@xopcai/xopc 0.0.117 → 0.0.119
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -24
- package/README.zh-CN.md +46 -42
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BBLhJ2C6.js → agent-avatar-dicebear-CU8J6zou.js} +1 -1
- package/dist/gateway/static/root/assets/agents-B0hkpLhP.js +2 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-B9vfYoEr.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-ClOzIO24.js +1 -0
- package/dist/gateway/static/root/assets/{apps-page-DdDx0V4z.js → apps-page-DU0dz9Zo.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-DZsVqMhU.js → archive-plugin-BkVIgZzA.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CIol6JWX.js → attachment-load-CaCMWh1D.js} +1 -1
- package/dist/gateway/static/root/assets/automation-suggestion-card-DhGDpKP3.js +1 -0
- package/dist/gateway/static/root/assets/automations-page-CTedroVo.js +1 -0
- package/dist/gateway/static/root/assets/{binary-plugins-B3UauMfp.js → binary-plugins-B4TO_bsn.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-2HJoFchH.js → block-editor-DJRWwWNI.js} +6 -6
- package/dist/gateway/static/root/assets/browser-settings-page-FCDwOOBK.js +8 -0
- package/dist/gateway/static/root/assets/capability-presets-api-Befi89CL.js +1 -0
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-_G8eb2vJ.js +1 -0
- package/dist/gateway/static/root/assets/channel-recipient-api-BNSuJb5f.js +1 -0
- package/dist/gateway/static/root/assets/channels-settings-C3d5JBJX.js +1 -0
- package/dist/gateway/static/root/assets/cn-BQ_8x0bT.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-yaUNvt5u.js +2 -0
- package/dist/gateway/static/root/assets/cron-expression-B3B1eqnr.js +2 -0
- package/dist/gateway/static/root/assets/dreaming-settings-DNrdg1Ve.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DX5WRE_t.js → extension-debug-page-DYh402XV.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Buah7Bw-.js → extension-page-Cr_TizrN.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DuroLVnf.js → extension-settings-page-BU1KoKRj.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-B5zdl27C.js → fetch-Y7AEX4H3.js} +1 -1
- package/dist/gateway/static/root/assets/format-cron-label-arqgGlVV.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-gT4ZhE7h.js → gateway-config-api-RbMmAOpX.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-C79wkXef.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-B3kL8KGY.js → gateway-startup-retry-DiD_Tx4N.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-9paXuHdo.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-AR-fVh0P.js → goals-config-api-DqxVi0p5.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-Cpb21ezg.js → goals-page-CS0R-Af2.js} +2 -2
- package/dist/gateway/static/root/assets/goals-settings-CSuzZ8Ae.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-DXPaYJm3.js +1 -0
- package/dist/gateway/static/root/assets/index-BoKafJIZ.js +191 -0
- package/dist/gateway/static/root/assets/index-CArhCcYn.css +1 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-Dvg53qnd.js +1 -0
- package/dist/gateway/static/root/assets/{logs-page-DefCgF4o.js → logs-page-DLXPcksQ.js} +2 -2
- package/dist/gateway/static/root/assets/{markdown-split-ChbR9LGO.js → markdown-split-CpHxbtWJ.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-B82oP80n.js → media-plugins-SFPQRSxq.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CrDHEbss.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-BDF2iyRk.js +2 -0
- package/dist/gateway/static/root/assets/note-detail-page-CSb_hwig.js +2 -0
- package/dist/gateway/static/root/assets/{note-image-lightbox-CDknITM3.js → note-image-lightbox-BUYURRgn.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-BsIBSFyZ.js +1 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DV3xQsWB.js → preview-open-alternatives-BHz9iWYA.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CwzSovcS.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BODCXnvY.js → save-bar-controls-CefkOlRg.js} +1 -1
- package/dist/gateway/static/root/assets/schedule-field-CmTRoOcE.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-qtfEI6QM.js → schema-form-FMKv1vGu.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-PHmX-NmA.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BRAeKJN4.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-BHZKjVcS.js → settings-collapsible-section-BouO6JTi.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-5i35D-J1.js → settings-form-section-D-4lBl6X.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-KKrbFjy8.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-layout-BJ4Gsef5.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-CrUjHPQo.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-B0H63tDv.js → share-preview-page-BDy2btRN.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-B18OBmH5.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-C28-2uKQ.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-Bm2ebkwl.js +2 -0
- package/dist/gateway/static/root/assets/system-settings-panel-CRngrlnZ.js +1 -0
- package/dist/gateway/static/root/assets/typed-models-lib-BltBc0b-.js +1 -0
- package/dist/gateway/static/root/assets/{use-channel-catalog-BCjP_VHb.js → use-channel-catalog-CjN-51e6.js} +1 -1
- package/dist/gateway/static/root/assets/user-profile-settings-panel-DJ1dKwZy.js +1 -0
- package/dist/gateway/static/root/assets/utils-B5M5-YvK.js +1 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-CeEevm7z.js +1 -0
- package/dist/gateway/static/root/assets/{voice-player-store-BlF9V05n.js → voice-player-store-B7ykUlHM.js} +1 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-C4PzUQjB.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-BL84_-Ky.js +18 -0
- package/dist/gateway/static/root/index.html +6 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +4 -5
- package/dist/src/agent/agent-manager.js +6 -9
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/agent-scope.js +0 -2
- package/dist/src/agent/agent-scope.js.map +1 -1
- package/dist/src/agent/background-review/prompts.d.ts +2 -2
- package/dist/src/agent/background-review/prompts.js +2 -2
- package/dist/src/agent/background-review/prompts.js.map +1 -1
- package/dist/src/agent/background-review/settings.d.ts +1 -1
- package/dist/src/agent/background-review/settings.js +7 -8
- package/dist/src/agent/background-review/settings.js.map +1 -1
- package/dist/src/agent/bootstrap/bootstrap-cache.d.ts +1 -0
- package/dist/src/agent/bootstrap/bootstrap-cache.js +4 -3
- package/dist/src/agent/bootstrap/bootstrap-cache.js.map +1 -1
- package/dist/src/agent/bootstrap/bootstrap-files.d.ts +4 -0
- package/dist/src/agent/bootstrap/bootstrap-files.js +4 -3
- package/dist/src/agent/bootstrap/bootstrap-files.js.map +1 -1
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js +4 -2
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js.map +1 -1
- package/dist/src/agent/bootstrap/load-bootstrap-files.d.ts +2 -1
- package/dist/src/agent/bootstrap/load-bootstrap-files.js +17 -16
- package/dist/src/agent/bootstrap/load-bootstrap-files.js.map +1 -1
- package/dist/src/agent/bootstrap/types.d.ts +1 -1
- package/dist/src/agent/context/workspace-templates/AGENTS.md +1 -1
- package/dist/src/agent/context/workspace.d.ts +4 -2
- package/dist/src/agent/context/workspace.js +5 -4
- package/dist/src/agent/context/workspace.js.map +1 -1
- package/dist/src/agent/embedded/run-for-session.js +106 -15
- package/dist/src/agent/embedded/run-for-session.js.map +1 -1
- package/dist/src/agent/fallback/candidates.d.ts +0 -8
- package/dist/src/agent/fallback/candidates.js +10 -11
- package/dist/src/agent/fallback/candidates.js.map +1 -1
- package/dist/src/agent/index.js +1 -1
- package/dist/src/agent/lifecycle/handlers/compaction.d.ts +1 -3
- package/dist/src/agent/lifecycle/handlers/compaction.js +1 -16
- package/dist/src/agent/lifecycle/handlers/compaction.js.map +1 -1
- package/dist/src/agent/lifecycle/progress.d.ts +0 -1
- package/dist/src/agent/lifecycle/progress.js +1 -6
- package/dist/src/agent/lifecycle/progress.js.map +1 -1
- package/dist/src/agent/lifecycle/timeout-wrapper.d.ts +1 -2
- package/dist/src/agent/lifecycle/timeout-wrapper.js +1 -7
- package/dist/src/agent/lifecycle/timeout-wrapper.js.map +1 -1
- package/dist/src/agent/memory/builtin-memory-store.d.ts +4 -2
- package/dist/src/agent/memory/builtin-memory-store.js +11 -6
- package/dist/src/agent/memory/builtin-memory-store.js.map +1 -1
- package/dist/src/agent/memory/builtin-provider.js +36 -7
- package/dist/src/agent/memory/builtin-provider.js.map +1 -1
- package/dist/src/agent/memory/candidate-extractor.d.ts +6 -0
- package/dist/src/agent/memory/candidate-extractor.js +60 -0
- package/dist/src/agent/memory/candidate-extractor.js.map +1 -0
- package/dist/src/agent/memory/manager.d.ts +2 -1
- package/dist/src/agent/memory/manager.js +27 -3
- package/dist/src/agent/memory/manager.js.map +1 -1
- package/dist/src/agent/memory/memory-config.js +3 -0
- package/dist/src/agent/memory/memory-config.js.map +1 -1
- package/dist/src/agent/memory/prefetch-coordinator.js.map +1 -1
- package/dist/src/agent/memory/types.d.ts +27 -4
- package/dist/src/agent/middleware/self-verify.d.ts +0 -1
- package/dist/src/agent/middleware/self-verify.js +0 -2
- package/dist/src/agent/middleware/self-verify.js.map +1 -1
- package/dist/src/agent/models/index.d.ts +1 -1
- package/dist/src/agent/models/manager.d.ts +4 -20
- package/dist/src/agent/models/manager.js +9 -126
- package/dist/src/agent/models/manager.js.map +1 -1
- package/dist/src/agent/orchestration/agent-orchestrator.d.ts +0 -4
- package/dist/src/agent/orchestration/agent-orchestrator.js +1 -9
- package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
- package/dist/src/agent/prompt/memory/index.d.ts +4 -2
- package/dist/src/agent/prompt/memory/index.js +18 -12
- package/dist/src/agent/prompt/memory/index.js.map +1 -1
- package/dist/src/agent/prompt/sections/memory-skills.js +1 -1
- package/dist/src/agent/prompt/sections/memory-skills.js.map +1 -1
- package/dist/src/agent/prompt/sections/tooling.js +2 -2
- package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.d.ts +0 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +4 -31
- package/dist/src/agent/prompt/service-prompt-builder.js.map +1 -1
- package/dist/src/agent/prompt/subagent-context.js +1 -1
- package/dist/src/agent/prompt/subagent-context.js.map +1 -1
- package/dist/src/agent/prompt/types.d.ts +1 -1
- package/dist/src/agent/reply/post-compaction-context.js +1 -3
- package/dist/src/agent/reply/post-compaction-context.js.map +1 -1
- package/dist/src/agent/reply/startup-context.js +1 -5
- package/dist/src/agent/reply/startup-context.js.map +1 -1
- package/dist/src/agent/service.d.ts +4 -12
- package/dist/src/agent/service.js +10 -48
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/service.types.d.ts +2 -2
- package/dist/src/agent/session/session-config-service.d.ts +11 -11
- package/dist/src/agent/session/session-config-service.js +14 -14
- package/dist/src/agent/session/session-config-service.js.map +1 -1
- package/dist/src/agent/session/session-inspector.js +3 -2
- package/dist/src/agent/session/session-inspector.js.map +1 -1
- package/dist/src/agent/starter-agents.js +12 -12
- package/dist/src/agent/starter-agents.js.map +1 -1
- package/dist/src/agent/tools/automation-tool.d.ts +14 -0
- package/dist/src/agent/tools/automation-tool.js +102 -0
- package/dist/src/agent/tools/automation-tool.js.map +1 -0
- package/dist/src/agent/tools/curated-memory-tool.js +57 -2
- package/dist/src/agent/tools/curated-memory-tool.js.map +1 -1
- package/dist/src/agent/tools/delegate-tool.js +1 -1
- package/dist/src/agent/tools/delegate-tool.js.map +1 -1
- package/dist/src/agent/tools/factory.d.ts +3 -3
- package/dist/src/agent/tools/factory.js +2 -2
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/index.d.ts +1 -1
- package/dist/src/agent/tools/index.js +2 -2
- package/dist/src/agent/tools/web-extract.js +6 -8
- package/dist/src/agent/tools/web-extract.js.map +1 -1
- package/dist/src/agent-manifest/index.js +2 -2
- package/dist/src/agent-manifest/resolver.d.ts +4 -2
- package/dist/src/agent-manifest/resolver.js +6 -3
- package/dist/src/agent-manifest/resolver.js.map +1 -1
- package/dist/src/agent-manifest/schema.d.ts +238 -0
- package/dist/src/agent-manifest/schema.js +16 -5
- package/dist/src/agent-manifest/schema.js.map +1 -1
- package/dist/src/agent-manifest/validator.d.ts +3 -2
- package/dist/src/agent-manifest/validator.js +2 -1
- package/dist/src/agent-manifest/validator.js.map +1 -1
- package/dist/src/ai-assist/text-assist.d.ts +1 -1
- package/dist/src/ai-assist/text-assist.js +56 -0
- package/dist/src/ai-assist/text-assist.js.map +1 -1
- package/dist/src/auth/profiles/store.js.map +1 -1
- package/dist/src/automations/api/routes.d.ts +3 -0
- package/dist/src/automations/api/routes.js +193 -0
- package/dist/src/automations/api/routes.js.map +1 -0
- package/dist/src/automations/domain/index.d.ts +3 -0
- package/dist/src/automations/domain/index.js +3 -0
- package/dist/src/automations/domain/schedule.d.ts +4 -0
- package/dist/src/automations/domain/schedule.js +37 -0
- package/dist/src/automations/domain/schedule.js.map +1 -0
- package/dist/src/automations/domain/types.d.ts +160 -0
- package/dist/src/automations/domain/validation.d.ts +370 -0
- package/dist/src/automations/domain/validation.js +149 -0
- package/dist/src/automations/domain/validation.js.map +1 -0
- package/dist/src/automations/draft/automation-draft-prompt.d.ts +26 -0
- package/dist/src/automations/draft/automation-draft-prompt.js +127 -0
- package/dist/src/automations/draft/automation-draft-prompt.js.map +1 -0
- package/dist/src/automations/draft/automation-draft-service.d.ts +12 -0
- package/dist/src/automations/draft/automation-draft-service.js +135 -0
- package/dist/src/automations/draft/automation-draft-service.js.map +1 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +99 -0
- package/dist/src/automations/draft/automation-draft-validator.js +105 -0
- package/dist/src/automations/draft/automation-draft-validator.js.map +1 -0
- package/dist/src/automations/draft/automation-draft.types.d.ts +40 -0
- package/dist/src/automations/draft/index.d.ts +3 -0
- package/dist/src/automations/draft/index.js +3 -0
- package/dist/src/automations/index.d.ts +3 -0
- package/dist/src/automations/index.js +8 -0
- package/dist/src/automations/product-events.d.ts +5 -0
- package/dist/src/automations/product-events.js +21 -0
- package/dist/src/automations/product-events.js.map +1 -0
- package/dist/src/automations/service/action-executor.d.ts +9 -0
- package/dist/src/automations/service/action-executor.js +157 -0
- package/dist/src/automations/service/action-executor.js.map +1 -0
- package/dist/src/automations/service/automation-service.d.ts +54 -0
- package/dist/src/automations/service/automation-service.js +404 -0
- package/dist/src/automations/service/automation-service.js.map +1 -0
- package/dist/src/automations/service/index.d.ts +2 -0
- package/dist/src/automations/service/index.js +3 -0
- package/dist/src/automations/storage/automation-repository.d.ts +6 -0
- package/dist/src/automations/storage/automation-repository.js +61 -0
- package/dist/src/automations/storage/automation-repository.js.map +1 -0
- package/dist/src/automations/storage/automation-run-repository.d.ts +17 -0
- package/dist/src/automations/storage/automation-run-repository.js +130 -0
- package/dist/src/automations/storage/automation-run-repository.js.map +1 -0
- package/dist/src/automations/storage/index.d.ts +2 -0
- package/dist/src/automations/storage/index.js +3 -0
- package/dist/src/channels/pipeline.d.ts +1 -1
- package/dist/src/channels/pipeline.js.map +1 -1
- package/dist/src/channels/plugin-types.d.ts +3 -0
- package/dist/src/chat-commands/agent-edit.js +0 -1
- package/dist/src/chat-commands/agent-edit.js.map +1 -1
- package/dist/src/chat-commands/builtins/model.js +2 -2
- package/dist/src/chat-commands/builtins/model.js.map +1 -1
- package/dist/src/chat-commands/builtins/thinking.js.map +1 -1
- package/dist/src/cli/command-catalog.js +0 -39
- package/dist/src/cli/command-catalog.js.map +1 -1
- package/dist/src/cli/command-loaders.js +0 -1
- package/dist/src/cli/command-loaders.js.map +1 -1
- package/dist/src/cli/command-manifest.d.ts +1 -1
- package/dist/src/cli/command-manifest.js +1 -5
- package/dist/src/cli/command-manifest.js.map +1 -1
- package/dist/src/cli/commands/agents.js +7 -6
- package/dist/src/cli/commands/agents.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/{cron-health.d.ts → migrations.d.ts} +1 -1
- package/dist/src/cli/commands/doctor/checks/migrations.js +40 -0
- package/dist/src/cli/commands/doctor/checks/migrations.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -0
- package/dist/src/cli/commands/doctor/checks/provider-auth.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/workspace-status.js +0 -1
- package/dist/src/cli/commands/doctor/checks/workspace-status.js.map +1 -1
- package/dist/src/cli/commands/doctor/flow.js +2 -2
- package/dist/src/cli/commands/doctor/flow.js.map +1 -1
- package/dist/src/cli/commands/gateway/call.js +2 -2
- package/dist/src/cli/commands/gateway/call.js.map +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/gateway/run-foreground.js +4 -2
- package/dist/src/cli/commands/gateway/run-foreground.js.map +1 -1
- package/dist/src/cli/commands/init.js +33 -14
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/commands/models.js +13 -31
- package/dist/src/cli/commands/models.js.map +1 -1
- package/dist/src/cli/commands/onboard/model.js +17 -10
- package/dist/src/cli/commands/onboard/model.js.map +1 -1
- package/dist/src/cli/commands/onboard.js +2 -2
- package/dist/src/cli/commands/onboard.js.map +1 -1
- package/dist/src/cli/commands/tui.js +26 -4
- package/dist/src/cli/commands/tui.js.map +1 -1
- package/dist/src/cli/index.d.ts +1 -0
- package/dist/src/cli/index.js +10 -5
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/cli/registry.js +1 -1
- package/dist/src/cli/registry.js.map +1 -1
- package/dist/src/cli/templates.d.ts +1 -1
- package/dist/src/cli/templates.js +1 -11
- package/dist/src/cli/templates.js.map +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +2 -0
- package/dist/src/cli/utils/init-workspace-core.js.map +1 -1
- package/dist/src/commands/agents.config.d.ts +9 -0
- package/dist/src/commands/agents.config.js +42 -12
- package/dist/src/commands/agents.config.js.map +1 -1
- package/dist/src/config/agent-profile.js +5 -3
- package/dist/src/config/agent-profile.js.map +1 -1
- package/dist/src/config/agent-typed-models.js +3 -5
- package/dist/src/config/agent-typed-models.js.map +1 -1
- package/dist/src/config/config-surface.d.ts +3 -0
- package/dist/src/config/index.d.ts +0 -1
- package/dist/src/config/index.js +3 -3
- package/dist/src/config/index.js.map +1 -1
- package/dist/src/config/paths.d.ts +8 -10
- package/dist/src/config/paths.js +16 -16
- package/dist/src/config/paths.js.map +1 -1
- package/dist/src/config/profile.js +0 -1
- package/dist/src/config/profile.js.map +1 -1
- package/dist/src/config/rules.js +0 -5
- package/dist/src/config/rules.js.map +1 -1
- package/dist/src/config/schema.d.ts +45 -44
- package/dist/src/config/schema.js +68 -52
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/config/web-patch.d.ts +0 -12
- package/dist/src/config/web-patch.js +2 -29
- package/dist/src/config/web-patch.js.map +1 -1
- package/dist/src/extensions/api.d.ts +2 -0
- package/dist/src/extensions/api.js +10 -0
- package/dist/src/extensions/api.js.map +1 -1
- package/dist/src/extensions/extension-registry-impl.d.ts +4 -1
- package/dist/src/extensions/extension-registry-impl.js +8 -0
- package/dist/src/extensions/extension-registry-impl.js.map +1 -1
- package/dist/src/extensions/loader.d.ts +3 -3
- package/dist/src/extensions/loader.js +3 -3
- package/dist/src/extensions/loader.js.map +1 -1
- package/dist/src/extensions/sdk/testing.d.ts +2 -0
- package/dist/src/extensions/sdk/testing.js +7 -0
- package/dist/src/extensions/sdk/testing.js.map +1 -1
- package/dist/src/extensions/types/core.d.ts +10 -1
- package/dist/src/extensions/types/index.d.ts +1 -1
- package/dist/src/extensions/types/{phase4.d.ts → registration.d.ts} +2 -2
- package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
- package/dist/src/gateway/agent-builtin-tools.js +1 -1
- package/dist/src/gateway/agent-builtin-tools.js.map +1 -1
- package/dist/src/gateway/agents-admin.d.ts +8 -0
- package/dist/src/gateway/agents-admin.js +63 -34
- package/dist/src/gateway/agents-admin.js.map +1 -1
- package/dist/src/gateway/capability-presets-admin.d.ts +1 -0
- package/dist/src/gateway/capability-presets-admin.js +19 -10
- package/dist/src/gateway/capability-presets-admin.js.map +1 -1
- package/dist/src/gateway/chat-stream/mapper.js +9 -2
- package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
- package/dist/src/gateway/dreaming-automation-reconciler.d.ts +11 -0
- package/dist/src/gateway/dreaming-automation-reconciler.js +105 -0
- package/dist/src/gateway/dreaming-automation-reconciler.js.map +1 -0
- package/dist/src/gateway/global-defaults-admin.d.ts +36 -0
- package/dist/src/gateway/global-defaults-admin.js +146 -0
- package/dist/src/gateway/global-defaults-admin.js.map +1 -0
- package/dist/src/gateway/heartbeat/service.d.ts +0 -2
- package/dist/src/gateway/heartbeat/service.js +0 -7
- package/dist/src/gateway/heartbeat/service.js.map +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +5 -6
- package/dist/src/gateway/hono/lib/config-payload.js +2 -2
- package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
- package/dist/src/gateway/hono/routes/agents.js +33 -1
- package/dist/src/gateway/hono/routes/agents.js.map +1 -1
- package/dist/src/gateway/hono/routes/commands-skills.js +4 -5
- package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.d.ts +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +12 -6
- package/dist/src/gateway/hono/routes/config-patch/misc.js.map +1 -1
- package/dist/src/gateway/hono/routes/dreaming.js +27 -37
- package/dist/src/gateway/hono/routes/dreaming.js.map +1 -1
- package/dist/src/gateway/hono/routes/global-defaults.d.ts +3 -0
- package/dist/src/gateway/hono/routes/global-defaults.js +61 -0
- package/dist/src/gateway/hono/routes/global-defaults.js.map +1 -0
- package/dist/src/gateway/hono/routes/home.d.ts +2 -2
- package/dist/src/gateway/hono/routes/home.js +34 -25
- package/dist/src/gateway/hono/routes/home.js.map +1 -1
- package/dist/src/gateway/hono/routes/lazy-bundles.js +21 -9
- package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
- package/dist/src/gateway/hono/routes/memory.js +75 -4
- package/dist/src/gateway/hono/routes/memory.js.map +1 -1
- package/dist/src/gateway/hono/routes/migrations.d.ts +3 -0
- package/dist/src/gateway/hono/routes/migrations.js +35 -0
- package/dist/src/gateway/hono/routes/migrations.js.map +1 -0
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/public-gateway.js +2 -1
- package/dist/src/gateway/hono/routes/public-gateway.js.map +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +14 -0
- package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
- package/dist/src/gateway/run-loop.js +2 -0
- package/dist/src/gateway/run-loop.js.map +1 -1
- package/dist/src/gateway/security/operator-scopes.js +5 -1
- package/dist/src/gateway/security/operator-scopes.js.map +1 -1
- package/dist/src/gateway/service/config-coordinator.d.ts +4 -4
- package/dist/src/gateway/service/config-coordinator.js +14 -8
- package/dist/src/gateway/service/config-coordinator.js.map +1 -1
- package/dist/src/gateway/service/marketplace-service.d.ts +4 -4
- package/dist/src/gateway/service/marketplace-service.js +11 -7
- package/dist/src/gateway/service/marketplace-service.js.map +1 -1
- package/dist/src/gateway/service/sessions-api.d.ts +2 -1
- package/dist/src/gateway/service/sessions-api.js +6 -1
- package/dist/src/gateway/service/sessions-api.js.map +1 -1
- package/dist/src/gateway/service.d.ts +7 -3
- package/dist/src/gateway/service.js +61 -27
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/goals/goal-service.js +45 -4
- package/dist/src/goals/goal-service.js.map +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/migrations/config/default-capability-preset.d.ts +10 -0
- package/dist/src/migrations/config/default-capability-preset.js +135 -0
- package/dist/src/migrations/config/default-capability-preset.js.map +1 -0
- package/dist/src/migrations/index.d.ts +4 -0
- package/dist/src/migrations/index.js +4 -0
- package/dist/src/migrations/registry.d.ts +8 -0
- package/dist/src/migrations/registry.js +18 -0
- package/dist/src/migrations/registry.js.map +1 -0
- package/dist/src/migrations/runner.d.ts +17 -0
- package/dist/src/migrations/runner.js +191 -0
- package/dist/src/migrations/runner.js.map +1 -0
- package/dist/src/migrations/types.d.ts +34 -0
- package/dist/src/notes/service.js +27 -2
- package/dist/src/notes/service.js.map +1 -1
- package/dist/src/providers/index.d.ts +4 -5
- package/dist/src/providers/index.js +16 -16
- package/dist/src/providers/index.js.map +1 -1
- package/dist/src/providers/model-registry.d.ts +0 -1
- package/dist/src/providers/model-registry.js +0 -3
- package/dist/src/providers/model-registry.js.map +1 -1
- package/dist/src/routing/resolve-tui-session-key.d.ts +3 -0
- package/dist/src/routing/resolve-tui-session-key.js +14 -3
- package/dist/src/routing/resolve-tui-session-key.js.map +1 -1
- package/dist/src/session/session-workspace.js +2 -7
- package/dist/src/session/session-workspace.js.map +1 -1
- package/dist/src/session/store.js +0 -5
- package/dist/src/session/store.js.map +1 -1
- package/dist/src/session/transcript-outline.d.ts +47 -0
- package/dist/src/session/transcript-outline.js +481 -0
- package/dist/src/session/transcript-outline.js.map +1 -0
- package/dist/src/storage/sqlite/index.d.ts +1 -3
- package/dist/src/storage/sqlite/index.js +2 -4
- package/dist/src/storage/sqlite/memory-index-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/memory-index-repository.js +15 -14
- package/dist/src/storage/sqlite/memory-index-repository.js.map +1 -1
- package/dist/src/storage/sqlite/memory-records-repository.d.ts +44 -1
- package/dist/src/storage/sqlite/memory-records-repository.js +164 -20
- package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/014_memory_record_governance.sql +10 -0
- package/dist/src/storage/sqlite/migrations/015_memory_trace_feedback.sql +4 -0
- package/dist/src/storage/sqlite/migrations/016_automations.sql +47 -0
- package/dist/src/storage/sqlite/migrations/017_automation_run_events.sql +14 -0
- package/dist/src/storage/sqlite/migrations/018_automation_safety.sql +1 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +56 -46
- package/dist/src/tui/backends/embedded-backend.d.ts +9 -0
- package/dist/src/tui/backends/embedded-backend.js +55 -27
- package/dist/src/tui/backends/embedded-backend.js.map +1 -1
- package/dist/src/tui/backends/gateway-sse-backend.d.ts +4 -0
- package/dist/src/tui/backends/gateway-sse-backend.js +30 -3
- package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
- package/dist/src/tui/components/tui-header.d.ts +0 -1
- package/dist/src/tui/components/tui-header.js +3 -8
- package/dist/src/tui/components/tui-header.js.map +1 -1
- package/dist/src/tui/tui-backend.d.ts +4 -0
- package/dist/src/tui/tui-commands.d.ts +5 -0
- package/dist/src/tui/tui-commands.js +43 -0
- package/dist/src/tui/tui-commands.js.map +1 -1
- package/dist/src/tui/tui-startup-resources.js +2 -1
- package/dist/src/tui/tui-startup-resources.js.map +1 -1
- package/dist/src/tui/tui-startup-text.js +12 -12
- package/dist/src/tui/tui-startup-text.js.map +1 -1
- package/dist/src/tui/tui-transcript-tree.d.ts +1 -1
- package/dist/src/tui/tui-transcript-tree.js +17 -257
- package/dist/src/tui/tui-transcript-tree.js.map +1 -1
- package/dist/src/tui/tui-types.d.ts +2 -0
- package/dist/src/tui/tui-types.js.map +1 -1
- package/dist/src/tui/tui.js +11 -3
- package/dist/src/tui/tui.js.map +1 -1
- package/dist/src/workflows/domain/index.js +1 -1
- package/dist/src/workflows/domain/run.d.ts +7 -7
- package/dist/src/workflows/domain/run.js.map +1 -1
- package/dist/src/workflows/index.js +2 -2
- package/dist/src/workflows/service/workflow-run-service.d.ts +2 -0
- package/dist/src/workflows/service/workflow-run-service.js +31 -9
- package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
- package/dist/src/workflows/service/workflow-run-service.types.d.ts +1 -1
- package/package.json +4 -2
- package/dist/gateway/static/root/assets/agents-C6xgagZd.js +0 -71
- package/dist/gateway/static/root/assets/app-management-settings-panel-CBpLONvG.js +0 -1
- package/dist/gateway/static/root/assets/appearance-settings-CGcc54yj.js +0 -1
- package/dist/gateway/static/root/assets/browser-settings-page-CUOO-PQk.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-api-XQoMTI0A.js +0 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-CfqF-kGr.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-BYyRzsex.js +0 -1
- package/dist/gateway/static/root/assets/cn-JdwAhgNB.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DIvEz4NX.js +0 -2
- package/dist/gateway/static/root/assets/createLucideIcon-DPHK1VkS.js +0 -1
- package/dist/gateway/static/root/assets/cron-api-R41aQCX9.js +0 -1
- package/dist/gateway/static/root/assets/cron-dreaming-jobs-nCMWCf0p.js +0 -1
- package/dist/gateway/static/root/assets/cron-page-D97nFqQD.js +0 -3
- package/dist/gateway/static/root/assets/dreaming-settings-Bceaw1PG.js +0 -1
- package/dist/gateway/static/root/assets/format-cron-label-BsotZDO5.js +0 -2
- package/dist/gateway/static/root/assets/format-interval-label-Dn_QKIqb.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-iISWAZRm.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DCUROLMQ.js +0 -1
- package/dist/gateway/static/root/assets/goals-settings-CPAuFwoD.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-config-api-D7bKFEeO.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-CC69vNx0.js +0 -1
- package/dist/gateway/static/root/assets/index-CwhK8qCh.js +0 -122
- package/dist/gateway/static/root/assets/index-CyfhARL-.css +0 -1
- package/dist/gateway/static/root/assets/interval-presets-0DtsnxE0.js +0 -1
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-BPREtN8B.js +0 -1
- package/dist/gateway/static/root/assets/messages-Cf1O9JB0.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-DmKiIihT.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-page-CxxfLRJZ.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-X2slSx7V.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BvmUWqgu.js +0 -1
- package/dist/gateway/static/root/assets/schedule-field-CgJSCD3B.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-B0yESuuL.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-q2M8RKOo.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-CGozabLD.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-FoOSe6nU.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-Cy5zWyYQ.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DaZNFro9.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CnwtUzvw.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-DXs2VmBt.js +0 -1
- package/dist/gateway/static/root/assets/typed-models-lib-4gPuydz_.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-DvKiOglO.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-CAVZcONQ.js +0 -18
- package/dist/src/agent/context/workspace-templates/USER.md +0 -24
- package/dist/src/agent/fallback/error.d.ts +0 -22
- package/dist/src/agent/fallback/error.js +0 -32
- package/dist/src/agent/fallback/error.js.map +0 -1
- package/dist/src/agent/fallback/index.d.ts +0 -5
- package/dist/src/agent/fallback/index.js +0 -9
- package/dist/src/agent/fallback/index.js.map +0 -1
- package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.d.ts +0 -29
- package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.js +0 -76
- package/dist/src/agent/orchestration/run-agent-turn-with-fallbacks.js.map +0 -1
- package/dist/src/agent/service/reconcile-dreaming-cron.d.ts +0 -6
- package/dist/src/agent/service/reconcile-dreaming-cron.js +0 -84
- package/dist/src/agent/service/reconcile-dreaming-cron.js.map +0 -1
- package/dist/src/agent/tools/cronjob-tool.d.ts +0 -29
- package/dist/src/agent/tools/cronjob-tool.js +0 -274
- package/dist/src/agent/tools/cronjob-tool.js.map +0 -1
- package/dist/src/cli/commands/cron-cli.d.ts +0 -2
- package/dist/src/cli/commands/cron-cli.js +0 -15
- package/dist/src/cli/commands/cron-cli.js.map +0 -1
- package/dist/src/cli/commands/cron.d.ts +0 -4
- package/dist/src/cli/commands/cron.js +0 -188
- package/dist/src/cli/commands/cron.js.map +0 -1
- package/dist/src/cli/commands/doctor/checks/cron-health.js +0 -35
- package/dist/src/cli/commands/doctor/checks/cron-health.js.map +0 -1
- package/dist/src/cron/execution-types.d.ts +0 -42
- package/dist/src/cron/executor.d.ts +0 -67
- package/dist/src/cron/executor.js +0 -669
- package/dist/src/cron/executor.js.map +0 -1
- package/dist/src/cron/index.d.ts +0 -7
- package/dist/src/cron/index.js +0 -7
- package/dist/src/cron/job-content.d.ts +0 -5
- package/dist/src/cron/job-content.js +0 -15
- package/dist/src/cron/job-content.js.map +0 -1
- package/dist/src/cron/run-log-store.d.ts +0 -12
- package/dist/src/cron/run-log-store.js +0 -58
- package/dist/src/cron/run-log-store.js.map +0 -1
- package/dist/src/cron/schedule.d.ts +0 -10
- package/dist/src/cron/schedule.js +0 -85
- package/dist/src/cron/schedule.js.map +0 -1
- package/dist/src/cron/service.d.ts +0 -58
- package/dist/src/cron/service.js +0 -419
- package/dist/src/cron/service.js.map +0 -1
- package/dist/src/cron/types.d.ts +0 -183
- package/dist/src/cron/validation.d.ts +0 -500
- package/dist/src/cron/validation.js +0 -192
- package/dist/src/cron/validation.js.map +0 -1
- package/dist/src/cron/workflow-run-completion.d.ts +0 -23
- package/dist/src/cron/workflow-run-completion.js +0 -72
- package/dist/src/cron/workflow-run-completion.js.map +0 -1
- package/dist/src/extensions/types/phase4.js +0 -1
- package/dist/src/gateway/hono/routes/cron.d.ts +0 -3
- package/dist/src/gateway/hono/routes/cron.js +0 -109
- package/dist/src/gateway/hono/routes/cron.js.map +0 -1
- package/dist/src/storage/sqlite/cron-job-repository.d.ts +0 -6
- package/dist/src/storage/sqlite/cron-job-repository.js +0 -70
- package/dist/src/storage/sqlite/cron-job-repository.js.map +0 -1
- package/dist/src/storage/sqlite/cron-run-repository.d.ts +0 -5
- package/dist/src/storage/sqlite/cron-run-repository.js +0 -96
- package/dist/src/storage/sqlite/cron-run-repository.js.map +0 -1
- /package/dist/src/{cron → automations/domain}/types.js +0 -0
- /package/dist/src/{config/defaults.d.ts → automations/draft/automation-draft.types.js} +0 -0
- /package/dist/src/{config/defaults.js → extensions/types/registration.js} +0 -0
- /package/dist/src/{cron/execution-types.js → migrations/types.js} +0 -0
|
@@ -1,669 +0,0 @@
|
|
|
1
|
-
import { init_agent_scope, normalizeAgentId } from "../agent/agent-scope.js";
|
|
2
|
-
import { buildSessionKey, init_session_key } from "../routing/session-key.js";
|
|
3
|
-
import { createLogger } from "../utils/logger/index.js";
|
|
4
|
-
import { init_logger } from "../utils/logger.js";
|
|
5
|
-
import { shouldSilence, stripHeartbeatToken } from "../heartbeat/tokens.js";
|
|
6
|
-
import { getChannelPlugin } from "../channels/plugins/registry.js";
|
|
7
|
-
import { getCronPayloadText } from "./job-content.js";
|
|
8
|
-
import { buildWorkflowRunCronSummary, buildWorkflowRunDeliveryText, isWorkflowRunCronSuccess, resolveWorkflowCronWaitMs, waitForWorkflowRunView } from "./workflow-run-completion.js";
|
|
9
|
-
//#region src/cron/executor.ts
|
|
10
|
-
init_logger();
|
|
11
|
-
init_agent_scope();
|
|
12
|
-
init_session_key();
|
|
13
|
-
const log = createLogger("CronExecutor");
|
|
14
|
-
const ERROR_BACKOFF_MS = [
|
|
15
|
-
3e4,
|
|
16
|
-
6e4,
|
|
17
|
-
5 * 6e4,
|
|
18
|
-
15 * 6e4,
|
|
19
|
-
60 * 6e4
|
|
20
|
-
];
|
|
21
|
-
function errorBackoffMs(consecutiveErrors) {
|
|
22
|
-
const idx = Math.min(consecutiveErrors - 1, ERROR_BACKOFF_MS.length - 1);
|
|
23
|
-
return ERROR_BACKOFF_MS[Math.max(0, idx)];
|
|
24
|
-
}
|
|
25
|
-
function resolveIsolatedCronJobModel(job) {
|
|
26
|
-
if (job.payload?.kind === "agentTurn") {
|
|
27
|
-
const m = job.payload.model?.trim();
|
|
28
|
-
if (m) return m;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
async function postCronWebhook(url, payload) {
|
|
32
|
-
const res = await fetch(url, {
|
|
33
|
-
method: "POST",
|
|
34
|
-
headers: { "content-type": "application/json" },
|
|
35
|
-
body: JSON.stringify(payload)
|
|
36
|
-
});
|
|
37
|
-
if (!res.ok) {
|
|
38
|
-
const text = await res.text().catch(() => "");
|
|
39
|
-
throw new Error(`Webhook delivery failed: HTTP ${res.status}${text ? ` ${text.slice(0, 200)}` : ""}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
var DefaultJobExecutor = class {
|
|
43
|
-
history = /* @__PURE__ */ new Map();
|
|
44
|
-
runningJobs = /* @__PURE__ */ new Map();
|
|
45
|
-
agentService = null;
|
|
46
|
-
messageBus = null;
|
|
47
|
-
heartbeatService = null;
|
|
48
|
-
sessionStore;
|
|
49
|
-
runLogStore = null;
|
|
50
|
-
getDefaultCronAgentId = null;
|
|
51
|
-
workflowRunService = null;
|
|
52
|
-
goalRunner = null;
|
|
53
|
-
setRunLogStore(store) {
|
|
54
|
-
this.runLogStore = store;
|
|
55
|
-
}
|
|
56
|
-
setDeps(deps) {
|
|
57
|
-
this.agentService = deps.agentService;
|
|
58
|
-
this.messageBus = deps.messageBus;
|
|
59
|
-
this.heartbeatService = deps.heartbeatService ?? null;
|
|
60
|
-
if (deps.sessionStore !== void 0) this.sessionStore = deps.sessionStore;
|
|
61
|
-
this.getDefaultCronAgentId = deps.getDefaultCronAgentId ?? null;
|
|
62
|
-
this.workflowRunService = deps.workflowRunService ?? null;
|
|
63
|
-
this.goalRunner = deps.goalRunner ?? null;
|
|
64
|
-
}
|
|
65
|
-
async buildCronOutboundMessage(channel, to, content) {
|
|
66
|
-
const plugin = getChannelPlugin(channel);
|
|
67
|
-
if (plugin?.cronDelivery) {
|
|
68
|
-
const { chatId, accountId, metadata } = await plugin.cronDelivery.normalizeDeliveryTarget(to, this.sessionStore);
|
|
69
|
-
const meta = accountId || metadata ? {
|
|
70
|
-
...metadata ?? {},
|
|
71
|
-
...accountId ? { accountId } : {}
|
|
72
|
-
} : void 0;
|
|
73
|
-
return {
|
|
74
|
-
channel,
|
|
75
|
-
chat_id: chatId,
|
|
76
|
-
content,
|
|
77
|
-
type: "message",
|
|
78
|
-
...meta && Object.keys(meta).length > 0 ? { metadata: meta } : {}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
channel,
|
|
83
|
-
chat_id: to,
|
|
84
|
-
content,
|
|
85
|
-
type: "message"
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
async execute(job, signal, deps) {
|
|
89
|
-
if (deps) this.setDeps(deps);
|
|
90
|
-
const executionId = crypto.randomUUID();
|
|
91
|
-
const execution = {
|
|
92
|
-
id: executionId,
|
|
93
|
-
jobId: job.id,
|
|
94
|
-
status: "running",
|
|
95
|
-
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
96
|
-
retryCount: 0,
|
|
97
|
-
sessionId: job.sessionKey,
|
|
98
|
-
sessionKey: job.sessionKey,
|
|
99
|
-
sessionType: job.sessionKey ? "cron" : void 0
|
|
100
|
-
};
|
|
101
|
-
this.addToHistory(job.id, execution);
|
|
102
|
-
if (this.runLogStore) await this.runLogStore.upsert(execution);
|
|
103
|
-
this.runningJobs.set(job.id, new AbortController());
|
|
104
|
-
log.info({
|
|
105
|
-
jobId: job.id,
|
|
106
|
-
executionId,
|
|
107
|
-
preview: getCronPayloadText(job).slice(0, 100)
|
|
108
|
-
}, "Job executing");
|
|
109
|
-
let result;
|
|
110
|
-
try {
|
|
111
|
-
if (signal.aborted) throw new Error("Job was cancelled before execution");
|
|
112
|
-
result = await this.performJob(job, signal);
|
|
113
|
-
execution.status = result.status === "ok" ? "success" : result.status === "skipped" ? "cancelled" : "failed";
|
|
114
|
-
execution.endedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
115
|
-
execution.duration = Date.now() - new Date(execution.startedAt).getTime();
|
|
116
|
-
execution.summary = result.summary;
|
|
117
|
-
execution.error = result.error;
|
|
118
|
-
execution.sessionId = result.sessionId;
|
|
119
|
-
execution.sessionKey = result.sessionKey;
|
|
120
|
-
execution.sessionType = result.sessionType;
|
|
121
|
-
execution.model = result.model;
|
|
122
|
-
execution.workflowRunId = result.workflowRunId;
|
|
123
|
-
if (result.status === "ok") log.info({
|
|
124
|
-
jobId: job.id,
|
|
125
|
-
executionId,
|
|
126
|
-
duration: execution.duration
|
|
127
|
-
}, "Job completed");
|
|
128
|
-
else if (result.status === "skipped") log.warn({
|
|
129
|
-
jobId: job.id,
|
|
130
|
-
executionId,
|
|
131
|
-
reason: result.error
|
|
132
|
-
}, "Job skipped");
|
|
133
|
-
else log.error({
|
|
134
|
-
jobId: job.id,
|
|
135
|
-
executionId,
|
|
136
|
-
errorMessage: result.error,
|
|
137
|
-
phase: "cron.execute"
|
|
138
|
-
}, `Job failed: ${result.error ?? "unknown"}`);
|
|
139
|
-
if (result.status === "ok" && job.wakeMode === "next-heartbeat" && this.heartbeatService) try {
|
|
140
|
-
this.heartbeatService.requestNow({ reason: `cron:${job.id}` });
|
|
141
|
-
} catch (e) {
|
|
142
|
-
log.warn({
|
|
143
|
-
jobId: job.id,
|
|
144
|
-
err: e
|
|
145
|
-
}, "Heartbeat wake after cron failed");
|
|
146
|
-
}
|
|
147
|
-
} catch (error) {
|
|
148
|
-
execution.status = "failed";
|
|
149
|
-
execution.endedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
150
|
-
execution.duration = Date.now() - new Date(execution.startedAt).getTime();
|
|
151
|
-
execution.error = error instanceof Error ? error.message : String(error);
|
|
152
|
-
log.error({
|
|
153
|
-
err: error,
|
|
154
|
-
errorMessage: execution.error,
|
|
155
|
-
jobId: job.id,
|
|
156
|
-
executionId,
|
|
157
|
-
phase: "cron.execute"
|
|
158
|
-
}, `Job execution error: ${execution.error}`);
|
|
159
|
-
result = {
|
|
160
|
-
status: "error",
|
|
161
|
-
error: execution.error
|
|
162
|
-
};
|
|
163
|
-
} finally {
|
|
164
|
-
this.runningJobs.delete(job.id);
|
|
165
|
-
}
|
|
166
|
-
if (this.runLogStore) await this.runLogStore.upsert(execution);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Perform the actual job work - integrate with AgentService
|
|
170
|
-
*/
|
|
171
|
-
async performJob(job, signal) {
|
|
172
|
-
const timeout = job.payload.kind === "agentTurn" && job.payload.timeoutSeconds ? job.payload.timeoutSeconds * 1e3 : 18e4;
|
|
173
|
-
const sessionTarget = job.sessionTarget;
|
|
174
|
-
if (signal.aborted) return {
|
|
175
|
-
status: "skipped",
|
|
176
|
-
error: "Job was aborted before execution"
|
|
177
|
-
};
|
|
178
|
-
try {
|
|
179
|
-
if (job.payload.kind === "goalContinue") return await this.executeGoalContinue(job);
|
|
180
|
-
if (job.payload.kind === "workflowRun") return await this.executeWorkflowRun(job, signal);
|
|
181
|
-
if (!this.agentService || !this.messageBus) {
|
|
182
|
-
log.warn({ jobId: job.id }, "No agent service configured, using basic execution");
|
|
183
|
-
return this.basicExecute(job, signal, timeout);
|
|
184
|
-
}
|
|
185
|
-
if (sessionTarget === "main") return await this.executeMainSession(job, signal, timeout);
|
|
186
|
-
else return await this.executeIsolated(job, signal, timeout);
|
|
187
|
-
} catch (error) {
|
|
188
|
-
return {
|
|
189
|
-
status: "error",
|
|
190
|
-
error: error instanceof Error ? error.message : String(error)
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
async executeGoalContinue(job) {
|
|
195
|
-
if (job.payload.kind !== "goalContinue") return {
|
|
196
|
-
status: "error",
|
|
197
|
-
error: "Cron job payload is not goalContinue"
|
|
198
|
-
};
|
|
199
|
-
if (!this.goalRunner) return {
|
|
200
|
-
status: "error",
|
|
201
|
-
error: "Goal runner is not configured for cron"
|
|
202
|
-
};
|
|
203
|
-
const item = this.goalRunner.enqueue(job.payload.goalId, {
|
|
204
|
-
message: job.payload.message,
|
|
205
|
-
maxRetries: job.payload.maxRetries ?? 0,
|
|
206
|
-
source: "cron"
|
|
207
|
-
});
|
|
208
|
-
return {
|
|
209
|
-
status: "ok",
|
|
210
|
-
summary: `Queued goal ${job.payload.goalId} (${item.status})`,
|
|
211
|
-
sessionId: item.sessionKey,
|
|
212
|
-
sessionKey: item.sessionKey,
|
|
213
|
-
sessionType: "goal"
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
async executeWorkflowRun(job, signal) {
|
|
217
|
-
if (signal.aborted) return {
|
|
218
|
-
status: "skipped",
|
|
219
|
-
error: "Job was aborted before workflow run start"
|
|
220
|
-
};
|
|
221
|
-
if (job.payload.kind !== "workflowRun") return {
|
|
222
|
-
status: "error",
|
|
223
|
-
error: "Cron job payload is not workflowRun"
|
|
224
|
-
};
|
|
225
|
-
if (!this.workflowRunService) return {
|
|
226
|
-
status: "error",
|
|
227
|
-
error: "Workflow run service is not configured for cron"
|
|
228
|
-
};
|
|
229
|
-
const fallbackAgentId = this.getDefaultCronAgentId?.() ?? "main";
|
|
230
|
-
const agentId = normalizeAgentId(job.payload.agentId || job.agentId || fallbackAgentId);
|
|
231
|
-
const fireId = job.payload.source?.fireId || crypto.randomUUID();
|
|
232
|
-
const source = {
|
|
233
|
-
kind: "cron",
|
|
234
|
-
scheduleId: job.payload.source?.scheduleId || job.id,
|
|
235
|
-
fireId,
|
|
236
|
-
scheduledAtMs: job.payload.source?.scheduledAtMs ?? Date.now()
|
|
237
|
-
};
|
|
238
|
-
const result = await this.workflowRunService.startWorkflowRun({
|
|
239
|
-
agentId,
|
|
240
|
-
definitionId: job.payload.definitionId,
|
|
241
|
-
input: job.payload.input,
|
|
242
|
-
inputEnvelope: job.payload.inputEnvelope,
|
|
243
|
-
goal: job.payload.goal,
|
|
244
|
-
source,
|
|
245
|
-
idempotencyKey: `cron:${job.id}:${fireId}`
|
|
246
|
-
});
|
|
247
|
-
if (result.ok === false) return {
|
|
248
|
-
status: "error",
|
|
249
|
-
error: result.message
|
|
250
|
-
};
|
|
251
|
-
log.info({
|
|
252
|
-
jobId: job.id,
|
|
253
|
-
workflowRunId: result.runId,
|
|
254
|
-
definitionId: job.payload.definitionId,
|
|
255
|
-
sessionKey: result.sessionKey
|
|
256
|
-
}, "Workflow run started from cron");
|
|
257
|
-
if (!(job.payload.waitForCompletion !== false) || !this.workflowRunService.readWorkflowRunView) return {
|
|
258
|
-
status: "ok",
|
|
259
|
-
summary: `Started workflow run ${result.runId}`,
|
|
260
|
-
sessionId: result.sessionKey,
|
|
261
|
-
sessionKey: result.sessionKey,
|
|
262
|
-
sessionType: "workflow",
|
|
263
|
-
workflowRunId: result.runId
|
|
264
|
-
};
|
|
265
|
-
return this.waitForWorkflowRunOutcome({
|
|
266
|
-
job,
|
|
267
|
-
agentId,
|
|
268
|
-
sessionKey: result.sessionKey,
|
|
269
|
-
initialRunId: result.runId,
|
|
270
|
-
signal
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
async waitForWorkflowRunOutcome(params) {
|
|
274
|
-
const waitMs = resolveWorkflowCronWaitMs(18e4);
|
|
275
|
-
const maxWorkflowRetries = params.job.payload.kind === "workflowRun" ? Math.max(0, Math.floor(params.job.payload.maxRetries ?? 0)) : 0;
|
|
276
|
-
let runId = params.initialRunId;
|
|
277
|
-
let attempt = 0;
|
|
278
|
-
while (attempt <= maxWorkflowRetries) {
|
|
279
|
-
const waitResult = await waitForWorkflowRunView({
|
|
280
|
-
readView: (id) => this.workflowRunService.readWorkflowRunView(params.agentId, id),
|
|
281
|
-
runId,
|
|
282
|
-
signal: params.signal,
|
|
283
|
-
timeoutMs: waitMs
|
|
284
|
-
});
|
|
285
|
-
if (waitResult.kind === "aborted") return {
|
|
286
|
-
status: "skipped",
|
|
287
|
-
error: "Job was aborted while waiting for workflow run"
|
|
288
|
-
};
|
|
289
|
-
if (waitResult.kind === "timeout") return {
|
|
290
|
-
status: "error",
|
|
291
|
-
error: `Workflow run ${runId} did not finish within ${waitMs}ms`,
|
|
292
|
-
summary: waitResult.lastView ? buildWorkflowRunCronSummary(waitResult.lastView) : void 0,
|
|
293
|
-
sessionId: params.sessionKey,
|
|
294
|
-
sessionKey: params.sessionKey,
|
|
295
|
-
sessionType: "workflow",
|
|
296
|
-
workflowRunId: runId
|
|
297
|
-
};
|
|
298
|
-
const view = waitResult.view;
|
|
299
|
-
const summary = buildWorkflowRunCronSummary(view);
|
|
300
|
-
if (isWorkflowRunCronSuccess(view)) {
|
|
301
|
-
const baseOutcome = {
|
|
302
|
-
status: "ok",
|
|
303
|
-
summary,
|
|
304
|
-
sessionId: params.sessionKey,
|
|
305
|
-
sessionKey: params.sessionKey,
|
|
306
|
-
sessionType: "workflow",
|
|
307
|
-
workflowRunId: runId
|
|
308
|
-
};
|
|
309
|
-
await this.deliverWorkflowRunOutcome(params.job, view, baseOutcome);
|
|
310
|
-
return baseOutcome;
|
|
311
|
-
}
|
|
312
|
-
if (!(attempt < maxWorkflowRetries && view.run.status === "failed" && Boolean(this.workflowRunService?.retryWorkflowRun))) return {
|
|
313
|
-
status: "error",
|
|
314
|
-
summary,
|
|
315
|
-
error: summary,
|
|
316
|
-
sessionId: params.sessionKey,
|
|
317
|
-
sessionKey: params.sessionKey,
|
|
318
|
-
sessionType: "workflow",
|
|
319
|
-
workflowRunId: runId
|
|
320
|
-
};
|
|
321
|
-
const retryResult = await this.workflowRunService.retryWorkflowRun({
|
|
322
|
-
agentId: params.agentId,
|
|
323
|
-
runId
|
|
324
|
-
});
|
|
325
|
-
if (retryResult.ok === false) return {
|
|
326
|
-
status: "error",
|
|
327
|
-
error: retryResult.message,
|
|
328
|
-
summary,
|
|
329
|
-
sessionId: params.sessionKey,
|
|
330
|
-
sessionKey: params.sessionKey,
|
|
331
|
-
sessionType: "workflow",
|
|
332
|
-
workflowRunId: runId
|
|
333
|
-
};
|
|
334
|
-
runId = retryResult.runId;
|
|
335
|
-
attempt += 1;
|
|
336
|
-
log.info({
|
|
337
|
-
jobId: params.job.id,
|
|
338
|
-
attempt,
|
|
339
|
-
workflowRunId: runId
|
|
340
|
-
}, "Retrying failed workflow run from cron");
|
|
341
|
-
}
|
|
342
|
-
return {
|
|
343
|
-
status: "error",
|
|
344
|
-
error: "Workflow run retries exhausted",
|
|
345
|
-
sessionId: params.sessionKey,
|
|
346
|
-
sessionKey: params.sessionKey,
|
|
347
|
-
sessionType: "workflow",
|
|
348
|
-
workflowRunId: runId
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
async deliverWorkflowRunOutcome(job, view, outcome) {
|
|
352
|
-
const delivery = job.delivery;
|
|
353
|
-
if (!delivery || delivery.mode === "none" || delivery.channel === "local" || !delivery.to?.trim()) return;
|
|
354
|
-
try {
|
|
355
|
-
const text = buildWorkflowRunDeliveryText(view);
|
|
356
|
-
if (delivery.mode === "webhook") {
|
|
357
|
-
await postCronWebhook(delivery.to, {
|
|
358
|
-
jobId: job.id,
|
|
359
|
-
jobName: job.name,
|
|
360
|
-
payloadKind: job.payload.kind,
|
|
361
|
-
workflowRunId: view.run.id,
|
|
362
|
-
status: view.run.status,
|
|
363
|
-
text,
|
|
364
|
-
run: view.run
|
|
365
|
-
});
|
|
366
|
-
log.info({
|
|
367
|
-
jobId: job.id,
|
|
368
|
-
workflowRunId: view.run.id
|
|
369
|
-
}, "Delivered workflow run webhook from cron");
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
if (!this.messageBus || !delivery.channel) return;
|
|
373
|
-
const outbound = await this.buildCronOutboundMessage(delivery.channel, delivery.to, text);
|
|
374
|
-
await this.messageBus.publishOutbound(outbound);
|
|
375
|
-
log.info({
|
|
376
|
-
jobId: job.id,
|
|
377
|
-
channel: delivery.channel,
|
|
378
|
-
to: outbound.chat_id,
|
|
379
|
-
workflowRunId: view.run.id
|
|
380
|
-
}, "Delivered workflow run result from cron");
|
|
381
|
-
} catch (err) {
|
|
382
|
-
const em = err instanceof Error ? err.message : String(err);
|
|
383
|
-
log.warn({
|
|
384
|
-
jobId: job.id,
|
|
385
|
-
err,
|
|
386
|
-
workflowRunId: view.run.id
|
|
387
|
-
}, `Workflow cron delivery failed: ${em}`);
|
|
388
|
-
if (outcome.status === "ok") outcome.summary = `${outcome.summary ?? ""} (delivery failed: ${em})`.trim();
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Execute in main session - sends system event
|
|
393
|
-
*/
|
|
394
|
-
async executeMainSession(job, signal, timeout) {
|
|
395
|
-
const text = getCronPayloadText(job);
|
|
396
|
-
if (!text || !text.trim()) return {
|
|
397
|
-
status: "skipped",
|
|
398
|
-
error: "Main session job requires non-empty message"
|
|
399
|
-
};
|
|
400
|
-
const delivery = job.delivery;
|
|
401
|
-
const channel = delivery?.channel ?? "local";
|
|
402
|
-
const to = delivery?.to ?? "";
|
|
403
|
-
const actualMessage = text;
|
|
404
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
405
|
-
setTimeout(() => reject(/* @__PURE__ */ new Error(`Job timed out after ${timeout}ms`)), timeout);
|
|
406
|
-
});
|
|
407
|
-
const executePromise = (async () => {
|
|
408
|
-
if (signal.aborted) throw new Error("Job was aborted");
|
|
409
|
-
if (!delivery || delivery.mode === "none" || channel === "local") {
|
|
410
|
-
log.info({
|
|
411
|
-
jobId: job.id,
|
|
412
|
-
messageLength: actualMessage.length
|
|
413
|
-
}, "Cron main session: no outbound publish");
|
|
414
|
-
return {
|
|
415
|
-
status: "ok",
|
|
416
|
-
summary: actualMessage.slice(0, 200)
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
if (delivery.mode === "webhook") {
|
|
420
|
-
if (!to.trim()) throw new Error("Webhook delivery requires delivery.to");
|
|
421
|
-
await postCronWebhook(to, {
|
|
422
|
-
jobId: job.id,
|
|
423
|
-
jobName: job.name,
|
|
424
|
-
payloadKind: job.payload.kind,
|
|
425
|
-
text: actualMessage
|
|
426
|
-
});
|
|
427
|
-
return {
|
|
428
|
-
status: "ok",
|
|
429
|
-
summary: actualMessage.slice(0, 200)
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
if (!this.messageBus) return {
|
|
433
|
-
status: "error",
|
|
434
|
-
error: "MessageBus not available"
|
|
435
|
-
};
|
|
436
|
-
const outbound = await this.buildCronOutboundMessage(channel, to, actualMessage);
|
|
437
|
-
await this.messageBus.publishOutbound(outbound);
|
|
438
|
-
log.info({
|
|
439
|
-
jobId: job.id,
|
|
440
|
-
channel,
|
|
441
|
-
to: outbound.chat_id,
|
|
442
|
-
messageLength: actualMessage.length
|
|
443
|
-
}, "Sent message to main session");
|
|
444
|
-
return {
|
|
445
|
-
status: "ok",
|
|
446
|
-
summary: actualMessage.slice(0, 200)
|
|
447
|
-
};
|
|
448
|
-
})();
|
|
449
|
-
return await Promise.race([executePromise, timeoutPromise]);
|
|
450
|
-
}
|
|
451
|
-
/**
|
|
452
|
-
* Execute in isolated mode - runs agent independently
|
|
453
|
-
*/
|
|
454
|
-
async executeIsolated(job, signal, timeout) {
|
|
455
|
-
const message = getCronPayloadText(job);
|
|
456
|
-
if (!message || !message.trim()) return {
|
|
457
|
-
status: "skipped",
|
|
458
|
-
error: "Isolated job requires non-empty message"
|
|
459
|
-
};
|
|
460
|
-
const explicitSessionKey = job.sessionTarget.startsWith("session:") ? job.sessionTarget.slice(8).trim() : job.sessionTarget === "current" ? job.sessionKey?.trim() : job.sessionTarget === "isolated" ? job.sessionKey?.trim() : void 0;
|
|
461
|
-
const aid = job.agentId?.trim();
|
|
462
|
-
const fallbackAgentId = this.getDefaultCronAgentId?.() ?? "main";
|
|
463
|
-
const sessionKey = explicitSessionKey || buildSessionKey({
|
|
464
|
-
agentId: normalizeAgentId(aid || fallbackAgentId),
|
|
465
|
-
source: "cron",
|
|
466
|
-
accountId: "default",
|
|
467
|
-
peerKind: "dm",
|
|
468
|
-
peerId: `${job.id}-${crypto.randomUUID().slice(0, 8)}`
|
|
469
|
-
});
|
|
470
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
471
|
-
setTimeout(() => reject(/* @__PURE__ */ new Error(`Job timed out after ${timeout}ms`)), timeout);
|
|
472
|
-
});
|
|
473
|
-
const executePromise = (async () => {
|
|
474
|
-
if (signal.aborted) throw new Error("Job was aborted");
|
|
475
|
-
await this.agentService.sessionConfig.applyCronJobWorkingDirectory(sessionKey, job.workingDirectory);
|
|
476
|
-
const jobModel = resolveIsolatedCronJobModel(job);
|
|
477
|
-
if (jobModel) {
|
|
478
|
-
if (!await this.agentService.sessionConfig.applyCronJobModelOverride(sessionKey, jobModel)) log.warn({
|
|
479
|
-
jobId: job.id,
|
|
480
|
-
sessionKey,
|
|
481
|
-
model: jobModel
|
|
482
|
-
}, "Cron job model invalid; using agent default");
|
|
483
|
-
} else await this.agentService.sessionConfig.applyCronJobModelOverride(sessionKey, void 0);
|
|
484
|
-
const response = await this.agentService.turnDispatcher.processDirect(message, sessionKey);
|
|
485
|
-
const model = this.agentService.getModelForSession(sessionKey);
|
|
486
|
-
log.info({
|
|
487
|
-
jobId: job.id,
|
|
488
|
-
sessionKey,
|
|
489
|
-
responseLength: response.length,
|
|
490
|
-
model
|
|
491
|
-
}, "Agent execution completed");
|
|
492
|
-
const delivery = job.delivery;
|
|
493
|
-
const outboundChannel = delivery?.channel;
|
|
494
|
-
if (delivery && delivery.mode !== "none" && delivery.to) {
|
|
495
|
-
if (shouldSilence(response, 300) || response.trim() === "NO_REPLY") return {
|
|
496
|
-
status: "ok",
|
|
497
|
-
summary: response.slice(0, 200),
|
|
498
|
-
sessionId: sessionKey,
|
|
499
|
-
sessionKey,
|
|
500
|
-
sessionType: "cron",
|
|
501
|
-
model
|
|
502
|
-
};
|
|
503
|
-
const { stripped } = stripHeartbeatToken(response);
|
|
504
|
-
const outboundText = stripped || response.trim();
|
|
505
|
-
if (delivery.mode === "webhook") {
|
|
506
|
-
await postCronWebhook(delivery.to, {
|
|
507
|
-
jobId: job.id,
|
|
508
|
-
jobName: job.name,
|
|
509
|
-
payloadKind: job.payload.kind,
|
|
510
|
-
sessionKey,
|
|
511
|
-
model,
|
|
512
|
-
text: outboundText
|
|
513
|
-
});
|
|
514
|
-
log.info({ jobId: job.id }, "Delivered agent response webhook");
|
|
515
|
-
return {
|
|
516
|
-
status: "ok",
|
|
517
|
-
summary: response.slice(0, 200),
|
|
518
|
-
sessionId: sessionKey,
|
|
519
|
-
sessionKey,
|
|
520
|
-
sessionType: "cron",
|
|
521
|
-
model
|
|
522
|
-
};
|
|
523
|
-
}
|
|
524
|
-
if (outboundChannel === "local") return {
|
|
525
|
-
status: "ok",
|
|
526
|
-
summary: response.slice(0, 200),
|
|
527
|
-
sessionId: sessionKey,
|
|
528
|
-
sessionKey,
|
|
529
|
-
sessionType: "cron",
|
|
530
|
-
model
|
|
531
|
-
};
|
|
532
|
-
const targetChannel = outboundChannel || "cli";
|
|
533
|
-
const outbound = await this.buildCronOutboundMessage(targetChannel, delivery.to, outboundText);
|
|
534
|
-
await this.messageBus.publishOutbound(outbound);
|
|
535
|
-
log.info({
|
|
536
|
-
jobId: job.id,
|
|
537
|
-
channel: targetChannel,
|
|
538
|
-
to: outbound.chat_id
|
|
539
|
-
}, "Delivered agent response");
|
|
540
|
-
return {
|
|
541
|
-
status: "ok",
|
|
542
|
-
summary: response.slice(0, 200),
|
|
543
|
-
sessionId: sessionKey,
|
|
544
|
-
sessionKey,
|
|
545
|
-
sessionType: "cron",
|
|
546
|
-
model
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
return {
|
|
550
|
-
status: "ok",
|
|
551
|
-
summary: response.slice(0, 200),
|
|
552
|
-
sessionId: sessionKey,
|
|
553
|
-
sessionKey,
|
|
554
|
-
sessionType: "cron",
|
|
555
|
-
model
|
|
556
|
-
};
|
|
557
|
-
})();
|
|
558
|
-
try {
|
|
559
|
-
return await Promise.race([executePromise, timeoutPromise]);
|
|
560
|
-
} finally {
|
|
561
|
-
const { retireSessionMcpRuntimeForSessionKey } = await import("../agent/mcp/bundle-mcp-tools.js");
|
|
562
|
-
await retireSessionMcpRuntimeForSessionKey({
|
|
563
|
-
sessionKey,
|
|
564
|
-
reason: "cron-isolated-end"
|
|
565
|
-
}).catch(() => {});
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* Basic execution without agent service (fallback)
|
|
570
|
-
*/
|
|
571
|
-
async basicExecute(job, signal, timeout) {
|
|
572
|
-
return new Promise((resolve, reject) => {
|
|
573
|
-
const timeoutId = setTimeout(() => {
|
|
574
|
-
reject(/* @__PURE__ */ new Error(`Job timed out after ${timeout}ms`));
|
|
575
|
-
}, timeout);
|
|
576
|
-
const abortHandler = () => {
|
|
577
|
-
clearTimeout(timeoutId);
|
|
578
|
-
reject(/* @__PURE__ */ new Error("Job was aborted"));
|
|
579
|
-
};
|
|
580
|
-
signal.addEventListener("abort", abortHandler);
|
|
581
|
-
setTimeout(() => {
|
|
582
|
-
clearTimeout(timeoutId);
|
|
583
|
-
signal.removeEventListener("abort", abortHandler);
|
|
584
|
-
if (signal.aborted) reject(/* @__PURE__ */ new Error("Job was aborted"));
|
|
585
|
-
else resolve({
|
|
586
|
-
status: "ok",
|
|
587
|
-
summary: `Executed: ${getCronPayloadText(job).slice(0, 100)}`
|
|
588
|
-
});
|
|
589
|
-
}, 100);
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
/**
|
|
593
|
-
* Cancel a running job
|
|
594
|
-
*/
|
|
595
|
-
cancelJob(jobId) {
|
|
596
|
-
const controller = this.runningJobs.get(jobId);
|
|
597
|
-
if (controller) {
|
|
598
|
-
controller.abort();
|
|
599
|
-
this.runningJobs.delete(jobId);
|
|
600
|
-
return true;
|
|
601
|
-
}
|
|
602
|
-
return false;
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
* Get execution history for a job
|
|
606
|
-
*/
|
|
607
|
-
getHistory(jobId, limit = 10) {
|
|
608
|
-
return (this.history.get(jobId) || []).slice(-limit);
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* Get currently running executions
|
|
612
|
-
*/
|
|
613
|
-
getRunningExecutions() {
|
|
614
|
-
const result = [];
|
|
615
|
-
for (const [jobId] of this.runningJobs) {
|
|
616
|
-
const history = this.history.get(jobId);
|
|
617
|
-
if (history) {
|
|
618
|
-
const running = history.find((e) => e.status === "running");
|
|
619
|
-
if (running) result.push(running);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
return result;
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* Check if a job is currently running
|
|
626
|
-
*/
|
|
627
|
-
isRunning(jobId) {
|
|
628
|
-
return this.runningJobs.has(jobId);
|
|
629
|
-
}
|
|
630
|
-
/**
|
|
631
|
-
* Get consecutive error count for a job
|
|
632
|
-
*/
|
|
633
|
-
getConsecutiveErrors(jobId) {
|
|
634
|
-
const history = this.history.get(jobId) || [];
|
|
635
|
-
for (let i = history.length - 1; i >= 0; i--) if (history[i].status !== "running") {
|
|
636
|
-
if (history[i].status === "failed" || history[i].status === "cancelled") {
|
|
637
|
-
let count = 0;
|
|
638
|
-
for (let j = i - 1; j >= 0; j--) if (history[j].status === "failed" || history[j].status === "cancelled") count++;
|
|
639
|
-
else break;
|
|
640
|
-
return count + 1;
|
|
641
|
-
}
|
|
642
|
-
return 0;
|
|
643
|
-
}
|
|
644
|
-
return 0;
|
|
645
|
-
}
|
|
646
|
-
/**
|
|
647
|
-
* Calculate backoff delay for a job
|
|
648
|
-
*/
|
|
649
|
-
calculateBackoff(jobId) {
|
|
650
|
-
return errorBackoffMs(this.getConsecutiveErrors(jobId));
|
|
651
|
-
}
|
|
652
|
-
/**
|
|
653
|
-
* Clear old history entries
|
|
654
|
-
*/
|
|
655
|
-
cleanupHistory(maxAgeDays = 7) {
|
|
656
|
-
const cutoff = Date.now() - maxAgeDays * 24 * 60 * 60 * 1e3;
|
|
657
|
-
for (const [jobId, executions] of this.history) this.history.set(jobId, executions.filter((e) => new Date(e.startedAt).getTime() > cutoff));
|
|
658
|
-
}
|
|
659
|
-
addToHistory(jobId, execution) {
|
|
660
|
-
const existing = this.history.get(jobId) || [];
|
|
661
|
-
existing.push(execution);
|
|
662
|
-
if (existing.length > 100) existing.shift();
|
|
663
|
-
this.history.set(jobId, existing);
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
//#endregion
|
|
667
|
-
export { DefaultJobExecutor };
|
|
668
|
-
|
|
669
|
-
//# sourceMappingURL=executor.js.map
|