gemi 0.60.0 → 0.62.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/Agent.d.ts +533 -25
- package/dist/ai/Agent.d.ts.map +1 -1
- package/dist/ai/Agent.test-d.d.ts +2 -0
- package/dist/ai/Agent.test-d.d.ts.map +1 -0
- package/dist/ai/AgentController.d.ts +275 -6
- package/dist/ai/AgentController.d.ts.map +1 -1
- package/dist/ai/AgentProvider.d.ts +255 -0
- package/dist/ai/AgentProvider.d.ts.map +1 -0
- package/dist/ai/Schema.d.ts +125 -0
- package/dist/ai/Schema.d.ts.map +1 -0
- package/dist/ai/Schema.test-d.d.ts +2 -0
- package/dist/ai/Schema.test-d.d.ts.map +1 -0
- package/dist/ai/client/index.d.ts +24 -0
- package/dist/ai/client/index.d.ts.map +1 -0
- package/dist/ai/client/index.js +1053 -0
- package/dist/ai/client/index.js.map +1 -0
- package/dist/ai/client/reducer.d.ts +127 -0
- package/dist/ai/client/reducer.d.ts.map +1 -0
- package/dist/ai/client/reducer.test-d.d.ts +2 -0
- package/dist/ai/client/reducer.test-d.d.ts.map +1 -0
- package/dist/ai/client/sse.d.ts +54 -0
- package/dist/ai/client/sse.d.ts.map +1 -0
- package/dist/ai/example.d.ts +129 -0
- package/dist/ai/example.d.ts.map +1 -0
- package/dist/ai/index.d.ts +35 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +20 -0
- package/dist/ai/index.js.map +23 -0
- package/dist/ai/live/harness.d.ts +137 -0
- package/dist/ai/live/harness.d.ts.map +1 -0
- package/dist/ai/providers/call.d.ts +42 -0
- package/dist/ai/providers/call.d.ts.map +1 -0
- package/dist/ai/providers/capabilities.d.ts +50 -0
- package/dist/ai/providers/capabilities.d.ts.map +1 -0
- package/dist/ai/providers/errors.d.ts +37 -0
- package/dist/ai/providers/errors.d.ts.map +1 -0
- package/dist/ai/providers/fakeProvider.d.ts +35 -0
- package/dist/ai/providers/fakeProvider.d.ts.map +1 -0
- package/dist/ai/providers/http.d.ts +46 -0
- package/dist/ai/providers/http.d.ts.map +1 -0
- package/dist/ai/providers/request.d.ts +69 -0
- package/dist/ai/providers/request.d.ts.map +1 -0
- package/dist/ai/providers/stream.d.ts +42 -0
- package/dist/ai/providers/stream.d.ts.map +1 -0
- package/dist/ai/signing.d.ts +195 -0
- package/dist/ai/signing.d.ts.map +1 -0
- package/dist/ai/store/LiveRuns.d.ts +142 -0
- package/dist/ai/store/LiveRuns.d.ts.map +1 -0
- package/dist/ai/store/MemoryAgentStore.d.ts +61 -0
- package/dist/ai/store/MemoryAgentStore.d.ts.map +1 -0
- package/dist/ai/store/index.d.ts +4 -0
- package/dist/ai/store/index.d.ts.map +1 -0
- package/dist/ai/store/sse.d.ts +58 -0
- package/dist/ai/store/sse.d.ts.map +1 -0
- package/dist/ai/store/stubAgentRun.d.ts +56 -0
- package/dist/ai/store/stubAgentRun.d.ts.map +1 -0
- package/dist/ai/types.d.ts +443 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/ai/useChat.d.ts +253 -7
- package/dist/ai/useChat.d.ts.map +1 -1
- package/dist/chunk-1aqzcgfr.js +5 -0
- package/dist/chunk-1aqzcgfr.js.map +10 -0
- package/dist/{chunk-get4mkx8.js → chunk-1b7e9rj7.js} +2 -2
- package/dist/{chunk-get4mkx8.js.map → chunk-1b7e9rj7.js.map} +1 -1
- package/dist/{chunk-j06g4sqc.js → chunk-528n3vgy.js} +2 -2
- package/dist/{chunk-j06g4sqc.js.map → chunk-528n3vgy.js.map} +1 -1
- package/dist/{chunk-2khdxyjb.js → chunk-57a0nqfj.js} +1 -1
- package/dist/chunk-57a0nqfj.js.map +10 -0
- package/dist/chunk-5fj71djg.js +6 -0
- package/dist/{chunk-y3zz410b.js.map → chunk-5fj71djg.js.map} +2 -2
- package/dist/{chunk-c40n5r4v.js → chunk-5mhcwnyd.js} +2 -2
- package/dist/{chunk-c40n5r4v.js.map → chunk-5mhcwnyd.js.map} +1 -1
- package/dist/{chunk-gwchvzdp.js → chunk-71pk1mxx.js} +2 -2
- package/dist/{chunk-gwchvzdp.js.map → chunk-71pk1mxx.js.map} +1 -1
- package/dist/{chunk-spbgpndn.js → chunk-7t1hjs9f.js} +2 -2
- package/dist/{chunk-spbgpndn.js.map → chunk-7t1hjs9f.js.map} +1 -1
- package/dist/{chunk-9gsdcjt7.js → chunk-7xvaace2.js} +3 -3
- package/dist/{chunk-9gsdcjt7.js.map → chunk-7xvaace2.js.map} +1 -1
- package/dist/{chunk-fxy42w6n.js → chunk-8ag0da2s.js} +2 -2
- package/dist/{chunk-fxy42w6n.js.map → chunk-8ag0da2s.js.map} +1 -1
- package/dist/chunk-8r8epsef.js +5 -0
- package/dist/chunk-8r8epsef.js.map +11 -0
- package/dist/{chunk-0fm6jh9b.js → chunk-9nmvm20t.js} +2 -2
- package/dist/{chunk-0fm6jh9b.js.map → chunk-9nmvm20t.js.map} +1 -1
- package/dist/chunk-9penj44g.js +5 -0
- package/dist/{chunk-khf9xda6.js.map → chunk-9penj44g.js.map} +2 -2
- package/dist/{chunk-98a3k7bp.js → chunk-9xpa7dpy.js} +2 -2
- package/dist/{chunk-98a3k7bp.js.map → chunk-9xpa7dpy.js.map} +1 -1
- package/dist/{chunk-qva4841r.js → chunk-a1exbqcq.js} +3 -3
- package/dist/{chunk-qva4841r.js.map → chunk-a1exbqcq.js.map} +1 -1
- package/dist/{chunk-cw9y6k15.js → chunk-bb19bwg6.js} +2 -2
- package/dist/{chunk-cw9y6k15.js.map → chunk-bb19bwg6.js.map} +1 -1
- package/dist/{chunk-3gvjn3q4.js → chunk-cf7bvd12.js} +1 -1
- package/dist/{chunk-rkbv3df7.js → chunk-djp2xeqe.js} +2 -2
- package/dist/{chunk-rkbv3df7.js.map → chunk-djp2xeqe.js.map} +1 -1
- package/dist/chunk-ds44bqr9.js +4 -0
- package/dist/{chunk-4mcyyh1v.js.map → chunk-ds44bqr9.js.map} +4 -9
- package/dist/{chunk-wzvs3sym.js → chunk-exndjhza.js} +3 -3
- package/dist/{chunk-wzvs3sym.js.map → chunk-exndjhza.js.map} +1 -1
- package/dist/{chunk-f6dd4gd8.js → chunk-f233yzxf.js} +2 -2
- package/dist/{chunk-f6dd4gd8.js.map → chunk-f233yzxf.js.map} +1 -1
- package/dist/chunk-fz5g2z6h.js +4 -0
- package/dist/{chunk-fbvvqf9b.js.map → chunk-fz5g2z6h.js.map} +2 -2
- package/dist/{chunk-vj9538yn.js → chunk-gcszdwcb.js} +2 -2
- package/dist/{chunk-vj9538yn.js.map → chunk-gcszdwcb.js.map} +1 -1
- package/dist/{chunk-dgasxgsm.js → chunk-hk06nhxh.js} +4 -4
- package/dist/{chunk-dgasxgsm.js.map → chunk-hk06nhxh.js.map} +5 -5
- package/dist/{chunk-pkjq9833.js → chunk-htesx7ym.js} +4 -4
- package/dist/{chunk-pkjq9833.js.map → chunk-htesx7ym.js.map} +1 -1
- package/dist/{chunk-stq96kya.js → chunk-k2sjvt0c.js} +2 -2
- package/dist/{chunk-stq96kya.js.map → chunk-k2sjvt0c.js.map} +1 -1
- package/dist/{chunk-x8beq9c4.js → chunk-k4a2gzyc.js} +2 -2
- package/dist/{chunk-x8beq9c4.js.map → chunk-k4a2gzyc.js.map} +1 -1
- package/dist/{chunk-zhbrkpb3.js → chunk-k75phgj4.js} +4 -4
- package/dist/{chunk-zhbrkpb3.js.map → chunk-k75phgj4.js.map} +1 -1
- package/dist/{chunk-23h0dmx2.js → chunk-kac5vmvn.js} +2 -2
- package/dist/{chunk-23h0dmx2.js.map → chunk-kac5vmvn.js.map} +1 -1
- package/dist/{chunk-y64j80v9.js → chunk-m0tp7zjp.js} +2 -2
- package/dist/{chunk-y64j80v9.js.map → chunk-m0tp7zjp.js.map} +1 -1
- package/dist/{chunk-06j6rsew.js → chunk-m45j7p1y.js} +2 -2
- package/dist/{chunk-06j6rsew.js.map → chunk-m45j7p1y.js.map} +1 -1
- package/dist/chunk-mca9wsvs.js +5 -0
- package/dist/{chunk-z2tcxwyr.js.map → chunk-mca9wsvs.js.map} +3 -4
- package/dist/{chunk-tey1xayb.js → chunk-ms13evzp.js} +2 -2
- package/dist/{chunk-tey1xayb.js.map → chunk-ms13evzp.js.map} +1 -1
- package/dist/{chunk-bn1v4sfs.js → chunk-r962ae93.js} +2 -2
- package/dist/{chunk-bn1v4sfs.js.map → chunk-r962ae93.js.map} +1 -1
- package/dist/chunk-snb68dgr.js +4 -0
- package/dist/{chunk-hwhw98hc.js.map → chunk-snb68dgr.js.map} +1 -1
- package/dist/chunk-sz051605.js +5 -0
- package/dist/chunk-sz051605.js.map +14 -0
- package/dist/{chunk-2cwcfwg3.js → chunk-tr3cbx8k.js} +2 -2
- package/dist/{chunk-2cwcfwg3.js.map → chunk-tr3cbx8k.js.map} +2 -2
- package/dist/{chunk-zqsfanvk.js → chunk-wpb1xpdp.js} +2 -2
- package/dist/{chunk-zqsfanvk.js.map → chunk-wpb1xpdp.js.map} +1 -1
- package/dist/{chunk-z1e55w67.js → chunk-ybqss0jy.js} +2 -2
- package/dist/{chunk-z1e55w67.js.map → chunk-ybqss0jy.js.map} +1 -1
- package/dist/{chunk-cejf873g.js → chunk-yk5wqmyh.js} +2 -2
- package/dist/{chunk-cejf873g.js.map → chunk-yk5wqmyh.js.map} +1 -1
- package/dist/{chunk-8kj3zrm9.js → chunk-ywntv8yw.js} +4 -4
- package/dist/{chunk-8kj3zrm9.js.map → chunk-ywntv8yw.js.map} +1 -1
- package/dist/chunks/{ThemeProvider-ByU4BQdL.js → ThemeProvider-BZ2SsSZ3.js} +60 -39
- package/dist/chunks/ThemeProvider-BZ2SsSZ3.js.map +1 -0
- package/dist/chunks/useParams-BN3XXfmG.js +20 -0
- package/dist/chunks/useParams-BN3XXfmG.js.map +1 -0
- package/dist/client/index.js +3 -3
- package/dist/client/index.js.map +1 -1
- package/dist/client/useDictionary.d.ts.map +1 -1
- package/dist/database/index.js +1 -1
- package/dist/facades/Storage.d.ts +6 -2
- package/dist/facades/Storage.d.ts.map +1 -1
- package/dist/facades/index.js +2 -2
- package/dist/facades/index.js.map +1 -1
- package/dist/http/ApiRouter.d.ts +30 -2
- package/dist/http/ApiRouter.d.ts.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/i18n/defineDictionary.d.ts +7 -4
- package/dist/i18n/defineDictionary.d.ts.map +1 -1
- package/dist/i18n/dictionaryRegistry.d.ts +38 -14
- package/dist/i18n/dictionaryRegistry.d.ts.map +1 -1
- package/dist/i18n/dictionaryRuntime.js +1 -1
- package/dist/i18n/index.js +2 -2
- package/dist/i18n/index.js.map +2 -2
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +2 -2
- package/dist/orm/index.js +2 -2
- package/dist/orm/index.js.map +2 -2
- package/dist/server/index.js +1 -1
- package/dist/services/file-storage/drivers/AzureBlobDriver.d.ts +3 -2
- package/dist/services/file-storage/drivers/AzureBlobDriver.d.ts.map +1 -1
- package/dist/services/file-storage/drivers/FileStorageDriver.d.ts +2 -2
- package/dist/services/file-storage/drivers/FileStorageDriver.d.ts.map +1 -1
- package/dist/services/file-storage/drivers/FileSystemDriver.d.ts +2 -2
- package/dist/services/file-storage/drivers/FileSystemDriver.d.ts.map +1 -1
- package/dist/services/file-storage/drivers/S3Driver.d.ts +2 -2
- package/dist/services/file-storage/drivers/S3Driver.d.ts.map +1 -1
- package/dist/services/file-storage/drivers/types.d.ts +9 -1
- package/dist/services/file-storage/drivers/types.d.ts.map +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +6 -6
- package/dist/services/index.js.map +4 -4
- package/dist/testing/index.js +2 -1
- package/dist/testing/index.js.map +1 -1
- package/package.json +3 -1
- package/dist/chunk-2khdxyjb.js.map +0 -10
- package/dist/chunk-4mcyyh1v.js +0 -4
- package/dist/chunk-fbvvqf9b.js +0 -4
- package/dist/chunk-hwhw98hc.js +0 -4
- package/dist/chunk-khf9xda6.js +0 -5
- package/dist/chunk-q0y0j3ne.js +0 -5
- package/dist/chunk-q0y0j3ne.js.map +0 -11
- package/dist/chunk-y3zz410b.js +0 -6
- package/dist/chunk-z2tcxwyr.js +0 -5
- package/dist/chunks/ThemeProvider-ByU4BQdL.js.map +0 -1
- /package/dist/{chunk-3gvjn3q4.js.map → chunk-cf7bvd12.js.map} +0 -0
package/dist/ai/Agent.d.ts
CHANGED
|
@@ -1,33 +1,541 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { HttpRequest } from "../http";
|
|
2
|
+
import type { AgentProvider } from "./AgentProvider";
|
|
3
|
+
import type { Infer, Schema } from "./Schema";
|
|
4
|
+
import type { AgentMessage, AgentStreamEvent, AgentStreamFrame, ClientTurn, FinishReason, NestedRun, PendingToolCall, ToolShapes, Usage } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* Everything a tool needs from the request it is running inside.
|
|
7
|
+
*
|
|
8
|
+
* Tools are created once at module scope and shared by every request, so they
|
|
9
|
+
* cannot close over a user or an abort signal — and anything mutable stored on
|
|
10
|
+
* the tool itself would leak across requests. That is why the run's state
|
|
11
|
+
* arrives as an argument instead: the tool stays a singleton and the context is
|
|
12
|
+
* per call.
|
|
13
|
+
*/
|
|
14
|
+
export interface ToolContext {
|
|
15
|
+
req: HttpRequest<any, any>;
|
|
16
|
+
runId: string;
|
|
17
|
+
threadId?: string;
|
|
18
|
+
toolCallId: string;
|
|
19
|
+
/**
|
|
20
|
+
* Aborted when the user calls `stop()`. Not when the connection drops — a run
|
|
21
|
+
* outlives the request that started it so a refresh can reattach, which means
|
|
22
|
+
* a disconnect is no longer a signal to stop working.
|
|
23
|
+
*/
|
|
24
|
+
signal: AbortSignal;
|
|
25
|
+
/** Which step of the tool loop this is, starting at 1. */
|
|
26
|
+
step: number;
|
|
27
|
+
/**
|
|
28
|
+
* How deep this tool is inside nested runs: 0 at the top, 1 inside a tool of
|
|
29
|
+
* an agent started by `runAgent`, and so on. Compared against `maxDepth` on
|
|
30
|
+
* `Agent.create` so a cycle — agent A with a tool that runs agent A — fails
|
|
31
|
+
* with a sentence to read instead of exhausting the stack.
|
|
32
|
+
*/
|
|
33
|
+
readonly depth: number;
|
|
34
|
+
/**
|
|
35
|
+
* True when this tool is being re-entered after a sub-agent it started asked
|
|
36
|
+
* the user something and the user answered.
|
|
37
|
+
*
|
|
38
|
+
* READ THE `runAgent` NOTE BEFORE USING IT. This is the flag that lets a tool
|
|
39
|
+
* tell a first attempt from a replay, and it exists because there is nothing
|
|
40
|
+
* to tell it otherwise: the tool body ran once already.
|
|
41
|
+
*/
|
|
42
|
+
readonly resumed: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Runs another agent from inside this tool, wired into the parent run.
|
|
45
|
+
*
|
|
46
|
+
* A tool can already drive a sub-agent by hand — make one, iterate it, yield
|
|
47
|
+
* its events as progress. What this does that hand-rolling cannot is join the
|
|
48
|
+
* two runs: the sub-run inherits `ctx.signal` so the parent's `stop()` reaches
|
|
49
|
+
* it; every sub-run event is re-emitted on the parent stream as
|
|
50
|
+
* `nested-event`, numbered in the parent's `seq`, so `/attach` replay stays
|
|
51
|
+
* correct through the nesting; the sub-run's usage rolls into the parent's;
|
|
52
|
+
* its transcript is recorded on the parent's `ToolCallPart.nested`; and the
|
|
53
|
+
* depth and agent-name chain travel with it, so a cycle fails fast.
|
|
54
|
+
*
|
|
55
|
+
* ESCALATION. If the sub-run ends `awaiting-input` — it has an approval tool,
|
|
56
|
+
* or it asked a question — `onPending: "escalate"` (the default) throws a
|
|
57
|
+
* `PendingEscalation` carrying the inner pending calls, which the parent run
|
|
58
|
+
* collects exactly like pending calls of its own: the parent ends
|
|
59
|
+
* `awaiting-input` with the sub-agent's questions in its list, and the client
|
|
60
|
+
* answers them with the same `approve()` / `answer()` it uses for any other.
|
|
61
|
+
* `onPending: "deny"` refuses them instead and lets the sub-run finish.
|
|
62
|
+
*
|
|
63
|
+
* THE COST, WHICH IS REAL AND WHICH YOU MUST DESIGN AROUND. A JS async
|
|
64
|
+
* generator cannot be suspended across a turn boundary: `awaiting-input` is
|
|
65
|
+
* terminal for the stream, the next turn re-enters the loop at the top and
|
|
66
|
+
* rebuilds its state from the message history, and a paused generator is not
|
|
67
|
+
* in that history and cannot be put there. So an escalating tool is
|
|
68
|
+
* RE-ENTERED FROM THE TOP on the next turn, with `ctx.resumed === true`, and
|
|
69
|
+
* `runAgent` is memoized by call index within the tool call: the Nth
|
|
70
|
+
* `runAgent` of a tool call that already completed on an earlier turn returns
|
|
71
|
+
* its persisted result immediately, calling no provider and running no
|
|
72
|
+
* sub-tool, and only the sub-run that escalated actually continues.
|
|
73
|
+
*
|
|
74
|
+
* The index is the only key there is, so a body whose `runAgent` calls sit in
|
|
75
|
+
* a branch or a loop can produce a different sequence on the replay and make
|
|
76
|
+
* index N mean two different things. That is checked, not trusted: a mismatch
|
|
77
|
+
* fails the tool call with a sentence naming both sub-runs, because pairing a
|
|
78
|
+
* user's answer with a sub-run they never saw would be invisible.
|
|
79
|
+
*
|
|
80
|
+
* Which means: CODE BEFORE AN ESCALATING `runAgent` RUNS AGAIN ON RESUME.
|
|
81
|
+
* Side effects there are repeated. Put your side effects after the
|
|
82
|
+
* `runAgent`, or make them idempotent, or branch on `ctx.resumed`. This is
|
|
83
|
+
* inherent to replay and it is the same bargain the outer tool loop already
|
|
84
|
+
* makes; it is written here in plain words rather than solved with a
|
|
85
|
+
* checkpoint API, because that is a much larger feature than this one.
|
|
86
|
+
*/
|
|
87
|
+
runAgent<A extends AnyAgent>(agent: A, params?: RunAgentParams): Promise<NestedRunResult>;
|
|
88
|
+
}
|
|
89
|
+
/** What `ctx.runAgent` is given. `messages` and `prompt` are alternatives. */
|
|
90
|
+
export interface RunAgentParams {
|
|
91
|
+
/** Prior turns for the sub-agent. Starts empty when omitted. */
|
|
92
|
+
messages?: AgentMessage[];
|
|
93
|
+
/** Sugar for a single user turn — the common case, and the whole message
|
|
94
|
+
* list when there is no sub-conversation to continue. */
|
|
95
|
+
prompt?: string;
|
|
96
|
+
/** Appended to the sub-agent's own `instructions`, for this run only. */
|
|
97
|
+
instructions?: string;
|
|
98
|
+
/** Shown on the nested transcript, e.g. "researching pricing". */
|
|
99
|
+
label?: string;
|
|
100
|
+
/**
|
|
101
|
+
* What to do when the sub-run ends `awaiting-input`. `"escalate"` (the
|
|
102
|
+
* default) throws `PendingEscalation` so the question reaches the user;
|
|
103
|
+
* `"deny"` refuses every pending call and lets the sub-run finish, which is
|
|
104
|
+
* what a tool wants when the sub-agent is meant to be autonomous.
|
|
105
|
+
*
|
|
106
|
+
* `"deny"` is refused *in place*, inside the sub-run's own loop, so the
|
|
107
|
+
* sub-agent is told it cannot ask and takes another step rather than ending
|
|
108
|
+
* parked — and it is inherited by everything below, so a grandchild asking to
|
|
109
|
+
* escalate is overruled too. A promise that nothing from this subtree reaches
|
|
110
|
+
* the user is only worth making if the whole subtree keeps it.
|
|
111
|
+
*/
|
|
112
|
+
onPending?: "escalate" | "deny";
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* What a completed sub-run gives back.
|
|
116
|
+
*
|
|
117
|
+
* `nested` is the transcript as it is recorded on the parent's tool-call part,
|
|
118
|
+
* so a tool that wants to summarize what its sub-agent did reads the same
|
|
119
|
+
* object the UI renders rather than a second representation of it.
|
|
120
|
+
*/
|
|
121
|
+
export interface NestedRunResult<O = unknown> {
|
|
122
|
+
runId: string;
|
|
123
|
+
/** The sub-agent's name — carried so a caller that fans out over several
|
|
124
|
+
* agents can tell the results apart without tracking the order. */
|
|
125
|
+
agent: string;
|
|
126
|
+
messages: AgentMessage[];
|
|
127
|
+
finishReason: FinishReason;
|
|
128
|
+
usage: Usage;
|
|
129
|
+
/** Set when the sub-agent declares an `output` schema and the run finished. */
|
|
130
|
+
output?: O;
|
|
131
|
+
/** The record written to the parent's `ToolCallPart.nested`. */
|
|
132
|
+
nested: NestedRun;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Thrown by `ctx.runAgent` when a sub-run ends `awaiting-input`.
|
|
136
|
+
*
|
|
137
|
+
* An exception rather than a return value because it must not be mistaken for
|
|
138
|
+
* an answer: a tool that ignored an `{ escalated: true }` field would return a
|
|
139
|
+
* result to the model as if the sub-agent had finished, and the model would act
|
|
140
|
+
* on an answer nobody gave. `executeTool` lets this one propagate instead of
|
|
141
|
+
* turning it into a `tool_error`, and the step loop collects `pending` exactly
|
|
142
|
+
* like the pending calls it produced itself.
|
|
143
|
+
*
|
|
144
|
+
* `path` is the chain of tool-call ids down to the escalating call; each entry
|
|
145
|
+
* of `pending` already carries its own full path, and this is the prefix they
|
|
146
|
+
* share.
|
|
147
|
+
*/
|
|
148
|
+
export declare class PendingEscalation extends Error {
|
|
149
|
+
readonly pending: PendingToolCall[];
|
|
150
|
+
readonly path: string[];
|
|
151
|
+
/** The sub-run that parked, so the parent can record its transcript before
|
|
152
|
+
* ending the turn — an escalation is a pause, not a lost run. */
|
|
153
|
+
readonly nested: NestedRun;
|
|
154
|
+
constructor(params: {
|
|
155
|
+
pending: PendingToolCall[];
|
|
156
|
+
path: string[];
|
|
157
|
+
nested: NestedRun;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* A tool either resolves once, or yields progress and then returns.
|
|
162
|
+
*
|
|
163
|
+
* The generator form exists because a tool that takes twenty seconds is the
|
|
164
|
+
* normal case, not the exotic one, and a chat UI that shows nothing for twenty
|
|
165
|
+
* seconds looks broken. Yields become `tool-progress` events; the return value
|
|
166
|
+
* is the result the model sees.
|
|
167
|
+
*/
|
|
168
|
+
export type ToolExecute<Input, Output, Progress = unknown> = (input: Input, ctx: ToolContext) => Promise<Output> | AsyncGenerator<Progress, Output, void>;
|
|
169
|
+
type ToolDefinitionBase<Name extends string, Input, Output> = {
|
|
170
|
+
name: Name;
|
|
171
|
+
/** The model's only description of when to reach for this. */
|
|
4
172
|
description: string;
|
|
5
|
-
inputSchema: Schema<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
173
|
+
inputSchema: Schema<Input>;
|
|
174
|
+
/**
|
|
175
|
+
* Optional for a server tool, required for a client one — there it is what
|
|
176
|
+
* the answer is validated against before the model sees it, and what types
|
|
177
|
+
* the value the browser has to produce.
|
|
178
|
+
*/
|
|
179
|
+
outputSchema?: Schema<Output>;
|
|
180
|
+
/**
|
|
181
|
+
* Withholds this tool's parameter schema from the request: the model is shown
|
|
182
|
+
* only the name and description, and pulls the rest in with the provider's
|
|
183
|
+
* `tool_search` when it decides it wants the tool (`defer_loading` on the
|
|
184
|
+
* wire).
|
|
185
|
+
*
|
|
186
|
+
* It says nothing about who runs the tool or when — it is a statement about
|
|
187
|
+
* the prompt, not about execution. What it buys is context: an agent with
|
|
188
|
+
* forty tools spends most of its prompt on schemas for tools it will not
|
|
189
|
+
* call, and deferred ones load at the end of the window, so adding one
|
|
190
|
+
* mid-conversation does not invalidate the cache.
|
|
191
|
+
*
|
|
192
|
+
* Purely an optimization, and gemi treats it as one: a provider that cannot
|
|
193
|
+
* do tool search is sent the schemas inline, and the agent behaves the same.
|
|
194
|
+
* So it is safe to set on a model that does not support it, and worth setting
|
|
195
|
+
* only for tools that are large, numerous, or rarely reached.
|
|
196
|
+
*/
|
|
197
|
+
deferred?: boolean;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Two ways a tool's result comes to exist, and neither changes the shape of the
|
|
201
|
+
* conversation.
|
|
202
|
+
*
|
|
203
|
+
* `execute` — the server runs it.
|
|
204
|
+
* `answeredBy: "client"` — the browser produces the result: a question for the
|
|
205
|
+
* user, or something only the page can do. The stream ends `awaiting-input`
|
|
206
|
+
* and the answer arrives as an ordinary turn.
|
|
207
|
+
*
|
|
208
|
+
* `requiresApproval` applies to the first: the server can run the tool, but
|
|
209
|
+
* asks first. That, too, ends the stream `awaiting-input`, which is the whole
|
|
210
|
+
* reason there is no second endpoint — an approval is a question whose answer
|
|
211
|
+
* happens to be yes or no.
|
|
212
|
+
*/
|
|
213
|
+
export type ToolDefinition<Name extends string, Input, Output, Progress = never> = (ToolDefinitionBase<Name, Input, Output> & {
|
|
214
|
+
answeredBy?: "server";
|
|
215
|
+
execute: ToolExecute<Input, Output, Progress>;
|
|
216
|
+
requiresApproval?: boolean;
|
|
217
|
+
}) | (ToolDefinitionBase<Name, Input, Output> & {
|
|
218
|
+
answeredBy: "client";
|
|
219
|
+
outputSchema: Schema<Output>;
|
|
220
|
+
execute?: never;
|
|
221
|
+
/** Meaningless here: the client answering *is* the approval. */
|
|
222
|
+
requiresApproval?: never;
|
|
223
|
+
});
|
|
224
|
+
/**
|
|
225
|
+
* `Progress` is inferred, never written down.
|
|
226
|
+
*
|
|
227
|
+
* It comes from the yield type of an `execute` that is an async generator, and
|
|
228
|
+
* from nothing else — a tool that returns a promise gets `never`, which is the
|
|
229
|
+
* honest statement that it cannot yield and is what makes
|
|
230
|
+
* `ToolShapesOf`'s `progress` member safe to emit unconditionally. It is
|
|
231
|
+
* carried as a fourth parameter rather than derived on demand because it has to
|
|
232
|
+
* survive the trip through `ToolNamespace`, `FlattenTools` and `ToolShapesOf`
|
|
233
|
+
* into the browser, and only a type argument does that.
|
|
234
|
+
*
|
|
235
|
+
* Structurally it lives on `execute`, which is optional, and which is also why
|
|
236
|
+
* `AnyAgentTool` must pass `any` here: `Progress` sits covariantly inside
|
|
237
|
+
* `AsyncGenerator<Progress, …>`, so a bound of `never` would make every
|
|
238
|
+
* yielding tool fail the `Extract` in `ToolShapesOf` and silently vanish from
|
|
239
|
+
* the shapes.
|
|
240
|
+
*/
|
|
241
|
+
export declare class AgentTool<Name extends string = string, Input = unknown, Output = unknown, Progress = never> {
|
|
242
|
+
readonly name: Name;
|
|
243
|
+
readonly description: string;
|
|
244
|
+
readonly inputSchema: Schema<Input>;
|
|
245
|
+
readonly outputSchema?: Schema<Output>;
|
|
246
|
+
readonly requiresApproval: boolean;
|
|
247
|
+
readonly deferred: boolean;
|
|
248
|
+
readonly answeredBy: "server" | "client";
|
|
249
|
+
/**
|
|
250
|
+
* There is deliberately no `namespace` here. A tool is a module-scope
|
|
251
|
+
* singleton, so a field naming its group would hold whichever agent
|
|
252
|
+
* constructed its namespace last and report that to every other one — the
|
|
253
|
+
* same global-effect-from-a-local-declaration that `ToolNamespace.deferred`
|
|
254
|
+
* avoids. Where a tool sits is a property of the agent, and it lives on the
|
|
255
|
+
* agent's `ResolvedTool`.
|
|
256
|
+
*/
|
|
257
|
+
readonly execute?: ToolExecute<Input, Output, Progress>;
|
|
258
|
+
private constructor();
|
|
259
|
+
/**
|
|
260
|
+
* `const` on the params is what preserves `name` as a literal, which is what
|
|
261
|
+
* lets the browser discriminate a tool part by name.
|
|
262
|
+
*/
|
|
263
|
+
static create<const Name extends string, Input, Output, Progress = never>(params: ToolDefinition<Name, Input, Output, Progress>): AgentTool<Name, Input, Output, Progress>;
|
|
264
|
+
/**
|
|
265
|
+
* Sugar for the common client tool: the agent asks the user something and
|
|
266
|
+
* waits. Equivalent to `answeredBy: "client"` with an input schema of one
|
|
267
|
+
* prompt field.
|
|
268
|
+
*/
|
|
269
|
+
static ask<const Name extends string, Output>(params: {
|
|
270
|
+
name: Name;
|
|
271
|
+
description: string;
|
|
272
|
+
outputSchema: Schema<Output>;
|
|
273
|
+
}): AgentTool<Name, {
|
|
274
|
+
question: string;
|
|
275
|
+
}, Output>;
|
|
10
276
|
}
|
|
11
|
-
export
|
|
12
|
-
|
|
277
|
+
export type AnyAgentTool = AgentTool<string, any, any, any>;
|
|
278
|
+
/**
|
|
279
|
+
* A group of tools the model can search as a unit.
|
|
280
|
+
*
|
|
281
|
+
* The provider's tool search works over namespaces, and the guidance is fewer
|
|
282
|
+
* than ten functions in each — the model looks at a namespace's description to
|
|
283
|
+
* decide whether anything inside is worth loading, so the grouping is part of
|
|
284
|
+
* the prompt, not bookkeeping. A namespace is also the only place a
|
|
285
|
+
* *collection* of tools can be described; on a flat list that sentence has
|
|
286
|
+
* nowhere to go.
|
|
287
|
+
*
|
|
288
|
+
* Tool names stay globally unique within an agent, so the browser still
|
|
289
|
+
* discriminates on `name` alone and the namespace never leaks into the client's
|
|
290
|
+
* types.
|
|
291
|
+
*/
|
|
292
|
+
export declare class ToolNamespace<Name extends string = string, T extends readonly AnyAgentTool[] = readonly AnyAgentTool[]> {
|
|
293
|
+
readonly name: Name;
|
|
294
|
+
readonly description: string;
|
|
295
|
+
readonly tools: T;
|
|
296
|
+
/**
|
|
297
|
+
* Kept here rather than pushed onto each tool. A tool is a module-scope
|
|
298
|
+
* singleton and may be listed bare as well as inside a group; writing the
|
|
299
|
+
* group's `deferred` onto it would defer it everywhere, which is a global
|
|
300
|
+
* effect from a local declaration.
|
|
301
|
+
*/
|
|
302
|
+
readonly deferred: boolean;
|
|
303
|
+
private constructor();
|
|
304
|
+
static create<const Name extends string, const T extends readonly AnyAgentTool[]>(params: {
|
|
305
|
+
name: Name;
|
|
306
|
+
/** What the model reads when deciding whether to search inside. */
|
|
307
|
+
description: string;
|
|
308
|
+
tools: T;
|
|
309
|
+
/** Defers every tool in the group, so the whole namespace costs its own
|
|
310
|
+
* description plus one line per tool until something is loaded. */
|
|
311
|
+
deferred?: boolean;
|
|
312
|
+
}): ToolNamespace<Name, T>;
|
|
313
|
+
}
|
|
314
|
+
/** What an agent's `tools` may hold: tools, or namespaces of them. */
|
|
315
|
+
export type ToolEntry = AnyAgentTool | ToolNamespace<string, readonly AnyAgentTool[]>;
|
|
316
|
+
type FlattenTools<T extends readonly ToolEntry[]> = T[number] extends infer E ? E extends ToolNamespace<any, infer NT> ? NT[number] : E : never;
|
|
317
|
+
/**
|
|
318
|
+
* The tool tuple, erased to the payload types the client is allowed to see.
|
|
319
|
+
*
|
|
320
|
+
* `progress` is emitted for every tool, `never` included, rather than only for
|
|
321
|
+
* the ones that can yield. A conditional that dropped the member would make
|
|
322
|
+
* `T[K]["progress"]` in `types.ts` resolve differently per tool, and this
|
|
323
|
+
* package compiles with `strict: false` — where `undefined extends T` is true
|
|
324
|
+
* of everything and an optional member is indistinguishable from a required
|
|
325
|
+
* one. Two inference bugs in this module already came from testing a shape
|
|
326
|
+
* under those options and believing the answer (see `OptionalSchema` in
|
|
327
|
+
* `Schema.ts`); an unconditional member has nothing to get wrong.
|
|
328
|
+
*/
|
|
329
|
+
export type ToolShapesOf<T extends readonly ToolEntry[]> = {
|
|
330
|
+
[K in Extract<FlattenTools<T>, AnyAgentTool> as K["name"]]: K extends AgentTool<any, infer I, infer O, infer P> ? {
|
|
331
|
+
input: I;
|
|
332
|
+
output: O;
|
|
333
|
+
progress: P;
|
|
334
|
+
} : never;
|
|
335
|
+
};
|
|
336
|
+
/**
|
|
337
|
+
* A skill is instructions the model can go and fetch.
|
|
338
|
+
*
|
|
339
|
+
* Inlining every skill into the system prompt costs its tokens on every request
|
|
340
|
+
* and gets worse with each skill added. So a skill is lowered to a tool: one
|
|
341
|
+
* zero-parameter function per skill, in a reserved `skills` namespace, whose
|
|
342
|
+
* description is the skill's and whose result is `instructions` plus any
|
|
343
|
+
* `files`. Only those descriptions are prompted, and a skill the model never
|
|
344
|
+
* reaches for costs a line of text.
|
|
345
|
+
*
|
|
346
|
+
* Lowering to a tool rather than to a synthetic `load_skill(name)` dispatcher
|
|
347
|
+
* is the whole trick: discovery is then the same mechanism as everything else
|
|
348
|
+
* the model chooses between, which means it runs on the provider's own
|
|
349
|
+
* tool-selection machinery instead of on a string argument gemi would have to
|
|
350
|
+
* validate, and a skill that is never loaded is a namespace entry rather than a
|
|
351
|
+
* branch in our code. It is also why `deferred` applies here unchanged — with
|
|
352
|
+
* tool search the namespace is searched, and without it the same tools are
|
|
353
|
+
* listed inline, which for zero-parameter functions costs almost nothing.
|
|
354
|
+
*/
|
|
355
|
+
export interface SkillDefinition<Name extends string = string> {
|
|
356
|
+
name: Name;
|
|
357
|
+
/** Read on every request — this is what the model decides to load from. */
|
|
13
358
|
description: string;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
359
|
+
/** A thunk so a large body stays off the startup path and out of memory. */
|
|
360
|
+
instructions: string | (() => string | Promise<string>);
|
|
361
|
+
/** Paths resolved relative to the app root, appended after `instructions`. */
|
|
362
|
+
files?: string[];
|
|
363
|
+
}
|
|
364
|
+
export declare class Skill<Name extends string = string> {
|
|
365
|
+
readonly name: Name;
|
|
366
|
+
readonly description: string;
|
|
367
|
+
readonly instructions: string | (() => string | Promise<string>);
|
|
368
|
+
readonly files?: string[];
|
|
369
|
+
private constructor();
|
|
370
|
+
static create<const Name extends string>(params: SkillDefinition<Name>): Skill<Name>;
|
|
371
|
+
}
|
|
372
|
+
/** Reserved: a skill is lowered into a namespace of exactly this name. */
|
|
373
|
+
export declare const SKILLS_NAMESPACE = "skills";
|
|
374
|
+
export type ReasoningEffort = "minimal" | "low" | "medium" | "high";
|
|
375
|
+
export interface CreateAgentParams<T extends readonly ToolEntry[], S extends readonly Skill[], O extends Schema<any> | undefined> {
|
|
23
376
|
name: string;
|
|
24
|
-
|
|
377
|
+
/** The system prompt. Per-request additions belong on the controller, which
|
|
378
|
+
* has the request; this is the part that is the same for everyone. */
|
|
379
|
+
instructions?: string;
|
|
380
|
+
provider: AgentProvider;
|
|
381
|
+
tools?: T;
|
|
382
|
+
/** Lowered into the reserved `skills` namespace — see `Skill`. The name is
|
|
383
|
+
* reserved, so a namespace of your own cannot be called `skills`. */
|
|
384
|
+
skills?: S;
|
|
385
|
+
/**
|
|
386
|
+
* Makes the final assistant turn strict JSON instead of prose. Tool turns are
|
|
387
|
+
* unaffected — only the answer is constrained, which is the only place a
|
|
388
|
+
* schema can apply once there is a tool loop.
|
|
389
|
+
*/
|
|
390
|
+
output?: O;
|
|
391
|
+
/** Ends the run with `finishReason: "max-steps"` rather than throwing: an
|
|
392
|
+
* agent that loops is a bug to show, not an exception to swallow. */
|
|
393
|
+
maxSteps?: number;
|
|
394
|
+
/**
|
|
395
|
+
* How far `ctx.runAgent` may nest below this agent. Default 3.
|
|
396
|
+
*
|
|
397
|
+
* It is a limit on the *tree*, taken from the run at the root, so raising it
|
|
398
|
+
* on a sub-agent cannot deepen a run it did not start. A cycle is caught by
|
|
399
|
+
* the agent-name chain before this is reached — this is for the mutually
|
|
400
|
+
* recursive shape a name check cannot see, and for the merely runaway one.
|
|
401
|
+
*/
|
|
402
|
+
maxDepth?: number;
|
|
403
|
+
reasoning?: ReasoningEffort;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* One call per client turn — a first message and an answer to a pending
|
|
407
|
+
* approval take the same path, because they are the same thing: the next turn
|
|
408
|
+
* of a conversation.
|
|
409
|
+
*/
|
|
410
|
+
export interface AgentStreamParams {
|
|
411
|
+
/** Prior turns. The controller loads these from its store, or takes what the
|
|
412
|
+
* client sent when running stateless. */
|
|
413
|
+
messages: AgentMessage[];
|
|
414
|
+
/** The client's turn: text, answers to pending calls, or both. */
|
|
415
|
+
turn?: ClientTurn;
|
|
416
|
+
req: HttpRequest<any, any>;
|
|
417
|
+
/** Aborted by an explicit `stop`, not by a disconnect. */
|
|
418
|
+
signal?: AbortSignal;
|
|
419
|
+
runId?: string;
|
|
420
|
+
threadId?: string;
|
|
421
|
+
/** Appended to the agent's own `instructions` for this request only. */
|
|
422
|
+
instructions?: string;
|
|
423
|
+
/** Per-request model choice, e.g. letting a user pick. */
|
|
424
|
+
provider?: AgentProvider;
|
|
425
|
+
maxSteps?: number;
|
|
426
|
+
reasoning?: ReasoningEffort;
|
|
427
|
+
/**
|
|
428
|
+
* Fires once for every message this run completes — the user's turn, each
|
|
429
|
+
* assistant turn, and any earlier message this turn amended by resolving a
|
|
430
|
+
* pending call. It is the controller's persistence point, and it fires
|
|
431
|
+
* whether or not anyone is still reading the stream, which is what makes a
|
|
432
|
+
* run that outlives its request useful.
|
|
433
|
+
*
|
|
434
|
+
* A message may be reported twice across runs under the same id when a
|
|
435
|
+
* pending call is resolved later; a store keyed by id should upsert.
|
|
436
|
+
*/
|
|
437
|
+
onMessage?: (message: AgentMessage) => void | Promise<void>;
|
|
438
|
+
/**
|
|
439
|
+
* Set by `ctx.runAgent` and by nothing else.
|
|
440
|
+
*
|
|
441
|
+
* It rides on the public params rather than on a back door because
|
|
442
|
+
* `Agent.stream` is the only way to start a run and a sub-run is a run —
|
|
443
|
+
* giving nesting its own construction path would mean two places where a run
|
|
444
|
+
* is set up, and the second one would drift. Omitted, a run is a root: depth
|
|
445
|
+
* 0, no path, signatures over its own id.
|
|
446
|
+
*/
|
|
447
|
+
nesting?: NestedContext;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Where a run sits inside a tree of runs. Carried down by `ctx.runAgent`.
|
|
451
|
+
*
|
|
452
|
+
* `signingRunId` and `signingPath` are the reason this is threaded rather than
|
|
453
|
+
* recomputed: a pending call a sub-agent raises is answered by the *client*,
|
|
454
|
+
* which only ever sees the root run, so the token has to be minted under the
|
|
455
|
+
* root's id and the sub-run's path from the start. Re-signing the token at each
|
|
456
|
+
* level on the way up would work too, and would throw away every signature but
|
|
457
|
+
* the outermost one — this way the run that asks the question is also the run
|
|
458
|
+
* that can check the answer, which is where the tool, its schema and its `kind`
|
|
459
|
+
* all already are.
|
|
460
|
+
*/
|
|
461
|
+
export type NestedContext = {
|
|
462
|
+
/** 0 at the root; `ctx.depth` inside a tool of this run. */
|
|
463
|
+
depth: number;
|
|
464
|
+
/** The `maxDepth` of the run at the root of the tree. */
|
|
465
|
+
maxDepth: number;
|
|
466
|
+
/** Agent names from the root down to and including this one, so a cycle can
|
|
467
|
+
* be reported as the chain that caused it. */
|
|
468
|
+
chain: string[];
|
|
469
|
+
/** The root run's id: what a pending call raised here is signed under. */
|
|
470
|
+
signingRunId: string;
|
|
471
|
+
/** Tool-call ids from the root down to the call that started this run. */
|
|
472
|
+
signingPath: string[];
|
|
473
|
+
/**
|
|
474
|
+
* Inherited, and once it is `"deny"` it stays `"deny"` all the way down. A
|
|
475
|
+
* caller that asked for an autonomous sub-agent must not have a question
|
|
476
|
+
* surface from three levels below it, and the only way to promise that is to
|
|
477
|
+
* make the whole subtree refuse rather than to check at the top.
|
|
478
|
+
*/
|
|
479
|
+
onPending: "escalate" | "deny";
|
|
480
|
+
};
|
|
481
|
+
export type AgentRunResult<T extends ToolShapes, O> = {
|
|
482
|
+
runId: string;
|
|
483
|
+
/** Everything produced this run — the controller persists these. */
|
|
484
|
+
messages: AgentMessage<T, O>[];
|
|
485
|
+
finishReason: FinishReason;
|
|
486
|
+
usage: Usage;
|
|
487
|
+
/** Set when the agent declares an `output` schema and the run finished. */
|
|
488
|
+
output?: O;
|
|
489
|
+
};
|
|
490
|
+
/**
|
|
491
|
+
* A run is an async iterable of events, and the SSE encoding is a method on it
|
|
492
|
+
* rather than a separate helper — so the same object serves a controller
|
|
493
|
+
* returning a `Response` and a server-side caller that just wants to await the
|
|
494
|
+
* result.
|
|
495
|
+
*
|
|
496
|
+
* A run keeps going when its request ends. That is what makes reattaching after
|
|
497
|
+
* a refresh possible, and it is why `stop()` is an explicit call rather than the
|
|
498
|
+
* client closing a socket.
|
|
499
|
+
*/
|
|
500
|
+
export interface AgentRun<T extends ToolShapes = ToolShapes, O = unknown> extends AsyncIterable<AgentStreamEvent<T, O>> {
|
|
501
|
+
readonly runId: string;
|
|
502
|
+
/** Numbered events, replayable from a cursor. `toResponse` is this, encoded. */
|
|
503
|
+
frames(from?: number): AsyncIterable<AgentStreamFrame<T, O>>;
|
|
504
|
+
toResponse(params?: {
|
|
505
|
+
from?: number;
|
|
506
|
+
}): Response;
|
|
507
|
+
result(): Promise<AgentRunResult<T, O>>;
|
|
508
|
+
/**
|
|
509
|
+
* Cancels the run and closes the conversation behind it: every tool call
|
|
510
|
+
* still in flight gets a `denied` result with `cause: "stopped"`, the
|
|
511
|
+
* assistant message is finalized with `finishReason: "aborted"`, and both go
|
|
512
|
+
* through `onMessage` like any other message.
|
|
513
|
+
*
|
|
514
|
+
* That last part is the point. A cancel that merely stops emitting leaves a
|
|
515
|
+
* history the provider will reject on the next turn, so the run's last act is
|
|
516
|
+
* to make the transcript valid — which is also what lets the user carry on
|
|
517
|
+
* talking instead of starting over.
|
|
518
|
+
*/
|
|
519
|
+
stop(params?: {
|
|
520
|
+
reason?: string;
|
|
521
|
+
}): void;
|
|
25
522
|
}
|
|
26
|
-
export declare class Agent<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
523
|
+
export declare class Agent<T extends readonly ToolEntry[] = readonly ToolEntry[], S extends readonly Skill[] = readonly Skill[], O extends Schema<any> | undefined = undefined> {
|
|
524
|
+
readonly name: string;
|
|
525
|
+
readonly tools: T;
|
|
526
|
+
readonly skills: S;
|
|
527
|
+
readonly provider: AgentProvider;
|
|
528
|
+
readonly output: O;
|
|
529
|
+
readonly instructions?: string;
|
|
530
|
+
readonly maxSteps: number;
|
|
531
|
+
readonly maxDepth: number;
|
|
532
|
+
readonly reasoning?: ReasoningEffort;
|
|
533
|
+
private readonly config;
|
|
534
|
+
private constructor();
|
|
535
|
+
static create<const T extends readonly ToolEntry[], const S extends readonly Skill[], O extends Schema<any> | undefined = undefined>(params: CreateAgentParams<T, S, O>): Agent<T, S, O>;
|
|
536
|
+
stream(params: AgentStreamParams): AgentRun<ToolShapesOf<T>, OutputOf<O>>;
|
|
31
537
|
}
|
|
538
|
+
export type OutputOf<O> = O extends Schema<any> ? Infer<O> : never;
|
|
539
|
+
export type AnyAgent = Agent<any, any, any>;
|
|
32
540
|
export {};
|
|
33
541
|
//# sourceMappingURL=Agent.d.ts.map
|
package/dist/ai/Agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../ai/Agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../ai/Agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC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