@elevasis/sdk 0.4.16 → 0.5.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.
@@ -23,7 +23,7 @@ A complete workflow definition has four required properties:
23
23
 
24
24
  ```typescript
25
25
  import { z } from 'zod';
26
- import type { WorkflowDefinition, OrganizationResources } from '@elevasis/sdk';
26
+ import type { WorkflowDefinition } from '@elevasis/sdk';
27
27
 
28
28
  const echoInput = z.object({
29
29
  message: z.string(),
@@ -34,21 +34,32 @@ const echoOutput = z.object({
34
34
  });
35
35
 
36
36
  type EchoInput = z.infer<typeof echoInput>;
37
- type EchoOutput = z.infer<typeof echoOutput>;
38
37
 
39
38
  const echoWorkflow: WorkflowDefinition = {
40
39
  config: {
41
- name: 'echo',
40
+ resourceId: 'echo',
41
+ name: 'Echo',
42
+ type: 'workflow',
42
43
  description: 'Returns the input message unchanged',
44
+ version: '1.0.0',
43
45
  status: 'dev',
44
46
  },
45
47
  contract: {
46
- input: echoInput,
47
- output: echoOutput,
48
+ inputSchema: echoInput,
49
+ outputSchema: echoOutput,
48
50
  },
49
51
  steps: {
50
- run: async (input: EchoInput): Promise<EchoOutput> => {
51
- return { result: input.message };
52
+ run: {
53
+ id: 'run',
54
+ name: 'Run',
55
+ description: 'Returns the input message unchanged',
56
+ handler: async (input) => {
57
+ const { message } = input as EchoInput;
58
+ return { result: message };
59
+ },
60
+ inputSchema: echoInput,
61
+ outputSchema: echoOutput,
62
+ next: null,
52
63
  },
53
64
  },
54
65
  entryPoint: 'run',
@@ -61,23 +72,27 @@ The `config` block identifies the workflow on the platform:
61
72
 
62
73
  | Field | Type | Description |
63
74
  | ----- | ---- | ----------- |
64
- | `name` | `string` | Unique name within your organization. Used by the CLI and platform UI. |
65
- | `description` | `string` | Human-readable summary shown in the dashboard. |
66
- | `status` | `'dev' | 'production'` | Controls availability. Use `'dev'` while building. See [Resource Status](#resource-status). |
75
+ | `resourceId` | `string` | Unique lowercase ID within your organization (e.g., `send-welcome-email`). Used by the CLI to target this resource. |
76
+ | `name` | `string` | Human-readable display name shown in the dashboard. |
77
+ | `type` | `'workflow'` | Always the literal string `'workflow'` for workflow resources. |
78
+ | `description` | `string` | Summary shown in the dashboard and command center. |
79
+ | `version` | `string` | Semver string (e.g., `'1.0.0'`). Increment when making breaking changes to the contract. |
80
+ | `status` | `'dev' | 'prod'` | Controls availability. Use `'dev'` while building. See [Resource Status](#resource-status). |
81
+ | `domains` | `string[]` | Optional. Groups resources in the command center view. |
67
82
 
68
83
  ### contract
69
84
 
70
- The `contract` block defines the Zod schemas for input and output. The platform validates input against `contract.input` before passing it to your step handler, and validates the step's return value against `contract.output`.
85
+ The `contract` block defines the Zod schemas for input and output. The platform validates input against `contract.inputSchema` before passing it to your entry step handler, and validates the final step's return value against `contract.outputSchema`.
71
86
 
72
- Always use `z.object()` for both schemas. Use `z.infer` to derive TypeScript types from the schemas -- this keeps types and runtime validation in sync automatically.
87
+ Always use `z.object()` for both schemas. Use `z.infer` to derive TypeScript types -- this keeps types and runtime validation in sync automatically.
73
88
 
74
89
  ```typescript
75
90
  const contract = {
76
- input: z.object({
91
+ inputSchema: z.object({
77
92
  userId: z.string().uuid(),
78
93
  action: z.string(),
79
94
  }),
80
- output: z.object({
95
+ outputSchema: z.object({
81
96
  success: z.boolean(),
82
97
  message: z.string(),
83
98
  }),
@@ -86,17 +101,31 @@ const contract = {
86
101
 
87
102
  ### steps
88
103
 
89
- The `steps` record maps step names to handler functions. Each handler receives the validated input and an optional `StepContext` (execution metadata). Single-step workflows have one entry; multi-step workflows have one entry per step.
104
+ The `steps` record maps step IDs to step objects. Each step has metadata (`id`, `name`, `description`), a `handler` function, Zod schemas for its own input and output, and a `next` property that controls routing.
90
105
 
91
106
  ```typescript
92
107
  const steps = {
93
- validate: async (input: MyInput) => {
94
- // first step -- returns output to pass to next step
95
- return { validated: true, data: input };
108
+ validate: {
109
+ id: 'validate',
110
+ name: 'Validate',
111
+ description: 'Validates the incoming request',
112
+ handler: async (input: MyInput) => {
113
+ return { validated: true, data: input };
114
+ },
115
+ inputSchema: myInputSchema,
116
+ outputSchema: z.object({ validated: z.boolean(), data: myInputSchema }),
117
+ next: { target: 'process' }, // points to the next step
96
118
  },
97
- process: async (input: ValidatedData) => {
98
- // second step
99
- return { result: 'done' };
119
+ process: {
120
+ id: 'process',
121
+ name: 'Process',
122
+ description: 'Processes the validated data',
123
+ handler: async (input: ValidatedData) => {
124
+ return { result: 'done' };
125
+ },
126
+ inputSchema: z.object({ validated: z.boolean(), data: myInputSchema }),
127
+ outputSchema: z.object({ result: z.string() }),
128
+ next: null, // terminal step
100
129
  },
101
130
  };
102
131
  ```
@@ -124,29 +153,43 @@ Use `StepType.LINEAR` to connect steps in a fixed sequence. Each step declares a
124
153
 
125
154
  ```typescript
126
155
  import { z } from 'zod';
127
- import { StepType } from '@elevasis/sdk';
128
156
  import type { WorkflowDefinition, WorkflowStep } from '@elevasis/sdk';
129
157
 
130
158
  const fetchStep: WorkflowStep = {
131
- type: StepType.LINEAR,
159
+ id: 'fetch',
160
+ name: 'Fetch',
161
+ description: 'Fetches the raw data',
132
162
  handler: async (input) => {
133
- const data = await fetchSomething(input.id);
163
+ const data = await fetchSomething((input as { id: string }).id);
134
164
  return { data };
135
165
  },
166
+ inputSchema: z.object({ id: z.string() }),
167
+ outputSchema: z.object({ data: z.unknown() }),
136
168
  next: { target: 'process' },
137
169
  };
138
170
 
139
171
  const processStep: WorkflowStep = {
140
- type: StepType.LINEAR,
172
+ id: 'process',
173
+ name: 'Process',
174
+ description: 'Transforms the fetched data',
141
175
  handler: async (input) => {
142
- return { result: transform(input.data) };
176
+ return { result: transform((input as { data: unknown }).data) };
143
177
  },
178
+ inputSchema: z.object({ data: z.unknown() }),
179
+ outputSchema: z.object({ result: z.string() }),
144
180
  next: null, // terminal step
145
181
  };
146
182
 
147
183
  const pipeline: WorkflowDefinition = {
148
- config: { name: 'pipeline', description: 'Fetch then process', status: 'dev' },
149
- contract: { input: pipelineInput, output: pipelineOutput },
184
+ config: {
185
+ resourceId: 'pipeline',
186
+ name: 'Pipeline',
187
+ type: 'workflow',
188
+ description: 'Fetch then process',
189
+ version: '1.0.0',
190
+ status: 'dev',
191
+ },
192
+ contract: { inputSchema: pipelineInput, outputSchema: pipelineOutput },
150
193
  steps: { fetch: fetchStep, process: processStep },
151
194
  entryPoint: 'fetch',
152
195
  };
@@ -157,23 +200,27 @@ const pipeline: WorkflowDefinition = {
157
200
  Use `StepType.CONDITIONAL` to route to different steps based on output values. Each route has a `condition` function and a `target` step name. The first condition that returns `true` wins. A `defaultTarget` is required as a fallback.
158
201
 
159
202
  ```typescript
160
- import { StepType } from '@elevasis/sdk';
203
+ import { z } from 'zod';
161
204
  import type { WorkflowStep } from '@elevasis/sdk';
162
205
 
163
206
  const routerStep: WorkflowStep = {
164
- type: StepType.CONDITIONAL,
207
+ id: 'router',
208
+ name: 'Router',
209
+ description: 'Scores the input and routes to the appropriate path',
165
210
  handler: async (input) => {
166
211
  const score = await evaluate(input);
167
212
  return { score };
168
213
  },
214
+ inputSchema: z.object({ value: z.unknown() }),
215
+ outputSchema: z.object({ score: z.number() }),
169
216
  next: {
170
217
  routes: [
171
218
  {
172
- condition: (output) => output.score \>= 80,
219
+ condition: (output) => (output as { score: number }).score \>= 80,
173
220
  target: 'highScorePath',
174
221
  },
175
222
  {
176
- condition: (output) => output.score \>= 50,
223
+ condition: (output) => (output as { score: number }).score \>= 50,
177
224
  target: 'mediumScorePath',
178
225
  },
179
226
  ],
@@ -219,7 +266,7 @@ const myStep: StepHandler = async (input, context) => {
219
266
 
220
267
  Agents are autonomous resources that use an LLM and tools to complete a goal. You define them with `AgentDefinition`.
221
268
 
222
- **Note:** Agent execution in the worker runtime is not yet fully supported. Defining agents is supported for forward compatibility, but executions will return a failure response until agent execution ships.
269
+ **Note:** Use `elevasis exec --async` when executing agents. Agents can run for minutes or longer, and the synchronous execute endpoint will time out for long-running runs. The `--async` flag returns an execution ID immediately and polls for the result.
223
270
 
224
271
  ```typescript
225
272
  import type { AgentDefinition } from '@elevasis/sdk';