@xopcai/xopc 0.0.178 → 0.0.180
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/{activity-store-BzGX__8I.js → activity-store-DFKtQDgE.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BzxntcaZ.js → agent-avatar-dicebear-CcTvB_4W.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DgGj9bu6.js +2 -0
- package/dist/gateway/static/root/assets/{api-hi6f2Xtp.js → api-CUClAvuL.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-fTY1F7ac.js → app-management-settings-panel-Ib-cWKHM.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BZ-IxQfB.js → appearance-settings-CRSN8WuA.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-B5xahuT-.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-ZSLLG8wB.js → archive-plugin-BBF9zspN.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-D4YktqIF.js → attachment-load-D3QQfA7w.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-BUYrvMmD.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BIkPxfxj.js → binary-plugins-D78XOjJ3.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Q3v_YQom.js → block-editor-D_VVXlYX.js} +46 -46
- package/dist/gateway/static/root/assets/browser-settings-page-Cjw07q9h.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-M5lTEW1I.js → browser-workflow-inputs-_gu08MA4.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-B3T1KYk4.js → browser-workflows-page-58DBMXgG.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-D_dfVxHY.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-DE09c0VB.js → capability-presets-api-DhCn9rPv.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-LWWIYUT7.js +1 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-CFR5FBfS.js → channel-recipient-api-DYtoNV5A.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-Cyj5OunL.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-TEFnV0IG.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-B1mD-3pM.js → connector-logo-CxIXnifA.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-0TobCpBB.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-CwVSLL6N.js +1 -0
- package/dist/gateway/static/root/assets/desktop-pet-settings-BOIp4q0Z.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BYQJ2XUS.js → directory-picker-path-field-C8_lsW6S.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-BXcb8fwx.js → dreaming-settings-Da9FeWQl.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-O1Xu1r4Q.js → extension-debug-page-CMNnSJP6.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-C2Jraq8l.js → extension-page-t0pJqLvM.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-DcXQDTpG.js → extension-settings-page-aiR-tKnW.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-DmPIZrvg.js → gateway-config-api-CkyQBD6r.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-BIZfAgfB.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BZEkOdPm.js → gateway-startup-retry-CSU7UvzG.js} +1 -1
- package/dist/gateway/static/root/assets/goals-settings-Dx9uTyWF.js +1 -0
- package/dist/gateway/static/root/assets/{heartbeat-settings-BtKu2NWT.js → heartbeat-settings-Cnr5ORXL.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-05Gg8wsU.js → image-generation-api-BR6Kb77X.js} +1 -1
- package/dist/gateway/static/root/assets/index-B0Tdge_q.css +1 -0
- package/dist/gateway/static/root/assets/index-BA56bQ68.js +224 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CfmDR9Sc.js → keyboard-shortcuts-settings-D76uYKeQ.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-DSUNtLHg.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-Df8BW1A_.js → local-apps-page-BsLnojTh.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CTwSy7yW.js → locale-store-BNC8HUCI.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-yI8kpQtO.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-B3FvKbaP.js → markdown-split-D6smTQWD.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DsjrvvB6.js → media-plugins-D1TmMF0A.js} +1 -1
- package/dist/gateway/static/root/assets/messages-H_iJjnEM.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-tuzIwy3c.js → notes-page-Vt-diFf0.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-BD297EZt.js +4 -0
- package/dist/gateway/static/root/assets/outcome-detail-page-C5i_ZR9a.js +1 -0
- package/dist/gateway/static/root/assets/{page-tabs-ke9s4nYi.js → page-tabs-BnSzIjH0.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-Cp1eI4S9.js → preview-open-alternatives-CF12Eqi4.js} +1 -1
- package/dist/gateway/static/root/assets/product-delivery-BVG-eWQO.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-dXQCMAtH.js → product-open-page-Du0TE_CU.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-D1HGz7Dy.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-CqP2TnW-.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-BXdVJLS3.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-Bl30zjHc.js → save-bar-controls-B53UNtDM.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-DqhmXQKo.js → schedule-field-C3dIMN5q.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DkUCy6vf.js → schema-form-BKvpxqof.js} +1 -1
- package/dist/gateway/static/root/assets/{schemas-DgQq6Z5S.js → schemas-C6onAggk.js} +2 -2
- package/dist/gateway/static/root/assets/sessions-page-CPAwDdl5.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-C-jGsoft.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-C6ZbNpdy.js → settings-form-section-kt6GIS32.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-Bk58_cr7.js → settings-loading-skeleton-85eUPcKz.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-k8iE_NdX.js → settings-page-Di5x6Xrc.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-DgFSya2e.js → settings-page-layout-CkkCee_x.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-B_KDlyZA.js → setup-status-panel-uxEE6gAB.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CV7nL_J9.js → share-preview-page-BtLEstaI.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-2mcsMWgn.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-ocDwsrEt.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-9_jfsFU5.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-kahBIHg0.js → skills-page.utils-C2SHvq8V.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-JV3-MG5F.js → system-settings-panel-CIJ66cUy.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-DFLyzoLO.js → theme-store-ClDa_Bci.js} +1 -1
- package/dist/gateway/static/root/assets/time-picker-D0zAsHOo.js +1 -0
- package/dist/gateway/static/root/assets/{typed-models-lib-60Aqo-UJ.js → typed-models-lib-GsmwmB40.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CnTkHDnw.js → use-channel-catalog-BQz3K7xj.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-Bn4BLg4W.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CNa8qUgS.js → voice-api-key-field-Blaxsbb3.js} +1 -1
- package/dist/gateway/static/root/assets/work-copy-Cwyan9Sn.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-iJ9RBSpu.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-CqTH7PQX.js +1 -0
- package/dist/gateway/static/root/assets/work-page-H3m99ccS.js +3 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-yV_x595t.js → workflow-run-setup-panel-CTG4RpRE.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-BxZSKMfv.js +11 -0
- package/dist/gateway/static/root/index.html +9 -10
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/outcomes.js +137 -0
- package/dist/packages/gateway-contract/src/product-delivery.js +1 -0
- package/dist/packages/gateway-contract/src/work-intake.js +85 -0
- package/dist/src/activity/service.d.ts +1 -0
- package/dist/src/activity/service.js +4 -1
- package/dist/src/agent/agent-manager.d.ts +4 -1
- package/dist/src/agent/agent-manager.js +21 -7
- package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
- package/dist/src/agent/code-intelligence/binary.js +1 -1
- package/dist/src/agent/context/execution-scope.d.ts +1 -1
- package/dist/src/agent/context/execution-scope.js +6 -4
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.d.ts +2 -0
- package/dist/src/agent/embedded/run-for-session.js +3 -1
- package/dist/src/agent/goals/post-turn.js +7 -6
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/inbound/turn-dispatcher.d.ts +6 -1
- package/dist/src/agent/inbound/turn-dispatcher.js +5 -2
- package/dist/src/agent/ipc/inbox.js +1 -1
- package/dist/src/agent/lifecycle/timeout-wrapper.d.ts +2 -0
- package/dist/src/agent/lifecycle/timeout-wrapper.js +39 -9
- package/dist/src/agent/mcp/bundle-mcp-materialize.js +2 -2
- package/dist/src/agent/mcp/bundle-mcp-runtime.js +6 -1
- package/dist/src/agent/mcp/bundle-mcp-types.d.ts +1 -1
- package/dist/src/agent/mcp/mcp-stdio-transport.js +1 -1
- package/dist/src/agent/mcp/mcp-transport-config.d.ts +2 -0
- package/dist/src/agent/mcp/mcp-transport-config.js +10 -3
- package/dist/src/agent/mcp/mcp-transport.d.ts +1 -0
- package/dist/src/agent/mcp/mcp-transport.js +5 -2
- package/dist/src/agent/memory/dreaming/config.js +1 -1
- package/dist/src/agent/memory/user-context-coordinator.d.ts +1 -0
- package/dist/src/agent/memory/user-context-coordinator.js +17 -1
- package/dist/src/agent/orchestration/run-agent-turn-with-timeout.d.ts +1 -1
- package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +6 -2
- package/dist/src/agent/outcomes/{task-evaluation.d.ts → execution-evaluation.d.ts} +3 -3
- package/dist/src/agent/outcomes/{task-evaluation.js → execution-evaluation.js} +5 -5
- package/dist/src/agent/outcomes/execution-verifier.d.ts +29 -0
- package/dist/src/agent/outcomes/{task-verifier.js → execution-verifier.js} +4 -4
- package/dist/src/agent/service/direct-turn-helpers.d.ts +1 -0
- package/dist/src/agent/service/direct-turn-helpers.js +1 -0
- package/dist/src/agent/service/process-direct-one-shot.d.ts +3 -0
- package/dist/src/agent/service/process-direct-one-shot.js +4 -1
- package/dist/src/agent/service/process-direct-streaming.js +3 -1
- package/dist/src/agent/service.d.ts +1 -0
- package/dist/src/agent/service.js +5 -2
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/config.js +6 -0
- package/dist/src/agent/skills/filesystem-watcher.d.ts +4 -0
- package/dist/src/agent/skills/filesystem-watcher.js +16 -7
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/skills/index.d.ts +10 -7
- package/dist/src/agent/skills/index.js +56 -47
- package/dist/src/agent/skills/skill-manage-ops.js +1 -1
- package/dist/src/agent/skills/skill-manager.d.ts +5 -2
- package/dist/src/agent/skills/skill-manager.js +10 -5
- package/dist/src/agent/skills/skill-sources.d.ts +18 -0
- package/dist/src/agent/skills/skill-sources.js +143 -0
- package/dist/src/agent/skills/types.d.ts +25 -2
- package/dist/src/agent/tools/delegate-tool.js +2 -1
- package/dist/src/agent/tools/executor.d.ts +2 -0
- package/dist/src/agent/tools/executor.js +18 -11
- package/dist/src/agent/tools/factory.js +18 -1
- package/dist/src/agent/tools/goal-tool.js +5 -3
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/agent/tools/managed-job-tool.d.ts +2 -0
- package/dist/src/agent/tools/managed-job-tool.js +160 -0
- package/dist/src/agent/tools/todo-tool.d.ts +5 -0
- package/dist/src/agent/tools/todo-tool.js +16 -4
- package/dist/src/agent/tools/update-plan-tool.d.ts +1 -0
- package/dist/src/agent/tools/update-plan-tool.js +6 -0
- package/dist/src/agent/workspace-runtime/registry.d.ts +3 -0
- package/dist/src/agent/workspace-runtime/registry.js +3 -1
- package/dist/src/agent-runtime/index.js +1 -1
- package/dist/src/agent-runtime/runtime-profile.js +1 -1
- package/dist/src/auth/credentials.d.ts +9 -1
- package/dist/src/auth/credentials.js +112 -56
- package/dist/src/auth/model-credential-store.js +7 -22
- package/dist/src/auth/oauth-provider-lock.d.ts +5 -0
- package/dist/src/auth/oauth-provider-lock.js +91 -0
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/automations/domain/defaults.d.ts +8 -1
- package/dist/src/automations/domain/defaults.js +9 -2
- package/dist/src/automations/domain/index.js +2 -2
- package/dist/src/automations/domain/types.d.ts +33 -7
- package/dist/src/automations/domain/validation.d.ts +8 -0
- package/dist/src/automations/domain/validation.js +2 -0
- package/dist/src/automations/draft/automation-draft-validator.d.ts +2 -1
- package/dist/src/automations/index.js +2 -2
- package/dist/src/automations/service/action-executor.d.ts +2 -2
- package/dist/src/automations/service/action-executor.js +144 -34
- package/dist/src/automations/service/automation-service.d.ts +4 -0
- package/dist/src/automations/service/automation-service.js +197 -18
- package/dist/src/automations/storage/automation-run-repository.d.ts +1 -0
- package/dist/src/automations/storage/automation-run-repository.js +37 -7
- package/dist/src/automations/storage/index.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/browser/providers/cloakbrowser.js +2 -2
- package/dist/src/channels/attachments/voice-stt-webchat.d.ts +0 -3
- package/dist/src/channels/attachments/voice-stt-webchat.js +1 -24
- package/dist/src/chat-commands/builtins/goal.js +5 -4
- package/dist/src/cli/commands/agents.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/goal.js +6 -5
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/tunnel.js +3 -3
- package/dist/src/cli/utils/oauth-login.js +1 -7
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.d.ts +3 -0
- package/dist/src/config/schema.js +2 -1
- package/dist/src/connectors/learning-coordinator.js +7 -1
- package/dist/src/connectors/source-change-publisher.d.ts +17 -0
- package/dist/src/connectors/source-change-publisher.js +148 -0
- package/dist/src/discussions/analyzer.d.ts +35 -0
- package/dist/src/discussions/analyzer.js +127 -0
- package/dist/src/discussions/index.d.ts +7 -0
- package/dist/src/discussions/index.js +7 -0
- package/dist/src/discussions/live-worker.d.ts +33 -0
- package/dist/src/discussions/live-worker.js +148 -0
- package/dist/src/discussions/pipeline.d.ts +33 -0
- package/dist/src/discussions/pipeline.js +205 -0
- package/dist/src/discussions/project-inference.d.ts +13 -0
- package/dist/src/discussions/project-inference.js +19 -0
- package/dist/src/discussions/repository.d.ts +29 -0
- package/dist/src/discussions/repository.js +255 -0
- package/dist/src/discussions/service.d.ts +51 -0
- package/dist/src/discussions/service.js +335 -0
- package/dist/src/discussions/transcript.d.ts +3 -0
- package/dist/src/discussions/transcript.js +15 -0
- package/dist/src/discussions/types.d.ts +116 -0
- package/dist/src/discussions/types.js +10 -0
- package/dist/src/discussions/worker.d.ts +18 -0
- package/dist/src/discussions/worker.js +74 -0
- package/dist/src/extensions/activation-context.js +2 -1
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/extensions/sdk/testing.js +1 -1
- package/dist/src/gateway/agents-admin.js +3 -3
- package/dist/src/gateway/chat-stream/mapper.js +53 -3
- package/dist/src/gateway/chat-stream/protocol.d.ts +17 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/app.js +8 -3
- package/dist/src/gateway/hono/lib/config-payload.js +2 -2
- package/dist/src/gateway/hono/middleware/auth.js +2 -2
- package/dist/src/gateway/hono/middleware/logger.js +1 -1
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +1 -1
- package/dist/src/gateway/hono/oauth-async.js +1 -7
- package/dist/src/gateway/hono/oauth.js +1 -7
- package/dist/src/gateway/hono/routes/agents.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
- package/dist/src/gateway/hono/routes/connectors.js +79 -0
- package/dist/src/gateway/hono/routes/discussions.d.ts +3 -0
- package/dist/src/gateway/hono/routes/discussions.js +177 -0
- package/dist/src/gateway/hono/routes/execution-receipts.d.ts +3 -0
- package/dist/src/gateway/hono/routes/execution-receipts.js +163 -0
- package/dist/src/gateway/hono/routes/exposure.js +1 -1
- package/dist/src/gateway/hono/routes/goals.js +3 -288
- package/dist/src/gateway/hono/routes/home.d.ts +2 -102
- package/dist/src/gateway/hono/routes/home.js +8 -424
- package/dist/src/gateway/hono/routes/index.js +6 -2
- package/dist/src/gateway/hono/routes/memory.js +7 -7
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/notes.js +30 -0
- package/dist/src/gateway/hono/routes/projects.js +8 -152
- package/dist/src/gateway/hono/routes/shares.js +1 -1
- package/dist/src/gateway/hono/routes/status.js +2 -2
- package/dist/src/gateway/hono/routes/tunnel.js +3 -3
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/gateway/hono/routes/work.d.ts +3 -0
- package/dist/src/gateway/hono/routes/work.js +207 -0
- package/dist/src/gateway/hono/routes/you.js +13 -15
- package/dist/src/gateway/index.js +2 -2
- package/dist/src/gateway/runtime-config.js +2 -2
- package/dist/src/gateway/security/audit.js +2 -2
- package/dist/src/gateway/security/index.js +1 -1
- package/dist/src/gateway/service/config-coordinator.js +2 -2
- package/dist/src/gateway/service/run-gateway-agent.js +46 -51
- package/dist/src/gateway/service.d.ts +8 -1
- package/dist/src/gateway/service.js +142 -15
- package/dist/src/goals/goal-queue-store.d.ts +1 -0
- package/dist/src/goals/goal-queue-store.js +5 -1
- package/dist/src/goals/goal-queue-types.d.ts +11 -1
- package/dist/src/goals/goal-runner.js +10 -6
- package/dist/src/goals/goal-service.d.ts +2 -15
- package/dist/src/goals/goal-service.js +9 -42
- package/dist/src/goals/goal-store.d.ts +1 -18
- package/dist/src/goals/goal-store.js +25 -231
- package/dist/src/goals/goal-workflow-judge.js +1 -1
- package/dist/src/goals/index.d.ts +0 -4
- package/dist/src/goals/index.js +1 -3
- package/dist/src/goals/types.d.ts +4 -66
- package/dist/src/notes/agent-context.js +1 -1
- package/dist/src/notes/service.d.ts +1 -0
- package/dist/src/notes/service.js +10 -1
- package/dist/src/notes/types.d.ts +1 -0
- package/dist/src/proactive/events/product-event-bridge.d.ts +7 -0
- package/dist/src/proactive/events/product-event-bridge.js +84 -0
- package/dist/src/proactive/execution/context.d.ts +27 -11
- package/dist/src/proactive/execution/context.js +259 -25
- package/dist/src/proactive/execution/repository.js +18 -5
- package/dist/src/proactive/execution/types.d.ts +7 -1
- package/dist/src/proactive/execution/worker.js +7 -6
- package/dist/src/proactive/inbox/repository.js +8 -2
- package/dist/src/proactive/index.d.ts +4 -2
- package/dist/src/proactive/index.js +5 -3
- package/dist/src/proactive/temporal/worker.d.ts +16 -0
- package/dist/src/proactive/temporal/worker.js +110 -0
- package/dist/src/projects/project-loop.js +3 -3
- package/dist/src/providers/auth-runtime/oauth.js +12 -0
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/share/share-zip.js +1 -1
- package/dist/src/share/site-proxy.js +1 -1
- package/dist/src/storage/sqlite/activity-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/activity-repository.js +4 -1
- package/dist/src/storage/sqlite/connector-sync-policy-repository.d.ts +20 -0
- package/dist/src/storage/sqlite/connector-sync-policy-repository.js +50 -0
- package/dist/src/storage/sqlite/execution-receipt-repository.d.ts +146 -0
- package/dist/src/storage/sqlite/execution-receipt-repository.js +235 -0
- package/dist/src/storage/sqlite/index.d.ts +4 -2
- package/dist/src/storage/sqlite/index.js +6 -4
- package/dist/src/storage/sqlite/knowledge-repository.d.ts +3 -0
- package/dist/src/storage/sqlite/knowledge-repository.js +9 -1
- package/dist/src/storage/sqlite/memory-records-repository.js +1 -1
- package/dist/src/storage/sqlite/migrations/075_connector_sync_policies.sql +13 -0
- package/dist/src/storage/sqlite/migrations/076_meeting_preparation_scenario.sql +29 -0
- package/dist/src/storage/sqlite/migrations/077_proactive_insight_fingerprints.sql +4 -0
- package/dist/src/storage/sqlite/migrations/078_discussion_captures.sql +64 -0
- package/dist/src/storage/sqlite/migrations/079_discussion_follow_up_scenario.sql +29 -0
- package/dist/src/storage/sqlite/migrations/080_task_outcome_context.sql +15 -0
- package/dist/src/storage/sqlite/migrations/081_project_monitoring_policies.sql +10 -0
- package/dist/src/storage/sqlite/migrations/082_one_click_live_discussions.sql +100 -0
- package/dist/src/storage/sqlite/migrations/083_session_task_plans.sql +9 -0
- package/dist/src/storage/sqlite/migrations/084_work_intake_lifecycle.sql +26 -0
- package/dist/src/storage/sqlite/migrations/085_task_outcome_projection.sql +19 -0
- package/dist/src/storage/sqlite/migrations/086_outcome_aggregates.sql +168 -0
- package/dist/src/storage/sqlite/migrations/087_context_snapshots.sql +21 -0
- package/dist/src/storage/sqlite/migrations/088_automation_execution_deadlines.sql +5 -0
- package/dist/src/storage/sqlite/migrations/089_automation_run_leases.sql +8 -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.ts +1 -1
- package/dist/src/storage/sqlite/notes-repository.js +9 -0
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +89 -44
- package/dist/src/storage/sqlite/session-repository.js +1 -1
- package/dist/src/storage/sqlite/session-task-plan-repository.d.ts +20 -0
- package/dist/src/storage/sqlite/session-task-plan-repository.js +77 -0
- package/dist/src/tui/backends/embedded-backend.d.ts +2 -0
- package/dist/src/tui/backends/embedded-backend.js +12 -8
- package/dist/src/tui/tui-backend.d.ts +2 -0
- package/dist/src/tui/tui-oauth-login.js +1 -7
- package/dist/src/tui/tui-picker-overlay.js +1 -0
- package/dist/src/tui/tui-picker-services.d.ts +1 -0
- package/dist/src/tui/tui-skills-autocomplete.d.ts +6 -2
- package/dist/src/tui/tui-skills-autocomplete.js +10 -6
- package/dist/src/tui/tui-startup-resources.d.ts +3 -1
- package/dist/src/tui/tui-startup-resources.js +4 -3
- package/dist/src/tui/tui.js +4 -1
- package/dist/src/tunnel/frpc-binary.js +1 -1
- package/dist/src/tunnel/frpc-extract.js +1 -1
- package/dist/src/tunnel/index.js +2 -2
- package/dist/src/user-context/context-compiler.d.ts +31 -0
- package/dist/src/user-context/context-compiler.js +51 -0
- package/dist/src/voice/local/model-files.js +1 -1
- package/dist/src/voice/stt/config.d.ts +4 -0
- package/dist/src/voice/stt/config.js +26 -0
- package/dist/src/voice/stt/index.d.ts +1 -0
- package/dist/src/voice/stt/index.js +2 -1
- package/dist/src/voice/stt/list-providers.js +1 -1
- package/dist/src/work/attention-governor.d.ts +20 -0
- package/dist/src/work/attention-governor.js +46 -0
- package/dist/src/work/execution-context.d.ts +16 -0
- package/dist/src/work/execution-context.js +66 -0
- package/dist/src/work/home-query-service.d.ts +147 -0
- package/dist/src/work/home-query-service.js +389 -0
- package/dist/src/work/index.d.ts +14 -0
- package/dist/src/work/index.js +15 -0
- package/dist/src/work/outcome-contract-definition.d.ts +8 -0
- package/dist/src/work/outcome-contract-definition.js +15 -0
- package/dist/src/work/outcome-execution-service.d.ts +27 -0
- package/dist/src/work/outcome-execution-service.js +60 -0
- package/dist/src/work/outcome-projection-service.d.ts +7 -0
- package/dist/src/work/outcome-projection-service.js +51 -0
- package/dist/src/work/outcome-receipt-service.d.ts +13 -0
- package/dist/src/work/outcome-receipt-service.js +55 -0
- package/dist/src/work/outcome-repository.d.ts +50 -0
- package/dist/src/work/outcome-repository.js +112 -0
- package/dist/src/work/outcome-run-coordinator.d.ts +25 -0
- package/dist/src/work/outcome-run-coordinator.js +117 -0
- package/dist/src/work/project-monitoring-service.d.ts +21 -0
- package/dist/src/work/project-monitoring-service.js +76 -0
- package/dist/src/work/project-operating-view-service.d.ts +10 -0
- package/dist/src/work/project-operating-view-service.js +46 -0
- package/dist/src/work/work-intake-repository.d.ts +49 -0
- package/dist/src/work/work-intake-repository.js +97 -0
- package/dist/src/work/work-intake-service.d.ts +26 -0
- package/dist/src/work/work-intake-service.js +171 -0
- package/dist/src/work/work-value-metrics-service.d.ts +4 -0
- package/dist/src/work/work-value-metrics-service.js +88 -0
- package/dist/src/work-items/work-item-service.d.ts +0 -2
- package/dist/src/work-items/work-item-service.js +0 -28
- package/dist/src/workflows/service/workflow-run-service.js +2 -2
- package/dist/src/workflows/service/workflow-run-service.types.d.ts +3 -1
- package/dist/src/workflows/service/workflow-session-bridge.js +2 -2
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/agents-DC9F12Kw.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-5bKr05Fa.js +0 -1
- package/dist/gateway/static/root/assets/automation-suggestion-card-B7mxFRtf.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-Dg6dmt5g.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-BHoo6Rpq.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BlsqN8Fu.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DJeT8_B4.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-C4VVjYEm.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-vdf8kB16.js +0 -1
- package/dist/gateway/static/root/assets/circle-alert-BEjgurr2.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DNcrDThX.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-B1urphOZ.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-DTL6J3EP.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-DmObBx9b.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-BRhmmBe9.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-C1k7_s_O.js +0 -4
- package/dist/gateway/static/root/assets/goals-config-api-Fwu1wjEP.js +0 -1
- package/dist/gateway/static/root/assets/goals-page-hOu9uA3q.js +0 -2
- package/dist/gateway/static/root/assets/goals-settings-DY-JjvHz.js +0 -1
- package/dist/gateway/static/root/assets/index-C0CGebQ1.js +0 -212
- package/dist/gateway/static/root/assets/index-eqq25gvV.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-EjsNT7nJ.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-Dswjlraa.js +0 -7
- package/dist/gateway/static/root/assets/messages-DP6tPKk-.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-DSh3-hMY.js +0 -4
- package/dist/gateway/static/root/assets/product-delivery-BTRT9kCS.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-D0QPRHR_.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-CI5Vz62F.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-S1jpzBS5.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CTm66k7h.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CU52AUVD.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-DK6XK95e.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Bvv_u4ii.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-BGHvVbay.js +0 -2
- package/dist/gateway/static/root/assets/time-picker-XwpxdZFr.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-DBCMk-Vn.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-C1UIdsCl.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-DEAQepB8.js +0 -1
- package/dist/gateway/static/root/assets/work-page-D5qYmCTq.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-yrK17ZZ5.js +0 -11
- package/dist/src/agent/outcomes/task-verifier.d.ts +0 -29
- package/dist/src/gateway/hono/routes/task-outcomes.d.ts +0 -3
- package/dist/src/gateway/hono/routes/task-outcomes.js +0 -109
- package/dist/src/goals/goal-contract-draft.d.ts +0 -15
- package/dist/src/goals/goal-contract-draft.js +0 -112
- package/dist/src/goals/goal-evidence-review.d.ts +0 -15
- package/dist/src/goals/goal-evidence-review.js +0 -89
- package/dist/src/storage/sqlite/task-outcome-repository.d.ts +0 -90
- package/dist/src/storage/sqlite/task-outcome-repository.js +0 -138
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Outcome, OutcomeContract, OutcomeImportance, OutcomeInternalStatus, OutcomeUserStatus } from '@xopcai/gateway-contract';
|
|
2
|
+
export type OutcomeSubjectKind = 'project' | 'goal' | 'work_item' | 'session' | 'workflow' | 'automation' | 'artifact' | 'source';
|
|
3
|
+
export type OutcomeLinkInput = {
|
|
4
|
+
kind: OutcomeSubjectKind;
|
|
5
|
+
id: string;
|
|
6
|
+
relation?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class OutcomeRepository {
|
|
9
|
+
create(input: {
|
|
10
|
+
id?: string;
|
|
11
|
+
objective: string;
|
|
12
|
+
deliverables?: string[];
|
|
13
|
+
acceptanceCriteria?: string[];
|
|
14
|
+
constraints?: string[];
|
|
15
|
+
approvalRequired?: string[];
|
|
16
|
+
contextSnapshotId?: string;
|
|
17
|
+
createdBy?: 'user' | 'system';
|
|
18
|
+
importance?: OutcomeImportance;
|
|
19
|
+
dueAt?: number;
|
|
20
|
+
links?: OutcomeLinkInput[];
|
|
21
|
+
now?: number;
|
|
22
|
+
}): Outcome;
|
|
23
|
+
get(id: string): Outcome | undefined;
|
|
24
|
+
getBySubject(kind: OutcomeSubjectKind, subjectId: string): Outcome | undefined;
|
|
25
|
+
listLinks(outcomeId: string): OutcomeLinkInput[];
|
|
26
|
+
list(input?: {
|
|
27
|
+
status?: OutcomeUserStatus;
|
|
28
|
+
limit?: number;
|
|
29
|
+
}): Outcome[];
|
|
30
|
+
getContract(outcomeId: string, version?: number): OutcomeContract | undefined;
|
|
31
|
+
reviseContract(input: {
|
|
32
|
+
outcomeId: string;
|
|
33
|
+
objective: string;
|
|
34
|
+
deliverables: string[];
|
|
35
|
+
acceptanceCriteria: string[];
|
|
36
|
+
constraints: string[];
|
|
37
|
+
approvalRequired: string[];
|
|
38
|
+
contextSnapshotId?: string;
|
|
39
|
+
createdBy: 'user' | 'system';
|
|
40
|
+
now?: number;
|
|
41
|
+
}): Outcome;
|
|
42
|
+
updateState(input: {
|
|
43
|
+
id: string;
|
|
44
|
+
userStatus: OutcomeUserStatus;
|
|
45
|
+
internalStatus: OutcomeInternalStatus;
|
|
46
|
+
latestReceiptRunId?: string;
|
|
47
|
+
now?: number;
|
|
48
|
+
}): Outcome | undefined;
|
|
49
|
+
addLink(outcomeId: string, link: OutcomeLinkInput, now?: number): void;
|
|
50
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { getSqliteDatabase, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
//#region src/work/outcome-repository.ts
|
|
4
|
+
function contractFromRow(row) {
|
|
5
|
+
return {
|
|
6
|
+
outcomeId: row.outcome_id,
|
|
7
|
+
version: row.version,
|
|
8
|
+
objective: row.objective,
|
|
9
|
+
deliverables: JSON.parse(row.deliverables_json),
|
|
10
|
+
acceptanceCriteria: JSON.parse(row.acceptance_criteria_json),
|
|
11
|
+
constraints: JSON.parse(row.constraints_json),
|
|
12
|
+
approvalRequired: JSON.parse(row.approval_required_json),
|
|
13
|
+
...row.context_snapshot_id ? { contextSnapshotId: row.context_snapshot_id } : {},
|
|
14
|
+
createdBy: row.created_by,
|
|
15
|
+
createdAt: row.created_at
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function outcomeFromRow(row, contract) {
|
|
19
|
+
return {
|
|
20
|
+
id: row.outcome_id,
|
|
21
|
+
objective: row.objective,
|
|
22
|
+
userStatus: row.user_status,
|
|
23
|
+
internalStatus: row.internal_status,
|
|
24
|
+
importance: row.importance,
|
|
25
|
+
...row.due_at === null ? {} : { dueAt: row.due_at },
|
|
26
|
+
latestContractVersion: row.latest_contract_version,
|
|
27
|
+
...row.latest_receipt_run_id ? { latestReceiptRunId: row.latest_receipt_run_id } : {},
|
|
28
|
+
...contract ? { contract } : {},
|
|
29
|
+
createdAt: row.created_at,
|
|
30
|
+
updatedAt: row.updated_at
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
var OutcomeRepository = class {
|
|
34
|
+
create(input) {
|
|
35
|
+
const objective = input.objective.trim();
|
|
36
|
+
if (!objective) throw new Error("Outcome objective is required");
|
|
37
|
+
const id = input.id ?? randomUUID();
|
|
38
|
+
const now = input.now ?? Date.now();
|
|
39
|
+
runSqliteWriteTransaction((db) => {
|
|
40
|
+
db.prepare(`INSERT INTO outcomes (
|
|
41
|
+
outcome_id, objective, user_status, internal_status, importance,
|
|
42
|
+
due_at, latest_contract_version, created_at, updated_at
|
|
43
|
+
) VALUES (?, ?, 'running', 'captured', ?, ?, 1, ?, ?)`).run(id, objective, input.importance ?? "normal", input.dueAt ?? null, now, now);
|
|
44
|
+
db.prepare(`INSERT INTO outcome_contracts (
|
|
45
|
+
outcome_id, version, objective, deliverables_json, acceptance_criteria_json,
|
|
46
|
+
constraints_json, approval_required_json, context_snapshot_id, created_by, created_at
|
|
47
|
+
) VALUES (?, 1, ?, ?, ?, ?, ?, ?, ?, ?)`).run(id, objective, JSON.stringify(input.deliverables ?? []), JSON.stringify(input.acceptanceCriteria ?? []), JSON.stringify(input.constraints ?? []), JSON.stringify(input.approvalRequired ?? []), input.contextSnapshotId ?? null, input.createdBy ?? "system", now);
|
|
48
|
+
for (const link of input.links ?? []) this.addLink(id, link, now);
|
|
49
|
+
});
|
|
50
|
+
return this.get(id);
|
|
51
|
+
}
|
|
52
|
+
get(id) {
|
|
53
|
+
const row = getSqliteDatabase().prepare("SELECT * FROM outcomes WHERE outcome_id = ?").get(id);
|
|
54
|
+
if (!row) return void 0;
|
|
55
|
+
return outcomeFromRow(row, this.getContract(id, row.latest_contract_version));
|
|
56
|
+
}
|
|
57
|
+
getBySubject(kind, subjectId) {
|
|
58
|
+
const row = getSqliteDatabase().prepare(`SELECT outcomes.* FROM outcomes
|
|
59
|
+
JOIN outcome_links ON outcome_links.outcome_id = outcomes.outcome_id
|
|
60
|
+
WHERE outcome_links.subject_kind = ? AND outcome_links.subject_id = ?
|
|
61
|
+
ORDER BY outcomes.updated_at DESC LIMIT 1`).get(kind, subjectId);
|
|
62
|
+
return row ? outcomeFromRow(row, this.getContract(row.outcome_id, row.latest_contract_version)) : void 0;
|
|
63
|
+
}
|
|
64
|
+
listLinks(outcomeId) {
|
|
65
|
+
return getSqliteDatabase().prepare(`SELECT subject_kind, subject_id, relation FROM outcome_links
|
|
66
|
+
WHERE outcome_id = ? ORDER BY created_at ASC`).all(outcomeId).map((row) => ({
|
|
67
|
+
kind: row.subject_kind,
|
|
68
|
+
id: row.subject_id,
|
|
69
|
+
relation: row.relation
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
list(input = {}) {
|
|
73
|
+
const limit = Math.max(1, Math.min(200, Math.floor(input.limit ?? 50)));
|
|
74
|
+
return (input.status ? getSqliteDatabase().prepare("SELECT * FROM outcomes WHERE user_status = ? ORDER BY updated_at DESC LIMIT ?").all(input.status, limit) : getSqliteDatabase().prepare("SELECT * FROM outcomes ORDER BY updated_at DESC LIMIT ?").all(limit)).map((row) => outcomeFromRow(row, this.getContract(row.outcome_id, row.latest_contract_version)));
|
|
75
|
+
}
|
|
76
|
+
getContract(outcomeId, version) {
|
|
77
|
+
const row = version === void 0 ? getSqliteDatabase().prepare("SELECT * FROM outcome_contracts WHERE outcome_id = ? ORDER BY version DESC LIMIT 1").get(outcomeId) : getSqliteDatabase().prepare("SELECT * FROM outcome_contracts WHERE outcome_id = ? AND version = ?").get(outcomeId, version);
|
|
78
|
+
return row ? contractFromRow(row) : void 0;
|
|
79
|
+
}
|
|
80
|
+
reviseContract(input) {
|
|
81
|
+
const current = this.get(input.outcomeId);
|
|
82
|
+
if (!current) throw new Error("Outcome not found");
|
|
83
|
+
const objective = input.objective.trim();
|
|
84
|
+
if (!objective) throw new Error("Outcome objective is required");
|
|
85
|
+
const version = current.latestContractVersion + 1;
|
|
86
|
+
const now = input.now ?? Date.now();
|
|
87
|
+
runSqliteWriteTransaction((db) => {
|
|
88
|
+
db.prepare(`INSERT INTO outcome_contracts (
|
|
89
|
+
outcome_id, version, objective, deliverables_json, acceptance_criteria_json,
|
|
90
|
+
constraints_json, approval_required_json, context_snapshot_id, created_by, created_at
|
|
91
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(input.outcomeId, version, objective, JSON.stringify(input.deliverables), JSON.stringify(input.acceptanceCriteria), JSON.stringify(input.constraints), JSON.stringify(input.approvalRequired), input.contextSnapshotId ?? null, input.createdBy, now);
|
|
92
|
+
db.prepare(`UPDATE outcomes SET objective = ?, latest_contract_version = ?, updated_at = ?
|
|
93
|
+
WHERE outcome_id = ?`).run(objective, version, now, input.outcomeId);
|
|
94
|
+
});
|
|
95
|
+
return this.get(input.outcomeId);
|
|
96
|
+
}
|
|
97
|
+
updateState(input) {
|
|
98
|
+
const now = input.now ?? Date.now();
|
|
99
|
+
getSqliteDatabase().prepare(`UPDATE outcomes SET user_status = ?, internal_status = ?,
|
|
100
|
+
latest_receipt_run_id = COALESCE(?, latest_receipt_run_id), updated_at = ?
|
|
101
|
+
WHERE outcome_id = ?`).run(input.userStatus, input.internalStatus, input.latestReceiptRunId ?? null, now, input.id);
|
|
102
|
+
return this.get(input.id);
|
|
103
|
+
}
|
|
104
|
+
addLink(outcomeId, link, now = Date.now()) {
|
|
105
|
+
getSqliteDatabase().prepare(`INSERT INTO outcome_links (outcome_id, subject_kind, subject_id, relation, created_at)
|
|
106
|
+
VALUES (?, ?, ?, ?, ?)
|
|
107
|
+
ON CONFLICT(outcome_id, subject_kind, subject_id)
|
|
108
|
+
DO UPDATE SET relation = excluded.relation`).run(outcomeId, link.kind, link.id, link.relation ?? "supports", now);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
//#endregion
|
|
112
|
+
export { OutcomeRepository };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ExecutionContract, type ExecutionEvidence, type ExecutionReceipt, type ExecutionReceiptStatus } from '../storage/sqlite/index.js';
|
|
2
|
+
import type { ExecutionContext } from './execution-context.js';
|
|
3
|
+
export declare class OutcomeRunCoordinator {
|
|
4
|
+
#private;
|
|
5
|
+
readonly runId: string;
|
|
6
|
+
readonly context: ExecutionContext;
|
|
7
|
+
readonly contract?: ExecutionContract;
|
|
8
|
+
private constructor();
|
|
9
|
+
static start(input: {
|
|
10
|
+
runId: string;
|
|
11
|
+
context: ExecutionContext;
|
|
12
|
+
fallbackObjective: string;
|
|
13
|
+
}): OutcomeRunCoordinator;
|
|
14
|
+
addEvidence(evidence: ExecutionEvidence): void;
|
|
15
|
+
capturePlan(items: Array<{
|
|
16
|
+
title: string;
|
|
17
|
+
status: string;
|
|
18
|
+
}>): void;
|
|
19
|
+
capturePatch(added: number, removed: number): void;
|
|
20
|
+
captureCommand(command: string, durationMs?: number): void;
|
|
21
|
+
finalize(input: {
|
|
22
|
+
status: Exclude<ExecutionReceiptStatus, 'running'>;
|
|
23
|
+
summary: string;
|
|
24
|
+
}): ExecutionReceipt | undefined;
|
|
25
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { completeExecutionReceipt, startExecutionReceipt, updateExecutionReceipt } from "../storage/sqlite/execution-receipt-repository.js";
|
|
2
|
+
import "../storage/sqlite/index.js";
|
|
3
|
+
import { GoalService } from "../goals/goal-service.js";
|
|
4
|
+
import { OutcomeRepository } from "./outcome-repository.js";
|
|
5
|
+
import "../goals/index.js";
|
|
6
|
+
import { executionReceiptContext } from "./execution-context.js";
|
|
7
|
+
import { OutcomeProjectionService } from "./outcome-projection-service.js";
|
|
8
|
+
import { ContextCompiler } from "../user-context/context-compiler.js";
|
|
9
|
+
//#region src/work/outcome-run-coordinator.ts
|
|
10
|
+
var OutcomeRunCoordinator = class OutcomeRunCoordinator {
|
|
11
|
+
#evidence = [];
|
|
12
|
+
#goals = new GoalService();
|
|
13
|
+
#outcomes = new OutcomeRepository();
|
|
14
|
+
#projection = new OutcomeProjectionService();
|
|
15
|
+
#contextCompiler = new ContextCompiler();
|
|
16
|
+
#startedAt = Date.now();
|
|
17
|
+
contract;
|
|
18
|
+
constructor(runId, context, fallbackObjective) {
|
|
19
|
+
this.runId = runId;
|
|
20
|
+
this.context = context;
|
|
21
|
+
const outcome = context.outcomeId ? this.#outcomes.get(context.outcomeId) : void 0;
|
|
22
|
+
const contract = outcome?.contract;
|
|
23
|
+
this.contract = contract ? {
|
|
24
|
+
objective: contract.objective,
|
|
25
|
+
deliverables: contract.deliverables,
|
|
26
|
+
acceptanceCriteria: contract.acceptanceCriteria,
|
|
27
|
+
constraints: contract.constraints,
|
|
28
|
+
approvalRequired: contract.approvalRequired
|
|
29
|
+
} : void 0;
|
|
30
|
+
startExecutionReceipt({
|
|
31
|
+
runId,
|
|
32
|
+
sessionKey: context.sessionKey,
|
|
33
|
+
channel: context.channel,
|
|
34
|
+
objective: outcome?.objective ?? contract?.objective ?? fallbackObjective.trim(),
|
|
35
|
+
context: executionReceiptContext(context),
|
|
36
|
+
...this.contract ? { contract: this.contract } : {},
|
|
37
|
+
...contract ? { contractVersion: contract.version } : {}
|
|
38
|
+
});
|
|
39
|
+
if (outcome) this.#outcomes.updateState({
|
|
40
|
+
id: outcome.id,
|
|
41
|
+
userStatus: "running",
|
|
42
|
+
internalStatus: "running"
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
static start(input) {
|
|
46
|
+
return new OutcomeRunCoordinator(input.runId, input.context, input.fallbackObjective);
|
|
47
|
+
}
|
|
48
|
+
addEvidence(evidence) {
|
|
49
|
+
if (this.#evidence.some((item) => item.kind === evidence.kind && item.title === evidence.title)) return;
|
|
50
|
+
this.#evidence.push(evidence);
|
|
51
|
+
}
|
|
52
|
+
capturePlan(items) {
|
|
53
|
+
for (const item of items) {
|
|
54
|
+
if (item.status !== "completed") continue;
|
|
55
|
+
this.addEvidence({
|
|
56
|
+
kind: "state",
|
|
57
|
+
title: `Plan item completed: ${item.title}`,
|
|
58
|
+
summary: "The execution agent marked this plan item as completed."
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
capturePatch(added, removed) {
|
|
63
|
+
this.addEvidence({
|
|
64
|
+
kind: "state",
|
|
65
|
+
title: "Changes applied",
|
|
66
|
+
summary: `${added} additions and ${removed} removals`
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
captureCommand(command, durationMs) {
|
|
70
|
+
if (!/(^|\s)(test|vitest|jest|pytest|lint|typecheck|build)(\s|$|:)/i.test(command)) return;
|
|
71
|
+
this.addEvidence({
|
|
72
|
+
kind: "test",
|
|
73
|
+
title: command.slice(0, 120),
|
|
74
|
+
summary: durationMs === void 0 ? "Command completed successfully" : `Command completed successfully in ${durationMs} ms`
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
finalize(input) {
|
|
78
|
+
const goal = this.context.goalId ? this.#goals.get(this.context.goalId) : void 0;
|
|
79
|
+
const contextSnapshot = this.#contextCompiler.latestForSession(this.context.sessionKey, this.#startedAt);
|
|
80
|
+
if (contextSnapshot) this.#contextCompiler.linkToRun({
|
|
81
|
+
snapshotId: contextSnapshot.id,
|
|
82
|
+
outcomeId: this.context.outcomeId,
|
|
83
|
+
runId: this.runId
|
|
84
|
+
});
|
|
85
|
+
const criteria = new Set(this.contract?.acceptanceCriteria ?? []);
|
|
86
|
+
for (const item of goal?.checklist ?? []) {
|
|
87
|
+
if (item.status !== "completed" || !criteria.has(item.text)) continue;
|
|
88
|
+
this.addEvidence({
|
|
89
|
+
kind: "state",
|
|
90
|
+
title: `Independently verified: ${item.text}`,
|
|
91
|
+
summary: item.evidenceSummary ?? "The goal judge marked this acceptance criterion complete.",
|
|
92
|
+
verifies: [item.text]
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (this.context.outcomeId) this.#outcomes.updateState({
|
|
96
|
+
id: this.context.outcomeId,
|
|
97
|
+
userStatus: goal?.status === "needs_input" ? "needs_user" : "running",
|
|
98
|
+
internalStatus: goal?.status === "needs_input" ? "needs_user" : "verifying"
|
|
99
|
+
});
|
|
100
|
+
updateExecutionReceipt({
|
|
101
|
+
runId: this.runId,
|
|
102
|
+
...this.contract ? { contract: this.contract } : {},
|
|
103
|
+
evidence: this.#evidence,
|
|
104
|
+
nextAction: goal?.nextAction ?? null,
|
|
105
|
+
needsUser: goal?.status === "needs_input",
|
|
106
|
+
contextTraceId: contextSnapshot?.id ?? this.context.contextTraceId ?? null
|
|
107
|
+
});
|
|
108
|
+
const outcome = completeExecutionReceipt({
|
|
109
|
+
runId: this.runId,
|
|
110
|
+
status: input.status,
|
|
111
|
+
summary: input.summary
|
|
112
|
+
});
|
|
113
|
+
return outcome ? this.#projection.project(outcome) : void 0;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
//#endregion
|
|
117
|
+
export { OutcomeRunCoordinator };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MonitoringMode, ProjectMonitoringPolicy, QuietHours } from '@xopcai/gateway-contract';
|
|
2
|
+
export type ProactiveDisposition = 'record_silently' | 'show_in_work' | 'request_approval' | 'auto_execute';
|
|
3
|
+
export declare function decideProactiveDisposition(policy: ProjectMonitoringPolicy, input: {
|
|
4
|
+
confidence: number;
|
|
5
|
+
valueScore: number;
|
|
6
|
+
risk: 'low' | 'medium' | 'high';
|
|
7
|
+
actionId?: string;
|
|
8
|
+
requiresApproval?: boolean;
|
|
9
|
+
}): ProactiveDisposition;
|
|
10
|
+
export declare class ProjectMonitoringService {
|
|
11
|
+
#private;
|
|
12
|
+
get(projectId: string): ProjectMonitoringPolicy;
|
|
13
|
+
configure(input: {
|
|
14
|
+
projectId: string;
|
|
15
|
+
mode: MonitoringMode;
|
|
16
|
+
quietHours?: QuietHours;
|
|
17
|
+
allowedActions?: string[];
|
|
18
|
+
confidenceThreshold?: number;
|
|
19
|
+
scenarios?: string[];
|
|
20
|
+
}): ProjectMonitoringPolicy;
|
|
21
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { getSqliteDatabase, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
+
import { ProactiveScenarioService } from "../proactive/scenarios/service.js";
|
|
3
|
+
//#region src/work/project-monitoring-service.ts
|
|
4
|
+
const DEFAULT_SCENARIOS = ["project_delivery_risk", "blocked_work"];
|
|
5
|
+
function validHour(value) {
|
|
6
|
+
return Number.isInteger(value) && value >= 0 && value <= 23;
|
|
7
|
+
}
|
|
8
|
+
function rowToPolicy(row, scenarios) {
|
|
9
|
+
return {
|
|
10
|
+
projectId: row.project_id,
|
|
11
|
+
mode: row.mode,
|
|
12
|
+
quietHours: row.quiet_hours_json ? JSON.parse(row.quiet_hours_json) : void 0,
|
|
13
|
+
allowedActions: JSON.parse(row.allowed_actions_json),
|
|
14
|
+
confidenceThreshold: row.confidence_threshold,
|
|
15
|
+
scenarios,
|
|
16
|
+
configured: true,
|
|
17
|
+
updatedAt: row.updated_at
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function decideProactiveDisposition(policy, input) {
|
|
21
|
+
if (policy.mode === "observe" || input.confidence < policy.confidenceThreshold || input.valueScore < .5) return "record_silently";
|
|
22
|
+
if (input.requiresApproval || input.risk !== "low") return "request_approval";
|
|
23
|
+
if (policy.mode === "auto_low_risk" && input.actionId && policy.allowedActions.includes(input.actionId)) return "auto_execute";
|
|
24
|
+
return "show_in_work";
|
|
25
|
+
}
|
|
26
|
+
var ProjectMonitoringService = class {
|
|
27
|
+
#scenarios = new ProactiveScenarioService();
|
|
28
|
+
get(projectId) {
|
|
29
|
+
const row = getSqliteDatabase().prepare("SELECT * FROM project_monitoring_policies WHERE project_id = ?").get(projectId);
|
|
30
|
+
const scenarios = this.#scenarios.subscriptions().filter((item) => item.scopeKind === "project" && item.scopeId === projectId && item.enabled).map((item) => item.scenarioKey).sort();
|
|
31
|
+
return row ? rowToPolicy(row, scenarios) : {
|
|
32
|
+
projectId,
|
|
33
|
+
mode: "observe",
|
|
34
|
+
allowedActions: [],
|
|
35
|
+
confidenceThreshold: .75,
|
|
36
|
+
scenarios: [],
|
|
37
|
+
configured: false
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
configure(input) {
|
|
41
|
+
if (!getSqliteDatabase().prepare("SELECT 1 FROM projects WHERE project_id = ?").get(input.projectId)) throw new Error("Project not found");
|
|
42
|
+
if (input.quietHours && (!validHour(input.quietHours.startHour) || !validHour(input.quietHours.endHour) || !input.quietHours.timezone.trim())) throw new Error("Quiet hours need a timezone and integer hours from 0 through 23");
|
|
43
|
+
const threshold = input.confidenceThreshold ?? .75;
|
|
44
|
+
if (!Number.isFinite(threshold) || threshold < 0 || threshold > 1) throw new Error("confidenceThreshold must be between 0 and 1");
|
|
45
|
+
const allowedActions = [...new Set(input.allowedActions ?? [])].map((action) => action.trim()).filter(Boolean);
|
|
46
|
+
const scenarios = [...new Set(input.scenarios ?? DEFAULT_SCENARIOS)];
|
|
47
|
+
const availableScenarios = new Set(this.#scenarios.list().map((scenario) => scenario.key));
|
|
48
|
+
if (scenarios.some((scenario) => !availableScenarios.has(scenario))) throw new Error("Unknown proactive scenario");
|
|
49
|
+
const existingSubscriptions = new Set(this.#scenarios.subscriptions().filter((item) => item.scopeKind === "project" && item.scopeId === input.projectId).map((item) => item.scenarioKey));
|
|
50
|
+
const now = Date.now();
|
|
51
|
+
runSqliteWriteTransaction((db) => {
|
|
52
|
+
db.prepare(`INSERT INTO project_monitoring_policies (
|
|
53
|
+
project_id, mode, quiet_hours_json, allowed_actions_json, confidence_threshold, created_at, updated_at
|
|
54
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
55
|
+
ON CONFLICT(project_id) DO UPDATE SET mode = excluded.mode,
|
|
56
|
+
quiet_hours_json = excluded.quiet_hours_json,
|
|
57
|
+
allowed_actions_json = excluded.allowed_actions_json,
|
|
58
|
+
confidence_threshold = excluded.confidence_threshold,
|
|
59
|
+
updated_at = excluded.updated_at`).run(input.projectId, input.mode, input.quietHours ? JSON.stringify(input.quietHours) : null, JSON.stringify(allowedActions), threshold, now, now);
|
|
60
|
+
const selected = new Set(scenarios);
|
|
61
|
+
for (const scenario of availableScenarios) {
|
|
62
|
+
if (!selected.has(scenario) && !existingSubscriptions.has(scenario)) continue;
|
|
63
|
+
this.#scenarios.subscribe({
|
|
64
|
+
scenarioKey: scenario,
|
|
65
|
+
workspaceId: "default",
|
|
66
|
+
scopeKind: "project",
|
|
67
|
+
scopeId: input.projectId,
|
|
68
|
+
enabled: selected.has(scenario)
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
return this.get(input.projectId);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
export { ProjectMonitoringService, decideProactiveDisposition };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProjectOperatingView } from '@xopcai/gateway-contract';
|
|
2
|
+
import { type ProjectService } from '../projects/index.js';
|
|
3
|
+
import type { WorkItemService } from '../work-items/index.js';
|
|
4
|
+
export declare class ProjectOperatingViewService {
|
|
5
|
+
#private;
|
|
6
|
+
private readonly projects;
|
|
7
|
+
private readonly workItems;
|
|
8
|
+
constructor(projects: ProjectService, workItems: WorkItemService);
|
|
9
|
+
get(projectId: string): ProjectOperatingView | undefined;
|
|
10
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { GoalService } from "../goals/goal-service.js";
|
|
2
|
+
import "../goals/index.js";
|
|
3
|
+
import { OutcomeReceiptService } from "./outcome-receipt-service.js";
|
|
4
|
+
import { buildProjectLoopOverview } from "../projects/project-loop.js";
|
|
5
|
+
import "../projects/index.js";
|
|
6
|
+
import { ProjectMonitoringService } from "./project-monitoring-service.js";
|
|
7
|
+
//#region src/work/project-operating-view-service.ts
|
|
8
|
+
var ProjectOperatingViewService = class {
|
|
9
|
+
#goals = new GoalService();
|
|
10
|
+
#receipts = new OutcomeReceiptService();
|
|
11
|
+
#monitoring = new ProjectMonitoringService();
|
|
12
|
+
constructor(projects, workItems) {
|
|
13
|
+
this.projects = projects;
|
|
14
|
+
this.workItems = workItems;
|
|
15
|
+
}
|
|
16
|
+
get(projectId) {
|
|
17
|
+
const project = this.projects.getWithDetails(projectId);
|
|
18
|
+
if (!project) return void 0;
|
|
19
|
+
const goals = this.projects.listGoalIds(project.id, 100).map((goalId) => this.#goals.get(goalId)).filter((goal) => Boolean(goal));
|
|
20
|
+
const actions = this.workItems.listProjectWorkItems(project.id, { limit: 100 }).items.filter((item) => item.status !== "done" && item.status !== "cancelled");
|
|
21
|
+
const loop = buildProjectLoopOverview({
|
|
22
|
+
project,
|
|
23
|
+
goals,
|
|
24
|
+
recentWorkflowRuns: project.recentWorkflowRuns
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
project,
|
|
28
|
+
desiredOutcomes: goals.filter((goal) => !goal.archivedAt),
|
|
29
|
+
currentActions: actions,
|
|
30
|
+
blockers: loop.attentionItems,
|
|
31
|
+
running: project.recentWorkflowRuns.filter((run) => run.status === "queued" || run.status === "running"),
|
|
32
|
+
recentReceipts: this.#receipts.list({
|
|
33
|
+
projectId: project.id,
|
|
34
|
+
limit: 10
|
|
35
|
+
}),
|
|
36
|
+
digest: {
|
|
37
|
+
health: loop.digest.status,
|
|
38
|
+
summary: loop.digest.summary,
|
|
39
|
+
recommendedAction: loop.recommendedAction
|
|
40
|
+
},
|
|
41
|
+
monitoring: this.#monitoring.get(project.id)
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
//#endregion
|
|
46
|
+
export { ProjectOperatingViewService };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ConfirmedWork, WorkExecutionMode, WorkIntakeProposal } from '@xopcai/gateway-contract';
|
|
2
|
+
type WorkIntakeStatus = 'proposed' | 'confirmed' | 'expired' | 'cancelled';
|
|
3
|
+
export interface StoredWorkIntake {
|
|
4
|
+
idempotencyKey: string;
|
|
5
|
+
requestFingerprint: string;
|
|
6
|
+
proposal: WorkIntakeProposal;
|
|
7
|
+
sessionKey?: string;
|
|
8
|
+
agentId?: string;
|
|
9
|
+
status: WorkIntakeStatus;
|
|
10
|
+
executionMode: WorkExecutionMode;
|
|
11
|
+
projectId?: string;
|
|
12
|
+
goalId?: string;
|
|
13
|
+
outcomeId?: string;
|
|
14
|
+
queueId?: string;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
confirmedAt?: number;
|
|
17
|
+
updatedAt: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class WorkIntakeRepository {
|
|
20
|
+
create(input: {
|
|
21
|
+
idempotencyKey: string;
|
|
22
|
+
requestFingerprint: string;
|
|
23
|
+
proposal: WorkIntakeProposal;
|
|
24
|
+
sessionKey?: string;
|
|
25
|
+
agentId?: string;
|
|
26
|
+
now?: number;
|
|
27
|
+
}): StoredWorkIntake;
|
|
28
|
+
get(intakeId: string, now?: number): StoredWorkIntake | undefined;
|
|
29
|
+
getByIdempotencyKey(idempotencyKey: string, now?: number): StoredWorkIntake | undefined;
|
|
30
|
+
listPendingExecution(limit?: number): StoredWorkIntake[];
|
|
31
|
+
markConfirmed(input: {
|
|
32
|
+
intakeId: string;
|
|
33
|
+
executionMode: WorkExecutionMode;
|
|
34
|
+
projectId?: string;
|
|
35
|
+
goalId: string;
|
|
36
|
+
outcomeId: string;
|
|
37
|
+
sessionKey?: string;
|
|
38
|
+
queueId?: string;
|
|
39
|
+
now?: number;
|
|
40
|
+
}): StoredWorkIntake;
|
|
41
|
+
setExecution(input: {
|
|
42
|
+
intakeId: string;
|
|
43
|
+
sessionKey?: string;
|
|
44
|
+
queueId: string;
|
|
45
|
+
now?: number;
|
|
46
|
+
}): StoredWorkIntake;
|
|
47
|
+
toConfirmedWork(stored: StoredWorkIntake): ConfirmedWork | undefined;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { getSqliteDatabase, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
+
//#region src/work/work-intake-repository.ts
|
|
3
|
+
function fromRow(row) {
|
|
4
|
+
return {
|
|
5
|
+
idempotencyKey: row.idempotency_key,
|
|
6
|
+
requestFingerprint: row.request_fingerprint,
|
|
7
|
+
proposal: JSON.parse(row.proposal_json),
|
|
8
|
+
...row.session_key ? { sessionKey: row.session_key } : {},
|
|
9
|
+
...row.agent_id ? { agentId: row.agent_id } : {},
|
|
10
|
+
status: row.status,
|
|
11
|
+
executionMode: row.execution_mode,
|
|
12
|
+
...row.project_id ? { projectId: row.project_id } : {},
|
|
13
|
+
...row.goal_id ? { goalId: row.goal_id } : {},
|
|
14
|
+
...row.outcome_id ? { outcomeId: row.outcome_id } : {},
|
|
15
|
+
...row.queue_id ? { queueId: row.queue_id } : {},
|
|
16
|
+
createdAt: row.created_at,
|
|
17
|
+
...row.confirmed_at === null ? {} : { confirmedAt: row.confirmed_at },
|
|
18
|
+
updatedAt: row.updated_at
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function selectBy(column, value) {
|
|
22
|
+
const row = getSqliteDatabase().prepare(`SELECT * FROM work_intakes WHERE ${column} = ?`).get(value);
|
|
23
|
+
return row ? fromRow(row) : void 0;
|
|
24
|
+
}
|
|
25
|
+
var WorkIntakeRepository = class {
|
|
26
|
+
create(input) {
|
|
27
|
+
const now = input.now ?? Date.now();
|
|
28
|
+
return runSqliteWriteTransaction((db) => {
|
|
29
|
+
db.prepare(`INSERT INTO work_intakes (
|
|
30
|
+
intake_id, idempotency_key, request_fingerprint, objective, proposal_json, session_key, agent_id,
|
|
31
|
+
status, execution_mode, expires_at, created_at, updated_at
|
|
32
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, 'proposed', 'run_now', ?, ?, ?)
|
|
33
|
+
ON CONFLICT(idempotency_key) DO NOTHING`).run(input.proposal.id, input.idempotencyKey, input.requestFingerprint, input.proposal.objective, JSON.stringify(input.proposal), input.sessionKey ?? null, input.agentId ?? null, input.proposal.expiresAt, now, now);
|
|
34
|
+
const stored = selectBy("idempotency_key", input.idempotencyKey);
|
|
35
|
+
if (!stored) throw new Error("Failed to persist work intake");
|
|
36
|
+
return stored;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
get(intakeId, now = Date.now()) {
|
|
40
|
+
const stored = selectBy("intake_id", intakeId);
|
|
41
|
+
if (!stored || stored.status !== "proposed" || stored.proposal.expiresAt > now) return stored;
|
|
42
|
+
runSqliteWriteTransaction((db) => {
|
|
43
|
+
db.prepare(`UPDATE work_intakes SET status = 'expired', updated_at = ?
|
|
44
|
+
WHERE intake_id = ? AND status = 'proposed'`).run(now, intakeId);
|
|
45
|
+
});
|
|
46
|
+
return selectBy("intake_id", intakeId);
|
|
47
|
+
}
|
|
48
|
+
getByIdempotencyKey(idempotencyKey, now = Date.now()) {
|
|
49
|
+
const stored = selectBy("idempotency_key", idempotencyKey);
|
|
50
|
+
return stored ? this.get(stored.proposal.id, now) : void 0;
|
|
51
|
+
}
|
|
52
|
+
listPendingExecution(limit = 100) {
|
|
53
|
+
return getSqliteDatabase().prepare(`SELECT * FROM work_intakes
|
|
54
|
+
WHERE status = 'confirmed' AND execution_mode = 'run_now' AND queue_id IS NULL
|
|
55
|
+
ORDER BY confirmed_at ASC
|
|
56
|
+
LIMIT ?`).all(Math.min(500, Math.max(1, Math.floor(limit)))).map(fromRow);
|
|
57
|
+
}
|
|
58
|
+
markConfirmed(input) {
|
|
59
|
+
const now = input.now ?? Date.now();
|
|
60
|
+
getSqliteDatabase().prepare(`UPDATE work_intakes SET
|
|
61
|
+
status = 'confirmed', execution_mode = ?, project_id = ?, goal_id = ?,
|
|
62
|
+
outcome_id = ?, session_key = COALESCE(?, session_key), queue_id = ?,
|
|
63
|
+
confirmed_at = COALESCE(confirmed_at, ?), updated_at = ?
|
|
64
|
+
WHERE intake_id = ? AND status = 'proposed'`).run(input.executionMode, input.projectId ?? null, input.goalId, input.outcomeId, input.sessionKey ?? null, input.queueId ?? null, now, now, input.intakeId);
|
|
65
|
+
const stored = selectBy("intake_id", input.intakeId);
|
|
66
|
+
if (!stored) throw new Error("Work intake not found");
|
|
67
|
+
return stored;
|
|
68
|
+
}
|
|
69
|
+
setExecution(input) {
|
|
70
|
+
const now = input.now ?? Date.now();
|
|
71
|
+
runSqliteWriteTransaction((db) => {
|
|
72
|
+
db.prepare(`UPDATE work_intakes SET session_key = COALESCE(?, session_key), queue_id = ?, updated_at = ?
|
|
73
|
+
WHERE intake_id = ? AND status = 'confirmed'`).run(input.sessionKey ?? null, input.queueId, now, input.intakeId);
|
|
74
|
+
});
|
|
75
|
+
const stored = selectBy("intake_id", input.intakeId);
|
|
76
|
+
if (!stored) throw new Error("Work intake not found");
|
|
77
|
+
return stored;
|
|
78
|
+
}
|
|
79
|
+
toConfirmedWork(stored) {
|
|
80
|
+
if (stored.status !== "confirmed" || !stored.outcomeId || !stored.goalId) return void 0;
|
|
81
|
+
const queue = stored.queueId ? getSqliteDatabase().prepare("SELECT status, session_key FROM goal_queue WHERE queue_id = ?").get(stored.queueId) : void 0;
|
|
82
|
+
const sessionKey = queue?.session_key ?? stored.sessionKey;
|
|
83
|
+
return {
|
|
84
|
+
outcomeId: stored.outcomeId,
|
|
85
|
+
...stored.projectId ? { projectId: stored.projectId } : {},
|
|
86
|
+
goalId: stored.goalId,
|
|
87
|
+
...sessionKey ? { sessionKey } : {},
|
|
88
|
+
execution: {
|
|
89
|
+
mode: stored.executionMode,
|
|
90
|
+
status: queue?.status ?? (stored.queueId ? "queued" : "not_started"),
|
|
91
|
+
...stored.queueId ? { queueId: stored.queueId } : {}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
export { WorkIntakeRepository };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ConfirmedWork, WorkExecutionMode, WorkIntakeProposal } from '@xopcai/gateway-contract';
|
|
2
|
+
import { type EnqueueGoalRunOptions, type GoalQueueItemSnapshot } from '../goals/index.js';
|
|
3
|
+
import { ProjectService } from '../projects/index.js';
|
|
4
|
+
export interface WorkIntakeExecutionPort {
|
|
5
|
+
enqueue(goalId: string, options: EnqueueGoalRunOptions): GoalQueueItemSnapshot;
|
|
6
|
+
}
|
|
7
|
+
export declare class WorkIntakeService {
|
|
8
|
+
#private;
|
|
9
|
+
private readonly projects;
|
|
10
|
+
private readonly execution?;
|
|
11
|
+
constructor(projects: ProjectService, execution?: WorkIntakeExecutionPort);
|
|
12
|
+
propose(input: {
|
|
13
|
+
idempotencyKey: string;
|
|
14
|
+
objective: string;
|
|
15
|
+
projectId?: string;
|
|
16
|
+
sessionKey?: string;
|
|
17
|
+
agentId?: string;
|
|
18
|
+
}): WorkIntakeProposal;
|
|
19
|
+
confirm(input: {
|
|
20
|
+
proposalId: string;
|
|
21
|
+
executionMode: WorkExecutionMode;
|
|
22
|
+
projectId?: string;
|
|
23
|
+
}): ConfirmedWork | undefined;
|
|
24
|
+
reconcilePendingExecutions(): number;
|
|
25
|
+
private _ensureExecution;
|
|
26
|
+
}
|