移除对 copilot 的兼容。更新示例和文档,统一使用 session_id 代替 conversationId
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import crypto from "node:crypto";
|
||||
|
||||
export type SessionBinding = {
|
||||
conversationId: string;
|
||||
clientSessionId: string;
|
||||
sessionId: string;
|
||||
lastUsedAt: number;
|
||||
};
|
||||
|
||||
export type SessionContext = {
|
||||
conversationId: string;
|
||||
clientSessionId: string;
|
||||
accessToken?: string;
|
||||
projectId?: string;
|
||||
};
|
||||
@@ -22,7 +22,7 @@ export class SessionRegistry {
|
||||
|
||||
upsert(context: SessionContext, sessionId: string): SessionBinding {
|
||||
const binding: SessionBinding = {
|
||||
conversationId: context.conversationId,
|
||||
clientSessionId: context.clientSessionId,
|
||||
sessionId,
|
||||
lastUsedAt: Date.now(),
|
||||
};
|
||||
@@ -62,12 +62,12 @@ export class SessionRegistry {
|
||||
}
|
||||
|
||||
private makeKey(context: SessionContext): string {
|
||||
// 会话隔离不能只看 conversationId;同一浏览器会话切换用户或项目时必须映射到不同 opencode session。
|
||||
// 会话隔离不能只看前端 session_id;同一浏览器会话切换用户或项目时必须映射到不同 opencode session。
|
||||
const digest = crypto
|
||||
.createHash("sha256")
|
||||
.update(
|
||||
[
|
||||
context.conversationId,
|
||||
context.clientSessionId,
|
||||
context.accessToken ?? "",
|
||||
context.projectId ?? "",
|
||||
].join("|"),
|
||||
|
||||
Reference in New Issue
Block a user