@defai.digital/ax-cli 0.1.1 → 0.2.2
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/README.md +24 -16
- package/automatosx.config.json +333 -0
- package/dist/agent/grok-agent.d.ts +7 -1
- package/dist/agent/grok-agent.js +22 -9
- package/dist/agent/grok-agent.js.map +1 -1
- package/dist/commands/mcp.js +1 -1
- package/dist/commands/mcp.js.map +1 -1
- package/dist/constants.d.ts +67 -1
- package/dist/constants.js +57 -1
- package/dist/constants.js.map +1 -1
- package/dist/grok/client.d.ts +133 -2
- package/dist/grok/client.js +173 -16
- package/dist/grok/client.js.map +1 -1
- package/dist/grok/types.d.ts +291 -0
- package/dist/grok/types.js +127 -0
- package/dist/grok/types.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/config.d.ts +1 -1
- package/dist/mcp/config.js +28 -5
- package/dist/mcp/config.js.map +1 -1
- package/dist/mcp/transports.d.ts +6 -3
- package/dist/mcp/transports.js +18 -12
- package/dist/mcp/transports.js.map +1 -1
- package/dist/schemas/api-schemas.d.ts +569 -0
- package/dist/schemas/api-schemas.js +117 -0
- package/dist/schemas/api-schemas.js.map +1 -0
- package/dist/schemas/confirmation-schemas.d.ts +60 -0
- package/dist/schemas/confirmation-schemas.js +41 -0
- package/dist/schemas/confirmation-schemas.js.map +1 -0
- package/dist/schemas/index-unified.d.ts +12 -0
- package/dist/schemas/index-unified.js +17 -0
- package/dist/schemas/index-unified.js.map +1 -0
- package/dist/schemas/index.d.ts +8 -8
- package/dist/schemas/index.js +5 -4
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/mcp-schemas.d.ts +171 -0
- package/dist/schemas/mcp-schemas.js +77 -0
- package/dist/schemas/mcp-schemas.js.map +1 -0
- package/dist/schemas/tool-schemas.d.ts +2 -2
- package/dist/tools/search.js +2 -2
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/text-editor.js +6 -0
- package/dist/tools/text-editor.js.map +1 -1
- package/dist/ui/components/api-key-input.js +2 -2
- package/dist/ui/components/api-key-input.js.map +1 -1
- package/dist/ui/components/chat-history.js +2 -0
- package/dist/ui/components/chat-history.js.map +1 -1
- package/dist/ui/components/chat-interface.js +31 -1
- package/dist/ui/components/chat-interface.js.map +1 -1
- package/dist/ui/components/mcp-status.js +1 -1
- package/dist/ui/components/mcp-status.js.map +1 -1
- package/dist/ui/components/reasoning-display.d.ts +109 -0
- package/dist/ui/components/reasoning-display.js +110 -0
- package/dist/ui/components/reasoning-display.js.map +1 -0
- package/dist/ui/shared/max-sized-box.js +1 -1
- package/dist/ui/shared/max-sized-box.js.map +1 -1
- package/dist/utils/cache.d.ts +75 -0
- package/dist/utils/cache.js +137 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/confirmation-service.js +2 -2
- package/dist/utils/confirmation-service.js.map +1 -1
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.js +23 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/path-validator.d.ts +30 -0
- package/dist/utils/path-validator.js +67 -0
- package/dist/utils/path-validator.js.map +1 -0
- package/dist/utils/performance.d.ts +72 -0
- package/dist/utils/performance.js +114 -0
- package/dist/utils/performance.js.map +1 -0
- package/dist/utils/settings-manager.js +2 -2
- package/dist/utils/settings-manager.js.map +1 -1
- package/dist/utils/token-counter.d.ts +8 -1
- package/dist/utils/token-counter.js +11 -10
- package/dist/utils/token-counter.js.map +1 -1
- package/eslint.config.js +60 -0
- package/package.json +6 -2
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for API request/response validation
|
|
3
|
+
* Ensures type safety for external API interactions
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { MessageRoleEnum } from '@ax-cli/schemas';
|
|
7
|
+
// Grok Tool Call Schema
|
|
8
|
+
export const GrokToolCallSchema = z.object({
|
|
9
|
+
id: z.string(),
|
|
10
|
+
type: z.literal('function'),
|
|
11
|
+
function: z.object({
|
|
12
|
+
name: z.string(),
|
|
13
|
+
arguments: z.string(),
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
// Grok Message Schema
|
|
17
|
+
export const GrokMessageSchema = z.object({
|
|
18
|
+
role: MessageRoleEnum,
|
|
19
|
+
content: z.string().nullable(),
|
|
20
|
+
tool_calls: z.array(GrokToolCallSchema).optional(),
|
|
21
|
+
tool_call_id: z.string().optional(),
|
|
22
|
+
name: z.string().optional(),
|
|
23
|
+
});
|
|
24
|
+
// Grok Response Schema
|
|
25
|
+
export const GrokResponseSchema = z.object({
|
|
26
|
+
id: z.string().optional(),
|
|
27
|
+
object: z.string().optional(),
|
|
28
|
+
created: z.number().optional(),
|
|
29
|
+
model: z.string().optional(),
|
|
30
|
+
choices: z.array(z.object({
|
|
31
|
+
index: z.number().optional(),
|
|
32
|
+
message: z.object({
|
|
33
|
+
role: z.string(),
|
|
34
|
+
content: z.string().nullable(),
|
|
35
|
+
tool_calls: z.array(GrokToolCallSchema).optional(),
|
|
36
|
+
}),
|
|
37
|
+
finish_reason: z.string().nullable(),
|
|
38
|
+
})),
|
|
39
|
+
usage: z
|
|
40
|
+
.object({
|
|
41
|
+
prompt_tokens: z.number(),
|
|
42
|
+
completion_tokens: z.number(),
|
|
43
|
+
total_tokens: z.number(),
|
|
44
|
+
})
|
|
45
|
+
.optional(),
|
|
46
|
+
});
|
|
47
|
+
// Search Parameters Schema
|
|
48
|
+
export const SearchParametersSchema = z.object({
|
|
49
|
+
mode: z.enum(['auto', 'on', 'off']).optional(),
|
|
50
|
+
});
|
|
51
|
+
// Search Options Schema
|
|
52
|
+
export const SearchOptionsSchema = z.object({
|
|
53
|
+
search_parameters: SearchParametersSchema.optional(),
|
|
54
|
+
});
|
|
55
|
+
// Streaming Chunk Schema
|
|
56
|
+
export const StreamingChunkSchema = z.discriminatedUnion('type', [
|
|
57
|
+
z.object({
|
|
58
|
+
type: z.literal('content'),
|
|
59
|
+
content: z.string(),
|
|
60
|
+
}),
|
|
61
|
+
z.object({
|
|
62
|
+
type: z.literal('tool_calls'),
|
|
63
|
+
toolCalls: z.array(GrokToolCallSchema),
|
|
64
|
+
}),
|
|
65
|
+
z.object({
|
|
66
|
+
type: z.literal('tool_result'),
|
|
67
|
+
toolCall: GrokToolCallSchema,
|
|
68
|
+
toolResult: z.object({
|
|
69
|
+
success: z.boolean(),
|
|
70
|
+
output: z.string().optional(),
|
|
71
|
+
error: z.string().optional(),
|
|
72
|
+
}),
|
|
73
|
+
}),
|
|
74
|
+
z.object({
|
|
75
|
+
type: z.literal('token_count'),
|
|
76
|
+
tokenCount: z.number(),
|
|
77
|
+
}),
|
|
78
|
+
z.object({
|
|
79
|
+
type: z.literal('done'),
|
|
80
|
+
}),
|
|
81
|
+
]);
|
|
82
|
+
// Chat Entry Schema
|
|
83
|
+
export const ChatEntrySchema = z.object({
|
|
84
|
+
type: z.enum(['user', 'assistant', 'tool_result', 'tool_call']),
|
|
85
|
+
content: z.string(),
|
|
86
|
+
timestamp: z.date(),
|
|
87
|
+
toolCalls: z.array(GrokToolCallSchema).optional(),
|
|
88
|
+
toolCall: GrokToolCallSchema.optional(),
|
|
89
|
+
toolResult: z
|
|
90
|
+
.object({
|
|
91
|
+
success: z.boolean(),
|
|
92
|
+
output: z.string().optional(),
|
|
93
|
+
error: z.string().optional(),
|
|
94
|
+
})
|
|
95
|
+
.optional(),
|
|
96
|
+
isStreaming: z.boolean().optional(),
|
|
97
|
+
});
|
|
98
|
+
/**
|
|
99
|
+
* Validation helper functions
|
|
100
|
+
*/
|
|
101
|
+
export function validateGrokResponse(data) {
|
|
102
|
+
return GrokResponseSchema.parse(data);
|
|
103
|
+
}
|
|
104
|
+
export function safeValidateGrokResponse(data) {
|
|
105
|
+
const result = GrokResponseSchema.safeParse(data);
|
|
106
|
+
if (result.success) {
|
|
107
|
+
return { success: true, data: result.data };
|
|
108
|
+
}
|
|
109
|
+
return { success: false, error: result.error };
|
|
110
|
+
}
|
|
111
|
+
export function validateToolCall(data) {
|
|
112
|
+
return GrokToolCallSchema.parse(data);
|
|
113
|
+
}
|
|
114
|
+
export function validateChatEntry(data) {
|
|
115
|
+
return ChatEntrySchema.parse(data);
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=api-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-schemas.js","sourceRoot":"","sources":["../../src/schemas/api-schemas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,wBAAwB;AACxB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC3B,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAChB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACtB,CAAC;CACH,CAAC,CAAC;AAIH,sBAAsB;AACtB,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,eAAe;IACrB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,UAAU,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE;IAClD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AAIH,uBAAuB;AACvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,EAAE,EAAE,CA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|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export declare const ConfirmationOptionsSchema: z.ZodObject<{
|
|
7
|
+
operation: z.ZodString;
|
|
8
|
+
filename: z.ZodString;
|
|
9
|
+
showVSCodeOpen: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
content: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
filename: string;
|
|
13
|
+
operation: string;
|
|
14
|
+
content?: string | undefined;
|
|
15
|
+
showVSCodeOpen?: boolean | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
filename: string;
|
|
18
|
+
operation: string;
|
|
19
|
+
content?: string | undefined;
|
|
20
|
+
showVSCodeOpen?: boolean | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export type ConfirmationOptions = z.infer<typeof ConfirmationOptionsSchema>;
|
|
23
|
+
export declare const ConfirmationResultSchema: z.ZodObject<{
|
|
24
|
+
confirmed: z.ZodBoolean;
|
|
25
|
+
dontAskAgain: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
feedback: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
confirmed: boolean;
|
|
29
|
+
dontAskAgain?: boolean | undefined;
|
|
30
|
+
feedback?: string | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
confirmed: boolean;
|
|
33
|
+
dontAskAgain?: boolean | undefined;
|
|
34
|
+
feedback?: string | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
export type ConfirmationResult = z.infer<typeof ConfirmationResultSchema>;
|
|
37
|
+
export declare const SessionFlagsSchema: z.ZodObject<{
|
|
38
|
+
fileOperations: z.ZodBoolean;
|
|
39
|
+
bashCommands: z.ZodBoolean;
|
|
40
|
+
allOperations: z.ZodBoolean;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
fileOperations: boolean;
|
|
43
|
+
bashCommands: boolean;
|
|
44
|
+
allOperations: boolean;
|
|
45
|
+
}, {
|
|
46
|
+
fileOperations: boolean;
|
|
47
|
+
bashCommands: boolean;
|
|
48
|
+
allOperations: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
export type SessionFlags = z.infer<typeof SessionFlagsSchema>;
|
|
51
|
+
/**
|
|
52
|
+
* Validation helper functions
|
|
53
|
+
*/
|
|
54
|
+
export declare function validateConfirmationOptions(data: unknown): ConfirmationOptions;
|
|
55
|
+
export declare function safeValidateConfirmationOptions(data: unknown): {
|
|
56
|
+
success: boolean;
|
|
57
|
+
data?: ConfirmationOptions;
|
|
58
|
+
error?: z.ZodError;
|
|
59
|
+
};
|
|
60
|
+
export declare function validateConfirmationResult(data: unknown): ConfirmationResult;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for confirmation service validation
|
|
3
|
+
* Ensures type safety for user confirmation dialogs
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
// Confirmation Options Schema
|
|
7
|
+
export const ConfirmationOptionsSchema = z.object({
|
|
8
|
+
operation: z.string().min(1, 'Operation description required'),
|
|
9
|
+
filename: z.string().min(1, 'Filename required'),
|
|
10
|
+
showVSCodeOpen: z.boolean().optional(),
|
|
11
|
+
content: z.string().optional(),
|
|
12
|
+
});
|
|
13
|
+
// Confirmation Result Schema
|
|
14
|
+
export const ConfirmationResultSchema = z.object({
|
|
15
|
+
confirmed: z.boolean(),
|
|
16
|
+
dontAskAgain: z.boolean().optional(),
|
|
17
|
+
feedback: z.string().optional(),
|
|
18
|
+
});
|
|
19
|
+
// Session Flags Schema
|
|
20
|
+
export const SessionFlagsSchema = z.object({
|
|
21
|
+
fileOperations: z.boolean(),
|
|
22
|
+
bashCommands: z.boolean(),
|
|
23
|
+
allOperations: z.boolean(),
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Validation helper functions
|
|
27
|
+
*/
|
|
28
|
+
export function validateConfirmationOptions(data) {
|
|
29
|
+
return ConfirmationOptionsSchema.parse(data);
|
|
30
|
+
}
|
|
31
|
+
export function safeValidateConfirmationOptions(data) {
|
|
32
|
+
const result = ConfirmationOptionsSchema.safeParse(data);
|
|
33
|
+
if (result.success) {
|
|
34
|
+
return { success: true, data: result.data };
|
|
35
|
+
}
|
|
36
|
+
return { success: false, error: result.error };
|
|
37
|
+
}
|
|
38
|
+
export function validateConfirmationResult(data) {
|
|
39
|
+
return ConfirmationResultSchema.parse(data);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=confirmation-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirmation-schemas.js","sourceRoot":"","sources":["../../src/schemas/confirmation-schemas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8BAA8B;AAC9B,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,gCAAgC,CAAC;IAC9D,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,mBAAmB,CAAC;IAChD,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACtC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC/B,CAAC,CAAC;AAIH,6BAA6B;AAC7B,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/C,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE;IACtB,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACpC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC;AAIH,uBAAuB;AACvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,cAAc,EAAE,CAAC,CAAC,OAAO,EAAE;IAC3B,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE;IACzB,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE;CAC3B,CAAC,CAAC;AAIH;;GAEG;AAEH,MAAM,UAAU,2BAA2B,CACzC,IAAa;IAEb,OAAO,yBAAyB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,IAAa;IAK3D,MAAM,MAAM,GAAG,yBAAyB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,IAAa;IACtD,OAAO,wBAAwB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified schema exports
|
|
3
|
+
* Central location for all Zod schemas and types
|
|
4
|
+
*/
|
|
5
|
+
export * from './settings-schemas.js';
|
|
6
|
+
export * from './tool-schemas.js';
|
|
7
|
+
export * from './api-schemas.js';
|
|
8
|
+
export * from './confirmation-schemas.js';
|
|
9
|
+
/**
|
|
10
|
+
* Re-export commonly used Zod utilities
|
|
11
|
+
*/
|
|
12
|
+
export { z } from 'zod';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified schema exports
|
|
3
|
+
* Central location for all Zod schemas and types
|
|
4
|
+
*/
|
|
5
|
+
// Settings schemas
|
|
6
|
+
export * from './settings-schemas.js';
|
|
7
|
+
// Tool schemas
|
|
8
|
+
export * from './tool-schemas.js';
|
|
9
|
+
// API schemas
|
|
10
|
+
export * from './api-schemas.js';
|
|
11
|
+
// Confirmation schemas
|
|
12
|
+
export * from './confirmation-schemas.js';
|
|
13
|
+
/**
|
|
14
|
+
* Re-export commonly used Zod utilities
|
|
15
|
+
*/
|
|
16
|
+
export { z } from 'zod';
|
|
17
|
+
//# sourceMappingURL=index-unified.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-unified.js","sourceRoot":"","sources":["../../src/schemas/index-unified.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,mBAAmB;AACnB,cAAc,uBAAuB,CAAC;AAEtC,eAAe;AACf,cAAc,mBAAmB,CAAC;AAElC,cAAc;AACd,cAAc,kBAAkB,CAAC;AAEjC,uBAAuB;AACvB,cAAc,2BAA2B,CAAC;AAE1C;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"}
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -189,7 +189,7 @@ export declare const APIResponseSchema: z.ZodObject<{
|
|
|
189
189
|
}[] | undefined;
|
|
190
190
|
};
|
|
191
191
|
index: number;
|
|
192
|
-
finish_reason: "length" | "
|
|
192
|
+
finish_reason: "length" | "tool_calls" | "stop" | "content_filter" | null;
|
|
193
193
|
}, {
|
|
194
194
|
message: {
|
|
195
195
|
role: "system" | "user" | "assistant" | "tool";
|
|
@@ -204,7 +204,7 @@ export declare const APIResponseSchema: z.ZodObject<{
|
|
|
204
204
|
}[] | undefined;
|
|
205
205
|
};
|
|
206
206
|
index: number;
|
|
207
|
-
finish_reason: "length" | "
|
|
207
|
+
finish_reason: "length" | "tool_calls" | "stop" | "content_filter" | null;
|
|
208
208
|
}>, "many">;
|
|
209
209
|
usage: z.ZodOptional<z.ZodObject<{
|
|
210
210
|
prompt_tokens: z.ZodNumber;
|
|
@@ -222,6 +222,8 @@ export declare const APIResponseSchema: z.ZodObject<{
|
|
|
222
222
|
}, "strip", z.ZodTypeAny, {
|
|
223
223
|
object: string;
|
|
224
224
|
id: string;
|
|
225
|
+
created: number;
|
|
226
|
+
model: string;
|
|
225
227
|
choices: {
|
|
226
228
|
message: {
|
|
227
229
|
role: "system" | "user" | "assistant" | "tool";
|
|
@@ -236,10 +238,8 @@ export declare const APIResponseSchema: z.ZodObject<{
|
|
|
236
238
|
}[] | undefined;
|
|
237
239
|
};
|
|
238
240
|
index: number;
|
|
239
|
-
finish_reason: "length" | "
|
|
241
|
+
finish_reason: "length" | "tool_calls" | "stop" | "content_filter" | null;
|
|
240
242
|
}[];
|
|
241
|
-
created: number;
|
|
242
|
-
model: string;
|
|
243
243
|
usage?: {
|
|
244
244
|
prompt_tokens: number;
|
|
245
245
|
completion_tokens: number;
|
|
@@ -248,6 +248,8 @@ export declare const APIResponseSchema: z.ZodObject<{
|
|
|
248
248
|
}, {
|
|
249
249
|
object: string;
|
|
250
250
|
id: string;
|
|
251
|
+
created: number;
|
|
252
|
+
model: string;
|
|
251
253
|
choices: {
|
|
252
254
|
message: {
|
|
253
255
|
role: "system" | "user" | "assistant" | "tool";
|
|
@@ -262,10 +264,8 @@ export declare const APIResponseSchema: z.ZodObject<{
|
|
|
262
264
|
}[] | undefined;
|
|
263
265
|
};
|
|
264
266
|
index: number;
|
|
265
|
-
finish_reason: "length" | "
|
|
267
|
+
finish_reason: "length" | "tool_calls" | "stop" | "content_filter" | null;
|
|
266
268
|
}[];
|
|
267
|
-
created: number;
|
|
268
|
-
model: string;
|
|
269
269
|
usage?: {
|
|
270
270
|
prompt_tokens: number;
|
|
271
271
|
completion_tokens: number;
|
package/dist/schemas/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
import { MessageRoleEnum, FinishReasonEnum, TransportEnum } from '@ax-cli/schemas';
|
|
2
3
|
/**
|
|
3
4
|
* Configuration schemas using Zod for runtime validation
|
|
4
5
|
*/
|
|
@@ -14,7 +15,7 @@ export const ProjectSettingsSchema = z.object({
|
|
|
14
15
|
model: z.string().optional(),
|
|
15
16
|
mcpServers: z.record(z.string(), z.object({
|
|
16
17
|
name: z.string(),
|
|
17
|
-
transport:
|
|
18
|
+
transport: TransportEnum,
|
|
18
19
|
command: z.string().optional(),
|
|
19
20
|
args: z.array(z.string()).optional(),
|
|
20
21
|
url: z.string().url().optional(),
|
|
@@ -24,7 +25,7 @@ export const ProjectSettingsSchema = z.object({
|
|
|
24
25
|
// MCP Server configuration schema
|
|
25
26
|
export const MCPServerConfigSchema = z.object({
|
|
26
27
|
name: z.string().min(1, 'Server name is required'),
|
|
27
|
-
transport:
|
|
28
|
+
transport: TransportEnum,
|
|
28
29
|
command: z.string().optional(),
|
|
29
30
|
args: z.array(z.string()).optional(),
|
|
30
31
|
url: z.string().url().optional(),
|
|
@@ -54,7 +55,7 @@ export const APIResponseSchema = z.object({
|
|
|
54
55
|
choices: z.array(z.object({
|
|
55
56
|
index: z.number(),
|
|
56
57
|
message: z.object({
|
|
57
|
-
role:
|
|
58
|
+
role: MessageRoleEnum,
|
|
58
59
|
content: z.string().nullable(),
|
|
59
60
|
tool_calls: z.array(z.object({
|
|
60
61
|
id: z.string(),
|
|
@@ -65,7 +66,7 @@ export const APIResponseSchema = z.object({
|
|
|
65
66
|
}),
|
|
66
67
|
})).optional(),
|
|
67
68
|
}),
|
|
68
|
-
finish_reason:
|
|
69
|
+
finish_reason: FinishReasonEnum.nullable(),
|
|
69
70
|
})),
|
|
70
71
|
usage: z.object({
|
|
71
72
|
prompt_tokens: z.number(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM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KAAK,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,IAAa;IACnD,OAAO,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC;AAED;;GAEG;AAEH,MAAM,UAAU,wBAAwB,CAAC,IAAa;IAKpD,MAAM,MAAM,GAAG,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,IAAa;IAKvD,MAAM,MAAM,GAAG,qBAAqB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for MCP (Model Context Protocol) validation
|
|
3
|
+
* Ensures type safety for MCP server configurations and tool definitions
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export declare const MCPTransportSchema: z.ZodEnum<["stdio", "http", "sse"]>;
|
|
7
|
+
export type MCPTransport = z.infer<typeof MCPTransportSchema>;
|
|
8
|
+
export declare const MCPServerConfigSchema: z.ZodEffects<z.ZodObject<{
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
transport: z.ZodEnum<["stdio", "http", "sse"]>;
|
|
11
|
+
command: z.ZodOptional<z.ZodString>;
|
|
12
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
13
|
+
url: z.ZodOptional<z.ZodString>;
|
|
14
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
name: string;
|
|
17
|
+
transport: "stdio" | "http" | "sse";
|
|
18
|
+
url?: string | undefined;
|
|
19
|
+
env?: Record<string, string> | undefined;
|
|
20
|
+
command?: string | undefined;
|
|
21
|
+
args?: string[] | undefined;
|
|
22
|
+
}, {
|
|
23
|
+
name: string;
|
|
24
|
+
transport: "stdio" | "http" | "sse";
|
|
25
|
+
url?: string | undefined;
|
|
26
|
+
env?: Record<string, string> | undefined;
|
|
27
|
+
command?: string | undefined;
|
|
28
|
+
args?: string[] | undefined;
|
|
29
|
+
}>, {
|
|
30
|
+
name: string;
|
|
31
|
+
transport: "stdio" | "http" | "sse";
|
|
32
|
+
url?: string | undefined;
|
|
33
|
+
env?: Record<string, string> | undefined;
|
|
34
|
+
command?: string | undefined;
|
|
35
|
+
args?: string[] | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
name: string;
|
|
38
|
+
transport: "stdio" | "http" | "sse";
|
|
39
|
+
url?: string | undefined;
|
|
40
|
+
env?: Record<string, string> | undefined;
|
|
41
|
+
command?: string | undefined;
|
|
42
|
+
args?: string[] | undefined;
|
|
43
|
+
}>;
|
|
44
|
+
export type MCPServerConfig = z.infer<typeof MCPServerConfigSchema>;
|
|
45
|
+
export declare const MCPToolSchema: z.ZodObject<{
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
description: z.ZodString;
|
|
48
|
+
inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
49
|
+
serverName: z.ZodString;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
inputSchema: Record<string, unknown>;
|
|
54
|
+
serverName: string;
|
|
55
|
+
}, {
|
|
56
|
+
name: string;
|
|
57
|
+
description: string;
|
|
58
|
+
inputSchema: Record<string, unknown>;
|
|
59
|
+
serverName: string;
|
|
60
|
+
}>;
|
|
61
|
+
export type MCPTool = z.infer<typeof MCPToolSchema>;
|
|
62
|
+
export declare const MCPConfigSchema: z.ZodObject<{
|
|
63
|
+
servers: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
64
|
+
name: z.ZodString;
|
|
65
|
+
transport: z.ZodEnum<["stdio", "http", "sse"]>;
|
|
66
|
+
command: z.ZodOptional<z.ZodString>;
|
|
67
|
+
args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
68
|
+
url: z.ZodOptional<z.ZodString>;
|
|
69
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
name: string;
|
|
72
|
+
transport: "stdio" | "http" | "sse";
|
|
73
|
+
url?: string | undefined;
|
|
74
|
+
env?: Record<string, string> | undefined;
|
|
75
|
+
command?: string | undefined;
|
|
76
|
+
args?: string[] | undefined;
|
|
77
|
+
}, {
|
|
78
|
+
name: string;
|
|
79
|
+
transport: "stdio" | "http" | "sse";
|
|
80
|
+
url?: string | undefined;
|
|
81
|
+
env?: Record<string, string> | undefined;
|
|
82
|
+
command?: string | undefined;
|
|
83
|
+
args?: string[] | undefined;
|
|
84
|
+
}>, {
|
|
85
|
+
name: string;
|
|
86
|
+
transport: "stdio" | "http" | "sse";
|
|
87
|
+
url?: string | undefined;
|
|
88
|
+
env?: Record<string, string> | undefined;
|
|
89
|
+
command?: string | undefined;
|
|
90
|
+
args?: string[] | undefined;
|
|
91
|
+
}, {
|
|
92
|
+
name: string;
|
|
93
|
+
transport: "stdio" | "http" | "sse";
|
|
94
|
+
url?: string | undefined;
|
|
95
|
+
env?: Record<string, string> | undefined;
|
|
96
|
+
command?: string | undefined;
|
|
97
|
+
args?: string[] | undefined;
|
|
98
|
+
}>, "many">;
|
|
99
|
+
}, "strip", z.ZodTypeAny, {
|
|
100
|
+
servers: {
|
|
101
|
+
name: string;
|
|
102
|
+
transport: "stdio" | "http" | "sse";
|
|
103
|
+
url?: string | undefined;
|
|
104
|
+
env?: Record<string, string> | undefined;
|
|
105
|
+
command?: string | undefined;
|
|
106
|
+
args?: string[] | undefined;
|
|
107
|
+
}[];
|
|
108
|
+
}, {
|
|
109
|
+
servers: {
|
|
110
|
+
name: string;
|
|
111
|
+
transport: "stdio" | "http" | "sse";
|
|
112
|
+
url?: string | undefined;
|
|
113
|
+
env?: Record<string, string> | undefined;
|
|
114
|
+
command?: string | undefined;
|
|
115
|
+
args?: string[] | undefined;
|
|
116
|
+
}[];
|
|
117
|
+
}>;
|
|
118
|
+
export type MCPConfig = z.infer<typeof MCPConfigSchema>;
|
|
119
|
+
export declare const MCPToolCallResultSchema: z.ZodObject<{
|
|
120
|
+
success: z.ZodBoolean;
|
|
121
|
+
output: z.ZodOptional<z.ZodString>;
|
|
122
|
+
error: z.ZodOptional<z.ZodString>;
|
|
123
|
+
content: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
124
|
+
type: z.ZodString;
|
|
125
|
+
text: z.ZodOptional<z.ZodString>;
|
|
126
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
127
|
+
}, "strip", z.ZodTypeAny, {
|
|
128
|
+
type: string;
|
|
129
|
+
data?: unknown;
|
|
130
|
+
text?: string | undefined;
|
|
131
|
+
}, {
|
|
132
|
+
type: string;
|
|
133
|
+
data?: unknown;
|
|
134
|
+
text?: string | undefined;
|
|
135
|
+
}>, "many">>;
|
|
136
|
+
}, "strip", z.ZodTypeAny, {
|
|
137
|
+
success: boolean;
|
|
138
|
+
content?: {
|
|
139
|
+
type: string;
|
|
140
|
+
data?: unknown;
|
|
141
|
+
text?: string | undefined;
|
|
142
|
+
}[] | undefined;
|
|
143
|
+
output?: string | undefined;
|
|
144
|
+
error?: string | undefined;
|
|
145
|
+
}, {
|
|
146
|
+
success: boolean;
|
|
147
|
+
content?: {
|
|
148
|
+
type: string;
|
|
149
|
+
data?: unknown;
|
|
150
|
+
text?: string | undefined;
|
|
151
|
+
}[] | undefined;
|
|
152
|
+
output?: string | undefined;
|
|
153
|
+
error?: string | undefined;
|
|
154
|
+
}>;
|
|
155
|
+
export type MCPToolCallResult = z.infer<typeof MCPToolCallResultSchema>;
|
|
156
|
+
/**
|
|
157
|
+
* Validation helper functions
|
|
158
|
+
*/
|
|
159
|
+
export declare function validateMCPServerConfig(data: unknown): MCPServerConfig;
|
|
160
|
+
export declare function safeValidateMCPServerConfig(data: unknown): {
|
|
161
|
+
success: boolean;
|
|
162
|
+
data?: MCPServerConfig;
|
|
163
|
+
error?: z.ZodError;
|
|
164
|
+
};
|
|
165
|
+
export declare function validateMCPConfig(data: unknown): MCPConfig;
|
|
166
|
+
export declare function safeValidateMCPConfig(data: unknown): {
|
|
167
|
+
success: boolean;
|
|
168
|
+
data?: MCPConfig;
|
|
169
|
+
error?: z.ZodError;
|
|
170
|
+
};
|
|
171
|
+
export declare function validateMCPTool(data: unknown): MCPTool;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for MCP (Model Context Protocol) validation
|
|
3
|
+
* Ensures type safety for MCP server configurations and tool definitions
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
// MCP Transport Types
|
|
7
|
+
export const MCPTransportSchema = z.enum(['stdio', 'http', 'sse']);
|
|
8
|
+
// MCP Server Configuration Schema
|
|
9
|
+
export const MCPServerConfigSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
name: z.string().min(1, 'Server name is required'),
|
|
12
|
+
transport: MCPTransportSchema,
|
|
13
|
+
command: z.string().optional(),
|
|
14
|
+
args: z.array(z.string()).optional(),
|
|
15
|
+
url: z.string().optional(),
|
|
16
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
17
|
+
})
|
|
18
|
+
.refine((data) => {
|
|
19
|
+
if (data.transport === 'stdio') {
|
|
20
|
+
return !!data.command;
|
|
21
|
+
}
|
|
22
|
+
if (data.transport === 'http' || data.transport === 'sse') {
|
|
23
|
+
return !!data.url;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}, {
|
|
27
|
+
message: 'stdio transport requires command, http/sse transport requires url',
|
|
28
|
+
});
|
|
29
|
+
// MCP Tool Schema
|
|
30
|
+
export const MCPToolSchema = z.object({
|
|
31
|
+
name: z.string().min(1),
|
|
32
|
+
description: z.string(),
|
|
33
|
+
inputSchema: z.record(z.unknown()),
|
|
34
|
+
serverName: z.string(),
|
|
35
|
+
});
|
|
36
|
+
// MCP Config Schema
|
|
37
|
+
export const MCPConfigSchema = z.object({
|
|
38
|
+
servers: z.array(MCPServerConfigSchema),
|
|
39
|
+
});
|
|
40
|
+
// MCP Tool Call Result Schema
|
|
41
|
+
export const MCPToolCallResultSchema = z.object({
|
|
42
|
+
success: z.boolean(),
|
|
43
|
+
output: z.string().optional(),
|
|
44
|
+
error: z.string().optional(),
|
|
45
|
+
content: z.array(z.object({
|
|
46
|
+
type: z.string(),
|
|
47
|
+
text: z.string().optional(),
|
|
48
|
+
data: z.unknown().optional(),
|
|
49
|
+
})).optional(),
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* Validation helper functions
|
|
53
|
+
*/
|
|
54
|
+
export function validateMCPServerConfig(data) {
|
|
55
|
+
return MCPServerConfigSchema.parse(data);
|
|
56
|
+
}
|
|
57
|
+
export function safeValidateMCPServerConfig(data) {
|
|
58
|
+
const result = MCPServerConfigSchema.safeParse(data);
|
|
59
|
+
if (result.success) {
|
|
60
|
+
return { success: true, data: result.data };
|
|
61
|
+
}
|
|
62
|
+
return { success: false, error: result.error };
|
|
63
|
+
}
|
|
64
|
+
export function validateMCPConfig(data) {
|
|
65
|
+
return MCPConfigSchema.parse(data);
|
|
66
|
+
}
|
|
67
|
+
export function safeValidateMCPConfig(data) {
|
|
68
|
+
const result = MCPConfigSchema.safeParse(data);
|
|
69
|
+
if (result.success) {
|
|
70
|
+
return { success: true, data: result.data };
|
|
71
|
+
}
|
|
72
|
+
return { success: false, error: result.error };
|
|
73
|
+
}
|
|
74
|
+
export function validateMCPTool(data) {
|
|
75
|
+
return MCPToolSchema.parse(data);
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=mcp-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-schemas.js","sourceRoot":"","sources":["../../src/schemas/mcp-schemas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,sBAAsB;AACtB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAInE,kCAAkC;AAClC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,yBAAyB,CAAC;IAClD,SAAS,EAAE,kBAAkB;IAC7B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACpC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC1B,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;CACjD,CAAC;KACD,MAAM,CACL,CAAC,IAAI,EAAE,EAAE;IACP,IAAI,IAAI,CAAC,SAAS,KAAK,OAAO,EAAE,CAAC;QAC/B,OAAO,CAA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AC,CACH,CAAC,QAAQ,EAAE;CACb,CAAC,CAAC;AAIH;;GAEG;AAEH,MAAM,UAAU,uBAAuB,CAAC,IAAa;IACnD,OAAO,qBAAqB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,IAAa;IAKvD,MAAM,MAAM,GAAG,qBAAqB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAa;IAC7C,OAAO,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,IAAa;IAKjD,MAAM,MAAM,GAAG,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -85,12 +85,12 @@ export declare const InsertSchema: z.ZodObject<{
|
|
|
85
85
|
new_str: z.ZodString;
|
|
86
86
|
}, "strip", z.ZodTypeAny, {
|
|
87
87
|
new_str: string;
|
|
88
|
-
file_path: string;
|
|
89
88
|
insert_line: number;
|
|
89
|
+
file_path: string;
|
|
90
90
|
}, {
|
|
91
91
|
new_str: string;
|
|
92
|
-
file_path: string;
|
|
93
92
|
insert_line: number;
|
|
93
|
+
file_path: string;
|
|
94
94
|
}>;
|
|
95
95
|
export declare const UndoEditSchema: z.ZodObject<{
|
|
96
96
|
file_path: z.ZodString;
|