driverkit 0.0.0-stage → 0.0.1
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/CONTROLS.md +578 -0
- package/REACT.md +477 -0
- package/README.md +104 -2
- package/dist/agent/backend.d.ts +69 -0
- package/dist/agent/backend.d.ts.map +1 -0
- package/dist/agent/backend.js +130 -0
- package/dist/agent/backend.js.map +1 -0
- package/dist/agent/control.d.ts +148 -0
- package/dist/agent/control.d.ts.map +1 -0
- package/dist/agent/control.js +342 -0
- package/dist/agent/control.js.map +1 -0
- package/dist/agent/index.d.ts +9 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +6 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/loop.d.ts +136 -0
- package/dist/agent/loop.d.ts.map +1 -0
- package/dist/agent/loop.js +824 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/render.d.ts +173 -0
- package/dist/agent/render.d.ts.map +1 -0
- package/dist/agent/render.js +425 -0
- package/dist/agent/render.js.map +1 -0
- package/dist/agent/tools.d.ts +138 -0
- package/dist/agent/tools.d.ts.map +1 -0
- package/dist/agent/tools.js +622 -0
- package/dist/agent/tools.js.map +1 -0
- package/dist/agent/types.d.ts +566 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +32 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/browser/budget.d.ts +92 -0
- package/dist/browser/budget.d.ts.map +1 -0
- package/dist/browser/budget.js +151 -0
- package/dist/browser/budget.js.map +1 -0
- package/dist/browser/connect.d.ts +368 -0
- package/dist/browser/connect.d.ts.map +1 -0
- package/dist/browser/connect.js +1038 -0
- package/dist/browser/connect.js.map +1 -0
- package/dist/browser/elsewhere.d.ts +89 -0
- package/dist/browser/elsewhere.d.ts.map +1 -0
- package/dist/browser/elsewhere.js +91 -0
- package/dist/browser/elsewhere.js.map +1 -0
- package/dist/browser/frames.d.ts +85 -0
- package/dist/browser/frames.d.ts.map +1 -0
- package/dist/browser/frames.js +11 -0
- package/dist/browser/frames.js.map +1 -0
- package/dist/browser/index.d.ts +8 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +9 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/check/check.d.ts +171 -0
- package/dist/check/check.d.ts.map +1 -0
- package/dist/check/check.js +666 -0
- package/dist/check/check.js.map +1 -0
- package/dist/check/index.d.ts +3 -0
- package/dist/check/index.d.ts.map +1 -0
- package/dist/check/index.js +2 -0
- package/dist/check/index.js.map +1 -0
- package/dist/check/types.d.ts +149 -0
- package/dist/check/types.d.ts.map +1 -0
- package/dist/check/types.js +29 -0
- package/dist/check/types.js.map +1 -0
- package/dist/controls/controls.d.ts +198 -0
- package/dist/controls/controls.d.ts.map +1 -0
- package/dist/controls/controls.js +742 -0
- package/dist/controls/controls.js.map +1 -0
- package/dist/controls/dom.d.ts +108 -0
- package/dist/controls/dom.d.ts.map +1 -0
- package/dist/controls/dom.js +56 -0
- package/dist/controls/dom.js.map +1 -0
- package/dist/controls/index.d.ts +26 -0
- package/dist/controls/index.d.ts.map +1 -0
- package/dist/controls/index.js +23 -0
- package/dist/controls/index.js.map +1 -0
- package/dist/controls/rows.d.ts +66 -0
- package/dist/controls/rows.d.ts.map +1 -0
- package/dist/controls/rows.js +127 -0
- package/dist/controls/rows.js.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +15 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/registry.d.ts +192 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +2799 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/types.d.ts +2468 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +19 -0
- package/dist/core/types.js.map +1 -0
- package/dist/otel/index.d.ts +122 -0
- package/dist/otel/index.d.ts.map +1 -0
- package/dist/otel/index.js +157 -0
- package/dist/otel/index.js.map +1 -0
- package/dist/react/index.d.ts +191 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +547 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/runtime.d.ts +95 -0
- package/dist/react/runtime.d.ts.map +1 -0
- package/dist/react/runtime.js +54 -0
- package/dist/react/runtime.js.map +1 -0
- package/dist/react/store.d.ts +333 -0
- package/dist/react/store.d.ts.map +1 -0
- package/dist/react/store.js +695 -0
- package/dist/react/store.js.map +1 -0
- package/dist/relay/auth.d.ts +244 -0
- package/dist/relay/auth.d.ts.map +1 -0
- package/dist/relay/auth.js +391 -0
- package/dist/relay/auth.js.map +1 -0
- package/dist/relay/frames.d.ts +141 -0
- package/dist/relay/frames.d.ts.map +1 -0
- package/dist/relay/frames.js +20 -0
- package/dist/relay/frames.js.map +1 -0
- package/dist/relay/index.d.ts +8 -0
- package/dist/relay/index.d.ts.map +1 -0
- package/dist/relay/index.js +4 -0
- package/dist/relay/index.js.map +1 -0
- package/dist/relay/relay.d.ts +277 -0
- package/dist/relay/relay.d.ts.map +1 -0
- package/dist/relay/relay.js +1026 -0
- package/dist/relay/relay.js.map +1 -0
- package/dist/relay/serve.d.ts +33 -0
- package/dist/relay/serve.d.ts.map +1 -0
- package/dist/relay/serve.js +86 -0
- package/dist/relay/serve.js.map +1 -0
- package/dist/widget/chat.d.ts +290 -0
- package/dist/widget/chat.d.ts.map +1 -0
- package/dist/widget/chat.js +486 -0
- package/dist/widget/chat.js.map +1 -0
- package/dist/widget/css.d.ts +49 -0
- package/dist/widget/css.d.ts.map +1 -0
- package/dist/widget/css.js +532 -0
- package/dist/widget/css.js.map +1 -0
- package/dist/widget/dom.d.ts +143 -0
- package/dist/widget/dom.d.ts.map +1 -0
- package/dist/widget/dom.js +27 -0
- package/dist/widget/dom.js.map +1 -0
- package/dist/widget/highlight.d.ts +64 -0
- package/dist/widget/highlight.d.ts.map +1 -0
- package/dist/widget/highlight.js +136 -0
- package/dist/widget/highlight.js.map +1 -0
- package/dist/widget/index.d.ts +9 -0
- package/dist/widget/index.d.ts.map +1 -0
- package/dist/widget/index.js +20 -0
- package/dist/widget/index.js.map +1 -0
- package/dist/widget/position.d.ts +166 -0
- package/dist/widget/position.d.ts.map +1 -0
- package/dist/widget/position.js +497 -0
- package/dist/widget/position.js.map +1 -0
- package/dist/widget/settings.d.ts +116 -0
- package/dist/widget/settings.d.ts.map +1 -0
- package/dist/widget/settings.js +117 -0
- package/dist/widget/settings.js.map +1 -0
- package/dist/widget/widget.d.ts +442 -0
- package/dist/widget/widget.d.ts.map +1 -0
- package/dist/widget/widget.js +2005 -0
- package/dist/widget/widget.js.map +1 -0
- package/package.json +144 -4
|
@@ -0,0 +1,566 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* driverkit/agent — the contract with the model, and nothing else.
|
|
3
|
+
*
|
|
4
|
+
* This package contains **no model client and no API key handling**, and that
|
|
5
|
+
* is the load-bearing decision rather than a scoping convenience. Three
|
|
6
|
+
* reasons, in order of how much they cost to get wrong:
|
|
7
|
+
*
|
|
8
|
+
* 1. **A browser cannot hold an API key.** Anything shipped to a page is
|
|
9
|
+
* readable by whoever has the page, so a widget that takes an `apiKey`
|
|
10
|
+
* option is a widget that leaks one. The realistic deployment is that
|
|
11
|
+
* `think` does `fetch("/api/chat")` against the app's own backend, which
|
|
12
|
+
* already authenticates the person and already holds the key. That is the
|
|
13
|
+
* documented default story — see `backendThink` — and nothing in these
|
|
14
|
+
* types assumes a model is reachable from the page at all.
|
|
15
|
+
*
|
|
16
|
+
* 2. **Vendor neutrality has to be structural.** A `provider: "anthropic" |
|
|
17
|
+
* "openai"` option means this package grows a translation layer per vendor
|
|
18
|
+
* and a release per API change. A function pointer means it grows neither,
|
|
19
|
+
* and a local model, a proxy, a queue or a scripted fake all satisfy it.
|
|
20
|
+
*
|
|
21
|
+
* 3. **It is how the loop gets tested.** Every test in this package drives a
|
|
22
|
+
* real `mount()`ed driver with a scripted `think`. If the model were inside,
|
|
23
|
+
* the loop's hard parts — the refusal path, the commit gate, the bounds —
|
|
24
|
+
* would be verified by paying a vendor and hoping.
|
|
25
|
+
*
|
|
26
|
+
* The shapes below are deliberately the *intersection* of the tool-use APIs,
|
|
27
|
+
* not the union: a system string, a flat message list, a tool list, and either
|
|
28
|
+
* prose or calls coming back. Mapping that onto a vendor's wire format is
|
|
29
|
+
* twenty lines in the caller and does not belong here.
|
|
30
|
+
*/
|
|
31
|
+
import type { Manifest, Result, Scalar, Snapshot, VerbKind } from "../core/index.ts";
|
|
32
|
+
/**
|
|
33
|
+
* One tool, as the model sees it.
|
|
34
|
+
*
|
|
35
|
+
* This is the MCP `tools/list` shape, down to the field names, because the
|
|
36
|
+
* Python MCP server in this same repository emits exactly that and the two
|
|
37
|
+
* halves of one library must not describe the same verbs differently. A model
|
|
38
|
+
* driving an app from outside through MCP and a model driving it from inside
|
|
39
|
+
* through this loop read the same sentences about the same verbs. See
|
|
40
|
+
* `tools.ts`, and `python/src/driverkit/mcp_server.py` for the other end.
|
|
41
|
+
*/
|
|
42
|
+
export interface ToolSpec {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
inputSchema: {
|
|
46
|
+
type: "object";
|
|
47
|
+
properties: Record<string, JsonSchema>;
|
|
48
|
+
required: string[];
|
|
49
|
+
additionalProperties: false;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** The sliver of JSON Schema a driverkit `ArgSpec` can produce. Hand-rolled to
|
|
53
|
+
* keep the zero-dependency promise the core makes. */
|
|
54
|
+
export interface JsonSchema {
|
|
55
|
+
type: "string" | "number" | "boolean" | "integer";
|
|
56
|
+
description: string;
|
|
57
|
+
/** From `ArgSpec.oneOf`, which is JSON Schema's `enum` and emphatically not
|
|
58
|
+
* JSON Schema's `oneOf`: the names look alike and the meanings diverge, and
|
|
59
|
+
* emitting the latter produces a schema that validates anything. */
|
|
60
|
+
enum?: Scalar[];
|
|
61
|
+
}
|
|
62
|
+
/** A verb the model wants run. `id` is the vendor's correlation id, passed
|
|
63
|
+
* straight back on the tool turn; this package never interprets it. */
|
|
64
|
+
export interface ToolCall {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
args: Record<string, Scalar>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* One message. A flat list of these, in order, is the uncached half.
|
|
71
|
+
*
|
|
72
|
+
* Three roles rather than a vendor's content-block union: it is the least that
|
|
73
|
+
* can express a tool-use loop, and widening it would mean this package taking
|
|
74
|
+
* a position on image blocks, thinking blocks and citations, each of which is
|
|
75
|
+
* spelled differently by every vendor and needed by none of this.
|
|
76
|
+
*/
|
|
77
|
+
export type Turn = {
|
|
78
|
+
role: "user";
|
|
79
|
+
text: string;
|
|
80
|
+
} | {
|
|
81
|
+
role: "assistant";
|
|
82
|
+
text?: string;
|
|
83
|
+
calls?: ToolCall[];
|
|
84
|
+
} | {
|
|
85
|
+
role: "tool";
|
|
86
|
+
callId: string;
|
|
87
|
+
name: string;
|
|
88
|
+
text: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* What `think` is handed.
|
|
92
|
+
*
|
|
93
|
+
* The split in here is the whole cost argument, restated as a function
|
|
94
|
+
* signature: `system` and `tools` are the static half and are **byte-identical
|
|
95
|
+
* on every call within a run**, so a caller can hand them to a provider with
|
|
96
|
+
* caching turned on and pay for them once. `messages` is the growing tail.
|
|
97
|
+
*
|
|
98
|
+
* A caller that folds anything per-turn into `system` — a timestamp, the
|
|
99
|
+
* current screen, a step counter — busts the prefix cache on every turn and
|
|
100
|
+
* the loop stops being cheap. `drive` computes `system` once, before the loop,
|
|
101
|
+
* from the manifest alone, which is the only way to make that structural
|
|
102
|
+
* rather than a rule in a comment. There is a test that asserts it.
|
|
103
|
+
*/
|
|
104
|
+
export interface ThinkInput {
|
|
105
|
+
/** Static for the whole run. Cache it. */
|
|
106
|
+
system: string;
|
|
107
|
+
/** Static for the whole run. Cache it. */
|
|
108
|
+
tools: ToolSpec[];
|
|
109
|
+
/** The tail: the person's message, the model's own turns, and one tool turn
|
|
110
|
+
* per verb that ran, each carrying the screen as it was after it ran. */
|
|
111
|
+
messages: Turn[];
|
|
112
|
+
/** The run's cancellation, forwarded so a `fetch` can be torn down mid
|
|
113
|
+
* flight. A `think` that ignores it still works; `drive` checks it again on
|
|
114
|
+
* the way out and will not run a verb for an aborted run. */
|
|
115
|
+
signal?: AbortSignal;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* What `think` returns.
|
|
119
|
+
*
|
|
120
|
+
* No `calls` (or an empty list) means the model answered, and the run ends
|
|
121
|
+
* with `text` as the answer. That is the only stop condition the model
|
|
122
|
+
* controls, and it is the same convention every tool-use API already uses, so
|
|
123
|
+
* an adapter is a field rename rather than a state machine.
|
|
124
|
+
*/
|
|
125
|
+
export interface ThinkResult {
|
|
126
|
+
text?: string;
|
|
127
|
+
calls?: ToolCall[];
|
|
128
|
+
}
|
|
129
|
+
export type Think = (input: ThinkInput) => Promise<ThinkResult>;
|
|
130
|
+
/** Why the run ended. Returned rather than thrown: `max-steps` and `stuck` are
|
|
131
|
+
* ordinary outcomes a UI has to render, and an exception would push every
|
|
132
|
+
* caller into a try/catch that treats a bounded run as a failure. */
|
|
133
|
+
export type StopReason =
|
|
134
|
+
/** The model answered in prose. The only ending the model chooses. */
|
|
135
|
+
"answered"
|
|
136
|
+
/** `maxSteps` was reached with the model still calling verbs. */
|
|
137
|
+
| "max-steps"
|
|
138
|
+
/** The `AbortSignal` fired. */
|
|
139
|
+
| "aborted"
|
|
140
|
+
/** The same verb was refused the same way `refusalLimit` times. */
|
|
141
|
+
| "stuck"
|
|
142
|
+
/**
|
|
143
|
+
* The app's own `MountOptions.budget` ceiling was reached, so the driver
|
|
144
|
+
* refused `budget-spent` and going on was pointless.
|
|
145
|
+
*
|
|
146
|
+
* A separate reason and not folded into `stuck`, which is what it would
|
|
147
|
+
* otherwise have become: the loop refuses the same way `refusalLimit` times
|
|
148
|
+
* and then reports "the same call kept being refused". That sentence is true
|
|
149
|
+
* and it is read as "the model is confused", which sends somebody to rewrite
|
|
150
|
+
* a prompt for an app that has simply run out of allowance — and it spends
|
|
151
|
+
* two more model round trips proving it, against the budget that just ran
|
|
152
|
+
* out. `budget-spent` is the one refusal in `RESERVED_REFUSALS` whose honest
|
|
153
|
+
* repair is "do not try again", so the loop stops on the first one.
|
|
154
|
+
*/
|
|
155
|
+
| "over-budget"
|
|
156
|
+
/** `think` returned neither prose nor calls. A broken adapter, usually. */
|
|
157
|
+
| "silent";
|
|
158
|
+
/** Handed to `onBeforeCommit`. Carries the manifest's `kind` and `refuses` so
|
|
159
|
+
* a host app can word its own confirmation using the app's own vocabulary
|
|
160
|
+
* rather than re-deriving it from the verb name. */
|
|
161
|
+
export interface CommitRequest {
|
|
162
|
+
name: string;
|
|
163
|
+
args: Record<string, Scalar>;
|
|
164
|
+
verb: Manifest["verbs"][number];
|
|
165
|
+
/** The screen as it is right now, so a confirmation can show the selection
|
|
166
|
+
* the commit is about to act on. */
|
|
167
|
+
snapshot: Snapshot;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* `true` (or nothing) lets the commit run. `false` vetoes it. A string vetoes
|
|
171
|
+
* it and becomes the hint the model is told.
|
|
172
|
+
*
|
|
173
|
+
* The veto reaches the model as an ordinary refusal — the `declined-by-user`
|
|
174
|
+
* slug — and never as an exception. A thrown veto would abort the run and the
|
|
175
|
+
* model would never learn why, so the next thing the person saw would be a
|
|
176
|
+
* dead panel instead of "you declined that; want me to narrow it first?".
|
|
177
|
+
*/
|
|
178
|
+
export type CommitDecision = boolean | string | void;
|
|
179
|
+
/**
|
|
180
|
+
* What the run controls are asking for right now.
|
|
181
|
+
*
|
|
182
|
+
* Two states and not three: there is no "stopped". A stop is the `AbortSignal`,
|
|
183
|
+
* which ends the run rather than changing how it is being driven, and folding
|
|
184
|
+
* the two together would invite a `state === "stopped"` check that a paused run
|
|
185
|
+
* could never recover from.
|
|
186
|
+
*/
|
|
187
|
+
export type ControlState = "running" | "paused";
|
|
188
|
+
/**
|
|
189
|
+
* What a UI should say the run is doing.
|
|
190
|
+
*
|
|
191
|
+
* The control states plus the one wait the controls do not own: a run sitting
|
|
192
|
+
* in front of `onBeforeCommit` is not paused and is not running either, it is
|
|
193
|
+
* waiting for a person to answer, and a panel that showed "running" there would
|
|
194
|
+
* be telling the person to wait for the thing that is waiting for them.
|
|
195
|
+
*/
|
|
196
|
+
export type RunState = ControlState | "awaiting-approval";
|
|
197
|
+
/**
|
|
198
|
+
* Pause, resume and step, as a plain object. Built by `runControls`.
|
|
199
|
+
*
|
|
200
|
+
* Passed into `drive` rather than returned from it, because `drive`'s promise
|
|
201
|
+
* settles when the run is over and a handle you can only hold afterwards is a
|
|
202
|
+
* handle you cannot pause with. See `runControls` for the rest of that
|
|
203
|
+
* argument.
|
|
204
|
+
*/
|
|
205
|
+
export interface RunControls {
|
|
206
|
+
/** `"paused"` means the run will hold before its next call. The call in
|
|
207
|
+
* flight, if any, still finishes: a pause is a gate between calls and never
|
|
208
|
+
* an interruption inside one. */
|
|
209
|
+
readonly state: ControlState;
|
|
210
|
+
/** Outstanding `step()` permits. For a UI that wants to show that a step has
|
|
211
|
+
* been asked for and not yet spent. */
|
|
212
|
+
readonly permits: number;
|
|
213
|
+
/** Hold before the next call. The call in flight finishes first. */
|
|
214
|
+
pause(): void;
|
|
215
|
+
/** Carry on. Drops any unspent `step()` permit, since running is the stronger
|
|
216
|
+
* statement. */
|
|
217
|
+
resume(): void;
|
|
218
|
+
/** Run exactly one more call, then hold again. Valid from either state. */
|
|
219
|
+
step(): void;
|
|
220
|
+
/**
|
|
221
|
+
* The delay before each call, in milliseconds, right now.
|
|
222
|
+
*
|
|
223
|
+
* Readable so a slider can render the run's real pace rather than its own
|
|
224
|
+
* last write — which are different numbers the moment anything else sets it,
|
|
225
|
+
* and the second one is the one a person would call a bug.
|
|
226
|
+
*/
|
|
227
|
+
readonly paceMs: number;
|
|
228
|
+
/**
|
|
229
|
+
* Change the pace of the run **in flight**: from the next wait onwards, and
|
|
230
|
+
* including the wait already running.
|
|
231
|
+
*
|
|
232
|
+
* Live because the moment a person wants the agent slowed down is while it is
|
|
233
|
+
* going. A slider that quietly applied next run would be worse than no
|
|
234
|
+
* slider: they move it, nothing happens, and they conclude it is broken.
|
|
235
|
+
*
|
|
236
|
+
* 0 means the next wait does not happen at all. Values that are not a claim
|
|
237
|
+
* about a speed — `NaN`, `Infinity`, anything non-finite — are **ignored**,
|
|
238
|
+
* and the current pace is kept: reading them as 0 would make the agent faster
|
|
239
|
+
* than the person asked for, and reading `Infinity` as a delay would park the
|
|
240
|
+
* run on a timer nobody meant to set. A negative is clamped to 0, since "less
|
|
241
|
+
* than no wait" has only one sensible meaning.
|
|
242
|
+
*/
|
|
243
|
+
pace(ms: number): void;
|
|
244
|
+
/**
|
|
245
|
+
* Be told when any of the above changes, for a UI that has to stay in step
|
|
246
|
+
* with controls it is not the only owner of. Returns an unsubscribe.
|
|
247
|
+
*
|
|
248
|
+
* Fires on a real change to `state`, `permits` or `paceMs`, and on nothing
|
|
249
|
+
* else. The listener is handed no arguments and reads whichever getter it
|
|
250
|
+
* cares about, so this cannot grow a snapshot shape that drifts from the
|
|
251
|
+
* object it describes.
|
|
252
|
+
*
|
|
253
|
+
* `onControl` already reports state during a run; this covers what that
|
|
254
|
+
* cannot, which is a `step()` or a pace change made **between** runs, when
|
|
255
|
+
* there is no loop to report anything. `drive` subscribes as well, which is
|
|
256
|
+
* how a pace change reaches a wait that has already started.
|
|
257
|
+
*/
|
|
258
|
+
subscribe(listener: () => void): () => void;
|
|
259
|
+
/**
|
|
260
|
+
* Block until the run may proceed. **`drive` calls this; a caller does not.**
|
|
261
|
+
*
|
|
262
|
+
* On the public interface because the waiting and the state have to live
|
|
263
|
+
* together — a gate that polled a `state` getter would either spin or add a
|
|
264
|
+
* latency of its own — and because a host with an exotic control surface (a
|
|
265
|
+
* queue, a remote operator, a test) can implement this interface itself and
|
|
266
|
+
* `drive` will drive it.
|
|
267
|
+
*
|
|
268
|
+
* `what` distinguishes a model round trip from a verb call: only a call spends
|
|
269
|
+
* a `step()` permit. Resolves immediately, without holding, if `signal` is
|
|
270
|
+
* already aborted or fires while parked — an abort outranks a pause, always.
|
|
271
|
+
*/
|
|
272
|
+
gate(what: "think" | "call", signal?: AbortSignal): Promise<void>;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* The timer `pace` uses. Injectable so the suite does not actually sleep.
|
|
276
|
+
*
|
|
277
|
+
* Deliberately smaller than `setTimeout`: no arguments forwarded, no return
|
|
278
|
+
* type promised. `unknown` for the handle because the real one is a `number` in
|
|
279
|
+
* a browser and a `Timeout` object in Node, and a package that named either
|
|
280
|
+
* would stop compiling in the other.
|
|
281
|
+
*/
|
|
282
|
+
export interface Clock {
|
|
283
|
+
set(fn: () => void, ms: number): unknown;
|
|
284
|
+
clear(handle: unknown): void;
|
|
285
|
+
/**
|
|
286
|
+
* Milliseconds since some fixed point. Defaults to `Date.now`.
|
|
287
|
+
*
|
|
288
|
+
* Here because a pace that can change mid-wait has to know how much of the
|
|
289
|
+
* wait has already elapsed, and a suite that could inject the timer but not
|
|
290
|
+
* the clock would have to sleep to test it.
|
|
291
|
+
*/
|
|
292
|
+
now?(): number;
|
|
293
|
+
}
|
|
294
|
+
/** The common shape of the three per-call events. Shared so a widget can write
|
|
295
|
+
* one function that renders a row and call it from all three. */
|
|
296
|
+
export interface CallEvent {
|
|
297
|
+
step: number;
|
|
298
|
+
call: ToolCall;
|
|
299
|
+
/** From the manifest, and undefined when the app declared none — this package
|
|
300
|
+
* does not manufacture a safety claim the app did not make, in either
|
|
301
|
+
* direction. */
|
|
302
|
+
kind?: VerbKind;
|
|
303
|
+
/**
|
|
304
|
+
* The verb's `at` selector, if the app declared one: a hint about which
|
|
305
|
+
* element on the page this call is about, so a UI can outline it.
|
|
306
|
+
*
|
|
307
|
+
* Passed straight through from the manifest and used by nothing in here.
|
|
308
|
+
* driverkit does not resolve selectors — see `Verb.at` in the core, which
|
|
309
|
+
* says why that is a promise and not an omission. A UI is free to query it; a
|
|
310
|
+
* UI is the only thing that should.
|
|
311
|
+
*/
|
|
312
|
+
at?: string;
|
|
313
|
+
/** Position within this turn's calls, 0-based. A model may ask for several
|
|
314
|
+
* verbs in one turn, and a step list that showed them without their order
|
|
315
|
+
* would be hiding the one thing the person needs: what ran before what. */
|
|
316
|
+
index: number;
|
|
317
|
+
/** How many calls this turn asked for. */
|
|
318
|
+
of: number;
|
|
319
|
+
}
|
|
320
|
+
export interface DriveEvents {
|
|
321
|
+
/** About to spend a model round trip. `step` is 1-based. */
|
|
322
|
+
onStep?: (e: {
|
|
323
|
+
step: number;
|
|
324
|
+
}) => void;
|
|
325
|
+
/** The model said something in prose, mid-run or as its answer. */
|
|
326
|
+
onSay?: (e: {
|
|
327
|
+
step: number;
|
|
328
|
+
text: string;
|
|
329
|
+
}) => void;
|
|
330
|
+
/**
|
|
331
|
+
* A call is going to be attempted — fired **before** the pace wait and before
|
|
332
|
+
* any pause gate, so a row for it can be on screen and glowing while the
|
|
333
|
+
* person still has time to stop it. This is the event a pending step list is
|
|
334
|
+
* built from; `onCall` then means "running" and `onResult` means "done".
|
|
335
|
+
*
|
|
336
|
+
* It is not a promise that the call will run. A stop pressed during the pace
|
|
337
|
+
* wait, or while the run is held, abandons it unrun — `onStop` fires with
|
|
338
|
+
* `aborted` and anything still pending should be settled from there, since no
|
|
339
|
+
* `onResult` is coming for a call that never happened.
|
|
340
|
+
*/
|
|
341
|
+
onBeforeCall?: (e: CallEvent) => void;
|
|
342
|
+
/** A verb is about to run, after any pacing and any hold: the last event
|
|
343
|
+
* before the app is touched. Pre-dates `onBeforeCall` and keeps its exact
|
|
344
|
+
* meaning and timing — with no pacing and no controls the two fire back to
|
|
345
|
+
* back, which is what an existing caller already sees. */
|
|
346
|
+
onCall?: (e: CallEvent) => void;
|
|
347
|
+
/** A verb ran. `result` is null for the one tool that is not a verb
|
|
348
|
+
* (`read_screen`) and for a call to a name the manifest does not have. */
|
|
349
|
+
onResult?: (e: CallEvent & {
|
|
350
|
+
result: Result | null;
|
|
351
|
+
/** What the model was told, verbatim. A UI showing this shows exactly
|
|
352
|
+
* what the model is reasoning from, which is the honest thing to show. */
|
|
353
|
+
text: string;
|
|
354
|
+
}) => void;
|
|
355
|
+
/**
|
|
356
|
+
* The run's control state changed. Fires once at the start of the run with
|
|
357
|
+
* the initial state, then on every transition.
|
|
358
|
+
*
|
|
359
|
+
* There at all because the state has more than one owner. The caller moves it
|
|
360
|
+
* with `pause`/`step`/`resume`, but `drive` moves it too — a step permit
|
|
361
|
+
* spent leaves the run paused again, and the commit gate parks it in
|
|
362
|
+
* `awaiting-approval` — and a UI that tracked it by watching its own buttons
|
|
363
|
+
* would be wrong in exactly the cases that matter. One event, from the thing
|
|
364
|
+
* that knows.
|
|
365
|
+
*
|
|
366
|
+
* `step` is the model turn in flight, and 0 for the opening event, before any
|
|
367
|
+
* turn has been spent.
|
|
368
|
+
*/
|
|
369
|
+
onControl?: (e: {
|
|
370
|
+
step: number;
|
|
371
|
+
state: RunState;
|
|
372
|
+
}) => void;
|
|
373
|
+
/** The run ended, for any reason including abort. Always fires once. */
|
|
374
|
+
onStop?: (e: {
|
|
375
|
+
stop: StopReason;
|
|
376
|
+
steps: number;
|
|
377
|
+
text?: string;
|
|
378
|
+
}) => void;
|
|
379
|
+
}
|
|
380
|
+
export interface DriveOptions extends DriveEvents {
|
|
381
|
+
think: Think;
|
|
382
|
+
/** What the person asked for. Appended as the newest user turn, together
|
|
383
|
+
* with the current screen. Omit it to continue a `history` that already
|
|
384
|
+
* ends in a user turn. */
|
|
385
|
+
task?: string;
|
|
386
|
+
/** Earlier turns, as returned by a previous `drive`. The loop keeps no state
|
|
387
|
+
* between runs: a conversation is the caller's array, which is what lets a
|
|
388
|
+
* widget hold one and a server hold another without this package owning a
|
|
389
|
+
* session concept. */
|
|
390
|
+
history?: Turn[];
|
|
391
|
+
/**
|
|
392
|
+
* Extra guidance from THIS HOST, folded into the system prompt after the
|
|
393
|
+
* app's own `Manifest.instructions`.
|
|
394
|
+
*
|
|
395
|
+
* Static, like everything else in there. A per-user or per-screen string
|
|
396
|
+
* here is the one mistake that makes the whole prefix uncacheable **across
|
|
397
|
+
* users**, which is where most of the saving actually lives.
|
|
398
|
+
*
|
|
399
|
+
* What belongs here is what this embedding wants said and the app itself
|
|
400
|
+
* would not say — a house tone, a rule about this deployment. What the APP
|
|
401
|
+
* has to say about itself belongs in `MountOptions.instructions`, which
|
|
402
|
+
* reaches an agent arriving over the relay as well as this one; a briefing
|
|
403
|
+
* put here is visible to one of driverkit's two paths and not the other,
|
|
404
|
+
* which is the gap that field exists to close.
|
|
405
|
+
*/
|
|
406
|
+
instructions?: string;
|
|
407
|
+
/**
|
|
408
|
+
* Hard cap on model round trips. Default 12.
|
|
409
|
+
*
|
|
410
|
+
* There is a cap at all because an agent that loops forever inside somebody
|
|
411
|
+
* else's web page is the thing that gets the library uninstalled. 12 is
|
|
412
|
+
* enough for read → describe → check the count → commit → answer with room
|
|
413
|
+
* to recover from two refusals, and small enough that a confused model costs
|
|
414
|
+
* cents rather than a tab that is still spending at lunchtime.
|
|
415
|
+
*/
|
|
416
|
+
maxSteps?: number;
|
|
417
|
+
/**
|
|
418
|
+
* Stop after this many identical refusals. Default 3.
|
|
419
|
+
*
|
|
420
|
+
* Identical means the same verb refused with the same slug. Counted across
|
|
421
|
+
* the run and not merely consecutively: a model that alternates a refused
|
|
422
|
+
* commit with a free read has not learned anything, it has just put a cheap
|
|
423
|
+
* call between two expensive mistakes.
|
|
424
|
+
*/
|
|
425
|
+
refusalLimit?: number;
|
|
426
|
+
/** Cancel the run. Checked before every model call and before every verb,
|
|
427
|
+
* and it outranks a pause: a held run is still abortable, never wedged. */
|
|
428
|
+
signal?: AbortSignal;
|
|
429
|
+
/**
|
|
430
|
+
* Milliseconds to wait before each call the model asked for — a verb or a
|
|
431
|
+
* `read_screen` — so a person can follow. **0 by default, which means no
|
|
432
|
+
* waiting at all.**
|
|
433
|
+
*
|
|
434
|
+
* Two defaults, on purpose, and the split is the same one `onBeforeCommit`
|
|
435
|
+
* makes. `drive` is a library primitive: it is driven by backend jobs, tests,
|
|
436
|
+
* CLIs and servers, where nobody is watching and a delay per call is latency
|
|
437
|
+
* charged to work with no eyes on it. So the default here is 0. `mountWidget`
|
|
438
|
+
* defaults it to `WATCHABLE_PACE`, because a panel in a page has a person in
|
|
439
|
+
* front of it by definition, and the whole reason the widget exists is that
|
|
440
|
+
* the person should be able to see what is being done to their screen and
|
|
441
|
+
* stop it. A library that invented 600ms of latency for a cron job to make a
|
|
442
|
+
* UI it cannot see feel better would have the defaults the wrong way round.
|
|
443
|
+
*
|
|
444
|
+
* The wait is before every call including the first, which is the one the
|
|
445
|
+
* person has had least chance to react to. It is cancellable: a stop during a
|
|
446
|
+
* pace wait returns at once rather than after the wait.
|
|
447
|
+
*
|
|
448
|
+
* It is not a wait per model turn. Those are already slow and already
|
|
449
|
+
* visible, and pacing them would double the latency of the part that costs
|
|
450
|
+
* money without making anything more legible.
|
|
451
|
+
*/
|
|
452
|
+
pace?: number;
|
|
453
|
+
/**
|
|
454
|
+
* Pause, resume and step. Build one with `runControls()`.
|
|
455
|
+
*
|
|
456
|
+
* Absent means a run that cannot be held, which is the right default for a
|
|
457
|
+
* caller with no UI: an unattended run with nobody to resume it would park
|
|
458
|
+
* forever on the first hold.
|
|
459
|
+
*/
|
|
460
|
+
controls?: RunControls;
|
|
461
|
+
/** The timer `pace` uses, and the clock a duration is measured against.
|
|
462
|
+
* Defaults to `setTimeout` and `Date.now`. Injectable so a suite can assert
|
|
463
|
+
* the waits without sleeping through them — and, with `timing`, so a run can
|
|
464
|
+
* produce a byte-exact transcript; see `renderDuration`. */
|
|
465
|
+
clock?: Clock;
|
|
466
|
+
/**
|
|
467
|
+
* Whether a call's elapsed time reaches the model, and when.
|
|
468
|
+
*
|
|
469
|
+
* The problem this answers: asked "compare how long it takes to fetch X and
|
|
470
|
+
* Y", an agent driving this library had nothing to go on. `AuditEvent.ms` is
|
|
471
|
+
* recorded on every call and goes to the HOST's logger; no byte of a rendered
|
|
472
|
+
* turn ever carried a duration, so a model asked about speed was guessing.
|
|
473
|
+
*
|
|
474
|
+
* `"off"` — no duration ever. **The default here**, and the reason is
|
|
475
|
+
* the same one `onBeforeCommit` is off by default in `drive`
|
|
476
|
+
* and on by default in `mountWidget`: this is a library
|
|
477
|
+
* primitive driven by a widget, a backend job, a test and a
|
|
478
|
+
* CLI, and a caller that opted into nothing must get the
|
|
479
|
+
* transcript it got before this field existed, byte for byte.
|
|
480
|
+
* Anything else would move every existing eval's cached
|
|
481
|
+
* prompts on upgrade.
|
|
482
|
+
* `"slow"` — a line only on calls at or above `SLOW_MS`. What
|
|
483
|
+
* `mountWidget` turns on. The whole token argument is here:
|
|
484
|
+
* a snappy app pays nothing, and the bytes are spent only
|
|
485
|
+
* where elapsed time is a fact about the app rather than
|
|
486
|
+
* noise. `pruneScreens` cut a ten-step run from 5,775 to
|
|
487
|
+
* 1,397 characters and this must not quietly give that back.
|
|
488
|
+
* `"always"` — a line on every call, down to tenths of a second. For the
|
|
489
|
+
* run that was actually asked to compare two fast verbs,
|
|
490
|
+
* where "both were under a second" is not the answer
|
|
491
|
+
* somebody wanted. Costs about five tokens per call forever,
|
|
492
|
+
* which is why it is not the default.
|
|
493
|
+
*
|
|
494
|
+
* What is measured is the app's own work: the clock runs across
|
|
495
|
+
* `driver.call()` and nothing else. The pace wait, a `controls` hold and this
|
|
496
|
+
* loop's own `onBeforeCommit` dialog are all outside it by construction
|
|
497
|
+
* rather than by subtraction. For a gate that lives INSIDE `driver.call()` —
|
|
498
|
+
* which is what `mountWidget` installs, through `DriverApproval.adopt` — see
|
|
499
|
+
* `waited`.
|
|
500
|
+
*/
|
|
501
|
+
timing?: "off" | "slow" | "always";
|
|
502
|
+
/**
|
|
503
|
+
* Total milliseconds this host has spent waiting on a PERSON, ever.
|
|
504
|
+
*
|
|
505
|
+
* Read before and after `driver.call()`, and the difference is subtracted
|
|
506
|
+
* from what the model is told. Monotonic and cumulative on purpose: a
|
|
507
|
+
* counter that the loop diffs cannot be got wrong by a dialog that opens
|
|
508
|
+
* twice, and the loop never has to be told when a question was asked.
|
|
509
|
+
*
|
|
510
|
+
* It exists because of one lie. A host may gate commits inside
|
|
511
|
+
* `driver.call()` rather than through `onBeforeCommit` — `mountWidget` does,
|
|
512
|
+
* via `DriverApproval.adopt`, so that a commit arriving over the relay gets
|
|
513
|
+
* the same dialog — and then the wall-clock time of the call includes
|
|
514
|
+
* somebody reading a confirmation. Reporting "this call took 40 seconds"
|
|
515
|
+
* when 38 of them were a person deciding is a false claim about the app's
|
|
516
|
+
* speed, and a model that believes it will route around a verb that is not
|
|
517
|
+
* slow.
|
|
518
|
+
*
|
|
519
|
+
* Absent means nothing is subtracted, which is correct for every host whose
|
|
520
|
+
* gate is `onBeforeCommit`: that one is already outside the measurement.
|
|
521
|
+
* Ignored entirely when `timing` is `"off"`.
|
|
522
|
+
*/
|
|
523
|
+
waited?: () => number;
|
|
524
|
+
/**
|
|
525
|
+
* Opt-in gate in front of every `commit` verb.
|
|
526
|
+
*
|
|
527
|
+
* Off by default **here, and only here**. `drive` is a library primitive: it
|
|
528
|
+
* is driven by a widget, a backend job, a test, a CLI, and a caller that has
|
|
529
|
+
* its own approval policy should not have to disable one it never asked for.
|
|
530
|
+
*
|
|
531
|
+
* It is a different judgement one level up. `mountWidget` defaults this ON,
|
|
532
|
+
* because a person watching a chatbot move their own screen should not learn
|
|
533
|
+
* about a thousand accepted rows afterwards — and the gate is cheap there
|
|
534
|
+
* for a reason worth stating: a `commit` verb takes no predicate and acts on
|
|
535
|
+
* the whole current selection, so accepting a thousand rows is ONE call and
|
|
536
|
+
* therefore one question, not a thousand. That makes it the cheapest
|
|
537
|
+
* possible place to put a human in front of the expensive failure.
|
|
538
|
+
*
|
|
539
|
+
* A veto reaches the model as a `declined-by-user` refusal — see `DECLINED`
|
|
540
|
+
* and PROTOCOL.md's reserved list — so the model adapts instead of retrying.
|
|
541
|
+
*/
|
|
542
|
+
onBeforeCommit?: (req: CommitRequest) => CommitDecision | Promise<CommitDecision>;
|
|
543
|
+
}
|
|
544
|
+
export interface DriveOutcome {
|
|
545
|
+
stop: StopReason;
|
|
546
|
+
/** The model's last prose. The thing to show the person.
|
|
547
|
+
*
|
|
548
|
+
* Present for `answered`; also present for the other endings when the model
|
|
549
|
+
* happened to narrate before it was cut off, because half an explanation is
|
|
550
|
+
* better than a bare "stopped". */
|
|
551
|
+
text?: string;
|
|
552
|
+
/** Model round trips spent. */
|
|
553
|
+
steps: number;
|
|
554
|
+
/** `history` plus everything this run added. Pass it back as the next run's
|
|
555
|
+
* `history` to continue the conversation.
|
|
556
|
+
*
|
|
557
|
+
* Not a verbatim transcript: every turn but the newest one carrying a screen
|
|
558
|
+
* has had its screen block replaced — the person's turns and the tool turns
|
|
559
|
+
* alike — so that a model is never shown two screens and left to work out
|
|
560
|
+
* which one is now true, and so that a ten-step run is not ten screens long.
|
|
561
|
+
* A tool turn keeps its outcome line either way, and no turn is ever dropped
|
|
562
|
+
* or re-paired: every `tool_use` in here still has its result. See
|
|
563
|
+
* `pruneScreens`. */
|
|
564
|
+
messages: Turn[];
|
|
565
|
+
}
|
|
566
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/agent/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAErF;;;;;;;;;GASG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,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;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;IACtB;;;;;;;;;;;;;;;;;OAiBG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACnF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,CAAC;IACjB;;;;wCAIoC;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd;;;;;;;;;0BASsB;IACtB,QAAQ,EAAE,IAAI,EAAE,CAAC;CAClB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* driverkit/agent — the contract with the model, and nothing else.
|
|
3
|
+
*
|
|
4
|
+
* This package contains **no model client and no API key handling**, and that
|
|
5
|
+
* is the load-bearing decision rather than a scoping convenience. Three
|
|
6
|
+
* reasons, in order of how much they cost to get wrong:
|
|
7
|
+
*
|
|
8
|
+
* 1. **A browser cannot hold an API key.** Anything shipped to a page is
|
|
9
|
+
* readable by whoever has the page, so a widget that takes an `apiKey`
|
|
10
|
+
* option is a widget that leaks one. The realistic deployment is that
|
|
11
|
+
* `think` does `fetch("/api/chat")` against the app's own backend, which
|
|
12
|
+
* already authenticates the person and already holds the key. That is the
|
|
13
|
+
* documented default story — see `backendThink` — and nothing in these
|
|
14
|
+
* types assumes a model is reachable from the page at all.
|
|
15
|
+
*
|
|
16
|
+
* 2. **Vendor neutrality has to be structural.** A `provider: "anthropic" |
|
|
17
|
+
* "openai"` option means this package grows a translation layer per vendor
|
|
18
|
+
* and a release per API change. A function pointer means it grows neither,
|
|
19
|
+
* and a local model, a proxy, a queue or a scripted fake all satisfy it.
|
|
20
|
+
*
|
|
21
|
+
* 3. **It is how the loop gets tested.** Every test in this package drives a
|
|
22
|
+
* real `mount()`ed driver with a scripted `think`. If the model were inside,
|
|
23
|
+
* the loop's hard parts — the refusal path, the commit gate, the bounds —
|
|
24
|
+
* would be verified by paying a vendor and hoping.
|
|
25
|
+
*
|
|
26
|
+
* The shapes below are deliberately the *intersection* of the tool-use APIs,
|
|
27
|
+
* not the union: a system string, a flat message list, a tool list, and either
|
|
28
|
+
* prose or calls coming back. Mapping that onto a vendor's wire format is
|
|
29
|
+
* twenty lines in the caller and does not belong here.
|
|
30
|
+
*/
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=types.js.map
|