@dexto/core 1.9.8 → 1.10.1
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/approval/factory.cjs +6 -3
- package/dist/approval/factory.d.ts.map +1 -1
- package/dist/approval/factory.js +6 -3
- package/dist/approval/index.cjs +2 -0
- package/dist/approval/index.d.ts +2 -2
- package/dist/approval/index.d.ts.map +1 -1
- package/dist/approval/index.js +2 -0
- package/dist/approval/manager.cjs +29 -44
- package/dist/approval/manager.d.ts +4 -2
- package/dist/approval/manager.d.ts.map +1 -1
- package/dist/approval/manager.js +30 -44
- package/dist/approval/schemas.cjs +7 -7
- package/dist/approval/schemas.d.ts +552 -5
- package/dist/approval/schemas.d.ts.map +1 -1
- package/dist/approval/schemas.js +5 -6
- package/dist/approval/types.d.ts +2 -1
- package/dist/approval/types.d.ts.map +1 -1
- package/dist/context/utils.cjs +28 -0
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +28 -0
- package/dist/index.browser.cjs +6 -0
- package/dist/index.browser.d.ts +4 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +4 -0
- package/dist/llm/errors.d.ts +8 -8
- package/dist/llm/formatters/vercel.cjs +59 -24
- package/dist/llm/formatters/vercel.d.ts.map +1 -1
- package/dist/llm/formatters/vercel.js +59 -24
- package/dist/llm/schemas.d.ts +3 -3
- package/dist/llm/services/factory.cjs +7 -0
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +7 -0
- package/dist/session/schemas.d.ts +2 -2
- package/dist/storage/tool-executions/types.cjs +2 -1
- package/dist/storage/tool-executions/types.d.ts +254 -3
- package/dist/storage/tool-executions/types.d.ts.map +1 -1
- package/dist/storage/tool-executions/types.js +2 -1
- package/dist/systemPrompt/schemas.d.ts +3 -3
- package/dist/tools/activity.cjs +341 -0
- package/dist/tools/activity.d.ts +70 -0
- package/dist/tools/activity.d.ts.map +1 -0
- package/dist/tools/activity.js +318 -0
- package/dist/tools/display-types.cjs +34 -4
- package/dist/tools/display-types.d.ts.map +1 -1
- package/dist/tools/display-types.js +34 -4
- package/dist/tools/index.cjs +8 -1
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +8 -1
- package/dist/tools/presentation/tool-presentation.cjs +78 -25
- package/dist/tools/presentation/tool-presentation.d.ts +2 -1
- package/dist/tools/presentation/tool-presentation.d.ts.map +1 -1
- package/dist/tools/presentation/tool-presentation.js +78 -25
- package/dist/tools/presentation-schema.cjs +118 -0
- package/dist/tools/presentation-schema.d.ts +132 -0
- package/dist/tools/presentation-schema.d.ts.map +1 -0
- package/dist/tools/presentation-schema.js +94 -0
- package/dist/tools/presentation.cjs +8 -0
- package/dist/tools/presentation.d.ts +4 -0
- package/dist/tools/presentation.d.ts.map +1 -1
- package/dist/tools/presentation.js +8 -0
- package/dist/tools/types.d.ts +12 -79
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/workspace/types.d.ts +1 -0
- package/dist/workspace/types.d.ts.map +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import "../chunk-C6A6W6XS.js";
|
|
2
|
+
function activity(category, running, completed, verb, singular, plural) {
|
|
3
|
+
return {
|
|
4
|
+
category,
|
|
5
|
+
label: { running, completed },
|
|
6
|
+
summary: { verb, singular, plural }
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const TOOL_ACTIVITY = {
|
|
10
|
+
runCommand: activity(
|
|
11
|
+
"command",
|
|
12
|
+
"Running command",
|
|
13
|
+
"Ran command",
|
|
14
|
+
"Ran",
|
|
15
|
+
"a command",
|
|
16
|
+
"commands"
|
|
17
|
+
),
|
|
18
|
+
checkCommandOutput: activity(
|
|
19
|
+
"command-output",
|
|
20
|
+
"Checking command output",
|
|
21
|
+
"Checked command output",
|
|
22
|
+
"Checked",
|
|
23
|
+
"command output",
|
|
24
|
+
"command outputs"
|
|
25
|
+
),
|
|
26
|
+
stopProcess: activity(
|
|
27
|
+
"process",
|
|
28
|
+
"Stopping process",
|
|
29
|
+
"Stopped process",
|
|
30
|
+
"Stopped",
|
|
31
|
+
"a process",
|
|
32
|
+
"processes"
|
|
33
|
+
),
|
|
34
|
+
readFile: activity("file-read", "Reading file", "Read file", "Read", "a file", "files"),
|
|
35
|
+
writeFile: activity("file-write", "Writing file", "Wrote file", "Wrote", "a file", "files"),
|
|
36
|
+
createFile: activity(
|
|
37
|
+
"file-create",
|
|
38
|
+
"Creating file",
|
|
39
|
+
"Created file",
|
|
40
|
+
"Created",
|
|
41
|
+
"a file",
|
|
42
|
+
"files"
|
|
43
|
+
),
|
|
44
|
+
editFile: activity("file-edit", "Editing file", "Edited file", "Edited", "a file", "files"),
|
|
45
|
+
searchFiles: activity(
|
|
46
|
+
"file-search",
|
|
47
|
+
"Searching files",
|
|
48
|
+
"Searched files",
|
|
49
|
+
"Ran",
|
|
50
|
+
"a file search",
|
|
51
|
+
"file searches"
|
|
52
|
+
),
|
|
53
|
+
searchWeb: activity(
|
|
54
|
+
"web-search",
|
|
55
|
+
"Searching the web",
|
|
56
|
+
"Searched the web",
|
|
57
|
+
"Ran",
|
|
58
|
+
"a web search",
|
|
59
|
+
"web searches"
|
|
60
|
+
),
|
|
61
|
+
searchCode: activity(
|
|
62
|
+
"code-search",
|
|
63
|
+
"Searching code",
|
|
64
|
+
"Searched code",
|
|
65
|
+
"Ran",
|
|
66
|
+
"a code search",
|
|
67
|
+
"code searches"
|
|
68
|
+
),
|
|
69
|
+
useSkill: activity("skill", "Using skill", "Used skill", "Used", "a skill", "skills"),
|
|
70
|
+
readSkill: activity("skill-read", "Reading skill", "Read skill", "Read", "a skill", "skills"),
|
|
71
|
+
createSkill: activity(
|
|
72
|
+
"skill-create",
|
|
73
|
+
"Creating skill",
|
|
74
|
+
"Created skill",
|
|
75
|
+
"Created",
|
|
76
|
+
"a skill",
|
|
77
|
+
"skills"
|
|
78
|
+
),
|
|
79
|
+
updateSkill: activity(
|
|
80
|
+
"skill-update",
|
|
81
|
+
"Updating skill",
|
|
82
|
+
"Updated skill",
|
|
83
|
+
"Updated",
|
|
84
|
+
"a skill",
|
|
85
|
+
"skills"
|
|
86
|
+
),
|
|
87
|
+
refreshSkill: activity(
|
|
88
|
+
"skill-refresh",
|
|
89
|
+
"Refreshing skill",
|
|
90
|
+
"Refreshed skill",
|
|
91
|
+
"Refreshed",
|
|
92
|
+
"a skill",
|
|
93
|
+
"skills"
|
|
94
|
+
),
|
|
95
|
+
searchSkills: activity(
|
|
96
|
+
"skill-search",
|
|
97
|
+
"Searching skills",
|
|
98
|
+
"Searched skills",
|
|
99
|
+
"Ran",
|
|
100
|
+
"a skill search",
|
|
101
|
+
"skill searches"
|
|
102
|
+
),
|
|
103
|
+
readResource: activity(
|
|
104
|
+
"resource",
|
|
105
|
+
"Reading resource",
|
|
106
|
+
"Read resource",
|
|
107
|
+
"Read",
|
|
108
|
+
"a resource",
|
|
109
|
+
"resources"
|
|
110
|
+
),
|
|
111
|
+
listResources: activity(
|
|
112
|
+
"resource-list",
|
|
113
|
+
"Listing resources",
|
|
114
|
+
"Listed resources",
|
|
115
|
+
"Listed",
|
|
116
|
+
"a resource catalog",
|
|
117
|
+
"resource catalogs"
|
|
118
|
+
),
|
|
119
|
+
requestHttp: activity(
|
|
120
|
+
"http-request",
|
|
121
|
+
"Sending request",
|
|
122
|
+
"Sent request",
|
|
123
|
+
"Sent",
|
|
124
|
+
"a request",
|
|
125
|
+
"requests"
|
|
126
|
+
),
|
|
127
|
+
delegate: activity(
|
|
128
|
+
"delegation",
|
|
129
|
+
"Delegating task",
|
|
130
|
+
"Delegated task",
|
|
131
|
+
"Delegated",
|
|
132
|
+
"a task",
|
|
133
|
+
"tasks"
|
|
134
|
+
),
|
|
135
|
+
runAgent: activity("agent", "Running agent", "Ran agent", "Ran", "an agent", "agents"),
|
|
136
|
+
checkTask: activity(
|
|
137
|
+
"task-check",
|
|
138
|
+
"Checking task",
|
|
139
|
+
"Checked task",
|
|
140
|
+
"Checked",
|
|
141
|
+
"a task",
|
|
142
|
+
"tasks"
|
|
143
|
+
),
|
|
144
|
+
listTasks: activity(
|
|
145
|
+
"task-list",
|
|
146
|
+
"Listing tasks",
|
|
147
|
+
"Listed tasks",
|
|
148
|
+
"Listed",
|
|
149
|
+
"a task collection",
|
|
150
|
+
"task collections"
|
|
151
|
+
),
|
|
152
|
+
updateTasks: activity(
|
|
153
|
+
"task",
|
|
154
|
+
"Updating tasks",
|
|
155
|
+
"Updated tasks",
|
|
156
|
+
"Updated",
|
|
157
|
+
"a task list",
|
|
158
|
+
"task lists"
|
|
159
|
+
),
|
|
160
|
+
createPlan: activity(
|
|
161
|
+
"plan-create",
|
|
162
|
+
"Creating plan",
|
|
163
|
+
"Created plan",
|
|
164
|
+
"Created",
|
|
165
|
+
"a plan",
|
|
166
|
+
"plans"
|
|
167
|
+
),
|
|
168
|
+
readPlan: activity("plan-read", "Reading plan", "Read plan", "Read", "a plan", "plans"),
|
|
169
|
+
reviewPlan: activity(
|
|
170
|
+
"plan-review",
|
|
171
|
+
"Reviewing plan",
|
|
172
|
+
"Reviewed plan",
|
|
173
|
+
"Reviewed",
|
|
174
|
+
"a plan",
|
|
175
|
+
"plans"
|
|
176
|
+
),
|
|
177
|
+
updatePlan: activity(
|
|
178
|
+
"plan-update",
|
|
179
|
+
"Updating plan",
|
|
180
|
+
"Updated plan",
|
|
181
|
+
"Updated",
|
|
182
|
+
"a plan",
|
|
183
|
+
"plans"
|
|
184
|
+
),
|
|
185
|
+
listMemories: activity(
|
|
186
|
+
"memory-list",
|
|
187
|
+
"Listing memories",
|
|
188
|
+
"Listed memories",
|
|
189
|
+
"Listed",
|
|
190
|
+
"a memory collection",
|
|
191
|
+
"memory collections"
|
|
192
|
+
),
|
|
193
|
+
readMemory: activity(
|
|
194
|
+
"memory-read",
|
|
195
|
+
"Reading memory",
|
|
196
|
+
"Read memory",
|
|
197
|
+
"Read",
|
|
198
|
+
"a memory",
|
|
199
|
+
"memories"
|
|
200
|
+
),
|
|
201
|
+
createMemory: activity(
|
|
202
|
+
"memory-create",
|
|
203
|
+
"Creating memory",
|
|
204
|
+
"Created memory",
|
|
205
|
+
"Created",
|
|
206
|
+
"a memory",
|
|
207
|
+
"memories"
|
|
208
|
+
),
|
|
209
|
+
updateMemory: activity(
|
|
210
|
+
"memory-update",
|
|
211
|
+
"Updating memory",
|
|
212
|
+
"Updated memory",
|
|
213
|
+
"Updated",
|
|
214
|
+
"a memory",
|
|
215
|
+
"memories"
|
|
216
|
+
),
|
|
217
|
+
deleteMemory: activity(
|
|
218
|
+
"memory-delete",
|
|
219
|
+
"Deleting memory",
|
|
220
|
+
"Deleted memory",
|
|
221
|
+
"Deleted",
|
|
222
|
+
"a memory",
|
|
223
|
+
"memories"
|
|
224
|
+
),
|
|
225
|
+
searchHistory: activity(
|
|
226
|
+
"history-search",
|
|
227
|
+
"Searching history",
|
|
228
|
+
"Searched history",
|
|
229
|
+
"Ran",
|
|
230
|
+
"a history search",
|
|
231
|
+
"history searches"
|
|
232
|
+
),
|
|
233
|
+
listSchedules: activity(
|
|
234
|
+
"schedule-list",
|
|
235
|
+
"Listing schedules",
|
|
236
|
+
"Listed schedules",
|
|
237
|
+
"Listed",
|
|
238
|
+
"a schedule collection",
|
|
239
|
+
"schedule collections"
|
|
240
|
+
),
|
|
241
|
+
readSchedule: activity(
|
|
242
|
+
"schedule-read",
|
|
243
|
+
"Reading schedule",
|
|
244
|
+
"Read schedule",
|
|
245
|
+
"Read",
|
|
246
|
+
"a schedule",
|
|
247
|
+
"schedules"
|
|
248
|
+
),
|
|
249
|
+
readScheduleHistory: activity(
|
|
250
|
+
"schedule-history",
|
|
251
|
+
"Reading schedule history",
|
|
252
|
+
"Read schedule history",
|
|
253
|
+
"Read",
|
|
254
|
+
"a schedule history",
|
|
255
|
+
"schedule histories"
|
|
256
|
+
),
|
|
257
|
+
createSchedule: activity(
|
|
258
|
+
"schedule-create",
|
|
259
|
+
"Creating schedule",
|
|
260
|
+
"Created schedule",
|
|
261
|
+
"Created",
|
|
262
|
+
"a schedule",
|
|
263
|
+
"schedules"
|
|
264
|
+
),
|
|
265
|
+
updateSchedule: activity(
|
|
266
|
+
"schedule-update",
|
|
267
|
+
"Updating schedule",
|
|
268
|
+
"Updated schedule",
|
|
269
|
+
"Updated",
|
|
270
|
+
"a schedule",
|
|
271
|
+
"schedules"
|
|
272
|
+
),
|
|
273
|
+
deleteSchedule: activity(
|
|
274
|
+
"schedule-delete",
|
|
275
|
+
"Deleting schedule",
|
|
276
|
+
"Deleted schedule",
|
|
277
|
+
"Deleted",
|
|
278
|
+
"a schedule",
|
|
279
|
+
"schedules"
|
|
280
|
+
),
|
|
281
|
+
triggerSchedule: activity(
|
|
282
|
+
"schedule-trigger",
|
|
283
|
+
"Running schedule",
|
|
284
|
+
"Ran schedule",
|
|
285
|
+
"Ran",
|
|
286
|
+
"a schedule",
|
|
287
|
+
"schedules"
|
|
288
|
+
),
|
|
289
|
+
inspectLogs: activity(
|
|
290
|
+
"logs",
|
|
291
|
+
"Inspecting logs",
|
|
292
|
+
"Inspected logs",
|
|
293
|
+
"Inspected",
|
|
294
|
+
"a log set",
|
|
295
|
+
"log sets"
|
|
296
|
+
),
|
|
297
|
+
wait: activity("wait", "Waiting", "Waited", "Waited for", "an event", "events"),
|
|
298
|
+
pause: activity("pause", "Waiting", "Waited", "Waited for", "a period", "periods"),
|
|
299
|
+
askUser: activity(
|
|
300
|
+
"user-input",
|
|
301
|
+
"Waiting for input",
|
|
302
|
+
"Received input",
|
|
303
|
+
"Requested",
|
|
304
|
+
"user input",
|
|
305
|
+
"user inputs"
|
|
306
|
+
),
|
|
307
|
+
discoverTools: activity(
|
|
308
|
+
"tool-discovery",
|
|
309
|
+
"Finding tools",
|
|
310
|
+
"Found tools",
|
|
311
|
+
"Ran",
|
|
312
|
+
"a tool search",
|
|
313
|
+
"tool searches"
|
|
314
|
+
)
|
|
315
|
+
};
|
|
316
|
+
export {
|
|
317
|
+
TOOL_ACTIVITY
|
|
318
|
+
};
|
|
@@ -41,13 +41,43 @@ function isFileDisplay(d) {
|
|
|
41
41
|
function isGenericDisplay(d) {
|
|
42
42
|
return d.type === "generic";
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
function isRecord(value) {
|
|
45
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
46
|
+
}
|
|
47
|
+
function isOptionalString(value) {
|
|
48
|
+
return value === void 0 || typeof value === "string";
|
|
49
|
+
}
|
|
50
|
+
function isNonNegativeInteger(value) {
|
|
51
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
52
|
+
}
|
|
53
|
+
function isOptionalNonNegativeInteger(value) {
|
|
54
|
+
return value === void 0 || isNonNegativeInteger(value);
|
|
55
|
+
}
|
|
56
|
+
function isSearchMatch(value) {
|
|
57
|
+
if (!isRecord(value)) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const context = value["context"];
|
|
61
|
+
return typeof value["file"] === "string" && isNonNegativeInteger(value["line"]) && typeof value["content"] === "string" && (context === void 0 || Array.isArray(context) && context.every((line) => typeof line === "string"));
|
|
62
|
+
}
|
|
45
63
|
function isValidDisplayData(d) {
|
|
46
|
-
if (d
|
|
64
|
+
if (!isRecord(d)) {
|
|
47
65
|
return false;
|
|
48
66
|
}
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
switch (d["type"]) {
|
|
68
|
+
case "diff":
|
|
69
|
+
return typeof d["unified"] === "string" && typeof d["filename"] === "string" && isNonNegativeInteger(d["additions"]) && isNonNegativeInteger(d["deletions"]) && isOptionalString(d["title"]) && isOptionalString(d["beforeContent"]) && isOptionalString(d["afterContent"]);
|
|
70
|
+
case "shell":
|
|
71
|
+
return typeof d["command"] === "string" && typeof d["exitCode"] === "number" && Number.isFinite(d["exitCode"]) && typeof d["duration"] === "number" && Number.isFinite(d["duration"]) && isOptionalString(d["title"]) && (d["isBackground"] === void 0 || typeof d["isBackground"] === "boolean") && isOptionalString(d["stdout"]) && isOptionalString(d["stderr"]);
|
|
72
|
+
case "search":
|
|
73
|
+
return typeof d["pattern"] === "string" && Array.isArray(d["matches"]) && d["matches"].every(isSearchMatch) && isNonNegativeInteger(d["totalMatches"]) && typeof d["truncated"] === "boolean" && isOptionalString(d["title"]);
|
|
74
|
+
case "file":
|
|
75
|
+
return typeof d["path"] === "string" && (d["operation"] === "read" || d["operation"] === "write" || d["operation"] === "create" || d["operation"] === "delete") && isOptionalString(d["title"]) && isOptionalNonNegativeInteger(d["size"]) && isOptionalNonNegativeInteger(d["lineCount"]) && isOptionalString(d["backupPath"]) && isOptionalString(d["content"]);
|
|
76
|
+
case "generic":
|
|
77
|
+
return isOptionalString(d["title"]);
|
|
78
|
+
default:
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
51
81
|
}
|
|
52
82
|
// Annotate the CommonJS export names for ESM import in node:
|
|
53
83
|
0 && (module.exports = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display-types.d.ts","sourceRoot":"","sources":["../../src/tools/display-types.ts"],"names":[],"mappings":"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
|
|
1
|
+
{"version":3,"file":"display-types.d.ts","sourceRoot":"","sources":["../../src/tools/display-types.ts"],"names":[],"mappings":"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"}
|
|
@@ -14,13 +14,43 @@ function isFileDisplay(d) {
|
|
|
14
14
|
function isGenericDisplay(d) {
|
|
15
15
|
return d.type === "generic";
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
function isRecord(value) {
|
|
18
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
function isOptionalString(value) {
|
|
21
|
+
return value === void 0 || typeof value === "string";
|
|
22
|
+
}
|
|
23
|
+
function isNonNegativeInteger(value) {
|
|
24
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
25
|
+
}
|
|
26
|
+
function isOptionalNonNegativeInteger(value) {
|
|
27
|
+
return value === void 0 || isNonNegativeInteger(value);
|
|
28
|
+
}
|
|
29
|
+
function isSearchMatch(value) {
|
|
30
|
+
if (!isRecord(value)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const context = value["context"];
|
|
34
|
+
return typeof value["file"] === "string" && isNonNegativeInteger(value["line"]) && typeof value["content"] === "string" && (context === void 0 || Array.isArray(context) && context.every((line) => typeof line === "string"));
|
|
35
|
+
}
|
|
18
36
|
function isValidDisplayData(d) {
|
|
19
|
-
if (d
|
|
37
|
+
if (!isRecord(d)) {
|
|
20
38
|
return false;
|
|
21
39
|
}
|
|
22
|
-
|
|
23
|
-
|
|
40
|
+
switch (d["type"]) {
|
|
41
|
+
case "diff":
|
|
42
|
+
return typeof d["unified"] === "string" && typeof d["filename"] === "string" && isNonNegativeInteger(d["additions"]) && isNonNegativeInteger(d["deletions"]) && isOptionalString(d["title"]) && isOptionalString(d["beforeContent"]) && isOptionalString(d["afterContent"]);
|
|
43
|
+
case "shell":
|
|
44
|
+
return typeof d["command"] === "string" && typeof d["exitCode"] === "number" && Number.isFinite(d["exitCode"]) && typeof d["duration"] === "number" && Number.isFinite(d["duration"]) && isOptionalString(d["title"]) && (d["isBackground"] === void 0 || typeof d["isBackground"] === "boolean") && isOptionalString(d["stdout"]) && isOptionalString(d["stderr"]);
|
|
45
|
+
case "search":
|
|
46
|
+
return typeof d["pattern"] === "string" && Array.isArray(d["matches"]) && d["matches"].every(isSearchMatch) && isNonNegativeInteger(d["totalMatches"]) && typeof d["truncated"] === "boolean" && isOptionalString(d["title"]);
|
|
47
|
+
case "file":
|
|
48
|
+
return typeof d["path"] === "string" && (d["operation"] === "read" || d["operation"] === "write" || d["operation"] === "create" || d["operation"] === "delete") && isOptionalString(d["title"]) && isOptionalNonNegativeInteger(d["size"]) && isOptionalNonNegativeInteger(d["lineCount"]) && isOptionalString(d["backupPath"]) && isOptionalString(d["content"]);
|
|
49
|
+
case "generic":
|
|
50
|
+
return isOptionalString(d["title"]);
|
|
51
|
+
default:
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
24
54
|
}
|
|
25
55
|
export {
|
|
26
56
|
isDiffDisplay,
|
package/dist/tools/index.cjs
CHANGED
|
@@ -24,13 +24,17 @@ __export(tools_exports, {
|
|
|
24
24
|
ToolError: () => import_errors.ToolError,
|
|
25
25
|
ToolErrorCode: () => import_error_codes.ToolErrorCode,
|
|
26
26
|
ToolManager: () => import_tool_manager.ToolManager,
|
|
27
|
-
|
|
27
|
+
ToolPresentationSnapshotV1Schema: () => import_presentation_schema.ToolPresentationSnapshotV1Schema,
|
|
28
|
+
defineTool: () => import_define_tool.defineTool,
|
|
29
|
+
isToolPresentationSnapshotV1: () => import_presentation_schema.isToolPresentationSnapshotV1
|
|
28
30
|
});
|
|
29
31
|
module.exports = __toCommonJS(tools_exports);
|
|
30
32
|
__reExport(tools_exports, require("./types.js"), module.exports);
|
|
31
33
|
var import_define_tool = require("./define-tool.js");
|
|
32
34
|
var import_session_tool_preferences_store = require("./session-tool-preferences-store.js");
|
|
33
35
|
__reExport(tools_exports, require("./display-types.js"), module.exports);
|
|
36
|
+
__reExport(tools_exports, require("./activity.js"), module.exports);
|
|
37
|
+
var import_presentation_schema = require("./presentation-schema.js");
|
|
34
38
|
__reExport(tools_exports, require("./schemas.js"), module.exports);
|
|
35
39
|
__reExport(tools_exports, require("./presentation.js"), module.exports);
|
|
36
40
|
var import_errors = require("./errors.js");
|
|
@@ -43,9 +47,12 @@ var import_tool_manager = require("./tool-manager.js");
|
|
|
43
47
|
ToolError,
|
|
44
48
|
ToolErrorCode,
|
|
45
49
|
ToolManager,
|
|
50
|
+
ToolPresentationSnapshotV1Schema,
|
|
46
51
|
defineTool,
|
|
52
|
+
isToolPresentationSnapshotV1,
|
|
47
53
|
...require("./types.js"),
|
|
48
54
|
...require("./display-types.js"),
|
|
55
|
+
...require("./activity.js"),
|
|
49
56
|
...require("./schemas.js"),
|
|
50
57
|
...require("./presentation.js")
|
|
51
58
|
});
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export { defineTool } from './define-tool.js';
|
|
|
9
9
|
export { SessionToolPreferencesSchema, SessionToolPreferencesStore, } from './session-tool-preferences-store.js';
|
|
10
10
|
export type { SessionToolPreferences } from './session-tool-preferences-store.js';
|
|
11
11
|
export * from './display-types.js';
|
|
12
|
+
export * from './activity.js';
|
|
13
|
+
export { isToolPresentationSnapshotV1, ToolPresentationSnapshotV1Schema, } from './presentation-schema.js';
|
|
14
|
+
export type { ToolPresentationSnapshotV1 } from './presentation-schema.js';
|
|
12
15
|
export * from './schemas.js';
|
|
13
16
|
export * from './presentation.js';
|
|
14
17
|
export type { ToolCallMetadata, ToolCallMetaWrapper } from './tool-call-metadata.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACH,4BAA4B,EAC5B,2BAA2B,GAC9B,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAGlF,cAAc,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACH,4BAA4B,EAC5B,2BAA2B,GAC9B,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAGlF,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,OAAO,EACH,4BAA4B,EAC5B,gCAAgC,GACnC,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAG3E,cAAc,cAAc,CAAC;AAG7B,cAAc,mBAAmB,CAAC;AAClC,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGrF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,OAAO,EAAE,WAAW,EAAE,KAAK,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAClF,YAAY,EACR,kBAAkB,EAClB,oBAAoB,EACpB,+BAA+B,EAC/B,0BAA0B,EAC1B,gCAAgC,EAChC,gBAAgB,EAChB,oBAAoB,GACvB,MAAM,mBAAmB,CAAC"}
|
package/dist/tools/index.js
CHANGED
|
@@ -6,6 +6,11 @@ import {
|
|
|
6
6
|
SessionToolPreferencesStore
|
|
7
7
|
} from "./session-tool-preferences-store.js";
|
|
8
8
|
export * from "./display-types.js";
|
|
9
|
+
export * from "./activity.js";
|
|
10
|
+
import {
|
|
11
|
+
isToolPresentationSnapshotV1,
|
|
12
|
+
ToolPresentationSnapshotV1Schema
|
|
13
|
+
} from "./presentation-schema.js";
|
|
9
14
|
export * from "./schemas.js";
|
|
10
15
|
export * from "./presentation.js";
|
|
11
16
|
import { ToolError } from "./errors.js";
|
|
@@ -17,5 +22,7 @@ export {
|
|
|
17
22
|
ToolError,
|
|
18
23
|
ToolErrorCode,
|
|
19
24
|
ToolManager,
|
|
20
|
-
|
|
25
|
+
ToolPresentationSnapshotV1Schema,
|
|
26
|
+
defineTool,
|
|
27
|
+
isToolPresentationSnapshotV1
|
|
21
28
|
};
|
|
@@ -23,6 +23,7 @@ __export(tool_presentation_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(tool_presentation_exports);
|
|
24
24
|
var import_errors = require("../../errors/index.js");
|
|
25
25
|
var import_error_codes = require("../error-codes.js");
|
|
26
|
+
var import_display_types = require("../display-types.js");
|
|
26
27
|
const MCP_TOOL_PREFIX = "mcp--";
|
|
27
28
|
class ToolPresentation {
|
|
28
29
|
constructor(getLocalTool, validateLocalToolArgs, buildToolExecutionContext, logger) {
|
|
@@ -58,13 +59,16 @@ class ToolPresentation {
|
|
|
58
59
|
return fallback;
|
|
59
60
|
}
|
|
60
61
|
const presentation = this.getLocalTool(input.toolName)?.presentation;
|
|
61
|
-
if (!presentation?.describeHeader && !presentation?.describeArgs) {
|
|
62
|
+
if (!presentation?.activity && !presentation?.describeHeader && !presentation?.describeArgs) {
|
|
62
63
|
return fallback;
|
|
63
64
|
}
|
|
65
|
+
let nextSnapshot = {
|
|
66
|
+
...fallback,
|
|
67
|
+
...presentation.activity ? { activity: presentation.activity } : {}
|
|
68
|
+
};
|
|
64
69
|
try {
|
|
65
70
|
const validatedArgs = this.validateLocalToolArgs(input.toolName, input.args);
|
|
66
71
|
const context = this.buildToolExecutionContext(input);
|
|
67
|
-
let nextSnapshot = fallback;
|
|
68
72
|
const header = presentation.describeHeader?.(validatedArgs, context);
|
|
69
73
|
if (!isPromiseLike(header) && header) {
|
|
70
74
|
nextSnapshot = {
|
|
@@ -84,7 +88,7 @@ class ToolPresentation {
|
|
|
84
88
|
this.logger.debug(
|
|
85
89
|
`Tool presentation snapshot generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
86
90
|
);
|
|
87
|
-
return
|
|
91
|
+
return nextSnapshot;
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
async snapshotForCall(input) {
|
|
@@ -93,51 +97,100 @@ class ToolPresentation {
|
|
|
93
97
|
return fallback;
|
|
94
98
|
}
|
|
95
99
|
const presentation = this.getLocalTool(input.toolName)?.presentation;
|
|
96
|
-
if (!presentation?.describeHeader && !presentation?.describeArgs) {
|
|
100
|
+
if (!presentation?.activity && !presentation?.describeHeader && !presentation?.describeArgs) {
|
|
97
101
|
return fallback;
|
|
98
102
|
}
|
|
103
|
+
let nextSnapshot = {
|
|
104
|
+
...fallback,
|
|
105
|
+
...presentation.activity ? { activity: presentation.activity } : {}
|
|
106
|
+
};
|
|
107
|
+
let context;
|
|
108
|
+
try {
|
|
109
|
+
context = this.buildToolExecutionContext(input);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
this.logger.debug(
|
|
112
|
+
`Tool presentation snapshot generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
113
|
+
);
|
|
114
|
+
return nextSnapshot;
|
|
115
|
+
}
|
|
99
116
|
try {
|
|
100
|
-
const context = this.buildToolExecutionContext(input);
|
|
101
117
|
const describedHeader = presentation.describeHeader ? await Promise.resolve(presentation.describeHeader(input.args, context)) : null;
|
|
118
|
+
if (describedHeader) {
|
|
119
|
+
nextSnapshot = {
|
|
120
|
+
...nextSnapshot,
|
|
121
|
+
header: { ...nextSnapshot.header, ...describedHeader }
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
} catch (error) {
|
|
125
|
+
this.logger.debug(
|
|
126
|
+
`Tool header presentation generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
102
130
|
const describedArgs = presentation.describeArgs ? await Promise.resolve(presentation.describeArgs(input.args, context)) : null;
|
|
103
|
-
|
|
104
|
-
...
|
|
105
|
-
|
|
106
|
-
...describedArgs ? { args: describedArgs } : {}
|
|
107
|
-
};
|
|
131
|
+
if (describedArgs) {
|
|
132
|
+
nextSnapshot = { ...nextSnapshot, args: describedArgs };
|
|
133
|
+
}
|
|
108
134
|
} catch (error) {
|
|
109
135
|
this.logger.debug(
|
|
110
|
-
`Tool presentation
|
|
136
|
+
`Tool argument presentation generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
111
137
|
);
|
|
112
|
-
return fallback;
|
|
113
138
|
}
|
|
139
|
+
return nextSnapshot;
|
|
114
140
|
}
|
|
115
141
|
async augmentWithResult(input) {
|
|
116
142
|
if (input.toolName.startsWith(MCP_TOOL_PREFIX)) {
|
|
117
143
|
return input.snapshot;
|
|
118
144
|
}
|
|
119
|
-
const
|
|
120
|
-
if (!describeResult) {
|
|
145
|
+
const presentation = this.getLocalTool(input.toolName)?.presentation;
|
|
146
|
+
if (!presentation?.describeResult && !presentation?.describeResultActivity) {
|
|
121
147
|
return input.snapshot;
|
|
122
148
|
}
|
|
149
|
+
let context;
|
|
123
150
|
try {
|
|
124
|
-
|
|
125
|
-
const resultPresentation = await Promise.resolve(
|
|
126
|
-
describeResult(input.result, input.args, context)
|
|
127
|
-
);
|
|
128
|
-
if (!resultPresentation) {
|
|
129
|
-
return input.snapshot;
|
|
130
|
-
}
|
|
131
|
-
return {
|
|
132
|
-
...input.snapshot,
|
|
133
|
-
result: resultPresentation
|
|
134
|
-
};
|
|
151
|
+
context = this.buildToolExecutionContext(input);
|
|
135
152
|
} catch (error) {
|
|
136
153
|
this.logger.debug(
|
|
137
154
|
`Tool result presentation snapshot generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
138
155
|
);
|
|
139
156
|
return input.snapshot;
|
|
140
157
|
}
|
|
158
|
+
let resultPresentation;
|
|
159
|
+
try {
|
|
160
|
+
resultPresentation = presentation.describeResult ? await Promise.resolve(
|
|
161
|
+
presentation.describeResult(input.result, input.args, context)
|
|
162
|
+
) ?? void 0 : void 0;
|
|
163
|
+
} catch (error) {
|
|
164
|
+
this.logger.debug(
|
|
165
|
+
`Tool result presentation generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
let resultActivity;
|
|
169
|
+
try {
|
|
170
|
+
resultActivity = presentation.describeResultActivity ? await Promise.resolve(
|
|
171
|
+
presentation.describeResultActivity(
|
|
172
|
+
this.extractDisplayData(input.result),
|
|
173
|
+
input.args,
|
|
174
|
+
context
|
|
175
|
+
)
|
|
176
|
+
) ?? void 0 : void 0;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
this.logger.debug(
|
|
179
|
+
`Tool result activity generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
...input.snapshot,
|
|
184
|
+
...resultActivity ? { activity: resultActivity } : {},
|
|
185
|
+
...resultPresentation ? { result: resultPresentation } : {}
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
extractDisplayData(result) {
|
|
189
|
+
if (result === null || typeof result !== "object" || !("_display" in result)) {
|
|
190
|
+
return void 0;
|
|
191
|
+
}
|
|
192
|
+
const display = result._display;
|
|
193
|
+
return (0, import_display_types.isValidDisplayData)(display) ? display : void 0;
|
|
141
194
|
}
|
|
142
195
|
async preview(input) {
|
|
143
196
|
if (input.toolName.startsWith(MCP_TOOL_PREFIX)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Logger } from '../../logger/v2/types.js';
|
|
2
2
|
import type { AgentRunContext } from '../../runtime/run-context.js';
|
|
3
3
|
import type { Tool, ToolExecutionContext, ToolPresentationSnapshotV1 } from '../types.js';
|
|
4
|
-
import type
|
|
4
|
+
import { type ToolDisplayData } from '../display-types.js';
|
|
5
5
|
type BuildToolExecutionContext = (options: {
|
|
6
6
|
sessionId?: string | undefined;
|
|
7
7
|
toolCallId?: string | undefined;
|
|
@@ -37,6 +37,7 @@ export declare class ToolPresentation {
|
|
|
37
37
|
sessionId?: string | undefined;
|
|
38
38
|
runContext?: AgentRunContext | undefined;
|
|
39
39
|
}): Promise<ToolPresentationSnapshotV1>;
|
|
40
|
+
private extractDisplayData;
|
|
40
41
|
preview(input: {
|
|
41
42
|
toolName: string;
|
|
42
43
|
args: Record<string, unknown>;
|