@xopcai/xopc 0.0.127 → 0.0.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CgGgO4OV.js → agent-avatar-dicebear-DHzfg5D-.js} +1 -1
- package/dist/gateway/static/root/assets/agents-CMxKKFQD.js +2 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-ptk9c5BN.js +1 -0
- package/dist/gateway/static/root/assets/{appearance-settings-BnHQW7Hv.js → appearance-settings-bYeEj3IW.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-DdZvDf5B.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-5NXT7Zqv.js → archive-plugin-Dy6lsTHw.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DghwhYe0.js → attachment-load-qOtBYR6Y.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-DYmESgwl.js → automation-suggestion-card-BFH-RfaV.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-B8JTjkCr.js +4 -0
- package/dist/gateway/static/root/assets/{binary-plugins-DSbPKdWX.js → binary-plugins-DJvi_thc.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CoZ-_np-.js → block-editor-DlMnizlt.js} +4 -4
- package/dist/gateway/static/root/assets/browser-settings-page-slHLiZgi.js +8 -0
- package/dist/gateway/static/root/assets/capability-presets-api-D4q7vHVJ.js +1 -0
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dng8Grpv.js +1 -0
- package/dist/gateway/static/root/assets/channel-recipient-api-BrW5Kcgc.js +1 -0
- package/dist/gateway/static/root/assets/channels-settings-KIsISXw0.js +1 -0
- package/dist/gateway/static/root/assets/{code-editor-gbRgS14t.js → code-editor--tMO38Tr.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-C5fx4Qs9.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-Jmdn6q47.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-npJ0Oh5p.js → desktop-pet-settings-B-u63N4e.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BR2ItBuf.js → directory-picker-path-field-8p1ehIHn.js} +1 -1
- package/dist/gateway/static/root/assets/dreaming-settings-CCkKP-I4.js +3 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-Tl0f1rNv.js → extension-debug-page-DJ1ABK95.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Ck7QuwE3.js → extension-page-CP9P2lGM.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-DnhU-tx0.js +1 -0
- package/dist/gateway/static/root/assets/fetch-BMjlW0g1.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-CjxDn46s.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-TING7224.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-Yh8h3hkj.js → gateway-startup-retry-CY5W2Pp4.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-2lPbGfp3.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-DHWVRafk.js +4 -0
- package/dist/gateway/static/root/assets/goals-config-api-BqhuxG8P.js +1 -0
- package/dist/gateway/static/root/assets/goals-page-CMk-9ZYN.js +2 -0
- package/dist/gateway/static/root/assets/goals-settings-BHzOAU_l.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-BQIm0P3V.js +1 -0
- package/dist/gateway/static/root/assets/{html-workspace-editor-DV90ddkE.js → html-workspace-editor-COqmtESs.js} +1 -1
- package/dist/gateway/static/root/assets/index-C4k6QSXw.js +257 -0
- package/dist/gateway/static/root/assets/index-EKmpPvZj.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CfQrt_Rb.js → keyboard-shortcuts-settings-BrENZzM7.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-BiL302Ve.js +2 -0
- package/dist/gateway/static/root/assets/{markdown-editor-BFOjBBla.js → markdown-editor-jD1LPiP-.js} +2 -2
- package/dist/gateway/static/root/assets/{markdown-split-BwiMdCf_.js → markdown-split-BYF4ReGM.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DhoizyZv.js → media-plugins-CpQDz-QJ.js} +1 -1
- package/dist/gateway/static/root/assets/messages-YzjnURPJ.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-CFPpl3Cq.js +2 -0
- package/dist/gateway/static/root/assets/notes-page-BurgcdVZ.js +1 -0
- package/dist/gateway/static/root/assets/notes-workbench-BAELRM_O.js +2 -0
- package/dist/gateway/static/root/assets/{page-tabs-DDC2t4Z8.js → page-tabs-RnYYOIWO.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BTmk-XDM.js → preview-open-alternatives-CTRt06Ri.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-iXX1Ceo2.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-GDVTFAY7.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-BUrbUnwv.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-DqU-yKIh.js → save-bar-controls-c4pZeikq.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-CUttkoSB.js → schedule-field-Cb6R7iuP.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CVSQA9nI.js → schema-form-BqET_hEP.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-CiOreA2k.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-C-qvptlu.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-CK7ogS-P.js → settings-collapsible-section-DuOvqNsI.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-Bugp38Fa.js → settings-form-section-DptSsbWd.js} +1 -1
- package/dist/gateway/static/root/assets/settings-loading-skeleton-BlVfBCb9.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-layout-DBRWwdhh.js → settings-page-layout-DVt69dJJ.js} +1 -1
- package/dist/gateway/static/root/assets/settings-page-xQx2Pkg5.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-DWB8VdLK.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-8m_ACH0z.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-CgxfhNxI.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BBFUOxmf.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-bo695odu.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-DJ6YuLqR.js → system-settings-panel-CW22OkZ4.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-B0T7N8Km.js → typed-models-lib-BqpGAKxV.js} +1 -1
- package/dist/gateway/static/root/assets/url-DFGNSBNT.js +1 -0
- package/dist/gateway/static/root/assets/use-channel-catalog-CPdJ0o0i.js +1 -0
- package/dist/gateway/static/root/assets/user-profile-settings-panel-CERVLuaW.js +1 -0
- package/dist/gateway/static/root/assets/{utils-CehXcWAY.js → utils-BnmysurA.js} +1 -1
- package/dist/gateway/static/root/assets/vendor-codemirror-C1WKjCk5.js +45 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-Jr3jvPcB.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-B-8rex4u.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-c4jeaohQ.js → workflow-run-setup-panel-Ci9GSPnS.js} +2 -2
- package/dist/gateway/static/root/assets/{workflow-start-dialog-ENRHjoqa.js → workflow-start-dialog-BhDj8pqH.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-Brb3UGvs.js +18 -0
- package/dist/gateway/static/root/index.html +7 -6
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +3 -0
- package/dist/src/agent/agent-manager.js +14 -6
- package/dist/src/agent/agent-manager.js.map +1 -1
- package/dist/src/agent/capabilities/definitions.d.ts +14 -0
- package/dist/src/agent/capabilities/definitions.js +19 -0
- package/dist/src/agent/capabilities/definitions.js.map +1 -1
- package/dist/src/agent/goals/post-turn.js +23 -2
- package/dist/src/agent/goals/post-turn.js.map +1 -1
- package/dist/src/agent/messaging/command-handler.d.ts +4 -0
- package/dist/src/agent/messaging/command-handler.js +6 -0
- package/dist/src/agent/messaging/command-handler.js.map +1 -1
- package/dist/src/agent/service.d.ts +2 -0
- package/dist/src/agent/service.js +23 -0
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/skills/hub-lock.d.ts +5 -5
- package/dist/src/agent/skills/hub-lock.js +12 -12
- package/dist/src/agent/skills/hub-lock.js.map +1 -1
- package/dist/src/agent/skills/hub-pull.d.ts +15 -0
- package/dist/src/agent/skills/hub-pull.js +299 -24
- package/dist/src/agent/skills/hub-pull.js.map +1 -1
- package/dist/src/agent/skills/index.js +4 -40
- package/dist/src/agent/skills/index.js.map +1 -1
- package/dist/src/agent/skills/install-target.d.ts +3 -0
- package/dist/src/agent/skills/install-target.js +11 -0
- package/dist/src/agent/skills/install-target.js.map +1 -0
- package/dist/src/agent/skills/managed-store.d.ts +5 -3
- package/dist/src/agent/skills/managed-store.js +10 -9
- package/dist/src/agent/skills/managed-store.js.map +1 -1
- package/dist/src/agent/skills/marketplace/adapters/store/adapter.js +5 -3
- package/dist/src/agent/skills/marketplace/adapters/store/adapter.js.map +1 -1
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.d.ts +21 -1
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +62 -6
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js.map +1 -1
- package/dist/src/agent/skills/marketplace/resolve-adapter.js +1 -1
- package/dist/src/agent/skills/marketplace/resolve-adapter.js.map +1 -1
- package/dist/src/agent/skills/skill-manage-ops.js +2 -2
- package/dist/src/agent/skills/skill-manage-ops.js.map +1 -1
- package/dist/src/agent/skills/skill-manager.js +1 -6
- package/dist/src/agent/skills/skill-manager.js.map +1 -1
- package/dist/src/agent/skills/workspace-skills-dir.d.ts +1 -0
- package/dist/src/agent/skills/workspace-skills-dir.js +5 -1
- package/dist/src/agent/skills/workspace-skills-dir.js.map +1 -1
- package/dist/src/agent/tools/automation-tool.d.ts +6 -6
- package/dist/src/agent/tools/browser/tool/schemas.d.ts +20 -20
- package/dist/src/agent/tools/composio-tool.d.ts +3 -3
- package/dist/src/agent/tools/desktop-pet-tool.d.ts +7 -7
- package/dist/src/agent/tools/factory.d.ts +3 -0
- package/dist/src/agent/tools/factory.js +6 -1
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/goal-tool.d.ts +16 -16
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/agent/tools/skill-install-tool.d.ts +28 -0
- package/dist/src/agent/tools/skill-install-tool.js +81 -0
- package/dist/src/agent/tools/skill-install-tool.js.map +1 -0
- package/dist/src/agent/tools/skill-manage-tool.js +3 -6
- package/dist/src/agent/tools/skill-manage-tool.js.map +1 -1
- package/dist/src/agent/tools/tool-manual-tool.d.ts +2 -2
- package/dist/src/agent/tools/xopc-use-tool.d.ts +5 -5
- package/dist/src/automations/domain/types.d.ts +1 -0
- package/dist/src/automations/draft/automation-draft-service.js +1 -1
- package/dist/src/automations/service/automation-service.js +9 -0
- package/dist/src/automations/service/automation-service.js.map +1 -1
- package/dist/src/browser/schemas.d.ts +52 -52
- package/dist/src/capabilities/store-connector.d.ts +17 -0
- package/dist/src/capabilities/store-connector.js +191 -0
- package/dist/src/capabilities/store-connector.js.map +1 -0
- package/dist/src/chat-commands/builtins/skill.d.ts +1 -0
- package/dist/src/chat-commands/builtins/skill.js +132 -0
- package/dist/src/chat-commands/builtins/skill.js.map +1 -0
- package/dist/src/chat-commands/context.d.ts +3 -0
- package/dist/src/chat-commands/context.js +2 -0
- package/dist/src/chat-commands/context.js.map +1 -1
- package/dist/src/chat-commands/index.d.ts +1 -0
- package/dist/src/chat-commands/index.js +3 -1
- package/dist/src/chat-commands/index.js.map +1 -1
- package/dist/src/chat-commands/types.d.ts +17 -0
- 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/connectors.d.ts +4 -0
- package/dist/src/cli/commands/connectors.js +96 -0
- package/dist/src/cli/commands/connectors.js.map +1 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +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/skills.js +1 -1
- 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/config/schema.js +2 -2
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/connectors/health.js +1 -1
- package/dist/src/connectors/install.js +3 -1
- package/dist/src/connectors/install.js.map +1 -1
- package/dist/src/connectors/materialize.js +2 -0
- package/dist/src/connectors/materialize.js.map +1 -1
- package/dist/src/connectors/types.d.ts +19 -1
- package/dist/src/extensions/install.js +1 -1
- package/dist/src/extensions/types/manifest.d.ts +1 -1
- package/dist/src/extensions/update.js +5 -3
- package/dist/src/extensions/update.js.map +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/chat-stream/mapper.js +5 -1
- package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
- package/dist/src/gateway/chat-stream/protocol.d.ts +2 -0
- package/dist/src/gateway/hono/lib/config-payload.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
- package/dist/src/gateway/hono/middleware/auth.d.ts +2 -2
- package/dist/src/gateway/hono/middleware/logger.d.ts +1 -1
- package/dist/src/gateway/hono/middleware/route-errors.d.ts +1 -1
- package/dist/src/gateway/hono/middleware/strict-rate-limit.d.ts +2 -2
- package/dist/src/gateway/hono/routes/capabilities.d.ts +3 -0
- package/dist/src/gateway/hono/routes/capabilities.js +79 -0
- package/dist/src/gateway/hono/routes/capabilities.js.map +1 -0
- package/dist/src/gateway/hono/routes/commands-skills.js +81 -3
- package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +2 -2
- package/dist/src/gateway/hono/routes/goals.js +212 -3
- 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/lazy-bundles.js +8 -0
- package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/hono/routes/mobile.d.ts +3 -0
- package/dist/src/gateway/hono/routes/mobile.js +113 -0
- package/dist/src/gateway/hono/routes/mobile.js.map +1 -0
- package/dist/src/gateway/hono/routes/projects.js +17 -0
- package/dist/src/gateway/hono/routes/projects.js.map +1 -1
- package/dist/src/gateway/hono/routes/workspace.js +4 -1
- package/dist/src/gateway/hono/routes/workspace.js.map +1 -1
- package/dist/src/gateway/hono/sse.d.ts +3 -3
- package/dist/src/gateway/run-loop.js +1 -1
- package/dist/src/gateway/service/marketplace-service.d.ts +23 -1
- package/dist/src/gateway/service/marketplace-service.js +57 -6
- package/dist/src/gateway/service/marketplace-service.js.map +1 -1
- package/dist/src/gateway/service.d.ts +2 -0
- package/dist/src/gateway/service.js +12 -2
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/goals/goal-contract-draft.d.ts +15 -0
- package/dist/src/goals/goal-contract-draft.js +114 -0
- package/dist/src/goals/goal-contract-draft.js.map +1 -0
- package/dist/src/goals/goal-evidence-review.d.ts +15 -0
- package/dist/src/goals/goal-evidence-review.js +91 -0
- package/dist/src/goals/goal-evidence-review.js.map +1 -0
- package/dist/src/goals/goal-runner.js +3 -1
- package/dist/src/goals/goal-runner.js.map +1 -1
- package/dist/src/goals/goal-service.d.ts +17 -1
- package/dist/src/goals/goal-service.js +44 -3
- package/dist/src/goals/goal-service.js.map +1 -1
- package/dist/src/goals/goal-store.d.ts +18 -1
- package/dist/src/goals/goal-store.js +190 -1
- package/dist/src/goals/goal-store.js.map +1 -1
- package/dist/src/goals/index.d.ts +4 -0
- package/dist/src/goals/index.js +3 -1
- package/dist/src/goals/types.d.ts +42 -0
- package/dist/src/mcp/channel-bridge.js +1 -1
- package/dist/src/mobile/notification-service.d.ts +8 -0
- package/dist/src/mobile/notification-service.js +139 -0
- package/dist/src/mobile/notification-service.js.map +1 -0
- package/dist/src/mobile/notification-store.d.ts +28 -0
- package/dist/src/mobile/notification-store.js +134 -0
- package/dist/src/mobile/notification-store.js.map +1 -0
- package/dist/src/mobile/notification-types.d.ts +37 -0
- package/dist/src/mobile/notification-types.js +11 -0
- package/dist/src/mobile/notification-types.js.map +1 -0
- package/dist/src/storage/sqlite/migrations/026_goal_contracts.sql +10 -0
- package/dist/src/storage/sqlite/migrations/027_mobile_notifications.sql +43 -0
- package/dist/src/storage/sqlite/migrations/028_goal_evidence_requirements.sql +47 -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/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +44 -0
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/package.json +1 -1
- package/skills/THIRD_PARTY_NOTICES.md +16 -0
- package/skills/creative/algorithmic-art/SKILL.md +37 -0
- package/skills/creative/algorithmic-art/templates/generator-template.js +27 -0
- package/skills/creative/algorithmic-art/templates/viewer.html +27 -0
- package/skills/documents/doc-coauthoring/SKILL.md +40 -0
- package/skills/documents/doc-coauthoring/references/reader-review.md +9 -0
- package/skills/documents/docx/SKILL.md +40 -0
- package/skills/documents/docx/references/editing-checklist.md +8 -0
- package/skills/documents/docx/scripts/inspect_ooxml.py +36 -0
- package/skills/documents/docx/scripts/render_docx.py +33 -0
- package/skills/documents/pdf/SKILL.md +47 -0
- package/skills/documents/pdf/references/operations.md +16 -0
- package/skills/documents/pdf/scripts/inspect_pdf.py +41 -0
- package/skills/documents/pdf/scripts/render_pdf.py +32 -0
- package/skills/documents/pptx/SKILL.md +41 -0
- package/skills/documents/pptx/references/qa-checklist.md +6 -0
- package/skills/documents/pptx/scripts/inspect_ooxml.py +34 -0
- package/skills/documents/pptx/scripts/render_pptx.py +33 -0
- package/skills/engineering/define-goal/SKILL.md +41 -0
- package/skills/engineering/define-goal/references/objective-rubric.md +12 -0
- package/dist/gateway/static/root/assets/agents-k59l7NMb.js +0 -2
- package/dist/gateway/static/root/assets/app-management-settings-panel-DeQsTsyy.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-BG9b4abG.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-De8mVutL.js +0 -4
- package/dist/gateway/static/root/assets/browser-settings-page-C_ZRa4LF.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-api-hny224j-.js +0 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Drc0qLsw.js +0 -1
- package/dist/gateway/static/root/assets/channel-recipient-api-DAlOHxKJ.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-CA20zBV9.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-qMyMB5te.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-XG6Vb_fZ.js +0 -1
- package/dist/gateway/static/root/assets/dreaming-settings-CkUZ997f.js +0 -3
- package/dist/gateway/static/root/assets/extension-settings-page-3RMhQtZ3.js +0 -1
- package/dist/gateway/static/root/assets/fetch-pg2ErdAk.js +0 -1
- package/dist/gateway/static/root/assets/gateway-config-api-DbG97ia2.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-B8cyqKk-.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-DmeW7Zz3.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DrTyGbVD.js +0 -1
- package/dist/gateway/static/root/assets/goals-config-api-CxCWGIBB.js +0 -1
- package/dist/gateway/static/root/assets/goals-page-DV1bJhIh.js +0 -2
- package/dist/gateway/static/root/assets/goals-settings-9DrfOkP5.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-KaDpZrv0.js +0 -1
- package/dist/gateway/static/root/assets/index-C2F0Clvm.js +0 -256
- package/dist/gateway/static/root/assets/index-COQSX5d_.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-C9dpiNTF.js +0 -2
- package/dist/gateway/static/root/assets/messages-DmnbiNxU.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-zdCdmBmH.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-MpGeFfPt.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-DYCM3yd2.js +0 -2
- package/dist/gateway/static/root/assets/project-detail-page-Cu0ElRnS.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DakNaUjZ.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DYKjt7L9.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CcGHDsz1.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CuFdeKNu.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-0AJoUvxi.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-D6a_hEk7.js +0 -1
- package/dist/gateway/static/root/assets/share-preview-page-BtsuETKF.js +0 -2
- package/dist/gateway/static/root/assets/shares-settings-CcEFT7S9.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BcN_RuTD.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-BbRZZZA5.js +0 -2
- package/dist/gateway/static/root/assets/use-channel-catalog-C6vrxdzZ.js +0 -1
- package/dist/gateway/static/root/assets/user-profile-settings-panel-DZ0nKMgj.js +0 -1
- package/dist/gateway/static/root/assets/vendor-codemirror-BvNgyE1Q.js +0 -45
- package/dist/gateway/static/root/assets/voice-api-key-field-2QKflCx8.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-DfJnuWq1.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-BJwwFTm_.js +0 -18
|
@@ -94,6 +94,48 @@ function goalContextFromRow(row) {
|
|
|
94
94
|
updatedAt: row.updated_at
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
+
function goalContractFromRow(row) {
|
|
98
|
+
return {
|
|
99
|
+
goalId: row.goal_id,
|
|
100
|
+
version: row.version,
|
|
101
|
+
objective: row.objective,
|
|
102
|
+
scopeBoundary: row.scope_boundary ?? void 0,
|
|
103
|
+
evidencePlan: parseJsonStringArray(row.evidence_plan_json) ?? [],
|
|
104
|
+
createdAt: row.created_at,
|
|
105
|
+
updatedAt: row.updated_at
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function normalizeStringList(items, limit = 20) {
|
|
109
|
+
if (!items) return [];
|
|
110
|
+
const seen = /* @__PURE__ */ new Set();
|
|
111
|
+
const result = [];
|
|
112
|
+
for (const item of items) {
|
|
113
|
+
const text = item.trim();
|
|
114
|
+
const key = text.toLocaleLowerCase();
|
|
115
|
+
if (!text || seen.has(key)) continue;
|
|
116
|
+
seen.add(key);
|
|
117
|
+
result.push(text);
|
|
118
|
+
if (result.length >= limit) break;
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
function normalizeContract(input, goalId, fallbackObjective, now, version = 1, createdAt = now) {
|
|
123
|
+
if (!input) return void 0;
|
|
124
|
+
return {
|
|
125
|
+
goalId,
|
|
126
|
+
version,
|
|
127
|
+
objective: input.objective?.trim() || fallbackObjective,
|
|
128
|
+
scopeBoundary: input.scopeBoundary?.trim() || void 0,
|
|
129
|
+
evidencePlan: normalizeStringList(input.evidencePlan),
|
|
130
|
+
createdAt,
|
|
131
|
+
updatedAt: now
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function insertGoalContract(db, contract) {
|
|
135
|
+
db.prepare(`INSERT INTO goal_contracts (
|
|
136
|
+
goal_id, version, objective, scope_boundary, evidence_plan_json, created_at, updated_at
|
|
137
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?)`).run(contract.goalId, contract.version, contract.objective, contract.scopeBoundary ?? null, JSON.stringify(contract.evidencePlan), contract.createdAt, contract.updatedAt);
|
|
138
|
+
}
|
|
97
139
|
function eventFromRow(row) {
|
|
98
140
|
return {
|
|
99
141
|
id: row.event_id,
|
|
@@ -118,6 +160,38 @@ function evidenceFromRow(row) {
|
|
|
118
160
|
createdAt: row.created_at
|
|
119
161
|
};
|
|
120
162
|
}
|
|
163
|
+
function evidenceRequirementFromRow(row, evidenceIds = []) {
|
|
164
|
+
return {
|
|
165
|
+
id: row.requirement_id,
|
|
166
|
+
goalId: row.goal_id,
|
|
167
|
+
text: row.text,
|
|
168
|
+
status: row.status,
|
|
169
|
+
evidenceIds,
|
|
170
|
+
reviewReason: row.review_reason ?? void 0,
|
|
171
|
+
reviewConfidence: row.review_confidence ?? void 0,
|
|
172
|
+
reviewedBy: row.reviewed_by ?? void 0,
|
|
173
|
+
reviewedAt: row.reviewed_at ?? void 0,
|
|
174
|
+
requiresHumanApproval: Boolean(row.requires_human_approval),
|
|
175
|
+
createdAt: row.created_at,
|
|
176
|
+
updatedAt: row.updated_at,
|
|
177
|
+
sortOrder: row.sort_order
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
function syncEvidenceRequirements(db, goalId, evidencePlan, now) {
|
|
181
|
+
const existing = db.prepare(`SELECT * FROM goal_evidence_requirements WHERE goal_id = ?`).all(goalId);
|
|
182
|
+
const byText = new Map(existing.map((item) => [item.text.toLocaleLowerCase(), item]));
|
|
183
|
+
const desired = new Set(evidencePlan.map((text) => text.toLocaleLowerCase()));
|
|
184
|
+
for (const item of existing) if (!desired.has(item.text.toLocaleLowerCase())) db.prepare(`DELETE FROM goal_evidence_requirements WHERE requirement_id = ?`).run(item.requirement_id);
|
|
185
|
+
for (const [index, text] of evidencePlan.entries()) {
|
|
186
|
+
const current = byText.get(text.toLocaleLowerCase());
|
|
187
|
+
if (current) db.prepare(`UPDATE goal_evidence_requirements
|
|
188
|
+
SET text = ?, sort_order = ?, updated_at = ?
|
|
189
|
+
WHERE requirement_id = ?`).run(text, index + 1, now, current.requirement_id);
|
|
190
|
+
else db.prepare(`INSERT INTO goal_evidence_requirements (
|
|
191
|
+
requirement_id, goal_id, text, status, requires_human_approval, created_at, updated_at, sort_order
|
|
192
|
+
) VALUES (?, ?, ?, 'pending', 1, ?, ?, ?)`).run(randomUUID(), goalId, text, now, now, index + 1);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
121
195
|
function clampLimit(n, fallback) {
|
|
122
196
|
return Math.min(500, Math.max(1, Math.floor(n ?? fallback)));
|
|
123
197
|
}
|
|
@@ -156,6 +230,8 @@ var GoalStore = class {
|
|
|
156
230
|
source: input.source ?? "chat",
|
|
157
231
|
projectId: input.projectId?.trim() || void 0
|
|
158
232
|
};
|
|
233
|
+
const contract = normalizeContract(input.contract, goal.id, goal.title, now);
|
|
234
|
+
const criteria = normalizeStringList(input.contract?.criteria);
|
|
159
235
|
runSqliteWriteTransaction((db) => {
|
|
160
236
|
db.prepare(`INSERT INTO goals (
|
|
161
237
|
goal_id, title, description, status, agent_id, priority, deadline_at,
|
|
@@ -164,6 +240,24 @@ var GoalStore = class {
|
|
|
164
240
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(goal.id, goal.title, goal.description ?? null, goal.status, goal.agentId, goal.priority, goal.deadlineAt ?? null, goal.createdAt, goal.updatedAt, goal.activeSessionKey ?? null, goal.judgeModelRef ?? null, goal.maxTurns, goal.turnsUsed, goal.uiLocale ?? null, goal.source, goal.projectId ?? null);
|
|
165
241
|
if (goal.activeSessionKey) db.prepare(`INSERT OR REPLACE INTO goal_session_links (goal_id, session_key, linked_at)
|
|
166
242
|
VALUES (?, ?, ?)`).run(goal.id, goal.activeSessionKey, now);
|
|
243
|
+
if (contract) {
|
|
244
|
+
insertGoalContract(db, contract);
|
|
245
|
+
syncEvidenceRequirements(db, goal.id, contract.evidencePlan, now);
|
|
246
|
+
for (const [index, text] of criteria.entries()) db.prepare(`INSERT INTO goal_checklist_items (
|
|
247
|
+
item_id, goal_id, text, status, added_by, added_at, sort_order
|
|
248
|
+
) VALUES (?, ?, ?, 'pending', 'user', ?, ?)`).run(randomUUID(), goal.id, text, now, index + 1);
|
|
249
|
+
insertGoalEvent(db, {
|
|
250
|
+
goalId: goal.id,
|
|
251
|
+
kind: "contract_created",
|
|
252
|
+
message: contract.objective,
|
|
253
|
+
data: {
|
|
254
|
+
version: contract.version,
|
|
255
|
+
criteriaCount: criteria.length,
|
|
256
|
+
evidenceCount: contract.evidencePlan.length
|
|
257
|
+
},
|
|
258
|
+
createdAt: now
|
|
259
|
+
});
|
|
260
|
+
}
|
|
167
261
|
insertGoalEvent(db, {
|
|
168
262
|
goalId: goal.id,
|
|
169
263
|
kind: "created",
|
|
@@ -201,6 +295,41 @@ var GoalStore = class {
|
|
|
201
295
|
const row = getSqliteDatabase().prepare(`SELECT * FROM goal_context_messages WHERE goal_id = ?`).get(goalId);
|
|
202
296
|
return row ? goalContextFromRow(row) : null;
|
|
203
297
|
}
|
|
298
|
+
getContract(goalId) {
|
|
299
|
+
const row = getSqliteDatabase().prepare(`SELECT * FROM goal_contracts WHERE goal_id = ?`).get(goalId);
|
|
300
|
+
return row ? goalContractFromRow(row) : null;
|
|
301
|
+
}
|
|
302
|
+
setContract(goalId, input) {
|
|
303
|
+
const goal = this.get(goalId);
|
|
304
|
+
if (!goal) return null;
|
|
305
|
+
return runSqliteWriteTransaction((db) => {
|
|
306
|
+
const existing = db.prepare(`SELECT * FROM goal_contracts WHERE goal_id = ?`).get(goalId);
|
|
307
|
+
const now = Date.now();
|
|
308
|
+
const contract = normalizeContract(input, goalId, goal.title, now, (existing?.version ?? 0) + 1, existing?.created_at ?? now);
|
|
309
|
+
if (!contract) return null;
|
|
310
|
+
db.prepare(`INSERT INTO goal_contracts (
|
|
311
|
+
goal_id, version, objective, scope_boundary, evidence_plan_json, created_at, updated_at
|
|
312
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
313
|
+
ON CONFLICT(goal_id) DO UPDATE SET
|
|
314
|
+
version = excluded.version,
|
|
315
|
+
objective = excluded.objective,
|
|
316
|
+
scope_boundary = excluded.scope_boundary,
|
|
317
|
+
evidence_plan_json = excluded.evidence_plan_json,
|
|
318
|
+
updated_at = excluded.updated_at`).run(contract.goalId, contract.version, contract.objective, contract.scopeBoundary ?? null, JSON.stringify(contract.evidencePlan), contract.createdAt, contract.updatedAt);
|
|
319
|
+
syncEvidenceRequirements(db, goalId, contract.evidencePlan, now);
|
|
320
|
+
insertGoalEvent(db, {
|
|
321
|
+
goalId,
|
|
322
|
+
kind: "contract_updated",
|
|
323
|
+
message: contract.objective,
|
|
324
|
+
data: {
|
|
325
|
+
version: contract.version,
|
|
326
|
+
evidenceCount: contract.evidencePlan.length
|
|
327
|
+
},
|
|
328
|
+
createdAt: now
|
|
329
|
+
});
|
|
330
|
+
return contract;
|
|
331
|
+
});
|
|
332
|
+
}
|
|
204
333
|
getActiveForSession(sessionKey) {
|
|
205
334
|
const row = getSqliteDatabase().prepare(`SELECT * FROM goals
|
|
206
335
|
WHERE active_session_key = ?
|
|
@@ -443,7 +572,67 @@ var GoalStore = class {
|
|
|
443
572
|
return evidence;
|
|
444
573
|
}
|
|
445
574
|
listEvidence(goalId, limit) {
|
|
446
|
-
|
|
575
|
+
const rows = getSqliteDatabase().prepare(`SELECT * FROM goal_evidence WHERE goal_id = ? ORDER BY created_at DESC LIMIT ?`).all(goalId, clampLimit(limit, 100));
|
|
576
|
+
const db = getSqliteDatabase();
|
|
577
|
+
return rows.map((row) => ({
|
|
578
|
+
...evidenceFromRow(row),
|
|
579
|
+
requirementIds: db.prepare(`SELECT requirement_id FROM goal_evidence_requirement_links WHERE evidence_id = ? ORDER BY requirement_id`).all(row.evidence_id).map((item) => item.requirement_id)
|
|
580
|
+
}));
|
|
581
|
+
}
|
|
582
|
+
listEvidenceRequirements(goalId) {
|
|
583
|
+
const db = getSqliteDatabase();
|
|
584
|
+
return db.prepare(`SELECT * FROM goal_evidence_requirements WHERE goal_id = ? ORDER BY sort_order ASC`).all(goalId).map((row) => evidenceRequirementFromRow(row, db.prepare(`SELECT evidence_id FROM goal_evidence_requirement_links WHERE requirement_id = ? ORDER BY created_at ASC`).all(row.requirement_id).map((item) => item.evidence_id)));
|
|
585
|
+
}
|
|
586
|
+
linkEvidenceRequirement(input) {
|
|
587
|
+
return runSqliteWriteTransaction((db) => {
|
|
588
|
+
const requirement = db.prepare(`SELECT * FROM goal_evidence_requirements WHERE requirement_id = ? AND goal_id = ?`).get(input.requirementId, input.goalId);
|
|
589
|
+
const evidence = db.prepare(`SELECT evidence_id FROM goal_evidence WHERE evidence_id = ? AND goal_id = ?`).get(input.evidenceId, input.goalId);
|
|
590
|
+
if (!requirement || !evidence) return null;
|
|
591
|
+
const now = Date.now();
|
|
592
|
+
db.prepare(`INSERT OR IGNORE INTO goal_evidence_requirement_links (requirement_id, evidence_id, linked_by, created_at)
|
|
593
|
+
VALUES (?, ?, ?, ?)`).run(input.requirementId, input.evidenceId, input.linkedBy, now);
|
|
594
|
+
db.prepare(`UPDATE goal_evidence_requirements
|
|
595
|
+
SET status = CASE WHEN status = 'rejected' THEN 'pending' ELSE status END,
|
|
596
|
+
updated_at = ?
|
|
597
|
+
WHERE requirement_id = ?`).run(now, input.requirementId);
|
|
598
|
+
insertGoalEvent(db, {
|
|
599
|
+
goalId: input.goalId,
|
|
600
|
+
kind: "evidence_requirement_linked",
|
|
601
|
+
message: requirement.text,
|
|
602
|
+
data: {
|
|
603
|
+
requirementId: input.requirementId,
|
|
604
|
+
evidenceId: input.evidenceId,
|
|
605
|
+
linkedBy: input.linkedBy
|
|
606
|
+
},
|
|
607
|
+
createdAt: now
|
|
608
|
+
});
|
|
609
|
+
const ids = db.prepare(`SELECT evidence_id FROM goal_evidence_requirement_links WHERE requirement_id = ? ORDER BY created_at ASC`).all(input.requirementId).map((item) => item.evidence_id);
|
|
610
|
+
return evidenceRequirementFromRow(db.prepare(`SELECT * FROM goal_evidence_requirements WHERE requirement_id = ?`).get(input.requirementId), ids);
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
reviewEvidenceRequirement(input) {
|
|
614
|
+
return runSqliteWriteTransaction((db) => {
|
|
615
|
+
const current = db.prepare(`SELECT * FROM goal_evidence_requirements WHERE requirement_id = ? AND goal_id = ?`).get(input.requirementId, input.goalId);
|
|
616
|
+
if (!current) return null;
|
|
617
|
+
const now = Date.now();
|
|
618
|
+
db.prepare(`UPDATE goal_evidence_requirements
|
|
619
|
+
SET status = ?, review_reason = ?, review_confidence = ?, reviewed_by = ?, reviewed_at = ?, updated_at = ?
|
|
620
|
+
WHERE requirement_id = ?`).run(input.status, input.reason.trim(), input.confidence ?? null, input.reviewedBy, now, now, input.requirementId);
|
|
621
|
+
insertGoalEvent(db, {
|
|
622
|
+
goalId: input.goalId,
|
|
623
|
+
kind: input.reviewedBy === "user" ? "evidence_requirement_approved" : "evidence_requirement_reviewed",
|
|
624
|
+
message: current.text,
|
|
625
|
+
data: {
|
|
626
|
+
requirementId: input.requirementId,
|
|
627
|
+
status: input.status,
|
|
628
|
+
reason: input.reason.trim(),
|
|
629
|
+
confidence: input.confidence
|
|
630
|
+
},
|
|
631
|
+
createdAt: now
|
|
632
|
+
});
|
|
633
|
+
const ids = db.prepare(`SELECT evidence_id FROM goal_evidence_requirement_links WHERE requirement_id = ? ORDER BY created_at ASC`).all(input.requirementId).map((item) => item.evidence_id);
|
|
634
|
+
return evidenceRequirementFromRow(db.prepare(`SELECT * FROM goal_evidence_requirements WHERE requirement_id = ?`).get(input.requirementId), ids);
|
|
635
|
+
});
|
|
447
636
|
}
|
|
448
637
|
};
|
|
449
638
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goal-store.js","names":[],"sources":["../../../src/goals/goal-store.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\n\nimport { getSqliteDatabase, runSqliteWriteTransaction } from '../storage/sqlite/transaction.js';\nimport type {\n CreateGoalInput,\n Goal,\n GoalChecklistAddedBy,\n GoalChecklistItem,\n GoalChecklistStatus,\n GoalContextAttachment,\n GoalContextMessage,\n GoalEvent,\n GoalEvidence,\n GoalListQuery,\n GoalPriority,\n GoalRun,\n GoalRunStatus,\n GoalRunVerdict,\n GoalSource,\n GoalStatus,\n} from './types.js';\n\ntype GoalRow = {\n goal_id: string;\n title: string;\n description: string | null;\n status: string;\n agent_id: string;\n priority: string;\n deadline_at: number | null;\n created_at: number;\n updated_at: number;\n completed_at: number | null;\n archived_at: number | null;\n active_session_key: string | null;\n current_run_id: string | null;\n next_action: string | null;\n blocked_reason: string | null;\n judge_model_ref: string | null;\n max_turns: number;\n turns_used: number;\n ui_locale: string | null;\n source: string;\n project_id: string | null;\n};\n\ntype ChecklistRow = {\n item_id: string;\n goal_id: string;\n text: string;\n status: string;\n added_by: string;\n added_at: number;\n completed_at: number | null;\n evidence_summary: string | null;\n sort_order: number;\n};\n\ntype GoalRunRow = {\n run_id: string;\n goal_id: string;\n session_key: string;\n source: string;\n status: string;\n started_at: number;\n finished_at: number | null;\n verdict: string | null;\n reason: string | null;\n next_action: string | null;\n assistant_preview: string | null;\n checklist_done: number | null;\n checklist_total: number | null;\n confidence: number | null;\n missing_evidence_json: string | null;\n user_question: string | null;\n completed_checklist_item_ids_json: string | null;\n};\n\ntype EventRow = {\n event_id: string;\n goal_id: string;\n run_id: string | null;\n kind: string;\n message: string;\n data_json: string | null;\n created_at: number;\n};\n\ntype EvidenceRow = {\n evidence_id: string;\n goal_id: string;\n run_id: string | null;\n kind: GoalEvidence['kind'];\n title: string;\n summary: string | null;\n uri: string | null;\n data_json: string | null;\n created_at: number;\n};\n\ntype GoalContextRow = {\n goal_id: string;\n text: string;\n attachments_json: string;\n created_at: number;\n updated_at: number;\n};\n\nfunction goalFromRow(row: GoalRow): Goal {\n return {\n id: row.goal_id,\n title: row.title,\n description: row.description ?? undefined,\n status: row.status as GoalStatus,\n agentId: row.agent_id,\n priority: row.priority as GoalPriority,\n deadlineAt: row.deadline_at ?? undefined,\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n completedAt: row.completed_at ?? undefined,\n archivedAt: row.archived_at ?? undefined,\n activeSessionKey: row.active_session_key ?? undefined,\n currentRunId: row.current_run_id ?? undefined,\n nextAction: row.next_action ?? undefined,\n blockedReason: row.blocked_reason ?? undefined,\n judgeModelRef: row.judge_model_ref ?? undefined,\n maxTurns: row.max_turns,\n turnsUsed: row.turns_used,\n uiLocale: row.ui_locale === 'en' || row.ui_locale === 'zh' ? row.ui_locale : undefined,\n source: row.source as GoalSource,\n projectId: row.project_id ?? undefined,\n };\n}\n\nfunction checklistFromRow(row: ChecklistRow): GoalChecklistItem {\n return {\n id: row.item_id,\n goalId: row.goal_id,\n text: row.text,\n status: row.status as GoalChecklistStatus,\n addedBy: row.added_by as GoalChecklistAddedBy,\n addedAt: row.added_at,\n completedAt: row.completed_at ?? undefined,\n evidenceSummary: row.evidence_summary ?? undefined,\n sortOrder: row.sort_order,\n };\n}\n\nfunction runFromRow(row: GoalRunRow): GoalRun {\n return {\n id: row.run_id,\n goalId: row.goal_id,\n sessionKey: row.session_key,\n source: row.source as GoalSource,\n status: row.status as GoalRunStatus,\n startedAt: row.started_at,\n finishedAt: row.finished_at ?? undefined,\n verdict: row.verdict ? (row.verdict as GoalRunVerdict) : undefined,\n reason: row.reason ?? undefined,\n nextAction: row.next_action ?? undefined,\n assistantPreview: row.assistant_preview ?? undefined,\n checklistProgress:\n row.checklist_done != null && row.checklist_total != null\n ? { done: row.checklist_done, total: row.checklist_total }\n : undefined,\n confidence: row.confidence ?? undefined,\n missingEvidence: parseJsonStringArray(row.missing_evidence_json),\n userQuestion: row.user_question ?? undefined,\n completedChecklistItemIds: parseJsonStringArray(row.completed_checklist_item_ids_json),\n };\n}\n\nfunction parseJsonField(raw: string | null): unknown {\n if (!raw) return undefined;\n try {\n return JSON.parse(raw) as unknown;\n } catch {\n return undefined;\n }\n}\n\nfunction parseJsonStringArray(raw: string | null): string[] | undefined {\n const value = parseJsonField(raw);\n if (!Array.isArray(value)) return undefined;\n const rows = value.filter((item): item is string => typeof item === 'string' && item.trim().length > 0);\n return rows.length ? rows : undefined;\n}\n\nfunction parseGoalContextAttachments(raw: string): GoalContextAttachment[] {\n const parsed = parseJsonField(raw);\n if (!Array.isArray(parsed)) return [];\n return parsed.filter((item): item is GoalContextAttachment => {\n if (!item || typeof item !== 'object') return false;\n const ref = item as Partial<GoalContextAttachment>;\n return (\n typeof ref.id === 'string' &&\n (ref.bucket === 'inbound' || ref.bucket === 'tts' || ref.bucket === 'outbound' || ref.bucket === 'work-item') &&\n typeof ref.type === 'string' &&\n typeof ref.mimeType === 'string' &&\n typeof ref.name === 'string' &&\n typeof ref.size === 'number' &&\n typeof ref.uri === 'string' &&\n typeof ref.path === 'string'\n );\n });\n}\n\nfunction goalContextFromRow(row: GoalContextRow): GoalContextMessage {\n return {\n goalId: row.goal_id,\n text: row.text,\n attachments: parseGoalContextAttachments(row.attachments_json),\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n}\n\nfunction eventFromRow(row: EventRow): GoalEvent {\n return {\n id: row.event_id,\n goalId: row.goal_id,\n runId: row.run_id ?? undefined,\n kind: row.kind,\n message: row.message,\n data: parseJsonField(row.data_json),\n createdAt: row.created_at,\n };\n}\n\nfunction evidenceFromRow(row: EvidenceRow): GoalEvidence {\n return {\n id: row.evidence_id,\n goalId: row.goal_id,\n runId: row.run_id ?? undefined,\n kind: row.kind,\n title: row.title,\n summary: row.summary ?? undefined,\n uri: row.uri ?? undefined,\n data: parseJsonField(row.data_json),\n createdAt: row.created_at,\n };\n}\n\nfunction clampLimit(n: number | undefined, fallback: number): number {\n return Math.min(500, Math.max(1, Math.floor(n ?? fallback)));\n}\n\nfunction insertGoalEvent(db: ReturnType<typeof getSqliteDatabase>, input: {\n goalId: string;\n runId?: string;\n kind: string;\n message: string;\n data?: unknown;\n createdAt?: number;\n}): GoalEvent {\n const event: GoalEvent = {\n id: randomUUID(),\n goalId: input.goalId,\n runId: input.runId,\n kind: input.kind,\n message: input.message,\n data: input.data,\n createdAt: input.createdAt ?? Date.now(),\n };\n db.prepare(\n `INSERT INTO goal_events (event_id, goal_id, run_id, kind, message, data_json, created_at)\n VALUES (?, ?, ?, ?, ?, ?, ?)`,\n ).run(\n event.id,\n event.goalId,\n event.runId ?? null,\n event.kind,\n event.message,\n event.data === undefined ? null : JSON.stringify(event.data),\n event.createdAt,\n );\n return event;\n}\n\nexport class GoalStore {\n create(input: CreateGoalInput): Goal {\n const now = Date.now();\n const goal: Goal = {\n id: randomUUID(),\n title: input.title.trim(),\n description: input.description?.trim() || undefined,\n status: 'active',\n agentId: input.agentId,\n priority: input.priority ?? 'normal',\n deadlineAt: input.deadlineAt,\n createdAt: now,\n updatedAt: now,\n activeSessionKey: input.sessionKey,\n judgeModelRef: input.judgeModelRef?.trim() || undefined,\n maxTurns: Math.max(1, Math.min(500, Math.floor(input.maxTurns))),\n turnsUsed: 0,\n uiLocale: input.uiLocale,\n source: input.source ?? 'chat',\n projectId: input.projectId?.trim() || undefined,\n };\n\n runSqliteWriteTransaction((db) => {\n db.prepare(\n `INSERT INTO goals (\n goal_id, title, description, status, agent_id, priority, deadline_at,\n created_at, updated_at, active_session_key, judge_model_ref,\n max_turns, turns_used, ui_locale, source, project_id\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n ).run(\n goal.id,\n goal.title,\n goal.description ?? null,\n goal.status,\n goal.agentId,\n goal.priority,\n goal.deadlineAt ?? null,\n goal.createdAt,\n goal.updatedAt,\n goal.activeSessionKey ?? null,\n goal.judgeModelRef ?? null,\n goal.maxTurns,\n goal.turnsUsed,\n goal.uiLocale ?? null,\n goal.source,\n goal.projectId ?? null,\n );\n if (goal.activeSessionKey) {\n db.prepare(\n `INSERT OR REPLACE INTO goal_session_links (goal_id, session_key, linked_at)\n VALUES (?, ?, ?)`,\n ).run(goal.id, goal.activeSessionKey, now);\n }\n insertGoalEvent(db, { goalId: goal.id, kind: 'created', message: 'Goal created', createdAt: now });\n });\n\n return goal;\n }\n\n get(goalId: string): Goal | null {\n const row = getSqliteDatabase()\n .prepare(`SELECT * FROM goals WHERE goal_id = ?`)\n .get(goalId) as GoalRow | undefined;\n return row ? goalFromRow(row) : null;\n }\n\n setContextMessage(input: {\n goalId: string;\n text: string;\n attachments?: GoalContextAttachment[];\n }): GoalContextMessage {\n return runSqliteWriteTransaction((db) => {\n const now = Date.now();\n const existing = db\n .prepare(`SELECT created_at FROM goal_context_messages WHERE goal_id = ?`)\n .get(input.goalId) as { created_at: number } | undefined;\n db.prepare(\n `INSERT INTO goal_context_messages (goal_id, text, attachments_json, created_at, updated_at)\n VALUES (?, ?, ?, ?, ?)\n ON CONFLICT(goal_id) DO UPDATE SET\n text = excluded.text,\n attachments_json = excluded.attachments_json,\n updated_at = excluded.updated_at`,\n ).run(\n input.goalId,\n input.text.trim(),\n JSON.stringify(input.attachments ?? []),\n existing?.created_at ?? now,\n now,\n );\n insertGoalEvent(db, {\n goalId: input.goalId,\n kind: 'context_updated',\n message: input.text.trim() || `${input.attachments?.length ?? 0} attachment(s)`,\n data: { attachmentCount: input.attachments?.length ?? 0 },\n createdAt: now,\n });\n const row = db\n .prepare(`SELECT * FROM goal_context_messages WHERE goal_id = ?`)\n .get(input.goalId) as GoalContextRow;\n return goalContextFromRow(row);\n });\n }\n\n getContextMessage(goalId: string): GoalContextMessage | null {\n const row = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_context_messages WHERE goal_id = ?`)\n .get(goalId) as GoalContextRow | undefined;\n return row ? goalContextFromRow(row) : null;\n }\n\n getActiveForSession(sessionKey: string): Goal | null {\n const row = getSqliteDatabase()\n .prepare(\n `SELECT * FROM goals\n WHERE active_session_key = ?\n AND status IN ('active', 'paused', 'blocked', 'needs_input', 'done')\n ORDER BY updated_at DESC\n LIMIT 1`,\n )\n .get(sessionKey) as GoalRow | undefined;\n return row ? goalFromRow(row) : null;\n }\n\n list(query: GoalListQuery = {}): Goal[] {\n const conditions: string[] = [];\n const params: Array<string | number> = [];\n if (query.status) {\n const statuses = Array.isArray(query.status) ? query.status : [query.status];\n conditions.push(`status IN (${statuses.map(() => '?').join(', ')})`);\n params.push(...statuses);\n }\n if (query.agentId) {\n conditions.push(`agent_id = ?`);\n params.push(query.agentId);\n }\n if (query.sessionKey) {\n conditions.push(`goal_id IN (SELECT goal_id FROM goal_session_links WHERE session_key = ?)`);\n params.push(query.sessionKey);\n }\n if (query.projectId) {\n conditions.push(`project_id = ?`);\n params.push(query.projectId);\n }\n const where = conditions.length ? `WHERE ${conditions.join(' AND ')}` : '';\n const limit = clampLimit(query.limit, 50);\n const offset = Math.max(0, Math.floor(query.offset ?? 0));\n const rows = getSqliteDatabase()\n .prepare(`SELECT * FROM goals ${where} ORDER BY updated_at DESC LIMIT ? OFFSET ?`)\n .all(...params, limit, offset) as GoalRow[];\n return rows.map(goalFromRow);\n }\n\n update(goalId: string, patch: Partial<Pick<\n Goal,\n | 'title'\n | 'description'\n | 'status'\n | 'priority'\n | 'deadlineAt'\n | 'completedAt'\n | 'archivedAt'\n | 'activeSessionKey'\n | 'currentRunId'\n | 'nextAction'\n | 'blockedReason'\n | 'judgeModelRef'\n | 'maxTurns'\n | 'turnsUsed'\n | 'uiLocale'\n | 'projectId'\n >>): Goal | null {\n const before = this.get(goalId);\n if (!before) return null;\n const next = { ...before, ...patch, updatedAt: Date.now() };\n runSqliteWriteTransaction((db) => {\n db.prepare(\n `UPDATE goals SET\n title = ?, description = ?, status = ?, priority = ?, deadline_at = ?,\n updated_at = ?, completed_at = ?, archived_at = ?, active_session_key = ?,\n current_run_id = ?, next_action = ?, blocked_reason = ?, judge_model_ref = ?,\n max_turns = ?, turns_used = ?, ui_locale = ?, project_id = ?\n WHERE goal_id = ?`,\n ).run(\n next.title,\n next.description ?? null,\n next.status,\n next.priority,\n next.deadlineAt ?? null,\n next.updatedAt,\n next.completedAt ?? null,\n next.archivedAt ?? null,\n next.activeSessionKey ?? null,\n next.currentRunId ?? null,\n next.nextAction ?? null,\n next.blockedReason ?? null,\n next.judgeModelRef ?? null,\n next.maxTurns,\n next.turnsUsed,\n next.uiLocale ?? null,\n next.projectId ?? null,\n goalId,\n );\n if (next.activeSessionKey) {\n db.prepare(\n `INSERT OR REPLACE INTO goal_session_links (goal_id, session_key, linked_at)\n VALUES (?, ?, ?)`,\n ).run(goalId, next.activeSessionKey, next.updatedAt);\n }\n });\n return this.get(goalId);\n }\n\n listChecklist(goalId: string): GoalChecklistItem[] {\n const rows = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_checklist_items WHERE goal_id = ? ORDER BY sort_order ASC, added_at ASC`)\n .all(goalId) as ChecklistRow[];\n return rows.map(checklistFromRow);\n }\n\n addChecklistItem(input: {\n goalId: string;\n text: string;\n addedBy: GoalChecklistAddedBy;\n status?: GoalChecklistStatus;\n }): GoalChecklistItem {\n return runSqliteWriteTransaction((db) => {\n const maxRow = db\n .prepare(`SELECT COALESCE(MAX(sort_order), 0) AS max_sort FROM goal_checklist_items WHERE goal_id = ?`)\n .get(input.goalId) as { max_sort: number };\n const now = Date.now();\n const item: GoalChecklistItem = {\n id: randomUUID(),\n goalId: input.goalId,\n text: input.text.trim(),\n status: input.status ?? 'pending',\n addedBy: input.addedBy,\n addedAt: now,\n sortOrder: maxRow.max_sort + 1,\n };\n db.prepare(\n `INSERT INTO goal_checklist_items (\n item_id, goal_id, text, status, added_by, added_at, sort_order\n ) VALUES (?, ?, ?, ?, ?, ?, ?)`,\n ).run(item.id, item.goalId, item.text, item.status, item.addedBy, item.addedAt, item.sortOrder);\n insertGoalEvent(db, {\n goalId: input.goalId,\n kind: 'checklist_added',\n message: item.text,\n data: { itemId: item.id, addedBy: item.addedBy },\n createdAt: now,\n });\n return item;\n });\n }\n\n updateChecklistItem(\n itemId: string,\n patch: Partial<Pick<GoalChecklistItem, 'text' | 'status' | 'evidenceSummary'>>,\n ): GoalChecklistItem | null {\n return runSqliteWriteTransaction((db) => {\n const row = db\n .prepare(`SELECT * FROM goal_checklist_items WHERE item_id = ?`)\n .get(itemId) as ChecklistRow | undefined;\n if (!row) return null;\n const before = checklistFromRow(row);\n const status = patch.status ?? before.status;\n const completedAt =\n status === 'completed' || status === 'impossible'\n ? (before.completedAt ?? Date.now())\n : null;\n db.prepare(\n `UPDATE goal_checklist_items SET text = ?, status = ?, completed_at = ?, evidence_summary = ?\n WHERE item_id = ?`,\n ).run(\n patch.text?.trim() || before.text,\n status,\n completedAt,\n patch.evidenceSummary ?? before.evidenceSummary ?? null,\n itemId,\n );\n insertGoalEvent(db, {\n goalId: before.goalId,\n kind: 'checklist_updated',\n message: patch.text?.trim() || before.text,\n data: { itemId, status },\n });\n const next = db\n .prepare(`SELECT * FROM goal_checklist_items WHERE item_id = ?`)\n .get(itemId) as ChecklistRow;\n return checklistFromRow(next);\n });\n }\n\n removeChecklistItem(itemId: string): boolean {\n return runSqliteWriteTransaction((db) => {\n const row = db\n .prepare(`SELECT goal_id, text FROM goal_checklist_items WHERE item_id = ?`)\n .get(itemId) as { goal_id: string; text: string } | undefined;\n if (!row) return false;\n db.prepare(`DELETE FROM goal_checklist_items WHERE item_id = ?`).run(itemId);\n insertGoalEvent(db, {\n goalId: row.goal_id,\n kind: 'checklist_removed',\n message: row.text,\n data: { itemId },\n });\n return true;\n });\n }\n\n clearChecklist(goalId: string): void {\n runSqliteWriteTransaction((db) => {\n db.prepare(`DELETE FROM goal_checklist_items WHERE goal_id = ?`).run(goalId);\n insertGoalEvent(db, { goalId, kind: 'checklist_cleared', message: 'Checklist cleared' });\n });\n }\n\n replaceChecklist(goalId: string, items: Array<{\n text: string;\n status: GoalChecklistStatus;\n addedBy: GoalChecklistAddedBy;\n addedAt?: number;\n completedAt?: number;\n evidenceSummary?: string;\n }>): GoalChecklistItem[] {\n return runSqliteWriteTransaction((db) => {\n db.prepare(`DELETE FROM goal_checklist_items WHERE goal_id = ?`).run(goalId);\n const now = Date.now();\n const next: GoalChecklistItem[] = [];\n for (let i = 0; i < items.length; i++) {\n const raw = items[i]!;\n const item: GoalChecklistItem = {\n id: randomUUID(),\n goalId,\n text: raw.text.trim(),\n status: raw.status,\n addedBy: raw.addedBy,\n addedAt: raw.addedAt ?? now,\n completedAt: raw.completedAt,\n evidenceSummary: raw.evidenceSummary,\n sortOrder: i + 1,\n };\n if (!item.text) continue;\n db.prepare(\n `INSERT INTO goal_checklist_items (\n item_id, goal_id, text, status, added_by, added_at, completed_at, evidence_summary, sort_order\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n ).run(\n item.id,\n item.goalId,\n item.text,\n item.status,\n item.addedBy,\n item.addedAt,\n item.completedAt ?? null,\n item.evidenceSummary ?? null,\n item.sortOrder,\n );\n next.push(item);\n }\n insertGoalEvent(db, {\n goalId,\n kind: 'checklist_replaced',\n message: `Checklist replaced (${next.length} items)`,\n });\n return next;\n });\n }\n\n appendRun(run: Omit<GoalRun, 'id' | 'startedAt'> & { id?: string; startedAt?: number }): GoalRun {\n const record: GoalRun = {\n id: run.id ?? randomUUID(),\n goalId: run.goalId,\n sessionKey: run.sessionKey,\n source: run.source,\n status: run.status,\n startedAt: run.startedAt ?? Date.now(),\n finishedAt: run.finishedAt,\n verdict: run.verdict,\n reason: run.reason,\n nextAction: run.nextAction,\n assistantPreview: run.assistantPreview,\n checklistProgress: run.checklistProgress,\n };\n runSqliteWriteTransaction((db) => {\n db.prepare(\n `INSERT INTO goal_runs (\n run_id, goal_id, session_key, source, status, started_at, finished_at,\n verdict, reason, next_action, assistant_preview, checklist_done, checklist_total,\n confidence, missing_evidence_json, user_question, completed_checklist_item_ids_json\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n ).run(\n record.id,\n record.goalId,\n record.sessionKey,\n record.source,\n record.status,\n record.startedAt,\n record.finishedAt ?? null,\n record.verdict ?? null,\n record.reason ?? null,\n record.nextAction ?? null,\n record.assistantPreview ?? null,\n record.checklistProgress?.done ?? null,\n record.checklistProgress?.total ?? null,\n record.confidence ?? null,\n record.missingEvidence ? JSON.stringify(record.missingEvidence) : null,\n record.userQuestion ?? null,\n record.completedChecklistItemIds ? JSON.stringify(record.completedChecklistItemIds) : null,\n );\n db.prepare(`UPDATE goals SET current_run_id = ?, updated_at = ? WHERE goal_id = ?`).run(\n record.id,\n record.finishedAt ?? record.startedAt,\n record.goalId,\n );\n insertGoalEvent(db, {\n goalId: record.goalId,\n runId: record.id,\n kind: 'run_recorded',\n message: record.reason ?? record.status,\n data: {\n verdict: record.verdict,\n status: record.status,\n confidence: record.confidence,\n missingEvidence: record.missingEvidence,\n userQuestion: record.userQuestion,\n completedChecklistItemIds: record.completedChecklistItemIds,\n },\n createdAt: record.finishedAt ?? record.startedAt,\n });\n });\n return record;\n }\n\n listRuns(goalId: string, limit?: number): GoalRun[] {\n const rows = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_runs WHERE goal_id = ? ORDER BY started_at DESC LIMIT ?`)\n .all(goalId, clampLimit(limit, 50)) as GoalRunRow[];\n return rows.map(runFromRow);\n }\n\n listRunsForSession(sessionKey: string, limit?: number): GoalRun[] {\n const rows = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_runs WHERE session_key = ? ORDER BY started_at DESC LIMIT ?`)\n .all(sessionKey, clampLimit(limit, 50)) as GoalRunRow[];\n return rows.map(runFromRow);\n }\n\n listEvents(goalId: string, limit?: number): GoalEvent[] {\n const rows = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_events WHERE goal_id = ? ORDER BY created_at DESC LIMIT ?`)\n .all(goalId, clampLimit(limit, 100)) as EventRow[];\n return rows.map(eventFromRow);\n }\n\n addEvidence(input: Omit<GoalEvidence, 'id' | 'createdAt'> & { id?: string; createdAt?: number }): GoalEvidence {\n const evidence: GoalEvidence = {\n id: input.id ?? randomUUID(),\n goalId: input.goalId,\n runId: input.runId,\n kind: input.kind,\n title: input.title,\n summary: input.summary,\n uri: input.uri,\n data: input.data,\n createdAt: input.createdAt ?? Date.now(),\n };\n runSqliteWriteTransaction((db) => {\n db.prepare(\n `INSERT INTO goal_evidence (\n evidence_id, goal_id, run_id, kind, title, summary, uri, data_json, created_at\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n ).run(\n evidence.id,\n evidence.goalId,\n evidence.runId ?? null,\n evidence.kind,\n evidence.title,\n evidence.summary ?? null,\n evidence.uri ?? null,\n evidence.data === undefined ? null : JSON.stringify(evidence.data),\n evidence.createdAt,\n );\n insertGoalEvent(db, {\n goalId: evidence.goalId,\n runId: evidence.runId,\n kind: 'evidence_added',\n message: evidence.title,\n data: { evidenceId: evidence.id, kind: evidence.kind },\n createdAt: evidence.createdAt,\n });\n });\n return evidence;\n }\n\n listEvidence(goalId: string, limit?: number): GoalEvidence[] {\n const rows = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_evidence WHERE goal_id = ? ORDER BY created_at DESC LIMIT ?`)\n .all(goalId, clampLimit(limit, 100)) as EvidenceRow[];\n return rows.map(evidenceFromRow);\n }\n}\n"],"mappings":";;;AA4GA,SAAS,YAAY,KAAoB;AACvC,QAAO;EACL,IAAI,IAAI;EACR,OAAO,IAAI;EACX,aAAa,IAAI,eAAe,KAAA;EAChC,QAAQ,IAAI;EACZ,SAAS,IAAI;EACb,UAAU,I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AQ,SAAS;IACjB,OAAO,SAAS;IAChB,MAAM;IACN,SAAS,SAAS;IAClB,MAAM;KAAE,YAAY,SAAS;KAAI,MAAM,SAAS;KAAM;IACtD,WAAW,SAAS;IACrB,CAAC;IACF;AACF,SAAO;;CAGT,aAAa,QAAgB,OAAgC;AAI3D,SAHa,mBAAmB,CAC7B,QAAQ,iFAAiF,CACzF,IAAI,QAAQ,WAAW,OAAO,IAAI,CAC1B,CAAC,IAAI,gBAAgB"}
|
|
1
|
+
{"version":3,"file":"goal-store.js","names":[],"sources":["../../../src/goals/goal-store.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\n\nimport { getSqliteDatabase, runSqliteWriteTransaction } from '../storage/sqlite/transaction.js';\nimport type {\n CreateGoalInput,\n Goal,\n GoalChecklistAddedBy,\n GoalChecklistItem,\n GoalChecklistStatus,\n GoalContextAttachment,\n GoalContextMessage,\n GoalContract,\n GoalContractInput,\n GoalEvent,\n GoalEvidence,\n GoalEvidenceRequirement,\n GoalEvidenceRequirementStatus,\n GoalEvidenceReviewSource,\n GoalListQuery,\n GoalPriority,\n GoalRun,\n GoalRunStatus,\n GoalRunVerdict,\n GoalSource,\n GoalStatus,\n} from './types.js';\n\ntype GoalRow = {\n goal_id: string;\n title: string;\n description: string | null;\n status: string;\n agent_id: string;\n priority: string;\n deadline_at: number | null;\n created_at: number;\n updated_at: number;\n completed_at: number | null;\n archived_at: number | null;\n active_session_key: string | null;\n current_run_id: string | null;\n next_action: string | null;\n blocked_reason: string | null;\n judge_model_ref: string | null;\n max_turns: number;\n turns_used: number;\n ui_locale: string | null;\n source: string;\n project_id: string | null;\n};\n\ntype ChecklistRow = {\n item_id: string;\n goal_id: string;\n text: string;\n status: string;\n added_by: string;\n added_at: number;\n completed_at: number | null;\n evidence_summary: string | null;\n sort_order: number;\n};\n\ntype GoalRunRow = {\n run_id: string;\n goal_id: string;\n session_key: string;\n source: string;\n status: string;\n started_at: number;\n finished_at: number | null;\n verdict: string | null;\n reason: string | null;\n next_action: string | null;\n assistant_preview: string | null;\n checklist_done: number | null;\n checklist_total: number | null;\n confidence: number | null;\n missing_evidence_json: string | null;\n user_question: string | null;\n completed_checklist_item_ids_json: string | null;\n};\n\ntype EventRow = {\n event_id: string;\n goal_id: string;\n run_id: string | null;\n kind: string;\n message: string;\n data_json: string | null;\n created_at: number;\n};\n\ntype EvidenceRow = {\n evidence_id: string;\n goal_id: string;\n run_id: string | null;\n kind: GoalEvidence['kind'];\n title: string;\n summary: string | null;\n uri: string | null;\n data_json: string | null;\n created_at: number;\n};\n\ntype GoalContextRow = {\n goal_id: string;\n text: string;\n attachments_json: string;\n created_at: number;\n updated_at: number;\n};\n\ntype GoalContractRow = {\n goal_id: string;\n version: number;\n objective: string;\n scope_boundary: string | null;\n evidence_plan_json: string;\n created_at: number;\n updated_at: number;\n};\n\ntype GoalEvidenceRequirementRow = {\n requirement_id: string;\n goal_id: string;\n text: string;\n status: GoalEvidenceRequirementStatus;\n review_reason: string | null;\n review_confidence: number | null;\n reviewed_by: GoalEvidenceReviewSource | null;\n reviewed_at: number | null;\n requires_human_approval: number;\n created_at: number;\n updated_at: number;\n sort_order: number;\n};\n\nfunction goalFromRow(row: GoalRow): Goal {\n return {\n id: row.goal_id,\n title: row.title,\n description: row.description ?? undefined,\n status: row.status as GoalStatus,\n agentId: row.agent_id,\n priority: row.priority as GoalPriority,\n deadlineAt: row.deadline_at ?? undefined,\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n completedAt: row.completed_at ?? undefined,\n archivedAt: row.archived_at ?? undefined,\n activeSessionKey: row.active_session_key ?? undefined,\n currentRunId: row.current_run_id ?? undefined,\n nextAction: row.next_action ?? undefined,\n blockedReason: row.blocked_reason ?? undefined,\n judgeModelRef: row.judge_model_ref ?? undefined,\n maxTurns: row.max_turns,\n turnsUsed: row.turns_used,\n uiLocale: row.ui_locale === 'en' || row.ui_locale === 'zh' ? row.ui_locale : undefined,\n source: row.source as GoalSource,\n projectId: row.project_id ?? undefined,\n };\n}\n\nfunction checklistFromRow(row: ChecklistRow): GoalChecklistItem {\n return {\n id: row.item_id,\n goalId: row.goal_id,\n text: row.text,\n status: row.status as GoalChecklistStatus,\n addedBy: row.added_by as GoalChecklistAddedBy,\n addedAt: row.added_at,\n completedAt: row.completed_at ?? undefined,\n evidenceSummary: row.evidence_summary ?? undefined,\n sortOrder: row.sort_order,\n };\n}\n\nfunction runFromRow(row: GoalRunRow): GoalRun {\n return {\n id: row.run_id,\n goalId: row.goal_id,\n sessionKey: row.session_key,\n source: row.source as GoalSource,\n status: row.status as GoalRunStatus,\n startedAt: row.started_at,\n finishedAt: row.finished_at ?? undefined,\n verdict: row.verdict ? (row.verdict as GoalRunVerdict) : undefined,\n reason: row.reason ?? undefined,\n nextAction: row.next_action ?? undefined,\n assistantPreview: row.assistant_preview ?? undefined,\n checklistProgress:\n row.checklist_done != null && row.checklist_total != null\n ? { done: row.checklist_done, total: row.checklist_total }\n : undefined,\n confidence: row.confidence ?? undefined,\n missingEvidence: parseJsonStringArray(row.missing_evidence_json),\n userQuestion: row.user_question ?? undefined,\n completedChecklistItemIds: parseJsonStringArray(row.completed_checklist_item_ids_json),\n };\n}\n\nfunction parseJsonField(raw: string | null): unknown {\n if (!raw) return undefined;\n try {\n return JSON.parse(raw) as unknown;\n } catch {\n return undefined;\n }\n}\n\nfunction parseJsonStringArray(raw: string | null): string[] | undefined {\n const value = parseJsonField(raw);\n if (!Array.isArray(value)) return undefined;\n const rows = value.filter((item): item is string => typeof item === 'string' && item.trim().length > 0);\n return rows.length ? rows : undefined;\n}\n\nfunction parseGoalContextAttachments(raw: string): GoalContextAttachment[] {\n const parsed = parseJsonField(raw);\n if (!Array.isArray(parsed)) return [];\n return parsed.filter((item): item is GoalContextAttachment => {\n if (!item || typeof item !== 'object') return false;\n const ref = item as Partial<GoalContextAttachment>;\n return (\n typeof ref.id === 'string' &&\n (ref.bucket === 'inbound' || ref.bucket === 'tts' || ref.bucket === 'outbound' || ref.bucket === 'work-item') &&\n typeof ref.type === 'string' &&\n typeof ref.mimeType === 'string' &&\n typeof ref.name === 'string' &&\n typeof ref.size === 'number' &&\n typeof ref.uri === 'string' &&\n typeof ref.path === 'string'\n );\n });\n}\n\nfunction goalContextFromRow(row: GoalContextRow): GoalContextMessage {\n return {\n goalId: row.goal_id,\n text: row.text,\n attachments: parseGoalContextAttachments(row.attachments_json),\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n}\n\nfunction goalContractFromRow(row: GoalContractRow): GoalContract {\n return {\n goalId: row.goal_id,\n version: row.version,\n objective: row.objective,\n scopeBoundary: row.scope_boundary ?? undefined,\n evidencePlan: parseJsonStringArray(row.evidence_plan_json) ?? [],\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n };\n}\n\nfunction normalizeStringList(items: string[] | undefined, limit = 20): string[] {\n if (!items) return [];\n const seen = new Set<string>();\n const result: string[] = [];\n for (const item of items) {\n const text = item.trim();\n const key = text.toLocaleLowerCase();\n if (!text || seen.has(key)) continue;\n seen.add(key);\n result.push(text);\n if (result.length >= limit) break;\n }\n return result;\n}\n\nfunction normalizeContract(\n input: GoalContractInput | undefined,\n goalId: string,\n fallbackObjective: string,\n now: number,\n version = 1,\n createdAt = now,\n): GoalContract | undefined {\n if (!input) return undefined;\n return {\n goalId,\n version,\n objective: input.objective?.trim() || fallbackObjective,\n scopeBoundary: input.scopeBoundary?.trim() || undefined,\n evidencePlan: normalizeStringList(input.evidencePlan),\n createdAt,\n updatedAt: now,\n };\n}\n\nfunction insertGoalContract(db: ReturnType<typeof getSqliteDatabase>, contract: GoalContract): void {\n db.prepare(\n `INSERT INTO goal_contracts (\n goal_id, version, objective, scope_boundary, evidence_plan_json, created_at, updated_at\n ) VALUES (?, ?, ?, ?, ?, ?, ?)`,\n ).run(\n contract.goalId,\n contract.version,\n contract.objective,\n contract.scopeBoundary ?? null,\n JSON.stringify(contract.evidencePlan),\n contract.createdAt,\n contract.updatedAt,\n );\n}\n\nfunction eventFromRow(row: EventRow): GoalEvent {\n return {\n id: row.event_id,\n goalId: row.goal_id,\n runId: row.run_id ?? undefined,\n kind: row.kind,\n message: row.message,\n data: parseJsonField(row.data_json),\n createdAt: row.created_at,\n };\n}\n\nfunction evidenceFromRow(row: EvidenceRow): GoalEvidence {\n return {\n id: row.evidence_id,\n goalId: row.goal_id,\n runId: row.run_id ?? undefined,\n kind: row.kind,\n title: row.title,\n summary: row.summary ?? undefined,\n uri: row.uri ?? undefined,\n data: parseJsonField(row.data_json),\n createdAt: row.created_at,\n };\n}\n\nfunction evidenceRequirementFromRow(row: GoalEvidenceRequirementRow, evidenceIds: string[] = []): GoalEvidenceRequirement {\n return {\n id: row.requirement_id,\n goalId: row.goal_id,\n text: row.text,\n status: row.status,\n evidenceIds,\n reviewReason: row.review_reason ?? undefined,\n reviewConfidence: row.review_confidence ?? undefined,\n reviewedBy: row.reviewed_by ?? undefined,\n reviewedAt: row.reviewed_at ?? undefined,\n requiresHumanApproval: Boolean(row.requires_human_approval),\n createdAt: row.created_at,\n updatedAt: row.updated_at,\n sortOrder: row.sort_order,\n };\n}\n\nfunction syncEvidenceRequirements(\n db: ReturnType<typeof getSqliteDatabase>,\n goalId: string,\n evidencePlan: string[],\n now: number,\n): void {\n const existing = db\n .prepare(`SELECT * FROM goal_evidence_requirements WHERE goal_id = ?`)\n .all(goalId) as GoalEvidenceRequirementRow[];\n const byText = new Map(existing.map((item) => [item.text.toLocaleLowerCase(), item]));\n const desired = new Set(evidencePlan.map((text) => text.toLocaleLowerCase()));\n for (const item of existing) {\n if (!desired.has(item.text.toLocaleLowerCase())) {\n db.prepare(`DELETE FROM goal_evidence_requirements WHERE requirement_id = ?`).run(item.requirement_id);\n }\n }\n for (const [index, text] of evidencePlan.entries()) {\n const current = byText.get(text.toLocaleLowerCase());\n if (current) {\n db.prepare(\n `UPDATE goal_evidence_requirements\n SET text = ?, sort_order = ?, updated_at = ?\n WHERE requirement_id = ?`,\n ).run(text, index + 1, now, current.requirement_id);\n } else {\n db.prepare(\n `INSERT INTO goal_evidence_requirements (\n requirement_id, goal_id, text, status, requires_human_approval, created_at, updated_at, sort_order\n ) VALUES (?, ?, ?, 'pending', 1, ?, ?, ?)`,\n ).run(randomUUID(), goalId, text, now, now, index + 1);\n }\n }\n}\n\nfunction clampLimit(n: number | undefined, fallback: number): number {\n return Math.min(500, Math.max(1, Math.floor(n ?? fallback)));\n}\n\nfunction insertGoalEvent(db: ReturnType<typeof getSqliteDatabase>, input: {\n goalId: string;\n runId?: string;\n kind: string;\n message: string;\n data?: unknown;\n createdAt?: number;\n}): GoalEvent {\n const event: GoalEvent = {\n id: randomUUID(),\n goalId: input.goalId,\n runId: input.runId,\n kind: input.kind,\n message: input.message,\n data: input.data,\n createdAt: input.createdAt ?? Date.now(),\n };\n db.prepare(\n `INSERT INTO goal_events (event_id, goal_id, run_id, kind, message, data_json, created_at)\n VALUES (?, ?, ?, ?, ?, ?, ?)`,\n ).run(\n event.id,\n event.goalId,\n event.runId ?? null,\n event.kind,\n event.message,\n event.data === undefined ? null : JSON.stringify(event.data),\n event.createdAt,\n );\n return event;\n}\n\nexport class GoalStore {\n create(input: CreateGoalInput): Goal {\n const now = Date.now();\n const goal: Goal = {\n id: randomUUID(),\n title: input.title.trim(),\n description: input.description?.trim() || undefined,\n status: 'active',\n agentId: input.agentId,\n priority: input.priority ?? 'normal',\n deadlineAt: input.deadlineAt,\n createdAt: now,\n updatedAt: now,\n activeSessionKey: input.sessionKey,\n judgeModelRef: input.judgeModelRef?.trim() || undefined,\n maxTurns: Math.max(1, Math.min(500, Math.floor(input.maxTurns))),\n turnsUsed: 0,\n uiLocale: input.uiLocale,\n source: input.source ?? 'chat',\n projectId: input.projectId?.trim() || undefined,\n };\n const contract = normalizeContract(input.contract, goal.id, goal.title, now);\n const criteria = normalizeStringList(input.contract?.criteria);\n\n runSqliteWriteTransaction((db) => {\n db.prepare(\n `INSERT INTO goals (\n goal_id, title, description, status, agent_id, priority, deadline_at,\n created_at, updated_at, active_session_key, judge_model_ref,\n max_turns, turns_used, ui_locale, source, project_id\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n ).run(\n goal.id,\n goal.title,\n goal.description ?? null,\n goal.status,\n goal.agentId,\n goal.priority,\n goal.deadlineAt ?? null,\n goal.createdAt,\n goal.updatedAt,\n goal.activeSessionKey ?? null,\n goal.judgeModelRef ?? null,\n goal.maxTurns,\n goal.turnsUsed,\n goal.uiLocale ?? null,\n goal.source,\n goal.projectId ?? null,\n );\n if (goal.activeSessionKey) {\n db.prepare(\n `INSERT OR REPLACE INTO goal_session_links (goal_id, session_key, linked_at)\n VALUES (?, ?, ?)`,\n ).run(goal.id, goal.activeSessionKey, now);\n }\n if (contract) {\n insertGoalContract(db, contract);\n syncEvidenceRequirements(db, goal.id, contract.evidencePlan, now);\n for (const [index, text] of criteria.entries()) {\n db.prepare(\n `INSERT INTO goal_checklist_items (\n item_id, goal_id, text, status, added_by, added_at, sort_order\n ) VALUES (?, ?, ?, 'pending', 'user', ?, ?)`,\n ).run(randomUUID(), goal.id, text, now, index + 1);\n }\n insertGoalEvent(db, {\n goalId: goal.id,\n kind: 'contract_created',\n message: contract.objective,\n data: { version: contract.version, criteriaCount: criteria.length, evidenceCount: contract.evidencePlan.length },\n createdAt: now,\n });\n }\n insertGoalEvent(db, { goalId: goal.id, kind: 'created', message: 'Goal created', createdAt: now });\n });\n\n return goal;\n }\n\n get(goalId: string): Goal | null {\n const row = getSqliteDatabase()\n .prepare(`SELECT * FROM goals WHERE goal_id = ?`)\n .get(goalId) as GoalRow | undefined;\n return row ? goalFromRow(row) : null;\n }\n\n setContextMessage(input: {\n goalId: string;\n text: string;\n attachments?: GoalContextAttachment[];\n }): GoalContextMessage {\n return runSqliteWriteTransaction((db) => {\n const now = Date.now();\n const existing = db\n .prepare(`SELECT created_at FROM goal_context_messages WHERE goal_id = ?`)\n .get(input.goalId) as { created_at: number } | undefined;\n db.prepare(\n `INSERT INTO goal_context_messages (goal_id, text, attachments_json, created_at, updated_at)\n VALUES (?, ?, ?, ?, ?)\n ON CONFLICT(goal_id) DO UPDATE SET\n text = excluded.text,\n attachments_json = excluded.attachments_json,\n updated_at = excluded.updated_at`,\n ).run(\n input.goalId,\n input.text.trim(),\n JSON.stringify(input.attachments ?? []),\n existing?.created_at ?? now,\n now,\n );\n insertGoalEvent(db, {\n goalId: input.goalId,\n kind: 'context_updated',\n message: input.text.trim() || `${input.attachments?.length ?? 0} attachment(s)`,\n data: { attachmentCount: input.attachments?.length ?? 0 },\n createdAt: now,\n });\n const row = db\n .prepare(`SELECT * FROM goal_context_messages WHERE goal_id = ?`)\n .get(input.goalId) as GoalContextRow;\n return goalContextFromRow(row);\n });\n }\n\n getContextMessage(goalId: string): GoalContextMessage | null {\n const row = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_context_messages WHERE goal_id = ?`)\n .get(goalId) as GoalContextRow | undefined;\n return row ? goalContextFromRow(row) : null;\n }\n\n getContract(goalId: string): GoalContract | null {\n const row = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_contracts WHERE goal_id = ?`)\n .get(goalId) as GoalContractRow | undefined;\n return row ? goalContractFromRow(row) : null;\n }\n\n setContract(goalId: string, input: GoalContractInput): GoalContract | null {\n const goal = this.get(goalId);\n if (!goal) return null;\n return runSqliteWriteTransaction((db) => {\n const existing = db\n .prepare(`SELECT * FROM goal_contracts WHERE goal_id = ?`)\n .get(goalId) as GoalContractRow | undefined;\n const now = Date.now();\n const contract = normalizeContract(\n input,\n goalId,\n goal.title,\n now,\n (existing?.version ?? 0) + 1,\n existing?.created_at ?? now,\n );\n if (!contract) return null;\n db.prepare(\n `INSERT INTO goal_contracts (\n goal_id, version, objective, scope_boundary, evidence_plan_json, created_at, updated_at\n ) VALUES (?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(goal_id) DO UPDATE SET\n version = excluded.version,\n objective = excluded.objective,\n scope_boundary = excluded.scope_boundary,\n evidence_plan_json = excluded.evidence_plan_json,\n updated_at = excluded.updated_at`,\n ).run(\n contract.goalId,\n contract.version,\n contract.objective,\n contract.scopeBoundary ?? null,\n JSON.stringify(contract.evidencePlan),\n contract.createdAt,\n contract.updatedAt,\n );\n syncEvidenceRequirements(db, goalId, contract.evidencePlan, now);\n insertGoalEvent(db, {\n goalId,\n kind: 'contract_updated',\n message: contract.objective,\n data: { version: contract.version, evidenceCount: contract.evidencePlan.length },\n createdAt: now,\n });\n return contract;\n });\n }\n\n getActiveForSession(sessionKey: string): Goal | null {\n const row = getSqliteDatabase()\n .prepare(\n `SELECT * FROM goals\n WHERE active_session_key = ?\n AND status IN ('active', 'paused', 'blocked', 'needs_input', 'done')\n ORDER BY updated_at DESC\n LIMIT 1`,\n )\n .get(sessionKey) as GoalRow | undefined;\n return row ? goalFromRow(row) : null;\n }\n\n list(query: GoalListQuery = {}): Goal[] {\n const conditions: string[] = [];\n const params: Array<string | number> = [];\n if (query.status) {\n const statuses = Array.isArray(query.status) ? query.status : [query.status];\n conditions.push(`status IN (${statuses.map(() => '?').join(', ')})`);\n params.push(...statuses);\n }\n if (query.agentId) {\n conditions.push(`agent_id = ?`);\n params.push(query.agentId);\n }\n if (query.sessionKey) {\n conditions.push(`goal_id IN (SELECT goal_id FROM goal_session_links WHERE session_key = ?)`);\n params.push(query.sessionKey);\n }\n if (query.projectId) {\n conditions.push(`project_id = ?`);\n params.push(query.projectId);\n }\n const where = conditions.length ? `WHERE ${conditions.join(' AND ')}` : '';\n const limit = clampLimit(query.limit, 50);\n const offset = Math.max(0, Math.floor(query.offset ?? 0));\n const rows = getSqliteDatabase()\n .prepare(`SELECT * FROM goals ${where} ORDER BY updated_at DESC LIMIT ? OFFSET ?`)\n .all(...params, limit, offset) as GoalRow[];\n return rows.map(goalFromRow);\n }\n\n update(goalId: string, patch: Partial<Pick<\n Goal,\n | 'title'\n | 'description'\n | 'status'\n | 'priority'\n | 'deadlineAt'\n | 'completedAt'\n | 'archivedAt'\n | 'activeSessionKey'\n | 'currentRunId'\n | 'nextAction'\n | 'blockedReason'\n | 'judgeModelRef'\n | 'maxTurns'\n | 'turnsUsed'\n | 'uiLocale'\n | 'projectId'\n >>): Goal | null {\n const before = this.get(goalId);\n if (!before) return null;\n const next = { ...before, ...patch, updatedAt: Date.now() };\n runSqliteWriteTransaction((db) => {\n db.prepare(\n `UPDATE goals SET\n title = ?, description = ?, status = ?, priority = ?, deadline_at = ?,\n updated_at = ?, completed_at = ?, archived_at = ?, active_session_key = ?,\n current_run_id = ?, next_action = ?, blocked_reason = ?, judge_model_ref = ?,\n max_turns = ?, turns_used = ?, ui_locale = ?, project_id = ?\n WHERE goal_id = ?`,\n ).run(\n next.title,\n next.description ?? null,\n next.status,\n next.priority,\n next.deadlineAt ?? null,\n next.updatedAt,\n next.completedAt ?? null,\n next.archivedAt ?? null,\n next.activeSessionKey ?? null,\n next.currentRunId ?? null,\n next.nextAction ?? null,\n next.blockedReason ?? null,\n next.judgeModelRef ?? null,\n next.maxTurns,\n next.turnsUsed,\n next.uiLocale ?? null,\n next.projectId ?? null,\n goalId,\n );\n if (next.activeSessionKey) {\n db.prepare(\n `INSERT OR REPLACE INTO goal_session_links (goal_id, session_key, linked_at)\n VALUES (?, ?, ?)`,\n ).run(goalId, next.activeSessionKey, next.updatedAt);\n }\n });\n return this.get(goalId);\n }\n\n listChecklist(goalId: string): GoalChecklistItem[] {\n const rows = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_checklist_items WHERE goal_id = ? ORDER BY sort_order ASC, added_at ASC`)\n .all(goalId) as ChecklistRow[];\n return rows.map(checklistFromRow);\n }\n\n addChecklistItem(input: {\n goalId: string;\n text: string;\n addedBy: GoalChecklistAddedBy;\n status?: GoalChecklistStatus;\n }): GoalChecklistItem {\n return runSqliteWriteTransaction((db) => {\n const maxRow = db\n .prepare(`SELECT COALESCE(MAX(sort_order), 0) AS max_sort FROM goal_checklist_items WHERE goal_id = ?`)\n .get(input.goalId) as { max_sort: number };\n const now = Date.now();\n const item: GoalChecklistItem = {\n id: randomUUID(),\n goalId: input.goalId,\n text: input.text.trim(),\n status: input.status ?? 'pending',\n addedBy: input.addedBy,\n addedAt: now,\n sortOrder: maxRow.max_sort + 1,\n };\n db.prepare(\n `INSERT INTO goal_checklist_items (\n item_id, goal_id, text, status, added_by, added_at, sort_order\n ) VALUES (?, ?, ?, ?, ?, ?, ?)`,\n ).run(item.id, item.goalId, item.text, item.status, item.addedBy, item.addedAt, item.sortOrder);\n insertGoalEvent(db, {\n goalId: input.goalId,\n kind: 'checklist_added',\n message: item.text,\n data: { itemId: item.id, addedBy: item.addedBy },\n createdAt: now,\n });\n return item;\n });\n }\n\n updateChecklistItem(\n itemId: string,\n patch: Partial<Pick<GoalChecklistItem, 'text' | 'status' | 'evidenceSummary'>>,\n ): GoalChecklistItem | null {\n return runSqliteWriteTransaction((db) => {\n const row = db\n .prepare(`SELECT * FROM goal_checklist_items WHERE item_id = ?`)\n .get(itemId) as ChecklistRow | undefined;\n if (!row) return null;\n const before = checklistFromRow(row);\n const status = patch.status ?? before.status;\n const completedAt =\n status === 'completed' || status === 'impossible'\n ? (before.completedAt ?? Date.now())\n : null;\n db.prepare(\n `UPDATE goal_checklist_items SET text = ?, status = ?, completed_at = ?, evidence_summary = ?\n WHERE item_id = ?`,\n ).run(\n patch.text?.trim() || before.text,\n status,\n completedAt,\n patch.evidenceSummary ?? before.evidenceSummary ?? null,\n itemId,\n );\n insertGoalEvent(db, {\n goalId: before.goalId,\n kind: 'checklist_updated',\n message: patch.text?.trim() || before.text,\n data: { itemId, status },\n });\n const next = db\n .prepare(`SELECT * FROM goal_checklist_items WHERE item_id = ?`)\n .get(itemId) as ChecklistRow;\n return checklistFromRow(next);\n });\n }\n\n removeChecklistItem(itemId: string): boolean {\n return runSqliteWriteTransaction((db) => {\n const row = db\n .prepare(`SELECT goal_id, text FROM goal_checklist_items WHERE item_id = ?`)\n .get(itemId) as { goal_id: string; text: string } | undefined;\n if (!row) return false;\n db.prepare(`DELETE FROM goal_checklist_items WHERE item_id = ?`).run(itemId);\n insertGoalEvent(db, {\n goalId: row.goal_id,\n kind: 'checklist_removed',\n message: row.text,\n data: { itemId },\n });\n return true;\n });\n }\n\n clearChecklist(goalId: string): void {\n runSqliteWriteTransaction((db) => {\n db.prepare(`DELETE FROM goal_checklist_items WHERE goal_id = ?`).run(goalId);\n insertGoalEvent(db, { goalId, kind: 'checklist_cleared', message: 'Checklist cleared' });\n });\n }\n\n replaceChecklist(goalId: string, items: Array<{\n text: string;\n status: GoalChecklistStatus;\n addedBy: GoalChecklistAddedBy;\n addedAt?: number;\n completedAt?: number;\n evidenceSummary?: string;\n }>): GoalChecklistItem[] {\n return runSqliteWriteTransaction((db) => {\n db.prepare(`DELETE FROM goal_checklist_items WHERE goal_id = ?`).run(goalId);\n const now = Date.now();\n const next: GoalChecklistItem[] = [];\n for (let i = 0; i < items.length; i++) {\n const raw = items[i]!;\n const item: GoalChecklistItem = {\n id: randomUUID(),\n goalId,\n text: raw.text.trim(),\n status: raw.status,\n addedBy: raw.addedBy,\n addedAt: raw.addedAt ?? now,\n completedAt: raw.completedAt,\n evidenceSummary: raw.evidenceSummary,\n sortOrder: i + 1,\n };\n if (!item.text) continue;\n db.prepare(\n `INSERT INTO goal_checklist_items (\n item_id, goal_id, text, status, added_by, added_at, completed_at, evidence_summary, sort_order\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n ).run(\n item.id,\n item.goalId,\n item.text,\n item.status,\n item.addedBy,\n item.addedAt,\n item.completedAt ?? null,\n item.evidenceSummary ?? null,\n item.sortOrder,\n );\n next.push(item);\n }\n insertGoalEvent(db, {\n goalId,\n kind: 'checklist_replaced',\n message: `Checklist replaced (${next.length} items)`,\n });\n return next;\n });\n }\n\n appendRun(run: Omit<GoalRun, 'id' | 'startedAt'> & { id?: string; startedAt?: number }): GoalRun {\n const record: GoalRun = {\n id: run.id ?? randomUUID(),\n goalId: run.goalId,\n sessionKey: run.sessionKey,\n source: run.source,\n status: run.status,\n startedAt: run.startedAt ?? Date.now(),\n finishedAt: run.finishedAt,\n verdict: run.verdict,\n reason: run.reason,\n nextAction: run.nextAction,\n assistantPreview: run.assistantPreview,\n checklistProgress: run.checklistProgress,\n };\n runSqliteWriteTransaction((db) => {\n db.prepare(\n `INSERT INTO goal_runs (\n run_id, goal_id, session_key, source, status, started_at, finished_at,\n verdict, reason, next_action, assistant_preview, checklist_done, checklist_total,\n confidence, missing_evidence_json, user_question, completed_checklist_item_ids_json\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n ).run(\n record.id,\n record.goalId,\n record.sessionKey,\n record.source,\n record.status,\n record.startedAt,\n record.finishedAt ?? null,\n record.verdict ?? null,\n record.reason ?? null,\n record.nextAction ?? null,\n record.assistantPreview ?? null,\n record.checklistProgress?.done ?? null,\n record.checklistProgress?.total ?? null,\n record.confidence ?? null,\n record.missingEvidence ? JSON.stringify(record.missingEvidence) : null,\n record.userQuestion ?? null,\n record.completedChecklistItemIds ? JSON.stringify(record.completedChecklistItemIds) : null,\n );\n db.prepare(`UPDATE goals SET current_run_id = ?, updated_at = ? WHERE goal_id = ?`).run(\n record.id,\n record.finishedAt ?? record.startedAt,\n record.goalId,\n );\n insertGoalEvent(db, {\n goalId: record.goalId,\n runId: record.id,\n kind: 'run_recorded',\n message: record.reason ?? record.status,\n data: {\n verdict: record.verdict,\n status: record.status,\n confidence: record.confidence,\n missingEvidence: record.missingEvidence,\n userQuestion: record.userQuestion,\n completedChecklistItemIds: record.completedChecklistItemIds,\n },\n createdAt: record.finishedAt ?? record.startedAt,\n });\n });\n return record;\n }\n\n listRuns(goalId: string, limit?: number): GoalRun[] {\n const rows = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_runs WHERE goal_id = ? ORDER BY started_at DESC LIMIT ?`)\n .all(goalId, clampLimit(limit, 50)) as GoalRunRow[];\n return rows.map(runFromRow);\n }\n\n listRunsForSession(sessionKey: string, limit?: number): GoalRun[] {\n const rows = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_runs WHERE session_key = ? ORDER BY started_at DESC LIMIT ?`)\n .all(sessionKey, clampLimit(limit, 50)) as GoalRunRow[];\n return rows.map(runFromRow);\n }\n\n listEvents(goalId: string, limit?: number): GoalEvent[] {\n const rows = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_events WHERE goal_id = ? ORDER BY created_at DESC LIMIT ?`)\n .all(goalId, clampLimit(limit, 100)) as EventRow[];\n return rows.map(eventFromRow);\n }\n\n addEvidence(input: Omit<GoalEvidence, 'id' | 'createdAt'> & { id?: string; createdAt?: number }): GoalEvidence {\n const evidence: GoalEvidence = {\n id: input.id ?? randomUUID(),\n goalId: input.goalId,\n runId: input.runId,\n kind: input.kind,\n title: input.title,\n summary: input.summary,\n uri: input.uri,\n data: input.data,\n createdAt: input.createdAt ?? Date.now(),\n };\n runSqliteWriteTransaction((db) => {\n db.prepare(\n `INSERT INTO goal_evidence (\n evidence_id, goal_id, run_id, kind, title, summary, uri, data_json, created_at\n ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n ).run(\n evidence.id,\n evidence.goalId,\n evidence.runId ?? null,\n evidence.kind,\n evidence.title,\n evidence.summary ?? null,\n evidence.uri ?? null,\n evidence.data === undefined ? null : JSON.stringify(evidence.data),\n evidence.createdAt,\n );\n insertGoalEvent(db, {\n goalId: evidence.goalId,\n runId: evidence.runId,\n kind: 'evidence_added',\n message: evidence.title,\n data: { evidenceId: evidence.id, kind: evidence.kind },\n createdAt: evidence.createdAt,\n });\n });\n return evidence;\n }\n\n listEvidence(goalId: string, limit?: number): GoalEvidence[] {\n const rows = getSqliteDatabase()\n .prepare(`SELECT * FROM goal_evidence WHERE goal_id = ? ORDER BY created_at DESC LIMIT ?`)\n .all(goalId, clampLimit(limit, 100)) as EvidenceRow[];\n const db = getSqliteDatabase();\n return rows.map((row) => ({\n ...evidenceFromRow(row),\n requirementIds: (db.prepare(\n `SELECT requirement_id FROM goal_evidence_requirement_links WHERE evidence_id = ? ORDER BY requirement_id`,\n ).all(row.evidence_id) as Array<{ requirement_id: string }>).map((item) => item.requirement_id),\n }));\n }\n\n listEvidenceRequirements(goalId: string): GoalEvidenceRequirement[] {\n const db = getSqliteDatabase();\n const rows = db\n .prepare(`SELECT * FROM goal_evidence_requirements WHERE goal_id = ? ORDER BY sort_order ASC`)\n .all(goalId) as GoalEvidenceRequirementRow[];\n return rows.map((row) => evidenceRequirementFromRow(\n row,\n (db.prepare(\n `SELECT evidence_id FROM goal_evidence_requirement_links WHERE requirement_id = ? ORDER BY created_at ASC`,\n ).all(row.requirement_id) as Array<{ evidence_id: string }>).map((item) => item.evidence_id),\n ));\n }\n\n linkEvidenceRequirement(input: {\n goalId: string;\n requirementId: string;\n evidenceId: string;\n linkedBy: 'user' | 'agent' | 'system';\n }): GoalEvidenceRequirement | null {\n return runSqliteWriteTransaction((db) => {\n const requirement = db.prepare(\n `SELECT * FROM goal_evidence_requirements WHERE requirement_id = ? AND goal_id = ?`,\n ).get(input.requirementId, input.goalId) as GoalEvidenceRequirementRow | undefined;\n const evidence = db.prepare(\n `SELECT evidence_id FROM goal_evidence WHERE evidence_id = ? AND goal_id = ?`,\n ).get(input.evidenceId, input.goalId) as { evidence_id: string } | undefined;\n if (!requirement || !evidence) return null;\n const now = Date.now();\n db.prepare(\n `INSERT OR IGNORE INTO goal_evidence_requirement_links (requirement_id, evidence_id, linked_by, created_at)\n VALUES (?, ?, ?, ?)`,\n ).run(input.requirementId, input.evidenceId, input.linkedBy, now);\n db.prepare(\n `UPDATE goal_evidence_requirements\n SET status = CASE WHEN status = 'rejected' THEN 'pending' ELSE status END,\n updated_at = ?\n WHERE requirement_id = ?`,\n ).run(now, input.requirementId);\n insertGoalEvent(db, {\n goalId: input.goalId,\n kind: 'evidence_requirement_linked',\n message: requirement.text,\n data: { requirementId: input.requirementId, evidenceId: input.evidenceId, linkedBy: input.linkedBy },\n createdAt: now,\n });\n const ids = (db.prepare(\n `SELECT evidence_id FROM goal_evidence_requirement_links WHERE requirement_id = ? ORDER BY created_at ASC`,\n ).all(input.requirementId) as Array<{ evidence_id: string }>).map((item) => item.evidence_id);\n const next = db.prepare(`SELECT * FROM goal_evidence_requirements WHERE requirement_id = ?`)\n .get(input.requirementId) as GoalEvidenceRequirementRow;\n return evidenceRequirementFromRow(next, ids);\n });\n }\n\n reviewEvidenceRequirement(input: {\n goalId: string;\n requirementId: string;\n status: GoalEvidenceRequirementStatus;\n reason: string;\n confidence?: number;\n reviewedBy: GoalEvidenceReviewSource;\n }): GoalEvidenceRequirement | null {\n return runSqliteWriteTransaction((db) => {\n const current = db.prepare(\n `SELECT * FROM goal_evidence_requirements WHERE requirement_id = ? AND goal_id = ?`,\n ).get(input.requirementId, input.goalId) as GoalEvidenceRequirementRow | undefined;\n if (!current) return null;\n const now = Date.now();\n db.prepare(\n `UPDATE goal_evidence_requirements\n SET status = ?, review_reason = ?, review_confidence = ?, reviewed_by = ?, reviewed_at = ?, updated_at = ?\n WHERE requirement_id = ?`,\n ).run(\n input.status,\n input.reason.trim(),\n input.confidence ?? null,\n input.reviewedBy,\n now,\n now,\n input.requirementId,\n );\n insertGoalEvent(db, {\n goalId: input.goalId,\n kind: input.reviewedBy === 'user' ? 'evidence_requirement_approved' : 'evidence_requirement_reviewed',\n message: current.text,\n data: { requirementId: input.requirementId, status: input.status, reason: input.reason.trim(), confidence: input.confidence },\n createdAt: now,\n });\n const ids = (db.prepare(\n `SELECT evidence_id FROM goal_evidence_requirement_links WHERE requirement_id = ? ORDER BY created_at ASC`,\n ).all(input.requirementId) as Array<{ evidence_id: string }>).map((item) => item.evidence_id);\n const next = db.prepare(`SELECT * FROM goal_evidence_requirements WHERE requirement_id = ?`)\n .get(input.requirementId) as GoalEvidenceRequirementRow;\n return evidenceRequirementFromRow(next, ids);\n });\n }\n}\n"],"mappings":";;;AA0IA,SAAS,YAAY,KAAoB;AACvC,QAAO;EACL,IAAI,IAAI;EACR,OAAO,IAAI;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,2BAA2B,OAAO;GACvC,MAAM,UAAU,GAAG,QACjB,oFACD,CAAC,IAAI,MAAM,eAAe,MAAM,OAAO;AACxC,OAAI,CAAC,QAAS,QAAO;GACrB,MAAM,MAAM,KAAK,KAAK;AACtB,MAAG,QACD;;mCAGD,CAAC,IACA,MAAM,QACN,MAAM,OAAO,MAAM,EACnB,MAAM,cAAc,MACpB,MAAM,YACN,KACA,KACA,MAAM,cACP;AACD,mBAAgB,IAAI;IAClB,QAAQ,MAAM;IACd,MAAM,MAAM,eAAe,SAAS,kCAAkC;IACtE,SAAS,QAAQ;IACjB,MAAM;KAAE,eAAe,MAAM;KAAe,QAAQ,MAAM;KAAQ,QAAQ,MAAM,OAAO,MAAM;KAAE,YAAY,MAAM;KAAY;IAC7H,WAAW;IACZ,CAAC;GACF,MAAM,MAAO,GAAG,QACd,2GACD,CAAC,IAAI,MAAM,cAAc,CAAoC,KAAK,SAAS,KAAK,YAAY;AAG7F,UAAO,2BAFM,GAAG,QAAQ,oEAAoE,CACzF,IAAI,MAAM,cACyB,EAAE,IAAI;IAC5C"}
|
|
@@ -4,6 +4,10 @@ export { GoalRunner } from './goal-runner.js';
|
|
|
4
4
|
export { GoalQueueStore } from './goal-queue-store.js';
|
|
5
5
|
export { GoalNotificationService } from './goal-notifications.js';
|
|
6
6
|
export { GoalWorkflowJudge } from './goal-workflow-judge.js';
|
|
7
|
+
export { draftGoalContract } from './goal-contract-draft.js';
|
|
8
|
+
export { reviewGoalEvidenceRequirement } from './goal-evidence-review.js';
|
|
9
|
+
export type * from './goal-contract-draft.js';
|
|
10
|
+
export type * from './goal-evidence-review.js';
|
|
7
11
|
export type * from './types.js';
|
|
8
12
|
export type * from './goal-queue-types.js';
|
|
9
13
|
export type * from './goal-notifications.js';
|
package/dist/src/goals/index.js
CHANGED
|
@@ -4,4 +4,6 @@ import { GoalQueueStore } from "./goal-queue-store.js";
|
|
|
4
4
|
import { GoalRunner } from "./goal-runner.js";
|
|
5
5
|
import { GoalNotificationService } from "./goal-notifications.js";
|
|
6
6
|
import { GoalWorkflowJudge } from "./goal-workflow-judge.js";
|
|
7
|
-
|
|
7
|
+
import { draftGoalContract } from "./goal-contract-draft.js";
|
|
8
|
+
import { reviewGoalEvidenceRequirement } from "./goal-evidence-review.js";
|
|
9
|
+
export { GoalNotificationService, GoalQueueStore, GoalRunner, GoalService, GoalStore, GoalWorkflowJudge, draftGoalContract, normalizeGoalUiLocale, reviewGoalEvidenceRequirement };
|
|
@@ -80,8 +80,27 @@ export interface GoalEvidence {
|
|
|
80
80
|
summary?: string;
|
|
81
81
|
uri?: string;
|
|
82
82
|
data?: unknown;
|
|
83
|
+
requirementIds?: string[];
|
|
83
84
|
createdAt: number;
|
|
84
85
|
}
|
|
86
|
+
export type GoalEvidenceRequirementStatus = 'pending' | 'ai_verified' | 'approved' | 'rejected';
|
|
87
|
+
export type GoalEvidenceReviewSource = 'ai' | 'user' | 'system';
|
|
88
|
+
/** A single, reviewable proof obligation from the goal contract. */
|
|
89
|
+
export interface GoalEvidenceRequirement {
|
|
90
|
+
id: string;
|
|
91
|
+
goalId: string;
|
|
92
|
+
text: string;
|
|
93
|
+
status: GoalEvidenceRequirementStatus;
|
|
94
|
+
evidenceIds: string[];
|
|
95
|
+
reviewReason?: string;
|
|
96
|
+
reviewConfidence?: number;
|
|
97
|
+
reviewedBy?: GoalEvidenceReviewSource;
|
|
98
|
+
reviewedAt?: number;
|
|
99
|
+
requiresHumanApproval: boolean;
|
|
100
|
+
createdAt: number;
|
|
101
|
+
updatedAt: number;
|
|
102
|
+
sortOrder: number;
|
|
103
|
+
}
|
|
85
104
|
export type GoalContextAttachment = MediaRef;
|
|
86
105
|
export interface GoalContextMessage {
|
|
87
106
|
goalId: string;
|
|
@@ -90,10 +109,32 @@ export interface GoalContextMessage {
|
|
|
90
109
|
createdAt: number;
|
|
91
110
|
updatedAt: number;
|
|
92
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* The user-confirmed definition of success for a persistent goal.
|
|
114
|
+
* Checklist items hold the individual acceptance criteria; this contract
|
|
115
|
+
* supplies the outcome, scope boundary, and expected evidence around them.
|
|
116
|
+
*/
|
|
117
|
+
export interface GoalContract {
|
|
118
|
+
goalId: string;
|
|
119
|
+
version: number;
|
|
120
|
+
objective: string;
|
|
121
|
+
scopeBoundary?: string;
|
|
122
|
+
evidencePlan: string[];
|
|
123
|
+
createdAt: number;
|
|
124
|
+
updatedAt: number;
|
|
125
|
+
}
|
|
126
|
+
export interface GoalContractInput {
|
|
127
|
+
objective?: string;
|
|
128
|
+
scopeBoundary?: string;
|
|
129
|
+
evidencePlan?: string[];
|
|
130
|
+
criteria?: string[];
|
|
131
|
+
}
|
|
93
132
|
export interface GoalWithDetails extends Goal {
|
|
94
133
|
checklist: GoalChecklistItem[];
|
|
95
134
|
latestRun?: GoalRun;
|
|
96
135
|
contextMessage?: GoalContextMessage;
|
|
136
|
+
contract?: GoalContract;
|
|
137
|
+
evidenceRequirements: GoalEvidenceRequirement[];
|
|
97
138
|
}
|
|
98
139
|
export interface GoalListQuery {
|
|
99
140
|
status?: GoalStatus | GoalStatus[];
|
|
@@ -115,6 +156,7 @@ export interface CreateGoalInput {
|
|
|
115
156
|
uiLocale?: GoalUiLocale;
|
|
116
157
|
source?: GoalSource;
|
|
117
158
|
projectId?: string;
|
|
159
|
+
contract?: GoalContractInput;
|
|
118
160
|
}
|
|
119
161
|
export interface GoalJudgeDecision {
|
|
120
162
|
verdict: GoalRunVerdict;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { init_loader, loadConfig } from "../config/loader.js";
|
|
4
|
-
import { loadUndiciRuntimeDeps } from "../infra/undici-fetch.js";
|
|
5
4
|
import { toConversation } from "./channel-shared.js";
|
|
6
5
|
import { createGatewayHttpClientFromConfig, resolveGatewayHttpBaseUrl } from "./gateway-http-client.js";
|
|
6
|
+
import { loadUndiciRuntimeDeps } from "../infra/undici-fetch.js";
|
|
7
7
|
//#region src/mcp/channel-bridge.ts
|
|
8
8
|
init_loader();
|
|
9
9
|
init_logger();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MobileActivityEvent } from './notification-types.js';
|
|
2
|
+
/** Converts gateway domain events into a portable mobile activity and push payload. */
|
|
3
|
+
export declare function mobileNotificationEventFromGatewayEvent(type: string, payload: unknown): Omit<MobileActivityEvent, 'id' | 'createdAt'> | null;
|
|
4
|
+
export declare class MobileNotificationService {
|
|
5
|
+
private readonly sent;
|
|
6
|
+
handleGatewayEvent(type: string, payload: unknown): void;
|
|
7
|
+
private deliver;
|
|
8
|
+
}
|