@xopcai/xopc 0.0.110 → 0.0.112
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 +46 -4
- package/README.zh-CN.md +46 -4
- 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/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/Combination-BzaXOLd9.js +41 -0
- package/dist/gateway/static/root/assets/agent-avatar-dicebear-EhRp-ZMa.js +1 -0
- package/dist/gateway/static/root/assets/agent-browser-settings-page-H4foVCiS.js +6 -0
- package/dist/gateway/static/root/assets/agent-defaults-tabbed-page-DDNw2oNU.js +1 -0
- package/dist/gateway/static/root/assets/agents-E_X2kzS1.js +71 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-BIy7KEsM.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-DGQG8NwA.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-BZLvInLr.js +1 -0
- package/dist/gateway/static/root/assets/archive-plugin-uuQPupqx.js +1 -0
- package/dist/gateway/static/root/assets/attachment-load-DBkv0cAv.js +2 -0
- package/dist/gateway/static/root/assets/{attachment-preview-renderer-CybMSIoS.js → attachment-preview-renderer-DonnL2dL.js} +1 -1
- package/dist/gateway/static/root/assets/binary-plugins-DxxN_VAR.js +2 -0
- package/dist/gateway/static/root/assets/block-editor-CwnUlRmO.js +180 -0
- package/dist/gateway/static/root/assets/channels-settings-BHvUKlzw.js +1 -0
- package/dist/gateway/static/root/assets/cn-JdwAhgNB.js +1 -0
- package/dist/gateway/static/root/assets/code-editor-dZTY2dRW.js +1 -0
- package/dist/gateway/static/root/assets/config-api-BD-NcD5d.js +3 -0
- package/dist/gateway/static/root/assets/config-reload-event-Bjh2zoKp.js +1 -0
- package/dist/gateway/static/root/assets/connectors-settings-VBzXcEXL.js +2 -0
- package/dist/gateway/static/root/assets/cron-api-C5DoipZA.js +1 -0
- package/dist/gateway/static/root/assets/cron-dreaming-jobs-nCMWCf0p.js +1 -0
- package/dist/gateway/static/root/assets/cron-page-BLTpdm34.js +3 -0
- package/dist/gateway/static/root/assets/dist-By6Rh2ee.js +1 -0
- package/dist/gateway/static/root/assets/dist-CkobR7mk.js +1 -0
- package/dist/gateway/static/root/assets/dist-DokQNVMQ.js +1 -0
- package/dist/gateway/static/root/assets/dreaming-scene-BHMRVEUS.js +4585 -0
- package/dist/gateway/static/root/assets/dreaming-settings-DSVhXTPq.js +1 -0
- package/dist/gateway/static/root/assets/extension-debug-page-BDHA9o_e.js +1 -0
- package/dist/gateway/static/root/assets/{extension-page-W1wiG38F.js → extension-page-DmDLVSPE.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-1124aHw_.js +1 -0
- package/dist/gateway/static/root/assets/fetch-DOe56Wmy.js +1 -0
- package/dist/gateway/static/root/assets/format-cron-label-BsotZDO5.js +2 -0
- package/dist/gateway/static/root/assets/format-interval-label-tsMSvBSR.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-CsD4FC9D.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-HQ8FBhY2.js +1 -0
- package/dist/gateway/static/root/assets/gateway-startup-retry-C1zg7pH3.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-BG3Onph0.js +1 -0
- package/dist/gateway/static/root/assets/goals-page-DgeKn8zL.js +2 -0
- package/dist/gateway/static/root/assets/goals-settings-B5nI6lgz.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-config-api-CIv42nJD.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-DFcVuJ3M.js +1 -0
- package/dist/gateway/static/root/assets/html-workspace-editor-CQLWDiwE.js +1 -0
- package/dist/gateway/static/root/assets/index-5A_ZaABy.css +1 -0
- package/dist/gateway/static/root/assets/index-BTmbp2AU.js +121 -0
- package/dist/gateway/static/root/assets/interval-presets-DGP3S7OB.js +1 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-fETaDYQP.js +1 -0
- package/dist/gateway/static/root/assets/locale-store-DjbfSsfA.js +1 -0
- package/dist/gateway/static/root/assets/logs-page-B1-b27lK.js +2 -0
- package/dist/gateway/static/root/assets/markdown-editor-AssmZFx4.js +2 -0
- package/dist/gateway/static/root/assets/markdown-split-CgeBJMOD.js +1 -0
- package/dist/gateway/static/root/assets/media-plugins-C30GzlV2.js +1 -0
- package/dist/gateway/static/root/assets/mermaid-render-BbqDc_LQ.js +134 -0
- package/dist/gateway/static/root/assets/messages-BUUfPaZ9.js +3 -0
- package/dist/gateway/static/root/assets/middleware-Pd0e8Igk.js +1 -0
- package/dist/gateway/static/root/assets/models-hub-panel-DPcTS1-u.js +2 -0
- package/dist/gateway/static/root/assets/note-detail-page-xeGb4owe.js +2 -0
- package/dist/gateway/static/root/assets/note-image-lightbox-t1g0qZYh.js +1 -0
- package/dist/gateway/static/root/assets/note-time-hm6JO_Wi.js +1 -0
- package/dist/gateway/static/root/assets/notes-page-C_TdnKBe.js +1 -0
- package/dist/gateway/static/root/assets/preview-open-alternatives-DeWp9x5g.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-BtkPmJIN.js +1 -0
- package/dist/gateway/static/root/assets/save-bar-controls-BOaAOJI3.js +1 -0
- package/dist/gateway/static/root/assets/schedule-field-BLWLKqgw.js +1 -0
- package/dist/gateway/static/root/assets/schema-form-plqRFYT8.js +1 -0
- package/dist/gateway/static/root/assets/sessions-page-DOUjxzJm.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-qK_bnTrw.js +1 -0
- package/dist/gateway/static/root/assets/settings-collapsible-section-BP5zRrDI.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-Bv8MZplG.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-DmDfE1ww.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-BEFwNcIZ.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-4OX1YCgp.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-CbKmJZot.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-YdtnUHtK.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DwW1IzQ0.js +2 -0
- package/dist/gateway/static/root/assets/system-settings-panel-CGy4f_s2.js +1 -0
- package/dist/gateway/static/root/assets/theme-store-CD2wtgZV.js +1 -0
- package/dist/gateway/static/root/assets/use-agent-defaults-form-BMuMvzl_.js +1 -0
- package/dist/gateway/static/root/assets/use-blob-object-url-D4BFuzZB.js +1 -0
- package/dist/gateway/static/root/assets/use-channel-catalog-CjGHnDvN.js +1 -0
- package/dist/gateway/static/root/assets/use-settings-tab-guard-BMMFa0oA.js +1 -0
- package/dist/gateway/static/root/assets/vendor-codemirror-CNP1wPe7.js +45 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-DnRbhMNq.js +1 -0
- package/dist/gateway/static/root/assets/voice-player-store-D5vzWwls.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-page.utils-EYg_xBQS.js → workflow-page.utils-tjGpRVnw.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-DqqHKGj2.js +18 -0
- 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.ico +0 -0
- package/dist/gateway/static/root/favicon.svg +14 -12
- package/dist/gateway/static/root/index.html +18 -15
- 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/checklist-judge.d.ts +5 -0
- package/dist/src/agent/goals/checklist-judge.js +26 -2
- package/dist/src/agent/goals/checklist-judge.js.map +1 -1
- package/dist/src/agent/goals/evaluate-turn.d.ts +5 -1
- package/dist/src/agent/goals/evaluate-turn.js +29 -3
- package/dist/src/agent/goals/evaluate-turn.js.map +1 -1
- package/dist/src/agent/goals/goal-locale.d.ts +0 -2
- package/dist/src/agent/goals/goal-locale.js +3 -16
- package/dist/src/agent/goals/goal-locale.js.map +1 -1
- package/dist/src/agent/goals/persistent-goal-service.d.ts +9 -0
- package/dist/src/agent/goals/persistent-goal-service.js +3 -2
- package/dist/src/agent/goals/persistent-goal-service.js.map +1 -1
- package/dist/src/agent/goals/post-turn.d.ts +7 -0
- package/dist/src/agent/goals/post-turn.js +70 -25
- package/dist/src/agent/goals/post-turn.js.map +1 -1
- package/dist/src/agent/goals/state.d.ts +0 -5
- package/dist/src/agent/goals/state.js +1 -96
- package/dist/src/agent/goals/state.js.map +1 -1
- 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 +7 -0
- package/dist/src/agent/messaging/command-handler.js +11 -2
- 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/direct-turn-helpers.d.ts +2 -0
- package/dist/src/agent/service/direct-turn-helpers.js +3 -2
- package/dist/src/agent/service/direct-turn-helpers.js.map +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +10 -1
- 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 +30 -6
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/service.types.d.ts +12 -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 +8 -3
- package/dist/src/agent/tools/cronjob-tool.js +82 -24
- 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/edit.d.ts +2 -0
- package/dist/src/agent/tools/edit.js +10 -0
- package/dist/src/agent/tools/edit.js.map +1 -1
- package/dist/src/agent/tools/factory.js +17 -4
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/find.js +1 -1
- package/dist/src/agent/tools/goal-evidence-recorder.d.ts +6 -0
- package/dist/src/agent/tools/goal-evidence-recorder.js +34 -0
- package/dist/src/agent/tools/goal-evidence-recorder.js.map +1 -0
- package/dist/src/agent/tools/goal-tool.d.ts +19 -0
- package/dist/src/agent/tools/goal-tool.js +101 -0
- package/dist/src/agent/tools/goal-tool.js.map +1 -0
- 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/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/agent/tools/shell.d.ts +2 -0
- package/dist/src/agent/tools/shell.js +17 -2
- package/dist/src/agent/tools/shell.js.map +1 -1
- package/dist/src/agent/tools/skill-manage-tool.js +1 -1
- package/dist/src/agent/tools/workflow-tool.d.ts +1 -0
- package/dist/src/agent/tools/workflow-tool.js +11 -3
- package/dist/src/agent/tools/workflow-tool.js.map +1 -1
- package/dist/src/agent/tools/write.d.ts +2 -0
- package/dist/src/agent/tools/write.js +11 -0
- package/dist/src/agent/tools/write.js.map +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 +39 -0
- package/dist/src/ai-assist/text-assist.js +234 -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/attachments/inbound-persist.d.ts +7 -0
- package/dist/src/channels/attachments/inbound-persist.js +20 -2
- package/dist/src/channels/attachments/inbound-persist.js.map +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/chat-commands/agent-edit.js +2 -2
- package/dist/src/chat-commands/builtins/config.js +3 -3
- package/dist/src/chat-commands/builtins/goal.d.ts +1 -1
- package/dist/src/chat-commands/builtins/goal.js +55 -97
- package/dist/src/chat-commands/builtins/goal.js.map +1 -1
- package/dist/src/chat-commands/builtins/subgoal.d.ts +1 -1
- package/dist/src/chat-commands/builtins/subgoal.js +49 -108
- package/dist/src/chat-commands/builtins/subgoal.js.map +1 -1
- 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/builtins/workflow.js +132 -8
- package/dist/src/chat-commands/builtins/workflow.js.map +1 -1
- package/dist/src/chat-commands/context.d.ts +6 -0
- package/dist/src/chat-commands/context.js +12 -0
- package/dist/src/chat-commands/context.js.map +1 -1
- package/dist/src/chat-commands/types.d.ts +7 -0
- package/dist/src/cli/command-catalog.js +43 -0
- package/dist/src/cli/command-catalog.js.map +1 -1
- package/dist/src/cli/command-loaders.js +1 -0
- package/dist/src/cli/command-loaders.js.map +1 -1
- package/dist/src/cli/command-manifest.js +4 -0
- package/dist/src/cli/command-manifest.js.map +1 -1
- 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/goal.d.ts +4 -0
- package/dist/src/cli/commands/goal.js +213 -0
- package/dist/src/cli/commands/goal.js.map +1 -0
- 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/onboard.js +11 -5
- package/dist/src/cli/commands/onboard.js.map +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 +8 -8
- 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 +115 -2
- package/dist/src/config/schema.js +63 -7
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/config/web-patch.d.ts +14 -1
- package/dist/src/config/web-patch.js +45 -8
- package/dist/src/config/web-patch.js.map +1 -1
- package/dist/src/config/workspace-path.js +1 -1
- package/dist/src/cron/executor.d.ts +2 -0
- package/dist/src/cron/executor.js +126 -70
- 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/job-content.js +1 -0
- package/dist/src/cron/job-content.js.map +1 -1
- 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 +97 -49
- package/dist/src/cron/validation.d.ts +374 -86
- package/dist/src/cron/validation.js +156 -129
- 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 +14 -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/goals.d.ts +1 -1
- package/dist/src/gateway/hono/routes/goals.js +670 -173
- package/dist/src/gateway/hono/routes/goals.js.map +1 -1
- package/dist/src/gateway/hono/routes/home.d.ts +5 -0
- package/dist/src/gateway/hono/routes/home.js +90 -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/notes.js +20 -14
- package/dist/src/gateway/hono/routes/notes.js.map +1 -1
- package/dist/src/gateway/hono/routes/shares.js +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +8 -4
- package/dist/src/gateway/hono/routes/workflows.js.map +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +2 -2
- package/dist/src/gateway/hono/sse.js.map +1 -1
- package/dist/src/gateway/lock.js +3 -3
- package/dist/src/gateway/ports.js +1 -1
- package/dist/src/gateway/service/agent-runner.d.ts +2 -0
- package/dist/src/gateway/service/agent-runner.js +8 -4
- package/dist/src/gateway/service/agent-runner.js.map +1 -1
- 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/run-gateway-agent.d.ts +3 -0
- package/dist/src/gateway/service/run-gateway-agent.js.map +1 -1
- package/dist/src/gateway/service.d.ts +8 -0
- package/dist/src/gateway/service.js +79 -6
- 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.d.ts +29 -0
- package/dist/src/goals/goal-notifications.js +154 -0
- package/dist/src/goals/goal-notifications.js.map +1 -0
- package/dist/src/goals/goal-queue-store.d.ts +16 -0
- package/dist/src/goals/goal-queue-store.js +131 -0
- package/dist/src/goals/goal-queue-store.js.map +1 -0
- package/dist/src/goals/goal-queue-types.d.ts +31 -0
- package/dist/src/goals/goal-queue-types.js +1 -0
- package/dist/src/goals/goal-runner.d.ts +17 -0
- package/dist/src/goals/goal-runner.js +127 -0
- package/dist/src/goals/goal-runner.js.map +1 -0
- package/dist/src/goals/goal-service.d.ts +77 -0
- package/dist/src/goals/goal-service.js +261 -0
- package/dist/src/goals/goal-service.js.map +1 -0
- package/dist/src/goals/goal-store.d.ts +38 -0
- package/dist/src/goals/goal-store.js +404 -0
- package/dist/src/goals/goal-store.js.map +1 -0
- package/dist/src/goals/goal-workflow-judge.d.ts +13 -0
- package/dist/src/goals/goal-workflow-judge.js +147 -0
- package/dist/src/goals/goal-workflow-judge.js.map +1 -0
- package/dist/src/goals/index.d.ts +10 -0
- package/dist/src/goals/index.js +7 -0
- package/dist/src/goals/types.d.ts +119 -0
- package/dist/src/goals/types.js +1 -0
- 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.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/006_add_goals.sql +108 -0
- package/dist/src/storage/sqlite/migrations/007_goal_run_judge_schema.sql +4 -0
- package/dist/src/storage/sqlite/migrations/008_goal_queue_workflow_runs.sql +53 -0
- 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 +188 -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/stats.d.ts +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/domain/run.d.ts +1 -0
- package/dist/src/workflows/domain/run.js.map +1 -1
- 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.d.ts +1 -0
- package/dist/src/workflows/service/workflow-run-service.js +7 -3
- package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
- package/dist/src/workflows/service/workflow-run-service.types.d.ts +1 -0
- package/dist/src/workflows/service/workflow-session-bridge.js +8 -1
- package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
- package/dist/src/workflows/store/event-store.js +1 -1
- package/dist/src/workflows/store/run-index-store.d.ts +8 -0
- package/dist/src/workflows/store/run-index-store.js +58 -0
- package/dist/src/workflows/store/run-index-store.js.map +1 -0
- package/dist/src/workflows/store/run-store.d.ts +2 -0
- package/dist/src/workflows/store/run-store.js +15 -22
- package/dist/src/workflows/store/run-store.js.map +1 -1
- package/package.json +10 -5
- package/dist/gateway/static/root/assets/Combination-HAlzriaz.js +0 -41
- package/dist/gateway/static/root/assets/agents-CFFioJCI.js +0 -78
- package/dist/gateway/static/root/assets/apps-page-BYDmkbzG.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-CsbDaMvd.js +0 -1
- package/dist/gateway/static/root/assets/circle-check-C23XjkUj.js +0 -1
- package/dist/gateway/static/root/assets/copy-Dv6d4Dvw.js +0 -1
- package/dist/gateway/static/root/assets/cron-page-Apk-7p4p.js +0 -1
- package/dist/gateway/static/root/assets/dist-DmGDgpy2.js +0 -1
- package/dist/gateway/static/root/assets/extension-debug-page-pxFC-tUa.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-COXSv6xP.js +0 -1
- package/dist/gateway/static/root/assets/fetch-CFdKBnE6.js +0 -1
- package/dist/gateway/static/root/assets/gateway-startup-retry-DdngdObI.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-config-api-DcmAMYmN.js +0 -1
- package/dist/gateway/static/root/assets/index-C_2yKRJX.js +0 -4845
- package/dist/gateway/static/root/assets/index-DI5_GsZt.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-DvTWUOzd.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-page-CZbdugWZ.js +0 -180
- package/dist/gateway/static/root/assets/note-time-RdyBZxj3.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-mEAwy3e1.js +0 -1
- package/dist/gateway/static/root/assets/schema-form-DEvdni_r.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BsgffzV4.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-t6v8Dwb8.js +0 -2
- package/dist/gateway/static/root/assets/settings-form-section-BoYYZmJG.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-ClIthYF8.js +0 -3
- package/dist/gateway/static/root/assets/share-preview-page-Dd9et7KD.js +0 -2
- package/dist/gateway/static/root/assets/skills-page-DEXtxyfQ.js +0 -2
- package/dist/gateway/static/root/assets/theme-store-BZozwAeK.js +0 -1
- package/dist/gateway/static/root/assets/url-DQRqHuL-.js +0 -3
- package/dist/gateway/static/root/assets/vendor-codemirror-DYoKfS8f.js +0 -45
- package/dist/gateway/static/root/assets/voice-api-key-field-CNrKzQrf.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-EMZkzJNN.js +0 -18
- package/dist/gateway/static/root/favicon-16.png +0 -0
- package/dist/gateway/static/root/favicon-32.png +0 -0
- package/dist/src/agent/goals/checklist-user.d.ts +0 -24
- package/dist/src/agent/goals/checklist-user.js +0 -92
- package/dist/src/agent/goals/checklist-user.js.map +0 -1
- package/dist/src/agent/goals/goal-run-store.d.ts +0 -19
- package/dist/src/agent/goals/goal-run-store.js +0 -138
- package/dist/src/agent/goals/goal-run-store.js.map +0 -1
- package/dist/src/agent/goals/goal-run-types.d.ts +0 -28
- package/dist/src/agent/goals/goal-run-types.js +0 -6
- package/dist/src/agent/goals/goal-run-types.js.map +0 -1
- package/dist/src/agent/goals/patch-from-user-action.d.ts +0 -20
- package/dist/src/agent/goals/patch-from-user-action.js +0 -103
- package/dist/src/agent/goals/patch-from-user-action.js.map +0 -1
- 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/gateway/static/root/assets/{note-detail-page-D4ZIVQbk.css → block-editor-D4ZIVQbk.css} +0 -0
|
@@ -1,224 +1,721 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import { buildSessionKey, init_session_key, sanitizeSegment } from "../../../routing/session-key.js";
|
|
2
|
+
import { getDefaultAgentId, init_resolve_route } from "../../../routing/resolve-route.js";
|
|
3
|
+
import { createWorkflowCatalog } from "../../../agent/workflow/catalog.js";
|
|
4
|
+
import { GoalService, normalizeGoalUiLocale } from "../../../goals/goal-service.js";
|
|
5
|
+
import "../../../goals/index.js";
|
|
6
6
|
//#region src/gateway/hono/routes/goals.ts
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
init_session_key();
|
|
8
|
+
init_resolve_route();
|
|
9
|
+
function parseLimit(raw, fallback = 50) {
|
|
10
|
+
if (!raw) return fallback;
|
|
11
|
+
const n = Number.parseInt(raw, 10);
|
|
12
|
+
return Number.isFinite(n) ? Math.min(500, Math.max(1, n)) : fallback;
|
|
9
13
|
}
|
|
10
|
-
|
|
14
|
+
function parseStatuses(raw) {
|
|
15
|
+
if (!raw?.trim()) return void 0;
|
|
16
|
+
const statuses = raw.split(",").map((s) => s.trim()).filter((s) => s === "active" || s === "paused" || s === "blocked" || s === "needs_input" || s === "done" || s === "archived");
|
|
17
|
+
return statuses.length ? statuses : void 0;
|
|
18
|
+
}
|
|
19
|
+
function parseBodyGoalStatus(raw) {
|
|
20
|
+
return raw === "active" || raw === "paused" || raw === "blocked" || raw === "needs_input" || raw === "done" || raw === "archived" ? raw : null;
|
|
21
|
+
}
|
|
22
|
+
function parsePriority(raw) {
|
|
23
|
+
return raw === "low" || raw === "normal" || raw === "high" ? raw : void 0;
|
|
24
|
+
}
|
|
25
|
+
const STOP_WORDS = new Set([
|
|
26
|
+
"a",
|
|
27
|
+
"an",
|
|
28
|
+
"and",
|
|
29
|
+
"are",
|
|
30
|
+
"as",
|
|
31
|
+
"for",
|
|
32
|
+
"in",
|
|
33
|
+
"is",
|
|
34
|
+
"of",
|
|
35
|
+
"on",
|
|
36
|
+
"or",
|
|
37
|
+
"the",
|
|
38
|
+
"to",
|
|
39
|
+
"with",
|
|
40
|
+
"一个",
|
|
41
|
+
"这个",
|
|
42
|
+
"需要",
|
|
43
|
+
"进行",
|
|
44
|
+
"推进"
|
|
45
|
+
]);
|
|
46
|
+
function tokenizeForWorkflowMatch(text) {
|
|
47
|
+
return (text.toLowerCase().match(/[\p{L}\p{N}_-]+/gu) ?? []).map((token) => token.trim()).filter((token) => token.length >= 2 && !STOP_WORDS.has(token));
|
|
48
|
+
}
|
|
49
|
+
function goalSearchText(goal) {
|
|
50
|
+
return [
|
|
51
|
+
goal.title,
|
|
52
|
+
goal.description,
|
|
53
|
+
goal.nextAction,
|
|
54
|
+
goal.blockedReason,
|
|
55
|
+
...goal.checklist.map((item) => `${item.text} ${item.evidenceSummary ?? ""}`)
|
|
56
|
+
].filter(Boolean).join("\n");
|
|
57
|
+
}
|
|
58
|
+
function buildGoalWorkflowSuggestions(params) {
|
|
59
|
+
const goalTokens = new Set(tokenizeForWorkflowMatch(goalSearchText(params.goal)));
|
|
60
|
+
const runsByDefinition = /* @__PURE__ */ new Map();
|
|
61
|
+
for (const run of params.workflowRuns) {
|
|
62
|
+
const list = runsByDefinition.get(run.definitionId) ?? [];
|
|
63
|
+
list.push(run);
|
|
64
|
+
runsByDefinition.set(run.definitionId, list);
|
|
65
|
+
}
|
|
66
|
+
const suggestions = [];
|
|
67
|
+
for (const entry of createWorkflowCatalog().list()) {
|
|
68
|
+
const candidateText = [
|
|
69
|
+
entry.name,
|
|
70
|
+
entry.title,
|
|
71
|
+
entry.description,
|
|
72
|
+
entry.whenToUse,
|
|
73
|
+
...entry.tags ?? []
|
|
74
|
+
].filter(Boolean).join("\n");
|
|
75
|
+
const candidateTokens = new Set(tokenizeForWorkflowMatch(candidateText));
|
|
76
|
+
const matched = [...goalTokens].filter((token) => candidateTokens.has(token));
|
|
77
|
+
const relatedRuns = runsByDefinition.get(entry.name) ?? [];
|
|
78
|
+
const terminalRuns = relatedRuns.filter((run) => run.status !== "queued" && run.status !== "running");
|
|
79
|
+
const succeededRuns = terminalRuns.filter((run) => run.status === "succeeded");
|
|
80
|
+
const successRate = terminalRuns.length ? succeededRuns.length / terminalRuns.length : void 0;
|
|
81
|
+
const lastRun = relatedRuns.toSorted((left, right) => right.createdAtMs - left.createdAtMs)[0];
|
|
82
|
+
let score = matched.length * 8;
|
|
83
|
+
if (entry.tags?.some((tag) => goalTokens.has(tag.toLowerCase()))) score += 8;
|
|
84
|
+
if (entry.whenToUse && matched.length > 0) score += 4;
|
|
85
|
+
if (successRate != null) score += Math.round(successRate * 10);
|
|
86
|
+
if (lastRun?.status === "succeeded") score += 4;
|
|
87
|
+
if (lastRun?.status === "failed" || lastRun?.status === "timeout") score -= 3;
|
|
88
|
+
if (score <= 0) score = entry.source === "builtin" ? 1 : 0;
|
|
89
|
+
const reasons = [];
|
|
90
|
+
if (matched.length) reasons.push(`matches ${matched.slice(0, 4).join(", ")}`);
|
|
91
|
+
if (successRate != null) reasons.push(`${Math.round(successRate * 100)}% success rate`);
|
|
92
|
+
if (lastRun) reasons.push(`last run ${lastRun.status}`);
|
|
93
|
+
if (!reasons.length && entry.whenToUse) reasons.push("general workflow fit");
|
|
94
|
+
if (score > 0) suggestions.push({
|
|
95
|
+
definitionId: entry.name,
|
|
96
|
+
name: entry.name,
|
|
97
|
+
title: entry.title || entry.name,
|
|
98
|
+
description: entry.description,
|
|
99
|
+
score,
|
|
100
|
+
reasons,
|
|
101
|
+
tags: entry.tags ?? [],
|
|
102
|
+
successRate,
|
|
103
|
+
lastRunStatus: lastRun?.status
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
return suggestions.sort((left, right) => right.score - left.score || left.name.localeCompare(right.name)).slice(0, 5);
|
|
107
|
+
}
|
|
108
|
+
function buildGoalActivities(input) {
|
|
109
|
+
const activities = [];
|
|
110
|
+
for (const item of input.queue.filter((queueItem) => queueItem.goalId === input.goalId)) activities.push({
|
|
111
|
+
id: `queue:${item.id}`,
|
|
112
|
+
kind: "queue",
|
|
113
|
+
status: item.status,
|
|
114
|
+
title: "Goal queued",
|
|
115
|
+
summary: item.lastError || item.message || void 0,
|
|
116
|
+
createdAt: item.finishedAt ?? item.startedAt ?? item.nextRunAt ?? item.enqueuedAt,
|
|
117
|
+
link: item.sessionKey ? {
|
|
118
|
+
type: "chat",
|
|
119
|
+
value: item.sessionKey
|
|
120
|
+
} : void 0,
|
|
121
|
+
data: item
|
|
122
|
+
});
|
|
123
|
+
for (const run of input.runs) activities.push({
|
|
124
|
+
id: `goal_run:${run.id}`,
|
|
125
|
+
kind: "goal_run",
|
|
126
|
+
status: run.verdict ?? run.status,
|
|
127
|
+
title: "Goal run judged",
|
|
128
|
+
summary: run.reason || run.assistantPreview || run.nextAction,
|
|
129
|
+
createdAt: run.finishedAt ?? run.startedAt,
|
|
130
|
+
data: run
|
|
131
|
+
});
|
|
132
|
+
for (const run of input.workflowRuns) activities.push({
|
|
133
|
+
id: `workflow_run:${run.id}`,
|
|
134
|
+
kind: "workflow_run",
|
|
135
|
+
status: run.status,
|
|
136
|
+
title: run.title || run.definitionId,
|
|
137
|
+
summary: run.definitionId,
|
|
138
|
+
createdAt: run.completedAtMs ?? run.startedAtMs ?? run.createdAtMs,
|
|
139
|
+
link: {
|
|
140
|
+
type: "workflow_run",
|
|
141
|
+
value: run.id
|
|
142
|
+
},
|
|
143
|
+
data: run
|
|
144
|
+
});
|
|
145
|
+
for (const event of input.events) activities.push({
|
|
146
|
+
id: `event:${event.id}`,
|
|
147
|
+
kind: "event",
|
|
148
|
+
status: event.kind,
|
|
149
|
+
title: event.kind,
|
|
150
|
+
summary: event.message,
|
|
151
|
+
createdAt: event.createdAt,
|
|
152
|
+
data: event
|
|
153
|
+
});
|
|
154
|
+
for (const item of input.evidence) activities.push({
|
|
155
|
+
id: `evidence:${item.id}`,
|
|
156
|
+
kind: "evidence",
|
|
157
|
+
status: item.kind,
|
|
158
|
+
title: item.title,
|
|
159
|
+
summary: item.summary || item.uri,
|
|
160
|
+
createdAt: item.createdAt,
|
|
161
|
+
data: item
|
|
162
|
+
});
|
|
163
|
+
return activities.sort((left, right) => right.createdAt - left.createdAt).slice(0, input.limit);
|
|
164
|
+
}
|
|
165
|
+
function abortActiveWebchatRunForGoal(deps, goal) {
|
|
166
|
+
const sessionKey = goal.activeSessionKey?.trim();
|
|
167
|
+
if (!sessionKey) return {};
|
|
168
|
+
const runId = deps.service.getActiveWebchatRunId(sessionKey);
|
|
169
|
+
if (!runId) return {};
|
|
170
|
+
return {
|
|
171
|
+
abortedRunId: runId,
|
|
172
|
+
aborted: deps.service.abortAgentRun(runId)
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/** First-class Goal API. Sessions are execution context; goals are durable product objects. */
|
|
11
176
|
function registerGoalsRoutes(authenticated, deps) {
|
|
12
|
-
const
|
|
177
|
+
const goals = new GoalService();
|
|
13
178
|
const cfg = () => deps.service.currentConfig;
|
|
14
|
-
|
|
179
|
+
const workflowRunService = deps.service.createWorkflowRunService();
|
|
180
|
+
authenticated.get("/api/goals/current", async (c) => {
|
|
15
181
|
const sessionKey = c.req.query("sessionKey")?.trim();
|
|
16
182
|
if (!sessionKey) return c.json({
|
|
17
183
|
ok: false,
|
|
18
184
|
error: "Missing sessionKey"
|
|
19
185
|
}, 400);
|
|
20
|
-
const uiLocale = normalizeGoalUiLocale(c.req.query("uiLocale"));
|
|
21
|
-
let m = await sm.getSessionMetadata(sessionKey);
|
|
22
|
-
if (uiLocale && m) {
|
|
23
|
-
const merged = mergePersistentGoalUiLocale(m.customData, uiLocale);
|
|
24
|
-
if (merged !== m.customData) {
|
|
25
|
-
await sm.updateSessionMetadata(sessionKey, { customData: merged });
|
|
26
|
-
m = await sm.getSessionMetadata(sessionKey);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const goal = readPersistentGoal(m?.customData);
|
|
30
186
|
return c.json({
|
|
31
187
|
ok: true,
|
|
32
|
-
sessionKey
|
|
33
|
-
persistentGoal: goal
|
|
188
|
+
goal: goals.getActiveForSession(sessionKey)
|
|
34
189
|
});
|
|
35
190
|
});
|
|
36
|
-
authenticated.get("/api/goals
|
|
37
|
-
const
|
|
38
|
-
|
|
191
|
+
authenticated.get("/api/goals", async (c) => {
|
|
192
|
+
const status = parseStatuses(c.req.query("status"));
|
|
193
|
+
const agentId = c.req.query("agentId")?.trim() || void 0;
|
|
194
|
+
const sessionKey = c.req.query("sessionKey")?.trim() || void 0;
|
|
195
|
+
const limit = parseLimit(c.req.query("limit"));
|
|
196
|
+
const offsetRaw = c.req.query("offset")?.trim();
|
|
197
|
+
const offset = offsetRaw ? Math.max(0, Number.parseInt(offsetRaw, 10) || 0) : 0;
|
|
198
|
+
return c.json({
|
|
199
|
+
ok: true,
|
|
200
|
+
goals: goals.list({
|
|
201
|
+
status,
|
|
202
|
+
agentId,
|
|
203
|
+
sessionKey,
|
|
204
|
+
limit,
|
|
205
|
+
offset
|
|
206
|
+
})
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
authenticated.get("/api/goals/queue", async (c) => {
|
|
210
|
+
return c.json({
|
|
211
|
+
ok: true,
|
|
212
|
+
queue: deps.service.getGoalQueueSnapshot()
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
authenticated.post("/api/goals", async (c) => {
|
|
216
|
+
const body = await c.req.json().catch(() => ({}));
|
|
217
|
+
const title = typeof body.title === "string" ? body.title.trim() : "";
|
|
218
|
+
if (!title) return c.json({
|
|
39
219
|
ok: false,
|
|
40
|
-
error: "Missing
|
|
220
|
+
error: "Missing title"
|
|
41
221
|
}, 400);
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
222
|
+
const sessionKey = typeof body.sessionKey === "string" && body.sessionKey.trim() ? body.sessionKey.trim() : void 0;
|
|
223
|
+
const agentId = typeof body.agentId === "string" && body.agentId.trim() ? body.agentId.trim() : sessionKey ? void 0 : getDefaultAgentId(cfg());
|
|
224
|
+
const maxTurns = typeof body.maxTurns === "number" && Number.isFinite(body.maxTurns) ? Math.max(1, Math.min(500, Math.floor(body.maxTurns))) : void 0;
|
|
225
|
+
const goal = goals.create({
|
|
226
|
+
title,
|
|
227
|
+
description: typeof body.description === "string" ? body.description : void 0,
|
|
228
|
+
sessionKey,
|
|
229
|
+
agentId,
|
|
230
|
+
priority: body.priority === "low" || body.priority === "high" ? body.priority : "normal",
|
|
231
|
+
deadlineAt: typeof body.deadlineAt === "number" && Number.isFinite(body.deadlineAt) ? body.deadlineAt : void 0,
|
|
232
|
+
judgeModelRef: typeof body.judgeModelRef === "string" ? body.judgeModelRef : void 0,
|
|
233
|
+
maxTurns,
|
|
234
|
+
uiLocale: normalizeGoalUiLocale(body.uiLocale),
|
|
235
|
+
source: body.source === "cli" || body.source === "cron" || body.source === "workflow" || body.source === "channel" || body.source === "api" ? body.source : "chat",
|
|
236
|
+
config: cfg()
|
|
237
|
+
});
|
|
238
|
+
if (sessionKey) deps.service.enqueueWebchatPersistentGoalKickoff(sessionKey, title);
|
|
239
|
+
return c.json({
|
|
240
|
+
ok: true,
|
|
241
|
+
goal: goals.get(goal.id)
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
authenticated.get("/api/goals/:goalId/workflow-runs", async (c) => {
|
|
245
|
+
const goalId = c.req.param("goalId");
|
|
246
|
+
const goal = goals.get(goalId);
|
|
247
|
+
if (!goal) return c.json({
|
|
248
|
+
ok: false,
|
|
249
|
+
error: "Goal not found"
|
|
250
|
+
}, 404);
|
|
251
|
+
const runs = await workflowRunService.createRunStore(goal.agentId || getDefaultAgentId(cfg())).listRunSummariesForGoal(goalId, parseLimit(c.req.query("limit")));
|
|
49
252
|
return c.json({
|
|
50
253
|
ok: true,
|
|
51
|
-
sessionKey,
|
|
52
254
|
runs
|
|
53
255
|
});
|
|
54
256
|
});
|
|
55
|
-
authenticated.post("/api/goals/
|
|
257
|
+
authenticated.post("/api/goals/:goalId/workflows/run", async (c) => {
|
|
258
|
+
const goalId = c.req.param("goalId");
|
|
259
|
+
const goal = goals.get(goalId);
|
|
260
|
+
if (!goal) return c.json({
|
|
261
|
+
ok: false,
|
|
262
|
+
error: "Goal not found"
|
|
263
|
+
}, 404);
|
|
264
|
+
if (goal.status === "done" || goal.status === "archived") return c.json({
|
|
265
|
+
ok: false,
|
|
266
|
+
error: `Goal is ${goal.status}`
|
|
267
|
+
}, 409);
|
|
56
268
|
const body = await c.req.json().catch(() => ({}));
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
269
|
+
const definitionId = typeof body.definitionId === "string" ? body.definitionId.trim() : "";
|
|
270
|
+
if (!definitionId) return c.json({
|
|
59
271
|
ok: false,
|
|
60
|
-
error: "Missing
|
|
272
|
+
error: "Missing definitionId"
|
|
61
273
|
}, 400);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const meta = await sm.getSessionMetadata(sessionKey);
|
|
66
|
-
if (!meta) return c.json({
|
|
67
|
-
ok: false,
|
|
68
|
-
error: "Session not found"
|
|
69
|
-
}, 404);
|
|
70
|
-
const applied = applyPersistentGoalUserAction(meta.customData, actionRaw, goalsSlice);
|
|
71
|
-
if (applied.kind === "error") return c.json({
|
|
72
|
-
ok: false,
|
|
73
|
-
error: applied.error
|
|
74
|
-
}, 400);
|
|
75
|
-
if (applied.kind === "noop") {
|
|
76
|
-
const persistentGoal = readPersistentGoal(meta.customData);
|
|
77
|
-
return c.json({
|
|
78
|
-
ok: true,
|
|
79
|
-
sessionKey,
|
|
80
|
-
noop: true,
|
|
81
|
-
message: applied.message,
|
|
82
|
-
persistentGoal
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
const uiLocale = normalizeGoalUiLocale(body.uiLocale);
|
|
86
|
-
const customData = uiLocale != null ? mergePersistentGoalUiLocale(applied.customData, uiLocale) ?? applied.customData : applied.customData;
|
|
87
|
-
await sm.updateSessionMetadata(sessionKey, { customData });
|
|
88
|
-
const persistentGoal = readPersistentGoal((await sm.getSessionMetadata(sessionKey))?.customData);
|
|
89
|
-
if (applied.kickoff) deps.service.enqueueWebchatPersistentGoalKickoff(sessionKey, applied.kickoff);
|
|
274
|
+
try {
|
|
275
|
+
createWorkflowCatalog().load(definitionId);
|
|
276
|
+
} catch {
|
|
90
277
|
return c.json({
|
|
91
|
-
ok: true,
|
|
92
|
-
sessionKey,
|
|
93
|
-
action: actionRaw,
|
|
94
|
-
persistentGoal
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
if (body.clear === true) {
|
|
98
|
-
const meta = await sm.getSessionMetadata(sessionKey);
|
|
99
|
-
if (!meta) return c.json({
|
|
100
278
|
ok: false,
|
|
101
|
-
error: "
|
|
279
|
+
error: "Workflow definition not found"
|
|
102
280
|
}, 404);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
281
|
+
}
|
|
282
|
+
const result = await workflowRunService.startWorkflowRun({
|
|
283
|
+
agentId: goal.agentId || getDefaultAgentId(cfg()),
|
|
284
|
+
definitionId,
|
|
285
|
+
goalId,
|
|
286
|
+
goal: typeof body.goal === "string" && body.goal.trim() ? body.goal.trim() : goal.nextAction || goal.title,
|
|
287
|
+
input: body.input ?? {
|
|
288
|
+
goal: goal.title,
|
|
289
|
+
description: goal.description,
|
|
290
|
+
nextAction: goal.nextAction,
|
|
291
|
+
checklist: goal.checklist.map((item) => ({
|
|
292
|
+
text: item.text,
|
|
293
|
+
status: item.status,
|
|
294
|
+
evidenceSummary: item.evidenceSummary
|
|
295
|
+
}))
|
|
296
|
+
},
|
|
297
|
+
parentSessionKey: goal.activeSessionKey,
|
|
298
|
+
source: { kind: "webui" },
|
|
299
|
+
concurrency: typeof body.concurrency === "number" ? body.concurrency : void 0,
|
|
300
|
+
maxSubagents: typeof body.maxSubagents === "number" ? body.maxSubagents : void 0
|
|
301
|
+
});
|
|
302
|
+
if (result.ok === false) return c.json({
|
|
303
|
+
ok: false,
|
|
304
|
+
error: result.message,
|
|
305
|
+
code: result.code
|
|
306
|
+
}, result.httpStatus);
|
|
307
|
+
return c.json({
|
|
308
|
+
ok: true,
|
|
309
|
+
runId: result.runId,
|
|
310
|
+
sessionKey: result.sessionKey
|
|
311
|
+
}, 202);
|
|
312
|
+
});
|
|
313
|
+
authenticated.get("/api/goals/:goalId/activity", async (c) => {
|
|
314
|
+
const goalId = c.req.param("goalId");
|
|
315
|
+
const goal = goals.get(goalId);
|
|
316
|
+
if (!goal) return c.json({
|
|
317
|
+
ok: false,
|
|
318
|
+
error: "Goal not found"
|
|
319
|
+
}, 404);
|
|
320
|
+
const limit = parseLimit(c.req.query("limit"), 100);
|
|
321
|
+
const workflowRuns = await workflowRunService.createRunStore(goal.agentId || getDefaultAgentId(cfg())).listRunSummariesForGoal(goalId, limit);
|
|
322
|
+
const activities = buildGoalActivities({
|
|
323
|
+
goalId,
|
|
324
|
+
queue: deps.service.getGoalQueueSnapshot(),
|
|
325
|
+
runs: goals.listRuns(goalId, limit),
|
|
326
|
+
workflowRuns,
|
|
327
|
+
events: goals.listEvents(goalId, limit),
|
|
328
|
+
evidence: goals.listEvidence(goalId, limit),
|
|
329
|
+
limit
|
|
330
|
+
});
|
|
331
|
+
return c.json({
|
|
332
|
+
ok: true,
|
|
333
|
+
activities
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
authenticated.get("/api/goals/:goalId/workflow-suggestions", async (c) => {
|
|
337
|
+
const goalId = c.req.param("goalId");
|
|
338
|
+
const goal = goals.get(goalId);
|
|
339
|
+
if (!goal) return c.json({
|
|
340
|
+
ok: false,
|
|
341
|
+
error: "Goal not found"
|
|
342
|
+
}, 404);
|
|
343
|
+
const workflowRuns = await workflowRunService.createRunStore(goal.agentId || getDefaultAgentId(cfg())).listRunSummaries(500);
|
|
344
|
+
return c.json({
|
|
345
|
+
ok: true,
|
|
346
|
+
suggestions: buildGoalWorkflowSuggestions({
|
|
347
|
+
goal,
|
|
348
|
+
workflowRuns
|
|
349
|
+
})
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
authenticated.get("/api/goals/:goalId", async (c) => {
|
|
353
|
+
const goal = goals.get(c.req.param("goalId"));
|
|
354
|
+
if (!goal) return c.json({
|
|
355
|
+
ok: false,
|
|
356
|
+
error: "Goal not found"
|
|
357
|
+
}, 404);
|
|
358
|
+
return c.json({
|
|
359
|
+
ok: true,
|
|
360
|
+
goal
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
authenticated.patch("/api/goals/:goalId", async (c) => {
|
|
364
|
+
const goalId = c.req.param("goalId");
|
|
365
|
+
const body = await c.req.json().catch(() => ({}));
|
|
366
|
+
const status = parseBodyGoalStatus(body.status);
|
|
367
|
+
let goal = goals.get(goalId);
|
|
368
|
+
if (!goal) return c.json({
|
|
369
|
+
ok: false,
|
|
370
|
+
error: "Goal not found"
|
|
371
|
+
}, 404);
|
|
372
|
+
const patch = {};
|
|
373
|
+
if (typeof body.title === "string") patch.title = body.title;
|
|
374
|
+
if ("description" in body) patch.description = typeof body.description === "string" ? body.description : void 0;
|
|
375
|
+
const priority = parsePriority(body.priority);
|
|
376
|
+
if (priority) patch.priority = priority;
|
|
377
|
+
if ("deadlineAt" in body) patch.deadlineAt = typeof body.deadlineAt === "number" && Number.isFinite(body.deadlineAt) ? body.deadlineAt : void 0;
|
|
378
|
+
if (typeof body.maxTurns === "number" && Number.isFinite(body.maxTurns)) patch.maxTurns = body.maxTurns;
|
|
379
|
+
if ("judgeModelRef" in body) patch.judgeModelRef = typeof body.judgeModelRef === "string" ? body.judgeModelRef : void 0;
|
|
380
|
+
if ("nextAction" in body) patch.nextAction = typeof body.nextAction === "string" ? body.nextAction : void 0;
|
|
381
|
+
if ("blockedReason" in body) patch.blockedReason = typeof body.blockedReason === "string" ? body.blockedReason : void 0;
|
|
382
|
+
const locale = normalizeGoalUiLocale(body.uiLocale);
|
|
383
|
+
if (locale) patch.uiLocale = locale;
|
|
384
|
+
if (Object.keys(patch).length > 0) goal = goals.update(goalId, patch);
|
|
385
|
+
if (status) {
|
|
386
|
+
const previousStatus = goal?.status;
|
|
387
|
+
goal = goals.setStatus(goalId, status, { reason: typeof body.reason === "string" ? body.reason : void 0 });
|
|
388
|
+
const abortResult = goal && status === "archived" ? abortActiveWebchatRunForGoal(deps, goal) : {};
|
|
389
|
+
if (goal && previousStatus !== goal.status) deps.service.emit("goal.status.updated", {
|
|
390
|
+
goalId,
|
|
391
|
+
previousStatus,
|
|
392
|
+
status: goal.status,
|
|
393
|
+
goal
|
|
394
|
+
});
|
|
106
395
|
return c.json({
|
|
107
396
|
ok: true,
|
|
108
|
-
|
|
109
|
-
|
|
397
|
+
goal,
|
|
398
|
+
...abortResult
|
|
110
399
|
});
|
|
111
400
|
}
|
|
112
|
-
|
|
113
|
-
|
|
401
|
+
return c.json({
|
|
402
|
+
ok: true,
|
|
403
|
+
goal
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
authenticated.post("/api/goals/:goalId/continue", async (c) => {
|
|
407
|
+
const goalId = c.req.param("goalId");
|
|
408
|
+
const body = await c.req.json().catch(() => ({}));
|
|
409
|
+
const goal = goals.get(goalId);
|
|
410
|
+
if (!goal) return c.json({
|
|
114
411
|
ok: false,
|
|
115
|
-
error: "
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
if (!
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
...uiLocale ? { uiLocale } : {}
|
|
136
|
-
};
|
|
137
|
-
const customData = mergeCustomDataPatch({ ...meta.customData }, { [PERSISTENT_GOAL_CUSTOM_KEY]: serializePersistentGoal(next) });
|
|
138
|
-
await sm.updateSessionMetadata(sessionKey, { customData });
|
|
139
|
-
const persistentGoal = readPersistentGoal((await sm.getSessionMetadata(sessionKey))?.customData);
|
|
140
|
-
deps.service.enqueueWebchatPersistentGoalKickoff(sessionKey, goalText);
|
|
412
|
+
error: "Goal not found"
|
|
413
|
+
}, 404);
|
|
414
|
+
let sessionKey = typeof body.sessionKey === "string" && body.sessionKey.trim() ? body.sessionKey.trim() : goal.activeSessionKey;
|
|
415
|
+
if (!sessionKey) {
|
|
416
|
+
sessionKey = buildSessionKey({
|
|
417
|
+
agentId: goal.agentId || getDefaultAgentId(cfg()),
|
|
418
|
+
source: "webchat",
|
|
419
|
+
accountId: "default",
|
|
420
|
+
peerKind: "direct",
|
|
421
|
+
peerId: `goal-${sanitizeSegment(goal.id) || Date.now()}`
|
|
422
|
+
});
|
|
423
|
+
await deps.service.sessionIndexInstance.saveMessages(sessionKey, []);
|
|
424
|
+
goals.attachSession(goalId, sessionKey);
|
|
425
|
+
}
|
|
426
|
+
const queued = deps.service.enqueueGoalRun(goalId, {
|
|
427
|
+
message: typeof body.message === "string" ? body.message : void 0,
|
|
428
|
+
maxRetries: typeof body.maxRetries === "number" && Number.isFinite(body.maxRetries) ? body.maxRetries : void 0,
|
|
429
|
+
source: "api"
|
|
430
|
+
});
|
|
431
|
+
const nextGoal = goals.get(goalId);
|
|
141
432
|
return c.json({
|
|
142
433
|
ok: true,
|
|
434
|
+
goal: nextGoal,
|
|
143
435
|
sessionKey,
|
|
144
|
-
|
|
436
|
+
queued
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
authenticated.post("/api/goals/:goalId/enqueue", async (c) => {
|
|
440
|
+
const goalId = c.req.param("goalId");
|
|
441
|
+
const body = await c.req.json().catch(() => ({}));
|
|
442
|
+
if (!goals.get(goalId)) return c.json({
|
|
443
|
+
ok: false,
|
|
444
|
+
error: "Goal not found"
|
|
445
|
+
}, 404);
|
|
446
|
+
const item = deps.service.enqueueGoalRun(goalId, {
|
|
447
|
+
message: typeof body.message === "string" ? body.message : void 0,
|
|
448
|
+
maxRetries: typeof body.maxRetries === "number" && Number.isFinite(body.maxRetries) ? body.maxRetries : void 0,
|
|
449
|
+
source: "api"
|
|
450
|
+
});
|
|
451
|
+
return c.json({
|
|
452
|
+
ok: true,
|
|
453
|
+
item
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
authenticated.post("/api/goals/:goalId/pause", async (c) => {
|
|
457
|
+
const body = await c.req.json().catch(() => ({}));
|
|
458
|
+
const before = goals.get(c.req.param("goalId"));
|
|
459
|
+
const goal = goals.pause(c.req.param("goalId"), typeof body.reason === "string" && body.reason.trim() ? body.reason.trim() : "user-paused");
|
|
460
|
+
if (!goal) return c.json({
|
|
461
|
+
ok: false,
|
|
462
|
+
error: "Goal not found"
|
|
463
|
+
}, 404);
|
|
464
|
+
if (before?.status !== goal.status) deps.service.emit("goal.status.updated", {
|
|
465
|
+
goalId: goal.id,
|
|
466
|
+
previousStatus: before?.status,
|
|
467
|
+
status: goal.status,
|
|
468
|
+
goal
|
|
469
|
+
});
|
|
470
|
+
return c.json({
|
|
471
|
+
ok: true,
|
|
472
|
+
goal
|
|
473
|
+
});
|
|
474
|
+
});
|
|
475
|
+
authenticated.post("/api/goals/:goalId/resume", async (c) => {
|
|
476
|
+
const before = goals.get(c.req.param("goalId"));
|
|
477
|
+
const goal = goals.resume(c.req.param("goalId"));
|
|
478
|
+
if (!goal) return c.json({
|
|
479
|
+
ok: false,
|
|
480
|
+
error: "Goal not found"
|
|
481
|
+
}, 404);
|
|
482
|
+
if (before?.status !== goal.status) deps.service.emit("goal.status.updated", {
|
|
483
|
+
goalId: goal.id,
|
|
484
|
+
previousStatus: before?.status,
|
|
485
|
+
status: goal.status,
|
|
486
|
+
goal
|
|
487
|
+
});
|
|
488
|
+
return c.json({
|
|
489
|
+
ok: true,
|
|
490
|
+
goal
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
authenticated.post("/api/goals/:goalId/reopen", async (c) => {
|
|
494
|
+
const before = goals.get(c.req.param("goalId"));
|
|
495
|
+
const goal = goals.reopen(c.req.param("goalId"));
|
|
496
|
+
if (!goal) return c.json({
|
|
497
|
+
ok: false,
|
|
498
|
+
error: "Goal not found"
|
|
499
|
+
}, 404);
|
|
500
|
+
if (before?.status !== goal.status) deps.service.emit("goal.status.updated", {
|
|
501
|
+
goalId: goal.id,
|
|
502
|
+
previousStatus: before?.status,
|
|
503
|
+
status: goal.status,
|
|
504
|
+
goal
|
|
505
|
+
});
|
|
506
|
+
return c.json({
|
|
507
|
+
ok: true,
|
|
508
|
+
goal
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
authenticated.post("/api/goals/:goalId/complete", async (c) => {
|
|
512
|
+
const before = goals.get(c.req.param("goalId"));
|
|
513
|
+
const goal = goals.complete(c.req.param("goalId"));
|
|
514
|
+
if (!goal) return c.json({
|
|
515
|
+
ok: false,
|
|
516
|
+
error: "Goal not found"
|
|
517
|
+
}, 404);
|
|
518
|
+
if (before?.status !== goal.status) deps.service.emit("goal.status.updated", {
|
|
519
|
+
goalId: goal.id,
|
|
520
|
+
previousStatus: before?.status,
|
|
521
|
+
status: goal.status,
|
|
522
|
+
goal
|
|
523
|
+
});
|
|
524
|
+
return c.json({
|
|
525
|
+
ok: true,
|
|
526
|
+
goal
|
|
145
527
|
});
|
|
146
528
|
});
|
|
147
|
-
|
|
148
|
-
|
|
529
|
+
authenticated.post("/api/goals/:goalId/archive", async (c) => {
|
|
530
|
+
const before = goals.get(c.req.param("goalId"));
|
|
531
|
+
const goal = goals.archive(c.req.param("goalId"));
|
|
532
|
+
if (!goal) return c.json({
|
|
533
|
+
ok: false,
|
|
534
|
+
error: "Goal not found"
|
|
535
|
+
}, 404);
|
|
536
|
+
const abortResult = abortActiveWebchatRunForGoal(deps, goal);
|
|
537
|
+
if (before?.status !== goal.status) deps.service.emit("goal.status.updated", {
|
|
538
|
+
goalId: goal.id,
|
|
539
|
+
previousStatus: before?.status,
|
|
540
|
+
status: goal.status,
|
|
541
|
+
goal
|
|
542
|
+
});
|
|
543
|
+
return c.json({
|
|
544
|
+
ok: true,
|
|
545
|
+
goal,
|
|
546
|
+
...abortResult
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
authenticated.post("/api/goals/:goalId/unarchive", async (c) => {
|
|
550
|
+
const before = goals.get(c.req.param("goalId"));
|
|
551
|
+
const goal = goals.unarchive(c.req.param("goalId"));
|
|
552
|
+
if (!goal) return c.json({
|
|
553
|
+
ok: false,
|
|
554
|
+
error: "Goal not found"
|
|
555
|
+
}, 404);
|
|
556
|
+
if (before?.status !== goal.status) deps.service.emit("goal.status.updated", {
|
|
557
|
+
goalId: goal.id,
|
|
558
|
+
previousStatus: before?.status,
|
|
559
|
+
status: goal.status,
|
|
560
|
+
goal
|
|
561
|
+
});
|
|
562
|
+
return c.json({
|
|
563
|
+
ok: true,
|
|
564
|
+
goal
|
|
565
|
+
});
|
|
566
|
+
});
|
|
567
|
+
authenticated.post("/api/goals/:goalId/attach", async (c) => {
|
|
568
|
+
const goalId = c.req.param("goalId");
|
|
149
569
|
const body = await c.req.json().catch(() => ({}));
|
|
150
570
|
const sessionKey = typeof body.sessionKey === "string" ? body.sessionKey.trim() : "";
|
|
151
571
|
if (!sessionKey) return c.json({
|
|
152
572
|
ok: false,
|
|
153
573
|
error: "Missing sessionKey"
|
|
154
574
|
}, 400);
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
if (!meta) return c.json({
|
|
158
|
-
ok: false,
|
|
159
|
-
error: "Session not found"
|
|
160
|
-
}, 404);
|
|
161
|
-
let mutation = null;
|
|
162
|
-
if (op === "reset") mutation = applyChecklistUserMutation(meta.customData, { type: "reset" });
|
|
163
|
-
else if (op === "add") {
|
|
164
|
-
const text = typeof body.text === "string" ? body.text : "";
|
|
165
|
-
mutation = applyChecklistUserMutation(meta.customData, {
|
|
166
|
-
type: "add",
|
|
167
|
-
text
|
|
168
|
-
});
|
|
169
|
-
} else if (op === "remove") {
|
|
170
|
-
const index = typeof body.index === "number" && Number.isFinite(body.index) ? Math.floor(body.index) : void 0;
|
|
171
|
-
if (index === void 0 || index < 1) return c.json({
|
|
172
|
-
ok: false,
|
|
173
|
-
error: "Missing or invalid index (1-based)"
|
|
174
|
-
}, 400);
|
|
175
|
-
mutation = applyChecklistUserMutation(meta.customData, {
|
|
176
|
-
type: "remove",
|
|
177
|
-
index1Based: index
|
|
178
|
-
});
|
|
179
|
-
} else if (op === "mark") {
|
|
180
|
-
const index = typeof body.index === "number" && Number.isFinite(body.index) ? Math.floor(body.index) : void 0;
|
|
181
|
-
const status = typeof body.status === "string" ? body.status.trim().toLowerCase() : "";
|
|
182
|
-
if (index === void 0 || index < 1) return c.json({
|
|
183
|
-
ok: false,
|
|
184
|
-
error: "Missing or invalid index (1-based)"
|
|
185
|
-
}, 400);
|
|
186
|
-
if (status !== "pending" && status !== "completed" && status !== "impossible") return c.json({
|
|
187
|
-
ok: false,
|
|
188
|
-
error: "status must be pending, completed, or impossible"
|
|
189
|
-
}, 400);
|
|
190
|
-
mutation = applyChecklistUserMutation(meta.customData, {
|
|
191
|
-
type: "mark",
|
|
192
|
-
index1Based: index,
|
|
193
|
-
status
|
|
194
|
-
});
|
|
195
|
-
} else return c.json({
|
|
575
|
+
const goal = goals.attachSession(goalId, sessionKey);
|
|
576
|
+
if (!goal) return c.json({
|
|
196
577
|
ok: false,
|
|
197
|
-
error: "
|
|
578
|
+
error: "Goal not found"
|
|
579
|
+
}, 404);
|
|
580
|
+
return c.json({
|
|
581
|
+
ok: true,
|
|
582
|
+
goal
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
authenticated.post("/api/goals/:goalId/detach", async (c) => {
|
|
586
|
+
const goal = goals.update(c.req.param("goalId"), { activeSessionKey: void 0 });
|
|
587
|
+
if (!goal) return c.json({
|
|
588
|
+
ok: false,
|
|
589
|
+
error: "Goal not found"
|
|
590
|
+
}, 404);
|
|
591
|
+
return c.json({
|
|
592
|
+
ok: true,
|
|
593
|
+
goal
|
|
594
|
+
});
|
|
595
|
+
});
|
|
596
|
+
authenticated.get("/api/goals/:goalId/runs", async (c) => {
|
|
597
|
+
const goalId = c.req.param("goalId");
|
|
598
|
+
if (!goals.get(goalId)) return c.json({
|
|
599
|
+
ok: false,
|
|
600
|
+
error: "Goal not found"
|
|
601
|
+
}, 404);
|
|
602
|
+
return c.json({
|
|
603
|
+
ok: true,
|
|
604
|
+
runs: goals.listRuns(goalId, parseLimit(c.req.query("limit")))
|
|
605
|
+
});
|
|
606
|
+
});
|
|
607
|
+
authenticated.get("/api/goals/:goalId/events", async (c) => {
|
|
608
|
+
const goalId = c.req.param("goalId");
|
|
609
|
+
if (!goals.get(goalId)) return c.json({
|
|
610
|
+
ok: false,
|
|
611
|
+
error: "Goal not found"
|
|
612
|
+
}, 404);
|
|
613
|
+
return c.json({
|
|
614
|
+
ok: true,
|
|
615
|
+
events: goals.listEvents(goalId, parseLimit(c.req.query("limit"), 100))
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
authenticated.get("/api/goals/:goalId/evidence", async (c) => {
|
|
619
|
+
const goalId = c.req.param("goalId");
|
|
620
|
+
if (!goals.get(goalId)) return c.json({
|
|
621
|
+
ok: false,
|
|
622
|
+
error: "Goal not found"
|
|
623
|
+
}, 404);
|
|
624
|
+
return c.json({
|
|
625
|
+
ok: true,
|
|
626
|
+
evidence: goals.listEvidence(goalId, parseLimit(c.req.query("limit"), 100))
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
authenticated.post("/api/goals/:goalId/evidence", async (c) => {
|
|
630
|
+
const goalId = c.req.param("goalId");
|
|
631
|
+
if (!goals.get(goalId)) return c.json({
|
|
632
|
+
ok: false,
|
|
633
|
+
error: "Goal not found"
|
|
634
|
+
}, 404);
|
|
635
|
+
const body = await c.req.json().catch(() => ({}));
|
|
636
|
+
const title = typeof body.title === "string" ? body.title.trim() : "";
|
|
637
|
+
const kind = body.kind;
|
|
638
|
+
if (!title) return c.json({
|
|
639
|
+
ok: false,
|
|
640
|
+
error: "Missing title"
|
|
198
641
|
}, 400);
|
|
199
|
-
if (
|
|
642
|
+
if (kind !== "file" && kind !== "diff" && kind !== "command" && kind !== "test" && kind !== "link" && kind !== "message" && kind !== "artifact") return c.json({
|
|
200
643
|
ok: false,
|
|
201
|
-
error:
|
|
644
|
+
error: "Invalid evidence kind"
|
|
202
645
|
}, 400);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
const uiLocale = normalizeGoalUiLocale(body.uiLocale);
|
|
214
|
-
const customData = uiLocale != null ? mergePersistentGoalUiLocale(mutation.customData, uiLocale) ?? mutation.customData : mutation.customData;
|
|
215
|
-
await sm.updateSessionMetadata(sessionKey, { customData });
|
|
216
|
-
const persistentGoal = readPersistentGoal((await sm.getSessionMetadata(sessionKey))?.customData);
|
|
646
|
+
const evidence = goals.addEvidence({
|
|
647
|
+
goalId,
|
|
648
|
+
runId: typeof body.runId === "string" ? body.runId : void 0,
|
|
649
|
+
kind,
|
|
650
|
+
title,
|
|
651
|
+
summary: typeof body.summary === "string" ? body.summary : void 0,
|
|
652
|
+
uri: typeof body.uri === "string" ? body.uri : void 0,
|
|
653
|
+
data: body.data
|
|
654
|
+
});
|
|
217
655
|
return c.json({
|
|
218
656
|
ok: true,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
657
|
+
evidence
|
|
658
|
+
});
|
|
659
|
+
});
|
|
660
|
+
authenticated.post("/api/goals/:goalId/checklist", async (c) => {
|
|
661
|
+
const goalId = c.req.param("goalId");
|
|
662
|
+
if (!goals.get(goalId)) return c.json({
|
|
663
|
+
ok: false,
|
|
664
|
+
error: "Goal not found"
|
|
665
|
+
}, 404);
|
|
666
|
+
const body = await c.req.json().catch(() => ({}));
|
|
667
|
+
const text = typeof body.text === "string" ? body.text.trim() : "";
|
|
668
|
+
if (!text) return c.json({
|
|
669
|
+
ok: false,
|
|
670
|
+
error: "Missing text"
|
|
671
|
+
}, 400);
|
|
672
|
+
const goal = goals.updateChecklist(goalId, {
|
|
673
|
+
type: "add",
|
|
674
|
+
text,
|
|
675
|
+
addedBy: "user"
|
|
676
|
+
});
|
|
677
|
+
return c.json({
|
|
678
|
+
ok: true,
|
|
679
|
+
goal
|
|
680
|
+
});
|
|
681
|
+
});
|
|
682
|
+
authenticated.patch("/api/goals/:goalId/checklist/:itemId", async (c) => {
|
|
683
|
+
const goalId = c.req.param("goalId");
|
|
684
|
+
const itemId = c.req.param("itemId");
|
|
685
|
+
if (!goals.get(goalId)) return c.json({
|
|
686
|
+
ok: false,
|
|
687
|
+
error: "Goal not found"
|
|
688
|
+
}, 404);
|
|
689
|
+
const body = await c.req.json().catch(() => ({}));
|
|
690
|
+
const status = body.status;
|
|
691
|
+
if (status !== "pending" && status !== "completed" && status !== "impossible") return c.json({
|
|
692
|
+
ok: false,
|
|
693
|
+
error: "Invalid checklist status"
|
|
694
|
+
}, 400);
|
|
695
|
+
const goal = goals.updateChecklist(goalId, {
|
|
696
|
+
type: "mark",
|
|
697
|
+
itemId,
|
|
698
|
+
status,
|
|
699
|
+
evidenceSummary: typeof body.evidenceSummary === "string" ? body.evidenceSummary : void 0
|
|
700
|
+
});
|
|
701
|
+
return c.json({
|
|
702
|
+
ok: true,
|
|
703
|
+
goal
|
|
704
|
+
});
|
|
705
|
+
});
|
|
706
|
+
authenticated.delete("/api/goals/:goalId/checklist/:itemId", async (c) => {
|
|
707
|
+
const goalId = c.req.param("goalId");
|
|
708
|
+
if (!goals.get(goalId)) return c.json({
|
|
709
|
+
ok: false,
|
|
710
|
+
error: "Goal not found"
|
|
711
|
+
}, 404);
|
|
712
|
+
const goal = goals.updateChecklist(goalId, {
|
|
713
|
+
type: "remove",
|
|
714
|
+
itemId: c.req.param("itemId")
|
|
715
|
+
});
|
|
716
|
+
return c.json({
|
|
717
|
+
ok: true,
|
|
718
|
+
goal
|
|
222
719
|
});
|
|
223
720
|
});
|
|
224
721
|
}
|