veryfront 0.1.1001 → 0.1.1003
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/extensions/ext-llm-openai/src/openai-chat-request-builder.d.ts.map +1 -1
- package/esm/extensions/ext-llm-openai/src/openai-chat-request-builder.js +24 -7
- package/esm/extensions/ext-llm-openai/src/openai-reasoning-models.d.ts.map +1 -1
- package/esm/extensions/ext-llm-openai/src/openai-reasoning-models.js +3 -1
- package/esm/extensions/ext-llm-openai/src/openai-responses-request-builder.d.ts +1 -0
- package/esm/extensions/ext-llm-openai/src/openai-responses-request-builder.d.ts.map +1 -1
- package/esm/extensions/ext-llm-openai/src/openai-responses-request-builder.js +5 -1
- 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 +28 -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 +293 -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";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-chat-request-builder.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-openai/src/openai-chat-request-builder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC/G,OAAO,EACL,KAAK,6BAA6B,EAGnC,MAAM,8BAA8B,CAAC;AAEtC,MAAM,MAAM,qBAAqB,GAC7B;IACA,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACtB,GACC;IACA,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,CAAC;AAEJ,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,WAAW,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|
+
{"version":3,"file":"openai-chat-request-builder.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-openai/src/openai-chat-request-builder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC/G,OAAO,EACL,KAAK,6BAA6B,EAGnC,MAAM,8BAA8B,CAAC;AAEtC,MAAM,MAAM,qBAAqB,GAC7B;IACA,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACtB,GACC;IACA,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,CAAC;AAEJ,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAChC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1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
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
101
|
+
// Env-BYOK users historically registered options under "openai-compatible";
|
|
102
|
+
// keep merging that bucket at the lowest precedence. max_tokens is normalized
|
|
103
|
+
// per bucket BEFORE merging so a higher-precedence bucket's max_tokens
|
|
104
|
+
// override still beats a lower bucket's max_completion_tokens.
|
|
105
|
+
const bucketNames = [
|
|
106
|
+
...(providerName === "openai" ? ["openai-compatible"] : []),
|
|
107
|
+
"openai",
|
|
108
|
+
providerName,
|
|
109
|
+
];
|
|
110
|
+
const providerOpts = {};
|
|
111
|
+
for (const bucketName of bucketNames) {
|
|
112
|
+
Object.assign(providerOpts, normalizeNativeMaxTokens(readProviderOptions(options.providerOptions, bucketName), modelId));
|
|
108
113
|
}
|
|
109
114
|
Object.assign(body, providerOpts);
|
|
110
115
|
return body;
|
|
111
116
|
}
|
|
117
|
+
/** Normalizes max_tokens to max_completion_tokens for native OpenAI models. */
|
|
118
|
+
function normalizeNativeMaxTokens(bucket, modelId) {
|
|
119
|
+
if (!isNativeOpenAIModel(modelId) || !("max_tokens" in bucket)) {
|
|
120
|
+
return bucket;
|
|
121
|
+
}
|
|
122
|
+
const normalized = { ...bucket };
|
|
123
|
+
if (!("max_completion_tokens" in normalized)) {
|
|
124
|
+
normalized.max_completion_tokens = normalized.max_tokens;
|
|
125
|
+
}
|
|
126
|
+
delete normalized.max_tokens;
|
|
127
|
+
return normalized;
|
|
128
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-reasoning-models.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-openai/src/openai-reasoning-models.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE9D,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,GAAG,KAAK,CAAC;AAE1E,MAAM,MAAM,6BAA6B,GAAG;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,6BAA6B,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC;CAChC,CAAC;AAIF,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAG5E;AAuBD,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,EACf,YAAY,SAAW,GACtB,qBAAqB,GAAG,SAAS,CAwBnC;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,6BAA6B,GAAG,SAAS,GAChD,uBAAuB,GAAG,SAAS,CAoBrC;AAED,wBAAgB,mCAAmC,CACjD,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,uBAAuB,GACjC,OAAO,
|
|
1
|
+
{"version":3,"file":"openai-reasoning-models.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-openai/src/openai-reasoning-models.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE9D,MAAM,MAAM,6BAA6B,GAAG,qBAAqB,GAAG,KAAK,CAAC;AAE1E,MAAM,MAAM,6BAA6B,GAAG;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,6BAA6B,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC;CAChC,CAAC;AAIF,wBAAgB,8BAA8B,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAG5E;AAuBD,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,MAAM,EACf,YAAY,SAAW,GACtB,qBAAqB,GAAG,SAAS,CAwBnC;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,6BAA6B,GAAG,SAAS,GAChD,uBAAuB,GAAG,SAAS,CAoBrC;AAED,wBAAgB,mCAAmC,CACjD,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,uBAAuB,GACjC,OAAO,CAIT;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,SAAW,GAAG,OAAO,CAExF;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAIpE"}
|
|
@@ -59,7 +59,9 @@ export function resolveOpenAIReasoningConfig(modelId, providerName, option) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
export function shouldRequestOpenAIReasoningSummary(providerName, reasoning) {
|
|
62
|
-
|
|
62
|
+
// Default-reasoning BYOK "openai" requests must not ask for summaries:
|
|
63
|
+
// unverified customer organizations get a 400 from the Responses API.
|
|
64
|
+
return reasoning.source === "explicit" || providerName.toLowerCase() === "veryfront-cloud";
|
|
63
65
|
}
|
|
64
66
|
export function isOpenAIReasoningModel(modelId, providerName = "openai") {
|
|
65
67
|
return getDefaultOpenAIReasoningEffort(modelId, providerName) !== undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-responses-request-builder.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-openai/src/openai-responses-request-builder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,+BAA+B,EAEhC,MAAM,kCAAkC,CAAC;AAO1C,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/D,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,wBAAwB,EAAE,CAAC;I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,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,+BAA+B,EACxC,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,gBAAgB,GACzB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"openai-responses-request-builder.d.ts","sourceRoot":"","sources":["../../../../src/extensions/ext-llm-openai/src/openai-responses-request-builder.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,+BAA+B,EAEhC,MAAM,kCAAkC,CAAC;AAO1C,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE/D,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,wBAAwB,EAAE,CAAC;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,IAAI,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IAC3C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,IAAI,CAAC,OAAO,EAAE;QACZ,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC;QACtC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,IAAI,CAAC;IACT,KAAK,IAAI,KAAK,CAAC;QACb,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC;QACtC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAAC;CACJ,CAAC;AA6IF,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,+BAA+B,EACxC,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,gBAAgB,GACzB,sBAAsB,CAsGxB"}
|
|
@@ -162,6 +162,8 @@ export function buildOpenAIResponsesRequest(modelId, providerName, options, stre
|
|
|
162
162
|
const body = {
|
|
163
163
|
model: modelId,
|
|
164
164
|
input,
|
|
165
|
+
// Stay stateless: encrypted reasoning content is never round-tripped via include.
|
|
166
|
+
store: false,
|
|
165
167
|
...(instructions !== undefined ? { instructions } : {}),
|
|
166
168
|
...(stream ? { stream: true } : {}),
|
|
167
169
|
...(options.maxOutputTokens !== undefined
|
|
@@ -208,6 +210,8 @@ export function buildOpenAIResponsesRequest(modelId, providerName, options, stre
|
|
|
208
210
|
}
|
|
209
211
|
: {}),
|
|
210
212
|
};
|
|
211
|
-
|
|
213
|
+
// Env-BYOK users historically registered options under "openai-compatible";
|
|
214
|
+
// keep merging that bucket at the lowest precedence.
|
|
215
|
+
Object.assign(body, readProviderOptions(options.providerOptions, ...(providerName === "openai" ? ["openai-compatible"] : []), "openai", providerName));
|
|
212
216
|
return body;
|
|
213
217
|
}
|
|
@@ -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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EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,0BAA0B,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,EACD,cAAc,SAAS,+BAA+B,EAEtD,KAAK,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,33 @@ 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[]>;
|
|
37
|
+
/** Composes abort signals manually for runtimes without AbortSignal.any (Node < 20.3). */
|
|
38
|
+
export declare function composeAbortSignals(signals: readonly AbortSignal[]): AbortSignal;
|
|
12
39
|
//# 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;AAM7B,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,CA0F1B;AAsLD,0FAA0F;AAC1F,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,WAAW,CAuBhF"}
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
import { isTextPreviewFile, } from "../../chat/types.js";
|
|
2
|
+
const MAX_INLINE_FILE_CONTENT_CHARS = 200_000;
|
|
3
|
+
const MAX_TOTAL_INLINE_FILE_CONTENT_CHARS = 400_000;
|
|
4
|
+
const DEFAULT_RUNTIME_FILE_CONTENT_FETCH_TIMEOUT_MS = 15_000;
|
|
5
|
+
/** Creates a safe runtime file content fetcher. */
|
|
6
|
+
export function createRuntimeFileContentFetcher(options = {}) {
|
|
7
|
+
const trustedUrls = options.trustedUrls;
|
|
8
|
+
return async (input) => {
|
|
9
|
+
if (!isFetchableRuntimeFileContentUrl(input.url, trustedUrls)) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const abortSignal = input.abortSignal ?? options.abortSignal;
|
|
13
|
+
const timeoutMs = input.timeoutMs ?? options.timeoutMs;
|
|
14
|
+
return await fetchRuntimeTextFileContent({
|
|
15
|
+
...input,
|
|
16
|
+
...(abortSignal ? { abortSignal } : {}),
|
|
17
|
+
...(timeoutMs != null ? { timeoutMs } : {}),
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
}
|
|
1
21
|
/** Resolves runtime message file urls. */
|
|
2
22
|
export async function resolveRuntimeMessageFileUrls(messages, resolveFileUrl) {
|
|
3
23
|
const urlByUploadId = new Map();
|
|
@@ -29,6 +49,87 @@ export async function resolveRuntimeMessageFileUrls(messages, resolveFileUrl) {
|
|
|
29
49
|
return { ...message, parts };
|
|
30
50
|
}));
|
|
31
51
|
}
|
|
52
|
+
/** Fetches text attachment bodies and adds them as adjacent text parts. */
|
|
53
|
+
export async function inlineRuntimeMessageFileContents(messages, fetchFileContent = createRuntimeFileContentFetcher(), options = {}) {
|
|
54
|
+
const contentByUrl = new Map();
|
|
55
|
+
const newestUserMessageIndex = findNewestUserMessageIndex(messages);
|
|
56
|
+
const inlineTextByPart = new Map();
|
|
57
|
+
let remainingBudget = MAX_TOTAL_INLINE_FILE_CONTENT_CHARS;
|
|
58
|
+
// Allocate the aggregate inline budget newest-first so the most recent
|
|
59
|
+
// attachments win, then skip fetching entirely once the budget is spent.
|
|
60
|
+
for (let messageIndex = messages.length - 1; messageIndex >= 0; messageIndex--) {
|
|
61
|
+
const message = messages[messageIndex];
|
|
62
|
+
for (let partIndex = 0; partIndex < message.parts.length; partIndex++) {
|
|
63
|
+
const file = getInlineableFilePart(message.parts[partIndex]);
|
|
64
|
+
if (!file)
|
|
65
|
+
continue;
|
|
66
|
+
if (remainingBudget <= 0) {
|
|
67
|
+
inlineTextByPart.set(`${messageIndex}:${partIndex}`, "[attachment content omitted: inline budget exceeded]");
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
let contentPromise = contentByUrl.get(file.url);
|
|
71
|
+
if (!contentPromise) {
|
|
72
|
+
contentPromise = fetchFileContent({
|
|
73
|
+
url: file.url,
|
|
74
|
+
mediaType: file.mediaType,
|
|
75
|
+
...(file.filename ? { filename: file.filename } : {}),
|
|
76
|
+
...(file.uploadId ? { uploadId: file.uploadId } : {}),
|
|
77
|
+
...(file.uploadPath ? { uploadPath: file.uploadPath } : {}),
|
|
78
|
+
...(options.abortSignal ? { abortSignal: options.abortSignal } : {}),
|
|
79
|
+
...(options.fetchTimeoutMs != null ? { timeoutMs: options.fetchTimeoutMs } : {}),
|
|
80
|
+
part: file,
|
|
81
|
+
message,
|
|
82
|
+
}).then(normalizeInlineFileContent);
|
|
83
|
+
contentByUrl.set(file.url, contentPromise);
|
|
84
|
+
}
|
|
85
|
+
let inlineContent;
|
|
86
|
+
try {
|
|
87
|
+
inlineContent = await contentPromise;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
// Attachments on the newest user message must stay hard failures, and
|
|
91
|
+
// caller aborts always propagate; stale history attachments degrade.
|
|
92
|
+
if (messageIndex === newestUserMessageIndex || options.abortSignal?.aborted) {
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
inlineTextByPart.set(`${messageIndex}:${partIndex}`, `[attachment unavailable: ${file.filename ?? file.uploadId ?? "file"}]`);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (!inlineContent)
|
|
99
|
+
continue;
|
|
100
|
+
let content = inlineContent.content;
|
|
101
|
+
let truncated = inlineContent.truncated;
|
|
102
|
+
if (content.length > remainingBudget) {
|
|
103
|
+
content = content.slice(0, remainingBudget);
|
|
104
|
+
truncated = true;
|
|
105
|
+
}
|
|
106
|
+
remainingBudget -= content.length;
|
|
107
|
+
inlineTextByPart.set(`${messageIndex}:${partIndex}`, buildInlineFileContentText(file, truncated ? `${content}\n\n[Attachment content truncated]` : content));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return messages.map((message, messageIndex) => {
|
|
111
|
+
if (!message.parts.some((part) => shouldInlineFileContent(part))) {
|
|
112
|
+
return message;
|
|
113
|
+
}
|
|
114
|
+
const parts = [];
|
|
115
|
+
for (let partIndex = 0; partIndex < message.parts.length; partIndex++) {
|
|
116
|
+
parts.push(message.parts[partIndex]);
|
|
117
|
+
const text = inlineTextByPart.get(`${messageIndex}:${partIndex}`);
|
|
118
|
+
if (text) {
|
|
119
|
+
parts.push({ type: "text", text });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return { ...message, parts };
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function findNewestUserMessageIndex(messages) {
|
|
126
|
+
for (let index = messages.length - 1; index >= 0; index--) {
|
|
127
|
+
if (messages[index]?.role === "user") {
|
|
128
|
+
return index;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return -1;
|
|
132
|
+
}
|
|
32
133
|
function isRecord(value) {
|
|
33
134
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34
135
|
}
|
|
@@ -44,6 +145,9 @@ function getUploadId(part) {
|
|
|
44
145
|
}
|
|
45
146
|
return getStringField(part, "uploadId") ?? getStringField(part, "upload_id");
|
|
46
147
|
}
|
|
148
|
+
function getUploadPath(part) {
|
|
149
|
+
return getStringField(part, "uploadPath") ?? getStringField(part, "upload_path");
|
|
150
|
+
}
|
|
47
151
|
function getMediaType(part) {
|
|
48
152
|
return getStringField(part, "mediaType") ?? getStringField(part, "media_type");
|
|
49
153
|
}
|
|
@@ -69,6 +173,195 @@ function normalizeUploadedFilePart(part, uploadId) {
|
|
|
69
173
|
...(uploadPath ? { uploadPath } : {}),
|
|
70
174
|
};
|
|
71
175
|
}
|
|
176
|
+
function shouldInlineFileContent(part) {
|
|
177
|
+
return getInlineableFilePart(part) !== null;
|
|
178
|
+
}
|
|
179
|
+
function getInlineableFilePart(part) {
|
|
180
|
+
if (!isRecord(part) || part.type !== "file")
|
|
181
|
+
return null;
|
|
182
|
+
const mediaType = getMediaType(part);
|
|
183
|
+
const url = getStringField(part, "url");
|
|
184
|
+
if (!mediaType || !url)
|
|
185
|
+
return null;
|
|
186
|
+
const filename = getStringField(part, "filename");
|
|
187
|
+
if (!isTextPreviewFile(filename, mediaType))
|
|
188
|
+
return null;
|
|
189
|
+
return {
|
|
190
|
+
type: "file",
|
|
191
|
+
mediaType,
|
|
192
|
+
url,
|
|
193
|
+
...(filename ? { filename } : {}),
|
|
194
|
+
...(getUploadId(part) ? { uploadId: getUploadId(part) } : {}),
|
|
195
|
+
...(getUploadPath(part) ? { uploadPath: getUploadPath(part) } : {}),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
async function fetchRuntimeTextFileContent(input) {
|
|
199
|
+
const timeoutMs = input.timeoutMs ?? DEFAULT_RUNTIME_FILE_CONTENT_FETCH_TIMEOUT_MS;
|
|
200
|
+
const fetchSignal = createRuntimeFileContentFetchSignal(input.abortSignal, timeoutMs);
|
|
201
|
+
const response = await waitForRuntimeFileContentFetchOperation(fetch(input.url, { signal: fetchSignal.signal }), input, fetchSignal, timeoutMs);
|
|
202
|
+
if (!response.ok) {
|
|
203
|
+
throw new Error(`Failed to fetch text attachment content${formatFileContentFetchLabel(input)}: HTTP ${response.status}${response.statusText ? ` ${response.statusText}` : ""}`);
|
|
204
|
+
}
|
|
205
|
+
return await readRuntimeTextFileContent(response, input, fetchSignal, timeoutMs);
|
|
206
|
+
}
|
|
207
|
+
async function readRuntimeTextFileContent(response, input, fetchSignal, timeoutMs) {
|
|
208
|
+
if (!response.body) {
|
|
209
|
+
return "";
|
|
210
|
+
}
|
|
211
|
+
const reader = response.body.getReader();
|
|
212
|
+
const decoder = new TextDecoder();
|
|
213
|
+
let content = "";
|
|
214
|
+
let shouldCancelReader = false;
|
|
215
|
+
try {
|
|
216
|
+
while (content.length <= MAX_INLINE_FILE_CONTENT_CHARS) {
|
|
217
|
+
const result = await waitForRuntimeFileContentFetchOperation(reader.read(), input, fetchSignal, timeoutMs);
|
|
218
|
+
if (result.done) {
|
|
219
|
+
return appendRuntimeTextContentUntilInlineLimit(content, decoder.decode()).content;
|
|
220
|
+
}
|
|
221
|
+
const nextContent = appendRuntimeTextContentUntilInlineLimit(content, decoder.decode(result.value, { stream: true }));
|
|
222
|
+
content = nextContent.content;
|
|
223
|
+
if (nextContent.reachedLimit) {
|
|
224
|
+
shouldCancelReader = true;
|
|
225
|
+
return content;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return content;
|
|
229
|
+
}
|
|
230
|
+
finally {
|
|
231
|
+
if (shouldCancelReader || fetchSignal.signal.aborted) {
|
|
232
|
+
void reader.cancel().catch(() => { });
|
|
233
|
+
}
|
|
234
|
+
try {
|
|
235
|
+
reader.releaseLock();
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
// Ignore release failures after cancellation has already been requested.
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function appendRuntimeTextContentUntilInlineLimit(content, decoded) {
|
|
243
|
+
const readLimit = MAX_INLINE_FILE_CONTENT_CHARS + 1;
|
|
244
|
+
const remainingChars = readLimit - content.length;
|
|
245
|
+
if (decoded.length >= remainingChars) {
|
|
246
|
+
return {
|
|
247
|
+
content: `${content}${decoded.slice(0, Math.max(0, remainingChars))}`,
|
|
248
|
+
reachedLimit: true,
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
return { content: `${content}${decoded}`, reachedLimit: false };
|
|
252
|
+
}
|
|
253
|
+
/** Composes abort signals manually for runtimes without AbortSignal.any (Node < 20.3). */
|
|
254
|
+
export function composeAbortSignals(signals) {
|
|
255
|
+
const controller = new AbortController();
|
|
256
|
+
const removeListeners = [];
|
|
257
|
+
const detachAll = () => {
|
|
258
|
+
for (const removeListener of removeListeners) {
|
|
259
|
+
removeListener();
|
|
260
|
+
}
|
|
261
|
+
removeListeners.length = 0;
|
|
262
|
+
};
|
|
263
|
+
for (const signal of signals) {
|
|
264
|
+
if (signal.aborted) {
|
|
265
|
+
detachAll();
|
|
266
|
+
controller.abort(signal.reason);
|
|
267
|
+
return controller.signal;
|
|
268
|
+
}
|
|
269
|
+
const onAbort = () => controller.abort(signal.reason);
|
|
270
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
271
|
+
removeListeners.push(() => signal.removeEventListener("abort", onAbort));
|
|
272
|
+
}
|
|
273
|
+
// Detach listeners from the still-pending source signals once any of them
|
|
274
|
+
// fires, so long-lived caller signals don't accumulate stale listeners.
|
|
275
|
+
controller.signal.addEventListener("abort", detachAll, { once: true });
|
|
276
|
+
return controller.signal;
|
|
277
|
+
}
|
|
278
|
+
function anyAbortSignal(signals) {
|
|
279
|
+
if (typeof AbortSignal.any === "function") {
|
|
280
|
+
return AbortSignal.any([...signals]);
|
|
281
|
+
}
|
|
282
|
+
return composeAbortSignals(signals);
|
|
283
|
+
}
|
|
284
|
+
function createRuntimeFileContentFetchSignal(abortSignal, timeoutMs) {
|
|
285
|
+
const timeoutSignal = AbortSignal.timeout(Math.max(0, timeoutMs));
|
|
286
|
+
if (!abortSignal) {
|
|
287
|
+
return {
|
|
288
|
+
signal: timeoutSignal,
|
|
289
|
+
wasAbortedByCaller: () => false,
|
|
290
|
+
didTimeout: () => timeoutSignal.aborted,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
signal: anyAbortSignal([abortSignal, timeoutSignal]),
|
|
295
|
+
wasAbortedByCaller: () => abortSignal.aborted,
|
|
296
|
+
didTimeout: () => timeoutSignal.aborted,
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
async function waitForRuntimeFileContentFetchOperation(operation, input, fetchSignal, timeoutMs) {
|
|
300
|
+
let abortError;
|
|
301
|
+
let removeAbortListener = () => { };
|
|
302
|
+
const abortPromise = new Promise((_, reject) => {
|
|
303
|
+
const rejectAbort = () => {
|
|
304
|
+
abortError = createRuntimeFileContentAbortError(input, fetchSignal, timeoutMs);
|
|
305
|
+
reject(abortError);
|
|
306
|
+
};
|
|
307
|
+
if (fetchSignal.signal.aborted) {
|
|
308
|
+
rejectAbort();
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
fetchSignal.signal.addEventListener("abort", rejectAbort, { once: true });
|
|
312
|
+
removeAbortListener = () => fetchSignal.signal.removeEventListener("abort", rejectAbort);
|
|
313
|
+
});
|
|
314
|
+
try {
|
|
315
|
+
return await Promise.race([operation, abortPromise]);
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
if (error === abortError) {
|
|
319
|
+
throw error;
|
|
320
|
+
}
|
|
321
|
+
const abortFailure = createRuntimeFileContentAbortError(input, fetchSignal, timeoutMs, error);
|
|
322
|
+
if (abortFailure) {
|
|
323
|
+
throw abortFailure;
|
|
324
|
+
}
|
|
325
|
+
throw error;
|
|
326
|
+
}
|
|
327
|
+
finally {
|
|
328
|
+
removeAbortListener();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
function createRuntimeFileContentAbortError(input, fetchSignal, timeoutMs, cause) {
|
|
332
|
+
if (fetchSignal.wasAbortedByCaller()) {
|
|
333
|
+
return new Error(`Failed to fetch text attachment content${formatFileContentFetchLabel(input)}: request aborted`, { cause });
|
|
334
|
+
}
|
|
335
|
+
if (fetchSignal.didTimeout()) {
|
|
336
|
+
return new Error(`Failed to fetch text attachment content${formatFileContentFetchLabel(input)}: request timed out after ${timeoutMs}ms`, { cause });
|
|
337
|
+
}
|
|
338
|
+
return undefined;
|
|
339
|
+
}
|
|
340
|
+
function formatFileContentFetchLabel(input) {
|
|
341
|
+
const label = input.filename ?? input.uploadId ?? input.uploadPath;
|
|
342
|
+
return label ? ` for ${label}` : "";
|
|
343
|
+
}
|
|
344
|
+
function isFetchableRuntimeFileContentUrl(url, trustedUrls) {
|
|
345
|
+
if (url.startsWith("data:")) {
|
|
346
|
+
return true;
|
|
347
|
+
}
|
|
348
|
+
return trustedUrls?.has(url) ?? false;
|
|
349
|
+
}
|
|
350
|
+
function normalizeInlineFileContent(content) {
|
|
351
|
+
if (!content || content.trim().length === 0)
|
|
352
|
+
return undefined;
|
|
353
|
+
if (content.length <= MAX_INLINE_FILE_CONTENT_CHARS) {
|
|
354
|
+
return { content, truncated: false };
|
|
355
|
+
}
|
|
356
|
+
return { content: content.slice(0, MAX_INLINE_FILE_CONTENT_CHARS), truncated: true };
|
|
357
|
+
}
|
|
358
|
+
function escapeXmlAttr(value) {
|
|
359
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
360
|
+
}
|
|
361
|
+
function buildInlineFileContentText(part, content) {
|
|
362
|
+
const name = part.filename ?? part.uploadId ?? "file";
|
|
363
|
+
return `Attached file content:\n\n<file_content name="${escapeXmlAttr(name)}" type="${escapeXmlAttr(part.mediaType)}">\n${content}\n</file_content>`;
|
|
364
|
+
}
|
|
72
365
|
function toResolverPart(part, uploadId) {
|
|
73
366
|
const normalized = normalizeUploadedFilePart(part, uploadId);
|
|
74
367
|
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();
|