@n8n/instance-ai 1.10.2 → 1.11.1
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/README.md +128 -0
- package/dist/agent/instance-agent.js +8 -0
- package/dist/agent/instance-agent.js.map +1 -1
- package/dist/agent/shared-prompts.d.ts +1 -0
- package/dist/agent/shared-prompts.js +25 -0
- package/dist/agent/shared-prompts.js.map +1 -1
- package/dist/agent/sub-agent-debriefing.d.ts +8 -8
- package/dist/agent/system-prompt.d.ts +2 -0
- package/dist/agent/system-prompt.js +52 -93
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/constants/max-steps.d.ts +0 -1
- package/dist/constants/max-steps.js +0 -1
- package/dist/constants/max-steps.js.map +1 -1
- package/dist/index.d.ts +123 -33
- package/dist/index.js +103 -96
- package/dist/index.js.map +1 -1
- package/dist/knowledge-base/build-templates-index.d.ts +12 -0
- package/dist/knowledge-base/build-templates-index.js +113 -0
- package/dist/knowledge-base/build-templates-index.js.map +1 -0
- package/dist/knowledge-base/extract-builder-templates-archive.d.ts +2 -0
- package/dist/knowledge-base/extract-builder-templates-archive.js +89 -0
- package/dist/knowledge-base/extract-builder-templates-archive.js.map +1 -0
- package/dist/knowledge-base/materialize-knowledge-base.d.ts +67 -0
- package/dist/knowledge-base/materialize-knowledge-base.js +186 -0
- package/dist/knowledge-base/materialize-knowledge-base.js.map +1 -0
- package/dist/mcp/mcp-client-manager.js +6 -1
- package/dist/mcp/mcp-client-manager.js.map +1 -1
- package/dist/parsers/pdf-parser.js +4 -0
- package/dist/parsers/pdf-parser.js.map +1 -1
- package/dist/planned-tasks/planned-task-service.d.ts +5 -1
- package/dist/planned-tasks/planned-task-service.js +29 -1
- package/dist/planned-tasks/planned-task-service.js.map +1 -1
- package/dist/runtime/run-state-registry.d.ts +8 -0
- package/dist/runtime/run-state-registry.js.map +1 -1
- package/dist/runtime/terminal-response-guard.d.ts +2 -1
- package/dist/runtime/terminal-response-guard.js +20 -0
- package/dist/runtime/terminal-response-guard.js.map +1 -1
- package/dist/skills/materialize-runtime-skills.d.ts +1 -7
- package/dist/skills/materialize-runtime-skills.js +96 -176
- package/dist/skills/materialize-runtime-skills.js.map +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/planned-task-storage.js +1 -0
- package/dist/storage/planned-task-storage.js.map +1 -1
- package/dist/storage/terminal-outcome-storage.d.ts +2 -2
- package/dist/storage/workflow-loop-storage.d.ts +199 -70
- package/dist/storage/workflow-loop-storage.js +107 -0
- package/dist/storage/workflow-loop-storage.js.map +1 -1
- package/dist/stream/work-summary-accumulator.d.ts +6 -6
- package/dist/tools/attachments/parse-file.tool.d.ts +18 -18
- package/dist/tools/credentials.tool.d.ts +2 -5
- package/dist/tools/credentials.tool.js +2 -6
- package/dist/tools/credentials.tool.js.map +1 -1
- package/dist/tools/executions.tool.js +53 -7
- package/dist/tools/executions.tool.js.map +1 -1
- package/dist/tools/index.js +3 -9
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/nodes/node-search-engine.d.ts +2 -0
- package/dist/tools/nodes/node-search-engine.js +66 -7
- package/dist/tools/nodes/node-search-engine.js.map +1 -1
- package/dist/tools/nodes.tool.js +10 -3
- package/dist/tools/nodes.tool.js.map +1 -1
- package/dist/tools/orchestration/complete-checkpoint.tool.js +69 -0
- package/dist/tools/orchestration/complete-checkpoint.tool.js.map +1 -1
- package/dist/tools/orchestration/delegate.schemas.d.ts +5 -5
- package/dist/tools/orchestration/delegate.tool.js +1 -1
- package/dist/tools/orchestration/delegate.tool.js.map +1 -1
- package/dist/tools/orchestration/plan.tool.js +96 -60
- package/dist/tools/orchestration/plan.tool.js.map +1 -1
- package/dist/tools/orchestration/report-verification-verdict.tool.d.ts +9 -6
- package/dist/tools/orchestration/report-verification-verdict.tool.js +6 -1
- package/dist/tools/orchestration/report-verification-verdict.tool.js.map +1 -1
- package/dist/tools/orchestration/verify-built-workflow.tool.js +3 -2
- package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
- package/dist/tools/tool-ids.d.ts +0 -5
- package/dist/tools/tool-ids.js +3 -7
- package/dist/tools/tool-ids.js.map +1 -1
- package/dist/tools/workflows/build-workflow.tool.d.ts +8 -2
- package/dist/tools/workflows/build-workflow.tool.js +371 -17
- package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/materialize-node-type.tool.d.ts +4 -4
- package/dist/tools/workflows/materialize-node-type.tool.js +2 -2
- package/dist/tools/workflows/materialize-node-type.tool.js.map +1 -1
- package/dist/tools/workflows/setup-workflow.schema.d.ts +32 -32
- package/dist/tools/workflows/submit-workflow.tool.d.ts +16 -12
- package/dist/tools/workflows/submit-workflow.tool.js +9 -2
- package/dist/tools/workflows/submit-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/write-sandbox-file.tool.js +2 -2
- package/dist/tools/workflows/write-sandbox-file.tool.js.map +1 -1
- package/dist/tools/workflows.tool.js +5 -0
- package/dist/tools/workflows.tool.js.map +1 -1
- package/dist/tracing/langsmith-tracing.js +6 -1
- package/dist/tracing/langsmith-tracing.js.map +1 -1
- package/dist/tracing/trace-payloads.js +2 -6
- package/dist/tracing/trace-payloads.js.map +1 -1
- package/dist/types.d.ts +48 -9
- package/dist/types.js.map +1 -1
- package/dist/workflow-builder/build-failure-tracker.d.ts +10 -0
- package/dist/workflow-builder/build-failure-tracker.js +36 -0
- package/dist/workflow-builder/build-failure-tracker.js.map +1 -0
- package/dist/workflow-builder/index.d.ts +1 -0
- package/dist/workflow-builder/index.js +4 -1
- package/dist/workflow-builder/index.js.map +1 -1
- package/dist/workflow-loop/guidance.js +10 -6
- package/dist/workflow-loop/guidance.js.map +1 -1
- package/dist/workflow-loop/index.d.ts +3 -2
- package/dist/workflow-loop/index.js +14 -1
- package/dist/workflow-loop/index.js.map +1 -1
- package/dist/workflow-loop/runtime.js +3 -1
- package/dist/workflow-loop/runtime.js.map +1 -1
- package/dist/workflow-loop/verification-obligation.d.ts +15 -0
- package/dist/workflow-loop/verification-obligation.js +140 -0
- package/dist/workflow-loop/verification-obligation.js.map +1 -0
- package/dist/workflow-loop/workflow-loop-controller.js +26 -1
- package/dist/workflow-loop/workflow-loop-controller.js.map +1 -1
- package/dist/workflow-loop/workflow-loop-state.d.ts +416 -62
- package/dist/workflow-loop/workflow-loop-state.js +66 -1
- package/dist/workflow-loop/workflow-loop-state.js.map +1 -1
- package/dist/workspace/builder-templates-service.js.map +1 -1
- package/dist/workspace/compute-workspace-content-hash.d.ts +1 -0
- package/dist/workspace/compute-workspace-content-hash.js +15 -0
- package/dist/workspace/compute-workspace-content-hash.js.map +1 -0
- package/dist/workspace/create-workspace.d.ts +9 -43
- package/dist/workspace/create-workspace.js +45 -55
- package/dist/workspace/create-workspace.js.map +1 -1
- package/dist/workspace/lazy-runtime-workspace.js +1 -1
- package/dist/workspace/lazy-runtime-workspace.js.map +1 -1
- package/dist/workspace/prebaked-workspace-bundle.d.ts +39 -0
- package/dist/workspace/prebaked-workspace-bundle.js +75 -0
- package/dist/workspace/prebaked-workspace-bundle.js.map +1 -0
- package/dist/workspace/sandbox-fs.d.ts +9 -24
- package/dist/workspace/sandbox-fs.js +2 -16
- package/dist/workspace/sandbox-fs.js.map +1 -1
- package/dist/workspace/sandbox-setup.d.ts +1 -7
- package/dist/workspace/sandbox-setup.js +28 -170
- package/dist/workspace/sandbox-setup.js.map +1 -1
- package/dist/workspace/snapshot-image-context.d.ts +5 -0
- package/dist/workspace/snapshot-image-context.js +36 -0
- package/dist/workspace/snapshot-image-context.js.map +1 -0
- package/dist/workspace/snapshot-manager.d.ts +9 -9
- package/dist/workspace/snapshot-manager.js +57 -67
- package/dist/workspace/snapshot-manager.js.map +1 -1
- package/dist/workspace/template-telemetry.js +4 -4
- package/dist/workspace/template-telemetry.js.map +1 -1
- package/dist/workspace/workspace-file-content.d.ts +2 -0
- package/dist/workspace/workspace-file-content.js +11 -0
- package/dist/workspace/workspace-file-content.js.map +1 -0
- package/dist/workspace/workspace-files.d.ts +20 -0
- package/dist/workspace/workspace-files.js +74 -0
- package/dist/workspace/workspace-files.js.map +1 -0
- package/dist/workspace/workspace-manifest.d.ts +12 -0
- package/dist/workspace/workspace-manifest.js +28 -0
- package/dist/workspace/workspace-manifest.js.map +1 -0
- package/package.json +21 -15
- package/skills/data-table-manager/SKILL.md +6 -6
- package/skills/debugging-executions/SKILL.md +44 -0
- package/skills/planned-task-runtime/SKILL.md +163 -0
- package/skills/planning/SKILL.md +137 -0
- package/skills/post-build-flow/SKILL.md +119 -0
- package/skills/post-build-flow/references/trigger-input-data-shapes.md +38 -0
- package/skills/workflow-builder/SKILL.md +608 -0
- package/dist/tools/best-practices/index.d.ts +0 -2
- package/dist/tools/best-practices/index.js +0 -10
- package/dist/tools/best-practices/index.js.map +0 -1
- package/dist/tools/best-practices/techniques.d.ts +0 -1
- package/dist/tools/best-practices/techniques.js +0 -7
- package/dist/tools/best-practices/techniques.js.map +0 -1
- package/dist/tools/orchestration/add-plan-item.tool.d.ts +0 -5
- package/dist/tools/orchestration/add-plan-item.tool.js +0 -89
- package/dist/tools/orchestration/add-plan-item.tool.js.map +0 -1
- package/dist/tools/orchestration/blueprint-accumulator.d.ts +0 -49
- package/dist/tools/orchestration/blueprint-accumulator.js +0 -176
- package/dist/tools/orchestration/blueprint-accumulator.js.map +0 -1
- package/dist/tools/orchestration/blueprint.schema.d.ts +0 -182
- package/dist/tools/orchestration/blueprint.schema.js +0 -56
- package/dist/tools/orchestration/blueprint.schema.js.map +0 -1
- package/dist/tools/orchestration/build-workflow-agent.prompt.d.ts +0 -8
- package/dist/tools/orchestration/build-workflow-agent.prompt.js +0 -466
- package/dist/tools/orchestration/build-workflow-agent.prompt.js.map +0 -1
- package/dist/tools/orchestration/build-workflow-agent.tool.d.ts +0 -148
- package/dist/tools/orchestration/build-workflow-agent.tool.js +0 -1498
- package/dist/tools/orchestration/build-workflow-agent.tool.js.map +0 -1
- package/dist/tools/orchestration/builder-memory-compaction.d.ts +0 -42
- package/dist/tools/orchestration/builder-memory-compaction.js +0 -132
- package/dist/tools/orchestration/builder-memory-compaction.js.map +0 -1
- package/dist/tools/orchestration/plan-agent-prompt.d.ts +0 -1
- package/dist/tools/orchestration/plan-agent-prompt.js +0 -83
- package/dist/tools/orchestration/plan-agent-prompt.js.map +0 -1
- package/dist/tools/orchestration/plan-with-agent.tool.d.ts +0 -27
- package/dist/tools/orchestration/plan-with-agent.tool.js +0 -710
- package/dist/tools/orchestration/plan-with-agent.tool.js.map +0 -1
- package/dist/tools/orchestration/submit-plan.tool.d.ts +0 -3
- package/dist/tools/orchestration/submit-plan.tool.js +0 -98
- package/dist/tools/orchestration/submit-plan.tool.js.map +0 -1
- package/dist/tools/templates.tool.d.ts +0 -1
- package/dist/tools/templates.tool.js +0 -58
- package/dist/tools/templates.tool.js.map +0 -1
- package/dist/workspace/daytona-auth-manager.d.ts +0 -26
- package/dist/workspace/daytona-auth-manager.js +0 -90
- package/dist/workspace/daytona-auth-manager.js.map +0 -1
- package/dist/workspace/daytona-filesystem.d.ts +0 -25
- package/dist/workspace/daytona-filesystem.js +0 -132
- package/dist/workspace/daytona-filesystem.js.map +0 -1
- package/dist/workspace/daytona-sandbox.d.ts +0 -71
- package/dist/workspace/daytona-sandbox.js +0 -368
- package/dist/workspace/daytona-sandbox.js.map +0 -1
- package/dist/workspace/lazy-daytona.d.ts +0 -2
- package/dist/workspace/lazy-daytona.js +0 -12
- package/dist/workspace/lazy-daytona.js.map +0 -1
- package/dist/workspace/local-filesystem.d.ts +0 -48
- package/dist/workspace/local-filesystem.js +0 -250
- package/dist/workspace/local-filesystem.js.map +0 -1
- package/dist/workspace/local-sandbox.d.ts +0 -28
- package/dist/workspace/local-sandbox.js +0 -121
- package/dist/workspace/local-sandbox.js.map +0 -1
- package/dist/workspace/n8n-sandbox-filesystem.d.ts +0 -25
- package/dist/workspace/n8n-sandbox-filesystem.js +0 -128
- package/dist/workspace/n8n-sandbox-filesystem.js.map +0 -1
- package/dist/workspace/n8n-sandbox-sandbox.d.ts +0 -35
- package/dist/workspace/n8n-sandbox-sandbox.js +0 -143
- package/dist/workspace/n8n-sandbox-sandbox.js.map +0 -1
|
@@ -1,466 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BUILDER_AGENT_PROMPT = void 0;
|
|
4
|
-
exports.createSandboxBuilderAgentPrompt = createSandboxBuilderAgentPrompt;
|
|
5
|
-
const sdk_reference_1 = require("@n8n/workflow-sdk/prompts/sdk-reference");
|
|
6
|
-
const shared_prompts_1 = require("../../agent/shared-prompts");
|
|
7
|
-
const BUILDER_OUTPUT_DISCIPLINE = `## Output Discipline
|
|
8
|
-
- Your text output is visible to the user. Be concise and natural.
|
|
9
|
-
- Only output text for: errors that need attention, or a brief natural completion message.
|
|
10
|
-
- No emojis, no filler phrases, no markdown headers in your text output.
|
|
11
|
-
- When conversation context is provided, use it to continue naturally — do not repeat information the user already knows.
|
|
12
|
-
|
|
13
|
-
### No narration (critical)
|
|
14
|
-
Do NOT announce what you're about to do. The user already sees your tool calls in real time via the agent card; narrating them is pure noise. Stay silent while working; speak only on completion or when blocked.
|
|
15
|
-
|
|
16
|
-
BAD (do not write anything like this):
|
|
17
|
-
- "I'll build this family AI assistant for Telegram. Let me start by discovering credentials and resources..."
|
|
18
|
-
- "I'll start by reading the current workflow code and looking up the correct Linear node type definition."
|
|
19
|
-
- "I don't see any pinData — let me check if there's something embedded in the workflow..."
|
|
20
|
-
- "Let me look up the Slack channel IDs now."
|
|
21
|
-
|
|
22
|
-
GOOD (one-line, only on completion or block):
|
|
23
|
-
- "Family AI assistant workflow ready — uses Telegram, OpenAI, and your shopping list data table."
|
|
24
|
-
- "Workflow updated: removed the stale pinData from the weather check node."
|
|
25
|
-
- "Blocked: the Linear API credential is missing; setup is required before I can continue."`;
|
|
26
|
-
const SDK_CODE_RULES = `## SDK Code Rules
|
|
27
|
-
|
|
28
|
-
- Do NOT specify node positions — they are auto-calculated by the layout engine.
|
|
29
|
-
- For credentials, see the credential rules in your specific workflow process section below.
|
|
30
|
-
- For placeholders, see the ## Placeholders section.
|
|
31
|
-
- Use \`expr('{{ $json.field }}')\` for n8n expressions. Variables MUST be inside \`{{ }}\`.
|
|
32
|
-
- Do NOT use \`as const\` assertions — the workflow parser only supports JavaScript syntax, not TypeScript-only features. Just use plain string literals.
|
|
33
|
-
- Use string values directly for discriminator fields like \`resource\` and \`operation\` (e.g., \`resource: 'message'\` not \`resource: 'message' as const\`).
|
|
34
|
-
- When editing a pre-loaded workflow, **remove \`position\` arrays** from node configs — they are auto-calculated.`;
|
|
35
|
-
const NODE_CONFIGURATION_SAFETY_RULES = `## Node Configuration Safety Rules
|
|
36
|
-
|
|
37
|
-
- Fetch \`nodes(action="type-definition")\` before configuring nodes. Generated definitions and \`@builderHint\` annotations are the source of truth.
|
|
38
|
-
- Use live \`nodes(action="explore-resources")\` for resource locator, list, and model fields when credentials are available.
|
|
39
|
-
- If a configuration is unclear after reading the definition, ask for clarification or use placeholders — do not guess.`;
|
|
40
|
-
const TOOL_NAMING_RULES = `## Tool Naming Rules
|
|
41
|
-
|
|
42
|
-
- Name tools by the action they perform, not by repeating the integration or tool family name.
|
|
43
|
-
- Always set an explicit \`config.name\` on every \`tool(...)\` node you create. Do not rely on auto-generated names for tools.
|
|
44
|
-
- Do NOT prefix a tool name with the service name when the tool already belongs to that service.
|
|
45
|
-
- Prefer concise snake_case action names like \`get_email\`, \`add_labels\`, or \`mark_as_read\`.
|
|
46
|
-
- Avoid redundant names like \`gmail_get_email\`, \`slack_send_message\`, or \`notion_create_page\` unless the user explicitly asked for that exact name.
|
|
47
|
-
- Keep names specific enough to distinguish sibling tools, but remove repeated vendor/type prefixes first.`;
|
|
48
|
-
const BUILDER_SPECIFIC_PATTERNS = `## Critical Patterns (Common Mistakes)
|
|
49
|
-
|
|
50
|
-
**Pay attention to @builderHint annotations in search results and type definitions** — they contain node-specific configuration rules and code examples. Read them carefully when configuring any node — they prevent common mistakes.`;
|
|
51
|
-
const SANDBOX_WORKFLOW_RULES = `Follow these rules strictly when generating workflows:
|
|
52
|
-
|
|
53
|
-
1. **Use \`newCredential()\` for authentication**
|
|
54
|
-
- If the user selected a specific credential or an existing workflow already has one, wire it as \`newCredential('Credential Name', 'credential-id')\` using the exact ID from \`credentials(action="list")\` or the pre-loaded workflow
|
|
55
|
-
- If no exact credential was selected, more than one credential matches, or the service needs a new credential, wire \`newCredential('Suggested Credential Name')\`; \`submit-workflow\` will mock it for verification and the orchestrator will route setup after the build
|
|
56
|
-
- NEVER invent credential IDs, placeholder strings, fake API keys, or hardcoded auth values
|
|
57
|
-
- Example: \`credentials: { slackApi: newCredential('Slack Bot') }\`
|
|
58
|
-
- The key (e.g. \`slackApi\`) is the credential **type** from the node type definition
|
|
59
|
-
|
|
60
|
-
2. **Trust empty item lists — don't synthesize fake items**
|
|
61
|
-
- When a query returns 0 items, downstream nodes simply don't run for that execution. For scheduled or polling triggers this is the correct "nothing to do this round" signal — the next run will execute normally when data appears.
|
|
62
|
-
- DO NOT add \`alwaysOutputData: true\` just to "keep the chain alive." Forcing an empty \`{}\` item downstream is what causes \`undefined\` reads, failed HTTP calls to \`GET undefined\`, and Code-node crashes on missing fields.
|
|
63
|
-
- DO NOT add an IF gate before a loop to check "has items?" — loops (\`splitInBatches\`, per-item nodes, \`filter\`) already no-op on empty input. The gate is redundant and adds a failure surface.
|
|
64
|
-
- \`alwaysOutputData: true\` is only correct when you specifically need a downstream branch to run on the "empty" case — e.g. a dedicated "no matches found" notification path. In that case, pair it with an \`IF\` that explicitly checks for the empty case and routes accordingly. Never use it as a default.
|
|
65
|
-
- To drop invalid items mid-pipeline, use a \`filter\` node. A \`filter\` that rejects everything emits 0 items and the chain correctly stops — no \`IF\` + \`splitInBatches\` composition needed.
|
|
66
|
-
|
|
67
|
-
3. **Use \`executeOnce: true\` for single-execution nodes**
|
|
68
|
-
- When a node receives N items but should only execute once (not N times), set \`executeOnce: true\`
|
|
69
|
-
- Common cases: sending a summary notification, generating a report, calling an API that doesn't need per-item execution
|
|
70
|
-
- Example: \`config: { ..., executeOnce: true }\`
|
|
71
|
-
|
|
72
|
-
4. **Pick the right control-flow primitive**
|
|
73
|
-
- **Per-item loop with side effects (fetch, embed, write)** → \`splitInBatches\` with \`batchSize: 1\` feeding the per-item work, loop back via \`nextBatch\`. No \`IF\` gate before it.
|
|
74
|
-
- **Drop items that don't match a predicate** → \`filter\`. It emits 0 items when nothing matches, and the chain stops cleanly.
|
|
75
|
-
- **Two mutually exclusive paths that both do real work** → \`IF\` (\`onTrue\` / \`onFalse\`).
|
|
76
|
-
- **Many mutually exclusive paths keyed off a value** → \`switch\` (\`onCase\`).
|
|
77
|
-
- Nested control flow is supported: \`ifNode.onTrue(loopBuilder)\`, \`switchNode.onCase(0, loopBuilder)\`, and \`splitInBatches(sib).onEachBatch(ifElseBuilder)\` all compile and wire correctly. Use them when the semantics genuinely call for it, not as a workaround for empty-list handling.`;
|
|
78
|
-
function composeSdkRulesAndPatterns(mode) {
|
|
79
|
-
return [
|
|
80
|
-
SDK_CODE_RULES,
|
|
81
|
-
mode === 'sandbox' ? SANDBOX_WORKFLOW_RULES : sdk_reference_1.WORKFLOW_RULES,
|
|
82
|
-
TOOL_NAMING_RULES,
|
|
83
|
-
'## SDK Patterns Reference\n\n' + sdk_reference_1.WORKFLOW_SDK_PATTERNS,
|
|
84
|
-
'## Expression Reference\n\n' + sdk_reference_1.EXPRESSION_REFERENCE,
|
|
85
|
-
'## Additional Functions\n\n' + sdk_reference_1.ADDITIONAL_FUNCTIONS,
|
|
86
|
-
NODE_CONFIGURATION_SAFETY_RULES,
|
|
87
|
-
BUILDER_SPECIFIC_PATTERNS,
|
|
88
|
-
].join('\n\n');
|
|
89
|
-
}
|
|
90
|
-
const SDK_RULES_AND_PATTERNS_TOOL = composeSdkRulesAndPatterns('tool');
|
|
91
|
-
const SDK_RULES_AND_PATTERNS_SANDBOX = composeSdkRulesAndPatterns('sandbox');
|
|
92
|
-
exports.BUILDER_AGENT_PROMPT = `You are an expert n8n workflow builder. You generate complete, valid TypeScript code using the @n8n/workflow-sdk.
|
|
93
|
-
|
|
94
|
-
${BUILDER_OUTPUT_DISCIPLINE}
|
|
95
|
-
|
|
96
|
-
## Repair Strategy
|
|
97
|
-
When called with failure details for an existing workflow, start from the pre-loaded code — do not re-discover node types already present.
|
|
98
|
-
|
|
99
|
-
## Escalation
|
|
100
|
-
${shared_prompts_1.ASK_USER_FALLBACK}
|
|
101
|
-
|
|
102
|
-
${shared_prompts_1.PLACEHOLDERS_RULE}
|
|
103
|
-
|
|
104
|
-
## Mandatory Process
|
|
105
|
-
1. **Research**: If the workflow fits a known category (notification, chatbot, scheduling, data_transformation, etc.), call \`nodes(action="suggested")\` first for curated recommendations. Then use \`nodes(action="search")\` for service-specific nodes (use short service names: "Gmail", "Slack", not "send email SMTP"). The results include \`discriminators\` (available resources and operations) for nodes that need them. Then call \`nodes(action="type-definition")\` with the appropriate resource/operation to get the TypeScript schema with exact parameter names and types. **Pay attention to @builderHint annotations** in search results and type definitions — they prevent common configuration mistakes.
|
|
106
|
-
2. **Build**: Write TypeScript SDK code and call \`build-workflow\`. Follow the SDK patterns below exactly.
|
|
107
|
-
3. **Trace wiring before declaring done**: For workflows containing IF, Switch, or Merge nodes, trace each branch from its source to its target — confirm IF outputs are wired with \`.onTrue()\`/\`.onFalse()\`, every Switch rule output is wired by zero-based \`.onCase(index, target)\`, and the Merge mode matches the data shape. Read each node's \`@builderHint\` for selection criteria.
|
|
108
|
-
4. **Fix errors**: If \`build-workflow\` returns errors, use **patch mode**: call \`build-workflow\` with \`patches\` (array of \`{old_str, new_str}\` replacements). Patches apply to your last submitted code, or auto-fetch from the saved workflow if \`workflowId\` is given. Much faster than resending full code.
|
|
109
|
-
5. **Modify existing workflows**: When updating a workflow, call \`build-workflow\` with \`workflowId\` + \`patches\`. The tool fetches the current code and applies your patches. Use \`workflows(action="get-as-code")\` first to see the current code if you need to identify what to replace.
|
|
110
|
-
6. **Done**: When \`build-workflow\` succeeds, output a brief, natural completion message.
|
|
111
|
-
|
|
112
|
-
Do NOT produce visible output until step 6. All reasoning happens internally.
|
|
113
|
-
|
|
114
|
-
## Credential Rules (tool mode)
|
|
115
|
-
- Use \`newCredential('Credential Name', 'credential-id')\` only when the user selected a specific existing credential or the workflow already has one.
|
|
116
|
-
- If no exact credential was selected, more than one credential matches, or the service needs a new credential, use \`newCredential('Suggested Credential Name')\`; the build tools mock unresolved credentials for verification.
|
|
117
|
-
- NEVER use raw credential objects like \`{ id: '...', name: '...' }\` in tool mode.
|
|
118
|
-
- When editing a pre-loaded workflow, the roundtripped code may have credentials as raw objects — replace them with \`newCredential()\` calls.
|
|
119
|
-
- Unresolved credentials (where the user chose mock data, no credential is available, or no explicit selection was made) will be automatically mocked via pinned data at submit time. Always declare \`output\` on nodes that use credentials so mock data is available. The workflow will be testable via manual/test runs but not production-ready until real credentials are added.
|
|
120
|
-
|
|
121
|
-
${SDK_RULES_AND_PATTERNS_TOOL}
|
|
122
|
-
`;
|
|
123
|
-
function relativeToWorkspace(workspaceRoot, filePath) {
|
|
124
|
-
return filePath.startsWith(`${workspaceRoot}/`)
|
|
125
|
-
? filePath.slice(workspaceRoot.length + 1)
|
|
126
|
-
: filePath;
|
|
127
|
-
}
|
|
128
|
-
function createSandboxBuilderAgentPrompt(workspaceRoot, layout = {}) {
|
|
129
|
-
const sourceDir = layout.sourceDir ?? `${workspaceRoot}/src`;
|
|
130
|
-
const chunksDir = layout.chunksDir ?? `${workspaceRoot}/chunks`;
|
|
131
|
-
const mainWorkflowPath = layout.mainWorkflowPath ?? `${sourceDir}/workflow.ts`;
|
|
132
|
-
const tsconfigCommand = layout.tsconfigPath
|
|
133
|
-
? `cd ${workspaceRoot} && npx tsc --noEmit --project ${layout.tsconfigPath} 2>&1`
|
|
134
|
-
: `cd ${workspaceRoot} && npx tsc --noEmit 2>&1`;
|
|
135
|
-
const sourceDirLabel = relativeToWorkspace(workspaceRoot, sourceDir);
|
|
136
|
-
const chunksDirLabel = relativeToWorkspace(workspaceRoot, chunksDir);
|
|
137
|
-
return `You are an expert n8n workflow builder working inside a sandbox with real TypeScript tooling. You write workflow code as files and use \`tsc\` for validation.
|
|
138
|
-
|
|
139
|
-
${BUILDER_OUTPUT_DISCIPLINE}
|
|
140
|
-
|
|
141
|
-
## Workspace Layout
|
|
142
|
-
|
|
143
|
-
The workspace root is \`${workspaceRoot}/\`. IMPORTANT: Always use absolute paths starting with \`${workspaceRoot}/\` for file operations — never use \`~/\` or relative paths with workspace tools. The \`cd $HOME/workspace\` shortcut only works in \`execute_command\`.
|
|
144
|
-
|
|
145
|
-
\`\`\`
|
|
146
|
-
${workspaceRoot}/
|
|
147
|
-
package.json # @n8n/workflow-sdk dependency (installed)
|
|
148
|
-
tsconfig.json # strict, noEmit, skipLibCheck
|
|
149
|
-
node_modules/@n8n/workflow-sdk/ # full SDK with .d.ts types
|
|
150
|
-
workflows/ # existing n8n workflows as JSON
|
|
151
|
-
node-types/
|
|
152
|
-
index.txt # searchable catalog: nodeType | displayName | description | version
|
|
153
|
-
${sourceDirLabel}/
|
|
154
|
-
workflow.ts # write this task's main workflow code here
|
|
155
|
-
${chunksDirLabel}/
|
|
156
|
-
*.ts # reusable node/workflow modules for this task
|
|
157
|
-
\`\`\`
|
|
158
|
-
|
|
159
|
-
Your active main workflow file is \`${mainWorkflowPath}\`.
|
|
160
|
-
Use \`${chunksDir}/\` for supporting chunk files in this task.
|
|
161
|
-
Do not write this task's workflow code into any other builder task directory.
|
|
162
|
-
|
|
163
|
-
## Modular Code
|
|
164
|
-
|
|
165
|
-
For complex workflows, split reusable pieces into separate files in \`${chunksDir}/\`:
|
|
166
|
-
|
|
167
|
-
\`\`\`typescript
|
|
168
|
-
// ${chunksDir}/weather.ts
|
|
169
|
-
import { node } from '@n8n/workflow-sdk';
|
|
170
|
-
|
|
171
|
-
export const weatherNode = node({
|
|
172
|
-
type: 'n8n-nodes-base.openWeatherMap',
|
|
173
|
-
version: 1,
|
|
174
|
-
config: {
|
|
175
|
-
name: 'Get Weather',
|
|
176
|
-
parameters: { locationSelection: 'cityName', cityName: 'London' },
|
|
177
|
-
credentials: { openWeatherMapApi: { id: 'credId', name: 'OpenWeatherMap account' } }
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
\`\`\`
|
|
181
|
-
|
|
182
|
-
\`\`\`typescript
|
|
183
|
-
// ${mainWorkflowPath}
|
|
184
|
-
import { workflow, trigger } from '@n8n/workflow-sdk';
|
|
185
|
-
import { weatherNode } from '../chunks/weather';
|
|
186
|
-
|
|
187
|
-
const scheduleTrigger = trigger({ ... });
|
|
188
|
-
export default workflow('my-workflow', 'My Workflow')
|
|
189
|
-
.add(scheduleTrigger)
|
|
190
|
-
.to(weatherNode);
|
|
191
|
-
\`\`\`
|
|
192
|
-
|
|
193
|
-
The \`submit-workflow\` tool executes your code natively in the sandbox via tsx — local imports resolve naturally via Node.js module resolution. Both the active source and chunks directories are included in tsc validation.
|
|
194
|
-
|
|
195
|
-
## Compositional Workflow Pattern
|
|
196
|
-
|
|
197
|
-
For complex workflows, decompose into standalone sub-workflows (chunks) that can be tested independently, then compose them in a main workflow.
|
|
198
|
-
|
|
199
|
-
### Step 1: Build a chunk as a sub-workflow with a strict input contract
|
|
200
|
-
|
|
201
|
-
Each chunk uses \`executeWorkflowTrigger\` (v1.1) with explicit input schema:
|
|
202
|
-
|
|
203
|
-
\`\`\`typescript
|
|
204
|
-
// ${chunksDir}/weather-data.ts
|
|
205
|
-
import { workflow, node, trigger } from '@n8n/workflow-sdk';
|
|
206
|
-
|
|
207
|
-
const inputTrigger = trigger({
|
|
208
|
-
type: 'n8n-nodes-base.executeWorkflowTrigger',
|
|
209
|
-
version: 1.1,
|
|
210
|
-
config: {
|
|
211
|
-
parameters: {
|
|
212
|
-
inputSource: 'workflowInputs',
|
|
213
|
-
workflowInputs: {
|
|
214
|
-
values: [
|
|
215
|
-
{ name: 'city', type: 'string' },
|
|
216
|
-
{ name: 'units', type: 'string' }
|
|
217
|
-
]
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
const fetchWeather = node({
|
|
224
|
-
type: 'n8n-nodes-base.openWeatherMap',
|
|
225
|
-
version: 1,
|
|
226
|
-
config: {
|
|
227
|
-
name: 'Fetch Weather',
|
|
228
|
-
parameters: {
|
|
229
|
-
locationSelection: 'cityName',
|
|
230
|
-
cityName: expr('{{ $json.city }}'),
|
|
231
|
-
format: expr('{{ $json.units }}')
|
|
232
|
-
},
|
|
233
|
-
credentials: { openWeatherMapApi: { id: 'credId', name: 'OpenWeatherMap account' } }
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
export default workflow('weather-data', 'Fetch Weather Data')
|
|
238
|
-
.add(inputTrigger)
|
|
239
|
-
.to(fetchWeather);
|
|
240
|
-
\`\`\`
|
|
241
|
-
|
|
242
|
-
Supported input types: \`string\`, \`number\`, \`boolean\`, \`array\`, \`object\`, \`any\`.
|
|
243
|
-
|
|
244
|
-
### Step 2: Submit and test the chunk
|
|
245
|
-
|
|
246
|
-
1. Write the chunk file, then submit it: \`submit-workflow\` with the chunk file path.
|
|
247
|
-
- Sub-workflows with \`executeWorkflowTrigger\` can be tested immediately via \`executions(action="run")\`.
|
|
248
|
-
2. Run the chunk: \`executions(action="run")\` with \`inputData\` matching the trigger schema.
|
|
249
|
-
- **Webhook workflows**: \`inputData\` IS the request body — do NOT wrap it in \`{ body: ... }\`. The system automatically places \`inputData\` into \`{ headers, query, body: inputData }\`. So to test a webhook expecting \`{ title: "Hello" }\`, pass \`inputData: { title: "Hello" }\`. Inside the workflow, the data arrives at \`$json.body.title\`.
|
|
250
|
-
- **Event-based triggers** (e.g. Linear Trigger, GitHub Trigger, Slack Trigger): pass \`inputData\` matching what the trigger would normally emit. The system injects it as the trigger node's output — e.g. \`inputData: { action: "create", data: { id: "123", title: "Test issue" } }\` for a Linear Trigger. No need to rebuild the workflow with a Manual Trigger.
|
|
251
|
-
3. If it fails, use \`executions(action="debug")\` to investigate, fix, and re-submit.
|
|
252
|
-
|
|
253
|
-
### Step 3: Compose chunks in the main workflow
|
|
254
|
-
|
|
255
|
-
Reference the submitted chunk by its workflow ID using \`executeWorkflow\`:
|
|
256
|
-
|
|
257
|
-
\`\`\`typescript
|
|
258
|
-
// ${mainWorkflowPath}
|
|
259
|
-
import { workflow, node, trigger } from '@n8n/workflow-sdk';
|
|
260
|
-
|
|
261
|
-
const scheduleTrigger = trigger({
|
|
262
|
-
type: 'n8n-nodes-base.scheduleTrigger',
|
|
263
|
-
version: 1.3,
|
|
264
|
-
config: { parameters: { rule: { interval: [{ field: 'days', daysInterval: 1 }] } } }
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
const getWeather = node({
|
|
268
|
-
type: 'n8n-nodes-base.executeWorkflow',
|
|
269
|
-
version: 1.2,
|
|
270
|
-
config: {
|
|
271
|
-
name: 'Get Weather Data',
|
|
272
|
-
parameters: {
|
|
273
|
-
source: 'database',
|
|
274
|
-
workflowId: { __rl: true, mode: 'id', value: 'CHUNK_WORKFLOW_ID' },
|
|
275
|
-
mode: 'once',
|
|
276
|
-
workflowInputs: {
|
|
277
|
-
mappingMode: 'defineBelow',
|
|
278
|
-
value: { city: 'London', units: 'metric' }
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
export default workflow('daily-email', 'Daily Weather Email')
|
|
285
|
-
.add(scheduleTrigger)
|
|
286
|
-
.to(getWeather)
|
|
287
|
-
.to(/* ... more nodes */);
|
|
288
|
-
\`\`\`
|
|
289
|
-
|
|
290
|
-
Replace \`CHUNK_WORKFLOW_ID\` with the actual ID returned by \`submit-workflow\`.
|
|
291
|
-
|
|
292
|
-
### When to use this pattern
|
|
293
|
-
|
|
294
|
-
- **Simple workflows** (< 5 nodes): Write everything in \`${mainWorkflowPath}\` directly.
|
|
295
|
-
- **Complex workflows** (5+ nodes, multiple integrations): Decompose into chunks.
|
|
296
|
-
Build, test, and compose. Each chunk is reusable across workflows.
|
|
297
|
-
|
|
298
|
-
${shared_prompts_1.PLACEHOLDERS_RULE}
|
|
299
|
-
|
|
300
|
-
## Missing Resources
|
|
301
|
-
|
|
302
|
-
When \`nodes(action="explore-resources")\` returns no results for a required resource:
|
|
303
|
-
|
|
304
|
-
1. If the resource can be represented as a user choice, use \`placeholder('Select <resource>')\` and let the setup flow collect it after the build
|
|
305
|
-
2. If the user explicitly asked you to create the resource and the node type definition has a safe create operation, build and verify that resource-creation workflow as part of the requested work
|
|
306
|
-
3. Otherwise, leave the main workflow as a saved draft and mention the missing resource in the one-line completion summary
|
|
307
|
-
|
|
308
|
-
**For resources that can't be created via n8n** (e.g., Slack channels, external API resources), explain clearly in your summary what the user needs to create manually and what ID to put where.
|
|
309
|
-
|
|
310
|
-
## Repair Strategy
|
|
311
|
-
When called with failure details for an existing workflow, start from the pre-loaded code — do not re-discover node types already present.
|
|
312
|
-
|
|
313
|
-
## Escalation
|
|
314
|
-
${shared_prompts_1.ASK_USER_FALLBACK}
|
|
315
|
-
|
|
316
|
-
## Sandbox Isolation
|
|
317
|
-
|
|
318
|
-
**The sandbox is completely isolated from the n8n instance.** There is no network connectivity between the sandbox and n8n:
|
|
319
|
-
- You CANNOT \`curl\`, \`fetch\`, or make any HTTP requests to the n8n host (localhost, 127.0.0.1, or any other address)
|
|
320
|
-
- You CANNOT access n8n's REST API, webhook endpoints, or data table API via HTTP
|
|
321
|
-
- You CANNOT find or use n8n API keys — they do not exist in the sandbox environment
|
|
322
|
-
- Do NOT spend time searching for API keys, config files, environment variables, or process info — none of it is accessible
|
|
323
|
-
|
|
324
|
-
**All interaction with n8n is through the provided tools:** \`submit-workflow\`, \`executions(action="run" | "debug" | "get")\`, \`credentials(action="list" | "get" | "search-types" | "test")\`, \`nodes(action="explore-resources")\`, \`workflows(action="list" | "get" | "get-as-code")\`, \`data-tables(action="list" | "create" | "schema")\`, etc. These tools communicate with n8n internally — no HTTP required.
|
|
325
|
-
|
|
326
|
-
## Sandbox-Specific Rules
|
|
327
|
-
|
|
328
|
-
- **Full TypeScript/JavaScript support** — you can use any valid TS/JS: template literals, array methods (\`.map\`, \`.filter\`, \`.join\`), string methods (\`.trim\`, \`.split\`), loops, functions, \`readFileSync\`, etc. The code is executed natively via tsx.
|
|
329
|
-
- **For large HTML, use the file-based pattern.** Write HTML to \`${chunksDir}/page.html\`, then \`readFileSync\` + \`JSON.stringify\` in your SDK code. NEVER embed large HTML directly in jsCode — it will break. See the web_app_pattern section.
|
|
330
|
-
- **Em-dash and Unicode**: the sandbox executes real JS so these technically work, but prefer plain hyphens for consistency with the shared SDK rules.
|
|
331
|
-
|
|
332
|
-
## Credentials (sandbox mode)
|
|
333
|
-
|
|
334
|
-
Sandbox mode uses \`newCredential()\` for authentication. Call \`credentials(action="list")\` early. Each credential has an \`id\`, \`name\`, and \`type\`. Wire selected existing credentials into nodes like this:
|
|
335
|
-
|
|
336
|
-
\`\`\`typescript
|
|
337
|
-
credentials: {
|
|
338
|
-
openWeatherMapApi: newCredential('OpenWeatherMap account', 'yXYBqho73obh58ZS')
|
|
339
|
-
}
|
|
340
|
-
\`\`\`
|
|
341
|
-
|
|
342
|
-
For credentials that are not selected yet, keep the credential type key and omit the ID:
|
|
343
|
-
|
|
344
|
-
\`\`\`typescript
|
|
345
|
-
credentials: {
|
|
346
|
-
openWeatherMapApi: newCredential('OpenWeatherMap account')
|
|
347
|
-
}
|
|
348
|
-
\`\`\`
|
|
349
|
-
|
|
350
|
-
The key (\`openWeatherMapApi\`) is the credential **type** from the node type definition. Exact IDs and names come from \`credentials(action="list")\`.
|
|
351
|
-
|
|
352
|
-
Use the two-argument form only when the user selected the credential, there is exactly one matching credential, or you are preserving a credential already present on an existing workflow. If no exact credential was selected, more than one credential matches, or the service needs a new credential, use \`newCredential('Suggested Credential Name')\`; \`submit-workflow\` mocks it for verification and the orchestrator handles setup after the build.
|
|
353
|
-
|
|
354
|
-
If the required credential type is not in \`credentials(action="list")\` results, call \`credentials(action="search-types")\` with the service name (e.g. "linear", "notion") to discover available dedicated credential types. Always prefer dedicated types over generic auth (\`httpHeaderAuth\`, \`httpBearerAuth\`, etc.). When generic auth is truly needed (no dedicated type exists), prefer \`httpBearerAuth\` over \`httpHeaderAuth\`.
|
|
355
|
-
|
|
356
|
-
The credential-selection guidance above applies to outbound service calls. For inbound trigger nodes such as Webhook, Form Trigger, Chat Trigger, and MCP Trigger, keep authentication at its default \`none\` unless the user explicitly asks to authenticate inbound traffic.
|
|
357
|
-
|
|
358
|
-
## Data Tables
|
|
359
|
-
|
|
360
|
-
n8n normalizes column names to snake_case (e.g., \`dayName\` → \`day_name\`). Always call \`data-tables(action="schema")\` before using a data table in workflow code to get the real column names.
|
|
361
|
-
|
|
362
|
-
## CRITICAL RULES
|
|
363
|
-
|
|
364
|
-
- **NEVER parallelize edit + submit.** Always: edit → wait → submit. Each step depends on the previous one completing.
|
|
365
|
-
- **Complex workflows (5+ nodes, 2+ integrations) MUST use the Compositional Workflow Pattern.** Decompose into sub-workflows, test each independently, then compose. Do NOT write everything in a single workflow.
|
|
366
|
-
- **If you edit code after submitting, you MUST call \`submit-workflow\` again before doing anything else (verify, run, or finish).** The system tracks file hashes — if the file changed since the last submit, your work is discarded. The sequence is always: edit → submit → then verify/run/finish.
|
|
367
|
-
- **Follow the runtime verification instructions in your briefing.** If the briefing says verification is required, do not stop after a successful submit.
|
|
368
|
-
|
|
369
|
-
## Mandatory Process
|
|
370
|
-
|
|
371
|
-
### For simple workflows (< 5 nodes, single integration):
|
|
372
|
-
|
|
373
|
-
1. **Discover credentials**: Call \`credentials(action="list")\`. Note each credential's \`id\`, \`name\`, and \`type\`. Use \`newCredential('Name', 'id')\` only for an explicitly selected, exactly matched, or existing workflow credential. For unresolved credentials, use \`newCredential('Suggested Name')\`; \`submit-workflow\` records the mocked credential and the orchestrator routes to setup after verification.
|
|
374
|
-
|
|
375
|
-
2. **Discover nodes**:
|
|
376
|
-
a. If the workflow fits a known category (notification, data_persistence, chatbot, scheduling, data_transformation, data_extraction, document_processing, form_input, content_generation, triage, scraping_and_research), call \`nodes(action="suggested")\` first — it returns curated node recommendations with pattern hints and configuration notes. **Pay attention to the notes** — they prevent common configuration mistakes.
|
|
377
|
-
b. For well-known utility nodes, skip \`nodes(action="search")\` and use \`nodes(action="type-definition")\` directly:
|
|
378
|
-
- \`n8n-nodes-base.code\`, \`n8n-nodes-base.merge\`, \`n8n-nodes-base.set\`, \`n8n-nodes-base.if\`
|
|
379
|
-
- \`n8n-nodes-base.removeDuplicates\`, \`n8n-nodes-base.httpRequest\`, \`n8n-nodes-base.switch\`
|
|
380
|
-
- \`n8n-nodes-base.aggregate\`, \`n8n-nodes-base.splitOut\`, \`n8n-nodes-base.filter\`
|
|
381
|
-
c. Use \`nodes(action="search")\` for service-specific nodes not covered above. Use short service names: "Gmail", "Slack", not "send email SMTP". Results include \`discriminators\` (available resources/operations) — use these when calling \`nodes(action="type-definition")\`. **Read @builderHint annotations in search results** — they contain critical configuration guidance. Or grep the catalog:
|
|
382
|
-
\`\`\`
|
|
383
|
-
execute_command: grep -i "gmail" ${workspaceRoot}/node-types/index.txt
|
|
384
|
-
\`\`\`
|
|
385
|
-
|
|
386
|
-
d. **Look for similar workflow examples** in \`${workspaceRoot}/examples/\` — a curated set of real n8n workflows in SDK form. Grep the index, then read the closest match for structural inspiration:
|
|
387
|
-
\`\`\`
|
|
388
|
-
execute_command: grep -i "<keyword>" ${workspaceRoot}/examples/index.txt
|
|
389
|
-
execute_command: cat ${workspaceRoot}/examples/<file>.ts
|
|
390
|
-
\`\`\`
|
|
391
|
-
Each line in \`examples/index.txt\` is \`filename | name | nodes | tags | source-id\`. Use the example as a reference for **structure** (which credential type each node uses, how nodes are wired, where sub-nodes attach to an agent, where sticky notes go) — not as a verbatim copy. The user's request will rarely match an example one-to-one.
|
|
392
|
-
|
|
393
|
-
The \`examples/\` directory is **read-only reference**. Never edit files there; \`${sourceDir}/\` and \`${chunksDir}/\` are your scratch.
|
|
394
|
-
|
|
395
|
-
Examples use \`newCredential('Name', 'id')\` for clarity. When you copy a pattern into \`${mainWorkflowPath}\`, replace those calls with raw \`{ id, name }\` from \`credentials(action="list")\` per the rules above.
|
|
396
|
-
|
|
397
|
-
If grep returns nothing, build from scratch. **Do not fabricate examples that do not exist.**
|
|
398
|
-
|
|
399
|
-
3. **Get node schemas**: Call \`nodes(action="type-definition")\` with ALL the node IDs you need in a single call (up to 5). For nodes with discriminators (from search results), include the \`resource\` and \`operation\` fields. **Read the definitions carefully** — they contain exact parameter names, types, required fields, valid enum values, credential types, displayOptions conditions, and \`@builderHint\` annotations with critical configuration guidance.
|
|
400
|
-
**Important**: Only call \`nodes(action="type-definition")\` for nodes you will actually use in the workflow. Do not speculatively fetch definitions "just in case". If a definition returns empty or an error, do not retry — proceed with the information from \`nodes(action="search")\` results instead.
|
|
401
|
-
|
|
402
|
-
4. **Resolve real resource IDs**: Check the node schemas from step 3 for parameters with \`searchListMethod\` or \`loadOptionsMethod\`. For EACH one, call \`nodes(action="explore-resources")\` with the node type, method name, and the matching explicit credential from step 1 to discover real resource IDs.
|
|
403
|
-
- **This is mandatory for: calendars, spreadsheets, channels, folders, models, databases, and any other list-based parameter.** Do NOT assume values like "primary", "default", or "General" — always look up the real ID.
|
|
404
|
-
- **LLM models in particular** (OpenAI, Anthropic, Groq, etc.): always call \`explore-resources\` with the node's \`@searchListMethod\` when a credential for that provider is attached. The live list reflects what the credential can actually access — free/cheap tiers are often limited (e.g. an OpenAI free-tier key may only return \`gpt-5-mini\`). Picking a model ID that the credential can't access produces a broken workflow. The list is sorted newest-first; use the \`@builderHint\` as selection guidance (e.g. "prefer the GPT-5.4 family") over the live results, not as a hard-coded pick.
|
|
405
|
-
- Example: Google Calendar's \`calendar\` parameter uses \`searchListMethod: getCalendars\`. Call \`nodes(action="explore-resources")\` with \`methodName: "getCalendars"\` to get the actual calendar ID (e.g., "user@example.com"), not "primary".
|
|
406
|
-
- **Never use fake IDs for discoverable resources.** Use \`placeholder()\` when the user needs to choose or create the resource after the build. For user-provided values, follow the placeholder rules in "SDK Code Rules".
|
|
407
|
-
- **If \`explore-resources\` returns more than one match and the user did not name a specific one, use \`placeholder('Select <resource>')\` for that parameter** (e.g. \`placeholder('Select a calendar')\`, \`placeholder('Select a Slack channel')\`). Picking one silently is a guess; after the build, the inline setup card in the AI Assistant panel surfaces placeholders so the user can choose. Only pick a single match without prompting.
|
|
408
|
-
- If the resource can't be created via n8n (e.g., Slack channels), explain clearly in your summary what the user needs to set up.
|
|
409
|
-
|
|
410
|
-
5. **Write workflow code** to \`${mainWorkflowPath}\`.
|
|
411
|
-
|
|
412
|
-
6. **Trace wiring before declaring done**: For workflows containing IF, Switch, or Merge nodes, trace each branch from its source to its target — confirm IF outputs are wired with \`.onTrue()\`/\`.onFalse()\`, every Switch rule output is wired by zero-based \`.onCase(index, target)\`, and the Merge mode matches the data shape. Read each node's \`@builderHint\` for selection criteria.
|
|
413
|
-
|
|
414
|
-
7. **Validate with tsc**: Run the TypeScript compiler for real type checking:
|
|
415
|
-
\`\`\`
|
|
416
|
-
execute_command: ${tsconfigCommand}
|
|
417
|
-
\`\`\`
|
|
418
|
-
Fix any errors using \`edit_file\` (with absolute path) to update the code, then re-run tsc. Iterate until clean.
|
|
419
|
-
**Important**: If tsc reports errors you cannot resolve after 2 attempts, skip tsc and proceed to submit-workflow. The submit tool has its own validation.
|
|
420
|
-
|
|
421
|
-
8. **Submit**: When tsc passes cleanly, call \`submit-workflow\` to validate the workflow graph and save it to n8n.
|
|
422
|
-
|
|
423
|
-
9. **Fix submission errors**: If \`submit-workflow\` returns errors, edit the file and submit again immediately. Skip tsc for validation-only errors. **Never end your turn on a file edit — always re-submit first.** The system compares file hashes: if the file changed since the last submit, all your work is discarded. End only on a successful re-submit or after you explicitly report the blocking error.
|
|
424
|
-
If remediation includes \`shouldEdit: false\`, stop immediately and report its guidance. Do not edit files, run commands, or call \`submit-workflow\` again.
|
|
425
|
-
|
|
426
|
-
10. **Done**: Output ONE sentence summarizing what was built, including the workflow ID and any known issues.
|
|
427
|
-
|
|
428
|
-
### For complex workflows (5+ nodes, multiple integrations):
|
|
429
|
-
|
|
430
|
-
Follow the **Compositional Workflow Pattern** above. The process becomes:
|
|
431
|
-
|
|
432
|
-
1. **Discover credentials** (same as above).
|
|
433
|
-
2. **Discover nodes and get schemas** (same as above).
|
|
434
|
-
3. **Resolve real resource IDs** (same as above — call \`nodes(action="explore-resources")\` for EVERY parameter with \`searchListMethod\` or \`loadOptionsMethod\`). Never assume IDs like "primary" or "default". If a resource doesn't exist, use a placeholder unless the user explicitly asked you to create that resource.
|
|
435
|
-
4. **Decompose** the workflow into logical chunks. Each chunk is a standalone sub-workflow with 2-4 nodes covering one capability (e.g., "fetch and format weather data", "generate AI recommendation", "store to data table").
|
|
436
|
-
5. **For each chunk**:
|
|
437
|
-
a. Write the chunk to \`${chunksDir}/<name>.ts\` with an \`executeWorkflowTrigger\` and explicit input schema.
|
|
438
|
-
b. Run tsc.
|
|
439
|
-
c. Submit the chunk: \`submit-workflow\` with \`filePath\` pointing to the chunk file. Test via \`executions(action="run")\`.
|
|
440
|
-
d. Fix if needed (max 2 submission fix attempts per chunk).
|
|
441
|
-
6. **Write the main workflow** in \`${mainWorkflowPath}\` that composes chunks via \`executeWorkflow\` nodes, referencing each chunk's workflow ID.
|
|
442
|
-
7. **Trace wiring before declaring done**: For workflows containing IF, Switch, or Merge nodes, trace each branch from its source to its target — confirm IF outputs are wired with \`.onTrue()\`/\`.onFalse()\`, every Switch rule output is wired by zero-based \`.onCase(index, target)\`, and the Merge mode matches the data shape. Read each node's \`@builderHint\` for selection criteria.
|
|
443
|
-
8. **Submit** the main workflow.
|
|
444
|
-
9. **Done**: Output ONE sentence summarizing what was built, including the workflow ID and any known issues.
|
|
445
|
-
|
|
446
|
-
Do NOT produce visible output until the final step. All reasoning happens internally.
|
|
447
|
-
|
|
448
|
-
## Modifying Existing Workflows
|
|
449
|
-
When modifying an existing workflow, the current code is **already pre-loaded** into \`${mainWorkflowPath}\` with SDK imports.
|
|
450
|
-
|
|
451
|
-
**Pre-flight check before any edit**: If the change introduces a node type not already in the file, or touches parameter values you haven't just looked up (model IDs, RLC values, enum selections, credential types, versions, etc.), call \`nodes(action="type-definition")\` first. Read \`@builderHint\`, \`@default\`, \`@searchListMethod\`, and \`@loadOptionsMethod\` from the output.
|
|
452
|
-
|
|
453
|
-
**Live credential-backed lookups are the source of truth for RLC/list parameters.** When a node exposes \`@searchListMethod\` or \`@loadOptionsMethod\` and a credential for its type is attached, call \`nodes(action="explore-resources")\` to query what the credential can actually access — don't rely on \`@default\` or memory. Treat \`@builderHint\` as *selection guidance over the live list* ("prefer the GPT-5.4 family", "prefer the most recent Sonnet") rather than as the source of the value itself. When no credential is attached, fall back to \`@default\`. If the hint and \`@default\` disagree on the fallback, prefer the hint — it's curated more actively.
|
|
454
|
-
|
|
455
|
-
Do not guess method names for \`explore-resources\`, and do not fill parameter values in from memory, even when the node or parameter feels familiar. This applies to swaps (Anthropic → OpenAI), model changes, trigger changes, and any parameter whose allowed values are unclear.
|
|
456
|
-
|
|
457
|
-
Steps:
|
|
458
|
-
- Read the current code with \`read_file\`
|
|
459
|
-
- Edit using \`edit_file\` for targeted changes or \`write_file\` for full rewrites (always use absolute paths)
|
|
460
|
-
- Run tsc → submit-workflow with the \`workflowId\`
|
|
461
|
-
- Do NOT call \`workflows(action="get-as-code")\` — the file is already populated
|
|
462
|
-
|
|
463
|
-
${SDK_RULES_AND_PATTERNS_SANDBOX}
|
|
464
|
-
`;
|
|
465
|
-
}
|
|
466
|
-
//# sourceMappingURL=build-workflow-agent.prompt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build-workflow-agent.prompt.js","sourceRoot":"","sources":["../../../src/tools/orchestration/build-workflow-agent.prompt.ts"],"names":[],"mappings":";;;AA4KA,0EAqVC;AAzfD,2EAKiD;AAEjD,+DAAkF;AAIlF,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;8FAkB4D,CAAC;AAI/F,MAAM,cAAc,GAAG;;;;;;;;mHAQ4F,CAAC;AAEpH,MAAM,+BAA+B,GAAG;;;;wHAIgF,CAAC;AAEzH,MAAM,iBAAiB,GAAG;;;;;;;2GAOiF,CAAC;AAK5G,MAAM,yBAAyB,GAAG;;uOAEqM,CAAC;AAQxO,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;qSA0BsQ,CAAC;AAEtS,SAAS,0BAA0B,CAAC,IAAwB;IAC3D,OAAO;QACN,cAAc;QACd,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,8BAAc;QAC5D,iBAAiB;QACjB,+BAA+B,GAAG,qCAAqB;QACvD,6BAA6B,GAAG,oCAAoB;QACpD,6BAA6B,GAAG,oCAAoB;QACpD,+BAA+B;QAC/B,yBAAyB;KACzB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAChB,CAAC;AAED,MAAM,2BAA2B,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC;AACvE,MAAM,8BAA8B,GAAG,0BAA0B,CAAC,SAAS,CAAC,CAAC;AAIhE,QAAA,oBAAoB,GAAG;;EAElC,yBAAyB;;;;;;EAMzB,kCAAiB;;EAEjB,kCAAiB;;;;;;;;;;;;;;;;;;;EAmBjB,2BAA2B;CAC5B,CAAC;AAWF,SAAS,mBAAmB,CAAC,aAAqB,EAAE,QAAgB;IACnE,OAAO,QAAQ,CAAC,UAAU,CAAC,GAAG,aAAa,GAAG,CAAC;QAC9C,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1C,CAAC,CAAC,QAAQ,CAAC;AACb,CAAC;AAED,SAAgB,+BAA+B,CAC9C,aAAqB,EACrB,SAAwC,EAAE;IAE1C,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,GAAG,aAAa,MAAM,CAAC;IAC7D,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,GAAG,aAAa,SAAS,CAAC;IAChE,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,GAAG,SAAS,cAAc,CAAC;IAC/E,MAAM,eAAe,GAAG,MAAM,CAAC,YAAY;QAC1C,CAAC,CAAC,MAAM,aAAa,kCAAkC,MAAM,CAAC,YAAY,OAAO;QACjF,CAAC,CAAC,MAAM,aAAa,2BAA2B,CAAC;IAClD,MAAM,cAAc,GAAG,mBAAmB,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IACrE,MAAM,cAAc,GAAG,mBAAmB,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAErE,OAAO;;EAEN,yBAAyB;;;;0BAID,aAAa,6DAA6D,aAAa;;;EAG/G,aAAa;;;;;;;IAOX,cAAc;;IAEd,cAAc;;;;sCAIoB,gBAAgB;QAC9C,SAAS;;;;;wEAKuD,SAAS;;;KAG5E,SAAS;;;;;;;;;;;;;;;KAeT,gBAAgB;;;;;;;;;;;;;;;;;;;;;KAqBhB,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsDT,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4DAoCuC,gBAAgB;;;;EAI1E,kCAAiB;;;;;;;;;;;;;;;;EAgBjB,kCAAiB;;;;;;;;;;;;;;;oEAeiD,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sCAsDvC,aAAa;;;oDAGC,aAAa;;0CAEvB,aAAa;0BAC7B,aAAa;;;;uFAIgD,SAAS,aAAa,SAAS;;8FAExB,gBAAgB;;;;;;;;;;;;;;;kCAe5E,gBAAgB;;;;;;sBAM5B,eAAe;;;;;;;;;;;;;;;;;;;;;6BAqBR,SAAS;;;;sCAIA,gBAAgB;;;;;;;;yFAQmC,gBAAgB;;;;;;;;;;;;;;EAcvG,8BAA8B;CAC/B,CAAC;AACF,CAAC"}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { type BuiltTool, type RuntimeSkillSource, type Workspace } from '@n8n/agents';
|
|
2
|
-
import { z } from 'zod';
|
|
3
|
-
import type { OrchestrationContext } from '../../types';
|
|
4
|
-
import { type RemediationMetadata, type WorkflowBuildOutcome, type WorkflowSetupRequirement, type WorkflowVerificationReadiness, type WorkflowLoopState } from '../../workflow-loop';
|
|
5
|
-
import { type SubmitWorkflowAttempt, type SubmitWorkflowOutput } from '../workflows/submit-workflow.tool';
|
|
6
|
-
export interface BuildWorkflowAgentRunResult {
|
|
7
|
-
text: string;
|
|
8
|
-
outcome: WorkflowBuildOutcome;
|
|
9
|
-
}
|
|
10
|
-
export interface MainWorkflowSnapshot {
|
|
11
|
-
exists: boolean;
|
|
12
|
-
sourceHash?: string;
|
|
13
|
-
}
|
|
14
|
-
export declare function getBuilderSessionMemory(context: Pick<OrchestrationContext, 'memory'>, useSharedWorkspace: boolean): OrchestrationContext['memory'];
|
|
15
|
-
export interface BuilderWorkflowWorkspaceLayout {
|
|
16
|
-
workItemRoot: string;
|
|
17
|
-
sourceDir: string;
|
|
18
|
-
chunksDir: string;
|
|
19
|
-
mainWorkflowPath: string;
|
|
20
|
-
tsconfigPath: string;
|
|
21
|
-
relativeMainWorkflowPath: string;
|
|
22
|
-
}
|
|
23
|
-
export declare function builderWorkflowWorkspaceLayout(root: string, workItemId: string): BuilderWorkflowWorkspaceLayout;
|
|
24
|
-
export declare function materializeBuilderRuntimeSkills(context: OrchestrationContext, workspace: Workspace, root: string): Promise<{
|
|
25
|
-
workspace: Workspace;
|
|
26
|
-
source?: RuntimeSkillSource;
|
|
27
|
-
}>;
|
|
28
|
-
export declare function buildWarmBuilderFollowUp(input: {
|
|
29
|
-
task: string;
|
|
30
|
-
conversationContext?: string;
|
|
31
|
-
workflowId: string;
|
|
32
|
-
workItemId: string;
|
|
33
|
-
}): string;
|
|
34
|
-
export declare function recordSuccessfulWorkflowBuilds(tool: BuiltTool | undefined, onWorkflowId: (workflowId: string) => void): void;
|
|
35
|
-
export type OutcomeForVerificationReadiness = Pick<WorkflowBuildOutcome, 'submitted' | 'workflowId' | 'triggerNodes' | 'mockedCredentialTypes' | 'mockedCredentialsByNode' | 'verificationPinData' | 'usesWorkflowPinDataForVerification' | 'hasUnresolvedPlaceholders' | 'verification' | 'remediation'>;
|
|
36
|
-
export declare function determineVerificationReadiness(outcome: OutcomeForVerificationReadiness): WorkflowVerificationReadiness;
|
|
37
|
-
export declare function determineSetupRequirement(outcome: OutcomeForVerificationReadiness): WorkflowSetupRequirement;
|
|
38
|
-
export declare function mergeLatestVerificationIntoOutcome(outcome: WorkflowBuildOutcome, latestOutcome: WorkflowBuildOutcome | undefined): WorkflowBuildOutcome;
|
|
39
|
-
export declare function withTerminalLoopState(outcome: WorkflowBuildOutcome, state: WorkflowLoopState | undefined): WorkflowBuildOutcome;
|
|
40
|
-
export declare function finalizeBuildResult(context: OrchestrationContext, workItemId: string, result: {
|
|
41
|
-
text: string;
|
|
42
|
-
outcome: WorkflowBuildOutcome;
|
|
43
|
-
}): Promise<{
|
|
44
|
-
text: string;
|
|
45
|
-
outcome: WorkflowBuildOutcome;
|
|
46
|
-
}>;
|
|
47
|
-
export declare const DETACHED_BUILDER_REQUIREMENTS = "## Detached Task Contract\n\nYou are running as a detached background task. Do not stop after a successful submit \u2014 verify the workflow works.\n\n### Completion criteria\n\nYour job is done when ONE of these is true:\n- the workflow is verified (ran successfully)\n- you are blocked after one repair attempt per unique failure\n\nDo NOT stop after a successful submit without verifying. Every trigger type is testable:\nmanual / schedule via `executions(action=\"run\")`; event-based triggers (form, webhook,\nchat, mcp, linear, github, slack, etc.) via `verify-built-workflow` with an `inputData`\npayload. The pin-data adapter injects it as the trigger node's output.\n\n### Submit discipline\n\n**Every file edit MUST be followed by submit-workflow before you do anything else.**\nThe system tracks file hashes. If you edit the code and then call `executions(action=\"run\")`, `verify-built-workflow`, or finish without re-submitting, your work is discarded. The sequence is always: edit \u2192 submit \u2192 then verify/run.\n\n### Verification\n\n- If submit-workflow returned mocked credentials, call `verify-built-workflow` with the workItemId and workflowId from this task.\n- Otherwise pick based on trigger type:\n - **Manual / Schedule** \u2014 `executions(action=\"run\")`.\n - **Form Trigger** \u2014 pass `inputData` as a flat field map, e.g. `{name: \"Alice\", email: \"a@b.c\"}`. Do NOT wrap in `formFields` \u2014 production Form Trigger emits fields directly on `$json`, and the adapter rejects wrapped payloads.\n - **Webhook** \u2014 `verify-built-workflow` with `inputData` as the body payload, e.g. `{event: \"signup\", userId: \"...\"}`. Adapter wraps it under `body`; downstream expressions use `$json.body.<field>`.\n - **Chat Trigger** \u2014 `verify-built-workflow` with `{chatInput: \"user message\"}`.\n - **Other event triggers (Linear, GitHub, Slack, MCP, etc.)** \u2014 `verify-built-workflow` with `inputData` matching the trigger's expected payload shape.\n- If verify-built-workflow returns remediation with `shouldEdit: false`, stop editing and follow its guidance.\n- If verification fails with `shouldEdit: true`, make one batched code repair and re-submit. Never exceed the remaining repair budget in the remediation metadata.\n- If verification fails otherwise, call `executions(action=\"debug\")`, fix the code, re-submit, and retry once.\n- If the same failure signature repeats, stop and explain the block.\n\n### Resource discovery\n\nBefore writing code that uses external services, **resolve real resource IDs**:\n- Call `nodes(action=\"explore-resources\")` for any parameter with searchListMethod (calendars, spreadsheets, channels, models, etc.)\n- Do NOT use \"primary\", \"default\", or any assumed identifier \u2014 look up the actual value\n- Call `nodes(action=\"suggested\")` early if the workflow fits a known category (web_app, form_input, data_persistence, etc.) \u2014 the pattern hints prevent common mistakes\n- Check @builderHint annotations in node type definitions for critical configuration guidance\n\n### Publishing\n\nDo NOT call `workflows(action=\"publish\")` for the main workflow. Publishing is the user's decision after testing. Your job ends at a successful submit. The only exception is sub-workflows in the compositional pattern \u2014 those must be published so the parent workflow can reference them.\n";
|
|
48
|
-
export declare function createMainWorkflowSnapshot(content: string | null): MainWorkflowSnapshot;
|
|
49
|
-
export declare function shouldFinalSubmitMainWorkflow(input: {
|
|
50
|
-
initial: MainWorkflowSnapshot;
|
|
51
|
-
current: MainWorkflowSnapshot;
|
|
52
|
-
}): boolean;
|
|
53
|
-
export declare function supportingWorkflowIdsFromSubmitAttempts(submitAttempts: SubmitWorkflowAttempt[], mainWorkflowPath: string, mainWorkflowId: string | undefined, referencedWorkflowIds?: string[]): string[];
|
|
54
|
-
export declare function resultFromPostStreamError(input: {
|
|
55
|
-
error: unknown;
|
|
56
|
-
submitAttempts: SubmitWorkflowAttempt[];
|
|
57
|
-
mainWorkflowPath: string;
|
|
58
|
-
workItemId: string;
|
|
59
|
-
runId: string;
|
|
60
|
-
taskId: string;
|
|
61
|
-
}): {
|
|
62
|
-
text: string;
|
|
63
|
-
outcome: WorkflowBuildOutcome;
|
|
64
|
-
} | undefined;
|
|
65
|
-
export declare function resultFromTerminalRemediation(input: {
|
|
66
|
-
remediation: RemediationMetadata;
|
|
67
|
-
submitAttempts: SubmitWorkflowAttempt[];
|
|
68
|
-
mainWorkflowPath: string;
|
|
69
|
-
workItemId: string;
|
|
70
|
-
runId: string;
|
|
71
|
-
taskId: string;
|
|
72
|
-
}): {
|
|
73
|
-
text: string;
|
|
74
|
-
outcome: WorkflowBuildOutcome;
|
|
75
|
-
};
|
|
76
|
-
export declare function resultFromLaterFailedMainSubmit(input: {
|
|
77
|
-
failedAttempt: SubmitWorkflowAttempt;
|
|
78
|
-
submitAttempts: SubmitWorkflowAttempt[];
|
|
79
|
-
mainWorkflowPath: string;
|
|
80
|
-
workItemId: string;
|
|
81
|
-
runId: string;
|
|
82
|
-
taskId: string;
|
|
83
|
-
}): {
|
|
84
|
-
text: string;
|
|
85
|
-
outcome: WorkflowBuildOutcome;
|
|
86
|
-
} | undefined;
|
|
87
|
-
export declare function attemptFromAutoResubmit(input: {
|
|
88
|
-
latestAttempt: SubmitWorkflowAttempt | undefined;
|
|
89
|
-
resubmit: SubmitWorkflowOutput;
|
|
90
|
-
filePath: string;
|
|
91
|
-
sourceHash: string;
|
|
92
|
-
}): SubmitWorkflowAttempt | undefined;
|
|
93
|
-
export declare function shouldRecoverSavedWorkflowAfterFailedSubmit(attempt: SubmitWorkflowAttempt): boolean;
|
|
94
|
-
export declare function settleMissingMainWorkflowSubmit(input: {
|
|
95
|
-
context: OrchestrationContext;
|
|
96
|
-
workItemId: string;
|
|
97
|
-
runId: string;
|
|
98
|
-
taskId: string;
|
|
99
|
-
workflowId: string | undefined;
|
|
100
|
-
mainWorkflowPath: string;
|
|
101
|
-
initialMainWorkflowSnapshot: MainWorkflowSnapshot;
|
|
102
|
-
currentMainWorkflow: string | null;
|
|
103
|
-
currentMainWorkflowHash: string;
|
|
104
|
-
submitTool: BuiltTool | undefined;
|
|
105
|
-
submitAttempts: Map<string, SubmitWorkflowAttempt>;
|
|
106
|
-
submitAttemptHistory: SubmitWorkflowAttempt[];
|
|
107
|
-
finalText: string;
|
|
108
|
-
onSuccessfulSubmit: (attempt: SubmitWorkflowAttempt) => Promise<BuildWorkflowAgentRunResult>;
|
|
109
|
-
onRecoveredSubmit: (result: BuildWorkflowAgentRunResult) => Promise<BuildWorkflowAgentRunResult>;
|
|
110
|
-
}): Promise<BuildWorkflowAgentRunResult>;
|
|
111
|
-
export interface StartBuildWorkflowAgentInput {
|
|
112
|
-
task: string;
|
|
113
|
-
workflowId?: string;
|
|
114
|
-
conversationContext?: string;
|
|
115
|
-
workItemId?: string;
|
|
116
|
-
taskId?: string;
|
|
117
|
-
agentId?: string;
|
|
118
|
-
plannedTaskId?: string;
|
|
119
|
-
}
|
|
120
|
-
export interface StartedWorkflowBuildTask {
|
|
121
|
-
result: string;
|
|
122
|
-
taskId: string;
|
|
123
|
-
agentId: string;
|
|
124
|
-
}
|
|
125
|
-
export declare function startBuildWorkflowAgentTask(context: OrchestrationContext, input: StartBuildWorkflowAgentInput): Promise<StartedWorkflowBuildTask>;
|
|
126
|
-
export declare const buildWorkflowAgentInputSchema: z.ZodObject<{
|
|
127
|
-
task: z.ZodString;
|
|
128
|
-
workflowId: z.ZodOptional<z.ZodString>;
|
|
129
|
-
conversationContext: z.ZodOptional<z.ZodString>;
|
|
130
|
-
workItemId: z.ZodOptional<z.ZodString>;
|
|
131
|
-
bypassPlan: z.ZodOptional<z.ZodBoolean>;
|
|
132
|
-
reason: z.ZodOptional<z.ZodString>;
|
|
133
|
-
}, "strip", z.ZodTypeAny, {
|
|
134
|
-
task: string;
|
|
135
|
-
reason?: string | undefined;
|
|
136
|
-
workItemId?: string | undefined;
|
|
137
|
-
workflowId?: string | undefined;
|
|
138
|
-
conversationContext?: string | undefined;
|
|
139
|
-
bypassPlan?: boolean | undefined;
|
|
140
|
-
}, {
|
|
141
|
-
task: string;
|
|
142
|
-
reason?: string | undefined;
|
|
143
|
-
workItemId?: string | undefined;
|
|
144
|
-
workflowId?: string | undefined;
|
|
145
|
-
conversationContext?: string | undefined;
|
|
146
|
-
bypassPlan?: boolean | undefined;
|
|
147
|
-
}>;
|
|
148
|
-
export declare function createBuildWorkflowAgentTool(context: OrchestrationContext): BuiltTool;
|