@theokit/sdk 5.12.1 → 5.14.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 (193) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/{agent-Cn0sphpA.d.cts → agent-DExqjqYy.d.cts} +18 -3
  3. package/dist/{agent-CVzDy_Oj.d.ts → agent-Dfw3VsIX.d.ts} +18 -3
  4. package/dist/{agent-IG7BP6GN.js → agent-T34LCGQM.js} +11 -11
  5. package/dist/{agent-IG7BP6GN.js.map → agent-T34LCGQM.js.map} +1 -1
  6. package/dist/{agent-BVKIUP7F.cjs → agent-TL4K7BTG.cjs} +12 -12
  7. package/dist/{agent-BVKIUP7F.cjs.map → agent-TL4K7BTG.cjs.map} +1 -1
  8. package/dist/auth/index.cjs +17 -16
  9. package/dist/auth/index.cjs.map +1 -1
  10. package/dist/auth/index.js +5 -4
  11. package/dist/auth/index.js.map +1 -1
  12. package/dist/{chunk-NHOEXFZT.js → chunk-2HXTNVLM.js} +5 -2
  13. package/dist/chunk-2HXTNVLM.js.map +1 -0
  14. package/dist/{chunk-Q6WT5535.cjs → chunk-2WY2OFSC.cjs} +259 -79
  15. package/dist/chunk-2WY2OFSC.cjs.map +1 -0
  16. package/dist/{chunk-HN4IKB6X.cjs → chunk-2XWAYCFM.cjs} +15 -13
  17. package/dist/chunk-2XWAYCFM.cjs.map +1 -0
  18. package/dist/{chunk-3FSBE4PS.js → chunk-3GTN4HOO.js} +10 -6
  19. package/dist/chunk-3GTN4HOO.js.map +1 -0
  20. package/dist/{chunk-VVGFZQZC.js → chunk-3LMVJTNJ.js} +9 -5
  21. package/dist/chunk-3LMVJTNJ.js.map +1 -0
  22. package/dist/{chunk-4GUFNDZR.js → chunk-3ONIVO2I.js} +3 -3
  23. package/dist/{chunk-4GUFNDZR.js.map → chunk-3ONIVO2I.js.map} +1 -1
  24. package/dist/{chunk-7WARNHWW.cjs → chunk-3UMPP553.cjs} +5 -2
  25. package/dist/chunk-3UMPP553.cjs.map +1 -0
  26. package/dist/{chunk-NWWTYBD3.cjs → chunk-4KBI37F3.cjs} +5 -5
  27. package/dist/{chunk-NWWTYBD3.cjs.map → chunk-4KBI37F3.cjs.map} +1 -1
  28. package/dist/{chunk-S46WJTDL.cjs → chunk-4TEGFMSP.cjs} +6 -6
  29. package/dist/{chunk-S46WJTDL.cjs.map → chunk-4TEGFMSP.cjs.map} +1 -1
  30. package/dist/{chunk-QISSETTG.cjs → chunk-5645PMVU.cjs} +6 -4
  31. package/dist/chunk-5645PMVU.cjs.map +1 -0
  32. package/dist/{chunk-ZLFFDPXC.js → chunk-73IITAF7.js} +36 -14
  33. package/dist/chunk-73IITAF7.js.map +1 -0
  34. package/dist/{chunk-5A4UFBHW.cjs → chunk-A77UMVMD.cjs} +15 -11
  35. package/dist/chunk-A77UMVMD.cjs.map +1 -0
  36. package/dist/{chunk-IO4RI5ZJ.cjs → chunk-BZK5QL3N.cjs} +4 -4
  37. package/dist/{chunk-IO4RI5ZJ.cjs.map → chunk-BZK5QL3N.cjs.map} +1 -1
  38. package/dist/{chunk-5HSMH2ZZ.js → chunk-CJN5CEI3.js} +4 -4
  39. package/dist/{chunk-5HSMH2ZZ.js.map → chunk-CJN5CEI3.js.map} +1 -1
  40. package/dist/{chunk-XRPMZ7TO.js → chunk-CYWOJA6B.js} +6 -4
  41. package/dist/chunk-CYWOJA6B.js.map +1 -0
  42. package/dist/{chunk-AQW54OWQ.js → chunk-DFBWYETS.js} +5 -3
  43. package/dist/chunk-DFBWYETS.js.map +1 -0
  44. package/dist/{chunk-EPANMGH7.cjs → chunk-FLDHYF5C.cjs} +11 -2
  45. package/dist/chunk-FLDHYF5C.cjs.map +1 -0
  46. package/dist/{chunk-BJ7BPLQK.js → chunk-GARVAUCU.js} +209 -29
  47. package/dist/chunk-GARVAUCU.js.map +1 -0
  48. package/dist/{chunk-YOVZMN4P.cjs → chunk-LXG6VL6R.cjs} +3 -3
  49. package/dist/{chunk-YOVZMN4P.cjs.map → chunk-LXG6VL6R.cjs.map} +1 -1
  50. package/dist/{chunk-NJBJ3CUG.js → chunk-NAVUTK6X.js} +3 -3
  51. package/dist/{chunk-NJBJ3CUG.js.map → chunk-NAVUTK6X.js.map} +1 -1
  52. package/dist/{chunk-2SFLLOMN.js → chunk-NVQSBRG6.js} +3 -3
  53. package/dist/{chunk-2SFLLOMN.js.map → chunk-NVQSBRG6.js.map} +1 -1
  54. package/dist/{chunk-FEAWEBWN.cjs → chunk-PDOXYXWX.cjs} +6 -4
  55. package/dist/chunk-PDOXYXWX.cjs.map +1 -0
  56. package/dist/{chunk-MS3TQSXU.js → chunk-QD6B6W6I.js} +6 -4
  57. package/dist/chunk-QD6B6W6I.js.map +1 -0
  58. package/dist/{chunk-NBNRQN6T.js → chunk-QGDPMM3C.js} +11 -2
  59. package/dist/chunk-QGDPMM3C.js.map +1 -0
  60. package/dist/{chunk-ZWLFHSON.cjs → chunk-R35ZJAYT.cjs} +38 -15
  61. package/dist/chunk-R35ZJAYT.cjs.map +1 -0
  62. package/dist/{chunk-4YD2WI57.cjs → chunk-R427EOZE.cjs} +19 -15
  63. package/dist/chunk-R427EOZE.cjs.map +1 -0
  64. package/dist/chunk-R5UQL2R5.cjs +18 -0
  65. package/dist/{chunk-LO6LIUZ6.cjs.map → chunk-R5UQL2R5.cjs.map} +1 -1
  66. package/dist/{chunk-TLVI2OQK.cjs → chunk-SETHRLQS.cjs} +18 -2
  67. package/dist/chunk-SETHRLQS.cjs.map +1 -0
  68. package/dist/{chunk-LSWHDOCL.cjs → chunk-SNVYOX46.cjs} +88 -72
  69. package/dist/chunk-SNVYOX46.cjs.map +1 -0
  70. package/dist/{chunk-BO3PV3OP.js → chunk-TDED5XES.js} +18 -3
  71. package/dist/chunk-TDED5XES.js.map +1 -0
  72. package/dist/{chunk-NKQVLWDF.js → chunk-ULEK4OM4.js} +3 -3
  73. package/dist/{chunk-NKQVLWDF.js.map → chunk-ULEK4OM4.js.map} +1 -1
  74. package/dist/{chunk-XJ4C4NFX.js → chunk-ZOL3L4EH.js} +63 -49
  75. package/dist/chunk-ZOL3L4EH.js.map +1 -0
  76. package/dist/{compact-session-NM56BREJ.cjs → compact-session-D2MQDB6G.cjs} +15 -15
  77. package/dist/{compact-session-NM56BREJ.cjs.map → compact-session-D2MQDB6G.cjs.map} +1 -1
  78. package/dist/{compact-session-3U2JYTVG.js → compact-session-N2PPHQO6.js} +6 -6
  79. package/dist/{compact-session-3U2JYTVG.js.map → compact-session-N2PPHQO6.js.map} +1 -1
  80. package/dist/{cron-CHn-F0fC.d.ts → cron-BubDpFJG.d.ts} +2 -2
  81. package/dist/{cron-BWDYetbq.d.cts → cron-CK2v0VWA.d.cts} +2 -2
  82. package/dist/cron.cjs +11 -11
  83. package/dist/cron.d.cts +3 -3
  84. package/dist/cron.d.ts +3 -3
  85. package/dist/cron.js +10 -10
  86. package/dist/eval.cjs +15 -15
  87. package/dist/eval.js +10 -10
  88. package/dist/{executor-HKHT4CWS.cjs → executor-5QL5AXIZ.cjs} +18 -15
  89. package/dist/executor-5QL5AXIZ.cjs.map +1 -0
  90. package/dist/{executor-3D2UDJHW.js → executor-THUXNAFR.js} +6 -3
  91. package/dist/executor-THUXNAFR.js.map +1 -0
  92. package/dist/generate-object-A5F576IT.cjs +20 -0
  93. package/dist/{generate-object-XBWD2PU7.cjs.map → generate-object-A5F576IT.cjs.map} +1 -1
  94. package/dist/{generate-object-S7MNVF2V.js → generate-object-TBDOBBYW.js} +4 -4
  95. package/dist/{generate-object-S7MNVF2V.js.map → generate-object-TBDOBBYW.js.map} +1 -1
  96. package/dist/generate-object.d.ts +14 -1
  97. package/dist/index.cjs +81 -65
  98. package/dist/index.cjs.map +1 -1
  99. package/dist/index.d.cts +36 -7
  100. package/dist/index.d.ts +36 -7
  101. package/dist/index.js +44 -28
  102. package/dist/index.js.map +1 -1
  103. package/dist/{inject-session-JVTZNQF6.cjs → inject-session-3ICZIJ2N.cjs} +4 -4
  104. package/dist/{inject-session-JVTZNQF6.cjs.map → inject-session-3ICZIJ2N.cjs.map} +1 -1
  105. package/dist/{inject-session-THABTKJY.js → inject-session-J26SHHIO.js} +3 -3
  106. package/dist/{inject-session-THABTKJY.js.map → inject-session-J26SHHIO.js.map} +1 -1
  107. package/dist/internal/agent-loop/prune-tool-results.d.ts +37 -0
  108. package/dist/internal/auth/credential-store.d.ts +1 -1
  109. package/dist/internal/auth/types.d.ts +4 -0
  110. package/dist/internal/providers/discovery.d.ts +2 -2
  111. package/dist/internal/providers/trust-gate.d.ts +35 -0
  112. package/dist/internal/runtime/plugin-loader/manifest-entry-import.d.ts +17 -0
  113. package/dist/internal/runtime/plugin-loader/workspace-plugin-trust.d.ts +16 -0
  114. package/dist/internal/runtime/skills/binary-on-path.d.ts +1 -0
  115. package/dist/internal/runtime/skills/discover-skills.d.ts +2 -0
  116. package/dist/internal/structured-output-helpers.d.ts +5 -2
  117. package/dist/mcp-auth.cjs +2 -2
  118. package/dist/mcp-auth.js +1 -1
  119. package/dist/models.cjs +11 -11
  120. package/dist/models.js +4 -4
  121. package/dist/providers.cjs +6 -6
  122. package/dist/providers.js +4 -4
  123. package/dist/sandbox/bwrap.d.cts +10 -8
  124. package/dist/sandbox/bwrap.d.ts +10 -8
  125. package/dist/sandbox/deny-read.d.cts +24 -0
  126. package/dist/sandbox/deny-read.d.ts +24 -0
  127. package/dist/sandbox/index.cjs +114 -35
  128. package/dist/sandbox/index.cjs.map +1 -1
  129. package/dist/sandbox/index.d.cts +2 -1
  130. package/dist/sandbox/index.d.ts +2 -1
  131. package/dist/sandbox/index.js +96 -21
  132. package/dist/sandbox/index.js.map +1 -1
  133. package/dist/sandbox/linux-sandbox.d.cts +16 -1
  134. package/dist/sandbox/linux-sandbox.d.ts +16 -1
  135. package/dist/sandbox/local-sandbox.d.cts +3 -1
  136. package/dist/sandbox/local-sandbox.d.ts +3 -1
  137. package/dist/sandbox/seccomp-delivery.d.cts +3 -0
  138. package/dist/sandbox/seccomp-delivery.d.ts +3 -0
  139. package/dist/sandbox/shell-escape.d.cts +14 -2
  140. package/dist/sandbox/shell-escape.d.ts +14 -2
  141. package/dist/sandbox/types.d.cts +45 -0
  142. package/dist/sandbox/types.d.ts +45 -0
  143. package/dist/{sdk-agent-4-dXI2GS.d.cts → sdk-agent-DwzHcuxy.d.cts} +28 -3
  144. package/dist/{sdk-agent-CTOJlWA_.d.ts → sdk-agent-a3fW1xUK.d.ts} +28 -3
  145. package/dist/skills.cjs +4 -4
  146. package/dist/skills.js +1 -1
  147. package/dist/stream-object-AS4YYM4B.cjs +20 -0
  148. package/dist/{stream-object-TEEK3CAX.cjs.map → stream-object-AS4YYM4B.cjs.map} +1 -1
  149. package/dist/stream-object-EKM4WGTI.js +7 -0
  150. package/dist/{stream-object-R6SMYV4R.js.map → stream-object-EKM4WGTI.js.map} +1 -1
  151. package/dist/stream-object.d.ts +14 -1
  152. package/dist/subagents-loader.d.cts +2 -2
  153. package/dist/subagents-loader.d.ts +2 -2
  154. package/dist/types/agent.d.ts +14 -1
  155. package/dist/types/run.d.ts +27 -2
  156. package/dist/workflow-as-tool.d.ts +39 -5
  157. package/dist/workflow-errors.d.ts +16 -0
  158. package/dist/workflow.cjs +31 -23
  159. package/dist/workflow.d.cts +55 -5
  160. package/dist/workflow.d.ts +55 -5
  161. package/dist/workflow.js +2 -2
  162. package/docs/adr/mutation-testing-scope.md +56 -0
  163. package/docs/error-codes.md +23 -18
  164. package/docs/harness-capability-map.md +78 -4
  165. package/package.json +1 -1
  166. package/dist/chunk-3FSBE4PS.js.map +0 -1
  167. package/dist/chunk-4YD2WI57.cjs.map +0 -1
  168. package/dist/chunk-5A4UFBHW.cjs.map +0 -1
  169. package/dist/chunk-7WARNHWW.cjs.map +0 -1
  170. package/dist/chunk-AQW54OWQ.js.map +0 -1
  171. package/dist/chunk-BJ7BPLQK.js.map +0 -1
  172. package/dist/chunk-BO3PV3OP.js.map +0 -1
  173. package/dist/chunk-EPANMGH7.cjs.map +0 -1
  174. package/dist/chunk-FEAWEBWN.cjs.map +0 -1
  175. package/dist/chunk-HN4IKB6X.cjs.map +0 -1
  176. package/dist/chunk-LO6LIUZ6.cjs +0 -18
  177. package/dist/chunk-LSWHDOCL.cjs.map +0 -1
  178. package/dist/chunk-MS3TQSXU.js.map +0 -1
  179. package/dist/chunk-NBNRQN6T.js.map +0 -1
  180. package/dist/chunk-NHOEXFZT.js.map +0 -1
  181. package/dist/chunk-Q6WT5535.cjs.map +0 -1
  182. package/dist/chunk-QISSETTG.cjs.map +0 -1
  183. package/dist/chunk-TLVI2OQK.cjs.map +0 -1
  184. package/dist/chunk-VVGFZQZC.js.map +0 -1
  185. package/dist/chunk-XJ4C4NFX.js.map +0 -1
  186. package/dist/chunk-XRPMZ7TO.js.map +0 -1
  187. package/dist/chunk-ZLFFDPXC.js.map +0 -1
  188. package/dist/chunk-ZWLFHSON.cjs.map +0 -1
  189. package/dist/executor-3D2UDJHW.js.map +0 -1
  190. package/dist/executor-HKHT4CWS.cjs.map +0 -1
  191. package/dist/generate-object-XBWD2PU7.cjs +0 -20
  192. package/dist/stream-object-R6SMYV4R.js +0 -7
  193. package/dist/stream-object-TEEK3CAX.cjs +0 -20
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkL7JPXZ2C_cjs = require('./chunk-L7JPXZ2C.cjs');
4
- var chunkYOVZMN4P_cjs = require('./chunk-YOVZMN4P.cjs');
4
+ var chunkLXG6VL6R_cjs = require('./chunk-LXG6VL6R.cjs');
5
5
  var chunkCWQPQTUZ_cjs = require('./chunk-CWQPQTUZ.cjs');
6
6
  var chunk7YUPSBDV_cjs = require('./chunk-7YUPSBDV.cjs');
7
7
  var chunkBV2MWEMV_cjs = require('./chunk-BV2MWEMV.cjs');
@@ -9,7 +9,7 @@ var chunkCGH4BCIY_cjs = require('./chunk-CGH4BCIY.cjs');
9
9
  var chunkRS7YQR4X_cjs = require('./chunk-RS7YQR4X.cjs');
10
10
  var chunkSDZ4XDWS_cjs = require('./chunk-SDZ4XDWS.cjs');
11
11
  var chunk6OCJWGVD_cjs = require('./chunk-6OCJWGVD.cjs');
12
- var chunkLSWHDOCL_cjs = require('./chunk-LSWHDOCL.cjs');
12
+ var chunkSNVYOX46_cjs = require('./chunk-SNVYOX46.cjs');
13
13
  var chunk2ZPEDVLM_cjs = require('./chunk-2ZPEDVLM.cjs');
14
14
  var chunkQG4SXZ2A_cjs = require('./chunk-QG4SXZ2A.cjs');
15
15
  var chunkUDAKAE4Z_cjs = require('./chunk-UDAKAE4Z.cjs');
@@ -18,7 +18,7 @@ var chunkAA27GEYS_cjs = require('./chunk-AA27GEYS.cjs');
18
18
  var chunkYSTXFWQE_cjs = require('./chunk-YSTXFWQE.cjs');
19
19
  var chunkH7HD6RXO_cjs = require('./chunk-H7HD6RXO.cjs');
20
20
  var chunkNINIJCHU_cjs = require('./chunk-NINIJCHU.cjs');
21
- var chunk7WARNHWW_cjs = require('./chunk-7WARNHWW.cjs');
21
+ var chunk3UMPP553_cjs = require('./chunk-3UMPP553.cjs');
22
22
  var chunkIJ7M6GOG_cjs = require('./chunk-IJ7M6GOG.cjs');
23
23
  var chunk3KIUY67P_cjs = require('./chunk-3KIUY67P.cjs');
24
24
  var chunkSA6K24NB_cjs = require('./chunk-SA6K24NB.cjs');
@@ -31,10 +31,10 @@ var chunkWDVG5R2Q_cjs = require('./chunk-WDVG5R2Q.cjs');
31
31
  var chunkYQ3XC6C2_cjs = require('./chunk-YQ3XC6C2.cjs');
32
32
  var chunk6XQLTQB6_cjs = require('./chunk-6XQLTQB6.cjs');
33
33
  var chunkKX5QXLBS_cjs = require('./chunk-KX5QXLBS.cjs');
34
- var chunkNWWTYBD3_cjs = require('./chunk-NWWTYBD3.cjs');
34
+ var chunk4KBI37F3_cjs = require('./chunk-4KBI37F3.cjs');
35
35
  var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
36
- var chunkLO6LIUZ6_cjs = require('./chunk-LO6LIUZ6.cjs');
37
- var chunkS46WJTDL_cjs = require('./chunk-S46WJTDL.cjs');
36
+ var chunkR5UQL2R5_cjs = require('./chunk-R5UQL2R5.cjs');
37
+ var chunk4TEGFMSP_cjs = require('./chunk-4TEGFMSP.cjs');
38
38
  var chunkNVXXWAU7_cjs = require('./chunk-NVXXWAU7.cjs');
39
39
  var chunkEHD25JBZ_cjs = require('./chunk-EHD25JBZ.cjs');
40
40
  var chunkCEGU5AVD_cjs = require('./chunk-CEGU5AVD.cjs');
@@ -45,6 +45,7 @@ var path = require('path');
45
45
  var fs = require('fs');
46
46
  var process$1 = require('process');
47
47
  var child_process = require('child_process');
48
+ var url = require('url');
48
49
  var zod = require('zod');
49
50
  var module$1 = require('module');
50
51
  var os = require('os');
@@ -164,7 +165,7 @@ async function agentGenerate(agent, agentModel, agentApiKey, agentLocal, input,
164
165
  const { output, maxRetries, errorStrategy, ...sendOptions } = options;
165
166
  const run = await agent.send(input, sendOptions);
166
167
  const result = await run.wait();
167
- const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-XBWD2PU7.cjs');
168
+ const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-A5F576IT.cjs');
168
169
  const answer = structurableAnswerOrThrow(result, GenerateObjectError);
169
170
  const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
170
171
  const facade = getAgentFacade();
@@ -1623,7 +1624,7 @@ function createRealCloudRun(options) {
1623
1624
  conversation: []
1624
1625
  };
1625
1626
  const apiKey = chunkRNXXYF22_cjs.resolveApiKey(options.agentOptions.apiKey);
1626
- const baseUrl = chunkLSWHDOCL_cjs.getConfiguredBaseUrl();
1627
+ const baseUrl = chunkSNVYOX46_cjs.getConfiguredBaseUrl();
1627
1628
  const handle = new RealCloudRun(
1628
1629
  {
1629
1630
  id,
@@ -1706,7 +1707,7 @@ var RealCloudRun = class extends FixtureRunBase {
1706
1707
  async consumeStream(response) {
1707
1708
  let finalStatus = "finished";
1708
1709
  let finalText = "";
1709
- for await (const record of chunkLSWHDOCL_cjs.parseSseStream(response.body, this.controller.signal)) {
1710
+ for await (const record of chunkSNVYOX46_cjs.parseSseStream(response.body, this.controller.signal)) {
1710
1711
  const parsed = safeParse(record.data);
1711
1712
  if (parsed === void 0) continue;
1712
1713
  const update = this.applyRecord(record.event, parsed);
@@ -1873,7 +1874,7 @@ var CloudAgent = class _CloudAgent {
1873
1874
  */
1874
1875
  isFixtureMode() {
1875
1876
  const apiKey = chunkRNXXYF22_cjs.resolveApiKey(this.options.apiKey);
1876
- return chunkLSWHDOCL_cjs.isFixtureApiKey(apiKey) && chunkLSWHDOCL_cjs.getConfiguredBaseUrl() === void 0;
1877
+ return chunkSNVYOX46_cjs.isFixtureApiKey(apiKey) && chunkSNVYOX46_cjs.getConfiguredBaseUrl() === void 0;
1877
1878
  }
1878
1879
  // SE9 — integrated structured output; delegates to the shared helper.
1879
1880
  generate(message, options) {
@@ -1928,7 +1929,7 @@ var CloudAgent = class _CloudAgent {
1928
1929
  const userText = typeof message === "string" ? message : message.text;
1929
1930
  const systemPrompt = await this.resolveSystemPromptForSend(userText, options);
1930
1931
  const apiKey = chunkRNXXYF22_cjs.resolveApiKey(this.options.apiKey);
1931
- const useRealRuntime = apiKey !== void 0 && !chunkLSWHDOCL_cjs.isFixtureApiKey(apiKey) && chunkLSWHDOCL_cjs.getConfiguredBaseUrl() !== void 0;
1932
+ const useRealRuntime = apiKey !== void 0 && !chunkSNVYOX46_cjs.isFixtureApiKey(apiKey) && chunkSNVYOX46_cjs.getConfiguredBaseUrl() !== void 0;
1932
1933
  return useRealRuntime ? createRealCloudRun({
1933
1934
  agentId: this.agentId,
1934
1935
  model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
@@ -2968,7 +2969,7 @@ function resolveWindowForRun(model, contextWindow) {
2968
2969
  const override = contextWindow !== void 0 && contextWindow > 0 ? contextWindow : void 0;
2969
2970
  return chunkKX5QXLBS_cjs.resolveEffectiveContextWindow({
2970
2971
  ...override !== void 0 ? { override } : {},
2971
- catalog: chunkS46WJTDL_cjs.getCatalogModelInfo(model)?.limit?.context,
2972
+ catalog: chunk4TEGFMSP_cjs.getCatalogModelInfo(model)?.limit?.context,
2972
2973
  margin: chunkKX5QXLBS_cjs.CONTEXT_WINDOW_MARGIN,
2973
2974
  floor: chunkKX5QXLBS_cjs.CONTEXT_WINDOW_FLOOR
2974
2975
  });
@@ -2993,7 +2994,7 @@ async function runPostRunLifecycle(inputs) {
2993
2994
  try {
2994
2995
  const partial = await safeConversation(run);
2995
2996
  if (partial !== void 0) {
2996
- chunkYOVZMN4P_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2997
+ chunkLXG6VL6R_cjs.persistTurnToTranscript(sessionStore, { cwd: workspaceCwd, agentId, model }, agentId, {
2997
2998
  userText,
2998
2999
  conversation: partial
2999
3000
  });
@@ -3003,11 +3004,11 @@ async function runPostRunLifecycle(inputs) {
3003
3004
  chunkRNXXYF22_cjs.diag(`[theokit-sdk] partial transcript write failed (${agentId}): ${msg}
3004
3005
  `);
3005
3006
  }
3006
- await chunkYOVZMN4P_cjs.flushSessionWrites();
3007
+ await chunkLXG6VL6R_cjs.flushSessionWrites();
3007
3008
  return;
3008
3009
  }
3009
3010
  if (result.result !== void 0) {
3010
- chunkYOVZMN4P_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
3011
+ chunkLXG6VL6R_cjs.appendSessionMessage(agentId, { role: "assistant", text: result.result });
3011
3012
  }
3012
3013
  const conversation = await safeConversation(run);
3013
3014
  const resolvedWindow = resolveWindowForRun(model, contextWindow);
@@ -3018,7 +3019,7 @@ async function runPostRunLifecycle(inputs) {
3018
3019
  }
3019
3020
  const lastRequestUsage = result.usage?.requests?.at(-1)?.totalTokens;
3020
3021
  const usageForTrigger = lastRequestUsage ?? result.usage?.totalTokens;
3021
- chunkYOVZMN4P_cjs.persistTurnToTranscript(
3022
+ chunkLXG6VL6R_cjs.persistTurnToTranscript(
3022
3023
  sessionStore,
3023
3024
  { cwd: workspaceCwd, agentId, model },
3024
3025
  agentId,
@@ -3030,7 +3031,7 @@ async function runPostRunLifecycle(inputs) {
3030
3031
  // The EFFECTIVE window (after override, clamp and margin) — not the declared one. Swapping for
3031
3032
  // `contextWindow` here would budget against a number the clamp already rejected.
3032
3033
  contextWindow: effectiveWindow,
3033
- summarize: chunkLSWHDOCL_cjs.buildDefaultSummarizer({
3034
+ summarize: chunkSNVYOX46_cjs.buildDefaultSummarizer({
3034
3035
  agentModel: model,
3035
3036
  ...inputs.apiKey !== void 0 ? { apiKey: inputs.apiKey } : {}
3036
3037
  })
@@ -3072,7 +3073,7 @@ async function runPostRunLifecycle(inputs) {
3072
3073
  agentId,
3073
3074
  runId: result.id
3074
3075
  });
3075
- await chunkYOVZMN4P_cjs.flushSessionWrites();
3076
+ await chunkLXG6VL6R_cjs.flushSessionWrites();
3076
3077
  }
3077
3078
  async function safeConversation(run) {
3078
3079
  try {
@@ -3084,38 +3085,142 @@ async function safeConversation(run) {
3084
3085
  return [];
3085
3086
  }
3086
3087
  }
3088
+ var WORKSPACE_TRUST = {
3089
+ subject: "workspace plugins",
3090
+ entries: "absolute folder realpaths"
3091
+ };
3092
+ function workspaceTrustRecordPath() {
3093
+ return path.join(path.dirname(chunkSNVYOX46_cjs.trustFilePath()), "trusted-workspace-plugins.json");
3094
+ }
3095
+ function readTrustedWorkspaceFolders() {
3096
+ const path$1 = workspaceTrustRecordPath();
3097
+ const trusted = /* @__PURE__ */ new Set();
3098
+ for (const entry of chunkSNVYOX46_cjs.readTrustArray(path$1, WORKSPACE_TRUST)) {
3099
+ if (path.isAbsolute(entry)) {
3100
+ trusted.add(entry);
3101
+ continue;
3102
+ }
3103
+ chunkRNXXYF22_cjs.diag(
3104
+ `[theokit-sdk] WARN: ${path$1} entry "${entry}" is not an absolute path \u2014 discarded (entries must be ${WORKSPACE_TRUST.entries})
3105
+ `
3106
+ );
3107
+ }
3108
+ return trusted;
3109
+ }
3110
+
3111
+ // src/internal/runtime/plugin-loader/manifest-entry-import.ts
3112
+ var warnedFolders = chunkNVXXWAU7_cjs.globalSingleton(
3113
+ "theokit-sdk.plugins.manifest-untrusted-warned",
3114
+ () => /* @__PURE__ */ new Set()
3115
+ );
3116
+ async function importTrustedManifestPlugins(candidates, trustedFolders) {
3117
+ const plugins = [];
3118
+ for (const candidate of candidates) {
3119
+ const realFolder = realpathOrUndefined(candidate.folderPath);
3120
+ if (realFolder === void 0 || !trustedFolders.has(realFolder)) {
3121
+ warnUntrustedOnce(candidate, realFolder ?? candidate.folderPath);
3122
+ continue;
3123
+ }
3124
+ plugins.push(await importEntry(candidate));
3125
+ }
3126
+ return plugins;
3127
+ }
3128
+ function realpathOrUndefined(path) {
3129
+ try {
3130
+ return fs.realpathSync(path);
3131
+ } catch {
3132
+ return void 0;
3133
+ }
3134
+ }
3135
+ function warnUntrustedOnce(candidate, realFolder) {
3136
+ if (warnedFolders.has(candidate.entryPath)) return;
3137
+ warnedFolders.add(candidate.entryPath);
3138
+ const { folder, metadata } = candidate;
3139
+ const declared = metadata.name === folder ? "" : ` (declares name "${metadata.name}")`;
3140
+ chunkRNXXYF22_cjs.diag(
3141
+ `[theokit-sdk] workspace plugin folder "${folder}"${declared} is not trusted \u2014 its entry was not imported. To trust it, add "${realFolder}" to ${workspaceTrustRecordPath()} (JSON array of folder realpaths).
3142
+ `
3143
+ );
3144
+ }
3145
+ async function importEntry(candidate) {
3146
+ const { metadata } = candidate;
3147
+ const entry = metadata.entry ?? "";
3148
+ let mod;
3149
+ try {
3150
+ mod = await import(url.pathToFileURL(candidate.entryPath).href);
3151
+ } catch (cause) {
3152
+ throw new chunkCEGU5AVD_cjs.ConfigurationError(`Plugin ${metadata.name} entry failed to import: ${entry}`, {
3153
+ code: "plugin_entry_import_failed",
3154
+ cause
3155
+ });
3156
+ }
3157
+ const plugin = mod.default;
3158
+ if (!isGeneralPlugin(plugin)) {
3159
+ throw new chunkCEGU5AVD_cjs.ConfigurationError(
3160
+ `Plugin ${metadata.name} entry must default-export a general plugin (kind "general", name, register): ${entry}`,
3161
+ { code: "plugin_entry_shape" }
3162
+ );
3163
+ }
3164
+ return plugin;
3165
+ }
3166
+ function isGeneralPlugin(value) {
3167
+ return chunkBV2MWEMV_cjs.isCodePlugin(value) && value.kind === "general" && typeof value.name === "string";
3168
+ }
3169
+ function executableExtensions() {
3170
+ return process.platform === "win32" ? ["", ...(process.env.PATHEXT ?? ".EXE;.CMD").split(";")] : [""];
3171
+ }
3172
+ function isExecutable(file) {
3173
+ try {
3174
+ fs.accessSync(file, fs.constants.X_OK);
3175
+ return true;
3176
+ } catch {
3177
+ return false;
3178
+ }
3179
+ }
3180
+ function binaryOnPath(bin) {
3181
+ if (bin.length === 0 || /[\\/]/.test(bin)) return false;
3182
+ const dirs = (process.env.PATH ?? "").split(path.delimiter).filter((dir) => dir.length > 0);
3183
+ return dirs.some(
3184
+ (dir) => executableExtensions().some((ext) => isExecutable(path.join(dir, bin + ext)))
3185
+ );
3186
+ }
3087
3187
  var SkillsManager = class {
3088
- constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline, compatSources = []) {
3188
+ constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline, compatSources = [], bundledDirs = []) {
3089
3189
  this.cwd = cwd;
3090
3190
  this.settingSourcesIncludeProject = settingSourcesIncludeProject;
3091
3191
  this.skillsDir = skillsDir;
3092
3192
  this.inline = inline;
3093
3193
  this.compatSources = compatSources;
3194
+ this.bundledDirs = bundledDirs;
3094
3195
  }
3095
3196
  cwd;
3096
3197
  settingSourcesIncludeProject;
3097
3198
  skillsDir;
3098
3199
  inline;
3099
3200
  compatSources;
3201
+ bundledDirs;
3100
3202
  skills = [];
3101
3203
  async initialize() {
3102
3204
  if (!this.settingSourcesIncludeProject) {
3103
- this.skills = this.mergeInline([]);
3205
+ this.skills = this.mergeInline(await this.discoverFrom(this.bundledDirs));
3104
3206
  return;
3105
3207
  }
3106
3208
  await this.refresh();
3107
3209
  }
3108
3210
  async refresh() {
3109
- const roots = this.skillsDir === void 0 ? [
3211
+ const ownRoots = this.skillsDir === void 0 ? [
3110
3212
  ...chunkYQ3XC6C2_cjs.projectConfigRoots(this.cwd, this.compatSources, "skills").map(
3111
3213
  (root) => path.join(root, "skills")
3112
3214
  ),
3113
3215
  ...(await chunkWDVG5R2Q_cjs.pluginBundleDirs(this.cwd, this.compatSources)).map((b) => path.join(b, "skills"))
3114
3216
  ] : [this.skillsDir];
3217
+ this.skills = this.mergeInline(await this.discoverFrom([...ownRoots, ...this.bundledDirs]));
3218
+ }
3219
+ async discoverFrom(roots) {
3115
3220
  const discovered = [];
3116
3221
  const seen = /* @__PURE__ */ new Set();
3117
3222
  for (const root of roots) {
3118
- for (const skill of await chunk7WARNHWW_cjs.discoverSkills(root, {
3223
+ for (const skill of await chunk3UMPP553_cjs.discoverSkills(root, {
3119
3224
  onInvalidSkill: (info) => {
3120
3225
  chunkRNXXYF22_cjs.diag(`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
3121
3226
  `);
@@ -3126,7 +3231,7 @@ var SkillsManager = class {
3126
3231
  discovered.push(skill);
3127
3232
  }
3128
3233
  }
3129
- this.skills = this.mergeInline(discovered);
3234
+ return discovered;
3130
3235
  }
3131
3236
  /** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
3132
3237
  mergeInline(discovered) {
@@ -3146,7 +3251,7 @@ var SkillsManager = class {
3146
3251
  async get(name) {
3147
3252
  const skill = this.skills.find((s) => s.name === name);
3148
3253
  if (skill === void 0) return void 0;
3149
- const instructions = typeof skill.instructions === "string" ? skill.instructions : chunk7WARNHWW_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
3254
+ const instructions = typeof skill.instructions === "string" ? skill.instructions : chunk3UMPP553_cjs.stripSkillFrontmatter(await promises.readFile(skill.source, "utf8"));
3150
3255
  const references = skill.references;
3151
3256
  return {
3152
3257
  name: skill.name,
@@ -3254,7 +3359,8 @@ async function resolveSendSkills(inputs, userText, memoryFacts) {
3254
3359
  inputs.settingSourcesIncludeProject,
3255
3360
  settings.skillsDir,
3256
3361
  settings.inline,
3257
- resolveCompatSources(inputs.options, inputs.workspaceCwd)
3362
+ resolveCompatSources(inputs.options, inputs.workspaceCwd),
3363
+ settings.bundledDirs
3258
3364
  );
3259
3365
  await manager.initialize();
3260
3366
  return { manager, autoInject: settings.autoInject ?? true };
@@ -3273,7 +3379,9 @@ async function buildSystemPromptContext(inputs, userText, memoryFacts, manager =
3273
3379
  // because a caller naming one has already made the decision this field keeps away from the
3274
3380
  // model. Widening it to execution would break the case the field is FOR — a side-effecting
3275
3381
  // skill a human may run and the model may not propose.
3276
- skills: skills.filter((skill) => skill.disableModelInvocation !== true).map((skill) => ({ name: skill.name, description: skill.description })),
3382
+ skills: skills.filter((skill) => skill.disableModelInvocation !== true).filter(
3383
+ (skill) => skill.requiresBins === void 0 || skill.requiresBins.every((bin) => binaryOnPath(bin))
3384
+ ).map((skill) => ({ name: skill.name, description: skill.description })),
3277
3385
  userMessage: userText,
3278
3386
  memory: memoryFacts.map((fact) => ({ text: fact.text }))
3279
3387
  };
@@ -3333,7 +3441,7 @@ var ActiveMemoryPromptProvider = class {
3333
3441
  if (ctx.activeMemorySummary === void 0 || ctx.activeMemorySummary.length === 0) {
3334
3442
  return Promise.resolve(void 0);
3335
3443
  }
3336
- const body = chunk7WARNHWW_cjs.escapeBlockBody(ctx.activeMemorySummary);
3444
+ const body = chunk3UMPP553_cjs.escapeBlockBody(ctx.activeMemorySummary);
3337
3445
  return Promise.resolve(`<active-memory>
3338
3446
  ${body}
3339
3447
  </active-memory>`);
@@ -3386,7 +3494,7 @@ function formatSource(name, tokens) {
3386
3494
  if (tokens.length === 0) {
3387
3495
  return ` <source name="${escapeAttribute(name)}" />`;
3388
3496
  }
3389
- const body = chunk7WARNHWW_cjs.escapeBlockBody(tokens.join(" "));
3497
+ const body = chunk3UMPP553_cjs.escapeBlockBody(tokens.join(" "));
3390
3498
  return ` <source name="${escapeAttribute(name)}">
3391
3499
  ${body}
3392
3500
  </source>`;
@@ -3410,7 +3518,7 @@ var MemoryPromptProvider = class {
3410
3518
  if (ctx.memory.length === 0) return Promise.resolve(void 0);
3411
3519
  const lines = ctx.memory.map((fact) => {
3412
3520
  const tag = fact.observations === 1 ? "[unconfirmed] " : "";
3413
- return ` - ${tag}${chunk7WARNHWW_cjs.escapeBlockBody(fact.text)}`;
3521
+ return ` - ${tag}${chunk3UMPP553_cjs.escapeBlockBody(fact.text)}`;
3414
3522
  });
3415
3523
  return Promise.resolve(`${MEMORY_GUIDANCE}
3416
3524
  <memory>
@@ -3434,7 +3542,7 @@ var SkillsPromptProvider = class {
3434
3542
  priority = 20;
3435
3543
  contribute(ctx) {
3436
3544
  if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
3437
- return Promise.resolve(chunk7WARNHWW_cjs.buildSkillsBlock(ctx.skills));
3545
+ return Promise.resolve(chunk3UMPP553_cjs.buildSkillsBlock(ctx.skills));
3438
3546
  }
3439
3547
  };
3440
3548
 
@@ -3703,7 +3811,7 @@ var HISTOGRAM_NAMES = {
3703
3811
  };
3704
3812
  function safeRequire(moduleName) {
3705
3813
  try {
3706
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-Q6WT5535.cjs', document.baseURI).href)));
3814
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-2WY2OFSC.cjs', document.baseURI).href)));
3707
3815
  return r(moduleName);
3708
3816
  } catch {
3709
3817
  return void 0;
@@ -3946,7 +4054,7 @@ var cachedOtel;
3946
4054
  function loadOtel() {
3947
4055
  if (cachedOtel === void 0) {
3948
4056
  try {
3949
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-Q6WT5535.cjs', document.baseURI).href)));
4057
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-2WY2OFSC.cjs', document.baseURI).href)));
3950
4058
  const mod = r("@opentelemetry/api");
3951
4059
  cachedOtel = mod;
3952
4060
  } catch {
@@ -4579,6 +4687,12 @@ var PluginsManager = class {
4579
4687
  localPaths;
4580
4688
  compatSources;
4581
4689
  plugins = [];
4690
+ /**
4691
+ * B-686 — where each listed object was discovered. Keyed by the object, not by name: two plugins
4692
+ * may share a declared name across roots or folders, and a field would leak a host path through
4693
+ * `plugins.list()`. `refresh()` replaces the objects, so stale origins are collected with them.
4694
+ */
4695
+ #origin = /* @__PURE__ */ new WeakMap();
4582
4696
  async initialize() {
4583
4697
  this.assertCloudRules();
4584
4698
  if (!this.settingSourcesIncludePlugins) {
@@ -4604,6 +4718,7 @@ var PluginsManager = class {
4604
4718
  const cliMetadata = await loadPluginManifestFromJson(this.cwd, cliPath, folderName);
4605
4719
  if (this.enabled === void 0 || this.enabled.includes(cliMetadata.name)) {
4606
4720
  this.plugins.push(cliMetadata);
4721
+ this.#origin.set(cliMetadata, { root: pluginsRoot, folder: folderName });
4607
4722
  }
4608
4723
  continue;
4609
4724
  }
@@ -4626,12 +4741,26 @@ var PluginsManager = class {
4626
4741
  if (this.enabled === void 0 || this.enabled.includes(metadata.name)) {
4627
4742
  await this.assertEntryFileExists(metadata, folderName, pluginsRoot);
4628
4743
  this.plugins.push(metadata);
4744
+ this.#origin.set(metadata, { root: pluginsRoot, folder: folderName });
4629
4745
  }
4630
4746
  }
4631
4747
  }
4632
4748
  list() {
4633
4749
  return Promise.resolve(this.plugins);
4634
4750
  }
4751
+ /** Listed native-root plugins that declare an `entry`, in list order. Reads no file. */
4752
+ nativeEntryCandidates() {
4753
+ const nativeRoot = path.join(chunkYQ3XC6C2_cjs.theokitConfigRoot(this.cwd), "plugins");
4754
+ return this.plugins.flatMap((metadata) => {
4755
+ const origin = this.#origin.get(metadata);
4756
+ if (origin === void 0 || origin.root !== nativeRoot || metadata.entry === void 0) {
4757
+ return [];
4758
+ }
4759
+ const folderPath = path.join(origin.root, origin.folder);
4760
+ const entryPath = chunk3KIUY67P_cjs.safePathJoin(folderPath, metadata.entry);
4761
+ return [{ metadata, folder: origin.folder, folderPath, entryPath }];
4762
+ });
4763
+ }
4635
4764
  async assertEntryFileExists(metadata, folderName, pluginsRoot) {
4636
4765
  const entry = metadata.entry;
4637
4766
  if (entry === void 0) return;
@@ -4797,7 +4926,8 @@ function buildSkills(args, out) {
4797
4926
  staticSkills?.inline,
4798
4927
  // #524 — the same declaration the per-send manager reads. Omitting it here would make
4799
4928
  // `agent.skills` disagree with the system prompt about which skills exist.
4800
- resolveCompatSources(args.options, args.workspaceCwd)
4929
+ resolveCompatSources(args.options, args.workspaceCwd),
4930
+ staticSkills?.bundledDirs
4801
4931
  );
4802
4932
  const localSkills = out.skillsManager;
4803
4933
  out.skills = {
@@ -5649,7 +5779,7 @@ function catalogCostFallback(provider, cleanedModel) {
5649
5779
  const candidates = [`${provider}/${cleanedModel}`, cleanedModel];
5650
5780
  if (stripped !== cleanedModel) candidates.push(`${provider}/${stripped}`, stripped);
5651
5781
  for (const key of candidates) {
5652
- const info = chunkS46WJTDL_cjs.getCatalogModelInfo(key);
5782
+ const info = chunk4TEGFMSP_cjs.getCatalogModelInfo(key);
5653
5783
  const cost = info?.cost;
5654
5784
  if (cost === void 0) continue;
5655
5785
  const [prov, ...modelParts] = key.split("/");
@@ -5661,7 +5791,7 @@ function catalogCostFallback(provider, cleanedModel) {
5661
5791
  ...cost.cache_read !== void 0 ? { cacheReadCostPerMillion: cost.cache_read } : {},
5662
5792
  ...cost.cache_write !== void 0 ? { cacheWriteCostPerMillion: cost.cache_write } : {},
5663
5793
  // M44 M5 fix — honest provenance: a key patched by the LIVE models-dev source is not "vendored".
5664
- pricingVersion: chunkS46WJTDL_cjs.isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
5794
+ pricingVersion: chunk4TEGFMSP_cjs.isPatchedModelKey(key) ? "catalog-models-dev" : "catalog-vendored"
5665
5795
  };
5666
5796
  }
5667
5797
  return void 0;
@@ -5864,6 +5994,42 @@ function stripThinkBlocks(content) {
5864
5994
  return { visible, thinking };
5865
5995
  }
5866
5996
 
5997
+ // src/internal/agent-loop/prune-tool-results.ts
5998
+ function stubFor(olderThanRounds) {
5999
+ return `[tool result pruned: older than ${olderThanRounds} rounds]`;
6000
+ }
6001
+ function carriesToolResult(message) {
6002
+ return message.content.some((part) => part.type === "tool_result");
6003
+ }
6004
+ function stubbed(message, stub) {
6005
+ const content = message.content.map(
6006
+ (part) => part.type === "tool_result" ? { ...part, content: stub } : part
6007
+ );
6008
+ return { ...message, content };
6009
+ }
6010
+ function pruneToolResultsForRequest(messages, options) {
6011
+ if (options === void 0) return messages;
6012
+ const stub = stubFor(options.olderThanRounds);
6013
+ const out = [...messages];
6014
+ let rounds = 0;
6015
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
6016
+ const message = messages[index];
6017
+ if (!carriesToolResult(message)) continue;
6018
+ rounds += 1;
6019
+ if (rounds > options.olderThanRounds) out[index] = stubbed(message, stub);
6020
+ }
6021
+ return out;
6022
+ }
6023
+ function validatePruneToolResults(options) {
6024
+ if (options === void 0) return;
6025
+ const value = options.olderThanRounds;
6026
+ if (typeof value === "number" && Number.isInteger(value) && value >= 1) return;
6027
+ throw new chunkCEGU5AVD_cjs.ConfigurationError(
6028
+ `SendOptions.pruneToolResults.olderThanRounds must be an integer of at least 1, got ${String(value)}`,
6029
+ { code: "invalid_prune_tool_results" }
6030
+ );
6031
+ }
6032
+
5867
6033
  // src/internal/agent-loop/loop-llm-stream.ts
5868
6034
  function resolveSystemPromptWithMemoryAdditions(systemPrompt, additions) {
5869
6035
  if (additions === void 0 || additions.length === 0) return systemPrompt;
@@ -5875,11 +6041,11 @@ ${systemPrompt}`;
5875
6041
  }
5876
6042
  function activeMemoryBlock(additions) {
5877
6043
  return `<active-memory>
5878
- ${chunk7WARNHWW_cjs.escapeBlockBody(additions)}
6044
+ ${chunk3UMPP553_cjs.escapeBlockBody(additions)}
5879
6045
  </active-memory>`;
5880
6046
  }
5881
6047
  function buildLoopSystem(systemPrompt, additions, modelId) {
5882
- if (!chunkNWWTYBD3_cjs.isAnthropicFamilyModel(modelId) || systemPrompt === void 0 || systemPrompt.length === 0) {
6048
+ if (!chunk4KBI37F3_cjs.isAnthropicFamilyModel(modelId) || systemPrompt === void 0 || systemPrompt.length === 0) {
5883
6049
  return resolveSystemPromptWithMemoryAdditions(systemPrompt, additions);
5884
6050
  }
5885
6051
  const blocks = [{ text: systemPrompt, cacheable: true }];
@@ -5952,7 +6118,8 @@ async function streamLlmTurn(inputs, ctx) {
5952
6118
  const key = derivePromptCacheKey(inputs.agentId);
5953
6119
  return key !== void 0 ? { promptCacheKey: key } : {};
5954
6120
  })(),
5955
- messages: ctx.messages,
6121
+ // B-564: the request gets a pruned copy; ctx.messages stays whole (the transcript is resent from it).
6122
+ messages: pruneToolResultsForRequest(ctx.messages, inputs.pruneToolResults),
5956
6123
  tools: ctx.tools.map(toLlmTool)
5957
6124
  },
5958
6125
  signal
@@ -6743,7 +6910,7 @@ function applyToolResultGuard(parts, opts) {
6743
6910
  (p) => (
6744
6911
  // SE7 — guard the TEXT of a tool result (string or the text blocks of a
6745
6912
  // structured content); image blocks pass through untouched.
6746
- p.type === "tool_result" ? { ...p, content: chunkLSWHDOCL_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6913
+ p.type === "tool_result" ? { ...p, content: chunkSNVYOX46_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6747
6914
  )
6748
6915
  );
6749
6916
  }
@@ -7061,13 +7228,13 @@ var FallbackLlmClient = class {
7061
7228
  async *stream(request, signal) {
7062
7229
  let lastError;
7063
7230
  for (const client of this.clients) {
7064
- if (signal.aborted) throw chunkLSWHDOCL_cjs.abortError(signal);
7065
- const attempt = await chunkLSWHDOCL_cjs.tryFirstEvent(client, request, signal, true);
7231
+ if (signal.aborted) throw chunkSNVYOX46_cjs.abortError(signal);
7232
+ const attempt = await chunkSNVYOX46_cjs.tryFirstEvent(client, request, signal, true);
7066
7233
  if (attempt.kind === "handshake_error") {
7067
7234
  lastError = attempt.error;
7068
7235
  continue;
7069
7236
  }
7070
- return yield* chunkLSWHDOCL_cjs.relayStream(attempt.generator, attempt.firstResult);
7237
+ return yield* chunkSNVYOX46_cjs.relayStream(attempt.generator, attempt.firstResult);
7071
7238
  }
7072
7239
  if (lastError !== void 0) throw lastError;
7073
7240
  throw new chunkCEGU5AVD_cjs.NetworkError("FallbackLlmClient has no providers configured", {
@@ -7695,6 +7862,13 @@ function createRealLocalRun(options) {
7695
7862
  registerRun(handle);
7696
7863
  return handle;
7697
7864
  }
7865
+ function toolResultPolicyInputs(sendOptions) {
7866
+ return {
7867
+ ...sendOptions.perToolTimeoutMs !== void 0 ? { perToolTimeoutMs: sendOptions.perToolTimeoutMs } : {},
7868
+ ...sendOptions.toolResultGuard !== void 0 ? { toolResultGuard: sendOptions.toolResultGuard } : {},
7869
+ ...sendOptions.pruneToolResults !== void 0 ? { pruneToolResults: sendOptions.pruneToolResults } : {}
7870
+ };
7871
+ }
7698
7872
  function buildLoopInputs(options, runId, userText, userImages) {
7699
7873
  const maxIterations = options.sendOptions.maxIterations;
7700
7874
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
@@ -7703,9 +7877,10 @@ function buildLoopInputs(options, runId, userText, userImages) {
7703
7877
  { code: "invalid_max_iterations" }
7704
7878
  );
7705
7879
  }
7706
- const { primary, effectiveModelId } = chunkLSWHDOCL_cjs.resolveRunProvider(options);
7880
+ validatePruneToolResults(options.sendOptions.pruneToolResults);
7881
+ const { primary, effectiveModelId } = chunkSNVYOX46_cjs.resolveRunProvider(options);
7707
7882
  const fallback = options.agentOptions.providers?.fallback;
7708
- const apiKeys = chunkLSWHDOCL_cjs.mergeExplicitApiKey(
7883
+ const apiKeys = chunkSNVYOX46_cjs.mergeExplicitApiKey(
7709
7884
  options.agentOptions.providers?.apiKeys,
7710
7885
  primary,
7711
7886
  options.agentOptions.apiKey
@@ -7714,7 +7889,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
7714
7889
  const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
7715
7890
  const rateLimitSink = options.sendOptions.onRunEvent;
7716
7891
  const modelBaseUrl = options.model?.url;
7717
- const chain = chunkLSWHDOCL_cjs.resolveProviderChain({
7892
+ const chain = chunkSNVYOX46_cjs.resolveProviderChain({
7718
7893
  primary,
7719
7894
  ...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
7720
7895
  ...fallback !== void 0 ? { fallback } : {},
@@ -7772,10 +7947,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
7772
7947
  ...options.sendOptions.context !== void 0 ? { context: options.sendOptions.context } : {},
7773
7948
  // SE2 — forward the opt-in typed runtime-event sink to the loop.
7774
7949
  ...options.sendOptions.onRunEvent !== void 0 ? { runEventSink: options.sendOptions.onRunEvent } : {},
7775
- // #58 / #57 — forward the per-tool timeout + tool-result guard so a consumer
7776
- // can enable them via SendOptions (not only internal AgentLoopInputs).
7777
- ...options.sendOptions.perToolTimeoutMs !== void 0 ? { perToolTimeoutMs: options.sendOptions.perToolTimeoutMs } : {},
7778
- ...options.sendOptions.toolResultGuard !== void 0 ? { toolResultGuard: options.sendOptions.toolResultGuard } : {},
7950
+ ...toolResultPolicyInputs(options.sendOptions),
7779
7951
  // M1-2: per-send iteration ceiling (validated above). The loop reads
7780
7952
  // inputs.maxIterations (default 8 when unset).
7781
7953
  ...maxIterations !== void 0 ? { maxIterations } : {},
@@ -7849,6 +8021,7 @@ var RealLocalRun = class extends FixtureRunBase {
7849
8021
  }
7850
8022
  async initializeMcp(inputs) {
7851
8023
  for (const [name, client] of inputs.mcp.entries()) {
8024
+ if (this.terminated) break;
7852
8025
  try {
7853
8026
  await client.initialize();
7854
8027
  } catch (cause) {
@@ -7999,7 +8172,7 @@ function buildRealRunOptions(args) {
7999
8172
  };
8000
8173
  }
8001
8174
  async function createFixtureRunHelper(args) {
8002
- const sessionMessages = chunkYOVZMN4P_cjs.getSessionMessages(args.inputs.agentId);
8175
+ const sessionMessages = chunkLXG6VL6R_cjs.getSessionMessages(args.inputs.agentId);
8003
8176
  const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
8004
8177
  return createLocalRun({
8005
8178
  agentId: args.inputs.agentId,
@@ -8018,7 +8191,7 @@ async function createFixtureRunHelper(args) {
8018
8191
  }
8019
8192
  async function dispatchLocalRun(args) {
8020
8193
  const apiKey = chunkRNXXYF22_cjs.resolveApiKey(args.inputs.options.apiKey);
8021
- if (chunkLSWHDOCL_cjs.shouldUseRealLocalRuntime(apiKey)) {
8194
+ if (chunkSNVYOX46_cjs.shouldUseRealLocalRuntime(apiKey)) {
8022
8195
  return createRealLocalRun(
8023
8196
  buildRealRunOptions({
8024
8197
  inputs: args.inputs,
@@ -8274,10 +8447,10 @@ async function disposeLocalAgentSession(agent) {
8274
8447
  agent.lifecycleAbortController.abort();
8275
8448
  await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
8276
8449
  disposeSessionMcpClients(agent.agentId);
8277
- await chunkYOVZMN4P_cjs.flushSessionWrites();
8450
+ await chunkLXG6VL6R_cjs.flushSessionWrites();
8278
8451
  await flushRegistrySaves(agent.workspaceCwd);
8279
8452
  await disposeSessionStore(agent.sessionStore);
8280
- chunkYOVZMN4P_cjs.discardSession(agent.workspaceCwd, agent.agentId);
8453
+ chunkLXG6VL6R_cjs.discardSession(agent.workspaceCwd, agent.agentId);
8281
8454
  }
8282
8455
  async function reloadLocalAgent(agent) {
8283
8456
  if (agent.context !== void 0) await agent.context.refresh();
@@ -9141,7 +9314,7 @@ var LocalAgentMemory = class {
9141
9314
  async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
9142
9315
  const cfg = this.options.memory?.activeRecall;
9143
9316
  if (cfg?.enabled !== true || this.index === void 0) return void 0;
9144
- if (this.breaker === void 0) this.breaker = new chunkLSWHDOCL_cjs.CircuitBreaker();
9317
+ if (this.breaker === void 0) this.breaker = new chunkSNVYOX46_cjs.CircuitBreaker();
9145
9318
  if (this.cache === void 0) this.cache = new ActiveMemoryCache();
9146
9319
  const result = await runActiveMemory({
9147
9320
  userText,
@@ -9456,8 +9629,8 @@ async function localAgentUsePersonality(agent, name, opts) {
9456
9629
  registry,
9457
9630
  store: agent.personalityStore,
9458
9631
  invalidateCache: (reason) => agent.invalidateCache(reason),
9459
- appendSessionMessage: (msg) => chunkYOVZMN4P_cjs.appendSessionMessage(agent.agentId, msg),
9460
- clearSession: () => chunkYOVZMN4P_cjs.clearSession(agent.agentId),
9632
+ appendSessionMessage: (msg) => chunkLXG6VL6R_cjs.appendSessionMessage(agent.agentId, msg),
9633
+ clearSession: () => chunkLXG6VL6R_cjs.clearSession(agent.agentId),
9461
9634
  opts: opts ?? {}
9462
9635
  })
9463
9636
  );
@@ -9985,7 +10158,7 @@ async function executeSendLocked(inputs, message, options) {
9985
10158
  if (inputs.options.onBeforeSend !== void 0) {
9986
10159
  await inputs.options.onBeforeSend({
9987
10160
  conversationId: inputs.agentId,
9988
- previousMessageCount: chunkYOVZMN4P_cjs.getSessionMessages(inputs.agentId).length
10161
+ previousMessageCount: chunkLXG6VL6R_cjs.getSessionMessages(inputs.agentId).length
9989
10162
  });
9990
10163
  }
9991
10164
  await inputs.runPreHook(userText);
@@ -9997,8 +10170,8 @@ async function executeSendLocked(inputs, message, options) {
9997
10170
  userText,
9998
10171
  sendOptions: options
9999
10172
  });
10000
- const priorMessages = [...chunkYOVZMN4P_cjs.getSessionMessages(inputs.agentId)];
10001
- chunkYOVZMN4P_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
10173
+ const priorMessages = [...chunkLXG6VL6R_cjs.getSessionMessages(inputs.agentId)];
10174
+ chunkLXG6VL6R_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
10002
10175
  await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
10003
10176
  const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory, userText);
10004
10177
  const memoryTools = void 0;
@@ -10289,13 +10462,20 @@ var LocalAgent = class {
10289
10462
  workspaceCwd: this.workspaceCwd
10290
10463
  });
10291
10464
  }
10465
+ /** B-686 — the workspace trust record is read only when a native manifest declares an entry. */
10466
+ async importManifestPlugins() {
10467
+ const candidates = this.pluginsManager?.nativeEntryCandidates() ?? [];
10468
+ if (candidates.length === 0) return [];
10469
+ return importTrustedManifestPlugins(candidates, readTrustedWorkspaceFolders());
10470
+ }
10292
10471
  async initialize() {
10293
10472
  await this.hooksExecutor.initialize(this.settingSourcesIncludeProject);
10294
10473
  if (this.context !== void 0) await this.context.initialize();
10295
10474
  if (this.skillsManager !== void 0) await this.skillsManager.initialize();
10296
10475
  if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
10297
10476
  const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
10298
- await this.pluginManagerCode.initialize(codePlugins);
10477
+ const manifestPlugins = await this.importManifestPlugins();
10478
+ await this.pluginManagerCode.initialize([...codePlugins, ...manifestPlugins]);
10299
10479
  this.resolvedSubagents = await chunkWDVG5R2Q_cjs.loadSubagents(
10300
10480
  this.workspaceCwd,
10301
10481
  this.settingSourcesIncludeProject,
@@ -10304,7 +10484,7 @@ var LocalAgent = class {
10304
10484
  );
10305
10485
  await acquireLeaseIfPossible(this.sessionStore, this.agentId);
10306
10486
  try {
10307
- await chunkYOVZMN4P_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
10487
+ await chunkLXG6VL6R_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
10308
10488
  await this.personalityStore.hydrate(this.agentId);
10309
10489
  } catch (err) {
10310
10490
  await releaseLeaseIfPossible(this.sessionStore, this.agentId);
@@ -10648,22 +10828,22 @@ async function maybeInjectHandoffTools(options) {
10648
10828
  };
10649
10829
  }
10650
10830
  function keyWillFlowToProvider(apiKey, provider) {
10651
- if (chunkLSWHDOCL_cjs.isFixtureApiKey(apiKey)) return false;
10652
- if (chunkLSWHDOCL_cjs.getConfiguredBaseUrl() !== void 0) return false;
10831
+ if (chunkSNVYOX46_cjs.isFixtureApiKey(apiKey)) return false;
10832
+ if (chunkSNVYOX46_cjs.getConfiguredBaseUrl() !== void 0) return false;
10653
10833
  if (provider === void 0) return false;
10654
- const profile = chunkLO6LIUZ6_cjs.getProviderProfile(provider);
10834
+ const profile = chunkR5UQL2R5_cjs.getProviderProfile(provider);
10655
10835
  if (profile === void 0) return false;
10656
10836
  return profile.authType !== "none";
10657
10837
  }
10658
10838
  function missingApiKeyMessage() {
10659
- const present = chunkLSWHDOCL_cjs.presentProviderCredentialEnvVars();
10839
+ const present = chunkSNVYOX46_cjs.presentProviderCredentialEnvVars();
10660
10840
  const base = `Missing API key \u2014 set ${chunkRNXXYF22_cjs.API_KEY_ENV_VAR}, or pass \`apiKey\` to Agent.create()`;
10661
10841
  if (present.length === 0) return `${base}.`;
10662
10842
  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]}, ... })\`.`;
10663
10843
  }
10664
10844
  function providerNeedsCallerKey(provider) {
10665
10845
  if (provider === void 0) return true;
10666
- const profile = chunkLO6LIUZ6_cjs.getProviderProfile(provider);
10846
+ const profile = chunkR5UQL2R5_cjs.getProviderProfile(provider);
10667
10847
  if (profile === void 0) return true;
10668
10848
  return profile.authType === "api_key";
10669
10849
  }
@@ -10676,7 +10856,7 @@ async function createLocalAgent(options) {
10676
10856
  }
10677
10857
  } else {
10678
10858
  const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
10679
- const shape = chunkLSWHDOCL_cjs.validateApiKeyShape(apiKey, {
10859
+ const shape = chunkSNVYOX46_cjs.validateApiKeyShape(apiKey, {
10680
10860
  strict: willFlowToProvider,
10681
10861
  ...willFlowToProvider ? { provider } : {}
10682
10862
  });
@@ -10695,15 +10875,15 @@ async function createCloudAgent(options) {
10695
10875
  code: "missing_api_key"
10696
10876
  });
10697
10877
  }
10698
- const shape = chunkLSWHDOCL_cjs.validateApiKeyShape(apiKey);
10878
+ const shape = chunkSNVYOX46_cjs.validateApiKeyShape(apiKey);
10699
10879
  if (shape.malformed) {
10700
10880
  throw new chunkCEGU5AVD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
10701
10881
  }
10702
- const baseUrl = chunkLSWHDOCL_cjs.getConfiguredBaseUrl();
10882
+ const baseUrl = chunkSNVYOX46_cjs.getConfiguredBaseUrl();
10703
10883
  if (baseUrl === void 0) {
10704
10884
  return new CloudAgent(options);
10705
10885
  }
10706
- const response = await chunkLSWHDOCL_cjs.httpRequest("/v1/agents", {
10886
+ const response = await chunkSNVYOX46_cjs.httpRequest("/v1/agents", {
10707
10887
  apiKey,
10708
10888
  method: "POST",
10709
10889
  body: {
@@ -10728,7 +10908,7 @@ function resolveAgentPersistenceCwd(options) {
10728
10908
  return process.cwd();
10729
10909
  }
10730
10910
  async function rehydrateExistingAgent(agentId, existing, options) {
10731
- await chunkLSWHDOCL_cjs.discoverProviderPlugins();
10911
+ await chunkSNVYOX46_cjs.discoverProviderPlugins();
10732
10912
  await validateRehydratedAgent(agentId, existing);
10733
10913
  const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
10734
10914
  const mergedMemory = mergeResumedMemory(existing.options.memory, options.memory);
@@ -10888,7 +11068,7 @@ var Agent = class _Agent {
10888
11068
  pluginCount: enabledPluginNames(options.plugins).length
10889
11069
  });
10890
11070
  try {
10891
- await chunkLSWHDOCL_cjs.discoverProviderPlugins();
11071
+ await chunkSNVYOX46_cjs.discoverProviderPlugins();
10892
11072
  const agent = await runCreateUnderSpan(options, span);
10893
11073
  return agent;
10894
11074
  } catch (err) {
@@ -10986,7 +11166,7 @@ var Agent = class _Agent {
10986
11166
  * @public
10987
11167
  */
10988
11168
  static async generateObject(options) {
10989
- const { generateObjectImpl } = await import('./generate-object-XBWD2PU7.cjs');
11169
+ const { generateObjectImpl } = await import('./generate-object-A5F576IT.cjs');
10990
11170
  return generateObjectImpl(options, {
10991
11171
  create: (opts) => _Agent.create(opts),
10992
11172
  delete: (agentId) => _Agent.delete(agentId)
@@ -11010,7 +11190,7 @@ var Agent = class _Agent {
11010
11190
  delete: (agentId) => _Agent.delete(agentId)
11011
11191
  };
11012
11192
  async function* wrapper() {
11013
- streamObjectImport ??= import('./stream-object-TEEK3CAX.cjs');
11193
+ streamObjectImport ??= import('./stream-object-AS4YYM4B.cjs');
11014
11194
  const { streamObjectImpl } = await streamObjectImport;
11015
11195
  yield* streamObjectImpl(options, deps);
11016
11196
  }
@@ -11186,9 +11366,9 @@ var Agent = class _Agent {
11186
11366
  */
11187
11367
  static async compact(agentId, options = {}) {
11188
11368
  const reg = await requireLocalAgent(agentId, "compact");
11189
- const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-NM56BREJ.cjs');
11369
+ const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-D2MQDB6G.cjs');
11190
11370
  const { cwd, model, store } = await openLocalStore(reg);
11191
- return chunkYOVZMN4P_cjs.enqueueSessionWrite(
11371
+ return chunkLXG6VL6R_cjs.enqueueSessionWrite(
11192
11372
  cwd,
11193
11373
  agentId,
11194
11374
  () => compactSessionTranscript({
@@ -11216,7 +11396,7 @@ var Agent = class _Agent {
11216
11396
  */
11217
11397
  static async injectSessionTurn(agentId, turn) {
11218
11398
  const reg = await requireLocalAgent(agentId, "injectSessionTurn");
11219
- const { injectSessionTurn } = await import('./inject-session-JVTZNQF6.cjs');
11399
+ const { injectSessionTurn } = await import('./inject-session-3ICZIJ2N.cjs');
11220
11400
  const { cwd, model, store } = await openLocalStore(reg);
11221
11401
  await injectSessionTurn({
11222
11402
  store,
@@ -11387,5 +11567,5 @@ exports.managedSettingsPathFor = managedSettingsPathFor;
11387
11567
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
11388
11568
  exports.readManagedSettings = readManagedSettings;
11389
11569
  exports.resolveSessionDir = resolveSessionDir;
11390
- //# sourceMappingURL=chunk-Q6WT5535.cjs.map
11391
- //# sourceMappingURL=chunk-Q6WT5535.cjs.map
11570
+ //# sourceMappingURL=chunk-2WY2OFSC.cjs.map
11571
+ //# sourceMappingURL=chunk-2WY2OFSC.cjs.map