@xopcai/xopc 0.0.225 → 0.0.228
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-CtTYnku4.js → activity-store-M0nAY5XB.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-dizuqu_4.js → agent-avatar-dicebear-CjGZBs4C.js} +1 -1
- package/dist/gateway/static/root/assets/agents-B0NI4_NI.js +68 -0
- package/dist/gateway/static/root/assets/{api-CLRMz2BT.js → api-BywYxpaS.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Cnk-DtQh.js → app-management-settings-panel--SjycrXk.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-wP0rogVI.js → appearance-settings-8G-TVUtg.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-2NiqD-YP.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-Cpzsm-DM.js → archive-plugin-7_DXaMTP.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Bd2OOoEK.js → attachment-load-Bx44zSpz.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-DNqhguyk.js → automations-page-CrKAHqc0.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-Q3g9cf0h.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-Dcma5HdI.js → binary-plugins-DjDwnHAQ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-D-B8ThwK.js → block-editor-7aMOKoZM.js} +3 -3
- package/dist/gateway/static/root/assets/browser-settings-page-DTwPkmAC.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-BAPZIXrs.js → browser-workflow-inputs-8NC2qDRF.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-DHtaSKEh.js → browser-workflows-page-DVLrWKz_.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-YcP4FbN7.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-zsZQ7im3.js → capability-presets-api-o0y9WgAI.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-AcPjHHia.js +3 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-Cp8iaaXp.js → channel-recipient-api-C5ABr73b.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-Ca94Q1D-.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-38FsOnR0.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-Dr6Rq2ln.js → chat-terminal-dock-BR-_7KC0.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-SGxfLTd6.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-BiXrpzmo.js → cron-expression-D8-c-Tkw.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-BPuRtwKt.js → date-picker-kV-Jyl9J.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-BNC_W7wI.js → dependency-picker-CwKcrfGj.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DzOpt5nI.js → desktop-pet-D9rnchu3.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-BW0brCvH.js → desktop-pet-settings-CTs5WGzk.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Baml0uTS.js → directory-picker-path-field-CCl0aaDm.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CBXyKmfS.js → extension-debug-page-Cau40SvC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BBhcr_SZ.js → extension-page-BsJXdvIL.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-4rwWpN9_.js → extension-settings-page-qWqJyF7-.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-Dg-BlBe4.js → gateway-config-api-BI0SELXm.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-Du0MvK9s.js → gateway-config-swr-BWGjnmDl.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-BOuYZOYe.js → gateway-settings-6ZdOIC7F.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-JbjcHCaN.js → gateway-startup-retry-B_zrtccP.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-KBwhXeFD.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BA2M4CLi.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-G2tfPvKP.js → image-generation-api-YKP2me5Z.js} +1 -1
- package/dist/gateway/static/root/assets/index-BX0dz1JK.js +70 -0
- package/dist/gateway/static/root/assets/index-D_hrEKXM.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-L1Vtxgp9.js → keyboard-shortcuts-settings-kHtpnyEm.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-D2nkn09R.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page--thlkBLS.js → local-apps-page-BCXa0oUa.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-DqJz-cOR.js → locale-store-CXhjfe4q.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-D3sNst0K.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-p55fR4XO.js → management-settings-tHnlfOAQ.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-DwMcRlBR.js → markdown-split-BMLqHHr5.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-DD_PgVue.css → markdown-view-CLzTdVLW.css} +1 -1
- package/dist/gateway/static/root/assets/markdown-view-DvM5PWEH.js +201 -0
- package/dist/gateway/static/root/assets/{media-plugins-O6H3GZn7.js → media-plugins-DybwqTgv.js} +1 -1
- package/dist/gateway/static/root/assets/messages-BMdD0LWk.js +3 -0
- package/dist/gateway/static/root/assets/{notes-api-CrjQbmk1.js → notes-api-BFsOGYkd.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-miO9ig9C.js → notes-page-C24SfF6r.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-CTdZc3ov.js +4 -0
- package/dist/gateway/static/root/assets/{product-open-page-BOu07nXf.js → product-open-page-DBfCVlJq.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-COHaEpbA.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-lMnST7D_.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-Bf_HDLUJ.js → registry-api-BFZrVYfy.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BIRKBvO_.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DthuRqUH.js → runtime-tools-settings-panel-BPEGTip5.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-8W8PhXxa.js → schema-form-Dxlu60Td.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-CATO9G3y.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-Cco_W41x.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CrsKGYiG.js → settings-form-section-ChXh3Bwk.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-WJtI0AAq.js → settings-loading-skeleton-BCAUqIe2.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-PCjwRF47.js → settings-page-D25W9Okr.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-D65CwlNC.js → setup-status-panel-DsN7Z4Fl.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BGtvLLeZ.js → share-preview-page-CRFnUaNb.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CAX0eNaP.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-Doy1gghe.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-C_npyryI.js → skills-page-Cl7jjTK7.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-C46Sd78k.js → skills-page.utils-BiCl4nb5.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DomTLwki.js → system-settings-panel-BuESR7ZT.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-BRiy8NL3.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-Ce7wq__X.js → theme-store-DOdCjyuw.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-Do9mCRcY.js → use-autosave-Dg1mgJ_l.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-CqoADNKu.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-Bc5p-0tX.js → voice-api-key-field-BDNexlVR.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BieqsmT1.js → work-discovery-overlay-BHTfeaWL.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DVj8iYvm.js → workflow-run-setup-panel-Cf_w-NZy.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-j0P-uECz.js +5 -0
- package/dist/gateway/static/root/index.html +12 -12
- package/dist/gateway/static/root/notification-sw.js +1 -1
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/notifications.js +56 -0
- package/dist/packages/gateway-contract/src/turn-outcome.js +114 -0
- package/dist/src/agent/agent-manager.d.ts +3 -1
- package/dist/src/agent/agent-manager.js +22 -5
- package/dist/src/agent/lifecycle/timeout-wrapper.d.ts +1 -0
- package/dist/src/agent/lifecycle/timeout-wrapper.js +7 -6
- package/dist/src/agent/mcp/mcp-transport-config.d.ts +1 -1
- package/dist/src/agent/mcp/mcp-transport-config.js +1 -1
- package/dist/src/agent/memory/understanding/service.js +1 -0
- package/dist/src/agent/memory/understanding/types.d.ts +1 -0
- package/dist/src/agent/orchestration/run-agent-turn-with-timeout.d.ts +2 -2
- package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +4 -4
- package/dist/src/agent/service.d.ts +2 -0
- package/dist/src/agent/service.js +6 -0
- package/dist/src/agent/skills/index.d.ts +22 -2
- package/dist/src/agent/skills/index.js +74 -32
- package/dist/src/agent/skills/skill-sources.d.ts +0 -1
- package/dist/src/agent/skills/skill-sources.js +1 -11
- package/dist/src/agent/tools/create-share-tool.js +14 -1
- package/dist/src/agent/tools/exec-command.js +3 -3
- package/dist/src/agent/tools/execute-code-tool.js +1 -1
- package/dist/src/agent/tools/executor.js +2 -2
- package/dist/src/agent/tools/image-generate-tool.js +12 -0
- package/dist/src/agent/tools/send-media.js +11 -0
- package/dist/src/agent/tools/xopc-use-tool.js +1 -1
- package/dist/src/cli/command-loaders.js +1 -0
- package/dist/src/cli/command-manifest.js +4 -0
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/history.d.ts +1 -0
- package/dist/src/cli/commands/history.js +50 -0
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/connectors/connected-source-understanding.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/chat-stream/protocol.d.ts +3 -2
- package/dist/src/gateway/chat-stream/turn-outcome-collector.d.ts +16 -0
- package/dist/src/gateway/chat-stream/turn-outcome-collector.js +111 -0
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/static-ui.js +7 -5
- package/dist/src/gateway/hono/routes/connectors.js +18 -16
- package/dist/src/gateway/hono/routes/index.js +2 -0
- package/dist/src/gateway/hono/routes/mobile.js +18 -40
- package/dist/src/gateway/hono/routes/notifications.d.ts +3 -0
- package/dist/src/gateway/hono/routes/notifications.js +45 -0
- package/dist/src/gateway/hono/routes/project-skills.js +30 -2
- package/dist/src/gateway/hono/routes/sessions.js +31 -0
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/hono/routes/voice.js +1 -1
- package/dist/src/gateway/hono/routes/you.js +52 -0
- package/dist/src/gateway/service/agent-runner.js +6 -2
- package/dist/src/gateway/service/run-gateway-agent.js +53 -1
- package/dist/src/gateway/service/sessions-api.d.ts +6 -0
- package/dist/src/gateway/service/sessions-api.js +60 -3
- package/dist/src/gateway/service.d.ts +2 -2
- package/dist/src/gateway/service.js +8 -7
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/history/ctx/exporter.d.ts +14 -0
- package/dist/src/history/ctx/exporter.js +99 -0
- package/dist/src/history/ctx/format.d.ts +25 -0
- package/dist/src/history/ctx/format.js +282 -0
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/knowledge/connected-understanding-pipeline.js +12 -3
- package/dist/src/knowledge/index.d.ts +0 -1
- package/dist/src/knowledge/index.js +1 -2
- package/dist/src/media/session-references.d.ts +6 -0
- package/dist/src/media/session-references.js +24 -3
- package/dist/src/notifications/device-store.d.ts +16 -0
- package/dist/src/notifications/device-store.js +96 -0
- package/dist/src/notifications/planner.d.ts +6 -0
- package/dist/src/notifications/planner.js +156 -0
- package/dist/src/notifications/service.d.ts +18 -0
- package/dist/src/notifications/service.js +184 -0
- package/dist/src/notifications/store.d.ts +53 -0
- package/dist/src/notifications/store.js +184 -0
- package/dist/src/notifications/types.d.ts +29 -0
- package/dist/src/notifications/types.js +14 -0
- package/dist/src/projects/project-skill-service.d.ts +28 -6
- package/dist/src/projects/project-skill-service.js +76 -29
- package/dist/src/session/client-history.d.ts +3 -1
- package/dist/src/session/client-history.js +13 -0
- package/dist/src/session/index.d.ts +1 -1
- package/dist/src/session/manager.d.ts +1 -0
- package/dist/src/session/manager.js +6 -0
- package/dist/src/session/store.d.ts +15 -0
- package/dist/src/session/store.js +58 -0
- package/dist/src/storage/sqlite/index.d.ts +2 -1
- package/dist/src/storage/sqlite/index.js +3 -2
- package/dist/src/storage/sqlite/migrations/135_user_people.sql +59 -0
- package/dist/src/storage/sqlite/migrations/136_product_notifications.sql +79 -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/storage/sqlite/session-input-repository.d.ts +5 -0
- package/dist/src/storage/sqlite/session-input-repository.js +9 -1
- package/dist/src/storage/sqlite/user-people-repository.d.ts +32 -0
- package/dist/src/storage/sqlite/user-people-repository.js +246 -0
- package/dist/src/tasks/index.js +2 -2
- package/dist/src/tasks/task-application-service.js +42 -6
- package/dist/src/tasks/task-change-events.d.ts +9 -0
- package/dist/src/tasks/task-change-events.js +17 -1
- package/dist/src/tasks/task-outbox-dispatcher.js +5 -1
- package/dist/src/tasks/task-run-dispatcher.js +4 -2
- package/dist/src/tasks/task-run-repository.js +13 -0
- package/dist/src/user-context/relationships/indexer.d.ts +13 -0
- package/dist/src/user-context/relationships/indexer.js +185 -0
- package/dist/src/user-context/relationships/service.d.ts +22 -0
- package/dist/src/user-context/relationships/service.js +50 -0
- package/dist/src/user-context/relationships/types.d.ts +55 -0
- package/dist/src/user-context/relationships/types.js +10 -0
- package/dist/src/user-context/sources/repository.d.ts +1 -1
- package/dist/src/user-context/sources/repository.js +8 -2
- package/dist/src/work-discovery/service.js +1 -1
- package/package.json +2 -2
- package/dist/gateway/static/root/assets/agents-DeEEFZJ4.js +0 -68
- package/dist/gateway/static/root/assets/apps-page-Db5YNHVM.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-CNT05YTb.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-UbDj3LIq.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CiO152QS.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-Bc_hRwfL.js +0 -3
- package/dist/gateway/static/root/assets/channels-settings-CFW7zBoT.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-5rNVq7iI.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DLBr5nre.js +0 -2
- package/dist/gateway/static/root/assets/heartbeat-settings-Dq4YAlSx.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BIXkO0Ck.js +0 -1
- package/dist/gateway/static/root/assets/index-Csccu8sa.js +0 -74
- package/dist/gateway/static/root/assets/index-D3_xSYKd.css +0 -2
- package/dist/gateway/static/root/assets/local-app-workbench-page-D-eacBcO.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-BRCglHvd.js +0 -2
- package/dist/gateway/static/root/assets/markdown-view-CTB9u15e.js +0 -69
- package/dist/gateway/static/root/assets/mermaid-render-BbqDc_LQ.js +0 -134
- package/dist/gateway/static/root/assets/messages-CeydamsI.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-_13lmvmF.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-BStRkOQr.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-CY03RxVr.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-B19llkld.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BDA2qbTd.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BONIDX4v.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-CdzVKrBl.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CsRWid5h.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-B6YFX7kK.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-CiCQA40E.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-AG04TTuH.js +0 -5
- package/dist/src/knowledge/people-graph.d.ts +0 -25
- package/dist/src/knowledge/people-graph.js +0 -92
- package/dist/src/mobile/notification-service.d.ts +0 -9
- package/dist/src/mobile/notification-service.js +0 -156
- package/dist/src/mobile/notification-store.d.ts +0 -28
- package/dist/src/mobile/notification-store.js +0 -132
- package/dist/src/mobile/notification-types.d.ts +0 -37
- package/dist/src/mobile/notification-types.js +0 -9
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Config } from '../config/schema.js';
|
|
2
|
-
import
|
|
2
|
+
import { type WorkspaceSkillSourceStatus } from '../agent/skills/index.js';
|
|
3
|
+
import type { Skill, SkillDiagnostic, SkillMetadata, SkillToolConditions } from '../agent/skills/types.js';
|
|
3
4
|
import type { ProjectService } from './project-service.js';
|
|
4
5
|
export type ProjectSkillErrorCode = 'project_not_found' | 'project_workspace_required' | 'project_workspace_missing' | 'project_workspace_not_writable' | 'skill_not_found' | 'invalid_skill_id';
|
|
5
6
|
export declare class ProjectSkillError extends Error {
|
|
@@ -8,33 +9,53 @@ export declare class ProjectSkillError extends Error {
|
|
|
8
9
|
constructor(code: ProjectSkillErrorCode, status: 400 | 403 | 404 | 409, message: string);
|
|
9
10
|
}
|
|
10
11
|
export interface ProjectSkillSummary {
|
|
11
|
-
|
|
12
|
+
key: string;
|
|
13
|
+
directoryId: string;
|
|
12
14
|
name: string;
|
|
13
15
|
description: string;
|
|
14
16
|
category?: string;
|
|
17
|
+
origin: Skill['origin']['id'];
|
|
18
|
+
path: string;
|
|
19
|
+
managed: boolean;
|
|
20
|
+
writable: boolean;
|
|
21
|
+
removable: boolean;
|
|
22
|
+
effective: boolean;
|
|
23
|
+
shadowedBy?: Skill['origin']['id'];
|
|
15
24
|
disableModelInvocation: boolean;
|
|
16
25
|
metadata: SkillMetadata;
|
|
17
26
|
toolConditions?: SkillToolConditions;
|
|
18
27
|
requiredEnvVarNames?: string[];
|
|
19
28
|
}
|
|
29
|
+
export interface ProjectWorkspaceTrustState {
|
|
30
|
+
workspacePath: string;
|
|
31
|
+
required: boolean;
|
|
32
|
+
decision: boolean | null;
|
|
33
|
+
trusted: boolean;
|
|
34
|
+
}
|
|
20
35
|
export interface ProjectSkillListResult {
|
|
21
36
|
workspaceRoot: string;
|
|
22
|
-
|
|
37
|
+
sources: WorkspaceSkillSourceStatus[];
|
|
38
|
+
trust: ProjectWorkspaceTrustState;
|
|
23
39
|
items: ProjectSkillSummary[];
|
|
40
|
+
inheritedItems: ProjectSkillSummary[];
|
|
24
41
|
diagnostics: SkillDiagnostic[];
|
|
25
42
|
}
|
|
26
43
|
interface ProjectSkillServiceOptions {
|
|
27
44
|
projects: ProjectService;
|
|
28
45
|
getConfig: () => Config;
|
|
46
|
+
getWorkspaceTrust: (workspaceRoot: string) => ProjectWorkspaceTrustState;
|
|
47
|
+
setWorkspaceTrust: (workspaceRoot: string, trusted: boolean) => ProjectWorkspaceTrustState;
|
|
29
48
|
refreshSkills: () => void | Promise<void>;
|
|
30
49
|
}
|
|
31
50
|
export declare class ProjectSkillService {
|
|
32
51
|
private readonly options;
|
|
33
52
|
constructor(options: ProjectSkillServiceOptions);
|
|
34
53
|
list(projectId: string): ProjectSkillListResult;
|
|
35
|
-
getContent(projectId: string,
|
|
54
|
+
getContent(projectId: string, skillKey: string): ProjectSkillSummary & {
|
|
36
55
|
bodyMarkdown: string;
|
|
37
56
|
};
|
|
57
|
+
getWorkspaceTrust(projectId: string): ProjectWorkspaceTrustState;
|
|
58
|
+
setWorkspaceTrust(projectId: string, trusted: boolean): ProjectWorkspaceTrustState;
|
|
38
59
|
installZip(projectId: string, buffer: Buffer, input?: {
|
|
39
60
|
skillId?: string;
|
|
40
61
|
overwrite?: boolean;
|
|
@@ -59,9 +80,10 @@ export declare class ProjectSkillService {
|
|
|
59
80
|
bodyMarkdown: string;
|
|
60
81
|
}>;
|
|
61
82
|
remove(projectId: string, skillId: string): Promise<void>;
|
|
62
|
-
private findSkill;
|
|
63
83
|
private resolveLocation;
|
|
64
|
-
private
|
|
84
|
+
private loadCatalog;
|
|
85
|
+
private skillKey;
|
|
86
|
+
private encodeSkillKey;
|
|
65
87
|
private toSummary;
|
|
66
88
|
}
|
|
67
89
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { init_paths, resolveBundledSkillsDir } from "../config/paths.js";
|
|
1
2
|
import { resolveWorkspaceSkillsDir, resolveWorkspaceSkillsLockPath } from "../agent/skills/workspace-skills-dir.js";
|
|
2
|
-
import {
|
|
3
|
+
import { loadSkills, loadWorkspaceSkillInventory } from "../agent/skills/index.js";
|
|
3
4
|
import { removeSkillsLockEntry } from "../agent/skills/hub-lock.js";
|
|
4
5
|
import { deleteManagedSkill, installSkillFromZip, isValidSkillId } from "../agent/skills/managed-store.js";
|
|
5
6
|
import { pullSkillFromSource } from "../agent/skills/hub-pull.js";
|
|
@@ -7,6 +8,7 @@ import { downloadFromMarketplace } from "../agent/skills/skills-marketplace.js";
|
|
|
7
8
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
8
9
|
import { accessSync, constants, existsSync, statSync } from "node:fs";
|
|
9
10
|
//#region src/projects/project-skill-service.ts
|
|
11
|
+
init_paths();
|
|
10
12
|
var ProjectSkillError = class extends Error {
|
|
11
13
|
constructor(code, status, message) {
|
|
12
14
|
super(message);
|
|
@@ -20,21 +22,44 @@ var ProjectSkillService = class {
|
|
|
20
22
|
this.options = options;
|
|
21
23
|
}
|
|
22
24
|
list(projectId) {
|
|
23
|
-
const location = this.
|
|
24
|
-
const loaded = loadWorkspaceSkills(location.workspaceRoot);
|
|
25
|
+
const { location, loaded, inherited, trust } = this.loadCatalog(projectId);
|
|
25
26
|
return {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
workspaceRoot: location.workspaceRoot,
|
|
28
|
+
sources: loaded.sources,
|
|
29
|
+
trust,
|
|
30
|
+
items: loaded.entries.map((entry) => this.toSummary(entry)),
|
|
31
|
+
inheritedItems: inherited.skills.map((skill) => this.toSummary({
|
|
32
|
+
skill,
|
|
33
|
+
effective: true
|
|
34
|
+
})),
|
|
35
|
+
diagnostics: inherited.diagnostics
|
|
29
36
|
};
|
|
30
37
|
}
|
|
31
|
-
getContent(projectId,
|
|
32
|
-
const {
|
|
38
|
+
getContent(projectId, skillKey) {
|
|
39
|
+
const { loaded, inherited } = this.loadCatalog(projectId);
|
|
40
|
+
const entry = loaded.entries.find((candidate) => this.skillKey(candidate.skill) === skillKey);
|
|
41
|
+
if (entry) return {
|
|
42
|
+
...this.toSummary(entry),
|
|
43
|
+
bodyMarkdown: entry.skill.content
|
|
44
|
+
};
|
|
45
|
+
const inheritedSkill = inherited.skills.find((candidate) => this.skillKey(candidate) === skillKey);
|
|
46
|
+
if (!inheritedSkill) throw new ProjectSkillError("skill_not_found", 404, "Project skill not found");
|
|
33
47
|
return {
|
|
34
|
-
...this.toSummary(
|
|
35
|
-
|
|
48
|
+
...this.toSummary({
|
|
49
|
+
skill: inheritedSkill,
|
|
50
|
+
effective: true
|
|
51
|
+
}),
|
|
52
|
+
bodyMarkdown: inheritedSkill.content
|
|
36
53
|
};
|
|
37
54
|
}
|
|
55
|
+
getWorkspaceTrust(projectId) {
|
|
56
|
+
const location = this.resolveLocation(projectId, false);
|
|
57
|
+
return this.options.getWorkspaceTrust(location.workspaceRoot);
|
|
58
|
+
}
|
|
59
|
+
setWorkspaceTrust(projectId, trusted) {
|
|
60
|
+
const location = this.resolveLocation(projectId, false);
|
|
61
|
+
return this.options.setWorkspaceTrust(location.workspaceRoot, trusted);
|
|
62
|
+
}
|
|
38
63
|
async installZip(projectId, buffer, input = {}) {
|
|
39
64
|
const location = this.resolveLocation(projectId, true);
|
|
40
65
|
const installed = installSkillFromZip(buffer, {
|
|
@@ -44,7 +69,7 @@ var ProjectSkillService = class {
|
|
|
44
69
|
});
|
|
45
70
|
removeSkillsLockEntry(installed.skillId, resolveWorkspaceSkillsLockPath(location.workspaceRoot));
|
|
46
71
|
await this.options.refreshSkills();
|
|
47
|
-
return this.getContent(projectId, installed.skillId);
|
|
72
|
+
return this.getContent(projectId, this.encodeSkillKey("xopc-workspace", installed.skillId));
|
|
48
73
|
}
|
|
49
74
|
async installMarketplace(projectId, input) {
|
|
50
75
|
const downloaded = await downloadFromMarketplace(this.options.getConfig(), input.name, input.version, input.provider);
|
|
@@ -64,7 +89,7 @@ var ProjectSkillService = class {
|
|
|
64
89
|
lockPath: resolveWorkspaceSkillsLockPath(location.workspaceRoot)
|
|
65
90
|
});
|
|
66
91
|
await this.options.refreshSkills();
|
|
67
|
-
return this.getContent(projectId, installed.skillId);
|
|
92
|
+
return this.getContent(projectId, this.encodeSkillKey("xopc-workspace", installed.skillId));
|
|
68
93
|
}
|
|
69
94
|
async remove(projectId, skillId) {
|
|
70
95
|
const location = this.resolveLocation(projectId, true);
|
|
@@ -74,18 +99,6 @@ var ProjectSkillService = class {
|
|
|
74
99
|
removeSkillsLockEntry(skillId, resolveWorkspaceSkillsLockPath(location.workspaceRoot));
|
|
75
100
|
await this.options.refreshSkills();
|
|
76
101
|
}
|
|
77
|
-
findSkill(projectId, skillId) {
|
|
78
|
-
if (!isValidSkillId(skillId)) throw new ProjectSkillError("invalid_skill_id", 400, "Invalid skill id");
|
|
79
|
-
const location = this.resolveLocation(projectId, false);
|
|
80
|
-
const skill = loadWorkspaceSkills(location.workspaceRoot).skills.find((item) => {
|
|
81
|
-
return !relative(location.skillsRoot, item.baseDir).includes(sep) && basename(item.baseDir) === skillId;
|
|
82
|
-
});
|
|
83
|
-
if (!skill) throw new ProjectSkillError("skill_not_found", 404, "Project skill not found");
|
|
84
|
-
return {
|
|
85
|
-
skill,
|
|
86
|
-
skillsRoot: location.skillsRoot
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
102
|
resolveLocation(projectId, requireWritable) {
|
|
90
103
|
const project = this.options.projects.get(projectId);
|
|
91
104
|
if (!project) throw new ProjectSkillError("project_not_found", 404, "Project not found");
|
|
@@ -110,16 +123,50 @@ var ProjectSkillService = class {
|
|
|
110
123
|
skillsRoot
|
|
111
124
|
};
|
|
112
125
|
}
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
126
|
+
loadCatalog(projectId) {
|
|
127
|
+
const location = this.resolveLocation(projectId, false);
|
|
128
|
+
const trust = this.options.getWorkspaceTrust(location.workspaceRoot);
|
|
129
|
+
const loaded = loadWorkspaceSkillInventory(location.workspaceRoot, { workspaceTrust: trust.trusted ? "trusted" : "untrusted" });
|
|
130
|
+
const all = loadSkills({
|
|
131
|
+
workspaceDir: location.workspaceRoot,
|
|
132
|
+
builtinDir: resolveBundledSkillsDir(),
|
|
133
|
+
workspaceTrust: trust.trusted ? "trusted" : "untrusted"
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
location,
|
|
137
|
+
loaded,
|
|
138
|
+
inherited: {
|
|
139
|
+
skills: all.skills.filter((skill) => skill.origin.scope !== "workspace"),
|
|
140
|
+
diagnostics: all.diagnostics
|
|
141
|
+
},
|
|
142
|
+
trust
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
skillKey(skill) {
|
|
146
|
+
const rel = relative(skill.origin.rootDir, skill.baseDir).split(sep).join("/");
|
|
147
|
+
return this.encodeSkillKey(skill.origin.id, rel);
|
|
148
|
+
}
|
|
149
|
+
encodeSkillKey(origin, relativeDir) {
|
|
150
|
+
return Buffer.from(`${origin}\0${relativeDir}`, "utf8").toString("base64url");
|
|
116
151
|
}
|
|
117
|
-
toSummary(
|
|
152
|
+
toSummary(entry) {
|
|
153
|
+
const { skill } = entry;
|
|
154
|
+
const id = basename(skill.baseDir);
|
|
155
|
+
const relativeDir = relative(skill.origin.rootDir, skill.baseDir);
|
|
156
|
+
const removable = skill.origin.id === "xopc-workspace" && !relativeDir.includes(sep) && isValidSkillId(id);
|
|
118
157
|
return {
|
|
119
|
-
|
|
158
|
+
key: this.skillKey(skill),
|
|
159
|
+
directoryId: id,
|
|
120
160
|
name: skill.name,
|
|
121
161
|
description: skill.description,
|
|
122
162
|
category: skill.category,
|
|
163
|
+
origin: skill.origin.id,
|
|
164
|
+
path: skill.baseDir,
|
|
165
|
+
managed: skill.origin.managed,
|
|
166
|
+
writable: skill.origin.writable,
|
|
167
|
+
removable,
|
|
168
|
+
effective: entry.effective,
|
|
169
|
+
shadowedBy: entry.shadowedBy,
|
|
123
170
|
disableModelInvocation: skill.disableModelInvocation,
|
|
124
171
|
metadata: skill.metadata,
|
|
125
172
|
toolConditions: skill.toolConditions,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type TurnOutcome } from '@xopcai/gateway-contract';
|
|
1
2
|
import type { Message } from './types.js';
|
|
2
3
|
import type { TranscriptStoredRow } from './session-context-for-llm.js';
|
|
3
4
|
/** Transcript row for TUI and HTTP clients (flattened from persisted session messages). */
|
|
@@ -13,7 +14,7 @@ export interface ClientHistoryMessage {
|
|
|
13
14
|
timestamp?: number;
|
|
14
15
|
/** Whitelisted display metadata; never includes source snapshot text. */
|
|
15
16
|
metadata?: {
|
|
16
|
-
sourceContexts
|
|
17
|
+
sourceContexts?: Array<{
|
|
17
18
|
kind: 'note';
|
|
18
19
|
sourceId: string;
|
|
19
20
|
version: string;
|
|
@@ -21,6 +22,7 @@ export interface ClientHistoryMessage {
|
|
|
21
22
|
tokenEstimate?: number;
|
|
22
23
|
truncated?: boolean;
|
|
23
24
|
}>;
|
|
25
|
+
turnOutcome?: TurnOutcome;
|
|
24
26
|
};
|
|
25
27
|
kind?: 'message' | 'compaction' | 'context' | 'bash' | 'custom' | 'branch';
|
|
26
28
|
tokensBefore?: number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseTurnOutcome } from "../../packages/gateway-contract/src/turn-outcome.js";
|
|
1
2
|
import { stripRuntimeContextFromUserMessage } from "./user-message-display.js";
|
|
2
3
|
import { buildTranscriptOutline } from "./transcript-outline.js";
|
|
3
4
|
//#region src/session/client-history.ts
|
|
@@ -286,6 +287,18 @@ function customStateRowToClientHistory(row) {
|
|
|
286
287
|
if (r.type !== "custom") return null;
|
|
287
288
|
const customType = optionalString(r.customType)?.trim();
|
|
288
289
|
if (!customType) return null;
|
|
290
|
+
if (customType === "turn_outcome") {
|
|
291
|
+
const outcome = parseTurnOutcome(r.data);
|
|
292
|
+
if (!outcome) return null;
|
|
293
|
+
return {
|
|
294
|
+
role: "assistant",
|
|
295
|
+
kind: "message",
|
|
296
|
+
turnId: outcome.turnId,
|
|
297
|
+
content: "",
|
|
298
|
+
timestamp: parseTimestampValue(typeof r.timestamp === "string" || typeof r.timestamp === "number" ? r.timestamp : void 0),
|
|
299
|
+
metadata: { turnOutcome: outcome }
|
|
300
|
+
};
|
|
301
|
+
}
|
|
289
302
|
return {
|
|
290
303
|
role: "system",
|
|
291
304
|
kind: "custom",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { SessionIndex, type SessionIndexConfig } from './manager.js';
|
|
2
2
|
export { onSessionTranscriptUpdate, emitSessionTranscriptUpdate, type SessionTranscriptUpdate, } from './transcript-events.js';
|
|
3
3
|
export { SessionStore } from './store.js';
|
|
4
|
-
export type { SessionStoreOptions } from './store.js';
|
|
4
|
+
export type { SessionStoreOptions, ForkSessionAtTurnOptions, ForkSessionResult, } from './store.js';
|
|
5
5
|
export { SessionConfigStore, resolveThinkingLevel, resolveReasoningLevel, resolveVerboseLevel } from './config-store.js';
|
|
6
6
|
export { DEFAULT_ACTIVITY_DETAIL_LEVEL, resolveConfiguredActivityDetailDefault, resolveEffectiveThinkingLevel, resolveEffectiveReasoningLevel, } from './thinking-resolve.js';
|
|
7
7
|
export type { SessionAgentConfig } from './config-types.js';
|
|
@@ -89,6 +89,7 @@ export declare class SessionIndex extends EventEmitter {
|
|
|
89
89
|
sessionKey: string;
|
|
90
90
|
rowCount: number;
|
|
91
91
|
}>;
|
|
92
|
+
forkSessionAtTurn(sourceKey: string, options: import('./store.js').ForkSessionAtTurnOptions): Promise<import('./store.js').ForkSessionResult>;
|
|
92
93
|
getStats(): Promise<GlobalSessionStats>;
|
|
93
94
|
archiveOldSessions(olderThanDays: number): Promise<number>;
|
|
94
95
|
onSessionCreated(callback: (metadata: SessionMetadata) => void): void;
|
|
@@ -171,6 +171,12 @@ var SessionIndex = class extends EventEmitter$1 {
|
|
|
171
171
|
if (metadata) this.emit("sessionCreated", metadata);
|
|
172
172
|
return result;
|
|
173
173
|
}
|
|
174
|
+
async forkSessionAtTurn(sourceKey, options) {
|
|
175
|
+
const result = await this.store.forkSessionAtTurn(sourceKey, options);
|
|
176
|
+
const metadata = await this.store.getMetadata(result.sessionKey);
|
|
177
|
+
if (metadata) this.emit("sessionCreated", metadata);
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
174
180
|
async getStats() {
|
|
175
181
|
return this.store.getStats();
|
|
176
182
|
}
|
|
@@ -27,6 +27,16 @@ export interface SessionCompactionHooks {
|
|
|
27
27
|
}) => Promise<void> | void;
|
|
28
28
|
}
|
|
29
29
|
export type ModelFallbackPreparation = 'prompt' | 'resume' | 'unsafe';
|
|
30
|
+
export interface ForkSessionAtTurnOptions {
|
|
31
|
+
targetKey: string;
|
|
32
|
+
lastTurnId: string;
|
|
33
|
+
targetMetadata: SessionMetadataSeed;
|
|
34
|
+
}
|
|
35
|
+
export interface ForkSessionResult {
|
|
36
|
+
sessionKey: string;
|
|
37
|
+
rowCount: number;
|
|
38
|
+
lastTurnId?: string;
|
|
39
|
+
}
|
|
30
40
|
export declare class SessionStore {
|
|
31
41
|
private options;
|
|
32
42
|
private window;
|
|
@@ -182,6 +192,11 @@ export declare class SessionStore {
|
|
|
182
192
|
sessionKey: string;
|
|
183
193
|
rowCount: number;
|
|
184
194
|
}>;
|
|
195
|
+
/**
|
|
196
|
+
* Atomically copy a completed turn prefix into a new session, including the
|
|
197
|
+
* source session's per-session agent configuration.
|
|
198
|
+
*/
|
|
199
|
+
forkSessionAtTurn(sourceKey: string, options: ForkSessionAtTurnOptions): Promise<ForkSessionResult>;
|
|
185
200
|
getStats(): Promise<GlobalSessionStats>;
|
|
186
201
|
archiveOld(olderThanDays: number): Promise<number>;
|
|
187
202
|
estimateTokens(messages: AgentMessage[]): number;
|
|
@@ -2,12 +2,14 @@ import { init_paths_state, resolveStateDir } from "../config/paths-state.js";
|
|
|
2
2
|
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
|
+
import { runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
5
6
|
import { buildSessionContextForLlm, buildSessionDisplayMessages, isRuntimeOnlyTranscriptMessage, isTranscriptCompactionEntry, mergeLlmMessagesPreservingContextRows, transcriptRowsFromJsonArray } from "./session-context-for-llm.js";
|
|
6
7
|
import "./types.js";
|
|
7
8
|
import { init_agent_session_key, resolveAgentIdFromSessionKey } from "../routing/agent-session-key.js";
|
|
8
9
|
import { estimateTokensFromMessages } from "../storage/sqlite/row-mappers.js";
|
|
9
10
|
import { deleteSessionRecord, ensureSessionRecord, findSessionKeyBySessionId, getGlobalSessionStats, getSessionMetadata, listSessionMetadata, listSessionsByAgent, patchSessionMetadata, resetSessionRecord } from "../storage/sqlite/session-repository.js";
|
|
10
11
|
import { appendCompactionBoundaryIfUnchanged, appendTranscriptEntry, listCompactionBoundaries, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRowsForSession, paginateTranscriptMessages, replaceTranscriptRows, restoreBeforeCompactionBoundary, searchSessionTranscript } from "../storage/sqlite/transcript-repository.js";
|
|
12
|
+
import { getSessionConfig, setSessionConfig } from "../storage/sqlite/config-repository.js";
|
|
11
13
|
import "../storage/sqlite/index.js";
|
|
12
14
|
import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
|
|
13
15
|
import { readPostCompactionContext } from "../agent/reply/post-compaction-context.js";
|
|
@@ -657,6 +659,62 @@ var SessionStore = class {
|
|
|
657
659
|
};
|
|
658
660
|
});
|
|
659
661
|
}
|
|
662
|
+
/**
|
|
663
|
+
* Atomically copy a completed turn prefix into a new session, including the
|
|
664
|
+
* source session's per-session agent configuration.
|
|
665
|
+
*/
|
|
666
|
+
async forkSessionAtTurn(sourceKey, options) {
|
|
667
|
+
requireXopcDatabase();
|
|
668
|
+
const targetKey = options.targetKey.trim();
|
|
669
|
+
const lastTurnId = options.lastTurnId.trim();
|
|
670
|
+
if (!targetKey) throw new Error("Target session key is required");
|
|
671
|
+
if (!lastTurnId) throw new Error("lastTurnId is required");
|
|
672
|
+
return runSqliteWriteTransaction(() => {
|
|
673
|
+
const sourceMetadata = getSessionMetadata(sourceKey);
|
|
674
|
+
if (!sourceMetadata) throw new Error(`Session not found: ${sourceKey}`);
|
|
675
|
+
if (getSessionMetadata(targetKey)) throw new Error(`Target session already exists: ${targetKey}`);
|
|
676
|
+
const rows = loadTranscriptHistoryRowsForSession(sourceKey);
|
|
677
|
+
let lastTurnRow = -1;
|
|
678
|
+
let hasAssistantOutput = false;
|
|
679
|
+
for (let index = 0; index < rows.length; index += 1) {
|
|
680
|
+
const row = rows[index];
|
|
681
|
+
if (row.turnId !== lastTurnId) continue;
|
|
682
|
+
lastTurnRow = index;
|
|
683
|
+
if (row.role === "assistant") hasAssistantOutput = true;
|
|
684
|
+
}
|
|
685
|
+
if (lastTurnRow < 0 || !hasAssistantOutput) throw new Error(`Completed turn not found: ${lastTurnId}`);
|
|
686
|
+
const selectedRows = rows.slice(0, lastTurnRow + 1);
|
|
687
|
+
const sourceLabel = sourceMetadata.name?.trim() || sourceKey;
|
|
688
|
+
const forkedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
689
|
+
const cwd = sourceMetadata.cwd?.trim() || this.resolveWorkspaceCwd(targetKey);
|
|
690
|
+
ensureSessionRecord(targetKey, cwd, {
|
|
691
|
+
...options.targetMetadata,
|
|
692
|
+
name: `Fork of ${sourceLabel}`,
|
|
693
|
+
tags: [...new Set([...sourceMetadata.tags ?? [], "fork"])],
|
|
694
|
+
projectId: sourceMetadata.projectId,
|
|
695
|
+
parentSessionKey: sourceKey,
|
|
696
|
+
hiddenFromSessionList: false,
|
|
697
|
+
customData: {
|
|
698
|
+
...sourceMetadata.customData ?? {},
|
|
699
|
+
...options.targetMetadata.customData ?? {},
|
|
700
|
+
genericNewChatShell: false,
|
|
701
|
+
forkedFromSessionKey: sourceKey,
|
|
702
|
+
forkedFromSessionId: sourceMetadata.sessionId,
|
|
703
|
+
forkedFromSessionName: sourceMetadata.name,
|
|
704
|
+
forkedFromTurnId: lastTurnId,
|
|
705
|
+
forkedAt
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
replaceTranscriptRows(targetKey, selectedRows);
|
|
709
|
+
const sourceConfig = getSessionConfig(sourceKey);
|
|
710
|
+
if (sourceConfig) setSessionConfig(targetKey, sourceConfig, cwd);
|
|
711
|
+
return {
|
|
712
|
+
sessionKey: targetKey,
|
|
713
|
+
rowCount: selectedRows.length,
|
|
714
|
+
lastTurnId
|
|
715
|
+
};
|
|
716
|
+
});
|
|
717
|
+
}
|
|
660
718
|
async getStats() {
|
|
661
719
|
requireXopcDatabase();
|
|
662
720
|
return getGlobalSessionStats();
|
|
@@ -10,7 +10,8 @@ export { closeTemporalAssertions, createTemporalAssertion, linkContextObjects, l
|
|
|
10
10
|
export { finishContextConsolidationRun, getContextConsolidationRun, listContextConsolidationDecisions, listContextConsolidationRuns, recordContextConsolidationDecision, startContextConsolidationRun, type ContextConsolidationDecision, type ContextConsolidationRun, } from './context-consolidation-repository.js';
|
|
11
11
|
export { summarizeUnderstandingFeedback, summarizeUserUnderstandingQuality, type UnderstandingFeedbackSummary, type UserUnderstandingQualityMetrics, } from './user-context-quality-repository.js';
|
|
12
12
|
export { createCollaborationRule, createContextEvidence, createUnderstanding, closeUnderstandingValidity, consumeContextConsent, deleteCollaborationRule, deleteUnderstanding, decideContextConsent, ensureContextConsent, getCollaborationRule, getTurnPersonalization, getUnderstanding, getUserProfile, hasContextConsent, isUnderstandingSuppressed, listCollaborationRules, listUnderstandingEvidence, listUnderstandings, linkUnderstandingEvidence, recordContextFeedback, recordContextRun, rejectUnderstanding, reviseCollaborationRule, reviseUnderstanding, searchActiveUnderstandings, setCollaborationRuleStatus, setUnderstandingStatus, updateUserProfile, type CreateUnderstandingInput, } from './user-context-repository.js';
|
|
13
|
-
export {
|
|
13
|
+
export { getUserPerson, getUserPeopleIndexState, listUserPeople, mergeUserPeople, replaceUserPeopleIndex, summarizeUserPeople, updateUserPerson, } from './user-people-repository.js';
|
|
14
|
+
export { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputState, getSessionInputById, insertSessionInput, listActiveSessionInputRuns, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus, type SessionInput, type SessionInputDelivery, type SessionInputState, type SessionInputStatus, } from './session-input-repository.js';
|
|
14
15
|
export { replaceLatestSessionTurnAndQueueInput, validateLatestSessionTurnTarget, type ReplaceLatestSessionTurnInput, type ReplaceLatestSessionTurnResult, } from './session-turn-replace-repository.js';
|
|
15
16
|
export { acknowledgeHomeAttention, isHomeAttentionAcknowledged, type HomeAttentionSubjectKind, } from './home-attention-repository.js';
|
|
16
17
|
export { claimNextConnectorLearningJob, enqueueConnectorLearningJob, listConnectorLearningJobs, recoverStaleConnectorLearningJobs, setConnectorLearningPaused, updateConnectorLearningJob, type ConnectorLearningJob, type ConnectorLearningMode, type ConnectorLearningPhase, type ConnectorLearningStatus, } from './connector-learning-repository.js';
|
|
@@ -11,7 +11,8 @@ import { closeTemporalAssertions, createTemporalAssertion, linkContextObjects, l
|
|
|
11
11
|
import { finishContextConsolidationRun, getContextConsolidationRun, listContextConsolidationDecisions, listContextConsolidationRuns, recordContextConsolidationDecision, startContextConsolidationRun } from "./context-consolidation-repository.js";
|
|
12
12
|
import { summarizeUnderstandingFeedback, summarizeUserUnderstandingQuality } from "./user-context-quality-repository.js";
|
|
13
13
|
import { closeUnderstandingValidity, consumeContextConsent, createCollaborationRule, createContextEvidence, createUnderstanding, decideContextConsent, deleteCollaborationRule, deleteUnderstanding, ensureContextConsent, getCollaborationRule, getTurnPersonalization, getUnderstanding, getUserProfile, hasContextConsent, isUnderstandingSuppressed, linkUnderstandingEvidence, listCollaborationRules, listUnderstandingEvidence, listUnderstandings, recordContextFeedback, recordContextRun, rejectUnderstanding, reviseCollaborationRule, reviseUnderstanding, searchActiveUnderstandings, setCollaborationRuleStatus, setUnderstandingStatus, updateUserProfile } from "./user-context-repository.js";
|
|
14
|
-
import {
|
|
14
|
+
import { getUserPeopleIndexState, getUserPerson, listUserPeople, mergeUserPeople, replaceUserPeopleIndex, summarizeUserPeople, updateUserPerson } from "./user-people-repository.js";
|
|
15
|
+
import { cancelQueuedSessionInput, claimNextSessionInput, findSessionInput, finishSessionInputRun, getSessionInputById, getSessionInputState, insertSessionInput, listActiveSessionInputRuns, mutateQueuedSessionInput, recoverSessionInputState, setSessionInputStatus } from "./session-input-repository.js";
|
|
15
16
|
import { buildDefaultSessionMetadata } from "./session-metadata.js";
|
|
16
17
|
import { buildGlobalSessionStats, classifyStoredRow, estimateTokensFromMessages, extractFtsContent, metadataToSessionInsert, sessionConfigRowToConfig, sessionRowToMetadata, transcriptEntryRowToStoredRow } from "./row-mappers.js";
|
|
17
18
|
import { replaceLatestSessionTurnAndQueueInput, validateLatestSessionTurnTarget } from "./session-turn-replace-repository.js";
|
|
@@ -35,4 +36,4 @@ import { appendConnectorExecutionAudit, claimConnectorWebhookDelivery, completeC
|
|
|
35
36
|
import { getConnectorAccount, listConnectorAccounts, reconcileConnectorAccount, refreshConnectorAccountCurrent } from "./connector-account-repository.js";
|
|
36
37
|
import { getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, listConnectorSyncPolicies, upsertConnectorSyncPolicy } from "./connector-sync-policy-repository.js";
|
|
37
38
|
import { getUserTrustPolicy, setUserTrustPolicy } from "./user-trust-repository.js";
|
|
38
|
-
export { COMPOSER_INPUT_HISTORY_LIMIT, DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, acknowledgeHomeAttention, appendCompactionBoundaryIfUnchanged, appendComposerInputHistory, appendConnectorExecutionAudit, appendMemorySignal, appendMemoryTraceEvent, appendTranscriptEntry, applyPendingMigrations, attachMemoryEvidence, bindEndpointPrincipal, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRelationshipPrompt, cancelQueuedSessionInput, claimConnectorWebhookDelivery, claimContextExtractionRun, claimKnowledgeSourceItems, claimNextConnectorLearningJob, claimNextSessionInput, classifyStoredRow, clearComposerInputHistory, closeTemporalAssertions, closeUnderstandingValidity, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeConnectorApproval, consumeContextConsent, countKnowledgeSourceItems, countMemoryRecordsBySourceInstanceId, createCollaborationRule, createConnectorApproval, createContextEvidence, createEndpointPrincipal, createObjectLinkRecord, createTemporalAssertion, createUnderstanding, decideConnectorApproval, decideContextConsent, deleteCollaborationRule, deleteConnectorConnection, deleteConnectorInstallation, deleteKnowledgeSourceItems, deleteMemoryEvidenceForRecord, deleteMemoryRecord, deleteMemoryRecordsBySourceInstanceId, deleteNoteAgentContextRecord, deleteNoteRecord, deleteObjectLinkRecord, deleteSessionConfig, deleteSessionRecord, deleteUnderstanding, discoverSqlMigrations, enqueueConnectorLearningJob, ensureContextConsent, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findSessionInput, findSessionKeyBySessionId, finishContextConsolidationRun, finishContextExtractionRun, finishEndpointToolInvocationAudit, finishKnowledgeSyncRun, finishSessionInputRun, getActivityEventRecord, getCachedConnectorCatalogEntry, getCollaborationRule, getConnectorAccount, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, getContextConsolidationRun, getContextExtractionRun, getCurrentSessionId, getEndpointPrincipal, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getMemoryProviderState, getMemoryRecord, getMemoryTurnFeedback, getNoteAgentContextRecord, getNoteRecord, getRelationshipSettings, getSessionConfig, getSessionInputById, getSessionInputState, getSessionMetadata, getSessionPersistedLevels, getSessionTaskPlan, getSqliteDatabase, getTurnPersonalization, getUnderstanding, getUserProfile, getUserTrustPolicy, getXopcDatabase, hasContextConsent, hasIndependentExtractionOutput, hasSessionConfig, hasUnresolvedMemoryConflict, incrementSessionStatsOnAppend, insertSessionInput, inspectSchemaMigrationStatus, isHomeAttentionAcknowledged, isProactiveSupportAllowed, isUnderstandingSuppressed, isXopcDatabaseOpen, linkContextObjects, linkUnderstandingEvidence, listActivityRecords, listCachedConnectorCatalogEntries, listCollaborationRules, listCompactionBoundaries, listComposerInputHistory, listConnectorAccounts, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listConnectorLearningJobs, listConnectorSyncPolicies, listContextConsolidationDecisions, listContextConsolidationRuns, listContextExtractionOutputs, listContextExtractionRuns, listContextObjectRelations, listEndpointPrincipals, listEndpointToolInvocationAudits, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listMemoryEvidence, listMemoryRecords, listMemorySignals, listMemoryTraceEvents, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listTemporalAssertions, listUnderstandingEvidence, listUnderstandings, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, markMemoryRecordsConflicted, metadataToSessionInsert, mutateQueuedSessionInput, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, pruneBoundedKnowledgeSourceItems, readSchemaVersion, readSchemaVersionForTest, reconcileConnectorAccount, recordActivityEvent, recordContextConsolidationDecision, recordContextFeedback, recordContextRun, recoverSessionInputState, recoverStaleConnectorLearningJobs, refreshConnectorAccountCurrent, rejectUnderstanding, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceLatestSessionTurnAndQueueInput, replaceTranscriptRows, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreBeforeCompactionBoundary, reviseCollaborationRule, reviseUnderstanding, revokeEndpointPrincipal, runSqliteWriteTransaction, searchActiveUnderstandings, searchMemoryRecords, searchSessionTranscript, sessionConfigRowToConfig, sessionRowToMetadata, setCollaborationRuleStatus, setConnectorLearningPaused, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setMemoryProviderState, setMemoryRecordStatus, setMemoryTurnFeedback, setSessionConfig, setSessionInputStatus, setSessionTaskPlan, setUnderstandingStatus, setUserTrustPolicy, startContextConsolidationRun, startEndpointToolInvocationAudit, startKnowledgeSyncRun, summarizeMemoryRecallFeedback, summarizeUnderstandingFeedback, summarizeUserUnderstandingQuality, touchEndpointPrincipal, transcriptEntryRowToStoredRow, updateConnectorLearningJob, updateInteractionStateFromMessage, updateRelationshipSettings, updateSessionConfig, updateSessionStats, updateUserProfile, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertConnectorSyncPolicy, upsertKnowledgeSourceItems, upsertMemoryRecord, upsertNoteAgentContextRecord, upsertNoteRecord, validateLatestSessionTurnTarget };
|
|
39
|
+
export { COMPOSER_INPUT_HISTORY_LIMIT, DatabaseSchemaMigrationGapError, DatabaseSchemaTooNewError, SCHEMA_META_SCHEMA_VERSION_KEY, XOPC_DB_BASELINE_SCHEMA_VERSION, XOPC_DB_FILENAME, XOPC_DB_SCHEMA_VERSION, acknowledgeHomeAttention, appendCompactionBoundaryIfUnchanged, appendComposerInputHistory, appendConnectorExecutionAudit, appendMemorySignal, appendMemoryTraceEvent, appendTranscriptEntry, applyPendingMigrations, attachMemoryEvidence, bindEndpointPrincipal, buildDefaultSessionMetadata, buildGlobalSessionStats, buildRelationshipPrompt, cancelQueuedSessionInput, claimConnectorWebhookDelivery, claimContextExtractionRun, claimKnowledgeSourceItems, claimNextConnectorLearningJob, claimNextSessionInput, classifyStoredRow, clearComposerInputHistory, closeTemporalAssertions, closeUnderstandingValidity, closeXopcDatabase, completeConnectorWebhookDelivery, completeKnowledgeSourceItemSynthesis, consumeConnectorApproval, consumeContextConsent, countKnowledgeSourceItems, countMemoryRecordsBySourceInstanceId, createCollaborationRule, createConnectorApproval, createContextEvidence, createEndpointPrincipal, createObjectLinkRecord, createTemporalAssertion, createUnderstanding, decideConnectorApproval, decideContextConsent, deleteCollaborationRule, deleteConnectorConnection, deleteConnectorInstallation, deleteKnowledgeSourceItems, deleteMemoryEvidenceForRecord, deleteMemoryRecord, deleteMemoryRecordsBySourceInstanceId, deleteNoteAgentContextRecord, deleteNoteRecord, deleteObjectLinkRecord, deleteSessionConfig, deleteSessionRecord, deleteUnderstanding, discoverSqlMigrations, enqueueConnectorLearningJob, ensureContextConsent, ensureSessionRecord, ensureXopcDatabaseSchema, estimateTokensFromMessages, extractFtsContent, findSessionInput, findSessionKeyBySessionId, finishContextConsolidationRun, finishContextExtractionRun, finishEndpointToolInvocationAudit, finishKnowledgeSyncRun, finishSessionInputRun, getActivityEventRecord, getCachedConnectorCatalogEntry, getCollaborationRule, getConnectorAccount, getConnectorApproval, getConnectorConnection, getConnectorInstallation, getConnectorSyncPolicy, getConnectorSyncPolicyForConnection, getContextConsolidationRun, getContextExtractionRun, getCurrentSessionId, getEndpointPrincipal, getGlobalSessionStats, getInteractionState, getKnowledgeConsumerWatermark, getKnowledgeSourceCursor, getKnowledgeSourceItem, getMemoryProviderState, getMemoryRecord, getMemoryTurnFeedback, getNoteAgentContextRecord, getNoteRecord, getRelationshipSettings, getSessionConfig, getSessionInputById, getSessionInputState, getSessionMetadata, getSessionPersistedLevels, getSessionTaskPlan, getSqliteDatabase, getTurnPersonalization, getUnderstanding, getUserPeopleIndexState, getUserPerson, getUserProfile, getUserTrustPolicy, getXopcDatabase, hasContextConsent, hasIndependentExtractionOutput, hasSessionConfig, hasUnresolvedMemoryConflict, incrementSessionStatsOnAppend, insertSessionInput, inspectSchemaMigrationStatus, isHomeAttentionAcknowledged, isProactiveSupportAllowed, isUnderstandingSuppressed, isXopcDatabaseOpen, linkContextObjects, linkUnderstandingEvidence, listActiveSessionInputRuns, listActivityRecords, listCachedConnectorCatalogEntries, listCollaborationRules, listCompactionBoundaries, listComposerInputHistory, listConnectorAccounts, listConnectorActionMetadata, listConnectorApprovals, listConnectorConnections, listConnectorExecutionAudit, listConnectorInstallations, listConnectorLearningJobs, listConnectorSyncPolicies, listContextConsolidationDecisions, listContextConsolidationRuns, listContextExtractionOutputs, listContextExtractionRuns, listContextObjectRelations, listEndpointPrincipals, listEndpointToolInvocationAudits, listKnowledgeSourceChanges, listKnowledgeSourceItems, listKnowledgeSyncRuns, listMemoryEvidence, listMemoryRecords, listMemorySignals, listMemoryTraceEvents, listNoteRecords, listObjectActivityRecords, listObjectLinkRecords, listProjectActivityRecords, listRegisteredMigrationTargets, listSessionMetadata, listSessionsByAgent, listTemporalAssertions, listUnderstandingEvidence, listUnderstandings, listUserPeople, loadCompactionSourceSnapshot, loadLlmMessagesForSession, loadTranscriptHistoryRowsForSession, loadTranscriptRows, loadTranscriptRowsForSession, markMemoryRecordsConflicted, mergeUserPeople, metadataToSessionInsert, mutateQueuedSessionInput, openXopcDatabase, paginateTranscriptMessages, patchSessionMetadata, pruneBoundedKnowledgeSourceItems, readSchemaVersion, readSchemaVersionForTest, reconcileConnectorAccount, recordActivityEvent, recordContextConsolidationDecision, recordContextFeedback, recordContextRun, recoverSessionInputState, recoverStaleConnectorLearningJobs, refreshConnectorAccountCurrent, rejectUnderstanding, releaseConnectorWebhookDelivery, replaceConnectorCatalogEntries, replaceLatestSessionTurnAndQueueInput, replaceTranscriptRows, replaceUserPeopleIndex, requireXopcDatabase, resetSessionRecord, resetXopcDatabaseSingletonForTest, resolveMigrationsDir, resolveSessionAgentId, resolveXopcDatabasePath, restoreBeforeCompactionBoundary, reviseCollaborationRule, reviseUnderstanding, revokeEndpointPrincipal, runSqliteWriteTransaction, searchActiveUnderstandings, searchMemoryRecords, searchSessionTranscript, sessionConfigRowToConfig, sessionRowToMetadata, setCollaborationRuleStatus, setConnectorLearningPaused, setInteractionState, setKnowledgeConsumerWatermark, setKnowledgeSourceCursor, setKnowledgeSourceItemSynthesisStatus, setMemoryProviderState, setMemoryRecordStatus, setMemoryTurnFeedback, setSessionConfig, setSessionInputStatus, setSessionTaskPlan, setUnderstandingStatus, setUserTrustPolicy, startContextConsolidationRun, startEndpointToolInvocationAudit, startKnowledgeSyncRun, summarizeMemoryRecallFeedback, summarizeUnderstandingFeedback, summarizeUserPeople, summarizeUserUnderstandingQuality, touchEndpointPrincipal, transcriptEntryRowToStoredRow, updateConnectorLearningJob, updateInteractionStateFromMessage, updateRelationshipSettings, updateSessionConfig, updateSessionStats, updateUserPerson, updateUserProfile, upsertConnectorActionMetadata, upsertConnectorCatalogEntry, upsertConnectorConnection, upsertConnectorInstallation, upsertConnectorSyncPolicy, upsertKnowledgeSourceItems, upsertMemoryRecord, upsertNoteAgentContextRecord, upsertNoteRecord, validateLatestSessionTurnTarget };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
CREATE TABLE user_people (
|
|
2
|
+
person_id TEXT PRIMARY KEY,
|
|
3
|
+
principal_id TEXT NOT NULL,
|
|
4
|
+
display_name TEXT NOT NULL,
|
|
5
|
+
user_display_name TEXT,
|
|
6
|
+
inferred_kind TEXT NOT NULL CHECK (inferred_kind IN ('person', 'bot', 'service', 'group', 'unknown')),
|
|
7
|
+
user_kind TEXT CHECK (user_kind IS NULL OR user_kind IN ('person', 'bot', 'service', 'group', 'unknown')),
|
|
8
|
+
hidden INTEGER NOT NULL DEFAULT 0 CHECK (hidden IN (0, 1)),
|
|
9
|
+
merged_into_person_id TEXT REFERENCES user_people(person_id) ON DELETE SET NULL,
|
|
10
|
+
confidence REAL NOT NULL CHECK (confidence >= 0 AND confidence <= 1),
|
|
11
|
+
first_observed_at INTEGER NOT NULL,
|
|
12
|
+
last_observed_at INTEGER NOT NULL,
|
|
13
|
+
created_at INTEGER NOT NULL,
|
|
14
|
+
updated_at INTEGER NOT NULL
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE INDEX idx_user_people_principal_kind
|
|
18
|
+
ON user_people(principal_id, inferred_kind, last_observed_at DESC);
|
|
19
|
+
CREATE INDEX idx_user_people_merge_target
|
|
20
|
+
ON user_people(merged_into_person_id);
|
|
21
|
+
|
|
22
|
+
CREATE TABLE user_person_handles (
|
|
23
|
+
handle_id TEXT PRIMARY KEY,
|
|
24
|
+
person_id TEXT NOT NULL REFERENCES user_people(person_id) ON DELETE CASCADE,
|
|
25
|
+
handle_type TEXT NOT NULL CHECK (handle_type IN ('email', 'provider_user', 'username', 'display_name')),
|
|
26
|
+
normalized_value TEXT NOT NULL,
|
|
27
|
+
display_value TEXT NOT NULL,
|
|
28
|
+
source_instance_id TEXT NOT NULL,
|
|
29
|
+
verification TEXT NOT NULL CHECK (verification IN ('observed', 'inferred', 'user_confirmed')),
|
|
30
|
+
first_observed_at INTEGER NOT NULL,
|
|
31
|
+
last_observed_at INTEGER NOT NULL,
|
|
32
|
+
created_at INTEGER NOT NULL,
|
|
33
|
+
updated_at INTEGER NOT NULL,
|
|
34
|
+
UNIQUE(handle_type, normalized_value, source_instance_id)
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
CREATE INDEX idx_user_person_handles_person ON user_person_handles(person_id);
|
|
38
|
+
CREATE INDEX idx_user_person_handles_lookup ON user_person_handles(handle_type, normalized_value);
|
|
39
|
+
|
|
40
|
+
CREATE TABLE user_person_source_stats (
|
|
41
|
+
person_id TEXT NOT NULL REFERENCES user_people(person_id) ON DELETE CASCADE,
|
|
42
|
+
source_instance_id TEXT NOT NULL,
|
|
43
|
+
interaction_count INTEGER NOT NULL CHECK (interaction_count >= 0),
|
|
44
|
+
first_observed_at INTEGER NOT NULL,
|
|
45
|
+
last_observed_at INTEGER NOT NULL,
|
|
46
|
+
last_source_item_id TEXT,
|
|
47
|
+
updated_at INTEGER NOT NULL,
|
|
48
|
+
PRIMARY KEY(person_id, source_instance_id)
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
CREATE INDEX idx_user_person_source_stats_source
|
|
52
|
+
ON user_person_source_stats(source_instance_id, last_observed_at DESC);
|
|
53
|
+
|
|
54
|
+
CREATE TABLE user_people_index_state (
|
|
55
|
+
principal_id TEXT PRIMARY KEY,
|
|
56
|
+
source_change_sequence INTEGER NOT NULL,
|
|
57
|
+
source_grants_updated_at INTEGER NOT NULL,
|
|
58
|
+
rebuilt_at INTEGER NOT NULL
|
|
59
|
+
);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
CREATE TABLE notification_devices (
|
|
2
|
+
device_id TEXT PRIMARY KEY,
|
|
3
|
+
platform TEXT NOT NULL CHECK (platform IN ('ios', 'android')),
|
|
4
|
+
push_token TEXT NOT NULL,
|
|
5
|
+
push_provider TEXT NOT NULL DEFAULT 'expo',
|
|
6
|
+
enabled INTEGER NOT NULL DEFAULT 1 CHECK (enabled IN (0, 1)),
|
|
7
|
+
permissions TEXT NOT NULL DEFAULT 'unknown' CHECK (permissions IN ('granted', 'denied', 'unknown')),
|
|
8
|
+
preferences_json TEXT NOT NULL DEFAULT '{}',
|
|
9
|
+
locale TEXT NOT NULL DEFAULT 'en' CHECK (locale IN ('en', 'zh')),
|
|
10
|
+
app_version TEXT,
|
|
11
|
+
lease_expires_at INTEGER NOT NULL,
|
|
12
|
+
last_seen_at INTEGER NOT NULL,
|
|
13
|
+
created_at INTEGER NOT NULL,
|
|
14
|
+
updated_at INTEGER NOT NULL
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
INSERT INTO notification_devices (
|
|
18
|
+
device_id, platform, push_token, push_provider, enabled, permissions,
|
|
19
|
+
preferences_json, locale, app_version, lease_expires_at,
|
|
20
|
+
last_seen_at, created_at, updated_at
|
|
21
|
+
)
|
|
22
|
+
SELECT
|
|
23
|
+
device_id, platform, push_token, push_provider, enabled, permissions,
|
|
24
|
+
preferences_json, 'en', app_version,
|
|
25
|
+
(unixepoch() * 1000) + 604800000,
|
|
26
|
+
last_seen_at, created_at, updated_at
|
|
27
|
+
FROM mobile_devices;
|
|
28
|
+
|
|
29
|
+
CREATE UNIQUE INDEX idx_notification_devices_push_token
|
|
30
|
+
ON notification_devices(push_provider, push_token);
|
|
31
|
+
CREATE INDEX idx_notification_devices_delivery
|
|
32
|
+
ON notification_devices(enabled, permissions, lease_expires_at);
|
|
33
|
+
|
|
34
|
+
CREATE TABLE notification_events (
|
|
35
|
+
event_id TEXT PRIMARY KEY,
|
|
36
|
+
dedupe_key TEXT NOT NULL UNIQUE,
|
|
37
|
+
event_type TEXT NOT NULL,
|
|
38
|
+
target_json TEXT NOT NULL,
|
|
39
|
+
priority TEXT NOT NULL CHECK (priority IN ('normal', 'high')),
|
|
40
|
+
title_en TEXT NOT NULL,
|
|
41
|
+
title_zh TEXT NOT NULL,
|
|
42
|
+
body_en TEXT,
|
|
43
|
+
body_zh TEXT,
|
|
44
|
+
payload_json TEXT NOT NULL DEFAULT '{}',
|
|
45
|
+
created_at INTEGER NOT NULL
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
CREATE INDEX idx_notification_events_created
|
|
49
|
+
ON notification_events(created_at, event_id);
|
|
50
|
+
|
|
51
|
+
CREATE TABLE notification_deliveries (
|
|
52
|
+
event_id TEXT NOT NULL,
|
|
53
|
+
device_id TEXT NOT NULL,
|
|
54
|
+
status TEXT NOT NULL CHECK (status IN ('pending', 'accepted', 'delivered', 'dead')),
|
|
55
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
56
|
+
next_attempt_at INTEGER NOT NULL,
|
|
57
|
+
provider_ticket_id TEXT,
|
|
58
|
+
last_error TEXT,
|
|
59
|
+
updated_at INTEGER NOT NULL,
|
|
60
|
+
PRIMARY KEY (event_id, device_id),
|
|
61
|
+
FOREIGN KEY (event_id) REFERENCES notification_events(event_id) ON DELETE CASCADE,
|
|
62
|
+
FOREIGN KEY (device_id) REFERENCES notification_devices(device_id) ON DELETE CASCADE
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
CREATE INDEX idx_notification_deliveries_due
|
|
66
|
+
ON notification_deliveries(status, next_attempt_at);
|
|
67
|
+
|
|
68
|
+
CREATE TABLE notification_acknowledgements (
|
|
69
|
+
event_id TEXT NOT NULL,
|
|
70
|
+
consumer_id TEXT NOT NULL,
|
|
71
|
+
surface TEXT NOT NULL CHECK (surface IN ('web', 'electron', 'mobile')),
|
|
72
|
+
acknowledged_at INTEGER NOT NULL,
|
|
73
|
+
PRIMARY KEY (event_id, consumer_id),
|
|
74
|
+
FOREIGN KEY (event_id) REFERENCES notification_events(event_id) ON DELETE CASCADE
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
DROP TABLE mobile_activity_acknowledgements;
|
|
78
|
+
DROP TABLE mobile_activity_events;
|
|
79
|
+
DROP TABLE mobile_devices;
|
|
@@ -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 = 136;
|
|
7
7
|
export declare function resolveMigrationsDir(override?: string): string;
|
|
8
8
|
/**
|
|
9
9
|
* Apply sequential SQL migrations from (currentVersion + 1) through targetVersion.
|