@theokit/sdk 3.2.0 → 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.
package/dist/cron.js CHANGED
@@ -4744,7 +4744,14 @@ var init_env_policy = __esm({
4744
4744
  /[_-]PWD/i,
4745
4745
  /CREDENTIAL/i,
4746
4746
  /PRIVATE/i,
4747
- /_AUTH/i
4747
+ /_AUTH/i,
4748
+ // #54-a — value-embedded-secret conventions (no generic `*_URL` — see keep-list test).
4749
+ /DSN/i,
4750
+ /WEBHOOK/i,
4751
+ /COOKIE/i,
4752
+ /CONNECTION[_-]?STRING/i,
4753
+ // Known DB / message-broker connection-string vars (carry `user:pass@`).
4754
+ /(?:^|[_-])(?:DATABASE|DB|REDIS|MONGO(?:DB)?|POSTGRES(?:QL)?|MYSQL|MARIADB|AMQP|RABBITMQ|CLICKHOUSE|ELASTIC(?:SEARCH)?|CASSANDRA|COUCHDB|MEMCACHED|NATS|KAFKA)[_-]?(?:URL|URI|DSN|CONNECTION)/i
4748
4755
  ];
4749
4756
  CORE_VARS = [
4750
4757
  "PATH",
@@ -7741,15 +7748,19 @@ async function collectChildToolResults(run) {
7741
7748
  ${lines.join("\n")}
7742
7749
  </subagent-tool-results>`;
7743
7750
  }
7744
- async function runChildAgent(spec, input, signal, maxSteps, inherited) {
7745
- const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
7751
+ function buildChildCreateOptions(spec, inherited) {
7746
7752
  const model = spec.model ? { id: spec.model } : inherited?.model;
7747
- const agent = await Agent2.create({
7753
+ return {
7748
7754
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
7749
7755
  ...model !== void 0 ? { model } : {},
7756
+ ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
7750
7757
  systemPrompt: spec.instructions,
7751
7758
  tools: spec.tools ?? []
7752
- });
7759
+ };
7760
+ }
7761
+ async function runChildAgent(spec, input, signal, maxSteps, inherited) {
7762
+ const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
7763
+ const agent = await Agent2.create(buildChildCreateOptions(spec, inherited));
7753
7764
  try {
7754
7765
  const sendOptions = {
7755
7766
  ...signal !== void 0 ? { signal } : {},
@@ -9652,7 +9663,10 @@ async function runAgentLoop(inputs) {
9652
9663
  }
9653
9664
  budget.consume();
9654
9665
  inputs.budgetTracker?.nextIteration?.();
9655
- if (inputs.signal?.aborted === true) break;
9666
+ if (inputs.signal?.aborted === true) {
9667
+ ctx.finalStatus = "cancelled";
9668
+ break;
9669
+ }
9656
9670
  }
9657
9671
  if (lastTurnDecision === "continue" && budget.shouldContinue() === false) {
9658
9672
  ctx.stoppedAtIterationLimit = true;
@@ -9837,15 +9851,15 @@ async function guardAndTransformToolResults(inputs, raw, ctx) {
9837
9851
  }
9838
9852
  async function continueOrTerminate(inputs, ctx, llmOutput) {
9839
9853
  if (llmOutput.errored) return "error";
9840
- if (llmOutput.text.length > 0) {
9841
- await emitAssistantTextStep(inputs, ctx, llmOutput.text);
9854
+ const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
9855
+ const text = llmOutput.text.length > 0 ? await transformLlmOutputText(inputs, llmOutput.text, tCtx) : llmOutput.text;
9856
+ if (text.length > 0) {
9857
+ await emitAssistantTextStep(inputs, ctx, text);
9842
9858
  }
9843
9859
  if (llmOutput.stopReason !== "tool_use" || llmOutput.toolCalls.length === 0) {
9844
9860
  return finishOrReflect(inputs, ctx, llmOutput);
9845
9861
  }
9846
- const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
9847
- const outText = await transformLlmOutputText(inputs, llmOutput.text, tCtx);
9848
- ctx.messages.push(buildAssistantTurn(outText, llmOutput.toolCalls));
9862
+ ctx.messages.push(buildAssistantTurn(text, llmOutput.toolCalls));
9849
9863
  const rawResults = await dispatchTools(
9850
9864
  // SE12 — forward a read-only text projection of the transcript-so-far to tool
9851
9865
  // handlers via `ctx.messages` (consumed by defineSubAgent's messageFilter).
@@ -13169,7 +13183,12 @@ var init_client = __esm({
13169
13183
  code: "mcp_http_error"
13170
13184
  });
13171
13185
  }
13172
- return await response.json();
13186
+ try {
13187
+ return await response.json();
13188
+ } catch (cause) {
13189
+ if (isAbortLike(cause)) throw mcpTimeoutError(this.name, timeoutMs);
13190
+ throw cause;
13191
+ }
13173
13192
  }
13174
13193
  };
13175
13194
  }
@@ -13409,9 +13428,11 @@ function declarativeSubagentTools(agentOptions, parentTools) {
13409
13428
  return subAgentToolsFromDefinitions(agents2, parentTools);
13410
13429
  }
13411
13430
  function bindParentCredentials(tools, agentOptions) {
13431
+ const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
13412
13432
  const credentials = {
13413
13433
  ...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
13414
- ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {}
13434
+ ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
13435
+ ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {}
13415
13436
  };
13416
13437
  for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
13417
13438
  }
@@ -15936,10 +15957,11 @@ var init_local_agent_memory = __esm({
15936
15957
  }
15937
15958
  buildTelemetryRecallArgs(telemetry) {
15938
15959
  const userId = typeof this.options.memoryContext?.userId === "string" ? this.options.memoryContext.userId : void 0;
15960
+ const tenantId = typeof this.options.memoryContext?.tenantId === "string" ? this.options.memoryContext.tenantId : void 0;
15939
15961
  return {
15940
15962
  ...telemetry !== void 0 ? { telemetry } : {},
15941
15963
  ...userId !== void 0 ? { userId } : {},
15942
- namespace: "default",
15964
+ namespace: tenantId ?? "default",
15943
15965
  scope: "session"
15944
15966
  };
15945
15967
  }