@stigmer/mcp-server 3.0.8-dev.20260612122433
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/LICENSE +190 -0
- package/README.md +157 -0
- package/cli/mcp-server-stigmer.d.ts +3 -0
- package/cli/mcp-server-stigmer.d.ts.map +1 -0
- package/cli/mcp-server-stigmer.js +201 -0
- package/cli/mcp-server-stigmer.js.map +1 -0
- package/config.d.ts +44 -0
- package/config.d.ts.map +1 -0
- package/config.js +92 -0
- package/config.js.map +1 -0
- package/domains/agents/apply.d.ts +4 -0
- package/domains/agents/apply.d.ts.map +1 -0
- package/domains/agents/apply.js +25 -0
- package/domains/agents/apply.js.map +1 -0
- package/domains/agents/delete.d.ts +3 -0
- package/domains/agents/delete.d.ts.map +1 -0
- package/domains/agents/delete.js +35 -0
- package/domains/agents/delete.js.map +1 -0
- package/domains/agents/fetch.d.ts +6 -0
- package/domains/agents/fetch.d.ts.map +1 -0
- package/domains/agents/fetch.js +24 -0
- package/domains/agents/fetch.js.map +1 -0
- package/domains/agents/resources.d.ts +5 -0
- package/domains/agents/resources.d.ts.map +1 -0
- package/domains/agents/resources.js +16 -0
- package/domains/agents/resources.js.map +1 -0
- package/domains/agents/tools.d.ts +5 -0
- package/domains/agents/tools.d.ts.map +1 -0
- package/domains/agents/tools.js +41 -0
- package/domains/agents/tools.js.map +1 -0
- package/domains/client.d.ts +53 -0
- package/domains/client.d.ts.map +1 -0
- package/domains/client.js +62 -0
- package/domains/client.js.map +1 -0
- package/domains/marshal.d.ts +8 -0
- package/domains/marshal.d.ts.map +1 -0
- package/domains/marshal.js +17 -0
- package/domains/marshal.js.map +1 -0
- package/domains/mcpservers/apply.d.ts +4 -0
- package/domains/mcpservers/apply.d.ts.map +1 -0
- package/domains/mcpservers/apply.js +26 -0
- package/domains/mcpservers/apply.js.map +1 -0
- package/domains/mcpservers/delete.d.ts +6 -0
- package/domains/mcpservers/delete.d.ts.map +1 -0
- package/domains/mcpservers/delete.js +42 -0
- package/domains/mcpservers/delete.js.map +1 -0
- package/domains/mcpservers/fetch.d.ts +7 -0
- package/domains/mcpservers/fetch.d.ts.map +1 -0
- package/domains/mcpservers/fetch.js +26 -0
- package/domains/mcpservers/fetch.js.map +1 -0
- package/domains/mcpservers/resources.d.ts +5 -0
- package/domains/mcpservers/resources.d.ts.map +1 -0
- package/domains/mcpservers/resources.js +16 -0
- package/domains/mcpservers/resources.js.map +1 -0
- package/domains/mcpservers/tools.d.ts +5 -0
- package/domains/mcpservers/tools.d.ts.map +1 -0
- package/domains/mcpservers/tools.js +39 -0
- package/domains/mcpservers/tools.js.map +1 -0
- package/domains/resourcehandler.d.ts +27 -0
- package/domains/resourcehandler.d.ts.map +1 -0
- package/domains/resourcehandler.js +32 -0
- package/domains/resourcehandler.js.map +1 -0
- package/domains/resourceuri.d.ts +34 -0
- package/domains/resourceuri.d.ts.map +1 -0
- package/domains/resourceuri.js +100 -0
- package/domains/resourceuri.js.map +1 -0
- package/domains/rpcerr.d.ts +8 -0
- package/domains/rpcerr.d.ts.map +1 -0
- package/domains/rpcerr.js +42 -0
- package/domains/rpcerr.js.map +1 -0
- package/domains/search/tools.d.ts +5 -0
- package/domains/search/tools.d.ts.map +1 -0
- package/domains/search/tools.js +125 -0
- package/domains/search/tools.js.map +1 -0
- package/domains/skills/delete.d.ts +6 -0
- package/domains/skills/delete.d.ts.map +1 -0
- package/domains/skills/delete.js +38 -0
- package/domains/skills/delete.js.map +1 -0
- package/domains/skills/fetch.d.ts +6 -0
- package/domains/skills/fetch.d.ts.map +1 -0
- package/domains/skills/fetch.js +28 -0
- package/domains/skills/fetch.js.map +1 -0
- package/domains/skills/resources.d.ts +5 -0
- package/domains/skills/resources.d.ts.map +1 -0
- package/domains/skills/resources.js +25 -0
- package/domains/skills/resources.js.map +1 -0
- package/domains/skills/tools.d.ts +5 -0
- package/domains/skills/tools.d.ts.map +1 -0
- package/domains/skills/tools.js +39 -0
- package/domains/skills/tools.js.map +1 -0
- package/domains/toolresult.d.ts +12 -0
- package/domains/toolresult.d.ts.map +1 -0
- package/domains/toolresult.js +30 -0
- package/domains/toolresult.js.map +1 -0
- package/domains/workflowexecutions/tools.d.ts +5 -0
- package/domains/workflowexecutions/tools.d.ts.map +1 -0
- package/domains/workflowexecutions/tools.js +80 -0
- package/domains/workflowexecutions/tools.js.map +1 -0
- package/domains/workflows/apply.d.ts +4 -0
- package/domains/workflows/apply.d.ts.map +1 -0
- package/domains/workflows/apply.js +30 -0
- package/domains/workflows/apply.js.map +1 -0
- package/domains/workflows/delete.d.ts +3 -0
- package/domains/workflows/delete.d.ts.map +1 -0
- package/domains/workflows/delete.js +35 -0
- package/domains/workflows/delete.js.map +1 -0
- package/domains/workflows/fetch.d.ts +6 -0
- package/domains/workflows/fetch.d.ts.map +1 -0
- package/domains/workflows/fetch.js +25 -0
- package/domains/workflows/fetch.js.map +1 -0
- package/domains/workflows/resources.d.ts +5 -0
- package/domains/workflows/resources.d.ts.map +1 -0
- package/domains/workflows/resources.js +16 -0
- package/domains/workflows/resources.js.map +1 -0
- package/domains/workflows/taskkinds.d.ts +5 -0
- package/domains/workflows/taskkinds.d.ts.map +1 -0
- package/domains/workflows/taskkinds.js +66 -0
- package/domains/workflows/taskkinds.js.map +1 -0
- package/domains/workflows/tools.d.ts +5 -0
- package/domains/workflows/tools.d.ts.map +1 -0
- package/domains/workflows/tools.js +35 -0
- package/domains/workflows/tools.js.map +1 -0
- package/domains/workflows/validate.d.ts +5 -0
- package/domains/workflows/validate.d.ts.map +1 -0
- package/domains/workflows/validate.js +113 -0
- package/domains/workflows/validate.js.map +1 -0
- package/gen/agent.d.ts +385 -0
- package/gen/agent.d.ts.map +1 -0
- package/gen/agent.js +170 -0
- package/gen/agent.js.map +1 -0
- package/gen/apply-runtime.d.ts +18 -0
- package/gen/apply-runtime.d.ts.map +1 -0
- package/gen/apply-runtime.js +50 -0
- package/gen/apply-runtime.js.map +1 -0
- package/gen/mcpserver.d.ts +289 -0
- package/gen/mcpserver.d.ts.map +1 -0
- package/gen/mcpserver.js +166 -0
- package/gen/mcpserver.js.map +1 -0
- package/gen/workflow.d.ts +805 -0
- package/gen/workflow.d.ts.map +1 -0
- package/gen/workflow.js +842 -0
- package/gen/workflow.js.map +1 -0
- package/index.d.ts +20 -0
- package/index.d.ts.map +1 -0
- package/index.js +58 -0
- package/index.js.map +1 -0
- package/logger.d.ts +20 -0
- package/logger.d.ts.map +1 -0
- package/logger.js +41 -0
- package/logger.js.map +1 -0
- package/package.json +43 -0
- package/server.d.ts +60 -0
- package/server.d.ts.map +1 -0
- package/server.js +366 -0
- package/server.js.map +1 -0
- package/src/cli/mcp-server-stigmer.ts +42 -0
- package/src/config.test.ts +88 -0
- package/src/config.ts +151 -0
- package/src/domains/agents/apply.ts +30 -0
- package/src/domains/agents/delete.ts +41 -0
- package/src/domains/agents/fetch.ts +33 -0
- package/src/domains/agents/resources.ts +20 -0
- package/src/domains/agents/tools.ts +68 -0
- package/src/domains/apply.integration.test.ts +220 -0
- package/src/domains/client.ts +95 -0
- package/src/domains/deletes.integration.test.ts +124 -0
- package/src/domains/marshal.ts +21 -0
- package/src/domains/mcpservers/apply.ts +36 -0
- package/src/domains/mcpservers/delete.ts +51 -0
- package/src/domains/mcpservers/fetch.ts +35 -0
- package/src/domains/mcpservers/resources.ts +20 -0
- package/src/domains/mcpservers/tools.ts +74 -0
- package/src/domains/reads.integration.test.ts +134 -0
- package/src/domains/resourcehandler.ts +90 -0
- package/src/domains/resources.integration.test.ts +139 -0
- package/src/domains/resourceuri.test.ts +97 -0
- package/src/domains/resourceuri.ts +124 -0
- package/src/domains/rpcerr.test.ts +62 -0
- package/src/domains/rpcerr.ts +46 -0
- package/src/domains/search/search.integration.test.ts +127 -0
- package/src/domains/search/tools.ts +160 -0
- package/src/domains/skills/delete.ts +44 -0
- package/src/domains/skills/fetch.ts +38 -0
- package/src/domains/skills/resources.ts +33 -0
- package/src/domains/skills/tools.ts +67 -0
- package/src/domains/toolresult.ts +33 -0
- package/src/domains/workflowexecutions/tools.ts +133 -0
- package/src/domains/workflows/apply.ts +40 -0
- package/src/domains/workflows/delete.ts +44 -0
- package/src/domains/workflows/fetch.ts +34 -0
- package/src/domains/workflows/resources.ts +20 -0
- package/src/domains/workflows/taskkinds.ts +103 -0
- package/src/domains/workflows/tools.ts +68 -0
- package/src/domains/workflows/validate.integration.test.ts +117 -0
- package/src/domains/workflows/validate.ts +144 -0
- package/src/domains/workflows/workflow-tools.integration.test.ts +148 -0
- package/src/gen/agent.ts +173 -0
- package/src/gen/apply-runtime.ts +52 -0
- package/src/gen/mcpserver.ts +163 -0
- package/src/gen/workflow.ts +858 -0
- package/src/http.integration.test.ts +140 -0
- package/src/index.ts +66 -0
- package/src/logger.ts +49 -0
- package/src/server.integration.test.ts +82 -0
- package/src/server.ts +414 -0
package/gen/workflow.js
ADDED
|
@@ -0,0 +1,842 @@
|
|
|
1
|
+
// Code generated by stigmer-codegen --target=mcp-ts. DO NOT EDIT.
|
|
2
|
+
//
|
|
3
|
+
// Flattened apply-input zod schema + toProto bridge for the Workflow resource.
|
|
4
|
+
// Source proto package: ai.stigmer.agentic.workflow.v1
|
|
5
|
+
import { generateSlug, visibilityFromString, enumFromString, toTimestamp } from "./apply-runtime.js";
|
|
6
|
+
import { create, toJson } from "@bufbuild/protobuf";
|
|
7
|
+
import { ContextManagementConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/spec_pb";
|
|
8
|
+
import { EnvVarDeclarationSchema } from "@stigmer/protos/ai/stigmer/agentic/environment/v1/spec_pb";
|
|
9
|
+
import { Harness } from "@stigmer/protos/ai/stigmer/agentic/session/v1/enum_pb";
|
|
10
|
+
import { WorkflowSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/api_pb";
|
|
11
|
+
import { WorkflowTaskKind, BudgetExceededPolicy } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/enum_pb";
|
|
12
|
+
import { WorkflowSpecSchema, WorkflowDocumentSchema, ExportSchema, FlowControlSchema, WorkflowTaskSchema, WorkflowBudgetSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/spec_pb";
|
|
13
|
+
import { AgentExecutionConfigSchema, AgentCallOutputContractSchema, AgentCallTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/agent_call_pb";
|
|
14
|
+
import { CallActivityTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/call_activity_pb";
|
|
15
|
+
import { OnInvalidOutputPolicy } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/common_pb";
|
|
16
|
+
import { EmitEventSpecSchema, EmitEventTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/emit_event_pb";
|
|
17
|
+
import { EvalCriterionSchema, EvalTaskConfigSchema, EvalScoringMode, EvalFailPolicy } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/eval_pb";
|
|
18
|
+
import { ForTaskConfigSchema, ForEachErrorPolicy } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/for_pb";
|
|
19
|
+
import { ForkBranchSchema, ForkTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/fork_pb";
|
|
20
|
+
import { GrpcCallTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/grpc_call_pb";
|
|
21
|
+
import { HttpEndpointSchema, HttpCallTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/http_call_pb";
|
|
22
|
+
import { HumanInputOutcomeSchema, HumanInputTaskConfigSchema, HumanInputTimeoutPolicy } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/human_input_pb";
|
|
23
|
+
import { SignalSpecSchema, ListenToSchema, ListenTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/listen_pb";
|
|
24
|
+
import { LlmCallTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/llm_call_pb";
|
|
25
|
+
import { NotificationTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/notification_pb";
|
|
26
|
+
import { RaiseTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/raise_pb";
|
|
27
|
+
import { RunTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/run_pb";
|
|
28
|
+
import { SetTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/set_pb";
|
|
29
|
+
import { SwitchCaseSchema, SwitchTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/switch_pb";
|
|
30
|
+
import { TransformTaskConfigSchema, TransformEngine } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/transform_pb";
|
|
31
|
+
import { CatchBlockSchema, TryTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/try_pb";
|
|
32
|
+
import { ValidationRuleSchema, ValidateTaskConfigSchema, ValidationFailPolicy } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/validate_pb";
|
|
33
|
+
import { DurationSchema, WaitTaskConfigSchema } from "@stigmer/protos/ai/stigmer/agentic/workflow/v1/tasks/wait_pb";
|
|
34
|
+
import { ApiResourceMetadataSchema } from "@stigmer/protos/ai/stigmer/commons/apiresource/metadata_pb";
|
|
35
|
+
import { z } from "zod";
|
|
36
|
+
/** WorkflowSpec defines the configurable properties of a workflow. @internal Follows the "kind + Struct" pattern from CloudResource (Planton). This replaces the old `synthesized_yaml` field with structured proto definitions. Each workflow task uses WorkflowTaskKind enum + google.protobuf.Struct for configuration, providing maximum flexibility and extensibility. The overview.md file provides the SDK-facing description and example YAML. */
|
|
37
|
+
export const WorkflowInputShape = {
|
|
38
|
+
name: z.string().describe("Human-readable name of the resource."),
|
|
39
|
+
slug: z.string().optional().describe("URL-friendly identifier (lowercase alphanumeric with hyphens). Auto-generated from name if omitted."),
|
|
40
|
+
org: z.string().describe("Organization that owns this resource (e.g. acme)."),
|
|
41
|
+
visibility: z.string().optional().describe("Resource visibility: PRIVATE or PUBLIC. Omit to leave unchanged on updates."),
|
|
42
|
+
labels: z.record(z.string()).optional().describe("Key-value labels for organization and filtering."),
|
|
43
|
+
tags: z.array(z.string()).optional().describe("Tags for categorization and discovery."),
|
|
44
|
+
description: z.string().optional().describe("Human-readable description for UI and marketplace display."),
|
|
45
|
+
document: z.lazy(() => WorkflowDocumentInputSchema).describe("Workflow document metadata including DSL version, namespace, name, and version."),
|
|
46
|
+
tasks: z.array(z.lazy(() => WorkflowTaskInputSchema)).optional().describe("Ordered list of tasks that make up this workflow. Tasks execute sequentially unless fork/parallel is used."),
|
|
47
|
+
env: z.record(z.lazy(() => EnvVarDeclarationInputSchema)).optional().describe("Environment variable declarations for this workflow. Keys are variable names; values describe their metadata and optionality."),
|
|
48
|
+
budget: z.lazy(() => WorkflowBudgetInputSchema).optional().describe("Budget limits for this workflow execution. When set, the runtime (T13) enforces cost, token, and duration limits across all tasks. The existing org-level billing reservation system (AuthorizeExecution / ExecutionBillingSignal) remains the safety net for overall credit exhaustion; workflow budgets prevent individual workflows from consuming more than intended. Optional — when not set, no workflow-level budget is enforced."),
|
|
49
|
+
};
|
|
50
|
+
export const WorkflowInputSchema = z.object(WorkflowInputShape);
|
|
51
|
+
const WorkflowDocumentInputSchema = z.object({
|
|
52
|
+
dsl: z.string().optional().describe("Workflow DSL version (semver). Must be '1.0.0' for the current specification."),
|
|
53
|
+
namespace: z.string().describe("Workflow namespace (organization/categorization)."),
|
|
54
|
+
name: z.string().describe("Workflow name (unique identifier within namespace)."),
|
|
55
|
+
version: z.string().describe("Workflow version (semver)."),
|
|
56
|
+
description: z.string().optional().describe("Human-readable description."),
|
|
57
|
+
});
|
|
58
|
+
const ContextManagementConfigInputSchema = z.object({
|
|
59
|
+
disable_summarization: z.boolean().optional().describe("Disable automatic context summarization for this execution. When true, the agent will never trigger automatic summarization, even if the context window approaches the model's limit. Use cases: - Short-lived executions that won't approach context limits - Debugging context-related issues - Workflows that manage their own context externally Warning: Disabling summarization may cause execution failure if context exceeds model limits. Default: false (summarization enabled based on model defaults)"),
|
|
60
|
+
custom_trigger_threshold: z.number().optional().describe("Custom token threshold to trigger summarization. When the context token count exceeds this threshold, summarization is triggered to reduce context size. Set to 0 to use model default. The default trigger threshold from Model Registry is typically 90% of the model's context window (e.g., 180K for 200K context models). Must be greater than custom_target_tokens if both are specified. Default: 0 (use model default from Model Registry)"),
|
|
61
|
+
custom_target_tokens: z.number().optional().describe("Custom target token count after summarization. Summarization aims to reduce context to approximately this size. Set to 0 to use model default. The default target from Model Registry is typically 80% of the model's context window (e.g., 160K for 200K context models). Must be less than custom_trigger_threshold if both are specified. Default: 0 (use model default from Model Registry)"),
|
|
62
|
+
});
|
|
63
|
+
const AgentExecutionConfigInputSchema = z.object({
|
|
64
|
+
model: z.string().optional().describe("LLM model to use for this invocation. Example: 'claude-3-5-sonnet', 'gpt-4', 'claude-3-opus' Optional - uses agent's default model if not specified."),
|
|
65
|
+
timeout: z.number().optional().describe("Timeout for agent execution in seconds. Default: 300 (5 minutes) Optional."),
|
|
66
|
+
temperature: z.number().optional().describe("Temperature for LLM sampling (0.0 to 1.0). Lower = more deterministic, Higher = more creative Default: 0.7 Optional."),
|
|
67
|
+
context_management: z.lazy(() => ContextManagementConfigInputSchema).optional().describe("Context management configuration for this agent invocation. Controls automatic summarization behavior for long-running conversations. When specified, overrides model defaults from the Model Registry. @internal @since Phase 3 (Context Summarization Architecture) Use cases: - Disable summarization for short-lived agents - Custom thresholds for agents with specific context requirements - Fine-tune summarization behavior per workflow task Example YAML: config: model: 'claude-sonnet-4.5' context_management: custom_trigger_threshold: 150000 custom_target_tokens: 120000"),
|
|
68
|
+
max_cost_micros: z.union([z.number(), z.string()]).optional().describe("Per-agent-call cost cap in micro-USD (1 USD = 1,000,000 micros). When set, the runtime terminates this agent call if its accumulated cost exceeds this limit. This uses the workflow domain's micro-USD convention and provides per-task cost control at the workflow level. The runtime checks both: per-task limit first, then workflow remaining budget. Optional — when 0, no per-task cost limit is enforced. @since T05 (Workflow-Level Budget Primitives)"),
|
|
69
|
+
});
|
|
70
|
+
const AgentCallOutputContractInputSchema = z.object({
|
|
71
|
+
schema: z.record(z.unknown()).describe("JSON Schema that the agent's structured output must conform to. Standard JSON Schema (draft 2020-12 or compatible). The workflow runner extracts JSON from the agent's final response and validates it against this schema. If validation fails, the on_invalid policy determines what happens next. The schema is carried as a google.protobuf.Struct to preserve the existing kind+Struct envelope pattern and allow YAML authors to write standard JSON Schema inline without a Stigmer-specific schema language."),
|
|
72
|
+
on_invalid: z.string().optional().describe("Policy when agent output fails schema validation. Default: ON_INVALID_FAIL (task fails immediately). Allowed values: ON_INVALID_FAIL, ON_INVALID_RETRY, ON_INVALID_FALLBACK."),
|
|
73
|
+
max_retries: z.number().optional().describe("Maximum retry attempts when on_invalid is ON_INVALID_RETRY. Each retry re-prompts the agent with the specific validation errors and the expected schema, giving the agent an opportunity to self-correct. Only meaningful when on_invalid is ON_INVALID_RETRY; ignored otherwise. Default: 1. Valid range: 1-5."),
|
|
74
|
+
fallback_task: z.string().optional().describe("Target task to branch to when schema validation cannot be resolved. Used in two scenarios: 1. on_invalid is ON_INVALID_RETRY and all retries are exhausted 2. on_invalid is ON_INVALID_FALLBACK (immediate branch, no retry) Must reference a valid task name in the same workflow. When empty and retries are exhausted, the task fails."),
|
|
75
|
+
});
|
|
76
|
+
const AgentCallTaskConfigInputSchema = z.object({
|
|
77
|
+
agent: z.string().describe("Agent reference in 'org/slug' or 'slug' format. - 'slug' only: uses the workflow's organization - 'org/slug': explicit organization reference Examples: 'code-reviewer', 'stigmer/code-reviewer', 'acme/data-analyst' Required field."),
|
|
78
|
+
org: z.string().optional().describe("Explicit organization for agent resolution. Optional. If empty, the org is parsed from the agent field or defaults to workflow's org. Use this when you need to override the parsed org."),
|
|
79
|
+
message: z.string().describe("Instructions/prompt to send to the agent. Supports interpolation of workflow variables using JQ expressions. Example: 'Analyze this code: ${ $context.fetchCode.body }' Required field."),
|
|
80
|
+
env: z.record(z.string()).optional().describe("Runtime environment variables to pass to the agent. Values can be literal strings or JQ expressions that reference workflow context or secrets. Example: {'GITHUB_TOKEN': '${ .secrets.GH_TOKEN }'} Optional."),
|
|
81
|
+
config: z.lazy(() => AgentExecutionConfigInputSchema).optional().describe("Execution configuration for the agent invocation. Optional - defaults are applied if not specified."),
|
|
82
|
+
output: z.lazy(() => AgentCallOutputContractInputSchema).optional().describe("Structured output contract for this agent call. When set, the workflow runner extracts structured JSON from the agent's final response and validates it against the declared schema. The validated JSON is placed in the task output under the 'structured' key, enabling reliable downstream routing via switch_case expressions. When not set, the task output contains the agent's raw text response (backward compatible with existing workflows). @since T02 (Structured Agent Output Model)"),
|
|
83
|
+
harness: z.string().optional().describe("Execution harness for the agent invocation. Determines which execution engine processes the agent call: - HARNESS_UNSPECIFIED / HARNESS_NATIVE: Stigmer native engine (Python/LangGraph) - HARNESS_CURSOR: Cursor SDK engine (TypeScript/Cursor) The workflow-runner creates a Session with this harness before creating the AgentExecution. The harness is a session-level concern — it determines tool availability, state management, model access, and billing tier. When unspecified, defaults to HARNESS_NATIVE for backward compatibility. YAML Example: - code_review: call: agent with: agent: 'code-reviewer' harness: cursor message: 'Review this PR' Allowed values: HARNESS_NATIVE, HARNESS_CURSOR."),
|
|
84
|
+
});
|
|
85
|
+
const CallActivityTaskConfigInputSchema = z.object({
|
|
86
|
+
activity: z.string().describe("Activity name to execute. @internal Must match a registered Temporal activity."),
|
|
87
|
+
input: z.record(z.unknown()).optional().describe("Activity input (optional). Can be any JSON structure. Supports expressions in string values."),
|
|
88
|
+
});
|
|
89
|
+
const EmitEventInputSchema = z.object({
|
|
90
|
+
type: z.string().describe("CloudEvents type identifier. A reverse-DNS string that categorizes the event for routing and filtering. Examples: 'stigmer.workflow.ticket.classified', 'acme.order.completed'"),
|
|
91
|
+
source: z.string().optional().describe("CloudEvents source identifier. URI or URI-reference that identifies the context in which the event happened. Supports ${ } expression interpolation. When empty, the runtime defaults to the workflow execution URI (e.g., '/workflows/{workflow_id}/executions/{execution_id}')."),
|
|
92
|
+
data: z.record(z.unknown()).optional().describe("Event payload data. Arbitrary JSON object carried as the CloudEvents data attribute. Values within the Struct can contain ${ } expressions that the runtime evaluates before emission. Unlike other Struct fields in the workflow domain (response_schema, form_schema, schema) which carry JSON Schema definitions, this field carries the actual event payload — not a schema."),
|
|
93
|
+
subject: z.string().optional().describe("CloudEvents subject identifier. Describes the subject of the event in the context of the event producer. Supports ${ } expression interpolation. Examples: '${ $context.ticket.id }', '${ $context.order.number }'"),
|
|
94
|
+
});
|
|
95
|
+
const EmitEventTaskConfigInputSchema = z.object({
|
|
96
|
+
event: z.lazy(() => EmitEventInputSchema).describe("The event specification to emit. Contains the CloudEvents envelope fields (type, source, data, subject). Required field."),
|
|
97
|
+
});
|
|
98
|
+
const EvalCriterionInputSchema = z.object({
|
|
99
|
+
name: z.string().describe("Name of this evaluation dimension. Used in the judge prompt and appears in the output. Examples: 'accuracy', 'completeness', 'safety', 'relevance'"),
|
|
100
|
+
description: z.string().describe("Description of what this criterion measures. Included in the judge prompt to guide the LLM's assessment. Example: 'Does the response accurately reflect the source data without hallucinations?'"),
|
|
101
|
+
weight: z.number().optional().describe("Relative weight for computing the weighted average overall score. When all weights are equal (or all zero), criteria are averaged uniformly. Example: accuracy=3.0, formatting=1.0 means accuracy counts 3x more."),
|
|
102
|
+
});
|
|
103
|
+
const EvalTaskConfigInputSchema = z.object({
|
|
104
|
+
model: z.string().describe("LLM model used as the judge. Resolved via the Stigmer model registry. Examples: 'gpt-4o', 'claude-sonnet-4-5'"),
|
|
105
|
+
subject: z.string().describe("Expression selecting the data to evaluate. Supports ${ } expression interpolation. Example: '${ $context.summarize.text }' to evaluate a summary task's output."),
|
|
106
|
+
rubric: z.string().describe("Evaluation criteria in natural language. Tells the judge LLM what to assess and what 'good' looks like. For pass_fail: describe what constitutes a pass. For numeric_score: describe the scoring scale. For multi_criteria: provide overall context (per-criterion detail goes in criteria field)."),
|
|
107
|
+
scoring_mode: z.string().optional().describe("How the judge scores the subject. Default: EVAL_PASS_FAIL. Allowed values: EVAL_PASS_FAIL, EVAL_NUMERIC_SCORE, EVAL_MULTI_CRITERIA."),
|
|
108
|
+
threshold: z.number().optional().describe("Pass threshold for numeric_score and multi_criteria modes. The subject passes if score >= threshold. Ignored for pass_fail mode (the judge's binary decision is used directly). Valid range: 0.0 to 1.0. Default: 0.5."),
|
|
109
|
+
on_fail: z.string().optional().describe("Policy applied when the subject fails evaluation. Default: EVAL_FAIL_RAISE (task fails with evaluation error). Allowed values: EVAL_FAIL_RAISE, EVAL_FAIL_BRANCH, EVAL_FAIL_WARN."),
|
|
110
|
+
fallback_task: z.string().optional().describe("Target task to branch to when on_fail is EVAL_FAIL_BRANCH. Must reference a valid task name in the same workflow. Only meaningful when on_fail is EVAL_FAIL_BRANCH; ignored otherwise."),
|
|
111
|
+
system_prompt: z.string().optional().describe("Optional custom system prompt override for the judge LLM. When set, replaces the auto-generated judge system prompt entirely. Use only when the default judge prompt template does not fit your needs. When empty, the runtime constructs a judge-appropriate system prompt from the rubric, scoring_mode, and criteria."),
|
|
112
|
+
criteria: z.array(z.lazy(() => EvalCriterionInputSchema)).optional().describe("Evaluation criteria for multi_criteria mode. Required when scoring_mode is EVAL_MULTI_CRITERIA; ignored otherwise. Each criterion is scored independently, and the overall score is the weighted average (uniform if all weights are equal or zero)."),
|
|
113
|
+
max_cost_micros: z.union([z.number(), z.string()]).optional().describe("Per-task cost cap in micro-USD (1 USD = 1,000,000 micros). When set, the runtime terminates this eval call if its cost exceeds this limit, independent of the workflow-level budget. Optional — when 0, no per-task cost limit is enforced. @since T05 (Workflow-Level Budget Primitives)"),
|
|
114
|
+
});
|
|
115
|
+
const ForTaskConfigInputSchema = z.lazy(() => z.object({
|
|
116
|
+
each: z.string().describe("Variable name for each item in the iteration. Accessible via ${ $data.item } in expressions."),
|
|
117
|
+
in: z.string().describe("Expression evaluating to the collection to iterate over. Example: '${ $data.items }' or '${ [1, 2, 3] }'"),
|
|
118
|
+
do: z.array(z.lazy(() => WorkflowTaskInputSchema)).optional().describe("Tasks to execute for each iteration. Loop variables available: ${ $data.item }, ${ $data.index }"),
|
|
119
|
+
max_parallelism: z.number().optional().describe("Maximum number of iterations to execute concurrently. 0 (default): sequential execution — iterations run one at a time in input order. This preserves pre-T17 behavior. 1: effectively sequential (one at a time, but uses the parallel execution path — useful for testing). N > 1: up to N iterations run concurrently using Temporal workflow goroutines with a semaphore-based concurrency limiter. Results are always reassembled in original input order regardless of completion order. @since T17 (Advanced Agentic Orchestration)"),
|
|
120
|
+
batch_size: z.number().optional().describe("Number of items to process in each batch before moving to the next. 0 (default): no batching — all items are available for parallel execution (up to max_parallelism concurrent). N > 0: items are chunked into groups of N. Each chunk is fully processed before the next chunk begins. Within each chunk, up to max_parallelism iterations run concurrently. Only meaningful when max_parallelism > 0; ignored in sequential mode. @since T17 (Advanced Agentic Orchestration)"),
|
|
121
|
+
on_error: z.string().optional().describe("Policy for handling individual iteration failures. Default: FOR_EACH_FAIL_FAST (stop on first error). Only meaningful when max_parallelism > 0; in sequential mode, any failure stops the loop regardless of this setting (pre-T17 behavior). @since T17 (Advanced Agentic Orchestration) Allowed values: FOR_EACH_FAIL_FAST, FOR_EACH_CONTINUE, FOR_EACH_SKIP."),
|
|
122
|
+
}));
|
|
123
|
+
const ForkBranchInputSchema = z.lazy(() => z.object({
|
|
124
|
+
name: z.string().describe("Branch name/identifier."),
|
|
125
|
+
do: z.array(z.lazy(() => WorkflowTaskInputSchema)).optional().describe("Tasks to execute in this branch."),
|
|
126
|
+
}));
|
|
127
|
+
const ForkTaskConfigInputSchema = z.lazy(() => z.object({
|
|
128
|
+
branches: z.array(z.lazy(() => ForkBranchInputSchema)).optional().describe("Branches to execute in parallel (at least 2 required)."),
|
|
129
|
+
compete: z.boolean().optional().describe("If true, first branch to complete wins (race mode). If false, all branches must complete (default)."),
|
|
130
|
+
}));
|
|
131
|
+
const GrpcCallTaskConfigInputSchema = z.object({
|
|
132
|
+
service: z.string().describe("Fully qualified service name. Example: 'com.example.UserService'"),
|
|
133
|
+
method: z.string().describe("Method name to call. Example: 'GetUser'"),
|
|
134
|
+
request: z.record(z.unknown()).optional().describe("Request message (optional). Can be any JSON structure matching the proto schema. Supports expressions in string values."),
|
|
135
|
+
});
|
|
136
|
+
const HttpEndpointInputSchema = z.object({
|
|
137
|
+
uri: z.string().describe("URI of the endpoint. Can contain expressions: 'https://api.example.com/${.resource}'"),
|
|
138
|
+
});
|
|
139
|
+
const HttpCallTaskConfigInputSchema = z.object({
|
|
140
|
+
method: z.string().describe("HTTP method (GET, POST, PUT, DELETE, PATCH). Allowed values: GET, POST, PUT, DELETE, PATCH."),
|
|
141
|
+
endpoint: z.lazy(() => HttpEndpointInputSchema).describe("HTTP endpoint configuration."),
|
|
142
|
+
headers: z.record(z.string()).optional().describe("HTTP headers (optional). Values can contain expressions: 'Bearer ${TOKEN}'"),
|
|
143
|
+
body: z.record(z.unknown()).optional().describe("Request body (optional). Can be any JSON structure. Supports expressions in string values."),
|
|
144
|
+
timeout_seconds: z.number().optional().describe("Request timeout in seconds (optional, default: 30)."),
|
|
145
|
+
});
|
|
146
|
+
const HumanInputOutcomeInputSchema = z.object({
|
|
147
|
+
name: z.string().describe("Outcome identifier used in task output and routing. Examples: 'approve', 'deny', 'needs_revision', 'escalate', 'defer' Must be unique within the outcomes list."),
|
|
148
|
+
label: z.string().optional().describe("Human-readable label for the button/action in the approval UI. When empty, the UI displays the capitalized name. Examples: 'Approve Escalation', 'Reject — Not Customer-Impacting'"),
|
|
149
|
+
then: z.string().optional().describe("Task to branch to when this outcome is selected. Must reference a valid task name in the same workflow. When empty, the workflow continues to the next task in sequence."),
|
|
150
|
+
});
|
|
151
|
+
const HumanInputTaskConfigInputSchema = z.object({
|
|
152
|
+
prompt: z.string().describe("Message shown to the reviewer explaining what needs approval or input. Supports ${ } expression interpolation for injecting workflow context. Example: 'Approve escalation for ticket ${ $context.ticket.id }?'"),
|
|
153
|
+
form_schema: z.record(z.unknown()).optional().describe("JSON Schema defining the input form rendered to the reviewer. When set, the approval UI renders a typed form based on this schema. The reviewer's form response is validated against the schema before the task completes, and the validated data appears in the task output under the 'form_data' key. When not set, the reviewer sees only the outcome buttons (approve/deny or custom outcomes) without a data entry form. Uses the same google.protobuf.Struct + JSON Schema pattern as AgentCallOutputContract.schema and LlmCallTaskConfig.response_schema."),
|
|
154
|
+
outcomes: z.array(z.lazy(() => HumanInputOutcomeInputSchema)).optional().describe("Named outcomes that the reviewer can select. Each outcome represents a decision the reviewer can make, with optional routing to a different downstream task. This enables rich branching beyond binary approve/deny. When empty, the task defaults to binary behavior: - 'approve': task completes, workflow continues to next task - 'deny': task fails (enters try_catch or EXECUTION_FAILED) When custom outcomes are defined, the first outcome is used as the default for HUMAN_INPUT_TIMEOUT_APPROVE, and the last outcome is used as the default for HUMAN_INPUT_TIMEOUT_DENY."),
|
|
155
|
+
approvers: z.array(z.string()).optional().describe("Approver identifiers — who is allowed to respond to this task. Supports user IDs, team slugs, and role names. Format examples: - 'user:jane@acme.com' — specific user - 'team:engineering-leads' — any member of the team - 'role:content-admin' — any user with the role When empty, any authenticated user can respond. Resolution of these identifiers is a runtime concern (T13)."),
|
|
156
|
+
timeout: z.number().optional().describe("Timeout in seconds before the on_timeout policy applies. Default: 0 (no timeout — the task waits indefinitely). Max: 2592000 (30 days). A timeout of 0 means the workflow will wait until a human responds. For production workflows, setting a timeout with an appropriate on_timeout policy is strongly recommended."),
|
|
157
|
+
on_timeout: z.string().optional().describe("Policy applied when the timeout expires without a response. Only meaningful when timeout > 0; ignored when timeout is 0. Default: HUMAN_INPUT_TIMEOUT_FAIL (task fails with timeout error). Allowed values: HUMAN_INPUT_TIMEOUT_FAIL, HUMAN_INPUT_TIMEOUT_APPROVE, HUMAN_INPUT_TIMEOUT_DENY, HUMAN_INPUT_TIMEOUT_ESCALATE."),
|
|
158
|
+
notification_channels: z.array(z.string()).optional().describe("Channel identifiers for sending approval request notifications. When the task starts, the runtime sends notifications through these channels to alert potential approvers. Format examples: - 'slack:#approvals' — Slack channel - 'email:ops@acme.com' — email address - 'teams:#incident-response' — Microsoft Teams channel The format and routing of notifications is a runtime concern (T13). The proto carries the identifiers; the runtime resolves them to actual notification providers configured in the workflow instance's environment."),
|
|
159
|
+
});
|
|
160
|
+
const SignalInputSchema = z.object({
|
|
161
|
+
id: z.string().describe("Signal identifier."),
|
|
162
|
+
type: z.string().describe("Signal type: 'signal', 'query', or 'update'. Allowed values: signal, query, update."),
|
|
163
|
+
});
|
|
164
|
+
const ListenToInputSchema = z.object({
|
|
165
|
+
mode: z.string().describe("Listening mode: - 'one': Wait for any one signal - 'all': Wait for all signals Allowed values: one, all."),
|
|
166
|
+
signals: z.array(z.lazy(() => SignalInputSchema)).optional().describe("Signals to listen for."),
|
|
167
|
+
});
|
|
168
|
+
const ListenTaskConfigInputSchema = z.object({
|
|
169
|
+
to: z.lazy(() => ListenToInputSchema).describe("Signal listening configuration."),
|
|
170
|
+
});
|
|
171
|
+
const LlmCallTaskConfigInputSchema = z.object({
|
|
172
|
+
model: z.string().describe("Model reference resolved via the Stigmer model registry. Examples: 'gpt-4o', 'gpt-4o-mini', 'claude-sonnet-4-5', 'claude-haiku-3-5' Required field."),
|
|
173
|
+
system_prompt: z.string().optional().describe("System prompt that sets the LLM's role and constraints. Supports ${ } expression interpolation for dynamic system prompts. Optional — omit for tasks where the user prompt is self-contained."),
|
|
174
|
+
prompt: z.string().describe("User prompt / instruction sent to the LLM. Supports ${ } expression interpolation for injecting workflow context. Example: 'Classify this ticket: ${ $context.ticket.description }' Required field."),
|
|
175
|
+
response_schema: z.record(z.unknown()).optional().describe("JSON Schema for structured output. When set, the runner requests structured output from the provider (e.g., OpenAI's response_format, Anthropic's tool_use extraction) and validates the response against this schema. Uses the same google.protobuf.Struct + JSON Schema pattern as AgentCallOutputContract.schema for consistency across the workflow domain. When not set, the task output is the LLM's raw text response."),
|
|
176
|
+
temperature: z.number().optional().describe("Sampling temperature (0.0 to 2.0). Lower = more deterministic, higher = more creative. Range is 0.0-2.0 to accommodate all major providers (OpenAI supports up to 2.0; others clamp to their supported range at runtime). Optional — uses the provider's default when not set."),
|
|
177
|
+
max_tokens: z.number().optional().describe("Maximum tokens in the LLM response. Optional — uses the provider's default when not set."),
|
|
178
|
+
timeout: z.number().optional().describe("Timeout for the LLM call in seconds. Default: 60. Max: 600 (10 minutes). Optional."),
|
|
179
|
+
on_invalid: z.string().optional().describe("Policy when the LLM response fails schema validation. Only meaningful when response_schema is set; ignored otherwise. Default: ON_INVALID_FAIL (task fails immediately). Allowed values: ON_INVALID_FAIL, ON_INVALID_RETRY, ON_INVALID_FALLBACK."),
|
|
180
|
+
max_retries: z.number().optional().describe("Maximum schema-validation retry attempts when on_invalid is ON_INVALID_RETRY. Each retry re-prompts the LLM with the validation errors and expected schema, giving it an opportunity to self-correct. Only meaningful when on_invalid is ON_INVALID_RETRY; ignored otherwise. Default: 1. Valid range: 1-5."),
|
|
181
|
+
fallback_task: z.string().optional().describe("Target task to branch to when schema validation cannot be resolved. Used in two scenarios: 1. on_invalid is ON_INVALID_RETRY and all retries are exhausted 2. on_invalid is ON_INVALID_FALLBACK (immediate branch, no retry) Must reference a valid task name in the same workflow. When empty and retries are exhausted, the task fails."),
|
|
182
|
+
max_cost_micros: z.union([z.number(), z.string()]).optional().describe("Per-task cost cap in micro-USD (1 USD = 1,000,000 micros). When set, the runtime terminates this specific LLM call if its cost exceeds this limit, independent of the workflow-level budget. The runtime checks both: per-task limit first, then workflow remaining budget. Optional — when 0, no per-task cost limit is enforced. @since T05 (Workflow-Level Budget Primitives)"),
|
|
183
|
+
max_total_tokens: z.union([z.number(), z.string()]).optional().describe("Per-task token cap (input + output tokens combined). When set, the runtime terminates this specific LLM call if total tokens exceed this limit. Complements max_tokens (field 6), which limits only the output token count as a generation parameter. Optional — when 0, no per-task total token limit is enforced. @since T05 (Workflow-Level Budget Primitives)"),
|
|
184
|
+
});
|
|
185
|
+
const NotificationTaskConfigInputSchema = z.object({
|
|
186
|
+
channel: z.string().describe("Notification channel identifier. Determines which notification provider processes this message. Common values: 'slack', 'email', 'discord', 'teams', 'webhook' This is a string (not an enum) for extensibility — new channels can be added without proto changes. The runtime resolves the channel to its configured provider in the workflow instance's environment."),
|
|
187
|
+
recipients: z.array(z.string()).optional().describe("Recipient identifiers for the notification. Format depends on the channel: - slack: '#channel-name', '@username', or Slack user IDs - email: 'user@example.com' - discord: '#channel-name', '@role' - teams: '#channel-name' - webhook: URL or webhook identifier At least one recipient is required. Individual values may contain ${ } expressions that the runtime evaluates before delivery (e.g., '${ $context.customer.email }')."),
|
|
188
|
+
subject: z.string().optional().describe("Notification subject or title. Supports ${ } expression interpolation. Used as: email subject line, Slack message title, webhook payload title. Optional — some channels (e.g., simple Slack messages) may not use it."),
|
|
189
|
+
body: z.string().describe("Notification body / message content. Supports ${ } expression interpolation. The primary content of the notification. Formatting depends on channel (e.g., Slack Markdown, HTML for email, plain text for SMS). When template is also set, body serves as the fallback content if the template cannot be resolved."),
|
|
190
|
+
template: z.string().optional().describe("Named template reference for rendering the notification. When set, the runtime looks up this template in the workflow instance's environment and uses it for rendering, with the workflow context as template data. The body field is used as fallback if the template cannot be resolved. Examples: 'incident-alert', 'order-confirmation', 'approval-request' Template resolution and rendering is a runtime concern (T13)."),
|
|
191
|
+
metadata: z.record(z.string()).optional().describe("Channel-specific metadata as key-value pairs. Provides additional configuration that varies by notification channel: - slack: {'thread_ts': '...', 'unfurl_links': 'false'} - email: {'priority': 'high', 'reply_to': '...', 'cc': '...'} - webhook: {'method': 'POST', 'content_type': 'application/json'} Values may contain ${ } expressions that the runtime evaluates before delivery."),
|
|
192
|
+
});
|
|
193
|
+
const RaiseTaskConfigInputSchema = z.object({
|
|
194
|
+
error: z.string().describe("Error type/name."),
|
|
195
|
+
message: z.string().describe("Error message. Can contain expressions: '${ .errorMessage }'"),
|
|
196
|
+
});
|
|
197
|
+
const RunTaskConfigInputSchema = z.object({
|
|
198
|
+
workflow: z.string().describe("Sub-workflow name/identifier to execute."),
|
|
199
|
+
input: z.record(z.unknown()).optional().describe("Sub-workflow input (optional). Can be any JSON structure. Supports expressions in string values."),
|
|
200
|
+
});
|
|
201
|
+
const SetTaskConfigInputSchema = z.object({
|
|
202
|
+
variables: z.record(z.string()).describe("Variables to set in workflow state. Keys are variable names, values can be literals or expressions. Expressions use ${...} syntax, e.g., '${.a + .b}' or '${now}'"),
|
|
203
|
+
});
|
|
204
|
+
const SwitchCaseInputSchema = z.object({
|
|
205
|
+
name: z.string().describe("Case name/identifier."),
|
|
206
|
+
when: z.string().optional().describe("Condition expression (optional). If empty, this is the default case. Example: '${ $context.value > 5 }'"),
|
|
207
|
+
then: z.string().describe("Target task name to execute if condition matches."),
|
|
208
|
+
});
|
|
209
|
+
const SwitchTaskConfigInputSchema = z.object({
|
|
210
|
+
cases: z.array(z.lazy(() => SwitchCaseInputSchema)).optional().describe("List of switch cases (at least one required). Cases are evaluated in order. First matching case executes. If no 'when' is specified, the case acts as default."),
|
|
211
|
+
});
|
|
212
|
+
const TransformTaskConfigInputSchema = z.object({
|
|
213
|
+
engine: z.string().describe("Transformation engine to use. Required — must be explicitly set (not UNSPECIFIED). Allowed values: TRANSFORM_ENGINE_JQ, TRANSFORM_ENGINE_JSONATA, TRANSFORM_ENGINE_TEMPLATE."),
|
|
214
|
+
expression: z.string().describe("Transformation expression in the chosen engine's syntax. For JQ: a JQ filter expression (e.g., '{name: .full_name}') For JSONata: a JSONata expression (e.g., '{'name': full_name}') For TEMPLATE: a Go text/template string with {{ }} placeholders Required field."),
|
|
215
|
+
input: z.string().optional().describe("Expression selecting the input data for the transformation. Supports ${ } expression interpolation. When omitted, the entire workflow context is used as input. Example: '${ $context.triage }' to transform just the triage output."),
|
|
216
|
+
});
|
|
217
|
+
const CatchBlockInputSchema = z.lazy(() => z.object({
|
|
218
|
+
as: z.string().optional().describe("Variable name to store the error (optional). Accessible via ${ .error } in catch tasks."),
|
|
219
|
+
do: z.array(z.lazy(() => WorkflowTaskInputSchema)).optional().describe("Tasks to execute when error is caught."),
|
|
220
|
+
compensate: z.boolean().optional().describe("Whether to run compensation tasks for already-completed try tasks before executing the catch do block. When true, the runtime walks the compensation stack (completed tasks that declared a 'compensate' block) in reverse order and executes each task's compensation actions. After all compensations complete (or fail), the catch 'do' block runs as normal. Compensation failures do not prevent the catch block from running. They are logged and included in the task output for diagnostics. Default: false (no compensation — preserves pre-T17 behavior). @since T17 (Advanced Agentic Orchestration)"),
|
|
221
|
+
}));
|
|
222
|
+
const TryTaskConfigInputSchema = z.lazy(() => z.object({
|
|
223
|
+
try: z.array(z.lazy(() => WorkflowTaskInputSchema)).optional().describe("Tasks to attempt (at least one required). If any task fails, execution jumps to catch block."),
|
|
224
|
+
catch: z.lazy(() => CatchBlockInputSchema).optional().describe("Catch block for error handling (optional). If not provided, errors propagate to parent."),
|
|
225
|
+
}));
|
|
226
|
+
const ValidationRuleInputSchema = z.object({
|
|
227
|
+
name: z.string().describe("Rule identifier for error reporting and debugging. Appears in validation error output so operators can identify which specific rule failed. Examples: 'critical_needs_rationale', 'customer_impact_requires_high_severity'"),
|
|
228
|
+
expression: z.string().describe("Boolean expression that must evaluate to true for the rule to pass. Supports ${ } expression interpolation. The expression receives the validate task's input data as its context. Example: '${ .severity != 'critical' || (.rationale != null && .rationale != '') }'"),
|
|
229
|
+
message: z.string().optional().describe("Error message included in validation output when the rule fails. Supports ${ } expression interpolation for dynamic error messages. When empty, a generic message is generated from the rule name. Example: 'Critical severity requires a rationale'"),
|
|
230
|
+
});
|
|
231
|
+
const ValidateTaskConfigInputSchema = z.object({
|
|
232
|
+
input: z.string().describe("Expression selecting the data to validate. Supports ${ } expression interpolation. Example: '${ $context.triage }' to validate the triage task's output."),
|
|
233
|
+
schema: z.record(z.unknown()).optional().describe("JSON Schema to validate the input data against. Standard JSON Schema (draft 2020-12 or compatible). The runtime validates the input data against this schema and reports detailed errors for any constraint violations. Uses the same google.protobuf.Struct + JSON Schema pattern as AgentCallOutputContract.schema, LlmCallTaskConfig.response_schema, and HumanInputTaskConfig.form_schema. At least one of schema or rules must be set."),
|
|
234
|
+
rules: z.array(z.lazy(() => ValidationRuleInputSchema)).optional().describe("Business rules to evaluate against the input data. Each rule is a boolean expression that must evaluate to true. Rules complement schema validation by expressing constraints that JSON Schema cannot: cross-field dependencies, conditional requirements, and domain-specific invariants. At least one of schema or rules must be set."),
|
|
235
|
+
on_fail: z.string().optional().describe("Policy applied when validation fails. Default: VALIDATION_FAIL_RAISE (task fails with validation error). Allowed values: VALIDATION_FAIL_RAISE, VALIDATION_FAIL_BRANCH, VALIDATION_FAIL_WARN."),
|
|
236
|
+
fallback_task: z.string().optional().describe("Target task to branch to when on_fail is VALIDATION_FAIL_BRANCH. Must reference a valid task name in the same workflow. Only meaningful when on_fail is VALIDATION_FAIL_BRANCH; ignored otherwise. When on_fail is BRANCH and fallback_task is empty, the task fails."),
|
|
237
|
+
});
|
|
238
|
+
const DurationInputSchema = z.object({
|
|
239
|
+
days: z.number().optional().describe("Number of days to wait (24 hours each)."),
|
|
240
|
+
hours: z.number().optional().describe("Number of hours to wait."),
|
|
241
|
+
minutes: z.number().optional().describe("Number of minutes to wait."),
|
|
242
|
+
seconds: z.number().optional().describe("Number of seconds to wait."),
|
|
243
|
+
milliseconds: z.number().optional().describe("Number of milliseconds to wait."),
|
|
244
|
+
});
|
|
245
|
+
const WaitTaskConfigInputSchema = z.object({
|
|
246
|
+
duration: z.lazy(() => DurationInputSchema).optional().describe("Relative duration to wait from now. Use this when you want to wait for a specific amount of time regardless of when the workflow reaches this task. Example: { days: 7 } = wait 1 week from now"),
|
|
247
|
+
until: z.string().optional().describe("Absolute timestamp to wait until. Use this when you want to wait until a specific point in time. If the timestamp is in the past, the task completes immediately. Example: '2026-03-01T09:00:00Z' = wait until March 1st, 2026 at 9am UTC"),
|
|
248
|
+
});
|
|
249
|
+
const ExportInputSchema = z.object({
|
|
250
|
+
as: z.string().optional().describe("Expression defining how to export output using ${...} syntax."),
|
|
251
|
+
});
|
|
252
|
+
const FlowControlInputSchema = z.object({
|
|
253
|
+
then: z.string().optional().describe("Target task name or 'end' to terminate workflow."),
|
|
254
|
+
});
|
|
255
|
+
const WorkflowTaskInputSchema = z.lazy(() => z.object({
|
|
256
|
+
name: z.string().optional().describe("Task name/identifier (must be unique within workflow). Must be a valid C-style identifier: starts with a letter or underscore, followed by letters, digits, or underscores."),
|
|
257
|
+
kind: z.string().describe("Task type. Set the matching config field (e.g. kind='http_call' -> populate http_call). Allowed values: set_vars, http_call, grpc_call, activity_call, switch_case, for_each, fork, try_catch, listen, wait, raise_error, run_workflow, agent_call, llm_call, transform, human_input, validate, emit_event, notification, eval."),
|
|
258
|
+
agent_call: z.lazy(() => AgentCallTaskConfigInputSchema).optional().describe("Required when kind='agent_call'. AgentCallTaskConfig defines the configuration for agent_call tasks that invoke AI agents. @internal The agent is referenced by org/slug format (e.g., 'stigmer/code-reviewer'). Resolution order: 1. If org is specified: look in that org's agents 2. If org is empty: use the workflow's org 3. Before external lookup, check manifest (current deployment) The workflow's execution context (environment variables, secrets) is passed to the agent invocation, allowing agents to access workflow state. YAML Example (without structured output): - analyze: call: agent with: agent: 'code-reviewer' message: 'Review this code: ${ $context.fetchCode.body }' env: GITHUB_TOKEN: '${ .secrets.GH_TOKEN }' config: model: 'claude-3-5-sonnet' timeout: 300 YAML Example (with structured output): - triage_ticket: call: agent with: agent: 'support-triage' message: '${ .ticket.description }' output: schema: type: object required: [severity, category, customer_impact] properties: severity: type: string enum: [low, medium, high, critical] category: type: string customer_impact: type: boolean rationale: type: string on_invalid: ON_INVALID_RETRY max_retries: 2 fallback_task: human_review export: as: '${ .structured }' Reference: design doc at stigmer/_cursor/add-agent-config-to-workflow.md"),
|
|
259
|
+
activity_call: z.lazy(() => CallActivityTaskConfigInputSchema).optional().describe("Required when kind='activity_call'. CallActivityTaskConfig defines the configuration for activity_call tasks that execute activities. @internal Executes Temporal activities. YAML Example: - taskName: call: activity with: activity: 'ProcessDataActivity' input: data: ${ .data } Reference: zigflow-dsl-pattern-catalog.md - Task Type 10"),
|
|
260
|
+
emit_event: z.lazy(() => EmitEventTaskConfigInputSchema).optional().describe("Required when kind='emit_event'. EmitEventTaskConfig defines the configuration for emit_event tasks that publish CloudEvents to external consumers, other workflows, audit trails, and metrics systems. @internal emit_event is the complement to listen. While listen waits for Temporal signals (internal workflow primitives), emit_event publishes business events using the CloudEvents envelope (a standard external contract). The runtime (T13) bridges the two: an emitted CloudEvent can be delivered as a Temporal signal to another workflow's listen task, or routed to external consumers via message queues, webhooks, or event buses. The task output is the fully-resolved CloudEvents envelope with runtime-generated fields populated: { 'id': '<generated UUID>', 'specversion': '1.0', 'type': 'stigmer.workflow.ticket.classified', 'source': '/workflows/triage/executions/abc-123', 'time': '2026-05-12T14:30:00Z', 'subject': 'TICKET-456', 'datacontenttype': 'application/json', 'data': { <resolved payload> } } YAML Example (emit a classification event): - notify_classified: emit_event: event: type: 'stigmer.workflow.ticket.classified' subject: '${ $context.ticket.id }' data: ticket_id: '${ $context.ticket.id }' severity: '${ $context.triage.severity }' category: '${ $context.triage.category }' classified_by: '${ $context.workflow_instance_id }' export: as: '${ . }' YAML Example (emit with explicit source): - publish_completion: emit_event: event: type: 'acme.order.fulfilled' source: 'urn:acme:fulfillment-service' subject: '${ $context.order.number }' data: order_id: '${ $context.order.id }' status: 'fulfilled' fulfilled_at: '${ $context.timestamp }' export: as: '${ . }'"),
|
|
261
|
+
eval: z.lazy(() => EvalTaskConfigInputSchema).optional().describe("Required when kind='eval'. EvalTaskConfig defines the configuration for eval tasks that use an LLM judge to assess the semantic quality of workflow data. @internal Use eval when you need to assess quality, correctness, safety, or completeness of LLM-generated or agent-produced content. This fills the gap between structural validation (validate task — JSON Schema, business rules) and human review (human_input task — manual inspection). The eval task constructs a judge prompt from the rubric and subject, calls the specified LLM with structured output enforcement, parses the judge's response, and applies the threshold to determine pass/fail. Key differences from validate: - validate checks deterministic structural properties (schema, rules) - eval checks semantic quality via an LLM judge (hallucination, relevance, safety) Key differences from llm_call: - llm_call is a general-purpose LLM invocation - eval has built-in judge prompt construction, scoring semantics, threshold application, and on_fail branching Task output structure: { 'pass': true/false, 'score': 0.85, // present for numeric_score and multi_criteria 'reasoning': 'The response...', 'criteria': [ // present only for multi_criteria {'name': 'accuracy', 'score': 0.9, 'reasoning': '...'}, {'name': 'safety', 'score': 0.8, 'reasoning': '...'} ], 'model_used': 'gpt-4o', 'subject': <original subject data> } YAML Example (binary pass/fail evaluation): - check_summary_quality: call: eval with: model: 'gpt-4o' subject: '${ $context.summarize.text }' rubric: | Evaluate whether this summary accurately captures the key points of the source document without hallucinations or omissions. The summary should be concise (under 3 sentences) and factually correct. scoring_mode: EVAL_PASS_FAIL on_fail: EVAL_FAIL_BRANCH fallback_task: regenerate_summary export: as: '${ . }' YAML Example (numeric score with threshold): - score_translation: call: eval with: model: 'gpt-4o' subject: '${ $context.translate.text }' rubric: | Rate the quality of this translation on accuracy, fluency, and preservation of meaning. Score 0.0 (unusable) to 1.0 (perfect). scoring_mode: EVAL_NUMERIC_SCORE threshold: 0.7 on_fail: EVAL_FAIL_WARN export: as: '${ . }' YAML Example (multi-criteria evaluation): - evaluate_response: call: eval with: model: 'gpt-4o' subject: '${ $context.agent_response }' rubric: 'Evaluate this customer support response.' scoring_mode: EVAL_MULTI_CRITERIA threshold: 0.75 criteria: - name: accuracy description: 'Is the information factually correct?' weight: 3.0 - name: helpfulness description: 'Does it address the customer's actual question?' weight: 2.0 - name: tone description: 'Is the tone professional and empathetic?' weight: 1.0 on_fail: EVAL_FAIL_RAISE export: as: '${ . }'"),
|
|
262
|
+
for_each: z.lazy(() => ForTaskConfigInputSchema).optional().describe("Required when kind='for_each'. ForTaskConfig defines the configuration for for_each tasks that iterate over collections. @internal Supports both sequential (default) and parallel execution modes. When max_parallelism is set, iterations run concurrently using Temporal workflow goroutines with bounded concurrency. Backward compatibility: all new fields default to values that preserve the pre-T17 sequential behavior. Existing workflows require no changes. YAML Example (sequential, unchanged from pre-T17): - taskName: for: each: item in: ${ $data.items } do: - processItem: call: http with: method: POST body: item: ${ $data.item } index: ${ $data.index } YAML Example (parallel with bounded concurrency): - batchProcess: for: each: item in: ${ $data.items } max_parallelism: 5 on_error: FOR_EACH_CONTINUE do: - callApi: call: http with: method: POST endpoint: uri: 'https://api.example.com/process' body: item: ${ $data.item } Reference: zigflow-dsl-pattern-catalog.md - Task Type 4 @since max_parallelism, batch_size, on_error: T17 (Advanced Agentic Orchestration)"),
|
|
263
|
+
fork: z.lazy(() => ForkTaskConfigInputSchema).optional().describe("Required when kind='fork'. ForkTaskConfig defines the configuration for fork tasks that execute branches in parallel. @internal YAML Example: - taskName: fork: branches: - branch1: do: - task1: call: http with: method: POST endpoint: uri: https://api.example.com/branch1 - branch2: do: - task2: call: http Reference: zigflow-dsl-pattern-catalog.md - Task Type 5"),
|
|
264
|
+
grpc_call: z.lazy(() => GrpcCallTaskConfigInputSchema).optional().describe("Required when kind='grpc_call'. GrpcCallTaskConfig defines the configuration for grpc_call tasks that make gRPC requests. @internal YAML Example: - taskName: call: grpc with: service: 'com.example.UserService' method: 'GetUser' request: userId: ${ .userId } Reference: zigflow-dsl-pattern-catalog.md - Task Type 9"),
|
|
265
|
+
http_call: z.lazy(() => HttpCallTaskConfigInputSchema).optional().describe("Required when kind='http_call'. HttpCallTaskConfig defines the configuration for http_call tasks that make HTTP requests. @internal YAML Example: - taskName: call: http with: method: POST endpoint: uri: https://api.example.com/data headers: Authorization: 'Bearer ${TOKEN}' body: field1: value Reference: zigflow-dsl-pattern-catalog.md - Task Type 2"),
|
|
266
|
+
human_input: z.lazy(() => HumanInputTaskConfigInputSchema).optional().describe("Required when kind='human_input'. HumanInputTaskConfig defines the configuration for human_input tasks that pause workflow execution to collect typed input or approval from a human reviewer, then resume based on the reviewer's response. @internal Use human_input when a workflow needs human judgment before proceeding: approvals before API calls, sign-off before publishing, confirmation before customer-impacting actions, or structured data collection from a human operator. This is a workflow-level approval gate — distinct from agent-level HITL (tool approval inside an agent session). Workflow-level gates are visible in the execution viewer as explicit tasks with input/output/timing, and they can route to different branches based on the reviewer's decision. Runtime implementation (T13) will use Temporal signals for workflow resumption. The proto definition is intentionally runtime-agnostic. The reviewer's response (selected outcome + form data) becomes the task output, accessible via export: { 'outcome': 'approve', 'form_data': { <validated form response if form_schema is set> }, 'reviewer': '<user who responded>', 'responded_at': '<ISO 8601 timestamp>' } YAML Example (approval gate with custom outcomes): - manager_approval: human_input: prompt: 'Customer-impacting incident classified as ${ $context.triage.severity }. Approve escalation?' form_schema: type: object properties: notes: type: string description: 'Optional notes for the engineering team' priority_override: type: string enum: [P1, P2, P3] outcomes: - name: approve label: 'Approve Escalation' - name: deny label: 'Reject — Not Customer-Impacting' then: re_classify - name: needs_revision label: 'Needs More Info' then: gather_more_context approvers: - 'team:engineering-leads' timeout: 86400 on_timeout: HUMAN_INPUT_TIMEOUT_ESCALATE notification_channels: - 'slack:#incident-approvals' export: as: '${ . }' YAML Example (simple binary approval, no form): - confirm_publish: human_input: prompt: 'Ready to publish ${ $context.document.title } to production?' approvers: - 'role:content-admin' timeout: 3600 on_timeout: HUMAN_INPUT_TIMEOUT_FAIL export: as: '${ . }'"),
|
|
267
|
+
listen: z.lazy(() => ListenTaskConfigInputSchema).optional().describe("Required when kind='listen'. ListenTaskConfig defines the configuration for listen tasks that wait for external signals. @internal Implemented via Temporal signals. YAML Example: - taskName: listen: to: one: with: id: approval_signal type: signal Reference: zigflow-dsl-pattern-catalog.md - Task Type 7"),
|
|
268
|
+
llm_call: z.lazy(() => LlmCallTaskConfigInputSchema).optional().describe("Required when kind='llm_call'. LlmCallTaskConfig defines the configuration for llm_call tasks that make direct LLM API calls without the overhead of a full agent invocation. @internal Use llm_call when the task is focused and deterministic: classification, extraction, scoring, summarization, moderation, or routing. An agent_call carries setup overhead (system prompt, tool resolution, MCP server setup, session management) that is unnecessary when all you need is a single prompt-response cycle with optional structured output. When response_schema is set, the runner requests structured output from the provider and validates the response against the schema. The on_invalid / max_retries / fallback_task fields control what happens when validation fails, using the same OnInvalidOutputPolicy enum as agent_call's output contract. YAML Example (classification with structured output): - classify_severity: call: llm with: model: 'gpt-4o-mini' system_prompt: 'You are a support ticket classifier.' prompt: 'Classify this ticket: ${ $context.ticket.description }' response_schema: type: object required: [severity, category] properties: severity: type: string enum: [low, medium, high, critical] category: type: string on_invalid: ON_INVALID_RETRY max_retries: 2 export: as: '${ . }' YAML Example (simple summarization, no schema): - summarize: call: llm with: model: 'claude-sonnet-4-5' prompt: 'Summarize in 2 sentences: ${ $context.document.text }' temperature: 0.3 max_tokens: 200 export: as: '${ . }'"),
|
|
269
|
+
notification: z.lazy(() => NotificationTaskConfigInputSchema).optional().describe("Required when kind='notification'. NotificationTaskConfig defines the configuration for notification tasks that send messages to humans through channels like Slack, email, Discord, Microsoft Teams, or webhooks. @internal notification is a convenience abstraction for 'send a message to humans' — simpler and more intuitive than emit_event for common operational notification patterns. While emit_event publishes system-level CloudEvents for machine consumption, notification is purpose-built for human-readable messages with channel routing and recipient targeting. Key distinction from related task types: emit_event = system-to-system (CloudEvents, consumed by workflows/services) notification = system-to-human (Slack, email, Discord — read by people) human_input = system-to-human-to-system (waits for a response; notification is fire-and-forget) Notifications are fire-and-forget by default. The task output confirms delivery was attempted but does not wait for acknowledgment: { 'channel': 'slack', 'recipients': ['#incident-response'], 'delivered': true, 'delivered_at': '<ISO 8601 timestamp>' } For notifications that require acknowledgment or a response, use human_input instead — it pauses the workflow until a human responds. The channel field is a string (not an enum) to allow extensibility: new notification channels can be added without proto changes. The runtime (T13) resolves channel identifiers to actual notification providers configured in the workflow instance's environment. YAML Example (Slack notification): - alert_slack: notification: channel: 'slack' recipients: - '#incident-response' - '@oncall-lead' subject: 'P${ $context.triage.severity } Incident: ${ $context.ticket.title }' body: | *Severity*: ${ $context.triage.severity } *Category*: ${ $context.triage.category } *Customer Impact*: ${ $context.triage.customer_impact } *Summary*: ${ $context.agent_analysis.structured.summary } metadata: thread_ts: '${ $context.slack_thread_id }' export: as: '${ . }' YAML Example (email with template): - send_confirmation: notification: channel: 'email' recipients: - '${ $context.customer.email }' subject: 'Order ${ $context.order.number } Confirmed' body: 'Your order has been confirmed. You will receive tracking information shortly.' template: 'order-confirmation' metadata: priority: 'high' reply_to: 'support@acme.com' export: as: '${ . }'"),
|
|
270
|
+
raise_error: z.lazy(() => RaiseTaskConfigInputSchema).optional().describe("Required when kind='raise_error'. RaiseTaskConfig defines the configuration for raise_error tasks that raise errors. @internal YAML Example: - taskName: raise: error: ValidationError message: ${ .errorMessage } Reference: zigflow-dsl-pattern-catalog.md - Task Type 11"),
|
|
271
|
+
run_workflow: z.lazy(() => RunTaskConfigInputSchema).optional().describe("Required when kind='run_workflow'. RunTaskConfig defines the configuration for run_workflow tasks that execute sub-workflows. @internal Implemented via Temporal child workflows. YAML Example: - taskName: run: workflow: 'sub-workflow-name' input: data: ${ .data } Reference: zigflow-dsl-pattern-catalog.md - Task Type 12"),
|
|
272
|
+
set_vars: z.lazy(() => SetTaskConfigInputSchema).optional().describe("Required when kind='set_vars'. SetTaskConfig defines the configuration for set_vars tasks that assign variables in workflow state. @internal YAML Example: - taskName: set: variable1: value variable2: ${ expression } computed: ${ .a + .b } Reference: zigflow-dsl-pattern-catalog.md - Task Type 1"),
|
|
273
|
+
switch_case: z.lazy(() => SwitchTaskConfigInputSchema).optional().describe("Required when kind='switch_case'. SwitchTaskConfig defines the configuration for switch_case tasks that branch conditionally. @internal YAML Example: - taskName: switch: - case1: when: ${ $context.value > 5 } then: highValueTask - defaultCase: then: unknownTask Reference: zigflow-dsl-pattern-catalog.md - Task Type 3"),
|
|
274
|
+
transform: z.lazy(() => TransformTaskConfigInputSchema).optional().describe("Required when kind='transform'. TransformTaskConfig defines the configuration for transform tasks that perform deterministic data transformation without LLM calls. @internal Use transform when you need to reshape data between tasks: projecting fields, joining objects, converting formats, or building API payloads. Unlike set_vars (which mutates workflow state variables as a side effect), transform produces an explicit output that flows through export like any other task — visible and inspectable in the execution viewer. The distinction from set_vars: set_vars = imperative assignment ('set X to Y'), mutates workflow context transform = functional transformation ('reshape this data'), produces output YAML Example (JQ — reshape data for an API call): - build_api_payload: transform: engine: jq expression: '{name: .customer.full_name, severity: .triage.severity, summary: .agent_analysis.structured.summary}' input: '${ $context }' export: as: '${ . }' YAML Example (template — render a notification message): - render_notification: transform: engine: template expression: 'Ticket {{ .ticket_id }} classified as {{ .severity }} — {{ .summary }}' input: '${ $context.build_api_payload }' export: as: '${ . }'"),
|
|
275
|
+
try_catch: z.lazy(() => TryTaskConfigInputSchema).optional().describe("Required when kind='try_catch'. TryTaskConfig defines the configuration for try_catch tasks that handle errors. @internal YAML Example: - taskName: try: - attemptTask: call: http with: method: POST endpoint: uri: https://api.example.com/flaky catch: as: error do: - errorHandler: call: http with: body: error: ${ .error } Reference: zigflow-dsl-pattern-catalog.md - Task Type 6"),
|
|
276
|
+
validate: z.lazy(() => ValidateTaskConfigInputSchema).optional().describe("Required when kind='validate'. ValidateTaskConfig defines the configuration for validate tasks that perform explicit schema and business-rule validation on workflow data. @internal Use validate when you need an explicit validation checkpoint before downstream actions. This is how you distinguish 'the API call succeeded' from 'the data is safe and complete enough to continue.' While switch_case + raise_error can approximate validation, a dedicated validate task makes the intent explicit, the error messages richer, and the execution trace clearer. In the execution viewer (T09), a validate task shows exactly what was checked, what passed, and what failed — visible as a distinct verification step. The task supports two complementary validation modes: - schema: JSON Schema validation for structural correctness - rules: business-rule expressions for domain-specific constraints At least one of schema or rules must be set. Both can be used together for comprehensive validation (schema checks structure, rules check business logic). This cross-field constraint is enforced at runtime validation since buf.validate cannot express it on individual fields. Task output includes the full validation result: { 'valid': true/false, 'errors': [ {'rule': 'critical_needs_rationale', 'message': 'Critical severity requires a rationale'}, {'path': '$.category', 'message': 'must have at least 1 character'} ], 'data': <original input data> } YAML Example (schema + business rules): - check_triage_quality: validate: input: '${ $context.triage }' schema: type: object required: [severity, category, customer_impact] properties: severity: type: string enum: [low, medium, high, critical] category: type: string minLength: 1 customer_impact: type: boolean rules: - name: critical_needs_rationale expression: '${ .severity != 'critical' || (.rationale != null && .rationale != '') }' message: 'Critical severity requires a rationale' - name: customer_impact_needs_severity expression: '${ .customer_impact != true || .severity in ['high', 'critical'] }' message: 'Customer-impacting issues must be high or critical severity' on_fail: VALIDATION_FAIL_BRANCH fallback_task: human_review export: as: '${ . }' YAML Example (schema-only validation with warn policy): - check_payload_shape: validate: input: '${ $context.api_payload }' schema: type: object required: [name, email] properties: name: type: string email: type: string format: email on_fail: VALIDATION_FAIL_WARN export: as: '${ . }'"),
|
|
277
|
+
wait: z.lazy(() => WaitTaskConfigInputSchema).optional().describe("Required when kind='wait'. WaitTaskConfig defines the configuration for wait tasks that pause workflow execution. Supports both relative durations and absolute timestamps. @internal Implemented via Temporal timers. YAML Examples: Relative duration: - waitForApproval: wait: duration: days: 7 Absolute timestamp: - waitUntilMarketOpen: wait: until: '2026-03-02T09:30:00Z' Reference: zigflow-dsl-pattern-catalog.md - Task Type 8"),
|
|
278
|
+
export: z.lazy(() => ExportInputSchema).optional().describe("Export configuration (how to save task output to context). Optional - if not set, output is not saved."),
|
|
279
|
+
flow: z.lazy(() => FlowControlInputSchema).optional().describe("Flow control (which task executes next). Optional - if not set, continues to next task in sequence."),
|
|
280
|
+
compensate: z.array(z.lazy(() => WorkflowTaskInputSchema)).optional().describe("Compensation tasks to execute if this task needs to be 'undone.' @internal Saga-style compensation for workflows with side effects. When a try_catch block catches an error, it can optionally run the compensation tasks for all already-completed tasks in reverse order. The compensation tasks receive the original task's output in their input context, allowing them to construct the appropriate undo operation (e.g., cancel an API call, delete a created resource, send a reversal notification). Only executed when: 1. The task completed successfully (failed tasks are not compensated) 2. A subsequent task within the same try_catch scope fails 3. The catch block is configured to run compensations YAML Example: try: - create_order: call: http with: method: POST endpoint: { uri: 'https://api.example.com/orders' } body: { ... } compensate: - cancel_order: call: http with: method: DELETE endpoint: { uri: 'https://api.example.com/orders/${ $context.create_order.id }' } export: as: '${ . }' - charge_payment: call: http with: method: POST endpoint: { uri: 'https://api.example.com/payments' } catch: as: error compensate: true do: - log_failure: call: notification with: ... Optional - when empty, this task has no compensation action. @since T17 (Advanced Agentic Orchestration)"),
|
|
281
|
+
}));
|
|
282
|
+
const EnvVarDeclarationInputSchema = z.object({
|
|
283
|
+
is_secret: z.boolean().optional().describe("Whether the resolved value should be treated as a secret. @internal When true: encrypted at rest, redacted in logs and Temporal history. When false: stored as plaintext, visible in audit logs."),
|
|
284
|
+
description: z.string().optional().describe("Human-readable description shown in the UI credential form. Should explain what the variable is used for and where to obtain it."),
|
|
285
|
+
optional: z.boolean().optional().describe("Whether this variable is optional. @internal When false (default): the execution pipeline rejects a run if this variable is missing from the user's environment. When true: a missing value is acceptable (the MCP server or agent degrades gracefully without it)."),
|
|
286
|
+
});
|
|
287
|
+
const WorkflowBudgetInputSchema = z.object({
|
|
288
|
+
max_cost_micros: z.union([z.number(), z.string()]).optional().describe("Maximum total cost for this workflow execution in micro-USD. 1 USD = 1,000,000 micros. Example: 2000000 = $2.00. When exceeded, the on_exceeded policy is applied. Optional — when 0, no cost limit is enforced."),
|
|
289
|
+
max_total_tokens: z.union([z.number(), z.string()]).optional().describe("Maximum total tokens (input + output) across all LLM/agent tasks. Optional — when 0, no token limit is enforced."),
|
|
290
|
+
max_duration_seconds: z.number().optional().describe("Maximum wall-clock duration for the entire workflow execution in seconds. Optional — when 0, no duration limit is enforced (Temporal's own workflow execution timeout still applies)."),
|
|
291
|
+
on_exceeded: z.string().optional().describe("Policy when any budget limit is exceeded. Allowed values: budget_exceeded_terminate, budget_exceeded_human_review, budget_exceeded_warn."),
|
|
292
|
+
});
|
|
293
|
+
/** Build the fully-formed Workflow proto from the flat MCP apply input. */
|
|
294
|
+
export function workflowInputToProto(input) {
|
|
295
|
+
const slug = input.slug && input.slug.length > 0 ? input.slug : generateSlug(input.name);
|
|
296
|
+
const spec = create(WorkflowSpecSchema);
|
|
297
|
+
if (input.description !== undefined)
|
|
298
|
+
spec.description = input.description;
|
|
299
|
+
if (input.document !== undefined)
|
|
300
|
+
spec.document = workflowDocumentInputToProto(input.document);
|
|
301
|
+
if (input.tasks !== undefined)
|
|
302
|
+
spec.tasks = input.tasks.map(workflowTaskInputToProto);
|
|
303
|
+
if (input.env !== undefined) {
|
|
304
|
+
for (const [k, v] of Object.entries(input.env))
|
|
305
|
+
spec.env[k] = envVarDeclarationInputToProto(v);
|
|
306
|
+
}
|
|
307
|
+
if (input.budget !== undefined)
|
|
308
|
+
spec.budget = workflowBudgetInputToProto(input.budget);
|
|
309
|
+
return Object.assign(create(WorkflowSchema), {
|
|
310
|
+
apiVersion: "agentic.stigmer.ai/v1",
|
|
311
|
+
kind: "Workflow",
|
|
312
|
+
metadata: Object.assign(create(ApiResourceMetadataSchema), {
|
|
313
|
+
name: input.name,
|
|
314
|
+
slug,
|
|
315
|
+
org: input.org,
|
|
316
|
+
...(input.visibility !== undefined && { visibility: visibilityFromString(input.visibility) }),
|
|
317
|
+
...(input.labels !== undefined && { labels: input.labels }),
|
|
318
|
+
...(input.tags !== undefined && { tags: input.tags }),
|
|
319
|
+
}),
|
|
320
|
+
spec,
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
function workflowDocumentInputToProto(input) {
|
|
324
|
+
const result = create(WorkflowDocumentSchema);
|
|
325
|
+
if (input.dsl !== undefined)
|
|
326
|
+
result.dsl = input.dsl;
|
|
327
|
+
if (input.namespace !== undefined)
|
|
328
|
+
result.namespace = input.namespace;
|
|
329
|
+
if (input.name !== undefined)
|
|
330
|
+
result.name = input.name;
|
|
331
|
+
if (input.version !== undefined)
|
|
332
|
+
result.version = input.version;
|
|
333
|
+
if (input.description !== undefined)
|
|
334
|
+
result.description = input.description;
|
|
335
|
+
return result;
|
|
336
|
+
}
|
|
337
|
+
function contextManagementConfigInputToProto(input) {
|
|
338
|
+
const result = create(ContextManagementConfigSchema);
|
|
339
|
+
if (input.disable_summarization !== undefined)
|
|
340
|
+
result.disableSummarization = input.disable_summarization;
|
|
341
|
+
if (input.custom_trigger_threshold !== undefined)
|
|
342
|
+
result.customTriggerThreshold = input.custom_trigger_threshold;
|
|
343
|
+
if (input.custom_target_tokens !== undefined)
|
|
344
|
+
result.customTargetTokens = input.custom_target_tokens;
|
|
345
|
+
return result;
|
|
346
|
+
}
|
|
347
|
+
function agentExecutionConfigInputToProto(input) {
|
|
348
|
+
const result = create(AgentExecutionConfigSchema);
|
|
349
|
+
if (input.model !== undefined)
|
|
350
|
+
result.model = input.model;
|
|
351
|
+
if (input.timeout !== undefined)
|
|
352
|
+
result.timeout = input.timeout;
|
|
353
|
+
if (input.temperature !== undefined)
|
|
354
|
+
result.temperature = input.temperature;
|
|
355
|
+
if (input.context_management !== undefined)
|
|
356
|
+
result.contextManagement = contextManagementConfigInputToProto(input.context_management);
|
|
357
|
+
if (input.max_cost_micros !== undefined)
|
|
358
|
+
result.maxCostMicros = BigInt(input.max_cost_micros);
|
|
359
|
+
return result;
|
|
360
|
+
}
|
|
361
|
+
function agentCallOutputContractInputToProto(input) {
|
|
362
|
+
const result = create(AgentCallOutputContractSchema);
|
|
363
|
+
if (input.schema !== undefined)
|
|
364
|
+
result.schema = input.schema;
|
|
365
|
+
result.onInvalid = enumFromString(OnInvalidOutputPolicy, input.on_invalid);
|
|
366
|
+
if (input.max_retries !== undefined)
|
|
367
|
+
result.maxRetries = input.max_retries;
|
|
368
|
+
if (input.fallback_task !== undefined)
|
|
369
|
+
result.fallbackTask = input.fallback_task;
|
|
370
|
+
return result;
|
|
371
|
+
}
|
|
372
|
+
function agentCallTaskConfigInputToProto(input) {
|
|
373
|
+
const result = create(AgentCallTaskConfigSchema);
|
|
374
|
+
if (input.agent !== undefined)
|
|
375
|
+
result.agent = input.agent;
|
|
376
|
+
if (input.org !== undefined)
|
|
377
|
+
result.org = input.org;
|
|
378
|
+
if (input.message !== undefined)
|
|
379
|
+
result.message = input.message;
|
|
380
|
+
if (input.env !== undefined)
|
|
381
|
+
result.env = input.env;
|
|
382
|
+
if (input.config !== undefined)
|
|
383
|
+
result.config = agentExecutionConfigInputToProto(input.config);
|
|
384
|
+
if (input.output !== undefined)
|
|
385
|
+
result.output = agentCallOutputContractInputToProto(input.output);
|
|
386
|
+
result.harness = enumFromString(Harness, input.harness);
|
|
387
|
+
return result;
|
|
388
|
+
}
|
|
389
|
+
function callActivityTaskConfigInputToProto(input) {
|
|
390
|
+
const result = create(CallActivityTaskConfigSchema);
|
|
391
|
+
if (input.activity !== undefined)
|
|
392
|
+
result.activity = input.activity;
|
|
393
|
+
if (input.input !== undefined)
|
|
394
|
+
result.input = input.input;
|
|
395
|
+
return result;
|
|
396
|
+
}
|
|
397
|
+
function emitEventInputToProto(input) {
|
|
398
|
+
const result = create(EmitEventSpecSchema);
|
|
399
|
+
if (input.type !== undefined)
|
|
400
|
+
result.type = input.type;
|
|
401
|
+
if (input.source !== undefined)
|
|
402
|
+
result.source = input.source;
|
|
403
|
+
if (input.data !== undefined)
|
|
404
|
+
result.data = input.data;
|
|
405
|
+
if (input.subject !== undefined)
|
|
406
|
+
result.subject = input.subject;
|
|
407
|
+
return result;
|
|
408
|
+
}
|
|
409
|
+
function emitEventTaskConfigInputToProto(input) {
|
|
410
|
+
const result = create(EmitEventTaskConfigSchema);
|
|
411
|
+
if (input.event !== undefined)
|
|
412
|
+
result.event = emitEventInputToProto(input.event);
|
|
413
|
+
return result;
|
|
414
|
+
}
|
|
415
|
+
function evalCriterionInputToProto(input) {
|
|
416
|
+
const result = create(EvalCriterionSchema);
|
|
417
|
+
if (input.name !== undefined)
|
|
418
|
+
result.name = input.name;
|
|
419
|
+
if (input.description !== undefined)
|
|
420
|
+
result.description = input.description;
|
|
421
|
+
if (input.weight !== undefined)
|
|
422
|
+
result.weight = input.weight;
|
|
423
|
+
return result;
|
|
424
|
+
}
|
|
425
|
+
function evalTaskConfigInputToProto(input) {
|
|
426
|
+
const result = create(EvalTaskConfigSchema);
|
|
427
|
+
if (input.model !== undefined)
|
|
428
|
+
result.model = input.model;
|
|
429
|
+
if (input.subject !== undefined)
|
|
430
|
+
result.subject = input.subject;
|
|
431
|
+
if (input.rubric !== undefined)
|
|
432
|
+
result.rubric = input.rubric;
|
|
433
|
+
result.scoringMode = enumFromString(EvalScoringMode, input.scoring_mode);
|
|
434
|
+
if (input.threshold !== undefined)
|
|
435
|
+
result.threshold = input.threshold;
|
|
436
|
+
result.onFail = enumFromString(EvalFailPolicy, input.on_fail);
|
|
437
|
+
if (input.fallback_task !== undefined)
|
|
438
|
+
result.fallbackTask = input.fallback_task;
|
|
439
|
+
if (input.system_prompt !== undefined)
|
|
440
|
+
result.systemPrompt = input.system_prompt;
|
|
441
|
+
if (input.criteria !== undefined)
|
|
442
|
+
result.criteria = input.criteria.map(evalCriterionInputToProto);
|
|
443
|
+
if (input.max_cost_micros !== undefined)
|
|
444
|
+
result.maxCostMicros = BigInt(input.max_cost_micros);
|
|
445
|
+
return result;
|
|
446
|
+
}
|
|
447
|
+
function forTaskConfigInputToProto(input) {
|
|
448
|
+
const result = create(ForTaskConfigSchema);
|
|
449
|
+
if (input.each !== undefined)
|
|
450
|
+
result.each = input.each;
|
|
451
|
+
if (input.in !== undefined)
|
|
452
|
+
result.in = input.in;
|
|
453
|
+
if (input.do !== undefined)
|
|
454
|
+
result.do = input.do.map(workflowTaskInputToProto);
|
|
455
|
+
if (input.max_parallelism !== undefined)
|
|
456
|
+
result.maxParallelism = input.max_parallelism;
|
|
457
|
+
if (input.batch_size !== undefined)
|
|
458
|
+
result.batchSize = input.batch_size;
|
|
459
|
+
result.onError = enumFromString(ForEachErrorPolicy, input.on_error);
|
|
460
|
+
return result;
|
|
461
|
+
}
|
|
462
|
+
function forkBranchInputToProto(input) {
|
|
463
|
+
const result = create(ForkBranchSchema);
|
|
464
|
+
if (input.name !== undefined)
|
|
465
|
+
result.name = input.name;
|
|
466
|
+
if (input.do !== undefined)
|
|
467
|
+
result.do = input.do.map(workflowTaskInputToProto);
|
|
468
|
+
return result;
|
|
469
|
+
}
|
|
470
|
+
function forkTaskConfigInputToProto(input) {
|
|
471
|
+
const result = create(ForkTaskConfigSchema);
|
|
472
|
+
if (input.branches !== undefined)
|
|
473
|
+
result.branches = input.branches.map(forkBranchInputToProto);
|
|
474
|
+
if (input.compete !== undefined)
|
|
475
|
+
result.compete = input.compete;
|
|
476
|
+
return result;
|
|
477
|
+
}
|
|
478
|
+
function grpcCallTaskConfigInputToProto(input) {
|
|
479
|
+
const result = create(GrpcCallTaskConfigSchema);
|
|
480
|
+
if (input.service !== undefined)
|
|
481
|
+
result.service = input.service;
|
|
482
|
+
if (input.method !== undefined)
|
|
483
|
+
result.method = input.method;
|
|
484
|
+
if (input.request !== undefined)
|
|
485
|
+
result.request = input.request;
|
|
486
|
+
return result;
|
|
487
|
+
}
|
|
488
|
+
function httpEndpointInputToProto(input) {
|
|
489
|
+
const result = create(HttpEndpointSchema);
|
|
490
|
+
if (input.uri !== undefined)
|
|
491
|
+
result.uri = input.uri;
|
|
492
|
+
return result;
|
|
493
|
+
}
|
|
494
|
+
function httpCallTaskConfigInputToProto(input) {
|
|
495
|
+
const result = create(HttpCallTaskConfigSchema);
|
|
496
|
+
if (input.method !== undefined)
|
|
497
|
+
result.method = input.method;
|
|
498
|
+
if (input.endpoint !== undefined)
|
|
499
|
+
result.endpoint = httpEndpointInputToProto(input.endpoint);
|
|
500
|
+
if (input.headers !== undefined)
|
|
501
|
+
result.headers = input.headers;
|
|
502
|
+
if (input.body !== undefined)
|
|
503
|
+
result.body = input.body;
|
|
504
|
+
if (input.timeout_seconds !== undefined)
|
|
505
|
+
result.timeoutSeconds = input.timeout_seconds;
|
|
506
|
+
return result;
|
|
507
|
+
}
|
|
508
|
+
function humanInputOutcomeInputToProto(input) {
|
|
509
|
+
const result = create(HumanInputOutcomeSchema);
|
|
510
|
+
if (input.name !== undefined)
|
|
511
|
+
result.name = input.name;
|
|
512
|
+
if (input.label !== undefined)
|
|
513
|
+
result.label = input.label;
|
|
514
|
+
if (input.then !== undefined)
|
|
515
|
+
result.then = input.then;
|
|
516
|
+
return result;
|
|
517
|
+
}
|
|
518
|
+
function humanInputTaskConfigInputToProto(input) {
|
|
519
|
+
const result = create(HumanInputTaskConfigSchema);
|
|
520
|
+
if (input.prompt !== undefined)
|
|
521
|
+
result.prompt = input.prompt;
|
|
522
|
+
if (input.form_schema !== undefined)
|
|
523
|
+
result.formSchema = input.form_schema;
|
|
524
|
+
if (input.outcomes !== undefined)
|
|
525
|
+
result.outcomes = input.outcomes.map(humanInputOutcomeInputToProto);
|
|
526
|
+
if (input.approvers !== undefined)
|
|
527
|
+
result.approvers = input.approvers;
|
|
528
|
+
if (input.timeout !== undefined)
|
|
529
|
+
result.timeout = input.timeout;
|
|
530
|
+
result.onTimeout = enumFromString(HumanInputTimeoutPolicy, input.on_timeout);
|
|
531
|
+
if (input.notification_channels !== undefined)
|
|
532
|
+
result.notificationChannels = input.notification_channels;
|
|
533
|
+
return result;
|
|
534
|
+
}
|
|
535
|
+
function signalInputToProto(input) {
|
|
536
|
+
const result = create(SignalSpecSchema);
|
|
537
|
+
if (input.id !== undefined)
|
|
538
|
+
result.id = input.id;
|
|
539
|
+
if (input.type !== undefined)
|
|
540
|
+
result.type = input.type;
|
|
541
|
+
return result;
|
|
542
|
+
}
|
|
543
|
+
function listenToInputToProto(input) {
|
|
544
|
+
const result = create(ListenToSchema);
|
|
545
|
+
if (input.mode !== undefined)
|
|
546
|
+
result.mode = input.mode;
|
|
547
|
+
if (input.signals !== undefined)
|
|
548
|
+
result.signals = input.signals.map(signalInputToProto);
|
|
549
|
+
return result;
|
|
550
|
+
}
|
|
551
|
+
function listenTaskConfigInputToProto(input) {
|
|
552
|
+
const result = create(ListenTaskConfigSchema);
|
|
553
|
+
if (input.to !== undefined)
|
|
554
|
+
result.to = listenToInputToProto(input.to);
|
|
555
|
+
return result;
|
|
556
|
+
}
|
|
557
|
+
function llmCallTaskConfigInputToProto(input) {
|
|
558
|
+
const result = create(LlmCallTaskConfigSchema);
|
|
559
|
+
if (input.model !== undefined)
|
|
560
|
+
result.model = input.model;
|
|
561
|
+
if (input.system_prompt !== undefined)
|
|
562
|
+
result.systemPrompt = input.system_prompt;
|
|
563
|
+
if (input.prompt !== undefined)
|
|
564
|
+
result.prompt = input.prompt;
|
|
565
|
+
if (input.response_schema !== undefined)
|
|
566
|
+
result.responseSchema = input.response_schema;
|
|
567
|
+
if (input.temperature !== undefined)
|
|
568
|
+
result.temperature = input.temperature;
|
|
569
|
+
if (input.max_tokens !== undefined)
|
|
570
|
+
result.maxTokens = input.max_tokens;
|
|
571
|
+
if (input.timeout !== undefined)
|
|
572
|
+
result.timeout = input.timeout;
|
|
573
|
+
result.onInvalid = enumFromString(OnInvalidOutputPolicy, input.on_invalid);
|
|
574
|
+
if (input.max_retries !== undefined)
|
|
575
|
+
result.maxRetries = input.max_retries;
|
|
576
|
+
if (input.fallback_task !== undefined)
|
|
577
|
+
result.fallbackTask = input.fallback_task;
|
|
578
|
+
if (input.max_cost_micros !== undefined)
|
|
579
|
+
result.maxCostMicros = BigInt(input.max_cost_micros);
|
|
580
|
+
if (input.max_total_tokens !== undefined)
|
|
581
|
+
result.maxTotalTokens = BigInt(input.max_total_tokens);
|
|
582
|
+
return result;
|
|
583
|
+
}
|
|
584
|
+
function notificationTaskConfigInputToProto(input) {
|
|
585
|
+
const result = create(NotificationTaskConfigSchema);
|
|
586
|
+
if (input.channel !== undefined)
|
|
587
|
+
result.channel = input.channel;
|
|
588
|
+
if (input.recipients !== undefined)
|
|
589
|
+
result.recipients = input.recipients;
|
|
590
|
+
if (input.subject !== undefined)
|
|
591
|
+
result.subject = input.subject;
|
|
592
|
+
if (input.body !== undefined)
|
|
593
|
+
result.body = input.body;
|
|
594
|
+
if (input.template !== undefined)
|
|
595
|
+
result.template = input.template;
|
|
596
|
+
if (input.metadata !== undefined)
|
|
597
|
+
result.metadata = input.metadata;
|
|
598
|
+
return result;
|
|
599
|
+
}
|
|
600
|
+
function raiseTaskConfigInputToProto(input) {
|
|
601
|
+
const result = create(RaiseTaskConfigSchema);
|
|
602
|
+
if (input.error !== undefined)
|
|
603
|
+
result.error = input.error;
|
|
604
|
+
if (input.message !== undefined)
|
|
605
|
+
result.message = input.message;
|
|
606
|
+
return result;
|
|
607
|
+
}
|
|
608
|
+
function runTaskConfigInputToProto(input) {
|
|
609
|
+
const result = create(RunTaskConfigSchema);
|
|
610
|
+
if (input.workflow !== undefined)
|
|
611
|
+
result.workflow = input.workflow;
|
|
612
|
+
if (input.input !== undefined)
|
|
613
|
+
result.input = input.input;
|
|
614
|
+
return result;
|
|
615
|
+
}
|
|
616
|
+
function setTaskConfigInputToProto(input) {
|
|
617
|
+
const result = create(SetTaskConfigSchema);
|
|
618
|
+
if (input.variables !== undefined)
|
|
619
|
+
result.variables = input.variables;
|
|
620
|
+
return result;
|
|
621
|
+
}
|
|
622
|
+
function switchCaseInputToProto(input) {
|
|
623
|
+
const result = create(SwitchCaseSchema);
|
|
624
|
+
if (input.name !== undefined)
|
|
625
|
+
result.name = input.name;
|
|
626
|
+
if (input.when !== undefined)
|
|
627
|
+
result.when = input.when;
|
|
628
|
+
if (input.then !== undefined)
|
|
629
|
+
result.then = input.then;
|
|
630
|
+
return result;
|
|
631
|
+
}
|
|
632
|
+
function switchTaskConfigInputToProto(input) {
|
|
633
|
+
const result = create(SwitchTaskConfigSchema);
|
|
634
|
+
if (input.cases !== undefined)
|
|
635
|
+
result.cases = input.cases.map(switchCaseInputToProto);
|
|
636
|
+
return result;
|
|
637
|
+
}
|
|
638
|
+
function transformTaskConfigInputToProto(input) {
|
|
639
|
+
const result = create(TransformTaskConfigSchema);
|
|
640
|
+
result.engine = enumFromString(TransformEngine, input.engine);
|
|
641
|
+
if (input.expression !== undefined)
|
|
642
|
+
result.expression = input.expression;
|
|
643
|
+
if (input.input !== undefined)
|
|
644
|
+
result.input = input.input;
|
|
645
|
+
return result;
|
|
646
|
+
}
|
|
647
|
+
function catchBlockInputToProto(input) {
|
|
648
|
+
const result = create(CatchBlockSchema);
|
|
649
|
+
if (input.as !== undefined)
|
|
650
|
+
result.as = input.as;
|
|
651
|
+
if (input.do !== undefined)
|
|
652
|
+
result.do = input.do.map(workflowTaskInputToProto);
|
|
653
|
+
if (input.compensate !== undefined)
|
|
654
|
+
result.compensate = input.compensate;
|
|
655
|
+
return result;
|
|
656
|
+
}
|
|
657
|
+
function tryTaskConfigInputToProto(input) {
|
|
658
|
+
const result = create(TryTaskConfigSchema);
|
|
659
|
+
if (input.try !== undefined)
|
|
660
|
+
result.try = input.try.map(workflowTaskInputToProto);
|
|
661
|
+
if (input.catch !== undefined)
|
|
662
|
+
result.catch = catchBlockInputToProto(input.catch);
|
|
663
|
+
return result;
|
|
664
|
+
}
|
|
665
|
+
function validationRuleInputToProto(input) {
|
|
666
|
+
const result = create(ValidationRuleSchema);
|
|
667
|
+
if (input.name !== undefined)
|
|
668
|
+
result.name = input.name;
|
|
669
|
+
if (input.expression !== undefined)
|
|
670
|
+
result.expression = input.expression;
|
|
671
|
+
if (input.message !== undefined)
|
|
672
|
+
result.message = input.message;
|
|
673
|
+
return result;
|
|
674
|
+
}
|
|
675
|
+
function validateTaskConfigInputToProto(input) {
|
|
676
|
+
const result = create(ValidateTaskConfigSchema);
|
|
677
|
+
if (input.input !== undefined)
|
|
678
|
+
result.input = input.input;
|
|
679
|
+
if (input.schema !== undefined)
|
|
680
|
+
result.schema = input.schema;
|
|
681
|
+
if (input.rules !== undefined)
|
|
682
|
+
result.rules = input.rules.map(validationRuleInputToProto);
|
|
683
|
+
result.onFail = enumFromString(ValidationFailPolicy, input.on_fail);
|
|
684
|
+
if (input.fallback_task !== undefined)
|
|
685
|
+
result.fallbackTask = input.fallback_task;
|
|
686
|
+
return result;
|
|
687
|
+
}
|
|
688
|
+
function durationInputToProto(input) {
|
|
689
|
+
const result = create(DurationSchema);
|
|
690
|
+
if (input.days !== undefined)
|
|
691
|
+
result.days = input.days;
|
|
692
|
+
if (input.hours !== undefined)
|
|
693
|
+
result.hours = input.hours;
|
|
694
|
+
if (input.minutes !== undefined)
|
|
695
|
+
result.minutes = input.minutes;
|
|
696
|
+
if (input.seconds !== undefined)
|
|
697
|
+
result.seconds = input.seconds;
|
|
698
|
+
if (input.milliseconds !== undefined)
|
|
699
|
+
result.milliseconds = input.milliseconds;
|
|
700
|
+
return result;
|
|
701
|
+
}
|
|
702
|
+
function waitTaskConfigInputToProto(input) {
|
|
703
|
+
const result = create(WaitTaskConfigSchema);
|
|
704
|
+
if (input.duration !== undefined)
|
|
705
|
+
result.waitType = { case: "duration", value: durationInputToProto(input.duration) };
|
|
706
|
+
if (input.until !== undefined)
|
|
707
|
+
result.waitType = { case: "until", value: toTimestamp(input.until) };
|
|
708
|
+
return result;
|
|
709
|
+
}
|
|
710
|
+
function exportInputToProto(input) {
|
|
711
|
+
const result = create(ExportSchema);
|
|
712
|
+
if (input.as !== undefined)
|
|
713
|
+
result.as = input.as;
|
|
714
|
+
return result;
|
|
715
|
+
}
|
|
716
|
+
function flowControlInputToProto(input) {
|
|
717
|
+
const result = create(FlowControlSchema);
|
|
718
|
+
if (input.then !== undefined)
|
|
719
|
+
result.then = input.then;
|
|
720
|
+
return result;
|
|
721
|
+
}
|
|
722
|
+
function workflowTaskInputToProto(input) {
|
|
723
|
+
const result = create(WorkflowTaskSchema);
|
|
724
|
+
if (input.name !== undefined)
|
|
725
|
+
result.name = input.name;
|
|
726
|
+
result.kind = enumFromString(WorkflowTaskKind, input.kind);
|
|
727
|
+
if (input.export !== undefined)
|
|
728
|
+
result.export = exportInputToProto(input.export);
|
|
729
|
+
if (input.flow !== undefined)
|
|
730
|
+
result.flow = flowControlInputToProto(input.flow);
|
|
731
|
+
if (input.compensate !== undefined)
|
|
732
|
+
result.compensate = input.compensate.map(workflowTaskInputToProto);
|
|
733
|
+
switch (input.kind) {
|
|
734
|
+
case "agent_call":
|
|
735
|
+
if (input.agent_call !== undefined)
|
|
736
|
+
result.taskConfig = toJson(AgentCallTaskConfigSchema, agentCallTaskConfigInputToProto(input.agent_call));
|
|
737
|
+
break;
|
|
738
|
+
case "activity_call":
|
|
739
|
+
if (input.activity_call !== undefined)
|
|
740
|
+
result.taskConfig = toJson(CallActivityTaskConfigSchema, callActivityTaskConfigInputToProto(input.activity_call));
|
|
741
|
+
break;
|
|
742
|
+
case "emit_event":
|
|
743
|
+
if (input.emit_event !== undefined)
|
|
744
|
+
result.taskConfig = toJson(EmitEventTaskConfigSchema, emitEventTaskConfigInputToProto(input.emit_event));
|
|
745
|
+
break;
|
|
746
|
+
case "eval":
|
|
747
|
+
if (input.eval !== undefined)
|
|
748
|
+
result.taskConfig = toJson(EvalTaskConfigSchema, evalTaskConfigInputToProto(input.eval));
|
|
749
|
+
break;
|
|
750
|
+
case "for_each":
|
|
751
|
+
if (input.for_each !== undefined)
|
|
752
|
+
result.taskConfig = toJson(ForTaskConfigSchema, forTaskConfigInputToProto(input.for_each));
|
|
753
|
+
break;
|
|
754
|
+
case "fork":
|
|
755
|
+
if (input.fork !== undefined)
|
|
756
|
+
result.taskConfig = toJson(ForkTaskConfigSchema, forkTaskConfigInputToProto(input.fork));
|
|
757
|
+
break;
|
|
758
|
+
case "grpc_call":
|
|
759
|
+
if (input.grpc_call !== undefined)
|
|
760
|
+
result.taskConfig = toJson(GrpcCallTaskConfigSchema, grpcCallTaskConfigInputToProto(input.grpc_call));
|
|
761
|
+
break;
|
|
762
|
+
case "http_call":
|
|
763
|
+
if (input.http_call !== undefined)
|
|
764
|
+
result.taskConfig = toJson(HttpCallTaskConfigSchema, httpCallTaskConfigInputToProto(input.http_call));
|
|
765
|
+
break;
|
|
766
|
+
case "human_input":
|
|
767
|
+
if (input.human_input !== undefined)
|
|
768
|
+
result.taskConfig = toJson(HumanInputTaskConfigSchema, humanInputTaskConfigInputToProto(input.human_input));
|
|
769
|
+
break;
|
|
770
|
+
case "listen":
|
|
771
|
+
if (input.listen !== undefined)
|
|
772
|
+
result.taskConfig = toJson(ListenTaskConfigSchema, listenTaskConfigInputToProto(input.listen));
|
|
773
|
+
break;
|
|
774
|
+
case "llm_call":
|
|
775
|
+
if (input.llm_call !== undefined)
|
|
776
|
+
result.taskConfig = toJson(LlmCallTaskConfigSchema, llmCallTaskConfigInputToProto(input.llm_call));
|
|
777
|
+
break;
|
|
778
|
+
case "notification":
|
|
779
|
+
if (input.notification !== undefined)
|
|
780
|
+
result.taskConfig = toJson(NotificationTaskConfigSchema, notificationTaskConfigInputToProto(input.notification));
|
|
781
|
+
break;
|
|
782
|
+
case "raise_error":
|
|
783
|
+
if (input.raise_error !== undefined)
|
|
784
|
+
result.taskConfig = toJson(RaiseTaskConfigSchema, raiseTaskConfigInputToProto(input.raise_error));
|
|
785
|
+
break;
|
|
786
|
+
case "run_workflow":
|
|
787
|
+
if (input.run_workflow !== undefined)
|
|
788
|
+
result.taskConfig = toJson(RunTaskConfigSchema, runTaskConfigInputToProto(input.run_workflow));
|
|
789
|
+
break;
|
|
790
|
+
case "set_vars":
|
|
791
|
+
if (input.set_vars !== undefined)
|
|
792
|
+
result.taskConfig = toJson(SetTaskConfigSchema, setTaskConfigInputToProto(input.set_vars));
|
|
793
|
+
break;
|
|
794
|
+
case "switch_case":
|
|
795
|
+
if (input.switch_case !== undefined)
|
|
796
|
+
result.taskConfig = toJson(SwitchTaskConfigSchema, switchTaskConfigInputToProto(input.switch_case));
|
|
797
|
+
break;
|
|
798
|
+
case "transform":
|
|
799
|
+
if (input.transform !== undefined)
|
|
800
|
+
result.taskConfig = toJson(TransformTaskConfigSchema, transformTaskConfigInputToProto(input.transform));
|
|
801
|
+
break;
|
|
802
|
+
case "try_catch":
|
|
803
|
+
if (input.try_catch !== undefined)
|
|
804
|
+
result.taskConfig = toJson(TryTaskConfigSchema, tryTaskConfigInputToProto(input.try_catch));
|
|
805
|
+
break;
|
|
806
|
+
case "validate":
|
|
807
|
+
if (input.validate !== undefined)
|
|
808
|
+
result.taskConfig = toJson(ValidateTaskConfigSchema, validateTaskConfigInputToProto(input.validate));
|
|
809
|
+
break;
|
|
810
|
+
case "wait":
|
|
811
|
+
if (input.wait !== undefined)
|
|
812
|
+
result.taskConfig = toJson(WaitTaskConfigSchema, waitTaskConfigInputToProto(input.wait));
|
|
813
|
+
break;
|
|
814
|
+
default:
|
|
815
|
+
if (input.kind !== undefined && input.kind !== "") {
|
|
816
|
+
throw new Error(`unknown task kind: ${input.kind}`);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
return result;
|
|
820
|
+
}
|
|
821
|
+
function envVarDeclarationInputToProto(input) {
|
|
822
|
+
const result = create(EnvVarDeclarationSchema);
|
|
823
|
+
if (input.is_secret !== undefined)
|
|
824
|
+
result.isSecret = input.is_secret;
|
|
825
|
+
if (input.description !== undefined)
|
|
826
|
+
result.description = input.description;
|
|
827
|
+
if (input.optional !== undefined)
|
|
828
|
+
result.optional = input.optional;
|
|
829
|
+
return result;
|
|
830
|
+
}
|
|
831
|
+
function workflowBudgetInputToProto(input) {
|
|
832
|
+
const result = create(WorkflowBudgetSchema);
|
|
833
|
+
if (input.max_cost_micros !== undefined)
|
|
834
|
+
result.maxCostMicros = BigInt(input.max_cost_micros);
|
|
835
|
+
if (input.max_total_tokens !== undefined)
|
|
836
|
+
result.maxTotalTokens = BigInt(input.max_total_tokens);
|
|
837
|
+
if (input.max_duration_seconds !== undefined)
|
|
838
|
+
result.maxDurationSeconds = input.max_duration_seconds;
|
|
839
|
+
result.onExceeded = enumFromString(BudgetExceededPolicy, input.on_exceeded);
|
|
840
|
+
return result;
|
|
841
|
+
}
|
|
842
|
+
//# sourceMappingURL=workflow.js.map
|