@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,13 +1,13 @@
1
1
  import { submit, emitRunEvent } from './chunk-HWMGR3HA.js';
2
- import { enqueueSessionWrite, hydrateSession, persistTurnToTranscript, flushSessionWrites, appendSessionMessage, getSessionMessages, discardSession, clearSession } from './chunk-4GUFNDZR.js';
2
+ import { enqueueSessionWrite, hydrateSession, persistTurnToTranscript, flushSessionWrites, appendSessionMessage, getSessionMessages, discardSession, clearSession } from './chunk-3ONIVO2I.js';
3
3
  import { IndexManager } from './chunk-2C24NSNV.js';
4
4
  import { currentPersonalityContext, warnPersonalitySwitchInsideFork } from './chunk-HJ2LV464.js';
5
- import { extractCodePlugins } from './chunk-2SFBB54R.js';
5
+ import { extractCodePlugins, isCodePlugin } from './chunk-2SFBB54R.js';
6
6
  import { createOpenAiCompatibleRuntime } from './chunk-H7G65PNI.js';
7
7
  import { persistActiveMemoryTranscript } from './chunk-QK2ERTO3.js';
8
8
  import { resolveMaxFacts, writeSessionSummary, resolveMemoryRoot, MEMORY_KINDS, appendFact, readFacts, legacyMemoryJsonPath, memoryMdPath, appendFactToMarkdown } from './chunk-DF77RBF4.js';
9
9
  import { FsSessionStore } from './chunk-AB4OPJLD.js';
10
- import { discoverProviderPlugins, validateApiKeyShape, getConfiguredBaseUrl, httpRequest, isFixtureApiKey, presentProviderCredentialEnvVars, buildDefaultSummarizer, shouldUseRealLocalRuntime, parseSseStream, CircuitBreaker, resolveRunProvider, mergeExplicitApiKey, resolveProviderChain, abortError, tryFirstEvent, relayStream, renderToolResultContentText } from './chunk-XJ4C4NFX.js';
10
+ import { discoverProviderPlugins, validateApiKeyShape, getConfiguredBaseUrl, httpRequest, isFixtureApiKey, presentProviderCredentialEnvVars, readTrustArray, buildDefaultSummarizer, shouldUseRealLocalRuntime, parseSseStream, CircuitBreaker, trustFilePath, resolveRunProvider, mergeExplicitApiKey, resolveProviderChain, abortError, tryFirstEvent, relayStream, renderToolResultContentText } from './chunk-ZOL3L4EH.js';
11
11
  import { resolveChildEnv } from './chunk-HKCKOAIO.js';
12
12
  import { DEFAULT_MAX_BYTES_PER_FILE, runDiscovery, truncateWithMarker } from './chunk-KCM3RMKR.js';
13
13
  import { warnFailureOnce, loadHookConfig, warnOnce } from './chunk-XJ3WU5CZ.js';
@@ -16,7 +16,7 @@ import { toJsonSchema } from './chunk-7I5Z3UBJ.js';
16
16
  import { sanitizeToolInput } from './chunk-FJWQP6EE.js';
17
17
  import { withInheritedSubAgentCredentials, subAgentToolsFromDefinitions } from './chunk-VZGE7NAI.js';
18
18
  import { setAgentFacade } from './chunk-6X6ID4MO.js';
19
- import { escapeBlockBody, buildSkillsBlock, discoverSkills, stripSkillFrontmatter } from './chunk-NHOEXFZT.js';
19
+ import { escapeBlockBody, buildSkillsBlock, discoverSkills, stripSkillFrontmatter } from './chunk-2HXTNVLM.js';
20
20
  import { withToolWhitelist, checkToolWhitelist } from './chunk-SAGRF4IB.js';
21
21
  import { validateArtifactPath, PathTraversalError, safePathJoin } from './chunk-PKRPV3R7.js';
22
22
  import { insideRoot, atOrInsideRoot } from './chunk-UKMBRMGT.js';
@@ -29,20 +29,21 @@ import { loadSubagents, pluginBundleDirs } from './chunk-RN3XDZGS.js';
29
29
  import { reportUndeclaredSources, theokitConfigRoot, undefinedVariablesIn, getTheokitHome, adapterForConfigPath, adaptersForSurface, projectConfigRoots, pluginBundleRoots } from './chunk-YMVTUV5K.js';
30
30
  import { readWorkspaceDir, parseSimpleYaml } from './chunk-Q7UG242V.js';
31
31
  import { resolveEffectiveContextWindow, CONTEXT_WINDOW_FLOOR, CONTEXT_WINDOW_MARGIN } from './chunk-SZQFCHU6.js';
32
- import { isAnthropicFamilyModel } from './chunk-2SFLLOMN.js';
32
+ import { isAnthropicFamilyModel } from './chunk-NVQSBRG6.js';
33
33
  import { parseModelId } from './chunk-R7WIIPUR.js';
34
- import { getProviderProfile } from './chunk-NKQVLWDF.js';
35
- import { getCatalogModelInfo, isPatchedModelKey } from './chunk-5HSMH2ZZ.js';
34
+ import { getProviderProfile } from './chunk-ULEK4OM4.js';
35
+ import { getCatalogModelInfo, isPatchedModelKey } from './chunk-CJN5CEI3.js';
36
36
  import { globalSingleton } from './chunk-AGACYRJ2.js';
37
37
  import { boundFetch } from './chunk-Q7GYMXVC.js';
38
38
  import { AgentRunError, coerceToKnownAgentRunErrorCode, UnknownAgentError, ConfigurationError, AuthenticationError, AgentDisposedError, UnsupportedRunOperationError, NetworkError, TheokitAgentError } from './chunk-TNFOU6SB.js';
39
39
  import { diag, resolveApiKey, API_KEY_ENV_VAR, redactSecrets, diagFailure } from './chunk-3OY6H3I7.js';
40
40
  import { stat, mkdir, readFile, readdir, access, unlink } from 'fs/promises';
41
41
  import { randomUUID, createHash } from 'crypto';
42
- import { join, dirname, resolve, relative, isAbsolute } from 'path';
43
- import { existsSync, readFileSync } from 'fs';
42
+ import { join, dirname, isAbsolute, delimiter, resolve, relative } from 'path';
43
+ import { existsSync, readFileSync, realpathSync, accessSync, constants } from 'fs';
44
44
  import { platform } from 'process';
45
45
  import { spawn } from 'child_process';
46
+ import { pathToFileURL } from 'url';
46
47
  import { z } from 'zod';
47
48
  import { createRequire } from 'module';
48
49
  import { homedir } from 'os';
@@ -161,7 +162,7 @@ async function agentGenerate(agent, agentModel, agentApiKey, agentLocal, input,
161
162
  const { output, maxRetries, errorStrategy, ...sendOptions } = options;
162
163
  const run = await agent.send(input, sendOptions);
163
164
  const result = await run.wait();
164
- const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-S7MNVF2V.js');
165
+ const { generateObjectImpl, GenerateObjectError } = await import('./generate-object-TBDOBBYW.js');
165
166
  const answer = structurableAnswerOrThrow(result, GenerateObjectError);
166
167
  const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
167
168
  const facade = getAgentFacade();
@@ -3081,34 +3082,138 @@ async function safeConversation(run) {
3081
3082
  return [];
3082
3083
  }
3083
3084
  }
3085
+ var WORKSPACE_TRUST = {
3086
+ subject: "workspace plugins",
3087
+ entries: "absolute folder realpaths"
3088
+ };
3089
+ function workspaceTrustRecordPath() {
3090
+ return join(dirname(trustFilePath()), "trusted-workspace-plugins.json");
3091
+ }
3092
+ function readTrustedWorkspaceFolders() {
3093
+ const path = workspaceTrustRecordPath();
3094
+ const trusted = /* @__PURE__ */ new Set();
3095
+ for (const entry of readTrustArray(path, WORKSPACE_TRUST)) {
3096
+ if (isAbsolute(entry)) {
3097
+ trusted.add(entry);
3098
+ continue;
3099
+ }
3100
+ diag(
3101
+ `[theokit-sdk] WARN: ${path} entry "${entry}" is not an absolute path \u2014 discarded (entries must be ${WORKSPACE_TRUST.entries})
3102
+ `
3103
+ );
3104
+ }
3105
+ return trusted;
3106
+ }
3107
+
3108
+ // src/internal/runtime/plugin-loader/manifest-entry-import.ts
3109
+ var warnedFolders = globalSingleton(
3110
+ "theokit-sdk.plugins.manifest-untrusted-warned",
3111
+ () => /* @__PURE__ */ new Set()
3112
+ );
3113
+ async function importTrustedManifestPlugins(candidates, trustedFolders) {
3114
+ const plugins = [];
3115
+ for (const candidate of candidates) {
3116
+ const realFolder = realpathOrUndefined(candidate.folderPath);
3117
+ if (realFolder === void 0 || !trustedFolders.has(realFolder)) {
3118
+ warnUntrustedOnce(candidate, realFolder ?? candidate.folderPath);
3119
+ continue;
3120
+ }
3121
+ plugins.push(await importEntry(candidate));
3122
+ }
3123
+ return plugins;
3124
+ }
3125
+ function realpathOrUndefined(path) {
3126
+ try {
3127
+ return realpathSync(path);
3128
+ } catch {
3129
+ return void 0;
3130
+ }
3131
+ }
3132
+ function warnUntrustedOnce(candidate, realFolder) {
3133
+ if (warnedFolders.has(candidate.entryPath)) return;
3134
+ warnedFolders.add(candidate.entryPath);
3135
+ const { folder, metadata } = candidate;
3136
+ const declared = metadata.name === folder ? "" : ` (declares name "${metadata.name}")`;
3137
+ diag(
3138
+ `[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).
3139
+ `
3140
+ );
3141
+ }
3142
+ async function importEntry(candidate) {
3143
+ const { metadata } = candidate;
3144
+ const entry = metadata.entry ?? "";
3145
+ let mod;
3146
+ try {
3147
+ mod = await import(pathToFileURL(candidate.entryPath).href);
3148
+ } catch (cause) {
3149
+ throw new ConfigurationError(`Plugin ${metadata.name} entry failed to import: ${entry}`, {
3150
+ code: "plugin_entry_import_failed",
3151
+ cause
3152
+ });
3153
+ }
3154
+ const plugin = mod.default;
3155
+ if (!isGeneralPlugin(plugin)) {
3156
+ throw new ConfigurationError(
3157
+ `Plugin ${metadata.name} entry must default-export a general plugin (kind "general", name, register): ${entry}`,
3158
+ { code: "plugin_entry_shape" }
3159
+ );
3160
+ }
3161
+ return plugin;
3162
+ }
3163
+ function isGeneralPlugin(value) {
3164
+ return isCodePlugin(value) && value.kind === "general" && typeof value.name === "string";
3165
+ }
3166
+ function executableExtensions() {
3167
+ return process.platform === "win32" ? ["", ...(process.env.PATHEXT ?? ".EXE;.CMD").split(";")] : [""];
3168
+ }
3169
+ function isExecutable(file) {
3170
+ try {
3171
+ accessSync(file, constants.X_OK);
3172
+ return true;
3173
+ } catch {
3174
+ return false;
3175
+ }
3176
+ }
3177
+ function binaryOnPath(bin) {
3178
+ if (bin.length === 0 || /[\\/]/.test(bin)) return false;
3179
+ const dirs = (process.env.PATH ?? "").split(delimiter).filter((dir) => dir.length > 0);
3180
+ return dirs.some(
3181
+ (dir) => executableExtensions().some((ext) => isExecutable(join(dir, bin + ext)))
3182
+ );
3183
+ }
3084
3184
  var SkillsManager = class {
3085
- constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline, compatSources = []) {
3185
+ constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline, compatSources = [], bundledDirs = []) {
3086
3186
  this.cwd = cwd;
3087
3187
  this.settingSourcesIncludeProject = settingSourcesIncludeProject;
3088
3188
  this.skillsDir = skillsDir;
3089
3189
  this.inline = inline;
3090
3190
  this.compatSources = compatSources;
3191
+ this.bundledDirs = bundledDirs;
3091
3192
  }
3092
3193
  cwd;
3093
3194
  settingSourcesIncludeProject;
3094
3195
  skillsDir;
3095
3196
  inline;
3096
3197
  compatSources;
3198
+ bundledDirs;
3097
3199
  skills = [];
3098
3200
  async initialize() {
3099
3201
  if (!this.settingSourcesIncludeProject) {
3100
- this.skills = this.mergeInline([]);
3202
+ this.skills = this.mergeInline(await this.discoverFrom(this.bundledDirs));
3101
3203
  return;
3102
3204
  }
3103
3205
  await this.refresh();
3104
3206
  }
3105
3207
  async refresh() {
3106
- const roots = this.skillsDir === void 0 ? [
3208
+ const ownRoots = this.skillsDir === void 0 ? [
3107
3209
  ...projectConfigRoots(this.cwd, this.compatSources, "skills").map(
3108
3210
  (root) => join(root, "skills")
3109
3211
  ),
3110
3212
  ...(await pluginBundleDirs(this.cwd, this.compatSources)).map((b) => join(b, "skills"))
3111
3213
  ] : [this.skillsDir];
3214
+ this.skills = this.mergeInline(await this.discoverFrom([...ownRoots, ...this.bundledDirs]));
3215
+ }
3216
+ async discoverFrom(roots) {
3112
3217
  const discovered = [];
3113
3218
  const seen = /* @__PURE__ */ new Set();
3114
3219
  for (const root of roots) {
@@ -3123,7 +3228,7 @@ var SkillsManager = class {
3123
3228
  discovered.push(skill);
3124
3229
  }
3125
3230
  }
3126
- this.skills = this.mergeInline(discovered);
3231
+ return discovered;
3127
3232
  }
3128
3233
  /** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
3129
3234
  mergeInline(discovered) {
@@ -3251,7 +3356,8 @@ async function resolveSendSkills(inputs, userText, memoryFacts) {
3251
3356
  inputs.settingSourcesIncludeProject,
3252
3357
  settings.skillsDir,
3253
3358
  settings.inline,
3254
- resolveCompatSources(inputs.options, inputs.workspaceCwd)
3359
+ resolveCompatSources(inputs.options, inputs.workspaceCwd),
3360
+ settings.bundledDirs
3255
3361
  );
3256
3362
  await manager.initialize();
3257
3363
  return { manager, autoInject: settings.autoInject ?? true };
@@ -3270,7 +3376,9 @@ async function buildSystemPromptContext(inputs, userText, memoryFacts, manager =
3270
3376
  // because a caller naming one has already made the decision this field keeps away from the
3271
3377
  // model. Widening it to execution would break the case the field is FOR — a side-effecting
3272
3378
  // skill a human may run and the model may not propose.
3273
- skills: skills.filter((skill) => skill.disableModelInvocation !== true).map((skill) => ({ name: skill.name, description: skill.description })),
3379
+ skills: skills.filter((skill) => skill.disableModelInvocation !== true).filter(
3380
+ (skill) => skill.requiresBins === void 0 || skill.requiresBins.every((bin) => binaryOnPath(bin))
3381
+ ).map((skill) => ({ name: skill.name, description: skill.description })),
3274
3382
  userMessage: userText,
3275
3383
  memory: memoryFacts.map((fact) => ({ text: fact.text }))
3276
3384
  };
@@ -4576,6 +4684,12 @@ var PluginsManager = class {
4576
4684
  localPaths;
4577
4685
  compatSources;
4578
4686
  plugins = [];
4687
+ /**
4688
+ * B-686 — where each listed object was discovered. Keyed by the object, not by name: two plugins
4689
+ * may share a declared name across roots or folders, and a field would leak a host path through
4690
+ * `plugins.list()`. `refresh()` replaces the objects, so stale origins are collected with them.
4691
+ */
4692
+ #origin = /* @__PURE__ */ new WeakMap();
4579
4693
  async initialize() {
4580
4694
  this.assertCloudRules();
4581
4695
  if (!this.settingSourcesIncludePlugins) {
@@ -4601,6 +4715,7 @@ var PluginsManager = class {
4601
4715
  const cliMetadata = await loadPluginManifestFromJson(this.cwd, cliPath, folderName);
4602
4716
  if (this.enabled === void 0 || this.enabled.includes(cliMetadata.name)) {
4603
4717
  this.plugins.push(cliMetadata);
4718
+ this.#origin.set(cliMetadata, { root: pluginsRoot, folder: folderName });
4604
4719
  }
4605
4720
  continue;
4606
4721
  }
@@ -4623,12 +4738,26 @@ var PluginsManager = class {
4623
4738
  if (this.enabled === void 0 || this.enabled.includes(metadata.name)) {
4624
4739
  await this.assertEntryFileExists(metadata, folderName, pluginsRoot);
4625
4740
  this.plugins.push(metadata);
4741
+ this.#origin.set(metadata, { root: pluginsRoot, folder: folderName });
4626
4742
  }
4627
4743
  }
4628
4744
  }
4629
4745
  list() {
4630
4746
  return Promise.resolve(this.plugins);
4631
4747
  }
4748
+ /** Listed native-root plugins that declare an `entry`, in list order. Reads no file. */
4749
+ nativeEntryCandidates() {
4750
+ const nativeRoot = join(theokitConfigRoot(this.cwd), "plugins");
4751
+ return this.plugins.flatMap((metadata) => {
4752
+ const origin = this.#origin.get(metadata);
4753
+ if (origin === void 0 || origin.root !== nativeRoot || metadata.entry === void 0) {
4754
+ return [];
4755
+ }
4756
+ const folderPath = join(origin.root, origin.folder);
4757
+ const entryPath = safePathJoin(folderPath, metadata.entry);
4758
+ return [{ metadata, folder: origin.folder, folderPath, entryPath }];
4759
+ });
4760
+ }
4632
4761
  async assertEntryFileExists(metadata, folderName, pluginsRoot) {
4633
4762
  const entry = metadata.entry;
4634
4763
  if (entry === void 0) return;
@@ -4794,7 +4923,8 @@ function buildSkills(args, out) {
4794
4923
  staticSkills?.inline,
4795
4924
  // #524 — the same declaration the per-send manager reads. Omitting it here would make
4796
4925
  // `agent.skills` disagree with the system prompt about which skills exist.
4797
- resolveCompatSources(args.options, args.workspaceCwd)
4926
+ resolveCompatSources(args.options, args.workspaceCwd),
4927
+ staticSkills?.bundledDirs
4798
4928
  );
4799
4929
  const localSkills = out.skillsManager;
4800
4930
  out.skills = {
@@ -5861,6 +5991,42 @@ function stripThinkBlocks(content) {
5861
5991
  return { visible, thinking };
5862
5992
  }
5863
5993
 
5994
+ // src/internal/agent-loop/prune-tool-results.ts
5995
+ function stubFor(olderThanRounds) {
5996
+ return `[tool result pruned: older than ${olderThanRounds} rounds]`;
5997
+ }
5998
+ function carriesToolResult(message) {
5999
+ return message.content.some((part) => part.type === "tool_result");
6000
+ }
6001
+ function stubbed(message, stub) {
6002
+ const content = message.content.map(
6003
+ (part) => part.type === "tool_result" ? { ...part, content: stub } : part
6004
+ );
6005
+ return { ...message, content };
6006
+ }
6007
+ function pruneToolResultsForRequest(messages, options) {
6008
+ if (options === void 0) return messages;
6009
+ const stub = stubFor(options.olderThanRounds);
6010
+ const out = [...messages];
6011
+ let rounds = 0;
6012
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
6013
+ const message = messages[index];
6014
+ if (!carriesToolResult(message)) continue;
6015
+ rounds += 1;
6016
+ if (rounds > options.olderThanRounds) out[index] = stubbed(message, stub);
6017
+ }
6018
+ return out;
6019
+ }
6020
+ function validatePruneToolResults(options) {
6021
+ if (options === void 0) return;
6022
+ const value = options.olderThanRounds;
6023
+ if (typeof value === "number" && Number.isInteger(value) && value >= 1) return;
6024
+ throw new ConfigurationError(
6025
+ `SendOptions.pruneToolResults.olderThanRounds must be an integer of at least 1, got ${String(value)}`,
6026
+ { code: "invalid_prune_tool_results" }
6027
+ );
6028
+ }
6029
+
5864
6030
  // src/internal/agent-loop/loop-llm-stream.ts
5865
6031
  function resolveSystemPromptWithMemoryAdditions(systemPrompt, additions) {
5866
6032
  if (additions === void 0 || additions.length === 0) return systemPrompt;
@@ -5949,7 +6115,8 @@ async function streamLlmTurn(inputs, ctx) {
5949
6115
  const key = derivePromptCacheKey(inputs.agentId);
5950
6116
  return key !== void 0 ? { promptCacheKey: key } : {};
5951
6117
  })(),
5952
- messages: ctx.messages,
6118
+ // B-564: the request gets a pruned copy; ctx.messages stays whole (the transcript is resent from it).
6119
+ messages: pruneToolResultsForRequest(ctx.messages, inputs.pruneToolResults),
5953
6120
  tools: ctx.tools.map(toLlmTool)
5954
6121
  },
5955
6122
  signal
@@ -7692,6 +7859,13 @@ function createRealLocalRun(options) {
7692
7859
  registerRun(handle);
7693
7860
  return handle;
7694
7861
  }
7862
+ function toolResultPolicyInputs(sendOptions) {
7863
+ return {
7864
+ ...sendOptions.perToolTimeoutMs !== void 0 ? { perToolTimeoutMs: sendOptions.perToolTimeoutMs } : {},
7865
+ ...sendOptions.toolResultGuard !== void 0 ? { toolResultGuard: sendOptions.toolResultGuard } : {},
7866
+ ...sendOptions.pruneToolResults !== void 0 ? { pruneToolResults: sendOptions.pruneToolResults } : {}
7867
+ };
7868
+ }
7695
7869
  function buildLoopInputs(options, runId, userText, userImages) {
7696
7870
  const maxIterations = options.sendOptions.maxIterations;
7697
7871
  if (maxIterations !== void 0 && (!Number.isInteger(maxIterations) || maxIterations < 1)) {
@@ -7700,6 +7874,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
7700
7874
  { code: "invalid_max_iterations" }
7701
7875
  );
7702
7876
  }
7877
+ validatePruneToolResults(options.sendOptions.pruneToolResults);
7703
7878
  const { primary, effectiveModelId } = resolveRunProvider(options);
7704
7879
  const fallback = options.agentOptions.providers?.fallback;
7705
7880
  const apiKeys = mergeExplicitApiKey(
@@ -7769,10 +7944,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
7769
7944
  ...options.sendOptions.context !== void 0 ? { context: options.sendOptions.context } : {},
7770
7945
  // SE2 — forward the opt-in typed runtime-event sink to the loop.
7771
7946
  ...options.sendOptions.onRunEvent !== void 0 ? { runEventSink: options.sendOptions.onRunEvent } : {},
7772
- // #58 / #57 — forward the per-tool timeout + tool-result guard so a consumer
7773
- // can enable them via SendOptions (not only internal AgentLoopInputs).
7774
- ...options.sendOptions.perToolTimeoutMs !== void 0 ? { perToolTimeoutMs: options.sendOptions.perToolTimeoutMs } : {},
7775
- ...options.sendOptions.toolResultGuard !== void 0 ? { toolResultGuard: options.sendOptions.toolResultGuard } : {},
7947
+ ...toolResultPolicyInputs(options.sendOptions),
7776
7948
  // M1-2: per-send iteration ceiling (validated above). The loop reads
7777
7949
  // inputs.maxIterations (default 8 when unset).
7778
7950
  ...maxIterations !== void 0 ? { maxIterations } : {},
@@ -7846,6 +8018,7 @@ var RealLocalRun = class extends FixtureRunBase {
7846
8018
  }
7847
8019
  async initializeMcp(inputs) {
7848
8020
  for (const [name, client] of inputs.mcp.entries()) {
8021
+ if (this.terminated) break;
7849
8022
  try {
7850
8023
  await client.initialize();
7851
8024
  } catch (cause) {
@@ -10286,13 +10459,20 @@ var LocalAgent = class {
10286
10459
  workspaceCwd: this.workspaceCwd
10287
10460
  });
10288
10461
  }
10462
+ /** B-686 — the workspace trust record is read only when a native manifest declares an entry. */
10463
+ async importManifestPlugins() {
10464
+ const candidates = this.pluginsManager?.nativeEntryCandidates() ?? [];
10465
+ if (candidates.length === 0) return [];
10466
+ return importTrustedManifestPlugins(candidates, readTrustedWorkspaceFolders());
10467
+ }
10289
10468
  async initialize() {
10290
10469
  await this.hooksExecutor.initialize(this.settingSourcesIncludeProject);
10291
10470
  if (this.context !== void 0) await this.context.initialize();
10292
10471
  if (this.skillsManager !== void 0) await this.skillsManager.initialize();
10293
10472
  if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
10294
10473
  const codePlugins = extractCodePlugins(this.options.plugins);
10295
- await this.pluginManagerCode.initialize(codePlugins);
10474
+ const manifestPlugins = await this.importManifestPlugins();
10475
+ await this.pluginManagerCode.initialize([...codePlugins, ...manifestPlugins]);
10296
10476
  this.resolvedSubagents = await loadSubagents(
10297
10477
  this.workspaceCwd,
10298
10478
  this.settingSourcesIncludeProject,
@@ -10983,7 +11163,7 @@ var Agent = class _Agent {
10983
11163
  * @public
10984
11164
  */
10985
11165
  static async generateObject(options) {
10986
- const { generateObjectImpl } = await import('./generate-object-S7MNVF2V.js');
11166
+ const { generateObjectImpl } = await import('./generate-object-TBDOBBYW.js');
10987
11167
  return generateObjectImpl(options, {
10988
11168
  create: (opts) => _Agent.create(opts),
10989
11169
  delete: (agentId) => _Agent.delete(agentId)
@@ -11007,7 +11187,7 @@ var Agent = class _Agent {
11007
11187
  delete: (agentId) => _Agent.delete(agentId)
11008
11188
  };
11009
11189
  async function* wrapper() {
11010
- streamObjectImport ??= import('./stream-object-R6SMYV4R.js');
11190
+ streamObjectImport ??= import('./stream-object-EKM4WGTI.js');
11011
11191
  const { streamObjectImpl } = await streamObjectImport;
11012
11192
  yield* streamObjectImpl(options, deps);
11013
11193
  }
@@ -11183,7 +11363,7 @@ var Agent = class _Agent {
11183
11363
  */
11184
11364
  static async compact(agentId, options = {}) {
11185
11365
  const reg = await requireLocalAgent(agentId, "compact");
11186
- const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-3U2JYTVG.js');
11366
+ const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-N2PPHQO6.js');
11187
11367
  const { cwd, model, store } = await openLocalStore(reg);
11188
11368
  return enqueueSessionWrite(
11189
11369
  cwd,
@@ -11213,7 +11393,7 @@ var Agent = class _Agent {
11213
11393
  */
11214
11394
  static async injectSessionTurn(agentId, turn) {
11215
11395
  const reg = await requireLocalAgent(agentId, "injectSessionTurn");
11216
- const { injectSessionTurn } = await import('./inject-session-THABTKJY.js');
11396
+ const { injectSessionTurn } = await import('./inject-session-J26SHHIO.js');
11217
11397
  const { cwd, model, store } = await openLocalStore(reg);
11218
11398
  await injectSessionTurn({
11219
11399
  store,
@@ -11371,5 +11551,5 @@ async function openLocalStore(reg) {
11371
11551
  }
11372
11552
 
11373
11553
  export { Agent, AgentBuilder, DEFAULT_AGENTIC_MODEL_ID, MEMORY_EMBEDDING_ADAPTERS, Tool, ToolError, UsageAccumulator, computeCost, generateCronId, getPricingEntry, managedSettingsPathFor, openRouterMemoryEmbeddingProviderAdapter, readManagedSettings, resolveSessionDir };
11374
- //# sourceMappingURL=chunk-BJ7BPLQK.js.map
11375
- //# sourceMappingURL=chunk-BJ7BPLQK.js.map
11554
+ //# sourceMappingURL=chunk-GARVAUCU.js.map
11555
+ //# sourceMappingURL=chunk-GARVAUCU.js.map