@theokit/sdk 5.3.3 → 5.4.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 (83) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/dist/{agent-KJLAWKZB.cjs → agent-AUVD4TI4.cjs} +9 -9
  3. package/dist/{agent-KJLAWKZB.cjs.map → agent-AUVD4TI4.cjs.map} +1 -1
  4. package/dist/{agent-CTbU0O1R.d.ts → agent-Bmy2G_ml.d.ts} +73 -2
  5. package/dist/{agent-QLwxhXY3.d.cts → agent-C1Efo7PI.d.cts} +73 -2
  6. package/dist/{agent-PNYJ5S2Y.js → agent-MNINE73R.js} +8 -8
  7. package/dist/{agent-PNYJ5S2Y.js.map → agent-MNINE73R.js.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-65UMH5V3.cjs → chunk-3FDU5JFE.cjs} +5 -5
  11. package/dist/{chunk-65UMH5V3.cjs.map → chunk-3FDU5JFE.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-363RBGIR.js → chunk-IKBLU7ZS.js} +58 -27
  21. package/dist/chunk-IKBLU7ZS.js.map +1 -0
  22. package/dist/{chunk-L4XENLQO.cjs → chunk-J6KZE2ZQ.cjs} +4 -4
  23. package/dist/{chunk-L4XENLQO.cjs.map → chunk-J6KZE2ZQ.cjs.map} +1 -1
  24. package/dist/{chunk-ZITYGJOD.js → chunk-KWGSBZ2Q.js} +3 -3
  25. package/dist/{chunk-ZITYGJOD.js.map → chunk-KWGSBZ2Q.js.map} +1 -1
  26. package/dist/{chunk-K3NH62DG.js → chunk-KZSKIUXZ.js} +7 -7
  27. package/dist/chunk-KZSKIUXZ.js.map +1 -0
  28. package/dist/{chunk-RP3VXJMA.js → chunk-NSLHPAC7.js} +14 -4
  29. package/dist/chunk-NSLHPAC7.js.map +1 -0
  30. package/dist/{chunk-DLFWMJE3.js → chunk-O7L7M42F.js} +3 -3
  31. package/dist/{chunk-DLFWMJE3.js.map → chunk-O7L7M42F.js.map} +1 -1
  32. package/dist/{chunk-Y46VI73J.cjs → chunk-UALC6Q3J.cjs} +127 -96
  33. package/dist/chunk-UALC6Q3J.cjs.map +1 -0
  34. package/dist/{chunk-7L3MIW2F.js → chunk-XD3FS5OI.js} +3 -3
  35. package/dist/{chunk-7L3MIW2F.js.map → chunk-XD3FS5OI.js.map} +1 -1
  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-FCCJQ3FN.cjs → context-4AIK26QB.cjs} +7 -7
  41. package/dist/{context-FCCJQ3FN.cjs.map → context-4AIK26QB.cjs.map} +1 -1
  42. package/dist/context-EGM6CHXD.js +6 -0
  43. package/dist/{context-BUIE52VH.js.map → context-EGM6CHXD.js.map} +1 -1
  44. package/dist/{cron-Dz8AOpy3.d.cts → cron-DSMdlhyF.d.cts} +1 -1
  45. package/dist/{cron-Cl8FrK3D.d.ts → cron-Dcdrdv_T.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 +25 -1
  64. package/dist/subagents-loader-AIVDQ2D5.js +7 -0
  65. package/dist/{subagents-loader-PAZVOZHI.js.map → subagents-loader-AIVDQ2D5.js.map} +1 -1
  66. package/dist/subagents-loader-DN4LETGL.cjs +16 -0
  67. package/dist/{subagents-loader-7G76XOZU.cjs.map → subagents-loader-DN4LETGL.cjs.map} +1 -1
  68. package/dist/subagents-loader.cjs +3 -3
  69. package/dist/subagents-loader.d.cts +1 -1
  70. package/dist/subagents-loader.d.ts +1 -1
  71. package/dist/subagents-loader.js +2 -2
  72. package/dist/types/agent.d.ts +25 -2
  73. package/dist/types/hooks.d.ts +48 -0
  74. package/package.json +1 -1
  75. package/dist/chunk-2HPNT6HH.cjs.map +0 -1
  76. package/dist/chunk-363RBGIR.js.map +0 -1
  77. package/dist/chunk-DWB3CN46.cjs.map +0 -1
  78. package/dist/chunk-K3NH62DG.js.map +0 -1
  79. package/dist/chunk-RP3VXJMA.js.map +0 -1
  80. package/dist/chunk-Y46VI73J.cjs.map +0 -1
  81. package/dist/context-BUIE52VH.js +0 -6
  82. package/dist/subagents-loader-7G76XOZU.cjs +0 -16
  83. 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 chunk3FDU5JFE_cjs = require('./chunk-3FDU5JFE.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
+ chunk3FDU5JFE_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
+ chunk3FDU5JFE_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
+ chunk3FDU5JFE_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
+ chunk3FDU5JFE_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 chunk3FDU5JFE_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,7 +2650,27 @@ 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) {
2663
+ if (this.gate?.approve === void 0) return false;
2664
+ const request = {
2665
+ command: command.command,
2666
+ event: payload.event,
2667
+ ...command.sourcePath === void 0 ? {} : { sourcePath: command.sourcePath },
2668
+ ...command.matcher === void 0 ? {} : { matcher: command.matcher }
2669
+ };
2670
+ return !await this.gate.approve(request);
2671
+ }
2651
2672
  async executeOne(command, payload) {
2673
+ if (await this.refusedByConsumer(command, payload)) return { decision: "allow" };
2652
2674
  const timeoutMs = command.timeoutMs ?? 3e4;
2653
2675
  const env = runtimeEnvFor(command.sourcePath, this.cwd);
2654
2676
  const result = await spawnAndCollect({
@@ -2659,28 +2681,36 @@ var HooksExecutor = class {
2659
2681
  timeoutMs,
2660
2682
  stdin: JSON.stringify(payload)
2661
2683
  });
2662
- if (result.timedOut) {
2663
- return { decision: "deny", reason: `Hook timed out after ${timeoutMs}ms` };
2664
- }
2684
+ const failure = this.decisionFromFailure(result, command, env, timeoutMs);
2685
+ return failure ?? parseDecisionFromStdout(result.stdout);
2686
+ }
2687
+ /**
2688
+ * A run that did not succeed, turned into a decision. `undefined` when it did.
2689
+ *
2690
+ * Extracted from `executeOne` when the approval gate pushed that function past the complexity
2691
+ * gate. The seam is not arbitrary — every branch here answers one question, "the command did not
2692
+ * run cleanly, so what does this hook decide?", and none of them knows how the command was
2693
+ * spawned.
2694
+ */
2695
+ decisionFromFailure(result, command, env, timeoutMs) {
2696
+ if (result.timedOut) return { decision: "deny", reason: `Hook timed out after ${timeoutMs}ms` };
2665
2697
  if (result.spawnError !== void 0) {
2666
2698
  return { decision: "deny", reason: `Hook spawn failed: ${result.spawnError.message}` };
2667
2699
  }
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);
2700
+ if (result.exitCode === 0) return void 0;
2701
+ const stderr = result.stderr.trim();
2702
+ const base = stderr.length > 0 ? stderr : `Hook exited with code ${result.exitCode}`;
2703
+ const missing = chunk43YXGD3P_cjs.undefinedVariablesIn(command.command, env);
2704
+ if (missing.length === 0) return { decision: "deny", reason: base };
2705
+ return {
2706
+ decision: "deny",
2707
+ 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.`
2708
+ };
2679
2709
  }
2680
2710
  };
2681
2711
  function runtimeEnvFor(sourcePath, cwd) {
2682
2712
  if (sourcePath === void 0) return {};
2683
- return chunkDWB3CN46_cjs.adapterForConfigPath(sourcePath)?.runtimeEnv(cwd) ?? {};
2713
+ return chunk43YXGD3P_cjs.adapterForConfigPath(sourcePath)?.runtimeEnv(cwd) ?? {};
2684
2714
  }
2685
2715
  function parseDecisionFromStdout(stdout) {
2686
2716
  const trimmed = stdout.trim();
@@ -2739,7 +2769,7 @@ async function runPostRunLifecycle(inputs) {
2739
2769
  try {
2740
2770
  const partial = await safeConversation(run);
2741
2771
  if (partial !== void 0) {
2742
- chunkY2KYR2ED_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2772
+ chunkDZG77WU7_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2743
2773
  userText,
2744
2774
  conversation: partial
2745
2775
  });
@@ -2749,11 +2779,11 @@ async function runPostRunLifecycle(inputs) {
2749
2779
  chunk6LHQPOMI_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
2750
2780
  `);
2751
2781
  }
2752
- await chunkY2KYR2ED_cjs.flushSessionWrites();
2782
+ await chunkDZG77WU7_cjs.flushSessionWrites();
2753
2783
  return;
2754
2784
  }
2755
2785
  if (result.result !== void 0) {
2756
- chunkY2KYR2ED_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2786
+ chunkDZG77WU7_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2757
2787
  }
2758
2788
  const conversation = await safeConversation(run);
2759
2789
  const resolvedWindow = resolveWindowForRun(model, contextWindow);
@@ -2764,7 +2794,7 @@ async function runPostRunLifecycle(inputs) {
2764
2794
  }
2765
2795
  const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
2766
2796
  const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
2767
- chunkY2KYR2ED_cjs.persistTurnToTranscript(
2797
+ chunkDZG77WU7_cjs.persistTurnToTranscript(
2768
2798
  sessionStore,
2769
2799
  { cwd: workspaceCwd, agentId, model },
2770
2800
  agentId,
@@ -2776,7 +2806,7 @@ async function runPostRunLifecycle(inputs) {
2776
2806
  // The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
2777
2807
  // `contextWindow` here would budget against a number the clamp already rejected.
2778
2808
  contextWindow: effectiveWindow,
2779
- summarize: chunk2HPNT6HH_cjs.buildDefaultSummarizer({
2809
+ summarize: chunkC4ZQPWXJ_cjs.buildDefaultSummarizer({
2780
2810
  agentModel: model,
2781
2811
  ...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
2782
2812
  })
@@ -2818,7 +2848,7 @@ async function runPostRunLifecycle(inputs) {
2818
2848
  agentId,
2819
2849
  runId: result.id
2820
2850
  });
2821
- await chunkY2KYR2ED_cjs.flushSessionWrites();
2851
+ await chunkDZG77WU7_cjs.flushSessionWrites();
2822
2852
  }
2823
2853
  async function safeConversation(run) {
2824
2854
  try {
@@ -2853,10 +2883,10 @@ var SkillsManager = class {
2853
2883
  }
2854
2884
  async refresh() {
2855
2885
  const roots = this.skillsDir === void 0 ? [
2856
- ...chunkDWB3CN46_cjs.projectConfigRoots(this.cwd, this.compatSources, "skills").map(
2886
+ ...chunk43YXGD3P_cjs.projectConfigRoots(this.cwd, this.compatSources, "skills").map(
2857
2887
  (root) => path.join(root, "skills")
2858
2888
  ),
2859
- ...(await chunkIQBDR5YZ_cjs.pluginBundleDirs(this.cwd, this.compatSources)).map((b) => path.join(b, "skills"))
2889
+ ...(await chunkAYA65JA5_cjs.pluginBundleDirs(this.cwd, this.compatSources)).map((b) => path.join(b, "skills"))
2860
2890
  ] : [this.skillsDir];
2861
2891
  const discovered = [];
2862
2892
  const seen = /* @__PURE__ */ new Set();
@@ -3440,7 +3470,7 @@ var HISTOGRAM_NAMES = {
3440
3470
  };
3441
3471
  function safeRequire(moduleName) {
3442
3472
  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)));
3473
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UALC6Q3J.cjs', document.baseURI).href)));
3444
3474
  return r(moduleName);
3445
3475
  } catch {
3446
3476
  return void 0;
@@ -3683,7 +3713,7 @@ var cachedOtel;
3683
3713
  function loadOtel() {
3684
3714
  if (cachedOtel === void 0) {
3685
3715
  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)));
3716
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UALC6Q3J.cjs', document.baseURI).href)));
3687
3717
  const mod = r("@opentelemetry/api");
3688
3718
  cachedOtel = mod;
3689
3719
  } catch {
@@ -4137,8 +4167,8 @@ var FileContextManager = class {
4137
4167
  }
4138
4168
  };
4139
4169
  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");
4170
+ const mdDir = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "context");
4171
+ const jsonPath = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "context.json");
4142
4172
  const mdEntities = await loadMarkdownEntities({
4143
4173
  dir: mdDir,
4144
4174
  schema: ContextSourceFrontmatterSchema,
@@ -4147,7 +4177,7 @@ async function loadContextConfig(cwd) {
4147
4177
  });
4148
4178
  if (mdEntities.length > 0) {
4149
4179
  if (fs.existsSync(jsonPath)) {
4150
- chunk65UMH5V3_cjs.warnOnce(
4180
+ chunk3FDU5JFE_cjs.warnOnce(
4151
4181
  "context-both-present",
4152
4182
  "[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
4153
4183
  );
@@ -4157,7 +4187,7 @@ async function loadContextConfig(cwd) {
4157
4187
  };
4158
4188
  }
4159
4189
  if (!fs.existsSync(jsonPath)) return { sources: [] };
4160
- chunk65UMH5V3_cjs.warnOnce(
4190
+ chunk3FDU5JFE_cjs.warnOnce(
4161
4191
  "context-json-deprecated",
4162
4192
  // Names no command: `theokit-migrate-config` was unpublished with the `bin` entry, and a warning
4163
4193
  // that tells you to run something the package does not ship is worse than one that tells you
@@ -4298,7 +4328,7 @@ var PluginsManager = class {
4298
4328
  }
4299
4329
  async refresh() {
4300
4330
  this.plugins = [];
4301
- for (const pluginsRoot of chunkDWB3CN46_cjs.pluginBundleRoots(this.cwd, this.compatSources)) {
4331
+ for (const pluginsRoot of chunk43YXGD3P_cjs.pluginBundleRoots(this.cwd, this.compatSources)) {
4302
4332
  await this.refreshRoot(pluginsRoot);
4303
4333
  }
4304
4334
  }
@@ -4320,13 +4350,13 @@ var PluginsManager = class {
4320
4350
  const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
4321
4351
  const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(this.cwd, pluginsRoot, folderName) : await loadPluginManifestFromJson(this.cwd, jsonPath, folderName);
4322
4352
  if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
4323
- chunk65UMH5V3_cjs.warnOnce(
4353
+ chunk3FDU5JFE_cjs.warnOnce(
4324
4354
  `plugin-${folderName}-both`,
4325
4355
  `[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
4326
4356
  );
4327
4357
  }
4328
4358
  if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
4329
- chunk65UMH5V3_cjs.warnOnce(
4359
+ chunk3FDU5JFE_cjs.warnOnce(
4330
4360
  "plugin-json-deprecated",
4331
4361
  // Same reason as the context.json warning: the CLI it used to name is no longer published.
4332
4362
  "[theokit-sdk] plugin.json manifests are deprecated; replace each with a PLUGIN.md"
@@ -6418,7 +6448,7 @@ function applyToolResultGuard(parts, opts) {
6418
6448
  (p) => (
6419
6449
  // SE7 — guard the TEXT of a tool result (string or the text blocks of a
6420
6450
  // structured content); image blocks pass through untouched.
6421
- p.type === "tool_result" ? { ...p, content: chunk2HPNT6HH_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6451
+ p.type === "tool_result" ? { ...p, content: chunkC4ZQPWXJ_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6422
6452
  )
6423
6453
  );
6424
6454
  }
@@ -6710,13 +6740,13 @@ var FallbackLlmClient = class {
6710
6740
  async *stream(request, signal) {
6711
6741
  let lastError;
6712
6742
  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);
6743
+ if (signal.aborted) throw chunkC4ZQPWXJ_cjs.abortError(signal);
6744
+ const attempt = await chunkC4ZQPWXJ_cjs.tryFirstEvent(client, request, signal, true);
6715
6745
  if (attempt.kind === "handshake_error") {
6716
6746
  lastError = attempt.error;
6717
6747
  continue;
6718
6748
  }
6719
- return yield* chunk2HPNT6HH_cjs.relayStream(attempt.generator, attempt.firstResult);
6749
+ return yield* chunkC4ZQPWXJ_cjs.relayStream(attempt.generator, attempt.firstResult);
6720
6750
  }
6721
6751
  if (lastError !== void 0) throw lastError;
6722
6752
  throw new chunkJ7J7J2GN_cjs.NetworkError("FallbackLlmClient has no providers configured", {
@@ -7216,7 +7246,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
7216
7246
  if (exposedSet.has(name)) continue;
7217
7247
  const hint = suggestClosest(name, exposedSet);
7218
7248
  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(
7249
+ chunk3FDU5JFE_cjs.warnOnce(
7220
7250
  `personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
7221
7251
  message
7222
7252
  );
@@ -7352,9 +7382,9 @@ function buildLoopInputs(options, runId, userText, userImages) {
7352
7382
  { code: "invalid_max_iterations" }
7353
7383
  );
7354
7384
  }
7355
- const { primary, effectiveModelId } = chunk2HPNT6HH_cjs.resolveRunProvider(options);
7385
+ const { primary, effectiveModelId } = chunkC4ZQPWXJ_cjs.resolveRunProvider(options);
7356
7386
  const fallback = options.agentOptions.providers?.fallback;
7357
- const apiKeys = chunk2HPNT6HH_cjs.mergeExplicitApiKey(
7387
+ const apiKeys = chunkC4ZQPWXJ_cjs.mergeExplicitApiKey(
7358
7388
  options.agentOptions.providers?.apiKeys,
7359
7389
  primary,
7360
7390
  options.agentOptions.apiKey
@@ -7363,7 +7393,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
7363
7393
  const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
7364
7394
  const rateLimitSink = options.sendOptions.onRunEvent;
7365
7395
  const modelBaseUrl = options.model?.url;
7366
- const chain = chunk2HPNT6HH_cjs.resolveProviderChain({
7396
+ const chain = chunkC4ZQPWXJ_cjs.resolveProviderChain({
7367
7397
  primary,
7368
7398
  ...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
7369
7399
  ...fallback !== void 0 ? { fallback } : {},
@@ -7623,7 +7653,7 @@ function buildRealRunOptions(args) {
7623
7653
  };
7624
7654
  }
7625
7655
  async function createFixtureRunHelper(args) {
7626
- const sessionMessages = chunkY2KYR2ED_cjs.getSessionMessages(args.inputs.agentId);
7656
+ const sessionMessages = chunkDZG77WU7_cjs.getSessionMessages(args.inputs.agentId);
7627
7657
  const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
7628
7658
  return createLocalRun({
7629
7659
  agentId: args.inputs.agentId,
@@ -7642,7 +7672,7 @@ async function createFixtureRunHelper(args) {
7642
7672
  }
7643
7673
  async function dispatchLocalRun(args) {
7644
7674
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(args.inputs.options.apiKey);
7645
- if (chunk2HPNT6HH_cjs.shouldUseRealLocalRuntime(apiKey)) {
7675
+ if (chunkC4ZQPWXJ_cjs.shouldUseRealLocalRuntime(apiKey)) {
7646
7676
  return createRealLocalRun(
7647
7677
  buildRealRunOptions({
7648
7678
  inputs: args.inputs,
@@ -7665,7 +7695,7 @@ async function dispatchLocalRun(args) {
7665
7695
  });
7666
7696
  }
7667
7697
  async function readProjectMcpServers(cwd) {
7668
- const path$1 = path.join(chunkDWB3CN46_cjs.theokitConfigRoot(cwd), "mcp.json");
7698
+ const path$1 = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "mcp.json");
7669
7699
  try {
7670
7700
  const raw = await promises.readFile(path$1, "utf8");
7671
7701
  const parsed = JSON.parse(raw);
@@ -7898,16 +7928,16 @@ async function disposeLocalAgentSession(agent) {
7898
7928
  agent.lifecycleAbortController.abort();
7899
7929
  await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
7900
7930
  disposeSessionMcpClients(agent.agentId);
7901
- await chunkY2KYR2ED_cjs.flushSessionWrites();
7931
+ await chunkDZG77WU7_cjs.flushSessionWrites();
7902
7932
  await flushRegistrySaves(agent.workspaceCwd);
7903
7933
  await disposeSessionStore(agent.sessionStore);
7904
- chunkY2KYR2ED_cjs.discardSession(agent.workspaceCwd, agent.agentId);
7934
+ chunkDZG77WU7_cjs.discardSession(agent.workspaceCwd, agent.agentId);
7905
7935
  }
7906
7936
  async function reloadLocalAgent(agent) {
7907
7937
  if (agent.context !== void 0) await agent.context.refresh();
7908
7938
  if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
7909
7939
  if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
7910
- return await chunkIQBDR5YZ_cjs.loadSubagents(
7940
+ return await chunkAYA65JA5_cjs.loadSubagents(
7911
7941
  agent.workspaceCwd,
7912
7942
  agent.settingSourcesIncludeProject,
7913
7943
  agent.options.agents
@@ -8765,7 +8795,7 @@ var LocalAgentMemory = class {
8765
8795
  async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
8766
8796
  const cfg = this.options.memory?.activeRecall;
8767
8797
  if (cfg?.enabled !== true || this.index === void 0) return void 0;
8768
- if (this.breaker === void 0) this.breaker = new chunk2HPNT6HH_cjs.CircuitBreaker();
8798
+ if (this.breaker === void 0) this.breaker = new chunkC4ZQPWXJ_cjs.CircuitBreaker();
8769
8799
  if (this.cache === void 0) this.cache = new ActiveMemoryCache();
8770
8800
  const result = await runActiveMemory({
8771
8801
  userText,
@@ -8941,7 +8971,7 @@ var PersonalityRegistry = class _PersonalityRegistry {
8941
8971
  * @internal
8942
8972
  */
8943
8973
  static async load(cwd) {
8944
- const projectDir = path.join(chunkDWB3CN46_cjs.theokitConfigRoot(cwd), PERSONALITIES_SUFFIX);
8974
+ const projectDir = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), PERSONALITIES_SUFFIX);
8945
8975
  const userDir = path.join(os.homedir(), USER_SUBDIR);
8946
8976
  const [userEntities, projectEntities] = await Promise.all([
8947
8977
  loadMarkdownEntities({
@@ -8993,7 +9023,7 @@ function addEntity(byName, entity, origin, collisionMap) {
8993
9023
  );
8994
9024
  }
8995
9025
  if (origin === "project" && collisionMap?.has(fm.name)) {
8996
- chunk65UMH5V3_cjs.warnOnce(
9026
+ chunk3FDU5JFE_cjs.warnOnce(
8997
9027
  `personality-collision-${fm.name}`,
8998
9028
  `[theokit-sdk] personality "${fm.name}" overridden by project preset`
8999
9029
  );
@@ -9043,14 +9073,14 @@ async function performPersonalitySwitch(args) {
9043
9073
 
9044
9074
  // src/internal/local-agent/local-agent-personality-extensions.ts
9045
9075
  function resolveActivePersonalityPreset(args) {
9046
- const forkCtx = chunk65UMH5V3_cjs.currentPersonalityContext();
9076
+ const forkCtx = chunk3FDU5JFE_cjs.currentPersonalityContext();
9047
9077
  const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
9048
9078
  if (slug === void 0) return void 0;
9049
9079
  return args.personalityRegistry?.get(slug);
9050
9080
  }
9051
9081
  async function ensurePersonalityRegistryIfNeeded(args) {
9052
9082
  if (args.personalityRegistry !== void 0) return args.personalityRegistry;
9053
- const forkSlug = chunk65UMH5V3_cjs.currentPersonalityContext()?.slug;
9083
+ const forkSlug = chunk3FDU5JFE_cjs.currentPersonalityContext()?.slug;
9054
9084
  const ownSlug = args.personalityStore.active(args.agentId);
9055
9085
  if (forkSlug === void 0 && ownSlug === void 0) return void 0;
9056
9086
  return await PersonalityRegistry.load(args.workspaceCwd);
@@ -9063,8 +9093,8 @@ function applyPersonalityOverlay(preset, base) {
9063
9093
  ${preset.systemPrompt}`;
9064
9094
  }
9065
9095
  async function localAgentUsePersonality(agent, name, opts) {
9066
- if (chunk65UMH5V3_cjs.currentPersonalityContext() !== void 0) {
9067
- chunk65UMH5V3_cjs.warnPersonalitySwitchInsideFork(agent.agentId);
9096
+ if (chunk3FDU5JFE_cjs.currentPersonalityContext() !== void 0) {
9097
+ chunk3FDU5JFE_cjs.warnPersonalitySwitchInsideFork(agent.agentId);
9068
9098
  return null;
9069
9099
  }
9070
9100
  if (agent.personalityRegistry === void 0) {
@@ -9080,8 +9110,8 @@ async function localAgentUsePersonality(agent, name, opts) {
9080
9110
  registry,
9081
9111
  store: agent.personalityStore,
9082
9112
  invalidateCache: (reason) => agent.invalidateCache(reason),
9083
- appendSessionMessage: (msg) => chunkY2KYR2ED_cjs.appendSessionMessage(agent.agentId, msg),
9084
- clearSession: () => chunkY2KYR2ED_cjs.clearSession(agent.agentId),
9113
+ appendSessionMessage: (msg) => chunkDZG77WU7_cjs.appendSessionMessage(agent.agentId, msg),
9114
+ clearSession: () => chunkDZG77WU7_cjs.clearSession(agent.agentId),
9085
9115
  opts: opts ?? {}
9086
9116
  })
9087
9117
  );
@@ -9125,7 +9155,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
9125
9155
  async function localAgentFork(parent, options) {
9126
9156
  const { forkAgentImpl } = await import('./fork-agent-WAEQI2DL.cjs');
9127
9157
  const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
9128
- const { withPersonalityContext } = await import('./context-FCCJQ3FN.cjs');
9158
+ const { withPersonalityContext } = await import('./context-4AIK26QB.cjs');
9129
9159
  const create = getAgentFacade().create;
9130
9160
  return withPersonalityContext(
9131
9161
  { slug: parent.personalitySlugSnapshot, isFork: true },
@@ -9635,7 +9665,7 @@ async function executeSendLocked(inputs, message, options) {
9635
9665
  if (inputs.options.onBeforeSend !== void 0) {
9636
9666
  await inputs.options.onBeforeSend({
9637
9667
  conversationId: inputs.agentId,
9638
- previousMessageCount: chunkY2KYR2ED_cjs.getSessionMessages(inputs.agentId).length
9668
+ previousMessageCount: chunkDZG77WU7_cjs.getSessionMessages(inputs.agentId).length
9639
9669
  });
9640
9670
  }
9641
9671
  await inputs.runPreHook(userText);
@@ -9647,8 +9677,8 @@ async function executeSendLocked(inputs, message, options) {
9647
9677
  userText,
9648
9678
  sendOptions: options
9649
9679
  });
9650
- const priorMessages = [...chunkY2KYR2ED_cjs.getSessionMessages(inputs.agentId)];
9651
- chunkY2KYR2ED_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9680
+ const priorMessages = [...chunkDZG77WU7_cjs.getSessionMessages(inputs.agentId)];
9681
+ chunkDZG77WU7_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9652
9682
  await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
9653
9683
  const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory, userText);
9654
9684
  const memoryTools = void 0;
@@ -9767,6 +9797,7 @@ var KNOWN_LOCAL_OPTION_KEYS = /* @__PURE__ */ new Set([
9767
9797
  "cwd",
9768
9798
  "settingSources",
9769
9799
  "compatSources",
9800
+ "hooks",
9770
9801
  "sandboxOptions",
9771
9802
  "sessionDir",
9772
9803
  "baseDir",
@@ -9917,8 +9948,8 @@ var LocalAgent = class {
9917
9948
  if (sub.plugins !== void 0) this.plugins = sub.plugins;
9918
9949
  reportUnknownLocalOptions(options.local);
9919
9950
  const compatSources = resolveCompatSources(options, this.workspaceCwd);
9920
- chunkDWB3CN46_cjs.reportUndeclaredSources(this.workspaceCwd, compatSources);
9921
- this.hooksExecutor = new HooksExecutor(this.workspaceCwd, compatSources);
9951
+ chunk43YXGD3P_cjs.reportUndeclaredSources(this.workspaceCwd, compatSources);
9952
+ this.hooksExecutor = new HooksExecutor(this.workspaceCwd, compatSources, options.local?.hooks);
9922
9953
  this.defaultMemoryProviderForLoop = createLocalAgentMemoryProvider({
9923
9954
  agentOptions: options,
9924
9955
  workspaceCwd: this.workspaceCwd,
@@ -9945,7 +9976,7 @@ var LocalAgent = class {
9945
9976
  if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
9946
9977
  const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
9947
9978
  await this.pluginManagerCode.initialize(codePlugins);
9948
- this.resolvedSubagents = await chunkIQBDR5YZ_cjs.loadSubagents(
9979
+ this.resolvedSubagents = await chunkAYA65JA5_cjs.loadSubagents(
9949
9980
  this.workspaceCwd,
9950
9981
  this.settingSourcesIncludeProject,
9951
9982
  this.options.agents,
@@ -9953,7 +9984,7 @@ var LocalAgent = class {
9953
9984
  );
9954
9985
  await acquireLeaseIfPossible(this.sessionStore, this.agentId);
9955
9986
  try {
9956
- await chunkY2KYR2ED_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
9987
+ await chunkDZG77WU7_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
9957
9988
  await this.personalityStore.hydrate(this.agentId);
9958
9989
  } catch (err) {
9959
9990
  await releaseLeaseIfPossible(this.sessionStore, this.agentId);
@@ -10294,15 +10325,15 @@ async function maybeInjectHandoffTools(options) {
10294
10325
  };
10295
10326
  }
10296
10327
  function keyWillFlowToProvider(apiKey, provider) {
10297
- if (chunk2HPNT6HH_cjs.isFixtureApiKey(apiKey)) return false;
10298
- if (chunk2HPNT6HH_cjs.getConfiguredBaseUrl() !== void 0) return false;
10328
+ if (chunkC4ZQPWXJ_cjs.isFixtureApiKey(apiKey)) return false;
10329
+ if (chunkC4ZQPWXJ_cjs.getConfiguredBaseUrl() !== void 0) return false;
10299
10330
  if (provider === void 0) return false;
10300
10331
  const profile = chunkANMJJD6D_cjs.getProviderProfile(provider);
10301
10332
  if (profile === void 0) return false;
10302
10333
  return profile.authType !== "none";
10303
10334
  }
10304
10335
  function missingApiKeyMessage() {
10305
- const present = chunk2HPNT6HH_cjs.presentProviderCredentialEnvVars();
10336
+ const present = chunkC4ZQPWXJ_cjs.presentProviderCredentialEnvVars();
10306
10337
  const base = `Missing API key \u2014 set ${chunk6LHQPOMI_cjs.API_KEY_ENV_VAR}, or pass \`apiKey\` to Agent.create()`;
10307
10338
  if (present.length === 0) return `${base}.`;
10308
10339
  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 +10353,7 @@ async function createLocalAgent(options) {
10322
10353
  }
10323
10354
  } else {
10324
10355
  const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
10325
- const shape = chunk2HPNT6HH_cjs.validateApiKeyShape(apiKey, {
10356
+ const shape = chunkC4ZQPWXJ_cjs.validateApiKeyShape(apiKey, {
10326
10357
  strict: willFlowToProvider,
10327
10358
  ...willFlowToProvider ? { provider } : {}
10328
10359
  });
@@ -10341,15 +10372,15 @@ async function createCloudAgent(options) {
10341
10372
  code: "missing_api_key"
10342
10373
  });
10343
10374
  }
10344
- const shape = chunk2HPNT6HH_cjs.validateApiKeyShape(apiKey);
10375
+ const shape = chunkC4ZQPWXJ_cjs.validateApiKeyShape(apiKey);
10345
10376
  if (shape.malformed) {
10346
10377
  throw new chunkJ7J7J2GN_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
10347
10378
  }
10348
- const baseUrl = chunk2HPNT6HH_cjs.getConfiguredBaseUrl();
10379
+ const baseUrl = chunkC4ZQPWXJ_cjs.getConfiguredBaseUrl();
10349
10380
  if (baseUrl === void 0) {
10350
10381
  return new CloudAgent(options);
10351
10382
  }
10352
- const response = await chunk2HPNT6HH_cjs.httpRequest("/v1/agents", {
10383
+ const response = await chunkC4ZQPWXJ_cjs.httpRequest("/v1/agents", {
10353
10384
  apiKey,
10354
10385
  method: "POST",
10355
10386
  body: {
@@ -10374,7 +10405,7 @@ function resolveAgentPersistenceCwd(options) {
10374
10405
  return process.cwd();
10375
10406
  }
10376
10407
  async function rehydrateExistingAgent(agentId, existing, options) {
10377
- await chunk2HPNT6HH_cjs.discoverProviderPlugins();
10408
+ await chunkC4ZQPWXJ_cjs.discoverProviderPlugins();
10378
10409
  await validateRehydratedAgent(agentId, existing);
10379
10410
  const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
10380
10411
  const mergedOptions = {
@@ -10525,7 +10556,7 @@ var Agent = class _Agent {
10525
10556
  pluginCount: enabledPluginNames(options.plugins).length
10526
10557
  });
10527
10558
  try {
10528
- await chunk2HPNT6HH_cjs.discoverProviderPlugins();
10559
+ await chunkC4ZQPWXJ_cjs.discoverProviderPlugins();
10529
10560
  const agent = await runCreateUnderSpan(options, span);
10530
10561
  return agent;
10531
10562
  } catch (err) {
@@ -10823,9 +10854,9 @@ var Agent = class _Agent {
10823
10854
  */
10824
10855
  static async compact(agentId, options = {}) {
10825
10856
  const reg = await requireLocalAgent(agentId, "compact");
10826
- const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-BHTPCIHA.cjs');
10857
+ const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-7FMYJXQ7.cjs');
10827
10858
  const { cwd, model, store } = await openLocalStore(reg);
10828
- return chunkY2KYR2ED_cjs.enqueueSessionWrite(
10859
+ return chunkDZG77WU7_cjs.enqueueSessionWrite(
10829
10860
  cwd,
10830
10861
  agentId,
10831
10862
  () => compactSessionTranscript({
@@ -10850,7 +10881,7 @@ var Agent = class _Agent {
10850
10881
  */
10851
10882
  static async injectSessionTurn(agentId, turn) {
10852
10883
  const reg = await requireLocalAgent(agentId, "injectSessionTurn");
10853
- const { injectSessionTurn } = await import('./inject-session-W6A46J3E.cjs');
10884
+ const { injectSessionTurn } = await import('./inject-session-PC73TMP2.cjs');
10854
10885
  const { cwd, model, store } = await openLocalStore(reg);
10855
10886
  await injectSessionTurn({
10856
10887
  store,
@@ -10901,7 +10932,7 @@ var Agent = class _Agent {
10901
10932
  */
10902
10933
  static async describe(agentId) {
10903
10934
  const agent = await getRegisteredAgentOrThrow(agentId);
10904
- const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-7G76XOZU.cjs');
10935
+ const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-DN4LETGL.cjs');
10905
10936
  const settingSources = agent.options.local?.settingSources;
10906
10937
  const subagents = await loadSubagents2(
10907
10938
  agent.cwd ?? process.cwd(),
@@ -11019,5 +11050,5 @@ exports.generateCronId = generateCronId;
11019
11050
  exports.getPricingEntry = getPricingEntry;
11020
11051
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
11021
11052
  exports.resolveSessionDir = resolveSessionDir;
11022
- //# sourceMappingURL=chunk-Y46VI73J.cjs.map
11023
- //# sourceMappingURL=chunk-Y46VI73J.cjs.map
11053
+ //# sourceMappingURL=chunk-UALC6Q3J.cjs.map
11054
+ //# sourceMappingURL=chunk-UALC6Q3J.cjs.map