@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,6 +1,6 @@
1
1
  import * as zod from 'zod';
2
2
  import { ZodType } from 'zod';
3
- import { C as CustomTool, M as ModelSelection, a7 as SDKUserMessage, a9 as SendOptions, b as Run, G as GenerateOptions, k as GenerateRunResult, V as RunToCompletionOptions, W as RunToCompletionResult, S as SDKMessage, ag as StreamToCompletionResult, a as McpServerConfig, P as Processor, r as MessageOrigin } from './run-CLXKMRgq.cjs';
3
+ import { C as CustomTool, M as ModelSelection, a7 as SDKUserMessage, a9 as SendOptions, b as Run, G as GenerateOptions, k as GenerateRunResult, V as RunToCompletionOptions, W as RunToCompletionResult, S as SDKMessage, ag as StreamToCompletionResult, a as McpServerConfig, P as Processor, r as MessageOrigin } from './run-CrHz9BAP.cjs';
4
4
 
5
5
  /**
6
6
  * Fork primitive public type contracts (T1.2, ADRs D110-D114).
@@ -1,6 +1,6 @@
1
1
  import * as zod from 'zod';
2
2
  import { ZodType } from 'zod';
3
- import { C as CustomTool, M as ModelSelection, a7 as SDKUserMessage, a9 as SendOptions, b as Run, G as GenerateOptions, k as GenerateRunResult, V as RunToCompletionOptions, W as RunToCompletionResult, S as SDKMessage, ag as StreamToCompletionResult, a as McpServerConfig, P as Processor, r as MessageOrigin } from './run-CLXKMRgq.js';
3
+ import { C as CustomTool, M as ModelSelection, a7 as SDKUserMessage, a9 as SendOptions, b as Run, G as GenerateOptions, k as GenerateRunResult, V as RunToCompletionOptions, W as RunToCompletionResult, S as SDKMessage, ag as StreamToCompletionResult, a as McpServerConfig, P as Processor, r as MessageOrigin } from './run-CrHz9BAP.js';
4
4
 
5
5
  /**
6
6
  * Fork primitive public type contracts (T1.2, ADRs D110-D114).
package/dist/cron.cjs CHANGED
@@ -966,10 +966,10 @@ function buildToolPrompt(prompt) {
966
966
  Respond by calling the \`output\` tool with the structured answer that matches the schema.`;
967
967
  }
968
968
  function setupStructuredOutput(schema, maxRetries) {
969
- const z7 = requireZod();
969
+ const z8 = requireZod();
970
970
  const jsonSchema = toJsonSchema(schema, { unrepresentable: "any" });
971
971
  return {
972
- z: z7,
972
+ z: z8,
973
973
  jsonSchema,
974
974
  maxRetries: maxRetries ?? 1,
975
975
  initialUsage: { inputTokens: 0, outputTokens: 0 }
@@ -4747,7 +4747,14 @@ var init_env_policy = __esm({
4747
4747
  /[_-]PWD/i,
4748
4748
  /CREDENTIAL/i,
4749
4749
  /PRIVATE/i,
4750
- /_AUTH/i
4750
+ /_AUTH/i,
4751
+ // #54-a — value-embedded-secret conventions (no generic `*_URL` — see keep-list test).
4752
+ /DSN/i,
4753
+ /WEBHOOK/i,
4754
+ /COOKIE/i,
4755
+ /CONNECTION[_-]?STRING/i,
4756
+ // Known DB / message-broker connection-string vars (carry `user:pass@`).
4757
+ /(?:^|[_-])(?:DATABASE|DB|REDIS|MONGO(?:DB)?|POSTGRES(?:QL)?|MYSQL|MARIADB|AMQP|RABBITMQ|CLICKHOUSE|ELASTIC(?:SEARCH)?|CASSANDRA|COUCHDB|MEMCACHED|NATS|KAFKA)[_-]?(?:URL|URI|DSN|CONNECTION)/i
4751
4758
  ];
4752
4759
  CORE_VARS = [
4753
4760
  "PATH",
@@ -6045,7 +6052,7 @@ async function buildSystemPromptContext(inputs, userText, memoryFacts, manager =
6045
6052
  memory: memoryFacts.map((fact) => ({ text: fact.text }))
6046
6053
  };
6047
6054
  }
6048
- async function buildAssemblyContext(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary) {
6055
+ async function buildAssemblyContext(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary, contextPaths) {
6049
6056
  const resolved = await resolveSendSkills(inputs, userText, memoryFacts);
6050
6057
  const baseCtx = await buildSystemPromptContext(inputs, userText, memoryFacts, resolved.manager);
6051
6058
  const assemblyCtx = {
@@ -6058,19 +6065,21 @@ async function buildAssemblyContext(inputs, userText, baseSystemPrompt, memoryFa
6058
6065
  assemblyCtx.activeMemorySummary = activeMemorySummary;
6059
6066
  }
6060
6067
  if (inputs.context !== void 0) {
6068
+ await inputs.context.applyScope(contextPaths);
6061
6069
  const internal = inputs.context.internalAssemblySnapshot();
6062
6070
  assemblyCtx.contextSnapshot = { sources: internal.sources };
6063
6071
  if (internal.maxTokens !== void 0) assemblyCtx.contextMaxTokens = internal.maxTokens;
6064
6072
  }
6065
6073
  return assemblyCtx;
6066
6074
  }
6067
- async function assembleSystemPromptForSend(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary) {
6075
+ async function assembleSystemPromptForSend(inputs, userText, baseSystemPrompt, memoryFacts, activeMemorySummary, contextPaths) {
6068
6076
  const ctx = await buildAssemblyContext(
6069
6077
  inputs,
6070
6078
  userText,
6071
6079
  baseSystemPrompt,
6072
6080
  memoryFacts,
6073
- activeMemorySummary
6081
+ activeMemorySummary,
6082
+ contextPaths
6074
6083
  );
6075
6084
  return inputs.systemPromptPipeline.assemble(ctx);
6076
6085
  }
@@ -6777,6 +6786,14 @@ var init_context_discovery = __esm({
6777
6786
  followImports: false,
6778
6787
  priority: 40
6779
6788
  },
6789
+ {
6790
+ id: "theokit-rules",
6791
+ pattern: ".theokit/rules/*.md",
6792
+ scope: "globbed",
6793
+ parser: "rules-frontmatter",
6794
+ followImports: false,
6795
+ priority: 45
6796
+ },
6780
6797
  {
6781
6798
  id: "theokit-context",
6782
6799
  pattern: ".theokit/context/*.md",
@@ -6860,32 +6877,27 @@ var init_context_import_resolver = __esm({
6860
6877
  MAX_HOPS = 5;
6861
6878
  }
6862
6879
  });
6863
- function parseMdc(content) {
6864
- const m = FRONTMATTER_RE.exec(content);
6865
- if (m === null) {
6866
- return { frontmatter: { alwaysApply: true }, body: content };
6867
- }
6868
- const yamlBody = m[1] ?? "";
6869
- const body = m[2] ?? "";
6870
- try {
6871
- const parsed = parseSimpleYaml2(yamlBody);
6872
- const validated = McdFrontmatterSchema.safeParse(parsed);
6873
- if (!validated.success) return void 0;
6874
- return { frontmatter: validated.data, body };
6875
- } catch {
6876
- return void 0;
6877
- }
6880
+
6881
+ // src/internal/runtime/context/context-glob.ts
6882
+ function globToRegex(glob) {
6883
+ const compiled = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*\//g, "::GLOBSTAR_SLASH::").replace(/\*\*/g, "::GLOBSTAR::").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(/::GLOBSTAR_SLASH::/g, "(?:.*/)?").replace(/::GLOBSTAR::/g, ".*");
6884
+ return new RegExp(`^${compiled}$`);
6878
6885
  }
6879
- function shouldActivate(fm, touchedFiles) {
6880
- if (fm.alwaysApply === true) return true;
6881
- if (fm.globs === void 0 || fm.globs.length === 0) return false;
6882
- if (touchedFiles.length === 0) return false;
6883
- const globRes = fm.globs.map(globToRegex);
6884
- return touchedFiles.some((file) => globRes.some((re) => re.test(file)));
6886
+ function anyGlobMatches(patterns, paths) {
6887
+ if (patterns.length === 0 || paths.length === 0) return false;
6888
+ const res = patterns.map(globToRegex);
6889
+ return paths.some((p) => res.some((re) => re.test(p)));
6885
6890
  }
6886
- function globToRegex(glob) {
6887
- const escaped = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "::DOUBLESTAR::").replace(/\*/g, "[^/]*").replace(/::DOUBLESTAR::/g, ".*").replace(/\?/g, ".");
6888
- return new RegExp(`^${escaped}$`);
6891
+ var init_context_glob = __esm({
6892
+ "src/internal/runtime/context/context-glob.ts"() {
6893
+ }
6894
+ });
6895
+
6896
+ // src/internal/runtime/context/context-yaml-lite.ts
6897
+ function splitFrontmatter3(content) {
6898
+ const m = FRONTMATTER_RE.exec(content);
6899
+ if (m === null) return { yaml: void 0, body: content };
6900
+ return { yaml: m[1] ?? "", body: m[2] ?? "" };
6889
6901
  }
6890
6902
  function parseSimpleYaml2(yaml) {
6891
6903
  const out = {};
@@ -6932,15 +6944,76 @@ function parseScalar(s) {
6932
6944
  if (/^-?\d+$/.test(s)) return parseInt(s, 10);
6933
6945
  return s.replace(/^["']|["']$/g, "");
6934
6946
  }
6935
- var McdFrontmatterSchema, FRONTMATTER_RE;
6947
+ var FRONTMATTER_RE;
6948
+ var init_context_yaml_lite = __esm({
6949
+ "src/internal/runtime/context/context-yaml-lite.ts"() {
6950
+ FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
6951
+ }
6952
+ });
6953
+ function parseMdc(content) {
6954
+ const { yaml, body } = splitFrontmatter3(content);
6955
+ if (yaml === void 0) {
6956
+ return { frontmatter: { alwaysApply: true }, body: content };
6957
+ }
6958
+ try {
6959
+ const parsed = parseSimpleYaml2(yaml);
6960
+ const validated = McdFrontmatterSchema.safeParse(parsed);
6961
+ if (!validated.success) return void 0;
6962
+ return { frontmatter: validated.data, body };
6963
+ } catch {
6964
+ return void 0;
6965
+ }
6966
+ }
6967
+ function shouldActivate(fm, touchedFiles) {
6968
+ if (fm.alwaysApply === true) return true;
6969
+ if (fm.globs === void 0 || fm.globs.length === 0) return false;
6970
+ return anyGlobMatches(fm.globs, touchedFiles);
6971
+ }
6972
+ var McdFrontmatterSchema;
6936
6973
  var init_context_mdc_parser = __esm({
6937
6974
  "src/internal/runtime/context/context-mdc-parser.ts"() {
6975
+ init_context_glob();
6976
+ init_context_yaml_lite();
6938
6977
  McdFrontmatterSchema = zod.z.object({
6939
6978
  description: zod.z.string().optional(),
6940
6979
  globs: zod.z.array(zod.z.string()).optional(),
6941
6980
  alwaysApply: zod.z.boolean().optional()
6942
6981
  });
6943
- FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/;
6982
+ }
6983
+ });
6984
+ function parseRules(content) {
6985
+ const { yaml, body } = splitFrontmatter3(content);
6986
+ if (yaml === void 0) {
6987
+ return { frontmatter: { alwaysApply: true }, body: content };
6988
+ }
6989
+ try {
6990
+ const parsed = parseSimpleYaml2(yaml);
6991
+ const validated = RulesFrontmatterSchema.safeParse(parsed);
6992
+ if (!validated.success) return void 0;
6993
+ return { frontmatter: validated.data, body };
6994
+ } catch {
6995
+ return void 0;
6996
+ }
6997
+ }
6998
+ function shouldActivateRule(fm, inScopePaths) {
6999
+ if (fm.enabled === false) return false;
7000
+ if (fm.alwaysApply === true) return true;
7001
+ const patterns = [...fm.paths ?? [], ...fm.globs ?? []];
7002
+ if (patterns.length === 0) return false;
7003
+ return anyGlobMatches(patterns, inScopePaths);
7004
+ }
7005
+ var RulesFrontmatterSchema;
7006
+ var init_context_rules_frontmatter = __esm({
7007
+ "src/internal/runtime/context/context-rules-frontmatter.ts"() {
7008
+ init_context_glob();
7009
+ init_context_yaml_lite();
7010
+ RulesFrontmatterSchema = zod.z.object({
7011
+ description: zod.z.string().optional(),
7012
+ paths: zod.z.array(zod.z.string()).optional(),
7013
+ globs: zod.z.array(zod.z.string()).optional(),
7014
+ alwaysApply: zod.z.boolean().optional(),
7015
+ enabled: zod.z.boolean().optional()
7016
+ });
6944
7017
  }
6945
7018
  });
6946
7019
  async function runDiscovery(opts) {
@@ -6976,6 +7049,9 @@ async function loadOneSource(spec, path$1, opts, gitRoot) {
6976
7049
  if (spec.parser === "mdc") {
6977
7050
  return loadMdcSource(spec, path$1, id, opts);
6978
7051
  }
7052
+ if (spec.parser === "rules-frontmatter") {
7053
+ return loadRulesSource(spec, path$1, id, opts);
7054
+ }
6979
7055
  if (spec.parser === "frontmatter-zod") {
6980
7056
  return void 0;
6981
7057
  }
@@ -6999,6 +7075,24 @@ async function loadMdcSource(spec, path, id, opts) {
6999
7075
  truncated: false
7000
7076
  };
7001
7077
  }
7078
+ async function loadRulesSource(spec, path, id, opts) {
7079
+ let raw;
7080
+ try {
7081
+ raw = await promises.readFile(path, "utf8");
7082
+ } catch {
7083
+ return void 0;
7084
+ }
7085
+ const parsed = parseRules(raw);
7086
+ if (parsed === void 0) return void 0;
7087
+ if (!shouldActivateRule(parsed.frontmatter, opts.touchedFiles ?? [])) return void 0;
7088
+ return {
7089
+ id,
7090
+ source: path,
7091
+ content: parsed.body,
7092
+ priority: spec.priority,
7093
+ truncated: false
7094
+ };
7095
+ }
7002
7096
  async function loadPlainMarkdownSource(spec, path, id, opts) {
7003
7097
  const loaded = await loadPlainMarkdown(path, { maxBytesPerFile: opts.maxBytesPerFile });
7004
7098
  if (loaded === void 0) return void 0;
@@ -7024,6 +7118,7 @@ var init_context_discovery_runner = __esm({
7024
7118
  init_context_import_resolver();
7025
7119
  init_context_loaders();
7026
7120
  init_context_mdc_parser();
7121
+ init_context_rules_frontmatter();
7027
7122
  }
7028
7123
  });
7029
7124
  var ContextSourceFrontmatterSchema;
@@ -7159,6 +7254,10 @@ function matchesGlob(pattern, path) {
7159
7254
  function tokenizeContent(content) {
7160
7255
  return content.split(/\s+/).filter((token) => token.length > 0);
7161
7256
  }
7257
+ function sameScope(a, b) {
7258
+ if (a.length !== b.length) return false;
7259
+ return a.every((v, i) => v === b[i]);
7260
+ }
7162
7261
  var FileContextManager;
7163
7262
  var init_context_manager = __esm({
7164
7263
  "src/internal/runtime/context/context-manager.ts"() {
@@ -7179,6 +7278,13 @@ var init_context_manager = __esm({
7179
7278
  settings;
7180
7279
  settingSourcesIncludeProject;
7181
7280
  state;
7281
+ /**
7282
+ * The in-scope file set used by the most recent `refresh`. Tracked so
7283
+ * `applyScope` only touches state when the scope actually changes — a
7284
+ * caller that never scopes (the common case) keeps the create-time
7285
+ * snapshot untouched, at zero per-send cost.
7286
+ */
7287
+ lastScope = [];
7182
7288
  async initialize() {
7183
7289
  if (!this.settingSourcesIncludeProject && this.settings.manager !== "file") {
7184
7290
  this.state = { config: { sources: [] }, loadedSources: [] };
@@ -7186,14 +7292,31 @@ var init_context_manager = __esm({
7186
7292
  }
7187
7293
  await this.refresh();
7188
7294
  }
7189
- async refresh() {
7295
+ /**
7296
+ * Re-run discovery for a specific per-send in-scope file set (T3). Path-scoped
7297
+ * rules (`.theokit/rules/*.md`, `.cursor/rules/*.mdc` globs) activate iff a
7298
+ * pattern matches one of `contextPaths`. Idempotent: unchanged scope is a
7299
+ * no-op, and `undefined` scope while never previously scoped never touches
7300
+ * state (preserves the create-time snapshot for non-users).
7301
+ */
7302
+ async applyScope(contextPaths) {
7303
+ const scope = contextPaths ?? [];
7304
+ if (scope.length === 0 && this.lastScope.length === 0) return;
7305
+ if (sameScope(scope, this.lastScope)) return;
7306
+ await this.refresh({ touchedFiles: scope });
7307
+ }
7308
+ async refresh(opts) {
7309
+ const touchedFiles = opts?.touchedFiles ?? [];
7310
+ this.lastScope = [...touchedFiles];
7190
7311
  const config = await loadContextConfig(this.cwd);
7191
7312
  const legacy = await loadSources(config, this.cwd);
7192
7313
  const maxBytesPerFile = this.settings.maxBytesPerFile ?? DEFAULT_MAX_BYTES_PER_FILE;
7193
7314
  const maxBytesTotal = this.settings.maxBytesTotal ?? DEFAULT_MAX_BYTES_TOTAL;
7194
7315
  const discovered = await runDiscovery({
7195
7316
  cwd: this.cwd,
7196
- maxBytesPerFile});
7317
+ maxBytesPerFile,
7318
+ touchedFiles
7319
+ });
7197
7320
  const legacyAsAggregator = legacy.map((src) => ({
7198
7321
  id: src.name,
7199
7322
  source: src.path,
@@ -7628,15 +7751,19 @@ async function collectChildToolResults(run) {
7628
7751
  ${lines.join("\n")}
7629
7752
  </subagent-tool-results>`;
7630
7753
  }
7631
- async function runChildAgent(spec, input, signal, maxSteps, inherited) {
7632
- const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
7754
+ function buildChildCreateOptions(spec, inherited) {
7633
7755
  const model = spec.model ? { id: spec.model } : inherited?.model;
7634
- const agent = await Agent2.create({
7756
+ return {
7635
7757
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
7636
7758
  ...model !== void 0 ? { model } : {},
7759
+ ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
7637
7760
  systemPrompt: spec.instructions,
7638
7761
  tools: spec.tools ?? []
7639
- });
7762
+ };
7763
+ }
7764
+ async function runChildAgent(spec, input, signal, maxSteps, inherited) {
7765
+ const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
7766
+ const agent = await Agent2.create(buildChildCreateOptions(spec, inherited));
7640
7767
  try {
7641
7768
  const sendOptions = {
7642
7769
  ...signal !== void 0 ? { signal } : {},
@@ -9539,7 +9666,10 @@ async function runAgentLoop(inputs) {
9539
9666
  }
9540
9667
  budget.consume();
9541
9668
  inputs.budgetTracker?.nextIteration?.();
9542
- if (inputs.signal?.aborted === true) break;
9669
+ if (inputs.signal?.aborted === true) {
9670
+ ctx.finalStatus = "cancelled";
9671
+ break;
9672
+ }
9543
9673
  }
9544
9674
  if (lastTurnDecision === "continue" && budget.shouldContinue() === false) {
9545
9675
  ctx.stoppedAtIterationLimit = true;
@@ -9724,15 +9854,15 @@ async function guardAndTransformToolResults(inputs, raw, ctx) {
9724
9854
  }
9725
9855
  async function continueOrTerminate(inputs, ctx, llmOutput) {
9726
9856
  if (llmOutput.errored) return "error";
9727
- if (llmOutput.text.length > 0) {
9728
- await emitAssistantTextStep(inputs, ctx, llmOutput.text);
9857
+ const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
9858
+ const text = llmOutput.text.length > 0 ? await transformLlmOutputText(inputs, llmOutput.text, tCtx) : llmOutput.text;
9859
+ if (text.length > 0) {
9860
+ await emitAssistantTextStep(inputs, ctx, text);
9729
9861
  }
9730
9862
  if (llmOutput.stopReason !== "tool_use" || llmOutput.toolCalls.length === 0) {
9731
9863
  return finishOrReflect(inputs, ctx, llmOutput);
9732
9864
  }
9733
- const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
9734
- const outText = await transformLlmOutputText(inputs, llmOutput.text, tCtx);
9735
- ctx.messages.push(buildAssistantTurn(outText, llmOutput.toolCalls));
9865
+ ctx.messages.push(buildAssistantTurn(text, llmOutput.toolCalls));
9736
9866
  const rawResults = await dispatchTools(
9737
9867
  // SE12 — forward a read-only text projection of the transcript-so-far to tool
9738
9868
  // handlers via `ctx.messages` (consumed by defineSubAgent's messageFilter).
@@ -13056,7 +13186,12 @@ var init_client = __esm({
13056
13186
  code: "mcp_http_error"
13057
13187
  });
13058
13188
  }
13059
- return await response.json();
13189
+ try {
13190
+ return await response.json();
13191
+ } catch (cause) {
13192
+ if (isAbortLike(cause)) throw mcpTimeoutError(this.name, timeoutMs);
13193
+ throw cause;
13194
+ }
13060
13195
  }
13061
13196
  };
13062
13197
  }
@@ -13296,9 +13431,11 @@ function declarativeSubagentTools(agentOptions, parentTools) {
13296
13431
  return subAgentToolsFromDefinitions(agents2, parentTools);
13297
13432
  }
13298
13433
  function bindParentCredentials(tools, agentOptions) {
13434
+ const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
13299
13435
  const credentials = {
13300
13436
  ...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
13301
- ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {}
13437
+ ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
13438
+ ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {}
13302
13439
  };
13303
13440
  for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
13304
13441
  }
@@ -15823,10 +15960,11 @@ var init_local_agent_memory = __esm({
15823
15960
  }
15824
15961
  buildTelemetryRecallArgs(telemetry) {
15825
15962
  const userId = typeof this.options.memoryContext?.userId === "string" ? this.options.memoryContext.userId : void 0;
15963
+ const tenantId = typeof this.options.memoryContext?.tenantId === "string" ? this.options.memoryContext.tenantId : void 0;
15826
15964
  return {
15827
15965
  ...telemetry !== void 0 ? { telemetry } : {},
15828
15966
  ...userId !== void 0 ? { userId } : {},
15829
- namespace: "default",
15967
+ namespace: tenantId ?? "default",
15830
15968
  scope: "session"
15831
15969
  };
15832
15970
  }
@@ -17123,7 +17261,8 @@ async function executeSendLocked(inputs, message, options) {
17123
17261
  userText,
17124
17262
  baseSystemPrompt,
17125
17263
  memoryFacts,
17126
- activeMemorySummary
17264
+ activeMemorySummary,
17265
+ options.contextPaths
17127
17266
  );
17128
17267
  const projectedSystemPrompt = await projectCurrentObjective(
17129
17268
  inputs.storageHandle,
@@ -18011,7 +18150,7 @@ var init_local_agent = __esm({
18011
18150
  runPreHook: (ut) => this.runPreHook(ut),
18012
18151
  // biome-ignore format: G8 budget — callbacks wire to private methods.
18013
18152
  resolveSystemPromptForSend: (ut, o, mf) => this.resolveSystemPrompt(ut, o, mf),
18014
- assembleSystemPromptForSend: (ut, bp, mf, ams) => assembleSystemPromptForSend(this.assemblyInputs(), ut, bp, mf, ams),
18153
+ assembleSystemPromptForSend: (ut, bp, mf, ams, cp) => assembleSystemPromptForSend(this.assemblyInputs(), ut, bp, mf, ams, cp),
18015
18154
  dispatchRun: (msg, o, sp, mf, pm, mt, mp) => this.dispatchRun(msg, o, sp, mf, pm, mt, mp)
18016
18155
  },
18017
18156
  message,