@adminforth/agent 1.43.28 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/agent/checkpointer.ts +2 -1
  2. package/agent/systemPrompt.ts +2 -1
  3. package/agentEvents.ts +61 -0
  4. package/agentResponseEvents.ts +1 -206
  5. package/apiBasedTools.ts +7 -3
  6. package/dist/agent/checkpointer.d.ts +29 -0
  7. package/dist/agent/languageDetect.d.ts +10 -0
  8. package/dist/agent/middleware/apiBasedTools.d.ts +3 -0
  9. package/dist/agent/middleware/openAiResponsesContinuation.d.ts +1 -0
  10. package/dist/agent/middleware/sequenceDebug.d.ts +46 -0
  11. package/dist/agent/simpleAgent.d.ts +61 -0
  12. package/dist/agent/skills/registry.d.ts +13 -0
  13. package/dist/agent/systemPrompt.d.ts +11 -0
  14. package/dist/agent/systemPrompt.js +3 -1
  15. package/dist/agent/toolCallEvents.d.ts +27 -0
  16. package/dist/agent/tools/apiTool.d.ts +6 -0
  17. package/dist/agent/tools/fetchSkill.d.ts +8 -0
  18. package/dist/agent/tools/fetchToolSchema.d.ts +9 -0
  19. package/dist/agent/tools/getUserLocation.d.ts +8 -0
  20. package/dist/agent/tools/index.d.ts +4 -0
  21. package/dist/agentEvents.d.ts +52 -0
  22. package/dist/agentEvents.js +1 -0
  23. package/dist/agentResponseEvents.d.ts +1 -0
  24. package/dist/agentResponseEvents.js +1 -144
  25. package/dist/apiBasedTools.d.ts +29 -0
  26. package/dist/apiBasedTools.js +5 -3
  27. package/dist/index.d.ts +58 -0
  28. package/dist/index.js +251 -59
  29. package/dist/sanitizeSpeechText.d.ts +1 -0
  30. package/dist/surfaces/web-sse/createSseEventEmitter.d.ts +14 -0
  31. package/dist/surfaces/web-sse/createSseEventEmitter.js +196 -0
  32. package/dist/types.d.ts +94 -0
  33. package/index.ts +279 -59
  34. package/package.json +2 -2
  35. package/surfaces/web-sse/createSseEventEmitter.ts +261 -0
  36. package/tsconfig.json +2 -1
  37. package/types.ts +6 -0
@@ -12,6 +12,7 @@ import type { PluginOptions } from "../types.js";
12
12
  import { Filters } from "adminforth";
13
13
 
14
14
  const ROOT_CHECKPOINT_NAMESPACE = "__root__";
15
+ type CheckpointRow = Record<string, unknown>;
15
16
 
16
17
  export class AdminForthCheckpointSaver extends BaseCheckpointSaver {
17
18
  constructor(
@@ -227,7 +228,7 @@ export class AdminForthCheckpointSaver extends BaseCheckpointSaver {
227
228
  [{ field: r.sequenceField, direction: "asc" }],
228
229
  );
229
230
 
230
- const pendingWrites: CheckpointPendingWrite[] = writesRows.flatMap((row) => {
231
+ const pendingWrites: CheckpointPendingWrite[] = writesRows.flatMap((row: CheckpointRow) => {
231
232
  const taskId = String(row[r.taskIdField] ?? "");
232
233
  const write = this.deserialize<PendingWrite>(row[r.writesPayloadField]);
233
234
  if (!write) {
@@ -95,8 +95,9 @@ export async function buildAgentSystemPrompt(
95
95
  adminforth: IAdminForth,
96
96
  hiddenResourceIds: Iterable<string> = [],
97
97
  ) {
98
+ const customComponentsDir = adminforth.config.customization.customComponentsDir ?? "custom";
98
99
  const [primarySkills, defaultSkills] = await Promise.all([
99
- listProjectSkillManifests(adminforth.config.customization.customComponentsDir),
100
+ listProjectSkillManifests(customComponentsDir),
100
101
  listBundledSkillManifests(),
101
102
  ]);
102
103
  const adminBasePath = adminforth.config.baseUrlSlashed;
package/agentEvents.ts ADDED
@@ -0,0 +1,61 @@
1
+ import type { ToolCallEvent } from "./agent/toolCallEvents.js";
2
+
3
+ export type AgentEvent =
4
+ | {
5
+ type: "turn-started";
6
+ messageId: string;
7
+ }
8
+ | {
9
+ type: "text-delta";
10
+ delta: string;
11
+ }
12
+ | {
13
+ type: "reasoning-delta";
14
+ delta: string;
15
+ }
16
+ | {
17
+ type: "tool-call";
18
+ data: ToolCallEvent;
19
+ }
20
+ | {
21
+ type: "transcript";
22
+ text: string;
23
+ language?: string;
24
+ }
25
+ | {
26
+ type: "response";
27
+ text: string;
28
+ sessionId: string;
29
+ turnId: string;
30
+ }
31
+ | {
32
+ type: "speech-response";
33
+ transcript: { text: string; language?: string };
34
+ response: { text: string };
35
+ sessionId: string;
36
+ turnId: string;
37
+ }
38
+ | {
39
+ type: "audio-start";
40
+ mimeType: string;
41
+ format: string;
42
+ sampleRate: number;
43
+ channelCount: number;
44
+ bitsPerSample: number;
45
+ }
46
+ | {
47
+ type: "audio-delta";
48
+ value: Uint8Array;
49
+ }
50
+ | {
51
+ type: "audio-done";
52
+ }
53
+ | {
54
+ type: "error";
55
+ error: string;
56
+ }
57
+ | {
58
+ type: "finish";
59
+ };
60
+
61
+ export type AgentEventEmitter = (event: AgentEvent) => void | Promise<void>;
@@ -1,206 +1 @@
1
- import { randomUUID } from "crypto";
2
-
3
- import type { ToolCallEvent } from "./agent/toolCallEvents.js";
4
-
5
- type AgentEventStreamResponse = {
6
- writeHead: (statusCode: number, headers: Record<string, string>) => void;
7
- write: (chunk: string) => unknown;
8
- end: () => unknown;
9
- writableEnded: boolean;
10
- destroyed: boolean;
11
- };
12
-
13
- type AgentEventStreamOptions = {
14
- vercelAiUiMessageStream?: boolean;
15
- closeActiveBlockOnToolStart?: boolean;
16
- };
17
-
18
- export function createAgentEventStream(
19
- res: AgentEventStreamResponse,
20
- options: AgentEventStreamOptions = {},
21
- ) {
22
- let isStreamClosed = false;
23
- let activeBlock: { type: "text" | "reasoning"; id: string } | null = null;
24
-
25
- res.writeHead(200, {
26
- "Content-Type": "text/event-stream",
27
- "Cache-Control": "no-cache",
28
- "Connection": "keep-alive",
29
- ...(options.vercelAiUiMessageStream
30
- ? { "x-vercel-ai-ui-message-stream": "v1" }
31
- : {}),
32
- });
33
-
34
- const stream = {
35
- send(obj: unknown) {
36
- if (isStreamClosed || res.writableEnded || res.destroyed) {
37
- return;
38
- }
39
-
40
- res.write(`data: ${JSON.stringify(obj)}\n\n`);
41
- },
42
-
43
- endActiveBlock() {
44
- if (!activeBlock) {
45
- return;
46
- }
47
-
48
- stream.send({
49
- type: `${activeBlock.type}-end`,
50
- id: activeBlock.id,
51
- });
52
-
53
- activeBlock = null;
54
- },
55
-
56
- startBlock(type: "text" | "reasoning") {
57
- if (activeBlock?.type === type) {
58
- return activeBlock.id;
59
- }
60
-
61
- stream.endActiveBlock();
62
-
63
- const id = randomUUID();
64
- activeBlock = { type, id };
65
-
66
- stream.send({
67
- type: `${type}-start`,
68
- id,
69
- });
70
-
71
- return id;
72
- },
73
-
74
- start(messageId: string) {
75
- stream.send({
76
- type: "start",
77
- messageId,
78
- });
79
- },
80
-
81
- textDelta(delta: string) {
82
- const textId = stream.startBlock("text");
83
- stream.send({
84
- type: "text-delta",
85
- id: textId,
86
- delta,
87
- });
88
- },
89
-
90
- reasoningDelta(delta: string) {
91
- const reasoningId = stream.startBlock("reasoning");
92
- stream.send({
93
- type: "reasoning-delta",
94
- id: reasoningId,
95
- delta,
96
- });
97
- },
98
-
99
- toolCall(event: ToolCallEvent) {
100
- if (options.closeActiveBlockOnToolStart && event.phase === "start") {
101
- stream.endActiveBlock();
102
- }
103
-
104
- stream.send({
105
- type: "data-tool-call",
106
- data: event,
107
- });
108
- },
109
-
110
- transcript(text: string, language?: string) {
111
- stream.send({
112
- type: "transcript",
113
- data: {
114
- text,
115
- language,
116
- },
117
- });
118
- },
119
-
120
- response(text: string, sessionId: string, turnId: string) {
121
- stream.send({
122
- type: "response",
123
- data: {
124
- text,
125
- sessionId,
126
- turnId,
127
- },
128
- });
129
- },
130
-
131
- speechResponse(
132
- transcript: { text: string; language?: string },
133
- response: { text: string },
134
- sessionId: string,
135
- turnId: string,
136
- ) {
137
- stream.send({
138
- type: "speech-response",
139
- data: {
140
- transcript,
141
- response,
142
- sessionId,
143
- turnId,
144
- },
145
- });
146
- },
147
-
148
- audioStart(
149
- mimeType: string,
150
- format: string,
151
- sampleRate: number,
152
- channelCount: number,
153
- bitsPerSample: number,
154
- ) {
155
- stream.send({
156
- type: "audio-start",
157
- data: {
158
- mimeType,
159
- format,
160
- sampleRate,
161
- channelCount,
162
- bitsPerSample,
163
- },
164
- });
165
- },
166
-
167
- audioDelta(value: Uint8Array) {
168
- stream.send({
169
- type: "audio-delta",
170
- data: {
171
- base64: Buffer.from(value).toString("base64"),
172
- },
173
- });
174
- },
175
-
176
- audioDone() {
177
- stream.send({
178
- type: "audio-done",
179
- });
180
- },
181
-
182
- error(error: string) {
183
- stream.send({
184
- type: "error",
185
- error,
186
- });
187
- },
188
-
189
- end() {
190
- if (isStreamClosed || res.writableEnded || res.destroyed) {
191
- return;
192
- }
193
-
194
- stream.endActiveBlock();
195
- stream.send({
196
- type: "finish",
197
- });
198
-
199
- res.write("data: [DONE]\n\n");
200
- isStreamClosed = true;
201
- res.end();
202
- },
203
- };
204
-
205
- return stream;
206
- }
1
+ export { createSseEventEmitter } from "./surfaces/web-sse/createSseEventEmitter.js";
package/apiBasedTools.ts CHANGED
@@ -169,6 +169,7 @@ export type ApiBasedToolCallParams = {
169
169
  abortSignal?: AbortSignal;
170
170
  inputs?: Record<string, unknown>;
171
171
  userTimeZone?: string;
172
+ acceptLanguage?: string;
172
173
  };
173
174
 
174
175
  export type ApiBasedTool = {
@@ -516,8 +517,9 @@ async function callOpenApiSchema(params: {
516
517
  schema: RegisteredApiToolSchema;
517
518
  toolName: string;
518
519
  userTimeZone?: string;
520
+ acceptLanguage?: string;
519
521
  }) {
520
- const { adminforth, adminUser, abortSignal, inputs, schema, toolName, userTimeZone } = params;
522
+ const { adminforth, adminUser, abortSignal, inputs, schema, toolName, userTimeZone, acceptLanguage } = params;
521
523
  const method = schema.method.toUpperCase();
522
524
  const normalizedInputs = normalizeDateTimeInputsToUtc(
523
525
  (inputs ?? {}) as Record<string, unknown>,
@@ -535,12 +537,13 @@ async function callOpenApiSchema(params: {
535
537
 
536
538
  const response = createDirectToolResponse();
537
539
  logger.info(`Calling OpenAPI tool "${toolName}" with direct handler`);
540
+ const lang = acceptLanguage ?? "en";
538
541
  const tr = (
539
542
  msg: string,
540
543
  category: string,
541
544
  trParams: unknown,
542
545
  pluralizationNumber?: number,
543
- ) => adminforth.tr(msg, category, undefined, trParams, pluralizationNumber);
546
+ ) => adminforth.tr(msg, category, lang, trParams, pluralizationNumber);
544
547
  const output = await schema.handler({
545
548
  body,
546
549
  query,
@@ -614,7 +617,7 @@ export function prepareApiBasedTools(
614
617
  description: schema.description,
615
618
  input_schema: schema.request_schema,
616
619
  output_schema: schema.response_schema,
617
- call: async ({ adminUser, adminuser, abortSignal, inputs, userTimeZone } = {}) => {
620
+ call: async ({ adminUser, adminuser, abortSignal, inputs, userTimeZone, acceptLanguage } = {}) => {
618
621
  if (isHiddenResourceCall(hiddenResourceIdSet, inputs)) {
619
622
  return YAML.stringify({
620
623
  error: 'RESOURCE_NOT_AVAILABLE',
@@ -630,6 +633,7 @@ export function prepareApiBasedTools(
630
633
  toolName,
631
634
  inputs,
632
635
  userTimeZone,
636
+ acceptLanguage,
633
637
  });
634
638
 
635
639
  const processedOutput = await applyToolOverride({
@@ -0,0 +1,29 @@
1
+ import type { RunnableConfig } from "@langchain/core/runnables";
2
+ import { BaseCheckpointSaver, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, type PendingWrite } from "@langchain/langgraph-checkpoint";
3
+ import type { PluginOptions } from "../types.js";
4
+ export declare class AdminForthCheckpointSaver extends BaseCheckpointSaver {
5
+ private readonly adminforth;
6
+ private readonly pluginOptions;
7
+ constructor(adminforth: any, pluginOptions: PluginOptions);
8
+ private get resourceConfig();
9
+ private resource;
10
+ private serialize;
11
+ private deserialize;
12
+ private now;
13
+ private encodeCheckpointNamespace;
14
+ private decodeCheckpointNamespace;
15
+ private getConfigValues;
16
+ private buildConfig;
17
+ private buildCheckpointRowId;
18
+ private buildWritesRowId;
19
+ private getWriteIndex;
20
+ private isDuplicateCheckpointWriteError;
21
+ put(config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata, _newVersions: Record<string, unknown>): Promise<RunnableConfig>;
22
+ putWrites(config: RunnableConfig, writes: PendingWrite[], taskId: string): Promise<void>;
23
+ getTuple(config: RunnableConfig): Promise<CheckpointTuple | undefined>;
24
+ list(config: RunnableConfig, options?: {
25
+ before?: RunnableConfig;
26
+ limit?: number;
27
+ }): AsyncGenerator<CheckpointTuple>;
28
+ deleteThread(threadId: string, checkpointNs?: string): Promise<void>;
29
+ }
@@ -0,0 +1,10 @@
1
+ import type { PluginOptions } from "../types.js";
2
+ export type DetectedLanguage = {
3
+ language: string;
4
+ code: string;
5
+ ambiguous: boolean;
6
+ };
7
+ export type PreviousUserMessage = {
8
+ text: string;
9
+ };
10
+ export declare function detectUserLanguage(completionAdapter: PluginOptions["modes"][number]["completionAdapter"], prompt: string, previousUserMessages?: PreviousUserMessage[]): Promise<DetectedLanguage | null>;
@@ -0,0 +1,3 @@
1
+ import { type IAdminForth } from "adminforth";
2
+ import { type ApiBasedTool } from "../../apiBasedTools.js";
3
+ export declare function createApiBasedToolsMiddleware(apiBasedTools: Record<string, ApiBasedTool>, adminforth: IAdminForth): import("langchain").AgentMiddleware<undefined, undefined, unknown, readonly (import("@langchain/core/tools").ClientTool | import("@langchain/core/tools").ServerTool)[]>;
@@ -0,0 +1 @@
1
+ export declare function createOpenAiResponsesContinuationMiddleware(): import("langchain").AgentMiddleware<undefined, undefined, unknown, readonly (import("@langchain/core/tools").ClientTool | import("@langchain/core/tools").ServerTool)[]>;
@@ -0,0 +1,46 @@
1
+ import type { ToolCallEvent } from "../toolCallEvents.js";
2
+ export type SequenceDebugResultType = "tool_calls" | "final_text";
3
+ type SequenceDebugToolCall = {
4
+ toolCallId: string;
5
+ toolName: string;
6
+ input: string;
7
+ output: string | null;
8
+ error: string | null;
9
+ };
10
+ export type SequenceDebug = {
11
+ sequenceId: number;
12
+ startedAt: string;
13
+ prompt: string;
14
+ promptTokens: number;
15
+ reasoning: string;
16
+ reasoningTokens: number;
17
+ text: string;
18
+ textTokens: number;
19
+ cachedTokens: number;
20
+ responseId: string | null;
21
+ toolCalls: SequenceDebugToolCall[];
22
+ endedAt: string;
23
+ resultType: SequenceDebugResultType;
24
+ };
25
+ type SequenceDebugModelCall = {
26
+ promptTokens: number;
27
+ reasoning: string;
28
+ reasoningTokens: number;
29
+ text: string;
30
+ textTokens: number;
31
+ cachedTokens: number;
32
+ responseId: string | null;
33
+ resultType: SequenceDebugResultType;
34
+ };
35
+ export type SequenceDebugModelCallSink = {
36
+ handleModelCallStart: (prompt: string) => void;
37
+ handleModelCallComplete: (params: SequenceDebugModelCall) => void;
38
+ };
39
+ export type SequenceDebugCollector = SequenceDebugModelCallSink & {
40
+ handleToolCallEvent: (event: ToolCallEvent) => void;
41
+ flush: () => void;
42
+ getHistory: () => SequenceDebug[];
43
+ };
44
+ export declare function createSequenceDebugCollector(): SequenceDebugCollector;
45
+ export declare function createSequenceDebugMiddleware(sink: SequenceDebugModelCallSink): import("langchain").AgentMiddleware<undefined, undefined, unknown, readonly (import("@langchain/core/tools").ClientTool | import("@langchain/core/tools").ServerTool)[]>;
46
+ export {};
@@ -0,0 +1,61 @@
1
+ import type { BaseChatModel } from "@langchain/core/language_models/chat_models";
2
+ import { type AdminUser, type CompletionAdapter, type IAdminForth } from "adminforth";
3
+ import { type BaseCheckpointSaver, type Messages } from "@langchain/langgraph";
4
+ import { z } from "zod";
5
+ import { createSequenceDebugMiddleware, type SequenceDebugModelCallSink } from "./middleware/sequenceDebug.js";
6
+ import type { ApiBasedTool } from "../apiBasedTools.js";
7
+ import type { ToolCallEventSink } from "./toolCallEvents.js";
8
+ import type { CurrentPageContext } from "./tools/getUserLocation.js";
9
+ export declare const contextSchema: z.ZodObject<{
10
+ adminUser: z.ZodCustom<AdminUser, AdminUser>;
11
+ userTimeZone: z.ZodString;
12
+ sessionId: z.ZodString;
13
+ turnId: z.ZodString;
14
+ abortSignal: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
15
+ currentPage: z.ZodOptional<z.ZodCustom<CurrentPageContext, CurrentPageContext>>;
16
+ emitToolCallEvent: z.ZodCustom<ToolCallEventSink, ToolCallEventSink>;
17
+ }, z.core.$strip>;
18
+ export type AgentChatModel = BaseChatModel<any, any>;
19
+ export type AgentModelPurpose = "primary" | "summary";
20
+ export type AgentModeCompletionAdapter = CompletionAdapter & {
21
+ getLangChainAgentSpec(params: {
22
+ maxTokens: number;
23
+ purpose: AgentModelPurpose;
24
+ }): Promise<{
25
+ model: unknown;
26
+ middleware?: unknown[];
27
+ }> | {
28
+ model: unknown;
29
+ middleware?: unknown[];
30
+ };
31
+ };
32
+ type AgentMiddleware = ReturnType<typeof createSequenceDebugMiddleware>;
33
+ type AgentChatModelSpec = {
34
+ model: AgentChatModel;
35
+ middleware: AgentMiddleware[];
36
+ };
37
+ export declare function createAgentChatModel(params: {
38
+ adapter: CompletionAdapter;
39
+ maxTokens: number;
40
+ purpose: AgentModelPurpose;
41
+ }): Promise<AgentChatModelSpec>;
42
+ export declare function callAgent(params: {
43
+ name: string;
44
+ model: AgentChatModel;
45
+ summaryModel: AgentChatModel;
46
+ modelMiddleware?: AgentMiddleware[];
47
+ checkpointer?: BaseCheckpointSaver;
48
+ messages: Messages;
49
+ adminUser: AdminUser;
50
+ adminforth: IAdminForth;
51
+ apiBasedTools: Record<string, ApiBasedTool>;
52
+ customComponentsDir: string;
53
+ sessionId: string;
54
+ turnId: string;
55
+ currentPage?: CurrentPageContext;
56
+ userTimeZone: string;
57
+ abortSignal?: AbortSignal;
58
+ emitToolCallEvent: ToolCallEventSink;
59
+ sequenceDebugSink: SequenceDebugModelCallSink;
60
+ }): Promise<import("@langchain/core/utils/stream").IterableReadableStream<[import("langchain").BaseMessage<import("@langchain/core/messages").MessageStructure<import("@langchain/core/messages").MessageToolSet>, import("@langchain/core/messages").MessageType>, Record<string, any>]>>;
61
+ export {};
@@ -0,0 +1,13 @@
1
+ export interface AgentSkillManifest {
2
+ directoryName: string;
3
+ name: string;
4
+ description: string;
5
+ instructions: string;
6
+ }
7
+ export declare function getProjectSkillsDirectoryPath(customComponentsDir: string): string;
8
+ export declare function getProjectPluginSkillsDirectoryPath(customComponentsDir: string): string;
9
+ export declare function listBundledSkillManifests(): Promise<AgentSkillManifest[]>;
10
+ export declare function listProjectSkillManifests(customComponentsDir: string): Promise<AgentSkillManifest[]>;
11
+ export declare function listSkillManifests(customComponentsDir: string): Promise<AgentSkillManifest[]>;
12
+ export declare function loadSkillManifest(skillName: string, customComponentsDir: string): Promise<AgentSkillManifest | null>;
13
+ export declare function loadSkillMarkdown(skillName: string, customComponentsDir: string): Promise<string | null>;
@@ -0,0 +1,11 @@
1
+ import type { AdminUser, IAdminForth } from "adminforth";
2
+ import type { DetectedLanguage } from "./languageDetect.js";
3
+ export declare const DEFAULT_AGENT_SYSTEM_PROMPT: string;
4
+ export declare function appendCustomSystemPrompt(systemPrompt: string, customSystemPrompt?: string): string;
5
+ export declare function buildAgentTurnSystemPrompt(input: {
6
+ agentSystemPrompt: string;
7
+ adminUser: AdminUser;
8
+ usernameField: string;
9
+ userLanguage: DetectedLanguage | null;
10
+ }): string;
11
+ export declare function buildAgentSystemPrompt(adminforth: IAdminForth, hiddenResourceIds?: Iterable<string>): Promise<string>;
@@ -73,8 +73,10 @@ function formatSkills(skills, label) {
73
73
  }
74
74
  export function buildAgentSystemPrompt(adminforth_1) {
75
75
  return __awaiter(this, arguments, void 0, function* (adminforth, hiddenResourceIds = []) {
76
+ var _a;
77
+ const customComponentsDir = (_a = adminforth.config.customization.customComponentsDir) !== null && _a !== void 0 ? _a : "custom";
76
78
  const [primarySkills, defaultSkills] = yield Promise.all([
77
- listProjectSkillManifests(adminforth.config.customization.customComponentsDir),
79
+ listProjectSkillManifests(customComponentsDir),
78
80
  listBundledSkillManifests(),
79
81
  ]);
80
82
  const adminBasePath = adminforth.config.baseUrlSlashed;
@@ -0,0 +1,27 @@
1
+ export type ToolCallEvent = {
2
+ toolCallId: string;
3
+ toolName: string;
4
+ toolInfo?: string;
5
+ phase: "start";
6
+ input: string;
7
+ } | {
8
+ toolCallId: string;
9
+ toolName: string;
10
+ phase: "end";
11
+ durationMs: number;
12
+ output: string | null;
13
+ error: string | null;
14
+ };
15
+ export type ToolCallEventSink = (event: ToolCallEvent) => void;
16
+ export declare function createToolCallTracker(params: {
17
+ emit: ToolCallEventSink;
18
+ toolCallId?: string;
19
+ toolName: string;
20
+ toolInfo?: string;
21
+ input?: Record<string, unknown>;
22
+ startedAt?: number;
23
+ }): {
24
+ start(): void;
25
+ finishSuccess(output: unknown): void;
26
+ finishError(error: unknown): void;
27
+ };
@@ -0,0 +1,6 @@
1
+ import type { ApiBasedTool } from "../../apiBasedTools.js";
2
+ export declare function createApiTool(toolName: string, apiBasedTool: ApiBasedTool): import("langchain").DynamicStructuredTool<Record<string, unknown> | {
3
+ readonly type: "object";
4
+ readonly properties: {};
5
+ readonly additionalProperties: true;
6
+ }, unknown, unknown, string, unknown, string>;
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ export declare function createFetchSkillTool(customComponentsDir: string): Promise<import("langchain").DynamicStructuredTool<z.ZodObject<{
3
+ skillName: z.ZodString;
4
+ }, z.core.$strip>, {
5
+ skillName: string;
6
+ }, {
7
+ skillName: string;
8
+ }, string, unknown, "fetch_skill">>;
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ import { type ApiBasedTool } from "../../apiBasedTools.js";
3
+ export declare function createFetchToolSchemaTool(apiBasedTools: Record<string, ApiBasedTool>): Promise<import("langchain").DynamicStructuredTool<z.ZodObject<{
4
+ toolName: z.ZodString;
5
+ }, z.core.$strip>, {
6
+ toolName: string;
7
+ }, {
8
+ toolName: string;
9
+ }, string, unknown, "fetch_tool_schema">>;
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+ export type CurrentPageContext = {
3
+ path: string;
4
+ fullPath: string;
5
+ title: string;
6
+ url: string;
7
+ };
8
+ export declare function createGetUserLocationTool(): import("langchain").DynamicStructuredTool<z.ZodObject<{}, z.core.$strip>, Record<string, never>, Record<string, never>, string, unknown, "get_user_location">;
@@ -0,0 +1,4 @@
1
+ import type { ClientTool } from "@langchain/core/tools";
2
+ import type { ApiBasedTool } from "../../apiBasedTools.js";
3
+ export declare const ALWAYS_AVAILABLE_API_TOOL_NAMES: readonly ["get_resource"];
4
+ export declare function createAgentTools(customComponentsDir: string, apiBasedTools: Record<string, ApiBasedTool>): Promise<ClientTool[]>;
@@ -0,0 +1,52 @@
1
+ import type { ToolCallEvent } from "./agent/toolCallEvents.js";
2
+ export type AgentEvent = {
3
+ type: "turn-started";
4
+ messageId: string;
5
+ } | {
6
+ type: "text-delta";
7
+ delta: string;
8
+ } | {
9
+ type: "reasoning-delta";
10
+ delta: string;
11
+ } | {
12
+ type: "tool-call";
13
+ data: ToolCallEvent;
14
+ } | {
15
+ type: "transcript";
16
+ text: string;
17
+ language?: string;
18
+ } | {
19
+ type: "response";
20
+ text: string;
21
+ sessionId: string;
22
+ turnId: string;
23
+ } | {
24
+ type: "speech-response";
25
+ transcript: {
26
+ text: string;
27
+ language?: string;
28
+ };
29
+ response: {
30
+ text: string;
31
+ };
32
+ sessionId: string;
33
+ turnId: string;
34
+ } | {
35
+ type: "audio-start";
36
+ mimeType: string;
37
+ format: string;
38
+ sampleRate: number;
39
+ channelCount: number;
40
+ bitsPerSample: number;
41
+ } | {
42
+ type: "audio-delta";
43
+ value: Uint8Array;
44
+ } | {
45
+ type: "audio-done";
46
+ } | {
47
+ type: "error";
48
+ error: string;
49
+ } | {
50
+ type: "finish";
51
+ };
52
+ export type AgentEventEmitter = (event: AgentEvent) => void | Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { createSseEventEmitter } from "./surfaces/web-sse/createSseEventEmitter.js";