@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
package/dist/mcp/transports.js
CHANGED
|
@@ -2,20 +2,24 @@ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
|
|
|
2
2
|
import { EventEmitter } from "events";
|
|
3
3
|
import axios from "axios";
|
|
4
4
|
export class StdioTransport {
|
|
5
|
-
config;
|
|
6
5
|
transport;
|
|
7
6
|
process;
|
|
7
|
+
command;
|
|
8
|
+
args;
|
|
9
|
+
env;
|
|
8
10
|
constructor(config) {
|
|
9
|
-
this.config = config;
|
|
10
11
|
if (!config.command) {
|
|
11
12
|
throw new Error('Command is required for stdio transport');
|
|
12
13
|
}
|
|
14
|
+
this.command = config.command;
|
|
15
|
+
this.args = config.args || [];
|
|
16
|
+
this.env = config.env;
|
|
13
17
|
}
|
|
14
18
|
async connect() {
|
|
15
19
|
// Create transport with environment variables to suppress verbose output
|
|
16
20
|
const env = {
|
|
17
21
|
...process.env,
|
|
18
|
-
...this.
|
|
22
|
+
...this.env,
|
|
19
23
|
// Try to suppress verbose output from mcp-remote
|
|
20
24
|
MCP_REMOTE_QUIET: '1',
|
|
21
25
|
MCP_REMOTE_SILENT: '1',
|
|
@@ -23,8 +27,8 @@ export class StdioTransport {
|
|
|
23
27
|
NODE_ENV: 'production'
|
|
24
28
|
};
|
|
25
29
|
this.transport = new StdioClientTransport({
|
|
26
|
-
command: this.
|
|
27
|
-
args: this.
|
|
30
|
+
command: this.command,
|
|
31
|
+
args: this.args,
|
|
28
32
|
env
|
|
29
33
|
});
|
|
30
34
|
return this.transport;
|
|
@@ -65,7 +69,7 @@ export class HttpTransport extends EventEmitter {
|
|
|
65
69
|
try {
|
|
66
70
|
await this.client.get('/health');
|
|
67
71
|
}
|
|
68
|
-
catch
|
|
72
|
+
catch {
|
|
69
73
|
// If health endpoint doesn't exist, assume connected
|
|
70
74
|
}
|
|
71
75
|
return new HttpClientTransport(this.client);
|
|
@@ -78,20 +82,20 @@ export class HttpTransport extends EventEmitter {
|
|
|
78
82
|
}
|
|
79
83
|
}
|
|
80
84
|
export class SSETransport extends EventEmitter {
|
|
81
|
-
|
|
85
|
+
url;
|
|
82
86
|
constructor(config) {
|
|
83
87
|
super();
|
|
84
|
-
this.config = config;
|
|
85
88
|
if (!config.url) {
|
|
86
89
|
throw new Error('URL is required for SSE transport');
|
|
87
90
|
}
|
|
91
|
+
this.url = config.url;
|
|
88
92
|
}
|
|
89
93
|
async connect() {
|
|
90
94
|
return new Promise((resolve, reject) => {
|
|
91
95
|
try {
|
|
92
96
|
// For Node.js environment, we'll use a simple HTTP-based approach
|
|
93
97
|
// In a real implementation, you'd use a proper SSE library like 'eventsource'
|
|
94
|
-
resolve(new SSEClientTransport(this.
|
|
98
|
+
resolve(new SSEClientTransport(this.url));
|
|
95
99
|
}
|
|
96
100
|
catch (error) {
|
|
97
101
|
reject(error);
|
|
@@ -156,18 +160,20 @@ class SSEClientTransport extends EventEmitter {
|
|
|
156
160
|
}
|
|
157
161
|
}
|
|
158
162
|
export class StreamableHttpTransport extends EventEmitter {
|
|
159
|
-
|
|
163
|
+
url;
|
|
164
|
+
headers;
|
|
160
165
|
constructor(config) {
|
|
161
166
|
super();
|
|
162
|
-
this.config = config;
|
|
163
167
|
if (!config.url) {
|
|
164
168
|
throw new Error('URL is required for streamable_http transport');
|
|
165
169
|
}
|
|
170
|
+
this.url = config.url;
|
|
171
|
+
this.headers = config.headers;
|
|
166
172
|
}
|
|
167
173
|
async connect() {
|
|
168
174
|
return new Promise((resolve, reject) => {
|
|
169
175
|
try {
|
|
170
|
-
resolve(new StreamableHttpClientTransport(this.
|
|
176
|
+
resolve(new StreamableHttpClientTransport(this.url, this.headers));
|
|
171
177
|
}
|
|
172
178
|
catch (error) {
|
|
173
179
|
reject(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports.js","sourceRoot":"","sources":["../../src/mcp/transports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAwB,MAAM,OAAO,CAAC;AAmB7C,MAAM,OAAO,cAAc;
|
|
1
|
+
{"version":3,"file":"transports.js","sourceRoot":"","sources":["../../src/mcp/transports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,O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IACtD,YAAY,IAAY,EAAE,QAAiC;QACzD,KAAK,EAAE,CAAC;IACV,CAAC;IAED,KAAK,CAAC,KAAK;QACT,0EAA0E;IAC5E,CAAC;IAED,KAAK,CAAC,KAAK;QACT,iDAAiD;IACnD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAY;QACrB,OAAO,CAAC,GAAG,CAAC,sHAAsH,CAAC,CAAC;QACpI,OAAO,CAAC,GAAG,CAAC,sDAAsD,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAE7F,mFAAmF;QACnF,mDAAmD;QACnD,MAAM,IAAI,KAAK,CAAC,+JAA+J,CAAC,CAAC;IACnL,CAAC;CACF;AAED,MAAM,UAAU,eAAe,CAAC,MAAuB;IACrD,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QACpC,KAAK,MAAM;YACT,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;QACnC,KAAK,KAAK;YACR,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;QAClC,KAAK,iBAAiB;YACpB,OAAO,IAAI,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAC7C;YACE,MAAM,IAAI,KAAK,CAAC,+BAA+B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schemas for API request/response validation
|
|
3
|
+
* Ensures type safety for external API interactions
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
export declare const GrokToolCallSchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
type: z.ZodLiteral<"function">;
|
|
9
|
+
function: z.ZodObject<{
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
arguments: z.ZodString;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
name: string;
|
|
14
|
+
arguments: string;
|
|
15
|
+
}, {
|
|
16
|
+
name: string;
|
|
17
|
+
arguments: string;
|
|
18
|
+
}>;
|
|
19
|
+
}, "strip", z.ZodTypeAny, {
|
|
20
|
+
function: {
|
|
21
|
+
name: string;
|
|
22
|
+
arguments: string;
|
|
23
|
+
};
|
|
24
|
+
id: string;
|
|
25
|
+
type: "function";
|
|
26
|
+
}, {
|
|
27
|
+
function: {
|
|
28
|
+
name: string;
|
|
29
|
+
arguments: string;
|
|
30
|
+
};
|
|
31
|
+
id: string;
|
|
32
|
+
type: "function";
|
|
33
|
+
}>;
|
|
34
|
+
export type GrokToolCall = z.infer<typeof GrokToolCallSchema>;
|
|
35
|
+
export declare const GrokMessageSchema: z.ZodObject<{
|
|
36
|
+
role: z.ZodEnum<["system", "user", "assistant", "tool"]>;
|
|
37
|
+
content: z.ZodNullable<z.ZodString>;
|
|
38
|
+
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
type: z.ZodLiteral<"function">;
|
|
41
|
+
function: z.ZodObject<{
|
|
42
|
+
name: z.ZodString;
|
|
43
|
+
arguments: z.ZodString;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
name: string;
|
|
46
|
+
arguments: string;
|
|
47
|
+
}, {
|
|
48
|
+
name: string;
|
|
49
|
+
arguments: string;
|
|
50
|
+
}>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
function: {
|
|
53
|
+
name: string;
|
|
54
|
+
arguments: string;
|
|
55
|
+
};
|
|
56
|
+
id: string;
|
|
57
|
+
type: "function";
|
|
58
|
+
}, {
|
|
59
|
+
function: {
|
|
60
|
+
name: string;
|
|
61
|
+
arguments: string;
|
|
62
|
+
};
|
|
63
|
+
id: string;
|
|
64
|
+
type: "function";
|
|
65
|
+
}>, "many">>;
|
|
66
|
+
tool_call_id: z.ZodOptional<z.ZodString>;
|
|
67
|
+
name: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, "strip", z.ZodTypeAny, {
|
|
69
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
70
|
+
content: string | null;
|
|
71
|
+
name?: string | undefined;
|
|
72
|
+
tool_calls?: {
|
|
73
|
+
function: {
|
|
74
|
+
name: string;
|
|
75
|
+
arguments: string;
|
|
76
|
+
};
|
|
77
|
+
id: string;
|
|
78
|
+
type: "function";
|
|
79
|
+
}[] | undefined;
|
|
80
|
+
tool_call_id?: string | undefined;
|
|
81
|
+
}, {
|
|
82
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
83
|
+
content: string | null;
|
|
84
|
+
name?: string | undefined;
|
|
85
|
+
tool_calls?: {
|
|
86
|
+
function: {
|
|
87
|
+
name: string;
|
|
88
|
+
arguments: string;
|
|
89
|
+
};
|
|
90
|
+
id: string;
|
|
91
|
+
type: "function";
|
|
92
|
+
}[] | undefined;
|
|
93
|
+
tool_call_id?: string | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
export type GrokMessage = z.infer<typeof GrokMessageSchema>;
|
|
96
|
+
export declare const GrokResponseSchema: z.ZodObject<{
|
|
97
|
+
id: z.ZodOptional<z.ZodString>;
|
|
98
|
+
object: z.ZodOptional<z.ZodString>;
|
|
99
|
+
created: z.ZodOptional<z.ZodNumber>;
|
|
100
|
+
model: z.ZodOptional<z.ZodString>;
|
|
101
|
+
choices: z.ZodArray<z.ZodObject<{
|
|
102
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
message: z.ZodObject<{
|
|
104
|
+
role: z.ZodString;
|
|
105
|
+
content: z.ZodNullable<z.ZodString>;
|
|
106
|
+
tool_calls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
107
|
+
id: z.ZodString;
|
|
108
|
+
type: z.ZodLiteral<"function">;
|
|
109
|
+
function: z.ZodObject<{
|
|
110
|
+
name: z.ZodString;
|
|
111
|
+
arguments: z.ZodString;
|
|
112
|
+
}, "strip", z.ZodTypeAny, {
|
|
113
|
+
name: string;
|
|
114
|
+
arguments: string;
|
|
115
|
+
}, {
|
|
116
|
+
name: string;
|
|
117
|
+
arguments: string;
|
|
118
|
+
}>;
|
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
|
120
|
+
function: {
|
|
121
|
+
name: string;
|
|
122
|
+
arguments: string;
|
|
123
|
+
};
|
|
124
|
+
id: string;
|
|
125
|
+
type: "function";
|
|
126
|
+
}, {
|
|
127
|
+
function: {
|
|
128
|
+
name: string;
|
|
129
|
+
arguments: string;
|
|
130
|
+
};
|
|
131
|
+
id: string;
|
|
132
|
+
type: "function";
|
|
133
|
+
}>, "many">>;
|
|
134
|
+
}, "strip", z.ZodTypeAny, {
|
|
135
|
+
role: string;
|
|
136
|
+
content: string | null;
|
|
137
|
+
tool_calls?: {
|
|
138
|
+
function: {
|
|
139
|
+
name: string;
|
|
140
|
+
arguments: string;
|
|
141
|
+
};
|
|
142
|
+
id: string;
|
|
143
|
+
type: "function";
|
|
144
|
+
}[] | undefined;
|
|
145
|
+
}, {
|
|
146
|
+
role: string;
|
|
147
|
+
content: string | null;
|
|
148
|
+
tool_calls?: {
|
|
149
|
+
function: {
|
|
150
|
+
name: string;
|
|
151
|
+
arguments: string;
|
|
152
|
+
};
|
|
153
|
+
id: string;
|
|
154
|
+
type: "function";
|
|
155
|
+
}[] | undefined;
|
|
156
|
+
}>;
|
|
157
|
+
finish_reason: z.ZodNullable<z.ZodString>;
|
|
158
|
+
}, "strip", z.ZodTypeAny, {
|
|
159
|
+
message: {
|
|
160
|
+
role: string;
|
|
161
|
+
content: string | null;
|
|
162
|
+
tool_calls?: {
|
|
163
|
+
function: {
|
|
164
|
+
name: string;
|
|
165
|
+
arguments: string;
|
|
166
|
+
};
|
|
167
|
+
id: string;
|
|
168
|
+
type: "function";
|
|
169
|
+
}[] | undefined;
|
|
170
|
+
};
|
|
171
|
+
finish_reason: string | null;
|
|
172
|
+
index?: number | undefined;
|
|
173
|
+
}, {
|
|
174
|
+
message: {
|
|
175
|
+
role: string;
|
|
176
|
+
content: string | null;
|
|
177
|
+
tool_calls?: {
|
|
178
|
+
function: {
|
|
179
|
+
name: string;
|
|
180
|
+
arguments: string;
|
|
181
|
+
};
|
|
182
|
+
id: string;
|
|
183
|
+
type: "function";
|
|
184
|
+
}[] | undefined;
|
|
185
|
+
};
|
|
186
|
+
finish_reason: string | null;
|
|
187
|
+
index?: number | undefined;
|
|
188
|
+
}>, "many">;
|
|
189
|
+
usage: z.ZodOptional<z.ZodObject<{
|
|
190
|
+
prompt_tokens: z.ZodNumber;
|
|
191
|
+
completion_tokens: z.ZodNumber;
|
|
192
|
+
total_tokens: z.ZodNumber;
|
|
193
|
+
}, "strip", z.ZodTypeAny, {
|
|
194
|
+
prompt_tokens: number;
|
|
195
|
+
completion_tokens: number;
|
|
196
|
+
total_tokens: number;
|
|
197
|
+
}, {
|
|
198
|
+
prompt_tokens: number;
|
|
199
|
+
completion_tokens: number;
|
|
200
|
+
total_tokens: number;
|
|
201
|
+
}>>;
|
|
202
|
+
}, "strip", z.ZodTypeAny, {
|
|
203
|
+
choices: {
|
|
204
|
+
message: {
|
|
205
|
+
role: string;
|
|
206
|
+
content: string | null;
|
|
207
|
+
tool_calls?: {
|
|
208
|
+
function: {
|
|
209
|
+
name: string;
|
|
210
|
+
arguments: string;
|
|
211
|
+
};
|
|
212
|
+
id: string;
|
|
213
|
+
type: "function";
|
|
214
|
+
}[] | undefined;
|
|
215
|
+
};
|
|
216
|
+
finish_reason: string | null;
|
|
217
|
+
index?: number | undefined;
|
|
218
|
+
}[];
|
|
219
|
+
object?: string | undefined;
|
|
220
|
+
id?: string | undefined;
|
|
221
|
+
created?: number | undefined;
|
|
222
|
+
model?: string | undefined;
|
|
223
|
+
usage?: {
|
|
224
|
+
prompt_tokens: number;
|
|
225
|
+
completion_tokens: number;
|
|
226
|
+
total_tokens: number;
|
|
227
|
+
} | undefined;
|
|
228
|
+
}, {
|
|
229
|
+
choices: {
|
|
230
|
+
message: {
|
|
231
|
+
role: string;
|
|
232
|
+
content: string | null;
|
|
233
|
+
tool_calls?: {
|
|
234
|
+
function: {
|
|
235
|
+
name: string;
|
|
236
|
+
arguments: string;
|
|
237
|
+
};
|
|
238
|
+
id: string;
|
|
239
|
+
type: "function";
|
|
240
|
+
}[] | undefined;
|
|
241
|
+
};
|
|
242
|
+
finish_reason: string | null;
|
|
243
|
+
index?: number | undefined;
|
|
244
|
+
}[];
|
|
245
|
+
object?: string | undefined;
|
|
246
|
+
id?: string | undefined;
|
|
247
|
+
created?: number | undefined;
|
|
248
|
+
model?: string | undefined;
|
|
249
|
+
usage?: {
|
|
250
|
+
prompt_tokens: number;
|
|
251
|
+
completion_tokens: number;
|
|
252
|
+
total_tokens: number;
|
|
253
|
+
} | undefined;
|
|
254
|
+
}>;
|
|
255
|
+
export type GrokResponse = z.infer<typeof GrokResponseSchema>;
|
|
256
|
+
export declare const SearchParametersSchema: z.ZodObject<{
|
|
257
|
+
mode: z.ZodOptional<z.ZodEnum<["auto", "on", "off"]>>;
|
|
258
|
+
}, "strip", z.ZodTypeAny, {
|
|
259
|
+
mode?: "auto" | "on" | "off" | undefined;
|
|
260
|
+
}, {
|
|
261
|
+
mode?: "auto" | "on" | "off" | undefined;
|
|
262
|
+
}>;
|
|
263
|
+
export type SearchParameters = z.infer<typeof SearchParametersSchema>;
|
|
264
|
+
export declare const SearchOptionsSchema: z.ZodObject<{
|
|
265
|
+
search_parameters: z.ZodOptional<z.ZodObject<{
|
|
266
|
+
mode: z.ZodOptional<z.ZodEnum<["auto", "on", "off"]>>;
|
|
267
|
+
}, "strip", z.ZodTypeAny, {
|
|
268
|
+
mode?: "auto" | "on" | "off" | undefined;
|
|
269
|
+
}, {
|
|
270
|
+
mode?: "auto" | "on" | "off" | undefined;
|
|
271
|
+
}>>;
|
|
272
|
+
}, "strip", z.ZodTypeAny, {
|
|
273
|
+
search_parameters?: {
|
|
274
|
+
mode?: "auto" | "on" | "off" | undefined;
|
|
275
|
+
} | undefined;
|
|
276
|
+
}, {
|
|
277
|
+
search_parameters?: {
|
|
278
|
+
mode?: "auto" | "on" | "off" | undefined;
|
|
279
|
+
} | undefined;
|
|
280
|
+
}>;
|
|
281
|
+
export type SearchOptions = z.infer<typeof SearchOptionsSchema>;
|
|
282
|
+
export declare const StreamingChunkSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
283
|
+
type: z.ZodLiteral<"content">;
|
|
284
|
+
content: z.ZodString;
|
|
285
|
+
}, "strip", z.ZodTypeAny, {
|
|
286
|
+
type: "content";
|
|
287
|
+
content: string;
|
|
288
|
+
}, {
|
|
289
|
+
type: "content";
|
|
290
|
+
content: string;
|
|
291
|
+
}>, z.ZodObject<{
|
|
292
|
+
type: z.ZodLiteral<"tool_calls">;
|
|
293
|
+
toolCalls: z.ZodArray<z.ZodObject<{
|
|
294
|
+
id: z.ZodString;
|
|
295
|
+
type: z.ZodLiteral<"function">;
|
|
296
|
+
function: z.ZodObject<{
|
|
297
|
+
name: z.ZodString;
|
|
298
|
+
arguments: z.ZodString;
|
|
299
|
+
}, "strip", z.ZodTypeAny, {
|
|
300
|
+
name: string;
|
|
301
|
+
arguments: string;
|
|
302
|
+
}, {
|
|
303
|
+
name: string;
|
|
304
|
+
arguments: string;
|
|
305
|
+
}>;
|
|
306
|
+
}, "strip", z.ZodTypeAny, {
|
|
307
|
+
function: {
|
|
308
|
+
name: string;
|
|
309
|
+
arguments: string;
|
|
310
|
+
};
|
|
311
|
+
id: string;
|
|
312
|
+
type: "function";
|
|
313
|
+
}, {
|
|
314
|
+
function: {
|
|
315
|
+
name: string;
|
|
316
|
+
arguments: string;
|
|
317
|
+
};
|
|
318
|
+
id: string;
|
|
319
|
+
type: "function";
|
|
320
|
+
}>, "many">;
|
|
321
|
+
}, "strip", z.ZodTypeAny, {
|
|
322
|
+
type: "tool_calls";
|
|
323
|
+
toolCalls: {
|
|
324
|
+
function: {
|
|
325
|
+
name: string;
|
|
326
|
+
arguments: string;
|
|
327
|
+
};
|
|
328
|
+
id: string;
|
|
329
|
+
type: "function";
|
|
330
|
+
}[];
|
|
331
|
+
}, {
|
|
332
|
+
type: "tool_calls";
|
|
333
|
+
toolCalls: {
|
|
334
|
+
function: {
|
|
335
|
+
name: string;
|
|
336
|
+
arguments: string;
|
|
337
|
+
};
|
|
338
|
+
id: string;
|
|
339
|
+
type: "function";
|
|
340
|
+
}[];
|
|
341
|
+
}>, z.ZodObject<{
|
|
342
|
+
type: z.ZodLiteral<"tool_result">;
|
|
343
|
+
toolCall: z.ZodObject<{
|
|
344
|
+
id: z.ZodString;
|
|
345
|
+
type: z.ZodLiteral<"function">;
|
|
346
|
+
function: z.ZodObject<{
|
|
347
|
+
name: z.ZodString;
|
|
348
|
+
arguments: z.ZodString;
|
|
349
|
+
}, "strip", z.ZodTypeAny, {
|
|
350
|
+
name: string;
|
|
351
|
+
arguments: string;
|
|
352
|
+
}, {
|
|
353
|
+
name: string;
|
|
354
|
+
arguments: string;
|
|
355
|
+
}>;
|
|
356
|
+
}, "strip", z.ZodTypeAny, {
|
|
357
|
+
function: {
|
|
358
|
+
name: string;
|
|
359
|
+
arguments: string;
|
|
360
|
+
};
|
|
361
|
+
id: string;
|
|
362
|
+
type: "function";
|
|
363
|
+
}, {
|
|
364
|
+
function: {
|
|
365
|
+
name: string;
|
|
366
|
+
arguments: string;
|
|
367
|
+
};
|
|
368
|
+
id: string;
|
|
369
|
+
type: "function";
|
|
370
|
+
}>;
|
|
371
|
+
toolResult: z.ZodObject<{
|
|
372
|
+
success: z.ZodBoolean;
|
|
373
|
+
output: z.ZodOptional<z.ZodString>;
|
|
374
|
+
error: z.ZodOptional<z.ZodString>;
|
|
375
|
+
}, "strip", z.ZodTypeAny, {
|
|
376
|
+
success: boolean;
|
|
377
|
+
output?: string | undefined;
|
|
378
|
+
error?: string | undefined;
|
|
379
|
+
}, {
|
|
380
|
+
success: boolean;
|
|
381
|
+
output?: string | undefined;
|
|
382
|
+
error?: string | undefined;
|
|
383
|
+
}>;
|
|
384
|
+
}, "strip", z.ZodTypeAny, {
|
|
385
|
+
type: "tool_result";
|
|
386
|
+
toolCall: {
|
|
387
|
+
function: {
|
|
388
|
+
name: string;
|
|
389
|
+
arguments: string;
|
|
390
|
+
};
|
|
391
|
+
id: string;
|
|
392
|
+
type: "function";
|
|
393
|
+
};
|
|
394
|
+
toolResult: {
|
|
395
|
+
success: boolean;
|
|
396
|
+
output?: string | undefined;
|
|
397
|
+
error?: string | undefined;
|
|
398
|
+
};
|
|
399
|
+
}, {
|
|
400
|
+
type: "tool_result";
|
|
401
|
+
toolCall: {
|
|
402
|
+
function: {
|
|
403
|
+
name: string;
|
|
404
|
+
arguments: string;
|
|
405
|
+
};
|
|
406
|
+
id: string;
|
|
407
|
+
type: "function";
|
|
408
|
+
};
|
|
409
|
+
toolResult: {
|
|
410
|
+
success: boolean;
|
|
411
|
+
output?: string | undefined;
|
|
412
|
+
error?: string | undefined;
|
|
413
|
+
};
|
|
414
|
+
}>, z.ZodObject<{
|
|
415
|
+
type: z.ZodLiteral<"token_count">;
|
|
416
|
+
tokenCount: z.ZodNumber;
|
|
417
|
+
}, "strip", z.ZodTypeAny, {
|
|
418
|
+
type: "token_count";
|
|
419
|
+
tokenCount: number;
|
|
420
|
+
}, {
|
|
421
|
+
type: "token_count";
|
|
422
|
+
tokenCount: number;
|
|
423
|
+
}>, z.ZodObject<{
|
|
424
|
+
type: z.ZodLiteral<"done">;
|
|
425
|
+
}, "strip", z.ZodTypeAny, {
|
|
426
|
+
type: "done";
|
|
427
|
+
}, {
|
|
428
|
+
type: "done";
|
|
429
|
+
}>]>;
|
|
430
|
+
export type StreamingChunk = z.infer<typeof StreamingChunkSchema>;
|
|
431
|
+
export declare const ChatEntrySchema: z.ZodObject<{
|
|
432
|
+
type: z.ZodEnum<["user", "assistant", "tool_result", "tool_call"]>;
|
|
433
|
+
content: z.ZodString;
|
|
434
|
+
timestamp: z.ZodDate;
|
|
435
|
+
toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
436
|
+
id: z.ZodString;
|
|
437
|
+
type: z.ZodLiteral<"function">;
|
|
438
|
+
function: z.ZodObject<{
|
|
439
|
+
name: z.ZodString;
|
|
440
|
+
arguments: z.ZodString;
|
|
441
|
+
}, "strip", z.ZodTypeAny, {
|
|
442
|
+
name: string;
|
|
443
|
+
arguments: string;
|
|
444
|
+
}, {
|
|
445
|
+
name: string;
|
|
446
|
+
arguments: string;
|
|
447
|
+
}>;
|
|
448
|
+
}, "strip", z.ZodTypeAny, {
|
|
449
|
+
function: {
|
|
450
|
+
name: string;
|
|
451
|
+
arguments: string;
|
|
452
|
+
};
|
|
453
|
+
id: string;
|
|
454
|
+
type: "function";
|
|
455
|
+
}, {
|
|
456
|
+
function: {
|
|
457
|
+
name: string;
|
|
458
|
+
arguments: string;
|
|
459
|
+
};
|
|
460
|
+
id: string;
|
|
461
|
+
type: "function";
|
|
462
|
+
}>, "many">>;
|
|
463
|
+
toolCall: z.ZodOptional<z.ZodObject<{
|
|
464
|
+
id: z.ZodString;
|
|
465
|
+
type: z.ZodLiteral<"function">;
|
|
466
|
+
function: z.ZodObject<{
|
|
467
|
+
name: z.ZodString;
|
|
468
|
+
arguments: z.ZodString;
|
|
469
|
+
}, "strip", z.ZodTypeAny, {
|
|
470
|
+
name: string;
|
|
471
|
+
arguments: string;
|
|
472
|
+
}, {
|
|
473
|
+
name: string;
|
|
474
|
+
arguments: string;
|
|
475
|
+
}>;
|
|
476
|
+
}, "strip", z.ZodTypeAny, {
|
|
477
|
+
function: {
|
|
478
|
+
name: string;
|
|
479
|
+
arguments: string;
|
|
480
|
+
};
|
|
481
|
+
id: string;
|
|
482
|
+
type: "function";
|
|
483
|
+
}, {
|
|
484
|
+
function: {
|
|
485
|
+
name: string;
|
|
486
|
+
arguments: string;
|
|
487
|
+
};
|
|
488
|
+
id: string;
|
|
489
|
+
type: "function";
|
|
490
|
+
}>>;
|
|
491
|
+
toolResult: z.ZodOptional<z.ZodObject<{
|
|
492
|
+
success: z.ZodBoolean;
|
|
493
|
+
output: z.ZodOptional<z.ZodString>;
|
|
494
|
+
error: z.ZodOptional<z.ZodString>;
|
|
495
|
+
}, "strip", z.ZodTypeAny, {
|
|
496
|
+
success: boolean;
|
|
497
|
+
output?: string | undefined;
|
|
498
|
+
error?: string | undefined;
|
|
499
|
+
}, {
|
|
500
|
+
success: boolean;
|
|
501
|
+
output?: string | undefined;
|
|
502
|
+
error?: string | undefined;
|
|
503
|
+
}>>;
|
|
504
|
+
isStreaming: z.ZodOptional<z.ZodBoolean>;
|
|
505
|
+
}, "strip", z.ZodTypeAny, {
|
|
506
|
+
type: "user" | "assistant" | "tool_result" | "tool_call";
|
|
507
|
+
content: string;
|
|
508
|
+
timestamp: Date;
|
|
509
|
+
toolCalls?: {
|
|
510
|
+
function: {
|
|
511
|
+
name: string;
|
|
512
|
+
arguments: string;
|
|
513
|
+
};
|
|
514
|
+
id: string;
|
|
515
|
+
type: "function";
|
|
516
|
+
}[] | undefined;
|
|
517
|
+
toolCall?: {
|
|
518
|
+
function: {
|
|
519
|
+
name: string;
|
|
520
|
+
arguments: string;
|
|
521
|
+
};
|
|
522
|
+
id: string;
|
|
523
|
+
type: "function";
|
|
524
|
+
} | undefined;
|
|
525
|
+
toolResult?: {
|
|
526
|
+
success: boolean;
|
|
527
|
+
output?: string | undefined;
|
|
528
|
+
error?: string | undefined;
|
|
529
|
+
} | undefined;
|
|
530
|
+
isStreaming?: boolean | undefined;
|
|
531
|
+
}, {
|
|
532
|
+
type: "user" | "assistant" | "tool_result" | "tool_call";
|
|
533
|
+
content: string;
|
|
534
|
+
timestamp: Date;
|
|
535
|
+
toolCalls?: {
|
|
536
|
+
function: {
|
|
537
|
+
name: string;
|
|
538
|
+
arguments: string;
|
|
539
|
+
};
|
|
540
|
+
id: string;
|
|
541
|
+
type: "function";
|
|
542
|
+
}[] | undefined;
|
|
543
|
+
toolCall?: {
|
|
544
|
+
function: {
|
|
545
|
+
name: string;
|
|
546
|
+
arguments: string;
|
|
547
|
+
};
|
|
548
|
+
id: string;
|
|
549
|
+
type: "function";
|
|
550
|
+
} | undefined;
|
|
551
|
+
toolResult?: {
|
|
552
|
+
success: boolean;
|
|
553
|
+
output?: string | undefined;
|
|
554
|
+
error?: string | undefined;
|
|
555
|
+
} | undefined;
|
|
556
|
+
isStreaming?: boolean | undefined;
|
|
557
|
+
}>;
|
|
558
|
+
export type ChatEntry = z.infer<typeof ChatEntrySchema>;
|
|
559
|
+
/**
|
|
560
|
+
* Validation helper functions
|
|
561
|
+
*/
|
|
562
|
+
export declare function validateGrokResponse(data: unknown): GrokResponse;
|
|
563
|
+
export declare function safeValidateGrokResponse(data: unknown): {
|
|
564
|
+
success: boolean;
|
|
565
|
+
data?: GrokResponse;
|
|
566
|
+
error?: z.ZodError;
|
|
567
|
+
};
|
|
568
|
+
export declare function validateToolCall(data: unknown): GrokToolCall;
|
|
569
|
+
export declare function validateChatEntry(data: unknown): ChatEntry;
|