@theokit/sdk 5.5.0 → 5.7.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 (160) hide show
  1. package/CHANGELOG.md +667 -0
  2. package/dist/{agent-CjMVbhhY.d.ts → agent-Bqzdhkqr.d.ts} +12 -3
  3. package/dist/{agent-DyB_lzrx.d.cts → agent-Dya5SmhY.d.cts} +12 -3
  4. package/dist/{agent-G3T7Q3SQ.js → agent-EQ5HKTWV.js} +15 -14
  5. package/dist/{agent-G3T7Q3SQ.js.map → agent-EQ5HKTWV.js.map} +1 -1
  6. package/dist/{agent-YWSIHHFM.cjs → agent-KA63WDQH.cjs} +16 -15
  7. package/dist/{agent-YWSIHHFM.cjs.map → agent-KA63WDQH.cjs.map} +1 -1
  8. package/dist/agent.d.ts +11 -0
  9. package/dist/{chunk-Z2JFX372.cjs → chunk-33A27NFX.cjs} +15 -15
  10. package/dist/{chunk-Z2JFX372.cjs.map → chunk-33A27NFX.cjs.map} +1 -1
  11. package/dist/{chunk-N6OOOYFZ.js → chunk-3VXQEQE4.js} +13 -4
  12. package/dist/chunk-3VXQEQE4.js.map +1 -0
  13. package/dist/{chunk-DZG77WU7.cjs → chunk-3XSWF5AP.cjs} +3 -3
  14. package/dist/{chunk-DZG77WU7.cjs.map → chunk-3XSWF5AP.cjs.map} +1 -1
  15. package/dist/{chunk-M3ZGRGOG.js → chunk-6JG2RFGK.js} +3 -3
  16. package/dist/{chunk-M3ZGRGOG.js.map → chunk-6JG2RFGK.js.map} +1 -1
  17. package/dist/{chunk-S6B5XYC3.js → chunk-7C3HWGCW.js} +33 -22
  18. package/dist/chunk-7C3HWGCW.js.map +1 -0
  19. package/dist/{chunk-LOHMT36V.cjs → chunk-7KBNBPFK.cjs} +75 -2
  20. package/dist/chunk-7KBNBPFK.cjs.map +1 -0
  21. package/dist/{chunk-UKJJRU7C.cjs → chunk-A575WPBL.cjs} +330 -129
  22. package/dist/chunk-A575WPBL.cjs.map +1 -0
  23. package/dist/{chunk-2XRAWOZZ.js → chunk-A6PDYH55.js} +74 -3
  24. package/dist/chunk-A6PDYH55.js.map +1 -0
  25. package/dist/{chunk-LX7SEXOQ.js → chunk-CA5VUAP3.js} +25 -7
  26. package/dist/chunk-CA5VUAP3.js.map +1 -0
  27. package/dist/{chunk-2QKV4CGK.js → chunk-CZWN4C6A.js} +3 -3
  28. package/dist/{chunk-2QKV4CGK.js.map → chunk-CZWN4C6A.js.map} +1 -1
  29. package/dist/chunk-DQNI52VV.js +20 -0
  30. package/dist/chunk-DQNI52VV.js.map +1 -0
  31. package/dist/{chunk-VPK6PHIE.cjs → chunk-E6QXZZKE.cjs} +8 -8
  32. package/dist/{chunk-VPK6PHIE.cjs.map → chunk-E6QXZZKE.cjs.map} +1 -1
  33. package/dist/{chunk-IU5N5224.cjs → chunk-EFETPSJZ.cjs} +17 -8
  34. package/dist/chunk-EFETPSJZ.cjs.map +1 -0
  35. package/dist/{chunk-2ZLQZHZC.cjs → chunk-ER5BOIYD.cjs} +4 -4
  36. package/dist/{chunk-2ZLQZHZC.cjs.map → chunk-ER5BOIYD.cjs.map} +1 -1
  37. package/dist/{chunk-ODBID5TG.js → chunk-FUUSIT2T.js} +234 -35
  38. package/dist/chunk-FUUSIT2T.js.map +1 -0
  39. package/dist/{chunk-VY6NKMOA.cjs → chunk-GK3UG7YQ.cjs} +34 -25
  40. package/dist/chunk-GK3UG7YQ.cjs.map +1 -0
  41. package/dist/{chunk-NQTNSHSB.cjs → chunk-HNAYCTX4.cjs} +5 -5
  42. package/dist/chunk-HNAYCTX4.cjs.map +1 -0
  43. package/dist/{chunk-QATRS7JD.cjs → chunk-MYJGWS2J.cjs} +26 -8
  44. package/dist/chunk-MYJGWS2J.cjs.map +1 -0
  45. package/dist/{chunk-KZSKIUXZ.js → chunk-N7VAE6DZ.js} +31 -3
  46. package/dist/chunk-N7VAE6DZ.js.map +1 -0
  47. package/dist/{chunk-7SZAV6QG.js → chunk-P5S3WCSZ.js} +3 -3
  48. package/dist/{chunk-7SZAV6QG.js.map → chunk-P5S3WCSZ.js.map} +1 -1
  49. package/dist/{chunk-HW7SEELD.cjs → chunk-QRVS2PRE.cjs} +31 -8
  50. package/dist/chunk-QRVS2PRE.cjs.map +1 -0
  51. package/dist/{chunk-SADXXGWU.js → chunk-R3LBRQAN.js} +3 -3
  52. package/dist/{chunk-NQTNSHSB.cjs.map → chunk-R3LBRQAN.js.map} +1 -1
  53. package/dist/{chunk-AYA65JA5.cjs → chunk-RWPLWMCZ.cjs} +25 -9
  54. package/dist/chunk-RWPLWMCZ.cjs.map +1 -0
  55. package/dist/{chunk-O7L7M42F.js → chunk-T3ZDEYTJ.js} +21 -5
  56. package/dist/chunk-T3ZDEYTJ.js.map +1 -0
  57. package/dist/{chunk-43YXGD3P.cjs → chunk-TY56BKSK.cjs} +8 -4
  58. package/dist/chunk-TY56BKSK.cjs.map +1 -0
  59. package/dist/chunk-UOLBAPDM.js +66 -0
  60. package/dist/chunk-UOLBAPDM.js.map +1 -0
  61. package/dist/{chunk-NSLHPAC7.js → chunk-X7EUUHXU.js} +6 -5
  62. package/dist/chunk-X7EUUHXU.js.map +1 -0
  63. package/dist/{chunk-WS5ULCL4.js → chunk-YRLI5DVC.js} +3 -3
  64. package/dist/{chunk-WS5ULCL4.js.map → chunk-YRLI5DVC.js.map} +1 -1
  65. package/dist/chunk-YYN6BB7R.cjs +24 -0
  66. package/dist/chunk-YYN6BB7R.cjs.map +1 -0
  67. package/dist/{chunk-C4ZQPWXJ.cjs → chunk-ZLMU5EU3.cjs} +33 -4
  68. package/dist/chunk-ZLMU5EU3.cjs.map +1 -0
  69. package/dist/{compact-session-7FMYJXQ7.cjs → compact-session-75KD2FCM.cjs} +15 -11
  70. package/dist/{compact-session-7FMYJXQ7.cjs.map → compact-session-75KD2FCM.cjs.map} +1 -1
  71. package/dist/{compact-session-YSEK7NQF.js → compact-session-QT6RJOKO.js} +3 -3
  72. package/dist/{compact-session-YSEK7NQF.js.map → compact-session-QT6RJOKO.js.map} +1 -1
  73. package/dist/context/index.cjs +11 -7
  74. package/dist/context/index.cjs.map +1 -1
  75. package/dist/context/index.js +7 -3
  76. package/dist/context/index.js.map +1 -1
  77. package/dist/context-7RP5JXGM.cjs +24 -0
  78. package/dist/{context-JTGSBJT6.cjs.map → context-7RP5JXGM.cjs.map} +1 -1
  79. package/dist/context-OJIIXJCV.js +7 -0
  80. package/dist/{context-3HPU754C.js.map → context-OJIIXJCV.js.map} +1 -1
  81. package/dist/{cron-Bgivg88c.d.cts → cron-BwxDUscv.d.cts} +1 -1
  82. package/dist/{cron-CNUa7PDo.d.ts → cron-D8uB1Xh5.d.ts} +1 -1
  83. package/dist/cron.cjs +15 -14
  84. package/dist/cron.d.cts +2 -2
  85. package/dist/cron.d.ts +2 -2
  86. package/dist/cron.js +14 -13
  87. package/dist/eval.cjs +14 -13
  88. package/dist/eval.cjs.map +1 -1
  89. package/dist/eval.js +13 -12
  90. package/dist/eval.js.map +1 -1
  91. package/dist/{index-manager-3UNPYH34.cjs → index-manager-W7RHSL6G.cjs} +6 -6
  92. package/dist/{index-manager-3UNPYH34.cjs.map → index-manager-W7RHSL6G.cjs.map} +1 -1
  93. package/dist/{index-manager-W7FDMGEG.js → index-manager-Z4XMRVWQ.js} +5 -5
  94. package/dist/{index-manager-W7FDMGEG.js.map → index-manager-Z4XMRVWQ.js.map} +1 -1
  95. package/dist/index.cjs +284 -49
  96. package/dist/index.cjs.map +1 -1
  97. package/dist/index.d.cts +197 -5
  98. package/dist/index.d.ts +197 -5
  99. package/dist/index.js +249 -25
  100. package/dist/index.js.map +1 -1
  101. package/dist/{inject-session-PC73TMP2.cjs → inject-session-L6MIIELT.cjs} +4 -4
  102. package/dist/{inject-session-PC73TMP2.cjs.map → inject-session-L6MIIELT.cjs.map} +1 -1
  103. package/dist/{inject-session-J4LBWAPH.js → inject-session-XWWN4DAA.js} +3 -3
  104. package/dist/{inject-session-J4LBWAPH.js.map → inject-session-XWWN4DAA.js.map} +1 -1
  105. package/dist/internal/memory/storage/index.cjs +32 -32
  106. package/dist/internal/memory/storage/index.js +3 -3
  107. package/dist/internal/memory/storage/memory-root.d.cts +27 -0
  108. package/dist/internal/memory/storage/memory-root.d.ts +27 -0
  109. package/dist/internal/persistence/index.cjs +4 -4
  110. package/dist/internal/persistence/index.js +1 -1
  111. package/dist/internal/runtime/compat/foreign-config-sources.d.ts +17 -4
  112. package/dist/internal/runtime/compat/managed-settings.d.ts +80 -0
  113. package/dist/internal/runtime/context/context-discovery-runner.d.ts +14 -0
  114. package/dist/internal/runtime/context/context-discovery.d.ts +64 -0
  115. package/dist/internal/runtime/context/context-manager.d.ts +21 -1
  116. package/dist/internal/runtime/context/yaml-frontmatter.d.ts +6 -3
  117. package/dist/internal/runtime/hooks/hooks-executor.d.ts +13 -1
  118. package/dist/internal/runtime/hooks/hooks-source.d.ts +36 -1
  119. package/dist/internal/runtime/skills/discover-skills.d.ts +4 -0
  120. package/dist/internal/session/compact-session.d.ts +36 -0
  121. package/dist/project.cjs +3 -3
  122. package/dist/project.js +1 -1
  123. package/dist/skills.cjs +5 -5
  124. package/dist/skills.js +2 -2
  125. package/dist/subagents-loader-CJFYQQU2.js +7 -0
  126. package/dist/{subagents-loader-AIVDQ2D5.js.map → subagents-loader-CJFYQQU2.js.map} +1 -1
  127. package/dist/subagents-loader-MOO7DC4E.cjs +16 -0
  128. package/dist/{subagents-loader-DN4LETGL.cjs.map → subagents-loader-MOO7DC4E.cjs.map} +1 -1
  129. package/dist/subagents-loader.cjs +4 -4
  130. package/dist/subagents-loader.d.cts +1 -1
  131. package/dist/subagents-loader.d.ts +1 -1
  132. package/dist/subagents-loader.js +3 -3
  133. package/dist/types/agent.d.ts +7 -2
  134. package/docs/error-codes.md +20 -18
  135. package/docs/harness-capability-map.md +9 -1
  136. package/package.json +1 -1
  137. package/dist/chunk-2XRAWOZZ.js.map +0 -1
  138. package/dist/chunk-43YXGD3P.cjs.map +0 -1
  139. package/dist/chunk-AYA65JA5.cjs.map +0 -1
  140. package/dist/chunk-C4ZQPWXJ.cjs.map +0 -1
  141. package/dist/chunk-HW7SEELD.cjs.map +0 -1
  142. package/dist/chunk-IU5N5224.cjs.map +0 -1
  143. package/dist/chunk-JNAA4G4H.js +0 -43
  144. package/dist/chunk-JNAA4G4H.js.map +0 -1
  145. package/dist/chunk-KZSKIUXZ.js.map +0 -1
  146. package/dist/chunk-LOHMT36V.cjs.map +0 -1
  147. package/dist/chunk-LX7SEXOQ.js.map +0 -1
  148. package/dist/chunk-N6OOOYFZ.js.map +0 -1
  149. package/dist/chunk-NSLHPAC7.js.map +0 -1
  150. package/dist/chunk-O7L7M42F.js.map +0 -1
  151. package/dist/chunk-ODBID5TG.js.map +0 -1
  152. package/dist/chunk-QATRS7JD.cjs.map +0 -1
  153. package/dist/chunk-S6B5XYC3.js.map +0 -1
  154. package/dist/chunk-SADXXGWU.js.map +0 -1
  155. package/dist/chunk-UKJJRU7C.cjs.map +0 -1
  156. package/dist/chunk-VY6NKMOA.cjs.map +0 -1
  157. package/dist/context-3HPU754C.js +0 -6
  158. package/dist/context-JTGSBJT6.cjs +0 -23
  159. package/dist/subagents-loader-AIVDQ2D5.js +0 -7
  160. package/dist/subagents-loader-DN4LETGL.cjs +0 -16
@@ -1,23 +1,24 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkKVSAY6NZ_cjs = require('./chunk-KVSAY6NZ.cjs');
4
- var chunkDZG77WU7_cjs = require('./chunk-DZG77WU7.cjs');
5
- var chunkZ2JFX372_cjs = require('./chunk-Z2JFX372.cjs');
6
- var chunkVY6NKMOA_cjs = require('./chunk-VY6NKMOA.cjs');
4
+ var chunk3XSWF5AP_cjs = require('./chunk-3XSWF5AP.cjs');
5
+ var chunk33A27NFX_cjs = require('./chunk-33A27NFX.cjs');
6
+ var chunkYYN6BB7R_cjs = require('./chunk-YYN6BB7R.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
- var chunkNQTNSHSB_cjs = require('./chunk-NQTNSHSB.cjs');
10
+ var chunkHNAYCTX4_cjs = require('./chunk-HNAYCTX4.cjs');
11
11
  var chunk7FDKWDA2_cjs = require('./chunk-7FDKWDA2.cjs');
12
- var chunkC4ZQPWXJ_cjs = require('./chunk-C4ZQPWXJ.cjs');
12
+ var chunkZLMU5EU3_cjs = require('./chunk-ZLMU5EU3.cjs');
13
13
  var chunk2ZPEDVLM_cjs = require('./chunk-2ZPEDVLM.cjs');
14
- var chunkIU5N5224_cjs = require('./chunk-IU5N5224.cjs');
14
+ var chunkEFETPSJZ_cjs = require('./chunk-EFETPSJZ.cjs');
15
+ var chunkGK3UG7YQ_cjs = require('./chunk-GK3UG7YQ.cjs');
15
16
  var chunkRQMCOFAI_cjs = require('./chunk-RQMCOFAI.cjs');
16
17
  var chunkAA27GEYS_cjs = require('./chunk-AA27GEYS.cjs');
17
18
  var chunkYSTXFWQE_cjs = require('./chunk-YSTXFWQE.cjs');
18
19
  var chunkNQTD6QOW_cjs = require('./chunk-NQTD6QOW.cjs');
19
20
  var chunkNINIJCHU_cjs = require('./chunk-NINIJCHU.cjs');
20
- var chunkQATRS7JD_cjs = require('./chunk-QATRS7JD.cjs');
21
+ var chunkMYJGWS2J_cjs = require('./chunk-MYJGWS2J.cjs');
21
22
  var chunkIJ7M6GOG_cjs = require('./chunk-IJ7M6GOG.cjs');
22
23
  var chunk7A6535RA_cjs = require('./chunk-7A6535RA.cjs');
23
24
  var chunkSA6K24NB_cjs = require('./chunk-SA6K24NB.cjs');
@@ -26,9 +27,9 @@ var chunkGZV6AVRL_cjs = require('./chunk-GZV6AVRL.cjs');
26
27
  var chunkBJUJT5ED_cjs = require('./chunk-BJUJT5ED.cjs');
27
28
  var chunkZF2LDKQQ_cjs = require('./chunk-ZF2LDKQQ.cjs');
28
29
  var chunkJLRLCBJ4_cjs = require('./chunk-JLRLCBJ4.cjs');
29
- var chunkAYA65JA5_cjs = require('./chunk-AYA65JA5.cjs');
30
- var chunk43YXGD3P_cjs = require('./chunk-43YXGD3P.cjs');
31
- var chunkHW7SEELD_cjs = require('./chunk-HW7SEELD.cjs');
30
+ var chunkRWPLWMCZ_cjs = require('./chunk-RWPLWMCZ.cjs');
31
+ var chunkTY56BKSK_cjs = require('./chunk-TY56BKSK.cjs');
32
+ var chunkQRVS2PRE_cjs = require('./chunk-QRVS2PRE.cjs');
32
33
  var chunkATT276RD_cjs = require('./chunk-ATT276RD.cjs');
33
34
  var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
34
35
  var chunkANMJJD6D_cjs = require('./chunk-ANMJJD6D.cjs');
@@ -40,6 +41,7 @@ var promises = require('fs/promises');
40
41
  var crypto = require('crypto');
41
42
  var path = require('path');
42
43
  var fs = require('fs');
44
+ var process$1 = require('process');
43
45
  var child_process = require('child_process');
44
46
  var zod = require('zod');
45
47
  var module$1 = require('module');
@@ -383,7 +385,7 @@ function serializeAgents(agents2) {
383
385
  return out;
384
386
  }
385
387
  function registryPath(cwd) {
386
- return path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), REGISTRY_RELATIVE_SUFFIX);
388
+ return path.join(chunkTY56BKSK_cjs.theokitConfigRoot(cwd), REGISTRY_RELATIVE_SUFFIX);
387
389
  }
388
390
  async function loadRegistry(cwd) {
389
391
  void chunkJLRLCBJ4_cjs.sweepStaleAtomicTemps(registryPath(cwd)).catch(() => void 0);
@@ -818,7 +820,7 @@ async function readLegacyFacts(jsonPath) {
818
820
  }
819
821
  async function writeMigratedFacts(cwd, jsonPath, facts) {
820
822
  try {
821
- for (const fact of facts) await chunkNQTNSHSB_cjs.appendFactToMarkdown(cwd, fact);
823
+ for (const fact of facts) await chunkHNAYCTX4_cjs.appendFactToMarkdown(cwd, fact);
822
824
  await promises.unlink(jsonPath).catch(() => void 0);
823
825
  chunk6LHQPOMI_cjs.diag(`[theokit-sdk] migrated ${facts.length} fact(s) from ${jsonPath} to MEMORY.md
824
826
  `);
@@ -835,11 +837,11 @@ async function migrateLegacyJson(cwd, config) {
835
837
  const key = `${cwd}::${config.namespace ?? "default"}::${config.scope ?? "agent"}::${config.userId ?? "default"}`;
836
838
  if (migrationRun.has(key)) return { migrated: false, factCount: 0, reason: "already-migrated" };
837
839
  migrationRun.add(key);
838
- const jsonPath = chunkNQTNSHSB_cjs.legacyMemoryJsonPath(cwd, config);
840
+ const jsonPath = chunkHNAYCTX4_cjs.legacyMemoryJsonPath(cwd, config);
839
841
  if (!await fileExists(jsonPath)) {
840
842
  return { migrated: false, factCount: 0, reason: "no-legacy-json" };
841
843
  }
842
- if (await fileExists(chunkNQTNSHSB_cjs.memoryMdPath(chunkNQTNSHSB_cjs.resolveMemoryRoot(cwd, config)))) {
844
+ if (await fileExists(chunkHNAYCTX4_cjs.memoryMdPath(chunkHNAYCTX4_cjs.resolveMemoryRoot(cwd, config)))) {
843
845
  chunk6LHQPOMI_cjs.diag(
844
846
  `[theokit-sdk] memory migration skipped: both MEMORY.md and legacy JSON exist at ${jsonPath}; leaving both intact
845
847
  `
@@ -868,19 +870,19 @@ function unstoredRememberWarning(message) {
868
870
  if (isMemoryWritePrompt(message) && extractMemoryFact(message).length > 0) return void 0;
869
871
  const trimmed = message.trim();
870
872
  const quoted = trimmed.length > QUOTED_MESSAGE_MAX ? `${trimmed.slice(0, QUOTED_MESSAGE_MAX)}\u2026` : trimmed;
871
- return `[theokit-sdk] NOTHING WAS STORED \u2014 this message does not match the memory capture pattern: ${JSON.stringify(quoted)}. Supported: "Remember: <fact>" or "Remember (${chunkNQTNSHSB_cjs.MEMORY_KINDS.join("|")}): <fact>". It still reaches the session transcript, so a follow-up may answer from it \u2014 that is search over transcripts, not a durable memory.`;
873
+ return `[theokit-sdk] NOTHING WAS STORED \u2014 this message does not match the memory capture pattern: ${JSON.stringify(quoted)}. Supported: "Remember: <fact>" or "Remember (${chunkHNAYCTX4_cjs.MEMORY_KINDS.join("|")}): <fact>". It still reaches the session transcript, so a follow-up may answer from it \u2014 that is search over transcripts, not a durable memory.`;
872
874
  }
873
875
  function extractMemoryKind(message) {
874
876
  const match = REMEMBER_PATTERN.exec(message);
875
877
  const declared = match?.[1];
876
878
  if (declared === void 0) return void 0;
877
879
  const lowered = declared.toLowerCase();
878
- return chunkNQTNSHSB_cjs.MEMORY_KINDS.includes(lowered) ? lowered : void 0;
880
+ return chunkHNAYCTX4_cjs.MEMORY_KINDS.includes(lowered) ? lowered : void 0;
879
881
  }
880
882
  async function readMemoryFacts(cwd, config) {
881
883
  if (!config.enabled) return [];
882
884
  await migrateLegacyJson(cwd, config);
883
- return chunkNQTNSHSB_cjs.readFacts(cwd, config);
885
+ return chunkHNAYCTX4_cjs.readFacts(cwd, config);
884
886
  }
885
887
  async function appendMemoryFact(cwd, config, fact) {
886
888
  if (!config.enabled) return;
@@ -889,7 +891,7 @@ async function appendMemoryFact(cwd, config, fact) {
889
891
  text: chunk6LHQPOMI_cjs.redactSecrets(fact.text),
890
892
  ...fact.kind === void 0 ? {} : { kind: fact.kind }
891
893
  };
892
- await chunkNQTNSHSB_cjs.appendFact(cwd, config, sanitized);
894
+ await chunkHNAYCTX4_cjs.appendFact(cwd, config, sanitized);
893
895
  }
894
896
 
895
897
  // src/internal/runtime/fixtures/fixture-scripts.ts
@@ -1560,7 +1562,7 @@ function createRealCloudRun(options) {
1560
1562
  conversation: []
1561
1563
  };
1562
1564
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(options.agentOptions.apiKey);
1563
- const baseUrl = chunkC4ZQPWXJ_cjs.getConfiguredBaseUrl();
1565
+ const baseUrl = chunkZLMU5EU3_cjs.getConfiguredBaseUrl();
1564
1566
  const handle = new RealCloudRun(
1565
1567
  {
1566
1568
  id,
@@ -1643,7 +1645,7 @@ var RealCloudRun = class extends FixtureRunBase {
1643
1645
  async consumeStream(response) {
1644
1646
  let finalStatus = "finished";
1645
1647
  let finalText = "";
1646
- for await (const record of chunkC4ZQPWXJ_cjs.parseSseStream(response.body, this.controller.signal)) {
1648
+ for await (const record of chunkZLMU5EU3_cjs.parseSseStream(response.body, this.controller.signal)) {
1647
1649
  const parsed = safeParse(record.data);
1648
1650
  if (parsed === void 0) continue;
1649
1651
  const update = this.applyRecord(record.event, parsed);
@@ -1810,7 +1812,7 @@ var CloudAgent = class _CloudAgent {
1810
1812
  */
1811
1813
  isFixtureMode() {
1812
1814
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(this.options.apiKey);
1813
- return chunkC4ZQPWXJ_cjs.isFixtureApiKey(apiKey) && chunkC4ZQPWXJ_cjs.getConfiguredBaseUrl() === void 0;
1815
+ return chunkZLMU5EU3_cjs.isFixtureApiKey(apiKey) && chunkZLMU5EU3_cjs.getConfiguredBaseUrl() === void 0;
1814
1816
  }
1815
1817
  // SE9 — integrated structured output; delegates to the shared helper.
1816
1818
  generate(message, options) {
@@ -1862,7 +1864,7 @@ var CloudAgent = class _CloudAgent {
1862
1864
  const userText = typeof message === "string" ? message : message.text;
1863
1865
  const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
1864
1866
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(this.options.apiKey);
1865
- const useRealRuntime = apiKey !== void 0 && !chunkC4ZQPWXJ_cjs.isFixtureApiKey(apiKey) && chunkC4ZQPWXJ_cjs.getConfiguredBaseUrl() !== void 0;
1867
+ const useRealRuntime = apiKey !== void 0 && !chunkZLMU5EU3_cjs.isFixtureApiKey(apiKey) && chunkZLMU5EU3_cjs.getConfiguredBaseUrl() !== void 0;
1866
1868
  return useRealRuntime ? createRealCloudRun({
1867
1869
  agentId: this.agentId,
1868
1870
  model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
@@ -2122,14 +2124,14 @@ async function readState(filePath) {
2122
2124
  try {
2123
2125
  parsed = JSON.parse(raw);
2124
2126
  } catch {
2125
- chunkVY6NKMOA_cjs.warnOnce(
2127
+ chunkGK3UG7YQ_cjs.warnOnce(
2126
2128
  "personality-store-json-parse",
2127
2129
  "[theokit-sdk] personality.json is malformed; treating as empty"
2128
2130
  );
2129
2131
  return emptyState();
2130
2132
  }
2131
2133
  if (!isStateV1(parsed)) {
2132
- chunkVY6NKMOA_cjs.warnOnce(
2134
+ chunkGK3UG7YQ_cjs.warnOnce(
2133
2135
  "personality-store-bad-version",
2134
2136
  `[theokit-sdk] personality.json has unknown version; treating as empty (file kept untouched)`
2135
2137
  );
@@ -2160,7 +2162,7 @@ var PersonalityStore = class {
2160
2162
  try {
2161
2163
  await this.#persist(agentId, slug);
2162
2164
  } catch (err) {
2163
- chunkVY6NKMOA_cjs.warnOnce(
2165
+ chunkGK3UG7YQ_cjs.warnOnce(
2164
2166
  `personality-store-persist-failure-${agentId}`,
2165
2167
  `[theokit-sdk] personality persist failed for ${chunk6LHQPOMI_cjs.redactSecrets(agentId)}: ${chunk6LHQPOMI_cjs.redactSecrets(
2166
2168
  err.message
@@ -2177,7 +2179,7 @@ var PersonalityStore = class {
2177
2179
  try {
2178
2180
  state = await readState(filePath);
2179
2181
  } catch (err) {
2180
- chunkVY6NKMOA_cjs.warnOnce(
2182
+ chunkGK3UG7YQ_cjs.warnOnce(
2181
2183
  `personality-store-hydrate-failure-${agentId}`,
2182
2184
  `[theokit-sdk] personality hydrate failed for ${chunk6LHQPOMI_cjs.redactSecrets(agentId)}: ${chunk6LHQPOMI_cjs.redactSecrets(
2183
2185
  err.message
@@ -2206,7 +2208,7 @@ var PersonalityStore = class {
2206
2208
  });
2207
2209
  }
2208
2210
  #filePath() {
2209
- return path.join(chunk43YXGD3P_cjs.getTheokitHome(this.#cwd), FILE_NAME);
2211
+ return path.join(chunkTY56BKSK_cjs.getTheokitHome(this.#cwd), FILE_NAME);
2210
2212
  }
2211
2213
  };
2212
2214
 
@@ -2523,7 +2525,7 @@ function removeAll(arr, toRemove) {
2523
2525
  }
2524
2526
  }
2525
2527
  function readCompatConfigFile(cwd) {
2526
- const path$1 = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "config.json");
2528
+ const path$1 = path.join(chunkTY56BKSK_cjs.theokitConfigRoot(cwd), "config.json");
2527
2529
  if (!fs.existsSync(path$1)) return [];
2528
2530
  let raw;
2529
2531
  try {
@@ -2553,6 +2555,116 @@ function readCompatConfigFile(cwd) {
2553
2555
  function resolveCompatSources(options, cwd) {
2554
2556
  return options.local?.compatSources ?? readCompatConfigFile(cwd);
2555
2557
  }
2558
+ var KNOWN_KEYS = /* @__PURE__ */ new Set([
2559
+ "disableAllHooks",
2560
+ "disableSkillShellExecution",
2561
+ "permissions",
2562
+ "permissionMode"
2563
+ ]);
2564
+ function managedSettingsPathFor(root) {
2565
+ if (root !== void 0) return path.join(root, "claude-code", "managed-settings.json");
2566
+ if (process$1.platform === "darwin") {
2567
+ return "/Library/Application Support/ClaudeCode/managed-settings.json";
2568
+ }
2569
+ if (process$1.platform === "win32") {
2570
+ const programData = process.env.PROGRAMDATA ?? "C:\\ProgramData";
2571
+ return path.join(programData, "ClaudeCode", "managed-settings.json");
2572
+ }
2573
+ return "/etc/claude-code/managed-settings.json";
2574
+ }
2575
+ function readManagedSettings(root) {
2576
+ const path = managedSettingsPathFor(root);
2577
+ const parsed = readPolicyDocument(path);
2578
+ if (parsed === void 0) return {};
2579
+ const out = {};
2580
+ for (const [key, value] of Object.entries(parsed)) {
2581
+ applyPolicyKey(out, key, value, path);
2582
+ }
2583
+ return out;
2584
+ }
2585
+ function readPolicyDocument(path) {
2586
+ if (!fs.existsSync(path)) return void 0;
2587
+ let raw;
2588
+ try {
2589
+ raw = fs.readFileSync(path, "utf8");
2590
+ } catch (cause) {
2591
+ chunk6LHQPOMI_cjs.diagFailure(
2592
+ `[theokit-sdk] ${path} exists and could not be read (${cause.message}) \u2014 NO operator policy is being applied. Fix the permissions or remove the file.
2593
+ `
2594
+ );
2595
+ return void 0;
2596
+ }
2597
+ let parsed;
2598
+ try {
2599
+ parsed = JSON.parse(raw);
2600
+ } catch (cause) {
2601
+ chunk6LHQPOMI_cjs.diagFailure(
2602
+ `[theokit-sdk] ${path} is not valid JSON (${cause.message}) \u2014 NO operator policy is being applied.
2603
+ `
2604
+ );
2605
+ return void 0;
2606
+ }
2607
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
2608
+ chunk6LHQPOMI_cjs.diagFailure(
2609
+ `[theokit-sdk] ${path} is not a JSON object \u2014 NO operator policy is being applied.
2610
+ `
2611
+ );
2612
+ return void 0;
2613
+ }
2614
+ return parsed;
2615
+ }
2616
+ var PERMISSION_MODES = ["default", "plan", "acceptEdits", "bypass"];
2617
+ function applyPolicyKey(out, key, value, path) {
2618
+ if (!KNOWN_KEYS.has(key)) {
2619
+ decline(path, key, "this runtime does not enforce it");
2620
+ return;
2621
+ }
2622
+ if (key === "permissionMode") {
2623
+ const mode = readMode(value, path);
2624
+ if (mode !== void 0) out.permissionMode = mode;
2625
+ return;
2626
+ }
2627
+ if (key === "permissions") {
2628
+ const rules = readRuleLists(value, path);
2629
+ if (rules !== void 0) out.permissions = rules;
2630
+ return;
2631
+ }
2632
+ const flag = readBoolean(value, key, path);
2633
+ if (flag === void 0) return;
2634
+ if (key === "disableAllHooks") out.disableAllHooks = flag;
2635
+ if (key === "disableSkillShellExecution") out.disableSkillShellExecution = flag;
2636
+ }
2637
+ function decline(path, key, reason) {
2638
+ chunk6LHQPOMI_cjs.diagFailure(`[theokit-sdk] ${path} declares "${key}" \u2014 ${reason}. It is NOT being applied.
2639
+ `);
2640
+ }
2641
+ function readMode(value, path) {
2642
+ if (typeof value === "string" && PERMISSION_MODES.includes(value)) {
2643
+ return value;
2644
+ }
2645
+ decline(
2646
+ path,
2647
+ "permissionMode",
2648
+ `${JSON.stringify(value)} is not one of ${PERMISSION_MODES.join(", ")}`
2649
+ );
2650
+ return void 0;
2651
+ }
2652
+ function readRuleLists(value, path) {
2653
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
2654
+ return value;
2655
+ }
2656
+ decline(
2657
+ path,
2658
+ "permissions",
2659
+ `it is ${Array.isArray(value) ? "an array" : typeof value}, not an object of rule lists`
2660
+ );
2661
+ return void 0;
2662
+ }
2663
+ function readBoolean(value, key, path) {
2664
+ if (typeof value === "boolean") return value;
2665
+ decline(path, key, `it is ${typeof value}, not a boolean`);
2666
+ return void 0;
2667
+ }
2556
2668
  function spawnAndCollect(options) {
2557
2669
  return new Promise((resolve) => {
2558
2670
  const timeoutMs = options.timeoutMs ?? 3e4;
@@ -2603,21 +2715,31 @@ function spawnAndCollect(options) {
2603
2715
 
2604
2716
  // src/internal/runtime/hooks/hooks-executor.ts
2605
2717
  var HooksExecutor = class {
2606
- constructor(cwd, compatSources = [], gate = void 0) {
2718
+ constructor(cwd, compatSources = [], gate = void 0, policy = {}) {
2607
2719
  this.cwd = cwd;
2608
2720
  this.compatSources = compatSources;
2609
2721
  this.gate = gate;
2722
+ this.policy = policy;
2610
2723
  }
2611
2724
  cwd;
2612
2725
  compatSources;
2613
2726
  gate;
2727
+ policy;
2614
2728
  config = {};
2615
2729
  async initialize(settingSourcesIncludeProject) {
2730
+ if (readManagedSettings(this.policy.managedSettingsRoot).disableAllHooks === true) {
2731
+ chunkGK3UG7YQ_cjs.warnFailureOnce(
2732
+ "hooks-disabled-by-policy",
2733
+ "[theokit-sdk] hooks: an operator policy (managed-settings.json) declares disableAllHooks \u2014 NO hook will run, including any this project declared."
2734
+ );
2735
+ this.config = {};
2736
+ return;
2737
+ }
2616
2738
  if (!settingSourcesIncludeProject) {
2617
2739
  this.config = {};
2618
2740
  return;
2619
2741
  }
2620
- this.config = await chunkVY6NKMOA_cjs.loadHookConfig(this.cwd, this.compatSources);
2742
+ this.config = await chunkGK3UG7YQ_cjs.loadHookConfig(this.cwd, this.compatSources);
2621
2743
  }
2622
2744
  /** Fire every hook registered for `event` and aggregate the decisions. */
2623
2745
  async run(payload) {
@@ -2684,7 +2806,7 @@ var HooksExecutor = class {
2684
2806
  cwd: this.cwd,
2685
2807
  ...Object.keys(env).length > 0 ? { env } : {},
2686
2808
  timeoutMs,
2687
- stdin: JSON.stringify(payload)
2809
+ stdin: JSON.stringify(stdinPayloadFor(payload, command, this.cwd))
2688
2810
  });
2689
2811
  const failure = this.decisionFromFailure(result, command, env, timeoutMs);
2690
2812
  return failure ?? parseDecisionFromStdout(result.stdout);
@@ -2698,14 +2820,21 @@ var HooksExecutor = class {
2698
2820
  * spawned.
2699
2821
  */
2700
2822
  decisionFromFailure(result, command, env, timeoutMs) {
2701
- if (result.timedOut) return { decision: "deny", reason: `Hook timed out after ${timeoutMs}ms` };
2823
+ if (result.timedOut)
2824
+ return {
2825
+ decision: "deny",
2826
+ reason: `Hook timed out after ${timeoutMs}ms`
2827
+ };
2702
2828
  if (result.spawnError !== void 0) {
2703
- return { decision: "deny", reason: `Hook spawn failed: ${result.spawnError.message}` };
2829
+ return {
2830
+ decision: "deny",
2831
+ reason: `Hook spawn failed: ${result.spawnError.message}`
2832
+ };
2704
2833
  }
2705
2834
  if (result.exitCode === 0) return void 0;
2706
2835
  const stderr = result.stderr.trim();
2707
2836
  const base = stderr.length > 0 ? stderr : `Hook exited with code ${result.exitCode}`;
2708
- const missing = chunk43YXGD3P_cjs.undefinedVariablesIn(command.command, env);
2837
+ const missing = chunkTY56BKSK_cjs.undefinedVariablesIn(command.command, env);
2709
2838
  if (missing.length === 0) return { decision: "deny", reason: base };
2710
2839
  return {
2711
2840
  decision: "deny",
@@ -2713,26 +2842,52 @@ var HooksExecutor = class {
2713
2842
  };
2714
2843
  }
2715
2844
  };
2845
+ function stdinPayloadFor(payload, command, cwd) {
2846
+ return {
2847
+ ...payload,
2848
+ cwd,
2849
+ ...command.sourceEvent === void 0 ? {} : { hook_event_name: command.sourceEvent },
2850
+ ...payload.tool === void 0 ? {} : { tool_name: payload.tool },
2851
+ ...payload.input === void 0 ? {} : { tool_input: payload.input },
2852
+ ...payload.output === void 0 ? {} : { tool_response: payload.output }
2853
+ };
2854
+ }
2716
2855
  function runtimeEnvFor(sourcePath, cwd) {
2717
2856
  if (sourcePath === void 0) return {};
2718
- return chunk43YXGD3P_cjs.adapterForConfigPath(sourcePath)?.runtimeEnv(cwd) ?? {};
2857
+ return chunkTY56BKSK_cjs.adapterForConfigPath(sourcePath)?.runtimeEnv(cwd) ?? {};
2719
2858
  }
2720
2859
  function parseDecisionFromStdout(stdout) {
2721
2860
  const trimmed = stdout.trim();
2722
2861
  if (trimmed.length === 0) return { decision: "allow" };
2862
+ let parsed;
2723
2863
  try {
2724
- const parsed = JSON.parse(trimmed);
2725
- if (parsed.decision === "deny" || parsed.decision === "feedback") {
2726
- const result = { decision: parsed.decision };
2727
- if (parsed.reason !== void 0) result.reason = parsed.reason;
2728
- if (parsed.feedback !== void 0) result.feedback = parsed.feedback;
2729
- return result;
2730
- }
2731
- if (parsed.decision === "allow") return { decision: "allow" };
2864
+ parsed = JSON.parse(trimmed);
2732
2865
  } catch {
2733
2866
  return { decision: "feedback", feedback: trimmed };
2734
2867
  }
2735
- return { decision: "allow" };
2868
+ return nestedDecision(parsed) ?? flatDecision(parsed) ?? { decision: "allow" };
2869
+ }
2870
+ function nestedDecision(parsed) {
2871
+ const nested = parsed.hookSpecificOutput;
2872
+ if (nested?.permissionDecision === "allow") return { decision: "allow" };
2873
+ if (nested?.permissionDecision !== "deny" && nested?.permissionDecision !== "ask") {
2874
+ return void 0;
2875
+ }
2876
+ const result = { decision: "deny" };
2877
+ if (nested.permissionDecisionReason !== void 0) {
2878
+ result.reason = nested.permissionDecisionReason;
2879
+ }
2880
+ return result;
2881
+ }
2882
+ function flatDecision(parsed) {
2883
+ if (parsed.decision === "allow") return { decision: "allow" };
2884
+ if (parsed.decision !== "deny" && parsed.decision !== "block" && parsed.decision !== "feedback") {
2885
+ return void 0;
2886
+ }
2887
+ const result = parsed.decision === "feedback" ? { decision: "feedback" } : { decision: "deny" };
2888
+ if (parsed.reason !== void 0) result.reason = parsed.reason;
2889
+ if (parsed.feedback !== void 0) result.feedback = parsed.feedback;
2890
+ return result;
2736
2891
  }
2737
2892
 
2738
2893
  // src/internal/runtime/lifecycle/context-budget-event.ts
@@ -2774,7 +2929,7 @@ async function runPostRunLifecycle(inputs) {
2774
2929
  try {
2775
2930
  const partial = await safeConversation(run);
2776
2931
  if (partial !== void 0) {
2777
- chunkDZG77WU7_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2932
+ chunk3XSWF5AP_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2778
2933
  userText,
2779
2934
  conversation: partial
2780
2935
  });
@@ -2784,11 +2939,11 @@ async function runPostRunLifecycle(inputs) {
2784
2939
  chunk6LHQPOMI_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
2785
2940
  `);
2786
2941
  }
2787
- await chunkDZG77WU7_cjs.flushSessionWrites();
2942
+ await chunk3XSWF5AP_cjs.flushSessionWrites();
2788
2943
  return;
2789
2944
  }
2790
2945
  if (result.result !== void 0) {
2791
- chunkDZG77WU7_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2946
+ chunk3XSWF5AP_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2792
2947
  }
2793
2948
  const conversation = await safeConversation(run);
2794
2949
  const resolvedWindow = resolveWindowForRun(model, contextWindow);
@@ -2799,7 +2954,7 @@ async function runPostRunLifecycle(inputs) {
2799
2954
  }
2800
2955
  const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
2801
2956
  const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
2802
- chunkDZG77WU7_cjs.persistTurnToTranscript(
2957
+ chunk3XSWF5AP_cjs.persistTurnToTranscript(
2803
2958
  sessionStore,
2804
2959
  { cwd: workspaceCwd, agentId, model },
2805
2960
  agentId,
@@ -2811,7 +2966,7 @@ async function runPostRunLifecycle(inputs) {
2811
2966
  // The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
2812
2967
  // `contextWindow` here would budget against a number the clamp already rejected.
2813
2968
  contextWindow: effectiveWindow,
2814
- summarize: chunkC4ZQPWXJ_cjs.buildDefaultSummarizer({
2969
+ summarize: chunkZLMU5EU3_cjs.buildDefaultSummarizer({
2815
2970
  agentModel: model,
2816
2971
  ...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
2817
2972
  })
@@ -2824,7 +2979,7 @@ async function runPostRunLifecycle(inputs) {
2824
2979
  cwd: workspaceCwd,
2825
2980
  // Resolved once, here, and handed to both writers. Recomputing it inside either one is how
2826
2981
  // the summary ended up in a directory the indexer never scanned (#463).
2827
- memoryRoot: chunkNQTNSHSB_cjs.resolveMemoryRoot(workspaceCwd, inputs.memory),
2982
+ memoryRoot: chunkHNAYCTX4_cjs.resolveMemoryRoot(workspaceCwd, inputs.memory),
2828
2983
  runId: result.id,
2829
2984
  agentId,
2830
2985
  userText,
@@ -2836,7 +2991,7 @@ async function runPostRunLifecycle(inputs) {
2836
2991
  if (memoryProvider?.recordSessionSummary !== void 0) {
2837
2992
  await memoryProvider.recordSessionSummary(summaryArgs);
2838
2993
  } else {
2839
- await chunkNQTNSHSB_cjs.writeSessionSummary(summaryArgs);
2994
+ await chunkHNAYCTX4_cjs.writeSessionSummary(summaryArgs);
2840
2995
  }
2841
2996
  } catch (cause) {
2842
2997
  const message = cause instanceof Error ? cause.message : String(cause);
@@ -2853,7 +3008,7 @@ async function runPostRunLifecycle(inputs) {
2853
3008
  agentId,
2854
3009
  runId: result.id
2855
3010
  });
2856
- await chunkDZG77WU7_cjs.flushSessionWrites();
3011
+ await chunk3XSWF5AP_cjs.flushSessionWrites();
2857
3012
  }
2858
3013
  async function safeConversation(run) {
2859
3014
  try {
@@ -2888,15 +3043,15 @@ var SkillsManager = class {
2888
3043
  }
2889
3044
  async refresh() {
2890
3045
  const roots = this.skillsDir === void 0 ? [
2891
- ...chunk43YXGD3P_cjs.projectConfigRoots(this.cwd, this.compatSources, "skills").map(
3046
+ ...chunkTY56BKSK_cjs.projectConfigRoots(this.cwd, this.compatSources, "skills").map(
2892
3047
  (root) => path.join(root, "skills")
2893
3048
  ),
2894
- ...(await chunkAYA65JA5_cjs.pluginBundleDirs(this.cwd, this.compatSources)).map((b) => path.join(b, "skills"))
3049
+ ...(await chunkRWPLWMCZ_cjs.pluginBundleDirs(this.cwd, this.compatSources)).map((b) => path.join(b, "skills"))
2895
3050
  ] : [this.skillsDir];
2896
3051
  const discovered = [];
2897
3052
  const seen = /* @__PURE__ */ new Set();
2898
3053
  for (const root of roots) {
2899
- for (const skill of await chunkQATRS7JD_cjs.discoverSkills(root, {
3054
+ for (const skill of await chunkMYJGWS2J_cjs.discoverSkills(root, {
2900
3055
  onInvalidSkill: (info) => {
2901
3056
  chunk6LHQPOMI_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
2902
3057
  `);
@@ -2927,7 +3082,7 @@ var SkillsManager = class {
2927
3082
  async get(name) {
2928
3083
  const skill = this.skills.find((s) => s.name === name);
2929
3084
  if (skill === void 0) return void 0;
2930
- const instructions = typeof skill.instructions === "string" ? skill.instructions : chunkQATRS7JD_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
3085
+ const instructions = typeof skill.instructions === "string" ? skill.instructions : chunkMYJGWS2J_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
2931
3086
  const references = skill.references;
2932
3087
  return {
2933
3088
  name: skill.name,
@@ -3046,7 +3201,15 @@ async function buildSystemPromptContext(inputs, userText, memoryFacts, manager =
3046
3201
  agentId: inputs.agentId,
3047
3202
  cwd: inputs.workspaceCwd,
3048
3203
  model: inputs.model,
3049
- skills: skills.map((skill) => ({ name: skill.name, description: skill.description })),
3204
+ // This is the ONLY place the model learns which skills exist, which is what makes
3205
+ // `disable-model-invocation` enforceable rather than decorative. The scaffold had been writing
3206
+ // authorization frontmatter that the parser discarded, so the default was disclose-all.
3207
+ //
3208
+ // A disclosure rule, not an execution rule: `skills.get(name)` still resolves a hidden skill,
3209
+ // because a caller naming one has already made the decision this field keeps away from the
3210
+ // model. Widening it to execution would break the case the field is FOR — a side-effecting
3211
+ // skill a human may run and the model may not propose.
3212
+ skills: skills.filter((skill) => skill.disableModelInvocation !== true).map((skill) => ({ name: skill.name, description: skill.description })),
3050
3213
  userMessage: userText,
3051
3214
  memory: memoryFacts.map((fact) => ({ text: fact.text }))
3052
3215
  };
@@ -3106,7 +3269,7 @@ var ActiveMemoryPromptProvider = class {
3106
3269
  if (ctx.activeMemorySummary === void 0 || ctx.activeMemorySummary.length === 0) {
3107
3270
  return Promise.resolve(void 0);
3108
3271
  }
3109
- const body = chunkQATRS7JD_cjs.escapeBlockBody(ctx.activeMemorySummary);
3272
+ const body = chunkMYJGWS2J_cjs.escapeBlockBody(ctx.activeMemorySummary);
3110
3273
  return Promise.resolve(`<active-memory>
3111
3274
  ${body}
3112
3275
  </active-memory>`);
@@ -3159,7 +3322,7 @@ function formatSource(name, tokens) {
3159
3322
  if (tokens.length === 0) {
3160
3323
  return ` <source name="${escapeAttribute(name)}" />`;
3161
3324
  }
3162
- const body = chunkQATRS7JD_cjs.escapeBlockBody(tokens.join(" "));
3325
+ const body = chunkMYJGWS2J_cjs.escapeBlockBody(tokens.join(" "));
3163
3326
  return ` <source name="${escapeAttribute(name)}">
3164
3327
  ${body}
3165
3328
  </source>`;
@@ -3183,7 +3346,7 @@ var MemoryPromptProvider = class {
3183
3346
  if (ctx.memory.length === 0) return Promise.resolve(void 0);
3184
3347
  const lines = ctx.memory.map((fact) => {
3185
3348
  const tag = fact.observations === 1 ? "[unconfirmed] " : "";
3186
- return ` - ${tag}${chunkQATRS7JD_cjs.escapeBlockBody(fact.text)}`;
3349
+ return ` - ${tag}${chunkMYJGWS2J_cjs.escapeBlockBody(fact.text)}`;
3187
3350
  });
3188
3351
  return Promise.resolve(`${MEMORY_GUIDANCE}
3189
3352
  <memory>
@@ -3207,7 +3370,7 @@ var SkillsPromptProvider = class {
3207
3370
  priority = 20;
3208
3371
  contribute(ctx) {
3209
3372
  if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
3210
- return Promise.resolve(chunkQATRS7JD_cjs.buildSkillsBlock(ctx.skills));
3373
+ return Promise.resolve(chunkMYJGWS2J_cjs.buildSkillsBlock(ctx.skills));
3211
3374
  }
3212
3375
  };
3213
3376
 
@@ -3475,7 +3638,7 @@ var HISTOGRAM_NAMES = {
3475
3638
  };
3476
3639
  function safeRequire(moduleName) {
3477
3640
  try {
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)));
3641
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-A575WPBL.cjs', document.baseURI).href)));
3479
3642
  return r(moduleName);
3480
3643
  } catch {
3481
3644
  return void 0;
@@ -3718,7 +3881,7 @@ var cachedOtel;
3718
3881
  function loadOtel() {
3719
3882
  if (cachedOtel === void 0) {
3720
3883
  try {
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)));
3884
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-A575WPBL.cjs', document.baseURI).href)));
3722
3885
  const mod = r("@opentelemetry/api");
3723
3886
  cachedOtel = mod;
3724
3887
  } catch {
@@ -3955,7 +4118,7 @@ async function loadMarkdownEntities(opts) {
3955
4118
  const raw = await promises.readFile(resolved.source, "utf8").catch(() => null);
3956
4119
  if (raw === null) continue;
3957
4120
  const split = splitFrontmatter(raw, resolved.source, errorCodePrefix);
3958
- const fields = chunkHW7SEELD_cjs.parseSimpleYaml(split.frontmatter);
4121
+ const fields = chunkQRVS2PRE_cjs.parseSimpleYaml(split.frontmatter);
3959
4122
  const parsed = schema.safeParse(fields);
3960
4123
  if (!parsed.success) {
3961
4124
  throw new chunkJ7J7J2GN_cjs.ConfigurationError(
@@ -4037,7 +4200,7 @@ function applyAggregateCap(sources, maxTotal) {
4037
4200
  }
4038
4201
  const remaining = maxTotal - totalBytes;
4039
4202
  if (remaining > 0) {
4040
- const { finalContent } = chunkIU5N5224_cjs.truncateWithMarker(s.content, remaining);
4203
+ const { finalContent } = chunkEFETPSJZ_cjs.truncateWithMarker(s.content, remaining);
4041
4204
  kept.push({ ...s, content: finalContent, truncated: true });
4042
4205
  totalBytes = maxTotal;
4043
4206
  } else {
@@ -4070,14 +4233,24 @@ var ContextSourceFrontmatterSchema = zod.z.object({
4070
4233
 
4071
4234
  // src/internal/runtime/context/context-manager.ts
4072
4235
  var FileContextManager = class {
4073
- constructor(cwd, settings, settingSourcesIncludeProject) {
4236
+ /**
4237
+ * @param compatSources - What the consumer declared in `local.compatSources` (or
4238
+ * `.theokit/config.json`), as `resolveCompatSources` resolved it. `undefined` means the caller
4239
+ * did not thread the declaration through at all and every dialect runs — the pre-#652 behaviour,
4240
+ * kept so an internal caller constructing this directly does not silently lose content. An empty
4241
+ * ARRAY is different and is the fix: it means the consumer declared no foreign dialect, so
4242
+ * `.claude/rules/*.md` does not reach the prompt.
4243
+ */
4244
+ constructor(cwd, settings, settingSourcesIncludeProject, compatSources) {
4074
4245
  this.cwd = cwd;
4075
4246
  this.settings = settings;
4076
4247
  this.settingSourcesIncludeProject = settingSourcesIncludeProject;
4248
+ this.compatSources = compatSources;
4077
4249
  }
4078
4250
  cwd;
4079
4251
  settings;
4080
4252
  settingSourcesIncludeProject;
4253
+ compatSources;
4081
4254
  state;
4082
4255
  /**
4083
4256
  * The in-scope file set used by the most recent `refresh`. Tracked so
@@ -4086,6 +4259,19 @@ var FileContextManager = class {
4086
4259
  * snapshot untouched, at zero per-send cost.
4087
4260
  */
4088
4261
  lastScope = [];
4262
+ /**
4263
+ * The dialect kinds granted the `context` surface, or `undefined` when nothing was declared to
4264
+ * this instance.
4265
+ *
4266
+ * Routed through `adaptersForSurface` rather than reading `.kind` off the declarations, so the
4267
+ * three fail-closed rules #524 established govern this surface identically to the other four: a
4268
+ * bare string admits everything, an object with no `import` admits nothing, and an unrecognised
4269
+ * surface name narrows rather than widens.
4270
+ */
4271
+ grantedContextDialects() {
4272
+ if (this.compatSources === void 0) return void 0;
4273
+ return chunkTY56BKSK_cjs.adaptersForSurface(this.compatSources, "context").map((a) => a.kind);
4274
+ }
4089
4275
  async initialize() {
4090
4276
  if (!this.settingSourcesIncludeProject && this.settings.manager !== "file") {
4091
4277
  this.state = { config: { sources: [] }, loadedSources: [] };
@@ -4111,13 +4297,18 @@ var FileContextManager = class {
4111
4297
  this.lastScope = [...touchedFiles];
4112
4298
  const config = await loadContextConfig(this.cwd);
4113
4299
  const legacy = await loadSources(config, this.cwd);
4114
- const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunkIU5N5224_cjs.DEFAULT_MAX_BYTES_PER_FILE;
4300
+ const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunkEFETPSJZ_cjs.DEFAULT_MAX_BYTES_PER_FILE;
4115
4301
  const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
4116
- const discovered = await chunkIU5N5224_cjs.runDiscovery({
4302
+ const granted = this.grantedContextDialects();
4303
+ const discovered = await chunkEFETPSJZ_cjs.runDiscovery({
4117
4304
  cwd: this.cwd,
4118
4305
  maxBytesPerFile,
4119
4306
  skipLegacyTheokitContext: true,
4120
- touchedFiles
4307
+ touchedFiles,
4308
+ // #652 — the grant this path never consulted. Without it, a consumer who enabled project
4309
+ // scope for its OWN `.theokit/` also received a cloned repository's `.claude/rules/*.md`,
4310
+ // through a door the hooks/skills/subagents/plugins gate does not cover.
4311
+ ...granted === void 0 ? {} : { declaredCompatKinds: granted }
4121
4312
  });
4122
4313
  const legacyAsAggregator = legacy.filter((src) => src.status !== "excluded").map((src) => ({
4123
4314
  id: src.name,
@@ -4172,8 +4363,8 @@ var FileContextManager = class {
4172
4363
  }
4173
4364
  };
4174
4365
  async function loadContextConfig(cwd) {
4175
- const mdDir = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "context");
4176
- const jsonPath = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "context.json");
4366
+ const mdDir = path.join(chunkTY56BKSK_cjs.theokitConfigRoot(cwd), "context");
4367
+ const jsonPath = path.join(chunkTY56BKSK_cjs.theokitConfigRoot(cwd), "context.json");
4177
4368
  const mdEntities = await loadMarkdownEntities({
4178
4369
  dir: mdDir,
4179
4370
  schema: ContextSourceFrontmatterSchema,
@@ -4182,7 +4373,7 @@ async function loadContextConfig(cwd) {
4182
4373
  });
4183
4374
  if (mdEntities.length > 0) {
4184
4375
  if (fs.existsSync(jsonPath)) {
4185
- chunkVY6NKMOA_cjs.warnOnce(
4376
+ chunkGK3UG7YQ_cjs.warnOnce(
4186
4377
  "context-both-present",
4187
4378
  "[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
4188
4379
  );
@@ -4192,7 +4383,7 @@ async function loadContextConfig(cwd) {
4192
4383
  };
4193
4384
  }
4194
4385
  if (!fs.existsSync(jsonPath)) return { sources: [] };
4195
- chunkVY6NKMOA_cjs.warnOnce(
4386
+ chunkGK3UG7YQ_cjs.warnOnce(
4196
4387
  "context-json-deprecated",
4197
4388
  // Names no command: `theokit-migrate-config` was unpublished with the `bin` entry, and a warning
4198
4389
  // that tells you to run something the package does not ship is worse than one that tells you
@@ -4333,13 +4524,13 @@ var PluginsManager = class {
4333
4524
  }
4334
4525
  async refresh() {
4335
4526
  this.plugins = [];
4336
- for (const pluginsRoot of chunk43YXGD3P_cjs.pluginBundleRoots(this.cwd, this.compatSources)) {
4527
+ for (const pluginsRoot of chunkTY56BKSK_cjs.pluginBundleRoots(this.cwd, this.compatSources)) {
4337
4528
  await this.refreshRoot(pluginsRoot);
4338
4529
  }
4339
4530
  }
4340
4531
  // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: MD-first + JSON fallback + CLI location + both-present detection per plugin folder — branch table is clearer inlined.
4341
4532
  async refreshRoot(pluginsRoot) {
4342
- const entries = await chunkHW7SEELD_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
4533
+ const entries = await chunkQRVS2PRE_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
4343
4534
  for (const entry of entries) {
4344
4535
  if (!entry.isDirectory()) continue;
4345
4536
  const folderName = entry.name;
@@ -4355,13 +4546,13 @@ var PluginsManager = class {
4355
4546
  const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
4356
4547
  const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(this.cwd, pluginsRoot, folderName) : await loadPluginManifestFromJson(this.cwd, jsonPath, folderName);
4357
4548
  if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
4358
- chunkVY6NKMOA_cjs.warnOnce(
4549
+ chunkGK3UG7YQ_cjs.warnOnce(
4359
4550
  `plugin-${folderName}-both`,
4360
4551
  `[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
4361
4552
  );
4362
4553
  }
4363
4554
  if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
4364
- chunkVY6NKMOA_cjs.warnOnce(
4555
+ chunkGK3UG7YQ_cjs.warnOnce(
4365
4556
  "plugin-json-deprecated",
4366
4557
  // Same reason as the context.json warning: the CLI it used to name is no longer published.
4367
4558
  "[theokit-sdk] plugin.json manifests are deprecated; replace each with a PLUGIN.md"
@@ -4512,7 +4703,12 @@ function buildContext(args, out) {
4512
4703
  out.context = new FileContextManager(
4513
4704
  args.workspaceCwd,
4514
4705
  args.options.context,
4515
- args.settingSourcesIncludeProject
4706
+ args.settingSourcesIncludeProject,
4707
+ // #652 — the same declaration `buildSkills` and `buildPlugins` already pass. Omitting it here
4708
+ // is what let a foreign root's instructions into the system prompt while its skills, subagents,
4709
+ // hooks and plugins were correctly withheld: four surfaces failing closed and a fifth nobody
4710
+ // had wired to the gate.
4711
+ resolveCompatSources(args.options, args.workspaceCwd)
4516
4712
  );
4517
4713
  }
4518
4714
  function buildProviders(args, out) {
@@ -5607,7 +5803,7 @@ function stripThinkBlocks(content) {
5607
5803
  function resolveSystemPromptWithMemoryAdditions(systemPrompt, additions) {
5608
5804
  if (additions === void 0 || additions.length === 0) return systemPrompt;
5609
5805
  const block = `<active-memory>
5610
- ${chunkQATRS7JD_cjs.escapeBlockBody(additions)}
5806
+ ${chunkMYJGWS2J_cjs.escapeBlockBody(additions)}
5611
5807
  </active-memory>`;
5612
5808
  if (systemPrompt === void 0 || systemPrompt.length === 0) return block;
5613
5809
  return `${block}
@@ -6453,7 +6649,7 @@ function applyToolResultGuard(parts, opts) {
6453
6649
  (p) => (
6454
6650
  // SE7 — guard the TEXT of a tool result (string or the text blocks of a
6455
6651
  // structured content); image blocks pass through untouched.
6456
- p.type === "tool_result" ? { ...p, content: chunkC4ZQPWXJ_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6652
+ p.type === "tool_result" ? { ...p, content: chunkZLMU5EU3_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6457
6653
  )
6458
6654
  );
6459
6655
  }
@@ -6745,13 +6941,13 @@ var FallbackLlmClient = class {
6745
6941
  async *stream(request, signal) {
6746
6942
  let lastError;
6747
6943
  for (const client of this.clients) {
6748
- if (signal.aborted) throw chunkC4ZQPWXJ_cjs.abortError(signal);
6749
- const attempt = await chunkC4ZQPWXJ_cjs.tryFirstEvent(client, request, signal, true);
6944
+ if (signal.aborted) throw chunkZLMU5EU3_cjs.abortError(signal);
6945
+ const attempt = await chunkZLMU5EU3_cjs.tryFirstEvent(client, request, signal, true);
6750
6946
  if (attempt.kind === "handshake_error") {
6751
6947
  lastError = attempt.error;
6752
6948
  continue;
6753
6949
  }
6754
- return yield* chunkC4ZQPWXJ_cjs.relayStream(attempt.generator, attempt.firstResult);
6950
+ return yield* chunkZLMU5EU3_cjs.relayStream(attempt.generator, attempt.firstResult);
6755
6951
  }
6756
6952
  if (lastError !== void 0) throw lastError;
6757
6953
  throw new chunkJ7J7J2GN_cjs.NetworkError("FallbackLlmClient has no providers configured", {
@@ -7251,7 +7447,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
7251
7447
  if (exposedSet.has(name)) continue;
7252
7448
  const hint = suggestClosest(name, exposedSet);
7253
7449
  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)`;
7254
- chunkVY6NKMOA_cjs.warnOnce(
7450
+ chunkGK3UG7YQ_cjs.warnOnce(
7255
7451
  `personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
7256
7452
  message
7257
7453
  );
@@ -7387,9 +7583,9 @@ function buildLoopInputs(options, runId, userText, userImages) {
7387
7583
  { code: "invalid_max_iterations" }
7388
7584
  );
7389
7585
  }
7390
- const { primary, effectiveModelId } = chunkC4ZQPWXJ_cjs.resolveRunProvider(options);
7586
+ const { primary, effectiveModelId } = chunkZLMU5EU3_cjs.resolveRunProvider(options);
7391
7587
  const fallback = options.agentOptions.providers?.fallback;
7392
- const apiKeys = chunkC4ZQPWXJ_cjs.mergeExplicitApiKey(
7588
+ const apiKeys = chunkZLMU5EU3_cjs.mergeExplicitApiKey(
7393
7589
  options.agentOptions.providers?.apiKeys,
7394
7590
  primary,
7395
7591
  options.agentOptions.apiKey
@@ -7398,7 +7594,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
7398
7594
  const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
7399
7595
  const rateLimitSink = options.sendOptions.onRunEvent;
7400
7596
  const modelBaseUrl = options.model?.url;
7401
- const chain = chunkC4ZQPWXJ_cjs.resolveProviderChain({
7597
+ const chain = chunkZLMU5EU3_cjs.resolveProviderChain({
7402
7598
  primary,
7403
7599
  ...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
7404
7600
  ...fallback !== void 0 ? { fallback } : {},
@@ -7658,7 +7854,7 @@ function buildRealRunOptions(args) {
7658
7854
  };
7659
7855
  }
7660
7856
  async function createFixtureRunHelper(args) {
7661
- const sessionMessages = chunkDZG77WU7_cjs.getSessionMessages(args.inputs.agentId);
7857
+ const sessionMessages = chunk3XSWF5AP_cjs.getSessionMessages(args.inputs.agentId);
7662
7858
  const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
7663
7859
  return createLocalRun({
7664
7860
  agentId: args.inputs.agentId,
@@ -7677,7 +7873,7 @@ async function createFixtureRunHelper(args) {
7677
7873
  }
7678
7874
  async function dispatchLocalRun(args) {
7679
7875
  const apiKey = chunk6LHQPOMI_cjs.resolveApiKey(args.inputs.options.apiKey);
7680
- if (chunkC4ZQPWXJ_cjs.shouldUseRealLocalRuntime(apiKey)) {
7876
+ if (chunkZLMU5EU3_cjs.shouldUseRealLocalRuntime(apiKey)) {
7681
7877
  return createRealLocalRun(
7682
7878
  buildRealRunOptions({
7683
7879
  inputs: args.inputs,
@@ -7700,7 +7896,7 @@ async function dispatchLocalRun(args) {
7700
7896
  });
7701
7897
  }
7702
7898
  async function readProjectMcpServers(cwd) {
7703
- const path$1 = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "mcp.json");
7899
+ const path$1 = path.join(chunkTY56BKSK_cjs.theokitConfigRoot(cwd), "mcp.json");
7704
7900
  try {
7705
7901
  const raw = await promises.readFile(path$1, "utf8");
7706
7902
  const parsed = JSON.parse(raw);
@@ -7933,16 +8129,16 @@ async function disposeLocalAgentSession(agent) {
7933
8129
  agent.lifecycleAbortController.abort();
7934
8130
  await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
7935
8131
  disposeSessionMcpClients(agent.agentId);
7936
- await chunkDZG77WU7_cjs.flushSessionWrites();
8132
+ await chunk3XSWF5AP_cjs.flushSessionWrites();
7937
8133
  await flushRegistrySaves(agent.workspaceCwd);
7938
8134
  await disposeSessionStore(agent.sessionStore);
7939
- chunkDZG77WU7_cjs.discardSession(agent.workspaceCwd, agent.agentId);
8135
+ chunk3XSWF5AP_cjs.discardSession(agent.workspaceCwd, agent.agentId);
7940
8136
  }
7941
8137
  async function reloadLocalAgent(agent) {
7942
8138
  if (agent.context !== void 0) await agent.context.refresh();
7943
8139
  if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
7944
8140
  if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
7945
- return await chunkAYA65JA5_cjs.loadSubagents(
8141
+ return await chunkRWPLWMCZ_cjs.loadSubagents(
7946
8142
  agent.workspaceCwd,
7947
8143
  agent.settingSourcesIncludeProject,
7948
8144
  agent.options.agents
@@ -8188,7 +8384,7 @@ async function finalize(args, queryMode, result) {
8188
8384
  };
8189
8385
  args.cache?.set(args.userText, queryMode, result, tenantCtx);
8190
8386
  if (args.persistTranscripts === true && args.cwd !== void 0) {
8191
- await chunkTMKTSYDS_cjs.persistActiveMemoryTranscript(args.memoryRoot ?? chunkNQTNSHSB_cjs.resolveMemoryRoot(args.cwd), {
8387
+ await chunkTMKTSYDS_cjs.persistActiveMemoryTranscript(args.memoryRoot ?? chunkHNAYCTX4_cjs.resolveMemoryRoot(args.cwd), {
8192
8388
  runId: args.runId ?? `run-${Date.now()}`,
8193
8389
  startedAtMs: Date.now() - result.durationMs,
8194
8390
  userText: args.userText,
@@ -8779,7 +8975,7 @@ var LocalAgentMemory = class {
8779
8975
  const openOpts = { cwd: this.workspaceCwd, memoryRoot };
8780
8976
  if (embedding !== void 0) openOpts.embedding = embedding;
8781
8977
  if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
8782
- this.index = await chunkZ2JFX372_cjs.IndexManager.open(openOpts);
8978
+ this.index = await chunk33A27NFX_cjs.IndexManager.open(openOpts);
8783
8979
  await this.index.sync();
8784
8980
  this.toolsCache = [
8785
8981
  createMemorySearchTool({ index: this.index }),
@@ -8800,7 +8996,7 @@ var LocalAgentMemory = class {
8800
8996
  async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
8801
8997
  const cfg = this.options.memory?.activeRecall;
8802
8998
  if (cfg?.enabled !== true || this.index === void 0) return void 0;
8803
- if (this.breaker === void 0) this.breaker = new chunkC4ZQPWXJ_cjs.CircuitBreaker();
8999
+ if (this.breaker === void 0) this.breaker = new chunkZLMU5EU3_cjs.CircuitBreaker();
8804
9000
  if (this.cache === void 0) this.cache = new ActiveMemoryCache();
8805
9001
  const result = await runActiveMemory({
8806
9002
  userText,
@@ -8823,7 +9019,7 @@ var LocalAgentMemory = class {
8823
9019
  * and the active-memory transcript writer. Three separate resolutions is how they drifted (#463).
8824
9020
  */
8825
9021
  memoryRoot() {
8826
- this.memoryRootCache ??= chunkNQTNSHSB_cjs.resolveMemoryRoot(this.workspaceCwd, this.options.memory);
9022
+ this.memoryRootCache ??= chunkHNAYCTX4_cjs.resolveMemoryRoot(this.workspaceCwd, this.options.memory);
8827
9023
  return this.memoryRootCache;
8828
9024
  }
8829
9025
  buildActiveMemoryOptions(cfg) {
@@ -8938,7 +9134,7 @@ function createLocalAgentMemoryProvider(opts) {
8938
9134
  return { facts: [], systemPromptAdditions: summary };
8939
9135
  },
8940
9136
  async recordSessionSummary(args) {
8941
- await chunkNQTNSHSB_cjs.writeSessionSummary(args);
9137
+ await chunkHNAYCTX4_cjs.writeSessionSummary(args);
8942
9138
  },
8943
9139
  async sync(handle) {
8944
9140
  const state = handle[INTERNAL_LAM_KEY];
@@ -8976,7 +9172,7 @@ var PersonalityRegistry = class _PersonalityRegistry {
8976
9172
  * @internal
8977
9173
  */
8978
9174
  static async load(cwd) {
8979
- const projectDir = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), PERSONALITIES_SUFFIX);
9175
+ const projectDir = path.join(chunkTY56BKSK_cjs.theokitConfigRoot(cwd), PERSONALITIES_SUFFIX);
8980
9176
  const userDir = path.join(os.homedir(), USER_SUBDIR);
8981
9177
  const [userEntities, projectEntities] = await Promise.all([
8982
9178
  loadMarkdownEntities({
@@ -9028,7 +9224,7 @@ function addEntity(byName, entity, origin, collisionMap) {
9028
9224
  );
9029
9225
  }
9030
9226
  if (origin === "project" && collisionMap?.has(fm.name)) {
9031
- chunkVY6NKMOA_cjs.warnOnce(
9227
+ chunkGK3UG7YQ_cjs.warnOnce(
9032
9228
  `personality-collision-${fm.name}`,
9033
9229
  `[theokit-sdk] personality "${fm.name}" overridden by project preset`
9034
9230
  );
@@ -9078,14 +9274,14 @@ async function performPersonalitySwitch(args) {
9078
9274
 
9079
9275
  // src/internal/local-agent/local-agent-personality-extensions.ts
9080
9276
  function resolveActivePersonalityPreset(args) {
9081
- const forkCtx = chunkVY6NKMOA_cjs.currentPersonalityContext();
9277
+ const forkCtx = chunkYYN6BB7R_cjs.currentPersonalityContext();
9082
9278
  const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
9083
9279
  if (slug === void 0) return void 0;
9084
9280
  return args.personalityRegistry?.get(slug);
9085
9281
  }
9086
9282
  async function ensurePersonalityRegistryIfNeeded(args) {
9087
9283
  if (args.personalityRegistry !== void 0) return args.personalityRegistry;
9088
- const forkSlug = chunkVY6NKMOA_cjs.currentPersonalityContext()?.slug;
9284
+ const forkSlug = chunkYYN6BB7R_cjs.currentPersonalityContext()?.slug;
9089
9285
  const ownSlug = args.personalityStore.active(args.agentId);
9090
9286
  if (forkSlug === void 0 && ownSlug === void 0) return void 0;
9091
9287
  return await PersonalityRegistry.load(args.workspaceCwd);
@@ -9098,8 +9294,8 @@ function applyPersonalityOverlay(preset, base) {
9098
9294
  ${preset.systemPrompt}`;
9099
9295
  }
9100
9296
  async function localAgentUsePersonality(agent, name, opts) {
9101
- if (chunkVY6NKMOA_cjs.currentPersonalityContext() !== void 0) {
9102
- chunkVY6NKMOA_cjs.warnPersonalitySwitchInsideFork(agent.agentId);
9297
+ if (chunkYYN6BB7R_cjs.currentPersonalityContext() !== void 0) {
9298
+ chunkYYN6BB7R_cjs.warnPersonalitySwitchInsideFork(agent.agentId);
9103
9299
  return null;
9104
9300
  }
9105
9301
  if (agent.personalityRegistry === void 0) {
@@ -9115,8 +9311,8 @@ async function localAgentUsePersonality(agent, name, opts) {
9115
9311
  registry,
9116
9312
  store: agent.personalityStore,
9117
9313
  invalidateCache: (reason) => agent.invalidateCache(reason),
9118
- appendSessionMessage: (msg) => chunkDZG77WU7_cjs.appendSessionMessage(agent.agentId, msg),
9119
- clearSession: () => chunkDZG77WU7_cjs.clearSession(agent.agentId),
9314
+ appendSessionMessage: (msg) => chunk3XSWF5AP_cjs.appendSessionMessage(agent.agentId, msg),
9315
+ clearSession: () => chunk3XSWF5AP_cjs.clearSession(agent.agentId),
9120
9316
  opts: opts ?? {}
9121
9317
  })
9122
9318
  );
@@ -9160,7 +9356,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
9160
9356
  async function localAgentFork(parent, options) {
9161
9357
  const { forkAgentImpl } = await import('./fork-agent-WAEQI2DL.cjs');
9162
9358
  const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
9163
- const { withPersonalityContext } = await import('./context-JTGSBJT6.cjs');
9359
+ const { withPersonalityContext } = await import('./context-7RP5JXGM.cjs');
9164
9360
  const create = getAgentFacade().create;
9165
9361
  return withPersonalityContext(
9166
9362
  { slug: parent.personalitySlugSnapshot, isFork: true },
@@ -9670,7 +9866,7 @@ async function executeSendLocked(inputs, message, options) {
9670
9866
  if (inputs.options.onBeforeSend !== void 0) {
9671
9867
  await inputs.options.onBeforeSend({
9672
9868
  conversationId: inputs.agentId,
9673
- previousMessageCount: chunkDZG77WU7_cjs.getSessionMessages(inputs.agentId).length
9869
+ previousMessageCount: chunk3XSWF5AP_cjs.getSessionMessages(inputs.agentId).length
9674
9870
  });
9675
9871
  }
9676
9872
  await inputs.runPreHook(userText);
@@ -9682,8 +9878,8 @@ async function executeSendLocked(inputs, message, options) {
9682
9878
  userText,
9683
9879
  sendOptions: options
9684
9880
  });
9685
- const priorMessages = [...chunkDZG77WU7_cjs.getSessionMessages(inputs.agentId)];
9686
- chunkDZG77WU7_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9881
+ const priorMessages = [...chunk3XSWF5AP_cjs.getSessionMessages(inputs.agentId)];
9882
+ chunk3XSWF5AP_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9687
9883
  await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
9688
9884
  const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory, userText);
9689
9885
  const memoryTools = void 0;
@@ -9953,7 +10149,7 @@ var LocalAgent = class {
9953
10149
  if (sub.plugins !== void 0) this.plugins = sub.plugins;
9954
10150
  reportUnknownLocalOptions(options.local);
9955
10151
  const compatSources = resolveCompatSources(options, this.workspaceCwd);
9956
- chunk43YXGD3P_cjs.reportUndeclaredSources(this.workspaceCwd, compatSources);
10152
+ chunkTY56BKSK_cjs.reportUndeclaredSources(this.workspaceCwd, compatSources);
9957
10153
  this.hooksExecutor = new HooksExecutor(this.workspaceCwd, compatSources, options.local?.hooks);
9958
10154
  this.defaultMemoryProviderForLoop = createLocalAgentMemoryProvider({
9959
10155
  agentOptions: options,
@@ -9981,7 +10177,7 @@ var LocalAgent = class {
9981
10177
  if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
9982
10178
  const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
9983
10179
  await this.pluginManagerCode.initialize(codePlugins);
9984
- this.resolvedSubagents = await chunkAYA65JA5_cjs.loadSubagents(
10180
+ this.resolvedSubagents = await chunkRWPLWMCZ_cjs.loadSubagents(
9985
10181
  this.workspaceCwd,
9986
10182
  this.settingSourcesIncludeProject,
9987
10183
  this.options.agents,
@@ -9989,7 +10185,7 @@ var LocalAgent = class {
9989
10185
  );
9990
10186
  await acquireLeaseIfPossible(this.sessionStore, this.agentId);
9991
10187
  try {
9992
- await chunkDZG77WU7_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
10188
+ await chunk3XSWF5AP_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
9993
10189
  await this.personalityStore.hydrate(this.agentId);
9994
10190
  } catch (err) {
9995
10191
  await releaseLeaseIfPossible(this.sessionStore, this.agentId);
@@ -10330,15 +10526,15 @@ async function maybeInjectHandoffTools(options) {
10330
10526
  };
10331
10527
  }
10332
10528
  function keyWillFlowToProvider(apiKey, provider) {
10333
- if (chunkC4ZQPWXJ_cjs.isFixtureApiKey(apiKey)) return false;
10334
- if (chunkC4ZQPWXJ_cjs.getConfiguredBaseUrl() !== void 0) return false;
10529
+ if (chunkZLMU5EU3_cjs.isFixtureApiKey(apiKey)) return false;
10530
+ if (chunkZLMU5EU3_cjs.getConfiguredBaseUrl() !== void 0) return false;
10335
10531
  if (provider === void 0) return false;
10336
10532
  const profile = chunkANMJJD6D_cjs.getProviderProfile(provider);
10337
10533
  if (profile === void 0) return false;
10338
10534
  return profile.authType !== "none";
10339
10535
  }
10340
10536
  function missingApiKeyMessage() {
10341
- const present = chunkC4ZQPWXJ_cjs.presentProviderCredentialEnvVars();
10537
+ const present = chunkZLMU5EU3_cjs.presentProviderCredentialEnvVars();
10342
10538
  const base = `Missing API key \u2014 set ${chunk6LHQPOMI_cjs.API_KEY_ENV_VAR}, or pass \`apiKey\` to Agent.create()`;
10343
10539
  if (present.length === 0) return `${base}.`;
10344
10540
  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]}, ... })\`.`;
@@ -10358,7 +10554,7 @@ async function createLocalAgent(options) {
10358
10554
  }
10359
10555
  } else {
10360
10556
  const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
10361
- const shape = chunkC4ZQPWXJ_cjs.validateApiKeyShape(apiKey, {
10557
+ const shape = chunkZLMU5EU3_cjs.validateApiKeyShape(apiKey, {
10362
10558
  strict: willFlowToProvider,
10363
10559
  ...willFlowToProvider ? { provider } : {}
10364
10560
  });
@@ -10377,15 +10573,15 @@ async function createCloudAgent(options) {
10377
10573
  code: "missing_api_key"
10378
10574
  });
10379
10575
  }
10380
- const shape = chunkC4ZQPWXJ_cjs.validateApiKeyShape(apiKey);
10576
+ const shape = chunkZLMU5EU3_cjs.validateApiKeyShape(apiKey);
10381
10577
  if (shape.malformed) {
10382
10578
  throw new chunkJ7J7J2GN_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
10383
10579
  }
10384
- const baseUrl = chunkC4ZQPWXJ_cjs.getConfiguredBaseUrl();
10580
+ const baseUrl = chunkZLMU5EU3_cjs.getConfiguredBaseUrl();
10385
10581
  if (baseUrl === void 0) {
10386
10582
  return new CloudAgent(options);
10387
10583
  }
10388
- const response = await chunkC4ZQPWXJ_cjs.httpRequest("/v1/agents", {
10584
+ const response = await chunkZLMU5EU3_cjs.httpRequest("/v1/agents", {
10389
10585
  apiKey,
10390
10586
  method: "POST",
10391
10587
  body: {
@@ -10410,7 +10606,7 @@ function resolveAgentPersistenceCwd(options) {
10410
10606
  return process.cwd();
10411
10607
  }
10412
10608
  async function rehydrateExistingAgent(agentId, existing, options) {
10413
- await chunkC4ZQPWXJ_cjs.discoverProviderPlugins();
10609
+ await chunkZLMU5EU3_cjs.discoverProviderPlugins();
10414
10610
  await validateRehydratedAgent(agentId, existing);
10415
10611
  const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
10416
10612
  const mergedOptions = {
@@ -10561,7 +10757,7 @@ var Agent = class _Agent {
10561
10757
  pluginCount: enabledPluginNames(options.plugins).length
10562
10758
  });
10563
10759
  try {
10564
- await chunkC4ZQPWXJ_cjs.discoverProviderPlugins();
10760
+ await chunkZLMU5EU3_cjs.discoverProviderPlugins();
10565
10761
  const agent = await runCreateUnderSpan(options, span);
10566
10762
  return agent;
10567
10763
  } catch (err) {
@@ -10859,9 +11055,9 @@ var Agent = class _Agent {
10859
11055
  */
10860
11056
  static async compact(agentId, options = {}) {
10861
11057
  const reg = await requireLocalAgent(agentId, "compact");
10862
- const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-7FMYJXQ7.cjs');
11058
+ const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-75KD2FCM.cjs');
10863
11059
  const { cwd, model, store } = await openLocalStore(reg);
10864
- return chunkDZG77WU7_cjs.enqueueSessionWrite(
11060
+ return chunk3XSWF5AP_cjs.enqueueSessionWrite(
10865
11061
  cwd,
10866
11062
  agentId,
10867
11063
  () => compactSessionTranscript({
@@ -10872,7 +11068,10 @@ var Agent = class _Agent {
10872
11068
  summarize: options.summarize ?? buildDefaultSummarizer2({
10873
11069
  agentModel: model,
10874
11070
  ...reg.options.apiKey !== void 0 ? { apiKey: reg.options.apiKey } : {}
10875
- })
11071
+ }),
11072
+ ...options.onPreCompact !== void 0 ? { onPreCompact: options.onPreCompact } : {},
11073
+ ...options.onPreCompactError !== void 0 ? { onPreCompactError: options.onPreCompactError } : {},
11074
+ ...options.preCompactTimeoutMs !== void 0 ? { preCompactTimeoutMs: options.preCompactTimeoutMs } : {}
10876
11075
  })
10877
11076
  );
10878
11077
  }
@@ -10886,7 +11085,7 @@ var Agent = class _Agent {
10886
11085
  */
10887
11086
  static async injectSessionTurn(agentId, turn) {
10888
11087
  const reg = await requireLocalAgent(agentId, "injectSessionTurn");
10889
- const { injectSessionTurn } = await import('./inject-session-PC73TMP2.cjs');
11088
+ const { injectSessionTurn } = await import('./inject-session-L6MIIELT.cjs');
10890
11089
  const { cwd, model, store } = await openLocalStore(reg);
10891
11090
  await injectSessionTurn({
10892
11091
  store,
@@ -10937,7 +11136,7 @@ var Agent = class _Agent {
10937
11136
  */
10938
11137
  static async describe(agentId) {
10939
11138
  const agent = await getRegisteredAgentOrThrow(agentId);
10940
- const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-DN4LETGL.cjs');
11139
+ const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-MOO7DC4E.cjs');
10941
11140
  const settingSources = agent.options.local?.settingSources;
10942
11141
  const subagents = await loadSubagents2(
10943
11142
  agent.cwd ?? process.cwd(),
@@ -11053,7 +11252,9 @@ exports.UsageAccumulator = UsageAccumulator;
11053
11252
  exports.computeCost = computeCost;
11054
11253
  exports.generateCronId = generateCronId;
11055
11254
  exports.getPricingEntry = getPricingEntry;
11255
+ exports.managedSettingsPathFor = managedSettingsPathFor;
11056
11256
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
11257
+ exports.readManagedSettings = readManagedSettings;
11057
11258
  exports.resolveSessionDir = resolveSessionDir;
11058
- //# sourceMappingURL=chunk-UKJJRU7C.cjs.map
11059
- //# sourceMappingURL=chunk-UKJJRU7C.cjs.map
11259
+ //# sourceMappingURL=chunk-A575WPBL.cjs.map
11260
+ //# sourceMappingURL=chunk-A575WPBL.cjs.map