n8n 2.28.4 → 2.29.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/abstract-server.js +1 -1
- package/dist/abstract-server.js.map +1 -1
- package/dist/active-executions.js +2 -2
- package/dist/active-executions.js.map +1 -1
- package/dist/active-workflow-manager.js +1 -1
- package/dist/active-workflow-manager.js.map +1 -1
- package/dist/auth/auth.service.js +12 -12
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/blob-storage/azure-byte-store.ee.d.ts +10 -0
- package/dist/blob-storage/azure-byte-store.ee.js +57 -0
- package/dist/blob-storage/azure-byte-store.ee.js.map +1 -0
- package/dist/blob-storage/fs-byte-store.d.ts +14 -0
- package/dist/blob-storage/fs-byte-store.js +97 -0
- package/dist/blob-storage/fs-byte-store.js.map +1 -0
- package/dist/blob-storage/json-store.d.ts +18 -0
- package/dist/blob-storage/json-store.js +125 -0
- package/dist/blob-storage/json-store.js.map +1 -0
- package/dist/blob-storage/s3-byte-store.ee.d.ts +10 -0
- package/dist/blob-storage/s3-byte-store.ee.js +52 -0
- package/dist/blob-storage/s3-byte-store.ee.js.map +1 -0
- package/dist/blob-storage/skipped-entry-deletion.error.d.ts +5 -0
- package/dist/blob-storage/skipped-entry-deletion.error.js +13 -0
- package/dist/blob-storage/skipped-entry-deletion.error.js.map +1 -0
- package/dist/blob-storage/types.d.ts +23 -0
- package/dist/blob-storage/types.js +3 -0
- package/dist/blob-storage/types.js.map +1 -0
- package/dist/build.tsbuildinfo +1 -1
- package/dist/chat/chat-server.js +1 -1
- package/dist/chat/chat-server.js.map +1 -1
- package/dist/chat/chat-service.js +1 -1
- package/dist/chat/chat-service.js.map +1 -1
- package/dist/chat/chat-service.types.d.ts +2 -2
- package/dist/collaboration/collaboration.service.d.ts +2 -2
- package/dist/collaboration/collaboration.service.js +2 -2
- package/dist/collaboration/collaboration.service.js.map +1 -1
- package/dist/commands/base-command.d.ts +1 -1
- package/dist/commands/base-command.js +30 -4
- package/dist/commands/base-command.js.map +1 -1
- package/dist/commands/export/entities.js +3 -3
- package/dist/commands/export/entities.js.map +1 -1
- package/dist/commands/export/workflow.js.map +1 -1
- package/dist/commands/import/entities.js +3 -3
- package/dist/commands/import/entities.js.map +1 -1
- package/dist/commands/import/workflow.js +1 -1
- package/dist/commands/import/workflow.js.map +1 -1
- package/dist/commands/start.js +5 -5
- package/dist/commands/start.js.map +1 -1
- package/dist/controller.registry.d.ts +1 -1
- package/dist/controller.registry.js +8 -8
- package/dist/controller.registry.js.map +1 -1
- package/dist/controllers/ai.controller.d.ts +1 -0
- package/dist/controllers/ai.controller.js +20 -11
- package/dist/controllers/ai.controller.js.map +1 -1
- package/dist/controllers/e2e.controller.js +1 -0
- package/dist/controllers/e2e.controller.js.map +1 -1
- package/dist/controllers/folder.controller.d.ts +1 -1
- package/dist/controllers/folder.controller.js +1 -1
- package/dist/controllers/folder.controller.js.map +1 -1
- package/dist/controllers/invitation.controller.d.ts +1 -1
- package/dist/controllers/invitation.controller.js +5 -5
- package/dist/controllers/invitation.controller.js.map +1 -1
- package/dist/controllers/oauth/oauth1-credential.controller.d.ts +1 -1
- package/dist/controllers/oauth/oauth1-credential.controller.js +1 -1
- package/dist/controllers/oauth/oauth1-credential.controller.js.map +1 -1
- package/dist/controllers/oauth/oauth2-credential.controller.js +1 -1
- package/dist/controllers/oauth/oauth2-credential.controller.js.map +1 -1
- package/dist/controllers/orchestration.controller.js.map +1 -1
- package/dist/controllers/owner.controller.d.ts +1 -1
- package/dist/controllers/owner.controller.js +1 -1
- package/dist/controllers/owner.controller.js.map +1 -1
- package/dist/controllers/password-reset.controller.d.ts +1 -1
- package/dist/controllers/password-reset.controller.js +3 -3
- package/dist/controllers/password-reset.controller.js.map +1 -1
- package/dist/controllers/posthog.controller.d.ts +2 -5
- package/dist/controllers/posthog.controller.js.map +1 -1
- package/dist/controllers/role.controller.d.ts +2 -1
- package/dist/controllers/role.controller.js +12 -0
- package/dist/controllers/role.controller.js.map +1 -1
- package/dist/controllers/security-settings.controller.d.ts +1 -1
- package/dist/controllers/third-party-licenses.controller.js +1 -1
- package/dist/controllers/third-party-licenses.controller.js.map +1 -1
- package/dist/controllers/translation.controller.js +1 -1
- package/dist/controllers/translation.controller.js.map +1 -1
- package/dist/controllers/users.controller.d.ts +8 -6
- package/dist/controllers/users.controller.js +59 -9
- package/dist/controllers/users.controller.js.map +1 -1
- package/dist/credentials/credentials.service.ee.js +7 -0
- package/dist/credentials/credentials.service.ee.js.map +1 -1
- package/dist/credentials/credentials.service.js +1 -1
- package/dist/credentials/credentials.service.js.map +1 -1
- package/dist/credentials/validation.js +1 -1
- package/dist/credentials/validation.js.map +1 -1
- package/dist/credentials-helper.d.ts +3 -1
- package/dist/credentials-helper.js +33 -5
- package/dist/credentials-helper.js.map +1 -1
- package/dist/credentials-overwrites.js.map +1 -1
- package/dist/evaluation.ee/evaluation-config.service.js +1 -1
- package/dist/evaluation.ee/evaluation-config.service.js.map +1 -1
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.d.ts +3 -3
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.js +11 -5
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.js.map +1 -1
- package/dist/evaluation.ee/test-runs.controller.ee.js.map +1 -1
- package/dist/events/relays/workflow-failure-notification.event-relay.js +1 -1
- package/dist/events/relays/workflow-failure-notification.event-relay.js.map +1 -1
- package/dist/execution-lifecycle/shared/shared-hook-functions.js +1 -0
- package/dist/execution-lifecycle/shared/shared-hook-functions.js.map +1 -1
- package/dist/executions/execution-data/azure-store.ee.js +2 -2
- package/dist/executions/execution-data/azure-store.ee.js.map +1 -1
- package/dist/executions/execution-data/types.d.ts +1 -1
- package/dist/executions/execution-persistence.js +11 -4
- package/dist/executions/execution-persistence.js.map +1 -1
- package/dist/executions/execution.service.js +5 -4
- package/dist/executions/execution.service.js.map +1 -1
- package/dist/executions/executions.controller.d.ts +2 -2
- package/dist/executions/executions.controller.js +4 -4
- package/dist/executions/executions.controller.js.map +1 -1
- package/dist/instance-settings-loader/loaders/log-streaming.instance-settings-loader.js +1 -1
- package/dist/instance-settings-loader/loaders/log-streaming.instance-settings-loader.js.map +1 -1
- package/dist/instance-settings-loader/loaders/owner.instance-settings-loader.js +1 -1
- package/dist/instance-settings-loader/loaders/owner.instance-settings-loader.js.map +1 -1
- package/dist/license/license.controller.js +1 -0
- package/dist/license/license.controller.js.map +1 -1
- package/dist/license/license.service.js +3 -4
- package/dist/license/license.service.js.map +1 -1
- package/dist/metrics/prometheus/db-pool-metrics.service.d.ts +13 -0
- package/dist/metrics/prometheus/db-pool-metrics.service.js +71 -0
- package/dist/metrics/prometheus/db-pool-metrics.service.js.map +1 -0
- package/dist/metrics/prometheus/prometheus.service.d.ts +2 -1
- package/dist/metrics/prometheus/prometheus.service.js +5 -2
- package/dist/metrics/prometheus/prometheus.service.js.map +1 -1
- package/dist/mfa/mfa.service.d.ts +1 -1
- package/dist/mfa/mfa.service.js +1 -1
- package/dist/mfa/mfa.service.js.map +1 -1
- package/dist/mfa/totp.service.js +41 -11
- package/dist/mfa/totp.service.js.map +1 -1
- package/dist/modules/agents/agent-builder.controller.d.ts +28 -0
- package/dist/modules/agents/agent-builder.controller.js +168 -0
- package/dist/modules/agents/agent-builder.controller.js.map +1 -0
- package/dist/modules/agents/agent-chat.controller.d.ts +41 -0
- package/dist/modules/agents/agent-chat.controller.js +206 -0
- package/dist/modules/agents/agent-chat.controller.js.map +1 -0
- package/dist/modules/agents/agent-config.service.d.ts +33 -0
- package/dist/modules/agents/agent-config.service.js +288 -0
- package/dist/modules/agents/agent-config.service.js.map +1 -0
- package/dist/modules/agents/agent-custom-tools.service.d.ts +22 -0
- package/dist/modules/agents/agent-custom-tools.service.js +98 -0
- package/dist/modules/agents/agent-custom-tools.service.js.map +1 -0
- package/dist/modules/agents/agent-execution-orchestrator.service.d.ts +110 -0
- package/dist/modules/agents/agent-execution-orchestrator.service.js +482 -0
- package/dist/modules/agents/agent-execution-orchestrator.service.js.map +1 -0
- package/dist/modules/agents/agent-execution.service.d.ts +4 -4
- package/dist/modules/agents/agent-execution.service.js +6 -5
- package/dist/modules/agents/agent-execution.service.js.map +1 -1
- package/dist/modules/agents/agent-integration-persistence.service.d.ts +19 -0
- package/dist/modules/agents/agent-integration-persistence.service.js +90 -0
- package/dist/modules/agents/agent-integration-persistence.service.js.map +1 -0
- package/dist/modules/agents/agent-integrations.controller.d.ts +60 -0
- package/dist/modules/agents/agent-integrations.controller.js +275 -0
- package/dist/modules/agents/agent-integrations.controller.js.map +1 -0
- package/dist/modules/agents/agent-knowledge-sandbox.service.d.ts +1 -1
- package/dist/modules/agents/agent-knowledge-sandbox.service.js +3 -3
- package/dist/modules/agents/agent-knowledge-sandbox.service.js.map +1 -1
- package/dist/modules/agents/agent-knowledge.controller.d.ts +26 -0
- package/dist/modules/agents/agent-knowledge.controller.js +112 -0
- package/dist/modules/agents/agent-knowledge.controller.js.map +1 -0
- package/dist/modules/agents/agent-publish.controller.d.ts +38 -0
- package/dist/modules/agents/agent-publish.controller.js +94 -0
- package/dist/modules/agents/agent-publish.controller.js.map +1 -0
- package/dist/modules/agents/agent-publish.service.d.ts +30 -0
- package/dist/modules/agents/agent-publish.service.js +293 -0
- package/dist/modules/agents/agent-publish.service.js.map +1 -0
- package/dist/modules/agents/agent-runnable-state.service.d.ts +15 -0
- package/dist/modules/agents/agent-runnable-state.service.js +43 -0
- package/dist/modules/agents/agent-runnable-state.service.js.map +1 -0
- package/dist/modules/agents/agent-runtime-cache.service.d.ts +44 -0
- package/dist/modules/agents/agent-runtime-cache.service.js +169 -0
- package/dist/modules/agents/agent-runtime-cache.service.js.map +1 -0
- package/dist/modules/agents/agent-runtime-reconstruction.service.d.ts +5 -9
- package/dist/modules/agents/agent-runtime-reconstruction.service.js +68 -41
- package/dist/modules/agents/agent-runtime-reconstruction.service.js.map +1 -1
- package/dist/modules/agents/agent-sandbox.controller.d.ts +3 -3
- package/dist/modules/agents/agent-sandbox.controller.js +9 -8
- package/dist/modules/agents/agent-sandbox.controller.js.map +1 -1
- package/dist/modules/agents/agent-skills.service.d.ts +3 -4
- package/dist/modules/agents/agent-skills.service.js +54 -28
- package/dist/modules/agents/agent-skills.service.js.map +1 -1
- package/dist/modules/agents/agent-task.service.d.ts +5 -5
- package/dist/modules/agents/agent-task.service.js +46 -46
- package/dist/modules/agents/agent-task.service.js.map +1 -1
- package/dist/modules/agents/agent-tasks.controller.d.ts +30 -0
- package/dist/modules/agents/agent-tasks.controller.js +106 -0
- package/dist/modules/agents/agent-tasks.controller.js.map +1 -0
- package/dist/modules/agents/agent-telemetry.js +0 -4
- package/dist/modules/agents/agent-telemetry.js.map +1 -1
- package/dist/modules/agents/agent-test-chat.service.d.ts +9 -0
- package/dist/modules/agents/agent-test-chat.service.js +49 -0
- package/dist/modules/agents/agent-test-chat.service.js.map +1 -0
- package/dist/modules/agents/agent-threads.controller.d.ts +28 -0
- package/dist/modules/agents/agent-threads.controller.js +66 -0
- package/dist/modules/agents/agent-threads.controller.js.map +1 -0
- package/dist/modules/agents/agent-validation.service.d.ts +13 -0
- package/dist/modules/agents/agent-validation.service.js +142 -0
- package/dist/modules/agents/agent-validation.service.js.map +1 -0
- package/dist/modules/agents/agents-catalog.controller.d.ts +8 -0
- package/dist/modules/agents/agents-catalog.controller.js +80 -0
- package/dist/modules/agents/agents-catalog.controller.js.map +1 -0
- package/dist/modules/agents/agents-config.controller.d.ts +181 -0
- package/dist/modules/agents/agents-config.controller.js +71 -0
- package/dist/modules/agents/agents-config.controller.js.map +1 -0
- package/dist/modules/agents/agents-skills.controller.d.ts +33 -0
- package/dist/modules/agents/agents-skills.controller.js +94 -0
- package/dist/modules/agents/agents-skills.controller.js.map +1 -0
- package/dist/modules/agents/agents-tools.service.d.ts +1 -7
- package/dist/modules/agents/agents-tools.service.js +3 -80
- package/dist/modules/agents/agents-tools.service.js.map +1 -1
- package/dist/modules/agents/agents.controller.d.ts +7 -393
- package/dist/modules/agents/agents.controller.js +6 -990
- package/dist/modules/agents/agents.controller.js.map +1 -1
- package/dist/modules/agents/agents.module.d.ts +2 -2
- package/dist/modules/agents/agents.module.js +12 -0
- package/dist/modules/agents/agents.module.js.map +1 -1
- package/dist/modules/agents/agents.service.d.ts +8 -166
- package/dist/modules/agents/agents.service.js +10 -1287
- package/dist/modules/agents/agents.service.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder-prompts.d.ts +2 -2
- package/dist/modules/agents/builder/agents-builder-prompts.js +3 -5
- package/dist/modules/agents/builder/agents-builder-prompts.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder-tools.service.d.ts +11 -1
- package/dist/modules/agents/builder/agents-builder-tools.service.js +60 -25
- package/dist/modules/agents/builder/agents-builder-tools.service.js.map +1 -1
- package/dist/modules/agents/builder/interactive/ask-credential.tool.d.ts +4 -0
- package/dist/modules/agents/builder/interactive/ask-credential.tool.js +36 -12
- package/dist/modules/agents/builder/interactive/ask-credential.tool.js.map +1 -1
- package/dist/modules/agents/builder/interactive/ask-llm.tool.js +1 -3
- package/dist/modules/agents/builder/interactive/ask-llm.tool.js.map +1 -1
- package/dist/modules/agents/builder/interactive/ask-question.tool.js.map +1 -1
- package/dist/modules/agents/builder/interactive/index.d.ts +1 -1
- package/dist/modules/agents/builder/interactive/index.js +2 -1
- package/dist/modules/agents/builder/interactive/index.js.map +1 -1
- package/dist/modules/agents/builder/interactive/llm-provider-defaults.js +1 -1
- package/dist/modules/agents/builder/interactive/llm-provider-defaults.js.map +1 -1
- package/dist/modules/agents/builder/interactive/resolve-llm.tool.js +3 -2
- package/dist/modules/agents/builder/interactive/resolve-llm.tool.js.map +1 -1
- package/dist/modules/agents/builder/prompts/config-mutation.prompt.js +3 -5
- package/dist/modules/agents/builder/prompts/config-mutation.prompt.js.map +1 -1
- package/dist/modules/agents/builder/prompts/config-rules.prompt.js +4 -6
- package/dist/modules/agents/builder/prompts/config-rules.prompt.js.map +1 -1
- package/dist/modules/agents/builder/prompts/llm-selection.prompt.js +1 -1
- package/dist/modules/agents/builder/prompts/memory.prompt.d.ts +1 -1
- package/dist/modules/agents/builder/prompts/memory.prompt.js +4 -4
- package/dist/modules/agents/builder/prompts/tools.prompt.d.ts +1 -1
- package/dist/modules/agents/builder/prompts/tools.prompt.js +8 -3
- package/dist/modules/agents/builder/prompts/tools.prompt.js.map +1 -1
- package/dist/modules/agents/builder/skills/integrations.skill.js +8 -0
- package/dist/modules/agents/builder/skills/integrations.skill.js.map +1 -1
- package/dist/modules/agents/builder/skills/mcp.skill.js +16 -0
- package/dist/modules/agents/builder/skills/mcp.skill.js.map +1 -1
- package/dist/modules/agents/builder/skills/resource-locators.skill.js +18 -0
- package/dist/modules/agents/builder/skills/resource-locators.skill.js.map +1 -1
- package/dist/modules/agents/builder/skills/sub-agents.skill.js +34 -8
- package/dist/modules/agents/builder/skills/sub-agents.skill.js.map +1 -1
- package/dist/modules/agents/builder/skills/target-skills.skill.js +22 -3
- package/dist/modules/agents/builder/skills/target-skills.skill.js.map +1 -1
- package/dist/modules/agents/builder/skills/target-tasks.skill.js +12 -0
- package/dist/modules/agents/builder/skills/target-tasks.skill.js.map +1 -1
- package/dist/modules/agents/entities/agent-memory-entry.entity.d.ts +1 -1
- package/dist/modules/agents/entities/agent-memory-entry.entity.js.map +1 -1
- package/dist/modules/agents/entities/agent.entity.d.ts +1 -2
- package/dist/modules/agents/entities/agent.entity.js +0 -4
- package/dist/modules/agents/entities/agent.entity.js.map +1 -1
- package/dist/modules/agents/integrations/agent-chat-bridge.d.ts +7 -23
- package/dist/modules/agents/integrations/agent-chat-bridge.js +60 -646
- package/dist/modules/agents/integrations/agent-chat-bridge.js.map +1 -1
- package/dist/modules/agents/integrations/agent-chat-hitl-resume-handler.d.ts +44 -0
- package/dist/modules/agents/integrations/agent-chat-hitl-resume-handler.js +110 -0
- package/dist/modules/agents/integrations/agent-chat-hitl-resume-handler.js.map +1 -0
- package/dist/modules/agents/integrations/agent-chat-integration.d.ts +38 -4
- package/dist/modules/agents/integrations/agent-chat-integration.js +10 -3
- package/dist/modules/agents/integrations/agent-chat-integration.js.map +1 -1
- package/dist/modules/agents/integrations/agent-chat-message-context.d.ts +22 -0
- package/dist/modules/agents/integrations/agent-chat-message-context.js +104 -0
- package/dist/modules/agents/integrations/agent-chat-message-context.js.map +1 -0
- package/dist/modules/agents/integrations/agent-chat-stream-consumer.d.ts +29 -0
- package/dist/modules/agents/integrations/agent-chat-stream-consumer.js +205 -0
- package/dist/modules/agents/integrations/agent-chat-stream-consumer.js.map +1 -0
- package/dist/modules/agents/integrations/agent-chat-suspension-cards.d.ts +10 -0
- package/dist/modules/agents/integrations/agent-chat-suspension-cards.js +90 -0
- package/dist/modules/agents/integrations/agent-chat-suspension-cards.js.map +1 -0
- package/dist/modules/agents/integrations/chat-integration.service.js +6 -3
- package/dist/modules/agents/integrations/chat-integration.service.js.map +1 -1
- package/dist/modules/agents/integrations/integration-message-context.service.d.ts +1 -1
- package/dist/modules/agents/integrations/integration-message-context.service.js.map +1 -1
- package/dist/modules/agents/integrations/integration-tool-definitions.d.ts +6037 -0
- package/dist/modules/agents/integrations/integration-tool-definitions.js +231 -0
- package/dist/modules/agents/integrations/integration-tool-definitions.js.map +1 -0
- package/dist/modules/agents/integrations/integration-tool-descriptions.d.ts +3 -0
- package/dist/modules/agents/integrations/integration-tool-descriptions.js +100 -0
- package/dist/modules/agents/integrations/integration-tool-descriptions.js.map +1 -0
- package/dist/modules/agents/integrations/integration-tool-execution.d.ts +27 -0
- package/dist/modules/agents/integrations/integration-tool-execution.js +278 -0
- package/dist/modules/agents/integrations/integration-tool-execution.js.map +1 -0
- package/dist/modules/agents/integrations/integration-tool-factory.d.ts +121 -0
- package/dist/modules/agents/integrations/integration-tool-factory.js +133 -0
- package/dist/modules/agents/integrations/integration-tool-factory.js.map +1 -0
- package/dist/modules/agents/integrations/integration-tool-schema.d.ts +107 -0
- package/dist/modules/agents/integrations/integration-tool-schema.js +140 -0
- package/dist/modules/agents/integrations/integration-tool-schema.js.map +1 -0
- package/dist/modules/agents/integrations/integration-tool-types.d.ts +105 -0
- package/dist/modules/agents/integrations/integration-tool-types.js +3 -0
- package/dist/modules/agents/integrations/integration-tool-types.js.map +1 -0
- package/dist/modules/agents/integrations/integration-tools.d.ts +3 -213
- package/dist/modules/agents/integrations/integration-tools.js +16 -998
- package/dist/modules/agents/integrations/integration-tools.js.map +1 -1
- package/dist/modules/agents/integrations/integrations-sync.d.ts +1 -1
- package/dist/modules/agents/integrations/n8n-memory.d.ts +1 -1
- package/dist/modules/agents/integrations/n8n-memory.js +2 -2
- package/dist/modules/agents/integrations/n8n-memory.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/linear-integration.d.ts +3 -3
- package/dist/modules/agents/integrations/platforms/linear-integration.js +14 -19
- package/dist/modules/agents/integrations/platforms/linear-integration.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/linear-tool-definitions.d.ts +473 -0
- package/dist/modules/agents/integrations/platforms/linear-tool-definitions.js +270 -0
- package/dist/modules/agents/integrations/platforms/linear-tool-definitions.js.map +1 -0
- package/dist/modules/agents/integrations/platforms/n8n-chat-integration.d.ts +4 -3
- package/dist/modules/agents/integrations/platforms/n8n-chat-integration.js +6 -2
- package/dist/modules/agents/integrations/platforms/n8n-chat-integration.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/slack-bridge-behavior.d.ts +12 -0
- package/dist/modules/agents/integrations/platforms/slack-bridge-behavior.js +198 -0
- package/dist/modules/agents/integrations/platforms/slack-bridge-behavior.js.map +1 -0
- package/dist/modules/agents/integrations/platforms/slack-integration.d.ts +14 -4
- package/dist/modules/agents/integrations/platforms/slack-integration.js +20 -7
- package/dist/modules/agents/integrations/platforms/slack-integration.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/slack-operations.js +1 -1
- package/dist/modules/agents/integrations/platforms/slack-operations.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/slack-tool-definitions.d.ts +35 -0
- package/dist/modules/agents/integrations/platforms/slack-tool-definitions.js +33 -0
- package/dist/modules/agents/integrations/platforms/slack-tool-definitions.js.map +1 -0
- package/dist/modules/agents/integrations/platforms/telegram-integration.d.ts +1 -2
- package/dist/modules/agents/integrations/platforms/telegram-integration.js +2 -1
- package/dist/modules/agents/integrations/platforms/telegram-integration.js.map +1 -1
- package/dist/modules/agents/integrations/slack-app-setup.service.d.ts +5 -3
- package/dist/modules/agents/integrations/slack-app-setup.service.js +11 -6
- package/dist/modules/agents/integrations/slack-app-setup.service.js.map +1 -1
- package/dist/modules/agents/json-config/from-json-config.d.ts +7 -0
- package/dist/modules/agents/json-config/from-json-config.js +60 -15
- package/dist/modules/agents/json-config/from-json-config.js.map +1 -1
- package/dist/modules/agents/json-config/sanitize-unknown-agent-credentials.js +17 -6
- package/dist/modules/agents/json-config/sanitize-unknown-agent-credentials.js.map +1 -1
- package/dist/modules/agents/repositories/agent-execution-thread.repository.d.ts +1 -1
- package/dist/modules/agents/repositories/agent-execution-thread.repository.js +2 -5
- package/dist/modules/agents/repositories/agent-execution-thread.repository.js.map +1 -1
- package/dist/modules/agents/repositories/agent-history.repository.d.ts +1 -1
- package/dist/modules/agents/repositories/agent-history.repository.js.map +1 -1
- package/dist/modules/agents/sub-agents/delegate-sub-agent-tool.d.ts +1 -1
- package/dist/modules/agents/sub-agents/sub-agent-source-resolver.d.ts +1 -1
- package/dist/modules/agents/sub-agents/sub-agent-source-resolver.js.map +1 -1
- package/dist/modules/agents/tools/agent-data-utils.d.ts +22 -0
- package/dist/modules/agents/tools/agent-data-utils.js +64 -0
- package/dist/modules/agents/tools/agent-data-utils.js.map +1 -0
- package/dist/modules/agents/tools/input-data-tool.d.ts +3 -0
- package/dist/modules/agents/tools/input-data-tool.js +40 -0
- package/dist/modules/agents/tools/input-data-tool.js.map +1 -0
- package/dist/modules/agents/tools/node-tool-factory.d.ts +1 -1
- package/dist/modules/agents/tools/node-tool-factory.js +1 -1
- package/dist/modules/agents/tools/node-tool-factory.js.map +1 -1
- package/dist/modules/agents/tools/workflow-context-tool.d.ts +3 -0
- package/dist/modules/agents/tools/workflow-context-tool.js +84 -0
- package/dist/modules/agents/tools/workflow-context-tool.js.map +1 -0
- package/dist/modules/agents/utils/agent-credential-provider.d.ts +4 -0
- package/dist/modules/agents/utils/agent-credential-provider.js +8 -0
- package/dist/modules/agents/utils/agent-credential-provider.js.map +1 -0
- package/dist/modules/agents/utils/agent-missing-skill-ids.d.ts +2 -0
- package/dist/modules/agents/utils/agent-missing-skill-ids.js +17 -0
- package/dist/modules/agents/utils/agent-missing-skill-ids.js.map +1 -0
- package/dist/modules/agents/utils/agent-published-snapshot.d.ts +2 -0
- package/dist/modules/agents/utils/agent-published-snapshot.js +17 -0
- package/dist/modules/agents/utils/agent-published-snapshot.js.map +1 -0
- package/dist/modules/agents/utils/agent-resource-id.d.ts +1 -1
- package/dist/modules/agents/utils/sub-agent-resolver.d.ts +14 -0
- package/dist/modules/agents/utils/sub-agent-resolver.js +23 -0
- package/dist/modules/agents/utils/sub-agent-resolver.js.map +1 -0
- package/dist/modules/breaking-changes/rules/v2/file-access.rule.js.map +1 -1
- package/dist/modules/breaking-changes/rules/v2/oauth-callback-auth.rule.js.map +1 -1
- package/dist/modules/breaking-changes/rules/v2/process-env-access.rule.js.map +1 -1
- package/dist/modules/breaking-changes/rules/v2/pyodide-removed.rule.js.map +1 -1
- package/dist/modules/breaking-changes/rules/v2/queue-worker-max-stalled-count.rule.js.map +1 -1
- package/dist/modules/breaking-changes/rules/v2/removed-nodes.rule.js.map +1 -1
- package/dist/modules/breaking-changes/rules/v2/settings-file-permissions.rule.js.map +1 -1
- package/dist/modules/breaking-changes/rules/v2/start-node-removed.rule.js.map +1 -1
- package/dist/modules/breaking-changes/rules/v2/task-runner-docker-image.rule.js.map +1 -1
- package/dist/modules/breaking-changes/rules/v2/tunnel-option.rule.js.map +1 -1
- package/dist/modules/breaking-changes/rules/v2/wait-node-subworkflow.rule.js +1 -1
- package/dist/modules/breaking-changes/rules/v2/wait-node-subworkflow.rule.js.map +1 -1
- package/dist/modules/breaking-changes/rules/v2/workflow-hooks-deprecated.rule.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub-agent.service.d.ts +5 -5
- package/dist/modules/chat-hub/chat-hub-agent.service.js +9 -9
- package/dist/modules/chat-hub/chat-hub-agent.service.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub-message.entity.d.ts +2 -2
- package/dist/modules/chat-hub/chat-hub-message.entity.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub-session.entity.d.ts +1 -1
- package/dist/modules/chat-hub/chat-hub.controller.d.ts +5 -2
- package/dist/modules/chat-hub/chat-hub.controller.js +23 -5
- package/dist/modules/chat-hub/chat-hub.controller.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub.module.d.ts +1 -1
- package/dist/modules/chat-hub/chat-hub.service.js +1 -1
- package/dist/modules/chat-hub/chat-hub.service.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub.settings.controller.d.ts +8 -4
- package/dist/modules/chat-hub/chat-hub.settings.controller.js +28 -18
- package/dist/modules/chat-hub/chat-hub.settings.controller.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub.settings.service.js +3 -3
- package/dist/modules/chat-hub/chat-hub.settings.service.js.map +1 -1
- package/dist/modules/chat-hub/chat-hub.types.d.ts +1 -1
- package/dist/modules/chat-hub/chat-session.repository.js +1 -1
- package/dist/modules/chat-hub/chat-session.repository.js.map +1 -1
- package/dist/modules/community-packages/community-node-types.service.js +2 -2
- package/dist/modules/community-packages/community-node-types.service.js.map +1 -1
- package/dist/modules/community-packages/community-packages.config.d.ts +2 -0
- package/dist/modules/community-packages/community-packages.config.js +10 -0
- package/dist/modules/community-packages/community-packages.config.js.map +1 -1
- package/dist/modules/community-packages/community-packages.lifecycle.service.d.ts +3 -3
- package/dist/modules/community-packages/community-packages.lifecycle.service.js +3 -3
- package/dist/modules/community-packages/community-packages.lifecycle.service.js.map +1 -1
- package/dist/modules/community-packages/community-packages.service.js +3 -3
- package/dist/modules/community-packages/community-packages.service.js.map +1 -1
- package/dist/modules/community-packages/npm-utils.js +1 -1
- package/dist/modules/community-packages/npm-utils.js.map +1 -1
- package/dist/modules/data-table/data-table-aggregate.service.js +1 -1
- package/dist/modules/data-table/data-table-aggregate.service.js.map +1 -1
- package/dist/modules/data-table/data-table-file-cleanup.service.js +1 -1
- package/dist/modules/data-table/data-table-file-cleanup.service.js.map +1 -1
- package/dist/modules/data-table/data-table-proxy.service.d.ts +2 -2
- package/dist/modules/data-table/data-table-proxy.service.js +3 -3
- package/dist/modules/data-table/data-table-proxy.service.js.map +1 -1
- package/dist/modules/data-table/data-table.controller.d.ts +2 -2
- package/dist/modules/data-table/data-table.controller.js +3 -3
- package/dist/modules/data-table/data-table.controller.js.map +1 -1
- package/dist/modules/data-table/utils/sql-utils.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/slack-signature-extractor.js +1 -1
- package/dist/modules/dynamic-credentials.ee/context-establishment-hooks/slack-signature-extractor.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-introspection-identifier.js +0 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-introspection-identifier.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-metadata-http-client.d.ts +0 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-metadata-http-client.js +3 -3
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-metadata-http-client.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-userinfo-identifier.js +0 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/oauth2-userinfo-identifier.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/slack-signature-identifier.js +2 -2
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/slack-signature-identifier.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/slack-credential-resolver.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/storage/dynamic-credential-entry-storage.d.ts +1 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/storage/dynamic-credential-entry-storage.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-cors.service.d.ts +1 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-cors.service.js +1 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-cors.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.d.ts +2 -2
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.js +2 -2
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-web.service.d.ts +2 -2
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-web.service.js +2 -2
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-web.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.d.ts +1 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/n8n-resolver-seeder.service.d.ts +1 -1
- package/dist/modules/dynamic-credentials.ee/services/n8n-resolver-seeder.service.js +1 -1
- package/dist/modules/dynamic-credentials.ee/services/n8n-resolver-seeder.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/utils.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/workflow-status.controller.d.ts +3 -1
- package/dist/modules/dynamic-credentials.ee/workflow-status.controller.js +14 -2
- package/dist/modules/dynamic-credentials.ee/workflow-status.controller.js.map +1 -1
- package/dist/modules/external-secrets.ee/external-secrets-manager.ee.d.ts +3 -4
- package/dist/modules/external-secrets.ee/external-secrets-manager.ee.js +20 -46
- package/dist/modules/external-secrets.ee/external-secrets-manager.ee.js.map +1 -1
- package/dist/modules/external-secrets.ee/external-secrets-provider-connection-manager.ee.d.ts +21 -0
- package/dist/modules/external-secrets.ee/external-secrets-provider-connection-manager.ee.js +142 -0
- package/dist/modules/external-secrets.ee/external-secrets-provider-connection-manager.ee.js.map +1 -0
- package/dist/modules/external-secrets.ee/external-secrets-settings.controller.ee.d.ts +1 -1
- package/dist/modules/external-secrets.ee/external-secrets-settings.controller.ee.js +1 -1
- package/dist/modules/external-secrets.ee/external-secrets-settings.controller.ee.js.map +1 -1
- package/dist/modules/external-secrets.ee/provider-registry.service.d.ts +1 -1
- package/dist/modules/external-secrets.ee/provider-registry.service.js +1 -1
- package/dist/modules/external-secrets.ee/providers/aws-secrets-manager.js +5 -1
- package/dist/modules/external-secrets.ee/providers/aws-secrets-manager.js.map +1 -1
- package/dist/modules/external-secrets.ee/providers/infisical.js +4 -4
- package/dist/modules/external-secrets.ee/providers/infisical.js.map +1 -1
- package/dist/modules/external-secrets.ee/providers/vault.js +10 -10
- package/dist/modules/external-secrets.ee/providers/vault.js.map +1 -1
- package/dist/modules/external-secrets.ee/redaction.service.ee.js.map +1 -1
- package/dist/modules/external-secrets.ee/secrets-providers-connections.service.ee.d.ts +1 -1
- package/dist/modules/external-secrets.ee/secrets-providers-connections.service.ee.js +1 -1
- package/dist/modules/external-secrets.ee/secrets-providers-connections.service.ee.js.map +1 -1
- package/dist/modules/external-secrets.ee/secrets-providers-types.controller.ee.d.ts +1 -1
- package/dist/modules/external-secrets.ee/secrets-providers-types.controller.ee.js +2 -2
- package/dist/modules/external-secrets.ee/secrets-providers-types.controller.ee.js.map +1 -1
- package/dist/modules/favorites/favorites.controller.d.ts +1 -1
- package/dist/modules/favorites/favorites.controller.js +2 -2
- package/dist/modules/favorites/favorites.controller.js.map +1 -1
- package/dist/modules/favorites/favorites.event-relay.d.ts +1 -1
- package/dist/modules/favorites/favorites.event-relay.js +1 -1
- package/dist/modules/favorites/favorites.event-relay.js.map +1 -1
- package/dist/modules/favorites/favorites.service.d.ts +2 -2
- package/dist/modules/favorites/favorites.service.js +2 -2
- package/dist/modules/favorites/favorites.service.js.map +1 -1
- package/dist/modules/insights/database/repositories/insights-by-period.repository.d.ts +1 -0
- package/dist/modules/insights/database/repositories/insights-by-period.repository.js +6 -0
- package/dist/modules/insights/database/repositories/insights-by-period.repository.js.map +1 -1
- package/dist/modules/insights/insights.module.d.ts +1 -0
- package/dist/modules/insights/insights.module.js +1 -1
- package/dist/modules/insights/insights.module.js.map +1 -1
- package/dist/modules/insights/insights.settings.d.ts +6 -3
- package/dist/modules/insights/insights.settings.js +8 -3
- package/dist/modules/insights/insights.settings.js.map +1 -1
- package/dist/modules/instance-ai/browser/browser-local-mcp-server.d.ts +23 -0
- package/dist/modules/instance-ai/browser/browser-local-mcp-server.js +123 -0
- package/dist/modules/instance-ai/browser/browser-local-mcp-server.js.map +1 -0
- package/dist/modules/instance-ai/browser/browser-use-server.d.ts +11 -0
- package/dist/modules/instance-ai/browser/browser-use-server.js +68 -0
- package/dist/modules/instance-ai/browser/browser-use-server.js.map +1 -0
- package/dist/modules/instance-ai/browser/browser-use-ws.constants.d.ts +7 -0
- package/dist/modules/instance-ai/browser/browser-use-ws.constants.js +6 -0
- package/dist/modules/instance-ai/browser/browser-use-ws.constants.js.map +1 -0
- package/dist/modules/instance-ai/browser/composite-local-mcp-server.d.ts +14 -0
- package/dist/modules/instance-ai/browser/composite-local-mcp-server.js +57 -0
- package/dist/modules/instance-ai/browser/composite-local-mcp-server.js.map +1 -0
- package/dist/modules/instance-ai/browser/instance-ai-browser-session.service.d.ts +40 -0
- package/dist/modules/instance-ai/browser/instance-ai-browser-session.service.js +297 -0
- package/dist/modules/instance-ai/browser/instance-ai-browser-session.service.js.map +1 -0
- package/dist/modules/instance-ai/eval/execution.service.js +2 -2
- package/dist/modules/instance-ai/eval/execution.service.js.map +1 -1
- package/dist/modules/instance-ai/eval/mock-handler.js +5 -1
- package/dist/modules/instance-ai/eval/mock-handler.js.map +1 -1
- package/dist/modules/instance-ai/eval/pin-data-generator.js +1 -1
- package/dist/modules/instance-ai/eval/pin-data-generator.js.map +1 -1
- package/dist/modules/instance-ai/eval/thread-restore.service.d.ts +14 -0
- package/dist/modules/instance-ai/eval/thread-restore.service.js +149 -0
- package/dist/modules/instance-ai/eval/thread-restore.service.js.map +1 -0
- package/dist/modules/instance-ai/eval/workflow-analysis.js +1 -1
- package/dist/modules/instance-ai/event-bus/in-process-event-bus.js.map +1 -1
- package/dist/modules/instance-ai/filesystem/local-gateway-registry.js.map +1 -1
- package/dist/modules/instance-ai/filesystem/local-gateway.d.ts +3 -0
- package/dist/modules/instance-ai/filesystem/local-gateway.js +20 -3
- package/dist/modules/instance-ai/filesystem/local-gateway.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai-event-relay.service.d.ts +12 -0
- package/dist/modules/instance-ai/instance-ai-event-relay.service.js +56 -0
- package/dist/modules/instance-ai/instance-ai-event-relay.service.js.map +1 -0
- package/dist/modules/instance-ai/instance-ai-gateway.service.d.ts +5 -1
- package/dist/modules/instance-ai/instance-ai-gateway.service.js +10 -3
- package/dist/modules/instance-ai/instance-ai-gateway.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai-memory.service.d.ts +5 -0
- package/dist/modules/instance-ai/instance-ai-memory.service.js +38 -0
- package/dist/modules/instance-ai/instance-ai-memory.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai-run-pin-data.d.ts +29 -0
- package/dist/modules/instance-ai/instance-ai-run-pin-data.js +222 -0
- package/dist/modules/instance-ai/instance-ai-run-pin-data.js.map +1 -0
- package/dist/modules/instance-ai/instance-ai-settings.service.d.ts +1 -0
- package/dist/modules/instance-ai/instance-ai-settings.service.js +9 -0
- package/dist/modules/instance-ai/instance-ai-settings.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai-terminal-outcome.service.d.ts +72 -0
- package/dist/modules/instance-ai/instance-ai-terminal-outcome.service.js +352 -0
- package/dist/modules/instance-ai/instance-ai-terminal-outcome.service.js.map +1 -0
- package/dist/modules/instance-ai/instance-ai-test.controller.d.ts +2 -2
- package/dist/modules/instance-ai/instance-ai-test.controller.js +2 -2
- package/dist/modules/instance-ai/instance-ai-test.controller.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.adapter.service.js +78 -193
- package/dist/modules/instance-ai/instance-ai.adapter.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.controller.d.ts +19 -2
- package/dist/modules/instance-ai/instance-ai.controller.js +96 -6
- package/dist/modules/instance-ai/instance-ai.controller.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.module.d.ts +1 -0
- package/dist/modules/instance-ai/instance-ai.module.js +4 -0
- package/dist/modules/instance-ai/instance-ai.module.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.service.d.ts +10 -33
- package/dist/modules/instance-ai/instance-ai.service.js +293 -767
- package/dist/modules/instance-ai/instance-ai.service.js.map +1 -1
- package/dist/modules/instance-ai/internal-messages.d.ts +2 -0
- package/dist/modules/instance-ai/internal-messages.js +4 -2
- package/dist/modules/instance-ai/internal-messages.js.map +1 -1
- package/dist/modules/instance-ai/liveness/index.d.ts +1 -1
- package/dist/modules/instance-ai/liveness/index.js.map +1 -1
- package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.d.ts +4 -7
- package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.js +2 -2
- package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.js.map +1 -1
- package/dist/modules/instance-ai/mcp/instance-ai-mcp-connection.controller.js.map +1 -1
- package/dist/modules/instance-ai/message-parser.js +4 -3
- package/dist/modules/instance-ai/message-parser.js.map +1 -1
- package/dist/modules/instance-ai/node-definition-resolver.js +2 -1
- package/dist/modules/instance-ai/node-definition-resolver.js.map +1 -1
- package/dist/modules/instance-ai/planned-task-action-runner.d.ts +1 -1
- package/dist/modules/instance-ai/planned-task-action-runner.js +3 -3
- package/dist/modules/instance-ai/planned-task-action-runner.js.map +1 -1
- package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.js.map +1 -1
- package/dist/modules/instance-ai/storage/typeorm-agent-memory.d.ts +1 -0
- package/dist/modules/instance-ai/storage/typeorm-agent-memory.js +29 -0
- package/dist/modules/instance-ai/storage/typeorm-agent-memory.js.map +1 -1
- package/dist/modules/instance-ai/suspended-run-restorer.service.d.ts +4 -8
- package/dist/modules/instance-ai/suspended-run-restorer.service.js +2 -2
- package/dist/modules/instance-ai/suspended-run-restorer.service.js.map +1 -1
- package/dist/modules/instance-ai/suspended-thread-persistence.service.d.ts +0 -14
- package/dist/modules/instance-ai/suspended-thread-persistence.service.js +0 -26
- package/dist/modules/instance-ai/suspended-thread-persistence.service.js.map +1 -1
- package/dist/modules/instance-ai/tracing/index.d.ts +1 -0
- package/dist/modules/instance-ai/tracing/index.js +6 -0
- package/dist/modules/instance-ai/tracing/index.js.map +1 -0
- package/dist/modules/instance-ai/tracing/instance-ai-tracing.service.d.ts +81 -0
- package/dist/modules/instance-ai/tracing/instance-ai-tracing.service.js +341 -0
- package/dist/modules/instance-ai/tracing/instance-ai-tracing.service.js.map +1 -0
- package/dist/modules/instance-ai/workflow-verification-task-projector.js +1 -2
- package/dist/modules/instance-ai/workflow-verification-task-projector.js.map +1 -1
- package/dist/modules/instance-registry/instance-registry.controller.js +1 -0
- package/dist/modules/instance-registry/instance-registry.controller.js.map +1 -1
- package/dist/modules/instance-registry/instance-registry.service.js +1 -1
- package/dist/modules/instance-registry/instance-registry.service.js.map +1 -1
- package/dist/modules/instance-version-history/instance-version-history.service.d.ts +1 -1
- package/dist/modules/instance-version-history/instance-version-history.service.js +1 -1
- package/dist/modules/instance-version-history/instance-version-history.service.js.map +1 -1
- package/dist/modules/ldap.ee/ldap.service.ee.d.ts +1 -1
- package/dist/modules/ldap.ee/ldap.service.ee.js +1 -1
- package/dist/modules/ldap.ee/ldap.service.ee.js.map +1 -1
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-sentry.ee.js.map +1 -1
- package/dist/modules/mcp/dto/update-allowed-redirect-uris.dto.js +1 -1
- package/dist/modules/mcp/dto/update-allowed-redirect-uris.dto.js.map +1 -1
- package/dist/modules/mcp/mcp.service.d.ts +5 -1
- package/dist/modules/mcp/mcp.service.js +18 -3
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/mcp/tools/data-table/add-data-table-column.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/data-table/add-data-table-column.tool.js.map +1 -1
- package/dist/modules/mcp/tools/data-table/add-data-table-rows.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/data-table/add-data-table-rows.tool.js.map +1 -1
- package/dist/modules/mcp/tools/data-table/create-data-table.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/data-table/create-data-table.tool.js.map +1 -1
- package/dist/modules/mcp/tools/data-table/delete-data-table-column.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/data-table/delete-data-table-column.tool.js.map +1 -1
- package/dist/modules/mcp/tools/data-table/rename-data-table-column.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/data-table/rename-data-table-column.tool.js.map +1 -1
- package/dist/modules/mcp/tools/data-table/rename-data-table.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/data-table/rename-data-table.tool.js.map +1 -1
- package/dist/modules/mcp/tools/data-table/search-data-tables.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/data-table/search-data-tables.tool.js.map +1 -1
- package/dist/modules/mcp/tools/execute-workflow.tool.d.ts +2 -2
- package/dist/modules/mcp/tools/execution-utils.js.map +1 -1
- package/dist/modules/mcp/tools/get-workflow-details.tool.d.ts +3 -3
- package/dist/modules/mcp/tools/get-workflow-details.tool.js.map +1 -1
- package/dist/modules/mcp/tools/get-workflow-history.tool.d.ts +49 -0
- package/dist/modules/mcp/tools/get-workflow-history.tool.js +115 -0
- package/dist/modules/mcp/tools/get-workflow-history.tool.js.map +1 -0
- package/dist/modules/mcp/tools/get-workflow-version.tool.d.ts +30 -0
- package/dist/modules/mcp/tools/get-workflow-version.tool.js +118 -0
- package/dist/modules/mcp/tools/get-workflow-version.tool.js.map +1 -0
- package/dist/modules/mcp/tools/prepare-workflow-pin-data.tool.d.ts +2 -2
- package/dist/modules/mcp/tools/prepare-workflow-pin-data.tool.js.map +1 -1
- package/dist/modules/mcp/tools/publish-workflow.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/publish-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/schemas.d.ts +25 -11
- package/dist/modules/mcp/tools/schemas.js +7 -4
- package/dist/modules/mcp/tools/schemas.js.map +1 -1
- package/dist/modules/mcp/tools/search-folders.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/search-folders.tool.js.map +1 -1
- package/dist/modules/mcp/tools/search-projects.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/search-projects.tool.js.map +1 -1
- package/dist/modules/mcp/tools/test-workflow.tool.d.ts +2 -2
- package/dist/modules/mcp/tools/test-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/unpublish-workflow.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/unpublish-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/webhook-utils.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/connection-structure-check.d.ts +1 -1
- package/dist/modules/mcp/tools/workflow-builder/connection-structure-check.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js +18 -2
- package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/delete-workflow.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/workflow-builder/delete-workflow.tool.js +1 -1
- package/dist/modules/mcp/tools/workflow-builder/delete-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/get-workflow-node-types.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/workflow-builder/get-workflow-node-types.tool.js +1 -1
- package/dist/modules/mcp/tools/workflow-builder/get-workflow-node-types.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/get-workflow-sdk-reference.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/workflow-builder/get-workflow-sdk-reference.tool.js +1 -1
- package/dist/modules/mcp/tools/workflow-builder/get-workflow-sdk-reference.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/mcp-instructions.js +4 -2
- package/dist/modules/mcp/tools/workflow-builder/mcp-instructions.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/restore-workflow-version.tool.d.ts +20 -0
- package/dist/modules/mcp/tools/workflow-builder/restore-workflow-version.tool.js +108 -0
- package/dist/modules/mcp/tools/workflow-builder/restore-workflow-version.tool.js.map +1 -0
- package/dist/modules/mcp/tools/workflow-builder/search-workflow-nodes.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/workflow-builder/search-workflow-nodes.tool.js +1 -1
- package/dist/modules/mcp/tools/workflow-builder/search-workflow-nodes.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.d.ts +3 -1
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js +117 -4
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/validate-node.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/workflow-builder/validate-node.tool.js +1 -1
- package/dist/modules/mcp/tools/workflow-builder/validate-node.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.d.ts +1 -1
- package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js +4 -1
- package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/workflow-operations.d.ts +195 -3
- package/dist/modules/mcp/tools/workflow-builder/workflow-operations.js +69 -1
- package/dist/modules/mcp/tools/workflow-builder/workflow-operations.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-history.utils.d.ts +3 -0
- package/dist/modules/mcp/tools/workflow-history.utils.js +18 -0
- package/dist/modules/mcp/tools/workflow-history.utils.js.map +1 -0
- package/dist/modules/mcp-registry/registry/mcp-registry.service.js +4 -1
- package/dist/modules/mcp-registry/registry/mcp-registry.service.js.map +1 -1
- package/dist/modules/mcp-registry/synthesize-type-def.d.ts +1 -1
- package/dist/modules/mcp-registry/synthesize-type-def.js +3 -3
- package/dist/modules/mcp-registry/synthesize-type-def.js.map +1 -1
- package/dist/modules/n8n-packages/n8n-packages.service.d.ts +1 -1
- package/dist/modules/n8n-packages/n8n-packages.service.js +1 -1
- package/dist/modules/n8n-packages/n8n-packages.service.js.map +1 -1
- package/dist/modules/n8n-packages/utils/import-package-upload.js +1 -1
- package/dist/modules/n8n-packages/utils/import-package-upload.js.map +1 -1
- package/dist/modules/oauth-server/oauth-consent.service.d.ts +3 -1
- package/dist/modules/oauth-server/oauth-consent.service.js +8 -4
- package/dist/modules/oauth-server/oauth-consent.service.js.map +1 -1
- package/dist/modules/oauth-server/oauth.controller.js +1 -0
- package/dist/modules/oauth-server/oauth.controller.js.map +1 -1
- package/dist/modules/oauth-server/oauth.helpers.d.ts +2 -2
- package/dist/modules/oauth-server/oauth.helpers.js +4 -2
- package/dist/modules/oauth-server/oauth.helpers.js.map +1 -1
- package/dist/modules/provisioning.ee/provisioning.module.js +4 -0
- package/dist/modules/provisioning.ee/provisioning.module.js.map +1 -1
- package/dist/modules/provisioning.ee/role-deletion-checker.ee.d.ts +7 -0
- package/dist/modules/provisioning.ee/role-deletion-checker.ee.js +33 -0
- package/dist/modules/provisioning.ee/role-deletion-checker.ee.js.map +1 -0
- package/dist/modules/quick-connect/handlers/firecrawl.handler.js +3 -3
- package/dist/modules/quick-connect/handlers/firecrawl.handler.js.map +1 -1
- package/dist/modules/quick-connect/quick-connect.config.d.ts +10 -10
- package/dist/modules/quick-connect/quick-connect.module.d.ts +2 -2
- package/dist/modules/quick-connect/quick-connect.service.js +1 -1
- package/dist/modules/quick-connect/quick-connect.service.js.map +1 -1
- package/dist/modules/redaction/executions/execution-redaction.service.d.ts +1 -1
- package/dist/modules/redaction/executions/execution-redaction.service.js.map +1 -1
- package/dist/modules/runtime-credentials/runtime-credentials.service.js +1 -1
- package/dist/modules/runtime-credentials/runtime-credentials.service.js.map +1 -1
- package/dist/modules/source-control.ee/source-control-context.factory.js.map +1 -1
- package/dist/modules/source-control.ee/source-control-export.service.ee.d.ts +1 -1
- package/dist/modules/source-control.ee/source-control-export.service.ee.js +2 -2
- package/dist/modules/source-control.ee/source-control-export.service.ee.js.map +1 -1
- package/dist/modules/source-control.ee/source-control-scoped.service.d.ts +3 -2
- package/dist/modules/source-control.ee/source-control-scoped.service.js +10 -1
- package/dist/modules/source-control.ee/source-control-scoped.service.js.map +1 -1
- package/dist/modules/source-control.ee/source-control-status.service.ee.d.ts +2 -2
- package/dist/modules/source-control.ee/source-control-status.service.ee.js +3 -3
- package/dist/modules/source-control.ee/source-control-status.service.ee.js.map +1 -1
- package/dist/modules/source-control.ee/source-control.controller.ee.d.ts +4 -4
- package/dist/modules/source-control.ee/source-control.controller.ee.js +5 -4
- package/dist/modules/source-control.ee/source-control.controller.ee.js.map +1 -1
- package/dist/modules/source-control.ee/source-control.service.ee.d.ts +8 -5
- package/dist/modules/source-control.ee/source-control.service.ee.js +25 -10
- package/dist/modules/source-control.ee/source-control.service.ee.js.map +1 -1
- package/dist/modules/sso-saml/saml-helpers.js.map +1 -1
- package/dist/modules/sso-saml/saml.controller.ee.d.ts +1 -1
- package/dist/modules/sso-saml/saml.controller.ee.js +4 -3
- package/dist/modules/sso-saml/saml.controller.ee.js.map +1 -1
- package/dist/modules/token-exchange/controllers/embed-auth.controller.js +1 -1
- package/dist/modules/token-exchange/controllers/embed-auth.controller.js.map +1 -1
- package/dist/modules/token-exchange/services/jwks-resolver.js +1 -1
- package/dist/modules/token-exchange/services/jwks-resolver.js.map +1 -1
- package/dist/modules/token-exchange/services/trusted-key.service.js +1 -1
- package/dist/modules/token-exchange/services/trusted-key.service.js.map +1 -1
- package/dist/modules/token-exchange/token-exchange.schemas.d.ts +2 -2
- package/dist/modules/workflow-builder/workflow-builder-session.entity.js +1 -1
- package/dist/modules/workflow-builder/workflow-builder-session.entity.js.map +1 -1
- package/dist/modules/workflow-builder/workflow-builder-session.repository.js +1 -1
- package/dist/modules/workflow-builder/workflow-builder-session.repository.js.map +1 -1
- package/dist/node-catalog/node-catalog.service.d.ts +3 -2
- package/dist/node-catalog/node-catalog.service.js +50 -18
- package/dist/node-catalog/node-catalog.service.js.map +1 -1
- package/dist/oauth/oauth.service.d.ts +1 -1
- package/dist/oauth/oauth.service.js +7 -6
- package/dist/oauth/oauth.service.js.map +1 -1
- package/dist/permissions.ee/check-access.js +1 -1
- package/dist/permissions.ee/check-access.js.map +1 -1
- package/dist/public-api/index.js +24 -3
- package/dist/public-api/index.js.map +1 -1
- package/dist/public-api/v1/handlers/discover/discover.service.js +38 -2
- package/dist/public-api/v1/handlers/discover/discover.service.js.map +1 -1
- package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.js +1 -1
- package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.js.map +1 -1
- package/dist/scaling/job-processor.js +1 -0
- package/dist/scaling/job-processor.js.map +1 -1
- package/dist/scaling/leader-election-client.d.ts +1 -1
- package/dist/scaling/leader-election-client.js +1 -1
- package/dist/scaling/leader-election-client.js.map +1 -1
- package/dist/scaling/pubsub/subscriber.service.js +1 -1
- package/dist/scaling/pubsub/subscriber.service.js.map +1 -1
- package/dist/scaling/redis/redis.types.d.ts +1 -1
- package/dist/scaling/redis-lock.service.d.ts +15 -0
- package/dist/scaling/redis-lock.service.js +154 -0
- package/dist/scaling/redis-lock.service.js.map +1 -0
- package/dist/security-audit/risk-reporters/instance-risk-reporter.js +3 -3
- package/dist/security-audit/risk-reporters/instance-risk-reporter.js.map +1 -1
- package/dist/server.js +4 -0
- package/dist/server.js.map +1 -1
- package/dist/services/ai-gateway.service.d.ts +1 -1
- package/dist/services/ai-gateway.service.js +1 -1
- package/dist/services/ai-gateway.service.js.map +1 -1
- package/dist/services/ai-workflow-builder.service.js +5 -4
- package/dist/services/ai-workflow-builder.service.js.map +1 -1
- package/dist/services/credentials-tester.service.d.ts +1 -1
- package/dist/services/credentials-tester.service.js +3 -3
- package/dist/services/credentials-tester.service.js.map +1 -1
- package/dist/services/dynamic-node-parameters.service.d.ts +3 -3
- package/dist/services/dynamic-node-parameters.service.js +4 -4
- package/dist/services/dynamic-node-parameters.service.js.map +1 -1
- package/dist/services/dynamic-templates.service.js +3 -3
- package/dist/services/dynamic-templates.service.js.map +1 -1
- package/dist/services/export.service.js +3 -3
- package/dist/services/export.service.js.map +1 -1
- package/dist/services/frontend.service.js.map +1 -1
- package/dist/services/import.service.js.map +1 -1
- package/dist/services/ownership.service.d.ts +3 -3
- package/dist/services/ownership.service.js +5 -5
- package/dist/services/ownership.service.js.map +1 -1
- package/dist/services/project.service.ee.js +2 -2
- package/dist/services/project.service.ee.js.map +1 -1
- package/dist/services/pruning/workflow-history-compaction.service.d.ts +1 -1
- package/dist/services/pruning/workflow-history-compaction.service.js +1 -1
- package/dist/services/pruning/workflow-history-compaction.service.js.map +1 -1
- package/dist/services/rate-limit.service.d.ts +1 -1
- package/dist/services/rate-limit.service.js.map +1 -1
- package/dist/services/role-deletion-check-proxy.service.d.ts +8 -0
- package/dist/services/role-deletion-check-proxy.service.js +28 -0
- package/dist/services/role-deletion-check-proxy.service.js.map +1 -0
- package/dist/services/role.service.d.ts +5 -2
- package/dist/services/role.service.js +18 -2
- package/dist/services/role.service.js.map +1 -1
- package/dist/services/user.service.js +5 -0
- package/dist/services/user.service.js.map +1 -1
- package/dist/task-runners/task-managers/data-request-response-builder.js +1 -0
- package/dist/task-runners/task-managers/data-request-response-builder.js.map +1 -1
- package/dist/task-runners/task-runner-process-js.js +2 -0
- package/dist/task-runners/task-runner-process-js.js.map +1 -1
- package/dist/tool-generation/hitl-tools.js.map +1 -1
- package/dist/utils/compression.util.js +2 -2
- package/dist/utils/compression.util.js.map +1 -1
- package/dist/utils/health-endpoint.util.js.map +1 -1
- package/dist/utils/strapi-utils.js +2 -3
- package/dist/utils/strapi-utils.js.map +1 -1
- package/dist/webhooks/test-webhook-registrations.service.js +1 -1
- package/dist/webhooks/test-webhook-registrations.service.js.map +1 -1
- package/dist/webhooks/test-webhooks.d.ts +1 -1
- package/dist/webhooks/test-webhooks.js.map +1 -1
- package/dist/webhooks/waiting-forms.js +2 -2
- package/dist/webhooks/waiting-forms.js.map +1 -1
- package/dist/webhooks/webhook.service.d.ts +1 -0
- package/dist/webhooks/webhook.service.js +4 -1
- package/dist/webhooks/webhook.service.js.map +1 -1
- package/dist/workflow-execute-additional-data.d.ts +2 -2
- package/dist/workflow-execute-additional-data.js +5 -4
- package/dist/workflow-execute-additional-data.js.map +1 -1
- package/dist/workflow-runner.js +1 -0
- package/dist/workflow-runner.js.map +1 -1
- package/dist/workflows/publication/workflow-publication-applier.d.ts +3 -1
- package/dist/workflows/publication/workflow-publication-applier.js +10 -2
- package/dist/workflows/publication/workflow-publication-applier.js.map +1 -1
- package/dist/workflows/triggers/non-webhook-trigger-registrar.d.ts +1 -1
- package/dist/workflows/triggers/trigger-execution-context.factory.d.ts +1 -1
- package/dist/workflows/triggers/trigger-execution-context.factory.js +4 -5
- package/dist/workflows/triggers/trigger-execution-context.factory.js.map +1 -1
- package/dist/workflows/triggers/webhook-trigger-registrar.d.ts +4 -1
- package/dist/workflows/triggers/webhook-trigger-registrar.js +36 -9
- package/dist/workflows/triggers/webhook-trigger-registrar.js.map +1 -1
- package/dist/workflows/triggers/workflow-trigger-activator.d.ts +3 -0
- package/dist/workflows/triggers/workflow-trigger-activator.js +66 -32
- package/dist/workflows/triggers/workflow-trigger-activator.js.map +1 -1
- package/dist/workflows/workflow-creation.service.js +1 -1
- package/dist/workflows/workflow-creation.service.js.map +1 -1
- package/dist/workflows/workflow-history/workflow-history.service.d.ts +4 -3
- package/dist/workflows/workflow-history/workflow-history.service.js +4 -3
- package/dist/workflows/workflow-history/workflow-history.service.js.map +1 -1
- package/dist/workflows/workflow-published-data.service.d.ts +16 -6
- package/dist/workflows/workflow-published-data.service.js +42 -2
- package/dist/workflows/workflow-published-data.service.js.map +1 -1
- package/dist/workflows/workflow-validation.service.js +4 -22
- package/dist/workflows/workflow-validation.service.js.map +1 -1
- package/dist/workflows/workflow.service.d.ts +2 -2
- package/dist/workflows/workflow.service.ee.d.ts +1 -1
- package/dist/workflows/workflow.service.ee.js +1 -1
- package/dist/workflows/workflow.service.ee.js.map +1 -1
- package/dist/workflows/workflow.service.js +7 -7
- package/dist/workflows/workflow.service.js.map +1 -1
- package/dist/workflows/workflows.controller.d.ts +6 -6
- package/dist/workflows/workflows.controller.js +3 -3
- package/dist/workflows/workflows.controller.js.map +1 -1
- package/package.json +68 -56
- package/dist/modules/instance-ai/eval/proxy-loopback.d.ts +0 -1
- package/dist/modules/instance-ai/eval/proxy-loopback.js +0 -44
- package/dist/modules/instance-ai/eval/proxy-loopback.js.map +0 -1
|
@@ -55,7 +55,6 @@ const workflow_sdk_1 = require("@n8n/workflow-sdk");
|
|
|
55
55
|
const n8n_core_1 = require("n8n-core");
|
|
56
56
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
57
57
|
const nanoid_1 = require("nanoid");
|
|
58
|
-
const uuid_1 = require("uuid");
|
|
59
58
|
const constants_1 = require("../../constants");
|
|
60
59
|
const event_service_1 = require("../../events/event.service");
|
|
61
60
|
const source_control_preferences_service_ee_1 = require("../../modules/source-control.ee/source-control-preferences.service.ee");
|
|
@@ -63,6 +62,8 @@ const ai_service_1 = require("../../services/ai.service");
|
|
|
63
62
|
const proxy_token_manager_1 = require("../../services/proxy-token-manager");
|
|
64
63
|
const url_service_1 = require("../../services/url.service");
|
|
65
64
|
const telemetry_1 = require("../../telemetry");
|
|
65
|
+
const composite_local_mcp_server_1 = require("./browser/composite-local-mcp-server");
|
|
66
|
+
const instance_ai_browser_session_service_1 = require("./browser/instance-ai-browser-session.service");
|
|
66
67
|
const thread_credential_allowlist_service_1 = require("./eval/thread-credential-allowlist.service");
|
|
67
68
|
const in_process_event_bus_1 = require("./event-bus/in-process-event-bus");
|
|
68
69
|
const instance_ai_credit_service_1 = require("./instance-ai-credit.service");
|
|
@@ -72,6 +73,7 @@ const instance_ai_model_service_1 = require("./instance-ai-model.service");
|
|
|
72
73
|
const instance_ai_run_probe_1 = require("./instance-ai-run-probe");
|
|
73
74
|
const instance_ai_settings_service_1 = require("./instance-ai-settings.service");
|
|
74
75
|
const instance_ai_temporary_workflow_service_1 = require("./instance-ai-temporary-workflow.service");
|
|
76
|
+
const instance_ai_terminal_outcome_service_1 = require("./instance-ai-terminal-outcome.service");
|
|
75
77
|
const instance_ai_adapter_service_1 = require("./instance-ai.adapter.service");
|
|
76
78
|
const internal_messages_1 = require("./internal-messages");
|
|
77
79
|
const liveness_1 = require("./liveness");
|
|
@@ -81,7 +83,6 @@ const output_redaction_config_1 = require("./output-redaction-config");
|
|
|
81
83
|
const planned_task_action_runner_1 = require("./planned-task-action-runner");
|
|
82
84
|
const instance_ai_pending_confirmation_repository_1 = require("./repositories/instance-ai-pending-confirmation.repository");
|
|
83
85
|
const instance_ai_thread_grant_repository_1 = require("./repositories/instance-ai-thread-grant.repository");
|
|
84
|
-
const run_trace_metadata_1 = require("./run-trace-metadata");
|
|
85
86
|
const sandbox_1 = require("./sandbox");
|
|
86
87
|
const db_iteration_log_storage_1 = require("./storage/db-iteration-log-storage");
|
|
87
88
|
const db_snapshot_storage_1 = require("./storage/db-snapshot-storage");
|
|
@@ -89,7 +90,7 @@ const typeorm_agent_checkpoint_store_1 = require("./storage/typeorm-agent-checkp
|
|
|
89
90
|
const typeorm_agent_memory_1 = require("./storage/typeorm-agent-memory");
|
|
90
91
|
const suspended_run_restorer_service_1 = require("./suspended-run-restorer.service");
|
|
91
92
|
const suspended_thread_persistence_service_1 = require("./suspended-thread-persistence.service");
|
|
92
|
-
const
|
|
93
|
+
const tracing_1 = require("./tracing");
|
|
93
94
|
const workflow_verification_obligation_service_1 = require("./workflow-verification-obligation-service");
|
|
94
95
|
const workflow_verification_task_projector_1 = require("./workflow-verification-task-projector");
|
|
95
96
|
function getErrorMessage(error) {
|
|
@@ -112,6 +113,27 @@ function buildContextResourcesBlock(workflowAttachments) {
|
|
|
112
113
|
].join('\n');
|
|
113
114
|
return `${internal_messages_1.EDITOR_CONTEXT_OPEN_TAG}\n${JSON.stringify(workflowAttachments)}\n\n${prose}\n${internal_messages_1.EDITOR_CONTEXT_CLOSE_TAG}`;
|
|
114
115
|
}
|
|
116
|
+
function buildHandoffContextBlock(context) {
|
|
117
|
+
if (!context)
|
|
118
|
+
return '';
|
|
119
|
+
const { credential } = context;
|
|
120
|
+
const lines = [
|
|
121
|
+
`- Credential type: \`${credential.credentialType}\` (${credential.displayName}).`,
|
|
122
|
+
credential.id ? `- Existing credential id: \`${credential.id}\`.` : '',
|
|
123
|
+
credential.nodeName ? `- Node name: "${credential.nodeName}".` : '',
|
|
124
|
+
credential.nodeType ? `- Node type: \`${credential.nodeType}\`.` : '',
|
|
125
|
+
credential.documentationUrl ? `- n8n documentation URL: ${credential.documentationUrl}` : '',
|
|
126
|
+
credential.oauthRedirectUrl
|
|
127
|
+
? `- OAuth redirect/callback URL shown in the modal: ${credential.oauthRedirectUrl}`
|
|
128
|
+
: '',
|
|
129
|
+
].filter(Boolean);
|
|
130
|
+
const prose = [
|
|
131
|
+
'The user opened this conversation from the credential setup modal and is asking for setup guidance.',
|
|
132
|
+
...lines,
|
|
133
|
+
'Use this metadata only as setup context. Never ask the user to paste credential secrets into chat. For credential setup docs, load `n8n-docs-assistant` and use `n8n-docs` with `intent: "credential-setup"`.',
|
|
134
|
+
].join('\n');
|
|
135
|
+
return `${internal_messages_1.CREDENTIAL_CONTEXT_OPEN_TAG}\n${JSON.stringify(context)}\n\n${prose}\n${internal_messages_1.CREDENTIAL_CONTEXT_CLOSE_TAG}`;
|
|
136
|
+
}
|
|
115
137
|
function isTelemetryConfigurableAgent(agent) {
|
|
116
138
|
return (typeof agent === 'object' &&
|
|
117
139
|
agent !== null &&
|
|
@@ -128,7 +150,6 @@ function isTextMessagePart(part) {
|
|
|
128
150
|
'text' in part &&
|
|
129
151
|
typeof part.text === 'string');
|
|
130
152
|
}
|
|
131
|
-
const ORCHESTRATOR_AGENT_ID = 'agent-001';
|
|
132
153
|
function getUserFacingErrorMessage(error) {
|
|
133
154
|
if (error instanceof n8n_workflow_1.UserError) {
|
|
134
155
|
return error.message;
|
|
@@ -141,45 +162,6 @@ function getUserFacingErrorMessage(error) {
|
|
|
141
162
|
}
|
|
142
163
|
return 'Something went wrong before I could finish that response. Please try again.';
|
|
143
164
|
}
|
|
144
|
-
function getBackgroundOutcomeResponseId(outcome) {
|
|
145
|
-
return `background-outcome:${outcome.id}`;
|
|
146
|
-
}
|
|
147
|
-
function createTerminalOutcomeAgentTree(outcome, responseId) {
|
|
148
|
-
return {
|
|
149
|
-
agentId: ORCHESTRATOR_AGENT_ID,
|
|
150
|
-
role: 'orchestrator',
|
|
151
|
-
status: outcome.status === 'cancelled'
|
|
152
|
-
? 'cancelled'
|
|
153
|
-
: outcome.status === 'failed'
|
|
154
|
-
? 'error'
|
|
155
|
-
: 'completed',
|
|
156
|
-
textContent: outcome.userFacingMessage,
|
|
157
|
-
reasoning: '',
|
|
158
|
-
toolCalls: [],
|
|
159
|
-
children: [],
|
|
160
|
-
timeline: [{ type: 'text', content: outcome.userFacingMessage, responseId }],
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
function appendTerminalOutcomeToAgentTree(tree, outcome, responseId) {
|
|
164
|
-
const text = outcome.userFacingMessage.trim();
|
|
165
|
-
if (!text)
|
|
166
|
-
return { tree, appended: false };
|
|
167
|
-
const alreadyInTimeline = tree.timeline.some((entry) => entry.type === 'text' && entry.responseId === responseId);
|
|
168
|
-
if (alreadyInTimeline) {
|
|
169
|
-
return { tree, appended: false };
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
appended: true,
|
|
173
|
-
tree: {
|
|
174
|
-
...tree,
|
|
175
|
-
textContent: tree.textContent ? `${tree.textContent}\n\n${outcome.userFacingMessage}` : text,
|
|
176
|
-
timeline: [
|
|
177
|
-
...tree.timeline,
|
|
178
|
-
{ type: 'text', content: outcome.userFacingMessage, responseId },
|
|
179
|
-
],
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
165
|
function createInertAbortSignal() {
|
|
184
166
|
return new AbortController().signal;
|
|
185
167
|
}
|
|
@@ -195,7 +177,6 @@ function getAbortReason(signal) {
|
|
|
195
177
|
return reason.message;
|
|
196
178
|
return typeof reason === 'string' ? reason : 'user_cancelled';
|
|
197
179
|
}
|
|
198
|
-
const INSTANCE_AI_FEEDBACK_NAMESPACE = 'c5be4c87-5b6e-49ed-afe1-9c5c1f99a5c0';
|
|
199
180
|
const MAX_CONCURRENT_BACKGROUND_TASKS_PER_THREAD = 5;
|
|
200
181
|
function stringifyForContextValue(value) {
|
|
201
182
|
if (typeof value === 'string')
|
|
@@ -286,12 +267,13 @@ let InstanceAiService = class InstanceAiService {
|
|
|
286
267
|
}
|
|
287
268
|
return this._mcpClientManager;
|
|
288
269
|
}
|
|
289
|
-
constructor(logger, globalConfig, instanceSettings, adapterService, eventBus, settingsService, gatewayService, memoryService, agentMemory, checkpointStore, aiService, threadGrantRepo, pendingConfirmationRepo, urlService, dbSnapshotStorage, dbIterationLogStorage, sourceControlPreferencesService, telemetry, mcpRegistryService, userRepository, temporaryWorkflowService, errorReporter, ssrfProtectionConfig, ssrfProtectionService, eventService, evalCredentialAllowlists, runProbe, modelService, creditService) {
|
|
270
|
+
constructor(logger, globalConfig, instanceSettings, adapterService, eventBus, settingsService, gatewayService, browserSessionService, memoryService, agentMemory, checkpointStore, aiService, threadGrantRepo, pendingConfirmationRepo, urlService, dbSnapshotStorage, dbIterationLogStorage, sourceControlPreferencesService, telemetry, mcpRegistryService, userRepository, temporaryWorkflowService, errorReporter, ssrfProtectionConfig, ssrfProtectionService, eventService, evalCredentialAllowlists, runProbe, modelService, creditService) {
|
|
290
271
|
this.instanceSettings = instanceSettings;
|
|
291
272
|
this.adapterService = adapterService;
|
|
292
273
|
this.eventBus = eventBus;
|
|
293
274
|
this.settingsService = settingsService;
|
|
294
275
|
this.gatewayService = gatewayService;
|
|
276
|
+
this.browserSessionService = browserSessionService;
|
|
295
277
|
this.memoryService = memoryService;
|
|
296
278
|
this.agentMemory = agentMemory;
|
|
297
279
|
this.checkpointStore = checkpointStore;
|
|
@@ -314,20 +296,16 @@ let InstanceAiService = class InstanceAiService {
|
|
|
314
296
|
this.runState = new instance_ai_1.RunStateRegistry();
|
|
315
297
|
this.backgroundTasks = new instance_ai_1.BackgroundTaskManager(MAX_CONCURRENT_BACKGROUND_TASKS_PER_THREAD);
|
|
316
298
|
this.memoryTaskRegistry = new instance_ai_1.MemoryTaskRegistry();
|
|
317
|
-
this.traceContextsByRunId = new Map();
|
|
318
299
|
this.reportedErrors = new WeakSet();
|
|
319
300
|
this.domainAccessTrackersByThread = new Map();
|
|
320
301
|
this.threadPushRef = new Map();
|
|
321
302
|
this.planRequestsByThread = new Map();
|
|
322
303
|
this.schedulerLocks = new Map();
|
|
323
304
|
this.pendingCheckpointReentries = new Map();
|
|
324
|
-
this.pendingTerminalOutcomes = new Map();
|
|
325
|
-
this.traceReplay = new trace_replay_state_1.TraceReplayState();
|
|
326
305
|
this.runDebugBuffer = new instance_ai_1.RunDebugBuffer();
|
|
327
306
|
this.checkpointPruningStopped = true;
|
|
328
307
|
this.inFlightExecutions = new Set();
|
|
329
308
|
this.preserveHitlOnShutdown = new Set();
|
|
330
|
-
this.userMessagePersistenceByRun = new Map();
|
|
331
309
|
this.logger = logger.scoped('instance-ai');
|
|
332
310
|
runProbe.registerActiveRunCountProvider(() => this.runState.activeRunCount());
|
|
333
311
|
this.workflowObligations = new workflow_verification_obligation_service_1.WorkflowVerificationObligationService(this.agentMemory);
|
|
@@ -337,7 +315,6 @@ let InstanceAiService = class InstanceAiService {
|
|
|
337
315
|
logger: this.logger,
|
|
338
316
|
config: this.instanceAiConfig,
|
|
339
317
|
pendingConfirmationRepo: this.pendingConfirmationRepo,
|
|
340
|
-
agentMemory: this.agentMemory,
|
|
341
318
|
});
|
|
342
319
|
this.suspendedRunRestorer = new suspended_run_restorer_service_1.SuspendedRunRestorer({
|
|
343
320
|
logger: this.logger,
|
|
@@ -367,6 +344,13 @@ let InstanceAiService = class InstanceAiService {
|
|
|
367
344
|
void this.suspendedThreads.dropPendingConfirmation(requestId);
|
|
368
345
|
},
|
|
369
346
|
});
|
|
347
|
+
this.tracing = new tracing_1.InstanceAiTracingService({
|
|
348
|
+
logger: this.logger,
|
|
349
|
+
eventBus: this.eventBus,
|
|
350
|
+
runState: this.runState,
|
|
351
|
+
dbSnapshotStorage: this.dbSnapshotStorage,
|
|
352
|
+
aiService: this.aiService,
|
|
353
|
+
});
|
|
370
354
|
this.sandboxService = new sandbox_1.InstanceAiSandboxService({
|
|
371
355
|
config: this.instanceAiConfig,
|
|
372
356
|
logger: this.logger,
|
|
@@ -376,6 +360,20 @@ let InstanceAiService = class InstanceAiService {
|
|
|
376
360
|
settingsService: this.settingsService,
|
|
377
361
|
aiService: this.aiService,
|
|
378
362
|
});
|
|
363
|
+
this.terminalOutcome = new instance_ai_terminal_outcome_service_1.InstanceAiTerminalOutcomeService({
|
|
364
|
+
eventBus: this.eventBus,
|
|
365
|
+
dbSnapshotStorage: this.dbSnapshotStorage,
|
|
366
|
+
agentMemory: this.agentMemory,
|
|
367
|
+
telemetry: this.telemetry,
|
|
368
|
+
logger: this.logger,
|
|
369
|
+
runState: this.runState,
|
|
370
|
+
suspendedThreads: this.suspendedThreads,
|
|
371
|
+
tracing: this.tracing,
|
|
372
|
+
publishRunFinish: (threadId, runId, status, reason) => {
|
|
373
|
+
this.publishRunFinish(threadId, runId, status, reason);
|
|
374
|
+
},
|
|
375
|
+
saveAgentTreeSnapshot: async (threadId, runId, snapshotStorage) => await this.saveAgentTreeSnapshot(threadId, runId, snapshotStorage),
|
|
376
|
+
});
|
|
379
377
|
this.defaultTimeZone = globalConfig.generic.timezone;
|
|
380
378
|
const restEndpoint = globalConfig.endpoints.rest;
|
|
381
379
|
this.oauth2CallbackUrl = `${this.urlService.getInstanceBaseUrl()}/${restEndpoint}/oauth2-credential/callback`;
|
|
@@ -495,23 +493,17 @@ let InstanceAiService = class InstanceAiService {
|
|
|
495
493
|
this.logger.info(`Observational memory task ${event.type}`, logContext);
|
|
496
494
|
};
|
|
497
495
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
messageGroupId,
|
|
508
|
-
tracing,
|
|
509
|
-
traceSlug: this.traceReplay.getActiveSlug(),
|
|
496
|
+
subscribeToAgentErrors(agent, threadId, runId) {
|
|
497
|
+
agent.on("error", (event) => {
|
|
498
|
+
if (event.type !== "error" || !event.source)
|
|
499
|
+
return;
|
|
500
|
+
this.reportInstanceAiError(event.error, {
|
|
501
|
+
component: `instance-ai-${event.source}`,
|
|
502
|
+
threadId,
|
|
503
|
+
runId,
|
|
504
|
+
});
|
|
510
505
|
});
|
|
511
506
|
}
|
|
512
|
-
getTraceContext(runId) {
|
|
513
|
-
return this.traceContextsByRunId.get(runId)?.tracing;
|
|
514
|
-
}
|
|
515
507
|
reportInstanceAiError(error, context) {
|
|
516
508
|
if (typeof error === 'object' && error !== null) {
|
|
517
509
|
if (this.reportedErrors.has(error))
|
|
@@ -588,282 +580,13 @@ let InstanceAiService = class InstanceAiService {
|
|
|
588
580
|
label: record.label,
|
|
589
581
|
}));
|
|
590
582
|
}
|
|
591
|
-
getTraceContextForContinuation(threadId, messageGroupId) {
|
|
592
|
-
const entries = [...this.traceContextsByRunId.values()].reverse();
|
|
593
|
-
const sameGroup = messageGroupId === undefined
|
|
594
|
-
? undefined
|
|
595
|
-
: entries.find((entry) => entry.threadId === threadId && entry.messageGroupId === messageGroupId)?.tracing;
|
|
596
|
-
return sameGroup ?? entries.find((entry) => entry.threadId === threadId)?.tracing;
|
|
597
|
-
}
|
|
598
|
-
async createOrchestratorResumeTraceContext(options) {
|
|
599
|
-
const baseTracing = options.baseTracing ??
|
|
600
|
-
this.getTraceContextForContinuation(options.threadId, options.messageGroupId);
|
|
601
|
-
if (!baseTracing)
|
|
602
|
-
return undefined;
|
|
603
|
-
const tracing = await (0, instance_ai_1.continueInstanceAiTraceContext)(baseTracing, {
|
|
604
|
-
threadId: options.threadId,
|
|
605
|
-
messageId: options.messageId,
|
|
606
|
-
messageGroupId: options.messageGroupId,
|
|
607
|
-
runId: options.runId,
|
|
608
|
-
userId: options.userId,
|
|
609
|
-
modelId: options.modelId,
|
|
610
|
-
input: options.input,
|
|
611
|
-
proxyConfig: options.proxyConfig ?? baseTracing?.proxyConfig,
|
|
612
|
-
metadata: {
|
|
613
|
-
resume_reason: options.resumeReason,
|
|
614
|
-
agent_id: ORCHESTRATOR_AGENT_ID,
|
|
615
|
-
...options.metadata,
|
|
616
|
-
},
|
|
617
|
-
n8nVersion: constants_1.N8N_VERSION,
|
|
618
|
-
workflowSdkVersion: constants_1.WORKFLOW_SDK_VERSION,
|
|
619
|
-
});
|
|
620
|
-
if (tracing) {
|
|
621
|
-
await this.configureTraceReplayMode(tracing);
|
|
622
|
-
this.storeTraceContext(options.runId, options.threadId, tracing, options.messageGroupId);
|
|
623
|
-
this.runState.attachTracing(options.threadId, tracing);
|
|
624
|
-
}
|
|
625
|
-
return tracing;
|
|
626
|
-
}
|
|
627
|
-
async configureTraceReplayMode(tracing) {
|
|
628
|
-
await this.traceReplay.configureReplayMode(tracing);
|
|
629
|
-
}
|
|
630
|
-
async finalizeMessageTraceRoot(runId, tracing, options) {
|
|
631
|
-
if (tracing.rootRun.endTime)
|
|
632
|
-
return;
|
|
633
|
-
const outputs = options.outputs ?? {
|
|
634
|
-
status: options.status,
|
|
635
|
-
runId,
|
|
636
|
-
...(options.outputText ? { response: options.outputText } : {}),
|
|
637
|
-
...(options.reason ? { reason: options.reason } : {}),
|
|
638
|
-
};
|
|
639
|
-
const metadata = {
|
|
640
|
-
final_status: options.status,
|
|
641
|
-
...(options.modelId !== undefined ? { model_id: options.modelId } : {}),
|
|
642
|
-
...options.metadata,
|
|
643
|
-
};
|
|
644
|
-
try {
|
|
645
|
-
await tracing.finishRun(tracing.rootRun, {
|
|
646
|
-
outputs,
|
|
647
|
-
metadata,
|
|
648
|
-
...(options.error
|
|
649
|
-
? { error: options.error }
|
|
650
|
-
: options.status === 'error' && options.reason
|
|
651
|
-
? { error: options.reason }
|
|
652
|
-
: {}),
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
catch (error) {
|
|
656
|
-
this.logger.warn('Failed to finalize Instance AI message trace root', {
|
|
657
|
-
runId,
|
|
658
|
-
threadId: tracing.rootRun.metadata?.thread_id,
|
|
659
|
-
error: getErrorMessage(error),
|
|
660
|
-
});
|
|
661
|
-
}
|
|
662
|
-
finally {
|
|
663
|
-
(0, instance_ai_1.releaseTraceClient)(tracing.rootRun.traceId);
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
async maybeFinalizeRunTraceRoot(runId, options) {
|
|
667
|
-
const tracing = this.getTraceContext(runId);
|
|
668
|
-
if (!tracing)
|
|
669
|
-
return;
|
|
670
|
-
await this.finalizeMessageTraceRoot(runId, tracing, options);
|
|
671
|
-
}
|
|
672
|
-
buildMessageTraceMetadata(threadId, runId, options) {
|
|
673
|
-
const traceOptions = {
|
|
674
|
-
status: options.status,
|
|
675
|
-
...(options.cancellationReason !== undefined
|
|
676
|
-
? { cancellationReason: options.cancellationReason }
|
|
677
|
-
: {}),
|
|
678
|
-
...(options.runTimeout !== undefined ? { runTimeout: options.runTimeout } : {}),
|
|
679
|
-
};
|
|
680
|
-
return {
|
|
681
|
-
completion_source: 'orchestrator',
|
|
682
|
-
...(0, run_trace_metadata_1.buildInstanceAiRunTraceMetadata)(this.eventBus.getEventsForRun(threadId, runId), traceOptions),
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
async finalizeRemainingMessageTraceRoots(threadId, options) {
|
|
686
|
-
const finalizedMessageRuns = new Set();
|
|
687
|
-
for (const [runId, entry] of this.traceContextsByRunId) {
|
|
688
|
-
if (entry.threadId !== threadId)
|
|
689
|
-
continue;
|
|
690
|
-
if (finalizedMessageRuns.has(entry.tracing.rootRun.id))
|
|
691
|
-
continue;
|
|
692
|
-
finalizedMessageRuns.add(entry.tracing.rootRun.id);
|
|
693
|
-
await this.finalizeMessageTraceRoot(runId, entry.tracing, options);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
deleteTraceContextsForThread(threadId) {
|
|
697
|
-
for (const [runId, entry] of this.traceContextsByRunId) {
|
|
698
|
-
if (entry.threadId === threadId) {
|
|
699
|
-
(0, instance_ai_1.releaseTraceClient)(entry.tracing.rootRun.traceId);
|
|
700
|
-
if (entry.tracing.traceWriter && entry.traceSlug) {
|
|
701
|
-
this.traceReplay.preserveWriterEvents(entry.traceSlug, entry.tracing.traceWriter.getEvents());
|
|
702
|
-
}
|
|
703
|
-
this.traceContextsByRunId.delete(runId);
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
deleteTraceContextsForSlug(slug) {
|
|
708
|
-
for (const [runId, entry] of this.traceContextsByRunId) {
|
|
709
|
-
if (entry.traceSlug === slug) {
|
|
710
|
-
(0, instance_ai_1.releaseTraceClient)(entry.tracing.rootRun.traceId);
|
|
711
|
-
this.traceContextsByRunId.delete(runId);
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
583
|
clearTraceContextsForTest() {
|
|
716
|
-
|
|
717
|
-
(0, instance_ai_1.releaseTraceClient)(entry.tracing.rootRun.traceId);
|
|
718
|
-
}
|
|
719
|
-
this.traceContextsByRunId.clear();
|
|
720
|
-
}
|
|
721
|
-
async finalizeDetachedTraceRun(taskId, traceContext, options) {
|
|
722
|
-
if (!traceContext)
|
|
723
|
-
return;
|
|
724
|
-
try {
|
|
725
|
-
if (traceContext.actorRun.id !== traceContext.rootRun.id &&
|
|
726
|
-
traceContext.actorRun.endTime === undefined) {
|
|
727
|
-
await traceContext.finishRun(traceContext.actorRun, {
|
|
728
|
-
outputs: {
|
|
729
|
-
status: options.status,
|
|
730
|
-
...options.outputs,
|
|
731
|
-
},
|
|
732
|
-
metadata: {
|
|
733
|
-
final_status: options.status,
|
|
734
|
-
...options.metadata,
|
|
735
|
-
},
|
|
736
|
-
...(options.error ? { error: options.error } : {}),
|
|
737
|
-
});
|
|
738
|
-
}
|
|
739
|
-
await traceContext.finishRun(traceContext.rootRun, {
|
|
740
|
-
outputs: {
|
|
741
|
-
status: options.status,
|
|
742
|
-
...options.outputs,
|
|
743
|
-
},
|
|
744
|
-
metadata: {
|
|
745
|
-
final_status: options.status,
|
|
746
|
-
...options.metadata,
|
|
747
|
-
},
|
|
748
|
-
...(options.error ? { error: options.error } : {}),
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
catch (error) {
|
|
752
|
-
this.logger.warn('Failed to finalize Instance AI detached trace run', {
|
|
753
|
-
taskId,
|
|
754
|
-
traceRunId: traceContext.rootRun.id,
|
|
755
|
-
error: getErrorMessage(error),
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
finally {
|
|
759
|
-
(0, instance_ai_1.releaseTraceClient)(traceContext.rootRun.traceId);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
async finalizeRunTracing(runId, tracing, options) {
|
|
763
|
-
if (!tracing)
|
|
764
|
-
return;
|
|
765
|
-
if (tracing.actorRun.endTime)
|
|
766
|
-
return;
|
|
767
|
-
const outputs = options.outputs ?? {
|
|
768
|
-
status: options.status,
|
|
769
|
-
runId,
|
|
770
|
-
...(options.outputText ? { response: options.outputText } : {}),
|
|
771
|
-
...(options.reason ? { reason: options.reason } : {}),
|
|
772
|
-
};
|
|
773
|
-
const metadata = {
|
|
774
|
-
final_status: options.status,
|
|
775
|
-
...(options.modelId !== undefined ? { model_id: options.modelId } : {}),
|
|
776
|
-
...options.metadata,
|
|
777
|
-
};
|
|
778
|
-
try {
|
|
779
|
-
await tracing.finishRun(tracing.actorRun, {
|
|
780
|
-
outputs,
|
|
781
|
-
metadata,
|
|
782
|
-
...(options.status === 'error' && options.reason ? { error: options.reason } : {}),
|
|
783
|
-
});
|
|
784
|
-
}
|
|
785
|
-
catch (error) {
|
|
786
|
-
this.logger.warn('Failed to finalize Instance AI run tracing', {
|
|
787
|
-
runId,
|
|
788
|
-
threadId: tracing.actorRun.metadata?.thread_id,
|
|
789
|
-
error: getErrorMessage(error),
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
async finalizeBackgroundTaskTracing(task, status) {
|
|
794
|
-
await this.finalizeDetachedTraceRun(task.taskId, task.traceContext, {
|
|
795
|
-
status,
|
|
796
|
-
outputs: {
|
|
797
|
-
taskId: task.taskId,
|
|
798
|
-
agentId: task.agentId,
|
|
799
|
-
role: task.role,
|
|
800
|
-
...(task.result ? { result: task.result } : {}),
|
|
801
|
-
},
|
|
802
|
-
...(status === 'failed' && task.error ? { error: task.error } : {}),
|
|
803
|
-
metadata: {
|
|
804
|
-
...(task.plannedTaskId ? { planned_task_id: task.plannedTaskId } : {}),
|
|
805
|
-
...(task.workItemId ? { work_item_id: task.workItemId } : {}),
|
|
806
|
-
},
|
|
807
|
-
});
|
|
584
|
+
this.tracing.clearTraceContextsForTest();
|
|
808
585
|
}
|
|
809
586
|
async submitLangsmithFeedback(user, threadId, responseId, payload) {
|
|
810
|
-
|
|
811
|
-
if (!anchor) {
|
|
812
|
-
this.logger.debug('No LangSmith anchor for feedback; skipping annotation', {
|
|
813
|
-
threadId,
|
|
814
|
-
responseId,
|
|
815
|
-
});
|
|
816
|
-
return;
|
|
817
|
-
}
|
|
818
|
-
let tracingProxyConfig;
|
|
819
|
-
if (this.aiService.isProxyEnabled()) {
|
|
820
|
-
try {
|
|
821
|
-
const client = await this.aiService.getClient();
|
|
822
|
-
const baseUrl = client.getApiProxyBaseUrl();
|
|
823
|
-
const manager = new proxy_token_manager_1.ProxyTokenManager(async () => await client.getBuilderApiProxyToken({ id: user.id }, { userMessageId: (0, nanoid_1.nanoid)() }));
|
|
824
|
-
tracingProxyConfig = {
|
|
825
|
-
apiUrl: baseUrl + '/langsmith',
|
|
826
|
-
getAuthHeaders: async () => await manager.getAuthHeaders(),
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
catch (error) {
|
|
830
|
-
this.logger.warn('Failed to build LangSmith proxy config for feedback', {
|
|
831
|
-
threadId,
|
|
832
|
-
responseId,
|
|
833
|
-
error: getErrorMessage(error),
|
|
834
|
-
});
|
|
835
|
-
return;
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
const key = 'user_score';
|
|
839
|
-
const feedbackId = (0, uuid_1.v5)(`${key}:${responseId}`, INSTANCE_AI_FEEDBACK_NAMESPACE);
|
|
840
|
-
try {
|
|
841
|
-
await (0, instance_ai_1.submitLangsmithUserFeedback)({
|
|
842
|
-
langsmithRunId: anchor.langsmithRunId,
|
|
843
|
-
langsmithTraceId: anchor.langsmithTraceId,
|
|
844
|
-
key,
|
|
845
|
-
score: payload.rating === 'up' ? 1 : 0,
|
|
846
|
-
value: payload.rating,
|
|
847
|
-
comment: payload.comment,
|
|
848
|
-
feedbackId,
|
|
849
|
-
sourceInfo: {
|
|
850
|
-
thread_id: threadId,
|
|
851
|
-
response_id: responseId,
|
|
852
|
-
user_id: user.id,
|
|
853
|
-
rating: payload.rating,
|
|
854
|
-
},
|
|
855
|
-
proxyConfig: tracingProxyConfig,
|
|
856
|
-
});
|
|
857
|
-
}
|
|
858
|
-
catch (error) {
|
|
859
|
-
this.logger.warn('Failed to submit LangSmith feedback', {
|
|
860
|
-
threadId,
|
|
861
|
-
responseId,
|
|
862
|
-
error: getErrorMessage(error),
|
|
863
|
-
});
|
|
864
|
-
}
|
|
587
|
+
await this.tracing.submitLangsmithFeedback(user, threadId, responseId, payload);
|
|
865
588
|
}
|
|
866
|
-
startRun(user, threadId, message, attachments, timeZone, pushRef) {
|
|
589
|
+
startRun(user, threadId, message, attachments, context, timeZone, pushRef) {
|
|
867
590
|
this.liveness.clearThreadState(threadId);
|
|
868
591
|
const { runId, abortController, messageGroupId } = this.runState.startRun({
|
|
869
592
|
threadId,
|
|
@@ -875,12 +598,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
875
598
|
if (pushRef !== undefined) {
|
|
876
599
|
this.threadPushRef.set(threadId, pushRef);
|
|
877
600
|
}
|
|
878
|
-
|
|
879
|
-
this.userMessagePersistenceByRun.set(runId, {
|
|
880
|
-
userId: user.id,
|
|
881
|
-
message: { id: userMessageId, text: message },
|
|
882
|
-
});
|
|
883
|
-
this.startExecuteRun(user, threadId, runId, message, abortController, attachments, messageGroupId, timeZone);
|
|
601
|
+
this.startExecuteRun(user, threadId, runId, message, abortController, attachments, context, messageGroupId, timeZone);
|
|
884
602
|
return runId;
|
|
885
603
|
}
|
|
886
604
|
getMessageGroupId(threadId) {
|
|
@@ -899,7 +617,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
899
617
|
const cancelledTasks = this.backgroundTasks.cancelThread(threadId);
|
|
900
618
|
const user = this.runState.getThreadUser(threadId);
|
|
901
619
|
for (const task of cancelledTasks) {
|
|
902
|
-
void this.finalizeBackgroundTaskTracing(task, 'cancelled');
|
|
620
|
+
void this.tracing.finalizeBackgroundTaskTracing(task, 'cancelled');
|
|
903
621
|
this.eventBus.publish(threadId, {
|
|
904
622
|
type: 'agent-completed',
|
|
905
623
|
runId: task.runId,
|
|
@@ -910,7 +628,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
910
628
|
error: reason === liveness_1.INSTANCE_AI_RUN_TIMEOUT_REASON ? 'Timed out' : 'Cancelled by user',
|
|
911
629
|
},
|
|
912
630
|
});
|
|
913
|
-
void this.recordBackgroundTerminalOutcome(task).finally(() => {
|
|
631
|
+
void this.terminalOutcome.recordBackgroundTerminalOutcome(task).finally(() => {
|
|
914
632
|
void this.saveAgentTreeSnapshot(threadId, task.runId, this.dbSnapshotStorage, true, task.messageGroupId);
|
|
915
633
|
});
|
|
916
634
|
if (user) {
|
|
@@ -941,14 +659,14 @@ let InstanceAiService = class InstanceAiService {
|
|
|
941
659
|
const task = this.backgroundTasks.cancelTask(threadId, taskId);
|
|
942
660
|
if (!task)
|
|
943
661
|
return;
|
|
944
|
-
void this.finalizeBackgroundTaskTracing(task, 'cancelled');
|
|
662
|
+
void this.tracing.finalizeBackgroundTaskTracing(task, 'cancelled');
|
|
945
663
|
this.eventBus.publish(threadId, {
|
|
946
664
|
type: 'agent-completed',
|
|
947
665
|
runId: task.runId,
|
|
948
666
|
agentId: task.agentId,
|
|
949
667
|
payload: { role: task.role, result: '', error: 'Cancelled by user' },
|
|
950
668
|
});
|
|
951
|
-
void this.recordBackgroundTerminalOutcome(task).finally(() => {
|
|
669
|
+
void this.terminalOutcome.recordBackgroundTerminalOutcome(task).finally(() => {
|
|
952
670
|
void this.saveAgentTreeSnapshot(threadId, task.runId, this.dbSnapshotStorage, true, task.messageGroupId);
|
|
953
671
|
});
|
|
954
672
|
const user = this.runState.getThreadUser(threadId);
|
|
@@ -959,7 +677,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
959
677
|
cancelAllBackgroundTasks() {
|
|
960
678
|
const cancelled = this.backgroundTasks.cancelAll();
|
|
961
679
|
for (const task of cancelled) {
|
|
962
|
-
void this.finalizeBackgroundTaskTracing(task, 'cancelled');
|
|
680
|
+
void this.tracing.finalizeBackgroundTaskTracing(task, 'cancelled');
|
|
963
681
|
}
|
|
964
682
|
return cancelled.length;
|
|
965
683
|
}
|
|
@@ -975,14 +693,14 @@ let InstanceAiService = class InstanceAiService {
|
|
|
975
693
|
this.eventBus.publish(threadId, {
|
|
976
694
|
type: 'run-start',
|
|
977
695
|
runId,
|
|
978
|
-
agentId:
|
|
696
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
979
697
|
userId: user.id,
|
|
980
698
|
payload: { messageId, messageGroupId },
|
|
981
699
|
});
|
|
982
700
|
this.eventBus.publish(threadId, {
|
|
983
701
|
type: 'text-delta',
|
|
984
702
|
runId,
|
|
985
|
-
agentId:
|
|
703
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
986
704
|
responseId: `test-background-start:${runId}`,
|
|
987
705
|
payload: { text: messageText },
|
|
988
706
|
});
|
|
@@ -991,7 +709,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
991
709
|
runId,
|
|
992
710
|
agentId,
|
|
993
711
|
payload: {
|
|
994
|
-
parentId:
|
|
712
|
+
parentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
995
713
|
role: 'workflow-builder',
|
|
996
714
|
tools: [],
|
|
997
715
|
taskId,
|
|
@@ -1037,7 +755,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1037
755
|
});
|
|
1038
756
|
},
|
|
1039
757
|
onSettled: async (task) => {
|
|
1040
|
-
await this.recordBackgroundTerminalOutcome(task);
|
|
758
|
+
await this.terminalOutcome.recordBackgroundTerminalOutcome(task);
|
|
1041
759
|
await this.saveAgentTreeSnapshot(threadId, runId, this.dbSnapshotStorage, true, messageGroupId);
|
|
1042
760
|
},
|
|
1043
761
|
});
|
|
@@ -1048,7 +766,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1048
766
|
this.eventBus.publish(threadId, {
|
|
1049
767
|
type: 'run-finish',
|
|
1050
768
|
runId,
|
|
1051
|
-
agentId:
|
|
769
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
1052
770
|
userId: user.id,
|
|
1053
771
|
payload: { status: 'completed' },
|
|
1054
772
|
});
|
|
@@ -1065,13 +783,13 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1065
783
|
await this.liveness.sweepTimedOutWork(now);
|
|
1066
784
|
}
|
|
1067
785
|
loadTraceEvents(slug, events) {
|
|
1068
|
-
this.
|
|
786
|
+
this.tracing.loadTraceEvents(slug, events);
|
|
1069
787
|
}
|
|
1070
788
|
getTraceEvents(slug) {
|
|
1071
|
-
return this.
|
|
789
|
+
return this.tracing.getTraceEvents(slug);
|
|
1072
790
|
}
|
|
1073
791
|
hasRunningWorkForTest() {
|
|
1074
|
-
const threadIds = new Set(
|
|
792
|
+
const threadIds = new Set(this.tracing.getTrackedThreadIds());
|
|
1075
793
|
for (const threadId of threadIds) {
|
|
1076
794
|
if (this.runState.getActiveRunId(threadId))
|
|
1077
795
|
return true;
|
|
@@ -1081,34 +799,33 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1081
799
|
return false;
|
|
1082
800
|
}
|
|
1083
801
|
activateTraceSlug(slug) {
|
|
1084
|
-
this.
|
|
802
|
+
this.tracing.activateTraceSlug(slug);
|
|
1085
803
|
}
|
|
1086
804
|
clearTraceEvents(slug) {
|
|
1087
|
-
this.
|
|
1088
|
-
this.traceReplay.clearEvents(slug);
|
|
805
|
+
this.tracing.clearTraceEvents(slug);
|
|
1089
806
|
}
|
|
1090
807
|
async clearThreadState(threadId) {
|
|
1091
808
|
this.liveness.clearThreadState(threadId);
|
|
1092
809
|
const { active, suspended } = this.runState.clearThread(threadId);
|
|
1093
810
|
if (active) {
|
|
1094
811
|
active.abortController.abort();
|
|
1095
|
-
await this.finalizeRunTracing(active.runId, active.tracing, {
|
|
812
|
+
await this.tracing.finalizeRunTracing(active.runId, active.tracing, {
|
|
1096
813
|
status: 'cancelled',
|
|
1097
814
|
reason: 'thread_cleared',
|
|
1098
815
|
});
|
|
1099
816
|
}
|
|
1100
817
|
if (suspended) {
|
|
1101
818
|
suspended.abortController.abort();
|
|
1102
|
-
await this.finalizeRunTracing(suspended.runId, suspended.tracing, {
|
|
819
|
+
await this.tracing.finalizeRunTracing(suspended.runId, suspended.tracing, {
|
|
1103
820
|
status: 'cancelled',
|
|
1104
821
|
reason: 'thread_cleared',
|
|
1105
822
|
});
|
|
1106
823
|
}
|
|
1107
824
|
for (const task of this.backgroundTasks.cancelThread(threadId)) {
|
|
1108
825
|
task.abortController.abort();
|
|
1109
|
-
await this.finalizeBackgroundTaskTracing(task, 'cancelled');
|
|
826
|
+
await this.tracing.finalizeBackgroundTaskTracing(task, 'cancelled');
|
|
1110
827
|
}
|
|
1111
|
-
await this.finalizeRemainingMessageTraceRoots(threadId, {
|
|
828
|
+
await this.tracing.finalizeRemainingMessageTraceRoots(threadId, {
|
|
1112
829
|
status: 'cancelled',
|
|
1113
830
|
reason: 'thread_cleared',
|
|
1114
831
|
metadata: { completion_source: 'service_cleanup' },
|
|
@@ -1119,7 +836,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1119
836
|
this.threadPushRef.delete(threadId);
|
|
1120
837
|
this.planRequestsByThread.delete(threadId);
|
|
1121
838
|
this.memoryTaskRegistry.clearThread(threadId);
|
|
1122
|
-
this.deleteTraceContextsForThread(threadId);
|
|
839
|
+
this.tracing.deleteTraceContextsForThread(threadId);
|
|
1123
840
|
await this.sandboxService.destroySandbox(threadId);
|
|
1124
841
|
await this.temporaryWorkflowService.reapForThreadCleanup(threadId);
|
|
1125
842
|
await this.suspendedThreads.dropPendingConfirmationsForThread(threadId);
|
|
@@ -1132,7 +849,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1132
849
|
const threadsWithPendingHitl = new Set(pendingThreadIds);
|
|
1133
850
|
for (const run of activeRuns) {
|
|
1134
851
|
if (threadsWithPendingHitl.has(run.threadId)) {
|
|
1135
|
-
await this.finalizeRunTracing(run.runId, run.tracing, {
|
|
852
|
+
await this.tracing.finalizeRunTracing(run.runId, run.tracing, {
|
|
1136
853
|
status: 'cancelled',
|
|
1137
854
|
reason: 'service_shutdown',
|
|
1138
855
|
});
|
|
@@ -1142,14 +859,14 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1142
859
|
}
|
|
1143
860
|
this.publishRunFinish(run.threadId, run.runId, 'cancelled', 'service_shutdown');
|
|
1144
861
|
await this.persistShutdownSnapshot(run.threadId, run.runId, run.messageGroupId);
|
|
1145
|
-
await this.finalizeRunTracing(run.runId, run.tracing, {
|
|
862
|
+
await this.tracing.finalizeRunTracing(run.runId, run.tracing, {
|
|
1146
863
|
status: 'cancelled',
|
|
1147
864
|
reason: 'service_shutdown',
|
|
1148
865
|
});
|
|
1149
866
|
run.abortController.abort();
|
|
1150
867
|
}
|
|
1151
868
|
for (const run of suspendedRuns) {
|
|
1152
|
-
await this.finalizeRunTracing(run.runId, run.tracing, {
|
|
869
|
+
await this.tracing.finalizeRunTracing(run.runId, run.tracing, {
|
|
1153
870
|
status: 'cancelled',
|
|
1154
871
|
reason: 'service_shutdown',
|
|
1155
872
|
});
|
|
@@ -1157,21 +874,22 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1157
874
|
}
|
|
1158
875
|
for (const task of this.backgroundTasks.cancelAll()) {
|
|
1159
876
|
task.abortController.abort();
|
|
1160
|
-
await this.finalizeBackgroundTaskTracing(task, 'cancelled');
|
|
877
|
+
await this.tracing.finalizeBackgroundTaskTracing(task, 'cancelled');
|
|
1161
878
|
}
|
|
1162
879
|
await this.drainInFlightExecutions(INSTANCE_AI_SHUTDOWN_DRAIN_TIMEOUT_MS);
|
|
1163
|
-
const threadsWithTraces = new Set(
|
|
880
|
+
const threadsWithTraces = new Set(this.tracing.getTrackedThreadIds());
|
|
1164
881
|
for (const threadId of threadsWithTraces) {
|
|
1165
|
-
await this.finalizeRemainingMessageTraceRoots(threadId, {
|
|
882
|
+
await this.tracing.finalizeRemainingMessageTraceRoots(threadId, {
|
|
1166
883
|
status: 'cancelled',
|
|
1167
884
|
reason: 'service_shutdown',
|
|
1168
885
|
metadata: { completion_source: 'service_cleanup' },
|
|
1169
886
|
});
|
|
1170
887
|
}
|
|
1171
888
|
this.gatewayService.disconnectAll();
|
|
889
|
+
await this.browserSessionService.shutdown();
|
|
1172
890
|
this.sandboxService.stopSandboxExpiryTimers();
|
|
1173
891
|
this.domainAccessTrackersByThread.clear();
|
|
1174
|
-
this.
|
|
892
|
+
this.tracing.clear();
|
|
1175
893
|
this.eventBus.clear();
|
|
1176
894
|
await this._mcpClientManager?.disconnect();
|
|
1177
895
|
this.logger.debug('Instance AI service shut down');
|
|
@@ -1210,14 +928,6 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1210
928
|
shouldPreserveHitlOnShutdown(runId) {
|
|
1211
929
|
return this.preserveHitlOnShutdown.has(runId);
|
|
1212
930
|
}
|
|
1213
|
-
async persistUserMessageOnFirstSuspend(threadId, runId) {
|
|
1214
|
-
const entry = this.userMessagePersistenceByRun.get(runId);
|
|
1215
|
-
if (!entry)
|
|
1216
|
-
return;
|
|
1217
|
-
const ok = await this.suspendedThreads.persistUserMessageOnSuspend(threadId, entry.userId, entry.message);
|
|
1218
|
-
if (ok)
|
|
1219
|
-
this.userMessagePersistenceByRun.delete(runId);
|
|
1220
|
-
}
|
|
1221
931
|
async drainInFlightExecutions(timeoutMs) {
|
|
1222
932
|
if (this.inFlightExecutions.size === 0)
|
|
1223
933
|
return;
|
|
@@ -1302,6 +1012,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1302
1012
|
await sync();
|
|
1303
1013
|
},
|
|
1304
1014
|
getBuildOutcome: async (workItemId) => await workflowTasks.getBuildOutcome(workItemId),
|
|
1015
|
+
getLatestBuildOutcomeForWorkflow: async (workflowId) => await workflowTasks.getLatestBuildOutcomeForWorkflow(workflowId),
|
|
1305
1016
|
getWorkflowLoopState: async (workItemId) => await workflowTasks.getWorkflowLoopState(workItemId),
|
|
1306
1017
|
};
|
|
1307
1018
|
}
|
|
@@ -1401,293 +1112,8 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1401
1112
|
const plannedTaskService = new instance_ai_1.PlannedTaskCoordinator(plannedTaskStorage);
|
|
1402
1113
|
return { memory, taskStorage, plannedTaskService };
|
|
1403
1114
|
}
|
|
1404
|
-
evaluateTerminalResponse(threadId, runId, status, options = {}) {
|
|
1405
|
-
const guard = new instance_ai_1.InstanceAiTerminalResponseGuard({
|
|
1406
|
-
runId,
|
|
1407
|
-
rootAgentId: ORCHESTRATOR_AGENT_ID,
|
|
1408
|
-
messageGroupId: options.messageGroupId,
|
|
1409
|
-
correlationId: options.correlationId,
|
|
1410
|
-
});
|
|
1411
|
-
const decision = guard.evaluateTerminal(this.getTerminalGuardEvents(threadId, runId, options.messageGroupId), status, {
|
|
1412
|
-
workSummary: options.workSummary,
|
|
1413
|
-
errorMessage: options.errorMessage,
|
|
1414
|
-
suppressCompletedFallback: options.suppressCompletedFallback,
|
|
1415
|
-
});
|
|
1416
|
-
this.handleTerminalResponseDecision(threadId, runId, decision, options.messageGroupId);
|
|
1417
|
-
return decision;
|
|
1418
|
-
}
|
|
1419
|
-
evaluateWaitingResponse(threadId, runId, confirmationEvent, options = {}) {
|
|
1420
|
-
const guard = new instance_ai_1.InstanceAiTerminalResponseGuard({
|
|
1421
|
-
runId,
|
|
1422
|
-
rootAgentId: ORCHESTRATOR_AGENT_ID,
|
|
1423
|
-
messageGroupId: options.messageGroupId,
|
|
1424
|
-
correlationId: options.correlationId,
|
|
1425
|
-
});
|
|
1426
|
-
const decision = guard.evaluateWaiting(this.getTerminalGuardEvents(threadId, runId, options.messageGroupId), confirmationEvent);
|
|
1427
|
-
this.handleTerminalResponseDecision(threadId, runId, decision, options.messageGroupId);
|
|
1428
|
-
return decision;
|
|
1429
|
-
}
|
|
1430
|
-
getTerminalGuardEvents(threadId, runId, messageGroupId) {
|
|
1431
|
-
if (!messageGroupId)
|
|
1432
|
-
return this.eventBus.getEventsForRun(threadId, runId);
|
|
1433
|
-
const groupRunIds = this.getRunIdsForMessageGroup(messageGroupId);
|
|
1434
|
-
return groupRunIds.length > 0
|
|
1435
|
-
? this.eventBus.getEventsForRuns(threadId, groupRunIds)
|
|
1436
|
-
: this.eventBus.getEventsForRun(threadId, runId);
|
|
1437
|
-
}
|
|
1438
|
-
handleTerminalResponseDecision(threadId, runId, decision, messageGroupId) {
|
|
1439
|
-
this.telemetry.track('instance_ai_terminal_response_decision', {
|
|
1440
|
-
thread_id: threadId,
|
|
1441
|
-
run_id: runId,
|
|
1442
|
-
message_group_id: messageGroupId,
|
|
1443
|
-
source: 'terminal_guard',
|
|
1444
|
-
status: decision.status,
|
|
1445
|
-
action: decision.action,
|
|
1446
|
-
reason: decision.reason,
|
|
1447
|
-
visibility_source: decision.visibilitySource,
|
|
1448
|
-
});
|
|
1449
|
-
if (decision.reason === 'completed-after-error') {
|
|
1450
|
-
this.logger.warn('completed_after_error_event', {
|
|
1451
|
-
threadId,
|
|
1452
|
-
runId,
|
|
1453
|
-
messageGroupId,
|
|
1454
|
-
});
|
|
1455
|
-
}
|
|
1456
|
-
if (decision.reason === 'confirmation-invalid') {
|
|
1457
|
-
this.logger.warn('invalid_confirmation_payload', {
|
|
1458
|
-
threadId,
|
|
1459
|
-
runId,
|
|
1460
|
-
messageGroupId,
|
|
1461
|
-
});
|
|
1462
|
-
}
|
|
1463
|
-
if (decision.action === 'emit' && decision.event) {
|
|
1464
|
-
this.eventBus.publish(threadId, decision.event);
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
createTerminalOutcomeStorage() {
|
|
1468
|
-
this.terminalOutcomeStorage ??= new instance_ai_1.TerminalOutcomeStorage(this.agentMemory);
|
|
1469
|
-
return this.terminalOutcomeStorage;
|
|
1470
|
-
}
|
|
1471
|
-
async finishInvalidConfirmationRun(args) {
|
|
1472
|
-
this.runState.cancelThread(args.threadId);
|
|
1473
|
-
void this.suspendedThreads.dropPendingConfirmationsForThread(args.threadId);
|
|
1474
|
-
args.abortController.abort();
|
|
1475
|
-
await this.finalizeRunTracing(args.runId, args.tracing, {
|
|
1476
|
-
status: 'error',
|
|
1477
|
-
reason: 'invalid_confirmation_payload',
|
|
1478
|
-
});
|
|
1479
|
-
this.publishRunFinish(args.threadId, args.runId, 'errored', 'I need your input to continue, but I could not display the prompt. Please try again.');
|
|
1480
|
-
await this.saveAgentTreeSnapshot(args.threadId, args.runId, args.snapshotStorage);
|
|
1481
|
-
return {
|
|
1482
|
-
status: 'error',
|
|
1483
|
-
reason: 'invalid_confirmation_payload',
|
|
1484
|
-
metadata: this.buildMessageTraceMetadata(args.threadId, args.runId, {
|
|
1485
|
-
status: 'error',
|
|
1486
|
-
}),
|
|
1487
|
-
};
|
|
1488
|
-
}
|
|
1489
|
-
buildBackgroundTerminalOutcome(task) {
|
|
1490
|
-
const status = task.status === 'failed' ? 'failed' : task.status === 'cancelled' ? 'cancelled' : 'completed';
|
|
1491
|
-
const userFacingMessage = status === 'completed'
|
|
1492
|
-
? `The background ${task.role} task finished.`
|
|
1493
|
-
: status === 'cancelled'
|
|
1494
|
-
? `The background ${task.role} task was cancelled.`
|
|
1495
|
-
: `The background ${task.role} task failed before I could complete that part.`;
|
|
1496
|
-
return {
|
|
1497
|
-
id: `${task.messageGroupId ?? task.runId}:${task.taskId}:${status}`,
|
|
1498
|
-
threadId: task.threadId,
|
|
1499
|
-
runId: task.runId,
|
|
1500
|
-
messageGroupId: task.messageGroupId,
|
|
1501
|
-
correlationId: task.messageGroupId,
|
|
1502
|
-
taskId: task.taskId,
|
|
1503
|
-
agentId: task.agentId,
|
|
1504
|
-
status,
|
|
1505
|
-
userFacingMessage,
|
|
1506
|
-
createdAt: new Date().toISOString(),
|
|
1507
|
-
};
|
|
1508
|
-
}
|
|
1509
1115
|
async replayUndeliveredTerminalOutcomes(threadId, options = {}) {
|
|
1510
|
-
|
|
1511
|
-
const persistedOutcomes = await storage.getUndelivered(threadId).catch((error) => {
|
|
1512
|
-
this.logger.warn('Failed to load undelivered Instance AI terminal outcomes', {
|
|
1513
|
-
threadId,
|
|
1514
|
-
error: getErrorMessage(error),
|
|
1515
|
-
});
|
|
1516
|
-
return [];
|
|
1517
|
-
});
|
|
1518
|
-
const inMemoryOutcomes = [...this.pendingTerminalOutcomes.values()].filter((outcome) => outcome.threadId === threadId);
|
|
1519
|
-
const outcomes = new Map();
|
|
1520
|
-
for (const outcome of [...persistedOutcomes, ...inMemoryOutcomes]) {
|
|
1521
|
-
outcomes.set(outcome.id, outcome);
|
|
1522
|
-
}
|
|
1523
|
-
const persistedOutcomeIds = new Set(persistedOutcomes.map((outcome) => outcome.id));
|
|
1524
|
-
const delivery = options.delivery ?? 'snapshot';
|
|
1525
|
-
for (const outcome of outcomes.values()) {
|
|
1526
|
-
const responseId = getBackgroundOutcomeResponseId(outcome);
|
|
1527
|
-
let snapshotDelivered = false;
|
|
1528
|
-
try {
|
|
1529
|
-
snapshotDelivered = await this.persistTerminalOutcomeLineToSnapshot(outcome, responseId);
|
|
1530
|
-
}
|
|
1531
|
-
catch (error) {
|
|
1532
|
-
this.logger.warn('Failed to replay Instance AI terminal outcome', {
|
|
1533
|
-
threadId,
|
|
1534
|
-
runId: outcome.runId,
|
|
1535
|
-
taskId: outcome.taskId,
|
|
1536
|
-
error: getErrorMessage(error),
|
|
1537
|
-
});
|
|
1538
|
-
if (delivery === 'event') {
|
|
1539
|
-
const published = this.publishTerminalOutcomeLine(outcome, responseId);
|
|
1540
|
-
this.telemetry.track('instance_ai_terminal_response_decision', {
|
|
1541
|
-
thread_id: threadId,
|
|
1542
|
-
run_id: outcome.runId,
|
|
1543
|
-
message_group_id: outcome.messageGroupId,
|
|
1544
|
-
task_id: outcome.taskId,
|
|
1545
|
-
source: 'terminal_outcome_replay',
|
|
1546
|
-
status: outcome.status,
|
|
1547
|
-
action: published ? 'replay_event' : 'already-emitted',
|
|
1548
|
-
visibility_source: 'background-outcome',
|
|
1549
|
-
});
|
|
1550
|
-
}
|
|
1551
|
-
continue;
|
|
1552
|
-
}
|
|
1553
|
-
if (!snapshotDelivered)
|
|
1554
|
-
continue;
|
|
1555
|
-
let action = 'replay_snapshot';
|
|
1556
|
-
if (delivery === 'event') {
|
|
1557
|
-
const published = this.publishTerminalOutcomeLine(outcome, responseId);
|
|
1558
|
-
action = published ? 'replay_event' : 'already-emitted';
|
|
1559
|
-
}
|
|
1560
|
-
if (persistedOutcomeIds.has(outcome.id)) {
|
|
1561
|
-
await storage
|
|
1562
|
-
.markDelivered(threadId, outcome.id, new Date().toISOString())
|
|
1563
|
-
.catch((error) => {
|
|
1564
|
-
this.logger.warn('Failed to mark Instance AI terminal outcome as delivered', {
|
|
1565
|
-
threadId,
|
|
1566
|
-
runId: outcome.runId,
|
|
1567
|
-
taskId: outcome.taskId,
|
|
1568
|
-
error: getErrorMessage(error),
|
|
1569
|
-
});
|
|
1570
|
-
});
|
|
1571
|
-
}
|
|
1572
|
-
this.pendingTerminalOutcomes.delete(outcome.id);
|
|
1573
|
-
this.telemetry.track('instance_ai_terminal_response_decision', {
|
|
1574
|
-
thread_id: threadId,
|
|
1575
|
-
run_id: outcome.runId,
|
|
1576
|
-
message_group_id: outcome.messageGroupId,
|
|
1577
|
-
task_id: outcome.taskId,
|
|
1578
|
-
source: 'terminal_outcome_replay',
|
|
1579
|
-
status: outcome.status,
|
|
1580
|
-
action,
|
|
1581
|
-
visibility_source: 'background-outcome',
|
|
1582
|
-
});
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
async persistTerminalOutcomeLineToSnapshot(outcome, responseId) {
|
|
1586
|
-
const snapshot = await this.dbSnapshotStorage.getLatest(outcome.threadId, {
|
|
1587
|
-
messageGroupId: outcome.messageGroupId,
|
|
1588
|
-
runId: outcome.runId,
|
|
1589
|
-
});
|
|
1590
|
-
if (!snapshot) {
|
|
1591
|
-
await this.dbSnapshotStorage.save(outcome.threadId, createTerminalOutcomeAgentTree(outcome, responseId), outcome.runId, {
|
|
1592
|
-
messageGroupId: outcome.messageGroupId,
|
|
1593
|
-
runIds: [outcome.runId],
|
|
1594
|
-
});
|
|
1595
|
-
return true;
|
|
1596
|
-
}
|
|
1597
|
-
const { tree } = appendTerminalOutcomeToAgentTree(snapshot.tree, outcome, responseId);
|
|
1598
|
-
const runIds = new Set(snapshot.runIds ?? [snapshot.runId]);
|
|
1599
|
-
runIds.add(outcome.runId);
|
|
1600
|
-
await this.dbSnapshotStorage.updateLast(outcome.threadId, tree, snapshot.runId, {
|
|
1601
|
-
messageGroupId: snapshot.messageGroupId ?? outcome.messageGroupId,
|
|
1602
|
-
runIds: [...runIds],
|
|
1603
|
-
langsmithRunId: snapshot.langsmithRunId,
|
|
1604
|
-
langsmithTraceId: snapshot.langsmithTraceId,
|
|
1605
|
-
});
|
|
1606
|
-
return true;
|
|
1607
|
-
}
|
|
1608
|
-
publishTerminalOutcomeLine(outcome, responseId) {
|
|
1609
|
-
const alreadyPublished = this.eventBus
|
|
1610
|
-
.getEventsForRun(outcome.threadId, outcome.runId)
|
|
1611
|
-
.some((event) => event.responseId === responseId);
|
|
1612
|
-
if (alreadyPublished)
|
|
1613
|
-
return false;
|
|
1614
|
-
this.eventBus.publish(outcome.threadId, {
|
|
1615
|
-
type: 'text-delta',
|
|
1616
|
-
runId: outcome.runId,
|
|
1617
|
-
agentId: ORCHESTRATOR_AGENT_ID,
|
|
1618
|
-
responseId,
|
|
1619
|
-
payload: { text: outcome.userFacingMessage },
|
|
1620
|
-
});
|
|
1621
|
-
return true;
|
|
1622
|
-
}
|
|
1623
|
-
async recordBackgroundTerminalOutcome(task) {
|
|
1624
|
-
const outcome = this.buildBackgroundTerminalOutcome(task);
|
|
1625
|
-
let persisted = false;
|
|
1626
|
-
try {
|
|
1627
|
-
await this.createTerminalOutcomeStorage().upsert(task.threadId, outcome);
|
|
1628
|
-
persisted = true;
|
|
1629
|
-
}
|
|
1630
|
-
catch (error) {
|
|
1631
|
-
this.pendingTerminalOutcomes.set(outcome.id, outcome);
|
|
1632
|
-
this.logger.warn('Failed to persist Instance AI terminal outcome', {
|
|
1633
|
-
threadId: task.threadId,
|
|
1634
|
-
runId: task.runId,
|
|
1635
|
-
taskId: task.taskId,
|
|
1636
|
-
error: getErrorMessage(error),
|
|
1637
|
-
});
|
|
1638
|
-
this.telemetry.track('instance_ai_terminal_outcome_persistence_failure', {
|
|
1639
|
-
thread_id: task.threadId,
|
|
1640
|
-
run_id: task.runId,
|
|
1641
|
-
task_id: task.taskId,
|
|
1642
|
-
status: outcome.status,
|
|
1643
|
-
phase: 'metadata',
|
|
1644
|
-
});
|
|
1645
|
-
}
|
|
1646
|
-
const responseId = getBackgroundOutcomeResponseId(outcome);
|
|
1647
|
-
const published = this.publishTerminalOutcomeLine(outcome, responseId);
|
|
1648
|
-
this.telemetry.track('instance_ai_terminal_response_decision', {
|
|
1649
|
-
thread_id: task.threadId,
|
|
1650
|
-
run_id: task.runId,
|
|
1651
|
-
message_group_id: task.messageGroupId,
|
|
1652
|
-
task_id: task.taskId,
|
|
1653
|
-
source: 'background_outcome',
|
|
1654
|
-
status: outcome.status,
|
|
1655
|
-
action: published ? 'emit' : 'already-emitted',
|
|
1656
|
-
visibility_source: 'background-outcome',
|
|
1657
|
-
});
|
|
1658
|
-
let snapshotDelivered = false;
|
|
1659
|
-
try {
|
|
1660
|
-
snapshotDelivered = await this.persistTerminalOutcomeLineToSnapshot(outcome, responseId);
|
|
1661
|
-
}
|
|
1662
|
-
catch (error) {
|
|
1663
|
-
this.logger.warn('Failed to persist Instance AI terminal outcome line to snapshot', {
|
|
1664
|
-
threadId: task.threadId,
|
|
1665
|
-
runId: task.runId,
|
|
1666
|
-
taskId: task.taskId,
|
|
1667
|
-
error: getErrorMessage(error),
|
|
1668
|
-
});
|
|
1669
|
-
this.telemetry.track('instance_ai_terminal_outcome_persistence_failure', {
|
|
1670
|
-
thread_id: task.threadId,
|
|
1671
|
-
run_id: task.runId,
|
|
1672
|
-
task_id: task.taskId,
|
|
1673
|
-
status: outcome.status,
|
|
1674
|
-
phase: 'snapshot',
|
|
1675
|
-
});
|
|
1676
|
-
}
|
|
1677
|
-
if (!persisted || !snapshotDelivered)
|
|
1678
|
-
return;
|
|
1679
|
-
try {
|
|
1680
|
-
await this.createTerminalOutcomeStorage().markDelivered(task.threadId, outcome.id, new Date().toISOString());
|
|
1681
|
-
this.pendingTerminalOutcomes.delete(outcome.id);
|
|
1682
|
-
}
|
|
1683
|
-
catch (error) {
|
|
1684
|
-
this.logger.warn('Failed to mark Instance AI terminal outcome as delivered', {
|
|
1685
|
-
threadId: task.threadId,
|
|
1686
|
-
runId: task.runId,
|
|
1687
|
-
taskId: task.taskId,
|
|
1688
|
-
error: getErrorMessage(error),
|
|
1689
|
-
});
|
|
1690
|
-
}
|
|
1116
|
+
await this.terminalOutcome.replayUndeliveredTerminalOutcomes(threadId, options);
|
|
1691
1117
|
}
|
|
1692
1118
|
async syncPlannedTasksToUi(threadId, graph) {
|
|
1693
1119
|
const { taskStorage } = await this.createPlannedTaskState();
|
|
@@ -1696,7 +1122,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1696
1122
|
this.eventBus.publish(threadId, {
|
|
1697
1123
|
type: 'tasks-update',
|
|
1698
1124
|
runId: graph.planRunId,
|
|
1699
|
-
agentId:
|
|
1125
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(graph.planRunId),
|
|
1700
1126
|
payload: { tasks },
|
|
1701
1127
|
});
|
|
1702
1128
|
}
|
|
@@ -1711,7 +1137,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1711
1137
|
this.eventBus.publish(threadId, {
|
|
1712
1138
|
type: 'tasks-update',
|
|
1713
1139
|
runId: graph.planRunId,
|
|
1714
|
-
agentId:
|
|
1140
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(graph.planRunId),
|
|
1715
1141
|
payload: { tasks: { tasks: [] }, planItems: [] },
|
|
1716
1142
|
});
|
|
1717
1143
|
}
|
|
@@ -1730,6 +1156,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1730
1156
|
}
|
|
1731
1157
|
const adminSettings = this.settingsService.getAdminSettings();
|
|
1732
1158
|
const localGatewayDisabledGlobally = adminSettings.localGatewayDisabled;
|
|
1159
|
+
const browserUseEnabledGlobally = adminSettings.browserUseEnabled;
|
|
1733
1160
|
const localGatewayDisabledForUser = await this.settingsService.isLocalGatewayDisabledForUser(user.id);
|
|
1734
1161
|
const userGateway = this.gatewayService.findGateway(user.id);
|
|
1735
1162
|
const { searchProxyConfig, tracingProxyConfig, tokenManager, proxyBaseUrl } = proxyRunConfig ?? (await this.createProxyRunConfig(user));
|
|
@@ -1740,8 +1167,14 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1740
1167
|
projectId: boundProjectId,
|
|
1741
1168
|
credentialIdAllowlist: this.evalCredentialAllowlists.get(threadId),
|
|
1742
1169
|
});
|
|
1743
|
-
|
|
1744
|
-
|
|
1170
|
+
this.gatewayService.applyToolPolicy(user.id);
|
|
1171
|
+
const gatewayMcpServer = !localGatewayDisabledForUser && userGateway?.isConnected ? userGateway : undefined;
|
|
1172
|
+
const browserMcpServer = browserUseEnabledGlobally
|
|
1173
|
+
? this.browserSessionService.findMcpServer(user.id)
|
|
1174
|
+
: undefined;
|
|
1175
|
+
const localMcpServer = (0, composite_local_mcp_server_1.composeLocalMcpServers)(gatewayMcpServer, browserMcpServer);
|
|
1176
|
+
if (localMcpServer) {
|
|
1177
|
+
context.localMcpServer = localMcpServer;
|
|
1745
1178
|
}
|
|
1746
1179
|
context.permissions = this.settingsService.getPermissions();
|
|
1747
1180
|
if (this.sourceControlPreferencesService.getPreferences().branchReadOnly) {
|
|
@@ -1767,18 +1200,31 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1767
1200
|
this.runDebugBuffer.recordWorkflowCode(runId, snapshot);
|
|
1768
1201
|
};
|
|
1769
1202
|
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1203
|
+
browserMcpServer?.setDomainGate({
|
|
1204
|
+
tracker: domainTracker,
|
|
1205
|
+
runId,
|
|
1206
|
+
permissionMode: context.permissions?.fetchUrl,
|
|
1207
|
+
});
|
|
1208
|
+
if (gatewayMcpServer || browserMcpServer) {
|
|
1209
|
+
const capabilities = new Set();
|
|
1210
|
+
if (gatewayMcpServer) {
|
|
1211
|
+
for (const { name, enabled } of gatewayMcpServer.getStatus().toolCategories) {
|
|
1212
|
+
if (enabled) {
|
|
1213
|
+
capabilities.add(name);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
if (browserMcpServer) {
|
|
1218
|
+
capabilities.add(instance_ai_gateway_service_1.BROWSER_TOOL_CATEGORY);
|
|
1219
|
+
}
|
|
1774
1220
|
context.localGatewayStatus = {
|
|
1775
1221
|
status: 'connected',
|
|
1776
|
-
capabilities:
|
|
1777
|
-
.getStatus()
|
|
1778
|
-
.toolCategories.filter(({ enabled }) => enabled)
|
|
1779
|
-
.map(({ name }) => name),
|
|
1222
|
+
capabilities: [...capabilities],
|
|
1780
1223
|
};
|
|
1781
1224
|
}
|
|
1225
|
+
else if (localGatewayDisabledGlobally && !browserUseEnabledGlobally) {
|
|
1226
|
+
context.localGatewayStatus = { status: 'disabledGlobally' };
|
|
1227
|
+
}
|
|
1782
1228
|
else {
|
|
1783
1229
|
context.localGatewayStatus = {
|
|
1784
1230
|
status: localGatewayDisabledForUser ? 'disabled' : 'disconnected',
|
|
@@ -1854,7 +1300,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1854
1300
|
messageGroupId,
|
|
1855
1301
|
userId: user.id,
|
|
1856
1302
|
projectId: boundProjectId,
|
|
1857
|
-
orchestratorAgentId:
|
|
1303
|
+
orchestratorAgentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
1858
1304
|
modelId,
|
|
1859
1305
|
checkpointStore: this.checkpointStore,
|
|
1860
1306
|
subAgentMaxSteps: this.instanceAiConfig.subAgentMaxSteps,
|
|
@@ -1876,7 +1322,6 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1876
1322
|
formBaseUrl: this.formBaseUrl,
|
|
1877
1323
|
waitForConfirmation: async (requestId) => {
|
|
1878
1324
|
this.runState.touchActiveRun(threadId);
|
|
1879
|
-
void this.persistUserMessageOnFirstSuspend(threadId, runId);
|
|
1880
1325
|
return await new Promise((resolve) => {
|
|
1881
1326
|
this.runState.registerPendingConfirmation(requestId, {
|
|
1882
1327
|
resolve,
|
|
@@ -1905,9 +1350,6 @@ let InstanceAiService = class InstanceAiService {
|
|
|
1905
1350
|
schedulePlannedTasks: async () => await this.schedulePlannedTasks(user, threadId),
|
|
1906
1351
|
iterationLog,
|
|
1907
1352
|
sendCorrectionToTask: (taskId, correction) => this.sendCorrectionToTask(threadId, taskId, correction),
|
|
1908
|
-
persistInFlightUserMessage: async () => {
|
|
1909
|
-
await this.persistUserMessageOnFirstSuspend(threadId, runId);
|
|
1910
|
-
},
|
|
1911
1353
|
workflowTaskService: workflowTasks,
|
|
1912
1354
|
workspace: runtimeWorkspace,
|
|
1913
1355
|
workspaceRoot,
|
|
@@ -2029,7 +1471,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2029
1471
|
}
|
|
2030
1472
|
this.collectWorkflowIds(task.outcome, ids);
|
|
2031
1473
|
}
|
|
2032
|
-
const tracing = this.getTraceContextForContinuation(threadId);
|
|
1474
|
+
const tracing = this.tracing.getTraceContextForContinuation(threadId);
|
|
2033
1475
|
for (const workflowId of [...ids]) {
|
|
2034
1476
|
const remappedWorkflowId = tracing?.idRemapper?.remapOutput(workflowId);
|
|
2035
1477
|
if (typeof remappedWorkflowId === 'string' && remappedWorkflowId.length > 0) {
|
|
@@ -2122,6 +1564,55 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2122
1564
|
};
|
|
2123
1565
|
return `<workflow-setup-required>\n${JSON.stringify(payload, null, 2)}\n</workflow-setup-required>\n\n${internal_messages_1.AUTO_FOLLOW_UP_MESSAGE}`;
|
|
2124
1566
|
}
|
|
1567
|
+
getWorkflowSetupSuspensionWorkflowId(toolName, suspendPayload) {
|
|
1568
|
+
if (toolName !== 'workflows' || !suspendPayload)
|
|
1569
|
+
return undefined;
|
|
1570
|
+
if (!Array.isArray(suspendPayload.setupRequests))
|
|
1571
|
+
return undefined;
|
|
1572
|
+
return typeof suspendPayload.workflowId === 'string' ? suspendPayload.workflowId : undefined;
|
|
1573
|
+
}
|
|
1574
|
+
async markWorkflowSetupHandled(threadId, workflowId, runId) {
|
|
1575
|
+
const records = await this.listWorkflowLoopRecords(threadId);
|
|
1576
|
+
if (records.length === 0)
|
|
1577
|
+
return false;
|
|
1578
|
+
const candidates = [];
|
|
1579
|
+
for (const record of records) {
|
|
1580
|
+
if (record.state.setupRoutedAt)
|
|
1581
|
+
continue;
|
|
1582
|
+
if (this.workflowObligations.isPlannedRecord(record))
|
|
1583
|
+
continue;
|
|
1584
|
+
const obligation = this.workflowObligations.obligationFromRecord(threadId, record, {
|
|
1585
|
+
source: 'direct',
|
|
1586
|
+
});
|
|
1587
|
+
if (obligation.workflowId !== workflowId)
|
|
1588
|
+
continue;
|
|
1589
|
+
if (obligation.setupRequirement?.status !== 'required')
|
|
1590
|
+
continue;
|
|
1591
|
+
candidates.push({ record, obligation });
|
|
1592
|
+
}
|
|
1593
|
+
const sameRunCandidates = runId
|
|
1594
|
+
? candidates.filter(({ obligation, record }) => obligation.runId === runId || record.state.runId === runId)
|
|
1595
|
+
: [];
|
|
1596
|
+
const fallbackCandidates = candidates.filter((candidate) => !sameRunCandidates.includes(candidate));
|
|
1597
|
+
for (const { record, obligation } of [...sameRunCandidates, ...fallbackCandidates]) {
|
|
1598
|
+
const claim = await this.claimWorkItemSetupRouting(threadId, record);
|
|
1599
|
+
if (!claim)
|
|
1600
|
+
continue;
|
|
1601
|
+
const marked = await this.markWorkItemSetupRouted(threadId, record.state.workItemId, claim.claimId);
|
|
1602
|
+
if (!marked) {
|
|
1603
|
+
await this.releaseWorkItemSetupRoutingClaim(threadId, record.state.workItemId, claim.claimId);
|
|
1604
|
+
this.logger.warn('Workflow setup completed but routing marker was not saved', {
|
|
1605
|
+
threadId,
|
|
1606
|
+
workItemId: record.state.workItemId,
|
|
1607
|
+
workflowId,
|
|
1608
|
+
});
|
|
1609
|
+
continue;
|
|
1610
|
+
}
|
|
1611
|
+
this.trackWorkflowVerificationObligation(obligation, 'setup_completed_by_tool');
|
|
1612
|
+
return true;
|
|
1613
|
+
}
|
|
1614
|
+
return false;
|
|
1615
|
+
}
|
|
2125
1616
|
async maybeStartWorkflowSetupFollowUp(user, threadId) {
|
|
2126
1617
|
const records = await this.listWorkflowLoopRecords(threadId);
|
|
2127
1618
|
if (records.length === 0)
|
|
@@ -2201,7 +1692,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2201
1692
|
: isReplanFollowUp
|
|
2202
1693
|
? 'replan'
|
|
2203
1694
|
: 'background_task_completed');
|
|
2204
|
-
this.startExecuteRun(user, threadId, runId, message, abortController, undefined, messageGroupId, timeZone, isReplanFollowUp, checkpoint, resumeReason, plannedBuild);
|
|
1695
|
+
this.startExecuteRun(user, threadId, runId, message, abortController, undefined, undefined, messageGroupId, timeZone, isReplanFollowUp, checkpoint, resumeReason, plannedBuild);
|
|
2205
1696
|
return runId;
|
|
2206
1697
|
}
|
|
2207
1698
|
async schedulePlannedTasks(user, threadId) {
|
|
@@ -2291,7 +1782,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2291
1782
|
}
|
|
2292
1783
|
async createPlannedTaskDispatchContext(user, threadId, graph) {
|
|
2293
1784
|
const environment = await this.createExecutionEnvironment(user, threadId, graph.planRunId, createInertAbortSignal(), graph.messageGroupId, this.threadPushRef.get(threadId));
|
|
2294
|
-
environment.orchestrationContext.tracing = this.getTraceContext(graph.planRunId);
|
|
1785
|
+
environment.orchestrationContext.tracing = this.tracing.getTraceContext(graph.planRunId);
|
|
2295
1786
|
return environment.orchestrationContext;
|
|
2296
1787
|
}
|
|
2297
1788
|
async doSchedulePlannedTasks(user, threadId) {
|
|
@@ -2326,8 +1817,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2326
1817
|
return;
|
|
2327
1818
|
}
|
|
2328
1819
|
}
|
|
2329
|
-
async executeRun(user, threadId, runId, message, abortController, attachments, messageGroupId, timeZone, isReplanFollowUp = false, checkpoint, resumeReason, plannedBuild) {
|
|
2330
|
-
const userMessagePersistence = this.userMessagePersistenceByRun.get(runId)?.message;
|
|
1820
|
+
async executeRun(user, threadId, runId, message, abortController, attachments, handoffContext, messageGroupId, timeZone, isReplanFollowUp = false, checkpoint, resumeReason, plannedBuild) {
|
|
2331
1821
|
const fileAttachments = (attachments ?? []).filter((attachment) => attachment.type === 'file');
|
|
2332
1822
|
const workflowAttachments = (attachments ?? []).filter((attachment) => attachment.type === 'workflow');
|
|
2333
1823
|
const signal = abortController.signal;
|
|
@@ -2352,7 +1842,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2352
1842
|
};
|
|
2353
1843
|
const proxyRunConfig = await this.createProxyRunConfig(user);
|
|
2354
1844
|
if (resumeReason) {
|
|
2355
|
-
tracing = await this.createOrchestratorResumeTraceContext({
|
|
1845
|
+
tracing = await this.tracing.createOrchestratorResumeTraceContext({
|
|
2356
1846
|
threadId,
|
|
2357
1847
|
messageId,
|
|
2358
1848
|
messageGroupId,
|
|
@@ -2390,19 +1880,19 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2390
1880
|
this.eventBus.publish(threadId, {
|
|
2391
1881
|
type: 'run-start',
|
|
2392
1882
|
runId,
|
|
2393
|
-
agentId:
|
|
1883
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
2394
1884
|
userId: user.id,
|
|
2395
1885
|
payload: { messageId, messageGroupId, ...(traceId ? { traceId } : {}) },
|
|
2396
1886
|
});
|
|
2397
1887
|
if (signal.aborted) {
|
|
2398
|
-
this.evaluateTerminalResponse(threadId, runId, 'cancelled', {
|
|
1888
|
+
this.terminalOutcome.evaluateTerminalResponse(threadId, runId, 'cancelled', {
|
|
2399
1889
|
messageGroupId,
|
|
2400
1890
|
correlationId: messageId,
|
|
2401
1891
|
});
|
|
2402
1892
|
this.eventBus.publish(threadId, {
|
|
2403
1893
|
type: 'run-finish',
|
|
2404
1894
|
runId,
|
|
2405
|
-
agentId:
|
|
1895
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
2406
1896
|
payload: { status: 'cancelled', reason: 'user_cancelled' },
|
|
2407
1897
|
});
|
|
2408
1898
|
return;
|
|
@@ -2413,7 +1903,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2413
1903
|
threadId,
|
|
2414
1904
|
runId,
|
|
2415
1905
|
tracing,
|
|
2416
|
-
agentId:
|
|
1906
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
2417
1907
|
userId: user.id,
|
|
2418
1908
|
messageGroupId,
|
|
2419
1909
|
messageId,
|
|
@@ -2480,10 +1970,10 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2480
1970
|
}
|
|
2481
1971
|
if (tracing) {
|
|
2482
1972
|
orchestrationContext.tracing = tracing;
|
|
2483
|
-
if (this.getTraceContext(runId) !== tracing) {
|
|
2484
|
-
await this.configureTraceReplayMode(tracing);
|
|
1973
|
+
if (this.tracing.getTraceContext(runId) !== tracing) {
|
|
1974
|
+
await this.tracing.configureTraceReplayMode(tracing);
|
|
2485
1975
|
this.runState.attachTracing(threadId, tracing);
|
|
2486
|
-
this.storeTraceContext(runId, threadId, tracing, messageGroupId);
|
|
1976
|
+
this.tracing.storeTraceContext(runId, threadId, tracing, messageGroupId);
|
|
2487
1977
|
}
|
|
2488
1978
|
}
|
|
2489
1979
|
const thread = await memory.getThread(threadId);
|
|
@@ -2504,12 +1994,13 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2504
1994
|
this.eventBus.publish(threadId, {
|
|
2505
1995
|
type: 'tasks-update',
|
|
2506
1996
|
runId,
|
|
2507
|
-
agentId:
|
|
1997
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
2508
1998
|
payload: { tasks: existingTasks },
|
|
2509
1999
|
});
|
|
2510
2000
|
}
|
|
2511
2001
|
const enrichedMessage = await this.buildMessageWithRunningTasks(threadId, message);
|
|
2512
2002
|
const contextResourcesBlock = buildContextResourcesBlock(workflowAttachments);
|
|
2003
|
+
const handoffContextBlock = buildHandoffContextBlock(handoffContext);
|
|
2513
2004
|
let nonStructuredAttachments = [];
|
|
2514
2005
|
let attachmentManifest = '';
|
|
2515
2006
|
let hasParseableAttachment = false;
|
|
@@ -2524,7 +2015,9 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2524
2015
|
: attachmentManifest
|
|
2525
2016
|
? `${enrichedMessage}\n\n${attachmentManifest}`
|
|
2526
2017
|
: enrichedMessage;
|
|
2527
|
-
const messageWithContext = [contextResourcesBlock, messageBody]
|
|
2018
|
+
const messageWithContext = [contextResourcesBlock, handoffContextBlock, messageBody]
|
|
2019
|
+
.filter(Boolean)
|
|
2020
|
+
.join('\n\n');
|
|
2528
2021
|
const fullMessage = (0, internal_messages_1.withCurrentDateTime)(messageWithContext, (0, instance_ai_1.getDateTimeSection)(timeZone ?? this.defaultTimeZone));
|
|
2529
2022
|
const promptBuildRun = tracing
|
|
2530
2023
|
? await tracing.startChildRun(tracing.messageRun, {
|
|
@@ -2540,7 +2033,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2540
2033
|
: undefined;
|
|
2541
2034
|
let streamInput;
|
|
2542
2035
|
try {
|
|
2543
|
-
if (nonStructuredAttachments.length > 0
|
|
2036
|
+
if (nonStructuredAttachments.length > 0) {
|
|
2544
2037
|
const baseContent = [
|
|
2545
2038
|
{ type: 'text', text: fullMessage },
|
|
2546
2039
|
...nonStructuredAttachments.map((attachment) => ({
|
|
@@ -2551,7 +2044,6 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2551
2044
|
];
|
|
2552
2045
|
streamInput = [
|
|
2553
2046
|
{
|
|
2554
|
-
...(userMessagePersistence ? { id: userMessagePersistence.id } : {}),
|
|
2555
2047
|
role: 'user',
|
|
2556
2048
|
content: baseContent,
|
|
2557
2049
|
},
|
|
@@ -2589,7 +2081,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2589
2081
|
tags: ['orchestrator'],
|
|
2590
2082
|
metadata: {
|
|
2591
2083
|
agent_role: 'orchestrator',
|
|
2592
|
-
agent_id:
|
|
2084
|
+
agent_id: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
2593
2085
|
execution_mode: 'foreground',
|
|
2594
2086
|
trace_kind: tracing.traceKind,
|
|
2595
2087
|
},
|
|
@@ -2598,6 +2090,8 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2598
2090
|
tracing.actorRun = actorRun;
|
|
2599
2091
|
tracing.orchestratorRun = actorRun;
|
|
2600
2092
|
}
|
|
2093
|
+
const runControl = (0, instance_ai_1.createOrchestratorRunControl)(orchestrationContext);
|
|
2094
|
+
const stopSignal = () => runControl.getStopSignal();
|
|
2601
2095
|
const agent = await (0, instance_ai_1.createInstanceAgent)({
|
|
2602
2096
|
modelId,
|
|
2603
2097
|
context,
|
|
@@ -2610,28 +2104,31 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2610
2104
|
onMemoryTaskEvent: this.memoryTaskObserverFor(threadId),
|
|
2611
2105
|
thinkingEnabled: this.instanceAiConfig.thinkingEnabled,
|
|
2612
2106
|
});
|
|
2107
|
+
this.subscribeToAgentErrors(agent, threadId, runId);
|
|
2613
2108
|
const streamOptions = this.buildOrchestratorAgentStreamOptions(user, threadId, runId, signal);
|
|
2614
2109
|
const result = tracing
|
|
2615
2110
|
? await tracing.withActiveSpan(tracing.actorRun, async () => {
|
|
2616
2111
|
return await (0, instance_ai_1.streamAgentRun)(agent, streamInput, streamOptions, {
|
|
2617
2112
|
threadId,
|
|
2618
2113
|
runId,
|
|
2619
|
-
agentId:
|
|
2114
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
2620
2115
|
signal,
|
|
2621
2116
|
eventBus: this.eventBus,
|
|
2622
2117
|
logger: this.logger,
|
|
2623
2118
|
onActivity: () => this.runState.touchActiveRun(threadId),
|
|
2119
|
+
stopSignal,
|
|
2624
2120
|
outputRedaction: (0, output_redaction_config_1.resolveOutputRedaction)(this.instanceAiConfig),
|
|
2625
2121
|
});
|
|
2626
2122
|
})
|
|
2627
2123
|
: await (0, instance_ai_1.streamAgentRun)(agent, streamInput, streamOptions, {
|
|
2628
2124
|
threadId,
|
|
2629
2125
|
runId,
|
|
2630
|
-
agentId:
|
|
2126
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
2631
2127
|
signal,
|
|
2632
2128
|
eventBus: this.eventBus,
|
|
2633
2129
|
logger: this.logger,
|
|
2634
2130
|
onActivity: () => this.runState.touchActiveRun(threadId),
|
|
2131
|
+
stopSignal,
|
|
2635
2132
|
outputRedaction: (0, output_redaction_config_1.resolveOutputRedaction)(this.instanceAiConfig),
|
|
2636
2133
|
});
|
|
2637
2134
|
if (result.status === 'suspended') {
|
|
@@ -2643,6 +2140,10 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2643
2140
|
threadId,
|
|
2644
2141
|
user,
|
|
2645
2142
|
toolCallId: result.suspension.toolCallId,
|
|
2143
|
+
...(result.suspension.toolName ? { toolName: result.suspension.toolName } : {}),
|
|
2144
|
+
...(result.suspension.suspendPayload
|
|
2145
|
+
? { suspendPayload: result.suspension.suspendPayload }
|
|
2146
|
+
: {}),
|
|
2646
2147
|
requestId: result.suspension.requestId,
|
|
2647
2148
|
abortController,
|
|
2648
2149
|
messageGroupId,
|
|
@@ -2651,6 +2152,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2651
2152
|
modelId,
|
|
2652
2153
|
checkpoint,
|
|
2653
2154
|
plannedBuild,
|
|
2155
|
+
runHandoff: runControl.state,
|
|
2654
2156
|
});
|
|
2655
2157
|
void this.suspendedThreads.persistPendingConfirmation({
|
|
2656
2158
|
requestId: result.suspension.requestId,
|
|
@@ -2672,12 +2174,12 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2672
2174
|
is_intermediate: true,
|
|
2673
2175
|
});
|
|
2674
2176
|
}
|
|
2675
|
-
const waitingDecision = this.evaluateWaitingResponse(threadId, runId, result.confirmationEvent, {
|
|
2177
|
+
const waitingDecision = this.terminalOutcome.evaluateWaitingResponse(threadId, runId, result.confirmationEvent, {
|
|
2676
2178
|
messageGroupId,
|
|
2677
2179
|
correlationId: messageId,
|
|
2678
2180
|
});
|
|
2679
2181
|
if (waitingDecision?.reason === 'confirmation-invalid') {
|
|
2680
|
-
messageTraceFinalization = await this.finishInvalidConfirmationRun({
|
|
2182
|
+
messageTraceFinalization = await this.terminalOutcome.finishInvalidConfirmationRun({
|
|
2681
2183
|
threadId,
|
|
2682
2184
|
runId,
|
|
2683
2185
|
abortController,
|
|
@@ -2700,7 +2202,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2700
2202
|
: {}),
|
|
2701
2203
|
...(result.suspension?.toolName ? { toolName: result.suspension.toolName } : {}),
|
|
2702
2204
|
};
|
|
2703
|
-
await this.finalizeRunTracing(runId, tracing, {
|
|
2205
|
+
await this.tracing.finalizeRunTracing(runId, tracing, {
|
|
2704
2206
|
status: 'suspended',
|
|
2705
2207
|
outputs: suspensionOutputs,
|
|
2706
2208
|
metadata: {
|
|
@@ -2740,21 +2242,23 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2740
2242
|
threadId,
|
|
2741
2243
|
runId,
|
|
2742
2244
|
tracing,
|
|
2743
|
-
agentId:
|
|
2245
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
2744
2246
|
userId: user.id,
|
|
2745
2247
|
messageGroupId,
|
|
2746
2248
|
messageId,
|
|
2747
2249
|
});
|
|
2748
2250
|
}
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2251
|
+
if (runControl.shouldEmitTerminalOutcome(result.stopReason)) {
|
|
2252
|
+
this.terminalOutcome.evaluateTerminalResponse(threadId, runId, result.status, {
|
|
2253
|
+
messageGroupId,
|
|
2254
|
+
correlationId: messageId,
|
|
2255
|
+
workSummary: result.workSummary,
|
|
2256
|
+
suppressCompletedFallback: checkpoint?.isCheckpointFollowUp === true ||
|
|
2257
|
+
plannedBuild?.isPlannedBuildFollowUp === true,
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2756
2260
|
const finalStatus = result.status === 'errored' ? 'error' : result.status;
|
|
2757
|
-
await this.finalizeRunTracing(runId, tracing, {
|
|
2261
|
+
await this.tracing.finalizeRunTracing(runId, tracing, {
|
|
2758
2262
|
status: finalStatus,
|
|
2759
2263
|
outputText,
|
|
2760
2264
|
modelId,
|
|
@@ -2763,7 +2267,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2763
2267
|
status: finalStatus,
|
|
2764
2268
|
outputText,
|
|
2765
2269
|
modelId,
|
|
2766
|
-
metadata: this.buildMessageTraceMetadata(threadId, runId, { status: finalStatus }),
|
|
2270
|
+
metadata: this.tracing.buildMessageTraceMetadata(threadId, runId, { status: finalStatus }),
|
|
2767
2271
|
};
|
|
2768
2272
|
const archivedWorkflowIds = await this.temporaryWorkflowService.reapForRun(threadId, user, aiCreatedWorkflowIds, this.backgroundTasks.getRunningTasks(threadId).length);
|
|
2769
2273
|
await this.finalizeRun(threadId, runId, result.status, snapshotStorage, {
|
|
@@ -2796,18 +2300,18 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2796
2300
|
if (cancellationReason === liveness_1.INSTANCE_AI_RUN_TIMEOUT_REASON) {
|
|
2797
2301
|
this.liveness.publishRunTimeoutNotice(threadId, runId);
|
|
2798
2302
|
}
|
|
2799
|
-
this.evaluateTerminalResponse(threadId, runId, 'cancelled', {
|
|
2303
|
+
this.terminalOutcome.evaluateTerminalResponse(threadId, runId, 'cancelled', {
|
|
2800
2304
|
messageGroupId,
|
|
2801
2305
|
correlationId: messageId,
|
|
2802
2306
|
});
|
|
2803
|
-
await this.finalizeRunTracing(runId, tracing, {
|
|
2307
|
+
await this.tracing.finalizeRunTracing(runId, tracing, {
|
|
2804
2308
|
status: 'cancelled',
|
|
2805
2309
|
reason: cancellationReason,
|
|
2806
2310
|
});
|
|
2807
2311
|
messageTraceFinalization = {
|
|
2808
2312
|
status: 'cancelled',
|
|
2809
2313
|
reason: cancellationReason,
|
|
2810
|
-
metadata: this.buildMessageTraceMetadata(threadId, runId, {
|
|
2314
|
+
metadata: this.tracing.buildMessageTraceMetadata(threadId, runId, {
|
|
2811
2315
|
status: 'cancelled',
|
|
2812
2316
|
cancellationReason,
|
|
2813
2317
|
runTimeout,
|
|
@@ -2826,7 +2330,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2826
2330
|
threadId,
|
|
2827
2331
|
runId,
|
|
2828
2332
|
tracing,
|
|
2829
|
-
agentId:
|
|
2333
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
2830
2334
|
userId: user.id,
|
|
2831
2335
|
messageGroupId,
|
|
2832
2336
|
messageId,
|
|
@@ -2836,25 +2340,25 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2836
2340
|
...(0, observability_1.buildInstanceAiObservabilityContext)(errCtx),
|
|
2837
2341
|
});
|
|
2838
2342
|
this.reportInstanceAiError(error, { component: 'instance-ai-run', ...errCtx });
|
|
2839
|
-
this.evaluateTerminalResponse(threadId, runId, 'errored', {
|
|
2343
|
+
this.terminalOutcome.evaluateTerminalResponse(threadId, runId, 'errored', {
|
|
2840
2344
|
messageGroupId,
|
|
2841
2345
|
correlationId: messageId,
|
|
2842
2346
|
errorMessage: userFacingErrorMessage,
|
|
2843
2347
|
});
|
|
2844
|
-
await this.finalizeRunTracing(runId, tracing, {
|
|
2348
|
+
await this.tracing.finalizeRunTracing(runId, tracing, {
|
|
2845
2349
|
status: 'error',
|
|
2846
2350
|
reason: errorMessage,
|
|
2847
2351
|
});
|
|
2848
2352
|
messageTraceFinalization = {
|
|
2849
2353
|
status: 'error',
|
|
2850
2354
|
reason: errorMessage,
|
|
2851
|
-
metadata: this.buildMessageTraceMetadata(threadId, runId, { status: 'error' }),
|
|
2355
|
+
metadata: this.tracing.buildMessageTraceMetadata(threadId, runId, { status: 'error' }),
|
|
2852
2356
|
};
|
|
2853
2357
|
const archivedWorkflowIds = await this.temporaryWorkflowService.reapForRun(threadId, user, aiCreatedWorkflowIds, this.backgroundTasks.getRunningTasks(threadId).length);
|
|
2854
2358
|
this.eventBus.publish(threadId, {
|
|
2855
2359
|
type: 'run-finish',
|
|
2856
2360
|
runId,
|
|
2857
|
-
agentId:
|
|
2361
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
2858
2362
|
payload: {
|
|
2859
2363
|
status: 'error',
|
|
2860
2364
|
reason: userFacingErrorMessage,
|
|
@@ -2867,10 +2371,9 @@ let InstanceAiService = class InstanceAiService {
|
|
|
2867
2371
|
}
|
|
2868
2372
|
finally {
|
|
2869
2373
|
this.runState.clearActiveRun(threadId);
|
|
2870
|
-
this.userMessagePersistenceByRun.delete(runId);
|
|
2871
2374
|
this.domainAccessTrackersByThread.get(threadId)?.clearRun(runId);
|
|
2872
2375
|
if (messageTraceFinalization) {
|
|
2873
|
-
await this.maybeFinalizeRunTraceRoot(runId, messageTraceFinalization);
|
|
2376
|
+
await this.tracing.maybeFinalizeRunTraceRoot(runId, messageTraceFinalization);
|
|
2874
2377
|
if (messageTraceFinalization.status !== 'cancelled') {
|
|
2875
2378
|
this.liveness.consumeRunTimeout(runId);
|
|
2876
2379
|
}
|
|
@@ -3086,6 +2589,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3086
2589
|
return { kind: 'env-failure', error };
|
|
3087
2590
|
}
|
|
3088
2591
|
const mcpServers = this.parseMcpServers(this.instanceAiConfig.mcpServers);
|
|
2592
|
+
const runControl = (0, instance_ai_1.createOrchestratorRunControl)(environment.orchestrationContext);
|
|
3089
2593
|
let agent;
|
|
3090
2594
|
try {
|
|
3091
2595
|
agent = await (0, instance_ai_1.createInstanceAgent)({
|
|
@@ -3100,6 +2604,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3100
2604
|
onMemoryTaskEvent: this.memoryTaskObserverFor(orphan.threadId),
|
|
3101
2605
|
thinkingEnabled: this.instanceAiConfig.thinkingEnabled,
|
|
3102
2606
|
});
|
|
2607
|
+
this.subscribeToAgentErrors(agent, orphan.threadId, orphan.runId);
|
|
3103
2608
|
}
|
|
3104
2609
|
catch (error) {
|
|
3105
2610
|
return { kind: 'agent-failure', error };
|
|
@@ -3122,6 +2627,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3122
2627
|
checkpoint: orphan.checkpointTaskId
|
|
3123
2628
|
? { isCheckpointFollowUp: true, checkpointTaskId: orphan.checkpointTaskId }
|
|
3124
2629
|
: undefined,
|
|
2630
|
+
runHandoff: runControl.state,
|
|
3125
2631
|
},
|
|
3126
2632
|
};
|
|
3127
2633
|
}
|
|
@@ -3153,7 +2659,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3153
2659
|
});
|
|
3154
2660
|
return false;
|
|
3155
2661
|
}
|
|
3156
|
-
const { agent, runId, agentRunId, threadId, user, toolCallId, abortController, tracing, modelId, messageGroupId, checkpoint, plannedBuild, } = suspended;
|
|
2662
|
+
const { agent, runId, agentRunId, threadId, user, toolCallId, toolName, suspendPayload, abortController, tracing, modelId, messageGroupId, checkpoint, plannedBuild, runHandoff, } = suspended;
|
|
3157
2663
|
if (user.id !== requestingUserId)
|
|
3158
2664
|
return false;
|
|
3159
2665
|
const activeUser = await this.revalidateActiveUser(user.id);
|
|
@@ -3181,7 +2687,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3181
2687
|
...(data.resourceDecision ? { resourceDecision: data.resourceDecision } : {}),
|
|
3182
2688
|
...(data.scope ? { scope: data.scope } : {}),
|
|
3183
2689
|
};
|
|
3184
|
-
const resumeTracing = await this.createOrchestratorResumeTraceContext({
|
|
2690
|
+
const resumeTracing = await this.tracing.createOrchestratorResumeTraceContext({
|
|
3185
2691
|
baseTracing: tracing,
|
|
3186
2692
|
threadId,
|
|
3187
2693
|
messageId: (0, nanoid_1.nanoid)(),
|
|
@@ -3214,6 +2720,8 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3214
2720
|
threadId,
|
|
3215
2721
|
user: activeUser,
|
|
3216
2722
|
toolCallId,
|
|
2723
|
+
toolName,
|
|
2724
|
+
suspendPayload,
|
|
3217
2725
|
signal: abortController.signal,
|
|
3218
2726
|
abortController,
|
|
3219
2727
|
snapshotStorage: this.dbSnapshotStorage,
|
|
@@ -3221,11 +2729,13 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3221
2729
|
modelId,
|
|
3222
2730
|
checkpoint,
|
|
3223
2731
|
plannedBuild,
|
|
2732
|
+
runHandoff,
|
|
3224
2733
|
});
|
|
3225
2734
|
return true;
|
|
3226
2735
|
}
|
|
3227
2736
|
async processResumedStream(agent, resumeData, opts) {
|
|
3228
2737
|
let messageTraceFinalization;
|
|
2738
|
+
let completedSetupWorkflowId;
|
|
3229
2739
|
try {
|
|
3230
2740
|
if (opts.tracing?.getTelemetry && isTelemetryConfigurableAgent(agent)) {
|
|
3231
2741
|
try {
|
|
@@ -3244,34 +2754,38 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3244
2754
|
}
|
|
3245
2755
|
}
|
|
3246
2756
|
const resumeOptions = this.buildOrchestratorResumeAgentOptions(opts.user, opts.threadId, opts.runId, opts.agentRunId, opts.toolCallId);
|
|
2757
|
+
const runControl = (0, instance_ai_1.createOrchestratorRunControlForState)(opts.runHandoff);
|
|
2758
|
+
const stopSignal = () => runControl.getStopSignal();
|
|
3247
2759
|
const result = opts.tracing
|
|
3248
2760
|
? await opts.tracing.withActiveSpan(opts.tracing.actorRun, async () => {
|
|
3249
2761
|
return await (0, instance_ai_1.resumeAgentRun)(agent, resumeData, resumeOptions, {
|
|
3250
2762
|
threadId: opts.threadId,
|
|
3251
2763
|
runId: opts.runId,
|
|
3252
|
-
agentId:
|
|
2764
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(opts.runId),
|
|
3253
2765
|
signal: opts.signal,
|
|
3254
2766
|
eventBus: this.eventBus,
|
|
3255
2767
|
logger: this.logger,
|
|
3256
2768
|
agentRunId: opts.agentRunId,
|
|
3257
2769
|
onActivity: () => this.runState.touchActiveRun(opts.threadId),
|
|
2770
|
+
stopSignal,
|
|
3258
2771
|
outputRedaction: (0, output_redaction_config_1.resolveOutputRedaction)(this.instanceAiConfig),
|
|
3259
2772
|
});
|
|
3260
2773
|
})
|
|
3261
2774
|
: await (0, instance_ai_1.resumeAgentRun)(agent, resumeData, resumeOptions, {
|
|
3262
2775
|
threadId: opts.threadId,
|
|
3263
2776
|
runId: opts.runId,
|
|
3264
|
-
agentId:
|
|
2777
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(opts.runId),
|
|
3265
2778
|
signal: opts.signal,
|
|
3266
2779
|
eventBus: this.eventBus,
|
|
3267
2780
|
logger: this.logger,
|
|
3268
2781
|
agentRunId: opts.agentRunId,
|
|
3269
2782
|
onActivity: () => this.runState.touchActiveRun(opts.threadId),
|
|
2783
|
+
stopSignal,
|
|
3270
2784
|
outputRedaction: (0, output_redaction_config_1.resolveOutputRedaction)(this.instanceAiConfig),
|
|
3271
2785
|
});
|
|
3272
2786
|
if (result.status === 'suspended') {
|
|
3273
2787
|
if (result.suspension) {
|
|
3274
|
-
const resumeMessageGroupId = this.
|
|
2788
|
+
const resumeMessageGroupId = this.tracing.getMessageGroupId(opts.runId);
|
|
3275
2789
|
this.runState.suspendRun(opts.threadId, {
|
|
3276
2790
|
runId: opts.runId,
|
|
3277
2791
|
agentRunId: result.agentRunId,
|
|
@@ -3279,6 +2793,10 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3279
2793
|
threadId: opts.threadId,
|
|
3280
2794
|
user: opts.user,
|
|
3281
2795
|
toolCallId: result.suspension.toolCallId,
|
|
2796
|
+
...(result.suspension.toolName ? { toolName: result.suspension.toolName } : {}),
|
|
2797
|
+
...(result.suspension.suspendPayload
|
|
2798
|
+
? { suspendPayload: result.suspension.suspendPayload }
|
|
2799
|
+
: {}),
|
|
3282
2800
|
requestId: result.suspension.requestId,
|
|
3283
2801
|
abortController: opts.abortController,
|
|
3284
2802
|
messageGroupId: resumeMessageGroupId,
|
|
@@ -3287,6 +2805,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3287
2805
|
...(opts.modelId !== undefined ? { modelId: opts.modelId } : {}),
|
|
3288
2806
|
checkpoint: opts.checkpoint,
|
|
3289
2807
|
plannedBuild: opts.plannedBuild,
|
|
2808
|
+
runHandoff: runControl.state,
|
|
3290
2809
|
});
|
|
3291
2810
|
void this.suspendedThreads.persistPendingConfirmation({
|
|
3292
2811
|
requestId: result.suspension.requestId,
|
|
@@ -3308,10 +2827,10 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3308
2827
|
is_intermediate: true,
|
|
3309
2828
|
});
|
|
3310
2829
|
}
|
|
3311
|
-
const messageGroupId = this.
|
|
3312
|
-
const waitingDecision = this.evaluateWaitingResponse(opts.threadId, opts.runId, result.confirmationEvent, { messageGroupId });
|
|
2830
|
+
const messageGroupId = this.tracing.getMessageGroupId(opts.runId);
|
|
2831
|
+
const waitingDecision = this.terminalOutcome.evaluateWaitingResponse(opts.threadId, opts.runId, result.confirmationEvent, { messageGroupId });
|
|
3313
2832
|
if (waitingDecision?.reason === 'confirmation-invalid') {
|
|
3314
|
-
messageTraceFinalization = await this.finishInvalidConfirmationRun({
|
|
2833
|
+
messageTraceFinalization = await this.terminalOutcome.finishInvalidConfirmationRun({
|
|
3315
2834
|
threadId: opts.threadId,
|
|
3316
2835
|
runId: opts.runId,
|
|
3317
2836
|
abortController: opts.abortController,
|
|
@@ -3334,7 +2853,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3334
2853
|
: {}),
|
|
3335
2854
|
...(result.suspension?.toolName ? { toolName: result.suspension.toolName } : {}),
|
|
3336
2855
|
};
|
|
3337
|
-
await this.finalizeRunTracing(opts.runId, opts.tracing, {
|
|
2856
|
+
await this.tracing.finalizeRunTracing(opts.runId, opts.tracing, {
|
|
3338
2857
|
status: 'suspended',
|
|
3339
2858
|
outputs: suspensionOutputs,
|
|
3340
2859
|
metadata: {
|
|
@@ -3368,33 +2887,35 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3368
2887
|
return;
|
|
3369
2888
|
}
|
|
3370
2889
|
const outputText = await (result.text ?? Promise.resolve(''));
|
|
3371
|
-
const messageGroupId = this.
|
|
2890
|
+
const messageGroupId = this.tracing.getMessageGroupId(opts.runId);
|
|
3372
2891
|
if (result.status === 'errored') {
|
|
3373
2892
|
this.reportInstanceAiError(result.error ?? new Error('Instance AI resumed stream errored'), {
|
|
3374
2893
|
component: 'instance-ai-stream',
|
|
3375
2894
|
threadId: opts.threadId,
|
|
3376
2895
|
runId: opts.runId,
|
|
3377
2896
|
tracing: opts.tracing,
|
|
3378
|
-
agentId:
|
|
2897
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(opts.runId),
|
|
3379
2898
|
userId: opts.user.id,
|
|
3380
2899
|
messageGroupId,
|
|
3381
2900
|
});
|
|
3382
2901
|
}
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
opts.
|
|
3388
|
-
|
|
2902
|
+
if (runControl.shouldEmitTerminalOutcome(result.stopReason)) {
|
|
2903
|
+
this.terminalOutcome.evaluateTerminalResponse(opts.threadId, opts.runId, result.status, {
|
|
2904
|
+
messageGroupId,
|
|
2905
|
+
workSummary: result.workSummary,
|
|
2906
|
+
suppressCompletedFallback: opts.checkpoint?.isCheckpointFollowUp === true ||
|
|
2907
|
+
opts.plannedBuild?.isPlannedBuildFollowUp === true,
|
|
2908
|
+
});
|
|
2909
|
+
}
|
|
3389
2910
|
const finalStatus = result.status === 'errored' ? 'error' : result.status;
|
|
3390
|
-
await this.finalizeRunTracing(opts.runId, opts.tracing, {
|
|
2911
|
+
await this.tracing.finalizeRunTracing(opts.runId, opts.tracing, {
|
|
3391
2912
|
status: finalStatus,
|
|
3392
2913
|
outputText,
|
|
3393
2914
|
});
|
|
3394
2915
|
messageTraceFinalization = {
|
|
3395
2916
|
status: finalStatus,
|
|
3396
2917
|
outputText,
|
|
3397
|
-
metadata: this.buildMessageTraceMetadata(opts.threadId, opts.runId, {
|
|
2918
|
+
metadata: this.tracing.buildMessageTraceMetadata(opts.threadId, opts.runId, {
|
|
3398
2919
|
status: finalStatus,
|
|
3399
2920
|
}),
|
|
3400
2921
|
};
|
|
@@ -3407,6 +2928,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3407
2928
|
});
|
|
3408
2929
|
await this.creditService.claimRunUsage(opts.user, opts.threadId, result.agentRunId || opts.runId, result.usage?.usage ?? [], result.status);
|
|
3409
2930
|
if (result.status === 'completed') {
|
|
2931
|
+
completedSetupWorkflowId = this.getWorkflowSetupSuspensionWorkflowId(opts.toolName, opts.suspendPayload);
|
|
3410
2932
|
this.telemetry.track('Builder sent message', {
|
|
3411
2933
|
thread_id: opts.threadId,
|
|
3412
2934
|
message: outputText,
|
|
@@ -3421,7 +2943,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3421
2943
|
if (this.shouldPreserveHitlOnShutdown(opts.runId)) {
|
|
3422
2944
|
return;
|
|
3423
2945
|
}
|
|
3424
|
-
const messageGroupId = this.
|
|
2946
|
+
const messageGroupId = this.tracing.getMessageGroupId(opts.runId);
|
|
3425
2947
|
const runTimeout = this.liveness.consumeRunTimeout(opts.runId);
|
|
3426
2948
|
const cancellationReason = runTimeout.timedOut
|
|
3427
2949
|
? liveness_1.INSTANCE_AI_RUN_TIMEOUT_REASON
|
|
@@ -3429,17 +2951,17 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3429
2951
|
if (cancellationReason === liveness_1.INSTANCE_AI_RUN_TIMEOUT_REASON) {
|
|
3430
2952
|
this.liveness.publishRunTimeoutNotice(opts.threadId, opts.runId);
|
|
3431
2953
|
}
|
|
3432
|
-
this.evaluateTerminalResponse(opts.threadId, opts.runId, 'cancelled', {
|
|
2954
|
+
this.terminalOutcome.evaluateTerminalResponse(opts.threadId, opts.runId, 'cancelled', {
|
|
3433
2955
|
messageGroupId,
|
|
3434
2956
|
});
|
|
3435
|
-
await this.finalizeRunTracing(opts.runId, opts.tracing, {
|
|
2957
|
+
await this.tracing.finalizeRunTracing(opts.runId, opts.tracing, {
|
|
3436
2958
|
status: 'cancelled',
|
|
3437
2959
|
reason: cancellationReason,
|
|
3438
2960
|
});
|
|
3439
2961
|
messageTraceFinalization = {
|
|
3440
2962
|
status: 'cancelled',
|
|
3441
2963
|
reason: cancellationReason,
|
|
3442
|
-
metadata: this.buildMessageTraceMetadata(opts.threadId, opts.runId, {
|
|
2964
|
+
metadata: this.tracing.buildMessageTraceMetadata(opts.threadId, opts.runId, {
|
|
3443
2965
|
status: 'cancelled',
|
|
3444
2966
|
cancellationReason,
|
|
3445
2967
|
runTimeout,
|
|
@@ -3452,12 +2974,12 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3452
2974
|
}
|
|
3453
2975
|
const errorMessage = getErrorMessage(error);
|
|
3454
2976
|
const userFacingErrorMessage = getUserFacingErrorMessage(error);
|
|
3455
|
-
const messageGroupId = this.
|
|
2977
|
+
const messageGroupId = this.tracing.getMessageGroupId(opts.runId);
|
|
3456
2978
|
const errCtx = {
|
|
3457
2979
|
threadId: opts.threadId,
|
|
3458
2980
|
runId: opts.runId,
|
|
3459
2981
|
tracing: opts.tracing,
|
|
3460
|
-
agentId:
|
|
2982
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(opts.runId),
|
|
3461
2983
|
userId: opts.user.id,
|
|
3462
2984
|
messageGroupId,
|
|
3463
2985
|
};
|
|
@@ -3466,18 +2988,18 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3466
2988
|
...(0, observability_1.buildInstanceAiObservabilityContext)(errCtx),
|
|
3467
2989
|
});
|
|
3468
2990
|
this.reportInstanceAiError(error, { component: 'instance-ai-run', ...errCtx });
|
|
3469
|
-
this.evaluateTerminalResponse(opts.threadId, opts.runId, 'errored', {
|
|
2991
|
+
this.terminalOutcome.evaluateTerminalResponse(opts.threadId, opts.runId, 'errored', {
|
|
3470
2992
|
messageGroupId,
|
|
3471
2993
|
errorMessage: userFacingErrorMessage,
|
|
3472
2994
|
});
|
|
3473
|
-
await this.finalizeRunTracing(opts.runId, opts.tracing, {
|
|
2995
|
+
await this.tracing.finalizeRunTracing(opts.runId, opts.tracing, {
|
|
3474
2996
|
status: 'error',
|
|
3475
2997
|
reason: errorMessage,
|
|
3476
2998
|
});
|
|
3477
2999
|
messageTraceFinalization = {
|
|
3478
3000
|
status: 'error',
|
|
3479
3001
|
reason: errorMessage,
|
|
3480
|
-
metadata: this.buildMessageTraceMetadata(opts.threadId, opts.runId, {
|
|
3002
|
+
metadata: this.tracing.buildMessageTraceMetadata(opts.threadId, opts.runId, {
|
|
3481
3003
|
status: 'error',
|
|
3482
3004
|
}),
|
|
3483
3005
|
};
|
|
@@ -3485,7 +3007,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3485
3007
|
this.eventBus.publish(opts.threadId, {
|
|
3486
3008
|
type: 'run-finish',
|
|
3487
3009
|
runId: opts.runId,
|
|
3488
|
-
agentId:
|
|
3010
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(opts.runId),
|
|
3489
3011
|
payload: {
|
|
3490
3012
|
status: 'error',
|
|
3491
3013
|
reason: userFacingErrorMessage,
|
|
@@ -3497,7 +3019,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3497
3019
|
finally {
|
|
3498
3020
|
this.runState.clearActiveRun(opts.threadId);
|
|
3499
3021
|
if (messageTraceFinalization) {
|
|
3500
|
-
await this.maybeFinalizeRunTraceRoot(opts.runId, messageTraceFinalization);
|
|
3022
|
+
await this.tracing.maybeFinalizeRunTraceRoot(opts.runId, messageTraceFinalization);
|
|
3501
3023
|
if (messageTraceFinalization.status !== 'cancelled') {
|
|
3502
3024
|
this.liveness.consumeRunTimeout(opts.runId);
|
|
3503
3025
|
}
|
|
@@ -3513,6 +3035,9 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3513
3035
|
await this.schedulePlannedTasks(opts.user, opts.threadId);
|
|
3514
3036
|
}
|
|
3515
3037
|
await this.drainPendingCheckpointReentries(opts.user, opts.threadId);
|
|
3038
|
+
if (completedSetupWorkflowId) {
|
|
3039
|
+
await this.markWorkflowSetupHandled(opts.threadId, completedSetupWorkflowId, opts.runId);
|
|
3040
|
+
}
|
|
3516
3041
|
await this.taskProjector.syncFromWorkflowLoop(opts.threadId, opts.runId);
|
|
3517
3042
|
await this.maybeStartWorkflowSetupFollowUp(opts.user, opts.threadId);
|
|
3518
3043
|
}
|
|
@@ -3534,7 +3059,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3534
3059
|
parentCheckpointId: opts.parentCheckpointId,
|
|
3535
3060
|
run: opts.run,
|
|
3536
3061
|
onLimitReached: async (errorMessage) => {
|
|
3537
|
-
await this.finalizeDetachedTraceRun(opts.taskId, opts.traceContext, {
|
|
3062
|
+
await this.tracing.finalizeDetachedTraceRun(opts.taskId, opts.traceContext, {
|
|
3538
3063
|
status: 'failed',
|
|
3539
3064
|
outputs: {
|
|
3540
3065
|
taskId: opts.taskId,
|
|
@@ -3559,7 +3084,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3559
3084
|
});
|
|
3560
3085
|
},
|
|
3561
3086
|
onCompleted: async (task) => {
|
|
3562
|
-
await this.finalizeBackgroundTaskTracing(task, 'completed');
|
|
3087
|
+
await this.tracing.finalizeBackgroundTaskTracing(task, 'completed');
|
|
3563
3088
|
this.eventBus.publish(opts.threadId, {
|
|
3564
3089
|
type: 'agent-completed',
|
|
3565
3090
|
runId,
|
|
@@ -3572,7 +3097,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3572
3097
|
}
|
|
3573
3098
|
},
|
|
3574
3099
|
onFailed: async (task) => {
|
|
3575
|
-
await this.finalizeBackgroundTaskTracing(task, 'failed');
|
|
3100
|
+
await this.tracing.finalizeBackgroundTaskTracing(task, 'failed');
|
|
3576
3101
|
this.reportInstanceAiError(new Error(task.error ?? 'Instance AI background task failed'), {
|
|
3577
3102
|
component: 'instance-ai-background-task',
|
|
3578
3103
|
threadId: opts.threadId,
|
|
@@ -3595,7 +3120,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3595
3120
|
}
|
|
3596
3121
|
},
|
|
3597
3122
|
onSettled: async (task) => {
|
|
3598
|
-
await this.recordBackgroundTerminalOutcome(task);
|
|
3123
|
+
await this.terminalOutcome.recordBackgroundTerminalOutcome(task);
|
|
3599
3124
|
await this.saveAgentTreeSnapshot(opts.threadId, runId, snapshotStorage, true, task.messageGroupId);
|
|
3600
3125
|
if (task.plannedTaskId)
|
|
3601
3126
|
return;
|
|
@@ -3665,7 +3190,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3665
3190
|
workflowId: opts.dedupeKey?.workflowId,
|
|
3666
3191
|
role: opts.role,
|
|
3667
3192
|
});
|
|
3668
|
-
void this.finalizeDetachedTraceRun(opts.taskId, opts.traceContext, {
|
|
3193
|
+
void this.tracing.finalizeDetachedTraceRun(opts.taskId, opts.traceContext, {
|
|
3669
3194
|
status: 'cancelled',
|
|
3670
3195
|
outputs: {
|
|
3671
3196
|
taskId: opts.taskId,
|
|
@@ -3758,17 +3283,17 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3758
3283
|
if (reason === liveness_1.INSTANCE_AI_RUN_TIMEOUT_REASON) {
|
|
3759
3284
|
this.liveness.publishRunTimeoutNotice(suspended.threadId, suspended.runId);
|
|
3760
3285
|
}
|
|
3761
|
-
await this.finalizeRunTracing(suspended.runId, suspended.tracing, {
|
|
3286
|
+
await this.tracing.finalizeRunTracing(suspended.runId, suspended.tracing, {
|
|
3762
3287
|
status: 'cancelled',
|
|
3763
3288
|
reason,
|
|
3764
3289
|
});
|
|
3765
3290
|
const archivedWorkflowIds = await this.temporaryWorkflowService.reapForRun(suspended.threadId, suspended.user, undefined, this.backgroundTasks.getRunningTasks(suspended.threadId).length);
|
|
3766
3291
|
this.publishRunFinish(suspended.threadId, suspended.runId, 'cancelled', reason, archivedWorkflowIds, suspended.user.id);
|
|
3767
3292
|
await this.saveAgentTreeSnapshot(suspended.threadId, suspended.runId, this.dbSnapshotStorage, true);
|
|
3768
|
-
await this.maybeFinalizeRunTraceRoot(suspended.runId, {
|
|
3293
|
+
await this.tracing.maybeFinalizeRunTraceRoot(suspended.runId, {
|
|
3769
3294
|
status: 'cancelled',
|
|
3770
3295
|
reason,
|
|
3771
|
-
metadata: this.buildMessageTraceMetadata(suspended.threadId, suspended.runId, {
|
|
3296
|
+
metadata: this.tracing.buildMessageTraceMetadata(suspended.threadId, suspended.runId, {
|
|
3772
3297
|
status: 'cancelled',
|
|
3773
3298
|
cancellationReason: reason,
|
|
3774
3299
|
...(runTimeout ? { runTimeout } : {}),
|
|
@@ -3782,7 +3307,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3782
3307
|
this.eventBus.publish(threadId, {
|
|
3783
3308
|
type: 'run-finish',
|
|
3784
3309
|
runId,
|
|
3785
|
-
agentId:
|
|
3310
|
+
agentId: (0, instance_ai_1.orchestratorAgentId)(runId),
|
|
3786
3311
|
payload: {
|
|
3787
3312
|
status: effectiveStatus,
|
|
3788
3313
|
...(status === 'cancelled' ? { reason: reason ?? 'user_cancelled' } : {}),
|
|
@@ -3833,7 +3358,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3833
3358
|
if (userTexts.length === 0)
|
|
3834
3359
|
return;
|
|
3835
3360
|
const userText = userTexts.join('\n');
|
|
3836
|
-
const baseTracing = this.getTraceContextForContinuation(threadId);
|
|
3361
|
+
const baseTracing = this.tracing.getTraceContextForContinuation(threadId);
|
|
3837
3362
|
const titleTracing = await (0, instance_ai_1.createInternalOperationTraceContext)({
|
|
3838
3363
|
threadId,
|
|
3839
3364
|
conversationId: threadId,
|
|
@@ -3902,7 +3427,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3902
3427
|
this.eventBus.publish(threadId, {
|
|
3903
3428
|
type: 'thread-title-updated',
|
|
3904
3429
|
runId: '',
|
|
3905
|
-
agentId:
|
|
3430
|
+
agentId: 'orchestrator',
|
|
3906
3431
|
payload: { title: llmTitle },
|
|
3907
3432
|
});
|
|
3908
3433
|
}
|
|
@@ -3946,7 +3471,7 @@ let InstanceAiService = class InstanceAiService {
|
|
|
3946
3471
|
return;
|
|
3947
3472
|
}
|
|
3948
3473
|
const agentTree = (0, instance_ai_1.buildAgentTreeFromEvents)(events);
|
|
3949
|
-
const tracing = this.
|
|
3474
|
+
const tracing = this.tracing.getTraceContext(runId);
|
|
3950
3475
|
const saveOptions = {
|
|
3951
3476
|
messageGroupId,
|
|
3952
3477
|
runIds: groupRunIds,
|
|
@@ -4001,6 +3526,7 @@ exports.InstanceAiService = InstanceAiService = __decorate([
|
|
|
4001
3526
|
in_process_event_bus_1.InProcessEventBus,
|
|
4002
3527
|
instance_ai_settings_service_1.InstanceAiSettingsService,
|
|
4003
3528
|
instance_ai_gateway_service_1.InstanceAiGatewayService,
|
|
3529
|
+
instance_ai_browser_session_service_1.InstanceAiBrowserSessionService,
|
|
4004
3530
|
instance_ai_memory_service_1.InstanceAiMemoryService,
|
|
4005
3531
|
typeorm_agent_memory_1.TypeORMAgentMemory,
|
|
4006
3532
|
typeorm_agent_checkpoint_store_1.TypeORMAgentCheckpointStore,
|