n8n 2.22.4 → 2.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/auth.service.d.ts +2 -0
- package/dist/auth/auth.service.js +15 -4
- package/dist/auth/auth.service.js.map +1 -1
- package/dist/build.tsbuildinfo +1 -1
- package/dist/chat/chat-service.types.d.ts +4 -4
- package/dist/commands/execute.d.ts +2 -2
- package/dist/commands/export/workflow.js +1 -0
- package/dist/commands/export/workflow.js.map +1 -1
- package/dist/commands/license/info.js +4 -4
- package/dist/commands/license/info.js.map +1 -1
- package/dist/commands/start.js +21 -1
- package/dist/commands/start.js.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/controllers/annotation-tags.controller.ee.d.ts +1 -1
- package/dist/controllers/e2e.controller.js +1 -0
- package/dist/controllers/e2e.controller.js.map +1 -1
- package/dist/controllers/oauth/oauth1-credential.controller.d.ts +1 -1
- package/dist/controllers/oauth/oauth1-credential.controller.js +4 -7
- package/dist/controllers/oauth/oauth1-credential.controller.js.map +1 -1
- package/dist/controllers/oauth/oauth2-credential.controller.js +3 -6
- package/dist/controllers/oauth/oauth2-credential.controller.js.map +1 -1
- package/dist/controllers/redaction-enforcement-mapper.d.ts +3 -0
- package/dist/controllers/redaction-enforcement-mapper.js +27 -0
- package/dist/controllers/redaction-enforcement-mapper.js.map +1 -0
- package/dist/controllers/security-settings.controller.d.ts +8 -2
- package/dist/controllers/security-settings.controller.js +35 -25
- package/dist/controllers/security-settings.controller.js.map +1 -1
- package/dist/credentials/credential-connection-status-provider.interface.d.ts +3 -0
- package/dist/credentials/credential-connection-status-provider.interface.js +3 -0
- package/dist/credentials/credential-connection-status-provider.interface.js.map +1 -0
- package/dist/credentials/credential-connection-status-proxy.d.ts +6 -0
- package/dist/credentials/credential-connection-status-proxy.js +25 -0
- package/dist/credentials/credential-connection-status-proxy.js.map +1 -0
- package/dist/credentials/credential-resolution-provider.interface.d.ts +1 -0
- package/dist/credentials/credentials.controller.d.ts +2 -0
- package/dist/credentials/credentials.service.d.ts +10 -1
- package/dist/credentials/credentials.service.ee.d.ts +2 -0
- package/dist/credentials/credentials.service.ee.js +13 -3
- package/dist/credentials/credentials.service.ee.js.map +1 -1
- package/dist/credentials/credentials.service.js +34 -7
- package/dist/credentials/credentials.service.js.map +1 -1
- package/dist/credentials/dynamic-credentials-proxy.d.ts +2 -0
- package/dist/credentials/dynamic-credentials-proxy.js +9 -0
- package/dist/credentials/dynamic-credentials-proxy.js.map +1 -1
- package/dist/credentials-helper.js +2 -1
- package/dist/credentials-helper.js.map +1 -1
- package/dist/errors/feature-not-licensed.error.d.ts +3 -1
- package/dist/errors/feature-not-licensed.error.js +2 -2
- package/dist/errors/feature-not-licensed.error.js.map +1 -1
- package/dist/evaluation.ee/evaluation-collection.service.js +2 -0
- package/dist/evaluation.ee/evaluation-collection.service.js.map +1 -1
- package/dist/evaluation.ee/insights/eval-insights.controller.ee.d.ts +41 -0
- package/dist/evaluation.ee/insights/eval-insights.controller.ee.js +62 -0
- package/dist/evaluation.ee/insights/eval-insights.controller.ee.js.map +1 -0
- package/dist/evaluation.ee/insights/eval-insights.service.d.ts +25 -0
- package/dist/evaluation.ee/insights/eval-insights.service.js +206 -0
- package/dist/evaluation.ee/insights/eval-insights.service.js.map +1 -0
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.d.ts +3 -2
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.js +16 -2
- package/dist/evaluation.ee/test-runner/test-runner.service.ee.js.map +1 -1
- package/dist/events/relays/telemetry.event-relay.d.ts +3 -1
- package/dist/events/relays/telemetry.event-relay.js +9 -3
- package/dist/events/relays/telemetry.event-relay.js.map +1 -1
- package/dist/execution-lifecycle/execution-lifecycle-hooks.d.ts +1 -1
- package/dist/execution-lifecycle/execution-lifecycle-hooks.js +4 -2
- package/dist/execution-lifecycle/execution-lifecycle-hooks.js.map +1 -1
- package/dist/executions/execution-data/db-store.d.ts +4 -2
- package/dist/executions/execution-data/db-store.js +9 -4
- package/dist/executions/execution-data/db-store.js.map +1 -1
- package/dist/executions/execution-data/missing-execution-data.error.d.ts +5 -0
- package/dist/executions/execution-data/missing-execution-data.error.js +11 -0
- package/dist/executions/execution-data/missing-execution-data.error.js.map +1 -0
- package/dist/executions/execution-data/types.d.ts +3 -2
- package/dist/executions/execution-data/types.js.map +1 -1
- package/dist/executions/execution-persistence.d.ts +12 -3
- package/dist/executions/execution-persistence.js +102 -26
- package/dist/executions/execution-persistence.js.map +1 -1
- package/dist/external-hooks.d.ts +6 -1
- package/dist/external-hooks.js.map +1 -1
- package/dist/instance-settings-loader/loaders/sso/provisioning.instance-settings-loader.d.ts +3 -2
- package/dist/instance-settings-loader/loaders/sso/provisioning.instance-settings-loader.js +17 -12
- package/dist/instance-settings-loader/loaders/sso/provisioning.instance-settings-loader.js.map +1 -1
- package/dist/interfaces.d.ts +1 -0
- package/dist/license.d.ts +2 -0
- package/dist/license.js +6 -0
- package/dist/license.js.map +1 -1
- package/dist/load-nodes-and-credentials.d.ts +32 -4
- package/dist/manual-execution.service.js +3 -0
- package/dist/manual-execution.service.js.map +1 -1
- package/dist/modules/agents/agent-execution.service.js +5 -5
- package/dist/modules/agents/agent-execution.service.js.map +1 -1
- package/dist/modules/agents/agent-sse-stream.js +17 -1
- package/dist/modules/agents/agent-sse-stream.js.map +1 -1
- package/dist/modules/agents/agents-tools.service.js +7 -5
- package/dist/modules/agents/agents-tools.service.js.map +1 -1
- package/dist/modules/agents/agents.controller.d.ts +29 -3
- package/dist/modules/agents/agents.controller.js +88 -7
- package/dist/modules/agents/agents.controller.js.map +1 -1
- package/dist/modules/agents/agents.module.d.ts +1 -1
- package/dist/modules/agents/agents.module.js +12 -6
- package/dist/modules/agents/agents.module.js.map +1 -1
- package/dist/modules/agents/agents.service.d.ts +7 -8
- package/dist/modules/agents/agents.service.js +120 -65
- package/dist/modules/agents/agents.service.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder-model-recommendations.d.ts +1 -1
- package/dist/modules/agents/builder/agents-builder-model-recommendations.js +3 -3
- package/dist/modules/agents/builder/agents-builder-model-recommendations.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder-prompts.d.ts +9 -17
- package/dist/modules/agents/builder/agents-builder-prompts.js +145 -549
- package/dist/modules/agents/builder/agents-builder-prompts.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder-settings.service.js +2 -2
- package/dist/modules/agents/builder/agents-builder-settings.service.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder-tools.service.js +10 -10
- package/dist/modules/agents/builder/agents-builder-tools.service.js.map +1 -1
- package/dist/modules/agents/builder/agents-builder.service.d.ts +3 -1
- package/dist/modules/agents/builder/agents-builder.service.js +58 -9
- package/dist/modules/agents/builder/agents-builder.service.js.map +1 -1
- package/dist/modules/agents/builder/interactive/ask-credential.tool.js +2 -2
- package/dist/modules/agents/builder/interactive/ask-credential.tool.js.map +1 -1
- package/dist/modules/agents/builder/interactive/ask-llm.tool.js +2 -2
- package/dist/modules/agents/builder/interactive/ask-llm.tool.js.map +1 -1
- package/dist/modules/agents/builder/interactive/ask-question.tool.js +2 -2
- package/dist/modules/agents/builder/interactive/ask-question.tool.js.map +1 -1
- package/dist/modules/agents/builder/interactive/resolve-llm.tool.js +2 -2
- package/dist/modules/agents/builder/interactive/resolve-llm.tool.js.map +1 -1
- package/dist/modules/agents/builder/prompts/config-mutation.prompt.d.ts +1 -0
- package/dist/modules/agents/builder/prompts/config-mutation.prompt.js +132 -0
- package/dist/modules/agents/builder/prompts/config-mutation.prompt.js.map +1 -0
- package/dist/modules/agents/builder/prompts/config-rules.prompt.d.ts +2 -0
- package/dist/modules/agents/builder/prompts/config-rules.prompt.js +63 -0
- package/dist/modules/agents/builder/prompts/config-rules.prompt.js.map +1 -0
- package/dist/modules/agents/builder/prompts/llm-selection.prompt.d.ts +1 -0
- package/dist/modules/agents/builder/prompts/llm-selection.prompt.js +47 -0
- package/dist/modules/agents/builder/prompts/llm-selection.prompt.js.map +1 -0
- package/dist/modules/agents/builder/prompts/memory.prompt.d.ts +1 -0
- package/dist/modules/agents/builder/prompts/memory.prompt.js +60 -0
- package/dist/modules/agents/builder/prompts/memory.prompt.js.map +1 -0
- package/dist/modules/agents/builder/prompts/tools.prompt.d.ts +1 -0
- package/dist/modules/agents/builder/prompts/tools.prompt.js +81 -0
- package/dist/modules/agents/builder/prompts/tools.prompt.js.map +1 -0
- package/dist/modules/agents/builder/skills/index.d.ts +2 -0
- package/dist/modules/agents/builder/skills/index.js +12 -0
- package/dist/modules/agents/builder/skills/index.js.map +1 -0
- package/dist/modules/agents/builder/skills/integrations.skill.d.ts +2 -0
- package/dist/modules/agents/builder/skills/integrations.skill.js +53 -0
- package/dist/modules/agents/builder/skills/integrations.skill.js.map +1 -0
- package/dist/modules/agents/builder/skills/research.skill.d.ts +2 -0
- package/dist/modules/agents/builder/skills/research.skill.js +42 -0
- package/dist/modules/agents/builder/skills/research.skill.js.map +1 -0
- package/dist/modules/agents/builder/skills/target-skills.skill.d.ts +2 -0
- package/dist/modules/agents/builder/skills/target-skills.skill.js +59 -0
- package/dist/modules/agents/builder/skills/target-skills.skill.js.map +1 -0
- package/dist/modules/agents/entities/{agent-published-version.entity.d.ts → agent-history.entity.d.ts} +4 -7
- package/dist/modules/agents/entities/{agent-published-version.entity.js → agent-history.entity.js} +22 -34
- package/dist/modules/agents/entities/agent-history.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-memory-entry-cursor.entity.d.ts +7 -0
- package/dist/modules/agents/entities/agent-memory-entry-cursor.entity.js +38 -0
- package/dist/modules/agents/entities/agent-memory-entry-cursor.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-memory-entry-lock.entity.d.ts +7 -0
- package/dist/modules/{instance-ai/entities/instance-ai-workflow-snapshot.entity.js → agents/entities/agent-memory-entry-lock.entity.js} +16 -19
- package/dist/modules/agents/entities/agent-memory-entry-lock.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-memory-entry-source.entity.d.ts +9 -0
- package/dist/modules/agents/entities/agent-memory-entry-source.entity.js +49 -0
- package/dist/modules/agents/entities/agent-memory-entry-source.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-memory-entry.entity.d.ts +15 -0
- package/dist/modules/agents/entities/agent-memory-entry.entity.js +65 -0
- package/dist/modules/agents/entities/agent-memory-entry.entity.js.map +1 -0
- package/dist/modules/agents/entities/agent-observation-cursor.entity.d.ts +2 -3
- package/dist/modules/agents/entities/agent-observation-cursor.entity.js +5 -4
- package/dist/modules/agents/entities/agent-observation-cursor.entity.js.map +1 -1
- package/dist/modules/agents/entities/agent-observation-lock.entity.d.ts +2 -3
- package/dist/modules/agents/entities/agent-observation-lock.entity.js +5 -4
- package/dist/modules/agents/entities/agent-observation-lock.entity.js.map +1 -1
- package/dist/modules/agents/entities/agent-observation.entity.d.ts +2 -3
- package/dist/modules/agents/entities/agent-observation.entity.js +6 -5
- package/dist/modules/agents/entities/agent-observation.entity.js.map +1 -1
- package/dist/modules/agents/entities/agent.entity.d.ts +3 -5
- package/dist/modules/agents/entities/agent.entity.js +7 -14
- package/dist/modules/agents/entities/agent.entity.js.map +1 -1
- package/dist/modules/agents/episodic-memory.d.ts +2 -0
- package/dist/modules/agents/episodic-memory.js +12 -0
- package/dist/modules/agents/episodic-memory.js.map +1 -0
- package/dist/modules/agents/integrations/agent-chat-bridge.d.ts +2 -1
- package/dist/modules/agents/integrations/agent-chat-bridge.js +19 -5
- package/dist/modules/agents/integrations/agent-chat-bridge.js.map +1 -1
- package/dist/modules/agents/integrations/agent-schedule.service.js +10 -6
- package/dist/modules/agents/integrations/agent-schedule.service.js.map +1 -1
- package/dist/modules/agents/integrations/chat-integration.service.js +1 -1
- package/dist/modules/agents/integrations/chat-integration.service.js.map +1 -1
- package/dist/modules/agents/integrations/n8n-memory.d.ts +41 -18
- package/dist/modules/agents/integrations/n8n-memory.js +519 -77
- package/dist/modules/agents/integrations/n8n-memory.js.map +1 -1
- package/dist/modules/agents/integrations/platforms/slack-integration.js +2 -12
- package/dist/modules/agents/integrations/platforms/slack-integration.js.map +1 -1
- package/dist/modules/agents/integrations/rich-interaction-tool.d.ts +1 -1
- package/dist/modules/agents/integrations/rich-interaction-tool.js +2 -2
- package/dist/modules/agents/integrations/rich-interaction-tool.js.map +1 -1
- package/dist/modules/agents/integrations/slack-app-setup.service.d.ts +52 -0
- package/dist/modules/agents/integrations/slack-app-setup.service.js +316 -0
- package/dist/modules/agents/integrations/slack-app-setup.service.js.map +1 -0
- package/dist/modules/agents/json-config/from-json-config.d.ts +2 -3
- package/dist/modules/agents/json-config/from-json-config.js +76 -61
- package/dist/modules/agents/json-config/from-json-config.js.map +1 -1
- package/dist/modules/agents/json-config/schema-text-serializer.js +2 -1
- package/dist/modules/agents/json-config/schema-text-serializer.js.map +1 -1
- package/dist/modules/agents/repositories/agent-history.repository.d.ts +19 -0
- package/dist/modules/agents/repositories/agent-history.repository.js +51 -0
- package/dist/modules/agents/repositories/agent-history.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-memory-entry-cursor.repository.d.ts +5 -0
- package/dist/modules/{instance-ai/repositories/instance-ai-workflow-snapshot.repository.js → agents/repositories/agent-memory-entry-cursor.repository.js} +8 -8
- package/dist/modules/agents/repositories/agent-memory-entry-cursor.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-memory-entry-lock.repository.d.ts +5 -0
- package/dist/modules/{instance-ai/repositories/instance-ai-observational-memory.repository.js → agents/repositories/agent-memory-entry-lock.repository.js} +8 -8
- package/dist/modules/agents/repositories/agent-memory-entry-lock.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-memory-entry-source.repository.d.ts +5 -0
- package/dist/modules/agents/repositories/agent-memory-entry-source.repository.js +26 -0
- package/dist/modules/agents/repositories/agent-memory-entry-source.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent-memory-entry.repository.d.ts +5 -0
- package/dist/modules/agents/repositories/agent-memory-entry.repository.js +26 -0
- package/dist/modules/agents/repositories/agent-memory-entry.repository.js.map +1 -0
- package/dist/modules/agents/repositories/agent.repository.js +3 -3
- package/dist/modules/agents/repositories/agent.repository.js.map +1 -1
- package/dist/modules/agents/runtime/agent-secure-runtime.js +5 -5
- package/dist/modules/agents/runtime/agent-secure-runtime.js.map +1 -1
- package/dist/modules/agents/tools/environment-tool.d.ts +1 -1
- package/dist/modules/agents/tools/environment-tool.js +3 -3
- package/dist/modules/agents/tools/environment-tool.js.map +1 -1
- package/dist/modules/agents/tools/node-tool-factory.js +5 -5
- package/dist/modules/agents/tools/node-tool-factory.js.map +1 -1
- package/dist/modules/agents/tools/workflow-tool-factory.js +3 -3
- package/dist/modules/agents/tools/workflow-tool-factory.js.map +1 -1
- package/dist/modules/agents/tracing/builder-telemetry.d.ts +2 -3
- package/dist/modules/agents/tracing/builder-telemetry.js +36 -3
- package/dist/modules/agents/tracing/builder-telemetry.js.map +1 -1
- package/dist/modules/agents/utils/agent-draft.utils.js +1 -2
- package/dist/modules/agents/utils/agent-draft.utils.js.map +1 -1
- package/dist/modules/agents/utils/agent-memory-scope.d.ts +3 -0
- package/dist/modules/agents/utils/agent-memory-scope.js +15 -0
- package/dist/modules/agents/utils/agent-memory-scope.js.map +1 -0
- package/dist/modules/chat-hub/chat-hub.constants.js +4 -0
- package/dist/modules/chat-hub/chat-hub.constants.js.map +1 -1
- package/dist/modules/chat-hub/context-limits.js +1 -0
- package/dist/modules/chat-hub/context-limits.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/constants.d.ts +3 -0
- package/dist/modules/dynamic-credentials.ee/constants.js +7 -0
- package/dist/modules/dynamic-credentials.ee/constants.js.map +1 -0
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/n8n-identifier.js +14 -2
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/identifiers/n8n-identifier.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/credential-resolvers.controller.d.ts +2 -2
- package/dist/modules/dynamic-credentials.ee/credential-resolvers.controller.js +18 -4
- package/dist/modules/dynamic-credentials.ee/credential-resolvers.controller.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.d.ts +1 -1
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.js +4 -1
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.module.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/errors/system-resolver-modification.error.d.ts +4 -0
- package/dist/modules/dynamic-credentials.ee/errors/system-resolver-modification.error.js +11 -0
- package/dist/modules/dynamic-credentials.ee/errors/system-resolver-modification.error.js.map +1 -0
- package/dist/modules/dynamic-credentials.ee/services/credential-connection-status.service.d.ts +7 -0
- package/dist/modules/dynamic-credentials.ee/services/credential-connection-status.service.js +40 -0
- package/dist/modules/dynamic-credentials.ee/services/credential-connection-status.service.js.map +1 -0
- package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.d.ts +3 -1
- package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.js +6 -3
- package/dist/modules/dynamic-credentials.ee/services/credential-resolver-workflow.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/credential-resolver.service.d.ts +2 -0
- package/dist/modules/dynamic-credentials.ee/services/credential-resolver.service.js +22 -0
- package/dist/modules/dynamic-credentials.ee/services/credential-resolver.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.d.ts +3 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.js +7 -3
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-storage.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.d.ts +4 -1
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.js +11 -3
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential.service.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/index.d.ts +2 -0
- package/dist/modules/dynamic-credentials.ee/services/index.js +2 -0
- package/dist/modules/dynamic-credentials.ee/services/index.js.map +1 -1
- package/dist/modules/dynamic-credentials.ee/services/n8n-resolver-seeder.service.d.ts +14 -0
- package/dist/modules/dynamic-credentials.ee/services/n8n-resolver-seeder.service.js +70 -0
- package/dist/modules/dynamic-credentials.ee/services/n8n-resolver-seeder.service.js.map +1 -0
- package/dist/modules/insights/insights-collection.service.js +1 -1
- package/dist/modules/insights/insights-collection.service.js.map +1 -1
- package/dist/modules/instance-ai/entities/index.d.ts +6 -2
- package/dist/modules/instance-ai/entities/index.js +9 -5
- package/dist/modules/instance-ai/entities/index.js.map +1 -1
- package/dist/modules/instance-ai/entities/instance-ai-checkpoint.entity.d.ts +12 -0
- package/dist/modules/instance-ai/entities/instance-ai-checkpoint.entity.js +54 -0
- package/dist/modules/instance-ai/entities/instance-ai-checkpoint.entity.js.map +1 -0
- package/dist/modules/instance-ai/entities/instance-ai-observation-cursor.entity.d.ts +6 -0
- package/dist/modules/instance-ai/entities/instance-ai-observation-cursor.entity.js +33 -0
- package/dist/modules/instance-ai/entities/instance-ai-observation-cursor.entity.js.map +1 -0
- package/dist/modules/instance-ai/entities/instance-ai-observation-lock.entity.d.ts +8 -0
- package/dist/modules/instance-ai/entities/instance-ai-observation-lock.entity.js +37 -0
- package/dist/modules/instance-ai/entities/instance-ai-observation-lock.entity.js.map +1 -0
- package/dist/modules/instance-ai/entities/instance-ai-observation.entity.d.ts +12 -0
- package/dist/modules/instance-ai/entities/instance-ai-observation.entity.js +52 -0
- package/dist/modules/instance-ai/entities/instance-ai-observation.entity.js.map +1 -0
- package/dist/modules/instance-ai/entities/instance-ai-pending-confirmation.entity.d.ts +19 -0
- package/dist/modules/instance-ai/entities/instance-ai-pending-confirmation.entity.js +82 -0
- package/dist/modules/instance-ai/entities/instance-ai-pending-confirmation.entity.js.map +1 -0
- package/dist/modules/instance-ai/entities/instance-ai-run-snapshot.entity.d.ts +2 -0
- package/dist/modules/instance-ai/entities/instance-ai-run-snapshot.entity.js +8 -0
- package/dist/modules/instance-ai/entities/instance-ai-run-snapshot.entity.js.map +1 -1
- package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.d.ts +12 -2
- package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.js +40 -4
- package/dist/modules/instance-ai/eval/eval-mocked-credentials-helper.js.map +1 -1
- package/dist/modules/instance-ai/eval/execution.service.d.ts +8 -2
- package/dist/modules/instance-ai/eval/execution.service.js +137 -47
- package/dist/modules/instance-ai/eval/execution.service.js.map +1 -1
- package/dist/modules/instance-ai/eval/llm-wire-server.d.ts +31 -0
- package/dist/modules/instance-ai/eval/llm-wire-server.js +127 -0
- package/dist/modules/instance-ai/eval/llm-wire-server.js.map +1 -0
- package/dist/modules/instance-ai/eval/openai-envelope.d.ts +6 -0
- package/dist/modules/instance-ai/eval/openai-envelope.js +96 -0
- package/dist/modules/instance-ai/eval/openai-envelope.js.map +1 -0
- package/dist/modules/instance-ai/eval/proxy-loopback.d.ts +1 -0
- package/dist/modules/instance-ai/eval/proxy-loopback.js +44 -0
- package/dist/modules/instance-ai/eval/proxy-loopback.js.map +1 -0
- package/dist/modules/instance-ai/eval/sub-agent-eval.service.js +29 -7
- package/dist/modules/instance-ai/eval/sub-agent-eval.service.js.map +1 -1
- package/dist/modules/instance-ai/eval/workflow-analysis.d.ts +7 -1
- package/dist/modules/instance-ai/eval/workflow-analysis.js +178 -3
- package/dist/modules/instance-ai/eval/workflow-analysis.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai-memory.service.d.ts +6 -6
- package/dist/modules/instance-ai/instance-ai-memory.service.js +44 -85
- package/dist/modules/instance-ai/instance-ai-memory.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai-settings.service.d.ts +2 -1
- package/dist/modules/instance-ai/instance-ai-settings.service.js +11 -22
- package/dist/modules/instance-ai/instance-ai-settings.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.adapter.service.d.ts +2 -0
- package/dist/modules/instance-ai/instance-ai.adapter.service.js +105 -13
- package/dist/modules/instance-ai/instance-ai.adapter.service.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.module.d.ts +1 -1
- package/dist/modules/instance-ai/instance-ai.module.js +10 -6
- package/dist/modules/instance-ai/instance-ai.module.js.map +1 -1
- package/dist/modules/instance-ai/instance-ai.service.d.ts +34 -12
- package/dist/modules/instance-ai/instance-ai.service.js +724 -264
- package/dist/modules/instance-ai/instance-ai.service.js.map +1 -1
- package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.d.ts +4 -1
- package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.js +3 -1
- package/dist/modules/instance-ai/liveness/instance-ai-liveness.service.js.map +1 -1
- package/dist/modules/instance-ai/message-parser.d.ts +3 -3
- package/dist/modules/instance-ai/message-parser.js +65 -61
- package/dist/modules/instance-ai/message-parser.js.map +1 -1
- package/dist/modules/instance-ai/node-definition-resolver.js +12 -48
- package/dist/modules/instance-ai/node-definition-resolver.js.map +1 -1
- package/dist/modules/instance-ai/repositories/index.d.ts +4 -2
- package/dist/modules/instance-ai/repositories/index.js +9 -5
- package/dist/modules/instance-ai/repositories/index.js.map +1 -1
- package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.d.ts +5 -0
- package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.js +26 -0
- package/dist/modules/instance-ai/repositories/instance-ai-checkpoint.repository.js.map +1 -0
- package/dist/modules/instance-ai/repositories/instance-ai-observation-cursor.repository.d.ts +5 -0
- package/dist/modules/instance-ai/repositories/instance-ai-observation-cursor.repository.js +26 -0
- package/dist/modules/instance-ai/repositories/instance-ai-observation-cursor.repository.js.map +1 -0
- package/dist/modules/instance-ai/repositories/instance-ai-observation-lock.repository.d.ts +5 -0
- package/dist/modules/instance-ai/repositories/instance-ai-observation-lock.repository.js +26 -0
- package/dist/modules/instance-ai/repositories/instance-ai-observation-lock.repository.js.map +1 -0
- package/dist/modules/instance-ai/repositories/instance-ai-observation.repository.d.ts +5 -0
- package/dist/modules/{agents/repositories/agent-published-version.repository.js → instance-ai/repositories/instance-ai-observation.repository.js} +8 -17
- package/dist/modules/instance-ai/repositories/instance-ai-observation.repository.js.map +1 -0
- package/dist/modules/instance-ai/storage/db-snapshot-storage.d.ts +2 -0
- package/dist/modules/instance-ai/storage/db-snapshot-storage.js +12 -2
- package/dist/modules/instance-ai/storage/db-snapshot-storage.js.map +1 -1
- package/dist/modules/instance-ai/storage/index.d.ts +2 -3
- package/dist/modules/instance-ai/storage/index.js +5 -7
- package/dist/modules/instance-ai/storage/index.js.map +1 -1
- package/dist/modules/instance-ai/storage/typeorm-agent-checkpoint-store.d.ts +15 -0
- package/dist/modules/instance-ai/storage/typeorm-agent-checkpoint-store.js +94 -0
- package/dist/modules/instance-ai/storage/typeorm-agent-checkpoint-store.js.map +1 -0
- package/dist/modules/instance-ai/storage/typeorm-agent-memory.d.ts +94 -0
- package/dist/modules/instance-ai/storage/typeorm-agent-memory.js +324 -0
- package/dist/modules/instance-ai/storage/typeorm-agent-memory.js.map +1 -0
- package/dist/modules/instance-ai/storage/typeorm-observation-log-store.d.ts +37 -0
- package/dist/modules/instance-ai/storage/typeorm-observation-log-store.js +212 -0
- package/dist/modules/instance-ai/storage/typeorm-observation-log-store.js.map +1 -0
- package/dist/modules/instance-ai/web-research/fetch-and-extract.js +34 -11
- package/dist/modules/instance-ai/web-research/fetch-and-extract.js.map +1 -1
- package/dist/modules/mcp/mcp.service.js +5 -5
- package/dist/modules/mcp/mcp.service.js.map +1 -1
- package/dist/modules/mcp/tools/schemas.d.ts +24 -24
- package/dist/modules/mcp/tools/search-projects.tool.js +59 -13
- 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/workflow-builder/connection-structure-check.d.ts +35 -0
- package/dist/modules/mcp/tools/workflow-builder/connection-structure-check.js +88 -0
- package/dist/modules/mcp/tools/workflow-builder/connection-structure-check.js.map +1 -0
- package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.d.ts +3 -2
- package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js +41 -9
- package/dist/modules/mcp/tools/workflow-builder/create-workflow-from-code.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/data-table-validation.d.ts +13 -0
- package/dist/modules/mcp/tools/workflow-builder/data-table-validation.js +87 -0
- package/dist/modules/mcp/tools/workflow-builder/data-table-validation.js.map +1 -0
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.d.ts +2 -1
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js +42 -6
- package/dist/modules/mcp/tools/workflow-builder/update-workflow.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.d.ts +2 -1
- package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js +5 -1
- package/dist/modules/mcp/tools/workflow-builder/validate-workflow-code.tool.js.map +1 -1
- package/dist/modules/mcp/tools/workflow-validation.utils.js +1 -1
- package/dist/modules/mcp/tools/workflow-validation.utils.js.map +1 -1
- package/dist/modules/mcp-registry/mcp-registry-test.controller.js +5 -1
- package/dist/modules/mcp-registry/mcp-registry-test.controller.js.map +1 -1
- package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.d.ts +18 -0
- package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.js +73 -0
- package/dist/modules/n8n-packages/entities/workflow/workflow.exporter.js.map +1 -0
- package/dist/modules/n8n-packages/entities/workflow/workflow.serializer.d.ts +5 -0
- package/dist/modules/n8n-packages/entities/workflow/workflow.serializer.js +31 -0
- package/dist/modules/n8n-packages/entities/workflow/workflow.serializer.js.map +1 -0
- package/dist/modules/n8n-packages/io/package-writer.d.ts +6 -0
- package/dist/{scaling/multi-main-setup.types.js → modules/n8n-packages/io/package-writer.js} +1 -1
- package/dist/modules/n8n-packages/io/package-writer.js.map +1 -0
- package/dist/modules/n8n-packages/io/slug.utils.d.ts +1 -0
- package/dist/modules/n8n-packages/io/slug.utils.js +16 -0
- package/dist/modules/n8n-packages/io/slug.utils.js.map +1 -0
- package/dist/modules/n8n-packages/io/tar/tar-package-writer.d.ts +9 -0
- package/dist/modules/n8n-packages/io/tar/tar-package-writer.js +71 -0
- package/dist/modules/n8n-packages/io/tar/tar-package-writer.js.map +1 -0
- package/dist/modules/n8n-packages/n8n-packages.controller.d.ts +10 -0
- package/dist/modules/n8n-packages/n8n-packages.controller.js +45 -0
- package/dist/modules/n8n-packages/n8n-packages.controller.js.map +1 -0
- package/dist/modules/{inbound-secrets/inbound-secrets.module.d.ts → n8n-packages/n8n-packages.module.d.ts} +1 -1
- package/dist/modules/{inbound-secrets/inbound-secrets.module.js → n8n-packages/n8n-packages.module.js} +12 -16
- package/dist/modules/n8n-packages/n8n-packages.module.js.map +1 -0
- package/dist/modules/n8n-packages/n8n-packages.service.d.ts +10 -0
- package/dist/modules/n8n-packages/n8n-packages.service.js +49 -0
- package/dist/modules/n8n-packages/n8n-packages.service.js.map +1 -0
- package/dist/modules/n8n-packages/n8n-packages.types.d.ts +5 -0
- package/dist/modules/n8n-packages/n8n-packages.types.js +3 -0
- package/dist/modules/n8n-packages/n8n-packages.types.js.map +1 -0
- package/dist/modules/n8n-packages/spec/constants.d.ts +1 -0
- package/dist/modules/n8n-packages/spec/constants.js +5 -0
- package/dist/modules/n8n-packages/spec/constants.js.map +1 -0
- package/dist/modules/n8n-packages/spec/manifest.schema.d.ts +55 -0
- package/dist/modules/n8n-packages/spec/manifest.schema.js +17 -0
- package/dist/modules/n8n-packages/spec/manifest.schema.js.map +1 -0
- package/dist/modules/n8n-packages/spec/serialized/workflow.schema.d.ts +169 -0
- package/dist/modules/n8n-packages/spec/serialized/workflow.schema.js +46 -0
- package/dist/modules/n8n-packages/spec/serialized/workflow.schema.js.map +1 -0
- package/dist/modules/oauth-jwe/oauth-jwe-decrypt.service.d.ts +5 -1
- package/dist/modules/oauth-jwe/oauth-jwe-decrypt.service.js +18 -2
- package/dist/modules/oauth-jwe/oauth-jwe-decrypt.service.js.map +1 -1
- package/dist/modules/oauth-jwe/oauth-jwe.utils.js +27 -2
- package/dist/modules/oauth-jwe/oauth-jwe.utils.js.map +1 -1
- package/dist/modules/otel/execution-level-tracer.js +1 -0
- package/dist/modules/otel/execution-level-tracer.js.map +1 -1
- package/dist/modules/otel/execution-level-tracer.types.d.ts +11 -6
- package/dist/modules/otel/execution-level-tracer.types.js.map +1 -1
- package/dist/modules/otel/otel-lifecycle-handler.d.ts +5 -1
- package/dist/modules/otel/otel-lifecycle-handler.js +30 -2
- package/dist/modules/otel/otel-lifecycle-handler.js.map +1 -1
- package/dist/modules/otel/otel.constants.d.ts +1 -0
- package/dist/modules/otel/otel.constants.js +1 -0
- package/dist/modules/otel/otel.constants.js.map +1 -1
- package/dist/modules/runtime-credentials/path-traversal.js.map +1 -0
- package/dist/modules/runtime-credentials/runtime-credentials-access.service.d.ts +8 -0
- package/dist/modules/runtime-credentials/runtime-credentials-access.service.js +35 -0
- package/dist/modules/runtime-credentials/runtime-credentials-access.service.js.map +1 -0
- package/dist/modules/{inbound-secrets/inbound-secrets-context-hook.d.ts → runtime-credentials/runtime-credentials-context-hook.d.ts} +4 -5
- package/dist/modules/{inbound-secrets/inbound-secrets-context-hook.js → runtime-credentials/runtime-credentials-context-hook.js} +14 -22
- package/dist/modules/runtime-credentials/runtime-credentials-context-hook.js.map +1 -0
- package/dist/modules/runtime-credentials/runtime-credentials.config.d.ts +3 -0
- package/dist/modules/{inbound-secrets/inbound-secrets.config.js → runtime-credentials/runtime-credentials.config.js} +7 -7
- package/dist/modules/runtime-credentials/runtime-credentials.config.js.map +1 -0
- package/dist/modules/runtime-credentials/runtime-credentials.module.d.ts +4 -0
- package/dist/modules/runtime-credentials/runtime-credentials.module.js +65 -0
- package/dist/modules/runtime-credentials/runtime-credentials.module.js.map +1 -0
- package/dist/modules/runtime-credentials/runtime-credentials.schemas.d.ts +23 -0
- package/dist/modules/runtime-credentials/runtime-credentials.schemas.js +10 -0
- package/dist/modules/runtime-credentials/runtime-credentials.schemas.js.map +1 -0
- package/dist/modules/runtime-credentials/runtime-credentials.service.d.ts +18 -0
- package/dist/modules/{inbound-secrets/inbound-secrets.service.js → runtime-credentials/runtime-credentials.service.js} +31 -28
- package/dist/modules/runtime-credentials/runtime-credentials.service.js.map +1 -0
- 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 +3 -1
- package/dist/modules/source-control.ee/source-control-export.service.ee.js.map +1 -1
- package/dist/modules/source-control.ee/source-control-import.service.ee.d.ts +2 -2
- package/dist/modules/source-control.ee/source-control-import.service.ee.js +29 -8
- package/dist/modules/source-control.ee/source-control-import.service.ee.js.map +1 -1
- package/dist/modules/source-control.ee/source-control-status.service.ee.js +4 -4
- 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 +2 -2
- package/dist/modules/source-control.ee/source-control.service.ee.d.ts +1 -1
- package/dist/modules/source-control.ee/types/exportable-workflow.d.ts +2 -1
- package/dist/modules/sso-saml/saml.service.ee.js +5 -1
- package/dist/modules/sso-saml/saml.service.ee.js.map +1 -1
- package/dist/modules/workflow-index/workflow-dependency.controller.d.ts +1 -4
- package/dist/modules/workflow-index/workflow-dependency.controller.js +2 -13
- package/dist/modules/workflow-index/workflow-dependency.controller.js.map +1 -1
- package/dist/node-catalog/node-catalog.service.d.ts +1 -2
- package/dist/node-catalog/node-catalog.service.js +6 -10
- package/dist/node-catalog/node-catalog.service.js.map +1 -1
- package/dist/node-execution/ephemeral-node-executor.js +19 -11
- package/dist/node-execution/ephemeral-node-executor.js.map +1 -1
- package/dist/oauth/oauth-jwe-service.proxy.d.ts +12 -2
- package/dist/oauth/oauth-jwe-service.proxy.js +5 -0
- package/dist/oauth/oauth-jwe-service.proxy.js.map +1 -1
- package/dist/oauth/oauth.service.d.ts +6 -1
- package/dist/oauth/oauth.service.js +42 -4
- package/dist/oauth/oauth.service.js.map +1 -1
- package/dist/permissions.ee/check-access.d.ts +2 -2
- package/dist/permissions.ee/check-access.js +15 -11
- package/dist/permissions.ee/check-access.js.map +1 -1
- package/dist/posthog/index.d.ts +2 -0
- package/dist/posthog/index.js +28 -6
- package/dist/posthog/index.js.map +1 -1
- package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.d.ts +10 -0
- package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.js +42 -0
- package/dist/public-api/v1/handlers/n8n-packages/n8n-packages.handler.js.map +1 -0
- package/dist/public-api/v1/openapi.yml +55 -0
- package/dist/requests.d.ts +1 -1
- package/dist/scaling/constants.js +3 -0
- package/dist/scaling/constants.js.map +1 -1
- package/dist/scaling/multi-main-setup.ee.d.ts +12 -7
- package/dist/scaling/multi-main-setup.ee.js +125 -22
- package/dist/scaling/multi-main-setup.ee.js.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.js +3 -4
- package/dist/server.js.map +1 -1
- package/dist/services/dynamic-node-parameters.service.d.ts +0 -1
- package/dist/services/dynamic-node-parameters.service.js +6 -14
- package/dist/services/dynamic-node-parameters.service.js.map +1 -1
- package/dist/services/frontend.service.js +1 -1
- package/dist/services/frontend.service.js.map +1 -1
- package/dist/services/import.service.js +3 -1
- package/dist/services/import.service.js.map +1 -1
- package/dist/services/proxy-token-manager.js +2 -13
- package/dist/services/proxy-token-manager.js.map +1 -1
- package/dist/services/runtime-credential-proxy.service.d.ts +9 -0
- package/dist/services/runtime-credential-proxy.service.js +29 -0
- package/dist/services/runtime-credential-proxy.service.js.map +1 -0
- package/dist/services/url.service.d.ts +1 -0
- package/dist/services/url.service.js +3 -0
- package/dist/services/url.service.js.map +1 -1
- package/dist/telemetry/index.d.ts +4 -1
- package/dist/telemetry/index.js +16 -8
- package/dist/telemetry/index.js.map +1 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +10 -0
- package/dist/utils.js.map +1 -1
- package/dist/webhooks/live-webhooks.js +2 -2
- package/dist/webhooks/live-webhooks.js.map +1 -1
- package/dist/webhooks/webhook-helpers.js +1 -1
- package/dist/webhooks/webhook-helpers.js.map +1 -1
- package/dist/workflow-execute-additional-data.d.ts +3 -1
- package/dist/workflow-execute-additional-data.js +26 -3
- package/dist/workflow-execute-additional-data.js.map +1 -1
- package/dist/workflow-helpers.d.ts +3 -1
- package/dist/workflow-helpers.js +39 -5
- package/dist/workflow-helpers.js.map +1 -1
- package/dist/workflow-hook-context.service.d.ts +6 -0
- package/dist/workflow-hook-context.service.js +32 -0
- package/dist/workflow-hook-context.service.js.map +1 -0
- package/dist/workflow-runner.js +2 -1
- package/dist/workflow-runner.js.map +1 -1
- package/dist/workflows/utils.d.ts +3 -0
- package/dist/workflows/utils.js +19 -0
- package/dist/workflows/utils.js.map +1 -1
- package/dist/workflows/workflow-creation.service.js +4 -2
- package/dist/workflows/workflow-creation.service.js.map +1 -1
- package/dist/workflows/workflow-execution.service.d.ts +4 -3
- package/dist/workflows/workflow-execution.service.js +8 -3
- package/dist/workflows/workflow-execution.service.js.map +1 -1
- package/dist/workflows/workflow-finder.service.d.ts +6 -2
- package/dist/workflows/workflow-finder.service.js +18 -0
- package/dist/workflows/workflow-finder.service.js.map +1 -1
- package/dist/workflows/workflow-history/workflow-history.controller.d.ts +1 -1
- package/dist/workflows/workflow-history/workflow-history.service.d.ts +2 -1
- package/dist/workflows/workflow-history/workflow-history.service.js +1 -0
- package/dist/workflows/workflow-history/workflow-history.service.js.map +1 -1
- package/dist/workflows/workflow-validation.service.d.ts +3 -1
- package/dist/workflows/workflow-validation.service.js +6 -3
- package/dist/workflows/workflow-validation.service.js.map +1 -1
- package/dist/workflows/workflow.service.d.ts +3 -3
- package/dist/workflows/workflow.service.js +26 -4
- package/dist/workflows/workflow.service.js.map +1 -1
- package/dist/workflows/workflows.controller.d.ts +31 -21
- package/dist/workflows/workflows.controller.js +6 -2
- package/dist/workflows/workflows.controller.js.map +1 -1
- package/package.json +36 -34
- package/dist/modules/agents/entities/agent-published-version.entity.js.map +0 -1
- package/dist/modules/agents/repositories/agent-published-version.repository.d.ts +0 -20
- package/dist/modules/agents/repositories/agent-published-version.repository.js.map +0 -1
- package/dist/modules/inbound-secrets/inbound-secrets-context-hook.js.map +0 -1
- package/dist/modules/inbound-secrets/inbound-secrets.config.d.ts +0 -3
- package/dist/modules/inbound-secrets/inbound-secrets.config.js.map +0 -1
- package/dist/modules/inbound-secrets/inbound-secrets.module.js.map +0 -1
- package/dist/modules/inbound-secrets/inbound-secrets.schemas.d.ts +0 -3
- package/dist/modules/inbound-secrets/inbound-secrets.schemas.js +0 -6
- package/dist/modules/inbound-secrets/inbound-secrets.schemas.js.map +0 -1
- package/dist/modules/inbound-secrets/inbound-secrets.service.d.ts +0 -17
- package/dist/modules/inbound-secrets/inbound-secrets.service.js.map +0 -1
- package/dist/modules/inbound-secrets/path-traversal.js.map +0 -1
- package/dist/modules/instance-ai/compaction.service.d.ts +0 -24
- package/dist/modules/instance-ai/compaction.service.js +0 -213
- package/dist/modules/instance-ai/compaction.service.js.map +0 -1
- package/dist/modules/instance-ai/entities/instance-ai-observational-memory.entity.d.ts +0 -33
- package/dist/modules/instance-ai/entities/instance-ai-observational-memory.entity.js +0 -145
- package/dist/modules/instance-ai/entities/instance-ai-observational-memory.entity.js.map +0 -1
- package/dist/modules/instance-ai/entities/instance-ai-workflow-snapshot.entity.d.ts +0 -8
- package/dist/modules/instance-ai/entities/instance-ai-workflow-snapshot.entity.js.map +0 -1
- package/dist/modules/instance-ai/repositories/instance-ai-observational-memory.repository.d.ts +0 -5
- package/dist/modules/instance-ai/repositories/instance-ai-observational-memory.repository.js.map +0 -1
- package/dist/modules/instance-ai/repositories/instance-ai-workflow-snapshot.repository.d.ts +0 -5
- package/dist/modules/instance-ai/repositories/instance-ai-workflow-snapshot.repository.js.map +0 -1
- package/dist/modules/instance-ai/snapshot-pruning.service.d.ts +0 -17
- package/dist/modules/instance-ai/snapshot-pruning.service.js +0 -89
- package/dist/modules/instance-ai/snapshot-pruning.service.js.map +0 -1
- package/dist/modules/instance-ai/storage/typeorm-composite-store.d.ts +0 -9
- package/dist/modules/instance-ai/storage/typeorm-composite-store.js +0 -33
- package/dist/modules/instance-ai/storage/typeorm-composite-store.js.map +0 -1
- package/dist/modules/instance-ai/storage/typeorm-memory-storage.d.ts +0 -96
- package/dist/modules/instance-ai/storage/typeorm-memory-storage.js +0 -864
- package/dist/modules/instance-ai/storage/typeorm-memory-storage.js.map +0 -1
- package/dist/modules/instance-ai/storage/typeorm-workflows-storage.d.ts +0 -44
- package/dist/modules/instance-ai/storage/typeorm-workflows-storage.js +0 -156
- package/dist/modules/instance-ai/storage/typeorm-workflows-storage.js.map +0 -1
- package/dist/scaling/multi-main-setup-legacy.d.ts +0 -25
- package/dist/scaling/multi-main-setup-legacy.js +0 -75
- package/dist/scaling/multi-main-setup-legacy.js.map +0 -1
- package/dist/scaling/multi-main-setup-v2.d.ts +0 -25
- package/dist/scaling/multi-main-setup-v2.js +0 -143
- package/dist/scaling/multi-main-setup-v2.js.map +0 -1
- package/dist/scaling/multi-main-setup.types.d.ts +0 -6
- package/dist/scaling/multi-main-setup.types.js.map +0 -1
- /package/dist/modules/{inbound-secrets → runtime-credentials}/path-traversal.d.ts +0 -0
- /package/dist/modules/{inbound-secrets → runtime-credentials}/path-traversal.js +0 -0
|
@@ -1,864 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var TypeORMMemoryStorage_1;
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.TypeORMMemoryStorage = void 0;
|
|
14
|
-
const node_crypto_1 = require("node:crypto");
|
|
15
|
-
const storage_1 = require("@mastra/core/storage");
|
|
16
|
-
const di_1 = require("@n8n/di");
|
|
17
|
-
const instance_ai_1 = require("@n8n/instance-ai");
|
|
18
|
-
const typeorm_1 = require("@n8n/typeorm");
|
|
19
|
-
const utils_1 = require("@n8n/utils");
|
|
20
|
-
const n8n_workflow_1 = require("n8n-workflow");
|
|
21
|
-
const instance_ai_message_repository_1 = require("../repositories/instance-ai-message.repository");
|
|
22
|
-
const instance_ai_observational_memory_repository_1 = require("../repositories/instance-ai-observational-memory.repository");
|
|
23
|
-
const instance_ai_resource_repository_1 = require("../repositories/instance-ai-resource.repository");
|
|
24
|
-
const instance_ai_thread_repository_1 = require("../repositories/instance-ai-thread.repository");
|
|
25
|
-
const PATCH_ONLY_METADATA_KEYS = [
|
|
26
|
-
'instanceAiPlannedTasks',
|
|
27
|
-
'instanceAiTasks',
|
|
28
|
-
'instanceAiTerminalOutcomes',
|
|
29
|
-
'instanceAiWorkflowLoop',
|
|
30
|
-
];
|
|
31
|
-
function countLines(value) {
|
|
32
|
-
return value === '' ? 0 : value.split(/\r?\n/u).length;
|
|
33
|
-
}
|
|
34
|
-
function buildResourceTraceMetadata(resourceId) {
|
|
35
|
-
const separatorIndex = resourceId.indexOf(':');
|
|
36
|
-
return {
|
|
37
|
-
resource_id: resourceId,
|
|
38
|
-
memory_scope: separatorIndex === -1 ? 'user' : 'user-role',
|
|
39
|
-
...(separatorIndex !== -1 && separatorIndex < resourceId.length - 1
|
|
40
|
-
? { memory_role: resourceId.slice(separatorIndex + 1) }
|
|
41
|
-
: {}),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function summarizeLoadedResource(resource) {
|
|
45
|
-
const workingMemory = resource?.workingMemory;
|
|
46
|
-
return {
|
|
47
|
-
found: resource !== null,
|
|
48
|
-
has_working_memory: typeof workingMemory === 'string' && workingMemory.length > 0,
|
|
49
|
-
working_memory_chars: typeof workingMemory === 'string' ? workingMemory.length : 0,
|
|
50
|
-
working_memory_lines: typeof workingMemory === 'string' ? countLines(workingMemory) : 0,
|
|
51
|
-
metadata_keys: resource?.metadata ? Object.keys(resource.metadata).length : 0,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
let TypeORMMemoryStorage = TypeORMMemoryStorage_1 = class TypeORMMemoryStorage extends storage_1.MemoryStorage {
|
|
55
|
-
constructor(threadRepo, messageRepo, resourceRepo, omRepo) {
|
|
56
|
-
super();
|
|
57
|
-
this.threadRepo = threadRepo;
|
|
58
|
-
this.messageRepo = messageRepo;
|
|
59
|
-
this.resourceRepo = resourceRepo;
|
|
60
|
-
this.omRepo = omRepo;
|
|
61
|
-
this.supportsObservationalMemory = true;
|
|
62
|
-
}
|
|
63
|
-
async dangerouslyClearAll() {
|
|
64
|
-
await this.omRepo.clear();
|
|
65
|
-
await this.messageRepo.clear();
|
|
66
|
-
await this.threadRepo.clear();
|
|
67
|
-
await this.resourceRepo.clear();
|
|
68
|
-
}
|
|
69
|
-
async getThreadById({ threadId }) {
|
|
70
|
-
const entity = await this.threadRepo.findOneBy({ id: threadId });
|
|
71
|
-
if (!entity)
|
|
72
|
-
return null;
|
|
73
|
-
return this.toStorageThread(entity);
|
|
74
|
-
}
|
|
75
|
-
async listThreads(args) {
|
|
76
|
-
const page = args.page ?? 0;
|
|
77
|
-
const perPageInput = args.perPage;
|
|
78
|
-
const perPage = perPageInput === false ? Number.MAX_SAFE_INTEGER : (perPageInput ?? 100);
|
|
79
|
-
const { field, direction } = this.parseOrderBy(args.orderBy);
|
|
80
|
-
const where = {};
|
|
81
|
-
if (args.filter?.resourceId)
|
|
82
|
-
where.resourceId = args.filter.resourceId;
|
|
83
|
-
const metadataFilter = args.filter?.metadata;
|
|
84
|
-
const hasMetadataFilter = metadataFilter && Object.keys(metadataFilter).length > 0;
|
|
85
|
-
if (hasMetadataFilter) {
|
|
86
|
-
this.validateMetadataKeys(metadataFilter);
|
|
87
|
-
const allEntities = await this.threadRepo.find({
|
|
88
|
-
where,
|
|
89
|
-
order: { [field]: direction },
|
|
90
|
-
});
|
|
91
|
-
const allThreads = allEntities
|
|
92
|
-
.map((e) => ({
|
|
93
|
-
id: e.id,
|
|
94
|
-
title: e.title,
|
|
95
|
-
resourceId: e.resourceId,
|
|
96
|
-
metadata: e.metadata ?? undefined,
|
|
97
|
-
createdAt: e.createdAt,
|
|
98
|
-
updatedAt: e.updatedAt,
|
|
99
|
-
}))
|
|
100
|
-
.filter((t) => {
|
|
101
|
-
if (!t.metadata)
|
|
102
|
-
return false;
|
|
103
|
-
return Object.entries(args.filter.metadata).every(([k, v]) => t.metadata[k] === v);
|
|
104
|
-
});
|
|
105
|
-
const total = allThreads.length;
|
|
106
|
-
const offset = page * perPage;
|
|
107
|
-
const paged = allThreads.slice(offset, offset + perPage);
|
|
108
|
-
return {
|
|
109
|
-
threads: paged,
|
|
110
|
-
total,
|
|
111
|
-
page,
|
|
112
|
-
perPage: perPageInput ?? 100,
|
|
113
|
-
hasMore: offset + perPage < total,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
const [entities, total] = await this.threadRepo.findAndCount({
|
|
117
|
-
where,
|
|
118
|
-
order: { [field]: direction },
|
|
119
|
-
skip: page * perPage,
|
|
120
|
-
take: perPage,
|
|
121
|
-
});
|
|
122
|
-
const threads = entities.map((e) => ({
|
|
123
|
-
id: e.id,
|
|
124
|
-
title: e.title,
|
|
125
|
-
resourceId: e.resourceId,
|
|
126
|
-
metadata: e.metadata ?? undefined,
|
|
127
|
-
createdAt: e.createdAt,
|
|
128
|
-
updatedAt: e.updatedAt,
|
|
129
|
-
}));
|
|
130
|
-
return {
|
|
131
|
-
threads,
|
|
132
|
-
total,
|
|
133
|
-
page,
|
|
134
|
-
perPage: perPageInput ?? 100,
|
|
135
|
-
hasMore: (page + 1) * perPage < total,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
async saveThread({ thread, }) {
|
|
139
|
-
return await this.serializeThreadMutation(thread.id, async () => {
|
|
140
|
-
const existing = await this.threadRepo.findOneBy({ id: thread.id });
|
|
141
|
-
if (existing) {
|
|
142
|
-
const safeIncoming = { ...(thread.metadata ?? {}) };
|
|
143
|
-
for (const key of PATCH_ONLY_METADATA_KEYS) {
|
|
144
|
-
delete safeIncoming[key];
|
|
145
|
-
}
|
|
146
|
-
existing.title = thread.title ?? existing.title;
|
|
147
|
-
existing.resourceId = thread.resourceId ?? existing.resourceId;
|
|
148
|
-
existing.metadata = {
|
|
149
|
-
...(existing.metadata ?? {}),
|
|
150
|
-
...safeIncoming,
|
|
151
|
-
};
|
|
152
|
-
const saved = await this.threadRepo.save(existing);
|
|
153
|
-
return this.toStorageThread(saved);
|
|
154
|
-
}
|
|
155
|
-
const entity = this.threadRepo.create({
|
|
156
|
-
id: thread.id,
|
|
157
|
-
resourceId: thread.resourceId,
|
|
158
|
-
title: thread.title ?? '',
|
|
159
|
-
metadata: thread.metadata ?? null,
|
|
160
|
-
});
|
|
161
|
-
const saved = await this.threadRepo.save(entity);
|
|
162
|
-
return this.toStorageThread(saved);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
async updateThread({ id, title, metadata, }) {
|
|
166
|
-
return await this.serializeThreadMutation(id, async () => {
|
|
167
|
-
const entity = await this.threadRepo.findOneByOrFail({ id });
|
|
168
|
-
const safeIncoming = { ...metadata };
|
|
169
|
-
for (const key of PATCH_ONLY_METADATA_KEYS) {
|
|
170
|
-
delete safeIncoming[key];
|
|
171
|
-
}
|
|
172
|
-
entity.title = title;
|
|
173
|
-
entity.metadata = {
|
|
174
|
-
...(entity.metadata ?? {}),
|
|
175
|
-
...safeIncoming,
|
|
176
|
-
};
|
|
177
|
-
const updated = await this.threadRepo.save(entity);
|
|
178
|
-
return this.toStorageThread(updated);
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
async patchThread({ threadId, update, }) {
|
|
182
|
-
return await this.serializeThreadMutation(threadId, async () => {
|
|
183
|
-
const entity = await this.threadRepo.findOneBy({ id: threadId });
|
|
184
|
-
if (!entity)
|
|
185
|
-
return null;
|
|
186
|
-
const current = this.toStorageThread(entity);
|
|
187
|
-
const patch = update({
|
|
188
|
-
...current,
|
|
189
|
-
metadata: { ...(current.metadata ?? {}) },
|
|
190
|
-
});
|
|
191
|
-
if (!patch)
|
|
192
|
-
return current;
|
|
193
|
-
if (patch.title !== undefined) {
|
|
194
|
-
entity.title = patch.title;
|
|
195
|
-
}
|
|
196
|
-
if (patch.metadata !== undefined) {
|
|
197
|
-
entity.metadata = patch.metadata;
|
|
198
|
-
}
|
|
199
|
-
const updated = await this.threadRepo.save(entity);
|
|
200
|
-
return this.toStorageThread(updated);
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
async deleteThread({ threadId }) {
|
|
204
|
-
await this.threadRepo.delete(threadId);
|
|
205
|
-
}
|
|
206
|
-
toStorageThread(entity) {
|
|
207
|
-
return {
|
|
208
|
-
id: entity.id,
|
|
209
|
-
title: entity.title,
|
|
210
|
-
resourceId: entity.resourceId,
|
|
211
|
-
metadata: entity.metadata ?? undefined,
|
|
212
|
-
createdAt: entity.createdAt,
|
|
213
|
-
updatedAt: entity.updatedAt,
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
async serializeThreadMutation(threadId, mutation) {
|
|
217
|
-
const queues = TypeORMMemoryStorage_1.threadMutationQueues;
|
|
218
|
-
const previous = queues.get(threadId) ?? Promise.resolve();
|
|
219
|
-
const previousSettled = previous.catch(() => { });
|
|
220
|
-
let releaseCurrent;
|
|
221
|
-
const current = new Promise((resolve) => {
|
|
222
|
-
releaseCurrent = resolve;
|
|
223
|
-
});
|
|
224
|
-
const queued = previousSettled.then(async () => await current);
|
|
225
|
-
queues.set(threadId, queued);
|
|
226
|
-
await previousSettled;
|
|
227
|
-
try {
|
|
228
|
-
return await mutation();
|
|
229
|
-
}
|
|
230
|
-
finally {
|
|
231
|
-
releaseCurrent();
|
|
232
|
-
if (queues.get(threadId) === queued) {
|
|
233
|
-
queues.delete(threadId);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
async listMessages(args) {
|
|
238
|
-
if (args.include?.length) {
|
|
239
|
-
const included = await this.getIncludedMessages(args);
|
|
240
|
-
return {
|
|
241
|
-
messages: included,
|
|
242
|
-
total: included.length,
|
|
243
|
-
page: 0,
|
|
244
|
-
perPage: false,
|
|
245
|
-
hasMore: false,
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
const threadIds = Array.isArray(args.threadId) ? args.threadId : [args.threadId];
|
|
249
|
-
const page = args.page ?? 0;
|
|
250
|
-
const perPageInput = args.perPage;
|
|
251
|
-
const perPage = perPageInput === false ? Number.MAX_SAFE_INTEGER : (perPageInput ?? 40);
|
|
252
|
-
const qb = this.messageRepo
|
|
253
|
-
.createQueryBuilder('m')
|
|
254
|
-
.where('m.threadId IN (:...threadIds)', { threadIds });
|
|
255
|
-
if (args.resourceId) {
|
|
256
|
-
qb.andWhere('m.resourceId = :resourceId', {
|
|
257
|
-
resourceId: args.resourceId,
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
if (args.filter?.dateRange?.start) {
|
|
261
|
-
const op = args.filter.dateRange.startExclusive ? '>' : '>=';
|
|
262
|
-
qb.andWhere(`m.createdAt ${op} :start`, {
|
|
263
|
-
start: args.filter.dateRange.start,
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
if (args.filter?.dateRange?.end) {
|
|
267
|
-
const op = args.filter.dateRange.endExclusive ? '<' : '<=';
|
|
268
|
-
qb.andWhere(`m.createdAt ${op} :end`, {
|
|
269
|
-
end: args.filter.dateRange.end,
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
const { field = 'createdAt', direction = 'ASC' } = args.orderBy ?? {};
|
|
273
|
-
qb.orderBy(`m.${field}`, direction);
|
|
274
|
-
const total = await qb.getCount();
|
|
275
|
-
qb.skip(page * perPage).take(perPage);
|
|
276
|
-
const entities = await qb.getMany();
|
|
277
|
-
const messages = entities.map((e) => this.entityToMessage(e));
|
|
278
|
-
return {
|
|
279
|
-
messages,
|
|
280
|
-
total,
|
|
281
|
-
page,
|
|
282
|
-
perPage: perPageInput ?? 40,
|
|
283
|
-
hasMore: (page + 1) * perPage < total,
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
async getIncludedMessages(args) {
|
|
287
|
-
const seen = new Set();
|
|
288
|
-
const result = [];
|
|
289
|
-
const threadIds = Array.isArray(args.threadId) ? args.threadId : [args.threadId];
|
|
290
|
-
for (const inc of args.include ?? []) {
|
|
291
|
-
const anchorThreadIds = inc.threadId ? [inc.threadId] : threadIds;
|
|
292
|
-
const anchor = await this.messageRepo.findOneBy({ id: inc.id });
|
|
293
|
-
if (!anchor)
|
|
294
|
-
continue;
|
|
295
|
-
const collected = [];
|
|
296
|
-
if (inc.withPreviousMessages && inc.withPreviousMessages > 0) {
|
|
297
|
-
const before = await this.messageRepo
|
|
298
|
-
.createQueryBuilder('m')
|
|
299
|
-
.where('m.threadId IN (:...threadIds)', { threadIds: anchorThreadIds })
|
|
300
|
-
.andWhere('m.createdAt < :anchorTime', { anchorTime: anchor.createdAt })
|
|
301
|
-
.orderBy('m.createdAt', 'DESC')
|
|
302
|
-
.take(inc.withPreviousMessages)
|
|
303
|
-
.getMany();
|
|
304
|
-
collected.push(...before.reverse().map((e) => this.entityToMessage(e)));
|
|
305
|
-
}
|
|
306
|
-
collected.push(this.entityToMessage(anchor));
|
|
307
|
-
if (inc.withNextMessages && inc.withNextMessages > 0) {
|
|
308
|
-
const after = await this.messageRepo
|
|
309
|
-
.createQueryBuilder('m')
|
|
310
|
-
.where('m.threadId IN (:...threadIds)', { threadIds: anchorThreadIds })
|
|
311
|
-
.andWhere('m.createdAt > :anchorTime', { anchorTime: anchor.createdAt })
|
|
312
|
-
.orderBy('m.createdAt', 'ASC')
|
|
313
|
-
.take(inc.withNextMessages)
|
|
314
|
-
.getMany();
|
|
315
|
-
collected.push(...after.map((e) => this.entityToMessage(e)));
|
|
316
|
-
}
|
|
317
|
-
for (const msg of collected) {
|
|
318
|
-
if (!seen.has(msg.id)) {
|
|
319
|
-
seen.add(msg.id);
|
|
320
|
-
result.push(msg);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
result.sort((a, b) => a.createdAt.getTime() - b.createdAt.getTime());
|
|
325
|
-
return result;
|
|
326
|
-
}
|
|
327
|
-
async listMessagesByResourceId(args) {
|
|
328
|
-
const page = args.page ?? 0;
|
|
329
|
-
const perPageInput = args.perPage;
|
|
330
|
-
const perPage = perPageInput === false ? Number.MAX_SAFE_INTEGER : (perPageInput ?? 40);
|
|
331
|
-
const qb = this.messageRepo
|
|
332
|
-
.createQueryBuilder('m')
|
|
333
|
-
.where('m.resourceId = :resourceId', { resourceId: args.resourceId });
|
|
334
|
-
if (args.filter?.dateRange?.start) {
|
|
335
|
-
const op = args.filter.dateRange.startExclusive ? '>' : '>=';
|
|
336
|
-
qb.andWhere(`m.createdAt ${op} :start`, {
|
|
337
|
-
start: args.filter.dateRange.start,
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
if (args.filter?.dateRange?.end) {
|
|
341
|
-
const op = args.filter.dateRange.endExclusive ? '<' : '<=';
|
|
342
|
-
qb.andWhere(`m.createdAt ${op} :end`, {
|
|
343
|
-
end: args.filter.dateRange.end,
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
const { field = 'createdAt', direction = 'ASC' } = args.orderBy ?? {};
|
|
347
|
-
qb.orderBy(`m.${field}`, direction);
|
|
348
|
-
const total = await qb.getCount();
|
|
349
|
-
qb.skip(page * perPage).take(perPage);
|
|
350
|
-
const entities = await qb.getMany();
|
|
351
|
-
return {
|
|
352
|
-
messages: entities.map((e) => this.entityToMessage(e)),
|
|
353
|
-
total,
|
|
354
|
-
page,
|
|
355
|
-
perPage: perPageInput ?? 40,
|
|
356
|
-
hasMore: (page + 1) * perPage < total,
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
async listMessagesById({ messageIds, }) {
|
|
360
|
-
if (messageIds.length === 0)
|
|
361
|
-
return { messages: [] };
|
|
362
|
-
const entities = await this.messageRepo.findBy({ id: (0, typeorm_1.In)(messageIds) });
|
|
363
|
-
return { messages: entities.map((e) => this.entityToMessage(e)) };
|
|
364
|
-
}
|
|
365
|
-
async saveMessages({ messages, }) {
|
|
366
|
-
const entities = messages.map((m) => {
|
|
367
|
-
if (!m.threadId) {
|
|
368
|
-
throw new Error(`Message ${m.id} is missing required threadId`);
|
|
369
|
-
}
|
|
370
|
-
const entity = this.messageRepo.create({
|
|
371
|
-
id: m.id,
|
|
372
|
-
threadId: m.threadId,
|
|
373
|
-
content: JSON.stringify(m.content),
|
|
374
|
-
role: m.role,
|
|
375
|
-
type: m.type ?? null,
|
|
376
|
-
resourceId: m.resourceId ?? null,
|
|
377
|
-
});
|
|
378
|
-
if (m.createdAt) {
|
|
379
|
-
entity.createdAt = m.createdAt;
|
|
380
|
-
}
|
|
381
|
-
return entity;
|
|
382
|
-
});
|
|
383
|
-
const saved = await this.messageRepo.save(entities);
|
|
384
|
-
const threadIds = [
|
|
385
|
-
...new Set(messages.map((m) => m.threadId).filter((id) => !!id)),
|
|
386
|
-
];
|
|
387
|
-
if (threadIds.length > 0) {
|
|
388
|
-
await this.threadRepo.update(threadIds, { updatedAt: new Date() });
|
|
389
|
-
}
|
|
390
|
-
return { messages: saved.map((e) => this.entityToMessage(e)) };
|
|
391
|
-
}
|
|
392
|
-
async updateMessages({ messages, }) {
|
|
393
|
-
const result = [];
|
|
394
|
-
for (const msg of messages) {
|
|
395
|
-
const existing = await this.messageRepo.findOneBy({ id: msg.id });
|
|
396
|
-
if (!existing)
|
|
397
|
-
continue;
|
|
398
|
-
const updates = {};
|
|
399
|
-
if (msg.role)
|
|
400
|
-
updates.role = msg.role;
|
|
401
|
-
if (msg.type !== undefined)
|
|
402
|
-
updates.type = msg.type;
|
|
403
|
-
if (msg.content) {
|
|
404
|
-
const existingContent = (0, n8n_workflow_1.jsonParse)(existing.content);
|
|
405
|
-
if (msg.content.metadata !== undefined)
|
|
406
|
-
existingContent.metadata = msg.content.metadata;
|
|
407
|
-
if (msg.content.content !== undefined)
|
|
408
|
-
existingContent.content = msg.content.content;
|
|
409
|
-
updates.content = JSON.stringify(existingContent);
|
|
410
|
-
}
|
|
411
|
-
if (Object.keys(updates).length > 0) {
|
|
412
|
-
await this.messageRepo.update(msg.id, updates);
|
|
413
|
-
}
|
|
414
|
-
const updated = await this.messageRepo.findOneByOrFail({ id: msg.id });
|
|
415
|
-
result.push(this.entityToMessage(updated));
|
|
416
|
-
}
|
|
417
|
-
return result;
|
|
418
|
-
}
|
|
419
|
-
async deleteMessages(messageIds) {
|
|
420
|
-
if (messageIds.length === 0)
|
|
421
|
-
return;
|
|
422
|
-
await this.messageRepo.delete(messageIds);
|
|
423
|
-
}
|
|
424
|
-
async getResourceById({ resourceId, }) {
|
|
425
|
-
return await (0, instance_ai_1.withCurrentTraceSpan)({
|
|
426
|
-
name: 'memory_load',
|
|
427
|
-
tags: ['memory', 'internal'],
|
|
428
|
-
metadata: buildResourceTraceMetadata(resourceId),
|
|
429
|
-
inputs: { resource_id: resourceId },
|
|
430
|
-
processOutputs: summarizeLoadedResource,
|
|
431
|
-
}, async () => {
|
|
432
|
-
const entity = await this.resourceRepo.findOneBy({ id: resourceId });
|
|
433
|
-
if (!entity)
|
|
434
|
-
return null;
|
|
435
|
-
return {
|
|
436
|
-
id: entity.id,
|
|
437
|
-
workingMemory: entity.workingMemory ?? undefined,
|
|
438
|
-
metadata: entity.metadata ?? undefined,
|
|
439
|
-
createdAt: entity.createdAt,
|
|
440
|
-
updatedAt: entity.updatedAt,
|
|
441
|
-
};
|
|
442
|
-
});
|
|
443
|
-
}
|
|
444
|
-
async saveResource({ resource, }) {
|
|
445
|
-
const entity = this.resourceRepo.create({
|
|
446
|
-
id: resource.id,
|
|
447
|
-
workingMemory: resource.workingMemory ?? null,
|
|
448
|
-
metadata: resource.metadata ?? null,
|
|
449
|
-
});
|
|
450
|
-
const saved = await this.resourceRepo.save(entity);
|
|
451
|
-
return {
|
|
452
|
-
id: saved.id,
|
|
453
|
-
workingMemory: saved.workingMemory ?? undefined,
|
|
454
|
-
metadata: saved.metadata ?? undefined,
|
|
455
|
-
createdAt: saved.createdAt,
|
|
456
|
-
updatedAt: saved.updatedAt,
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
async updateResource({ resourceId, workingMemory, metadata, }) {
|
|
460
|
-
let existing = await this.resourceRepo.findOneBy({ id: resourceId });
|
|
461
|
-
if (!existing) {
|
|
462
|
-
existing = await this.resourceRepo.save(this.resourceRepo.create({
|
|
463
|
-
id: resourceId,
|
|
464
|
-
workingMemory: workingMemory ?? null,
|
|
465
|
-
metadata: metadata ?? null,
|
|
466
|
-
}));
|
|
467
|
-
}
|
|
468
|
-
else {
|
|
469
|
-
if (workingMemory !== undefined)
|
|
470
|
-
existing.workingMemory = workingMemory;
|
|
471
|
-
if (metadata !== undefined)
|
|
472
|
-
existing.metadata = metadata;
|
|
473
|
-
existing = await this.resourceRepo.save(existing);
|
|
474
|
-
}
|
|
475
|
-
return {
|
|
476
|
-
id: existing.id,
|
|
477
|
-
workingMemory: existing.workingMemory ?? undefined,
|
|
478
|
-
metadata: existing.metadata ?? undefined,
|
|
479
|
-
createdAt: existing.createdAt,
|
|
480
|
-
updatedAt: existing.updatedAt,
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
async cloneThread(args) {
|
|
484
|
-
const source = await this.getThreadById({
|
|
485
|
-
threadId: args.sourceThreadId,
|
|
486
|
-
});
|
|
487
|
-
if (!source)
|
|
488
|
-
throw new Error(`Source thread ${args.sourceThreadId} not found`);
|
|
489
|
-
const newThreadId = args.newThreadId ?? (0, node_crypto_1.randomUUID)();
|
|
490
|
-
const cloneMetadata = {
|
|
491
|
-
...(source.metadata ?? {}),
|
|
492
|
-
...(args.metadata ?? {}),
|
|
493
|
-
mastra: {
|
|
494
|
-
...(source.metadata?.mastra ?? {}),
|
|
495
|
-
clone: {
|
|
496
|
-
sourceThreadId: args.sourceThreadId,
|
|
497
|
-
clonedAt: new Date(),
|
|
498
|
-
},
|
|
499
|
-
},
|
|
500
|
-
};
|
|
501
|
-
const newThread = await this.saveThread({
|
|
502
|
-
thread: {
|
|
503
|
-
id: newThreadId,
|
|
504
|
-
resourceId: args.resourceId ?? source.resourceId,
|
|
505
|
-
title: args.title ?? source.title,
|
|
506
|
-
metadata: cloneMetadata,
|
|
507
|
-
createdAt: new Date(),
|
|
508
|
-
updatedAt: new Date(),
|
|
509
|
-
},
|
|
510
|
-
});
|
|
511
|
-
const { messages: sourceMessages } = await this.listMessages({
|
|
512
|
-
threadId: args.sourceThreadId,
|
|
513
|
-
perPage: false,
|
|
514
|
-
orderBy: { field: 'createdAt', direction: 'ASC' },
|
|
515
|
-
});
|
|
516
|
-
let messagesToClone = sourceMessages;
|
|
517
|
-
if (args.options?.messageLimit) {
|
|
518
|
-
messagesToClone = messagesToClone.slice(-args.options.messageLimit);
|
|
519
|
-
}
|
|
520
|
-
const messageIdMap = {};
|
|
521
|
-
const clonedMessages = messagesToClone.map((m) => {
|
|
522
|
-
const newId = (0, utils_1.generateNanoId)();
|
|
523
|
-
messageIdMap[m.id] = newId;
|
|
524
|
-
return { ...m, id: newId, threadId: newThreadId };
|
|
525
|
-
});
|
|
526
|
-
if (clonedMessages.length > 0) {
|
|
527
|
-
await this.saveMessages({ messages: clonedMessages });
|
|
528
|
-
}
|
|
529
|
-
return { thread: newThread, clonedMessages, messageIdMap };
|
|
530
|
-
}
|
|
531
|
-
omLookupKey(scope, threadId, resourceId) {
|
|
532
|
-
return `${scope}:${threadId ?? 'null'}:${resourceId}`;
|
|
533
|
-
}
|
|
534
|
-
entityToOMRecord(entity) {
|
|
535
|
-
return {
|
|
536
|
-
id: entity.id,
|
|
537
|
-
scope: entity.scope,
|
|
538
|
-
threadId: entity.threadId,
|
|
539
|
-
resourceId: entity.resourceId,
|
|
540
|
-
createdAt: entity.createdAt,
|
|
541
|
-
updatedAt: entity.updatedAt,
|
|
542
|
-
lastObservedAt: entity.lastObservedAt ?? undefined,
|
|
543
|
-
originType: entity.originType,
|
|
544
|
-
generationCount: entity.generationCount,
|
|
545
|
-
activeObservations: entity.activeObservations,
|
|
546
|
-
bufferedObservationChunks: (entity.bufferedObservationChunks ??
|
|
547
|
-
undefined),
|
|
548
|
-
bufferedObservations: entity.bufferedObservations ?? undefined,
|
|
549
|
-
bufferedObservationTokens: entity.bufferedObservationTokens ?? undefined,
|
|
550
|
-
bufferedMessageIds: entity.bufferedMessageIds ?? undefined,
|
|
551
|
-
bufferedReflection: entity.bufferedReflection ?? undefined,
|
|
552
|
-
bufferedReflectionTokens: entity.bufferedReflectionTokens ?? undefined,
|
|
553
|
-
bufferedReflectionInputTokens: entity.bufferedReflectionInputTokens ?? undefined,
|
|
554
|
-
reflectedObservationLineCount: entity.reflectedObservationLineCount ?? undefined,
|
|
555
|
-
observedMessageIds: entity.observedMessageIds ?? undefined,
|
|
556
|
-
observedTimezone: entity.observedTimezone ?? undefined,
|
|
557
|
-
totalTokensObserved: entity.totalTokensObserved,
|
|
558
|
-
observationTokenCount: entity.observationTokenCount,
|
|
559
|
-
pendingMessageTokens: entity.pendingMessageTokens,
|
|
560
|
-
isReflecting: entity.isReflecting,
|
|
561
|
-
isObserving: entity.isObserving,
|
|
562
|
-
isBufferingObservation: entity.isBufferingObservation,
|
|
563
|
-
isBufferingReflection: entity.isBufferingReflection,
|
|
564
|
-
lastBufferedAtTokens: entity.lastBufferedAtTokens,
|
|
565
|
-
lastBufferedAtTime: entity.lastBufferedAtTime,
|
|
566
|
-
config: typeof entity.config === 'string' ? (0, n8n_workflow_1.jsonParse)(entity.config) : entity.config,
|
|
567
|
-
metadata: entity.metadata ?? undefined,
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
async getObservationalMemory(threadId, resourceId) {
|
|
571
|
-
const lookupKey = this.omLookupKey(threadId ? 'thread' : 'resource', threadId, resourceId);
|
|
572
|
-
const entity = await this.omRepo.findOne({
|
|
573
|
-
where: { lookupKey },
|
|
574
|
-
order: { generationCount: 'DESC' },
|
|
575
|
-
});
|
|
576
|
-
if (!entity)
|
|
577
|
-
return null;
|
|
578
|
-
return this.entityToOMRecord(entity);
|
|
579
|
-
}
|
|
580
|
-
async getObservationalMemoryHistory(threadId, resourceId, limit = 10) {
|
|
581
|
-
const scope = threadId ? 'thread' : 'resource';
|
|
582
|
-
const entities = await this.omRepo.find({
|
|
583
|
-
where: { scope, threadId: threadId ?? undefined, resourceId },
|
|
584
|
-
order: { generationCount: 'DESC' },
|
|
585
|
-
take: limit,
|
|
586
|
-
});
|
|
587
|
-
return entities.map((e) => this.entityToOMRecord(e));
|
|
588
|
-
}
|
|
589
|
-
async initializeObservationalMemory(input) {
|
|
590
|
-
const id = (0, utils_1.generateNanoId)();
|
|
591
|
-
const lookupKey = this.omLookupKey(input.scope, input.threadId, input.resourceId);
|
|
592
|
-
const entity = this.omRepo.create({
|
|
593
|
-
id,
|
|
594
|
-
lookupKey,
|
|
595
|
-
scope: input.scope,
|
|
596
|
-
threadId: input.threadId,
|
|
597
|
-
resourceId: input.resourceId,
|
|
598
|
-
originType: 'initial',
|
|
599
|
-
config: JSON.stringify(input.config),
|
|
600
|
-
observedTimezone: input.observedTimezone ?? null,
|
|
601
|
-
});
|
|
602
|
-
const saved = await this.omRepo.save(entity);
|
|
603
|
-
return this.entityToOMRecord(saved);
|
|
604
|
-
}
|
|
605
|
-
async insertObservationalMemoryRecord(record) {
|
|
606
|
-
const lookupKey = this.omLookupKey(record.scope, record.threadId, record.resourceId);
|
|
607
|
-
const entity = this.omRepo.create({
|
|
608
|
-
id: record.id,
|
|
609
|
-
lookupKey,
|
|
610
|
-
scope: record.scope,
|
|
611
|
-
threadId: record.threadId,
|
|
612
|
-
resourceId: record.resourceId,
|
|
613
|
-
activeObservations: record.activeObservations,
|
|
614
|
-
originType: record.originType,
|
|
615
|
-
config: JSON.stringify(record.config),
|
|
616
|
-
generationCount: record.generationCount,
|
|
617
|
-
lastObservedAt: record.lastObservedAt ?? null,
|
|
618
|
-
pendingMessageTokens: record.pendingMessageTokens,
|
|
619
|
-
totalTokensObserved: record.totalTokensObserved,
|
|
620
|
-
observationTokenCount: record.observationTokenCount,
|
|
621
|
-
isObserving: record.isObserving,
|
|
622
|
-
isReflecting: record.isReflecting,
|
|
623
|
-
observedMessageIds: record.observedMessageIds ?? null,
|
|
624
|
-
observedTimezone: record.observedTimezone ?? null,
|
|
625
|
-
bufferedObservations: record.bufferedObservations ?? null,
|
|
626
|
-
bufferedObservationTokens: record.bufferedObservationTokens ?? null,
|
|
627
|
-
bufferedMessageIds: record.bufferedMessageIds ?? null,
|
|
628
|
-
bufferedReflection: record.bufferedReflection ?? null,
|
|
629
|
-
bufferedReflectionTokens: record.bufferedReflectionTokens ?? null,
|
|
630
|
-
bufferedReflectionInputTokens: record.bufferedReflectionInputTokens ?? null,
|
|
631
|
-
reflectedObservationLineCount: record.reflectedObservationLineCount ?? null,
|
|
632
|
-
bufferedObservationChunks: (record.bufferedObservationChunks ?? null),
|
|
633
|
-
isBufferingObservation: record.isBufferingObservation,
|
|
634
|
-
isBufferingReflection: record.isBufferingReflection,
|
|
635
|
-
lastBufferedAtTokens: record.lastBufferedAtTokens,
|
|
636
|
-
lastBufferedAtTime: record.lastBufferedAtTime ?? null,
|
|
637
|
-
metadata: record.metadata ?? null,
|
|
638
|
-
});
|
|
639
|
-
await this.omRepo.save(entity);
|
|
640
|
-
}
|
|
641
|
-
async updateActiveObservations(input) {
|
|
642
|
-
const entity = await this.omRepo.findOneByOrFail({ id: input.id });
|
|
643
|
-
const existingIds = entity.observedMessageIds ?? [];
|
|
644
|
-
const mergedIds = [...new Set([...existingIds, ...(input.observedMessageIds ?? [])])];
|
|
645
|
-
await this.omRepo.update(input.id, {
|
|
646
|
-
activeObservations: input.observations,
|
|
647
|
-
observationTokenCount: input.tokenCount,
|
|
648
|
-
lastObservedAt: input.lastObservedAt,
|
|
649
|
-
observedMessageIds: mergedIds,
|
|
650
|
-
observedTimezone: input.observedTimezone ?? entity.observedTimezone,
|
|
651
|
-
totalTokensObserved: entity.totalTokensObserved + input.tokenCount,
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
async updateBufferedObservations(input) {
|
|
655
|
-
const entity = await this.omRepo.findOneByOrFail({ id: input.id });
|
|
656
|
-
const chunks = entity.bufferedObservationChunks ?? [];
|
|
657
|
-
chunks.push(input.chunk);
|
|
658
|
-
const updates = {
|
|
659
|
-
bufferedObservationChunks: chunks,
|
|
660
|
-
};
|
|
661
|
-
if (input.lastBufferedAtTime) {
|
|
662
|
-
updates.lastBufferedAtTime = input.lastBufferedAtTime;
|
|
663
|
-
}
|
|
664
|
-
await this.omRepo.update(input.id, updates);
|
|
665
|
-
}
|
|
666
|
-
async swapBufferedToActive(input) {
|
|
667
|
-
const entity = await this.omRepo.findOneByOrFail({ id: input.id });
|
|
668
|
-
const record = this.entityToOMRecord(entity);
|
|
669
|
-
const chunks = record.bufferedObservationChunks ?? [];
|
|
670
|
-
if (chunks.length === 0) {
|
|
671
|
-
return {
|
|
672
|
-
chunksActivated: 0,
|
|
673
|
-
messageTokensActivated: 0,
|
|
674
|
-
observationTokensActivated: 0,
|
|
675
|
-
messagesActivated: 0,
|
|
676
|
-
activatedCycleIds: [],
|
|
677
|
-
activatedMessageIds: [],
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
const retentionFloor = input.messageTokensThreshold * (1 - input.activationRatio);
|
|
681
|
-
const tokensToRemove = input.currentPendingTokens - retentionFloor;
|
|
682
|
-
let removedTokens = 0;
|
|
683
|
-
let activatedCount = 0;
|
|
684
|
-
const activated = [];
|
|
685
|
-
const remaining = [];
|
|
686
|
-
for (const chunk of chunks) {
|
|
687
|
-
if (removedTokens < tokensToRemove || (input.forceMaxActivation && remaining.length === 0)) {
|
|
688
|
-
activated.push(chunk);
|
|
689
|
-
removedTokens += chunk.messageTokens ?? 0;
|
|
690
|
-
activatedCount++;
|
|
691
|
-
}
|
|
692
|
-
else {
|
|
693
|
-
remaining.push(chunk);
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
let totalMessageTokens = 0;
|
|
697
|
-
let totalObsTokens = 0;
|
|
698
|
-
let totalMessages = 0;
|
|
699
|
-
const allMsgIds = [];
|
|
700
|
-
const cycleIds = [];
|
|
701
|
-
const observationParts = [];
|
|
702
|
-
for (const chunk of activated) {
|
|
703
|
-
totalMessageTokens += chunk.messageTokens ?? 0;
|
|
704
|
-
totalObsTokens += chunk.tokenCount ?? 0;
|
|
705
|
-
totalMessages += chunk.messageIds?.length ?? 0;
|
|
706
|
-
allMsgIds.push(...(chunk.messageIds ?? []));
|
|
707
|
-
if (chunk.cycleId)
|
|
708
|
-
cycleIds.push(chunk.cycleId);
|
|
709
|
-
if (chunk.observations)
|
|
710
|
-
observationParts.push(chunk.observations);
|
|
711
|
-
}
|
|
712
|
-
const newActive = record.activeObservations
|
|
713
|
-
? record.activeObservations + '\n' + observationParts.join('\n')
|
|
714
|
-
: observationParts.join('\n');
|
|
715
|
-
const lastActivatedChunk = activated[activated.length - 1];
|
|
716
|
-
const newLastObservedAt = input.lastObservedAt ??
|
|
717
|
-
(lastActivatedChunk?.lastObservedAt
|
|
718
|
-
? new Date(lastActivatedChunk.lastObservedAt)
|
|
719
|
-
: record.lastObservedAt);
|
|
720
|
-
const existingMsgIds = record.observedMessageIds ?? [];
|
|
721
|
-
const mergedMsgIds = [...new Set([...existingMsgIds, ...allMsgIds])];
|
|
722
|
-
await this.omRepo.update(input.id, {
|
|
723
|
-
activeObservations: newActive,
|
|
724
|
-
observationTokenCount: record.observationTokenCount + totalObsTokens,
|
|
725
|
-
bufferedObservationChunks: remaining.length > 0 ? remaining : null,
|
|
726
|
-
lastObservedAt: newLastObservedAt ?? null,
|
|
727
|
-
observedMessageIds: mergedMsgIds,
|
|
728
|
-
totalTokensObserved: record.totalTokensObserved + totalObsTokens,
|
|
729
|
-
isBufferingObservation: false,
|
|
730
|
-
});
|
|
731
|
-
return {
|
|
732
|
-
chunksActivated: activatedCount,
|
|
733
|
-
messageTokensActivated: totalMessageTokens,
|
|
734
|
-
observationTokensActivated: totalObsTokens,
|
|
735
|
-
messagesActivated: totalMessages,
|
|
736
|
-
activatedCycleIds: cycleIds,
|
|
737
|
-
activatedMessageIds: allMsgIds,
|
|
738
|
-
observations: observationParts.join('\n'),
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
async createReflectionGeneration(input) {
|
|
742
|
-
const { currentRecord, reflection, tokenCount } = input;
|
|
743
|
-
const newId = (0, utils_1.generateNanoId)();
|
|
744
|
-
const lookupKey = this.omLookupKey(currentRecord.scope, currentRecord.threadId, currentRecord.resourceId);
|
|
745
|
-
const entity = this.omRepo.create({
|
|
746
|
-
id: newId,
|
|
747
|
-
lookupKey,
|
|
748
|
-
scope: currentRecord.scope,
|
|
749
|
-
threadId: currentRecord.threadId,
|
|
750
|
-
resourceId: currentRecord.resourceId,
|
|
751
|
-
activeObservations: reflection,
|
|
752
|
-
originType: 'reflection',
|
|
753
|
-
config: JSON.stringify(currentRecord.config),
|
|
754
|
-
generationCount: currentRecord.generationCount + 1,
|
|
755
|
-
lastObservedAt: currentRecord.lastObservedAt ?? null,
|
|
756
|
-
observationTokenCount: tokenCount,
|
|
757
|
-
totalTokensObserved: currentRecord.totalTokensObserved,
|
|
758
|
-
pendingMessageTokens: currentRecord.pendingMessageTokens,
|
|
759
|
-
isObserving: false,
|
|
760
|
-
isReflecting: false,
|
|
761
|
-
isBufferingObservation: false,
|
|
762
|
-
isBufferingReflection: false,
|
|
763
|
-
lastBufferedAtTokens: 0,
|
|
764
|
-
lastBufferedAtTime: null,
|
|
765
|
-
observedTimezone: currentRecord.observedTimezone ?? null,
|
|
766
|
-
metadata: currentRecord.metadata ?? null,
|
|
767
|
-
});
|
|
768
|
-
const saved = await this.omRepo.save(entity);
|
|
769
|
-
return this.entityToOMRecord(saved);
|
|
770
|
-
}
|
|
771
|
-
async updateBufferedReflection(input) {
|
|
772
|
-
await this.omRepo.update(input.id, {
|
|
773
|
-
bufferedReflection: input.reflection,
|
|
774
|
-
bufferedReflectionTokens: input.tokenCount,
|
|
775
|
-
bufferedReflectionInputTokens: input.inputTokenCount,
|
|
776
|
-
reflectedObservationLineCount: input.reflectedObservationLineCount,
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
async swapBufferedReflectionToActive(input) {
|
|
780
|
-
const { currentRecord, tokenCount } = input;
|
|
781
|
-
const lines = currentRecord.activeObservations.split('\n');
|
|
782
|
-
const reflectedCount = currentRecord.reflectedObservationLineCount ?? lines.length;
|
|
783
|
-
const unreflected = lines.slice(reflectedCount).join('\n');
|
|
784
|
-
const newActive = currentRecord.bufferedReflection
|
|
785
|
-
? unreflected
|
|
786
|
-
? `${currentRecord.bufferedReflection}\n${unreflected}`
|
|
787
|
-
: currentRecord.bufferedReflection
|
|
788
|
-
: unreflected;
|
|
789
|
-
const newId = (0, utils_1.generateNanoId)();
|
|
790
|
-
const lookupKey = this.omLookupKey(currentRecord.scope, currentRecord.threadId, currentRecord.resourceId);
|
|
791
|
-
const entity = this.omRepo.create({
|
|
792
|
-
id: newId,
|
|
793
|
-
lookupKey,
|
|
794
|
-
scope: currentRecord.scope,
|
|
795
|
-
threadId: currentRecord.threadId,
|
|
796
|
-
resourceId: currentRecord.resourceId,
|
|
797
|
-
activeObservations: newActive,
|
|
798
|
-
originType: 'reflection',
|
|
799
|
-
config: JSON.stringify(currentRecord.config),
|
|
800
|
-
generationCount: currentRecord.generationCount + 1,
|
|
801
|
-
lastObservedAt: currentRecord.lastObservedAt ?? null,
|
|
802
|
-
observationTokenCount: tokenCount,
|
|
803
|
-
totalTokensObserved: currentRecord.totalTokensObserved,
|
|
804
|
-
pendingMessageTokens: currentRecord.pendingMessageTokens,
|
|
805
|
-
isObserving: false,
|
|
806
|
-
isReflecting: false,
|
|
807
|
-
isBufferingObservation: false,
|
|
808
|
-
isBufferingReflection: false,
|
|
809
|
-
lastBufferedAtTokens: 0,
|
|
810
|
-
lastBufferedAtTime: null,
|
|
811
|
-
observedTimezone: currentRecord.observedTimezone ?? null,
|
|
812
|
-
metadata: currentRecord.metadata ?? null,
|
|
813
|
-
});
|
|
814
|
-
const saved = await this.omRepo.save(entity);
|
|
815
|
-
return this.entityToOMRecord(saved);
|
|
816
|
-
}
|
|
817
|
-
async setReflectingFlag(id, isReflecting) {
|
|
818
|
-
await this.omRepo.update(id, { isReflecting });
|
|
819
|
-
}
|
|
820
|
-
async setObservingFlag(id, isObserving) {
|
|
821
|
-
await this.omRepo.update(id, { isObserving });
|
|
822
|
-
}
|
|
823
|
-
async setBufferingObservationFlag(id, isBuffering, lastBufferedAtTokens) {
|
|
824
|
-
const updates = {
|
|
825
|
-
isBufferingObservation: isBuffering,
|
|
826
|
-
};
|
|
827
|
-
if (isBuffering && lastBufferedAtTokens !== undefined) {
|
|
828
|
-
updates.lastBufferedAtTokens = lastBufferedAtTokens;
|
|
829
|
-
}
|
|
830
|
-
await this.omRepo.update(id, updates);
|
|
831
|
-
}
|
|
832
|
-
async setBufferingReflectionFlag(id, isBuffering) {
|
|
833
|
-
await this.omRepo.update(id, { isBufferingReflection: isBuffering });
|
|
834
|
-
}
|
|
835
|
-
async clearObservationalMemory(threadId, resourceId) {
|
|
836
|
-
const scope = threadId ? 'thread' : 'resource';
|
|
837
|
-
const lookupKey = this.omLookupKey(scope, threadId, resourceId);
|
|
838
|
-
await this.omRepo.delete({ lookupKey });
|
|
839
|
-
}
|
|
840
|
-
async setPendingMessageTokens(id, tokenCount) {
|
|
841
|
-
await this.omRepo.update(id, { pendingMessageTokens: tokenCount });
|
|
842
|
-
}
|
|
843
|
-
entityToMessage(entity) {
|
|
844
|
-
return {
|
|
845
|
-
id: entity.id,
|
|
846
|
-
role: entity.role,
|
|
847
|
-
createdAt: entity.createdAt,
|
|
848
|
-
threadId: entity.threadId,
|
|
849
|
-
resourceId: entity.resourceId ?? undefined,
|
|
850
|
-
type: entity.type ?? undefined,
|
|
851
|
-
content: (0, n8n_workflow_1.jsonParse)(entity.content),
|
|
852
|
-
};
|
|
853
|
-
}
|
|
854
|
-
};
|
|
855
|
-
exports.TypeORMMemoryStorage = TypeORMMemoryStorage;
|
|
856
|
-
TypeORMMemoryStorage.threadMutationQueues = new Map();
|
|
857
|
-
exports.TypeORMMemoryStorage = TypeORMMemoryStorage = TypeORMMemoryStorage_1 = __decorate([
|
|
858
|
-
(0, di_1.Service)(),
|
|
859
|
-
__metadata("design:paramtypes", [instance_ai_thread_repository_1.InstanceAiThreadRepository,
|
|
860
|
-
instance_ai_message_repository_1.InstanceAiMessageRepository,
|
|
861
|
-
instance_ai_resource_repository_1.InstanceAiResourceRepository,
|
|
862
|
-
instance_ai_observational_memory_repository_1.InstanceAiObservationalMemoryRepository])
|
|
863
|
-
], TypeORMMemoryStorage);
|
|
864
|
-
//# sourceMappingURL=typeorm-memory-storage.js.map
|