@theokit/agents 13.0.0-next.8 → 13.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 +1707 -0
- package/README.md +31 -0
- package/dist/{agent-compiler-C2jIZ4CZ.d.ts → agent-compiler-B0hb6HCo.d.ts} +182 -26
- package/dist/ask.d.ts +1 -0
- package/dist/auth.d.ts +148 -1
- package/dist/auth.js +36 -0
- package/dist/auth.js.map +1 -1
- package/dist/{bridge-entry-BJ86tO6e.d.ts → bridge-entry-DBkqwe6b.d.ts} +72 -6
- package/dist/bridge.d.ts +6 -4
- package/dist/bridge.js +9 -4
- package/dist/{chunk-3GQJ2BHT.js → chunk-G7QBDGZ4.js} +93 -18
- package/dist/chunk-G7QBDGZ4.js.map +1 -0
- package/dist/chunk-HGVT4VCE.js +97 -0
- package/dist/chunk-HGVT4VCE.js.map +1 -0
- package/dist/{chunk-NZTLBLHB.js → chunk-KTQID5V3.js} +560 -342
- package/dist/chunk-KTQID5V3.js.map +1 -0
- package/dist/chunk-M5J3Q6YC.js +17 -0
- package/dist/chunk-M5J3Q6YC.js.map +1 -0
- package/dist/{chunk-RKWCXVYG.js → chunk-MJ6FRILJ.js} +67 -5
- package/dist/chunk-MJ6FRILJ.js.map +1 -0
- package/dist/{chunk-X4IGZHOV.js → chunk-PMMOOXR6.js} +43 -8
- package/dist/chunk-PMMOOXR6.js.map +1 -0
- package/dist/chunk-U72XTMYB.js +7 -0
- package/dist/chunk-U72XTMYB.js.map +1 -0
- package/dist/client-react.d.ts +1 -0
- package/dist/client.d.ts +1 -0
- package/dist/config.d.ts +163 -36
- package/dist/config.js +119 -7
- package/dist/config.js.map +1 -1
- package/dist/{define-agent-WYnUlWaH.d.ts → define-agent-DhwNmdej.d.ts} +28 -153
- package/dist/{delegation-scoring-BrBQXvIp.d.ts → delegation-scoring-BzJEheml.d.ts} +1 -1
- package/dist/hooks.d.ts +0 -32
- package/dist/hooks.js +42 -14
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +191 -17
- package/dist/index.js +43 -5
- package/dist/index.js.map +1 -1
- package/dist/sandbox.js.map +1 -1
- package/dist/setting-sources-gate-DFu51i50.d.ts +278 -0
- package/dist/testing.d.ts +5 -2
- package/dist/testing.js +1 -1
- package/dist/tools.d.ts +4 -2
- package/dist/tools.js +22 -4
- package/dist/tools.js.map +1 -1
- package/dist/usage.d.ts +30 -0
- package/dist/usage.js +3 -0
- package/dist/usage.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-3GQJ2BHT.js.map +0 -1
- package/dist/chunk-NZTLBLHB.js.map +0 -1
- package/dist/chunk-RKWCXVYG.js.map +0 -1
- package/dist/chunk-X4IGZHOV.js.map +0 -1
|
@@ -1,157 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CustomTool, MemorySettings, TelemetrySettings } from '@theokit/sdk';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { G as Guardrail, S as SkillsSelection, H as HookApprovalGate, C as CompiledAgentOptions } from './agent-compiler-
|
|
3
|
+
import { G as Guardrail, S as SkillsSelection, H as HookApprovalGate, C as CodePlugin, a as CompiledAgentOptions } from './agent-compiler-B0hb6HCo.js';
|
|
4
4
|
import { R as ReasoningEffort, H as HumanInTheLoopOptions, M as McpServersMap } from './types-C16Wuh9E.js';
|
|
5
5
|
import { H as HookHandlers } from './hook-handlers-Cw2FsnE5.js';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* M68 — the trust gate for `settingSources`.
|
|
10
|
-
*
|
|
11
|
-
* ## The defect this module closes
|
|
12
|
-
*
|
|
13
|
-
* `settingSources` enables on-disk config discovery. `'user'` reads `~/.theokit/` — the operator's
|
|
14
|
-
* own machine, which no third party controls. `'project'` reads `<cwd>/.theokit/`, **including
|
|
15
|
-
* `hooks.json`, which executes shell**.
|
|
16
|
-
*
|
|
17
|
-
* The previous API took `readonly SettingSource[]`, and its JSDoc justified the risk this way:
|
|
18
|
-
* *"it is opt-in because `.theokit/` is the app's own repo (informed consent)"*. That premise holds
|
|
19
|
-
* for a web app whose `cwd` is its own deploy. It does **not** hold for the class of product this
|
|
20
|
-
* framework addresses — an agent whose `cwd` is a repository the user just cloned. There `.theokit/`
|
|
21
|
-
* is attacker-controlled content, and enabling `'project'` is remote code execution on the first
|
|
22
|
-
* `build()`.
|
|
23
|
-
*
|
|
24
|
-
* Documenting it did not prevent it. The measured consumer (TheoCode) did not trust the API: it
|
|
25
|
-
* gated from the outside, with a `posture.allows` of its own (`chat.ts:386`, comment B-008). It
|
|
26
|
-
* already **had** the right decision and could not pass it through, because the API only accepted
|
|
27
|
-
* strings. The gate existed on its side and evaporated at the boundary.
|
|
28
|
-
*
|
|
29
|
-
* ## The evidence is the SDK's, not one invented here
|
|
30
|
-
*
|
|
31
|
-
* `TrustPosture` is `@theokit/sdk`'s own trust primitive, and `recordWiring`'s doc says *"a posture
|
|
32
|
-
* is the only thing in this package that retains a capability"*. A bespoke type would make two trust
|
|
33
|
-
* grammars coexist and drift apart (ADR 0063).
|
|
34
|
-
*/
|
|
35
|
-
/**
|
|
36
|
-
* The framework's capability vocabulary — deliberately a single name (ADR 0065).
|
|
37
|
-
*
|
|
38
|
-
* `allows` is all-or-nothing in the SDK: every declared `K` gets the same boolean. A finer
|
|
39
|
-
* vocabulary (`hooks`, `skills`, `subagents`, `mcp`) would promise the consumer it can gate one
|
|
40
|
-
* without gating the other, and the primitive does not deliver that. An API that suggests a
|
|
41
|
-
* distinction the runtime does not make teaches the wrong thing, and the error only surfaces when
|
|
42
|
-
* somebody depends on the distinction.
|
|
43
|
-
*/
|
|
44
|
-
type SettingSourceCapability = 'projectSettings';
|
|
45
|
-
/** Authorization to read config from the working directory. Requires the posture, never a claim. */
|
|
46
|
-
interface ProjectSettingsGrant {
|
|
47
|
-
/**
|
|
48
|
-
* Typically the output of `resolveTrustPosture` — which is what gives it `source` (`'env' |
|
|
49
|
-
* 'store' | 'default'`) and therefore a refusal that says WHERE the decision came from instead of
|
|
50
|
-
* merely denying.
|
|
51
|
-
*/
|
|
52
|
-
readonly trustedBy: TrustPosture<SettingSourceCapability>;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Which on-disk config roots the agent may read.
|
|
56
|
-
*
|
|
57
|
-
* The asymmetry is the design: `user` is a boolean because `~/.theokit/` belongs to the operator;
|
|
58
|
-
* `project` requires evidence because `<cwd>/.theokit/` may not. Omitting a root is not enabling it
|
|
59
|
-
* — never "enabling without a gate". The asymmetry is inherited from the SDK itself, whose
|
|
60
|
-
* `TrustPostureInput.envOverride` documents that `false` and `undefined` both mean "the operator did
|
|
61
|
-
* not turn it on", not "turned it off".
|
|
62
|
-
*/
|
|
63
|
-
interface SettingSourcesSelection {
|
|
64
|
-
/** `~/.theokit/` — the operator's machine. No gate: no third party controls it. */
|
|
65
|
-
readonly user?: boolean;
|
|
66
|
-
/** `<cwd>/.theokit/` — controlled by whoever wrote the open repository. Requires evidence. */
|
|
67
|
-
readonly project?: ProjectSettingsGrant;
|
|
68
|
-
/**
|
|
69
|
-
* `<cwd>/.claude/` — a FOREIGN configuration dialect, read only once declared
|
|
70
|
-
* (`usetheokit/theokit-sdk#524`).
|
|
71
|
-
*
|
|
72
|
-
* ## Two questions, and which half of this field answers each
|
|
73
|
-
*
|
|
74
|
-
* The SDK's docblock separates them, and the separation is the whole point of `compatSources`:
|
|
75
|
-
* a trust gate answers *"do I trust the code in this directory?"*; importing another product's
|
|
76
|
-
* configuration answers *"do I want it imported into this one?"*. They come apart in the ordinary
|
|
77
|
-
* case, because `.claude/` is populated in exactly the repository one trusts most — for a
|
|
78
|
-
* different tool, by a teammate who never heard of this runtime.
|
|
79
|
-
*
|
|
80
|
-
* So the two are answered by two different things here, and it matters which:
|
|
81
|
-
*
|
|
82
|
-
* | Question | Answered by |
|
|
83
|
-
* |---|---|
|
|
84
|
-
* | do I want the foreign dialect imported? | **declaring this field at all** — omitting is not enabling |
|
|
85
|
-
* | do I trust this directory's code to run? | the `TrustPosture` inside the grant |
|
|
86
|
-
*
|
|
87
|
-
* ## Why the grant is `ProjectSettingsGrant` and not a vocabulary of its own
|
|
88
|
-
*
|
|
89
|
-
* Not because the two questions are the same — they are not. Because a separate grant could not
|
|
90
|
-
* carry the distinction even if it existed: `TrustPosture.allows` is `Record<K, boolean>` and the
|
|
91
|
-
* SDK documents every value as moving together with the level, so a `'foreignDialects'` capability
|
|
92
|
-
* beside `'projectSettings'` would promise an operator they can grant one and withhold the other,
|
|
93
|
-
* and `resolveTrustPosture` would hand back the same boolean for both. That is precisely the
|
|
94
|
-
* failure ADR 0065 exists to prevent, and inventing the second name would commit it while looking
|
|
95
|
-
* like rigour.
|
|
96
|
-
*
|
|
97
|
-
* The consent half is therefore carried by the declaration, which is a real and sufficient
|
|
98
|
-
* boundary: an operator who trusts a repository completely still reads no `.claude/` until they
|
|
99
|
-
* write this field. What the grant adds on top is stricter than the SDK — there, listing a dialect
|
|
100
|
-
* is enough — and the extra strictness is deliberate: this reads a `hooks.json` that executes
|
|
101
|
-
* shell out of a directory that usually arrived with the clone.
|
|
102
|
-
*/
|
|
103
|
-
readonly claudeCode?: ProjectSettingsGrant;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Refusal to read the working directory for lack of trust.
|
|
107
|
-
*
|
|
108
|
-
* Descends from `TheokitAgentError` because typed errors are an unbreakable rule here — and because
|
|
109
|
-
* `isTransientError` only sees this hierarchy. A class extending plain `Error` would be invisible to
|
|
110
|
-
* the predicate that separates recoverable from unrecoverable (the defect M67 fixed in five
|
|
111
|
-
* classes).
|
|
112
|
-
*/
|
|
113
|
-
declare class UntrustedSettingSourceError extends TheokitAgentError {
|
|
114
|
-
/** Where the trust decision came from: `'env' | 'store' | 'default'`. */
|
|
115
|
-
readonly trustSource: string;
|
|
116
|
-
/** The refused capability. */
|
|
117
|
-
readonly capability: SettingSourceCapability;
|
|
118
|
-
readonly name = "UntrustedSettingSourceError";
|
|
119
|
-
constructor(message: string,
|
|
120
|
-
/** Where the trust decision came from: `'env' | 'store' | 'default'`. */
|
|
121
|
-
trustSource: string,
|
|
122
|
-
/** The refused capability. */
|
|
123
|
-
capability: SettingSourceCapability);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Translate the declared selection into the `SettingSource`s the SDK accepts, refusing what the
|
|
127
|
-
* posture does not authorize.
|
|
128
|
-
*
|
|
129
|
-
* Refuses rather than ignores (ADR 0064). Ignoring would leave the product running in the belief
|
|
130
|
-
* that the repository's hooks are active — a silent failure mode, on the wrong side. The SDK already
|
|
131
|
-
* picked that side for the same problem: `recordWiring` throws `UngatedCapabilityError` when
|
|
132
|
-
* somebody registers a capability the posture does not gate.
|
|
133
|
-
*
|
|
134
|
-
* @throws {UntrustedSettingSourceError} when `project` is requested and the posture does not grant it.
|
|
135
|
-
*/
|
|
136
|
-
declare function resolveSettingSources(selection: SettingSourcesSelection | undefined): readonly SettingSource[];
|
|
137
|
-
/**
|
|
138
|
-
* The foreign configuration dialects this layer forwards, once the posture authorises them.
|
|
139
|
-
*
|
|
140
|
-
* ## Why it is a separate function and the same vocabulary
|
|
141
|
-
*
|
|
142
|
-
* Separate because the SDK takes them on a separate option (`local.compatSources`); the same
|
|
143
|
-
* `ProjectSettingsGrant` because the thing being authorised is identical — reading a `hooks.json`
|
|
144
|
-
* that executes shell out of a directory the operator does not necessarily control.
|
|
145
|
-
*
|
|
146
|
-
* ## What it deliberately does NOT do
|
|
147
|
-
*
|
|
148
|
-
* Validate the source NAME. The SDK DROPS an unrecognised name rather than turning it into
|
|
149
|
-
* `<cwd>/<name>`, so a typo fails closed there; turning that into a throw here would convert a safe
|
|
150
|
-
* default into a crash. This gate decides authorisation, never vocabulary.
|
|
151
|
-
*
|
|
152
|
-
* @throws {UntrustedSettingSourceError} when a source is requested and the posture does not grant it.
|
|
153
|
-
*/
|
|
154
|
-
declare function resolveCompatSources(selection: SettingSourcesSelection | undefined): readonly string[];
|
|
6
|
+
import { S as SettingSourcesSelection } from './setting-sources-gate-DFu51i50.js';
|
|
155
7
|
|
|
156
8
|
/**
|
|
157
9
|
* M2 (theokit-ai-first) — `defineAgent`, the zero-config imperative agent surface.
|
|
@@ -257,17 +109,40 @@ interface DefineAgentConfig<TInput extends z.ZodType = z.ZodType> {
|
|
|
257
109
|
*/
|
|
258
110
|
hookApproval?: HookApprovalGate;
|
|
259
111
|
/**
|
|
112
|
+
* B-054 — `MEMORY.md` here is NOT the Claude Code CLI's auto-memory file. This is the durable
|
|
113
|
+
* subsystem below: a SQLite+FTS5 store under `.theokit/memory/`, with `memory_search`/`memory_get`
|
|
114
|
+
* tools and no index cap. The CLI's lives under its own home (`CLAUDE_CONFIG_DIR` or `~/.claude`),
|
|
115
|
+
* is capped at 200 lines / 25 KB on read, and is swept on `cleanupPeriodDays` — none of which is
|
|
116
|
+
* implemented here. The SDK READS that directory for interop and does not write to it.
|
|
117
|
+
*
|
|
118
|
+
* Same filename, different directory, different semantics. Stated at both ends because a checklist
|
|
119
|
+
* that greps for `MEMORY.md` finds one and concludes the other exists.
|
|
120
|
+
*
|
|
260
121
|
* M49 — durable memory (the SDK's `.theokit/memory/` subsystem: `Remember:` capture, MEMORY.md
|
|
261
122
|
* store, auto-injected `<memory>` block, `memory_search`/`memory_get` tools). The shape is the
|
|
262
123
|
* SDK's own `MemorySettings` — the canonical runtime contract. Projected into
|
|
263
124
|
* `Agent.create({ memory })` by `assembleM8CreateOptions`.
|
|
264
125
|
*/
|
|
265
126
|
memory?: MemorySettings;
|
|
127
|
+
/**
|
|
128
|
+
* B-072 — OpenTelemetry for this agent. Forwarded verbatim to `Agent.create({ telemetry })`,
|
|
129
|
+
* where the SDK emits spans for `agent.send`, `llm.call`, `tool.call` and `memory.search`.
|
|
130
|
+
*
|
|
131
|
+
* `{ enabled: true }` is the minimal opt-in. `@opentelemetry/api` is an OPTIONAL peer of the SDK:
|
|
132
|
+
* without it the whole thing is a silent no-op, which is the usual reason a run reports no spans.
|
|
133
|
+
*/
|
|
134
|
+
telemetry?: TelemetrySettings;
|
|
266
135
|
/**
|
|
267
136
|
* Code `Plugin` objects forwarded to `Agent.create({ plugins })` — EXTENSION units (tools,
|
|
268
137
|
* commands, model providers, memory adapters). For lifecycle interception use {@link hooks}.
|
|
269
138
|
*/
|
|
270
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Code plugins — `{ name, register }`. NOT the Claude Code filesystem-bundle form, which is
|
|
141
|
+
* declared by living in a `plugins/` directory rather than by being passed here (B-055).
|
|
142
|
+
*
|
|
143
|
+
* `readonly unknown[]` is what let the wrong shape through silently.
|
|
144
|
+
*/
|
|
145
|
+
plugins?: readonly CodePlugin[];
|
|
271
146
|
/**
|
|
272
147
|
* Lifecycle hooks keyed by `HookName` (`pre_tool_call` may veto via `{ block, message }`). Set by
|
|
273
148
|
* the builder's `hooks()`; converted into a code plugin at `build()` and never reaching the SDK
|
|
@@ -310,4 +185,4 @@ declare function isAgentDefinition(value: unknown): value is AgentDefinition;
|
|
|
310
185
|
*/
|
|
311
186
|
declare function compileAgentDefinition(def: AgentDefinition): CompiledAgentOptions;
|
|
312
187
|
|
|
313
|
-
export { type AgentDefinition as A, type DefineAgentConfig as D, type InferAgentInput as I,
|
|
188
|
+
export { type AgentDefinition as A, type DefineAgentConfig as D, type InferAgentInput as I, AGENT_BRAND as a, type InferAgentToolNames as b, compileAgentDefinition as c, isAgentDefinition as i };
|
|
@@ -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 {
|
|
3
|
+
import { a as CompiledAgentOptions, b as CompiledTool } from './agent-compiler-B0hb6HCo.js';
|
|
4
4
|
import { TheokitAgentError } from '@theokit/sdk/errors';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { b as MainLoopMeta } from './types-C16Wuh9E.js';
|
package/dist/hooks.d.ts
CHANGED
|
@@ -264,38 +264,6 @@ interface HookRunResult {
|
|
|
264
264
|
*/
|
|
265
265
|
declare function runHookCommand(input: HookRunInput): Promise<HookRunResult>;
|
|
266
266
|
|
|
267
|
-
/**
|
|
268
|
-
* Hook inheritance for a delegated member — the authority a sub-agent runs under.
|
|
269
|
-
*
|
|
270
|
-
* ## Why this exists
|
|
271
|
-
*
|
|
272
|
-
* `delegate()` already merges the parent's TOOLS and clamps the parent's BUDGET into the member's
|
|
273
|
-
* run. It did not carry the parent's HOOKS, so a member could call a tool the parent's
|
|
274
|
-
* `pre_tool_call` gate had refused. The failure is silent and green: nothing throws, nothing warns,
|
|
275
|
-
* and the member's own suite passes because the member never declared the gate.
|
|
276
|
-
*
|
|
277
|
-
* The only real consumer of this layer found it and closed it with sixteen lines of its own. Sixteen
|
|
278
|
-
* lines standing between a squad and the parent's veto is not a consumer's job — it is authority
|
|
279
|
-
* inheritance, and a consumer who does not know the rule exists has the hole and no way to see it.
|
|
280
|
-
*
|
|
281
|
-
* ## The composition rule: inheritance may only TIGHTEN
|
|
282
|
-
*
|
|
283
|
-
* A Chain of Responsibility over the two handler maps, with one asymmetry that carries the whole
|
|
284
|
-
* security property: for `pre_tool_call`, BOTH gates run and the FIRST refusal wins. A member cannot
|
|
285
|
-
* widen what the parent refused — if it could, the parent's gate would be decorative.
|
|
286
|
-
*
|
|
287
|
-
* A free function rather than a class: there is no state to hold and no second implementation to
|
|
288
|
-
* swap. Wrapping a pure fold in a class would be the ceremony parsimony refuses (`parsimony-ladder`
|
|
289
|
-
* rung 5), and this module's whole surface is one composition.
|
|
290
|
-
*
|
|
291
|
-
* ## Failure posture
|
|
292
|
-
*
|
|
293
|
-
* A gate that throws REFUSES. An inherited gate that opens on its own error is worse than no gate,
|
|
294
|
-
* because it reads as protection — `error-handling.md § 2` forbids that swallow. Observers
|
|
295
|
-
* (`post_tool_call`, session lifecycle) are fire-and-forget by contract, so a broken notifier is
|
|
296
|
-
* isolated and never becomes the reason a turn failed.
|
|
297
|
-
*/
|
|
298
|
-
|
|
299
267
|
/** The code-plugin envelope the SDK dispatches hooks through. */
|
|
300
268
|
interface CodePlugin {
|
|
301
269
|
readonly name: string;
|
package/dist/hooks.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
hooksPlugin,
|
|
7
7
|
inheritHooks
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-MJ6FRILJ.js";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
11
11
|
} from "./chunk-Z4QWC7IK.js";
|
|
@@ -113,6 +113,28 @@ function killGroup(pid) {
|
|
|
113
113
|
}
|
|
114
114
|
__name(killGroup, "killGroup");
|
|
115
115
|
|
|
116
|
+
// src/hooks/unwired-events.ts
|
|
117
|
+
var UNWIRED_EVENT_REASONS = Object.freeze({
|
|
118
|
+
transform_llm_output: Object.freeze({
|
|
119
|
+
seam: "Guardrail.checkOutput",
|
|
120
|
+
reason: "returning action 'redact' replaces the model's text and continues"
|
|
121
|
+
}),
|
|
122
|
+
pre_user_send: Object.freeze({
|
|
123
|
+
seam: "createToolHooksPlugin({ processInput })",
|
|
124
|
+
reason: "contributes text before the model, additively"
|
|
125
|
+
}),
|
|
126
|
+
on_session_end: Object.freeze({
|
|
127
|
+
seam: null,
|
|
128
|
+
reason: "no seam delivers this: the handler returns void and cannot refuse an ending"
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
function unwiredEventAdvice(event, reasons = UNWIRED_EVENT_REASONS) {
|
|
132
|
+
const entry = reasons[event];
|
|
133
|
+
if (entry === void 0) return "the handler does not exist yet.";
|
|
134
|
+
return entry.seam === null ? `${entry.reason}.` : `use ${entry.seam} instead: ${entry.reason}.`;
|
|
135
|
+
}
|
|
136
|
+
__name(unwiredEventAdvice, "unwiredEventAdvice");
|
|
137
|
+
|
|
116
138
|
// src/hooks/hook-spec.ts
|
|
117
139
|
var HOOK_EVENTS = [
|
|
118
140
|
"pre_tool_call",
|
|
@@ -157,13 +179,14 @@ function parseHookSpecs(input) {
|
|
|
157
179
|
}
|
|
158
180
|
__name(parseHookSpecs, "parseHookSpecs");
|
|
159
181
|
var IGNORE_WARNING = /* @__PURE__ */ __name(() => void 0, "IGNORE_WARNING");
|
|
160
|
-
var
|
|
182
|
+
var WIRED_EVENT_LIST = [
|
|
161
183
|
"pre_tool_call",
|
|
162
184
|
"post_tool_call",
|
|
163
185
|
"transform_tool_result",
|
|
164
186
|
"on_session_start",
|
|
165
187
|
"post_assistant_reply"
|
|
166
|
-
]
|
|
188
|
+
];
|
|
189
|
+
var WIRED_EVENTS = new Set(WIRED_EVENT_LIST);
|
|
167
190
|
function buildHookHandlers(specs, options) {
|
|
168
191
|
const warn = options.onWarn ?? IGNORE_WARNING;
|
|
169
192
|
if (!options.trusted) {
|
|
@@ -183,9 +206,7 @@ function buildHookHandlers(specs, options) {
|
|
|
183
206
|
if (runnable.length === 0) return {};
|
|
184
207
|
for (const spec of runnable) {
|
|
185
208
|
if (!WIRED_EVENTS.has(spec.event)) {
|
|
186
|
-
warn(`hook declared on "${spec.event}" will NOT fire
|
|
187
|
-
...WIRED_EVENTS
|
|
188
|
-
].join(" and ")} only. The event is accepted by the schema and the approval is real \u2014 the handler does not exist yet.`);
|
|
209
|
+
warn(`hook declared on "${spec.event}" will NOT fire \u2014 ${unwiredEventAdvice(spec.event)}`);
|
|
189
210
|
}
|
|
190
211
|
}
|
|
191
212
|
const handlers = {};
|
|
@@ -272,13 +293,7 @@ function buildHookHandlers(specs, options) {
|
|
|
272
293
|
if (transformHooks.length > 0) {
|
|
273
294
|
handlers.transform_tool_result = buildTransformHandler(transformHooks, options, warn, chainBudgetMs);
|
|
274
295
|
}
|
|
275
|
-
|
|
276
|
-
const list = runnable.filter((spec) => spec.event === event);
|
|
277
|
-
if (list.length === 0) continue;
|
|
278
|
-
const fire = buildObservationalHandler(event, list, options, warn, chainBudgetMs);
|
|
279
|
-
if (event === "on_session_start") handlers.on_session_start = fire;
|
|
280
|
-
else handlers.post_assistant_reply = fire;
|
|
281
|
-
}
|
|
296
|
+
assignObservationalHandlers(handlers, OBSERVATIONAL_EVENTS, (event, list) => buildObservationalHandler(event, list, options, warn, chainBudgetMs), runnable);
|
|
282
297
|
return handlers;
|
|
283
298
|
}
|
|
284
299
|
__name(buildHookHandlers, "buildHookHandlers");
|
|
@@ -295,8 +310,13 @@ function identityOf(spec) {
|
|
|
295
310
|
__name(identityOf, "identityOf");
|
|
296
311
|
function matches(spec, toolName) {
|
|
297
312
|
if (spec.matcher === void 0) return true;
|
|
313
|
+
const trimmed = spec.matcher.trim();
|
|
314
|
+
if (trimmed === "" || trimmed === "*") return true;
|
|
315
|
+
if (trimmed.includes(",")) {
|
|
316
|
+
return trimmed.split(",").map((name) => name.trim()).filter((name) => name !== "").includes(toolName);
|
|
317
|
+
}
|
|
298
318
|
try {
|
|
299
|
-
return new RegExp(
|
|
319
|
+
return new RegExp(trimmed).test(toolName);
|
|
300
320
|
} catch {
|
|
301
321
|
return false;
|
|
302
322
|
}
|
|
@@ -366,6 +386,14 @@ ${fenceHookOutput(feedback)}`;
|
|
|
366
386
|
};
|
|
367
387
|
}
|
|
368
388
|
__name(buildTransformHandler, "buildTransformHandler");
|
|
389
|
+
function assignObservationalHandlers(handlers, events, make, specs = []) {
|
|
390
|
+
for (const event of events) {
|
|
391
|
+
const list = specs.filter((spec) => spec.event === event);
|
|
392
|
+
if (list.length === 0) continue;
|
|
393
|
+
handlers[event] = make(event, list);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
__name(assignObservationalHandlers, "assignObservationalHandlers");
|
|
369
397
|
function buildObservationalHandler(event, list, options, warn, chainBudgetMs) {
|
|
370
398
|
return async () => {
|
|
371
399
|
const started = Date.now();
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/hook-spec.ts","../src/hooks/hook-fingerprint.ts","../src/hooks/hook-run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MC,SAAkBC,KAAKC,MAAMH,GAAAA;AACnC,UAAI,CAACI,MAAMC,QAAQJ,MAAAA,EAAS,OAAM,IAAIK,MAAM,uCAAA;AAC5C,aAAOL;IACT,GACA,CAAA,CAAE;AAEJ,SAAKlC,gBAAgB+B;AAErB,SAAK,WAAW,IAAIS,IAAIV,MAAMnB,IAAI,CAACD,MAAM;MAAC,GAAGA,EAAEL,KAAK,KAASK,EAAEE,WAAW;MAAIF;KAAE,CAAA;AAChF,WAAO,KAAK;EACd;EAEA,SAASY,SAAoC;AAC3CmB,oBAAgB,KAAK1C,MAAM,MAAM,GAAGoC,KAAKO,UAAU;SAAIpB,QAAQd,OAAM;OAAK,MAAM,CAAA,CAAA;CAAM;EACxF;AACF;","names":["randomBytes","TheokitAgentError","z","createHash","FIELD_SEPARATOR","hookFingerprint","identity","canonical","command","event","matcher","String","timeoutMs","join","createHash","update","digest","spawn","MAX_OUTPUT_BYTES","DRAIN_BUDGET_MS","CHAIN_BUDGET_MULTIPLIER","runHookCommand","input","Promise","resolve","child","spawn","command","cwd","shell","detached","env","stdio","stdout","stderr","truncated","timedOut","settled","capture","current","chunk","length","next","toString","slice","on","settle","exitCode","clearTimeout","timer","drainTimer","setTimeout","killGroup","pid","timeoutMs","undefined","code","stdin","end","process","kill","HOOK_EVENTS","DEFAULT_HOOK_TIMEOUT_MS","DEFAULT_CONTINUATION_BUDGET","hookSpecSchema","z","object","event","enum","command","string","min","refine","value","test","message","matcher","optional","timeout_ms","number","int","positive","default","strict","HookSpecError","TheokitAgentError","name","code","isRetryable","parseHookSpecs","input","parsed","array","safeParse","success","error","issues","map","issue","path","join","data","IGNORE_WARNING","undefined","WIRED_EVENTS","Set","buildHookHandlers","specs","options","warn","onWarn","trusted","length","String","fingerprintOf","fingerprint","hookFingerprint","runnable","filter","spec","approved","has","identityOf","handlers","chainBudgetMs","Math","max","CHAIN_BUDGET_MULTIPLIER","preHooks","pre_tool_call","ctx","started","Date","now","onVeto","tool","reason","block","matches","result","runHookCommand","cwd","timeoutMs","stdin","JSON","stringify","args","env","exitCode","fenceHookOutput","stdout","stderr","postHooks","post_tool_call","truncated","transformHooks","transform_tool_result","buildTransformHandler","OBSERVATIONAL_EVENTS","list","fire","buildObservationalHandler","on_session_start","post_assistant_reply","toolName","RegExp","output","nonce","randomBytes","toString","open","close","escaped","replaceAll","remaining","continuationBudget","results","out","targets","toolCalls","call","feedback","trim","realpathSync","join","resolve","slotOf","identity","event","matcher","canonicalScope","dir","realpathSync","resolve","HookApprovalStore","path","lastReadError","options","join","home","approvedFingerprints","scope","key","Set","values","filter","r","map","fingerprint","approvals","stateOf","inScope","some","hookFingerprint","slot","record","command","approve","records","set","undefined","approvedAt","Date","toISOString","revoke","delete","value","error","readSecureJson","raw","parsed","JSON","parse","Array","isArray","Error","Map","writeSecureJson","stringify"]}
|
|
1
|
+
{"version":3,"sources":["../src/hooks/hook-spec.ts","../src/hooks/hook-fingerprint.ts","../src/hooks/hook-runner.ts","../src/hooks/unwired-events.ts","../src/hooks/approval-store.ts"],"mappings":";;;;;;;;;;;;;AAAA,SAASA,mBAAmB;AAG5B,SAASC,yBAAyB;AAClC,SAASC,SAAS;;;ACJlB,SAASC,kBAAkB;AAsC3B,IAAMC,kBAAkB;AASjB,SAASC,gBAAgBC,UAAsB;AACpD,QAAMC,YAAY;IAChBD,SAASE;IACTF,SAASG;IACTH,SAASI,WAAW;IACpBC,OAAOL,SAASM,SAAS;IACzBC,KAAKT,eAAAA;AACP,SAAOU,WAAW,QAAA,EAAUC,OAAOR,WAAW,MAAA,EAAQS,OAAO,KAAA;AAC/D;AARgBX;;;AC/ChB,SAASY,aAAa;AA+Bf,IAAMC,mBAAmB;AAQzB,IAAMC,kBAAkB;AAGxB,IAAMC,0BAA0B;AAgCvC,eAAsBC,eAAeC,OAAmB;AACtD,SAAO,IAAIC,QAAuB,CAACC,aAAAA;AAcjC,UAAMC,QAAQC,MAAMJ,MAAMK,SAAS;MACjCC,KAAKN,MAAMM;MACXC,OA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AAAA,CAAAA,EAAW,GAAG;AAChF,WAAK,SAAS+B,OAAAA;IAChB;EACF;;;;;;;EAQA,QAAK;AACH,UAAM,EAAEQ,OAAOC,MAAK,IAAKC,eACvB,KAAKjC,MACL,CAACkC,QAAAA;AACC,YAAMC,SAAkBC,KAAKC,MAAMH,GAAAA;AACnC,UAAI,CAACI,MAAMC,QAAQJ,MAAAA,EAAS,OAAM,IAAIK,MAAM,uCAAA;AAC5C,aAAOL;IACT,GACA,CAAA,CAAE;AAEJ,SAAKlC,gBAAgB+B;AAErB,SAAK,WAAW,IAAIS,IAAIV,MAAMnB,IAAI,CAACD,MAAM;MAAC,GAAGA,EAAEL,KAAK,KAASK,EAAEE,WAAW;MAAIF;KAAE,CAAA;AAChF,WAAO,KAAK;EACd;EAEA,SAASY,SAAoC;AAC3CmB,oBAAgB,KAAK1C,MAAM,MAAM,GAAGoC,KAAKO,UAAU;SAAIpB,QAAQd,OAAM;OAAK,MAAM,CAAA,CAAA;CAAM;EACxF;AACF;","names":["randomBytes","TheokitAgentError","z","createHash","FIELD_SEPARATOR","hookFingerprint","identity","canonical","command","event","matcher","String","timeoutMs","join","createHash","update","digest","spawn","MAX_OUTPUT_BYTES","DRAIN_BUDGET_MS","CHAIN_BUDGET_MULTIPLIER","runHookCommand","input","Promise","resolve","child","spawn","command","cwd","shell","detached","env","stdio","stdout","stderr","truncated","timedOut","settled","capture","current","chunk","length","next","toString","slice","on","settle","exitCode","clearTimeout","timer","drainTimer","setTimeout","killGroup","pid","timeoutMs","undefined","code","stdin","end","process","kill","UNWIRED_EVENT_REASONS","Object","freeze","transform_llm_output","seam","reason","pre_user_send","on_session_end","unwiredEventAdvice","event","reasons","entry","undefined","HOOK_EVENTS","DEFAULT_HOOK_TIMEOUT_MS","DEFAULT_CONTINUATION_BUDGET","hookSpecSchema","z","object","event","enum","command","string","min","refine","value","test","message","matcher","optional","timeout_ms","number","int","positive","default","strict","HookSpecError","TheokitAgentError","name","code","isRetryable","parseHookSpecs","input","parsed","array","safeParse","success","error","issues","map","issue","path","join","data","IGNORE_WARNING","undefined","WIRED_EVENT_LIST","WIRED_EVENTS","Set","buildHookHandlers","specs","options","warn","onWarn","trusted","length","String","fingerprintOf","fingerprint","hookFingerprint","runnable","filter","spec","approved","has","identityOf","unwiredEventAdvice","handlers","chainBudgetMs","Math","max","CHAIN_BUDGET_MULTIPLIER","preHooks","pre_tool_call","ctx","started","Date","now","onVeto","tool","reason","block","matches","result","runHookCommand","cwd","timeoutMs","stdin","JSON","stringify","args","env","exitCode","fenceHookOutput","stdout","stderr","postHooks","post_tool_call","truncated","transformHooks","transform_tool_result","buildTransformHandler","assignObservationalHandlers","OBSERVATIONAL_EVENTS","list","buildObservationalHandler","toolName","trimmed","trim","includes","split","RegExp","fenceHookOutput","output","nonce","randomBytes","toString","open","close","escaped","replaceAll","OBSERVATIONAL_EVENTS","buildTransformHandler","transformHooks","options","warn","chainBudgetMs","remaining","continuationBudget","DEFAULT_CONTINUATION_BUDGET","results","ctx","out","started","Date","now","spec","targets","matcher","undefined","toolCalls","length","filter","call","matches","name","result","runHookCommand","command","cwd","timeoutMs","timeout_ms","stdin","JSON","stringify","tool","args","env","exitCode","feedback","stdout","trim","String","assignObservationalHandlers","handlers","events","make","specs","event","list","buildObservationalHandler","realpathSync","join","resolve","slotOf","identity","event","matcher","canonicalScope","dir","realpathSync","resolve","HookApprovalStore","path","lastReadError","options","join","home","approvedFingerprints","scope","key","Set","values","filter","r","map","fingerprint","approvals","stateOf","inScope","some","hookFingerprint","slot","record","command","approve","records","set","undefined","approvedAt","Date","toISOString","revoke","delete","value","error","readSecureJson","raw","parsed","JSON","parse","Array","isArray","Error","Map","writeSecureJson","stringify"]}
|