@elevasis/sdk 0.5.13 → 0.5.15
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/dist/cli.cjs +745 -409
- package/dist/index.d.ts +32 -0
- package/dist/index.js +68 -0
- package/dist/templates.js +254 -37
- package/dist/worker/index.js +3 -7
- package/package.json +1 -1
- package/reference/cli.mdx +568 -505
- package/reference/concepts.mdx +4 -43
- package/reference/deployment/api.mdx +297 -297
- package/reference/deployment/command-center.mdx +9 -12
- package/reference/deployment/index.mdx +7 -7
- package/reference/framework/agent.mdx +6 -18
- package/reference/framework/interaction-guidance.mdx +182 -182
- package/reference/framework/memory.mdx +3 -24
- package/reference/framework/project-structure.mdx +277 -298
- package/reference/framework/tutorial-system.mdx +13 -44
- package/reference/getting-started.mdx +152 -148
- package/reference/index.mdx +28 -14
- package/reference/platform-tools/adapters.mdx +868 -1072
- package/reference/platform-tools/index.mdx +3 -3
- package/reference/resources/index.mdx +339 -341
- package/reference/resources/patterns.mdx +355 -354
- package/reference/resources/types.mdx +207 -207
- package/reference/roadmap.mdx +163 -147
- package/reference/runtime.mdx +2 -25
- package/reference/troubleshooting.mdx +223 -210
|
@@ -1,341 +1,339 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Writing Resources
|
|
3
|
-
description: Guide to creating workflows and agents using WorkflowDefinition, AgentDefinition, and OrganizationResources with the Elevasis SDK
|
|
4
|
-
loadWhen: "Building or modifying a workflow"
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
Resources are the building blocks of your Elevasis project. A resource is a workflow or agent definition that the platform can execute on your behalf. You define them in TypeScript, export them from a single entry point, and the platform handles scheduling, retries, logging, and execution.
|
|
8
|
-
|
|
9
|
-
This page covers how to structure your resources, write step handlers, and export everything through `OrganizationResources`.
|
|
10
|
-
|
|
11
|
-
## WorkflowDefinition
|
|
12
|
-
|
|
13
|
-
A workflow is a series of named steps executed in sequence or branching paths. You define it with a `WorkflowDefinition` object.
|
|
14
|
-
|
|
15
|
-
A complete workflow definition has four required properties:
|
|
16
|
-
|
|
17
|
-
- `config` - metadata about the workflow (name, description, status)
|
|
18
|
-
- `contract` - Zod schemas for input and output validation
|
|
19
|
-
- `steps` - a record of named step handlers
|
|
20
|
-
- `entryPoint` - the name of the first step to execute
|
|
21
|
-
|
|
22
|
-
### Minimal Example
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
import { z } from 'zod';
|
|
26
|
-
import type { WorkflowDefinition } from '@elevasis/sdk';
|
|
27
|
-
|
|
28
|
-
const echoInput = z.object({
|
|
29
|
-
message: z.string(),
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const echoOutput = z.object({
|
|
33
|
-
result: z.string(),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
type EchoInput = z.infer<typeof echoInput>;
|
|
37
|
-
|
|
38
|
-
const echoWorkflow: WorkflowDefinition = {
|
|
39
|
-
config: {
|
|
40
|
-
resourceId: 'echo',
|
|
41
|
-
name: 'Echo',
|
|
42
|
-
type: 'workflow',
|
|
43
|
-
description: 'Returns the input message unchanged',
|
|
44
|
-
version: '1.0.0',
|
|
45
|
-
status: 'dev',
|
|
46
|
-
},
|
|
47
|
-
contract: {
|
|
48
|
-
inputSchema: echoInput,
|
|
49
|
-
outputSchema: echoOutput,
|
|
50
|
-
},
|
|
51
|
-
steps: {
|
|
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,
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
entryPoint: 'run',
|
|
66
|
-
};
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### config
|
|
70
|
-
|
|
71
|
-
The `config` block identifies the workflow on the platform:
|
|
72
|
-
|
|
73
|
-
| Field
|
|
74
|
-
|
|
|
75
|
-
| `resourceId`
|
|
76
|
-
| `name`
|
|
77
|
-
| `type`
|
|
78
|
-
| `description` | `string`
|
|
79
|
-
| `version`
|
|
80
|
-
| `status`
|
|
81
|
-
| `domains`
|
|
82
|
-
|
|
83
|
-
### contract
|
|
84
|
-
|
|
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`.
|
|
86
|
-
|
|
87
|
-
Always use `z.object()` for both schemas. Use `z.infer` to derive TypeScript types -- this keeps types and runtime validation in sync automatically.
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
const contract = {
|
|
91
|
-
inputSchema: z.object({
|
|
92
|
-
userId: z.string().uuid(),
|
|
93
|
-
action: z.string(),
|
|
94
|
-
}),
|
|
95
|
-
outputSchema: z.object({
|
|
96
|
-
success: z.boolean(),
|
|
97
|
-
message: z.string(),
|
|
98
|
-
}),
|
|
99
|
-
};
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### steps
|
|
103
|
-
|
|
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.
|
|
105
|
-
|
|
106
|
-
```typescript
|
|
107
|
-
const steps = {
|
|
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
|
|
118
|
-
},
|
|
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
|
|
129
|
-
},
|
|
130
|
-
};
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### entryPoint
|
|
134
|
-
|
|
135
|
-
`entryPoint` is the name of the first step. For single-step workflows it is always the only step name. For multi-step workflows it is the name of the first step in the chain.
|
|
136
|
-
|
|
137
|
-
```typescript
|
|
138
|
-
const workflow: WorkflowDefinition = {
|
|
139
|
-
// ...
|
|
140
|
-
entryPoint: 'validate', // execution starts here
|
|
141
|
-
};
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
## Multi-Step Workflows
|
|
147
|
-
|
|
148
|
-
For workflows with more than one step, import `StepType` from `@elevasis/sdk` to configure step routing.
|
|
149
|
-
|
|
150
|
-
### Linear Steps
|
|
151
|
-
|
|
152
|
-
Use `StepType.LINEAR` to connect steps in a fixed sequence. Each step declares a `next` property pointing to the next step name.
|
|
153
|
-
|
|
154
|
-
```typescript
|
|
155
|
-
import { z } from 'zod';
|
|
156
|
-
import type { WorkflowDefinition, WorkflowStep } from '@elevasis/sdk';
|
|
157
|
-
|
|
158
|
-
const fetchStep: WorkflowStep = {
|
|
159
|
-
id: 'fetch',
|
|
160
|
-
name: 'Fetch',
|
|
161
|
-
description: 'Fetches the raw data',
|
|
162
|
-
handler: async (input) => {
|
|
163
|
-
const data = await fetchSomething((input as { id: string }).id);
|
|
164
|
-
return { data };
|
|
165
|
-
},
|
|
166
|
-
inputSchema: z.object({ id: z.string() }),
|
|
167
|
-
outputSchema: z.object({ data: z.unknown() }),
|
|
168
|
-
next: { target: 'process' },
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const processStep: WorkflowStep = {
|
|
172
|
-
id: 'process',
|
|
173
|
-
name: 'Process',
|
|
174
|
-
description: 'Transforms the fetched data',
|
|
175
|
-
handler: async (input) => {
|
|
176
|
-
return { result: transform((input as { data: unknown }).data) };
|
|
177
|
-
},
|
|
178
|
-
inputSchema: z.object({ data: z.unknown() }),
|
|
179
|
-
outputSchema: z.object({ result: z.string() }),
|
|
180
|
-
next: null, // terminal step
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
const pipeline: WorkflowDefinition = {
|
|
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 },
|
|
193
|
-
steps: { fetch: fetchStep, process: processStep },
|
|
194
|
-
entryPoint: 'fetch',
|
|
195
|
-
};
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### Conditional Branching
|
|
199
|
-
|
|
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 `
|
|
201
|
-
|
|
202
|
-
```typescript
|
|
203
|
-
import { z } from 'zod';
|
|
204
|
-
import type { WorkflowStep } from '@elevasis/sdk';
|
|
205
|
-
|
|
206
|
-
const routerStep: WorkflowStep = {
|
|
207
|
-
id: 'router',
|
|
208
|
-
name: 'Router',
|
|
209
|
-
description: 'Scores the input and routes to the appropriate path',
|
|
210
|
-
handler: async (input) => {
|
|
211
|
-
const score = await evaluate(input);
|
|
212
|
-
return { score };
|
|
213
|
-
},
|
|
214
|
-
inputSchema: z.object({ value: z.unknown() }),
|
|
215
|
-
outputSchema: z.object({ score: z.number() }),
|
|
216
|
-
next: {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
|
257
|
-
|
|
|
258
|
-
| `
|
|
259
|
-
| `
|
|
260
|
-
| `
|
|
261
|
-
| `
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
**Last Updated:** 2026-02-25
|
|
1
|
+
---
|
|
2
|
+
title: Writing Resources
|
|
3
|
+
description: Guide to creating workflows and agents using WorkflowDefinition, AgentDefinition, and OrganizationResources with the Elevasis SDK
|
|
4
|
+
loadWhen: "Building or modifying a workflow"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Resources are the building blocks of your Elevasis project. A resource is a workflow or agent definition that the platform can execute on your behalf. You define them in TypeScript, export them from a single entry point, and the platform handles scheduling, retries, logging, and execution.
|
|
8
|
+
|
|
9
|
+
This page covers how to structure your resources, write step handlers, and export everything through `OrganizationResources`.
|
|
10
|
+
|
|
11
|
+
## WorkflowDefinition
|
|
12
|
+
|
|
13
|
+
A workflow is a series of named steps executed in sequence or branching paths. You define it with a `WorkflowDefinition` object.
|
|
14
|
+
|
|
15
|
+
A complete workflow definition has four required properties:
|
|
16
|
+
|
|
17
|
+
- `config` - metadata about the workflow (name, description, status)
|
|
18
|
+
- `contract` - Zod schemas for input and output validation
|
|
19
|
+
- `steps` - a record of named step handlers
|
|
20
|
+
- `entryPoint` - the name of the first step to execute
|
|
21
|
+
|
|
22
|
+
### Minimal Example
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { z } from 'zod';
|
|
26
|
+
import type { WorkflowDefinition } from '@elevasis/sdk';
|
|
27
|
+
|
|
28
|
+
const echoInput = z.object({
|
|
29
|
+
message: z.string(),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const echoOutput = z.object({
|
|
33
|
+
result: z.string(),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
type EchoInput = z.infer<typeof echoInput>;
|
|
37
|
+
|
|
38
|
+
const echoWorkflow: WorkflowDefinition = {
|
|
39
|
+
config: {
|
|
40
|
+
resourceId: 'echo',
|
|
41
|
+
name: 'Echo',
|
|
42
|
+
type: 'workflow',
|
|
43
|
+
description: 'Returns the input message unchanged',
|
|
44
|
+
version: '1.0.0',
|
|
45
|
+
status: 'dev',
|
|
46
|
+
},
|
|
47
|
+
contract: {
|
|
48
|
+
inputSchema: echoInput,
|
|
49
|
+
outputSchema: echoOutput,
|
|
50
|
+
},
|
|
51
|
+
steps: {
|
|
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,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
entryPoint: 'run',
|
|
66
|
+
};
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### config
|
|
70
|
+
|
|
71
|
+
The `config` block identifies the workflow on the platform:
|
|
72
|
+
|
|
73
|
+
| Field | Type | Description |
|
|
74
|
+
| ------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
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. |
|
|
82
|
+
|
|
83
|
+
### contract
|
|
84
|
+
|
|
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`.
|
|
86
|
+
|
|
87
|
+
Always use `z.object()` for both schemas. Use `z.infer` to derive TypeScript types -- this keeps types and runtime validation in sync automatically.
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const contract = {
|
|
91
|
+
inputSchema: z.object({
|
|
92
|
+
userId: z.string().uuid(),
|
|
93
|
+
action: z.string(),
|
|
94
|
+
}),
|
|
95
|
+
outputSchema: z.object({
|
|
96
|
+
success: z.boolean(),
|
|
97
|
+
message: z.string(),
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### steps
|
|
103
|
+
|
|
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.
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
const steps = {
|
|
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: { type: 'linear', target: 'process' }, // points to the next step
|
|
118
|
+
},
|
|
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
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### entryPoint
|
|
134
|
+
|
|
135
|
+
`entryPoint` is the name of the first step. For single-step workflows it is always the only step name. For multi-step workflows it is the name of the first step in the chain.
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
const workflow: WorkflowDefinition = {
|
|
139
|
+
// ...
|
|
140
|
+
entryPoint: 'validate', // execution starts here
|
|
141
|
+
};
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Multi-Step Workflows
|
|
147
|
+
|
|
148
|
+
For workflows with more than one step, import `StepType` from `@elevasis/sdk` to configure step routing.
|
|
149
|
+
|
|
150
|
+
### Linear Steps
|
|
151
|
+
|
|
152
|
+
Use `StepType.LINEAR` to connect steps in a fixed sequence. Each step declares a `next` property pointing to the next step name.
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
import { z } from 'zod';
|
|
156
|
+
import type { WorkflowDefinition, WorkflowStep } from '@elevasis/sdk';
|
|
157
|
+
|
|
158
|
+
const fetchStep: WorkflowStep = {
|
|
159
|
+
id: 'fetch',
|
|
160
|
+
name: 'Fetch',
|
|
161
|
+
description: 'Fetches the raw data',
|
|
162
|
+
handler: async (input) => {
|
|
163
|
+
const data = await fetchSomething((input as { id: string }).id);
|
|
164
|
+
return { data };
|
|
165
|
+
},
|
|
166
|
+
inputSchema: z.object({ id: z.string() }),
|
|
167
|
+
outputSchema: z.object({ data: z.unknown() }),
|
|
168
|
+
next: { type: 'linear', target: 'process' },
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const processStep: WorkflowStep = {
|
|
172
|
+
id: 'process',
|
|
173
|
+
name: 'Process',
|
|
174
|
+
description: 'Transforms the fetched data',
|
|
175
|
+
handler: async (input) => {
|
|
176
|
+
return { result: transform((input as { data: unknown }).data) };
|
|
177
|
+
},
|
|
178
|
+
inputSchema: z.object({ data: z.unknown() }),
|
|
179
|
+
outputSchema: z.object({ result: z.string() }),
|
|
180
|
+
next: null, // terminal step
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const pipeline: WorkflowDefinition = {
|
|
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 },
|
|
193
|
+
steps: { fetch: fetchStep, process: processStep },
|
|
194
|
+
entryPoint: 'fetch',
|
|
195
|
+
};
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Conditional Branching
|
|
199
|
+
|
|
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 `default` fallback step is required.
|
|
201
|
+
|
|
202
|
+
```typescript
|
|
203
|
+
import { z } from 'zod';
|
|
204
|
+
import type { WorkflowStep } from '@elevasis/sdk';
|
|
205
|
+
|
|
206
|
+
const routerStep: WorkflowStep = {
|
|
207
|
+
id: 'router',
|
|
208
|
+
name: 'Router',
|
|
209
|
+
description: 'Scores the input and routes to the appropriate path',
|
|
210
|
+
handler: async (input) => {
|
|
211
|
+
const score = await evaluate(input);
|
|
212
|
+
return { score };
|
|
213
|
+
},
|
|
214
|
+
inputSchema: z.object({ value: z.unknown() }),
|
|
215
|
+
outputSchema: z.object({ score: z.number() }),
|
|
216
|
+
next: {
|
|
217
|
+
type: 'conditional',
|
|
218
|
+
routes: [
|
|
219
|
+
{
|
|
220
|
+
condition: (output) => (output as { score: number }).score \>= 80,
|
|
221
|
+
target: 'highScorePath',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
condition: (output) => (output as { score: number }).score \>= 50,
|
|
225
|
+
target: 'mediumScorePath',
|
|
226
|
+
},
|
|
227
|
+
],
|
|
228
|
+
default: 'lowScorePath',
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## StepContext
|
|
236
|
+
|
|
237
|
+
Every step handler can optionally accept a second `context` parameter. TypeScript allows you to omit it if you do not need it -- you can write `handler: async (input) => { ... }` without declaring `context`.
|
|
238
|
+
|
|
239
|
+
When you do need it, the context provides runtime metadata:
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import type { StepHandler } from '@elevasis/sdk';
|
|
243
|
+
|
|
244
|
+
const myStep: StepHandler = async (input, context) => {
|
|
245
|
+
const { executionId, organizationId, resourceId, logger, store } = context;
|
|
246
|
+
|
|
247
|
+
logger.info('Starting step', { executionId });
|
|
248
|
+
|
|
249
|
+
// store is a simple key-value store scoped to this execution
|
|
250
|
+
await store.set('progress', '50%');
|
|
251
|
+
|
|
252
|
+
return { done: true };
|
|
253
|
+
};
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
| Field | Type | Description |
|
|
257
|
+
| ---------------- | -------- | -------------------------------------------------------------- |
|
|
258
|
+
| `executionId` | `string` | Unique ID for this execution run |
|
|
259
|
+
| `organizationId` | `string` | Your organization ID |
|
|
260
|
+
| `resourceId` | `string` | ID of the workflow or agent being executed |
|
|
261
|
+
| `logger` | `Logger` | Structured logger -- messages appear in the Elevasis dashboard |
|
|
262
|
+
| `store` | `Store` | Key-value store scoped to the current execution |
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## AgentDefinition
|
|
267
|
+
|
|
268
|
+
Agents are autonomous resources that use an LLM and tools to complete a goal. You define them with `AgentDefinition`.
|
|
269
|
+
|
|
270
|
+
**Note:** Use `elevasis-sdk 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.
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
import type { AgentDefinition } from '@elevasis/sdk';
|
|
274
|
+
|
|
275
|
+
const myAgent: AgentDefinition = {
|
|
276
|
+
config: {
|
|
277
|
+
name: 'my-agent',
|
|
278
|
+
description: 'Answers questions using platform tools',
|
|
279
|
+
status: 'dev',
|
|
280
|
+
},
|
|
281
|
+
agentConfig: {
|
|
282
|
+
model: { provider: 'openai', model: 'gpt-4o' },
|
|
283
|
+
systemPrompt: 'You are a helpful assistant.',
|
|
284
|
+
maxIterations: 10,
|
|
285
|
+
},
|
|
286
|
+
tools: [],
|
|
287
|
+
};
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
## OrganizationResources
|
|
293
|
+
|
|
294
|
+
All resources must be exported through an `OrganizationResources` default export from `src/index.ts`. This is the entry point the platform reads when you deploy.
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
import type { OrganizationResources } from '@elevasis/sdk';
|
|
298
|
+
|
|
299
|
+
const org: OrganizationResources = {
|
|
300
|
+
workflows: [echoWorkflow, pipeline],
|
|
301
|
+
agents: [
|
|
302
|
+
// myAgent,
|
|
303
|
+
],
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export default org;
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Each resource's `config.resourceId` is used as its identifier on the platform. These IDs appear in CLI output (`elevasis-sdk resources`), execution commands (`elevasis-sdk exec`), and the dashboard.
|
|
310
|
+
|
|
311
|
+
### Resource Status
|
|
312
|
+
|
|
313
|
+
Set `config.status` to control whether the platform accepts execution requests:
|
|
314
|
+
|
|
315
|
+
- `'dev'` - Resource is visible in the dashboard but the platform will not route scheduled or webhook-triggered executions to it. You can still trigger it manually via `elevasis-sdk exec`.
|
|
316
|
+
- `'prod'` - Resource is live and accepts all execution sources.
|
|
317
|
+
|
|
318
|
+
Use `'dev'` while you are building and testing. Switch to `'prod'` when you are ready to go live.
|
|
319
|
+
|
|
320
|
+
You can also set a global default status in `elevasis.config.ts`:
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
import type { ElevasConfig } from '@elevasis/sdk';
|
|
324
|
+
|
|
325
|
+
const config: ElevasConfig = {
|
|
326
|
+
defaultStatus: 'dev',
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
export default config;
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
## Documentation
|
|
333
|
+
|
|
334
|
+
- [SDK Types](types.mdx) - Complete type reference for `@elevasis/sdk` exports, config, and step handler context
|
|
335
|
+
- [Common Patterns](patterns.mdx) - Sequential steps, conditional branching, error handling, and resource status patterns
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
**Last Updated:** 2026-02-25
|