@theokit/agents 7.6.0 → 8.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.
Files changed (52) hide show
  1. package/dist/{agent-handle-BX4oFqfb.d.ts → agent-handle-Dgi4ZGbg.d.ts} +11 -1
  2. package/dist/ask.d.ts +190 -0
  3. package/dist/ask.js +167 -0
  4. package/dist/ask.js.map +1 -0
  5. package/dist/auth.d.ts +95 -1
  6. package/dist/auth.js +83 -0
  7. package/dist/auth.js.map +1 -1
  8. package/dist/{bridge-entry-CvmBrmc9.d.ts → bridge-entry-BEniSXWE.d.ts} +223 -700
  9. package/dist/bridge.d.ts +6 -3
  10. package/dist/bridge.js +16 -8
  11. package/dist/chunk-4VHCH6IZ.js +181 -0
  12. package/dist/chunk-4VHCH6IZ.js.map +1 -0
  13. package/dist/{chunk-22IPZFVT.js → chunk-C7UXZWVY.js} +167 -207
  14. package/dist/chunk-C7UXZWVY.js.map +1 -0
  15. package/dist/{chunk-2BAFKRXT.js → chunk-M6HMASZC.js} +9 -4
  16. package/dist/chunk-M6HMASZC.js.map +1 -0
  17. package/dist/client-react.d.ts +2 -1
  18. package/dist/client-react.js +1 -1
  19. package/dist/client.d.ts +3 -2
  20. package/dist/client.js +1 -1
  21. package/dist/commands.d.ts +120 -0
  22. package/dist/commands.js +145 -0
  23. package/dist/commands.js.map +1 -0
  24. package/dist/define-agent-3Kuf6iKM.d.ts +633 -0
  25. package/dist/doctor.d.ts +119 -0
  26. package/dist/doctor.js +84 -0
  27. package/dist/doctor.js.map +1 -0
  28. package/dist/hook-handlers-Cw2FsnE5.d.ts +56 -0
  29. package/dist/hooks.d.ts +225 -0
  30. package/dist/hooks.js +286 -0
  31. package/dist/hooks.js.map +1 -0
  32. package/dist/index.d.ts +170 -26
  33. package/dist/index.js +90 -22
  34. package/dist/index.js.map +1 -1
  35. package/dist/mcp-health.d.ts +69 -0
  36. package/dist/mcp-health.js +42 -0
  37. package/dist/mcp-health.js.map +1 -0
  38. package/dist/session.d.ts +238 -0
  39. package/dist/session.js +338 -0
  40. package/dist/session.js.map +1 -0
  41. package/dist/testing.d.ts +90 -1
  42. package/dist/testing.js +76 -1
  43. package/dist/testing.js.map +1 -1
  44. package/dist/tool-scope.d.ts +133 -0
  45. package/dist/tool-scope.js +61 -0
  46. package/dist/tool-scope.js.map +1 -0
  47. package/dist/usage.d.ts +98 -0
  48. package/dist/usage.js +55 -0
  49. package/dist/usage.js.map +1 -0
  50. package/package.json +34 -2
  51. package/dist/chunk-22IPZFVT.js.map +0 -1
  52. package/dist/chunk-2BAFKRXT.js.map +0 -1
@@ -1,3 +1,8 @@
1
+ import {
2
+ compileAgentDefinition,
3
+ defineAgent,
4
+ isAgentDefinition
5
+ } from "./chunk-4VHCH6IZ.js";
1
6
  import {
2
7
  __name
3
8
  } from "./chunk-Z4QWC7IK.js";
@@ -5,142 +10,6 @@ import {
5
10
  // src/errors.ts
6
11
  import { ConfigurationError } from "@theokit/sdk/errors";
7
12
 
8
- // src/bridge/define-agent.ts
9
- var AGENT_BRAND = /* @__PURE__ */ Symbol.for("theokit.agent.definition");
10
- function defineAgent(config) {
11
- return {
12
- ...config,
13
- [AGENT_BRAND]: true
14
- };
15
- }
16
- __name(defineAgent, "defineAgent");
17
- function isAgentDefinition(value) {
18
- return typeof value === "object" && value !== null && value[AGENT_BRAND] === true;
19
- }
20
- __name(isAgentDefinition, "isAgentDefinition");
21
- function toCompiledTool(tool) {
22
- const handler = tool.handler;
23
- const compiled = {
24
- name: tool.name,
25
- description: tool.description,
26
- inputSchema: tool.inputSchema,
27
- handler: /* @__PURE__ */ __name((input, ctx) => handler(input, ctx), "handler")
28
- };
29
- for (const sym of Object.getOwnPropertySymbols(tool)) {
30
- ;
31
- compiled[sym] = tool[sym];
32
- }
33
- return compiled;
34
- }
35
- __name(toCompiledTool, "toCompiledTool");
36
- function compileAgentDefinition(def) {
37
- return {
38
- model: def.model,
39
- reasoningEffort: def.reasoningEffort,
40
- systemPrompt: def.system,
41
- tools: (def.tools ?? []).map(toCompiledTool),
42
- agents: {},
43
- stream: true,
44
- // M7 — run-context flows to CompiledAgentOptions.runContext (distinct from the
45
- // context-window `context` field the decorator path uses); absent ⇒ no key.
46
- ...def.context !== void 0 ? {
47
- runContext: def.context
48
- } : {},
49
- // M9 — guardrails flow through unchanged; the runner applies them at the input boundary.
50
- ...def.guardrails !== void 0 ? {
51
- guardrails: def.guardrails
52
- } : {},
53
- // M14 — HITL approvals compile into the same `hitl` map the decorator path produces.
54
- ...def.approvals !== void 0 ? {
55
- hitl: compileApprovals(def)
56
- } : {},
57
- // M13 — skills: a static list → SDK skills.enabled; a resolver → carried for the request path.
58
- ...compileSkillsSelection(def.skills),
59
- // theokit-file-based-config — the declared `.theokit/` sources flow to the run path, which
60
- // projects them into `Agent.create({ local.settingSources })`; absent ⇒ inline config only.
61
- ...def.settingSources !== void 0 ? {
62
- settingSources: def.settingSources
63
- } : {},
64
- // M49 — memory flows to the projection layer; `assembleM8CreateOptions` forwards it to Agent.create.
65
- ...def.memory !== void 0 ? {
66
- memory: def.memory
67
- } : {},
68
- // Hooks are converted here — the layer EVERY path converges on — rather than on the builder, so
69
- // `defineAgent({ hooks })` cannot type-check and silently no-op. A lifecycle hook that is
70
- // declared but never registered is a security gate that does not gate.
71
- ...compileHooksAndPlugins(def),
72
- // MCP — builder/`defineAgent` servers converge on the same `mcpServers` field the `@MCP`
73
- // decorator path populates; the SDK adapter forwards it to `Agent.create({ mcpServers })`.
74
- ...def.mcpServers !== void 0 ? {
75
- mcpServers: def.mcpServers
76
- } : {}
77
- };
78
- }
79
- __name(compileAgentDefinition, "compileAgentDefinition");
80
- function compileHooksAndPlugins(def) {
81
- const map = def.hooks;
82
- const entries = Object.entries(map ?? {}).filter(([, h]) => typeof h === "function");
83
- const explicit = def.plugins ?? [];
84
- if (entries.length === 0) {
85
- return def.plugins !== void 0 ? {
86
- plugins: def.plugins
87
- } : {};
88
- }
89
- const plugin = {
90
- name: "theokit-builder-hooks",
91
- version: "1.0.0",
92
- kind: "general",
93
- register(ctx) {
94
- for (const [hookName, handler] of entries) {
95
- ctx.on(hookName, handler);
96
- }
97
- }
98
- };
99
- return {
100
- plugins: [
101
- ...explicit,
102
- plugin
103
- ]
104
- };
105
- }
106
- __name(compileHooksAndPlugins, "compileHooksAndPlugins");
107
- function compileSkillsSelection(skills) {
108
- if (skills === void 0) return {};
109
- if (typeof skills === "function") return {
110
- skillsResolver: skills
111
- };
112
- const enabled = [];
113
- const inline = [];
114
- for (const entry of skills) {
115
- if (typeof entry === "string") enabled.push(entry);
116
- else inline.push(entry);
117
- }
118
- return {
119
- skills: {
120
- enabled,
121
- autoInject: true,
122
- ...inline.length > 0 ? {
123
- inline
124
- } : {}
125
- }
126
- };
127
- }
128
- __name(compileSkillsSelection, "compileSkillsSelection");
129
- function compileApprovals(def) {
130
- const toolNames = new Set((def.tools ?? []).map((t) => t.name));
131
- const gates = /* @__PURE__ */ new Map();
132
- for (const [toolName, options] of Object.entries(def.approvals ?? {})) {
133
- if (!toolNames.has(toolName)) {
134
- throw new Error(`[@theokit/agents] defineAgent approval references unknown tool "${toolName}". Declared tools: ${[
135
- ...toolNames
136
- ].join(", ") || "(none)"}.`);
137
- }
138
- gates.set(toolName, options);
139
- }
140
- return gates;
141
- }
142
- __name(compileApprovals, "compileApprovals");
143
-
144
13
  // src/bridge/compile-context-window.ts
145
14
  var STRATEGY_KNOBS = [
146
15
  "compactionStrategy",
@@ -456,27 +325,38 @@ function generateAgentRoutes(ctx) {
456
325
  __name(generateAgentRoutes, "generateAgentRoutes");
457
326
 
458
327
  // src/guardrails/types.ts
459
- var GuardrailViolationError = class extends Error {
328
+ import { TheokitAgentError } from "@theokit/sdk/errors";
329
+ var GuardrailViolationError = class extends TheokitAgentError {
460
330
  static {
461
331
  __name(this, "GuardrailViolationError");
462
332
  }
463
333
  guardName;
464
334
  phase;
465
335
  reason;
336
+ name = "GuardrailViolationError";
466
337
  constructor(guardName, phase, reason) {
467
- super(`Guardrail "${guardName}" blocked ${phase}: ${reason}`), this.guardName = guardName, this.phase = phase, this.reason = reason;
468
- this.name = "GuardrailViolationError";
338
+ super(`Guardrail "${guardName}" blocked ${phase}: ${reason}`, {
339
+ code: "GUARDRAIL_VIOLATION",
340
+ // A blocked prompt is a REFUSAL, not a hiccup. Retrying re-submits the very input a
341
+ // prompt-injection or PII guard just rejected.
342
+ isRetryable: false
343
+ }), this.guardName = guardName, this.phase = phase, this.reason = reason;
469
344
  }
470
345
  };
471
- var CostBudgetExceededError = class extends Error {
346
+ var CostBudgetExceededError = class extends TheokitAgentError {
472
347
  static {
473
348
  __name(this, "CostBudgetExceededError");
474
349
  }
475
350
  usedTokens;
476
351
  maxTokens;
352
+ name = "CostBudgetExceededError";
477
353
  constructor(usedTokens, maxTokens) {
478
- super(`Cost budget exceeded: ${usedTokens} > ${maxTokens} tokens`), this.usedTokens = usedTokens, this.maxTokens = maxTokens;
479
- this.name = "CostBudgetExceededError";
354
+ super(`Cost budget exceeded: ${usedTokens} > ${maxTokens} tokens`, {
355
+ code: "COST_BUDGET_EXCEEDED",
356
+ // The budget does not refill on retry; retrying spends the next request against the same
357
+ // exhausted ceiling.
358
+ isRetryable: false
359
+ }), this.usedTokens = usedTokens, this.maxTokens = maxTokens;
480
360
  }
481
361
  };
482
362
 
@@ -1149,6 +1029,9 @@ function posturePlugins(posturePolicy, gated) {
1149
1029
  })
1150
1030
  ];
1151
1031
  case "auto-approve":
1032
+ if (!posturePolicy.confinedBy.enforced) {
1033
+ throw new Error(`[@theokit/agents] approval posture "auto-approve" claims confinement ("${posturePolicy.reason}"), but the sandbox reports it is NOT enforced: ${posturePolicy.confinedBy.detail} (mode: ${posturePolicy.confinedBy.mode}). Auto-approving gated tools without enforced confinement runs arbitrary commands with no human and no sandbox. Use "interactive" (a human decides) or "auto-reject" (fail-closed) until the sandbox reports enforced.`);
1034
+ }
1152
1035
  return [
1153
1036
  createToolHooksPlugin({
1154
1037
  beforeToolCall: /* @__PURE__ */ __name((ctx) => {
@@ -1212,11 +1095,12 @@ function assembleM8CreateOptions(compiled) {
1212
1095
  options.plugins = compiled.plugins;
1213
1096
  applied.push("plugins");
1214
1097
  }
1215
- const settingSources = resolveSettingSources(compiled);
1216
- if (settingSources) {
1098
+ if (compiled.settingSources !== void 0 && compiled.settingSources.length > 0) {
1217
1099
  options.local = {
1218
1100
  ...options.local,
1219
- settingSources
1101
+ settingSources: [
1102
+ ...compiled.settingSources
1103
+ ]
1220
1104
  };
1221
1105
  applied.push("settingSources");
1222
1106
  }
@@ -1255,17 +1139,6 @@ function assembleM8CreateOptions(compiled) {
1255
1139
  };
1256
1140
  }
1257
1141
  __name(assembleM8CreateOptions, "assembleM8CreateOptions");
1258
- function resolveSettingSources(compiled) {
1259
- const explicit = compiled.settingSources;
1260
- if (explicit && explicit.length > 0) return [
1261
- ...explicit
1262
- ];
1263
- if (compiled.skills) return [
1264
- "project"
1265
- ];
1266
- return void 0;
1267
- }
1268
- __name(resolveSettingSources, "resolveSettingSources");
1269
1142
  function realUsageDone(result, t0) {
1270
1143
  const u = result.usage;
1271
1144
  const inputTokens = u?.inputTokens ?? 0;
@@ -1947,6 +1820,20 @@ function makeBuilder(config) {
1947
1820
  tool
1948
1821
  ]
1949
1822
  }), "tool"),
1823
+ tools: /* @__PURE__ */ __name((list) => makeBuilder({
1824
+ ...config,
1825
+ tools: [
1826
+ ...config.tools ?? [],
1827
+ ...list
1828
+ ]
1829
+ }), "tools"),
1830
+ // `when` is deliberately not a conditional-typed return: the branch runs or it does not, and
1831
+ // either way the caller gets a builder carrying the same accumulated state. Returning `builder`
1832
+ // unchanged on `false` is what makes it a true no-op rather than a reset.
1833
+ when: /* @__PURE__ */ __name((condition, apply) => {
1834
+ const builder = makeBuilder(config);
1835
+ return condition ? apply(builder) : builder;
1836
+ }, "when"),
1950
1837
  guardrail: /* @__PURE__ */ __name((g) => makeBuilder({
1951
1838
  ...config,
1952
1839
  guardrails: [
@@ -1973,9 +1860,9 @@ function makeBuilder(config) {
1973
1860
  ...config,
1974
1861
  skills: selection
1975
1862
  }), "skills"),
1976
- settingSources: /* @__PURE__ */ __name((sources) => makeBuilder({
1863
+ settingSources: /* @__PURE__ */ __name((selection) => makeBuilder({
1977
1864
  ...config,
1978
- settingSources: sources
1865
+ settingSources: selection
1979
1866
  }), "settingSources"),
1980
1867
  memory: /* @__PURE__ */ __name((settings) => makeBuilder({
1981
1868
  ...config,
@@ -2010,13 +1897,18 @@ var AgentBuilder = {
2010
1897
  };
2011
1898
 
2012
1899
  // src/bridge/agent-endpoint.ts
2013
- var AgentDefinitionError = class extends Error {
1900
+ import { TheokitAgentError as TheokitAgentError2 } from "@theokit/sdk/errors";
1901
+ var AgentDefinitionError = class extends TheokitAgentError2 {
2014
1902
  static {
2015
1903
  __name(this, "AgentDefinitionError");
2016
1904
  }
1905
+ name = "AgentDefinitionError";
2017
1906
  constructor(source) {
2018
- super(`[@theokit/agents] ${source}: an agents/ file must default-export a defineAgent(...) value or an @Agent-decorated class.`);
2019
- this.name = "AgentDefinitionError";
1907
+ super(`[@theokit/agents] ${source}: an agents/ file must default-export a defineAgent(...) value or an @Agent-decorated class.`, {
1908
+ code: "AGENT_DEFINITION_INVALID",
1909
+ // a malformed module does not become well-formed by being loaded twice.
1910
+ isRetryable: false
1911
+ });
2020
1912
  }
2021
1913
  };
2022
1914
  function extractDefaultExport(mod) {
@@ -2262,28 +2154,39 @@ var noopReflectionStrategy = {
2262
2154
  };
2263
2155
 
2264
2156
  // src/bridge/delegation-types.ts
2265
- var DelegationBudgetExceededError = class extends Error {
2157
+ import { TheokitAgentError as TheokitAgentError3 } from "@theokit/sdk/errors";
2158
+ var DelegationBudgetExceededError = class extends TheokitAgentError3 {
2266
2159
  static {
2267
2160
  __name(this, "DelegationBudgetExceededError");
2268
2161
  }
2269
2162
  agentName;
2270
2163
  actualCost;
2271
2164
  budgetLimit;
2165
+ name = "DelegationBudgetExceededError";
2272
2166
  constructor(agentName, actualCost, budgetLimit) {
2273
- super(`Agent "${agentName}" exceeded budget: $${actualCost.toFixed(4)} > $${budgetLimit.toFixed(4)}`), this.agentName = agentName, this.actualCost = actualCost, this.budgetLimit = budgetLimit;
2274
- this.name = "DelegationBudgetExceededError";
2167
+ super(`Agent "${agentName}" exceeded budget: $${actualCost.toFixed(4)} > $${budgetLimit.toFixed(4)}`, {
2168
+ code: "DELEGATION_BUDGET_EXCEEDED",
2169
+ // The budget does not refill on retry.
2170
+ isRetryable: false
2171
+ }), this.agentName = agentName, this.actualCost = actualCost, this.budgetLimit = budgetLimit;
2275
2172
  }
2276
2173
  };
2277
2174
  var BudgetExceededError = DelegationBudgetExceededError;
2278
- var DelegationError = class extends Error {
2175
+ var DelegationError = class extends TheokitAgentError3 {
2279
2176
  static {
2280
2177
  __name(this, "DelegationError");
2281
2178
  }
2282
2179
  agentName;
2283
2180
  cause;
2181
+ name = "DelegationError";
2284
2182
  constructor(agentName, cause) {
2285
- super(`Delegation to agent "${agentName}" failed: ${cause instanceof Error ? cause.message : String(cause)}`), this.agentName = agentName, this.cause = cause;
2286
- this.name = "DelegationError";
2183
+ super(`Delegation to agent "${agentName}" failed: ${cause instanceof Error ? cause.message : String(cause)}`, {
2184
+ code: "DELEGATION_FAILED",
2185
+ // Not retryable AT THIS LEVEL: whether the underlying cause is transient is the cause's own
2186
+ // answer, and `cause` is carried so a caller can ask it rather than guess from the wrapper.
2187
+ isRetryable: false,
2188
+ cause
2189
+ }), this.agentName = agentName, this.cause = cause;
2287
2190
  }
2288
2191
  };
2289
2192
 
@@ -2757,6 +2660,36 @@ var GoalRunner = class {
2757
2660
  }
2758
2661
  };
2759
2662
 
2663
+ // src/loop/format-goal-event.ts
2664
+ function formatGoalEvent(event) {
2665
+ const candidate = event;
2666
+ if (candidate === null || typeof candidate !== "object" || typeof candidate.type !== "string") {
2667
+ return "[goal] unrecognised event (malformed)";
2668
+ }
2669
+ switch (event.type) {
2670
+ case "turn_start":
2671
+ return `[goal] turn ${event.turn} started \u2014 ${event.goal}`;
2672
+ case "agent_response":
2673
+ return `[goal] turn ${event.turn} response: ${event.content}`;
2674
+ case "judge_verdict":
2675
+ return `[goal] turn ${event.turn} judged ${event.verdict}: ${event.reason}` + // Surfaced rather than hidden: a verdict the judge could not parse reached a decision by
2676
+ // fallback, and an operator reading the log needs to know which of the two happened.
2677
+ (event.parseFailed ? " (verdict could not be parsed)" : "");
2678
+ case "continuation":
2679
+ return `[goal] turn ${event.turn} continuing: ${event.prompt}`;
2680
+ case "status_change":
2681
+ return `[goal] status ${event.status}: ${event.reason}`;
2682
+ default:
2683
+ return formatUnrecognised(event);
2684
+ }
2685
+ }
2686
+ __name(formatGoalEvent, "formatGoalEvent");
2687
+ function formatUnrecognised(event) {
2688
+ const { type } = event;
2689
+ return `[goal] unrecognised event: ${String(type)}`;
2690
+ }
2691
+ __name(formatUnrecognised, "formatUnrecognised");
2692
+
2760
2693
  // src/bridge/agent-orchestrator.ts
2761
2694
  function requireApiKey(opts, agentName) {
2762
2695
  const apiKey = opts.apiKey ?? "";
@@ -2842,11 +2775,69 @@ function createApiErrorHandler(policy) {
2842
2775
  }
2843
2776
  __name(createApiErrorHandler, "createApiErrorHandler");
2844
2777
 
2778
+ // src/bridge/delegation-lifecycle.ts
2779
+ import { TheokitAgentError as TheokitAgentError4 } from "@theokit/sdk/errors";
2780
+ var DelegationTimeoutError = class extends TheokitAgentError4 {
2781
+ static {
2782
+ __name(this, "DelegationTimeoutError");
2783
+ }
2784
+ name = "DelegationTimeoutError";
2785
+ constructor(subAgent, timeoutMs) {
2786
+ super(`delegation to "${subAgent}" exceeded its ${String(timeoutMs)} ms clock cap. This is a WALL CLOCK limit, not a budget: the run may have been progressing and simply slow, or hung. Raise \`timeoutMs\` if the work legitimately takes longer.`, {
2787
+ code: "DELEGATION_TIMEOUT",
2788
+ // A hang is often transient — the model, a tool or a network call. Unlike the budget errors,
2789
+ // this one is worth another attempt, which is exactly why it is a separate class.
2790
+ isRetryable: true
2791
+ });
2792
+ }
2793
+ };
2794
+ async function withClockCap(promise, timeoutMs, subAgent) {
2795
+ let timer;
2796
+ const clock = new Promise((_resolve, reject) => {
2797
+ timer = setTimeout(() => {
2798
+ reject(new DelegationTimeoutError(subAgent, timeoutMs));
2799
+ }, timeoutMs);
2800
+ });
2801
+ try {
2802
+ return await Promise.race([
2803
+ promise,
2804
+ clock
2805
+ ]);
2806
+ } finally {
2807
+ if (timer !== void 0) clearTimeout(timer);
2808
+ }
2809
+ }
2810
+ __name(withClockCap, "withClockCap");
2811
+ async function withEphemeralAgent(create, body, options = {}) {
2812
+ const { agent, dispose } = await create();
2813
+ try {
2814
+ return await body(agent);
2815
+ } finally {
2816
+ try {
2817
+ await dispose();
2818
+ } catch (error) {
2819
+ options.onDisposeError?.(error);
2820
+ }
2821
+ }
2822
+ }
2823
+ __name(withEphemeralAgent, "withEphemeralAgent");
2824
+
2845
2825
  // src/bridge/delegation-scoring.ts
2826
+ function isPort(target) {
2827
+ return typeof target.run === "function";
2828
+ }
2829
+ __name(isPort, "isPort");
2830
+ async function runOnce(target, message, delegateFn, opts) {
2831
+ const port = isPort(target);
2832
+ const started = port ? target.run(message) : delegateFn(target, message, opts);
2833
+ if (opts.timeoutMs === void 0) return started;
2834
+ return withClockCap(started, opts.timeoutMs, port ? "port" : target.name);
2835
+ }
2836
+ __name(runOnce, "runOnce");
2846
2837
  function delegateBackground(subAgent, message, opts = {}) {
2847
2838
  const { delegateFn = delegate, ...delegateOpts } = opts;
2848
2839
  let isSettled = false;
2849
- const promise = delegateFn(subAgent, message, delegateOpts).finally(() => {
2840
+ const promise = runOnce(subAgent, message, delegateFn, delegateOpts).finally(() => {
2850
2841
  isSettled = true;
2851
2842
  });
2852
2843
  promise.catch(() => void 0);
@@ -2870,7 +2861,7 @@ async function delegateWithScoring(subAgent, message, opts) {
2870
2861
  let currentMessage = message;
2871
2862
  let lastResult;
2872
2863
  for (let round = 1; round <= maxRounds; round++) {
2873
- const result = await delegateFn(subAgent, currentMessage, delegateOpts);
2864
+ const result = await runOnce(subAgent, currentMessage, delegateFn, delegateOpts);
2874
2865
  lastResult = result;
2875
2866
  const verdict = await scorer(result);
2876
2867
  verdicts.push(verdict);
@@ -2964,7 +2955,7 @@ __name(mcpToolApprovals, "mcpToolApprovals");
2964
2955
  // src/bridge/mcp-file.ts
2965
2956
  import { existsSync, readFileSync } from "fs";
2966
2957
  import { join } from "path";
2967
- import { TheokitAgentError } from "@theokit/sdk/errors";
2958
+ import { TheokitAgentError as TheokitAgentError5 } from "@theokit/sdk/errors";
2968
2959
  function warningChannel(opts) {
2969
2960
  return opts.onWarn ?? ((warning) => {
2970
2961
  process.stderr.write(`[@theokit/agents] ${warning}
@@ -2972,7 +2963,7 @@ function warningChannel(opts) {
2972
2963
  });
2973
2964
  }
2974
2965
  __name(warningChannel, "warningChannel");
2975
- var McpFileError = class extends TheokitAgentError {
2966
+ var McpFileError = class extends TheokitAgentError5 {
2976
2967
  static {
2977
2968
  __name(this, "McpFileError");
2978
2969
  }
@@ -3097,35 +3088,6 @@ function isStringRecord(v) {
3097
3088
  }
3098
3089
  __name(isStringRecord, "isStringRecord");
3099
3090
 
3100
- // src/bridge/setting-sources-gate.ts
3101
- import { TheokitAgentError as TheokitAgentError2 } from "@theokit/sdk/errors";
3102
- var UntrustedSettingSourceError = class extends TheokitAgentError2 {
3103
- static {
3104
- __name(this, "UntrustedSettingSourceError");
3105
- }
3106
- trustSource;
3107
- capability;
3108
- name = "UntrustedSettingSourceError";
3109
- constructor(message, trustSource, capability) {
3110
- super(message), this.trustSource = trustSource, this.capability = capability;
3111
- }
3112
- };
3113
- function resolveSettingSources2(selection) {
3114
- if (selection === void 0) return [];
3115
- const sources = [];
3116
- if (selection.user === true) sources.push("user");
3117
- const grant = selection.project;
3118
- if (grant !== void 0) {
3119
- const posture = grant.trustedBy;
3120
- if (!posture.allows.projectSettings) {
3121
- throw new UntrustedSettingSourceError(`the \`project\` setting source reads <cwd>/.theokit/ \u2014 including shell-executing hooks \u2014 and the posture does not grant \`projectSettings\` (level: ${posture.level}, decided by: ${posture.source}). Grant it with a trusted posture, or omit \`project\` to read only the operator's own ~/.theokit/.`, posture.source, "projectSettings");
3122
- }
3123
- sources.push("project");
3124
- }
3125
- return sources;
3126
- }
3127
- __name(resolveSettingSources2, "resolveSettingSources");
3128
-
3129
3091
  // src/manifest/agent-manifest.ts
3130
3092
  function generateAgentManifest(sources) {
3131
3093
  return {
@@ -3261,10 +3223,6 @@ __name(matchRoute, "matchRoute");
3261
3223
 
3262
3224
  export {
3263
3225
  ConfigurationError,
3264
- AGENT_BRAND,
3265
- isAgentDefinition,
3266
- compileAgentDefinition,
3267
- compileSkillsSelection,
3268
3226
  compileContextWindow,
3269
3227
  compileSkills,
3270
3228
  toolRuntimeName,
@@ -3325,9 +3283,13 @@ export {
3325
3283
  AgentRunnerBuilder,
3326
3284
  GoalRunner,
3327
3285
  JudgeCredentialError,
3286
+ formatGoalEvent,
3328
3287
  delegate,
3329
3288
  runWithApiErrorHandling,
3330
3289
  createApiErrorHandler,
3290
+ DelegationTimeoutError,
3291
+ withClockCap,
3292
+ withEphemeralAgent,
3331
3293
  delegateBackground,
3332
3294
  delegateWithScoring,
3333
3295
  resolveMcpServers,
@@ -3335,9 +3297,7 @@ export {
3335
3297
  mcpToolApprovals,
3336
3298
  McpFileError,
3337
3299
  loadMcpJson,
3338
- UntrustedSettingSourceError,
3339
- resolveSettingSources2 as resolveSettingSources,
3340
3300
  generateAgentManifest,
3341
3301
  agentsPlugin
3342
3302
  };
3343
- //# sourceMappingURL=chunk-22IPZFVT.js.map
3303
+ //# sourceMappingURL=chunk-C7UXZWVY.js.map