@theokit/agents 10.0.0 → 11.0.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/CHANGELOG.md +324 -0
- package/LICENSE +2 -2
- package/README.md +6 -5
- package/dist/{agent-compiler-CIPQkehU.d.ts → agent-compiler-tetgj6zR.d.ts} +3 -172
- package/dist/{agent-handle-Dgi4ZGbg.d.ts → agent-handle-rEWdERuv.d.ts} +113 -2
- package/dist/auth.js +1 -1
- package/dist/{bridge-entry-emr2PSXC.d.ts → bridge-entry-DRAzQ7UA.d.ts} +32 -200
- package/dist/bridge.d.ts +7 -6
- package/dist/bridge.js +3 -3
- package/dist/{chunk-CKRM5Q2K.js → chunk-4EHZG6KN.js} +122 -16
- package/dist/chunk-4EHZG6KN.js.map +1 -0
- package/dist/{chunk-M6HMASZC.js → chunk-7PNUTDBQ.js} +109 -14
- package/dist/chunk-7PNUTDBQ.js.map +1 -0
- package/dist/{chunk-QXGSF6WX.js → chunk-D2EFYZBV.js} +1 -1
- package/dist/{chunk-QXGSF6WX.js.map → chunk-D2EFYZBV.js.map} +1 -1
- package/dist/{chunk-4VHCH6IZ.js → chunk-LLIERPF3.js} +14 -1
- package/dist/chunk-LLIERPF3.js.map +1 -0
- package/dist/{chunk-QJN2LLPF.js → chunk-T5MBTKA2.js} +275 -164
- package/dist/chunk-T5MBTKA2.js.map +1 -0
- package/dist/client-react.d.ts +24 -2
- package/dist/client-react.js +2 -1
- package/dist/client-react.js.map +1 -1
- package/dist/client.d.ts +99 -5
- package/dist/client.js +3 -1
- package/dist/config.d.ts +2 -2
- package/dist/config.js +2 -2
- package/dist/{define-agent-BO5QSjV8.d.ts → define-agent-BnH1MBxs.d.ts} +16 -1
- package/dist/{delegation-scoring-CDvtrYKd.d.ts → delegation-scoring-CQtF2Zaf.d.ts} +345 -11
- package/dist/hooks.js +2 -2
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +22 -9
- package/dist/index.js +8 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp-health.d.ts +66 -1
- package/dist/mcp-health.js +32 -1
- package/dist/mcp-health.js.map +1 -1
- package/dist/pty.js.map +1 -1
- package/dist/session.d.ts +75 -1
- package/dist/session.js +43 -4
- package/dist/session.js.map +1 -1
- package/dist/testing.d.ts +3 -2
- package/dist/testing.js +1 -1
- package/dist/tools.d.ts +4 -2
- package/dist/tools.js +4 -4
- package/dist/tools.js.map +1 -1
- package/dist/types-C16Wuh9E.d.ts +173 -0
- package/package.json +23 -10
- package/dist/chunk-4VHCH6IZ.js.map +0 -1
- package/dist/chunk-CKRM5Q2K.js.map +0 -1
- package/dist/chunk-M6HMASZC.js.map +0 -1
- package/dist/chunk-QJN2LLPF.js.map +0 -1
|
@@ -168,6 +168,83 @@ declare class ChannelTransport implements AgentTransport {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
type UseAgentStatus = 'idle' | 'streaming' | 'done' | 'error';
|
|
171
|
+
/**
|
|
172
|
+
* The stream ended before the run did — theokit#384.
|
|
173
|
+
*
|
|
174
|
+
* ## Why the status is `'error'` and not a new `'interrupted'` member
|
|
175
|
+
*
|
|
176
|
+
* `UseAgentStatus` is published, and every surface in and out of this repo switches on it. Adding a
|
|
177
|
+
* member fixes the lie only for the consumers who then update their switch; for everyone else the
|
|
178
|
+
* new value falls through to the same "not streaming, not an error" branch that shows a finished
|
|
179
|
+
* turn — the exact symptom, preserved. Reusing `'error'` fixes it for all of them at once, and it
|
|
180
|
+
* is already the value the rest of this store treats correctly: `send()` refuses to commit a turn
|
|
181
|
+
* that did not settle on `'done'`, so a half-answer stops being written into history as complete,
|
|
182
|
+
* and the reconnect wiring the issue found disabled (`status === 'error'` → `reconnect()`) starts
|
|
183
|
+
* firing without the consumer changing a line.
|
|
184
|
+
*
|
|
185
|
+
* ## Why the discrimination is a typed error rather than a status
|
|
186
|
+
*
|
|
187
|
+
* "The provider refused" and "the connection died" want opposite reactions — one is a failure to
|
|
188
|
+
* report, the other is a turn that can be resumed — and this framework already has a place for that
|
|
189
|
+
* difference: `TheokitAgentError`'s `code` + `isRetryable`, which `isTransientError` reads. A class
|
|
190
|
+
* outside that hierarchy is invisible to it and leaves the consumer matching on message text (M80).
|
|
191
|
+
*
|
|
192
|
+
* ## Why this is NOT a `stopReason` (theokit#379)
|
|
193
|
+
*
|
|
194
|
+
* The two are orthogonal, and collapsing them would be a category error. `stopReason` says why the
|
|
195
|
+
* RUN stopped and rides the `finish` chunk's metadata — it exists only when a terminal frame
|
|
196
|
+
* arrived. An interruption is the ABSENCE of that frame: the run may still be going, and this
|
|
197
|
+
* client cannot know why it stopped, because it never heard. Spelling it as a third `stopReason`
|
|
198
|
+
* member would put a value on a `done` turn that no producer produced, and would reintroduce the
|
|
199
|
+
* defect it fixes — a truncated run reported through the field that means "the agent finished".
|
|
200
|
+
* Transport termination and execution termination are separate axes; this is the transport one.
|
|
201
|
+
*/
|
|
202
|
+
declare class AgentStreamInterruptedError extends TheokitAgentError {
|
|
203
|
+
readonly chunksReceived: number;
|
|
204
|
+
readonly name = "AgentStreamInterruptedError";
|
|
205
|
+
constructor(chunksReceived: number);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* One HITL decision the run is parked on, flattened for the surface that renders it
|
|
209
|
+
* (usetheokit/theokit#392).
|
|
210
|
+
*
|
|
211
|
+
* ## Why the store publishes this at all, when the part already carries it
|
|
212
|
+
*
|
|
213
|
+
* `approve()` needs an id. Before this field the snapshot had four keys and none of them was that
|
|
214
|
+
* id, so an application had two options: scan every part of every message for `state ===
|
|
215
|
+
* 'approval-requested'`, or poll `GET /api/agents/<name>/approvals` out of band — which is what the
|
|
216
|
+
* measured J2 client did, at twelve lines and two React primitives, through an endpoint under a
|
|
217
|
+
* security advisory. Publishing the id is what removes the reason to reach for either.
|
|
218
|
+
*
|
|
219
|
+
* ## Why it is DERIVED and not accumulated
|
|
220
|
+
*
|
|
221
|
+
* It is computed from the current turn's parts on each emit, never written by a second reducer. A
|
|
222
|
+
* separate list would need its own settle path and could then disagree with the transcript about
|
|
223
|
+
* whether a decision is outstanding — and the transcript is what renders. Deriving makes the two
|
|
224
|
+
* unable to drift: a settled gate leaves `approval-requested` on the same chunk that fills in the
|
|
225
|
+
* output, so it leaves this array in the same step.
|
|
226
|
+
*
|
|
227
|
+
* ## Why plural
|
|
228
|
+
*
|
|
229
|
+
* The SDK dispatches a round's calls concurrently (`mapWithConcurrency`), so two gated calls of the
|
|
230
|
+
* same tool can be outstanding at once — pinned by
|
|
231
|
+
* `tests/integration/hitl-call-correlation.test.ts`. A singular field would have to pick one and
|
|
232
|
+
* would be silently wrong exactly when a human has two things to decide.
|
|
233
|
+
*/
|
|
234
|
+
interface PendingApproval {
|
|
235
|
+
/** The id `approve()` settles. */
|
|
236
|
+
readonly approvalId: string;
|
|
237
|
+
/** The call this gate holds — the same id `tool-input-available` announced. */
|
|
238
|
+
readonly toolCallId: string;
|
|
239
|
+
/** The gated tool's name, off the part. `undefined` only if the producer announced none. */
|
|
240
|
+
readonly toolName: string | undefined;
|
|
241
|
+
/** The resolved arguments the human is authorising, off the part. */
|
|
242
|
+
readonly input: unknown;
|
|
243
|
+
/** The question declared on the gate, when the producer sent one. */
|
|
244
|
+
readonly question?: string;
|
|
245
|
+
/** The window before the gate settles itself, in ms, when the producer sent one. */
|
|
246
|
+
readonly timeoutMs?: number;
|
|
247
|
+
}
|
|
171
248
|
/** The observable state the store exposes (stable reference between emits — `useSyncExternalStore` contract). */
|
|
172
249
|
interface AgentClientState {
|
|
173
250
|
/** The CURRENT turn's assistant messages (per-turn; reset each `send`). Back-compat — unchanged since M41. */
|
|
@@ -180,6 +257,11 @@ interface AgentClientState {
|
|
|
180
257
|
thread: WireMessage[];
|
|
181
258
|
status: UseAgentStatus;
|
|
182
259
|
error: Error | undefined;
|
|
260
|
+
/**
|
|
261
|
+
* The HITL decisions this turn is parked on, newest last. Empty whenever nothing is outstanding.
|
|
262
|
+
* Each entry carries the id `approve()` takes plus what the prompt needs to name the action.
|
|
263
|
+
*/
|
|
264
|
+
pendingApprovals: PendingApproval[];
|
|
183
265
|
}
|
|
184
266
|
/**
|
|
185
267
|
* M41 (ADR-0050 D6) — the framework-agnostic agent client store.
|
|
@@ -201,10 +283,31 @@ interface AgentClientOptions {
|
|
|
201
283
|
* change the observable behaviour of anyone counting emits or depending on first-token latency.
|
|
202
284
|
*/
|
|
203
285
|
readonly emitIntervalMs?: number;
|
|
286
|
+
/**
|
|
287
|
+
* The conversation this client continues. Absent = a fresh one is drawn.
|
|
288
|
+
*
|
|
289
|
+
* The id is not decorative: the HTTP transport sends it as the top-level `id`, which the server
|
|
290
|
+
* reads as the session id (`client/http-transport.ts:88-92`). It used to be drawn in the field
|
|
291
|
+
* declaration with no way to supply or read it, so every `new AgentClient(...)` was a new
|
|
292
|
+
* conversation and a page reload silently abandoned the thread the server still held
|
|
293
|
+
* (usetheokit/theokit#364).
|
|
294
|
+
*
|
|
295
|
+
* Supply it to resume; read `client.chatId` to persist it. Both halves are needed: reading without
|
|
296
|
+
* supplying lets an application store an id it can never restore, and supplying without reading
|
|
297
|
+
* leaves it nothing to store.
|
|
298
|
+
*/
|
|
299
|
+
readonly chatId?: string;
|
|
204
300
|
}
|
|
205
301
|
declare class AgentClient<TInput = unknown> {
|
|
206
302
|
#private;
|
|
207
303
|
constructor(transport: AgentTransport, contextResolver?: () => RequestContext | undefined, options?: AgentClientOptions);
|
|
304
|
+
/**
|
|
305
|
+
* The conversation this client is on — the id the server keys the session by.
|
|
306
|
+
*
|
|
307
|
+
* Readable so an application can persist it and pass it back through
|
|
308
|
+
* {@link AgentClientOptions.chatId} after a reload (usetheokit/theokit#364).
|
|
309
|
+
*/
|
|
310
|
+
get chatId(): string;
|
|
208
311
|
/** Subscribe to state changes; returns an unsubscribe fn. */
|
|
209
312
|
subscribe: (listener: () => void) => (() => void);
|
|
210
313
|
/** The current immutable snapshot (stable reference until the next emit). */
|
|
@@ -217,7 +320,15 @@ declare class AgentClient<TInput = unknown> {
|
|
|
217
320
|
abort: () => void;
|
|
218
321
|
/** Clear messages + error, back to idle. */
|
|
219
322
|
reset: () => void;
|
|
220
|
-
/**
|
|
323
|
+
/**
|
|
324
|
+
* Settle a paused HITL approval via the transport's HITL path (HTTP POST or inline callback).
|
|
325
|
+
*
|
|
326
|
+
* The signature is unchanged by usetheokit/theokit#392, deliberately. What that issue reported was
|
|
327
|
+
* not that `approve` takes an id — it was that nothing HANDED the caller one, so the id had to be
|
|
328
|
+
* mined out of band. `pendingApprovals` hands it over, and taking the entry instead of its
|
|
329
|
+
* `approvalId` would save no line while adding a second accepted shape to a published method that
|
|
330
|
+
* surfaces outside this repository (`@theokit/tui`, `@theokit/ui`).
|
|
331
|
+
*/
|
|
221
332
|
approve: (approvalId: string, decision: ApprovalDecision) => Promise<void>;
|
|
222
333
|
}
|
|
223
334
|
|
|
@@ -258,4 +369,4 @@ declare function agentHandle<TInput = unknown, TToolNames extends string = strin
|
|
|
258
369
|
/** Narrow an unknown binding to an {@link AgentHandle} (has a string `path`, is not a transport). */
|
|
259
370
|
declare function isAgentHandle(value: unknown): value is AgentHandle;
|
|
260
371
|
|
|
261
|
-
export { type ApprovalDecision as A, type ChannelPushSource as C, type InProcessApprovalRequestLike as I, type RequestContext as R, type UseAgentStatus as U, type AgentHandle as a, type AgentTransport as b, AgentClient as c, type AgentClientOptions as d, type AgentClientState as e,
|
|
372
|
+
export { type ApprovalDecision as A, type ChannelPushSource as C, type InProcessApprovalRequestLike as I, type PendingApproval as P, type RequestContext as R, type UseAgentStatus as U, type AgentHandle as a, type AgentTransport as b, AgentClient as c, type AgentClientOptions as d, type AgentClientState as e, AgentStreamInterruptedError as f, ApprovalAbortedError as g, ChannelTransport as h, type ChannelTransportOptions as i, type ChannelTurnHandlers as j, type InProcessAwaitApproval as k, type InProcessRunInput as l, type InProcessRunner as m, InProcessTransport as n, type InProcessTransportOptions as o, agentHandle as p, isAgentHandle as q };
|
package/dist/auth.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { ExecutionContext } from '@theokit/http';
|
|
2
|
-
import { c as AgentOptions, T as ToolOptions,
|
|
2
|
+
import { c as AgentOptions, T as ToolOptions, P as ProjectContextOptions, H as HumanInTheLoopOptions, R as ReasoningEffort, M as McpServersMap } from './types-C16Wuh9E.js';
|
|
3
|
+
import { C as CompiledAgentOptions, a as CompiledTool, G as Guardrail, S as SkillsSelection } from './agent-compiler-tetgj6zR.js';
|
|
3
4
|
import { SkillsSettings, ContextSettings, SystemPromptResolver, ModelSelection, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition as AgentDefinition$1, BudgetTracker, CustomTool, RunEventSink, MemorySettings } from '@theokit/sdk';
|
|
4
|
-
import { S as StreamEvent } from './delegation-scoring-
|
|
5
|
+
import { S as StreamEvent, f as ApprovalRequiredEvent, a4 as MaskError } from './delegation-scoring-CQtF2Zaf.js';
|
|
5
6
|
import { SandboxPosture } from '@theokit/sdk/sandbox';
|
|
6
|
-
import { A as AgentDefinition, S as SettingSourcesSelection } from './define-agent-
|
|
7
|
-
import { WireChunk } from '@theokit/presenter/wire';
|
|
7
|
+
import { A as AgentDefinition, S as SettingSourcesSelection } from './define-agent-BnH1MBxs.js';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
import { H as HookHandlers } from './hook-handlers-Cw2FsnE5.js';
|
|
10
|
+
import { WireChunk } from '@theokit/presenter/wire';
|
|
10
11
|
import { TheokitAgentError } from '@theokit/sdk/errors';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -120,197 +121,6 @@ declare function projectContextMetadataOnlyKnobs(options: ProjectContextOptions)
|
|
|
120
121
|
*/
|
|
121
122
|
declare function compileProjectContext(options: ProjectContextOptions, base?: string | SystemPromptResolver): SystemPromptResolver;
|
|
122
123
|
|
|
123
|
-
/**
|
|
124
|
-
* Typed discriminated union for agent SSE stream events.
|
|
125
|
-
*
|
|
126
|
-
* Every event has a `type` field for discrimination.
|
|
127
|
-
* Clients narrow via `if (event.type === 'text_delta') event.content`.
|
|
128
|
-
*/
|
|
129
|
-
/** Partial text content from the LLM. */
|
|
130
|
-
interface TextDeltaEvent {
|
|
131
|
-
type: 'text_delta';
|
|
132
|
-
content: string;
|
|
133
|
-
}
|
|
134
|
-
/** Agent started a tool call. */
|
|
135
|
-
interface ToolCallEvent {
|
|
136
|
-
type: 'tool_call';
|
|
137
|
-
callId: string;
|
|
138
|
-
toolName: string;
|
|
139
|
-
input: unknown;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Tool-call arguments streaming in incrementally (theokit-sdk#70). Emitted repeatedly as the
|
|
143
|
-
* model generates a tool call's args, BEFORE they are committed. The same `callId` correlates to
|
|
144
|
-
* the later `tool_call` (args committed) and `tool_result`. Consumers opt in to render tool-input
|
|
145
|
-
* progressively; those that don't simply ignore this variant (it never replaces `tool_call`).
|
|
146
|
-
*/
|
|
147
|
-
interface PartialToolCallEvent {
|
|
148
|
-
type: 'partial_tool_call';
|
|
149
|
-
callId: string;
|
|
150
|
-
toolName: string;
|
|
151
|
-
input: unknown;
|
|
152
|
-
}
|
|
153
|
-
/** Tool execution completed. */
|
|
154
|
-
interface ToolResultEvent {
|
|
155
|
-
type: 'tool_result';
|
|
156
|
-
callId: string;
|
|
157
|
-
toolName: string;
|
|
158
|
-
output: string;
|
|
159
|
-
durationMs: number;
|
|
160
|
-
isError: boolean;
|
|
161
|
-
}
|
|
162
|
-
/** Extended thinking / reasoning (when model supports it). */
|
|
163
|
-
interface ThinkingEvent {
|
|
164
|
-
type: 'thinking';
|
|
165
|
-
content: string;
|
|
166
|
-
}
|
|
167
|
-
/** Agent loop iteration. */
|
|
168
|
-
interface IterationEvent {
|
|
169
|
-
type: 'iteration';
|
|
170
|
-
step: number;
|
|
171
|
-
totalSteps: number | null;
|
|
172
|
-
}
|
|
173
|
-
/** Human approval required before proceeding. */
|
|
174
|
-
interface ApprovalRequiredEvent {
|
|
175
|
-
type: 'approval_required';
|
|
176
|
-
callId: string;
|
|
177
|
-
toolName: string;
|
|
178
|
-
question: string;
|
|
179
|
-
input?: unknown;
|
|
180
|
-
callbackUrl: string;
|
|
181
|
-
timeoutMs: number;
|
|
182
|
-
/** M20 — JSON-schema descriptor of the custom payload the approver may attach (optional). */
|
|
183
|
-
payloadSchema?: Record<string, unknown>;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* The run is blocked awaiting user input or approval — theokit#141.
|
|
187
|
-
*
|
|
188
|
-
* The SDK's low-fidelity pause signal (`SDKRequestMessage`), distinct from {@link
|
|
189
|
-
* ApprovalRequiredEvent}. The latter is the framework's own, produced by `createHitlPlugin`, and
|
|
190
|
-
* carries everything an approval UI needs to be actionable. This one carries only the request id,
|
|
191
|
-
* because that is all the SDK provides — and it matters most exactly where the plugin is absent
|
|
192
|
-
* (the ACP/serving path of theokit#139), which is where a dropped pause reads to the user as a
|
|
193
|
-
* hang with no explanation.
|
|
194
|
-
*
|
|
195
|
-
* A consumer that cannot resolve the request should still SHOW that the run is waiting. Silence is
|
|
196
|
-
* the one response that is always wrong.
|
|
197
|
-
*/
|
|
198
|
-
interface InputRequestedEvent {
|
|
199
|
-
type: 'input_requested';
|
|
200
|
-
requestId: string;
|
|
201
|
-
}
|
|
202
|
-
/** Task-level milestone or summary — theokit#141. Both fields are optional at the source. */
|
|
203
|
-
interface TaskProgressEvent {
|
|
204
|
-
type: 'task_progress';
|
|
205
|
-
status?: string;
|
|
206
|
-
text?: string;
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Live output from a shell command the SDK is running — theokit#141.
|
|
210
|
-
*
|
|
211
|
-
* `event` is passed through opaquely because the SDK types it as `Record<string, unknown>`. The
|
|
212
|
-
* layer deliberately does not interpret or render it: guessing a shape here would be a second,
|
|
213
|
-
* weaker oracle over a payload whose real contract lives upstream.
|
|
214
|
-
*/
|
|
215
|
-
interface ShellOutputEvent {
|
|
216
|
-
type: 'shell_output';
|
|
217
|
-
event: Record<string, unknown>;
|
|
218
|
-
}
|
|
219
|
-
/** Agent encountered an error. */
|
|
220
|
-
interface ErrorEvent {
|
|
221
|
-
type: 'error';
|
|
222
|
-
code: string;
|
|
223
|
-
message: string;
|
|
224
|
-
retryable: boolean;
|
|
225
|
-
}
|
|
226
|
-
/** Agent completed with a final result. */
|
|
227
|
-
interface DoneEvent {
|
|
228
|
-
type: 'done';
|
|
229
|
-
result: string;
|
|
230
|
-
usage: {
|
|
231
|
-
inputTokens: number;
|
|
232
|
-
outputTokens: number;
|
|
233
|
-
totalTokens: number;
|
|
234
|
-
/** V4-O: SDK reasoning/cache token buckets (0 when the provider omits them). */
|
|
235
|
-
reasoningTokens?: number;
|
|
236
|
-
cacheReadTokens?: number;
|
|
237
|
-
cacheWriteTokens?: number;
|
|
238
|
-
};
|
|
239
|
-
durationMs: number;
|
|
240
|
-
/** Total cost in USD for this agent run (EC-2: added for budget tracking). */
|
|
241
|
-
cost?: number;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Per-turn usage the translator attaches to the ai-sdk `finish` chunk's `messageMetadata`, so it
|
|
245
|
-
* lands on the reconstructed assistant `UIMessage.metadata` on the client (via `readUIMessageStream`)
|
|
246
|
-
* with NO extra header/store wiring. It is the seam that lets a surface (a TUI status bar, a web
|
|
247
|
-
* cost meter) show real tokens/cost for the turn it just streamed. Mirrors `DoneEvent`'s usage/cost
|
|
248
|
-
* (the authoritative totals the SDK reports at turn end) plus the wall-clock `durationMs`.
|
|
249
|
-
*/
|
|
250
|
-
interface AgentTurnMetadata {
|
|
251
|
-
usage: DoneEvent['usage'];
|
|
252
|
-
/** Total cost in USD for the turn (present iff the SDK reported it). */
|
|
253
|
-
cost?: number;
|
|
254
|
-
durationMs: number;
|
|
255
|
-
}
|
|
256
|
-
/** Agent run started. */
|
|
257
|
-
interface RunStartedEvent {
|
|
258
|
-
type: 'run_started';
|
|
259
|
-
runId: string;
|
|
260
|
-
agentName: string;
|
|
261
|
-
model?: string;
|
|
262
|
-
}
|
|
263
|
-
/** Artifact generation started (code, document, diagram). */
|
|
264
|
-
interface ArtifactStartEvent {
|
|
265
|
-
type: 'artifact_start';
|
|
266
|
-
artifactId: string;
|
|
267
|
-
mimeType: string;
|
|
268
|
-
filename?: string;
|
|
269
|
-
metadata?: Record<string, unknown>;
|
|
270
|
-
}
|
|
271
|
-
/** Artifact content chunk (streamable artifacts). */
|
|
272
|
-
interface ArtifactChunkEvent {
|
|
273
|
-
type: 'artifact_chunk';
|
|
274
|
-
artifactId: string;
|
|
275
|
-
chunk: string;
|
|
276
|
-
isLast: boolean;
|
|
277
|
-
}
|
|
278
|
-
/** Real-time state update from @Observable channels. */
|
|
279
|
-
interface StateUpdateEvent {
|
|
280
|
-
type: 'state_update';
|
|
281
|
-
channel: string;
|
|
282
|
-
data: unknown;
|
|
283
|
-
}
|
|
284
|
-
/** Checkpoint saved (resumable agents). */
|
|
285
|
-
interface CheckpointSavedEvent {
|
|
286
|
-
type: 'checkpoint_saved';
|
|
287
|
-
checkpointId: string;
|
|
288
|
-
step: number;
|
|
289
|
-
resumeToken: string;
|
|
290
|
-
}
|
|
291
|
-
/** File edit produced by a code assistant tool. */
|
|
292
|
-
interface FileEditEvent {
|
|
293
|
-
type: 'file_edit';
|
|
294
|
-
file: string;
|
|
295
|
-
format: 'search-replace' | 'unified-diff' | 'full-file' | 'line-range';
|
|
296
|
-
search?: string;
|
|
297
|
-
replace?: string;
|
|
298
|
-
content?: string;
|
|
299
|
-
diff?: string;
|
|
300
|
-
startLine?: number;
|
|
301
|
-
endLine?: number;
|
|
302
|
-
}
|
|
303
|
-
/** Discriminated union of all agent stream events. */
|
|
304
|
-
type AgentStreamEvent = RunStartedEvent | TextDeltaEvent | ToolCallEvent | PartialToolCallEvent | ToolResultEvent | ThinkingEvent | IterationEvent | ApprovalRequiredEvent | InputRequestedEvent | TaskProgressEvent | ShellOutputEvent | ArtifactStartEvent | ArtifactChunkEvent | StateUpdateEvent | CheckpointSavedEvent | FileEditEvent | ErrorEvent | DoneEvent;
|
|
305
|
-
/** Type guard helpers. */
|
|
306
|
-
declare function isTextDelta(e: AgentStreamEvent): e is TextDeltaEvent;
|
|
307
|
-
declare function isToolCall(e: AgentStreamEvent): e is ToolCallEvent;
|
|
308
|
-
declare function isPartialToolCall(e: AgentStreamEvent): e is PartialToolCallEvent;
|
|
309
|
-
declare function isToolResult(e: AgentStreamEvent): e is ToolResultEvent;
|
|
310
|
-
declare function isDone(e: AgentStreamEvent): e is DoneEvent;
|
|
311
|
-
declare function isError(e: AgentStreamEvent): e is ErrorEvent;
|
|
312
|
-
declare function isApprovalRequired(e: AgentStreamEvent): e is ApprovalRequiredEvent;
|
|
313
|
-
|
|
314
124
|
/**
|
|
315
125
|
* Auto-generate HTTP routes from @Agent metadata — Web Standard.
|
|
316
126
|
*
|
|
@@ -370,6 +180,14 @@ interface HitlDecision {
|
|
|
370
180
|
approved: boolean;
|
|
371
181
|
reason?: string;
|
|
372
182
|
payload?: unknown;
|
|
183
|
+
/**
|
|
184
|
+
* What settled this, when it was not a person (usetheokit/theokit#393).
|
|
185
|
+
*
|
|
186
|
+
* Mirrors `ApprovalDecision.settledBy` in `theokit`, for the reason the comment above this
|
|
187
|
+
* interface gives: this package must not import from `theokit`. Absent means the decision came
|
|
188
|
+
* through the approve route; `'timeout'` means the window closed with nobody deciding.
|
|
189
|
+
*/
|
|
190
|
+
settledBy?: 'timeout';
|
|
373
191
|
}
|
|
374
192
|
/** Injected wiring — the harness (mount-agent) supplies these; the plugin stays pure. */
|
|
375
193
|
interface HitlWiring {
|
|
@@ -838,10 +656,6 @@ interface SdkMessage {
|
|
|
838
656
|
*/
|
|
839
657
|
declare function translateSdkEvent(msg: SdkMessage, runId: string): StreamEvent[];
|
|
840
658
|
|
|
841
|
-
declare function presentUIMessageStream(events: AsyncIterable<AgentStreamEvent>, opts: {
|
|
842
|
-
textId: string;
|
|
843
|
-
}): AsyncGenerator<WireChunk, void, unknown>;
|
|
844
|
-
|
|
845
659
|
/**
|
|
846
660
|
* M8 — `AgentBuilder.create()`, the fluent agent builder with accumulative **type-state**.
|
|
847
661
|
*
|
|
@@ -949,6 +763,15 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
|
|
|
949
763
|
system(prompt: string): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
950
764
|
/** Set the extended-thinking effort. */
|
|
951
765
|
reasoningEffort(effort: ReasoningEffort): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
766
|
+
/**
|
|
767
|
+
* theokit#363 — cap the agent's tool-calling turns within ONE run. A positive integer; throws at
|
|
768
|
+
* `.build()` otherwise. Unset ⇒ the SDK's own ceiling (8) applies, unchanged.
|
|
769
|
+
*
|
|
770
|
+
* This is the chain the scaffold writes, and until now it had no way to say "stop after N steps":
|
|
771
|
+
* the declaration existed on the decorator path only, and even there nothing on the served path
|
|
772
|
+
* read it. See {@link DefineAgentConfig.maxIterations} for why the name is `maxIterations`.
|
|
773
|
+
*/
|
|
774
|
+
maxIterations(limit: number): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
952
775
|
/** Set the run-context (M7) — the object every tool handler receives as `ctx.context`. */
|
|
953
776
|
context<C extends Record<string, unknown>>(value: C): AgentBuilder<TInput, TModel, C, TTools>;
|
|
954
777
|
/**
|
|
@@ -1110,6 +933,15 @@ interface StreamHitlOptions {
|
|
|
1110
933
|
interface StreamAgentOptions {
|
|
1111
934
|
message: string;
|
|
1112
935
|
sessionId: string;
|
|
936
|
+
/**
|
|
937
|
+
* What the browser is told a failure was (usetheokit/theokit#390).
|
|
938
|
+
*
|
|
939
|
+
* Absent ⇒ masked to a fixed string. The server's raw error text — a driver's message, an HTTP
|
|
940
|
+
* client's, a filesystem call's — used to reach the client verbatim, and `ai@7` on the same
|
|
941
|
+
* protocol masks by default for the reason its own comment gives. The full text still reaches
|
|
942
|
+
* the logs and the `agent.run` span; what stops is it reaching a browser unless a host decides.
|
|
943
|
+
*/
|
|
944
|
+
onError?: MaskError;
|
|
1113
945
|
/** M35 (multimodal) — images to send alongside the text. Absent ⇒ the string send path is unchanged. */
|
|
1114
946
|
images?: RuntimeOverrides['images'];
|
|
1115
947
|
/** Enable human-in-the-loop tool approval (M4). Absent ⇒ the M2 non-HITL path, byte-unchanged. */
|
|
@@ -1594,4 +1426,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
|
|
|
1594
1426
|
register(app: PluginApp): void;
|
|
1595
1427
|
};
|
|
1596
1428
|
|
|
1597
|
-
export {
|
|
1429
|
+
export { createApiErrorHandler as $, type AgentManifestEntry as A, type BeforeToolCallContext as B, type ContextWindowOptions as C, type DefinitionOrThunk as D, type EphemeralAgent as E, type SdkMessage as F, type SdkSendOptions as G, type HitlDecision as H, type SdkTurnHandle as I, type Segment as J, type ShouldAutoApproveOptions as K, type LLMCallContext as L, type McpApprovalSpec as M, type ToolHooks as N, type ToolHooksPlugin as O, type ProcessInputContext as P, agentsPlugin as Q, applyPosture as R, type SkillsOptions as S, type ToolCallVeto as T, buildModelSelection as U, compileAgentModule as V, WRITE_SCOPED_TOOLS as W, compileContextWindow as X, compileProjectContext as Y, compileSkills as Z, createAgentExecutionContext as _, type ApprovalPosture as a, createSdkAgentStream as a0, createThinkTagExtractor as a1, createToolHooksPlugin as a2, extractThinkTagStream as a3, generateAgentManifest as a4, generateAgentRoutes as a5, isAgentContext as a6, loadMcpJson as a7, mcpRegistry as a8, mcpToolApprovals as a9, projectContextMetadataOnlyKnobs as aa, reasoningEffortOf as ab, resolveMcpServers as ac, runWithApiErrorHandling as ad, shouldAutoApprove as ae, toAgentFactory as af, translateSdkEvent as ag, withClockCap as ah, withEphemeralAgent as ai, APPROVAL_MODES as b, type AfterToolCallContext as c, AgentBuilder as d, AgentDefinitionError as e, type AgentExecutionContext as f, type AgentManifest as g, type AgentManifestSource as h, type AgentManifestTool as i, type AgentRoute as j, type AgentRouteContext as k, type AgentRunInfo as l, type AgentsPluginOptions as m, type ApiErrorContext as n, type ApiErrorDecision as o, type ApiErrorPolicy as p, type ApprovalMode as q, type CompiledContextWindow as r, streamAgentUIMessages as s, ContextualTool as t, DelegationTimeoutError as u, McpFileError as v, type McpRegistryConfig as w, type McpRequestContext as x, type McpSelection as y, type SdkAgentHandle as z };
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
export { b as APPROVAL_MODES, c as AfterToolCallContext, d as AgentBuilder, e as AgentDefinitionError, f as AgentExecutionContext, g as AgentManifest, A as AgentManifestEntry, h as AgentManifestSource, i as AgentManifestTool, j as AgentRoute, k as AgentRouteContext, l as AgentRunInfo, m as
|
|
2
|
-
export { C as CompiledAgentOptions,
|
|
3
|
-
export { B as BackgroundDelegation,
|
|
4
|
-
export { a as AGENT_BRAND, A as AgentDefinition, D as DefineAgentConfig, I as InferAgentInput, b as InferAgentToolNames, P as ProjectSettingsGrant, c as SettingSourceCapability, S as SettingSourcesSelection, U as UntrustedSettingSourceError, d as compileAgentDefinition, i as isAgentDefinition, r as resolveSettingSources } from './define-agent-
|
|
1
|
+
export { b as APPROVAL_MODES, c as AfterToolCallContext, d as AgentBuilder, e as AgentDefinitionError, f as AgentExecutionContext, g as AgentManifest, A as AgentManifestEntry, h as AgentManifestSource, i as AgentManifestTool, j as AgentRoute, k as AgentRouteContext, l as AgentRunInfo, m as AgentsPluginOptions, n as ApiErrorContext, o as ApiErrorDecision, p as ApiErrorPolicy, q as ApprovalMode, a as ApprovalPosture, B as BeforeToolCallContext, r as CompiledContextWindow, t as ContextualTool, D as DefinitionOrThunk, u as DelegationTimeoutError, E as EphemeralAgent, L as LLMCallContext, M as McpApprovalSpec, v as McpFileError, w as McpRegistryConfig, x as McpRequestContext, y as McpSelection, P as ProcessInputContext, z as SdkAgentHandle, F as SdkMessage, G as SdkSendOptions, I as SdkTurnHandle, J as Segment, K as ShouldAutoApproveOptions, T as ToolCallVeto, N as ToolHooks, O as ToolHooksPlugin, W as WRITE_SCOPED_TOOLS, Q as agentsPlugin, R as applyPosture, U as buildModelSelection, V as compileAgentModule, X as compileContextWindow, Y as compileProjectContext, Z as compileSkills, _ as createAgentExecutionContext, $ as createApiErrorHandler, a0 as createSdkAgentStream, a1 as createThinkTagExtractor, a2 as createToolHooksPlugin, a3 as extractThinkTagStream, a4 as generateAgentManifest, a5 as generateAgentRoutes, a6 as isAgentContext, a7 as loadMcpJson, a8 as mcpRegistry, a9 as mcpToolApprovals, aa as projectContextMetadataOnlyKnobs, ab as reasoningEffortOf, ac as resolveMcpServers, ad as runWithApiErrorHandling, ae as shouldAutoApprove, s as streamAgentUIMessages, af as toAgentFactory, ag as translateSdkEvent, ah as withClockCap, ai as withEphemeralAgent } from './bridge-entry-DRAzQ7UA.js';
|
|
2
|
+
export { C as CompiledAgentOptions, a as CompiledTool, T as ToolWalkResult, h as ToolboxWalkResult, i as compileTools } from './agent-compiler-tetgj6zR.js';
|
|
3
|
+
export { A as AgentStopReason, d as AgentStreamEvent, e as AgentTurnMetadata, f as ApprovalRequiredEvent, g as ArtifactChunkEvent, h as ArtifactStartEvent, B as BackgroundDelegation, i as BudgetExceededError, C as CheckpointSavedEvent, k as DelegateFn, a as DelegateOptions, l as DelegationBudgetExceededError, m as DelegationError, n as DelegationPort, c as DelegationResult, D as DelegationTarget, o as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, P as PartialToolCallEvent, v as RunStartedEvent, w as ScoreVerdict, x as ScoredDelegation, y as Scorer, z as StateUpdateEvent, S as StreamEvent, T as TextDeltaEvent, G as ThinkingEvent, H as ToolCallEvent, J as ToolResultEvent, K as delegate, M as delegateBackground, N as delegateWithScoring, O as isApprovalRequired, Q as isDone, U as isError, V as isPartialToolCall, W as isTextDelta, X as isToolCall, Y as isToolResult, a0 as presentUIMessageStream, a3 as streamAgentResponse } from './delegation-scoring-CQtF2Zaf.js';
|
|
4
|
+
export { a as AGENT_BRAND, A as AgentDefinition, D as DefineAgentConfig, I as InferAgentInput, b as InferAgentToolNames, P as ProjectSettingsGrant, c as SettingSourceCapability, S as SettingSourcesSelection, U as UntrustedSettingSourceError, d as compileAgentDefinition, i as isAgentDefinition, r as resolveSettingSources } from './define-agent-BnH1MBxs.js';
|
|
5
5
|
import '@theokit/http';
|
|
6
|
+
import './types-C16Wuh9E.js';
|
|
6
7
|
import '@theokit/sdk';
|
|
7
|
-
import '@theokit/sdk/sandbox';
|
|
8
|
-
import '@theokit/presenter/wire';
|
|
9
8
|
import 'zod';
|
|
9
|
+
import '@theokit/sdk/sandbox';
|
|
10
10
|
import './hook-handlers-Cw2FsnE5.js';
|
|
11
|
+
import '@theokit/presenter/wire';
|
|
11
12
|
import '@theokit/sdk/errors';
|
|
12
13
|
import '@theokit/sdk/retry';
|
package/dist/bridge.js
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
runWithApiErrorHandling,
|
|
29
29
|
streamAgentResponse,
|
|
30
30
|
streamAgentUIMessages
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-T5MBTKA2.js";
|
|
32
32
|
import {
|
|
33
33
|
APPROVAL_MODES,
|
|
34
34
|
BudgetExceededError,
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
translateSdkEvent,
|
|
54
54
|
withClockCap,
|
|
55
55
|
withEphemeralAgent
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-4EHZG6KN.js";
|
|
57
57
|
import "./chunk-RKWCXVYG.js";
|
|
58
58
|
import {
|
|
59
59
|
AGENT_BRAND,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
compileAgentDefinition,
|
|
62
62
|
isAgentDefinition,
|
|
63
63
|
resolveSettingSources
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-LLIERPF3.js";
|
|
65
65
|
import "./chunk-Z4QWC7IK.js";
|
|
66
66
|
export {
|
|
67
67
|
AGENT_BRAND,
|