-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagentContext.ts
More file actions
34 lines (31 loc) · 1.21 KB
/
Copy pathagentContext.ts
File metadata and controls
34 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import type { AdminUser } from "adminforth";
import { z } from "zod";
import type { AgentEventEmitter } from "../domain/agentEvents.js";
import type { SequenceDebugCollector } from "./middleware/sequenceDebug.js";
import type { CurrentPageContext } from "../tools/getUserLocation.js";
import type { AgentTurnContext } from "../domain/turnTypes.js";
import type { DetectedLanguage } from "../domain/languageDetect.js";
export const contextSchema = z.object({
adminUser: z.custom<AdminUser>(),
userTimeZone: z.string(),
sessionId: z.string(),
turnId: z.string(),
abortSignal: z.custom<AbortSignal>().optional(),
currentPage: z.custom<CurrentPageContext>().optional(),
chatSurface: z.string().optional(),
adminBaseUrl: z.string().optional(),
adminPublicOrigin: z.string().optional(),
userLanguage: z.custom<DetectedLanguage | null>().optional(),
emit: z.custom<AgentEventEmitter>().optional(),
sequenceDebugSink: z.custom<SequenceDebugCollector>(),
});
export type AgentContext = z.infer<typeof contextSchema>;
export function toLangchainAgentContext(
context: AgentTurnContext & {
adminBaseUrl: string;
emit?: AgentEventEmitter;
sequenceDebugSink: SequenceDebugCollector;
},
) {
return context;
}