zeitlich 0.2.18 → 0.2.19

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.
@@ -1,5 +1,5 @@
1
1
  import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-BMRzfELQ.cjs';
2
- import { R as RouterContext } from './types-CmOSypVk.cjs';
2
+ import { R as RouterContext } from './types-DjT78Sdp.cjs';
3
3
 
4
4
  /**
5
5
  * Ephemeral {@link SandboxFileSystem} backed by a {@link FileResolver}.
@@ -1,5 +1,5 @@
1
1
  import { a as SandboxFileSystem, F as FileStat, D as DirentEntry, S as Sandbox, d as SandboxCreateOptions } from './types-BMRzfELQ.js';
2
- import { R as RouterContext } from './types-CmOSypVk.js';
2
+ import { R as RouterContext } from './types-DjT78Sdp.js';
3
3
 
4
4
  /**
5
5
  * Ephemeral {@link SandboxFileSystem} backed by a {@link FileResolver}.
@@ -1,5 +1,5 @@
1
1
  import { Duration } from '@temporalio/common';
2
- import { a as ToolMap, b as ToolRouterHooks, M as MessageContent, S as SessionExitReason, c as ToolHandlerResponse, P as PreToolUseHookResult, d as PostToolUseFailureHookResult, e as RawToolCall, f as TokenUsage, B as BaseAgentState, g as RunAgentConfig, h as AgentStatus, W as WorkflowTask, i as ToolDefinition, j as ToolResultConfig, k as ToolCallResultUnion, I as InferToolResults } from './types-CmOSypVk.cjs';
2
+ import { a as ToolMap, b as ToolRouterHooks, M as MessageContent, S as SessionExitReason, c as ToolHandlerResponse, P as PreToolUseHookResult, d as PostToolUseFailureHookResult, e as RawToolCall, f as TokenUsage, B as BaseAgentState, g as RunAgentConfig, h as AgentStatus, W as WorkflowTask, i as ToolDefinition, j as ToolResultConfig, k as ToolCallResultUnion, I as InferToolResults } from './types-DjT78Sdp.cjs';
3
3
  import { z } from 'zod';
4
4
  import { g as SandboxOps } from './types-BMRzfELQ.cjs';
5
5
  import { QueryDefinition } from '@temporalio/workflow';
@@ -1,5 +1,5 @@
1
1
  import { Duration } from '@temporalio/common';
2
- import { a as ToolMap, b as ToolRouterHooks, M as MessageContent, S as SessionExitReason, c as ToolHandlerResponse, P as PreToolUseHookResult, d as PostToolUseFailureHookResult, e as RawToolCall, f as TokenUsage, B as BaseAgentState, g as RunAgentConfig, h as AgentStatus, W as WorkflowTask, i as ToolDefinition, j as ToolResultConfig, k as ToolCallResultUnion, I as InferToolResults } from './types-CmOSypVk.js';
2
+ import { a as ToolMap, b as ToolRouterHooks, M as MessageContent, S as SessionExitReason, c as ToolHandlerResponse, P as PreToolUseHookResult, d as PostToolUseFailureHookResult, e as RawToolCall, f as TokenUsage, B as BaseAgentState, g as RunAgentConfig, h as AgentStatus, W as WorkflowTask, i as ToolDefinition, j as ToolResultConfig, k as ToolCallResultUnion, I as InferToolResults } from './types-DjT78Sdp.js';
3
3
  import { z } from 'zod';
4
4
  import { g as SandboxOps } from './types-BMRzfELQ.js';
5
5
  import { QueryDefinition } from '@temporalio/workflow';
@@ -162,8 +162,8 @@ interface ToolWithHandler<TName extends string = string, TSchema extends z.ZodTy
162
162
  */
163
163
  type ToolMap = Record<string, {
164
164
  name: string;
165
- description: string;
166
- schema: z.ZodType;
165
+ description: string | (() => string);
166
+ schema: z.ZodType | (() => z.ZodType);
167
167
  handler: ToolHandler<any, any, any>;
168
168
  strict?: boolean;
169
169
  max_uses?: number;
@@ -162,8 +162,8 @@ interface ToolWithHandler<TName extends string = string, TSchema extends z.ZodTy
162
162
  */
163
163
  type ToolMap = Record<string, {
164
164
  name: string;
165
- description: string;
166
- schema: z.ZodType;
165
+ description: string | (() => string);
166
+ schema: z.ZodType | (() => z.ZodType);
167
167
  handler: ToolHandler<any, any, any>;
168
168
  strict?: boolean;
169
169
  max_uses?: number;
package/dist/workflow.cjs CHANGED
@@ -15,7 +15,8 @@ function createToolRouter(options) {
15
15
  for (const [_key, tool] of Object.entries(options.tools)) {
16
16
  toolMap.set(tool.name, tool);
17
17
  }
18
- const isEnabled = (tool) => typeof tool.enabled === "function" ? tool.enabled() : tool.enabled ?? true;
18
+ const resolve = (v) => typeof v === "function" ? v() : v;
19
+ const isEnabled = (tool) => resolve(tool.enabled) ?? true;
19
20
  if (options.plugins) {
20
21
  for (const plugin of options.plugins) {
21
22
  toolMap.set(plugin.name, plugin);
@@ -166,7 +167,7 @@ function createToolRouter(options) {
166
167
  if (!tool || !isEnabled(tool)) {
167
168
  throw new Error(`Tool ${toolCall.name} not found`);
168
169
  }
169
- const parsedArgs = tool.schema.parse(toolCall.args);
170
+ const parsedArgs = resolve(tool.schema).parse(toolCall.args);
170
171
  return {
171
172
  id: toolCall.id ?? "",
172
173
  name: toolCall.name,
@@ -183,8 +184,8 @@ function createToolRouter(options) {
183
184
  getToolDefinitions() {
184
185
  return Array.from(toolMap).filter(([, tool]) => isEnabled(tool)).map(([name, tool]) => ({
185
186
  name,
186
- description: tool.description,
187
- schema: tool.schema,
187
+ description: resolve(tool.description),
188
+ schema: resolve(tool.schema),
188
189
  strict: tool.strict,
189
190
  max_uses: tool.max_uses
190
191
  }));
@@ -395,15 +396,9 @@ function buildSubagentRegistration(subagents) {
395
396
  const resolveSubagentName = (args) => args.subagent;
396
397
  return {
397
398
  name: SUBAGENT_TOOL_NAME,
398
- get enabled() {
399
- return getEnabled().length > 0;
400
- },
401
- get description() {
402
- return createSubagentTool(getEnabled()).description;
403
- },
404
- get schema() {
405
- return createSubagentTool(getEnabled()).schema;
406
- },
399
+ enabled: () => getEnabled().length > 0,
400
+ description: () => createSubagentTool(getEnabled()).description,
401
+ schema: () => createSubagentTool(getEnabled()).schema,
407
402
  handler: createSubagentHandler(subagents),
408
403
  ...subagentHooksMap.size > 0 && {
409
404
  hooks: {