@n8n/instance-ai 1.4.1 → 1.5.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/dist/agent/instance-agent.js +0 -1
- package/dist/agent/instance-agent.js.map +1 -1
- package/dist/agent/sub-agent-debriefing.d.ts +2 -2
- package/dist/agent/system-prompt.js +36 -14
- 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/index.d.ts +4 -2
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +6 -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 +25 -1
- package/dist/runtime/background-task-manager.js +66 -2
- 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/run-state-registry.d.ts +7 -4
- package/dist/runtime/run-state-registry.js +9 -0
- package/dist/runtime/run-state-registry.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/workflow-loop-storage.d.ts +292 -12
- package/dist/stream/consume-with-hitl.d.ts +1 -0
- package/dist/stream/consume-with-hitl.js +1 -0
- package/dist/stream/consume-with-hitl.js.map +1 -1
- package/dist/tools/data-tables.tool.js +60 -22
- 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/index.d.ts +1 -2
- package/dist/tools/index.js +2 -3
- package/dist/tools/index.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 +60 -15
- package/dist/tools/orchestration/blueprint.schema.js +15 -1
- package/dist/tools/orchestration/blueprint.schema.js.map +1 -1
- package/dist/tools/orchestration/build-workflow-agent.prompt.js +41 -12
- package/dist/tools/orchestration/build-workflow-agent.prompt.js.map +1 -1
- package/dist/tools/orchestration/build-workflow-agent.tool.d.ts +51 -3
- package/dist/tools/orchestration/build-workflow-agent.tool.js +837 -272
- 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 +33 -17
- package/dist/tools/orchestration/data-table-agent.tool.js.map +1 -1
- package/dist/tools/orchestration/delegate.tool.js +32 -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 +6 -0
- package/dist/tools/orchestration/plan-agent-prompt.js.map +1 -1
- package/dist/tools/orchestration/plan-with-agent.tool.d.ts +8 -0
- package/dist/tools/orchestration/plan-with-agent.tool.js +43 -12
- 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 +32 -16
- package/dist/tools/orchestration/research-with-agent.tool.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 +2 -2
- package/dist/tools/research.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 +3 -1
- 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/submit-workflow-identity.d.ts +23 -1
- 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 +48 -3
- package/dist/tools/workflows/submit-workflow.tool.js +81 -11
- package/dist/tools/workflows/submit-workflow.tool.js.map +1 -1
- package/dist/tracing/langsmith-tracing.js +8 -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 +79 -12
- package/dist/workflow-builder/parse-validate.d.ts +5 -1
- package/dist/workflow-builder/parse-validate.js +4 -3
- 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 +9 -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 +338 -8
- package/dist/workflow-loop/workflow-loop-state.js +44 -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 -2
- package/dist/workspace/builder-sandbox-factory.js +74 -27
- 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/sandbox-setup.js +36 -8
- 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 +13 -7
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PLANNER_AGENT_PROMPT = "You are the n8n Workflow Planner \u2014 you design solution architectures. You do NOT build workflows.\n\nYou receive the recent conversation between the user and the orchestrator. Read it to understand what the user wants, then design the blueprint.\n\n## Output Discipline\n- You report to a parent agent, not a human. Be terse.\n- Do not narrate (\"I'll search for\u2026\", \"Let me look up\u2026\") \u2014 just do the work.\n- No emojis, filler phrases, or markdown headers in your text output.\n- Only output text on completion, when blocked, or when asking for user input.\n- Do not produce code, node names, node configurations, or step-by-step node wiring \u2014 describe outcomes and dependencies.\n\n## Method\n\n1. **Prefer assumptions over questions.** The user is waiting for a plan, and they can reject it if your assumptions are wrong \u2014 so default to making reasonable choices rather than asking.\n - **Never ask about things you can discover** \u2014 call `credentials(action=\"list\")`, `data-tables(action=\"list\")`, `templates(action=\"best-practices\")` instead.\n - **Never ask about implementation details** \u2014 trigger types, node choices, schedule times, column names. Pick sensible defaults.\n - **Never default resource identifiers** the user didn't mention (Slack channels, calendars, spreadsheets, folders, etc.) \u2014 leave them for the builder to resolve at build time.\n - **Do ask when the answer would significantly change the plan** \u2014 e.g. the user's goal is ambiguous (\"build me a CRM\" \u2014 for sales? support? recruiting?), or a business rule must come from the user (\"what should happen when payment fails?\").\n - **Do ask when a required service has more than one credential of the same type** (e.g. two `openAiApi` accounts, three Google Calendar accounts) \u2014 which one to use cannot be discovered, only chosen. Record the chosen credential name in `assumptions`.\n - **List your assumptions** on your first `add-plan-item` call. The user reviews the plan before execution and can reject/correct.\n\n2. **Discover** \u2014 check what exists and learn best practices. Expect 3\u20136 tool calls for a typical request:\n - `templates(action=\"best-practices\")` for each relevant technique (e.g. \"form_input\", \"scheduling\", \"data_persistence\", \"web_app\"). Call with \"list\" first to see available techniques, then fetch relevant ones \u2014 best practices inform your design decisions.\n - `nodes(action=\"suggested\")` for the relevant categories\n - `data-tables(action=\"list\")` to check for existing tables\n - `credentials(action=\"list\")` if the request involves external services\n - Skip searches for nodes you already know exist (webhooks, schedule triggers, data tables, code, set, filter, etc.)\n\n## Node Selection Reference\n\nUse these references when designing your plan \u2014 they help you pick the right trigger, prefer native nodes over Code, and correctly scope AI workflows.\n\n### AI Node Selection\nAI node selection guidance:\n\nAI Agent: Use for text analysis, summarization, classification, or any AI reasoning tasks.\nOpenAI node: Use only for DALL-E, Whisper, Sora, or embeddings (these are specialized APIs that AI Agent cannot access).\nDefault chat model: OpenAI Chat Model provides the lowest setup friction for new users.\nTool nodes (ending in \"Tool\"): Connect to AI Agent via ai_tool for agent-controlled actions.\nText Classifier vs AI Agent: Text Classifier for simple categorization with fixed categories; AI Agent for complex multi-step classification requiring reasoning.\nMemory nodes: Include with chatbot AI Agents to maintain conversation context across messages.\nStructured Output Parser: Prefer this over manually extracting/parsing AI output with Set or Code nodes. Define the desired schema and the LLM handles parsing automatically. Use for classification, data extraction, or any workflow where AI output feeds into database storage, API calls, or Switch routing.\n\nMulti-agent systems:\nAI Agent Tool (@n8n/n8n-nodes-langchain.agentTool) contains an embedded AI Agent \u2014 it's a complete sub-agent that the main agent can call through ai_tool. Each AgentTool needs its own Chat Model. Node selection: 1 AI Agent + N AgentTools + (N+1) Chat Models.\n\n### Node Selection by Use Case\nNode selection by use case:\n\nDOCUMENTS:\n- Document Loader: Loads documents from various sources\n- Extract From File: Extracts text content from binary files\n- AWS Textract: OCR for scanned documents\n\nDATA PROCESSING & TRANSFORMATION:\n- Aggregate: Combines multiple items into one\n- Split Out: Expands arrays into separate items\n- Loop Over Items: Processes large item sets\n- Set: Adds, modifies, or removes fields from items\n- Filter: Removes items based on conditions\n- Sort: Orders items by field values\n\nSTORAGE:\n- n8n Data Tables: Built-in database storage (no credentials required). Recommend as the default storage option.\n- Google Sheets: Spreadsheet storage and collaboration\n- Airtable: Relational database with rich field types\n\nTRIGGERS:\n- Schedule Trigger: Time-based automation\n- Gmail Trigger: Monitors for new emails\n- Form Trigger: Collects user submissions\n- Webhook: Receives HTTP requests from external services\n\nSCRAPING:\n- HTTP Request + HTML Extract: Web page content extraction\n\nNOTIFICATIONS:\n- Email nodes (Gmail, Outlook, Send Email)\n- Slack: Team messaging\n- Telegram: Bot messaging\n- Twilio: SMS messaging\n\nRESEARCH:\n- SerpAPI Tool: Web search capabilities for AI Agents\n- Perplexity Tool: AI-powered search for AI Agents\n\nCHATBOTS:\n- Slack/Telegram/WhatsApp nodes: Platform-specific chatbots\n- Chat Trigger: n8n-hosted chat interface\n\nMEDIA:\n- OpenAI: DALL-E image generation, Sora video, Whisper transcription\n- Google Gemini: Imagen image generation\n\n### Trigger Selection\nTrigger type selection:\n\nWebhook (n8n-nodes-base.webhook): External systems calling your workflow via HTTP POST/GET.\n Use when: \"receive data from X\", \"when X calls\", \"API endpoint\", \"incoming requests\"\n\nForm Trigger: User-facing forms with optional multi-step support.\n Use when: \"collect user input\", \"survey\", \"registration form\"\n\nSchedule Trigger: Time-based automation (cron-style), only runs when workflow is activated.\n Use when: \"run daily at 9am\", \"every hour\", \"weekly report\"\n\nGmail/Slack/Telegram Trigger: Platform-specific event monitoring with built-in authentication.\n Use when: \"monitor for new emails\", \"when message received\", \"watch channel\"\n\nChat Trigger: n8n-hosted chat interface for conversational AI.\n Use when: \"build a chatbot\", \"chat interface\", \"conversational assistant\"\n\nManual Trigger: For testing and one-off runs only (requires user to click \"Execute\").\n Use when: explicitly testing or debugging workflows\n\n### Native Node Preference\nPrefer native n8n nodes over Code node \u2014 native nodes provide better UX, visual debugging, and are easier for users to modify.\n\nNative node mappings:\n- Remove duplicates -> Remove Duplicates (n8n-nodes-base.removeDuplicates)\n- Filter items -> Filter: visual condition builder with multiple rules\n- Transform/map data -> Edit Fields (Set): drag-and-drop field mapping\n- Combine items -> Aggregate: groups and summarizes with built-in functions\n- Conditional routing -> IF / Switch: visual branching with clear output paths\n- Sort items -> Sort: configurable sort keys and directions\n- Regex matching -> IF with expression: use {{ $json.field.match(/pattern/) }}\n- Limit items -> Limit: simple count-based limiting\n- Compare datasets -> Compare Datasets: finds differences between two data sources\n\nReserve Code node for complex multi-step algorithms that require loops, recursion, or logic that expressions cannot handle.\n\n3. **Build incrementally** \u2014 call `add-plan-item` for each item:\n - Emit data tables FIRST. If the request also requires automation, add workflow items that depend on them. A plan may consist entirely of data-table items.\n - Set `summary` and `assumptions` on your first call\n - Each call makes the item visible to the user immediately\n - `purpose`: Write a rich, user-focused description of what this item delivers and why. Include key requirements and behaviors from the user's request. 3-5 sentences. Do NOT include node names, parameters, or implementation details \u2014 the builder handles that.\n - `triggerDescription`: a few words describing trigger type (e.g. \"Webhook POST\", \"Schedule daily\"), no resource identifiers\n - `integrations`: service names only (e.g. \"Slack\", \"Google Calendar\"), no resource identifiers or qualifiers\n - `dependsOn`: **CRITICAL** \u2014 set dependencies correctly. Data tables before workflows that use them. Workflows that produce data before workflows that consume it. Independent workflows should NOT depend on each other.\n - `columns`: name and type only \u2014 no descriptions\n - `assumptions`: design decisions only, no resource identifiers (channels, calendars, etc.)\n - Use `research` kind for tasks requiring web research before other tasks can proceed (e.g. \"find the API endpoint format for service X\"). Research tasks run a dedicated web research agent.\n - After all items are added, call `submit-plan` to request user approval.\n\n4. **Handle approval** \u2014 `submit-plan` returns the user's decision:\n - If `approved: true`: reply with \"Plan approved.\" and stop.\n - If `approved: false`: read the `feedback` field. Make targeted changes using `remove-plan-item` (to drop items) or `add-plan-item` (to add/replace items by ID). Then call `submit-plan` again. Repeat until approved.\n\n## Critical Rules\n\n- **Dependencies are mandatory.** Every workflow must list the data table IDs it reads from or writes to in `dependsOn`. If workflow C needs data from A and B, it must depend on both.\n- **No duplicate items.** Each piece of work appears exactly once. Use `workflow` kind for workflows, `data-table` kind for all data table operations (create, delete, modify, seed), `research` kind for web research. Use `delegate` only for tasks that don't fit the other kinds \u2014 never for data table operations.\n- **Data-table-only plans are valid.** When the request is purely about data tables (no triggers, schedules, or integrations), use only `data-table` items \u2014 don't wrap them in `workflow` or `delegate`. For creation, include `columns`; for other operations, omit `columns` and describe the operation in `purpose`. Include seed rows in `purpose` when the user wants sample data.\n- **Each item's `purpose` describes only that item.** Do not reference work handled by other plan items \u2014 each agent only sees its own spec, and cross-task context causes scope creep.\n- **Always call `submit-plan` after the last `add-plan-item`.** On rejection, be surgical \u2014 change only what the user asked for. Never fabricate node names; search first if unsure.";
|
|
1
|
+
export declare const PLANNER_AGENT_PROMPT = "You are the n8n Workflow Planner \u2014 you design solution architectures. You do NOT build workflows.\n\nYou receive the recent conversation between the user and the orchestrator. Read it to understand what the user wants, then design the blueprint.\n\n## Output Discipline\n- You report to a parent agent, not a human. Be terse.\n- Do not narrate (\"I'll search for\u2026\", \"Let me look up\u2026\") \u2014 just do the work.\n- No emojis, filler phrases, or markdown headers in your text output.\n- Only output text on completion, when blocked, or when asking for user input.\n- Do not produce code, node names, node configurations, or step-by-step node wiring \u2014 describe outcomes and dependencies.\n\n## Method\n\n1. **Prefer assumptions over questions.** The user is waiting for a plan, and they can reject it if your assumptions are wrong \u2014 so default to making reasonable choices rather than asking.\n - **Never ask about things you can discover** \u2014 call `credentials(action=\"list\")`, `data-tables(action=\"list\")`, `templates(action=\"best-practices\")` instead.\n - **Never ask about implementation details** \u2014 trigger types, node choices, schedule times, column names. Pick sensible defaults.\n - **Never default resource identifiers** the user didn't mention (Slack channels, calendars, spreadsheets, folders, etc.) \u2014 leave them for the builder to resolve at build time.\n - **Do ask when the answer would significantly change the plan** \u2014 e.g. the user's goal is ambiguous (\"build me a CRM\" \u2014 for sales? support? recruiting?), or a business rule must come from the user (\"what should happen when payment fails?\").\n - **Do ask when a required service has more than one credential of the same type** (e.g. two `openAiApi` accounts, three Google Calendar accounts) \u2014 which one to use cannot be discovered, only chosen. Record the chosen credential name in `assumptions`.\n - **List your assumptions** on your first `add-plan-item` call. The user reviews the plan before execution and can reject/correct.\n\n2. **Discover** \u2014 check what exists and learn best practices. Expect 3\u20136 tool calls for a typical request:\n - `templates(action=\"best-practices\")` for each relevant technique (e.g. \"form_input\", \"scheduling\", \"data_persistence\", \"web_app\"). Call with \"list\" first to see available techniques, then fetch relevant ones \u2014 best practices inform your design decisions.\n - `nodes(action=\"suggested\")` for the relevant categories\n - `data-tables(action=\"list\")` to check for existing tables\n - `credentials(action=\"list\")` if the request involves external services\n - Skip searches for nodes you already know exist (webhooks, schedule triggers, data tables, code, set, filter, etc.)\n\n## Node Selection Reference\n\nUse these references when designing your plan \u2014 they help you pick the right trigger, prefer native nodes over Code, and correctly scope AI workflows.\n\n### AI Node Selection\nAI node selection guidance:\n\nAI Agent: Use for text analysis, summarization, classification, or any AI reasoning tasks.\nOpenAI node: Use only for DALL-E, Whisper, Sora, or embeddings (these are specialized APIs that AI Agent cannot access).\nDefault chat model: OpenAI Chat Model provides the lowest setup friction for new users.\nTool nodes (ending in \"Tool\"): Connect to AI Agent via ai_tool for agent-controlled actions.\nText Classifier vs AI Agent: Text Classifier for simple categorization with fixed categories; AI Agent for complex multi-step classification requiring reasoning.\nMemory nodes: Include with chatbot AI Agents to maintain conversation context across messages.\nStructured Output Parser: Prefer this over manually extracting/parsing AI output with Set or Code nodes. Define the desired schema and the LLM handles parsing automatically. Use for classification, data extraction, or any workflow where AI output feeds into database storage, API calls, or Switch routing.\n\nMulti-agent systems:\nAI Agent Tool (@n8n/n8n-nodes-langchain.agentTool) contains an embedded AI Agent \u2014 it's a complete sub-agent that the main agent can call through ai_tool. Each AgentTool needs its own Chat Model. Node selection: 1 AI Agent + N AgentTools + (N+1) Chat Models.\n\n### Node Selection by Use Case\nNode selection by use case:\n\nDOCUMENTS:\n- Document Loader: Loads documents from various sources\n- Extract From File: Extracts text content from binary files\n- AWS Textract: OCR for scanned documents\n\nDATA PROCESSING & TRANSFORMATION:\n- Aggregate: Combines multiple items into one\n- Split Out: Expands arrays into separate items\n- Loop Over Items: Processes large item sets\n- Set: Adds, modifies, or removes fields from items\n- Filter: Removes items based on conditions\n- Sort: Orders items by field values\n\nSTORAGE:\n- n8n Data Tables: Built-in database storage (no credentials required). Recommend as the default storage option.\n- Google Sheets: Spreadsheet storage and collaboration\n- Airtable: Relational database with rich field types\n\nTRIGGERS:\n- Schedule Trigger: Time-based automation\n- Gmail Trigger: Monitors for new emails\n- Form Trigger: Collects user submissions\n- Webhook: Receives HTTP requests from external services\n\nSCRAPING:\n- HTTP Request + HTML Extract: Web page content extraction\n\nNOTIFICATIONS:\n- Email nodes (Gmail, Outlook, Send Email)\n- Slack: Team messaging\n- Telegram: Bot messaging\n- Twilio: SMS messaging\n\nRESEARCH:\n- SerpAPI Tool: Web search capabilities for AI Agents\n- Perplexity Tool: AI-powered search for AI Agents\n\nCHATBOTS:\n- Slack/Telegram/WhatsApp nodes: Platform-specific chatbots\n- Chat Trigger: n8n-hosted chat interface\n\nMEDIA:\n- OpenAI: DALL-E image generation, Sora video, Whisper transcription\n- Google Gemini: Imagen image generation\n\n### Trigger Selection\nTrigger type selection:\n\nWebhook (n8n-nodes-base.webhook): External systems calling your workflow via HTTP POST/GET.\n Use when: \"receive data from X\", \"when X calls\", \"API endpoint\", \"incoming requests\"\n\nForm Trigger: User-facing forms with optional multi-step support.\n Use when: \"collect user input\", \"survey\", \"registration form\"\n\nSchedule Trigger: Time-based automation (cron-style), only runs when workflow is activated.\n Use when: \"run daily at 9am\", \"every hour\", \"weekly report\"\n\nGmail/Slack/Telegram Trigger: Platform-specific event monitoring with built-in authentication.\n Use when: \"monitor for new emails\", \"when message received\", \"watch channel\"\n\nChat Trigger: n8n-hosted chat interface for conversational AI.\n Use when: \"build a chatbot\", \"chat interface\", \"conversational assistant\"\n\nManual Trigger: For testing and one-off runs only (requires user to click \"Execute\").\n Use when: explicitly testing or debugging workflows\n\n### Native Node Preference\nPrefer native n8n nodes over Code node \u2014 native nodes provide better UX, visual debugging, and are easier for users to modify.\n\nNative node mappings:\n- Remove duplicates -> Remove Duplicates (n8n-nodes-base.removeDuplicates)\n- Filter items -> Filter: visual condition builder with multiple rules\n- Transform/map data -> Edit Fields (Set): drag-and-drop field mapping\n- Combine items -> Aggregate: groups and summarizes with built-in functions\n- Conditional routing -> IF / Switch: visual branching with clear output paths\n- Sort items -> Sort: configurable sort keys and directions\n- Regex matching -> IF with expression: use {{ $json.field.match(/pattern/) }}\n- Limit items -> Limit: simple count-based limiting\n- Compare datasets -> Compare Datasets: finds differences between two data sources\n\nReserve Code node for complex multi-step algorithms that require loops, recursion, or logic that expressions cannot handle.\n\n3. **Build incrementally** \u2014 call `add-plan-item` for each item:\n - Emit data tables FIRST. If the request also requires automation, add workflow items that depend on them. A plan may consist entirely of data-table items.\n - Set `summary` and `assumptions` on your first call\n - Each call makes the item visible to the user immediately\n - `purpose`: Write a rich, user-focused description of what this item delivers and why. Include key requirements and behaviors from the user's request. 3-5 sentences. Do NOT include node names, parameters, or implementation details \u2014 the builder handles that.\n - `triggerDescription`: a few words describing trigger type (e.g. \"Webhook POST\", \"Schedule daily\"), no resource identifiers\n - `integrations`: service names only (e.g. \"Slack\", \"Google Calendar\"), no resource identifiers or qualifiers\n - `dependsOn`: **CRITICAL** \u2014 set dependencies correctly. Data tables before workflows that use them. Workflows that produce data before workflows that consume it. Independent workflows should NOT depend on each other.\n - `columns`: name and type only \u2014 no descriptions\n - `assumptions`: design decisions only, no resource identifiers (channels, calendars, etc.)\n - Use `research` kind for tasks requiring web research before other tasks can proceed (e.g. \"find the API endpoint format for service X\"). Research tasks run a dedicated web research agent.\n - After all items are added, call `submit-plan` to request user approval.\n\n4. **Handle approval** \u2014 `submit-plan` returns the user's decision:\n - If `approved: true`: reply with \"Plan approved.\" and stop.\n - If `approved: false`: read the `feedback` field. Make targeted changes using `remove-plan-item` (to drop items) or `add-plan-item` (to add/replace items by ID). Then call `submit-plan` again. Repeat until approved.\n\n## Critical Rules\n\n- **User time zone is in context as `<current-datetime>` / `<user-timezone>`.** Schedule times, cron expressions, and digest times must be stated in the user's time zone. Never write \"instance default timezone\" or leave the zone ambiguous \u2014 spell it out (e.g. \"daily at 08:00 America/New_York\").\n- **Dependencies are mandatory.** Every workflow must list the data table IDs it reads from or writes to in `dependsOn`. If workflow C needs data from A and B, it must depend on both.\n- **No duplicate items.** Each piece of work appears exactly once. Use `workflow` kind for workflows, `data-table` kind for all data table operations (create, delete, modify, seed), `research` kind for web research. Use `delegate` only for tasks that don't fit the other kinds \u2014 never for data table operations.\n- **Data-table-only plans are valid.** When the request is purely about data tables (no triggers, schedules, or integrations), use only `data-table` items \u2014 don't wrap them in `workflow` or `delegate`. For creation, include `columns`; for other operations, omit `columns` and describe the operation in `purpose`. Include seed rows in `purpose` when the user wants sample data.\n- **Each item's `purpose` describes only that item.** Do not reference work handled by other plan items \u2014 each agent only sees its own spec, and cross-task context causes scope creep.\n- **Workflow verification is mandatory.** For **every** `workflow` item you add, also add a `checkpoint` item whose `dependsOn` includes that workflow's ID. Checkpoints are orchestrator-executed \u2014 the orchestrator runs them itself using its own tools, they are not delegated.\n - `title`: a user-readable verification goal, e.g. `\"Verify 'Daily API Email' workflow runs successfully\"`.\n - `instructions`: detailed steps the orchestrator must execute. Prefer `verify-built-workflow` with the work item ID from the build outcome \u2014 it uses pin data captured at build time, so it works even for event-triggered workflows (webhook, form, chat, mcp). For workflows with real credentials and a testable trigger (manual, schedule), `executions(action=\"run\")` is acceptable. State the pass condition in plain terms (e.g. \"run completes without errors and produces at least one output row\").\n - Do NOT list `tools` on a checkpoint \u2014 it is not a delegate task.\n - Do NOT emit a checkpoint for a `data-table`, `research`, or `delegate` item. Checkpoints are for workflows only.\n- **Always call `submit-plan` after the last `add-plan-item`.** On rejection, be surgical \u2014 change only what the user asked for. Never fabricate node names; search first if unsure.";
|
|
@@ -62,9 +62,15 @@ ${node_selection_1.NATIVE_NODE_PREFERENCE}
|
|
|
62
62
|
|
|
63
63
|
## Critical Rules
|
|
64
64
|
|
|
65
|
+
- **User time zone is in context as \`<current-datetime>\` / \`<user-timezone>\`.** Schedule times, cron expressions, and digest times must be stated in the user's time zone. Never write "instance default timezone" or leave the zone ambiguous — spell it out (e.g. "daily at 08:00 America/New_York").
|
|
65
66
|
- **Dependencies are mandatory.** Every workflow must list the data table IDs it reads from or writes to in \`dependsOn\`. If workflow C needs data from A and B, it must depend on both.
|
|
66
67
|
- **No duplicate items.** Each piece of work appears exactly once. Use \`workflow\` kind for workflows, \`data-table\` kind for all data table operations (create, delete, modify, seed), \`research\` kind for web research. Use \`delegate\` only for tasks that don't fit the other kinds — never for data table operations.
|
|
67
68
|
- **Data-table-only plans are valid.** When the request is purely about data tables (no triggers, schedules, or integrations), use only \`data-table\` items — don't wrap them in \`workflow\` or \`delegate\`. For creation, include \`columns\`; for other operations, omit \`columns\` and describe the operation in \`purpose\`. Include seed rows in \`purpose\` when the user wants sample data.
|
|
68
69
|
- **Each item's \`purpose\` describes only that item.** Do not reference work handled by other plan items — each agent only sees its own spec, and cross-task context causes scope creep.
|
|
70
|
+
- **Workflow verification is mandatory.** For **every** \`workflow\` item you add, also add a \`checkpoint\` item whose \`dependsOn\` includes that workflow's ID. Checkpoints are orchestrator-executed — the orchestrator runs them itself using its own tools, they are not delegated.
|
|
71
|
+
- \`title\`: a user-readable verification goal, e.g. \`"Verify 'Daily API Email' workflow runs successfully"\`.
|
|
72
|
+
- \`instructions\`: detailed steps the orchestrator must execute. Prefer \`verify-built-workflow\` with the work item ID from the build outcome — it uses pin data captured at build time, so it works even for event-triggered workflows (webhook, form, chat, mcp). For workflows with real credentials and a testable trigger (manual, schedule), \`executions(action="run")\` is acceptable. State the pass condition in plain terms (e.g. "run completes without errors and produces at least one output row").
|
|
73
|
+
- Do NOT list \`tools\` on a checkpoint — it is not a delegate task.
|
|
74
|
+
- Do NOT emit a checkpoint for a \`data-table\`, \`research\`, or \`delegate\` item. Checkpoints are for workflows only.
|
|
69
75
|
- **Always call \`submit-plan\` after the last \`add-plan-item\`.** On rejection, be surgical — change only what the user asked for. Never fabricate node names; search first if unsure.`;
|
|
70
76
|
//# sourceMappingURL=plan-agent-prompt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-agent-prompt.js","sourceRoot":"","sources":["../../../src/tools/orchestration/plan-agent-prompt.ts"],"names":[],"mappings":";;;AAAA,6EAKkD;AAElD,+DAAsE;AAEzD,QAAA,oBAAoB,GAAG;;;;EAIlC,yCAAwB;;;;;;;;;;;;;;;;;;;;;;;;;EAyBxB,kCAAiB;;;EAGjB,wCAAuB;;;EAGvB,kCAAiB;;;EAGjB,uCAAsB
|
|
1
|
+
{"version":3,"file":"plan-agent-prompt.js","sourceRoot":"","sources":["../../../src/tools/orchestration/plan-agent-prompt.ts"],"names":[],"mappings":";;;AAAA,6EAKkD;AAElD,+DAAsE;AAEzD,QAAA,oBAAoB,GAAG;;;;EAIlC,yCAAwB;;;;;;;;;;;;;;;;;;;;;;;;;EAyBxB,kCAAiB;;;EAGjB,wCAAuB;;;EAGvB,kCAAiB;;;EAGjB,uCAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yLA+BiK,CAAC"}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import type { OrchestrationContext } from '../../types';
|
|
2
|
+
interface FormattedMessage {
|
|
3
|
+
role: string;
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
declare function formatMessagesForBriefing(messages: FormattedMessage[], guidance?: string, timeZone?: string): string;
|
|
7
|
+
export declare const __testFormatMessagesForBriefing: typeof formatMessagesForBriefing;
|
|
8
|
+
export declare function __testClearPlannedTaskGraph(context: OrchestrationContext): Promise<void>;
|
|
2
9
|
export declare function createPlanWithAgentTool(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>, "plan", unknown>;
|
|
10
|
+
export {};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.__testFormatMessagesForBriefing = void 0;
|
|
4
|
+
exports.__testClearPlannedTaskGraph = __testClearPlannedTaskGraph;
|
|
3
5
|
exports.createPlanWithAgentTool = createPlanWithAgentTool;
|
|
4
6
|
const agent_1 = require("@mastra/core/agent");
|
|
5
7
|
const tools_1 = require("@mastra/core/tools");
|
|
8
|
+
const luxon_1 = require("luxon");
|
|
6
9
|
const nanoid_1 = require("nanoid");
|
|
7
10
|
const zod_1 = require("zod");
|
|
8
11
|
const add_plan_item_tool_1 = require("./add-plan-item.tool");
|
|
@@ -16,15 +19,9 @@ const max_steps_1 = require("../../constants/max-steps");
|
|
|
16
19
|
const resumable_stream_executor_1 = require("../../runtime/resumable-stream-executor");
|
|
17
20
|
const consume_with_hitl_1 = require("../../stream/consume-with-hitl");
|
|
18
21
|
const langsmith_tracing_1 = require("../../tracing/langsmith-tracing");
|
|
22
|
+
const templates_tool_1 = require("../templates.tool");
|
|
19
23
|
const MESSAGE_HISTORY_COUNT = 5;
|
|
20
|
-
const PLANNER_DOMAIN_TOOL_NAMES = [
|
|
21
|
-
'nodes',
|
|
22
|
-
'templates',
|
|
23
|
-
'credentials',
|
|
24
|
-
'data-tables',
|
|
25
|
-
'workflows',
|
|
26
|
-
'ask-user',
|
|
27
|
-
];
|
|
24
|
+
const PLANNER_DOMAIN_TOOL_NAMES = ['nodes', 'credentials', 'data-tables', 'workflows', 'ask-user'];
|
|
28
25
|
const PLANNER_RESEARCH_TOOL_NAMES = ['research'];
|
|
29
26
|
function extractTextFromMemoryContent(content) {
|
|
30
27
|
if (typeof content === 'string')
|
|
@@ -73,8 +70,14 @@ async function getRecentMessages(context, count) {
|
|
|
73
70
|
}
|
|
74
71
|
return messages;
|
|
75
72
|
}
|
|
76
|
-
function formatMessagesForBriefing(messages, guidance) {
|
|
73
|
+
function formatMessagesForBriefing(messages, guidance, timeZone) {
|
|
77
74
|
const parts = [];
|
|
75
|
+
const now = timeZone ? luxon_1.DateTime.now().setZone(timeZone) : luxon_1.DateTime.now();
|
|
76
|
+
const isoNow = now.toISO({ includeOffset: true }) ?? new Date().toISOString();
|
|
77
|
+
parts.push(`<current-datetime>${isoNow}</current-datetime>`);
|
|
78
|
+
if (timeZone) {
|
|
79
|
+
parts.push(`<user-timezone>${timeZone}</user-timezone>`);
|
|
80
|
+
}
|
|
78
81
|
if (messages.length > 0) {
|
|
79
82
|
parts.push('## Recent conversation');
|
|
80
83
|
for (const m of messages) {
|
|
@@ -89,6 +92,7 @@ function formatMessagesForBriefing(messages, guidance) {
|
|
|
89
92
|
parts.push('\nDesign the solution blueprint based on the conversation above.');
|
|
90
93
|
return parts.join('\n\n');
|
|
91
94
|
}
|
|
95
|
+
exports.__testFormatMessagesForBriefing = formatMessagesForBriefing;
|
|
92
96
|
function publishClearingEvent(context) {
|
|
93
97
|
context.eventBus.publish(context.threadId, {
|
|
94
98
|
type: 'tasks-update',
|
|
@@ -104,6 +108,25 @@ async function clearDraftChecklist(context) {
|
|
|
104
108
|
catch {
|
|
105
109
|
}
|
|
106
110
|
}
|
|
111
|
+
async function __testClearPlannedTaskGraph(context) {
|
|
112
|
+
return await clearPlannedTaskGraph(context);
|
|
113
|
+
}
|
|
114
|
+
async function clearPlannedTaskGraph(context) {
|
|
115
|
+
if (!context.plannedTaskService)
|
|
116
|
+
return;
|
|
117
|
+
try {
|
|
118
|
+
const graph = await context.plannedTaskService.getGraph(context.threadId);
|
|
119
|
+
if (!graph)
|
|
120
|
+
return;
|
|
121
|
+
if (graph.planRunId !== context.runId)
|
|
122
|
+
return;
|
|
123
|
+
if (graph.status !== 'awaiting_approval')
|
|
124
|
+
return;
|
|
125
|
+
await context.plannedTaskService.clear(context.threadId);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
}
|
|
129
|
+
}
|
|
107
130
|
function createPlanWithAgentTool(context) {
|
|
108
131
|
return (0, tools_1.createTool)({
|
|
109
132
|
id: 'plan',
|
|
@@ -136,12 +159,13 @@ function createPlanWithAgentTool(context) {
|
|
|
136
159
|
plannerTools[name] = context.domainTools[name];
|
|
137
160
|
}
|
|
138
161
|
}
|
|
162
|
+
plannerTools.templates = (0, templates_tool_1.createTemplatesTool)();
|
|
139
163
|
const accumulator = new blueprint_accumulator_1.BlueprintAccumulator();
|
|
140
164
|
plannerTools['add-plan-item'] = (0, add_plan_item_tool_1.createAddPlanItemTool)(accumulator, context);
|
|
141
165
|
plannerTools['remove-plan-item'] = (0, add_plan_item_tool_1.createRemovePlanItemTool)(accumulator, context);
|
|
142
166
|
plannerTools['submit-plan'] = (0, submit_plan_tool_1.createSubmitPlanTool)(accumulator, context);
|
|
143
167
|
const messages = await getRecentMessages(context, MESSAGE_HISTORY_COUNT);
|
|
144
|
-
const briefing = formatMessagesForBriefing(messages, input.guidance);
|
|
168
|
+
const briefing = formatMessagesForBriefing(messages, input.guidance, context.timeZone);
|
|
145
169
|
const subAgentId = `agent-planner-${(0, nanoid_1.nanoid)(6)}`;
|
|
146
170
|
const subtitle = input.guidance ?? messages.find((m) => m.role === 'user')?.content ?? 'Planning...';
|
|
147
171
|
context.eventBus.publish(context.threadId, {
|
|
@@ -230,6 +254,9 @@ function createPlanWithAgentTool(context) {
|
|
|
230
254
|
},
|
|
231
255
|
});
|
|
232
256
|
if (accumulator.isApproved()) {
|
|
257
|
+
if (context.plannedTaskService) {
|
|
258
|
+
await context.plannedTaskService.approvePlan(context.threadId);
|
|
259
|
+
}
|
|
233
260
|
if (context.schedulePlannedTasks) {
|
|
234
261
|
await context.schedulePlannedTasks();
|
|
235
262
|
}
|
|
@@ -240,6 +267,7 @@ function createPlanWithAgentTool(context) {
|
|
|
240
267
|
}
|
|
241
268
|
publishClearingEvent(context);
|
|
242
269
|
await clearDraftChecklist(context);
|
|
270
|
+
await clearPlannedTaskGraph(context);
|
|
243
271
|
if (!accumulator.isEmpty()) {
|
|
244
272
|
return {
|
|
245
273
|
result: `Planner added ${accumulator.getTaskList().length} items but did not submit the plan for approval. The plan was not executed.`,
|
|
@@ -265,8 +293,11 @@ function createPlanWithAgentTool(context) {
|
|
|
265
293
|
error: errorMessage,
|
|
266
294
|
},
|
|
267
295
|
});
|
|
268
|
-
|
|
269
|
-
|
|
296
|
+
if (!accumulator.isApproved()) {
|
|
297
|
+
publishClearingEvent(context);
|
|
298
|
+
await clearDraftChecklist(context);
|
|
299
|
+
await clearPlannedTaskGraph(context);
|
|
300
|
+
}
|
|
270
301
|
return { result: `Planner error: ${errorMessage}` };
|
|
271
302
|
}
|
|
272
303
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-with-agent.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/plan-with-agent.tool.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plan-with-agent.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/plan-with-agent.tool.ts"],"names":[],"mappings":";;;AAuMA,kEAEC;AAmBD,0DAiOC;AA/aD,8CAA2C;AAE3C,8CAAgD;AAChD,iCAAiC;AACjC,mCAAgC;AAChC,6BAAwB;AAExB,6DAAuF;AACvF,mEAA+D;AAC/D,mDAAgD;AAChD,2DAA2D;AAC3D,yDAA0D;AAC1D,mDAMyB;AACzB,2EAAsE;AACtE,yDAAsD;AACtD,uFAAkF;AAClF,sEAAuE;AACvE,uEAA4F;AAE5F,sDAAwD;AAGxD,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAGhC,MAAM,yBAAyB,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;AAGnG,MAAM,2BAA2B,GAAG,CAAC,UAAU,CAAC,CAAC;AAYjD,SAAS,4BAA4B,CAAC,OAAgB;IACrD,IAAI,OAAO,OAAO,KAAK,QAA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,OAAO;wBACN,MAAM,EAAE,iBAAiB,WAAW,CAAC,WAAW,EAAE,CAAC,MAAM,6EAA6E;qBACtI,CAAC;gBACH,CAAC;gBACD,OAAO;oBACN,MAAM,EAAE,4DAA4D,UAAU,EAAE;iBAChF,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC5E,MAAM,IAAA,4BAAY,EAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE;oBAC5C,QAAQ,EAAE,UAAU;oBACpB,UAAU,EAAE,SAAS;iBACrB,CAAC,CAAC;gBAEH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE;oBAC1C,IAAI,EAAE,iBAAiB;oBACvB,KAAK,EAAE,OAAO,CAAC,KAAK;oBACpB,OAAO,EAAE,UAAU;oBACnB,OAAO,EAAE;wBACR,IAAI,EAAE,SAAS;wBACf,MAAM,EAAE,EAAE;wBACV,KAAK,EAAE,YAAY;qBACnB;iBACD,CAAC,CAAC;gBAQH,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,CAAC;oBAC/B,oBAAoB,CAAC,OAAO,CAAC,CAAC;oBAC9B,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;oBACnC,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;gBACtC,CAAC;gBAED,OAAO,EAAE,MAAM,EAAE,kBAAkB,YAAY,EAAE,EAAE,CAAC;YACrD,CAAC;QACF,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -9,7 +9,7 @@ const zod_1 = require("zod");
|
|
|
9
9
|
const plannedTaskSchema = zod_1.z.object({
|
|
10
10
|
id: zod_1.z.string().describe('Stable task identifier used by dependency edges'),
|
|
11
11
|
title: zod_1.z.string().describe('Short user-facing task title'),
|
|
12
|
-
kind: zod_1.z.enum(['delegate', 'build-workflow', 'manage-data-tables', 'research']),
|
|
12
|
+
kind: zod_1.z.enum(['delegate', 'build-workflow', 'manage-data-tables', 'research', 'checkpoint']),
|
|
13
13
|
spec: zod_1.z.string().describe('Detailed executor briefing for this task'),
|
|
14
14
|
deps: zod_1.z
|
|
15
15
|
.array(zod_1.z.string())
|
|
@@ -44,6 +44,9 @@ async function threadHasExistingPlan(context) {
|
|
|
44
44
|
const graph = await context.plannedTaskService.getGraph(context.threadId);
|
|
45
45
|
if (!graph)
|
|
46
46
|
return false;
|
|
47
|
+
if (graph.status === 'awaiting_approval') {
|
|
48
|
+
return graph.planRunId === context.runId;
|
|
49
|
+
}
|
|
47
50
|
return graph.status === 'active' || graph.status === 'awaiting_replan';
|
|
48
51
|
}
|
|
49
52
|
catch {
|
|
@@ -149,12 +152,25 @@ function createPlanTool(context) {
|
|
|
149
152
|
return { result: 'Awaiting approval', taskCount: input.tasks.length };
|
|
150
153
|
}
|
|
151
154
|
if (resumeData.approved) {
|
|
155
|
+
await context.plannedTaskService.approvePlan(context.threadId);
|
|
152
156
|
await context.schedulePlannedTasks();
|
|
153
157
|
return {
|
|
154
158
|
result: `Plan approved. Started ${input.tasks.length} task${input.tasks.length === 1 ? '' : 's'}.`,
|
|
155
159
|
taskCount: input.tasks.length,
|
|
156
160
|
};
|
|
157
161
|
}
|
|
162
|
+
try {
|
|
163
|
+
await context.taskStorage.save(context.threadId, { tasks: [] });
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
context.logger.warn('Failed to clear rejected plan checklist', { error });
|
|
167
|
+
}
|
|
168
|
+
context.eventBus.publish(context.threadId, {
|
|
169
|
+
type: 'tasks-update',
|
|
170
|
+
runId: context.runId,
|
|
171
|
+
agentId: context.orchestratorAgentId,
|
|
172
|
+
payload: { tasks: { tasks: [] }, planItems: [] },
|
|
173
|
+
});
|
|
158
174
|
return {
|
|
159
175
|
result: `User requested changes: ${resumeData.userInput ?? 'No feedback provided'}. Revise the tasks and call create-tasks again.`,
|
|
160
176
|
taskCount: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/plan.tool.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"plan.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/plan.tool.ts"],"names":[],"mappings":";;;AA6FA,wCAgJC;AA7OD,8CAAgD;AAChD,8CAAgD;AAChD,mCAAgC;AAChC,6BAAwB;AAIxB,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC;IAClC,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;IAC1E,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;IAC1D,IAAI,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAC5F,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;IACrE,IAAI,EAAE,OAAC;SACL,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,CACR,yDAAyD;QACxD,gFAAgF,CACjF;IACF,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;IACzF,UAAU,EAAE,OAAC;SACX,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,4DAA4D,CAAC;CACxE,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,OAAC,CAAC,MAAM,CAAC;IAChC,KAAK,EAAE,OAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,GAAG,C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AC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG;oBAClG,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM;iBAC7B,CAAC;YACH,CAAC;YAWD,IAAI,CAAC;gBACJ,MAAM,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;YACjE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,yCAAyC,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YAC3E,CAAC;YACD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE;gBAC1C,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,OAAO,EAAE,OAAO,CAAC,mBAAmB;gBACpC,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;aAChD,CAAC,CAAC;YACH,OAAO;gBACN,MAAM,EAAE,2BAA2B,UAAU,CAAC,SAAS,IAAI,sBAAsB,iDAAiD;gBAClI,SAAS,EAAE,CAAC;aACZ,CAAC;QACH,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -9,26 +9,64 @@ export declare const reportVerificationVerdictInputSchema: z.ZodObject<{
|
|
|
9
9
|
failedNodeName: z.ZodOptional<z.ZodString>;
|
|
10
10
|
diagnosis: z.ZodOptional<z.ZodString>;
|
|
11
11
|
patch: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
12
|
+
remediation: z.ZodOptional<z.ZodObject<{
|
|
13
|
+
category: z.ZodEnum<["code_fixable", "needs_setup", "blocked"]>;
|
|
14
|
+
shouldEdit: z.ZodBoolean;
|
|
15
|
+
guidance: z.ZodString;
|
|
16
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
17
|
+
remainingSubmitFixes: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
attemptCount: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
category: "blocked" | "code_fixable" | "needs_setup";
|
|
21
|
+
shouldEdit: boolean;
|
|
22
|
+
guidance: string;
|
|
23
|
+
reason?: string | undefined;
|
|
24
|
+
remainingSubmitFixes?: number | undefined;
|
|
25
|
+
attemptCount?: number | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
category: "blocked" | "code_fixable" | "needs_setup";
|
|
28
|
+
shouldEdit: boolean;
|
|
29
|
+
guidance: string;
|
|
30
|
+
reason?: string | undefined;
|
|
31
|
+
remainingSubmitFixes?: number | undefined;
|
|
32
|
+
attemptCount?: number | undefined;
|
|
33
|
+
}>>;
|
|
12
34
|
summary: z.ZodString;
|
|
13
35
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
workItemId: string;
|
|
15
36
|
workflowId: string;
|
|
37
|
+
workItemId: string;
|
|
16
38
|
summary: string;
|
|
17
39
|
verdict: "trigger_only" | "verified" | "needs_patch" | "needs_rebuild" | "needs_user_input" | "failed_terminal";
|
|
18
40
|
diagnosis?: string | undefined;
|
|
19
41
|
patch?: Record<string, unknown> | undefined;
|
|
20
42
|
executionId?: string | undefined;
|
|
21
43
|
failureSignature?: string | undefined;
|
|
44
|
+
remediation?: {
|
|
45
|
+
category: "blocked" | "code_fixable" | "needs_setup";
|
|
46
|
+
shouldEdit: boolean;
|
|
47
|
+
guidance: string;
|
|
48
|
+
reason?: string | undefined;
|
|
49
|
+
remainingSubmitFixes?: number | undefined;
|
|
50
|
+
attemptCount?: number | undefined;
|
|
51
|
+
} | undefined;
|
|
22
52
|
failedNodeName?: string | undefined;
|
|
23
53
|
}, {
|
|
24
|
-
workItemId: string;
|
|
25
54
|
workflowId: string;
|
|
55
|
+
workItemId: string;
|
|
26
56
|
summary: string;
|
|
27
57
|
verdict: "trigger_only" | "verified" | "needs_patch" | "needs_rebuild" | "needs_user_input" | "failed_terminal";
|
|
28
58
|
diagnosis?: string | undefined;
|
|
29
59
|
patch?: Record<string, unknown> | undefined;
|
|
30
60
|
executionId?: string | undefined;
|
|
31
61
|
failureSignature?: string | undefined;
|
|
62
|
+
remediation?: {
|
|
63
|
+
category: "blocked" | "code_fixable" | "needs_setup";
|
|
64
|
+
shouldEdit: boolean;
|
|
65
|
+
guidance: string;
|
|
66
|
+
reason?: string | undefined;
|
|
67
|
+
remainingSubmitFixes?: number | undefined;
|
|
68
|
+
attemptCount?: number | undefined;
|
|
69
|
+
} | undefined;
|
|
32
70
|
failedNodeName?: string | undefined;
|
|
33
71
|
}>;
|
|
34
72
|
export declare function createReportVerificationVerdictTool(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>, "report-verification-verdict", unknown>;
|
|
@@ -5,6 +5,7 @@ exports.createReportVerificationVerdictTool = createReportVerificationVerdictToo
|
|
|
5
5
|
const tools_1 = require("@mastra/core/tools");
|
|
6
6
|
const zod_1 = require("zod");
|
|
7
7
|
const guidance_1 = require("../../workflow-loop/guidance");
|
|
8
|
+
const remediation_1 = require("../../workflow-loop/remediation");
|
|
8
9
|
const workflow_loop_state_1 = require("../../workflow-loop/workflow-loop-state");
|
|
9
10
|
exports.reportVerificationVerdictInputSchema = zod_1.z.object({
|
|
10
11
|
workItemId: zod_1.z.string().describe('The work item ID from the build task (wi_XXXXXXXX)'),
|
|
@@ -32,8 +33,48 @@ exports.reportVerificationVerdictInputSchema = zod_1.z.object({
|
|
|
32
33
|
.record(zod_1.z.unknown())
|
|
33
34
|
.optional()
|
|
34
35
|
.describe('Node parameter patch object for "needs_patch" verdict — the specific parameters to change on the failed node'),
|
|
36
|
+
remediation: zod_1.z
|
|
37
|
+
.object({
|
|
38
|
+
category: zod_1.z.enum(['code_fixable', 'needs_setup', 'blocked']),
|
|
39
|
+
shouldEdit: zod_1.z.boolean(),
|
|
40
|
+
guidance: zod_1.z.string(),
|
|
41
|
+
reason: zod_1.z.string().optional(),
|
|
42
|
+
remainingSubmitFixes: zod_1.z.number().int().min(0).optional(),
|
|
43
|
+
attemptCount: zod_1.z.number().int().min(0).optional(),
|
|
44
|
+
})
|
|
45
|
+
.optional()
|
|
46
|
+
.describe('Remediation metadata returned by verify-built-workflow, if available'),
|
|
35
47
|
summary: zod_1.z.string().describe('One-sentence summary of the verification result'),
|
|
36
48
|
});
|
|
49
|
+
function defaultRemediationForVerdict(input) {
|
|
50
|
+
switch (input.verdict) {
|
|
51
|
+
case 'needs_patch':
|
|
52
|
+
case 'needs_rebuild':
|
|
53
|
+
return (0, remediation_1.createRemediation)({
|
|
54
|
+
category: 'code_fixable',
|
|
55
|
+
shouldEdit: true,
|
|
56
|
+
reason: 'verification_code_fixable',
|
|
57
|
+
guidance: input.diagnosis ??
|
|
58
|
+
'Verification found a workflow-code issue. Apply one batched repair if the guard allows it.',
|
|
59
|
+
});
|
|
60
|
+
case 'needs_user_input':
|
|
61
|
+
return (0, remediation_1.createRemediation)({
|
|
62
|
+
category: 'needs_setup',
|
|
63
|
+
shouldEdit: false,
|
|
64
|
+
reason: input.failureSignature ?? 'verification_needs_user_input',
|
|
65
|
+
guidance: input.diagnosis ?? input.summary,
|
|
66
|
+
});
|
|
67
|
+
case 'failed_terminal':
|
|
68
|
+
return (0, remediation_1.createRemediation)({
|
|
69
|
+
category: 'blocked',
|
|
70
|
+
shouldEdit: false,
|
|
71
|
+
reason: input.failureSignature ?? 'verification_terminal_failure',
|
|
72
|
+
guidance: input.diagnosis ?? input.summary,
|
|
73
|
+
});
|
|
74
|
+
default:
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
37
78
|
function createReportVerificationVerdictTool(context) {
|
|
38
79
|
return (0, tools_1.createTool)({
|
|
39
80
|
id: 'report-verification-verdict',
|
|
@@ -48,17 +89,55 @@ function createReportVerificationVerdictTool(context) {
|
|
|
48
89
|
if (!context.workflowTaskService) {
|
|
49
90
|
return { guidance: 'Error: verification verdict reporting not available.' };
|
|
50
91
|
}
|
|
92
|
+
const stateBefore = await context.workflowTaskService.getWorkflowLoopState(input.workItemId);
|
|
93
|
+
const terminalRemediation = stateBefore?.lastRemediation && !stateBefore.lastRemediation.shouldEdit
|
|
94
|
+
? (0, remediation_1.terminalRemediationFromState)(stateBefore, context.runId)
|
|
95
|
+
: undefined;
|
|
96
|
+
if (terminalRemediation) {
|
|
97
|
+
return {
|
|
98
|
+
guidance: (0, guidance_1.formatWorkflowLoopGuidance)({
|
|
99
|
+
type: 'blocked',
|
|
100
|
+
reason: terminalRemediation.guidance,
|
|
101
|
+
}),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const remediation = input.remediation ?? defaultRemediationForVerdict(input);
|
|
105
|
+
const forcedTerminalVerdict = remediation && !remediation.shouldEdit
|
|
106
|
+
? remediation.category === 'needs_setup'
|
|
107
|
+
? 'needs_user_input'
|
|
108
|
+
: 'failed_terminal'
|
|
109
|
+
: undefined;
|
|
51
110
|
const action = await context.workflowTaskService.reportVerificationVerdict({
|
|
52
111
|
workItemId: input.workItemId,
|
|
112
|
+
runId: context.runId,
|
|
53
113
|
workflowId: input.workflowId,
|
|
54
114
|
executionId: input.executionId,
|
|
55
|
-
verdict: input.verdict,
|
|
56
|
-
failureSignature:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
115
|
+
verdict: forcedTerminalVerdict ?? input.verdict,
|
|
116
|
+
failureSignature: forcedTerminalVerdict
|
|
117
|
+
? (remediation?.reason ?? input.failureSignature)
|
|
118
|
+
: input.failureSignature,
|
|
119
|
+
failedNodeName: forcedTerminalVerdict ? undefined : input.failedNodeName,
|
|
120
|
+
diagnosis: forcedTerminalVerdict
|
|
121
|
+
? (remediation?.guidance ?? input.diagnosis)
|
|
122
|
+
: input.diagnosis,
|
|
123
|
+
patch: forcedTerminalVerdict ? undefined : input.patch,
|
|
124
|
+
remediation,
|
|
125
|
+
summary: forcedTerminalVerdict ? (remediation?.guidance ?? input.summary) : input.summary,
|
|
61
126
|
});
|
|
127
|
+
if (action.type === 'blocked') {
|
|
128
|
+
const state = await context.workflowTaskService.getWorkflowLoopState(input.workItemId);
|
|
129
|
+
if (state?.lastRemediation && !state.lastRemediation.shouldEdit) {
|
|
130
|
+
context.trackTelemetry?.('Builder remediation guard fired', {
|
|
131
|
+
thread_id: context.threadId,
|
|
132
|
+
run_id: context.runId,
|
|
133
|
+
work_item_id: input.workItemId,
|
|
134
|
+
workflow_id: input.workflowId,
|
|
135
|
+
category: state.lastRemediation.category,
|
|
136
|
+
attempt_count: state.lastRemediation.attemptCount,
|
|
137
|
+
reason: state.lastRemediation.reason,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
62
141
|
return {
|
|
63
142
|
guidance: (0, guidance_1.formatWorkflowLoopGuidance)(action, { workItemId: input.workItemId }),
|
|
64
143
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report-verification-verdict.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/report-verification-verdict.tool.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"report-verification-verdict.tool.js","sourceRoot":"","sources":["../../../src/tools/orchestration/report-verification-verdict.tool.ts"],"names":[],"mappings":";;;AAoGA,kFA4EC;AAtKD,8CAAgD;AAChD,6BAAwB;AAGxB,2DAA0E;AAC1E,iEAAkG;AAClG,iFAGiD;AAEpC,QAAA,oCAAoC,GAAG,OAAC,CAAC,MAAM,CAAC;IAC5D,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oDAAoD,CAAC;IACrF,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAA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EAAC,MAAM,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC;aAC9E,CAAC;QACH,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -29,21 +29,6 @@ async function startResearchAgentTask(context, input) {
|
|
|
29
29
|
}
|
|
30
30
|
const subAgentId = input.agentId ?? `agent-researcher-${(0, nanoid_1.nanoid)(6)}`;
|
|
31
31
|
const taskId = input.taskId ?? `research-${(0, nanoid_1.nanoid)(8)}`;
|
|
32
|
-
context.eventBus.publish(context.threadId, {
|
|
33
|
-
type: 'agent-spawned',
|
|
34
|
-
runId: context.runId,
|
|
35
|
-
agentId: subAgentId,
|
|
36
|
-
payload: {
|
|
37
|
-
parentId: context.orchestratorAgentId,
|
|
38
|
-
role: 'web-researcher',
|
|
39
|
-
tools: Object.keys(researchTools),
|
|
40
|
-
taskId,
|
|
41
|
-
kind: 'researcher',
|
|
42
|
-
title: 'Researching',
|
|
43
|
-
subtitle: (0, display_utils_1.truncateLabel)(input.goal),
|
|
44
|
-
goal: input.goal,
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
32
|
const briefing = await (0, sub_agent_briefing_1.buildSubAgentBriefing)({
|
|
48
33
|
task: input.goal,
|
|
49
34
|
conversationContext: input.conversationContext,
|
|
@@ -63,13 +48,15 @@ async function startResearchAgentTask(context, input) {
|
|
|
63
48
|
},
|
|
64
49
|
});
|
|
65
50
|
const tracedResearchTools = (0, tracing_utils_1.traceSubAgentTools)(context, researchTools, 'web-researcher');
|
|
66
|
-
context.spawnBackgroundTask({
|
|
51
|
+
const spawnOutcome = context.spawnBackgroundTask({
|
|
67
52
|
taskId,
|
|
68
53
|
threadId: context.threadId,
|
|
69
54
|
agentId: subAgentId,
|
|
70
55
|
role: 'web-researcher',
|
|
71
56
|
traceContext,
|
|
72
57
|
plannedTaskId: input.plannedTaskId,
|
|
58
|
+
dedupeKey: { role: 'web-researcher', plannedTaskId: input.plannedTaskId },
|
|
59
|
+
parentCheckpointId: context.isCheckpointFollowUp === true ? context.checkpointTaskId : undefined,
|
|
73
60
|
run: async (signal, drainCorrections, waitForCorrection) => {
|
|
74
61
|
return await (0, tracing_utils_1.withTraceContextActor)(traceContext, async () => {
|
|
75
62
|
const subAgent = new agent_1.Agent({
|
|
@@ -121,6 +108,35 @@ async function startResearchAgentTask(context, input) {
|
|
|
121
108
|
});
|
|
122
109
|
},
|
|
123
110
|
});
|
|
111
|
+
if (spawnOutcome.status === 'duplicate') {
|
|
112
|
+
return {
|
|
113
|
+
result: `Research already in progress (task: ${spawnOutcome.existing.taskId}). Wait for the planned-task-follow-up — do not dispatch again.`,
|
|
114
|
+
taskId: spawnOutcome.existing.taskId,
|
|
115
|
+
agentId: spawnOutcome.existing.agentId,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (spawnOutcome.status === 'limit-reached') {
|
|
119
|
+
return {
|
|
120
|
+
result: 'Could not start research: concurrent background-task limit reached. Wait for an existing task to finish and try again.',
|
|
121
|
+
taskId: '',
|
|
122
|
+
agentId: '',
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
context.eventBus.publish(context.threadId, {
|
|
126
|
+
type: 'agent-spawned',
|
|
127
|
+
runId: context.runId,
|
|
128
|
+
agentId: subAgentId,
|
|
129
|
+
payload: {
|
|
130
|
+
parentId: context.orchestratorAgentId,
|
|
131
|
+
role: 'web-researcher',
|
|
132
|
+
tools: Object.keys(researchTools),
|
|
133
|
+
taskId,
|
|
134
|
+
kind: 'researcher',
|
|
135
|
+
title: 'Researching',
|
|
136
|
+
subtitle: (0, display_utils_1.truncateLabel)(input.goal),
|
|
137
|
+
goal: input.goal,
|
|
138
|
+
},
|
|
139
|
+
});
|
|
124
140
|
return {
|
|
125
141
|
result: `Research started (task: ${taskId}). Do NOT summarize the plan or list details.`,
|
|
126
142
|
taskId,
|