@xopcai/xopc 0.0.176 → 0.0.178
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-DsFM1upC.js → activity-store-BzGX__8I.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DvdMLOga.js → agent-avatar-dicebear-BzxntcaZ.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DC9F12Kw.js +2 -0
- package/dist/gateway/static/root/assets/{api-BdPLCCBm.js → api-hi6f2Xtp.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DMLDOHul.js → app-management-settings-panel-fTY1F7ac.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DbI9foFR.js → appearance-settings-BZ-IxQfB.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-5bKr05Fa.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-Dfdxuwvb.js → archive-plugin-ZSLLG8wB.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Dn3RlnYD.js → attachment-load-D4YktqIF.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-Bc0Y7A9u.js → automation-suggestion-card-B7mxFRtf.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-Dg6dmt5g.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-0XtB-xC0.js → binary-plugins-BIkPxfxj.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-C4fXWbEE.js → block-editor-Q3v_YQom.js} +6 -6
- package/dist/gateway/static/root/assets/{browser-settings-page-lC86-drr.js → browser-settings-page-BHoo6Rpq.js} +4 -4
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-CZmzNymN.js → browser-workflow-inputs-M5lTEW1I.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-CBYM9HqG.js → browser-workflows-page-B3T1KYk4.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-BlsqN8Fu.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-BiJxmmhW.js → capability-presets-api-DE09c0VB.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DJeT8_B4.js +1 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-BKTUZDp-.js → channel-recipient-api-CFR5FBfS.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-C4VVjYEm.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-vdf8kB16.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-Pr4RIKjj.js → connector-logo-B1mD-3pM.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-DNcrDThX.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-B1urphOZ.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CEQacUDF.js → desktop-pet-settings-DTL6J3EP.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DWnxdZtc.js → directory-picker-path-field-BYQJ2XUS.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-D2e2w2Ho.js → dreaming-settings-BXcb8fwx.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-BLjTGbv3.js → extension-debug-page-O1Xu1r4Q.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-D2_UC6hy.js → extension-page-C2Jraq8l.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BsH6o_PX.js → extension-settings-page-DcXQDTpG.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-C-DkC6UJ.js → gateway-config-api-DmPIZrvg.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DEOGiimF.js → gateway-settings-DmObBx9b.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BlSLh1TF.js → gateway-startup-retry-BZEkOdPm.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-create-dialog-CSFcRE_N.js → goal-create-dialog-BRhmmBe9.js} +1 -1
- package/dist/gateway/static/root/assets/goal-detail-page-C1k7_s_O.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-CcdS9qek.js → goals-config-api-Fwu1wjEP.js} +1 -1
- package/dist/gateway/static/root/assets/{goals-page-BAcErdch.js → goals-page-hOu9uA3q.js} +2 -2
- package/dist/gateway/static/root/assets/{goals-settings-BY7crl0z.js → goals-settings-DY-JjvHz.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DtTkS0gs.js → heartbeat-settings-BtKu2NWT.js} +1 -1
- package/dist/gateway/static/root/assets/{image-generation-api-WGgkbwDZ.js → image-generation-api-05Gg8wsU.js} +1 -1
- package/dist/gateway/static/root/assets/{index-2UImfRDC.js → index-C0CGebQ1.js} +65 -65
- package/dist/gateway/static/root/assets/index-eqq25gvV.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C5lpWQ3f.js → keyboard-shortcuts-settings-CfmDR9Sc.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-EjsNT7nJ.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-b05wWvXG.js → local-apps-page-Df8BW1A_.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-sToMfHX_.js → locale-store-CTwSy7yW.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-cDE1jLJv.js → logs-page-Dswjlraa.js} +3 -3
- package/dist/gateway/static/root/assets/{markdown-split-0gPVst5y.js → markdown-split-B3FvKbaP.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Rxyq_KTm.js → media-plugins-DsjrvvB6.js} +1 -1
- package/dist/gateway/static/root/assets/messages-DP6tPKk-.js +3 -0
- package/dist/gateway/static/root/assets/{notes-page-DRhNDl_Q.js → notes-page-tuzIwy3c.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-DSh3-hMY.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-cOEOQqHh.js → page-tabs-ke9s4nYi.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BopOLFvu.js → preview-open-alternatives-Cp1eI4S9.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DWVPmmOq.js → product-open-page-dXQCMAtH.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-D0QPRHR_.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-CI5Vz62F.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-S1jpzBS5.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-BfZmKe1t.js → save-bar-controls-Bl30zjHc.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-Cpi4jCRV.js → schedule-field-DqhmXQKo.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-OXFkcZQe.js → schema-form-DkUCy6vf.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-CTm66k7h.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CU52AUVD.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-BwqkZCHJ.js → settings-form-section-C6ZbNpdy.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-BbqH_S3Y.js → settings-loading-skeleton-Bk58_cr7.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BoxC-JSa.js → settings-page-k8iE_NdX.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-Ddu2iGaW.js → settings-page-layout-DgFSya2e.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-z1Lwv0js.js → setup-status-panel-B_KDlyZA.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-CVazOFjy.js → share-preview-page-CV7nL_J9.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DK6XK95e.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-Bvv_u4ii.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-BGHvVbay.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-DgyB1tSo.js → skills-page.utils-kahBIHg0.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-BoLSQL65.js → system-settings-panel-JV3-MG5F.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-CBNcGOfj.js → theme-store-DFLyzoLO.js} +1 -1
- package/dist/gateway/static/root/assets/{time-picker-gochWrny.js → time-picker-XwpxdZFr.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-DvRnr7YB.js → typed-models-lib-60Aqo-UJ.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-CA9BFVB7.js → use-channel-catalog-CnTkHDnw.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-DBCMk-Vn.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-v8tgylEZ.js → voice-api-key-field-CNa8qUgS.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-C1UIdsCl.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-DEAQepB8.js +1 -0
- package/dist/gateway/static/root/assets/work-page-D5qYmCTq.js +3 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CC3cJn5k.js → workflow-run-setup-panel-yV_x595t.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-yrK17ZZ5.js +11 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/embedded/model-runtime.js +3 -0
- package/dist/src/agent/embedded/run-for-session.js +18 -5
- package/dist/src/agent/embedded/run-turn.js +6 -3
- package/dist/src/agent/embedded/types.d.ts +2 -0
- package/dist/src/automations/service/automation-service.d.ts +3 -0
- package/dist/src/automations/service/automation-service.js +37 -7
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/connectors/composio-sessions.js +1 -1
- package/dist/src/gateway/hono/routes/home.d.ts +18 -2
- package/dist/src/gateway/hono/routes/home.js +19 -0
- package/dist/src/gateway/hono/routes/index.js +2 -2
- package/dist/src/gateway/hono/routes/local-apps.js +1 -1
- package/dist/src/gateway/hono/routes/proactive.d.ts +4 -0
- package/dist/src/gateway/hono/routes/proactive.js +157 -0
- package/dist/src/gateway/hono/routes/projects.js +2 -2
- package/dist/src/gateway/hono/routes/update.js +2 -2
- package/dist/src/gateway/index.js +1 -1
- package/dist/src/gateway/run-loop.js +1 -1
- package/dist/src/gateway/service.d.ts +10 -1
- package/dist/src/gateway/service.js +36 -36
- package/dist/src/infra/gateway-processes.js +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/infra/update-runner.js +2 -2
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/mcp/channel-bridge.js +1 -1
- package/dist/src/mobile/notification-service.d.ts +1 -0
- package/dist/src/mobile/notification-service.js +38 -18
- package/dist/src/mobile/notification-types.d.ts +2 -2
- package/dist/src/proactive/events/envelope.d.ts +2 -0
- package/dist/src/proactive/events/envelope.js +54 -0
- package/dist/src/proactive/events/publisher.d.ts +4 -0
- package/dist/src/proactive/events/repository.d.ts +9 -0
- package/dist/src/proactive/events/repository.js +62 -0
- package/dist/src/proactive/events/types.d.ts +44 -0
- package/dist/src/proactive/events/types.js +15 -0
- package/dist/src/proactive/execution/agent-executor.d.ts +16 -0
- package/dist/src/proactive/execution/agent-executor.js +104 -0
- package/dist/src/proactive/execution/context.d.ts +31 -0
- package/dist/src/proactive/execution/context.js +72 -0
- package/dist/src/proactive/execution/insight.d.ts +4 -0
- package/dist/src/proactive/execution/insight.js +74 -0
- package/dist/src/proactive/execution/repository.d.ts +23 -0
- package/dist/src/proactive/execution/repository.js +122 -0
- package/dist/src/proactive/execution/types.d.ts +54 -0
- package/dist/src/proactive/execution/types.js +1 -0
- package/dist/src/proactive/execution/worker.d.ts +15 -0
- package/dist/src/proactive/execution/worker.js +96 -0
- package/dist/src/proactive/inbox/repository.d.ts +24 -0
- package/dist/src/proactive/inbox/repository.js +117 -0
- package/dist/src/proactive/inbox/service.d.ts +17 -0
- package/dist/src/proactive/inbox/service.js +22 -0
- package/dist/src/proactive/inbox/types.d.ts +38 -0
- package/dist/src/proactive/inbox/types.js +1 -0
- package/dist/src/proactive/inbox/worker.d.ts +12 -0
- package/dist/src/proactive/inbox/worker.js +56 -0
- package/dist/src/proactive/index.d.ts +17 -0
- package/dist/src/proactive/index.js +11 -0
- package/dist/src/proactive/routing/batch-repository.d.ts +27 -0
- package/dist/src/proactive/routing/batch-repository.js +56 -0
- package/dist/src/proactive/routing/matcher.d.ts +5 -0
- package/dist/src/proactive/routing/matcher.js +56 -0
- package/dist/src/proactive/routing/types.d.ts +44 -0
- package/dist/src/proactive/routing/types.js +1 -0
- package/dist/src/proactive/scenarios/prompt-composer.d.ts +14 -0
- package/dist/src/proactive/scenarios/prompt-composer.js +24 -0
- package/dist/src/proactive/scenarios/repository.d.ts +23 -0
- package/dist/src/proactive/scenarios/repository.js +162 -0
- package/dist/src/proactive/scenarios/service.d.ts +15 -0
- package/dist/src/proactive/scenarios/service.js +26 -0
- package/dist/src/proactive/scenarios/types.d.ts +36 -0
- package/dist/src/proactive/scenarios/types.js +1 -0
- package/dist/src/proactive/service.d.ts +18 -0
- package/dist/src/proactive/service.js +61 -0
- package/dist/src/projects/project-service.d.ts +3 -1
- package/dist/src/projects/project-service.js +62 -32
- package/dist/src/providers/provider-auth-service.js +3 -0
- package/dist/src/providers/register-bundled-oauth-flows.d.ts +2 -0
- package/dist/src/providers/register-bundled-oauth-flows.js +16 -0
- package/dist/src/session/store.d.ts +2 -0
- package/dist/src/session/store.js +30 -0
- package/dist/src/storage/sqlite/migrations/068_proactive_event_spine.sql +71 -0
- package/dist/src/storage/sqlite/migrations/069_proactive_scenario_control.sql +69 -0
- package/dist/src/storage/sqlite/migrations/070_proactive_execution.sql +55 -0
- package/dist/src/storage/sqlite/migrations/071_proactive_inbox.sql +45 -0
- package/dist/src/storage/sqlite/migrations/072_proactive_judgments.sql +14 -0
- package/dist/src/storage/sqlite/migrations/073_enable_default_proactive_scenarios.sql +13 -0
- package/dist/src/storage/sqlite/migrations/074_deduplicate_blocked_work_routing.sql +5 -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/schema.js +1 -1
- package/dist/src/work-discovery/thread-service.d.ts +1 -3
- package/dist/src/work-discovery/thread-service.js +13 -25
- package/dist/src/work-items/work-item-service.d.ts +3 -1
- package/dist/src/work-items/work-item-service.js +67 -36
- package/package.json +3 -11
- package/dist/gateway/static/root/assets/agents-BVjlpbeZ.js +0 -2
- package/dist/gateway/static/root/assets/api-Bop4IQRW.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-njqxLWYD.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-D-eweHZJ.js +0 -6
- package/dist/gateway/static/root/assets/capabilities-settings-panel-6tYNfHqJ.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Co-ymbd9.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-D46eVjaQ.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-BMRAO4zZ.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-Dw1eYbRi.js +0 -2
- package/dist/gateway/static/root/assets/copy-VueTIC2x.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-B8cZuQUt.js +0 -1
- package/dist/gateway/static/root/assets/focus-detail-page-BBXUtxRB.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-VjRArfAJ.js +0 -4
- package/dist/gateway/static/root/assets/index-CS9sVShT.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Cl0fcPL4.js +0 -2
- package/dist/gateway/static/root/assets/messages-CarlxqXV.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-BKNBk0Uf.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-BhjEXNQW.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-B80e69PH.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CwdVob6H.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BGt3Asj6.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BnTdM9Nn.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-C4lXuyQj.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DSuIDkeI.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-xgZczqVe.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-CEfIy4WZ.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-B-3MClaf.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-CEsFEdax.js +0 -1
- package/dist/gateway/static/root/assets/work-page-CT9AHnq6.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-C-1-_Zp1.js +0 -11
- package/dist/src/focuses/candidate-repository.d.ts +0 -15
- package/dist/src/focuses/candidate-repository.js +0 -91
- package/dist/src/focuses/index.d.ts +0 -7
- package/dist/src/focuses/index.js +0 -7
- package/dist/src/focuses/insight-repository.d.ts +0 -22
- package/dist/src/focuses/insight-repository.js +0 -77
- package/dist/src/focuses/prompts.d.ts +0 -2
- package/dist/src/focuses/prompts.js +0 -18
- package/dist/src/focuses/reconciler.d.ts +0 -5
- package/dist/src/focuses/reconciler.js +0 -26
- package/dist/src/focuses/repository.d.ts +0 -61
- package/dist/src/focuses/repository.js +0 -214
- package/dist/src/focuses/run-processor.d.ts +0 -18
- package/dist/src/focuses/run-processor.js +0 -162
- package/dist/src/focuses/service.d.ts +0 -42
- package/dist/src/focuses/service.js +0 -241
- package/dist/src/focuses/types.d.ts +0 -89
- package/dist/src/gateway/hono/routes/focuses.d.ts +0 -3
- package/dist/src/gateway/hono/routes/focuses.js +0 -319
- /package/dist/src/{focuses/types.js → proactive/events/publisher.js} +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { EventCondition, ScenarioRoute } from '../routing/types.js';
|
|
2
|
+
export interface ScenarioDefinition {
|
|
3
|
+
key: string;
|
|
4
|
+
version: number;
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
basePrompt: string;
|
|
8
|
+
baseTemplateVersion: number;
|
|
9
|
+
eventTypes: string[];
|
|
10
|
+
condition?: EventCondition;
|
|
11
|
+
aggregation: ScenarioRoute['aggregation'];
|
|
12
|
+
debounceSeconds: number;
|
|
13
|
+
maxWindowSeconds: number;
|
|
14
|
+
}
|
|
15
|
+
export interface ScenarioSubscription {
|
|
16
|
+
id: string;
|
|
17
|
+
scenarioKey: string;
|
|
18
|
+
workspaceId: string;
|
|
19
|
+
scopeKind: 'workspace' | 'project';
|
|
20
|
+
scopeId: string;
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
activePromptRevisionId?: string;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
}
|
|
26
|
+
export interface PromptRevision {
|
|
27
|
+
id: string;
|
|
28
|
+
subscriptionId: string;
|
|
29
|
+
revision: number;
|
|
30
|
+
status: 'draft' | 'published' | 'retired';
|
|
31
|
+
baseTemplateVersion: number;
|
|
32
|
+
userInstructions: string;
|
|
33
|
+
contentHash: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
publishedAt?: string;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { listEvents } from './events/repository.js';
|
|
2
|
+
import type { PublishEventInput, PublishedEvent } from './events/types.js';
|
|
3
|
+
import { listBatches, markReadyBatches } from './routing/batch-repository.js';
|
|
4
|
+
import type { ScenarioRoute } from './routing/types.js';
|
|
5
|
+
export declare class ProactiveEventService {
|
|
6
|
+
private readonly routes;
|
|
7
|
+
constructor(routes?: () => readonly ScenarioRoute[]);
|
|
8
|
+
publish(input: PublishEventInput, now?: Date): PublishedEvent;
|
|
9
|
+
listEvents: typeof listEvents;
|
|
10
|
+
listBatches: typeof listBatches;
|
|
11
|
+
markReadyBatches: typeof markReadyBatches;
|
|
12
|
+
health(): {
|
|
13
|
+
events: number;
|
|
14
|
+
collecting: number;
|
|
15
|
+
ready: number;
|
|
16
|
+
oldestReadyAt: string | null;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getSqliteDatabase } from "../storage/sqlite/transaction.js";
|
|
2
|
+
import { normalizeEventEnvelope } from "./events/envelope.js";
|
|
3
|
+
import { matchScenario } from "./routing/matcher.js";
|
|
4
|
+
import { getEventByDedupeKey, insertEvent, isEventRouted, listEvents, markEventRouted } from "./events/repository.js";
|
|
5
|
+
import { addEventToBatch, listBatches, markReadyBatches } from "./routing/batch-repository.js";
|
|
6
|
+
//#region src/proactive/service.ts
|
|
7
|
+
var ProactiveEventService = class {
|
|
8
|
+
constructor(routes = () => []) {
|
|
9
|
+
this.routes = routes;
|
|
10
|
+
}
|
|
11
|
+
publish(input, now = /* @__PURE__ */ new Date()) {
|
|
12
|
+
let event = normalizeEventEnvelope(input, now);
|
|
13
|
+
const inserted = insertEvent(event);
|
|
14
|
+
if (!inserted) {
|
|
15
|
+
const existing = getEventByDedupeKey(event.dedupeKey);
|
|
16
|
+
if (!existing) throw new Error(`Proactive event dedupe lookup failed: ${event.dedupeKey}`);
|
|
17
|
+
event = existing;
|
|
18
|
+
if (isEventRouted(event.id)) return {
|
|
19
|
+
event,
|
|
20
|
+
inserted: false,
|
|
21
|
+
batchIds: []
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
const batchIds = this.routes().flatMap((scenario) => {
|
|
25
|
+
const key = matchScenario(event, scenario);
|
|
26
|
+
if (!key) return [];
|
|
27
|
+
return [addEventToBatch({
|
|
28
|
+
event,
|
|
29
|
+
scenario,
|
|
30
|
+
aggregationKey: key,
|
|
31
|
+
now
|
|
32
|
+
}).id];
|
|
33
|
+
});
|
|
34
|
+
markEventRouted(event.id, now.toISOString());
|
|
35
|
+
return {
|
|
36
|
+
event,
|
|
37
|
+
inserted,
|
|
38
|
+
batchIds
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
listEvents = listEvents;
|
|
42
|
+
listBatches = listBatches;
|
|
43
|
+
markReadyBatches = markReadyBatches;
|
|
44
|
+
health() {
|
|
45
|
+
const db = getSqliteDatabase();
|
|
46
|
+
const events = db.prepare("SELECT COUNT(*) AS count FROM proactive_events").get();
|
|
47
|
+
const batches = db.prepare(`SELECT
|
|
48
|
+
SUM(CASE WHEN status = 'collecting' THEN 1 ELSE 0 END) AS collecting,
|
|
49
|
+
SUM(CASE WHEN status = 'ready' THEN 1 ELSE 0 END) AS ready,
|
|
50
|
+
MIN(CASE WHEN status = 'ready' THEN ready_at END) AS oldest_ready_at
|
|
51
|
+
FROM proactive_signal_batches`).get();
|
|
52
|
+
return {
|
|
53
|
+
events: events.count,
|
|
54
|
+
collecting: batches.collecting ?? 0,
|
|
55
|
+
ready: batches.ready ?? 0,
|
|
56
|
+
oldestReadyAt: batches.oldest_ready_at
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { ProactiveEventService };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProactiveSignalPublisher } from '../proactive/events/publisher.js';
|
|
1
2
|
import { ProjectStore } from './project-store.js';
|
|
2
3
|
import type { CreateProjectInput, Project, ProjectListQuery, ProjectListResult, ProjectWithDetails, SidebarProjectListQuery, UpdateProjectInput } from './types.js';
|
|
3
4
|
import { type WorkspaceProjectMatch } from './workspace-project.js';
|
|
@@ -9,7 +10,8 @@ export type ProjectSuggestion = {
|
|
|
9
10
|
};
|
|
10
11
|
export declare class ProjectService {
|
|
11
12
|
private readonly store;
|
|
12
|
-
|
|
13
|
+
private readonly signals?;
|
|
14
|
+
constructor(store?: ProjectStore, signals?: ProactiveSignalPublisher);
|
|
13
15
|
private listAllProjects;
|
|
14
16
|
create(input: CreateProjectInput): Project;
|
|
15
17
|
get(id: string): Project | null;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
1
2
|
import { getSessionMetadata } from "../storage/sqlite/session-repository.js";
|
|
2
3
|
import "../storage/sqlite/index.js";
|
|
3
4
|
import { changedFieldsFromPatch, emitActivity, systemActivityActor, systemActivitySource } from "../activity/emitter.js";
|
|
@@ -5,10 +6,12 @@ import { ProjectStore } from "./project-store.js";
|
|
|
5
6
|
import { bindGoalToProject, listProjectGoalIds, unbindGoalFromProject } from "./goal-bind.js";
|
|
6
7
|
import { bindSessionToProject, listProjectSessionKeys, unbindSessionFromProject } from "./session-bind.js";
|
|
7
8
|
import { ProjectWorkspaceConflictError, ProjectWorkspaceMissingError, canonicalWorkspacePath, ensureWorkspaceDirectory, inferProjectNameFromWorkspaceRoot, isPathSameOrInsideWorkspace, isSafeAutoCreateWorkspaceRoot, resolveWorkspaceProjectRoot, workspaceDirectoryExists } from "./workspace-project.js";
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
8
10
|
//#region src/projects/project-service.ts
|
|
9
11
|
var ProjectService = class {
|
|
10
|
-
constructor(store = new ProjectStore()) {
|
|
12
|
+
constructor(store = new ProjectStore(), signals) {
|
|
11
13
|
this.store = store;
|
|
14
|
+
this.signals = signals;
|
|
12
15
|
}
|
|
13
16
|
listAllProjects() {
|
|
14
17
|
const items = [];
|
|
@@ -144,38 +147,65 @@ var ProjectService = class {
|
|
|
144
147
|
else throw new ProjectWorkspaceMissingError(workspaceRoot);
|
|
145
148
|
patch.workspaceRoot = workspaceRoot;
|
|
146
149
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
150
|
+
return runSqliteWriteTransaction(() => {
|
|
151
|
+
const before = this.store.get(id);
|
|
152
|
+
const project = this.store.update(id, patch);
|
|
153
|
+
const changes = changedFieldsFromPatch(patch, ["createWorkspaceRoot"]);
|
|
154
|
+
const type = before?.status !== project.status ? "project.status_changed" : before?.workspaceRoot !== project.workspaceRoot ? "project.workspace_changed" : "project.updated";
|
|
155
|
+
emitActivity({
|
|
156
|
+
type,
|
|
157
|
+
primaryObject: {
|
|
158
|
+
kind: "project",
|
|
159
|
+
id: project.id,
|
|
160
|
+
title: project.name
|
|
161
|
+
},
|
|
162
|
+
actor: systemActivityActor(),
|
|
163
|
+
source: systemActivitySource(),
|
|
164
|
+
payload: {
|
|
165
|
+
changes,
|
|
166
|
+
...type === "project.status_changed" ? {
|
|
167
|
+
from: before?.status,
|
|
168
|
+
to: project.status
|
|
169
|
+
} : {},
|
|
170
|
+
...type === "project.workspace_changed" ? {
|
|
171
|
+
from: before?.workspaceRoot,
|
|
172
|
+
to: project.workspaceRoot
|
|
173
|
+
} : {}
|
|
174
|
+
},
|
|
175
|
+
scopes: [{
|
|
176
|
+
scopeKind: "project",
|
|
177
|
+
scopeId: project.id,
|
|
178
|
+
reason: "object_owner"
|
|
179
|
+
}],
|
|
180
|
+
nowMs: project.updatedAt
|
|
181
|
+
});
|
|
182
|
+
this.signals?.publish({
|
|
183
|
+
type: "project.updated.v1",
|
|
184
|
+
schemaVersion: 1,
|
|
185
|
+
source: {
|
|
186
|
+
kind: "projects",
|
|
187
|
+
id: "local"
|
|
188
|
+
},
|
|
189
|
+
subject: {
|
|
190
|
+
kind: "project",
|
|
191
|
+
id: project.id
|
|
192
|
+
},
|
|
193
|
+
actor: { kind: "system" },
|
|
194
|
+
scope: {
|
|
195
|
+
workspaceId: "default",
|
|
196
|
+
projectId: project.id
|
|
197
|
+
},
|
|
198
|
+
occurredAt: new Date(project.updatedAt).toISOString(),
|
|
199
|
+
dedupeKey: `project:${project.id}:${project.updatedAt}:${createHash("sha256").update(JSON.stringify(patch)).digest("hex")}`,
|
|
200
|
+
sensitivity: "personal",
|
|
201
|
+
payload: {
|
|
202
|
+
before,
|
|
203
|
+
after: project,
|
|
204
|
+
changes
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
return project;
|
|
177
208
|
});
|
|
178
|
-
return project;
|
|
179
209
|
}
|
|
180
210
|
pin(id) {
|
|
181
211
|
return this.update(id, { pinnedAt: Date.now() });
|
|
@@ -2,11 +2,13 @@ import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
import { init_paths, resolveModelsJsonPath } from "../config/paths.js";
|
|
3
3
|
import { CredentialResolver, init_credentials } from "../auth/credentials.js";
|
|
4
4
|
import { XopcModelCredentialStore, init_model_credential_store } from "../auth/model-credential-store.js";
|
|
5
|
+
import { init_register_bundled_oauth_flows, registerBundledOAuthFlows } from "./register-bundled-oauth-flows.js";
|
|
5
6
|
import { init_register_runtime_providers, registerRuntimeProviders } from "./register-runtime-providers.js";
|
|
6
7
|
import { InMemoryModelsStore } from "@earendil-works/pi-ai";
|
|
7
8
|
import { ModelRuntime } from "@earendil-works/pi-coding-agent";
|
|
8
9
|
//#region src/providers/provider-auth-service.ts
|
|
9
10
|
async function createAuthRuntime(credentials) {
|
|
11
|
+
registerBundledOAuthFlows();
|
|
10
12
|
const runtime = await ModelRuntime.create({
|
|
11
13
|
credentials,
|
|
12
14
|
modelsPath: resolveModelsJsonPath(),
|
|
@@ -32,6 +34,7 @@ var init_provider_auth_service = __esmMin((() => {
|
|
|
32
34
|
init_credentials();
|
|
33
35
|
init_model_credential_store();
|
|
34
36
|
init_paths();
|
|
37
|
+
init_register_bundled_oauth_flows();
|
|
35
38
|
init_register_runtime_providers();
|
|
36
39
|
ProviderAuthService = class {
|
|
37
40
|
credentials;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { registerBunOAuthFlows } from "@earendil-works/pi-ai/bun-oauth";
|
|
3
|
+
//#region src/providers/register-bundled-oauth-flows.ts
|
|
4
|
+
/** Statically include pi-ai OAuth flows for single-file runtimes such as Electron. */
|
|
5
|
+
function registerBundledOAuthFlows() {
|
|
6
|
+
if (registered) return;
|
|
7
|
+
registerBunOAuthFlows();
|
|
8
|
+
registered = true;
|
|
9
|
+
}
|
|
10
|
+
var registered;
|
|
11
|
+
var init_register_bundled_oauth_flows = __esmMin((() => {
|
|
12
|
+
registered = false;
|
|
13
|
+
}));
|
|
14
|
+
//#endregion
|
|
15
|
+
init_register_bundled_oauth_flows();
|
|
16
|
+
export { init_register_bundled_oauth_flows, registerBundledOAuthFlows };
|
|
@@ -26,6 +26,7 @@ export interface SessionCompactionHooks {
|
|
|
26
26
|
compactedCount: number;
|
|
27
27
|
}) => Promise<void> | void;
|
|
28
28
|
}
|
|
29
|
+
export type ModelFallbackPreparation = 'prompt' | 'resume' | 'unsafe';
|
|
29
30
|
export declare class SessionStore {
|
|
30
31
|
private options;
|
|
31
32
|
private window;
|
|
@@ -78,6 +79,7 @@ export declare class SessionStore {
|
|
|
78
79
|
private buildSessionDetail;
|
|
79
80
|
loadTranscriptRows(key: string): Promise<TranscriptStoredRow[]>;
|
|
80
81
|
loadTranscriptHistoryRows(key: string): Promise<TranscriptStoredRow[]>;
|
|
82
|
+
prepareModelFallback(key: string, rowsBeforeAttempt: readonly TranscriptStoredRow[]): Promise<ModelFallbackPreparation>;
|
|
81
83
|
getMetadata(key: string): Promise<SessionMetadata | null>;
|
|
82
84
|
resolveKeyBySessionId(sessionId: string): Promise<string | null>;
|
|
83
85
|
updateMetadata(key: string, updates: Partial<SessionMetadata>): Promise<void>;
|
|
@@ -21,6 +21,16 @@ init_paths_state();
|
|
|
21
21
|
init_logger();
|
|
22
22
|
const log = createLogger("SessionStore");
|
|
23
23
|
const INDEX_VERSION = "1.0";
|
|
24
|
+
function isTranscriptMessageRole(row, role) {
|
|
25
|
+
return !!row && typeof row === "object" && "role" in row && row.role === role;
|
|
26
|
+
}
|
|
27
|
+
function isErrorAssistantRow(row) {
|
|
28
|
+
return isTranscriptMessageRole(row, "assistant") && row.stopReason === "error";
|
|
29
|
+
}
|
|
30
|
+
function transcriptPrefixMatches(expected, current) {
|
|
31
|
+
if (current.length < expected.length) return false;
|
|
32
|
+
return expected.every((row, index) => JSON.stringify(row) === JSON.stringify(current[index]));
|
|
33
|
+
}
|
|
24
34
|
var SessionStore = class {
|
|
25
35
|
window;
|
|
26
36
|
compactor;
|
|
@@ -186,6 +196,26 @@ var SessionStore = class {
|
|
|
186
196
|
requireXopcDatabase();
|
|
187
197
|
return loadTranscriptHistoryRowsForSession(key);
|
|
188
198
|
}
|
|
199
|
+
async prepareModelFallback(key, rowsBeforeAttempt) {
|
|
200
|
+
return this.runStoreMutation(async () => {
|
|
201
|
+
requireXopcDatabase();
|
|
202
|
+
const currentRows = loadTranscriptRowsForSession(key);
|
|
203
|
+
if (!transcriptPrefixMatches(rowsBeforeAttempt, currentRows)) return "unsafe";
|
|
204
|
+
let preparedRows = currentRows;
|
|
205
|
+
let removedError = false;
|
|
206
|
+
if (isErrorAssistantRow(preparedRows.at(-1))) {
|
|
207
|
+
preparedRows = preparedRows.slice(0, -1);
|
|
208
|
+
removedError = true;
|
|
209
|
+
}
|
|
210
|
+
const appendedRows = preparedRows.slice(rowsBeforeAttempt.length);
|
|
211
|
+
if (appendedRows.length === 1 && isTranscriptMessageRole(appendedRows[0], "user") || removedError && appendedRows.length === 0 && isTranscriptMessageRole(preparedRows.at(-1), "user")) {
|
|
212
|
+
if (removedError) replaceTranscriptRows(key, preparedRows);
|
|
213
|
+
return "resume";
|
|
214
|
+
}
|
|
215
|
+
if (!removedError && appendedRows.length === 0) return "prompt";
|
|
216
|
+
return "unsafe";
|
|
217
|
+
});
|
|
218
|
+
}
|
|
189
219
|
async getMetadata(key) {
|
|
190
220
|
requireXopcDatabase();
|
|
191
221
|
return getSessionMetadata(key);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
DROP TABLE IF EXISTS focus_insights;
|
|
2
|
+
DROP TABLE IF EXISTS focus_activities;
|
|
3
|
+
DROP TABLE IF EXISTS focus_monitors;
|
|
4
|
+
DROP TABLE IF EXISTS focus_projects;
|
|
5
|
+
DROP TABLE IF EXISTS focuses;
|
|
6
|
+
DROP TABLE IF EXISTS focus_candidate_projects;
|
|
7
|
+
DROP TABLE IF EXISTS focus_candidates;
|
|
8
|
+
|
|
9
|
+
CREATE TABLE proactive_events (
|
|
10
|
+
event_id TEXT PRIMARY KEY,
|
|
11
|
+
type TEXT NOT NULL,
|
|
12
|
+
schema_version INTEGER NOT NULL CHECK (schema_version > 0),
|
|
13
|
+
source_kind TEXT NOT NULL,
|
|
14
|
+
source_id TEXT NOT NULL,
|
|
15
|
+
device_id TEXT,
|
|
16
|
+
subject_kind TEXT NOT NULL,
|
|
17
|
+
subject_id TEXT NOT NULL,
|
|
18
|
+
actor_kind TEXT NOT NULL CHECK (actor_kind IN ('user', 'agent', 'system', 'integration')),
|
|
19
|
+
actor_id TEXT,
|
|
20
|
+
workspace_id TEXT NOT NULL,
|
|
21
|
+
project_id TEXT,
|
|
22
|
+
agent_id TEXT,
|
|
23
|
+
occurred_at TEXT NOT NULL,
|
|
24
|
+
observed_at TEXT NOT NULL,
|
|
25
|
+
correlation_id TEXT NOT NULL,
|
|
26
|
+
causation_id TEXT,
|
|
27
|
+
dedupe_key TEXT NOT NULL UNIQUE,
|
|
28
|
+
sensitivity TEXT NOT NULL CHECK (sensitivity IN ('public', 'personal', 'confidential', 'restricted')),
|
|
29
|
+
payload_json TEXT NOT NULL,
|
|
30
|
+
routed_at TEXT
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
CREATE TABLE proactive_signal_batches (
|
|
34
|
+
batch_id TEXT PRIMARY KEY,
|
|
35
|
+
scenario_key TEXT NOT NULL,
|
|
36
|
+
scenario_version INTEGER NOT NULL CHECK (scenario_version > 0),
|
|
37
|
+
aggregation_key TEXT NOT NULL,
|
|
38
|
+
window_started_at TEXT NOT NULL,
|
|
39
|
+
window_ends_at TEXT NOT NULL,
|
|
40
|
+
ready_at TEXT NOT NULL,
|
|
41
|
+
status TEXT NOT NULL CHECK (status IN (
|
|
42
|
+
'collecting', 'ready', 'processing', 'processed', 'ignored',
|
|
43
|
+
'failed_retryable', 'failed_permanent', 'expired'
|
|
44
|
+
)),
|
|
45
|
+
event_count INTEGER NOT NULL DEFAULT 0 CHECK (event_count >= 0),
|
|
46
|
+
created_at TEXT NOT NULL,
|
|
47
|
+
updated_at TEXT NOT NULL
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
CREATE TABLE proactive_batch_events (
|
|
51
|
+
batch_id TEXT NOT NULL,
|
|
52
|
+
event_id TEXT NOT NULL,
|
|
53
|
+
added_at TEXT NOT NULL,
|
|
54
|
+
PRIMARY KEY (batch_id, event_id),
|
|
55
|
+
FOREIGN KEY (batch_id) REFERENCES proactive_signal_batches(batch_id) ON DELETE CASCADE,
|
|
56
|
+
FOREIGN KEY (event_id) REFERENCES proactive_events(event_id) ON DELETE CASCADE
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
CREATE INDEX idx_proactive_events_type_observed
|
|
60
|
+
ON proactive_events(type, observed_at DESC);
|
|
61
|
+
CREATE INDEX idx_proactive_events_subject
|
|
62
|
+
ON proactive_events(subject_kind, subject_id, occurred_at DESC);
|
|
63
|
+
CREATE INDEX idx_proactive_events_project
|
|
64
|
+
ON proactive_events(project_id, occurred_at DESC) WHERE project_id IS NOT NULL;
|
|
65
|
+
CREATE INDEX idx_proactive_events_correlation
|
|
66
|
+
ON proactive_events(correlation_id);
|
|
67
|
+
CREATE INDEX idx_proactive_batches_ready
|
|
68
|
+
ON proactive_signal_batches(status, ready_at);
|
|
69
|
+
CREATE UNIQUE INDEX idx_proactive_collecting_batch
|
|
70
|
+
ON proactive_signal_batches(scenario_key, aggregation_key)
|
|
71
|
+
WHERE status = 'collecting';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
CREATE TABLE proactive_scenarios (
|
|
2
|
+
scenario_key TEXT PRIMARY KEY,
|
|
3
|
+
version INTEGER NOT NULL CHECK (version > 0),
|
|
4
|
+
title TEXT NOT NULL,
|
|
5
|
+
description TEXT NOT NULL,
|
|
6
|
+
base_prompt TEXT NOT NULL,
|
|
7
|
+
base_template_version INTEGER NOT NULL CHECK (base_template_version > 0),
|
|
8
|
+
event_types_json TEXT NOT NULL,
|
|
9
|
+
condition_json TEXT,
|
|
10
|
+
aggregation TEXT NOT NULL CHECK (aggregation IN ('subject', 'project', 'workspace')),
|
|
11
|
+
debounce_seconds INTEGER NOT NULL CHECK (debounce_seconds >= 0),
|
|
12
|
+
max_window_seconds INTEGER NOT NULL CHECK (max_window_seconds > 0),
|
|
13
|
+
created_at TEXT NOT NULL,
|
|
14
|
+
updated_at TEXT NOT NULL
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE proactive_scenario_subscriptions (
|
|
18
|
+
subscription_id TEXT PRIMARY KEY,
|
|
19
|
+
scenario_key TEXT NOT NULL,
|
|
20
|
+
workspace_id TEXT NOT NULL,
|
|
21
|
+
scope_kind TEXT NOT NULL CHECK (scope_kind IN ('workspace', 'project')),
|
|
22
|
+
scope_id TEXT NOT NULL,
|
|
23
|
+
enabled INTEGER NOT NULL DEFAULT 0 CHECK (enabled IN (0, 1)),
|
|
24
|
+
active_prompt_revision_id TEXT,
|
|
25
|
+
created_at TEXT NOT NULL,
|
|
26
|
+
updated_at TEXT NOT NULL,
|
|
27
|
+
UNIQUE (scenario_key, workspace_id, scope_kind, scope_id),
|
|
28
|
+
FOREIGN KEY (scenario_key) REFERENCES proactive_scenarios(scenario_key) ON DELETE CASCADE
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
CREATE TABLE proactive_prompt_revisions (
|
|
32
|
+
revision_id TEXT PRIMARY KEY,
|
|
33
|
+
subscription_id TEXT NOT NULL,
|
|
34
|
+
revision INTEGER NOT NULL CHECK (revision > 0),
|
|
35
|
+
status TEXT NOT NULL CHECK (status IN ('draft', 'published', 'retired')),
|
|
36
|
+
base_template_version INTEGER NOT NULL CHECK (base_template_version > 0),
|
|
37
|
+
user_instructions TEXT NOT NULL,
|
|
38
|
+
content_hash TEXT NOT NULL,
|
|
39
|
+
created_at TEXT NOT NULL,
|
|
40
|
+
published_at TEXT,
|
|
41
|
+
UNIQUE (subscription_id, revision),
|
|
42
|
+
FOREIGN KEY (subscription_id) REFERENCES proactive_scenario_subscriptions(subscription_id) ON DELETE CASCADE
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
CREATE INDEX idx_proactive_subscriptions_enabled
|
|
46
|
+
ON proactive_scenario_subscriptions(enabled, workspace_id, scenario_key);
|
|
47
|
+
CREATE INDEX idx_proactive_prompt_revisions_subscription
|
|
48
|
+
ON proactive_prompt_revisions(subscription_id, status, revision DESC);
|
|
49
|
+
|
|
50
|
+
ALTER TABLE proactive_signal_batches ADD COLUMN subscription_id TEXT NOT NULL DEFAULT '';
|
|
51
|
+
DROP INDEX idx_proactive_collecting_batch;
|
|
52
|
+
CREATE UNIQUE INDEX idx_proactive_collecting_batch
|
|
53
|
+
ON proactive_signal_batches(subscription_id, scenario_key, aggregation_key)
|
|
54
|
+
WHERE status = 'collecting';
|
|
55
|
+
|
|
56
|
+
INSERT INTO proactive_scenarios VALUES
|
|
57
|
+
('project_delivery_risk', 1, 'Project delivery risk', 'Detect credible risks to a project commitment.',
|
|
58
|
+
'Identify material changes that create supported schedule, scope, dependency, capacity, or ownership risk. Ignore routine activity and unsupported absence-of-activity claims.',
|
|
59
|
+
1, '["project.updated.v1","work_item.status_changed.v1","work_item.updated.v1"]', NULL,
|
|
60
|
+
'project', 300, 1800, datetime('now'), datetime('now')),
|
|
61
|
+
('blocked_work', 1, 'Blocked work', 'Find work that needs a decision, dependency, or owner intervention.',
|
|
62
|
+
'Confirm that work is truly blocked, identify the blocking object and downstream impact, then propose the smallest supported intervention.',
|
|
63
|
+
1, '["work_item.status_changed.v1","work_item.updated.v1"]',
|
|
64
|
+
'{"op":"any","conditions":[{"op":"eq","field":"payload.after.status","value":"blocked"},{"op":"changed","field":"payload.dependencyIds"}]}',
|
|
65
|
+
'project', 180, 900, datetime('now'), datetime('now')),
|
|
66
|
+
('automation_failure_impact', 1, 'Automation failure impact', 'Explain whether a terminal automation failure affects user outcomes.',
|
|
67
|
+
'Classify the failure, distinguish completed from incomplete work, connect it to a user outcome, and request only supported recovery decisions. Do not repeat raw stack traces.',
|
|
68
|
+
1, '["automation.run_failed.v1"]', NULL,
|
|
69
|
+
'subject', 60, 300, datetime('now'), datetime('now'));
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
CREATE TABLE proactive_context_snapshots (
|
|
2
|
+
snapshot_id TEXT PRIMARY KEY,
|
|
3
|
+
batch_id TEXT NOT NULL,
|
|
4
|
+
content_json TEXT NOT NULL,
|
|
5
|
+
evidence_ids_json TEXT NOT NULL,
|
|
6
|
+
created_at TEXT NOT NULL,
|
|
7
|
+
FOREIGN KEY (batch_id) REFERENCES proactive_signal_batches(batch_id) ON DELETE CASCADE
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
CREATE TABLE proactive_runs (
|
|
11
|
+
run_id TEXT PRIMARY KEY,
|
|
12
|
+
batch_id TEXT NOT NULL UNIQUE,
|
|
13
|
+
subscription_id TEXT NOT NULL,
|
|
14
|
+
scenario_key TEXT NOT NULL,
|
|
15
|
+
scenario_version INTEGER NOT NULL,
|
|
16
|
+
prompt_revision_id TEXT,
|
|
17
|
+
context_snapshot_id TEXT,
|
|
18
|
+
status TEXT NOT NULL CHECK (status IN ('running', 'completed', 'discarded', 'retryable', 'failed')),
|
|
19
|
+
attempt INTEGER NOT NULL DEFAULT 1 CHECK (attempt > 0),
|
|
20
|
+
lease_owner TEXT,
|
|
21
|
+
lease_expires_at TEXT,
|
|
22
|
+
model_ref TEXT,
|
|
23
|
+
raw_output TEXT,
|
|
24
|
+
error_message TEXT,
|
|
25
|
+
next_attempt_at TEXT,
|
|
26
|
+
started_at TEXT NOT NULL,
|
|
27
|
+
completed_at TEXT,
|
|
28
|
+
updated_at TEXT NOT NULL,
|
|
29
|
+
FOREIGN KEY (batch_id) REFERENCES proactive_signal_batches(batch_id) ON DELETE CASCADE,
|
|
30
|
+
FOREIGN KEY (subscription_id) REFERENCES proactive_scenario_subscriptions(subscription_id) ON DELETE CASCADE,
|
|
31
|
+
FOREIGN KEY (prompt_revision_id) REFERENCES proactive_prompt_revisions(revision_id),
|
|
32
|
+
FOREIGN KEY (context_snapshot_id) REFERENCES proactive_context_snapshots(snapshot_id)
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
CREATE TABLE proactive_insights (
|
|
36
|
+
insight_id TEXT PRIMARY KEY,
|
|
37
|
+
run_id TEXT NOT NULL UNIQUE,
|
|
38
|
+
subscription_id TEXT NOT NULL,
|
|
39
|
+
scenario_key TEXT NOT NULL,
|
|
40
|
+
title TEXT NOT NULL,
|
|
41
|
+
summary TEXT NOT NULL,
|
|
42
|
+
why_now TEXT NOT NULL,
|
|
43
|
+
impact TEXT NOT NULL,
|
|
44
|
+
recommendation TEXT NOT NULL,
|
|
45
|
+
urgency TEXT NOT NULL CHECK (urgency IN ('low', 'medium', 'high', 'critical')),
|
|
46
|
+
confidence REAL NOT NULL CHECK (confidence >= 0 AND confidence <= 1),
|
|
47
|
+
value_score REAL NOT NULL CHECK (value_score >= 0 AND value_score <= 1),
|
|
48
|
+
evidence_ids_json TEXT NOT NULL,
|
|
49
|
+
created_at TEXT NOT NULL,
|
|
50
|
+
FOREIGN KEY (run_id) REFERENCES proactive_runs(run_id) ON DELETE CASCADE,
|
|
51
|
+
FOREIGN KEY (subscription_id) REFERENCES proactive_scenario_subscriptions(subscription_id) ON DELETE CASCADE
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
CREATE INDEX idx_proactive_runs_status_lease ON proactive_runs(status, next_attempt_at, lease_expires_at, updated_at);
|
|
55
|
+
CREATE INDEX idx_proactive_insights_created ON proactive_insights(created_at DESC);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
CREATE TABLE proactive_inbox_items (
|
|
2
|
+
inbox_item_id TEXT PRIMARY KEY,
|
|
3
|
+
insight_id TEXT NOT NULL UNIQUE,
|
|
4
|
+
status TEXT NOT NULL CHECK (status IN ('unread', 'read', 'snoozed', 'resolved')),
|
|
5
|
+
snoozed_until TEXT,
|
|
6
|
+
resolution TEXT,
|
|
7
|
+
created_at TEXT NOT NULL,
|
|
8
|
+
updated_at TEXT NOT NULL,
|
|
9
|
+
FOREIGN KEY (insight_id) REFERENCES proactive_insights(insight_id) ON DELETE CASCADE
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE TABLE proactive_decisions (
|
|
13
|
+
decision_id TEXT PRIMARY KEY,
|
|
14
|
+
inbox_item_id TEXT NOT NULL,
|
|
15
|
+
choice TEXT NOT NULL,
|
|
16
|
+
note TEXT NOT NULL,
|
|
17
|
+
created_at TEXT NOT NULL,
|
|
18
|
+
FOREIGN KEY (inbox_item_id) REFERENCES proactive_inbox_items(inbox_item_id) ON DELETE CASCADE
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
CREATE TABLE proactive_delivery_outbox (
|
|
22
|
+
delivery_id TEXT PRIMARY KEY,
|
|
23
|
+
inbox_item_id TEXT NOT NULL UNIQUE,
|
|
24
|
+
status TEXT NOT NULL CHECK (status IN ('pending', 'delivering', 'delivered', 'retryable', 'failed')),
|
|
25
|
+
attempt INTEGER NOT NULL DEFAULT 0 CHECK (attempt >= 0),
|
|
26
|
+
next_attempt_at TEXT NOT NULL,
|
|
27
|
+
lease_expires_at TEXT,
|
|
28
|
+
error_message TEXT,
|
|
29
|
+
created_at TEXT NOT NULL,
|
|
30
|
+
delivered_at TEXT,
|
|
31
|
+
updated_at TEXT NOT NULL,
|
|
32
|
+
FOREIGN KEY (inbox_item_id) REFERENCES proactive_inbox_items(inbox_item_id) ON DELETE CASCADE
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
CREATE TABLE proactive_feedback (
|
|
36
|
+
feedback_id TEXT PRIMARY KEY,
|
|
37
|
+
inbox_item_id TEXT NOT NULL,
|
|
38
|
+
rating TEXT NOT NULL CHECK (rating IN ('useful', 'not_useful')),
|
|
39
|
+
note TEXT NOT NULL,
|
|
40
|
+
created_at TEXT NOT NULL,
|
|
41
|
+
FOREIGN KEY (inbox_item_id) REFERENCES proactive_inbox_items(inbox_item_id) ON DELETE CASCADE
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
CREATE INDEX idx_proactive_inbox_status ON proactive_inbox_items(status, updated_at DESC);
|
|
45
|
+
CREATE INDEX idx_proactive_outbox_ready ON proactive_delivery_outbox(status, next_attempt_at);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
ALTER TABLE proactive_insights ADD COLUMN work_done TEXT NOT NULL DEFAULT '';
|
|
2
|
+
ALTER TABLE proactive_insights ADD COLUMN decision_json TEXT;
|
|
3
|
+
|
|
4
|
+
CREATE TABLE proactive_instruction_feedback (
|
|
5
|
+
instruction_id TEXT PRIMARY KEY,
|
|
6
|
+
inbox_item_id TEXT NOT NULL,
|
|
7
|
+
prompt_revision_id TEXT NOT NULL,
|
|
8
|
+
instruction TEXT NOT NULL,
|
|
9
|
+
created_at TEXT NOT NULL,
|
|
10
|
+
FOREIGN KEY (inbox_item_id) REFERENCES proactive_inbox_items(inbox_item_id) ON DELETE CASCADE,
|
|
11
|
+
FOREIGN KEY (prompt_revision_id) REFERENCES proactive_prompt_revisions(revision_id)
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
CREATE INDEX idx_proactive_instruction_item ON proactive_instruction_feedback(inbox_item_id, created_at DESC);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
INSERT OR IGNORE INTO proactive_scenario_subscriptions (
|
|
2
|
+
subscription_id,
|
|
3
|
+
scenario_key,
|
|
4
|
+
workspace_id,
|
|
5
|
+
scope_kind,
|
|
6
|
+
scope_id,
|
|
7
|
+
enabled,
|
|
8
|
+
created_at,
|
|
9
|
+
updated_at
|
|
10
|
+
) VALUES
|
|
11
|
+
('default-project-delivery-risk', 'project_delivery_risk', 'default', 'workspace', 'default', 1, datetime('now'), datetime('now')),
|
|
12
|
+
('default-blocked-work', 'blocked_work', 'default', 'workspace', 'default', 1, datetime('now'), datetime('now')),
|
|
13
|
+
('default-automation-failure-impact', 'automation_failure_impact', 'default', 'workspace', 'default', 1, datetime('now'), datetime('now'));
|
|
@@ -3,7 +3,7 @@ import type { ApplyMigrationsOptions } from './types.js';
|
|
|
3
3
|
/** Baseline schema version applied from schema.sql on first open. */
|
|
4
4
|
export declare const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
|
|
5
5
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
6
|
-
export declare const XOPC_DB_SCHEMA_VERSION =
|
|
6
|
+
export declare const XOPC_DB_SCHEMA_VERSION = 74;
|
|
7
7
|
export declare function resolveMigrationsDir(override?: string): string;
|
|
8
8
|
/**
|
|
9
9
|
* Apply sequential SQL migrations from (currentVersion + 1) through targetVersion.
|