@elevasis/sdk 0.4.6 → 0.4.8
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 +815 -452
- package/dist/index.d.ts +79 -14
- package/dist/index.js +17 -12
- package/dist/templates.js +747 -0
- package/dist/types/templates.d.ts +1 -0
- package/dist/types/worker/index.d.ts +6 -0
- package/dist/types/worker/platform.d.ts +32 -0
- package/dist/worker/index.js +4728 -11
- package/package.json +16 -10
- package/reference/_index.md +48 -6
- package/reference/_navigation.md +104 -0
- package/reference/cli/index.mdx +2 -1
- package/reference/concepts/index.mdx +203 -0
- package/reference/deployment/api.mdx +1 -0
- package/reference/deployment/index.mdx +1 -0
- package/reference/developer/interaction-guidance.mdx +213 -0
- package/reference/framework/agent.mdx +175 -0
- package/reference/{documentation/index.mdx → framework/documentation.mdx} +1 -0
- package/reference/framework/index.mdx +95 -0
- package/reference/framework/memory.mdx +337 -0
- package/reference/framework/project-structure.mdx +294 -0
- package/reference/getting-started/index.mdx +39 -15
- package/reference/index.mdx +10 -2
- package/reference/platform-tools/examples.mdx +1 -0
- package/reference/platform-tools/index.mdx +43 -2
- package/reference/resources/index.mdx +1 -0
- package/reference/resources/patterns.mdx +2 -1
- package/reference/resources/types.mdx +1 -0
- package/reference/roadmap/index.mdx +1 -0
- package/reference/runtime/index.mdx +1 -0
- package/reference/runtime/limits.mdx +1 -0
- package/reference/security/credentials.mdx +141 -0
- package/reference/templates/data-enrichment.mdx +162 -0
- package/reference/templates/email-sender.mdx +135 -0
- package/reference/templates/lead-scorer.mdx +175 -0
- package/reference/templates/pdf-generator.mdx +151 -0
- package/reference/templates/recurring-job.mdx +189 -0
- package/reference/templates/text-classifier.mdx +147 -0
- package/reference/templates/web-scraper.mdx +135 -0
- package/reference/troubleshooting/common-errors.mdx +210 -0
- package/reference/getting-started/project-structure.mdx +0 -148
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Getting Started
|
|
3
3
|
description: Install the Elevasis SDK, scaffold a project, and run your first deployment
|
|
4
|
+
loadWhen: "Setting up a new project or onboarding"
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
This guide takes you from a fresh install to a running deployment in four steps: install, scaffold, deploy, and execute.
|
|
@@ -28,33 +29,49 @@ elevasis init my-project
|
|
|
28
29
|
cd my-project
|
|
29
30
|
```
|
|
30
31
|
|
|
31
|
-
The command scaffolds
|
|
32
|
+
The command scaffolds 23 files covering configuration, source, documentation, and Claude Code integration:
|
|
32
33
|
|
|
33
34
|
```
|
|
34
35
|
my-project/
|
|
35
36
|
├── CLAUDE.md # Project instructions for Claude Code
|
|
36
37
|
├── .claude/
|
|
37
38
|
│ ├── settings.json # autoCompact: false
|
|
38
|
-
│ ├── profile.json # Created on first session (gitignored)
|
|
39
39
|
│ └── commands/
|
|
40
|
-
│ ├── docs.md # Documentation
|
|
40
|
+
│ ├── docs.md # Documentation lifecycle
|
|
41
41
|
│ ├── resource.md # Resource scaffolding
|
|
42
|
-
│ ├──
|
|
43
|
-
│ ├──
|
|
44
|
-
│
|
|
42
|
+
│ ├── meta.md # Project lifecycle (init, deploy, health, develop)
|
|
43
|
+
│ ├── help.md # Command tree and navigation
|
|
44
|
+
│ ├── database.md # Database setup and management
|
|
45
|
+
│ ├── agent.md # Agent development
|
|
46
|
+
│ ├── templates.md # Workflow templates
|
|
47
|
+
│ ├── tutorial.md # Progressive learning
|
|
48
|
+
│ └── profile.md # View and update user profile
|
|
45
49
|
├── src/
|
|
46
|
-
│
|
|
50
|
+
│ ├── index.ts # Registry entry point
|
|
51
|
+
│ └── workflows/
|
|
52
|
+
│ └── echo.ts # Starter workflow
|
|
47
53
|
├── docs/
|
|
48
|
-
│
|
|
49
|
-
|
|
54
|
+
│ ├── index.mdx # Starter documentation page
|
|
55
|
+
│ └── in-progress/
|
|
56
|
+
│ └── .gitkeep # Work-in-progress docs directory
|
|
57
|
+
├── elevasis.config.ts # Config with templateVersion and options
|
|
50
58
|
├── package.json # check-types + deploy scripts
|
|
51
59
|
├── tsconfig.json # TypeScript config (app-focused)
|
|
52
60
|
├── pnpm-workspace.yaml # Standalone project workspace
|
|
53
61
|
├── .env # API key only
|
|
54
62
|
├── .env.example # Git-safe template
|
|
55
63
|
├── .npmrc # auto-install-peers
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
└── .gitignore # Excludes worker temp file, claude files
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The scaffolded `elevasis.config.ts` includes a `templateVersion` field that tracks which template generation your project uses. Leave it as-is -- it is managed automatically by `elevasis update`:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import type { ElevasConfig } from '@elevasis/sdk'
|
|
71
|
+
|
|
72
|
+
export default {
|
|
73
|
+
templateVersion: 4,
|
|
74
|
+
} satisfies ElevasConfig
|
|
58
75
|
```
|
|
59
76
|
|
|
60
77
|
### Set Up Your API Key
|
|
@@ -69,6 +86,10 @@ The `.env.example` file provides the same template and is safe to commit. The ac
|
|
|
69
86
|
|
|
70
87
|
**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
88
|
|
|
89
|
+
### Guided Setup with Claude Code
|
|
90
|
+
|
|
91
|
+
After scaffolding, open the project in Claude Code and run `/meta init`. This command installs dependencies, walks you through `.env` setup, creates your developer profile in `.claude/memory/`, and optionally runs your first deploy -- all in one guided flow.
|
|
92
|
+
|
|
72
93
|
---
|
|
73
94
|
|
|
74
95
|
## First Deployment
|
|
@@ -98,14 +119,14 @@ elevasis deployments # Show deployment history
|
|
|
98
119
|
Execute the scaffolded echo workflow to verify end-to-end connectivity:
|
|
99
120
|
|
|
100
121
|
```bash
|
|
101
|
-
elevasis exec echo
|
|
122
|
+
elevasis exec echo --input '{"message": "hello"}'
|
|
102
123
|
```
|
|
103
124
|
|
|
104
125
|
View the execution result:
|
|
105
126
|
|
|
106
127
|
```bash
|
|
107
|
-
elevasis executions echo
|
|
108
|
-
elevasis execution echo
|
|
128
|
+
elevasis executions echo # Execution history
|
|
129
|
+
elevasis execution echo \<execution-id\> # Full detail for one execution
|
|
109
130
|
```
|
|
110
131
|
|
|
111
132
|
Replace `<execution-id>` with the ID returned from the executions list.
|
|
@@ -114,11 +135,14 @@ Replace `<execution-id>` with the ID returned from the executions list.
|
|
|
114
135
|
|
|
115
136
|
## Next Steps
|
|
116
137
|
|
|
117
|
-
-
|
|
138
|
+
- **Run `/meta init` in Claude Code** -- Guided setup that installs deps, configures `.env`, and creates your developer profile in `.claude/memory/`
|
|
139
|
+
- [Development Framework](../framework/index.mdx) -- How Claude Code helps you build
|
|
118
140
|
- [Resources](../resources/index.mdx) -- Define workflows and agents
|
|
119
141
|
- [CLI Reference](../cli/index.mdx) -- Full command reference with flags
|
|
120
142
|
- [Deployment](../deployment/index.mdx) -- Deployment lifecycle and environment variables
|
|
121
143
|
|
|
144
|
+
When a new SDK version is released, run `elevasis update` to bring your project's managed files (CLAUDE.md, slash commands, `.gitignore`) up to date. The command adds missing files and flags any files that differ from the new template for agent-assisted review.
|
|
145
|
+
|
|
122
146
|
---
|
|
123
147
|
|
|
124
148
|
**Last Updated:** 2026-02-25
|
package/reference/index.mdx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Elevasis SDK
|
|
3
3
|
description: Build and deploy workflows, agents, and resources with the Elevasis SDK
|
|
4
|
+
loadWhen: "First session or new to the SDK"
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
`@elevasis/sdk` lets you build workflows, agents, and resources in TypeScript and deploy them to the Elevasis platform with a single command. The developer experience is Vercel-style: write TypeScript, validate locally, deploy -- the platform handles execution, tool access, and observability. You never manage infrastructure. Zod 4.1 is the only peer dependency.
|
|
@@ -69,7 +70,7 @@ const result = await platform.call({
|
|
|
69
70
|
});
|
|
70
71
|
```
|
|
71
72
|
|
|
72
|
-
The platform exposes 70+ tools across
|
|
73
|
+
The platform exposes 70+ tools across 13 integration adapters -- Gmail, Stripe, Google Sheets, Notion, and more. Credentials are managed server-side; API keys never cross the execution boundary. LLM calls are also available via `platform.call({ tool: 'llm', ... })` with API keys resolved from platform environment variables.
|
|
73
74
|
|
|
74
75
|
See [Platform Tools](platform-tools/index.mdx) for the full catalog.
|
|
75
76
|
|
|
@@ -88,16 +89,23 @@ See [Platform Tools](platform-tools/index.mdx) for the full catalog.
|
|
|
88
89
|
|
|
89
90
|
- [Resources](resources/index.mdx) - Workflow and agent definition patterns, Zod schemas, step types, and routing
|
|
90
91
|
- [Platform Tools](platform-tools/index.mdx) - Full catalog of 70+ tools, integration adapters, and credential management
|
|
92
|
+
- [Security](security/credentials.mdx) - Three-layer credential model, HTTP tool patterns, and credential management
|
|
91
93
|
|
|
92
94
|
### Reference
|
|
93
95
|
|
|
96
|
+
- [Concepts](concepts/index.mdx) - Plain-English concept explanations, glossary, Zod guide, execution model, and common errors
|
|
97
|
+
- [Templates](templates/index.mdx) - 7 workflow templates: web-scraper, data-enrichment, email-sender, lead-scorer, and more
|
|
94
98
|
- [CLI Reference](cli/index.mdx) - All CLI commands: check, deploy, exec, resources, executions, env, and more
|
|
95
99
|
- [Deployment](deployment/index.mdx) - Deploy pipeline, versioning, bundle upload, and registry registration
|
|
96
100
|
- [Runtime](runtime/index.mdx) - Worker execution model, concurrency, timeouts, cancellation, and resource limits
|
|
97
101
|
|
|
102
|
+
### Framework
|
|
103
|
+
|
|
104
|
+
- [Development Framework](framework/index.mdx) - How Claude Code helps you build: project structure, agent integration, memory, and documentation
|
|
105
|
+
|
|
98
106
|
### Developer Tools
|
|
99
107
|
|
|
100
|
-
- [Documentation](documentation
|
|
108
|
+
- [Documentation](framework/documentation.mdx) - Writing and deploying MDX documentation alongside your resources
|
|
101
109
|
- [Roadmap](roadmap/index.mdx) - Planned features including agent execution, streaming logs, and SDK testing utilities
|
|
102
110
|
|
|
103
111
|
---
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Integration Examples
|
|
3
3
|
description: Common platform.call() patterns for email, CRM, PDF, LLM inference, resource triggering, and storage
|
|
4
|
+
loadWhen: "Implementing a platform tool call in a workflow step"
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
Common `platform.call()` patterns ready to use in your SDK workflows. Each example shows the complete invocation including tool name, method, params, and credential (where required).
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Platform Tools
|
|
3
|
-
description: Access 70+ integration adapters and platform services from your SDK workflows via platform.call()
|
|
3
|
+
description: Access 70+ tools across integration adapters and platform services from your SDK workflows via platform.call()
|
|
4
|
+
loadWhen: "Connecting to external services"
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
`platform.call()` gives your SDK workflows access to the same 70+ tools that internal Elevasis agents use -- Gmail, Stripe, Google Sheets, PDF generation, human-in-the-loop approvals, storage, scheduling, and more. Credentials are managed server-side and never appear in your code. You pass a tool name, method, and parameters; Elevasis handles credential lookup, rate limiting, and retry transparently.
|
|
@@ -22,7 +23,7 @@ const result = await platform.call({
|
|
|
22
23
|
|
|
23
24
|
## Integration Adapters
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
Thirteen integration adapters give you access to 70+ tool methods covering third-party APIs. Pass the `credential` field with the name of the stored credential for that service.
|
|
26
27
|
|
|
27
28
|
| Adapter | Tools | Credential Shape |
|
|
28
29
|
| --- | --- | --- |
|
|
@@ -38,6 +39,7 @@ Twelve integration adapters give you access to roughly 50 tool factories coverin
|
|
|
38
39
|
| Dropbox | 2 (upload/folder) | `{ accessToken }` |
|
|
39
40
|
| Apify | 1 (run actor) | `{ token }` |
|
|
40
41
|
| Mailso | 1 (verify email) | `{ apiKey }` |
|
|
42
|
+
| Supabase | 7 (insert/select/update/delete/upsert/rpc/count) | `{ url, serviceRoleKey }` |
|
|
41
43
|
|
|
42
44
|
Credentials are stored in the Elevasis credentials table and injected server-side. The credential name you pass in `credential` must match the name you set when storing the credential.
|
|
43
45
|
|
|
@@ -132,6 +134,45 @@ elevasis env remove KEY
|
|
|
132
134
|
|
|
133
135
|
Environment variables set this way are injected into your worker process at startup and are available via `process.env`.
|
|
134
136
|
|
|
137
|
+
## Database Access
|
|
138
|
+
|
|
139
|
+
Supabase is a first-class integration adapter that gives your workflows persistent storage using the same `platform.call()` interface as every other tool. Pass the `credential` field with the name of your stored Supabase credential.
|
|
140
|
+
|
|
141
|
+
**Methods:** `insert`, `select`, `update`, `delete`, `upsert`, `rpc`, `count`
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
// Select rows with filters
|
|
145
|
+
const qualified = await platform.call({
|
|
146
|
+
tool: 'supabase',
|
|
147
|
+
credential: 'my-database',
|
|
148
|
+
method: 'select',
|
|
149
|
+
params: {
|
|
150
|
+
table: 'leads',
|
|
151
|
+
filter: { status: 'eq.qualified', score: 'gte.80' },
|
|
152
|
+
order: { column: 'score', ascending: false },
|
|
153
|
+
limit: 50,
|
|
154
|
+
},
|
|
155
|
+
})
|
|
156
|
+
// Returns: [{ id: '...', name: 'Jane Doe', score: 92, ... }, ...]
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**Filter syntax** uses PostgREST string format (`operator.value`):
|
|
160
|
+
|
|
161
|
+
| Filter | Example | Meaning |
|
|
162
|
+
| --- | --- | --- |
|
|
163
|
+
| `eq` | `{ status: 'eq.qualified' }` | Equals |
|
|
164
|
+
| `neq` | `{ status: 'neq.lost' }` | Not equals |
|
|
165
|
+
| `gt`, `gte`, `lt`, `lte` | `{ score: 'gte.80' }` | Comparisons |
|
|
166
|
+
| `like`, `ilike` | `{ name: 'ilike.%jane%' }` | Pattern match |
|
|
167
|
+
| `in` | `{ status: 'in.(new,contacted)' }` | In set |
|
|
168
|
+
| `is` | `{ deleted_at: 'is.null' }` | Null check |
|
|
169
|
+
|
|
170
|
+
**Credential setup:** Create a credential with provider `supabase` in the command center. The config fields are `url` (your Supabase project URL) and `serviceRoleKey` (the service role key from Settings > API). Workflows always use the service role key -- server-side execution, no RLS.
|
|
171
|
+
|
|
172
|
+
**`/database init`:** A guided setup command that stores your Supabase credential, generates `data/schema.ts`, and creates `docs/database.mdx`.
|
|
173
|
+
|
|
174
|
+
**`data/schema.ts`:** An agent-readable Zod schema that documents your table structure. It is NOT deployed and NOT executed -- the agent reads it to understand your data model when writing workflow steps or generating queries.
|
|
175
|
+
|
|
135
176
|
## Documentation
|
|
136
177
|
|
|
137
178
|
- [Integration Examples](examples.mdx) - Common `platform.call()` patterns with working code for email, CRM, PDF, LLM, and more
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Writing Resources
|
|
3
3
|
description: Guide to creating workflows and agents using WorkflowDefinition, AgentDefinition, and OrganizationResources with the Elevasis SDK
|
|
4
|
+
loadWhen: "Building or modifying a workflow"
|
|
4
5
|
---
|
|
5
6
|
|
|
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.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Common Patterns
|
|
3
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"
|
|
4
5
|
---
|
|
5
6
|
|
|
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.
|
|
@@ -117,7 +118,7 @@ const sendEmailStep: WorkflowStep = {
|
|
|
117
118
|
subject: input.subject,
|
|
118
119
|
body: input.body,
|
|
119
120
|
},
|
|
120
|
-
credential: '
|
|
121
|
+
credential: 'sendgrid', // name of the stored credential
|
|
121
122
|
});
|
|
122
123
|
|
|
123
124
|
context.logger.info('Email sent', { messageId: result.messageId });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: SDK Types
|
|
3
3
|
description: Complete type reference for @elevasis/sdk -- package exports, re-exported platform types, ElevasConfig interface, StepHandler context, and runtime values
|
|
4
|
+
loadWhen: "Looking up type signatures or SDK exports"
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
`@elevasis/sdk` is published to the public npm registry. It bundles all platform types from `@repo/core` into a single self-contained type declaration file with zero internal monorepo references. External developers install the package and get full TypeScript support without any monorepo tooling.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Roadmap
|
|
3
3
|
description: Planned SDK features -- error taxonomy, retry semantics, circuit breaker, metrics, alerting, and resource lifecycle extensions
|
|
4
|
+
loadWhen: "Asking about future features or planned capabilities"
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
**Status:** Planned -- none of these features are implemented yet.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Execution Runtime
|
|
3
3
|
description: How your code runs on the Elevasis platform -- execution lifecycle, concurrency, timeouts, cancellation, error handling, and observability
|
|
4
|
+
loadWhen: "Debugging execution behavior or understanding the runtime model"
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
This page covers everything that happens after you deploy -- how resources execute as managed processes, how failures surface to you, and what observability data you can access. For resource limits and quotas, see [Resource Limits & Quotas](limits.mdx).
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Resource Limits & Quotas
|
|
3
3
|
description: Memory limits, execution timeouts, scale quotas, networking constraints, and v1 platform limitations for SDK resources
|
|
4
|
+
loadWhen: "Hitting resource limits or planning for scale"
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
This page documents the hard limits enforced on all SDK resources running on the Elevasis platform. These limits exist to ensure platform stability and fair resource usage across all organizations.
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Credential Security"
|
|
3
|
+
description: "Three-layer credential model: platform tools (server-side injection), http tool (arbitrary APIs), getCredential() (explicit opt-in raw access) -- .env scope and security boundaries"
|
|
4
|
+
loadWhen: "Setting up integrations or configuring tool access"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
This reference covers the Elevasis credential security model. Read it when helping a user connect to an external service, set up platform tools, or understand why environment variables are not used in workflows.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## The Core Rule
|
|
12
|
+
|
|
13
|
+
Integration credentials are never stored in `.env` and never available via `process.env` inside worker threads.
|
|
14
|
+
|
|
15
|
+
Credentials live in the platform credential system, created via the command center UI. Worker threads access credentials only through controlled channels: `platform.call()` (server-side injection) or `platform.getCredential()` (explicit opt-in).
|
|
16
|
+
|
|
17
|
+
`.env` contains only `ELEVASIS_API_KEY`, used by the CLI for authentication. It is never uploaded to the platform and never injected into workers.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Three-Layer Model
|
|
22
|
+
|
|
23
|
+
### Layer 1: Platform Tools (Default)
|
|
24
|
+
|
|
25
|
+
All platform tools resolve credentials server-side. The tool dispatcher in the API process looks up the credential by name, injects it into the service call, and returns only the result. Credential values never cross the postMessage boundary into the worker.
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
// Credential 'my-gmail' is resolved server-side -- value never enters worker memory
|
|
29
|
+
const result = await platform.call({
|
|
30
|
+
tool: 'gmail',
|
|
31
|
+
method: 'sendEmail',
|
|
32
|
+
credential: 'my-gmail',
|
|
33
|
+
params: { to: '...', subject: '...', body: '...' },
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
This is the default pattern for all integrations that have a platform adapter (Gmail, Attio, Stripe, Resend, etc.).
|
|
38
|
+
|
|
39
|
+
### Layer 2: HTTP Platform Tool
|
|
40
|
+
|
|
41
|
+
For APIs without a dedicated platform adapter, use the `http` platform tool. Credentials are resolved and injected server-side before the outgoing HTTP request.
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
const result = await platform.call({
|
|
45
|
+
tool: 'http',
|
|
46
|
+
method: 'request',
|
|
47
|
+
credential: 'my-custom-api',
|
|
48
|
+
params: {
|
|
49
|
+
url: 'https://api.example.com/v1/data',
|
|
50
|
+
method: 'GET',
|
|
51
|
+
headers: { 'Content-Type': 'application/json' },
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
// result = { status: 200, headers: {...}, body: {...} }
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Supported credential injection patterns:**
|
|
58
|
+
|
|
59
|
+
| Pattern | Credential Config | How Injected |
|
|
60
|
+
| --- | --- | --- |
|
|
61
|
+
| Bearer token | `{ type: 'bearer', token: 'sk_...' }` | `Authorization: Bearer sk_...` header |
|
|
62
|
+
| API key header | `{ type: 'api-key-header', header: 'X-API-Key', key: 'ak_...' }` | Custom header with key value |
|
|
63
|
+
| Basic auth | `{ type: 'basic', username: '...', password: '...' }` | `Authorization: Basic base64(user:pass)` header |
|
|
64
|
+
| Query parameter | `{ type: 'query-param', param: 'api_key', value: 'ak_...' }` | Appended to URL query string |
|
|
65
|
+
| Body field | `{ type: 'body-field', field: 'apiKey', value: 'ak_...' }` | Merged into JSON request body |
|
|
66
|
+
| Custom header | `{ type: 'custom-header', header: 'X-Custom', value: '...' }` | Arbitrary header with value |
|
|
67
|
+
|
|
68
|
+
The credential type is selected when creating the credential in the command center UI.
|
|
69
|
+
|
|
70
|
+
### Layer 3: getCredential() (Explicit Opt-In)
|
|
71
|
+
|
|
72
|
+
For cases where a third-party SDK must be initialized with a raw key (e.g., `new Stripe(key)`), use `platform.getCredential()`. This is an explicit opt-in that causes the credential value to enter worker memory.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
import { platform } from '@elevasis/sdk/worker'
|
|
76
|
+
|
|
77
|
+
// Explicit opt-in -- secret enters worker memory for duration of execution
|
|
78
|
+
const cred = await platform.getCredential('my-stripe-key')
|
|
79
|
+
const stripe = new Stripe(cred.credentials.secretKey)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`getCredential()` returns `{ provider: string, credentials: Record<string, string> }`. The fields in `credentials` depend on the credential type stored in the command center.
|
|
83
|
+
|
|
84
|
+
**Security guardrails:**
|
|
85
|
+
|
|
86
|
+
- All `getCredential()` calls are logged with credential name, deployment ID, and execution ID
|
|
87
|
+
- Workers are ephemeral (destroyed after each execution) -- no credential persistence
|
|
88
|
+
- Use `platform.call()` with the `http` tool instead when possible
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## Credential Setup
|
|
93
|
+
|
|
94
|
+
Credentials are created in the command center UI:
|
|
95
|
+
|
|
96
|
+
1. Open the Elevasis command center
|
|
97
|
+
2. Navigate to Credentials
|
|
98
|
+
3. Click "Add Credential"
|
|
99
|
+
4. Enter a name (e.g., `my-gmail`, `production-attio`, `custom-api`)
|
|
100
|
+
5. Select the credential type (bearer, api-key-header, basic, etc.)
|
|
101
|
+
6. Enter the secret values
|
|
102
|
+
7. Save
|
|
103
|
+
|
|
104
|
+
The credential name is what you pass as `credential: 'my-gmail'` in `platform.call()`.
|
|
105
|
+
|
|
106
|
+
Credential names are case-sensitive. A mismatch causes a `PlatformToolError` with the message "credential not found."
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## .env Scope
|
|
111
|
+
|
|
112
|
+
`.env` in your workspace contains only:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
ELEVASIS_API_KEY=sk_your_key_here
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This key authenticates CLI operations (`elevasis deploy`, `elevasis check`, `elevasis exec`). It is never uploaded to the platform and never injected into workers.
|
|
119
|
+
|
|
120
|
+
Do not put integration API keys in `.env`. They will not be available inside workflows.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Choosing a Credential Pattern
|
|
125
|
+
|
|
126
|
+
| Situation | Pattern |
|
|
127
|
+
| --- | --- |
|
|
128
|
+
| Using a supported platform tool (Gmail, Attio, Stripe, etc.) | `platform.call()` with the tool name |
|
|
129
|
+
| Calling an API not in the tool catalog | `platform.call()` with `tool: 'http'` |
|
|
130
|
+
| Third-party SDK that requires a raw key | `platform.getCredential()` |
|
|
131
|
+
| CLI authentication | `ELEVASIS_API_KEY` in `.env` only |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## Migrating from elevasis env
|
|
136
|
+
|
|
137
|
+
If you previously set integration credentials via `elevasis env set`, that command no longer exists. Use `elevasis env list` to see what was set, then recreate each entry as a platform credential in the command center. Update workflow code from `process.env.KEY` to `platform.call({ tool: 'http', credential: '...', ... })` or `platform.getCredential('...')`, then redeploy. The `.env` file remains but is scoped to `ELEVASIS_API_KEY` only.
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
**Last Updated:** 2026-02-26
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Template: Data Enrichment"
|
|
3
|
+
description: "LLM-powered enrichment of existing database records -- read rows, enrich each with an LLM, write results back to Supabase"
|
|
4
|
+
loadWhen: "Applying the data-enrichment workflow template"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
**Category:** Data Processing
|
|
8
|
+
|
|
9
|
+
**Platform Tools:** `llm` (text generation), `supabase` (select and update)
|
|
10
|
+
|
|
11
|
+
**Credentials Required:**
|
|
12
|
+
|
|
13
|
+
- `my-database` -- Supabase project URL and service role key
|
|
14
|
+
- LLM API keys are resolved server-side from platform configuration (no credential name needed)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## What This Workflow Does
|
|
19
|
+
|
|
20
|
+
Fetches records from a Supabase table that need enrichment, sends each record to an LLM with a custom prompt, and writes the enriched field back to the table. Supports batching to process multiple records per execution. Suitable for enriching leads with AI-generated summaries, classifying records, extracting structured data from text fields, or scoring records.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Input Schema
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
z.object({
|
|
28
|
+
table: z.string(), // Supabase table to enrich
|
|
29
|
+
filter: z.record(z.string()).optional(), // Filter rows to enrich (PostgREST format)
|
|
30
|
+
sourceField: z.string(), // Field to send to the LLM as input
|
|
31
|
+
targetField: z.string(), // Field to write enriched output to
|
|
32
|
+
prompt: z.string(), // LLM prompt template (use {value} as placeholder)
|
|
33
|
+
limit: z.number().optional(), // Max rows to process (default: 20)
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Output Schema
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
z.object({
|
|
41
|
+
processed: z.number(), // Rows successfully enriched
|
|
42
|
+
skipped: z.number(), // Rows skipped (missing source field, LLM error)
|
|
43
|
+
errors: z.array(z.string()), // Error messages for skipped rows
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Workflow Code Pattern
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import type { WorkflowDefinition } from '@elevasis/sdk'
|
|
53
|
+
import { platform } from '@elevasis/sdk/worker'
|
|
54
|
+
import { z } from 'zod'
|
|
55
|
+
|
|
56
|
+
const inputSchema = z.object({
|
|
57
|
+
table: z.string(),
|
|
58
|
+
filter: z.record(z.string()).optional(),
|
|
59
|
+
sourceField: z.string(),
|
|
60
|
+
targetField: z.string(),
|
|
61
|
+
prompt: z.string(),
|
|
62
|
+
limit: z.number().optional(),
|
|
63
|
+
})
|
|
64
|
+
const outputSchema = z.object({
|
|
65
|
+
processed: z.number(),
|
|
66
|
+
skipped: z.number(),
|
|
67
|
+
errors: z.array(z.string()),
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
type Input = z.infer<typeof inputSchema>
|
|
71
|
+
|
|
72
|
+
export const dataEnrichment: WorkflowDefinition = {
|
|
73
|
+
config: {
|
|
74
|
+
resourceId: 'data-enrichment',
|
|
75
|
+
name: 'Data Enrichment',
|
|
76
|
+
type: 'workflow',
|
|
77
|
+
description: 'Enriches database records using an LLM',
|
|
78
|
+
version: '1.0.0',
|
|
79
|
+
status: 'dev',
|
|
80
|
+
},
|
|
81
|
+
contract: { inputSchema, outputSchema },
|
|
82
|
+
steps: {
|
|
83
|
+
enrich: {
|
|
84
|
+
id: 'enrich',
|
|
85
|
+
name: 'Enrich Records',
|
|
86
|
+
description: 'Fetch records, call LLM for each, write results back',
|
|
87
|
+
inputSchema,
|
|
88
|
+
outputSchema,
|
|
89
|
+
handler: async (input, context) => {
|
|
90
|
+
const { table, filter, sourceField, targetField, prompt, limit } = input as Input
|
|
91
|
+
|
|
92
|
+
// Fetch rows to enrich
|
|
93
|
+
const rows = await platform.call({
|
|
94
|
+
tool: 'supabase',
|
|
95
|
+
method: 'select',
|
|
96
|
+
credential: 'my-database',
|
|
97
|
+
params: { table, filter, limit: limit ?? 20 },
|
|
98
|
+
}) as Array<Record<string, unknown>>
|
|
99
|
+
|
|
100
|
+
let processed = 0
|
|
101
|
+
const errors: string[] = []
|
|
102
|
+
|
|
103
|
+
for (const row of rows) {
|
|
104
|
+
const sourceValue = row[sourceField]
|
|
105
|
+
if (!sourceValue || typeof sourceValue !== 'string') {
|
|
106
|
+
errors.push(`Row ${String(row.id)}: missing ${sourceField}`)
|
|
107
|
+
continue
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
try {
|
|
111
|
+
const enrichedPrompt = prompt.replace('{value}', sourceValue)
|
|
112
|
+
const result = await platform.call({
|
|
113
|
+
tool: 'llm',
|
|
114
|
+
method: 'generate',
|
|
115
|
+
params: {
|
|
116
|
+
provider: 'openai',
|
|
117
|
+
model: 'gpt-4o-mini',
|
|
118
|
+
messages: [{ role: 'user', content: enrichedPrompt }],
|
|
119
|
+
},
|
|
120
|
+
}) as string
|
|
121
|
+
|
|
122
|
+
await platform.call({
|
|
123
|
+
tool: 'supabase',
|
|
124
|
+
method: 'update',
|
|
125
|
+
credential: 'my-database',
|
|
126
|
+
params: {
|
|
127
|
+
table,
|
|
128
|
+
filter: { id: `eq.${String(row.id)}` },
|
|
129
|
+
data: { [targetField]: result },
|
|
130
|
+
},
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
context.logger.info('Enriched row', { id: row.id })
|
|
134
|
+
processed++
|
|
135
|
+
} catch (err) {
|
|
136
|
+
const msg = err instanceof Error ? err.message : String(err)
|
|
137
|
+
errors.push(`Row ${String(row.id)}: ${msg}`)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return { processed, skipped: errors.length, errors }
|
|
142
|
+
},
|
|
143
|
+
next: null,
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
entryPoint: 'enrich',
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Adaptation Notes
|
|
153
|
+
|
|
154
|
+
- **Credential name:** Replace `'my-database'` with the user's database credential name.
|
|
155
|
+
- **LLM provider and model:** Default uses `openai` / `gpt-4o-mini`. Adapt to the user's preference or available providers.
|
|
156
|
+
- **Prompt template:** The `{value}` placeholder is replaced with the source field's value at runtime. Adapt the prompt for the user's specific enrichment task.
|
|
157
|
+
- **Batch size:** Default limit is 20 rows. Increase for bulk processing, decrease for expensive LLM calls.
|
|
158
|
+
- **Skill adaptation:** For beginners, explain what "enrichment" means and give concrete examples (adding a summary field, scoring, categorizing) before generating code.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
**Last Updated:** 2026-02-26
|