@xopcai/xopc 0.0.249 → 0.0.250
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-B759R_qf.js → activity-store-DfBjTSo9.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BUu7EnwM.js → agent-avatar-dicebear-BN6FJXkJ.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C7rZH1A2.js +1 -0
- package/dist/gateway/static/root/assets/{agents-DK9HjHO0.js → agents-CgGaoo4z.js} +1 -1
- package/dist/gateway/static/root/assets/{api-Cg0v7Lpn.js → api-zxpcJfgj.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-C9DkCW_d.js → app-management-settings-panel-D2gMshuS.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CFggS95Y.js → appearance-settings-wMu0jSKx.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-jOvT-fzU.js → apps-page-KF1Gnv36.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-BQrilVVv.js → archive-plugin-u6EE3JV8.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BG0BliqV.js → attachment-load-DbJurnv-.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-Bo4RiTkh.js → automations-page-Ew_e5HDn.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-Ch-ldu35.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BCnyNU0C.js → binary-plugins-DtDFNfPM.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Db8DlVvg.js → block-editor-CnAwmabq.js} +50 -50
- package/dist/gateway/static/root/assets/browser-settings-page-DtVhsHJW.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-C71vfl0b.js → browser-workflow-inputs-BX1-uM9L.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-vvmSYKsO.js → browser-workflows-page-CcbUOWDF.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel--sXeylhe.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-AXSBDujZ.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-CKyV3jY5.js → channels-status-swr-CX-yWwLD.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-B1Xd6OFB.js → chat-terminal-dock-CryTDNdD.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-HBHUWohz.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-D-F9vjtE.js → cron-expression-ji5aWrjG.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-B2OoYvic.js → date-picker-Dro_w3eX.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-BiGx9Sbj.js → dependency-picker-Ce19KKnX.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-BNMRqipe.js → desktop-pet-DsSi-3uZ.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DeYbIV7A.js → desktop-pet-settings-8WQ4woJy.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-COyn05ub.js → extension-debug-page-CgvEBfLZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-oH43chS2.js → extension-page-DkznBbMj.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BMO59994.js → extension-settings-page-BOjhchK2.js} +1 -1
- package/dist/gateway/static/root/assets/files-BArWTfr7.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-cimpViGk.js → gateway-config-api-OEruhhX3.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BGdHwT4e.js → gateway-config-swr-CMNbl0FZ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-BHJtnSic.js → gateway-settings-BgH3A0LO.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CuaM3b4c.js → gateway-startup-retry-CR7Xg8As.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-C97naDkO.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BBKKme4G.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-D7duj7Uj.js → image-generation-api-C5mn73ca.js} +1 -1
- package/dist/gateway/static/root/assets/index-BcaF-dgQ.js +72 -0
- package/dist/gateway/static/root/assets/{index-DGeGmj4k.css → index-DAryGvZ7.css} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D8Zw_lYd.js → keyboard-shortcuts-settings-BYhfzsqe.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-eBFVWmtH.js → local-app-workbench-page-DNncc2tn.js} +2 -2
- package/dist/gateway/static/root/assets/{local-apps-page-CvPDPRwb.js → local-apps-page-vBlknU7C.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-zEL8bkwx.js → locale-store-CF4erhjB.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-ClvcWlL6.js → logs-page-CizZInrT.js} +2 -2
- package/dist/gateway/static/root/assets/{management-settings-D8moh99U.js → management-settings-Dnx6mSNe.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-D7V3j0vE.js → markdown-split-DtBtcHWi.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-DGRN-8wP.js → markdown-view-CQvzsE24.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BLaE5b1Y.js → media-plugins-DrMYeHe7.js} +1 -1
- package/dist/gateway/static/root/assets/messages-Cf5hpZE6.js +3 -0
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-DiVDuCxl.js → mobile-pairing-wizard-AKgGy3Kx.js} +1 -1
- package/dist/gateway/static/root/assets/note-detail-panel-Bw3jD9Jf.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-Dpqq7Z-J.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-BFMGjA60.js → page-tabs-CX9T71by.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DNEWZN7H.js → preview-open-alternatives-DvEHoimN.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-Co5u7asH.js → product-open-page-COcr_NUJ.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BuT6MCTs.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DXWMxOjf.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-Cg92zSod.js → registry-api-BsRBlji7.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-7rBCUWzZ.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-C0ByNmlV.js → runtime-tools-settings-panel-CQ13P-mS.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Dq_VQpuY.js → schema-form-BUVyTpZj.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-gmEOYNb4.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DYYoJcl7.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CZu6FX4k.js → settings-form-section-DVY-8_B9.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-S8ekeUZd.js → settings-page-CdiVYyTl.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BdVmwXMv.js → setup-status-panel-BhenBnUj.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-D2fEidbn.js → share-preview-page-C88YLKm4.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Dq7xIj0_.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-MDI9Lz6z.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-AYiPlgZE.js → skills-page-DLir1nM0.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-DGzl-ib-.js → skills-page.utils-BMZAfS3G.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-5Xd5mIiR.js → system-settings-panel-BM8ivYan.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-P0_RldWv.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-ZVClZKQ0.js → theme-store-BOgkc_9D.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-CdZN1Jin.js → tunnel-api-DemxChjo.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-czRI0NBc.js → use-autosave-CV3Ui5hu.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CxfnoRVn.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-8YEvA3cU.js → voice-api-key-field-CUoCi4Sq.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-CopF64lY.js → voice-config-api-C-ryeIxj.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-keLtqYYJ.js → work-discovery-overlay-BhDlkCMB.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Dy5WgYMO.js → workflow-run-setup-panel-D8CcPc_C.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-Bxn2Dc16.js +5 -0
- package/dist/gateway/static/root/index.html +11 -11
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/user-message-display.js +18 -0
- package/dist/src/agent/agent-instance-gateway.d.ts +1 -1
- package/dist/src/agent/agent-manager.d.ts +9 -9
- package/dist/src/agent/agent-manager.js +46 -28
- package/dist/src/agent/background-review/prompts.d.ts +1 -1
- package/dist/src/agent/background-review/prompts.js +11 -2
- package/dist/src/agent/context/audit.d.ts +3 -1
- package/dist/src/agent/context/audit.js +32 -6
- package/dist/src/agent/context/coordinator.d.ts +6 -1
- package/dist/src/agent/context/coordinator.js +14 -13
- package/dist/src/agent/context/execution-context.d.ts +6 -47
- package/dist/src/agent/context/execution-context.js +79 -15
- package/dist/src/agent/context/execution-context.types.d.ts +50 -0
- package/dist/src/agent/context/execution-context.types.js +1 -0
- package/dist/src/agent/context/execution-scope.d.ts +5 -1
- package/dist/src/agent/context/execution-scope.js +6 -2
- package/dist/src/agent/context/project-context.d.ts +3 -0
- package/dist/src/agent/context/project-context.js +5 -3
- package/dist/src/agent/external-tools/index.d.ts +1 -0
- package/dist/src/agent/external-tools/index.js +1 -0
- package/dist/src/agent/external-tools/memory-provider.d.ts +1 -0
- package/dist/src/agent/external-tools/memory-provider.js +1 -0
- package/dist/src/agent/inbound/attachment-pipeline.js +5 -1
- package/dist/src/agent/memory/compaction-promotion.d.ts +1 -0
- package/dist/src/agent/memory/compaction-promotion.js +7 -2
- package/dist/src/agent/memory/index.d.ts +1 -1
- package/dist/src/agent/memory/index.js +3 -3
- package/dist/src/agent/memory/memory-config.d.ts +0 -5
- package/dist/src/agent/memory/memory-config.js +1 -8
- package/dist/src/agent/orchestration/context-overflow.js +1 -0
- package/dist/src/agent/service/direct-turn-helpers.d.ts +2 -2
- package/dist/src/agent/service/direct-turn-helpers.js +2 -2
- package/dist/src/agent/service/process-direct-streaming.js +3 -4
- package/dist/src/agent/tools/factory.d.ts +1 -0
- package/dist/src/agent/tools/factory.js +37 -7
- package/dist/src/agent/tools/knowledge-memory-tool.d.ts +6 -0
- package/dist/src/agent/tools/knowledge-memory-tool.js +81 -26
- package/dist/src/agent/tools/session-search-tool.d.ts +1 -0
- package/dist/src/agent/tools/session-search-tool.js +7 -0
- package/dist/src/agent/tools/user-context-tool.d.ts +2 -0
- package/dist/src/agent/tools/user-context-tool.js +21 -4
- package/dist/src/automations/service/automation-service.d.ts +2 -1
- package/dist/src/automations/service/automation-service.js +6 -2
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/connectors/connection-recovery-service.d.ts +1 -0
- package/dist/src/connectors/connection-recovery-service.js +46 -22
- package/dist/src/files/file-service.js +4 -1
- package/dist/src/gateway/hono/routes/connectors.js +17 -3
- package/dist/src/gateway/hono/routes/files.js +23 -2
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/security/gateway-scopes.js +2 -0
- package/dist/src/gateway/service/agent-runner.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service/session-input-coordinator.js +1 -1
- package/dist/src/gateway/service.js +8 -4
- package/dist/src/knowledge-memory/domain.d.ts +1 -0
- package/dist/src/knowledge-memory/index.js +2 -2
- package/dist/src/knowledge-memory/repository.d.ts +4 -1
- package/dist/src/knowledge-memory/repository.js +16 -2
- package/dist/src/notifications/planner.js +7 -3
- package/dist/src/proactive/actions/service.d.ts +0 -1
- package/dist/src/proactive/actions/service.js +1 -10
- package/dist/src/proactive/execution/context.d.ts +6 -8
- package/dist/src/proactive/execution/context.js +78 -32
- package/dist/src/proactive/execution/insight.d.ts +4 -1
- package/dist/src/proactive/execution/insight.js +5 -2
- package/dist/src/proactive/execution/repository.d.ts +1 -0
- package/dist/src/proactive/execution/repository.js +9 -1
- package/dist/src/proactive/execution/types.d.ts +0 -1
- package/dist/src/proactive/execution/worker.js +7 -5
- package/dist/src/proactive/inbox/repository.js +8 -2
- package/dist/src/proactive/inbox/service.js +2 -2
- package/dist/src/proactive/inbox/types.d.ts +1 -0
- package/dist/src/proactive/inbox/worker.d.ts +1 -0
- package/dist/src/proactive/inbox/worker.js +7 -0
- package/dist/src/proactive/index.d.ts +1 -0
- package/dist/src/proactive/index.js +2 -1
- package/dist/src/proactive/maintenance.d.ts +4 -0
- package/dist/src/proactive/maintenance.js +21 -0
- package/dist/src/proactive/scenarios/repository.d.ts +1 -1
- package/dist/src/proactive/scenarios/repository.js +10 -3
- package/dist/src/proactive/scenarios/types.d.ts +7 -0
- package/dist/src/proactive/service.d.ts +7 -0
- package/dist/src/proactive/service.js +17 -1
- package/dist/src/projects/project-service.d.ts +2 -1
- package/dist/src/projects/project-service.js +3 -2
- package/dist/src/session/index.js +1 -1
- package/dist/src/session/store.js +5 -2
- package/dist/src/storage/sqlite/collaboration-rule-repository.d.ts +3 -1
- package/dist/src/storage/sqlite/collaboration-rule-repository.js +1 -1
- package/dist/src/storage/sqlite/config-repository.js +1 -1
- package/dist/src/storage/sqlite/connection-wait-repository.js +2 -2
- package/dist/src/storage/sqlite/index.js +2 -2
- package/dist/src/storage/sqlite/migrations/151_proactive_scope_cleanup.sql +6 -0
- package/dist/src/storage/sqlite/migrations/152_proactive_scenario_contract.sql +140 -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/row-mappers.js +2 -2
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-input-repository.js +1 -1
- package/dist/src/storage/sqlite/session-instance-repository.d.ts +2 -0
- package/dist/src/storage/sqlite/session-instance-repository.js +6 -0
- package/dist/src/storage/sqlite/session-repository.d.ts +1 -1
- package/dist/src/storage/sqlite/session-repository.js +3 -5
- package/dist/src/storage/sqlite/transcript-repository.js +2 -1
- package/dist/src/tasks/home-query-service.js +35 -13
- package/dist/src/tasks/project-monitoring-service.d.ts +2 -0
- package/dist/src/tasks/project-monitoring-service.js +4 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/user-context/access-policy.d.ts +11 -0
- package/dist/src/user-context/access-policy.js +26 -0
- package/dist/src/user-model/capture/executor.d.ts +10 -0
- package/dist/src/user-model/capture/executor.js +99 -3
- package/dist/src/user-model/capture/semantic.d.ts +18 -0
- package/dist/src/user-model/capture/semantic.js +72 -6
- package/dist/src/user-model/goals.d.ts +4 -0
- package/dist/src/user-model/goals.js +4 -2
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C1rXNUAG.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BKjKTlW8.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-Dzq18pO1.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DW4SBQf4.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-57OGuewD.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CT_I3kbR.js +0 -2
- package/dist/gateway/static/root/assets/files-D6vf3S30.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DNhrZHqx.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BiHwiBnQ.js +0 -1
- package/dist/gateway/static/root/assets/index-aBs0EfQB.js +0 -72
- package/dist/gateway/static/root/assets/messages-W5P19VTF.js +0 -11
- package/dist/gateway/static/root/assets/note-detail-panel-CEEvR-fV.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-BLqgXNCx.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-CIiFJ5tk.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-B3UF-Pfm.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BUtpkJPG.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-UgJmG-V4.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DDCzpdkl.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BdsqnCYj.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-ghzAQKna.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-BQAUaCDD.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-W3GTm6nA.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-BbAV3h7n.js +0 -5
|
@@ -3,6 +3,7 @@ import { getKnowledgeSourceItem } from "../../storage/sqlite/knowledge-repositor
|
|
|
3
3
|
import { getConnectorSyncPolicyForConnection } from "../../storage/sqlite/connector-sync-policy-repository.js";
|
|
4
4
|
import { getAssertionSlot, listUserAssertions } from "../../user-model/repository.js";
|
|
5
5
|
import "../../user-model/index.js";
|
|
6
|
+
import { getDiscussionCapture, getLatestDiscussionOrganization } from "../../discussions/repository.js";
|
|
6
7
|
import { wrapExternalContent } from "../../gateway/security/external-content.js";
|
|
7
8
|
//#region src/proactive/execution/context.ts
|
|
8
9
|
const MAX_EVENT_COUNT = 50;
|
|
@@ -39,9 +40,6 @@ function authorizedConnectedSourceItem(event, scenarioKey) {
|
|
|
39
40
|
}
|
|
40
41
|
var EventBatchContextProvider = class {
|
|
41
42
|
id = "event_batch";
|
|
42
|
-
supports() {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
43
|
async collect(input) {
|
|
46
44
|
const rows = eventRows(input.eventIds).filter((row) => !row.type.startsWith("connected_source.") || Boolean(authorizedConnectedSourceItem(row, input.scenarioKey)));
|
|
47
45
|
return {
|
|
@@ -61,9 +59,6 @@ var EventBatchContextProvider = class {
|
|
|
61
59
|
};
|
|
62
60
|
var ConnectedSourceContextProvider = class {
|
|
63
61
|
id = "connected_source";
|
|
64
|
-
supports() {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
62
|
async collect(input) {
|
|
68
63
|
const items = [];
|
|
69
64
|
const snapshotItems = [];
|
|
@@ -104,9 +99,6 @@ var ConnectedSourceContextProvider = class {
|
|
|
104
99
|
};
|
|
105
100
|
var InternalObjectContextProvider = class {
|
|
106
101
|
id = "internal_objects";
|
|
107
|
-
supports() {
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
102
|
async collect(input) {
|
|
111
103
|
const db = getSqliteDatabase();
|
|
112
104
|
const objects = [];
|
|
@@ -157,9 +149,6 @@ var InternalObjectContextProvider = class {
|
|
|
157
149
|
};
|
|
158
150
|
var UserModelContextProvider = class {
|
|
159
151
|
id = "user_model";
|
|
160
|
-
supports() {
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
152
|
async collect(input) {
|
|
164
153
|
const scope = eventRows(input.eventIds).at(-1);
|
|
165
154
|
if (!scope) return emptyContext();
|
|
@@ -186,9 +175,6 @@ var UserModelContextProvider = class {
|
|
|
186
175
|
};
|
|
187
176
|
var MeetingWorkspaceContextProvider = class {
|
|
188
177
|
id = "meeting_workspace";
|
|
189
|
-
supports(scenarioKey) {
|
|
190
|
-
return scenarioKey === "meeting_preparation";
|
|
191
|
-
}
|
|
192
178
|
async collect(input) {
|
|
193
179
|
const scope = eventRows(input.eventIds).at(-1);
|
|
194
180
|
if (!scope) return emptyContext();
|
|
@@ -237,16 +223,27 @@ var MeetingWorkspaceContextProvider = class {
|
|
|
237
223
|
};
|
|
238
224
|
var ProjectStateContextProvider = class {
|
|
239
225
|
id = "project_state";
|
|
240
|
-
supports(scenarioKey) {
|
|
241
|
-
return scenarioKey === "project_delivery_risk" || scenarioKey === "blocked_work";
|
|
242
|
-
}
|
|
243
226
|
async collect(input) {
|
|
244
227
|
if (!input.eventIds.length) return emptyContext();
|
|
245
228
|
const project = getSqliteDatabase().prepare(`SELECT p.* FROM proactive_events e JOIN projects p ON p.project_id = e.project_id
|
|
246
229
|
WHERE e.event_id IN (${input.eventIds.map(() => "?").join(",")}) AND e.project_id IS NOT NULL ORDER BY e.occurred_at DESC LIMIT 1`).get(...input.eventIds);
|
|
247
230
|
if (!project) return emptyContext();
|
|
248
231
|
const tasks = getSqliteDatabase().prepare(`SELECT task.task_id, task.title, task.body,
|
|
249
|
-
task.phase, task.resolution, task.priority, task.due_at, task.updated_at
|
|
232
|
+
task.phase, task.resolution, task.priority, task.due_at, task.updated_at,
|
|
233
|
+
(SELECT wait.kind FROM task_waits wait
|
|
234
|
+
WHERE wait.task_id = task.task_id AND wait.status = 'active'
|
|
235
|
+
ORDER BY wait.created_at DESC LIMIT 1) AS wait_kind,
|
|
236
|
+
(SELECT wait.reason FROM task_waits wait
|
|
237
|
+
WHERE wait.task_id = task.task_id AND wait.status = 'active'
|
|
238
|
+
ORDER BY wait.created_at DESC LIMIT 1) AS wait_reason,
|
|
239
|
+
(SELECT json_group_array(json_object(
|
|
240
|
+
'taskId', dependency.depends_on_task_id,
|
|
241
|
+
'title', upstream.title,
|
|
242
|
+
'phase', upstream.phase,
|
|
243
|
+
'resolution', upstream.resolution
|
|
244
|
+
)) FROM task_dependencies dependency
|
|
245
|
+
JOIN tasks upstream ON upstream.task_id = dependency.depends_on_task_id
|
|
246
|
+
WHERE dependency.task_id = task.task_id) AS dependencies_json
|
|
250
247
|
FROM tasks task
|
|
251
248
|
WHERE task.project_id = ? AND task.phase <> 'closed'
|
|
252
249
|
ORDER BY CASE WHEN EXISTS (
|
|
@@ -261,10 +258,14 @@ var ProjectStateContextProvider = class {
|
|
|
261
258
|
evidenceId: projectEvidenceId,
|
|
262
259
|
...project
|
|
263
260
|
},
|
|
264
|
-
activeTasks: tasks.map((task, index) =>
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
261
|
+
activeTasks: tasks.map((task, index) => {
|
|
262
|
+
const { dependencies_json: dependenciesJson, ...fields } = task;
|
|
263
|
+
return {
|
|
264
|
+
evidenceId: taskEvidenceIds[index],
|
|
265
|
+
...fields,
|
|
266
|
+
dependencies: dependenciesJson ? JSON.parse(String(dependenciesJson)) : []
|
|
267
|
+
};
|
|
268
|
+
})
|
|
268
269
|
},
|
|
269
270
|
evidenceIds: [projectEvidenceId, ...taskEvidenceIds]
|
|
270
271
|
};
|
|
@@ -272,9 +273,6 @@ var ProjectStateContextProvider = class {
|
|
|
272
273
|
};
|
|
273
274
|
var AutomationStateContextProvider = class {
|
|
274
275
|
id = "automation_state";
|
|
275
|
-
supports(scenarioKey) {
|
|
276
|
-
return scenarioKey === "automation_failure_impact";
|
|
277
|
-
}
|
|
278
276
|
async collect(input) {
|
|
279
277
|
if (!input.eventIds.length) return emptyContext();
|
|
280
278
|
const run = getSqliteDatabase().prepare(`SELECT r.* FROM proactive_events e JOIN automation_runs r ON r.run_id = e.subject_id
|
|
@@ -282,6 +280,9 @@ var AutomationStateContextProvider = class {
|
|
|
282
280
|
if (!run) return emptyContext();
|
|
283
281
|
const automation = getSqliteDatabase().prepare(`SELECT automation_id, name, description, enabled, reliability_json, state_json, project_id
|
|
284
282
|
FROM automations WHERE automation_id = ?`).get(String(run.automation_id));
|
|
283
|
+
const recentRuns = getSqliteDatabase().prepare(`SELECT run_id, status, summary, error, duration_ms, started_at, ended_at
|
|
284
|
+
FROM automation_runs WHERE automation_id = ? AND run_id <> ?
|
|
285
|
+
ORDER BY started_at DESC LIMIT 5`).all(String(run.automation_id), String(run.run_id));
|
|
285
286
|
const runEvidenceId = `automation-run:${String(run.run_id)}`;
|
|
286
287
|
return {
|
|
287
288
|
content: {
|
|
@@ -289,12 +290,50 @@ var AutomationStateContextProvider = class {
|
|
|
289
290
|
failedRun: {
|
|
290
291
|
evidenceId: runEvidenceId,
|
|
291
292
|
...run
|
|
292
|
-
}
|
|
293
|
+
},
|
|
294
|
+
recentRuns
|
|
293
295
|
},
|
|
294
296
|
evidenceIds: [runEvidenceId]
|
|
295
297
|
};
|
|
296
298
|
}
|
|
297
299
|
};
|
|
300
|
+
var DiscussionContextProvider = class {
|
|
301
|
+
id = "discussion";
|
|
302
|
+
async collect(input) {
|
|
303
|
+
const event = eventRows(input.eventIds).findLast((row) => row.subject_kind === "discussion");
|
|
304
|
+
if (!event) return emptyContext();
|
|
305
|
+
const discussion = getDiscussionCapture(event.subject_id);
|
|
306
|
+
if (!discussion || discussion.status !== "completed") return emptyContext();
|
|
307
|
+
const organization = getLatestDiscussionOrganization(discussion.id);
|
|
308
|
+
const discussionEvidenceId = `discussion:${discussion.id}`;
|
|
309
|
+
const noteEvidenceId = `note:${discussion.noteId}`;
|
|
310
|
+
return {
|
|
311
|
+
content: { discussion: {
|
|
312
|
+
evidenceId: discussionEvidenceId,
|
|
313
|
+
id: discussion.id,
|
|
314
|
+
noteId: discussion.noteId,
|
|
315
|
+
noteEvidenceId,
|
|
316
|
+
projectId: discussion.projectId,
|
|
317
|
+
title: discussion.generatedTitle,
|
|
318
|
+
transcript: boundedText(discussion.canonicalTranscript, 6e3),
|
|
319
|
+
organization: organization?.organization,
|
|
320
|
+
completedAt: discussion.completedAt
|
|
321
|
+
} },
|
|
322
|
+
snapshotContent: { discussion: {
|
|
323
|
+
evidenceId: discussionEvidenceId,
|
|
324
|
+
id: discussion.id,
|
|
325
|
+
noteId: discussion.noteId,
|
|
326
|
+
noteEvidenceId,
|
|
327
|
+
projectId: discussion.projectId,
|
|
328
|
+
transcriptSha256: discussion.canonicalTranscriptSha256,
|
|
329
|
+
organizationRevision: organization?.revision,
|
|
330
|
+
organization: organization?.organization,
|
|
331
|
+
completedAt: discussion.completedAt
|
|
332
|
+
} },
|
|
333
|
+
evidenceIds: [discussionEvidenceId, noteEvidenceId]
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
};
|
|
298
337
|
var ContextProviderRegistry = class {
|
|
299
338
|
constructor(providers = [
|
|
300
339
|
new EventBatchContextProvider(),
|
|
@@ -303,14 +342,21 @@ var ContextProviderRegistry = class {
|
|
|
303
342
|
new UserModelContextProvider(),
|
|
304
343
|
new MeetingWorkspaceContextProvider(),
|
|
305
344
|
new ProjectStateContextProvider(),
|
|
306
|
-
new AutomationStateContextProvider()
|
|
345
|
+
new AutomationStateContextProvider(),
|
|
346
|
+
new DiscussionContextProvider()
|
|
307
347
|
]) {
|
|
308
348
|
this.providers = providers;
|
|
309
349
|
}
|
|
310
|
-
async collect(
|
|
311
|
-
const
|
|
350
|
+
async collect(scenario, input) {
|
|
351
|
+
const providers = new Map(this.providers.map((provider) => [provider.id, provider]));
|
|
352
|
+
const selected = scenario.contextProviderIds.map((id) => {
|
|
353
|
+
const provider = providers.get(id);
|
|
354
|
+
if (!provider) throw new Error(`Unknown context provider: ${id}`);
|
|
355
|
+
return provider;
|
|
356
|
+
});
|
|
357
|
+
const entries = await Promise.all(selected.map(async (provider) => [provider.id, await provider.collect({
|
|
312
358
|
...input,
|
|
313
|
-
scenarioKey
|
|
359
|
+
scenarioKey: scenario.key
|
|
314
360
|
})]));
|
|
315
361
|
return {
|
|
316
362
|
content: Object.fromEntries(entries.map(([id, result]) => [id, result.content])),
|
|
@@ -320,4 +366,4 @@ var ContextProviderRegistry = class {
|
|
|
320
366
|
}
|
|
321
367
|
};
|
|
322
368
|
//#endregion
|
|
323
|
-
export { AutomationStateContextProvider, ConnectedSourceContextProvider, ContextProviderRegistry, EventBatchContextProvider, InternalObjectContextProvider, MeetingWorkspaceContextProvider, ProjectStateContextProvider, UserModelContextProvider };
|
|
369
|
+
export { AutomationStateContextProvider, ConnectedSourceContextProvider, ContextProviderRegistry, DiscussionContextProvider, EventBatchContextProvider, InternalObjectContextProvider, MeetingWorkspaceContextProvider, ProjectStateContextProvider, UserModelContextProvider };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { InsightCandidate } from './types.js';
|
|
2
2
|
export declare function parseInsightCandidate(raw: string, allowedEvidenceIds: Set<string>): InsightCandidate;
|
|
3
3
|
export declare function scoreInsight(candidate: InsightCandidate): number;
|
|
4
|
-
export declare function isValuableInsight(candidate: InsightCandidate
|
|
4
|
+
export declare function isValuableInsight(candidate: InsightCandidate, policy?: {
|
|
5
|
+
minConfidence: number;
|
|
6
|
+
minScore: number;
|
|
7
|
+
}): boolean;
|
|
@@ -87,8 +87,11 @@ function scoreInsight(candidate) {
|
|
|
87
87
|
}[candidate.urgency];
|
|
88
88
|
return Math.round((candidate.confidence * .7 + urgencyWeight * .3) * 1e3) / 1e3;
|
|
89
89
|
}
|
|
90
|
-
function isValuableInsight(candidate
|
|
91
|
-
|
|
90
|
+
function isValuableInsight(candidate, policy = {
|
|
91
|
+
minConfidence: .65,
|
|
92
|
+
minScore: .6
|
|
93
|
+
}) {
|
|
94
|
+
return candidate.confidence >= policy.minConfidence && candidate.urgency !== "low" && scoreInsight(candidate) >= policy.minScore;
|
|
92
95
|
}
|
|
93
96
|
//#endregion
|
|
94
97
|
export { isValuableInsight, parseInsightCandidate, scoreInsight };
|
|
@@ -5,8 +5,16 @@ const str = (row, key) => String(row[key]);
|
|
|
5
5
|
function claimNextRun(owner, now = /* @__PURE__ */ new Date(), leaseSeconds = 120) {
|
|
6
6
|
return runSqliteWriteTransaction((db) => {
|
|
7
7
|
const nowIso = now.toISOString();
|
|
8
|
+
const dayStart = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate())).toISOString();
|
|
8
9
|
db.prepare(`UPDATE proactive_signal_batches SET status = 'ignored', updated_at = ? WHERE status = 'ready'
|
|
9
10
|
AND subscription_id IN (SELECT subscription_id FROM proactive_scenario_subscriptions WHERE enabled = 0)`).run(nowIso);
|
|
11
|
+
db.prepare(`UPDATE proactive_signal_batches AS batch SET status = 'ignored', updated_at = ?
|
|
12
|
+
WHERE batch.status = 'ready' AND EXISTS (
|
|
13
|
+
SELECT 1 FROM proactive_scenario_versions scenario
|
|
14
|
+
WHERE scenario.scenario_key = batch.scenario_key AND scenario.version = batch.scenario_version
|
|
15
|
+
AND (SELECT COUNT(*) FROM proactive_runs run
|
|
16
|
+
WHERE run.scenario_key = batch.scenario_key AND run.started_at >= ?) >= scenario.max_runs_per_day
|
|
17
|
+
)`).run(nowIso, dayStart);
|
|
10
18
|
db.prepare(`UPDATE proactive_signal_batches SET status = 'failed_permanent', updated_at = ?
|
|
11
19
|
WHERE status = 'processing' AND batch_id IN (
|
|
12
20
|
SELECT batch_id FROM proactive_runs WHERE status = 'running' AND lease_expires_at <= ? AND attempt >= 3
|
|
@@ -80,7 +88,7 @@ function finishRun(input, now = /* @__PURE__ */ new Date()) {
|
|
|
80
88
|
input.candidate.recommendation
|
|
81
89
|
].map((value) => value.trim().toLowerCase().replace(/\s+/g, " "))].join("\n")).digest("hex") : void 0;
|
|
82
90
|
const duplicate = fingerprint ? db.prepare(`SELECT 1 FROM proactive_insights
|
|
83
|
-
WHERE subscription_id = ? AND scenario_key = ? AND content_fingerprint = ? AND created_at >= ? LIMIT 1`).get(input.run.subscriptionId, input.run.scenarioKey, fingerprint, (/* @__PURE__ */ new Date(now.getTime() - 10080 *
|
|
91
|
+
WHERE subscription_id = ? AND scenario_key = ? AND content_fingerprint = ? AND created_at >= ? LIMIT 1`).get(input.run.subscriptionId, input.run.scenarioKey, fingerprint, (/* @__PURE__ */ new Date(now.getTime() - (input.cooldownSeconds ?? 10080 * 60) * 1e3)).toISOString()) : void 0;
|
|
84
92
|
const valuable = Boolean(input.candidate) && !duplicate;
|
|
85
93
|
db.prepare(`UPDATE proactive_runs SET status = ?, raw_output = ?, model_ref = ?, lease_owner = NULL,
|
|
86
94
|
lease_expires_at = NULL, completed_at = ?, updated_at = ? WHERE run_id = ?`).run(valuable ? "completed" : "discarded", input.rawOutput.slice(0, 2e4), input.modelRef ?? null, nowIso, nowIso, input.run.id);
|
|
@@ -40,11 +40,11 @@ var ProactiveWorker = class {
|
|
|
40
40
|
const run = claimNextRun(this.owner);
|
|
41
41
|
if (!run) return;
|
|
42
42
|
try {
|
|
43
|
-
const scenario = getScenario(run.scenarioKey);
|
|
44
|
-
if (!scenario
|
|
43
|
+
const scenario = getScenario(run.scenarioKey, run.scenarioVersion);
|
|
44
|
+
if (!scenario) throw new Error("Pinned scenario version is unavailable");
|
|
45
45
|
const revision = run.promptRevisionId ? getPromptRevision(run.promptRevisionId) ?? void 0 : void 0;
|
|
46
46
|
const eventIds = eventIdsForBatch(run.batchId);
|
|
47
|
-
const context = await this.contexts.collect(
|
|
47
|
+
const context = await this.contexts.collect(scenario, {
|
|
48
48
|
batchId: run.batchId,
|
|
49
49
|
eventIds,
|
|
50
50
|
subscriptionId: run.subscriptionId
|
|
@@ -62,13 +62,15 @@ var ProactiveWorker = class {
|
|
|
62
62
|
authorizedContext: context.content
|
|
63
63
|
});
|
|
64
64
|
const candidate = parseInsightCandidate(output.text, new Set(context.evidenceIds));
|
|
65
|
-
const
|
|
65
|
+
const valueScore = scoreInsight(candidate);
|
|
66
|
+
const valuable = isValuableInsight(candidate, scenario.valuePolicy);
|
|
66
67
|
const insight = finishRun({
|
|
67
68
|
run,
|
|
68
69
|
...valuable ? {
|
|
69
70
|
candidate,
|
|
70
|
-
valueScore
|
|
71
|
+
valueScore
|
|
71
72
|
} : {},
|
|
73
|
+
cooldownSeconds: scenario.valuePolicy.cooldownSeconds,
|
|
72
74
|
rawOutput: output.text,
|
|
73
75
|
modelRef: output.modelRef
|
|
74
76
|
});
|
|
@@ -4,6 +4,7 @@ import { randomUUID } from "node:crypto";
|
|
|
4
4
|
//#region src/proactive/inbox/repository.ts
|
|
5
5
|
const s = (row, key) => String(row[key]);
|
|
6
6
|
function itemFromRow(row) {
|
|
7
|
+
const attentionKind = row.action_status === "completed" ? "receipt" : row.decision_json || row.action_status === "approval_required" ? "decision" : "information";
|
|
7
8
|
return {
|
|
8
9
|
id: s(row, "inbox_item_id"),
|
|
9
10
|
insightId: s(row, "insight_id"),
|
|
@@ -30,7 +31,8 @@ function itemFromRow(row) {
|
|
|
30
31
|
urgency: s(row, "urgency"),
|
|
31
32
|
confidence: Number(row.confidence),
|
|
32
33
|
valueScore: Number(row.value_score),
|
|
33
|
-
evidenceIds: JSON.parse(s(row, "evidence_ids_json"))
|
|
34
|
+
evidenceIds: JSON.parse(s(row, "evidence_ids_json")),
|
|
35
|
+
attentionKind
|
|
34
36
|
}
|
|
35
37
|
};
|
|
36
38
|
}
|
|
@@ -124,13 +126,17 @@ function transitionInboxItem(id, input, now = /* @__PURE__ */ new Date()) {
|
|
|
124
126
|
function recordDecision(id, choice, note = "", now = /* @__PURE__ */ new Date()) {
|
|
125
127
|
if (!choice.trim()) throw new Error("choice is required");
|
|
126
128
|
runSqliteWriteTransaction((db) => {
|
|
127
|
-
const row = db.prepare(`SELECT x.decision_json FROM proactive_inbox_items i
|
|
129
|
+
const row = db.prepare(`SELECT i.status, x.decision_json, x.action_status FROM proactive_inbox_items i
|
|
128
130
|
JOIN proactive_insights x ON x.insight_id = i.insight_id WHERE i.inbox_item_id = ?`).get(id);
|
|
129
131
|
if (!row) throw new Error("Inbox item not found");
|
|
132
|
+
if (row.status === "resolved") throw new Error("Inbox item is already resolved");
|
|
130
133
|
if (!row.decision_json) throw new Error("Inbox item does not require a decision");
|
|
131
134
|
if (!JSON.parse(row.decision_json).options.some((option) => option.id === choice.trim())) throw new Error("choice is not a valid decision option");
|
|
132
135
|
db.prepare("INSERT INTO proactive_decisions (decision_id, inbox_item_id, choice, note, created_at) VALUES (?, ?, ?, ?, ?)").run(randomUUID(), id, choice.trim().slice(0, 200), note.trim().slice(0, 2e3), now.toISOString());
|
|
133
136
|
db.prepare("UPDATE proactive_inbox_items SET status = 'resolved', resolution = ?, updated_at = ? WHERE inbox_item_id = ?").run(choice.trim().slice(0, 200), now.toISOString(), id);
|
|
137
|
+
if (row.action_status === "approval_required") db.prepare(`UPDATE proactive_insights SET action_status = ?, action_updated_at = ?
|
|
138
|
+
WHERE insight_id = (SELECT insight_id FROM proactive_inbox_items WHERE inbox_item_id = ?)
|
|
139
|
+
AND action_status = 'approval_required'`).run(choice === "approve" ? "pending" : "rejected", now.toISOString(), id);
|
|
134
140
|
});
|
|
135
141
|
return getInboxItem(id);
|
|
136
142
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { publishInstructionFeedback } from "../scenarios/repository.js";
|
|
2
|
-
import {
|
|
2
|
+
import { executePendingProactiveActions } from "../actions/service.js";
|
|
3
3
|
import { getInboxItem, getInboxSubscriptionId, listInbox, projectInsightsToInbox, recordDecision, recordFeedback, transitionInboxItem, wakeSnoozedItems } from "./repository.js";
|
|
4
4
|
//#region src/proactive/inbox/service.ts
|
|
5
5
|
var ProactiveInboxService = class {
|
|
@@ -9,7 +9,7 @@ var ProactiveInboxService = class {
|
|
|
9
9
|
feedback = recordFeedback;
|
|
10
10
|
decide(id, choice, note = "") {
|
|
11
11
|
const item = recordDecision(id, choice, note);
|
|
12
|
-
|
|
12
|
+
if (choice === "approve") executePendingProactiveActions();
|
|
13
13
|
return getInboxItem(id) ?? item;
|
|
14
14
|
}
|
|
15
15
|
instruct(id, instruction) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createLogger } from "../../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../../utils/logger.js";
|
|
3
|
+
import { pruneProactiveHistory } from "../maintenance.js";
|
|
3
4
|
import { executePendingProactiveActions } from "../actions/service.js";
|
|
4
5
|
import { claimDelivery, finishDelivery, projectInsightsToInbox, recoverExpiredDeliveries, wakeSnoozedItems } from "./repository.js";
|
|
5
6
|
//#region src/proactive/inbox/worker.ts
|
|
@@ -9,6 +10,7 @@ var ProactiveInboxWorker = class {
|
|
|
9
10
|
timer;
|
|
10
11
|
running = false;
|
|
11
12
|
waiters = [];
|
|
13
|
+
lastMaintenanceAt = 0;
|
|
12
14
|
constructor(delivery, intervalMs = 3e3) {
|
|
13
15
|
this.delivery = delivery;
|
|
14
16
|
this.intervalMs = intervalMs;
|
|
@@ -28,6 +30,11 @@ var ProactiveInboxWorker = class {
|
|
|
28
30
|
if (this.running) return;
|
|
29
31
|
this.running = true;
|
|
30
32
|
try {
|
|
33
|
+
const now = Date.now();
|
|
34
|
+
if (now - this.lastMaintenanceAt >= 60 * 6e4) {
|
|
35
|
+
pruneProactiveHistory(new Date(now));
|
|
36
|
+
this.lastMaintenanceAt = now;
|
|
37
|
+
}
|
|
31
38
|
projectInsightsToInbox();
|
|
32
39
|
executePendingProactiveActions();
|
|
33
40
|
wakeSnoozedItems();
|
|
@@ -6,6 +6,7 @@ export { matchesCondition, matchScenario } from './routing/matcher.js';
|
|
|
6
6
|
export type { EventCondition, ScenarioRoute } from './routing/types.js';
|
|
7
7
|
export type { SignalBatch } from './routing/batch-repository.js';
|
|
8
8
|
export { ProactiveEventService } from './service.js';
|
|
9
|
+
export { pruneProactiveHistory } from './maintenance.js';
|
|
9
10
|
export { ProactiveScenarioService } from './scenarios/service.js';
|
|
10
11
|
export type { PromptRevision, ScenarioDefinition, ScenarioSubscription } from './scenarios/types.js';
|
|
11
12
|
export { AutomationStateContextProvider, ConnectedSourceContextProvider, ContextProviderRegistry, EventBatchContextProvider, InternalObjectContextProvider, MeetingWorkspaceContextProvider, ProjectStateContextProvider, UserModelContextProvider, } from './execution/context.js';
|
|
@@ -3,6 +3,7 @@ import { normalizeEventEnvelope } from "./events/envelope.js";
|
|
|
3
3
|
import { mapProductEventToProactive } from "./events/product-event-bridge.js";
|
|
4
4
|
import { matchScenario, matchesCondition } from "./routing/matcher.js";
|
|
5
5
|
import { ProactiveEventService } from "./service.js";
|
|
6
|
+
import { pruneProactiveHistory } from "./maintenance.js";
|
|
6
7
|
import { AutomationStateContextProvider, ConnectedSourceContextProvider, ContextProviderRegistry, EventBatchContextProvider, InternalObjectContextProvider, MeetingWorkspaceContextProvider, ProjectStateContextProvider, UserModelContextProvider } from "./execution/context.js";
|
|
7
8
|
import { ReadonlyProactiveAgentExecutor } from "./execution/agent-executor.js";
|
|
8
9
|
import { listInsights } from "./execution/repository.js";
|
|
@@ -10,4 +11,4 @@ import { ProactiveWorker } from "./execution/worker.js";
|
|
|
10
11
|
import { ProactiveTemporalWorker } from "./temporal/worker.js";
|
|
11
12
|
import { ProactiveInboxService } from "./inbox/service.js";
|
|
12
13
|
import { ProactiveInboxWorker } from "./inbox/worker.js";
|
|
13
|
-
export { AutomationStateContextProvider, ConnectedSourceContextProvider, ContextProviderRegistry, EventBatchContextProvider, InternalObjectContextProvider, MeetingWorkspaceContextProvider, ProactiveEventService, ProactiveInboxService, ProactiveInboxWorker, ProactiveScenarioService, ProactiveTemporalWorker, ProactiveWorker, ProjectStateContextProvider, ReadonlyProactiveAgentExecutor, UserModelContextProvider, listInsights, mapProductEventToProactive, matchScenario, matchesCondition, normalizeEventEnvelope };
|
|
14
|
+
export { AutomationStateContextProvider, ConnectedSourceContextProvider, ContextProviderRegistry, EventBatchContextProvider, InternalObjectContextProvider, MeetingWorkspaceContextProvider, ProactiveEventService, ProactiveInboxService, ProactiveInboxWorker, ProactiveScenarioService, ProactiveTemporalWorker, ProactiveWorker, ProjectStateContextProvider, ReadonlyProactiveAgentExecutor, UserModelContextProvider, listInsights, mapProductEventToProactive, matchScenario, matchesCondition, normalizeEventEnvelope, pruneProactiveHistory };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
+
//#region src/proactive/maintenance.ts
|
|
3
|
+
const RETENTION_DAYS = 90;
|
|
4
|
+
function pruneProactiveHistory(now = /* @__PURE__ */ new Date()) {
|
|
5
|
+
const cutoff = (/* @__PURE__ */ new Date(now.getTime() - RETENTION_DAYS * 24 * 60 * 6e4)).toISOString();
|
|
6
|
+
return runSqliteWriteTransaction((db) => {
|
|
7
|
+
const batches = db.prepare(`DELETE FROM proactive_signal_batches
|
|
8
|
+
WHERE updated_at < ? AND status IN ('processed', 'ignored', 'failed_permanent', 'expired')`).run(cutoff).changes;
|
|
9
|
+
const events = db.prepare(`DELETE FROM proactive_events
|
|
10
|
+
WHERE observed_at < ? AND NOT EXISTS (
|
|
11
|
+
SELECT 1 FROM proactive_batch_events batch_event
|
|
12
|
+
WHERE batch_event.event_id = proactive_events.event_id
|
|
13
|
+
)`).run(cutoff).changes;
|
|
14
|
+
return {
|
|
15
|
+
batches: Number(batches),
|
|
16
|
+
events: Number(events)
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { pruneProactiveHistory };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ScenarioRoute } from '../routing/types.js';
|
|
2
2
|
import type { PromptRevision, ScenarioDefinition, ScenarioSubscription } from './types.js';
|
|
3
3
|
export declare function listScenarios(): ScenarioDefinition[];
|
|
4
|
-
export declare function getScenario(key: string): ScenarioDefinition | null;
|
|
4
|
+
export declare function getScenario(key: string, version?: number): ScenarioDefinition | null;
|
|
5
5
|
export declare function upsertSubscription(input: {
|
|
6
6
|
scenarioKey: string;
|
|
7
7
|
workspaceId: string;
|
|
@@ -15,7 +15,14 @@ function scenarioFromRow(row) {
|
|
|
15
15
|
...condition ? { condition } : {},
|
|
16
16
|
aggregation: text(row, "aggregation"),
|
|
17
17
|
debounceSeconds: Number(row.debounce_seconds),
|
|
18
|
-
maxWindowSeconds: Number(row.max_window_seconds)
|
|
18
|
+
maxWindowSeconds: Number(row.max_window_seconds),
|
|
19
|
+
contextProviderIds: JSON.parse(text(row, "context_provider_ids_json")),
|
|
20
|
+
valuePolicy: {
|
|
21
|
+
minConfidence: Number(row.min_confidence),
|
|
22
|
+
minScore: Number(row.min_value_score),
|
|
23
|
+
cooldownSeconds: Number(row.cooldown_seconds),
|
|
24
|
+
maxRunsPerDay: Number(row.max_runs_per_day)
|
|
25
|
+
}
|
|
19
26
|
};
|
|
20
27
|
}
|
|
21
28
|
function subscriptionFromRow(row) {
|
|
@@ -47,8 +54,8 @@ function revisionFromRow(row) {
|
|
|
47
54
|
function listScenarios() {
|
|
48
55
|
return getSqliteDatabase().prepare("SELECT * FROM proactive_scenarios ORDER BY scenario_key").all().map(scenarioFromRow);
|
|
49
56
|
}
|
|
50
|
-
function getScenario(key) {
|
|
51
|
-
const row = getSqliteDatabase().prepare("SELECT * FROM proactive_scenarios WHERE scenario_key = ?").get(key);
|
|
57
|
+
function getScenario(key, version) {
|
|
58
|
+
const row = version === void 0 ? getSqliteDatabase().prepare("SELECT * FROM proactive_scenarios WHERE scenario_key = ?").get(key) : getSqliteDatabase().prepare("SELECT * FROM proactive_scenario_versions WHERE scenario_key = ? AND version = ?").get(key, version);
|
|
52
59
|
return row ? scenarioFromRow(row) : null;
|
|
53
60
|
}
|
|
54
61
|
function upsertSubscription(input, now = /* @__PURE__ */ new Date()) {
|
|
@@ -11,6 +11,13 @@ export interface ScenarioDefinition {
|
|
|
11
11
|
aggregation: ScenarioRoute['aggregation'];
|
|
12
12
|
debounceSeconds: number;
|
|
13
13
|
maxWindowSeconds: number;
|
|
14
|
+
contextProviderIds: string[];
|
|
15
|
+
valuePolicy: {
|
|
16
|
+
minConfidence: number;
|
|
17
|
+
minScore: number;
|
|
18
|
+
cooldownSeconds: number;
|
|
19
|
+
maxRunsPerDay: number;
|
|
20
|
+
};
|
|
14
21
|
}
|
|
15
22
|
export interface ScenarioSubscription {
|
|
16
23
|
id: string;
|
|
@@ -14,5 +14,12 @@ export declare class ProactiveEventService {
|
|
|
14
14
|
collecting: number;
|
|
15
15
|
ready: number;
|
|
16
16
|
oldestReadyAt: string | null;
|
|
17
|
+
last24Hours: {
|
|
18
|
+
runs: number;
|
|
19
|
+
insights: number;
|
|
20
|
+
discarded: number;
|
|
21
|
+
useful: number;
|
|
22
|
+
notUseful: number;
|
|
23
|
+
};
|
|
17
24
|
};
|
|
18
25
|
}
|
|
@@ -49,11 +49,27 @@ var ProactiveEventService = class {
|
|
|
49
49
|
SUM(CASE WHEN status = 'ready' THEN 1 ELSE 0 END) AS ready,
|
|
50
50
|
MIN(CASE WHEN status = 'ready' THEN ready_at END) AS oldest_ready_at
|
|
51
51
|
FROM proactive_signal_batches`).get();
|
|
52
|
+
const since = (/* @__PURE__ */ new Date(Date.now() - 1440 * 6e4)).toISOString();
|
|
53
|
+
const runs = db.prepare(`SELECT COUNT(*) AS runs,
|
|
54
|
+
SUM(CASE WHEN status = 'discarded' THEN 1 ELSE 0 END) AS discarded
|
|
55
|
+
FROM proactive_runs WHERE started_at >= ?`).get(since);
|
|
56
|
+
const insights = db.prepare("SELECT COUNT(*) AS count FROM proactive_insights WHERE created_at >= ?").get(since);
|
|
57
|
+
const feedback = db.prepare(`SELECT
|
|
58
|
+
SUM(CASE WHEN rating = 'useful' THEN 1 ELSE 0 END) AS useful,
|
|
59
|
+
SUM(CASE WHEN rating = 'not_useful' THEN 1 ELSE 0 END) AS not_useful
|
|
60
|
+
FROM proactive_feedback WHERE created_at >= ?`).get(since);
|
|
52
61
|
return {
|
|
53
62
|
events: events.count,
|
|
54
63
|
collecting: batches.collecting ?? 0,
|
|
55
64
|
ready: batches.ready ?? 0,
|
|
56
|
-
oldestReadyAt: batches.oldest_ready_at
|
|
65
|
+
oldestReadyAt: batches.oldest_ready_at,
|
|
66
|
+
last24Hours: {
|
|
67
|
+
runs: runs.runs,
|
|
68
|
+
insights: insights.count,
|
|
69
|
+
discarded: runs.discarded ?? 0,
|
|
70
|
+
useful: feedback.useful ?? 0,
|
|
71
|
+
notUseful: feedback.not_useful ?? 0
|
|
72
|
+
}
|
|
57
73
|
};
|
|
58
74
|
}
|
|
59
75
|
};
|
|
@@ -11,7 +11,8 @@ export type ProjectSuggestion = {
|
|
|
11
11
|
export declare class ProjectService {
|
|
12
12
|
private readonly store;
|
|
13
13
|
private readonly signals?;
|
|
14
|
-
|
|
14
|
+
private readonly workspaceId;
|
|
15
|
+
constructor(store?: ProjectStore, signals?: ProactiveSignalPublisher, workspaceId?: string);
|
|
15
16
|
private listAllProjects;
|
|
16
17
|
create(input: CreateProjectInput): Project;
|
|
17
18
|
get(id: string): Project | null;
|
|
@@ -9,9 +9,10 @@ import { bindSessionToProject, listProjectSessionKeys, unbindSessionFromProject
|
|
|
9
9
|
import { createHash } from "node:crypto";
|
|
10
10
|
//#region src/projects/project-service.ts
|
|
11
11
|
var ProjectService = class {
|
|
12
|
-
constructor(store = new ProjectStore(), signals) {
|
|
12
|
+
constructor(store = new ProjectStore(), signals, workspaceId = "default") {
|
|
13
13
|
this.store = store;
|
|
14
14
|
this.signals = signals;
|
|
15
|
+
this.workspaceId = workspaceId;
|
|
15
16
|
}
|
|
16
17
|
listAllProjects() {
|
|
17
18
|
const items = [];
|
|
@@ -199,7 +200,7 @@ var ProjectService = class {
|
|
|
199
200
|
},
|
|
200
201
|
actor: { kind: "system" },
|
|
201
202
|
scope: {
|
|
202
|
-
workspaceId:
|
|
203
|
+
workspaceId: this.workspaceId,
|
|
203
204
|
projectId: project.id
|
|
204
205
|
},
|
|
205
206
|
occurredAt: new Date(project.updatedAt).toISOString(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SessionStatus } from "./types.js";
|
|
2
1
|
import { buildSessionContextForLlm, isTranscriptContextEntry, mergeLlmMessagesPreservingContextRows, transcriptRowsFromJsonArray } from "./session-context-for-llm.js";
|
|
2
|
+
import { SessionStatus } from "./types.js";
|
|
3
3
|
import { effectiveWorkspacePathForSession, normalizeWorkingDirectoryInput, projectWorkspacePath } from "./session-workspace.js";
|
|
4
4
|
import { emitSessionTranscriptUpdate, onSessionTranscriptUpdate } from "./transcript-events.js";
|
|
5
5
|
import { fallbackTitleFromMessages, generateSessionTitleFromMessages, getSessionTitleSource, isWebchatSessionKey, maybeRefineSessionTitleWithLlm, maybeSetProvisionalSessionTitle, provisionalTitleFromUserText, sanitizeGeneratedSessionTitle, sanitizeSessionTitle, shouldAutoTitleSessionKey, shouldRefineSessionTitleWithLlm } from "./session-title.js";
|
|
@@ -3,8 +3,8 @@ import { createLogger } from "../utils/logger/index.js";
|
|
|
3
3
|
import { init_logger } from "../utils/logger.js";
|
|
4
4
|
import { requireXopcDatabase } from "../storage/sqlite/connection.js";
|
|
5
5
|
import { runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
6
|
-
import "./types.js";
|
|
7
6
|
import { buildSessionContextForLlm, buildSessionDisplayMessages, isRuntimeOnlyTranscriptMessage, isTranscriptCompactionEntry, mergeLlmMessagesPreservingContextRows, transcriptRowsFromJsonArray } from "./session-context-for-llm.js";
|
|
7
|
+
import "./types.js";
|
|
8
8
|
import { init_agent_session_key, resolveAgentIdFromSessionKey } from "../routing/agent-session-key.js";
|
|
9
9
|
import { estimateTokensFromMessages } from "../storage/sqlite/row-mappers.js";
|
|
10
10
|
import { deleteSessionRecord, ensureSessionRecord, findSessionKeyBySessionId, getGlobalSessionStats, getSessionMetadata, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord } from "../storage/sqlite/session-repository.js";
|
|
@@ -13,6 +13,7 @@ import { getSessionConfig, setSessionConfig } from "../storage/sqlite/config-rep
|
|
|
13
13
|
import "../storage/sqlite/index.js";
|
|
14
14
|
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
15
15
|
import { SessionCompactor } from "../agent/memory/compaction.js";
|
|
16
|
+
import { resolveUserContextSessionAccess } from "../user-context/access-policy.js";
|
|
16
17
|
import { readPostCompactionContext } from "../agent/reply/post-compaction-context.js";
|
|
17
18
|
import { resolveCompactionPolicy } from "../agent/memory/compaction-policy.js";
|
|
18
19
|
import { promoteCompactionLedger } from "../agent/memory/compaction-promotion.js";
|
|
@@ -464,6 +465,7 @@ var SessionStore = class {
|
|
|
464
465
|
})) throw new Error(`Session changed while compaction was running: ${key}`);
|
|
465
466
|
try {
|
|
466
467
|
const metadata = getSessionMetadata(key);
|
|
468
|
+
const access = resolveUserContextSessionAccess(this.options.config, key);
|
|
467
469
|
const promoted = promoteCompactionLedger({
|
|
468
470
|
sessionKey: key,
|
|
469
471
|
sessionId: expectedSnapshot.sessionId,
|
|
@@ -472,7 +474,8 @@ var SessionStore = class {
|
|
|
472
474
|
projectId: metadata?.projectId,
|
|
473
475
|
handover: result.handover,
|
|
474
476
|
audit: result.audit,
|
|
475
|
-
sourceEntries: expectedSnapshot.entries
|
|
477
|
+
sourceEntries: expectedSnapshot.entries,
|
|
478
|
+
writePolicy: access.knowledge && this.options.config.userContext.knowledgeMemory.sources.includes("session") ? this.options.config.userContext.knowledgeMemory.writePolicy : "deny"
|
|
476
479
|
});
|
|
477
480
|
log.info({
|
|
478
481
|
sessionKey: key,
|