@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.cjs CHANGED
@@ -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",
@@ -7744,15 +7751,19 @@ async function collectChildToolResults(run) {
7744
7751
  ${lines.join("\n")}
7745
7752
  </subagent-tool-results>`;
7746
7753
  }
7747
- async function runChildAgent(spec, input, signal, maxSteps, inherited) {
7748
- const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
7754
+ function buildChildCreateOptions(spec, inherited) {
7749
7755
  const model = spec.model ? { id: spec.model } : inherited?.model;
7750
- const agent = await Agent2.create({
7756
+ return {
7751
7757
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
7752
7758
  ...model !== void 0 ? { model } : {},
7759
+ ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
7753
7760
  systemPrompt: spec.instructions,
7754
7761
  tools: spec.tools ?? []
7755
- });
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));
7756
7767
  try {
7757
7768
  const sendOptions = {
7758
7769
  ...signal !== void 0 ? { signal } : {},
@@ -9655,7 +9666,10 @@ async function runAgentLoop(inputs) {
9655
9666
  }
9656
9667
  budget.consume();
9657
9668
  inputs.budgetTracker?.nextIteration?.();
9658
- if (inputs.signal?.aborted === true) break;
9669
+ if (inputs.signal?.aborted === true) {
9670
+ ctx.finalStatus = "cancelled";
9671
+ break;
9672
+ }
9659
9673
  }
9660
9674
  if (lastTurnDecision === "continue" && budget.shouldContinue() === false) {
9661
9675
  ctx.stoppedAtIterationLimit = true;
@@ -9840,15 +9854,15 @@ async function guardAndTransformToolResults(inputs, raw, ctx) {
9840
9854
  }
9841
9855
  async function continueOrTerminate(inputs, ctx, llmOutput) {
9842
9856
  if (llmOutput.errored) return "error";
9843
- if (llmOutput.text.length > 0) {
9844
- 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);
9845
9861
  }
9846
9862
  if (llmOutput.stopReason !== "tool_use" || llmOutput.toolCalls.length === 0) {
9847
9863
  return finishOrReflect(inputs, ctx, llmOutput);
9848
9864
  }
9849
- const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
9850
- const outText = await transformLlmOutputText(inputs, llmOutput.text, tCtx);
9851
- ctx.messages.push(buildAssistantTurn(outText, llmOutput.toolCalls));
9865
+ ctx.messages.push(buildAssistantTurn(text, llmOutput.toolCalls));
9852
9866
  const rawResults = await dispatchTools(
9853
9867
  // SE12 — forward a read-only text projection of the transcript-so-far to tool
9854
9868
  // handlers via `ctx.messages` (consumed by defineSubAgent's messageFilter).
@@ -13172,7 +13186,12 @@ var init_client = __esm({
13172
13186
  code: "mcp_http_error"
13173
13187
  });
13174
13188
  }
13175
- 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
+ }
13176
13195
  }
13177
13196
  };
13178
13197
  }
@@ -13412,9 +13431,11 @@ function declarativeSubagentTools(agentOptions, parentTools) {
13412
13431
  return subAgentToolsFromDefinitions(agents2, parentTools);
13413
13432
  }
13414
13433
  function bindParentCredentials(tools, agentOptions) {
13434
+ const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
13415
13435
  const credentials = {
13416
13436
  ...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
13417
- ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {}
13437
+ ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
13438
+ ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {}
13418
13439
  };
13419
13440
  for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
13420
13441
  }
@@ -15939,10 +15960,11 @@ var init_local_agent_memory = __esm({
15939
15960
  }
15940
15961
  buildTelemetryRecallArgs(telemetry) {
15941
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;
15942
15964
  return {
15943
15965
  ...telemetry !== void 0 ? { telemetry } : {},
15944
15966
  ...userId !== void 0 ? { userId } : {},
15945
- namespace: "default",
15967
+ namespace: tenantId ?? "default",
15946
15968
  scope: "session"
15947
15969
  };
15948
15970
  }