veryfront 0.1.284 → 0.1.286
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/esm/deno.d.ts +2 -0
- package/esm/deno.js +3 -1
- package/esm/src/chat/types.d.ts +189 -0
- package/esm/src/chat/types.d.ts.map +1 -0
- package/esm/src/chat/types.js +294 -0
- package/esm/src/sandbox/index.d.ts +1 -1
- package/esm/src/sandbox/index.d.ts.map +1 -1
- package/esm/src/sandbox/index.js +1 -1
- package/esm/src/sandbox/lazy-sandbox.d.ts +3 -0
- package/esm/src/sandbox/lazy-sandbox.d.ts.map +1 -1
- package/esm/src/sandbox/lazy-sandbox.js +22 -1
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +5 -1
- package/src/deno.js +3 -1
- package/src/src/chat/types.ts +602 -0
- package/src/src/sandbox/index.ts +5 -1
- package/src/src/sandbox/lazy-sandbox.ts +25 -1
- package/src/src/utils/version-constant.ts +1 -1
package/esm/deno.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ declare namespace _default {
|
|
|
14
14
|
"./chat": string;
|
|
15
15
|
"./chat/ag-ui": string;
|
|
16
16
|
"./chat/protocol": string;
|
|
17
|
+
"./chat/types": string;
|
|
17
18
|
"./markdown": string;
|
|
18
19
|
"./mdx": string;
|
|
19
20
|
"./agent": string;
|
|
@@ -52,6 +53,7 @@ declare namespace _default {
|
|
|
52
53
|
"veryfront/chat": string;
|
|
53
54
|
"veryfront/chat/ag-ui": string;
|
|
54
55
|
"veryfront/chat/protocol": string;
|
|
56
|
+
"veryfront/chat/types": string;
|
|
55
57
|
"veryfront/markdown": string;
|
|
56
58
|
"veryfront/mdx": string;
|
|
57
59
|
"veryfront/fs": string;
|
package/esm/deno.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.286",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"nodeModulesDir": "auto",
|
|
6
6
|
"workspace": [
|
|
@@ -34,6 +34,7 @@ export default {
|
|
|
34
34
|
"./chat": "./src/chat/index.ts",
|
|
35
35
|
"./chat/ag-ui": "./src/chat/ag-ui.ts",
|
|
36
36
|
"./chat/protocol": "./src/chat/protocol.ts",
|
|
37
|
+
"./chat/types": "./src/chat/types.ts",
|
|
37
38
|
"./markdown": "./src/markdown/index.ts",
|
|
38
39
|
"./mdx": "./src/mdx/index.ts",
|
|
39
40
|
"./agent": "./src/agent/index.ts",
|
|
@@ -72,6 +73,7 @@ export default {
|
|
|
72
73
|
"veryfront/chat": "./src/chat/index.ts",
|
|
73
74
|
"veryfront/chat/ag-ui": "./src/chat/ag-ui.ts",
|
|
74
75
|
"veryfront/chat/protocol": "./src/chat/protocol.ts",
|
|
76
|
+
"veryfront/chat/types": "./src/chat/types.ts",
|
|
75
77
|
"veryfront/markdown": "./src/markdown/index.ts",
|
|
76
78
|
"veryfront/mdx": "./src/mdx/index.ts",
|
|
77
79
|
"veryfront/fs": "./src/fs/index.ts",
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import type { ChatMessageMetadata, ChatMessageMetadataUsage, ChatUiMessageChunk, ChildRunAudit, ChildRunAuditToolCall, ChildRunAuditToolResult } from "./protocol.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export declare const textFileExtensions: readonly [".txt", ".md", ".json", ".xml", ".html", ".css", ".js", ".mjs", ".cjs", ".ts", ".mts", ".cts", ".jsx", ".tsx", ".py", ".java", ".cpp", ".c", ".h", ".php", ".rb", ".go", ".rs", ".swift", ".kt", ".scala", ".sh", ".yaml", ".yml", ".toml", ".ini", ".cfg", ".conf", ".sql", ".csv"];
|
|
4
|
+
export declare const imageFileTypes: readonly ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/webp", "image/bmp", "image/tiff"];
|
|
5
|
+
export type ChatUiMessageRole = "system" | "user" | "assistant";
|
|
6
|
+
export type ChatTextUiPart = {
|
|
7
|
+
type: "text";
|
|
8
|
+
text: string;
|
|
9
|
+
};
|
|
10
|
+
export type ChatReasoningUiPart = {
|
|
11
|
+
type: "reasoning";
|
|
12
|
+
text: string;
|
|
13
|
+
};
|
|
14
|
+
export type ChatStepStartUiPart = {
|
|
15
|
+
type: "step-start";
|
|
16
|
+
};
|
|
17
|
+
export type ChatSourceUrlUiPart = {
|
|
18
|
+
type: "source-url";
|
|
19
|
+
sourceId: string;
|
|
20
|
+
url: string;
|
|
21
|
+
title?: string;
|
|
22
|
+
};
|
|
23
|
+
export type ChatSourceDocumentUiPart = {
|
|
24
|
+
type: "source-document";
|
|
25
|
+
sourceId: string;
|
|
26
|
+
title: string;
|
|
27
|
+
mediaType?: string;
|
|
28
|
+
filename?: string;
|
|
29
|
+
};
|
|
30
|
+
export type ChatFileUiPart = {
|
|
31
|
+
type: "file";
|
|
32
|
+
mediaType: string;
|
|
33
|
+
url: string;
|
|
34
|
+
filename?: string;
|
|
35
|
+
};
|
|
36
|
+
export type FileUIPartWithUpload = ChatFileUiPart & {
|
|
37
|
+
uploadId?: string;
|
|
38
|
+
uploadPath?: string;
|
|
39
|
+
};
|
|
40
|
+
export type ChatToolPartState = "pending" | "input-streaming" | "input-available" | "approval-requested" | "approval-responded" | "output-available" | "output-error" | "output-denied" | "error" | "completed";
|
|
41
|
+
type ChatToolPartBase = {
|
|
42
|
+
toolCallId: string;
|
|
43
|
+
input: unknown;
|
|
44
|
+
state: ChatToolPartState;
|
|
45
|
+
title?: string;
|
|
46
|
+
providerExecuted?: boolean;
|
|
47
|
+
callProviderMetadata?: Record<string, unknown>;
|
|
48
|
+
output?: unknown;
|
|
49
|
+
errorText?: string;
|
|
50
|
+
approval?: {
|
|
51
|
+
id: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export type ChatDynamicToolUiPart = ChatToolPartBase & {
|
|
55
|
+
type: "dynamic-tool";
|
|
56
|
+
toolName: string;
|
|
57
|
+
};
|
|
58
|
+
export type ChatNamedToolUiPart = ChatToolPartBase & {
|
|
59
|
+
type: `tool-${string}` | "tool_call";
|
|
60
|
+
toolName?: string;
|
|
61
|
+
};
|
|
62
|
+
export type ChatDataUiPart = {
|
|
63
|
+
type: `data-${string}`;
|
|
64
|
+
data: unknown;
|
|
65
|
+
};
|
|
66
|
+
export type ChatUiMessagePart = ChatTextUiPart | ChatReasoningUiPart | ChatStepStartUiPart | ChatSourceUrlUiPart | ChatSourceDocumentUiPart | FileUIPartWithUpload | ChatDynamicToolUiPart | ChatNamedToolUiPart | ChatDataUiPart;
|
|
67
|
+
export interface ChatUiMessage<TMessageMetadata = ChatMessageMetadata> {
|
|
68
|
+
id: string;
|
|
69
|
+
role: ChatUiMessageRole;
|
|
70
|
+
parts: ChatUiMessagePart[];
|
|
71
|
+
metadata?: TMessageMetadata;
|
|
72
|
+
}
|
|
73
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
74
|
+
[key: string]: JsonValue;
|
|
75
|
+
};
|
|
76
|
+
export type ChatModelTextPart = {
|
|
77
|
+
type: "text";
|
|
78
|
+
text: string;
|
|
79
|
+
};
|
|
80
|
+
export type ChatModelReasoningPart = {
|
|
81
|
+
type: "reasoning";
|
|
82
|
+
text: string;
|
|
83
|
+
};
|
|
84
|
+
export type ChatModelFilePart = {
|
|
85
|
+
type: "file" | "image";
|
|
86
|
+
mediaType: string;
|
|
87
|
+
data?: string;
|
|
88
|
+
url?: string;
|
|
89
|
+
filename?: string;
|
|
90
|
+
uploadId?: string;
|
|
91
|
+
uploadPath?: string;
|
|
92
|
+
};
|
|
93
|
+
export type ChatToolCallPart = {
|
|
94
|
+
type: "tool-call";
|
|
95
|
+
toolCallId: string;
|
|
96
|
+
toolName: string;
|
|
97
|
+
input: Record<string, unknown>;
|
|
98
|
+
providerExecuted?: boolean;
|
|
99
|
+
};
|
|
100
|
+
export type ChatToolResultOutput = {
|
|
101
|
+
type: "json";
|
|
102
|
+
value: JsonValue;
|
|
103
|
+
} | {
|
|
104
|
+
type: "text";
|
|
105
|
+
value: string;
|
|
106
|
+
} | {
|
|
107
|
+
type: "error-text";
|
|
108
|
+
value: string;
|
|
109
|
+
};
|
|
110
|
+
export type ChatToolResultPart = {
|
|
111
|
+
type: "tool-result";
|
|
112
|
+
toolCallId: string;
|
|
113
|
+
toolName: string;
|
|
114
|
+
output: ChatToolResultOutput;
|
|
115
|
+
providerOptions?: unknown;
|
|
116
|
+
};
|
|
117
|
+
export type ChatUserContentPart = ChatModelTextPart | ChatModelFilePart;
|
|
118
|
+
export type ChatAssistantContentPart = ChatModelTextPart | ChatModelReasoningPart | ChatModelFilePart | ChatToolCallPart | ChatToolResultPart;
|
|
119
|
+
export type ChatSystemMessage = {
|
|
120
|
+
role: "system";
|
|
121
|
+
content: string;
|
|
122
|
+
providerOptions?: Record<string, unknown>;
|
|
123
|
+
};
|
|
124
|
+
export type ChatUserMessage = {
|
|
125
|
+
role: "user";
|
|
126
|
+
content: string | ChatUserContentPart[];
|
|
127
|
+
};
|
|
128
|
+
export type ChatAssistantMessage = {
|
|
129
|
+
role: "assistant";
|
|
130
|
+
content: string | ChatAssistantContentPart[];
|
|
131
|
+
};
|
|
132
|
+
export type ChatToolMessage = {
|
|
133
|
+
role: "tool";
|
|
134
|
+
content: ChatToolResultPart[];
|
|
135
|
+
};
|
|
136
|
+
export type ChatModelMessage = ChatSystemMessage | ChatUserMessage | ChatAssistantMessage | ChatToolMessage;
|
|
137
|
+
export interface DurableRootRunDescriptor {
|
|
138
|
+
runId: string;
|
|
139
|
+
messageId: string;
|
|
140
|
+
latestEventId?: number;
|
|
141
|
+
latestExternalEventSequence?: number;
|
|
142
|
+
parentConversationId?: string;
|
|
143
|
+
parentRunId?: string;
|
|
144
|
+
spawnedFromToolCallId?: string;
|
|
145
|
+
}
|
|
146
|
+
export interface ChatRuntimeOverrides {
|
|
147
|
+
allowedTools?: string[];
|
|
148
|
+
thinking?: false | number;
|
|
149
|
+
maxSteps?: number;
|
|
150
|
+
}
|
|
151
|
+
export interface ProjectFile {
|
|
152
|
+
path: string;
|
|
153
|
+
content: string;
|
|
154
|
+
}
|
|
155
|
+
export interface ProjectFileListItem {
|
|
156
|
+
id: string;
|
|
157
|
+
path: string;
|
|
158
|
+
type: string;
|
|
159
|
+
size: number;
|
|
160
|
+
updated_at: string;
|
|
161
|
+
}
|
|
162
|
+
export interface UploadedFileReference {
|
|
163
|
+
name: string;
|
|
164
|
+
mediaType: string;
|
|
165
|
+
uploadId?: string;
|
|
166
|
+
path?: string;
|
|
167
|
+
url?: string;
|
|
168
|
+
size?: number;
|
|
169
|
+
}
|
|
170
|
+
export declare const chatRequestContextSchema: z.ZodObject<{
|
|
171
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
172
|
+
projectId: z.ZodNullable<z.ZodString>;
|
|
173
|
+
branchId: z.ZodNullable<z.ZodString>;
|
|
174
|
+
environmentContext: z.ZodOptional<z.ZodString>;
|
|
175
|
+
}, z.core.$strict>;
|
|
176
|
+
export type ChatRequestContext = z.infer<typeof chatRequestContextSchema>;
|
|
177
|
+
export declare const messageMetadataSchema: z.ZodType<ChatMessageMetadata>;
|
|
178
|
+
export declare const chatUiMessageRoleSchema: z.ZodType<ChatUiMessageRole>;
|
|
179
|
+
export declare const chatToolPartStateSchema: z.ZodType<ChatToolPartState>;
|
|
180
|
+
export declare const chatUiMessagePartSchema: z.ZodType<ChatUiMessagePart>;
|
|
181
|
+
export declare const chatUiMessageSchema: z.ZodType<ChatUiMessage>;
|
|
182
|
+
export declare const chatUiMessagesSchema: z.ZodArray<z.ZodType<ChatUiMessage<ChatMessageMetadata>, unknown, z.core.$ZodTypeInternals<ChatUiMessage<ChatMessageMetadata>, unknown>>>;
|
|
183
|
+
export declare function isImageFile(type: string | undefined): boolean;
|
|
184
|
+
export declare function isValidImageFile(type: string): boolean;
|
|
185
|
+
export declare function isTextPreviewFile(name: string | undefined, type: string | undefined): boolean;
|
|
186
|
+
export declare function normalizeInlineAttachmentMediaType(filename: string | undefined, mediaType: string | undefined): string;
|
|
187
|
+
export declare function buildDataFileAnnotation(refs: UploadedFileReference[]): string;
|
|
188
|
+
export type { ChatMessageMetadata, ChatMessageMetadata as MessageMetadata, ChatMessageMetadataUsage, ChatUiMessageChunk, ChildRunAudit, ChildRunAuditToolCall, ChildRunAuditToolResult, };
|
|
189
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/src/chat/types.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,mBAAmB,EACnB,wBAAwB,EACxB,kBAAkB,EAClB,aAAa,EACb,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuCxB,eAAO,MAAM,kBAAkB,gSAA0D,CAAC;AAE1F,eAAO,MAAM,cAAc,yGAQjB,CAAC;AAMX,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAEhE,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,iBA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
|
10
|
+
".mjs",
|
|
11
|
+
".cjs",
|
|
12
|
+
".ts",
|
|
13
|
+
".mts",
|
|
14
|
+
".cts",
|
|
15
|
+
".jsx",
|
|
16
|
+
".tsx",
|
|
17
|
+
".py",
|
|
18
|
+
".java",
|
|
19
|
+
".cpp",
|
|
20
|
+
".c",
|
|
21
|
+
".h",
|
|
22
|
+
".php",
|
|
23
|
+
".rb",
|
|
24
|
+
".go",
|
|
25
|
+
".rs",
|
|
26
|
+
".swift",
|
|
27
|
+
".kt",
|
|
28
|
+
".scala",
|
|
29
|
+
".sh",
|
|
30
|
+
".yaml",
|
|
31
|
+
".yml",
|
|
32
|
+
".toml",
|
|
33
|
+
".ini",
|
|
34
|
+
".cfg",
|
|
35
|
+
".conf",
|
|
36
|
+
".sql",
|
|
37
|
+
];
|
|
38
|
+
export const textFileExtensions = [...NATIVE_TEXT_ATTACHMENT_EXTENSIONS, ".csv"];
|
|
39
|
+
export const imageFileTypes = [
|
|
40
|
+
"image/png",
|
|
41
|
+
"image/jpeg",
|
|
42
|
+
"image/jpg",
|
|
43
|
+
"image/gif",
|
|
44
|
+
"image/webp",
|
|
45
|
+
"image/bmp",
|
|
46
|
+
"image/tiff",
|
|
47
|
+
];
|
|
48
|
+
const INLINE_TEXT_MEDIA_TYPE = "text/plain";
|
|
49
|
+
const INLINE_BINARY_MEDIA_TYPE = "application/octet-stream";
|
|
50
|
+
const INLINE_PDF_MEDIA_TYPE = "application/pdf";
|
|
51
|
+
export const chatRequestContextSchema = z
|
|
52
|
+
.object({
|
|
53
|
+
conversationId: z.string().optional(),
|
|
54
|
+
projectId: z.string().nullable(),
|
|
55
|
+
branchId: z.string().nullable(),
|
|
56
|
+
environmentContext: z.string().optional(),
|
|
57
|
+
})
|
|
58
|
+
.strict();
|
|
59
|
+
const childRunAuditStatusSchema = z.enum([
|
|
60
|
+
"completed",
|
|
61
|
+
"failed",
|
|
62
|
+
"cancelled",
|
|
63
|
+
"stopped",
|
|
64
|
+
]);
|
|
65
|
+
const childRunAuditToolCallSchema = z
|
|
66
|
+
.object({
|
|
67
|
+
toolName: z.string(),
|
|
68
|
+
toolCallId: z.string(),
|
|
69
|
+
input: z.unknown().optional(),
|
|
70
|
+
})
|
|
71
|
+
.strict();
|
|
72
|
+
const childRunAuditToolResultSchema = z
|
|
73
|
+
.object({
|
|
74
|
+
toolName: z.string(),
|
|
75
|
+
toolCallId: z.string(),
|
|
76
|
+
input: z.unknown(),
|
|
77
|
+
output: z.unknown(),
|
|
78
|
+
})
|
|
79
|
+
.strict();
|
|
80
|
+
const childRunAuditSchema = z
|
|
81
|
+
.object({
|
|
82
|
+
status: childRunAuditStatusSchema,
|
|
83
|
+
description: z.string().optional(),
|
|
84
|
+
steps: z.number().optional(),
|
|
85
|
+
durationMs: z.number().optional(),
|
|
86
|
+
toolCalls: z.array(childRunAuditToolCallSchema).optional(),
|
|
87
|
+
toolResults: z.array(childRunAuditToolResultSchema).optional(),
|
|
88
|
+
terminalErrorCode: z.string().nullable().optional(),
|
|
89
|
+
terminalErrorMessage: z.string().nullable().optional(),
|
|
90
|
+
})
|
|
91
|
+
.strict();
|
|
92
|
+
const messageMetadataUsageSchema = z
|
|
93
|
+
.object({
|
|
94
|
+
inputTokens: z.number().optional(),
|
|
95
|
+
outputTokens: z.number().optional(),
|
|
96
|
+
reasoningTokens: z.number().optional(),
|
|
97
|
+
cachedInputTokens: z.number().optional(),
|
|
98
|
+
})
|
|
99
|
+
.strict();
|
|
100
|
+
export const messageMetadataSchema = z
|
|
101
|
+
.object({
|
|
102
|
+
createdAt: z.string().optional(),
|
|
103
|
+
isStopped: z.boolean().optional(),
|
|
104
|
+
isCompleted: z.boolean().optional(),
|
|
105
|
+
completedAt: z.string().optional(),
|
|
106
|
+
agentId: z.string().optional(),
|
|
107
|
+
agentName: z.string().optional(),
|
|
108
|
+
conversationId: z.string().optional(),
|
|
109
|
+
modelId: z.string().optional(),
|
|
110
|
+
runId: z.string().optional(),
|
|
111
|
+
streamingMessageId: z.string().optional(),
|
|
112
|
+
childRunAudit: childRunAuditSchema.optional(),
|
|
113
|
+
usage: messageMetadataUsageSchema.optional(),
|
|
114
|
+
})
|
|
115
|
+
.strict();
|
|
116
|
+
const nonEmptyStringSchema = z.string().min(1);
|
|
117
|
+
export const chatUiMessageRoleSchema = z.enum([
|
|
118
|
+
"system",
|
|
119
|
+
"user",
|
|
120
|
+
"assistant",
|
|
121
|
+
]);
|
|
122
|
+
export const chatToolPartStateSchema = z.enum([
|
|
123
|
+
"pending",
|
|
124
|
+
"input-streaming",
|
|
125
|
+
"input-available",
|
|
126
|
+
"approval-requested",
|
|
127
|
+
"approval-responded",
|
|
128
|
+
"output-available",
|
|
129
|
+
"output-error",
|
|
130
|
+
"output-denied",
|
|
131
|
+
"error",
|
|
132
|
+
"completed",
|
|
133
|
+
]);
|
|
134
|
+
const toolApprovalSchema = z
|
|
135
|
+
.object({
|
|
136
|
+
id: nonEmptyStringSchema,
|
|
137
|
+
})
|
|
138
|
+
.strict();
|
|
139
|
+
const toolPartBaseSchema = z
|
|
140
|
+
.object({
|
|
141
|
+
toolCallId: nonEmptyStringSchema,
|
|
142
|
+
input: z.unknown(),
|
|
143
|
+
state: chatToolPartStateSchema,
|
|
144
|
+
title: nonEmptyStringSchema.optional(),
|
|
145
|
+
providerExecuted: z.boolean().optional(),
|
|
146
|
+
callProviderMetadata: z.record(z.string(), z.unknown()).optional(),
|
|
147
|
+
output: z.unknown().optional(),
|
|
148
|
+
errorText: nonEmptyStringSchema.optional(),
|
|
149
|
+
approval: toolApprovalSchema.optional(),
|
|
150
|
+
})
|
|
151
|
+
.strip();
|
|
152
|
+
const chatTextUiPartSchema = z
|
|
153
|
+
.object({
|
|
154
|
+
type: z.literal("text"),
|
|
155
|
+
text: z.string(),
|
|
156
|
+
})
|
|
157
|
+
.strip();
|
|
158
|
+
const chatReasoningUiPartSchema = z
|
|
159
|
+
.object({
|
|
160
|
+
type: z.literal("reasoning"),
|
|
161
|
+
text: z.string(),
|
|
162
|
+
})
|
|
163
|
+
.strip();
|
|
164
|
+
const chatStepStartUiPartSchema = z
|
|
165
|
+
.object({
|
|
166
|
+
type: z.literal("step-start"),
|
|
167
|
+
})
|
|
168
|
+
.strip();
|
|
169
|
+
const chatSourceUrlUiPartSchema = z
|
|
170
|
+
.object({
|
|
171
|
+
type: z.literal("source-url"),
|
|
172
|
+
sourceId: nonEmptyStringSchema,
|
|
173
|
+
url: nonEmptyStringSchema,
|
|
174
|
+
title: z.string().optional(),
|
|
175
|
+
})
|
|
176
|
+
.strip();
|
|
177
|
+
const chatSourceDocumentUiPartSchema = z
|
|
178
|
+
.object({
|
|
179
|
+
type: z.literal("source-document"),
|
|
180
|
+
sourceId: nonEmptyStringSchema,
|
|
181
|
+
title: nonEmptyStringSchema,
|
|
182
|
+
mediaType: nonEmptyStringSchema.optional(),
|
|
183
|
+
filename: nonEmptyStringSchema.optional(),
|
|
184
|
+
})
|
|
185
|
+
.strip();
|
|
186
|
+
const chatFileUiPartBaseSchema = z
|
|
187
|
+
.object({
|
|
188
|
+
type: z.literal("file"),
|
|
189
|
+
mediaType: nonEmptyStringSchema,
|
|
190
|
+
url: nonEmptyStringSchema,
|
|
191
|
+
filename: nonEmptyStringSchema.optional(),
|
|
192
|
+
})
|
|
193
|
+
.strip();
|
|
194
|
+
const fileUiPartWithUploadSchema = chatFileUiPartBaseSchema.extend({
|
|
195
|
+
uploadId: nonEmptyStringSchema.optional(),
|
|
196
|
+
uploadPath: nonEmptyStringSchema.optional(),
|
|
197
|
+
});
|
|
198
|
+
const chatDynamicToolUiPartSchema = toolPartBaseSchema.extend({
|
|
199
|
+
type: z.literal("dynamic-tool"),
|
|
200
|
+
toolName: nonEmptyStringSchema,
|
|
201
|
+
});
|
|
202
|
+
const chatNamedToolTypeSchema = z.custom((value) => typeof value === "string" && (value === "tool_call" || /^tool-.+$/u.test(value)));
|
|
203
|
+
const chatNamedToolUiPartSchema = toolPartBaseSchema.extend({
|
|
204
|
+
type: chatNamedToolTypeSchema,
|
|
205
|
+
toolName: nonEmptyStringSchema.optional(),
|
|
206
|
+
});
|
|
207
|
+
const chatDataUiPartTypeSchema = z.custom((value) => typeof value === "string" && /^data-.+$/u.test(value));
|
|
208
|
+
const chatDataUiPartSchema = z
|
|
209
|
+
.object({
|
|
210
|
+
type: chatDataUiPartTypeSchema,
|
|
211
|
+
data: z.unknown(),
|
|
212
|
+
})
|
|
213
|
+
.strip();
|
|
214
|
+
export const chatUiMessagePartSchema = z.union([
|
|
215
|
+
chatTextUiPartSchema,
|
|
216
|
+
chatReasoningUiPartSchema,
|
|
217
|
+
chatStepStartUiPartSchema,
|
|
218
|
+
chatSourceUrlUiPartSchema,
|
|
219
|
+
chatSourceDocumentUiPartSchema,
|
|
220
|
+
fileUiPartWithUploadSchema,
|
|
221
|
+
chatDynamicToolUiPartSchema,
|
|
222
|
+
chatNamedToolUiPartSchema,
|
|
223
|
+
chatDataUiPartSchema,
|
|
224
|
+
]);
|
|
225
|
+
export const chatUiMessageSchema = z
|
|
226
|
+
.object({
|
|
227
|
+
id: nonEmptyStringSchema,
|
|
228
|
+
role: chatUiMessageRoleSchema,
|
|
229
|
+
parts: z.array(chatUiMessagePartSchema),
|
|
230
|
+
metadata: messageMetadataSchema.optional(),
|
|
231
|
+
})
|
|
232
|
+
.strip();
|
|
233
|
+
export const chatUiMessagesSchema = z.array(chatUiMessageSchema);
|
|
234
|
+
function hasExtension(filename, extensions) {
|
|
235
|
+
const normalizedFilename = filename?.toLowerCase() ?? "";
|
|
236
|
+
return extensions.some((extension) => normalizedFilename.endsWith(extension));
|
|
237
|
+
}
|
|
238
|
+
function isNativeTextAttachmentFile(filename) {
|
|
239
|
+
return hasExtension(filename, NATIVE_TEXT_ATTACHMENT_EXTENSIONS);
|
|
240
|
+
}
|
|
241
|
+
function preferNativeTextAttachmentMediaType(filename, fallbackMediaType) {
|
|
242
|
+
return isNativeTextAttachmentFile(filename) ? INLINE_TEXT_MEDIA_TYPE : fallbackMediaType;
|
|
243
|
+
}
|
|
244
|
+
function isTextMediaType(type) {
|
|
245
|
+
return type?.startsWith("text/") ?? false;
|
|
246
|
+
}
|
|
247
|
+
function isInlinePreviewMediaType(mediaType) {
|
|
248
|
+
return isTextMediaType(mediaType) || isImageFile(mediaType) ||
|
|
249
|
+
mediaType === INLINE_PDF_MEDIA_TYPE;
|
|
250
|
+
}
|
|
251
|
+
export function isImageFile(type) {
|
|
252
|
+
return type?.startsWith("image/") ?? false;
|
|
253
|
+
}
|
|
254
|
+
export function isValidImageFile(type) {
|
|
255
|
+
if (type.length === 0) {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
return imageFileTypes.some((imageFileType) => imageFileType === type);
|
|
259
|
+
}
|
|
260
|
+
export function isTextPreviewFile(name, type) {
|
|
261
|
+
return isTextMediaType(type) || hasExtension(name, textFileExtensions);
|
|
262
|
+
}
|
|
263
|
+
export function normalizeInlineAttachmentMediaType(filename, mediaType) {
|
|
264
|
+
if (!mediaType) {
|
|
265
|
+
return preferNativeTextAttachmentMediaType(filename, INLINE_BINARY_MEDIA_TYPE);
|
|
266
|
+
}
|
|
267
|
+
if (isInlinePreviewMediaType(mediaType)) {
|
|
268
|
+
return mediaType;
|
|
269
|
+
}
|
|
270
|
+
return preferNativeTextAttachmentMediaType(filename, mediaType);
|
|
271
|
+
}
|
|
272
|
+
function escapeXmlAttr(value) {
|
|
273
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
274
|
+
}
|
|
275
|
+
export function buildDataFileAnnotation(refs) {
|
|
276
|
+
if (refs.length === 0)
|
|
277
|
+
return "";
|
|
278
|
+
const fileTags = refs
|
|
279
|
+
.map((ref) => {
|
|
280
|
+
const attrs = [`name="${escapeXmlAttr(ref.name)}"`];
|
|
281
|
+
if (ref.uploadId)
|
|
282
|
+
attrs.push(`upload_id="${escapeXmlAttr(ref.uploadId)}"`);
|
|
283
|
+
if (ref.path)
|
|
284
|
+
attrs.push(`path="${escapeXmlAttr(ref.path)}"`);
|
|
285
|
+
if (typeof ref.size === "number")
|
|
286
|
+
attrs.push(`size="${ref.size}"`);
|
|
287
|
+
if (ref.url)
|
|
288
|
+
attrs.push(`url="${escapeXmlAttr(ref.url)}"`);
|
|
289
|
+
attrs.push(`type="${escapeXmlAttr(ref.mediaType)}"`);
|
|
290
|
+
return `<file ${attrs.join(" ")} />`;
|
|
291
|
+
})
|
|
292
|
+
.join("\n");
|
|
293
|
+
return `\n\n<uploaded_files>\n${fileTags}\n</uploaded_files>`;
|
|
294
|
+
}
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import "../../_dnt.polyfills.js";
|
|
20
20
|
export { type CommandJob, type CommandJobHeartbeatStatus, type CommandJobOutput, type CommandJobStatus, type ExecOptions, type ExecResult, type ExecStreamEvent, Sandbox, type SandboxAttachment, type SandboxListOptions, type SandboxListResult, type SandboxOptions, type SandboxSession, } from "./sandbox.js";
|
|
21
|
-
export { LazySandbox, type LazySandboxOptions } from "./lazy-sandbox.js";
|
|
21
|
+
export { LazySandbox, type LazySandboxOptions, resolveDefaultSandboxRuntimeEndpoint, } from "./lazy-sandbox.js";
|
|
22
22
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,yBAAyB,CAAC;AAGjC,OAAO,EACL,KAAK,UAAU,EACf,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,OAAO,EACP,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,yBAAyB,CAAC;AAGjC,OAAO,EACL,KAAK,UAAU,EACf,KAAK,yBAAyB,EAC9B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,OAAO,EACP,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,WAAW,EACX,KAAK,kBAAkB,EACvB,oCAAoC,GACrC,MAAM,mBAAmB,CAAC"}
|
package/esm/src/sandbox/index.js
CHANGED
|
@@ -14,6 +14,9 @@ export interface LazySandboxOptions extends SandboxOptions {
|
|
|
14
14
|
sessionId: string;
|
|
15
15
|
}) => string;
|
|
16
16
|
}
|
|
17
|
+
export declare function resolveDefaultSandboxRuntimeEndpoint(input: {
|
|
18
|
+
endpoint: string;
|
|
19
|
+
}): string;
|
|
17
20
|
/** Lazily provisions sandbox sessions and keeps them alive while in use. */
|
|
18
21
|
export declare class LazySandbox {
|
|
19
22
|
private readonly apiUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-sandbox.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/lazy-sandbox.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lazy-sandbox.d.ts","sourceRoot":"","sources":["../../../src/src/sandbox/lazy-sandbox.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,gBAAgB,EAErB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,eAAe,EAGpB,KAAK,cAAc,EACpB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,YA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AAI,EAAE,IAAI,MAAM,GAAG,IAAI,CAEtB;IAED,IAAI,GAAG,IAAI,MAAM,GAAG,IAAI,CAEvB;IAED,IAAI,QAAQ,IAAI,OAAO,CAEtB;YAEa,gBAAgB;YAiChB,oBAAoB;YAQpB,mBAAmB;YA4BnB,YAAY;IAc1B,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,iBAAiB;YAMX,aAAa;IAO3B,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,kBAAkB;YAKZ,yBAAyB;IAUvC,OAAO,CAAC,uBAAuB;YAgBjB,SAAS;YAkCT,cAAc;YAId,YAAY;IAI1B,OAAO,CAAC,qBAAqB;YAIf,gCAAgC;IAQ9C,OAAO,CAAC,sBAAsB;IAO9B,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,WAAW;CAMpB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as dntShim from "../../_dnt.shims.js";
|
|
2
2
|
import { REQUEST_ERROR } from "../errors/index.js";
|
|
3
|
+
import { getHostEnv } from "../platform/compat/process.js";
|
|
3
4
|
import { resolveSandboxApiUrl, resolveSandboxAuthToken, } from "./sandbox.js";
|
|
4
5
|
const DEFAULT_STARTUP_TIMEOUT_MS = 180_000;
|
|
5
6
|
const DEFAULT_POLL_INTERVAL_MS = 2_000;
|
|
@@ -15,6 +16,25 @@ const REPROVISIONABLE_EXEC_START_ERROR_CODES = new Set([
|
|
|
15
16
|
"ENOTFOUND",
|
|
16
17
|
"EHOSTUNREACH",
|
|
17
18
|
]);
|
|
19
|
+
const VERYFRONT_SANDBOX_PUBLIC_HOST_PATTERN = /^([a-z0-9-]+)\.sandbox\.veryfront\.[a-z0-9.-]+$/i;
|
|
20
|
+
export function resolveDefaultSandboxRuntimeEndpoint(input) {
|
|
21
|
+
if (!getHostEnv("KUBERNETES_SERVICE_HOST")) {
|
|
22
|
+
return input.endpoint;
|
|
23
|
+
}
|
|
24
|
+
let hostname;
|
|
25
|
+
try {
|
|
26
|
+
hostname = new URL(input.endpoint).hostname;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return input.endpoint;
|
|
30
|
+
}
|
|
31
|
+
const match = hostname.match(VERYFRONT_SANDBOX_PUBLIC_HOST_PATTERN);
|
|
32
|
+
const shortId = match?.[1];
|
|
33
|
+
if (!shortId) {
|
|
34
|
+
return input.endpoint;
|
|
35
|
+
}
|
|
36
|
+
return `http://sandbox.veryfront-sandbox-${shortId}.svc.cluster.local`;
|
|
37
|
+
}
|
|
18
38
|
/** Lazily provisions sandbox sessions and keeps them alive while in use. */
|
|
19
39
|
export class LazySandbox {
|
|
20
40
|
apiUrl;
|
|
@@ -494,7 +514,8 @@ export class LazySandbox {
|
|
|
494
514
|
resolveRuntimeEndpoint() {
|
|
495
515
|
const endpoint = this.requireEndpoint();
|
|
496
516
|
const sessionId = this.requireSessionId();
|
|
497
|
-
return this.resolveRuntimeEndpointOption?.({ endpoint, sessionId }) ??
|
|
517
|
+
return this.resolveRuntimeEndpointOption?.({ endpoint, sessionId }) ??
|
|
518
|
+
resolveDefaultSandboxRuntimeEndpoint({ endpoint });
|
|
498
519
|
}
|
|
499
520
|
requireSessionId() {
|
|
500
521
|
if (!this.sessionId) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.286";
|
|
2
2
|
//# sourceMappingURL=version-constant.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.286",
|
|
4
4
|
"description": "The simplest way to build AI-powered apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -57,6 +57,10 @@
|
|
|
57
57
|
"import": "./esm/src/chat/protocol.js",
|
|
58
58
|
"types": "./esm/src/chat/protocol.d.ts"
|
|
59
59
|
},
|
|
60
|
+
"./chat/types": {
|
|
61
|
+
"import": "./esm/src/chat/types.js",
|
|
62
|
+
"types": "./esm/src/chat/types.d.ts"
|
|
63
|
+
},
|
|
60
64
|
"./markdown": {
|
|
61
65
|
"import": "./esm/src/markdown/index.js",
|
|
62
66
|
"types": "./esm/src/markdown/index.d.ts"
|
package/src/deno.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.286",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"nodeModulesDir": "auto",
|
|
6
6
|
"workspace": [
|
|
@@ -34,6 +34,7 @@ export default {
|
|
|
34
34
|
"./chat": "./src/chat/index.ts",
|
|
35
35
|
"./chat/ag-ui": "./src/chat/ag-ui.ts",
|
|
36
36
|
"./chat/protocol": "./src/chat/protocol.ts",
|
|
37
|
+
"./chat/types": "./src/chat/types.ts",
|
|
37
38
|
"./markdown": "./src/markdown/index.ts",
|
|
38
39
|
"./mdx": "./src/mdx/index.ts",
|
|
39
40
|
"./agent": "./src/agent/index.ts",
|
|
@@ -72,6 +73,7 @@ export default {
|
|
|
72
73
|
"veryfront/chat": "./src/chat/index.ts",
|
|
73
74
|
"veryfront/chat/ag-ui": "./src/chat/ag-ui.ts",
|
|
74
75
|
"veryfront/chat/protocol": "./src/chat/protocol.ts",
|
|
76
|
+
"veryfront/chat/types": "./src/chat/types.ts",
|
|
75
77
|
"veryfront/markdown": "./src/markdown/index.ts",
|
|
76
78
|
"veryfront/mdx": "./src/mdx/index.ts",
|
|
77
79
|
"veryfront/fs": "./src/fs/index.ts",
|
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
import "../../_dnt.polyfills.js";
|
|
2
|
+
import type {
|
|
3
|
+
ChatMessageMetadata,
|
|
4
|
+
ChatMessageMetadataUsage,
|
|
5
|
+
ChatUiMessageChunk,
|
|
6
|
+
ChildRunAudit,
|
|
7
|
+
ChildRunAuditToolCall,
|
|
8
|
+
ChildRunAuditToolResult,
|
|
9
|
+
} from "./protocol.js";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
|
|
12
|
+
const NATIVE_TEXT_ATTACHMENT_EXTENSIONS = [
|
|
13
|
+
".txt",
|
|
14
|
+
".md",
|
|
15
|
+
".json",
|
|
16
|
+
".xml",
|
|
17
|
+
".html",
|
|
18
|
+
".css",
|
|
19
|
+
".js",
|
|
20
|
+
".mjs",
|
|
21
|
+
".cjs",
|
|
22
|
+
".ts",
|
|
23
|
+
".mts",
|
|
24
|
+
".cts",
|
|
25
|
+
".jsx",
|
|
26
|
+
".tsx",
|
|
27
|
+
".py",
|
|
28
|
+
".java",
|
|
29
|
+
".cpp",
|
|
30
|
+
".c",
|
|
31
|
+
".h",
|
|
32
|
+
".php",
|
|
33
|
+
".rb",
|
|
34
|
+
".go",
|
|
35
|
+
".rs",
|
|
36
|
+
".swift",
|
|
37
|
+
".kt",
|
|
38
|
+
".scala",
|
|
39
|
+
".sh",
|
|
40
|
+
".yaml",
|
|
41
|
+
".yml",
|
|
42
|
+
".toml",
|
|
43
|
+
".ini",
|
|
44
|
+
".cfg",
|
|
45
|
+
".conf",
|
|
46
|
+
".sql",
|
|
47
|
+
] as const;
|
|
48
|
+
|
|
49
|
+
export const textFileExtensions = [...NATIVE_TEXT_ATTACHMENT_EXTENSIONS, ".csv"] as const;
|
|
50
|
+
|
|
51
|
+
export const imageFileTypes = [
|
|
52
|
+
"image/png",
|
|
53
|
+
"image/jpeg",
|
|
54
|
+
"image/jpg",
|
|
55
|
+
"image/gif",
|
|
56
|
+
"image/webp",
|
|
57
|
+
"image/bmp",
|
|
58
|
+
"image/tiff",
|
|
59
|
+
] as const;
|
|
60
|
+
|
|
61
|
+
const INLINE_TEXT_MEDIA_TYPE = "text/plain";
|
|
62
|
+
const INLINE_BINARY_MEDIA_TYPE = "application/octet-stream";
|
|
63
|
+
const INLINE_PDF_MEDIA_TYPE = "application/pdf";
|
|
64
|
+
|
|
65
|
+
export type ChatUiMessageRole = "system" | "user" | "assistant";
|
|
66
|
+
|
|
67
|
+
export type ChatTextUiPart = {
|
|
68
|
+
type: "text";
|
|
69
|
+
text: string;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type ChatReasoningUiPart = {
|
|
73
|
+
type: "reasoning";
|
|
74
|
+
text: string;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export type ChatStepStartUiPart = {
|
|
78
|
+
type: "step-start";
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type ChatSourceUrlUiPart = {
|
|
82
|
+
type: "source-url";
|
|
83
|
+
sourceId: string;
|
|
84
|
+
url: string;
|
|
85
|
+
title?: string;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type ChatSourceDocumentUiPart = {
|
|
89
|
+
type: "source-document";
|
|
90
|
+
sourceId: string;
|
|
91
|
+
title: string;
|
|
92
|
+
mediaType?: string;
|
|
93
|
+
filename?: string;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export type ChatFileUiPart = {
|
|
97
|
+
type: "file";
|
|
98
|
+
mediaType: string;
|
|
99
|
+
url: string;
|
|
100
|
+
filename?: string;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export type FileUIPartWithUpload = ChatFileUiPart & {
|
|
104
|
+
uploadId?: string;
|
|
105
|
+
uploadPath?: string;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export type ChatToolPartState =
|
|
109
|
+
| "pending"
|
|
110
|
+
| "input-streaming"
|
|
111
|
+
| "input-available"
|
|
112
|
+
| "approval-requested"
|
|
113
|
+
| "approval-responded"
|
|
114
|
+
| "output-available"
|
|
115
|
+
| "output-error"
|
|
116
|
+
| "output-denied"
|
|
117
|
+
| "error"
|
|
118
|
+
| "completed";
|
|
119
|
+
|
|
120
|
+
type ChatToolPartBase = {
|
|
121
|
+
toolCallId: string;
|
|
122
|
+
input: unknown;
|
|
123
|
+
state: ChatToolPartState;
|
|
124
|
+
title?: string;
|
|
125
|
+
providerExecuted?: boolean;
|
|
126
|
+
callProviderMetadata?: Record<string, unknown>;
|
|
127
|
+
output?: unknown;
|
|
128
|
+
errorText?: string;
|
|
129
|
+
approval?: {
|
|
130
|
+
id: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export type ChatDynamicToolUiPart = ChatToolPartBase & {
|
|
135
|
+
type: "dynamic-tool";
|
|
136
|
+
toolName: string;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export type ChatNamedToolUiPart = ChatToolPartBase & {
|
|
140
|
+
type: `tool-${string}` | "tool_call";
|
|
141
|
+
toolName?: string;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type ChatDataUiPart = {
|
|
145
|
+
type: `data-${string}`;
|
|
146
|
+
data: unknown;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export type ChatUiMessagePart =
|
|
150
|
+
| ChatTextUiPart
|
|
151
|
+
| ChatReasoningUiPart
|
|
152
|
+
| ChatStepStartUiPart
|
|
153
|
+
| ChatSourceUrlUiPart
|
|
154
|
+
| ChatSourceDocumentUiPart
|
|
155
|
+
| FileUIPartWithUpload
|
|
156
|
+
| ChatDynamicToolUiPart
|
|
157
|
+
| ChatNamedToolUiPart
|
|
158
|
+
| ChatDataUiPart;
|
|
159
|
+
|
|
160
|
+
export interface ChatUiMessage<TMessageMetadata = ChatMessageMetadata> {
|
|
161
|
+
id: string;
|
|
162
|
+
role: ChatUiMessageRole;
|
|
163
|
+
parts: ChatUiMessagePart[];
|
|
164
|
+
metadata?: TMessageMetadata;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };
|
|
168
|
+
|
|
169
|
+
export type ChatModelTextPart = {
|
|
170
|
+
type: "text";
|
|
171
|
+
text: string;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export type ChatModelReasoningPart = {
|
|
175
|
+
type: "reasoning";
|
|
176
|
+
text: string;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
export type ChatModelFilePart = {
|
|
180
|
+
type: "file" | "image";
|
|
181
|
+
mediaType: string;
|
|
182
|
+
data?: string;
|
|
183
|
+
url?: string;
|
|
184
|
+
filename?: string;
|
|
185
|
+
uploadId?: string;
|
|
186
|
+
uploadPath?: string;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export type ChatToolCallPart = {
|
|
190
|
+
type: "tool-call";
|
|
191
|
+
toolCallId: string;
|
|
192
|
+
toolName: string;
|
|
193
|
+
input: Record<string, unknown>;
|
|
194
|
+
providerExecuted?: boolean;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export type ChatToolResultOutput =
|
|
198
|
+
| {
|
|
199
|
+
type: "json";
|
|
200
|
+
value: JsonValue;
|
|
201
|
+
}
|
|
202
|
+
| {
|
|
203
|
+
type: "text";
|
|
204
|
+
value: string;
|
|
205
|
+
}
|
|
206
|
+
| {
|
|
207
|
+
type: "error-text";
|
|
208
|
+
value: string;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export type ChatToolResultPart = {
|
|
212
|
+
type: "tool-result";
|
|
213
|
+
toolCallId: string;
|
|
214
|
+
toolName: string;
|
|
215
|
+
output: ChatToolResultOutput;
|
|
216
|
+
providerOptions?: unknown;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export type ChatUserContentPart = ChatModelTextPart | ChatModelFilePart;
|
|
220
|
+
export type ChatAssistantContentPart =
|
|
221
|
+
| ChatModelTextPart
|
|
222
|
+
| ChatModelReasoningPart
|
|
223
|
+
| ChatModelFilePart
|
|
224
|
+
| ChatToolCallPart
|
|
225
|
+
| ChatToolResultPart;
|
|
226
|
+
|
|
227
|
+
export type ChatSystemMessage = {
|
|
228
|
+
role: "system";
|
|
229
|
+
content: string;
|
|
230
|
+
providerOptions?: Record<string, unknown>;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export type ChatUserMessage = {
|
|
234
|
+
role: "user";
|
|
235
|
+
content: string | ChatUserContentPart[];
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export type ChatAssistantMessage = {
|
|
239
|
+
role: "assistant";
|
|
240
|
+
content: string | ChatAssistantContentPart[];
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export type ChatToolMessage = {
|
|
244
|
+
role: "tool";
|
|
245
|
+
content: ChatToolResultPart[];
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
export type ChatModelMessage =
|
|
249
|
+
| ChatSystemMessage
|
|
250
|
+
| ChatUserMessage
|
|
251
|
+
| ChatAssistantMessage
|
|
252
|
+
| ChatToolMessage;
|
|
253
|
+
|
|
254
|
+
export interface DurableRootRunDescriptor {
|
|
255
|
+
runId: string;
|
|
256
|
+
messageId: string;
|
|
257
|
+
latestEventId?: number;
|
|
258
|
+
latestExternalEventSequence?: number;
|
|
259
|
+
parentConversationId?: string;
|
|
260
|
+
parentRunId?: string;
|
|
261
|
+
spawnedFromToolCallId?: string;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface ChatRuntimeOverrides {
|
|
265
|
+
allowedTools?: string[];
|
|
266
|
+
thinking?: false | number;
|
|
267
|
+
maxSteps?: number;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface ProjectFile {
|
|
271
|
+
path: string;
|
|
272
|
+
content: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
export interface ProjectFileListItem {
|
|
276
|
+
id: string;
|
|
277
|
+
path: string;
|
|
278
|
+
type: string;
|
|
279
|
+
size: number;
|
|
280
|
+
updated_at: string;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export interface UploadedFileReference {
|
|
284
|
+
name: string;
|
|
285
|
+
mediaType: string;
|
|
286
|
+
uploadId?: string;
|
|
287
|
+
path?: string;
|
|
288
|
+
url?: string;
|
|
289
|
+
size?: number;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export const chatRequestContextSchema = z
|
|
293
|
+
.object({
|
|
294
|
+
conversationId: z.string().optional(),
|
|
295
|
+
projectId: z.string().nullable(),
|
|
296
|
+
branchId: z.string().nullable(),
|
|
297
|
+
environmentContext: z.string().optional(),
|
|
298
|
+
})
|
|
299
|
+
.strict();
|
|
300
|
+
|
|
301
|
+
export type ChatRequestContext = z.infer<typeof chatRequestContextSchema>;
|
|
302
|
+
|
|
303
|
+
const childRunAuditStatusSchema: z.ZodType<ChildRunAudit["status"]> = z.enum([
|
|
304
|
+
"completed",
|
|
305
|
+
"failed",
|
|
306
|
+
"cancelled",
|
|
307
|
+
"stopped",
|
|
308
|
+
]);
|
|
309
|
+
|
|
310
|
+
const childRunAuditToolCallSchema: z.ZodType<ChildRunAuditToolCall> = z
|
|
311
|
+
.object({
|
|
312
|
+
toolName: z.string(),
|
|
313
|
+
toolCallId: z.string(),
|
|
314
|
+
input: z.unknown().optional(),
|
|
315
|
+
})
|
|
316
|
+
.strict();
|
|
317
|
+
|
|
318
|
+
const childRunAuditToolResultSchema: z.ZodType<ChildRunAuditToolResult> = z
|
|
319
|
+
.object({
|
|
320
|
+
toolName: z.string(),
|
|
321
|
+
toolCallId: z.string(),
|
|
322
|
+
input: z.unknown(),
|
|
323
|
+
output: z.unknown(),
|
|
324
|
+
})
|
|
325
|
+
.strict();
|
|
326
|
+
|
|
327
|
+
const childRunAuditSchema: z.ZodType<ChildRunAudit> = z
|
|
328
|
+
.object({
|
|
329
|
+
status: childRunAuditStatusSchema,
|
|
330
|
+
description: z.string().optional(),
|
|
331
|
+
steps: z.number().optional(),
|
|
332
|
+
durationMs: z.number().optional(),
|
|
333
|
+
toolCalls: z.array(childRunAuditToolCallSchema).optional(),
|
|
334
|
+
toolResults: z.array(childRunAuditToolResultSchema).optional(),
|
|
335
|
+
terminalErrorCode: z.string().nullable().optional(),
|
|
336
|
+
terminalErrorMessage: z.string().nullable().optional(),
|
|
337
|
+
})
|
|
338
|
+
.strict();
|
|
339
|
+
|
|
340
|
+
const messageMetadataUsageSchema: z.ZodType<ChatMessageMetadataUsage> = z
|
|
341
|
+
.object({
|
|
342
|
+
inputTokens: z.number().optional(),
|
|
343
|
+
outputTokens: z.number().optional(),
|
|
344
|
+
reasoningTokens: z.number().optional(),
|
|
345
|
+
cachedInputTokens: z.number().optional(),
|
|
346
|
+
})
|
|
347
|
+
.strict();
|
|
348
|
+
|
|
349
|
+
export const messageMetadataSchema: z.ZodType<ChatMessageMetadata> = z
|
|
350
|
+
.object({
|
|
351
|
+
createdAt: z.string().optional(),
|
|
352
|
+
isStopped: z.boolean().optional(),
|
|
353
|
+
isCompleted: z.boolean().optional(),
|
|
354
|
+
completedAt: z.string().optional(),
|
|
355
|
+
agentId: z.string().optional(),
|
|
356
|
+
agentName: z.string().optional(),
|
|
357
|
+
conversationId: z.string().optional(),
|
|
358
|
+
modelId: z.string().optional(),
|
|
359
|
+
runId: z.string().optional(),
|
|
360
|
+
streamingMessageId: z.string().optional(),
|
|
361
|
+
childRunAudit: childRunAuditSchema.optional(),
|
|
362
|
+
usage: messageMetadataUsageSchema.optional(),
|
|
363
|
+
})
|
|
364
|
+
.strict();
|
|
365
|
+
|
|
366
|
+
const nonEmptyStringSchema = z.string().min(1);
|
|
367
|
+
|
|
368
|
+
export const chatUiMessageRoleSchema: z.ZodType<ChatUiMessageRole> = z.enum([
|
|
369
|
+
"system",
|
|
370
|
+
"user",
|
|
371
|
+
"assistant",
|
|
372
|
+
]);
|
|
373
|
+
|
|
374
|
+
export const chatToolPartStateSchema: z.ZodType<ChatToolPartState> = z.enum([
|
|
375
|
+
"pending",
|
|
376
|
+
"input-streaming",
|
|
377
|
+
"input-available",
|
|
378
|
+
"approval-requested",
|
|
379
|
+
"approval-responded",
|
|
380
|
+
"output-available",
|
|
381
|
+
"output-error",
|
|
382
|
+
"output-denied",
|
|
383
|
+
"error",
|
|
384
|
+
"completed",
|
|
385
|
+
]);
|
|
386
|
+
|
|
387
|
+
const toolApprovalSchema = z
|
|
388
|
+
.object({
|
|
389
|
+
id: nonEmptyStringSchema,
|
|
390
|
+
})
|
|
391
|
+
.strict();
|
|
392
|
+
|
|
393
|
+
const toolPartBaseSchema = z
|
|
394
|
+
.object({
|
|
395
|
+
toolCallId: nonEmptyStringSchema,
|
|
396
|
+
input: z.unknown(),
|
|
397
|
+
state: chatToolPartStateSchema,
|
|
398
|
+
title: nonEmptyStringSchema.optional(),
|
|
399
|
+
providerExecuted: z.boolean().optional(),
|
|
400
|
+
callProviderMetadata: z.record(z.string(), z.unknown()).optional(),
|
|
401
|
+
output: z.unknown().optional(),
|
|
402
|
+
errorText: nonEmptyStringSchema.optional(),
|
|
403
|
+
approval: toolApprovalSchema.optional(),
|
|
404
|
+
})
|
|
405
|
+
.strip();
|
|
406
|
+
|
|
407
|
+
const chatTextUiPartSchema: z.ZodType<ChatTextUiPart> = z
|
|
408
|
+
.object({
|
|
409
|
+
type: z.literal("text"),
|
|
410
|
+
text: z.string(),
|
|
411
|
+
})
|
|
412
|
+
.strip();
|
|
413
|
+
|
|
414
|
+
const chatReasoningUiPartSchema: z.ZodType<ChatReasoningUiPart> = z
|
|
415
|
+
.object({
|
|
416
|
+
type: z.literal("reasoning"),
|
|
417
|
+
text: z.string(),
|
|
418
|
+
})
|
|
419
|
+
.strip();
|
|
420
|
+
|
|
421
|
+
const chatStepStartUiPartSchema: z.ZodType<ChatStepStartUiPart> = z
|
|
422
|
+
.object({
|
|
423
|
+
type: z.literal("step-start"),
|
|
424
|
+
})
|
|
425
|
+
.strip();
|
|
426
|
+
|
|
427
|
+
const chatSourceUrlUiPartSchema: z.ZodType<ChatSourceUrlUiPart> = z
|
|
428
|
+
.object({
|
|
429
|
+
type: z.literal("source-url"),
|
|
430
|
+
sourceId: nonEmptyStringSchema,
|
|
431
|
+
url: nonEmptyStringSchema,
|
|
432
|
+
title: z.string().optional(),
|
|
433
|
+
})
|
|
434
|
+
.strip();
|
|
435
|
+
|
|
436
|
+
const chatSourceDocumentUiPartSchema: z.ZodType<ChatSourceDocumentUiPart> = z
|
|
437
|
+
.object({
|
|
438
|
+
type: z.literal("source-document"),
|
|
439
|
+
sourceId: nonEmptyStringSchema,
|
|
440
|
+
title: nonEmptyStringSchema,
|
|
441
|
+
mediaType: nonEmptyStringSchema.optional(),
|
|
442
|
+
filename: nonEmptyStringSchema.optional(),
|
|
443
|
+
})
|
|
444
|
+
.strip();
|
|
445
|
+
|
|
446
|
+
const chatFileUiPartBaseSchema = z
|
|
447
|
+
.object({
|
|
448
|
+
type: z.literal("file"),
|
|
449
|
+
mediaType: nonEmptyStringSchema,
|
|
450
|
+
url: nonEmptyStringSchema,
|
|
451
|
+
filename: nonEmptyStringSchema.optional(),
|
|
452
|
+
})
|
|
453
|
+
.strip();
|
|
454
|
+
|
|
455
|
+
const fileUiPartWithUploadSchema: z.ZodType<FileUIPartWithUpload> = chatFileUiPartBaseSchema.extend(
|
|
456
|
+
{
|
|
457
|
+
uploadId: nonEmptyStringSchema.optional(),
|
|
458
|
+
uploadPath: nonEmptyStringSchema.optional(),
|
|
459
|
+
},
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
const chatDynamicToolUiPartSchema: z.ZodType<ChatDynamicToolUiPart> = toolPartBaseSchema.extend({
|
|
463
|
+
type: z.literal("dynamic-tool"),
|
|
464
|
+
toolName: nonEmptyStringSchema,
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
const chatNamedToolTypeSchema: z.ZodType<ChatNamedToolUiPart["type"]> = z.custom<
|
|
468
|
+
ChatNamedToolUiPart["type"]
|
|
469
|
+
>((value) => typeof value === "string" && (value === "tool_call" || /^tool-.+$/u.test(value)));
|
|
470
|
+
|
|
471
|
+
const chatNamedToolUiPartSchema: z.ZodType<ChatNamedToolUiPart> = toolPartBaseSchema.extend({
|
|
472
|
+
type: chatNamedToolTypeSchema,
|
|
473
|
+
toolName: nonEmptyStringSchema.optional(),
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
const chatDataUiPartTypeSchema: z.ZodType<ChatDataUiPart["type"]> = z.custom<
|
|
477
|
+
ChatDataUiPart["type"]
|
|
478
|
+
>((value) => typeof value === "string" && /^data-.+$/u.test(value));
|
|
479
|
+
|
|
480
|
+
const chatDataUiPartSchema: z.ZodType<ChatDataUiPart> = z
|
|
481
|
+
.object({
|
|
482
|
+
type: chatDataUiPartTypeSchema,
|
|
483
|
+
data: z.unknown(),
|
|
484
|
+
})
|
|
485
|
+
.strip();
|
|
486
|
+
|
|
487
|
+
export const chatUiMessagePartSchema: z.ZodType<ChatUiMessagePart> = z.union([
|
|
488
|
+
chatTextUiPartSchema,
|
|
489
|
+
chatReasoningUiPartSchema,
|
|
490
|
+
chatStepStartUiPartSchema,
|
|
491
|
+
chatSourceUrlUiPartSchema,
|
|
492
|
+
chatSourceDocumentUiPartSchema,
|
|
493
|
+
fileUiPartWithUploadSchema,
|
|
494
|
+
chatDynamicToolUiPartSchema,
|
|
495
|
+
chatNamedToolUiPartSchema,
|
|
496
|
+
chatDataUiPartSchema,
|
|
497
|
+
]);
|
|
498
|
+
|
|
499
|
+
export const chatUiMessageSchema: z.ZodType<ChatUiMessage> = z
|
|
500
|
+
.object({
|
|
501
|
+
id: nonEmptyStringSchema,
|
|
502
|
+
role: chatUiMessageRoleSchema,
|
|
503
|
+
parts: z.array(chatUiMessagePartSchema),
|
|
504
|
+
metadata: messageMetadataSchema.optional(),
|
|
505
|
+
})
|
|
506
|
+
.strip();
|
|
507
|
+
|
|
508
|
+
export const chatUiMessagesSchema = z.array(chatUiMessageSchema);
|
|
509
|
+
|
|
510
|
+
function hasExtension(filename: string | undefined, extensions: readonly string[]) {
|
|
511
|
+
const normalizedFilename = filename?.toLowerCase() ?? "";
|
|
512
|
+
return extensions.some((extension) => normalizedFilename.endsWith(extension));
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function isNativeTextAttachmentFile(filename: string | undefined) {
|
|
516
|
+
return hasExtension(filename, NATIVE_TEXT_ATTACHMENT_EXTENSIONS);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function preferNativeTextAttachmentMediaType(
|
|
520
|
+
filename: string | undefined,
|
|
521
|
+
fallbackMediaType: string,
|
|
522
|
+
) {
|
|
523
|
+
return isNativeTextAttachmentFile(filename) ? INLINE_TEXT_MEDIA_TYPE : fallbackMediaType;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function isTextMediaType(type: string | undefined) {
|
|
527
|
+
return type?.startsWith("text/") ?? false;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
function isInlinePreviewMediaType(mediaType: string) {
|
|
531
|
+
return isTextMediaType(mediaType) || isImageFile(mediaType) ||
|
|
532
|
+
mediaType === INLINE_PDF_MEDIA_TYPE;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
export function isImageFile(type: string | undefined) {
|
|
536
|
+
return type?.startsWith("image/") ?? false;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export function isValidImageFile(type: string) {
|
|
540
|
+
if (type.length === 0) {
|
|
541
|
+
return false;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
return imageFileTypes.some((imageFileType) => imageFileType === type);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export function isTextPreviewFile(name: string | undefined, type: string | undefined) {
|
|
548
|
+
return isTextMediaType(type) || hasExtension(name, textFileExtensions);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
export function normalizeInlineAttachmentMediaType(
|
|
552
|
+
filename: string | undefined,
|
|
553
|
+
mediaType: string | undefined,
|
|
554
|
+
) {
|
|
555
|
+
if (!mediaType) {
|
|
556
|
+
return preferNativeTextAttachmentMediaType(filename, INLINE_BINARY_MEDIA_TYPE);
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
if (isInlinePreviewMediaType(mediaType)) {
|
|
560
|
+
return mediaType;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
return preferNativeTextAttachmentMediaType(filename, mediaType);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function escapeXmlAttr(value: string): string {
|
|
567
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(
|
|
568
|
+
/>/g,
|
|
569
|
+
">",
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
export function buildDataFileAnnotation(refs: UploadedFileReference[]): string {
|
|
574
|
+
if (refs.length === 0) return "";
|
|
575
|
+
|
|
576
|
+
const fileTags = refs
|
|
577
|
+
.map((ref) => {
|
|
578
|
+
const attrs = [`name="${escapeXmlAttr(ref.name)}"`];
|
|
579
|
+
|
|
580
|
+
if (ref.uploadId) attrs.push(`upload_id="${escapeXmlAttr(ref.uploadId)}"`);
|
|
581
|
+
if (ref.path) attrs.push(`path="${escapeXmlAttr(ref.path)}"`);
|
|
582
|
+
if (typeof ref.size === "number") attrs.push(`size="${ref.size}"`);
|
|
583
|
+
if (ref.url) attrs.push(`url="${escapeXmlAttr(ref.url)}"`);
|
|
584
|
+
|
|
585
|
+
attrs.push(`type="${escapeXmlAttr(ref.mediaType)}"`);
|
|
586
|
+
|
|
587
|
+
return `<file ${attrs.join(" ")} />`;
|
|
588
|
+
})
|
|
589
|
+
.join("\n");
|
|
590
|
+
|
|
591
|
+
return `\n\n<uploaded_files>\n${fileTags}\n</uploaded_files>`;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export type {
|
|
595
|
+
ChatMessageMetadata,
|
|
596
|
+
ChatMessageMetadata as MessageMetadata,
|
|
597
|
+
ChatMessageMetadataUsage,
|
|
598
|
+
ChatUiMessageChunk,
|
|
599
|
+
ChildRunAudit,
|
|
600
|
+
ChildRunAuditToolCall,
|
|
601
|
+
ChildRunAuditToolResult,
|
|
602
|
+
};
|
package/src/src/sandbox/index.ts
CHANGED
|
@@ -34,4 +34,8 @@ export {
|
|
|
34
34
|
type SandboxOptions,
|
|
35
35
|
type SandboxSession,
|
|
36
36
|
} from "./sandbox.js";
|
|
37
|
-
export {
|
|
37
|
+
export {
|
|
38
|
+
LazySandbox,
|
|
39
|
+
type LazySandboxOptions,
|
|
40
|
+
resolveDefaultSandboxRuntimeEndpoint,
|
|
41
|
+
} from "./lazy-sandbox.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as dntShim from "../../_dnt.shims.js";
|
|
2
2
|
import { REQUEST_ERROR } from "../errors/index.js";
|
|
3
|
+
import { getHostEnv } from "../platform/compat/process.js";
|
|
3
4
|
import {
|
|
4
5
|
type CommandJob,
|
|
5
6
|
type CommandJobOutput,
|
|
@@ -45,6 +46,28 @@ const REPROVISIONABLE_EXEC_START_ERROR_CODES = new Set([
|
|
|
45
46
|
"ENOTFOUND",
|
|
46
47
|
"EHOSTUNREACH",
|
|
47
48
|
]);
|
|
49
|
+
const VERYFRONT_SANDBOX_PUBLIC_HOST_PATTERN = /^([a-z0-9-]+)\.sandbox\.veryfront\.[a-z0-9.-]+$/i;
|
|
50
|
+
|
|
51
|
+
export function resolveDefaultSandboxRuntimeEndpoint(input: { endpoint: string }): string {
|
|
52
|
+
if (!getHostEnv("KUBERNETES_SERVICE_HOST")) {
|
|
53
|
+
return input.endpoint;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let hostname: string;
|
|
57
|
+
try {
|
|
58
|
+
hostname = new URL(input.endpoint).hostname;
|
|
59
|
+
} catch {
|
|
60
|
+
return input.endpoint;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const match = hostname.match(VERYFRONT_SANDBOX_PUBLIC_HOST_PATTERN);
|
|
64
|
+
const shortId = match?.[1];
|
|
65
|
+
if (!shortId) {
|
|
66
|
+
return input.endpoint;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return `http://sandbox.veryfront-sandbox-${shortId}.svc.cluster.local`;
|
|
70
|
+
}
|
|
48
71
|
|
|
49
72
|
/** Lazily provisions sandbox sessions and keeps them alive while in use. */
|
|
50
73
|
export class LazySandbox {
|
|
@@ -625,7 +648,8 @@ export class LazySandbox {
|
|
|
625
648
|
private resolveRuntimeEndpoint(): string {
|
|
626
649
|
const endpoint = this.requireEndpoint();
|
|
627
650
|
const sessionId = this.requireSessionId();
|
|
628
|
-
return this.resolveRuntimeEndpointOption?.({ endpoint, sessionId }) ??
|
|
651
|
+
return this.resolveRuntimeEndpointOption?.({ endpoint, sessionId }) ??
|
|
652
|
+
resolveDefaultSandboxRuntimeEndpoint({ endpoint });
|
|
629
653
|
}
|
|
630
654
|
|
|
631
655
|
private requireSessionId(): string {
|