@xopcai/xopc 0.0.484 → 0.0.486
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/src/inbound-processor.js +4 -6
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/messaging/process-message.js +2 -1
- package/dist/gateway/server/chunks.bin +1166 -1121
- package/dist/gateway/server/chunks.json +1 -1
- package/dist/gateway/static/root/assets/agent-run-error-parser-DsXmcKt-.js +1 -0
- package/dist/gateway/static/root/assets/{api-CGs641OT.js → api-CGrHK9ij.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-CH9wENBj.js → apps-page-6xeWvMpF.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-B1Ri4sh8.js → automations-page-BLFBqaPX.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-CNSza6ir.js → automations-workspace-DiO3Iyuj.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-abgigXV1.js → capabilities-CW-vdkz6.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-BaKHutgZ.js → capabilities-DZrjA95P.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-DQrfkrBA.js +2 -0
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-BOwbZn9X.js → capabilities-settings-panel-DIT2dvtc.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-DlnXbcOj.js → channels-Dcr5dgqw.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-page-LOR5JxDh.js → chat-page-DWZCzxY7.js} +31 -31
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DE8j-K9d.js → chat-terminal-dock-DCUuwiTt.js} +1 -1
- package/dist/gateway/static/root/assets/command-palette-api-UrqPvWR1.js +1 -0
- package/dist/gateway/static/root/assets/composer-payload-handoff-a0quQ25p.js +1 -0
- package/dist/gateway/static/root/assets/connected-providers-grid-BJKEp0SE.js +1 -0
- package/dist/gateway/static/root/assets/{connectors-page-BJm1jjct.js → connectors-page-BteRI1XM.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-D3X7SlzG.js → extension-debug-page-4jJ1uVQJ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-CIAq7PSn.js → extension-iframe-host-CJV5JETm.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-message-router-B2wbucV7.js → extension-message-router-B4I-Y6qs.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-qwY7r1_p.js → extension-page-lc7a84nG.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-DFcRbTHI.js → extension-provider-D8_mIBI0.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-Cpnh9lcZ.js → extension-settings-page-Uw2lfWRh.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-BusNFHe-.js → home-page-mSRCU81k.js} +4 -4
- package/dist/gateway/static/root/assets/{home-task-actions-C8Fi6GBq.js → home-task-actions-_ZAc57Y7.js} +1 -1
- package/dist/gateway/static/root/assets/{index-DE6GguFZ.js → index-CJAEAcZV.js} +7 -7
- package/dist/gateway/static/root/assets/{local-app-workbench-page-B9uSL1Mi.js → local-app-workbench-page-C3Lqi8E1.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-DXzfoiyk.js → note-detail-panel-uc-5k3a2.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-BNTgiHSk.js → notes-page-RPfvHnl6.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-BXSBeGms.js → page-context-capture-button-CVHz9b6c.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-D7zTHQ0K.js → personal-page-Dt1d3tQT.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-profile-settings-TcI0Zfwr.js → personal-profile-settings-XiT1MgTK.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-BJ46T7ZO.js → personal-settings-panel-bcw04REt.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-runtime-C1U57WSM.js → preview-runtime-FtWOW5i4.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-GA_YPLkr.js → product-automation-feedback-DdFoCDzG.js} +1 -1
- package/dist/gateway/static/root/assets/product-preview-content-B3mzl6-f.js +1 -0
- package/dist/gateway/static/root/assets/product-preview-modal-5kTp_7Qk.js +2 -0
- package/dist/gateway/static/root/assets/project-detail-page-DGPfKx5M.js +7 -0
- package/dist/gateway/static/root/assets/{projects-page-BHQxQGTd.js → projects-page-C-9x23LR.js} +1 -1
- package/dist/gateway/static/root/assets/route-preload-CzorjVc9.js +2 -0
- package/dist/gateway/static/root/assets/routine-panel-n4IstC8Y.js +2 -0
- package/dist/gateway/static/root/assets/session-manager-C2MCS4C5.js +28 -0
- package/dist/gateway/static/root/assets/{settings-page-BOzzOS6k.js → settings-page-DsM_f07M.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-Di5_ukH8.js → share-preview-page-C32Mq-BY.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-CirGM67m.js → shares-settings-BDGbs8wz.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-gGU0LZ5e.js → skills-page-kL8E5zgi.js} +1 -1
- package/dist/gateway/static/root/assets/space-page-DwyuUvI3.js +2 -0
- package/dist/gateway/static/root/assets/task-copy-CtcqCQ78.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-DdCpNW8K.js +3 -0
- package/dist/gateway/static/root/assets/{task-header-title-Cdgp2rCs.js → task-header-title-CLt_lmjb.js} +1 -1
- package/dist/gateway/static/root/assets/task-result-presentation-CgvcqEMD.js +1 -0
- package/dist/gateway/static/root/assets/task-run-issue-notice-8FX876PP.js +1 -0
- package/dist/gateway/static/root/assets/tasks-CvOAtEHv.js +1 -0
- package/dist/gateway/static/root/assets/turn-outcome-Dtw6OgwL.js +1 -0
- package/dist/gateway/static/root/assets/{use-composer-attachments-DJsIzJ1c.js → use-composer-attachments-BEuyorVm.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-BFF2vXm5.js → use-file-preview-expanded-Cehu0745.js} +1 -1
- package/dist/gateway/static/root/assets/use-personal-work-B25WRGHj.js +1 -0
- package/dist/gateway/static/root/assets/{use-realtime-voice-9OvLwHzk.js → use-realtime-voice-CV3GIt_T.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-LCIT1H-D.js → use-workspace-tree-C0C861cb.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-settings-j8o-hGTm.js → voice-settings-JpPo3BvX.js} +1 -1
- package/dist/gateway/static/root/assets/workspace-api-CQOuWbVv.js +2 -0
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-DwVWTehC.js → workspace-file-preview-dialog-CmMueTmW.js} +1 -1
- package/dist/gateway/static/root/index.html +30 -28
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/index.js +3 -1
- package/dist/packages/gateway-contract/src/notifications.js +1 -8
- package/dist/packages/gateway-contract/src/task-display.js +9 -2
- package/dist/packages/gateway-contract/src/task-lifecycle.js +1 -0
- package/dist/packages/gateway-contract/src/task-research-result.js +2 -1
- package/dist/packages/gateway-contract/src/tasks.js +6 -1
- package/dist/packages/gateway-contract/src/user-message-text.js +64 -0
- package/dist/src/agent/embedded/run-for-session.js +27 -28
- package/dist/src/agent/embedded/session-runner.js +14 -1
- package/dist/src/agent/fallback/candidates.d.ts +1 -0
- package/dist/src/agent/fallback/candidates.js +1 -1
- package/dist/src/agent/image/generation/provider-registry.js +3 -1
- package/dist/src/agent/mcp/connection-drafts.d.ts +3 -1
- package/dist/src/agent/mcp/connection-drafts.js +24 -11
- package/dist/src/agent/mcp/connection-setup.js +13 -10
- package/dist/src/agent/mcp/native-mcp.js +1 -0
- package/dist/src/agent/mcp/network-policy.d.ts +6 -0
- package/dist/src/agent/mcp/network-policy.js +49 -0
- package/dist/src/agent/mcp/transport.js +14 -7
- package/dist/src/agent/messaging/message-router.js +2 -2
- package/dist/src/agent/models/manager.d.ts +1 -1
- package/dist/src/agent/models/manager.js +2 -1
- package/dist/src/agent/models/turn-candidates.d.ts +16 -0
- package/dist/src/agent/models/turn-candidates.js +55 -0
- package/dist/src/agent/service/direct-turn-helpers.js +9 -24
- package/dist/src/agent/service.d.ts +1 -0
- package/dist/src/agent/service.js +12 -0
- package/dist/src/agent/skills/installer.js +2 -2
- package/dist/src/auth/credentials.js +3 -1
- package/dist/src/auth/oauth/index.d.ts +0 -1
- package/dist/src/auth/oauth/index.js +1 -4
- package/dist/src/auth/oauth/registry.js +0 -4
- package/dist/src/auth/oauth/xopc-cloud.js +1 -1
- package/dist/src/chat-commands/command-parse.d.ts +1 -0
- package/dist/src/chat-commands/command-parse.js +8 -10
- package/dist/src/chat-commands/registry.d.ts +5 -0
- package/dist/src/chat-commands/registry.js +8 -0
- package/dist/src/cli/command-manifest.js +1 -1
- package/dist/src/cli/commands/auth.js +4 -2
- package/dist/src/cli/commands/models.js +12 -10
- package/dist/src/config/models-json.js +1 -2
- package/dist/src/config/schema.d.ts +54 -4
- package/dist/src/config/schema.js +3 -1
- package/dist/src/gateway/agent-reactions/reaction.d.ts +1 -2
- package/dist/src/gateway/agent-reactions/reaction.js +10 -21
- package/dist/src/gateway/custom-image-providers.js +4 -1
- package/dist/src/gateway/hono/oauth.js +3 -0
- package/dist/src/gateway/hono/routes/device-push.js +55 -15
- package/dist/src/gateway/hono/routes/mobile-capability-panels.d.ts +67 -0
- package/dist/src/gateway/hono/routes/mobile-capability-panels.js +16 -131
- package/dist/src/gateway/hono/routes/mobile-mcp-setup.d.ts +9 -0
- package/dist/src/gateway/hono/routes/mobile-mcp-setup.js +949 -0
- package/dist/src/gateway/hono/routes/notifications.js +12 -1
- package/dist/src/gateway/hono/routes/session-command-handler.js +1 -4
- package/dist/src/gateway/hono/routes/session-input-handler.js +1 -4
- package/dist/src/gateway/hono/routes/sessions.js +1 -13
- package/dist/src/gateway/next-turn-suggestions/generator.js +16 -2
- package/dist/src/gateway/next-turn-suggestions/service.d.ts +2 -1
- package/dist/src/gateway/next-turn-suggestions/service.js +17 -5
- package/dist/src/gateway/next-turn-suggestions/snapshot.d.ts +11 -0
- package/dist/src/gateway/next-turn-suggestions/snapshot.js +31 -2
- package/dist/src/gateway/security/gateway-scopes.js +1 -0
- package/dist/src/gateway/service/config-coordinator.d.ts +14 -1
- package/dist/src/gateway/service/run-gateway-agent.js +2 -13
- package/dist/src/gateway/service.js +80 -60
- package/dist/src/local-apps/capabilities/projections.d.ts +5 -5
- package/dist/src/media/generation-changes.d.ts +4 -0
- package/dist/src/media/generation-changes.js +37 -0
- package/dist/src/music-generation/repository.js +12 -6
- package/dist/src/notifications/device-store.d.ts +3 -0
- package/dist/src/notifications/device-store.js +14 -1
- package/dist/src/notifications/platform-push.d.ts +17 -0
- package/dist/src/notifications/platform-push.js +58 -0
- package/dist/src/notifications/service.d.ts +2 -2
- package/dist/src/notifications/service.js +26 -12
- package/dist/src/notifications/store.d.ts +1 -1
- package/dist/src/notifications/store.js +3 -2
- package/dist/src/providers/env-keys.js +0 -1
- package/dist/src/providers/index.js +1 -7
- package/dist/src/providers/model-catalog-sync-service.js +3 -1
- package/dist/src/providers/model-registry.js +6 -2
- package/dist/src/providers/presentation.js +1 -2
- package/dist/src/providers/provider-policy.js +2 -1
- package/dist/src/session/client-history.js +3 -3
- package/dist/src/session/reset-triggers.js +1 -1
- package/dist/src/session/user-message-display.js +3 -2
- package/dist/src/storage/sqlite/agent-reaction-repository.d.ts +2 -4
- package/dist/src/storage/sqlite/agent-reaction-repository.js +18 -13
- package/dist/src/storage/sqlite/device-access-repository.js +2 -1
- package/dist/src/tasks/capabilities/write.d.ts +2 -0
- package/dist/src/tasks/home-query-service.js +2 -1
- package/dist/src/tasks/task-contract-planner.js +1 -0
- package/dist/src/tasks/task-conversation-summary.d.ts +1 -1
- package/dist/src/tasks/task-delivery-checks.d.ts +12 -0
- package/dist/src/tasks/task-delivery-checks.js +91 -0
- package/dist/src/tasks/task-final-reply.d.ts +3 -1
- package/dist/src/tasks/task-final-reply.js +17 -4
- package/dist/src/tasks/task-model-call.js +4 -2
- package/dist/src/tasks/task-origin-repository.d.ts +1 -1
- package/dist/src/tasks/task-read-model-projector.js +24 -7
- package/dist/src/tasks/task-research-result.js +12 -27
- package/dist/src/tasks/task-result-delivery-repository.js +3 -2
- package/dist/src/tasks/task-retry-service.js +2 -1
- package/dist/src/tasks/task-run-coordinator.js +14 -4
- package/dist/src/tasks/task-run-dispatcher.d.ts +1 -0
- package/dist/src/tasks/task-run-dispatcher.js +78 -48
- package/dist/src/tasks/task-run-repository.js +1 -1
- package/dist/src/tui/tui-commands.d.ts +2 -1
- package/dist/src/tui/tui-commands.js +3 -3
- package/dist/src/tui/tui-submit.d.ts +1 -1
- package/dist/src/tui/tui-submit.js +2 -4
- package/dist/src/video-generation/drafts.js +2 -0
- package/dist/src/video-generation/repository.js +13 -6
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-EENl65YY.js +0 -2
- package/dist/gateway/static/root/assets/command-palette-api-YP0zV_Ol.js +0 -1
- package/dist/gateway/static/root/assets/composer-payload-handoff-ClWsunJ2.js +0 -1
- package/dist/gateway/static/root/assets/connected-providers-grid-BgW-ioIt.js +0 -1
- package/dist/gateway/static/root/assets/product-preview-content-BOq3gtSJ.js +0 -1
- package/dist/gateway/static/root/assets/product-preview-modal-DIh_CsXp.js +0 -2
- package/dist/gateway/static/root/assets/project-detail-page-Dgs8ImMC.js +0 -7
- package/dist/gateway/static/root/assets/route-preload-7WVrzJca.js +0 -2
- package/dist/gateway/static/root/assets/routine-panel-Bfbiz0IN.js +0 -2
- package/dist/gateway/static/root/assets/session-manager-DUWeBdeG.js +0 -28
- package/dist/gateway/static/root/assets/space-page-CKVuhV2i.js +0 -2
- package/dist/gateway/static/root/assets/task-detail-page-DEpYIaok.js +0 -3
- package/dist/gateway/static/root/assets/task-run-issue-notice-CGrUMy0s.js +0 -1
- package/dist/gateway/static/root/assets/tasks-CwyNaa-j.js +0 -1
- package/dist/gateway/static/root/assets/turn-outcome-BSbEJx8h.js +0 -1
- package/dist/gateway/static/root/assets/use-personal-work-Dd2jRUpz.js +0 -1
- package/dist/gateway/static/root/assets/workspace-api-BuNWyNvA.js +0 -2
- package/dist/src/auth/oauth/google-antigravity.d.ts +0 -4
- package/dist/src/auth/oauth/google-antigravity.js +0 -9
- package/dist/src/auth/oauth/google-oauth/google-antigravity.d.ts +0 -25
- package/dist/src/auth/oauth/google-oauth/google-antigravity.js +0 -309
- package/dist/src/notifications/harmony-push.d.ts +0 -27
- package/dist/src/notifications/harmony-push.js +0 -96
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createLogger } from "../utils/logger/index.js";
|
|
2
|
+
import { init_logger } from "../utils/logger.js";
|
|
3
|
+
import { afterSqliteCommit, init_transaction } from "../storage/sqlite/transaction.js";
|
|
4
|
+
//#region src/media/generation-changes.ts
|
|
5
|
+
init_transaction();
|
|
6
|
+
init_logger();
|
|
7
|
+
const log = createLogger("MediaGeneration");
|
|
8
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
9
|
+
function mediaGenerationPhase(state) {
|
|
10
|
+
switch (state) {
|
|
11
|
+
case "completed":
|
|
12
|
+
case "failed":
|
|
13
|
+
case "submission_unknown": return state;
|
|
14
|
+
default: return "pending";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function onMediaGenerationChanged(listener) {
|
|
18
|
+
listeners.add(listener);
|
|
19
|
+
return () => {
|
|
20
|
+
listeners.delete(listener);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function notifyMediaGenerationAfterCommit(conversationId, transcriptId) {
|
|
24
|
+
afterSqliteCommit(() => {
|
|
25
|
+
for (const listener of listeners) try {
|
|
26
|
+
listener(conversationId, transcriptId);
|
|
27
|
+
} catch (err) {
|
|
28
|
+
log.error({
|
|
29
|
+
err,
|
|
30
|
+
conversationId,
|
|
31
|
+
transcriptId
|
|
32
|
+
}, "Media generation change listener failed");
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { mediaGenerationPhase, notifyMediaGenerationAfterCommit, onMediaGenerationChanged };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../storage/sqlite/transaction.js";
|
|
2
2
|
import { archiveSpaceGeneratedMedia } from "../space/ingest.js";
|
|
3
|
+
import { mediaGenerationPhase, notifyMediaGenerationAfterCommit } from "../media/generation-changes.js";
|
|
3
4
|
import { configuredMusicModel } from "./providers.js";
|
|
4
5
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
6
|
//#region src/music-generation/repository.ts
|
|
@@ -76,15 +77,17 @@ async function enqueueMusicJob(conversationId, transcriptId, toolCallId, request
|
|
|
76
77
|
db.prepare(`INSERT INTO music_generation_jobs (id, conversation_id, transcript_id, work_id, parent_id, version_number, model_ref,
|
|
77
78
|
request_hash, title, mode, prompt, lyrics, state, next_attempt_at, created_at)
|
|
78
79
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'queued', ?, ?)`).run(id, conversationId, transcriptId, workId, parent?.id ?? null, version, route.ref, hash, title, mode, prompt, lyrics, now, now);
|
|
80
|
+
notifyMediaGenerationAfterCommit(conversationId, transcriptId);
|
|
79
81
|
return { job: publicMusicJob(getMusicJob(conversationId, id)) };
|
|
80
82
|
});
|
|
81
83
|
}
|
|
82
84
|
function claimMusicJob() {
|
|
83
85
|
return runSqliteWriteTransaction((db) => {
|
|
84
86
|
const now = Date.now();
|
|
85
|
-
db.prepare(`UPDATE music_generation_jobs SET state = 'submission_unknown', error = NULL, error_code = NULL,
|
|
87
|
+
const expired = db.prepare(`UPDATE music_generation_jobs SET state = 'submission_unknown', error = NULL, error_code = NULL,
|
|
86
88
|
lease_token = NULL, lease_until = NULL
|
|
87
|
-
WHERE state = 'submitting' AND lease_until <=
|
|
89
|
+
WHERE state = 'submitting' AND lease_until <= ? RETURNING conversation_id, transcript_id`).all(now);
|
|
90
|
+
for (const job of expired) notifyMediaGenerationAfterCommit(job.conversation_id, job.transcript_id);
|
|
88
91
|
const row = db.prepare(`SELECT * FROM music_generation_jobs WHERE state IN ('queued', 'submitted', 'running', 'saving')
|
|
89
92
|
AND next_attempt_at <= ? AND (lease_until IS NULL OR lease_until <= ?) ORDER BY next_attempt_at, rowid LIMIT 1`).get(now, now);
|
|
90
93
|
if (!row) return void 0;
|
|
@@ -101,12 +104,15 @@ function updateMusicJob(id, token, state, options = {}) {
|
|
|
101
104
|
const update = (db) => db.prepare(`UPDATE music_generation_jobs SET state = ?, error = ?, error_code = ?,
|
|
102
105
|
provider_task_id = COALESCE(?, provider_task_id), duration_ms = COALESCE(?, duration_ms), next_attempt_at = ?,
|
|
103
106
|
lease_token = CASE WHEN ? THEN lease_token END, lease_until = CASE WHEN ? THEN lease_until END
|
|
104
|
-
WHERE id = ? AND lease_token = ? AND lease_until >
|
|
105
|
-
|
|
107
|
+
WHERE id = ? AND lease_token = ? AND lease_until > ?
|
|
108
|
+
RETURNING conversation_id, transcript_id`).get(state, options.error ?? null, options.errorCode ?? null, options.taskId ?? null, options.durationMs ?? null, now + (options.delayMs ?? 0), Number(options.keepLease ?? false), Number(options.keepLease ?? false), id, token, now);
|
|
109
|
+
if (mediaGenerationPhase(state) === "pending") return Boolean(update(getSqliteDatabase()));
|
|
106
110
|
return runSqliteWriteTransaction((db) => {
|
|
107
111
|
const updated = update(db);
|
|
108
|
-
if (updated)
|
|
109
|
-
|
|
112
|
+
if (!updated) return false;
|
|
113
|
+
if (state === "completed") archiveSpaceGeneratedMedia(db, "music", id);
|
|
114
|
+
notifyMediaGenerationAfterCommit(updated.conversation_id, updated.transcript_id);
|
|
115
|
+
return true;
|
|
110
116
|
});
|
|
111
117
|
}
|
|
112
118
|
//#endregion
|
|
@@ -9,7 +9,10 @@ export type RegisterNotificationDeviceInput = {
|
|
|
9
9
|
appVersion?: string;
|
|
10
10
|
};
|
|
11
11
|
export declare function registerNotificationDevice(input: RegisterNotificationDeviceInput): NotificationDevice;
|
|
12
|
+
export declare function replaceNotificationPushReference(deviceId: string, previous: string, next: string): boolean;
|
|
12
13
|
export declare function getNotificationDevice(deviceId: string): NotificationDevice | null;
|
|
13
14
|
export declare function listDeliverableNotificationDevices(now?: number): NotificationDevice[];
|
|
14
15
|
export declare function updateNotificationDevicePreferences(deviceId: string, patch: Partial<NotificationPreferences>): NotificationDevice | null;
|
|
16
|
+
export declare function listRevokedPlatformPushDevices(now: number): NotificationDevice[];
|
|
17
|
+
export declare function disableNotificationDevice(deviceId: string): void;
|
|
15
18
|
export declare function removeNotificationDevice(deviceId: string): boolean;
|
|
@@ -65,6 +65,9 @@ function registerNotificationDevice(input) {
|
|
|
65
65
|
});
|
|
66
66
|
return getNotificationDevice(input.deviceId);
|
|
67
67
|
}
|
|
68
|
+
function replaceNotificationPushReference(deviceId, previous, next) {
|
|
69
|
+
return runSqliteWriteTransaction((db) => db.prepare("UPDATE device_push_endpoints SET push_token = ?, updated_at = ? WHERE device_id = ? AND push_token = ? AND enabled = 1").run(next, Date.now(), deviceId, previous).changes > 0);
|
|
70
|
+
}
|
|
68
71
|
function getNotificationDevice(deviceId) {
|
|
69
72
|
const row = getSqliteDatabase().prepare("SELECT * FROM device_push_endpoints WHERE device_id = ?").get(deviceId);
|
|
70
73
|
return row ? deviceFromRow(row) : null;
|
|
@@ -86,8 +89,18 @@ function updateNotificationDevicePreferences(deviceId, patch) {
|
|
|
86
89
|
});
|
|
87
90
|
return getNotificationDevice(deviceId);
|
|
88
91
|
}
|
|
92
|
+
function listRevokedPlatformPushDevices(now) {
|
|
93
|
+
return getSqliteDatabase().prepare(`
|
|
94
|
+
SELECT n.* FROM device_push_endpoints n JOIN devices d ON n.device_id = d.device_id
|
|
95
|
+
WHERE d.revoked_at IS NOT NULL AND n.enabled = 0 AND n.push_token LIKE 'platform-push:%'
|
|
96
|
+
AND n.lease_expires_at > ? ORDER BY n.updated_at LIMIT 20
|
|
97
|
+
`).all(now).map(deviceFromRow);
|
|
98
|
+
}
|
|
99
|
+
function disableNotificationDevice(deviceId) {
|
|
100
|
+
runSqliteWriteTransaction((db) => db.prepare("UPDATE device_push_endpoints SET enabled = 0 WHERE device_id = ?").run(deviceId));
|
|
101
|
+
}
|
|
89
102
|
function removeNotificationDevice(deviceId) {
|
|
90
103
|
return runSqliteWriteTransaction((db) => db.prepare("DELETE FROM device_push_endpoints WHERE device_id = ?").run(deviceId).changes > 0);
|
|
91
104
|
}
|
|
92
105
|
//#endregion
|
|
93
|
-
export { getNotificationDevice, listDeliverableNotificationDevices, registerNotificationDevice, removeNotificationDevice, updateNotificationDevicePreferences };
|
|
106
|
+
export { disableNotificationDevice, getNotificationDevice, listDeliverableNotificationDevices, listRevokedPlatformPushDevices, registerNotificationDevice, removeNotificationDevice, replaceNotificationPushReference, updateNotificationDevicePreferences };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { NotificationTarget } from '@xopcai/gateway-contract';
|
|
2
|
+
export declare class PlatformPushError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly code: string;
|
|
5
|
+
constructor(status: number, code: string);
|
|
6
|
+
}
|
|
7
|
+
export declare function platformPushEndpoint(value: string): string | undefined;
|
|
8
|
+
export declare function registerPlatformPushDevice(gatewayId: string, deviceId: string, pushToken: string): Promise<string>;
|
|
9
|
+
export declare function removePlatformPushDevice(reference: string): Promise<void>;
|
|
10
|
+
export type PlatformPushDelivery = {
|
|
11
|
+
endpointId: string;
|
|
12
|
+
eventId: string;
|
|
13
|
+
locale: 'en' | 'zh';
|
|
14
|
+
target: NotificationTarget;
|
|
15
|
+
expiresAt: number;
|
|
16
|
+
};
|
|
17
|
+
export declare function sendPlatformPush(message: PlatformPushDelivery, fetchImpl?: typeof fetch): Promise<string>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { XOPC_CLOUD_PROVIDER_ID, init_xopc_cloud_config, resolveXopcModelRouterUrl } from "../providers/xopc-cloud-config.js";
|
|
2
|
+
import { getProviderAuthService, init_provider_auth_service } from "../providers/provider-auth-service.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
//#region src/notifications/platform-push.ts
|
|
5
|
+
init_provider_auth_service();
|
|
6
|
+
init_xopc_cloud_config();
|
|
7
|
+
const endpointResponse = z.object({ endpointId: z.string().uuid() });
|
|
8
|
+
const endpointPrefix = "platform-push:";
|
|
9
|
+
var PlatformPushError = class extends Error {
|
|
10
|
+
constructor(status, code) {
|
|
11
|
+
super(code);
|
|
12
|
+
this.status = status;
|
|
13
|
+
this.code = code;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
function platformPushEndpoint(value) {
|
|
17
|
+
return value.startsWith(endpointPrefix) ? value.slice(14) : void 0;
|
|
18
|
+
}
|
|
19
|
+
async function request(path, method, body, fetchImpl = fetch) {
|
|
20
|
+
const token = await getProviderAuthService().resolveApiKey(XOPC_CLOUD_PROVIDER_ID);
|
|
21
|
+
if (!token) throw new PlatformPushError(401, "PUSH_CLOUD_AUTH_REQUIRED");
|
|
22
|
+
const response = await fetchImpl(resolveXopcModelRouterUrl() + "/push" + path, {
|
|
23
|
+
method,
|
|
24
|
+
redirect: "error",
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: "Bearer " + token,
|
|
27
|
+
"Content-Type": "application/json"
|
|
28
|
+
},
|
|
29
|
+
body: body && JSON.stringify(body),
|
|
30
|
+
signal: AbortSignal.timeout(8e3)
|
|
31
|
+
});
|
|
32
|
+
if (response.ok) return response;
|
|
33
|
+
if (response.status === 401 || response.status === 403) throw new PlatformPushError(response.status, "PUSH_CLOUD_AUTH_REQUIRED");
|
|
34
|
+
const error = await response.json().catch(() => null);
|
|
35
|
+
if (response.status === 503 && error?.error?.code === "push_provider_unavailable") throw new PlatformPushError(503, "PUSH_PLATFORM_UNAVAILABLE");
|
|
36
|
+
throw new PlatformPushError(response.status, "PUSH_PLATFORM_REQUEST_FAILED");
|
|
37
|
+
}
|
|
38
|
+
async function registerPlatformPushDevice(gatewayId, deviceId, pushToken) {
|
|
39
|
+
const response = await request("/endpoints", "PUT", {
|
|
40
|
+
gatewayId,
|
|
41
|
+
deviceId,
|
|
42
|
+
platform: "harmonyos",
|
|
43
|
+
pushToken
|
|
44
|
+
});
|
|
45
|
+
const result = endpointResponse.safeParse(await response.json().catch(() => null));
|
|
46
|
+
if (!result.success) throw new PlatformPushError(502, "PUSH_PLATFORM_INVALID_RESPONSE");
|
|
47
|
+
return endpointPrefix + result.data.endpointId;
|
|
48
|
+
}
|
|
49
|
+
async function removePlatformPushDevice(reference) {
|
|
50
|
+
const endpointId = platformPushEndpoint(reference);
|
|
51
|
+
if (endpointId) await request("/endpoints/" + encodeURIComponent(endpointId), "DELETE");
|
|
52
|
+
}
|
|
53
|
+
async function sendPlatformPush(message, fetchImpl = fetch) {
|
|
54
|
+
if ((await request("/deliveries", "POST", message, fetchImpl)).status !== 202) throw new PlatformPushError(502, "PUSH_PLATFORM_INVALID_RESPONSE");
|
|
55
|
+
return "platform:" + message.eventId;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { PlatformPushError, platformPushEndpoint, registerPlatformPushDevice, removePlatformPushDevice, sendPlatformPush };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type NotificationPlan } from './planner.js';
|
|
2
|
-
import {
|
|
2
|
+
import { sendPlatformPush } from './platform-push.js';
|
|
3
3
|
export declare class NotificationService {
|
|
4
4
|
private readonly options;
|
|
5
5
|
private timer;
|
|
@@ -10,7 +10,7 @@ export declare class NotificationService {
|
|
|
10
10
|
publish: (type: string, payload: unknown) => void;
|
|
11
11
|
fetch?: typeof fetch;
|
|
12
12
|
allowsNotification?: (notification: NotificationPlan['notification']) => boolean;
|
|
13
|
-
|
|
13
|
+
sendPush?: typeof sendPlatformPush;
|
|
14
14
|
});
|
|
15
15
|
start(): void;
|
|
16
16
|
stop(): void;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
|
-
import { localizeNotification } from "../../packages/gateway-contract/src/notifications.js";
|
|
4
|
-
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
5
3
|
import { getOrCreateGatewayIdentity } from "../storage/sqlite/gateway-identity-repository.js";
|
|
6
|
-
import { getNotificationDevice, listDeliverableNotificationDevices } from "./device-store.js";
|
|
4
|
+
import { getNotificationDevice, listDeliverableNotificationDevices, listRevokedPlatformPushDevices, removeNotificationDevice, replaceNotificationPushReference } from "./device-store.js";
|
|
7
5
|
import { notificationPlanFromGatewayEvent } from "./planner.js";
|
|
8
6
|
import { cancelNotificationDelivery, createNotificationEvent, expireUndeliverableNotificationDeliveries, listDueNotificationDeliveries, markNotificationDeliveryAccepted, markNotificationDeliveryDead, pruneNotificationEvents, rescheduleNotificationDelivery } from "./store.js";
|
|
9
|
-
import {
|
|
7
|
+
import { platformPushEndpoint, registerPlatformPushDevice, removePlatformPushDevice, sendPlatformPush } from "./platform-push.js";
|
|
10
8
|
import { flushClarificationNotifications, isClarificationNotificationActionable } from "./clarification.js";
|
|
11
9
|
//#region src/notifications/service.ts
|
|
12
|
-
init_src();
|
|
13
10
|
init_logger();
|
|
14
11
|
const log = createLogger("Notifications");
|
|
15
12
|
const MAX_DELIVERY_ATTEMPTS = 5;
|
|
@@ -106,6 +103,12 @@ var NotificationService = class {
|
|
|
106
103
|
}
|
|
107
104
|
for (const notification of flushClarificationNotifications((plan) => this.persistPlan(plan))) this.options.publish("notification.created", notification);
|
|
108
105
|
await this.deliverPending();
|
|
106
|
+
for (const device of listRevokedPlatformPushDevices(Date.now())) try {
|
|
107
|
+
await removePlatformPushDevice(device.pushToken);
|
|
108
|
+
removeNotificationDevice(device.id);
|
|
109
|
+
} catch {
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
109
112
|
} catch (err) {
|
|
110
113
|
log.warn({ err }, "Notification delivery pass failed");
|
|
111
114
|
} finally {
|
|
@@ -134,20 +137,31 @@ var NotificationService = class {
|
|
|
134
137
|
return;
|
|
135
138
|
}
|
|
136
139
|
const fetchImpl = this.options.fetch ?? fetch;
|
|
137
|
-
const localized = localizeNotification(delivery.event, delivery.locale);
|
|
138
140
|
try {
|
|
139
141
|
if (delivery.platform !== "harmonyos") {
|
|
140
142
|
markNotificationDeliveryDead(delivery.event.id, delivery.deviceId, "Native push provider is not configured");
|
|
141
143
|
return;
|
|
142
144
|
}
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
+
const expiresAt = Math.min(delivery.event.createdAt + 1440 * 60 * 1e3, delivery.event.type === "chat.needs_input" && typeof delivery.event.payload.expiresAt === "number" ? delivery.event.payload.expiresAt : Number.POSITIVE_INFINITY);
|
|
146
|
+
if (expiresAt <= Date.now()) {
|
|
147
|
+
cancelNotificationDelivery(delivery.event.id, delivery.deviceId);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
let endpointId = platformPushEndpoint(delivery.pushToken);
|
|
151
|
+
if (!endpointId && !this.options.sendPush) {
|
|
152
|
+
const reference = await registerPlatformPushDevice(getOrCreateGatewayIdentity().id, delivery.deviceId, delivery.pushToken);
|
|
153
|
+
if (!replaceNotificationPushReference(delivery.deviceId, delivery.pushToken, reference)) {
|
|
154
|
+
if (getNotificationDevice(delivery.deviceId)?.pushToken !== reference) await removePlatformPushDevice(reference);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
endpointId = platformPushEndpoint(reference);
|
|
158
|
+
}
|
|
159
|
+
const ticket = await (this.options.sendPush ?? sendPlatformPush)({
|
|
160
|
+
endpointId: endpointId ?? delivery.pushToken,
|
|
145
161
|
eventId: delivery.event.id,
|
|
146
|
-
|
|
162
|
+
locale: delivery.locale,
|
|
147
163
|
target: delivery.event.target,
|
|
148
|
-
|
|
149
|
-
body: localized.localizedBody,
|
|
150
|
-
...delivery.event.type === "chat.needs_input" && typeof delivery.event.payload.expiresAt === "number" ? { expiresAt: delivery.event.payload.expiresAt } : {}
|
|
164
|
+
expiresAt
|
|
151
165
|
}, fetchImpl);
|
|
152
166
|
markNotificationDeliveryAccepted(delivery.event.id, delivery.deviceId, ticket, Number.MAX_SAFE_INTEGER);
|
|
153
167
|
} catch (err) {
|
|
@@ -27,7 +27,7 @@ export declare function listNotificationEvents(options?: {
|
|
|
27
27
|
items: ProductNotification[];
|
|
28
28
|
nextCursor: string | null;
|
|
29
29
|
};
|
|
30
|
-
export declare function acknowledgeNotification(eventId: string, consumerId: string, surface: 'web' | 'electron' | 'mobile'): boolean;
|
|
30
|
+
export declare function acknowledgeNotification(eventId: string, consumerId: string, surface: 'web' | 'electron' | 'mobile', deviceId?: string): boolean;
|
|
31
31
|
export declare function listDueNotificationDeliveries(status: 'pending' | 'accepted', now?: number, limit?: number): NotificationDelivery[];
|
|
32
32
|
export declare function markNotificationDeliveryAccepted(eventId: string, deviceId: string, ticketId: string, receiptAt: number): void;
|
|
33
33
|
export declare function markNotificationDeliveryDelivered(eventId: string, deviceId: string): void;
|
|
@@ -74,8 +74,9 @@ function listNotificationEvents(options = {}) {
|
|
|
74
74
|
nextCursor: items.at(-1)?.id ?? null
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
function acknowledgeNotification(eventId, consumerId, surface) {
|
|
78
|
-
|
|
77
|
+
function acknowledgeNotification(eventId, consumerId, surface, deviceId) {
|
|
78
|
+
const db = getSqliteDatabase();
|
|
79
|
+
if (!(deviceId ? db.prepare("SELECT 1 FROM notification_deliveries WHERE event_id = ? AND device_id = ?").get(eventId, deviceId) : db.prepare("SELECT 1 FROM notification_events WHERE event_id = ?").get(eventId))) return false;
|
|
79
80
|
runSqliteWriteTransaction((db) => {
|
|
80
81
|
db.prepare(`INSERT INTO notification_acknowledgements (
|
|
81
82
|
event_id, consumer_id, surface, acknowledged_at
|
|
@@ -55,7 +55,6 @@ var init_env_keys = __esmMin((() => {
|
|
|
55
55
|
"xiaomi-token-plan-ams": ["XIAOMI_TOKEN_PLAN_AMS_API_KEY", "XIAOMI_TOKEN_PLAN_API_KEY"],
|
|
56
56
|
"xiaomi-token-plan-sgp": ["XIAOMI_TOKEN_PLAN_SGP_API_KEY", "XIAOMI_TOKEN_PLAN_API_KEY"],
|
|
57
57
|
"google-gemini-cli": ["GEMINI_CLI_TOKEN", "GOOGLE_TOKEN"],
|
|
58
|
-
"google-antigravity": ["ANTIGRAVITY_API_KEY"],
|
|
59
58
|
"vercel-ai-gateway": ["AI_GATEWAY_API_KEY", "VERCEL_AI_GATEWAY_API_KEY"],
|
|
60
59
|
"github-copilot": [
|
|
61
60
|
"COPILOT_GITHUB_TOKEN",
|
|
@@ -289,7 +289,7 @@ function providerSupportsOAuth(provider) {
|
|
|
289
289
|
return PROVIDER_META[provider]?.supportsOAuth ?? false;
|
|
290
290
|
}
|
|
291
291
|
function providerSupportsApiKey(provider) {
|
|
292
|
-
return PROVIDER_META[provider]?.supportsApiKey ?? true;
|
|
292
|
+
return !isRetiredModelProvider(provider) && (PROVIDER_META[provider]?.supportsApiKey ?? true);
|
|
293
293
|
}
|
|
294
294
|
/**
|
|
295
295
|
* Get a default model reference.
|
|
@@ -609,12 +609,6 @@ var init_providers = __esmMin((() => {
|
|
|
609
609
|
category: "oauth",
|
|
610
610
|
supportsOAuth: true,
|
|
611
611
|
supportsApiKey: false
|
|
612
|
-
},
|
|
613
|
-
"google-antigravity": {
|
|
614
|
-
name: "Google Antigravity (OAuth)",
|
|
615
|
-
category: "oauth",
|
|
616
|
-
supportsOAuth: true,
|
|
617
|
-
supportsApiKey: false
|
|
618
612
|
}
|
|
619
613
|
};
|
|
620
614
|
}));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
|
+
import { init_provider_policy, isRetiredModelProvider } from "./provider-policy.js";
|
|
3
4
|
import { init_models_json, loadModelsJson } from "../config/models-json.js";
|
|
4
5
|
import { getModelCatalogStore, init_model_catalog_store } from "./model-catalog-store.js";
|
|
5
6
|
import { getModelRegistry, init_model_registry } from "./model-registry.js";
|
|
@@ -10,6 +11,7 @@ init_logger();
|
|
|
10
11
|
init_models_json();
|
|
11
12
|
init_model_catalog_store();
|
|
12
13
|
init_model_registry();
|
|
14
|
+
init_provider_policy();
|
|
13
15
|
const log = createLogger("ModelCatalogSync");
|
|
14
16
|
const DEFAULT_INTERVAL_MS = 360 * 6e4;
|
|
15
17
|
var ModelCatalogSyncService = class {
|
|
@@ -92,7 +94,7 @@ var ModelCatalogSyncService = class {
|
|
|
92
94
|
}
|
|
93
95
|
this.status.refreshing = true;
|
|
94
96
|
const providers = this.options.loadProviders?.() ?? loadModelsJson().config.providers;
|
|
95
|
-
const discoverable = Object.entries(providers).filter(([, provider]) => provider.modelDiscovery?.enabled === true && typeof provider.baseUrl === "string" && isProviderApiDiscoverable(provider.api));
|
|
97
|
+
const discoverable = Object.entries(providers).filter(([providerId, provider]) => !isRetiredModelProvider(providerId) && provider.modelDiscovery?.enabled === true && typeof provider.baseUrl === "string" && isProviderApiDiscoverable(provider.api));
|
|
96
98
|
const catalogStore = this.options.catalogStore ?? getModelCatalogStore();
|
|
97
99
|
const enabledSourceIds = new Set(discoverable.map(([providerId]) => `provider:${providerId}`));
|
|
98
100
|
const removedSource = Object.keys(catalogStore.load().sources).filter((sourceId) => sourceId.startsWith("provider:") && !enabledSourceIds.has(sourceId)).map((sourceId) => catalogStore.removeSource(sourceId)).some(Boolean);
|
|
@@ -326,7 +326,8 @@ var init_model_registry = __esmMin((() => {
|
|
|
326
326
|
const overrides = /* @__PURE__ */ new Map();
|
|
327
327
|
const modelOverrides = /* @__PURE__ */ new Map();
|
|
328
328
|
const apiKeyConfigs = /* @__PURE__ */ new Map();
|
|
329
|
-
|
|
329
|
+
const activeProviders = Object.fromEntries(Object.entries(config.providers).filter(([providerName]) => !isRetiredModelProvider(providerName)));
|
|
330
|
+
for (const [providerName, providerConfig] of Object.entries(activeProviders)) {
|
|
330
331
|
if (providerConfig.baseUrl || providerConfig.headers || providerConfig.apiKey) overrides.set(providerName, {
|
|
331
332
|
baseUrl: providerConfig.baseUrl,
|
|
332
333
|
headers: providerConfig.headers,
|
|
@@ -336,7 +337,10 @@ var init_model_registry = __esmMin((() => {
|
|
|
336
337
|
if (providerConfig.modelOverrides) modelOverrides.set(providerName, new Map(Object.entries(providerConfig.modelOverrides)));
|
|
337
338
|
}
|
|
338
339
|
return {
|
|
339
|
-
models: this.parseModels(
|
|
340
|
+
models: this.parseModels({
|
|
341
|
+
...config,
|
|
342
|
+
providers: activeProviders
|
|
343
|
+
}),
|
|
340
344
|
overrides,
|
|
341
345
|
modelOverrides,
|
|
342
346
|
apiKeyConfigs,
|
|
@@ -74,8 +74,7 @@ const PROVIDER_HINTS = {
|
|
|
74
74
|
"zai-coding-cn": "Zhipu GLM coding-plan China endpoint from pi-ai.",
|
|
75
75
|
minimax: "MiniMax text models; Anthropic-compatible endpoint is preferred for agent workflows.",
|
|
76
76
|
"minimax-cn": "MiniMax China endpoint for domestic access.",
|
|
77
|
-
"google-gemini-cli": "Gemini through Google Cloud Code Assist OAuth."
|
|
78
|
-
"google-antigravity": "Gemini/Antigravity OAuth model access."
|
|
77
|
+
"google-gemini-cli": "Gemini through Google Cloud Code Assist OAuth."
|
|
79
78
|
};
|
|
80
79
|
const RECOMMENDED_MODEL_PATTERNS = {
|
|
81
80
|
"xopc-cloud": [/^auto$/],
|
|
@@ -2,11 +2,12 @@ import { __esmMin } from "../../_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
//#region src/providers/provider-policy.ts
|
|
3
3
|
/** Provider identities removed from xopc's current model contract. */
|
|
4
4
|
function isRetiredModelProvider(provider) {
|
|
5
|
-
return provider === "openai-codex" || provider === "azure-openai-responses";
|
|
5
|
+
return provider === "openai-codex" || provider === "azure-openai-responses" || provider === "google-antigravity";
|
|
6
6
|
}
|
|
7
7
|
function assertCurrentModelProvider(provider) {
|
|
8
8
|
if (provider === "openai-codex") throw new Error("Provider openai-codex is no longer supported. Select openai/<model-id> and sign in with ChatGPT again under openai.");
|
|
9
9
|
if (provider === "azure-openai-responses") throw new Error("Provider azure-openai-responses is no longer supported. Update the provider ID and model references to azure; the azure-openai-responses API type remains supported.");
|
|
10
|
+
if (provider === "google-antigravity") throw new Error("Google Antigravity OAuth has been removed. Update any google-antigravity model references to a supported provider.");
|
|
10
11
|
}
|
|
11
12
|
var init_provider_policy = __esmMin((() => {}));
|
|
12
13
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseTurnOutcome } from "../../packages/gateway-contract/src/turn-outcome.js";
|
|
2
|
+
import { stripUserMessageDisplayContext } from "../../packages/gateway-contract/src/user-message-text.js";
|
|
2
3
|
import { isUserTurnDocument } from "../../packages/gateway-contract/src/user-turn-document.js";
|
|
3
4
|
import { clarificationChoiceReceiptSchema } from "../../packages/gateway-contract/src/clarifications.js";
|
|
4
5
|
import { parseTaskResultDelivery } from "../../packages/gateway-contract/src/task-result-delivery.js";
|
|
@@ -7,7 +8,6 @@ import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
|
7
8
|
import { init_task_allocation_status, isRoutineTaskAllocationStatus } from "./task-allocation-status.js";
|
|
8
9
|
import { init_voice_transcript, isVoiceConversationMessage } from "./voice-transcript.js";
|
|
9
10
|
import { init_row_mappers, storedTranscriptEntryId } from "../storage/sqlite/row-mappers.js";
|
|
10
|
-
import { stripRuntimeContextFromUserMessage } from "./user-message-display.js";
|
|
11
11
|
import { buildTranscriptOutline } from "./transcript-outline.js";
|
|
12
12
|
//#region src/session/client-history.ts
|
|
13
13
|
init_src();
|
|
@@ -191,7 +191,7 @@ function messagesToClientHistory(messages, opts) {
|
|
|
191
191
|
out.push({
|
|
192
192
|
role: m.role,
|
|
193
193
|
...typeof m.turnId === "string" ? { turnId: m.turnId } : {},
|
|
194
|
-
content: m.role === "user" ?
|
|
194
|
+
content: m.role === "user" ? stripUserMessageDisplayContext(text) : text,
|
|
195
195
|
...m.media?.length ? { media: m.media } : {},
|
|
196
196
|
...sourceContextDisplayMetadata(m.metadata) ? { metadata: sourceContextDisplayMetadata(m.metadata) } : {},
|
|
197
197
|
timestamp: parseTimestamp(m.timestamp)
|
|
@@ -622,7 +622,7 @@ function transcriptRowsToClientHistory(rows, opts) {
|
|
|
622
622
|
...messageRow.turnId ? { turnId: messageRow.turnId } : {},
|
|
623
623
|
role: messageRow.role,
|
|
624
624
|
kind: "message",
|
|
625
|
-
content: messageRow.role === "user" ?
|
|
625
|
+
content: messageRow.role === "user" ? stripUserMessageDisplayContext(flattenMessageContent(messageRow.content ?? "")) : flattenMessageContent(messageRow.content ?? ""),
|
|
626
626
|
...messageRow.media?.length ? { media: messageRow.media } : {},
|
|
627
627
|
...sourceContextDisplayMetadata(messageRow.metadata) ? { metadata: sourceContextDisplayMetadata(messageRow.metadata) } : {},
|
|
628
628
|
...displayIndex !== void 0 ? { displayIndex } : {},
|
|
@@ -60,7 +60,7 @@ const TASK_DESTRUCTIVE_COMMANDS = new Set([
|
|
|
60
60
|
]);
|
|
61
61
|
function isTaskDestructiveCommand(body) {
|
|
62
62
|
const normalized = stripLeadingEnvelopeTimestamp(body.trim());
|
|
63
|
-
const match = /^\/([
|
|
63
|
+
const match = /^\/([^/\s@]+)(?:@[^/\s]+)?(?:\s|$)/.exec(normalized);
|
|
64
64
|
return Boolean(match && TASK_DESTRUCTIVE_COMMANDS.has(match[1].toLowerCase()));
|
|
65
65
|
}
|
|
66
66
|
function shouldSkipResetOverlapCommand(command, resetTriggered) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { stripRuntimeUserMessageEnvelope } from "../../packages/gateway-contract/src/user-message-display.js";
|
|
2
|
+
import { stripUserMessageDisplayContext } from "../../packages/gateway-contract/src/user-message-text.js";
|
|
2
3
|
import { init_src } from "../../packages/gateway-contract/src/index.js";
|
|
3
4
|
import { stripSessionStartupContextFromUserText } from "../agent/reply/startup-context.js";
|
|
4
5
|
//#region src/session/user-message-display.ts
|
|
@@ -9,14 +10,14 @@ function stripRuntimeContextFromUserMessage(text) {
|
|
|
9
10
|
}
|
|
10
11
|
/** Preserve structured content while cleaning every user text block. */
|
|
11
12
|
function stripRuntimeContextFromUserContent(content) {
|
|
12
|
-
if (typeof content === "string") return
|
|
13
|
+
if (typeof content === "string") return stripUserMessageDisplayContext(content);
|
|
13
14
|
return content.map((block) => {
|
|
14
15
|
if (!block || typeof block !== "object") return block;
|
|
15
16
|
const row = block;
|
|
16
17
|
if (row.type !== "text" || typeof row.text !== "string") return block;
|
|
17
18
|
return {
|
|
18
19
|
...row,
|
|
19
|
-
text:
|
|
20
|
+
text: stripUserMessageDisplayContext(row.text)
|
|
20
21
|
};
|
|
21
22
|
});
|
|
22
23
|
}
|
|
@@ -2,14 +2,12 @@ import type { SessionAgentReaction } from '@xopcai/gateway-contract';
|
|
|
2
2
|
export type ReactionTarget = Omit<SessionAgentReaction, 'entryId' | 'emoji' | 'createdAtMs' | 'actorName'> & {
|
|
3
3
|
inputId: string;
|
|
4
4
|
};
|
|
5
|
-
export declare const DEFAULT_AGENT_REACTION = "\uD83D\uDCAC";
|
|
6
5
|
export declare function hasActiveReactionInput(target: ReactionTarget): boolean;
|
|
7
|
-
export declare function activeReactionEntry(target: ReactionTarget
|
|
8
|
-
allowSteering: boolean;
|
|
9
|
-
}): {
|
|
6
|
+
export declare function activeReactionEntry(target: ReactionTarget): {
|
|
10
7
|
entryId: string;
|
|
11
8
|
seq: number;
|
|
12
9
|
} | undefined;
|
|
13
10
|
export declare function reactionCoolingDown(conversationId: string, now: number): boolean;
|
|
11
|
+
export declare function recentAgentReactionEmojis(conversationId: string, transcriptId: string): string[];
|
|
14
12
|
export declare function commitAgentReaction(input: ReactionTarget, entryId: string, emoji: string, actorName: string): SessionAgentReaction | null;
|
|
15
13
|
export declare function readAgentReactions(conversationId: string, transcriptId: string, entries: readonly string[], actorName: string): SessionAgentReaction[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "./transaction.js";
|
|
2
2
|
//#region src/storage/sqlite/agent-reaction-repository.ts
|
|
3
3
|
init_transaction();
|
|
4
|
-
const
|
|
4
|
+
const LEGACY_DEFAULT_AGENT_REACTION = "💬";
|
|
5
5
|
const ACTIVE_REACTION_INPUT = `SELECT s.active_transcript_id, r.active_run_id FROM sessions s
|
|
6
6
|
JOIN session_input_runtime r ON r.conversation_id = s.conversation_id
|
|
7
7
|
JOIN session_inputs i ON i.id = r.active_input_id AND i.conversation_id = s.conversation_id
|
|
@@ -13,41 +13,45 @@ const ACTIVE_REACTION_INPUT = `SELECT s.active_transcript_id, r.active_run_id FR
|
|
|
13
13
|
AND i.kind = 'message' AND i.effective_delivery = 'next'
|
|
14
14
|
AND i.expected_transcript_id = s.active_transcript_id
|
|
15
15
|
AND json_extract(i.origin_json, '$.type') = 'endpoint'
|
|
16
|
-
AND
|
|
16
|
+
AND NOT EXISTS (SELECT 1 FROM session_inputs steer WHERE steer.conversation_id = i.conversation_id
|
|
17
17
|
AND (steer.target_run_id = r.active_run_id OR steer.run_id = r.active_run_id)
|
|
18
|
-
AND steer.id <> i.id AND steer.effective_delivery = 'steer')
|
|
19
|
-
function reactionInputBindings(target
|
|
18
|
+
AND steer.id <> i.id AND steer.effective_delivery = 'steer')`;
|
|
19
|
+
function reactionInputBindings(target) {
|
|
20
20
|
return [
|
|
21
21
|
target.conversationId,
|
|
22
22
|
target.transcriptId,
|
|
23
23
|
target.actorAgentId,
|
|
24
24
|
target.runId,
|
|
25
25
|
target.inputId,
|
|
26
|
-
target.clientMessageId
|
|
27
|
-
Number(allowSteering)
|
|
26
|
+
target.clientMessageId
|
|
28
27
|
];
|
|
29
28
|
}
|
|
30
29
|
function hasActiveReactionInput(target) {
|
|
31
30
|
return getSqliteDatabase().prepare(ACTIVE_REACTION_INPUT).get(...reactionInputBindings(target)) !== void 0;
|
|
32
31
|
}
|
|
33
|
-
function activeReactionEntry(target
|
|
32
|
+
function activeReactionEntry(target) {
|
|
34
33
|
const entries = getSqliteDatabase().prepare(`SELECT e.entry_id AS entryId, e.seq
|
|
35
34
|
FROM (${ACTIVE_REACTION_INPUT}) input JOIN transcript_entries e ON e.transcript_id = input.active_transcript_id
|
|
36
35
|
WHERE e.entry_kind = 'message' AND e.role = 'user' AND json_extract(e.payload_json, '$.turnId') = input.active_run_id
|
|
37
36
|
AND COALESCE(json_extract(e.payload_json, '$.metadata.steered'), 0) = 0
|
|
38
37
|
AND COALESCE(json_extract(e.payload_json, '$.metadata.hiddenFromClient'), 0) = 0
|
|
39
|
-
ORDER BY e.seq DESC LIMIT 2`).all(...reactionInputBindings(target
|
|
38
|
+
ORDER BY e.seq DESC LIMIT 2`).all(...reactionInputBindings(target));
|
|
40
39
|
return entries.length === 1 ? entries[0] : void 0;
|
|
41
40
|
}
|
|
42
41
|
function reactionCoolingDown(conversationId, now) {
|
|
43
42
|
return Boolean(getSqliteDatabase().prepare(`SELECT 1 FROM session_agent_reactions
|
|
44
|
-
WHERE conversation_id = ? AND created_at_ms > ? AND emoji <> ? LIMIT 1`).get(conversationId, now - 2e4,
|
|
43
|
+
WHERE conversation_id = ? AND created_at_ms > ? AND emoji <> ? LIMIT 1`).get(conversationId, now - 2e4, LEGACY_DEFAULT_AGENT_REACTION));
|
|
44
|
+
}
|
|
45
|
+
function recentAgentReactionEmojis(conversationId, transcriptId) {
|
|
46
|
+
return getSqliteDatabase().prepare(`SELECT emoji FROM session_agent_reactions
|
|
47
|
+
WHERE conversation_id = ? AND transcript_id = ? AND emoji <> ?
|
|
48
|
+
ORDER BY created_at_ms DESC LIMIT 4`).all(conversationId, transcriptId, LEGACY_DEFAULT_AGENT_REACTION).map((row) => row.emoji);
|
|
45
49
|
}
|
|
46
50
|
function commitAgentReaction(input, entryId, emoji, actorName) {
|
|
51
|
+
if (emoji === LEGACY_DEFAULT_AGENT_REACTION) return null;
|
|
47
52
|
return runSqliteWriteTransaction((db) => {
|
|
48
53
|
const now = Date.now();
|
|
49
|
-
|
|
50
|
-
if (activeReactionEntry(input, { allowSteering: isDefault })?.entryId !== entryId || !isDefault && reactionCoolingDown(input.conversationId, now)) return null;
|
|
54
|
+
if (activeReactionEntry(input)?.entryId !== entryId || reactionCoolingDown(input.conversationId, now)) return null;
|
|
51
55
|
const { inputId: _inputId, ...identity } = input;
|
|
52
56
|
return db.prepare(`INSERT INTO session_agent_reactions
|
|
53
57
|
(conversation_id, transcript_id, client_message_id, entry_id, actor_agent_id, run_id, emoji, created_at_ms)
|
|
@@ -67,7 +71,8 @@ function readAgentReactions(conversationId, transcriptId, entries, actorName) {
|
|
|
67
71
|
r.run_id AS runId, r.emoji, r.created_at_ms AS createdAtMs, ? AS actorName
|
|
68
72
|
FROM session_agent_reactions r JOIN sessions s ON s.conversation_id = r.conversation_id
|
|
69
73
|
AND s.active_transcript_id = r.transcript_id
|
|
70
|
-
WHERE r.conversation_id = ? AND r.transcript_id = ? AND r.
|
|
74
|
+
WHERE r.conversation_id = ? AND r.transcript_id = ? AND r.emoji <> ?
|
|
75
|
+
AND r.entry_id IN (${entries.map(() => "?").join(",")})`).all(actorName, conversationId, transcriptId, LEGACY_DEFAULT_AGENT_REACTION, ...entries);
|
|
71
76
|
}
|
|
72
77
|
//#endregion
|
|
73
|
-
export {
|
|
78
|
+
export { activeReactionEntry, commitAgentReaction, hasActiveReactionInput, reactionCoolingDown, readAgentReactions, recentAgentReactionEmojis };
|
|
@@ -212,7 +212,8 @@ function revokeDevice(deviceId, now = Date.now()) {
|
|
|
212
212
|
const changed = db.prepare("UPDATE devices SET revoked_at = ? WHERE device_id = ? AND revoked_at IS NULL").run(now, deviceId).changes > 0;
|
|
213
213
|
db.prepare("UPDATE device_access_sessions SET revoked_at = ? WHERE device_id = ? AND revoked_at IS NULL").run(now, deviceId);
|
|
214
214
|
db.prepare("UPDATE device_refresh_credentials SET revoked_at = ? WHERE device_id = ? AND revoked_at IS NULL").run(now, deviceId);
|
|
215
|
-
db.prepare(
|
|
215
|
+
db.prepare(`DELETE FROM device_push_endpoints WHERE device_id = ? AND push_token NOT LIKE 'platform-push:%'`).run(deviceId);
|
|
216
|
+
db.prepare("UPDATE device_push_endpoints SET enabled = 0 WHERE device_id = ?").run(deviceId);
|
|
216
217
|
return changed;
|
|
217
218
|
});
|
|
218
219
|
}
|
|
@@ -136,6 +136,7 @@ export declare const TaskMutationOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObj
|
|
|
136
136
|
run_failed: "run_failed";
|
|
137
137
|
run_decision_required: "run_decision_required";
|
|
138
138
|
verification_failed: "verification_failed";
|
|
139
|
+
verification_unverified: "verification_unverified";
|
|
139
140
|
overdue: "overdue";
|
|
140
141
|
stale: "stale";
|
|
141
142
|
}>;
|
|
@@ -317,6 +318,7 @@ export declare const TaskMutationOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObj
|
|
|
317
318
|
run_failed: "run_failed";
|
|
318
319
|
run_decision_required: "run_decision_required";
|
|
319
320
|
verification_failed: "verification_failed";
|
|
321
|
+
verification_unverified: "verification_unverified";
|
|
320
322
|
overdue: "overdue";
|
|
321
323
|
stale: "stale";
|
|
322
324
|
}>;
|
|
@@ -89,10 +89,11 @@ function decisionFromTask(model, projectName, locale) {
|
|
|
89
89
|
"run_decision_required",
|
|
90
90
|
"run_failed",
|
|
91
91
|
"verification_failed",
|
|
92
|
+
"verification_unverified",
|
|
92
93
|
"overdue"
|
|
93
94
|
].includes(candidate.kind));
|
|
94
95
|
if (!item) return null;
|
|
95
|
-
const reason = item.kind === "input_required" || item.kind === "run_decision_required" ? "needs_input" : item.kind === "approval_required" ? "approval_required" : item.kind === "dependency_blocked" ? "dependency" : item.kind === "run_failed" || item.kind === "verification_failed" ? "retry" : item.kind === "overdue" ? "overdue" : void 0;
|
|
96
|
+
const reason = item.kind === "input_required" || item.kind === "run_decision_required" ? "needs_input" : item.kind === "approval_required" ? "approval_required" : item.kind === "dependency_blocked" ? "dependency" : item.kind === "run_failed" || item.kind === "verification_failed" || item.kind === "verification_unverified" ? "retry" : item.kind === "overdue" ? "overdue" : void 0;
|
|
96
97
|
if (!reason) return null;
|
|
97
98
|
return {
|
|
98
99
|
id: `task:${task.id}`,
|