@theokit/sdk 5.12.1 → 5.13.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 (139) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/{agent-IG7BP6GN.js → agent-5DSDDH7K.js} +5 -5
  3. package/dist/{agent-IG7BP6GN.js.map → agent-5DSDDH7K.js.map} +1 -1
  4. package/dist/{agent-CVzDy_Oj.d.ts → agent-DSMuwADp.d.ts} +9 -2
  5. package/dist/{agent-BVKIUP7F.cjs → agent-WOMRT3KX.cjs} +6 -6
  6. package/dist/{agent-BVKIUP7F.cjs.map → agent-WOMRT3KX.cjs.map} +1 -1
  7. package/dist/{agent-Cn0sphpA.d.cts → agent-iW5kPpfT.d.cts} +9 -2
  8. package/dist/{chunk-XJ4C4NFX.js → chunk-2PRGRYEQ.js} +61 -47
  9. package/dist/chunk-2PRGRYEQ.js.map +1 -0
  10. package/dist/{chunk-HN4IKB6X.cjs → chunk-2XWAYCFM.cjs} +15 -13
  11. package/dist/chunk-2XWAYCFM.cjs.map +1 -0
  12. package/dist/{chunk-VVGFZQZC.js → chunk-3LMVJTNJ.js} +9 -5
  13. package/dist/chunk-3LMVJTNJ.js.map +1 -0
  14. package/dist/{chunk-IO4RI5ZJ.cjs → chunk-47EACDOC.cjs} +4 -4
  15. package/dist/{chunk-IO4RI5ZJ.cjs.map → chunk-47EACDOC.cjs.map} +1 -1
  16. package/dist/{chunk-LSWHDOCL.cjs → chunk-4UYHP6NF.cjs} +64 -48
  17. package/dist/chunk-4UYHP6NF.cjs.map +1 -0
  18. package/dist/{chunk-ZLFFDPXC.js → chunk-73IITAF7.js} +36 -14
  19. package/dist/chunk-73IITAF7.js.map +1 -0
  20. package/dist/{chunk-XRPMZ7TO.js → chunk-CYWOJA6B.js} +6 -4
  21. package/dist/chunk-CYWOJA6B.js.map +1 -0
  22. package/dist/{chunk-AQW54OWQ.js → chunk-DFBWYETS.js} +5 -3
  23. package/dist/chunk-DFBWYETS.js.map +1 -0
  24. package/dist/{chunk-YOVZMN4P.cjs → chunk-DVP3YMDA.cjs} +3 -3
  25. package/dist/{chunk-YOVZMN4P.cjs.map → chunk-DVP3YMDA.cjs.map} +1 -1
  26. package/dist/{chunk-EPANMGH7.cjs → chunk-FLDHYF5C.cjs} +11 -2
  27. package/dist/chunk-FLDHYF5C.cjs.map +1 -0
  28. package/dist/{chunk-BJ7BPLQK.js → chunk-JX4LB6XO.js} +124 -13
  29. package/dist/chunk-JX4LB6XO.js.map +1 -0
  30. package/dist/{chunk-Q6WT5535.cjs → chunk-KL7ZUMK3.cjs} +161 -50
  31. package/dist/chunk-KL7ZUMK3.cjs.map +1 -0
  32. package/dist/{chunk-FEAWEBWN.cjs → chunk-PDOXYXWX.cjs} +6 -4
  33. package/dist/chunk-PDOXYXWX.cjs.map +1 -0
  34. package/dist/{chunk-NBNRQN6T.js → chunk-QGDPMM3C.js} +11 -2
  35. package/dist/chunk-QGDPMM3C.js.map +1 -0
  36. package/dist/{chunk-ZWLFHSON.cjs → chunk-R35ZJAYT.cjs} +38 -15
  37. package/dist/chunk-R35ZJAYT.cjs.map +1 -0
  38. package/dist/{chunk-4YD2WI57.cjs → chunk-R427EOZE.cjs} +19 -15
  39. package/dist/chunk-R427EOZE.cjs.map +1 -0
  40. package/dist/{chunk-TLVI2OQK.cjs → chunk-SETHRLQS.cjs} +18 -2
  41. package/dist/chunk-SETHRLQS.cjs.map +1 -0
  42. package/dist/{chunk-BO3PV3OP.js → chunk-TDED5XES.js} +18 -3
  43. package/dist/chunk-TDED5XES.js.map +1 -0
  44. package/dist/{chunk-4GUFNDZR.js → chunk-XOYNB3YN.js} +3 -3
  45. package/dist/{chunk-4GUFNDZR.js.map → chunk-XOYNB3YN.js.map} +1 -1
  46. package/dist/{chunk-NJBJ3CUG.js → chunk-ZTP6ZACR.js} +3 -3
  47. package/dist/{chunk-NJBJ3CUG.js.map → chunk-ZTP6ZACR.js.map} +1 -1
  48. package/dist/{compact-session-3U2JYTVG.js → compact-session-5HMX6KYT.js} +3 -3
  49. package/dist/{compact-session-3U2JYTVG.js.map → compact-session-5HMX6KYT.js.map} +1 -1
  50. package/dist/{compact-session-NM56BREJ.cjs → compact-session-B7P6EU3Z.cjs} +12 -12
  51. package/dist/{compact-session-NM56BREJ.cjs.map → compact-session-B7P6EU3Z.cjs.map} +1 -1
  52. package/dist/{cron-BWDYetbq.d.cts → cron-BvxrLW5J.d.cts} +1 -1
  53. package/dist/{cron-CHn-F0fC.d.ts → cron-DdKzwJqK.d.ts} +1 -1
  54. package/dist/cron.cjs +5 -5
  55. package/dist/cron.d.cts +2 -2
  56. package/dist/cron.d.ts +2 -2
  57. package/dist/cron.js +4 -4
  58. package/dist/eval.cjs +9 -9
  59. package/dist/eval.js +4 -4
  60. package/dist/{executor-HKHT4CWS.cjs → executor-5QL5AXIZ.cjs} +18 -15
  61. package/dist/executor-5QL5AXIZ.cjs.map +1 -0
  62. package/dist/{executor-3D2UDJHW.js → executor-THUXNAFR.js} +6 -3
  63. package/dist/executor-THUXNAFR.js.map +1 -0
  64. package/dist/generate-object-A5F576IT.cjs +20 -0
  65. package/dist/{generate-object-XBWD2PU7.cjs.map → generate-object-A5F576IT.cjs.map} +1 -1
  66. package/dist/{generate-object-S7MNVF2V.js → generate-object-TBDOBBYW.js} +4 -4
  67. package/dist/{generate-object-S7MNVF2V.js.map → generate-object-TBDOBBYW.js.map} +1 -1
  68. package/dist/generate-object.d.ts +14 -1
  69. package/dist/index.cjs +43 -43
  70. package/dist/index.d.cts +30 -4
  71. package/dist/index.d.ts +30 -4
  72. package/dist/index.js +13 -13
  73. package/dist/{inject-session-THABTKJY.js → inject-session-75L3NCNL.js} +3 -3
  74. package/dist/{inject-session-THABTKJY.js.map → inject-session-75L3NCNL.js.map} +1 -1
  75. package/dist/{inject-session-JVTZNQF6.cjs → inject-session-WOH7TPDX.cjs} +4 -4
  76. package/dist/{inject-session-JVTZNQF6.cjs.map → inject-session-WOH7TPDX.cjs.map} +1 -1
  77. package/dist/internal/providers/discovery.d.ts +2 -2
  78. package/dist/internal/providers/trust-gate.d.ts +35 -0
  79. package/dist/internal/runtime/plugin-loader/manifest-entry-import.d.ts +17 -0
  80. package/dist/internal/runtime/plugin-loader/workspace-plugin-trust.d.ts +16 -0
  81. package/dist/internal/structured-output-helpers.d.ts +5 -2
  82. package/dist/sandbox/bwrap.d.cts +10 -8
  83. package/dist/sandbox/bwrap.d.ts +10 -8
  84. package/dist/sandbox/deny-read.d.cts +24 -0
  85. package/dist/sandbox/deny-read.d.ts +24 -0
  86. package/dist/sandbox/index.cjs +114 -35
  87. package/dist/sandbox/index.cjs.map +1 -1
  88. package/dist/sandbox/index.d.cts +2 -1
  89. package/dist/sandbox/index.d.ts +2 -1
  90. package/dist/sandbox/index.js +96 -21
  91. package/dist/sandbox/index.js.map +1 -1
  92. package/dist/sandbox/linux-sandbox.d.cts +16 -1
  93. package/dist/sandbox/linux-sandbox.d.ts +16 -1
  94. package/dist/sandbox/local-sandbox.d.cts +3 -1
  95. package/dist/sandbox/local-sandbox.d.ts +3 -1
  96. package/dist/sandbox/seccomp-delivery.d.cts +3 -0
  97. package/dist/sandbox/seccomp-delivery.d.ts +3 -0
  98. package/dist/sandbox/shell-escape.d.cts +14 -2
  99. package/dist/sandbox/shell-escape.d.ts +14 -2
  100. package/dist/sandbox/types.d.cts +45 -0
  101. package/dist/sandbox/types.d.ts +45 -0
  102. package/dist/stream-object-AS4YYM4B.cjs +20 -0
  103. package/dist/{stream-object-TEEK3CAX.cjs.map → stream-object-AS4YYM4B.cjs.map} +1 -1
  104. package/dist/stream-object-EKM4WGTI.js +7 -0
  105. package/dist/{stream-object-R6SMYV4R.js.map → stream-object-EKM4WGTI.js.map} +1 -1
  106. package/dist/stream-object.d.ts +14 -1
  107. package/dist/subagents-loader.d.cts +1 -1
  108. package/dist/subagents-loader.d.ts +1 -1
  109. package/dist/types/agent.d.ts +8 -1
  110. package/dist/workflow-as-tool.d.ts +39 -5
  111. package/dist/workflow-errors.d.ts +16 -0
  112. package/dist/workflow.cjs +31 -23
  113. package/dist/workflow.d.cts +54 -4
  114. package/dist/workflow.d.ts +54 -4
  115. package/dist/workflow.js +2 -2
  116. package/docs/error-codes.md +16 -13
  117. package/docs/harness-capability-map.md +50 -4
  118. package/package.json +1 -1
  119. package/dist/chunk-4YD2WI57.cjs.map +0 -1
  120. package/dist/chunk-AQW54OWQ.js.map +0 -1
  121. package/dist/chunk-BJ7BPLQK.js.map +0 -1
  122. package/dist/chunk-BO3PV3OP.js.map +0 -1
  123. package/dist/chunk-EPANMGH7.cjs.map +0 -1
  124. package/dist/chunk-FEAWEBWN.cjs.map +0 -1
  125. package/dist/chunk-HN4IKB6X.cjs.map +0 -1
  126. package/dist/chunk-LSWHDOCL.cjs.map +0 -1
  127. package/dist/chunk-NBNRQN6T.js.map +0 -1
  128. package/dist/chunk-Q6WT5535.cjs.map +0 -1
  129. package/dist/chunk-TLVI2OQK.cjs.map +0 -1
  130. package/dist/chunk-VVGFZQZC.js.map +0 -1
  131. package/dist/chunk-XJ4C4NFX.js.map +0 -1
  132. package/dist/chunk-XRPMZ7TO.js.map +0 -1
  133. package/dist/chunk-ZLFFDPXC.js.map +0 -1
  134. package/dist/chunk-ZWLFHSON.cjs.map +0 -1
  135. package/dist/executor-3D2UDJHW.js.map +0 -1
  136. package/dist/executor-HKHT4CWS.cjs.map +0 -1
  137. package/dist/generate-object-XBWD2PU7.cjs +0 -20
  138. package/dist/stream-object-R6SMYV4R.js +0 -7
  139. 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 chunkDVP3YMDA_cjs = require('./chunk-DVP3YMDA.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 chunk4UYHP6NF_cjs = require('./chunk-4UYHP6NF.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');
@@ -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 = chunk4UYHP6NF_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 chunk4UYHP6NF_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 chunk4UYHP6NF_cjs.isFixtureApiKey(apiKey) && chunk4UYHP6NF_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 && !chunk4UYHP6NF_cjs.isFixtureApiKey(apiKey) && chunk4UYHP6NF_cjs.getConfiguredBaseUrl() !== void 0;
1932
1933
  return useRealRuntime ? createRealCloudRun({
1933
1934
  agentId: this.agentId,
1934
1935
  model: this.model ?? { id: DEFAULT_AGENTIC_MODEL_ID },
@@ -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
+ chunkDVP3YMDA_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 chunkDVP3YMDA_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
+ chunkDVP3YMDA_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
+ chunkDVP3YMDA_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: chunk4UYHP6NF_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 chunkDVP3YMDA_cjs.flushSessionWrites();
3076
3077
  }
3077
3078
  async function safeConversation(run) {
3078
3079
  try {
@@ -3084,6 +3085,87 @@ 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(chunk4UYHP6NF_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 chunk4UYHP6NF_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
+ }
3087
3169
  var SkillsManager = class {
3088
3170
  constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline, compatSources = []) {
3089
3171
  this.cwd = cwd;
@@ -3703,7 +3785,7 @@ var HISTOGRAM_NAMES = {
3703
3785
  };
3704
3786
  function safeRequire(moduleName) {
3705
3787
  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)));
3788
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-KL7ZUMK3.cjs', document.baseURI).href)));
3707
3789
  return r(moduleName);
3708
3790
  } catch {
3709
3791
  return void 0;
@@ -3946,7 +4028,7 @@ var cachedOtel;
3946
4028
  function loadOtel() {
3947
4029
  if (cachedOtel === void 0) {
3948
4030
  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)));
4031
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-KL7ZUMK3.cjs', document.baseURI).href)));
3950
4032
  const mod = r("@opentelemetry/api");
3951
4033
  cachedOtel = mod;
3952
4034
  } catch {
@@ -4579,6 +4661,12 @@ var PluginsManager = class {
4579
4661
  localPaths;
4580
4662
  compatSources;
4581
4663
  plugins = [];
4664
+ /**
4665
+ * B-686 — where each listed object was discovered. Keyed by the object, not by name: two plugins
4666
+ * may share a declared name across roots or folders, and a field would leak a host path through
4667
+ * `plugins.list()`. `refresh()` replaces the objects, so stale origins are collected with them.
4668
+ */
4669
+ #origin = /* @__PURE__ */ new WeakMap();
4582
4670
  async initialize() {
4583
4671
  this.assertCloudRules();
4584
4672
  if (!this.settingSourcesIncludePlugins) {
@@ -4604,6 +4692,7 @@ var PluginsManager = class {
4604
4692
  const cliMetadata = await loadPluginManifestFromJson(this.cwd, cliPath, folderName);
4605
4693
  if (this.enabled === void 0 || this.enabled.includes(cliMetadata.name)) {
4606
4694
  this.plugins.push(cliMetadata);
4695
+ this.#origin.set(cliMetadata, { root: pluginsRoot, folder: folderName });
4607
4696
  }
4608
4697
  continue;
4609
4698
  }
@@ -4626,12 +4715,26 @@ var PluginsManager = class {
4626
4715
  if (this.enabled === void 0 || this.enabled.includes(metadata.name)) {
4627
4716
  await this.assertEntryFileExists(metadata, folderName, pluginsRoot);
4628
4717
  this.plugins.push(metadata);
4718
+ this.#origin.set(metadata, { root: pluginsRoot, folder: folderName });
4629
4719
  }
4630
4720
  }
4631
4721
  }
4632
4722
  list() {
4633
4723
  return Promise.resolve(this.plugins);
4634
4724
  }
4725
+ /** Listed native-root plugins that declare an `entry`, in list order. Reads no file. */
4726
+ nativeEntryCandidates() {
4727
+ const nativeRoot = path.join(chunkYQ3XC6C2_cjs.theokitConfigRoot(this.cwd), "plugins");
4728
+ return this.plugins.flatMap((metadata) => {
4729
+ const origin = this.#origin.get(metadata);
4730
+ if (origin === void 0 || origin.root !== nativeRoot || metadata.entry === void 0) {
4731
+ return [];
4732
+ }
4733
+ const folderPath = path.join(origin.root, origin.folder);
4734
+ const entryPath = chunk3KIUY67P_cjs.safePathJoin(folderPath, metadata.entry);
4735
+ return [{ metadata, folder: origin.folder, folderPath, entryPath }];
4736
+ });
4737
+ }
4635
4738
  async assertEntryFileExists(metadata, folderName, pluginsRoot) {
4636
4739
  const entry = metadata.entry;
4637
4740
  if (entry === void 0) return;
@@ -6743,7 +6846,7 @@ function applyToolResultGuard(parts, opts) {
6743
6846
  (p) => (
6744
6847
  // SE7 — guard the TEXT of a tool result (string or the text blocks of a
6745
6848
  // structured content); image blocks pass through untouched.
6746
- p.type === "tool_result" ? { ...p, content: chunkLSWHDOCL_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6849
+ p.type === "tool_result" ? { ...p, content: chunk4UYHP6NF_cjs.renderToolResultContentText(p.content, (t) => guardText(t, opts)) } : p
6747
6850
  )
6748
6851
  );
6749
6852
  }
@@ -7061,13 +7164,13 @@ var FallbackLlmClient = class {
7061
7164
  async *stream(request, signal) {
7062
7165
  let lastError;
7063
7166
  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);
7167
+ if (signal.aborted) throw chunk4UYHP6NF_cjs.abortError(signal);
7168
+ const attempt = await chunk4UYHP6NF_cjs.tryFirstEvent(client, request, signal, true);
7066
7169
  if (attempt.kind === "handshake_error") {
7067
7170
  lastError = attempt.error;
7068
7171
  continue;
7069
7172
  }
7070
- return yield* chunkLSWHDOCL_cjs.relayStream(attempt.generator, attempt.firstResult);
7173
+ return yield* chunk4UYHP6NF_cjs.relayStream(attempt.generator, attempt.firstResult);
7071
7174
  }
7072
7175
  if (lastError !== void 0) throw lastError;
7073
7176
  throw new chunkCEGU5AVD_cjs.NetworkError("FallbackLlmClient has no providers configured", {
@@ -7703,9 +7806,9 @@ function buildLoopInputs(options, runId, userText, userImages) {
7703
7806
  { code: "invalid_max_iterations" }
7704
7807
  );
7705
7808
  }
7706
- const { primary, effectiveModelId } = chunkLSWHDOCL_cjs.resolveRunProvider(options);
7809
+ const { primary, effectiveModelId } = chunk4UYHP6NF_cjs.resolveRunProvider(options);
7707
7810
  const fallback = options.agentOptions.providers?.fallback;
7708
- const apiKeys = chunkLSWHDOCL_cjs.mergeExplicitApiKey(
7811
+ const apiKeys = chunk4UYHP6NF_cjs.mergeExplicitApiKey(
7709
7812
  options.agentOptions.providers?.apiKeys,
7710
7813
  primary,
7711
7814
  options.agentOptions.apiKey
@@ -7714,7 +7817,7 @@ function buildLoopInputs(options, runId, userText, userImages) {
7714
7817
  const extractToolCallsFromContent = options.agentOptions.providers?.routes?.[0]?.extractToolCallsFromContent;
7715
7818
  const rateLimitSink = options.sendOptions.onRunEvent;
7716
7819
  const modelBaseUrl = options.model?.url;
7717
- const chain = chunkLSWHDOCL_cjs.resolveProviderChain({
7820
+ const chain = chunk4UYHP6NF_cjs.resolveProviderChain({
7718
7821
  primary,
7719
7822
  ...modelBaseUrl !== void 0 ? { baseUrl: modelBaseUrl } : {},
7720
7823
  ...fallback !== void 0 ? { fallback } : {},
@@ -7849,6 +7952,7 @@ var RealLocalRun = class extends FixtureRunBase {
7849
7952
  }
7850
7953
  async initializeMcp(inputs) {
7851
7954
  for (const [name, client] of inputs.mcp.entries()) {
7955
+ if (this.terminated) break;
7852
7956
  try {
7853
7957
  await client.initialize();
7854
7958
  } catch (cause) {
@@ -7999,7 +8103,7 @@ function buildRealRunOptions(args) {
7999
8103
  };
8000
8104
  }
8001
8105
  async function createFixtureRunHelper(args) {
8002
- const sessionMessages = chunkYOVZMN4P_cjs.getSessionMessages(args.inputs.agentId);
8106
+ const sessionMessages = chunkDVP3YMDA_cjs.getSessionMessages(args.inputs.agentId);
8003
8107
  const projectMcpServers = args.inputs.settingSourcesIncludeProject ? await readProjectMcpServers(args.inputs.workspaceCwd) : {};
8004
8108
  return createLocalRun({
8005
8109
  agentId: args.inputs.agentId,
@@ -8018,7 +8122,7 @@ async function createFixtureRunHelper(args) {
8018
8122
  }
8019
8123
  async function dispatchLocalRun(args) {
8020
8124
  const apiKey = chunkRNXXYF22_cjs.resolveApiKey(args.inputs.options.apiKey);
8021
- if (chunkLSWHDOCL_cjs.shouldUseRealLocalRuntime(apiKey)) {
8125
+ if (chunk4UYHP6NF_cjs.shouldUseRealLocalRuntime(apiKey)) {
8022
8126
  return createRealLocalRun(
8023
8127
  buildRealRunOptions({
8024
8128
  inputs: args.inputs,
@@ -8274,10 +8378,10 @@ async function disposeLocalAgentSession(agent) {
8274
8378
  agent.lifecycleAbortController.abort();
8275
8379
  await chunkZF2LDKQQ_cjs.withCwdMutex(`agent-send:${agent.agentId}`, () => Promise.resolve());
8276
8380
  disposeSessionMcpClients(agent.agentId);
8277
- await chunkYOVZMN4P_cjs.flushSessionWrites();
8381
+ await chunkDVP3YMDA_cjs.flushSessionWrites();
8278
8382
  await flushRegistrySaves(agent.workspaceCwd);
8279
8383
  await disposeSessionStore(agent.sessionStore);
8280
- chunkYOVZMN4P_cjs.discardSession(agent.workspaceCwd, agent.agentId);
8384
+ chunkDVP3YMDA_cjs.discardSession(agent.workspaceCwd, agent.agentId);
8281
8385
  }
8282
8386
  async function reloadLocalAgent(agent) {
8283
8387
  if (agent.context !== void 0) await agent.context.refresh();
@@ -9141,7 +9245,7 @@ var LocalAgentMemory = class {
9141
9245
  async runActiveMemoryIfEnabled(userText, priorMessages, telemetry) {
9142
9246
  const cfg = this.options.memory?.activeRecall;
9143
9247
  if (cfg?.enabled !== true || this.index === void 0) return void 0;
9144
- if (this.breaker === void 0) this.breaker = new chunkLSWHDOCL_cjs.CircuitBreaker();
9248
+ if (this.breaker === void 0) this.breaker = new chunk4UYHP6NF_cjs.CircuitBreaker();
9145
9249
  if (this.cache === void 0) this.cache = new ActiveMemoryCache();
9146
9250
  const result = await runActiveMemory({
9147
9251
  userText,
@@ -9456,8 +9560,8 @@ async function localAgentUsePersonality(agent, name, opts) {
9456
9560
  registry,
9457
9561
  store: agent.personalityStore,
9458
9562
  invalidateCache: (reason) => agent.invalidateCache(reason),
9459
- appendSessionMessage: (msg) => chunkYOVZMN4P_cjs.appendSessionMessage(agent.agentId, msg),
9460
- clearSession: () => chunkYOVZMN4P_cjs.clearSession(agent.agentId),
9563
+ appendSessionMessage: (msg) => chunkDVP3YMDA_cjs.appendSessionMessage(agent.agentId, msg),
9564
+ clearSession: () => chunkDVP3YMDA_cjs.clearSession(agent.agentId),
9461
9565
  opts: opts ?? {}
9462
9566
  })
9463
9567
  );
@@ -9985,7 +10089,7 @@ async function executeSendLocked(inputs, message, options) {
9985
10089
  if (inputs.options.onBeforeSend !== void 0) {
9986
10090
  await inputs.options.onBeforeSend({
9987
10091
  conversationId: inputs.agentId,
9988
- previousMessageCount: chunkYOVZMN4P_cjs.getSessionMessages(inputs.agentId).length
10092
+ previousMessageCount: chunkDVP3YMDA_cjs.getSessionMessages(inputs.agentId).length
9989
10093
  });
9990
10094
  }
9991
10095
  await inputs.runPreHook(userText);
@@ -9997,8 +10101,8 @@ async function executeSendLocked(inputs, message, options) {
9997
10101
  userText,
9998
10102
  sendOptions: options
9999
10103
  });
10000
- const priorMessages = [...chunkYOVZMN4P_cjs.getSessionMessages(inputs.agentId)];
10001
- chunkYOVZMN4P_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
10104
+ const priorMessages = [...chunkDVP3YMDA_cjs.getSessionMessages(inputs.agentId)];
10105
+ chunkDVP3YMDA_cjs.appendSessionMessage(inputs.agentId, { role: "user", text: userText });
10002
10106
  await persistMemoryFactIfWritePrompt(inputs.workspaceCwd, inputs.options.memory, userText);
10003
10107
  const memoryFacts = await readMemoryForSend(inputs.workspaceCwd, inputs.options.memory, userText);
10004
10108
  const memoryTools = void 0;
@@ -10289,13 +10393,20 @@ var LocalAgent = class {
10289
10393
  workspaceCwd: this.workspaceCwd
10290
10394
  });
10291
10395
  }
10396
+ /** B-686 — the workspace trust record is read only when a native manifest declares an entry. */
10397
+ async importManifestPlugins() {
10398
+ const candidates = this.pluginsManager?.nativeEntryCandidates() ?? [];
10399
+ if (candidates.length === 0) return [];
10400
+ return importTrustedManifestPlugins(candidates, readTrustedWorkspaceFolders());
10401
+ }
10292
10402
  async initialize() {
10293
10403
  await this.hooksExecutor.initialize(this.settingSourcesIncludeProject);
10294
10404
  if (this.context !== void 0) await this.context.initialize();
10295
10405
  if (this.skillsManager !== void 0) await this.skillsManager.initialize();
10296
10406
  if (this.pluginsManager !== void 0) await this.pluginsManager.initialize();
10297
10407
  const codePlugins = chunkBV2MWEMV_cjs.extractCodePlugins(this.options.plugins);
10298
- await this.pluginManagerCode.initialize(codePlugins);
10408
+ const manifestPlugins = await this.importManifestPlugins();
10409
+ await this.pluginManagerCode.initialize([...codePlugins, ...manifestPlugins]);
10299
10410
  this.resolvedSubagents = await chunkWDVG5R2Q_cjs.loadSubagents(
10300
10411
  this.workspaceCwd,
10301
10412
  this.settingSourcesIncludeProject,
@@ -10304,7 +10415,7 @@ var LocalAgent = class {
10304
10415
  );
10305
10416
  await acquireLeaseIfPossible(this.sessionStore, this.agentId);
10306
10417
  try {
10307
- await chunkYOVZMN4P_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
10418
+ await chunkDVP3YMDA_cjs.hydrateSession(this.agentId, { store: this.sessionStore, cwd: this.workspaceCwd });
10308
10419
  await this.personalityStore.hydrate(this.agentId);
10309
10420
  } catch (err) {
10310
10421
  await releaseLeaseIfPossible(this.sessionStore, this.agentId);
@@ -10648,15 +10759,15 @@ async function maybeInjectHandoffTools(options) {
10648
10759
  };
10649
10760
  }
10650
10761
  function keyWillFlowToProvider(apiKey, provider) {
10651
- if (chunkLSWHDOCL_cjs.isFixtureApiKey(apiKey)) return false;
10652
- if (chunkLSWHDOCL_cjs.getConfiguredBaseUrl() !== void 0) return false;
10762
+ if (chunk4UYHP6NF_cjs.isFixtureApiKey(apiKey)) return false;
10763
+ if (chunk4UYHP6NF_cjs.getConfiguredBaseUrl() !== void 0) return false;
10653
10764
  if (provider === void 0) return false;
10654
10765
  const profile = chunkLO6LIUZ6_cjs.getProviderProfile(provider);
10655
10766
  if (profile === void 0) return false;
10656
10767
  return profile.authType !== "none";
10657
10768
  }
10658
10769
  function missingApiKeyMessage() {
10659
- const present = chunkLSWHDOCL_cjs.presentProviderCredentialEnvVars();
10770
+ const present = chunk4UYHP6NF_cjs.presentProviderCredentialEnvVars();
10660
10771
  const base = `Missing API key \u2014 set ${chunkRNXXYF22_cjs.API_KEY_ENV_VAR}, or pass \`apiKey\` to Agent.create()`;
10661
10772
  if (present.length === 0) return `${base}.`;
10662
10773
  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]}, ... })\`.`;
@@ -10676,7 +10787,7 @@ async function createLocalAgent(options) {
10676
10787
  }
10677
10788
  } else {
10678
10789
  const willFlowToProvider = keyWillFlowToProvider(apiKey, provider);
10679
- const shape = chunkLSWHDOCL_cjs.validateApiKeyShape(apiKey, {
10790
+ const shape = chunk4UYHP6NF_cjs.validateApiKeyShape(apiKey, {
10680
10791
  strict: willFlowToProvider,
10681
10792
  ...willFlowToProvider ? { provider } : {}
10682
10793
  });
@@ -10695,15 +10806,15 @@ async function createCloudAgent(options) {
10695
10806
  code: "missing_api_key"
10696
10807
  });
10697
10808
  }
10698
- const shape = chunkLSWHDOCL_cjs.validateApiKeyShape(apiKey);
10809
+ const shape = chunk4UYHP6NF_cjs.validateApiKeyShape(apiKey);
10699
10810
  if (shape.malformed) {
10700
10811
  throw new chunkCEGU5AVD_cjs.AuthenticationError(shape.message, { code: "malformed_api_key" });
10701
10812
  }
10702
- const baseUrl = chunkLSWHDOCL_cjs.getConfiguredBaseUrl();
10813
+ const baseUrl = chunk4UYHP6NF_cjs.getConfiguredBaseUrl();
10703
10814
  if (baseUrl === void 0) {
10704
10815
  return new CloudAgent(options);
10705
10816
  }
10706
- const response = await chunkLSWHDOCL_cjs.httpRequest("/v1/agents", {
10817
+ const response = await chunk4UYHP6NF_cjs.httpRequest("/v1/agents", {
10707
10818
  apiKey,
10708
10819
  method: "POST",
10709
10820
  body: {
@@ -10728,7 +10839,7 @@ function resolveAgentPersistenceCwd(options) {
10728
10839
  return process.cwd();
10729
10840
  }
10730
10841
  async function rehydrateExistingAgent(agentId, existing, options) {
10731
- await chunkLSWHDOCL_cjs.discoverProviderPlugins();
10842
+ await chunk4UYHP6NF_cjs.discoverProviderPlugins();
10732
10843
  await validateRehydratedAgent(agentId, existing);
10733
10844
  const mergedLocal = options.local !== void 0 && existing.options.local !== void 0 ? { ...existing.options.local, ...options.local } : options.local ?? existing.options.local;
10734
10845
  const mergedMemory = mergeResumedMemory(existing.options.memory, options.memory);
@@ -10888,7 +10999,7 @@ var Agent = class _Agent {
10888
10999
  pluginCount: enabledPluginNames(options.plugins).length
10889
11000
  });
10890
11001
  try {
10891
- await chunkLSWHDOCL_cjs.discoverProviderPlugins();
11002
+ await chunk4UYHP6NF_cjs.discoverProviderPlugins();
10892
11003
  const agent = await runCreateUnderSpan(options, span);
10893
11004
  return agent;
10894
11005
  } catch (err) {
@@ -10986,7 +11097,7 @@ var Agent = class _Agent {
10986
11097
  * @public
10987
11098
  */
10988
11099
  static async generateObject(options) {
10989
- const { generateObjectImpl } = await import('./generate-object-XBWD2PU7.cjs');
11100
+ const { generateObjectImpl } = await import('./generate-object-A5F576IT.cjs');
10990
11101
  return generateObjectImpl(options, {
10991
11102
  create: (opts) => _Agent.create(opts),
10992
11103
  delete: (agentId) => _Agent.delete(agentId)
@@ -11010,7 +11121,7 @@ var Agent = class _Agent {
11010
11121
  delete: (agentId) => _Agent.delete(agentId)
11011
11122
  };
11012
11123
  async function* wrapper() {
11013
- streamObjectImport ??= import('./stream-object-TEEK3CAX.cjs');
11124
+ streamObjectImport ??= import('./stream-object-AS4YYM4B.cjs');
11014
11125
  const { streamObjectImpl } = await streamObjectImport;
11015
11126
  yield* streamObjectImpl(options, deps);
11016
11127
  }
@@ -11186,9 +11297,9 @@ var Agent = class _Agent {
11186
11297
  */
11187
11298
  static async compact(agentId, options = {}) {
11188
11299
  const reg = await requireLocalAgent(agentId, "compact");
11189
- const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-NM56BREJ.cjs');
11300
+ const { compactSessionTranscript, buildDefaultSummarizer: buildDefaultSummarizer2 } = await import('./compact-session-B7P6EU3Z.cjs');
11190
11301
  const { cwd, model, store } = await openLocalStore(reg);
11191
- return chunkYOVZMN4P_cjs.enqueueSessionWrite(
11302
+ return chunkDVP3YMDA_cjs.enqueueSessionWrite(
11192
11303
  cwd,
11193
11304
  agentId,
11194
11305
  () => compactSessionTranscript({
@@ -11216,7 +11327,7 @@ var Agent = class _Agent {
11216
11327
  */
11217
11328
  static async injectSessionTurn(agentId, turn) {
11218
11329
  const reg = await requireLocalAgent(agentId, "injectSessionTurn");
11219
- const { injectSessionTurn } = await import('./inject-session-JVTZNQF6.cjs');
11330
+ const { injectSessionTurn } = await import('./inject-session-WOH7TPDX.cjs');
11220
11331
  const { cwd, model, store } = await openLocalStore(reg);
11221
11332
  await injectSessionTurn({
11222
11333
  store,
@@ -11387,5 +11498,5 @@ exports.managedSettingsPathFor = managedSettingsPathFor;
11387
11498
  exports.openRouterMemoryEmbeddingProviderAdapter = openRouterMemoryEmbeddingProviderAdapter;
11388
11499
  exports.readManagedSettings = readManagedSettings;
11389
11500
  exports.resolveSessionDir = resolveSessionDir;
11390
- //# sourceMappingURL=chunk-Q6WT5535.cjs.map
11391
- //# sourceMappingURL=chunk-Q6WT5535.cjs.map
11501
+ //# sourceMappingURL=chunk-KL7ZUMK3.cjs.map
11502
+ //# sourceMappingURL=chunk-KL7ZUMK3.cjs.map