@xopcai/xopc 0.0.158 → 0.0.160
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/dashscope/src/image-generation-provider.js +1 -1
- package/dist/extensions/fal/src/image-generation-provider.js +1 -1
- package/dist/extensions/google/src/image-generation-provider.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{action-boundary-settings-panel-2p1f4-KA.js → action-boundary-settings-panel-CY3sizqC.js} +1 -1
- package/dist/gateway/static/root/assets/{activity-store-C-57rvkX.js → activity-store-3Cso_2qm.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BIl6X2b_.js → agent-avatar-dicebear-B_27aaZQ.js} +1 -1
- package/dist/gateway/static/root/assets/agents-B1l3iii6.js +2 -0
- package/dist/gateway/static/root/assets/{api-BjcBIV2O.js → api-BbzB57CJ.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-CZxw161D.js → app-management-settings-panel-DfmyWcyh.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CRXNlDhH.js → appearance-settings-B2v0c-K-.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-DaNFLsp0.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CpVshjXu.js → archive-plugin-DL5Lnx0C.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-M9WqqJnQ.js → attachment-load-InuP-ZjQ.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-CYMsAsYf.js → automation-suggestion-card-CahGuh7B.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-Cd0gMx6p.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-Cjn3zb4u.js → binary-plugins-CdOTGYVu.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BPKdquaV.js → block-editor-D6ShK1S-.js} +3 -3
- package/dist/gateway/static/root/assets/browser-settings-page-BmUYDL2Z.js +8 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-Bzkcsyzn.js → capability-presets-api-BzoLm52Z.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-D4rH4Dax.js → capability-presets-settings-panel-CE7mrWtS.js} +2 -2
- package/dist/gateway/static/root/assets/{channel-recipient-api-CFqrSi5K.js → channel-recipient-api-DbgydMjl.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-D1_gcAHK.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-Cqfqv59m.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-ljPKdYKh.js → connector-logo-C3bJC9nt.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-CaLBi6Na.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-settings-BrHVvbBw.js +1 -0
- package/dist/gateway/static/root/assets/desktop-pet-sprite-CFd1jGLJ.js +1 -0
- package/dist/gateway/static/root/assets/desktop-pet-wacrnJJ1.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Dmy1035j.js → directory-picker-path-field-BPI969w-.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-tT4WkBkd.js → dreaming-settings-iw6QXD45.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-CL79q8AH.js → extension-debug-page-rCHyhEr6.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-hq80wkFI.js → extension-page-C4gQsAPt.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BV-9GDfT.js → extension-settings-page-DB_3eik7.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-CFqoN2NW.js → gateway-config-api-Cdt38iF2.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-DM4BgyGw.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-cxQ94qMm.js → gateway-startup-retry-ChRFNjj_.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-BQamcEmF.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-DZUQ0Lf1.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api--qJ4qlRq.js → goals-config-api-RvljeEm6.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-BtxVD27C.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-h7x9h5lb.js → goals-settings-DMGV4S4L.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-71IhhM3s.js → heartbeat-settings-B8r5EXc5.js} +1 -1
- package/dist/gateway/static/root/assets/index-CHKe7nwC.js +197 -0
- package/dist/gateway/static/root/assets/index-CXhfUIjh.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BZGmHvLu.js → keyboard-shortcuts-settings-1-LYibQ4.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CTTfyFe3.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-CiLqrMIh.js → local-apps-page-CC4vtUUI.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-C_M71MK9.js → locale-store-CPbGB_6l.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-Bn_taxBV.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-r1HPWfCU.js → markdown-split-CprEIf8A.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-D74kd3hn.js → media-plugins-BXt_Sj2O.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-BuT0SR1R.js → messages-DDsiqdJS.js} +4 -4
- package/dist/gateway/static/root/assets/models-hub-panel-DJReXRP9.js +2 -0
- package/dist/gateway/static/root/assets/{notes-page-Dgu02514.js → notes-page-Wf5-eyyM.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-BbdjzYzs.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-hinRdDy3.js → page-tabs-dtpK_4Fs.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-C7fw3oGy.js → preview-open-alternatives-DijtEVxG.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BwG8SOzI.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-nUlyUtxh.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-rf7bjije.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-C3aU8-vO.js → save-bar-controls-qhDisdqY.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-DjegExFD.js → schedule-field-AhJ50NoT.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DLubnsql.js → schema-form-AuJg2CXU.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-CSoHUe38.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-Db976IEa.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-3syQHsNR.js → settings-collapsible-section-D5ganr_X.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-D4DCZzKg.js → settings-form-section-Db3cKRsg.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-c5K85ylS.js → settings-loading-skeleton-D05YKT2x.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DNiDlaRq.js → settings-page-DYfXmfTx.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-iTRY1Hy-.js → settings-page-layout-Cv_Cu4I5.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-wBWOFpvw.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-B88Afrhe.js → share-preview-page-CYkZVuse.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-BAMma1-P.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-TWxFFWxM.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-Ca2RA29R.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-DtpTq837.js → system-settings-panel-C1Ng5bXh.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-C8ohIHhw.js → theme-store-LMHIDR9n.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-ndEnUP3b.js → typed-models-lib-Ch2Bdm_5.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-BWzou5ar.js → use-channel-catalog-CZnaMOeL.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-CTumZa0y.js +1 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-DdlMxeqO.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-CcfZhdBi.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page--wxLw1p_.js +1 -0
- package/dist/gateway/static/root/assets/work-page-DyS0XBpV.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-ukmpkj66.js → workflow-run-setup-panel-BFk8TvTw.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-CVVJd4gy.js +11 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/embedded/session-tool-result-guard.js +14 -0
- package/dist/src/agent/image/generation/openai-compatible-image-provider.js +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +1 -1
- package/dist/src/agent/tools/image-generate-tool.js +10 -3
- package/dist/src/agent/tools/send-media.js +20 -70
- package/dist/src/agent/tools/tool-media.d.ts +9 -0
- package/dist/src/agent/tools/tool-media.js +58 -0
- package/dist/src/automations/service/action-executor.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/gateway/agent-run-relay.d.ts +2 -0
- package/dist/src/gateway/agent-run-relay.js +114 -14
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/chat-stream/mapper.d.ts +1 -0
- package/dist/src/gateway/chat-stream/mapper.js +40 -19
- package/dist/src/gateway/chat-stream/thinking-delta-coalescer.d.ts +7 -0
- package/dist/src/gateway/chat-stream/thinking-delta-coalescer.js +103 -0
- package/dist/src/gateway/hono/routes/home.js +15 -2
- package/dist/src/gateway/hono/routes/work-discovery.js +451 -0
- package/dist/src/gateway/hono/sse.d.ts +1 -1
- package/dist/src/gateway/hono/sse.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +5 -1
- package/dist/src/gateway/service.d.ts +2 -0
- package/dist/src/gateway/service.js +27 -2
- package/dist/src/media/session-references.js +9 -6
- package/dist/src/mobile/notification-service.js +1 -0
- package/dist/src/pets/factory.js +23 -26
- package/dist/src/pets/manifest.d.ts +2 -1
- package/dist/src/pets/manifest.js +15 -8
- package/dist/src/pets/validator.js +8 -3
- package/dist/src/proactive/calendar-signals.d.ts +4 -0
- package/dist/src/proactive/calendar-signals.js +120 -0
- package/dist/src/proactive/focus-service.d.ts +62 -0
- package/dist/src/proactive/focus-service.js +173 -0
- package/dist/src/proactive/index.d.ts +7 -0
- package/dist/src/proactive/index.js +7 -0
- package/dist/src/proactive/insight-repository.d.ts +19 -0
- package/dist/src/proactive/insight-repository.js +106 -0
- package/dist/src/proactive/run-processor.d.ts +19 -0
- package/dist/src/proactive/run-processor.js +125 -0
- package/dist/src/proactive/trial-expiry-reconciler.d.ts +5 -0
- package/dist/src/proactive/trial-expiry-reconciler.js +30 -0
- package/dist/src/proactive/types.d.ts +64 -0
- package/dist/src/proactive/types.js +1 -0
- package/dist/src/proactive/watch-repository.d.ts +28 -0
- package/dist/src/proactive/watch-repository.js +129 -0
- package/dist/src/session/client-history.d.ts +1 -0
- package/dist/src/session/client-history.js +56 -12
- package/dist/src/session/types.d.ts +1 -0
- package/dist/src/storage/sqlite/knowledge-repository.d.ts +1 -0
- package/dist/src/storage/sqlite/knowledge-repository.js +4 -0
- package/dist/src/storage/sqlite/migrations/047_work_discovery_sources.sql +16 -0
- package/dist/src/storage/sqlite/migrations/048_work_understanding_investigations.sql +40 -0
- package/dist/src/storage/sqlite/migrations/049_work_understanding_threads.sql +52 -0
- package/dist/src/storage/sqlite/migrations/050_work_discovery_source_refreshes.sql +15 -0
- package/dist/src/storage/sqlite/migrations/051_focus_watches.sql +26 -0
- package/dist/src/storage/sqlite/migrations/052_proactive_insights.sql +25 -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/analyzer.d.ts +12 -1
- package/dist/src/work-discovery/analyzer.js +126 -7
- package/dist/src/work-discovery/candidate-discovery.d.ts +17 -0
- package/dist/src/work-discovery/candidate-discovery.js +279 -0
- package/dist/src/work-discovery/evaluation.d.ts +11 -0
- package/dist/src/work-discovery/evaluation.js +17 -0
- package/dist/src/work-discovery/governance.d.ts +25 -0
- package/dist/src/work-discovery/governance.js +96 -0
- package/dist/src/work-discovery/incremental-repository.d.ts +13 -0
- package/dist/src/work-discovery/incremental-repository.js +55 -0
- package/dist/src/work-discovery/incremental.d.ts +2 -0
- package/dist/src/work-discovery/incremental.js +7 -0
- package/dist/src/work-discovery/index.d.ts +10 -0
- package/dist/src/work-discovery/index.js +13 -3
- package/dist/src/work-discovery/investigation-repository.d.ts +16 -0
- package/dist/src/work-discovery/investigation-repository.js +122 -0
- package/dist/src/work-discovery/investigator.d.ts +55 -0
- package/dist/src/work-discovery/investigator.js +358 -0
- package/dist/src/work-discovery/probe.d.ts +22 -0
- package/dist/src/work-discovery/probe.js +88 -1
- package/dist/src/work-discovery/service.d.ts +110 -1
- package/dist/src/work-discovery/service.js +578 -8
- package/dist/src/work-discovery/source-repository.d.ts +13 -0
- package/dist/src/work-discovery/source-repository.js +72 -0
- package/dist/src/work-discovery/thread-repository.d.ts +34 -0
- package/dist/src/work-discovery/thread-repository.js +112 -0
- package/dist/src/work-discovery/thread-service.d.ts +8 -0
- package/dist/src/work-discovery/thread-service.js +104 -0
- package/dist/src/work-discovery/types.d.ts +145 -0
- package/package.json +1 -1
- package/skills/creative/hatch-pet/SKILL.md +2 -2
- package/dist/gateway/static/root/assets/agents-bnkKH9EI.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-l4ripRNG.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-Kny7tLiF.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-vr1tXAab.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-Tlhbi5eh.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-vooEF4lG.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-_XfvjXoY.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-DKUlAgm7.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-aWWzjdza.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-sprite-DqZ6fbIj.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-DzR-kM91.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-BLjHRtqe.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-BRxeujXh.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-BaZ3aw4u.js +0 -2
- package/dist/gateway/static/root/assets/index-EXa_i6BT.js +0 -193
- package/dist/gateway/static/root/assets/index-gpwk8Nro.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-lUpd6lSo.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-FPDTmcWe.js +0 -7
- package/dist/gateway/static/root/assets/models-hub-panel-BXrdePhv.js +0 -2
- package/dist/gateway/static/root/assets/notes-workbench-D-EAhXv1.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-BjpB1wrp.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BxyjqOfC.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BFv6Upke.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BX4DH8J7.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CJ9MbRP8.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BH4xQKM9.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-B6kKkvOb.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DtjS-nUK.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-CQEoPv0u.js +0 -2
- package/dist/gateway/static/root/assets/sliding-segmented-uWmrxE3P.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-Dn2T3itn.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-wtWc3SfN.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-Ckxhj66e.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-_1QgGPNw.js +0 -1
- package/dist/gateway/static/root/assets/work-page-BPdf2iuv.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-DdKTx0Hs.js +0 -11
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { requireXopcDatabase } from "../storage/sqlite/connection.js";
|
|
2
|
+
import { runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
//#region src/proactive/watch-repository.ts
|
|
5
|
+
function watchFromRow(row) {
|
|
6
|
+
let config = {};
|
|
7
|
+
try {
|
|
8
|
+
const parsed = JSON.parse(row.config_json);
|
|
9
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) config = parsed;
|
|
10
|
+
} catch {
|
|
11
|
+
config = {};
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
id: row.watch_id,
|
|
15
|
+
threadId: row.thread_id,
|
|
16
|
+
...row.goal_id ? { goalId: row.goal_id } : {},
|
|
17
|
+
automationId: row.automation_id,
|
|
18
|
+
kind: row.kind,
|
|
19
|
+
status: row.status,
|
|
20
|
+
config,
|
|
21
|
+
...row.trial_ends_at != null ? { trialEndsAt: row.trial_ends_at } : {},
|
|
22
|
+
...row.last_cursor ? { lastCursor: row.last_cursor } : {},
|
|
23
|
+
...row.last_run_at != null ? { lastRunAt: row.last_run_at } : {},
|
|
24
|
+
...row.last_useful_result_at != null ? { lastUsefulResultAt: row.last_useful_result_at } : {},
|
|
25
|
+
consecutiveEmptyRuns: row.consecutive_empty_runs,
|
|
26
|
+
createdAt: row.created_at,
|
|
27
|
+
updatedAt: row.updated_at
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function listFocusWatches(options = {}) {
|
|
31
|
+
const clauses = [];
|
|
32
|
+
const values = [];
|
|
33
|
+
if (options.threadId) {
|
|
34
|
+
clauses.push("thread_id = ?");
|
|
35
|
+
values.push(options.threadId);
|
|
36
|
+
}
|
|
37
|
+
if (options.status) {
|
|
38
|
+
clauses.push("status = ?");
|
|
39
|
+
values.push(options.status);
|
|
40
|
+
}
|
|
41
|
+
const { db } = requireXopcDatabase();
|
|
42
|
+
return db.prepare(`SELECT * FROM focus_watches ${clauses.length ? `WHERE ${clauses.join(" AND ")}` : ""}
|
|
43
|
+
ORDER BY updated_at DESC`).all(...values).map(watchFromRow);
|
|
44
|
+
}
|
|
45
|
+
function getFocusWatchByThreadAndKind(threadId, kind) {
|
|
46
|
+
const { db } = requireXopcDatabase();
|
|
47
|
+
const row = db.prepare("SELECT * FROM focus_watches WHERE thread_id = ? AND kind = ?").get(threadId, kind);
|
|
48
|
+
return row ? watchFromRow(row) : null;
|
|
49
|
+
}
|
|
50
|
+
function getFocusWatchByAutomationId(automationId) {
|
|
51
|
+
const { db } = requireXopcDatabase();
|
|
52
|
+
const row = db.prepare("SELECT * FROM focus_watches WHERE automation_id = ?").get(automationId);
|
|
53
|
+
return row ? watchFromRow(row) : null;
|
|
54
|
+
}
|
|
55
|
+
function createFocusWatch(input) {
|
|
56
|
+
const now = input.nowMs ?? Date.now();
|
|
57
|
+
const id = randomUUID();
|
|
58
|
+
runSqliteWriteTransaction((db) => {
|
|
59
|
+
db.prepare(`INSERT INTO focus_watches (
|
|
60
|
+
watch_id, thread_id, goal_id, automation_id, kind, status, config_json,
|
|
61
|
+
trial_ends_at, consecutive_empty_runs, created_at, updated_at
|
|
62
|
+
) VALUES (?, ?, ?, ?, ?, 'active', ?, ?, 0, ?, ?)`).run(id, input.threadId, input.goalId ?? null, input.automationId, input.kind, JSON.stringify(input.config ?? {}), input.trialEndsAt ?? null, now, now);
|
|
63
|
+
});
|
|
64
|
+
return getFocusWatchByThreadAndKind(input.threadId, input.kind);
|
|
65
|
+
}
|
|
66
|
+
function setFocusWatchStatus(id, status, nowMs = Date.now()) {
|
|
67
|
+
let changed = false;
|
|
68
|
+
runSqliteWriteTransaction((db) => {
|
|
69
|
+
changed = db.prepare("UPDATE focus_watches SET status = ?, updated_at = ? WHERE watch_id = ?").run(status, nowMs, id).changes > 0;
|
|
70
|
+
});
|
|
71
|
+
if (!changed) return null;
|
|
72
|
+
const { db } = requireXopcDatabase();
|
|
73
|
+
return watchFromRow(db.prepare("SELECT * FROM focus_watches WHERE watch_id = ?").get(id));
|
|
74
|
+
}
|
|
75
|
+
function restartFocusWatchTrial(id, trialEndsAt, nowMs = Date.now()) {
|
|
76
|
+
let changed = false;
|
|
77
|
+
runSqliteWriteTransaction((db) => {
|
|
78
|
+
changed = db.prepare(`UPDATE focus_watches
|
|
79
|
+
SET status = 'active', trial_ends_at = ?, consecutive_empty_runs = 0, updated_at = ?
|
|
80
|
+
WHERE watch_id = ?`).run(trialEndsAt, nowMs, id).changes > 0;
|
|
81
|
+
});
|
|
82
|
+
if (!changed) return null;
|
|
83
|
+
const { db } = requireXopcDatabase();
|
|
84
|
+
return watchFromRow(db.prepare("SELECT * FROM focus_watches WHERE watch_id = ?").get(id));
|
|
85
|
+
}
|
|
86
|
+
function recordFocusWatchRun(input) {
|
|
87
|
+
const now = input.nowMs ?? Date.now();
|
|
88
|
+
let changed = false;
|
|
89
|
+
runSqliteWriteTransaction((db) => {
|
|
90
|
+
changed = db.prepare(`UPDATE focus_watches SET
|
|
91
|
+
last_cursor = ?,
|
|
92
|
+
last_run_at = ?,
|
|
93
|
+
last_useful_result_at = CASE WHEN ? = 'meaningful' THEN ? ELSE last_useful_result_at END,
|
|
94
|
+
consecutive_empty_runs = CASE
|
|
95
|
+
WHEN ? = 'meaningful' THEN 0
|
|
96
|
+
WHEN ? = 'empty' THEN consecutive_empty_runs + 1
|
|
97
|
+
ELSE consecutive_empty_runs
|
|
98
|
+
END,
|
|
99
|
+
updated_at = ?
|
|
100
|
+
WHERE watch_id = ? AND (last_cursor IS NULL OR last_cursor <> ?)`).run(input.runId, now, input.outcome, now, input.outcome, input.outcome, now, input.id, input.runId).changes > 0;
|
|
101
|
+
});
|
|
102
|
+
if (!changed) return null;
|
|
103
|
+
return listFocusWatches().find((watch) => watch.id === input.id) ?? null;
|
|
104
|
+
}
|
|
105
|
+
function recordFocusWatchFeedback(id, useful, nowMs = Date.now()) {
|
|
106
|
+
const watch = listFocusWatches().find((item) => item.id === id);
|
|
107
|
+
if (!watch) return null;
|
|
108
|
+
const previous = watch.config.feedback && typeof watch.config.feedback === "object" && !Array.isArray(watch.config.feedback) ? watch.config.feedback : {};
|
|
109
|
+
const approved = typeof previous.approved === "number" ? previous.approved : 0;
|
|
110
|
+
const dismissed = typeof previous.dismissed === "number" ? previous.dismissed : 0;
|
|
111
|
+
const consecutiveDismissed = useful ? 0 : (typeof previous.consecutiveDismissed === "number" ? previous.consecutiveDismissed : 0) + 1;
|
|
112
|
+
const config = {
|
|
113
|
+
...watch.config,
|
|
114
|
+
feedback: {
|
|
115
|
+
approved: approved + (useful ? 1 : 0),
|
|
116
|
+
dismissed: dismissed + (useful ? 0 : 1),
|
|
117
|
+
consecutiveDismissed
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
runSqliteWriteTransaction((db) => {
|
|
121
|
+
db.prepare("UPDATE focus_watches SET config_json = ?, updated_at = ? WHERE watch_id = ?").run(JSON.stringify(config), nowMs, id);
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
watch: listFocusWatches().find((item) => item.id === id),
|
|
125
|
+
consecutiveDismissed
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
//#endregion
|
|
129
|
+
export { createFocusWatch, getFocusWatchByAutomationId, getFocusWatchByThreadAndKind, listFocusWatches, recordFocusWatchFeedback, recordFocusWatchRun, restartFocusWatchTrial, setFocusWatchStatus };
|
|
@@ -33,22 +33,65 @@ function collectToolResults(messages) {
|
|
|
33
33
|
if (!id || typeof id !== "string") continue;
|
|
34
34
|
map.set(id, {
|
|
35
35
|
text: flattenMessageContent(m.content),
|
|
36
|
-
isError: m.isError
|
|
36
|
+
isError: m.isError,
|
|
37
|
+
details: m.details
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
40
|
return map;
|
|
40
41
|
}
|
|
41
|
-
function
|
|
42
|
-
if (!tool_calls?.length) return void 0;
|
|
42
|
+
function collectMessageToolCalls(content, openAiToolCalls, rawToolCalls) {
|
|
43
43
|
const out = [];
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
const seen = /* @__PURE__ */ new Set();
|
|
45
|
+
const add = (call) => {
|
|
46
|
+
const key = call.id ? `id:${call.id}` : `position:${out.length}`;
|
|
47
|
+
if (seen.has(key)) return;
|
|
48
|
+
seen.add(key);
|
|
49
|
+
out.push(call);
|
|
50
|
+
};
|
|
51
|
+
for (const call of openAiToolCalls ?? []) add({
|
|
52
|
+
id: call.id,
|
|
53
|
+
name: call.function.name,
|
|
54
|
+
args: safeJsonParseArguments(call.function.arguments)
|
|
55
|
+
});
|
|
56
|
+
for (const item of Array.isArray(rawToolCalls) ? rawToolCalls : []) {
|
|
57
|
+
if (!item || typeof item !== "object") continue;
|
|
58
|
+
const call = item;
|
|
59
|
+
const name = typeof call.name === "string" ? call.name : void 0;
|
|
60
|
+
if (!name) continue;
|
|
61
|
+
add({
|
|
62
|
+
id: typeof call.id === "string" ? call.id : void 0,
|
|
63
|
+
name,
|
|
64
|
+
args: call.args ?? call.arguments ?? call.input
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
for (const item of Array.isArray(content) ? content : []) {
|
|
68
|
+
if (!item || typeof item !== "object") continue;
|
|
69
|
+
const call = item;
|
|
70
|
+
if (call.type !== "toolCall" && call.type !== "tool_use" && call.type !== "tool_call") continue;
|
|
71
|
+
const fn = call.function && typeof call.function === "object" ? call.function : void 0;
|
|
72
|
+
const name = typeof call.name === "string" ? call.name : typeof fn?.name === "string" ? fn.name : void 0;
|
|
73
|
+
if (!name) continue;
|
|
74
|
+
const rawArgs = call.arguments ?? call.args ?? call.input ?? fn?.arguments;
|
|
75
|
+
add({
|
|
76
|
+
id: typeof call.id === "string" ? call.id : void 0,
|
|
77
|
+
name,
|
|
78
|
+
args: typeof rawArgs === "string" ? safeJsonParseArguments(rawArgs) : rawArgs
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return out.length ? out : void 0;
|
|
82
|
+
}
|
|
83
|
+
function toolCallsWithResults(toolCalls, results) {
|
|
84
|
+
if (!toolCalls?.length) return void 0;
|
|
85
|
+
const out = [];
|
|
86
|
+
for (const call of toolCalls) {
|
|
87
|
+
const res = call.id ? results.get(call.id) : void 0;
|
|
46
88
|
out.push({
|
|
47
|
-
id:
|
|
48
|
-
name:
|
|
49
|
-
args:
|
|
89
|
+
id: call.id,
|
|
90
|
+
name: call.name,
|
|
91
|
+
args: call.args,
|
|
50
92
|
result: res?.text,
|
|
51
|
-
isError: res?.isError
|
|
93
|
+
isError: res?.isError,
|
|
94
|
+
details: res?.details
|
|
52
95
|
});
|
|
53
96
|
}
|
|
54
97
|
return out.length ? out : void 0;
|
|
@@ -74,7 +117,7 @@ function messagesToClientHistory(messages, opts) {
|
|
|
74
117
|
}
|
|
75
118
|
if (m.role === "assistant") {
|
|
76
119
|
const text = flattenMessageContent(m.content);
|
|
77
|
-
const toolCalls = toolCallsWithResults(m.tool_calls, results);
|
|
120
|
+
const toolCalls = toolCallsWithResults(collectMessageToolCalls(m.content, m.tool_calls), results);
|
|
78
121
|
out.push({
|
|
79
122
|
role: "assistant",
|
|
80
123
|
content: text,
|
|
@@ -108,7 +151,8 @@ function collectHistoryToolResults(messages) {
|
|
|
108
151
|
if (!id || typeof id !== "string") continue;
|
|
109
152
|
map.set(id, {
|
|
110
153
|
text: flattenMessageContent(m.content ?? ""),
|
|
111
|
-
isError: m.isError
|
|
154
|
+
isError: m.isError,
|
|
155
|
+
details: m.details
|
|
112
156
|
});
|
|
113
157
|
}
|
|
114
158
|
return map;
|
|
@@ -380,7 +424,7 @@ function transcriptRowsToClientHistory(rows, opts) {
|
|
|
380
424
|
...rawContent ? { rawContent } : {},
|
|
381
425
|
...displayIndex !== void 0 ? { displayIndex } : {},
|
|
382
426
|
timestamp: parseTimestampValue(messageRow.timestamp),
|
|
383
|
-
toolCalls: toolCallsWithResults(messageRow.tool_calls
|
|
427
|
+
toolCalls: toolCallsWithResults(collectMessageToolCalls(messageRow.content, messageRow.tool_calls, messageRow.toolCalls), results)
|
|
384
428
|
});
|
|
385
429
|
}
|
|
386
430
|
return out;
|
|
@@ -39,6 +39,7 @@ export declare function getKnowledgeConsumerWatermark(consumerId: string, source
|
|
|
39
39
|
export declare function setKnowledgeConsumerWatermark(consumerId: string, sourceInstanceId: string, sequence: number, nowMs?: number): void;
|
|
40
40
|
export declare function listKnowledgeSourceItems(options?: {
|
|
41
41
|
sourceInstanceId?: string;
|
|
42
|
+
itemType?: string;
|
|
42
43
|
synthesisStatus?: KnowledgeSynthesisStatus;
|
|
43
44
|
includeDeleted?: boolean;
|
|
44
45
|
limit?: number;
|
|
@@ -238,6 +238,10 @@ function listKnowledgeSourceItems(options = {}) {
|
|
|
238
238
|
where.push("source_instance_id = ?");
|
|
239
239
|
params.push(options.sourceInstanceId);
|
|
240
240
|
}
|
|
241
|
+
if (options.itemType) {
|
|
242
|
+
where.push("item_type = ?");
|
|
243
|
+
params.push(options.itemType);
|
|
244
|
+
}
|
|
241
245
|
if (options.synthesisStatus) {
|
|
242
246
|
where.push("synthesis_status = ?");
|
|
243
247
|
params.push(options.synthesisStatus);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS work_discovery_sources (
|
|
2
|
+
source_id TEXT PRIMARY KEY,
|
|
3
|
+
kind TEXT NOT NULL CHECK (kind = 'directory'),
|
|
4
|
+
root_path TEXT,
|
|
5
|
+
display_name TEXT NOT NULL,
|
|
6
|
+
status TEXT NOT NULL DEFAULT 'active' CHECK (status IN ('active', 'revoked')),
|
|
7
|
+
scope_json TEXT NOT NULL DEFAULT '{}',
|
|
8
|
+
fingerprint_json TEXT,
|
|
9
|
+
last_scanned_at INTEGER,
|
|
10
|
+
created_at INTEGER NOT NULL,
|
|
11
|
+
updated_at INTEGER NOT NULL,
|
|
12
|
+
UNIQUE(kind, root_path)
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
CREATE INDEX idx_work_discovery_sources_kind_status
|
|
16
|
+
ON work_discovery_sources(kind, status, updated_at DESC);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS work_understanding_investigations (
|
|
2
|
+
investigation_id TEXT PRIMARY KEY,
|
|
3
|
+
discovery_run_id TEXT NOT NULL UNIQUE,
|
|
4
|
+
status TEXT NOT NULL CHECK (status IN (
|
|
5
|
+
'planning', 'investigating', 'synthesizing', 'completed', 'failed', 'canceled'
|
|
6
|
+
)),
|
|
7
|
+
plan_json TEXT NOT NULL DEFAULT '{}',
|
|
8
|
+
budget_json TEXT NOT NULL,
|
|
9
|
+
tool_call_count INTEGER NOT NULL DEFAULT 0,
|
|
10
|
+
content_chars_read INTEGER NOT NULL DEFAULT 0,
|
|
11
|
+
error_message TEXT,
|
|
12
|
+
started_at INTEGER NOT NULL,
|
|
13
|
+
completed_at INTEGER,
|
|
14
|
+
FOREIGN KEY (discovery_run_id) REFERENCES work_discovery_runs(id) ON DELETE CASCADE
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE TABLE IF NOT EXISTS work_understanding_evidence (
|
|
18
|
+
evidence_id TEXT PRIMARY KEY,
|
|
19
|
+
investigation_id TEXT NOT NULL,
|
|
20
|
+
source_grant_id TEXT,
|
|
21
|
+
project_id TEXT,
|
|
22
|
+
source_type TEXT NOT NULL CHECK (source_type IN (
|
|
23
|
+
'file', 'git', 'project_metadata', 'personal_context', 'session', 'user_statement'
|
|
24
|
+
)),
|
|
25
|
+
source_ref TEXT NOT NULL,
|
|
26
|
+
observation TEXT NOT NULL,
|
|
27
|
+
content_hash TEXT,
|
|
28
|
+
observed_at INTEGER,
|
|
29
|
+
collected_at INTEGER NOT NULL,
|
|
30
|
+
sensitivity TEXT NOT NULL DEFAULT 'normal' CHECK (sensitivity IN ('normal', 'restricted')),
|
|
31
|
+
FOREIGN KEY (investigation_id) REFERENCES work_understanding_investigations(investigation_id) ON DELETE CASCADE,
|
|
32
|
+
FOREIGN KEY (source_grant_id) REFERENCES work_discovery_sources(source_id) ON DELETE SET NULL,
|
|
33
|
+
FOREIGN KEY (project_id) REFERENCES projects(project_id) ON DELETE SET NULL
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
CREATE INDEX idx_work_understanding_evidence_investigation
|
|
37
|
+
ON work_understanding_evidence(investigation_id, collected_at ASC);
|
|
38
|
+
|
|
39
|
+
CREATE INDEX idx_work_understanding_evidence_source
|
|
40
|
+
ON work_understanding_evidence(source_grant_id, source_type, collected_at DESC);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS work_understanding_threads (
|
|
2
|
+
thread_id TEXT PRIMARY KEY,
|
|
3
|
+
canonical_key TEXT NOT NULL UNIQUE,
|
|
4
|
+
title TEXT NOT NULL,
|
|
5
|
+
summary TEXT NOT NULL,
|
|
6
|
+
status TEXT NOT NULL CHECK (status IN ('active', 'paused', 'blocked', 'completed', 'uncertain')),
|
|
7
|
+
horizon TEXT NOT NULL CHECK (horizon IN ('current', 'ongoing', 'long_term')),
|
|
8
|
+
focus_score REAL NOT NULL,
|
|
9
|
+
confidence REAL NOT NULL,
|
|
10
|
+
user_status TEXT NOT NULL DEFAULT 'unreviewed' CHECK (user_status IN ('unreviewed', 'confirmed', 'corrected', 'rejected')),
|
|
11
|
+
parent_thread_id TEXT,
|
|
12
|
+
first_observed_at INTEGER NOT NULL,
|
|
13
|
+
last_observed_at INTEGER NOT NULL,
|
|
14
|
+
created_at INTEGER NOT NULL,
|
|
15
|
+
updated_at INTEGER NOT NULL,
|
|
16
|
+
FOREIGN KEY (parent_thread_id) REFERENCES work_understanding_threads(thread_id) ON DELETE SET NULL
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
CREATE TABLE IF NOT EXISTS work_understanding_thread_projects (
|
|
20
|
+
thread_id TEXT NOT NULL,
|
|
21
|
+
project_id TEXT NOT NULL,
|
|
22
|
+
created_at INTEGER NOT NULL,
|
|
23
|
+
PRIMARY KEY (thread_id, project_id),
|
|
24
|
+
FOREIGN KEY (thread_id) REFERENCES work_understanding_threads(thread_id) ON DELETE CASCADE,
|
|
25
|
+
FOREIGN KEY (project_id) REFERENCES projects(project_id) ON DELETE CASCADE
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
CREATE TABLE IF NOT EXISTS work_understanding_thread_evidence (
|
|
29
|
+
thread_id TEXT NOT NULL,
|
|
30
|
+
evidence_id TEXT NOT NULL,
|
|
31
|
+
relation TEXT NOT NULL DEFAULT 'supports' CHECK (relation IN ('supports', 'contradicts', 'context')),
|
|
32
|
+
created_at INTEGER NOT NULL,
|
|
33
|
+
PRIMARY KEY (thread_id, evidence_id),
|
|
34
|
+
FOREIGN KEY (thread_id) REFERENCES work_understanding_threads(thread_id) ON DELETE CASCADE,
|
|
35
|
+
FOREIGN KEY (evidence_id) REFERENCES work_understanding_evidence(evidence_id) ON DELETE CASCADE
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
CREATE TABLE IF NOT EXISTS work_understanding_thread_feedback (
|
|
39
|
+
feedback_id TEXT PRIMARY KEY,
|
|
40
|
+
thread_id TEXT NOT NULL,
|
|
41
|
+
decision TEXT NOT NULL CHECK (decision IN ('confirmed', 'corrected', 'rejected', 'paused', 'completed')),
|
|
42
|
+
corrected_title TEXT,
|
|
43
|
+
corrected_summary TEXT,
|
|
44
|
+
created_at INTEGER NOT NULL,
|
|
45
|
+
FOREIGN KEY (thread_id) REFERENCES work_understanding_threads(thread_id) ON DELETE CASCADE
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
CREATE INDEX idx_work_understanding_threads_focus
|
|
49
|
+
ON work_understanding_threads(user_status, status, focus_score DESC, last_observed_at DESC);
|
|
50
|
+
|
|
51
|
+
CREATE INDEX idx_work_understanding_thread_projects_project
|
|
52
|
+
ON work_understanding_thread_projects(project_id, created_at DESC);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS work_discovery_source_refreshes (
|
|
2
|
+
refresh_id TEXT PRIMARY KEY,
|
|
3
|
+
source_id TEXT NOT NULL,
|
|
4
|
+
discovery_run_id TEXT,
|
|
5
|
+
changed INTEGER NOT NULL CHECK (changed IN (0, 1)),
|
|
6
|
+
previous_fingerprint_json TEXT,
|
|
7
|
+
current_fingerprint_json TEXT NOT NULL,
|
|
8
|
+
status TEXT NOT NULL CHECK (status IN ('checked', 'queued', 'completed', 'failed')),
|
|
9
|
+
checked_at INTEGER NOT NULL,
|
|
10
|
+
FOREIGN KEY (source_id) REFERENCES work_discovery_sources(source_id) ON DELETE CASCADE,
|
|
11
|
+
FOREIGN KEY (discovery_run_id) REFERENCES work_discovery_runs(id) ON DELETE SET NULL
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
CREATE INDEX idx_work_discovery_source_refreshes_source
|
|
15
|
+
ON work_discovery_source_refreshes(source_id, checked_at DESC);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
CREATE TABLE focus_watches (
|
|
2
|
+
watch_id TEXT PRIMARY KEY,
|
|
3
|
+
thread_id TEXT NOT NULL,
|
|
4
|
+
goal_id TEXT,
|
|
5
|
+
automation_id TEXT NOT NULL,
|
|
6
|
+
kind TEXT NOT NULL CHECK (kind IN ('progress', 'staleness', 'deadline', 'intelligence')),
|
|
7
|
+
status TEXT NOT NULL CHECK (status IN ('active', 'paused')),
|
|
8
|
+
config_json TEXT NOT NULL DEFAULT '{}',
|
|
9
|
+
trial_ends_at INTEGER,
|
|
10
|
+
last_cursor TEXT,
|
|
11
|
+
last_run_at INTEGER,
|
|
12
|
+
last_useful_result_at INTEGER,
|
|
13
|
+
consecutive_empty_runs INTEGER NOT NULL DEFAULT 0,
|
|
14
|
+
created_at INTEGER NOT NULL,
|
|
15
|
+
updated_at INTEGER NOT NULL,
|
|
16
|
+
UNIQUE (thread_id, kind),
|
|
17
|
+
FOREIGN KEY (thread_id) REFERENCES work_understanding_threads(thread_id) ON DELETE CASCADE,
|
|
18
|
+
FOREIGN KEY (goal_id) REFERENCES goals(goal_id) ON DELETE SET NULL,
|
|
19
|
+
FOREIGN KEY (automation_id) REFERENCES automations(automation_id) ON DELETE CASCADE
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE INDEX idx_focus_watches_thread
|
|
23
|
+
ON focus_watches(thread_id, status, updated_at DESC);
|
|
24
|
+
|
|
25
|
+
CREATE INDEX idx_focus_watches_automation
|
|
26
|
+
ON focus_watches(automation_id);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
CREATE TABLE proactive_insights (
|
|
2
|
+
insight_id TEXT PRIMARY KEY,
|
|
3
|
+
watch_id TEXT NOT NULL,
|
|
4
|
+
run_id TEXT NOT NULL UNIQUE,
|
|
5
|
+
kind TEXT NOT NULL CHECK (kind IN ('progress', 'staleness', 'deadline', 'intelligence')),
|
|
6
|
+
title TEXT NOT NULL,
|
|
7
|
+
summary TEXT NOT NULL,
|
|
8
|
+
why_it_matters TEXT NOT NULL,
|
|
9
|
+
next_action TEXT NOT NULL,
|
|
10
|
+
evidence_json TEXT NOT NULL,
|
|
11
|
+
content_hash TEXT NOT NULL,
|
|
12
|
+
status TEXT NOT NULL CHECK (status IN ('unread', 'read', 'approved', 'dismissed')),
|
|
13
|
+
created_at INTEGER NOT NULL,
|
|
14
|
+
updated_at INTEGER NOT NULL,
|
|
15
|
+
FOREIGN KEY (watch_id) REFERENCES focus_watches(watch_id) ON DELETE CASCADE
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
CREATE INDEX idx_proactive_insights_status
|
|
19
|
+
ON proactive_insights(status, created_at DESC);
|
|
20
|
+
|
|
21
|
+
CREATE INDEX idx_proactive_insights_watch
|
|
22
|
+
ON proactive_insights(watch_id, created_at DESC);
|
|
23
|
+
|
|
24
|
+
CREATE UNIQUE INDEX idx_proactive_insights_dedupe
|
|
25
|
+
ON proactive_insights(watch_id, content_hash);
|
|
@@ -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 = 52;
|
|
7
7
|
export declare function resolveMigrationsDir(override?: string): string;
|
|
8
8
|
/**
|
|
9
9
|
* Apply sequential SQL migrations from (currentVersion + 1) through targetVersion.
|
|
@@ -12,7 +12,7 @@ const log = createLogger("Sqlite:Migrations");
|
|
|
12
12
|
/** Baseline schema version applied from schema.sql on first open. */
|
|
13
13
|
const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
|
|
14
14
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
15
|
-
const XOPC_DB_SCHEMA_VERSION =
|
|
15
|
+
const XOPC_DB_SCHEMA_VERSION = 52;
|
|
16
16
|
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
17
17
|
function resolveMigrationsDir(override) {
|
|
18
18
|
if (override) return override;
|
|
@@ -46,7 +46,7 @@ function applySingleMigration(db, migration) {
|
|
|
46
46
|
* Each step runs in its own transaction and updates schema_meta on success.
|
|
47
47
|
*/
|
|
48
48
|
function applyPendingMigrations(db, options = {}) {
|
|
49
|
-
const targetVersion = options.targetVersion ??
|
|
49
|
+
const targetVersion = options.targetVersion ?? 52;
|
|
50
50
|
let currentVersion = readSchemaVersion(db);
|
|
51
51
|
if (currentVersion > targetVersion) throw new DatabaseSchemaTooNewError(currentVersion, targetVersion);
|
|
52
52
|
if (currentVersion >= targetVersion) return currentVersion;
|
|
@@ -62,7 +62,7 @@ function applyPendingMigrations(db, options = {}) {
|
|
|
62
62
|
}
|
|
63
63
|
/** Inspect schema version without mutating the database. */
|
|
64
64
|
function inspectSchemaMigrationStatus(db, options = {}) {
|
|
65
|
-
const appVersion = options.targetVersion ??
|
|
65
|
+
const appVersion = options.targetVersion ?? 52;
|
|
66
66
|
const dbVersion = readSchemaVersion(db);
|
|
67
67
|
if (dbVersion > appVersion) return {
|
|
68
68
|
dbVersion,
|
|
@@ -19,7 +19,7 @@ const log = createLogger('Sqlite:Migrations');
|
|
|
19
19
|
export const XOPC_DB_BASELINE_SCHEMA_VERSION = 11;
|
|
20
20
|
|
|
21
21
|
/** Latest schema version this release supports (increment when adding migrations). */
|
|
22
|
-
export const XOPC_DB_SCHEMA_VERSION =
|
|
22
|
+
export const XOPC_DB_SCHEMA_VERSION = 52;
|
|
23
23
|
|
|
24
24
|
const MODULE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
25
25
|
|
|
@@ -31,7 +31,7 @@ function ensureXopcDatabaseSchema(db) {
|
|
|
31
31
|
bootstrapFreshDatabase(db);
|
|
32
32
|
currentVersion = 11;
|
|
33
33
|
}
|
|
34
|
-
applyPendingMigrations(db, { targetVersion:
|
|
34
|
+
applyPendingMigrations(db, { targetVersion: 52 });
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
export { SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_SCHEMA_VERSION, ensureSchemaMetaTable, ensureXopcDatabaseSchema, readSchemaVersion, readSchemaVersionForTest, setSchemaVersion };
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { Config } from '../config/schema.js';
|
|
2
|
-
import type { WorkContextSnapshot, WorkDiscoveryResult } from './types.js';
|
|
2
|
+
import type { WorkContextSnapshot, WorkDiscoveryCandidate, WorkDiscoveryPersonalContextItem, WorkDiscoveryProfileCandidate, WorkDiscoveryResult, WorkUnderstandingThreadCandidate } from './types.js';
|
|
3
3
|
export declare function analyzeWorkContext(input: {
|
|
4
4
|
config: Config;
|
|
5
5
|
snapshot: WorkContextSnapshot;
|
|
6
|
+
candidateContext?: WorkDiscoveryCandidate[];
|
|
6
7
|
signal?: AbortSignal;
|
|
7
8
|
}): Promise<{
|
|
8
9
|
modelRef: string;
|
|
9
10
|
result: WorkDiscoveryResult;
|
|
10
11
|
}>;
|
|
12
|
+
export declare function analyzePersonalContext(input: {
|
|
13
|
+
config: Config;
|
|
14
|
+
items: WorkDiscoveryPersonalContextItem[];
|
|
15
|
+
workContext?: Pick<WorkDiscoveryResult, 'projectSummary' | 'currentState' | 'uncertainties' | 'workThreads'>;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
modelRef: string;
|
|
19
|
+
profileCandidates: WorkDiscoveryProfileCandidate[];
|
|
20
|
+
workThreadCandidates: WorkUnderstandingThreadCandidate[];
|
|
21
|
+
}>;
|
|
11
22
|
export declare function workDiscoveryResultMarkdown(result: WorkDiscoveryResult): string;
|