@ebowwa/codespaces-types 1.4.0 → 1.4.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/compile/index.js +245 -111
- package/compile/index.ts +4 -4
- package/compile/resources.js +86 -105
- package/compile/terminal-websocket.js +28 -39
- package/compile/time.js +24 -28
- package/compile/validation.js +40 -80
- package/package.json +1 -1
- package/runtime/ai.js +286 -468
- package/runtime/ai.ts +27 -5
- package/runtime/api.js +452 -677
- package/runtime/database.js +64 -90
- package/runtime/env.js +34 -57
- package/runtime/glm.js +14 -26
- package/runtime/index.js +882 -26
- package/runtime/ssh.js +31 -43
package/runtime/ai.ts
CHANGED
|
@@ -18,7 +18,19 @@ import { z } from "zod";
|
|
|
18
18
|
/**
|
|
19
19
|
* Chat message role (OpenAI-compatible)
|
|
20
20
|
*/
|
|
21
|
-
export const ChatMessageRoleSchema = z.enum(["system", "user", "assistant"]);
|
|
21
|
+
export const ChatMessageRoleSchema = z.enum(["system", "user", "assistant", "tool"]);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Tool call in response (OpenAI/GLM function calling format)
|
|
25
|
+
*/
|
|
26
|
+
export const ToolCallSchema = z.object({
|
|
27
|
+
id: z.string(),
|
|
28
|
+
type: z.literal("function"),
|
|
29
|
+
function: z.object({
|
|
30
|
+
name: z.string(),
|
|
31
|
+
arguments: z.string(), // JSON string of arguments
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
22
34
|
|
|
23
35
|
/**
|
|
24
36
|
* Base chat message (OpenAI-compatible)
|
|
@@ -26,6 +38,10 @@ export const ChatMessageRoleSchema = z.enum(["system", "user", "assistant"]);
|
|
|
26
38
|
export const ChatMessageSchema = z.object({
|
|
27
39
|
role: ChatMessageRoleSchema,
|
|
28
40
|
content: z.string(),
|
|
41
|
+
// For assistant messages with tool calls
|
|
42
|
+
tool_calls: z.array(ToolCallSchema).optional(),
|
|
43
|
+
// For tool response messages
|
|
44
|
+
tool_call_id: z.string().optional(),
|
|
29
45
|
});
|
|
30
46
|
|
|
31
47
|
/**
|
|
@@ -102,9 +118,11 @@ export const RawChoiceSchema = z.object({
|
|
|
102
118
|
index: z.number().int().nonnegative(),
|
|
103
119
|
message: z.object({
|
|
104
120
|
role: z.string(),
|
|
105
|
-
content: z.string(),
|
|
121
|
+
content: z.string().nullable().optional(),
|
|
122
|
+
// Tool calls for function calling
|
|
123
|
+
tool_calls: z.array(ToolCallSchema).optional(),
|
|
106
124
|
}),
|
|
107
|
-
finish_reason: z.string(),
|
|
125
|
+
finish_reason: z.string().nullable(),
|
|
108
126
|
});
|
|
109
127
|
|
|
110
128
|
/**
|
|
@@ -133,9 +151,11 @@ export const ChatCompletionResponseSchema = z.object({
|
|
|
133
151
|
index: z.number().int().nonnegative(),
|
|
134
152
|
message: z.object({
|
|
135
153
|
role: z.string(),
|
|
136
|
-
content: z.string(),
|
|
154
|
+
content: z.string().nullable().optional(),
|
|
155
|
+
// Tool calls for function calling
|
|
156
|
+
tool_calls: z.array(ToolCallSchema).optional(),
|
|
137
157
|
}),
|
|
138
|
-
finish_reason: z.string(),
|
|
158
|
+
finish_reason: z.string().nullable(),
|
|
139
159
|
}),
|
|
140
160
|
)
|
|
141
161
|
.min(1),
|
|
@@ -246,6 +266,7 @@ export const ErrorTypeSchema = z.enum([
|
|
|
246
266
|
// ============================================================================
|
|
247
267
|
|
|
248
268
|
export type ChatMessageRole = z.infer<typeof ChatMessageRoleSchema>;
|
|
269
|
+
export type ToolCall = z.infer<typeof ToolCallSchema>;
|
|
249
270
|
export type ChatMessage = z.infer<typeof ChatMessageSchema>;
|
|
250
271
|
export type TokenUsage = z.infer<typeof TokenUsageSchema>;
|
|
251
272
|
export type BaseAIRequestOptions = z.infer<typeof BaseAIRequestOptionsSchema>;
|
|
@@ -461,6 +482,7 @@ export default {
|
|
|
461
482
|
// Messages
|
|
462
483
|
ChatMessageSchema,
|
|
463
484
|
ChatMessageRoleSchema,
|
|
485
|
+
ToolCallSchema,
|
|
464
486
|
|
|
465
487
|
// Usage
|
|
466
488
|
TokenUsageSchema,
|