veryfront 0.1.1001 → 0.1.1002
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.js +1 -1
- package/esm/deps/esm.sh/react-dom@19.2.4/client.d.ts +3 -2
- package/esm/deps/esm.sh/react-dom@19.2.4/server.d.ts +3 -2
- package/esm/deps/esm.sh/react-dom@19.2.4.d.ts +3 -2
- package/esm/deps/esm.sh/react@19.2.4/jsx-dev-runtime.d.ts +3 -2
- package/esm/deps/esm.sh/react@19.2.4/jsx-runtime.d.ts +3 -2
- package/esm/deps/esm.sh/react@19.2.4.d.ts +3 -2
- package/esm/deps/esm.sh/scheduler@^0.27.0.d.ts +3 -2
- package/esm/src/agent/hosted/chat-preparation.d.ts +1 -1
- package/esm/src/agent/hosted/chat-preparation.d.ts.map +1 -1
- package/esm/src/agent/hosted/chat-preparation.js +5 -0
- package/esm/src/agent/runtime/message-file-url-refresh.d.ts +26 -1
- package/esm/src/agent/runtime/message-file-url-refresh.d.ts.map +1 -1
- package/esm/src/agent/runtime/message-file-url-refresh.js +219 -0
- package/esm/src/agent/runtime/message-preparation.d.ts +4 -1
- package/esm/src/agent/runtime/message-preparation.d.ts.map +1 -1
- package/esm/src/agent/runtime/message-preparation.js +20 -4
- package/esm/src/discovery/transpiler.d.ts.map +1 -1
- package/esm/src/discovery/transpiler.js +2 -0
- package/esm/src/extensions/bundler/defaults.d.ts +6 -0
- package/esm/src/extensions/bundler/defaults.d.ts.map +1 -0
- package/esm/src/extensions/bundler/defaults.js +21 -0
- package/esm/src/provider/model-registry.d.ts.map +1 -1
- package/esm/src/provider/model-registry.js +15 -1
- package/esm/src/testing/init.js +2 -18
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
package/esm/deno.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* npm package shim for esm.sh react-dom@19.2.4/client.d.ts */
|
|
2
|
+
export * from "react-dom/client";
|
|
3
|
+
export { default } from "react-dom/client";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* npm package shim for esm.sh react-dom@19.2.4/server.d.ts */
|
|
2
|
+
export * from "react-dom/server";
|
|
3
|
+
export { default } from "react-dom/server";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* npm package shim for esm.sh react-dom@19.2.4.d.ts */
|
|
2
|
+
export * from "react-dom";
|
|
3
|
+
export { default } from "react-dom";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* npm package shim for esm.sh react@19.2.4/jsx-dev-runtime.d.ts */
|
|
2
|
+
export * from "react/jsx-dev-runtime";
|
|
3
|
+
export { default } from "react/jsx-dev-runtime";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* npm package shim for esm.sh react@19.2.4/jsx-runtime.d.ts */
|
|
2
|
+
export * from "react/jsx-runtime";
|
|
3
|
+
export { default } from "react/jsx-runtime";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* npm package shim for esm.sh react@19.2.4.d.ts */
|
|
2
|
+
export * from "react";
|
|
3
|
+
export { default } from "react";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* npm package shim for esm.sh scheduler@^0.27.0.d.ts */
|
|
2
|
+
export * from "scheduler";
|
|
3
|
+
export { default } from "scheduler";
|
|
@@ -16,7 +16,7 @@ export type NormalizedHostedChatRequest = {
|
|
|
16
16
|
parentMessageId: string | undefined;
|
|
17
17
|
};
|
|
18
18
|
/** Options accepted by prepare hosted chat runtime messages. */
|
|
19
|
-
export type PrepareHostedChatRuntimeMessagesOptions = Pick<PrepareAgentRuntimeMessagesFromUiMessagesOptions, "emptyConversationPrompt" | "providerOwnedToolNames"> & {
|
|
19
|
+
export type PrepareHostedChatRuntimeMessagesOptions = Pick<PrepareAgentRuntimeMessagesFromUiMessagesOptions, "emptyConversationPrompt" | "providerOwnedToolNames" | "abortSignal" | "fileContentFetchTimeoutMs"> & {
|
|
20
20
|
authToken?: string;
|
|
21
21
|
apiUrl?: string | URL;
|
|
22
22
|
projectId?: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-preparation.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/chat-preparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EACV,gCAAgC,EAChC,+BAA+B,EAEhC,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EACL,KAAK,gCAAgC,EAErC,KAAK,4CAA4C,EAClD,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEL,KAAK,gDAAgD,EACtD,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EACL,KAAK,kCAAkC,EAExC,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAA2B,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACpG,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAEjC,MAAM,6BAA6B,CAAC;AAGrC,kDAAkD;AAClD,MAAM,MAAM,2BAA2B,GAAG;IACxC,iBAAiB,EAAE,aAAa,EAAE,CAAC;IACnC,yBAAyB,EAAE,kBAAkB,CAAC;IAC9C,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF,gEAAgE;AAChE,MAAM,MAAM,uCAAuC,GAC/C,IAAI,CACJ,gDAAgD,
|
|
1
|
+
{"version":3,"file":"chat-preparation.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/chat-preparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EACV,gCAAgC,EAChC,+BAA+B,EAEhC,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EACL,KAAK,gCAAgC,EAErC,KAAK,4CAA4C,EAClD,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEL,KAAK,gDAAgD,EACtD,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EACL,KAAK,kCAAkC,EAExC,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAA2B,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACpG,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,2BAA2B,EAEjC,MAAM,6BAA6B,CAAC;AAGrC,kDAAkD;AAClD,MAAM,MAAM,2BAA2B,GAAG;IACxC,iBAAiB,EAAE,aAAa,EAAE,CAAC;IACnC,yBAAyB,EAAE,kBAAkB,CAAC;IAC9C,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF,gEAAgE;AAChE,MAAM,MAAM,uCAAuC,GAC/C,IAAI,CACJ,gDAAgD,EAC9C,yBAAyB,GACzB,wBAAwB,GACxB,aAAa,G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AAK,EAAE,mCAAmC,CACxC,uBAAuB,EACvB,cAAc,CACf,GACA,OAAO,CACR,oCAAoC,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAC9E,CAiFA;AAED,4CAA4C;AAC5C,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,OAAO,GAAE,uCAA4C,GACpD,OAAO,CAAC,mBAAmB,EAAE,CAAC,CA2BhC"}
|
|
@@ -167,6 +167,7 @@ export async function prepareHostedChatExecution(input) {
|
|
|
167
167
|
apiUrl: input.apiUrl,
|
|
168
168
|
projectId: input.request.projectId,
|
|
169
169
|
providerOwnedToolNames: getProviderToolNames(input.agentConfig),
|
|
170
|
+
abortSignal: input.abortSignal,
|
|
170
171
|
});
|
|
171
172
|
let budgetedContext;
|
|
172
173
|
if (input.contextBudget) {
|
|
@@ -213,6 +214,8 @@ export async function prepareHostedChatRuntimeMessages(messages, options = {}) {
|
|
|
213
214
|
messages,
|
|
214
215
|
emptyConversationPrompt: options.emptyConversationPrompt,
|
|
215
216
|
providerOwnedToolNames: options.providerOwnedToolNames,
|
|
217
|
+
abortSignal: options.abortSignal,
|
|
218
|
+
fileContentFetchTimeoutMs: options.fileContentFetchTimeoutMs,
|
|
216
219
|
});
|
|
217
220
|
}
|
|
218
221
|
const authToken = options.authToken;
|
|
@@ -221,6 +224,8 @@ export async function prepareHostedChatRuntimeMessages(messages, options = {}) {
|
|
|
221
224
|
messages,
|
|
222
225
|
emptyConversationPrompt: options.emptyConversationPrompt,
|
|
223
226
|
providerOwnedToolNames: options.providerOwnedToolNames,
|
|
227
|
+
abortSignal: options.abortSignal,
|
|
228
|
+
fileContentFetchTimeoutMs: options.fileContentFetchTimeoutMs,
|
|
224
229
|
resolveFileUrl: ({ uploadId }) => getRuntimeUploadUrl({
|
|
225
230
|
apiUrl,
|
|
226
231
|
authToken,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ChatUiMessage, type FileUIPartWithUpload } from "../../chat/types.js";
|
|
2
2
|
/** Input payload for runtime file URL resolver. */
|
|
3
3
|
export type RuntimeFileUrlResolverInput = {
|
|
4
4
|
uploadId: string;
|
|
@@ -7,6 +7,31 @@ export type RuntimeFileUrlResolverInput = {
|
|
|
7
7
|
};
|
|
8
8
|
/** Public API contract for runtime file URL resolver. */
|
|
9
9
|
export type RuntimeFileUrlResolver = (input: RuntimeFileUrlResolverInput) => Promise<string | undefined>;
|
|
10
|
+
/** Input payload for runtime file content fetcher. */
|
|
11
|
+
export type RuntimeFileContentFetcherInput = {
|
|
12
|
+
url: string;
|
|
13
|
+
mediaType: string;
|
|
14
|
+
filename?: string;
|
|
15
|
+
uploadId?: string;
|
|
16
|
+
uploadPath?: string;
|
|
17
|
+
abortSignal?: AbortSignal;
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
part: FileUIPartWithUpload;
|
|
20
|
+
message: ChatUiMessage;
|
|
21
|
+
};
|
|
22
|
+
/** Public API contract for runtime file content fetcher. */
|
|
23
|
+
export type RuntimeFileContentFetcher = (input: RuntimeFileContentFetcherInput) => Promise<string | undefined>;
|
|
24
|
+
/** Creates a safe runtime file content fetcher. */
|
|
25
|
+
export declare function createRuntimeFileContentFetcher(options?: {
|
|
26
|
+
trustedUrls?: ReadonlySet<string>;
|
|
27
|
+
abortSignal?: AbortSignal;
|
|
28
|
+
timeoutMs?: number;
|
|
29
|
+
}): RuntimeFileContentFetcher;
|
|
10
30
|
/** Resolves runtime message file urls. */
|
|
11
31
|
export declare function resolveRuntimeMessageFileUrls(messages: readonly ChatUiMessage[], resolveFileUrl: RuntimeFileUrlResolver): Promise<ChatUiMessage[]>;
|
|
32
|
+
/** Fetches text attachment bodies and adds them as adjacent text parts. */
|
|
33
|
+
export declare function inlineRuntimeMessageFileContents(messages: readonly ChatUiMessage[], fetchFileContent?: RuntimeFileContentFetcher, options?: {
|
|
34
|
+
abortSignal?: AbortSignal;
|
|
35
|
+
fetchTimeoutMs?: number;
|
|
36
|
+
}): Promise<ChatUiMessage[]>;
|
|
12
37
|
//# sourceMappingURL=message-file-url-refresh.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-file-url-refresh.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/message-file-url-refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"message-file-url-refresh.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/message-file-url-refresh.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAE1B,MAAM,qBAAqB,CAAC;AAK7B,mDAAmD;AACnD,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,OAAO,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,yDAAyD;AACzD,MAAM,MAAM,sBAAsB,GAAG,CACnC,KAAK,EAAE,2BAA2B,KAC/B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAEjC,sDAAsD;AACtD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,oBAAoB,CAAC;IAC3B,OAAO,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,yBAAyB,GAAG,CACtC,KAAK,EAAE,8BAA8B,KAClC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAEjC,mDAAmD;AACnD,wBAAgB,+BAA+B,CAC7C,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACf,GACL,yBAAyB,CAe3B;AAED,0CAA0C;AAC1C,wBAAsB,6BAA6B,CACjD,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,aAAa,EAAE,CAAC,CAqC1B;AAED,2EAA2E;AAC3E,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,gBAAgB,GAAE,yBAA6D,EAC/E,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACpB,GACL,OAAO,CAAC,aAAa,EAAE,CAAC,CA4C1B"}
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import { isTextPreviewFile, } from "../../chat/types.js";
|
|
2
|
+
const MAX_INLINE_FILE_CONTENT_CHARS = 200_000;
|
|
3
|
+
const DEFAULT_RUNTIME_FILE_CONTENT_FETCH_TIMEOUT_MS = 15_000;
|
|
4
|
+
/** Creates a safe runtime file content fetcher. */
|
|
5
|
+
export function createRuntimeFileContentFetcher(options = {}) {
|
|
6
|
+
const trustedUrls = options.trustedUrls;
|
|
7
|
+
return async (input) => {
|
|
8
|
+
if (!isFetchableRuntimeFileContentUrl(input.url, trustedUrls)) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const abortSignal = input.abortSignal ?? options.abortSignal;
|
|
12
|
+
const timeoutMs = input.timeoutMs ?? options.timeoutMs;
|
|
13
|
+
return await fetchRuntimeTextFileContent({
|
|
14
|
+
...input,
|
|
15
|
+
...(abortSignal ? { abortSignal } : {}),
|
|
16
|
+
...(timeoutMs != null ? { timeoutMs } : {}),
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
}
|
|
1
20
|
/** Resolves runtime message file urls. */
|
|
2
21
|
export async function resolveRuntimeMessageFileUrls(messages, resolveFileUrl) {
|
|
3
22
|
const urlByUploadId = new Map();
|
|
@@ -29,6 +48,45 @@ export async function resolveRuntimeMessageFileUrls(messages, resolveFileUrl) {
|
|
|
29
48
|
return { ...message, parts };
|
|
30
49
|
}));
|
|
31
50
|
}
|
|
51
|
+
/** Fetches text attachment bodies and adds them as adjacent text parts. */
|
|
52
|
+
export async function inlineRuntimeMessageFileContents(messages, fetchFileContent = createRuntimeFileContentFetcher(), options = {}) {
|
|
53
|
+
const contentByUrl = new Map();
|
|
54
|
+
return Promise.all(messages.map(async (message) => {
|
|
55
|
+
if (!message.parts.some((part) => shouldInlineFileContent(part))) {
|
|
56
|
+
return message;
|
|
57
|
+
}
|
|
58
|
+
const parts = [];
|
|
59
|
+
for (const part of message.parts) {
|
|
60
|
+
parts.push(part);
|
|
61
|
+
const file = getInlineableFilePart(part);
|
|
62
|
+
if (!file)
|
|
63
|
+
continue;
|
|
64
|
+
let contentPromise = contentByUrl.get(file.url);
|
|
65
|
+
if (!contentPromise) {
|
|
66
|
+
contentPromise = fetchFileContent({
|
|
67
|
+
url: file.url,
|
|
68
|
+
mediaType: file.mediaType,
|
|
69
|
+
...(file.filename ? { filename: file.filename } : {}),
|
|
70
|
+
...(file.uploadId ? { uploadId: file.uploadId } : {}),
|
|
71
|
+
...(file.uploadPath ? { uploadPath: file.uploadPath } : {}),
|
|
72
|
+
...(options.abortSignal ? { abortSignal: options.abortSignal } : {}),
|
|
73
|
+
...(options.fetchTimeoutMs != null ? { timeoutMs: options.fetchTimeoutMs } : {}),
|
|
74
|
+
part: file,
|
|
75
|
+
message,
|
|
76
|
+
}).then(normalizeInlineFileContent);
|
|
77
|
+
contentByUrl.set(file.url, contentPromise);
|
|
78
|
+
}
|
|
79
|
+
const content = await contentPromise;
|
|
80
|
+
if (!content)
|
|
81
|
+
continue;
|
|
82
|
+
parts.push({
|
|
83
|
+
type: "text",
|
|
84
|
+
text: buildInlineFileContentText(file, content),
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
return { ...message, parts };
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
32
90
|
function isRecord(value) {
|
|
33
91
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34
92
|
}
|
|
@@ -44,6 +102,9 @@ function getUploadId(part) {
|
|
|
44
102
|
}
|
|
45
103
|
return getStringField(part, "uploadId") ?? getStringField(part, "upload_id");
|
|
46
104
|
}
|
|
105
|
+
function getUploadPath(part) {
|
|
106
|
+
return getStringField(part, "uploadPath") ?? getStringField(part, "upload_path");
|
|
107
|
+
}
|
|
47
108
|
function getMediaType(part) {
|
|
48
109
|
return getStringField(part, "mediaType") ?? getStringField(part, "media_type");
|
|
49
110
|
}
|
|
@@ -69,6 +130,164 @@ function normalizeUploadedFilePart(part, uploadId) {
|
|
|
69
130
|
...(uploadPath ? { uploadPath } : {}),
|
|
70
131
|
};
|
|
71
132
|
}
|
|
133
|
+
function shouldInlineFileContent(part) {
|
|
134
|
+
return getInlineableFilePart(part) !== null;
|
|
135
|
+
}
|
|
136
|
+
function getInlineableFilePart(part) {
|
|
137
|
+
if (!isRecord(part) || part.type !== "file")
|
|
138
|
+
return null;
|
|
139
|
+
const mediaType = getMediaType(part);
|
|
140
|
+
const url = getStringField(part, "url");
|
|
141
|
+
if (!mediaType || !url)
|
|
142
|
+
return null;
|
|
143
|
+
const filename = getStringField(part, "filename");
|
|
144
|
+
if (!isTextPreviewFile(filename, mediaType))
|
|
145
|
+
return null;
|
|
146
|
+
return {
|
|
147
|
+
type: "file",
|
|
148
|
+
mediaType,
|
|
149
|
+
url,
|
|
150
|
+
...(filename ? { filename } : {}),
|
|
151
|
+
...(getUploadId(part) ? { uploadId: getUploadId(part) } : {}),
|
|
152
|
+
...(getUploadPath(part) ? { uploadPath: getUploadPath(part) } : {}),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
async function fetchRuntimeTextFileContent(input) {
|
|
156
|
+
const timeoutMs = input.timeoutMs ?? DEFAULT_RUNTIME_FILE_CONTENT_FETCH_TIMEOUT_MS;
|
|
157
|
+
const fetchSignal = createRuntimeFileContentFetchSignal(input.abortSignal, timeoutMs);
|
|
158
|
+
const response = await waitForRuntimeFileContentFetchOperation(fetch(input.url, { signal: fetchSignal.signal }), input, fetchSignal, timeoutMs);
|
|
159
|
+
if (!response.ok) {
|
|
160
|
+
throw new Error(`Failed to fetch text attachment content${formatFileContentFetchLabel(input)}: HTTP ${response.status}${response.statusText ? ` ${response.statusText}` : ""}`);
|
|
161
|
+
}
|
|
162
|
+
return await readRuntimeTextFileContent(response, input, fetchSignal, timeoutMs);
|
|
163
|
+
}
|
|
164
|
+
async function readRuntimeTextFileContent(response, input, fetchSignal, timeoutMs) {
|
|
165
|
+
if (!response.body) {
|
|
166
|
+
return "";
|
|
167
|
+
}
|
|
168
|
+
const reader = response.body.getReader();
|
|
169
|
+
const decoder = new TextDecoder();
|
|
170
|
+
let content = "";
|
|
171
|
+
let shouldCancelReader = false;
|
|
172
|
+
try {
|
|
173
|
+
while (content.length <= MAX_INLINE_FILE_CONTENT_CHARS) {
|
|
174
|
+
const result = await waitForRuntimeFileContentFetchOperation(reader.read(), input, fetchSignal, timeoutMs);
|
|
175
|
+
if (result.done) {
|
|
176
|
+
return appendRuntimeTextContentUntilInlineLimit(content, decoder.decode()).content;
|
|
177
|
+
}
|
|
178
|
+
const nextContent = appendRuntimeTextContentUntilInlineLimit(content, decoder.decode(result.value, { stream: true }));
|
|
179
|
+
content = nextContent.content;
|
|
180
|
+
if (nextContent.reachedLimit) {
|
|
181
|
+
shouldCancelReader = true;
|
|
182
|
+
return content;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return content;
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
if (shouldCancelReader || fetchSignal.signal.aborted) {
|
|
189
|
+
void reader.cancel().catch(() => { });
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
reader.releaseLock();
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
// Ignore release failures after cancellation has already been requested.
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
function appendRuntimeTextContentUntilInlineLimit(content, decoded) {
|
|
200
|
+
const readLimit = MAX_INLINE_FILE_CONTENT_CHARS + 1;
|
|
201
|
+
const remainingChars = readLimit - content.length;
|
|
202
|
+
if (decoded.length >= remainingChars) {
|
|
203
|
+
return {
|
|
204
|
+
content: `${content}${decoded.slice(0, Math.max(0, remainingChars))}`,
|
|
205
|
+
reachedLimit: true,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
return { content: `${content}${decoded}`, reachedLimit: false };
|
|
209
|
+
}
|
|
210
|
+
function createRuntimeFileContentFetchSignal(abortSignal, timeoutMs) {
|
|
211
|
+
const timeoutSignal = AbortSignal.timeout(Math.max(0, timeoutMs));
|
|
212
|
+
if (!abortSignal) {
|
|
213
|
+
return {
|
|
214
|
+
signal: timeoutSignal,
|
|
215
|
+
wasAbortedByCaller: () => false,
|
|
216
|
+
didTimeout: () => timeoutSignal.aborted,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
return {
|
|
220
|
+
signal: AbortSignal.any([abortSignal, timeoutSignal]),
|
|
221
|
+
wasAbortedByCaller: () => abortSignal.aborted,
|
|
222
|
+
didTimeout: () => timeoutSignal.aborted,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
async function waitForRuntimeFileContentFetchOperation(operation, input, fetchSignal, timeoutMs) {
|
|
226
|
+
let abortError;
|
|
227
|
+
let removeAbortListener = () => { };
|
|
228
|
+
const abortPromise = new Promise((_, reject) => {
|
|
229
|
+
const rejectAbort = () => {
|
|
230
|
+
abortError = createRuntimeFileContentAbortError(input, fetchSignal, timeoutMs);
|
|
231
|
+
reject(abortError);
|
|
232
|
+
};
|
|
233
|
+
if (fetchSignal.signal.aborted) {
|
|
234
|
+
rejectAbort();
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
fetchSignal.signal.addEventListener("abort", rejectAbort, { once: true });
|
|
238
|
+
removeAbortListener = () => fetchSignal.signal.removeEventListener("abort", rejectAbort);
|
|
239
|
+
});
|
|
240
|
+
try {
|
|
241
|
+
return await Promise.race([operation, abortPromise]);
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
if (error === abortError) {
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
const abortFailure = createRuntimeFileContentAbortError(input, fetchSignal, timeoutMs, error);
|
|
248
|
+
if (abortFailure) {
|
|
249
|
+
throw abortFailure;
|
|
250
|
+
}
|
|
251
|
+
throw error;
|
|
252
|
+
}
|
|
253
|
+
finally {
|
|
254
|
+
removeAbortListener();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function createRuntimeFileContentAbortError(input, fetchSignal, timeoutMs, cause) {
|
|
258
|
+
if (fetchSignal.wasAbortedByCaller()) {
|
|
259
|
+
return new Error(`Failed to fetch text attachment content${formatFileContentFetchLabel(input)}: request aborted`, { cause });
|
|
260
|
+
}
|
|
261
|
+
if (fetchSignal.didTimeout()) {
|
|
262
|
+
return new Error(`Failed to fetch text attachment content${formatFileContentFetchLabel(input)}: request timed out after ${timeoutMs}ms`, { cause });
|
|
263
|
+
}
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
function formatFileContentFetchLabel(input) {
|
|
267
|
+
const label = input.filename ?? input.uploadId ?? input.uploadPath;
|
|
268
|
+
return label ? ` for ${label}` : "";
|
|
269
|
+
}
|
|
270
|
+
function isFetchableRuntimeFileContentUrl(url, trustedUrls) {
|
|
271
|
+
if (url.startsWith("data:")) {
|
|
272
|
+
return true;
|
|
273
|
+
}
|
|
274
|
+
return trustedUrls?.has(url) ?? false;
|
|
275
|
+
}
|
|
276
|
+
function normalizeInlineFileContent(content) {
|
|
277
|
+
if (!content || content.trim().length === 0)
|
|
278
|
+
return undefined;
|
|
279
|
+
if (content.length <= MAX_INLINE_FILE_CONTENT_CHARS) {
|
|
280
|
+
return content;
|
|
281
|
+
}
|
|
282
|
+
return `${content.slice(0, MAX_INLINE_FILE_CONTENT_CHARS)}\n\n[Attachment content truncated]`;
|
|
283
|
+
}
|
|
284
|
+
function escapeXmlAttr(value) {
|
|
285
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
286
|
+
}
|
|
287
|
+
function buildInlineFileContentText(part, content) {
|
|
288
|
+
const name = part.filename ?? part.uploadId ?? "file";
|
|
289
|
+
return `Attached file content:\n\n<file_content name="${escapeXmlAttr(name)}" type="${escapeXmlAttr(part.mediaType)}">\n${content}\n</file_content>`;
|
|
290
|
+
}
|
|
72
291
|
function toResolverPart(part, uploadId) {
|
|
73
292
|
const normalized = normalizeUploadedFilePart(part, uploadId);
|
|
74
293
|
if (isRecord(normalized) && normalized.type === "file") {
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { ChatUiMessage } from "../../chat/types.js";
|
|
2
2
|
import { type AgentRuntimeMessage } from "./message-adapter.js";
|
|
3
|
-
import { type RuntimeFileUrlResolver } from "./message-file-url-refresh.js";
|
|
3
|
+
import { type RuntimeFileContentFetcher, type RuntimeFileUrlResolver } from "./message-file-url-refresh.js";
|
|
4
4
|
/** Options accepted by prepare agent runtime messages from UI messages. */
|
|
5
5
|
export type PrepareAgentRuntimeMessagesFromUiMessagesOptions = {
|
|
6
6
|
messages: readonly ChatUiMessage[];
|
|
7
7
|
emptyConversationPrompt?: string;
|
|
8
8
|
resolveFileUrl?: RuntimeFileUrlResolver;
|
|
9
|
+
fetchFileContent?: RuntimeFileContentFetcher;
|
|
10
|
+
abortSignal?: AbortSignal;
|
|
11
|
+
fileContentFetchTimeoutMs?: number;
|
|
9
12
|
providerOwnedToolNames?: readonly string[];
|
|
10
13
|
};
|
|
11
14
|
/** Prepare agent runtime messages from UI messages. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-preparation.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/message-preparation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"message-preparation.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/message-preparation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAIL,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AAKvC,2EAA2E;AAC3E,MAAM,MAAM,gDAAgD,GAAG;IAC7D,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,gBAAgB,CAAC,EAAE,yBAAyB,CAAC;IAC7C,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,sBAAsB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C,CAAC;AAEF,uDAAuD;AACvD,wBAAsB,yCAAyC,CAC7D,OAAO,EAAE,gDAAgD,GACxD,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAuChC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { prepareProviderModelMessagesFromUiMessages } from "../../chat/message-prep.js";
|
|
2
2
|
import { convertProviderMessagesToAgentRuntimeMessages, } from "./message-adapter.js";
|
|
3
|
-
import { resolveRuntimeMessageFileUrls, } from "./message-file-url-refresh.js";
|
|
3
|
+
import { createRuntimeFileContentFetcher, inlineRuntimeMessageFileContents, resolveRuntimeMessageFileUrls, } from "./message-file-url-refresh.js";
|
|
4
4
|
const DEFAULT_EMPTY_CONVERSATION_PROMPT = "Please provide 3-4 specific suggestions for what I could build or improve based on the current project context.";
|
|
5
5
|
/** Prepare agent runtime messages from UI messages. */
|
|
6
6
|
export async function prepareAgentRuntimeMessagesFromUiMessages(options) {
|
|
@@ -12,10 +12,26 @@ export async function prepareAgentRuntimeMessagesFromUiMessages(options) {
|
|
|
12
12
|
},
|
|
13
13
|
]);
|
|
14
14
|
}
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const trustedFileContentUrls = new Set();
|
|
16
|
+
const resolveFileUrl = options.resolveFileUrl;
|
|
17
|
+
const refreshedMessages = resolveFileUrl
|
|
18
|
+
? await resolveRuntimeMessageFileUrls(options.messages, async (input) => {
|
|
19
|
+
const url = await resolveFileUrl(input);
|
|
20
|
+
if (url) {
|
|
21
|
+
trustedFileContentUrls.add(url);
|
|
22
|
+
}
|
|
23
|
+
return url;
|
|
24
|
+
})
|
|
17
25
|
: [...options.messages];
|
|
18
|
-
|
|
26
|
+
const messagesWithFileContent = await inlineRuntimeMessageFileContents(refreshedMessages, options.fetchFileContent ?? createRuntimeFileContentFetcher({
|
|
27
|
+
trustedUrls: trustedFileContentUrls,
|
|
28
|
+
}), {
|
|
29
|
+
...(options.abortSignal ? { abortSignal: options.abortSignal } : {}),
|
|
30
|
+
...(options.fileContentFetchTimeoutMs != null
|
|
31
|
+
? { fetchTimeoutMs: options.fileContentFetchTimeoutMs }
|
|
32
|
+
: {}),
|
|
33
|
+
});
|
|
34
|
+
return convertProviderMessagesToAgentRuntimeMessages(prepareProviderModelMessagesFromUiMessages(messagesWithFileContent, {
|
|
19
35
|
providerOwnedToolNames: options.providerOwnedToolNames,
|
|
20
36
|
}));
|
|
21
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpiler.d.ts","sourceRoot":"","sources":["../../../src/src/discovery/transpiler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transpiler.d.ts","sourceRoot":"","sources":["../../../src/src/discovery/transpiler.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA6IvD;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,OAAO,CAAC,CAwGlB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* for dynamic import during discovery.
|
|
6
6
|
*/
|
|
7
7
|
import * as dntShim from "../../_dnt.shims.js";
|
|
8
|
+
import { ensureDefaultBundlerContracts } from "../extensions/bundler/defaults.js";
|
|
8
9
|
import { isDeno, isDenoCompiled } from "../platform/compat/runtime.js";
|
|
9
10
|
import { createFileSystem } from "../platform/compat/fs.js";
|
|
10
11
|
import * as pathHelper from "../platform/compat/path/index.js";
|
|
@@ -149,6 +150,7 @@ export async function importModule(file, context) {
|
|
|
149
150
|
});
|
|
150
151
|
}
|
|
151
152
|
const loader = getEsbuildLoader(filePath);
|
|
153
|
+
await ensureDefaultBundlerContracts();
|
|
152
154
|
const { build } = await import("../extensions/bundler/index.js");
|
|
153
155
|
const fileDir = pathHelper.dirname(filePath);
|
|
154
156
|
// When using fsAdapter (VFS), bundle all relative imports via the plugin.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazily register the first-party Bundler + ModuleLexer implementation when it
|
|
3
|
+
* is available from workspace source or an installed @veryfront/ext package.
|
|
4
|
+
*/
|
|
5
|
+
export declare function ensureDefaultBundlerContracts(): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../../src/src/extensions/bundler/defaults.ts"],"names":[],"mappings":"AAaA;;;GAGG;AACH,wBAAsB,6BAA6B,IAAI,OAAO,CAAC,IAAI,CAAC,CAgBnE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { register, tryResolve } from "../contracts.js";
|
|
2
|
+
import { importFirstPartyExtensionModule, isMissingFirstPartyExtensionModule, } from "../first-party-import.js";
|
|
3
|
+
/**
|
|
4
|
+
* Lazily register the first-party Bundler + ModuleLexer implementation when it
|
|
5
|
+
* is available from workspace source or an installed @veryfront/ext package.
|
|
6
|
+
*/
|
|
7
|
+
export async function ensureDefaultBundlerContracts() {
|
|
8
|
+
if (tryResolve("Bundler") && tryResolve("ModuleLexer"))
|
|
9
|
+
return;
|
|
10
|
+
try {
|
|
11
|
+
const { EsbuildBundler, EsModuleLexer } = await importFirstPartyExtensionModule("ext-bundler-esbuild", "@veryfront/ext-bundler-esbuild");
|
|
12
|
+
if (!tryResolve("Bundler"))
|
|
13
|
+
register("Bundler", new EsbuildBundler());
|
|
14
|
+
if (!tryResolve("ModuleLexer"))
|
|
15
|
+
register("ModuleLexer", new EsModuleLexer());
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (!isMissingFirstPartyExtensionModule(error))
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../../../src/src/provider/model-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAeH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,sDAAsD;AACtD,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../../../src/src/provider/model-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAeH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,sDAAsD;AACtD,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,YAAY,CAAC;AAqBrE;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,oBAAoB,GAC5B,IAAI,CAEN;AAuJD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,YAAY,CAuC9D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGtD;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,EAAE,CAGtD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,IAAI,CAAC,CAKf;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAG1C"}
|
|
@@ -22,6 +22,20 @@ import { createVeryfrontCloudModel } from "./veryfront-cloud/provider.js";
|
|
|
22
22
|
import { getModelRuntimeId, hasLocalModelRuntimeMarker } from "./runtime-inspection.js";
|
|
23
23
|
const manager = new ProjectScopedRegistryManager("model-provider");
|
|
24
24
|
let autoInitialized = false;
|
|
25
|
+
function isOpenAIBaseURL(baseURL) {
|
|
26
|
+
if (!baseURL)
|
|
27
|
+
return true;
|
|
28
|
+
try {
|
|
29
|
+
const hostname = new URL(baseURL).hostname.toLowerCase();
|
|
30
|
+
return hostname === "api.openai.com" || hostname.endsWith(".api.openai.com");
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function getOpenAIEnvProviderName(baseURL) {
|
|
37
|
+
return isOpenAIBaseURL(baseURL) ? "openai" : "openai-compatible";
|
|
38
|
+
}
|
|
25
39
|
/**
|
|
26
40
|
* Register a custom model provider factory for the current project.
|
|
27
41
|
*
|
|
@@ -65,7 +79,7 @@ function autoInitializeFromEnv() {
|
|
|
65
79
|
return provider.createModel(id, {
|
|
66
80
|
credential: config.apiKey,
|
|
67
81
|
baseURL: config.baseURL,
|
|
68
|
-
providerName:
|
|
82
|
+
providerName: getOpenAIEnvProviderName(config.baseURL),
|
|
69
83
|
});
|
|
70
84
|
}
|
|
71
85
|
throw toError(createError({
|
package/esm/src/testing/init.js
CHANGED
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
import * as dntShim from "../../_dnt.shims.js";
|
|
13
|
-
import {
|
|
14
|
-
import { importFirstPartyExtensionModule, isMissingFirstPartyExtensionModule, } from "../extensions/first-party-import.js";
|
|
13
|
+
import { ensureDefaultBundlerContracts } from "../extensions/bundler/defaults.js";
|
|
15
14
|
const g = dntShim.dntGlobalThis;
|
|
16
15
|
g.__vfDisableLruInterval = true;
|
|
17
16
|
g.__vfTestEnv = true;
|
|
@@ -21,19 +20,4 @@ g.__vfTestEnvMask = {
|
|
|
21
20
|
// Tests don't run the extension orchestrator; prime the Bundler + ModuleLexer
|
|
22
21
|
// contracts here so transforms that depend on them (lexer.ts, parse-cache.ts,
|
|
23
22
|
// the platform/compat/esbuild shim, and bundler call-sites) work in tests.
|
|
24
|
-
await
|
|
25
|
-
async function registerDefaultBundlerContracts() {
|
|
26
|
-
if (tryResolve("Bundler") && tryResolve("ModuleLexer"))
|
|
27
|
-
return;
|
|
28
|
-
try {
|
|
29
|
-
const { EsbuildBundler, EsModuleLexer } = await importFirstPartyExtensionModule("ext-bundler-esbuild", "@veryfront/ext-bundler-esbuild");
|
|
30
|
-
if (!tryResolve("Bundler"))
|
|
31
|
-
registerContract("Bundler", new EsbuildBundler());
|
|
32
|
-
if (!tryResolve("ModuleLexer"))
|
|
33
|
-
registerContract("ModuleLexer", new EsModuleLexer());
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
if (!isMissingFirstPartyExtensionModule(error))
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
23
|
+
await ensureDefaultBundlerContracts();
|