@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
|
@@ -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,EAAE,IAAI,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAC1F,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;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,KAAK,EAAE,IAAI,EAAE,oBAAoB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAI/E,KAAK,yBAAyB,GAAG,CAAC,OAAO,EAAE;IACvC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;CAC5C,KAAK,oBAAoB,CAAC;AAE3B,qBAAa,gBAAgB;IAErB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IAItC,OAAO,CAAC,QAAQ,CAAC,yBAAyB;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM;gBANN,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,SAAS,EACpD,qBAAqB,EAAE,CACpC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACX,yBAAyB,EAAE,yBAAyB,EACpD,MAAM,EAAE,MAAM;IAGnC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,0BAA0B;IA2BlE,wBAAwB,CAAC,KAAK,EAAE;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,UAAU,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;KAC5C,GAAG,0BAA0B;IAmDxB,eAAe,CAAC,KAAK,EAAE;QACzB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,UAAU,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;KAC5C,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAoEjC,iBAAiB,CAAC,KAAK,EAAE;QAC3B,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,0BAA0B,CAAC;QACrC,MAAM,EAAE,OAAO,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAC/B,UAAU,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;KAC5C,GAAG,OAAO,CAAC,0BAA0B,CAAC;IA+DvC,OAAO,CAAC,kBAAkB;IAQpB,OAAO,CAAC,KAAK,EAAE;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC9B,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,CAAC,EAAE,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"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../../chunk-C6A6W6XS.js";
|
|
2
2
|
import { DextoRuntimeError } from "../../errors/index.js";
|
|
3
3
|
import { ToolErrorCode } from "../error-codes.js";
|
|
4
|
+
import { isValidDisplayData } from "../display-types.js";
|
|
4
5
|
const MCP_TOOL_PREFIX = "mcp--";
|
|
5
6
|
class ToolPresentation {
|
|
6
7
|
constructor(getLocalTool, validateLocalToolArgs, buildToolExecutionContext, logger) {
|
|
@@ -36,13 +37,16 @@ class ToolPresentation {
|
|
|
36
37
|
return fallback;
|
|
37
38
|
}
|
|
38
39
|
const presentation = this.getLocalTool(input.toolName)?.presentation;
|
|
39
|
-
if (!presentation?.describeHeader && !presentation?.describeArgs) {
|
|
40
|
+
if (!presentation?.activity && !presentation?.describeHeader && !presentation?.describeArgs) {
|
|
40
41
|
return fallback;
|
|
41
42
|
}
|
|
43
|
+
let nextSnapshot = {
|
|
44
|
+
...fallback,
|
|
45
|
+
...presentation.activity ? { activity: presentation.activity } : {}
|
|
46
|
+
};
|
|
42
47
|
try {
|
|
43
48
|
const validatedArgs = this.validateLocalToolArgs(input.toolName, input.args);
|
|
44
49
|
const context = this.buildToolExecutionContext(input);
|
|
45
|
-
let nextSnapshot = fallback;
|
|
46
50
|
const header = presentation.describeHeader?.(validatedArgs, context);
|
|
47
51
|
if (!isPromiseLike(header) && header) {
|
|
48
52
|
nextSnapshot = {
|
|
@@ -62,7 +66,7 @@ class ToolPresentation {
|
|
|
62
66
|
this.logger.debug(
|
|
63
67
|
`Tool presentation snapshot generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
64
68
|
);
|
|
65
|
-
return
|
|
69
|
+
return nextSnapshot;
|
|
66
70
|
}
|
|
67
71
|
}
|
|
68
72
|
async snapshotForCall(input) {
|
|
@@ -71,51 +75,100 @@ class ToolPresentation {
|
|
|
71
75
|
return fallback;
|
|
72
76
|
}
|
|
73
77
|
const presentation = this.getLocalTool(input.toolName)?.presentation;
|
|
74
|
-
if (!presentation?.describeHeader && !presentation?.describeArgs) {
|
|
78
|
+
if (!presentation?.activity && !presentation?.describeHeader && !presentation?.describeArgs) {
|
|
75
79
|
return fallback;
|
|
76
80
|
}
|
|
81
|
+
let nextSnapshot = {
|
|
82
|
+
...fallback,
|
|
83
|
+
...presentation.activity ? { activity: presentation.activity } : {}
|
|
84
|
+
};
|
|
85
|
+
let context;
|
|
86
|
+
try {
|
|
87
|
+
context = this.buildToolExecutionContext(input);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
this.logger.debug(
|
|
90
|
+
`Tool presentation snapshot generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
91
|
+
);
|
|
92
|
+
return nextSnapshot;
|
|
93
|
+
}
|
|
77
94
|
try {
|
|
78
|
-
const context = this.buildToolExecutionContext(input);
|
|
79
95
|
const describedHeader = presentation.describeHeader ? await Promise.resolve(presentation.describeHeader(input.args, context)) : null;
|
|
96
|
+
if (describedHeader) {
|
|
97
|
+
nextSnapshot = {
|
|
98
|
+
...nextSnapshot,
|
|
99
|
+
header: { ...nextSnapshot.header, ...describedHeader }
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
} catch (error) {
|
|
103
|
+
this.logger.debug(
|
|
104
|
+
`Tool header presentation generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
80
108
|
const describedArgs = presentation.describeArgs ? await Promise.resolve(presentation.describeArgs(input.args, context)) : null;
|
|
81
|
-
|
|
82
|
-
...
|
|
83
|
-
|
|
84
|
-
...describedArgs ? { args: describedArgs } : {}
|
|
85
|
-
};
|
|
109
|
+
if (describedArgs) {
|
|
110
|
+
nextSnapshot = { ...nextSnapshot, args: describedArgs };
|
|
111
|
+
}
|
|
86
112
|
} catch (error) {
|
|
87
113
|
this.logger.debug(
|
|
88
|
-
`Tool presentation
|
|
114
|
+
`Tool argument presentation generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
89
115
|
);
|
|
90
|
-
return fallback;
|
|
91
116
|
}
|
|
117
|
+
return nextSnapshot;
|
|
92
118
|
}
|
|
93
119
|
async augmentWithResult(input) {
|
|
94
120
|
if (input.toolName.startsWith(MCP_TOOL_PREFIX)) {
|
|
95
121
|
return input.snapshot;
|
|
96
122
|
}
|
|
97
|
-
const
|
|
98
|
-
if (!describeResult) {
|
|
123
|
+
const presentation = this.getLocalTool(input.toolName)?.presentation;
|
|
124
|
+
if (!presentation?.describeResult && !presentation?.describeResultActivity) {
|
|
99
125
|
return input.snapshot;
|
|
100
126
|
}
|
|
127
|
+
let context;
|
|
101
128
|
try {
|
|
102
|
-
|
|
103
|
-
const resultPresentation = await Promise.resolve(
|
|
104
|
-
describeResult(input.result, input.args, context)
|
|
105
|
-
);
|
|
106
|
-
if (!resultPresentation) {
|
|
107
|
-
return input.snapshot;
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
...input.snapshot,
|
|
111
|
-
result: resultPresentation
|
|
112
|
-
};
|
|
129
|
+
context = this.buildToolExecutionContext(input);
|
|
113
130
|
} catch (error) {
|
|
114
131
|
this.logger.debug(
|
|
115
132
|
`Tool result presentation snapshot generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
116
133
|
);
|
|
117
134
|
return input.snapshot;
|
|
118
135
|
}
|
|
136
|
+
let resultPresentation;
|
|
137
|
+
try {
|
|
138
|
+
resultPresentation = presentation.describeResult ? await Promise.resolve(
|
|
139
|
+
presentation.describeResult(input.result, input.args, context)
|
|
140
|
+
) ?? void 0 : void 0;
|
|
141
|
+
} catch (error) {
|
|
142
|
+
this.logger.debug(
|
|
143
|
+
`Tool result presentation generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
let resultActivity;
|
|
147
|
+
try {
|
|
148
|
+
resultActivity = presentation.describeResultActivity ? await Promise.resolve(
|
|
149
|
+
presentation.describeResultActivity(
|
|
150
|
+
this.extractDisplayData(input.result),
|
|
151
|
+
input.args,
|
|
152
|
+
context
|
|
153
|
+
)
|
|
154
|
+
) ?? void 0 : void 0;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
this.logger.debug(
|
|
157
|
+
`Tool result activity generation failed for '${input.toolName}': ${error instanceof Error ? error.message : String(error)}`
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
...input.snapshot,
|
|
162
|
+
...resultActivity ? { activity: resultActivity } : {},
|
|
163
|
+
...resultPresentation ? { result: resultPresentation } : {}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
extractDisplayData(result) {
|
|
167
|
+
if (result === null || typeof result !== "object" || !("_display" in result)) {
|
|
168
|
+
return void 0;
|
|
169
|
+
}
|
|
170
|
+
const display = result._display;
|
|
171
|
+
return isValidDisplayData(display) ? display : void 0;
|
|
119
172
|
}
|
|
120
173
|
async preview(input) {
|
|
121
174
|
if (input.toolName.startsWith(MCP_TOOL_PREFIX)) {
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var presentation_schema_exports = {};
|
|
20
|
+
__export(presentation_schema_exports, {
|
|
21
|
+
ToolPresentationSnapshotV1Schema: () => ToolPresentationSnapshotV1Schema,
|
|
22
|
+
isToolPresentationSnapshotV1: () => isToolPresentationSnapshotV1
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(presentation_schema_exports);
|
|
25
|
+
var import_zod = require("zod");
|
|
26
|
+
const ToolActivityPresentationSchema = import_zod.z.object({
|
|
27
|
+
category: import_zod.z.string().min(1),
|
|
28
|
+
label: import_zod.z.object({
|
|
29
|
+
running: import_zod.z.string().min(1),
|
|
30
|
+
completed: import_zod.z.string().min(1)
|
|
31
|
+
}).strict(),
|
|
32
|
+
summary: import_zod.z.object({
|
|
33
|
+
verb: import_zod.z.string().min(1),
|
|
34
|
+
singular: import_zod.z.string().min(1),
|
|
35
|
+
plural: import_zod.z.string().min(1)
|
|
36
|
+
}).strict()
|
|
37
|
+
}).strict();
|
|
38
|
+
const PresentationValueSchema = import_zod.z.object({
|
|
39
|
+
label: import_zod.z.string(),
|
|
40
|
+
display: import_zod.z.string(),
|
|
41
|
+
kind: import_zod.z.enum(["path", "command", "url", "text", "json"]).optional(),
|
|
42
|
+
sensitive: import_zod.z.boolean().optional()
|
|
43
|
+
}).strict();
|
|
44
|
+
const UiEffectSchema = import_zod.z.discriminatedUnion("type", [
|
|
45
|
+
import_zod.z.object({
|
|
46
|
+
type: import_zod.z.literal("setFlag"),
|
|
47
|
+
flag: import_zod.z.enum(["autoApproveEdits", "planModeActive", "planModeInitialized"]),
|
|
48
|
+
value: import_zod.z.boolean()
|
|
49
|
+
}).strict(),
|
|
50
|
+
import_zod.z.object({
|
|
51
|
+
type: import_zod.z.literal("toast"),
|
|
52
|
+
kind: import_zod.z.enum(["info", "warning", "success", "error"]),
|
|
53
|
+
message: import_zod.z.string()
|
|
54
|
+
}).strict()
|
|
55
|
+
]);
|
|
56
|
+
const ApprovalActionSchema = import_zod.z.union([
|
|
57
|
+
import_zod.z.object({
|
|
58
|
+
id: import_zod.z.string(),
|
|
59
|
+
label: import_zod.z.string(),
|
|
60
|
+
kind: import_zod.z.enum(["primary", "secondary", "danger"]).optional(),
|
|
61
|
+
responseData: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()).optional(),
|
|
62
|
+
uiEffects: import_zod.z.array(UiEffectSchema).optional()
|
|
63
|
+
}).strict(),
|
|
64
|
+
import_zod.z.object({
|
|
65
|
+
id: import_zod.z.string(),
|
|
66
|
+
label: import_zod.z.string(),
|
|
67
|
+
kind: import_zod.z.literal("danger").optional(),
|
|
68
|
+
denyWithFeedback: import_zod.z.object({
|
|
69
|
+
placeholder: import_zod.z.string().optional(),
|
|
70
|
+
messageTemplate: import_zod.z.string().optional()
|
|
71
|
+
}).strict()
|
|
72
|
+
}).strict()
|
|
73
|
+
]);
|
|
74
|
+
const ToolPresentationSnapshotV1Schema = import_zod.z.object({
|
|
75
|
+
version: import_zod.z.literal(1),
|
|
76
|
+
activity: ToolActivityPresentationSchema.optional(),
|
|
77
|
+
source: import_zod.z.object({
|
|
78
|
+
type: import_zod.z.enum(["local", "mcp"]),
|
|
79
|
+
mcpServerName: import_zod.z.string().optional()
|
|
80
|
+
}).strict().optional(),
|
|
81
|
+
header: import_zod.z.object({
|
|
82
|
+
title: import_zod.z.string().optional(),
|
|
83
|
+
argsText: import_zod.z.string().optional()
|
|
84
|
+
}).strict().optional(),
|
|
85
|
+
chips: import_zod.z.array(
|
|
86
|
+
import_zod.z.object({
|
|
87
|
+
kind: import_zod.z.enum(["neutral", "info", "warning", "danger", "success"]),
|
|
88
|
+
text: import_zod.z.string()
|
|
89
|
+
}).strict()
|
|
90
|
+
).optional(),
|
|
91
|
+
args: import_zod.z.object({
|
|
92
|
+
summary: import_zod.z.array(PresentationValueSchema).optional(),
|
|
93
|
+
groups: import_zod.z.array(
|
|
94
|
+
import_zod.z.object({
|
|
95
|
+
id: import_zod.z.string(),
|
|
96
|
+
label: import_zod.z.string(),
|
|
97
|
+
collapsedByDefault: import_zod.z.boolean().optional(),
|
|
98
|
+
items: import_zod.z.array(PresentationValueSchema)
|
|
99
|
+
}).strict()
|
|
100
|
+
).optional()
|
|
101
|
+
}).strict().optional(),
|
|
102
|
+
capabilities: import_zod.z.array(import_zod.z.string()).optional(),
|
|
103
|
+
approval: import_zod.z.object({
|
|
104
|
+
actions: import_zod.z.array(ApprovalActionSchema).optional()
|
|
105
|
+
}).strict().optional(),
|
|
106
|
+
result: import_zod.z.object({
|
|
107
|
+
summaryText: import_zod.z.string().optional(),
|
|
108
|
+
uiEffects: import_zod.z.array(UiEffectSchema).optional()
|
|
109
|
+
}).strict().optional()
|
|
110
|
+
}).strict();
|
|
111
|
+
function isToolPresentationSnapshotV1(value) {
|
|
112
|
+
return ToolPresentationSnapshotV1Schema.safeParse(value).success;
|
|
113
|
+
}
|
|
114
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
115
|
+
0 && (module.exports = {
|
|
116
|
+
ToolPresentationSnapshotV1Schema,
|
|
117
|
+
isToolPresentationSnapshotV1
|
|
118
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Runtime validator for persisted and transported tool presentation snapshots. */
|
|
3
|
+
export declare const ToolPresentationSnapshotV1Schema: z.ZodObject<{
|
|
4
|
+
version: z.ZodLiteral<1>;
|
|
5
|
+
activity: z.ZodOptional<z.ZodObject<{
|
|
6
|
+
category: z.ZodString;
|
|
7
|
+
label: z.ZodObject<{
|
|
8
|
+
running: z.ZodString;
|
|
9
|
+
completed: z.ZodString;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
summary: z.ZodObject<{
|
|
12
|
+
verb: z.ZodString;
|
|
13
|
+
singular: z.ZodString;
|
|
14
|
+
plural: z.ZodString;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
}, z.core.$strict>>;
|
|
17
|
+
source: z.ZodOptional<z.ZodObject<{
|
|
18
|
+
type: z.ZodEnum<{
|
|
19
|
+
mcp: "mcp";
|
|
20
|
+
local: "local";
|
|
21
|
+
}>;
|
|
22
|
+
mcpServerName: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strict>>;
|
|
24
|
+
header: z.ZodOptional<z.ZodObject<{
|
|
25
|
+
title: z.ZodOptional<z.ZodString>;
|
|
26
|
+
argsText: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strict>>;
|
|
28
|
+
chips: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
29
|
+
kind: z.ZodEnum<{
|
|
30
|
+
info: "info";
|
|
31
|
+
warning: "warning";
|
|
32
|
+
success: "success";
|
|
33
|
+
danger: "danger";
|
|
34
|
+
neutral: "neutral";
|
|
35
|
+
}>;
|
|
36
|
+
text: z.ZodString;
|
|
37
|
+
}, z.core.$strict>>>;
|
|
38
|
+
args: z.ZodOptional<z.ZodObject<{
|
|
39
|
+
summary: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
40
|
+
label: z.ZodString;
|
|
41
|
+
display: z.ZodString;
|
|
42
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
43
|
+
path: "path";
|
|
44
|
+
command: "command";
|
|
45
|
+
url: "url";
|
|
46
|
+
text: "text";
|
|
47
|
+
json: "json";
|
|
48
|
+
}>>;
|
|
49
|
+
sensitive: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
}, z.core.$strict>>>;
|
|
51
|
+
groups: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
52
|
+
id: z.ZodString;
|
|
53
|
+
label: z.ZodString;
|
|
54
|
+
collapsedByDefault: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
items: z.ZodArray<z.ZodObject<{
|
|
56
|
+
label: z.ZodString;
|
|
57
|
+
display: z.ZodString;
|
|
58
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
59
|
+
path: "path";
|
|
60
|
+
command: "command";
|
|
61
|
+
url: "url";
|
|
62
|
+
text: "text";
|
|
63
|
+
json: "json";
|
|
64
|
+
}>>;
|
|
65
|
+
sensitive: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
+
}, z.core.$strict>>;
|
|
67
|
+
}, z.core.$strict>>>;
|
|
68
|
+
}, z.core.$strict>>;
|
|
69
|
+
capabilities: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
70
|
+
approval: z.ZodOptional<z.ZodObject<{
|
|
71
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
72
|
+
id: z.ZodString;
|
|
73
|
+
label: z.ZodString;
|
|
74
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
75
|
+
primary: "primary";
|
|
76
|
+
secondary: "secondary";
|
|
77
|
+
danger: "danger";
|
|
78
|
+
}>>;
|
|
79
|
+
responseData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
80
|
+
uiEffects: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
81
|
+
type: z.ZodLiteral<"setFlag">;
|
|
82
|
+
flag: z.ZodEnum<{
|
|
83
|
+
autoApproveEdits: "autoApproveEdits";
|
|
84
|
+
planModeActive: "planModeActive";
|
|
85
|
+
planModeInitialized: "planModeInitialized";
|
|
86
|
+
}>;
|
|
87
|
+
value: z.ZodBoolean;
|
|
88
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
89
|
+
type: z.ZodLiteral<"toast">;
|
|
90
|
+
kind: z.ZodEnum<{
|
|
91
|
+
info: "info";
|
|
92
|
+
error: "error";
|
|
93
|
+
warning: "warning";
|
|
94
|
+
success: "success";
|
|
95
|
+
}>;
|
|
96
|
+
message: z.ZodString;
|
|
97
|
+
}, z.core.$strict>], "type">>>;
|
|
98
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
99
|
+
id: z.ZodString;
|
|
100
|
+
label: z.ZodString;
|
|
101
|
+
kind: z.ZodOptional<z.ZodLiteral<"danger">>;
|
|
102
|
+
denyWithFeedback: z.ZodObject<{
|
|
103
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
104
|
+
messageTemplate: z.ZodOptional<z.ZodString>;
|
|
105
|
+
}, z.core.$strict>;
|
|
106
|
+
}, z.core.$strict>]>>>;
|
|
107
|
+
}, z.core.$strict>>;
|
|
108
|
+
result: z.ZodOptional<z.ZodObject<{
|
|
109
|
+
summaryText: z.ZodOptional<z.ZodString>;
|
|
110
|
+
uiEffects: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
111
|
+
type: z.ZodLiteral<"setFlag">;
|
|
112
|
+
flag: z.ZodEnum<{
|
|
113
|
+
autoApproveEdits: "autoApproveEdits";
|
|
114
|
+
planModeActive: "planModeActive";
|
|
115
|
+
planModeInitialized: "planModeInitialized";
|
|
116
|
+
}>;
|
|
117
|
+
value: z.ZodBoolean;
|
|
118
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
119
|
+
type: z.ZodLiteral<"toast">;
|
|
120
|
+
kind: z.ZodEnum<{
|
|
121
|
+
info: "info";
|
|
122
|
+
error: "error";
|
|
123
|
+
warning: "warning";
|
|
124
|
+
success: "success";
|
|
125
|
+
}>;
|
|
126
|
+
message: z.ZodString;
|
|
127
|
+
}, z.core.$strict>], "type">>>;
|
|
128
|
+
}, z.core.$strict>>;
|
|
129
|
+
}, z.core.$strict>;
|
|
130
|
+
export type ToolPresentationSnapshotV1 = z.output<typeof ToolPresentationSnapshotV1Schema>;
|
|
131
|
+
export declare function isToolPresentationSnapshotV1(value: unknown): value is ToolPresentationSnapshotV1;
|
|
132
|
+
//# sourceMappingURL=presentation-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-schema.d.ts","sourceRoot":"","sources":["../../src/tools/presentation-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwExB,mFAAmF;AACnF,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA6DhC,CAAC;AAEd,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gCAAgC,CAAC,CAAC;AAE3F,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,0BAA0B,CAEhG"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import "../chunk-C6A6W6XS.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const ToolActivityPresentationSchema = z.object({
|
|
4
|
+
category: z.string().min(1),
|
|
5
|
+
label: z.object({
|
|
6
|
+
running: z.string().min(1),
|
|
7
|
+
completed: z.string().min(1)
|
|
8
|
+
}).strict(),
|
|
9
|
+
summary: z.object({
|
|
10
|
+
verb: z.string().min(1),
|
|
11
|
+
singular: z.string().min(1),
|
|
12
|
+
plural: z.string().min(1)
|
|
13
|
+
}).strict()
|
|
14
|
+
}).strict();
|
|
15
|
+
const PresentationValueSchema = z.object({
|
|
16
|
+
label: z.string(),
|
|
17
|
+
display: z.string(),
|
|
18
|
+
kind: z.enum(["path", "command", "url", "text", "json"]).optional(),
|
|
19
|
+
sensitive: z.boolean().optional()
|
|
20
|
+
}).strict();
|
|
21
|
+
const UiEffectSchema = z.discriminatedUnion("type", [
|
|
22
|
+
z.object({
|
|
23
|
+
type: z.literal("setFlag"),
|
|
24
|
+
flag: z.enum(["autoApproveEdits", "planModeActive", "planModeInitialized"]),
|
|
25
|
+
value: z.boolean()
|
|
26
|
+
}).strict(),
|
|
27
|
+
z.object({
|
|
28
|
+
type: z.literal("toast"),
|
|
29
|
+
kind: z.enum(["info", "warning", "success", "error"]),
|
|
30
|
+
message: z.string()
|
|
31
|
+
}).strict()
|
|
32
|
+
]);
|
|
33
|
+
const ApprovalActionSchema = z.union([
|
|
34
|
+
z.object({
|
|
35
|
+
id: z.string(),
|
|
36
|
+
label: z.string(),
|
|
37
|
+
kind: z.enum(["primary", "secondary", "danger"]).optional(),
|
|
38
|
+
responseData: z.record(z.string(), z.unknown()).optional(),
|
|
39
|
+
uiEffects: z.array(UiEffectSchema).optional()
|
|
40
|
+
}).strict(),
|
|
41
|
+
z.object({
|
|
42
|
+
id: z.string(),
|
|
43
|
+
label: z.string(),
|
|
44
|
+
kind: z.literal("danger").optional(),
|
|
45
|
+
denyWithFeedback: z.object({
|
|
46
|
+
placeholder: z.string().optional(),
|
|
47
|
+
messageTemplate: z.string().optional()
|
|
48
|
+
}).strict()
|
|
49
|
+
}).strict()
|
|
50
|
+
]);
|
|
51
|
+
const ToolPresentationSnapshotV1Schema = z.object({
|
|
52
|
+
version: z.literal(1),
|
|
53
|
+
activity: ToolActivityPresentationSchema.optional(),
|
|
54
|
+
source: z.object({
|
|
55
|
+
type: z.enum(["local", "mcp"]),
|
|
56
|
+
mcpServerName: z.string().optional()
|
|
57
|
+
}).strict().optional(),
|
|
58
|
+
header: z.object({
|
|
59
|
+
title: z.string().optional(),
|
|
60
|
+
argsText: z.string().optional()
|
|
61
|
+
}).strict().optional(),
|
|
62
|
+
chips: z.array(
|
|
63
|
+
z.object({
|
|
64
|
+
kind: z.enum(["neutral", "info", "warning", "danger", "success"]),
|
|
65
|
+
text: z.string()
|
|
66
|
+
}).strict()
|
|
67
|
+
).optional(),
|
|
68
|
+
args: z.object({
|
|
69
|
+
summary: z.array(PresentationValueSchema).optional(),
|
|
70
|
+
groups: z.array(
|
|
71
|
+
z.object({
|
|
72
|
+
id: z.string(),
|
|
73
|
+
label: z.string(),
|
|
74
|
+
collapsedByDefault: z.boolean().optional(),
|
|
75
|
+
items: z.array(PresentationValueSchema)
|
|
76
|
+
}).strict()
|
|
77
|
+
).optional()
|
|
78
|
+
}).strict().optional(),
|
|
79
|
+
capabilities: z.array(z.string()).optional(),
|
|
80
|
+
approval: z.object({
|
|
81
|
+
actions: z.array(ApprovalActionSchema).optional()
|
|
82
|
+
}).strict().optional(),
|
|
83
|
+
result: z.object({
|
|
84
|
+
summaryText: z.string().optional(),
|
|
85
|
+
uiEffects: z.array(UiEffectSchema).optional()
|
|
86
|
+
}).strict().optional()
|
|
87
|
+
}).strict();
|
|
88
|
+
function isToolPresentationSnapshotV1(value) {
|
|
89
|
+
return ToolPresentationSnapshotV1Schema.safeParse(value).success;
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
ToolPresentationSnapshotV1Schema,
|
|
93
|
+
isToolPresentationSnapshotV1
|
|
94
|
+
};
|
|
@@ -18,11 +18,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var presentation_exports = {};
|
|
20
20
|
__export(presentation_exports, {
|
|
21
|
+
ToolPresentationSnapshotV1Schema: () => import_presentation_schema.ToolPresentationSnapshotV1Schema,
|
|
21
22
|
createLocalToolCallHeader: () => createLocalToolCallHeader,
|
|
22
23
|
createLocalToolCallSnapshot: () => createLocalToolCallSnapshot,
|
|
24
|
+
isToolPresentationSnapshotV1: () => import_presentation_schema.isToolPresentationSnapshotV1,
|
|
25
|
+
isValidDisplayData: () => import_display_types.isValidDisplayData,
|
|
23
26
|
truncateForHeader: () => truncateForHeader
|
|
24
27
|
});
|
|
25
28
|
module.exports = __toCommonJS(presentation_exports);
|
|
29
|
+
var import_display_types = require("./display-types.js");
|
|
30
|
+
var import_presentation_schema = require("./presentation-schema.js");
|
|
26
31
|
function createLocalToolCallHeader(options) {
|
|
27
32
|
return {
|
|
28
33
|
title: options.title,
|
|
@@ -43,7 +48,10 @@ function truncateForHeader(value, maxLen) {
|
|
|
43
48
|
}
|
|
44
49
|
// Annotate the CommonJS export names for ESM import in node:
|
|
45
50
|
0 && (module.exports = {
|
|
51
|
+
ToolPresentationSnapshotV1Schema,
|
|
46
52
|
createLocalToolCallHeader,
|
|
47
53
|
createLocalToolCallSnapshot,
|
|
54
|
+
isToolPresentationSnapshotV1,
|
|
55
|
+
isValidDisplayData,
|
|
48
56
|
truncateForHeader
|
|
49
57
|
});
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { ToolPresentationSnapshotV1 } from './types.js';
|
|
2
|
+
export type { ToolDisplayData } from './display-types.js';
|
|
3
|
+
export { isValidDisplayData } from './display-types.js';
|
|
4
|
+
export type { ToolPresentationSnapshotV1 } from './presentation-schema.js';
|
|
5
|
+
export { isToolPresentationSnapshotV1, ToolPresentationSnapshotV1Schema, } from './presentation-schema.js';
|
|
2
6
|
export declare function createLocalToolCallHeader(options: {
|
|
3
7
|
title: string;
|
|
4
8
|
argsText?: string;
|
|
@@ -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,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,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,4 +1,9 @@
|
|
|
1
1
|
import "../chunk-C6A6W6XS.js";
|
|
2
|
+
import { isValidDisplayData } from "./display-types.js";
|
|
3
|
+
import {
|
|
4
|
+
isToolPresentationSnapshotV1,
|
|
5
|
+
ToolPresentationSnapshotV1Schema
|
|
6
|
+
} from "./presentation-schema.js";
|
|
2
7
|
function createLocalToolCallHeader(options) {
|
|
3
8
|
return {
|
|
4
9
|
title: options.title,
|
|
@@ -18,7 +23,10 @@ function truncateForHeader(value, maxLen) {
|
|
|
18
23
|
return value.slice(0, maxLen - 3) + "...";
|
|
19
24
|
}
|
|
20
25
|
export {
|
|
26
|
+
ToolPresentationSnapshotV1Schema,
|
|
21
27
|
createLocalToolCallHeader,
|
|
22
28
|
createLocalToolCallSnapshot,
|
|
29
|
+
isToolPresentationSnapshotV1,
|
|
30
|
+
isValidDisplayData,
|
|
23
31
|
truncateForHeader
|
|
24
32
|
};
|