@elevasis/sdk 0.4.3 → 0.4.5
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 +352 -77
- package/package.json +10 -10
package/dist/cli.cjs
CHANGED
|
@@ -43808,7 +43808,7 @@ async function apiDelete(endpoint, apiUrl = resolveApiUrl()) {
|
|
|
43808
43808
|
}
|
|
43809
43809
|
|
|
43810
43810
|
// src/cli/version.ts
|
|
43811
|
-
var SDK_VERSION = "0.4.
|
|
43811
|
+
var SDK_VERSION = "0.4.5";
|
|
43812
43812
|
|
|
43813
43813
|
// src/cli/commands/deploy.ts
|
|
43814
43814
|
var import_meta2 = {};
|
|
@@ -43859,6 +43859,56 @@ async function scanDocumentation() {
|
|
|
43859
43859
|
await scan(docsDir, "");
|
|
43860
43860
|
return files.length > 0 ? files : void 0;
|
|
43861
43861
|
}
|
|
43862
|
+
function escapeMdx(text) {
|
|
43863
|
+
if (!text) return "";
|
|
43864
|
+
return text.replace(/\|/g, "\\|").replace(/\{/g, "\\{").replace(/\}/g, "\\}");
|
|
43865
|
+
}
|
|
43866
|
+
async function generateResourceMap(org) {
|
|
43867
|
+
const workflows = org.workflows ?? [];
|
|
43868
|
+
const agents = org.agents ?? [];
|
|
43869
|
+
if (workflows.length === 0 && agents.length === 0) return;
|
|
43870
|
+
const lines = [
|
|
43871
|
+
"---",
|
|
43872
|
+
"title: Resource Map",
|
|
43873
|
+
"description: Auto-generated resource inventory (updated on each deploy)",
|
|
43874
|
+
"order: 999",
|
|
43875
|
+
"---",
|
|
43876
|
+
"",
|
|
43877
|
+
"# Resource Map",
|
|
43878
|
+
"",
|
|
43879
|
+
"> Auto-generated by `elevasis deploy`. Do not edit manually.",
|
|
43880
|
+
""
|
|
43881
|
+
];
|
|
43882
|
+
if (workflows.length > 0) {
|
|
43883
|
+
lines.push(
|
|
43884
|
+
"## Workflows",
|
|
43885
|
+
"",
|
|
43886
|
+
"| Resource ID | Name | Version | Status | Description |",
|
|
43887
|
+
"| --- | --- | --- | --- | --- |"
|
|
43888
|
+
);
|
|
43889
|
+
for (const w of workflows) {
|
|
43890
|
+
const desc = escapeMdx(w.config.description);
|
|
43891
|
+
lines.push(`| \`${w.config.resourceId}\` | ${w.config.name} | ${w.config.version} | ${w.config.status} | ${desc} |`);
|
|
43892
|
+
}
|
|
43893
|
+
lines.push("");
|
|
43894
|
+
}
|
|
43895
|
+
if (agents.length > 0) {
|
|
43896
|
+
lines.push(
|
|
43897
|
+
"## Agents",
|
|
43898
|
+
"",
|
|
43899
|
+
"| Resource ID | Name | Version | Status | Description |",
|
|
43900
|
+
"| --- | --- | --- | --- | --- |"
|
|
43901
|
+
);
|
|
43902
|
+
for (const a of agents) {
|
|
43903
|
+
const desc = escapeMdx(a.config.description);
|
|
43904
|
+
lines.push(`| \`${a.config.resourceId}\` | ${a.config.name} | ${a.config.version} | ${a.config.status} | ${desc} |`);
|
|
43905
|
+
}
|
|
43906
|
+
lines.push("");
|
|
43907
|
+
}
|
|
43908
|
+
lines.push(`**Total:** ${workflows.length + agents.length} resources (${workflows.length} workflows, ${agents.length} agents)`, "");
|
|
43909
|
+
await (0, import_promises.mkdir)((0, import_path2.resolve)("docs"), { recursive: true });
|
|
43910
|
+
await (0, import_promises.writeFile)((0, import_path2.resolve)("docs/resource-map.mdx"), lines.join("\n"), "utf-8");
|
|
43911
|
+
}
|
|
43862
43912
|
function registerDeployCommand(program3) {
|
|
43863
43913
|
program3.command("deploy").description("Validate, bundle, upload, and deploy project resources\n Example: elevasis deploy --api-url http://localhost:5170").option("--api-url <url>", "API URL").option("--entry <path>", "Path to entry file (default: ./src/index.ts)").action(wrapAction("deploy", async (options2) => {
|
|
43864
43914
|
const startTime = Date.now();
|
|
@@ -43920,6 +43970,7 @@ function registerDeployCommand(program3) {
|
|
|
43920
43970
|
}
|
|
43921
43971
|
throw error46;
|
|
43922
43972
|
}
|
|
43973
|
+
await generateResourceMap(org);
|
|
43923
43974
|
const documentation = await scanDocumentation();
|
|
43924
43975
|
if (documentation) {
|
|
43925
43976
|
console.log(source_default.gray(` docs ${source_default.white(String(documentation.length))} file${documentation.length !== 1 ? "s" : ""}`));
|
|
@@ -44414,14 +44465,18 @@ var SCAFFOLD_FILES = [
|
|
|
44414
44465
|
"pnpm-workspace.yaml",
|
|
44415
44466
|
"tsconfig.json",
|
|
44416
44467
|
".env",
|
|
44468
|
+
".env.example",
|
|
44469
|
+
".npmrc",
|
|
44417
44470
|
".gitignore",
|
|
44418
|
-
"README.md",
|
|
44419
44471
|
"src/index.ts",
|
|
44420
44472
|
"docs/index.mdx",
|
|
44421
44473
|
"CLAUDE.md",
|
|
44474
|
+
".claude/settings.json",
|
|
44422
44475
|
".claude/commands/docs.md",
|
|
44423
44476
|
".claude/commands/resource.md",
|
|
44424
|
-
".claude/commands/deploy.md"
|
|
44477
|
+
".claude/commands/deploy.md",
|
|
44478
|
+
".claude/commands/inspect.md",
|
|
44479
|
+
".claude/commands/env.md"
|
|
44425
44480
|
];
|
|
44426
44481
|
function registerInitCommand(program3) {
|
|
44427
44482
|
program3.command("init [directory]").description("Scaffold a new Elevasis project\n Example: elevasis init my-project").option("--force", "Overwrite existing files").action(wrapAction("init", async (directory, options2) => {
|
|
@@ -44454,14 +44509,18 @@ function registerInitCommand(program3) {
|
|
|
44454
44509
|
"pnpm-workspace.yaml": pnpmWorkspaceTemplate(),
|
|
44455
44510
|
"tsconfig.json": tsconfigTemplate(),
|
|
44456
44511
|
".env": envTemplate(),
|
|
44512
|
+
".env.example": envExampleTemplate(),
|
|
44513
|
+
".npmrc": npmrcTemplate(),
|
|
44457
44514
|
".gitignore": gitignoreTemplate(),
|
|
44458
|
-
"README.md": readmeTemplate(orgSlug),
|
|
44459
44515
|
"src/index.ts": starterTemplate(),
|
|
44460
|
-
"docs/index.mdx": docsIndexTemplate(),
|
|
44516
|
+
"docs/index.mdx": docsIndexTemplate(orgSlug),
|
|
44461
44517
|
"CLAUDE.md": claudeMdTemplate(),
|
|
44518
|
+
".claude/settings.json": claudeSettingsTemplate(),
|
|
44462
44519
|
".claude/commands/docs.md": claudeDocsCommandTemplate(),
|
|
44463
44520
|
".claude/commands/resource.md": claudeResourceCommandTemplate(),
|
|
44464
|
-
".claude/commands/deploy.md": claudeDeployCommandTemplate()
|
|
44521
|
+
".claude/commands/deploy.md": claudeDeployCommandTemplate(),
|
|
44522
|
+
".claude/commands/inspect.md": claudeInspectCommandTemplate(),
|
|
44523
|
+
".claude/commands/env.md": claudeEnvCommandTemplate()
|
|
44465
44524
|
};
|
|
44466
44525
|
for (const [filePath, content] of Object.entries(files)) {
|
|
44467
44526
|
await (0, import_promises2.writeFile)((0, import_path3.resolve)(targetDir, filePath), content, "utf-8");
|
|
@@ -44473,7 +44532,7 @@ function registerInitCommand(program3) {
|
|
|
44473
44532
|
console.log(source_default.gray(` cd ${directory}`));
|
|
44474
44533
|
}
|
|
44475
44534
|
console.log(source_default.gray(" pnpm install"));
|
|
44476
|
-
console.log(source_default.gray(" #
|
|
44535
|
+
console.log(source_default.gray(" # Copy .env.example to .env and add your API key"));
|
|
44477
44536
|
console.log(source_default.gray(" elevasis check"));
|
|
44478
44537
|
console.log(source_default.gray(" elevasis deploy"));
|
|
44479
44538
|
}));
|
|
@@ -44485,7 +44544,10 @@ function toSlug(name) {
|
|
|
44485
44544
|
function configTemplate() {
|
|
44486
44545
|
return `import type { ElevasConfig } from '@elevasis/sdk'
|
|
44487
44546
|
|
|
44488
|
-
export default {
|
|
44547
|
+
export default {
|
|
44548
|
+
// defaultStatus: 'dev', // Default status for new resources ('dev' | 'production')
|
|
44549
|
+
// dev: { port: 5170 }, // Local API port (internal development only)
|
|
44550
|
+
} satisfies ElevasConfig
|
|
44489
44551
|
`;
|
|
44490
44552
|
}
|
|
44491
44553
|
function packageJsonTemplate(organization) {
|
|
@@ -44521,8 +44583,6 @@ function tsconfigTemplate() {
|
|
|
44521
44583
|
skipLibCheck: true,
|
|
44522
44584
|
forceConsistentCasingInFileNames: true,
|
|
44523
44585
|
isolatedModules: true,
|
|
44524
|
-
declaration: true,
|
|
44525
|
-
declarationMap: true,
|
|
44526
44586
|
outDir: "./dist"
|
|
44527
44587
|
},
|
|
44528
44588
|
include: ["src"],
|
|
@@ -44531,17 +44591,33 @@ function tsconfigTemplate() {
|
|
|
44531
44591
|
}
|
|
44532
44592
|
function envTemplate() {
|
|
44533
44593
|
return `ELEVASIS_API_KEY=
|
|
44534
|
-
|
|
44594
|
+
`;
|
|
44595
|
+
}
|
|
44596
|
+
function envExampleTemplate() {
|
|
44597
|
+
return `ELEVASIS_API_KEY=sk_your_key_here
|
|
44598
|
+
`;
|
|
44599
|
+
}
|
|
44600
|
+
function npmrcTemplate() {
|
|
44601
|
+
return `auto-install-peers = true
|
|
44535
44602
|
`;
|
|
44536
44603
|
}
|
|
44537
44604
|
function gitignoreTemplate() {
|
|
44538
44605
|
return `node_modules/
|
|
44539
44606
|
.env
|
|
44540
44607
|
dist/
|
|
44608
|
+
__elevasis_worker.ts
|
|
44609
|
+
.claude/settings.local.json
|
|
44610
|
+
.claude/profile.json
|
|
44541
44611
|
`;
|
|
44542
44612
|
}
|
|
44543
|
-
function
|
|
44544
|
-
return
|
|
44613
|
+
function docsIndexTemplate(organization) {
|
|
44614
|
+
return `---
|
|
44615
|
+
title: ${organization}
|
|
44616
|
+
description: Documentation for the ${organization} Elevasis project
|
|
44617
|
+
order: 1
|
|
44618
|
+
---
|
|
44619
|
+
|
|
44620
|
+
# ${organization}
|
|
44545
44621
|
|
|
44546
44622
|
An [Elevasis](https://elevasis.io) project built with the \`@elevasis/sdk\`.
|
|
44547
44623
|
|
|
@@ -44551,7 +44627,7 @@ An [Elevasis](https://elevasis.io) project built with the \`@elevasis/sdk\`.
|
|
|
44551
44627
|
pnpm install
|
|
44552
44628
|
\`\`\`
|
|
44553
44629
|
|
|
44554
|
-
|
|
44630
|
+
Copy \`.env.example\` to \`.env\` and add your API key:
|
|
44555
44631
|
|
|
44556
44632
|
\`\`\`
|
|
44557
44633
|
ELEVASIS_API_KEY=sk_...
|
|
@@ -44560,58 +44636,72 @@ ELEVASIS_API_KEY=sk_...
|
|
|
44560
44636
|
## Development
|
|
44561
44637
|
|
|
44562
44638
|
\`\`\`bash
|
|
44563
|
-
# Validate
|
|
44564
|
-
elevasis
|
|
44565
|
-
|
|
44566
|
-
#
|
|
44567
|
-
elevasis
|
|
44568
|
-
|
|
44569
|
-
#
|
|
44570
|
-
elevasis
|
|
44571
|
-
|
|
44572
|
-
# List deployed resources
|
|
44573
|
-
elevasis resources
|
|
44574
|
-
|
|
44575
|
-
# View execution history
|
|
44576
|
-
elevasis executions <resourceId>
|
|
44639
|
+
elevasis check # Validate resource definitions
|
|
44640
|
+
elevasis deploy # Bundle and deploy to platform
|
|
44641
|
+
elevasis exec <resourceId> --input '...' # Execute a resource
|
|
44642
|
+
elevasis resources # List deployed resources
|
|
44643
|
+
elevasis describe <resourceId> # Show resource definition + schemas
|
|
44644
|
+
elevasis executions <resourceId> # View execution history
|
|
44645
|
+
elevasis env list # List platform env var names
|
|
44646
|
+
elevasis env set NAME VALUE # Set env var (requires redeploy)
|
|
44577
44647
|
\`\`\`
|
|
44578
44648
|
|
|
44579
44649
|
## Project Structure
|
|
44580
44650
|
|
|
44581
44651
|
- \`elevasis.config.ts\` -- Project config (optional settings)
|
|
44582
44652
|
- \`src/index.ts\` -- Resource definitions (workflows, agents)
|
|
44653
|
+
- \`docs/\` -- Documentation (.mdx files, deployed alongside code)
|
|
44583
44654
|
- \`.env\` -- API key and environment variables
|
|
44584
|
-
`;
|
|
44585
|
-
}
|
|
44586
|
-
function docsIndexTemplate() {
|
|
44587
|
-
return `---
|
|
44588
|
-
title: Overview
|
|
44589
|
-
description: Documentation for this Elevasis project
|
|
44590
|
-
---
|
|
44591
|
-
|
|
44592
|
-
# Overview
|
|
44593
|
-
|
|
44594
|
-
Welcome to the documentation for this project.
|
|
44595
44655
|
|
|
44596
44656
|
## Resources
|
|
44597
44657
|
|
|
44598
|
-
|
|
44599
|
-
code and rendered in the Elevasis platform UI.
|
|
44658
|
+
### Echo Workflow
|
|
44600
44659
|
|
|
44601
|
-
|
|
44660
|
+
A simple workflow that echoes the input message back. Use it to verify your
|
|
44661
|
+
deployment is working:
|
|
44602
44662
|
|
|
44603
44663
|
\`\`\`bash
|
|
44604
|
-
elevasis
|
|
44605
|
-
elevasis deploy # Deploy to platform
|
|
44606
|
-
elevasis exec <resourceId> --input '{"key": "value"}'
|
|
44664
|
+
elevasis exec echo --input '{"message": "hello"}'
|
|
44607
44665
|
\`\`\`
|
|
44666
|
+
|
|
44667
|
+
**Input:** \`{ "message": string }\`
|
|
44668
|
+
**Output:** \`{ "echo": string }\`
|
|
44608
44669
|
`;
|
|
44609
44670
|
}
|
|
44671
|
+
function claudeSettingsTemplate() {
|
|
44672
|
+
return JSON.stringify({ autoCompact: false }, null, 2) + "\n";
|
|
44673
|
+
}
|
|
44610
44674
|
function claudeMdTemplate() {
|
|
44611
44675
|
return `# CLAUDE.md
|
|
44612
44676
|
|
|
44613
44677
|
Project instructions for Claude Code when working with this Elevasis SDK project.
|
|
44614
44678
|
|
|
44679
|
+
## Welcome & Profiling
|
|
44680
|
+
|
|
44681
|
+
On first interaction, check if \`.claude/profile.json\` exists.
|
|
44682
|
+
|
|
44683
|
+
**If it does NOT exist**, run a one-time welcome:
|
|
44684
|
+
|
|
44685
|
+
1. Greet the developer and explain this is a quick one-time setup to personalize help
|
|
44686
|
+
2. Ask these questions:
|
|
44687
|
+
- What kind of business or team is this for? (e.g., marketing agency, SaaS, e-commerce)
|
|
44688
|
+
- What are the main goals for this project? (e.g., email automation, CRM sync, lead scoring)
|
|
44689
|
+
- Which external tools or services will your workflows integrate with? (e.g., Gmail, Attio, Slack)
|
|
44690
|
+
- How would you describe your experience with TypeScript and AI automation? (beginner/intermediate/advanced)
|
|
44691
|
+
3. Write answers to \`.claude/profile.json\`:
|
|
44692
|
+
\`\`\`json
|
|
44693
|
+
{
|
|
44694
|
+
"organization": { "name": "", "industry": "", "size": "" },
|
|
44695
|
+
"developer": { "experience": "", "aiExperience": "" },
|
|
44696
|
+
"project": { "description": "", "existingTools": [], "primaryGoals": [] },
|
|
44697
|
+
"preferences": { "verbosity": "concise" }
|
|
44698
|
+
}
|
|
44699
|
+
\`\`\`
|
|
44700
|
+
4. Summarize what you will help them build and suggest a first resource to create
|
|
44701
|
+
|
|
44702
|
+
**If it exists**, read it at session start to personalize your responses (suggest
|
|
44703
|
+
relevant tools, calibrate explanation depth, reference their goals).
|
|
44704
|
+
|
|
44615
44705
|
## What This Is
|
|
44616
44706
|
|
|
44617
44707
|
An Elevasis SDK project -- external resources (workflows, agents) that deploy to
|
|
@@ -44623,21 +44713,40 @@ scheduling, and integration tools.
|
|
|
44623
44713
|
- \`src/index.ts\` -- Resource definitions (workflows, agents). Exports
|
|
44624
44714
|
\`OrganizationResources\` as default export.
|
|
44625
44715
|
- \`docs/\` -- Documentation files (.mdx). Deployed alongside code, rendered in
|
|
44626
|
-
platform UI.
|
|
44716
|
+
platform UI. Max 100KB per file, 1MB total per deployment.
|
|
44627
44717
|
- \`elevasis.config.ts\` -- Project configuration (optional).
|
|
44628
44718
|
- \`.env\` -- API key (\`ELEVASIS_API_KEY\`) and environment variables.
|
|
44719
|
+
- \`dist/\` -- Generated by \`elevasis deploy\` (gitignored, never commit).
|
|
44720
|
+
- \`.claude/profile.json\` -- Your profile (created on first session, gitignored).
|
|
44629
44721
|
|
|
44630
|
-
##
|
|
44722
|
+
## CLI Reference
|
|
44723
|
+
|
|
44724
|
+
\`\`\`bash
|
|
44725
|
+
elevasis check # Validate resource definitions (--entry to override)
|
|
44726
|
+
elevasis deploy # Bundle + deploy to platform (--entry, --api-url)
|
|
44727
|
+
elevasis exec <id> -i '{"key":"val"}' # Execute a resource (--async for background)
|
|
44728
|
+
elevasis resources # List deployed resources (--json)
|
|
44729
|
+
elevasis describe <id> # Show resource definition + schemas (--json)
|
|
44730
|
+
elevasis executions <id> # Execution history (--limit, --status, --json)
|
|
44731
|
+
elevasis execution <id> <execId> # Execution detail (--logs-only, --input, --result)
|
|
44732
|
+
elevasis deployments # Deployment history (--json)
|
|
44733
|
+
elevasis env list # List platform env var names (--json)
|
|
44734
|
+
elevasis env set <NAME> <VALUE> # Set env var (requires redeploy to take effect)
|
|
44735
|
+
elevasis env remove <NAME> # Remove env var (requires redeploy to take effect)
|
|
44736
|
+
\`\`\`
|
|
44631
44737
|
|
|
44632
|
-
|
|
44738
|
+
## SDK Patterns
|
|
44633
44739
|
|
|
44634
|
-
|
|
44635
|
-
implementation (steps for workflows, agent config for agents).
|
|
44740
|
+
### Single-Step Workflow
|
|
44636
44741
|
|
|
44637
44742
|
\`\`\`typescript
|
|
44638
44743
|
import type { WorkflowDefinition, OrganizationResources } from '@elevasis/sdk'
|
|
44639
44744
|
import { z } from 'zod'
|
|
44640
44745
|
|
|
44746
|
+
const myInput = z.object({ message: z.string() })
|
|
44747
|
+
const myOutput = z.object({ result: z.string() })
|
|
44748
|
+
type MyInput = z.infer<typeof myInput>
|
|
44749
|
+
|
|
44641
44750
|
const myWorkflow: WorkflowDefinition = {
|
|
44642
44751
|
config: {
|
|
44643
44752
|
resourceId: 'my-workflow',
|
|
@@ -44648,41 +44757,130 @@ const myWorkflow: WorkflowDefinition = {
|
|
|
44648
44757
|
status: 'dev', // 'dev' | 'production'
|
|
44649
44758
|
},
|
|
44650
44759
|
contract: {
|
|
44651
|
-
inputSchema:
|
|
44652
|
-
outputSchema:
|
|
44760
|
+
inputSchema: myInput,
|
|
44761
|
+
outputSchema: myOutput,
|
|
44653
44762
|
},
|
|
44654
|
-
steps: {
|
|
44655
|
-
|
|
44763
|
+
steps: {
|
|
44764
|
+
'process': {
|
|
44765
|
+
id: 'process',
|
|
44766
|
+
name: 'Process',
|
|
44767
|
+
description: 'Process the input',
|
|
44768
|
+
handler: async (input) => {
|
|
44769
|
+
const { message } = input as MyInput
|
|
44770
|
+
return { result: message.toUpperCase() }
|
|
44771
|
+
},
|
|
44772
|
+
inputSchema: myInput,
|
|
44773
|
+
outputSchema: myOutput,
|
|
44774
|
+
next: null, // terminal step
|
|
44775
|
+
},
|
|
44776
|
+
},
|
|
44777
|
+
entryPoint: 'process',
|
|
44656
44778
|
}
|
|
44657
44779
|
|
|
44658
|
-
const org: OrganizationResources = {
|
|
44659
|
-
workflows: [myWorkflow],
|
|
44660
|
-
}
|
|
44780
|
+
const org: OrganizationResources = { workflows: [myWorkflow] }
|
|
44661
44781
|
export default org
|
|
44662
44782
|
\`\`\`
|
|
44663
44783
|
|
|
44664
|
-
###
|
|
44784
|
+
### Multi-Step Workflow
|
|
44665
44785
|
|
|
44666
|
-
|
|
44667
|
-
at deploy time via \`z.toJSONSchema()\`.
|
|
44786
|
+
Use \`StepType\` (runtime value) from \`'@elevasis/sdk'\` to chain steps:
|
|
44668
44787
|
|
|
44669
|
-
|
|
44788
|
+
\`\`\`typescript
|
|
44789
|
+
import { StepType } from '@elevasis/sdk'
|
|
44790
|
+
|
|
44791
|
+
steps: {
|
|
44792
|
+
'step-one': {
|
|
44793
|
+
id: 'step-one',
|
|
44794
|
+
name: 'Step One',
|
|
44795
|
+
handler: async (input) => { /* ... */ },
|
|
44796
|
+
inputSchema: stepOneInput,
|
|
44797
|
+
outputSchema: stepOneOutput,
|
|
44798
|
+
next: { type: StepType.LINEAR, target: 'step-two' }, // linear chain
|
|
44799
|
+
},
|
|
44800
|
+
'step-two': {
|
|
44801
|
+
id: 'step-two',
|
|
44802
|
+
name: 'Step Two',
|
|
44803
|
+
handler: async (input) => { /* ... */ },
|
|
44804
|
+
inputSchema: stepTwoInput,
|
|
44805
|
+
outputSchema: stepTwoOutput,
|
|
44806
|
+
next: null, // terminal
|
|
44807
|
+
},
|
|
44808
|
+
},
|
|
44809
|
+
entryPoint: 'step-one',
|
|
44810
|
+
\`\`\`
|
|
44670
44811
|
|
|
44671
|
-
|
|
44672
|
-
|
|
44673
|
-
|
|
44674
|
-
|
|
44675
|
-
|
|
44676
|
-
|
|
44812
|
+
### Conditional Routing
|
|
44813
|
+
|
|
44814
|
+
Route to different steps based on output data:
|
|
44815
|
+
|
|
44816
|
+
\`\`\`typescript
|
|
44817
|
+
import { StepType } from '@elevasis/sdk'
|
|
44818
|
+
|
|
44819
|
+
next: {
|
|
44820
|
+
type: StepType.CONDITIONAL,
|
|
44821
|
+
routes: [
|
|
44822
|
+
{ target: 'approved', condition: (data: any) => data.score >= 80 },
|
|
44823
|
+
{ target: 'review', condition: (data: any) => data.score >= 50 },
|
|
44824
|
+
],
|
|
44825
|
+
default: 'rejected', // fallback if no condition matches
|
|
44826
|
+
},
|
|
44827
|
+
\`\`\`
|
|
44828
|
+
|
|
44829
|
+
### Platform Tools
|
|
44830
|
+
|
|
44831
|
+
Call 70+ platform tools from step handlers via \`platform.call()\`:
|
|
44832
|
+
|
|
44833
|
+
\`\`\`typescript
|
|
44834
|
+
import { platform, PlatformToolError } from '@elevasis/sdk/worker'
|
|
44835
|
+
|
|
44836
|
+
handler: async (input) => {
|
|
44837
|
+
try {
|
|
44838
|
+
const result = await platform.call({
|
|
44839
|
+
tool: 'gmail', // tool name
|
|
44840
|
+
method: 'sendEmail', // method
|
|
44841
|
+
params: { to: '...', subject: '...', body: '...' },
|
|
44842
|
+
credential: 'my-gmail', // credential name (required for integrations)
|
|
44843
|
+
})
|
|
44844
|
+
return { sent: true, result }
|
|
44845
|
+
} catch (err) {
|
|
44846
|
+
if (err instanceof PlatformToolError) {
|
|
44847
|
+
console.error(err.code, err.retryable)
|
|
44848
|
+
}
|
|
44849
|
+
throw err
|
|
44850
|
+
}
|
|
44851
|
+
}
|
|
44677
44852
|
\`\`\`
|
|
44678
44853
|
|
|
44854
|
+
Each \`platform.call()\` has a 60-second timeout. The \`credential\` field names a
|
|
44855
|
+
credential configured in the Elevasis platform for your organization.
|
|
44856
|
+
|
|
44857
|
+
### ExecutionContext
|
|
44858
|
+
|
|
44859
|
+
Step handlers receive \`(input, context)\`. The context includes:
|
|
44860
|
+
|
|
44861
|
+
- \`context.executionId\` -- Unique ID for this execution
|
|
44862
|
+
- \`context.organizationId\` -- Your organization ID
|
|
44863
|
+
- \`context.resourceId\` -- The resource being executed
|
|
44864
|
+
- \`context.logger\` -- \`{ debug, info, warn, error }\` for structured logging
|
|
44865
|
+
- \`context.store\` -- \`Map<string, unknown>\` for passing data between steps
|
|
44866
|
+
|
|
44867
|
+
### Zod Schemas
|
|
44868
|
+
|
|
44869
|
+
All schemas use Zod 4.1+. Input and output schemas are converted to JSON Schema
|
|
44870
|
+
at deploy time via \`z.toJSONSchema()\`.
|
|
44871
|
+
|
|
44679
44872
|
## Rules
|
|
44680
44873
|
|
|
44681
44874
|
- All resource definitions must be in \`src/\` and exported via \`src/index.ts\`
|
|
44682
44875
|
- The default export must be an \`OrganizationResources\` object
|
|
44683
44876
|
- Do not import from \`@repo/core\` -- use \`@elevasis/sdk\` types only
|
|
44877
|
+
- \`StepType\`, \`ExecutionError\`, \`ToolingError\` are runtime imports from \`'@elevasis/sdk'\`
|
|
44878
|
+
- \`platform\`, \`PlatformToolError\` are runtime imports from \`'@elevasis/sdk/worker'\`
|
|
44684
44879
|
- Environment variables go in \`.env\` (never commit API keys)
|
|
44880
|
+
- Env vars set via \`elevasis env set\` require \`elevasis deploy\` to take effect
|
|
44685
44881
|
- Documentation goes in \`docs/\` as \`.mdx\` files
|
|
44882
|
+
- \`dist/\` is generated by deploy -- never commit it
|
|
44883
|
+
- \`resourceId\` must be lowercase with hyphens, unique per organization
|
|
44686
44884
|
`;
|
|
44687
44885
|
}
|
|
44688
44886
|
function claudeDocsCommandTemplate() {
|
|
@@ -44715,23 +44913,31 @@ You are a resource scaffolding assistant for this Elevasis SDK project.
|
|
|
44715
44913
|
|
|
44716
44914
|
## Context
|
|
44717
44915
|
|
|
44718
|
-
Read CLAUDE.md for SDK patterns.
|
|
44916
|
+
Read CLAUDE.md for SDK patterns (single-step, multi-step, conditional, platform tools).
|
|
44719
44917
|
Read src/index.ts for existing resource definitions and the OrganizationResources export.
|
|
44720
44918
|
|
|
44721
44919
|
## Operations
|
|
44722
44920
|
|
|
44723
|
-
**\`workflow <name>\`:** Create a new workflow definition with:
|
|
44724
|
-
- Zod input/output schemas
|
|
44921
|
+
**\`workflow <name>\`:** Create a new single-step workflow definition with:
|
|
44922
|
+
- Zod input/output schemas with \`z.infer\` type aliases
|
|
44725
44923
|
- Config object (resourceId, name, type, description, version, status)
|
|
44726
44924
|
- Contract with schemas
|
|
44727
|
-
- Step
|
|
44925
|
+
- Step definition with handler
|
|
44728
44926
|
- Add to the OrganizationResources export
|
|
44729
44927
|
|
|
44730
|
-
**\`
|
|
44731
|
-
-
|
|
44732
|
-
-
|
|
44733
|
-
-
|
|
44734
|
-
-
|
|
44928
|
+
**\`multi-step <name>\`:** Create a multi-step workflow with:
|
|
44929
|
+
- Multiple steps connected via StepType.LINEAR or StepType.CONDITIONAL
|
|
44930
|
+
- Import \`{ StepType }\` from '@elevasis/sdk' (runtime value, not type)
|
|
44931
|
+
- Each step has its own inputSchema/outputSchema
|
|
44932
|
+
- Linear: \`next: { type: StepType.LINEAR, target: 'step-two' }\`
|
|
44933
|
+
- Conditional: \`next: { type: StepType.CONDITIONAL, routes: [...], default: 'fallback' }\`
|
|
44934
|
+
- Last step: \`next: null\`
|
|
44935
|
+
|
|
44936
|
+
**\`tool-step <name>\`:** Create a step that calls a platform tool:
|
|
44937
|
+
- Import \`{ platform, PlatformToolError }\` from '@elevasis/sdk/worker'
|
|
44938
|
+
- Use \`await platform.call({ tool, method, params, credential })\`
|
|
44939
|
+
- Wrap in try/catch for PlatformToolError
|
|
44940
|
+
- Note: 60s timeout per call, credential required for integration tools
|
|
44735
44941
|
`;
|
|
44736
44942
|
}
|
|
44737
44943
|
function claudeDeployCommandTemplate() {
|
|
@@ -44757,6 +44963,73 @@ Before deploying, verify:
|
|
|
44757
44963
|
then \`elevasis resources\` to list deployed resources.
|
|
44758
44964
|
`;
|
|
44759
44965
|
}
|
|
44966
|
+
function claudeInspectCommandTemplate() {
|
|
44967
|
+
return `# /inspect command
|
|
44968
|
+
|
|
44969
|
+
You are a deployment health and execution debugging assistant.
|
|
44970
|
+
|
|
44971
|
+
## Context
|
|
44972
|
+
|
|
44973
|
+
Read CLAUDE.md for project context and CLI reference.
|
|
44974
|
+
|
|
44975
|
+
## Operations
|
|
44976
|
+
|
|
44977
|
+
**No arguments (default):** Run a health overview:
|
|
44978
|
+
1. Run \`elevasis deployments\` to show deployment status
|
|
44979
|
+
2. Run \`elevasis resources\` to list deployed resources
|
|
44980
|
+
3. Summarize: deployment age, resource count, any issues
|
|
44981
|
+
|
|
44982
|
+
**\`executions <resourceId>\`:** Show execution history:
|
|
44983
|
+
1. Run \`elevasis executions <resourceId>\`
|
|
44984
|
+
2. Summarize: success/failure counts, recent trends
|
|
44985
|
+
3. If failures exist, suggest drilling into specific executions
|
|
44986
|
+
|
|
44987
|
+
**\`describe <resourceId>\`:** Show resource schemas:
|
|
44988
|
+
1. Run \`elevasis describe <resourceId>\`
|
|
44989
|
+
2. Display input/output schemas in a readable format
|
|
44990
|
+
3. Generate an example \`elevasis exec\` command from the input schema
|
|
44991
|
+
|
|
44992
|
+
**\`execution <resourceId> <executionId>\`:** Drill into a specific execution:
|
|
44993
|
+
1. Run \`elevasis execution <resourceId> <executionId>\`
|
|
44994
|
+
2. Show status, timing, input, output
|
|
44995
|
+
3. If failed, analyze the error and suggest fixes
|
|
44996
|
+
|
|
44997
|
+
**\`failed <resourceId>\`:** Find and analyze recent failures:
|
|
44998
|
+
1. Run \`elevasis executions <resourceId> --status failed --limit 5\`
|
|
44999
|
+
2. For each failure, run \`elevasis execution <resourceId> <id> --logs-only\`
|
|
45000
|
+
3. Identify patterns and suggest fixes
|
|
45001
|
+
`;
|
|
45002
|
+
}
|
|
45003
|
+
function claudeEnvCommandTemplate() {
|
|
45004
|
+
return `# /env command
|
|
45005
|
+
|
|
45006
|
+
You are an environment variable management assistant.
|
|
45007
|
+
|
|
45008
|
+
## Context
|
|
45009
|
+
|
|
45010
|
+
Read CLAUDE.md for project context and CLI reference.
|
|
45011
|
+
Read .env for local environment variables.
|
|
45012
|
+
|
|
45013
|
+
## Operations
|
|
45014
|
+
|
|
45015
|
+
**No arguments (default):** Compare local vs platform:
|
|
45016
|
+
1. Read .env file and extract variable names
|
|
45017
|
+
2. Run \`elevasis env list\` to get platform variables
|
|
45018
|
+
3. Show comparison: what is local-only, platform-only, or in both
|
|
45019
|
+
4. Suggest actions for any mismatches
|
|
45020
|
+
|
|
45021
|
+
**\`set <NAME> <VALUE>\`:** Set a platform variable:
|
|
45022
|
+
1. Run \`elevasis env set <NAME> <VALUE>\`
|
|
45023
|
+
2. Remind user to redeploy: \`elevasis deploy\`
|
|
45024
|
+
|
|
45025
|
+
**\`sync\`:** Walk .env and sync to platform:
|
|
45026
|
+
1. Read .env file
|
|
45027
|
+
2. For each variable (except ELEVASIS_API_KEY), check if it exists on platform
|
|
45028
|
+
3. Show what would be added/updated
|
|
45029
|
+
4. Ask for confirmation before running \`elevasis env set\` for each
|
|
45030
|
+
5. Remind user to redeploy after syncing
|
|
45031
|
+
`;
|
|
45032
|
+
}
|
|
44760
45033
|
function starterTemplate() {
|
|
44761
45034
|
return `import type { WorkflowDefinition, OrganizationResources } from '@elevasis/sdk'
|
|
44762
45035
|
import { z } from 'zod'
|
|
@@ -44764,6 +45037,8 @@ import { z } from 'zod'
|
|
|
44764
45037
|
const echoInput = z.object({ message: z.string() })
|
|
44765
45038
|
const echoOutput = z.object({ echo: z.string() })
|
|
44766
45039
|
|
|
45040
|
+
type EchoInput = z.infer<typeof echoInput>
|
|
45041
|
+
|
|
44767
45042
|
const echo: WorkflowDefinition = {
|
|
44768
45043
|
config: {
|
|
44769
45044
|
resourceId: 'echo',
|
|
@@ -44783,7 +45058,7 @@ const echo: WorkflowDefinition = {
|
|
|
44783
45058
|
name: 'Echo Message',
|
|
44784
45059
|
description: 'Returns the input message',
|
|
44785
45060
|
handler: async (input) => {
|
|
44786
|
-
const { message } = input as
|
|
45061
|
+
const { message } = input as EchoInput
|
|
44787
45062
|
return { echo: message }
|
|
44788
45063
|
},
|
|
44789
45064
|
inputSchema: echoInput,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elevasis/sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "SDK for building Elevasis organization resources",
|
|
5
5
|
"comment:bin": "IMPORTANT: This package shares the 'elevasis' binary name with @repo/cli. They never conflict because @elevasis/sdk must NEVER be added as a dependency of any workspace package (apps/*, packages/*, organizations/*). Workspace projects use @repo/cli for the 'elevasis' binary. External developers (outside the workspace) get this SDK's binary via npm install.",
|
|
6
6
|
"type": "module",
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"dist/types/worker/platform.d.ts",
|
|
27
27
|
"dist/cli.cjs"
|
|
28
28
|
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.core-dts.json && tsc -p tsconfig.build.json && tsup && rollup -c rollup.dts.config.mjs && esbuild src/cli/index.ts --bundle --platform=node --outfile=dist/cli.cjs --format=cjs --external:esbuild --external:jiti --banner:js=\"#!/usr/bin/env node\"",
|
|
31
|
+
"check-types": "tsc --noEmit",
|
|
32
|
+
"test:bundle": "pnpm build && vitest run --config vitest.bundle.config.ts"
|
|
33
|
+
},
|
|
29
34
|
"dependencies": {
|
|
30
35
|
"esbuild": "^0.25.0",
|
|
31
36
|
"jiti": "^2.0.0"
|
|
@@ -34,6 +39,8 @@
|
|
|
34
39
|
"zod": "^4.1.0"
|
|
35
40
|
},
|
|
36
41
|
"devDependencies": {
|
|
42
|
+
"@repo/core": "workspace:*",
|
|
43
|
+
"@repo/typescript-config": "workspace:*",
|
|
37
44
|
"@types/node": "^22.0.0",
|
|
38
45
|
"chalk": "^5.3.0",
|
|
39
46
|
"commander": "^11.0.0",
|
|
@@ -44,13 +51,6 @@
|
|
|
44
51
|
"rollup-plugin-dts": "^6.3.0",
|
|
45
52
|
"tsup": "^8.0.0",
|
|
46
53
|
"typescript": "5.9.2",
|
|
47
|
-
"zod": "^4.1.0"
|
|
48
|
-
"@repo/core": "0.0.0",
|
|
49
|
-
"@repo/typescript-config": "0.0.0"
|
|
50
|
-
},
|
|
51
|
-
"scripts": {
|
|
52
|
-
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.core-dts.json && tsc -p tsconfig.build.json && tsup && rollup -c rollup.dts.config.mjs && esbuild src/cli/index.ts --bundle --platform=node --outfile=dist/cli.cjs --format=cjs --external:esbuild --external:jiti --banner:js=\"#!/usr/bin/env node\"",
|
|
53
|
-
"check-types": "tsc --noEmit",
|
|
54
|
-
"test:bundle": "pnpm build && vitest run --config vitest.bundle.config.ts"
|
|
54
|
+
"zod": "^4.1.0"
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|