@xopcai/xopc 0.0.471 → 0.0.473
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/discord/src/index.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{apps-page-O944fHx0.js → apps-page-BlDivdQ0.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-Cflfmbrc.js → automations-page-BoYv4mr2.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-DM6e37bB.js → automations-workspace-DdHpajzk.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-page-DYU6WSde.js → capabilities-page-DWslQZCv.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-DfyND0IO.js → capabilities-settings-panel-Drpf_JGM.js} +2 -2
- package/dist/gateway/static/root/assets/{channels-DwUmMnA1.js → channels-CjDJ2Mmb.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-page-C0ONpQcA.js → chat-page-4Agzfc_0.js} +30 -30
- package/dist/gateway/static/root/assets/{chat-terminal-dock-Dn7Cm1O4.js → chat-terminal-dock-1VI02yzQ.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-DfDVgGh_.js → connectors-page-T7W-zTEK.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DIAyDA-a.js → extension-debug-page-DIU2PfhR.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-CCe4R7L7.js → extension-iframe-host-0xdd5xm5.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-message-router-BD0ZamBV.js → extension-message-router-CN1KAjhe.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-C09dlV3J.js → extension-page-BiAzQtvI.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-BhluafoX.js → extension-provider-CYVVZ21G.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CB8KLYoG.js → extension-settings-page-B71tjY9p.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-8KwhWlYt.js → home-page-C79KZbb1.js} +3 -3
- package/dist/gateway/static/root/assets/{index-CwEEoE-7.js → index-Ek2aSUt6.js} +6 -6
- package/dist/gateway/static/root/assets/{local-app-workbench-page-DmzgjJNj.js → local-app-workbench-page-TZ7JoORJ.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-Cu_YCIN6.js → note-detail-panel-C8o-hv5U.js} +3 -3
- package/dist/gateway/static/root/assets/{notes-page-CQtqNBlW.js → notes-page-VWv-Q26S.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-Cn4zi3Mt.js → page-context-capture-button-zG-782MJ.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-OK0-3ovb.js → personal-page-CweKnHPY.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-profile-settings-CNI5Eor6.js → personal-profile-settings-OoFMAniP.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-BcrpYRn9.js → personal-settings-panel-BVv8cYny.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-runtime-RnBDP-Lq.js → preview-runtime-pJGZe5Jx.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-ydVvC7Fi.js → project-detail-page-CR9prGyI.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-g-LvDQgh.js → route-preload-D3c2DaKJ.js} +2 -2
- package/dist/gateway/static/root/assets/{routine-panel-rjq-8nZ8.js → routine-panel-BsUWc1HR.js} +2 -2
- package/dist/gateway/static/root/assets/session-manager-DzSlogQc.js +22 -0
- package/dist/gateway/static/root/assets/{settings-page-DHXt4EPc.js → settings-page-De1H4SjW.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-nzWjWhqF.js → share-preview-page-DDd5iT5G.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-LB3SYKFS.js → shares-settings-Dmk9W8r9.js} +1 -1
- package/dist/gateway/static/root/assets/{space-page-D7YRR6ZW.js → space-page-fq1NyJx5.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-BUn6GRzz.js → task-detail-page-DqVRV32Y.js} +2 -2
- package/dist/gateway/static/root/assets/task-header-title-D3zA4Ho1.js +1 -0
- package/dist/gateway/static/root/assets/{task-result-evidence-Bmgta9z9.js → task-result-evidence-DCHcXh04.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-sszsCdh5.js → use-composer-attachments-B6CKcx51.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-D4b4fDeu.js → use-file-preview-expanded-1ZjXWaYM.js} +1 -1
- package/dist/gateway/static/root/assets/{use-personal-work-CNK4dpEh.js → use-personal-work-BJ1yKsau.js} +1 -1
- package/dist/gateway/static/root/assets/{use-realtime-voice-cugjs8cK.js → use-realtime-voice-D5-XzM7H.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-Crfx5ctU.js → use-workspace-tree-DsuGqCMo.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-settings-BzfNK5Jm.js → voice-settings-lJN2e9mQ.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-g-wCKoQU.js → workspace-api-CFPK3JR6.js} +2 -2
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-DxaxVC3q.js → workspace-file-preview-dialog-35uL-ra3.js} +1 -1
- package/dist/gateway/static/root/index.html +16 -16
- package/dist/package.js +1 -1
- package/dist/src/agent/context/connection-objective-context.js +5 -1
- package/dist/src/agent/inbound/turn-dispatcher.d.ts +2 -0
- package/dist/src/agent/inbound/turn-dispatcher.js +3 -1
- package/dist/src/agent/service/process-direct-streaming.js +14 -0
- package/dist/src/agent/tools/factory.js +1 -1
- package/dist/src/agent/tools/personal-request-tool.d.ts +24 -1
- package/dist/src/agent/tools/personal-request-tool.js +180 -261
- package/dist/src/agent/tools/personal-task-tool.d.ts +8 -0
- package/dist/src/agent/tools/personal-task-tool.js +108 -46
- package/dist/src/channels/enterprise/plugin.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +52 -17
- package/dist/src/cli/commands/doctor/checks/tool-runtimes.js +12 -1
- package/dist/src/cli/commands/doctor/flow.js +11 -6
- package/dist/src/cli/index.js +8 -2
- package/dist/src/connectors/connection-candidates.d.ts +1 -0
- package/dist/src/connectors/connection-candidates.js +20 -1
- package/dist/src/gateway/chat-stream/mapper.js +10 -4
- package/dist/src/gateway/hono/routes/sessions.js +5 -2
- package/dist/src/gateway/hono/routes/video-generation.js +6 -5
- package/dist/src/gateway/service/session-input-coordinator.d.ts +2 -1
- package/dist/src/gateway/service/session-input-coordinator.js +3 -1
- package/dist/src/music-generation/artifact.d.ts +1 -1
- package/dist/src/music-generation/artifact.js +4 -3
- package/dist/src/music-generation/provider.d.ts +1 -0
- package/dist/src/music-generation/providers.js +4 -1
- package/dist/src/music-generation/worker.js +1 -1
- package/dist/src/music-generation/xopc-cloud.js +22 -0
- package/dist/src/personal-agent/prompts.js +29 -6
- package/dist/src/personal-agent/request-repository.d.ts +4 -0
- package/dist/src/personal-agent/request-repository.js +17 -1
- package/dist/src/session/manager.d.ts +3 -1
- package/dist/src/session/manager.js +2 -2
- package/dist/src/session/store.d.ts +3 -1
- package/dist/src/session/store.js +2 -2
- package/dist/src/session/user-round-delete.d.ts +3 -1
- package/dist/src/session/user-round-delete.js +6 -4
- package/dist/src/storage/sqlite/session-turn-replace-repository.js +6 -1
- package/dist/src/tasks/task-context-assembler.js +5 -2
- package/dist/src/tasks/task-deliverables.js +73 -38
- package/dist/src/tasks/task-main-update-delivery.js +1 -1
- package/dist/src/tasks/task-origin-repository.d.ts +2 -0
- package/dist/src/tasks/task-origin-repository.js +15 -6
- package/dist/src/video-generation/drafts.js +3 -3
- package/dist/src/video-generation/settings.d.ts +1 -0
- package/dist/src/video-generation/settings.js +23 -7
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/session-manager-BVS3zxRZ.js +0 -22
- package/dist/gateway/static/root/assets/task-header-title-BsYL4R80.js +0 -1
|
@@ -3,7 +3,7 @@ import { normalizeSpecialistRequirements } from "../../../packages/gateway-contr
|
|
|
3
3
|
import { init_src } from "../../../packages/gateway-contract/src/index.js";
|
|
4
4
|
import { getSessionInputById, getSessionInputState, init_session_input_repository } from "../../storage/sqlite/session-input-repository.js";
|
|
5
5
|
import { TaskRepository, init_task_repository } from "../../tasks/task-repository.js";
|
|
6
|
-
import { getPersonalRequest, init_request_repository } from "../../personal-agent/request-repository.js";
|
|
6
|
+
import { getPersonalRequest, init_request_repository, personalRequestForTask } from "../../personal-agent/request-repository.js";
|
|
7
7
|
import { getSessionMetadata } from "../../storage/sqlite/session-read-repository.js";
|
|
8
8
|
import "../../storage/sqlite/index.js";
|
|
9
9
|
import { isPersonalConversation } from "../../personal-agent/repository.js";
|
|
@@ -23,6 +23,7 @@ import { AgentSelectionRepository, selectionRequestHash } from "../../agent-matc
|
|
|
23
23
|
import { assertSpecialistEligible, createSelectedTask } from "../../agent-matching/delegation-service.js";
|
|
24
24
|
import { cancelPersonalTask } from "../../personal-agent/task-cancel.js";
|
|
25
25
|
import { taskConversationSummary } from "../../tasks/task-conversation-summary.js";
|
|
26
|
+
import { PersonalRequestTimeRangeSchema, coordinatePersonalRequest, listUnallocatedPersonalRequests } from "./personal-request-tool.js";
|
|
26
27
|
import { randomUUID } from "node:crypto";
|
|
27
28
|
import { Type } from "@sinclair/typebox";
|
|
28
29
|
//#region src/agent/tools/personal-task-tool.ts
|
|
@@ -69,13 +70,19 @@ const PersonalTaskSchema = Type.Object({
|
|
|
69
70
|
])),
|
|
70
71
|
previousSelectionId: Type.Optional(Type.String()),
|
|
71
72
|
matchId: Type.Optional(Type.String()),
|
|
72
|
-
requestId: Type.Optional(Type.String()),
|
|
73
|
+
requestId: Type.Optional(Type.String({ description: "Connected-app request ID. Use this if no taskId has been assigned." })),
|
|
74
|
+
timeRange: Type.Optional(PersonalRequestTimeRangeSchema),
|
|
73
75
|
cursor: Type.Optional(Type.String()),
|
|
74
76
|
offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
75
77
|
limit: Type.Optional(Type.Integer({
|
|
76
78
|
minimum: 1,
|
|
77
79
|
maximum: 20
|
|
78
80
|
})),
|
|
81
|
+
query: Type.Optional(Type.String({
|
|
82
|
+
minLength: 1,
|
|
83
|
+
maxLength: 200,
|
|
84
|
+
description: "For list, search this chat’s task titles and objectives by a distinctive phrase."
|
|
85
|
+
})),
|
|
79
86
|
title: Type.Optional(Type.String({ description: "Short task title, ideally under 60 characters. Do not put the full instructions here." })),
|
|
80
87
|
objective: Type.Optional(Type.String({
|
|
81
88
|
minLength: 1,
|
|
@@ -98,6 +105,11 @@ const PersonalTaskSchema = Type.Object({
|
|
|
98
105
|
expectedVersion: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
99
106
|
supersedesEntryIds: Type.Optional(Type.Array(Type.String({ description: "Only actual earlier instruction/answer entry IDs from collaboration. Omit for original-contract changes or the first revision; never use task/result/run IDs." }), { maxItems: 40 })),
|
|
100
107
|
instruction: Type.Optional(Type.String({ description: "The user’s new direction for this delegated Task." })),
|
|
108
|
+
taskReference: Type.Optional(Type.String({
|
|
109
|
+
minLength: 1,
|
|
110
|
+
maxLength: 200,
|
|
111
|
+
description: "For instruct with multiple candidate tasks, quote the shortest distinctive task reference from the latest user message, such as 华东. If a reference fits several tasks, ask which one."
|
|
112
|
+
})),
|
|
101
113
|
entryId: Type.Optional(Type.String({ description: "Read one complete collaboration entry, including its question or instruction body." })),
|
|
102
114
|
afterSequence: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
103
115
|
bodyOffset: Type.Optional(Type.Integer({
|
|
@@ -132,6 +144,15 @@ const PersonalTaskSchema = Type.Object({
|
|
|
132
144
|
requiredTools: Type.Optional(Type.Array(Type.String({ description: "Tool names needed for this Task. Use names returned by agents; omit when matching by role or expertise." }))),
|
|
133
145
|
idempotencyKey: Type.Optional(Type.String())
|
|
134
146
|
});
|
|
147
|
+
const REQUEST_COORDINATION_COMMANDS = [
|
|
148
|
+
"get",
|
|
149
|
+
"cancel",
|
|
150
|
+
"collaboration",
|
|
151
|
+
"notifications",
|
|
152
|
+
"entry",
|
|
153
|
+
"instruct",
|
|
154
|
+
"answer"
|
|
155
|
+
];
|
|
135
156
|
const PersonalTaskModelSchema = Type.Object({
|
|
136
157
|
command: Type.String({
|
|
137
158
|
enum: [...[
|
|
@@ -232,34 +253,39 @@ const PersonalTaskModelSchema = Type.Object({
|
|
|
232
253
|
},
|
|
233
254
|
{ properties: { command: { enum: ["list", "selection"] } } },
|
|
234
255
|
{
|
|
235
|
-
properties: { command: {
|
|
236
|
-
"get",
|
|
237
|
-
"collaboration",
|
|
238
|
-
"retry_allocation",
|
|
239
|
-
"cancel"
|
|
240
|
-
] } },
|
|
256
|
+
properties: { command: { const: "retry_allocation" } },
|
|
241
257
|
required: ["taskId"]
|
|
242
258
|
},
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
"
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
259
|
+
...["taskId", "requestId"].flatMap((id) => [
|
|
260
|
+
{
|
|
261
|
+
properties: { command: { enum: [
|
|
262
|
+
"get",
|
|
263
|
+
"collaboration",
|
|
264
|
+
"cancel"
|
|
265
|
+
] } },
|
|
266
|
+
required: [id]
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
properties: { command: { const: "notifications" } },
|
|
270
|
+
required: [id, "notificationPreference"]
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
properties: { command: { const: "entry" } },
|
|
274
|
+
required: [id, "entryId"]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
properties: { command: { const: "instruct" } },
|
|
278
|
+
required: [id, "instruction"]
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
properties: { command: { const: "answer" } },
|
|
282
|
+
required: [
|
|
283
|
+
id,
|
|
284
|
+
"instruction",
|
|
285
|
+
"questionId"
|
|
286
|
+
]
|
|
287
|
+
}
|
|
288
|
+
])
|
|
263
289
|
]
|
|
264
290
|
});
|
|
265
291
|
const MAX_PERSONAL_TASK_TITLE = 60;
|
|
@@ -286,22 +312,61 @@ function createPersonalTaskTool(deps) {
|
|
|
286
312
|
return {
|
|
287
313
|
name: "personal_task",
|
|
288
314
|
label: "Personal Task",
|
|
289
|
-
description: "Coordinate ordinary Tasks. Always include command. New goal: submit objective plus useOriginalRequest=true for a self-contained active user message; the host preserves the complete original text. Otherwise supply a concise complete description. Include sourceRefs for required inputs without pre-reading files or planning the execution. Use requirements.requestedAgentId only for an explicitly named executor; preserve explicitly requested requiredSkills. The background Router chooses the executor. After successful persistence, give one short confirmation and finish; updates arrive automatically.\nRUNNING work: send
|
|
315
|
+
description: "Coordinate ordinary Tasks and connected-app requests. For get, instruct, cancel, answer, collaboration, entry or notifications, use the known taskId or requestId. Connected-app requests awaiting authorization have only a requestId. Use timeRange on instruct for a changed absolute query range. Always include command. New ordinary goal: submit objective plus useOriginalRequest=true for a self-contained active user message; the host preserves the complete original text. Otherwise supply a concise complete description. Include sourceRefs for required inputs without pre-reading files or planning the execution. Use requirements.requestedAgentId only for an explicitly named executor; preserve explicitly requested requiredSkills. The background Router chooses the executor. After successful persistence, give one short confirmation and finish; updates arrive automatically.\nRUNNING work: send instruct with the known ID and instruction for new direction, or answer with the known ID, questionId and instruction for an exact worker question. Reuse the SAME Task, without a baseline lookup. Never revise running work.\nCOMPLETED ordinary work only: get(section=\"revision\"), then revise with instruction and exact returned revisionBaseline.resultId, baselineVersion and expectedVersion. If revisionBaseline is absent, use instruct/answer; never invent placeholders. This saves a revision and queues background allocation atomically. Reuse idempotencyKey for uncertain retries. supersedesEntryIds names only earlier instruction/answer entries to replace; all other requirements remain. Independent goals use submit with pinned old-result sources; connected-app side effects require a newly authorized Request.\nsourceRefs: workspace input {kind:\"file\",sourceId:\"path\"}; prior result {kind:\"result\",resultId:\"exact result ID\",sourceId:\"exact artifact ID or unique file title\"}, omitting sourceId only for retained body; other prior inputs use stable sourceId and optional expectedVersion. The host authorizes and pins exact versions; workspace inputs are not executor cwd. Do not invent composite IDs.\nUse notifications with the known ID and notificationPreference to change an existing Task only when the user asks. Use get(section=\"status\") for a brief current status; list locates a Task or a request awaiting authorization and get(section,limit,offset) reads details. collaboration(afterSequence) returns previews; entry(entryId,bodyOffset) reads full bodies through nextBodyOffset. Read complete questions before answering. cancel only on explicit user instruction; report executionStopConfirmed accurately. retry_allocation retries selection, not arbitrary execution. Saved, delivered, executor-confirmed and verified completion are distinct; report only confirmed states.",
|
|
290
316
|
parameters: PersonalTaskModelSchema,
|
|
291
317
|
mutatesWorkspace: true,
|
|
292
318
|
mutationScope: "external",
|
|
293
319
|
requiresExclusiveWorkspaceLock: false,
|
|
294
320
|
finalGuardRelevant: true,
|
|
295
|
-
async
|
|
321
|
+
execute: async function executeTask(toolCallId, modelInput, signal, _onUpdate, requestResolved = false) {
|
|
296
322
|
if (!PersonalTaskSchema.properties.command.anyOf.some((command) => command.const === modelInput.command)) throw new Error("Unsupported personal_task command; completed work uses atomic revise, not manual start/reopen");
|
|
297
323
|
if (modelInput.conversationExcerpts?.length && modelInput.command !== "submit") throw new Error("conversationExcerpts are supported only by submit; use instruct or answer for a running Task");
|
|
298
324
|
const input = modelInput;
|
|
299
325
|
if (input.notificationPreference !== void 0 && (!isTaskNotificationPreference(input.notificationPreference) || !["submit", "notifications"].includes(input.command))) throw new Error("Invalid Task notification preference");
|
|
300
326
|
if (input.dueAt !== void 0 && input.command !== "submit") throw new Error("dueAt is supported only by submit");
|
|
327
|
+
if (input.taskReference !== void 0 && input.command !== "instruct") throw new Error("taskReference is supported only by instruct");
|
|
301
328
|
if (modelInput.sourceRefs?.length && !["submit", "revise"].includes(input.command)) throw new Error("sourceRefs is supported only by submit/revise; it cannot be silently ignored by a coordination command");
|
|
302
329
|
const conversationId = deps.getCurrentConversationId?.();
|
|
303
330
|
const ownAgentId = deps.getCurrentAgentId?.();
|
|
304
331
|
if (!conversationId || !ownAgentId || !isPersonalConversation(conversationId)) throw new Error("Personal conversation context is unavailable");
|
|
332
|
+
if (!requestResolved && REQUEST_COORDINATION_COMMANDS.includes(input.command)) {
|
|
333
|
+
if (input.requestId !== void 0 && input.taskId !== void 0) throw new Error("Provide either taskId or requestId");
|
|
334
|
+
const request = input.requestId !== void 0 ? getPersonalRequest(input.requestId.trim()) : input.taskId ? personalRequestForTask(input.taskId.trim()) : void 0;
|
|
335
|
+
if (request && request.conversationId !== conversationId || input.requestId !== void 0 && !request) throw new Error("Request does not belong to this personal conversation");
|
|
336
|
+
if (request) return coordinatePersonalRequest(request, input, (taskId, instruction) => executeTask(toolCallId, {
|
|
337
|
+
...modelInput,
|
|
338
|
+
requestId: void 0,
|
|
339
|
+
taskId,
|
|
340
|
+
instruction,
|
|
341
|
+
timeRange: void 0
|
|
342
|
+
}, signal, void 0, true));
|
|
343
|
+
}
|
|
344
|
+
if (input.timeRange !== void 0) throw new Error("timeRange is supported only when updating a connected-app request");
|
|
345
|
+
if (input.requestId !== void 0 && input.command !== "selection") throw new Error("requestId is supported only for request coordination");
|
|
346
|
+
if (input.query !== void 0 && input.command !== "list") throw new Error("query is supported only by list");
|
|
347
|
+
if (input.command === "list") {
|
|
348
|
+
const offset = input.offset ?? 0;
|
|
349
|
+
const limit = input.limit ?? 10;
|
|
350
|
+
const query = input.query?.trim();
|
|
351
|
+
const requests = listUnallocatedPersonalRequests(conversationId, limit, offset, query);
|
|
352
|
+
const tasks = new TaskOriginRepository().list(conversationId, Math.max(1, limit - requests.items.length), {
|
|
353
|
+
offset: Math.max(0, offset - requests.total),
|
|
354
|
+
query
|
|
355
|
+
});
|
|
356
|
+
const payload = boundedPersonalResult({
|
|
357
|
+
ok: true,
|
|
358
|
+
items: [...requests.items, ...tasks.items.slice(0, limit - requests.items.length)],
|
|
359
|
+
total: requests.total + tasks.total,
|
|
360
|
+
offset
|
|
361
|
+
});
|
|
362
|
+
return {
|
|
363
|
+
content: [{
|
|
364
|
+
type: "text",
|
|
365
|
+
text: JSON.stringify(payload)
|
|
366
|
+
}],
|
|
367
|
+
details: {}
|
|
368
|
+
};
|
|
369
|
+
}
|
|
305
370
|
const requirements = normalizeSpecialistRequirements({
|
|
306
371
|
...input.requirements,
|
|
307
372
|
requestedAgentId: input.requirements?.requestedAgentId?.trim() || void 0,
|
|
@@ -504,16 +569,23 @@ function createPersonalTaskTool(deps) {
|
|
|
504
569
|
constraints: input.constraints,
|
|
505
570
|
idempotencyKey: key
|
|
506
571
|
};
|
|
507
|
-
} else if (command === "list") {
|
|
508
|
-
command = "delegated_tasks";
|
|
509
|
-
args = {
|
|
510
|
-
limit: input.limit ?? 10,
|
|
511
|
-
offset: input.offset ?? 0
|
|
512
|
-
};
|
|
513
572
|
} else {
|
|
514
573
|
const taskId = input.taskId?.trim();
|
|
515
574
|
if (!taskId) throw new Error("taskId is required");
|
|
516
575
|
if (!new TaskOriginRepository().owns(taskId, conversationId)) throw new Error("Task does not belong to this personal conversation");
|
|
576
|
+
if (command === "instruct" && !requestResolved) {
|
|
577
|
+
const activeInputId = getSessionInputState(conversationId).activeInputId;
|
|
578
|
+
const activeInput = activeInputId ? getSessionInputById(conversationId, activeInputId) : void 0;
|
|
579
|
+
const directory = new TaskOriginRepository();
|
|
580
|
+
const workerUpdate = activeInput?.origin.type === "system" && activeInput.origin.source === "task_update";
|
|
581
|
+
if (activeInput?.kind === "message" && !workerUpdate && directory.list(conversationId, 1).total > 1) {
|
|
582
|
+
const reference = input.taskReference?.trim();
|
|
583
|
+
if (!reference || !activeInput.content.toLowerCase().includes(reference.toLowerCase())) throw new Error("Provide taskReference quoted from the latest user message. If the user did not identify one task, ask which task they mean without retrying the update.");
|
|
584
|
+
const candidates = directory.list(conversationId, 2, { query: reference.replace(/(?:那|这)[份个项条]$/u, "") || reference });
|
|
585
|
+
if (candidates.total > 1) throw new Error("The taskReference does not identify this task uniquely. Ask which task the user means without retrying this reference.");
|
|
586
|
+
if (candidates.items[0]?.id !== taskId) throw new Error("The taskReference does not identify the selected task. Use a distinctive part of its title quoted from the user’s message, or ask which task they mean.");
|
|
587
|
+
}
|
|
588
|
+
}
|
|
517
589
|
if (command === "notifications") {
|
|
518
590
|
if (!input.notificationPreference) throw new Error("notificationPreference is required");
|
|
519
591
|
setTaskNotificationPreference(taskId, conversationId, input.notificationPreference);
|
|
@@ -787,16 +859,6 @@ function createPersonalTaskTool(deps) {
|
|
|
787
859
|
details: {}
|
|
788
860
|
};
|
|
789
861
|
}
|
|
790
|
-
if (payload && input.command === "list") return {
|
|
791
|
-
content: [{
|
|
792
|
-
type: "text",
|
|
793
|
-
text: JSON.stringify(boundedPersonalResult({
|
|
794
|
-
...payload,
|
|
795
|
-
offset: input.offset ?? 0
|
|
796
|
-
}))
|
|
797
|
-
}],
|
|
798
|
-
details: {}
|
|
799
|
-
};
|
|
800
862
|
return {
|
|
801
863
|
content: result.content,
|
|
802
864
|
details: {}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { resolveStandardAllowFromPath, resolveStandardPairingPath } from "../pairing/paths.js";
|
|
2
2
|
import { readAllowFromIdsSync } from "../pairing/allow-from-file.js";
|
|
3
3
|
import { evaluateAccess } from "../security.js";
|
|
4
|
-
import { redactEnterpriseChannelSecret } from "./config-surface.js";
|
|
5
4
|
import { record, string } from "./socket.js";
|
|
5
|
+
import { redactEnterpriseChannelSecret } from "./config-surface.js";
|
|
6
6
|
import { createEnterpriseSetup } from "./setup.js";
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
8
8
|
import { isDeepStrictEqual } from "node:util";
|
|
@@ -1,37 +1,72 @@
|
|
|
1
|
+
import { XOPC_DB_FILENAME } from "../../../../config/paths-state.js";
|
|
2
|
+
import { init_paths } from "../../../../storage/sqlite/paths.js";
|
|
1
3
|
import { readSchemaVersion } from "../../../../storage/sqlite/schema-version.js";
|
|
4
|
+
import "../../../../storage/sqlite/schema-upgrade.js";
|
|
2
5
|
import { init_schema } from "../../../../storage/sqlite/schema.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import "../../../../storage/sqlite/index.js";
|
|
6
|
-
import { loadConfig } from "../../../../config/loader.js";
|
|
6
|
+
import { init_node_sqlite, requireNodeSqlite } from "../../../../infra/node-sqlite.js";
|
|
7
|
+
import { join } from "node:path";
|
|
7
8
|
import { existsSync } from "node:fs";
|
|
8
9
|
//#region src/cli/commands/doctor/checks/database-schema.ts
|
|
10
|
+
init_node_sqlite();
|
|
11
|
+
init_paths();
|
|
9
12
|
init_schema();
|
|
10
13
|
async function checkDatabaseSchema(ctx) {
|
|
11
|
-
|
|
14
|
+
const result = {
|
|
12
15
|
id: "database-schema",
|
|
13
|
-
label: "Database schema"
|
|
16
|
+
label: "Database schema"
|
|
17
|
+
};
|
|
18
|
+
const path = join(ctx.stateDir, XOPC_DB_FILENAME);
|
|
19
|
+
if (!existsSync(path)) return {
|
|
20
|
+
...result,
|
|
14
21
|
status: "skip",
|
|
15
|
-
message: "No
|
|
22
|
+
message: "No SQLite database found.",
|
|
16
23
|
hints: []
|
|
17
24
|
};
|
|
25
|
+
let version;
|
|
18
26
|
try {
|
|
19
|
-
|
|
27
|
+
const { DatabaseSync } = requireNodeSqlite();
|
|
28
|
+
const db = new DatabaseSync(path, { readOnly: true });
|
|
29
|
+
try {
|
|
30
|
+
version = db.prepare("SELECT 1 FROM sqlite_schema WHERE type = 'table' AND name = 'schema_meta'").get() ? readSchemaVersion(db) : 0;
|
|
31
|
+
} finally {
|
|
32
|
+
db.close();
|
|
33
|
+
}
|
|
20
34
|
} catch {
|
|
21
35
|
return {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
hints: ["Fix xopc.json before running database checks."]
|
|
36
|
+
...result,
|
|
37
|
+
status: "fail",
|
|
38
|
+
message: "Could not read the SQLite schema version.",
|
|
39
|
+
hints: [path]
|
|
27
40
|
};
|
|
28
41
|
}
|
|
29
|
-
|
|
42
|
+
if (!version) return {
|
|
43
|
+
...result,
|
|
44
|
+
status: "fail",
|
|
45
|
+
message: "SQLite database has no valid xopc schema version.",
|
|
46
|
+
hints: [path]
|
|
47
|
+
};
|
|
48
|
+
if (version < 202) return {
|
|
49
|
+
...result,
|
|
50
|
+
status: "fail",
|
|
51
|
+
message: `SQLite schema v${version} is older than the minimum supported upgrade version (v202).`,
|
|
52
|
+
hints: ["Back up the entire state directory. See https://xopcai.github.io/xopc/update#database-upgrades for recovery."]
|
|
53
|
+
};
|
|
54
|
+
if (version > 280) return {
|
|
55
|
+
...result,
|
|
56
|
+
status: "fail",
|
|
57
|
+
message: `SQLite schema v${version} is newer than this release supports (v280).`,
|
|
58
|
+
hints: ["Use an xopc release that supports this database."]
|
|
59
|
+
};
|
|
60
|
+
if (version < 280) return {
|
|
61
|
+
...result,
|
|
62
|
+
status: "warn",
|
|
63
|
+
message: `SQLite schema v${version} needs an upgrade to v280.`,
|
|
64
|
+
hints: ["Stop other xopc processes using the database before starting Gateway."]
|
|
65
|
+
};
|
|
30
66
|
return {
|
|
31
|
-
|
|
32
|
-
label: "Database schema",
|
|
67
|
+
...result,
|
|
33
68
|
status: "pass",
|
|
34
|
-
message: `SQLite schema v${
|
|
69
|
+
message: `SQLite schema v${version} (current release v280).`,
|
|
35
70
|
hints: []
|
|
36
71
|
};
|
|
37
72
|
}
|
|
@@ -2,7 +2,18 @@ import { ManagedRuntimeManager } from "../../../../runtime-tools/manager.js";
|
|
|
2
2
|
import { loadConfig } from "../../../../config/loader.js";
|
|
3
3
|
//#region src/cli/commands/doctor/checks/tool-runtimes.ts
|
|
4
4
|
async function checkToolRuntimes(ctx) {
|
|
5
|
-
|
|
5
|
+
let config;
|
|
6
|
+
try {
|
|
7
|
+
config = loadConfig(ctx.configPath);
|
|
8
|
+
} catch {
|
|
9
|
+
return {
|
|
10
|
+
id: "tool-runtimes",
|
|
11
|
+
label: "Agent tool runtimes",
|
|
12
|
+
status: "skip",
|
|
13
|
+
message: "Config could not be loaded; skipped.",
|
|
14
|
+
hints: []
|
|
15
|
+
};
|
|
16
|
+
}
|
|
6
17
|
const statuses = await new ManagedRuntimeManager({
|
|
7
18
|
stateDir: ctx.stateDir,
|
|
8
19
|
config: config.runtimeTools
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { init_connection, isXopcDatabaseOpen } from "../../../storage/sqlite/connection.js";
|
|
1
2
|
import { printJsonResults, printResults } from "./format.js";
|
|
2
3
|
import { checkNodeVersion } from "./checks/node-version.js";
|
|
3
4
|
import { checkConfigHealth } from "./checks/config-health.js";
|
|
@@ -19,6 +20,7 @@ import { checkImageProviders } from "./checks/image-providers.js";
|
|
|
19
20
|
import { checkToolRuntimes } from "./checks/tool-runtimes.js";
|
|
20
21
|
import { checkAutomationIntegrity } from "./checks/automation-integrity.js";
|
|
21
22
|
//#region src/cli/commands/doctor/flow.ts
|
|
23
|
+
init_connection();
|
|
22
24
|
const DOCTOR_CHECKS = [
|
|
23
25
|
checkVersionUpdate,
|
|
24
26
|
checkNodeVersion,
|
|
@@ -26,16 +28,17 @@ const DOCTOR_CHECKS = [
|
|
|
26
28
|
checkMigrations,
|
|
27
29
|
checkConfigHealth,
|
|
28
30
|
checkStateIntegrity,
|
|
29
|
-
checkDatabaseSchema,
|
|
30
|
-
checkDatabaseRelations,
|
|
31
|
-
checkProviderAuth,
|
|
32
31
|
checkImageProviders,
|
|
33
32
|
checkChannelConfig,
|
|
34
33
|
checkChannelPairingPending,
|
|
35
34
|
checkSecurityAudit,
|
|
36
|
-
checkWorkspaceStatus,
|
|
37
35
|
checkGatewayService,
|
|
38
|
-
checkGatewayHealth
|
|
36
|
+
checkGatewayHealth
|
|
37
|
+
];
|
|
38
|
+
const DATABASE_CHECKS = [
|
|
39
|
+
checkDatabaseRelations,
|
|
40
|
+
checkProviderAuth,
|
|
41
|
+
checkWorkspaceStatus,
|
|
39
42
|
checkSessionIntegrity,
|
|
40
43
|
checkAutomationIntegrity
|
|
41
44
|
];
|
|
@@ -44,8 +47,10 @@ const DOCTOR_CHECKS = [
|
|
|
44
47
|
*/
|
|
45
48
|
async function collectDoctorResults(ctx) {
|
|
46
49
|
if (ctx.options.security) return [await checkSecurityAudit(ctx)];
|
|
47
|
-
const
|
|
50
|
+
const databaseSchema = await checkDatabaseSchema(ctx);
|
|
51
|
+
const results = [databaseSchema];
|
|
48
52
|
for (const check of DOCTOR_CHECKS) results.push(await check(ctx));
|
|
53
|
+
if (databaseSchema.status === "pass" && isXopcDatabaseOpen()) for (const check of DATABASE_CHECKS) results.push(await check(ctx));
|
|
49
54
|
results.push(...await checkChannelPlugins(ctx));
|
|
50
55
|
return results;
|
|
51
56
|
}
|
package/dist/src/cli/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { version } from "../../package.js";
|
|
3
|
+
import { DatabaseSchemaTooOldError, init_schema_errors } from "../storage/sqlite/schema-errors.js";
|
|
3
4
|
import { bootstrapApplicationStateSync } from "../bootstrap/application-state.js";
|
|
4
5
|
import { isHelpOrVersionInvocation } from "./argv.js";
|
|
5
6
|
import { ROOT_COMMAND_DESCRIPTION } from "./command-manifest.js";
|
|
@@ -8,6 +9,7 @@ import { getContextWithOpts, parsedOpts } from "./context.js";
|
|
|
8
9
|
import { Command } from "commander";
|
|
9
10
|
//#region src/cli/index.ts
|
|
10
11
|
/** Command wiring and `program.parse`; executable entry is `bin.ts` (log preset before logger init). */
|
|
12
|
+
init_schema_errors();
|
|
11
13
|
async function flushLoggerAndExit(code) {
|
|
12
14
|
const { flushAndClose } = await import("../utils/logger/shutdown.js");
|
|
13
15
|
await flushAndClose();
|
|
@@ -28,7 +30,11 @@ function buildProgram(ctx) {
|
|
|
28
30
|
for (const k of Object.keys(parsedOpts)) delete parsedOpts[k];
|
|
29
31
|
Object.assign(parsedOpts, next);
|
|
30
32
|
if (["backup", "device-host"].includes(actionCommand?.name() ?? "") || actionCommand?.parent?.name() === "backup") return;
|
|
31
|
-
|
|
33
|
+
try {
|
|
34
|
+
bootstrapApplicationStateSync();
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (!(actionCommand?.name() === "doctor" || actionCommand?.parent?.name() === "support") || !(error instanceof DatabaseSchemaTooOldError)) throw error;
|
|
37
|
+
}
|
|
32
38
|
});
|
|
33
39
|
program.hook("postAction", async (_hookOwner, actionCommand) => {
|
|
34
40
|
const cmd = actionCommand ?? program;
|
|
@@ -40,7 +46,7 @@ function buildProgram(ctx) {
|
|
|
40
46
|
}
|
|
41
47
|
return;
|
|
42
48
|
}
|
|
43
|
-
await flushLoggerAndExit(0);
|
|
49
|
+
await flushLoggerAndExit(typeof process.exitCode === "number" ? process.exitCode : 0);
|
|
44
50
|
});
|
|
45
51
|
return program;
|
|
46
52
|
}
|
|
@@ -3,6 +3,7 @@ export declare function connectionCandidates(query: string): {
|
|
|
3
3
|
label: string;
|
|
4
4
|
capabilities: string[];
|
|
5
5
|
}[];
|
|
6
|
+
export declare function resolveExactConnectionCandidate(app: string): string;
|
|
6
7
|
export declare function resolveConnectionCandidate(ref: string): {
|
|
7
8
|
key: string;
|
|
8
9
|
target: {
|
|
@@ -89,6 +89,25 @@ function connectionCandidates(query) {
|
|
|
89
89
|
...aliases
|
|
90
90
|
].filter((candidate, index, all) => all.findIndex((item) => item.candidateRef === candidate.candidateRef) === index);
|
|
91
91
|
}
|
|
92
|
+
function resolveExactConnectionCandidate(app) {
|
|
93
|
+
const name = app.trim();
|
|
94
|
+
if (getConnectorDefinition(name)) {
|
|
95
|
+
resolveConnectionCandidate(name);
|
|
96
|
+
return name;
|
|
97
|
+
}
|
|
98
|
+
const identity = normalizedIdentity(name);
|
|
99
|
+
const matches = listConnectorCatalog().filter((definition) => {
|
|
100
|
+
const runtime = definition.runtime;
|
|
101
|
+
if (runtime.type === "composio" && runtime.role === "toolkit") return [
|
|
102
|
+
definition.id,
|
|
103
|
+
definition.displayName,
|
|
104
|
+
runtime.toolkit
|
|
105
|
+
].some((value) => normalizedIdentity(value) === identity);
|
|
106
|
+
return runtime.type === "cli" && [definition.id, definition.displayName].some((value) => normalizedIdentity(value) === identity);
|
|
107
|
+
});
|
|
108
|
+
if (matches.length !== 1) throw new Error("Use personal_capability to identify the exact supported app or connector ID");
|
|
109
|
+
return matches[0].id;
|
|
110
|
+
}
|
|
92
111
|
function resolveConnectionCandidate(ref) {
|
|
93
112
|
const definition = getConnectorDefinition(ref);
|
|
94
113
|
if (definition?.runtime.type === "cli") return {
|
|
@@ -113,4 +132,4 @@ function resolveConnectionCandidate(ref) {
|
|
|
113
132
|
};
|
|
114
133
|
}
|
|
115
134
|
//#endregion
|
|
116
|
-
export { connectionCandidates, resolveConnectionCandidate };
|
|
135
|
+
export { connectionCandidates, resolveConnectionCandidate, resolveExactConnectionCandidate };
|
|
@@ -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:
|
|
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
|
-
|
|
466
|
-
|
|
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
|
-
|
|
879
|
-
|
|
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,
|
|
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 =
|
|
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 =
|
|
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>;
|