@theokit/agents 13.0.0-next.6 → 13.0.0-next.8

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 CHANGED
@@ -1,5 +1,44 @@
1
1
  # @theokit/agents
2
2
 
3
+ ## 13.0.0-next.8
4
+
5
+ ### Minor Changes
6
+
7
+ - feb5781: `AgentBuilder.create().hookApproval()` — the fluent twin of `defineAgent({ hookApproval })`
8
+
9
+ `13.0.0-next.7` shipped the hook approval gate reachable through `defineAgent` and capabilities, and
10
+ not through the fluent builder. A consumer that authors with `AgentBuilder.create()` had no way to
11
+ reach it: `.use()` composes presets rather than sinking capabilities, and the definition reaches
12
+ `streamAgentTurnInProcess` with `local` already assembled, so there was no downstream place to inject
13
+ `local.hooks` by hand either.
14
+
15
+ Fifth instance of one family and a NEW variant. The first four were "the symbol exists and the barrel
16
+ omits it", which the emitted-export guard now catches. This one is the opposite: the symbol is
17
+ exported, on the compiled waist, and reachable through one authoring door — the other door simply
18
+ does not offer it, and an export check is green on that.
19
+
20
+ So the guard for this variant builds the SAME agent through BOTH doors and asserts they arrive at the
21
+ same compiled waist. It catches the worst case too: an interface that declares the method while the
22
+ factory never wires it compiles, does nothing, and fails this test.
23
+
24
+ ## 13.0.0-next.7
25
+
26
+ ### Patch Changes
27
+
28
+ - a2b0a59: The hook gate's vocabulary crosses with the capability that takes it
29
+
30
+ `13.0.0-next.6` exported `HookApprovalCapability` and withheld `HookApprovalGate`,
31
+ `HookApprovalRequest` and `HookGateUnsupportedError`. A consumer could build the gate, and could
32
+ neither type the object it takes nor catch its refusal by class — which matters more here than
33
+ usual, because refusing loudly is the whole design.
34
+
35
+ Fourth instance of the same shape (#663 `AgentModule`, #668 `transcriptOf`, #675 `RegistryOutcome`),
36
+ and the first three were each found by installing the published package. The source is correct every
37
+ time: the type IS exported from its own module, and only the barrel omits it.
38
+
39
+ A guard now reads the EMITTED `dist/index.d.ts` export list rather than the source, and it was
40
+ proved able to fail by removing one export and watching it name that one.
41
+
3
42
  ## 13.0.0-next.6
4
43
 
5
44
  ### Minor Changes
@@ -125,6 +125,29 @@ interface HookApprovalRequest {
125
125
  readonly sourcePath?: string;
126
126
  readonly matcher?: string;
127
127
  }
128
+ /**
129
+ * Refuses when the installed SDK cannot honour a declared hook gate.
130
+ *
131
+ * ## Why this THROWS where its `compatSources` sibling only warns
132
+ *
133
+ * That one guards a configuration source: ignored, the foreign root is not read, and the agent runs
134
+ * with less than was asked for. This one guards a SECURITY decision. Ignored, the agent runs with
135
+ * MORE than was asked for — every hook spawns unreviewed — while the consumer believes it is gated
136
+ * and stops looking. The consumer that reported #686 asked for the refusal in those words: they
137
+ * would rather have no gate than a silent one, because their `doctor` would otherwise publish a
138
+ * guarantee that is false on `@theokit/sdk@5.0.0`.
139
+ *
140
+ * ## Why an unreadable version is a refusal and not a shrug
141
+ *
142
+ * The sibling stays silent when it cannot read the version, and that is right for a diagnostic. Here
143
+ * "cannot tell" and "is gated" must not collapse: unproven is not proven, and this whole issue is
144
+ * one instance of that confusion. A bundled SDK that hides `package.json` gets an explicit refusal
145
+ * naming what it could not read, which is recoverable; a silent pass is not.
146
+ */
147
+ declare class HookGateUnsupportedError extends TheokitAgentError {
148
+ readonly name = "HookGateUnsupportedError";
149
+ constructor(version: string | undefined);
150
+ }
128
151
 
129
152
  /**
130
153
  * Agent compiler — transforms decorator metadata into SDK calls.
@@ -275,4 +298,4 @@ interface CompiledAgentOptions {
275
298
  skillsResolver?: SkillsSelection;
276
299
  }
277
300
 
278
- export { type CompiledAgentOptions as C, type Guardrail as G, type HookApprovalGate as H, type SkillsSelection as S, type ToolWalkResult as T, type CompiledTool as a, CostBudgetExceededError as b, type GuardrailAction as c, type GuardrailPhase as d, type GuardrailResult as e, GuardrailViolationError as f, type SkillsRequestContext as g, type ToolboxWalkResult as h, compileTools as i, resolveEnabledSkills as r };
301
+ export { type CompiledAgentOptions as C, type Guardrail as G, type HookApprovalGate as H, type SkillsSelection as S, type ToolWalkResult as T, type CompiledTool as a, CostBudgetExceededError as b, type GuardrailAction as c, type GuardrailPhase as d, type GuardrailResult as e, GuardrailViolationError as f, type HookApprovalRequest as g, HookGateUnsupportedError as h, type SkillsRequestContext as i, type ToolboxWalkResult as j, compileTools as k, resolveEnabledSkills as r };
@@ -1,11 +1,11 @@
1
1
  import { ExecutionContext } from '@theokit/http';
2
2
  import { c as AgentOptions, T as ToolOptions, P as ProjectContextOptions, H as HumanInTheLoopOptions, R as ReasoningEffort, M as McpServersMap } from './types-C16Wuh9E.js';
3
- import { C as CompiledAgentOptions, a as CompiledTool, G as Guardrail, S as SkillsSelection } from './agent-compiler-B_A4p8F8.js';
3
+ import { C as CompiledAgentOptions, a as CompiledTool, G as Guardrail, S as SkillsSelection, H as HookApprovalGate } from './agent-compiler-C2jIZ4CZ.js';
4
4
  import { SkillsSettings, ContextSettings, SystemPromptResolver, ModelSelection, PluginsSettings, Plugin, ProviderRoutingSettings, AgentDefinition as AgentDefinition$1, BudgetTracker, CustomTool, RunEventSink, MemorySettings } from '@theokit/sdk';
5
- import { S as StreamEvent, f as ApprovalRequiredEvent, a4 as MaskError } from './delegation-scoring-y-ar_2Eb.js';
5
+ import { S as StreamEvent, f as ApprovalRequiredEvent, a4 as MaskError } from './delegation-scoring-BrBQXvIp.js';
6
6
  import { RetryOptions } from '@theokit/sdk/retry';
7
7
  import { SandboxPosture } from '@theokit/sdk/sandbox';
8
- import { A as AgentDefinition, S as SettingSourcesSelection } from './define-agent-DbwSXyYe.js';
8
+ import { A as AgentDefinition, S as SettingSourcesSelection } from './define-agent-WYnUlWaH.js';
9
9
  import { z } from 'zod';
10
10
  import { H as HookHandlers } from './hook-handlers-Cw2FsnE5.js';
11
11
  import { WireChunk } from '@theokit/presenter/wire';
@@ -912,6 +912,22 @@ interface AgentBuilder<TInput extends z.ZodType | UnsetMarker = UnsetMarker, TMo
912
912
  * whose `cwd` is its own deploy, false for an agent pointed at a repository someone else wrote.
913
913
  */
914
914
  settingSources(selection: SettingSourcesSelection): AgentBuilder<TInput, TModel, TContext, TTools>;
915
+ /**
916
+ * #686 — decide whether a hook declared in a config root is spawned AT ALL, before it runs.
917
+ *
918
+ * The fluent twin of `defineAgent({ hookApproval })`. It exists because a consumer that builds
919
+ * through this chain had no way to reach the gate: `.use()` composes presets rather than sinking
920
+ * capabilities, and the definition reaches `streamAgentTurnInProcess` with `local` already
921
+ * assembled, so there was no downstream place to inject it either.
922
+ *
923
+ * Distinct from {@link AgentBuilder.hooks} below, which ATTACHES lifecycle hooks. This one decides
924
+ * whether hooks somebody ELSE declared — in `.theokit/`, or in a foreign dialect imported through
925
+ * `settingSources` — are allowed to run.
926
+ *
927
+ * Requires `@theokit/sdk >= 5.4.0`. Declaring it against an older SDK is refused at assembly
928
+ * rather than forwarded: a gate that silently does not gate is worse than none.
929
+ */
930
+ hookApproval(gate: HookApprovalGate): AgentBuilder<TInput, TModel, TContext, TTools>;
915
931
  /**
916
932
  * M49 — enable the SDK's durable memory for this agent (`.theokit/memory/` in the run cwd:
917
933
  * `Remember:` capture with secret redaction, auto-injected recall, memory tools). Takes the SDK's
package/dist/bridge.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { c as APPROVAL_MODES, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinitionError, g as AgentExecutionContext, h as AgentManifest, A as AgentManifestEntry, i as AgentManifestSource, j as AgentManifestTool, b as AgentModule, k as AgentRoute, l as AgentRouteContext, m as AgentRunInfo, n as AgentsPluginOptions, o as ApiErrorContext, p as ApiErrorDecision, q as ApiErrorPolicy, r as ApprovalMode, a as ApprovalPosture, B as BeforeToolCallContext, u as CompiledContextWindow, v as ContextualTool, D as DefinitionOrThunk, w as DelegationTimeoutError, E as EphemeralAgent, L as LLMCallContext, M as McpApprovalSpec, x as McpFileError, y as McpRegistryConfig, z as McpRequestContext, F as McpSelection, P as ProcessInputContext, G as SdkAgentHandle, I as SdkMessage, J as SdkSendOptions, K as SdkTurnHandle, N as Segment, O as ShouldAutoApproveOptions, T as ToolCallVeto, Q as ToolHooks, R as ToolHooksPlugin, W as WRITE_SCOPED_TOOLS, U as agentsPlugin, V as applyPosture, X as buildModelSelection, Y as compileAgentModule, Z as compileContextWindow, _ as compileLoadedAgentModule, $ as compileProjectContext, a0 as compileSkills, a1 as createAgentExecutionContext, a2 as createApiErrorHandler, a3 as createSdkAgentStream, a4 as createThinkTagExtractor, a5 as createToolHooksPlugin, a6 as extractThinkTagStream, a7 as generateAgentManifest, a8 as generateAgentRoutes, a9 as isAgentContext, aa as loadMcpJson, ab as mcpRegistry, ac as mcpToolApprovals, ad as projectContextMetadataOnlyKnobs, ae as reasoningEffortOf, af as resolveMcpServers, ag as runWithApiErrorHandling, ah as shouldAutoApprove, s as streamAgentUIMessages, ai as toAgentFactory, aj as translateSdkEvent, ak as withClockCap, al as withEphemeralAgent } from './bridge-entry-9Fj7T18f.js';
2
- export { C as CompiledAgentOptions, a as CompiledTool, T as ToolWalkResult, h as ToolboxWalkResult, i as compileTools } from './agent-compiler-B_A4p8F8.js';
3
- export { A as AgentStopReason, d as AgentStreamEvent, e as AgentTurnMetadata, f as ApprovalRequiredEvent, g as ArtifactChunkEvent, h as ArtifactStartEvent, B as BackgroundDelegation, i as BudgetExceededError, C as CheckpointSavedEvent, k as DelegateFn, a as DelegateOptions, l as DelegationBudgetExceededError, m as DelegationError, n as DelegationPort, c as DelegationResult, D as DelegationTarget, o as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, P as PartialToolCallEvent, v as RunStartedEvent, w as ScoreVerdict, x as ScoredDelegation, y as Scorer, z as StateUpdateEvent, S as StreamEvent, T as TextDeltaEvent, G as ThinkingEvent, H as ToolCallEvent, J as ToolResultEvent, K as delegate, M as delegateBackground, N as delegateWithScoring, O as isApprovalRequired, Q as isDone, U as isError, V as isPartialToolCall, W as isTextDelta, X as isToolCall, Y as isToolResult, a0 as presentUIMessageStream, a3 as streamAgentResponse } from './delegation-scoring-y-ar_2Eb.js';
4
- export { a as AGENT_BRAND, A as AgentDefinition, D as DefineAgentConfig, I as InferAgentInput, b as InferAgentToolNames, P as ProjectSettingsGrant, c as SettingSourceCapability, S as SettingSourcesSelection, U as UntrustedSettingSourceError, d as compileAgentDefinition, i as isAgentDefinition, r as resolveCompatSources, e as resolveSettingSources } from './define-agent-DbwSXyYe.js';
1
+ export { c as APPROVAL_MODES, d as AfterToolCallContext, e as AgentBuilder, f as AgentDefinitionError, g as AgentExecutionContext, h as AgentManifest, A as AgentManifestEntry, i as AgentManifestSource, j as AgentManifestTool, b as AgentModule, k as AgentRoute, l as AgentRouteContext, m as AgentRunInfo, n as AgentsPluginOptions, o as ApiErrorContext, p as ApiErrorDecision, q as ApiErrorPolicy, r as ApprovalMode, a as ApprovalPosture, B as BeforeToolCallContext, u as CompiledContextWindow, v as ContextualTool, D as DefinitionOrThunk, w as DelegationTimeoutError, E as EphemeralAgent, L as LLMCallContext, M as McpApprovalSpec, x as McpFileError, y as McpRegistryConfig, z as McpRequestContext, F as McpSelection, P as ProcessInputContext, G as SdkAgentHandle, I as SdkMessage, J as SdkSendOptions, K as SdkTurnHandle, N as Segment, O as ShouldAutoApproveOptions, T as ToolCallVeto, Q as ToolHooks, R as ToolHooksPlugin, W as WRITE_SCOPED_TOOLS, U as agentsPlugin, V as applyPosture, X as buildModelSelection, Y as compileAgentModule, Z as compileContextWindow, _ as compileLoadedAgentModule, $ as compileProjectContext, a0 as compileSkills, a1 as createAgentExecutionContext, a2 as createApiErrorHandler, a3 as createSdkAgentStream, a4 as createThinkTagExtractor, a5 as createToolHooksPlugin, a6 as extractThinkTagStream, a7 as generateAgentManifest, a8 as generateAgentRoutes, a9 as isAgentContext, aa as loadMcpJson, ab as mcpRegistry, ac as mcpToolApprovals, ad as projectContextMetadataOnlyKnobs, ae as reasoningEffortOf, af as resolveMcpServers, ag as runWithApiErrorHandling, ah as shouldAutoApprove, s as streamAgentUIMessages, ai as toAgentFactory, aj as translateSdkEvent, ak as withClockCap, al as withEphemeralAgent } from './bridge-entry-BJ86tO6e.js';
2
+ export { C as CompiledAgentOptions, a as CompiledTool, H as HookApprovalGate, g as HookApprovalRequest, h as HookGateUnsupportedError, T as ToolWalkResult, j as ToolboxWalkResult, k as compileTools } from './agent-compiler-C2jIZ4CZ.js';
3
+ export { A as AgentStopReason, d as AgentStreamEvent, e as AgentTurnMetadata, f as ApprovalRequiredEvent, g as ArtifactChunkEvent, h as ArtifactStartEvent, B as BackgroundDelegation, i as BudgetExceededError, C as CheckpointSavedEvent, k as DelegateFn, a as DelegateOptions, l as DelegationBudgetExceededError, m as DelegationError, n as DelegationPort, c as DelegationResult, D as DelegationTarget, o as DoneEvent, E as ErrorEvent, F as FileEditEvent, I as IterationEvent, P as PartialToolCallEvent, v as RunStartedEvent, w as ScoreVerdict, x as ScoredDelegation, y as Scorer, z as StateUpdateEvent, S as StreamEvent, T as TextDeltaEvent, G as ThinkingEvent, H as ToolCallEvent, J as ToolResultEvent, K as delegate, M as delegateBackground, N as delegateWithScoring, O as isApprovalRequired, Q as isDone, U as isError, V as isPartialToolCall, W as isTextDelta, X as isToolCall, Y as isToolResult, a0 as presentUIMessageStream, a3 as streamAgentResponse } from './delegation-scoring-BrBQXvIp.js';
4
+ export { a as AGENT_BRAND, A as AgentDefinition, D as DefineAgentConfig, I as InferAgentInput, b as InferAgentToolNames, P as ProjectSettingsGrant, c as SettingSourceCapability, S as SettingSourcesSelection, U as UntrustedSettingSourceError, d as compileAgentDefinition, i as isAgentDefinition, r as resolveCompatSources, e as resolveSettingSources } from './define-agent-WYnUlWaH.js';
5
5
  import '@theokit/http';
6
6
  import './types-C16Wuh9E.js';
7
7
  import '@theokit/sdk';
package/dist/bridge.js CHANGED
@@ -29,13 +29,14 @@ import {
29
29
  runWithApiErrorHandling,
30
30
  streamAgentResponse,
31
31
  streamAgentUIMessages
32
- } from "./chunk-E55OHDVH.js";
32
+ } from "./chunk-3GQJ2BHT.js";
33
33
  import {
34
34
  APPROVAL_MODES,
35
35
  BudgetExceededError,
36
36
  DelegationBudgetExceededError,
37
37
  DelegationError,
38
38
  DelegationTimeoutError,
39
+ HookGateUnsupportedError,
39
40
  WRITE_SCOPED_TOOLS,
40
41
  applyPosture,
41
42
  buildModelSelection,
@@ -54,7 +55,7 @@ import {
54
55
  translateSdkEvent,
55
56
  withClockCap,
56
57
  withEphemeralAgent
57
- } from "./chunk-D6QM7FY5.js";
58
+ } from "./chunk-NZTLBLHB.js";
58
59
  import "./chunk-RKWCXVYG.js";
59
60
  import {
60
61
  AGENT_BRAND,
@@ -76,6 +77,7 @@ export {
76
77
  DelegationBudgetExceededError,
77
78
  DelegationError,
78
79
  DelegationTimeoutError,
80
+ HookGateUnsupportedError,
79
81
  McpFileError,
80
82
  UntrustedSettingSourceError,
81
83
  WRITE_SCOPED_TOOLS,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createHitlPlugin,
3
3
  createSdkAgentStream
4
- } from "./chunk-D6QM7FY5.js";
4
+ } from "./chunk-NZTLBLHB.js";
5
5
  import {
6
6
  compileAgentDefinition,
7
7
  defineAgent,
@@ -641,6 +641,10 @@ function makeBuilder(config) {
641
641
  ...config,
642
642
  settingSources: selection
643
643
  }), "settingSources"),
644
+ hookApproval: /* @__PURE__ */ __name((gate) => makeBuilder({
645
+ ...config,
646
+ hookApproval: gate
647
+ }), "hookApproval"),
644
648
  memory: /* @__PURE__ */ __name((settings) => makeBuilder({
645
649
  ...config,
646
650
  memory: settings
@@ -1236,4 +1240,4 @@ export {
1236
1240
  generateAgentManifest,
1237
1241
  agentsPlugin
1238
1242
  };
1239
- //# sourceMappingURL=chunk-E55OHDVH.js.map
1243
+ //# sourceMappingURL=chunk-3GQJ2BHT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/errors.ts","../src/bridge/compile-context-window.ts","../src/bridge/compile-skills.ts","../src/bridge/agent-compiler.ts","../src/bridge/agent-execution-context.ts","../src/bridge/present-ui-message-stream.ts","../src/bridge/hitl-call-correlation.ts","../src/bridge/agent-sse-handler.ts","../src/bridge/agent-stream-events.ts","../src/bridge/agent-route-generator.ts","../src/bridge/agent-builder.ts","../src/bridge/agent-endpoint.ts","../src/bridge/api-error-handler.ts","../src/bridge/mcp-resolver.ts","../src/bridge/mcp-file.ts","../src/manifest/agent-manifest.ts","../src/theokit-plugin.ts"],"mappings":";;;;;;;;;;;;;;AAiBA,SAASA,0BAA0B;;;ACiCnC,IAAMC,iBAAiB;EACrB;EACA;EACA;EACA;;AAUK,SAASC,qBAAqBC,SAA6B;AAChE,QAAMC,UAA2B,CAAC;AAClC,MAAI,OAAOD,QAAQE,cAAc,UAAU;AACzCD,YAAQC,YAAYF,QAAQE;EAC9B;AAEA,QAAMC,OAAOH;AACb,QAAMI,oBAAoBN,eAAeO,OAAO,CAACC,SAASH,KAAKG,IAAAA,MAAUC,MAAAA;AAEzE,SAAO;IAAEN;IAASG;EAAkB;AACtC;AAVgBL;;;ACrCT,SAASS,cAAcC,SAAsB;AAClD,MAAIA,QAAQC,cAAc;AACxB,WAAO;MAAEC,YAAY;IAAK;EAC5B;AACA,SAAO;IAAEC,SAASH,QAAQI;IAASF,YAAY;EAAK;AACtD;AALgBH;;;ACoEhB,IAAMM,gBAAgB;AAGtB,IAAMC,2BAA2B;AAGjC,IAAMC,wBAAwB;AAU9B,IAAMC,0BAA+C,oBAAIC,IAAI;EAC3D;EACA;EACA;CACD;AACD,IAAMC,2BAA2B;AAmB1B,SAASC,gBAAgBC,WAAmBC,UAAgB;AAIjE,MAAIA,SAASC,KAAI,EAAGC,WAAW,GAAG;AAChC,UAAMC,QAAQJ,YAAY,kBAAkBA,SAAAA,MAAe;AAC3D,UAAM,IAAIK,mBAAmB,mBAAmBD,KAAAA,+CAA+C;EACjG;AAEA,QAAME,OAAON,YAAY,GAAGA,SAAAA,IAAaC,QAAAA,KAAaA;AAEtD,MAAI,CAACR,cAAcc,KAAKD,IAAAA,GAAO;AAG7B,QAAIX,sBAAsBY,KAAKD,IAAAA,GAAO;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,GAAA,EAAM,QAAOtD;AAClC,UAAMuD,cAAcvD,EAAEqD,KAAKG,QAAQ,WAAW,OAAA;AAC9C,WAAO;MAAE,GAAGxD;MAAGyD,OAAOC,OAAO,IAAIH,WAAAA,GAAc;IAAE;EACnD,CAAA;AACF;AANSjB;AAST,SAASf,WACPZ,QACAS,QACAI,UAAgB;AAEhB,SAAOb,OAAOgD,KAAK,CAAC3D,MAAAA;AAClB,QAAIA,EAAEoB,WAAWA,OAAQ,QAAO;AAChC,QAAIpB,EAAEyD,MAAO,QAAOzD,EAAEyD,MAAMG,KAAKpC,QAAAA;AACjC,WAAOxB,EAAEqD,SAAS7B;EACpB,CAAA;AACF;AAVSD;","names":["ConfigurationError","STRATEGY_KNOBS","compileContextWindow","options","context","maxTokens","opts","metadataOnlyKnobs","filter","knob","undefined","compileSkills","options","autoDiscover","autoInject","enabled","include","SDK_TOOL_NAME","SDK_TOOL_NAME_MAX_LENGTH","SDK_TOOL_NAME_CHARSET","SDK_RESERVED_TOOL_NAMES","Set","SDK_RESERVED_TOOL_PREFIX","toolRuntimeName","namespace","toolName","trim","length","where","ConfigurationError","name","test","String","has","startsWith","join","compileHitlGates","toolboxes","gates","Map","tb","tool","tools","hitl","set","config","compileTools","toolboxInstances","instance","get","class","handler","propertyKey","push","description","inputSchema","input","call","createAgentExecutionContext","base","agent","run","toolCall","getRequest","getUrl","getClass","getMethodName","getAgent","getRun","getToolCall","isAgentContext","ctx","UIMessageStreamPresenter","WIRE_APPROVAL_DETAIL_PART","claim","queues","toolName","queue","get","undefined","claimed","shift","length","delete","enqueue","id","set","push","forget","at","indexOf","splice","HitlCallCorrelation","Map","announceToolCall","callId","announced","approvalToolCallId","approvalId","resultToolCallId","toAgentOutputEvent","e","type","text","content","callId","name","toolName","input","result","output","isError","doneToMetadata","event","usage","durationMs","cost","undefined","stopReason","model","ERROR_CODE_DATA_PART","INPUT_REQUESTED_DATA_PART","TASK_PROGRESS_DATA_PART","SHELL_OUTPUT_DATA_PART","dataPart","data","transient","UNMASKED_CODES","Set","MASK_ERROR","error","code","has","message","errorChunks","errorText","diagnosticDataPart","checkpointId","resumeToken","step","requestId","status","correlateToolIds","correlation","announceToolCall","resultToolCallId","presentUIMessageStream","events","opts","onError","presenter","UIMessageStreamPresenter","textId","HitlCallCorrelation","turnMetadata","correlated","present","closeBlock","toolCallId","approvalToolCallId","hasSeen","markSeen","dynamic","WIRE_APPROVAL_DETAIL_PART","approvalId","question","timeoutMs","diagnostic","err","codeOrUndefined","String","finish","encoder","TextEncoder","DONE_FRAME","streamAgentResponse","eventStream","opts","stream","ReadableStream","start","controller","closed","safeEnqueue","chunk","enqueue","chunks","presentUIMessageStream","textId","crypto","randomUUID","onError","undefined","data","JSON","stringify","encode","type","close","Response","status","headers","isTextDelta","e","type","isToolCall","isPartialToolCall","isToolResult","isDone","isError","isApprovalRequired","generateAgentRoutes","ctx","walkResult","createRun","getRun","basePath","route","replace","routes","push","method","path","handler","request","body","json","message","length","Response","JSON","stringify","error","code","status","headers","rawSessionId","sessionId","Date","now","streamAgentResponse","url","URL","runId","pathname","split","pop","run","ContextualTool","of","tool","_requiredContext","makeBuilder","config","runtime","input","schema","model","id","system","prompt","reasoningEffort","effort","maxIterations","limit","context","value","tools","list","when","condition","apply","builder","guardrail","g","guardrails","gs","approval","toolName","options","approvals","map","skills","selection","settingSources","hookApproval","gate","memory","settings","hooks","plugins","mcp","servers","mcpServers","use","preset","build","defineAgent","AgentBuilder","create","TheokitAgentError","AgentDefinitionError","TheokitAgentError","name","source","code","isRetryable","extractDefaultExport","mod","default","isCompiledAgentOptions","value","v","Array","isArray","tools","agents","compileAgentModule","def","isAgentDefinition","compileAgentDefinition","compileLoadedAgentModule","asAgentStream","events","e","EventQueue","push","item","r","shift","done","close","splice","undefined","drain","length","next","Promise","resolve","appendCheckpointSaved","sessionId","emitted","checkpoint","type","checkpointId","crypto","randomUUID","step","resumeToken","ev","streamAgentUIMessages","compiled","apiKey","input","textId","overrides","cwd","baseDir","images","onRunEvent","retry","signal","exposeUsageToTools","hitl","gated","size","createSdkAgentStream","message","queue","addEventListener","once","plugin","createHitlPlugin","emit","awaitApproval","sdkStream","plugins","err","Error","String","retryable","durableCheckpoint","storage","presentUIMessageStream","onError","DEFAULT_MAX_ATTEMPTS","runWithApiErrorHandling","thunk","policy","maxAttempts","attempt","error","decision","processApiError","retry","fallback","undefined","createApiErrorHandler","resolveMcpServers","selection","ctx","undefined","resolved","Error","mcpRegistry","config","registry","apps","composio","command","args","length","join","env","COMPOSIO_API_KEY","apiKey","profile","MCP_RUN_API_KEY","JSON","stringify","mcpToolApprovals","specs","out","tool","spec","Object","entries","question","existsSync","readFileSync","join","TheokitAgentError","warningChannel","opts","onWarn","warning","process","stderr","write","McpFileError","TheokitAgentError","name","message","MCP_FILENAME","loadMcpJson","cwd","path","join","existsSync","text","readFileSync","err","describeIt","parsed","JSON","parse","parseMcpJson","raw","source","Array","isArray","serversRaw","mcpServers","undefined","out","entryRaw","Object","entries","reason","validateEntry","buildEntry","entry","hasUrl","url","hasCommand","command","validateRemote","validateStdio","length","args","isStringArray","env","isStringRecord","URL","type","headers","requestTimeoutMs","remote","auth","stdio","Error","String","v","every","x","values","generateAgentManifest","sources","version","generatedAt","Date","toISOString","agents","map","r","name","agentConfig","route","model","stream","mainLoop","method","String","propertyKey","strategy","guards","g","interceptors","i","tools","toolboxes","flatMap","tb","t","namespace","config","description","risk","approval","undefined","capabilities","trace","audit","gateway","platforms","sessionStrategy","subAgents","subAgentClasses","cls","memory","provider","embeddings","fts","scope","skills","include","mcpServers","Object","keys","validateUniqueRoutes","results","seen","Map","r","existing","get","route","undefined","Error","agentConfig","name","set","agentsPlugin","opts","routes","register","app","addHook","pluginCtx","initRoutes","request","url","URL","method","toUpperCase","matched","matchRoute","pathname","handler","allRoutes","routeIdentities","entry","agents","push","createRun","createRunFactory","compiled","defaultCreateRun","generateAgentRoutes","walkResult","compiledOptions","compileRoutePatterns","_message","_sessionId","Promise","resolve","type","runId","Date","now","agentName","model","code","message","retryable","map","path","includes","regexSource","replace","regex","RegExp","find","test"]}
@@ -517,6 +517,174 @@ function reasoningEffortOf(model) {
517
517
  }
518
518
  __name(reasoningEffortOf, "reasoningEffortOf");
519
519
 
520
+ // src/bridge/sdk-adapter-create-options.ts
521
+ import { createRequire } from "module";
522
+ import { TheokitAgentError as TheokitAgentError2 } from "@theokit/sdk/errors";
523
+ var HOOK_GATE_SINCE = {
524
+ major: 5,
525
+ minor: 4
526
+ };
527
+ var HookGateUnsupportedError = class extends TheokitAgentError2 {
528
+ static {
529
+ __name(this, "HookGateUnsupportedError");
530
+ }
531
+ name = "HookGateUnsupportedError";
532
+ constructor(version) {
533
+ super(`a hook approval gate was declared, but the installed @theokit/sdk (${version ?? "version unreadable"}) cannot honour it: \`local.hooks\` landed in ${String(HOOK_GATE_SINCE.major)}.${String(HOOK_GATE_SINCE.minor)}.0. Forwarding it anyway would leave every hook spawning unreviewed while the gate reports as installed. Upgrade @theokit/sdk, or remove \`hookApproval\` and keep whatever refusal you have today (usetheokit/theokit#686).`, {
534
+ code: "hook_gate_unsupported",
535
+ isRetryable: false
536
+ });
537
+ }
538
+ };
539
+ function assertSdkCanGateHooks(version) {
540
+ const [major, minor] = (version ?? "").split(".").map((n) => Number.parseInt(n, 10));
541
+ const known = Number.isFinite(major) && Number.isFinite(minor);
542
+ const supported = known && (major > HOOK_GATE_SINCE.major || major === HOOK_GATE_SINCE.major && minor >= HOOK_GATE_SINCE.minor);
543
+ if (!supported) throw new HookGateUnsupportedError(version);
544
+ }
545
+ __name(assertSdkCanGateHooks, "assertSdkCanGateHooks");
546
+ function installedSdkVersion() {
547
+ try {
548
+ return createRequire(import.meta.url)("@theokit/sdk/package.json").version;
549
+ } catch {
550
+ return void 0;
551
+ }
552
+ }
553
+ __name(installedSdkVersion, "installedSdkVersion");
554
+ var sdkCompatWarningEmitted = false;
555
+ function warnIfSdkCannotReadCompatSources() {
556
+ if (sdkCompatWarningEmitted) return;
557
+ let version;
558
+ try {
559
+ version = createRequire(import.meta.url)("@theokit/sdk/package.json").version;
560
+ } catch {
561
+ return;
562
+ }
563
+ const major = Number.parseInt(version?.split(".")[0] ?? "", 10);
564
+ if (!Number.isFinite(major) || major >= 5) return;
565
+ sdkCompatWarningEmitted = true;
566
+ console.warn(`[theokit/agents] \`compatSources\` was declared, but @theokit/sdk@${version} does not know that option and will ignore it \u2014 the foreign configuration root will NOT be read. It landed in 5.0.0. Until this package's floor can name a stable 5.x, override the SDK in your workspace (usetheokit/theokit#634).`);
567
+ }
568
+ __name(warnIfSdkCannotReadCompatSources, "warnIfSdkCannotReadCompatSources");
569
+ function applyLocalSources(compiled, options, applied) {
570
+ if (compiled.settingSources !== void 0 && compiled.settingSources.length > 0) {
571
+ options.local = {
572
+ ...options.local,
573
+ settingSources: [
574
+ ...compiled.settingSources
575
+ ]
576
+ };
577
+ applied.push("settingSources");
578
+ }
579
+ if (compiled.compatSources !== void 0 && compiled.compatSources.length > 0) {
580
+ options.local = {
581
+ ...options.local,
582
+ compatSources: [
583
+ ...compiled.compatSources
584
+ ]
585
+ };
586
+ applied.push("compatSources");
587
+ warnIfSdkCannotReadCompatSources();
588
+ }
589
+ }
590
+ __name(applyLocalSources, "applyLocalSources");
591
+ function applyHookApproval(compiled, options, applied, sdkVersion) {
592
+ if (compiled.hookApproval === void 0) return;
593
+ assertSdkCanGateHooks(sdkVersion ?? installedSdkVersion());
594
+ options.local = {
595
+ ...options.local,
596
+ hooks: compiled.hookApproval
597
+ };
598
+ applied.push("hookApproval");
599
+ }
600
+ __name(applyHookApproval, "applyHookApproval");
601
+ function assembleM8CreateOptions(compiled, deps = {}) {
602
+ const options = {};
603
+ const applied = [];
604
+ const base = compiled.systemPrompt;
605
+ if (compiled.skills) {
606
+ options.skills = compiled.skills;
607
+ applied.push("skills");
608
+ }
609
+ if (compiled.plugins) {
610
+ options.plugins = compiled.plugins;
611
+ applied.push("plugins");
612
+ }
613
+ applyLocalSources(compiled, options, applied);
614
+ applyHookApproval(compiled, options, applied, deps.sdkVersion);
615
+ if (compiled.context) {
616
+ options.context = compiled.context;
617
+ applied.push("context");
618
+ }
619
+ if (compiled.projectContext) {
620
+ options.systemPrompt = compileProjectContext(compiled.projectContext, base);
621
+ applied.push("projectContext");
622
+ } else if (base !== void 0) {
623
+ options.systemPrompt = base;
624
+ }
625
+ if (compiled.mcpServers && Object.keys(compiled.mcpServers).length > 0) {
626
+ options.mcpServers = compiled.mcpServers;
627
+ applied.push("mcpServers");
628
+ }
629
+ if (compiled.memory !== void 0) {
630
+ if ("enabled" in compiled.memory) {
631
+ options.memory = compiled.memory;
632
+ } else {
633
+ const dropped = Object.keys(compiled.memory);
634
+ if (dropped.length > 0) {
635
+ process.stderr.write(`[theokit-agents] @Memory decorator options not yet mapped to the SDK (${dropped.join(", ")}) \u2014 memory enabled with defaults
636
+ `);
637
+ }
638
+ options.memory = {
639
+ enabled: true
640
+ };
641
+ }
642
+ applied.push("memory");
643
+ }
644
+ return {
645
+ options,
646
+ applied
647
+ };
648
+ }
649
+ __name(assembleM8CreateOptions, "assembleM8CreateOptions");
650
+ function stopReasonOf(result) {
651
+ if (result.stoppedByDoomLoop === true) return "no_progress";
652
+ if (result.stoppedAtIterationLimit === true) return "step_limit";
653
+ return void 0;
654
+ }
655
+ __name(stopReasonOf, "stopReasonOf");
656
+ function realUsageDone(result, t0, model) {
657
+ const u = result.usage;
658
+ const inputTokens = u?.inputTokens ?? 0;
659
+ const outputTokens = u?.outputTokens ?? 0;
660
+ const stopReason = stopReasonOf(result);
661
+ return {
662
+ type: "done",
663
+ result: result.result ?? "",
664
+ // V4-O: forward the SDK reasoning/cache buckets (0 when the provider omits them) so a
665
+ // consumer keeps full per-turn usage through the loop into DelegationResult (passthrough — ADR D1).
666
+ usage: {
667
+ inputTokens,
668
+ outputTokens,
669
+ totalTokens: inputTokens + outputTokens,
670
+ reasoningTokens: u?.reasoningTokens ?? 0,
671
+ cacheReadTokens: u?.cacheReadTokens ?? 0,
672
+ cacheWriteTokens: u?.cacheWriteTokens ?? 0
673
+ },
674
+ durationMs: Date.now() - t0,
675
+ cost: result.cost?.amount ?? 0,
676
+ ...terminalExtras(stopReason, model)
677
+ };
678
+ }
679
+ __name(realUsageDone, "realUsageDone");
680
+ function terminalExtras(stopReason, model) {
681
+ const extras = {};
682
+ if (stopReason !== void 0) extras.stopReason = stopReason;
683
+ if (model !== void 0) extras.model = model;
684
+ return extras;
685
+ }
686
+ __name(terminalExtras, "terminalExtras");
687
+
520
688
  // src/bridge/event-translator.ts
521
689
  function asString(value, fallback) {
522
690
  if (typeof value === "string") return value;
@@ -888,174 +1056,6 @@ function resolveProjection(def, overrides) {
888
1056
  }
889
1057
  __name(resolveProjection, "resolveProjection");
890
1058
 
891
- // src/bridge/sdk-adapter-create-options.ts
892
- import { createRequire } from "module";
893
- import { TheokitAgentError as TheokitAgentError2 } from "@theokit/sdk/errors";
894
- var HOOK_GATE_SINCE = {
895
- major: 5,
896
- minor: 4
897
- };
898
- var HookGateUnsupportedError = class extends TheokitAgentError2 {
899
- static {
900
- __name(this, "HookGateUnsupportedError");
901
- }
902
- name = "HookGateUnsupportedError";
903
- constructor(version) {
904
- super(`a hook approval gate was declared, but the installed @theokit/sdk (${version ?? "version unreadable"}) cannot honour it: \`local.hooks\` landed in ${String(HOOK_GATE_SINCE.major)}.${String(HOOK_GATE_SINCE.minor)}.0. Forwarding it anyway would leave every hook spawning unreviewed while the gate reports as installed. Upgrade @theokit/sdk, or remove \`hookApproval\` and keep whatever refusal you have today (usetheokit/theokit#686).`, {
905
- code: "hook_gate_unsupported",
906
- isRetryable: false
907
- });
908
- }
909
- };
910
- function assertSdkCanGateHooks(version) {
911
- const [major, minor] = (version ?? "").split(".").map((n) => Number.parseInt(n, 10));
912
- const known = Number.isFinite(major) && Number.isFinite(minor);
913
- const supported = known && (major > HOOK_GATE_SINCE.major || major === HOOK_GATE_SINCE.major && minor >= HOOK_GATE_SINCE.minor);
914
- if (!supported) throw new HookGateUnsupportedError(version);
915
- }
916
- __name(assertSdkCanGateHooks, "assertSdkCanGateHooks");
917
- function installedSdkVersion() {
918
- try {
919
- return createRequire(import.meta.url)("@theokit/sdk/package.json").version;
920
- } catch {
921
- return void 0;
922
- }
923
- }
924
- __name(installedSdkVersion, "installedSdkVersion");
925
- var sdkCompatWarningEmitted = false;
926
- function warnIfSdkCannotReadCompatSources() {
927
- if (sdkCompatWarningEmitted) return;
928
- let version;
929
- try {
930
- version = createRequire(import.meta.url)("@theokit/sdk/package.json").version;
931
- } catch {
932
- return;
933
- }
934
- const major = Number.parseInt(version?.split(".")[0] ?? "", 10);
935
- if (!Number.isFinite(major) || major >= 5) return;
936
- sdkCompatWarningEmitted = true;
937
- console.warn(`[theokit/agents] \`compatSources\` was declared, but @theokit/sdk@${version} does not know that option and will ignore it \u2014 the foreign configuration root will NOT be read. It landed in 5.0.0. Until this package's floor can name a stable 5.x, override the SDK in your workspace (usetheokit/theokit#634).`);
938
- }
939
- __name(warnIfSdkCannotReadCompatSources, "warnIfSdkCannotReadCompatSources");
940
- function applyLocalSources(compiled, options, applied) {
941
- if (compiled.settingSources !== void 0 && compiled.settingSources.length > 0) {
942
- options.local = {
943
- ...options.local,
944
- settingSources: [
945
- ...compiled.settingSources
946
- ]
947
- };
948
- applied.push("settingSources");
949
- }
950
- if (compiled.compatSources !== void 0 && compiled.compatSources.length > 0) {
951
- options.local = {
952
- ...options.local,
953
- compatSources: [
954
- ...compiled.compatSources
955
- ]
956
- };
957
- applied.push("compatSources");
958
- warnIfSdkCannotReadCompatSources();
959
- }
960
- }
961
- __name(applyLocalSources, "applyLocalSources");
962
- function applyHookApproval(compiled, options, applied, sdkVersion) {
963
- if (compiled.hookApproval === void 0) return;
964
- assertSdkCanGateHooks(sdkVersion ?? installedSdkVersion());
965
- options.local = {
966
- ...options.local,
967
- hooks: compiled.hookApproval
968
- };
969
- applied.push("hookApproval");
970
- }
971
- __name(applyHookApproval, "applyHookApproval");
972
- function assembleM8CreateOptions(compiled, deps = {}) {
973
- const options = {};
974
- const applied = [];
975
- const base = compiled.systemPrompt;
976
- if (compiled.skills) {
977
- options.skills = compiled.skills;
978
- applied.push("skills");
979
- }
980
- if (compiled.plugins) {
981
- options.plugins = compiled.plugins;
982
- applied.push("plugins");
983
- }
984
- applyLocalSources(compiled, options, applied);
985
- applyHookApproval(compiled, options, applied, deps.sdkVersion);
986
- if (compiled.context) {
987
- options.context = compiled.context;
988
- applied.push("context");
989
- }
990
- if (compiled.projectContext) {
991
- options.systemPrompt = compileProjectContext(compiled.projectContext, base);
992
- applied.push("projectContext");
993
- } else if (base !== void 0) {
994
- options.systemPrompt = base;
995
- }
996
- if (compiled.mcpServers && Object.keys(compiled.mcpServers).length > 0) {
997
- options.mcpServers = compiled.mcpServers;
998
- applied.push("mcpServers");
999
- }
1000
- if (compiled.memory !== void 0) {
1001
- if ("enabled" in compiled.memory) {
1002
- options.memory = compiled.memory;
1003
- } else {
1004
- const dropped = Object.keys(compiled.memory);
1005
- if (dropped.length > 0) {
1006
- process.stderr.write(`[theokit-agents] @Memory decorator options not yet mapped to the SDK (${dropped.join(", ")}) \u2014 memory enabled with defaults
1007
- `);
1008
- }
1009
- options.memory = {
1010
- enabled: true
1011
- };
1012
- }
1013
- applied.push("memory");
1014
- }
1015
- return {
1016
- options,
1017
- applied
1018
- };
1019
- }
1020
- __name(assembleM8CreateOptions, "assembleM8CreateOptions");
1021
- function stopReasonOf(result) {
1022
- if (result.stoppedByDoomLoop === true) return "no_progress";
1023
- if (result.stoppedAtIterationLimit === true) return "step_limit";
1024
- return void 0;
1025
- }
1026
- __name(stopReasonOf, "stopReasonOf");
1027
- function realUsageDone(result, t0, model) {
1028
- const u = result.usage;
1029
- const inputTokens = u?.inputTokens ?? 0;
1030
- const outputTokens = u?.outputTokens ?? 0;
1031
- const stopReason = stopReasonOf(result);
1032
- return {
1033
- type: "done",
1034
- result: result.result ?? "",
1035
- // V4-O: forward the SDK reasoning/cache buckets (0 when the provider omits them) so a
1036
- // consumer keeps full per-turn usage through the loop into DelegationResult (passthrough — ADR D1).
1037
- usage: {
1038
- inputTokens,
1039
- outputTokens,
1040
- totalTokens: inputTokens + outputTokens,
1041
- reasoningTokens: u?.reasoningTokens ?? 0,
1042
- cacheReadTokens: u?.cacheReadTokens ?? 0,
1043
- cacheWriteTokens: u?.cacheWriteTokens ?? 0
1044
- },
1045
- durationMs: Date.now() - t0,
1046
- cost: result.cost?.amount ?? 0,
1047
- ...terminalExtras(stopReason, model)
1048
- };
1049
- }
1050
- __name(realUsageDone, "realUsageDone");
1051
- function terminalExtras(stopReason, model) {
1052
- const extras = {};
1053
- if (stopReason !== void 0) extras.stopReason = stopReason;
1054
- if (model !== void 0) extras.model = model;
1055
- return extras;
1056
- }
1057
- __name(terminalExtras, "terminalExtras");
1058
-
1059
1059
  // src/bridge/sdk-error.ts
1060
1060
  function sdkErrorEvent(err) {
1061
1061
  const sdkErr = err;
@@ -2521,6 +2521,7 @@ export {
2521
2521
  applyPosture,
2522
2522
  buildModelSelection,
2523
2523
  reasoningEffortOf,
2524
+ HookGateUnsupportedError,
2524
2525
  translateSdkEvent,
2525
2526
  createThinkTagExtractor,
2526
2527
  extractThinkTagStream,
@@ -2552,4 +2553,4 @@ export {
2552
2553
  delegateBackground,
2553
2554
  delegateWithScoring
2554
2555
  };
2555
- //# sourceMappingURL=chunk-D6QM7FY5.js.map
2556
+ //# sourceMappingURL=chunk-NZTLBLHB.js.map