@xopcai/xopc 0.0.472 → 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/{automations-page-36Dx_eLZ.js → automations-page-BoYv4mr2.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-BY3P8w5G.js → automations-workspace-DdHpajzk.js} +2 -2
- package/dist/gateway/static/root/assets/{chat-page-D_8adelp.js → chat-page-4Agzfc_0.js} +2 -2
- package/dist/gateway/static/root/assets/{index-Jbmr3G0d.js → index-Ek2aSUt6.js} +5 -5
- package/dist/gateway/static/root/assets/{note-detail-panel-DFR9Fc16.js → note-detail-panel-C8o-hv5U.js} +2 -2
- package/dist/gateway/static/root/assets/{notes-page-Y6jTwZhu.js → notes-page-VWv-Q26S.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-CNAaIQe_.js → personal-page-CweKnHPY.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-CdIhsx42.js → project-detail-page-CR9prGyI.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-DAyaQF0B.js → route-preload-D3c2DaKJ.js} +2 -2
- package/dist/gateway/static/root/assets/{settings-page-C2DiHQf_.js → settings-page-De1H4SjW.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DE3BWEBP.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/{use-personal-work-CwZNBF3F.js → use-personal-work-BJ1yKsau.js} +1 -1
- package/dist/gateway/static/root/index.html +5 -5
- package/dist/package.js +1 -1
- package/dist/src/agent/context/connection-objective-context.js +5 -1
- 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/hono/routes/home.js +1 -1
- package/dist/src/gateway/service.js +4 -4
- package/dist/src/home-intelligence/host.js +5 -5
- 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/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/package.json +1 -1
- package/dist/gateway/static/root/assets/task-header-title-BTCuRQKx.js +0 -1
|
@@ -28,8 +28,15 @@ declare const PersonalTaskModelSchema: import("@sinclair/typebox").TObject<{
|
|
|
28
28
|
acceptancePolicy: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"verified_auto">, import("@sinclair/typebox").TLiteral<"manual">]>>;
|
|
29
29
|
limit: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
30
30
|
offset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
31
|
+
timeRange: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
32
|
+
from: import("@sinclair/typebox").TString;
|
|
33
|
+
to: import("@sinclair/typebox").TString;
|
|
34
|
+
timezone: import("@sinclair/typebox").TString;
|
|
35
|
+
expression: import("@sinclair/typebox").TString;
|
|
36
|
+
}>>;
|
|
31
37
|
section: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<string>[]>>;
|
|
32
38
|
entryId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
39
|
+
query: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
33
40
|
baselineVersion: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
34
41
|
notificationPreference: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"default" | "final_only" | "updates">[]>>;
|
|
35
42
|
afterSequence: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
@@ -37,6 +44,7 @@ declare const PersonalTaskModelSchema: import("@sinclair/typebox").TObject<{
|
|
|
37
44
|
useOriginalRequest: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
38
45
|
baselineResultId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
39
46
|
supersedesEntryIds: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
|
47
|
+
taskReference: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
40
48
|
bodyOffset: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
|
|
41
49
|
command: import("@sinclair/typebox").TString;
|
|
42
50
|
sourceRefs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
@@ -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 };
|
|
@@ -8,8 +8,8 @@ import { acknowledgeHomeAttention } from "../../../storage/sqlite/home-attention
|
|
|
8
8
|
import "../../../storage/sqlite/index.js";
|
|
9
9
|
import { HomeQueryService, buildHomeWorkbench, decisionFromTask } from "../../../tasks/home-query-service.js";
|
|
10
10
|
import { resumeApprovedConnectorAction } from "../../../connectors/approval-resume.js";
|
|
11
|
-
import { ObservationConflictError } from "../../../home-intelligence/observation.js";
|
|
12
11
|
import { HomeOpportunityActionError, HomeOpportunityNotFoundError } from "../../../home-intelligence/application-service.js";
|
|
12
|
+
import { ObservationConflictError } from "../../../home-intelligence/observation.js";
|
|
13
13
|
//#region src/gateway/hono/routes/home.ts
|
|
14
14
|
init_src();
|
|
15
15
|
/** Register the unified work-home read model and its decision actions. */
|
|
@@ -107,6 +107,10 @@ import { DiscussionSealer } from "../discussions/sealer.js";
|
|
|
107
107
|
import "../discussions/index.js";
|
|
108
108
|
import { EndpointToolRuntime } from "../endpoint-tools/runtime.js";
|
|
109
109
|
import "../endpoint-tools/index.js";
|
|
110
|
+
import { HomeCapabilityPreflightService } from "../home-intelligence/capability-preflight.js";
|
|
111
|
+
import { HomeAdviceGenerator } from "../home-intelligence/generator.js";
|
|
112
|
+
import { HomeIntelligenceHost } from "../home-intelligence/host.js";
|
|
113
|
+
import { HomeSnapshotBuilder } from "../home-intelligence/snapshot.js";
|
|
110
114
|
import { assertGatewayAuthConfigured, extractToken, resolveGatewayAuth, validateToken } from "./auth.js";
|
|
111
115
|
import { prepareAutomationAgentSession } from "./automation-agent-session.js";
|
|
112
116
|
import { deliverAutomationCompletion } from "./automation-completion-delivery.js";
|
|
@@ -173,10 +177,6 @@ import { TaskMainUpdateDecisionService } from "../tasks/task-main-update-decisio
|
|
|
173
177
|
import { selectTaskMainUpdateAttempt, submitAndConfirmTaskMainUpdate } from "../tasks/task-main-update-input.js";
|
|
174
178
|
import { checkAppContextAccess, prepareAppContext } from "./service/app-context-access.js";
|
|
175
179
|
import { applyAutomaticVoiceLanguage, inferProductLanguageFromEnvironment, initializeVoiceDefaults } from "../voice/language-profile.js";
|
|
176
|
-
import { HomeAdviceGenerator } from "../home-intelligence/generator.js";
|
|
177
|
-
import { HomeIntelligenceHost } from "../home-intelligence/host.js";
|
|
178
|
-
import { HomeSnapshotBuilder } from "../home-intelligence/snapshot.js";
|
|
179
|
-
import { HomeCapabilityPreflightService } from "../home-intelligence/capability-preflight.js";
|
|
180
180
|
import crypto from "node:crypto";
|
|
181
181
|
//#region src/gateway/service.ts
|
|
182
182
|
init_session_repository();
|
|
@@ -7,14 +7,14 @@ import { TaskRepository, init_task_repository } from "../tasks/task-repository.j
|
|
|
7
7
|
import { appendTranscriptEntry } from "../storage/sqlite/transcript-repository.js";
|
|
8
8
|
import { createConversation, init_conversation_repository } from "../storage/sqlite/conversation-repository.js";
|
|
9
9
|
import { TaskApplicationService } from "../tasks/task-application-service.js";
|
|
10
|
-
import { HomeObservation, ObservationConflictError } from "./observation.js";
|
|
11
|
-
import { HomeFollowUps } from "./follow-ups.js";
|
|
12
|
-
import { observationStarters } from "./observation-starters.js";
|
|
13
|
-
import { HomeAdviceBudgetExceededError, isHomeProseLocalized } from "./generator.js";
|
|
14
10
|
import { homePatternKey } from "./strategy.js";
|
|
15
|
-
import { HomeAdvicePolicy } from "./policy.js";
|
|
16
11
|
import { HomeIntelligenceRepository } from "./repository.js";
|
|
17
12
|
import { HomeOpportunityApplicationService } from "./application-service.js";
|
|
13
|
+
import { HomeAdvicePolicy } from "./policy.js";
|
|
14
|
+
import { HomeObservation, ObservationConflictError } from "./observation.js";
|
|
15
|
+
import { HomeFollowUps } from "./follow-ups.js";
|
|
16
|
+
import { HomeAdviceBudgetExceededError, isHomeProseLocalized } from "./generator.js";
|
|
17
|
+
import { observationStarters } from "./observation-starters.js";
|
|
18
18
|
import { buildHomeOpportunityNotification } from "./notification.js";
|
|
19
19
|
import { ObservationRoutines } from "./routines.js";
|
|
20
20
|
import { createHash } from "node:crypto";
|