@xopcai/xopc 0.0.121 → 0.0.123
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 +23 -3
- package/README.zh-CN.md +23 -3
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-4AW4JgSU.js → agent-avatar-dicebear-Bicr3ZBg.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CxDSFHGx.js +2 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CE6GkGU2.js → app-management-settings-panel-CbEy9sR1.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BmaUjghw.js → appearance-settings-CTHja6n9.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-CyZdgqvm.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CX4_KWut.js → archive-plugin-Bpy64GjU.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-jf-PIIUU.js → attachment-load-DMkp4xSb.js} +1 -1
- package/dist/gateway/static/root/assets/automation-suggestion-card-KnYaP7NT.js +1 -0
- package/dist/gateway/static/root/assets/automations-page-8VLKM4au.js +1 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DG9XQikd.js → binary-plugins-DA9C5mCw.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Up_VIxLJ.js → block-editor-CiSXk_YC.js} +6 -6
- package/dist/gateway/static/root/assets/browser-settings-page-5tPg0DcP.js +8 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-CGM4OyMw.js → capability-presets-api-CEJ44WCU.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-CzWt0LBb.js → capability-presets-settings-panel-BJW3aVST.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-BEByL4_o.js → channel-recipient-api-CDhrhfhN.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-CorUCTrs.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-VKstC3sP.js +2 -0
- package/dist/gateway/static/root/assets/directory-picker-path-field-7jKfbH0J.js +1 -0
- package/dist/gateway/static/root/assets/dreaming-settings-m1-wmz4o.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DZxa_j7-.js → extension-debug-page-C9qQQrBS.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CseziW53.js → extension-page-DcBBMEGl.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-B_9J-xyo.js → extension-settings-page-BQ-jMMP9.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-Cs4ck8zA.js → fetch-Dtpbbe0s.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-Dl223a7r.js → gateway-config-api-BN6pyX2c.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-hQtgVmSR.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-IvePwjFE.js → gateway-startup-retry-BIET2x3y.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-BuIMDx6C.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-FEypCq74.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-CUCP6yCl.js → goals-config-api-CQm2r1Ty.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-C4-2_MLG.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-Dj87qPxv.js → goals-settings-DDrdRMxB.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-BJVok3Sl.js +1 -0
- package/dist/gateway/static/root/assets/index-CBDr5xjB.css +1 -0
- package/dist/gateway/static/root/assets/index-T0SaNd5a.js +191 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DJgYw0nB.js → keyboard-shortcuts-settings-C2TuQppb.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DwkwPgid.js +2 -0
- package/dist/gateway/static/root/assets/{markdown-split-gnQ_EiGo.js → markdown-split-DhONQ81k.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CQV-mgJn.js → media-plugins-DS44pJzr.js} +1 -1
- package/dist/gateway/static/root/assets/messages-avfvyZuQ.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-huNY4A1G.js +2 -0
- package/dist/gateway/static/root/assets/notes-page-DdfGuEZ1.js +1 -0
- package/dist/gateway/static/root/assets/notes-workbench-B0bT9Hqa.js +2 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BPMXC-2u.js → preview-open-alternatives-Dej6zHnr.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CjxhPorG.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-C4Z5OJMF.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-CVCOPUVd.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BEHqwZjz.js → save-bar-controls-Zu1FzH6z.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-CMY25m97.js → schedule-field-BW78mKc0.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CxjxsFfg.js → schema-form-Cc-IOydE.js} +1 -1
- package/dist/gateway/static/root/assets/segmented-styles-BL8oLBEp.js +1 -0
- package/dist/gateway/static/root/assets/sessions-page-B4qExXHC.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-Ce8yLTBi.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-s-kiLAxP.js → settings-collapsible-section-DIpIYht_.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-CIxIEYxU.js → settings-form-section-BFxBNxOG.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-C4fivemT.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-layout-CLx4o2PN.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-Kyc4eUf0.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-ZswWCrDu.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-Bu76CMiC.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-D-CFg86j.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-CUU4f6Ss.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-Czjf0kLJ.js → system-settings-panel-3ZNcGRhS.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-Cmt8SYdI.js → typed-models-lib-bpzZjiVF.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-DyM-ckEQ.js → use-channel-catalog-BCjZLZ3O.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-BygLv8vm.js → user-profile-settings-panel-CIXafITi.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-CloW8coB.js → utils-DXMtz5j_.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-C1MrQD8R.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-DqizIcY5.js +3 -0
- package/dist/gateway/static/root/assets/workflow-start-dialog-B4sZpTDQ.js +1 -0
- package/dist/gateway/static/root/assets/workflows-page-B3sVNPFk.js +18 -0
- package/dist/gateway/static/root/index.html +5 -5
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +2 -0
- package/dist/src/agent/agent-manager.js +47 -7
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/context/project-context.d.ts +19 -0
- package/dist/src/agent/context/project-context.js +90 -0
- package/dist/src/agent/context/project-context.js.map +1 -0
- package/dist/src/agent/goals/goal-locale.js +2 -2
- package/dist/src/agent/memory/types.d.ts +1 -0
- package/dist/src/agent/prompt/service-prompt-builder.d.ts +1 -0
- package/dist/src/agent/prompt/service-prompt-builder.js +2 -0
- package/dist/src/agent/prompt/service-prompt-builder.js.map +1 -1
- package/dist/src/agent/prompt/system-prompt-params.d.ts +2 -0
- package/dist/src/agent/prompt/system-prompt-params.js +1 -0
- package/dist/src/agent/prompt/system-prompt-params.js.map +1 -1
- package/dist/src/agent/prompt/system-prompt.d.ts +1 -0
- package/dist/src/agent/prompt/system-prompt.js +2 -1
- package/dist/src/agent/prompt/system-prompt.js.map +1 -1
- package/dist/src/agent/service.js +4 -3
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/session/session-config-service.js +6 -1
- package/dist/src/agent/session/session-config-service.js.map +1 -1
- package/dist/src/agent/session/session-hydrator.js +7 -3
- package/dist/src/agent/session/session-hydrator.js.map +1 -1
- package/dist/src/agent/session/session-inspector.js +9 -5
- package/dist/src/agent/session/session-inspector.js.map +1 -1
- package/dist/src/agent/starter-agents.js +5 -34
- package/dist/src/agent/starter-agents.js.map +1 -1
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/goal-tool.d.ts +5 -1
- package/dist/src/agent/tools/goal-tool.js +8 -2
- package/dist/src/agent/tools/goal-tool.js.map +1 -1
- package/dist/src/agent/tools/index.d.ts +1 -1
- package/dist/src/agent/workflow/index.js +2 -2
- package/dist/src/agent/workflow/runtime.js +1 -1
- package/dist/src/automations/api/routes.js +13 -2
- package/dist/src/automations/api/routes.js.map +1 -1
- package/dist/src/automations/domain/types.d.ts +2 -0
- package/dist/src/automations/domain/validation.d.ts +3 -0
- package/dist/src/automations/domain/validation.js +1 -0
- package/dist/src/automations/domain/validation.js.map +1 -1
- package/dist/src/automations/draft/automation-draft-validator.d.ts +1 -0
- package/dist/src/automations/service/action-executor.js +3 -1
- package/dist/src/automations/service/action-executor.js.map +1 -1
- package/dist/src/automations/service/automation-service.d.ts +4 -1
- package/dist/src/automations/service/automation-service.js +2 -2
- package/dist/src/automations/service/automation-service.js.map +1 -1
- package/dist/src/automations/storage/automation-repository.d.ts +3 -1
- package/dist/src/automations/storage/automation-repository.js +7 -5
- package/dist/src/automations/storage/automation-repository.js.map +1 -1
- package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
- package/dist/src/automations/storage/automation-run-repository.js +12 -1
- package/dist/src/automations/storage/automation-run-repository.js.map +1 -1
- package/dist/src/chat-commands/builtins/goal.js +4 -1
- package/dist/src/chat-commands/builtins/goal.js.map +1 -1
- package/dist/src/chat-commands/context.js +2 -1
- package/dist/src/chat-commands/context.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/agent.js +2 -2
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/goal.js +27 -4
- package/dist/src/cli/commands/goal.js.map +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/commands/profile.js +1 -1
- package/dist/src/cli/commands/project.d.ts +4 -0
- package/dist/src/cli/commands/project.js +239 -0
- package/dist/src/cli/commands/project.js.map +1 -0
- package/dist/src/cli/commands/tunnel.js +1 -1
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/cli/extension-cli-register.js +1 -1
- package/dist/src/config/index.js +1 -1
- package/dist/src/gateway/hono/routes/goals.js +51 -4
- package/dist/src/gateway/hono/routes/goals.js.map +1 -1
- package/dist/src/gateway/hono/routes/index.js +2 -0
- package/dist/src/gateway/hono/routes/index.js.map +1 -1
- package/dist/src/gateway/hono/routes/memory.js +5 -1
- package/dist/src/gateway/hono/routes/memory.js.map +1 -1
- package/dist/src/gateway/hono/routes/notes.js +5 -0
- package/dist/src/gateway/hono/routes/notes.js.map +1 -1
- package/dist/src/gateway/hono/routes/projects.d.ts +3 -0
- package/dist/src/gateway/hono/routes/projects.js +662 -0
- package/dist/src/gateway/hono/routes/projects.js.map +1 -0
- package/dist/src/gateway/hono/routes/sessions.js +47 -7
- package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +27 -4
- package/dist/src/gateway/hono/routes/workflows.js.map +1 -1
- package/dist/src/gateway/run-loop.js +1 -1
- package/dist/src/gateway/service.d.ts +3 -0
- package/dist/src/gateway/service.js +10 -3
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/goals/goal-service.d.ts +1 -1
- package/dist/src/goals/goal-service.js +2 -1
- package/dist/src/goals/goal-service.js.map +1 -1
- package/dist/src/goals/goal-store.d.ts +1 -1
- package/dist/src/goals/goal-store.js +12 -6
- package/dist/src/goals/goal-store.js.map +1 -1
- package/dist/src/goals/goal-workflow-judge.js +1 -1
- package/dist/src/goals/types.d.ts +3 -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/notes/agent-context.js +2 -2
- package/dist/src/projects/automation-bind.d.ts +1 -0
- package/dist/src/projects/automation-bind.js +16 -0
- package/dist/src/projects/automation-bind.js.map +1 -0
- package/dist/src/projects/goal-bind.d.ts +4 -0
- package/dist/src/projects/goal-bind.js +40 -0
- package/dist/src/projects/goal-bind.js.map +1 -0
- package/dist/src/projects/index.d.ts +12 -0
- package/dist/src/projects/index.js +12 -0
- package/dist/src/projects/memory-bind.d.ts +1 -0
- package/dist/src/projects/memory-bind.js +16 -0
- package/dist/src/projects/memory-bind.js.map +1 -0
- package/dist/src/projects/project-agent.d.ts +10 -0
- package/dist/src/projects/project-agent.js +27 -0
- package/dist/src/projects/project-agent.js.map +1 -0
- package/dist/src/projects/project-loop.d.ts +58 -0
- package/dist/src/projects/project-loop.js +118 -0
- package/dist/src/projects/project-loop.js.map +1 -0
- package/dist/src/projects/project-service.d.ts +40 -0
- package/dist/src/projects/project-service.js +187 -0
- package/dist/src/projects/project-service.js.map +1 -0
- package/dist/src/projects/project-store.d.ts +31 -0
- package/dist/src/projects/project-store.js +193 -0
- package/dist/src/projects/project-store.js.map +1 -0
- package/dist/src/projects/session-bind.d.ts +5 -0
- package/dist/src/projects/session-bind.js +46 -0
- package/dist/src/projects/session-bind.js.map +1 -0
- package/dist/src/projects/types.d.ts +62 -0
- package/dist/src/projects/types.js +1 -0
- package/dist/src/projects/workflow-bind.d.ts +1 -0
- package/dist/src/projects/workflow-bind.js +16 -0
- package/dist/src/projects/workflow-bind.js.map +1 -0
- package/dist/src/projects/workspace-project.d.ts +22 -0
- package/dist/src/projects/workspace-project.js +143 -0
- package/dist/src/projects/workspace-project.js.map +1 -0
- package/dist/src/projects/workspace.d.ts +5 -0
- package/dist/src/projects/workspace.js +25 -0
- package/dist/src/projects/workspace.js.map +1 -0
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/index.js +3 -3
- package/dist/src/session/session-workspace.d.ts +4 -2
- package/dist/src/session/session-workspace.js +10 -3
- package/dist/src/session/session-workspace.js.map +1 -1
- package/dist/src/session/types.d.ts +3 -0
- package/dist/src/session/types.js.map +1 -1
- package/dist/src/storage/sqlite/memory-records-repository.d.ts +3 -0
- package/dist/src/storage/sqlite/memory-records-repository.js +16 -5
- package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/019_projects.sql +40 -0
- package/dist/src/storage/sqlite/migrations/020_project_default_agent.sql +1 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/notes-repository.js +20 -4
- package/dist/src/storage/sqlite/notes-repository.js.map +1 -1
- package/dist/src/storage/sqlite/row-mappers.d.ts +2 -0
- package/dist/src/storage/sqlite/row-mappers.js +2 -0
- package/dist/src/storage/sqlite/row-mappers.js.map +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-repository.js +10 -5
- package/dist/src/storage/sqlite/session-repository.js.map +1 -1
- package/dist/src/storage/sqlite/transcript-repository.js +8 -0
- package/dist/src/storage/sqlite/transcript-repository.js.map +1 -1
- package/dist/src/tui/backends/embedded-backend.d.ts +7 -1
- package/dist/src/tui/backends/embedded-backend.js +41 -2
- package/dist/src/tui/backends/embedded-backend.js.map +1 -1
- package/dist/src/tui/backends/gateway-sse-backend.d.ts +7 -1
- package/dist/src/tui/backends/gateway-sse-backend.js +22 -0
- package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
- package/dist/src/tui/tui-backend.d.ts +16 -0
- package/dist/src/tui/tui-commands.js +145 -0
- package/dist/src/tui/tui-commands.js.map +1 -1
- package/dist/src/tui/tui.js +21 -0
- package/dist/src/tui/tui.js.map +1 -1
- package/dist/src/workflows/domain/run.d.ts +1 -0
- package/dist/src/workflows/domain/run.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 +18 -4
- package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
- package/dist/src/workflows/service/workflow-run-service.types.d.ts +2 -0
- package/dist/src/workflows/service/workflow-session-bridge.d.ts +1 -0
- package/dist/src/workflows/service/workflow-session-bridge.js +3 -0
- package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
- package/dist/src/workflows/store/run-index-store.d.ts +1 -0
- package/dist/src/workflows/store/run-index-store.js +13 -3
- package/dist/src/workflows/store/run-index-store.js.map +1 -1
- package/dist/src/workflows/store/run-store.d.ts +3 -1
- package/dist/src/workflows/store/run-store.js +5 -2
- package/dist/src/workflows/store/run-store.js.map +1 -1
- package/package.json +10 -1
- package/dist/gateway/static/root/assets/agents-2SVUUPlp.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-BWeQ1I49.js +0 -1
- package/dist/gateway/static/root/assets/automation-suggestion-card-BHk5rtJz.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-QHotl53D.js +0 -1
- package/dist/gateway/static/root/assets/browser-settings-page-Cmwi6IIQ.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-BOMCUe2J.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-C-Dexk_F.js +0 -2
- package/dist/gateway/static/root/assets/dreaming-settings-WPEj8pir.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-DdzbtW9R.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-Dxldogms.js +0 -1
- package/dist/gateway/static/root/assets/goals-page-DU5Nd6Xp.js +0 -2
- package/dist/gateway/static/root/assets/heartbeat-settings-Cgm5JmwH.js +0 -1
- package/dist/gateway/static/root/assets/index-BU1pvxmS.js +0 -191
- package/dist/gateway/static/root/assets/index-l54WfSqe.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-C10aS4XO.js +0 -2
- package/dist/gateway/static/root/assets/messages-C6Kc4Jhf.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-B35CAfg6.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-page-Brlwse8x.js +0 -2
- package/dist/gateway/static/root/assets/note-image-lightbox-BthwKjLA.js +0 -1
- package/dist/gateway/static/root/assets/note-time-hm6JO_Wi.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-CoAwRc7L.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-B36RQ05h.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-73THChnj.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CR9VsY-R.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-BJ1AhfKI.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-layout--6qT7ZJa.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-C1TtS1vJ.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-BZADSbS1.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-gqC8Rmhy.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-C9P-WYvS.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CEpSvOhF.js +0 -2
- package/dist/gateway/static/root/assets/voice-api-key-field-BsoqJba6.js +0 -1
- package/dist/gateway/static/root/assets/voice-player-store-DduWlJYV.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-CcQeX6l5.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-CeA8A9Ef.js +0 -18
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
import { getSqliteDatabase } from "../../../storage/sqlite/transaction.js";
|
|
2
|
+
import { GoalService } from "../../../goals/goal-service.js";
|
|
3
|
+
import "../../../goals/index.js";
|
|
4
|
+
import { getSessionMetadata } from "../../../storage/sqlite/session-repository.js";
|
|
5
|
+
import { loadTranscriptRowsForSession } from "../../../storage/sqlite/transcript-repository.js";
|
|
6
|
+
import { listMemoryRecords, upsertMemoryRecord } from "../../../storage/sqlite/memory-records-repository.js";
|
|
7
|
+
import "../../../storage/sqlite/index.js";
|
|
8
|
+
import { ProjectWorkspaceConflictError, ProjectWorkspaceMissingError } from "../../../projects/workspace-project.js";
|
|
9
|
+
import { isValidProjectAgentId, normalizeProjectAgentId, resolveProjectAgentId } from "../../../projects/project-agent.js";
|
|
10
|
+
import { buildProjectLoopOverview } from "../../../projects/project-loop.js";
|
|
11
|
+
import "../../../projects/index.js";
|
|
12
|
+
import { createGatewayRouteLogger } from "../lib/route-logger.js";
|
|
13
|
+
import * as path$1 from "node:path";
|
|
14
|
+
import { readdir, realpath, stat } from "node:fs/promises";
|
|
15
|
+
//#region src/gateway/hono/routes/projects.ts
|
|
16
|
+
const log = createGatewayRouteLogger("Projects");
|
|
17
|
+
function parseProjectStatus(raw) {
|
|
18
|
+
return raw === "active" || raw === "paused" || raw === "archived" ? raw : void 0;
|
|
19
|
+
}
|
|
20
|
+
function parseLimit(raw, fallback = 50) {
|
|
21
|
+
if (!raw) return void 0;
|
|
22
|
+
const n = Number.parseInt(raw, 10);
|
|
23
|
+
return Number.isFinite(n) ? Math.min(500, Math.max(1, n)) : fallback;
|
|
24
|
+
}
|
|
25
|
+
function textField(body, key) {
|
|
26
|
+
const value = body[key];
|
|
27
|
+
return typeof value === "string" ? value : void 0;
|
|
28
|
+
}
|
|
29
|
+
function optionalTextField(body, key) {
|
|
30
|
+
if (!(key in body)) return void 0;
|
|
31
|
+
const value = body[key];
|
|
32
|
+
return typeof value === "string" ? value : null;
|
|
33
|
+
}
|
|
34
|
+
const SKIP_FILE_NAMES = new Set([".git", "node_modules"]);
|
|
35
|
+
function normalizeRelativePath(raw) {
|
|
36
|
+
return (raw ?? "").trim().replaceAll("\\", "/").replace(/^\/+/, "");
|
|
37
|
+
}
|
|
38
|
+
function isWithinDirectory(root, target) {
|
|
39
|
+
const relativePath = path$1.relative(root, target);
|
|
40
|
+
return relativePath === "" || !relativePath.startsWith("..") && !path$1.isAbsolute(relativePath);
|
|
41
|
+
}
|
|
42
|
+
function textFromTranscriptContent(content) {
|
|
43
|
+
if (typeof content === "string") return content;
|
|
44
|
+
if (!Array.isArray(content)) return "";
|
|
45
|
+
return content.map((part) => {
|
|
46
|
+
if (!part || typeof part !== "object") return "";
|
|
47
|
+
const record = part;
|
|
48
|
+
return typeof record.text === "string" ? record.text : "";
|
|
49
|
+
}).filter(Boolean).join("\n");
|
|
50
|
+
}
|
|
51
|
+
function buildSessionSummaryMemoryContent(sessionKey, explicitSummary) {
|
|
52
|
+
const summary = explicitSummary?.trim();
|
|
53
|
+
if (summary) return summary;
|
|
54
|
+
const lines = loadTranscriptRowsForSession(sessionKey).filter((row) => {
|
|
55
|
+
if (!row || typeof row !== "object") return false;
|
|
56
|
+
const role = row.role;
|
|
57
|
+
return role === "user" || role === "assistant" || role === "compactionSummary" || role === "branchSummary";
|
|
58
|
+
}).slice(-12).map((row) => {
|
|
59
|
+
const record = row;
|
|
60
|
+
const rowRole = typeof record.role === "string" ? record.role : "message";
|
|
61
|
+
const role = rowRole === "compactionSummary" || rowRole === "branchSummary" ? "summary" : rowRole;
|
|
62
|
+
const compact = ((typeof record.summary === "string" ? record.summary : void 0) ?? textFromTranscriptContent(record.content)).trim().replace(/\s+/g, " ").slice(0, 280);
|
|
63
|
+
return compact ? `- ${role}: ${compact}` : "";
|
|
64
|
+
}).filter(Boolean);
|
|
65
|
+
return lines.length > 0 ? [`Session summary for ${sessionKey}:`, ...lines].join("\n") : `Session summary for ${sessionKey}: no transcript content available.`;
|
|
66
|
+
}
|
|
67
|
+
function listFailedProjectWorkflowRuns(projectId, limit = 5) {
|
|
68
|
+
return getSqliteDatabase().prepare(`SELECT run_id, definition_id, status, created_at_ms, error_message
|
|
69
|
+
FROM workflow_runs
|
|
70
|
+
WHERE project_id = ? AND status IN ('failed', 'timeout', 'cancelled')
|
|
71
|
+
ORDER BY created_at_ms DESC
|
|
72
|
+
LIMIT ?`).all(projectId, Math.max(1, Math.min(20, Math.floor(limit)))).map((row) => ({
|
|
73
|
+
runId: row.run_id,
|
|
74
|
+
definitionId: row.definition_id,
|
|
75
|
+
status: row.status,
|
|
76
|
+
createdAt: row.created_at_ms,
|
|
77
|
+
errorMessage: row.error_message ?? void 0
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
80
|
+
function buildProjectDigestMemoryContent(input) {
|
|
81
|
+
const lines = [
|
|
82
|
+
`Project digest: ${input.projectName}`,
|
|
83
|
+
`Status: ${input.digest.summary}`,
|
|
84
|
+
input.digest.nextAction ? `Next: ${input.digest.nextAction}` : void 0
|
|
85
|
+
].filter(Boolean);
|
|
86
|
+
if (input.attentionItems.length > 0) {
|
|
87
|
+
lines.push("", "Attention:");
|
|
88
|
+
for (const item of input.attentionItems.slice(0, 8)) lines.push(`- ${item.kind}: ${item.title}${item.detail ? ` - ${item.detail}` : ""}`);
|
|
89
|
+
}
|
|
90
|
+
if (input.timeline.length > 0) {
|
|
91
|
+
lines.push("", "Recent activity:");
|
|
92
|
+
for (const item of input.timeline.slice(0, 8)) lines.push(`- ${item.kind}: ${item.title}${item.detail ? ` - ${item.detail}` : ""}`);
|
|
93
|
+
}
|
|
94
|
+
return lines.join("\n");
|
|
95
|
+
}
|
|
96
|
+
function projectDigestMemoryRecordId(projectId) {
|
|
97
|
+
return `project-digest:${projectId}`;
|
|
98
|
+
}
|
|
99
|
+
function registerProjectsRoutes(authenticated, deps) {
|
|
100
|
+
const { service } = deps;
|
|
101
|
+
const goals = new GoalService();
|
|
102
|
+
authenticated.post("/api/projects", async (c) => {
|
|
103
|
+
const body = await c.req.json().catch(() => ({}));
|
|
104
|
+
const name = textField(body, "name")?.trim();
|
|
105
|
+
const workspaceRoot = textField(body, "workspaceRoot")?.trim();
|
|
106
|
+
if (!name && !workspaceRoot) return c.json({
|
|
107
|
+
ok: false,
|
|
108
|
+
error: "Missing name"
|
|
109
|
+
}, 400);
|
|
110
|
+
const defaultAgentId = normalizeProjectAgentId(textField(body, "defaultAgentId"));
|
|
111
|
+
if (!isValidProjectAgentId(service.currentConfig, defaultAgentId)) return c.json({
|
|
112
|
+
ok: false,
|
|
113
|
+
error: "Default agent not found"
|
|
114
|
+
}, 400);
|
|
115
|
+
try {
|
|
116
|
+
const project = service.projects.create({
|
|
117
|
+
name,
|
|
118
|
+
description: textField(body, "description"),
|
|
119
|
+
defaultAgentId,
|
|
120
|
+
workspaceRoot,
|
|
121
|
+
createWorkspaceRoot: body.createWorkspaceRoot === true,
|
|
122
|
+
brief: textField(body, "brief"),
|
|
123
|
+
instructions: textField(body, "instructions")
|
|
124
|
+
});
|
|
125
|
+
return c.json({
|
|
126
|
+
ok: true,
|
|
127
|
+
project
|
|
128
|
+
}, 201);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
if (error instanceof ProjectWorkspaceConflictError) return c.json({
|
|
131
|
+
ok: false,
|
|
132
|
+
code: "workspace_already_bound",
|
|
133
|
+
error: error.message,
|
|
134
|
+
project: error.project
|
|
135
|
+
}, 409);
|
|
136
|
+
if (error instanceof ProjectWorkspaceMissingError) return c.json({
|
|
137
|
+
ok: false,
|
|
138
|
+
code: "workspace_root_missing",
|
|
139
|
+
error: error.message,
|
|
140
|
+
workspaceRoot: error.workspaceRoot
|
|
141
|
+
}, 409);
|
|
142
|
+
return c.json({
|
|
143
|
+
ok: false,
|
|
144
|
+
error: error instanceof Error ? error.message : String(error)
|
|
145
|
+
}, 400);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
authenticated.get("/api/projects", async (c) => {
|
|
149
|
+
const status = parseProjectStatus(c.req.query("status"));
|
|
150
|
+
const result = service.projects.list({
|
|
151
|
+
...status ? { status } : {},
|
|
152
|
+
search: c.req.query("search"),
|
|
153
|
+
sortBy: c.req.query("sortBy"),
|
|
154
|
+
sortOrder: c.req.query("sortOrder"),
|
|
155
|
+
limit: parseLimit(c.req.query("limit")),
|
|
156
|
+
offset: c.req.query("offset") ? Math.max(0, Number.parseInt(c.req.query("offset"), 10) || 0) : void 0
|
|
157
|
+
});
|
|
158
|
+
return c.json({
|
|
159
|
+
ok: true,
|
|
160
|
+
...result
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
authenticated.get("/api/projects/suggestions", async (c) => {
|
|
164
|
+
const sessionKey = c.req.query("sessionKey")?.trim();
|
|
165
|
+
return c.json({
|
|
166
|
+
ok: true,
|
|
167
|
+
suggestions: sessionKey ? service.projects.suggestProjectsForSession(sessionKey) : []
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
authenticated.post("/api/projects/resolve-workspace", async (c) => {
|
|
171
|
+
const body = await c.req.json().catch(() => ({}));
|
|
172
|
+
const workspacePath = textField(body, "workspacePath")?.trim();
|
|
173
|
+
if (!workspacePath) return c.json({
|
|
174
|
+
ok: false,
|
|
175
|
+
error: "Missing workspacePath"
|
|
176
|
+
}, 400);
|
|
177
|
+
const agentId = textField(body, "agentId")?.trim() || "main";
|
|
178
|
+
let match;
|
|
179
|
+
try {
|
|
180
|
+
match = service.projects.resolveOrCreateForWorkspacePath({
|
|
181
|
+
workspacePath,
|
|
182
|
+
agentId,
|
|
183
|
+
autoCreate: body.autoCreate !== false
|
|
184
|
+
});
|
|
185
|
+
} catch (error) {
|
|
186
|
+
if (error instanceof ProjectWorkspaceConflictError) match = {
|
|
187
|
+
project: error.project,
|
|
188
|
+
reason: "exact",
|
|
189
|
+
created: false
|
|
190
|
+
};
|
|
191
|
+
else throw error;
|
|
192
|
+
}
|
|
193
|
+
if (!match) return c.json({
|
|
194
|
+
ok: true,
|
|
195
|
+
project: null
|
|
196
|
+
});
|
|
197
|
+
const sessionKey = textField(body, "sessionKey")?.trim();
|
|
198
|
+
if (sessionKey) {
|
|
199
|
+
if (!getSessionMetadata(sessionKey)) await service.sessionIndexInstance.saveMessages(sessionKey, [], { metadata: {
|
|
200
|
+
sourceChannel: "tui",
|
|
201
|
+
sourceChatId: `default:direct:${sessionKey}`,
|
|
202
|
+
sessionType: "chat",
|
|
203
|
+
projectId: match.project.id,
|
|
204
|
+
routing: {
|
|
205
|
+
agentId,
|
|
206
|
+
source: "tui",
|
|
207
|
+
accountId: "default",
|
|
208
|
+
peerKind: "direct",
|
|
209
|
+
peerId: sessionKey
|
|
210
|
+
}
|
|
211
|
+
} });
|
|
212
|
+
service.projects.attachSession(sessionKey, match.project.id);
|
|
213
|
+
}
|
|
214
|
+
return c.json({
|
|
215
|
+
ok: true,
|
|
216
|
+
...match
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
authenticated.get("/api/projects/:id/overview", async (c) => {
|
|
220
|
+
const project = service.projects.getWithDetails(c.req.param("id"));
|
|
221
|
+
if (!project) return c.json({
|
|
222
|
+
ok: false,
|
|
223
|
+
error: "Project not found"
|
|
224
|
+
}, 404);
|
|
225
|
+
const loop = buildProjectLoopOverview({
|
|
226
|
+
project,
|
|
227
|
+
goals: service.projects.listGoalIds(project.id, parseLimit(c.req.query("goalLimit"), 100)).map((id) => goals.get(id)).filter((goal) => Boolean(goal)),
|
|
228
|
+
recentWorkflowRuns: project.recentWorkflowRuns,
|
|
229
|
+
failedWorkflowRuns: listFailedProjectWorkflowRuns(project.id),
|
|
230
|
+
memoryRecords: listMemoryRecords({
|
|
231
|
+
projectId: project.id,
|
|
232
|
+
status: "active",
|
|
233
|
+
limit: 5
|
|
234
|
+
})
|
|
235
|
+
});
|
|
236
|
+
return c.json({
|
|
237
|
+
ok: true,
|
|
238
|
+
overview: {
|
|
239
|
+
project,
|
|
240
|
+
stats: {
|
|
241
|
+
sessionCount: project.sessionCount,
|
|
242
|
+
goalCount: project.goalCount,
|
|
243
|
+
activeGoalCount: project.activeGoalCount,
|
|
244
|
+
recentWorkflowRunCount: project.recentWorkflowRuns.length,
|
|
245
|
+
staleGoalCount: loop.staleGoals.length,
|
|
246
|
+
attentionCount: loop.attentionItems.length,
|
|
247
|
+
failedWorkflowRunCount: loop.failedWorkflowRuns.length
|
|
248
|
+
},
|
|
249
|
+
activeGoals: loop.activeGoals,
|
|
250
|
+
blockedGoals: loop.blockedGoals,
|
|
251
|
+
staleGoals: loop.staleGoals,
|
|
252
|
+
nextActions: loop.nextActions,
|
|
253
|
+
attentionItems: loop.attentionItems,
|
|
254
|
+
timeline: loop.timeline,
|
|
255
|
+
digest: loop.digest,
|
|
256
|
+
failedWorkflowRuns: loop.failedWorkflowRuns,
|
|
257
|
+
recentSessions: project.recentSessions,
|
|
258
|
+
recentWorkflowRuns: project.recentWorkflowRuns,
|
|
259
|
+
recommendedAction: loop.recommendedAction
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
authenticated.post("/api/projects/:id/digest-memory", async (c) => {
|
|
264
|
+
const project = service.projects.getWithDetails(c.req.param("id"));
|
|
265
|
+
if (!project) return c.json({
|
|
266
|
+
ok: false,
|
|
267
|
+
error: "Project not found"
|
|
268
|
+
}, 404);
|
|
269
|
+
const loop = buildProjectLoopOverview({
|
|
270
|
+
project,
|
|
271
|
+
goals: service.projects.listGoalIds(project.id, 100).map((id) => goals.get(id)).filter((goal) => Boolean(goal)),
|
|
272
|
+
recentWorkflowRuns: project.recentWorkflowRuns,
|
|
273
|
+
failedWorkflowRuns: listFailedProjectWorkflowRuns(project.id),
|
|
274
|
+
memoryRecords: listMemoryRecords({
|
|
275
|
+
projectId: project.id,
|
|
276
|
+
status: "active",
|
|
277
|
+
limit: 5
|
|
278
|
+
})
|
|
279
|
+
});
|
|
280
|
+
const record = upsertMemoryRecord({
|
|
281
|
+
id: projectDigestMemoryRecordId(project.id),
|
|
282
|
+
providerId: "local",
|
|
283
|
+
kind: "daily_note",
|
|
284
|
+
agentId: resolveProjectAgentId({
|
|
285
|
+
config: service.currentConfig,
|
|
286
|
+
projects: service.projects,
|
|
287
|
+
projectId: project.id
|
|
288
|
+
}),
|
|
289
|
+
workspaceId: project.workspaceRoot,
|
|
290
|
+
projectId: project.id,
|
|
291
|
+
content: buildProjectDigestMemoryContent({
|
|
292
|
+
...loop,
|
|
293
|
+
projectName: project.name
|
|
294
|
+
}),
|
|
295
|
+
source: { provider: "project-digest" },
|
|
296
|
+
confidence: .75,
|
|
297
|
+
tags: [
|
|
298
|
+
"project",
|
|
299
|
+
"project-digest",
|
|
300
|
+
project.slug
|
|
301
|
+
],
|
|
302
|
+
status: "active",
|
|
303
|
+
sensitivity: "normal"
|
|
304
|
+
});
|
|
305
|
+
return c.json({
|
|
306
|
+
ok: true,
|
|
307
|
+
record
|
|
308
|
+
}, 201);
|
|
309
|
+
});
|
|
310
|
+
authenticated.post("/api/projects/:id/blockers", async (c) => {
|
|
311
|
+
const project = service.projects.getWithDetails(c.req.param("id"));
|
|
312
|
+
if (!project) return c.json({
|
|
313
|
+
ok: false,
|
|
314
|
+
error: "Project not found"
|
|
315
|
+
}, 404);
|
|
316
|
+
const body = await c.req.json().catch(() => ({}));
|
|
317
|
+
const title = typeof body.title === "string" ? body.title.trim() : "";
|
|
318
|
+
if (!title) return c.json({
|
|
319
|
+
ok: false,
|
|
320
|
+
error: "Missing title"
|
|
321
|
+
}, 400);
|
|
322
|
+
const reason = typeof body.reason === "string" ? body.reason.trim() : "";
|
|
323
|
+
const goal = goals.create({
|
|
324
|
+
title,
|
|
325
|
+
description: reason || void 0,
|
|
326
|
+
agentId: resolveProjectAgentId({
|
|
327
|
+
config: service.currentConfig,
|
|
328
|
+
projects: service.projects,
|
|
329
|
+
projectId: project.id
|
|
330
|
+
}),
|
|
331
|
+
priority: body.priority === "low" || body.priority === "normal" || body.priority === "high" ? body.priority : "high",
|
|
332
|
+
source: "api",
|
|
333
|
+
projectId: project.id
|
|
334
|
+
});
|
|
335
|
+
const blocked = goals.setStatus(goal.id, "blocked", { reason: reason || title });
|
|
336
|
+
if (reason) goals.setContextMessage({
|
|
337
|
+
goalId: goal.id,
|
|
338
|
+
text: reason
|
|
339
|
+
});
|
|
340
|
+
return c.json({
|
|
341
|
+
ok: true,
|
|
342
|
+
goal: blocked ?? goals.get(goal.id)
|
|
343
|
+
}, 201);
|
|
344
|
+
});
|
|
345
|
+
authenticated.get("/api/projects/:id", async (c) => {
|
|
346
|
+
const project = service.projects.getWithDetails(c.req.param("id"));
|
|
347
|
+
if (!project) return c.json({
|
|
348
|
+
ok: false,
|
|
349
|
+
error: "Project not found"
|
|
350
|
+
}, 404);
|
|
351
|
+
return c.json({
|
|
352
|
+
ok: true,
|
|
353
|
+
project
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
authenticated.patch("/api/projects/:id", async (c) => {
|
|
357
|
+
const body = await c.req.json().catch(() => ({}));
|
|
358
|
+
const status = parseProjectStatus(body.status);
|
|
359
|
+
const defaultAgentPatch = optionalTextField(body, "defaultAgentId");
|
|
360
|
+
const defaultAgentId = defaultAgentPatch === void 0 ? void 0 : normalizeProjectAgentId(defaultAgentPatch);
|
|
361
|
+
if (defaultAgentId && !isValidProjectAgentId(service.currentConfig, defaultAgentId)) return c.json({
|
|
362
|
+
ok: false,
|
|
363
|
+
error: "Default agent not found"
|
|
364
|
+
}, 400);
|
|
365
|
+
try {
|
|
366
|
+
const project = service.projects.update(c.req.param("id"), {
|
|
367
|
+
...textField(body, "name") !== void 0 ? { name: textField(body, "name") } : {},
|
|
368
|
+
...optionalTextField(body, "description") !== void 0 ? { description: optionalTextField(body, "description") } : {},
|
|
369
|
+
...status ? { status } : {},
|
|
370
|
+
...defaultAgentPatch !== void 0 ? { defaultAgentId: defaultAgentId ?? null } : {},
|
|
371
|
+
...optionalTextField(body, "workspaceRoot") !== void 0 ? { workspaceRoot: optionalTextField(body, "workspaceRoot") } : {},
|
|
372
|
+
createWorkspaceRoot: body.createWorkspaceRoot === true,
|
|
373
|
+
...optionalTextField(body, "brief") !== void 0 ? { brief: optionalTextField(body, "brief") } : {},
|
|
374
|
+
...optionalTextField(body, "instructions") !== void 0 ? { instructions: optionalTextField(body, "instructions") } : {}
|
|
375
|
+
});
|
|
376
|
+
return c.json({
|
|
377
|
+
ok: true,
|
|
378
|
+
project
|
|
379
|
+
});
|
|
380
|
+
} catch (error) {
|
|
381
|
+
if (error instanceof ProjectWorkspaceConflictError) return c.json({
|
|
382
|
+
ok: false,
|
|
383
|
+
code: "workspace_already_bound",
|
|
384
|
+
error: error.message,
|
|
385
|
+
project: error.project
|
|
386
|
+
}, 409);
|
|
387
|
+
if (error instanceof ProjectWorkspaceMissingError) return c.json({
|
|
388
|
+
ok: false,
|
|
389
|
+
code: "workspace_root_missing",
|
|
390
|
+
error: error.message,
|
|
391
|
+
workspaceRoot: error.workspaceRoot
|
|
392
|
+
}, 409);
|
|
393
|
+
return c.json({
|
|
394
|
+
ok: false,
|
|
395
|
+
error: error instanceof Error ? error.message : String(error)
|
|
396
|
+
}, 404);
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
authenticated.delete("/api/projects/:id", async (c) => {
|
|
400
|
+
service.projects.delete(c.req.param("id"));
|
|
401
|
+
return c.json({ ok: true });
|
|
402
|
+
});
|
|
403
|
+
authenticated.get("/api/projects/:id/sessions", async (c) => {
|
|
404
|
+
try {
|
|
405
|
+
const keys = service.projects.listSessionKeys(c.req.param("id"), parseLimit(c.req.query("limit"), 100));
|
|
406
|
+
const sessions = await Promise.all(keys.map((key) => service.sessions.getSession(key)));
|
|
407
|
+
return c.json({
|
|
408
|
+
ok: true,
|
|
409
|
+
sessions: sessions.filter(Boolean)
|
|
410
|
+
});
|
|
411
|
+
} catch (error) {
|
|
412
|
+
return c.json({
|
|
413
|
+
ok: false,
|
|
414
|
+
error: error instanceof Error ? error.message : String(error)
|
|
415
|
+
}, 404);
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
authenticated.get("/api/projects/:id/goals", async (c) => {
|
|
419
|
+
try {
|
|
420
|
+
const ids = service.projects.listGoalIds(c.req.param("id"), parseLimit(c.req.query("limit"), 100));
|
|
421
|
+
return c.json({
|
|
422
|
+
ok: true,
|
|
423
|
+
goals: ids.map((id) => goals.get(id)).filter(Boolean)
|
|
424
|
+
});
|
|
425
|
+
} catch (error) {
|
|
426
|
+
return c.json({
|
|
427
|
+
ok: false,
|
|
428
|
+
error: error instanceof Error ? error.message : String(error)
|
|
429
|
+
}, 404);
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
authenticated.get("/api/projects/:id/files", async (c) => {
|
|
433
|
+
const project = service.projects.get(c.req.param("id"));
|
|
434
|
+
if (!project) return c.json({
|
|
435
|
+
ok: false,
|
|
436
|
+
error: "Project not found"
|
|
437
|
+
}, 404);
|
|
438
|
+
if (!project.workspaceRoot?.trim()) return c.json({
|
|
439
|
+
ok: false,
|
|
440
|
+
error: "Project workspace root is not set"
|
|
441
|
+
}, 400);
|
|
442
|
+
let root;
|
|
443
|
+
try {
|
|
444
|
+
root = await realpath(project.workspaceRoot);
|
|
445
|
+
if (!(await stat(root)).isDirectory()) return c.json({
|
|
446
|
+
ok: false,
|
|
447
|
+
error: "Project workspace root is not a directory"
|
|
448
|
+
}, 400);
|
|
449
|
+
} catch (err) {
|
|
450
|
+
log.warn({
|
|
451
|
+
err,
|
|
452
|
+
projectId: project.id,
|
|
453
|
+
path: project.workspaceRoot
|
|
454
|
+
}, "project workspace root unavailable");
|
|
455
|
+
return c.json({
|
|
456
|
+
ok: false,
|
|
457
|
+
error: "Project workspace root is unavailable"
|
|
458
|
+
}, 404);
|
|
459
|
+
}
|
|
460
|
+
const requestedPath = normalizeRelativePath(c.req.query("path"));
|
|
461
|
+
const candidate = path$1.resolve(root, requestedPath);
|
|
462
|
+
if (!isWithinDirectory(root, candidate)) return c.json({
|
|
463
|
+
ok: false,
|
|
464
|
+
error: "Path is outside project workspace"
|
|
465
|
+
}, 400);
|
|
466
|
+
let currentPath;
|
|
467
|
+
try {
|
|
468
|
+
currentPath = await realpath(candidate);
|
|
469
|
+
if (!isWithinDirectory(root, currentPath)) return c.json({
|
|
470
|
+
ok: false,
|
|
471
|
+
error: "Path is outside project workspace"
|
|
472
|
+
}, 400);
|
|
473
|
+
if (!(await stat(currentPath)).isDirectory()) return c.json({
|
|
474
|
+
ok: false,
|
|
475
|
+
error: "Path is not a directory"
|
|
476
|
+
}, 400);
|
|
477
|
+
} catch (err) {
|
|
478
|
+
log.warn({
|
|
479
|
+
err,
|
|
480
|
+
projectId: project.id,
|
|
481
|
+
path: candidate
|
|
482
|
+
}, "project file path unavailable");
|
|
483
|
+
return c.json({
|
|
484
|
+
ok: false,
|
|
485
|
+
error: "Path not found"
|
|
486
|
+
}, 404);
|
|
487
|
+
}
|
|
488
|
+
try {
|
|
489
|
+
const dirents = await readdir(currentPath, { withFileTypes: true });
|
|
490
|
+
const entries = await Promise.all(dirents.filter((entry) => !SKIP_FILE_NAMES.has(entry.name)).map(async (entry) => {
|
|
491
|
+
const absolutePath = path$1.join(currentPath, entry.name);
|
|
492
|
+
const entryStat = await stat(absolutePath).catch(() => null);
|
|
493
|
+
const relativePath = path$1.relative(root, absolutePath).split(path$1.sep).join("/");
|
|
494
|
+
return {
|
|
495
|
+
name: entry.name,
|
|
496
|
+
path: relativePath,
|
|
497
|
+
type: entry.isDirectory() ? "directory" : "file",
|
|
498
|
+
size: entryStat?.isFile() ? entryStat.size : void 0,
|
|
499
|
+
updatedAt: entryStat?.mtime.toISOString()
|
|
500
|
+
};
|
|
501
|
+
}));
|
|
502
|
+
entries.sort((left, right) => {
|
|
503
|
+
if (left.type !== right.type) return left.type === "directory" ? -1 : 1;
|
|
504
|
+
return left.name.localeCompare(right.name);
|
|
505
|
+
});
|
|
506
|
+
const relativeCurrentPath = path$1.relative(root, currentPath).split(path$1.sep).join("/");
|
|
507
|
+
const parentRelativePath = relativeCurrentPath ? path$1.dirname(relativeCurrentPath).replaceAll("\\", "/") : null;
|
|
508
|
+
return c.json({
|
|
509
|
+
ok: true,
|
|
510
|
+
root,
|
|
511
|
+
path: relativeCurrentPath === "." ? "" : relativeCurrentPath,
|
|
512
|
+
parentPath: parentRelativePath === "." ? "" : parentRelativePath,
|
|
513
|
+
entries
|
|
514
|
+
});
|
|
515
|
+
} catch (err) {
|
|
516
|
+
log.warn({
|
|
517
|
+
err,
|
|
518
|
+
projectId: project.id,
|
|
519
|
+
path: currentPath
|
|
520
|
+
}, "project file list failed");
|
|
521
|
+
if (err?.code === "EACCES") return c.json({
|
|
522
|
+
ok: false,
|
|
523
|
+
error: "Permission denied"
|
|
524
|
+
}, 403);
|
|
525
|
+
return c.json({
|
|
526
|
+
ok: false,
|
|
527
|
+
error: "Failed to read project files"
|
|
528
|
+
}, 500);
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
authenticated.post("/api/projects/:id/sessions/:sessionKey", async (c) => {
|
|
532
|
+
try {
|
|
533
|
+
service.projects.attachSession(c.req.param("sessionKey"), c.req.param("id"));
|
|
534
|
+
const session = await service.sessions.getSession(c.req.param("sessionKey"));
|
|
535
|
+
return c.json({
|
|
536
|
+
ok: true,
|
|
537
|
+
session
|
|
538
|
+
});
|
|
539
|
+
} catch (error) {
|
|
540
|
+
return c.json({
|
|
541
|
+
ok: false,
|
|
542
|
+
error: error instanceof Error ? error.message : String(error)
|
|
543
|
+
}, 404);
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
authenticated.delete("/api/projects/:id/sessions/:sessionKey", async (c) => {
|
|
547
|
+
try {
|
|
548
|
+
const projectId = c.req.param("id");
|
|
549
|
+
const sessionKey = c.req.param("sessionKey");
|
|
550
|
+
if (!service.projects.get(projectId)) return c.json({
|
|
551
|
+
ok: false,
|
|
552
|
+
error: "Project not found"
|
|
553
|
+
}, 404);
|
|
554
|
+
const session = await service.sessions.getSession(sessionKey);
|
|
555
|
+
if (!session) return c.json({
|
|
556
|
+
ok: false,
|
|
557
|
+
error: "Session not found"
|
|
558
|
+
}, 404);
|
|
559
|
+
if (session.projectId !== projectId) return c.json({
|
|
560
|
+
ok: false,
|
|
561
|
+
error: "Session is not attached to this project"
|
|
562
|
+
}, 409);
|
|
563
|
+
service.projects.detachSession(sessionKey);
|
|
564
|
+
return c.json({ ok: true });
|
|
565
|
+
} catch (error) {
|
|
566
|
+
return c.json({
|
|
567
|
+
ok: false,
|
|
568
|
+
error: error instanceof Error ? error.message : String(error)
|
|
569
|
+
}, 404);
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
authenticated.post("/api/projects/:id/sessions/:sessionKey/summary-memory", async (c) => {
|
|
573
|
+
const projectId = c.req.param("id");
|
|
574
|
+
const sessionKey = c.req.param("sessionKey");
|
|
575
|
+
const project = service.projects.get(projectId);
|
|
576
|
+
if (!project) return c.json({
|
|
577
|
+
ok: false,
|
|
578
|
+
error: "Project not found"
|
|
579
|
+
}, 404);
|
|
580
|
+
const session = getSessionMetadata(sessionKey);
|
|
581
|
+
if (!session) return c.json({
|
|
582
|
+
ok: false,
|
|
583
|
+
error: "Session not found"
|
|
584
|
+
}, 404);
|
|
585
|
+
if (session.projectId !== projectId) return c.json({
|
|
586
|
+
ok: false,
|
|
587
|
+
error: "Session is not attached to this project"
|
|
588
|
+
}, 409);
|
|
589
|
+
const body = await c.req.json().catch(() => ({}));
|
|
590
|
+
const content = buildSessionSummaryMemoryContent(sessionKey, typeof body.summary === "string" ? body.summary : void 0);
|
|
591
|
+
const record = upsertMemoryRecord({
|
|
592
|
+
providerId: "local",
|
|
593
|
+
kind: "session_summary",
|
|
594
|
+
agentId: session.routing?.agentId ?? "main",
|
|
595
|
+
workspaceId: session.cwd,
|
|
596
|
+
sessionKey,
|
|
597
|
+
projectId,
|
|
598
|
+
content,
|
|
599
|
+
source: {
|
|
600
|
+
provider: "project-summary",
|
|
601
|
+
sessionEntryId: sessionKey
|
|
602
|
+
},
|
|
603
|
+
confidence: typeof body.confidence === "number" ? body.confidence : .7,
|
|
604
|
+
tags: [
|
|
605
|
+
"project",
|
|
606
|
+
"session-summary",
|
|
607
|
+
project.slug
|
|
608
|
+
],
|
|
609
|
+
status: "active",
|
|
610
|
+
sensitivity: "normal",
|
|
611
|
+
evidence: [{ sessionKey }]
|
|
612
|
+
});
|
|
613
|
+
return c.json({
|
|
614
|
+
ok: true,
|
|
615
|
+
record
|
|
616
|
+
}, 201);
|
|
617
|
+
});
|
|
618
|
+
authenticated.post("/api/projects/:id/goals/:goalId", async (c) => {
|
|
619
|
+
try {
|
|
620
|
+
service.projects.attachGoal(c.req.param("goalId"), c.req.param("id"));
|
|
621
|
+
return c.json({
|
|
622
|
+
ok: true,
|
|
623
|
+
goal: goals.get(c.req.param("goalId"))
|
|
624
|
+
});
|
|
625
|
+
} catch (error) {
|
|
626
|
+
return c.json({
|
|
627
|
+
ok: false,
|
|
628
|
+
error: error instanceof Error ? error.message : String(error)
|
|
629
|
+
}, 404);
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
authenticated.delete("/api/projects/:id/goals/:goalId", async (c) => {
|
|
633
|
+
try {
|
|
634
|
+
const projectId = c.req.param("id");
|
|
635
|
+
const goalId = c.req.param("goalId");
|
|
636
|
+
if (!service.projects.get(projectId)) return c.json({
|
|
637
|
+
ok: false,
|
|
638
|
+
error: "Project not found"
|
|
639
|
+
}, 404);
|
|
640
|
+
const goal = goals.get(goalId);
|
|
641
|
+
if (!goal) return c.json({
|
|
642
|
+
ok: false,
|
|
643
|
+
error: "Goal not found"
|
|
644
|
+
}, 404);
|
|
645
|
+
if (goal.projectId !== projectId) return c.json({
|
|
646
|
+
ok: false,
|
|
647
|
+
error: "Goal is not attached to this project"
|
|
648
|
+
}, 409);
|
|
649
|
+
service.projects.detachGoal(goalId);
|
|
650
|
+
return c.json({ ok: true });
|
|
651
|
+
} catch (error) {
|
|
652
|
+
return c.json({
|
|
653
|
+
ok: false,
|
|
654
|
+
error: error instanceof Error ? error.message : String(error)
|
|
655
|
+
}, 404);
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
//#endregion
|
|
660
|
+
export { registerProjectsRoutes };
|
|
661
|
+
|
|
662
|
+
//# sourceMappingURL=projects.js.map
|