@xopcai/xopc 0.0.485 → 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.
Files changed (167) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/server/chunks.bin +982 -949
  4. package/dist/gateway/server/chunks.json +1 -1
  5. package/dist/gateway/static/root/assets/agent-run-error-parser-DsXmcKt-.js +1 -0
  6. package/dist/gateway/static/root/assets/{api-CGs641OT.js → api-CGrHK9ij.js} +1 -1
  7. package/dist/gateway/static/root/assets/{apps-page-CH9wENBj.js → apps-page-6xeWvMpF.js} +1 -1
  8. package/dist/gateway/static/root/assets/{automations-page-uY_wmZY1.js → automations-page-BLFBqaPX.js} +1 -1
  9. package/dist/gateway/static/root/assets/{automations-workspace-DyQq55Rh.js → automations-workspace-DiO3Iyuj.js} +2 -2
  10. package/dist/gateway/static/root/assets/{capabilities-abgigXV1.js → capabilities-CW-vdkz6.js} +1 -1
  11. package/dist/gateway/static/root/assets/{capabilities-BaKHutgZ.js → capabilities-DZrjA95P.js} +1 -1
  12. package/dist/gateway/static/root/assets/capabilities-page-DQrfkrBA.js +2 -0
  13. package/dist/gateway/static/root/assets/{capabilities-settings-panel-BOwbZn9X.js → capabilities-settings-panel-DIT2dvtc.js} +1 -1
  14. package/dist/gateway/static/root/assets/{channels-DlnXbcOj.js → channels-Dcr5dgqw.js} +1 -1
  15. package/dist/gateway/static/root/assets/{chat-page-3fVhP77N.js → chat-page-DWZCzxY7.js} +31 -31
  16. package/dist/gateway/static/root/assets/{chat-terminal-dock-DE8j-K9d.js → chat-terminal-dock-DCUuwiTt.js} +1 -1
  17. package/dist/gateway/static/root/assets/composer-payload-handoff-a0quQ25p.js +1 -0
  18. package/dist/gateway/static/root/assets/connected-providers-grid-BJKEp0SE.js +1 -0
  19. package/dist/gateway/static/root/assets/{connectors-page-BJm1jjct.js → connectors-page-BteRI1XM.js} +1 -1
  20. package/dist/gateway/static/root/assets/{extension-debug-page-D3X7SlzG.js → extension-debug-page-4jJ1uVQJ.js} +1 -1
  21. package/dist/gateway/static/root/assets/{extension-iframe-host-CIAq7PSn.js → extension-iframe-host-CJV5JETm.js} +1 -1
  22. package/dist/gateway/static/root/assets/{extension-message-router-B2wbucV7.js → extension-message-router-B4I-Y6qs.js} +1 -1
  23. package/dist/gateway/static/root/assets/{extension-page-qwY7r1_p.js → extension-page-lc7a84nG.js} +1 -1
  24. package/dist/gateway/static/root/assets/{extension-provider-DFcRbTHI.js → extension-provider-D8_mIBI0.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-settings-page-Cpnh9lcZ.js → extension-settings-page-Uw2lfWRh.js} +1 -1
  26. package/dist/gateway/static/root/assets/{home-page-BusNFHe-.js → home-page-mSRCU81k.js} +4 -4
  27. package/dist/gateway/static/root/assets/{home-task-actions-C8Fi6GBq.js → home-task-actions-_ZAc57Y7.js} +1 -1
  28. package/dist/gateway/static/root/assets/{index-790PGhZb.js → index-CJAEAcZV.js} +7 -7
  29. package/dist/gateway/static/root/assets/{local-app-workbench-page-B9uSL1Mi.js → local-app-workbench-page-C3Lqi8E1.js} +1 -1
  30. package/dist/gateway/static/root/assets/{note-detail-panel-Bwm_aehq.js → note-detail-panel-uc-5k3a2.js} +3 -3
  31. package/dist/gateway/static/root/assets/{notes-page-DkZWV3Ds.js → notes-page-RPfvHnl6.js} +1 -1
  32. package/dist/gateway/static/root/assets/{page-context-capture-button-BXSBeGms.js → page-context-capture-button-CVHz9b6c.js} +1 -1
  33. package/dist/gateway/static/root/assets/{personal-page-cauym9hr.js → personal-page-Dt1d3tQT.js} +1 -1
  34. package/dist/gateway/static/root/assets/{personal-profile-settings-TcI0Zfwr.js → personal-profile-settings-XiT1MgTK.js} +1 -1
  35. package/dist/gateway/static/root/assets/{personal-settings-panel-BJ46T7ZO.js → personal-settings-panel-bcw04REt.js} +1 -1
  36. package/dist/gateway/static/root/assets/{preview-runtime-C1U57WSM.js → preview-runtime-FtWOW5i4.js} +1 -1
  37. package/dist/gateway/static/root/assets/{product-automation-feedback-GA_YPLkr.js → product-automation-feedback-DdFoCDzG.js} +1 -1
  38. package/dist/gateway/static/root/assets/product-preview-content-B3mzl6-f.js +1 -0
  39. package/dist/gateway/static/root/assets/product-preview-modal-5kTp_7Qk.js +2 -0
  40. package/dist/gateway/static/root/assets/project-detail-page-DGPfKx5M.js +7 -0
  41. package/dist/gateway/static/root/assets/{projects-page-BHQxQGTd.js → projects-page-C-9x23LR.js} +1 -1
  42. package/dist/gateway/static/root/assets/route-preload-CzorjVc9.js +2 -0
  43. package/dist/gateway/static/root/assets/routine-panel-n4IstC8Y.js +2 -0
  44. package/dist/gateway/static/root/assets/session-manager-C2MCS4C5.js +28 -0
  45. package/dist/gateway/static/root/assets/{settings-page-Cd9WZ-Ac.js → settings-page-DsM_f07M.js} +1 -1
  46. package/dist/gateway/static/root/assets/{share-preview-page-Di5_ukH8.js → share-preview-page-C32Mq-BY.js} +1 -1
  47. package/dist/gateway/static/root/assets/{shares-settings-CirGM67m.js → shares-settings-BDGbs8wz.js} +1 -1
  48. package/dist/gateway/static/root/assets/space-page-DwyuUvI3.js +2 -0
  49. package/dist/gateway/static/root/assets/task-copy-CtcqCQ78.js +1 -0
  50. package/dist/gateway/static/root/assets/task-detail-page-DdCpNW8K.js +3 -0
  51. package/dist/gateway/static/root/assets/{task-header-title-qzNctGl5.js → task-header-title-CLt_lmjb.js} +1 -1
  52. package/dist/gateway/static/root/assets/task-result-presentation-CgvcqEMD.js +1 -0
  53. package/dist/gateway/static/root/assets/task-run-issue-notice-8FX876PP.js +1 -0
  54. package/dist/gateway/static/root/assets/tasks-CvOAtEHv.js +1 -0
  55. package/dist/gateway/static/root/assets/turn-outcome-Dtw6OgwL.js +1 -0
  56. package/dist/gateway/static/root/assets/{use-composer-attachments-DJsIzJ1c.js → use-composer-attachments-BEuyorVm.js} +1 -1
  57. package/dist/gateway/static/root/assets/{use-file-preview-expanded-BFF2vXm5.js → use-file-preview-expanded-Cehu0745.js} +1 -1
  58. package/dist/gateway/static/root/assets/use-personal-work-B25WRGHj.js +1 -0
  59. package/dist/gateway/static/root/assets/{use-realtime-voice-9OvLwHzk.js → use-realtime-voice-CV3GIt_T.js} +1 -1
  60. package/dist/gateway/static/root/assets/{use-workspace-tree-LCIT1H-D.js → use-workspace-tree-C0C861cb.js} +1 -1
  61. package/dist/gateway/static/root/assets/{voice-settings-j8o-hGTm.js → voice-settings-JpPo3BvX.js} +1 -1
  62. package/dist/gateway/static/root/assets/workspace-api-CQOuWbVv.js +2 -0
  63. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-DwVWTehC.js → workspace-file-preview-dialog-CmMueTmW.js} +1 -1
  64. package/dist/gateway/static/root/index.html +29 -27
  65. package/dist/package.js +1 -1
  66. package/dist/packages/gateway-contract/src/index.js +3 -1
  67. package/dist/packages/gateway-contract/src/notifications.js +1 -8
  68. package/dist/packages/gateway-contract/src/task-display.js +9 -2
  69. package/dist/packages/gateway-contract/src/task-lifecycle.js +1 -0
  70. package/dist/packages/gateway-contract/src/task-research-result.js +2 -1
  71. package/dist/packages/gateway-contract/src/tasks.js +6 -1
  72. package/dist/packages/gateway-contract/src/user-message-text.js +64 -0
  73. package/dist/src/agent/embedded/run-for-session.js +27 -28
  74. package/dist/src/agent/embedded/session-runner.js +14 -1
  75. package/dist/src/agent/fallback/candidates.d.ts +1 -0
  76. package/dist/src/agent/fallback/candidates.js +1 -1
  77. package/dist/src/agent/image/generation/provider-registry.js +3 -1
  78. package/dist/src/agent/models/manager.d.ts +1 -1
  79. package/dist/src/agent/models/manager.js +2 -1
  80. package/dist/src/agent/models/turn-candidates.d.ts +16 -0
  81. package/dist/src/agent/models/turn-candidates.js +55 -0
  82. package/dist/src/agent/service.d.ts +1 -0
  83. package/dist/src/agent/service.js +12 -0
  84. package/dist/src/agent/skills/installer.js +2 -2
  85. package/dist/src/auth/credentials.js +3 -1
  86. package/dist/src/auth/oauth/index.d.ts +0 -1
  87. package/dist/src/auth/oauth/index.js +1 -4
  88. package/dist/src/auth/oauth/registry.js +0 -4
  89. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  90. package/dist/src/cli/command-manifest.js +1 -1
  91. package/dist/src/cli/commands/auth.js +4 -2
  92. package/dist/src/cli/commands/models.js +12 -10
  93. package/dist/src/config/models-json.js +1 -2
  94. package/dist/src/gateway/agent-reactions/reaction.d.ts +1 -2
  95. package/dist/src/gateway/agent-reactions/reaction.js +10 -21
  96. package/dist/src/gateway/custom-image-providers.js +4 -1
  97. package/dist/src/gateway/hono/oauth.js +3 -0
  98. package/dist/src/gateway/hono/routes/device-push.js +55 -15
  99. package/dist/src/gateway/hono/routes/home.js +1 -1
  100. package/dist/src/gateway/hono/routes/mobile-mcp-setup.js +49 -29
  101. package/dist/src/gateway/hono/routes/notifications.js +12 -1
  102. package/dist/src/gateway/hono/routes/sessions.js +1 -13
  103. package/dist/src/gateway/security/gateway-scopes.js +1 -0
  104. package/dist/src/gateway/service/run-gateway-agent.js +2 -13
  105. package/dist/src/gateway/service.js +84 -64
  106. package/dist/src/home-intelligence/host.js +5 -5
  107. package/dist/src/local-apps/capabilities/projections.d.ts +5 -5
  108. package/dist/src/notifications/device-store.d.ts +3 -0
  109. package/dist/src/notifications/device-store.js +14 -1
  110. package/dist/src/notifications/platform-push.d.ts +17 -0
  111. package/dist/src/notifications/platform-push.js +58 -0
  112. package/dist/src/notifications/service.d.ts +2 -2
  113. package/dist/src/notifications/service.js +26 -12
  114. package/dist/src/notifications/store.d.ts +1 -1
  115. package/dist/src/notifications/store.js +3 -2
  116. package/dist/src/providers/env-keys.js +0 -1
  117. package/dist/src/providers/index.js +1 -7
  118. package/dist/src/providers/model-catalog-sync-service.js +3 -1
  119. package/dist/src/providers/model-registry.js +6 -2
  120. package/dist/src/providers/presentation.js +1 -2
  121. package/dist/src/providers/provider-policy.js +2 -1
  122. package/dist/src/session/client-history.js +3 -3
  123. package/dist/src/session/user-message-display.js +3 -2
  124. package/dist/src/storage/sqlite/agent-reaction-repository.d.ts +2 -4
  125. package/dist/src/storage/sqlite/agent-reaction-repository.js +18 -13
  126. package/dist/src/storage/sqlite/device-access-repository.js +2 -1
  127. package/dist/src/tasks/capabilities/write.d.ts +2 -0
  128. package/dist/src/tasks/home-query-service.js +2 -1
  129. package/dist/src/tasks/task-contract-planner.js +1 -0
  130. package/dist/src/tasks/task-conversation-summary.d.ts +1 -1
  131. package/dist/src/tasks/task-delivery-checks.d.ts +12 -0
  132. package/dist/src/tasks/task-delivery-checks.js +91 -0
  133. package/dist/src/tasks/task-final-reply.d.ts +3 -1
  134. package/dist/src/tasks/task-final-reply.js +17 -4
  135. package/dist/src/tasks/task-model-call.js +4 -2
  136. package/dist/src/tasks/task-origin-repository.d.ts +1 -1
  137. package/dist/src/tasks/task-read-model-projector.js +24 -7
  138. package/dist/src/tasks/task-research-result.js +12 -27
  139. package/dist/src/tasks/task-result-delivery-repository.js +3 -2
  140. package/dist/src/tasks/task-retry-service.js +2 -1
  141. package/dist/src/tasks/task-run-coordinator.js +14 -4
  142. package/dist/src/tasks/task-run-dispatcher.d.ts +1 -0
  143. package/dist/src/tasks/task-run-dispatcher.js +78 -48
  144. package/dist/src/tasks/task-run-repository.js +1 -1
  145. package/package.json +1 -1
  146. package/dist/gateway/static/root/assets/capabilities-page-WCl7Fdce.js +0 -2
  147. package/dist/gateway/static/root/assets/composer-payload-handoff-ClWsunJ2.js +0 -1
  148. package/dist/gateway/static/root/assets/connected-providers-grid-BgW-ioIt.js +0 -1
  149. package/dist/gateway/static/root/assets/product-preview-content-BOq3gtSJ.js +0 -1
  150. package/dist/gateway/static/root/assets/product-preview-modal-DIh_CsXp.js +0 -2
  151. package/dist/gateway/static/root/assets/project-detail-page-D9WKZe3z.js +0 -7
  152. package/dist/gateway/static/root/assets/route-preload-DF8LOfKW.js +0 -2
  153. package/dist/gateway/static/root/assets/routine-panel-Bfbiz0IN.js +0 -2
  154. package/dist/gateway/static/root/assets/session-manager-DUWeBdeG.js +0 -28
  155. package/dist/gateway/static/root/assets/space-page-DlJB7GT1.js +0 -2
  156. package/dist/gateway/static/root/assets/task-detail-page-BFa0Px-B.js +0 -3
  157. package/dist/gateway/static/root/assets/task-run-issue-notice-CGrUMy0s.js +0 -1
  158. package/dist/gateway/static/root/assets/tasks-CwyNaa-j.js +0 -1
  159. package/dist/gateway/static/root/assets/turn-outcome-BSbEJx8h.js +0 -1
  160. package/dist/gateway/static/root/assets/use-personal-work-B1DWeBnm.js +0 -1
  161. package/dist/gateway/static/root/assets/workspace-api-BuNWyNvA.js +0 -2
  162. package/dist/src/auth/oauth/google-antigravity.d.ts +0 -4
  163. package/dist/src/auth/oauth/google-antigravity.js +0 -9
  164. package/dist/src/auth/oauth/google-oauth/google-antigravity.d.ts +0 -25
  165. package/dist/src/auth/oauth/google-oauth/google-antigravity.js +0 -309
  166. package/dist/src/notifications/harmony-push.d.ts +0 -27
  167. package/dist/src/notifications/harmony-push.js +0 -96
@@ -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 { sendHarmonyPush } from './harmony-push.js';
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
- sendHarmony?: typeof sendHarmonyPush;
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 { sendHarmonyPush } from "./harmony-push.js";
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 ticket = await (this.options.sendHarmony ?? sendHarmonyPush)({
144
- pushToken: delivery.pushToken,
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
- gatewayId: getOrCreateGatewayIdentity().id,
162
+ locale: delivery.locale,
147
163
  target: delivery.event.target,
148
- title: localized.localizedTitle,
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
- if (!getSqliteDatabase().prepare("SELECT 1 FROM notification_events WHERE event_id = ?").get(eventId)) return false;
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
- for (const [providerName, providerConfig] of Object.entries(config.providers)) {
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(config),
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" ? stripRuntimeContextFromUserMessage(text) : text,
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" ? stripRuntimeContextFromUserMessage(flattenMessageContent(messageRow.content ?? "")) : flattenMessageContent(messageRow.content ?? ""),
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 } : {},
@@ -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 stripRuntimeContextFromUserMessage(content);
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: stripRuntimeContextFromUserMessage(row.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, options?: {
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 DEFAULT_AGENT_REACTION = "💬";
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 (? = 1 OR NOT EXISTS (SELECT 1 FROM session_inputs steer WHERE steer.conversation_id = i.conversation_id
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, allowSteering = false) {
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, options) {
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, options?.allowSteering));
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, DEFAULT_AGENT_REACTION));
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
- const isDefault = emoji === DEFAULT_AGENT_REACTION;
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.entry_id IN (${entries.map(() => "?").join(",")})`).all(actorName, conversationId, transcriptId, ...entries);
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 { DEFAULT_AGENT_REACTION, activeReactionEntry, commitAgentReaction, hasActiveReactionInput, reactionCoolingDown, readAgentReactions };
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("DELETE FROM device_push_endpoints WHERE device_id = ?").run(deviceId);
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}`,
@@ -91,6 +91,7 @@ var ModelTaskContractPlanner = class {
91
91
  "Acceptance criteria must describe externally checkable finished states, not activities.",
92
92
  "Write boundaries and prohibitions on unrelated actions belong in constraints, not criteria requiring proof that no unobserved action ever occurred. Criteria may check the actual delivered output paths and unchanged supplied input bytes. Never remove an explicit scope restriction.",
93
93
  "Keep each criterion concise and concrete. For simple work use the fewest checks that cover all explicit deliverables and material constraints. Prefer observable checks such as the required file, format, fields or count. Treat optional analysis, extra conclusions and aesthetic improvements as optional unless the user requires them. Do not invent work to make the contract more elaborate.",
94
+ "Keep delivery format and character limits in their own criteria, separate from factual accuracy, publication dates and source requirements. For explicit chat format and limits, use concrete wording such as \"The final reply must be plain text\" or \"The final reply must be at most 500 characters\". For explicitly requested HTML structure, describe the required file name or page elements separately from what those elements must substantively say.",
94
95
  "Define criteria for the deliverables requested by the user. When the requested answer is a chat reply, list it explicitly in expectedOutputs and preserve its concrete requirements, including language and any length limits the user actually set. Treat general brevity or “keep it short” as a presentation preference. Do not turn it into a word or character quota or an acceptance check. Keep source support, calculations, completeness and requested limitations as separate criteria. Do not create self-referential criteria about calling publish_task_result, receiving this review or wording a routine delivery acknowledgement.",
95
96
  "requiredCapabilities is a minimal subset of read_input, execute_code, publish_files, web_research, browser, generate_image. Include only operations necessary for the requested inputs/outputs; this list selects registered tools and grants no permissions. Do not require browser when ordinary web fetch suffices. Preserve explicit executor/Skill and scope constraints.",
96
97
  "List assumptions explicitly. Put only irreversible, external, financial, privacy, or permission decisions in approvalRequired.",
@@ -59,7 +59,7 @@ export declare function taskConversationSummary(taskId: string, conversationId:
59
59
  questionId: unknown;
60
60
  }[];
61
61
  attention: {
62
- kind: "allocation_blocked" | "allocation_failed" | "input_required" | "approval_required" | "dependency_blocked" | "run_failed" | "run_decision_required" | "verification_failed" | "overdue" | "stale";
62
+ kind: "allocation_blocked" | "allocation_failed" | "input_required" | "approval_required" | "dependency_blocked" | "run_failed" | "run_decision_required" | "verification_failed" | "verification_unverified" | "overdue" | "stale";
63
63
  summary: string;
64
64
  }[];
65
65
  workerProgress: {
@@ -0,0 +1,12 @@
1
+ import type { TaskResearchResult } from '@xopcai/gateway-contract';
2
+ type PublishedFile = {
3
+ title: string;
4
+ content?: string;
5
+ };
6
+ export declare function checkTaskDelivery(result: TaskResearchResult, input: {
7
+ files: PublishedFile[];
8
+ publishedFileCount: number;
9
+ chatReplyOnly: boolean;
10
+ zh: boolean;
11
+ }): TaskResearchResult;
12
+ export {};
@@ -0,0 +1,91 @@
1
+ import { finalReplyCharacterLimit, isReplyLengthCriterion } from "./task-final-reply.js";
2
+ import { parseHTML } from "linkedom";
3
+ import MarkdownIt from "markdown-it";
4
+ //#region src/tasks/task-delivery-checks.ts
5
+ const markdown = new MarkdownIt({ html: true });
6
+ const plainChat = /^(?:(?:最终)?(?:回复|答复)为纯文本(?:聊天内容)?|(?:use |deliver )(?:a )?plain[- ]text chat (?:reply|response)|(?:the )?(?:final )?(?:chat )?(?:reply|response) (?:is|must be) plain[- ]text)(?:[,,]\s*(?:未生成任何文件|不生成(?:任何)?文件|without (?:any )?(?:files|attachments)))?$/iu;
7
+ const noMarkdown = /^(?:(?:最终)?(?:回复|答复)(?:使用纯文本[,,]\s*)?(?:不使用|不得使用|无)\s*Markdown|(?:the )?(?:final )?(?:chat )?(?:reply|response) (?:uses? no|must not use) Markdown)$/iu;
8
+ const htmlFilename = /^(?:(?:HTML\s*)?文件名(?:为|是|:|:)\s*|(?:the )?(?:HTML )?(?:file ?name is|file is named)\s+)`?([^\s`/\\]+\.html?)`?$/iu;
9
+ const singleHtml = /^(?:(?:交付|发布)(?:一个|一份)?单文件\s*HTML(?:\s*(?:文件|网页))?|(?:deliver|publish) (?:a )?single HTML (?:file|document))$/iu;
10
+ const htmlHeadingAndFooter = /^(?:HTML\s*(?:页面)?(?:包含|含有)(?:可见)?标题(?:和|与|及)页脚|(?:the )?HTML (?:page )?(?:has|contains) (?:a )?(?:heading|title) and (?:a )?footer)$/iu;
11
+ const inlineCss = /^(?:CSS\s*(?:全部)?(?:内联|内嵌)|CSS\s*(?:必须|须)(?:内联|内嵌)|(?:all )?CSS (?:is|must be) (?:inline|embedded))$/iu;
12
+ function checkTaskDelivery(result, input) {
13
+ const { finalText } = result;
14
+ const { files, zh } = input;
15
+ const length = finalText === void 0 ? void 0 : Array.from(finalText).length;
16
+ const htmlFiles = files.filter((file) => /\.html?$/iu.test(file.title));
17
+ const knowsFinalFiles = result.finalArtifactIds !== void 0 || files.length > 0;
18
+ const htmlContent = htmlFiles.length === 1 ? htmlFiles[0].content : void 0;
19
+ let document;
20
+ const checked = (check, passed, zhNote, enNote) => ({
21
+ ...check,
22
+ status: passed ? "passed" : "failed",
23
+ claimIds: [],
24
+ method: "tool_verified",
25
+ note: zh ? zhNote : enNote
26
+ });
27
+ const unverified = (check, zhNote, enNote) => ({
28
+ ...check,
29
+ status: "unverified",
30
+ claimIds: [],
31
+ note: zh ? zhNote : enNote
32
+ });
33
+ const checks = result.checks.map((check) => {
34
+ const criterion = check.criterion.trim().replace(/[.。]$/u, "");
35
+ const limit = finalReplyCharacterLimit(check.criterion, input.chatReplyOnly);
36
+ if (finalText === void 0 && (limit !== void 0 || plainChat.test(criterion) || noMarkdown.test(criterion))) return unverified(check, "尚未提交供核验的最终回复。", "No final reply was submitted for verification.");
37
+ if (limit !== void 0 && length !== void 0) {
38
+ if (length > limit || isReplyLengthCriterion(criterion, input.chatReplyOnly)) return checked(check, length <= limit, `最终回复共 ${length} 个字符,上限为 ${limit}。`, `The final reply contains ${length} characters. The limit is ${limit}.`);
39
+ }
40
+ if (finalText !== void 0 && plainChat.test(criterion)) {
41
+ const excludesFiles = /未生成|不生成|without /iu.test(criterion);
42
+ const passed = !((input.chatReplyOnly || excludesFiles) && files.length > 0 || /未生成|不生成/u.test(criterion) && input.publishedFileCount > 0) && !markdown.parse(finalText, {}).some((token) => [
43
+ "html_block",
44
+ "fence",
45
+ "code_block"
46
+ ].includes(token.type) || token.children?.some((child) => ["html_inline", "image"].includes(child.type)));
47
+ return checked(check, passed, passed ? "最终交付为纯文本聊天回复。" : "最终交付含文件、图片、HTML 或代码块。", passed ? "The final delivery is a plain-text chat reply." : "The delivery contains files, images, HTML, or code blocks.");
48
+ }
49
+ if (finalText !== void 0 && noMarkdown.test(criterion)) {
50
+ const passed = markdown.parse(finalText, {}).every((token) => [
51
+ "paragraph_open",
52
+ "paragraph_close",
53
+ "inline"
54
+ ].includes(token.type) && (token.children ?? []).every((child) => ["text", "softbreak"].includes(child.type)));
55
+ return checked(check, passed, passed ? "最终回复为无 Markdown 格式的文本。" : "最终回复含 Markdown 排版或 HTML。", passed ? "The final reply is text without Markdown formatting." : "The final reply contains Markdown formatting or HTML.");
56
+ }
57
+ const filename = htmlFilename.exec(criterion)?.[1];
58
+ if (filename && knowsFinalFiles) {
59
+ const file = htmlFiles.find((item) => item.title === filename);
60
+ return checked(check, Boolean(file), file ? `最终交付包含文件 ${filename}。` : `最终交付中缺少 ${filename}。`, file ? `The final delivery lists the file ${filename}.` : `The final publication does not include ${filename}.`);
61
+ }
62
+ const single = singleHtml.test(criterion);
63
+ const css = inlineCss.test(criterion);
64
+ if (single || css || htmlHeadingAndFooter.test(criterion)) {
65
+ if (knowsFinalFiles && (htmlFiles.length === 0 || single && files.length !== 1)) return checked(check, false, "最终交付未包含要求的 HTML 文件。", "The final delivery does not contain the required HTML file.");
66
+ if (htmlContent === void 0) return unverified(check, "尚未读取最终 HTML 正文。", "The final HTML could not be read.");
67
+ document ??= parseHTML(htmlContent).document;
68
+ let passed;
69
+ let label;
70
+ if (single) {
71
+ passed = Boolean(document.querySelector("html > body"));
72
+ label = zh ? "单文件 HTML 结构" : "single-file HTML structure";
73
+ } else if (css) {
74
+ const style = [...document.querySelectorAll("style")].map((element) => element.textContent ?? "").join("\n");
75
+ passed = Boolean(style.trim() || document.querySelector("[style]")) && !document.querySelector("link[rel~=\"stylesheet\" i]") && !/@import\b/iu.test(style.replace(/\/\*[\s\S]*?\*\//gu, ""));
76
+ label = zh ? "内联样式" : "inline CSS";
77
+ } else {
78
+ passed = Boolean(document.querySelector("body h1")?.textContent?.trim() && document.querySelector("body footer")?.textContent?.trim());
79
+ label = zh ? "页面标题和页脚" : "page heading and footer";
80
+ }
81
+ return checked(check, passed, `最终 HTML 的${label}${passed ? "符合" : "不符合"}要求。`, `The published HTML ${passed ? "meets" : "does not meet"} the requirement for ${label}.`);
82
+ }
83
+ return check;
84
+ });
85
+ return {
86
+ ...result,
87
+ checks
88
+ };
89
+ }
90
+ //#endregion
91
+ export { checkTaskDelivery };
@@ -1,2 +1,4 @@
1
1
  export declare function isChatReplyOutput(output: string): boolean;
2
- export declare function finalReplyCharacterLimit(criterion: string): number | undefined;
2
+ export declare function finalReplyCharacterLimit(criterion: string, chatReplyOnly?: boolean): number | undefined;
3
+ export declare function isChatOnlyDelivery(outputs: string[]): boolean;
4
+ export declare function isReplyLengthCriterion(criterion: string, chatReplyOnly: boolean): boolean;