@theokit/agents 16.6.0 → 16.7.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 +14 -0
- package/README.md +84 -3
- package/dist/{agent-compiler-C-4X_vKz.d.ts → agent-compiler-aubY9WIa.d.ts} +13 -1
- package/dist/{agent-handle-rEWdERuv.d.ts → agent-handle-C343-xUh.d.ts} +16 -1
- package/dist/{agent-orchestrator-4xtsYrzm.d.ts → agent-orchestrator-DQtfrPaq.d.ts} +1 -1
- package/dist/{agent-runner-CE8MzVTu.d.ts → agent-runner-BuuqK_Dp.d.ts} +2 -2
- package/dist/{bridge-entry-BT2ou71q.d.ts → bridge-entry-nkeH6pAk.d.ts} +49 -6
- package/dist/bridge.d.ts +5 -5
- package/dist/bridge.js +7 -5
- package/dist/{chunk-KXE52FP2.js → chunk-4DOKIDGC.js} +59 -1
- package/dist/chunk-4DOKIDGC.js.map +1 -0
- package/dist/{chunk-NIQJ4GZX.js → chunk-JJ6Y6EBP.js} +4 -1
- package/dist/chunk-JJ6Y6EBP.js.map +1 -0
- package/dist/{chunk-ZLKZOSWR.js → chunk-RXD6S6RV.js} +2 -2
- package/dist/{chunk-K4MY4CV7.js → chunk-UARNAQ6O.js} +3 -3
- package/dist/{chunk-AZ2FOUSN.js → chunk-W533YIGA.js} +32 -5
- package/dist/chunk-W533YIGA.js.map +1 -0
- package/dist/{chunk-CZIJFINK.js → chunk-XGW7IZP6.js} +67 -3
- package/dist/chunk-XGW7IZP6.js.map +1 -0
- package/dist/client-react.d.ts +1 -1
- package/dist/client-react.js +1 -1
- package/dist/client.d.ts +14 -4
- package/dist/client.js +49 -2
- package/dist/client.js.map +1 -1
- package/dist/commands.d.ts +64 -12
- package/dist/commands.js +104 -12
- package/dist/commands.js.map +1 -1
- package/dist/config.d.ts +105 -1
- package/dist/config.js +454 -60
- package/dist/config.js.map +1 -1
- package/dist/{delegation-scoring-4dQIXi-w.d.ts → delegation-scoring-DPckVefy.d.ts} +1 -1
- package/dist/evals.d.ts +2 -2
- package/dist/evals.js +2 -2
- package/dist/handoff.d.ts +3 -3
- package/dist/handoff.js +3 -3
- package/dist/hooks.d.ts +24 -1
- package/dist/hooks.js +78 -3
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +21 -11
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/{sdk-adapter-BE0Cmj7f.d.ts → sdk-adapter-B0i8J7N0.d.ts} +1 -1
- package/dist/session.d.ts +17 -1
- package/dist/session.js +15 -0
- package/dist/session.js.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/tools.d.ts +3 -3
- package/dist/tools.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-AZ2FOUSN.js.map +0 -1
- package/dist/chunk-CZIJFINK.js.map +0 -1
- package/dist/chunk-KXE52FP2.js.map +0 -1
- package/dist/chunk-NIQJ4GZX.js.map +0 -1
- /package/dist/{chunk-ZLKZOSWR.js.map → chunk-RXD6S6RV.js.map} +0 -0
- /package/dist/{chunk-K4MY4CV7.js.map → chunk-UARNAQ6O.js.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @theokit/agents
|
|
2
2
|
|
|
3
|
+
## 16.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 817296c: Add `defineAppBootstrap`, `assertBootstrapped` and `projectEnvStep` to `@theokit/agents/config`, so every entry of an agent app runs the same setup once, in order.
|
|
8
|
+
- 98829ee: `AgentClient.sendAndWait` resolves when its own turn settles, and `asGoalLoopAgent` adapts a client to the SDK `GoalLoopAgent` contract so `runGoalLoop` can drive a UI client without polling.
|
|
9
|
+
- e104596: `@theokit/agents/commands` adds `createCommandRegistry` and `CommandRegistryError`. Command definitions take `aliases`, `hidden` and `run`; `routeCommand` resolves aliases.
|
|
10
|
+
- 2da7cde: Add `listUserTurns` to `@theokit/agents/session`, listing the user turns `forkBeforeUserTurn` counts.
|
|
11
|
+
- b4526ae: `@theokit/agents/bridge` exports `loadMcpScopes`, which merges personal and project MCP servers with a trust gate for the project and a clash rule (personal wins by default).
|
|
12
|
+
- f5452e3: `@theokit/agents/hooks` exports `runHostHooks`, which runs the approved hooks of one event the host owns (such as session start) outside an agent loop, with the same trust and approval gate as `buildHookHandlers` and an explicit, required environment.
|
|
13
|
+
- 787c3c6: `@theokit/agents/config` adds `settingsCandidates`, `readSettingsFile` and `firstSettingsFile` to read `settings.json` under an own root and the `.claude` root, reporting `ignored` and `unrecognised` keys and unsupported permission entries. `CLAUDE_SETTINGS_KEYS` and `FOREIGN_KEY_DECISIONS` are exported.
|
|
14
|
+
- fd25499: `Shutdown.register` now returns a disposer, and `@theokit/agents/commands` exports `exitAfterDrain` for a normal exit that lets output drain. `createShutdown` takes `drain: true` to use it.
|
|
15
|
+
- aa5755c: `AgentBuilder.withholdBuiltinTools(names)` withholds SDK builtin tools (such as `shell`) on every run path, not only `toAgentFactory`. Unknown names are refused with a `ConfigurationError`; `withholdBuiltinShell` is unioned with it.
|
|
16
|
+
|
|
3
17
|
## 16.6.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -41,9 +41,9 @@ Twenty-three entry points. Import the one you need — the barrel is not the API
|
|
|
41
41
|
| `./interactive` | The interactive-shell backend contract |
|
|
42
42
|
| `./pty` | The node-pty implementation of that contract |
|
|
43
43
|
| `./auth` | Credential store, OAuth/device flow, `resolveCredential`, `assertSecureModes`, `RefreshFailure` |
|
|
44
|
-
| `./config` | Agent configuration, trust posture, and the instruction tree (`loadInstructionTree`) |
|
|
44
|
+
| `./config` | Agent configuration, trust posture, and the instruction tree (`loadInstructionTree`); `defineAppBootstrap` runs one setup from every entry |
|
|
45
45
|
| `./tools` | Built-in tool factories (read, list, grep, git, patch, edit, shell, …) |
|
|
46
|
-
| `./client` | Transports for driving an agent from a client |
|
|
46
|
+
| `./client` | Transports for driving an agent from a client. `AgentClient.sendAndWait(input)` resolves when that turn settles (`done`/`error`/`aborted`, never rejects), and `asGoalLoopAgent(client)` adapts a client to the SDK `GoalLoopAgent` so `runGoalLoop` can drive it without polling |
|
|
47
47
|
| `./client/react` | `useAgent` and the React bindings |
|
|
48
48
|
| `./session` | Session lifecycle, listing, fork/rewind, transcript GC with a retention floor |
|
|
49
49
|
| `./hooks` | The lifecycle-hook engine and its fingerprint gate |
|
|
@@ -51,14 +51,51 @@ Twenty-three entry points. Import the one you need — the barrel is not the API
|
|
|
51
51
|
| `./tool-scope` | `bindToolScope` — bind `{projectRoot, writeRoot, sandbox}` once so an unconfined shell is unrepresentable |
|
|
52
52
|
| `./a2a` | `createA2ATool` — call a remote agent over HTTP as a tool |
|
|
53
53
|
| `./mcp-health` | MCP server health probing |
|
|
54
|
-
| `./commands` | Command routing and the shutdown/cleanup contract |
|
|
54
|
+
| `./commands` | Command routing and the shutdown/cleanup contract. `Shutdown.register` returns a disposer (a no-op once `run()` started); `exitAfterDrain(code)` sets the exit code and forces the exit only if the loop has not drained within `capMs` |
|
|
55
55
|
| `./doctor` | Environment diagnostics |
|
|
56
56
|
| `./usage` | Token and cost accounting |
|
|
57
57
|
| `./evals` | `runAgentEvals` — run cases against an agent and read pass, fail or error per case |
|
|
58
58
|
| `./handoff` | `createHandoffConversation`: one agent hands the conversation to another, and the next turn is answered by the receiver |
|
|
59
59
|
|
|
60
|
+
A terminal command list, with aliases, hidden names and handlers, from `./commands`:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { createCommandRegistry, defineCommand } from '@theokit/agents/commands'
|
|
64
|
+
|
|
65
|
+
const registry = createCommandRegistry<{ exit(): void }>([
|
|
66
|
+
defineCommand({ name: 'quit', description: 'leave', aliases: ['exit'], arg: 'none', run: (_arg, ctx) => ctx.exit() }),
|
|
67
|
+
defineCommand({ name: 'debug', description: 'toggle debug', hidden: true }),
|
|
68
|
+
])
|
|
69
|
+
registry.palette() // [{ name: 'quit', description: 'leave' }]
|
|
70
|
+
await registry.dispatch('/exit', { exit: () => process.exit(0) })
|
|
71
|
+
```
|
|
72
|
+
|
|
60
73
|
`AuthProvider.ensureFresh` throws `RefreshFailure` (exported from `./auth`) when a token refresh fails. It is a `TheokitAgentError` with `code: 'oauth_refresh_failed'`, `isRetryable` equal to `.transient`, and the original error as `cause`, so the SDK's `isTransientError(err)` is `true` for a network reset and `false` for `invalid_grant`.
|
|
61
74
|
|
|
75
|
+
## One bootstrap for every entry
|
|
76
|
+
|
|
77
|
+
An app with several entries (CLI, ACP server) declares its setup once. Each step runs once, in order,
|
|
78
|
+
before anything resolves an SDK path; a failing step throws `BootstrapStepError` and later steps do not run.
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
// bootstrap.ts
|
|
82
|
+
import { defineAppBootstrap, projectEnvStep } from '@theokit/agents/config'
|
|
83
|
+
|
|
84
|
+
export const bootstrap = defineAppBootstrap([
|
|
85
|
+
projectEnvStep, // loads .env, refusing the SDK's sovereign keys
|
|
86
|
+
{ name: 'home', run: (ctx) => void (ctx.env.THEOKIT_HOME ??= ctx.home) },
|
|
87
|
+
])
|
|
88
|
+
|
|
89
|
+
// cli.ts and acp.ts both begin with the same call
|
|
90
|
+
import { homedir } from 'node:os'
|
|
91
|
+
import { bootstrap } from './bootstrap.js'
|
|
92
|
+
await bootstrap.run({ env: process.env, cwd: process.cwd(), home: homedir() })
|
|
93
|
+
|
|
94
|
+
// any module that resolves SDK paths
|
|
95
|
+
import { assertBootstrapped } from '@theokit/agents/config'
|
|
96
|
+
assertBootstrapped(bootstrap, 'openTranscriptStore')
|
|
97
|
+
```
|
|
98
|
+
|
|
62
99
|
## The shapes worth knowing before you start
|
|
63
100
|
|
|
64
101
|
**Tool scope is bound once, not per tool.** `bindToolScope({ projectRoot, writeRoot, sandbox })`
|
|
@@ -123,6 +160,25 @@ entry, that brings its own `transfer_to_agent` tool is refused with `reserved_to
|
|
|
123
160
|
`@theokit/sdk-handoff` and `createDelegateTool` work differently. They are call-and-return: the
|
|
124
161
|
agent you call answers the caller, and the caller keeps the turn.
|
|
125
162
|
|
|
163
|
+
## Withholding SDK builtin tools
|
|
164
|
+
|
|
165
|
+
`AgentBuilder.withholdBuiltinTools(['shell'])` keeps the named SDK builtin tools (`shell`,
|
|
166
|
+
`memory_search`, `memory_get`) out of the model's tool list, on every run path: `createSdkAgentStream`,
|
|
167
|
+
`streamAgentTurnInProcess`, the client's `InProcessTransport` and `toAgentFactory`. An unknown name is
|
|
168
|
+
refused with a `ConfigurationError`. `toAgentFactory({ withholdBuiltinShell: true })` still works;
|
|
169
|
+
when both are set, the union is passed.
|
|
170
|
+
|
|
171
|
+
## Hooks the host owns
|
|
172
|
+
|
|
173
|
+
`buildHookHandlers` wires hooks into one agent loop. Some events belong to the host instead:
|
|
174
|
+
`on_session_start` fires once per loop context, so an app that builds a fresh agent per turn would
|
|
175
|
+
run a session-start hook on every message. For those, call `runHostHooks(event, specs, options)` from
|
|
176
|
+
`@theokit/agents/hooks` at the moment the host starts the session. It applies the same trust and
|
|
177
|
+
fingerprint gate as `buildHookHandlers`, ignores specs of other events, and returns one
|
|
178
|
+
`HostHookOutcome` per spec (`ran`, `not-approved`, `failed`, `timed-out` or `could-not-start`)
|
|
179
|
+
without throwing. `options.env` is required and is the whole environment of the hook; `process.env`
|
|
180
|
+
is never inherited. Leave the event unwired in the loop handlers so it is not delivered twice.
|
|
181
|
+
|
|
126
182
|
## What changed recently
|
|
127
183
|
|
|
128
184
|
See [`CHANGELOG.md`](./CHANGELOG.md) — shipped inside this package, so `node_modules` answers the
|
|
@@ -188,6 +244,8 @@ gap worth declaring and one worth closing — so it was closed. `loadPersonalMcp
|
|
|
188
244
|
and only that key, and returns empty on a malformed file rather than throwing, because one stray comma
|
|
189
245
|
in a shared home file must not break every project on the machine.
|
|
190
246
|
|
|
247
|
+
**MCP scopes.** `loadMcpScopes({ cwd, home, projectAllowed, onClash?, personalFiles?, onWarn? })` (from `@theokit/agents/bridge`) merges the personal servers (`~/.claude.json` by default) with `<cwd>/.mcp.json`. When `projectAllowed` is false the project's servers are withheld: the file is parsed only to list its names in `projectWithheld`. On a name clash the personal server wins by default, so a repository cannot replace a server the operator configured; pass `onClash: 'project-wins'` for the reference format. Clashes are returned as data in `shadowed`. A malformed project file throws `McpFileError`; a malformed personal file only warns.
|
|
248
|
+
|
|
191
249
|
Both MCP readers are called by the host, not from inside this package — `loadMcpJson` has no internal
|
|
192
250
|
caller either, and a library with no `main()` cannot have one. That is why both rows say **read**: the
|
|
193
251
|
criterion is not who calls, it is whether the chain is intact. Nothing drops an MCP server.
|
|
@@ -233,6 +291,23 @@ A consumer that wants it passes it. Measured 2026-09-15 while auditing this tabl
|
|
|
233
291
|
was listed as `read`. The word describes the mechanism existing; a reader takes it as the behaviour
|
|
234
292
|
happening.
|
|
235
293
|
|
|
294
|
+
### Reading settings under two roots
|
|
295
|
+
|
|
296
|
+
An app with its own root (`.myapp/`) that also honours `.claude/` uses `settingsCandidates` (per scope,
|
|
297
|
+
own root before foreign root; `foreignRoot: false` reads only the own root) and `firstSettingsFile` /
|
|
298
|
+
`readSettingsFile`. The first existing file in a scope wins.
|
|
299
|
+
|
|
300
|
+
```ts
|
|
301
|
+
const c = settingsCandidates({ cwd, home, ownRoot: '.myapp' })
|
|
302
|
+
const read = firstSettingsFile(c.project, { ownKeys: ['model'], renames: { outputStyle: 'style' }, onWarn })
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
In an own-root file an unknown key stays in `values`, so your strict schema rejects it by name. In a
|
|
306
|
+
foreign-root file it is listed in `unrecognised`. A Claude Code key you do not implement, `$schema` and
|
|
307
|
+
`_`-prefixed keys go to `ignored`. `permissions` becomes `permissionRules`, and entries that cannot be
|
|
308
|
+
rendered are in `unsupportedPermissions`. `hooks` is returned raw. A file that exists but cannot be
|
|
309
|
+
parsed is reported through `onWarn` and yields `undefined`.
|
|
310
|
+
|
|
236
311
|
### `settings.json` — `env`
|
|
237
312
|
|
|
238
313
|
`outputStyle` is read AND applied: `loadSettings` returns it and `resolveOutputStyle` hands it to
|
|
@@ -390,3 +465,9 @@ Two consequences worth stating, because they are the cost:
|
|
|
390
465
|
## Licence
|
|
391
466
|
|
|
392
467
|
See `LICENSE`.
|
|
468
|
+
|
|
469
|
+
## Sessions
|
|
470
|
+
|
|
471
|
+
`@theokit/agents/session` forks a session before a user turn with `forkBeforeUserTurn(srcId, newId, nth, { cwd })`.
|
|
472
|
+
`listUserTurns(sessionId, { cwd })` lists the turns it can cut before as `{ nth, text }`. `nth` is 1-based and is
|
|
473
|
+
the number `forkBeforeUserTurn` takes, so a backtrack UI can show the list and fork at the chosen entry.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InlineSkill, CustomTool, MemorySettings, TelemetrySettings, SystemPromptResolver, SessionStore, PermissionGate, SkillsSettings, ContextSettings } from '@theokit/sdk';
|
|
1
|
+
import { InlineSkill, CustomTool, BuiltinToolName, MemorySettings, TelemetrySettings, SystemPromptResolver, SessionStore, PermissionGate, SkillsSettings, ContextSettings } from '@theokit/sdk';
|
|
2
2
|
import { AgentDefinition as AgentDefinition$1 } from '@theokit/sdk/subagents-loader';
|
|
3
3
|
import { TheokitAgentError } from '@theokit/sdk/errors';
|
|
4
4
|
import { R as ReasoningEffort, H as HumanInTheLoopOptions, a as McpServersMap, b as MemoryOptions, P as ProjectContextOptions, C as CheckpointOptions, T as ToolOptions, A as ApprovalOptions, B as BudgetOptions } from './types-D5cHmSLi.js';
|
|
@@ -359,6 +359,12 @@ interface DefineAgentConfig<TInput extends z.ZodType = z.ZodType> {
|
|
|
359
359
|
* rather than forwarded, because a gate that silently does not gate is worse than none.
|
|
360
360
|
*/
|
|
361
361
|
hookApproval?: HookApprovalGate;
|
|
362
|
+
/**
|
|
363
|
+
* #1912 — SDK builtin tools to withhold from the model (`Agent.create({ withheldBuiltinTools })`),
|
|
364
|
+
* so their schema is never declared, rather than refused at call time. Unknown names are refused
|
|
365
|
+
* at assembly with a `ConfigurationError`.
|
|
366
|
+
*/
|
|
367
|
+
withheldBuiltinTools?: readonly BuiltinToolName[];
|
|
362
368
|
/**
|
|
363
369
|
* B-054 — `MEMORY.md` here is NOT the Claude Code CLI's auto-memory file. This is the durable
|
|
364
370
|
* subsystem below: a SQLite+FTS5 store under `.theokit/memory/`, with `memory_search`/`memory_get`
|
|
@@ -555,6 +561,12 @@ interface CompiledAgentOptions {
|
|
|
555
561
|
* a foreign dialect imported through `compatSources` — is spawned at all.
|
|
556
562
|
*/
|
|
557
563
|
hookApproval?: HookApprovalGate;
|
|
564
|
+
/**
|
|
565
|
+
* #1912 — SDK builtin tools to withhold from the model (`Agent.create({ withheldBuiltinTools })`),
|
|
566
|
+
* so their schema is never declared, rather than refused at call time. Unknown names are refused
|
|
567
|
+
* at assembly with a `ConfigurationError`.
|
|
568
|
+
*/
|
|
569
|
+
withheldBuiltinTools?: readonly BuiltinToolName[];
|
|
558
570
|
/** Code `Plugin` objects forwarded to `Agent.create({ plugins })` (lifecycle-hook seam). */
|
|
559
571
|
/**
|
|
560
572
|
* Code plugins — `{ name, register }` objects registered with the SDK's lifecycle-hook seam.
|
|
@@ -298,6 +298,16 @@ interface AgentClientOptions {
|
|
|
298
298
|
*/
|
|
299
299
|
readonly chatId?: string;
|
|
300
300
|
}
|
|
301
|
+
/** How one turn ended, as `sendAndWait` reports it. */
|
|
302
|
+
interface TurnSettled {
|
|
303
|
+
readonly status: 'done' | 'error' | 'aborted';
|
|
304
|
+
/** Concatenated text parts of the turn's last assistant message. */
|
|
305
|
+
readonly text?: string;
|
|
306
|
+
readonly usage?: {
|
|
307
|
+
readonly totalTokens?: number;
|
|
308
|
+
};
|
|
309
|
+
readonly error?: Error;
|
|
310
|
+
}
|
|
301
311
|
declare class AgentClient<TInput = unknown> {
|
|
302
312
|
#private;
|
|
303
313
|
constructor(transport: AgentTransport, contextResolver?: () => RequestContext | undefined, options?: AgentClientOptions);
|
|
@@ -314,6 +324,11 @@ declare class AgentClient<TInput = unknown> {
|
|
|
314
324
|
getSnapshot: () => AgentClientState;
|
|
315
325
|
/** Send a typed input; opens a fresh stream (replaces prior messages). */
|
|
316
326
|
send: (input: TInput) => void;
|
|
327
|
+
/**
|
|
328
|
+
* Same as `send`, and resolves when THIS turn settles — from the same place `#drive` sets the final
|
|
329
|
+
* status, never from a timer. Never rejects; a superseded or aborted turn resolves `'aborted'`.
|
|
330
|
+
*/
|
|
331
|
+
sendAndWait: (input: TInput) => Promise<TurnSettled>;
|
|
317
332
|
/** Resume an interrupted stream via the transport's `reconnectToStream` (no-op when unavailable). */
|
|
318
333
|
reconnect: () => void;
|
|
319
334
|
/** Abort an in-flight stream (not an error — leaves messages as-is). */
|
|
@@ -369,4 +384,4 @@ declare function agentHandle<TInput = unknown, TToolNames extends string = strin
|
|
|
369
384
|
/** Narrow an unknown binding to an {@link AgentHandle} (has a string `path`, is not a transport). */
|
|
370
385
|
declare function isAgentHandle(value: unknown): value is AgentHandle;
|
|
371
386
|
|
|
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 };
|
|
387
|
+
export { type ApprovalDecision as A, type ChannelPushSource as C, type InProcessApprovalRequestLike as I, type PendingApproval as P, type RequestContext as R, type TurnSettled as T, 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 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginsSettings, ProviderRoutingSettings, AgentDefinition, BudgetTracker, CustomTool } from '@theokit/sdk';
|
|
2
2
|
import { RetryOptions } from '@theokit/sdk/retry';
|
|
3
|
-
import { a as CompiledAgentOptions, C as CompiledTool } from './agent-compiler-
|
|
3
|
+
import { a as CompiledAgentOptions, C as CompiledTool } from './agent-compiler-aubY9WIa.js';
|
|
4
4
|
import { TheokitAgentError } from '@theokit/sdk/errors';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { M as MainLoopMeta } from './types-D5cHmSLi.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition, BudgetTracker, CustomTool } from '@theokit/sdk';
|
|
2
2
|
import { RetryOptions } from '@theokit/sdk/retry';
|
|
3
|
-
import { C as CompiledTool, a as CompiledAgentOptions } from './agent-compiler-
|
|
3
|
+
import { C as CompiledTool, a as CompiledAgentOptions } from './agent-compiler-aubY9WIa.js';
|
|
4
4
|
import { S as StreamEvent } from './agent-sse-handler-BtIpJZxO.js';
|
|
5
|
-
import { R as RoundStreamFactory, L as LoopStrategy, b as ReflectionStrategy, D as DelegationResult } from './agent-orchestrator-
|
|
5
|
+
import { R as RoundStreamFactory, L as LoopStrategy, b as ReflectionStrategy, D as DelegationResult } from './agent-orchestrator-DQtfrPaq.js';
|
|
6
6
|
import { B as BudgetOptions, R as ReasoningEffort, M as MainLoopMeta } from './types-D5cHmSLi.js';
|
|
7
7
|
import { CompressibleMessage } from '@theokit/sdk/compaction';
|
|
8
8
|
import { z } from 'zod';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { ExecutionContext } from '@theokit/http';
|
|
2
2
|
import { c as AgentOptions, T as ToolOptions, P as ProjectContextOptions, R as ReasoningEffort, H as HumanInTheLoopOptions, a as McpServersMap } from './types-D5cHmSLi.js';
|
|
3
|
-
import { a as CompiledAgentOptions, G as Guardrail, k as SkillsSelection, p as SubagentAgentDefinition, H as HookApprovalGate, q as CodePlugin, A as AgentDefinition } from './agent-compiler-
|
|
4
|
-
import { SkillsSettings, ContextSettings, SystemPromptResolver, ModelSelection, InteractionUpdate, CustomTool, MemorySettings, TelemetrySettings, PermissionRule, Plugin } from '@theokit/sdk';
|
|
3
|
+
import { a as CompiledAgentOptions, G as Guardrail, k as SkillsSelection, p as SubagentAgentDefinition, H as HookApprovalGate, q as CodePlugin, A as AgentDefinition } from './agent-compiler-aubY9WIa.js';
|
|
4
|
+
import { SkillsSettings, ContextSettings, SystemPromptResolver, ModelSelection, InteractionUpdate, CustomTool, BuiltinToolName, MemorySettings, TelemetrySettings, PermissionRule, Plugin } from '@theokit/sdk';
|
|
5
5
|
import { S as StreamEvent, M as MaskError } from './agent-sse-handler-BtIpJZxO.js';
|
|
6
|
-
import { R as RuntimeOverrides, f as HitlWiring } from './sdk-adapter-
|
|
6
|
+
import { R as RuntimeOverrides, f as HitlWiring } from './sdk-adapter-B0i8J7N0.js';
|
|
7
7
|
import { SandboxPosture } from '@theokit/sdk/sandbox';
|
|
8
8
|
import { TheokitAgentError } from '@theokit/sdk/errors';
|
|
9
9
|
import { z } from 'zod';
|
|
10
10
|
import { H as HookHandlers } from './hook-handlers-Cw2FsnE5.js';
|
|
11
11
|
import { S as SettingSourcesSelection } from './setting-sources-gate-BJJiKq33.js';
|
|
12
12
|
import { WireChunk } from '@theokit/presenter/wire';
|
|
13
|
-
import './agent-orchestrator-
|
|
14
|
-
import './delegation-scoring-
|
|
13
|
+
import './agent-orchestrator-DQtfrPaq.js';
|
|
14
|
+
import './delegation-scoring-DPckVefy.js';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* AgentExecutionContext — extends http-decorators' ExecutionContext with agent-specific methods.
|
|
@@ -773,6 +773,13 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
|
|
|
773
773
|
* rather than forwarded: a gate that silently does not gate is worse than none.
|
|
774
774
|
*/
|
|
775
775
|
hookApproval(gate: HookApprovalGate): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
776
|
+
/**
|
|
777
|
+
* #1912 — withhold SDK builtin tools (e.g. `'shell'`) so the model never sees their schema.
|
|
778
|
+
* Projected to `Agent.create({ withheldBuiltinTools })` on every run path. A name the SDK does
|
|
779
|
+
* not know is refused with a `ConfigurationError` at assembly.
|
|
780
|
+
* Calling it again REPLACES the earlier list; it does not accumulate.
|
|
781
|
+
*/
|
|
782
|
+
withholdBuiltinTools(names: readonly BuiltinToolName[]): AgentBuilder<TInput, TModel, TContext, TTools>;
|
|
776
783
|
/**
|
|
777
784
|
* M49 — enable the SDK's durable memory for this agent (`.theokit/memory/` in the run cwd:
|
|
778
785
|
* `Remember:` capture with secret redaction, auto-injected recall, memory tools). Takes the SDK's
|
|
@@ -1394,6 +1401,42 @@ declare function loadMcpJson(cwd: string, opts?: LoadMcpJsonOptions): McpServers
|
|
|
1394
1401
|
*/
|
|
1395
1402
|
declare function loadPersonalMcpServers(home: string, opts?: LoadMcpJsonOptions): McpServersMap;
|
|
1396
1403
|
|
|
1404
|
+
interface McpScopesResult {
|
|
1405
|
+
readonly servers: McpServersMap;
|
|
1406
|
+
/** Names that came from personal files. */
|
|
1407
|
+
readonly personal: readonly string[];
|
|
1408
|
+
/** Project names dropped by the trust gate. */
|
|
1409
|
+
readonly projectWithheld: readonly string[];
|
|
1410
|
+
/** Names declared in both scopes, and which scope kept its server. */
|
|
1411
|
+
readonly shadowed: readonly {
|
|
1412
|
+
readonly name: string;
|
|
1413
|
+
readonly winner: 'personal' | 'project';
|
|
1414
|
+
}[];
|
|
1415
|
+
}
|
|
1416
|
+
/**
|
|
1417
|
+
* Merge the operator's own MCP servers with the project's `.mcp.json`.
|
|
1418
|
+
*
|
|
1419
|
+
* - `personalFiles` defaults to `['claude-json']` (`~/.claude.json`); any other string is a directory
|
|
1420
|
+
* holding a `.mcp.json`. When personal files repeat a name, the earlier one wins.
|
|
1421
|
+
* - A malformed PROJECT file throws `McpFileError`, because it is the project's own declaration. A
|
|
1422
|
+
* malformed PERSONAL file only warns, because one stray comma in a shared home file must not break
|
|
1423
|
+
* every project on the machine.
|
|
1424
|
+
* - When `projectAllowed` is false the project file is parsed only to list its names in
|
|
1425
|
+
* `projectWithheld`; none of its entries reach `servers`. (Names the operator policy already denies
|
|
1426
|
+
* are not listed, since the loader drops them while parsing.)
|
|
1427
|
+
* - `onClash` defaults to `'personal-wins'`: a repository must not be able to replace a server the
|
|
1428
|
+
* operator configured. `'project-wins'` matches the reference format.
|
|
1429
|
+
*/
|
|
1430
|
+
declare function loadMcpScopes(input: {
|
|
1431
|
+
readonly cwd: string;
|
|
1432
|
+
readonly home: string;
|
|
1433
|
+
/** `'claude-json'` reads `~/.claude.json`; any other string is a directory holding a `.mcp.json`. */
|
|
1434
|
+
readonly personalFiles?: readonly string[];
|
|
1435
|
+
readonly projectAllowed: boolean;
|
|
1436
|
+
readonly onClash?: 'personal-wins' | 'project-wins';
|
|
1437
|
+
readonly onWarn?: (message: string) => void;
|
|
1438
|
+
}): McpScopesResult;
|
|
1439
|
+
|
|
1397
1440
|
/**
|
|
1398
1441
|
* Agent manifest generator — build-time JSON describing all agents, tools, guards, policies.
|
|
1399
1442
|
*
|
|
@@ -1539,4 +1582,4 @@ declare function agentsPlugin(opts: AgentsPluginOptions): {
|
|
|
1539
1582
|
register(app: PluginApp): void;
|
|
1540
1583
|
};
|
|
1541
1584
|
|
|
1542
|
-
export {
|
|
1585
|
+
export { agentsPlugin as $, type AgentManifestEntry as A, type BeforeToolCallContext as B, type ContextWindowOptions as C, DelegationTimeoutError as D, type EphemeralAgent as E, type McpSelection as F, type OpenAIChatRequest as G, type OpenAICompatibleRoutesOptions as H, type OpenAICompletion as I, type OpenAITextPart as J, type ProcessInputContext as K, type LLMCallContext as L, MAX_REQUEST_BODY_BYTES as M, type SdkMessage as N, type OpenAIChatMessage as O, type PermissionsPluginOptions as P, type SdkTimelineEvent as Q, type Segment as R, type SkillsOptions as S, type ShouldAutoApproveOptions as T, type ToolArgsValidator as U, type ToolCallVeto as V, type ToolCallVetoPort as W, type ToolHooks as X, type ToolHooksPlugin as Y, type ToolInvokeRouteOptions as Z, WRITE_SCOPED_TOOLS as _, type AgentModule as a, buildModelSelection as a0, compileAgentModule as a1, compileContextWindow as a2, compileLoadedAgentModule as a3, compileProjectContext as a4, compileSkills as a5, createAgentExecutionContext as a6, createApiErrorHandler as a7, createOpenAICompatibleRoutes as a8, createPermissionsPlugin as a9, createThinkTagExtractor as aa, createToolHooksPlugin as ab, createToolInvokeRoute as ac, createToolSeen as ad, extractThinkTagStream as ae, flushPendingToolResults as af, generateAgentManifest as ag, generateAgentRoutes as ah, isAgentContext as ai, loadMcpJson as aj, loadMcpScopes as ak, loadPersonalMcpServers as al, mcpRegistry as am, mcpToolApprovals as an, projectContextMetadataOnlyKnobs as ao, readCappedBody as ap, reasoningEffortOf as aq, renderTranscript as ar, resolveMcpServers as as, runWithApiErrorHandling as at, shouldAutoApprove as au, translateInteractionUpdate as av, translateSdkEvent as aw, translateTimelineEvent as ax, withClockCap as ay, withEphemeralAgent as az, 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, BodyTooLargeError as r, streamAgentUIMessages as s, type CompiledContextWindow as t, ContextualTool as u, type McpApprovalSpec as v, McpFileError as w, type McpRegistryConfig as x, type McpRequestContext as y, type McpScopesResult as z };
|
package/dist/bridge.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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, a as AgentModule, j as AgentRoute, k as AgentRouteContext, l as AgentRunInfo, m as AgentsPluginOptions, n as ApiErrorContext, o as ApiErrorDecision, p as ApiErrorPolicy, q as ApprovalMode, B as BeforeToolCallContext, r as BodyTooLargeError, t as CompiledContextWindow, u as ContextualTool, D as DelegationTimeoutError, E as EphemeralAgent, L as LLMCallContext, M as MAX_REQUEST_BODY_BYTES, v as McpApprovalSpec, w as McpFileError, x as McpRegistryConfig, y as McpRequestContext, z as McpSelection, O as OpenAIChatMessage,
|
|
2
|
-
export { b as AGENT_BRAND, A as AgentDefinition, a as CompiledAgentOptions, C as CompiledTool, D as DefineAgentConfig, H as HookApprovalGate, i as HookApprovalRequest, I as InferAgentInput, j as InferAgentToolNames, T as ToolWalkResult, l as ToolboxWalkResult, m as compileAgentDefinition, n as compileTools, o as isAgentDefinition } from './agent-compiler-
|
|
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, a as AgentModule, j as AgentRoute, k as AgentRouteContext, l as AgentRunInfo, m as AgentsPluginOptions, n as ApiErrorContext, o as ApiErrorDecision, p as ApiErrorPolicy, q as ApprovalMode, B as BeforeToolCallContext, r as BodyTooLargeError, t as CompiledContextWindow, u as ContextualTool, D as DelegationTimeoutError, E as EphemeralAgent, L as LLMCallContext, M as MAX_REQUEST_BODY_BYTES, v as McpApprovalSpec, w as McpFileError, x as McpRegistryConfig, y as McpRequestContext, z as McpScopesResult, F as McpSelection, O as OpenAIChatMessage, G as OpenAIChatRequest, H as OpenAICompatibleRoutesOptions, I as OpenAICompletion, J as OpenAITextPart, P as PermissionsPluginOptions, K as ProcessInputContext, N as SdkMessage, Q as SdkTimelineEvent, R as Segment, T as ShouldAutoApproveOptions, U as ToolArgsValidator, V as ToolCallVeto, W as ToolCallVetoPort, X as ToolHooks, Y as ToolHooksPlugin, Z as ToolInvokeRouteOptions, _ as WRITE_SCOPED_TOOLS, $ as agentsPlugin, a0 as buildModelSelection, a1 as compileAgentModule, a2 as compileContextWindow, a3 as compileLoadedAgentModule, a4 as compileProjectContext, a5 as compileSkills, a6 as createAgentExecutionContext, a7 as createApiErrorHandler, a8 as createOpenAICompatibleRoutes, a9 as createPermissionsPlugin, aa as createThinkTagExtractor, ab as createToolHooksPlugin, ac as createToolInvokeRoute, ad as createToolSeen, ae as extractThinkTagStream, af as flushPendingToolResults, ag as generateAgentManifest, ah as generateAgentRoutes, ai as isAgentContext, aj as loadMcpJson, ak as loadMcpScopes, al as loadPersonalMcpServers, am as mcpRegistry, an as mcpToolApprovals, ao as projectContextMetadataOnlyKnobs, ap as readCappedBody, aq as reasoningEffortOf, ar as renderTranscript, as as resolveMcpServers, at as runWithApiErrorHandling, au as shouldAutoApprove, s as streamAgentUIMessages, av as translateInteractionUpdate, aw as translateSdkEvent, ax as translateTimelineEvent, ay as withClockCap, az as withEphemeralAgent } from './bridge-entry-nkeH6pAk.js';
|
|
2
|
+
export { b as AGENT_BRAND, A as AgentDefinition, a as CompiledAgentOptions, C as CompiledTool, D as DefineAgentConfig, H as HookApprovalGate, i as HookApprovalRequest, I as InferAgentInput, j as InferAgentToolNames, T as ToolWalkResult, l as ToolboxWalkResult, m as compileAgentDefinition, n as compileTools, o as isAgentDefinition } from './agent-compiler-aubY9WIa.js';
|
|
3
3
|
export { a as AgentStopReason, b as AgentStreamEvent, c as AgentTurnMetadata, A as ApprovalRequiredEvent, d as ArtifactChunkEvent, e as ArtifactStartEvent, C as CheckpointSavedEvent, D as DoneEvent, E as ERROR_CODE_DATA_PART, f as ErrorEvent, F as FileEditEvent, I as IterationEvent, P as PartialToolCallEvent, R as RunStartedEvent, g as StateUpdateEvent, S as StreamEvent, T as TextDeltaEvent, h as ThinkingEvent, i as ToolCallEvent, j as ToolResultEvent, k as isApprovalRequired, l as isDone, m as isError, n as isPartialToolCall, o as isTextDelta, p as isToolCall, q as isToolResult, r as presentUIMessageStream, s as streamAgentResponse } from './agent-sse-handler-BtIpJZxO.js';
|
|
4
|
-
export { A as ApprovalPosture, D as DefinitionOrThunk, S as SdkAgentHandle, b as SdkSendOptions, c as SdkTurnHandle, d as applyPosture, e as createSdkAgentStream, t as toAgentFactory } from './sdk-adapter-
|
|
5
|
-
export { B as BudgetExceededError, a as DelegateOptions, d as DelegationBudgetCostUnknownError, e as DelegationBudgetExceededError, f as DelegationError, D as DelegationResult, m as delegate } from './agent-orchestrator-
|
|
6
|
-
export { B as BackgroundDelegation, a as DelegateFn, b as DelegationPort, D as DelegationTarget, S as ScoreVerdict, c as ScoredDelegation, d as Scorer, e as delegateBackground, f as delegateWithScoring } from './delegation-scoring-
|
|
4
|
+
export { A as ApprovalPosture, D as DefinitionOrThunk, S as SdkAgentHandle, b as SdkSendOptions, c as SdkTurnHandle, d as applyPosture, e as createSdkAgentStream, t as toAgentFactory } from './sdk-adapter-B0i8J7N0.js';
|
|
5
|
+
export { B as BudgetExceededError, a as DelegateOptions, d as DelegationBudgetCostUnknownError, e as DelegationBudgetExceededError, f as DelegationError, D as DelegationResult, m as delegate } from './agent-orchestrator-DQtfrPaq.js';
|
|
6
|
+
export { B as BackgroundDelegation, a as DelegateFn, b as DelegationPort, D as DelegationTarget, S as ScoreVerdict, c as ScoredDelegation, d as Scorer, e as delegateBackground, f as delegateWithScoring } from './delegation-scoring-DPckVefy.js';
|
|
7
7
|
export { C as CompatSurface, a as GatedCompatSource, G as GatedSettingSource, P as ProjectSettingsGrant, R as ResolvedCompatSource, b as SettingSourceCapability, S as SettingSourcesSelection, U as UntrustedSettingSourceError, r as resolveCompatSources, c as resolveSettingSources } from './setting-sources-gate-BJJiKq33.js';
|
|
8
8
|
import '@theokit/http';
|
|
9
9
|
import './types-D5cHmSLi.js';
|
package/dist/bridge.js
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
isToolCall,
|
|
29
29
|
isToolResult,
|
|
30
30
|
loadMcpJson,
|
|
31
|
+
loadMcpScopes,
|
|
31
32
|
loadPersonalMcpServers,
|
|
32
33
|
mcpRegistry,
|
|
33
34
|
mcpToolApprovals,
|
|
@@ -38,7 +39,7 @@ import {
|
|
|
38
39
|
runWithApiErrorHandling,
|
|
39
40
|
streamAgentResponse,
|
|
40
41
|
streamAgentUIMessages
|
|
41
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-XGW7IZP6.js";
|
|
42
43
|
import {
|
|
43
44
|
DelegationTimeoutError,
|
|
44
45
|
delegate,
|
|
@@ -46,14 +47,14 @@ import {
|
|
|
46
47
|
delegateWithScoring,
|
|
47
48
|
withClockCap,
|
|
48
49
|
withEphemeralAgent
|
|
49
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-UARNAQ6O.js";
|
|
50
51
|
import "./chunk-MJ6FRILJ.js";
|
|
51
52
|
import {
|
|
52
53
|
BudgetExceededError,
|
|
53
54
|
DelegationBudgetCostUnknownError,
|
|
54
55
|
DelegationBudgetExceededError,
|
|
55
56
|
DelegationError
|
|
56
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-RXD6S6RV.js";
|
|
57
58
|
import {
|
|
58
59
|
APPROVAL_MODES,
|
|
59
60
|
WRITE_SCOPED_TOOLS,
|
|
@@ -73,7 +74,7 @@ import {
|
|
|
73
74
|
translateInteractionUpdate,
|
|
74
75
|
translateSdkEvent,
|
|
75
76
|
translateTimelineEvent
|
|
76
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-W533YIGA.js";
|
|
77
78
|
import "./chunk-M5J3Q6YC.js";
|
|
78
79
|
import "./chunk-Q65ZIFNK.js";
|
|
79
80
|
import {
|
|
@@ -83,7 +84,7 @@ import {
|
|
|
83
84
|
isAgentDefinition,
|
|
84
85
|
resolveCompatSources,
|
|
85
86
|
resolveSettingSources
|
|
86
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-JJ6Y6EBP.js";
|
|
87
88
|
import "./chunk-2SP5BB6U.js";
|
|
88
89
|
import "./chunk-OXNDJSAJ.js";
|
|
89
90
|
import "./chunk-Z4QWC7IK.js";
|
|
@@ -140,6 +141,7 @@ export {
|
|
|
140
141
|
isToolCall,
|
|
141
142
|
isToolResult,
|
|
142
143
|
loadMcpJson,
|
|
144
|
+
loadMcpScopes,
|
|
143
145
|
loadPersonalMcpServers,
|
|
144
146
|
mcpRegistry,
|
|
145
147
|
mcpToolApprovals,
|
|
@@ -403,6 +403,8 @@ var AgentClient = class {
|
|
|
403
403
|
static {
|
|
404
404
|
__name(this, "AgentClient");
|
|
405
405
|
}
|
|
406
|
+
/** The in-flight `sendAndWait` turn: settled from where `#drive` sets the final status. */
|
|
407
|
+
#waiter;
|
|
406
408
|
#transport;
|
|
407
409
|
#chatId;
|
|
408
410
|
#listeners = /* @__PURE__ */ new Set();
|
|
@@ -523,6 +525,31 @@ var AgentClient = class {
|
|
|
523
525
|
else next.push(message);
|
|
524
526
|
this.#messages = next;
|
|
525
527
|
}
|
|
528
|
+
/** Resolve the pending `sendAndWait` waiter (if any) for `controller`; never rejects. */
|
|
529
|
+
#settle(controller, status) {
|
|
530
|
+
const waiter = this.#waiter;
|
|
531
|
+
if (waiter?.controller !== controller) return;
|
|
532
|
+
this.#waiter = void 0;
|
|
533
|
+
const last = [
|
|
534
|
+
...this.#messages
|
|
535
|
+
].reverse().find((m) => m.role === "assistant");
|
|
536
|
+
const text = last?.parts.map((part) => part.type === "text" && "text" in part ? String(part.text) : "").join("");
|
|
537
|
+
const totalTokens = last?.metadata?.usage?.totalTokens;
|
|
538
|
+
waiter.resolve({
|
|
539
|
+
status,
|
|
540
|
+
...text === void 0 ? {} : {
|
|
541
|
+
text
|
|
542
|
+
},
|
|
543
|
+
...typeof totalTokens === "number" ? {
|
|
544
|
+
usage: {
|
|
545
|
+
totalTokens
|
|
546
|
+
}
|
|
547
|
+
} : {},
|
|
548
|
+
...status === "error" && this.#error ? {
|
|
549
|
+
error: this.#error
|
|
550
|
+
} : {}
|
|
551
|
+
});
|
|
552
|
+
}
|
|
526
553
|
async #drive(open, controller) {
|
|
527
554
|
const aborted = /* @__PURE__ */ __name(() => controller.signal.aborted, "aborted");
|
|
528
555
|
try {
|
|
@@ -531,6 +558,7 @@ var AgentClient = class {
|
|
|
531
558
|
if (stream === null) {
|
|
532
559
|
this.#status = this.#messages.length > 0 ? "done" : "idle";
|
|
533
560
|
this.#emit();
|
|
561
|
+
this.#settle(controller, "done");
|
|
534
562
|
return;
|
|
535
563
|
}
|
|
536
564
|
const outcome = await consumeChunkStream(stream, (message) => {
|
|
@@ -547,15 +575,18 @@ var AgentClient = class {
|
|
|
547
575
|
this.#error = new AgentStreamInterruptedError(outcome.chunksReceived);
|
|
548
576
|
this.#status = "error";
|
|
549
577
|
this.#emit();
|
|
578
|
+
this.#settle(controller, "error");
|
|
550
579
|
return;
|
|
551
580
|
}
|
|
552
581
|
this.#status = "done";
|
|
553
582
|
this.#emit();
|
|
583
|
+
this.#settle(controller, "done");
|
|
554
584
|
} catch (err) {
|
|
555
585
|
if (aborted()) return;
|
|
556
586
|
this.#error = err instanceof Error ? err : new Error(String(err));
|
|
557
587
|
this.#status = "error";
|
|
558
588
|
this.#emit();
|
|
589
|
+
this.#settle(controller, "error");
|
|
559
590
|
}
|
|
560
591
|
}
|
|
561
592
|
/** Send a typed input; opens a fresh stream (replaces prior messages). */
|
|
@@ -595,8 +626,27 @@ var AgentClient = class {
|
|
|
595
626
|
metadata: context?.metadata
|
|
596
627
|
}), controller);
|
|
597
628
|
}, "send");
|
|
629
|
+
/**
|
|
630
|
+
* Same as `send`, and resolves when THIS turn settles — from the same place `#drive` sets the final
|
|
631
|
+
* status, never from a timer. Never rejects; a superseded or aborted turn resolves `'aborted'`.
|
|
632
|
+
*/
|
|
633
|
+
sendAndWait = /* @__PURE__ */ __name((input) => {
|
|
634
|
+
const promise = new Promise((resolve) => {
|
|
635
|
+
this.send(input);
|
|
636
|
+
const controller = this.#controller;
|
|
637
|
+
if (controller === null) resolve({
|
|
638
|
+
status: "aborted"
|
|
639
|
+
});
|
|
640
|
+
else this.#waiter = {
|
|
641
|
+
controller,
|
|
642
|
+
resolve
|
|
643
|
+
};
|
|
644
|
+
});
|
|
645
|
+
return promise;
|
|
646
|
+
}, "sendAndWait");
|
|
598
647
|
/** Resume an interrupted stream via the transport's `reconnectToStream` (no-op when unavailable). */
|
|
599
648
|
reconnect = /* @__PURE__ */ __name(() => {
|
|
649
|
+
this.#abortWaiter();
|
|
600
650
|
const controller = new AbortController();
|
|
601
651
|
this.#controller = controller;
|
|
602
652
|
if (!this.#currentAssistantId) this.#currentAssistantId = crypto.randomUUID();
|
|
@@ -610,8 +660,16 @@ var AgentClient = class {
|
|
|
610
660
|
metadata: context?.metadata
|
|
611
661
|
}), controller);
|
|
612
662
|
}, "reconnect");
|
|
663
|
+
#abortWaiter() {
|
|
664
|
+
const waiter = this.#waiter;
|
|
665
|
+
this.#waiter = void 0;
|
|
666
|
+
waiter?.resolve({
|
|
667
|
+
status: "aborted"
|
|
668
|
+
});
|
|
669
|
+
}
|
|
613
670
|
/** Abort an in-flight stream (not an error — leaves messages as-is). */
|
|
614
671
|
abort = /* @__PURE__ */ __name(() => {
|
|
672
|
+
this.#abortWaiter();
|
|
615
673
|
this.#controller?.abort();
|
|
616
674
|
this.#controller = null;
|
|
617
675
|
if (this.#status === "streaming") {
|
|
@@ -673,4 +731,4 @@ export {
|
|
|
673
731
|
agentHandle,
|
|
674
732
|
isAgentHandle
|
|
675
733
|
};
|
|
676
|
-
//# sourceMappingURL=chunk-
|
|
734
|
+
//# sourceMappingURL=chunk-4DOKIDGC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client/http-transport.ts","../src/client/last-user-text.ts","../src/client/in-process-transport.ts","../src/client/channel-transport.ts","../src/client/agent-client.ts","../src/client/agent-handle.ts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AgB;AACrC,SAAK,KAAK,OACR,MACE,KAAK,WAAWW,kBAAkB;MAChCpD,QAAQ,KAAK;MACb+C,SAASN,SAASM;MAClBxB,UAAUkB,SAASlB;IACrB,CAAA,GACFT,UAAAA;EAEJ,GArBY;EAuBZ,eAAY;AACV,UAAMC,SAAS,KAAK;AACpB,SAAK,UAAUtC;AACfsC,YAAQU,QAAQ;MAAEhC,QAAQ;IAAU,CAAA;EACtC;;EAGA6C,QAAQ,6BAAA;AACN,SAAK,aAAY;AACjB,SAAK,aAAaA,MAAAA;AAClB,SAAK,cAAc;AAKnB,QAAI,KAAK,YAAY,aAAa;AAChC,WAAK,UAAU,KAAK,WAAWR,SAAS,KAAK,KAAK,UAAUA,SAAS,IAAI,SAAS;AAClF,WAAK,MAAK;IACZ;EACF,GAZQ;;EAeRuB,QAAQ,6BAAA;AACN,SAAKf,MAAK;AACV,SAAK,YAAY,CAAA;AAEjB,SAAK,aAAa,CAAA;AAGlB,SAAK,mBAAmB,KAAK;AAC7B,SAAK,eAAe7D;AACpB,SAAK,SAASA;AACd,SAAK,UAAU;AACf,SAAK,MAAK;EACZ,GAZQ;;;;;;;;;;EAuBR6E,UAAU,8BAAOhF,YAAoBiF,aAAAA;AACnC,UAAM,KAAK,WAAWD,UAAUhF,YAAYiF,QAAAA;EAC9C,GAFU;AAGZ;;;ACthBO,SAASC,YACdC,MAAY;AAEZ,SAAO;IACLA;IACAC,WAAW,wBAACC,QAAQ,IAAIC,mBAAmB;MAAED;IAAI,CAAA,GAAtC;IACXE,SAAS,wBAACC,WAAW,IAAIC,iBAAiB;MAAED;IAAO,CAAA,GAA1C;EACX;AACF;AARgBN;AAWT,SAASQ,cAAcC,OAAc;AAC1C,SACE,OAAOA,UAAU,YACjBA,UAAU,QACV,OAAQA,MAA6BR,SAAS,YAC9C,OAAQQ,MAAqCC,iBAAiB;AAElE;AAPgBF;","names":["inMemoryRunIdStore","runId","get","set","next","toRecord","headers","undefined","Headers","Object","fromEntries","entries","HttpTransport","options","api","fetch","globalThis","bind","runIdStore","sendMessages","messages","abortSignal","body","chatId","extra","response","method","agentRequestHeaders","AGENT_ACTION_HEADERS","JSON","stringify","id","signal","ok","Error","status","statusText","responseToChunkStream","reconnectToStream","approve","approvalId","decision","extractLastUserText","messages","i","length","message","role","text","parts","filter","part","type","map","join","TheokitAgentError","generatorToStream","gen","ReadableStream","pull","controller","result","next","done","close","enqueue","value","err","error","cancel","return","undefined","ApprovalAbortedError","TheokitAgentError","name","approvalId","reason","code","isRetryable","InProcessTransport","Map","options","run","turn","signal","req","Promise","resolve","reject","aborted","has","Error","set","id","entry","delete","pending","size","sendMessages","messages","abortSignal","metadata","currentTurn","addEventListener","once","generator","message","extractLastUserText","awaitApproval","context","reconnectToStream","approve","decision","get","ChannelTransport","options","source","sendMessages","messages","abortSignal","metadata","message","extractLastUserText","closed","teardown","undefined","detachAbort","stream","ReadableStream","start","controller","finish","settle","context","onLine","line","parsed","JSON","parse","type","enqueue","onClose","close","onError","err","error","onAbort","aborted","addEventListener","removeEventListener","cancel","Promise","resolve","reconnectToStream","approve","approvalId","decision","Error","TheokitAgentError","AgentStreamInterruptedError","TheokitAgentError","name","chunksReceived","String","isRetryable","code","NO_PENDING_APPROVALS","derivePendingApprovals","messages","pending","message","part","parts","state","approval","id","push","approvalId","toolCallId","toolName","undefined","input","question","timeoutMs","inputToText","JSON","stringify","buildUserMessage","crypto","randomUUID","role","type","text","AgentClient","Set","thread","status","error","pendingApprovals","transport","contextResolver","options","emitIntervalMs","chatId","subscribe","listener","add","delete","getSnapshot","clearTimeout","tail","concat","setTimeout","next","idx","findIndex","existing","controller","waiter","last","reverse","find","m","map","join","totalTokens","metadata","usage","resolve","open","aborted","signal","stream","length","outcome","consumeChunkStream","stamped","terminated","err","Error","send","abort","AbortController","userMsg","context","sendMessages","trigger","messageId","abortSignal","body","headers","sendAndWait","promise","Promise","reconnect","reconnectToStream","reset","approve","decision","agentHandle","path","inProcess","run","InProcessTransport","channel","source","ChannelTransport","isAgentHandle","value","sendMessages"]}
|
|
@@ -186,6 +186,9 @@ function compileAgentDefinition(def) {
|
|
|
186
186
|
...def.hookApproval !== void 0 ? {
|
|
187
187
|
hookApproval: def.hookApproval
|
|
188
188
|
} : {},
|
|
189
|
+
...def.withheldBuiltinTools !== void 0 ? {
|
|
190
|
+
withheldBuiltinTools: def.withheldBuiltinTools
|
|
191
|
+
} : {},
|
|
189
192
|
// M49 — memory flows to the projection layer; `assembleM8CreateOptions` forwards it to Agent.create.
|
|
190
193
|
...def.memory !== void 0 ? {
|
|
191
194
|
memory: def.memory
|
|
@@ -282,4 +285,4 @@ export {
|
|
|
282
285
|
compileAgentDefinition,
|
|
283
286
|
compileSkillsSelection
|
|
284
287
|
};
|
|
285
|
-
//# sourceMappingURL=chunk-
|
|
288
|
+
//# sourceMappingURL=chunk-JJ6Y6EBP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bridge/setting-sources-gate.ts","../src/bridge/define-agent.ts"],"mappings":";;;;;;;;AACA,SAASA,yBAAyB;AA+MlC,IAAMC,gBAA0C;EAC9C;EACA;EACA;EACA;EACA;EACA;;AAGF,IAAMC,iBAAiB,6BAAYC,QAAZ;AAehB,IAAMC,8BAAN,cAA0CC,kBAAAA;EAvOjD,OAuOiDA;;;;;EAC7BC,OAAO;EAEzB,YACEC,SAESC,aAEAC,YACT;AACA,UAAMF,OAAAA,GAAAA,KAJGC,cAAAA,aAAAA,KAEAC,aAAAA;EAGX;AACF;AAmGO,SAASC,sBACdC,WAA8C;AAE9C,MAAIA,cAAcR,OAAW,QAAO,CAAA;AAIpC,QAAMS,UAAgC,CAAA;AACtC,QAAMC,QAAQ,wBAACC,SAA4CA,MAA7C;AACd,MAAIH,UAAUI,SAAS,KAAMH,SAAQI,KAAKH,MAAM,MAAA,CAAA;AAEhD,QAAMI,QAAQN,UAAUO;AACxB,MAAID,UAAUd,QAAW;AACvB,UAAMgB,UAAUF,MAAMG;AACtB,QAAI,C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C9C;WAAIL;QAAWQ,KAAK,IAAA,KAAS,QAAA,GAAW;IAEjE;AACAL,UAAMM,IAAIJ,UAAUC,OAAAA;EACtB;AACA,SAAOH;AACT;AAbSrC;","names":["TheokitAgentError","EVERY_SURFACE","IGNORE_WARNING","undefined","UntrustedSettingSourceError","TheokitAgentError","name","message","trustSource","capability","resolveSettingSources","selection","sources","gated","root","user","push","grant","project","posture","trustedBy","allows","projectSettings","level","source","pluginsGrant","plugins","resolveCompatSources","onWarn","claudeCode","surfaces","import","length","currentOperatorPolicy","disableAllHooks","kept","filter","surface","kind","AGENT_BRAND","Symbol","for","defineAgent","config","assertValidMaxIterations","maxIterations","value","undefined","Number","isInteger","Error","String","isAgentDefinition","toCompiledTool","tool","handler","compiled","name","description","inputSchema","input","ctx","sym","Object","getOwnPropertySymbols","compileAgentDefinition","def","model","reasoningEffort","systemPrompt","system","tools","map","agents","stream","context","runContext","guardrails","approvals","hitl","compileApprovals","compileSkillsSelection","skills","subagents","settingSources","resolveSettingSources","claudeCode","compatSources","resolveCompatSources","hookApproval","withheldBuiltinTools","memory","telemetry","compileHooksAndPlugins","mcpServers","hooks","entries","filter","h","explicit","plugins","length","plugin","version","kind","register","hookName","on","skillsResolver","enabled","inline","entry","push","autoInject","toolNames","Set","t","gates","Map","toolName","options","has","join","set"]}
|