@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,389 @@
|
|
|
1
|
+
import { isHomeAttentionAcknowledged } from "../storage/sqlite/home-attention-repository.js";
|
|
2
|
+
import { getRelationshipSettings } from "../storage/sqlite/relationship-settings-repository.js";
|
|
3
|
+
import { listConnectorApprovals } from "../storage/sqlite/connector-repository.js";
|
|
4
|
+
import "../storage/sqlite/index.js";
|
|
5
|
+
import { GoalService } from "../goals/goal-service.js";
|
|
6
|
+
import { OutcomeRepository } from "./outcome-repository.js";
|
|
7
|
+
import "../goals/index.js";
|
|
8
|
+
import { AttentionGovernor } from "./attention-governor.js";
|
|
9
|
+
import { listGatewayAgents } from "../gateway/agents-admin.js";
|
|
10
|
+
import { getTunnelService } from "../tunnel/tunnel-service.js";
|
|
11
|
+
import "../tunnel/index.js";
|
|
12
|
+
import "../automations/domain/defaults.js";
|
|
13
|
+
import "../automations/index.js";
|
|
14
|
+
import { WorkItemService } from "../work-items/work-item-service.js";
|
|
15
|
+
import "../work-items/index.js";
|
|
16
|
+
import { OutcomeReceiptService } from "./outcome-receipt-service.js";
|
|
17
|
+
//#region src/work/home-query-service.ts
|
|
18
|
+
function workItemAttentionRank(item, nowMs) {
|
|
19
|
+
if (item.status === "needs_input" || item.status === "in_review" || item.status === "blocked") return 0;
|
|
20
|
+
if (item.dueAt != null && item.dueAt < nowMs) return 1;
|
|
21
|
+
if (item.dueAt != null && item.dueAt < nowMs + 1440 * 60 * 1e3) return 2;
|
|
22
|
+
if (item.priority === "urgent") return 3;
|
|
23
|
+
return 4;
|
|
24
|
+
}
|
|
25
|
+
function toHomeWorkItem(item, projectName) {
|
|
26
|
+
return {
|
|
27
|
+
...item,
|
|
28
|
+
projectName
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function toHomeWorkflowRun(run) {
|
|
32
|
+
return {
|
|
33
|
+
id: run.id,
|
|
34
|
+
definitionId: run.definitionId,
|
|
35
|
+
title: run.title,
|
|
36
|
+
status: run.status,
|
|
37
|
+
sessionKey: run.metadata?.sessionKey,
|
|
38
|
+
createdAtMs: run.createdAtMs,
|
|
39
|
+
startedAtMs: run.startedAtMs,
|
|
40
|
+
completedAtMs: run.completedAtMs,
|
|
41
|
+
metrics: run.metrics
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function triggerLabel(automation) {
|
|
45
|
+
const trigger = automation.trigger;
|
|
46
|
+
if (trigger.kind === "manual") return "manual";
|
|
47
|
+
if (trigger.kind === "webhook") return "webhook";
|
|
48
|
+
if (trigger.kind === "event") return `event:${trigger.eventType}`;
|
|
49
|
+
const schedule = trigger.schedule;
|
|
50
|
+
if (schedule.kind === "once") return schedule.at;
|
|
51
|
+
if (schedule.kind === "interval") return `every ${Math.round(schedule.everyMs / 6e4)} minutes`;
|
|
52
|
+
return schedule.expr;
|
|
53
|
+
}
|
|
54
|
+
function actionLabel(automation) {
|
|
55
|
+
if (automation.action.kind === "workflow") return `workflow:${automation.action.workflowId}`;
|
|
56
|
+
if (automation.action.kind === "browser_recipe") return `browser-workflow:${automation.action.recipeId}`;
|
|
57
|
+
return automation.action.agentId ? `agent:${automation.action.agentId}` : "agent";
|
|
58
|
+
}
|
|
59
|
+
function toHomeAutomation(automation) {
|
|
60
|
+
if (!automation.enabled || !automation.state.nextRunAtMs) return null;
|
|
61
|
+
return {
|
|
62
|
+
id: automation.id,
|
|
63
|
+
name: automation.name,
|
|
64
|
+
trigger: triggerLabel(automation),
|
|
65
|
+
action: actionLabel(automation),
|
|
66
|
+
nextRunAt: new Date(automation.state.nextRunAtMs).toISOString()
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function toHomeAutomationRun(run) {
|
|
70
|
+
return {
|
|
71
|
+
id: run.id,
|
|
72
|
+
automationId: run.automationId,
|
|
73
|
+
automationName: run.automationName,
|
|
74
|
+
status: run.status,
|
|
75
|
+
createdAtMs: run.createdAtMs,
|
|
76
|
+
startedAtMs: run.startedAtMs,
|
|
77
|
+
endedAtMs: run.endedAtMs,
|
|
78
|
+
error: run.error,
|
|
79
|
+
summary: run.summary,
|
|
80
|
+
sessionKey: run.sessionKey,
|
|
81
|
+
workflowRunId: run.workflowRunId
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function effectiveAutomationTimeoutSeconds(run, automation) {
|
|
85
|
+
return run.actionSnapshot.timeoutSeconds ?? automation?.reliability?.timeoutSeconds ?? 1800;
|
|
86
|
+
}
|
|
87
|
+
function attentionDetail(kind, status, locale, timeoutSeconds) {
|
|
88
|
+
const isChinese = locale?.toLowerCase().startsWith("zh") ?? false;
|
|
89
|
+
if (status === "timeout") {
|
|
90
|
+
const seconds = timeoutSeconds ?? 1800;
|
|
91
|
+
const duration = seconds % 60 === 0 ? `${seconds / 60} ${isChinese ? "分钟" : seconds === 60 ? "minute" : "minutes"}` : `${seconds} ${isChinese ? "秒" : seconds === 1 ? "second" : "seconds"}`;
|
|
92
|
+
return isChinese ? `运行超过 ${duration},系统已停止本次执行。` : `The run exceeded ${duration} and was stopped.`;
|
|
93
|
+
}
|
|
94
|
+
if (isChinese) return kind === "automation_run" ? "自动化未能完成,请查看详情后重试。" : "工作流未能完成,请查看详情后重试。";
|
|
95
|
+
return kind === "automation_run" ? "The automation did not complete. Review the details and retry." : "The workflow did not complete. Review the details and retry.";
|
|
96
|
+
}
|
|
97
|
+
function decisionFromGoal(goal, projectName) {
|
|
98
|
+
if (goal.status !== "needs_input" && goal.status !== "blocked") return null;
|
|
99
|
+
return {
|
|
100
|
+
id: `goal:${goal.id}`,
|
|
101
|
+
kind: "goal",
|
|
102
|
+
title: goal.title,
|
|
103
|
+
detail: goal.blockedReason || goal.nextAction,
|
|
104
|
+
reason: goal.status,
|
|
105
|
+
urgency: "now",
|
|
106
|
+
href: `/work/${encodeURIComponent(goal.outcomeId)}`,
|
|
107
|
+
projectId: goal.projectId,
|
|
108
|
+
projectName,
|
|
109
|
+
updatedAt: goal.updatedAt
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function decisionFromWorkItem(item, projectName, nowMs) {
|
|
113
|
+
let reason;
|
|
114
|
+
let urgency = "now";
|
|
115
|
+
if (item.status === "needs_input" || item.status === "in_review" || item.status === "blocked") reason = item.status;
|
|
116
|
+
else if (item.dueAt != null && item.dueAt < nowMs) reason = "overdue";
|
|
117
|
+
else if (item.dueAt != null && item.dueAt < nowMs + 1440 * 60 * 1e3) {
|
|
118
|
+
reason = "due_soon";
|
|
119
|
+
urgency = "soon";
|
|
120
|
+
}
|
|
121
|
+
if (!reason) return null;
|
|
122
|
+
return {
|
|
123
|
+
id: `work:${item.id}`,
|
|
124
|
+
kind: "work_item",
|
|
125
|
+
title: item.title,
|
|
126
|
+
detail: item.blockedReason || item.nextAction,
|
|
127
|
+
reason,
|
|
128
|
+
urgency,
|
|
129
|
+
href: `/work-items/${encodeURIComponent(item.id)}`,
|
|
130
|
+
projectId: item.projectId,
|
|
131
|
+
projectName,
|
|
132
|
+
updatedAt: item.updatedAt
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function buildHomeBriefing(input) {
|
|
136
|
+
const isChinese = input.locale?.toLowerCase().startsWith("zh") ?? false;
|
|
137
|
+
const movingCount = input.activeWorkCount + input.activeWorkflowCount + input.activeGoalCount;
|
|
138
|
+
const attentionCount = input.decisions.length + input.attention.length;
|
|
139
|
+
const summary = attentionCount > 0 ? isChinese ? movingCount > 0 ? `有 ${attentionCount} 件事需要你处理;我正在继续推进 ${movingCount} 件工作。` : `有 ${attentionCount} 件事需要你处理。` : movingCount > 0 ? `${attentionCount} ${attentionCount === 1 ? "item needs" : "items need"} your attention; I’m continuing ${movingCount} in the background.` : `${attentionCount} ${attentionCount === 1 ? "item needs" : "items need"} your attention.` : movingCount > 0 ? isChinese ? `目前没有事情需要你处理;我正在继续推进 ${movingCount} 件工作。` : `Nothing needs you right now; I’m continuing ${movingCount} ${movingCount === 1 ? "item" : "items"} in the background.` : isChinese ? "今天还没有正在推进的事项。把想要的结果交给我,我会从这里开始。" : "Nothing is moving yet today. Hand me an outcome and I’ll take it from here.";
|
|
140
|
+
return {
|
|
141
|
+
generatedAt: input.nowMs,
|
|
142
|
+
summary,
|
|
143
|
+
focus: input.decisions.slice(0, 3),
|
|
144
|
+
progress: {
|
|
145
|
+
activeWorkCount: input.activeWorkCount,
|
|
146
|
+
activeWorkflowCount: input.activeWorkflowCount,
|
|
147
|
+
activeGoalCount: input.activeGoalCount,
|
|
148
|
+
movingCount
|
|
149
|
+
},
|
|
150
|
+
wins: input.wins.slice(0, 5),
|
|
151
|
+
nextScheduled: input.nextScheduled
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
var WorkHomeQueryService = class {
|
|
155
|
+
#goals = new GoalService();
|
|
156
|
+
#receipts = new OutcomeReceiptService();
|
|
157
|
+
#outcomes = new OutcomeRepository();
|
|
158
|
+
#attentionGovernor = new AttentionGovernor();
|
|
159
|
+
constructor(service) {
|
|
160
|
+
this.service = service;
|
|
161
|
+
}
|
|
162
|
+
async getSnapshot(locale) {
|
|
163
|
+
const notes = this.service.notesServiceInstance;
|
|
164
|
+
const sessions = this.service.sessions;
|
|
165
|
+
const agents = await listGatewayAgents(this.service.currentConfig);
|
|
166
|
+
const defaultAgent = agents.agents.find((agent) => agent.id === agents.defaultId) ?? agents.agents[0];
|
|
167
|
+
const workflowRunStore = this.service.createWorkflowRunService().createRunStore(defaultAgent?.id ?? agents.defaultId);
|
|
168
|
+
const tunnel = getTunnelService().getStatus();
|
|
169
|
+
const health = this.service.getHealth();
|
|
170
|
+
const workItems = new WorkItemService();
|
|
171
|
+
const nowMs = Date.now();
|
|
172
|
+
const outcomes = this.#outcomes.list({ limit: 60 });
|
|
173
|
+
const [recentlyOpened, inbox, pendingTasks, recentSessions, workflowRuns, automations, automationRuns, projects, allWorkItems, activeGoals, connectorApprovals] = await Promise.all([
|
|
174
|
+
notes.listNotes({
|
|
175
|
+
sortBy: "lastOpenedAt",
|
|
176
|
+
sortOrder: "desc",
|
|
177
|
+
limit: 10
|
|
178
|
+
}),
|
|
179
|
+
notes.listNotes({
|
|
180
|
+
status: "inbox",
|
|
181
|
+
limit: 0
|
|
182
|
+
}),
|
|
183
|
+
notes.listNotes({
|
|
184
|
+
pendingTasksOnly: true,
|
|
185
|
+
sortBy: "createdAt",
|
|
186
|
+
sortOrder: "desc",
|
|
187
|
+
limit: 10
|
|
188
|
+
}),
|
|
189
|
+
sessions.listSessions({
|
|
190
|
+
channel: "webchat",
|
|
191
|
+
sortBy: "updatedAt",
|
|
192
|
+
sortOrder: "desc",
|
|
193
|
+
limit: 50
|
|
194
|
+
}),
|
|
195
|
+
workflowRunStore.listRunSummaries(20),
|
|
196
|
+
this.service.automationServiceInstance.list(),
|
|
197
|
+
this.service.automationServiceInstance.listRuns({ limit: 10 }),
|
|
198
|
+
this.service.projects.list({ limit: 500 }),
|
|
199
|
+
Promise.resolve(workItems.listWorkItems({ limit: 100 })),
|
|
200
|
+
Promise.resolve(this.#goals.list({
|
|
201
|
+
status: [
|
|
202
|
+
"active",
|
|
203
|
+
"blocked",
|
|
204
|
+
"needs_input",
|
|
205
|
+
"paused"
|
|
206
|
+
],
|
|
207
|
+
limit: 100
|
|
208
|
+
})),
|
|
209
|
+
Promise.resolve(listConnectorApprovals({
|
|
210
|
+
principalId: "local-owner",
|
|
211
|
+
status: "pending",
|
|
212
|
+
limit: 100
|
|
213
|
+
}))
|
|
214
|
+
]);
|
|
215
|
+
const projectsById = new Map(projects.items.map((project) => [project.id, project]));
|
|
216
|
+
const workChats = recentSessions.items.filter((session) => (session.messageCount ?? 0) > 0).map((session) => ({
|
|
217
|
+
key: session.key,
|
|
218
|
+
name: session.name || "Conversation",
|
|
219
|
+
updatedAt: session.updatedAt,
|
|
220
|
+
active: sessions.getActiveRun(session.key).active
|
|
221
|
+
}));
|
|
222
|
+
const activeWorkItems = allWorkItems.items.filter((item) => item.status !== "done" && item.status !== "cancelled").sort((left, right) => {
|
|
223
|
+
return workItemAttentionRank(left, nowMs) - workItemAttentionRank(right, nowMs) || right.updatedAt - left.updatedAt;
|
|
224
|
+
});
|
|
225
|
+
const attentionWorkItems = activeWorkItems.filter((item) => workItemAttentionRank(item, nowMs) < 4).slice(0, 8).map((item) => toHomeWorkItem(item, projectsById.get(item.projectId)?.name ?? "Project"));
|
|
226
|
+
const currentWorkItems = activeWorkItems.slice(0, 30).map((item) => toHomeWorkItem(item, projectsById.get(item.projectId)?.name ?? "Project"));
|
|
227
|
+
const recentlyCompletedWorkItems = allWorkItems.items.filter((item) => item.status === "done").sort((left, right) => (right.completedAt ?? right.updatedAt) - (left.completedAt ?? left.updatedAt)).slice(0, 8).map((item) => toHomeWorkItem(item, projectsById.get(item.projectId)?.name ?? "Project"));
|
|
228
|
+
const activeWorkflowRuns = workflowRuns.filter((run) => run.status === "queued" || run.status === "running").slice(0, 5).map(toHomeWorkflowRun);
|
|
229
|
+
const failedWorkflowRuns = workflowRuns.filter((run) => run.status === "failed" || run.status === "timeout").slice(0, 5).map(toHomeWorkflowRun);
|
|
230
|
+
const recentWorkflowRuns = workflowRuns.slice(0, 5).map(toHomeWorkflowRun);
|
|
231
|
+
const upcomingAutomations = automations.map(toHomeAutomation).filter((automation) => Boolean(automation)).sort((a, b) => Date.parse(a.nextRunAt) - Date.parse(b.nextRunAt)).slice(0, 5);
|
|
232
|
+
const latestAutomationRuns = [...automationRuns].sort((left, right) => right.createdAtMs - left.createdAtMs).filter((run, index, all) => all.findIndex((candidate) => candidate.automationId === run.automationId) === index);
|
|
233
|
+
const automationsById = new Map(automations.map((automation) => [automation.id, automation]));
|
|
234
|
+
const decisionCandidates = [
|
|
235
|
+
...this.service.proactiveInbox.list({ limit: 20 }).filter((item) => item.status === "unread" || item.status === "read").map((item) => ({
|
|
236
|
+
id: `agent-judgment:${item.id}`,
|
|
237
|
+
kind: "agent_judgment",
|
|
238
|
+
title: item.insight.title,
|
|
239
|
+
detail: item.insight.summary,
|
|
240
|
+
reason: "decision_needed",
|
|
241
|
+
urgency: item.insight.urgency === "critical" || item.insight.urgency === "high" ? "now" : "soon",
|
|
242
|
+
href: `/work?judgment=${encodeURIComponent(item.id)}`,
|
|
243
|
+
updatedAt: Date.parse(item.updatedAt),
|
|
244
|
+
judgment: {
|
|
245
|
+
inboxItemId: item.id,
|
|
246
|
+
whyNow: item.insight.whyNow,
|
|
247
|
+
impact: item.insight.impact,
|
|
248
|
+
workDone: item.insight.workDone,
|
|
249
|
+
recommendation: item.insight.recommendation,
|
|
250
|
+
confidence: item.insight.confidence,
|
|
251
|
+
valueScore: item.insight.valueScore,
|
|
252
|
+
...item.insight.decision ? { decision: item.insight.decision } : {}
|
|
253
|
+
}
|
|
254
|
+
})),
|
|
255
|
+
...activeWorkItems.map((item) => decisionFromWorkItem(item, projectsById.get(item.projectId)?.name ?? "Project", nowMs)).filter((item) => Boolean(item)),
|
|
256
|
+
...activeGoals.map((goal) => decisionFromGoal(goal, goal.projectId ? projectsById.get(goal.projectId)?.name : void 0)).filter((item) => Boolean(item)),
|
|
257
|
+
...connectorApprovals.filter((approval) => Date.parse(approval.expiresAt) > nowMs).map((approval) => ({
|
|
258
|
+
id: `connector-approval:${approval.id}`,
|
|
259
|
+
kind: "connector_approval",
|
|
260
|
+
title: approval.actionId,
|
|
261
|
+
detail: `${approval.connectorId} · ${approval.scope}`,
|
|
262
|
+
reason: "approval_required",
|
|
263
|
+
urgency: "now",
|
|
264
|
+
href: "/connectors",
|
|
265
|
+
updatedAt: Date.parse(approval.createdAt),
|
|
266
|
+
response: {
|
|
267
|
+
kind: "connector_approval",
|
|
268
|
+
approvalId: approval.id
|
|
269
|
+
}
|
|
270
|
+
}))
|
|
271
|
+
];
|
|
272
|
+
const attentionCandidates = [...failedWorkflowRuns.filter((run) => !isHomeAttentionAcknowledged("workflow_run", run.id)).map((run) => ({
|
|
273
|
+
id: `workflow_run:${run.id}`,
|
|
274
|
+
kind: "workflow_run",
|
|
275
|
+
runId: run.id,
|
|
276
|
+
title: run.title,
|
|
277
|
+
detail: attentionDetail("workflow_run", run.status === "timeout" ? "timeout" : "failed", locale),
|
|
278
|
+
reason: run.status === "timeout" ? "run_timeout" : "run_failed",
|
|
279
|
+
href: `/workflows?runId=${encodeURIComponent(run.id)}`,
|
|
280
|
+
updatedAt: run.completedAtMs ?? run.startedAtMs ?? run.createdAtMs,
|
|
281
|
+
sessionKey: run.sessionKey
|
|
282
|
+
})), ...latestAutomationRuns.filter((run) => run.status === "failed" || run.status === "timeout").filter((run) => !isHomeAttentionAcknowledged("automation_run", run.id)).map((run) => ({
|
|
283
|
+
id: `automation_run:${run.id}`,
|
|
284
|
+
kind: "automation_run",
|
|
285
|
+
runId: run.id,
|
|
286
|
+
title: run.automationName || run.automationId,
|
|
287
|
+
detail: attentionDetail("automation_run", run.status === "timeout" ? "timeout" : "failed", locale, effectiveAutomationTimeoutSeconds(run, automationsById.get(run.automationId))),
|
|
288
|
+
reason: run.status === "timeout" ? "run_timeout" : "run_failed",
|
|
289
|
+
href: `/automations?run=${encodeURIComponent(run.id)}`,
|
|
290
|
+
updatedAt: run.endedAtMs ?? run.startedAtMs ?? run.createdAtMs,
|
|
291
|
+
sessionKey: run.sessionKey
|
|
292
|
+
}))].sort((left, right) => right.updatedAt - left.updatedAt);
|
|
293
|
+
const governed = this.#attentionGovernor.project({
|
|
294
|
+
decisions: decisionCandidates,
|
|
295
|
+
attention: attentionCandidates,
|
|
296
|
+
proactiveEnabled: getRelationshipSettings().proactiveEnabled
|
|
297
|
+
});
|
|
298
|
+
const decisions = governed.decisions;
|
|
299
|
+
const attention = governed.attention;
|
|
300
|
+
const wins = [
|
|
301
|
+
...recentlyCompletedWorkItems.map((item) => ({
|
|
302
|
+
id: `work:${item.id}`,
|
|
303
|
+
kind: "work_item",
|
|
304
|
+
title: item.title,
|
|
305
|
+
href: `/work-items/${encodeURIComponent(item.id)}`,
|
|
306
|
+
completedAt: item.completedAt ?? item.updatedAt
|
|
307
|
+
})),
|
|
308
|
+
...workflowRuns.filter((run) => run.status === "succeeded").map((run) => ({
|
|
309
|
+
id: `workflow:${run.id}`,
|
|
310
|
+
kind: "workflow_run",
|
|
311
|
+
title: run.title,
|
|
312
|
+
href: `/workflows?runId=${encodeURIComponent(run.id)}`,
|
|
313
|
+
completedAt: run.completedAtMs ?? run.createdAtMs
|
|
314
|
+
})),
|
|
315
|
+
...latestAutomationRuns.filter((run) => run.status === "succeeded").map((run) => ({
|
|
316
|
+
id: `automation:${run.id}`,
|
|
317
|
+
kind: "automation_run",
|
|
318
|
+
title: run.automationName || run.automationId,
|
|
319
|
+
href: "/automations",
|
|
320
|
+
completedAt: run.endedAtMs ?? run.createdAtMs
|
|
321
|
+
}))
|
|
322
|
+
].sort((left, right) => right.completedAt - left.completedAt);
|
|
323
|
+
const briefing = buildHomeBriefing({
|
|
324
|
+
locale,
|
|
325
|
+
decisions,
|
|
326
|
+
attention,
|
|
327
|
+
activeWorkCount: activeWorkItems.filter((item) => item.status === "in_progress").length,
|
|
328
|
+
activeWorkflowCount: activeWorkflowRuns.length,
|
|
329
|
+
activeGoalCount: activeGoals.filter((goal) => goal.status === "active").length,
|
|
330
|
+
wins,
|
|
331
|
+
nextScheduled: upcomingAutomations[0],
|
|
332
|
+
nowMs
|
|
333
|
+
});
|
|
334
|
+
return {
|
|
335
|
+
recentlyOpened: recentlyOpened.items.filter((note) => note.lastOpenedAt),
|
|
336
|
+
inboxCount: inbox.total,
|
|
337
|
+
pendingTasks: pendingTasks.items,
|
|
338
|
+
pendingTaskCount: pendingTasks.total,
|
|
339
|
+
recentSessions: recentSessions.items.slice(0, 5),
|
|
340
|
+
activeAgent: defaultAgent ? {
|
|
341
|
+
id: defaultAgent.id,
|
|
342
|
+
name: defaultAgent.name,
|
|
343
|
+
description: defaultAgent.description
|
|
344
|
+
} : { id: agents.defaultId },
|
|
345
|
+
gateway: {
|
|
346
|
+
status: health.status,
|
|
347
|
+
ready: health.ready,
|
|
348
|
+
httpListening: health.httpListening,
|
|
349
|
+
version: health.version,
|
|
350
|
+
uptime: health.uptime,
|
|
351
|
+
tunnel: {
|
|
352
|
+
state: tunnel.state,
|
|
353
|
+
publicUrl: tunnel.publicUrl,
|
|
354
|
+
connected: tunnel.state === "connected"
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
workflowRuns: {
|
|
358
|
+
active: activeWorkflowRuns,
|
|
359
|
+
recent: recentWorkflowRuns
|
|
360
|
+
},
|
|
361
|
+
briefing,
|
|
362
|
+
decisions,
|
|
363
|
+
attention,
|
|
364
|
+
attentionPolicy: governed.policy,
|
|
365
|
+
chats: {
|
|
366
|
+
running: workChats.filter((chat) => chat.active),
|
|
367
|
+
recent: workChats.filter((chat) => !chat.active).slice(0, 8)
|
|
368
|
+
},
|
|
369
|
+
work: {
|
|
370
|
+
attentionCount: activeWorkItems.filter((item) => workItemAttentionRank(item, nowMs) < 3).length,
|
|
371
|
+
overdueCount: activeWorkItems.filter((item) => item.dueAt != null && item.dueAt < nowMs).length,
|
|
372
|
+
todayCount: activeWorkItems.filter((item) => item.dueAt != null && item.dueAt >= nowMs && item.dueAt < nowMs + 1440 * 60 * 1e3).length,
|
|
373
|
+
items: attentionWorkItems,
|
|
374
|
+
current: currentWorkItems,
|
|
375
|
+
recentlyCompleted: recentlyCompletedWorkItems
|
|
376
|
+
},
|
|
377
|
+
upcomingAutomations,
|
|
378
|
+
outcomes: {
|
|
379
|
+
running: outcomes.filter((outcome) => outcome.userStatus === "running").slice(0, 20),
|
|
380
|
+
needsUser: outcomes.filter((outcome) => outcome.userStatus === "needs_user").slice(0, 20),
|
|
381
|
+
recentlyCompleted: outcomes.filter((outcome) => outcome.userStatus === "completed").slice(0, 10)
|
|
382
|
+
},
|
|
383
|
+
recentOutcomes: this.#receipts.list({ limit: 20 }).filter((receipt) => receipt.status !== "running").slice(0, 8),
|
|
384
|
+
recentAutomationRuns: automationRuns.slice(0, 5).map(toHomeAutomationRun)
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
//#endregion
|
|
389
|
+
export { WorkHomeQueryService, buildHomeBriefing, decisionFromGoal, workItemAttentionRank };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './execution-context.js';
|
|
2
|
+
export * from './attention-governor.js';
|
|
3
|
+
export * from './home-query-service.js';
|
|
4
|
+
export * from './outcome-receipt-service.js';
|
|
5
|
+
export * from './outcome-projection-service.js';
|
|
6
|
+
export * from './outcome-repository.js';
|
|
7
|
+
export * from './outcome-execution-service.js';
|
|
8
|
+
export * from './outcome-contract-definition.js';
|
|
9
|
+
export * from './outcome-run-coordinator.js';
|
|
10
|
+
export * from './project-operating-view-service.js';
|
|
11
|
+
export * from './project-monitoring-service.js';
|
|
12
|
+
export * from './work-intake-service.js';
|
|
13
|
+
export * from './work-intake-repository.js';
|
|
14
|
+
export * from './work-value-metrics-service.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OutcomeRepository } from "./outcome-repository.js";
|
|
2
|
+
import { executionReceiptContext, resolveExecutionContext } from "./execution-context.js";
|
|
3
|
+
import { AttentionGovernor } from "./attention-governor.js";
|
|
4
|
+
import { OutcomeReceiptService, toOutcomeReceipt } from "./outcome-receipt-service.js";
|
|
5
|
+
import { WorkHomeQueryService, buildHomeBriefing, decisionFromGoal, workItemAttentionRank } from "./home-query-service.js";
|
|
6
|
+
import { EXECUTION_RECEIPT_PROJECTION_VERSION, OutcomeProjectionService } from "./outcome-projection-service.js";
|
|
7
|
+
import { OutcomeExecutionService } from "./outcome-execution-service.js";
|
|
8
|
+
import { defineOutcomeContract } from "./outcome-contract-definition.js";
|
|
9
|
+
import { OutcomeRunCoordinator } from "./outcome-run-coordinator.js";
|
|
10
|
+
import { ProjectMonitoringService, decideProactiveDisposition } from "./project-monitoring-service.js";
|
|
11
|
+
import { ProjectOperatingViewService } from "./project-operating-view-service.js";
|
|
12
|
+
import { WorkIntakeRepository } from "./work-intake-repository.js";
|
|
13
|
+
import { WorkIntakeService } from "./work-intake-service.js";
|
|
14
|
+
import { WorkValueMetricsService } from "./work-value-metrics-service.js";
|
|
15
|
+
export { AttentionGovernor, EXECUTION_RECEIPT_PROJECTION_VERSION, OutcomeExecutionService, OutcomeProjectionService, OutcomeReceiptService, OutcomeRepository, OutcomeRunCoordinator, ProjectMonitoringService, ProjectOperatingViewService, WorkHomeQueryService, WorkIntakeRepository, WorkIntakeService, WorkValueMetricsService, buildHomeBriefing, decideProactiveDisposition, decisionFromGoal, defineOutcomeContract, executionReceiptContext, resolveExecutionContext, toOutcomeReceipt, workItemAttentionRank };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface OutcomeContractDefinition {
|
|
2
|
+
objective: string;
|
|
3
|
+
deliverables: string[];
|
|
4
|
+
acceptanceCriteria: string[];
|
|
5
|
+
constraints: string[];
|
|
6
|
+
approvalRequired: string[];
|
|
7
|
+
}
|
|
8
|
+
export declare function defineOutcomeContract(objectiveInput: string): OutcomeContractDefinition;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/work/outcome-contract-definition.ts
|
|
2
|
+
function defineOutcomeContract(objectiveInput) {
|
|
3
|
+
const objective = objectiveInput.trim();
|
|
4
|
+
if (!objective) throw new Error("Objective is required");
|
|
5
|
+
const chinese = /[\u3400-\u9fff]/u.test(objective);
|
|
6
|
+
return {
|
|
7
|
+
objective,
|
|
8
|
+
deliverables: [objective],
|
|
9
|
+
acceptanceCriteria: chinese ? [`已交付:${objective}`, "结果有可检查的证据,并满足用户明确提出的约束。"] : [`Delivered: ${objective}`, "The result has inspectable evidence and satisfies the user-provided constraints."],
|
|
10
|
+
constraints: [],
|
|
11
|
+
approvalRequired: []
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { defineOutcomeContract };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Goal, type GoalPriority, type GoalSource, type GoalUiLocale } from '../goals/index.js';
|
|
2
|
+
export interface CreateOutcomeExecutionInput {
|
|
3
|
+
objective: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
deliverables?: string[];
|
|
6
|
+
acceptanceCriteria?: string[];
|
|
7
|
+
constraints?: string[];
|
|
8
|
+
approvalRequired?: string[];
|
|
9
|
+
projectId?: string;
|
|
10
|
+
sessionKey?: string;
|
|
11
|
+
agentId?: string;
|
|
12
|
+
priority?: GoalPriority;
|
|
13
|
+
deadlineAt?: number;
|
|
14
|
+
judgeModelRef?: string;
|
|
15
|
+
maxTurns?: number;
|
|
16
|
+
uiLocale?: GoalUiLocale;
|
|
17
|
+
source?: GoalSource;
|
|
18
|
+
}
|
|
19
|
+
export interface OutcomeExecution {
|
|
20
|
+
outcomeId: string;
|
|
21
|
+
contractVersion: number;
|
|
22
|
+
goal: Goal;
|
|
23
|
+
}
|
|
24
|
+
export declare class OutcomeExecutionService {
|
|
25
|
+
#private;
|
|
26
|
+
create(input: CreateOutcomeExecutionInput): OutcomeExecution;
|
|
27
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { runSqliteWriteTransaction } from "../storage/sqlite/transaction.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
|
+
//#region src/work/outcome-execution-service.ts
|
|
7
|
+
var OutcomeExecutionService = class {
|
|
8
|
+
#goals = new GoalService();
|
|
9
|
+
#outcomes = new OutcomeRepository();
|
|
10
|
+
create(input) {
|
|
11
|
+
const objective = input.objective.trim();
|
|
12
|
+
if (!objective) throw new Error("Objective is required");
|
|
13
|
+
return runSqliteWriteTransaction(() => {
|
|
14
|
+
const outcome = this.#outcomes.create({
|
|
15
|
+
objective,
|
|
16
|
+
deliverables: input.deliverables?.length ? input.deliverables : [objective],
|
|
17
|
+
acceptanceCriteria: input.acceptanceCriteria ?? [],
|
|
18
|
+
constraints: input.constraints ?? [],
|
|
19
|
+
approvalRequired: input.approvalRequired ?? [],
|
|
20
|
+
createdBy: "user",
|
|
21
|
+
links: [...input.projectId ? [{
|
|
22
|
+
kind: "project",
|
|
23
|
+
id: input.projectId,
|
|
24
|
+
relation: "contains"
|
|
25
|
+
}] : [], ...input.sessionKey ? [{
|
|
26
|
+
kind: "session",
|
|
27
|
+
id: input.sessionKey,
|
|
28
|
+
relation: "originated_from"
|
|
29
|
+
}] : []]
|
|
30
|
+
});
|
|
31
|
+
const goal = this.#goals.create({
|
|
32
|
+
outcomeId: outcome.id,
|
|
33
|
+
outcomeContractVersion: outcome.latestContractVersion,
|
|
34
|
+
title: objective,
|
|
35
|
+
description: input.description,
|
|
36
|
+
projectId: input.projectId,
|
|
37
|
+
sessionKey: input.sessionKey,
|
|
38
|
+
agentId: input.agentId ?? "main",
|
|
39
|
+
priority: input.priority,
|
|
40
|
+
deadlineAt: input.deadlineAt,
|
|
41
|
+
judgeModelRef: input.judgeModelRef,
|
|
42
|
+
maxTurns: input.maxTurns,
|
|
43
|
+
uiLocale: input.uiLocale,
|
|
44
|
+
source: input.source
|
|
45
|
+
});
|
|
46
|
+
this.#outcomes.addLink(outcome.id, {
|
|
47
|
+
kind: "goal",
|
|
48
|
+
id: goal.id,
|
|
49
|
+
relation: "drives"
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
outcomeId: outcome.id,
|
|
53
|
+
contractVersion: outcome.latestContractVersion,
|
|
54
|
+
goal
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { OutcomeExecutionService };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ExecutionReceipt } from '../storage/sqlite/index.js';
|
|
2
|
+
export declare const EXECUTION_RECEIPT_PROJECTION_VERSION = 4;
|
|
3
|
+
export declare class OutcomeProjectionService {
|
|
4
|
+
#private;
|
|
5
|
+
project(outcome: ExecutionReceipt): ExecutionReceipt;
|
|
6
|
+
reconcile(limit?: number): number;
|
|
7
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { listUnprojectedExecutionReceipts, markExecutionReceiptProjected } from "../storage/sqlite/execution-receipt-repository.js";
|
|
2
|
+
import "../storage/sqlite/index.js";
|
|
3
|
+
import { OutcomeRepository } from "./outcome-repository.js";
|
|
4
|
+
//#region src/work/outcome-projection-service.ts
|
|
5
|
+
const EXECUTION_RECEIPT_PROJECTION_VERSION = 4;
|
|
6
|
+
const MAX_AUTONOMOUS_ATTEMPTS = 3;
|
|
7
|
+
function canRecoverAutonomously(outcome) {
|
|
8
|
+
return outcome.status === "failed" && outcome.attempt < MAX_AUTONOMOUS_ATTEMPTS && outcome.failure?.recoveryAction !== "request_user_input" && outcome.failure?.recoveryAction !== "none";
|
|
9
|
+
}
|
|
10
|
+
var OutcomeProjectionService = class {
|
|
11
|
+
#outcomes = new OutcomeRepository();
|
|
12
|
+
project(outcome) {
|
|
13
|
+
if (outcome.status === "running" || outcome.projectionVersion >= 4) return outcome;
|
|
14
|
+
const verdict = outcome.completionVerdict;
|
|
15
|
+
const recovering = canRecoverAutonomously(outcome);
|
|
16
|
+
if (outcome.context.outcomeId) {
|
|
17
|
+
if (verdict === "achieved") this.#outcomes.updateState({
|
|
18
|
+
id: outcome.context.outcomeId,
|
|
19
|
+
userStatus: "completed",
|
|
20
|
+
internalStatus: "completed",
|
|
21
|
+
latestReceiptRunId: outcome.runId
|
|
22
|
+
});
|
|
23
|
+
else if (verdict === "partial") this.#outcomes.updateState({
|
|
24
|
+
id: outcome.context.outcomeId,
|
|
25
|
+
userStatus: outcome.needsUser ? "needs_user" : "running",
|
|
26
|
+
internalStatus: outcome.needsUser ? "needs_user" : "continuing",
|
|
27
|
+
latestReceiptRunId: outcome.runId
|
|
28
|
+
});
|
|
29
|
+
else if (verdict === "not_achieved") this.#outcomes.updateState({
|
|
30
|
+
id: outcome.context.outcomeId,
|
|
31
|
+
userStatus: outcome.status === "cancelled" ? "completed" : recovering ? "running" : "needs_user",
|
|
32
|
+
internalStatus: outcome.status === "cancelled" ? "cancelled" : recovering ? "continuing" : "blocked",
|
|
33
|
+
latestReceiptRunId: outcome.runId
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return markExecutionReceiptProjected({
|
|
37
|
+
runId: outcome.runId,
|
|
38
|
+
projectionVersion: 4
|
|
39
|
+
}) ?? outcome;
|
|
40
|
+
}
|
|
41
|
+
reconcile(limit = 100) {
|
|
42
|
+
const pending = listUnprojectedExecutionReceipts({
|
|
43
|
+
projectionVersion: 4,
|
|
44
|
+
limit
|
|
45
|
+
});
|
|
46
|
+
for (const outcome of pending) this.project(outcome);
|
|
47
|
+
return pending.length;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { EXECUTION_RECEIPT_PROJECTION_VERSION, OutcomeProjectionService };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OutcomeReceipt } from '@xopcai/gateway-contract';
|
|
2
|
+
import { type ExecutionReceipt } from '../storage/sqlite/index.js';
|
|
3
|
+
export declare function toOutcomeReceipt(outcome: ExecutionReceipt): OutcomeReceipt;
|
|
4
|
+
export declare class OutcomeReceiptService {
|
|
5
|
+
get(runId: string): OutcomeReceipt | undefined;
|
|
6
|
+
list(input?: {
|
|
7
|
+
outcomeId?: string;
|
|
8
|
+
projectId?: string;
|
|
9
|
+
workItemId?: string;
|
|
10
|
+
sessionKey?: string;
|
|
11
|
+
limit?: number;
|
|
12
|
+
}): OutcomeReceipt[];
|
|
13
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { getExecutionReceipt, listExecutionReceipts } from "../storage/sqlite/execution-receipt-repository.js";
|
|
2
|
+
import "../storage/sqlite/index.js";
|
|
3
|
+
//#region src/work/outcome-receipt-service.ts
|
|
4
|
+
function receiptStatus(outcome) {
|
|
5
|
+
if (outcome.status === "running") return "running";
|
|
6
|
+
if (outcome.status === "cancelled") return "cancelled";
|
|
7
|
+
if (outcome.needsUser) return "needs_user";
|
|
8
|
+
if (outcome.completionVerdict === "achieved") return "completed";
|
|
9
|
+
if (outcome.completionVerdict === "partial") return "partial";
|
|
10
|
+
return "failed";
|
|
11
|
+
}
|
|
12
|
+
function remainingWork(outcome) {
|
|
13
|
+
const incomplete = outcome.verification.checks.filter((check) => check.status !== "passed").map((check) => check.criterion);
|
|
14
|
+
if (outcome.nextAction && !incomplete.includes(outcome.nextAction)) incomplete.push(outcome.nextAction);
|
|
15
|
+
return incomplete;
|
|
16
|
+
}
|
|
17
|
+
function toOutcomeReceipt(outcome) {
|
|
18
|
+
return {
|
|
19
|
+
runId: outcome.runId,
|
|
20
|
+
...outcome.context.outcomeId ? { outcomeId: outcome.context.outcomeId } : {},
|
|
21
|
+
...outcome.contractVersion ? { contractVersion: outcome.contractVersion } : {},
|
|
22
|
+
sessionKey: outcome.sessionKey,
|
|
23
|
+
objective: outcome.objective,
|
|
24
|
+
status: receiptStatus(outcome),
|
|
25
|
+
summary: outcome.summary ?? (outcome.status === "running" ? "Work is in progress." : "Work finished without a summary."),
|
|
26
|
+
projectId: outcome.context.projectId,
|
|
27
|
+
goalId: outcome.context.goalId,
|
|
28
|
+
workItemId: outcome.context.workItemId,
|
|
29
|
+
origin: outcome.context.origin,
|
|
30
|
+
triggerKind: outcome.context.triggerKind,
|
|
31
|
+
changes: outcome.evidence.filter((item) => item.kind === "artifact" || item.kind === "state"),
|
|
32
|
+
evidence: outcome.evidence,
|
|
33
|
+
verification: outcome.verification,
|
|
34
|
+
remainingWork: remainingWork(outcome),
|
|
35
|
+
nextAction: outcome.nextAction,
|
|
36
|
+
needsUser: outcome.needsUser,
|
|
37
|
+
completionVerdict: outcome.completionVerdict,
|
|
38
|
+
correctionText: outcome.correctionText,
|
|
39
|
+
contextTraceId: outcome.context.contextTraceId,
|
|
40
|
+
startedAt: outcome.startedAt,
|
|
41
|
+
completedAt: outcome.completedAt,
|
|
42
|
+
feedback: outcome.feedback
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
var OutcomeReceiptService = class {
|
|
46
|
+
get(runId) {
|
|
47
|
+
const outcome = getExecutionReceipt(runId);
|
|
48
|
+
return outcome ? toOutcomeReceipt(outcome) : void 0;
|
|
49
|
+
}
|
|
50
|
+
list(input = {}) {
|
|
51
|
+
return listExecutionReceipts(input).map(toOutcomeReceipt);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { OutcomeReceiptService, toOutcomeReceipt };
|