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