feat(auth): validate agent context upstream

This commit is contained in:
2026-06-12 10:18:41 +08:00
parent 4b572d9264
commit 8857b18dc9
13 changed files with 247 additions and 57 deletions
+5
View File
@@ -18,6 +18,7 @@ export type SessionContext = {
clientSessionId: string;
accessToken?: string;
projectId?: string;
tokenExpiresAt?: string;
userId?: string;
};
@@ -37,6 +38,7 @@ export class ChatSessionBridge {
accessToken?: string;
projectId?: string;
traceId?: string;
tokenExpiresAt?: string;
userId?: string;
}): Promise<{
binding: SessionBinding;
@@ -72,6 +74,7 @@ export class ChatSessionBridge {
projectId: requestContext.projectId,
projectKey: requestContext.projectKey,
sessionId,
tokenExpiresAt: requestContext.tokenExpiresAt,
traceId: requestContext.traceId,
});
@@ -143,6 +146,7 @@ export class ChatSessionBridge {
accessToken?: string;
projectId?: string;
traceId?: string;
tokenExpiresAt?: string;
userId?: string;
}): ChatRequestContext {
const sessionId = context.sessionId?.trim();
@@ -152,6 +156,7 @@ export class ChatSessionBridge {
actorKey: toActorKey(context.userId),
projectId: context.projectId,
projectKey: toProjectKey(context.projectId),
tokenExpiresAt: context.tokenExpiresAt,
traceId: context.traceId?.trim() || `trace-${randomUUID().slice(0, 12)}`,
userId: context.userId?.trim(),
};