@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/eval.cjs CHANGED
@@ -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",
@@ -7740,15 +7747,19 @@ async function collectChildToolResults(run) {
7740
7747
  ${lines.join("\n")}
7741
7748
  </subagent-tool-results>`;
7742
7749
  }
7743
- async function runChildAgent(spec, input, signal, maxSteps, inherited) {
7744
- const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
7750
+ function buildChildCreateOptions(spec, inherited) {
7745
7751
  const model = spec.model ? { id: spec.model } : inherited?.model;
7746
- const agent = await Agent2.create({
7752
+ return {
7747
7753
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
7748
7754
  ...model !== void 0 ? { model } : {},
7755
+ ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
7749
7756
  systemPrompt: spec.instructions,
7750
7757
  tools: spec.tools ?? []
7751
- });
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));
7752
7763
  try {
7753
7764
  const sendOptions = {
7754
7765
  ...signal !== void 0 ? { signal } : {},
@@ -9651,7 +9662,10 @@ async function runAgentLoop(inputs) {
9651
9662
  }
9652
9663
  budget.consume();
9653
9664
  inputs.budgetTracker?.nextIteration?.();
9654
- if (inputs.signal?.aborted === true) break;
9665
+ if (inputs.signal?.aborted === true) {
9666
+ ctx.finalStatus = "cancelled";
9667
+ break;
9668
+ }
9655
9669
  }
9656
9670
  if (lastTurnDecision === "continue" && budget.shouldContinue() === false) {
9657
9671
  ctx.stoppedAtIterationLimit = true;
@@ -9836,15 +9850,15 @@ async function guardAndTransformToolResults(inputs, raw, ctx) {
9836
9850
  }
9837
9851
  async function continueOrTerminate(inputs, ctx, llmOutput) {
9838
9852
  if (llmOutput.errored) return "error";
9839
- if (llmOutput.text.length > 0) {
9840
- 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);
9841
9857
  }
9842
9858
  if (llmOutput.stopReason !== "tool_use" || llmOutput.toolCalls.length === 0) {
9843
9859
  return finishOrReflect(inputs, ctx, llmOutput);
9844
9860
  }
9845
- const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
9846
- const outText = await transformLlmOutputText(inputs, llmOutput.text, tCtx);
9847
- ctx.messages.push(buildAssistantTurn(outText, llmOutput.toolCalls));
9861
+ ctx.messages.push(buildAssistantTurn(text, llmOutput.toolCalls));
9848
9862
  const rawResults = await dispatchTools(
9849
9863
  // SE12 — forward a read-only text projection of the transcript-so-far to tool
9850
9864
  // handlers via `ctx.messages` (consumed by defineSubAgent's messageFilter).
@@ -13168,7 +13182,12 @@ var init_client = __esm({
13168
13182
  code: "mcp_http_error"
13169
13183
  });
13170
13184
  }
13171
- 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
+ }
13172
13191
  }
13173
13192
  };
13174
13193
  }
@@ -13408,9 +13427,11 @@ function declarativeSubagentTools(agentOptions, parentTools) {
13408
13427
  return subAgentToolsFromDefinitions(agents2, parentTools);
13409
13428
  }
13410
13429
  function bindParentCredentials(tools, agentOptions) {
13430
+ const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
13411
13431
  const credentials = {
13412
13432
  ...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
13413
- ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {}
13433
+ ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
13434
+ ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {}
13414
13435
  };
13415
13436
  for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
13416
13437
  }
@@ -15935,10 +15956,11 @@ var init_local_agent_memory = __esm({
15935
15956
  }
15936
15957
  buildTelemetryRecallArgs(telemetry) {
15937
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;
15938
15960
  return {
15939
15961
  ...telemetry !== void 0 ? { telemetry } : {},
15940
15962
  ...userId !== void 0 ? { userId } : {},
15941
- namespace: "default",
15963
+ namespace: tenantId ?? "default",
15942
15964
  scope: "session"
15943
15965
  };
15944
15966
  }
@@ -19824,14 +19846,6 @@ async function llmJudgeScore(options) {
19824
19846
  init_env_policy();
19825
19847
 
19826
19848
  // src/sandbox/types.ts
19827
- var SandboxSecurityError = class extends Error {
19828
- code = "sandbox_security";
19829
- constructor(message) {
19830
- super(message);
19831
- this.name = "SandboxSecurityError";
19832
- }
19833
- };
19834
- var SHELL_METACHARACTERS = /[;&|`$(){}]/;
19835
19849
  var SandboxBackend = class {
19836
19850
  config;
19837
19851
  constructor(config = {}) {
@@ -19874,13 +19888,6 @@ var SandboxBackend = class {
19874
19888
  if (result.exitCode !== 0) return [];
19875
19889
  return result.stdout.trim().split("\n").filter(Boolean);
19876
19890
  }
19877
- validateCommand(command) {
19878
- if (SHELL_METACHARACTERS.test(command)) {
19879
- throw new SandboxSecurityError(
19880
- `Command contains shell metacharacters: ${command.slice(0, 80)}`
19881
- );
19882
- }
19883
- }
19884
19891
  truncateOutput(output) {
19885
19892
  const max = this.config.maxOutputBytes ?? 5 * 1024 * 1024;
19886
19893
  if (Buffer.byteLength(output) > max) {