@theokit/sdk 2.22.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.
@@ -1130,6 +1130,23 @@ interface SendOptions {
1130
1130
  * forces a tool call; `"auto"` (or omitted) is the default. Local runtime; OpenAI-compat providers.
1131
1131
  */
1132
1132
  toolChoice?: "auto" | "none" | "required";
1133
+ /**
1134
+ * SE18 — per-send runtime tool subset (**local runtime only**; cloud agents
1135
+ * ignore it). When set, only tools whose name is in this list may be called for
1136
+ * this send; a call to any other registered tool is vetoed at dispatch (the same
1137
+ * `withToolWhitelist` path `Agent.fork`'s `allowedTools` uses — NOT
1138
+ * `PermissionEngine`). Composes with `toolChoice`: `activeTools` narrows the set,
1139
+ * `toolChoice` gates calling within it. Absent ⇒ the full toolset is available.
1140
+ *
1141
+ * Matching is EXACT against the tool's registered name — the same name the
1142
+ * dispatch sees after tool-name repair (mirrors `Agent.fork`'s `allowedTools`;
1143
+ * it is NOT lowercased for you, so a mixed-case registered tool needs its exact
1144
+ * registered name here). An empty list (`[]`) vetoes EVERY tool (fail-closed —
1145
+ * "restrict to the empty set"); pass `undefined` (or omit) for no restriction.
1146
+ * A subagent invoked within this send inherits the whitelist via async-context
1147
+ * propagation unless it declares its own tool scope.
1148
+ */
1149
+ activeTools?: string[];
1133
1150
  /** Local agents only. Expire a stuck active run before starting this message. */
1134
1151
  local?: {
1135
1152
  force?: boolean;
@@ -1130,6 +1130,23 @@ interface SendOptions {
1130
1130
  * forces a tool call; `"auto"` (or omitted) is the default. Local runtime; OpenAI-compat providers.
1131
1131
  */
1132
1132
  toolChoice?: "auto" | "none" | "required";
1133
+ /**
1134
+ * SE18 — per-send runtime tool subset (**local runtime only**; cloud agents
1135
+ * ignore it). When set, only tools whose name is in this list may be called for
1136
+ * this send; a call to any other registered tool is vetoed at dispatch (the same
1137
+ * `withToolWhitelist` path `Agent.fork`'s `allowedTools` uses — NOT
1138
+ * `PermissionEngine`). Composes with `toolChoice`: `activeTools` narrows the set,
1139
+ * `toolChoice` gates calling within it. Absent ⇒ the full toolset is available.
1140
+ *
1141
+ * Matching is EXACT against the tool's registered name — the same name the
1142
+ * dispatch sees after tool-name repair (mirrors `Agent.fork`'s `allowedTools`;
1143
+ * it is NOT lowercased for you, so a mixed-case registered tool needs its exact
1144
+ * registered name here). An empty list (`[]`) vetoes EVERY tool (fail-closed —
1145
+ * "restrict to the empty set"); pass `undefined` (or omit) for no restriction.
1146
+ * A subagent invoked within this send inherits the whitelist via async-context
1147
+ * propagation unless it declares its own tool scope.
1148
+ */
1149
+ activeTools?: string[];
1133
1150
  /** Local agents only. Expire a stuck active run before starting this message. */
1134
1151
  local?: {
1135
1152
  force?: boolean;
@@ -328,6 +328,23 @@ export interface SendOptions {
328
328
  * forces a tool call; `"auto"` (or omitted) is the default. Local runtime; OpenAI-compat providers.
329
329
  */
330
330
  toolChoice?: "auto" | "none" | "required";
331
+ /**
332
+ * SE18 — per-send runtime tool subset (**local runtime only**; cloud agents
333
+ * ignore it). When set, only tools whose name is in this list may be called for
334
+ * this send; a call to any other registered tool is vetoed at dispatch (the same
335
+ * `withToolWhitelist` path `Agent.fork`'s `allowedTools` uses — NOT
336
+ * `PermissionEngine`). Composes with `toolChoice`: `activeTools` narrows the set,
337
+ * `toolChoice` gates calling within it. Absent ⇒ the full toolset is available.
338
+ *
339
+ * Matching is EXACT against the tool's registered name — the same name the
340
+ * dispatch sees after tool-name repair (mirrors `Agent.fork`'s `allowedTools`;
341
+ * it is NOT lowercased for you, so a mixed-case registered tool needs its exact
342
+ * registered name here). An empty list (`[]`) vetoes EVERY tool (fail-closed —
343
+ * "restrict to the empty set"); pass `undefined` (or omit) for no restriction.
344
+ * A subagent invoked within this send inherits the whitelist via async-context
345
+ * propagation unless it declares its own tool scope.
346
+ */
347
+ activeTools?: string[];
331
348
  /** Local agents only. Expire a stuck active run before starting this message. */
332
349
  local?: {
333
350
  force?: boolean;
package/dist/workflow.cjs CHANGED
@@ -2244,6 +2244,9 @@ function sanitizeIdentifier(input, options) {
2244
2244
  }
2245
2245
  return input.toLowerCase();
2246
2246
  }
2247
+ function toJsonSchema(schema, options = { unrepresentable: "any" }) {
2248
+ return zod.toJSONSchema(schema, options);
2249
+ }
2247
2250
 
2248
2251
  // src/workflow.ts
2249
2252
  init_workflow();
@@ -2470,6 +2473,38 @@ function agentStep(id, agent, promptTemplate, opts) {
2470
2473
  ...opts?.origin !== void 0 ? { origin: opts.origin } : {}
2471
2474
  };
2472
2475
  }
2476
+ var WorkflowToolError = class extends Error {
2477
+ constructor(toolName, workflowStatus, workflowError) {
2478
+ super(
2479
+ `workflowAsTool("${toolName}"): workflow ${workflowStatus}${workflowError ? `: ${workflowError.message}` : ""}`
2480
+ );
2481
+ this.toolName = toolName;
2482
+ this.workflowStatus = workflowStatus;
2483
+ this.workflowError = workflowError;
2484
+ this.name = "WorkflowToolError";
2485
+ }
2486
+ toolName;
2487
+ workflowStatus;
2488
+ workflowError;
2489
+ code = "workflow_tool_failed";
2490
+ };
2491
+ function workflowAsTool(workflow, spec) {
2492
+ const inputSchema = toJsonSchema(spec.inputSchema, { unrepresentable: "any" });
2493
+ return {
2494
+ name: spec.name,
2495
+ description: spec.description,
2496
+ inputSchema,
2497
+ handler: async (rawInput) => {
2498
+ const parsed = spec.inputSchema.parse(rawInput);
2499
+ const run = await workflow.run(parsed);
2500
+ if (run.status !== "completed") {
2501
+ throw new WorkflowToolError(spec.name, run.status, run.error);
2502
+ }
2503
+ const output = run.output;
2504
+ return typeof output === "string" ? output : JSON.stringify(output ?? null);
2505
+ }
2506
+ };
2507
+ }
2473
2508
  function validateStepId(id) {
2474
2509
  sanitizeIdentifier(id, { maxLen: 64 });
2475
2510
  }
@@ -2497,8 +2532,10 @@ function walkStepsValidating(steps, seen) {
2497
2532
 
2498
2533
  exports.Workflow = Workflow;
2499
2534
  exports.WorkflowBuilder = WorkflowBuilder;
2535
+ exports.WorkflowToolError = WorkflowToolError;
2500
2536
  exports.__resetSnapshotStoresForTests = __resetSnapshotStoresForTests;
2501
2537
  exports.agentStep = agentStep;
2502
2538
  exports.fn = fn;
2539
+ exports.workflowAsTool = workflowAsTool;
2503
2540
  //# sourceMappingURL=workflow.cjs.map
2504
2541
  //# sourceMappingURL=workflow.cjs.map