@elevasis/sdk 0.5.11 → 0.5.12
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 +185 -218
- package/dist/index.d.ts +2 -3
- package/dist/index.js +5 -29
- package/dist/templates.js +167 -164
- package/dist/worker/index.js +79 -22
- package/package.json +1 -1
- package/reference/framework/project-structure.mdx +3 -13
- package/reference/getting-started/index.mdx +2 -3
package/dist/worker/index.js
CHANGED
|
@@ -4997,15 +4997,20 @@ function resolveNext(next, data) {
|
|
|
4997
4997
|
}
|
|
4998
4998
|
return next.default;
|
|
4999
4999
|
}
|
|
5000
|
+
function serializeNext(next) {
|
|
5001
|
+
if (next === null) return null;
|
|
5002
|
+
if (next.type === "linear") return { type: "linear", target: next.target };
|
|
5003
|
+
return { type: "conditional", routes: next.routes.map((r) => ({ target: r.target })), default: next.default };
|
|
5004
|
+
}
|
|
5000
5005
|
async function executeWorkflow(workflow, input, context) {
|
|
5001
5006
|
const logs = [];
|
|
5002
|
-
const postLog = (level, message) => {
|
|
5007
|
+
const postLog = (level, message, logContext) => {
|
|
5003
5008
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
5004
|
-
const entry = { level, message, timestamp };
|
|
5009
|
+
const entry = { level, message, timestamp, context: logContext };
|
|
5005
5010
|
logs.push(entry);
|
|
5006
5011
|
parentPort.postMessage({
|
|
5007
5012
|
type: "log",
|
|
5008
|
-
entry: { level, message, timestamp, executionId: context.executionId }
|
|
5013
|
+
entry: { level, message, timestamp, executionId: context.executionId, context: logContext }
|
|
5009
5014
|
});
|
|
5010
5015
|
};
|
|
5011
5016
|
const origLog = console.log;
|
|
@@ -5026,26 +5031,71 @@ async function executeWorkflow(workflow, input, context) {
|
|
|
5026
5031
|
if (!step) {
|
|
5027
5032
|
throw new Error(`Step '${stepId}' not found in workflow '${workflow.config.resourceId}'`);
|
|
5028
5033
|
}
|
|
5034
|
+
const stepStartTime = Date.now();
|
|
5029
5035
|
const stepInput = step.inputSchema.parse(currentData);
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
parentExecutionId: context.parentExecutionId,
|
|
5038
|
-
executionDepth: context.executionDepth,
|
|
5039
|
-
store: /* @__PURE__ */ new Map(),
|
|
5040
|
-
logger: {
|
|
5041
|
-
debug: (msg) => console.log(`[debug] ${msg}`),
|
|
5042
|
-
info: (msg) => console.log(`[info] ${msg}`),
|
|
5043
|
-
warn: (msg) => console.warn(`[warn] ${msg}`),
|
|
5044
|
-
error: (msg) => console.error(`[error] ${msg}`)
|
|
5045
|
-
}
|
|
5036
|
+
postLog("info", `Step '${step.name}' started`, {
|
|
5037
|
+
type: "workflow",
|
|
5038
|
+
contextType: "step-started",
|
|
5039
|
+
stepId: step.id,
|
|
5040
|
+
stepStatus: "started",
|
|
5041
|
+
input: stepInput,
|
|
5042
|
+
startTime: stepStartTime
|
|
5046
5043
|
});
|
|
5047
|
-
|
|
5048
|
-
|
|
5044
|
+
try {
|
|
5045
|
+
const rawOutput = await step.handler(stepInput, {
|
|
5046
|
+
executionId: context.executionId,
|
|
5047
|
+
organizationId: context.organizationId,
|
|
5048
|
+
organizationName: context.organizationName,
|
|
5049
|
+
resourceId: workflow.config.resourceId,
|
|
5050
|
+
sessionId: context.sessionId,
|
|
5051
|
+
sessionTurnNumber: context.sessionTurnNumber,
|
|
5052
|
+
parentExecutionId: context.parentExecutionId,
|
|
5053
|
+
executionDepth: context.executionDepth,
|
|
5054
|
+
store: /* @__PURE__ */ new Map(),
|
|
5055
|
+
logger: {
|
|
5056
|
+
debug: (msg) => console.log(`[debug] ${msg}`),
|
|
5057
|
+
info: (msg) => console.log(`[info] ${msg}`),
|
|
5058
|
+
warn: (msg) => console.warn(`[warn] ${msg}`),
|
|
5059
|
+
error: (msg) => console.error(`[error] ${msg}`)
|
|
5060
|
+
}
|
|
5061
|
+
});
|
|
5062
|
+
currentData = step.outputSchema.parse(rawOutput);
|
|
5063
|
+
const stepEndTime = Date.now();
|
|
5064
|
+
const nextStepId = resolveNext(step.next, currentData);
|
|
5065
|
+
postLog("info", `Step '${step.name}' completed (${stepEndTime - stepStartTime}ms)`, {
|
|
5066
|
+
type: "workflow",
|
|
5067
|
+
contextType: "step-completed",
|
|
5068
|
+
stepId: step.id,
|
|
5069
|
+
stepStatus: "completed",
|
|
5070
|
+
output: currentData,
|
|
5071
|
+
duration: stepEndTime - stepStartTime,
|
|
5072
|
+
isTerminal: nextStepId === null,
|
|
5073
|
+
startTime: stepStartTime,
|
|
5074
|
+
endTime: stepEndTime
|
|
5075
|
+
});
|
|
5076
|
+
if (step.next?.type === "conditional" && nextStepId !== null) {
|
|
5077
|
+
postLog("info", `Routing from '${step.name}' to '${nextStepId}'`, {
|
|
5078
|
+
type: "workflow",
|
|
5079
|
+
contextType: "conditional-route",
|
|
5080
|
+
stepId: step.id,
|
|
5081
|
+
target: nextStepId
|
|
5082
|
+
});
|
|
5083
|
+
}
|
|
5084
|
+
stepId = nextStepId;
|
|
5085
|
+
} catch (err) {
|
|
5086
|
+
const stepEndTime = Date.now();
|
|
5087
|
+
postLog("error", `Step '${step.name}' failed: ${String(err)}`, {
|
|
5088
|
+
type: "workflow",
|
|
5089
|
+
contextType: "step-failed",
|
|
5090
|
+
stepId: step.id,
|
|
5091
|
+
stepStatus: "failed",
|
|
5092
|
+
error: String(err),
|
|
5093
|
+
duration: stepEndTime - stepStartTime,
|
|
5094
|
+
startTime: stepStartTime,
|
|
5095
|
+
endTime: stepEndTime
|
|
5096
|
+
});
|
|
5097
|
+
throw err;
|
|
5098
|
+
}
|
|
5049
5099
|
}
|
|
5050
5100
|
if (workflow.contract.outputSchema) {
|
|
5051
5101
|
currentData = workflow.contract.outputSchema.parse(currentData);
|
|
@@ -5122,7 +5172,14 @@ function startWorker(org) {
|
|
|
5122
5172
|
status: w.config.status,
|
|
5123
5173
|
description: w.config.description,
|
|
5124
5174
|
version: w.config.version,
|
|
5125
|
-
domains: w.config.domains
|
|
5175
|
+
domains: w.config.domains,
|
|
5176
|
+
steps: Object.values(w.steps).map((step) => ({
|
|
5177
|
+
id: step.id,
|
|
5178
|
+
name: step.name,
|
|
5179
|
+
description: step.description,
|
|
5180
|
+
next: serializeNext(step.next)
|
|
5181
|
+
})),
|
|
5182
|
+
entryPoint: w.entryPoint
|
|
5126
5183
|
})),
|
|
5127
5184
|
agents: (org.agents ?? []).map((a) => ({
|
|
5128
5185
|
resourceId: a.config.resourceId,
|
package/package.json
CHANGED
|
@@ -156,16 +156,6 @@ Local utility scripts for tasks that do not run on the platform: database seeds,
|
|
|
156
156
|
|
|
157
157
|
Contains your `ELEVASIS_API_KEY`. This file is gitignored. Never commit it.
|
|
158
158
|
|
|
159
|
-
### `.env.example`
|
|
160
|
-
|
|
161
|
-
A git-safe template showing which variables are needed:
|
|
162
|
-
|
|
163
|
-
```
|
|
164
|
-
ELEVASIS_API_KEY=sk_your_key_here
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Commit this file so collaborators know what to configure.
|
|
168
|
-
|
|
169
159
|
### `.npmrc`
|
|
170
160
|
|
|
171
161
|
Sets `auto-install-peers = true`. The SDK uses Zod as a peer dependency, so this ensures Zod installs automatically.
|
|
@@ -269,11 +259,11 @@ A 7-lesson guided learning path adapted to the user's skill profile. Lessons cov
|
|
|
269
259
|
|
|
270
260
|
Not all scaffolded files participate in template updates. Files fall into two categories:
|
|
271
261
|
|
|
272
|
-
**SCAFFOLD_FILES total:
|
|
262
|
+
**SCAFFOLD_FILES total: 29**
|
|
273
263
|
|
|
274
|
-
**INIT_ONLY** (
|
|
264
|
+
**INIT_ONLY** (14 files) -- Written once during `elevasis-sdk init`, never updated by `elevasis-sdk update`:
|
|
275
265
|
- `package.json`, `pnpm-workspace.yaml`, `tsconfig.json`
|
|
276
|
-
- `.env`, `.
|
|
266
|
+
- `.env`, `.npmrc`
|
|
277
267
|
- `src/index.ts`, `src/operations/platform-status.ts`, `src/operations/index.ts`, `src/example/echo.ts`, `src/example/index.ts`, `src/shared/.gitkeep`
|
|
278
268
|
- `docs/index.mdx`, `docs/in-progress/.gitkeep`
|
|
279
269
|
- `.claude/rules/workspace-patterns.md`
|
|
@@ -18,7 +18,7 @@ pnpm install
|
|
|
18
18
|
|
|
19
19
|
`pnpm dlx` downloads the SDK temporarily to run `elevasis-sdk init`, which scaffolds your project with a working echo workflow, TypeScript config, and Claude Code integration. `pnpm install` then installs the SDK and its dependencies locally -- after that, all `elevasis-sdk` commands work directly via the scripts in `package.json` or `pnpm exec elevasis-sdk <command>`.
|
|
20
20
|
|
|
21
|
-
The command scaffolds
|
|
21
|
+
The command scaffolds 28 files covering configuration, source, documentation, and Claude Code integration:
|
|
22
22
|
|
|
23
23
|
```
|
|
24
24
|
my-project/
|
|
@@ -58,7 +58,6 @@ my-project/
|
|
|
58
58
|
├── tsconfig.json # TypeScript config (app-focused)
|
|
59
59
|
├── pnpm-workspace.yaml # Standalone project workspace
|
|
60
60
|
├── .env # API key only
|
|
61
|
-
├── .env.example # Git-safe template
|
|
62
61
|
├── .npmrc # auto-install-peers
|
|
63
62
|
└── .gitignore # Excludes worker temp file, claude files
|
|
64
63
|
```
|
|
@@ -81,7 +80,7 @@ Open `.env` and set your API key:
|
|
|
81
80
|
ELEVASIS_API_KEY=sk_your_key_here
|
|
82
81
|
```
|
|
83
82
|
|
|
84
|
-
The `.env
|
|
83
|
+
The `.env` file is gitignored -- never commit it.
|
|
85
84
|
|
|
86
85
|
**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.
|
|
87
86
|
|