@elevasis/sdk 0.4.5 → 0.4.6

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.
@@ -0,0 +1,296 @@
1
+ ---
2
+ title: Execution API
3
+ description: REST endpoints for executing resources, querying execution history, and managing deployments via the Elevasis external API
4
+ ---
5
+
6
+ The Elevasis external API exposes REST endpoints under `/api/external/` for executing your deployed resources and inspecting results. All endpoints require your `ELEVASIS_API_KEY` sent as a Bearer token. Organization is resolved server-side from the API key -- you never pass an org identifier in requests.
7
+
8
+ **Authentication header:**
9
+
10
+ ```
11
+ Authorization: Bearer sk_...
12
+ ```
13
+
14
+ ---
15
+
16
+ ## API Base URL
17
+
18
+ | Environment | Base URL |
19
+ | ----------- | -------- |
20
+ | Production | `https://api.elevasis.io` |
21
+ | Development | `http://localhost:<port>` |
22
+
23
+ Override the base URL by setting `ELEVASIS_API_URL` in your environment or passing `--api-url` to any CLI command.
24
+
25
+ ---
26
+
27
+ ## Endpoints
28
+
29
+ | Method | Path | Purpose |
30
+ | ------ | ---- | ------- |
31
+ | `GET` | `/api/external/resources` | List all resources for your organization |
32
+ | `GET` | `/api/external/resources/:resourceId/definition` | Get resource metadata and schemas |
33
+ | `POST` | `/api/external/execute` | Execute a resource synchronously |
34
+ | `POST` | `/api/external/execute-async` | Execute a resource asynchronously |
35
+ | `POST` | `/api/external/executions/:resourceId/:executionId/cancel` | Cancel a running execution |
36
+ | `GET` | `/api/external/executions/:resourceId` | List execution history for a resource |
37
+ | `GET` | `/api/external/executions/:resourceId/:executionId` | Get full execution detail |
38
+ | `POST` | `/api/external/deploy` | Upload bundle and deploy resources |
39
+ | `GET` | `/api/external/deployments` | List all deployments |
40
+ | `GET` | `/api/external/deployments/:id` | Get a deployment by ID |
41
+
42
+ ---
43
+
44
+ ## Execution Endpoints
45
+
46
+ ### POST /api/external/execute
47
+
48
+ Execute a resource synchronously. The request waits for the resource to complete and returns the full result.
49
+
50
+ **Request body:**
51
+
52
+ ```json
53
+ {
54
+ "resourceId": "onboard-client",
55
+ "input": {
56
+ "clientName": "Jane",
57
+ "email": "jane@example.com"
58
+ }
59
+ }
60
+ ```
61
+
62
+ **Response:**
63
+
64
+ ```json
65
+ {
66
+ "executionId": "550e8400-e29b-41d4-a716-446655440000",
67
+ "success": true,
68
+ "data": {
69
+ "success": true,
70
+ "clientId": "client_1708521600000",
71
+ "welcomeEmailSent": true
72
+ }
73
+ }
74
+ ```
75
+
76
+ ### POST /api/external/execute-async
77
+
78
+ Execute a resource asynchronously. Returns immediately with an `executionId`. Poll `GET /executions/:resourceId/:executionId` to check status and retrieve output.
79
+
80
+ **Request body:**
81
+
82
+ ```json
83
+ {
84
+ "resourceId": "onboard-client",
85
+ "input": { "clientName": "Jane" }
86
+ }
87
+ ```
88
+
89
+ **Response:**
90
+
91
+ ```json
92
+ {
93
+ "executionId": "550e8400-e29b-41d4-a716-446655440000",
94
+ "status": "running"
95
+ }
96
+ ```
97
+
98
+ ### POST /api/external/executions/:resourceId/:executionId/cancel
99
+
100
+ Cancel a running execution. If the execution is found in memory, sends a cancellation signal immediately. Falls back to a database status update if no in-memory signal is found.
101
+
102
+ **Response:**
103
+
104
+ ```json
105
+ {
106
+ "success": true
107
+ }
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Resource Endpoints
113
+
114
+ ### GET /api/external/resources
115
+
116
+ List all resources registered to your organization. In production, only `status: 'prod'` resources are returned.
117
+
118
+ **Response:**
119
+
120
+ ```json
121
+ [
122
+ {
123
+ "resourceId": "onboard-client",
124
+ "resourceType": "workflow",
125
+ "name": "Onboard Client",
126
+ "status": "prod"
127
+ },
128
+ {
129
+ "resourceId": "email-assistant",
130
+ "resourceType": "agent",
131
+ "name": "Email Assistant",
132
+ "status": "prod"
133
+ }
134
+ ]
135
+ ```
136
+
137
+ ### GET /api/external/resources/:resourceId/definition
138
+
139
+ Get the full definition for a single resource: metadata, input schema, and output schema.
140
+
141
+ **Response:**
142
+
143
+ ```json
144
+ {
145
+ "resourceId": "onboard-client",
146
+ "resourceType": "workflow",
147
+ "name": "Onboard Client",
148
+ "description": "Creates a client record and sends a welcome email",
149
+ "status": "prod",
150
+ "inputSchema": {
151
+ "type": "object",
152
+ "properties": {
153
+ "clientName": { "type": "string" },
154
+ "email": { "type": "string", "format": "email" }
155
+ },
156
+ "required": ["clientName", "email"]
157
+ },
158
+ "outputSchema": {
159
+ "type": "object",
160
+ "properties": {
161
+ "success": { "type": "boolean" },
162
+ "clientId": { "type": "string" }
163
+ }
164
+ }
165
+ }
166
+ ```
167
+
168
+ Returns `404` if the resource is not found.
169
+
170
+ ---
171
+
172
+ ## Execution History Endpoints
173
+
174
+ ### GET /api/external/executions/:resourceId
175
+
176
+ List execution history for a resource.
177
+
178
+ **Query parameters:**
179
+
180
+ | Parameter | Description |
181
+ | --------- | ----------- |
182
+ | `limit` | Maximum number of results (default: 20) |
183
+ | `status` | Filter by status: `running`, `completed`, `failed`, `cancelled` |
184
+
185
+ **Response:**
186
+
187
+ ```json
188
+ [
189
+ {
190
+ "executionId": "550e8400-e29b-41d4-a716-446655440000",
191
+ "resourceId": "onboard-client",
192
+ "status": "completed",
193
+ "createdAt": "2026-02-25T14:32:01Z",
194
+ "durationMs": 1234
195
+ }
196
+ ]
197
+ ```
198
+
199
+ ### GET /api/external/executions/:resourceId/:executionId
200
+
201
+ Get the full detail for a single execution including input, output, logs, and error.
202
+
203
+ **Response:**
204
+
205
+ ```json
206
+ {
207
+ "executionId": "550e8400-e29b-41d4-a716-446655440000",
208
+ "resourceId": "onboard-client",
209
+ "status": "completed",
210
+ "createdAt": "2026-02-25T14:32:01Z",
211
+ "durationMs": 1234,
212
+ "input": {
213
+ "clientName": "Jane",
214
+ "email": "jane@example.com"
215
+ },
216
+ "output": {
217
+ "success": true,
218
+ "clientId": "client_1708521600000",
219
+ "welcomeEmailSent": true
220
+ },
221
+ "logs": [
222
+ { "timestamp": "2026-02-25T14:32:01.123Z", "message": "Starting onboard-client workflow" },
223
+ { "timestamp": "2026-02-25T14:32:01.456Z", "message": "Created client record" }
224
+ ],
225
+ "error": null
226
+ }
227
+ ```
228
+
229
+ ---
230
+
231
+ ## Deployment Endpoints
232
+
233
+ ### POST /api/external/deploy
234
+
235
+ Upload a resource bundle and deploy it. Accepts a multipart request with the compiled bundle and resource metadata.
236
+
237
+ **Response:**
238
+
239
+ ```json
240
+ {
241
+ "deployId": "deploy_abc123",
242
+ "status": "active",
243
+ "resources": 4
244
+ }
245
+ ```
246
+
247
+ Use `elevasis deploy` from the CLI rather than calling this endpoint directly -- the CLI handles bundling, metadata generation, and status streaming automatically.
248
+
249
+ ### GET /api/external/deployments
250
+
251
+ List all deployments for your organization.
252
+
253
+ **Response:**
254
+
255
+ ```json
256
+ [
257
+ {
258
+ "id": "deploy_abc123",
259
+ "status": "active",
260
+ "createdAt": "2026-02-25T14:00:00Z",
261
+ "resources": 4
262
+ },
263
+ {
264
+ "id": "deploy_abc122",
265
+ "status": "stopped",
266
+ "createdAt": "2026-02-24T09:30:00Z",
267
+ "resources": 3
268
+ }
269
+ ]
270
+ ```
271
+
272
+ ### GET /api/external/deployments/:id
273
+
274
+ Get a single deployment by ID.
275
+
276
+ **Response shape:** Same as a single item from `GET /deployments`.
277
+
278
+ ---
279
+
280
+ ## CLI Execution Commands
281
+
282
+ The SDK CLI wraps all execution endpoints. Use these commands instead of calling the API directly during development:
283
+
284
+ | Command | API call | Purpose |
285
+ | ------- | -------- | ------- |
286
+ | `elevasis resources` | `GET /api/external/resources` | List all resources |
287
+ | `elevasis describe <resource>` | `GET /api/external/resources/:id/definition` | Show resource definition |
288
+ | `elevasis exec <resource> --input '...'` | `POST /api/external/execute` | Execute synchronously |
289
+ | `elevasis exec <resource> --input '...' --async` | `POST /api/external/execute-async` | Execute asynchronously |
290
+ | `elevasis executions <resource>` | `GET /api/external/executions/:id` | List execution history |
291
+ | `elevasis execution <resource> <id>` | `GET /api/external/executions/:id/:execId` | Get execution detail |
292
+ | `elevasis deployments` | `GET /api/external/deployments` | List deployments |
293
+
294
+ ---
295
+
296
+ **Last Updated:** 2026-02-25
@@ -0,0 +1,152 @@
1
+ ---
2
+ title: Deploying Resources
3
+ description: How to deploy your Elevasis SDK resources to the platform using elevasis deploy, including configuration, validation, and environment setup
4
+ ---
5
+
6
+ Deploying your resources makes them live on the Elevasis platform and immediately available for execution. The deploy process validates your resource definitions, bundles your code into a single self-contained file, and uploads it to the platform -- no server-side dependency installation required.
7
+
8
+ ---
9
+
10
+ ## How Deployment Works
11
+
12
+ When you run `elevasis deploy`, the CLI performs these steps in order:
13
+
14
+ 1. **Authenticate** -- calls the API with your `ELEVASIS_API_KEY` to verify credentials and resolve your organization name
15
+ 2. **Validate** -- runs your `src/index.ts` through `ResourceRegistry`, catching the same errors as the platform
16
+ 3. **Bundle** -- uses esbuild to produce a single self-contained `dist/bundle.js` file (~50-200 KB) containing your code and all dependencies
17
+ 4. **Upload** -- sends the bundle and resource metadata to the platform via `POST /api/external/deploy`
18
+ 5. **Go live** -- the platform registers your resources; they are immediately available for execution
19
+
20
+ There is no local dev server and no separate staging environment. Deployed resources run directly on the platform. Local testing uses `tsc --noEmit` and Vitest with direct handler calls.
21
+
22
+ ---
23
+
24
+ ## Running a Deploy
25
+
26
+ ```bash
27
+ elevasis deploy
28
+ ```
29
+
30
+ **Successful deploy output:**
31
+
32
+ ```
33
+ Authenticating... done (acme-corp)
34
+ Validating... done (4 resources, 0 errors)
35
+ Bundling... done (142 KB)
36
+ Uploading... done
37
+
38
+ Deployed! 4 resources live.
39
+ Deployment: deploy_abc123
40
+ ```
41
+
42
+ Each deploy creates a new deployment record. The previous active deployment is automatically stopped. You can view all deployments with `elevasis deployments`.
43
+
44
+ ---
45
+
46
+ ## Validation
47
+
48
+ The CLI validates your resources before bundling. Validation uses the same `ResourceRegistry` as the platform, so errors caught locally are the same errors that would be caught at deploy time.
49
+
50
+ **Validation checks:**
51
+
52
+ - Duplicate `resourceId` within your organization
53
+ - Invalid model configuration (temperature and token bounds out of range)
54
+ - `ExecutionInterface` form fields not matching `inputSchema`
55
+ - Broken workflow step chains (`next` referencing a step that does not exist)
56
+ - Relationship declarations referencing resources that do not exist
57
+
58
+ **Validation failure output:**
59
+
60
+ ```
61
+ Authenticating... done (acme-corp)
62
+ Validating...
63
+ ERROR Duplicate resource ID 'onboard-client' in organization 'Acme Corp'
64
+ ERROR Workflow step 'send-email' references non-existent next step 'notify'
65
+
66
+ 2 errors. Deploy aborted.
67
+ ```
68
+
69
+ Run `elevasis check` at any time to validate without deploying.
70
+
71
+ ---
72
+
73
+ ## Configuration
74
+
75
+ The CLI reads `elevasis.config.ts` from your project root. All fields are optional -- the organization name is resolved from your API key, not from config.
76
+
77
+ ```typescript
78
+ // elevasis.config.ts
79
+ import type { ElevasConfig } from '@elevasis/sdk'
80
+
81
+ export default {} satisfies ElevasConfig
82
+ ```
83
+
84
+ The `ElevasConfig` type is exported from `@elevasis/sdk`. You can leave the config empty or extend it as options are added in future SDK versions.
85
+
86
+ ---
87
+
88
+ ## Environment Variables
89
+
90
+ | Variable | Required | Description |
91
+ | -------- | -------- | ----------- |
92
+ | `ELEVASIS_API_KEY` | Yes | Your `sk_...` API key. Used for authentication and organization resolution. |
93
+ | `ELEVASIS_API_URL` | No | Override the API base URL. Useful for pointing at a staging environment. |
94
+
95
+ The CLI also accepts a `--api-url` flag on every command, which takes priority over `ELEVASIS_API_URL`.
96
+
97
+ **API URL resolution order:**
98
+
99
+ 1. `--api-url` flag (highest priority)
100
+ 2. `ELEVASIS_API_URL` environment variable
101
+ 3. `NODE_ENV`-based default (production: `https://api.elevasis.io`, development: localhost)
102
+
103
+ **Setting `ELEVASIS_API_KEY` via `.env` file:**
104
+
105
+ ```
106
+ ELEVASIS_API_KEY=sk_***
107
+ ```
108
+
109
+ Place `.env` in your project root. The CLI reads it automatically. Never commit this file.
110
+
111
+ ---
112
+
113
+ ## Deployment Lifecycle
114
+
115
+ Each call to `elevasis deploy` creates a new deployment. The platform tracks all deployments for your organization.
116
+
117
+ | Status | Meaning |
118
+ | ------ | ------- |
119
+ | `deploying` | Bundle is being processed and resources are being registered |
120
+ | `active` | Resources are live and available for execution |
121
+ | `stopped` | Superseded by a newer deployment |
122
+ | `failed` | Deploy did not complete (validation or bundle error) |
123
+
124
+ Only one deployment can be `active` at a time. Deploying again automatically moves the previous active deployment to `stopped`.
125
+
126
+ **View deployment history:**
127
+
128
+ ```bash
129
+ elevasis deployments
130
+ ```
131
+
132
+ ```
133
+ deploy_abc123 active 2026-02-25 14:00:00 4 resources
134
+ deploy_abc122 stopped 2026-02-24 09:30:00 3 resources
135
+ deploy_abc121 stopped 2026-02-23 11:15:00 3 resources
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Bundle Details
141
+
142
+ The deploy bundle is a single CJS file produced by esbuild. It includes:
143
+
144
+ - Your resource definitions from `src/index.ts`
145
+ - The `@elevasis/sdk/worker` runtime that handles execution messages from the platform
146
+ - All your npm dependencies (fully self-contained, no `node_modules` needed on the server)
147
+
148
+ The bundle is stored on the platform for durability and restart recovery. If the platform API restarts, it re-downloads your bundle and re-registers your resources automatically -- no action required on your part.
149
+
150
+ ---
151
+
152
+ **Last Updated:** 2026-02-25
@@ -0,0 +1,91 @@
1
+ ---
2
+ title: Resource Documentation
3
+ description: Write and deploy MDX documentation alongside your Elevasis resources
4
+ ---
5
+
6
+ `elevasis deploy` ships your code and your documentation atomically -- one command, no version drift. Documentation files live in a `docs/` directory at your project root and render in the Elevasis platform UI for operators using your resources.
7
+
8
+ ## Directory Structure
9
+
10
+ Create `.mdx` files inside a `docs/` directory at your project root. `elevasis init` scaffolds a starter structure:
11
+
12
+ ```
13
+ my-project/
14
+ ├── docs/
15
+ │ └── index.mdx # Resource overview (scaffolded by init)
16
+ ├── src/
17
+ │ └── index.ts # Resource definitions
18
+ ├── elevasis.config.ts
19
+ └── ...
20
+ ```
21
+
22
+ A missing `docs/` directory is silently ignored -- documentation is optional. If the directory exists, its contents are included in the deploy payload alongside resource schemas.
23
+
24
+ ## Frontmatter Schema
25
+
26
+ Every documentation file supports a frontmatter block at the top:
27
+
28
+ ```yaml
29
+ ---
30
+ title: string # Page title (required)
31
+ description: string # Short description (optional)
32
+ order: number # Sort order within directory (optional, default: 0)
33
+ ---
34
+ ```
35
+
36
+ ## Naming Conventions
37
+
38
+ - `docs/index.mdx` is the root documentation page and is always rendered first
39
+ - Nested directories create sections: `docs/guides/getting-started.mdx`
40
+ - File names become URL slugs: `setup-guide.mdx` renders at `/docs/setup-guide`
41
+ - Arbitrary nesting is supported -- there is no depth limit
42
+
43
+ ## Size Limits
44
+
45
+ - 100KB per file
46
+ - 1MB total across all files in a deployment
47
+
48
+ These limits are enforced by the CLI before the deploy request is sent. Validation errors include the file name and size.
49
+
50
+ ## Starter Template
51
+
52
+ `elevasis init` writes this starter file to `docs/index.mdx`:
53
+
54
+ ```mdx
55
+ ---
56
+ title: Overview
57
+ description: Documentation for this Elevasis project
58
+ ---
59
+
60
+ # Overview
61
+
62
+ Welcome to the documentation for this project.
63
+
64
+ ## Resources
65
+
66
+ Describe your workflows and agents here. This documentation is deployed alongside your
67
+ code and rendered in the Elevasis platform UI.
68
+
69
+ ## Getting Started
70
+
71
+ \`\`\`bash
72
+ elevasis check # Validate resources
73
+ elevasis deploy # Deploy to platform
74
+ elevasis exec <resourceId> --input '{"key": "value"}'
75
+ \`\`\`
76
+ ```
77
+
78
+ ## Deploy Behavior
79
+
80
+ When you run `elevasis deploy`:
81
+
82
+ 1. The CLI scans `docs/` recursively for `.mdx` files
83
+ 2. Each file's frontmatter (title, description, order) is parsed and stripped from the content
84
+ 3. Total size is validated against the 1MB limit and individual files against 100KB
85
+ 4. The documentation array is included in the deploy metadata alongside your resource schemas
86
+
87
+ Documentation and code ship in the same transaction. There is no separate upload step and no way for documentation to drift out of sync with the deployed version.
88
+
89
+ ---
90
+
91
+ **Last Updated:** 2026-02-25
@@ -0,0 +1,124 @@
1
+ ---
2
+ title: Getting Started
3
+ description: Install the Elevasis SDK, scaffold a project, and run your first deployment
4
+ ---
5
+
6
+ This guide takes you from a fresh install to a running deployment in four steps: install, scaffold, deploy, and execute.
7
+
8
+ ## Installation
9
+
10
+ Install the SDK and its peer dependency:
11
+
12
+ ```bash
13
+ npm install @elevasis/sdk zod
14
+ # or
15
+ pnpm add @elevasis/sdk zod
16
+ ```
17
+
18
+ The `.npmrc` file scaffolded by `elevasis init` sets `auto-install-peers = true`, so peer dependencies are handled automatically on subsequent installs.
19
+
20
+ ---
21
+
22
+ ## Scaffold a Project
23
+
24
+ Run `elevasis init` to create a new project directory with all required files:
25
+
26
+ ```bash
27
+ elevasis init my-project
28
+ cd my-project
29
+ ```
30
+
31
+ The command scaffolds 18 files covering configuration, source, documentation, and Claude Code integration:
32
+
33
+ ```
34
+ my-project/
35
+ ├── CLAUDE.md # Project instructions for Claude Code
36
+ ├── .claude/
37
+ │ ├── settings.json # autoCompact: false
38
+ │ ├── profile.json # Created on first session (gitignored)
39
+ │ └── commands/
40
+ │ ├── docs.md # Documentation assistant
41
+ │ ├── resource.md # Resource scaffolding
42
+ │ ├── deploy.md # Deployment assistant
43
+ │ ├── inspect.md # Deployment health + execution debugging
44
+ │ └── env.md # Platform env var management
45
+ ├── src/
46
+ │ └── index.ts # Echo workflow starter
47
+ ├── docs/
48
+ │ └── index.mdx # Starter documentation page
49
+ ├── elevasis.config.ts # Config with commented-out options
50
+ ├── package.json # check-types + deploy scripts
51
+ ├── tsconfig.json # TypeScript config (app-focused)
52
+ ├── pnpm-workspace.yaml # Standalone project workspace
53
+ ├── .env # API key only
54
+ ├── .env.example # Git-safe template
55
+ ├── .npmrc # auto-install-peers
56
+ ├── .gitignore # Excludes worker temp file, claude files
57
+ └── README.md # Setup and CLI reference
58
+ ```
59
+
60
+ ### Set Up Your API Key
61
+
62
+ Open `.env` and set your API key:
63
+
64
+ ```
65
+ ELEVASIS_API_KEY=sk_your_key_here
66
+ ```
67
+
68
+ The `.env.example` file provides the same template and is safe to commit. The actual `.env` is gitignored.
69
+
70
+ **Note:** Do not add `NODE_ENV` to your `.env`. The SDK treats `undefined` as production by default, which means your project connects to the hosted Elevasis API. Adding `NODE_ENV=development` is the most common setup mistake.
71
+
72
+ ---
73
+
74
+ ## First Deployment
75
+
76
+ Validate your resources and deploy:
77
+
78
+ ```bash
79
+ elevasis check # Validate resource definitions
80
+ elevasis deploy # Bundle and deploy to the platform
81
+ ```
82
+
83
+ `elevasis check` runs validation without deploying. Fix any errors it reports before running `elevasis deploy`.
84
+
85
+ `elevasis deploy` bundles your `src/` code and `docs/` documentation into a single deployment transaction. Both ship atomically -- there is no separate upload step for documentation.
86
+
87
+ After a successful deploy, confirm the resources are live:
88
+
89
+ ```bash
90
+ elevasis resources # List deployed resources
91
+ elevasis deployments # Show deployment history
92
+ ```
93
+
94
+ ---
95
+
96
+ ## First Execution
97
+
98
+ Execute the scaffolded echo workflow to verify end-to-end connectivity:
99
+
100
+ ```bash
101
+ elevasis exec echo-workflow --input '{"message": "hello"}'
102
+ ```
103
+
104
+ View the execution result:
105
+
106
+ ```bash
107
+ elevasis executions echo-workflow # Execution history
108
+ elevasis execution echo-workflow \<execution-id\> # Full detail for one execution
109
+ ```
110
+
111
+ Replace `<execution-id>` with the ID returned from the executions list.
112
+
113
+ ---
114
+
115
+ ## Next Steps
116
+
117
+ - [Project Structure](project-structure.mdx) -- Understand each scaffolded file
118
+ - [Resources](../resources/index.mdx) -- Define workflows and agents
119
+ - [CLI Reference](../cli/index.mdx) -- Full command reference with flags
120
+ - [Deployment](../deployment/index.mdx) -- Deployment lifecycle and environment variables
121
+
122
+ ---
123
+
124
+ **Last Updated:** 2026-02-25