stitchkit 0.56.1 → 0.56.2
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/README.md +12 -3
- package/dist/agent-runtime/compaction.d.ts +33 -0
- package/dist/agent-runtime/compaction.d.ts.map +1 -0
- package/dist/agent-runtime/coordinator.d.ts +24 -0
- package/dist/agent-runtime/coordinator.d.ts.map +1 -0
- package/dist/agent-runtime/events.d.ts +454 -0
- package/dist/agent-runtime/events.d.ts.map +1 -0
- package/dist/agent-runtime/history.d.ts +11 -0
- package/dist/agent-runtime/history.d.ts.map +1 -0
- package/dist/agent-runtime/managed-tools.d.ts +18 -0
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -0
- package/dist/agent-runtime/models.d.ts +51 -0
- package/dist/agent-runtime/models.d.ts.map +1 -0
- package/dist/agent-runtime/observability.d.ts +134 -0
- package/dist/agent-runtime/observability.d.ts.map +1 -0
- package/dist/agent-runtime/prompt.d.ts +50 -0
- package/dist/agent-runtime/prompt.d.ts.map +1 -0
- package/dist/agent-runtime/protocol.d.ts +16 -0
- package/dist/agent-runtime/protocol.d.ts.map +1 -0
- package/dist/agent-runtime/runtime.d.ts +120 -0
- package/dist/agent-runtime/runtime.d.ts.map +1 -0
- package/dist/agent-runtime/schemas.d.ts +470 -0
- package/dist/agent-runtime/schemas.d.ts.map +1 -0
- package/dist/agent-runtime/store.d.ts +905 -0
- package/dist/agent-runtime/store.d.ts.map +1 -0
- package/dist/agent-runtime/testing.d.ts +17 -0
- package/dist/agent-runtime/testing.d.ts.map +1 -0
- package/dist/agent-runtime-openrouter.d.ts +6 -0
- package/dist/agent-runtime-openrouter.d.ts.map +1 -0
- package/dist/agent-runtime-openrouter.js +46 -0
- package/dist/agent-runtime.d.ts +13 -0
- package/dist/agent-runtime.d.ts.map +1 -0
- package/dist/agent-runtime.js +1931 -0
- package/dist/cli.js +8 -5
- package/dist/index-0nc0cddp.js +178 -0
- package/dist/{index-6y759j86.js → index-1tkyng3g.js} +9 -57
- package/dist/{index-sm2tjx06.js → index-41wm56v0.js} +2 -2
- package/dist/index-6djpbnda.js +56 -0
- package/dist/{index-j3dem06f.js → index-7c0gkyvj.js} +5 -3
- package/dist/{index-75njxz7p.js → index-9zn9fb4e.js} +8 -6
- package/dist/{index-xy8fmh6w.js → index-f6pymtqe.js} +3 -3
- package/dist/{index-jcc611vh.js → index-gnvzyw0k.js} +2 -2
- package/dist/{index-qh4xevf5.js → index-mr617n62.js} +4 -2
- package/dist/{index-5r13htq1.js → index-ps5pxp3h.js} +1 -1
- package/dist/index-sa2mbwa7.js +336 -0
- package/dist/index-smpbdg6k.js +27 -0
- package/dist/{index-7eq9va6e.js → index-y2rb7dwx.js} +1 -27
- package/dist/{index-escqg10p.js → index-zk5zn2nh.js} +32 -334
- package/dist/internal/observability-sink.d.ts +26 -0
- package/dist/internal/observability-sink.d.ts.map +1 -0
- package/dist/node.js +6 -5
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/index.js +15 -178
- package/dist/remote.js +4 -3
- package/dist/server/error-hook.d.ts +9 -7
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/index.js +9 -7
- package/dist/testing.js +5 -3
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/execute.d.ts +7 -0
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools.d.ts +2 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +23 -12
- package/llms-full.txt +365 -10
- package/llms.txt +1 -0
- package/package.json +16 -3
package/README.md
CHANGED
|
@@ -85,11 +85,13 @@ Server code imports server entrypoints:
|
|
|
85
85
|
import { createServer, createHandler, implement } from 'stitchkit/server'
|
|
86
86
|
import { createSocketIOServer, createAuthHook } from 'stitchkit/server'
|
|
87
87
|
import { createMcpHandler, mountAgent } from 'stitchkit/tools'
|
|
88
|
+
import { createAgentRuntime, defineAgentProtocol } from 'stitchkit/agent-runtime'
|
|
88
89
|
import { implementRemote } from 'stitchkit/remote'
|
|
89
90
|
```
|
|
90
91
|
|
|
91
|
-
The root `stitchkit` entrypoint is browser-safe. Server, tool
|
|
92
|
-
remote-proxy code live behind
|
|
92
|
+
The root `stitchkit` entrypoint is browser-safe. Server, tool, optional
|
|
93
|
+
AI-SDK-backed agent-runtime and peer-free remote-proxy code live behind
|
|
94
|
+
`stitchkit/server`, `stitchkit/tools`, `stitchkit/agent-runtime` and
|
|
93
95
|
`stitchkit/remote` respectively.
|
|
94
96
|
|
|
95
97
|
## Quick Start
|
|
@@ -213,6 +215,11 @@ const result = await generateText({ model, tools, prompt: 'Create a user named M
|
|
|
213
215
|
|
|
214
216
|
### 7. WebSocket (Socket.IO)
|
|
215
217
|
|
|
218
|
+
For applications that want Stitchkit to own durable message/run transitions,
|
|
219
|
+
stream checkpoints, interruption and managed-tool fencing, use the optional
|
|
220
|
+
[`stitchkit/agent-runtime`](docs/guide/agent-runtime.md). `mountAgent` remains
|
|
221
|
+
the smaller application-owned-loop path.
|
|
222
|
+
|
|
216
223
|
stitchkit's WebSocket layer is Socket.IO — `polling` fallback, heartbeat, acks,
|
|
217
224
|
a mature client. The wrappers cover the boilerplate.
|
|
218
225
|
|
|
@@ -282,6 +289,7 @@ import { parseSSE } from 'stitchkit' // client: Response → AsyncGene
|
|
|
282
289
|
| **HTTP Server** | `createServer()` / `createHandler()` — Bun.serve, validation, hooks, raw routes |
|
|
283
290
|
| **MCP Tools** | `createMcpHandler()` / `mountMcp()` — MCP tools from contracts |
|
|
284
291
|
| **Agent Tools** | `mountAgent()` — Vercel AI SDK tools from contracts |
|
|
292
|
+
| **Agent Runtime** | `createAgentRuntime()` — optional durable history, stream loop, coordination and fencing |
|
|
285
293
|
| **Typed Client** | `createClient()` / `createClients()` — typed fetch from contracts |
|
|
286
294
|
| **Cursor Pagination** | `createCursorQuery()` — `react-query-kit` infinite query from a contract method |
|
|
287
295
|
| **WebSocket** | `createSocketIOClient()` / `createSocketIOServer()` — typed Socket.IO wrappers |
|
|
@@ -367,7 +375,8 @@ peer — an install pulls in only what the project actually uses.
|
|
|
367
375
|
| `@modelcontextprotocol/server` | peer, optional | MCP server surfaces in `stitchkit/tools`; SDK v2, protocol `2026-07-28`. |
|
|
368
376
|
| `@modelcontextprotocol/client` | development dependency, optional | Only consumers that run MCP client integration tests or build an MCP host. |
|
|
369
377
|
| `@modelcontextprotocol/ext-apps` | peer, optional | Only MCP Apps (`ui://` resources and UI metadata). |
|
|
370
|
-
| `ai` | peer, optional |
|
|
378
|
+
| `ai` | peer, optional | `stitchkit/tools` agent tools and the optional server-only `stitchkit/agent-runtime`. |
|
|
379
|
+
| `@openrouter/ai-sdk-provider` | peer, optional | Only `stitchkit/agent-runtime/openrouter`; neutral runtime imports do not resolve it. |
|
|
371
380
|
| `@tanstack/react-query` + `react-query-kit` | peer, optional | Only `stitchkit/react` — `createCursorQuery`, `createCacheBridge`. |
|
|
372
381
|
| `socket.io` / `@socket.io/bun-engine` / `socket.io-client` | peer, optional | Only the Socket.IO wrappers. |
|
|
373
382
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ZodType, z } from 'zod';
|
|
2
|
+
import type { AgentMessage, AgentSnapshot } from './schemas';
|
|
3
|
+
import type { AgentRuntimeStore } from './store';
|
|
4
|
+
export interface AgentCompactionContext<SUMMARY> {
|
|
5
|
+
conversationId: string;
|
|
6
|
+
snapshot: AgentSnapshot;
|
|
7
|
+
eligibleMessages: readonly AgentMessage[];
|
|
8
|
+
previousSummary?: SUMMARY;
|
|
9
|
+
signal: AbortSignal;
|
|
10
|
+
}
|
|
11
|
+
export interface StructuredCompactionConfig<SUMMARY_SCHEMA extends ZodType> {
|
|
12
|
+
schema: SUMMARY_SCHEMA;
|
|
13
|
+
keepRecentTurns: number;
|
|
14
|
+
threshold(input: AgentSnapshot): boolean | Promise<boolean>;
|
|
15
|
+
summarize(context: AgentCompactionContext<z.infer<SUMMARY_SCHEMA>>): z.infer<SUMMARY_SCHEMA> | Promise<z.infer<SUMMARY_SCHEMA>>;
|
|
16
|
+
createSummaryMessage(input: {
|
|
17
|
+
conversationId: string;
|
|
18
|
+
summary: z.infer<SUMMARY_SCHEMA>;
|
|
19
|
+
compactedMessages: readonly AgentMessage[];
|
|
20
|
+
}): AgentMessage;
|
|
21
|
+
readPreviousSummary?(message: AgentMessage): z.infer<SUMMARY_SCHEMA>;
|
|
22
|
+
}
|
|
23
|
+
export interface AgentCompactionResult {
|
|
24
|
+
outcome: 'not_needed' | 'nothing_eligible' | 'applied' | 'conflict' | 'not_found';
|
|
25
|
+
snapshot: AgentSnapshot;
|
|
26
|
+
}
|
|
27
|
+
export declare function structuredCompaction<SUMMARY_SCHEMA extends ZodType>(config: StructuredCompactionConfig<SUMMARY_SCHEMA>): (input: {
|
|
28
|
+
conversationId: string;
|
|
29
|
+
store: AgentRuntimeStore;
|
|
30
|
+
signal: AbortSignal;
|
|
31
|
+
previousSummary?: z.infer<SUMMARY_SCHEMA>;
|
|
32
|
+
}) => Promise<AgentCompactionResult>;
|
|
33
|
+
//# sourceMappingURL=compaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compaction.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/compaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAA4B,MAAM,SAAS,CAAC;AAE3E,MAAM,WAAW,sBAAsB,CAAC,OAAO;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,aAAa,CAAC;IACxB,gBAAgB,EAAE,SAAS,YAAY,EAAE,CAAC;IAC1C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,0BAA0B,CAAC,cAAc,SAAS,OAAO;IACxE,MAAM,EAAE,cAAc,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D,SAAS,CACP,OAAO,EAAE,sBAAsB,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,GACvD,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;IAC9D,oBAAoB,CAAC,KAAK,EAAE;QAC1B,cAAc,EAAE,MAAM,CAAC;QACvB,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QACjC,iBAAiB,EAAE,SAAS,YAAY,EAAE,CAAC;KAC5C,GAAG,YAAY,CAAC;IACjB,mBAAmB,CAAC,CAAC,OAAO,EAAE,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,YAAY,GAAG,kBAAkB,GAAG,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC;IAClF,QAAQ,EAAE,aAAa,CAAC;CACzB;AAqED,wBAAgB,oBAAoB,CAAC,cAAc,SAAS,OAAO,EACjE,MAAM,EAAE,0BAA0B,CAAC,cAAc,CAAC,WAM7B;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,iBAAiB,CAAC;IACzB,MAAM,EAAE,WAAW,CAAC;IACpB,eAAe,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;CAC3C,KAAG,OAAO,CAAC,qBAAqB,CAAC,CA4CnC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type AgentInputPolicy = 'queue' | 'interrupt';
|
|
2
|
+
export type AgentStopReason = 'user-interrupt' | 'timeout' | 'shutdown';
|
|
3
|
+
export interface AgentCoordinatedRun<RESULT> {
|
|
4
|
+
runId: string;
|
|
5
|
+
execute(): Promise<RESULT>;
|
|
6
|
+
}
|
|
7
|
+
export interface AgentRunTicket<RESULT> {
|
|
8
|
+
accepted: Promise<void>;
|
|
9
|
+
result: Promise<RESULT>;
|
|
10
|
+
}
|
|
11
|
+
export interface AgentSessionCoordinator {
|
|
12
|
+
submit<RESULT>(input: {
|
|
13
|
+
key: string;
|
|
14
|
+
policy: AgentInputPolicy;
|
|
15
|
+
create(signal: AbortSignal): AgentCoordinatedRun<RESULT> | Promise<AgentCoordinatedRun<RESULT>>;
|
|
16
|
+
}): AgentRunTicket<RESULT>;
|
|
17
|
+
stop(key: string, reason?: AgentStopReason): boolean;
|
|
18
|
+
close(options?: {
|
|
19
|
+
drainTimeoutMs?: number;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
isRunning(key: string): boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function createAgentSessionCoordinator(): AgentSessionCoordinator;
|
|
24
|
+
//# sourceMappingURL=coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coordinator.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,WAAW,CAAC;AACrD,MAAM,MAAM,eAAe,GAAG,gBAAgB,GAAG,SAAS,GAAG,UAAU,CAAC;AAExE,MAAM,WAAW,mBAAmB,CAAC,MAAM;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5B;AAED,MAAM,WAAW,cAAc,CAAC,MAAM;IACpC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;CACzB;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE;QACpB,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,gBAAgB,CAAC;QACzB,MAAM,CACJ,MAAM,EAAE,WAAW,GAClB,mBAAmB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;KACvE,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAC3B,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC;IACrD,KAAK,CAAC,OAAO,CAAC,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACjC;AAiBD,wBAAgB,6BAA6B,IAAI,uBAAuB,CAmGvE"}
|
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AgentTransientDeltaEventSchema: z.ZodObject<{
|
|
3
|
+
conversationId: z.ZodString;
|
|
4
|
+
runId: z.ZodString;
|
|
5
|
+
emittedAt: z.ZodISODateTime;
|
|
6
|
+
type: z.ZodLiteral<"assistant-delta">;
|
|
7
|
+
runtimeEpoch: z.ZodString;
|
|
8
|
+
sequence: z.ZodInt;
|
|
9
|
+
textDelta: z.ZodString;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare const AgentCheckpointEventSchema: z.ZodObject<{
|
|
12
|
+
conversationId: z.ZodString;
|
|
13
|
+
runId: z.ZodString;
|
|
14
|
+
emittedAt: z.ZodISODateTime;
|
|
15
|
+
type: z.ZodLiteral<"assistant-checkpoint">;
|
|
16
|
+
eventId: z.ZodString;
|
|
17
|
+
snapshotVersion: z.ZodInt;
|
|
18
|
+
message: z.ZodObject<{
|
|
19
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
conversationId: z.ZodString;
|
|
22
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
23
|
+
role: z.ZodEnum<{
|
|
24
|
+
assistant: "assistant";
|
|
25
|
+
summary: "summary";
|
|
26
|
+
system: "system";
|
|
27
|
+
user: "user";
|
|
28
|
+
}>;
|
|
29
|
+
status: z.ZodEnum<{
|
|
30
|
+
committed: "committed";
|
|
31
|
+
completed: "completed";
|
|
32
|
+
failed: "failed";
|
|
33
|
+
interrupted: "interrupted";
|
|
34
|
+
streaming: "streaming";
|
|
35
|
+
}>;
|
|
36
|
+
parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
37
|
+
type: z.ZodLiteral<"text">;
|
|
38
|
+
text: z.ZodString;
|
|
39
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
40
|
+
type: z.ZodLiteral<"reasoning">;
|
|
41
|
+
text: z.ZodString;
|
|
42
|
+
provider: z.ZodOptional<z.ZodObject<{
|
|
43
|
+
schemaVersion: z.ZodInt;
|
|
44
|
+
provider: z.ZodString;
|
|
45
|
+
data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
46
|
+
}, z.core.$strip>>;
|
|
47
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
48
|
+
type: z.ZodLiteral<"file">;
|
|
49
|
+
mediaType: z.ZodString;
|
|
50
|
+
reference: z.ZodString;
|
|
51
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
53
|
+
type: z.ZodLiteral<"source">;
|
|
54
|
+
sourceId: z.ZodString;
|
|
55
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
56
|
+
title: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
58
|
+
type: z.ZodLiteral<"tool-call">;
|
|
59
|
+
callId: z.ZodString;
|
|
60
|
+
toolName: z.ZodString;
|
|
61
|
+
input: z.ZodJSONSchema;
|
|
62
|
+
provider: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
schemaVersion: z.ZodInt;
|
|
64
|
+
provider: z.ZodString;
|
|
65
|
+
data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
66
|
+
}, z.core.$strip>>;
|
|
67
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
68
|
+
type: z.ZodLiteral<"tool-result">;
|
|
69
|
+
callId: z.ZodString;
|
|
70
|
+
toolName: z.ZodString;
|
|
71
|
+
outcome: z.ZodEnum<{
|
|
72
|
+
error: "error";
|
|
73
|
+
interrupted: "interrupted";
|
|
74
|
+
success: "success";
|
|
75
|
+
}>;
|
|
76
|
+
output: z.ZodOptional<z.ZodJSONSchema>;
|
|
77
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
78
|
+
type: z.ZodLiteral<"provider">;
|
|
79
|
+
envelope: z.ZodObject<{
|
|
80
|
+
schemaVersion: z.ZodInt;
|
|
81
|
+
provider: z.ZodString;
|
|
82
|
+
data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
85
|
+
type: z.ZodLiteral<"control">;
|
|
86
|
+
reason: z.ZodEnum<{
|
|
87
|
+
"run-interrupted": "run-interrupted";
|
|
88
|
+
"stale-run": "stale-run";
|
|
89
|
+
}>;
|
|
90
|
+
}, z.core.$strip>], "type">>;
|
|
91
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
92
|
+
createdAt: z.ZodISODateTime;
|
|
93
|
+
updatedAt: z.ZodISODateTime;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
export declare const AgentRunStateEventSchema: z.ZodObject<{
|
|
97
|
+
conversationId: z.ZodString;
|
|
98
|
+
runId: z.ZodString;
|
|
99
|
+
emittedAt: z.ZodISODateTime;
|
|
100
|
+
type: z.ZodLiteral<"run-state">;
|
|
101
|
+
eventId: z.ZodString;
|
|
102
|
+
snapshotVersion: z.ZodInt;
|
|
103
|
+
state: z.ZodEnum<{
|
|
104
|
+
abandoned: "abandoned";
|
|
105
|
+
cancelled: "cancelled";
|
|
106
|
+
completed: "completed";
|
|
107
|
+
failed: "failed";
|
|
108
|
+
interrupt_requested: "interrupt_requested";
|
|
109
|
+
interrupted: "interrupted";
|
|
110
|
+
queued: "queued";
|
|
111
|
+
running: "running";
|
|
112
|
+
}>;
|
|
113
|
+
}, z.core.$strip>;
|
|
114
|
+
export declare const AgentToolStatusEventSchema: z.ZodObject<{
|
|
115
|
+
conversationId: z.ZodString;
|
|
116
|
+
runId: z.ZodString;
|
|
117
|
+
emittedAt: z.ZodISODateTime;
|
|
118
|
+
type: z.ZodLiteral<"tool-status">;
|
|
119
|
+
runtimeEpoch: z.ZodString;
|
|
120
|
+
sequence: z.ZodInt;
|
|
121
|
+
callId: z.ZodString;
|
|
122
|
+
toolName: z.ZodString;
|
|
123
|
+
status: z.ZodEnum<{
|
|
124
|
+
completed: "completed";
|
|
125
|
+
failed: "failed";
|
|
126
|
+
interrupted: "interrupted";
|
|
127
|
+
started: "started";
|
|
128
|
+
}>;
|
|
129
|
+
input: z.ZodOptional<z.ZodJSONSchema>;
|
|
130
|
+
output: z.ZodOptional<z.ZodJSONSchema>;
|
|
131
|
+
}, z.core.$strip>;
|
|
132
|
+
export declare const AgentTerminalEventSchema: z.ZodObject<{
|
|
133
|
+
conversationId: z.ZodString;
|
|
134
|
+
runId: z.ZodString;
|
|
135
|
+
emittedAt: z.ZodISODateTime;
|
|
136
|
+
type: z.ZodLiteral<"terminal">;
|
|
137
|
+
eventId: z.ZodString;
|
|
138
|
+
snapshotVersion: z.ZodInt;
|
|
139
|
+
reason: z.ZodEnum<{
|
|
140
|
+
abandoned: "abandoned";
|
|
141
|
+
cancelled: "cancelled";
|
|
142
|
+
interrupted: "interrupted";
|
|
143
|
+
policy_stop: "policy_stop";
|
|
144
|
+
provider_failure: "provider_failure";
|
|
145
|
+
shutdown: "shutdown";
|
|
146
|
+
success: "success";
|
|
147
|
+
timeout: "timeout";
|
|
148
|
+
tool_failure: "tool_failure";
|
|
149
|
+
}>;
|
|
150
|
+
policyName: z.ZodOptional<z.ZodString>;
|
|
151
|
+
message: z.ZodObject<{
|
|
152
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
153
|
+
id: z.ZodString;
|
|
154
|
+
conversationId: z.ZodString;
|
|
155
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
156
|
+
role: z.ZodEnum<{
|
|
157
|
+
assistant: "assistant";
|
|
158
|
+
summary: "summary";
|
|
159
|
+
system: "system";
|
|
160
|
+
user: "user";
|
|
161
|
+
}>;
|
|
162
|
+
status: z.ZodEnum<{
|
|
163
|
+
committed: "committed";
|
|
164
|
+
completed: "completed";
|
|
165
|
+
failed: "failed";
|
|
166
|
+
interrupted: "interrupted";
|
|
167
|
+
streaming: "streaming";
|
|
168
|
+
}>;
|
|
169
|
+
parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
170
|
+
type: z.ZodLiteral<"text">;
|
|
171
|
+
text: z.ZodString;
|
|
172
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
173
|
+
type: z.ZodLiteral<"reasoning">;
|
|
174
|
+
text: z.ZodString;
|
|
175
|
+
provider: z.ZodOptional<z.ZodObject<{
|
|
176
|
+
schemaVersion: z.ZodInt;
|
|
177
|
+
provider: z.ZodString;
|
|
178
|
+
data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
179
|
+
}, z.core.$strip>>;
|
|
180
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
181
|
+
type: z.ZodLiteral<"file">;
|
|
182
|
+
mediaType: z.ZodString;
|
|
183
|
+
reference: z.ZodString;
|
|
184
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
185
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
186
|
+
type: z.ZodLiteral<"source">;
|
|
187
|
+
sourceId: z.ZodString;
|
|
188
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
189
|
+
title: z.ZodOptional<z.ZodString>;
|
|
190
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
191
|
+
type: z.ZodLiteral<"tool-call">;
|
|
192
|
+
callId: z.ZodString;
|
|
193
|
+
toolName: z.ZodString;
|
|
194
|
+
input: z.ZodJSONSchema;
|
|
195
|
+
provider: z.ZodOptional<z.ZodObject<{
|
|
196
|
+
schemaVersion: z.ZodInt;
|
|
197
|
+
provider: z.ZodString;
|
|
198
|
+
data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
199
|
+
}, z.core.$strip>>;
|
|
200
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
201
|
+
type: z.ZodLiteral<"tool-result">;
|
|
202
|
+
callId: z.ZodString;
|
|
203
|
+
toolName: z.ZodString;
|
|
204
|
+
outcome: z.ZodEnum<{
|
|
205
|
+
error: "error";
|
|
206
|
+
interrupted: "interrupted";
|
|
207
|
+
success: "success";
|
|
208
|
+
}>;
|
|
209
|
+
output: z.ZodOptional<z.ZodJSONSchema>;
|
|
210
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
211
|
+
type: z.ZodLiteral<"provider">;
|
|
212
|
+
envelope: z.ZodObject<{
|
|
213
|
+
schemaVersion: z.ZodInt;
|
|
214
|
+
provider: z.ZodString;
|
|
215
|
+
data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
216
|
+
}, z.core.$strip>;
|
|
217
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
218
|
+
type: z.ZodLiteral<"control">;
|
|
219
|
+
reason: z.ZodEnum<{
|
|
220
|
+
"run-interrupted": "run-interrupted";
|
|
221
|
+
"stale-run": "stale-run";
|
|
222
|
+
}>;
|
|
223
|
+
}, z.core.$strip>], "type">>;
|
|
224
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
225
|
+
createdAt: z.ZodISODateTime;
|
|
226
|
+
updatedAt: z.ZodISODateTime;
|
|
227
|
+
}, z.core.$strip>;
|
|
228
|
+
}, z.core.$strip>;
|
|
229
|
+
export declare const AgentRuntimeEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
230
|
+
conversationId: z.ZodString;
|
|
231
|
+
runId: z.ZodString;
|
|
232
|
+
emittedAt: z.ZodISODateTime;
|
|
233
|
+
type: z.ZodLiteral<"assistant-delta">;
|
|
234
|
+
runtimeEpoch: z.ZodString;
|
|
235
|
+
sequence: z.ZodInt;
|
|
236
|
+
textDelta: z.ZodString;
|
|
237
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
238
|
+
conversationId: z.ZodString;
|
|
239
|
+
runId: z.ZodString;
|
|
240
|
+
emittedAt: z.ZodISODateTime;
|
|
241
|
+
type: z.ZodLiteral<"assistant-checkpoint">;
|
|
242
|
+
eventId: z.ZodString;
|
|
243
|
+
snapshotVersion: z.ZodInt;
|
|
244
|
+
message: z.ZodObject<{
|
|
245
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
246
|
+
id: z.ZodString;
|
|
247
|
+
conversationId: z.ZodString;
|
|
248
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
249
|
+
role: z.ZodEnum<{
|
|
250
|
+
assistant: "assistant";
|
|
251
|
+
summary: "summary";
|
|
252
|
+
system: "system";
|
|
253
|
+
user: "user";
|
|
254
|
+
}>;
|
|
255
|
+
status: z.ZodEnum<{
|
|
256
|
+
committed: "committed";
|
|
257
|
+
completed: "completed";
|
|
258
|
+
failed: "failed";
|
|
259
|
+
interrupted: "interrupted";
|
|
260
|
+
streaming: "streaming";
|
|
261
|
+
}>;
|
|
262
|
+
parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
263
|
+
type: z.ZodLiteral<"text">;
|
|
264
|
+
text: z.ZodString;
|
|
265
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
266
|
+
type: z.ZodLiteral<"reasoning">;
|
|
267
|
+
text: z.ZodString;
|
|
268
|
+
provider: z.ZodOptional<z.ZodObject<{
|
|
269
|
+
schemaVersion: z.ZodInt;
|
|
270
|
+
provider: z.ZodString;
|
|
271
|
+
data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
272
|
+
}, z.core.$strip>>;
|
|
273
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
274
|
+
type: z.ZodLiteral<"file">;
|
|
275
|
+
mediaType: z.ZodString;
|
|
276
|
+
reference: z.ZodString;
|
|
277
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
278
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
279
|
+
type: z.ZodLiteral<"source">;
|
|
280
|
+
sourceId: z.ZodString;
|
|
281
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
282
|
+
title: z.ZodOptional<z.ZodString>;
|
|
283
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
284
|
+
type: z.ZodLiteral<"tool-call">;
|
|
285
|
+
callId: z.ZodString;
|
|
286
|
+
toolName: z.ZodString;
|
|
287
|
+
input: z.ZodJSONSchema;
|
|
288
|
+
provider: z.ZodOptional<z.ZodObject<{
|
|
289
|
+
schemaVersion: z.ZodInt;
|
|
290
|
+
provider: z.ZodString;
|
|
291
|
+
data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
292
|
+
}, z.core.$strip>>;
|
|
293
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
294
|
+
type: z.ZodLiteral<"tool-result">;
|
|
295
|
+
callId: z.ZodString;
|
|
296
|
+
toolName: z.ZodString;
|
|
297
|
+
outcome: z.ZodEnum<{
|
|
298
|
+
error: "error";
|
|
299
|
+
interrupted: "interrupted";
|
|
300
|
+
success: "success";
|
|
301
|
+
}>;
|
|
302
|
+
output: z.ZodOptional<z.ZodJSONSchema>;
|
|
303
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
304
|
+
type: z.ZodLiteral<"provider">;
|
|
305
|
+
envelope: z.ZodObject<{
|
|
306
|
+
schemaVersion: z.ZodInt;
|
|
307
|
+
provider: z.ZodString;
|
|
308
|
+
data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
309
|
+
}, z.core.$strip>;
|
|
310
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
311
|
+
type: z.ZodLiteral<"control">;
|
|
312
|
+
reason: z.ZodEnum<{
|
|
313
|
+
"run-interrupted": "run-interrupted";
|
|
314
|
+
"stale-run": "stale-run";
|
|
315
|
+
}>;
|
|
316
|
+
}, z.core.$strip>], "type">>;
|
|
317
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
318
|
+
createdAt: z.ZodISODateTime;
|
|
319
|
+
updatedAt: z.ZodISODateTime;
|
|
320
|
+
}, z.core.$strip>;
|
|
321
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
322
|
+
conversationId: z.ZodString;
|
|
323
|
+
runId: z.ZodString;
|
|
324
|
+
emittedAt: z.ZodISODateTime;
|
|
325
|
+
type: z.ZodLiteral<"run-state">;
|
|
326
|
+
eventId: z.ZodString;
|
|
327
|
+
snapshotVersion: z.ZodInt;
|
|
328
|
+
state: z.ZodEnum<{
|
|
329
|
+
abandoned: "abandoned";
|
|
330
|
+
cancelled: "cancelled";
|
|
331
|
+
completed: "completed";
|
|
332
|
+
failed: "failed";
|
|
333
|
+
interrupt_requested: "interrupt_requested";
|
|
334
|
+
interrupted: "interrupted";
|
|
335
|
+
queued: "queued";
|
|
336
|
+
running: "running";
|
|
337
|
+
}>;
|
|
338
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
339
|
+
conversationId: z.ZodString;
|
|
340
|
+
runId: z.ZodString;
|
|
341
|
+
emittedAt: z.ZodISODateTime;
|
|
342
|
+
type: z.ZodLiteral<"tool-status">;
|
|
343
|
+
runtimeEpoch: z.ZodString;
|
|
344
|
+
sequence: z.ZodInt;
|
|
345
|
+
callId: z.ZodString;
|
|
346
|
+
toolName: z.ZodString;
|
|
347
|
+
status: z.ZodEnum<{
|
|
348
|
+
completed: "completed";
|
|
349
|
+
failed: "failed";
|
|
350
|
+
interrupted: "interrupted";
|
|
351
|
+
started: "started";
|
|
352
|
+
}>;
|
|
353
|
+
input: z.ZodOptional<z.ZodJSONSchema>;
|
|
354
|
+
output: z.ZodOptional<z.ZodJSONSchema>;
|
|
355
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
356
|
+
conversationId: z.ZodString;
|
|
357
|
+
runId: z.ZodString;
|
|
358
|
+
emittedAt: z.ZodISODateTime;
|
|
359
|
+
type: z.ZodLiteral<"terminal">;
|
|
360
|
+
eventId: z.ZodString;
|
|
361
|
+
snapshotVersion: z.ZodInt;
|
|
362
|
+
reason: z.ZodEnum<{
|
|
363
|
+
abandoned: "abandoned";
|
|
364
|
+
cancelled: "cancelled";
|
|
365
|
+
interrupted: "interrupted";
|
|
366
|
+
policy_stop: "policy_stop";
|
|
367
|
+
provider_failure: "provider_failure";
|
|
368
|
+
shutdown: "shutdown";
|
|
369
|
+
success: "success";
|
|
370
|
+
timeout: "timeout";
|
|
371
|
+
tool_failure: "tool_failure";
|
|
372
|
+
}>;
|
|
373
|
+
policyName: z.ZodOptional<z.ZodString>;
|
|
374
|
+
message: z.ZodObject<{
|
|
375
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
376
|
+
id: z.ZodString;
|
|
377
|
+
conversationId: z.ZodString;
|
|
378
|
+
runId: z.ZodOptional<z.ZodString>;
|
|
379
|
+
role: z.ZodEnum<{
|
|
380
|
+
assistant: "assistant";
|
|
381
|
+
summary: "summary";
|
|
382
|
+
system: "system";
|
|
383
|
+
user: "user";
|
|
384
|
+
}>;
|
|
385
|
+
status: z.ZodEnum<{
|
|
386
|
+
committed: "committed";
|
|
387
|
+
completed: "completed";
|
|
388
|
+
failed: "failed";
|
|
389
|
+
interrupted: "interrupted";
|
|
390
|
+
streaming: "streaming";
|
|
391
|
+
}>;
|
|
392
|
+
parts: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
393
|
+
type: z.ZodLiteral<"text">;
|
|
394
|
+
text: z.ZodString;
|
|
395
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
396
|
+
type: z.ZodLiteral<"reasoning">;
|
|
397
|
+
text: z.ZodString;
|
|
398
|
+
provider: z.ZodOptional<z.ZodObject<{
|
|
399
|
+
schemaVersion: z.ZodInt;
|
|
400
|
+
provider: z.ZodString;
|
|
401
|
+
data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
402
|
+
}, z.core.$strip>>;
|
|
403
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
404
|
+
type: z.ZodLiteral<"file">;
|
|
405
|
+
mediaType: z.ZodString;
|
|
406
|
+
reference: z.ZodString;
|
|
407
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
408
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
409
|
+
type: z.ZodLiteral<"source">;
|
|
410
|
+
sourceId: z.ZodString;
|
|
411
|
+
url: z.ZodOptional<z.ZodURL>;
|
|
412
|
+
title: z.ZodOptional<z.ZodString>;
|
|
413
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
414
|
+
type: z.ZodLiteral<"tool-call">;
|
|
415
|
+
callId: z.ZodString;
|
|
416
|
+
toolName: z.ZodString;
|
|
417
|
+
input: z.ZodJSONSchema;
|
|
418
|
+
provider: z.ZodOptional<z.ZodObject<{
|
|
419
|
+
schemaVersion: z.ZodInt;
|
|
420
|
+
provider: z.ZodString;
|
|
421
|
+
data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
422
|
+
}, z.core.$strip>>;
|
|
423
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
424
|
+
type: z.ZodLiteral<"tool-result">;
|
|
425
|
+
callId: z.ZodString;
|
|
426
|
+
toolName: z.ZodString;
|
|
427
|
+
outcome: z.ZodEnum<{
|
|
428
|
+
error: "error";
|
|
429
|
+
interrupted: "interrupted";
|
|
430
|
+
success: "success";
|
|
431
|
+
}>;
|
|
432
|
+
output: z.ZodOptional<z.ZodJSONSchema>;
|
|
433
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
434
|
+
type: z.ZodLiteral<"provider">;
|
|
435
|
+
envelope: z.ZodObject<{
|
|
436
|
+
schemaVersion: z.ZodInt;
|
|
437
|
+
provider: z.ZodString;
|
|
438
|
+
data: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
439
|
+
}, z.core.$strip>;
|
|
440
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
441
|
+
type: z.ZodLiteral<"control">;
|
|
442
|
+
reason: z.ZodEnum<{
|
|
443
|
+
"run-interrupted": "run-interrupted";
|
|
444
|
+
"stale-run": "stale-run";
|
|
445
|
+
}>;
|
|
446
|
+
}, z.core.$strip>], "type">>;
|
|
447
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
448
|
+
createdAt: z.ZodISODateTime;
|
|
449
|
+
updatedAt: z.ZodISODateTime;
|
|
450
|
+
}, z.core.$strip>;
|
|
451
|
+
}, z.core.$strip>], "type">;
|
|
452
|
+
export type AgentRuntimeEvent = z.infer<typeof AgentRuntimeEventSchema>;
|
|
453
|
+
export type AgentRuntimePublisher = (event: AgentRuntimeEvent) => void | Promise<void>;
|
|
454
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB,eAAO,MAAM,8BAA8B;;;;;;;;iBAKzC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKrC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;iBAKnC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;iBASrC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOnC,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAMlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,qBAAqB,GAAG,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FilePart, type ModelMessage } from 'ai';
|
|
2
|
+
import type { AgentMessage, AgentMessagePart } from './schemas';
|
|
3
|
+
export interface AgentHistoryProjectionOptions {
|
|
4
|
+
resolveFile?(part: Extract<AgentMessagePart, {
|
|
5
|
+
type: 'file';
|
|
6
|
+
}>, message: AgentMessage): FilePart['data'] | Promise<FilePart['data']>;
|
|
7
|
+
unresolvedFile?: 'text' | 'omit' | 'error';
|
|
8
|
+
}
|
|
9
|
+
/** Project canonical engine records into provider-valid AI SDK messages. */
|
|
10
|
+
export declare function projectAgentHistory(messages: readonly AgentMessage[], options?: AgentHistoryProjectionOptions): Promise<ModelMessage[]>;
|
|
11
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAsB,MAAM,IAAI,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAyB,MAAM,WAAW,CAAC;AAEvF,MAAM,WAAW,6BAA6B;IAC5C,WAAW,CAAC,CACV,IAAI,EAAE,OAAO,CAAC,gBAAgB,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,EACjD,OAAO,EAAE,YAAY,GACpB,QAAQ,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAChD,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAC5C;AA0FD,4EAA4E;AAC5E,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,SAAS,YAAY,EAAE,EACjC,OAAO,GAAE,6BAAkC,GAC1C,OAAO,CAAC,YAAY,EAAE,CAAC,CAiBzB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RuntimeContext } from '../contract';
|
|
2
|
+
import type { OperationIdentity } from '../server/types';
|
|
3
|
+
import { type ToolExecutionControlReason, type ToolLifecycle } from '../tools/execute';
|
|
4
|
+
export interface AgentToolFenceContext {
|
|
5
|
+
runId: string;
|
|
6
|
+
stepId?: string;
|
|
7
|
+
callId?: string;
|
|
8
|
+
idempotencyKey?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AgentToolFenceConfig {
|
|
11
|
+
runId: string;
|
|
12
|
+
assertCurrent(input: AgentToolFenceContext): void | ToolExecutionControlReason | Promise<void> | Promise<ToolExecutionControlReason | undefined>;
|
|
13
|
+
context?(ctx: RuntimeContext, endpoint: OperationIdentity): Partial<AgentToolFenceContext>;
|
|
14
|
+
onSettled?(input: AgentToolFenceContext): void | Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/** Compose beside auth/application lifecycles with `composeToolLifecycle`. */
|
|
17
|
+
export declare function createAgentToolFenceLifecycle(config: AgentToolFenceConfig): ToolLifecycle;
|
|
18
|
+
//# sourceMappingURL=managed-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed-tools.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/managed-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CACX,KAAK,EAAE,qBAAqB,GAE1B,IAAI,GACJ,0BAA0B,GAC1B,OAAO,CAAC,IAAI,CAAC,GACb,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAAC;IACpD,OAAO,CAAC,CAAC,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC3F,SAAS,CAAC,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChE;AAUD,8EAA8E;AAC9E,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,oBAAoB,GAAG,aAAa,CAoBzF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { LanguageModel, LanguageModelUsage } from 'ai';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { AgentUsage } from './schemas';
|
|
4
|
+
export declare const AgentModelCapabilitySchema: z.ZodEnum<{
|
|
5
|
+
files: "files";
|
|
6
|
+
reasoning: "reasoning";
|
|
7
|
+
tools: "tools";
|
|
8
|
+
vision: "vision";
|
|
9
|
+
}>;
|
|
10
|
+
export type AgentModelCapability = z.infer<typeof AgentModelCapabilitySchema>;
|
|
11
|
+
export declare const AgentModelDescriptorSchema: z.ZodObject<{
|
|
12
|
+
provider: z.ZodString;
|
|
13
|
+
modelId: z.ZodString;
|
|
14
|
+
contextWindow: z.ZodInt;
|
|
15
|
+
capabilities: z.ZodArray<z.ZodEnum<{
|
|
16
|
+
files: "files";
|
|
17
|
+
reasoning: "reasoning";
|
|
18
|
+
tools: "tools";
|
|
19
|
+
vision: "vision";
|
|
20
|
+
}>>;
|
|
21
|
+
observedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
22
|
+
source: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export type AgentModelDescriptor = z.infer<typeof AgentModelDescriptorSchema>;
|
|
25
|
+
export interface AgentLanguageModelProvider {
|
|
26
|
+
create(modelId: string): LanguageModel;
|
|
27
|
+
normalizeUsage?(input: {
|
|
28
|
+
usage: LanguageModelUsage;
|
|
29
|
+
providerMetadata?: unknown;
|
|
30
|
+
}): AgentUsage;
|
|
31
|
+
}
|
|
32
|
+
export interface AgentModelDeclaration extends AgentModelDescriptor {
|
|
33
|
+
provider: string;
|
|
34
|
+
}
|
|
35
|
+
export interface AgentModelRegistryConfig<MODELS extends Record<string, AgentModelDeclaration>> {
|
|
36
|
+
models: MODELS;
|
|
37
|
+
providers: Readonly<Record<string, AgentLanguageModelProvider>>;
|
|
38
|
+
}
|
|
39
|
+
export interface AgentResolvedModel {
|
|
40
|
+
descriptor: AgentModelDescriptor;
|
|
41
|
+
model: LanguageModel;
|
|
42
|
+
normalizeUsage?: AgentLanguageModelProvider['normalizeUsage'];
|
|
43
|
+
}
|
|
44
|
+
export interface AgentModelRegistry<MODEL_KEY extends string> {
|
|
45
|
+
keys(): readonly MODEL_KEY[];
|
|
46
|
+
descriptor(key: MODEL_KEY): AgentModelDescriptor;
|
|
47
|
+
supports(key: MODEL_KEY, capabilities: readonly AgentModelCapability[]): boolean;
|
|
48
|
+
resolve(key: MODEL_KEY, capabilities?: readonly AgentModelCapability[]): AgentResolvedModel;
|
|
49
|
+
}
|
|
50
|
+
export declare function defineModelRegistry<MODELS extends Record<string, AgentModelDeclaration>>(config: AgentModelRegistryConfig<MODELS>): AgentModelRegistry<Extract<keyof MODELS, string>>;
|
|
51
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AAC5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,eAAO,MAAM,0BAA0B;;;;;EAAoD,CAAC;AAE5F,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,eAAO,MAAM,0BAA0B;;;;;;;;;;;;iBAOrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,MAAM,WAAW,0BAA0B;IACzC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC;IACvC,cAAc,CAAC,CAAC,KAAK,EAAE;QACrB,KAAK,EAAE,kBAAkB,CAAC;QAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;KAC5B,GAAG,UAAU,CAAC;CAChB;AAED,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,wBAAwB,CACvC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC;IAEpD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC,CAAC;CACjE;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,oBAAoB,CAAC;IACjC,KAAK,EAAE,aAAa,CAAC;IACrB,cAAc,CAAC,EAAE,0BAA0B,CAAC,gBAAgB,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,kBAAkB,CAAC,SAAS,SAAS,MAAM;IAC1D,IAAI,IAAI,SAAS,SAAS,EAAE,CAAC;IAC7B,UAAU,CAAC,GAAG,EAAE,SAAS,GAAG,oBAAoB,CAAC;IACjD,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,oBAAoB,EAAE,GAAG,OAAO,CAAC;IACjF,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,SAAS,oBAAoB,EAAE,GAAG,kBAAkB,CAAC;CAC7F;AAED,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,EACtF,MAAM,EAAE,wBAAwB,CAAC,MAAM,CAAC,GACvC,kBAAkB,CAAC,OAAO,CAAC,MAAM,MAAM,EAAE,MAAM,CAAC,CAAC,CAqCnD"}
|