@theokit/sdk 2.23.0 → 2.24.0

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/index.cjs CHANGED
@@ -15788,6 +15788,7 @@ function levenshtein(a, b) {
15788
15788
  }
15789
15789
 
15790
15790
  // src/internal/runtime/local-agent/real-local-run.ts
15791
+ init_async_local_storage();
15791
15792
  function createRealLocalRun(options) {
15792
15793
  const { userText, id, startTime } = prepareRunContext(options.message);
15793
15794
  const supported = /* @__PURE__ */ new Set(["stream", "wait", "cancel", "conversation"]);
@@ -15899,6 +15900,7 @@ function buildLoopInputs(options, runId, userText) {
15899
15900
  ...options.onStep !== void 0 ? { onStep: options.onStep } : {},
15900
15901
  ...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
15901
15902
  ...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
15903
+ ...options.sendOptions.activeTools !== void 0 ? { activeTools: options.sendOptions.activeTools } : {},
15902
15904
  ...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
15903
15905
  ...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
15904
15906
  ...buildCustomToolsInput(
@@ -16029,7 +16031,7 @@ var RealLocalRun = class extends FixtureRunBase {
16029
16031
  }
16030
16032
  async executeAgentLoop(inputs) {
16031
16033
  try {
16032
- const output = await runAgentLoop(inputs);
16034
+ const output = inputs.activeTools !== void 0 ? await withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : await runAgentLoop(inputs);
16033
16035
  this.applyAgentLoopOutput(output);
16034
16036
  this.transitionTo(output.finalStatus);
16035
16037
  } catch (cause) {
@@ -19515,6 +19517,11 @@ function defineProvider(profile, opts) {
19515
19517
 
19516
19518
  // src/define-tool.ts
19517
19519
  init_to_json_schema();
19520
+ function shapeToolResult(spec, out) {
19521
+ const validated = spec.outputSchema === void 0 ? out : spec.outputSchema.parse(out);
19522
+ if (spec.toModelOutput !== void 0) return spec.toModelOutput(validated);
19523
+ return typeof validated === "string" ? validated : JSON.stringify(validated);
19524
+ }
19518
19525
  function defineTool(spec) {
19519
19526
  const inputSchema = toJsonSchema(spec.inputSchema, {
19520
19527
  unrepresentable: "any"
@@ -19529,7 +19536,8 @@ function defineTool(spec) {
19529
19536
  schema: spec.inputSchema
19530
19537
  }).value : input;
19531
19538
  const parsed = spec.inputSchema.parse(raw);
19532
- return await spec.handler(parsed, ctx);
19539
+ const out = await spec.handler(parsed, ctx);
19540
+ return shapeToolResult(spec, out);
19533
19541
  }
19534
19542
  };
19535
19543
  }