@n8n/instance-ai 1.4.1 → 1.6.0
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/agent/computer-use-prompt.d.ts +5 -0
- package/dist/agent/computer-use-prompt.js +97 -0
- package/dist/agent/computer-use-prompt.js.map +1 -0
- package/dist/agent/instance-agent.js +48 -73
- package/dist/agent/instance-agent.js.map +1 -1
- package/dist/agent/mcp-tool-name-validation.d.ts +15 -0
- package/dist/agent/mcp-tool-name-validation.js +67 -0
- package/dist/agent/mcp-tool-name-validation.js.map +1 -0
- package/dist/agent/sanitize-mcp-schemas.d.ts +56 -2
- package/dist/agent/sanitize-mcp-schemas.js +226 -19
- package/dist/agent/sanitize-mcp-schemas.js.map +1 -1
- package/dist/agent/sub-agent-debriefing.d.ts +2 -2
- package/dist/agent/sub-agent-factory.d.ts +1 -0
- package/dist/agent/sub-agent-factory.js +1 -0
- package/dist/agent/sub-agent-factory.js.map +1 -1
- package/dist/agent/system-prompt.d.ts +1 -1
- package/dist/agent/system-prompt.js +46 -104
- package/dist/agent/system-prompt.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/constants/model-settings.d.ts +3 -0
- package/dist/constants/model-settings.js +7 -0
- package/dist/constants/model-settings.js.map +1 -0
- package/dist/domain-access/domain-access-tracker.d.ts +3 -0
- package/dist/domain-access/domain-access-tracker.js +16 -0
- package/dist/domain-access/domain-access-tracker.js.map +1 -1
- package/dist/domain-access/domain-gating.d.ts +35 -6
- package/dist/domain-access/domain-gating.js +47 -1
- package/dist/domain-access/domain-gating.js.map +1 -1
- package/dist/domain-access/index.d.ts +1 -1
- package/dist/domain-access/index.js +3 -1
- package/dist/domain-access/index.js.map +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +6 -0
- package/dist/mcp/mcp-client-manager.d.ts +18 -2
- package/dist/mcp/mcp-client-manager.js +124 -20
- package/dist/mcp/mcp-client-manager.js.map +1 -1
- package/dist/parsers/docx-parser.d.ts +6 -0
- package/dist/parsers/docx-parser.js +65 -0
- package/dist/parsers/docx-parser.js.map +1 -0
- package/dist/parsers/html-parser.d.ts +7 -0
- package/dist/parsers/html-parser.js +67 -0
- package/dist/parsers/html-parser.js.map +1 -0
- package/dist/parsers/index.d.ts +4 -0
- package/dist/parsers/index.js +16 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/parsers/pdf-parser.d.ts +7 -0
- package/dist/parsers/pdf-parser.js +72 -0
- package/dist/parsers/pdf-parser.js.map +1 -0
- package/dist/parsers/structured-file-parser.d.ts +8 -3
- package/dist/parsers/structured-file-parser.js +36 -4
- package/dist/parsers/structured-file-parser.js.map +1 -1
- package/dist/parsers/validate-attachments.d.ts +14 -0
- package/dist/parsers/validate-attachments.js +61 -0
- package/dist/parsers/validate-attachments.js.map +1 -0
- package/dist/parsers/xlsx-parser.d.ts +2 -0
- package/dist/parsers/xlsx-parser.js +75 -0
- package/dist/parsers/xlsx-parser.js.map +1 -0
- package/dist/planned-tasks/planned-task-permissions.d.ts +2 -0
- package/dist/planned-tasks/planned-task-permissions.js +8 -2
- package/dist/planned-tasks/planned-task-permissions.js.map +1 -1
- package/dist/planned-tasks/planned-task-service.d.ts +14 -1
- package/dist/planned-tasks/planned-task-service.js +138 -2
- package/dist/planned-tasks/planned-task-service.js.map +1 -1
- package/dist/runtime/background-task-manager.d.ts +32 -1
- package/dist/runtime/background-task-manager.js +134 -4
- package/dist/runtime/background-task-manager.js.map +1 -1
- package/dist/runtime/builder-sandbox-session-registry.d.ts +45 -0
- package/dist/runtime/builder-sandbox-session-registry.js +159 -0
- package/dist/runtime/builder-sandbox-session-registry.js.map +1 -0
- package/dist/runtime/liveness-policy.d.ts +40 -0
- package/dist/runtime/liveness-policy.js +74 -0
- package/dist/runtime/liveness-policy.js.map +1 -0
- package/dist/runtime/resumable-stream-executor.d.ts +1 -0
- package/dist/runtime/resumable-stream-executor.js +1 -0
- package/dist/runtime/resumable-stream-executor.js.map +1 -1
- package/dist/runtime/run-state-registry.d.ts +21 -5
- package/dist/runtime/run-state-registry.js +109 -7
- package/dist/runtime/run-state-registry.js.map +1 -1
- package/dist/runtime/stream-runner.d.ts +3 -0
- package/dist/runtime/stream-runner.js +3 -0
- package/dist/runtime/stream-runner.js.map +1 -1
- package/dist/runtime/terminal-response-guard.d.ts +30 -0
- package/dist/runtime/terminal-response-guard.js +149 -0
- package/dist/runtime/terminal-response-guard.js.map +1 -0
- package/dist/storage/agent-tree-snapshot.d.ts +2 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +3 -1
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/planned-task-storage.js +2 -1
- package/dist/storage/planned-task-storage.js.map +1 -1
- package/dist/storage/terminal-outcome-storage.d.ts +48 -0
- package/dist/storage/terminal-outcome-storage.js +84 -0
- package/dist/storage/terminal-outcome-storage.js.map +1 -0
- package/dist/storage/workflow-loop-storage.d.ts +442 -16
- package/dist/stream/consume-with-hitl.d.ts +2 -0
- package/dist/stream/consume-with-hitl.js +2 -0
- package/dist/stream/consume-with-hitl.js.map +1 -1
- package/dist/stream/map-chunk.js +6 -0
- package/dist/stream/map-chunk.js.map +1 -1
- package/dist/tools/attachments/parse-file.tool.d.ts +46 -34
- package/dist/tools/attachments/parse-file.tool.js +115 -56
- package/dist/tools/attachments/parse-file.tool.js.map +1 -1
- package/dist/tools/credentials.tool.d.ts +120 -1
- package/dist/tools/credentials.tool.js +65 -12
- package/dist/tools/credentials.tool.js.map +1 -1
- package/dist/tools/data-tables.tool.d.ts +1 -0
- package/dist/tools/data-tables.tool.js +64 -24
- package/dist/tools/data-tables.tool.js.map +1 -1
- package/dist/tools/executions.tool.js +4 -1
- package/dist/tools/executions.tool.js.map +1 -1
- package/dist/tools/filesystem/create-tools-from-mcp-server.d.ts +2 -1
- package/dist/tools/filesystem/create-tools-from-mcp-server.js +74 -5
- package/dist/tools/filesystem/create-tools-from-mcp-server.js.map +1 -1
- package/dist/tools/index.d.ts +4 -24
- package/dist/tools/index.js +23 -7
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/nodes.tool.js +15 -15
- package/dist/tools/nodes.tool.js.map +1 -1
- package/dist/tools/orchestration/add-plan-item.tool.js +3 -1
- package/dist/tools/orchestration/add-plan-item.tool.js.map +1 -1
- package/dist/tools/orchestration/blueprint-accumulator.d.ts +4 -1
- package/dist/tools/orchestration/blueprint-accumulator.js +28 -0
- package/dist/tools/orchestration/blueprint-accumulator.js.map +1 -1
- package/dist/tools/orchestration/blueprint.schema.d.ts +61 -16
- package/dist/tools/orchestration/blueprint.schema.js +15 -1
- package/dist/tools/orchestration/blueprint.schema.js.map +1 -1
- package/dist/tools/orchestration/browser-credential-setup.nudge.d.ts +5 -0
- package/dist/tools/orchestration/browser-credential-setup.nudge.js +11 -0
- package/dist/tools/orchestration/browser-credential-setup.nudge.js.map +1 -0
- package/dist/tools/orchestration/browser-credential-setup.prompt.js +2 -1
- package/dist/tools/orchestration/browser-credential-setup.prompt.js.map +1 -1
- package/dist/tools/orchestration/browser-credential-setup.tool.js +55 -7
- package/dist/tools/orchestration/browser-credential-setup.tool.js.map +1 -1
- package/dist/tools/orchestration/build-workflow-agent.prompt.js +86 -60
- package/dist/tools/orchestration/build-workflow-agent.prompt.js.map +1 -1
- package/dist/tools/orchestration/build-workflow-agent.tool.d.ts +56 -3
- package/dist/tools/orchestration/build-workflow-agent.tool.js +1020 -300
- package/dist/tools/orchestration/build-workflow-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/builder-memory-compaction.d.ts +38 -0
- package/dist/tools/orchestration/builder-memory-compaction.js +146 -0
- package/dist/tools/orchestration/builder-memory-compaction.js.map +1 -0
- package/dist/tools/orchestration/complete-checkpoint.tool.d.ts +2 -0
- package/dist/tools/orchestration/complete-checkpoint.tool.js +76 -0
- package/dist/tools/orchestration/complete-checkpoint.tool.js.map +1 -0
- package/dist/tools/orchestration/data-table-agent.tool.js +34 -17
- package/dist/tools/orchestration/data-table-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/delegate.tool.js +34 -16
- package/dist/tools/orchestration/delegate.tool.js.map +1 -1
- package/dist/tools/orchestration/plan-agent-prompt.d.ts +1 -1
- package/dist/tools/orchestration/plan-agent-prompt.js +7 -0
- package/dist/tools/orchestration/plan-agent-prompt.js.map +1 -1
- package/dist/tools/orchestration/plan-with-agent.tool.d.ts +23 -0
- package/dist/tools/orchestration/plan-with-agent.tool.js +314 -13
- package/dist/tools/orchestration/plan-with-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/plan.tool.js +17 -1
- package/dist/tools/orchestration/plan.tool.js.map +1 -1
- package/dist/tools/orchestration/report-verification-verdict.tool.d.ts +40 -2
- package/dist/tools/orchestration/report-verification-verdict.tool.js +85 -6
- package/dist/tools/orchestration/report-verification-verdict.tool.js.map +1 -1
- package/dist/tools/orchestration/research-with-agent.tool.js +33 -16
- package/dist/tools/orchestration/research-with-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/tracing-utils.js +8 -0
- package/dist/tools/orchestration/tracing-utils.js.map +1 -1
- package/dist/tools/orchestration/verify-built-workflow.tool.d.ts +8 -2
- package/dist/tools/orchestration/verify-built-workflow.tool.js +476 -6
- package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
- package/dist/tools/research.tool.js +56 -10
- package/dist/tools/research.tool.js.map +1 -1
- package/dist/tools/shared/ask-user.tool.d.ts +1 -0
- package/dist/tools/shared/ask-user.tool.js +3 -2
- package/dist/tools/shared/ask-user.tool.js.map +1 -1
- package/dist/tools/templates.tool.js +5 -90
- package/dist/tools/templates.tool.js.map +1 -1
- package/dist/tools/web-research/sanitize-web-content.d.ts +0 -1
- package/dist/tools/web-research/sanitize-web-content.js +0 -9
- package/dist/tools/web-research/sanitize-web-content.js.map +1 -1
- package/dist/tools/workflows/apply-workflow-credentials.tool.d.ts +2 -2
- package/dist/tools/workflows/build-workflow.tool.d.ts +2 -2
- package/dist/tools/workflows/build-workflow.tool.js +6 -4
- package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/materialize-node-type.tool.d.ts +8 -8
- package/dist/tools/workflows/resolve-credentials.d.ts +9 -4
- package/dist/tools/workflows/resolve-credentials.js +59 -27
- package/dist/tools/workflows/resolve-credentials.js.map +1 -1
- package/dist/tools/workflows/setup-workflow.schema.d.ts +40 -0
- package/dist/tools/workflows/setup-workflow.service.d.ts +5 -1
- package/dist/tools/workflows/setup-workflow.service.js +71 -5
- package/dist/tools/workflows/setup-workflow.service.js.map +1 -1
- package/dist/tools/workflows/submit-workflow-identity.d.ts +25 -3
- package/dist/tools/workflows/submit-workflow-identity.js +92 -5
- package/dist/tools/workflows/submit-workflow-identity.js.map +1 -1
- package/dist/tools/workflows/submit-workflow.tool.d.ts +60 -6
- package/dist/tools/workflows/submit-workflow.tool.js +102 -19
- package/dist/tools/workflows/submit-workflow.tool.js.map +1 -1
- package/dist/tools/workflows/workflow-json-utils.d.ts +4 -0
- package/dist/tools/workflows/workflow-json-utils.js +54 -0
- package/dist/tools/workflows/workflow-json-utils.js.map +1 -0
- package/dist/tools/workflows.tool.d.ts +7 -1
- package/dist/tools/workflows.tool.js +283 -54
- package/dist/tools/workflows.tool.js.map +1 -1
- package/dist/tracing/langsmith-tracing.d.ts +2 -0
- package/dist/tracing/langsmith-tracing.js +12 -3
- package/dist/tracing/langsmith-tracing.js.map +1 -1
- package/dist/tracing/trace-replay.d.ts +3 -0
- package/dist/tracing/trace-replay.js +65 -0
- package/dist/tracing/trace-replay.js.map +1 -1
- package/dist/types.d.ts +92 -16
- package/dist/workflow-builder/parse-validate.d.ts +5 -1
- package/dist/workflow-builder/parse-validate.js +5 -4
- package/dist/workflow-builder/parse-validate.js.map +1 -1
- package/dist/workflow-loop/guidance.js +8 -2
- package/dist/workflow-loop/guidance.js.map +1 -1
- package/dist/workflow-loop/index.d.ts +3 -2
- package/dist/workflow-loop/index.js +11 -1
- package/dist/workflow-loop/index.js.map +1 -1
- package/dist/workflow-loop/remediation.d.ts +13 -0
- package/dist/workflow-loop/remediation.js +36 -0
- package/dist/workflow-loop/remediation.js.map +1 -0
- package/dist/workflow-loop/runtime.js +7 -0
- package/dist/workflow-loop/runtime.js.map +1 -1
- package/dist/workflow-loop/workflow-loop-controller.d.ts +1 -1
- package/dist/workflow-loop/workflow-loop-controller.js +196 -29
- package/dist/workflow-loop/workflow-loop-controller.js.map +1 -1
- package/dist/workflow-loop/workflow-loop-state.d.ts +500 -10
- package/dist/workflow-loop/workflow-loop-state.js +74 -1
- package/dist/workflow-loop/workflow-loop-state.js.map +1 -1
- package/dist/workflow-loop/workflow-task-service.d.ts +2 -1
- package/dist/workflow-loop/workflow-task-service.js +4 -0
- package/dist/workflow-loop/workflow-task-service.js.map +1 -1
- package/dist/workspace/builder-sandbox-factory.d.ts +3 -4
- package/dist/workspace/builder-sandbox-factory.js +74 -35
- package/dist/workspace/builder-sandbox-factory.js.map +1 -1
- package/dist/workspace/create-workspace.d.ts +2 -0
- package/dist/workspace/create-workspace.js.map +1 -1
- package/dist/workspace/n8n-sandbox-filesystem.js +2 -2
- package/dist/workspace/n8n-sandbox-filesystem.js.map +1 -1
- package/dist/workspace/n8n-sandbox-sandbox.d.ts +2 -3
- package/dist/workspace/n8n-sandbox-sandbox.js +3 -7
- package/dist/workspace/n8n-sandbox-sandbox.js.map +1 -1
- package/dist/workspace/sandbox-setup.d.ts +1 -1
- package/dist/workspace/sandbox-setup.js +41 -16
- package/dist/workspace/sandbox-setup.js.map +1 -1
- package/dist/workspace/snapshot-manager.d.ts +14 -2
- package/dist/workspace/snapshot-manager.js +57 -1
- package/dist/workspace/snapshot-manager.js.map +1 -1
- package/package.json +35 -10
- package/dist/tools/templates/template-api.d.ts +0 -21
- package/dist/tools/templates/template-api.js +0 -104
- package/dist/tools/templates/template-api.js.map +0 -1
- package/dist/tools/templates/types.d.ts +0 -52
- package/dist/tools/templates/types.js +0 -37
- package/dist/tools/templates/types.js.map +0 -1
- package/dist/tools/utils/mermaid.utils.d.ts +0 -15
- package/dist/tools/utils/mermaid.utils.js +0 -622
- package/dist/tools/utils/mermaid.utils.js.map +0 -1
- package/dist/tools/utils/node-configuration.utils.d.ts +0 -6
- package/dist/tools/utils/node-configuration.utils.js +0 -77
- package/dist/tools/utils/node-configuration.utils.js.map +0 -1
- package/dist/workspace/n8n-sandbox-client.d.ts +0 -105
- package/dist/workspace/n8n-sandbox-client.js +0 -335
- package/dist/workspace/n8n-sandbox-client.js.map +0 -1
- package/dist/workspace/n8n-sandbox-image-manager.d.ts +0 -5
- package/dist/workspace/n8n-sandbox-image-manager.js +0 -25
- package/dist/workspace/n8n-sandbox-image-manager.js.map +0 -1
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BUILDER_AGENT_PROMPT = void 0;
|
|
4
4
|
exports.createSandboxBuilderAgentPrompt = createSandboxBuilderAgentPrompt;
|
|
5
|
-
const parameter_guides_1 = require("@n8n/workflow-sdk/prompts/node-guidance/parameter-guides");
|
|
6
5
|
const node_selection_1 = require("@n8n/workflow-sdk/prompts/node-selection");
|
|
7
6
|
const sdk_reference_1 = require("@n8n/workflow-sdk/prompts/sdk-reference");
|
|
8
7
|
const shared_prompts_1 = require("../../agent/shared-prompts");
|
|
@@ -33,11 +32,14 @@ const SDK_CODE_RULES = `## SDK Code Rules
|
|
|
33
32
|
- Use \`expr('{{ $json.field }}')\` for n8n expressions. Variables MUST be inside \`{{ }}\`.
|
|
34
33
|
- Do NOT use \`as const\` assertions — the workflow parser only supports JavaScript syntax, not TypeScript-only features. Just use plain string literals.
|
|
35
34
|
- Use string values directly for discriminator fields like \`resource\` and \`operation\` (e.g., \`resource: 'message'\` not \`resource: 'message' as const\`).
|
|
36
|
-
- When editing a pre-loaded workflow, **remove \`position\` arrays** from node configs — they are auto-calculated
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
- When editing a pre-loaded workflow, **remove \`position\` arrays** from node configs — they are auto-calculated.`;
|
|
36
|
+
const NODE_CONFIGURATION_SAFETY_RULES = `## Node Configuration Safety Rules
|
|
37
|
+
|
|
38
|
+
- Fetch \`nodes(action="type-definition")\` before configuring nodes. Generated definitions and \`@builderHint\` annotations are the source of truth.
|
|
39
|
+
- Use live \`nodes(action="explore-resources")\` for resource locator, list, and model fields when credentials are available.
|
|
40
|
+
- If a configuration is unclear after reading the definition, ask for clarification or use placeholders — do not guess.`;
|
|
41
|
+
function buildBuilderSpecificPatterns() {
|
|
42
|
+
const openAiCredExample = "newCredential('OpenAI')";
|
|
41
43
|
return `## Critical Patterns (Common Mistakes)
|
|
42
44
|
|
|
43
45
|
**Pay attention to @builderHint annotations in search results and type definitions** — these provide critical guidance on how to correctly configure node parameters. Write them out as notes when reviewing — they prevent common configuration mistakes.
|
|
@@ -53,6 +55,16 @@ After writing any workflow with IF, Switch, or Filter nodes, verify:
|
|
|
53
55
|
|
|
54
56
|
### AI Agent with Subnodes — use factory functions in subnodes config
|
|
55
57
|
\`\`\`javascript
|
|
58
|
+
const chatTrigger = trigger({
|
|
59
|
+
type: '@n8n/n8n-nodes-langchain.chatTrigger',
|
|
60
|
+
version: 1.3,
|
|
61
|
+
config: {
|
|
62
|
+
name: 'Chat Trigger',
|
|
63
|
+
parameters: { public: false },
|
|
64
|
+
output: [{ sessionId: 'chat-session-id', chatInput: 'Hello' }]
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
56
68
|
const model = languageModel({
|
|
57
69
|
type: '@n8n/n8n-nodes-langchain.lmChatOpenAi',
|
|
58
70
|
version: 1.3,
|
|
@@ -75,6 +87,19 @@ const parser = outputParser({
|
|
|
75
87
|
}
|
|
76
88
|
});
|
|
77
89
|
|
|
90
|
+
const memoryNode = memory({
|
|
91
|
+
type: '@n8n/n8n-nodes-langchain.memoryBufferWindow',
|
|
92
|
+
version: 1.3,
|
|
93
|
+
config: {
|
|
94
|
+
name: 'Conversation Memory',
|
|
95
|
+
parameters: {
|
|
96
|
+
sessionIdType: 'customKey',
|
|
97
|
+
sessionKey: nodeJson(chatTrigger, 'sessionId'),
|
|
98
|
+
contextWindowLength: 10
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
78
103
|
const agent = node({
|
|
79
104
|
type: '@n8n/n8n-nodes-langchain.agent',
|
|
80
105
|
version: 3.1,
|
|
@@ -86,11 +111,12 @@ const agent = node({
|
|
|
86
111
|
hasOutputParser: true,
|
|
87
112
|
options: { systemMessage: 'You are an expert...' }
|
|
88
113
|
},
|
|
89
|
-
subnodes: { model: model, outputParser: parser }
|
|
114
|
+
subnodes: { model: model, memory: memoryNode, outputParser: parser }
|
|
90
115
|
}
|
|
91
116
|
});
|
|
92
117
|
\`\`\`
|
|
93
118
|
WRONG: \`.to(agent, { connectionType: 'ai_languageModel' })\` — subnodes MUST be in the config object.
|
|
119
|
+
For values inside AI subnodes, use explicit references such as \`nodeJson(triggerNode, 'sessionId')\` instead of \`$json.sessionId\`. For Chat Trigger memory specifically, \`sessionIdType: 'fromInput'\` is also valid.
|
|
94
120
|
|
|
95
121
|
### Code Node
|
|
96
122
|
\`\`\`javascript
|
|
@@ -192,10 +218,6 @@ export default workflow('id', 'name')
|
|
|
192
218
|
.add(scheduleTrigger).to(processNode);
|
|
193
219
|
\`\`\`
|
|
194
220
|
|
|
195
|
-
### Web App (SPA served from a webhook)
|
|
196
|
-
|
|
197
|
-
When the workflow serves HTML from a webhook (dashboards, admin UIs, custom forms), call \`templates(action="best-practices", technique="web_app")\` for the full file-based HTML pattern, data-injection recipe, multi-route architecture, and a complete multi-route dashboard example. Embedding large HTML inline in Code nodes breaks at ~20KB — always use the file-based pattern from the guide.
|
|
198
|
-
|
|
199
221
|
### Google Sheets — documentId and sheetName (RLC fields)
|
|
200
222
|
|
|
201
223
|
These are Resource Locator fields that require the \`__rl\` object format:
|
|
@@ -224,50 +246,43 @@ ${node_selection_1.CONNECTION_CHANGING_PARAMETERS}
|
|
|
224
246
|
### Baseline Flow Control Nodes
|
|
225
247
|
${node_selection_1.BASELINE_FLOW_CONTROL}`;
|
|
226
248
|
}
|
|
227
|
-
const
|
|
228
|
-
const BUILDER_SPECIFIC_PATTERNS_SANDBOX = buildBuilderSpecificPatterns('sandbox');
|
|
249
|
+
const BUILDER_SPECIFIC_PATTERNS = buildBuilderSpecificPatterns();
|
|
229
250
|
const SANDBOX_WORKFLOW_RULES = `Follow these rules strictly when generating workflows:
|
|
230
251
|
|
|
231
|
-
1. **
|
|
232
|
-
-
|
|
233
|
-
-
|
|
234
|
-
-
|
|
252
|
+
1. **Use \`newCredential()\` for authentication**
|
|
253
|
+
- 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
|
|
254
|
+
- 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
|
|
255
|
+
- NEVER invent credential IDs, placeholder strings, fake API keys, or hardcoded auth values
|
|
256
|
+
- Example: \`credentials: { slackApi: newCredential('Slack Bot') }\`
|
|
235
257
|
- The key (e.g. \`slackApi\`) is the credential **type** from the node type definition
|
|
236
258
|
|
|
237
|
-
2. **
|
|
238
|
-
-
|
|
239
|
-
-
|
|
240
|
-
-
|
|
241
|
-
-
|
|
242
|
-
-
|
|
259
|
+
2. **Trust empty item lists — don't synthesize fake items**
|
|
260
|
+
- 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.
|
|
261
|
+
- 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.
|
|
262
|
+
- 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.
|
|
263
|
+
- \`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.
|
|
264
|
+
- 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.
|
|
243
265
|
|
|
244
266
|
3. **Use \`executeOnce: true\` for single-execution nodes**
|
|
245
267
|
- When a node receives N items but should only execute once (not N times), set \`executeOnce: true\`
|
|
246
268
|
- Common cases: sending a summary notification, generating a report, calling an API that doesn't need per-item execution
|
|
247
|
-
- Example: \`config: { ..., executeOnce: true }
|
|
269
|
+
- Example: \`config: { ..., executeOnce: true }\`
|
|
270
|
+
|
|
271
|
+
4. **Pick the right control-flow primitive**
|
|
272
|
+
- **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.
|
|
273
|
+
- **Drop items that don't match a predicate** → \`filter\`. It emits 0 items when nothing matches, and the chain stops cleanly.
|
|
274
|
+
- **Two mutually exclusive paths that both do real work** → \`IF\` (\`onTrue\` / \`onFalse\`).
|
|
275
|
+
- **Many mutually exclusive paths keyed off a value** → \`switch\` (\`onCase\`).
|
|
276
|
+
- 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.`;
|
|
248
277
|
function composeSdkRulesAndPatterns(mode) {
|
|
249
|
-
const sandboxOverride = mode === 'sandbox'
|
|
250
|
-
? "> **Sandbox credential override**: The SDK pattern examples below use `newCredential('X')`. " +
|
|
251
|
-
"In sandbox mode, replace every `newCredential('X')` with the raw `{ id, name }` object from " +
|
|
252
|
-
'`credentials(action="list")`. `newCredential()` serializes to `undefined` in sandbox and will ' +
|
|
253
|
-
'silently drop credentials from the saved workflow.'
|
|
254
|
-
: null;
|
|
255
278
|
return [
|
|
256
279
|
SDK_CODE_RULES,
|
|
257
280
|
mode === 'sandbox' ? SANDBOX_WORKFLOW_RULES : sdk_reference_1.WORKFLOW_RULES,
|
|
258
|
-
...(sandboxOverride ? [sandboxOverride] : []),
|
|
259
281
|
'## SDK Patterns Reference\n\n' + sdk_reference_1.WORKFLOW_SDK_PATTERNS,
|
|
260
282
|
'## Expression Reference\n\n' + sdk_reference_1.EXPRESSION_REFERENCE,
|
|
261
283
|
'## Additional Functions\n\n' + sdk_reference_1.ADDITIONAL_FUNCTIONS,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
parameter_guides_1.SWITCH_NODE_GUIDE.content,
|
|
265
|
-
parameter_guides_1.SET_NODE_GUIDE.content,
|
|
266
|
-
parameter_guides_1.HTTP_REQUEST_GUIDE.content,
|
|
267
|
-
parameter_guides_1.TOOL_NODES_GUIDE.content,
|
|
268
|
-
parameter_guides_1.EMBEDDING_NODES_GUIDE.content,
|
|
269
|
-
parameter_guides_1.RESOURCE_LOCATOR_GUIDE.content,
|
|
270
|
-
mode === 'sandbox' ? BUILDER_SPECIFIC_PATTERNS_SANDBOX : BUILDER_SPECIFIC_PATTERNS_TOOL,
|
|
284
|
+
NODE_CONFIGURATION_SAFETY_RULES,
|
|
285
|
+
BUILDER_SPECIFIC_PATTERNS,
|
|
271
286
|
].join('\n\n');
|
|
272
287
|
}
|
|
273
288
|
const SDK_RULES_AND_PATTERNS_TOOL = composeSdkRulesAndPatterns('tool');
|
|
@@ -294,10 +309,11 @@ ${shared_prompts_1.PLACEHOLDERS_RULE}
|
|
|
294
309
|
Do NOT produce visible output until step 5. All reasoning happens internally.
|
|
295
310
|
|
|
296
311
|
## Credential Rules (tool mode)
|
|
297
|
-
-
|
|
298
|
-
-
|
|
312
|
+
- Use \`newCredential('Credential Name', 'credential-id')\` only when the user selected a specific existing credential or the workflow already has one.
|
|
313
|
+
- 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.
|
|
314
|
+
- NEVER use raw credential objects like \`{ id: '...', name: '...' }\` in tool mode.
|
|
299
315
|
- When editing a pre-loaded workflow, the roundtripped code may have credentials as raw objects — replace them with \`newCredential()\` calls.
|
|
300
|
-
- Unresolved credentials (where the user chose mock data
|
|
316
|
+
- 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.
|
|
301
317
|
|
|
302
318
|
${SDK_RULES_AND_PATTERNS_TOOL}
|
|
303
319
|
`;
|
|
@@ -408,7 +424,7 @@ Supported input types: \`string\`, \`number\`, \`boolean\`, \`array\`, \`object\
|
|
|
408
424
|
### Step 2: Submit and test the chunk
|
|
409
425
|
|
|
410
426
|
1. Write the chunk file, then submit it: \`submit-workflow\` with the chunk file path.
|
|
411
|
-
- Sub-workflows with \`executeWorkflowTrigger\` can be tested immediately via \`executions(action="run")
|
|
427
|
+
- Sub-workflows with \`executeWorkflowTrigger\` can be tested immediately via \`executions(action="run")\`.
|
|
412
428
|
2. Run the chunk: \`executions(action="run")\` with \`inputData\` matching the trigger schema.
|
|
413
429
|
- **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\`.
|
|
414
430
|
- **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.
|
|
@@ -461,14 +477,13 @@ Replace \`CHUNK_WORKFLOW_ID\` with the actual ID returned by \`submit-workflow\`
|
|
|
461
477
|
|
|
462
478
|
${shared_prompts_1.PLACEHOLDERS_RULE}
|
|
463
479
|
|
|
464
|
-
##
|
|
480
|
+
## Missing Resources
|
|
465
481
|
|
|
466
482
|
When \`nodes(action="explore-resources")\` returns no results for a required resource:
|
|
467
483
|
|
|
468
|
-
1.
|
|
469
|
-
2.
|
|
470
|
-
3.
|
|
471
|
-
4. Use that real resource ID in the main workflow
|
|
484
|
+
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
|
|
485
|
+
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
|
|
486
|
+
3. Otherwise, leave the main workflow as a saved draft and mention the missing resource in the one-line completion summary
|
|
472
487
|
|
|
473
488
|
**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.
|
|
474
489
|
|
|
@@ -486,7 +501,7 @@ ${shared_prompts_1.ASK_USER_FALLBACK}
|
|
|
486
501
|
- You CANNOT find or use n8n API keys — they do not exist in the sandbox environment
|
|
487
502
|
- Do NOT spend time searching for API keys, config files, environment variables, or process info — none of it is accessible
|
|
488
503
|
|
|
489
|
-
**All interaction with n8n is through the provided tools:** \`submit-workflow\`, \`executions(action="run" | "debug" | "get")\`, \`credentials(action="list" | "test")\`, \`nodes(action="explore-resources")\`, \`workflows(action="
|
|
504
|
+
**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.
|
|
490
505
|
|
|
491
506
|
## Sandbox-Specific Rules
|
|
492
507
|
|
|
@@ -496,18 +511,30 @@ ${shared_prompts_1.ASK_USER_FALLBACK}
|
|
|
496
511
|
|
|
497
512
|
## Credentials (sandbox mode)
|
|
498
513
|
|
|
499
|
-
Sandbox mode uses
|
|
514
|
+
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:
|
|
500
515
|
|
|
501
516
|
\`\`\`typescript
|
|
502
517
|
credentials: {
|
|
503
|
-
openWeatherMapApi:
|
|
518
|
+
openWeatherMapApi: newCredential('OpenWeatherMap account', 'yXYBqho73obh58ZS')
|
|
504
519
|
}
|
|
505
520
|
\`\`\`
|
|
506
521
|
|
|
507
|
-
|
|
522
|
+
For credentials that are not selected yet, keep the credential type key and omit the ID:
|
|
523
|
+
|
|
524
|
+
\`\`\`typescript
|
|
525
|
+
credentials: {
|
|
526
|
+
openWeatherMapApi: newCredential('OpenWeatherMap account')
|
|
527
|
+
}
|
|
528
|
+
\`\`\`
|
|
529
|
+
|
|
530
|
+
The key (\`openWeatherMapApi\`) is the credential **type** from the node type definition. Exact IDs and names come from \`credentials(action="list")\`.
|
|
531
|
+
|
|
532
|
+
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.
|
|
508
533
|
|
|
509
534
|
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\`.
|
|
510
535
|
|
|
536
|
+
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.
|
|
537
|
+
|
|
511
538
|
## Data Tables
|
|
512
539
|
|
|
513
540
|
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.
|
|
@@ -518,13 +545,12 @@ n8n normalizes column names to snake_case (e.g., \`dayName\` → \`day_name\`).
|
|
|
518
545
|
- **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.
|
|
519
546
|
- **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.
|
|
520
547
|
- **Follow the runtime verification instructions in your briefing.** If the briefing says verification is required, do not stop after a successful submit.
|
|
521
|
-
- **Do NOT call \`workflows(action="publish")\`.** Publishing is the user's decision after they have tested the workflow. Your job ends at a successful submit.
|
|
522
548
|
|
|
523
549
|
## Mandatory Process
|
|
524
550
|
|
|
525
551
|
### For simple workflows (< 5 nodes, single integration):
|
|
526
552
|
|
|
527
|
-
1. **Discover credentials**: Call \`credentials(action="list")\`. Note each credential's \`id\`, \`name\`, and \`type\`.
|
|
553
|
+
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.
|
|
528
554
|
|
|
529
555
|
2. **Discover nodes**:
|
|
530
556
|
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.
|
|
@@ -540,11 +566,11 @@ n8n normalizes column names to snake_case (e.g., \`dayName\` → \`day_name\`).
|
|
|
540
566
|
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.
|
|
541
567
|
**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.
|
|
542
568
|
|
|
543
|
-
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 credential from step 1 to discover real resource IDs.
|
|
569
|
+
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.
|
|
544
570
|
- **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.
|
|
545
571
|
- **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.
|
|
546
572
|
- 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".
|
|
547
|
-
- **Never use
|
|
573
|
+
- **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".
|
|
548
574
|
- **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; the setup wizard surfaces placeholders so the user can choose after the build. Only pick a single match without prompting.
|
|
549
575
|
- 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.
|
|
550
576
|
|
|
@@ -569,16 +595,16 @@ Follow the **Compositional Workflow Pattern** above. The process becomes:
|
|
|
569
595
|
|
|
570
596
|
1. **Discover credentials** (same as above).
|
|
571
597
|
2. **Discover nodes and get schemas** (same as above).
|
|
572
|
-
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,
|
|
598
|
+
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.
|
|
573
599
|
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").
|
|
574
600
|
5. **For each chunk**:
|
|
575
601
|
a. Write the chunk to \`${workspaceRoot}/chunks/<name>.ts\` with an \`executeWorkflowTrigger\` and explicit input schema.
|
|
576
602
|
b. Run tsc.
|
|
577
|
-
c. Submit the chunk: \`submit-workflow\` with \`filePath\` pointing to the chunk file. Test via \`executions(action="run")
|
|
603
|
+
c. Submit the chunk: \`submit-workflow\` with \`filePath\` pointing to the chunk file. Test via \`executions(action="run")\`.
|
|
578
604
|
d. Fix if needed (max 2 submission fix attempts per chunk).
|
|
579
605
|
6. **Write the main workflow** in \`${workspaceRoot}/src/workflow.ts\` that composes chunks via \`executeWorkflow\` nodes, referencing each chunk's workflow ID.
|
|
580
606
|
7. **Submit** the main workflow.
|
|
581
|
-
8. **Done**: Output ONE sentence summarizing what was built, including the workflow ID and any known issues.
|
|
607
|
+
8. **Done**: Output ONE sentence summarizing what was built, including the workflow ID and any known issues.
|
|
582
608
|
|
|
583
609
|
Do NOT produce visible output until the final step. All reasoning happens internally.
|
|
584
610
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-workflow-agent.prompt.js","sourceRoot":"","sources":["../../../src/tools/orchestration/build-workflow-agent.prompt.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"build-workflow-agent.prompt.js","sourceRoot":"","sources":["../../../src/tools/orchestration/build-workflow-agent.prompt.ts"],"names":[],"mappings":";;;AAwWA,0EAoTC;AAppBD,6EAIkD;AAClD,2EAKiD;AAEjD,+DAAkF;AAIlF,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;0GAkBwE,CAAC;AAI3G,MAAM,cAAc,GAAG;;;;;;;;mHAQ4F,CAAC;AAEpH,MAAM,+BAA+B,GAAG;;;;wHAIgF,CAAC;AAKzH,SAAS,4BAA4B;IACpC,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;IACpD,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA+BwB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuK/C,iCAAgB;;;EAGhB,+CAA8B;;;EAG9B,sCAAqB,EAAE,CAAC;AAC1B,CAAC;AAED,MAAM,yBAAyB,GAAG,4BAA4B,EAAE,CAAC;AAQjE,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,+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;;;;;;;;;;;;;;;;;;EAkBjB,2BAA2B;CAC5B,CAAC;AAIF,SAAgB,+BAA+B,CAAC,aAAqB;IACpE,OAAO;;EAEN,yBAAyB;;;;0BAID,aAAa,6DAA6D,aAAa;;;EAG/G,aAAa;;;;;;;;;;;;;;;;;;KAkBV,aAAa;;;;;;;;;;;;;;;KAeb,aAAa;;;;;;;;;;;;;;;;;;;;;KAqBb,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsDb,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwChB,kCAAiB;;;;;;;;;;;;;;;;EAgBjB,kCAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sCAqEmB,aAAa;;;;;;;;;;;;;;kCAcjB,aAAa;;;;;;;;;;;;;;;;;;;;;;;;6BAwBlB,aAAa;;;;sCAIJ,aAAa;;;;;;;yFAOsC,aAAa;;;;;;;;;;;;;;EAcpG,8BAA8B;CAC/B,CAAC;AACF,CAAC"}
|
|
@@ -1,18 +1,62 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import type {
|
|
3
|
-
import { type
|
|
2
|
+
import type { OrchestrationContext } from '../../types';
|
|
3
|
+
import { type WorkflowBuildOutcome, type WorkflowSetupRequirement, type WorkflowVerificationReadiness, type WorkflowLoopState } from '../../workflow-loop';
|
|
4
|
+
import { type SubmitWorkflowAttempt, type SubmitWorkflowOutput } from '../workflows/submit-workflow.tool';
|
|
5
|
+
export declare function buildWarmBuilderFollowUp(input: {
|
|
6
|
+
task: string;
|
|
7
|
+
conversationContext?: string;
|
|
8
|
+
workflowId: string;
|
|
9
|
+
workItemId: string;
|
|
10
|
+
}): string;
|
|
4
11
|
export declare function recordSuccessfulWorkflowBuilds(tool: unknown, onWorkflowId: (workflowId: string) => void): void;
|
|
12
|
+
export type OutcomeForVerificationReadiness = Pick<WorkflowBuildOutcome, 'submitted' | 'workflowId' | 'triggerNodes' | 'mockedCredentialTypes' | 'mockedCredentialsByNode' | 'verificationPinData' | 'usesWorkflowPinDataForVerification' | 'hasUnresolvedPlaceholders' | 'verification' | 'remediation'>;
|
|
13
|
+
export declare function determineVerificationReadiness(outcome: OutcomeForVerificationReadiness): WorkflowVerificationReadiness;
|
|
14
|
+
export declare function determineSetupRequirement(outcome: OutcomeForVerificationReadiness): WorkflowSetupRequirement;
|
|
15
|
+
export declare function mergeLatestVerificationIntoOutcome(outcome: WorkflowBuildOutcome, latestOutcome: WorkflowBuildOutcome | undefined): WorkflowBuildOutcome;
|
|
16
|
+
export declare function withTerminalLoopState(outcome: WorkflowBuildOutcome, state: WorkflowLoopState | undefined): WorkflowBuildOutcome;
|
|
17
|
+
export declare function finalizeBuildResult(context: OrchestrationContext, workItemId: string, result: {
|
|
18
|
+
text: string;
|
|
19
|
+
outcome: WorkflowBuildOutcome;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
text: string;
|
|
22
|
+
outcome: WorkflowBuildOutcome;
|
|
23
|
+
}>;
|
|
24
|
+
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\")` 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.\n- Otherwise pick based on trigger type:\n - **Manual / Schedule** \u2014 `executions(action=\"run\")`.\n - **Form Trigger** \u2014 `verify-built-workflow` with `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 when a matching explicit credential is attached (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";
|
|
25
|
+
export declare function supportingWorkflowIdsFromSubmitAttempts(submitAttempts: SubmitWorkflowAttempt[], mainWorkflowPath: string, mainWorkflowId: string | undefined, referencedWorkflowIds?: string[]): string[];
|
|
5
26
|
export declare function resultFromPostStreamError(input: {
|
|
6
27
|
error: unknown;
|
|
7
28
|
submitAttempts: SubmitWorkflowAttempt[];
|
|
8
29
|
mainWorkflowPath: string;
|
|
9
30
|
workItemId: string;
|
|
31
|
+
runId: string;
|
|
32
|
+
taskId: string;
|
|
33
|
+
}): {
|
|
34
|
+
text: string;
|
|
35
|
+
outcome: WorkflowBuildOutcome;
|
|
36
|
+
} | undefined;
|
|
37
|
+
export declare function resultFromLaterFailedMainSubmit(input: {
|
|
38
|
+
failedAttempt: SubmitWorkflowAttempt;
|
|
39
|
+
submitAttempts: SubmitWorkflowAttempt[];
|
|
40
|
+
mainWorkflowPath: string;
|
|
41
|
+
workItemId: string;
|
|
42
|
+
runId: string;
|
|
10
43
|
taskId: string;
|
|
11
|
-
}):
|
|
44
|
+
}): {
|
|
45
|
+
text: string;
|
|
46
|
+
outcome: WorkflowBuildOutcome;
|
|
47
|
+
} | undefined;
|
|
48
|
+
export declare function attemptFromAutoResubmit(input: {
|
|
49
|
+
latestAttempt: SubmitWorkflowAttempt | undefined;
|
|
50
|
+
resubmit: SubmitWorkflowOutput;
|
|
51
|
+
filePath: string;
|
|
52
|
+
sourceHash: string;
|
|
53
|
+
}): SubmitWorkflowAttempt | undefined;
|
|
54
|
+
export declare function shouldRecoverSavedWorkflowAfterFailedSubmit(attempt: SubmitWorkflowAttempt): boolean;
|
|
12
55
|
export interface StartBuildWorkflowAgentInput {
|
|
13
56
|
task: string;
|
|
14
57
|
workflowId?: string;
|
|
15
58
|
conversationContext?: string;
|
|
59
|
+
workItemId?: string;
|
|
16
60
|
taskId?: string;
|
|
17
61
|
agentId?: string;
|
|
18
62
|
plannedTaskId?: string;
|
|
@@ -27,13 +71,22 @@ export declare const buildWorkflowAgentInputSchema: z.ZodObject<{
|
|
|
27
71
|
task: z.ZodString;
|
|
28
72
|
workflowId: z.ZodOptional<z.ZodString>;
|
|
29
73
|
conversationContext: z.ZodOptional<z.ZodString>;
|
|
74
|
+
workItemId: z.ZodOptional<z.ZodString>;
|
|
75
|
+
bypassPlan: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
30
77
|
}, "strip", z.ZodTypeAny, {
|
|
31
78
|
task: string;
|
|
79
|
+
reason?: string | undefined;
|
|
32
80
|
workflowId?: string | undefined;
|
|
81
|
+
workItemId?: string | undefined;
|
|
33
82
|
conversationContext?: string | undefined;
|
|
83
|
+
bypassPlan?: boolean | undefined;
|
|
34
84
|
}, {
|
|
35
85
|
task: string;
|
|
86
|
+
reason?: string | undefined;
|
|
36
87
|
workflowId?: string | undefined;
|
|
88
|
+
workItemId?: string | undefined;
|
|
37
89
|
conversationContext?: string | undefined;
|
|
90
|
+
bypassPlan?: boolean | undefined;
|
|
38
91
|
}>;
|
|
39
92
|
export declare function createBuildWorkflowAgentTool(context: OrchestrationContext): import("@mastra/core/tools").Tool<InferPublicSchema<T>, InferPublicSchema<T>, InferPublicSchema<T>, InferPublicSchema<T>, import("@mastra/core/tools").ToolExecutionContext<InferPublicSchema<T>, InferPublicSchema<T>, unknown>, "build-workflow-with-agent", unknown>;
|