@theokit/sdk 3.1.1 → 3.2.2

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 (44) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/a2a/index.cjs +188 -49
  3. package/dist/a2a/index.cjs.map +1 -1
  4. package/dist/a2a/index.js +188 -49
  5. package/dist/a2a/index.js.map +1 -1
  6. package/dist/{cron-C2jWAvlQ.d.cts → cron-4u1UdmgC.d.cts} +1 -1
  7. package/dist/{cron-BLRe166v.d.ts → cron-DuhVPer6.d.ts} +1 -1
  8. package/dist/cron.cjs +188 -49
  9. package/dist/cron.cjs.map +1 -1
  10. package/dist/cron.d.cts +2 -2
  11. package/dist/cron.d.ts +2 -2
  12. package/dist/cron.js +188 -49
  13. package/dist/cron.js.map +1 -1
  14. package/dist/{errors-D_Bfo30u.d.ts → errors-_fPS0X80.d.ts} +1 -1
  15. package/dist/{errors-DZpCGlYv.d.cts → errors-jxK4yfp5.d.cts} +1 -1
  16. package/dist/errors.d.cts +2 -2
  17. package/dist/eval.cjs +188 -64
  18. package/dist/eval.cjs.map +1 -1
  19. package/dist/eval.js +188 -64
  20. package/dist/eval.js.map +1 -1
  21. package/dist/index.cjs +197 -50
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +6 -6
  24. package/dist/index.d.ts +6 -6
  25. package/dist/index.js +197 -50
  26. package/dist/index.js.map +1 -1
  27. package/dist/internal/runtime/context/context-discovery.d.ts +1 -1
  28. package/dist/internal/runtime/context/context-glob.d.ts +1 -0
  29. package/dist/internal/runtime/context/context-manager.d.ts +18 -1
  30. package/dist/internal/runtime/context/context-mdc-parser.d.ts +7 -6
  31. package/dist/internal/runtime/context/context-rules-frontmatter.d.ts +30 -0
  32. package/dist/internal/runtime/context/context-yaml-lite.d.ts +26 -0
  33. package/dist/project.cjs.map +1 -1
  34. package/dist/project.js.map +1 -1
  35. package/dist/{run-CLXKMRgq.d.cts → run-CrHz9BAP.d.cts} +9 -0
  36. package/dist/{run-CLXKMRgq.d.ts → run-CrHz9BAP.d.ts} +9 -0
  37. package/dist/sandbox/index.cjs +8 -9
  38. package/dist/sandbox/index.cjs.map +1 -1
  39. package/dist/sandbox/index.js +8 -9
  40. package/dist/sandbox/index.js.map +1 -1
  41. package/dist/sandbox/types.d.cts +0 -1
  42. package/dist/sandbox/types.d.ts +0 -1
  43. package/dist/types/run.d.ts +9 -0
  44. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import { H as RunOperation } from './run-CLXKMRgq.js';
1
+ import { H as RunOperation } from './run-CrHz9BAP.js';
2
2
 
3
3
  /**
4
4
  * Public type contract for the Budget enforcement primitive
@@ -1,4 +1,4 @@
1
- import { H as RunOperation } from './run-CLXKMRgq.cjs';
1
+ import { H as RunOperation } from './run-CrHz9BAP.cjs';
2
2
 
3
3
  /**
4
4
  * Public type contract for the Budget enforcement primitive
package/dist/errors.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, g as BudgetExceededError, C as ConfigurationError, u as CredentialPoolExhaustedError, m as ErrorCode, E as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, K as KnownAgentRunErrorCode, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, T as TheokitAgentError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-DZpCGlYv.cjs';
2
- import './run-CLXKMRgq.cjs';
1
+ export { A as AgentDisposedError, c as AgentRunError, d as AgentRunErrorCode, e as AuthenticationError, g as BudgetExceededError, C as ConfigurationError, u as CredentialPoolExhaustedError, m as ErrorCode, E as ErrorMetadata, I as IntegrationNotConnectedError, n as InvalidTaskIdError, K as KnownAgentRunErrorCode, M as MemoryAdapterError, o as MemoryAdapterErrorCode, N as NetworkError, R as RateLimitError, p as TaskNotFoundError, T as TheokitAgentError, U as UnknownAgentError, q as UnsupportedBudgetOperationError, r as UnsupportedRunOperationError, s as UnsupportedTaskOperationError, t as isTransientError } from './errors-jxK4yfp5.cjs';
2
+ import './run-CrHz9BAP.cjs';
3
3
  import 'zod';
package/dist/eval.cjs CHANGED
@@ -962,10 +962,10 @@ function buildToolPrompt(prompt) {
962
962
  Respond by calling the \`output\` tool with the structured answer that matches the schema.`;
963
963
  }
964
964
  function setupStructuredOutput(schema, maxRetries) {
965
- const z8 = requireZod();
965
+ const z9 = requireZod();
966
966
  const jsonSchema = toJsonSchema(schema, { unrepresentable: "any" });
967
967
  return {
968
- z: z8,
968
+ z: z9,
969
969
  jsonSchema,
970
970
  maxRetries: maxRetries ?? 1,
971
971
  initialUsage: { inputTokens: 0, outputTokens: 0 }
@@ -4743,7 +4743,14 @@ var init_env_policy = __esm({
4743
4743
  /[_-]PWD/i,
4744
4744
  /CREDENTIAL/i,
4745
4745
  /PRIVATE/i,
4746
- /_AUTH/i
4746
+ /_AUTH/i,
4747
+ // #54-a — value-embedded-secret conventions (no generic `*_URL` — see keep-list test).
4748
+ /DSN/i,
4749
+ /WEBHOOK/i,
4750
+ /COOKIE/i,
4751
+ /CONNECTION[_-]?STRING/i,
4752
+ // Known DB / message-broker connection-string vars (carry `user:pass@`).
4753
+ /(?:^|[_-])(?:DATABASE|DB|REDIS|MONGO(?:DB)?|POSTGRES(?:QL)?|MYSQL|MARIADB|AMQP|RABBITMQ|CLICKHOUSE|ELASTIC(?:SEARCH)?|CASSANDRA|COUCHDB|MEMCACHED|NATS|KAFKA)[_-]?(?:URL|URI|DSN|CONNECTION)/i
4747
4754
  ];
4748
4755
  CORE_VARS = [
4749
4756
  "PATH",
@@ -6041,7 +6048,7 @@ async function buildSystemPromptContext(inputs, userText, memoryFacts, manager =
6041
6048
  memory: memoryFacts.map((fact) => ({ text: fact.text }))
6042
6049
  };
6043
6050
  }
6044
- async function buildAssemblyContext(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary) {
6051
+ async function buildAssemblyContext(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary, contextPaths) {
6045
6052
  const resolved = await resolveSendSkills(inputs, userText, memoryFacts);
6046
6053
  const baseCtx = await buildSystemPromptContext(inputs, userText, memoryFacts, resolved.manager);
6047
6054
  const assemblyCtx = {
@@ -6054,19 +6061,21 @@ async function buildAssemblyContext(inputs, userText, baseSystemPrompt, memoryFa
6054
6061
  assemblyCtx.activeMemorySummary = activeMemorySummary;
6055
6062
  }
6056
6063
  if (inputs.context !== void 0) {
6064
+ await inputs.context.applyScope(contextPaths);
6057
6065
  const internal = inputs.context.internalAssemblySnapshot();
6058
6066
  assemblyCtx.contextSnapshot = { sources: internal.sources };
6059
6067
  if (internal.maxTokens !== void 0) assemblyCtx.contextMaxTokens = internal.maxTokens;
6060
6068
  }
6061
6069
  return assemblyCtx;
6062
6070
  }
6063
- async function assembleSystemPromptForSend(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary) {
6071
+ async function assembleSystemPromptForSend(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary, contextPaths) {
6064
6072
  const ctx = await buildAssemblyContext(
6065
6073
  inputs,
6066
6074
  userText,
6067
6075
  baseSystemPrompt,
6068
6076
  memoryFacts,
6069
- activeMemorySummary
6077
+ activeMemorySummary,
6078
+ contextPaths
6070
6079
  );
6071
6080
  return inputs.systemPromptPipeline.assemble(ctx);
6072
6081
  }
@@ -6773,6 +6782,14 @@ var init_context_discovery = __esm({
6773
6782
  followImports: false,
6774
6783
  priority: 40
6775
6784
  },
6785
+ {
6786
+ id: "theokit-rules",
6787
+ pattern: ".theokit/rules/*.md",
6788
+ scope: "globbed",
6789
+ parser: "rules-frontmatter",
6790
+ followImports: false,
6791
+ priority: 45
6792
+ },
6776
6793
  {
6777
6794
  id: "theokit-context",
6778
6795
  pattern: ".theokit/context/*.md",
@@ -6856,32 +6873,27 @@ var init_context_import_resolver = __esm({
6856
6873
  MAX_HOPS = 5;
6857
6874
  }
6858
6875
  });
6859
- function parseMdc(content) {
6860
- const m = FRONTMATTER_RE.exec(content);
6861
- if (m === null) {
6862
- return { frontmatter: { alwaysApply: true }, body: content };
6863
- }
6864
- const yamlBody = m[1] ?? "";
6865
- const body = m[2] ?? "";
6866
- try {
6867
- const parsed = parseSimpleYaml2(yamlBody);
6868
- const validated = McdFrontmatterSchema.safeParse(parsed);
6869
- if (!validated.success) return void 0;
6870
- return { frontmatter: validated.data, body };
6871
- } catch {
6872
- return void 0;
6873
- }
6876
+
6877
+ // src/internal/runtime/context/context-glob.ts
6878
+ function globToRegex(glob) {
6879
+ const compiled = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*\//g, "::GLOBSTAR_SLASH::").replace(/\*\*/g, "::GLOBSTAR::").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(/::GLOBSTAR_SLASH::/g, "(?:.*/)?").replace(/::GLOBSTAR::/g, ".*");
6880
+ return new RegExp(`^${compiled}$`);
6874
6881
  }
6875
- function shouldActivate(fm, touchedFiles) {
6876
- if (fm.alwaysApply === true) return true;
6877
- if (fm.globs === void 0 || fm.globs.length === 0) return false;
6878
- if (touchedFiles.length === 0) return false;
6879
- const globRes = fm.globs.map(globToRegex);
6880
- return touchedFiles.some((file) => globRes.some((re) => re.test(file)));
6882
+ function anyGlobMatches(patterns, paths) {
6883
+ if (patterns.length === 0 || paths.length === 0) return false;
6884
+ const res = patterns.map(globToRegex);
6885
+ return paths.some((p) => res.some((re) => re.test(p)));
6881
6886
  }
6882
- function globToRegex(glob) {
6883
- const escaped = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "::DOUBLESTAR::").replace(/\*/g, "[^/]*").replace(/::DOUBLESTAR::/g, ".*").replace(/\?/g, ".");
6884
- return new RegExp(`^${escaped}$`);
6887
+ var init_context_glob = __esm({
6888
+ "src/internal/runtime/context/context-glob.ts"() {
6889
+ }
6890
+ });
6891
+
6892
+ // src/internal/runtime/context/context-yaml-lite.ts
6893
+ function splitFrontmatter3(content) {
6894
+ const m = FRONTMATTER_RE.exec(content);
6895
+ if (m === null) return { yaml: void 0, body: content };
6896
+ return { yaml: m[1] ?? "", body: m[2] ?? "" };
6885
6897
  }
6886
6898
  function parseSimpleYaml2(yaml) {
6887
6899
  const out = {};
@@ -6928,15 +6940,76 @@ function parseScalar(s) {
6928
6940
  if (/^-?\d+$/.test(s)) return parseInt(s, 10);
6929
6941
  return s.replace(/^["']|["']$/g, "");
6930
6942
  }
6931
- var McdFrontmatterSchema, FRONTMATTER_RE;
6943
+ var FRONTMATTER_RE;
6944
+ var init_context_yaml_lite = __esm({
6945
+ "src/internal/runtime/context/context-yaml-lite.ts"() {
6946
+ FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
6947
+ }
6948
+ });
6949
+ function parseMdc(content) {
6950
+ const { yaml, body } = splitFrontmatter3(content);
6951
+ if (yaml === void 0) {
6952
+ return { frontmatter: { alwaysApply: true }, body: content };
6953
+ }
6954
+ try {
6955
+ const parsed = parseSimpleYaml2(yaml);
6956
+ const validated = McdFrontmatterSchema.safeParse(parsed);
6957
+ if (!validated.success) return void 0;
6958
+ return { frontmatter: validated.data, body };
6959
+ } catch {
6960
+ return void 0;
6961
+ }
6962
+ }
6963
+ function shouldActivate(fm, touchedFiles) {
6964
+ if (fm.alwaysApply === true) return true;
6965
+ if (fm.globs === void 0 || fm.globs.length === 0) return false;
6966
+ return anyGlobMatches(fm.globs, touchedFiles);
6967
+ }
6968
+ var McdFrontmatterSchema;
6932
6969
  var init_context_mdc_parser = __esm({
6933
6970
  "src/internal/runtime/context/context-mdc-parser.ts"() {
6971
+ init_context_glob();
6972
+ init_context_yaml_lite();
6934
6973
  McdFrontmatterSchema = zod.z.object({
6935
6974
  description: zod.z.string().optional(),
6936
6975
  globs: zod.z.array(zod.z.string()).optional(),
6937
6976
  alwaysApply: zod.z.boolean().optional()
6938
6977
  });
6939
- FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
6978
+ }
6979
+ });
6980
+ function parseRules(content) {
6981
+ const { yaml, body } = splitFrontmatter3(content);
6982
+ if (yaml === void 0) {
6983
+ return { frontmatter: { alwaysApply: true }, body: content };
6984
+ }
6985
+ try {
6986
+ const parsed = parseSimpleYaml2(yaml);
6987
+ const validated = RulesFrontmatterSchema.safeParse(parsed);
6988
+ if (!validated.success) return void 0;
6989
+ return { frontmatter: validated.data, body };
6990
+ } catch {
6991
+ return void 0;
6992
+ }
6993
+ }
6994
+ function shouldActivateRule(fm, inScopePaths) {
6995
+ if (fm.enabled === false) return false;
6996
+ if (fm.alwaysApply === true) return true;
6997
+ const patterns = [...fm.paths ?? [], ...fm.globs ?? []];
6998
+ if (patterns.length === 0) return false;
6999
+ return anyGlobMatches(patterns, inScopePaths);
7000
+ }
7001
+ var RulesFrontmatterSchema;
7002
+ var init_context_rules_frontmatter = __esm({
7003
+ "src/internal/runtime/context/context-rules-frontmatter.ts"() {
7004
+ init_context_glob();
7005
+ init_context_yaml_lite();
7006
+ RulesFrontmatterSchema = zod.z.object({
7007
+ description: zod.z.string().optional(),
7008
+ paths: zod.z.array(zod.z.string()).optional(),
7009
+ globs: zod.z.array(zod.z.string()).optional(),
7010
+ alwaysApply: zod.z.boolean().optional(),
7011
+ enabled: zod.z.boolean().optional()
7012
+ });
6940
7013
  }
6941
7014
  });
6942
7015
  async function runDiscovery(opts) {
@@ -6972,6 +7045,9 @@ async function loadOneSource(spec, path$1, opts, gitRoot) {
6972
7045
  if (spec.parser === "mdc") {
6973
7046
  return loadMdcSource(spec, path$1, id, opts);
6974
7047
  }
7048
+ if (spec.parser === "rules-frontmatter") {
7049
+ return loadRulesSource(spec, path$1, id, opts);
7050
+ }
6975
7051
  if (spec.parser === "frontmatter-zod") {
6976
7052
  return void 0;
6977
7053
  }
@@ -6995,6 +7071,24 @@ async function loadMdcSource(spec, path, id, opts) {
6995
7071
  truncated: false
6996
7072
  };
6997
7073
  }
7074
+ async function loadRulesSource(spec, path, id, opts) {
7075
+ let raw;
7076
+ try {
7077
+ raw = await promises.readFile(path, "utf8");
7078
+ } catch {
7079
+ return void 0;
7080
+ }
7081
+ const parsed = parseRules(raw);
7082
+ if (parsed === void 0) return void 0;
7083
+ if (!shouldActivateRule(parsed.frontmatter, opts.touchedFiles ?? [])) return void 0;
7084
+ return {
7085
+ id,
7086
+ source: path,
7087
+ content: parsed.body,
7088
+ priority: spec.priority,
7089
+ truncated: false
7090
+ };
7091
+ }
6998
7092
  async function loadPlainMarkdownSource(spec, path, id, opts) {
6999
7093
  const loaded = await loadPlainMarkdown(path, { maxBytesPerFile: opts.maxBytesPerFile });
7000
7094
  if (loaded === void 0) return void 0;
@@ -7020,6 +7114,7 @@ var init_context_discovery_runner = __esm({
7020
7114
  init_context_import_resolver();
7021
7115
  init_context_loaders();
7022
7116
  init_context_mdc_parser();
7117
+ init_context_rules_frontmatter();
7023
7118
  }
7024
7119
  });
7025
7120
  var ContextSourceFrontmatterSchema;
@@ -7155,6 +7250,10 @@ function matchesGlob(pattern, path) {
7155
7250
  function tokenizeContent(content) {
7156
7251
  return content.split(/\s+/).filter((token) => token.length > 0);
7157
7252
  }
7253
+ function sameScope(a, b) {
7254
+ if (a.length !== b.length) return false;
7255
+ return a.every((v, i) => v === b[i]);
7256
+ }
7158
7257
  var FileContextManager;
7159
7258
  var init_context_manager = __esm({
7160
7259
  "src/internal/runtime/context/context-manager.ts"() {
@@ -7175,6 +7274,13 @@ var init_context_manager = __esm({
7175
7274
  settings;
7176
7275
  settingSourcesIncludeProject;
7177
7276
  state;
7277
+ /**
7278
+ * The in-scope file set used by the most recent `refresh`. Tracked so
7279
+ * `applyScope` only touches state when the scope actually changes — a
7280
+ * caller that never scopes (the common case) keeps the create-time
7281
+ * snapshot untouched, at zero per-send cost.
7282
+ */
7283
+ lastScope = [];
7178
7284
  async initialize() {
7179
7285
  if (!this.settingSourcesIncludeProject && this.settings.manager !== "file") {
7180
7286
  this.state = { config: { sources: [] }, loadedSources: [] };
@@ -7182,14 +7288,31 @@ var init_context_manager = __esm({
7182
7288
  }
7183
7289
  await this.refresh();
7184
7290
  }
7185
- async refresh() {
7291
+ /**
7292
+ * Re-run discovery for a specific per-send in-scope file set (T3). Path-scoped
7293
+ * rules (`.theokit/rules/*.md`, `.cursor/rules/*.mdc` globs) activate iff a
7294
+ * pattern matches one of `contextPaths`. Idempotent: unchanged scope is a
7295
+ * no-op, and `undefined` scope while never previously scoped never touches
7296
+ * state (preserves the create-time snapshot for non-users).
7297
+ */
7298
+ async applyScope(contextPaths) {
7299
+ const scope = contextPaths ?? [];
7300
+ if (scope.length === 0 && this.lastScope.length === 0) return;
7301
+ if (sameScope(scope, this.lastScope)) return;
7302
+ await this.refresh({ touchedFiles: scope });
7303
+ }
7304
+ async refresh(opts) {
7305
+ const touchedFiles = opts?.touchedFiles ?? [];
7306
+ this.lastScope = [...touchedFiles];
7186
7307
  const config = await loadContextConfig(this.cwd);
7187
7308
  const legacy = await loadSources(config, this.cwd);
7188
7309
  const maxBytesPerFile = this.settings.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
7189
7310
  const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
7190
7311
  const discovered = await runDiscovery({
7191
7312
  cwd: this.cwd,
7192
- maxBytesPerFile});
7313
+ maxBytesPerFile,
7314
+ touchedFiles
7315
+ });
7193
7316
  const legacyAsAggregator = legacy.map((src) => ({
7194
7317
  id: src.name,
7195
7318
  source: src.path,
@@ -7624,15 +7747,19 @@ async function collectChildToolResults(run) {
7624
7747
  ${lines.join("\n")}
7625
7748
  </subagent-tool-results>`;
7626
7749
  }
7627
- async function runChildAgent(spec, input, signal, maxSteps, inherited) {
7628
- const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
7750
+ function buildChildCreateOptions(spec, inherited) {
7629
7751
  const model = spec.model ? { id: spec.model } : inherited?.model;
7630
- const agent = await Agent2.create({
7752
+ return {
7631
7753
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
7632
7754
  ...model !== void 0 ? { model } : {},
7755
+ ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
7633
7756
  systemPrompt: spec.instructions,
7634
7757
  tools: spec.tools ?? []
7635
- });
7758
+ };
7759
+ }
7760
+ async function runChildAgent(spec, input, signal, maxSteps, inherited) {
7761
+ const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
7762
+ const agent = await Agent2.create(buildChildCreateOptions(spec, inherited));
7636
7763
  try {
7637
7764
  const sendOptions = {
7638
7765
  ...signal !== void 0 ? { signal } : {},
@@ -9535,7 +9662,10 @@ async function runAgentLoop(inputs) {
9535
9662
  }
9536
9663
  budget.consume();
9537
9664
  inputs.budgetTracker?.nextIteration?.();
9538
- if (inputs.signal?.aborted === true) break;
9665
+ if (inputs.signal?.aborted === true) {
9666
+ ctx.finalStatus = "cancelled";
9667
+ break;
9668
+ }
9539
9669
  }
9540
9670
  if (lastTurnDecision === "continue" && budget.shouldContinue() === false) {
9541
9671
  ctx.stoppedAtIterationLimit = true;
@@ -9720,15 +9850,15 @@ async function guardAndTransformToolResults(inputs, raw, ctx) {
9720
9850
  }
9721
9851
  async function continueOrTerminate(inputs, ctx, llmOutput) {
9722
9852
  if (llmOutput.errored) return "error";
9723
- if (llmOutput.text.length > 0) {
9724
- await emitAssistantTextStep(inputs, ctx, llmOutput.text);
9853
+ const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
9854
+ const text = llmOutput.text.length > 0 ? await transformLlmOutputText(inputs, llmOutput.text, tCtx) : llmOutput.text;
9855
+ if (text.length > 0) {
9856
+ await emitAssistantTextStep(inputs, ctx, text);
9725
9857
  }
9726
9858
  if (llmOutput.stopReason !== "tool_use" || llmOutput.toolCalls.length === 0) {
9727
9859
  return finishOrReflect(inputs, ctx, llmOutput);
9728
9860
  }
9729
- const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
9730
- const outText = await transformLlmOutputText(inputs, llmOutput.text, tCtx);
9731
- ctx.messages.push(buildAssistantTurn(outText, llmOutput.toolCalls));
9861
+ ctx.messages.push(buildAssistantTurn(text, llmOutput.toolCalls));
9732
9862
  const rawResults = await dispatchTools(
9733
9863
  // SE12 — forward a read-only text projection of the transcript-so-far to tool
9734
9864
  // handlers via `ctx.messages` (consumed by defineSubAgent's messageFilter).
@@ -13052,7 +13182,12 @@ var init_client = __esm({
13052
13182
  code: "mcp_http_error"
13053
13183
  });
13054
13184
  }
13055
- return await response.json();
13185
+ try {
13186
+ return await response.json();
13187
+ } catch (cause) {
13188
+ if (isAbortLike(cause)) throw mcpTimeoutError(this.name, timeoutMs);
13189
+ throw cause;
13190
+ }
13056
13191
  }
13057
13192
  };
13058
13193
  }
@@ -13292,9 +13427,11 @@ function declarativeSubagentTools(agentOptions, parentTools) {
13292
13427
  return subAgentToolsFromDefinitions(agents2, parentTools);
13293
13428
  }
13294
13429
  function bindParentCredentials(tools, agentOptions) {
13430
+ const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
13295
13431
  const credentials = {
13296
13432
  ...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
13297
- ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {}
13433
+ ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
13434
+ ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {}
13298
13435
  };
13299
13436
  for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
13300
13437
  }
@@ -15819,10 +15956,11 @@ var init_local_agent_memory = __esm({
15819
15956
  }
15820
15957
  buildTelemetryRecallArgs(telemetry) {
15821
15958
  const userId = typeof this.options.memoryContext?.userId === "string" ? this.options.memoryContext.userId : void 0;
15959
+ const tenantId = typeof this.options.memoryContext?.tenantId === "string" ? this.options.memoryContext.tenantId : void 0;
15822
15960
  return {
15823
15961
  ...telemetry !== void 0 ? { telemetry } : {},
15824
15962
  ...userId !== void 0 ? { userId } : {},
15825
- namespace: "default",
15963
+ namespace: tenantId ?? "default",
15826
15964
  scope: "session"
15827
15965
  };
15828
15966
  }
@@ -17119,7 +17257,8 @@ async function executeSendLocked(inputs, message, options) {
17119
17257
  userText,
17120
17258
  baseSystemPrompt,
17121
17259
  memoryFacts,
17122
- activeMemorySummary
17260
+ activeMemorySummary,
17261
+ options.contextPaths
17123
17262
  );
17124
17263
  const projectedSystemPrompt = await projectCurrentObjective(
17125
17264
  inputs.storageHandle,
@@ -18007,7 +18146,7 @@ var init_local_agent = __esm({
18007
18146
  runPreHook: (ut) => this.runPreHook(ut),
18008
18147
  // biome-ignore format: G8 budget — callbacks wire to private methods.
18009
18148
  resolveSystemPromptForSend: (ut, o, mf) => this.resolveSystemPrompt(ut, o, mf),
18010
- assembleSystemPromptForSend: (ut, bp, mf, ams) => assembleSystemPromptForSend(this.assemblyInputs(), ut, bp, mf, ams),
18149
+ assembleSystemPromptForSend: (ut, bp, mf, ams, cp) => assembleSystemPromptForSend(this.assemblyInputs(), ut, bp, mf, ams, cp),
18011
18150
  dispatchRun: (msg, o, sp, mf, pm, mt, mp) => this.dispatchRun(msg, o, sp, mf, pm, mt, mp)
18012
18151
  },
18013
18152
  message,
@@ -19707,14 +19846,6 @@ async function llmJudgeScore(options) {
19707
19846
  init_env_policy();
19708
19847
 
19709
19848
  // src/sandbox/types.ts
19710
- var SandboxSecurityError = class extends Error {
19711
- code = "sandbox_security";
19712
- constructor(message) {
19713
- super(message);
19714
- this.name = "SandboxSecurityError";
19715
- }
19716
- };
19717
- var SHELL_METACHARACTERS = /[;&|`$(){}]/;
19718
19849
  var SandboxBackend = class {
19719
19850
  config;
19720
19851
  constructor(config = {}) {
@@ -19757,13 +19888,6 @@ var SandboxBackend = class {
19757
19888
  if (result.exitCode !== 0) return [];
19758
19889
  return result.stdout.trim().split("\n").filter(Boolean);
19759
19890
  }
19760
- validateCommand(command) {
19761
- if (SHELL_METACHARACTERS.test(command)) {
19762
- throw new SandboxSecurityError(
19763
- `Command contains shell metacharacters: ${command.slice(0, 80)}`
19764
- );
19765
- }
19766
- }
19767
19891
  truncateOutput(output) {
19768
19892
  const max = this.config.maxOutputBytes ?? 5 * 1024 * 1024;
19769
19893
  if (Buffer.byteLength(output) > max) {