@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
|
@@ -1,3 +1,26 @@
|
|
|
1
|
-
import type { AgentTool } from '@earendil-works/pi-agent-core';
|
|
1
|
+
import type { AgentTool, AgentToolResult } from '@earendil-works/pi-agent-core';
|
|
2
|
+
import { type PersonalRequest } from '../../personal-agent/request-repository.js';
|
|
2
3
|
import type { XopcUseToolDeps } from './xopc-use-tool.js';
|
|
4
|
+
export declare const PersonalRequestTimeRangeSchema: import("@sinclair/typebox").TObject<{
|
|
5
|
+
from: import("@sinclair/typebox").TString;
|
|
6
|
+
to: import("@sinclair/typebox").TString;
|
|
7
|
+
timezone: import("@sinclair/typebox").TString;
|
|
8
|
+
expression: import("@sinclair/typebox").TString;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function listUnallocatedPersonalRequests(conversationId: string, limit: number, offset: number, query?: string): {
|
|
11
|
+
total: number;
|
|
12
|
+
items: {
|
|
13
|
+
requestId: string;
|
|
14
|
+
title: string;
|
|
15
|
+
connectorId: string;
|
|
16
|
+
state: import("../../personal-agent/request-repository.js").PersonalRequestState;
|
|
17
|
+
updatedAt: number;
|
|
18
|
+
}[];
|
|
19
|
+
};
|
|
20
|
+
export declare function coordinatePersonalRequest(request: PersonalRequest, input: {
|
|
21
|
+
command: string;
|
|
22
|
+
instruction?: string;
|
|
23
|
+
notificationPreference?: PersonalRequest['parameters']['notificationPreference'];
|
|
24
|
+
timeRange?: PersonalRequest['parameters']['timeRange'];
|
|
25
|
+
}, coordinateTask: (taskId: string, instruction?: string) => Promise<AgentToolResult<Record<string, never>>>): Promise<AgentToolResult<Record<string, never>>>;
|
|
3
26
|
export declare function createPersonalRequestTools(deps: XopcUseToolDeps): AgentTool[];
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import { getSqliteDatabase, init_transaction, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
|
|
2
2
|
import { init_session_instance_repository, readCurrentTranscriptId } from "../../storage/sqlite/session-instance-repository.js";
|
|
3
3
|
import { getSessionInputState, init_session_input_repository } from "../../storage/sqlite/session-input-repository.js";
|
|
4
|
-
import { getPersonalRequest, init_request_repository,
|
|
4
|
+
import { getPersonalRequest, init_request_repository, listPersonalRequestsWithoutTask, updatePersonalRequest } from "../../personal-agent/request-repository.js";
|
|
5
5
|
import { getActiveConnectionWait, init_connection_wait_repository, reviseCurrentConnectionObjective, updateConnectionWait } from "../../storage/sqlite/connection-wait-repository.js";
|
|
6
|
-
import { getSessionMetadata } from "../../storage/sqlite/session-read-repository.js";
|
|
7
|
-
import { init_session_repository } from "../../storage/sqlite/session-repository.js";
|
|
8
6
|
import { isPersonalConversation } from "../../personal-agent/repository.js";
|
|
9
7
|
import { TaskAllocationRepository } from "../../tasks/task-allocation-repository.js";
|
|
10
|
-
import {
|
|
8
|
+
import { resolveExactConnectionCandidate } from "../../connectors/connection-candidates.js";
|
|
11
9
|
import { TASK_NOTIFICATION_PREFERENCES, getTaskNotificationPreference, isTaskNotificationPreference, setTaskNotificationPreference } from "../../tasks/task-notification-preference.js";
|
|
12
10
|
import { personalCapabilities } from "../../personal-agent/capability-service.js";
|
|
13
11
|
import { selectionRequestHash } from "../../agent-matching/selection-repository.js";
|
|
14
|
-
import { createPersonalTaskTool } from "./personal-task-tool.js";
|
|
15
12
|
import { assertPersonalRequestTimeRange, cancelPersonalRequest, personalRequestSnapshot, publishPersonalRequest, stopPersonalRequestExecution, submitPersonalRequest } from "../../personal-agent/request-service.js";
|
|
16
13
|
import { Type } from "@sinclair/typebox";
|
|
17
14
|
//#region src/agent/tools/personal-request-tool.ts
|
|
18
15
|
init_session_input_repository();
|
|
19
|
-
init_session_repository();
|
|
20
16
|
init_session_instance_repository();
|
|
21
17
|
init_connection_wait_repository();
|
|
22
18
|
init_request_repository();
|
|
23
19
|
init_transaction();
|
|
20
|
+
const PersonalRequestTimeRangeSchema = Type.Object({
|
|
21
|
+
from: Type.String(),
|
|
22
|
+
to: Type.String(),
|
|
23
|
+
timezone: Type.String(),
|
|
24
|
+
expression: Type.String()
|
|
25
|
+
});
|
|
24
26
|
const CapabilitySchema = Type.Object({
|
|
25
27
|
query: Type.String({
|
|
26
28
|
minLength: 1,
|
|
@@ -29,142 +31,174 @@ const CapabilitySchema = Type.Object({
|
|
|
29
31
|
accountId: Type.Optional(Type.String())
|
|
30
32
|
});
|
|
31
33
|
const RequestSchema = Type.Object({
|
|
32
|
-
command: Type.
|
|
33
|
-
|
|
34
|
-
"get",
|
|
35
|
-
"list",
|
|
36
|
-
"cancel",
|
|
37
|
-
"answer",
|
|
38
|
-
"instruct",
|
|
39
|
-
"collaboration",
|
|
40
|
-
"entry",
|
|
41
|
-
"notifications"
|
|
42
|
-
].map((command) => Type.Literal(command))),
|
|
43
|
-
notificationPreference: Type.Optional(Type.Union(TASK_NOTIFICATION_PREFERENCES.map((value) => Type.Literal(value)), { description: "Only for explicit user preferences on submit or notifications. final_only suppresses progress; updates enables meaningful milestones; default restores normal behavior." })),
|
|
34
|
+
command: Type.Literal("submit"),
|
|
35
|
+
notificationPreference: Type.Optional(Type.Union(TASK_NOTIFICATION_PREFERENCES.map((value) => Type.Literal(value)), { description: "Only for explicit user preferences. final_only suppresses progress; updates enables meaningful milestones; default restores normal behavior." })),
|
|
44
36
|
dueAt: Type.Optional(Type.Integer({
|
|
45
37
|
minimum: 0,
|
|
46
38
|
description: "User-provided deadline in epoch milliseconds, only on submit."
|
|
47
39
|
})),
|
|
48
|
-
|
|
49
|
-
instruction: Type.Optional(Type.String({
|
|
40
|
+
connectorId: Type.String({
|
|
50
41
|
minLength: 1,
|
|
51
|
-
|
|
52
|
-
})
|
|
53
|
-
questionId: Type.Optional(Type.String({ minLength: 1 })),
|
|
54
|
-
entryId: Type.Optional(Type.String({ minLength: 1 })),
|
|
55
|
-
afterSequence: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
56
|
-
bodyOffset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
57
|
-
requestId: Type.Optional(Type.String()),
|
|
58
|
-
offset: Type.Optional(Type.Integer({ minimum: 0 })),
|
|
59
|
-
limit: Type.Optional(Type.Integer({
|
|
60
|
-
minimum: 1,
|
|
61
|
-
maximum: 20
|
|
62
|
-
})),
|
|
63
|
-
connectorId: Type.Optional(Type.String()),
|
|
42
|
+
description: "Exact app name (e.g. Gmail, Outlook, Google Drive) or connector ID from personal_capability."
|
|
43
|
+
}),
|
|
64
44
|
accountId: Type.Optional(Type.String()),
|
|
65
|
-
description: Type.
|
|
45
|
+
description: Type.String({
|
|
66
46
|
minLength: 1,
|
|
67
47
|
maxLength: 16e3,
|
|
68
48
|
description: "Complete task brief preserving all user requirements, stages, inputs, outputs and constraints. Do not replace exact specifications with a short objective or a reference to an unspecified process."
|
|
69
|
-
})
|
|
49
|
+
}),
|
|
70
50
|
acceptancePolicy: Type.Optional(Type.Union([Type.Literal("verified_auto"), Type.Literal("manual")], { description: "Default automatic verification and completion. Use manual only for an explicit user requirement for human acceptance." })),
|
|
71
|
-
objective: Type.
|
|
51
|
+
objective: Type.String({
|
|
72
52
|
minLength: 1,
|
|
73
53
|
maxLength: 4e3
|
|
74
|
-
})
|
|
54
|
+
}),
|
|
75
55
|
idempotencyKey: Type.Optional(Type.String({
|
|
76
56
|
minLength: 1,
|
|
77
57
|
maxLength: 200
|
|
78
58
|
})),
|
|
79
|
-
timeRange: Type.Optional(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
]
|
|
95
|
-
},
|
|
96
|
-
{ properties: { command: { const: "list" } } },
|
|
97
|
-
{
|
|
98
|
-
properties: { command: { enum: [
|
|
99
|
-
"get",
|
|
100
|
-
"cancel",
|
|
101
|
-
"collaboration"
|
|
102
|
-
] } },
|
|
103
|
-
required: ["requestId"]
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
properties: { command: { const: "notifications" } },
|
|
107
|
-
required: ["requestId", "notificationPreference"]
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
properties: { command: { const: "entry" } },
|
|
111
|
-
required: ["requestId", "entryId"]
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
properties: { command: { const: "instruct" } },
|
|
115
|
-
required: ["requestId", "instruction"]
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
properties: { command: { const: "answer" } },
|
|
119
|
-
required: [
|
|
120
|
-
"requestId",
|
|
121
|
-
"questionId",
|
|
122
|
-
"instruction"
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
]
|
|
126
|
-
});
|
|
127
|
-
function createPersonalRequestTools(deps) {
|
|
128
|
-
const conversation = () => {
|
|
129
|
-
const id = deps.getCurrentConversationId?.();
|
|
130
|
-
if (!id || !isPersonalConversation(id)) throw new Error("Personal conversation is required");
|
|
131
|
-
return id;
|
|
132
|
-
};
|
|
133
|
-
const snapshot = (request) => {
|
|
134
|
-
const value = personalRequestSnapshot(request);
|
|
135
|
-
return {
|
|
136
|
-
...value,
|
|
137
|
-
executorAgentId: value.parameters.allocate && value.executorAgentId === "task-router" ? void 0 : value.executorAgentId,
|
|
138
|
-
...value.taskId ? { allocation: new TaskAllocationRepository().summary(value.taskId) } : {}
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
const compactSnapshot = (request) => {
|
|
142
|
-
const value = snapshot(request);
|
|
143
|
-
return {
|
|
144
|
-
requestId: value.requestId,
|
|
145
|
-
taskId: value.taskId,
|
|
146
|
-
state: value.state,
|
|
147
|
-
version: value.version,
|
|
148
|
-
connectorId: value.connectorId,
|
|
149
|
-
accountId: value.accountId,
|
|
150
|
-
executorAgentId: value.executorAgentId,
|
|
151
|
-
notificationPreference: value.taskId ? getTaskNotificationPreference(value.taskId, value.conversationId) : value.parameters.notificationPreference,
|
|
152
|
-
..."allocation" in value ? { allocation: value.allocation } : {},
|
|
153
|
-
parameters: { timeRange: value.parameters.timeRange }
|
|
154
|
-
};
|
|
59
|
+
timeRange: Type.Optional(PersonalRequestTimeRangeSchema)
|
|
60
|
+
}, { additionalProperties: false });
|
|
61
|
+
function compactSnapshot(request) {
|
|
62
|
+
const value = personalRequestSnapshot(request);
|
|
63
|
+
return {
|
|
64
|
+
requestId: value.requestId,
|
|
65
|
+
taskId: value.taskId,
|
|
66
|
+
state: value.state,
|
|
67
|
+
version: value.version,
|
|
68
|
+
connectorId: value.connectorId,
|
|
69
|
+
accountId: value.accountId,
|
|
70
|
+
executorAgentId: value.parameters.allocate && value.executorAgentId === "task-router" ? void 0 : value.executorAgentId,
|
|
71
|
+
notificationPreference: value.taskId ? getTaskNotificationPreference(value.taskId, value.conversationId) : value.parameters.notificationPreference,
|
|
72
|
+
allocation: value.taskId ? new TaskAllocationRepository().summary(value.taskId) : void 0,
|
|
73
|
+
parameters: { timeRange: value.parameters.timeRange }
|
|
155
74
|
};
|
|
156
|
-
|
|
75
|
+
}
|
|
76
|
+
function result(value) {
|
|
77
|
+
return {
|
|
157
78
|
content: [{
|
|
158
79
|
type: "text",
|
|
159
80
|
text: JSON.stringify(value)
|
|
160
81
|
}],
|
|
161
82
|
details: {}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function listUnallocatedPersonalRequests(conversationId, limit, offset, query) {
|
|
86
|
+
const { total, items } = listPersonalRequestsWithoutTask(conversationId, limit, offset, query);
|
|
87
|
+
return {
|
|
88
|
+
total,
|
|
89
|
+
items: items.map((request) => ({
|
|
90
|
+
requestId: request.requestId,
|
|
91
|
+
title: request.objective,
|
|
92
|
+
connectorId: request.connectorId,
|
|
93
|
+
state: request.state,
|
|
94
|
+
updatedAt: request.updatedAt
|
|
95
|
+
}))
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async function coordinatePersonalRequest(request, input, coordinateTask) {
|
|
99
|
+
const { conversationId } = request;
|
|
100
|
+
if (input.timeRange !== void 0 && input.command !== "instruct") throw new Error("timeRange is supported only on instruct for a connected-app request");
|
|
101
|
+
if (input.command === "notifications") {
|
|
102
|
+
if (!input.notificationPreference) throw new Error("notificationPreference is required");
|
|
103
|
+
if (readCurrentTranscriptId(getSqliteDatabase(), conversationId) !== request.transcriptId) throw new Error("SESSION_CHANGED");
|
|
104
|
+
if (request.taskId) {
|
|
105
|
+
setTaskNotificationPreference(request.taskId, conversationId, input.notificationPreference);
|
|
106
|
+
return result(compactSnapshot(request));
|
|
107
|
+
}
|
|
108
|
+
return result(compactSnapshot(updatePersonalRequest(request, { parameters: {
|
|
109
|
+
...request.parameters,
|
|
110
|
+
notificationPreference: input.notificationPreference
|
|
111
|
+
} })));
|
|
112
|
+
}
|
|
113
|
+
if (input.command === "cancel") {
|
|
114
|
+
if (["completed", "failed"].includes(personalRequestSnapshot(request).state)) return result(compactSnapshot(request));
|
|
115
|
+
const cancelled = cancelPersonalRequest(request);
|
|
116
|
+
const stop = stopPersonalRequestExecution(cancelled);
|
|
117
|
+
publishPersonalRequest(cancelled);
|
|
118
|
+
return result({
|
|
119
|
+
...compactSnapshot(cancelled),
|
|
120
|
+
status: cancelled.state,
|
|
121
|
+
executionStopConfirmed: stop.executionStopConfirmed
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (input.command === "get" && !request.taskId) return result({
|
|
125
|
+
ok: true,
|
|
126
|
+
...compactSnapshot(request),
|
|
127
|
+
objective: request.objective
|
|
162
128
|
});
|
|
129
|
+
if (input.command === "instruct" && input.timeRange) assertPersonalRequestTimeRange(input.timeRange);
|
|
130
|
+
if ((input.command === "instruct" || input.command === "answer") && !input.instruction?.trim()) throw new Error("instruction is required");
|
|
131
|
+
const instruction = input.command === "instruct" && input.timeRange ? `${input.instruction}\n\nUpdated absolute query range: ${JSON.stringify(input.timeRange)}` : input.instruction;
|
|
132
|
+
if (input.command === "answer" || input.command === "instruct") {
|
|
133
|
+
if ([
|
|
134
|
+
"completed",
|
|
135
|
+
"failed",
|
|
136
|
+
"cancelled"
|
|
137
|
+
].includes(personalRequestSnapshot(request).state)) throw new Error("Request is no longer active");
|
|
138
|
+
if (readCurrentTranscriptId(getSqliteDatabase(), conversationId) !== request.transcriptId) throw new Error("SESSION_CHANGED");
|
|
139
|
+
if (!request.taskId && input.command === "instruct" && request.state === "waiting_connection") {
|
|
140
|
+
const addition = `\n\nSupplemental requirement:\n${instruction.trim()}`;
|
|
141
|
+
if (!request.objective.endsWith(addition)) runSqliteWriteTransaction(() => {
|
|
142
|
+
if (getActiveConnectionWait(conversationId)?.id !== request.connectionWaitId) throw new Error("Connection objective changed");
|
|
143
|
+
reviseCurrentConnectionObjective(conversationId, request.objective + addition);
|
|
144
|
+
const revised = getActiveConnectionWait(conversationId);
|
|
145
|
+
updateConnectionWait({
|
|
146
|
+
...revised,
|
|
147
|
+
checkpoint: {
|
|
148
|
+
...revised.checkpoint,
|
|
149
|
+
timeRange: input.timeRange ?? request.parameters.timeRange
|
|
150
|
+
}
|
|
151
|
+
}, revised.version);
|
|
152
|
+
updatePersonalRequest(request, {
|
|
153
|
+
objective: request.objective + addition,
|
|
154
|
+
parameters: {
|
|
155
|
+
...request.parameters,
|
|
156
|
+
...input.timeRange ? { timeRange: input.timeRange } : {}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
return result({
|
|
161
|
+
ok: true,
|
|
162
|
+
...compactSnapshot(getPersonalRequest(request.requestId)),
|
|
163
|
+
instructionStatus: "saved",
|
|
164
|
+
guidance: "Account authorization is still required. The existing Request will create its Task with this requirement after authorization."
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (!request.taskId) throw new Error("No Task yet; complete account authorization in the main connection UI");
|
|
169
|
+
const coordinated = await coordinateTask(request.taskId, instruction);
|
|
170
|
+
if (input.command === "get") return result({
|
|
171
|
+
...JSON.parse(coordinated.content[0].text),
|
|
172
|
+
...compactSnapshot(request)
|
|
173
|
+
});
|
|
174
|
+
if (input.command === "instruct" && input.timeRange && JSON.parse(coordinated.content[0].text).ok === true) runSqliteWriteTransaction(() => {
|
|
175
|
+
const current = getPersonalRequest(request.requestId);
|
|
176
|
+
updatePersonalRequest(current, { parameters: {
|
|
177
|
+
...current.parameters,
|
|
178
|
+
timeRange: input.timeRange
|
|
179
|
+
} });
|
|
180
|
+
const wait = getActiveConnectionWait(conversationId);
|
|
181
|
+
if (wait && wait.id === current.connectionWaitId) updateConnectionWait({
|
|
182
|
+
...wait,
|
|
183
|
+
checkpoint: {
|
|
184
|
+
...wait.checkpoint,
|
|
185
|
+
timeRange: input.timeRange
|
|
186
|
+
}
|
|
187
|
+
}, wait.version);
|
|
188
|
+
});
|
|
189
|
+
return coordinated;
|
|
190
|
+
}
|
|
191
|
+
function createPersonalRequestTools(deps) {
|
|
192
|
+
const conversation = () => {
|
|
193
|
+
const id = deps.getCurrentConversationId?.();
|
|
194
|
+
if (!id || !isPersonalConversation(id)) throw new Error("Personal conversation is required");
|
|
195
|
+
return id;
|
|
196
|
+
};
|
|
163
197
|
return [{
|
|
164
198
|
name: "personal_capability",
|
|
165
199
|
label: "Connected app availability",
|
|
166
200
|
parameters: CapabilitySchema,
|
|
167
|
-
description: "Check connected
|
|
201
|
+
description: "Check supported connected apps, their capabilities and account connection state. Use for capability questions or when the app is unclear. For a clearly named app, submit with personal_request directly.",
|
|
168
202
|
async execute(_id, input) {
|
|
169
203
|
return result(personalCapabilities(conversation(), input.query, input.accountId).map(({ executorProfiles: _profiles, executorAgentIds, accounts, ...capability }) => ({
|
|
170
204
|
...capability,
|
|
@@ -176,156 +210,41 @@ function createPersonalRequestTools(deps) {
|
|
|
176
210
|
name: "personal_request",
|
|
177
211
|
label: "Connected app request",
|
|
178
212
|
parameters: RequestSchema,
|
|
179
|
-
description: "Submit a read-only connected-app request with
|
|
213
|
+
description: "Submit a new read-only connected-app request with the exact app name or connector ID, short objective, full brief and any absolute time range. The host validates access, shows account selection or authorization when needed, and continues automatically. For mail without a requested range, report the last-7-days default if returned. Report the confirmed submission state and use personal_task with the returned requestId or taskId for follow-up.",
|
|
180
214
|
async execute(toolCallId, input) {
|
|
181
215
|
const conversationId = conversation();
|
|
182
|
-
if (input.
|
|
183
|
-
if (input.
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
notificationPreference: input.notificationPreference,
|
|
212
|
-
dueAt: input.dueAt,
|
|
213
|
-
idempotencyKey: input.idempotencyKey ?? `personal-request-submit:${selectionRequestHash({
|
|
214
|
-
inputId: getSessionInputState(conversationId).activeInputId ?? toolCallId,
|
|
215
|
-
objective: input.objective.trim(),
|
|
216
|
-
description: input.description?.trim(),
|
|
217
|
-
connectorId: input.connectorId,
|
|
218
|
-
accountId: input.accountId,
|
|
219
|
-
timeRange: input.timeRange,
|
|
220
|
-
acceptancePolicy: input.acceptancePolicy,
|
|
221
|
-
notificationPreference: input.notificationPreference,
|
|
222
|
-
dueAt: input.dueAt
|
|
223
|
-
})}`
|
|
224
|
-
});
|
|
225
|
-
publishPersonalRequest(request);
|
|
226
|
-
deps.dispatchTaskRuns?.();
|
|
227
|
-
return result({
|
|
228
|
-
...compactSnapshot(request),
|
|
229
|
-
guidance: request.state === "waiting_connection" ? "The objective is saved. The host presents the required connection or account selection and continues automatically afterward. Stop this turn; do not ask the user to confirm the read or reply continue." : "The request was accepted. No further user confirmation is needed. Report the returned state accurately, do not submit a duplicate, and wait for delivery without polling."
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
const request = input.requestId ? getPersonalRequest(input.requestId) : void 0;
|
|
233
|
-
if (!request || request.conversationId !== conversationId) throw new Error("Request does not belong to this conversation");
|
|
234
|
-
if (input.command === "notifications") {
|
|
235
|
-
if (!input.notificationPreference) throw new Error("notificationPreference is required");
|
|
236
|
-
if (readCurrentTranscriptId(getSqliteDatabase(), conversationId) !== request.transcriptId) throw new Error("SESSION_CHANGED");
|
|
237
|
-
if (request.taskId) {
|
|
238
|
-
setTaskNotificationPreference(request.taskId, conversationId, input.notificationPreference);
|
|
239
|
-
return result(compactSnapshot(request));
|
|
240
|
-
}
|
|
241
|
-
return result(compactSnapshot(updatePersonalRequest(request, { parameters: {
|
|
242
|
-
...request.parameters,
|
|
243
|
-
notificationPreference: input.notificationPreference
|
|
244
|
-
} })));
|
|
245
|
-
}
|
|
246
|
-
if (input.command === "cancel") {
|
|
247
|
-
if (["completed", "failed"].includes(personalRequestSnapshot(request).state)) return result(compactSnapshot(request));
|
|
248
|
-
const cancelled = cancelPersonalRequest(request);
|
|
249
|
-
const stop = stopPersonalRequestExecution(cancelled);
|
|
250
|
-
publishPersonalRequest(cancelled);
|
|
251
|
-
return result({
|
|
252
|
-
...compactSnapshot(cancelled),
|
|
253
|
-
executionStopConfirmed: stop.executionStopConfirmed
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
if (input.command === "get" && input.section === "status" && !request.taskId) return result(compactSnapshot(request));
|
|
257
|
-
const taskTool = createPersonalTaskTool({
|
|
258
|
-
...deps,
|
|
259
|
-
getCurrentAgentId: () => deps.getCurrentAgentId?.() ?? getSessionMetadata(conversationId)?.agentId
|
|
216
|
+
if (input.command !== "submit") throw new Error("Use personal_task to manage an existing request");
|
|
217
|
+
if (input.notificationPreference !== void 0 && !isTaskNotificationPreference(input.notificationPreference)) throw new Error("Invalid Request notification preference");
|
|
218
|
+
const objective = input.objective?.trim();
|
|
219
|
+
const description = input.description?.trim();
|
|
220
|
+
if (!objective || !description) throw new Error("objective and a complete description are required");
|
|
221
|
+
const submission = {
|
|
222
|
+
objective,
|
|
223
|
+
description,
|
|
224
|
+
connectorId: resolveExactConnectionCandidate(input.connectorId ?? ""),
|
|
225
|
+
accountId: input.accountId,
|
|
226
|
+
timeRange: input.timeRange,
|
|
227
|
+
acceptancePolicy: input.acceptancePolicy,
|
|
228
|
+
notificationPreference: input.notificationPreference,
|
|
229
|
+
dueAt: input.dueAt
|
|
230
|
+
};
|
|
231
|
+
const inputId = getSessionInputState(conversationId).activeInputId ?? toolCallId;
|
|
232
|
+
const request = submitPersonalRequest({
|
|
233
|
+
conversationId,
|
|
234
|
+
...submission,
|
|
235
|
+
idempotencyKey: input.idempotencyKey ?? `personal-request-submit:${selectionRequestHash({
|
|
236
|
+
inputId,
|
|
237
|
+
...submission
|
|
238
|
+
})}`
|
|
239
|
+
});
|
|
240
|
+
publishPersonalRequest(request);
|
|
241
|
+
deps.dispatchTaskRuns?.();
|
|
242
|
+
return result({
|
|
243
|
+
...compactSnapshot(request),
|
|
244
|
+
guidance: request.state === "waiting_connection" ? "The objective is saved. The host presents the required connection or account selection and continues automatically afterward. Stop this turn; do not ask the user to confirm the read or reply continue." : "The request was accepted. No further user confirmation is needed. Report the returned state accurately, do not submit a duplicate, and wait for delivery without polling."
|
|
260
245
|
});
|
|
261
|
-
if (input.command === "instruct" && input.timeRange) assertPersonalRequestTimeRange(input.timeRange);
|
|
262
|
-
const instruction = input.command === "instruct" && input.timeRange ? `${input.instruction}\n\nUpdated absolute query range: ${JSON.stringify(input.timeRange)}` : input.instruction;
|
|
263
|
-
if (input.command === "answer" || input.command === "instruct") {
|
|
264
|
-
if ([
|
|
265
|
-
"completed",
|
|
266
|
-
"failed",
|
|
267
|
-
"cancelled"
|
|
268
|
-
].includes(personalRequestSnapshot(request).state)) throw new Error("Request is no longer active");
|
|
269
|
-
if (readCurrentTranscriptId(getSqliteDatabase(), conversationId) !== request.transcriptId) throw new Error("SESSION_CHANGED");
|
|
270
|
-
if (!request.taskId && input.command === "instruct" && request.state === "waiting_connection") {
|
|
271
|
-
const addition = `\n\nSupplemental requirement:\n${instruction.trim()}`;
|
|
272
|
-
if (!request.objective.endsWith(addition)) runSqliteWriteTransaction(() => {
|
|
273
|
-
if (getActiveConnectionWait(conversationId)?.id !== request.connectionWaitId) throw new Error("Connection objective changed");
|
|
274
|
-
reviseCurrentConnectionObjective(conversationId, request.objective + addition);
|
|
275
|
-
const revised = getActiveConnectionWait(conversationId);
|
|
276
|
-
updateConnectionWait({
|
|
277
|
-
...revised,
|
|
278
|
-
checkpoint: {
|
|
279
|
-
...revised.checkpoint,
|
|
280
|
-
timeRange: input.timeRange ?? request.parameters.timeRange
|
|
281
|
-
}
|
|
282
|
-
}, revised.version);
|
|
283
|
-
updatePersonalRequest(request, {
|
|
284
|
-
objective: request.objective + addition,
|
|
285
|
-
parameters: {
|
|
286
|
-
...request.parameters,
|
|
287
|
-
...input.timeRange ? { timeRange: input.timeRange } : {}
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
return result({
|
|
292
|
-
...snapshot(getPersonalRequest(request.requestId)),
|
|
293
|
-
instructionStatus: "saved",
|
|
294
|
-
guidance: "Account authorization is still required. The existing Request will create its Task with this requirement after authorization."
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
if (input.command !== "get" || request.taskId) {
|
|
299
|
-
if (!request.taskId) throw new Error("No Task yet; complete account authorization in the main connection UI");
|
|
300
|
-
const coordinated = await taskTool.execute(toolCallId, {
|
|
301
|
-
...input,
|
|
302
|
-
instruction,
|
|
303
|
-
taskId: request.taskId
|
|
304
|
-
});
|
|
305
|
-
if (input.command === "instruct" && input.timeRange && JSON.parse(coordinated.content[0].text).ok === true) runSqliteWriteTransaction(() => {
|
|
306
|
-
const current = getPersonalRequest(request.requestId);
|
|
307
|
-
updatePersonalRequest(current, { parameters: {
|
|
308
|
-
...current.parameters,
|
|
309
|
-
timeRange: input.timeRange
|
|
310
|
-
} });
|
|
311
|
-
const wait = getActiveConnectionWait(conversationId);
|
|
312
|
-
if (wait && wait.id === current.connectionWaitId) updateConnectionWait({
|
|
313
|
-
...wait,
|
|
314
|
-
checkpoint: {
|
|
315
|
-
...wait.checkpoint,
|
|
316
|
-
timeRange: input.timeRange
|
|
317
|
-
}
|
|
318
|
-
}, wait.version);
|
|
319
|
-
});
|
|
320
|
-
if (input.command !== "get") return coordinated;
|
|
321
|
-
return result({
|
|
322
|
-
...input.section === "status" ? compactSnapshot(request) : snapshot(request),
|
|
323
|
-
coordination: JSON.parse(coordinated.content[0].text)
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
return result(snapshot(request));
|
|
327
246
|
}
|
|
328
247
|
}];
|
|
329
248
|
}
|
|
330
249
|
//#endregion
|
|
331
|
-
export { createPersonalRequestTools };
|
|
250
|
+
export { PersonalRequestTimeRangeSchema, coordinatePersonalRequest, createPersonalRequestTools, listUnallocatedPersonalRequests };
|
|
@@ -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<{
|