@theokit/sdk 4.56.0 → 4.58.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 (151) hide show
  1. package/CHANGELOG.md +170 -0
  2. package/dist/{agent-K3PQBS7D.js → agent-6WM4QOWS.js} +15 -14
  3. package/dist/{agent-K3PQBS7D.js.map → agent-6WM4QOWS.js.map} +1 -1
  4. package/dist/{agent-PJMBK7HQ.cjs → agent-MIYY7TXV.cjs} +16 -15
  5. package/dist/{agent-PJMBK7HQ.cjs.map → agent-MIYY7TXV.cjs.map} +1 -1
  6. package/dist/agent-session-store-G2BMUZQV.js +7 -0
  7. package/dist/{agent-session-store-P6V3FINW.js.map → agent-session-store-G2BMUZQV.js.map} +1 -1
  8. package/dist/agent-session-store-WAKLOKWK.cjs +24 -0
  9. package/dist/{agent-session-store-ZJ3JSRS4.cjs.map → agent-session-store-WAKLOKWK.cjs.map} +1 -1
  10. package/dist/{chunk-6VLKVX7O.cjs → chunk-27AXGJMV.cjs} +26 -15
  11. package/dist/chunk-27AXGJMV.cjs.map +1 -0
  12. package/dist/{chunk-HLPSLDGL.cjs → chunk-43GFJ5SD.cjs} +7 -7
  13. package/dist/{chunk-HLPSLDGL.cjs.map → chunk-43GFJ5SD.cjs.map} +1 -1
  14. package/dist/{chunk-M7UHYBEY.js → chunk-5QOIQJ5J.js} +3 -3
  15. package/dist/{chunk-M7UHYBEY.js.map → chunk-5QOIQJ5J.js.map} +1 -1
  16. package/dist/{chunk-E3WZ6Y4H.cjs → chunk-7BG5UH3T.cjs} +8 -8
  17. package/dist/{chunk-E3WZ6Y4H.cjs.map → chunk-7BG5UH3T.cjs.map} +1 -1
  18. package/dist/chunk-AQO3NSRG.cjs +41 -0
  19. package/dist/chunk-AQO3NSRG.cjs.map +1 -0
  20. package/dist/{chunk-JHPGF3FP.cjs → chunk-BUIK7GUA.cjs} +22 -2
  21. package/dist/chunk-BUIK7GUA.cjs.map +1 -0
  22. package/dist/{chunk-KBXWEWKS.js → chunk-CF5OMCZG.js} +87 -43
  23. package/dist/chunk-CF5OMCZG.js.map +1 -0
  24. package/dist/{chunk-DZBSJX6J.js → chunk-FKMUFNQE.js} +21 -4
  25. package/dist/chunk-FKMUFNQE.js.map +1 -0
  26. package/dist/{chunk-BMAZLQQ4.js → chunk-G24KZRSA.js} +3 -3
  27. package/dist/{chunk-BMAZLQQ4.js.map → chunk-G24KZRSA.js.map} +1 -1
  28. package/dist/{chunk-MVAPK2BX.js → chunk-IACR5LEM.js} +3 -3
  29. package/dist/{chunk-MVAPK2BX.js.map → chunk-IACR5LEM.js.map} +1 -1
  30. package/dist/{chunk-U2AC6JUP.cjs → chunk-J2UROOIG.cjs} +2 -27
  31. package/dist/chunk-J2UROOIG.cjs.map +1 -0
  32. package/dist/{chunk-V2UUGUY4.cjs → chunk-KKK3FZ4A.cjs} +6 -6
  33. package/dist/{chunk-V2UUGUY4.cjs.map → chunk-KKK3FZ4A.cjs.map} +1 -1
  34. package/dist/{chunk-ZNW6V4Y6.cjs → chunk-LKFET5A3.cjs} +23 -2
  35. package/dist/chunk-LKFET5A3.cjs.map +1 -0
  36. package/dist/{chunk-YMA4S2WO.js → chunk-MZ2FGBLZ.js} +33 -11
  37. package/dist/chunk-MZ2FGBLZ.js.map +1 -0
  38. package/dist/{chunk-LQYQHXIW.cjs → chunk-N47KLTKD.cjs} +163 -119
  39. package/dist/chunk-N47KLTKD.cjs.map +1 -0
  40. package/dist/{chunk-53CBTBWO.cjs → chunk-P6H23T43.cjs} +33 -11
  41. package/dist/chunk-P6H23T43.cjs.map +1 -0
  42. package/dist/{chunk-YPJ5NH5N.cjs → chunk-QI7WE46I.cjs} +29 -6
  43. package/dist/chunk-QI7WE46I.cjs.map +1 -0
  44. package/dist/{chunk-H5GOSXSC.cjs → chunk-QIRDQZYL.cjs} +4 -4
  45. package/dist/{chunk-H5GOSXSC.cjs.map → chunk-QIRDQZYL.cjs.map} +1 -1
  46. package/dist/{chunk-7FHZ4VQX.js → chunk-SAVIWMZB.js} +3 -3
  47. package/dist/{chunk-7FHZ4VQX.js.map → chunk-SAVIWMZB.js.map} +1 -1
  48. package/dist/{chunk-UPRJR6IP.js → chunk-UCBJBJ27.js} +3 -25
  49. package/dist/chunk-UCBJBJ27.js.map +1 -0
  50. package/dist/chunk-UFLD2HEV.js +35 -0
  51. package/dist/chunk-UFLD2HEV.js.map +1 -0
  52. package/dist/{chunk-GTKFV7O5.js → chunk-WFC26L6Y.js} +23 -2
  53. package/dist/chunk-WFC26L6Y.js.map +1 -0
  54. package/dist/{chunk-OHBIUXKM.js → chunk-WG7R5W6R.js} +4 -4
  55. package/dist/{chunk-OHBIUXKM.js.map → chunk-WG7R5W6R.js.map} +1 -1
  56. package/dist/{chunk-ODTZ7HX3.js → chunk-WLZ7XRWH.js} +25 -15
  57. package/dist/chunk-WLZ7XRWH.js.map +1 -0
  58. package/dist/{chunk-HJBMA5MB.cjs → chunk-WNTAPVU5.cjs} +47 -6
  59. package/dist/chunk-WNTAPVU5.cjs.map +1 -0
  60. package/dist/{chunk-GJ6RK75E.js → chunk-YJDH3CKG.js} +29 -6
  61. package/dist/chunk-YJDH3CKG.js.map +1 -0
  62. package/dist/{chunk-CTCGWIUD.cjs → chunk-Z4BCLVTI.cjs} +5 -5
  63. package/dist/{chunk-CTCGWIUD.cjs.map → chunk-Z4BCLVTI.cjs.map} +1 -1
  64. package/dist/{chunk-2QKTVKH3.js → chunk-ZHPWGIUX.js} +48 -8
  65. package/dist/chunk-ZHPWGIUX.js.map +1 -0
  66. package/dist/{compact-session-FUJDVF7B.js → compact-session-QGDNP45U.js} +4 -4
  67. package/dist/{compact-session-FUJDVF7B.js.map → compact-session-QGDNP45U.js.map} +1 -1
  68. package/dist/{compact-session-LEWF554G.cjs → compact-session-YHFQIXV5.cjs} +12 -12
  69. package/dist/{compact-session-LEWF554G.cjs.map → compact-session-YHFQIXV5.cjs.map} +1 -1
  70. package/dist/context/index.cjs +7 -7
  71. package/dist/context/index.js +3 -3
  72. package/dist/{context-VMIE4BMD.cjs → context-LCKNH2XI.cjs} +7 -6
  73. package/dist/{context-VMIE4BMD.cjs.map → context-LCKNH2XI.cjs.map} +1 -1
  74. package/dist/context-MZSKGKYR.js +7 -0
  75. package/dist/{context-FDOON2DB.js.map → context-MZSKGKYR.js.map} +1 -1
  76. package/dist/cron.cjs +15 -14
  77. package/dist/cron.js +14 -13
  78. package/dist/eval.cjs +14 -13
  79. package/dist/eval.cjs.map +1 -1
  80. package/dist/eval.js +13 -12
  81. package/dist/eval.js.map +1 -1
  82. package/dist/{fs-session-store-IN7JTTXD.js → fs-session-store-4BHGIWRE.js} +4 -4
  83. package/dist/{fs-session-store-IN7JTTXD.js.map → fs-session-store-4BHGIWRE.js.map} +1 -1
  84. package/dist/{fs-session-store-3MOJQGP2.cjs → fs-session-store-XZ7ZTB3A.cjs} +5 -5
  85. package/dist/{fs-session-store-3MOJQGP2.cjs.map → fs-session-store-XZ7ZTB3A.cjs.map} +1 -1
  86. package/dist/{index-manager-WC5ZVJWO.cjs → index-manager-J2QIDI6I.cjs} +5 -4
  87. package/dist/{index-manager-WC5ZVJWO.cjs.map → index-manager-J2QIDI6I.cjs.map} +1 -1
  88. package/dist/{index-manager-WBIMDVQT.js → index-manager-WYESAVTX.js} +4 -3
  89. package/dist/{index-manager-WBIMDVQT.js.map → index-manager-WYESAVTX.js.map} +1 -1
  90. package/dist/index.cjs +44 -45
  91. package/dist/index.cjs.map +1 -1
  92. package/dist/index.d.cts +1 -1
  93. package/dist/index.d.ts +1 -1
  94. package/dist/index.js +17 -18
  95. package/dist/index.js.map +1 -1
  96. package/dist/{inject-session-WQGGMCQY.cjs → inject-session-MLCJMYDG.cjs} +7 -7
  97. package/dist/{inject-session-WQGGMCQY.cjs.map → inject-session-MLCJMYDG.cjs.map} +1 -1
  98. package/dist/{inject-session-BJMJH5BX.js → inject-session-RBQZ45UM.js} +5 -5
  99. package/dist/{inject-session-BJMJH5BX.js.map → inject-session-RBQZ45UM.js.map} +1 -1
  100. package/dist/internal/memory/storage/markdown-store.d.ts +13 -0
  101. package/dist/internal/persistence/index.cjs +17 -16
  102. package/dist/internal/persistence/index.cjs.map +1 -1
  103. package/dist/internal/persistence/index.js +2 -1
  104. package/dist/internal/persistence/index.js.map +1 -1
  105. package/dist/internal/persistence/paths.d.cts +42 -0
  106. package/dist/internal/persistence/paths.d.ts +42 -0
  107. package/dist/internal/persistence/session-transcript.d.cts +40 -1
  108. package/dist/internal/persistence/session-transcript.d.ts +40 -1
  109. package/dist/internal/runtime/plugins/plugin-bundles.d.ts +19 -0
  110. package/dist/persistence.cjs +4 -4
  111. package/dist/persistence.js +1 -1
  112. package/dist/project.cjs +3 -3
  113. package/dist/project.js +1 -1
  114. package/dist/session-transcript-HF5GEU5M.cjs +63 -0
  115. package/dist/{session-transcript-JXHFTB7G.cjs.map → session-transcript-HF5GEU5M.cjs.map} +1 -1
  116. package/dist/session-transcript-P462ZRHX.js +6 -0
  117. package/dist/{session-transcript-AKDYYGXQ.js.map → session-transcript-P462ZRHX.js.map} +1 -1
  118. package/dist/subagents-loader-6ATCDEKN.js +8 -0
  119. package/dist/{subagents-loader-J54ESLDV.js.map → subagents-loader-6ATCDEKN.js.map} +1 -1
  120. package/dist/subagents-loader-X5QKODCL.cjs +17 -0
  121. package/dist/{subagents-loader-AZIXJ7D3.cjs.map → subagents-loader-X5QKODCL.cjs.map} +1 -1
  122. package/dist/subagents-loader.cjs +3 -2
  123. package/dist/subagents-loader.cjs.map +1 -1
  124. package/dist/subagents-loader.js +2 -1
  125. package/dist/subagents-loader.js.map +1 -1
  126. package/docs/error-codes.md +19 -19
  127. package/docs/harness-capability-map.md +1 -1
  128. package/package.json +5 -9
  129. package/dist/agent-session-store-P6V3FINW.js +0 -7
  130. package/dist/agent-session-store-ZJ3JSRS4.cjs +0 -24
  131. package/dist/chunk-2QKTVKH3.js.map +0 -1
  132. package/dist/chunk-53CBTBWO.cjs.map +0 -1
  133. package/dist/chunk-6VLKVX7O.cjs.map +0 -1
  134. package/dist/chunk-DZBSJX6J.js.map +0 -1
  135. package/dist/chunk-GJ6RK75E.js.map +0 -1
  136. package/dist/chunk-GTKFV7O5.js.map +0 -1
  137. package/dist/chunk-HJBMA5MB.cjs.map +0 -1
  138. package/dist/chunk-JHPGF3FP.cjs.map +0 -1
  139. package/dist/chunk-KBXWEWKS.js.map +0 -1
  140. package/dist/chunk-LQYQHXIW.cjs.map +0 -1
  141. package/dist/chunk-ODTZ7HX3.js.map +0 -1
  142. package/dist/chunk-U2AC6JUP.cjs.map +0 -1
  143. package/dist/chunk-UPRJR6IP.js.map +0 -1
  144. package/dist/chunk-YMA4S2WO.js.map +0 -1
  145. package/dist/chunk-YPJ5NH5N.cjs.map +0 -1
  146. package/dist/chunk-ZNW6V4Y6.cjs.map +0 -1
  147. package/dist/context-FDOON2DB.js +0 -6
  148. package/dist/session-transcript-AKDYYGXQ.js +0 -6
  149. package/dist/session-transcript-JXHFTB7G.cjs +0 -51
  150. package/dist/subagents-loader-AZIXJ7D3.cjs +0 -16
  151. package/dist/subagents-loader-J54ESLDV.js +0 -7
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkV2UUGUY4_cjs = require('./chunk-V2UUGUY4.cjs');
4
- var chunk6VLKVX7O_cjs = require('./chunk-6VLKVX7O.cjs');
5
- var chunk53CBTBWO_cjs = require('./chunk-53CBTBWO.cjs');
3
+ var chunkKKK3FZ4A_cjs = require('./chunk-KKK3FZ4A.cjs');
4
+ var chunk27AXGJMV_cjs = require('./chunk-27AXGJMV.cjs');
5
+ var chunkP6H23T43_cjs = require('./chunk-P6H23T43.cjs');
6
6
  var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
7
7
  var chunkNGESVVJN_cjs = require('./chunk-NGESVVJN.cjs');
8
8
  var chunkEI2Q7SJ5_cjs = require('./chunk-EI2Q7SJ5.cjs');
9
- var chunkYPJ5NH5N_cjs = require('./chunk-YPJ5NH5N.cjs');
10
- var chunkHLPSLDGL_cjs = require('./chunk-HLPSLDGL.cjs');
9
+ var chunkQI7WE46I_cjs = require('./chunk-QI7WE46I.cjs');
10
+ var chunk43GFJ5SD_cjs = require('./chunk-43GFJ5SD.cjs');
11
11
  var chunk2ZPEDVLM_cjs = require('./chunk-2ZPEDVLM.cjs');
12
- var chunkE3WZ6Y4H_cjs = require('./chunk-E3WZ6Y4H.cjs');
13
- var chunkU2AC6JUP_cjs = require('./chunk-U2AC6JUP.cjs');
12
+ var chunk7BG5UH3T_cjs = require('./chunk-7BG5UH3T.cjs');
13
+ var chunkJ2UROOIG_cjs = require('./chunk-J2UROOIG.cjs');
14
14
  var chunkWJVHMTKB_cjs = require('./chunk-WJVHMTKB.cjs');
15
15
  var chunk6JSIEDKL_cjs = require('./chunk-6JSIEDKL.cjs');
16
16
  var chunk4O5TGQBW_cjs = require('./chunk-4O5TGQBW.cjs');
@@ -20,11 +20,12 @@ var chunkVJ26EKGJ_cjs = require('./chunk-VJ26EKGJ.cjs');
20
20
  var chunkR3UPQFKK_cjs = require('./chunk-R3UPQFKK.cjs');
21
21
  var chunkVKJ7V7EB_cjs = require('./chunk-VKJ7V7EB.cjs');
22
22
  var chunkILCGLTSA_cjs = require('./chunk-ILCGLTSA.cjs');
23
- var chunkJHPGF3FP_cjs = require('./chunk-JHPGF3FP.cjs');
23
+ var chunkBUIK7GUA_cjs = require('./chunk-BUIK7GUA.cjs');
24
24
  var chunk2ADR2GSO_cjs = require('./chunk-2ADR2GSO.cjs');
25
25
  var chunkZF2LDKQQ_cjs = require('./chunk-ZF2LDKQQ.cjs');
26
26
  var chunkI6TGFUCO_cjs = require('./chunk-I6TGFUCO.cjs');
27
- var chunkHJBMA5MB_cjs = require('./chunk-HJBMA5MB.cjs');
27
+ var chunkWNTAPVU5_cjs = require('./chunk-WNTAPVU5.cjs');
28
+ var chunkAQO3NSRG_cjs = require('./chunk-AQO3NSRG.cjs');
28
29
  var chunkIWBGCBR6_cjs = require('./chunk-IWBGCBR6.cjs');
29
30
  var chunkXSX2UU6Y_cjs = require('./chunk-XSX2UU6Y.cjs');
30
31
  var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
@@ -453,7 +454,7 @@ function registryPath(cwd) {
453
454
  return path.join(cwd, REGISTRY_RELATIVE_PATH);
454
455
  }
455
456
  async function loadRegistry(cwd) {
456
- return chunkU2AC6JUP_cjs.readVersionedJson({
457
+ return chunkJ2UROOIG_cjs.readVersionedJson({
457
458
  path: registryPath(cwd),
458
459
  currentVersion: SCHEMA_VERSION,
459
460
  defaultValue: () => ({}),
@@ -477,7 +478,7 @@ async function saveRegistry(cwd, agents2) {
477
478
  }
478
479
  const path = registryPath(cwd);
479
480
  await chunkZF2LDKQQ_cjs.withCwdMutex(`registry:${cwd}`, async () => {
480
- await chunkU2AC6JUP_cjs.writeVersionedJson(path, serialized, SCHEMA_VERSION);
481
+ await chunkJ2UROOIG_cjs.writeVersionedJson(path, serialized, SCHEMA_VERSION);
481
482
  });
482
483
  }
483
484
  function toSerialized(agent) {
@@ -884,7 +885,7 @@ async function readLegacyFacts(jsonPath) {
884
885
  }
885
886
  async function writeMigratedFacts(cwd, jsonPath, facts) {
886
887
  try {
887
- for (const fact of facts) await chunk6VLKVX7O_cjs.appendFactToMarkdown(cwd, fact);
888
+ for (const fact of facts) await chunk27AXGJMV_cjs.appendFactToMarkdown(cwd, fact);
888
889
  await promises.unlink(jsonPath).catch(() => void 0);
889
890
  chunkNUKRL3I6_cjs.diag(`[theokit-sdk] migrated ${facts.length} fact(s) from ${jsonPath} to MEMORY.md
890
891
  `);
@@ -901,11 +902,11 @@ async function migrateLegacyJson(cwd, config) {
901
902
  const key = `${cwd}::${config.namespace ?? "default"}::${config.scope ?? "agent"}::${config.userId ?? "default"}`;
902
903
  if (migrationRun.has(key)) return { migrated: false, factCount: 0, reason: "already-migrated" };
903
904
  migrationRun.add(key);
904
- const jsonPath = chunk6VLKVX7O_cjs.legacyMemoryJsonPath(cwd, config);
905
+ const jsonPath = chunk27AXGJMV_cjs.legacyMemoryJsonPath(cwd, config);
905
906
  if (!await fileExists(jsonPath)) {
906
907
  return { migrated: false, factCount: 0, reason: "no-legacy-json" };
907
908
  }
908
- if (await fileExists(chunk6VLKVX7O_cjs.memoryMdPath(cwd))) {
909
+ if (await fileExists(chunk27AXGJMV_cjs.memoryMdPath(cwd))) {
909
910
  chunkNUKRL3I6_cjs.diag(
910
911
  `[theokit-sdk] memory migration skipped: both MEMORY.md and legacy JSON exist at ${jsonPath}; leaving both intact
911
912
  `
@@ -918,25 +919,35 @@ async function migrateLegacyJson(cwd, config) {
918
919
  }
919
920
 
920
921
  // src/internal/runtime/memory/memory-store.ts
921
- var REMEMBER_PATTERN = /^\s*Remember(?:\s+this\s+durable\s+preference)?\s*:\s*(.+)$/i;
922
+ var REMEMBER_PATTERN = /^\s*Remember(?:\s+this\s+durable\s+preference)?\s*(?:\((user|feedback|project|reference)\))?\s*:\s*(.+)$/i;
922
923
  function isMemoryWritePrompt(message) {
923
924
  return REMEMBER_PATTERN.test(message) || message.includes("Remember this durable");
924
925
  }
925
926
  function extractMemoryFact(message) {
926
927
  const match = REMEMBER_PATTERN.exec(message);
927
- if (match === null || match[1] === void 0) return "";
928
- return match[1].trim().replace(/\.$/, "");
928
+ if (match === null || match[2] === void 0) return "";
929
+ return match[2].trim().replace(/\.$/, "");
930
+ }
931
+ function extractMemoryKind(message) {
932
+ const match = REMEMBER_PATTERN.exec(message);
933
+ const declared = match?.[1];
934
+ if (declared === void 0) return void 0;
935
+ const lowered = declared.toLowerCase();
936
+ return chunk27AXGJMV_cjs.MEMORY_KINDS.includes(lowered) ? lowered : void 0;
929
937
  }
930
938
  async function readMemoryFacts(cwd, config) {
931
939
  if (!config.enabled) return [];
932
940
  await migrateLegacyJson(cwd, config);
933
- return chunk6VLKVX7O_cjs.readFacts(cwd, config);
941
+ return chunk27AXGJMV_cjs.readFacts(cwd, config);
934
942
  }
935
943
  async function appendMemoryFact(cwd, config, fact) {
936
944
  if (!config.enabled) return;
937
945
  await migrateLegacyJson(cwd, config);
938
- const sanitized = { text: chunkJTB5Q42C_cjs.redactSecrets(fact.text) };
939
- await chunk6VLKVX7O_cjs.appendFact(cwd, config, sanitized);
946
+ const sanitized = {
947
+ text: chunkJTB5Q42C_cjs.redactSecrets(fact.text),
948
+ ...fact.kind === void 0 ? {} : { kind: fact.kind }
949
+ };
950
+ await chunk27AXGJMV_cjs.appendFact(cwd, config, sanitized);
940
951
  }
941
952
 
942
953
  // src/internal/runtime/fixtures/fixture-scripts.ts
@@ -1607,7 +1618,7 @@ function createRealCloudRun(options) {
1607
1618
  conversation: []
1608
1619
  };
1609
1620
  const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(options.agentOptions.apiKey);
1610
- const baseUrl = chunkHLPSLDGL_cjs.getConfiguredBaseUrl();
1621
+ const baseUrl = chunk43GFJ5SD_cjs.getConfiguredBaseUrl();
1611
1622
  const handle = new RealCloudRun(
1612
1623
  {
1613
1624
  id,
@@ -1690,7 +1701,7 @@ var RealCloudRun = class extends FixtureRunBase {
1690
1701
  async consumeStream(response) {
1691
1702
  let finalStatus = "finished";
1692
1703
  let finalText = "";
1693
- for await (const record of chunkHLPSLDGL_cjs.parseSseStream(response.body, this.controller.signal)) {
1704
+ for await (const record of chunk43GFJ5SD_cjs.parseSseStream(response.body, this.controller.signal)) {
1694
1705
  const parsed = safeParse(record.data);
1695
1706
  if (parsed === void 0) continue;
1696
1707
  const update = this.applyRecord(record.event, parsed);
@@ -1836,7 +1847,7 @@ var CloudAgent = class {
1836
1847
  */
1837
1848
  isFixtureMode() {
1838
1849
  const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(this.options.apiKey);
1839
- return chunkHLPSLDGL_cjs.isFixtureApiKey(apiKey) && chunkHLPSLDGL_cjs.getConfiguredBaseUrl() === void 0;
1850
+ return chunk43GFJ5SD_cjs.isFixtureApiKey(apiKey) && chunk43GFJ5SD_cjs.getConfiguredBaseUrl() === void 0;
1840
1851
  }
1841
1852
  // SE9 — integrated structured output; delegates to the shared helper.
1842
1853
  generate(message, options) {
@@ -1888,7 +1899,7 @@ var CloudAgent = class {
1888
1899
  const userText = typeof message === "string" ? message : message.text;
1889
1900
  const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
1890
1901
  const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(this.options.apiKey);
1891
- const useRealRuntime = apiKey !== void 0 && !chunkHLPSLDGL_cjs.isFixtureApiKey(apiKey) && chunkHLPSLDGL_cjs.getConfiguredBaseUrl() !== void 0;
1902
+ const useRealRuntime = apiKey !== void 0 && !chunk43GFJ5SD_cjs.isFixtureApiKey(apiKey) && chunk43GFJ5SD_cjs.getConfiguredBaseUrl() !== void 0;
1892
1903
  return useRealRuntime ? createRealCloudRun({
1893
1904
  agentId: this.agentId,
1894
1905
  model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
@@ -2113,15 +2124,15 @@ function resolveSessionDir(local) {
2113
2124
  "[theokit-sdk] local.sessionDir and local.baseDir are both set; using sessionDir. baseDir is the deprecated name for the same option (#301)."
2114
2125
  );
2115
2126
  }
2116
- return chunkJHPGF3FP_cjs.expandTilde(local.sessionDir);
2127
+ return chunkBUIK7GUA_cjs.expandTilde(local.sessionDir);
2117
2128
  }
2118
2129
  if (local?.baseDir !== void 0) {
2119
2130
  chunkNUKRL3I6_cjs.diag(
2120
2131
  "[theokit-sdk] local.baseDir is deprecated; rename it to local.sessionDir (#301). It is the directory for session transcripts, not the working directory \u2014 that is local.cwd."
2121
2132
  );
2122
- return chunkJHPGF3FP_cjs.expandTilde(local.baseDir);
2133
+ return chunkBUIK7GUA_cjs.expandTilde(local.baseDir);
2123
2134
  }
2124
- return chunkJHPGF3FP_cjs.defaultBaseDir();
2135
+ return chunkBUIK7GUA_cjs.defaultBaseDir();
2125
2136
  }
2126
2137
  var SCHEMA_VERSION2 = 1;
2127
2138
  var FILE_NAME = "personality.json";
@@ -2148,14 +2159,14 @@ async function readState(filePath) {
2148
2159
  try {
2149
2160
  parsed = JSON.parse(raw);
2150
2161
  } catch {
2151
- chunk53CBTBWO_cjs.warnOnce(
2162
+ chunkP6H23T43_cjs.warnOnce(
2152
2163
  "personality-store-json-parse",
2153
2164
  "[theokit-sdk] personality.json is malformed; treating as empty"
2154
2165
  );
2155
2166
  return emptyState();
2156
2167
  }
2157
2168
  if (!isStateV1(parsed)) {
2158
- chunk53CBTBWO_cjs.warnOnce(
2169
+ chunkP6H23T43_cjs.warnOnce(
2159
2170
  "personality-store-bad-version",
2160
2171
  `[theokit-sdk] personality.json has unknown version; treating as empty (file kept untouched)`
2161
2172
  );
@@ -2186,7 +2197,7 @@ var PersonalityStore = class {
2186
2197
  try {
2187
2198
  await this.#persist(agentId, slug);
2188
2199
  } catch (err) {
2189
- chunk53CBTBWO_cjs.warnOnce(
2200
+ chunkP6H23T43_cjs.warnOnce(
2190
2201
  `personality-store-persist-failure-${agentId}`,
2191
2202
  `[theokit-sdk] personality persist failed for ${chunkJTB5Q42C_cjs.redactSecrets(agentId)}: ${chunkJTB5Q42C_cjs.redactSecrets(
2192
2203
  err.message
@@ -2203,7 +2214,7 @@ var PersonalityStore = class {
2203
2214
  try {
2204
2215
  state = await readState(filePath);
2205
2216
  } catch (err) {
2206
- chunk53CBTBWO_cjs.warnOnce(
2217
+ chunkP6H23T43_cjs.warnOnce(
2207
2218
  `personality-store-hydrate-failure-${agentId}`,
2208
2219
  `[theokit-sdk] personality hydrate failed for ${chunkJTB5Q42C_cjs.redactSecrets(agentId)}: ${chunkJTB5Q42C_cjs.redactSecrets(
2209
2220
  err.message
@@ -2232,7 +2243,7 @@ var PersonalityStore = class {
2232
2243
  });
2233
2244
  }
2234
2245
  #filePath() {
2235
- return path.join(chunkU2AC6JUP_cjs.getTheokitHome(this.#cwd), FILE_NAME);
2246
+ return path.join(chunkAQO3NSRG_cjs.getTheokitHome(this.#cwd), FILE_NAME);
2236
2247
  }
2237
2248
  };
2238
2249
 
@@ -2593,7 +2604,7 @@ var HooksExecutor = class {
2593
2604
  this.config = {};
2594
2605
  return;
2595
2606
  }
2596
- this.config = await chunk53CBTBWO_cjs.loadHookConfig(this.cwd);
2607
+ this.config = await chunkP6H23T43_cjs.loadHookConfig(this.cwd);
2597
2608
  }
2598
2609
  /** Fire every hook registered for `event` and aggregate the decisions. */
2599
2610
  async run(payload) {
@@ -2730,7 +2741,7 @@ async function runPostRunLifecycle(inputs) {
2730
2741
  try {
2731
2742
  const partial = await safeConversation(run);
2732
2743
  if (partial !== void 0) {
2733
- chunkV2UUGUY4_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2744
+ chunkKKK3FZ4A_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2734
2745
  userText,
2735
2746
  conversation: partial
2736
2747
  });
@@ -2740,11 +2751,11 @@ async function runPostRunLifecycle(inputs) {
2740
2751
  chunkNUKRL3I6_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
2741
2752
  `);
2742
2753
  }
2743
- await chunkV2UUGUY4_cjs.flushSessionWrites();
2754
+ await chunkKKK3FZ4A_cjs.flushSessionWrites();
2744
2755
  return;
2745
2756
  }
2746
2757
  if (result.result !== void 0) {
2747
- chunkV2UUGUY4_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2758
+ chunkKKK3FZ4A_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
2748
2759
  }
2749
2760
  const conversation = await safeConversation(run);
2750
2761
  const resolvedWindow = resolveWindowForRun(model, contextWindow);
@@ -2755,7 +2766,7 @@ async function runPostRunLifecycle(inputs) {
2755
2766
  }
2756
2767
  const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
2757
2768
  const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
2758
- chunkV2UUGUY4_cjs.persistTurnToTranscript(
2769
+ chunkKKK3FZ4A_cjs.persistTurnToTranscript(
2759
2770
  sessionStore,
2760
2771
  { cwd: workspaceCwd, agentId, model },
2761
2772
  agentId,
@@ -2767,7 +2778,7 @@ async function runPostRunLifecycle(inputs) {
2767
2778
  // The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
2768
2779
  // `contextWindow` here would budget against a number the clamp already rejected.
2769
2780
  contextWindow: effectiveWindow,
2770
- summarize: chunkHLPSLDGL_cjs.buildDefaultSummarizer({
2781
+ summarize: chunk43GFJ5SD_cjs.buildDefaultSummarizer({
2771
2782
  agentModel: model,
2772
2783
  ...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
2773
2784
  })
@@ -2789,7 +2800,7 @@ async function runPostRunLifecycle(inputs) {
2789
2800
  if (memoryProvider?.recordSessionSummary !== void 0) {
2790
2801
  await memoryProvider.recordSessionSummary(summaryArgs);
2791
2802
  } else {
2792
- await chunk6VLKVX7O_cjs.writeSessionSummary(summaryArgs);
2803
+ await chunk27AXGJMV_cjs.writeSessionSummary(summaryArgs);
2793
2804
  }
2794
2805
  if (!shouldUsePortMemoryPath()) {
2795
2806
  void memoryGlue.syncIfReady();
@@ -2809,7 +2820,7 @@ async function runPostRunLifecycle(inputs) {
2809
2820
  agentId,
2810
2821
  runId: result.id
2811
2822
  });
2812
- await chunkV2UUGUY4_cjs.flushSessionWrites();
2823
+ await chunkKKK3FZ4A_cjs.flushSessionWrites();
2813
2824
  }
2814
2825
  async function safeConversation(run) {
2815
2826
  try {
@@ -2916,13 +2927,24 @@ var SkillsManager = class {
2916
2927
  await this.refresh();
2917
2928
  }
2918
2929
  async refresh() {
2919
- const skillsRoot = this.skillsDir ?? path.join(this.cwd, ".theokit", "skills");
2920
- const discovered = await chunk3YJNUKYN_cjs.discoverSkills(skillsRoot, {
2921
- onInvalidSkill: (info) => {
2922
- chunkNUKRL3I6_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
2930
+ const roots = this.skillsDir === void 0 ? [
2931
+ ...chunkAQO3NSRG_cjs.projectConfigRoots(this.cwd).map((root) => path.join(root, "skills")),
2932
+ ...(await chunkWNTAPVU5_cjs.pluginBundleDirs(this.cwd)).map((bundle) => path.join(bundle, "skills"))
2933
+ ] : [this.skillsDir];
2934
+ const discovered = [];
2935
+ const seen = /* @__PURE__ */ new Set();
2936
+ for (const root of roots) {
2937
+ for (const skill of await chunk3YJNUKYN_cjs.discoverSkills(root, {
2938
+ onInvalidSkill: (info) => {
2939
+ chunkNUKRL3I6_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
2923
2940
  `);
2941
+ }
2942
+ })) {
2943
+ if (seen.has(skill.name)) continue;
2944
+ seen.add(skill.name);
2945
+ discovered.push(skill);
2924
2946
  }
2925
- });
2947
+ }
2926
2948
  this.skills = this.mergeInline(discovered);
2927
2949
  }
2928
2950
  /** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
@@ -3402,7 +3424,7 @@ var HISTOGRAM_NAMES = {
3402
3424
  };
3403
3425
  function safeRequire(moduleName) {
3404
3426
  try {
3405
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-LQYQHXIW.cjs', document.baseURI).href)));
3427
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-N47KLTKD.cjs', document.baseURI).href)));
3406
3428
  return r(moduleName);
3407
3429
  } catch {
3408
3430
  return void 0;
@@ -3630,7 +3652,7 @@ var cachedOtel;
3630
3652
  function loadOtel() {
3631
3653
  if (cachedOtel === void 0) {
3632
3654
  try {
3633
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-LQYQHXIW.cjs', document.baseURI).href)));
3655
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-N47KLTKD.cjs', document.baseURI).href)));
3634
3656
  const mod = r("@opentelemetry/api");
3635
3657
  cachedOtel = mod;
3636
3658
  } catch {
@@ -3949,7 +3971,7 @@ function applyAggregateCap(sources, maxTotal) {
3949
3971
  }
3950
3972
  const remaining = maxTotal - totalBytes;
3951
3973
  if (remaining > 0) {
3952
- const { finalContent } = chunkE3WZ6Y4H_cjs.truncateWithMarker(s.content, remaining);
3974
+ const { finalContent } = chunk7BG5UH3T_cjs.truncateWithMarker(s.content, remaining);
3953
3975
  kept.push({ ...s, content: finalContent, truncated: true });
3954
3976
  totalBytes = maxTotal;
3955
3977
  } else {
@@ -4023,9 +4045,9 @@ var FileContextManager = class {
4023
4045
  this.lastScope = [...touchedFiles];
4024
4046
  const config = await loadContextConfig(this.cwd);
4025
4047
  const legacy = await loadSources(config, this.cwd);
4026
- const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunkE3WZ6Y4H_cjs.DEFAULT_MAX_BYTES_PER_FILE;
4048
+ const maxBytesPerFile = this.settings.maxBytesPerFile ?? chunk7BG5UH3T_cjs.DEFAULT_MAX_BYTES_PER_FILE;
4027
4049
  const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
4028
- const discovered = await chunkE3WZ6Y4H_cjs.runDiscovery({
4050
+ const discovered = await chunk7BG5UH3T_cjs.runDiscovery({
4029
4051
  cwd: this.cwd,
4030
4052
  maxBytesPerFile,
4031
4053
  skipLegacyTheokitContext: true,
@@ -4094,7 +4116,7 @@ async function loadContextConfig(cwd) {
4094
4116
  });
4095
4117
  if (mdEntities.length > 0) {
4096
4118
  if (fs.existsSync(jsonPath)) {
4097
- chunk53CBTBWO_cjs.warnOnce(
4119
+ chunkP6H23T43_cjs.warnOnce(
4098
4120
  "context-both-present",
4099
4121
  "[theokit-sdk] both .theokit/context/ and .theokit/context.json detected \u2014 using markdown; remove context.json"
4100
4122
  );
@@ -4104,7 +4126,7 @@ async function loadContextConfig(cwd) {
4104
4126
  };
4105
4127
  }
4106
4128
  if (!fs.existsSync(jsonPath)) return { sources: [] };
4107
- chunk53CBTBWO_cjs.warnOnce(
4129
+ chunkP6H23T43_cjs.warnOnce(
4108
4130
  "context-json-deprecated",
4109
4131
  "[theokit-sdk] .theokit/context.json is deprecated; migrate to .theokit/context/<name>.md via theokit-migrate-config"
4110
4132
  );
@@ -4238,25 +4260,37 @@ var PluginsManager = class {
4238
4260
  }
4239
4261
  await this.refresh();
4240
4262
  }
4241
- // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: MD-first + JSON fallback + both-present detection per plugin folder — branch table is clearer inlined.
4242
4263
  async refresh() {
4243
4264
  this.plugins = [];
4244
- const pluginsRoot = path.join(this.cwd, ".theokit", "plugins");
4265
+ for (const pluginsRoot of chunkAQO3NSRG_cjs.pluginBundleRoots(this.cwd)) {
4266
+ await this.refreshRoot(pluginsRoot);
4267
+ }
4268
+ }
4269
+ // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: MD-first + JSON fallback + CLI location + both-present detection per plugin folder — branch table is clearer inlined.
4270
+ async refreshRoot(pluginsRoot) {
4245
4271
  const entries = await chunkIWBGCBR6_cjs.readWorkspaceDir(pluginsRoot, "plugins_read_error", "plugins directory");
4246
4272
  for (const entry of entries) {
4247
4273
  if (!entry.isDirectory()) continue;
4248
4274
  const folderName = entry.name;
4275
+ const cliPath = path.join(pluginsRoot, folderName, ".claude-plugin", "plugin.json");
4276
+ if (fs.existsSync(cliPath)) {
4277
+ const cliMetadata = await loadPluginManifestFromJson(cliPath, folderName);
4278
+ if (this.enabled === void 0 || this.enabled.includes(cliMetadata.name)) {
4279
+ this.plugins.push(cliMetadata);
4280
+ }
4281
+ continue;
4282
+ }
4249
4283
  const mdPath = path.join(pluginsRoot, folderName, "PLUGIN.md");
4250
4284
  const jsonPath = path.join(pluginsRoot, folderName, "plugin.json");
4251
4285
  const metadata = fs.existsSync(mdPath) ? await loadPluginManifestFromMarkdown(pluginsRoot, folderName) : await loadPluginManifestFromJson(jsonPath, folderName);
4252
4286
  if (fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
4253
- chunk53CBTBWO_cjs.warnOnce(
4287
+ chunkP6H23T43_cjs.warnOnce(
4254
4288
  `plugin-${folderName}-both`,
4255
4289
  `[theokit-sdk] both ${folderName}/PLUGIN.md and ${folderName}/plugin.json detected \u2014 using markdown; remove plugin.json`
4256
4290
  );
4257
4291
  }
4258
4292
  if (!fs.existsSync(mdPath) && fs.existsSync(jsonPath)) {
4259
- chunk53CBTBWO_cjs.warnOnce(
4293
+ chunkP6H23T43_cjs.warnOnce(
4260
4294
  "plugin-json-deprecated",
4261
4295
  "[theokit-sdk] plugin.json manifests are deprecated; migrate to PLUGIN.md via theokit-migrate-config"
4262
4296
  );
@@ -5872,7 +5906,7 @@ function applyToolResultGuard(parts, opts) {
5872
5906
  (p) => (
5873
5907
  // SE7 — guard the TEXT of a tool result (string or the text blocks of a
5874
5908
  // structured content); image blocks pass through untouched.
5875
- p.type === "tool_result" ? { ...p, content: chunkHLPSLDGL_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
5909
+ p.type === "tool_result" ? { ...p, content: chunk43GFJ5SD_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
5876
5910
  )
5877
5911
  );
5878
5912
  }
@@ -6538,12 +6572,12 @@ var FallbackLlmClient = class {
6538
6572
  let lastError;
6539
6573
  for (const client of this.clients) {
6540
6574
  if (signal.aborted) throw abortError(signal);
6541
- const attempt = await chunkHLPSLDGL_cjs.tryFirstEvent(client, request, signal, true);
6575
+ const attempt = await chunk43GFJ5SD_cjs.tryFirstEvent(client, request, signal, true);
6542
6576
  if (attempt.kind === "handshake_error") {
6543
6577
  lastError = attempt.error;
6544
6578
  continue;
6545
6579
  }
6546
- return yield* chunkHLPSLDGL_cjs.relayStream(attempt.generator, attempt.firstResult);
6580
+ return yield* chunk43GFJ5SD_cjs.relayStream(attempt.generator, attempt.firstResult);
6547
6581
  }
6548
6582
  if (lastError !== void 0) throw lastError;
6549
6583
  throw new chunkK3FW2XZD_cjs.NetworkError("FallbackLlmClient has no providers configured", {
@@ -7004,7 +7038,7 @@ function applyPersonalityFilter(exposedTools, whitelist, opts) {
7004
7038
  if (exposedSet.has(name)) continue;
7005
7039
  const hint = suggestClosest(name, exposedSet);
7006
7040
  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)`;
7007
- chunk53CBTBWO_cjs.warnOnce(
7041
+ chunkP6H23T43_cjs.warnOnce(
7008
7042
  `personality-tool-missing|${opts?.agentId ?? "?"}|${opts?.personalityName ?? "?"}|${name}`,
7009
7043
  message
7010
7044
  );
@@ -7130,15 +7164,15 @@ function resolveRunProvider(options) {
7130
7164
  }
7131
7165
  const parsedModel = chunk3EE6LVWT_cjs.parseModelId(options.model?.id);
7132
7166
  const modelInferredProvider = parsedModel.provider !== void 0 && chunkNIRE5CNO_cjs.getProviderProfile(parsedModel.provider) !== void 0 ? parsedModel.provider : void 0;
7133
- const keyInferredProvider = chunkHLPSLDGL_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
7134
- const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunkHLPSLDGL_cjs.detectPrimaryProvider();
7135
- chunkHLPSLDGL_cjs.warnProviderPrecedenceOnce(modelInferredProvider, primary);
7167
+ const keyInferredProvider = chunk43GFJ5SD_cjs.inferProviderFromApiKey(options.agentOptions.apiKey);
7168
+ const primary = options.agentOptions.providers?.routes?.[0]?.provider ?? keyInferredProvider ?? modelInferredProvider ?? chunk43GFJ5SD_cjs.detectPrimaryProvider();
7169
+ chunk43GFJ5SD_cjs.warnProviderPrecedenceOnce(modelInferredProvider, primary);
7136
7170
  const effectiveModelId = modelInferredProvider !== void 0 && modelInferredProvider === primary ? parsedModel.name : options.model?.id ?? "claude-sonnet-4-6";
7137
7171
  return { primary, effectiveModelId };
7138
7172
  }
7139
7173
  function mergeExplicitApiKey(pools, primary, apiKey) {
7140
7174
  if (apiKey === void 0 || apiKey.length === 0) return pools;
7141
- if (chunkHLPSLDGL_cjs.isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
7175
+ if (chunk43GFJ5SD_cjs.isFixtureApiKey(apiKey) || apiKey === LOCAL_RUNTIME_MOCK_KEY) return pools;
7142
7176
  const existing = pools?.[primary];
7143
7177
  if (existing !== void 0 && existing.length > 0) return pools;
7144
7178
  return { ...pools ?? {}, [primary]: [apiKey] };
@@ -7162,7 +7196,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
7162
7196
  const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
7163
7197
  const rateLimitSink = options.sendOptions.onRunEvent;
7164
7198
  const modelBaseUrl = options.model?.url;
7165
- const chain = chunkHLPSLDGL_cjs.resolveProviderChain({
7199
+ const chain = chunk43GFJ5SD_cjs.resolveProviderChain({
7166
7200
  primary,
7167
7201
  ...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
7168
7202
  ...fallback !== void 0 ? { fallback } : {},
@@ -7445,7 +7479,7 @@ function buildRealRunOptions(args) {
7445
7479
  };
7446
7480
  }
7447
7481
  async function createFixtureRunHelper(args) {
7448
- const sessionMessages = chunkV2UUGUY4_cjs.getSessionMessages(args.inputs.agentId);
7482
+ const sessionMessages = chunkKKK3FZ4A_cjs.getSessionMessages(args.inputs.agentId);
7449
7483
  const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
7450
7484
  return createLocalRun({
7451
7485
  agentId: args.inputs.agentId,
@@ -7464,7 +7498,7 @@ async function createFixtureRunHelper(args) {
7464
7498
  }
7465
7499
  async function dispatchLocalRun(args) {
7466
7500
  const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(args.inputs.options.apiKey);
7467
- if (chunkHLPSLDGL_cjs.shouldUseRealLocalRuntime(apiKey)) {
7501
+ if (chunk43GFJ5SD_cjs.shouldUseRealLocalRuntime(apiKey)) {
7468
7502
  return createRealLocalRun(
7469
7503
  buildRealRunOptions({
7470
7504
  inputs: args.inputs,
@@ -7720,16 +7754,16 @@ async function disposeLocalAgentSession(agent) {
7720
7754
  agent.lifecycleAbortController.abort();
7721
7755
  await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
7722
7756
  disposeSessionMcpClients(agent.agentId);
7723
- await chunkV2UUGUY4_cjs.flushSessionWrites();
7757
+ await chunkKKK3FZ4A_cjs.flushSessionWrites();
7724
7758
  await flushRegistrySaves(agent.workspaceCwd);
7725
7759
  await disposeSessionStore(agent.sessionStore);
7726
- chunkV2UUGUY4_cjs.discardSession(agent.workspaceCwd, agent.agentId);
7760
+ chunkKKK3FZ4A_cjs.discardSession(agent.workspaceCwd, agent.agentId);
7727
7761
  }
7728
7762
  async function reloadLocalAgent(agent) {
7729
7763
  if (agent.context !== void 0) await agent.context.refresh();
7730
7764
  if (agent.skillsManager !== void 0) await agent.skillsManager.refresh();
7731
7765
  if (agent.pluginsManager !== void 0) await agent.pluginsManager.refresh();
7732
- return await chunkHJBMA5MB_cjs.loadSubagents(
7766
+ return await chunkWNTAPVU5_cjs.loadSubagents(
7733
7767
  agent.workspaceCwd,
7734
7768
  agent.settingSourcesIncludeProject,
7735
7769
  agent.options.agents
@@ -7737,7 +7771,7 @@ async function reloadLocalAgent(agent) {
7737
7771
  }
7738
7772
  async function persistActiveMemoryTranscript(cwd, transcript) {
7739
7773
  try {
7740
- const dir = path.join(chunk6VLKVX7O_cjs.memoryDir(cwd), "transcripts", "active-memory");
7774
+ const dir = path.join(chunk27AXGJMV_cjs.memoryDir(cwd), "transcripts", "active-memory");
7741
7775
  const file = path.join(dir, `${transcript.runId}.json`);
7742
7776
  await chunkI6TGFUCO_cjs.atomicWriteJson(file, transcript);
7743
7777
  } catch (cause) {
@@ -8367,7 +8401,7 @@ function createMemorySearchTool(opts) {
8367
8401
  };
8368
8402
  }
8369
8403
  function createMemoryGetTool(opts) {
8370
- const memoryRoot = path.resolve(chunk6VLKVX7O_cjs.memoryDir(opts.cwd));
8404
+ const memoryRoot = path.resolve(chunk27AXGJMV_cjs.memoryDir(opts.cwd));
8371
8405
  return {
8372
8406
  name: "memory_get",
8373
8407
  description: GET_DESCRIPTION,
@@ -8473,7 +8507,7 @@ var LocalAgentMemory = class {
8473
8507
  const openOpts = { cwd: this.workspaceCwd };
8474
8508
  if (embedding !== void 0) openOpts.embedding = embedding;
8475
8509
  if (cfg?.backend !== void 0) openOpts.backend = cfg.backend;
8476
- this.index = await chunk6VLKVX7O_cjs.IndexManager.open(openOpts);
8510
+ this.index = await chunk27AXGJMV_cjs.IndexManager.open(openOpts);
8477
8511
  await this.index.sync();
8478
8512
  this.toolsCache = [
8479
8513
  createMemorySearchTool({ index: this.index }),
@@ -8497,7 +8531,7 @@ var LocalAgentMemory = class {
8497
8531
  async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
8498
8532
  const cfg = this.options.memory?.activeRecall;
8499
8533
  if (cfg?.enabled !== true || this.index === void 0) return void 0;
8500
- if (this.breaker === void 0) this.breaker = new chunkHLPSLDGL_cjs.CircuitBreaker();
8534
+ if (this.breaker === void 0) this.breaker = new chunk43GFJ5SD_cjs.CircuitBreaker();
8501
8535
  if (this.cache === void 0) this.cache = new ActiveMemoryCache();
8502
8536
  const result = await runActiveMemory({
8503
8537
  userText,
@@ -8731,7 +8765,7 @@ function createLocalAgentMemoryProvider(opts) {
8731
8765
  return { facts: [], systemPromptAdditions: summary };
8732
8766
  },
8733
8767
  async recordSessionSummary(args) {
8734
- await chunk6VLKVX7O_cjs.writeSessionSummary(args);
8768
+ await chunk27AXGJMV_cjs.writeSessionSummary(args);
8735
8769
  },
8736
8770
  async sync(handle) {
8737
8771
  const state = handle[INTERNAL_LAM_KEY];
@@ -8821,7 +8855,7 @@ function addEntity(byName, entity, origin, collisionMap) {
8821
8855
  );
8822
8856
  }
8823
8857
  if (origin === "project" && collisionMap?.has(fm.name)) {
8824
- chunk53CBTBWO_cjs.warnOnce(
8858
+ chunkP6H23T43_cjs.warnOnce(
8825
8859
  `personality-collision-${fm.name}`,
8826
8860
  `[theokit-sdk] personality "${fm.name}" overridden by project preset`
8827
8861
  );
@@ -8871,14 +8905,14 @@ async function performPersonalitySwitch(args) {
8871
8905
 
8872
8906
  // src/internal/local-agent/local-agent-personality-extensions.ts
8873
8907
  function resolveActivePersonalityPreset(args) {
8874
- const forkCtx = chunk53CBTBWO_cjs.currentPersonalityContext();
8908
+ const forkCtx = chunkP6H23T43_cjs.currentPersonalityContext();
8875
8909
  const slug = forkCtx !== void 0 ? forkCtx.slug : args.personalityStore.active(args.agentId);
8876
8910
  if (slug === void 0) return void 0;
8877
8911
  return args.personalityRegistry?.get(slug);
8878
8912
  }
8879
8913
  async function ensurePersonalityRegistryIfNeeded(args) {
8880
8914
  if (args.personalityRegistry !== void 0) return args.personalityRegistry;
8881
- const forkSlug = chunk53CBTBWO_cjs.currentPersonalityContext()?.slug;
8915
+ const forkSlug = chunkP6H23T43_cjs.currentPersonalityContext()?.slug;
8882
8916
  const ownSlug = args.personalityStore.active(args.agentId);
8883
8917
  if (forkSlug === void 0 && ownSlug === void 0) return void 0;
8884
8918
  return await PersonalityRegistry.load(args.workspaceCwd);
@@ -8892,8 +8926,8 @@ ${preset.systemPrompt}`;
8892
8926
  }
8893
8927
  async function localAgentUsePersonality(args) {
8894
8928
  if (args.disposed) throw new Error("Agent has been disposed");
8895
- if (chunk53CBTBWO_cjs.currentPersonalityContext() !== void 0) {
8896
- chunk53CBTBWO_cjs.warnPersonalitySwitchInsideFork(args.agentId);
8929
+ if (chunkP6H23T43_cjs.currentPersonalityContext() !== void 0) {
8930
+ chunkP6H23T43_cjs.warnPersonalitySwitchInsideFork(args.agentId);
8897
8931
  return null;
8898
8932
  }
8899
8933
  let registry = args.personalityRegistry;
@@ -8910,8 +8944,8 @@ async function localAgentUsePersonality(args) {
8910
8944
  registry,
8911
8945
  store: args.personalityStore,
8912
8946
  invalidateCache: (reason) => args.invalidateCache(reason),
8913
- appendSessionMessage: (msg) => chunkV2UUGUY4_cjs.appendSessionMessage(args.agentId, msg),
8914
- clearSession: () => chunkV2UUGUY4_cjs.clearSession(args.agentId),
8947
+ appendSessionMessage: (msg) => chunkKKK3FZ4A_cjs.appendSessionMessage(args.agentId, msg),
8948
+ clearSession: () => chunkKKK3FZ4A_cjs.clearSession(args.agentId),
8915
8949
  opts: args.opts ?? {}
8916
8950
  })
8917
8951
  );
@@ -8955,7 +8989,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
8955
8989
  async function localAgentFork(parent, options) {
8956
8990
  const { forkAgentImpl } = await import('./fork-agent-Y2IK2RYU.cjs');
8957
8991
  const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
8958
- const { withPersonalityContext } = await import('./context-VMIE4BMD.cjs');
8992
+ const { withPersonalityContext } = await import('./context-LCKNH2XI.cjs');
8959
8993
  const create = getAgentFacade().create;
8960
8994
  return withPersonalityContext(
8961
8995
  { slug: parent.personalitySlugSnapshot, isFork: true },
@@ -8967,8 +9001,12 @@ async function persistMemoryFactIfWritePrompt(workspaceCwd, memoryConfig, userTe
8967
9001
  if (!isMemoryWritePrompt(userText)) return;
8968
9002
  const fact = extractMemoryFact(userText);
8969
9003
  if (fact.length === 0) return;
9004
+ const kind = extractMemoryKind(userText);
8970
9005
  await safeCall(
8971
- () => appendMemoryFact(workspaceCwd, memoryConfig, { text: fact }),
9006
+ () => appendMemoryFact(workspaceCwd, memoryConfig, {
9007
+ text: fact,
9008
+ ...kind === void 0 ? {} : { kind }
9009
+ }),
8972
9010
  void 0,
8973
9011
  "memory write"
8974
9012
  );
@@ -9280,7 +9318,7 @@ async function executeSendLocked(inputs, message, options) {
9280
9318
  if (inputs.options.onBeforeSend !== void 0) {
9281
9319
  await inputs.options.onBeforeSend({
9282
9320
  conversationId: inputs.agentId,
9283
- previousMessageCount: chunkV2UUGUY4_cjs.getSessionMessages(inputs.agentId).length
9321
+ previousMessageCount: chunkKKK3FZ4A_cjs.getSessionMessages(inputs.agentId).length
9284
9322
  });
9285
9323
  }
9286
9324
  await inputs.runPreHook(userText);
@@ -9292,8 +9330,8 @@ async function executeSendLocked(inputs, message, options) {
9292
9330
  userText,
9293
9331
  sendOptions: options
9294
9332
  });
9295
- const priorMessages = [...chunkV2UUGUY4_cjs.getSessionMessages(inputs.agentId)];
9296
- chunkV2UUGUY4_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9333
+ const priorMessages = [...chunkKKK3FZ4A_cjs.getSessionMessages(inputs.agentId)];
9334
+ chunkKKK3FZ4A_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
9297
9335
  await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
9298
9336
  const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory);
9299
9337
  const portPathActive = shouldUsePortMemoryPath();
@@ -9456,7 +9494,7 @@ var LocalAgent = class {
9456
9494
  this.options = options;
9457
9495
  this.workspaceCwd = resolveCwd(options.local?.cwd);
9458
9496
  this.transcriptBaseDir = resolveSessionDir(options.local);
9459
- this.sessionStore = options.local?.sessionStore ?? new chunkYPJ5NH5N_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
9497
+ this.sessionStore = options.local?.sessionStore ?? new chunkQI7WE46I_cjs.FsSessionStore({ baseDir: this.transcriptBaseDir, cwd: this.workspaceCwd });
9460
9498
  this.settingSourcesIncludeProject = includesSetting(options, "project");
9461
9499
  this.settingSourcesIncludePlugins = includesSetting(options, "plugins");
9462
9500
  const sub = bootstrapSubmanagers({
@@ -9499,14 +9537,14 @@ var LocalAgent = class {
9499
9537
  if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
9500
9538
  const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
9501
9539
  await this.pluginManagerCode.initialize(codePlugins);
9502
- this.resolvedSubagents = await chunkHJBMA5MB_cjs.loadSubagents(
9540
+ this.resolvedSubagents = await chunkWNTAPVU5_cjs.loadSubagents(
9503
9541
  this.workspaceCwd,
9504
9542
  this.settingSourcesIncludeProject,
9505
9543
  this.options.agents
9506
9544
  );
9507
9545
  await acquireLeaseIfPossible(this.sessionStore, this.agentId);
9508
9546
  try {
9509
- await chunkV2UUGUY4_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
9547
+ await chunkKKK3FZ4A_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
9510
9548
  await this.personalityStore.hydrate(this.agentId);
9511
9549
  } catch (err) {
9512
9550
  await releaseLeaseIfPossible(this.sessionStore, this.agentId);
@@ -9834,35 +9872,41 @@ async function maybeInjectHandoffTools(options) {
9834
9872
  };
9835
9873
  }
9836
9874
  function keyWillFlowToProvider(apiKey, provider) {
9837
- if (chunkHLPSLDGL_cjs.isFixtureApiKey(apiKey)) return false;
9838
- if (chunkHLPSLDGL_cjs.getConfiguredBaseUrl() !== void 0) return false;
9875
+ if (chunk43GFJ5SD_cjs.isFixtureApiKey(apiKey)) return false;
9876
+ if (chunk43GFJ5SD_cjs.getConfiguredBaseUrl() !== void 0) return false;
9839
9877
  if (provider === void 0) return false;
9840
9878
  const profile = chunk6HTXPPHK_cjs.getProviderProfile(provider);
9841
9879
  if (profile === void 0) return false;
9842
9880
  return profile.authType !== "none";
9843
9881
  }
9844
9882
  function missingApiKeyMessage() {
9845
- const present = chunkHLPSLDGL_cjs.presentProviderCredentialEnvVars();
9883
+ const present = chunk43GFJ5SD_cjs.presentProviderCredentialEnvVars();
9846
9884
  const base = `Missing API key \u2014 set ${chunkJTB5Q42C_cjs.API_KEY_ENV_VAR}, or pass \`apiKey\` to Agent.create()`;
9847
9885
  if (present.length === 0) return `${base}.`;
9848
9886
  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]}, ... })\`.`;
9849
9887
  }
9888
+ function providerNeedsCallerKey(provider) {
9889
+ if (provider === void 0) return true;
9890
+ const profile = chunk6HTXPPHK_cjs.getProviderProfile(provider);
9891
+ if (profile === void 0) return true;
9892
+ return profile.authType === "api_key";
9893
+ }
9850
9894
  async function createLocalAgent(options) {
9895
+ const provider = providerFromModelId(normalizeModel(options.model)?.id);
9851
9896
  const apiKey = chunkJTB5Q42C_cjs.resolveApiKey(options.apiKey);
9852
9897
  if (apiKey === void 0) {
9853
- throw new chunkK3FW2XZD_cjs.AuthenticationError(missingApiKeyMessage(), { code: "missing_api_key" });
9854
- }
9855
- const provider = providerFromModelId(normalizeModel(options.model)?.id);
9856
- const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
9857
- const shape = validateApiKeyShape(apiKey, {
9858
- strict: willFlowToProvider,
9859
- // `options.model` is already normalized by `runCreateUnderSpan`; `normalizeModel`
9860
- // here is the idempotent narrowing of the widened public type (`{id}` passes
9861
- // through by reference) — cleaner than an `as` cast.
9862
- ...willFlowToProvider ? { provider } : {}
9863
- });
9864
- if (shape.malformed) {
9865
- throw new chunkK3FW2XZD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
9898
+ if (providerNeedsCallerKey(provider)) {
9899
+ throw new chunkK3FW2XZD_cjs.AuthenticationError(missingApiKeyMessage(), { code: "missing_api_key" });
9900
+ }
9901
+ } else {
9902
+ const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
9903
+ const shape = validateApiKeyShape(apiKey, {
9904
+ strict: willFlowToProvider,
9905
+ ...willFlowToProvider ? { provider } : {}
9906
+ });
9907
+ if (shape.malformed) {
9908
+ throw new chunkK3FW2XZD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
9909
+ }
9866
9910
  }
9867
9911
  const agent = new LocalAgent(options);
9868
9912
  await agent.initialize();
@@ -9879,11 +9923,11 @@ async function createCloudAgent(options) {
9879
9923
  if (shape.malformed) {
9880
9924
  throw new chunkK3FW2XZD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
9881
9925
  }
9882
- const baseUrl = chunkHLPSLDGL_cjs.getConfiguredBaseUrl();
9926
+ const baseUrl = chunk43GFJ5SD_cjs.getConfiguredBaseUrl();
9883
9927
  if (baseUrl === void 0) {
9884
9928
  return new CloudAgent(options);
9885
9929
  }
9886
- const response = await chunkHLPSLDGL_cjs.httpRequest("/v1/agents", {
9930
+ const response = await chunk43GFJ5SD_cjs.httpRequest("/v1/agents", {
9887
9931
  apiKey,
9888
9932
  method: "POST",
9889
9933
  body: {
@@ -9908,7 +9952,7 @@ function resolveAgentPersistenceCwd(options) {
9908
9952
  return process.cwd();
9909
9953
  }
9910
9954
  async function rehydrateExistingAgent(agentId, existing, options) {
9911
- await chunkHLPSLDGL_cjs.discoverProviderPlugins();
9955
+ await chunk43GFJ5SD_cjs.discoverProviderPlugins();
9912
9956
  await validateRehydratedAgent(agentId, existing);
9913
9957
  const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
9914
9958
  const mergedOptions = {
@@ -10052,7 +10096,7 @@ var Agent = class _Agent {
10052
10096
  pluginCount: enabledPluginNames(options.plugins).length
10053
10097
  });
10054
10098
  try {
10055
- await chunkHLPSLDGL_cjs.discoverProviderPlugins();
10099
+ await chunk43GFJ5SD_cjs.discoverProviderPlugins();
10056
10100
  const agent = await runCreateUnderSpan(options, span);
10057
10101
  return agent;
10058
10102
  } catch (err) {
@@ -10359,9 +10403,9 @@ var Agent = class _Agent {
10359
10403
  `No local agent "${agentId}" registered \u2014 compact targets local sessions.`
10360
10404
  );
10361
10405
  }
10362
- const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-LEWF554G.cjs');
10406
+ const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-YHFQIXV5.cjs');
10363
10407
  const { cwd, model, store } = await openLocalStore(reg);
10364
- return chunkV2UUGUY4_cjs.enqueueSessionWrite(
10408
+ return chunkKKK3FZ4A_cjs.enqueueSessionWrite(
10365
10409
  cwd,
10366
10410
  agentId,
10367
10411
  () => compactSessionTranscript({
@@ -10395,7 +10439,7 @@ var Agent = class _Agent {
10395
10439
  `No local agent "${agentId}" registered \u2014 injectSessionTurn targets local sessions.`
10396
10440
  );
10397
10441
  }
10398
- const { injectSessionTurn } = await import('./inject-session-WQGGMCQY.cjs');
10442
+ const { injectSessionTurn } = await import('./inject-session-MLCJMYDG.cjs');
10399
10443
  const { cwd, model, store } = await openLocalStore(reg);
10400
10444
  await injectSessionTurn({
10401
10445
  store,
@@ -10434,7 +10478,7 @@ var Agent = class _Agent {
10434
10478
  `No local agent "${agentId}" registered \u2014 transcript targets local sessions.`
10435
10479
  );
10436
10480
  }
10437
- const { readSessionMessages } = await import('./agent-session-store-ZJ3JSRS4.cjs');
10481
+ const { readSessionMessages } = await import('./agent-session-store-WAKLOKWK.cjs');
10438
10482
  const { store } = await openLocalStore(reg);
10439
10483
  return readSessionMessages(store, agentId);
10440
10484
  }
@@ -10455,7 +10499,7 @@ var Agent = class _Agent {
10455
10499
  */
10456
10500
  static async describe(agentId) {
10457
10501
  const agent = await getRegisteredAgentOrThrow(agentId);
10458
- const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-AZIXJ7D3.cjs');
10502
+ const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-X5QKODCL.cjs');
10459
10503
  const settingSources = agent.options.local?.settingSources;
10460
10504
  const subagents = await loadSubagents2(
10461
10505
  agent.cwd ?? process.cwd(),
@@ -10522,8 +10566,8 @@ async function openLocalStore(reg) {
10522
10566
  const cwd = reg.cwd ?? process.cwd();
10523
10567
  const optModel = reg.options.model;
10524
10568
  const model = reg.model?.id ?? (typeof optModel === "string" ? optModel : optModel?.id) ?? "unknown";
10525
- const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-3MOJQGP2.cjs');
10526
- const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-JXHFTB7G.cjs');
10569
+ const { FsSessionStore: FsSessionStore2 } = await import('./fs-session-store-XZ7ZTB3A.cjs');
10570
+ const { defaultBaseDir: defaultBaseDir2, expandTilde: expandTilde2 } = await import('./session-transcript-HF5GEU5M.cjs');
10527
10571
  const configuredSessionDir = reg.options.local?.sessionDir ?? reg.options.local?.baseDir;
10528
10572
  const baseDir = configuredSessionDir !== void 0 ? expandTilde2(configuredSessionDir) : defaultBaseDir2();
10529
10573
  return { cwd, model, store: new FsSessionStore2({ baseDir, cwd }) };
@@ -10540,5 +10584,5 @@ exports.computeCost = computeCost;
10540
10584
  exports.generateCronId = generateCronId;
10541
10585
  exports.getPricingEntry = getPricingEntry;
10542
10586
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
10543
- //# sourceMappingURL=chunk-LQYQHXIW.cjs.map
10544
- //# sourceMappingURL=chunk-LQYQHXIW.cjs.map
10587
+ //# sourceMappingURL=chunk-N47KLTKD.cjs.map
10588
+ //# sourceMappingURL=chunk-N47KLTKD.cjs.map