@truefoundry/trueforge-core 0.2.0-rc.4 → 0.2.0-rc.6
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.
- package/dist/agent-session/ITurnResourceResolver.d.ts +6 -0
- package/dist/agent-session/ITurnResourceResolver.d.ts.map +1 -1
- package/dist/agent-session/ITurnResourceResolver.js.map +1 -1
- package/dist/agent-session/SessionHandle.d.ts.map +1 -1
- package/dist/agent-session/SessionHandle.js +2 -0
- package/dist/agent-session/SessionHandle.js.map +1 -1
- package/dist/agent-session/SessionHandle.mjs +2 -0
- package/dist/agent-session/SessionHandle.mjs.map +1 -1
- package/dist/agent-session/TurnResourceResolver.d.ts +8 -0
- package/dist/agent-session/TurnResourceResolver.d.ts.map +1 -1
- package/dist/agent-session/TurnResourceResolver.js +4 -0
- package/dist/agent-session/TurnResourceResolver.js.map +1 -1
- package/dist/agent-session/TurnResourceResolver.mjs +4 -0
- package/dist/agent-session/TurnResourceResolver.mjs.map +1 -1
- package/dist/agent-session/builtinsFromSpec.d.ts +2 -0
- package/dist/agent-session/builtinsFromSpec.d.ts.map +1 -1
- package/dist/agent-session/builtinsFromSpec.js +5 -1
- package/dist/agent-session/builtinsFromSpec.js.map +1 -1
- package/dist/agent-session/builtinsFromSpec.mjs +5 -1
- package/dist/agent-session/builtinsFromSpec.mjs.map +1 -1
- package/dist/agent-session/index.d.ts +2 -2
- package/dist/agent-session/index.d.ts.map +1 -1
- package/dist/agent-session/index.js +2 -0
- package/dist/agent-session/index.js.map +1 -1
- package/dist/agent-session/index.mjs +3 -1
- package/dist/agent-session/index.mjs.map +1 -1
- package/dist/agent-session/schemas/agentSpec.d.ts +6 -0
- package/dist/agent-session/schemas/agentSpec.d.ts.map +1 -1
- package/dist/agent-session/schemas/agentSpec.js +7 -3
- package/dist/agent-session/schemas/agentSpec.js.map +1 -1
- package/dist/agent-session/schemas/agentSpec.mjs +7 -3
- package/dist/agent-session/schemas/agentSpec.mjs.map +1 -1
- package/dist/agent-session/schemas/events.d.ts +65 -2
- package/dist/agent-session/schemas/events.d.ts.map +1 -1
- package/dist/agent-session/schemas/events.js +32 -2
- package/dist/agent-session/schemas/events.js.map +1 -1
- package/dist/agent-session/schemas/events.mjs +26 -1
- package/dist/agent-session/schemas/events.mjs.map +1 -1
- package/dist/agent-session/schemas/session.d.ts +9 -0
- package/dist/agent-session/schemas/session.d.ts.map +1 -1
- package/dist/core/capabilities/builtins/WebSearch.d.ts +32 -0
- package/dist/core/capabilities/builtins/WebSearch.d.ts.map +1 -0
- package/dist/core/capabilities/builtins/WebSearch.js +137 -0
- package/dist/core/capabilities/builtins/WebSearch.js.map +1 -0
- package/dist/core/capabilities/builtins/WebSearch.mjs +96 -0
- package/dist/core/capabilities/builtins/WebSearch.mjs.map +1 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +22 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +20 -0
- package/dist/core/index.mjs.map +1 -1
- package/dist/core/mcp/RemoteMCP.d.ts +2 -0
- package/dist/core/mcp/RemoteMCP.d.ts.map +1 -1
- package/dist/core/mcp/RemoteMCP.js +11 -1
- package/dist/core/mcp/RemoteMCP.js.map +1 -1
- package/dist/core/mcp/RemoteMCP.mjs +12 -1
- package/dist/core/mcp/RemoteMCP.mjs.map +1 -1
- package/dist/core/mcp/ToolSelectorPolicy.d.ts +1 -1
- package/dist/core/mcp/ToolSelectorPolicy.js +1 -1
- package/dist/core/mcp/ToolSelectorPolicy.js.map +1 -1
- package/dist/core/mcp/ToolSelectorPolicy.mjs +1 -1
- package/dist/core/mcp/ToolSelectorPolicy.mjs.map +1 -1
- package/dist/core/mcp/remoteMcpClient.d.ts +5 -0
- package/dist/core/mcp/remoteMcpClient.d.ts.map +1 -1
- package/dist/core/mcp/remoteMcpClient.js +49 -7
- package/dist/core/mcp/remoteMcpClient.js.map +1 -1
- package/dist/core/mcp/remoteMcpClient.mjs +46 -6
- package/dist/core/mcp/remoteMcpClient.mjs.map +1 -1
- package/dist/core/mcp/toolSelectors.d.ts.map +1 -1
- package/dist/core/mcp/toolSelectors.js +1 -1
- package/dist/core/mcp/toolSelectors.js.map +1 -1
- package/dist/core/mcp/toolSelectors.mjs +1 -1
- package/dist/core/mcp/toolSelectors.mjs.map +1 -1
- package/dist/core/web-search/ParallelWebSearchProvider.d.ts +24 -0
- package/dist/core/web-search/ParallelWebSearchProvider.d.ts.map +1 -0
- package/dist/core/web-search/ParallelWebSearchProvider.js +95 -0
- package/dist/core/web-search/ParallelWebSearchProvider.js.map +1 -0
- package/dist/core/web-search/ParallelWebSearchProvider.mjs +62 -0
- package/dist/core/web-search/ParallelWebSearchProvider.mjs.map +1 -0
- package/dist/core/web-search/WebSearchProvider.d.ts +42 -0
- package/dist/core/web-search/WebSearchProvider.d.ts.map +1 -0
- package/dist/core/web-search/WebSearchProvider.js +34 -0
- package/dist/core/web-search/WebSearchProvider.js.map +1 -0
- package/dist/core/web-search/WebSearchProvider.mjs +9 -0
- package/dist/core/web-search/WebSearchProvider.mjs.map +1 -0
- package/dist/request-reply/client.d.ts +2 -2
- package/dist/request-reply/client.d.ts.map +1 -1
- package/dist/request-reply/client.js +3 -0
- package/dist/request-reply/client.js.map +1 -1
- package/dist/request-reply/client.mjs +3 -0
- package/dist/request-reply/client.mjs.map +1 -1
- package/package.json +3 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Turn/session event product schemas. Event payloads come from the harness; this
|
|
3
|
-
* module owns turn lifecycle events (turn.created / turn.done) and
|
|
4
|
-
* event unions the store writes. SSE streaming envelopes stay in
|
|
3
|
+
* module owns turn lifecycle events (turn.created / turn.update / turn.done) and
|
|
4
|
+
* the persisted event unions the store writes. SSE streaming envelopes stay in
|
|
5
|
+
* server/schemas.
|
|
5
6
|
*/
|
|
6
7
|
import { z } from '@hono/zod-openapi';
|
|
7
8
|
import type { WithRegisteredPassthrough } from '../../core/events/PassthroughEvents';
|
|
@@ -22,6 +23,7 @@ export declare const EventType: {
|
|
|
22
23
|
readonly USER_TOOL_RESPONSE: 'user.tool_response';
|
|
23
24
|
readonly USER_MESSAGE: 'user.message';
|
|
24
25
|
readonly TURN_CREATED: 'turn.created';
|
|
26
|
+
readonly TURN_UPDATE: 'turn.update';
|
|
25
27
|
readonly TURN_DONE: 'turn.done';
|
|
26
28
|
};
|
|
27
29
|
export declare const TurnCreatedEventSchema: z.ZodObject<{
|
|
@@ -189,6 +191,40 @@ export declare const TurnDoneEventSchema: z.ZodObject<{
|
|
|
189
191
|
created_at: z.ZodString;
|
|
190
192
|
thread_id: z.ZodNullable<z.ZodString>;
|
|
191
193
|
}, z.core.$strip>;
|
|
194
|
+
export declare const ActionRequiredSchema: z.ZodObject<{
|
|
195
|
+
id: z.ZodString;
|
|
196
|
+
}, z.core.$strip>;
|
|
197
|
+
export declare const TurnUpdateStatePausedSchema: z.ZodObject<{
|
|
198
|
+
status: z.ZodLiteral<"paused">;
|
|
199
|
+
action_required_on_events: z.ZodArray<z.ZodObject<{
|
|
200
|
+
id: z.ZodString;
|
|
201
|
+
}, z.core.$strip>>;
|
|
202
|
+
}, z.core.$strip>;
|
|
203
|
+
export declare const TurnUpdateStateRunningSchema: z.ZodObject<{
|
|
204
|
+
status: z.ZodLiteral<"running">;
|
|
205
|
+
}, z.core.$strip>;
|
|
206
|
+
export declare const TurnUpdateStateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
207
|
+
status: z.ZodLiteral<"paused">;
|
|
208
|
+
action_required_on_events: z.ZodArray<z.ZodObject<{
|
|
209
|
+
id: z.ZodString;
|
|
210
|
+
}, z.core.$strip>>;
|
|
211
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
212
|
+
status: z.ZodLiteral<"running">;
|
|
213
|
+
}, z.core.$strip>], "status">;
|
|
214
|
+
export declare const TurnUpdateEventSchema: z.ZodObject<{
|
|
215
|
+
type: z.ZodLiteral<"turn.update">;
|
|
216
|
+
id: z.ZodString;
|
|
217
|
+
state: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
218
|
+
status: z.ZodLiteral<"paused">;
|
|
219
|
+
action_required_on_events: z.ZodArray<z.ZodObject<{
|
|
220
|
+
id: z.ZodString;
|
|
221
|
+
}, z.core.$strip>>;
|
|
222
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
223
|
+
status: z.ZodLiteral<"running">;
|
|
224
|
+
}, z.core.$strip>], "status">;
|
|
225
|
+
created_at: z.ZodString;
|
|
226
|
+
thread_id: z.ZodNullable<z.ZodString>;
|
|
227
|
+
}, z.core.$strip>;
|
|
192
228
|
/** Built-in durable turn events — lifecycle + content; no deltas, no passthrough. */
|
|
193
229
|
export declare const SessionEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
194
230
|
type: z.ZodLiteral<"turn.created">;
|
|
@@ -226,6 +262,19 @@ export declare const SessionEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
226
262
|
}, z.core.$strip>;
|
|
227
263
|
created_at: z.ZodString;
|
|
228
264
|
thread_id: z.ZodNullable<z.ZodString>;
|
|
265
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
266
|
+
type: z.ZodLiteral<"turn.update">;
|
|
267
|
+
id: z.ZodString;
|
|
268
|
+
state: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
269
|
+
status: z.ZodLiteral<"paused">;
|
|
270
|
+
action_required_on_events: z.ZodArray<z.ZodObject<{
|
|
271
|
+
id: z.ZodString;
|
|
272
|
+
}, z.core.$strip>>;
|
|
273
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
274
|
+
status: z.ZodLiteral<"running">;
|
|
275
|
+
}, z.core.$strip>], "status">;
|
|
276
|
+
created_at: z.ZodString;
|
|
277
|
+
thread_id: z.ZodNullable<z.ZodString>;
|
|
229
278
|
}, z.core.$strip>, z.ZodObject<{
|
|
230
279
|
type: z.ZodLiteral<"turn.done">;
|
|
231
280
|
id: z.ZodString;
|
|
@@ -641,6 +690,19 @@ export declare const SessionEventItemSchema: z.ZodObject<{
|
|
|
641
690
|
}, z.core.$strip>;
|
|
642
691
|
created_at: z.ZodString;
|
|
643
692
|
thread_id: z.ZodNullable<z.ZodString>;
|
|
693
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
694
|
+
type: z.ZodLiteral<"turn.update">;
|
|
695
|
+
id: z.ZodString;
|
|
696
|
+
state: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
697
|
+
status: z.ZodLiteral<"paused">;
|
|
698
|
+
action_required_on_events: z.ZodArray<z.ZodObject<{
|
|
699
|
+
id: z.ZodString;
|
|
700
|
+
}, z.core.$strip>>;
|
|
701
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
702
|
+
status: z.ZodLiteral<"running">;
|
|
703
|
+
}, z.core.$strip>], "status">;
|
|
704
|
+
created_at: z.ZodString;
|
|
705
|
+
thread_id: z.ZodNullable<z.ZodString>;
|
|
644
706
|
}, z.core.$strip>, z.ZodObject<{
|
|
645
707
|
type: z.ZodLiteral<"turn.done">;
|
|
646
708
|
id: z.ZodString;
|
|
@@ -1019,6 +1081,7 @@ export declare const SessionEventItemSchema: z.ZodObject<{
|
|
|
1019
1081
|
}, z.core.$strip>], "type">;
|
|
1020
1082
|
}, z.core.$strip>;
|
|
1021
1083
|
export type TurnCreatedEvent = z.infer<typeof TurnCreatedEventSchema>;
|
|
1084
|
+
export type TurnUpdateEvent = z.infer<typeof TurnUpdateEventSchema>;
|
|
1022
1085
|
export type TurnDoneEvent = z.infer<typeof TurnDoneEventSchema>;
|
|
1023
1086
|
export type SessionEvent = z.infer<typeof SessionEventSchema>;
|
|
1024
1087
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/agent-session/schemas/events.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../../src/agent-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C;CAC3B"}
|
|
@@ -20,11 +20,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/agent-session/schemas/events.ts
|
|
21
21
|
var events_exports = {};
|
|
22
22
|
__export(events_exports, {
|
|
23
|
+
ActionRequiredSchema: () => ActionRequiredSchema,
|
|
23
24
|
EventType: () => EventType,
|
|
24
25
|
SessionEventItemSchema: () => SessionEventItemSchema,
|
|
25
26
|
SessionEventSchema: () => SessionEventSchema,
|
|
26
27
|
TurnCreatedEventSchema: () => TurnCreatedEventSchema,
|
|
27
|
-
TurnDoneEventSchema: () => TurnDoneEventSchema
|
|
28
|
+
TurnDoneEventSchema: () => TurnDoneEventSchema,
|
|
29
|
+
TurnUpdateEventSchema: () => TurnUpdateEventSchema,
|
|
30
|
+
TurnUpdateStatePausedSchema: () => TurnUpdateStatePausedSchema,
|
|
31
|
+
TurnUpdateStateRunningSchema: () => TurnUpdateStateRunningSchema,
|
|
32
|
+
TurnUpdateStateSchema: () => TurnUpdateStateSchema
|
|
28
33
|
});
|
|
29
34
|
module.exports = __toCommonJS(events_exports);
|
|
30
35
|
var import_zod_openapi = require("@hono/zod-openapi");
|
|
@@ -33,6 +38,7 @@ var import_turn = require("./turn.js");
|
|
|
33
38
|
var EventType = {
|
|
34
39
|
...import_schema.EventType,
|
|
35
40
|
TURN_CREATED: "turn.created",
|
|
41
|
+
TURN_UPDATE: "turn.update",
|
|
36
42
|
TURN_DONE: "turn.done"
|
|
37
43
|
};
|
|
38
44
|
var TurnCreatedEventSchema = import_zod_openapi.z.object({
|
|
@@ -52,8 +58,27 @@ var TurnDoneEventSchema = import_zod_openapi.z.object({
|
|
|
52
58
|
created_at: import_zod_openapi.z.string().describe("ISO 8601 event timestamp."),
|
|
53
59
|
thread_id: import_zod_openapi.z.string().nullable().describe("Thread that owns the event; null for turn-level lifecycle events.")
|
|
54
60
|
}).openapi("TurnDoneEvent");
|
|
61
|
+
var ActionRequiredSchema = import_zod_openapi.z.object({
|
|
62
|
+
id: import_schema.EventIdSchema
|
|
63
|
+
}).openapi("ActionRequired");
|
|
64
|
+
var TurnUpdateStatePausedSchema = import_zod_openapi.z.object({
|
|
65
|
+
status: import_zod_openapi.z.literal("paused").describe("Turn is paused waiting for required actions."),
|
|
66
|
+
action_required_on_events: import_zod_openapi.z.array(ActionRequiredSchema).describe("Events that still need a user or client action.")
|
|
67
|
+
}).openapi("TurnUpdateStatePaused");
|
|
68
|
+
var TurnUpdateStateRunningSchema = import_zod_openapi.z.object({
|
|
69
|
+
status: import_zod_openapi.z.literal("running").describe("Turn is executing.")
|
|
70
|
+
}).openapi("TurnUpdateStateRunning");
|
|
71
|
+
var TurnUpdateStateSchema = import_zod_openapi.z.discriminatedUnion("status", [TurnUpdateStatePausedSchema, TurnUpdateStateRunningSchema]).describe("Live non-terminal turn status.").openapi("TurnUpdateState");
|
|
72
|
+
var TurnUpdateEventSchema = import_zod_openapi.z.object({
|
|
73
|
+
type: import_zod_openapi.z.literal(EventType.TURN_UPDATE).describe("Emitted when a turn pauses or resumes."),
|
|
74
|
+
id: import_schema.EventIdSchema,
|
|
75
|
+
state: TurnUpdateStateSchema,
|
|
76
|
+
created_at: import_zod_openapi.z.string().describe("ISO 8601 event timestamp."),
|
|
77
|
+
thread_id: import_zod_openapi.z.string().nullable().describe("Thread that owns the event; null for turn-level lifecycle events.")
|
|
78
|
+
}).openapi("TurnUpdateEvent");
|
|
55
79
|
var SessionEventSchema = import_zod_openapi.z.discriminatedUnion("type", [
|
|
56
80
|
TurnCreatedEventSchema,
|
|
81
|
+
TurnUpdateEventSchema,
|
|
57
82
|
TurnDoneEventSchema,
|
|
58
83
|
import_schema.ModelMessageEventSchema,
|
|
59
84
|
import_schema.ToolResponseEventSchema,
|
|
@@ -71,10 +96,15 @@ var SessionEventItemSchema = import_zod_openapi.z.object({
|
|
|
71
96
|
}).openapi("SessionEventItem");
|
|
72
97
|
// Annotate the CommonJS export names for ESM import in node:
|
|
73
98
|
0 && (module.exports = {
|
|
99
|
+
ActionRequiredSchema,
|
|
74
100
|
EventType,
|
|
75
101
|
SessionEventItemSchema,
|
|
76
102
|
SessionEventSchema,
|
|
77
103
|
TurnCreatedEventSchema,
|
|
78
|
-
TurnDoneEventSchema
|
|
104
|
+
TurnDoneEventSchema,
|
|
105
|
+
TurnUpdateEventSchema,
|
|
106
|
+
TurnUpdateStatePausedSchema,
|
|
107
|
+
TurnUpdateStateRunningSchema,
|
|
108
|
+
TurnUpdateStateSchema
|
|
79
109
|
});
|
|
80
110
|
//# sourceMappingURL=events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/agent-session/schemas/events.ts"],"sourcesContent":["/**\n * Turn/session event product schemas. Event payloads come from the harness; this\n * module owns turn lifecycle events (turn.created / turn.done) and the persisted
|
|
1
|
+
{"version":3,"sources":["../../../src/agent-session/schemas/events.ts"],"sourcesContent":["/**\n * Turn/session event product schemas. Event payloads come from the harness; this\n * module owns turn lifecycle events (turn.created / turn.update / turn.done) and\n * the persisted event unions the store writes. SSE streaming envelopes stay in\n * server/schemas.\n */\nimport { z } from '@hono/zod-openapi';\nimport type { WithRegisteredPassthrough } from '../../core/events/PassthroughEvents';\nimport {\n EventIdSchema,\n EventType as HarnessEventType,\n MCPAuthRequiredEventSchema,\n MCPInitializeEventSchema,\n ModelMessageEventSchema,\n SandboxCreatedEventSchema,\n ThreadCreatedEventSchema,\n ThreadDoneEventSchema,\n ToolApprovalRequiredEventSchema,\n ToolResponseEventSchema,\n ToolResponseRequiredEventSchema,\n} from '../../core/events/schema';\nimport {\n TurnInputItemSchema,\n TurnStateCancelledSchema,\n TurnStateDoneSchema,\n TurnStateErrorSchema,\n TurnStateRunningSchema,\n} from './turn';\n\n/** Harness event types plus the turn lifecycle types owned by agentSession. */\nexport const EventType = {\n ...HarnessEventType,\n TURN_CREATED: 'turn.created',\n TURN_UPDATE: 'turn.update',\n TURN_DONE: 'turn.done',\n} as const;\n\nexport const TurnCreatedEventSchema = z\n .object({\n type: z.literal(EventType.TURN_CREATED).describe('Emitted when a turn starts.'),\n id: EventIdSchema,\n turn_id: z.string().describe('Id of the newly created turn.'),\n previous_turn_id: z.string().nullable().describe('Prior turn this turn chains from; null for a root turn.'),\n input: z.array(TurnInputItemSchema).optional().describe('Input items supplied when the turn was created.'),\n state: TurnStateRunningSchema,\n created_at: z.string().describe('ISO 8601 event timestamp.'),\n thread_id: z.string().nullable().describe('Thread that owns the event; null for turn-level lifecycle events.'),\n })\n .openapi('TurnCreatedEvent');\n\nexport const TurnDoneEventSchema = z\n .object({\n type: z.literal(EventType.TURN_DONE).describe('Emitted when a turn reaches a terminal state.'),\n id: EventIdSchema,\n state: z\n .discriminatedUnion('status', [TurnStateDoneSchema, TurnStateCancelledSchema, TurnStateErrorSchema])\n .describe('Terminal turn state (done, cancelled, or error).'),\n created_at: z.string().describe('ISO 8601 event timestamp.'),\n thread_id: z.string().nullable().describe('Thread that owns the event; null for turn-level lifecycle events.'),\n })\n .openapi('TurnDoneEvent');\n\nexport const ActionRequiredSchema = z\n .object({\n id: EventIdSchema,\n })\n .openapi('ActionRequired');\n\nexport const TurnUpdateStatePausedSchema = z\n .object({\n status: z.literal('paused').describe('Turn is paused waiting for required actions.'),\n action_required_on_events: z\n .array(ActionRequiredSchema)\n .describe('Events that still need a user or client action.'),\n })\n .openapi('TurnUpdateStatePaused');\n\nexport const TurnUpdateStateRunningSchema = z\n .object({\n status: z.literal('running').describe('Turn is executing.'),\n })\n .openapi('TurnUpdateStateRunning');\n\nexport const TurnUpdateStateSchema = z\n .discriminatedUnion('status', [TurnUpdateStatePausedSchema, TurnUpdateStateRunningSchema])\n .describe('Live non-terminal turn status.')\n .openapi('TurnUpdateState');\n\nexport const TurnUpdateEventSchema = z\n .object({\n type: z.literal(EventType.TURN_UPDATE).describe('Emitted when a turn pauses or resumes.'),\n id: EventIdSchema,\n state: TurnUpdateStateSchema,\n created_at: z.string().describe('ISO 8601 event timestamp.'),\n thread_id: z.string().nullable().describe('Thread that owns the event; null for turn-level lifecycle events.'),\n })\n .openapi('TurnUpdateEvent');\n\n/** Built-in durable turn events — lifecycle + content; no deltas, no passthrough. */\nexport const SessionEventSchema = z\n .discriminatedUnion('type', [\n TurnCreatedEventSchema,\n TurnUpdateEventSchema,\n TurnDoneEventSchema,\n ModelMessageEventSchema,\n ToolResponseEventSchema,\n ThreadCreatedEventSchema,\n ThreadDoneEventSchema,\n MCPAuthRequiredEventSchema,\n MCPInitializeEventSchema,\n SandboxCreatedEventSchema,\n ToolApprovalRequiredEventSchema,\n ToolResponseRequiredEventSchema,\n ])\n .openapi('SessionEvent');\n\n/** One row on the session timeline: which turn emitted the event plus the event payload. */\nexport const SessionEventItemSchema = z\n .object({\n turn_id: z.string().describe('Turn that emitted this event.'),\n event: SessionEventSchema,\n })\n .openapi('SessionEventItem');\n\nexport type TurnCreatedEvent = z.infer<typeof TurnCreatedEventSchema>;\nexport type TurnUpdateEvent = z.infer<typeof TurnUpdateEventSchema>;\nexport type TurnDoneEvent = z.infer<typeof TurnDoneEventSchema>;\nexport type SessionEvent = z.infer<typeof SessionEventSchema>;\n/**\n * Durable turn event log entries: {@link SessionEvent} plus any registered\n * passthrough events. Every merged event must carry its monotonic ULID and\n * creation timestamp; shared by append and list operations.\n */\nexport type PersistedTurnEvent = WithRegisteredPassthrough<SessionEvent> & {\n id: string;\n created_at: string;\n};\nexport interface SessionEventItem {\n turn_id: string;\n event: PersistedTurnEvent;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,yBAAkB;AAElB,oBAYO;AACP,kBAMO;AAGA,IAAM,YAAY;AAAA,EACvB,GAAG,cAAAA;AAAA,EACH,cAAc;AAAA,EACd,aAAa;AAAA,EACb,WAAW;AACb;AAEO,IAAM,yBAAyB,qBACnC,OAAO;AAAA,EACN,MAAM,qBAAE,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AC,6BAA6B,4BAA4B,CAAC,EACxF,SAAS,gCAAgC,EACzC,QAAQ,iBAAiB;AAErB,IAAM,wBAAwB,qBAClC,OAAO;AAAA,EACN,MAAM,qBAAE,QAAQ,UAAU,WAAW,EAAE,SAAS,wCAAwC;AAAA,EACxF,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,YAAY,qBAAE,OAAO,EAAE,SAAS,2BAA2B;AAAA,EAC3D,WAAW,qBAAE,OAAO,EAAE,SAAS,EAAE,SAAS,mEAAmE;AAC/G,CAAC,EACA,QAAQ,iBAAiB;AAGrB,IAAM,qBAAqB,qBAC/B,mBAAmB,QAAQ;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC,EACA,QAAQ,cAAc;AAGlB,IAAM,yBAAyB,qBACnC,OAAO;AAAA,EACN,SAAS,qBAAE,OAAO,EAAE,SAAS,+BAA+B;AAAA,EAC5D,OAAO;AACT,CAAC,EACA,QAAQ,kBAAkB;","names":["HarnessEventType"]}
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
var EventType = {
|
|
24
24
|
...HarnessEventType,
|
|
25
25
|
TURN_CREATED: "turn.created",
|
|
26
|
+
TURN_UPDATE: "turn.update",
|
|
26
27
|
TURN_DONE: "turn.done"
|
|
27
28
|
};
|
|
28
29
|
var TurnCreatedEventSchema = z.object({
|
|
@@ -42,8 +43,27 @@ var TurnDoneEventSchema = z.object({
|
|
|
42
43
|
created_at: z.string().describe("ISO 8601 event timestamp."),
|
|
43
44
|
thread_id: z.string().nullable().describe("Thread that owns the event; null for turn-level lifecycle events.")
|
|
44
45
|
}).openapi("TurnDoneEvent");
|
|
46
|
+
var ActionRequiredSchema = z.object({
|
|
47
|
+
id: EventIdSchema
|
|
48
|
+
}).openapi("ActionRequired");
|
|
49
|
+
var TurnUpdateStatePausedSchema = z.object({
|
|
50
|
+
status: z.literal("paused").describe("Turn is paused waiting for required actions."),
|
|
51
|
+
action_required_on_events: z.array(ActionRequiredSchema).describe("Events that still need a user or client action.")
|
|
52
|
+
}).openapi("TurnUpdateStatePaused");
|
|
53
|
+
var TurnUpdateStateRunningSchema = z.object({
|
|
54
|
+
status: z.literal("running").describe("Turn is executing.")
|
|
55
|
+
}).openapi("TurnUpdateStateRunning");
|
|
56
|
+
var TurnUpdateStateSchema = z.discriminatedUnion("status", [TurnUpdateStatePausedSchema, TurnUpdateStateRunningSchema]).describe("Live non-terminal turn status.").openapi("TurnUpdateState");
|
|
57
|
+
var TurnUpdateEventSchema = z.object({
|
|
58
|
+
type: z.literal(EventType.TURN_UPDATE).describe("Emitted when a turn pauses or resumes."),
|
|
59
|
+
id: EventIdSchema,
|
|
60
|
+
state: TurnUpdateStateSchema,
|
|
61
|
+
created_at: z.string().describe("ISO 8601 event timestamp."),
|
|
62
|
+
thread_id: z.string().nullable().describe("Thread that owns the event; null for turn-level lifecycle events.")
|
|
63
|
+
}).openapi("TurnUpdateEvent");
|
|
45
64
|
var SessionEventSchema = z.discriminatedUnion("type", [
|
|
46
65
|
TurnCreatedEventSchema,
|
|
66
|
+
TurnUpdateEventSchema,
|
|
47
67
|
TurnDoneEventSchema,
|
|
48
68
|
ModelMessageEventSchema,
|
|
49
69
|
ToolResponseEventSchema,
|
|
@@ -60,10 +80,15 @@ var SessionEventItemSchema = z.object({
|
|
|
60
80
|
event: SessionEventSchema
|
|
61
81
|
}).openapi("SessionEventItem");
|
|
62
82
|
export {
|
|
83
|
+
ActionRequiredSchema,
|
|
63
84
|
EventType,
|
|
64
85
|
SessionEventItemSchema,
|
|
65
86
|
SessionEventSchema,
|
|
66
87
|
TurnCreatedEventSchema,
|
|
67
|
-
TurnDoneEventSchema
|
|
88
|
+
TurnDoneEventSchema,
|
|
89
|
+
TurnUpdateEventSchema,
|
|
90
|
+
TurnUpdateStatePausedSchema,
|
|
91
|
+
TurnUpdateStateRunningSchema,
|
|
92
|
+
TurnUpdateStateSchema
|
|
68
93
|
};
|
|
69
94
|
//# sourceMappingURL=events.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/agent-session/schemas/events.ts"],"sourcesContent":["/**\n * Turn/session event product schemas. Event payloads come from the harness; this\n * module owns turn lifecycle events (turn.created / turn.done) and the persisted
|
|
1
|
+
{"version":3,"sources":["../../../src/agent-session/schemas/events.ts"],"sourcesContent":["/**\n * Turn/session event product schemas. Event payloads come from the harness; this\n * module owns turn lifecycle events (turn.created / turn.update / turn.done) and\n * the persisted event unions the store writes. SSE streaming envelopes stay in\n * server/schemas.\n */\nimport { z } from '@hono/zod-openapi';\nimport type { WithRegisteredPassthrough } from '../../core/events/PassthroughEvents';\nimport {\n EventIdSchema,\n EventType as HarnessEventType,\n MCPAuthRequiredEventSchema,\n MCPInitializeEventSchema,\n ModelMessageEventSchema,\n SandboxCreatedEventSchema,\n ThreadCreatedEventSchema,\n ThreadDoneEventSchema,\n ToolApprovalRequiredEventSchema,\n ToolResponseEventSchema,\n ToolResponseRequiredEventSchema,\n} from '../../core/events/schema';\nimport {\n TurnInputItemSchema,\n TurnStateCancelledSchema,\n TurnStateDoneSchema,\n TurnStateErrorSchema,\n TurnStateRunningSchema,\n} from './turn';\n\n/** Harness event types plus the turn lifecycle types owned by agentSession. */\nexport const EventType = {\n ...HarnessEventType,\n TURN_CREATED: 'turn.created',\n TURN_UPDATE: 'turn.update',\n TURN_DONE: 'turn.done',\n} as const;\n\nexport const TurnCreatedEventSchema = z\n .object({\n type: z.literal(EventType.TURN_CREATED).describe('Emitted when a turn starts.'),\n id: EventIdSchema,\n turn_id: z.string().describe('Id of the newly created turn.'),\n previous_turn_id: z.string().nullable().describe('Prior turn this turn chains from; null for a root turn.'),\n input: z.array(TurnInputItemSchema).optional().describe('Input items supplied when the turn was created.'),\n state: TurnStateRunningSchema,\n created_at: z.string().describe('ISO 8601 event timestamp.'),\n thread_id: z.string().nullable().describe('Thread that owns the event; null for turn-level lifecycle events.'),\n })\n .openapi('TurnCreatedEvent');\n\nexport const TurnDoneEventSchema = z\n .object({\n type: z.literal(EventType.TURN_DONE).describe('Emitted when a turn reaches a terminal state.'),\n id: EventIdSchema,\n state: z\n .discriminatedUnion('status', [TurnStateDoneSchema, TurnStateCancelledSchema, TurnStateErrorSchema])\n .describe('Terminal turn state (done, cancelled, or error).'),\n created_at: z.string().describe('ISO 8601 event timestamp.'),\n thread_id: z.string().nullable().describe('Thread that owns the event; null for turn-level lifecycle events.'),\n })\n .openapi('TurnDoneEvent');\n\nexport const ActionRequiredSchema = z\n .object({\n id: EventIdSchema,\n })\n .openapi('ActionRequired');\n\nexport const TurnUpdateStatePausedSchema = z\n .object({\n status: z.literal('paused').describe('Turn is paused waiting for required actions.'),\n action_required_on_events: z\n .array(ActionRequiredSchema)\n .describe('Events that still need a user or client action.'),\n })\n .openapi('TurnUpdateStatePaused');\n\nexport const TurnUpdateStateRunningSchema = z\n .object({\n status: z.literal('running').describe('Turn is executing.'),\n })\n .openapi('TurnUpdateStateRunning');\n\nexport const TurnUpdateStateSchema = z\n .discriminatedUnion('status', [TurnUpdateStatePausedSchema, TurnUpdateStateRunningSchema])\n .describe('Live non-terminal turn status.')\n .openapi('TurnUpdateState');\n\nexport const TurnUpdateEventSchema = z\n .object({\n type: z.literal(EventType.TURN_UPDATE).describe('Emitted when a turn pauses or resumes.'),\n id: EventIdSchema,\n state: TurnUpdateStateSchema,\n created_at: z.string().describe('ISO 8601 event timestamp.'),\n thread_id: z.string().nullable().describe('Thread that owns the event; null for turn-level lifecycle events.'),\n })\n .openapi('TurnUpdateEvent');\n\n/** Built-in durable turn events — lifecycle + content; no deltas, no passthrough. */\nexport const SessionEventSchema = z\n .discriminatedUnion('type', [\n TurnCreatedEventSchema,\n TurnUpdateEventSchema,\n TurnDoneEventSchema,\n ModelMessageEventSchema,\n ToolResponseEventSchema,\n ThreadCreatedEventSchema,\n ThreadDoneEventSchema,\n MCPAuthRequiredEventSchema,\n MCPInitializeEventSchema,\n SandboxCreatedEventSchema,\n ToolApprovalRequiredEventSchema,\n ToolResponseRequiredEventSchema,\n ])\n .openapi('SessionEvent');\n\n/** One row on the session timeline: which turn emitted the event plus the event payload. */\nexport const SessionEventItemSchema = z\n .object({\n turn_id: z.string().describe('Turn that emitted this event.'),\n event: SessionEventSchema,\n })\n .openapi('SessionEventItem');\n\nexport type TurnCreatedEvent = z.infer<typeof TurnCreatedEventSchema>;\nexport type TurnUpdateEvent = z.infer<typeof TurnUpdateEventSchema>;\nexport type TurnDoneEvent = z.infer<typeof TurnDoneEventSchema>;\nexport type SessionEvent = z.infer<typeof SessionEventSchema>;\n/**\n * Durable turn event log entries: {@link SessionEvent} plus any registered\n * passthrough events. Every merged event must carry its monotonic ULID and\n * creation timestamp; shared by append and list operations.\n */\nexport type PersistedTurnEvent = WithRegisteredPassthrough<SessionEvent> & {\n id: string;\n created_at: string;\n};\nexport interface SessionEventItem {\n turn_id: string;\n event: PersistedTurnEvent;\n}\n"],"mappings":";AAMA,SAAS,SAAS;AAElB;AAAA,EACE;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,IAAM,YAAY;AAAA,EACvB,GAAG;AAAA,EACH,cAAc;AAAA,EACd,aAAa;AAAA,EACb,WAAW;AACb;AAEO,IAAM,yBAAyB,EACnC,OAAO;AAAA,EACN,MAAM,EAAE,QAAQ,UAAU,YAAY,EAAE,SAAS,6BAA6B;AAAA,EAC9E,IAAI;AAAA,EACJ,SAAS,EAAE,OAAO,EAAE,SAAS,+BAA+B;AAAA,EAC5D,kBAAkB,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,yDAAyD;AAAA,EAC1G,OAAO,E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EAAE,OAAO,EAAE,SAAS,2BAA2B;AAAA,EAC3D,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,mEAAmE;AAC/G,CAAC,EACA,QAAQ,iBAAiB;AAGrB,IAAM,qBAAqB,EAC/B,mBAAmB,QAAQ;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC,EACA,QAAQ,cAAc;AAGlB,IAAM,yBAAyB,EACnC,OAAO;AAAA,EACN,SAAS,EAAE,OAAO,EAAE,SAAS,+BAA+B;AAAA,EAC5D,OAAO;AACT,CAAC,EACA,QAAQ,kBAAkB;","names":[]}
|
|
@@ -99,6 +99,9 @@ export declare const SessionAgentInlineSchema: z.ZodObject<{
|
|
|
99
99
|
ask_user_questions: z.ZodDefault<z.ZodObject<{
|
|
100
100
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
101
101
|
}, z.core.$strip>>;
|
|
102
|
+
web_search: z.ZodDefault<z.ZodObject<{
|
|
103
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
104
|
+
}, z.core.$strip>>;
|
|
102
105
|
}, z.core.$strip>>;
|
|
103
106
|
}, z.core.$strip>;
|
|
104
107
|
}, z.core.$strict>;
|
|
@@ -191,6 +194,9 @@ export declare const SessionAgentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
191
194
|
ask_user_questions: z.ZodDefault<z.ZodObject<{
|
|
192
195
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
193
196
|
}, z.core.$strip>>;
|
|
197
|
+
web_search: z.ZodDefault<z.ZodObject<{
|
|
198
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
199
|
+
}, z.core.$strip>>;
|
|
194
200
|
}, z.core.$strip>>;
|
|
195
201
|
}, z.core.$strip>;
|
|
196
202
|
}, z.core.$strict>], "type">;
|
|
@@ -303,6 +309,9 @@ export declare const SessionSchema: z.ZodObject<{
|
|
|
303
309
|
ask_user_questions: z.ZodDefault<z.ZodObject<{
|
|
304
310
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
305
311
|
}, z.core.$strip>>;
|
|
312
|
+
web_search: z.ZodDefault<z.ZodObject<{
|
|
313
|
+
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
314
|
+
}, z.core.$strip>>;
|
|
306
315
|
}, z.core.$strip>>;
|
|
307
316
|
}, z.core.$strip>;
|
|
308
317
|
}, z.core.$strict>], "type">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/agent-session/schemas/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAetC,eAAO,MAAM,qBAAqB,uCAiBL,CAAC;AAE9B,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,oBAAoB;;;;kBAQL,CAAC;AAE7B,eAAO,MAAM,2BAA2B;;;;kBAWL,CAAC;AAEpC,eAAO,MAAM,wBAAwB
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/agent-session/schemas/session.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAetC,eAAO,MAAM,qBAAqB,uCAiBL,CAAC;AAE9B,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,oBAAoB;;;;kBAQL,CAAC;AAE7B,eAAO,MAAM,2BAA2B;;;;kBAWL,CAAC;AAEpC,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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
|
3
|
+
import type { AgentTracing } from '../../tracing/AgentTracing';
|
|
4
|
+
import type { IWebSearchProvider } from '../../web-search/WebSearchProvider';
|
|
5
|
+
import type { AgentCapability } from '../AgentCapability';
|
|
6
|
+
export declare const WEB_SEARCH_SERVER_ID = "web-search";
|
|
7
|
+
export declare const WEB_SEARCH_TOOL_NAME = "web_search";
|
|
8
|
+
export declare const WEB_FETCH_TOOL_NAME = "web_fetch";
|
|
9
|
+
export declare const WEB_SEARCH_REMINDER_TAG = "web-search";
|
|
10
|
+
/**
|
|
11
|
+
* Cross-tool policy (when / how to combine search + fetch).
|
|
12
|
+
* Per-tool behavior and params stay on tool descriptions / schema describes.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildWebSearchInstruction(builder: InstructionBuilder): void;
|
|
15
|
+
export declare class WebSearchTools extends LocalToolMCP {
|
|
16
|
+
#private;
|
|
17
|
+
readonly name = "web-search";
|
|
18
|
+
readonly displayName = "WebSearch";
|
|
19
|
+
constructor(options: {
|
|
20
|
+
provider: IWebSearchProvider;
|
|
21
|
+
tracing: AgentTracing;
|
|
22
|
+
});
|
|
23
|
+
private tools;
|
|
24
|
+
protected getTools(): ToolDefinition[];
|
|
25
|
+
private runSearch;
|
|
26
|
+
private runFetch;
|
|
27
|
+
}
|
|
28
|
+
export declare function webSearch(options: {
|
|
29
|
+
provider: IWebSearchProvider;
|
|
30
|
+
tracing: AgentTracing;
|
|
31
|
+
}): AgentCapability;
|
|
32
|
+
//# sourceMappingURL=WebSearch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebSearch.d.ts","sourceRoot":"","sources":["../../../../src/core/capabilities/builtins/WebSearch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAc,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD,eAAO,MAAM,mBAAmB,cAAc,CAAC;AAC/C,eAAO,MAAM,uBAAuB,eAAe,CAAC;AAyCpD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAiB3E;AAED,qBAAa,cAAe,SAAQ,YAAY;;IAC9C,QAAQ,CAAC,IAAI,gBAAwB;IACrC,QAAQ,CAAC,WAAW,eAAe;IAGnC,YAAY,OAAO,EAAE;QAAE,QAAQ,EAAE,kBAAkB,CAAC;QAAC,OAAO,EAAE,YAAY,CAAA;KAAE,EAG3E;IAED,OAAO,CAAC,KAAK,CAaX;IAEF,SAAS,CAAC,QAAQ,IAAI,cAAc,EAAE,CAErC;YAEa,SAAS;YAQT,QAAQ;CAOvB;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE;IAAE,QAAQ,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAAG,eAAe,CAK3G"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/core/capabilities/builtins/WebSearch.ts
|
|
31
|
+
var WebSearch_exports = {};
|
|
32
|
+
__export(WebSearch_exports, {
|
|
33
|
+
WEB_FETCH_TOOL_NAME: () => WEB_FETCH_TOOL_NAME,
|
|
34
|
+
WEB_SEARCH_REMINDER_TAG: () => WEB_SEARCH_REMINDER_TAG,
|
|
35
|
+
WEB_SEARCH_SERVER_ID: () => WEB_SEARCH_SERVER_ID,
|
|
36
|
+
WEB_SEARCH_TOOL_NAME: () => WEB_SEARCH_TOOL_NAME,
|
|
37
|
+
WebSearchTools: () => WebSearchTools,
|
|
38
|
+
buildWebSearchInstruction: () => buildWebSearchInstruction,
|
|
39
|
+
webSearch: () => webSearch
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(WebSearch_exports);
|
|
42
|
+
var import_dedent = __toESM(require("dedent"), 1);
|
|
43
|
+
var import_zod = require("zod");
|
|
44
|
+
var import_InstructionBuilder = require("../../InstructionBuilder.js");
|
|
45
|
+
var import_IMCPServer = require("../../mcp/IMCPServer.js");
|
|
46
|
+
var import_LocalToolMCP = require("../../mcp/LocalToolMCP.js");
|
|
47
|
+
var WEB_SEARCH_SERVER_ID = "web-search";
|
|
48
|
+
var WEB_SEARCH_TOOL_NAME = "web_search";
|
|
49
|
+
var WEB_FETCH_TOOL_NAME = "web_fetch";
|
|
50
|
+
var WEB_SEARCH_REMINDER_TAG = "web-search";
|
|
51
|
+
var webSearchInputSchema = import_zod.z.object({
|
|
52
|
+
search_queries: import_zod.z.array(import_zod.z.string().min(1)).min(1).max(5).describe(
|
|
53
|
+
'Keyword search queries (prefer 3\u20136 words each; 2\u20133 queries often beat one long query). Operators such as site:domain, filetype:pdf, intitle:word, -term, and "exact phrase" may work when the backend supports them.'
|
|
54
|
+
),
|
|
55
|
+
objective: import_zod.z.string().min(1).optional().describe("Natural-language goal for the search. Helps the backend focus hits when provided.")
|
|
56
|
+
}).strict();
|
|
57
|
+
var webFetchInputSchema = import_zod.z.object({
|
|
58
|
+
urls: import_zod.z.array(import_zod.z.url()).min(1).max(5).describe("Page URLs to extract (up to 5). Prefer specific hit URLs from web_search."),
|
|
59
|
+
objective: import_zod.z.string().min(1).optional().describe("Optional goal used to focus extracted excerpts when the page is large.")
|
|
60
|
+
}).strict();
|
|
61
|
+
var WEB_SEARCH_TOOL_DESCRIPTION = "Search the web. Returns ranked hits with titles, URLs, and snippets. Prefer concise keyword queries; use multiple related queries in one call when useful.";
|
|
62
|
+
var WEB_FETCH_TOOL_DESCRIPTION = `Extract page content from URLs as markdown/text (no LLM summarization). Prefer specific hit URLs from ${WEB_SEARCH_TOOL_NAME} when snippets are not enough.`;
|
|
63
|
+
function buildWebSearchInstruction(builder) {
|
|
64
|
+
builder.addSection(
|
|
65
|
+
WEB_SEARCH_REMINDER_TAG,
|
|
66
|
+
import_dedent.default`
|
|
67
|
+
The Agent has two system tools for live web access: ${WEB_SEARCH_TOOL_NAME} (search) and ${WEB_FETCH_TOOL_NAME} (extract page content).
|
|
68
|
+
|
|
69
|
+
When to use them:
|
|
70
|
+
- The user asks to search, browse, verify, look up, or get latest information.
|
|
71
|
+
- Facts may have changed recently (news, prices, laws, schedules, product specs, software APIs/docs, people in roles, rates, scores).
|
|
72
|
+
- The answer needs direct quotes, links, or precise source attribution.
|
|
73
|
+
- A specific page, paper, dataset, or site is referenced and its contents were not provided.
|
|
74
|
+
|
|
75
|
+
How to use them:
|
|
76
|
+
- Start with ${WEB_SEARCH_TOOL_NAME} for discovery; follow with ${WEB_FETCH_TOOL_NAME} on the best URLs when snippets are not enough.
|
|
77
|
+
- Prefer primary and authoritative sources.
|
|
78
|
+
`.trim()
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
var WebSearchTools = class extends import_LocalToolMCP.LocalToolMCP {
|
|
82
|
+
name = WEB_SEARCH_SERVER_ID;
|
|
83
|
+
displayName = "WebSearch";
|
|
84
|
+
#provider;
|
|
85
|
+
constructor(options) {
|
|
86
|
+
super({ tracing: options.tracing });
|
|
87
|
+
this.#provider = options.provider;
|
|
88
|
+
}
|
|
89
|
+
tools = [
|
|
90
|
+
(0, import_LocalToolMCP.defineTool)({
|
|
91
|
+
name: WEB_SEARCH_TOOL_NAME,
|
|
92
|
+
description: WEB_SEARCH_TOOL_DESCRIPTION,
|
|
93
|
+
schema: webSearchInputSchema,
|
|
94
|
+
handler: (input) => this.runSearch(input)
|
|
95
|
+
}),
|
|
96
|
+
(0, import_LocalToolMCP.defineTool)({
|
|
97
|
+
name: WEB_FETCH_TOOL_NAME,
|
|
98
|
+
description: WEB_FETCH_TOOL_DESCRIPTION,
|
|
99
|
+
schema: webFetchInputSchema,
|
|
100
|
+
handler: (input) => this.runFetch(input)
|
|
101
|
+
})
|
|
102
|
+
];
|
|
103
|
+
getTools() {
|
|
104
|
+
return this.tools;
|
|
105
|
+
}
|
|
106
|
+
async runSearch(input) {
|
|
107
|
+
const result = await this.#provider.search({
|
|
108
|
+
search_queries: input.search_queries,
|
|
109
|
+
objective: input.objective
|
|
110
|
+
});
|
|
111
|
+
return (0, import_IMCPServer.toolResultResponse)({ text: JSON.stringify(result) });
|
|
112
|
+
}
|
|
113
|
+
async runFetch(input) {
|
|
114
|
+
const result = await this.#provider.fetch({
|
|
115
|
+
urls: input.urls,
|
|
116
|
+
objective: input.objective
|
|
117
|
+
});
|
|
118
|
+
return (0, import_IMCPServer.toolResultResponse)({ text: JSON.stringify(result) });
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
function webSearch(options) {
|
|
122
|
+
return {
|
|
123
|
+
systemToolSets: [new WebSearchTools(options)],
|
|
124
|
+
instructionBuilders: [buildWebSearchInstruction]
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
128
|
+
0 && (module.exports = {
|
|
129
|
+
WEB_FETCH_TOOL_NAME,
|
|
130
|
+
WEB_SEARCH_REMINDER_TAG,
|
|
131
|
+
WEB_SEARCH_SERVER_ID,
|
|
132
|
+
WEB_SEARCH_TOOL_NAME,
|
|
133
|
+
WebSearchTools,
|
|
134
|
+
buildWebSearchInstruction,
|
|
135
|
+
webSearch
|
|
136
|
+
});
|
|
137
|
+
//# sourceMappingURL=WebSearch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/capabilities/builtins/WebSearch.ts"],"sourcesContent":["import dedent from 'dedent';\nimport { z } from 'zod';\nimport { InstructionBuilder } from '../../InstructionBuilder';\nimport { type CallToolResponse, toolResultResponse } from '../../mcp/IMCPServer';\nimport { defineTool, LocalToolMCP, type ToolDefinition } from '../../mcp/LocalToolMCP';\nimport type { AgentTracing } from '../../tracing/AgentTracing';\nimport type { IWebSearchProvider } from '../../web-search/WebSearchProvider';\nimport type { AgentCapability } from '../AgentCapability';\n\nexport const WEB_SEARCH_SERVER_ID = 'web-search';\nexport const WEB_SEARCH_TOOL_NAME = 'web_search';\nexport const WEB_FETCH_TOOL_NAME = 'web_fetch';\nexport const WEB_SEARCH_REMINDER_TAG = 'web-search';\n\nconst webSearchInputSchema = z\n .object({\n search_queries: z\n .array(z.string().min(1))\n .min(1)\n .max(5)\n .describe(\n 'Keyword search queries (prefer 3–6 words each; 2–3 queries often beat one long query). Operators such as site:domain, filetype:pdf, intitle:word, -term, and \"exact phrase\" may work when the backend supports them.',\n ),\n objective: z\n .string()\n .min(1)\n .optional()\n .describe('Natural-language goal for the search. Helps the backend focus hits when provided.'),\n })\n .strict();\n\nconst webFetchInputSchema = z\n .object({\n urls: z\n .array(z.url())\n .min(1)\n .max(5)\n .describe('Page URLs to extract (up to 5). Prefer specific hit URLs from web_search.'),\n objective: z\n .string()\n .min(1)\n .optional()\n .describe('Optional goal used to focus extracted excerpts when the page is large.'),\n })\n .strict();\n\n/** What the tool does — param details live on the Zod schema `.describe`s. */\nconst WEB_SEARCH_TOOL_DESCRIPTION =\n 'Search the web. Returns ranked hits with titles, URLs, and snippets. Prefer concise keyword queries; use multiple related queries in one call when useful.';\n\n/** What the tool does — param details live on the Zod schema `.describe`s. */\nconst WEB_FETCH_TOOL_DESCRIPTION = `Extract page content from URLs as markdown/text (no LLM summarization). Prefer specific hit URLs from ${WEB_SEARCH_TOOL_NAME} when snippets are not enough.`;\n\n/**\n * Cross-tool policy (when / how to combine search + fetch).\n * Per-tool behavior and params stay on tool descriptions / schema describes.\n */\nexport function buildWebSearchInstruction(builder: InstructionBuilder): void {\n builder.addSection(\n WEB_SEARCH_REMINDER_TAG,\n dedent`\n The Agent has two system tools for live web access: ${WEB_SEARCH_TOOL_NAME} (search) and ${WEB_FETCH_TOOL_NAME} (extract page content).\n\n When to use them:\n - The user asks to search, browse, verify, look up, or get latest information.\n - Facts may have changed recently (news, prices, laws, schedules, product specs, software APIs/docs, people in roles, rates, scores).\n - The answer needs direct quotes, links, or precise source attribution.\n - A specific page, paper, dataset, or site is referenced and its contents were not provided.\n\n How to use them:\n - Start with ${WEB_SEARCH_TOOL_NAME} for discovery; follow with ${WEB_FETCH_TOOL_NAME} on the best URLs when snippets are not enough.\n - Prefer primary and authoritative sources.\n `.trim(),\n );\n}\n\nexport class WebSearchTools extends LocalToolMCP {\n readonly name = WEB_SEARCH_SERVER_ID;\n readonly displayName = 'WebSearch';\n readonly #provider: IWebSearchProvider;\n\n constructor(options: { provider: IWebSearchProvider; tracing: AgentTracing }) {\n super({ tracing: options.tracing });\n this.#provider = options.provider;\n }\n\n private tools: ToolDefinition[] = [\n defineTool({\n name: WEB_SEARCH_TOOL_NAME,\n description: WEB_SEARCH_TOOL_DESCRIPTION,\n schema: webSearchInputSchema,\n handler: input => this.runSearch(input),\n }),\n defineTool({\n name: WEB_FETCH_TOOL_NAME,\n description: WEB_FETCH_TOOL_DESCRIPTION,\n schema: webFetchInputSchema,\n handler: input => this.runFetch(input),\n }),\n ];\n\n protected getTools(): ToolDefinition[] {\n return this.tools;\n }\n\n private async runSearch(input: z.infer<typeof webSearchInputSchema>): Promise<CallToolResponse> {\n const result = await this.#provider.search({\n search_queries: input.search_queries,\n objective: input.objective,\n });\n return toolResultResponse({ text: JSON.stringify(result) });\n }\n\n private async runFetch(input: z.infer<typeof webFetchInputSchema>): Promise<CallToolResponse> {\n const result = await this.#provider.fetch({\n urls: input.urls,\n objective: input.objective,\n });\n return toolResultResponse({ text: JSON.stringify(result) });\n }\n}\n\nexport function webSearch(options: { provider: IWebSearchProvider; tracing: AgentTracing }): AgentCapability {\n return {\n systemToolSets: [new WebSearchTools(options)],\n instructionBuilders: [buildWebSearchInstruction],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,iBAAkB;AAClB,gCAAmC;AACnC,wBAA0D;AAC1D,0BAA8D;AAKvD,IAAM,uBAAuB;AAC7B,IAAM,uBAAuB;AAC7B,IAAM,sBAAsB;AAC5B,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AAK,SAAS,KAAK;AAAA,IACvC,CAAC;AAAA,EACH;AAAA,EAEU,WAA6B;AACrC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAc,UAAU,OAAwE;AAC9F,UAAM,SAAS,MAAM,KAAK,UAAU,OAAO;AAAA,MACzC,gBAAgB,MAAM;AAAA,MACtB,WAAW,MAAM;AAAA,IACnB,CAAC;AACD,eAAO,sCAAmB,EAAE,MAAM,KAAK,UAAU,MAAM,EAAE,CAAC;AAAA,EAC5D;AAAA,EAEA,MAAc,SAAS,OAAuE;AAC5F,UAAM,SAAS,MAAM,KAAK,UAAU,MAAM;AAAA,MACxC,MAAM,MAAM;AAAA,MACZ,WAAW,MAAM;AAAA,IACnB,CAAC;AACD,eAAO,sCAAmB,EAAE,MAAM,KAAK,UAAU,MAAM,EAAE,CAAC;AAAA,EAC5D;AACF;AAEO,SAAS,UAAU,SAAmF;AAC3G,SAAO;AAAA,IACL,gBAAgB,CAAC,IAAI,eAAe,OAAO,CAAC;AAAA,IAC5C,qBAAqB,CAAC,yBAAyB;AAAA,EACjD;AACF;","names":["dedent"]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// src/core/capabilities/builtins/WebSearch.ts
|
|
2
|
+
import dedent from "dedent";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import "../../InstructionBuilder.mjs";
|
|
5
|
+
import { toolResultResponse } from "../../mcp/IMCPServer.mjs";
|
|
6
|
+
import { defineTool, LocalToolMCP } from "../../mcp/LocalToolMCP.mjs";
|
|
7
|
+
var WEB_SEARCH_SERVER_ID = "web-search";
|
|
8
|
+
var WEB_SEARCH_TOOL_NAME = "web_search";
|
|
9
|
+
var WEB_FETCH_TOOL_NAME = "web_fetch";
|
|
10
|
+
var WEB_SEARCH_REMINDER_TAG = "web-search";
|
|
11
|
+
var webSearchInputSchema = z.object({
|
|
12
|
+
search_queries: z.array(z.string().min(1)).min(1).max(5).describe(
|
|
13
|
+
'Keyword search queries (prefer 3\u20136 words each; 2\u20133 queries often beat one long query). Operators such as site:domain, filetype:pdf, intitle:word, -term, and "exact phrase" may work when the backend supports them.'
|
|
14
|
+
),
|
|
15
|
+
objective: z.string().min(1).optional().describe("Natural-language goal for the search. Helps the backend focus hits when provided.")
|
|
16
|
+
}).strict();
|
|
17
|
+
var webFetchInputSchema = z.object({
|
|
18
|
+
urls: z.array(z.url()).min(1).max(5).describe("Page URLs to extract (up to 5). Prefer specific hit URLs from web_search."),
|
|
19
|
+
objective: z.string().min(1).optional().describe("Optional goal used to focus extracted excerpts when the page is large.")
|
|
20
|
+
}).strict();
|
|
21
|
+
var WEB_SEARCH_TOOL_DESCRIPTION = "Search the web. Returns ranked hits with titles, URLs, and snippets. Prefer concise keyword queries; use multiple related queries in one call when useful.";
|
|
22
|
+
var WEB_FETCH_TOOL_DESCRIPTION = `Extract page content from URLs as markdown/text (no LLM summarization). Prefer specific hit URLs from ${WEB_SEARCH_TOOL_NAME} when snippets are not enough.`;
|
|
23
|
+
function buildWebSearchInstruction(builder) {
|
|
24
|
+
builder.addSection(
|
|
25
|
+
WEB_SEARCH_REMINDER_TAG,
|
|
26
|
+
dedent`
|
|
27
|
+
The Agent has two system tools for live web access: ${WEB_SEARCH_TOOL_NAME} (search) and ${WEB_FETCH_TOOL_NAME} (extract page content).
|
|
28
|
+
|
|
29
|
+
When to use them:
|
|
30
|
+
- The user asks to search, browse, verify, look up, or get latest information.
|
|
31
|
+
- Facts may have changed recently (news, prices, laws, schedules, product specs, software APIs/docs, people in roles, rates, scores).
|
|
32
|
+
- The answer needs direct quotes, links, or precise source attribution.
|
|
33
|
+
- A specific page, paper, dataset, or site is referenced and its contents were not provided.
|
|
34
|
+
|
|
35
|
+
How to use them:
|
|
36
|
+
- Start with ${WEB_SEARCH_TOOL_NAME} for discovery; follow with ${WEB_FETCH_TOOL_NAME} on the best URLs when snippets are not enough.
|
|
37
|
+
- Prefer primary and authoritative sources.
|
|
38
|
+
`.trim()
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
var WebSearchTools = class extends LocalToolMCP {
|
|
42
|
+
name = WEB_SEARCH_SERVER_ID;
|
|
43
|
+
displayName = "WebSearch";
|
|
44
|
+
#provider;
|
|
45
|
+
constructor(options) {
|
|
46
|
+
super({ tracing: options.tracing });
|
|
47
|
+
this.#provider = options.provider;
|
|
48
|
+
}
|
|
49
|
+
tools = [
|
|
50
|
+
defineTool({
|
|
51
|
+
name: WEB_SEARCH_TOOL_NAME,
|
|
52
|
+
description: WEB_SEARCH_TOOL_DESCRIPTION,
|
|
53
|
+
schema: webSearchInputSchema,
|
|
54
|
+
handler: (input) => this.runSearch(input)
|
|
55
|
+
}),
|
|
56
|
+
defineTool({
|
|
57
|
+
name: WEB_FETCH_TOOL_NAME,
|
|
58
|
+
description: WEB_FETCH_TOOL_DESCRIPTION,
|
|
59
|
+
schema: webFetchInputSchema,
|
|
60
|
+
handler: (input) => this.runFetch(input)
|
|
61
|
+
})
|
|
62
|
+
];
|
|
63
|
+
getTools() {
|
|
64
|
+
return this.tools;
|
|
65
|
+
}
|
|
66
|
+
async runSearch(input) {
|
|
67
|
+
const result = await this.#provider.search({
|
|
68
|
+
search_queries: input.search_queries,
|
|
69
|
+
objective: input.objective
|
|
70
|
+
});
|
|
71
|
+
return toolResultResponse({ text: JSON.stringify(result) });
|
|
72
|
+
}
|
|
73
|
+
async runFetch(input) {
|
|
74
|
+
const result = await this.#provider.fetch({
|
|
75
|
+
urls: input.urls,
|
|
76
|
+
objective: input.objective
|
|
77
|
+
});
|
|
78
|
+
return toolResultResponse({ text: JSON.stringify(result) });
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
function webSearch(options) {
|
|
82
|
+
return {
|
|
83
|
+
systemToolSets: [new WebSearchTools(options)],
|
|
84
|
+
instructionBuilders: [buildWebSearchInstruction]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
WEB_FETCH_TOOL_NAME,
|
|
89
|
+
WEB_SEARCH_REMINDER_TAG,
|
|
90
|
+
WEB_SEARCH_SERVER_ID,
|
|
91
|
+
WEB_SEARCH_TOOL_NAME,
|
|
92
|
+
WebSearchTools,
|
|
93
|
+
buildWebSearchInstruction,
|
|
94
|
+
webSearch
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=WebSearch.mjs.map
|