@theokit/sdk 5.3.3 → 5.5.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 (87) hide show
  1. package/CHANGELOG.md +101 -0
  2. package/dist/{agent-CTbU0O1R.d.ts → agent-CjMVbhhY.d.ts} +95 -2
  3. package/dist/{agent-QLwxhXY3.d.cts → agent-DyB_lzrx.d.cts} +95 -2
  4. package/dist/{agent-PNYJ5S2Y.js → agent-G3T7Q3SQ.js} +8 -8
  5. package/dist/{agent-PNYJ5S2Y.js.map → agent-G3T7Q3SQ.js.map} +1 -1
  6. package/dist/{agent-KJLAWKZB.cjs → agent-YWSIHHFM.cjs} +9 -9
  7. package/dist/{agent-KJLAWKZB.cjs.map → agent-YWSIHHFM.cjs.map} +1 -1
  8. package/dist/{chunk-AWINL3ZC.js → chunk-2QKV4CGK.js} +3 -3
  9. package/dist/{chunk-AWINL3ZC.js.map → chunk-2QKV4CGK.js.map} +1 -1
  10. package/dist/{chunk-L4XENLQO.cjs → chunk-2ZLQZHZC.cjs} +4 -4
  11. package/dist/{chunk-L4XENLQO.cjs.map → chunk-2ZLQZHZC.cjs.map} +1 -1
  12. package/dist/{chunk-DWB3CN46.cjs → chunk-43YXGD3P.cjs} +14 -4
  13. package/dist/chunk-43YXGD3P.cjs.map +1 -0
  14. package/dist/{chunk-IQBDR5YZ.cjs → chunk-AYA65JA5.cjs} +5 -5
  15. package/dist/{chunk-IQBDR5YZ.cjs.map → chunk-AYA65JA5.cjs.map} +1 -1
  16. package/dist/{chunk-2HPNT6HH.cjs → chunk-C4ZQPWXJ.cjs} +9 -9
  17. package/dist/chunk-C4ZQPWXJ.cjs.map +1 -0
  18. package/dist/{chunk-Y2KYR2ED.cjs → chunk-DZG77WU7.cjs} +3 -3
  19. package/dist/{chunk-Y2KYR2ED.cjs.map → chunk-DZG77WU7.cjs.map} +1 -1
  20. package/dist/{chunk-K3NH62DG.js → chunk-KZSKIUXZ.js} +7 -7
  21. package/dist/chunk-KZSKIUXZ.js.map +1 -0
  22. package/dist/{chunk-ZITYGJOD.js → chunk-M3ZGRGOG.js} +3 -3
  23. package/dist/{chunk-ZITYGJOD.js.map → chunk-M3ZGRGOG.js.map} +1 -1
  24. package/dist/{chunk-RP3VXJMA.js → chunk-NSLHPAC7.js} +14 -4
  25. package/dist/chunk-NSLHPAC7.js.map +1 -0
  26. package/dist/{chunk-DLFWMJE3.js → chunk-O7L7M42F.js} +3 -3
  27. package/dist/{chunk-DLFWMJE3.js.map → chunk-O7L7M42F.js.map} +1 -1
  28. package/dist/{chunk-363RBGIR.js → chunk-ODBID5TG.js} +63 -27
  29. package/dist/chunk-ODBID5TG.js.map +1 -0
  30. package/dist/{chunk-7L3MIW2F.js → chunk-S6B5XYC3.js} +4 -4
  31. package/dist/chunk-S6B5XYC3.js.map +1 -0
  32. package/dist/{chunk-Y46VI73J.cjs → chunk-UKJJRU7C.cjs} +132 -96
  33. package/dist/chunk-UKJJRU7C.cjs.map +1 -0
  34. package/dist/{chunk-65UMH5V3.cjs → chunk-VY6NKMOA.cjs} +6 -6
  35. package/dist/chunk-VY6NKMOA.cjs.map +1 -0
  36. package/dist/{compact-session-BHTPCIHA.cjs → compact-session-7FMYJXQ7.cjs} +11 -11
  37. package/dist/{compact-session-BHTPCIHA.cjs.map → compact-session-7FMYJXQ7.cjs.map} +1 -1
  38. package/dist/{compact-session-W4WLJTHA.js → compact-session-YSEK7NQF.js} +3 -3
  39. package/dist/{compact-session-W4WLJTHA.js.map → compact-session-YSEK7NQF.js.map} +1 -1
  40. package/dist/context-3HPU754C.js +6 -0
  41. package/dist/{context-BUIE52VH.js.map → context-3HPU754C.js.map} +1 -1
  42. package/dist/{context-FCCJQ3FN.cjs → context-JTGSBJT6.cjs} +7 -7
  43. package/dist/{context-FCCJQ3FN.cjs.map → context-JTGSBJT6.cjs.map} +1 -1
  44. package/dist/{cron-Dz8AOpy3.d.cts → cron-Bgivg88c.d.cts} +1 -1
  45. package/dist/{cron-Cl8FrK3D.d.ts → cron-CNUa7PDo.d.ts} +1 -1
  46. package/dist/cron.cjs +8 -8
  47. package/dist/cron.d.cts +2 -2
  48. package/dist/cron.d.ts +2 -2
  49. package/dist/cron.js +7 -7
  50. package/dist/eval.cjs +7 -7
  51. package/dist/eval.js +6 -6
  52. package/dist/index.cjs +30 -30
  53. package/dist/index.d.cts +3 -3
  54. package/dist/index.d.ts +3 -3
  55. package/dist/index.js +9 -9
  56. package/dist/{inject-session-SUM6TDJF.js → inject-session-J4LBWAPH.js} +3 -3
  57. package/dist/{inject-session-SUM6TDJF.js.map → inject-session-J4LBWAPH.js.map} +1 -1
  58. package/dist/{inject-session-W6A46J3E.cjs → inject-session-PC73TMP2.cjs} +4 -4
  59. package/dist/{inject-session-W6A46J3E.cjs.map → inject-session-PC73TMP2.cjs.map} +1 -1
  60. package/dist/internal/llm/tool-result-content.d.ts +1 -1
  61. package/dist/internal/persistence/index.cjs +4 -4
  62. package/dist/internal/persistence/index.js +1 -1
  63. package/dist/internal/runtime/hooks/hooks-executor.d.ts +35 -1
  64. package/dist/internal/runtime/hooks/hooks-source.d.ts +10 -0
  65. package/dist/subagents-loader-AIVDQ2D5.js +7 -0
  66. package/dist/{subagents-loader-PAZVOZHI.js.map → subagents-loader-AIVDQ2D5.js.map} +1 -1
  67. package/dist/subagents-loader-DN4LETGL.cjs +16 -0
  68. package/dist/{subagents-loader-7G76XOZU.cjs.map → subagents-loader-DN4LETGL.cjs.map} +1 -1
  69. package/dist/subagents-loader.cjs +3 -3
  70. package/dist/subagents-loader.d.cts +1 -1
  71. package/dist/subagents-loader.d.ts +1 -1
  72. package/dist/subagents-loader.js +2 -2
  73. package/dist/types/agent.d.ts +25 -2
  74. package/dist/types/hooks.d.ts +70 -0
  75. package/docs/error-codes.md +4 -4
  76. package/package.json +1 -1
  77. package/dist/chunk-2HPNT6HH.cjs.map +0 -1
  78. package/dist/chunk-363RBGIR.js.map +0 -1
  79. package/dist/chunk-65UMH5V3.cjs.map +0 -1
  80. package/dist/chunk-7L3MIW2F.js.map +0 -1
  81. package/dist/chunk-DWB3CN46.cjs.map +0 -1
  82. package/dist/chunk-K3NH62DG.js.map +0 -1
  83. package/dist/chunk-RP3VXJMA.js.map +0 -1
  84. package/dist/chunk-Y46VI73J.cjs.map +0 -1
  85. package/dist/context-BUIE52VH.js +0 -6
  86. package/dist/subagents-loader-7G76XOZU.cjs +0 -16
  87. package/dist/subagents-loader-PAZVOZHI.js +0 -7
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkKVSAY6NZ_cjs = require('./chunk-KVSAY6NZ.cjs');
4
- var chunkY2KYR2ED_cjs = require('./chunk-Y2KYR2ED.cjs');
4
+ var chunkDZG77WU7_cjs = require('./chunk-DZG77WU7.cjs');
5
5
  var chunkZ2JFX372_cjs = require('./chunk-Z2JFX372.cjs');
6
- var chunk65UMH5V3_cjs = require('./chunk-65UMH5V3.cjs');
6
+ var chunkVY6NKMOA_cjs = require('./chunk-VY6NKMOA.cjs');
7
7
  var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
8
8
  var chunkD6POWE7E_cjs = require('./chunk-D6POWE7E.cjs');
9
9
  var chunkTMKTSYDS_cjs = require('./chunk-TMKTSYDS.cjs');
10
10
  var chunkNQTNSHSB_cjs = require('./chunk-NQTNSHSB.cjs');
11
11
  var chunk7FDKWDA2_cjs = require('./chunk-7FDKWDA2.cjs');
12
- var chunk2HPNT6HH_cjs = require('./chunk-2HPNT6HH.cjs');
12
+ var chunkC4ZQPWXJ_cjs = require('./chunk-C4ZQPWXJ.cjs');
13
13
  var chunk2ZPEDVLM_cjs = require('./chunk-2ZPEDVLM.cjs');
14
14
  var chunkIU5N5224_cjs = require('./chunk-IU5N5224.cjs');
15
15
  var chunkRQMCOFAI_cjs = require('./chunk-RQMCOFAI.cjs');
@@ -26,8 +26,8 @@ var chunkGZV6AVRL_cjs = require('./chunk-GZV6AVRL.cjs');
26
26
  var chunkBJUJT5ED_cjs = require('./chunk-BJUJT5ED.cjs');
27
27
  var chunkZF2LDKQQ_cjs = require('./chunk-ZF2LDKQQ.cjs');
28
28
  var chunkJLRLCBJ4_cjs = require('./chunk-JLRLCBJ4.cjs');
29
- var chunkIQBDR5YZ_cjs = require('./chunk-IQBDR5YZ.cjs');
30
- var chunkDWB3CN46_cjs = require('./chunk-DWB3CN46.cjs');
29
+ var chunkAYA65JA5_cjs = require('./chunk-AYA65JA5.cjs');
30
+ var chunk43YXGD3P_cjs = require('./chunk-43YXGD3P.cjs');
31
31
  var chunkHW7SEELD_cjs = require('./chunk-HW7SEELD.cjs');
32
32
  var chunkATT276RD_cjs = require('./chunk-ATT276RD.cjs');
33
33
  var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
@@ -383,7 +383,7 @@ function serializeAgents(agents2) {
383
383
  return out;
384
384
  }
385
385
  function registryPath(cwd) {
386
- return path.join(chunkDWB3CN46_cjs.theokitConfigRoot(cwd), REGISTRY_RELATIVE_SUFFIX);
386
+ return path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), REGISTRY_RELATIVE_SUFFIX);
387
387
  }
388
388
  async function loadRegistry(cwd) {
389
389
  void chunkJLRLCBJ4_cjs.sweepStaleAtomicTemps(registryPath(cwd)).catch(() => void 0);
@@ -1560,7 +1560,7 @@ function createRealCloudRun(options) {
1560
1560
  conversation: []
1561
1561
  };
1562
1562
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(options.agentOptions.apiKey);
1563
- const baseUrl = chunk2HPNT6HH_cjs.getConfiguredBaseUrl();
1563
+ const baseUrl = chunkC4ZQPWXJ_cjs.getConfiguredBaseUrl();
1564
1564
  const handle = new RealCloudRun(
1565
1565
  {
1566
1566
  id,
@@ -1643,7 +1643,7 @@ var RealCloudRun = class extends FixtureRunBase {
1643
1643
  async consumeStream(response) {
1644
1644
  let finalStatus = "finished";
1645
1645
  let finalText = "";
1646
- for await (const record of chunk2HPNT6HH_cjs.parseSseStream(response.body, this.controller.signal)) {
1646
+ for await (const record of chunkC4ZQPWXJ_cjs.parseSseStream(response.body, this.controller.signal)) {
1647
1647
  const parsed = safeParse(record.data);
1648
1648
  if (parsed === void 0) continue;
1649
1649
  const update = this.applyRecord(record.event, parsed);
@@ -1810,7 +1810,7 @@ var CloudAgent = class _CloudAgent {
1810
1810
  */
1811
1811
  isFixtureMode() {
1812
1812
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(this.options.apiKey);
1813
- return chunk2HPNT6HH_cjs.isFixtureApiKey(apiKey) && chunk2HPNT6HH_cjs.getConfiguredBaseUrl() === void 0;
1813
+ return chunkC4ZQPWXJ_cjs.isFixtureApiKey(apiKey) && chunkC4ZQPWXJ_cjs.getConfiguredBaseUrl() === void 0;
1814
1814
  }
1815
1815
  // SE9 — integrated structured output; delegates to the shared helper.
1816
1816
  generate(message, options) {
@@ -1862,7 +1862,7 @@ var CloudAgent = class _CloudAgent {
1862
1862
  const userText = typeof message === "string" ? message : message.text;
1863
1863
  const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
1864
1864
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(this.options.apiKey);
1865
- const useRealRuntime = apiKey !== void 0 && !chunk2HPNT6HH_cjs.isFixtureApiKey(apiKey) && chunk2HPNT6HH_cjs.getConfiguredBaseUrl() !== void 0;
1865
+ const useRealRuntime = apiKey !== void 0 && !chunkC4ZQPWXJ_cjs.isFixtureApiKey(apiKey) && chunkC4ZQPWXJ_cjs.getConfiguredBaseUrl() !== void 0;
1866
1866
  return useRealRuntime ? createRealCloudRun({
1867
1867
  agentId: this.agentId,
1868
1868
  model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
@@ -2122,14 +2122,14 @@ async function readState(filePath) {
2122
2122
  try {
2123
2123
  parsed = JSON.parse(raw);
2124
2124
  } catch {
2125
- chunk65UMH5V3_cjs.warnOnce(
2125
+ chunkVY6NKMOA_cjs.warnOnce(
2126
2126
  "personality-store-json-parse",
2127
2127
  "[theokit-sdk] personality.json is malformed; treating as empty"
2128
2128
  );
2129
2129
  return emptyState();
2130
2130
  }
2131
2131
  if (!isStateV1(parsed)) {
2132
- chunk65UMH5V3_cjs.warnOnce(
2132
+ chunkVY6NKMOA_cjs.warnOnce(
2133
2133
  "personality-store-bad-version",
2134
2134
  `[theokit-sdk] personality.json has unknown version; treating as empty (file kept untouched)`
2135
2135
  );
@@ -2160,7 +2160,7 @@ var PersonalityStore = class {
2160
2160
  try {
2161
2161
  await this.#persist(agentId, slug);
2162
2162
  } catch (err) {
2163
- chunk65UMH5V3_cjs.warnOnce(
2163
+ chunkVY6NKMOA_cjs.warnOnce(
2164
2164
  `personality-store-persist-failure-${agentId}`,
2165
2165
  `[theokit-sdk] personality persist failed for ${chunk6LHQPOMI_cjs.redactSecrets(agentId)}: ${chunk6LHQPOMI_cjs.redactSecrets(
2166
2166
  err.message
@@ -2177,7 +2177,7 @@ var PersonalityStore = class {
2177
2177
  try {
2178
2178
  state = await readState(filePath);
2179
2179
  } catch (err) {
2180
- chunk65UMH5V3_cjs.warnOnce(
2180
+ chunkVY6NKMOA_cjs.warnOnce(
2181
2181
  `personality-store-hydrate-failure-${agentId}`,
2182
2182
  `[theokit-sdk] personality hydrate failed for ${chunk6LHQPOMI_cjs.redactSecrets(agentId)}: ${chunk6LHQPOMI_cjs.redactSecrets(
2183
2183
  err.message
@@ -2206,7 +2206,7 @@ var PersonalityStore = class {
2206
2206
  });
2207
2207
  }
2208
2208
  #filePath() {
2209
- return path.join(chunkDWB3CN46_cjs.getTheokitHome(this.#cwd), FILE_NAME);
2209
+ return path.join(chunk43YXGD3P_cjs.getTheokitHome(this.#cwd), FILE_NAME);
2210
2210
  }
2211
2211
  };
2212
2212
 
@@ -2523,7 +2523,7 @@ function removeAll(arr, toRemove) {
2523
2523
  }
2524
2524
  }
2525
2525
  function readCompatConfigFile(cwd) {
2526
- const path$1 = path.join(chunkDWB3CN46_cjs.theokitConfigRoot(cwd), "config.json");
2526
+ const path$1 = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "config.json");
2527
2527
  if (!fs.existsSync(path$1)) return [];
2528
2528
  let raw;
2529
2529
  try {
@@ -2603,19 +2603,21 @@ function spawnAndCollect(options) {
2603
2603
 
2604
2604
  // src/internal/runtime/hooks/hooks-executor.ts
2605
2605
  var HooksExecutor = class {
2606
- constructor(cwd, compatSources = []) {
2606
+ constructor(cwd, compatSources = [], gate = void 0) {
2607
2607
  this.cwd = cwd;
2608
2608
  this.compatSources = compatSources;
2609
+ this.gate = gate;
2609
2610
  }
2610
2611
  cwd;
2611
2612
  compatSources;
2613
+ gate;
2612
2614
  config = {};
2613
2615
  async initialize(settingSourcesIncludeProject) {
2614
2616
  if (!settingSourcesIncludeProject) {
2615
2617
  this.config = {};
2616
2618
  return;
2617
2619
  }
2618
- this.config = await chunk65UMH5V3_cjs.loadHookConfig(this.cwd, this.compatSources);
2620
+ this.config = await chunkVY6NKMOA_cjs.loadHookConfig(this.cwd, this.compatSources);
2619
2621
  }
2620
2622
  /** Fire every hook registered for `event` and aggregate the decisions. */
2621
2623
  async run(payload) {
@@ -2648,8 +2650,33 @@ var HooksExecutor = class {
2648
2650
  }
2649
2651
  });
2650
2652
  }
2653
+ /**
2654
+ * #631 — the consumer's gate, consulted at the ONLY point a hook is spawned.
2655
+ *
2656
+ * Here and not at the caller on purpose: a check anywhere else could be reached around by a
2657
+ * second execution path later, and this one cannot — `spawnAndCollect` is called for a hook from
2658
+ * exactly one place.
2659
+ *
2660
+ * No gate means no refusal, which is what every consumer gets today.
2661
+ */
2662
+ async refusedByConsumer(command, payload, timeoutMs) {
2663
+ if (this.gate?.approve === void 0) return false;
2664
+ const request = {
2665
+ command: command.command,
2666
+ event: payload.event,
2667
+ // #637 — the EFFECTIVE timeout, passed in rather than recomputed here, so the number the
2668
+ // consumer is shown and the number `spawnAndCollect` enforces are the same expression.
2669
+ // Recomputing would be one line and would be the place they later diverge.
2670
+ timeoutMs,
2671
+ sourceEvent: command.sourceEvent,
2672
+ ...command.sourcePath === void 0 ? {} : { sourcePath: command.sourcePath },
2673
+ ...command.matcher === void 0 ? {} : { matcher: command.matcher }
2674
+ };
2675
+ return !await this.gate.approve(request);
2676
+ }
2651
2677
  async executeOne(command, payload) {
2652
2678
  const timeoutMs = command.timeoutMs ?? 3e4;
2679
+ if (await this.refusedByConsumer(command, payload, timeoutMs)) return { decision: "allow" };
2653
2680
  const env = runtimeEnvFor(command.sourcePath, this.cwd);
2654
2681
  const result = await spawnAndCollect({
2655
2682
  command: "sh",
@@ -2659,28 +2686,36 @@ var HooksExecutor = class {
2659
2686
  timeoutMs,
2660
2687
  stdin: JSON.stringify(payload)
2661
2688
  });
2662
- if (result.timedOut) {
2663
- return { decision: "deny", reason: `Hook timed out after ${timeoutMs}ms` };
2664
- }
2689
+ const failure = this.decisionFromFailure(result, command, env, timeoutMs);
2690
+ return failure ?? parseDecisionFromStdout(result.stdout);
2691
+ }
2692
+ /**
2693
+ * A run that did not succeed, turned into a decision. `undefined` when it did.
2694
+ *
2695
+ * Extracted from `executeOne` when the approval gate pushed that function past the complexity
2696
+ * gate. The seam is not arbitrary — every branch here answers one question, "the command did not
2697
+ * run cleanly, so what does this hook decide?", and none of them knows how the command was
2698
+ * spawned.
2699
+ */
2700
+ decisionFromFailure(result, command, env, timeoutMs) {
2701
+ if (result.timedOut) return { decision: "deny", reason: `Hook timed out after ${timeoutMs}ms` };
2665
2702
  if (result.spawnError !== void 0) {
2666
2703
  return { decision: "deny", reason: `Hook spawn failed: ${result.spawnError.message}` };
2667
2704
  }
2668
- if (result.exitCode !== 0) {
2669
- const stderr = result.stderr.trim();
2670
- const base = stderr.length > 0 ? stderr : `Hook exited with code ${result.exitCode}`;
2671
- const missing = chunkDWB3CN46_cjs.undefinedVariablesIn(command.command, env);
2672
- if (missing.length === 0) return { decision: "deny", reason: base };
2673
- return {
2674
- decision: "deny",
2675
- reason: `${base} \u2014 this hook came from ${command.sourcePath ?? "an unrecorded source"} and uses ${missing.map((n) => `$${n}`).join(", ")}, which nothing defines here. A variable this runtime does not supply expands to the empty string, so the error above names a path rather than the cause.`
2676
- };
2677
- }
2678
- return parseDecisionFromStdout(result.stdout);
2705
+ if (result.exitCode === 0) return void 0;
2706
+ const stderr = result.stderr.trim();
2707
+ const base = stderr.length > 0 ? stderr : `Hook exited with code ${result.exitCode}`;
2708
+ const missing = chunk43YXGD3P_cjs.undefinedVariablesIn(command.command, env);
2709
+ if (missing.length === 0) return { decision: "deny", reason: base };
2710
+ return {
2711
+ decision: "deny",
2712
+ reason: `${base} \u2014 this hook came from ${command.sourcePath ?? "an unrecorded source"} and uses ${missing.map((n) => `$${n}`).join(", ")}, which nothing defines here. A variable this runtime does not supply expands to the empty string, so the error above names a path rather than the cause.`
2713
+ };
2679
2714
  }
2680
2715
  };
2681
2716
  function runtimeEnvFor(sourcePath, cwd) {
2682
2717
  if (sourcePath === void 0) return {};
2683
- return chunkDWB3CN46_cjs.adapterForConfigPath(sourcePath)?.runtimeEnv(cwd) ?? {};
2718
+ return chunk43YXGD3P_cjs.adapterForConfigPath(sourcePath)?.runtimeEnv(cwd) ?? {};
2684
2719
  }
2685
2720
  function parseDecisionFromStdout(stdout) {
2686
2721
  const trimmed = stdout.trim();
@@ -2739,7 +2774,7 @@ async function runPostRunLifecycle(inputs) {
2739
2774
  try {
2740
2775
  const partial = await safeConversation(run);
2741
2776
  if (partial !== void 0) {
2742
- chunkY2KYR2ED_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2777
+ chunkDZG77WU7_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2743
2778
  userText,
2744
2779
  conversation: partial
2745
2780
  });
@@ -2749,11 +2784,11 @@ async function runPostRunLifecycle(inputs) {
2749
2784
  chunk6LHQPOMI_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
2750
2785
  `);
2751
2786
  }
2752
- await chunkY2KYR2ED_cjs.flushSessionWrites();
2787
+ await chunkDZG77WU7_cjs.flushSessionWrites();
2753
2788
  return;
2754
2789
  }
2755
2790
  if (result.result !== void 0) {
2756
- chunkY2KYR2ED_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2791
+ chunkDZG77WU7_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2757
2792
  }
2758
2793
  const conversation = await safeConversation(run);
2759
2794
  const resolvedWindow = resolveWindowForRun(model, contextWindow);
@@ -2764,7 +2799,7 @@ async function runPostRunLifecycle(inputs) {
2764
2799
  }
2765
2800
  const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
2766
2801
  const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
2767
- chunkY2KYR2ED_cjs.persistTurnToTranscript(
2802
+ chunkDZG77WU7_cjs.persistTurnToTranscript(
2768
2803
  sessionStore,
2769
2804
  { cwd: workspaceCwd, agentId, model },
2770
2805
  agentId,
@@ -2776,7 +2811,7 @@ async function runPostRunLifecycle(inputs) {
2776
2811
  // The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
2777
2812
  // `contextWindow` here would budget against a number the clamp already rejected.
2778
2813
  contextWindow: effectiveWindow,
2779
- summarize: chunk2HPNT6HH_cjs.buildDefaultSummarizer({
2814
+ summarize: chunkC4ZQPWXJ_cjs.buildDefaultSummarizer({
2780
2815
  agentModel: model,
2781
2816
  ...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
2782
2817
  })
@@ -2818,7 +2853,7 @@ async function runPostRunLifecycle(inputs) {
2818
2853
  agentId,
2819
2854
  runId: result.id
2820
2855
  });
2821
- await chunkY2KYR2ED_cjs.flushSessionWrites();
2856
+ await chunkDZG77WU7_cjs.flushSessionWrites();
2822
2857
  }
2823
2858
  async function safeConversation(run) {
2824
2859
  try {
@@ -2853,10 +2888,10 @@ var SkillsManager = class {
2853
2888
  }
2854
2889
  async refresh() {
2855
2890
  const roots = this.skillsDir === void 0 ? [
2856
- ...chunkDWB3CN46_cjs.projectConfigRoots(this.cwd, this.compatSources, "skills").map(
2891
+ ...chunk43YXGD3P_cjs.projectConfigRoots(this.cwd, this.compatSources, "skills").map(
2857
2892
  (root) => path.join(root, "skills")
2858
2893
  ),
2859
- ...(await chunkIQBDR5YZ_cjs.pluginBundleDirs(this.cwd, this.compatSources)).map((b) => path.join(b, "skills"))
2894
+ ...(await chunkAYA65JA5_cjs.pluginBundleDirs(this.cwd, this.compatSources)).map((b) => path.join(b, "skills"))
2860
2895
  ] : [this.skillsDir];
2861
2896
  const discovered = [];
2862
2897
  const seen = /* @__PURE__ */ new Set();
@@ -3440,7 +3475,7 @@ var HISTOGRAM_NAMES = {
3440
3475
  };
3441
3476
  function safeRequire(moduleName) {
3442
3477
  try {
3443
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-Y46VI73J.cjs', document.baseURI).href)));
3478
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UKJJRU7C.cjs', document.baseURI).href)));
3444
3479
  return r(moduleName);
3445
3480
  } catch {
3446
3481
  return void 0;
@@ -3683,7 +3718,7 @@ var cachedOtel;
3683
3718
  function loadOtel() {
3684
3719
  if (cachedOtel === void 0) {
3685
3720
  try {
3686
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-Y46VI73J.cjs', document.baseURI).href)));
3721
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UKJJRU7C.cjs', document.baseURI).href)));
3687
3722
  const mod = r("@opentelemetry/api");
3688
3723
  cachedOtel = mod;
3689
3724
  } catch {
@@ -4137,8 +4172,8 @@ var FileContextManager = class {
4137
4172
  }
4138
4173
  };
4139
4174
  async function loadContextConfig(cwd) {
4140
- const mdDir = path.join(chunkDWB3CN46_cjs.theokitConfigRoot(cwd), "context");
4141
- const jsonPath = path.join(chunkDWB3CN46_cjs.theokitConfigRoot(cwd), "context.json");
4175
+ const mdDir = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "context");
4176
+ const jsonPath = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "context.json");
4142
4177
  const mdEntities = await loadMarkdownEntities({
4143
4178
  dir: mdDir,
4144
4179
  schema: ContextSourceFrontmatterSchema,
@@ -4147,7 +4182,7 @@ async function loadContextConfig(cwd) {
4147
4182
  });
4148
4183
  if (mdEntities.length > 0) {
4149
4184
  if (fs.existsSync(jsonPath)) {
4150
- chunk65UMH5V3_cjs.warnOnce(
4185
+ chunkVY6NKMOA_cjs.warnOnce(
4151
4186
  "context-both-present",
4152
4187
  "[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
4153
4188
  );
@@ -4157,7 +4192,7 @@ async function loadContextConfig(cwd) {
4157
4192
  };
4158
4193
  }
4159
4194
  if (!fs.existsSync(jsonPath)) return { sources: [] };
4160
- chunk65UMH5V3_cjs.warnOnce(
4195
+ chunkVY6NKMOA_cjs.warnOnce(
4161
4196
  "context-json-deprecated",
4162
4197
  // Names no command: `theokit-migrate-config` was unpublished with the `bin` entry, and a warning
4163
4198
  // that tells you to run something the package does not ship is worse than one that tells you
@@ -4298,7 +4333,7 @@ var PluginsManager = class {
4298
4333
  }
4299
4334
  async refresh() {
4300
4335
  this.plugins = [];
4301
- for (const pluginsRoot of chunkDWB3CN46_cjs.pluginBundleRoots(this.cwd, this.compatSources)) {
4336
+ for (const pluginsRoot of chunk43YXGD3P_cjs.pluginBundleRoots(this.cwd, this.compatSources)) {
4302
4337
  await this.refreshRoot(pluginsRoot);
4303
4338
  }
4304
4339
  }
@@ -4320,13 +4355,13 @@ var PluginsManager = class {
4320
4355
  const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
4321
4356
  const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(this.cwd, pluginsRoot, folderName) : await loadPluginManifestFromJson(this.cwd, jsonPath, folderName);
4322
4357
  if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
4323
- chunk65UMH5V3_cjs.warnOnce(
4358
+ chunkVY6NKMOA_cjs.warnOnce(
4324
4359
  `plugin-${folderName}-both`,
4325
4360
  `[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
4326
4361
  );
4327
4362
  }
4328
4363
  if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
4329
- chunk65UMH5V3_cjs.warnOnce(
4364
+ chunkVY6NKMOA_cjs.warnOnce(
4330
4365
  "plugin-json-deprecated",
4331
4366
  // Same reason as the context.json warning: the CLI it used to name is no longer published.
4332
4367
  "[theokit-sdk] plugin.json manifests are deprecated; replace each with a PLUGIN.md"
@@ -6418,7 +6453,7 @@ function applyToolResultGuard(parts, opts) {
6418
6453
  (p) => (
6419
6454
  // SE7 — guard the TEXT of a tool result (string or the text blocks of a
6420
6455
  // structured content); image blocks pass through untouched.
6421
- p.type === "tool_result" ? { ...p, content: chunk2HPNT6HH_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6456
+ p.type === "tool_result" ? { ...p, content: chunkC4ZQPWXJ_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6422
6457
  )
6423
6458
  );
6424
6459
  }
@@ -6710,13 +6745,13 @@ var FallbackLlmClient = class {
6710
6745
  async *stream(request, signal) {
6711
6746
  let lastError;
6712
6747
  for (const client of this.clients) {
6713
- if (signal.aborted) throw chunk2HPNT6HH_cjs.abortError(signal);
6714
- const attempt = await chunk2HPNT6HH_cjs.tryFirstEvent(client, request, signal, true);
6748
+ if (signal.aborted) throw chunkC4ZQPWXJ_cjs.abortError(signal);
6749
+ const attempt = await chunkC4ZQPWXJ_cjs.tryFirstEvent(client, request, signal, true);
6715
6750
  if (attempt.kind === "handshake_error") {
6716
6751
  lastError = attempt.error;
6717
6752
  continue;
6718
6753
  }
6719
- return yield* chunk2HPNT6HH_cjs.relayStream(attempt.generator, attempt.firstResult);
6754
+ return yield* chunkC4ZQPWXJ_cjs.relayStream(attempt.generator, attempt.firstResult);
6720
6755
  }
6721
6756
  if (lastError !== void 0) throw lastError;
6722
6757
  throw new chunkJ7J7J2GN_cjs.NetworkError("FallbackLlmClient has no providers configured", {
@@ -7216,7 +7251,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
7216
7251
  if (exposedSet.has(name)) continue;
7217
7252
  const hint = suggestClosest(name, exposedSet);
7218
7253
  const message = hint !== void 0 ? `[theokit-sdk] personality "${opts?.personalityName ?? "?"}" references unknown tool "${name}"; did you mean "${hint}"?` : `[theokit-sdk] personality "${opts?.personalityName ?? "?"}" references unknown tool "${name}" (not exposed)`;
7219
- chunk65UMH5V3_cjs.warnOnce(
7254
+ chunkVY6NKMOA_cjs.warnOnce(
7220
7255
  `personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
7221
7256
  message
7222
7257
  );
@@ -7352,9 +7387,9 @@ function buildLoopInputs(options, runId, userText, userImages) {
7352
7387
  { code: "invalid_max_iterations" }
7353
7388
  );
7354
7389
  }
7355
- const { primary, effectiveModelId } = chunk2HPNT6HH_cjs.resolveRunProvider(options);
7390
+ const { primary, effectiveModelId } = chunkC4ZQPWXJ_cjs.resolveRunProvider(options);
7356
7391
  const fallback = options.agentOptions.providers?.fallback;
7357
- const apiKeys = chunk2HPNT6HH_cjs.mergeExplicitApiKey(
7392
+ const apiKeys = chunkC4ZQPWXJ_cjs.mergeExplicitApiKey(
7358
7393
  options.agentOptions.providers?.apiKeys,
7359
7394
  primary,
7360
7395
  options.agentOptions.apiKey
@@ -7363,7 +7398,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
7363
7398
  const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
7364
7399
  const rateLimitSink = options.sendOptions.onRunEvent;
7365
7400
  const modelBaseUrl = options.model?.url;
7366
- const chain = chunk2HPNT6HH_cjs.resolveProviderChain({
7401
+ const chain = chunkC4ZQPWXJ_cjs.resolveProviderChain({
7367
7402
  primary,
7368
7403
  ...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
7369
7404
  ...fallback !== void 0 ? { fallback } : {},
@@ -7623,7 +7658,7 @@ function buildRealRunOptions(args) {
7623
7658
  };
7624
7659
  }
7625
7660
  async function createFixtureRunHelper(args) {
7626
- const sessionMessages = chunkY2KYR2ED_cjs.getSessionMessages(args.inputs.agentId);
7661
+ const sessionMessages = chunkDZG77WU7_cjs.getSessionMessages(args.inputs.agentId);
7627
7662
  const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
7628
7663
  return createLocalRun({
7629
7664
  agentId: args.inputs.agentId,
@@ -7642,7 +7677,7 @@ async function createFixtureRunHelper(args) {
7642
7677
  }
7643
7678
  async function dispatchLocalRun(args) {
7644
7679
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(args.inputs.options.apiKey);
7645
- if (chunk2HPNT6HH_cjs.shouldUseRealLocalRuntime(apiKey)) {
7680
+ if (chunkC4ZQPWXJ_cjs.shouldUseRealLocalRuntime(apiKey)) {
7646
7681
  return createRealLocalRun(
7647
7682
  buildRealRunOptions({
7648
7683
  inputs: args.inputs,
@@ -7665,7 +7700,7 @@ async function dispatchLocalRun(args) {
7665
7700
  });
7666
7701
  }
7667
7702
  async function readProjectMcpServers(cwd) {
7668
- const path$1 = path.join(chunkDWB3CN46_cjs.theokitConfigRoot(cwd), "mcp.json");
7703
+ const path$1 = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "mcp.json");
7669
7704
  try {
7670
7705
  const raw = await promises.readFile(path$1, "utf8");
7671
7706
  const parsed = JSON.parse(raw);
@@ -7898,16 +7933,16 @@ async function disposeLocalAgentSession(agent) {
7898
7933
  agent.lifecycleAbortController.abort();
7899
7934
  await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
7900
7935
  disposeSessionMcpClients(agent.agentId);
7901
- await chunkY2KYR2ED_cjs.flushSessionWrites();
7936
+ await chunkDZG77WU7_cjs.flushSessionWrites();
7902
7937
  await flushRegistrySaves(agent.workspaceCwd);
7903
7938
  await disposeSessionStore(agent.sessionStore);
7904
- chunkY2KYR2ED_cjs.discardSession(agent.workspaceCwd, agent.agentId);
7939
+ chunkDZG77WU7_cjs.discardSession(agent.workspaceCwd, agent.agentId);
7905
7940
  }
7906
7941
  async function reloadLocalAgent(agent) {
7907
7942
  if (agent.context !== void 0) await agent.context.refresh();
7908
7943
  if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
7909
7944
  if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
7910
- return await chunkIQBDR5YZ_cjs.loadSubagents(
7945
+ return await chunkAYA65JA5_cjs.loadSubagents(
7911
7946
  agent.workspaceCwd,
7912
7947
  agent.settingSourcesIncludeProject,
7913
7948
  agent.options.agents
@@ -8765,7 +8800,7 @@ var LocalAgentMemory = class {
8765
8800
  async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
8766
8801
  const cfg = this.options.memory?.activeRecall;
8767
8802
  if (cfg?.enabled !== true || this.index === void 0) return void 0;
8768
- if (this.breaker === void 0) this.breaker = new chunk2HPNT6HH_cjs.CircuitBreaker();
8803
+ if (this.breaker === void 0) this.breaker = new chunkC4ZQPWXJ_cjs.CircuitBreaker();
8769
8804
  if (this.cache === void 0) this.cache = new ActiveMemoryCache();
8770
8805
  const result = await runActiveMemory({
8771
8806
  userText,
@@ -8941,7 +8976,7 @@ var PersonalityRegistry = class _PersonalityRegistry {
8941
8976
  * @internal
8942
8977
  */
8943
8978
  static async load(cwd) {
8944
- const projectDir = path.join(chunkDWB3CN46_cjs.theokitConfigRoot(cwd), PERSONALITIES_SUFFIX);
8979
+ const projectDir = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), PERSONALITIES_SUFFIX);
8945
8980
  const userDir = path.join(os.homedir(), USER_SUBDIR);
8946
8981
  const [userEntities, projectEntities] = await Promise.all([
8947
8982
  loadMarkdownEntities({
@@ -8993,7 +9028,7 @@ function addEntity(byName, entity, origin, collisionMap) {
8993
9028
  );
8994
9029
  }
8995
9030
  if (origin === "project" && collisionMap?.has(fm.name)) {
8996
- chunk65UMH5V3_cjs.warnOnce(
9031
+ chunkVY6NKMOA_cjs.warnOnce(
8997
9032
  `personality-collision-${fm.name}`,
8998
9033
  `[theokit-sdk] personality "${fm.name}" overridden by project preset`
8999
9034
  );
@@ -9043,14 +9078,14 @@ async function performPersonalitySwitch(args) {
9043
9078
 
9044
9079
  // src/internal/local-agent/local-agent-personality-extensions.ts
9045
9080
  function resolveActivePersonalityPreset(args) {
9046
- const forkCtx = chunk65UMH5V3_cjs.currentPersonalityContext();
9081
+ const forkCtx = chunkVY6NKMOA_cjs.currentPersonalityContext();
9047
9082
  const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
9048
9083
  if (slug === void 0) return void 0;
9049
9084
  return args.personalityRegistry?.get(slug);
9050
9085
  }
9051
9086
  async function ensurePersonalityRegistryIfNeeded(args) {
9052
9087
  if (args.personalityRegistry !== void 0) return args.personalityRegistry;
9053
- const forkSlug = chunk65UMH5V3_cjs.currentPersonalityContext()?.slug;
9088
+ const forkSlug = chunkVY6NKMOA_cjs.currentPersonalityContext()?.slug;
9054
9089
  const ownSlug = args.personalityStore.active(args.agentId);
9055
9090
  if (forkSlug === void 0 && ownSlug === void 0) return void 0;
9056
9091
  return await PersonalityRegistry.load(args.workspaceCwd);
@@ -9063,8 +9098,8 @@ function applyPersonalityOverlay(preset, base) {
9063
9098
  ${preset.systemPrompt}`;
9064
9099
  }
9065
9100
  async function localAgentUsePersonality(agent, name, opts) {
9066
- if (chunk65UMH5V3_cjs.currentPersonalityContext() !== void 0) {
9067
- chunk65UMH5V3_cjs.warnPersonalitySwitchInsideFork(agent.agentId);
9101
+ if (chunkVY6NKMOA_cjs.currentPersonalityContext() !== void 0) {
9102
+ chunkVY6NKMOA_cjs.warnPersonalitySwitchInsideFork(agent.agentId);
9068
9103
  return null;
9069
9104
  }
9070
9105
  if (agent.personalityRegistry === void 0) {
@@ -9080,8 +9115,8 @@ async function localAgentUsePersonality(agent, name, opts) {
9080
9115
  registry,
9081
9116
  store: agent.personalityStore,
9082
9117
  invalidateCache: (reason) => agent.invalidateCache(reason),
9083
- appendSessionMessage: (msg) => chunkY2KYR2ED_cjs.appendSessionMessage(agent.agentId, msg),
9084
- clearSession: () => chunkY2KYR2ED_cjs.clearSession(agent.agentId),
9118
+ appendSessionMessage: (msg) => chunkDZG77WU7_cjs.appendSessionMessage(agent.agentId, msg),
9119
+ clearSession: () => chunkDZG77WU7_cjs.clearSession(agent.agentId),
9085
9120
  opts: opts ?? {}
9086
9121
  })
9087
9122
  );
@@ -9125,7 +9160,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
9125
9160
  async function localAgentFork(parent, options) {
9126
9161
  const { forkAgentImpl } = await import('./fork-agent-WAEQI2DL.cjs');
9127
9162
  const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
9128
- const { withPersonalityContext } = await import('./context-FCCJQ3FN.cjs');
9163
+ const { withPersonalityContext } = await import('./context-JTGSBJT6.cjs');
9129
9164
  const create = getAgentFacade().create;
9130
9165
  return withPersonalityContext(
9131
9166
  { slug: parent.personalitySlugSnapshot, isFork: true },
@@ -9635,7 +9670,7 @@ async function executeSendLocked(inputs, message, options) {
9635
9670
  if (inputs.options.onBeforeSend !== void 0) {
9636
9671
  await inputs.options.onBeforeSend({
9637
9672
  conversationId: inputs.agentId,
9638
- previousMessageCount: chunkY2KYR2ED_cjs.getSessionMessages(inputs.agentId).length
9673
+ previousMessageCount: chunkDZG77WU7_cjs.getSessionMessages(inputs.agentId).length
9639
9674
  });
9640
9675
  }
9641
9676
  await inputs.runPreHook(userText);
@@ -9647,8 +9682,8 @@ async function executeSendLocked(inputs, message, options) {
9647
9682
  userText,
9648
9683
  sendOptions: options
9649
9684
  });
9650
- const priorMessages = [...chunkY2KYR2ED_cjs.getSessionMessages(inputs.agentId)];
9651
- chunkY2KYR2ED_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9685
+ const priorMessages = [...chunkDZG77WU7_cjs.getSessionMessages(inputs.agentId)];
9686
+ chunkDZG77WU7_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9652
9687
  await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
9653
9688
  const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory, userText);
9654
9689
  const memoryTools = void 0;
@@ -9767,6 +9802,7 @@ var KNOWN_LOCAL_OPTION_KEYS = /* @__PURE__ */ new Set([
9767
9802
  "cwd",
9768
9803
  "settingSources",
9769
9804
  "compatSources",
9805
+ "hooks",
9770
9806
  "sandboxOptions",
9771
9807
  "sessionDir",
9772
9808
  "baseDir",
@@ -9917,8 +9953,8 @@ var LocalAgent = class {
9917
9953
  if (sub.plugins !== void 0) this.plugins = sub.plugins;
9918
9954
  reportUnknownLocalOptions(options.local);
9919
9955
  const compatSources = resolveCompatSources(options, this.workspaceCwd);
9920
- chunkDWB3CN46_cjs.reportUndeclaredSources(this.workspaceCwd, compatSources);
9921
- this.hooksExecutor = new HooksExecutor(this.workspaceCwd, compatSources);
9956
+ chunk43YXGD3P_cjs.reportUndeclaredSources(this.workspaceCwd, compatSources);
9957
+ this.hooksExecutor = new HooksExecutor(this.workspaceCwd, compatSources, options.local?.hooks);
9922
9958
  this.defaultMemoryProviderForLoop = createLocalAgentMemoryProvider({
9923
9959
  agentOptions: options,
9924
9960
  workspaceCwd: this.workspaceCwd,
@@ -9945,7 +9981,7 @@ var LocalAgent = class {
9945
9981
  if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
9946
9982
  const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
9947
9983
  await this.pluginManagerCode.initialize(codePlugins);
9948
- this.resolvedSubagents = await chunkIQBDR5YZ_cjs.loadSubagents(
9984
+ this.resolvedSubagents = await chunkAYA65JA5_cjs.loadSubagents(
9949
9985
  this.workspaceCwd,
9950
9986
  this.settingSourcesIncludeProject,
9951
9987
  this.options.agents,
@@ -9953,7 +9989,7 @@ var LocalAgent = class {
9953
9989
  );
9954
9990
  await acquireLeaseIfPossible(this.sessionStore, this.agentId);
9955
9991
  try {
9956
- await chunkY2KYR2ED_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
9992
+ await chunkDZG77WU7_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
9957
9993
  await this.personalityStore.hydrate(this.agentId);
9958
9994
  } catch (err) {
9959
9995
  await releaseLeaseIfPossible(this.sessionStore, this.agentId);
@@ -10294,15 +10330,15 @@ async function maybeInjectHandoffTools(options) {
10294
10330
  };
10295
10331
  }
10296
10332
  function keyWillFlowToProvider(apiKey, provider) {
10297
- if (chunk2HPNT6HH_cjs.isFixtureApiKey(apiKey)) return false;
10298
- if (chunk2HPNT6HH_cjs.getConfiguredBaseUrl() !== void 0) return false;
10333
+ if (chunkC4ZQPWXJ_cjs.isFixtureApiKey(apiKey)) return false;
10334
+ if (chunkC4ZQPWXJ_cjs.getConfiguredBaseUrl() !== void 0) return false;
10299
10335
  if (provider === void 0) return false;
10300
10336
  const profile = chunkANMJJD6D_cjs.getProviderProfile(provider);
10301
10337
  if (profile === void 0) return false;
10302
10338
  return profile.authType !== "none";
10303
10339
  }
10304
10340
  function missingApiKeyMessage() {
10305
- const present = chunk2HPNT6HH_cjs.presentProviderCredentialEnvVars();
10341
+ const present = chunkC4ZQPWXJ_cjs.presentProviderCredentialEnvVars();
10306
10342
  const base = `Missing API key \u2014 set ${chunk6LHQPOMI_cjs.API_KEY_ENV_VAR}, or pass \`apiKey\` to Agent.create()`;
10307
10343
  if (present.length === 0) return `${base}.`;
10308
10344
  return `${base}. ${present.join(" and ")} ${present.length === 1 ? "is" : "are"} set, but a provider credential is not read from the environment automatically \u2014 pass it explicitly, e.g. \`Agent.create({ apiKey: process.env.${present[0]}, ... })\`.`;
@@ -10322,7 +10358,7 @@ async function createLocalAgent(options) {
10322
10358
  }
10323
10359
  } else {
10324
10360
  const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
10325
- const shape = chunk2HPNT6HH_cjs.validateApiKeyShape(apiKey, {
10361
+ const shape = chunkC4ZQPWXJ_cjs.validateApiKeyShape(apiKey, {
10326
10362
  strict: willFlowToProvider,
10327
10363
  ...willFlowToProvider ? { provider } : {}
10328
10364
  });
@@ -10341,15 +10377,15 @@ async function createCloudAgent(options) {
10341
10377
  code: "missing_api_key"
10342
10378
  });
10343
10379
  }
10344
- const shape = chunk2HPNT6HH_cjs.validateApiKeyShape(apiKey);
10380
+ const shape = chunkC4ZQPWXJ_cjs.validateApiKeyShape(apiKey);
10345
10381
  if (shape.malformed) {
10346
10382
  throw new chunkJ7J7J2GN_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
10347
10383
  }
10348
- const baseUrl = chunk2HPNT6HH_cjs.getConfiguredBaseUrl();
10384
+ const baseUrl = chunkC4ZQPWXJ_cjs.getConfiguredBaseUrl();
10349
10385
  if (baseUrl === void 0) {
10350
10386
  return new CloudAgent(options);
10351
10387
  }
10352
- const response = await chunk2HPNT6HH_cjs.httpRequest("/v1/agents", {
10388
+ const response = await chunkC4ZQPWXJ_cjs.httpRequest("/v1/agents", {
10353
10389
  apiKey,
10354
10390
  method: "POST",
10355
10391
  body: {
@@ -10374,7 +10410,7 @@ function resolveAgentPersistenceCwd(options) {
10374
10410
  return process.cwd();
10375
10411
  }
10376
10412
  async function rehydrateExistingAgent(agentId, existing, options) {
10377
- await chunk2HPNT6HH_cjs.discoverProviderPlugins();
10413
+ await chunkC4ZQPWXJ_cjs.discoverProviderPlugins();
10378
10414
  await validateRehydratedAgent(agentId, existing);
10379
10415
  const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
10380
10416
  const mergedOptions = {
@@ -10525,7 +10561,7 @@ var Agent = class _Agent {
10525
10561
  pluginCount: enabledPluginNames(options.plugins).length
10526
10562
  });
10527
10563
  try {
10528
- await chunk2HPNT6HH_cjs.discoverProviderPlugins();
10564
+ await chunkC4ZQPWXJ_cjs.discoverProviderPlugins();
10529
10565
  const agent = await runCreateUnderSpan(options, span);
10530
10566
  return agent;
10531
10567
  } catch (err) {
@@ -10823,9 +10859,9 @@ var Agent = class _Agent {
10823
10859
  */
10824
10860
  static async compact(agentId, options = {}) {
10825
10861
  const reg = await requireLocalAgent(agentId, "compact");
10826
- const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-BHTPCIHA.cjs');
10862
+ const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-7FMYJXQ7.cjs');
10827
10863
  const { cwd, model, store } = await openLocalStore(reg);
10828
- return chunkY2KYR2ED_cjs.enqueueSessionWrite(
10864
+ return chunkDZG77WU7_cjs.enqueueSessionWrite(
10829
10865
  cwd,
10830
10866
  agentId,
10831
10867
  () => compactSessionTranscript({
@@ -10850,7 +10886,7 @@ var Agent = class _Agent {
10850
10886
  */
10851
10887
  static async injectSessionTurn(agentId, turn) {
10852
10888
  const reg = await requireLocalAgent(agentId, "injectSessionTurn");
10853
- const { injectSessionTurn } = await import('./inject-session-W6A46J3E.cjs');
10889
+ const { injectSessionTurn } = await import('./inject-session-PC73TMP2.cjs');
10854
10890
  const { cwd, model, store } = await openLocalStore(reg);
10855
10891
  await injectSessionTurn({
10856
10892
  store,
@@ -10901,7 +10937,7 @@ var Agent = class _Agent {
10901
10937
  */
10902
10938
  static async describe(agentId) {
10903
10939
  const agent = await getRegisteredAgentOrThrow(agentId);
10904
- const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-7G76XOZU.cjs');
10940
+ const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-DN4LETGL.cjs');
10905
10941
  const settingSources = agent.options.local?.settingSources;
10906
10942
  const subagents = await loadSubagents2(
10907
10943
  agent.cwd ?? process.cwd(),
@@ -11019,5 +11055,5 @@ exports.generateCronId = generateCronId;
11019
11055
  exports.getPricingEntry = getPricingEntry;
11020
11056
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
11021
11057
  exports.resolveSessionDir = resolveSessionDir;
11022
- //# sourceMappingURL=chunk-Y46VI73J.cjs.map
11023
- //# sourceMappingURL=chunk-Y46VI73J.cjs.map
11058
+ //# sourceMappingURL=chunk-UKJJRU7C.cjs.map
11059
+ //# sourceMappingURL=chunk-UKJJRU7C.cjs.map