@sensigo/realm 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -0
- package/dist/adapters/adapter-utils.d.ts +14 -0
- package/dist/adapters/adapter-utils.d.ts.map +1 -0
- package/dist/adapters/adapter-utils.js +18 -0
- package/dist/adapters/adapter-utils.js.map +1 -0
- package/dist/adapters/airtable-adapter.d.ts +51 -0
- package/dist/adapters/airtable-adapter.d.ts.map +1 -0
- package/dist/adapters/airtable-adapter.js +425 -0
- package/dist/adapters/airtable-adapter.js.map +1 -0
- package/dist/adapters/file-adapter.d.ts +14 -0
- package/dist/adapters/file-adapter.d.ts.map +1 -0
- package/dist/adapters/file-adapter.js +89 -0
- package/dist/adapters/file-adapter.js.map +1 -0
- package/dist/adapters/github-adapter.d.ts +40 -0
- package/dist/adapters/github-adapter.d.ts.map +1 -0
- package/dist/adapters/github-adapter.js +286 -0
- package/dist/adapters/github-adapter.js.map +1 -0
- package/dist/adapters/gorgias-adapter.d.ts +40 -0
- package/dist/adapters/gorgias-adapter.d.ts.map +1 -0
- package/dist/adapters/gorgias-adapter.js +300 -0
- package/dist/adapters/gorgias-adapter.js.map +1 -0
- package/dist/adapters/http-adapter.d.ts +28 -0
- package/dist/adapters/http-adapter.d.ts.map +1 -0
- package/dist/adapters/http-adapter.js +97 -0
- package/dist/adapters/http-adapter.js.map +1 -0
- package/dist/adapters/mock-adapter.d.ts +16 -0
- package/dist/adapters/mock-adapter.d.ts.map +1 -0
- package/dist/adapters/mock-adapter.js +61 -0
- package/dist/adapters/mock-adapter.js.map +1 -0
- package/dist/adapters/notion-adapter.d.ts +54 -0
- package/dist/adapters/notion-adapter.d.ts.map +1 -0
- package/dist/adapters/notion-adapter.js +751 -0
- package/dist/adapters/notion-adapter.js.map +1 -0
- package/dist/adapters/parcelpanel-adapter.d.ts +60 -0
- package/dist/adapters/parcelpanel-adapter.d.ts.map +1 -0
- package/dist/adapters/parcelpanel-adapter.js +251 -0
- package/dist/adapters/parcelpanel-adapter.js.map +1 -0
- package/dist/adapters/rate-limiter.d.ts +26 -0
- package/dist/adapters/rate-limiter.d.ts.map +1 -0
- package/dist/adapters/rate-limiter.js +3 -0
- package/dist/adapters/rate-limiter.js.map +1 -0
- package/dist/adapters/shopify-adapter.d.ts +92 -0
- package/dist/adapters/shopify-adapter.d.ts.map +1 -0
- package/dist/adapters/shopify-adapter.js +415 -0
- package/dist/adapters/shopify-adapter.js.map +1 -0
- package/dist/adapters/slack-adapter.d.ts +18 -0
- package/dist/adapters/slack-adapter.d.ts.map +1 -0
- package/dist/adapters/slack-adapter.js +81 -0
- package/dist/adapters/slack-adapter.js.map +1 -0
- package/dist/adapters/token-bucket.d.ts +27 -0
- package/dist/adapters/token-bucket.d.ts.map +1 -0
- package/dist/adapters/token-bucket.js +109 -0
- package/dist/adapters/token-bucket.js.map +1 -0
- package/dist/config/secrets.d.ts +15 -0
- package/dist/config/secrets.d.ts.map +1 -0
- package/dist/config/secrets.js +33 -0
- package/dist/config/secrets.js.map +1 -0
- package/dist/engine/eligibility.d.ts +50 -0
- package/dist/engine/eligibility.d.ts.map +1 -0
- package/dist/engine/eligibility.js +267 -0
- package/dist/engine/eligibility.js.map +1 -0
- package/dist/engine/error-resolution.d.ts +20 -0
- package/dist/engine/error-resolution.d.ts.map +1 -0
- package/dist/engine/error-resolution.js +32 -0
- package/dist/engine/error-resolution.js.map +1 -0
- package/dist/engine/execution-loop.d.ts +101 -0
- package/dist/engine/execution-loop.d.ts.map +1 -0
- package/dist/engine/execution-loop.js +1156 -0
- package/dist/engine/execution-loop.js.map +1 -0
- package/dist/engine/lifecycle.d.ts +14 -0
- package/dist/engine/lifecycle.d.ts.map +1 -0
- package/dist/engine/lifecycle.js +17 -0
- package/dist/engine/lifecycle.js.map +1 -0
- package/dist/engine/precondition.d.ts +30 -0
- package/dist/engine/precondition.d.ts.map +1 -0
- package/dist/engine/precondition.js +125 -0
- package/dist/engine/precondition.js.map +1 -0
- package/dist/engine/prompt-template.d.ts +25 -0
- package/dist/engine/prompt-template.d.ts.map +1 -0
- package/dist/engine/prompt-template.js +66 -0
- package/dist/engine/prompt-template.js.map +1 -0
- package/dist/engine/render-template.d.ts +52 -0
- package/dist/engine/render-template.d.ts.map +1 -0
- package/dist/engine/render-template.js +548 -0
- package/dist/engine/render-template.js.map +1 -0
- package/dist/engine/state-guard.d.ts +15 -0
- package/dist/engine/state-guard.d.ts.map +1 -0
- package/dist/engine/state-guard.js +40 -0
- package/dist/engine/state-guard.js.map +1 -0
- package/dist/engine/trace-normalizer.d.ts +36 -0
- package/dist/engine/trace-normalizer.d.ts.map +1 -0
- package/dist/engine/trace-normalizer.js +146 -0
- package/dist/engine/trace-normalizer.js.map +1 -0
- package/dist/engine/trace-policy.d.ts +53 -0
- package/dist/engine/trace-policy.d.ts.map +1 -0
- package/dist/engine/trace-policy.js +35 -0
- package/dist/engine/trace-policy.js.map +1 -0
- package/dist/engine/workflow-context-loader.d.ts +9 -0
- package/dist/engine/workflow-context-loader.d.ts.map +1 -0
- package/dist/engine/workflow-context-loader.js +41 -0
- package/dist/engine/workflow-context-loader.js.map +1 -0
- package/dist/evidence/snapshot.d.ts +38 -0
- package/dist/evidence/snapshot.d.ts.map +1 -0
- package/dist/evidence/snapshot.js +53 -0
- package/dist/evidence/snapshot.js.map +1 -0
- package/dist/extensions/default-registry.d.ts +19 -0
- package/dist/extensions/default-registry.d.ts.map +1 -0
- package/dist/extensions/default-registry.js +31 -0
- package/dist/extensions/default-registry.js.map +1 -0
- package/dist/extensions/processor.d.ts +13 -0
- package/dist/extensions/processor.d.ts.map +1 -0
- package/dist/extensions/processor.js +3 -0
- package/dist/extensions/processor.js.map +1 -0
- package/dist/extensions/registry.d.ts +25 -0
- package/dist/extensions/registry.d.ts.map +1 -0
- package/dist/extensions/registry.js +43 -0
- package/dist/extensions/registry.js.map +1 -0
- package/dist/extensions/service-adapter.d.ts +35 -0
- package/dist/extensions/service-adapter.d.ts.map +1 -0
- package/dist/extensions/service-adapter.js +3 -0
- package/dist/extensions/service-adapter.js.map +1 -0
- package/dist/extensions/step-handler.d.ts +28 -0
- package/dist/extensions/step-handler.d.ts.map +1 -0
- package/dist/extensions/step-handler.js +3 -0
- package/dist/extensions/step-handler.js.map +1 -0
- package/dist/handlers/primitives/compare-strings.d.ts +13 -0
- package/dist/handlers/primitives/compare-strings.d.ts.map +1 -0
- package/dist/handlers/primitives/compare-strings.js +28 -0
- package/dist/handlers/primitives/compare-strings.js.map +1 -0
- package/dist/handlers/primitives/count-results.d.ts +21 -0
- package/dist/handlers/primitives/count-results.d.ts.map +1 -0
- package/dist/handlers/primitives/count-results.js +23 -0
- package/dist/handlers/primitives/count-results.js.map +1 -0
- package/dist/handlers/primitives/partition-by-substring.d.ts +18 -0
- package/dist/handlers/primitives/partition-by-substring.d.ts.map +1 -0
- package/dist/handlers/primitives/partition-by-substring.js +28 -0
- package/dist/handlers/primitives/partition-by-substring.js.map +1 -0
- package/dist/handlers/primitives/resolve-resource.d.ts +13 -0
- package/dist/handlers/primitives/resolve-resource.d.ts.map +1 -0
- package/dist/handlers/primitives/resolve-resource.js +21 -0
- package/dist/handlers/primitives/resolve-resource.js.map +1 -0
- package/dist/handlers/primitives/walk-field.d.ts +11 -0
- package/dist/handlers/primitives/walk-field.d.ts.map +1 -0
- package/dist/handlers/primitives/walk-field.js +31 -0
- package/dist/handlers/primitives/walk-field.js.map +1 -0
- package/dist/handlers/validate-field-match.d.ts +11 -0
- package/dist/handlers/validate-field-match.d.ts.map +1 -0
- package/dist/handlers/validate-field-match.js +39 -0
- package/dist/handlers/validate-field-match.js.map +1 -0
- package/dist/handlers/validate-verbatim-quotes.d.ts +11 -0
- package/dist/handlers/validate-verbatim-quotes.d.ts.map +1 -0
- package/dist/handlers/validate-verbatim-quotes.js +37 -0
- package/dist/handlers/validate-verbatim-quotes.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +45 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline/processing-pipeline.d.ts +24 -0
- package/dist/pipeline/processing-pipeline.d.ts.map +1 -0
- package/dist/pipeline/processing-pipeline.js +53 -0
- package/dist/pipeline/processing-pipeline.js.map +1 -0
- package/dist/processors/compute-hash.d.ts +4 -0
- package/dist/processors/compute-hash.d.ts.map +1 -0
- package/dist/processors/compute-hash.js +14 -0
- package/dist/processors/compute-hash.js.map +1 -0
- package/dist/processors/normalize-text.d.ts +8 -0
- package/dist/processors/normalize-text.d.ts.map +1 -0
- package/dist/processors/normalize-text.js +47 -0
- package/dist/processors/normalize-text.js.map +1 -0
- package/dist/store/json-file-store.d.ts +24 -0
- package/dist/store/json-file-store.d.ts.map +1 -0
- package/dist/store/json-file-store.js +210 -0
- package/dist/store/json-file-store.js.map +1 -0
- package/dist/store/store-interface.d.ts +33 -0
- package/dist/store/store-interface.d.ts.map +1 -0
- package/dist/store/store-interface.js +2 -0
- package/dist/store/store-interface.js.map +1 -0
- package/dist/store/trace-buffer-store.d.ts +55 -0
- package/dist/store/trace-buffer-store.d.ts.map +1 -0
- package/dist/store/trace-buffer-store.js +113 -0
- package/dist/store/trace-buffer-store.js.map +1 -0
- package/dist/types/mcp-types.d.ts +17 -0
- package/dist/types/mcp-types.d.ts.map +1 -0
- package/dist/types/mcp-types.js +5 -0
- package/dist/types/mcp-types.js.map +1 -0
- package/dist/types/response-envelope.d.ts +96 -0
- package/dist/types/response-envelope.d.ts.map +1 -0
- package/dist/types/response-envelope.js +2 -0
- package/dist/types/response-envelope.js.map +1 -0
- package/dist/types/run-record.d.ts +169 -0
- package/dist/types/run-record.d.ts.map +1 -0
- package/dist/types/run-record.js +2 -0
- package/dist/types/run-record.js.map +1 -0
- package/dist/types/workflow-definition.d.ts +292 -0
- package/dist/types/workflow-definition.d.ts.map +1 -0
- package/dist/types/workflow-definition.js +2 -0
- package/dist/types/workflow-definition.js.map +1 -0
- package/dist/types/workflow-error.d.ts +26 -0
- package/dist/types/workflow-error.d.ts.map +1 -0
- package/dist/types/workflow-error.js +28 -0
- package/dist/types/workflow-error.js.map +1 -0
- package/dist/utils/schema-skeleton.d.ts +11 -0
- package/dist/utils/schema-skeleton.d.ts.map +1 -0
- package/dist/utils/schema-skeleton.js +40 -0
- package/dist/utils/schema-skeleton.js.map +1 -0
- package/dist/validation/input-schema.d.ts +26 -0
- package/dist/validation/input-schema.d.ts.map +1 -0
- package/dist/validation/input-schema.js +67 -0
- package/dist/validation/input-schema.js.map +1 -0
- package/dist/workflow/registrar.d.ts +20 -0
- package/dist/workflow/registrar.d.ts.map +1 -0
- package/dist/workflow/registrar.js +61 -0
- package/dist/workflow/registrar.js.map +1 -0
- package/dist/workflow/template-resolver.d.ts +25 -0
- package/dist/workflow/template-resolver.d.ts.map +1 -0
- package/dist/workflow/template-resolver.js +112 -0
- package/dist/workflow/template-resolver.js.map +1 -0
- package/dist/workflow/yaml-loader.d.ts +15 -0
- package/dist/workflow/yaml-loader.d.ts.map +1 -0
- package/dist/workflow/yaml-loader.js +408 -0
- package/dist/workflow/yaml-loader.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import type { McpServerConfig } from './mcp-types.js';
|
|
2
|
+
export type ExecutionMode = 'auto' | 'agent';
|
|
3
|
+
export interface ProtocolConfig {
|
|
4
|
+
/** Override for the generated quick-start paragraph. */
|
|
5
|
+
quick_start?: string;
|
|
6
|
+
/** Behavioral rules injected verbatim into the agent protocol. */
|
|
7
|
+
rules?: string[];
|
|
8
|
+
}
|
|
9
|
+
export type TrustLevel = 'auto' | 'human_notified' | 'human_confirmed' | 'human_reviewed';
|
|
10
|
+
export type ServiceTrust = 'engine_delivered' | 'engine_managed' | 'agent_provided';
|
|
11
|
+
export interface JsonSchema {
|
|
12
|
+
type?: string;
|
|
13
|
+
required?: string[];
|
|
14
|
+
properties?: Record<string, JsonSchema>;
|
|
15
|
+
items?: JsonSchema;
|
|
16
|
+
minimum?: number;
|
|
17
|
+
maximum?: number;
|
|
18
|
+
pattern?: string;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface RateLimitConfig {
|
|
22
|
+
/** Maximum number of requests per second. Used as the token refill rate. */
|
|
23
|
+
requests_per_second?: number;
|
|
24
|
+
/** Initial token capacity (burst). Defaults to requests_per_second if omitted. */
|
|
25
|
+
burst?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Fallback retry-after delay (seconds) when the service returns HTTP 429 with no header.
|
|
28
|
+
* Overrides adapter.defaultRetryAfterSeconds when set.
|
|
29
|
+
*/
|
|
30
|
+
fallback_retry_seconds?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Maximum retry-after window (seconds). When the resolved retry_after exceeds this value,
|
|
33
|
+
* the step fails immediately with agentAction: 'report_to_user' instead of waiting.
|
|
34
|
+
*/
|
|
35
|
+
max_retry_seconds?: number;
|
|
36
|
+
}
|
|
37
|
+
export interface ServiceDefinition {
|
|
38
|
+
adapter: string;
|
|
39
|
+
auth?: {
|
|
40
|
+
token_from: string;
|
|
41
|
+
};
|
|
42
|
+
trust: ServiceTrust;
|
|
43
|
+
rate_limit?: RateLimitConfig;
|
|
44
|
+
}
|
|
45
|
+
/** A single parameter declaration in a template. */
|
|
46
|
+
export interface TemplateParam {
|
|
47
|
+
required?: boolean;
|
|
48
|
+
default?: string;
|
|
49
|
+
}
|
|
50
|
+
/** A named reusable step group with parameter placeholders. */
|
|
51
|
+
export interface TemplateDefinition {
|
|
52
|
+
params?: Record<string, TemplateParam>;
|
|
53
|
+
steps: Record<string, StepDefinition>;
|
|
54
|
+
}
|
|
55
|
+
export interface RetryConfig {
|
|
56
|
+
max_attempts: number;
|
|
57
|
+
backoff?: 'linear' | 'exponential' | 'fixed';
|
|
58
|
+
base_delay_ms?: number;
|
|
59
|
+
/** Cap on the computed backoff delay. When set, no single delay exceeds this value. */
|
|
60
|
+
max_delay_ms?: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Controls when a step becomes eligible based on its dependencies' outcomes.
|
|
64
|
+
* Default: 'all_success'.
|
|
65
|
+
*/
|
|
66
|
+
export type TriggerRule = 'all_success' | 'all_failed' | 'all_done' | 'one_failed' | 'one_success' | 'none_failed';
|
|
67
|
+
export interface StepDefinition {
|
|
68
|
+
description: string;
|
|
69
|
+
execution: ExecutionMode;
|
|
70
|
+
/**
|
|
71
|
+
* Step IDs this step waits for. Empty array or omitted = eligible from run start
|
|
72
|
+
* (first tier of the DAG).
|
|
73
|
+
*/
|
|
74
|
+
depends_on?: string[];
|
|
75
|
+
/**
|
|
76
|
+
* When to evaluate dependency satisfaction. Default: 'all_success'.
|
|
77
|
+
*/
|
|
78
|
+
trigger_rule?: TriggerRule;
|
|
79
|
+
/**
|
|
80
|
+
* Optional condition expression evaluated against prior step evidence.
|
|
81
|
+
* Step is ineligible until this expression is truthy.
|
|
82
|
+
* Uses the same dot-path syntax as input_map.
|
|
83
|
+
* Example: "context.resources.classifier.category == 'billing'"
|
|
84
|
+
*/
|
|
85
|
+
when?: string;
|
|
86
|
+
uses_service?: string;
|
|
87
|
+
/**
|
|
88
|
+
* Which adapter method to invoke for this service step.
|
|
89
|
+
* Defaults to 'fetch' if omitted.
|
|
90
|
+
*/
|
|
91
|
+
service_method?: 'fetch' | 'create' | 'update' | 'delete';
|
|
92
|
+
/**
|
|
93
|
+
* Operation name passed as the first argument to the adapter method.
|
|
94
|
+
* Defaults to the step name if omitted.
|
|
95
|
+
*/
|
|
96
|
+
operation?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Static path-mapping that assembles this step's adapter params from run state.
|
|
99
|
+
* Each key is the param name passed to the adapter; each value is a dot-path:
|
|
100
|
+
* run.params.FIELD — from the run's initial params
|
|
101
|
+
* context.resources.STEP.FIELD — from a prior step's evidence output
|
|
102
|
+
* Only valid on execution: 'auto' steps with uses_service.
|
|
103
|
+
*/
|
|
104
|
+
input_map?: Record<string, string>;
|
|
105
|
+
handler?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Static key-value configuration passed to the step handler via context.config.
|
|
108
|
+
* Only meaningful on execution: auto steps with a handler declaration.
|
|
109
|
+
*/
|
|
110
|
+
config?: Record<string, unknown>;
|
|
111
|
+
input_schema?: JsonSchema;
|
|
112
|
+
/**
|
|
113
|
+
* Validates the agent's submitted output (the params passed to `execute_step`)
|
|
114
|
+
* against this JSON Schema before the engine claims the step.
|
|
115
|
+
* Only valid on `execution: 'agent'` steps. Declaring `output_schema` on an
|
|
116
|
+
* `execution: 'auto'` step is a loader error.
|
|
117
|
+
*
|
|
118
|
+
* Validation runs pre-claim. If it fails the engine returns
|
|
119
|
+
* `agent_action: 'provide_input'` and the step remains unclaimed —
|
|
120
|
+
* the agent can correct its output and re-submit without side effects.
|
|
121
|
+
*
|
|
122
|
+
* For gate steps (`trust: 'human_confirmed'` or `trust: 'human_reviewed'`),
|
|
123
|
+
* the schema validates before the gate opens. `submitHumanResponse` commits
|
|
124
|
+
* the previewed payload unchanged — the human always sees a schema-conformant
|
|
125
|
+
* payload.
|
|
126
|
+
*/
|
|
127
|
+
output_schema?: JsonSchema;
|
|
128
|
+
/**
|
|
129
|
+
* JSON Schema validated against the canonical stored trace entries for this step.
|
|
130
|
+
* Only valid on `execution: 'agent'` steps.
|
|
131
|
+
* When `trace_validation_mode` is `'enforce'`, invalid trace fails pre-claim and the
|
|
132
|
+
* step remains unclaimed. When `'warn'` (default), a warning is added to the envelope.
|
|
133
|
+
*/
|
|
134
|
+
trace_schema?: JsonSchema;
|
|
135
|
+
/**
|
|
136
|
+
* Controls how `trace_schema` failures are handled.
|
|
137
|
+
* Default when `trace_schema` is set and mode is omitted: `'warn'`.
|
|
138
|
+
* Ignored when no `trace_schema` is declared.
|
|
139
|
+
*/
|
|
140
|
+
trace_validation_mode?: 'warn' | 'enforce';
|
|
141
|
+
preconditions?: string[];
|
|
142
|
+
trust?: TrustLevel;
|
|
143
|
+
timeout_seconds?: number;
|
|
144
|
+
retry?: RetryConfig;
|
|
145
|
+
/** Plain-English instructions for the agent at this step. */
|
|
146
|
+
instructions?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Template-resolved task prompt delivered to the agent at step entry via next_actions[].prompt.
|
|
149
|
+
* Supports {{ context.resources.STEP.FIELD }} and {{ run.params.FIELD }} references.
|
|
150
|
+
* For human_confirmed steps, delivered as gate.prompt when the gate opens.
|
|
151
|
+
*/
|
|
152
|
+
prompt?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Optional Jinja-style display template rendered by the CLI against this step's
|
|
155
|
+
* output_summary for human-readable terminal output. Uses {{ field }} syntax where
|
|
156
|
+
* field is a dot-path into the step's output object. When absent, the CLI falls
|
|
157
|
+
* back to the existing headline/message and JSON rendering behaviour.
|
|
158
|
+
* No engine evaluation — rendered client-side at run completion.
|
|
159
|
+
*/
|
|
160
|
+
display?: string;
|
|
161
|
+
/**
|
|
162
|
+
* When present, this entry is a template instantiation rather than a concrete step.
|
|
163
|
+
* Resolved by loadWorkflowFromString before validation — never present in a
|
|
164
|
+
* WorkflowDefinition returned to callers.
|
|
165
|
+
*/
|
|
166
|
+
use_template?: string;
|
|
167
|
+
/** Gate configuration — choices available to the human reviewer. */
|
|
168
|
+
gate?: {
|
|
169
|
+
choices?: string[];
|
|
170
|
+
/**
|
|
171
|
+
* Slack user ID or handle of the person responsible for resolving this gate.
|
|
172
|
+
* Used for notification targeting and escalation.
|
|
173
|
+
* Optional — notifications work without it.
|
|
174
|
+
* Example: '@mihai.lupu' or 'U012AB3CD'
|
|
175
|
+
*/
|
|
176
|
+
owner?: string;
|
|
177
|
+
/**
|
|
178
|
+
* Developer-authored template string presented to the human reviewer when this gate opens.
|
|
179
|
+
* Supports {{ context.resources.STEP.FIELD }} and {{ run.params.FIELD }} references.
|
|
180
|
+
* Resolved from run data at gate-open time. Fail-fast: unresolvable references cause
|
|
181
|
+
* a stop error rather than opening a gate with broken placeholder text.
|
|
182
|
+
* When absent, the Slack path falls back to formatGatePreviewForSlack(preview)
|
|
183
|
+
* and the MCP path falls back to step.prompt resolution (existing behavior).
|
|
184
|
+
*/
|
|
185
|
+
message?: string;
|
|
186
|
+
/**
|
|
187
|
+
* Per-choice messages posted to the Slack thread when the gate resolves via Slack.
|
|
188
|
+
* Keys must match entries in `choices`. Values are plain text (not mrkdwn templates).
|
|
189
|
+
* Optional — when absent or when a choice has no entry, the generic fallback is used.
|
|
190
|
+
* Example:
|
|
191
|
+
* resolution_messages:
|
|
192
|
+
* send: "✅ Incident report sent to #incidents."
|
|
193
|
+
* reject: "❌ Draft discarded. Run will not continue."
|
|
194
|
+
*/
|
|
195
|
+
resolution_messages?: Record<string, string>;
|
|
196
|
+
};
|
|
197
|
+
/** Name of the agent profile for this step. Only valid on execution: 'agent' steps. */
|
|
198
|
+
agent_profile?: string;
|
|
199
|
+
/**
|
|
200
|
+
* Allow-list of tools this step may invoke, in 'server_id:tool_name' format.
|
|
201
|
+
* Only valid on execution: 'agent' steps without a handler. Requires input_schema.
|
|
202
|
+
*/
|
|
203
|
+
tools?: string[];
|
|
204
|
+
/**
|
|
205
|
+
* Maximum number of tool-call iterations before the agentic loop terminates.
|
|
206
|
+
* Default: 20 (applied at runtime).
|
|
207
|
+
*/
|
|
208
|
+
max_tool_calls?: number;
|
|
209
|
+
/**
|
|
210
|
+
* Timeout in seconds for each individual tool call.
|
|
211
|
+
* Default: 30 (applied at runtime).
|
|
212
|
+
*/
|
|
213
|
+
tool_timeout?: number;
|
|
214
|
+
}
|
|
215
|
+
export interface WorkflowDefinition {
|
|
216
|
+
id: string;
|
|
217
|
+
name: string;
|
|
218
|
+
version: number;
|
|
219
|
+
/** JSON Schema describing the params accepted by start_run. */
|
|
220
|
+
params_schema?: JsonSchema;
|
|
221
|
+
/** Optional protocol customizations — overrides generated sections. */
|
|
222
|
+
protocol?: ProtocolConfig;
|
|
223
|
+
services?: Record<string, ServiceDefinition>;
|
|
224
|
+
/** MCP server configurations available to tool-enabled steps in this workflow. */
|
|
225
|
+
mcp_servers?: McpServerConfig[];
|
|
226
|
+
/** Optional named step groups with {{ param }} placeholders; resolved at load time. */
|
|
227
|
+
templates?: Record<string, TemplateDefinition>;
|
|
228
|
+
steps: Record<string, StepDefinition>;
|
|
229
|
+
/** Optional: directory containing shared profile markdown files.
|
|
230
|
+
* Resolved relative to the workflow YAML file at load time.
|
|
231
|
+
* Falls back to <workflow-dir>/profiles/ if omitted. */
|
|
232
|
+
profiles_dir?: string;
|
|
233
|
+
/**
|
|
234
|
+
* Map of resolved profile content keyed by profile name.
|
|
235
|
+
* Populated by loadWorkflowFromFile — absent when loaded from string.
|
|
236
|
+
* Do not serialize/write to workflow YAML — this is a runtime-only field.
|
|
237
|
+
*/
|
|
238
|
+
resolved_profiles?: Record<string, {
|
|
239
|
+
content: string;
|
|
240
|
+
content_hash: string;
|
|
241
|
+
}>;
|
|
242
|
+
/**
|
|
243
|
+
* Schema version stamped by the loader at registration time.
|
|
244
|
+
* Used by JsonWorkflowStore.get() to reject stale registrations.
|
|
245
|
+
* Runtime-only — not a user-facing YAML field.
|
|
246
|
+
*/
|
|
247
|
+
schema_version?: number;
|
|
248
|
+
/**
|
|
249
|
+
* Named context entries available in all step prompts via {{ workflow.context.NAME }}.
|
|
250
|
+
* Loaded once at run start. Separate from step evidence.
|
|
251
|
+
* Paths are resolved to absolute at registration time by the YAML loader.
|
|
252
|
+
*/
|
|
253
|
+
workflow_context?: Record<string, WorkflowContextEntry>;
|
|
254
|
+
/**
|
|
255
|
+
* Wrapper format applied to {{ workflow.context.NAME }} template references.
|
|
256
|
+
* Does not affect {{ workflow.context.NAME.raw }}.
|
|
257
|
+
* Default: 'xml'
|
|
258
|
+
*/
|
|
259
|
+
context_wrapper?: ContextWrapperFormat;
|
|
260
|
+
/**
|
|
261
|
+
* How the workflow was originally created. Stamped at registration time — runtime-only.
|
|
262
|
+
* Never write to workflow YAML.
|
|
263
|
+
* 'human' — registered via YAML file (CLI register / watch).
|
|
264
|
+
* 'agent' — created at runtime via the create_workflow MCP tool.
|
|
265
|
+
*/
|
|
266
|
+
origin?: 'human' | 'agent';
|
|
267
|
+
/**
|
|
268
|
+
* LLM model identifier used to create this workflow (e.g. "claude-sonnet-4-6", "gpt-4o").
|
|
269
|
+
* Only meaningful when origin is 'agent'. Self-reported — not verified.
|
|
270
|
+
* Runtime-only — do not write to workflow YAML.
|
|
271
|
+
*/
|
|
272
|
+
model?: string;
|
|
273
|
+
/**
|
|
274
|
+
* Orchestrating tool or framework that called create_workflow
|
|
275
|
+
* (e.g. "cursor", "github-copilot"). Only meaningful when origin is 'agent'.
|
|
276
|
+
* Self-reported — not verified.
|
|
277
|
+
* Runtime-only — do not write to workflow YAML.
|
|
278
|
+
*/
|
|
279
|
+
agent?: string;
|
|
280
|
+
}
|
|
281
|
+
/** A single named entry in the workflow_context section. */
|
|
282
|
+
export interface WorkflowContextEntry {
|
|
283
|
+
/** Absolute file path — resolved from the YAML-relative path at registration time. */
|
|
284
|
+
source: {
|
|
285
|
+
path: string;
|
|
286
|
+
};
|
|
287
|
+
/** Optional human-readable description of what this context contains. */
|
|
288
|
+
description?: string;
|
|
289
|
+
}
|
|
290
|
+
/** Wrapper format applied to {{ workflow.context.NAME }} template references. */
|
|
291
|
+
export type ContextWrapperFormat = 'xml' | 'brackets' | 'none';
|
|
292
|
+
//# sourceMappingURL=workflow-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-definition.d.ts","sourceRoot":"","sources":["../../src/types/workflow-definition.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,CAAC;AAE7C,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,gBAA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C,CAAC;IACtC;;6DAEyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9E;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IACxD;;;;OAIG;IACH,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC3B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,4DAA4D;AAC5D,MAAM,WAAW,oBAAoB;IACnC,sFAAsF;IACtF,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACzB,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,iFAAiF;AACjF,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,UAAU,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-definition.js","sourceRoot":"","sources":["../../src/types/workflow-definition.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type ErrorCategory = 'NETWORK' | 'SERVICE' | 'STATE' | 'VALIDATION' | 'ENGINE' | 'RESOURCE';
|
|
2
|
+
export type AgentAction = 'report_to_user' | 'provide_input' | 'resolve_precondition' | 'stop' | 'wait_for_human' | 'wait_and_proceed';
|
|
3
|
+
export type ErrorCode = 'NETWORK_TIMEOUT' | 'NETWORK_UNREACHABLE' | 'NETWORK_DNS_FAILED' | 'NETWORK_CONNECTION_RESET' | 'SERVICE_HTTP_4XX' | 'SERVICE_HTTP_5XX' | 'SERVICE_RATE_LIMITED' | 'SERVICE_AUTH_FAILED' | 'SERVICE_NOT_FOUND' | 'SERVICE_RESPONSE_INVALID' | 'STATE_BLOCKED' | 'STATE_PRECONDITION_FAILED' | 'STATE_RUN_NOT_FOUND' | 'STATE_WORKFLOW_NOT_FOUND' | 'STATE_RUN_TERMINAL' | 'STATE_SNAPSHOT_MISMATCH' | 'STATE_RUN_LOCKED' | 'STATE_TRANSITION_DENIED' | 'STATE_LEGACY_FORMAT' | 'STATE_STEP_ALREADY_CLAIMED' | 'STATE_STEP_NOT_ELIGIBLE' | 'STATE_RUN_DIVERGED' | 'VALIDATION_INPUT_SCHEMA' | 'VALIDATION_OUTPUT_SCHEMA' | 'VALIDATION_TRACE_SCHEMA' | 'VALIDATION_WORKFLOW_SCHEMA' | 'VALIDATION_HASH_MISMATCH' | 'VALIDATION_QUOTE_NOT_FOUND' | 'VALIDATION_FIELD_UNKNOWN' | 'VALIDATION_FIELD_EXCLUDED' | 'VALIDATION_EMPTY_VALUE' | 'STEP_HANDLER_ERROR' | 'ENGINE_INTERNAL' | 'ENGINE_STORE_FAILED' | 'ENGINE_ADAPTER_FAILED' | 'ENGINE_PROCESSOR_FAILED' | 'ENGINE_HANDLER_FAILED' | 'ENGINE_STEP_FAILED' | 'ENGINE_GATE_OPEN_FAILED' | 'GATE_MESSAGE_UNRESOLVABLE' | 'FILTER_UNKNOWN' | 'ADAPTER_OP_UNSUPPORTED' | 'ADAPTER_VALIDATION_FAILED' | 'ADAPTER_REQUEST_FAILED' | 'STEP_TIMEOUT' | 'STEP_ABORTED' | 'STEP_RETRY_EXHAUSTED' | 'STATE_STEP_PENDING' | 'STEP_NOT_FOUND' | 'RESOURCE_FETCH_FAILED' | 'RESOURCE_TOO_LARGE' | 'RESOURCE_FORMAT_INVALID' | 'RESOURCE_NOT_ACCESSIBLE' | 'BUFFER_FULL' | 'MCP_CONNECTION_FAILED' | 'MCP_TOOL_NOT_FOUND' | 'MCP_TOOL_NAME_COLLISION';
|
|
4
|
+
export interface WorkflowErrorOptions {
|
|
5
|
+
code: ErrorCode;
|
|
6
|
+
category: ErrorCategory;
|
|
7
|
+
agentAction: AgentAction;
|
|
8
|
+
retryable: boolean;
|
|
9
|
+
details?: Record<string, unknown>;
|
|
10
|
+
stepId?: string;
|
|
11
|
+
attempt?: number;
|
|
12
|
+
retry_after?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class WorkflowError extends Error {
|
|
15
|
+
readonly code: ErrorCode;
|
|
16
|
+
readonly category: ErrorCategory;
|
|
17
|
+
readonly agentAction: AgentAction;
|
|
18
|
+
readonly retryable: boolean;
|
|
19
|
+
readonly details: Record<string, unknown>;
|
|
20
|
+
readonly stepId?: string;
|
|
21
|
+
readonly timestamp: string;
|
|
22
|
+
readonly attempt: number;
|
|
23
|
+
readonly retry_after?: number;
|
|
24
|
+
constructor(message: string, options: WorkflowErrorOptions);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=workflow-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-error.d.ts","sourceRoot":"","sources":["../../src/types/workflow-error.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEnG,MAAM,MAAM,WAAW,GACnB,gBAAgB,GAChB,eAAe,GACf,sBAAsB,GACtB,MAAM,GACN,gBAAgB,GAChB,kBAAkB,CAAC;AAEvB,MAAM,MAAM,SAAS,GAEjB,iBAAiB,GACjB,qBAAqB,GACrB,oBAAoB,GACpB,0BAA0B,GAE1B,kBAAkB,GAClB,kBAAkB,GAClB,sBAAsB,GACtB,qBAAqB,GACrB,mBAAmB,GACnB,0BAA0B,GAE1B,eAAe,GACf,2BAA2B,GAC3B,qBAAqB,GACrB,0BAA0B,GAC1B,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AAC;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;gBAElB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB;CAa3D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Structured, categorized error class used throughout the engine.
|
|
2
|
+
export class WorkflowError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
category;
|
|
5
|
+
agentAction;
|
|
6
|
+
retryable;
|
|
7
|
+
details;
|
|
8
|
+
stepId;
|
|
9
|
+
timestamp;
|
|
10
|
+
attempt;
|
|
11
|
+
retry_after;
|
|
12
|
+
constructor(message, options) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'WorkflowError';
|
|
15
|
+
this.code = options.code;
|
|
16
|
+
this.category = options.category;
|
|
17
|
+
this.agentAction = options.agentAction;
|
|
18
|
+
this.retryable = options.retryable;
|
|
19
|
+
this.details = options.details ?? {};
|
|
20
|
+
if (options.stepId !== undefined)
|
|
21
|
+
this.stepId = options.stepId;
|
|
22
|
+
this.timestamp = new Date().toISOString();
|
|
23
|
+
this.attempt = options.attempt ?? 1;
|
|
24
|
+
if (options.retry_after !== undefined)
|
|
25
|
+
this.retry_after = options.retry_after;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=workflow-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-error.js","sourceRoot":"","sources":["../../src/types/workflow-error.ts"],"names":[],"mappings":"AAAA,kEAAkE;AA0FlE,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,IAAI,CAAY;IAChB,QAAQ,CAAgB;IACxB,WAAW,CAAc;IACzB,SAAS,CAAU;IACnB,OAAO,CAA0B;IACjC,MAAM,CAAU;IAChB,SAAS,CAAS;IAClB,OAAO,CAAS;IAChB,WAAW,CAAU;IAE9B,YAAY,OAAe,EAAE,OAA6B;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QACrC,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS;YAAE,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC/D,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;QACpC,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS;YAAE,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAChF,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type JsonSchema = Record<string, unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* Returns a minimal skeleton value for the given JSON Schema.
|
|
4
|
+
* Only required properties are included for object types.
|
|
5
|
+
* Enums produce a "<val1|val2>" placeholder string.
|
|
6
|
+
* Arrays produce a one-element array of the item skeleton.
|
|
7
|
+
* Nested objects are recursed.
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateSchemaSkeleton(schema: JsonSchema): unknown;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=schema-skeleton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-skeleton.d.ts","sourceRoot":"","sources":["../../src/utils/schema-skeleton.ts"],"names":[],"mappings":"AAGA,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CA+BlE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Generates a minimal conforming skeleton from a JSON Schema object.
|
|
2
|
+
// Used to populate call_with placeholders in NextAction instructions.
|
|
3
|
+
/**
|
|
4
|
+
* Returns a minimal skeleton value for the given JSON Schema.
|
|
5
|
+
* Only required properties are included for object types.
|
|
6
|
+
* Enums produce a "<val1|val2>" placeholder string.
|
|
7
|
+
* Arrays produce a one-element array of the item skeleton.
|
|
8
|
+
* Nested objects are recursed.
|
|
9
|
+
*/
|
|
10
|
+
export function generateSchemaSkeleton(schema) {
|
|
11
|
+
const type = schema['type'];
|
|
12
|
+
const properties = schema['properties'];
|
|
13
|
+
if (type === 'object' || (type === undefined && properties !== undefined)) {
|
|
14
|
+
if (properties === undefined)
|
|
15
|
+
return {};
|
|
16
|
+
const required = schema['required'] ?? Object.keys(properties);
|
|
17
|
+
const result = {};
|
|
18
|
+
for (const key of required) {
|
|
19
|
+
const propSchema = properties[key];
|
|
20
|
+
if (propSchema !== undefined) {
|
|
21
|
+
result[key] = generateSchemaSkeleton(propSchema);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
if (type === 'array') {
|
|
27
|
+
const items = schema['items'];
|
|
28
|
+
return items !== undefined ? [generateSchemaSkeleton(items)] : [];
|
|
29
|
+
}
|
|
30
|
+
if (type === 'string') {
|
|
31
|
+
const enumValues = schema['enum'];
|
|
32
|
+
return enumValues !== undefined ? `<${enumValues.join('|')}>` : '';
|
|
33
|
+
}
|
|
34
|
+
if (type === 'number' || type === 'integer')
|
|
35
|
+
return 0;
|
|
36
|
+
if (type === 'boolean')
|
|
37
|
+
return false;
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=schema-skeleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-skeleton.js","sourceRoot":"","sources":["../../src/utils/schema-skeleton.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sEAAsE;AAItE;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAkB;IACvD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5B,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAA2C,CAAC;IAElF,IAAI,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,UAAU,KAAK,SAAS,CAAC,EAAE,CAAC;QAC1E,IAAI,UAAU,KAAK,SAAS;YAAE,OAAO,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAI,MAAM,CAAC,UAAU,CAA0B,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACzF,MAAM,MAAM,GAA4B,EAAE,CAAC;QAC3C,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;YAC3B,MAAM,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;QACrB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAA2B,CAAC;QACxD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACpE,CAAC;IAED,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAyB,CAAC;QAC1D,OAAO,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,CAAC;IAED,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,CAAC,CAAC;IACtD,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAErC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { JsonSchema } from '../types/workflow-definition.js';
|
|
2
|
+
import type { TraceEntry } from '../types/run-record.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validates input against the step's declared JSON Schema.
|
|
5
|
+
* Throws WorkflowError(VALIDATION_INPUT_SCHEMA) on failure.
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateInputSchema(input: Record<string, unknown>, schema: JsonSchema, stepId: string): void;
|
|
8
|
+
/**
|
|
9
|
+
* Validates the agent's submitted output against the step's declared JSON Schema.
|
|
10
|
+
* Throws WorkflowError(VALIDATION_OUTPUT_SCHEMA) on failure.
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateOutputSchema(output: Record<string, unknown>, schema: JsonSchema, stepId: string): void;
|
|
13
|
+
export interface TraceSchemaWarnResult {
|
|
14
|
+
errorCount: number;
|
|
15
|
+
warning: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Validates canonical trace entries against the step's declared trace_schema.
|
|
19
|
+
*
|
|
20
|
+
* In 'enforce' mode: throws WorkflowError(VALIDATION_TRACE_SCHEMA, agentAction: 'provide_input').
|
|
21
|
+
* In 'warn' mode: returns a result with errorCount and a human-readable warning string.
|
|
22
|
+
* Returns { errorCount: 0, warning: '' } when validation passes in warn mode.
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateTraceSchema(entries: TraceEntry[], schema: JsonSchema, stepId: string, mode: 'enforce'): void;
|
|
25
|
+
export declare function validateTraceSchema(entries: TraceEntry[], schema: JsonSchema, stepId: string, mode: 'warn'): TraceSchemaWarnResult;
|
|
26
|
+
//# sourceMappingURL=input-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-schema.d.ts","sourceRoot":"","sources":["../../src/validation/input-schema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GACb,IAAI,CAaN;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GACb,IAAI,CAaN;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,UAAU,EAAE,EACrB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,GACd,IAAI,CAAC;AACR,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,UAAU,EAAE,EACrB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Input schema validation — validates step input against a declared JSON Schema using Ajv.
|
|
2
|
+
import { Ajv } from 'ajv';
|
|
3
|
+
import { WorkflowError } from '../types/workflow-error.js';
|
|
4
|
+
/**
|
|
5
|
+
* Validates input against the step's declared JSON Schema.
|
|
6
|
+
* Throws WorkflowError(VALIDATION_INPUT_SCHEMA) on failure.
|
|
7
|
+
*/
|
|
8
|
+
export function validateInputSchema(input, schema, stepId) {
|
|
9
|
+
const ajv = new Ajv();
|
|
10
|
+
const valid = ajv.validate(schema, input);
|
|
11
|
+
if (!valid) {
|
|
12
|
+
throw new WorkflowError(`Invalid input for step '${stepId}'`, {
|
|
13
|
+
code: 'VALIDATION_INPUT_SCHEMA',
|
|
14
|
+
category: 'VALIDATION',
|
|
15
|
+
agentAction: 'provide_input',
|
|
16
|
+
retryable: false,
|
|
17
|
+
details: { errors: ajv.errors ?? [] },
|
|
18
|
+
stepId,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Validates the agent's submitted output against the step's declared JSON Schema.
|
|
24
|
+
* Throws WorkflowError(VALIDATION_OUTPUT_SCHEMA) on failure.
|
|
25
|
+
*/
|
|
26
|
+
export function validateOutputSchema(output, schema, stepId) {
|
|
27
|
+
const ajv = new Ajv();
|
|
28
|
+
const valid = ajv.validate(schema, output);
|
|
29
|
+
if (!valid) {
|
|
30
|
+
throw new WorkflowError(`Output validation failed for step '${stepId}'`, {
|
|
31
|
+
code: 'VALIDATION_OUTPUT_SCHEMA',
|
|
32
|
+
category: 'VALIDATION',
|
|
33
|
+
agentAction: 'provide_input',
|
|
34
|
+
retryable: false,
|
|
35
|
+
details: { errors: ajv.errors ?? [] },
|
|
36
|
+
stepId,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function validateTraceSchema(entries, schema, stepId, mode) {
|
|
41
|
+
const ajv = new Ajv();
|
|
42
|
+
const valid = ajv.validate(schema, entries);
|
|
43
|
+
if (valid) {
|
|
44
|
+
if (mode === 'warn')
|
|
45
|
+
return { errorCount: 0, warning: '' };
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (mode === 'enforce') {
|
|
49
|
+
throw new WorkflowError(`Trace schema validation failed for step '${stepId}'`, {
|
|
50
|
+
code: 'VALIDATION_TRACE_SCHEMA',
|
|
51
|
+
category: 'VALIDATION',
|
|
52
|
+
agentAction: 'provide_input',
|
|
53
|
+
retryable: false,
|
|
54
|
+
details: { errors: ajv.errors ?? [] },
|
|
55
|
+
stepId,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
// warn mode — return error details without throwing
|
|
59
|
+
const errorSummary = (ajv.errors ?? [])
|
|
60
|
+
.map((e) => `${e.instancePath !== '' ? e.instancePath + ' ' : ''}${e.message ?? ''}`.trim())
|
|
61
|
+
.join('; ');
|
|
62
|
+
return {
|
|
63
|
+
errorCount: (ajv.errors ?? []).length,
|
|
64
|
+
warning: `Trace schema violation for step '${stepId}': ${errorSummary}`,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=input-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-schema.js","sourceRoot":"","sources":["../../src/validation/input-schema.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAG3D;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAA8B,EAC9B,MAAkB,EAClB,MAAc;IAEd,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IACtB,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAgB,EAAE,KAAK,CAAC,CAAC;IACpD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,aAAa,CAAC,2BAA2B,MAAM,GAAG,EAAE;YAC5D,IAAI,EAAE,yBAAyB;YAC/B,QAAQ,EAAE,YAAY;YACtB,WAAW,EAAE,eAAe;YAC5B,SAAS,EAAE,KAAK;YAChB,OA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AE,GAAG,CAAC,MAAM,IAAI,EAAE,EAAE;YACrC,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,oDAAoD;IACpD,MAAM,YAAY,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC;SACpC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,YAAY,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;SAC3F,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO;QACL,UAAU,EAAE,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,MAAM;QACrC,OAAO,EAAE,oCAAoC,MAAM,MAAM,YAAY,EAAE;KACxE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { WorkflowDefinition } from '../types/workflow-definition.js';
|
|
2
|
+
export interface WorkflowRegistrar {
|
|
3
|
+
/** Persist a WorkflowDefinition under its id, overwriting any previous registration. */
|
|
4
|
+
register(definition: WorkflowDefinition): Promise<void>;
|
|
5
|
+
/** Retrieve a WorkflowDefinition by id. Throws WorkflowError if not found. */
|
|
6
|
+
get(workflowId: string): Promise<WorkflowDefinition>;
|
|
7
|
+
/** List all registered workflows. */
|
|
8
|
+
list(): Promise<WorkflowDefinition[]>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Stores WorkflowDefinition objects as JSON files at ~/.realm/workflows/{id}.json.
|
|
12
|
+
*/
|
|
13
|
+
export declare class JsonWorkflowStore implements WorkflowRegistrar {
|
|
14
|
+
private readonly dir;
|
|
15
|
+
constructor(baseDir?: string);
|
|
16
|
+
register(definition: WorkflowDefinition): Promise<void>;
|
|
17
|
+
get(workflowId: string): Promise<WorkflowDefinition>;
|
|
18
|
+
list(): Promise<WorkflowDefinition[]>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=registrar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registrar.d.ts","sourceRoot":"","sources":["../../src/workflow/registrar.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAI1E,MAAM,WAAW,iBAAiB;IAChC,wFAAwF;IACxF,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,8EAA8E;IAC9E,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACrD,qCAAqC;IACrC,IAAI,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;CACvC;AAED;;GAEG;AACH,qBAAa,iBAAkB,YAAW,iBAAiB;IACzD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;gBAEjB,OAAO,CAAC,EAAE,MAAM;IAKtB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQvD,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgCpD,IAAI,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;CAa5C"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// JsonWorkflowStore — persists registered WorkflowDefinition objects to ~/.realm/workflows/.
|
|
2
|
+
import { readFileSync, writeFileSync, mkdirSync, readdirSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { WorkflowError } from '../types/workflow-error.js';
|
|
6
|
+
import { CURRENT_WORKFLOW_SCHEMA_VERSION } from './yaml-loader.js';
|
|
7
|
+
/**
|
|
8
|
+
* Stores WorkflowDefinition objects as JSON files at ~/.realm/workflows/{id}.json.
|
|
9
|
+
*/
|
|
10
|
+
export class JsonWorkflowStore {
|
|
11
|
+
dir;
|
|
12
|
+
constructor(baseDir) {
|
|
13
|
+
this.dir = baseDir ?? join(homedir(), '.realm', 'workflows');
|
|
14
|
+
mkdirSync(this.dir, { recursive: true });
|
|
15
|
+
}
|
|
16
|
+
async register(definition) {
|
|
17
|
+
writeFileSync(join(this.dir, `${definition.id}.json`), JSON.stringify(definition, null, 2), 'utf8');
|
|
18
|
+
}
|
|
19
|
+
async get(workflowId) {
|
|
20
|
+
const filePath = join(this.dir, `${workflowId}.json`);
|
|
21
|
+
let raw;
|
|
22
|
+
try {
|
|
23
|
+
raw = readFileSync(filePath, 'utf8');
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new WorkflowError(`Workflow not found: ${workflowId}`, {
|
|
27
|
+
code: 'STATE_WORKFLOW_NOT_FOUND',
|
|
28
|
+
category: 'STATE',
|
|
29
|
+
agentAction: 'report_to_user',
|
|
30
|
+
retryable: false,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const parsed = JSON.parse(raw);
|
|
34
|
+
if (parsed.schema_version === undefined ||
|
|
35
|
+
parsed.schema_version < CURRENT_WORKFLOW_SCHEMA_VERSION) {
|
|
36
|
+
throw new WorkflowError('This workflow was registered with an older version of Realm. ' +
|
|
37
|
+
'Re-register it with: realm workflow register <path-to-workflow>', {
|
|
38
|
+
code: 'STATE_LEGACY_FORMAT',
|
|
39
|
+
category: 'STATE',
|
|
40
|
+
agentAction: 'report_to_user',
|
|
41
|
+
retryable: false,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return parsed;
|
|
45
|
+
}
|
|
46
|
+
async list() {
|
|
47
|
+
const entries = readdirSync(this.dir).filter((f) => f.endsWith('.json'));
|
|
48
|
+
const results = [];
|
|
49
|
+
for (const entry of entries) {
|
|
50
|
+
try {
|
|
51
|
+
const raw = readFileSync(join(this.dir, entry), 'utf8');
|
|
52
|
+
results.push(JSON.parse(raw));
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Skip files that fail to parse
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return results;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=registrar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registrar.js","sourceRoot":"","sources":["../../src/workflow/registrar.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AAWnE;;GAEG;AACH,MAAM,OAAO,iBAAiB;IACX,GAAG,CAAS;IAE7B,YAAY,OAAgB;QAC1B,IAAI,CAAC,GAAG,GAAG,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;QAC7D,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,UAA8B;QAC3C,aAAa,CACX,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,CAAC,EAAE,OAAO,CAAC,EACvC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,EACnC,MAAM,CACP,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,UAAkB;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,OAAO,CAAC,CAAC;QACtD,IAAI,GAAW,CAAC;QACh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