fix: use optionalEnv with defaults for agent CLI paths in bundle entry
requireEnv causes silent worker crash when env vars are missing —
thread shows 0 steps with no error. Use optionalEnv + sensible defaults.
Also added pitfall guidance in skill author docs.
小橘 🍊
This commit is contained in:
+7
-1
@@ -1,7 +1,13 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://biomejs.dev/schemas/2.4.15/schema.json",
|
"$schema": "https://biomejs.dev/schemas/2.4.15/schema.json",
|
||||||
"files": {
|
"files": {
|
||||||
"includes": ["**", "!**/dist", "!**/node_modules", "!packages/workflow/workflow"]
|
"includes": [
|
||||||
|
"**",
|
||||||
|
"!**/dist",
|
||||||
|
"!**/node_modules",
|
||||||
|
"!packages/workflow/workflow",
|
||||||
|
"!xiaoju/scripts/bundle.ts"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
"assist": { "actions": { "source": { "organizeImports": "on" } } },
|
||||||
"formatter": {
|
"formatter": {
|
||||||
|
|||||||
@@ -301,6 +301,26 @@ function createLazyAdapter(): AdapterFn {
|
|||||||
}
|
}
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
|
### Agent CLI paths: use optionalEnv with defaults
|
||||||
|
|
||||||
|
When binding agent adapters (cursor-agent, hermes, etc.), **always use \`optionalEnv\` with a sensible default** — never \`requireEnv\`. The worker process may start without the expected env vars, causing a silent crash.
|
||||||
|
|
||||||
|
Discover the correct CLI path yourself (e.g. \`which cursor-agent\`, \`which hermes\`) and use it as the fallback:
|
||||||
|
|
||||||
|
\`\`\`typescript
|
||||||
|
// ❌ WRONG — worker crash if env var missing, thread silently fails with 0 steps
|
||||||
|
const adapter = createCursorAgent({
|
||||||
|
command: requireEnv("WORKFLOW_CURSOR_COMMAND", "set it"),
|
||||||
|
...
|
||||||
|
});
|
||||||
|
|
||||||
|
// ✅ CORRECT — env override with discovered default
|
||||||
|
const adapter = createCursorAgent({
|
||||||
|
command: optionalEnv("WORKFLOW_CURSOR_COMMAND") ?? "cursor-agent",
|
||||||
|
...
|
||||||
|
});
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
### Bundle import restrictions
|
### Bundle import restrictions
|
||||||
|
|
||||||
The bundle validator only allows these import specifiers:
|
The bundle validator only allows these import specifiers:
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
import { createCursorAgent } from "@uncaged/workflow-agent-cursor";
|
import { createCursorAgent } from "@uncaged/workflow-agent-cursor";
|
||||||
import { createHermesAgent } from "@uncaged/workflow-agent-hermes";
|
import { createHermesAgent } from "@uncaged/workflow-agent-hermes";
|
||||||
import { createWorkflow } from "@uncaged/workflow-runtime";
|
import { createWorkflow } from "@uncaged/workflow-runtime";
|
||||||
import { optionalEnv, requireEnv } from "@uncaged/workflow-util";
|
import { optionalEnv } from "@uncaged/workflow-util";
|
||||||
import { buildDevelopDescriptor, developWorkflowDefinition } from "./src/index.js";
|
import { buildDevelopDescriptor, developWorkflowDefinition } from "./src/index.js";
|
||||||
|
|
||||||
const cursorAdapter = createCursorAgent({
|
const cursorAdapter = createCursorAgent({
|
||||||
command: requireEnv("WORKFLOW_CURSOR_COMMAND", "set WORKFLOW_CURSOR_COMMAND (e.g. cursor-agent)"),
|
command: optionalEnv("WORKFLOW_CURSOR_COMMAND") ?? "cursor-agent",
|
||||||
model: optionalEnv("WORKFLOW_CURSOR_MODEL"),
|
model: optionalEnv("WORKFLOW_CURSOR_MODEL"),
|
||||||
timeout: optionalEnv("WORKFLOW_CURSOR_TIMEOUT")
|
timeout: optionalEnv("WORKFLOW_CURSOR_TIMEOUT")
|
||||||
? Number(optionalEnv("WORKFLOW_CURSOR_TIMEOUT"))
|
? Number(optionalEnv("WORKFLOW_CURSOR_TIMEOUT"))
|
||||||
@@ -20,7 +20,7 @@ const cursorAdapter = createCursorAgent({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const hermesAdapter = createHermesAgent({
|
const hermesAdapter = createHermesAgent({
|
||||||
command: requireEnv("WORKFLOW_HERMES_COMMAND", "set WORKFLOW_HERMES_COMMAND (absolute path to hermes CLI)"),
|
command: optionalEnv("WORKFLOW_HERMES_COMMAND") ?? "hermes",
|
||||||
model: optionalEnv("WORKFLOW_HERMES_MODEL"),
|
model: optionalEnv("WORKFLOW_HERMES_MODEL"),
|
||||||
timeout: optionalEnv("WORKFLOW_HERMES_TIMEOUT")
|
timeout: optionalEnv("WORKFLOW_HERMES_TIMEOUT")
|
||||||
? Number(optionalEnv("WORKFLOW_HERMES_TIMEOUT"))
|
? Number(optionalEnv("WORKFLOW_HERMES_TIMEOUT"))
|
||||||
|
|||||||
Reference in New Issue
Block a user