@dexto/core 1.10.3 → 1.11.0
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/agent/DextoAgent.cjs +22 -12
- package/dist/agent/DextoAgent.d.ts +3 -3
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +22 -15
- package/dist/agent/agent-options.d.ts +3 -3
- package/dist/agent/agent-options.d.ts.map +1 -1
- package/dist/approval/schemas.d.ts +8 -8
- package/dist/context/types.d.ts +3 -1
- package/dist/context/types.d.ts.map +1 -1
- package/dist/context/utils.cjs +10 -2
- package/dist/context/utils.d.ts +3 -0
- package/dist/context/utils.d.ts.map +1 -1
- package/dist/context/utils.js +10 -2
- package/dist/events/index.d.ts +0 -4
- package/dist/events/index.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.cjs +2 -1
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +2 -1
- package/dist/skills/contracts.cjs +42 -0
- package/dist/skills/contracts.d.ts +20 -0
- package/dist/skills/contracts.d.ts.map +1 -0
- package/dist/skills/contracts.js +18 -0
- package/dist/skills/index.cjs +5 -6
- package/dist/skills/index.d.ts +3 -3
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +3 -4
- package/dist/skills/types.d.ts +14 -18
- package/dist/skills/types.d.ts.map +1 -1
- package/dist/storage/index.cjs +9 -2
- package/dist/storage/index.d.ts +1 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +9 -1
- package/dist/storage/tool-executions/types.cjs +16 -0
- package/dist/storage/tool-executions/types.d.ts +19 -4
- package/dist/storage/tool-executions/types.d.ts.map +1 -1
- package/dist/storage/tool-executions/types.js +16 -0
- package/dist/systemPrompt/contributors.cjs +5 -8
- package/dist/systemPrompt/contributors.d.ts +4 -4
- package/dist/systemPrompt/contributors.d.ts.map +1 -1
- package/dist/systemPrompt/contributors.js +5 -8
- package/dist/tools/display-types.cjs +41 -0
- package/dist/tools/display-types.d.ts +54 -3
- package/dist/tools/display-types.d.ts.map +1 -1
- package/dist/tools/display-types.js +36 -0
- package/dist/tools/presentation/tool-presentation.cjs +47 -0
- package/dist/tools/presentation/tool-presentation.d.ts +10 -1
- package/dist/tools/presentation/tool-presentation.d.ts.map +1 -1
- package/dist/tools/presentation/tool-presentation.js +47 -0
- package/dist/tools/presentation-schema.d.ts +2 -2
- package/dist/tools/presentation.d.ts +1 -0
- package/dist/tools/presentation.d.ts.map +1 -1
- package/dist/tools/tool-call-metadata.cjs +17 -3
- package/dist/tools/tool-call-metadata.d.ts +4 -1
- package/dist/tools/tool-call-metadata.d.ts.map +1 -1
- package/dist/tools/tool-call-metadata.js +17 -3
- package/dist/tools/tool-manager.cjs +14 -5
- package/dist/tools/tool-manager.d.ts +0 -1
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +14 -5
- package/dist/tools/types.d.ts +23 -2
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/execution-context.cjs +3 -3
- package/dist/utils/execution-context.d.ts.map +1 -1
- package/dist/utils/execution-context.js +3 -3
- package/package.json +2 -2
- package/dist/skills/skill-manager.cjs +0 -76
- package/dist/skills/skill-manager.d.ts +0 -13
- package/dist/skills/skill-manager.d.ts.map +0 -1
- package/dist/skills/skill-manager.js +0 -53
- package/dist/skills/workspace-skill-source.cjs +0 -120
- package/dist/skills/workspace-skill-source.d.ts +0 -16
- package/dist/skills/workspace-skill-source.d.ts.map +0 -1
- package/dist/skills/workspace-skill-source.js +0 -97
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contributors.d.ts","sourceRoot":"","sources":["../../src/systemPrompt/contributors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAGhF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,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QAAQ,EAAE,MAAM;IACvB,OAAO,CAAC,MAAM;IALlB,OAAO,CAAC,MAAM,CAAS;gBAGZ,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM;IAMZ,UAAU,CAAC,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC;CAoCzE"}
|
|
@@ -168,10 +168,10 @@ ${memoryList}`;
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
class SkillsContributor {
|
|
171
|
-
constructor(id, priority,
|
|
171
|
+
constructor(id, priority, skills, logger) {
|
|
172
172
|
this.id = id;
|
|
173
173
|
this.priority = priority;
|
|
174
|
-
this.
|
|
174
|
+
this.skills = skills;
|
|
175
175
|
this.logger = logger;
|
|
176
176
|
this.logger.debug(`[SkillsContributor] Created "${id}"`);
|
|
177
177
|
}
|
|
@@ -184,19 +184,16 @@ class SkillsContributor {
|
|
|
184
184
|
componentName: "SkillsContributor",
|
|
185
185
|
resultAttributes: (skills2) => ({ "skills.count": skills2.length })
|
|
186
186
|
},
|
|
187
|
-
() => this.
|
|
187
|
+
() => this.skills.list(),
|
|
188
188
|
this.logger
|
|
189
189
|
);
|
|
190
190
|
if (skills.length === 0) {
|
|
191
191
|
return "";
|
|
192
192
|
}
|
|
193
|
-
const skillsList = skills.map((skill) => {
|
|
194
|
-
const desc = skill.description ? ` - ${skill.description}` : "";
|
|
195
|
-
return `- ${skill.displayName}${desc}`;
|
|
196
|
-
}).join("\n");
|
|
193
|
+
const skillsList = skills.map((skill) => `- ${skill.name} - ${skill.description}`).join("\n");
|
|
197
194
|
const result = `## Available Skills
|
|
198
195
|
|
|
199
|
-
Use \`
|
|
196
|
+
Use \`skill_load\` when one of these skills is relevant:
|
|
200
197
|
|
|
201
198
|
${skillsList}`;
|
|
202
199
|
this.logger.debug(
|
|
@@ -18,11 +18,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var display_types_exports = {};
|
|
20
20
|
__export(display_types_exports, {
|
|
21
|
+
isCollectionDisplay: () => isCollectionDisplay,
|
|
21
22
|
isDiffDisplay: () => isDiffDisplay,
|
|
22
23
|
isFileDisplay: () => isFileDisplay,
|
|
23
24
|
isGenericDisplay: () => isGenericDisplay,
|
|
25
|
+
isProcessDisplay: () => isProcessDisplay,
|
|
26
|
+
isRecordDisplay: () => isRecordDisplay,
|
|
24
27
|
isSearchDisplay: () => isSearchDisplay,
|
|
25
28
|
isShellDisplay: () => isShellDisplay,
|
|
29
|
+
isStatusDisplay: () => isStatusDisplay,
|
|
30
|
+
isTextDisplay: () => isTextDisplay,
|
|
26
31
|
isValidDisplayData: () => isValidDisplayData
|
|
27
32
|
});
|
|
28
33
|
module.exports = __toCommonJS(display_types_exports);
|
|
@@ -41,12 +46,30 @@ function isFileDisplay(d) {
|
|
|
41
46
|
function isGenericDisplay(d) {
|
|
42
47
|
return d.type === "generic";
|
|
43
48
|
}
|
|
49
|
+
function isTextDisplay(d) {
|
|
50
|
+
return d.type === "text";
|
|
51
|
+
}
|
|
52
|
+
function isStatusDisplay(d) {
|
|
53
|
+
return d.type === "status";
|
|
54
|
+
}
|
|
55
|
+
function isRecordDisplay(d) {
|
|
56
|
+
return d.type === "record";
|
|
57
|
+
}
|
|
58
|
+
function isCollectionDisplay(d) {
|
|
59
|
+
return d.type === "collection";
|
|
60
|
+
}
|
|
61
|
+
function isProcessDisplay(d) {
|
|
62
|
+
return d.type === "process";
|
|
63
|
+
}
|
|
44
64
|
function isRecord(value) {
|
|
45
65
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
46
66
|
}
|
|
47
67
|
function isOptionalString(value) {
|
|
48
68
|
return value === void 0 || typeof value === "string";
|
|
49
69
|
}
|
|
70
|
+
function isNullableString(value) {
|
|
71
|
+
return value === null || typeof value === "string";
|
|
72
|
+
}
|
|
50
73
|
function isNonNegativeInteger(value) {
|
|
51
74
|
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
52
75
|
}
|
|
@@ -60,6 +83,9 @@ function isSearchMatch(value) {
|
|
|
60
83
|
const context = value["context"];
|
|
61
84
|
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
85
|
}
|
|
86
|
+
function isToolDisplayField(value) {
|
|
87
|
+
return isRecord(value) && typeof value["label"] === "string" && typeof value["value"] === "string";
|
|
88
|
+
}
|
|
63
89
|
function isValidDisplayData(d) {
|
|
64
90
|
if (!isRecord(d)) {
|
|
65
91
|
return false;
|
|
@@ -75,16 +101,31 @@ function isValidDisplayData(d) {
|
|
|
75
101
|
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
102
|
case "generic":
|
|
77
103
|
return isOptionalString(d["title"]);
|
|
104
|
+
case "text":
|
|
105
|
+
return isNullableString(d["title"]) && typeof d["text"] === "string";
|
|
106
|
+
case "status":
|
|
107
|
+
return isNullableString(d["title"]) && (d["status"] === "success" || d["status"] === "error" || d["status"] === "info" || d["status"] === "warning") && typeof d["message"] === "string";
|
|
108
|
+
case "record":
|
|
109
|
+
return isNullableString(d["title"]) && Array.isArray(d["fields"]) && d["fields"].every(isToolDisplayField);
|
|
110
|
+
case "collection":
|
|
111
|
+
return isNullableString(d["title"]) && Array.isArray(d["items"]) && d["items"].every((item) => typeof item === "string");
|
|
112
|
+
case "process":
|
|
113
|
+
return isNullableString(d["title"]) && typeof d["processId"] === "string" && isNullableString(d["command"]) && (d["state"] === "running" || d["state"] === "succeeded" || d["state"] === "failed" || d["state"] === "stopped" || d["state"] === "interrupted") && (d["exitCode"] === null || typeof d["exitCode"] === "number" && Number.isInteger(d["exitCode"])) && isNullableString(d["startedAt"]) && isNullableString(d["finishedAt"]);
|
|
78
114
|
default:
|
|
79
115
|
return false;
|
|
80
116
|
}
|
|
81
117
|
}
|
|
82
118
|
// Annotate the CommonJS export names for ESM import in node:
|
|
83
119
|
0 && (module.exports = {
|
|
120
|
+
isCollectionDisplay,
|
|
84
121
|
isDiffDisplay,
|
|
85
122
|
isFileDisplay,
|
|
86
123
|
isGenericDisplay,
|
|
124
|
+
isProcessDisplay,
|
|
125
|
+
isRecordDisplay,
|
|
87
126
|
isSearchDisplay,
|
|
88
127
|
isShellDisplay,
|
|
128
|
+
isStatusDisplay,
|
|
129
|
+
isTextDisplay,
|
|
89
130
|
isValidDisplayData
|
|
90
131
|
});
|
|
@@ -5,14 +5,55 @@
|
|
|
5
5
|
* These types enable both CLI and WebUI to render tool results with
|
|
6
6
|
* appropriate formatting (diffs, shell output, search results, etc.)
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Legacy tools may return a `_display` field in their result. Tool presentation resolvers can
|
|
9
|
+
* provide the same metadata without adding it to the model-visible result. Both paths end up in
|
|
10
|
+
* `SanitizedToolResult.meta.display`.
|
|
10
11
|
*/
|
|
11
12
|
/**
|
|
12
13
|
* Discriminated union of all tool display data types.
|
|
13
14
|
* Switch on `type` field for exhaustive handling.
|
|
14
15
|
*/
|
|
15
|
-
export type ToolDisplayData = DiffDisplayData | ShellDisplayData | SearchDisplayData | FileDisplayData | GenericDisplayData;
|
|
16
|
+
export type ToolDisplayData = DiffDisplayData | ShellDisplayData | SearchDisplayData | FileDisplayData | GenericDisplayData | TextDisplayData | StatusDisplayData | RecordDisplayData | CollectionDisplayData | ProcessDisplayData;
|
|
17
|
+
/** Display data for a plain text result. */
|
|
18
|
+
export interface TextDisplayData {
|
|
19
|
+
type: 'text';
|
|
20
|
+
title: string | null;
|
|
21
|
+
text: string;
|
|
22
|
+
}
|
|
23
|
+
/** Display data for a single operation status. */
|
|
24
|
+
export interface StatusDisplayData {
|
|
25
|
+
type: 'status';
|
|
26
|
+
title: string | null;
|
|
27
|
+
status: 'success' | 'error' | 'info' | 'warning';
|
|
28
|
+
message: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ToolDisplayField {
|
|
31
|
+
label: string;
|
|
32
|
+
value: string;
|
|
33
|
+
}
|
|
34
|
+
/** Display data for one structured record. */
|
|
35
|
+
export interface RecordDisplayData {
|
|
36
|
+
type: 'record';
|
|
37
|
+
title: string | null;
|
|
38
|
+
fields: ToolDisplayField[];
|
|
39
|
+
}
|
|
40
|
+
/** Display data for a list of values. */
|
|
41
|
+
export interface CollectionDisplayData {
|
|
42
|
+
type: 'collection';
|
|
43
|
+
title: string | null;
|
|
44
|
+
items: string[];
|
|
45
|
+
}
|
|
46
|
+
/** Display data for a supervised process and its lifecycle state. */
|
|
47
|
+
export interface ProcessDisplayData {
|
|
48
|
+
type: 'process';
|
|
49
|
+
title: string | null;
|
|
50
|
+
processId: string;
|
|
51
|
+
command: string | null;
|
|
52
|
+
state: 'running' | 'succeeded' | 'failed' | 'stopped' | 'interrupted';
|
|
53
|
+
exitCode: number | null;
|
|
54
|
+
startedAt: string | null;
|
|
55
|
+
finishedAt: string | null;
|
|
56
|
+
}
|
|
16
57
|
/**
|
|
17
58
|
* Display data for file edit operations (edit_file, write_file overwrites).
|
|
18
59
|
* Contains unified diff format for rendering changes.
|
|
@@ -135,6 +176,16 @@ export declare function isFileDisplay(d: ToolDisplayData): d is FileDisplayData;
|
|
|
135
176
|
* Type guard for GenericDisplayData.
|
|
136
177
|
*/
|
|
137
178
|
export declare function isGenericDisplay(d: ToolDisplayData): d is GenericDisplayData;
|
|
179
|
+
/** Type guard for TextDisplayData. */
|
|
180
|
+
export declare function isTextDisplay(d: ToolDisplayData): d is TextDisplayData;
|
|
181
|
+
/** Type guard for StatusDisplayData. */
|
|
182
|
+
export declare function isStatusDisplay(d: ToolDisplayData): d is StatusDisplayData;
|
|
183
|
+
/** Type guard for RecordDisplayData. */
|
|
184
|
+
export declare function isRecordDisplay(d: ToolDisplayData): d is RecordDisplayData;
|
|
185
|
+
/** Type guard for CollectionDisplayData. */
|
|
186
|
+
export declare function isCollectionDisplay(d: ToolDisplayData): d is CollectionDisplayData;
|
|
187
|
+
/** Type guard for ProcessDisplayData. */
|
|
188
|
+
export declare function isProcessDisplay(d: ToolDisplayData): d is ProcessDisplayData;
|
|
138
189
|
/**
|
|
139
190
|
* Validates that an unknown value is a valid ToolDisplayData.
|
|
140
191
|
* Used by sanitizer to safely extract _display from tool results.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display-types.d.ts","sourceRoot":"","sources":["../../src/tools/display-types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"display-types.d.ts","sourceRoot":"","sources":["../../src/tools/display-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;;GAGG;AACH,MAAM,MAAM,eAAe,GACrB,eAAe,GACf,gBAAgB,GAChB,iBAAiB,GACjB,eAAe,GACf,kBAAkB,GAClB,eAAe,GACf,iBAAiB,GACjB,iBAAiB,GACjB,qBAAqB,GACrB,kBAAkB,CAAC;AAEzB,4CAA4C;AAC5C,MAAM,WAAW,eAAe;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,kDAAkD;AAClD,MAAM,WAAW,iBAAiB;IAC9B,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IACjD,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB;AAED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
14
|
function isGenericDisplay(d) {
|
|
15
15
|
return d.type === "generic";
|
|
16
16
|
}
|
|
17
|
+
function isTextDisplay(d) {
|
|
18
|
+
return d.type === "text";
|
|
19
|
+
}
|
|
20
|
+
function isStatusDisplay(d) {
|
|
21
|
+
return d.type === "status";
|
|
22
|
+
}
|
|
23
|
+
function isRecordDisplay(d) {
|
|
24
|
+
return d.type === "record";
|
|
25
|
+
}
|
|
26
|
+
function isCollectionDisplay(d) {
|
|
27
|
+
return d.type === "collection";
|
|
28
|
+
}
|
|
29
|
+
function isProcessDisplay(d) {
|
|
30
|
+
return d.type === "process";
|
|
31
|
+
}
|
|
17
32
|
function isRecord(value) {
|
|
18
33
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19
34
|
}
|
|
20
35
|
function isOptionalString(value) {
|
|
21
36
|
return value === void 0 || typeof value === "string";
|
|
22
37
|
}
|
|
38
|
+
function isNullableString(value) {
|
|
39
|
+
return value === null || typeof value === "string";
|
|
40
|
+
}
|
|
23
41
|
function isNonNegativeInteger(value) {
|
|
24
42
|
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
25
43
|
}
|
|
@@ -33,6 +51,9 @@ function isSearchMatch(value) {
|
|
|
33
51
|
const context = value["context"];
|
|
34
52
|
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
53
|
}
|
|
54
|
+
function isToolDisplayField(value) {
|
|
55
|
+
return isRecord(value) && typeof value["label"] === "string" && typeof value["value"] === "string";
|
|
56
|
+
}
|
|
36
57
|
function isValidDisplayData(d) {
|
|
37
58
|
if (!isRecord(d)) {
|
|
38
59
|
return false;
|
|
@@ -48,15 +69,30 @@ function isValidDisplayData(d) {
|
|
|
48
69
|
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
70
|
case "generic":
|
|
50
71
|
return isOptionalString(d["title"]);
|
|
72
|
+
case "text":
|
|
73
|
+
return isNullableString(d["title"]) && typeof d["text"] === "string";
|
|
74
|
+
case "status":
|
|
75
|
+
return isNullableString(d["title"]) && (d["status"] === "success" || d["status"] === "error" || d["status"] === "info" || d["status"] === "warning") && typeof d["message"] === "string";
|
|
76
|
+
case "record":
|
|
77
|
+
return isNullableString(d["title"]) && Array.isArray(d["fields"]) && d["fields"].every(isToolDisplayField);
|
|
78
|
+
case "collection":
|
|
79
|
+
return isNullableString(d["title"]) && Array.isArray(d["items"]) && d["items"].every((item) => typeof item === "string");
|
|
80
|
+
case "process":
|
|
81
|
+
return isNullableString(d["title"]) && typeof d["processId"] === "string" && isNullableString(d["command"]) && (d["state"] === "running" || d["state"] === "succeeded" || d["state"] === "failed" || d["state"] === "stopped" || d["state"] === "interrupted") && (d["exitCode"] === null || typeof d["exitCode"] === "number" && Number.isInteger(d["exitCode"])) && isNullableString(d["startedAt"]) && isNullableString(d["finishedAt"]);
|
|
51
82
|
default:
|
|
52
83
|
return false;
|
|
53
84
|
}
|
|
54
85
|
}
|
|
55
86
|
export {
|
|
87
|
+
isCollectionDisplay,
|
|
56
88
|
isDiffDisplay,
|
|
57
89
|
isFileDisplay,
|
|
58
90
|
isGenericDisplay,
|
|
91
|
+
isProcessDisplay,
|
|
92
|
+
isRecordDisplay,
|
|
59
93
|
isSearchDisplay,
|
|
60
94
|
isShellDisplay,
|
|
95
|
+
isStatusDisplay,
|
|
96
|
+
isTextDisplay,
|
|
61
97
|
isValidDisplayData
|
|
62
98
|
};
|
|
@@ -185,6 +185,53 @@ class ToolPresentation {
|
|
|
185
185
|
...resultPresentation ? { result: resultPresentation } : {}
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
|
+
async resolveResultDisplay(input) {
|
|
189
|
+
if (input.toolName.startsWith(MCP_TOOL_PREFIX)) {
|
|
190
|
+
return void 0;
|
|
191
|
+
}
|
|
192
|
+
const policy = this.getLocalTool(input.toolName)?.presentation?.result;
|
|
193
|
+
if (policy === void 0 || policy.type === "none" || policy.type === "content") {
|
|
194
|
+
return void 0;
|
|
195
|
+
}
|
|
196
|
+
if (policy.type === "passthrough") {
|
|
197
|
+
return this.extractDisplayData(input.result);
|
|
198
|
+
}
|
|
199
|
+
let context;
|
|
200
|
+
try {
|
|
201
|
+
context = this.buildToolExecutionContext(input);
|
|
202
|
+
} catch (error) {
|
|
203
|
+
this.logger.debug(
|
|
204
|
+
`Tool result display context generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
205
|
+
);
|
|
206
|
+
return void 0;
|
|
207
|
+
}
|
|
208
|
+
try {
|
|
209
|
+
const display = await Promise.resolve(
|
|
210
|
+
policy.resolve(input.result, input.args, context)
|
|
211
|
+
);
|
|
212
|
+
if (display === null) {
|
|
213
|
+
return void 0;
|
|
214
|
+
}
|
|
215
|
+
if (!(0, import_display_types.isValidDisplayData)(display)) {
|
|
216
|
+
this.logger.debug(
|
|
217
|
+
`Tool result display resolver returned invalid display data for '${input.toolName}'`
|
|
218
|
+
);
|
|
219
|
+
return void 0;
|
|
220
|
+
}
|
|
221
|
+
return display;
|
|
222
|
+
} catch (error) {
|
|
223
|
+
this.logger.debug(
|
|
224
|
+
`Tool result display resolution failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
225
|
+
);
|
|
226
|
+
return void 0;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
getResultPolicyType(toolName) {
|
|
230
|
+
if (toolName.startsWith(MCP_TOOL_PREFIX)) {
|
|
231
|
+
return void 0;
|
|
232
|
+
}
|
|
233
|
+
return this.getLocalTool(toolName)?.presentation?.result?.type;
|
|
234
|
+
}
|
|
188
235
|
extractDisplayData(result) {
|
|
189
236
|
if (result === null || typeof result !== "object" || !("_display" in result)) {
|
|
190
237
|
return void 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Logger } from '../../logger/v2/types.js';
|
|
2
2
|
import type { AgentRunContext } from '../../runtime/run-context.js';
|
|
3
|
-
import type { Tool, ToolExecutionContext, ToolPresentationSnapshotV1 } from '../types.js';
|
|
3
|
+
import type { Tool, ToolExecutionContext, ToolPresentationResultType, ToolPresentationSnapshotV1 } from '../types.js';
|
|
4
4
|
import { type ToolDisplayData } from '../display-types.js';
|
|
5
5
|
type BuildToolExecutionContext = (options: {
|
|
6
6
|
sessionId?: string | undefined;
|
|
@@ -37,6 +37,15 @@ export declare class ToolPresentation {
|
|
|
37
37
|
sessionId?: string | undefined;
|
|
38
38
|
runContext?: AgentRunContext | undefined;
|
|
39
39
|
}): Promise<ToolPresentationSnapshotV1>;
|
|
40
|
+
resolveResultDisplay(input: {
|
|
41
|
+
toolName: string;
|
|
42
|
+
result: unknown;
|
|
43
|
+
args: Record<string, unknown>;
|
|
44
|
+
toolCallId: string;
|
|
45
|
+
sessionId?: string | undefined;
|
|
46
|
+
runContext?: AgentRunContext | undefined;
|
|
47
|
+
}): Promise<ToolDisplayData | undefined>;
|
|
48
|
+
getResultPolicyType(toolName: string): ToolPresentationResultType | undefined;
|
|
40
49
|
private extractDisplayData;
|
|
41
50
|
preview(input: {
|
|
42
51
|
toolName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-presentation.d.ts","sourceRoot":"","sources":["../../../src/tools/presentation/tool-presentation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"tool-presentation.d.ts","sourceRoot":"","sources":["../../../src/tools/presentation/tool-presentation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAC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AAE,MAAM,GAAG,SAAS,CAAC;QAC/B,UAAU,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;KAC5C,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAgCxC,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,WAAW;CAQtB"}
|
|
@@ -163,6 +163,53 @@ class ToolPresentation {
|
|
|
163
163
|
...resultPresentation ? { result: resultPresentation } : {}
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
+
async resolveResultDisplay(input) {
|
|
167
|
+
if (input.toolName.startsWith(MCP_TOOL_PREFIX)) {
|
|
168
|
+
return void 0;
|
|
169
|
+
}
|
|
170
|
+
const policy = this.getLocalTool(input.toolName)?.presentation?.result;
|
|
171
|
+
if (policy === void 0 || policy.type === "none" || policy.type === "content") {
|
|
172
|
+
return void 0;
|
|
173
|
+
}
|
|
174
|
+
if (policy.type === "passthrough") {
|
|
175
|
+
return this.extractDisplayData(input.result);
|
|
176
|
+
}
|
|
177
|
+
let context;
|
|
178
|
+
try {
|
|
179
|
+
context = this.buildToolExecutionContext(input);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
this.logger.debug(
|
|
182
|
+
`Tool result display context generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
183
|
+
);
|
|
184
|
+
return void 0;
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const display = await Promise.resolve(
|
|
188
|
+
policy.resolve(input.result, input.args, context)
|
|
189
|
+
);
|
|
190
|
+
if (display === null) {
|
|
191
|
+
return void 0;
|
|
192
|
+
}
|
|
193
|
+
if (!isValidDisplayData(display)) {
|
|
194
|
+
this.logger.debug(
|
|
195
|
+
`Tool result display resolver returned invalid display data for '${input.toolName}'`
|
|
196
|
+
);
|
|
197
|
+
return void 0;
|
|
198
|
+
}
|
|
199
|
+
return display;
|
|
200
|
+
} catch (error) {
|
|
201
|
+
this.logger.debug(
|
|
202
|
+
`Tool result display resolution failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
203
|
+
);
|
|
204
|
+
return void 0;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
getResultPolicyType(toolName) {
|
|
208
|
+
if (toolName.startsWith(MCP_TOOL_PREFIX)) {
|
|
209
|
+
return void 0;
|
|
210
|
+
}
|
|
211
|
+
return this.getLocalTool(toolName)?.presentation?.result?.type;
|
|
212
|
+
}
|
|
166
213
|
extractDisplayData(result) {
|
|
167
214
|
if (result === null || typeof result !== "object" || !("_display" in result)) {
|
|
168
215
|
return void 0;
|
|
@@ -41,9 +41,9 @@ export declare const ToolPresentationSnapshotV1Schema: z.ZodObject<{
|
|
|
41
41
|
display: z.ZodString;
|
|
42
42
|
kind: z.ZodOptional<z.ZodEnum<{
|
|
43
43
|
path: "path";
|
|
44
|
+
text: "text";
|
|
44
45
|
command: "command";
|
|
45
46
|
url: "url";
|
|
46
|
-
text: "text";
|
|
47
47
|
json: "json";
|
|
48
48
|
}>>;
|
|
49
49
|
sensitive: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -57,9 +57,9 @@ export declare const ToolPresentationSnapshotV1Schema: z.ZodObject<{
|
|
|
57
57
|
display: z.ZodString;
|
|
58
58
|
kind: z.ZodOptional<z.ZodEnum<{
|
|
59
59
|
path: "path";
|
|
60
|
+
text: "text";
|
|
60
61
|
command: "command";
|
|
61
62
|
url: "url";
|
|
62
|
-
text: "text";
|
|
63
63
|
json: "json";
|
|
64
64
|
}>>;
|
|
65
65
|
sensitive: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ToolPresentationSnapshotV1 } from './types.js';
|
|
2
2
|
export type { ToolDisplayData } from './display-types.js';
|
|
3
3
|
export { isValidDisplayData } from './display-types.js';
|
|
4
|
+
export type { ToolPresentationResultPolicy, ToolPresentationResultResolver, ToolPresentationResultType, } from './types.js';
|
|
4
5
|
export type { ToolPresentationSnapshotV1 } from './presentation-schema.js';
|
|
5
6
|
export { isToolPresentationSnapshotV1, ToolPresentationSnapshotV1Schema, } from './presentation-schema.js';
|
|
6
7
|
export declare function createLocalToolCallHeader(options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../src/tools/presentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAE7D,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EACH,4BAA4B,EAC5B,gCAAgC,GACnC,MAAM,0BAA0B,CAAC;AAElC,wBAAgB,yBAAyB,CAAC,OAAO,EAAE;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,WAAW,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAKpD;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,0BAA0B,CAM7B;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIvE"}
|
|
1
|
+
{"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../src/tools/presentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAE7D,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EACR,4BAA4B,EAC5B,8BAA8B,EAC9B,0BAA0B,GAC7B,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EACH,4BAA4B,EAC5B,gCAAgC,GACnC,MAAM,0BAA0B,CAAC;AAElC,wBAAgB,yBAAyB,CAAC,OAAO,EAAE;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,WAAW,CAAC,0BAA0B,CAAC,QAAQ,CAAC,CAAC,CAKpD;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,0BAA0B,CAM7B;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIvE"}
|
|
@@ -37,9 +37,23 @@ const META_SCHEMA = {
|
|
|
37
37
|
type: "boolean",
|
|
38
38
|
description: "Notify when the background task completes."
|
|
39
39
|
},
|
|
40
|
-
|
|
41
|
-
type: "
|
|
42
|
-
description: "
|
|
40
|
+
callActivity: {
|
|
41
|
+
type: "object",
|
|
42
|
+
description: "Concise action-only descriptions for the tool call. Use present-progressive tense while running and past tense when complete. Write in sentence case without terminal punctuation; do not speculate about the outcome.",
|
|
43
|
+
properties: {
|
|
44
|
+
running: {
|
|
45
|
+
type: "string",
|
|
46
|
+
maxLength: 120,
|
|
47
|
+
description: "Present-progressive description of the action currently being performed, in concise sentence case without terminal punctuation."
|
|
48
|
+
},
|
|
49
|
+
completed: {
|
|
50
|
+
type: "string",
|
|
51
|
+
maxLength: 120,
|
|
52
|
+
description: "Past-tense description of the action that was performed, in concise sentence case without terminal punctuation."
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
required: ["running", "completed"],
|
|
56
|
+
additionalProperties: false
|
|
43
57
|
}
|
|
44
58
|
},
|
|
45
59
|
additionalProperties: true
|
|
@@ -3,7 +3,10 @@ export type ToolCallMetadata = Record<string, unknown> & {
|
|
|
3
3
|
runInBackground?: boolean;
|
|
4
4
|
timeoutMs?: number;
|
|
5
5
|
notifyOnComplete?: boolean;
|
|
6
|
-
|
|
6
|
+
callActivity?: {
|
|
7
|
+
running: string;
|
|
8
|
+
completed: string;
|
|
9
|
+
};
|
|
7
10
|
};
|
|
8
11
|
export type ToolCallMetaWrapper = {
|
|
9
12
|
__meta: ToolCallMetadata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-call-metadata.d.ts","sourceRoot":"","sources":["../../src/tools/tool-call-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACrD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,
|
|
1
|
+
{"version":3,"file":"tool-call-metadata.d.ts","sourceRoot":"","sources":["../../src/tools/tool-call-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACrD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;KACrB,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAC9B,MAAM,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AA+LF,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,WAAW,GAAG,WAAW,CAkB7E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAChE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,IAAI,EAAE,gBAAgB,CAAC;CAC1B,CAQA"}
|
|
@@ -14,9 +14,23 @@ const META_SCHEMA = {
|
|
|
14
14
|
type: "boolean",
|
|
15
15
|
description: "Notify when the background task completes."
|
|
16
16
|
},
|
|
17
|
-
|
|
18
|
-
type: "
|
|
19
|
-
description: "
|
|
17
|
+
callActivity: {
|
|
18
|
+
type: "object",
|
|
19
|
+
description: "Concise action-only descriptions for the tool call. Use present-progressive tense while running and past tense when complete. Write in sentence case without terminal punctuation; do not speculate about the outcome.",
|
|
20
|
+
properties: {
|
|
21
|
+
running: {
|
|
22
|
+
type: "string",
|
|
23
|
+
maxLength: 120,
|
|
24
|
+
description: "Present-progressive description of the action currently being performed, in concise sentence case without terminal punctuation."
|
|
25
|
+
},
|
|
26
|
+
completed: {
|
|
27
|
+
type: "string",
|
|
28
|
+
maxLength: 120,
|
|
29
|
+
description: "Past-tense description of the action that was performed, in concise sentence case without terminal punctuation."
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
required: ["running", "completed"],
|
|
33
|
+
additionalProperties: false
|
|
20
34
|
}
|
|
21
35
|
},
|
|
22
36
|
additionalProperties: true
|
|
@@ -803,7 +803,7 @@ let _ToolManager = class _ToolManager {
|
|
|
803
803
|
}
|
|
804
804
|
const { toolArgs: rawToolArgs, meta } = (0, import_tool_call_metadata.extractToolCallMeta)(input.input);
|
|
805
805
|
const eventMeta = Object.keys(meta).length > 0 ? meta : void 0;
|
|
806
|
-
const
|
|
806
|
+
const approvalDescription = typeof meta.callActivity?.running === "string" ? meta.callActivity.running : typeof rawToolArgs.description === "string" ? rawToolArgs.description : void 0;
|
|
807
807
|
let validatedArgs;
|
|
808
808
|
try {
|
|
809
809
|
validatedArgs = this.validateLocalToolArgs(input.toolName, rawToolArgs);
|
|
@@ -827,7 +827,6 @@ let _ToolManager = class _ToolManager {
|
|
|
827
827
|
source,
|
|
828
828
|
toolCallId: input.toolCallId,
|
|
829
829
|
toolName: input.toolName,
|
|
830
|
-
...callDescription !== void 0 ? { callDescription } : {},
|
|
831
830
|
...eventMeta !== void 0 ? { meta: eventMeta } : {}
|
|
832
831
|
};
|
|
833
832
|
const approvalGate = await this.toolApprovalPolicy.resolve({
|
|
@@ -848,7 +847,7 @@ let _ToolManager = class _ToolManager {
|
|
|
848
847
|
approvalGate,
|
|
849
848
|
args: validatedArgs,
|
|
850
849
|
call,
|
|
851
|
-
...
|
|
850
|
+
...approvalDescription !== void 0 ? { approvalDescription } : {},
|
|
852
851
|
...input.runContext !== void 0 ? { runContext: input.runContext } : {},
|
|
853
852
|
...sessionId !== void 0 ? { sessionId } : {},
|
|
854
853
|
toolCallId: input.toolCallId,
|
|
@@ -874,7 +873,7 @@ let _ToolManager = class _ToolManager {
|
|
|
874
873
|
presentationSnapshot: input.call.presentationSnapshot,
|
|
875
874
|
toolCallId: input.toolCallId,
|
|
876
875
|
args: input.args,
|
|
877
|
-
...input.
|
|
876
|
+
...input.approvalDescription !== void 0 ? { description: input.approvalDescription } : {},
|
|
878
877
|
...displayPreview !== void 0 ? { displayPreview } : {}
|
|
879
878
|
}
|
|
880
879
|
};
|
|
@@ -1111,7 +1110,6 @@ let _ToolManager = class _ToolManager {
|
|
|
1111
1110
|
}),
|
|
1112
1111
|
args: call.input,
|
|
1113
1112
|
...call.meta !== void 0 ? { meta: call.meta } : {},
|
|
1114
|
-
...call.callDescription !== void 0 ? { callDescription: call.callDescription } : {},
|
|
1115
1113
|
callId: call.toolCallId,
|
|
1116
1114
|
sessionId,
|
|
1117
1115
|
...hostRuntime !== void 0 && { hostRuntime }
|
|
@@ -1468,8 +1466,19 @@ let _ToolManager = class _ToolManager {
|
|
|
1468
1466
|
...sessionId !== void 0 ? { sessionId } : {},
|
|
1469
1467
|
...runContext !== void 0 ? { runContext } : {}
|
|
1470
1468
|
});
|
|
1469
|
+
const display = await this.toolPresentation.resolveResultDisplay({
|
|
1470
|
+
toolName: call.toolName,
|
|
1471
|
+
result,
|
|
1472
|
+
args: toolArgs,
|
|
1473
|
+
toolCallId: call.toolCallId,
|
|
1474
|
+
...sessionId !== void 0 ? { sessionId } : {},
|
|
1475
|
+
...runContext !== void 0 ? { runContext } : {}
|
|
1476
|
+
});
|
|
1477
|
+
const resultPresentation = this.toolPresentation.getResultPolicyType(call.toolName);
|
|
1471
1478
|
const executionResult = {
|
|
1472
1479
|
result,
|
|
1480
|
+
...display !== void 0 ? { display } : {},
|
|
1481
|
+
...resultPresentation !== void 0 ? { resultPresentation } : {},
|
|
1473
1482
|
...presentationSnapshot !== void 0 && { presentationSnapshot },
|
|
1474
1483
|
...call.meta !== void 0 ? { meta: call.meta } : {},
|
|
1475
1484
|
...call.approval !== void 0 ? call.approval : {}
|