@xopcai/xopc 0.0.227 → 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-BevwE16n.js → activity-store-M0nAY5XB.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BggVQrEZ.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-Bx_BpIt8.js → api-BywYxpaS.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BtKP9n2r.js → app-management-settings-panel--SjycrXk.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BoH2NAUX.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-DnceUyxm.js → archive-plugin-7_DXaMTP.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Bh8_9gkr.js → attachment-load-Bx44zSpz.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-ZKeAAVxD.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-Cy9er6w-.js → binary-plugins-DjDwnHAQ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Cc0wWvNX.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-BS7rpLLl.js → browser-workflow-inputs-8NC2qDRF.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-BdBVUZXm.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-D1Lqz0Tt.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-CGuEl-l2.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-CdX_7aQh.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-BnSQc4Ek.js → cron-expression-D8-c-Tkw.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-BbuG7zQ_.js → date-picker-kV-Jyl9J.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-snZeqOmG.js → dependency-picker-CwKcrfGj.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DJQ8JoR1.js → desktop-pet-D9rnchu3.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-B9txsRtv.js → desktop-pet-settings-CTs5WGzk.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-D7WKWkNB.js → directory-picker-path-field-CCl0aaDm.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-D_7cOCj2.js → extension-debug-page-Cau40SvC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Bwu47iUb.js → extension-page-BsJXdvIL.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-Dwg4dSZM.js → extension-settings-page-qWqJyF7-.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-jURUSte_.js → gateway-config-api-BI0SELXm.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-6SQXF1yR.js → gateway-config-swr-BWGjnmDl.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-UklJOMLX.js → gateway-settings-6ZdOIC7F.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DqWaxyvZ.js → gateway-startup-retry-B_zrtccP.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-Djs_nduD.js → heartbeat-settings-KBwhXeFD.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-BA2M4CLi.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-Bxmt6LEr.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-ByVsCH3d.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-D19R-xsz.js → local-apps-page-BCXa0oUa.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-Ci1Qi0Q-.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-G0y7zmfY.js → management-settings-tHnlfOAQ.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-B69d2HWt.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-6TWEQgN_.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-DLsnnZCS.js → notes-api-BFsOGYkd.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-CkRJJKDm.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-HxArIvoN.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-lEar5FOV.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-Bf03UNGD.js → runtime-tools-settings-panel-BPEGTip5.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CIXMBgx5.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-DgdB26mE.js → settings-form-section-ChXh3Bwk.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-efk5W6lG.js → settings-loading-skeleton-BCAUqIe2.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BHVf4gEP.js → settings-page-D25W9Okr.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-WK0dGNMv.js → setup-status-panel-DsN7Z4Fl.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-Cod-w2qm.js → share-preview-page-CRFnUaNb.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-CUqQ31gt.js → shares-settings-CAX0eNaP.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-Doy1gghe.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-DwCcipqK.js → skills-page-Cl7jjTK7.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-3WSbtl3S.js → skills-page.utils-BiCl4nb5.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-C5VxqC_s.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-Dd89g_ki.js → theme-store-DOdCjyuw.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-CeV8VJh2.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-EmJ-8aZu.js → voice-api-key-field-BDNexlVR.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-zsk6E3Mi.js → work-discovery-overlay-BHTfeaWL.js} +1 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-Cf_w-NZy.js +3 -0
- 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/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/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/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/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/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/hono/lib/static-ui.js +7 -5
- 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/sessions.js +31 -0
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- 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/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/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/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 +1 -1
- package/dist/src/storage/sqlite/index.js +2 -2
- 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/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/package.json +2 -2
- package/dist/gateway/static/root/assets/agents-TJpjRHnr.js +0 -68
- package/dist/gateway/static/root/assets/apps-page-CZ4Da51l.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-2Y00PvJU.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CbJD27_j.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-Dv8y6OuP.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-TZmjzWzt.js +0 -3
- package/dist/gateway/static/root/assets/channels-settings-g-68dutA.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-D7KsAeWh.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DXA0rAvQ.js +0 -2
- package/dist/gateway/static/root/assets/home-page-i6bXCHdo.js +0 -1
- package/dist/gateway/static/root/assets/index-BBBE89vm.css +0 -2
- package/dist/gateway/static/root/assets/index-BsD5wygl.js +0 -74
- package/dist/gateway/static/root/assets/local-app-workbench-page-BCKEDMlP.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-Cy9YQK7j.js +0 -2
- package/dist/gateway/static/root/assets/markdown-view-CBM-v2ph.js +0 -69
- package/dist/gateway/static/root/assets/mermaid-render-BbqDc_LQ.js +0 -134
- package/dist/gateway/static/root/assets/messages-CtOJwGW3.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-B10T3hGX.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-DsqRlgsy.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-Bu2PN8OK.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CXACdJ2f.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CS2knWDT.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-ByFGk0q_.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DweAPjI8.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-DEj-BFMP.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-f7yh7aD5.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-CBAYvm3G.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-BN0JmHrG.js +0 -5
- 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,132 +0,0 @@
|
|
|
1
|
-
import { getSqliteDatabase, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
|
-
import { DEFAULT_MOBILE_NOTIFICATION_PREFERENCES } from "./notification-types.js";
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
-
//#region src/mobile/notification-store.ts
|
|
5
|
-
function parseJson(raw, fallback) {
|
|
6
|
-
try {
|
|
7
|
-
return JSON.parse(raw);
|
|
8
|
-
} catch {
|
|
9
|
-
return fallback;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
function normalizePreferences(input) {
|
|
13
|
-
return {
|
|
14
|
-
needsInput: input?.needsInput ?? DEFAULT_MOBILE_NOTIFICATION_PREFERENCES.needsInput,
|
|
15
|
-
failed: input?.failed ?? DEFAULT_MOBILE_NOTIFICATION_PREFERENCES.failed,
|
|
16
|
-
completed: input?.completed ?? DEFAULT_MOBILE_NOTIFICATION_PREFERENCES.completed,
|
|
17
|
-
automationFailed: input?.automationFailed ?? DEFAULT_MOBILE_NOTIFICATION_PREFERENCES.automationFailed
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function deviceFromRow(row) {
|
|
21
|
-
return {
|
|
22
|
-
id: row.device_id,
|
|
23
|
-
platform: row.platform === "android" ? "android" : "ios",
|
|
24
|
-
pushToken: row.push_token,
|
|
25
|
-
enabled: row.enabled !== 0,
|
|
26
|
-
permissions: row.permissions === "granted" || row.permissions === "denied" ? row.permissions : "unknown",
|
|
27
|
-
preferences: normalizePreferences(parseJson(row.preferences_json, {})),
|
|
28
|
-
appVersion: row.app_version ?? void 0,
|
|
29
|
-
lastSeenAt: row.last_seen_at,
|
|
30
|
-
createdAt: row.created_at,
|
|
31
|
-
updatedAt: row.updated_at
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
function activityFromRow(row) {
|
|
35
|
-
return {
|
|
36
|
-
id: row.event_id,
|
|
37
|
-
type: row.event_type,
|
|
38
|
-
entity: {
|
|
39
|
-
kind: row.entity_kind,
|
|
40
|
-
id: row.entity_id
|
|
41
|
-
},
|
|
42
|
-
priority: row.priority,
|
|
43
|
-
title: row.title,
|
|
44
|
-
body: row.body ?? void 0,
|
|
45
|
-
deepLink: row.deep_link,
|
|
46
|
-
payload: parseJson(row.payload_json, {}),
|
|
47
|
-
createdAt: row.created_at
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function registerMobileDevice(input) {
|
|
51
|
-
const now = Date.now();
|
|
52
|
-
const preferences = input.preferences ? normalizePreferences(input.preferences) : getMobileDevice(input.id)?.preferences ?? normalizePreferences();
|
|
53
|
-
runSqliteWriteTransaction((db) => {
|
|
54
|
-
db.prepare(`DELETE FROM mobile_devices
|
|
55
|
-
WHERE push_provider = 'expo' AND push_token = ? AND device_id <> ?`).run(input.pushToken, input.id);
|
|
56
|
-
db.prepare(`INSERT INTO mobile_devices (
|
|
57
|
-
device_id, platform, push_token, permissions, preferences_json,
|
|
58
|
-
app_version, last_seen_at, created_at, updated_at
|
|
59
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
60
|
-
ON CONFLICT(device_id) DO UPDATE SET
|
|
61
|
-
platform = excluded.platform,
|
|
62
|
-
push_token = excluded.push_token,
|
|
63
|
-
enabled = 1,
|
|
64
|
-
permissions = excluded.permissions,
|
|
65
|
-
preferences_json = excluded.preferences_json,
|
|
66
|
-
app_version = excluded.app_version,
|
|
67
|
-
last_seen_at = excluded.last_seen_at,
|
|
68
|
-
updated_at = excluded.updated_at`).run(input.id, input.platform, input.pushToken, input.permissions, JSON.stringify(preferences), input.appVersion?.trim() || null, now, now, now);
|
|
69
|
-
});
|
|
70
|
-
return getMobileDevice(input.id);
|
|
71
|
-
}
|
|
72
|
-
function getMobileDevice(deviceId) {
|
|
73
|
-
const row = getSqliteDatabase().prepare(`SELECT * FROM mobile_devices WHERE device_id = ?`).get(deviceId);
|
|
74
|
-
return row ? deviceFromRow(row) : null;
|
|
75
|
-
}
|
|
76
|
-
function listEnabledMobileDevices() {
|
|
77
|
-
return getSqliteDatabase().prepare(`SELECT * FROM mobile_devices WHERE enabled = 1 AND permissions = 'granted' ORDER BY updated_at DESC`).all().map(deviceFromRow);
|
|
78
|
-
}
|
|
79
|
-
function updateMobileDevicePreferences(deviceId, patch) {
|
|
80
|
-
const current = getMobileDevice(deviceId);
|
|
81
|
-
if (!current) return null;
|
|
82
|
-
const preferences = normalizePreferences({
|
|
83
|
-
...current.preferences,
|
|
84
|
-
...patch
|
|
85
|
-
});
|
|
86
|
-
runSqliteWriteTransaction((db) => {
|
|
87
|
-
db.prepare(`UPDATE mobile_devices SET preferences_json = ?, updated_at = ? WHERE device_id = ?`).run(JSON.stringify(preferences), Date.now(), deviceId);
|
|
88
|
-
});
|
|
89
|
-
return getMobileDevice(deviceId);
|
|
90
|
-
}
|
|
91
|
-
function removeMobileDevice(deviceId) {
|
|
92
|
-
return runSqliteWriteTransaction((db) => db.prepare(`DELETE FROM mobile_devices WHERE device_id = ?`).run(deviceId).changes > 0);
|
|
93
|
-
}
|
|
94
|
-
function disableMobileDeviceForPushToken(pushToken) {
|
|
95
|
-
runSqliteWriteTransaction((db) => {
|
|
96
|
-
db.prepare(`UPDATE mobile_devices SET enabled = 0, updated_at = ? WHERE push_token = ?`).run(Date.now(), pushToken);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
function createMobileActivityEvent(input) {
|
|
100
|
-
const event = {
|
|
101
|
-
...input,
|
|
102
|
-
id: input.id ?? randomUUID(),
|
|
103
|
-
createdAt: input.createdAt ?? Date.now()
|
|
104
|
-
};
|
|
105
|
-
runSqliteWriteTransaction((db) => {
|
|
106
|
-
db.prepare(`INSERT INTO mobile_activity_events (
|
|
107
|
-
event_id, event_type, entity_kind, entity_id, priority, title, body,
|
|
108
|
-
deep_link, payload_json, created_at
|
|
109
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(event.id, event.type, event.entity.kind, event.entity.id, event.priority, event.title, event.body ?? null, event.deepLink, JSON.stringify(event.payload), event.createdAt);
|
|
110
|
-
});
|
|
111
|
-
return event;
|
|
112
|
-
}
|
|
113
|
-
function listMobileActivityEvents(options) {
|
|
114
|
-
const limit = Math.max(1, Math.min(100, options?.limit ?? 50));
|
|
115
|
-
const cursor = options?.cursor;
|
|
116
|
-
const items = (cursor == null ? getSqliteDatabase().prepare(`SELECT * FROM mobile_activity_events ORDER BY created_at DESC LIMIT ?`).all(limit) : getSqliteDatabase().prepare(`SELECT * FROM mobile_activity_events WHERE created_at < ? ORDER BY created_at DESC LIMIT ?`).all(cursor, limit)).map(activityFromRow);
|
|
117
|
-
return {
|
|
118
|
-
items,
|
|
119
|
-
nextCursor: items.length === limit ? items[items.length - 1].createdAt : null
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
function acknowledgeMobileActivityEvent(eventId, deviceId) {
|
|
123
|
-
if (!getMobileDevice(deviceId)) return false;
|
|
124
|
-
if (!getSqliteDatabase().prepare(`SELECT 1 FROM mobile_activity_events WHERE event_id = ?`).get(eventId)) return false;
|
|
125
|
-
runSqliteWriteTransaction((db) => {
|
|
126
|
-
db.prepare(`INSERT OR REPLACE INTO mobile_activity_acknowledgements (event_id, device_id, acknowledged_at)
|
|
127
|
-
VALUES (?, ?, ?)`).run(eventId, deviceId, Date.now());
|
|
128
|
-
});
|
|
129
|
-
return true;
|
|
130
|
-
}
|
|
131
|
-
//#endregion
|
|
132
|
-
export { acknowledgeMobileActivityEvent, createMobileActivityEvent, disableMobileDeviceForPushToken, getMobileDevice, listEnabledMobileDevices, listMobileActivityEvents, registerMobileDevice, removeMobileDevice, updateMobileDevicePreferences };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export type MobilePlatform = 'ios' | 'android';
|
|
2
|
-
export type MobileNotificationPermission = 'granted' | 'denied' | 'unknown';
|
|
3
|
-
export type MobileNotificationPriority = 'normal' | 'high';
|
|
4
|
-
export type MobileNotificationEventType = 'task.needs_input' | 'task.blocked' | 'task.completed' | 'automation.failed' | 'automation.completed' | 'proactive.insight';
|
|
5
|
-
export type MobileNotificationPreferences = {
|
|
6
|
-
needsInput: boolean;
|
|
7
|
-
failed: boolean;
|
|
8
|
-
completed: boolean;
|
|
9
|
-
automationFailed: boolean;
|
|
10
|
-
};
|
|
11
|
-
export type MobileDevice = {
|
|
12
|
-
id: string;
|
|
13
|
-
platform: MobilePlatform;
|
|
14
|
-
pushToken: string;
|
|
15
|
-
enabled: boolean;
|
|
16
|
-
permissions: MobileNotificationPermission;
|
|
17
|
-
preferences: MobileNotificationPreferences;
|
|
18
|
-
appVersion?: string;
|
|
19
|
-
lastSeenAt: number;
|
|
20
|
-
createdAt: number;
|
|
21
|
-
updatedAt: number;
|
|
22
|
-
};
|
|
23
|
-
export type MobileActivityEvent = {
|
|
24
|
-
id: string;
|
|
25
|
-
type: MobileNotificationEventType;
|
|
26
|
-
entity: {
|
|
27
|
-
kind: 'task' | 'automation' | 'insight';
|
|
28
|
-
id: string;
|
|
29
|
-
};
|
|
30
|
-
priority: MobileNotificationPriority;
|
|
31
|
-
title: string;
|
|
32
|
-
body?: string;
|
|
33
|
-
deepLink: string;
|
|
34
|
-
payload: Record<string, unknown>;
|
|
35
|
-
createdAt: number;
|
|
36
|
-
};
|
|
37
|
-
export declare const DEFAULT_MOBILE_NOTIFICATION_PREFERENCES: MobileNotificationPreferences;
|