@elevasis/sdk 1.25.0 → 1.26.1

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.
Files changed (64) hide show
  1. package/dist/cli.cjs +87 -120
  2. package/dist/index.d.ts +220 -50
  3. package/dist/index.js +4 -435
  4. package/dist/node/index.d.ts +46 -38
  5. package/dist/test-utils/index.d.ts +154 -40
  6. package/dist/test-utils/index.js +27 -355
  7. package/dist/types/worker/adapters/clickup.d.ts +22 -0
  8. package/dist/types/worker/adapters/index.d.ts +1 -0
  9. package/dist/worker/index.js +32 -354
  10. package/package.json +2 -2
  11. package/reference/_navigation.md +11 -1
  12. package/reference/_reference-manifest.json +70 -0
  13. package/reference/claude-config/rules/organization-model.md +12 -1
  14. package/reference/claude-config/rules/organization-os.md +12 -1
  15. package/reference/claude-config/skills/om/SKILL.md +13 -5
  16. package/reference/claude-config/skills/om/operations/codify-level-a.md +109 -100
  17. package/reference/claude-config/skills/om/operations/customers.md +10 -6
  18. package/reference/claude-config/skills/om/operations/features.md +7 -3
  19. package/reference/claude-config/skills/om/operations/goals.md +10 -6
  20. package/reference/claude-config/skills/om/operations/identity.md +8 -5
  21. package/reference/claude-config/skills/om/operations/labels.md +17 -1
  22. package/reference/claude-config/skills/om/operations/offerings.md +11 -7
  23. package/reference/claude-config/skills/om/operations/roles.md +11 -7
  24. package/reference/claude-config/skills/om/operations/techStack.md +10 -2
  25. package/reference/claude-config/skills/setup/SKILL.md +2 -2
  26. package/reference/claude-config/sync-notes/2026-05-20-om-define-helpers.md +32 -0
  27. package/reference/claude-config/sync-notes/2026-05-22-access-model-and-right-panel.md +43 -0
  28. package/reference/claude-config/sync-notes/2026-05-22-lead-gen-tenant-config.md +40 -0
  29. package/reference/claude-config/sync-notes/2026-05-22-org-model-multi-file-split.md +61 -0
  30. package/reference/claude-config/sync-notes/2026-05-23-branding-names-to-identity.md +49 -0
  31. package/reference/claude-config/sync-notes/2026-05-23-om-deployment-drift-detection.md +42 -0
  32. package/reference/cli-management.mdx +541 -0
  33. package/reference/cli.mdx +4 -532
  34. package/reference/concepts.mdx +134 -146
  35. package/reference/deployment/api.mdx +296 -297
  36. package/reference/deployment/command-center.mdx +208 -209
  37. package/reference/deployment/index.mdx +194 -195
  38. package/reference/deployment/provided-features.mdx +110 -107
  39. package/reference/deployment/ui-execution.mdx +249 -250
  40. package/reference/examples/organization-model.ts +14 -4
  41. package/reference/framework/index.mdx +111 -195
  42. package/reference/framework/resource-documentation.mdx +90 -0
  43. package/reference/framework/tutorial-system.mdx +135 -135
  44. package/reference/getting-started.mdx +141 -142
  45. package/reference/index.mdx +95 -106
  46. package/reference/packages/ui/src/auth/README.md +6 -6
  47. package/reference/platform-tools/adapters-integration.mdx +300 -301
  48. package/reference/platform-tools/adapters-platform.mdx +552 -553
  49. package/reference/platform-tools/index.mdx +216 -217
  50. package/reference/platform-tools/type-safety.mdx +82 -82
  51. package/reference/resources/index.mdx +348 -349
  52. package/reference/resources/patterns.mdx +446 -449
  53. package/reference/resources/types.mdx +115 -116
  54. package/reference/roadmap.mdx +164 -165
  55. package/reference/rules/organization-model.md +14 -0
  56. package/reference/runtime.mdx +172 -173
  57. package/reference/scaffold/operations/propagation-pipeline.md +1 -1
  58. package/reference/scaffold/recipes/extend-lead-gen.md +130 -77
  59. package/reference/scaffold/reference/contracts.md +376 -446
  60. package/reference/scaffold/reference/glossary.md +8 -6
  61. package/reference/scaffold/ui/feature-flags-and-gating.md +59 -46
  62. package/reference/scaffold/ui/feature-shell.mdx +11 -11
  63. package/reference/scaffold/ui/recipes.md +24 -24
  64. package/reference/troubleshooting.mdx +222 -223
@@ -1,449 +1,446 @@
1
- ---
2
- title: Common Patterns
3
- description: Common resource patterns for Elevasis SDK developers -- sequential steps, conditional branching, platform tools, error handling, and resource status management
4
- loadWhen: "Building or modifying a workflow"
5
- ---
6
-
7
- This page collects the patterns you will reach for most often when writing resources. Each pattern is self-contained and can be adapted directly into your project.
8
-
9
- ---
10
-
11
- ## Sequential Workflow Steps
12
-
13
- The simplest pattern: a chain of steps where each step feeds its output into the next.
14
-
15
- ```typescript
16
- import { z } from 'zod';
17
- import { StepType } from '@elevasis/sdk';
18
- import type { WorkflowDefinition, WorkflowStep } from '@elevasis/sdk';
19
-
20
- const inputSchema = z.object({ orderId: z.string() });
21
- const outputSchema = z.object({ shipped: z.boolean(), trackingNumber: z.string() });
22
-
23
- type Input = z.infer<typeof inputSchema>;
24
- type Output = z.infer<typeof outputSchema>;
25
-
26
- const validateStep: WorkflowStep = {
27
- type: StepType.LINEAR,
28
- handler: async (input: Input) => {
29
- const order = await getOrder(input.orderId);
30
- if (!order) throw new Error(`Order ${input.orderId} not found`);
31
- return { order };
32
- },
33
- next: { type: 'linear', target: 'ship' },
34
- };
35
-
36
- const shipStep: WorkflowStep = {
37
- type: StepType.LINEAR,
38
- handler: async (input) => {
39
- const tracking = await createShipment(input.order);
40
- return { shipped: true, trackingNumber: tracking.number };
41
- },
42
- next: null, // terminal -- no further steps
43
- };
44
-
45
- const fulfillOrder: WorkflowDefinition = {
46
- config: { resourceId: 'fulfill-order', name: 'Fulfill Order', type: 'workflow', description: 'Validates and ships an order', version: '1.0.0', status: 'dev' },
47
- contract: { inputSchema, outputSchema },
48
- steps: { validate: validateStep, ship: shipStep },
49
- entryPoint: 'validate',
50
- };
51
- ```
52
-
53
- **Key points:**
54
-
55
- - `next: { target: 'stepName' }` routes to the next step
56
- - `next: null` marks the terminal step
57
- - Each step receives the full return value of the previous step as its `input`
58
- - The terminal step's return value must satisfy `contract.output`
59
-
60
- ---
61
-
62
- ## Conditional Branching
63
-
64
- Use `StepType.CONDITIONAL` when the next step depends on the output of the current step.
65
-
66
- ```typescript
67
- import { StepType } from '@elevasis/sdk';
68
- import type { WorkflowStep } from '@elevasis/sdk';
69
-
70
- const scoreStep: WorkflowStep = {
71
- type: StepType.CONDITIONAL,
72
- handler: async (input) => {
73
- const score = await calculateRiskScore(input.applicationId);
74
- return { score, applicationId: input.applicationId };
75
- },
76
- next: {
77
- type: 'conditional',
78
- routes: [
79
- {
80
- condition: (output) => output.score \>= 80,
81
- target: 'autoApprove',
82
- },
83
- {
84
- condition: (output) => output.score \>= 40,
85
- target: 'manualReview',
86
- },
87
- ],
88
- default: 'autoReject', // used when no condition matches
89
- },
90
- };
91
- ```
92
-
93
- **Key points:**
94
-
95
- - Routes are evaluated in order -- the first matching condition wins
96
- - `default` is required and acts as the `else` branch
97
- - The condition function receives the full handler output
98
- - All route targets and `default` must be keys in your `steps` record
99
-
100
- ---
101
-
102
- ## Using Platform Tools in Steps
103
-
104
- Platform tools let your steps call integrations managed by Elevasis (email, CRM, databases, etc.). Import `platform` from `@elevasis/sdk/worker` and call it with the tool name, method, parameters, and an optional credential reference when the tool requires one.
105
-
106
- ```typescript
107
- import { platform, PlatformToolError } from '@elevasis/sdk/worker';
108
- import type { WorkflowStep } from '@elevasis/sdk';
109
- import { StepType } from '@elevasis/sdk';
110
-
111
- const sendEmailStep: WorkflowStep = {
112
- type: StepType.LINEAR,
113
- handler: async (input, context) => {
114
- const result = await platform.call({
115
- tool: 'email',
116
- method: 'send',
117
- params: {
118
- to: input.recipientEmail,
119
- subject: input.subject,
120
- body: input.body,
121
- },
122
- credential: 'sendgrid', // name of the stored credential
123
- });
124
-
125
- context.logger.info('Email sent', { messageId: result.messageId });
126
- return { sent: true, messageId: result.messageId };
127
- },
128
- next: null,
129
- };
130
- ```
131
-
132
- **Key points:**
133
-
134
- - `platform.call()` is async and times out after 60 seconds
135
- - `credential` is the name of a platform environment variable set via `elevasis-sdk env set` when the tool needs one
136
- - On failure, `platform.call()` throws `PlatformToolError` (not `ToolingError`)
137
- - Always log success so executions are easy to debug in the dashboard
138
-
139
- ---
140
-
141
- ## Error Handling
142
-
143
- ### Catching Tool Errors
144
-
145
- Use `PlatformToolError` (from `@elevasis/sdk/worker`) to handle tool-specific failures without catching everything:
146
-
147
- ```typescript
148
- import { platform, PlatformToolError } from '@elevasis/sdk/worker';
149
-
150
- const step = async (input) => {
151
- try {
152
- const deals = await platform.call({
153
- tool: 'crm',
154
- method: 'listDeals',
155
- params: { stage: 'proposal', limit: 10 },
156
- });
157
-
158
- const deal = deals[0]
159
- ? await platform.call({
160
- tool: 'crm',
161
- method: 'getDeal',
162
- params: { dealId: deals[0].id },
163
- })
164
- : null;
165
-
166
- if (deal) {
167
- await platform.call({
168
- tool: 'crm',
169
- method: 'updateDealStage',
170
- params: { dealId: deal.id, stage: 'closing' },
171
- });
172
-
173
- await platform.call({
174
- tool: 'crm',
175
- method: 'createDealNote',
176
- params: {
177
- dealId: deal.id,
178
- body: 'Reviewed proposal and moved the deal forward.',
179
- },
180
- });
181
-
182
- await platform.call({
183
- tool: 'crm',
184
- method: 'createDealTask',
185
- params: {
186
- dealId: deal.id,
187
- title: 'Send updated proposal',
188
- dueAt: input.followUpAt ?? null,
189
- },
190
- });
191
-
192
- await platform.call({
193
- tool: 'crm',
194
- method: 'recordActivity',
195
- params: {
196
- dealId: deal.id,
197
- type: 'stage_changed',
198
- title: 'Deal moved to closing',
199
- description: 'Reviewed the proposal and moved the deal forward.',
200
- },
201
- });
202
- }
203
-
204
- return { dealId: deal?.id ?? null, dealCount: deals.length };
205
- } catch (err) {
206
- if (err instanceof PlatformToolError) {
207
- // Tool failed -- log it and return a degraded result
208
- console.error('CRM tool failed:', err.message);
209
- return { dealId: null, error: err.message };
210
- }
211
- throw err; // re-throw unexpected errors
212
- }
213
- };
214
- ```
215
-
216
- ### Failing an Execution Explicitly
217
-
218
- Use `ExecutionError` when your step detects a condition that should mark the entire execution as failed:
219
-
220
- ```typescript
221
- import { ExecutionError } from '@elevasis/sdk';
222
-
223
- const validateStep = async (input) => {
224
- if (!input.userId) {
225
- throw new ExecutionError('userId is required', { code: 'MISSING_INPUT' });
226
- }
227
- if (input.amount \<= 0) {
228
- throw new ExecutionError('amount must be positive', { code: 'INVALID_AMOUNT' });
229
- }
230
- return { valid: true };
231
- };
232
- ```
233
-
234
- `ExecutionError` messages and metadata appear in the Elevasis dashboard under the failed execution's detail view.
235
-
236
- ### Using ToolingError
237
-
238
- `ToolingError` is thrown by lower-level platform operations (not `platform.call()` directly). You may encounter it in advanced scenarios:
239
-
240
- ```typescript
241
- import { ToolingError } from '@elevasis/sdk';
242
-
243
- const step = async (input) => {
244
- try {
245
- return await doSomething(input);
246
- } catch (err) {
247
- if (err instanceof ToolingError) {
248
- // check err.type for the error category
249
- console.error('Tooling error:', err.type, err.message);
250
- }
251
- throw err;
252
- }
253
- };
254
- ```
255
-
256
- ---
257
-
258
- ## Logging in Steps
259
-
260
- The `context.logger` writes structured logs attached to the execution. Use it instead of `console.log` so logs appear in the dashboard alongside the execution record.
261
-
262
- ```typescript
263
- import type { StepHandler } from '@elevasis/sdk';
264
-
265
- const processStep: StepHandler = async (input, context) => {
266
- context.logger.info('Starting process', { userId: input.userId });
267
-
268
- const result = await doWork(input);
269
-
270
- context.logger.info('Process complete', { resultId: result.id });
271
- return result;
272
- };
273
- ```
274
-
275
- Avoid logging sensitive values (API keys, passwords, PII) since logs are stored and visible in the dashboard.
276
-
277
- ---
278
-
279
- ## Using the Execution Store
280
-
281
- `context.store` is a simple key-value store scoped to the current execution. Use it to pass data between steps without coupling step interfaces, or to checkpoint long-running work.
282
-
283
- ```typescript
284
- const firstStep: StepHandler = async (input, context) => {
285
- const data = await fetchExpensiveData(input.id);
286
-
287
- // Save for use by later steps
288
- await context.store.set('fetchedData', JSON.stringify(data));
289
-
290
- return { fetched: true };
291
- };
292
-
293
- const secondStep: StepHandler = async (input, context) => {
294
- const raw = await context.store.get('fetchedData');
295
- const data = JSON.parse(raw ?? '{}');
296
-
297
- return { processed: transform(data) };
298
- };
299
- ```
300
-
301
- Store values are strings. Serialize objects with `JSON.stringify` and parse with `JSON.parse`.
302
-
303
- ---
304
-
305
- ## Resource Status
306
-
307
- ### Dev vs Production
308
-
309
- While building a resource, set `config.status` to `'dev'`:
310
-
311
- ```typescript
312
- const myWorkflow: WorkflowDefinition = {
313
- config: {
314
- name: 'my-workflow',
315
- description: 'Does something useful',
316
- status: 'dev', // only manually triggerable
317
- },
318
- // ...
319
- };
320
- ```
321
-
322
- Dev resources:
323
-
324
- - Appear in `elevasis-sdk resources` output
325
- - Can be triggered with `elevasis-sdk exec my-workflow --input '{...}'`
326
- - Will NOT receive scheduled or webhook-triggered executions
327
- - Will NOT appear as available to external callers
328
-
329
- When you are ready to go live, change to `'prod'` and redeploy:
330
-
331
- ```typescript
332
- config: {
333
- name: 'my-workflow',
334
- description: 'Does something useful',
335
- status: 'prod', // receives all execution sources
336
- },
337
- ```
338
-
339
- ### Global Default Status
340
-
341
- Set a project-wide default in `elevasis.config.ts` to keep all resources in `'dev'` mode during development without touching each resource file:
342
-
343
- ```typescript
344
- import type { ElevasConfig } from '@elevasis/sdk';
345
-
346
- const config: ElevasConfig = {
347
- defaultStatus: 'dev',
348
- };
349
-
350
- export default config;
351
- ```
352
-
353
- Individual resources that set their own `config.status` override this default.
354
-
355
- ---
356
-
357
- ## Organizing Multiple Resources
358
-
359
- As your project grows, organize resources by business domain. Each domain gets its own directory with an `index.ts` barrel that exports `workflows` and `agents` arrays:
360
-
361
- ```typescript
362
- // src/orders/fulfill-order.ts
363
- export const fulfillOrder: WorkflowDefinition = { ... };
364
-
365
- // src/billing/send-invoice.ts
366
- export const sendInvoice: WorkflowDefinition = { ... };
367
-
368
- // src/orders/index.ts
369
- import { fulfillOrder } from './fulfill-order.js';
370
- export const workflows = [fulfillOrder];
371
- export const agents = [];
372
-
373
- // src/billing/index.ts
374
- import { sendInvoice } from './send-invoice.js';
375
- export const workflows = [sendInvoice];
376
- export const agents = [];
377
-
378
- // src/index.ts
379
- import type { DeploymentSpec } from '@elevasis/sdk';
380
- import * as orders from './orders/index.js';
381
- import * as billing from './billing/index.js';
382
-
383
- const org: DeploymentSpec = {
384
- workflows: [
385
- ...orders.workflows,
386
- ...billing.workflows,
387
- ],
388
- agents: [
389
- ...orders.agents,
390
- ...billing.agents,
391
- ],
392
- };
393
-
394
- export default org;
395
- ```
396
-
397
- The keys in `workflows` and `agents` are the resource identifiers used in CLI commands and the dashboard. Choose names that are descriptive and use kebab-case for consistency.
398
-
399
- ---
400
-
401
- ---
402
-
403
- ## Human-in-the-Loop UI Integration
404
-
405
- The platform's HITL mechanism works in two parts: your workflow code creates an approval task, and a UI surfaces that task to a reviewer.
406
-
407
- ### Creating approval tasks
408
-
409
- Call `approval.create()` from any workflow step to pause execution and emit a task to the Command Queue:
410
-
411
- ```typescript
412
- import { approval } from '@elevasis/sdk/worker'
413
-
414
- const task = await approval.create({
415
- actions: [
416
- { id: 'approve', label: 'Approve', type: 'primary' },
417
- { id: 'reject', label: 'Reject', type: 'danger' },
418
- ],
419
- context: { dealId, proposalUrl },
420
- description: 'Review proposal before sending',
421
- })
422
-
423
- if (task.actionId === 'approve') {
424
- // continue with approved path
425
- }
426
- ```
427
-
428
- The workflow step suspends at `approval.create()` and resumes only after a reviewer submits an action. See [Platform Adapters](../platform-tools/adapters-platform.mdx) for the full `approval.create()` reference.
429
-
430
- ### Built-in Command Center handling
431
-
432
- The Command Queue page in the Command Center surfaces all pending approval tasks automatically. Reviewers can filter by resource, approve or reject with an optional comment, and view decision history. No custom UI code is required -- deploy your workflow and the queue populates as tasks arrive.
433
-
434
- ### Custom UI handling
435
-
436
- `@elevasis/ui` exposes the following hooks for approval task operations, exported from `@elevasis/ui/hooks`:
437
-
438
- - `useCommandQueue` -- fetches the list of pending tasks for the organization
439
- - `useSubmitAction` -- POSTs an action decision to `/command-queue/{taskId}/action`
440
- - `usePatchTask` -- updates task metadata
441
- - `useDeleteTask` -- removes a task
442
-
443
- Use these hooks to build a custom approval queue surface in your template UI. `useSubmitAction` accepts `taskId`, `actionId`, and optional `notes`, and optimistically marks the task as `processing` while the request is in flight.
444
-
445
- For triggering executions from custom pages (the other side of the workflow interaction), see [UI Execution](../deployment/ui-execution.mdx).
446
-
447
- ---
448
-
449
- **Last Updated:** 2026-02-25
1
+ ---
2
+ title: Common Patterns
3
+ description: Common resource patterns for Elevasis SDK developers -- sequential steps, conditional branching, platform tools, error handling, and resource status management
4
+ ---
5
+
6
+ This page collects the patterns you will reach for most often when writing resources. Each pattern is self-contained and can be adapted directly into your project.
7
+
8
+ ---
9
+
10
+ ## Sequential Workflow Steps
11
+
12
+ The simplest pattern: a chain of steps where each step feeds its output into the next.
13
+
14
+ ```typescript
15
+ import { z } from 'zod';
16
+ import { StepType } from '@elevasis/sdk';
17
+ import type { WorkflowDefinition, WorkflowStep } from '@elevasis/sdk';
18
+
19
+ const inputSchema = z.object({ orderId: z.string() });
20
+ const outputSchema = z.object({ shipped: z.boolean(), trackingNumber: z.string() });
21
+
22
+ type Input = z.infer<typeof inputSchema>;
23
+ type Output = z.infer<typeof outputSchema>;
24
+
25
+ const validateStep: WorkflowStep = {
26
+ type: StepType.LINEAR,
27
+ handler: async (input: Input) => {
28
+ const order = await getOrder(input.orderId);
29
+ if (!order) throw new Error(`Order ${input.orderId} not found`);
30
+ return { order };
31
+ },
32
+ next: { type: 'linear', target: 'ship' },
33
+ };
34
+
35
+ const shipStep: WorkflowStep = {
36
+ type: StepType.LINEAR,
37
+ handler: async (input) => {
38
+ const tracking = await createShipment(input.order);
39
+ return { shipped: true, trackingNumber: tracking.number };
40
+ },
41
+ next: null, // terminal -- no further steps
42
+ };
43
+
44
+ const fulfillOrder: WorkflowDefinition = {
45
+ config: { resourceId: 'fulfill-order', name: 'Fulfill Order', type: 'workflow', description: 'Validates and ships an order', version: '1.0.0', status: 'dev' },
46
+ contract: { inputSchema, outputSchema },
47
+ steps: { validate: validateStep, ship: shipStep },
48
+ entryPoint: 'validate',
49
+ };
50
+ ```
51
+
52
+ **Key points:**
53
+
54
+ - `next: { target: 'stepName' }` routes to the next step
55
+ - `next: null` marks the terminal step
56
+ - Each step receives the full return value of the previous step as its `input`
57
+ - The terminal step's return value must satisfy `contract.output`
58
+
59
+ ---
60
+
61
+ ## Conditional Branching
62
+
63
+ Use `StepType.CONDITIONAL` when the next step depends on the output of the current step.
64
+
65
+ ```typescript
66
+ import { StepType } from '@elevasis/sdk';
67
+ import type { WorkflowStep } from '@elevasis/sdk';
68
+
69
+ const scoreStep: WorkflowStep = {
70
+ type: StepType.CONDITIONAL,
71
+ handler: async (input) => {
72
+ const score = await calculateRiskScore(input.applicationId);
73
+ return { score, applicationId: input.applicationId };
74
+ },
75
+ next: {
76
+ type: 'conditional',
77
+ routes: [
78
+ {
79
+ condition: (output) => output.score \>= 80,
80
+ target: 'autoApprove',
81
+ },
82
+ {
83
+ condition: (output) => output.score \>= 40,
84
+ target: 'manualReview',
85
+ },
86
+ ],
87
+ default: 'autoReject', // used when no condition matches
88
+ },
89
+ };
90
+ ```
91
+
92
+ **Key points:**
93
+
94
+ - Routes are evaluated in order -- the first matching condition wins
95
+ - `default` is required and acts as the `else` branch
96
+ - The condition function receives the full handler output
97
+ - All route targets and `default` must be keys in your `steps` record
98
+
99
+ ---
100
+
101
+ ## Using Platform Tools in Steps
102
+
103
+ Platform tools let your steps call integrations managed by Elevasis (email, CRM, databases, etc.). Import `platform` from `@elevasis/sdk/worker` and call it with the tool name, method, parameters, and an optional credential reference when the tool requires one.
104
+
105
+ ```typescript
106
+ import { platform, PlatformToolError } from '@elevasis/sdk/worker';
107
+ import type { WorkflowStep } from '@elevasis/sdk';
108
+ import { StepType } from '@elevasis/sdk';
109
+
110
+ const sendEmailStep: WorkflowStep = {
111
+ type: StepType.LINEAR,
112
+ handler: async (input, context) => {
113
+ const result = await platform.call({
114
+ tool: 'email',
115
+ method: 'send',
116
+ params: {
117
+ to: input.recipientEmail,
118
+ subject: input.subject,
119
+ body: input.body,
120
+ },
121
+ credential: 'sendgrid', // name of the stored credential
122
+ });
123
+
124
+ context.logger.info('Email sent', { messageId: result.messageId });
125
+ return { sent: true, messageId: result.messageId };
126
+ },
127
+ next: null,
128
+ };
129
+ ```
130
+
131
+ **Key points:**
132
+
133
+ - `platform.call()` is async and times out after 60 seconds
134
+ - `credential` is the name of a platform environment variable set via `elevasis-sdk env set` when the tool needs one
135
+ - On failure, `platform.call()` throws `PlatformToolError` (not `ToolingError`)
136
+ - Always log success so executions are easy to debug in the dashboard
137
+
138
+ ---
139
+
140
+ ## Error Handling
141
+
142
+ ### Catching Tool Errors
143
+
144
+ Use `PlatformToolError` (from `@elevasis/sdk/worker`) to handle tool-specific failures without catching everything:
145
+
146
+ ```typescript
147
+ import { platform, PlatformToolError } from '@elevasis/sdk/worker';
148
+
149
+ const step = async (input) => {
150
+ try {
151
+ const deals = await platform.call({
152
+ tool: 'crm',
153
+ method: 'listDeals',
154
+ params: { stage: 'proposal', limit: 10 },
155
+ });
156
+
157
+ const deal = deals[0]
158
+ ? await platform.call({
159
+ tool: 'crm',
160
+ method: 'getDeal',
161
+ params: { dealId: deals[0].id },
162
+ })
163
+ : null;
164
+
165
+ if (deal) {
166
+ await platform.call({
167
+ tool: 'crm',
168
+ method: 'updateDealStage',
169
+ params: { dealId: deal.id, stage: 'closing' },
170
+ });
171
+
172
+ await platform.call({
173
+ tool: 'crm',
174
+ method: 'createDealNote',
175
+ params: {
176
+ dealId: deal.id,
177
+ body: 'Reviewed proposal and moved the deal forward.',
178
+ },
179
+ });
180
+
181
+ await platform.call({
182
+ tool: 'crm',
183
+ method: 'createDealTask',
184
+ params: {
185
+ dealId: deal.id,
186
+ title: 'Send updated proposal',
187
+ dueAt: input.followUpAt ?? null,
188
+ },
189
+ });
190
+
191
+ await platform.call({
192
+ tool: 'crm',
193
+ method: 'recordActivity',
194
+ params: {
195
+ dealId: deal.id,
196
+ type: 'stage_changed',
197
+ title: 'Deal moved to closing',
198
+ description: 'Reviewed the proposal and moved the deal forward.',
199
+ },
200
+ });
201
+ }
202
+
203
+ return { dealId: deal?.id ?? null, dealCount: deals.length };
204
+ } catch (err) {
205
+ if (err instanceof PlatformToolError) {
206
+ // Tool failed -- log it and return a degraded result
207
+ console.error('CRM tool failed:', err.message);
208
+ return { dealId: null, error: err.message };
209
+ }
210
+ throw err; // re-throw unexpected errors
211
+ }
212
+ };
213
+ ```
214
+
215
+ ### Failing an Execution Explicitly
216
+
217
+ Use `ExecutionError` when your step detects a condition that should mark the entire execution as failed:
218
+
219
+ ```typescript
220
+ import { ExecutionError } from '@elevasis/sdk';
221
+
222
+ const validateStep = async (input) => {
223
+ if (!input.userId) {
224
+ throw new ExecutionError('userId is required', { code: 'MISSING_INPUT' });
225
+ }
226
+ if (input.amount \<= 0) {
227
+ throw new ExecutionError('amount must be positive', { code: 'INVALID_AMOUNT' });
228
+ }
229
+ return { valid: true };
230
+ };
231
+ ```
232
+
233
+ `ExecutionError` messages and metadata appear in the Elevasis dashboard under the failed execution's detail view.
234
+
235
+ ### Using ToolingError
236
+
237
+ `ToolingError` is thrown by lower-level platform operations (not `platform.call()` directly). You may encounter it in advanced scenarios:
238
+
239
+ ```typescript
240
+ import { ToolingError } from '@elevasis/sdk';
241
+
242
+ const step = async (input) => {
243
+ try {
244
+ return await doSomething(input);
245
+ } catch (err) {
246
+ if (err instanceof ToolingError) {
247
+ // check err.type for the error category
248
+ console.error('Tooling error:', err.type, err.message);
249
+ }
250
+ throw err;
251
+ }
252
+ };
253
+ ```
254
+
255
+ ---
256
+
257
+ ## Logging in Steps
258
+
259
+ The `context.logger` writes structured logs attached to the execution. Use it instead of `console.log` so logs appear in the dashboard alongside the execution record.
260
+
261
+ ```typescript
262
+ import type { StepHandler } from '@elevasis/sdk';
263
+
264
+ const processStep: StepHandler = async (input, context) => {
265
+ context.logger.info('Starting process', { userId: input.userId });
266
+
267
+ const result = await doWork(input);
268
+
269
+ context.logger.info('Process complete', { resultId: result.id });
270
+ return result;
271
+ };
272
+ ```
273
+
274
+ Avoid logging sensitive values (API keys, passwords, PII) since logs are stored and visible in the dashboard.
275
+
276
+ ---
277
+
278
+ ## Using the Execution Store
279
+
280
+ `context.store` is a simple key-value store scoped to the current execution. Use it to pass data between steps without coupling step interfaces, or to checkpoint long-running work.
281
+
282
+ ```typescript
283
+ const firstStep: StepHandler = async (input, context) => {
284
+ const data = await fetchExpensiveData(input.id);
285
+
286
+ // Save for use by later steps
287
+ await context.store.set('fetchedData', JSON.stringify(data));
288
+
289
+ return { fetched: true };
290
+ };
291
+
292
+ const secondStep: StepHandler = async (input, context) => {
293
+ const raw = await context.store.get('fetchedData');
294
+ const data = JSON.parse(raw ?? '{}');
295
+
296
+ return { processed: transform(data) };
297
+ };
298
+ ```
299
+
300
+ Store values are strings. Serialize objects with `JSON.stringify` and parse with `JSON.parse`.
301
+
302
+ ---
303
+
304
+ ## Resource Status
305
+
306
+ ### Dev vs Production
307
+
308
+ While building a resource, set `config.status` to `'dev'`:
309
+
310
+ ```typescript
311
+ const myWorkflow: WorkflowDefinition = {
312
+ config: {
313
+ name: 'my-workflow',
314
+ description: 'Does something useful',
315
+ status: 'dev', // only manually triggerable
316
+ },
317
+ // ...
318
+ };
319
+ ```
320
+
321
+ Dev resources:
322
+
323
+ - Appear in `elevasis-sdk resources` output
324
+ - Can be triggered with `elevasis-sdk exec my-workflow --input '{...}'`
325
+ - Will NOT receive scheduled or webhook-triggered executions
326
+ - Will NOT appear as available to external callers
327
+
328
+ When you are ready to go live, change to `'prod'` and redeploy:
329
+
330
+ ```typescript
331
+ config: {
332
+ name: 'my-workflow',
333
+ description: 'Does something useful',
334
+ status: 'prod', // receives all execution sources
335
+ },
336
+ ```
337
+
338
+ ### Global Default Status
339
+
340
+ Set a project-wide default in `elevasis.config.ts` to keep all resources in `'dev'` mode during development without touching each resource file:
341
+
342
+ ```typescript
343
+ import type { ElevasConfig } from '@elevasis/sdk';
344
+
345
+ const config: ElevasConfig = {
346
+ defaultStatus: 'dev',
347
+ };
348
+
349
+ export default config;
350
+ ```
351
+
352
+ Individual resources that set their own `config.status` override this default.
353
+
354
+ ---
355
+
356
+ ## Organizing Multiple Resources
357
+
358
+ As your project grows, organize resources by business domain. Each domain gets its own directory with an `index.ts` barrel that exports `workflows` and `agents` arrays:
359
+
360
+ ```typescript
361
+ // src/orders/fulfill-order.ts
362
+ export const fulfillOrder: WorkflowDefinition = { ... };
363
+
364
+ // src/billing/send-invoice.ts
365
+ export const sendInvoice: WorkflowDefinition = { ... };
366
+
367
+ // src/orders/index.ts
368
+ import { fulfillOrder } from './fulfill-order.js';
369
+ export const workflows = [fulfillOrder];
370
+ export const agents = [];
371
+
372
+ // src/billing/index.ts
373
+ import { sendInvoice } from './send-invoice.js';
374
+ export const workflows = [sendInvoice];
375
+ export const agents = [];
376
+
377
+ // src/index.ts
378
+ import type { DeploymentSpec } from '@elevasis/sdk';
379
+ import * as orders from './orders/index.js';
380
+ import * as billing from './billing/index.js';
381
+
382
+ const org: DeploymentSpec = {
383
+ workflows: [
384
+ ...orders.workflows,
385
+ ...billing.workflows,
386
+ ],
387
+ agents: [
388
+ ...orders.agents,
389
+ ...billing.agents,
390
+ ],
391
+ };
392
+
393
+ export default org;
394
+ ```
395
+
396
+ The keys in `workflows` and `agents` are the resource identifiers used in CLI commands and the dashboard. Choose names that are descriptive and use kebab-case for consistency.
397
+
398
+ ---
399
+
400
+ ## Human-in-the-Loop UI Integration
401
+
402
+ The platform's HITL mechanism works in two parts: your workflow code creates an approval task, and a UI surfaces that task to a reviewer.
403
+
404
+ ### Creating approval tasks
405
+
406
+ Call `approval.create()` from any workflow step to pause execution and emit a task to the Command Queue:
407
+
408
+ ```typescript
409
+ import { approval } from '@elevasis/sdk/worker'
410
+
411
+ const task = await approval.create({
412
+ actions: [
413
+ { id: 'approve', label: 'Approve', type: 'primary' },
414
+ { id: 'reject', label: 'Reject', type: 'danger' },
415
+ ],
416
+ context: { dealId, proposalUrl },
417
+ description: 'Review proposal before sending',
418
+ })
419
+
420
+ if (task.actionId === 'approve') {
421
+ // continue with approved path
422
+ }
423
+ ```
424
+
425
+ The workflow step suspends at `approval.create()` and resumes only after a reviewer submits an action. See [Platform Adapters](../platform-tools/adapters-platform.mdx) for the full `approval.create()` reference.
426
+
427
+ ### Built-in Command Center handling
428
+
429
+ The Command Queue page in the Command Center surfaces all pending approval tasks automatically. Reviewers can filter by resource, approve or reject with an optional comment, and view decision history. No custom UI code is required -- deploy your workflow and the queue populates as tasks arrive.
430
+
431
+ ### Custom UI handling
432
+
433
+ `@elevasis/ui` exposes the following hooks for approval task operations, exported from `@elevasis/ui/hooks`:
434
+
435
+ - `useCommandQueue` -- fetches the list of pending tasks for the organization
436
+ - `useSubmitAction` -- POSTs an action decision to `/command-queue/{taskId}/action`
437
+ - `usePatchTask` -- updates task metadata
438
+ - `useDeleteTask` -- removes a task
439
+
440
+ Use these hooks to build a custom approval queue surface in your template UI. `useSubmitAction` accepts `taskId`, `actionId`, and optional `notes`, and optimistically marks the task as `processing` while the request is in flight.
441
+
442
+ For triggering executions from custom pages (the other side of the workflow interaction), see [UI Execution](../deployment/ui-execution.mdx).
443
+
444
+ ---
445
+
446
+ **Last Updated:** 2026-02-25