@xopcai/xopc 0.0.111 → 0.0.113
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/browser-ext/icons/icon-128.png +0 -0
- package/dist/browser-ext/icons/icon-16.png +0 -0
- package/dist/browser-ext/icons/icon-32.png +0 -0
- package/dist/browser-ext/icons/icon-48.png +0 -0
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/feishu/src/workflow-progress.js +1 -1
- package/dist/extensions/telegram/src/adapters/streaming-adapter.js +1 -1
- package/dist/extensions/telegram/src/inbound-processor.js +1 -1
- package/dist/extensions/telegram/src/plugin.js +1 -1
- package/dist/extensions/telegram/src/routing-integration.js +2 -2
- package/dist/extensions/telegram/src/update-offset-store.js +1 -1
- package/dist/extensions/telegram/src/workflow-progress.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/api/api.js +2 -2
- package/dist/extensions/weixin/src/auth/accounts.js +1 -1
- package/dist/extensions/weixin/src/cdn/upload.js +1 -1
- package/dist/extensions/weixin/src/delivery-to.d.ts +3 -3
- package/dist/extensions/weixin/src/delivery-to.js.map +1 -1
- package/dist/extensions/weixin/src/media/data-url.js +1 -1
- package/dist/extensions/weixin/src/messaging/debug-mode.js +1 -1
- package/dist/extensions/weixin/src/messaging/inbound.js +1 -1
- package/dist/extensions/weixin/src/messaging/process-message.js +1 -1
- package/dist/extensions/weixin/src/plugin.js +1 -1
- package/dist/extensions/weixin/src/storage/sync-buf.js +1 -1
- package/dist/extensions/weixin/src/workflow-progress.js +1 -1
- package/dist/gateway/static/root/apple-touch-icon.png +0 -0
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-zlx9l5Yp.js → agent-avatar-dicebear-CBlklyNr.js} +1 -1
- package/dist/gateway/static/root/assets/agent-browser-settings-page-rGbKc2Hh.js +6 -0
- package/dist/gateway/static/root/assets/{agent-defaults-tabbed-page-Bz7JWjRM.js → agent-defaults-tabbed-page-CtwVbjOA.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CCBmGcwc.js +71 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DaQwdeCq.js → app-management-settings-panel-28E_WfMe.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-D2zv6r3P.js → appearance-settings-Do1z0XgJ.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BIppe_jj.js → apps-page-xwCsJS15.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-DEmu8eH7.js → archive-plugin-BAFlsov_.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-B98lJoN5.js → attachment-load-V3qGPC3x.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-CL9QKmyo.js → binary-plugins-DT8NvA6W.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BOAhMAhT.js → block-editor-CdLMEcHd.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-Br8iRnXp.js → channels-settings-C044DcYk.js} +1 -1
- package/dist/gateway/static/root/assets/{config-api-0o1WYdz2.js → config-api-Bf5mjpu7.js} +1 -1
- package/dist/gateway/static/root/assets/config-reload-event-Bjh2zoKp.js +1 -0
- package/dist/gateway/static/root/assets/connectors-settings-8VEWUOTj.js +2 -0
- package/dist/gateway/static/root/assets/cron-api--pAB_rps.js +1 -0
- package/dist/gateway/static/root/assets/cron-page-DqmNGNOy.js +3 -0
- package/dist/gateway/static/root/assets/dreaming-settings-6UZE1FSK.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-Cjx6pZVz.js → extension-debug-page-BGhE7msg.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BSPNL90V.js → extension-page-CvpI45WG.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-DAmR5FUe.js +1 -0
- package/dist/gateway/static/root/assets/{fetch-Bs7in_4F.js → fetch-NZmjSXLl.js} +1 -1
- package/dist/gateway/static/root/assets/format-cron-label-BsotZDO5.js +2 -0
- package/dist/gateway/static/root/assets/{format-interval-label-CftJ5uXu.js → format-interval-label-qhth3BMV.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-Clfck-hW.js → gateway-config-api-CaXBt-9R.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-DphpbLBc.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BkjVJc38.js → gateway-startup-retry-Be1omjh3.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-detail-page-kqJue0sE.js → goal-detail-page-bv0VRDaf.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-1Ywnt4Cb.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-CJnzNSDo.js → goals-settings-ceEBjnfc.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-config-api-Cp7CPuIn.js → heartbeat-config-api-BzO6G4fD.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-ifSI1Wbh.js → heartbeat-settings-DCST9-du.js} +1 -1
- package/dist/gateway/static/root/assets/index-Cxm6xsps.js +122 -0
- package/dist/gateway/static/root/assets/index-b_R4tKqt.css +1 -0
- package/dist/gateway/static/root/assets/interval-presets-DJmshV8n.js +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings--MI1rYl7.js → keyboard-shortcuts-settings-9AUUlQ5Q.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-BwrVNlyW.js → logs-page-B_wrxhee.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-B_oc9lJe.js → markdown-split-CYYELqAr.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DLPvB5H3.js → media-plugins-BEcMR2M8.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CkT-lcgP.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-D0JDSbNu.js +2 -0
- package/dist/gateway/static/root/assets/note-detail-page-DpFV-EO6.js +2 -0
- package/dist/gateway/static/root/assets/{note-image-lightbox-rSqAgOi9.js → note-image-lightbox-DNAoPcmm.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-C9ACGEty.js → notes-page-CdkjTch8.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-Bw_N2oZi.js → preview-open-alternatives-BPLz0AIv.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BhcWIKuM.js → remote-access-hub-DSYVAi96.js} +1 -1
- package/dist/gateway/static/root/assets/{save-bar-controls-CNP2jmw0.js → save-bar-controls-CrWwWRVK.js} +1 -1
- package/dist/gateway/static/root/assets/schedule-field-CF2sadvN.js +1 -0
- package/dist/gateway/static/root/assets/{schema-form-CDPzua9q.js → schema-form-Di5cKjYE.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-DzkpSDZr.js → sessions-page-CenkcVjF.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-D9sva86V.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-C9bff85B.js → settings-collapsible-section-Chh282jW.js} +1 -1
- package/dist/gateway/static/root/assets/settings-form-section-Dq-83cQd.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-DWK4Zo7s.js → settings-page-DL35U0x0.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Ctwbp9Er.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-DnutoY_S.js → share-preview-page-0FXYnSUA.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-6oRgJMpn.js → shares-settings-DIM3JNsr.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DAlNaNzL.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-CLrHVzAt.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-qP1JDtDd.js → system-settings-panel-W1pTcojB.js} +1 -1
- package/dist/gateway/static/root/assets/use-agent-defaults-form-BVRvkK7m.js +1 -0
- package/dist/gateway/static/root/assets/{use-channel-catalog-C4mg1hjD.js → use-channel-catalog-CgJibfMM.js} +1 -1
- package/dist/gateway/static/root/assets/{use-settings-tab-guard-F6C0mpJt.js → use-settings-tab-guard-Bw_qkRQE.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-BnDDb6qO.js → voice-api-key-field-vYAO71Gn.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-player-store-B2EwIhtY.js → voice-player-store-C7lziaAx.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-page.utils-CRB7WX9l.js → workflow-page.utils-sgHjOXOm.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-2Fptr0je.js → workflows-page-DYyOTmFx.js} +1 -1
- package/dist/gateway/static/root/favicon-16x16.png +0 -0
- package/dist/gateway/static/root/favicon-32x32.png +0 -0
- package/dist/gateway/static/root/favicon-icon.svg +1 -0
- package/dist/gateway/static/root/favicon.ico +0 -0
- package/dist/gateway/static/root/favicon.png +0 -0
- package/dist/gateway/static/root/favicon.svg +24 -15
- package/dist/gateway/static/root/index.html +11 -10
- package/dist/gateway/static/root/logo-dark.svg +23 -15
- package/dist/gateway/static/root/logo.svg +23 -16
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +28 -2
- package/dist/src/agent/agent-manager.js +82 -11
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/agent-scope.js +1 -1
- package/dist/src/agent/bootstrap/load-bootstrap-files.js +1 -1
- package/dist/src/agent/context/workspace-seed.js +2 -2
- package/dist/src/agent/context/workspace-state.js +1 -1
- package/dist/src/agent/context/workspace.js +1 -1
- package/dist/src/agent/goals/goal-locale.js +2 -2
- package/dist/src/agent/goals/persistent-goal-service.js +1 -1
- package/dist/src/agent/goals/post-turn.js +3 -3
- package/dist/src/agent/image/load-image-media.js +2 -2
- package/dist/src/agent/ipc/inbox.js +3 -3
- package/dist/src/agent/ipc/socket.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-materialize.js +1 -1
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
- package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
- package/dist/src/agent/mcp/mcp-transport.js +1 -1
- package/dist/src/agent/memory/builtin-memory-store.js +1 -1
- package/dist/src/agent/memory/dreaming/deep-promotion.js +1 -1
- package/dist/src/agent/memory/dreaming/events.js +1 -1
- package/dist/src/agent/memory/dreaming/last-run.js +1 -1
- package/dist/src/agent/memory/dreaming/light-sweep.js +1 -1
- package/dist/src/agent/memory/dreaming/preview.js +1 -1
- package/dist/src/agent/memory/dreaming/rem-patterns.js +1 -1
- package/dist/src/agent/memory/dreaming/short-term-store.js +1 -1
- package/dist/src/agent/memory/dreaming/utils.js +1 -1
- package/dist/src/agent/memory/memory-flush.js +1 -1
- package/dist/src/agent/memory/plugin-discovery.js +1 -1
- package/dist/src/agent/messaging/command-handler.d.ts +3 -0
- package/dist/src/agent/messaging/command-handler.js +5 -0
- package/dist/src/agent/messaging/command-handler.js.map +1 -1
- package/dist/src/agent/models/manager.js +1 -1
- package/dist/src/agent/prompt/memory/index.js +1 -1
- package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
- package/dist/src/agent/reply/post-compaction-context.js +1 -1
- package/dist/src/agent/reply/workspace-boundary-read.js +1 -1
- package/dist/src/agent/sandbox/path-policy.js +2 -2
- package/dist/src/agent/service/process-direct-streaming.js +9 -4
- package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
- package/dist/src/agent/service/reconcile-dreaming-cron.js +8 -5
- package/dist/src/agent/service/reconcile-dreaming-cron.js.map +1 -1
- package/dist/src/agent/service.d.ts +2 -1
- package/dist/src/agent/service.js +10 -5
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/service.types.d.ts +4 -0
- package/dist/src/agent/session/session-config-service.d.ts +8 -0
- package/dist/src/agent/session/session-config-service.js +20 -0
- package/dist/src/agent/session/session-config-service.js.map +1 -1
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/config.js +2 -2
- package/dist/src/agent/skills/filesystem-watcher.d.ts +19 -0
- package/dist/src/agent/skills/filesystem-watcher.js +182 -0
- package/dist/src/agent/skills/filesystem-watcher.js.map +1 -0
- package/dist/src/agent/skills/hub-hash.js +2 -2
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/skills/hub-pull.js +30 -36
- package/dist/src/agent/skills/hub-pull.js.map +1 -1
- package/dist/src/agent/skills/index.js +82 -38
- package/dist/src/agent/skills/index.js.map +1 -1
- package/dist/src/agent/skills/installer.js +2 -2
- package/dist/src/agent/skills/managed-store.d.ts +19 -0
- package/dist/src/agent/skills/managed-store.js +97 -38
- package/dist/src/agent/skills/managed-store.js.map +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/skills/skill-manager.d.ts +16 -6
- package/dist/src/agent/skills/skill-manager.js +79 -24
- package/dist/src/agent/skills/skill-manager.js.map +1 -1
- package/dist/src/agent/skills/skill-view-path.js +1 -1
- package/dist/src/agent/skills/test-framework.js +1 -1
- package/dist/src/agent/skills/types.d.ts +11 -0
- package/dist/src/agent/skills/watcher.js +1 -1
- package/dist/src/agent/starter-agents.js +1 -1
- package/dist/src/agent/tools/cronjob-tool.d.ts +6 -3
- package/dist/src/agent/tools/cronjob-tool.js +58 -23
- package/dist/src/agent/tools/cronjob-tool.js.map +1 -1
- package/dist/src/agent/tools/dreaming-tool.js +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/find.js +1 -1
- package/dist/src/agent/tools/grep.js +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +1 -1
- package/dist/src/agent/tools/skill-manage-tool.js +1 -1
- package/dist/src/agent/tools/workflow-tool.js +1 -1
- package/dist/src/agent/workflow/catalog.js +1 -1
- package/dist/src/agent/workspace-runtime/registry.d.ts +5 -0
- package/dist/src/agent/workspace-runtime/registry.js +7 -0
- package/dist/src/agent/workspace-runtime/registry.js.map +1 -1
- package/dist/src/ai-assist/text-assist.d.ts +42 -0
- package/dist/src/ai-assist/text-assist.js +252 -0
- package/dist/src/ai-assist/text-assist.js.map +1 -0
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/profiles/store.js +2 -2
- package/dist/src/auth/sync-provider-auth.js +1 -1
- package/dist/src/browser/cache-dir-policy.js +1 -1
- package/dist/src/browser/cdp-local-launcher.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +4 -4
- package/dist/src/browser/providers/cloakbrowser.js +5 -5
- package/dist/src/browser/providers/playwright-doctor.js +1 -1
- package/dist/src/browser/stealth.js +1 -1
- package/dist/src/channels/outbound/persist-store.js +1 -1
- package/dist/src/channels/pairing/allow-from-file.js +1 -1
- package/dist/src/channels/pairing/pairing-store.js +2 -2
- package/dist/src/channels/plugins/types.adapters.d.ts +2 -2
- package/dist/src/chat-commands/agent-edit.js +2 -2
- package/dist/src/chat-commands/builtins/config.js +3 -3
- package/dist/src/chat-commands/builtins/system.js +11 -4
- package/dist/src/chat-commands/builtins/system.js.map +1 -1
- package/dist/src/chat-commands/context.d.ts +3 -0
- package/dist/src/chat-commands/context.js +7 -0
- package/dist/src/chat-commands/context.js.map +1 -1
- package/dist/src/chat-commands/types.d.ts +2 -0
- package/dist/src/cli/commands/config.js +1 -1
- package/dist/src/cli/commands/cron.js +55 -16
- package/dist/src/cli/commands/cron.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/config-health.js +1 -1
- package/dist/src/cli/commands/doctor/checks/cron-health.js +2 -83
- package/dist/src/cli/commands/doctor/checks/cron-health.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/doctor/checks/state-integrity.js +1 -1
- package/dist/src/cli/commands/doctor/checks/workspace-status.js +1 -1
- package/dist/src/cli/commands/extension-create.js +1 -1
- package/dist/src/cli/commands/extension-dev.js +2 -2
- package/dist/src/cli/commands/extension-marketplace.js +2 -2
- package/dist/src/cli/commands/extension-pack.js +2 -2
- package/dist/src/cli/commands/extension.js +3 -3
- package/dist/src/cli/commands/gateway/logs.js +1 -1
- package/dist/src/cli/commands/image.js +1 -1
- package/dist/src/cli/commands/init.js +2 -2
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/skills-test.js +1 -1
- package/dist/src/cli/templates.js +1 -1
- package/dist/src/cli/utils/gateway-client.js +1 -1
- package/dist/src/cli/utils/init-workspace-core.js +2 -2
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/agent-typed-models.js +1 -1
- package/dist/src/config/gateway-bind.js +1 -1
- package/dist/src/config/index.js +7 -7
- package/dist/src/config/loader.js +4 -4
- package/dist/src/config/models-json.js +2 -2
- package/dist/src/config/paths-state.js +1 -1
- package/dist/src/config/paths.js +1 -1
- package/dist/src/config/profile.js +1 -1
- package/dist/src/config/reload.js +1 -1
- package/dist/src/config/schema.d.ts +0 -2
- package/dist/src/config/schema.js +0 -3
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/config/web-patch.d.ts +0 -1
- package/dist/src/config/web-patch.js +0 -2
- package/dist/src/config/web-patch.js.map +1 -1
- package/dist/src/config/workspace-path.js +1 -1
- package/dist/src/cron/executor.js +102 -71
- package/dist/src/cron/executor.js.map +1 -1
- package/dist/src/cron/index.d.ts +1 -1
- package/dist/src/cron/index.js +3 -3
- package/dist/src/cron/run-log-store.d.ts +1 -0
- package/dist/src/cron/run-log-store.js +4 -2
- package/dist/src/cron/run-log-store.js.map +1 -1
- package/dist/src/cron/schedule.d.ts +10 -0
- package/dist/src/cron/schedule.js +85 -0
- package/dist/src/cron/schedule.js.map +1 -0
- package/dist/src/cron/service.d.ts +34 -77
- package/dist/src/cron/service.js +327 -264
- package/dist/src/cron/service.js.map +1 -1
- package/dist/src/cron/types.d.ts +80 -50
- package/dist/src/cron/validation.d.ts +358 -90
- package/dist/src/cron/validation.js +152 -132
- package/dist/src/cron/validation.js.map +1 -1
- package/dist/src/cron/workflow-run-completion.js +1 -1
- package/dist/src/daemon/constants.js +1 -1
- package/dist/src/daemon/install-plan.js +2 -2
- package/dist/src/daemon/launchd.js +2 -2
- package/dist/src/daemon/schtasks.js +2 -2
- package/dist/src/daemon/systemd.js +2 -2
- package/dist/src/extensions/bundle-mcp.js +1 -1
- package/dist/src/extensions/discover-extensions.js +2 -2
- package/dist/src/extensions/health.js +1 -1
- package/dist/src/extensions/install.js +2 -2
- package/dist/src/extensions/loader.js +2 -2
- package/dist/src/extensions/lockfile.js +3 -3
- package/dist/src/extensions/security.js +1 -1
- package/dist/src/extensions/update.js +2 -2
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/chat-stream/mapper.d.ts +1 -0
- package/dist/src/gateway/chat-stream/mapper.js +6 -2
- package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
- package/dist/src/gateway/chat-stream/protocol.d.ts +2 -0
- package/dist/src/gateway/file-path-classifier.js +2 -2
- package/dist/src/gateway/hono/lib/config-payload.d.ts +0 -1
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/lib/extension-store.js +2 -2
- package/dist/src/gateway/hono/lib/static-ui.js +2 -2
- package/dist/src/gateway/hono/oauth-async.js +1 -1
- package/dist/src/gateway/hono/routes/agents.js +1 -1
- package/dist/src/gateway/hono/routes/ai-assist.d.ts +3 -0
- package/dist/src/gateway/hono/routes/ai-assist.js +66 -0
- package/dist/src/gateway/hono/routes/ai-assist.js.map +1 -0
- package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
- package/dist/src/gateway/hono/routes/commands-skills.js +7 -0
- package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/cron.js +24 -5
- package/dist/src/gateway/hono/routes/cron.js.map +1 -1
- package/dist/src/gateway/hono/routes/dreaming.js +1 -1
- package/dist/src/gateway/hono/routes/home.js +5 -3
- package/dist/src/gateway/hono/routes/home.js.map +1 -1
- package/dist/src/gateway/hono/routes/host-fs.js +2 -2
- package/dist/src/gateway/hono/routes/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/shares.js +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +2 -2
- package/dist/src/gateway/hono/routes/workspace.js +2 -2
- package/dist/src/gateway/lock.js +3 -3
- package/dist/src/gateway/ports.js +1 -1
- package/dist/src/gateway/service/agent-runner.js +2 -2
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service/marketplace-service.d.ts +22 -10
- package/dist/src/gateway/service/marketplace-service.js +46 -5
- package/dist/src/gateway/service/marketplace-service.js.map +1 -1
- package/dist/src/gateway/service.js +11 -5
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/gateway/workspace-fs-file-list.js +1 -1
- package/dist/src/goals/goal-notifications.js +1 -1
- package/dist/src/goals/goal-workflow-judge.js +3 -3
- package/dist/src/i18n/goals-bundle.js +1 -1
- package/dist/src/i18n/index.js +1 -1
- package/dist/src/i18n/share-tool-bundle.js +2 -2
- package/dist/src/infra/brew.js +1 -1
- package/dist/src/infra/package-json.js +1 -1
- package/dist/src/infra/package-update-steps.js +1 -1
- package/dist/src/infra/path-env.js +2 -2
- package/dist/src/infra/restart.js +1 -1
- package/dist/src/infra/stable-node-path.js +1 -1
- package/dist/src/infra/update-check.js +1 -1
- package/dist/src/infra/update-global.js +1 -1
- package/dist/src/infra/update-lock.js +2 -2
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/infra/update-runner.js +1 -1
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/infra/write-file-atomic.js +2 -2
- package/dist/src/media/store.js +1 -1
- package/dist/src/notes/agent-context.js +1 -1
- package/dist/src/notes/service.js +1 -1
- package/dist/src/notes/store.js +2 -2
- package/dist/src/project-trust/trust-store.js +2 -2
- package/dist/src/providers/auth-runtime/auth-profile-store.js +1 -1
- package/dist/src/providers/index.js +1 -1
- package/dist/src/providers/model-registry.js +4 -4
- package/dist/src/session/init-session-turn.js +2 -2
- package/dist/src/session/resolve-session.js +3 -3
- package/dist/src/session/session-title.js +2 -2
- package/dist/src/session/store-reader.d.ts +5 -0
- package/dist/src/session/store-reader.js +1 -0
- package/dist/src/session/store.js +1 -1
- package/dist/src/share/share-auto.js +2 -2
- package/dist/src/share/share-store.js +3 -3
- package/dist/src/share/share-thumbnail.js +2 -2
- package/dist/src/share/share-zip.js +1 -1
- package/dist/src/share/site-share-store.js +3 -3
- package/dist/src/share/site-static-serve.js +1 -1
- package/dist/src/storage/sqlite/connection.js +1 -1
- package/dist/src/storage/sqlite/cron-job-repository.d.ts +6 -0
- package/dist/src/storage/sqlite/cron-job-repository.js +70 -0
- package/dist/src/storage/sqlite/cron-job-repository.js.map +1 -0
- package/dist/src/storage/sqlite/cron-run-repository.js +0 -1
- package/dist/src/storage/sqlite/cron-run-repository.js.map +1 -1
- package/dist/src/storage/sqlite/index.d.ts +1 -0
- package/dist/src/storage/sqlite/index.js +2 -1
- package/dist/src/storage/sqlite/memory-index-repository.js +2 -2
- package/dist/src/storage/sqlite/migrations/009_cron_jobs.sql +24 -0
- package/dist/src/storage/sqlite/migrations/discover.js +1 -1
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +4 -4
- 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 +2 -2
- package/dist/src/storage/sqlite/schema.sql +25 -0
- package/dist/src/tui/clipboard-image.js +3 -3
- package/dist/src/tui/extension-host/load-extensions.js +1 -1
- package/dist/src/tui/theme-manager.js +1 -1
- package/dist/src/tui/tui-command-formatters.js +4 -4
- package/dist/src/tui/tui-commands.js +2 -2
- package/dist/src/tui/tui-keybindings-file.js +1 -1
- package/dist/src/tui/tui-scoped-models.js +2 -2
- package/dist/src/tui/tui-settings.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +6 -6
- package/dist/src/tunnel/frpc-binary.js +4 -4
- package/dist/src/tunnel/frpc-config.js +1 -1
- package/dist/src/tunnel/frpc-extract.js +1 -1
- package/dist/src/tunnel/tunnel-state.js +1 -1
- package/dist/src/utils/logger/audit.js +1 -1
- package/dist/src/utils/logger/log-store.js +1 -1
- package/dist/src/utils/logger/rotation.js +1 -1
- package/dist/src/utils/logger/streams.js +1 -1
- package/dist/src/voice/tts/audio.js +1 -1
- package/dist/src/voice/tts/providers/edge-speech.js +2 -2
- package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
- package/dist/src/workflows/engine/projector.js +23 -14
- package/dist/src/workflows/engine/projector.js.map +1 -1
- package/dist/src/workflows/engine/workflow-engine.d.ts +1 -0
- package/dist/src/workflows/engine/workflow-engine.js +36 -0
- package/dist/src/workflows/engine/workflow-engine.js.map +1 -1
- package/dist/src/workflows/index.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +2 -2
- package/dist/src/workflows/service/workflow-session-bridge.js +2 -2
- package/dist/src/workflows/store/event-store.js +1 -1
- package/dist/src/workflows/store/run-store.js +1 -1
- package/package.json +2 -3
- package/dist/gateway/static/root/assets/agent-browser-settings-page-B-0zGjt8.js +0 -6
- package/dist/gateway/static/root/assets/agents-DwDnJlXT.js +0 -71
- package/dist/gateway/static/root/assets/connectors-settings-DDvHo9in.js +0 -2
- package/dist/gateway/static/root/assets/cron-api-Dj_UZKST.js +0 -1
- package/dist/gateway/static/root/assets/cron-page-Dv7GII9G.js +0 -1
- package/dist/gateway/static/root/assets/cron-schedule-picker-DH10KgD6.js +0 -1
- package/dist/gateway/static/root/assets/dreaming-settings-L2rgZDQl.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-m_UQYkVc.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-CS177xni.js +0 -1
- package/dist/gateway/static/root/assets/goals-page-C0FujUB5.js +0 -2
- package/dist/gateway/static/root/assets/index-COkF54xv.js +0 -121
- package/dist/gateway/static/root/assets/index-DIaSNGEO.css +0 -1
- package/dist/gateway/static/root/assets/interval-presets-B29Ss_2y.js +0 -2
- package/dist/gateway/static/root/assets/messages-Csef1aW7.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-DHGiTIvf.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-page-BM7zlDiT.js +0 -2
- package/dist/gateway/static/root/assets/schedule-field-BPAWui3P.js +0 -1
- package/dist/gateway/static/root/assets/schedule-summary-B-hdSRdR.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BYS-rpzn.js +0 -1
- package/dist/gateway/static/root/assets/settings-form-section-BsrK7TBF.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DJiksNu4.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CU9i0nJV.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-ERbdWENm.js +0 -2
- package/dist/gateway/static/root/assets/use-agent-defaults-form-D3FGVLZb.js +0 -1
- package/dist/gateway/static/root/favicon-16.png +0 -0
- package/dist/gateway/static/root/favicon-32.png +0 -0
- package/dist/src/cron/persistence.d.ts +0 -62
- package/dist/src/cron/persistence.js +0 -188
- package/dist/src/cron/persistence.js.map +0 -1
package/dist/src/cron/service.js
CHANGED
|
@@ -1,356 +1,419 @@
|
|
|
1
|
+
import { init_agent_scope, normalizeAgentId } from "../agent/agent-scope.js";
|
|
1
2
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
3
|
import { init_logger } from "../utils/logger.js";
|
|
3
|
-
import {
|
|
4
|
+
import { buildSessionKey, init_session_key } from "../routing/session-key.js";
|
|
5
|
+
import { AddJobRequestSchema, JobDataSchema, UpdateJobRequestSchema } from "./validation.js";
|
|
6
|
+
import { deleteCronJob, getCronJob, listCronJobs, saveCronJob, saveCronJobs } from "../storage/sqlite/cron-job-repository.js";
|
|
7
|
+
import "../storage/sqlite/index.js";
|
|
8
|
+
import { computeNextRunAtMs, describeSchedule, timerDelayUntil } from "./schedule.js";
|
|
4
9
|
import { DefaultJobExecutor } from "./executor.js";
|
|
5
|
-
import { AddJobRequestSchema, UpdateJobRequestSchema } from "./validation.js";
|
|
6
|
-
import { CronPersistence } from "./persistence.js";
|
|
7
10
|
import { CronRunLogStore } from "./run-log-store.js";
|
|
8
|
-
import
|
|
9
|
-
import { CronExpressionParser } from "cron-parser";
|
|
10
|
-
import { v4 } from "uuid";
|
|
11
|
+
import { randomUUID } from "node:crypto";
|
|
11
12
|
//#region src/cron/service.ts
|
|
12
|
-
init_paths();
|
|
13
13
|
init_logger();
|
|
14
|
+
init_agent_scope();
|
|
15
|
+
init_session_key();
|
|
14
16
|
const log = createLogger("CronService");
|
|
17
|
+
const DEFAULT_MAX_CONCURRENT_JOBS = 5;
|
|
18
|
+
const DEFAULT_MISSED_JOB_STAGGER_MS = 5e3;
|
|
19
|
+
var CronJobAlreadyRunningError = class extends Error {
|
|
20
|
+
jobId;
|
|
21
|
+
runningSessionKey;
|
|
22
|
+
constructor(jobId, runningSessionKey) {
|
|
23
|
+
super(`Job is already running: ${jobId}`);
|
|
24
|
+
this.name = "CronJobAlreadyRunningError";
|
|
25
|
+
this.jobId = jobId;
|
|
26
|
+
this.runningSessionKey = runningSessionKey;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
function nowMs() {
|
|
30
|
+
return Date.now();
|
|
31
|
+
}
|
|
32
|
+
function runStatusFromExecution(status) {
|
|
33
|
+
if (status === "success") return "ok";
|
|
34
|
+
if (status === "cancelled" || status === "skipped") return "skipped";
|
|
35
|
+
return "error";
|
|
36
|
+
}
|
|
37
|
+
async function postFailureWebhook(url, payload) {
|
|
38
|
+
const res = await fetch(url, {
|
|
39
|
+
method: "POST",
|
|
40
|
+
headers: { "content-type": "application/json" },
|
|
41
|
+
body: JSON.stringify(payload)
|
|
42
|
+
});
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
const text = await res.text().catch(() => "");
|
|
45
|
+
throw new Error(`Cron failure webhook failed: HTTP ${res.status}${text ? ` ${text.slice(0, 200)}` : ""}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function inferJobName(input) {
|
|
49
|
+
if (input.name?.trim()) return input.name.trim();
|
|
50
|
+
if (input.payload.kind === "agentTurn") return input.payload.message.slice(0, 60) || "Agent task";
|
|
51
|
+
if (input.payload.kind === "systemEvent") return input.payload.text.slice(0, 60) || "System event";
|
|
52
|
+
if (input.payload.kind === "workflowRun") return `Workflow ${input.payload.definitionId}`;
|
|
53
|
+
if (input.payload.kind === "goalContinue") return `Goal ${input.payload.goalId}`;
|
|
54
|
+
return describeSchedule(input.schedule);
|
|
55
|
+
}
|
|
56
|
+
function resolveRunningSessionKey(job, deps) {
|
|
57
|
+
if (job.payload.kind !== "agentTurn") return void 0;
|
|
58
|
+
if (job.sessionTarget.startsWith("session:")) return job.sessionTarget.slice(8).trim() || void 0;
|
|
59
|
+
if (job.sessionTarget === "current") return job.sessionKey?.trim() || void 0;
|
|
60
|
+
if (job.sessionTarget !== "isolated") return;
|
|
61
|
+
const aid = job.agentId?.trim();
|
|
62
|
+
const fallbackAgentId = deps.getDefaultCronAgentId?.() ?? "main";
|
|
63
|
+
return buildSessionKey({
|
|
64
|
+
agentId: normalizeAgentId(aid || fallbackAgentId),
|
|
65
|
+
source: "cron",
|
|
66
|
+
accountId: "default",
|
|
67
|
+
peerKind: "dm",
|
|
68
|
+
peerId: `${job.id}-${randomUUID().slice(0, 8)}`
|
|
69
|
+
});
|
|
70
|
+
}
|
|
15
71
|
var CronService = class {
|
|
16
|
-
|
|
17
|
-
executor;
|
|
72
|
+
executor = new DefaultJobExecutor();
|
|
18
73
|
runLogStore;
|
|
19
|
-
tasks = /* @__PURE__ */ new Map();
|
|
20
74
|
initialized = false;
|
|
21
|
-
|
|
22
|
-
|
|
75
|
+
stopped = false;
|
|
76
|
+
running = false;
|
|
77
|
+
timer = null;
|
|
78
|
+
deps = {};
|
|
79
|
+
maxConcurrentJobs;
|
|
80
|
+
missedJobStaggerMs;
|
|
23
81
|
constructor(config) {
|
|
24
|
-
const filePath = config?.filePath || resolveCronJobsPath();
|
|
25
|
-
this.persistence = new CronPersistence(filePath);
|
|
26
|
-
this.executor = new DefaultJobExecutor();
|
|
27
82
|
this.runLogStore = new CronRunLogStore(config?.dbPath);
|
|
28
83
|
this.executor.setRunLogStore(this.runLogStore);
|
|
84
|
+
this.maxConcurrentJobs = Math.max(1, Math.floor(config?.maxConcurrentJobs ?? DEFAULT_MAX_CONCURRENT_JOBS));
|
|
85
|
+
this.missedJobStaggerMs = Math.max(0, Math.floor(config?.missedJobStaggerMs ?? DEFAULT_MISSED_JOB_STAGGER_MS));
|
|
29
86
|
if (config?.agentService || config?.messageBus) this.setDeps({
|
|
30
87
|
agentService: config.agentService,
|
|
31
88
|
messageBus: config.messageBus
|
|
32
89
|
});
|
|
33
90
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Set dependencies for the executor
|
|
36
|
-
*/
|
|
37
91
|
setDeps(deps) {
|
|
38
|
-
this.
|
|
39
|
-
|
|
40
|
-
|
|
92
|
+
this.deps = {
|
|
93
|
+
...this.deps,
|
|
94
|
+
...deps
|
|
95
|
+
};
|
|
96
|
+
this.executor.setDeps(this.deps);
|
|
41
97
|
log.debug("CronService dependencies set");
|
|
42
98
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Initialize the service and load all jobs
|
|
45
|
-
*/
|
|
46
99
|
async initialize() {
|
|
47
100
|
if (this.initialized) return;
|
|
48
|
-
|
|
49
|
-
await this.
|
|
101
|
+
this.stopped = false;
|
|
102
|
+
await this.recomputeAllNextRuns({ catchUp: true });
|
|
50
103
|
this.initialized = true;
|
|
51
|
-
|
|
104
|
+
this.armTimer();
|
|
105
|
+
log.info("CronService initialized");
|
|
52
106
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
throw new Error(`Validation failed: ${errorMsg}`);
|
|
64
|
-
}
|
|
65
|
-
const data = validationResult.data;
|
|
66
|
-
const id = v4().slice(0, 8);
|
|
67
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
68
|
-
const sessionTarget = data.sessionTarget ?? "main";
|
|
69
|
-
const job = {
|
|
107
|
+
async addJob(scheduleOrInput, options) {
|
|
108
|
+
const raw = options ? {
|
|
109
|
+
...options,
|
|
110
|
+
schedule: scheduleOrInput
|
|
111
|
+
} : scheduleOrInput;
|
|
112
|
+
const parsed = AddJobRequestSchema.parse(raw);
|
|
113
|
+
const ts = nowMs();
|
|
114
|
+
const id = parsed.id?.trim() || randomUUID().slice(0, 12);
|
|
115
|
+
const job = JobDataSchema.parse({
|
|
116
|
+
...parsed,
|
|
70
117
|
id,
|
|
71
|
-
name:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
delivery: data.delivery,
|
|
84
|
-
model: data.model
|
|
85
|
-
};
|
|
86
|
-
await this.persistence.addJob(job);
|
|
87
|
-
this.scheduleJob(job);
|
|
118
|
+
name: inferJobName(parsed),
|
|
119
|
+
enabled: parsed.enabled ?? true,
|
|
120
|
+
deleteAfterRun: parsed.deleteAfterRun ?? parsed.schedule.kind === "at",
|
|
121
|
+
createdAtMs: ts,
|
|
122
|
+
updatedAtMs: ts,
|
|
123
|
+
sessionTarget: parsed.sessionTarget ?? (parsed.payload.kind === "systemEvent" ? "main" : "isolated"),
|
|
124
|
+
wakeMode: parsed.wakeMode ?? "now",
|
|
125
|
+
state: { ...parsed.state ?? {} }
|
|
126
|
+
});
|
|
127
|
+
job.state.nextRunAtMs = computeNextRunAtMs(job, ts);
|
|
128
|
+
saveCronJob(job);
|
|
129
|
+
this.armTimer();
|
|
88
130
|
log.info({
|
|
89
|
-
jobId: id,
|
|
90
|
-
name:
|
|
91
|
-
|
|
92
|
-
}, "
|
|
131
|
+
jobId: job.id,
|
|
132
|
+
name: job.name,
|
|
133
|
+
schedule: job.schedule
|
|
134
|
+
}, "Cron job added");
|
|
93
135
|
return {
|
|
94
|
-
id,
|
|
95
|
-
schedule:
|
|
136
|
+
id: job.id,
|
|
137
|
+
schedule: job.schedule
|
|
96
138
|
};
|
|
97
139
|
}
|
|
98
|
-
/**
|
|
99
|
-
* List all jobs with next run time
|
|
100
|
-
*/
|
|
101
140
|
async listJobs() {
|
|
102
|
-
return (
|
|
103
|
-
let nextRun;
|
|
104
|
-
if (job.enabled) try {
|
|
105
|
-
const options = job.timezone ? { tz: job.timezone } : void 0;
|
|
106
|
-
nextRun = CronExpressionParser.parse(job.schedule, options).next().toISOString();
|
|
107
|
-
} catch (err) {
|
|
108
|
-
log.debug({
|
|
109
|
-
jobId: job.id,
|
|
110
|
-
err
|
|
111
|
-
}, "Failed to parse cron for next run");
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
id: job.id,
|
|
115
|
-
name: job.name,
|
|
116
|
-
schedule: job.schedule,
|
|
117
|
-
enabled: job.enabled,
|
|
118
|
-
timezone: job.timezone,
|
|
119
|
-
maxRetries: job.maxRetries,
|
|
120
|
-
timeout: job.timeout,
|
|
121
|
-
sessionTarget: job.sessionTarget,
|
|
122
|
-
...job.agentId ? { agentId: job.agentId } : {},
|
|
123
|
-
...job.workingDirectory ? { workingDirectory: job.workingDirectory } : {},
|
|
124
|
-
payload: job.payload,
|
|
125
|
-
delivery: job.delivery,
|
|
126
|
-
model: job.model,
|
|
127
|
-
next_run: nextRun
|
|
128
|
-
};
|
|
129
|
-
});
|
|
141
|
+
return listCronJobs();
|
|
130
142
|
}
|
|
131
|
-
/**
|
|
132
|
-
* Get a single job
|
|
133
|
-
*/
|
|
134
143
|
async getJob(id) {
|
|
135
|
-
return
|
|
144
|
+
return getCronJob(id);
|
|
136
145
|
}
|
|
137
|
-
/**
|
|
138
|
-
* Update a job
|
|
139
|
-
*/
|
|
140
146
|
async updateJob(id, updates) {
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
else if (workingDirectoryPatch !== void 0) patch.workingDirectory = workingDirectoryPatch;
|
|
156
|
-
if (patch.schedule && patch.schedule !== job.schedule) this.cancelTask(id);
|
|
157
|
-
await this.persistence.updateJob(id, patch, {
|
|
158
|
-
clearAgentId,
|
|
159
|
-
clearWorkingDirectory
|
|
147
|
+
const parsed = UpdateJobRequestSchema.parse(updates);
|
|
148
|
+
const current = getCronJob(id);
|
|
149
|
+
if (!current) return false;
|
|
150
|
+
const ts = nowMs();
|
|
151
|
+
const next = JobDataSchema.parse({
|
|
152
|
+
...current,
|
|
153
|
+
...parsed,
|
|
154
|
+
id: current.id,
|
|
155
|
+
createdAtMs: current.createdAtMs,
|
|
156
|
+
updatedAtMs: ts,
|
|
157
|
+
state: {
|
|
158
|
+
...current.state,
|
|
159
|
+
...parsed.state ?? {}
|
|
160
|
+
}
|
|
160
161
|
});
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
if ("schedule" in parsed || "enabled" in parsed) {
|
|
163
|
+
next.state.nextRunAtMs = computeNextRunAtMs(next, ts);
|
|
164
|
+
delete next.state.runningAtMs;
|
|
165
|
+
}
|
|
166
|
+
if ("agentId" in updates && updates.agentId?.trim() === "") delete next.agentId;
|
|
167
|
+
if ("workingDirectory" in updates && updates.workingDirectory?.trim() === "") delete next.workingDirectory;
|
|
168
|
+
saveCronJob(next);
|
|
169
|
+
this.armTimer();
|
|
170
|
+
log.info({ jobId: id }, "Cron job updated");
|
|
164
171
|
return true;
|
|
165
172
|
}
|
|
166
|
-
/**
|
|
167
|
-
* Remove a job
|
|
168
|
-
*/
|
|
169
173
|
async removeJob(id) {
|
|
170
|
-
|
|
171
|
-
const removed = await this.persistence.removeJob(id);
|
|
174
|
+
const removed = deleteCronJob(id);
|
|
172
175
|
if (removed) {
|
|
176
|
+
this.executor.cancelJob(id);
|
|
173
177
|
await this.runLogStore.deleteJobRuns(id);
|
|
174
|
-
|
|
178
|
+
this.armTimer();
|
|
179
|
+
log.info({ jobId: id }, "Cron job removed");
|
|
175
180
|
}
|
|
176
181
|
return removed;
|
|
177
182
|
}
|
|
178
|
-
/**
|
|
179
|
-
* Toggle job enabled state
|
|
180
|
-
*/
|
|
181
183
|
async toggleJob(id, enabled) {
|
|
182
|
-
|
|
183
|
-
await this.persistence.updateJob(id, { enabled });
|
|
184
|
-
if (enabled) {
|
|
185
|
-
const updated = await this.persistence.getJob(id);
|
|
186
|
-
if (updated) this.scheduleJob(updated);
|
|
187
|
-
} else this.cancelTask(id);
|
|
188
|
-
log.info({
|
|
189
|
-
jobId: id,
|
|
190
|
-
enabled
|
|
191
|
-
}, "Job toggled");
|
|
192
|
-
return true;
|
|
184
|
+
return this.updateJob(id, { enabled });
|
|
193
185
|
}
|
|
194
|
-
/**
|
|
195
|
-
* Execution history for one job: merged in-memory (incl. running) + persisted SQLite rows.
|
|
196
|
-
*/
|
|
197
186
|
async getJobHistory(jobId, limit) {
|
|
198
|
-
|
|
199
|
-
const [disk, memory] = await Promise.all([this.runLogStore.readJobHistory(jobId, cap * 2), Promise.resolve(this.executor.getHistory(jobId, cap * 2))]);
|
|
200
|
-
const byId = /* @__PURE__ */ new Map();
|
|
201
|
-
for (const e of memory) byId.set(e.id, e);
|
|
202
|
-
for (const e of disk) if (!byId.has(e.id)) byId.set(e.id, e);
|
|
203
|
-
return [...byId.values()].sort((a, b) => new Date(b.startedAt).getTime() - new Date(a.startedAt).getTime()).slice(0, cap);
|
|
187
|
+
return this.runLogStore.readJobHistory(jobId, Math.min(Math.max(limit ?? 10, 1), 500));
|
|
204
188
|
}
|
|
205
|
-
/**
|
|
206
|
-
* Latest runs across all jobs (persisted rows + optional job name).
|
|
207
|
-
*/
|
|
208
189
|
async getAllRunsHistory(limit) {
|
|
209
190
|
const cap = Math.min(Math.max(limit ?? 50, 1), 500);
|
|
210
|
-
const jobs =
|
|
211
|
-
const
|
|
212
|
-
return this.runLogStore.readAllRuns(cap,
|
|
191
|
+
const jobs = listCronJobs();
|
|
192
|
+
const names = new Map(jobs.map((job) => [job.id, job.name]));
|
|
193
|
+
return this.runLogStore.readAllRuns(cap, names);
|
|
213
194
|
}
|
|
214
|
-
/**
|
|
215
|
-
* Get service metrics
|
|
216
|
-
*/
|
|
217
195
|
async getMetrics() {
|
|
218
|
-
const jobs =
|
|
219
|
-
const enabled = jobs.filter((
|
|
220
|
-
|
|
221
|
-
for (const job of enabled) try {
|
|
222
|
-
const options = job.timezone ? { tz: job.timezone } : void 0;
|
|
223
|
-
const next = CronExpressionParser.parse(job.schedule, options).next();
|
|
224
|
-
if (!nextScheduledJob || next.getTime() < nextScheduledJob.runAt.getTime()) nextScheduledJob = {
|
|
225
|
-
id: job.id,
|
|
226
|
-
name: job.name,
|
|
227
|
-
runAt: next.toDate()
|
|
228
|
-
};
|
|
229
|
-
} catch {}
|
|
196
|
+
const jobs = listCronJobs();
|
|
197
|
+
const enabled = jobs.filter((job) => job.enabled);
|
|
198
|
+
const next = enabled.filter((job) => job.state.nextRunAtMs != null).toSorted((a, b) => (a.state.nextRunAtMs ?? 0) - (b.state.nextRunAtMs ?? 0))[0];
|
|
230
199
|
return {
|
|
231
200
|
totalJobs: jobs.length,
|
|
232
|
-
runningJobs:
|
|
201
|
+
runningJobs: jobs.filter((job) => job.state.runningAtMs != null).length,
|
|
233
202
|
enabledJobs: enabled.length,
|
|
234
|
-
failedLastHour: 0,
|
|
203
|
+
failedLastHour: jobs.filter((job) => job.state.lastRunStatus === "error" && (job.state.lastRunAtMs ?? 0) >= nowMs() - 60 * 6e4).length,
|
|
235
204
|
avgExecutionTime: 0,
|
|
236
|
-
nextScheduledJob
|
|
205
|
+
nextScheduledJob: next?.state.nextRunAtMs ? {
|
|
206
|
+
id: next.id,
|
|
207
|
+
name: next.name,
|
|
208
|
+
runAt: new Date(next.state.nextRunAtMs)
|
|
209
|
+
} : void 0
|
|
237
210
|
};
|
|
238
211
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
updateConfig(_config) {
|
|
243
|
-
log.debug("Cron config updated (jobs managed separately via addJob/removeJob)");
|
|
212
|
+
updateConfig(config) {
|
|
213
|
+
this.maxConcurrentJobs = Math.max(1, Math.floor(config.cron?.maxConcurrentJobs ?? DEFAULT_MAX_CONCURRENT_JOBS));
|
|
214
|
+
this.armTimer();
|
|
244
215
|
}
|
|
245
|
-
/**
|
|
246
|
-
* Health check
|
|
247
|
-
*/
|
|
248
216
|
async healthCheck() {
|
|
249
217
|
const issues = [];
|
|
250
218
|
if (!this.initialized) issues.push("Service not initialized");
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
issues.push(`Job ${job.id} requires agent service but none configured`);
|
|
255
|
-
break;
|
|
219
|
+
for (const job of listCronJobs()) {
|
|
220
|
+
if (!JobDataSchema.safeParse(job).success) issues.push(`Job ${job.id} is invalid`);
|
|
221
|
+
if (job.enabled && job.state.nextRunAtMs == null && job.schedule.kind !== "at") issues.push(`Job ${job.id} has no next run`);
|
|
256
222
|
}
|
|
257
|
-
let status = "healthy";
|
|
258
|
-
if (issues.length > 0) status = issues.length > 5 ? "unhealthy" : "degraded";
|
|
259
223
|
return {
|
|
260
|
-
status,
|
|
224
|
+
status: issues.length === 0 ? "healthy" : issues.length > 5 ? "unhealthy" : "degraded",
|
|
261
225
|
issues
|
|
262
226
|
};
|
|
263
227
|
}
|
|
264
|
-
/**
|
|
265
|
-
* Run a job immediately (manual trigger)
|
|
266
|
-
*/
|
|
267
228
|
async runJobNow(id) {
|
|
268
|
-
const job =
|
|
229
|
+
const job = getCronJob(id);
|
|
269
230
|
if (!job) throw new Error(`Job not found: ${id}`);
|
|
270
|
-
if (
|
|
271
|
-
|
|
231
|
+
if (job.state.runningAtMs != null) throw new CronJobAlreadyRunningError(id, job.state.runningSessionKey);
|
|
232
|
+
return {
|
|
233
|
+
job: this.startSingleJob(job, { manual: true }),
|
|
234
|
+
history: await this.getJobHistory(id, 20)
|
|
235
|
+
};
|
|
272
236
|
}
|
|
273
|
-
/**
|
|
274
|
-
* Stop all jobs and cleanup
|
|
275
|
-
*/
|
|
276
237
|
async stop(options) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
this.
|
|
238
|
+
this.stopped = true;
|
|
239
|
+
if (this.timer) {
|
|
240
|
+
clearTimeout(this.timer);
|
|
241
|
+
this.timer = null;
|
|
281
242
|
}
|
|
282
|
-
this.
|
|
243
|
+
for (const job of listCronJobs()) this.executor.cancelJob(job.id);
|
|
283
244
|
if (options?.waitForRunning) {
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
245
|
+
const started = nowMs();
|
|
246
|
+
const timeout = options.timeout ?? 3e4;
|
|
247
|
+
while (nowMs() - started < timeout) {
|
|
248
|
+
if (listCronJobs().every((job) => job.state.runningAtMs == null)) break;
|
|
249
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
288
250
|
}
|
|
289
251
|
}
|
|
290
|
-
await this.persistence.flush();
|
|
291
252
|
log.info("CronService stopped");
|
|
292
253
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
254
|
+
async recomputeAllNextRuns(opts) {
|
|
255
|
+
const ts = nowMs();
|
|
256
|
+
saveCronJobs(listCronJobs().map((job, index) => {
|
|
257
|
+
const next = {
|
|
258
|
+
...job,
|
|
259
|
+
state: { ...job.state }
|
|
260
|
+
};
|
|
261
|
+
if (next.state.runningAtMs != null) {
|
|
262
|
+
next.state.lastRunStatus = "error";
|
|
263
|
+
next.state.lastError = "Interrupted by gateway restart";
|
|
264
|
+
next.state.consecutiveErrors = (next.state.consecutiveErrors ?? 0) + 1;
|
|
265
|
+
delete next.state.runningAtMs;
|
|
266
|
+
}
|
|
267
|
+
if (next.enabled) {
|
|
268
|
+
const existingNext = next.state.nextRunAtMs;
|
|
269
|
+
if (opts?.catchUp && existingNext != null && existingNext <= ts) next.state.nextRunAtMs = ts + index * this.missedJobStaggerMs;
|
|
270
|
+
else next.state.nextRunAtMs = computeNextRunAtMs(next, ts);
|
|
271
|
+
} else next.state.nextRunAtMs = void 0;
|
|
272
|
+
return next;
|
|
273
|
+
}));
|
|
300
274
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
if (!nodeCron.validate(job.schedule)) {
|
|
307
|
-
log.error({
|
|
308
|
-
jobId: job.id,
|
|
309
|
-
schedule: job.schedule
|
|
310
|
-
}, "Invalid cron expression");
|
|
311
|
-
return;
|
|
275
|
+
armTimer() {
|
|
276
|
+
if (this.stopped) return;
|
|
277
|
+
if (this.timer) {
|
|
278
|
+
clearTimeout(this.timer);
|
|
279
|
+
this.timer = null;
|
|
312
280
|
}
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
jobId: job.id,
|
|
320
|
-
schedule: job.schedule
|
|
321
|
-
}, "Job scheduled");
|
|
281
|
+
const next = listCronJobs().filter((job) => job.enabled && job.state.nextRunAtMs != null).toSorted((a, b) => (a.state.nextRunAtMs ?? 0) - (b.state.nextRunAtMs ?? 0))[0];
|
|
282
|
+
if (!next?.state.nextRunAtMs) return;
|
|
283
|
+
this.timer = setTimeout(() => {
|
|
284
|
+
this.onTimer();
|
|
285
|
+
}, timerDelayUntil(next.state.nextRunAtMs));
|
|
286
|
+
this.timer.unref?.();
|
|
322
287
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (this.executor.isRunning(job.id)) {
|
|
328
|
-
log.warn({ jobId: job.id }, "Job already running, skipping");
|
|
288
|
+
async onTimer() {
|
|
289
|
+
if (this.stopped) return;
|
|
290
|
+
if (this.running) {
|
|
291
|
+
this.armTimer();
|
|
329
292
|
return;
|
|
330
293
|
}
|
|
331
|
-
|
|
294
|
+
this.running = true;
|
|
332
295
|
try {
|
|
333
|
-
|
|
334
|
-
|
|
296
|
+
const ts = nowMs();
|
|
297
|
+
const due = listCronJobs().filter((job) => job.enabled && job.state.nextRunAtMs != null && job.state.nextRunAtMs <= ts && job.state.runningAtMs == null).slice(0, this.maxConcurrentJobs);
|
|
298
|
+
if (due.length === 0) return;
|
|
299
|
+
const reserved = due.map((job) => ({
|
|
300
|
+
...job,
|
|
301
|
+
state: {
|
|
302
|
+
...job.state,
|
|
303
|
+
runningAtMs: ts
|
|
304
|
+
}
|
|
305
|
+
}));
|
|
306
|
+
saveCronJobs(reserved);
|
|
307
|
+
await Promise.all(reserved.map((job) => this.runSingleJob(job)));
|
|
308
|
+
} finally {
|
|
309
|
+
this.running = false;
|
|
310
|
+
this.armTimer();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
startSingleJob(job, opts) {
|
|
314
|
+
const started = nowMs();
|
|
315
|
+
const runningSessionKey = resolveRunningSessionKey(job, this.deps);
|
|
316
|
+
const reserved = {
|
|
317
|
+
...job,
|
|
318
|
+
state: {
|
|
319
|
+
...job.state,
|
|
320
|
+
runningAtMs: started,
|
|
321
|
+
...runningSessionKey ? { runningSessionKey } : {}
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
saveCronJob(reserved);
|
|
325
|
+
this.runReservedJob(reserved, started, runningSessionKey, opts).catch((err) => {
|
|
335
326
|
log.error({
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
},
|
|
327
|
+
err,
|
|
328
|
+
jobId: job.id
|
|
329
|
+
}, `Background cron job failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
330
|
+
});
|
|
331
|
+
return reserved;
|
|
332
|
+
}
|
|
333
|
+
async runSingleJob(job, opts) {
|
|
334
|
+
const started = nowMs();
|
|
335
|
+
const runningSessionKey = resolveRunningSessionKey(job, this.deps);
|
|
336
|
+
const reserved = {
|
|
337
|
+
...job,
|
|
338
|
+
state: {
|
|
339
|
+
...job.state,
|
|
340
|
+
runningAtMs: started,
|
|
341
|
+
...runningSessionKey ? { runningSessionKey } : {}
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
saveCronJob(reserved);
|
|
345
|
+
await this.runReservedJob(reserved, started, runningSessionKey, opts);
|
|
346
|
+
}
|
|
347
|
+
async runReservedJob(reserved, started, runningSessionKey, opts) {
|
|
348
|
+
const controller = new AbortController();
|
|
349
|
+
await this.executor.execute(runningSessionKey ? {
|
|
350
|
+
...reserved,
|
|
351
|
+
sessionKey: runningSessionKey
|
|
352
|
+
} : reserved, controller.signal, this.deps);
|
|
353
|
+
const latestRun = (await this.getJobHistory(reserved.id, 1))[0];
|
|
354
|
+
const finished = nowMs();
|
|
355
|
+
const status = latestRun ? runStatusFromExecution(latestRun.status) : "error";
|
|
356
|
+
const latest = getCronJob(reserved.id);
|
|
357
|
+
if (!latest) return;
|
|
358
|
+
const next = {
|
|
359
|
+
...latest,
|
|
360
|
+
state: {
|
|
361
|
+
...latest.state,
|
|
362
|
+
lastRunAtMs: finished,
|
|
363
|
+
lastRunStatus: status,
|
|
364
|
+
lastError: latestRun?.error,
|
|
365
|
+
lastDurationMs: finished - started,
|
|
366
|
+
consecutiveErrors: status === "error" ? (latest.state.consecutiveErrors ?? 0) + 1 : 0,
|
|
367
|
+
consecutiveSkipped: status === "skipped" ? (latest.state.consecutiveSkipped ?? 0) + 1 : 0,
|
|
368
|
+
lastDeliveryStatus: latest.delivery?.mode && latest.delivery.mode !== "none" ? "unknown" : "not-requested"
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
delete next.state.runningAtMs;
|
|
372
|
+
delete next.state.runningSessionKey;
|
|
373
|
+
if (!opts?.manual && next.deleteAfterRun && status === "ok") {
|
|
374
|
+
await this.removeJob(next.id);
|
|
375
|
+
return;
|
|
339
376
|
}
|
|
377
|
+
next.state.nextRunAtMs = computeNextRunAtMs(next, finished);
|
|
378
|
+
saveCronJob(next);
|
|
379
|
+
await this.maybeEmitFailureAlert(next);
|
|
340
380
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
381
|
+
async maybeEmitFailureAlert(job) {
|
|
382
|
+
if (!job.failureAlert) return;
|
|
383
|
+
if (job.state.lastRunStatus !== "error") return;
|
|
384
|
+
const threshold = job.failureAlert.after ?? 1;
|
|
385
|
+
if ((job.state.consecutiveErrors ?? 0) < threshold) return;
|
|
386
|
+
const ts = nowMs();
|
|
387
|
+
const cooldownMs = job.failureAlert.cooldownMs ?? 60 * 6e4;
|
|
388
|
+
if (job.state.lastFailureAlertAtMs && ts - job.state.lastFailureAlertAtMs < cooldownMs) return;
|
|
389
|
+
const channel = job.failureAlert.channel || job.delivery?.channel;
|
|
390
|
+
const to = job.failureAlert.to || job.delivery?.to;
|
|
391
|
+
if (!to) return;
|
|
392
|
+
if (job.failureAlert.mode === "webhook") {
|
|
393
|
+
await postFailureWebhook(to, {
|
|
394
|
+
jobId: job.id,
|
|
395
|
+
jobName: job.name,
|
|
396
|
+
status: job.state.lastRunStatus,
|
|
397
|
+
error: job.state.lastError ?? "Unknown error",
|
|
398
|
+
consecutiveErrors: job.state.consecutiveErrors ?? 0,
|
|
399
|
+
lastRunAtMs: job.state.lastRunAtMs
|
|
400
|
+
});
|
|
401
|
+
job.state.lastFailureAlertAtMs = ts;
|
|
402
|
+
saveCronJob(job);
|
|
403
|
+
return;
|
|
350
404
|
}
|
|
405
|
+
if (!this.deps.messageBus || !channel) return;
|
|
406
|
+
await this.deps.messageBus.publishOutbound({
|
|
407
|
+
channel,
|
|
408
|
+
chat_id: to,
|
|
409
|
+
type: "message",
|
|
410
|
+
content: `Cron job failed: ${job.name}\n${job.state.lastError ?? "Unknown error"}`
|
|
411
|
+
});
|
|
412
|
+
job.state.lastFailureAlertAtMs = ts;
|
|
413
|
+
saveCronJob(job);
|
|
351
414
|
}
|
|
352
415
|
};
|
|
353
416
|
//#endregion
|
|
354
|
-
export { CronService };
|
|
417
|
+
export { CronJobAlreadyRunningError, CronService };
|
|
355
418
|
|
|
356
419
|
//# sourceMappingURL=service.js.map
|