@theokit/sdk 5.5.0 → 5.6.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 (131) hide show
  1. package/CHANGELOG.md +601 -0
  2. package/dist/{agent-YWSIHHFM.cjs → agent-47NS6ZVL.cjs} +13 -13
  3. package/dist/{agent-YWSIHHFM.cjs.map → agent-47NS6ZVL.cjs.map} +1 -1
  4. package/dist/{agent-DyB_lzrx.d.cts → agent-82d_DrCL.d.cts} +11 -2
  5. package/dist/{agent-CjMVbhhY.d.ts → agent-G6g-uwcB.d.ts} +11 -2
  6. package/dist/{agent-G3T7Q3SQ.js → agent-JJZM2VIK.js} +12 -12
  7. package/dist/{agent-G3T7Q3SQ.js.map → agent-JJZM2VIK.js.map} +1 -1
  8. package/dist/{chunk-ODBID5TG.js → chunk-2UXQASTX.js} +225 -30
  9. package/dist/chunk-2UXQASTX.js.map +1 -0
  10. package/dist/{chunk-VPK6PHIE.cjs → chunk-52FDUJSV.cjs} +8 -8
  11. package/dist/{chunk-VPK6PHIE.cjs.map → chunk-52FDUJSV.cjs.map} +1 -1
  12. package/dist/{chunk-2XRAWOZZ.js → chunk-5NELQ6LB.js} +65 -3
  13. package/dist/chunk-5NELQ6LB.js.map +1 -0
  14. package/dist/{chunk-VY6NKMOA.cjs → chunk-7IZKTQ5G.cjs} +34 -6
  15. package/dist/chunk-7IZKTQ5G.cjs.map +1 -0
  16. package/dist/{chunk-7SZAV6QG.js → chunk-7MMTZBTT.js} +3 -3
  17. package/dist/{chunk-7SZAV6QG.js.map → chunk-7MMTZBTT.js.map} +1 -1
  18. package/dist/{chunk-SADXXGWU.js → chunk-BZ3YMAMP.js} +3 -3
  19. package/dist/{chunk-NQTNSHSB.cjs.map → chunk-BZ3YMAMP.js.map} +1 -1
  20. package/dist/{chunk-LX7SEXOQ.js → chunk-CA5VUAP3.js} +25 -7
  21. package/dist/chunk-CA5VUAP3.js.map +1 -0
  22. package/dist/{chunk-IU5N5224.cjs → chunk-EIOMN5VA.cjs} +8 -8
  23. package/dist/chunk-EIOMN5VA.cjs.map +1 -0
  24. package/dist/{chunk-M3ZGRGOG.js → chunk-FPIY5CLV.js} +3 -3
  25. package/dist/{chunk-M3ZGRGOG.js.map → chunk-FPIY5CLV.js.map} +1 -1
  26. package/dist/{chunk-UKJJRU7C.cjs → chunk-GCHZMH42.cjs} +283 -86
  27. package/dist/chunk-GCHZMH42.cjs.map +1 -0
  28. package/dist/{chunk-NQTNSHSB.cjs → chunk-GFFBXSQT.cjs} +5 -5
  29. package/dist/chunk-GFFBXSQT.cjs.map +1 -0
  30. package/dist/{chunk-2ZLQZHZC.cjs → chunk-HG4UN4MN.cjs} +4 -4
  31. package/dist/{chunk-2ZLQZHZC.cjs.map → chunk-HG4UN4MN.cjs.map} +1 -1
  32. package/dist/{chunk-N6OOOYFZ.js → chunk-HUDNLFY4.js} +4 -4
  33. package/dist/chunk-HUDNLFY4.js.map +1 -0
  34. package/dist/{chunk-LOHMT36V.cjs → chunk-LD6HASA5.cjs} +65 -2
  35. package/dist/chunk-LD6HASA5.cjs.map +1 -0
  36. package/dist/{chunk-QATRS7JD.cjs → chunk-MYJGWS2J.cjs} +26 -8
  37. package/dist/chunk-MYJGWS2J.cjs.map +1 -0
  38. package/dist/{chunk-S6B5XYC3.js → chunk-N2KAIZ5D.js} +33 -6
  39. package/dist/chunk-N2KAIZ5D.js.map +1 -0
  40. package/dist/{chunk-HW7SEELD.cjs → chunk-QRVS2PRE.cjs} +31 -8
  41. package/dist/chunk-QRVS2PRE.cjs.map +1 -0
  42. package/dist/{chunk-AYA65JA5.cjs → chunk-RWPLWMCZ.cjs} +25 -9
  43. package/dist/chunk-RWPLWMCZ.cjs.map +1 -0
  44. package/dist/{chunk-WS5ULCL4.js → chunk-STGSMJMJ.js} +3 -3
  45. package/dist/{chunk-WS5ULCL4.js.map → chunk-STGSMJMJ.js.map} +1 -1
  46. package/dist/{chunk-O7L7M42F.js → chunk-T3ZDEYTJ.js} +21 -5
  47. package/dist/chunk-T3ZDEYTJ.js.map +1 -0
  48. package/dist/{chunk-43YXGD3P.cjs → chunk-TY56BKSK.cjs} +8 -4
  49. package/dist/chunk-TY56BKSK.cjs.map +1 -0
  50. package/dist/chunk-UOLBAPDM.js +66 -0
  51. package/dist/chunk-UOLBAPDM.js.map +1 -0
  52. package/dist/{chunk-Z2JFX372.cjs → chunk-VUHXC74Q.cjs} +15 -15
  53. package/dist/{chunk-Z2JFX372.cjs.map → chunk-VUHXC74Q.cjs.map} +1 -1
  54. package/dist/{chunk-NSLHPAC7.js → chunk-X7EUUHXU.js} +6 -5
  55. package/dist/chunk-X7EUUHXU.js.map +1 -0
  56. package/dist/context/index.cjs +7 -7
  57. package/dist/context/index.js +3 -3
  58. package/dist/{context-JTGSBJT6.cjs → context-HR4KMXMA.cjs} +7 -7
  59. package/dist/{context-JTGSBJT6.cjs.map → context-HR4KMXMA.cjs.map} +1 -1
  60. package/dist/context-J5BJ3LBS.js +6 -0
  61. package/dist/{context-3HPU754C.js.map → context-J5BJ3LBS.js.map} +1 -1
  62. package/dist/{cron-Bgivg88c.d.cts → cron-DWv69ZSD.d.cts} +1 -1
  63. package/dist/{cron-CNUa7PDo.d.ts → cron-GynWtAax.d.ts} +1 -1
  64. package/dist/cron.cjs +12 -12
  65. package/dist/cron.d.cts +2 -2
  66. package/dist/cron.d.ts +2 -2
  67. package/dist/cron.js +11 -11
  68. package/dist/eval.cjs +11 -11
  69. package/dist/eval.js +10 -10
  70. package/dist/{index-manager-W7FDMGEG.js → index-manager-27WLNQEE.js} +5 -5
  71. package/dist/{index-manager-W7FDMGEG.js.map → index-manager-27WLNQEE.js.map} +1 -1
  72. package/dist/{index-manager-3UNPYH34.cjs → index-manager-BBHDKMQS.cjs} +6 -6
  73. package/dist/{index-manager-3UNPYH34.cjs.map → index-manager-BBHDKMQS.cjs.map} +1 -1
  74. package/dist/index.cjs +274 -40
  75. package/dist/index.cjs.map +1 -1
  76. package/dist/index.d.cts +168 -5
  77. package/dist/index.d.ts +168 -5
  78. package/dist/index.js +246 -23
  79. package/dist/index.js.map +1 -1
  80. package/dist/internal/memory/storage/index.cjs +32 -32
  81. package/dist/internal/memory/storage/index.js +3 -3
  82. package/dist/internal/memory/storage/memory-root.d.cts +27 -0
  83. package/dist/internal/memory/storage/memory-root.d.ts +27 -0
  84. package/dist/internal/persistence/index.cjs +4 -4
  85. package/dist/internal/persistence/index.js +1 -1
  86. package/dist/internal/runtime/compat/foreign-config-sources.d.ts +17 -4
  87. package/dist/internal/runtime/compat/managed-settings.d.ts +80 -0
  88. package/dist/internal/runtime/context/context-discovery-runner.d.ts +14 -0
  89. package/dist/internal/runtime/context/context-discovery.d.ts +37 -0
  90. package/dist/internal/runtime/context/context-manager.d.ts +21 -1
  91. package/dist/internal/runtime/context/yaml-frontmatter.d.ts +6 -3
  92. package/dist/internal/runtime/hooks/hooks-executor.d.ts +13 -1
  93. package/dist/internal/runtime/hooks/hooks-source.d.ts +36 -1
  94. package/dist/internal/runtime/skills/discover-skills.d.ts +4 -0
  95. package/dist/project.cjs +3 -3
  96. package/dist/project.js +1 -1
  97. package/dist/skills.cjs +5 -5
  98. package/dist/skills.js +2 -2
  99. package/dist/subagents-loader-CJFYQQU2.js +7 -0
  100. package/dist/{subagents-loader-AIVDQ2D5.js.map → subagents-loader-CJFYQQU2.js.map} +1 -1
  101. package/dist/subagents-loader-MOO7DC4E.cjs +16 -0
  102. package/dist/{subagents-loader-DN4LETGL.cjs.map → subagents-loader-MOO7DC4E.cjs.map} +1 -1
  103. package/dist/subagents-loader.cjs +4 -4
  104. package/dist/subagents-loader.d.cts +1 -1
  105. package/dist/subagents-loader.d.ts +1 -1
  106. package/dist/subagents-loader.js +3 -3
  107. package/dist/types/agent.d.ts +6 -1
  108. package/docs/error-codes.md +20 -18
  109. package/docs/harness-capability-map.md +9 -1
  110. package/package.json +1 -1
  111. package/dist/chunk-2XRAWOZZ.js.map +0 -1
  112. package/dist/chunk-43YXGD3P.cjs.map +0 -1
  113. package/dist/chunk-AYA65JA5.cjs.map +0 -1
  114. package/dist/chunk-HW7SEELD.cjs.map +0 -1
  115. package/dist/chunk-IU5N5224.cjs.map +0 -1
  116. package/dist/chunk-JNAA4G4H.js +0 -43
  117. package/dist/chunk-JNAA4G4H.js.map +0 -1
  118. package/dist/chunk-LOHMT36V.cjs.map +0 -1
  119. package/dist/chunk-LX7SEXOQ.js.map +0 -1
  120. package/dist/chunk-N6OOOYFZ.js.map +0 -1
  121. package/dist/chunk-NSLHPAC7.js.map +0 -1
  122. package/dist/chunk-O7L7M42F.js.map +0 -1
  123. package/dist/chunk-ODBID5TG.js.map +0 -1
  124. package/dist/chunk-QATRS7JD.cjs.map +0 -1
  125. package/dist/chunk-S6B5XYC3.js.map +0 -1
  126. package/dist/chunk-SADXXGWU.js.map +0 -1
  127. package/dist/chunk-UKJJRU7C.cjs.map +0 -1
  128. package/dist/chunk-VY6NKMOA.cjs.map +0 -1
  129. package/dist/context-3HPU754C.js +0 -6
  130. package/dist/subagents-loader-AIVDQ2D5.js +0 -7
  131. package/dist/subagents-loader-DN4LETGL.cjs +0 -16
@@ -2,22 +2,22 @@
2
2
 
3
3
  var chunkKVSAY6NZ_cjs = require('./chunk-KVSAY6NZ.cjs');
4
4
  var chunkDZG77WU7_cjs = require('./chunk-DZG77WU7.cjs');
5
- var chunkZ2JFX372_cjs = require('./chunk-Z2JFX372.cjs');
6
- var chunkVY6NKMOA_cjs = require('./chunk-VY6NKMOA.cjs');
5
+ var chunkVUHXC74Q_cjs = require('./chunk-VUHXC74Q.cjs');
6
+ var chunk7IZKTQ5G_cjs = require('./chunk-7IZKTQ5G.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 chunkGFFBXSQT_cjs = require('./chunk-GFFBXSQT.cjs');
11
11
  var chunk7FDKWDA2_cjs = require('./chunk-7FDKWDA2.cjs');
12
12
  var chunkC4ZQPWXJ_cjs = require('./chunk-C4ZQPWXJ.cjs');
13
13
  var chunk2ZPEDVLM_cjs = require('./chunk-2ZPEDVLM.cjs');
14
- var chunkIU5N5224_cjs = require('./chunk-IU5N5224.cjs');
14
+ var chunkEIOMN5VA_cjs = require('./chunk-EIOMN5VA.cjs');
15
15
  var chunkRQMCOFAI_cjs = require('./chunk-RQMCOFAI.cjs');
16
16
  var chunkAA27GEYS_cjs = require('./chunk-AA27GEYS.cjs');
17
17
  var chunkYSTXFWQE_cjs = require('./chunk-YSTXFWQE.cjs');
18
18
  var chunkNQTD6QOW_cjs = require('./chunk-NQTD6QOW.cjs');
19
19
  var chunkNINIJCHU_cjs = require('./chunk-NINIJCHU.cjs');
20
- var chunkQATRS7JD_cjs = require('./chunk-QATRS7JD.cjs');
20
+ var chunkMYJGWS2J_cjs = require('./chunk-MYJGWS2J.cjs');
21
21
  var chunkIJ7M6GOG_cjs = require('./chunk-IJ7M6GOG.cjs');
22
22
  var chunk7A6535RA_cjs = require('./chunk-7A6535RA.cjs');
23
23
  var chunkSA6K24NB_cjs = require('./chunk-SA6K24NB.cjs');
@@ -26,9 +26,9 @@ 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 chunkAYA65JA5_cjs = require('./chunk-AYA65JA5.cjs');
30
- var chunk43YXGD3P_cjs = require('./chunk-43YXGD3P.cjs');
31
- var chunkHW7SEELD_cjs = require('./chunk-HW7SEELD.cjs');
29
+ var chunkRWPLWMCZ_cjs = require('./chunk-RWPLWMCZ.cjs');
30
+ var chunkTY56BKSK_cjs = require('./chunk-TY56BKSK.cjs');
31
+ var chunkQRVS2PRE_cjs = require('./chunk-QRVS2PRE.cjs');
32
32
  var chunkATT276RD_cjs = require('./chunk-ATT276RD.cjs');
33
33
  var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
34
34
  var chunkANMJJD6D_cjs = require('./chunk-ANMJJD6D.cjs');
@@ -40,6 +40,7 @@ var promises = require('fs/promises');
40
40
  var crypto = require('crypto');
41
41
  var path = require('path');
42
42
  var fs = require('fs');
43
+ var process$1 = require('process');
43
44
  var child_process = require('child_process');
44
45
  var zod = require('zod');
45
46
  var module$1 = require('module');
@@ -383,7 +384,7 @@ function serializeAgents(agents2) {
383
384
  return out;
384
385
  }
385
386
  function registryPath(cwd) {
386
- return path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), REGISTRY_RELATIVE_SUFFIX);
387
+ return path.join(chunkTY56BKSK_cjs.theokitConfigRoot(cwd), REGISTRY_RELATIVE_SUFFIX);
387
388
  }
388
389
  async function loadRegistry(cwd) {
389
390
  void chunkJLRLCBJ4_cjs.sweepStaleAtomicTemps(registryPath(cwd)).catch(() => void 0);
@@ -818,7 +819,7 @@ async function readLegacyFacts(jsonPath) {
818
819
  }
819
820
  async function writeMigratedFacts(cwd, jsonPath, facts) {
820
821
  try {
821
- for (const fact of facts) await chunkNQTNSHSB_cjs.appendFactToMarkdown(cwd, fact);
822
+ for (const fact of facts) await chunkGFFBXSQT_cjs.appendFactToMarkdown(cwd, fact);
822
823
  await promises.unlink(jsonPath).catch(() => void 0);
823
824
  chunk6LHQPOMI_cjs.diag(`[theokit-sdk] migrated ${facts.length} fact(s) from ${jsonPath} to MEMORY.md
824
825
  `);
@@ -835,11 +836,11 @@ async function migrateLegacyJson(cwd, config) {
835
836
  const key = `${cwd}::${config.namespace ?? "default"}::${config.scope ?? "agent"}::${config.userId ?? "default"}`;
836
837
  if (migrationRun.has(key)) return { migrated: false, factCount: 0, reason: "already-migrated" };
837
838
  migrationRun.add(key);
838
- const jsonPath = chunkNQTNSHSB_cjs.legacyMemoryJsonPath(cwd, config);
839
+ const jsonPath = chunkGFFBXSQT_cjs.legacyMemoryJsonPath(cwd, config);
839
840
  if (!await fileExists(jsonPath)) {
840
841
  return { migrated: false, factCount: 0, reason: "no-legacy-json" };
841
842
  }
842
- if (await fileExists(chunkNQTNSHSB_cjs.memoryMdPath(chunkNQTNSHSB_cjs.resolveMemoryRoot(cwd, config)))) {
843
+ if (await fileExists(chunkGFFBXSQT_cjs.memoryMdPath(chunkGFFBXSQT_cjs.resolveMemoryRoot(cwd, config)))) {
843
844
  chunk6LHQPOMI_cjs.diag(
844
845
  `[theokit-sdk] memory migration skipped: both MEMORY.md and legacy JSON exist at ${jsonPath}; leaving both intact
845
846
  `
@@ -868,19 +869,19 @@ function unstoredRememberWarning(message) {
868
869
  if (isMemoryWritePrompt(message) && extractMemoryFact(message).length > 0) return void 0;
869
870
  const trimmed = message.trim();
870
871
  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.`;
872
+ return `[theokit-sdk] NOTHING WAS STORED \u2014 this message does not match the memory capture pattern: ${JSON.stringify(quoted)}. Supported: "Remember: <fact>" or "Remember (${chunkGFFBXSQT_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
873
  }
873
874
  function extractMemoryKind(message) {
874
875
  const match = REMEMBER_PATTERN.exec(message);
875
876
  const declared = match?.[1];
876
877
  if (declared === void 0) return void 0;
877
878
  const lowered = declared.toLowerCase();
878
- return chunkNQTNSHSB_cjs.MEMORY_KINDS.includes(lowered) ? lowered : void 0;
879
+ return chunkGFFBXSQT_cjs.MEMORY_KINDS.includes(lowered) ? lowered : void 0;
879
880
  }
880
881
  async function readMemoryFacts(cwd, config) {
881
882
  if (!config.enabled) return [];
882
883
  await migrateLegacyJson(cwd, config);
883
- return chunkNQTNSHSB_cjs.readFacts(cwd, config);
884
+ return chunkGFFBXSQT_cjs.readFacts(cwd, config);
884
885
  }
885
886
  async function appendMemoryFact(cwd, config, fact) {
886
887
  if (!config.enabled) return;
@@ -889,7 +890,7 @@ async function appendMemoryFact(cwd, config, fact) {
889
890
  text: chunk6LHQPOMI_cjs.redactSecrets(fact.text),
890
891
  ...fact.kind === void 0 ? {} : { kind: fact.kind }
891
892
  };
892
- await chunkNQTNSHSB_cjs.appendFact(cwd, config, sanitized);
893
+ await chunkGFFBXSQT_cjs.appendFact(cwd, config, sanitized);
893
894
  }
894
895
 
895
896
  // src/internal/runtime/fixtures/fixture-scripts.ts
@@ -2122,14 +2123,14 @@ async function readState(filePath) {
2122
2123
  try {
2123
2124
  parsed = JSON.parse(raw);
2124
2125
  } catch {
2125
- chunkVY6NKMOA_cjs.warnOnce(
2126
+ chunk7IZKTQ5G_cjs.warnOnce(
2126
2127
  "personality-store-json-parse",
2127
2128
  "[theokit-sdk] personality.json is malformed; treating as empty"
2128
2129
  );
2129
2130
  return emptyState();
2130
2131
  }
2131
2132
  if (!isStateV1(parsed)) {
2132
- chunkVY6NKMOA_cjs.warnOnce(
2133
+ chunk7IZKTQ5G_cjs.warnOnce(
2133
2134
  "personality-store-bad-version",
2134
2135
  `[theokit-sdk] personality.json has unknown version; treating as empty (file kept untouched)`
2135
2136
  );
@@ -2160,7 +2161,7 @@ var PersonalityStore = class {
2160
2161
  try {
2161
2162
  await this.#persist(agentId, slug);
2162
2163
  } catch (err) {
2163
- chunkVY6NKMOA_cjs.warnOnce(
2164
+ chunk7IZKTQ5G_cjs.warnOnce(
2164
2165
  `personality-store-persist-failure-${agentId}`,
2165
2166
  `[theokit-sdk] personality persist failed for ${chunk6LHQPOMI_cjs.redactSecrets(agentId)}: ${chunk6LHQPOMI_cjs.redactSecrets(
2166
2167
  err.message
@@ -2177,7 +2178,7 @@ var PersonalityStore = class {
2177
2178
  try {
2178
2179
  state = await readState(filePath);
2179
2180
  } catch (err) {
2180
- chunkVY6NKMOA_cjs.warnOnce(
2181
+ chunk7IZKTQ5G_cjs.warnOnce(
2181
2182
  `personality-store-hydrate-failure-${agentId}`,
2182
2183
  `[theokit-sdk] personality hydrate failed for ${chunk6LHQPOMI_cjs.redactSecrets(agentId)}: ${chunk6LHQPOMI_cjs.redactSecrets(
2183
2184
  err.message
@@ -2206,7 +2207,7 @@ var PersonalityStore = class {
2206
2207
  });
2207
2208
  }
2208
2209
  #filePath() {
2209
- return path.join(chunk43YXGD3P_cjs.getTheokitHome(this.#cwd), FILE_NAME);
2210
+ return path.join(chunkTY56BKSK_cjs.getTheokitHome(this.#cwd), FILE_NAME);
2210
2211
  }
2211
2212
  };
2212
2213
 
@@ -2523,7 +2524,7 @@ function removeAll(arr, toRemove) {
2523
2524
  }
2524
2525
  }
2525
2526
  function readCompatConfigFile(cwd) {
2526
- const path$1 = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "config.json");
2527
+ const path$1 = path.join(chunkTY56BKSK_cjs.theokitConfigRoot(cwd), "config.json");
2527
2528
  if (!fs.existsSync(path$1)) return [];
2528
2529
  let raw;
2529
2530
  try {
@@ -2553,6 +2554,116 @@ function readCompatConfigFile(cwd) {
2553
2554
  function resolveCompatSources(options, cwd) {
2554
2555
  return options.local?.compatSources ?? readCompatConfigFile(cwd);
2555
2556
  }
2557
+ var KNOWN_KEYS = /* @__PURE__ */ new Set([
2558
+ "disableAllHooks",
2559
+ "disableSkillShellExecution",
2560
+ "permissions",
2561
+ "permissionMode"
2562
+ ]);
2563
+ function managedSettingsPathFor(root) {
2564
+ if (root !== void 0) return path.join(root, "claude-code", "managed-settings.json");
2565
+ if (process$1.platform === "darwin") {
2566
+ return "/Library/Application Support/ClaudeCode/managed-settings.json";
2567
+ }
2568
+ if (process$1.platform === "win32") {
2569
+ const programData = process.env.PROGRAMDATA ?? "C:\\ProgramData";
2570
+ return path.join(programData, "ClaudeCode", "managed-settings.json");
2571
+ }
2572
+ return "/etc/claude-code/managed-settings.json";
2573
+ }
2574
+ function readManagedSettings(root) {
2575
+ const path = managedSettingsPathFor(root);
2576
+ const parsed = readPolicyDocument(path);
2577
+ if (parsed === void 0) return {};
2578
+ const out = {};
2579
+ for (const [key, value] of Object.entries(parsed)) {
2580
+ applyPolicyKey(out, key, value, path);
2581
+ }
2582
+ return out;
2583
+ }
2584
+ function readPolicyDocument(path) {
2585
+ if (!fs.existsSync(path)) return void 0;
2586
+ let raw;
2587
+ try {
2588
+ raw = fs.readFileSync(path, "utf8");
2589
+ } catch (cause) {
2590
+ chunk6LHQPOMI_cjs.diagFailure(
2591
+ `[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.
2592
+ `
2593
+ );
2594
+ return void 0;
2595
+ }
2596
+ let parsed;
2597
+ try {
2598
+ parsed = JSON.parse(raw);
2599
+ } catch (cause) {
2600
+ chunk6LHQPOMI_cjs.diagFailure(
2601
+ `[theokit-sdk] ${path} is not valid JSON (${cause.message}) \u2014 NO operator policy is being applied.
2602
+ `
2603
+ );
2604
+ return void 0;
2605
+ }
2606
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
2607
+ chunk6LHQPOMI_cjs.diagFailure(
2608
+ `[theokit-sdk] ${path} is not a JSON object \u2014 NO operator policy is being applied.
2609
+ `
2610
+ );
2611
+ return void 0;
2612
+ }
2613
+ return parsed;
2614
+ }
2615
+ var PERMISSION_MODES = ["default", "plan", "acceptEdits", "bypass"];
2616
+ function applyPolicyKey(out, key, value, path) {
2617
+ if (!KNOWN_KEYS.has(key)) {
2618
+ decline(path, key, "this runtime does not enforce it");
2619
+ return;
2620
+ }
2621
+ if (key === "permissionMode") {
2622
+ const mode = readMode(value, path);
2623
+ if (mode !== void 0) out.permissionMode = mode;
2624
+ return;
2625
+ }
2626
+ if (key === "permissions") {
2627
+ const rules = readRuleLists(value, path);
2628
+ if (rules !== void 0) out.permissions = rules;
2629
+ return;
2630
+ }
2631
+ const flag = readBoolean(value, key, path);
2632
+ if (flag === void 0) return;
2633
+ if (key === "disableAllHooks") out.disableAllHooks = flag;
2634
+ if (key === "disableSkillShellExecution") out.disableSkillShellExecution = flag;
2635
+ }
2636
+ function decline(path, key, reason) {
2637
+ chunk6LHQPOMI_cjs.diagFailure(`[theokit-sdk] ${path} declares "${key}" \u2014 ${reason}. It is NOT being applied.
2638
+ `);
2639
+ }
2640
+ function readMode(value, path) {
2641
+ if (typeof value === "string" && PERMISSION_MODES.includes(value)) {
2642
+ return value;
2643
+ }
2644
+ decline(
2645
+ path,
2646
+ "permissionMode",
2647
+ `${JSON.stringify(value)} is not one of ${PERMISSION_MODES.join(", ")}`
2648
+ );
2649
+ return void 0;
2650
+ }
2651
+ function readRuleLists(value, path) {
2652
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
2653
+ return value;
2654
+ }
2655
+ decline(
2656
+ path,
2657
+ "permissions",
2658
+ `it is ${Array.isArray(value) ? "an array" : typeof value}, not an object of rule lists`
2659
+ );
2660
+ return void 0;
2661
+ }
2662
+ function readBoolean(value, key, path) {
2663
+ if (typeof value === "boolean") return value;
2664
+ decline(path, key, `it is ${typeof value}, not a boolean`);
2665
+ return void 0;
2666
+ }
2556
2667
  function spawnAndCollect(options) {
2557
2668
  return new Promise((resolve) => {
2558
2669
  const timeoutMs = options.timeoutMs ?? 3e4;
@@ -2603,21 +2714,31 @@ function spawnAndCollect(options) {
2603
2714
 
2604
2715
  // src/internal/runtime/hooks/hooks-executor.ts
2605
2716
  var HooksExecutor = class {
2606
- constructor(cwd, compatSources = [], gate = void 0) {
2717
+ constructor(cwd, compatSources = [], gate = void 0, policy = {}) {
2607
2718
  this.cwd = cwd;
2608
2719
  this.compatSources = compatSources;
2609
2720
  this.gate = gate;
2721
+ this.policy = policy;
2610
2722
  }
2611
2723
  cwd;
2612
2724
  compatSources;
2613
2725
  gate;
2726
+ policy;
2614
2727
  config = {};
2615
2728
  async initialize(settingSourcesIncludeProject) {
2729
+ if (readManagedSettings(this.policy.managedSettingsRoot).disableAllHooks === true) {
2730
+ chunk7IZKTQ5G_cjs.warnFailureOnce(
2731
+ "hooks-disabled-by-policy",
2732
+ "[theokit-sdk] hooks: an operator policy (managed-settings.json) declares disableAllHooks \u2014 NO hook will run, including any this project declared."
2733
+ );
2734
+ this.config = {};
2735
+ return;
2736
+ }
2616
2737
  if (!settingSourcesIncludeProject) {
2617
2738
  this.config = {};
2618
2739
  return;
2619
2740
  }
2620
- this.config = await chunkVY6NKMOA_cjs.loadHookConfig(this.cwd, this.compatSources);
2741
+ this.config = await chunk7IZKTQ5G_cjs.loadHookConfig(this.cwd, this.compatSources);
2621
2742
  }
2622
2743
  /** Fire every hook registered for `event` and aggregate the decisions. */
2623
2744
  async run(payload) {
@@ -2684,7 +2805,7 @@ var HooksExecutor = class {
2684
2805
  cwd: this.cwd,
2685
2806
  ...Object.keys(env).length > 0 ? { env } : {},
2686
2807
  timeoutMs,
2687
- stdin: JSON.stringify(payload)
2808
+ stdin: JSON.stringify(stdinPayloadFor(payload, command, this.cwd))
2688
2809
  });
2689
2810
  const failure = this.decisionFromFailure(result, command, env, timeoutMs);
2690
2811
  return failure ?? parseDecisionFromStdout(result.stdout);
@@ -2698,14 +2819,21 @@ var HooksExecutor = class {
2698
2819
  * spawned.
2699
2820
  */
2700
2821
  decisionFromFailure(result, command, env, timeoutMs) {
2701
- if (result.timedOut) return { decision: "deny", reason: `Hook timed out after ${timeoutMs}ms` };
2822
+ if (result.timedOut)
2823
+ return {
2824
+ decision: "deny",
2825
+ reason: `Hook timed out after ${timeoutMs}ms`
2826
+ };
2702
2827
  if (result.spawnError !== void 0) {
2703
- return { decision: "deny", reason: `Hook spawn failed: ${result.spawnError.message}` };
2828
+ return {
2829
+ decision: "deny",
2830
+ reason: `Hook spawn failed: ${result.spawnError.message}`
2831
+ };
2704
2832
  }
2705
2833
  if (result.exitCode === 0) return void 0;
2706
2834
  const stderr = result.stderr.trim();
2707
2835
  const base = stderr.length > 0 ? stderr : `Hook exited with code ${result.exitCode}`;
2708
- const missing = chunk43YXGD3P_cjs.undefinedVariablesIn(command.command, env);
2836
+ const missing = chunkTY56BKSK_cjs.undefinedVariablesIn(command.command, env);
2709
2837
  if (missing.length === 0) return { decision: "deny", reason: base };
2710
2838
  return {
2711
2839
  decision: "deny",
@@ -2713,26 +2841,52 @@ var HooksExecutor = class {
2713
2841
  };
2714
2842
  }
2715
2843
  };
2844
+ function stdinPayloadFor(payload, command, cwd) {
2845
+ return {
2846
+ ...payload,
2847
+ cwd,
2848
+ ...command.sourceEvent === void 0 ? {} : { hook_event_name: command.sourceEvent },
2849
+ ...payload.tool === void 0 ? {} : { tool_name: payload.tool },
2850
+ ...payload.input === void 0 ? {} : { tool_input: payload.input },
2851
+ ...payload.output === void 0 ? {} : { tool_response: payload.output }
2852
+ };
2853
+ }
2716
2854
  function runtimeEnvFor(sourcePath, cwd) {
2717
2855
  if (sourcePath === void 0) return {};
2718
- return chunk43YXGD3P_cjs.adapterForConfigPath(sourcePath)?.runtimeEnv(cwd) ?? {};
2856
+ return chunkTY56BKSK_cjs.adapterForConfigPath(sourcePath)?.runtimeEnv(cwd) ?? {};
2719
2857
  }
2720
2858
  function parseDecisionFromStdout(stdout) {
2721
2859
  const trimmed = stdout.trim();
2722
2860
  if (trimmed.length === 0) return { decision: "allow" };
2861
+ let parsed;
2723
2862
  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" };
2863
+ parsed = JSON.parse(trimmed);
2732
2864
  } catch {
2733
2865
  return { decision: "feedback", feedback: trimmed };
2734
2866
  }
2735
- return { decision: "allow" };
2867
+ return nestedDecision(parsed) ?? flatDecision(parsed) ?? { decision: "allow" };
2868
+ }
2869
+ function nestedDecision(parsed) {
2870
+ const nested = parsed.hookSpecificOutput;
2871
+ if (nested?.permissionDecision === "allow") return { decision: "allow" };
2872
+ if (nested?.permissionDecision !== "deny" && nested?.permissionDecision !== "ask") {
2873
+ return void 0;
2874
+ }
2875
+ const result = { decision: "deny" };
2876
+ if (nested.permissionDecisionReason !== void 0) {
2877
+ result.reason = nested.permissionDecisionReason;
2878
+ }
2879
+ return result;
2880
+ }
2881
+ function flatDecision(parsed) {
2882
+ if (parsed.decision === "allow") return { decision: "allow" };
2883
+ if (parsed.decision !== "deny" && parsed.decision !== "block" && parsed.decision !== "feedback") {
2884
+ return void 0;
2885
+ }
2886
+ const result = parsed.decision === "feedback" ? { decision: "feedback" } : { decision: "deny" };
2887
+ if (parsed.reason !== void 0) result.reason = parsed.reason;
2888
+ if (parsed.feedback !== void 0) result.feedback = parsed.feedback;
2889
+ return result;
2736
2890
  }
2737
2891
 
2738
2892
  // src/internal/runtime/lifecycle/context-budget-event.ts
@@ -2824,7 +2978,7 @@ async function runPostRunLifecycle(inputs) {
2824
2978
  cwd: workspaceCwd,
2825
2979
  // Resolved once, here, and handed to both writers. Recomputing it inside either one is how
2826
2980
  // the summary ended up in a directory the indexer never scanned (#463).
2827
- memoryRoot: chunkNQTNSHSB_cjs.resolveMemoryRoot(workspaceCwd, inputs.memory),
2981
+ memoryRoot: chunkGFFBXSQT_cjs.resolveMemoryRoot(workspaceCwd, inputs.memory),
2828
2982
  runId: result.id,
2829
2983
  agentId,
2830
2984
  userText,
@@ -2836,7 +2990,7 @@ async function runPostRunLifecycle(inputs) {
2836
2990
  if (memoryProvider?.recordSessionSummary !== void 0) {
2837
2991
  await memoryProvider.recordSessionSummary(summaryArgs);
2838
2992
  } else {
2839
- await chunkNQTNSHSB_cjs.writeSessionSummary(summaryArgs);
2993
+ await chunkGFFBXSQT_cjs.writeSessionSummary(summaryArgs);
2840
2994
  }
2841
2995
  } catch (cause) {
2842
2996
  const message = cause instanceof Error ? cause.message : String(cause);
@@ -2888,15 +3042,15 @@ var SkillsManager = class {
2888
3042
  }
2889
3043
  async refresh() {
2890
3044
  const roots = this.skillsDir === void 0 ? [
2891
- ...chunk43YXGD3P_cjs.projectConfigRoots(this.cwd, this.compatSources, "skills").map(
3045
+ ...chunkTY56BKSK_cjs.projectConfigRoots(this.cwd, this.compatSources, "skills").map(
2892
3046
  (root) => path.join(root, "skills")
2893
3047
  ),
2894
- ...(await chunkAYA65JA5_cjs.pluginBundleDirs(this.cwd, this.compatSources)).map((b) => path.join(b, "skills"))
3048
+ ...(await chunkRWPLWMCZ_cjs.pluginBundleDirs(this.cwd, this.compatSources)).map((b) => path.join(b, "skills"))
2895
3049
  ] : [this.skillsDir];
2896
3050
  const discovered = [];
2897
3051
  const seen = /* @__PURE__ */ new Set();
2898
3052
  for (const root of roots) {
2899
- for (const skill of await chunkQATRS7JD_cjs.discoverSkills(root, {
3053
+ for (const skill of await chunkMYJGWS2J_cjs.discoverSkills(root, {
2900
3054
  onInvalidSkill: (info) => {
2901
3055
  chunk6LHQPOMI_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
2902
3056
  `);
@@ -2927,7 +3081,7 @@ var SkillsManager = class {
2927
3081
  async get(name) {
2928
3082
  const skill = this.skills.find((s) => s.name === name);
2929
3083
  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"));
3084
+ const instructions = typeof skill.instructions === "string" ? skill.instructions : chunkMYJGWS2J_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
2931
3085
  const references = skill.references;
2932
3086
  return {
2933
3087
  name: skill.name,
@@ -3046,7 +3200,15 @@ async function buildSystemPromptContext(inputs, userText, memoryFacts, manager =
3046
3200
  agentId: inputs.agentId,
3047
3201
  cwd: inputs.workspaceCwd,
3048
3202
  model: inputs.model,
3049
- skills: skills.map((skill) => ({ name: skill.name, description: skill.description })),
3203
+ // This is the ONLY place the model learns which skills exist, which is what makes
3204
+ // `disable-model-invocation` enforceable rather than decorative. The scaffold had been writing
3205
+ // authorization frontmatter that the parser discarded, so the default was disclose-all.
3206
+ //
3207
+ // A disclosure rule, not an execution rule: `skills.get(name)` still resolves a hidden skill,
3208
+ // because a caller naming one has already made the decision this field keeps away from the
3209
+ // model. Widening it to execution would break the case the field is FOR — a side-effecting
3210
+ // skill a human may run and the model may not propose.
3211
+ skills: skills.filter((skill) => skill.disableModelInvocation !== true).map((skill) => ({ name: skill.name, description: skill.description })),
3050
3212
  userMessage: userText,
3051
3213
  memory: memoryFacts.map((fact) => ({ text: fact.text }))
3052
3214
  };
@@ -3106,7 +3268,7 @@ var ActiveMemoryPromptProvider = class {
3106
3268
  if (ctx.activeMemorySummary === void 0 || ctx.activeMemorySummary.length === 0) {
3107
3269
  return Promise.resolve(void 0);
3108
3270
  }
3109
- const body = chunkQATRS7JD_cjs.escapeBlockBody(ctx.activeMemorySummary);
3271
+ const body = chunkMYJGWS2J_cjs.escapeBlockBody(ctx.activeMemorySummary);
3110
3272
  return Promise.resolve(`<active-memory>
3111
3273
  ${body}
3112
3274
  </active-memory>`);
@@ -3159,7 +3321,7 @@ function formatSource(name, tokens) {
3159
3321
  if (tokens.length === 0) {
3160
3322
  return ` <source name="${escapeAttribute(name)}" />`;
3161
3323
  }
3162
- const body = chunkQATRS7JD_cjs.escapeBlockBody(tokens.join(" "));
3324
+ const body = chunkMYJGWS2J_cjs.escapeBlockBody(tokens.join(" "));
3163
3325
  return ` <source name="${escapeAttribute(name)}">
3164
3326
  ${body}
3165
3327
  </source>`;
@@ -3183,7 +3345,7 @@ var MemoryPromptProvider = class {
3183
3345
  if (ctx.memory.length === 0) return Promise.resolve(void 0);
3184
3346
  const lines = ctx.memory.map((fact) => {
3185
3347
  const tag = fact.observations === 1 ? "[unconfirmed] " : "";
3186
- return ` - ${tag}${chunkQATRS7JD_cjs.escapeBlockBody(fact.text)}`;
3348
+ return ` - ${tag}${chunkMYJGWS2J_cjs.escapeBlockBody(fact.text)}`;
3187
3349
  });
3188
3350
  return Promise.resolve(`${MEMORY_GUIDANCE}
3189
3351
  <memory>
@@ -3207,7 +3369,7 @@ var SkillsPromptProvider = class {
3207
3369
  priority = 20;
3208
3370
  contribute(ctx) {
3209
3371
  if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
3210
- return Promise.resolve(chunkQATRS7JD_cjs.buildSkillsBlock(ctx.skills));
3372
+ return Promise.resolve(chunkMYJGWS2J_cjs.buildSkillsBlock(ctx.skills));
3211
3373
  }
3212
3374
  };
3213
3375
 
@@ -3475,7 +3637,7 @@ var HISTOGRAM_NAMES = {
3475
3637
  };
3476
3638
  function safeRequire(moduleName) {
3477
3639
  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)));
3640
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-GCHZMH42.cjs', document.baseURI).href)));
3479
3641
  return r(moduleName);
3480
3642
  } catch {
3481
3643
  return void 0;
@@ -3718,7 +3880,7 @@ var cachedOtel;
3718
3880
  function loadOtel() {
3719
3881
  if (cachedOtel === void 0) {
3720
3882
  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)));
3883
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-GCHZMH42.cjs', document.baseURI).href)));
3722
3884
  const mod = r("@opentelemetry/api");
3723
3885
  cachedOtel = mod;
3724
3886
  } catch {
@@ -3955,7 +4117,7 @@ async function loadMarkdownEntities(opts) {
3955
4117
  const raw = await promises.readFile(resolved.source, "utf8").catch(() => null);
3956
4118
  if (raw === null) continue;
3957
4119
  const split = splitFrontmatter(raw, resolved.source, errorCodePrefix);
3958
- const fields = chunkHW7SEELD_cjs.parseSimpleYaml(split.frontmatter);
4120
+ const fields = chunkQRVS2PRE_cjs.parseSimpleYaml(split.frontmatter);
3959
4121
  const parsed = schema.safeParse(fields);
3960
4122
  if (!parsed.success) {
3961
4123
  throw new chunkJ7J7J2GN_cjs.ConfigurationError(
@@ -4037,7 +4199,7 @@ function applyAggregateCap(sources, maxTotal) {
4037
4199
  }
4038
4200
  const remaining = maxTotal - totalBytes;
4039
4201
  if (remaining > 0) {
4040
- const { finalContent } = chunkIU5N5224_cjs.truncateWithMarker(s.content, remaining);
4202
+ const { finalContent } = chunkEIOMN5VA_cjs.truncateWithMarker(s.content, remaining);
4041
4203
  kept.push({ ...s, content: finalContent, truncated: true });
4042
4204
  totalBytes = maxTotal;
4043
4205
  } else {
@@ -4070,14 +4232,24 @@ var ContextSourceFrontmatterSchema = zod.z.object({
4070
4232
 
4071
4233
  // src/internal/runtime/context/context-manager.ts
4072
4234
  var FileContextManager = class {
4073
- constructor(cwd, settings, settingSourcesIncludeProject) {
4235
+ /**
4236
+ * @param compatSources - What the consumer declared in `local.compatSources` (or
4237
+ * `.theokit/config.json`), as `resolveCompatSources` resolved it. `undefined` means the caller
4238
+ * did not thread the declaration through at all and every dialect runs — the pre-#652 behaviour,
4239
+ * kept so an internal caller constructing this directly does not silently lose content. An empty
4240
+ * ARRAY is different and is the fix: it means the consumer declared no foreign dialect, so
4241
+ * `.claude/rules/*.md` does not reach the prompt.
4242
+ */
4243
+ constructor(cwd, settings, settingSourcesIncludeProject, compatSources) {
4074
4244
  this.cwd = cwd;
4075
4245
  this.settings = settings;
4076
4246
  this.settingSourcesIncludeProject = settingSourcesIncludeProject;
4247
+ this.compatSources = compatSources;
4077
4248
  }
4078
4249
  cwd;
4079
4250
  settings;
4080
4251
  settingSourcesIncludeProject;
4252
+ compatSources;
4081
4253
  state;
4082
4254
  /**
4083
4255
  * The in-scope file set used by the most recent `refresh`. Tracked so
@@ -4086,6 +4258,19 @@ var FileContextManager = class {
4086
4258
  * snapshot untouched, at zero per-send cost.
4087
4259
  */
4088
4260
  lastScope = [];
4261
+ /**
4262
+ * The dialect kinds granted the `context` surface, or `undefined` when nothing was declared to
4263
+ * this instance.
4264
+ *
4265
+ * Routed through `adaptersForSurface` rather than reading `.kind` off the declarations, so the
4266
+ * three fail-closed rules #524 established govern this surface identically to the other four: a
4267
+ * bare string admits everything, an object with no `import` admits nothing, and an unrecognised
4268
+ * surface name narrows rather than widens.
4269
+ */
4270
+ grantedContextDialects() {
4271
+ if (this.compatSources === void 0) return void 0;
4272
+ return chunkTY56BKSK_cjs.adaptersForSurface(this.compatSources, "context").map((a) => a.kind);
4273
+ }
4089
4274
  async initialize() {
4090
4275
  if (!this.settingSourcesIncludeProject && this.settings.manager !== "file") {
4091
4276
  this.state = { config: { sources: [] }, loadedSources: [] };
@@ -4111,13 +4296,18 @@ var FileContextManager = class {
4111
4296
  this.lastScope = [...touchedFiles];
4112
4297
  const config = await loadContextConfig(this.cwd);
4113
4298
  const legacy = await loadSources(config, this.cwd);
4114
- const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunkIU5N5224_cjs.DEFAULT_MAX_BYTES_PER_FILE;
4299
+ const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunkEIOMN5VA_cjs.DEFAULT_MAX_BYTES_PER_FILE;
4115
4300
  const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
4116
- const discovered = await chunkIU5N5224_cjs.runDiscovery({
4301
+ const granted = this.grantedContextDialects();
4302
+ const discovered = await chunkEIOMN5VA_cjs.runDiscovery({
4117
4303
  cwd: this.cwd,
4118
4304
  maxBytesPerFile,
4119
4305
  skipLegacyTheokitContext: true,
4120
- touchedFiles
4306
+ touchedFiles,
4307
+ // #652 — the grant this path never consulted. Without it, a consumer who enabled project
4308
+ // scope for its OWN `.theokit/` also received a cloned repository's `.claude/rules/*.md`,
4309
+ // through a door the hooks/skills/subagents/plugins gate does not cover.
4310
+ ...granted === void 0 ? {} : { declaredCompatKinds: granted }
4121
4311
  });
4122
4312
  const legacyAsAggregator = legacy.filter((src) => src.status !== "excluded").map((src) => ({
4123
4313
  id: src.name,
@@ -4172,8 +4362,8 @@ var FileContextManager = class {
4172
4362
  }
4173
4363
  };
4174
4364
  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");
4365
+ const mdDir = path.join(chunkTY56BKSK_cjs.theokitConfigRoot(cwd), "context");
4366
+ const jsonPath = path.join(chunkTY56BKSK_cjs.theokitConfigRoot(cwd), "context.json");
4177
4367
  const mdEntities = await loadMarkdownEntities({
4178
4368
  dir: mdDir,
4179
4369
  schema: ContextSourceFrontmatterSchema,
@@ -4182,7 +4372,7 @@ async function loadContextConfig(cwd) {
4182
4372
  });
4183
4373
  if (mdEntities.length > 0) {
4184
4374
  if (fs.existsSync(jsonPath)) {
4185
- chunkVY6NKMOA_cjs.warnOnce(
4375
+ chunk7IZKTQ5G_cjs.warnOnce(
4186
4376
  "context-both-present",
4187
4377
  "[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
4188
4378
  );
@@ -4192,7 +4382,7 @@ async function loadContextConfig(cwd) {
4192
4382
  };
4193
4383
  }
4194
4384
  if (!fs.existsSync(jsonPath)) return { sources: [] };
4195
- chunkVY6NKMOA_cjs.warnOnce(
4385
+ chunk7IZKTQ5G_cjs.warnOnce(
4196
4386
  "context-json-deprecated",
4197
4387
  // Names no command: `theokit-migrate-config` was unpublished with the `bin` entry, and a warning
4198
4388
  // that tells you to run something the package does not ship is worse than one that tells you
@@ -4333,13 +4523,13 @@ var PluginsManager = class {
4333
4523
  }
4334
4524
  async refresh() {
4335
4525
  this.plugins = [];
4336
- for (const pluginsRoot of chunk43YXGD3P_cjs.pluginBundleRoots(this.cwd, this.compatSources)) {
4526
+ for (const pluginsRoot of chunkTY56BKSK_cjs.pluginBundleRoots(this.cwd, this.compatSources)) {
4337
4527
  await this.refreshRoot(pluginsRoot);
4338
4528
  }
4339
4529
  }
4340
4530
  // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: MD-first + JSON fallback + CLI location + both-present detection per plugin folder — branch table is clearer inlined.
4341
4531
  async refreshRoot(pluginsRoot) {
4342
- const entries = await chunkHW7SEELD_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
4532
+ const entries = await chunkQRVS2PRE_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
4343
4533
  for (const entry of entries) {
4344
4534
  if (!entry.isDirectory()) continue;
4345
4535
  const folderName = entry.name;
@@ -4355,13 +4545,13 @@ var PluginsManager = class {
4355
4545
  const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
4356
4546
  const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(this.cwd, pluginsRoot, folderName) : await loadPluginManifestFromJson(this.cwd, jsonPath, folderName);
4357
4547
  if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
4358
- chunkVY6NKMOA_cjs.warnOnce(
4548
+ chunk7IZKTQ5G_cjs.warnOnce(
4359
4549
  `plugin-${folderName}-both`,
4360
4550
  `[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
4361
4551
  );
4362
4552
  }
4363
4553
  if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
4364
- chunkVY6NKMOA_cjs.warnOnce(
4554
+ chunk7IZKTQ5G_cjs.warnOnce(
4365
4555
  "plugin-json-deprecated",
4366
4556
  // Same reason as the context.json warning: the CLI it used to name is no longer published.
4367
4557
  "[theokit-sdk] plugin.json manifests are deprecated; replace each with a PLUGIN.md"
@@ -4512,7 +4702,12 @@ function buildContext(args, out) {
4512
4702
  out.context = new FileContextManager(
4513
4703
  args.workspaceCwd,
4514
4704
  args.options.context,
4515
- args.settingSourcesIncludeProject
4705
+ args.settingSourcesIncludeProject,
4706
+ // #652 — the same declaration `buildSkills` and `buildPlugins` already pass. Omitting it here
4707
+ // is what let a foreign root's instructions into the system prompt while its skills, subagents,
4708
+ // hooks and plugins were correctly withheld: four surfaces failing closed and a fifth nobody
4709
+ // had wired to the gate.
4710
+ resolveCompatSources(args.options, args.workspaceCwd)
4516
4711
  );
4517
4712
  }
4518
4713
  function buildProviders(args, out) {
@@ -5607,7 +5802,7 @@ function stripThinkBlocks(content) {
5607
5802
  function resolveSystemPromptWithMemoryAdditions(systemPrompt, additions) {
5608
5803
  if (additions === void 0 || additions.length === 0) return systemPrompt;
5609
5804
  const block = `<active-memory>
5610
- ${chunkQATRS7JD_cjs.escapeBlockBody(additions)}
5805
+ ${chunkMYJGWS2J_cjs.escapeBlockBody(additions)}
5611
5806
  </active-memory>`;
5612
5807
  if (systemPrompt === void 0 || systemPrompt.length === 0) return block;
5613
5808
  return `${block}
@@ -7251,7 +7446,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
7251
7446
  if (exposedSet.has(name)) continue;
7252
7447
  const hint = suggestClosest(name, exposedSet);
7253
7448
  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(
7449
+ chunk7IZKTQ5G_cjs.warnOnce(
7255
7450
  `personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
7256
7451
  message
7257
7452
  );
@@ -7700,7 +7895,7 @@ async function dispatchLocalRun(args) {
7700
7895
  });
7701
7896
  }
7702
7897
  async function readProjectMcpServers(cwd) {
7703
- const path$1 = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), "mcp.json");
7898
+ const path$1 = path.join(chunkTY56BKSK_cjs.theokitConfigRoot(cwd), "mcp.json");
7704
7899
  try {
7705
7900
  const raw = await promises.readFile(path$1, "utf8");
7706
7901
  const parsed = JSON.parse(raw);
@@ -7942,7 +8137,7 @@ async function reloadLocalAgent(agent) {
7942
8137
  if (agent.context !== void 0) await agent.context.refresh();
7943
8138
  if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
7944
8139
  if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
7945
- return await chunkAYA65JA5_cjs.loadSubagents(
8140
+ return await chunkRWPLWMCZ_cjs.loadSubagents(
7946
8141
  agent.workspaceCwd,
7947
8142
  agent.settingSourcesIncludeProject,
7948
8143
  agent.options.agents
@@ -8188,7 +8383,7 @@ async function finalize(args, queryMode, result) {
8188
8383
  };
8189
8384
  args.cache?.set(args.userText, queryMode, result, tenantCtx);
8190
8385
  if (args.persistTranscripts === true && args.cwd !== void 0) {
8191
- await chunkTMKTSYDS_cjs.persistActiveMemoryTranscript(args.memoryRoot ?? chunkNQTNSHSB_cjs.resolveMemoryRoot(args.cwd), {
8386
+ await chunkTMKTSYDS_cjs.persistActiveMemoryTranscript(args.memoryRoot ?? chunkGFFBXSQT_cjs.resolveMemoryRoot(args.cwd), {
8192
8387
  runId: args.runId ?? `run-${Date.now()}`,
8193
8388
  startedAtMs: Date.now() - result.durationMs,
8194
8389
  userText: args.userText,
@@ -8779,7 +8974,7 @@ var LocalAgentMemory = class {
8779
8974
  const openOpts = { cwd: this.workspaceCwd, memoryRoot };
8780
8975
  if (embedding !== void 0) openOpts.embedding = embedding;
8781
8976
  if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
8782
- this.index = await chunkZ2JFX372_cjs.IndexManager.open(openOpts);
8977
+ this.index = await chunkVUHXC74Q_cjs.IndexManager.open(openOpts);
8783
8978
  await this.index.sync();
8784
8979
  this.toolsCache = [
8785
8980
  createMemorySearchTool({ index: this.index }),
@@ -8823,7 +9018,7 @@ var LocalAgentMemory = class {
8823
9018
  * and the active-memory transcript writer. Three separate resolutions is how they drifted (#463).
8824
9019
  */
8825
9020
  memoryRoot() {
8826
- this.memoryRootCache ??= chunkNQTNSHSB_cjs.resolveMemoryRoot(this.workspaceCwd, this.options.memory);
9021
+ this.memoryRootCache ??= chunkGFFBXSQT_cjs.resolveMemoryRoot(this.workspaceCwd, this.options.memory);
8827
9022
  return this.memoryRootCache;
8828
9023
  }
8829
9024
  buildActiveMemoryOptions(cfg) {
@@ -8938,7 +9133,7 @@ function createLocalAgentMemoryProvider(opts) {
8938
9133
  return { facts: [], systemPromptAdditions: summary };
8939
9134
  },
8940
9135
  async recordSessionSummary(args) {
8941
- await chunkNQTNSHSB_cjs.writeSessionSummary(args);
9136
+ await chunkGFFBXSQT_cjs.writeSessionSummary(args);
8942
9137
  },
8943
9138
  async sync(handle) {
8944
9139
  const state = handle[INTERNAL_LAM_KEY];
@@ -8976,7 +9171,7 @@ var PersonalityRegistry = class _PersonalityRegistry {
8976
9171
  * @internal
8977
9172
  */
8978
9173
  static async load(cwd) {
8979
- const projectDir = path.join(chunk43YXGD3P_cjs.theokitConfigRoot(cwd), PERSONALITIES_SUFFIX);
9174
+ const projectDir = path.join(chunkTY56BKSK_cjs.theokitConfigRoot(cwd), PERSONALITIES_SUFFIX);
8980
9175
  const userDir = path.join(os.homedir(), USER_SUBDIR);
8981
9176
  const [userEntities, projectEntities] = await Promise.all([
8982
9177
  loadMarkdownEntities({
@@ -9028,7 +9223,7 @@ function addEntity(byName, entity, origin, collisionMap) {
9028
9223
  );
9029
9224
  }
9030
9225
  if (origin === "project" && collisionMap?.has(fm.name)) {
9031
- chunkVY6NKMOA_cjs.warnOnce(
9226
+ chunk7IZKTQ5G_cjs.warnOnce(
9032
9227
  `personality-collision-${fm.name}`,
9033
9228
  `[theokit-sdk] personality "${fm.name}" overridden by project preset`
9034
9229
  );
@@ -9078,14 +9273,14 @@ async function performPersonalitySwitch(args) {
9078
9273
 
9079
9274
  // src/internal/local-agent/local-agent-personality-extensions.ts
9080
9275
  function resolveActivePersonalityPreset(args) {
9081
- const forkCtx = chunkVY6NKMOA_cjs.currentPersonalityContext();
9276
+ const forkCtx = chunk7IZKTQ5G_cjs.currentPersonalityContext();
9082
9277
  const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
9083
9278
  if (slug === void 0) return void 0;
9084
9279
  return args.personalityRegistry?.get(slug);
9085
9280
  }
9086
9281
  async function ensurePersonalityRegistryIfNeeded(args) {
9087
9282
  if (args.personalityRegistry !== void 0) return args.personalityRegistry;
9088
- const forkSlug = chunkVY6NKMOA_cjs.currentPersonalityContext()?.slug;
9283
+ const forkSlug = chunk7IZKTQ5G_cjs.currentPersonalityContext()?.slug;
9089
9284
  const ownSlug = args.personalityStore.active(args.agentId);
9090
9285
  if (forkSlug === void 0 && ownSlug === void 0) return void 0;
9091
9286
  return await PersonalityRegistry.load(args.workspaceCwd);
@@ -9098,8 +9293,8 @@ function applyPersonalityOverlay(preset, base) {
9098
9293
  ${preset.systemPrompt}`;
9099
9294
  }
9100
9295
  async function localAgentUsePersonality(agent, name, opts) {
9101
- if (chunkVY6NKMOA_cjs.currentPersonalityContext() !== void 0) {
9102
- chunkVY6NKMOA_cjs.warnPersonalitySwitchInsideFork(agent.agentId);
9296
+ if (chunk7IZKTQ5G_cjs.currentPersonalityContext() !== void 0) {
9297
+ chunk7IZKTQ5G_cjs.warnPersonalitySwitchInsideFork(agent.agentId);
9103
9298
  return null;
9104
9299
  }
9105
9300
  if (agent.personalityRegistry === void 0) {
@@ -9160,7 +9355,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
9160
9355
  async function localAgentFork(parent, options) {
9161
9356
  const { forkAgentImpl } = await import('./fork-agent-WAEQI2DL.cjs');
9162
9357
  const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
9163
- const { withPersonalityContext } = await import('./context-JTGSBJT6.cjs');
9358
+ const { withPersonalityContext } = await import('./context-HR4KMXMA.cjs');
9164
9359
  const create = getAgentFacade().create;
9165
9360
  return withPersonalityContext(
9166
9361
  { slug: parent.personalitySlugSnapshot, isFork: true },
@@ -9953,7 +10148,7 @@ var LocalAgent = class {
9953
10148
  if (sub.plugins !== void 0) this.plugins = sub.plugins;
9954
10149
  reportUnknownLocalOptions(options.local);
9955
10150
  const compatSources = resolveCompatSources(options, this.workspaceCwd);
9956
- chunk43YXGD3P_cjs.reportUndeclaredSources(this.workspaceCwd, compatSources);
10151
+ chunkTY56BKSK_cjs.reportUndeclaredSources(this.workspaceCwd, compatSources);
9957
10152
  this.hooksExecutor = new HooksExecutor(this.workspaceCwd, compatSources, options.local?.hooks);
9958
10153
  this.defaultMemoryProviderForLoop = createLocalAgentMemoryProvider({
9959
10154
  agentOptions: options,
@@ -9981,7 +10176,7 @@ var LocalAgent = class {
9981
10176
  if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
9982
10177
  const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
9983
10178
  await this.pluginManagerCode.initialize(codePlugins);
9984
- this.resolvedSubagents = await chunkAYA65JA5_cjs.loadSubagents(
10179
+ this.resolvedSubagents = await chunkRWPLWMCZ_cjs.loadSubagents(
9985
10180
  this.workspaceCwd,
9986
10181
  this.settingSourcesIncludeProject,
9987
10182
  this.options.agents,
@@ -10937,7 +11132,7 @@ var Agent = class _Agent {
10937
11132
  */
10938
11133
  static async describe(agentId) {
10939
11134
  const agent = await getRegisteredAgentOrThrow(agentId);
10940
- const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-DN4LETGL.cjs');
11135
+ const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-MOO7DC4E.cjs');
10941
11136
  const settingSources = agent.options.local?.settingSources;
10942
11137
  const subagents = await loadSubagents2(
10943
11138
  agent.cwd ?? process.cwd(),
@@ -11053,7 +11248,9 @@ exports.UsageAccumulator = UsageAccumulator;
11053
11248
  exports.computeCost = computeCost;
11054
11249
  exports.generateCronId = generateCronId;
11055
11250
  exports.getPricingEntry = getPricingEntry;
11251
+ exports.managedSettingsPathFor = managedSettingsPathFor;
11056
11252
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
11253
+ exports.readManagedSettings = readManagedSettings;
11057
11254
  exports.resolveSessionDir = resolveSessionDir;
11058
- //# sourceMappingURL=chunk-UKJJRU7C.cjs.map
11059
- //# sourceMappingURL=chunk-UKJJRU7C.cjs.map
11255
+ //# sourceMappingURL=chunk-GCHZMH42.cjs.map
11256
+ //# sourceMappingURL=chunk-GCHZMH42.cjs.map