@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.js CHANGED
@@ -4740,7 +4740,14 @@ var init_env_policy = __esm({
4740
4740
  /[_-]PWD/i,
4741
4741
  /CREDENTIAL/i,
4742
4742
  /PRIVATE/i,
4743
- /_AUTH/i
4743
+ /_AUTH/i,
4744
+ // #54-a — value-embedded-secret conventions (no generic `*_URL` — see keep-list test).
4745
+ /DSN/i,
4746
+ /WEBHOOK/i,
4747
+ /COOKIE/i,
4748
+ /CONNECTION[_-]?STRING/i,
4749
+ // Known DB / message-broker connection-string vars (carry `user:pass@`).
4750
+ /(?:^|[_-])(?:DATABASE|DB|REDIS|MONGO(?:DB)?|POSTGRES(?:QL)?|MYSQL|MARIADB|AMQP|RABBITMQ|CLICKHOUSE|ELASTIC(?:SEARCH)?|CASSANDRA|COUCHDB|MEMCACHED|NATS|KAFKA)[_-]?(?:URL|URI|DSN|CONNECTION)/i
4744
4751
  ];
4745
4752
  CORE_VARS = [
4746
4753
  "PATH",
@@ -7737,15 +7744,19 @@ async function collectChildToolResults(run) {
7737
7744
  ${lines.join("\n")}
7738
7745
  </subagent-tool-results>`;
7739
7746
  }
7740
- async function runChildAgent(spec, input, signal, maxSteps, inherited) {
7741
- const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
7747
+ function buildChildCreateOptions(spec, inherited) {
7742
7748
  const model = spec.model ? { id: spec.model } : inherited?.model;
7743
- const agent = await Agent2.create({
7749
+ return {
7744
7750
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
7745
7751
  ...model !== void 0 ? { model } : {},
7752
+ ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
7746
7753
  systemPrompt: spec.instructions,
7747
7754
  tools: spec.tools ?? []
7748
- });
7755
+ };
7756
+ }
7757
+ async function runChildAgent(spec, input, signal, maxSteps, inherited) {
7758
+ const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
7759
+ const agent = await Agent2.create(buildChildCreateOptions(spec, inherited));
7749
7760
  try {
7750
7761
  const sendOptions = {
7751
7762
  ...signal !== void 0 ? { signal } : {},
@@ -9648,7 +9659,10 @@ async function runAgentLoop(inputs) {
9648
9659
  }
9649
9660
  budget.consume();
9650
9661
  inputs.budgetTracker?.nextIteration?.();
9651
- if (inputs.signal?.aborted === true) break;
9662
+ if (inputs.signal?.aborted === true) {
9663
+ ctx.finalStatus = "cancelled";
9664
+ break;
9665
+ }
9652
9666
  }
9653
9667
  if (lastTurnDecision === "continue" && budget.shouldContinue() === false) {
9654
9668
  ctx.stoppedAtIterationLimit = true;
@@ -9833,15 +9847,15 @@ async function guardAndTransformToolResults(inputs, raw, ctx) {
9833
9847
  }
9834
9848
  async function continueOrTerminate(inputs, ctx, llmOutput) {
9835
9849
  if (llmOutput.errored) return "error";
9836
- if (llmOutput.text.length > 0) {
9837
- await emitAssistantTextStep(inputs, ctx, llmOutput.text);
9850
+ const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
9851
+ const text = llmOutput.text.length > 0 ? await transformLlmOutputText(inputs, llmOutput.text, tCtx) : llmOutput.text;
9852
+ if (text.length > 0) {
9853
+ await emitAssistantTextStep(inputs, ctx, text);
9838
9854
  }
9839
9855
  if (llmOutput.stopReason !== "tool_use" || llmOutput.toolCalls.length === 0) {
9840
9856
  return finishOrReflect(inputs, ctx, llmOutput);
9841
9857
  }
9842
- const tCtx = { agentId: inputs.agentId, runId: inputs.runId };
9843
- const outText = await transformLlmOutputText(inputs, llmOutput.text, tCtx);
9844
- ctx.messages.push(buildAssistantTurn(outText, llmOutput.toolCalls));
9858
+ ctx.messages.push(buildAssistantTurn(text, llmOutput.toolCalls));
9845
9859
  const rawResults = await dispatchTools(
9846
9860
  // SE12 — forward a read-only text projection of the transcript-so-far to tool
9847
9861
  // handlers via `ctx.messages` (consumed by defineSubAgent's messageFilter).
@@ -13165,7 +13179,12 @@ var init_client = __esm({
13165
13179
  code: "mcp_http_error"
13166
13180
  });
13167
13181
  }
13168
- return await response.json();
13182
+ try {
13183
+ return await response.json();
13184
+ } catch (cause) {
13185
+ if (isAbortLike(cause)) throw mcpTimeoutError(this.name, timeoutMs);
13186
+ throw cause;
13187
+ }
13169
13188
  }
13170
13189
  };
13171
13190
  }
@@ -13405,9 +13424,11 @@ function declarativeSubagentTools(agentOptions, parentTools) {
13405
13424
  return subAgentToolsFromDefinitions(agents2, parentTools);
13406
13425
  }
13407
13426
  function bindParentCredentials(tools, agentOptions) {
13427
+ const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
13408
13428
  const credentials = {
13409
13429
  ...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
13410
- ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {}
13430
+ ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
13431
+ ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {}
13411
13432
  };
13412
13433
  for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
13413
13434
  }
@@ -15932,10 +15953,11 @@ var init_local_agent_memory = __esm({
15932
15953
  }
15933
15954
  buildTelemetryRecallArgs(telemetry) {
15934
15955
  const userId = typeof this.options.memoryContext?.userId === "string" ? this.options.memoryContext.userId : void 0;
15956
+ const tenantId = typeof this.options.memoryContext?.tenantId === "string" ? this.options.memoryContext.tenantId : void 0;
15935
15957
  return {
15936
15958
  ...telemetry !== void 0 ? { telemetry } : {},
15937
15959
  ...userId !== void 0 ? { userId } : {},
15938
- namespace: "default",
15960
+ namespace: tenantId ?? "default",
15939
15961
  scope: "session"
15940
15962
  };
15941
15963
  }
@@ -19821,14 +19843,6 @@ async function llmJudgeScore(options) {
19821
19843
  init_env_policy();
19822
19844
 
19823
19845
  // src/sandbox/types.ts
19824
- var SandboxSecurityError = class extends Error {
19825
- code = "sandbox_security";
19826
- constructor(message) {
19827
- super(message);
19828
- this.name = "SandboxSecurityError";
19829
- }
19830
- };
19831
- var SHELL_METACHARACTERS = /[;&|`$(){}]/;
19832
19846
  var SandboxBackend = class {
19833
19847
  config;
19834
19848
  constructor(config = {}) {
@@ -19871,13 +19885,6 @@ var SandboxBackend = class {
19871
19885
  if (result.exitCode !== 0) return [];
19872
19886
  return result.stdout.trim().split("\n").filter(Boolean);
19873
19887
  }
19874
- validateCommand(command) {
19875
- if (SHELL_METACHARACTERS.test(command)) {
19876
- throw new SandboxSecurityError(
19877
- `Command contains shell metacharacters: ${command.slice(0, 80)}`
19878
- );
19879
- }
19880
- }
19881
19888
  truncateOutput(output) {
19882
19889
  const max = this.config.maxOutputBytes ?? 5 * 1024 * 1024;
19883
19890
  if (Buffer.byteLength(output) > max) {