@xopcai/xopc 0.0.121 → 0.0.122
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-CK3s5cJo.js} +1 -1
- package/dist/gateway/static/root/assets/agents-SsQrj9B-.js +2 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CE6GkGU2.js → app-management-settings-panel-CWsNHtTs.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BmaUjghw.js → appearance-settings-C4b8y6iZ.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-CYb6fame.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CX4_KWut.js → archive-plugin-DAtNW3Ia.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-jf-PIIUU.js → attachment-load-Dm-RY54y.js} +1 -1
- package/dist/gateway/static/root/assets/automation-suggestion-card-BKHewSVT.js +1 -0
- package/dist/gateway/static/root/assets/automations-page-DpOOq1nk.js +1 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DG9XQikd.js → binary-plugins-BG6Xnk71.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Up_VIxLJ.js → block-editor-DfndiO3h.js} +28 -28
- package/dist/gateway/static/root/assets/browser-settings-page-9nXxgh4u.js +8 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-CGM4OyMw.js → capability-presets-api-Cx93GLdw.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-CzWt0LBb.js → capability-presets-settings-panel-D528_YFy.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-BEByL4_o.js → channel-recipient-api-DdPTtEs8.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-Ck-3h5lI.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-DL-fAqE_.js +2 -0
- package/dist/gateway/static/root/assets/directory-picker-path-field-D835EHJd.js +1 -0
- package/dist/gateway/static/root/assets/dreaming-settings-CCa1F7Fg.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DZxa_j7-.js → extension-debug-page-W2ITCPSA.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CseziW53.js → extension-page-DrvUytvn.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-B_9J-xyo.js → extension-settings-page-qM8aLT5u.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-Cs4ck8zA.js → fetch-ovkvM8KQ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-Dl223a7r.js → gateway-config-api-BB3biuD0.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-mmmnIH27.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-IvePwjFE.js → gateway-startup-retry-CanQ8UcR.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-CNqNdEkQ.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-Ceu5zrN6.js +1 -0
- package/dist/gateway/static/root/assets/{goals-config-api-CUCP6yCl.js → goals-config-api-BBOX6mUl.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BP1kfvWv.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-Dj87qPxv.js → goals-settings-Bh3A7OZV.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-YoYgKlfX.js +1 -0
- package/dist/gateway/static/root/assets/index-DdqSO9R2.js +191 -0
- package/dist/gateway/static/root/assets/index-jGB-2nI-.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DJgYw0nB.js → keyboard-shortcuts-settings-B4TKJHla.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-BgVk5DvZ.js +2 -0
- package/dist/gateway/static/root/assets/{markdown-split-gnQ_EiGo.js → markdown-split-DcFtdLci.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CQV-mgJn.js → media-plugins-B6SmeLVB.js} +1 -1
- package/dist/gateway/static/root/assets/messages-B5O4OIEo.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-BU0x8PGP.js +2 -0
- package/dist/gateway/static/root/assets/notes-page-D6JYVP4I.js +1 -0
- package/dist/gateway/static/root/assets/notes-workbench-mqRJYnJS.js +2 -0
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BPMXC-2u.js → preview-open-alternatives-C29O19s7.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DOTgzoeh.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DGUIb4y5.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-DVKKUj3u.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BEHqwZjz.js → save-bar-controls-B4ad9GfB.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-CMY25m97.js → schedule-field-DdYncfLR.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CxjxsFfg.js → schema-form-BMTrDE-7.js} +1 -1
- package/dist/gateway/static/root/assets/segmented-styles-BL8oLBEp.js +1 -0
- package/dist/gateway/static/root/assets/sessions-page-BVbzUWxW.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DrNNoSqE.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-s-kiLAxP.js → settings-collapsible-section-MwTW2eK4.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-CIxIEYxU.js → settings-form-section-Dg6LBbcr.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-CMDqgeMR.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-layout-BX4T-OLF.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-Ce1pcFtR.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-DWE-dUFh.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-aKSraR8l.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-CS-FU_B-.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-BaF3u0LA.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-Czjf0kLJ.js → system-settings-panel-Dd6Y35Cm.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-Cmt8SYdI.js → typed-models-lib-Cx6XV5A2.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-DyM-ckEQ.js → use-channel-catalog-D4sMbmy7.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-BygLv8vm.js → user-profile-settings-panel-Bx-hjMQc.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-CloW8coB.js → utils-D7b_vZnv.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-CkhbRt1q.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel--TdohF5N.js +3 -0
- package/dist/gateway/static/root/assets/workflow-start-dialog-B0lavx_o.js +1 -0
- package/dist/gateway/static/root/assets/workflows-page-CZR05Bu_.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/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/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/agent-profile.js +1 -1
- package/dist/src/config/index.js +1 -1
- package/dist/src/gateway/agents-admin.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 +578 -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/mcp/channel-bridge.js +1 -1
- 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 +11 -0
- package/dist/src/projects/index.js +11 -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 +26 -0
- package/dist/src/projects/project-service.js +94 -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 +60 -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.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.js +1 -1
- package/dist/src/tui/tui-commands.js +145 -0
- package/dist/src/tui/tui-commands.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,578 @@
|
|
|
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 { isValidProjectAgentId, normalizeProjectAgentId, resolveProjectAgentId } from "../../../projects/project-agent.js";
|
|
9
|
+
import { buildProjectLoopOverview } from "../../../projects/project-loop.js";
|
|
10
|
+
import "../../../projects/index.js";
|
|
11
|
+
import { createGatewayRouteLogger } from "../lib/route-logger.js";
|
|
12
|
+
import * as path$1 from "node:path";
|
|
13
|
+
import { readdir, realpath, stat } from "node:fs/promises";
|
|
14
|
+
//#region src/gateway/hono/routes/projects.ts
|
|
15
|
+
const log = createGatewayRouteLogger("Projects");
|
|
16
|
+
function parseProjectStatus(raw) {
|
|
17
|
+
return raw === "active" || raw === "paused" || raw === "archived" ? raw : void 0;
|
|
18
|
+
}
|
|
19
|
+
function parseLimit(raw, fallback = 50) {
|
|
20
|
+
if (!raw) return void 0;
|
|
21
|
+
const n = Number.parseInt(raw, 10);
|
|
22
|
+
return Number.isFinite(n) ? Math.min(500, Math.max(1, n)) : fallback;
|
|
23
|
+
}
|
|
24
|
+
function textField(body, key) {
|
|
25
|
+
const value = body[key];
|
|
26
|
+
return typeof value === "string" ? value : void 0;
|
|
27
|
+
}
|
|
28
|
+
function optionalTextField(body, key) {
|
|
29
|
+
if (!(key in body)) return void 0;
|
|
30
|
+
const value = body[key];
|
|
31
|
+
return typeof value === "string" ? value : null;
|
|
32
|
+
}
|
|
33
|
+
const SKIP_FILE_NAMES = new Set([".git", "node_modules"]);
|
|
34
|
+
function normalizeRelativePath(raw) {
|
|
35
|
+
return (raw ?? "").trim().replaceAll("\\", "/").replace(/^\/+/, "");
|
|
36
|
+
}
|
|
37
|
+
function isWithinDirectory(root, target) {
|
|
38
|
+
const relativePath = path$1.relative(root, target);
|
|
39
|
+
return relativePath === "" || !relativePath.startsWith("..") && !path$1.isAbsolute(relativePath);
|
|
40
|
+
}
|
|
41
|
+
function textFromTranscriptContent(content) {
|
|
42
|
+
if (typeof content === "string") return content;
|
|
43
|
+
if (!Array.isArray(content)) return "";
|
|
44
|
+
return content.map((part) => {
|
|
45
|
+
if (!part || typeof part !== "object") return "";
|
|
46
|
+
const record = part;
|
|
47
|
+
return typeof record.text === "string" ? record.text : "";
|
|
48
|
+
}).filter(Boolean).join("\n");
|
|
49
|
+
}
|
|
50
|
+
function buildSessionSummaryMemoryContent(sessionKey, explicitSummary) {
|
|
51
|
+
const summary = explicitSummary?.trim();
|
|
52
|
+
if (summary) return summary;
|
|
53
|
+
const lines = loadTranscriptRowsForSession(sessionKey).filter((row) => {
|
|
54
|
+
if (!row || typeof row !== "object") return false;
|
|
55
|
+
const role = row.role;
|
|
56
|
+
return role === "user" || role === "assistant" || role === "compactionSummary" || role === "branchSummary";
|
|
57
|
+
}).slice(-12).map((row) => {
|
|
58
|
+
const record = row;
|
|
59
|
+
const rowRole = typeof record.role === "string" ? record.role : "message";
|
|
60
|
+
const role = rowRole === "compactionSummary" || rowRole === "branchSummary" ? "summary" : rowRole;
|
|
61
|
+
const compact = ((typeof record.summary === "string" ? record.summary : void 0) ?? textFromTranscriptContent(record.content)).trim().replace(/\s+/g, " ").slice(0, 280);
|
|
62
|
+
return compact ? `- ${role}: ${compact}` : "";
|
|
63
|
+
}).filter(Boolean);
|
|
64
|
+
return lines.length > 0 ? [`Session summary for ${sessionKey}:`, ...lines].join("\n") : `Session summary for ${sessionKey}: no transcript content available.`;
|
|
65
|
+
}
|
|
66
|
+
function listFailedProjectWorkflowRuns(projectId, limit = 5) {
|
|
67
|
+
return getSqliteDatabase().prepare(`SELECT run_id, definition_id, status, created_at_ms, error_message
|
|
68
|
+
FROM workflow_runs
|
|
69
|
+
WHERE project_id = ? AND status IN ('failed', 'timeout', 'cancelled')
|
|
70
|
+
ORDER BY created_at_ms DESC
|
|
71
|
+
LIMIT ?`).all(projectId, Math.max(1, Math.min(20, Math.floor(limit)))).map((row) => ({
|
|
72
|
+
runId: row.run_id,
|
|
73
|
+
definitionId: row.definition_id,
|
|
74
|
+
status: row.status,
|
|
75
|
+
createdAt: row.created_at_ms,
|
|
76
|
+
errorMessage: row.error_message ?? void 0
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
function buildProjectDigestMemoryContent(input) {
|
|
80
|
+
const lines = [
|
|
81
|
+
`Project digest: ${input.projectName}`,
|
|
82
|
+
`Status: ${input.digest.summary}`,
|
|
83
|
+
input.digest.nextAction ? `Next: ${input.digest.nextAction}` : void 0
|
|
84
|
+
].filter(Boolean);
|
|
85
|
+
if (input.attentionItems.length > 0) {
|
|
86
|
+
lines.push("", "Attention:");
|
|
87
|
+
for (const item of input.attentionItems.slice(0, 8)) lines.push(`- ${item.kind}: ${item.title}${item.detail ? ` - ${item.detail}` : ""}`);
|
|
88
|
+
}
|
|
89
|
+
if (input.timeline.length > 0) {
|
|
90
|
+
lines.push("", "Recent activity:");
|
|
91
|
+
for (const item of input.timeline.slice(0, 8)) lines.push(`- ${item.kind}: ${item.title}${item.detail ? ` - ${item.detail}` : ""}`);
|
|
92
|
+
}
|
|
93
|
+
return lines.join("\n");
|
|
94
|
+
}
|
|
95
|
+
function projectDigestMemoryRecordId(projectId) {
|
|
96
|
+
return `project-digest:${projectId}`;
|
|
97
|
+
}
|
|
98
|
+
function registerProjectsRoutes(authenticated, deps) {
|
|
99
|
+
const { service } = deps;
|
|
100
|
+
const goals = new GoalService();
|
|
101
|
+
authenticated.post("/api/projects", async (c) => {
|
|
102
|
+
const body = await c.req.json().catch(() => ({}));
|
|
103
|
+
const name = textField(body, "name")?.trim();
|
|
104
|
+
if (!name) return c.json({
|
|
105
|
+
ok: false,
|
|
106
|
+
error: "Missing name"
|
|
107
|
+
}, 400);
|
|
108
|
+
const defaultAgentId = normalizeProjectAgentId(textField(body, "defaultAgentId"));
|
|
109
|
+
if (!isValidProjectAgentId(service.currentConfig, defaultAgentId)) return c.json({
|
|
110
|
+
ok: false,
|
|
111
|
+
error: "Default agent not found"
|
|
112
|
+
}, 400);
|
|
113
|
+
const project = service.projects.create({
|
|
114
|
+
name,
|
|
115
|
+
description: textField(body, "description"),
|
|
116
|
+
defaultAgentId,
|
|
117
|
+
workspaceRoot: textField(body, "workspaceRoot"),
|
|
118
|
+
brief: textField(body, "brief"),
|
|
119
|
+
instructions: textField(body, "instructions")
|
|
120
|
+
});
|
|
121
|
+
return c.json({
|
|
122
|
+
ok: true,
|
|
123
|
+
project
|
|
124
|
+
}, 201);
|
|
125
|
+
});
|
|
126
|
+
authenticated.get("/api/projects", async (c) => {
|
|
127
|
+
const status = parseProjectStatus(c.req.query("status"));
|
|
128
|
+
const result = service.projects.list({
|
|
129
|
+
...status ? { status } : {},
|
|
130
|
+
search: c.req.query("search"),
|
|
131
|
+
sortBy: c.req.query("sortBy"),
|
|
132
|
+
sortOrder: c.req.query("sortOrder"),
|
|
133
|
+
limit: parseLimit(c.req.query("limit")),
|
|
134
|
+
offset: c.req.query("offset") ? Math.max(0, Number.parseInt(c.req.query("offset"), 10) || 0) : void 0
|
|
135
|
+
});
|
|
136
|
+
return c.json({
|
|
137
|
+
ok: true,
|
|
138
|
+
...result
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
authenticated.get("/api/projects/suggestions", async (c) => {
|
|
142
|
+
const sessionKey = c.req.query("sessionKey")?.trim();
|
|
143
|
+
return c.json({
|
|
144
|
+
ok: true,
|
|
145
|
+
suggestions: sessionKey ? service.projects.suggestProjectsForSession(sessionKey) : []
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
authenticated.get("/api/projects/:id/overview", async (c) => {
|
|
149
|
+
const project = service.projects.getWithDetails(c.req.param("id"));
|
|
150
|
+
if (!project) return c.json({
|
|
151
|
+
ok: false,
|
|
152
|
+
error: "Project not found"
|
|
153
|
+
}, 404);
|
|
154
|
+
const loop = buildProjectLoopOverview({
|
|
155
|
+
project,
|
|
156
|
+
goals: service.projects.listGoalIds(project.id, parseLimit(c.req.query("goalLimit"), 100)).map((id) => goals.get(id)).filter((goal) => Boolean(goal)),
|
|
157
|
+
recentWorkflowRuns: project.recentWorkflowRuns,
|
|
158
|
+
failedWorkflowRuns: listFailedProjectWorkflowRuns(project.id),
|
|
159
|
+
memoryRecords: listMemoryRecords({
|
|
160
|
+
projectId: project.id,
|
|
161
|
+
status: "active",
|
|
162
|
+
limit: 5
|
|
163
|
+
})
|
|
164
|
+
});
|
|
165
|
+
return c.json({
|
|
166
|
+
ok: true,
|
|
167
|
+
overview: {
|
|
168
|
+
project,
|
|
169
|
+
stats: {
|
|
170
|
+
sessionCount: project.sessionCount,
|
|
171
|
+
goalCount: project.goalCount,
|
|
172
|
+
activeGoalCount: project.activeGoalCount,
|
|
173
|
+
recentWorkflowRunCount: project.recentWorkflowRuns.length,
|
|
174
|
+
staleGoalCount: loop.staleGoals.length,
|
|
175
|
+
attentionCount: loop.attentionItems.length,
|
|
176
|
+
failedWorkflowRunCount: loop.failedWorkflowRuns.length
|
|
177
|
+
},
|
|
178
|
+
activeGoals: loop.activeGoals,
|
|
179
|
+
blockedGoals: loop.blockedGoals,
|
|
180
|
+
staleGoals: loop.staleGoals,
|
|
181
|
+
nextActions: loop.nextActions,
|
|
182
|
+
attentionItems: loop.attentionItems,
|
|
183
|
+
timeline: loop.timeline,
|
|
184
|
+
digest: loop.digest,
|
|
185
|
+
failedWorkflowRuns: loop.failedWorkflowRuns,
|
|
186
|
+
recentSessions: project.recentSessions,
|
|
187
|
+
recentWorkflowRuns: project.recentWorkflowRuns,
|
|
188
|
+
recommendedAction: loop.recommendedAction
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
authenticated.post("/api/projects/:id/digest-memory", async (c) => {
|
|
193
|
+
const project = service.projects.getWithDetails(c.req.param("id"));
|
|
194
|
+
if (!project) return c.json({
|
|
195
|
+
ok: false,
|
|
196
|
+
error: "Project not found"
|
|
197
|
+
}, 404);
|
|
198
|
+
const loop = buildProjectLoopOverview({
|
|
199
|
+
project,
|
|
200
|
+
goals: service.projects.listGoalIds(project.id, 100).map((id) => goals.get(id)).filter((goal) => Boolean(goal)),
|
|
201
|
+
recentWorkflowRuns: project.recentWorkflowRuns,
|
|
202
|
+
failedWorkflowRuns: listFailedProjectWorkflowRuns(project.id),
|
|
203
|
+
memoryRecords: listMemoryRecords({
|
|
204
|
+
projectId: project.id,
|
|
205
|
+
status: "active",
|
|
206
|
+
limit: 5
|
|
207
|
+
})
|
|
208
|
+
});
|
|
209
|
+
const record = upsertMemoryRecord({
|
|
210
|
+
id: projectDigestMemoryRecordId(project.id),
|
|
211
|
+
providerId: "local",
|
|
212
|
+
kind: "daily_note",
|
|
213
|
+
agentId: resolveProjectAgentId({
|
|
214
|
+
config: service.currentConfig,
|
|
215
|
+
projects: service.projects,
|
|
216
|
+
projectId: project.id
|
|
217
|
+
}),
|
|
218
|
+
workspaceId: project.workspaceRoot,
|
|
219
|
+
projectId: project.id,
|
|
220
|
+
content: buildProjectDigestMemoryContent({
|
|
221
|
+
...loop,
|
|
222
|
+
projectName: project.name
|
|
223
|
+
}),
|
|
224
|
+
source: { provider: "project-digest" },
|
|
225
|
+
confidence: .75,
|
|
226
|
+
tags: [
|
|
227
|
+
"project",
|
|
228
|
+
"project-digest",
|
|
229
|
+
project.slug
|
|
230
|
+
],
|
|
231
|
+
status: "active",
|
|
232
|
+
sensitivity: "normal"
|
|
233
|
+
});
|
|
234
|
+
return c.json({
|
|
235
|
+
ok: true,
|
|
236
|
+
record
|
|
237
|
+
}, 201);
|
|
238
|
+
});
|
|
239
|
+
authenticated.post("/api/projects/:id/blockers", async (c) => {
|
|
240
|
+
const project = service.projects.getWithDetails(c.req.param("id"));
|
|
241
|
+
if (!project) return c.json({
|
|
242
|
+
ok: false,
|
|
243
|
+
error: "Project not found"
|
|
244
|
+
}, 404);
|
|
245
|
+
const body = await c.req.json().catch(() => ({}));
|
|
246
|
+
const title = typeof body.title === "string" ? body.title.trim() : "";
|
|
247
|
+
if (!title) return c.json({
|
|
248
|
+
ok: false,
|
|
249
|
+
error: "Missing title"
|
|
250
|
+
}, 400);
|
|
251
|
+
const reason = typeof body.reason === "string" ? body.reason.trim() : "";
|
|
252
|
+
const goal = goals.create({
|
|
253
|
+
title,
|
|
254
|
+
description: reason || void 0,
|
|
255
|
+
agentId: resolveProjectAgentId({
|
|
256
|
+
config: service.currentConfig,
|
|
257
|
+
projects: service.projects,
|
|
258
|
+
projectId: project.id
|
|
259
|
+
}),
|
|
260
|
+
priority: body.priority === "low" || body.priority === "normal" || body.priority === "high" ? body.priority : "high",
|
|
261
|
+
source: "api",
|
|
262
|
+
projectId: project.id
|
|
263
|
+
});
|
|
264
|
+
const blocked = goals.setStatus(goal.id, "blocked", { reason: reason || title });
|
|
265
|
+
if (reason) goals.setContextMessage({
|
|
266
|
+
goalId: goal.id,
|
|
267
|
+
text: reason
|
|
268
|
+
});
|
|
269
|
+
return c.json({
|
|
270
|
+
ok: true,
|
|
271
|
+
goal: blocked ?? goals.get(goal.id)
|
|
272
|
+
}, 201);
|
|
273
|
+
});
|
|
274
|
+
authenticated.get("/api/projects/:id", async (c) => {
|
|
275
|
+
const project = service.projects.getWithDetails(c.req.param("id"));
|
|
276
|
+
if (!project) return c.json({
|
|
277
|
+
ok: false,
|
|
278
|
+
error: "Project not found"
|
|
279
|
+
}, 404);
|
|
280
|
+
return c.json({
|
|
281
|
+
ok: true,
|
|
282
|
+
project
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
authenticated.patch("/api/projects/:id", async (c) => {
|
|
286
|
+
const body = await c.req.json().catch(() => ({}));
|
|
287
|
+
const status = parseProjectStatus(body.status);
|
|
288
|
+
const defaultAgentPatch = optionalTextField(body, "defaultAgentId");
|
|
289
|
+
const defaultAgentId = defaultAgentPatch === void 0 ? void 0 : normalizeProjectAgentId(defaultAgentPatch);
|
|
290
|
+
if (defaultAgentId && !isValidProjectAgentId(service.currentConfig, defaultAgentId)) return c.json({
|
|
291
|
+
ok: false,
|
|
292
|
+
error: "Default agent not found"
|
|
293
|
+
}, 400);
|
|
294
|
+
try {
|
|
295
|
+
const project = service.projects.update(c.req.param("id"), {
|
|
296
|
+
...textField(body, "name") !== void 0 ? { name: textField(body, "name") } : {},
|
|
297
|
+
...optionalTextField(body, "description") !== void 0 ? { description: optionalTextField(body, "description") } : {},
|
|
298
|
+
...status ? { status } : {},
|
|
299
|
+
...defaultAgentPatch !== void 0 ? { defaultAgentId: defaultAgentId ?? null } : {},
|
|
300
|
+
...optionalTextField(body, "workspaceRoot") !== void 0 ? { workspaceRoot: optionalTextField(body, "workspaceRoot") } : {},
|
|
301
|
+
...optionalTextField(body, "brief") !== void 0 ? { brief: optionalTextField(body, "brief") } : {},
|
|
302
|
+
...optionalTextField(body, "instructions") !== void 0 ? { instructions: optionalTextField(body, "instructions") } : {}
|
|
303
|
+
});
|
|
304
|
+
return c.json({
|
|
305
|
+
ok: true,
|
|
306
|
+
project
|
|
307
|
+
});
|
|
308
|
+
} catch (error) {
|
|
309
|
+
return c.json({
|
|
310
|
+
ok: false,
|
|
311
|
+
error: error instanceof Error ? error.message : String(error)
|
|
312
|
+
}, 404);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
authenticated.delete("/api/projects/:id", async (c) => {
|
|
316
|
+
service.projects.delete(c.req.param("id"));
|
|
317
|
+
return c.json({ ok: true });
|
|
318
|
+
});
|
|
319
|
+
authenticated.get("/api/projects/:id/sessions", async (c) => {
|
|
320
|
+
try {
|
|
321
|
+
const keys = service.projects.listSessionKeys(c.req.param("id"), parseLimit(c.req.query("limit"), 100));
|
|
322
|
+
const sessions = await Promise.all(keys.map((key) => service.sessions.getSession(key)));
|
|
323
|
+
return c.json({
|
|
324
|
+
ok: true,
|
|
325
|
+
sessions: sessions.filter(Boolean)
|
|
326
|
+
});
|
|
327
|
+
} catch (error) {
|
|
328
|
+
return c.json({
|
|
329
|
+
ok: false,
|
|
330
|
+
error: error instanceof Error ? error.message : String(error)
|
|
331
|
+
}, 404);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
authenticated.get("/api/projects/:id/goals", async (c) => {
|
|
335
|
+
try {
|
|
336
|
+
const ids = service.projects.listGoalIds(c.req.param("id"), parseLimit(c.req.query("limit"), 100));
|
|
337
|
+
return c.json({
|
|
338
|
+
ok: true,
|
|
339
|
+
goals: ids.map((id) => goals.get(id)).filter(Boolean)
|
|
340
|
+
});
|
|
341
|
+
} catch (error) {
|
|
342
|
+
return c.json({
|
|
343
|
+
ok: false,
|
|
344
|
+
error: error instanceof Error ? error.message : String(error)
|
|
345
|
+
}, 404);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
authenticated.get("/api/projects/:id/files", async (c) => {
|
|
349
|
+
const project = service.projects.get(c.req.param("id"));
|
|
350
|
+
if (!project) return c.json({
|
|
351
|
+
ok: false,
|
|
352
|
+
error: "Project not found"
|
|
353
|
+
}, 404);
|
|
354
|
+
if (!project.workspaceRoot?.trim()) return c.json({
|
|
355
|
+
ok: false,
|
|
356
|
+
error: "Project workspace root is not set"
|
|
357
|
+
}, 400);
|
|
358
|
+
let root;
|
|
359
|
+
try {
|
|
360
|
+
root = await realpath(project.workspaceRoot);
|
|
361
|
+
if (!(await stat(root)).isDirectory()) return c.json({
|
|
362
|
+
ok: false,
|
|
363
|
+
error: "Project workspace root is not a directory"
|
|
364
|
+
}, 400);
|
|
365
|
+
} catch (err) {
|
|
366
|
+
log.warn({
|
|
367
|
+
err,
|
|
368
|
+
projectId: project.id,
|
|
369
|
+
path: project.workspaceRoot
|
|
370
|
+
}, "project workspace root unavailable");
|
|
371
|
+
return c.json({
|
|
372
|
+
ok: false,
|
|
373
|
+
error: "Project workspace root is unavailable"
|
|
374
|
+
}, 404);
|
|
375
|
+
}
|
|
376
|
+
const requestedPath = normalizeRelativePath(c.req.query("path"));
|
|
377
|
+
const candidate = path$1.resolve(root, requestedPath);
|
|
378
|
+
if (!isWithinDirectory(root, candidate)) return c.json({
|
|
379
|
+
ok: false,
|
|
380
|
+
error: "Path is outside project workspace"
|
|
381
|
+
}, 400);
|
|
382
|
+
let currentPath;
|
|
383
|
+
try {
|
|
384
|
+
currentPath = await realpath(candidate);
|
|
385
|
+
if (!isWithinDirectory(root, currentPath)) return c.json({
|
|
386
|
+
ok: false,
|
|
387
|
+
error: "Path is outside project workspace"
|
|
388
|
+
}, 400);
|
|
389
|
+
if (!(await stat(currentPath)).isDirectory()) return c.json({
|
|
390
|
+
ok: false,
|
|
391
|
+
error: "Path is not a directory"
|
|
392
|
+
}, 400);
|
|
393
|
+
} catch (err) {
|
|
394
|
+
log.warn({
|
|
395
|
+
err,
|
|
396
|
+
projectId: project.id,
|
|
397
|
+
path: candidate
|
|
398
|
+
}, "project file path unavailable");
|
|
399
|
+
return c.json({
|
|
400
|
+
ok: false,
|
|
401
|
+
error: "Path not found"
|
|
402
|
+
}, 404);
|
|
403
|
+
}
|
|
404
|
+
try {
|
|
405
|
+
const dirents = await readdir(currentPath, { withFileTypes: true });
|
|
406
|
+
const entries = await Promise.all(dirents.filter((entry) => !SKIP_FILE_NAMES.has(entry.name)).map(async (entry) => {
|
|
407
|
+
const absolutePath = path$1.join(currentPath, entry.name);
|
|
408
|
+
const entryStat = await stat(absolutePath).catch(() => null);
|
|
409
|
+
const relativePath = path$1.relative(root, absolutePath).split(path$1.sep).join("/");
|
|
410
|
+
return {
|
|
411
|
+
name: entry.name,
|
|
412
|
+
path: relativePath,
|
|
413
|
+
type: entry.isDirectory() ? "directory" : "file",
|
|
414
|
+
size: entryStat?.isFile() ? entryStat.size : void 0,
|
|
415
|
+
updatedAt: entryStat?.mtime.toISOString()
|
|
416
|
+
};
|
|
417
|
+
}));
|
|
418
|
+
entries.sort((left, right) => {
|
|
419
|
+
if (left.type !== right.type) return left.type === "directory" ? -1 : 1;
|
|
420
|
+
return left.name.localeCompare(right.name);
|
|
421
|
+
});
|
|
422
|
+
const relativeCurrentPath = path$1.relative(root, currentPath).split(path$1.sep).join("/");
|
|
423
|
+
const parentRelativePath = relativeCurrentPath ? path$1.dirname(relativeCurrentPath).replaceAll("\\", "/") : null;
|
|
424
|
+
return c.json({
|
|
425
|
+
ok: true,
|
|
426
|
+
root,
|
|
427
|
+
path: relativeCurrentPath === "." ? "" : relativeCurrentPath,
|
|
428
|
+
parentPath: parentRelativePath === "." ? "" : parentRelativePath,
|
|
429
|
+
entries
|
|
430
|
+
});
|
|
431
|
+
} catch (err) {
|
|
432
|
+
log.warn({
|
|
433
|
+
err,
|
|
434
|
+
projectId: project.id,
|
|
435
|
+
path: currentPath
|
|
436
|
+
}, "project file list failed");
|
|
437
|
+
if (err?.code === "EACCES") return c.json({
|
|
438
|
+
ok: false,
|
|
439
|
+
error: "Permission denied"
|
|
440
|
+
}, 403);
|
|
441
|
+
return c.json({
|
|
442
|
+
ok: false,
|
|
443
|
+
error: "Failed to read project files"
|
|
444
|
+
}, 500);
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
authenticated.post("/api/projects/:id/sessions/:sessionKey", async (c) => {
|
|
448
|
+
try {
|
|
449
|
+
service.projects.attachSession(c.req.param("sessionKey"), c.req.param("id"));
|
|
450
|
+
const session = await service.sessions.getSession(c.req.param("sessionKey"));
|
|
451
|
+
return c.json({
|
|
452
|
+
ok: true,
|
|
453
|
+
session
|
|
454
|
+
});
|
|
455
|
+
} catch (error) {
|
|
456
|
+
return c.json({
|
|
457
|
+
ok: false,
|
|
458
|
+
error: error instanceof Error ? error.message : String(error)
|
|
459
|
+
}, 404);
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
authenticated.delete("/api/projects/:id/sessions/:sessionKey", async (c) => {
|
|
463
|
+
try {
|
|
464
|
+
const projectId = c.req.param("id");
|
|
465
|
+
const sessionKey = c.req.param("sessionKey");
|
|
466
|
+
if (!service.projects.get(projectId)) return c.json({
|
|
467
|
+
ok: false,
|
|
468
|
+
error: "Project not found"
|
|
469
|
+
}, 404);
|
|
470
|
+
const session = await service.sessions.getSession(sessionKey);
|
|
471
|
+
if (!session) return c.json({
|
|
472
|
+
ok: false,
|
|
473
|
+
error: "Session not found"
|
|
474
|
+
}, 404);
|
|
475
|
+
if (session.projectId !== projectId) return c.json({
|
|
476
|
+
ok: false,
|
|
477
|
+
error: "Session is not attached to this project"
|
|
478
|
+
}, 409);
|
|
479
|
+
service.projects.detachSession(sessionKey);
|
|
480
|
+
return c.json({ ok: true });
|
|
481
|
+
} catch (error) {
|
|
482
|
+
return c.json({
|
|
483
|
+
ok: false,
|
|
484
|
+
error: error instanceof Error ? error.message : String(error)
|
|
485
|
+
}, 404);
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
authenticated.post("/api/projects/:id/sessions/:sessionKey/summary-memory", async (c) => {
|
|
489
|
+
const projectId = c.req.param("id");
|
|
490
|
+
const sessionKey = c.req.param("sessionKey");
|
|
491
|
+
const project = service.projects.get(projectId);
|
|
492
|
+
if (!project) return c.json({
|
|
493
|
+
ok: false,
|
|
494
|
+
error: "Project not found"
|
|
495
|
+
}, 404);
|
|
496
|
+
const session = getSessionMetadata(sessionKey);
|
|
497
|
+
if (!session) return c.json({
|
|
498
|
+
ok: false,
|
|
499
|
+
error: "Session not found"
|
|
500
|
+
}, 404);
|
|
501
|
+
if (session.projectId !== projectId) return c.json({
|
|
502
|
+
ok: false,
|
|
503
|
+
error: "Session is not attached to this project"
|
|
504
|
+
}, 409);
|
|
505
|
+
const body = await c.req.json().catch(() => ({}));
|
|
506
|
+
const content = buildSessionSummaryMemoryContent(sessionKey, typeof body.summary === "string" ? body.summary : void 0);
|
|
507
|
+
const record = upsertMemoryRecord({
|
|
508
|
+
providerId: "local",
|
|
509
|
+
kind: "session_summary",
|
|
510
|
+
agentId: session.routing?.agentId ?? "main",
|
|
511
|
+
workspaceId: session.cwd,
|
|
512
|
+
sessionKey,
|
|
513
|
+
projectId,
|
|
514
|
+
content,
|
|
515
|
+
source: {
|
|
516
|
+
provider: "project-summary",
|
|
517
|
+
sessionEntryId: sessionKey
|
|
518
|
+
},
|
|
519
|
+
confidence: typeof body.confidence === "number" ? body.confidence : .7,
|
|
520
|
+
tags: [
|
|
521
|
+
"project",
|
|
522
|
+
"session-summary",
|
|
523
|
+
project.slug
|
|
524
|
+
],
|
|
525
|
+
status: "active",
|
|
526
|
+
sensitivity: "normal",
|
|
527
|
+
evidence: [{ sessionKey }]
|
|
528
|
+
});
|
|
529
|
+
return c.json({
|
|
530
|
+
ok: true,
|
|
531
|
+
record
|
|
532
|
+
}, 201);
|
|
533
|
+
});
|
|
534
|
+
authenticated.post("/api/projects/:id/goals/:goalId", async (c) => {
|
|
535
|
+
try {
|
|
536
|
+
service.projects.attachGoal(c.req.param("goalId"), c.req.param("id"));
|
|
537
|
+
return c.json({
|
|
538
|
+
ok: true,
|
|
539
|
+
goal: goals.get(c.req.param("goalId"))
|
|
540
|
+
});
|
|
541
|
+
} catch (error) {
|
|
542
|
+
return c.json({
|
|
543
|
+
ok: false,
|
|
544
|
+
error: error instanceof Error ? error.message : String(error)
|
|
545
|
+
}, 404);
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
authenticated.delete("/api/projects/:id/goals/:goalId", async (c) => {
|
|
549
|
+
try {
|
|
550
|
+
const projectId = c.req.param("id");
|
|
551
|
+
const goalId = c.req.param("goalId");
|
|
552
|
+
if (!service.projects.get(projectId)) return c.json({
|
|
553
|
+
ok: false,
|
|
554
|
+
error: "Project not found"
|
|
555
|
+
}, 404);
|
|
556
|
+
const goal = goals.get(goalId);
|
|
557
|
+
if (!goal) return c.json({
|
|
558
|
+
ok: false,
|
|
559
|
+
error: "Goal not found"
|
|
560
|
+
}, 404);
|
|
561
|
+
if (goal.projectId !== projectId) return c.json({
|
|
562
|
+
ok: false,
|
|
563
|
+
error: "Goal is not attached to this project"
|
|
564
|
+
}, 409);
|
|
565
|
+
service.projects.detachGoal(goalId);
|
|
566
|
+
return c.json({ ok: true });
|
|
567
|
+
} catch (error) {
|
|
568
|
+
return c.json({
|
|
569
|
+
ok: false,
|
|
570
|
+
error: error instanceof Error ? error.message : String(error)
|
|
571
|
+
}, 404);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
//#endregion
|
|
576
|
+
export { registerProjectsRoutes };
|
|
577
|
+
|
|
578
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.js","names":["path","record"],"sources":["../../../../../src/gateway/hono/routes/projects.ts"],"sourcesContent":["import type { Hono } from 'hono';\nimport { readdir, realpath, stat } from 'node:fs/promises';\nimport * as path from 'node:path';\n\nimport type { GoalWithDetails } from '../../../goals/index.js';\nimport { GoalService } from '../../../goals/index.js';\nimport {\n buildProjectLoopOverview,\n isValidProjectAgentId,\n normalizeProjectAgentId,\n resolveProjectAgentId,\n type ProjectStatus,\n type ProjectWorkflowRunBrief,\n} from '../../../projects/index.js';\nimport {\n getSqliteDatabase,\n getSessionMetadata,\n listMemoryRecords,\n loadTranscriptRowsForSession,\n upsertMemoryRecord,\n} from '../../../storage/sqlite/index.js';\nimport { createGatewayRouteLogger } from '../lib/route-logger.js';\nimport type { AuthenticatedRouteDeps } from './deps.js';\n\nconst log = createGatewayRouteLogger('Projects');\n\nfunction parseProjectStatus(raw: unknown): ProjectStatus | undefined {\n return raw === 'active' || raw === 'paused' || raw === 'archived' ? raw : undefined;\n}\n\nfunction parseLimit(raw: string | undefined, fallback = 50): number | undefined {\n if (!raw) return undefined;\n const n = Number.parseInt(raw, 10);\n return Number.isFinite(n) ? Math.min(500, Math.max(1, n)) : fallback;\n}\n\nfunction textField(body: Record<string, unknown>, key: string): string | undefined {\n const value = body[key];\n return typeof value === 'string' ? value : undefined;\n}\n\nfunction optionalTextField(body: Record<string, unknown>, key: string): string | null | undefined {\n if (!(key in body)) return undefined;\n const value = body[key];\n return typeof value === 'string' ? value : null;\n}\n\nconst SKIP_FILE_NAMES = new Set(['.git', 'node_modules']);\n\nfunction normalizeRelativePath(raw: string | undefined): string {\n const normalized = (raw ?? '').trim().replaceAll('\\\\', '/');\n return normalized.replace(/^\\/+/, '');\n}\n\nfunction isWithinDirectory(root: string, target: string): boolean {\n const relativePath = path.relative(root, target);\n return relativePath === '' || (!relativePath.startsWith('..') && !path.isAbsolute(relativePath));\n}\n\nfunction textFromTranscriptContent(content: unknown): string {\n if (typeof content === 'string') return content;\n if (!Array.isArray(content)) return '';\n return content\n .map((part) => {\n if (!part || typeof part !== 'object') return '';\n const record = part as Record<string, unknown>;\n return typeof record.text === 'string' ? record.text : '';\n })\n .filter(Boolean)\n .join('\\n');\n}\n\nfunction buildSessionSummaryMemoryContent(sessionKey: string, explicitSummary?: string): string {\n const summary = explicitSummary?.trim();\n if (summary) return summary;\n const rows = loadTranscriptRowsForSession(sessionKey)\n .filter((row) => {\n if (!row || typeof row !== 'object') return false;\n const record = row as unknown as Record<string, unknown>;\n const role = record.role;\n return role === 'user' || role === 'assistant' || role === 'compactionSummary' || role === 'branchSummary';\n })\n .slice(-12);\n const lines = rows\n .map((row) => {\n const record = row as unknown as Record<string, unknown>;\n const rowRole = typeof record.role === 'string' ? record.role : 'message';\n const role = rowRole === 'compactionSummary' || rowRole === 'branchSummary' ? 'summary' : rowRole;\n const text = (typeof record.summary === 'string' ? record.summary : undefined) ?? textFromTranscriptContent(record.content);\n const compact = text.trim().replace(/\\s+/g, ' ').slice(0, 280);\n return compact ? `- ${role}: ${compact}` : '';\n })\n .filter(Boolean);\n return lines.length > 0\n ? [`Session summary for ${sessionKey}:`, ...lines].join('\\n')\n : `Session summary for ${sessionKey}: no transcript content available.`;\n}\n\nfunction listFailedProjectWorkflowRuns(projectId: string, limit = 5): ProjectWorkflowRunBrief[] {\n const rows = getSqliteDatabase()\n .prepare(\n `SELECT run_id, definition_id, status, created_at_ms, error_message\n FROM workflow_runs\n WHERE project_id = ? AND status IN ('failed', 'timeout', 'cancelled')\n ORDER BY created_at_ms DESC\n LIMIT ?`,\n )\n .all(projectId, Math.max(1, Math.min(20, Math.floor(limit)))) as Array<{\n run_id: string;\n definition_id: string;\n status: string;\n created_at_ms: number;\n error_message: string | null;\n }>;\n return rows.map((row) => ({\n runId: row.run_id,\n definitionId: row.definition_id,\n status: row.status,\n createdAt: row.created_at_ms,\n errorMessage: row.error_message ?? undefined,\n }));\n}\n\nfunction buildProjectDigestMemoryContent(input: ReturnType<typeof buildProjectLoopOverview> & { projectName: string }): string {\n const lines = [\n `Project digest: ${input.projectName}`,\n `Status: ${input.digest.summary}`,\n input.digest.nextAction ? `Next: ${input.digest.nextAction}` : undefined,\n ].filter(Boolean) as string[];\n if (input.attentionItems.length > 0) {\n lines.push('', 'Attention:');\n for (const item of input.attentionItems.slice(0, 8)) {\n lines.push(`- ${item.kind}: ${item.title}${item.detail ? ` - ${item.detail}` : ''}`);\n }\n }\n if (input.timeline.length > 0) {\n lines.push('', 'Recent activity:');\n for (const item of input.timeline.slice(0, 8)) {\n lines.push(`- ${item.kind}: ${item.title}${item.detail ? ` - ${item.detail}` : ''}`);\n }\n }\n return lines.join('\\n');\n}\n\nfunction projectDigestMemoryRecordId(projectId: string): string {\n return `project-digest:${projectId}`;\n}\n\nexport function registerProjectsRoutes(authenticated: Hono, deps: AuthenticatedRouteDeps): void {\n const { service } = deps;\n const goals = new GoalService();\n\n authenticated.post('/api/projects', async (c) => {\n const body = (await c.req.json().catch(() => ({}))) as Record<string, unknown>;\n const name = textField(body, 'name')?.trim();\n if (!name) return c.json({ ok: false, error: 'Missing name' }, 400);\n const defaultAgentId = normalizeProjectAgentId(textField(body, 'defaultAgentId'));\n if (!isValidProjectAgentId(service.currentConfig, defaultAgentId)) {\n return c.json({ ok: false, error: 'Default agent not found' }, 400);\n }\n const project = service.projects.create({\n name,\n description: textField(body, 'description'),\n defaultAgentId,\n workspaceRoot: textField(body, 'workspaceRoot'),\n brief: textField(body, 'brief'),\n instructions: textField(body, 'instructions'),\n });\n return c.json({ ok: true, project }, 201);\n });\n\n authenticated.get('/api/projects', async (c) => {\n const status = parseProjectStatus(c.req.query('status'));\n const result = service.projects.list({\n ...(status ? { status } : {}),\n search: c.req.query('search'),\n sortBy: c.req.query('sortBy') as 'updatedAt' | 'createdAt' | 'name' | undefined,\n sortOrder: c.req.query('sortOrder') as 'asc' | 'desc' | undefined,\n limit: parseLimit(c.req.query('limit')),\n offset: c.req.query('offset') ? Math.max(0, Number.parseInt(c.req.query('offset')!, 10) || 0) : undefined,\n });\n return c.json({ ok: true, ...result });\n });\n\n authenticated.get('/api/projects/suggestions', async (c) => {\n const sessionKey = c.req.query('sessionKey')?.trim();\n return c.json({ ok: true, suggestions: sessionKey ? service.projects.suggestProjectsForSession(sessionKey) : [] });\n });\n\n authenticated.get('/api/projects/:id/overview', async (c) => {\n const project = service.projects.getWithDetails(c.req.param('id'));\n if (!project) return c.json({ ok: false, error: 'Project not found' }, 404);\n const goalIds = service.projects.listGoalIds(project.id, parseLimit(c.req.query('goalLimit'), 100));\n const projectGoals = goalIds\n .map((id) => goals.get(id))\n .filter((goal): goal is GoalWithDetails => Boolean(goal));\n const loop = buildProjectLoopOverview({\n project,\n goals: projectGoals,\n recentWorkflowRuns: project.recentWorkflowRuns,\n failedWorkflowRuns: listFailedProjectWorkflowRuns(project.id),\n memoryRecords: listMemoryRecords({ projectId: project.id, status: 'active', limit: 5 }),\n });\n return c.json({\n ok: true,\n overview: {\n project,\n stats: {\n sessionCount: project.sessionCount,\n goalCount: project.goalCount,\n activeGoalCount: project.activeGoalCount,\n recentWorkflowRunCount: project.recentWorkflowRuns.length,\n staleGoalCount: loop.staleGoals.length,\n attentionCount: loop.attentionItems.length,\n failedWorkflowRunCount: loop.failedWorkflowRuns.length,\n },\n activeGoals: loop.activeGoals,\n blockedGoals: loop.blockedGoals,\n staleGoals: loop.staleGoals,\n nextActions: loop.nextActions,\n attentionItems: loop.attentionItems,\n timeline: loop.timeline,\n digest: loop.digest,\n failedWorkflowRuns: loop.failedWorkflowRuns,\n recentSessions: project.recentSessions,\n recentWorkflowRuns: project.recentWorkflowRuns,\n recommendedAction: loop.recommendedAction,\n },\n });\n });\n\n authenticated.post('/api/projects/:id/digest-memory', async (c) => {\n const project = service.projects.getWithDetails(c.req.param('id'));\n if (!project) return c.json({ ok: false, error: 'Project not found' }, 404);\n const goalIds = service.projects.listGoalIds(project.id, 100);\n const projectGoals = goalIds\n .map((id) => goals.get(id))\n .filter((goal): goal is GoalWithDetails => Boolean(goal));\n const loop = buildProjectLoopOverview({\n project,\n goals: projectGoals,\n recentWorkflowRuns: project.recentWorkflowRuns,\n failedWorkflowRuns: listFailedProjectWorkflowRuns(project.id),\n memoryRecords: listMemoryRecords({ projectId: project.id, status: 'active', limit: 5 }),\n });\n const record = upsertMemoryRecord({\n id: projectDigestMemoryRecordId(project.id),\n providerId: 'local',\n kind: 'daily_note',\n agentId: resolveProjectAgentId({\n config: service.currentConfig,\n projects: service.projects,\n projectId: project.id,\n }),\n workspaceId: project.workspaceRoot,\n projectId: project.id,\n content: buildProjectDigestMemoryContent({ ...loop, projectName: project.name }),\n source: {\n provider: 'project-digest',\n },\n confidence: 0.75,\n tags: ['project', 'project-digest', project.slug],\n status: 'active',\n sensitivity: 'normal',\n });\n return c.json({ ok: true, record }, 201);\n });\n\n authenticated.post('/api/projects/:id/blockers', async (c) => {\n const project = service.projects.getWithDetails(c.req.param('id'));\n if (!project) return c.json({ ok: false, error: 'Project not found' }, 404);\n const body = (await c.req.json().catch(() => ({}))) as Record<string, unknown>;\n const title = typeof body.title === 'string' ? body.title.trim() : '';\n if (!title) return c.json({ ok: false, error: 'Missing title' }, 400);\n const reason = typeof body.reason === 'string' ? body.reason.trim() : '';\n const goal = goals.create({\n title,\n description: reason || undefined,\n agentId: resolveProjectAgentId({\n config: service.currentConfig,\n projects: service.projects,\n projectId: project.id,\n }),\n priority: body.priority === 'low' || body.priority === 'normal' || body.priority === 'high' ? body.priority : 'high',\n source: 'api',\n projectId: project.id,\n });\n const blocked = goals.setStatus(goal.id, 'blocked', { reason: reason || title });\n if (reason) {\n goals.setContextMessage({ goalId: goal.id, text: reason });\n }\n return c.json({ ok: true, goal: blocked ?? goals.get(goal.id) }, 201);\n });\n\n authenticated.get('/api/projects/:id', async (c) => {\n const project = service.projects.getWithDetails(c.req.param('id'));\n if (!project) return c.json({ ok: false, error: 'Project not found' }, 404);\n return c.json({ ok: true, project });\n });\n\n authenticated.patch('/api/projects/:id', async (c) => {\n const body = (await c.req.json().catch(() => ({}))) as Record<string, unknown>;\n const status = parseProjectStatus(body.status);\n const defaultAgentPatch = optionalTextField(body, 'defaultAgentId');\n const defaultAgentId = defaultAgentPatch === undefined ? undefined : normalizeProjectAgentId(defaultAgentPatch);\n if (defaultAgentId && !isValidProjectAgentId(service.currentConfig, defaultAgentId)) {\n return c.json({ ok: false, error: 'Default agent not found' }, 400);\n }\n try {\n const project = service.projects.update(c.req.param('id'), {\n ...(textField(body, 'name') !== undefined ? { name: textField(body, 'name') } : {}),\n ...(optionalTextField(body, 'description') !== undefined ? { description: optionalTextField(body, 'description') } : {}),\n ...(status ? { status } : {}),\n ...(defaultAgentPatch !== undefined ? { defaultAgentId: defaultAgentId ?? null } : {}),\n ...(optionalTextField(body, 'workspaceRoot') !== undefined ? { workspaceRoot: optionalTextField(body, 'workspaceRoot') } : {}),\n ...(optionalTextField(body, 'brief') !== undefined ? { brief: optionalTextField(body, 'brief') } : {}),\n ...(optionalTextField(body, 'instructions') !== undefined ? { instructions: optionalTextField(body, 'instructions') } : {}),\n });\n return c.json({ ok: true, project });\n } catch (error) {\n return c.json({ ok: false, error: error instanceof Error ? error.message : String(error) }, 404);\n }\n });\n\n authenticated.delete('/api/projects/:id', async (c) => {\n service.projects.delete(c.req.param('id'));\n return c.json({ ok: true });\n });\n\n authenticated.get('/api/projects/:id/sessions', async (c) => {\n try {\n const keys = service.projects.listSessionKeys(c.req.param('id'), parseLimit(c.req.query('limit'), 100));\n const sessions = await Promise.all(keys.map((key) => service.sessions.getSession(key)));\n return c.json({ ok: true, sessions: sessions.filter(Boolean) });\n } catch (error) {\n return c.json({ ok: false, error: error instanceof Error ? error.message : String(error) }, 404);\n }\n });\n\n authenticated.get('/api/projects/:id/goals', async (c) => {\n try {\n const ids = service.projects.listGoalIds(c.req.param('id'), parseLimit(c.req.query('limit'), 100));\n return c.json({ ok: true, goals: ids.map((id) => goals.get(id)).filter(Boolean) });\n } catch (error) {\n return c.json({ ok: false, error: error instanceof Error ? error.message : String(error) }, 404);\n }\n });\n\n authenticated.get('/api/projects/:id/files', async (c) => {\n const project = service.projects.get(c.req.param('id'));\n if (!project) return c.json({ ok: false, error: 'Project not found' }, 404);\n if (!project.workspaceRoot?.trim()) {\n return c.json({ ok: false, error: 'Project workspace root is not set' }, 400);\n }\n\n let root: string;\n try {\n root = await realpath(project.workspaceRoot);\n const rootStat = await stat(root);\n if (!rootStat.isDirectory()) {\n return c.json({ ok: false, error: 'Project workspace root is not a directory' }, 400);\n }\n } catch (err) {\n log.warn({ err, projectId: project.id, path: project.workspaceRoot }, 'project workspace root unavailable');\n return c.json({ ok: false, error: 'Project workspace root is unavailable' }, 404);\n }\n\n const requestedPath = normalizeRelativePath(c.req.query('path'));\n const candidate = path.resolve(root, requestedPath);\n if (!isWithinDirectory(root, candidate)) {\n return c.json({ ok: false, error: 'Path is outside project workspace' }, 400);\n }\n\n let currentPath: string;\n try {\n currentPath = await realpath(candidate);\n if (!isWithinDirectory(root, currentPath)) {\n return c.json({ ok: false, error: 'Path is outside project workspace' }, 400);\n }\n const currentStat = await stat(currentPath);\n if (!currentStat.isDirectory()) {\n return c.json({ ok: false, error: 'Path is not a directory' }, 400);\n }\n } catch (err) {\n log.warn({ err, projectId: project.id, path: candidate }, 'project file path unavailable');\n return c.json({ ok: false, error: 'Path not found' }, 404);\n }\n\n try {\n const dirents = await readdir(currentPath, { withFileTypes: true });\n const entries = await Promise.all(dirents\n .filter((entry) => !SKIP_FILE_NAMES.has(entry.name))\n .map(async (entry) => {\n const absolutePath = path.join(currentPath, entry.name);\n const entryStat = await stat(absolutePath).catch(() => null);\n const relativePath = path.relative(root, absolutePath).split(path.sep).join('/');\n return {\n name: entry.name,\n path: relativePath,\n type: entry.isDirectory() ? 'directory' : 'file',\n size: entryStat?.isFile() ? entryStat.size : undefined,\n updatedAt: entryStat?.mtime.toISOString(),\n };\n }));\n entries.sort((left, right) => {\n if (left.type !== right.type) return left.type === 'directory' ? -1 : 1;\n return left.name.localeCompare(right.name);\n });\n const relativeCurrentPath = path.relative(root, currentPath).split(path.sep).join('/');\n const parentRelativePath = relativeCurrentPath ? path.dirname(relativeCurrentPath).replaceAll('\\\\', '/') : null;\n return c.json({\n ok: true,\n root,\n path: relativeCurrentPath === '.' ? '' : relativeCurrentPath,\n parentPath: parentRelativePath === '.' ? '' : parentRelativePath,\n entries,\n });\n } catch (err) {\n log.warn({ err, projectId: project.id, path: currentPath }, 'project file list failed');\n if ((err as NodeJS.ErrnoException)?.code === 'EACCES') {\n return c.json({ ok: false, error: 'Permission denied' }, 403);\n }\n return c.json({ ok: false, error: 'Failed to read project files' }, 500);\n }\n });\n\n authenticated.post('/api/projects/:id/sessions/:sessionKey', async (c) => {\n try {\n service.projects.attachSession(c.req.param('sessionKey'), c.req.param('id'));\n const session = await service.sessions.getSession(c.req.param('sessionKey'));\n return c.json({ ok: true, session });\n } catch (error) {\n return c.json({ ok: false, error: error instanceof Error ? error.message : String(error) }, 404);\n }\n });\n\n authenticated.delete('/api/projects/:id/sessions/:sessionKey', async (c) => {\n try {\n const projectId = c.req.param('id');\n const sessionKey = c.req.param('sessionKey');\n if (!service.projects.get(projectId)) {\n return c.json({ ok: false, error: 'Project not found' }, 404);\n }\n const session = await service.sessions.getSession(sessionKey);\n if (!session) {\n return c.json({ ok: false, error: 'Session not found' }, 404);\n }\n if (session.projectId !== projectId) {\n return c.json({ ok: false, error: 'Session is not attached to this project' }, 409);\n }\n service.projects.detachSession(sessionKey);\n return c.json({ ok: true });\n } catch (error) {\n return c.json({ ok: false, error: error instanceof Error ? error.message : String(error) }, 404);\n }\n });\n\n authenticated.post('/api/projects/:id/sessions/:sessionKey/summary-memory', async (c) => {\n const projectId = c.req.param('id');\n const sessionKey = c.req.param('sessionKey');\n const project = service.projects.get(projectId);\n if (!project) return c.json({ ok: false, error: 'Project not found' }, 404);\n const session = getSessionMetadata(sessionKey);\n if (!session) return c.json({ ok: false, error: 'Session not found' }, 404);\n if (session.projectId !== projectId) {\n return c.json({ ok: false, error: 'Session is not attached to this project' }, 409);\n }\n const body = (await c.req.json().catch(() => ({}))) as Record<string, unknown>;\n const content = buildSessionSummaryMemoryContent(\n sessionKey,\n typeof body.summary === 'string' ? body.summary : undefined,\n );\n const record = upsertMemoryRecord({\n providerId: 'local',\n kind: 'session_summary',\n agentId: session.routing?.agentId ?? 'main',\n workspaceId: session.cwd,\n sessionKey,\n projectId,\n content,\n source: {\n provider: 'project-summary',\n sessionEntryId: sessionKey,\n },\n confidence: typeof body.confidence === 'number' ? body.confidence : 0.7,\n tags: ['project', 'session-summary', project.slug],\n status: 'active',\n sensitivity: 'normal',\n evidence: [{ sessionKey }],\n });\n return c.json({ ok: true, record }, 201);\n });\n\n authenticated.post('/api/projects/:id/goals/:goalId', async (c) => {\n try {\n service.projects.attachGoal(c.req.param('goalId'), c.req.param('id'));\n return c.json({ ok: true, goal: goals.get(c.req.param('goalId')) });\n } catch (error) {\n return c.json({ ok: false, error: error instanceof Error ? error.message : String(error) }, 404);\n }\n });\n\n authenticated.delete('/api/projects/:id/goals/:goalId', async (c) => {\n try {\n const projectId = c.req.param('id');\n const goalId = c.req.param('goalId');\n if (!service.projects.get(projectId)) {\n return c.json({ ok: false, error: 'Project not found' }, 404);\n }\n const goal = goals.get(goalId);\n if (!goal) {\n return c.json({ ok: false, error: 'Goal not found' }, 404);\n }\n if (goal.projectId !== projectId) {\n return c.json({ ok: false, error: 'Goal is not attached to this project' }, 409);\n }\n service.projects.detachGoal(goalId);\n return c.json({ ok: true });\n } catch (error) {\n return c.json({ ok: false, error: error instanceof Error ? error.message : String(error) }, 404);\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBA,MAAM,MAAM,yBAAyB,WAAW;AAEhD,SAAS,mBAAmB,KAAyC;AACnE,QAAO,QAAQ,YAAY,QAAQ,YAAY,QAAQ,aAAa,MAAM,KAAA;;AAG5E,SAA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