@xopcai/xopc 0.0.470 → 0.0.472

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 (83) 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/static/root/assets/{apps-page-CXKTWj1s.js → apps-page-BlDivdQ0.js} +1 -1
  4. package/dist/gateway/static/root/assets/{automations-page-DqrAOReO.js → automations-page-36Dx_eLZ.js} +1 -1
  5. package/dist/gateway/static/root/assets/{automations-workspace-BYmFhO8E.js → automations-workspace-BY3P8w5G.js} +4 -4
  6. package/dist/gateway/static/root/assets/capabilities-page-DWslQZCv.js +2 -0
  7. package/dist/gateway/static/root/assets/{capabilities-settings-panel-DfyND0IO.js → capabilities-settings-panel-Drpf_JGM.js} +2 -2
  8. package/dist/gateway/static/root/assets/{channels-DwUmMnA1.js → channels-CjDJ2Mmb.js} +1 -1
  9. package/dist/gateway/static/root/assets/chat-page-D_8adelp.js +72 -0
  10. package/dist/gateway/static/root/assets/{chat-terminal-dock-Dn7Cm1O4.js → chat-terminal-dock-1VI02yzQ.js} +1 -1
  11. package/dist/gateway/static/root/assets/{connectors-page-HHGB3r3Q.js → connectors-page-T7W-zTEK.js} +1 -1
  12. package/dist/gateway/static/root/assets/{extension-debug-page-DIAyDA-a.js → extension-debug-page-DIU2PfhR.js} +1 -1
  13. package/dist/gateway/static/root/assets/{extension-iframe-host-CCe4R7L7.js → extension-iframe-host-0xdd5xm5.js} +1 -1
  14. package/dist/gateway/static/root/assets/{extension-message-router-BD0ZamBV.js → extension-message-router-CN1KAjhe.js} +1 -1
  15. package/dist/gateway/static/root/assets/{extension-page-C09dlV3J.js → extension-page-BiAzQtvI.js} +1 -1
  16. package/dist/gateway/static/root/assets/{extension-provider-BhluafoX.js → extension-provider-CYVVZ21G.js} +1 -1
  17. package/dist/gateway/static/root/assets/{extension-settings-page-CB8KLYoG.js → extension-settings-page-B71tjY9p.js} +1 -1
  18. package/dist/gateway/static/root/assets/{home-page-8KwhWlYt.js → home-page-C79KZbb1.js} +3 -3
  19. package/dist/gateway/static/root/assets/index-55eQOJhF.css +1 -0
  20. package/dist/gateway/static/root/assets/{index-CQNwlXpQ.js → index-Jbmr3G0d.js} +8 -8
  21. package/dist/gateway/static/root/assets/{local-app-workbench-page-DmzgjJNj.js → local-app-workbench-page-TZ7JoORJ.js} +1 -1
  22. package/dist/gateway/static/root/assets/{note-detail-panel-DeFb2HEC.js → note-detail-panel-DFR9Fc16.js} +3 -3
  23. package/dist/gateway/static/root/assets/{notes-page-nvqpOeHp.js → notes-page-Y6jTwZhu.js} +1 -1
  24. package/dist/gateway/static/root/assets/{page-context-capture-button-Cn4zi3Mt.js → page-context-capture-button-zG-782MJ.js} +1 -1
  25. package/dist/gateway/static/root/assets/{personal-page-HFjWZacf.js → personal-page-CNAaIQe_.js} +1 -1
  26. package/dist/gateway/static/root/assets/{personal-profile-settings-CNI5Eor6.js → personal-profile-settings-OoFMAniP.js} +1 -1
  27. package/dist/gateway/static/root/assets/{personal-settings-panel-BcrpYRn9.js → personal-settings-panel-BVv8cYny.js} +1 -1
  28. package/dist/gateway/static/root/assets/{preview-runtime-RnBDP-Lq.js → preview-runtime-pJGZe5Jx.js} +1 -1
  29. package/dist/gateway/static/root/assets/{project-detail-page-Dr5_WPRB.js → project-detail-page-CdIhsx42.js} +1 -1
  30. package/dist/gateway/static/root/assets/{route-preload-D-pdVwIK.js → route-preload-DAyaQF0B.js} +2 -2
  31. package/dist/gateway/static/root/assets/{routine-panel-rjq-8nZ8.js → routine-panel-BsUWc1HR.js} +2 -2
  32. package/dist/gateway/static/root/assets/session-manager-DzSlogQc.js +22 -0
  33. package/dist/gateway/static/root/assets/{settings-page-bCW4rave.js → settings-page-C2DiHQf_.js} +1 -1
  34. package/dist/gateway/static/root/assets/{share-preview-page-nzWjWhqF.js → share-preview-page-DDd5iT5G.js} +1 -1
  35. package/dist/gateway/static/root/assets/{shares-settings-LB3SYKFS.js → shares-settings-Dmk9W8r9.js} +1 -1
  36. package/dist/gateway/static/root/assets/skills-page-DXYcUGzM.js +2 -0
  37. package/dist/gateway/static/root/assets/space-page-fq1NyJx5.js +2 -0
  38. package/dist/gateway/static/root/assets/{task-detail-page-gffrDRvW.js → task-detail-page-DE3BWEBP.js} +1 -1
  39. package/dist/gateway/static/root/assets/{task-header-title-DwtjUOBg.js → task-header-title-BTCuRQKx.js} +1 -1
  40. package/dist/gateway/static/root/assets/{task-result-evidence-Bmgta9z9.js → task-result-evidence-DCHcXh04.js} +1 -1
  41. package/dist/gateway/static/root/assets/{use-composer-attachments-sszsCdh5.js → use-composer-attachments-B6CKcx51.js} +1 -1
  42. package/dist/gateway/static/root/assets/{use-file-preview-expanded-D4b4fDeu.js → use-file-preview-expanded-1ZjXWaYM.js} +1 -1
  43. package/dist/gateway/static/root/assets/{use-personal-work-C-rw8XVO.js → use-personal-work-CwZNBF3F.js} +1 -1
  44. package/dist/gateway/static/root/assets/{use-realtime-voice-cugjs8cK.js → use-realtime-voice-D5-XzM7H.js} +1 -1
  45. package/dist/gateway/static/root/assets/{use-workspace-tree-Crfx5ctU.js → use-workspace-tree-DsuGqCMo.js} +1 -1
  46. package/dist/gateway/static/root/assets/{voice-settings-BzfNK5Jm.js → voice-settings-lJN2e9mQ.js} +1 -1
  47. package/dist/gateway/static/root/assets/{workspace-api-g-wCKoQU.js → workspace-api-CFPK3JR6.js} +2 -2
  48. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-DxaxVC3q.js → workspace-file-preview-dialog-35uL-ra3.js} +1 -1
  49. package/dist/gateway/static/root/index.html +17 -17
  50. package/dist/package.js +1 -1
  51. package/dist/src/agent/inbound/turn-dispatcher.d.ts +2 -0
  52. package/dist/src/agent/inbound/turn-dispatcher.js +3 -1
  53. package/dist/src/agent/service/process-direct-streaming.js +14 -0
  54. package/dist/src/agent/tools/video-draft-tool.js +1 -1
  55. package/dist/src/gateway/chat-stream/mapper.js +10 -4
  56. package/dist/src/gateway/hono/routes/sessions.js +5 -2
  57. package/dist/src/gateway/hono/routes/video-generation.js +6 -5
  58. package/dist/src/gateway/service/session-input-coordinator.d.ts +2 -1
  59. package/dist/src/gateway/service/session-input-coordinator.js +3 -1
  60. package/dist/src/music-generation/artifact.d.ts +1 -1
  61. package/dist/src/music-generation/artifact.js +5 -4
  62. package/dist/src/music-generation/provider.d.ts +1 -0
  63. package/dist/src/music-generation/providers.js +4 -1
  64. package/dist/src/music-generation/worker.js +1 -1
  65. package/dist/src/music-generation/xopc-cloud.js +22 -0
  66. package/dist/src/session/manager.d.ts +3 -1
  67. package/dist/src/session/manager.js +2 -2
  68. package/dist/src/session/store.d.ts +3 -1
  69. package/dist/src/session/store.js +2 -2
  70. package/dist/src/session/user-round-delete.d.ts +3 -1
  71. package/dist/src/session/user-round-delete.js +6 -4
  72. package/dist/src/storage/sqlite/session-turn-replace-repository.js +6 -1
  73. package/dist/src/video-generation/artifact.js +1 -1
  74. package/dist/src/video-generation/drafts.js +3 -3
  75. package/dist/src/video-generation/settings.d.ts +1 -0
  76. package/dist/src/video-generation/settings.js +23 -7
  77. package/package.json +1 -1
  78. package/dist/gateway/static/root/assets/capabilities-page-XgIRdqCb.js +0 -2
  79. package/dist/gateway/static/root/assets/chat-page-DfFXhDRv.js +0 -72
  80. package/dist/gateway/static/root/assets/index-CZUfwwLp.css +0 -1
  81. package/dist/gateway/static/root/assets/session-manager-BVS3zxRZ.js +0 -22
  82. package/dist/gateway/static/root/assets/skills-page-CfhEcU8L.js +0 -2
  83. package/dist/gateway/static/root/assets/space-page-BXyQdUvp.js +0 -2
@@ -11,7 +11,7 @@
11
11
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=20260910-1" />
12
12
  <link rel="manifest" href="/site.webmanifest?v=20260910-1" />
13
13
  <title>XOPC — Keep what matters moving.</title>
14
- <script type="module" crossorigin src="/assets/index-CQNwlXpQ.js"></script>
14
+ <script type="module" crossorigin src="/assets/index-Jbmr3G0d.js"></script>
15
15
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-aKtaBQYM.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/diagnostics-Bo0Z42P_.js">
17
17
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-BOUWij0V.js">
@@ -142,9 +142,9 @@
142
142
  <link rel="modulepreload" crossorigin href="/assets/attachment-utils-core-BPYdUI6y.js">
143
143
  <link rel="modulepreload" crossorigin href="/assets/use-async-resource-BHFGZCY2.js">
144
144
  <link rel="modulepreload" crossorigin href="/assets/files-BNL4kkSB.js">
145
- <link rel="modulepreload" crossorigin href="/assets/workspace-api-g-wCKoQU.js">
145
+ <link rel="modulepreload" crossorigin href="/assets/workspace-api-CFPK3JR6.js">
146
146
  <link rel="modulepreload" crossorigin href="/assets/index.module-Cd9ENXfk.js">
147
- <link rel="modulepreload" crossorigin href="/assets/preview-runtime-RnBDP-Lq.js">
147
+ <link rel="modulepreload" crossorigin href="/assets/preview-runtime-pJGZe5Jx.js">
148
148
  <link rel="modulepreload" crossorigin href="/assets/trash-2-DusmjVPV.js">
149
149
  <link rel="modulepreload" crossorigin href="/assets/user-round-C9jxPhMR.js">
150
150
  <link rel="modulepreload" crossorigin href="/assets/copy-text-row-CpiRzq4G.js">
@@ -159,7 +159,7 @@
159
159
  <link rel="modulepreload" crossorigin href="/assets/gateway-realtime-store-BpnGXAhi.js">
160
160
  <link rel="modulepreload" crossorigin href="/assets/gateway-realtime-BnwNxbyc.js">
161
161
  <link rel="modulepreload" crossorigin href="/assets/agents-admin-api-BL8lN8gP.js">
162
- <link rel="modulepreload" crossorigin href="/assets/session-manager-BVS3zxRZ.js">
162
+ <link rel="modulepreload" crossorigin href="/assets/session-manager-DzSlogQc.js">
163
163
  <link rel="modulepreload" crossorigin href="/assets/new-session-preferences-gb411vZP.js">
164
164
  <link rel="modulepreload" crossorigin href="/assets/open-capability-settings-DQsmJxI7.js">
165
165
  <link rel="modulepreload" crossorigin href="/assets/model-sort-_Tz8s_4N.js">
@@ -182,15 +182,15 @@
182
182
  <link rel="modulepreload" crossorigin href="/assets/voice-CDlC6XMH.js">
183
183
  <link rel="modulepreload" crossorigin href="/assets/activity-store-DKP2sWTJ.js">
184
184
  <link rel="modulepreload" crossorigin href="/assets/composer-notifications-B0IZsy8x.js">
185
- <link rel="modulepreload" crossorigin href="/assets/use-realtime-voice-cugjs8cK.js">
185
+ <link rel="modulepreload" crossorigin href="/assets/use-realtime-voice-D5-XzM7H.js">
186
186
  <link rel="modulepreload" crossorigin href="/assets/voice-call-context-BM2A4bLz.js">
187
187
  <link rel="modulepreload" crossorigin href="/assets/app-chrome-BeB4KgOf.js">
188
188
  <link rel="modulepreload" crossorigin href="/assets/page-header-store-1-lflHAx.js">
189
189
  <link rel="modulepreload" crossorigin href="/assets/new-chat-navigation-DXYDldT_.js">
190
190
  <link rel="modulepreload" crossorigin href="/assets/loopi-CNtmi9FU.js">
191
191
  <link rel="modulepreload" crossorigin href="/assets/theme-store-C1MxmBg7.js">
192
- <link rel="modulepreload" crossorigin href="/assets/extension-message-router-BD0ZamBV.js">
193
- <link rel="modulepreload" crossorigin href="/assets/extension-provider-BhluafoX.js">
192
+ <link rel="modulepreload" crossorigin href="/assets/extension-message-router-CN1KAjhe.js">
193
+ <link rel="modulepreload" crossorigin href="/assets/extension-provider-CYVVZ21G.js">
194
194
  <link rel="modulepreload" crossorigin href="/assets/agent-avatar-display-CIsejg_E.js">
195
195
  <link rel="modulepreload" crossorigin href="/assets/skill-wire-pattern-BPpeIcCi.js">
196
196
  <link rel="modulepreload" crossorigin href="/assets/composer-handoff-params-DBpzHuNo.js">
@@ -205,9 +205,9 @@
205
205
  <link rel="modulepreload" crossorigin href="/assets/constants-D5Z-mUto.js">
206
206
  <link rel="modulepreload" crossorigin href="/assets/sliding-indicator-hwz0sx3h.js">
207
207
  <link rel="modulepreload" crossorigin href="/assets/sliding-tab-list-CmcrqRzN.js">
208
- <link rel="modulepreload" crossorigin href="/assets/use-file-preview-expanded-D4b4fDeu.js">
208
+ <link rel="modulepreload" crossorigin href="/assets/use-file-preview-expanded-1ZjXWaYM.js">
209
209
  <link rel="modulepreload" crossorigin href="/assets/file-preview-surface-CeFFZo3a.js">
210
- <link rel="modulepreload" crossorigin href="/assets/use-composer-attachments-sszsCdh5.js">
210
+ <link rel="modulepreload" crossorigin href="/assets/use-composer-attachments-B6CKcx51.js">
211
211
  <link rel="modulepreload" crossorigin href="/assets/skill-api-utils-C7V4JVXM.js">
212
212
  <link rel="modulepreload" crossorigin href="/assets/skill-list-api-D4eokPXx.js">
213
213
  <link rel="modulepreload" crossorigin href="/assets/command-palette-api-DPtCt8Je.js">
@@ -218,7 +218,7 @@
218
218
  <link rel="modulepreload" crossorigin href="/assets/automation-task-card-BNT3n0qu.js">
219
219
  <link rel="modulepreload" crossorigin href="/assets/dev-view-store-DnQ2nBtV.js">
220
220
  <link rel="modulepreload" crossorigin href="/assets/extension-authoritative-grants-BqtUnmq-.js">
221
- <link rel="modulepreload" crossorigin href="/assets/extension-iframe-host-CCe4R7L7.js">
221
+ <link rel="modulepreload" crossorigin href="/assets/extension-iframe-host-0xdd5xm5.js">
222
222
  <link rel="modulepreload" crossorigin href="/assets/runtime-health-zDkHcOZO.js">
223
223
  <link rel="modulepreload" crossorigin href="/assets/api-V4P8zfkJ.js">
224
224
  <link rel="modulepreload" crossorigin href="/assets/terminal-panel-store-B1bAD5Xf.js">
@@ -228,7 +228,7 @@
228
228
  <link rel="modulepreload" crossorigin href="/assets/page-context-draft-BjbX5zd7.js">
229
229
  <link rel="modulepreload" crossorigin href="/assets/management-api-DG-yZnHK.js">
230
230
  <link rel="modulepreload" crossorigin href="/assets/side-chat-shortcut-BIw-1TTD.js">
231
- <link rel="modulepreload" crossorigin href="/assets/chat-page-DfFXhDRv.js">
231
+ <link rel="modulepreload" crossorigin href="/assets/chat-page-D_8adelp.js">
232
232
  <link rel="modulepreload" crossorigin href="/assets/arrow-right-DSSvoX71.js">
233
233
  <link rel="modulepreload" crossorigin href="/assets/browser-notification-delivery-DmE2FgGc.js">
234
234
  <link rel="modulepreload" crossorigin href="/assets/unlink-NsCMuCT1.js">
@@ -285,7 +285,7 @@
285
285
  <link rel="modulepreload" crossorigin href="/assets/panel-left-C8MqSXRZ.js">
286
286
  <link rel="modulepreload" crossorigin href="/assets/panel-right-CFGrHTsD.js">
287
287
  <link rel="modulepreload" crossorigin href="/assets/wand-sparkles-CkSL-3Fy.js">
288
- <link rel="modulepreload" crossorigin href="/assets/use-personal-work-C-rw8XVO.js">
288
+ <link rel="modulepreload" crossorigin href="/assets/use-personal-work-CwZNBF3F.js">
289
289
  <link rel="modulepreload" crossorigin href="/assets/pin-off-BMRv-Kxr.js">
290
290
  <link rel="modulepreload" crossorigin href="/assets/power-ZI-pBczI.js">
291
291
  <link rel="modulepreload" crossorigin href="/assets/puzzle-BptcPjKI.js">
@@ -306,16 +306,16 @@
306
306
  <link rel="modulepreload" crossorigin href="/assets/preference-select-fields-BKmzpfHq.js">
307
307
  <link rel="modulepreload" crossorigin href="/assets/navigation-ByOzYT0t.js">
308
308
  <link rel="modulepreload" crossorigin href="/assets/page-tabs-oeTY7z3_.js">
309
- <link rel="modulepreload" crossorigin href="/assets/route-preload-D-pdVwIK.js">
309
+ <link rel="modulepreload" crossorigin href="/assets/route-preload-DAyaQF0B.js">
310
310
  <link rel="modulepreload" crossorigin href="/assets/use-personal-profile-CNPszzzT.js">
311
311
  <link rel="modulepreload" crossorigin href="/assets/personal-avatar-CM3vUGhL.js">
312
312
  <link rel="modulepreload" crossorigin href="/assets/project-understanding-Dv26vu9S.js">
313
313
  <link rel="modulepreload" crossorigin href="/assets/refresh-button-DiWdGAaX.js">
314
314
  <link rel="modulepreload" crossorigin href="/assets/file-tree-CYUkQR1t.js">
315
- <link rel="modulepreload" crossorigin href="/assets/workspace-file-preview-dialog-DxaxVC3q.js">
316
- <link rel="modulepreload" crossorigin href="/assets/use-workspace-tree-Crfx5ctU.js">
315
+ <link rel="modulepreload" crossorigin href="/assets/workspace-file-preview-dialog-35uL-ra3.js">
316
+ <link rel="modulepreload" crossorigin href="/assets/use-workspace-tree-DsuGqCMo.js">
317
317
  <link rel="modulepreload" crossorigin href="/assets/date-formatters-DukWSVwc.js">
318
- <link rel="modulepreload" crossorigin href="/assets/task-header-title-DwtjUOBg.js">
318
+ <link rel="modulepreload" crossorigin href="/assets/task-header-title-BTCuRQKx.js">
319
319
  <link rel="modulepreload" crossorigin href="/assets/date-time-picker--LGC1D3b.js">
320
320
  <link rel="modulepreload" crossorigin href="/assets/settings-mode-store-Dk0bZQgo.js">
321
321
  <link rel="modulepreload" crossorigin href="/assets/global-defaults-api-CNyJ0dGb.js">
@@ -327,7 +327,7 @@
327
327
  <link rel="stylesheet" crossorigin href="/assets/loopi-C09I2mNj.css">
328
328
  <link rel="stylesheet" crossorigin href="/assets/chat-page-zQeUaawJ.css">
329
329
  <link rel="stylesheet" crossorigin href="/assets/personal-avatar-DsEp8QJ7.css">
330
- <link rel="stylesheet" crossorigin href="/assets/index-CZUfwwLp.css">
330
+ <link rel="stylesheet" crossorigin href="/assets/index-55eQOJhF.css">
331
331
  </head>
332
332
  <body>
333
333
  <div id="root"></div>
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.0.470";
2
+ var version = "0.0.472";
3
3
  //#endregion
4
4
  export { version };
@@ -15,6 +15,7 @@
15
15
  * in their own classes and are unit-testable.
16
16
  */
17
17
  import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol';
18
+ import type { UserTurnDocument } from '@xopcai/gateway-contract';
18
19
  import type { Config } from '../../config/schema.js';
19
20
  import type { ContextualLogger } from '../../utils/logger/types.js';
20
21
  import type { AgentManager } from '../agent-manager.js';
@@ -97,6 +98,7 @@ export declare class TurnDispatcher {
97
98
  sourceContexts?: AgentSourceContext[];
98
99
  voiceAgentInstruction?: boolean;
99
100
  clientMessageId?: string;
101
+ userTurnDocument?: UserTurnDocument;
100
102
  onHandled?: () => void;
101
103
  }): Promise<boolean>;
102
104
  private buildStreamingDeps;
@@ -103,6 +103,7 @@ var TurnDispatcher = class {
103
103
  clientMessageId: options.clientMessageId,
104
104
  steered: true
105
105
  } : {},
106
+ ...options.userTurnDocument ? { userTurnDocument: options.userTurnDocument } : {},
106
107
  ...options.sourceContexts?.length ? { sourceContexts: options.sourceContexts.map(summarizeSourceContext) } : {}
107
108
  }
108
109
  };
@@ -124,7 +125,8 @@ var TurnDispatcher = class {
124
125
  timestamp: Date.now(),
125
126
  metadata: {
126
127
  clientMessageId: options.clientMessageId,
127
- steered: true
128
+ steered: true,
129
+ ...options.userTurnDocument ? { userTurnDocument: options.userTurnDocument } : {}
128
130
  }
129
131
  },
130
132
  onHandled: options.onHandled
@@ -9,6 +9,7 @@ import { readAgentMessageContent } from "../memory/agent-message-access.js";
9
9
  import { getClarificationResumeInput } from "../../storage/sqlite/clarification-wait-repository.js";
10
10
  import { init_model_usage, modelUsageOriginFromTurn, withModelUsageOrigin } from "../../providers/model-usage.js";
11
11
  import { init_agent_session_key, resolveAgentMainConversationId } from "../../routing/agent-session-key.js";
12
+ import { onSessionTranscriptUpdate } from "../../session/transcript-events.js";
12
13
  import { clearPendingTranscriptUserMessage, setPendingTranscriptUserMessage } from "../inbound/attachment-pipeline.js";
13
14
  import { abortEmbeddedRun } from "../embedded/runs.js";
14
15
  import { phoneResumeForRun } from "../../phone/assistance.js";
@@ -173,6 +174,18 @@ async function* runProcessDirectStreamingInner(deps, input) {
173
174
  });
174
175
  };
175
176
  if (channel === "webchat") deps.registerWebchatStreamPublisher(conversationId, pushVisible);
177
+ const stopSteerEvents = channel === "webchat" && input.runId ? onSessionTranscriptUpdate((update) => {
178
+ if (update.conversationId !== conversationId) return;
179
+ const message = update.message;
180
+ if (message?.role !== "user" || message.turnId !== input.runId || !message.metadata?.steered || !message.metadata.clientMessageId) return;
181
+ pushVisible({
182
+ type: "user_message",
183
+ content: message.content,
184
+ timestamp: message.timestamp,
185
+ media: message.media,
186
+ metadata: message.metadata
187
+ });
188
+ }) : void 0;
176
189
  const signal = input.signal;
177
190
  let userAborted = false;
178
191
  let abortHandled = false;
@@ -441,6 +454,7 @@ async function* runProcessDirectStreamingInner(deps, input) {
441
454
  }
442
455
  deps.recordTaskReviewStreamHint?.(conversationId, { skipTaskReview: ranSlashCommand });
443
456
  } finally {
457
+ stopSteerEvents?.();
444
458
  if (channel === "webchat") deps.unregisterWebchatStreamPublisher(conversationId);
445
459
  deps.endDirectRequestContext();
446
460
  }
@@ -35,7 +35,7 @@ function createVideoDraftTool(getConversationId) {
35
35
  return {
36
36
  name: "video_draft",
37
37
  label: "Prepare video draft",
38
- description: "Prepare a video when the user asks to generate one in Web chat. Create a draft, update the pending draft, or revise the last submitted video as a new version. For a new draft, a single image in the current user message is used by default. An update or revision keeps its reference image unless the user requests another one; use image=current to switch to a new attachment. Use inspect to list recent images and the previous draft. Ask which image to use when the reference is ambiguous. Use video settings for any unspecified options. Provide a short scene summary alongside the full prompt. The draft appears as a card. When first presenting it, briefly tell the user they can click Confirm generation or reply “confirm video generation” / “就按这个生成”. This tool cannot start generation.",
38
+ description: "Prepare a video when the user asks to generate one in Web chat. Create a draft, update the pending draft, or revise the last submitted video as a new version. For a new draft, a single image in the current user message is used by default. An update or revision keeps its reference image unless the user requests another one; use image=current to switch to a new attachment. Use inspect to list recent images and the previous draft. Ask which image to use when the reference is ambiguous. Use video settings for any unspecified options. Provide a short scene summary alongside the full prompt. The draft appears as a card. When presenting a new or updated draft, tell the user to confirm using the button on the card, in the language of the reply. For Chinese replies, use “点击卡片上的「确认生成」,或回复「就按这个生成」。” For English replies, also offer “confirm video generation” as a reply. This tool cannot start generation.",
39
39
  parameters: schema,
40
40
  async execute(_id, args) {
41
41
  if (!Value.Check(schema, args)) throw new Error("Invalid video draft parameters.");
@@ -3,6 +3,7 @@ import { resolveToolActivity } from "../../../packages/gateway-contract/src/tool
3
3
  import { isUserTurnDocument } from "../../../packages/gateway-contract/src/user-turn-document.js";
4
4
  import { readClarificationPresentation } from "../../../packages/gateway-contract/src/clarifications.js";
5
5
  import { init_src } from "../../../packages/gateway-contract/src/index.js";
6
+ import { stripRuntimeContextFromUserContent } from "../../session/user-message-display.js";
6
7
  import { productDeliveries } from "../../session/compact-history.js";
7
8
  import { createPetFeedback } from "./pet-feedback.js";
8
9
  //#region src/gateway/chat-stream/mapper.ts
@@ -449,10 +450,11 @@ var ChatStreamMapper = class {
449
450
  }
450
451
  };
451
452
  function userMessageFromEvent(event, turnId) {
453
+ const content = event.content;
452
454
  return {
453
455
  role: "user",
454
456
  turnId,
455
- content: event.content ?? [],
457
+ content: typeof content === "string" || Array.isArray(content) ? stripRuntimeContextFromUserContent(content) : [],
456
458
  attachments: event.media,
457
459
  metadata: userMessageDisplayMetadata(event.metadata),
458
460
  timestamp: typeof event.timestamp === "number" ? event.timestamp : Date.now()
@@ -462,8 +464,11 @@ function userMessageDisplayMetadata(value) {
462
464
  const metadata = asRecord(value);
463
465
  const rows = metadata?.sourceContexts;
464
466
  const userTurnDocument = isUserTurnDocument(metadata?.userTurnDocument) ? metadata.userTurnDocument : void 0;
465
- if (!Array.isArray(rows)) return userTurnDocument ? { userTurnDocument } : void 0;
466
- const sourceContexts = rows.flatMap((value) => {
467
+ const steer = metadata?.steered === true && typeof metadata.clientMessageId === "string" ? {
468
+ steered: true,
469
+ clientMessageId: metadata.clientMessageId
470
+ } : void 0;
471
+ const sourceContexts = (Array.isArray(rows) ? rows : []).flatMap((value) => {
467
472
  const row = asRecord(value);
468
473
  if (row?.kind !== "note" && row?.kind !== "task" && row?.kind !== "file" && row?.kind !== "session" && row?.kind !== "browser_tab" && row?.kind !== "mcp_resource" || typeof row.sourceId !== "string" || typeof row.version !== "string" || typeof row.title !== "string") return [];
469
474
  return [{
@@ -477,7 +482,8 @@ function userMessageDisplayMetadata(value) {
477
482
  ...row.kind === "file" && (row.fileKind === "file" || row.fileKind === "directory") ? { fileKind: row.fileKind } : {}
478
483
  }];
479
484
  });
480
- return sourceContexts.length > 0 || userTurnDocument ? {
485
+ return sourceContexts.length > 0 || userTurnDocument || steer ? {
486
+ ...steer,
481
487
  ...sourceContexts.length > 0 ? { sourceContexts } : {},
482
488
  ...userTurnDocument ? { userTurnDocument } : {}
483
489
  } : void 0;
@@ -875,8 +875,11 @@ function registerSessionsRoutes(authenticated, deps) {
875
875
  if (service.voiceRealtime?.hasConversation(key)) return c.json({ error: "End the voice call before editing its history" }, 409);
876
876
  const body = await c.req.json().catch(() => ({}));
877
877
  const userRoundIndex = typeof body.userRoundIndex === "number" ? body.userRoundIndex : void 0;
878
- if (userRoundIndex === void 0 || !Number.isInteger(userRoundIndex) || userRoundIndex < 0) return c.json({ error: "userRoundIndex must be a non-negative integer" }, 400);
879
- const result = await service.sessionIndexInstance.deleteUserRound(key, userRoundIndex);
878
+ const steerId = typeof body.steerId === "string" ? body.steerId.trim() : "";
879
+ if (steerId && (steerId.length > 128 || body.userRoundIndex !== void 0)) return c.json({ error: "Specify one valid message target" }, 400);
880
+ const target = steerId ? { steerId } : userRoundIndex;
881
+ if (target === void 0 || typeof target === "number" && (!Number.isInteger(target) || target < 0)) return c.json({ error: "userRoundIndex must be a non-negative integer" }, 400);
882
+ const result = await service.sessionIndexInstance.deleteUserRound(key, target);
880
883
  if (!result) return c.json({ error: "User round index out of range" }, 400);
881
884
  await deleteMediaUrisNoLongerReferenced({
882
885
  removed: result.removedMessages,
@@ -1,8 +1,8 @@
1
1
  import { init_transaction, runSqliteWriteTransaction } from "../../../storage/sqlite/transaction.js";
2
- import { VIDEO_IMAGE_MAX_BYTES, VIDEO_MODELS, VIDEO_MODEL_REFS, VIDEO_RESOLUTIONS, WAN_VIDEO_MODEL_REF, isVideoDurationSupported } from "../../../../packages/gateway-contract/src/video-generation.js";
2
+ import { VIDEO_IMAGE_MAX_BYTES, VIDEO_MODEL_REFS, VIDEO_RESOLUTIONS, WAN_VIDEO_MODEL_REF, isVideoDurationSupported } from "../../../../packages/gateway-contract/src/video-generation.js";
3
3
  import { init_src } from "../../../../packages/gateway-contract/src/index.js";
4
4
  import { readMediaReference } from "../../../media/media-reference.js";
5
- import { getVideoDefaults, getVideoModel, setVideoDefaults, setVideoModel } from "../../../video-generation/settings.js";
5
+ import { getVideoDefaults, getVideoModel, getVideoModelDefinition, setVideoDefaults, setVideoModel } from "../../../video-generation/settings.js";
6
6
  import { enqueueVideoJob, getVideoJob, listVideoJobs } from "../../../video-generation/repository.js";
7
7
  import { getVideoDraft } from "../../../video-generation/drafts.js";
8
8
  import { readVideoArtifact } from "../../../video-generation/artifact.js";
@@ -59,7 +59,8 @@ async function videoSettings() {
59
59
  modelRef,
60
60
  defaults: getVideoDefaults(modelRef),
61
61
  configured,
62
- modelRefs: [...new Set([...getAvailableVideoModelRefs(), modelRef])]
62
+ modelRefs: [...new Set([...getAvailableVideoModelRefs(), modelRef])],
63
+ models: Object.fromEntries(getAvailableVideoModelRefs().map((ref) => [ref, getVideoModelDefinition(ref)]))
63
64
  };
64
65
  }
65
66
  function registerVideoGenerationRoutes(app, deps) {
@@ -79,7 +80,7 @@ function registerVideoGenerationRoutes(app, deps) {
79
80
  }).safeParse(await c.req.json().catch(() => null));
80
81
  if (!parsed.success) return c.json({ error: "Invalid video defaults" }, 400);
81
82
  const { modelRef, duration, resolution } = parsed.data;
82
- const model = VIDEO_MODELS[modelRef];
83
+ const model = getVideoModelDefinition(modelRef);
83
84
  if (!isVideoDurationSupported(model, duration) || !model.resolutions.includes(resolution)) return c.json({ error: "The selected model does not support these video defaults" }, 400);
84
85
  setVideoDefaults(modelRef, {
85
86
  duration,
@@ -130,7 +131,7 @@ function registerVideoGenerationRoutes(app, deps) {
130
131
  const { imageUri, modelRef, ...request } = parsed.data;
131
132
  const upload = form?.get("image") ?? null;
132
133
  if (upload !== null && (!(upload instanceof File) || imageUri || !upload.size || upload.size > 5242880)) return c.json({ error: "Provide one PNG, JPEG or WebP image up to 5 MiB" }, 400);
133
- const model = VIDEO_MODELS[modelRef];
134
+ const model = getVideoModelDefinition(modelRef);
134
135
  const hasImage = Boolean(upload || imageUri);
135
136
  if (!isVideoDurationSupported(model, request.duration) || !model.resolutions.includes(request.resolution) || hasImage && !model.imageRatios.includes(request.ratio)) return c.json({ error: "The selected model does not support these video settings" }, 400);
136
137
  let bytes;
@@ -1,4 +1,4 @@
1
- import { type SessionInputControlCommand } from '@xopcai/gateway-contract';
1
+ import { parseUserTurnDocument, type SessionInputControlCommand } from '@xopcai/gateway-contract';
2
2
  import { type PhoneAssistance } from '../../phone/assistance.js';
3
3
  import type { TurnOrigin } from '@xopcai/endpoint-tools-protocol';
4
4
  import type { ConnectionWait } from '@xopcai/gateway-contract';
@@ -66,6 +66,7 @@ export declare class SessionInputCoordinator {
66
66
  sourceContexts?: AgentSourceContext[];
67
67
  voiceAgentInstruction?: boolean;
68
68
  clientMessageId?: string;
69
+ userTurnDocument?: NonNullable<ReturnType<typeof parseUserTurnDocument>>;
69
70
  onHandled?: () => void;
70
71
  }) => Promise<boolean>;
71
72
  emit: (type: string, payload: unknown) => void;
@@ -300,7 +300,7 @@ var SessionInputCoordinator = class {
300
300
  }
301
301
  const target = validateLatestSessionTurnTarget(conversationId, targetTurnId);
302
302
  if (target.ok === false) return target;
303
- const original = findSessionInputByRunId(conversationId, targetTurnId);
303
+ const original = targetTurnId.startsWith("steer:") ? findSessionInput(conversationId, targetTurnId.slice(6)) : findSessionInputByRunId(conversationId, targetTurnId);
304
304
  if (original) {
305
305
  input.origin = original.origin;
306
306
  input.sourceContexts = [...(input.sourceContexts ?? []).filter((source) => source.kind !== "device_context"), ...(original.contextSnapshots ?? []).filter((source) => source.kind === "device_context")];
@@ -506,6 +506,7 @@ var SessionInputCoordinator = class {
506
506
  }
507
507
  steerInput(row, runId) {
508
508
  const text = steeringText(row.content, row.contextSnapshots);
509
+ const userTurnDocument = parseUserTurnDocument(row.content);
509
510
  const voiceAgentInstruction = isNaturalVoiceDelegation(row);
510
511
  const trackDelivery = row.origin.type === "endpoint";
511
512
  if (!trackDelivery && !voiceAgentInstruction && !row.attachments?.length && !row.contextSnapshots?.length) return this.deps.steer(row.conversationId, text, runId);
@@ -515,6 +516,7 @@ var SessionInputCoordinator = class {
515
516
  ...voiceAgentInstruction ? { voiceAgentInstruction: true } : {},
516
517
  ...trackDelivery ? {
517
518
  clientMessageId: row.clientMessageId,
519
+ ...userTurnDocument ? { userTurnDocument } : {},
518
520
  onHandled: () => {
519
521
  const current = getSessionInputById(row.conversationId, row.id);
520
522
  if (current?.status === "injecting" && current.targetRunId === runId) setSessionInputStatus(row.id, "completed");
@@ -1,5 +1,5 @@
1
1
  import type { MusicProvider } from './provider.js';
2
2
  export declare function musicArtifactExists(id: string): Promise<boolean>;
3
3
  export declare function deleteMusicArtifact(id: string): Promise<void>;
4
- export declare function saveMusicArtifact(id: string, provider: MusicProvider, source: string, canPublish: () => boolean): Promise<void>;
4
+ export declare function saveMusicArtifact(id: string, provider: MusicProvider, source: string, canPublish: () => boolean, key?: string): Promise<void>;
5
5
  export declare function readMusicArtifact(id: string, rangeHeader?: string, download?: boolean): Promise<Response>;
@@ -21,9 +21,10 @@ async function musicArtifactExists(id) {
21
21
  async function deleteMusicArtifact(id) {
22
22
  await deleteMediaUris([buildMediaUri("outbound", `music-${id}.mp3`)], { strict: true });
23
23
  }
24
- async function saveMusicArtifact(id, provider, source, canPublish) {
24
+ async function saveMusicArtifact(id, provider, source, canPublish, key) {
25
25
  const url = new URL(source);
26
- if (url.protocol !== "https:" || url.username || url.password || url.port || !provider.allowsAudioHost(url.hostname)) throw new Error("Music provider returned an untrusted audio URL.");
26
+ const download = provider.downloadAudio && key ? () => provider.downloadAudio(key, url) : void 0;
27
+ if (url.protocol !== "https:" || url.username || url.password || url.port || !download && !provider.allowsAudioHost(url.hostname)) throw new Error("Music provider returned an untrusted audio URL.");
27
28
  await assertSafeUrl(url);
28
29
  const path = artifactPath(id);
29
30
  const temporary = `${path}.${randomUUID()}.part`;
@@ -31,7 +32,7 @@ async function saveMusicArtifact(id, provider, source, canPublish) {
31
32
  recursive: true,
32
33
  mode: 448
33
34
  });
34
- const response = await fetch(url, {
35
+ const response = download ? await download() : await fetch(url, {
35
36
  signal: AbortSignal.timeout(45e3),
36
37
  redirect: "error"
37
38
  });
@@ -50,7 +51,7 @@ async function saveMusicArtifact(id, provider, source, canPublish) {
50
51
  flags: "wx",
51
52
  mode: 384
52
53
  }));
53
- const file = await open(temporary, "r");
54
+ const file = await open(temporary, "r+");
54
55
  try {
55
56
  const header = Buffer.alloc(10);
56
57
  const { bytesRead } = await file.read(header);
@@ -27,6 +27,7 @@ export interface MusicProvider {
27
27
  submit(key: string, model: string, input: MusicInput): Promise<string>;
28
28
  query(key: string, mode: MusicMode, taskId: string): Promise<MusicProviderStatus>;
29
29
  allowsAudioHost(host: string): boolean;
30
+ downloadAudio?(key: string, url: URL): Promise<Response>;
30
31
  }
31
32
  export declare class MusicRequestRejected extends Error {
32
33
  readonly code: Extract<MusicJobErrorCode, 'provider_rate_limited' | 'provider_rejected'>;
@@ -26,8 +26,11 @@ function resolveMusicModel(ref) {
26
26
  }
27
27
  function selectedMusicModel() {
28
28
  const ref = storedMusicModel() ?? process.env.XOPC_MUSIC_MODEL?.trim();
29
- if (ref && resolveMusicModel(ref)) return ref;
30
29
  const cloud = getCloudMediaDefault("music");
30
+ if (ref && resolveMusicModel(ref)) {
31
+ if (cloud === "xopc-cloud/music" && ref.startsWith("xopc-cloud/") && !getCloudMediaModels("music").some((item) => `xopc-cloud/${item.id}` === ref)) return cloud;
32
+ return ref;
33
+ }
31
34
  return cloud && resolveMusicModel(cloud) ? cloud : DEFAULT_MUSIC_MODEL;
32
35
  }
33
36
  function hasMusicProvider(id) {
@@ -109,7 +109,7 @@ var MusicGenerationWorker = class {
109
109
  keepLease: true
110
110
  })) return;
111
111
  saving = true;
112
- await saveMusicArtifact(id, provider, result.url, () => updateMusicJob(id, token, "saving", { keepLease: true }));
112
+ await saveMusicArtifact(id, provider, result.url, () => updateMusicJob(id, token, "saving", { keepLease: true }), key);
113
113
  if (await musicArtifactExists(id)) updateMusicJob(id, token, "completed");
114
114
  if (!getMusicJob(row.conversation_id, id)) await deleteMusicArtifact(id);
115
115
  }
@@ -1,12 +1,19 @@
1
+ import { init_xopc_cloud_config, resolveXopcModelRouterUrl } from "../providers/xopc-cloud-config.js";
1
2
  import { CLOUD_MEDIA_PROVIDER, CloudMediaError, queryCloudMedia, submitCloudMedia } from "../providers/xopc-cloud-media.js";
2
3
  import { MusicRequestRejected } from "./provider.js";
3
4
  import { murekaGlobalProvider, murekaProvider } from "./mureka.js";
4
5
  import { tencentMpsProvider } from "./tencent-mps.js";
6
+ //#region src/music-generation/xopc-cloud.ts
7
+ init_xopc_cloud_config();
5
8
  const cloudMusicProvider = {
6
9
  id: CLOUD_MEDIA_PROVIDER,
7
10
  name: "XOPC Cloud",
8
11
  models: {
9
12
  music: murekaProvider.models["mureka-9.5"],
13
+ "music-mureka-cn": {
14
+ ...murekaProvider.models["mureka-9.5"],
15
+ name: "mureka-9.5 (China)"
16
+ },
10
17
  "music-mureka-global": {
11
18
  ...murekaGlobalProvider.models["mureka-9.5"],
12
19
  name: "mureka-9.5 (Global)"
@@ -15,6 +22,21 @@ const cloudMusicProvider = {
15
22
  },
16
23
  environmentKey: () => void 0,
17
24
  allowsAudioHost: (host) => murekaProvider.allowsAudioHost(host) || tencentMpsProvider.allowsAudioHost(host),
25
+ async downloadAudio(token, url) {
26
+ const router = new URL(resolveXopcModelRouterUrl());
27
+ const prefix = `${router.pathname.replace(/\/$/, "")}/music/generations/`;
28
+ const route = url.pathname.slice(prefix.length);
29
+ if (url.origin === router.origin && url.pathname.startsWith(prefix) && /^[\da-f-]{36}\/audio$/i.test(route) && !url.search && !url.hash) return fetch(url, {
30
+ headers: { Authorization: `Bearer ${token}` },
31
+ signal: AbortSignal.timeout(45e3),
32
+ redirect: "error"
33
+ });
34
+ if (!cloudMusicProvider.allowsAudioHost(url.hostname)) throw new Error("Music provider returned an untrusted audio URL.");
35
+ return fetch(url, {
36
+ signal: AbortSignal.timeout(45e3),
37
+ redirect: "error"
38
+ });
39
+ },
18
40
  async submit(token, model, input) {
19
41
  try {
20
42
  return await submitCloudMedia("music", token, {
@@ -137,7 +137,9 @@ export declare class SessionIndex extends EventEmitter {
137
137
  saveMessages(key: string, messages: any[], options?: {
138
138
  metadata?: SessionMetadataSeed;
139
139
  }): Promise<void>;
140
- deleteUserRound(key: string, userRoundIndex: number): Promise<{
140
+ deleteUserRound(key: string, target: number | {
141
+ steerId: string;
142
+ }): Promise<{
141
143
  deleted: number;
142
144
  removedMessages: import("@earendil-works/pi-agent-core").AgentMessage[];
143
145
  remainingMessages: import("@earendil-works/pi-agent-core").AgentMessage[];
@@ -236,8 +236,8 @@ var SessionIndex = class extends EventEmitter$1 {
236
236
  async saveMessages(key, messages, options) {
237
237
  return this.store.saveMessages(key, messages, options);
238
238
  }
239
- async deleteUserRound(key, userRoundIndex) {
240
- const result = await this.store.deleteUserRound(key, userRoundIndex);
239
+ async deleteUserRound(key, target) {
240
+ const result = await this.store.deleteUserRound(key, target);
241
241
  if (result) this.emit("sessionUpdated", { key });
242
242
  return result;
243
243
  }
@@ -170,7 +170,9 @@ export declare class SessionStore {
170
170
  saveMessages(key: string, messages: AgentMessage[], options?: {
171
171
  metadata?: SessionMetadataSeed;
172
172
  }): Promise<void>;
173
- deleteUserRound(key: string, userRoundIndex: number): Promise<{
173
+ deleteUserRound(key: string, target: number | {
174
+ steerId: string;
175
+ }): Promise<{
174
176
  deleted: number;
175
177
  removedMessages: AgentMessage[];
176
178
  remainingMessages: AgentMessage[];
@@ -520,11 +520,11 @@ var SessionStore = class {
520
520
  replaceTranscriptRows(key, mergeLlmMessagesPreservingContextRows(await this.loadTranscriptRows(key), messages));
521
521
  });
522
522
  }
523
- async deleteUserRound(key, userRoundIndex) {
523
+ async deleteUserRound(key, target) {
524
524
  return this.runStoreMutation(async () => {
525
525
  requireXopcDatabase();
526
526
  const canonicalRows = (await this.loadTranscriptRows(key)).filter((row) => !isTranscriptCompactionEntry(row) && !isRuntimeOnlyTranscriptMessage(row));
527
- const range = computeTranscriptUserRoundDeleteRange(canonicalRows, userRoundIndex);
527
+ const range = computeTranscriptUserRoundDeleteRange(canonicalRows, target);
528
528
  if (!range) return null;
529
529
  const removedRows = canonicalRows.slice(range.startIndex, range.startIndex + range.count);
530
530
  const remainingRows = canonicalRows.slice(0, range.startIndex).concat(canonicalRows.slice(range.startIndex + range.count));
@@ -1,6 +1,8 @@
1
1
  import { type TranscriptStoredRow } from './session-context-for-llm.js';
2
2
  /** Raw transcript range for one UI-visible user turn. */
3
- export declare function computeTranscriptUserRoundDeleteRange(rows: readonly TranscriptStoredRow[], userRoundIndex: number): {
3
+ export declare function computeTranscriptUserRoundDeleteRange(rows: readonly TranscriptStoredRow[], target: number | {
4
+ steerId: string;
5
+ }): {
4
6
  startIndex: number;
5
7
  count: number;
6
8
  } | null;
@@ -6,13 +6,15 @@ function isVisibleUserRow(row) {
6
6
  return row.role === "user";
7
7
  }
8
8
  /** Raw transcript range for one UI-visible user turn. */
9
- function computeTranscriptUserRoundDeleteRange(rows, userRoundIndex) {
10
- if (!Number.isInteger(userRoundIndex) || userRoundIndex < 0 || rows.length === 0) return null;
9
+ function computeTranscriptUserRoundDeleteRange(rows, target) {
10
+ if (typeof target === "number" && (!Number.isInteger(target) || target < 0)) return null;
11
11
  let userCount = 0;
12
12
  let startIndex = -1;
13
13
  for (let index = 0; index < rows.length; index += 1) {
14
- if (!isVisibleUserRow(rows[index])) continue;
15
- if (userCount === userRoundIndex) {
14
+ const row = rows[index];
15
+ if (!isVisibleUserRow(row)) continue;
16
+ const { role, metadata } = row;
17
+ if (typeof target === "number" ? userCount === target : role === "user" && metadata?.steered === true && metadata.clientMessageId === target.steerId) {
16
18
  startIndex = index;
17
19
  break;
18
20
  }
@@ -18,7 +18,12 @@ function rowTurnId(row) {
18
18
  return typeof value === "string" && value.trim() ? value.trim() : void 0;
19
19
  }
20
20
  function validateTargetRows(rows, targetTurnId) {
21
- const targetIndex = rows.findIndex((row) => row.role === "user" && rowTurnId(row) === targetTurnId);
21
+ const targetIndex = rows.findIndex((row) => {
22
+ const { role, metadata } = row;
23
+ if (role !== "user") return false;
24
+ if (metadata?.steered && metadata.clientMessageId) return `steer:${metadata.clientMessageId}` === targetTurnId;
25
+ return rowTurnId(row) === targetTurnId;
26
+ });
22
27
  if (targetIndex < 0) return {
23
28
  ok: false,
24
29
  code: "TARGET_NOT_FOUND"
@@ -37,7 +37,7 @@ async function storeVideoArtifact(jobId, response) {
37
37
  flags: "wx",
38
38
  mode: 384
39
39
  }));
40
- const file = await open(temporary, "r");
40
+ const file = await open(temporary, "r+");
41
41
  try {
42
42
  const header = Buffer.alloc(12);
43
43
  const { bytesRead } = await file.read(header);
@@ -1,11 +1,11 @@
1
- import { VIDEO_MODELS, estimateVideoCostFen, isVideoDurationSupported } from "../../packages/gateway-contract/src/video-generation.js";
1
+ import { estimateVideoCostFen, isVideoDurationSupported } from "../../packages/gateway-contract/src/video-generation.js";
2
2
  import { init_src } from "../../packages/gateway-contract/src/index.js";
3
3
  import { DurableState } from "../storage/sqlite/durable-state.js";
4
4
  import { getCurrentTranscriptId, init_session_repository } from "../storage/sqlite/session-repository.js";
5
5
  import { loadRecentUserTranscriptRows } from "../storage/sqlite/transcript-repository.js";
6
6
  import { getActiveTranscriptUserMedia } from "../agent/inbound/attachment-pipeline.js";
7
7
  import { getCloudMediaModels } from "../providers/xopc-cloud-media.js";
8
- import { getVideoDefaults, getVideoModel } from "./settings.js";
8
+ import { getVideoDefaults, getVideoModel, getVideoModelDefinition } from "./settings.js";
9
9
  import { getVideoJob } from "./repository.js";
10
10
  import { randomUUID } from "node:crypto";
11
11
  //#region src/video-generation/drafts.ts
@@ -40,7 +40,7 @@ function prepareVideoDraft(conversationId, input) {
40
40
  if (input.action === "create" && previous && !job) throw new Error("A video draft is already pending. Update it instead.");
41
41
  const base = input.action === "create" ? void 0 : previous;
42
42
  const modelRef = getVideoModel();
43
- const model = VIDEO_MODELS[modelRef];
43
+ const model = getVideoModelDefinition(modelRef);
44
44
  const defaults = getVideoDefaults(modelRef);
45
45
  const prompt = (input.prompt ?? base?.prompt ?? "").trim();
46
46
  if (!prompt || prompt.length > 1e3) throw new Error("Provide a video description of 1–1000 characters.");
@@ -2,5 +2,6 @@ import { type VideoGenerationDefaults, type VideoModelRef } from '@xopcai/gatewa
2
2
  export declare function storedVideoModel(): VideoModelRef | undefined;
3
3
  export declare function getVideoModel(): VideoModelRef;
4
4
  export declare function setVideoModel(modelRef: VideoModelRef): void;
5
+ export declare function getVideoModelDefinition(ref: VideoModelRef): import("@xopcai/gateway-contract").VideoModelDefinition;
5
6
  export declare function getVideoDefaults(modelRef: VideoModelRef): VideoGenerationDefaults;
6
7
  export declare function setVideoDefaults(modelRef: VideoModelRef, value: VideoGenerationDefaults): void;