@robota-sdk/agent-core 3.0.0-beta.79 → 3.0.0-beta.81

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +667 -0
  2. package/README.md +24 -4
  3. package/dist/browser/bounded-output-DpjpS98g.js +2 -0
  4. package/dist/browser/bounded-output-DpjpS98g.js.map +1 -0
  5. package/dist/browser/command-executor-cI7XJ374.js +2 -0
  6. package/dist/browser/command-executor-cI7XJ374.js.map +1 -0
  7. package/dist/browser/http-executor-CHy6UeBU.js +2 -0
  8. package/dist/browser/http-executor-CHy6UeBU.js.map +1 -0
  9. package/dist/browser/index.d.ts +3337 -1499
  10. package/dist/browser/index.d.ts.map +1 -1
  11. package/dist/browser/index.js +11 -11
  12. package/dist/browser/index.js.map +1 -1
  13. package/dist/browser/verdict-decoder-Dk_w2NG9.js +2 -0
  14. package/dist/browser/verdict-decoder-Dk_w2NG9.js.map +1 -0
  15. package/dist/node/bounded-output-DpjpS98g.js +2 -0
  16. package/dist/node/bounded-output-DpjpS98g.js.map +1 -0
  17. package/dist/node/command-executor-Aat_q7P2.cjs +1 -0
  18. package/dist/node/command-executor-DV-H2oD6.js +2 -0
  19. package/dist/node/command-executor-DV-H2oD6.js.map +1 -0
  20. package/dist/node/http-executor-71JiIdFP.cjs +1 -0
  21. package/dist/node/http-executor-cWzI2svn.js +2 -0
  22. package/dist/node/http-executor-cWzI2svn.js.map +1 -0
  23. package/dist/node/{index-BKIUt9pk.d.ts → index-CiFlpr7-.d.cts} +3289 -1783
  24. package/dist/node/index-CiFlpr7-.d.cts.map +1 -0
  25. package/dist/node/index-DFlMw376.d.ts +6893 -0
  26. package/dist/node/index-DFlMw376.d.ts.map +1 -0
  27. package/dist/node/index.cjs +11 -11
  28. package/dist/node/index.d.cts +3 -0
  29. package/dist/node/index.d.ts +3 -2
  30. package/dist/node/index.js +11 -11
  31. package/dist/node/index.js.map +1 -1
  32. package/dist/node/node.cjs +1 -0
  33. package/dist/node/node.d.cts +236 -0
  34. package/dist/node/node.d.cts.map +1 -0
  35. package/dist/node/node.d.ts +236 -0
  36. package/dist/node/node.d.ts.map +1 -0
  37. package/dist/node/node.js +2 -0
  38. package/dist/node/node.js.map +1 -0
  39. package/dist/node/project-tool-schema-DrDjGKnH.cjs +1 -0
  40. package/dist/node/project-tool-schema-_UKfY7yO.js +2 -0
  41. package/dist/node/project-tool-schema-_UKfY7yO.js.map +1 -0
  42. package/dist/node/rolldown-runtime-DK3Fl9T5.js +1 -0
  43. package/dist/node/rolldown-runtime-DWNI8pZO.cjs +1 -0
  44. package/dist/node/testing/index.cjs +1 -1
  45. package/dist/node/testing/index.d.cts +96 -0
  46. package/dist/node/testing/index.d.cts.map +1 -0
  47. package/dist/node/testing/index.d.ts +35 -4
  48. package/dist/node/testing/index.d.ts.map +1 -1
  49. package/dist/node/testing/index.js +1 -1
  50. package/dist/node/testing/index.js.map +1 -1
  51. package/dist/node/types-gNrckgFE.d.cts +335 -0
  52. package/dist/node/types-gNrckgFE.d.cts.map +1 -0
  53. package/dist/node/types-gNrckgFE.d.ts +335 -0
  54. package/dist/node/types-gNrckgFE.d.ts.map +1 -0
  55. package/dist/node/verdict-decoder-Dk_w2NG9.js +2 -0
  56. package/dist/node/verdict-decoder-Dk_w2NG9.js.map +1 -0
  57. package/dist/node/verdict-decoder-Estx9MtY.cjs +1 -0
  58. package/package.json +75 -24
  59. package/dist/node/index-BKIUt9pk.d.ts.map +0 -1
@@ -0,0 +1,335 @@
1
+ //#region src/interfaces/universal-value.d.ts
2
+ /**
3
+ * Universal value type axis (recursive, JSON-like + Date).
4
+ *
5
+ * Extracted from `types.ts` into its own leaf module: several foundational modules (e.g.
6
+ * `provider.ts`) need only this axis, not the rest of `types.ts` (which itself depends on
7
+ * plugin-execution types) — importing the whole barrel there created a module-level import
8
+ * cycle. `types.ts` re-exports these names, so existing `from './types'` imports are unaffected.
9
+ *
10
+ * IMPORTANT:
11
+ * - This axis is the single source of truth for payload/context/result values.
12
+ * - It must support nested objects/arrays without `any`/`unknown`.
13
+ */
14
+ /**
15
+ * Primitive value types - foundation for all other types
16
+ * Extended to include null/undefined for agent contexts
17
+ */
18
+ type TPrimitiveValue = string | number | boolean | null | undefined;
19
+ type TUniversalValue = TPrimitiveValue | Date | TUniversalArrayValue | IUniversalObjectValue;
20
+ type TUniversalArrayValue = TUniversalValue[];
21
+ interface IUniversalObjectValue {
22
+ [key: string]: TUniversalValue;
23
+ }
24
+ //#endregion
25
+ //#region src/interfaces/model-effort-capability.d.ts
26
+ /** Provider-neutral native effort controls. `auto` is selection state, not a control. */
27
+ type TModelEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
28
+ /** Runtime boundary vocabulary for a concrete provider-native effort control. */
29
+ declare const MODEL_EFFORT_VALUES: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
30
+ declare function isModelEffort(value: TUniversalValue | undefined): value is TModelEffort;
31
+ /** A caller can preserve provider-default selection without serializing a native control. */
32
+ type TModelEffortSelection = TModelEffort | 'auto';
33
+ /** The verified effort facts an adapter declares for one exact model identifier. */
34
+ interface IModelEffortCapability {
35
+ supportedEfforts: readonly TModelEffort[];
36
+ defaultEffort: TModelEffort;
37
+ /** Adapter-owned opaque identity for the verified native control. */
38
+ nativeControlId: string;
39
+ }
40
+ /** Source-dated provider data. Core owns the shape but never provides the data. */
41
+ interface IProviderModelEffortTable {
42
+ verifiedAt: string;
43
+ sourceUrl: string;
44
+ models: Readonly<Record<string, IModelEffortCapability>>;
45
+ }
46
+ type TModelEffortDisposition = 'exact' | 'clamped' | 'model-default' | 'not-applied';
47
+ /** Serializable output of resolving a selection against a verified provider table. */
48
+ interface IModelEffortResolution {
49
+ selection: TModelEffortSelection;
50
+ effective: TModelEffort | null;
51
+ disposition: TModelEffortDisposition;
52
+ fingerprint: string;
53
+ }
54
+ /** Whether the adapter serialized a verified native effort control. */
55
+ type TModelEffortNativeControl = {
56
+ readonly state: 'sent';
57
+ readonly id: string;
58
+ } | {
59
+ readonly state: 'omitted';
60
+ readonly reason: string;
61
+ };
62
+ /** Whether an endpoint dispatch occurred after the effort decision. */
63
+ type TModelEffortProviderDispatch = {
64
+ readonly state: 'sent';
65
+ } | {
66
+ readonly state: 'not-dispatched';
67
+ readonly reason: string;
68
+ };
69
+ /** Serializable terminal result of one effort-bearing provider request. */
70
+ interface IModelEffortOutcome {
71
+ readonly resolution: IModelEffortResolution;
72
+ readonly nativeControl: TModelEffortNativeControl;
73
+ readonly providerDispatch: TModelEffortProviderDispatch;
74
+ }
75
+ /** Local observer for a request's one terminal provider effort outcome. */
76
+ type TModelEffortOutcomeCallback = (outcome: IModelEffortOutcome) => void;
77
+ /** Construct the three-fact terminal outcome without conflating its states. */
78
+ declare function createModelEffortOutcome(resolution: IModelEffortResolution, outcome: Omit<IModelEffortOutcome, 'resolution'>): IModelEffortOutcome;
79
+ /**
80
+ * Resolve only adapter-declared facts. Missing provider/model data never becomes a guessed default.
81
+ */
82
+ declare function resolveModelEffort(table: IProviderModelEffortTable | undefined, modelId: string, selection: TModelEffortSelection): IModelEffortResolution;
83
+ //#endregion
84
+ //#region src/interfaces/trace-context.d.ts
85
+ /**
86
+ * Trusted W3C trace context for a run's provider calls and child processes.
87
+ *
88
+ * A host that exports a trace for a prompt hands the run the trace it owns, the exact origins it
89
+ * trusts with that trace's identifiers, and the subprocess classes it lets inherit them. Nothing
90
+ * here is adopted from the ambient environment: the host decides, and a run without this context
91
+ * sends nothing.
92
+ */
93
+ /** A class of child process a host may let receive `TRACEPARENT`. */
94
+ type TSubprocessTraceClass = 'shell' | 'hooks';
95
+ /** What one child process receives: exactly one environment variable, never `TRACESTATE`. */
96
+ interface ISubprocessTraceEnv {
97
+ readonly TRACEPARENT: string;
98
+ }
99
+ /** The trace a host hands one run. */
100
+ interface IRunTraceContext {
101
+ /** The host-owned trace ID (32 lowercase hex) every provider call of this run belongs to. */
102
+ readonly traceId: string;
103
+ /** The host's span under which each provider-call span is exported. */
104
+ readonly parentSpanId: string;
105
+ /** Exact origins (`scheme://host[:port]`) that may receive `traceparent`; may be empty. */
106
+ readonly allowedOrigins: readonly string[];
107
+ /**
108
+ * Child-process classes that receive `TRACEPARENT` in their environment. Derived separately from
109
+ * the origins, so a host may enable either without the other.
110
+ */
111
+ readonly subprocessClasses?: readonly TSubprocessTraceClass[];
112
+ /**
113
+ * Told when an invoked call's provider cannot carry trace context, and only when origins are
114
+ * listed: a run that propagates to subprocesses alone has nothing to tell. Receives the provider ID only,
115
+ * never an origin, URL or identifier, so a host can surface it without disclosing either.
116
+ */
117
+ readonly onPropagationUnavailable?: (providerId: string) => void;
118
+ }
119
+ /** What one invoked provider call carries: the header value and where it may go. */
120
+ interface IOutboundTraceContext {
121
+ /** `00-<trace-id>-<provider-call-span-id>-01`. */
122
+ readonly traceparent: string;
123
+ /** Exact origins the adapter may send `traceparent` to; any other origin gets nothing. */
124
+ readonly allowedOrigins: readonly string[];
125
+ }
126
+ //#endregion
127
+ //#region src/hooks/types.d.ts
128
+ /**
129
+ * Hook lifecycle events.
130
+ *
131
+ * `PreModelCall`, `PostModelCall`, and `PermissionDecision` (SELFHOST-009) are
132
+ * INFORMATIONAL-ONLY: they are fired fire-and-forget from the turn owner at points it already
133
+ * observes and their `runHooks` result is NOT awaited or consulted for gating. The sole BLOCKING
134
+ * event is `PreToolUse`. The deny causes are enumerated once, in the catalog SSOT
135
+ * `packages/agent-core/docs/HOOK-CATALOG.md` § "Blocking semantics" — cited here rather than
136
+ * recounted, because two different groupings of the same set were in circulation and a second copy
137
+ * is what let them drift. Which events enforce is recorded in `HOOK_ENFORCEMENT_POLICY`
138
+ * (`./enforcement-policy.ts`); see the catalog SSOT `packages/agent-core/docs/HOOK-CATALOG.md` for
139
+ * per-event timing, fire-site, and blocking semantics.
140
+ */
141
+ type THookEvent = 'PreToolUse' | 'PostToolUse' | 'SessionStart' | 'SessionEnd' | 'Stop' | 'StopFailure' | 'PreCompact' | 'PostCompact' | 'UserPromptSubmit' | 'SubagentStart' | 'SubagentStop' | 'WorktreeCreate' | 'WorktreeRemove' | 'PreModelCall' | 'PostModelCall' | 'PermissionDecision';
142
+ /** Claude Code compatible session end reasons. */
143
+ type TSessionEndReason = 'clear' | 'resume' | 'logout' | 'prompt_input_exit' | 'bypass_permissions_disabled' | 'other';
144
+ /** Command hook — executes a shell command */
145
+ interface ICommandHookDefinition {
146
+ type: 'command';
147
+ command: string;
148
+ timeout?: number;
149
+ }
150
+ /** HTTP hook — sends an HTTP request */
151
+ interface IHttpHookDefinition {
152
+ type: 'http';
153
+ url: string;
154
+ headers?: Record<string, string>;
155
+ timeout?: number;
156
+ }
157
+ /** Prompt hook — evaluates a prompt via an AI model */
158
+ interface IPromptHookDefinition {
159
+ type: 'prompt';
160
+ prompt: string;
161
+ model?: string;
162
+ }
163
+ /** Agent hook — delegates to a subagent */
164
+ interface IAgentHookDefinition {
165
+ type: 'agent';
166
+ agent: string;
167
+ maxTurns?: number;
168
+ timeout?: number;
169
+ }
170
+ /**
171
+ * Guardrail hook (SELFHOST-005) — runs the registered guardrail SET in parallel and fails the turn
172
+ * fast. The guardrail functions live in the `GuardrailExecutor` (registered by the consumer); this
173
+ * data-only definition just selects which to run. Any failure maps onto the existing exit-code-2 /
174
+ * `blocked` contract, so enforcement reuses the single `runHooks` → `runPreToolHook` path.
175
+ */
176
+ interface IGuardrailHookDefinition {
177
+ type: 'guardrail';
178
+ /** Names of registered guardrails to run; omitted = run ALL registered guardrails. */
179
+ guardrails?: string[];
180
+ }
181
+ /** Discriminated union of all hook definition types */
182
+ type THookDefinition = ICommandHookDefinition | IHttpHookDefinition | IPromptHookDefinition | IAgentHookDefinition | IGuardrailHookDefinition;
183
+ /**
184
+ * SELFHOST-005: the verdict a guardrail returns. `pass: false` fails the turn fast (mapped to the
185
+ * exit-code-2 / `blocked` hook contract).
186
+ */
187
+ interface IGuardrailResult {
188
+ pass: boolean;
189
+ /** Human-readable reason surfaced when `pass === false`. */
190
+ reason?: string;
191
+ }
192
+ /**
193
+ * SELFHOST-005: a registerable guardrail — a pure MECHANISM that inspects the turn's hook input and
194
+ * votes pass/block. The POLICY (what to check) is the consumer's. Guardrails in a set run in parallel
195
+ * and the first `!pass` (or a thrown error — fail-safe) fails the turn fast.
196
+ */
197
+ type TGuardrail = (input: IHookInput) => IGuardrailResult | Promise<IGuardrailResult>;
198
+ /** A hook group — matcher + array of hook definitions */
199
+ interface IHookGroup {
200
+ /** Regex pattern to match tool name (empty string = match all) */
201
+ matcher: string;
202
+ hooks: THookDefinition[];
203
+ /** Environment variables injected into hook child processes for this group */
204
+ env?: Record<string, string>;
205
+ }
206
+ /** Complete hooks configuration: event → array of hook groups */
207
+ type THooksConfig = Partial<Record<THookEvent, IHookGroup[]>>;
208
+ /** Input passed to hook commands via stdin */
209
+ interface IHookInput {
210
+ session_id: string;
211
+ cwd: string;
212
+ hook_event_name: THookEvent;
213
+ tool_name?: string;
214
+ tool_input?: Record<string, string | number | boolean | object>;
215
+ tool_output?: string;
216
+ /** Compaction trigger source (PreCompact/PostCompact only) */
217
+ trigger?: 'auto' | 'manual';
218
+ /** Compaction summary text (PostCompact only) */
219
+ compact_summary?: string;
220
+ /** User message text (UserPromptSubmit only) */
221
+ user_message?: string;
222
+ /** User prompt text — Claude Code compatible alias for user_message (UserPromptSubmit only) */
223
+ prompt?: string;
224
+ /** Assistant response text (Stop only) */
225
+ response?: string;
226
+ /** Last assistant message text (StopFailure only) */
227
+ last_assistant_message?: string;
228
+ /** Stop hook recursion guard (Stop/StopFailure only) */
229
+ stop_hook_active?: boolean;
230
+ /** Session end reason (SessionEnd only) */
231
+ reason?: TSessionEndReason | string;
232
+ /** Session transcript path when available (SessionEnd/SubagentStop only) */
233
+ transcript_path?: string;
234
+ /** Subagent identifier (SubagentStart/SubagentStop only) */
235
+ agent_id?: string;
236
+ /** Subagent type/name (SubagentStart/SubagentStop only) */
237
+ agent_type?: string;
238
+ /** Subagent transcript path when available (SubagentStop only) */
239
+ agent_transcript_path?: string;
240
+ /** Claude Code permission mode at time of event (e.g. "default", "plan", "acceptEdits", "bypassPermissions") */
241
+ permission_mode?: string;
242
+ /**
243
+ * Provider model identifier for the model call (PreModelCall/PostModelCall only).
244
+ * SELFHOST-009 — informational.
245
+ */
246
+ model?: string;
247
+ /**
248
+ * Provider name for the model call (PreModelCall/PostModelCall only).
249
+ * SELFHOST-009 — informational.
250
+ */
251
+ provider?: string;
252
+ /**
253
+ * Model-effort selection for the model call (PreModelCall/PostModelCall only).
254
+ * API-001 — informational; `auto` remains provider-default selection.
255
+ */
256
+ effort?: TModelEffortSelection;
257
+ /** Agentic round index for the model call (PreModelCall/PostModelCall only). SELFHOST-009 — informational. */
258
+ round?: number;
259
+ /**
260
+ * Reported permission decision (PermissionDecision only) — the value `evaluatePermission` returned
261
+ * (`'auto' | 'approve' | 'deny'`). SELFHOST-009 — informational. This REPORTS a decision already made;
262
+ * it neither extends `TPermissionDecision` nor the internal `IRunHooksResult.permissionDecision`, and
263
+ * the hook cannot change the outcome.
264
+ */
265
+ permission_decision?: string;
266
+ /** Additional environment variables to pass to hook child processes */
267
+ env?: Record<string, string>;
268
+ }
269
+ /**
270
+ * Why a hook execution could not produce a verdict (SEC-015).
271
+ *
272
+ * The distinction these six names carry is the one the exit-code channel could not: a hook that
273
+ * DECIDED versus one that never got to. Which of the six it was is diagnostic detail; that it was
274
+ * any of them is what an enforcing consumer acts on.
275
+ */
276
+ type THookErrorKind =
277
+ /** The executor's own deadline elapsed before the hook answered. */
278
+ 'timeout' |
279
+ /** The process or transport never started (ENOENT, EACCES, a refused handshake). */
280
+ 'spawn-failure' |
281
+ /** It started and failed mid-flight — network drop, provider error, session failure. */
282
+ 'transport-failure' |
283
+ /** A well-formed response carrying a non-2xx status. */
284
+ 'http-status' |
285
+ /** A response arrived and could not be decoded into a verdict. */
286
+ 'malformed-response' |
287
+ /** The process exited with a code that is neither 0 nor 2, or was killed by a signal. */
288
+ 'nonzero-exit';
289
+ /** The hook approved. Its stdout carries the Claude Code response protocol, which the runner decodes. */
290
+ interface IHookAllowOutcome {
291
+ readonly outcome: 'allow';
292
+ /** Which executor produced this outcome — preserved for diagnostics. */
293
+ readonly source: THookDefinition['type'];
294
+ readonly stdout: string;
295
+ }
296
+ /** The hook decided to block, and said why. */
297
+ interface IHookDenyOutcome {
298
+ readonly outcome: 'deny';
299
+ /** Which executor produced this outcome — preserved for diagnostics. */
300
+ readonly source: THookDefinition['type'];
301
+ readonly reason: string;
302
+ }
303
+ /**
304
+ * The hook rendered no verdict.
305
+ *
306
+ * This is NOT a third verdict — it is the absence of one, and the policy for what an enforcing event
307
+ * does about it is deliberately not encoded here.
308
+ */
309
+ interface IHookErrorOutcome {
310
+ readonly outcome: 'error';
311
+ /** Which executor produced this outcome — preserved for diagnostics. */
312
+ readonly source: THookDefinition['type'];
313
+ readonly kind: THookErrorKind;
314
+ readonly reason: string;
315
+ }
316
+ /**
317
+ * The decoded result of one hook execution (SEC-015).
318
+ *
319
+ * It replaces an `{ exitCode, stdout, stderr }` record whose only channel for a failure was a
320
+ * number, which forced every failure to be coerced into a verdict: a truthy non-boolean `ok` read
321
+ * as allow and disabled the gate, while a falsy or missing one read as deny and blocked the user's
322
+ * tool call on a decision no hook made. Making the third outcome representable is what removes the
323
+ * coercion — a malformed response is now `error`, which is neither.
324
+ */
325
+ type THookOutcome = IHookAllowOutcome | IHookDenyOutcome | IHookErrorOutcome;
326
+ /** Strategy interface for hook type executors */
327
+ interface IHookTypeExecutor {
328
+ /** The hook type this executor handles */
329
+ type: THookDefinition['type'];
330
+ /** Execute a hook definition with the given input */
331
+ execute(definition: THookDefinition, input: IHookInput): Promise<THookOutcome>;
332
+ }
333
+ //#endregion
334
+ export { TModelEffortProviderDispatch as A, IModelEffortResolution as C, TModelEffortDisposition as D, TModelEffort as E, IUniversalObjectValue as F, TPrimitiveValue as I, TUniversalArrayValue as L, createModelEffortOutcome as M, isModelEffort as N, TModelEffortNativeControl as O, resolveModelEffort as P, TUniversalValue as R, IModelEffortOutcome as S, MODEL_EFFORT_VALUES as T, IOutboundTraceContext as _, IHookErrorOutcome as a, TSubprocessTraceClass as b, IHookTypeExecutor as c, TGuardrail as d, THookDefinition as f, TSessionEndReason as g, THooksConfig as h, IGuardrailResult as i, TModelEffortSelection as j, TModelEffortOutcomeCallback as k, IHttpHookDefinition as l, THookOutcome as m, ICommandHookDefinition as n, IHookGroup as o, THookEvent as p, IGuardrailHookDefinition as r, IHookInput as s, IAgentHookDefinition as t, IPromptHookDefinition as u, IRunTraceContext as v, IProviderModelEffortTable as w, IModelEffortCapability as x, ISubprocessTraceEnv as y };
335
+ //# sourceMappingURL=types-gNrckgFE.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-gNrckgFE.d.cts","names":[],"sources":["../../src/interfaces/universal-value.ts","../../src/interfaces/model-effort-capability.ts","../../src/interfaces/trace-context.ts","../../src/hooks/types.ts"],"mappings":";;;;;;;;;;;;;;;;;KAiBY;KAEA,kBAAkB,kBAAkB,OAAO,uBAAuB;KAElE,uBAAuB;UAElB;GACd,cAAc;;;;;KCvBL;;cAGC;iBAUG,cAAc,OAAO,8BAA8B,SAAS;;KAKhE,wBAAwB;;UAGnB;EACf,2BAA2B;EAC3B,eAAe;;EAEf;;;UAIe;EACf;EACA;EACA,QAAQ,SAAS,eAAe;;KAGtB;;UAGK;EACf,WAAW;EACX,WAAW;EACX,aAAa;EACb;;;KAIU;WACG;WAAwB;;WACxB;WAA2B;;;KAG9B;WACC;;WAA6B;WAAkC;;;UAG3D;WACN,YAAY;WACZ,eAAe;WACf,kBAAkB;;;KAIjB,+BAA+B,SAAS;;iBAGpC,yBACd,YAAY,wBACZ,SAAS,KAAK,qCACb;;;;iBAkBa,mBACd,OAAO,uCACP,iBACA,WAAW,wBACV;;;;;;;;;;;;KCjFS;;UAGK;WACN;;;UAIM;;WAEN;;WAEA;;WAEA;;;;;WAKA,6BAA6B;;;;;;WAM7B,4BAA4B;;;UAItB;;WAEN;;WAEA;;;;;;;;;;;;;;;;;KCxBC;;KAmBA;;UAIK;EACf;EACA;EACA;;;UAIe;EACf;EACA;EACA,UAAU;EACV;;;UAIe;EACf;EACA;EACA;;;UAIe;EACf;EACA;EACA;EACA;;;;;;;;UASe;EACf;;EAEA;;;KAIU,kBACR,yBACA,sBACA,wBACA,uBACA;;;;;UAMa;EACf;;EAEA;;;;;;;KAQU,cAAc,OAAO,eAAe,mBAAmB,QAAQ;;UAG1D;;EAEf;EACA,OAAO;;EAEP,MAAM;;;KAII,eAAe,QAAQ,OAAO,YAAY;;UAGrC;EACf;EACA;EACA,iBAAiB;EACjB;EACA,aAAa;EACb;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,SAAS;;EAET;;EAEA;;EAEA;;EAEA;;EAEA;;;;;EAKA;;;;;EAKA;;;;;EAKA,SAAS;;EAET;;;;;;;EAOA;;EAEA,MAAM;;;;;;;;;KAUI;;;;;;;;;;;;;;UAeK;WACN;;WAEA,QAAQ;WACR;;;UAIM;WACN;;WAEA,QAAQ;WACR;;;;;;;;UASM;WACN;;WAEA,QAAQ;WACR,MAAM;WACN;;;;;;;;;;;KAYC,eAAe,oBAAoB,mBAAmB;;UAGjD;;EAEf,MAAM;;EAEN,QAAQ,YAAY,iBAAiB,OAAO,aAAa,QAAQ"}
@@ -0,0 +1,335 @@
1
+ //#region src/interfaces/universal-value.d.ts
2
+ /**
3
+ * Universal value type axis (recursive, JSON-like + Date).
4
+ *
5
+ * Extracted from `types.ts` into its own leaf module: several foundational modules (e.g.
6
+ * `provider.ts`) need only this axis, not the rest of `types.ts` (which itself depends on
7
+ * plugin-execution types) — importing the whole barrel there created a module-level import
8
+ * cycle. `types.ts` re-exports these names, so existing `from './types'` imports are unaffected.
9
+ *
10
+ * IMPORTANT:
11
+ * - This axis is the single source of truth for payload/context/result values.
12
+ * - It must support nested objects/arrays without `any`/`unknown`.
13
+ */
14
+ /**
15
+ * Primitive value types - foundation for all other types
16
+ * Extended to include null/undefined for agent contexts
17
+ */
18
+ type TPrimitiveValue = string | number | boolean | null | undefined;
19
+ type TUniversalValue = TPrimitiveValue | Date | TUniversalArrayValue | IUniversalObjectValue;
20
+ type TUniversalArrayValue = TUniversalValue[];
21
+ interface IUniversalObjectValue {
22
+ [key: string]: TUniversalValue;
23
+ }
24
+ //#endregion
25
+ //#region src/interfaces/model-effort-capability.d.ts
26
+ /** Provider-neutral native effort controls. `auto` is selection state, not a control. */
27
+ type TModelEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
28
+ /** Runtime boundary vocabulary for a concrete provider-native effort control. */
29
+ declare const MODEL_EFFORT_VALUES: readonly ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
30
+ declare function isModelEffort(value: TUniversalValue | undefined): value is TModelEffort;
31
+ /** A caller can preserve provider-default selection without serializing a native control. */
32
+ type TModelEffortSelection = TModelEffort | 'auto';
33
+ /** The verified effort facts an adapter declares for one exact model identifier. */
34
+ interface IModelEffortCapability {
35
+ supportedEfforts: readonly TModelEffort[];
36
+ defaultEffort: TModelEffort;
37
+ /** Adapter-owned opaque identity for the verified native control. */
38
+ nativeControlId: string;
39
+ }
40
+ /** Source-dated provider data. Core owns the shape but never provides the data. */
41
+ interface IProviderModelEffortTable {
42
+ verifiedAt: string;
43
+ sourceUrl: string;
44
+ models: Readonly<Record<string, IModelEffortCapability>>;
45
+ }
46
+ type TModelEffortDisposition = 'exact' | 'clamped' | 'model-default' | 'not-applied';
47
+ /** Serializable output of resolving a selection against a verified provider table. */
48
+ interface IModelEffortResolution {
49
+ selection: TModelEffortSelection;
50
+ effective: TModelEffort | null;
51
+ disposition: TModelEffortDisposition;
52
+ fingerprint: string;
53
+ }
54
+ /** Whether the adapter serialized a verified native effort control. */
55
+ type TModelEffortNativeControl = {
56
+ readonly state: 'sent';
57
+ readonly id: string;
58
+ } | {
59
+ readonly state: 'omitted';
60
+ readonly reason: string;
61
+ };
62
+ /** Whether an endpoint dispatch occurred after the effort decision. */
63
+ type TModelEffortProviderDispatch = {
64
+ readonly state: 'sent';
65
+ } | {
66
+ readonly state: 'not-dispatched';
67
+ readonly reason: string;
68
+ };
69
+ /** Serializable terminal result of one effort-bearing provider request. */
70
+ interface IModelEffortOutcome {
71
+ readonly resolution: IModelEffortResolution;
72
+ readonly nativeControl: TModelEffortNativeControl;
73
+ readonly providerDispatch: TModelEffortProviderDispatch;
74
+ }
75
+ /** Local observer for a request's one terminal provider effort outcome. */
76
+ type TModelEffortOutcomeCallback = (outcome: IModelEffortOutcome) => void;
77
+ /** Construct the three-fact terminal outcome without conflating its states. */
78
+ declare function createModelEffortOutcome(resolution: IModelEffortResolution, outcome: Omit<IModelEffortOutcome, 'resolution'>): IModelEffortOutcome;
79
+ /**
80
+ * Resolve only adapter-declared facts. Missing provider/model data never becomes a guessed default.
81
+ */
82
+ declare function resolveModelEffort(table: IProviderModelEffortTable | undefined, modelId: string, selection: TModelEffortSelection): IModelEffortResolution;
83
+ //#endregion
84
+ //#region src/interfaces/trace-context.d.ts
85
+ /**
86
+ * Trusted W3C trace context for a run's provider calls and child processes.
87
+ *
88
+ * A host that exports a trace for a prompt hands the run the trace it owns, the exact origins it
89
+ * trusts with that trace's identifiers, and the subprocess classes it lets inherit them. Nothing
90
+ * here is adopted from the ambient environment: the host decides, and a run without this context
91
+ * sends nothing.
92
+ */
93
+ /** A class of child process a host may let receive `TRACEPARENT`. */
94
+ type TSubprocessTraceClass = 'shell' | 'hooks';
95
+ /** What one child process receives: exactly one environment variable, never `TRACESTATE`. */
96
+ interface ISubprocessTraceEnv {
97
+ readonly TRACEPARENT: string;
98
+ }
99
+ /** The trace a host hands one run. */
100
+ interface IRunTraceContext {
101
+ /** The host-owned trace ID (32 lowercase hex) every provider call of this run belongs to. */
102
+ readonly traceId: string;
103
+ /** The host's span under which each provider-call span is exported. */
104
+ readonly parentSpanId: string;
105
+ /** Exact origins (`scheme://host[:port]`) that may receive `traceparent`; may be empty. */
106
+ readonly allowedOrigins: readonly string[];
107
+ /**
108
+ * Child-process classes that receive `TRACEPARENT` in their environment. Derived separately from
109
+ * the origins, so a host may enable either without the other.
110
+ */
111
+ readonly subprocessClasses?: readonly TSubprocessTraceClass[];
112
+ /**
113
+ * Told when an invoked call's provider cannot carry trace context, and only when origins are
114
+ * listed: a run that propagates to subprocesses alone has nothing to tell. Receives the provider ID only,
115
+ * never an origin, URL or identifier, so a host can surface it without disclosing either.
116
+ */
117
+ readonly onPropagationUnavailable?: (providerId: string) => void;
118
+ }
119
+ /** What one invoked provider call carries: the header value and where it may go. */
120
+ interface IOutboundTraceContext {
121
+ /** `00-<trace-id>-<provider-call-span-id>-01`. */
122
+ readonly traceparent: string;
123
+ /** Exact origins the adapter may send `traceparent` to; any other origin gets nothing. */
124
+ readonly allowedOrigins: readonly string[];
125
+ }
126
+ //#endregion
127
+ //#region src/hooks/types.d.ts
128
+ /**
129
+ * Hook lifecycle events.
130
+ *
131
+ * `PreModelCall`, `PostModelCall`, and `PermissionDecision` (SELFHOST-009) are
132
+ * INFORMATIONAL-ONLY: they are fired fire-and-forget from the turn owner at points it already
133
+ * observes and their `runHooks` result is NOT awaited or consulted for gating. The sole BLOCKING
134
+ * event is `PreToolUse`. The deny causes are enumerated once, in the catalog SSOT
135
+ * `packages/agent-core/docs/HOOK-CATALOG.md` § "Blocking semantics" — cited here rather than
136
+ * recounted, because two different groupings of the same set were in circulation and a second copy
137
+ * is what let them drift. Which events enforce is recorded in `HOOK_ENFORCEMENT_POLICY`
138
+ * (`./enforcement-policy.ts`); see the catalog SSOT `packages/agent-core/docs/HOOK-CATALOG.md` for
139
+ * per-event timing, fire-site, and blocking semantics.
140
+ */
141
+ type THookEvent = 'PreToolUse' | 'PostToolUse' | 'SessionStart' | 'SessionEnd' | 'Stop' | 'StopFailure' | 'PreCompact' | 'PostCompact' | 'UserPromptSubmit' | 'SubagentStart' | 'SubagentStop' | 'WorktreeCreate' | 'WorktreeRemove' | 'PreModelCall' | 'PostModelCall' | 'PermissionDecision';
142
+ /** Claude Code compatible session end reasons. */
143
+ type TSessionEndReason = 'clear' | 'resume' | 'logout' | 'prompt_input_exit' | 'bypass_permissions_disabled' | 'other';
144
+ /** Command hook — executes a shell command */
145
+ interface ICommandHookDefinition {
146
+ type: 'command';
147
+ command: string;
148
+ timeout?: number;
149
+ }
150
+ /** HTTP hook — sends an HTTP request */
151
+ interface IHttpHookDefinition {
152
+ type: 'http';
153
+ url: string;
154
+ headers?: Record<string, string>;
155
+ timeout?: number;
156
+ }
157
+ /** Prompt hook — evaluates a prompt via an AI model */
158
+ interface IPromptHookDefinition {
159
+ type: 'prompt';
160
+ prompt: string;
161
+ model?: string;
162
+ }
163
+ /** Agent hook — delegates to a subagent */
164
+ interface IAgentHookDefinition {
165
+ type: 'agent';
166
+ agent: string;
167
+ maxTurns?: number;
168
+ timeout?: number;
169
+ }
170
+ /**
171
+ * Guardrail hook (SELFHOST-005) — runs the registered guardrail SET in parallel and fails the turn
172
+ * fast. The guardrail functions live in the `GuardrailExecutor` (registered by the consumer); this
173
+ * data-only definition just selects which to run. Any failure maps onto the existing exit-code-2 /
174
+ * `blocked` contract, so enforcement reuses the single `runHooks` → `runPreToolHook` path.
175
+ */
176
+ interface IGuardrailHookDefinition {
177
+ type: 'guardrail';
178
+ /** Names of registered guardrails to run; omitted = run ALL registered guardrails. */
179
+ guardrails?: string[];
180
+ }
181
+ /** Discriminated union of all hook definition types */
182
+ type THookDefinition = ICommandHookDefinition | IHttpHookDefinition | IPromptHookDefinition | IAgentHookDefinition | IGuardrailHookDefinition;
183
+ /**
184
+ * SELFHOST-005: the verdict a guardrail returns. `pass: false` fails the turn fast (mapped to the
185
+ * exit-code-2 / `blocked` hook contract).
186
+ */
187
+ interface IGuardrailResult {
188
+ pass: boolean;
189
+ /** Human-readable reason surfaced when `pass === false`. */
190
+ reason?: string;
191
+ }
192
+ /**
193
+ * SELFHOST-005: a registerable guardrail — a pure MECHANISM that inspects the turn's hook input and
194
+ * votes pass/block. The POLICY (what to check) is the consumer's. Guardrails in a set run in parallel
195
+ * and the first `!pass` (or a thrown error — fail-safe) fails the turn fast.
196
+ */
197
+ type TGuardrail = (input: IHookInput) => IGuardrailResult | Promise<IGuardrailResult>;
198
+ /** A hook group — matcher + array of hook definitions */
199
+ interface IHookGroup {
200
+ /** Regex pattern to match tool name (empty string = match all) */
201
+ matcher: string;
202
+ hooks: THookDefinition[];
203
+ /** Environment variables injected into hook child processes for this group */
204
+ env?: Record<string, string>;
205
+ }
206
+ /** Complete hooks configuration: event → array of hook groups */
207
+ type THooksConfig = Partial<Record<THookEvent, IHookGroup[]>>;
208
+ /** Input passed to hook commands via stdin */
209
+ interface IHookInput {
210
+ session_id: string;
211
+ cwd: string;
212
+ hook_event_name: THookEvent;
213
+ tool_name?: string;
214
+ tool_input?: Record<string, string | number | boolean | object>;
215
+ tool_output?: string;
216
+ /** Compaction trigger source (PreCompact/PostCompact only) */
217
+ trigger?: 'auto' | 'manual';
218
+ /** Compaction summary text (PostCompact only) */
219
+ compact_summary?: string;
220
+ /** User message text (UserPromptSubmit only) */
221
+ user_message?: string;
222
+ /** User prompt text — Claude Code compatible alias for user_message (UserPromptSubmit only) */
223
+ prompt?: string;
224
+ /** Assistant response text (Stop only) */
225
+ response?: string;
226
+ /** Last assistant message text (StopFailure only) */
227
+ last_assistant_message?: string;
228
+ /** Stop hook recursion guard (Stop/StopFailure only) */
229
+ stop_hook_active?: boolean;
230
+ /** Session end reason (SessionEnd only) */
231
+ reason?: TSessionEndReason | string;
232
+ /** Session transcript path when available (SessionEnd/SubagentStop only) */
233
+ transcript_path?: string;
234
+ /** Subagent identifier (SubagentStart/SubagentStop only) */
235
+ agent_id?: string;
236
+ /** Subagent type/name (SubagentStart/SubagentStop only) */
237
+ agent_type?: string;
238
+ /** Subagent transcript path when available (SubagentStop only) */
239
+ agent_transcript_path?: string;
240
+ /** Claude Code permission mode at time of event (e.g. "default", "plan", "acceptEdits", "bypassPermissions") */
241
+ permission_mode?: string;
242
+ /**
243
+ * Provider model identifier for the model call (PreModelCall/PostModelCall only).
244
+ * SELFHOST-009 — informational.
245
+ */
246
+ model?: string;
247
+ /**
248
+ * Provider name for the model call (PreModelCall/PostModelCall only).
249
+ * SELFHOST-009 — informational.
250
+ */
251
+ provider?: string;
252
+ /**
253
+ * Model-effort selection for the model call (PreModelCall/PostModelCall only).
254
+ * API-001 — informational; `auto` remains provider-default selection.
255
+ */
256
+ effort?: TModelEffortSelection;
257
+ /** Agentic round index for the model call (PreModelCall/PostModelCall only). SELFHOST-009 — informational. */
258
+ round?: number;
259
+ /**
260
+ * Reported permission decision (PermissionDecision only) — the value `evaluatePermission` returned
261
+ * (`'auto' | 'approve' | 'deny'`). SELFHOST-009 — informational. This REPORTS a decision already made;
262
+ * it neither extends `TPermissionDecision` nor the internal `IRunHooksResult.permissionDecision`, and
263
+ * the hook cannot change the outcome.
264
+ */
265
+ permission_decision?: string;
266
+ /** Additional environment variables to pass to hook child processes */
267
+ env?: Record<string, string>;
268
+ }
269
+ /**
270
+ * Why a hook execution could not produce a verdict (SEC-015).
271
+ *
272
+ * The distinction these six names carry is the one the exit-code channel could not: a hook that
273
+ * DECIDED versus one that never got to. Which of the six it was is diagnostic detail; that it was
274
+ * any of them is what an enforcing consumer acts on.
275
+ */
276
+ type THookErrorKind =
277
+ /** The executor's own deadline elapsed before the hook answered. */
278
+ 'timeout' |
279
+ /** The process or transport never started (ENOENT, EACCES, a refused handshake). */
280
+ 'spawn-failure' |
281
+ /** It started and failed mid-flight — network drop, provider error, session failure. */
282
+ 'transport-failure' |
283
+ /** A well-formed response carrying a non-2xx status. */
284
+ 'http-status' |
285
+ /** A response arrived and could not be decoded into a verdict. */
286
+ 'malformed-response' |
287
+ /** The process exited with a code that is neither 0 nor 2, or was killed by a signal. */
288
+ 'nonzero-exit';
289
+ /** The hook approved. Its stdout carries the Claude Code response protocol, which the runner decodes. */
290
+ interface IHookAllowOutcome {
291
+ readonly outcome: 'allow';
292
+ /** Which executor produced this outcome — preserved for diagnostics. */
293
+ readonly source: THookDefinition['type'];
294
+ readonly stdout: string;
295
+ }
296
+ /** The hook decided to block, and said why. */
297
+ interface IHookDenyOutcome {
298
+ readonly outcome: 'deny';
299
+ /** Which executor produced this outcome — preserved for diagnostics. */
300
+ readonly source: THookDefinition['type'];
301
+ readonly reason: string;
302
+ }
303
+ /**
304
+ * The hook rendered no verdict.
305
+ *
306
+ * This is NOT a third verdict — it is the absence of one, and the policy for what an enforcing event
307
+ * does about it is deliberately not encoded here.
308
+ */
309
+ interface IHookErrorOutcome {
310
+ readonly outcome: 'error';
311
+ /** Which executor produced this outcome — preserved for diagnostics. */
312
+ readonly source: THookDefinition['type'];
313
+ readonly kind: THookErrorKind;
314
+ readonly reason: string;
315
+ }
316
+ /**
317
+ * The decoded result of one hook execution (SEC-015).
318
+ *
319
+ * It replaces an `{ exitCode, stdout, stderr }` record whose only channel for a failure was a
320
+ * number, which forced every failure to be coerced into a verdict: a truthy non-boolean `ok` read
321
+ * as allow and disabled the gate, while a falsy or missing one read as deny and blocked the user's
322
+ * tool call on a decision no hook made. Making the third outcome representable is what removes the
323
+ * coercion — a malformed response is now `error`, which is neither.
324
+ */
325
+ type THookOutcome = IHookAllowOutcome | IHookDenyOutcome | IHookErrorOutcome;
326
+ /** Strategy interface for hook type executors */
327
+ interface IHookTypeExecutor {
328
+ /** The hook type this executor handles */
329
+ type: THookDefinition['type'];
330
+ /** Execute a hook definition with the given input */
331
+ execute(definition: THookDefinition, input: IHookInput): Promise<THookOutcome>;
332
+ }
333
+ //#endregion
334
+ export { TModelEffortProviderDispatch as A, IModelEffortResolution as C, TModelEffortDisposition as D, TModelEffort as E, IUniversalObjectValue as F, TPrimitiveValue as I, TUniversalArrayValue as L, createModelEffortOutcome as M, isModelEffort as N, TModelEffortNativeControl as O, resolveModelEffort as P, TUniversalValue as R, IModelEffortOutcome as S, MODEL_EFFORT_VALUES as T, IOutboundTraceContext as _, IHookErrorOutcome as a, TSubprocessTraceClass as b, IHookTypeExecutor as c, TGuardrail as d, THookDefinition as f, TSessionEndReason as g, THooksConfig as h, IGuardrailResult as i, TModelEffortSelection as j, TModelEffortOutcomeCallback as k, IHttpHookDefinition as l, THookOutcome as m, ICommandHookDefinition as n, IHookGroup as o, THookEvent as p, IGuardrailHookDefinition as r, IHookInput as s, IAgentHookDefinition as t, IPromptHookDefinition as u, IRunTraceContext as v, IProviderModelEffortTable as w, IModelEffortCapability as x, ISubprocessTraceEnv as y };
335
+ //# sourceMappingURL=types-gNrckgFE.d.ts.map