zeitlich 0.2.17 → 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-BMXzv7TN.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-BMXzv7TN.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-BMXzv7TN.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';
@@ -104,7 +104,7 @@ interface SubagentConfig<TResult extends z.ZodType = z.ZodType> {
104
104
  /** Description shown to the parent agent explaining what this subagent does */
105
105
  description: string;
106
106
  /** Whether this subagent is available (default: true). Disabled subagents are excluded from the Subagent tool. */
107
- enabled?: boolean;
107
+ enabled?: boolean | (() => boolean);
108
108
  /** Temporal workflow function or type name (used with executeChild) */
109
109
  workflow: string | SubagentWorkflow<TResult>;
110
110
  /** Optional task queue - defaults to parent's queue if not specified */
@@ -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-BMXzv7TN.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';
@@ -104,7 +104,7 @@ interface SubagentConfig<TResult extends z.ZodType = z.ZodType> {
104
104
  /** Description shown to the parent agent explaining what this subagent does */
105
105
  description: string;
106
106
  /** Whether this subagent is available (default: true). Disabled subagents are excluded from the Subagent tool. */
107
- enabled?: boolean;
107
+ enabled?: boolean | (() => boolean);
108
108
  /** Temporal workflow function or type name (used with executeChild) */
109
109
  workflow: string | SubagentWorkflow<TResult>;
110
110
  /** Optional task queue - defaults to parent's queue if not specified */
@@ -148,7 +148,7 @@ interface ToolWithHandler<TName extends string = string, TSchema extends z.ZodTy
148
148
  strict?: boolean;
149
149
  max_uses?: number;
150
150
  /** Whether this tool is available to the agent (default: true). Disabled tools are excluded from definitions and rejected at parse time. */
151
- enabled?: boolean;
151
+ enabled?: boolean | (() => boolean);
152
152
  /** Per-tool lifecycle hooks (run in addition to global hooks) */
153
153
  hooks?: ToolHooks<z.infer<TSchema>, TResult>;
154
154
  }
@@ -162,12 +162,12 @@ 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;
170
- enabled?: boolean;
170
+ enabled?: boolean | (() => boolean);
171
171
  hooks?: ToolHooks<any, any>;
172
172
  }>;
173
173
  /**
@@ -148,7 +148,7 @@ interface ToolWithHandler<TName extends string = string, TSchema extends z.ZodTy
148
148
  strict?: boolean;
149
149
  max_uses?: number;
150
150
  /** Whether this tool is available to the agent (default: true). Disabled tools are excluded from definitions and rejected at parse time. */
151
- enabled?: boolean;
151
+ enabled?: boolean | (() => boolean);
152
152
  /** Per-tool lifecycle hooks (run in addition to global hooks) */
153
153
  hooks?: ToolHooks<z.infer<TSchema>, TResult>;
154
154
  }
@@ -162,12 +162,12 @@ 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;
170
- enabled?: boolean;
170
+ enabled?: boolean | (() => boolean);
171
171
  hooks?: ToolHooks<any, any>;
172
172
  }>;
173
173
  /**
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) => 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
  }));
@@ -385,7 +386,9 @@ function createSubagentHandler(subagents) {
385
386
  // src/lib/subagent/register.ts
386
387
  function buildSubagentRegistration(subagents) {
387
388
  if (subagents.length === 0) return null;
388
- const getEnabled = () => subagents.filter((s) => s.enabled ?? true);
389
+ const getEnabled = () => subagents.filter(
390
+ (s) => typeof s.enabled === "function" ? s.enabled() : s.enabled ?? true
391
+ );
389
392
  const subagentHooksMap = /* @__PURE__ */ new Map();
390
393
  for (const s of subagents) {
391
394
  if (s.hooks) subagentHooksMap.set(s.agentName, s.hooks);
@@ -393,15 +396,9 @@ function buildSubagentRegistration(subagents) {
393
396
  const resolveSubagentName = (args) => args.subagent;
394
397
  return {
395
398
  name: SUBAGENT_TOOL_NAME,
396
- get enabled() {
397
- return getEnabled().length > 0;
398
- },
399
- get description() {
400
- return createSubagentTool(getEnabled()).description;
401
- },
402
- get schema() {
403
- return createSubagentTool(getEnabled()).schema;
404
- },
399
+ enabled: () => getEnabled().length > 0,
400
+ description: () => createSubagentTool(getEnabled()).description,
401
+ schema: () => createSubagentTool(getEnabled()).schema,
405
402
  handler: createSubagentHandler(subagents),
406
403
  ...subagentHooksMap.size > 0 && {
407
404
  hooks: {