@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,27 +1,28 @@
|
|
|
1
|
+
import { GoalService } from "../../goals/goal-service.js";
|
|
2
|
+
import "../../goals/index.js";
|
|
1
3
|
import { commandRegistry } from "../registry.js";
|
|
2
|
-
import { checklistCounts } from "../../agent/goals/checklist-types.js";
|
|
3
|
-
import { readPersistentGoal, renderChecklistNumbered } from "../../agent/goals/state.js";
|
|
4
|
-
import { applyChecklistUserMutation } from "../../agent/goals/checklist-user.js";
|
|
5
4
|
//#region src/chat-commands/builtins/subgoal.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
/**
|
|
6
|
+
* `/subgoal` — view or edit checklist criteria for the active first-class goal.
|
|
7
|
+
*/
|
|
8
|
+
const goals = new GoalService();
|
|
9
|
+
function activeGoal(ctx) {
|
|
10
|
+
return goals.getActiveForSession(ctx.sessionKey);
|
|
11
|
+
}
|
|
12
|
+
function renderChecklist(goal) {
|
|
13
|
+
if (!goal.checklist.length) return "Checklist is empty. Add criteria with /subgoal add <text>.";
|
|
14
|
+
const done = goal.checklist.filter((it) => it.status === "completed" || it.status === "impossible").length;
|
|
15
|
+
const lines = goal.checklist.map((it, index) => {
|
|
16
|
+
const marker = it.status === "completed" ? "[x]" : it.status === "impossible" ? "[!]" : "[ ]";
|
|
17
|
+
const evidence = it.evidenceSummary ? ` (${it.evidenceSummary})` : "";
|
|
18
|
+
return `${index + 1}. ${marker} ${it.text}${evidence}`;
|
|
19
|
+
});
|
|
20
|
+
return `Checklist (${done}/${goal.checklist.length} terminal):\n${lines.join("\n")}`;
|
|
20
21
|
}
|
|
21
22
|
const subgoalCommand = {
|
|
22
23
|
id: "system.subgoal",
|
|
23
24
|
name: "subgoal",
|
|
24
|
-
description: "View or edit checklist criteria for the active
|
|
25
|
+
description: "View or edit checklist criteria for the active goal (add, mark, remove, reset)",
|
|
25
26
|
category: "system",
|
|
26
27
|
scope: [
|
|
27
28
|
"global",
|
|
@@ -37,73 +38,31 @@ const subgoalCommand = {
|
|
|
37
38
|
"/subgoal reset"
|
|
38
39
|
],
|
|
39
40
|
handler: async (ctx, args) => {
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
content: "
|
|
43
|
-
success:
|
|
41
|
+
const goal = activeGoal(ctx);
|
|
42
|
+
if (!goal) return {
|
|
43
|
+
content: "No active goal. Set one with /goal <text> first.",
|
|
44
|
+
success: true
|
|
44
45
|
};
|
|
45
46
|
const t = args.trim();
|
|
46
47
|
const lower = t.toLowerCase();
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
content: "No active goal. Set one with /goal <text> first.",
|
|
52
|
-
success: true
|
|
53
|
-
};
|
|
54
|
-
const items = s.checklist ?? [];
|
|
55
|
-
if (!items.length) return {
|
|
56
|
-
content: s.decomposed === true ? "Checklist is empty (decomposition produced no items). The judge will use freeform mode." : "Checklist not built yet — it appears after the first assistant turn once decomposition runs.",
|
|
57
|
-
success: true
|
|
58
|
-
};
|
|
59
|
-
const { total, completed, impossible } = checklistCounts(items);
|
|
60
|
-
return {
|
|
61
|
-
content: `Checklist (${completed + impossible}/${total} terminal):\n` + renderChecklistNumbered(items),
|
|
62
|
-
success: true
|
|
63
|
-
};
|
|
64
|
-
}
|
|
48
|
+
if (!t || lower === "list" || lower === "status") return {
|
|
49
|
+
content: renderChecklist(goal),
|
|
50
|
+
success: true
|
|
51
|
+
};
|
|
65
52
|
if (lower === "reset" || lower === "clear") {
|
|
66
|
-
|
|
67
|
-
if (applied.kind === "error") return {
|
|
68
|
-
content: applied.error,
|
|
69
|
-
success: false
|
|
70
|
-
};
|
|
71
|
-
if (applied.kind === "noop") return {
|
|
72
|
-
content: applied.message,
|
|
73
|
-
success: true
|
|
74
|
-
};
|
|
75
|
-
const cd = applied.customData;
|
|
76
|
-
const r = await patchMetadata(ctx, () => cd);
|
|
77
|
-
if (!r.ok) return {
|
|
78
|
-
content: "error" in r ? r.error : "Failed",
|
|
79
|
-
success: false
|
|
80
|
-
};
|
|
53
|
+
goals.updateChecklist(goal.id, { type: "reset" });
|
|
81
54
|
return {
|
|
82
|
-
content: "✓ Checklist cleared.
|
|
55
|
+
content: "✓ Checklist cleared.",
|
|
83
56
|
success: true
|
|
84
57
|
};
|
|
85
58
|
}
|
|
86
59
|
const addM = t.match(/^add\s+([\s\S]+)$/i);
|
|
87
60
|
if (addM) {
|
|
88
61
|
const text = addM[1].trim();
|
|
89
|
-
|
|
62
|
+
goals.updateChecklist(goal.id, {
|
|
90
63
|
type: "add",
|
|
91
64
|
text
|
|
92
65
|
});
|
|
93
|
-
if (applied.kind === "error") return {
|
|
94
|
-
content: applied.error,
|
|
95
|
-
success: false
|
|
96
|
-
};
|
|
97
|
-
if (applied.kind === "noop") return {
|
|
98
|
-
content: applied.message,
|
|
99
|
-
success: true
|
|
100
|
-
};
|
|
101
|
-
const cd = applied.customData;
|
|
102
|
-
const r = await patchMetadata(ctx, () => cd);
|
|
103
|
-
if (!r.ok) return {
|
|
104
|
-
content: "error" in r ? r.error : "Failed",
|
|
105
|
-
success: false
|
|
106
|
-
};
|
|
107
66
|
return {
|
|
108
67
|
content: `⊙ Added checklist item: ${text}`,
|
|
109
68
|
success: true
|
|
@@ -111,60 +70,42 @@ const subgoalCommand = {
|
|
|
111
70
|
}
|
|
112
71
|
const removeM = t.match(/^remove\s+(\d+)\s*$/i);
|
|
113
72
|
if (removeM) {
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
});
|
|
119
|
-
if (applied.kind === "error") return {
|
|
120
|
-
content: applied.error,
|
|
121
|
-
success: false
|
|
122
|
-
};
|
|
123
|
-
if (applied.kind === "noop") return {
|
|
124
|
-
content: applied.message,
|
|
125
|
-
success: true
|
|
126
|
-
};
|
|
127
|
-
const cd = applied.customData;
|
|
128
|
-
const r = await patchMetadata(ctx, () => cd);
|
|
129
|
-
if (!r.ok) return {
|
|
130
|
-
content: "error" in r ? r.error : "Failed",
|
|
73
|
+
const index = Number(removeM[1]);
|
|
74
|
+
const item = goal.checklist[index - 1];
|
|
75
|
+
if (!item) return {
|
|
76
|
+
content: `No checklist item #${index}.`,
|
|
131
77
|
success: false
|
|
132
78
|
};
|
|
79
|
+
goals.updateChecklist(goal.id, {
|
|
80
|
+
type: "remove",
|
|
81
|
+
itemId: item.id
|
|
82
|
+
});
|
|
133
83
|
return {
|
|
134
|
-
content: `✓ Removed item #${
|
|
84
|
+
content: `✓ Removed item #${index}.`,
|
|
135
85
|
success: true
|
|
136
86
|
};
|
|
137
87
|
}
|
|
138
88
|
const markM = t.match(/^mark\s+(\d+)\s+(pending|completed|impossible)\s*$/i);
|
|
139
89
|
if (markM) {
|
|
140
|
-
const
|
|
90
|
+
const index = Number(markM[1]);
|
|
141
91
|
const status = markM[2].toLowerCase();
|
|
142
|
-
const
|
|
92
|
+
const item = goal.checklist[index - 1];
|
|
93
|
+
if (!item) return {
|
|
94
|
+
content: `No checklist item #${index}.`,
|
|
95
|
+
success: false
|
|
96
|
+
};
|
|
97
|
+
goals.updateChecklist(goal.id, {
|
|
143
98
|
type: "mark",
|
|
144
|
-
|
|
99
|
+
itemId: item.id,
|
|
145
100
|
status
|
|
146
101
|
});
|
|
147
|
-
if (applied.kind === "error") return {
|
|
148
|
-
content: applied.error,
|
|
149
|
-
success: false
|
|
150
|
-
};
|
|
151
|
-
if (applied.kind === "noop") return {
|
|
152
|
-
content: applied.message,
|
|
153
|
-
success: true
|
|
154
|
-
};
|
|
155
|
-
const cd = applied.customData;
|
|
156
|
-
const r = await patchMetadata(ctx, () => cd);
|
|
157
|
-
if (!r.ok) return {
|
|
158
|
-
content: "error" in r ? r.error : "Failed",
|
|
159
|
-
success: false
|
|
160
|
-
};
|
|
161
102
|
return {
|
|
162
|
-
content: `⊙ Item #${
|
|
103
|
+
content: `⊙ Item #${index} -> ${status}.`,
|
|
163
104
|
success: true
|
|
164
105
|
};
|
|
165
106
|
}
|
|
166
107
|
return {
|
|
167
|
-
content: "Usage:\n• /subgoal — show checklist\n• /subgoal add <text>\n• /subgoal mark <n> pending|completed|impossible\n• /subgoal remove <n>\n• /subgoal reset
|
|
108
|
+
content: "Usage:\n• /subgoal — show checklist\n• /subgoal add <text>\n• /subgoal mark <n> pending|completed|impossible\n• /subgoal remove <n>\n• /subgoal reset",
|
|
168
109
|
success: true
|
|
169
110
|
};
|
|
170
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgoal.js","names":[],"sources":["../../../../src/chat-commands/builtins/subgoal.ts"],"sourcesContent":["/**\n * `/subgoal` — view or edit
|
|
1
|
+
{"version":3,"file":"subgoal.js","names":[],"sources":["../../../../src/chat-commands/builtins/subgoal.ts"],"sourcesContent":["/**\n * `/subgoal` — view or edit checklist criteria for the active first-class goal.\n */\n\nimport { GoalService } from '../../goals/index.js';\nimport type { CommandContext, CommandDefinition } from '../types.js';\nimport { commandRegistry } from '../registry.js';\n\nconst goals = new GoalService();\n\nfunction activeGoal(ctx: CommandContext) {\n return goals.getActiveForSession(ctx.sessionKey);\n}\n\nfunction renderChecklist(goal: NonNullable<ReturnType<typeof activeGoal>>): string {\n if (!goal.checklist.length) return 'Checklist is empty. Add criteria with /subgoal add <text>.';\n const done = goal.checklist.filter((it) => it.status === 'completed' || it.status === 'impossible').length;\n const lines = goal.checklist.map((it, index) => {\n const marker = it.status === 'completed' ? '[x]' : it.status === 'impossible' ? '[!]' : '[ ]';\n const evidence = it.evidenceSummary ? ` (${it.evidenceSummary})` : '';\n return `${index + 1}. ${marker} ${it.text}${evidence}`;\n });\n return `Checklist (${done}/${goal.checklist.length} terminal):\\n${lines.join('\\n')}`;\n}\n\nconst subgoalCommand: CommandDefinition = {\n id: 'system.subgoal',\n name: 'subgoal',\n description: 'View or edit checklist criteria for the active goal (add, mark, remove, reset)',\n category: 'system',\n scope: ['global', 'private', 'group'],\n acceptsArgs: true,\n examples: [\n '/subgoal',\n '/subgoal add Run tests in CI',\n '/subgoal mark 2 completed',\n '/subgoal remove 3',\n '/subgoal reset',\n ],\n handler: async (ctx: CommandContext, args: string) => {\n const goal = activeGoal(ctx);\n if (!goal) return { content: 'No active goal. Set one with /goal <text> first.', success: true };\n\n const t = args.trim();\n const lower = t.toLowerCase();\n\n if (!t || lower === 'list' || lower === 'status') {\n return { content: renderChecklist(goal), success: true };\n }\n\n if (lower === 'reset' || lower === 'clear') {\n goals.updateChecklist(goal.id, { type: 'reset' });\n return { content: '✓ Checklist cleared.', success: true };\n }\n\n const addM = t.match(/^add\\s+([\\s\\S]+)$/i);\n if (addM) {\n const text = addM[1]!.trim();\n goals.updateChecklist(goal.id, { type: 'add', text });\n return { content: `⊙ Added checklist item: ${text}`, success: true };\n }\n\n const removeM = t.match(/^remove\\s+(\\d+)\\s*$/i);\n if (removeM) {\n const index = Number(removeM[1]);\n const item = goal.checklist[index - 1];\n if (!item) return { content: `No checklist item #${index}.`, success: false };\n goals.updateChecklist(goal.id, { type: 'remove', itemId: item.id });\n return { content: `✓ Removed item #${index}.`, success: true };\n }\n\n const markM = t.match(/^mark\\s+(\\d+)\\s+(pending|completed|impossible)\\s*$/i);\n if (markM) {\n const index = Number(markM[1]);\n const status = markM[2]!.toLowerCase() as 'pending' | 'completed' | 'impossible';\n const item = goal.checklist[index - 1];\n if (!item) return { content: `No checklist item #${index}.`, success: false };\n goals.updateChecklist(goal.id, { type: 'mark', itemId: item.id, status });\n return { content: `⊙ Item #${index} -> ${status}.`, success: true };\n }\n\n return {\n content:\n 'Usage:\\n' +\n '• /subgoal — show checklist\\n' +\n '• /subgoal add <text>\\n' +\n '• /subgoal mark <n> pending|completed|impossible\\n' +\n '• /subgoal remove <n>\\n' +\n '• /subgoal reset',\n success: true,\n };\n },\n};\n\nexport function registerSubgoalComm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MAAM,qBAAqB;AAC1C,MAAI,MAAM;GACR,MAAM,OAAO,KAAK,GAAI,MAAM;AAC5B,SAAM,gBAAgB,KAAK,IAAI;IAAE,MAAM;IAAO;IAAM,CAAC;AACrD,UAAO;IAAE,SAAS,2BAA2B;IAAQ,SAAS;IAAM;;EAGtE,MAAM,UAAU,EAAE,MAAM,uBAAuB;AAC/C,MAAI,SAAS;GACX,MAAM,QAAQ,OAAO,QAAQ,GAAG;GAChC,MAAM,OAAO,KAAK,UAAU,QAAQ;AACpC,OAAI,CAAC,KAAM,QAAO;IAAE,SAAS,sBAAsB,MAAM;IAAI,SAAS;IAAO;AAC7E,SAAM,gBAAgB,KAAK,IAAI;IAAE,MAAM;IAAU,QAAQ,KAAK;IAAI,CAAC;AACnE,UAAO;IAAE,SAAS,mBAAmB,MAAM;IAAI,SAAS;IAAM;;EAGhE,MAAM,QAAQ,EAAE,MAAM,sDAAsD;AAC5E,MAAI,OAAO;GACT,MAAM,QAAQ,OAAO,MAAM,GAAG;GAC9B,MAAM,SAAS,MAAM,GAAI,aAAa;GACtC,MAAM,OAAO,KAAK,UAAU,QAAQ;AACpC,OAAI,CAAC,KAAM,QAAO;IAAE,SAAS,sBAAsB,MAAM;IAAI,SAAS;IAAO;AAC7E,SAAM,gBAAgB,KAAK,IAAI;IAAE,MAAM;IAAQ,QAAQ,KAAK;IAAI;IAAQ,CAAC;AACzE,UAAO;IAAE,SAAS,WAAW,MAAM,MAAM,OAAO;IAAI,SAAS;IAAM;;AAGrE,SAAO;GACL,SACE;GAMF,SAAS;GACV;;CAEJ;AAED,SAAgB,yBAA+B;AAC7C,iBAAgB,SAAS,eAAe"}
|
|
@@ -97,10 +97,17 @@ const skillsCommand = {
|
|
|
97
97
|
acceptsArgs: true,
|
|
98
98
|
examples: ["/skills reload"],
|
|
99
99
|
handler: async (ctx, args) => {
|
|
100
|
-
if (args === "reload")
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
if (args === "reload") {
|
|
101
|
+
if (!ctx.reloadSkills) return {
|
|
102
|
+
content: "Skills reload is not available in this context.",
|
|
103
|
+
success: false
|
|
104
|
+
};
|
|
105
|
+
await ctx.reloadSkills();
|
|
106
|
+
return {
|
|
107
|
+
content: "Skills reloaded successfully",
|
|
108
|
+
success: true
|
|
109
|
+
};
|
|
110
|
+
}
|
|
104
111
|
return {
|
|
105
112
|
content: joinBlocks(section("🛠️ Skills Management"), bulletList(["`/skills reload` — Reload all skills from disk"])),
|
|
106
113
|
success: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.js","names":[],"sources":["../../../../src/chat-commands/builtins/system.ts"],"sourcesContent":["/**\n * System Commands\n *\n * Built-in system commands:\n * - /help - Show help message\n * - /start - Welcome message\n * - /settings - Show settings\n */\n\nimport type { CommandDefinition, CommandContext } from '../types.js';\nimport { commandRegistry } from '../registry.js';\nimport { bulletList, commandBullet, joinBlocks, kvList, section } from '../format-output.js';\n\nconst helpCommand: CommandDefinition = {\n id: 'system.help',\n name: 'help',\n aliases: ['h', 'commands'],\n description: 'Show available commands',\n category: 'system',\n scope: ['global', 'private', 'group'],\n handler: async (_ctx: CommandContext) => {\n const allCommands = commandRegistry.list();\n\n // Group by category\n const byCategory = new Map<string, typeof allCommands>();\n for (const cmd of allCommands) {\n if (!byCategory.has(cmd.category)) {\n byCategory.set(cmd.category, []);\n }\n byCategory.get(cmd.category)!.push(cmd);\n }\n\n const categoryBlocks: string[] = [];\n for (const [category, commands] of byCategory) {\n categoryBlocks.push(\n joinBlocks(\n section(category.toUpperCase()),\n commands\n .map((cmd) => commandBullet(cmd.name, cmd.description, cmd.aliases))\n .join('\\n'),\n ),\n );\n }\n\n return {\n content: joinBlocks(section('📖 Available Commands'), ...categoryBlocks),\n success: true,\n };\n },\n};\n\nconst startCommand: CommandDefinition = {\n id: 'system.start',\n name: 'start',\n description: 'Show welcome message',\n category: 'system',\n scope: ['global', 'private', 'group'],\n handler: async (_ctx: CommandContext) => {\n const content = joinBlocks(\n section('👋 Welcome to xopc!'),\n \"I am your AI assistant. Here's what I can do:\",\n bulletList([\n '**AI Chat** — Just send a message to start chatting',\n '**Session Management** — Use `/new`, `/list`, `/usage`',\n '**Model Selection** — `/models` shows names and `provider/model` refs; `/switch` uses that ref',\n ]),\n 'Type `/help` to see all available commands.',\n );\n\n return {\n content,\n success: true,\n };\n },\n};\n\nconst settingsCommand: CommandDefinition = {\n id: 'system.settings',\n name: 'settings',\n description: 'Show current settings',\n category: 'system',\n scope: ['global', 'private', 'group'],\n handler: async (ctx: CommandContext) => {\n const model = ctx.getCurrentModel();\n const sessionKey = ctx.sessionKey;\n\n const content = joinBlocks(\n section('⚙️ Current Settings'),\n kvList([\n { key: 'Model', value: model },\n { key: 'Session', value: sessionKey },\n { key: 'Platform', value: ctx.source },\n { key: 'Group', value: ctx.isGroup ? 'Yes' : 'No' },\n ]),\n );\n\n return {\n content,\n success: true,\n };\n },\n};\n\nconst skillsCommand: CommandDefinition = {\n id: 'system.skills',\n name: 'skills',\n description: 'Manage skills (e.g., /skills reload)',\n category: 'system',\n scope: ['global', 'private', 'group'],\n acceptsArgs: true,\n examples: ['/skills reload'],\n handler: async (ctx: CommandContext, args: string) => {\n if (args === 'reload') {\n
|
|
1
|
+
{"version":3,"file":"system.js","names":[],"sources":["../../../../src/chat-commands/builtins/system.ts"],"sourcesContent":["/**\n * System Commands\n *\n * Built-in system commands:\n * - /help - Show help message\n * - /start - Welcome message\n * - /settings - Show settings\n */\n\nimport type { CommandDefinition, CommandContext } from '../types.js';\nimport { commandRegistry } from '../registry.js';\nimport { bulletList, commandBullet, joinBlocks, kvList, section } from '../format-output.js';\n\nconst helpCommand: CommandDefinition = {\n id: 'system.help',\n name: 'help',\n aliases: ['h', 'commands'],\n description: 'Show available commands',\n category: 'system',\n scope: ['global', 'private', 'group'],\n handler: async (_ctx: CommandContext) => {\n const allCommands = commandRegistry.list();\n\n // Group by category\n const byCategory = new Map<string, typeof allCommands>();\n for (const cmd of allCommands) {\n if (!byCategory.has(cmd.category)) {\n byCategory.set(cmd.category, []);\n }\n byCategory.get(cmd.category)!.push(cmd);\n }\n\n const categoryBlocks: string[] = [];\n for (const [category, commands] of byCategory) {\n categoryBlocks.push(\n joinBlocks(\n section(category.toUpperCase()),\n commands\n .map((cmd) => commandBullet(cmd.name, cmd.description, cmd.aliases))\n .join('\\n'),\n ),\n );\n }\n\n return {\n content: joinBlocks(section('📖 Available Commands'), ...categoryBlocks),\n success: true,\n };\n },\n};\n\nconst startCommand: CommandDefinition = {\n id: 'system.start',\n name: 'start',\n description: 'Show welcome message',\n category: 'system',\n scope: ['global', 'private', 'group'],\n handler: async (_ctx: CommandContext) => {\n const content = joinBlocks(\n section('👋 Welcome to xopc!'),\n \"I am your AI assistant. Here's what I can do:\",\n bulletList([\n '**AI Chat** — Just send a message to start chatting',\n '**Session Management** — Use `/new`, `/list`, `/usage`',\n '**Model Selection** — `/models` shows names and `provider/model` refs; `/switch` uses that ref',\n ]),\n 'Type `/help` to see all available commands.',\n );\n\n return {\n content,\n success: true,\n };\n },\n};\n\nconst settingsCommand: CommandDefinition = {\n id: 'system.settings',\n name: 'settings',\n description: 'Show current settings',\n category: 'system',\n scope: ['global', 'private', 'group'],\n handler: async (ctx: CommandContext) => {\n const model = ctx.getCurrentModel();\n const sessionKey = ctx.sessionKey;\n\n const content = joinBlocks(\n section('⚙️ Current Settings'),\n kvList([\n { key: 'Model', value: model },\n { key: 'Session', value: sessionKey },\n { key: 'Platform', value: ctx.source },\n { key: 'Group', value: ctx.isGroup ? 'Yes' : 'No' },\n ]),\n );\n\n return {\n content,\n success: true,\n };\n },\n};\n\nconst skillsCommand: CommandDefinition = {\n id: 'system.skills',\n name: 'skills',\n description: 'Manage skills (e.g., /skills reload)',\n category: 'system',\n scope: ['global', 'private', 'group'],\n acceptsArgs: true,\n examples: ['/skills reload'],\n handler: async (ctx: CommandContext, args: string) => {\n if (args === 'reload') {\n if (!ctx.reloadSkills) {\n return {\n content: 'Skills reload is not available in this context.',\n success: false,\n };\n }\n await ctx.reloadSkills();\n return {\n content: 'Skills reloaded successfully',\n success: true,\n };\n }\n\n const content = joinBlocks(\n section('🛠️ Skills Management'),\n bulletList(['`/skills reload` — Reload all skills from disk']),\n );\n\n return {\n content,\n success: true,\n };\n },\n};\n\n// Register all system commands\nexport function registerSystemCommands(): void {\n commandRegistry.register(helpCommand);\n commandRegistry.register(startCommand);\n commandRegistry.register(settingsCommand);\n commandRegistry.register(skillsCommand);\n}\n"],"mappings":";;;AAaA,MAAM,cAAiC;CACrC,IAAI;CACJ,MAAM;CACN,SAAS,CAAC,KAAK,WAAW;CAC1B,aAAa;CACb,UAAU;CACV,OAAO;EAAC;EAAU;EAAW;EAAQ;CACrC,SAAS,OAAO,SAAyB;EACvC,MAAM,cAAc,gBAAgB,MAAM;EAG1C,MAAM,6BAAa,IAAI,KAAiC;AACxD,OAAK,MAAM,OAAO,aAAa;AAC7B,OAAI,CAAC,WAAW,IAAI,IAAI,SAAS,CAC/B,YAAW,IAAI,IAAI,UAAU,EAAE,CAAC;AAElC,cAAW,IAAI,IAAI,SAAS,CAAE,KAAK,IAAI;;EAGzC,MAAM,iBAA2B,EAAE;AACnC,OAAK,MAAM,CAAC,UAAU,aAAa,WACjC,gBAAe,KACb,WACE,QAAQ,SAAS,aAAa,CAAC,EAC/B,SACG,KAAK,QAAQ,cAAc,IAAI,MAAM,IAAI,aAAa,IAAI,QAAQ,CAAC,CACnE,KAAK,KAAK,CACd,CACF;AAGH,SAAO;GACL,SAAS,WAAW,QAAQ,wBAAwB,EAAE,GAAG,eAAe;GACxE,SAAS;GACV;;CAEJ;AAED,MAAM,eAAkC;CACtC,IAAI;CACJ,MAAM;CACN,aAAa;CACb,UAAU;CACV,OAAO;EAAC;EAAU;EAAW;EAAQ;CACrC,SAAS,OAAO,SAAyB;AAYvC,SAAO;GACL,SAZc,WACd,QAAQ,sBAAsB,EAC9B,iDACA,WAAW;IACT;IACA;IACA;IACD,CAAC,EACF,8CAIO;GACP,SAAS;GACV;;CAEJ;AAED,MAAM,kBAAqC;CACzC,IAAI;CACJ,MAAM;CACN,aAAa;CACb,UAAU;CACV,OAAO;EAAC;EAAU;EAAW;EAAQ;CACrC,SAAS,OAAO,QAAwB;EACtC,MAAM,QAAQ,IAAI,iBAAiB;EACnC,MAAM,aAAa,IAAI;AAYvB,SAAO;GACL,SAXc,WACd,QAAQ,sBAAsB,EAC9B,OAAO;IACL;KAAE,KAAK;KAAS,OAAO;KAAO;IAC9B;KAAE,KAAK;KAAW,OAAO;KAAY;IACrC;KAAE,KAAK;KAAY,OAAO,IAAI;KAAQ;IACtC;KAAE,KAAK;KAAS,OAAO,IAAI,UAAU,QAAQ;KAAM;IACpD,CAAC,CAIK;GACP,SAAS;GACV;;CAEJ;AAED,MAAM,gBAAmC;CACvC,IAAI;CACJ,MAAM;CACN,aAAa;CACb,UAAU;CACV,OAAO;EAAC;EAAU;EAAW;EAAQ;CACrC,aAAa;CACb,UAAU,CAAC,iBAAiB;CAC5B,SAAS,OAAO,KAAqB,SAAiB;AACpD,MAAI,SAAS,UAAU;AACrB,OAAI,CAAC,IAAI,aACP,QAAO;IACL,SAAS;IACT,SAAS;IACV;AAEH,SAAM,IAAI,cAAc;AACxB,UAAO;IACL,SAAS;IACT,SAAS;IACV;;AAQH,SAAO;GACL,SANc,WACd,QAAQ,wBAAwB,EAChC,WAAW,CAAC,iDAAiD,CAAC,CAIvD;GACP,SAAS;GACV;;CAEJ;AAGD,SAAgB,yBAA+B;AAC7C,iBAAgB,SAAS,YAAY;AACrC,iBAAgB,SAAS,aAAa;AACtC,iBAAgB,SAAS,gBAAgB;AACzC,iBAAgB,SAAS,cAAc"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { extractProfileAgentId } from "../../config/agent-profile.js";
|
|
1
2
|
import { createWorkflowCatalog } from "../../agent/workflow/catalog.js";
|
|
2
3
|
import { getLastWorkflowMemory } from "../../agent/workflow/last-run-memory.js";
|
|
3
4
|
import { commandRegistry } from "../registry.js";
|
|
@@ -109,13 +110,7 @@ const workflowCommand = {
|
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
|
-
if (subLower === "run" || subLower === "start")
|
|
113
|
-
const name = target || "<name>";
|
|
114
|
-
return {
|
|
115
|
-
content: joinBlocks(`To run a workflow, ask in plain language: "run the ${name} workflow".`, `The assistant will call the workflow tool with ${code(`name="${name}"`)} and stream progress inline.`),
|
|
116
|
-
success: true
|
|
117
|
-
};
|
|
118
|
-
}
|
|
113
|
+
if (subLower === "run" || subLower === "start") return runWorkflowFromCommand(ctx, target);
|
|
119
114
|
if (subLower === "save") {
|
|
120
115
|
if (!target) return {
|
|
121
116
|
content: `usage: ${code("/workflow save <name>")}`,
|
|
@@ -142,11 +137,140 @@ const workflowCommand = {
|
|
|
142
137
|
}
|
|
143
138
|
}
|
|
144
139
|
return {
|
|
145
|
-
content: joinBlocks(`Unknown subcommand "${sub}". Available: list, view ${code("<name>")}, save ${code("<name>")}.`,
|
|
140
|
+
content: joinBlocks(`Unknown subcommand "${sub}". Available: list, view ${code("<name>")}, save ${code("<name>")}.`, `Run directly with ${code("/workflow run <name> [--goal \"...\"] [--json '{...}']")}.`),
|
|
146
141
|
success: false
|
|
147
142
|
};
|
|
148
143
|
}
|
|
149
144
|
};
|
|
145
|
+
async function runWorkflowFromCommand(ctx, args) {
|
|
146
|
+
if (!ctx.workflowRunApis) return {
|
|
147
|
+
content: "Workflow runs are not available in this context.",
|
|
148
|
+
success: false
|
|
149
|
+
};
|
|
150
|
+
let parsed;
|
|
151
|
+
try {
|
|
152
|
+
parsed = parseWorkflowRunArgs(args);
|
|
153
|
+
} catch (err) {
|
|
154
|
+
return {
|
|
155
|
+
content: `error: ${err instanceof Error ? err.message : String(err)}`,
|
|
156
|
+
success: false
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (!parsed.name) return {
|
|
160
|
+
content: `usage: ${code("/workflow run <name> [--goal \"...\"] [--json '{...}']")}`,
|
|
161
|
+
success: false
|
|
162
|
+
};
|
|
163
|
+
const catalog = createWorkflowCatalog();
|
|
164
|
+
try {
|
|
165
|
+
catalog.load(parsed.name);
|
|
166
|
+
} catch (e) {
|
|
167
|
+
return {
|
|
168
|
+
content: `error: ${e instanceof Error ? e.message : String(e)}`,
|
|
169
|
+
success: false
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const agentId = extractProfileAgentId(ctx.sessionKey, ctx.config);
|
|
173
|
+
const source = ctx.source === "webui" || ctx.channelId === "webchat" ? {
|
|
174
|
+
kind: "webui",
|
|
175
|
+
sessionKey: ctx.sessionKey
|
|
176
|
+
} : {
|
|
177
|
+
kind: "chat",
|
|
178
|
+
sessionKey: ctx.sessionKey
|
|
179
|
+
};
|
|
180
|
+
const result = await ctx.workflowRunApis.startWorkflowRun({
|
|
181
|
+
agentId,
|
|
182
|
+
definitionId: parsed.name,
|
|
183
|
+
goal: parsed.goal,
|
|
184
|
+
input: parsed.input,
|
|
185
|
+
parentSessionKey: ctx.sessionKey,
|
|
186
|
+
source
|
|
187
|
+
});
|
|
188
|
+
if (result.ok === false) return {
|
|
189
|
+
content: `error: ${result.message}`,
|
|
190
|
+
success: false,
|
|
191
|
+
metadata: { workflowRun: {
|
|
192
|
+
ok: false,
|
|
193
|
+
definitionId: parsed.name,
|
|
194
|
+
code: result.code,
|
|
195
|
+
message: result.message
|
|
196
|
+
} }
|
|
197
|
+
};
|
|
198
|
+
return {
|
|
199
|
+
content: joinBlocks(`Started workflow **${parsed.name}**.`, bulletList([{
|
|
200
|
+
label: "runId",
|
|
201
|
+
detail: code(result.runId)
|
|
202
|
+
}, {
|
|
203
|
+
label: "sessionKey",
|
|
204
|
+
detail: code(result.sessionKey)
|
|
205
|
+
}])),
|
|
206
|
+
success: true,
|
|
207
|
+
metadata: { workflowRun: {
|
|
208
|
+
ok: true,
|
|
209
|
+
definitionId: parsed.name,
|
|
210
|
+
runId: result.runId,
|
|
211
|
+
sessionKey: result.sessionKey,
|
|
212
|
+
parentSessionKey: ctx.sessionKey
|
|
213
|
+
} }
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function parseWorkflowRunArgs(raw) {
|
|
217
|
+
const tokens = tokenizeArgs(raw);
|
|
218
|
+
const name = tokens.shift()?.trim() ?? "";
|
|
219
|
+
let goal;
|
|
220
|
+
let input;
|
|
221
|
+
for (let i = 0; i < tokens.length; i += 1) {
|
|
222
|
+
const token = tokens[i];
|
|
223
|
+
if (token === "--goal" || token === "-g") {
|
|
224
|
+
goal = tokens[++i]?.trim() || void 0;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (token.startsWith("--goal=")) {
|
|
228
|
+
goal = token.slice(7).trim() || void 0;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
if (token === "--json" || token === "--input") {
|
|
232
|
+
const value = tokens[++i];
|
|
233
|
+
input = parseJsonArg(value, token);
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if (token.startsWith("--json=")) {
|
|
237
|
+
input = parseJsonArg(token.slice(7), "--json");
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (token.startsWith("--input=")) {
|
|
241
|
+
input = parseJsonArg(token.slice(8), "--input");
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (!goal) {
|
|
245
|
+
goal = [token, ...tokens.slice(i + 1)].join(" ").trim() || void 0;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
name,
|
|
251
|
+
goal,
|
|
252
|
+
input
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function parseJsonArg(value, flag) {
|
|
256
|
+
if (!value?.trim()) throw new Error(`${flag} requires a JSON value`);
|
|
257
|
+
try {
|
|
258
|
+
return JSON.parse(value);
|
|
259
|
+
} catch (err) {
|
|
260
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
261
|
+
throw new Error(`${flag} is not valid JSON: ${message}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function tokenizeArgs(raw) {
|
|
265
|
+
const tokens = [];
|
|
266
|
+
const re = /"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|(\S+)/g;
|
|
267
|
+
let match;
|
|
268
|
+
while ((match = re.exec(raw)) !== null) {
|
|
269
|
+
const value = match[1] ?? match[2] ?? match[3] ?? "";
|
|
270
|
+
tokens.push(value.replace(/\\(["'\\])/g, "$1"));
|
|
271
|
+
}
|
|
272
|
+
return tokens;
|
|
273
|
+
}
|
|
150
274
|
/**
|
|
151
275
|
* Replace the `name` field inside the FIRST `export const meta = { ... }` literal.
|
|
152
276
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.js","names":[],"sources":["../../../../src/chat-commands/builtins/workflow.ts"],"sourcesContent":["/**\n * `/workflows` and `/workflow <subcommand>` — read-only commands for browsing\n * saved workflows.\n *\n * Why only read commands here? Slash command results are sent to the user; they\n * are NOT injected back into the agent's turn. Triggering a workflow run from\n * the slash layer would require a non-trivial cross-cutting \"inject this as the\n * next user message\" hook that doesn't exist yet. Instead, the workflow tool\n * understands `name`, and its description tells the model to prefer that route\n * whenever a user mentions a saved workflow by name. Plain text — \"run the\n * audit_repo workflow\" — works end-to-end.\n *\n * `/workflows` and `/workflow view` make discovery cheap, which is the missing\n * piece.\n */\n\nimport { commandRegistry } from '../registry.js';\nimport type { CommandContext, CommandDefinition } from '../types.js';\nimport { bulletList, code, joinBlocks, section } from '../format-output.js';\n\nimport { createWorkflowCatalog } from '../../agent/workflow/catalog.js';\nimport { getLastWorkflowMemory } from '../../agent/workflow/last-run-memory.js';\nimport type { CatalogEntry } from '../../agent/workflow/catalog.js';\n\nconst VIEW_MAX_LINES = 200;\n\nfunction formatEntryDetail(entry: CatalogEntry): string {\n const tags = entry.tags?.length ? `[${entry.tags.join(', ')}] ` : '';\n const agents = entry.estimatedAgents\n ? ` (~${entry.estimatedAgents.min}–${entry.estimatedAgents.max} agents)`\n : '';\n return `${tags}${entry.description}${agents}`;\n}\n\nfunction formatWorkflowListContent(entries: CatalogEntry[], userDir: string): string {\n const grouped = {\n builtin: entries.filter((e) => e.source === 'builtin'),\n user: entries.filter((e) => e.source === 'user'),\n };\n const exampleName = entries[0]?.name ?? 'audit_repo';\n const blocks: string[] = [];\n\n if (grouped.user.length > 0) {\n blocks.push(\n joinBlocks(\n section('User workflows'),\n bulletList(grouped.user.map((e) => ({ label: e.name, detail: formatEntryDetail(e) }))),\n ),\n );\n }\n if (grouped.builtin.length > 0) {\n blocks.push(\n joinBlocks(\n section('Built-in workflows'),\n bulletList(grouped.builtin.map((e) => ({ label: e.name, detail: formatEntryDetail(e) }))),\n ),\n );\n }\n\n blocks.push(\n joinBlocks(\n section('How to run'),\n bulletList([\n `Plain language: \"run the ${exampleName} workflow\"`,\n `Inspect source: ${code(`/workflow view ${exampleName}`)}`,\n `Add your own: drop a ${code('.js')} at ${code(userDir)}`,\n ]),\n ),\n );\n\n return joinBlocks(...blocks);\n}\n\nconst workflowsCommand: CommandDefinition = {\n id: 'system.workflows',\n name: 'workflows',\n description: 'List saved workflows (built-in + ~/.xopc/workflows/)',\n category: 'system',\n scope: ['global', 'private', 'group'],\n handler: async (_ctx: CommandContext) => {\n const catalog = createWorkflowCatalog();\n const entries = catalog.list();\n if (entries.length === 0) {\n return {\n content: `No workflows found. Drop a script at ${code(`${catalog.userDir}/<name>.js`)} to add one.`,\n success: true,\n };\n }\n return { content: formatWorkflowListContent(entries, catalog.userDir), success: true };\n },\n};\n\nexport const workflowCommand: CommandDefinition = {\n id: 'system.workflow',\n name: 'workflow',\n description: 'Inspect or manage saved workflows. Subcommands: list, view <name>',\n category: 'system',\n scope: ['global', 'private', 'group'],\n acceptsArgs: true,\n examples: ['/workflow list', '/workflow view audit_repo'],\n handler: async (ctx: CommandContext, args: string) => {\n const trimmed = args.trim();\n if (!trimmed || trimmed.toLowerCase() === 'list') {\n return workflowsCommand.handler(ctx, '');\n }\n const [sub, ...rest] = trimmed.split(/\\s+/);\n const subLower = sub.toLowerCase();\n const target = rest.join(' ').trim();\n\n if (subLower === 'view' || subLower === 'show' || subLower === 'cat') {\n if (!target) {\n return { content: `usage: ${code('/workflow view <name>')}`, success: false };\n }\n const catalog = createWorkflowCatalog();\n try {\n const loaded = catalog.load(target);\n const lines = loaded.script.split('\\n');\n const visible =\n lines.length > VIEW_MAX_LINES\n ? [...lines.slice(0, VIEW_MAX_LINES), `… (truncated; ${lines.length - VIEW_MAX_LINES} more lines)`]\n : lines;\n const source = loaded.source === 'user' ? loaded.path ?? 'user' : 'built-in';\n return {\n content: joinBlocks(\n `**${loaded.name}** (${source}) — ${loaded.meta.description}`,\n '```js\\n' + visible.join('\\n') + '\\n```',\n ),\n success: true,\n };\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n return { content: `error: ${message}`, success: false };\n }\n }\n\n if (subLower === 'run' || subLower === 'start') {\n const name = target || '<name>';\n return {\n content: joinBlocks(\n `To run a workflow, ask in plain language: \"run the ${name} workflow\".`,\n `The assistant will call the workflow tool with ${code(`name=\"${name}\"`)} and stream progress inline.`,\n ),\n success: true,\n };\n }\n\n if (subLower === 'save') {\n if (!target) {\n return { content: `usage: ${code('/workflow save <name>')}`, success: false };\n }\n const last = getLastWorkflowMemory().get(ctx.sessionKey);\n if (!last) {\n return {\n content:\n 'No workflow has run successfully in this session yet. Run one first (e.g. ask \"run the audit_repo workflow\"), then `/workflow save <name>`.',\n success: false,\n };\n }\n const catalog = createWorkflowCatalog();\n try {\n // Allow the user to rename: if target differs from meta.name, rewrite it\n // before saving so the file is addressable as `target`.\n const script =\n last.metaName === target ? last.script : rewriteMetaName(last.script, target);\n const { path } = catalog.save(target, script);\n return {\n content: joinBlocks(\n `✓ Saved workflow **${target}** → ${code(path)}`,\n bulletList([\n `Trigger with ${code(`/${target}`)} or \"run the ${target} workflow\"`,\n `Inspect with ${code(`/workflow view ${target}`)}`,\n ]),\n ),\n success: true,\n };\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n return { content: `error: ${message}`, success: false };\n }\n }\n\n return {\n content: joinBlocks(\n `Unknown subcommand \"${sub}\". Available: list, view ${code('<name>')}, save ${code('<name>')}.`,\n 'To run a workflow, ask in plain language (\"run the audit_repo workflow\") — the assistant uses the workflow tool with `name=\"...\"`.',\n ),\n success: false,\n };\n },\n};\n\n/**\n * Replace the `name` field inside the FIRST `export const meta = { ... }` literal.\n *\n * Why text-level (not AST re-emit)? The parser already accepted the script\n * once (the runtime ran it), so the surrounding code is unchanged. A targeted\n * regex on the `name: '...'` slot inside the first object literal keeps the\n * user's formatting / comments / quote style intact, which an AST round-trip\n * would smash. The match anchors to the first `name:` after `export const meta`\n * and only touches that single value.\n */\nfunction rewriteMetaName(script: string, newName: string): string {\n const re = /(export\\s+const\\s+meta\\s*=\\s*\\{[^}]*?\\bname\\s*:\\s*)(['\"`])([^'\"`]*)\\2/;\n if (!re.test(script)) {\n throw new Error('could not locate meta.name in the recorded script to rewrite');\n }\n return script.replace(re, (_m, prefix, quote) => `${prefix}${quote}${newName}${quote}`);\n}\n\nexport function registerWorkflowCommands(): void {\n commandRegistry.register(workflowsCommand);\n commandRegistry.register(workflowCommand);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,iBAAiB;AAEvB,SAAS,kBAAkB,OAA6B;CACtD,MAAM,OAAO,MAAM,MAAM,SAAS,IAAI,MAAM,KAAK,KAAK,KAAK,CAAC,MAAM;CAClE,MAAM,SAAS,MAAM,kBACjB,MAAM,MAAM,gBAAgB,IAAI,GAAG,MAAM,gBAAgB,IAAI,YAC7D;AACJ,QAAO,GAAG,OAAO,MAAM,cAAc;;AAGvC,SAAS,0BAA0B,SAAyB,SAAyB;CACnF,MAAM,UAAU;EACd,SAAS,QAAQ,QAAQ,MAAM,EAAE,WAAW,UAAU;EACtD,MAAM,QAAQ,QAAQ,MAAM,E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CAAC,KACH,QAAO;IACL,SACE;IACF,SAAS;IACV;GAEH,MAAM,UAAU,uBAAuB;AACvC,OAAI;IAGF,MAAM,SACJ,KAAK,aAAa,SAAS,KAAK,SAAS,gBAAgB,KAAK,QAAQ,OAAO;IAC/E,MAAM,EAAE,SAAS,QAAQ,KAAK,QAAQ,OAAO;AAC7C,WAAO;KACL,SAAS,WACP,sBAAsB,OAAO,OAAO,KAAK,KAAK,IAC9C,WAAW,CACT,gBAAgB,KAAK,IAAI,SAAS,CAAC,eAAe,OAAO,aACzD,gBAAgB,KAAK,kBAAkB,SAAS,GACjD,CAAC,CACH;KACD,SAAS;KACV;YACM,GAAG;AAEV,WAAO;KAAE,SAAS,UADF,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE;KACnB,SAAS;KAAO;;;AAI3D,SAAO;GACL,SAAS,WACP,uBAAuB,IAAI,2BAA2B,KAAK,SAAS,CAAC,SAAS,KAAK,SAAS,CAAC,IAC7F,yIACD;GACD,SAAS;GACV;;CAEJ;;;;;;;;;;;AAYD,SAAS,gBAAgB,QAAgB,SAAyB;CAChE,MAAM,KAAK;AACX,KAAI,CAAC,GAAG,KAAK,OAAO,CAClB,OAAM,IAAI,MAAM,+DAA+D;AAEjF,QAAO,OAAO,QAAQ,KAAK,IAAI,QAAQ,UAAU,GAAG,SAAS,QAAQ,UAAU,QAAQ;;AAGzF,SAAgB,2BAAiC;AAC/C,iBAAgB,SAAS,iBAAiB;AAC1C,iBAAgB,SAAS,gBAAgB"}
|
|
1
|
+
{"version":3,"file":"workflow.js","names":[],"sources":["../../../../src/chat-commands/builtins/workflow.ts"],"sourcesContent":["/**\n * `/workflows` and `/workflow <subcommand>` — read-only commands for browsing\n * saved workflows.\n *\n * Why only read commands here? Slash command results are sent to the user; they\n * are NOT injected back into the agent's turn. Triggering a workflow run from\n * the slash layer would require a non-trivial cross-cutting \"inject this as the\n * next user message\" hook that doesn't exist yet. Instead, the workflow tool\n * understands `name`, and its description tells the model to prefer that route\n * whenever a user mentions a saved workflow by name. Plain text — \"run the\n * audit_repo workflow\" — works end-to-end.\n *\n * `/workflows` and `/workflow view` make discovery cheap, which is the missing\n * piece.\n */\n\nimport { commandRegistry } from '../registry.js';\nimport type { CommandContext, CommandDefinition } from '../types.js';\nimport { bulletList, code, joinBlocks, section } from '../format-output.js';\n\nimport { createWorkflowCatalog } from '../../agent/workflow/catalog.js';\nimport { getLastWorkflowMemory } from '../../agent/workflow/last-run-memory.js';\nimport type { CatalogEntry } from '../../agent/workflow/catalog.js';\nimport { extractProfileAgentId } from '../../config/agent-profile.js';\n\nconst VIEW_MAX_LINES = 200;\n\nfunction formatEntryDetail(entry: CatalogEntry): string {\n const tags = entry.tags?.length ? `[${entry.tags.join(', ')}] ` : '';\n const agents = entry.estimatedAgents\n ? ` (~${entry.estimatedAgents.min}–${entry.estimatedAgents.max} agents)`\n : '';\n return `${tags}${entry.description}${agents}`;\n}\n\nfunction formatWorkflowListContent(entries: CatalogEntry[], userDir: string): string {\n const grouped = {\n builtin: entries.filter((e) => e.source === 'builtin'),\n user: entries.filter((e) => e.source === 'user'),\n };\n const exampleName = entries[0]?.name ?? 'audit_repo';\n const blocks: string[] = [];\n\n if (grouped.user.length > 0) {\n blocks.push(\n joinBlocks(\n section('User workflows'),\n bulletList(grouped.user.map((e) => ({ label: e.name, detail: formatEntryDetail(e) }))),\n ),\n );\n }\n if (grouped.builtin.length > 0) {\n blocks.push(\n joinBlocks(\n section('Built-in workflows'),\n bulletList(grouped.builtin.map((e) => ({ label: e.name, detail: formatEntryDetail(e) }))),\n ),\n );\n }\n\n blocks.push(\n joinBlocks(\n section('How to run'),\n bulletList([\n `Plain language: \"run the ${exampleName} workflow\"`,\n `Inspect source: ${code(`/workflow view ${exampleName}`)}`,\n `Add your own: drop a ${code('.js')} at ${code(userDir)}`,\n ]),\n ),\n );\n\n return joinBlocks(...blocks);\n}\n\nconst workflowsCommand: CommandDefinition = {\n id: 'system.workflows',\n name: 'workflows',\n description: 'List saved workflows (built-in + ~/.xopc/workflows/)',\n category: 'system',\n scope: ['global', 'private', 'group'],\n handler: async (_ctx: CommandContext) => {\n const catalog = createWorkflowCatalog();\n const entries = catalog.list();\n if (entries.length === 0) {\n return {\n content: `No workflows found. Drop a script at ${code(`${catalog.userDir}/<name>.js`)} to add one.`,\n success: true,\n };\n }\n return { content: formatWorkflowListContent(entries, catalog.userDir), success: true };\n },\n};\n\nexport const workflowCommand: CommandDefinition = {\n id: 'system.workflow',\n name: 'workflow',\n description: 'Inspect or manage saved workflows. Subcommands: list, view <name>',\n category: 'system',\n scope: ['global', 'private', 'group'],\n acceptsArgs: true,\n examples: ['/workflow list', '/workflow view audit_repo'],\n handler: async (ctx: CommandContext, args: string) => {\n const trimmed = args.trim();\n if (!trimmed || trimmed.toLowerCase() === 'list') {\n return workflowsCommand.handler(ctx, '');\n }\n const [sub, ...rest] = trimmed.split(/\\s+/);\n const subLower = sub.toLowerCase();\n const target = rest.join(' ').trim();\n\n if (subLower === 'view' || subLower === 'show' || subLower === 'cat') {\n if (!target) {\n return { content: `usage: ${code('/workflow view <name>')}`, success: false };\n }\n const catalog = createWorkflowCatalog();\n try {\n const loaded = catalog.load(target);\n const lines = loaded.script.split('\\n');\n const visible =\n lines.length > VIEW_MAX_LINES\n ? [...lines.slice(0, VIEW_MAX_LINES), `… (truncated; ${lines.length - VIEW_MAX_LINES} more lines)`]\n : lines;\n const source = loaded.source === 'user' ? loaded.path ?? 'user' : 'built-in';\n return {\n content: joinBlocks(\n `**${loaded.name}** (${source}) — ${loaded.meta.description}`,\n '```js\\n' + visible.join('\\n') + '\\n```',\n ),\n success: true,\n };\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n return { content: `error: ${message}`, success: false };\n }\n }\n\n if (subLower === 'run' || subLower === 'start') {\n return runWorkflowFromCommand(ctx, target);\n }\n\n if (subLower === 'save') {\n if (!target) {\n return { content: `usage: ${code('/workflow save <name>')}`, success: false };\n }\n const last = getLastWorkflowMemory().get(ctx.sessionKey);\n if (!last) {\n return {\n content:\n 'No workflow has run successfully in this session yet. Run one first (e.g. ask \"run the audit_repo workflow\"), then `/workflow save <name>`.',\n success: false,\n };\n }\n const catalog = createWorkflowCatalog();\n try {\n // Allow the user to rename: if target differs from meta.name, rewrite it\n // before saving so the file is addressable as `target`.\n const script =\n last.metaName === target ? last.script : rewriteMetaName(last.script, target);\n const { path } = catalog.save(target, script);\n return {\n content: joinBlocks(\n `✓ Saved workflow **${target}** → ${code(path)}`,\n bulletList([\n `Trigger with ${code(`/${target}`)} or \"run the ${target} workflow\"`,\n `Inspect with ${code(`/workflow view ${target}`)}`,\n ]),\n ),\n success: true,\n };\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n return { content: `error: ${message}`, success: false };\n }\n }\n\n return {\n content: joinBlocks(\n `Unknown subcommand \"${sub}\". Available: list, view ${code('<name>')}, save ${code('<name>')}.`,\n `Run directly with ${code('/workflow run <name> [--goal \"...\"] [--json \\'{...}\\']')}.`,\n ),\n success: false,\n };\n },\n};\n\nasync function runWorkflowFromCommand(ctx: CommandContext, args: string) {\n if (!ctx.workflowRunApis) {\n return {\n content: 'Workflow runs are not available in this context.',\n success: false,\n };\n }\n\n let parsed: { name: string; goal?: string; input?: unknown };\n try {\n parsed = parseWorkflowRunArgs(args);\n } catch (err) {\n return {\n content: `error: ${err instanceof Error ? err.message : String(err)}`,\n success: false,\n };\n }\n if (!parsed.name) {\n return {\n content: `usage: ${code('/workflow run <name> [--goal \"...\"] [--json \\'{...}\\']')}`,\n success: false,\n };\n }\n\n const catalog = createWorkflowCatalog();\n try {\n catalog.load(parsed.name);\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n return { content: `error: ${message}`, success: false };\n }\n\n const agentId = extractProfileAgentId(ctx.sessionKey, ctx.config);\n const source =\n ctx.source === 'webui' || ctx.channelId === 'webchat'\n ? ({ kind: 'webui' as const, sessionKey: ctx.sessionKey })\n : ({ kind: 'chat' as const, sessionKey: ctx.sessionKey });\n const result = await ctx.workflowRunApis.startWorkflowRun({\n agentId,\n definitionId: parsed.name,\n goal: parsed.goal,\n input: parsed.input,\n parentSessionKey: ctx.sessionKey,\n source,\n });\n\n if (result.ok === false) {\n return {\n content: `error: ${result.message}`,\n success: false,\n metadata: {\n workflowRun: {\n ok: false,\n definitionId: parsed.name,\n code: result.code,\n message: result.message,\n },\n },\n };\n }\n\n const content = joinBlocks(\n `Started workflow **${parsed.name}**.`,\n bulletList([\n { label: 'runId', detail: code(result.runId) },\n { label: 'sessionKey', detail: code(result.sessionKey) },\n ]),\n );\n\n return {\n content,\n success: true,\n metadata: {\n workflowRun: {\n ok: true,\n definitionId: parsed.name,\n runId: result.runId,\n sessionKey: result.sessionKey,\n parentSessionKey: ctx.sessionKey,\n },\n },\n };\n}\n\nfunction parseWorkflowRunArgs(raw: string): { name: string; goal?: string; input?: unknown } {\n const tokens = tokenizeArgs(raw);\n const name = tokens.shift()?.trim() ?? '';\n let goal: string | undefined;\n let input: unknown;\n\n for (let i = 0; i < tokens.length; i += 1) {\n const token = tokens[i];\n if (token === '--goal' || token === '-g') {\n goal = tokens[++i]?.trim() || undefined;\n continue;\n }\n if (token.startsWith('--goal=')) {\n goal = token.slice('--goal='.length).trim() || undefined;\n continue;\n }\n if (token === '--json' || token === '--input') {\n const value = tokens[++i];\n input = parseJsonArg(value, token);\n continue;\n }\n if (token.startsWith('--json=')) {\n input = parseJsonArg(token.slice('--json='.length), '--json');\n continue;\n }\n if (token.startsWith('--input=')) {\n input = parseJsonArg(token.slice('--input='.length), '--input');\n continue;\n }\n if (!goal) {\n goal = [token, ...tokens.slice(i + 1)].join(' ').trim() || undefined;\n break;\n }\n }\n\n return { name, goal, input };\n}\n\nfunction parseJsonArg(value: string | undefined, flag: string): unknown {\n if (!value?.trim()) {\n throw new Error(`${flag} requires a JSON value`);\n }\n try {\n return JSON.parse(value);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n throw new Error(`${flag} is not valid JSON: ${message}`);\n }\n}\n\nfunction tokenizeArgs(raw: string): string[] {\n const tokens: string[] = [];\n const re = /\"([^\"\\\\]*(?:\\\\.[^\"\\\\]*)*)\"|'([^'\\\\]*(?:\\\\.[^'\\\\]*)*)'|(\\S+)/g;\n let match: RegExpExecArray | null;\n while ((match = re.exec(raw)) !== null) {\n const value = match[1] ?? match[2] ?? match[3] ?? '';\n tokens.push(value.replace(/\\\\([\"'\\\\])/g, '$1'));\n }\n return tokens;\n}\n\n/**\n * Replace the `name` field inside the FIRST `export const meta = { ... }` literal.\n *\n * Why text-level (not AST re-emit)? The parser already accepted the script\n * once (the runtime ran it), so the surrounding code is unchanged. A targeted\n * regex on the `name: '...'` slot inside the first object literal keeps the\n * user's formatting / comments / quote style intact, which an AST round-trip\n * would smash. The match anchors to the first `name:` after `export const meta`\n * and only touches that single value.\n */\nfunction rewriteMetaName(script: string, newName: string): string {\n const re = /(export\\s+const\\s+meta\\s*=\\s*\\{[^}]*?\\bname\\s*:\\s*)(['\"`])([^'\"`]*)\\2/;\n if (!re.test(script)) {\n throw new Error('could not locate meta.name in the recorded script to rewrite');\n }\n return script.replace(re, (_m, prefix, quote) => `${prefix}${quote}${newName}${quote}`);\n}\n\nexport function registerWorkflowCommands(): void {\n commandRegistry.register(workflowsCommand);\n commandRegistry.register(workflowCommand);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyBA,MAAM,iBAAiB;AAEvB,SAAS,kBAAkB,OAA6B;CACtD,MAAM,OAAO,MAAM,MAAM,SAAS,IAAI,MAAM,KAAK,KAAK,KAAK,CAAC,MAAM;CAClE,MAAM,SAAS,MAAM,kBACjB,MAAM,MAAM,gBAAgB,IAAI,GAAG,MAAM,gBAAgB,IAAI,YAC7D;AACJ,QAAO,GAAG,OAAO,MAAM,cAAc;;AAGvC,SAAS,0BAA0B,SAAyB,SAAyB;CACnF,MAAM,UAAU;EACd,SAAS,QAAQ,QAAQ,MAAM,EAAE,WAAW,UAAU;EACtD,MAAM,QAAQ,QAAQ,MA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E,SAAS;AAC7D;;AAEF,MAAI,MAAM,WAAW,WAAW,EAAE;AAChC,WAAQ,aAAa,MAAM,MAAM,EAAkB,EAAE,UAAU;AAC/D;;AAEF,MAAI,CAAC,MAAM;AACT,UAAO,CAAC,OAAO,GAAG,OAAO,MAAM,IAAI,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,MAAM,IAAI,KAAA;AAC3D;;;AAIJ,QAAO;EAAE;EAAM;EAAM;EAAO;;AAG9B,SAAS,aAAa,OAA2B,MAAuB;AACtE,KAAI,CAAC,OAAO,MAAM,CAChB,OAAM,IAAI,MAAM,GAAG,KAAK,wBAAwB;AAElD,KAAI;AACF,SAAO,KAAK,MAAM,MAAM;UACjB,KAAK;EACZ,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;AAChE,QAAM,IAAI,MAAM,GAAG,KAAK,sBAAsB,UAAU;;;AAI5D,SAAS,aAAa,KAAuB;CAC3C,MAAM,SAAmB,EAAE;CAC3B,MAAM,KAAK;CACX,IAAI;AACJ,SAAQ,QAAQ,GAAG,KAAK,IAAI,MAAM,MAAM;EACtC,MAAM,QAAQ,MAAM,MAAM,MAAM,MAAM,MAAM,MAAM;AAClD,SAAO,KAAK,MAAM,QAAQ,eAAe,KAAK,CAAC;;AAEjD,QAAO;;;;;;;;;;;;AAaT,SAAS,gBAAgB,QAAgB,SAAyB;CAChE,MAAM,KAAK;AACX,KAAI,CAAC,GAAG,KAAK,OAAO,CAClB,OAAM,IAAI,MAAM,+DAA+D;AAEjF,QAAO,OAAO,QAAQ,KAAK,IAAI,QAAQ,UAAU,GAAG,SAAS,QAAQ,UAAU,QAAQ;;AAGzF,SAAgB,2BAAiC;AAC/C,iBAAgB,SAAS,iBAAiB;AAC1C,iBAAgB,SAAS,gBAAgB"}
|
|
@@ -12,6 +12,7 @@ import type { SessionStore, SessionConfigStore } from '../session/index.js';
|
|
|
12
12
|
import type { ThinkLevel, ReasoningLevel, VerboseLevel } from '../agent/transcript/thinking-types.js';
|
|
13
13
|
import type { CompactionResult } from '../agent/memory/compaction.js';
|
|
14
14
|
import type { PersistentGoalApis } from '../agent/goals/persistent-goal-apis.js';
|
|
15
|
+
import type { WorkflowRunServiceLike } from '../workflows/service/workflow-run-service.types.js';
|
|
15
16
|
export interface CommandContextDeps {
|
|
16
17
|
sessionKey: string;
|
|
17
18
|
source: MessageSource;
|
|
@@ -39,6 +40,8 @@ export interface CommandContextDeps {
|
|
|
39
40
|
getUsage?: () => Promise<UsageStats>;
|
|
40
41
|
/** Stop current LLM turn and clear channel preview stream (Telegram draft, etc.) */
|
|
41
42
|
abortCurrentTurn?: () => Promise<void>;
|
|
43
|
+
/** Reload skills from disk and refresh active agent prompts. */
|
|
44
|
+
reloadSkills?: () => Promise<void>;
|
|
42
45
|
compactSession?: (sessionKey: string, options?: {
|
|
43
46
|
instructions?: string;
|
|
44
47
|
force?: boolean;
|
|
@@ -49,6 +52,7 @@ export interface CommandContextDeps {
|
|
|
49
52
|
}>;
|
|
50
53
|
getSessionContextReport?: (sessionKey: string, mode: 'list' | 'detail' | 'json') => Promise<string>;
|
|
51
54
|
persistentGoalApis?: PersistentGoalApis;
|
|
55
|
+
workflowRunService?: WorkflowRunServiceLike;
|
|
52
56
|
}
|
|
53
57
|
export declare class CommandContextImpl implements CommandContext {
|
|
54
58
|
readonly sessionKey: string;
|
|
@@ -59,7 +63,9 @@ export declare class CommandContextImpl implements CommandContext {
|
|
|
59
63
|
readonly isGroup: boolean;
|
|
60
64
|
readonly config: Config;
|
|
61
65
|
readonly abortCurrentTurn?: () => Promise<void>;
|
|
66
|
+
readonly reloadSkills?: () => Promise<void>;
|
|
62
67
|
readonly persistentGoalApis?: PersistentGoalApis;
|
|
68
|
+
readonly workflowRunApis?: CommandContext['workflowRunApis'];
|
|
63
69
|
private deps;
|
|
64
70
|
constructor(deps: CommandContextDeps);
|
|
65
71
|
reply(text: string, options?: ReplyOptions): Promise<void>;
|
|
@@ -19,7 +19,9 @@ var CommandContextImpl = class {
|
|
|
19
19
|
isGroup;
|
|
20
20
|
config;
|
|
21
21
|
abortCurrentTurn;
|
|
22
|
+
reloadSkills;
|
|
22
23
|
persistentGoalApis;
|
|
24
|
+
workflowRunApis;
|
|
23
25
|
deps;
|
|
24
26
|
constructor(deps) {
|
|
25
27
|
this.sessionKey = deps.sessionKey;
|
|
@@ -36,7 +38,17 @@ var CommandContextImpl = class {
|
|
|
36
38
|
await run();
|
|
37
39
|
};
|
|
38
40
|
}
|
|
41
|
+
if (deps.reloadSkills) {
|
|
42
|
+
const run = deps.reloadSkills;
|
|
43
|
+
this.reloadSkills = async () => {
|
|
44
|
+
await run();
|
|
45
|
+
};
|
|
46
|
+
}
|
|
39
47
|
this.persistentGoalApis = deps.persistentGoalApis;
|
|
48
|
+
if (deps.workflowRunService) this.workflowRunApis = {
|
|
49
|
+
service: deps.workflowRunService,
|
|
50
|
+
startWorkflowRun: (params) => deps.workflowRunService.startWorkflowRun(params)
|
|
51
|
+
};
|
|
40
52
|
}
|
|
41
53
|
async reply(text, options) {
|
|
42
54
|
await this.deps.replyHandler(text, options);
|