veryfront 0.1.372 → 0.1.374
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 +11 -0
- package/esm/deno.js +13 -1
- package/esm/src/agent/index.d.ts +2 -0
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +2 -0
- package/esm/src/agent/project-context.d.ts +8 -0
- package/esm/src/agent/project-context.d.ts.map +1 -0
- package/esm/src/agent/project-context.js +40 -0
- package/esm/src/agent/project-steering-mutation.d.ts +23 -0
- package/esm/src/agent/project-steering-mutation.d.ts.map +1 -0
- package/esm/src/agent/project-steering-mutation.js +72 -0
- package/esm/src/embedding/resolve.d.ts.map +1 -1
- package/esm/src/embedding/resolve.js +11 -2
- package/esm/src/embedding/veryfront-cloud/provider.d.ts.map +1 -1
- package/esm/src/embedding/veryfront-cloud/provider.js +18 -8
- package/esm/src/provider/model-registry.d.ts.map +1 -1
- package/esm/src/provider/model-registry.js +11 -2
- package/esm/src/provider/runtime-loader.d.ts +6 -11
- package/esm/src/provider/runtime-loader.d.ts.map +1 -1
- package/esm/src/provider/runtime-loader.js +7 -512
- package/esm/src/provider/shared/index.d.ts +2 -2
- package/esm/src/provider/shared/index.d.ts.map +1 -1
- package/esm/src/provider/shared/index.js +1 -1
- package/esm/src/provider/veryfront-cloud/provider.d.ts.map +1 -1
- package/esm/src/provider/veryfront-cloud/provider.js +14 -11
- 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/src/deno.js +13 -1
- package/src/deps/esm.sh/@types/react-dom@19.2.3/client.d.ts +1 -1
- package/src/deps/esm.sh/@types/{react@19.2.3 → react@19.2.14}/global.d.ts +1 -0
- package/src/deps/esm.sh/@types/{react@19.2.3 → react@19.2.14}/index.d.ts +93 -24
- package/src/deps/esm.sh/react-dom@19.2.4/client.d.ts +1 -1
- package/src/src/agent/index.ts +15 -0
- package/src/src/agent/project-context.ts +63 -0
- package/src/src/agent/project-steering-mutation.ts +126 -0
- package/src/src/embedding/resolve.ts +14 -2
- package/src/src/embedding/veryfront-cloud/provider.ts +22 -8
- package/src/src/provider/model-registry.ts +14 -2
- package/src/src/provider/runtime-loader.ts +8 -672
- package/src/src/provider/shared/index.ts +4 -0
- package/src/src/provider/veryfront-cloud/provider.ts +16 -11
- package/src/src/utils/version-constant.ts +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { getAnthropicMessagesUrl
|
|
2
|
-
import {
|
|
3
|
-
import { normalizeAnthropicFinishReason
|
|
4
|
-
import { createAnthropicRequestInit
|
|
1
|
+
import { getAnthropicMessagesUrl } from "./runtime-loader/provider-endpoints.js";
|
|
2
|
+
import { isNumberArray } from "./runtime-loader/provider-embedding-responses.js";
|
|
3
|
+
import { normalizeAnthropicFinishReason } from "./runtime-loader/provider-finish-reasons.js";
|
|
4
|
+
import { createAnthropicRequestInit } from "./runtime-loader/provider-request-init.js";
|
|
5
5
|
import { parseSseChunk } from "./runtime-loader/provider-sse.js";
|
|
6
|
-
import { extractAnthropicUsage,
|
|
6
|
+
import { extractAnthropicUsage, mergeUsage, } from "./runtime-loader/provider-usage.js";
|
|
7
7
|
import { buildProviderError, parseRetryAfterMs, requestJson, requestStream, } from "./runtime-loader/provider-http.js";
|
|
8
8
|
import { readRecord } from "./runtime-loader/provider-records.js";
|
|
9
9
|
import { TOOL_INPUT_PENDING_THRESHOLD_MS, withToolInputStatusTransitions, } from "./runtime-loader/tool-input-status.js";
|
|
10
10
|
export { ProviderError, ProviderOverloadedError, ProviderQuotaError, ProviderRateLimitError, ProviderRequestError, } from "./runtime-loader/provider-http.js";
|
|
11
11
|
export { TOOL_INPUT_PENDING_THRESHOLD_MS, withToolInputStatusTransitions };
|
|
12
|
-
export { buildProviderError, isNumberArray, mergeUsage, parseRetryAfterMs, readRecord, requestJson, requestStream, };
|
|
12
|
+
export { buildProviderError, isNumberArray, mergeUsage, parseRetryAfterMs, parseSseChunk, readRecord, requestJson, requestStream, };
|
|
13
13
|
export function createWarningCollector() {
|
|
14
14
|
const list = [];
|
|
15
15
|
return {
|
|
@@ -827,421 +827,13 @@ async function* streamAnthropicCompatibleParts(stream) {
|
|
|
827
827
|
...(usage ? { usage } : {}),
|
|
828
828
|
};
|
|
829
829
|
}
|
|
830
|
-
function
|
|
831
|
-
const systemParts = [];
|
|
832
|
-
const contents = [];
|
|
833
|
-
for (const message of prompt) {
|
|
834
|
-
switch (message.role) {
|
|
835
|
-
case "system":
|
|
836
|
-
if (message.content.length > 0) {
|
|
837
|
-
systemParts.push(message.content);
|
|
838
|
-
}
|
|
839
|
-
break;
|
|
840
|
-
case "user":
|
|
841
|
-
contents.push({
|
|
842
|
-
role: "user",
|
|
843
|
-
parts: [{ text: readTextParts(message.content) }],
|
|
844
|
-
});
|
|
845
|
-
break;
|
|
846
|
-
case "assistant": {
|
|
847
|
-
// Anthropic-only `reasoning` parts have no Gemini equivalent
|
|
848
|
-
// and are dropped on replay.
|
|
849
|
-
const parts = [];
|
|
850
|
-
for (const part of message.content) {
|
|
851
|
-
if (part.type === "text") {
|
|
852
|
-
parts.push({ text: part.text });
|
|
853
|
-
continue;
|
|
854
|
-
}
|
|
855
|
-
if (part.type === "reasoning") {
|
|
856
|
-
continue;
|
|
857
|
-
}
|
|
858
|
-
parts.push({
|
|
859
|
-
functionCall: {
|
|
860
|
-
id: part.toolCallId,
|
|
861
|
-
name: part.toolName,
|
|
862
|
-
args: part.input,
|
|
863
|
-
},
|
|
864
|
-
});
|
|
865
|
-
}
|
|
866
|
-
contents.push({ role: "model", parts });
|
|
867
|
-
break;
|
|
868
|
-
}
|
|
869
|
-
case "tool":
|
|
870
|
-
contents.push({
|
|
871
|
-
role: "user",
|
|
872
|
-
parts: message.content.map((part) => ({
|
|
873
|
-
functionResponse: {
|
|
874
|
-
id: part.toolCallId,
|
|
875
|
-
name: part.toolName,
|
|
876
|
-
response: {
|
|
877
|
-
result: part.output.value,
|
|
878
|
-
},
|
|
879
|
-
},
|
|
880
|
-
})),
|
|
881
|
-
});
|
|
882
|
-
break;
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
return {
|
|
886
|
-
...(systemParts.length > 0
|
|
887
|
-
? { systemInstruction: { parts: systemParts.map((text) => ({ text })) } }
|
|
888
|
-
: {}),
|
|
889
|
-
contents,
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
function toGoogleTools(tools) {
|
|
893
|
-
if (!tools) {
|
|
894
|
-
return undefined;
|
|
895
|
-
}
|
|
896
|
-
const functionDeclarations = [];
|
|
897
|
-
const providerEntries = [];
|
|
898
|
-
for (const tool of tools) {
|
|
899
|
-
if (tool.type === "function") {
|
|
900
|
-
functionDeclarations.push({
|
|
901
|
-
name: tool.name,
|
|
902
|
-
...(typeof tool.description === "string" ? { description: tool.description } : {}),
|
|
903
|
-
parameters: unwrapToolInputSchema(tool.inputSchema),
|
|
904
|
-
});
|
|
905
|
-
continue;
|
|
906
|
-
}
|
|
907
|
-
// Gemini provider tools — code_execution, google_search,
|
|
908
|
-
// google_search_retrieval — each lives in its own tools[] entry
|
|
909
|
-
// with a single key keyed by the camelCase tool name and an
|
|
910
|
-
// optional config payload (caller-provided tool.args).
|
|
911
|
-
if (!tool.id.startsWith("google.")) {
|
|
912
|
-
continue;
|
|
913
|
-
}
|
|
914
|
-
const providerType = tool.id.slice("google.".length);
|
|
915
|
-
if (providerType.length === 0) {
|
|
916
|
-
continue;
|
|
917
|
-
}
|
|
918
|
-
const camelKey = providerType.replace(/_([a-z])/g, (_, ch) => ch.toUpperCase());
|
|
919
|
-
providerEntries.push({ [camelKey]: tool.args ?? {} });
|
|
920
|
-
}
|
|
921
|
-
const result = [];
|
|
922
|
-
if (functionDeclarations.length > 0) {
|
|
923
|
-
result.push({ functionDeclarations });
|
|
924
|
-
}
|
|
925
|
-
result.push(...providerEntries);
|
|
926
|
-
return result.length > 0 ? result : undefined;
|
|
927
|
-
}
|
|
928
|
-
function unwrapToolInputSchema(inputSchema) {
|
|
830
|
+
export function unwrapToolInputSchema(inputSchema) {
|
|
929
831
|
if (typeof inputSchema !== "object" || inputSchema === null || Array.isArray(inputSchema)) {
|
|
930
832
|
return inputSchema;
|
|
931
833
|
}
|
|
932
834
|
const candidate = Reflect.get(inputSchema, "jsonSchema");
|
|
933
835
|
return candidate ?? inputSchema;
|
|
934
836
|
}
|
|
935
|
-
function normalizeGoogleToolChoice(toolChoice) {
|
|
936
|
-
if (toolChoice === undefined) {
|
|
937
|
-
return undefined;
|
|
938
|
-
}
|
|
939
|
-
if (typeof toolChoice === "string") {
|
|
940
|
-
switch (toolChoice) {
|
|
941
|
-
case "none":
|
|
942
|
-
return { functionCallingConfig: { mode: "NONE" } };
|
|
943
|
-
case "any":
|
|
944
|
-
case "required":
|
|
945
|
-
return { functionCallingConfig: { mode: "ANY" } };
|
|
946
|
-
default:
|
|
947
|
-
return { functionCallingConfig: { mode: "AUTO" } };
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
const record = readRecord(toolChoice);
|
|
951
|
-
if (!record)
|
|
952
|
-
return undefined;
|
|
953
|
-
// Single-tool restriction: { type: "tool", name } — pin to one
|
|
954
|
-
// function via mode: ANY + allowedFunctionNames: [name].
|
|
955
|
-
if (record.type === "tool" && typeof record.name === "string") {
|
|
956
|
-
return {
|
|
957
|
-
functionCallingConfig: {
|
|
958
|
-
mode: "ANY",
|
|
959
|
-
allowedFunctionNames: [record.name],
|
|
960
|
-
},
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
// Multi-tool restriction: { type: "tools", names: string[] } — pin
|
|
964
|
-
// to a subset via mode: ANY + the full allowedFunctionNames array.
|
|
965
|
-
if (record.type === "tools" && Array.isArray(record.names)) {
|
|
966
|
-
const names = record.names.filter((n) => typeof n === "string");
|
|
967
|
-
if (names.length > 0) {
|
|
968
|
-
return {
|
|
969
|
-
functionCallingConfig: {
|
|
970
|
-
mode: "ANY",
|
|
971
|
-
allowedFunctionNames: names,
|
|
972
|
-
},
|
|
973
|
-
};
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
// Explicit mode forms: { type: "auto" | "none" | "any" }.
|
|
977
|
-
if (record.type === "auto") {
|
|
978
|
-
return { functionCallingConfig: { mode: "AUTO" } };
|
|
979
|
-
}
|
|
980
|
-
if (record.type === "none") {
|
|
981
|
-
return { functionCallingConfig: { mode: "NONE" } };
|
|
982
|
-
}
|
|
983
|
-
if (record.type === "any" || record.type === "required") {
|
|
984
|
-
return { functionCallingConfig: { mode: "ANY" } };
|
|
985
|
-
}
|
|
986
|
-
return undefined;
|
|
987
|
-
}
|
|
988
|
-
/**
|
|
989
|
-
* Map the unified reasoning option to Gemini's thinkingConfig. Gemini 2.5+
|
|
990
|
-
* accepts `includeThoughts: true` to stream back `thought` parts, and
|
|
991
|
-
* `thinkingBudget: N` to cap the thinking token count. The effort levels
|
|
992
|
-
* here follow Google's own guidance (low ~= 512, medium ~= 2048,
|
|
993
|
-
* high ~= 8192, max = -1 means "dynamic/no cap").
|
|
994
|
-
*/
|
|
995
|
-
function resolveGoogleThinkingConfig(option) {
|
|
996
|
-
if (!option || option.enabled !== true) {
|
|
997
|
-
return undefined;
|
|
998
|
-
}
|
|
999
|
-
const config = { includeThoughts: true };
|
|
1000
|
-
if (typeof option.budgetTokens === "number") {
|
|
1001
|
-
config.thinkingBudget = option.budgetTokens;
|
|
1002
|
-
return config;
|
|
1003
|
-
}
|
|
1004
|
-
switch (option.effort) {
|
|
1005
|
-
case "low":
|
|
1006
|
-
config.thinkingBudget = 512;
|
|
1007
|
-
break;
|
|
1008
|
-
case "high":
|
|
1009
|
-
config.thinkingBudget = 8192;
|
|
1010
|
-
break;
|
|
1011
|
-
case "max":
|
|
1012
|
-
config.thinkingBudget = -1;
|
|
1013
|
-
break;
|
|
1014
|
-
case "medium":
|
|
1015
|
-
default:
|
|
1016
|
-
config.thinkingBudget = 2048;
|
|
1017
|
-
break;
|
|
1018
|
-
}
|
|
1019
|
-
return config;
|
|
1020
|
-
}
|
|
1021
|
-
function buildGoogleGenerationConfig(options) {
|
|
1022
|
-
const thinkingConfig = resolveGoogleThinkingConfig(options.reasoning);
|
|
1023
|
-
const config = {
|
|
1024
|
-
...(options.maxOutputTokens !== undefined ? { maxOutputTokens: options.maxOutputTokens } : {}),
|
|
1025
|
-
...(options.temperature !== undefined ? { temperature: options.temperature } : {}),
|
|
1026
|
-
...(options.topP !== undefined ? { topP: options.topP } : {}),
|
|
1027
|
-
...(options.topK !== undefined ? { topK: options.topK } : {}),
|
|
1028
|
-
...(options.stopSequences && options.stopSequences.length > 0
|
|
1029
|
-
? { stopSequences: options.stopSequences }
|
|
1030
|
-
: {}),
|
|
1031
|
-
...(options.seed !== undefined ? { seed: options.seed } : {}),
|
|
1032
|
-
...(thinkingConfig ? { thinkingConfig } : {}),
|
|
1033
|
-
};
|
|
1034
|
-
return Object.keys(config).length > 0 ? config : undefined;
|
|
1035
|
-
}
|
|
1036
|
-
function buildGoogleGenerateContentRequest(providerName, options, warnings) {
|
|
1037
|
-
// Google generate-content surface doesn't accept presence/frequency
|
|
1038
|
-
// penalties on most current models. Emit warnings and let the request
|
|
1039
|
-
// through without them.
|
|
1040
|
-
if (options.presencePenalty !== undefined) {
|
|
1041
|
-
warnings.push({
|
|
1042
|
-
type: "unsupported-setting",
|
|
1043
|
-
provider: "google",
|
|
1044
|
-
setting: "presencePenalty",
|
|
1045
|
-
details: "Gemini generateContent does not accept presencePenalty; the value was dropped.",
|
|
1046
|
-
});
|
|
1047
|
-
}
|
|
1048
|
-
if (options.frequencyPenalty !== undefined) {
|
|
1049
|
-
warnings.push({
|
|
1050
|
-
type: "unsupported-setting",
|
|
1051
|
-
provider: "google",
|
|
1052
|
-
setting: "frequencyPenalty",
|
|
1053
|
-
details: "Gemini generateContent does not accept frequencyPenalty; the value was dropped.",
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1056
|
-
if (options.responseFormat && options.responseFormat.type !== "text") {
|
|
1057
|
-
warnings.push({
|
|
1058
|
-
type: "unsupported-setting",
|
|
1059
|
-
provider: "google",
|
|
1060
|
-
setting: "responseFormat",
|
|
1061
|
-
details: "Gemini uses generationConfig.responseMimeType + responseSchema for structured outputs, which is a separate surface and not yet wired through this option.",
|
|
1062
|
-
});
|
|
1063
|
-
}
|
|
1064
|
-
const { systemInstruction, contents } = toGoogleContents(options.prompt);
|
|
1065
|
-
const generationConfig = buildGoogleGenerationConfig(options);
|
|
1066
|
-
// requestLabels wins over userId-derived labels: when callers explicitly
|
|
1067
|
-
// provide a label map, that's the source of truth. Otherwise fall back
|
|
1068
|
-
// to {user_id} derived from the unified userId option.
|
|
1069
|
-
const labels = options.requestLabels && Object.keys(options.requestLabels).length > 0
|
|
1070
|
-
? options.requestLabels
|
|
1071
|
-
: typeof options.userId === "string" && options.userId.length > 0
|
|
1072
|
-
? { user_id: options.userId }
|
|
1073
|
-
: undefined;
|
|
1074
|
-
const body = {
|
|
1075
|
-
contents,
|
|
1076
|
-
...(systemInstruction ? { systemInstruction } : {}),
|
|
1077
|
-
...(toGoogleTools(options.tools) ? { tools: toGoogleTools(options.tools) } : {}),
|
|
1078
|
-
...(normalizeGoogleToolChoice(options.toolChoice)
|
|
1079
|
-
? { toolConfig: normalizeGoogleToolChoice(options.toolChoice) }
|
|
1080
|
-
: {}),
|
|
1081
|
-
...(generationConfig ? { generationConfig } : {}),
|
|
1082
|
-
...(labels ? { labels } : {}),
|
|
1083
|
-
...(typeof options.googleCachedContent === "string" && options.googleCachedContent.length > 0
|
|
1084
|
-
? { cachedContent: options.googleCachedContent }
|
|
1085
|
-
: {}),
|
|
1086
|
-
...(options.googleSafetySettings && options.googleSafetySettings.length > 0
|
|
1087
|
-
? { safetySettings: options.googleSafetySettings }
|
|
1088
|
-
: {}),
|
|
1089
|
-
};
|
|
1090
|
-
Object.assign(body, readProviderOptions(options.providerOptions, "google", providerName));
|
|
1091
|
-
return body;
|
|
1092
|
-
}
|
|
1093
|
-
function extractFirstGoogleCandidate(payload) {
|
|
1094
|
-
const record = readRecord(payload);
|
|
1095
|
-
const candidates = record?.candidates;
|
|
1096
|
-
if (!Array.isArray(candidates) || candidates.length === 0) {
|
|
1097
|
-
return undefined;
|
|
1098
|
-
}
|
|
1099
|
-
return readRecord(candidates[0]);
|
|
1100
|
-
}
|
|
1101
|
-
function extractGoogleCandidateParts(payload) {
|
|
1102
|
-
const candidate = extractFirstGoogleCandidate(payload);
|
|
1103
|
-
const content = readRecord(candidate?.content);
|
|
1104
|
-
const parts = content?.parts;
|
|
1105
|
-
if (!Array.isArray(parts)) {
|
|
1106
|
-
return [];
|
|
1107
|
-
}
|
|
1108
|
-
return parts.flatMap((part) => {
|
|
1109
|
-
const record = readRecord(part);
|
|
1110
|
-
return record ? [record] : [];
|
|
1111
|
-
});
|
|
1112
|
-
}
|
|
1113
|
-
function buildGoogleGenerateResult(payload) {
|
|
1114
|
-
const parts = extractGoogleCandidateParts(payload);
|
|
1115
|
-
const content = [];
|
|
1116
|
-
for (const [index, part] of parts.entries()) {
|
|
1117
|
-
if (typeof part.text === "string" && part.text.length > 0) {
|
|
1118
|
-
content.push({ type: "text", text: part.text });
|
|
1119
|
-
continue;
|
|
1120
|
-
}
|
|
1121
|
-
const functionCall = readRecord(part.functionCall);
|
|
1122
|
-
if (typeof functionCall?.name === "string") {
|
|
1123
|
-
content.push({
|
|
1124
|
-
type: "tool-call",
|
|
1125
|
-
toolCallId: typeof functionCall.id === "string" ? functionCall.id : `tool-${index}`,
|
|
1126
|
-
toolName: functionCall.name,
|
|
1127
|
-
input: stringifyJsonValue(functionCall.args ?? {}),
|
|
1128
|
-
});
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
// Gemini grounding (google_search / google_search_retrieval) returns
|
|
1132
|
-
// a per-candidate groundingMetadata object with web search queries,
|
|
1133
|
-
// grounding chunks, and citation indices into the response text.
|
|
1134
|
-
// Pass it through opaquely so callers can render footnotes / source
|
|
1135
|
-
// chips / "Search results" UI without parsing the wire shape.
|
|
1136
|
-
const candidate = extractFirstGoogleCandidate(payload);
|
|
1137
|
-
const groundingMetadata = readRecord(candidate?.groundingMetadata);
|
|
1138
|
-
return {
|
|
1139
|
-
content,
|
|
1140
|
-
finishReason: normalizeGoogleFinishReason(candidate?.finishReason),
|
|
1141
|
-
usage: extractGoogleUsage(payload),
|
|
1142
|
-
...(groundingMetadata ? { groundingMetadata } : {}),
|
|
1143
|
-
};
|
|
1144
|
-
}
|
|
1145
|
-
async function* streamGoogleCompatibleParts(stream) {
|
|
1146
|
-
const decoder = new TextDecoder();
|
|
1147
|
-
let buffer = "";
|
|
1148
|
-
const seenToolCalls = new Set();
|
|
1149
|
-
let reasoningId = null;
|
|
1150
|
-
let reasoningIndex = 0;
|
|
1151
|
-
let finishReason = null;
|
|
1152
|
-
let usage;
|
|
1153
|
-
for await (const chunk of stream) {
|
|
1154
|
-
buffer += decoder.decode(chunk, { stream: true });
|
|
1155
|
-
const parsed = parseSseChunk(buffer);
|
|
1156
|
-
buffer = parsed.remainder;
|
|
1157
|
-
for (const event of parsed.events) {
|
|
1158
|
-
if (event === "[DONE]") {
|
|
1159
|
-
continue;
|
|
1160
|
-
}
|
|
1161
|
-
usage = extractGoogleUsage(event) ?? usage;
|
|
1162
|
-
const candidate = extractFirstGoogleCandidate(event);
|
|
1163
|
-
const normalizedFinishReason = normalizeGoogleFinishReason(candidate?.finishReason);
|
|
1164
|
-
if (normalizedFinishReason) {
|
|
1165
|
-
finishReason = normalizedFinishReason;
|
|
1166
|
-
}
|
|
1167
|
-
for (const [index, part] of extractGoogleCandidateParts(event).entries()) {
|
|
1168
|
-
const isThought = part.thought === true;
|
|
1169
|
-
if (isThought && typeof part.text === "string" && part.text.length > 0) {
|
|
1170
|
-
if (!reasoningId) {
|
|
1171
|
-
reasoningId = `reasoning-${reasoningIndex++}`;
|
|
1172
|
-
yield {
|
|
1173
|
-
type: "reasoning-start",
|
|
1174
|
-
id: reasoningId,
|
|
1175
|
-
};
|
|
1176
|
-
}
|
|
1177
|
-
yield {
|
|
1178
|
-
type: "reasoning-delta",
|
|
1179
|
-
id: reasoningId,
|
|
1180
|
-
delta: part.text,
|
|
1181
|
-
};
|
|
1182
|
-
continue;
|
|
1183
|
-
}
|
|
1184
|
-
if (reasoningId) {
|
|
1185
|
-
yield {
|
|
1186
|
-
type: "reasoning-end",
|
|
1187
|
-
id: reasoningId,
|
|
1188
|
-
};
|
|
1189
|
-
reasoningId = null;
|
|
1190
|
-
}
|
|
1191
|
-
if (typeof part.text === "string" && part.text.length > 0) {
|
|
1192
|
-
yield { type: "text-delta", delta: part.text };
|
|
1193
|
-
continue;
|
|
1194
|
-
}
|
|
1195
|
-
const functionCall = readRecord(part.functionCall);
|
|
1196
|
-
if (typeof functionCall?.name !== "string") {
|
|
1197
|
-
continue;
|
|
1198
|
-
}
|
|
1199
|
-
const toolCallId = typeof functionCall.id === "string" ? functionCall.id : `tool-${index}`;
|
|
1200
|
-
if (seenToolCalls.has(toolCallId)) {
|
|
1201
|
-
continue;
|
|
1202
|
-
}
|
|
1203
|
-
const serializedInput = stringifyJsonValue(functionCall.args ?? {});
|
|
1204
|
-
seenToolCalls.add(toolCallId);
|
|
1205
|
-
yield {
|
|
1206
|
-
type: "tool-input-start",
|
|
1207
|
-
id: toolCallId,
|
|
1208
|
-
toolName: functionCall.name,
|
|
1209
|
-
};
|
|
1210
|
-
yield {
|
|
1211
|
-
type: "tool-input-delta",
|
|
1212
|
-
id: toolCallId,
|
|
1213
|
-
delta: serializedInput,
|
|
1214
|
-
};
|
|
1215
|
-
yield {
|
|
1216
|
-
type: "tool-call",
|
|
1217
|
-
toolCallId,
|
|
1218
|
-
toolName: functionCall.name,
|
|
1219
|
-
input: serializedInput,
|
|
1220
|
-
};
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
if (buffer.trim().length > 0) {
|
|
1225
|
-
const parsed = parseSseChunk(`${buffer}\n\n`);
|
|
1226
|
-
for (const event of parsed.events) {
|
|
1227
|
-
if (event === "[DONE]") {
|
|
1228
|
-
continue;
|
|
1229
|
-
}
|
|
1230
|
-
usage = extractGoogleUsage(event) ?? usage;
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
if (reasoningId) {
|
|
1234
|
-
yield {
|
|
1235
|
-
type: "reasoning-end",
|
|
1236
|
-
id: reasoningId,
|
|
1237
|
-
};
|
|
1238
|
-
}
|
|
1239
|
-
yield {
|
|
1240
|
-
type: "finish",
|
|
1241
|
-
finishReason,
|
|
1242
|
-
...(usage ? { usage } : {}),
|
|
1243
|
-
};
|
|
1244
|
-
}
|
|
1245
837
|
export function createAnthropicModelRuntime(config, modelId) {
|
|
1246
838
|
const fetchImpl = config.fetch ?? globalThis.fetch;
|
|
1247
839
|
return {
|
|
@@ -1302,100 +894,3 @@ export function createAnthropicModelRuntime(config, modelId) {
|
|
|
1302
894
|
},
|
|
1303
895
|
};
|
|
1304
896
|
}
|
|
1305
|
-
export function createGoogleModelRuntime(config, modelId) {
|
|
1306
|
-
const fetchImpl = config.fetch ?? globalThis.fetch;
|
|
1307
|
-
return {
|
|
1308
|
-
provider: config.name ?? "google",
|
|
1309
|
-
modelId,
|
|
1310
|
-
specificationVersion: "v3",
|
|
1311
|
-
supportedUrls: {},
|
|
1312
|
-
doGenerate(optionsForRuntime) {
|
|
1313
|
-
const options = optionsForRuntime;
|
|
1314
|
-
const url = getGoogleGenerateContentUrl(config.baseURL, modelId);
|
|
1315
|
-
const warnings = createWarningCollector();
|
|
1316
|
-
const body = buildGoogleGenerateContentRequest(config.name ?? "google", options, warnings);
|
|
1317
|
-
return requestJson({
|
|
1318
|
-
url,
|
|
1319
|
-
fetchImpl,
|
|
1320
|
-
providerLabel: config.name ?? "google",
|
|
1321
|
-
providerKind: "google",
|
|
1322
|
-
init: createGoogleRequestInit({
|
|
1323
|
-
apiKey: config.apiKey,
|
|
1324
|
-
extraHeaders: options.headers,
|
|
1325
|
-
body: JSON.stringify(body),
|
|
1326
|
-
signal: options.abortSignal,
|
|
1327
|
-
}),
|
|
1328
|
-
}).then((payload) => {
|
|
1329
|
-
const drained = warnings.drain();
|
|
1330
|
-
return {
|
|
1331
|
-
...buildGoogleGenerateResult(payload),
|
|
1332
|
-
...(drained.length > 0 ? { warnings: drained } : {}),
|
|
1333
|
-
};
|
|
1334
|
-
});
|
|
1335
|
-
},
|
|
1336
|
-
doStream(optionsForRuntime) {
|
|
1337
|
-
const options = optionsForRuntime;
|
|
1338
|
-
const url = getGoogleStreamGenerateContentUrl(config.baseURL, modelId);
|
|
1339
|
-
const warnings = createWarningCollector();
|
|
1340
|
-
const body = buildGoogleGenerateContentRequest(config.name ?? "google", options, warnings);
|
|
1341
|
-
return requestStream({
|
|
1342
|
-
url,
|
|
1343
|
-
fetchImpl,
|
|
1344
|
-
providerLabel: config.name ?? "google",
|
|
1345
|
-
providerKind: "google",
|
|
1346
|
-
init: createGoogleRequestInit({
|
|
1347
|
-
apiKey: config.apiKey,
|
|
1348
|
-
extraHeaders: options.headers,
|
|
1349
|
-
body: JSON.stringify(body),
|
|
1350
|
-
signal: options.abortSignal,
|
|
1351
|
-
}),
|
|
1352
|
-
}).then((responseStream) => {
|
|
1353
|
-
const drained = warnings.drain();
|
|
1354
|
-
return {
|
|
1355
|
-
stream: ReadableStream.from(withToolInputStatusTransitions(streamGoogleCompatibleParts(responseStream))),
|
|
1356
|
-
...(drained.length > 0 ? { warnings: drained } : {}),
|
|
1357
|
-
};
|
|
1358
|
-
});
|
|
1359
|
-
},
|
|
1360
|
-
};
|
|
1361
|
-
}
|
|
1362
|
-
export function createGoogleEmbeddingRuntime(config, modelId) {
|
|
1363
|
-
const fetchImpl = config.fetch ?? globalThis.fetch;
|
|
1364
|
-
return {
|
|
1365
|
-
provider: config.name ?? "google",
|
|
1366
|
-
modelId,
|
|
1367
|
-
supportsParallelCalls: true,
|
|
1368
|
-
doEmbed({ values, abortSignal }) {
|
|
1369
|
-
if (values.length === 0) {
|
|
1370
|
-
return Promise.resolve({
|
|
1371
|
-
embeddings: [],
|
|
1372
|
-
warnings: [],
|
|
1373
|
-
rawResponse: { embeddings: [] },
|
|
1374
|
-
});
|
|
1375
|
-
}
|
|
1376
|
-
const url = getGoogleEmbeddingUrl(config.baseURL, modelId);
|
|
1377
|
-
return Promise.all(values.map((value) => requestJson({
|
|
1378
|
-
url,
|
|
1379
|
-
fetchImpl,
|
|
1380
|
-
providerLabel: config.name ?? "google",
|
|
1381
|
-
providerKind: "google",
|
|
1382
|
-
init: createGoogleRequestInit({
|
|
1383
|
-
apiKey: config.apiKey,
|
|
1384
|
-
body: JSON.stringify({
|
|
1385
|
-
content: {
|
|
1386
|
-
parts: [{ text: value }],
|
|
1387
|
-
},
|
|
1388
|
-
}),
|
|
1389
|
-
signal: abortSignal,
|
|
1390
|
-
}),
|
|
1391
|
-
}))).then((payloads) => ({
|
|
1392
|
-
embeddings: payloads.map(extractGoogleEmbedding),
|
|
1393
|
-
usage: {
|
|
1394
|
-
tokens: payloads.reduce((total, payload) => total + (extractGoogleUsageTokens(payload) ?? 0), 0),
|
|
1395
|
-
},
|
|
1396
|
-
rawResponse: payloads,
|
|
1397
|
-
warnings: [],
|
|
1398
|
-
}));
|
|
1399
|
-
},
|
|
1400
|
-
};
|
|
1401
|
-
}
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
export { getAnthropicMessagesUrl, getGoogleEmbeddingUrl, getGoogleGenerateContentUrl, getGoogleStreamGenerateContentUrl, getOpenAIChatCompletionsUrl, getOpenAIEmbeddingUrl, getOpenAIResponsesUrl, } from "../runtime-loader/provider-endpoints.js";
|
|
12
12
|
export { createAnthropicRequestInit, createGoogleRequestInit, createOpenAIRequestInit, } from "../runtime-loader/provider-request-init.js";
|
|
13
13
|
export { TOOL_INPUT_PENDING_THRESHOLD_MS, withToolInputStatusTransitions, } from "../runtime-loader/tool-input-status.js";
|
|
14
|
-
export { buildProviderError, createWarningCollector, isNumberArray, mergeUsage, parseRetryAfterMs, ProviderError, ProviderOverloadedError, ProviderQuotaError, ProviderRateLimitError, ProviderRequestError, readProviderOptions, readRecord, readTextParts, requestJson, requestStream, stringifyJsonValue, toOpenAICompatibleMessages, toOpenAICompatibleTools, } from "../runtime-loader.js";
|
|
15
|
-
export type { OpenAICompatibleChatMessage, OpenAICompatibleChatRequest, RuntimePromptMessage, } from "../runtime-loader.js";
|
|
14
|
+
export { buildProviderError, createWarningCollector, isNumberArray, mergeUsage, parseRetryAfterMs, parseSseChunk, ProviderError, ProviderOverloadedError, ProviderQuotaError, ProviderRateLimitError, ProviderRequestError, readProviderOptions, readRecord, readTextParts, requestJson, requestStream, stringifyJsonValue, toOpenAICompatibleMessages, toOpenAICompatibleTools, unwrapToolInputSchema, } from "../runtime-loader.js";
|
|
15
|
+
export type { OpenAICompatibleChatMessage, OpenAICompatibleChatRequest, ProviderWarning, RuntimePromptMessage, RuntimeUsage, } from "../runtime-loader.js";
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,2BAA2B,EAC3B,iCAAiC,EACjC,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,4CAA4C,CAAC;AAGpD,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,GAC/B,MAAM,wCAAwC,CAAC;AAGhD,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/shared/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EACrB,2BAA2B,EAC3B,iCAAiC,EACjC,2BAA2B,EAC3B,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,4CAA4C,CAAC;AAGpD,OAAO,EACL,+BAA+B,EAC/B,8BAA8B,GAC/B,MAAM,wCAAwC,CAAC;AAGhD,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,EACV,aAAa,EACb,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,2BAA2B,EAC3B,2BAA2B,EAC3B,eAAe,EACf,oBAAoB,EACpB,YAAY,GACb,MAAM,sBAAsB,CAAC"}
|
|
@@ -15,4 +15,4 @@ export { createAnthropicRequestInit, createGoogleRequestInit, createOpenAIReques
|
|
|
15
15
|
// Tool-input status transitions
|
|
16
16
|
export { TOOL_INPUT_PENDING_THRESHOLD_MS, withToolInputStatusTransitions, } from "../runtime-loader/tool-input-status.js";
|
|
17
17
|
// Retry / error / HTTP plumbing (currently in runtime-loader.ts).
|
|
18
|
-
export { buildProviderError, createWarningCollector, isNumberArray, mergeUsage, parseRetryAfterMs, ProviderError, ProviderOverloadedError, ProviderQuotaError, ProviderRateLimitError, ProviderRequestError, readProviderOptions, readRecord, readTextParts, requestJson, requestStream, stringifyJsonValue, toOpenAICompatibleMessages, toOpenAICompatibleTools, } from "../runtime-loader.js";
|
|
18
|
+
export { buildProviderError, createWarningCollector, isNumberArray, mergeUsage, parseRetryAfterMs, parseSseChunk, ProviderError, ProviderOverloadedError, ProviderQuotaError, ProviderRateLimitError, ProviderRequestError, readProviderOptions, readRecord, readTextParts, requestJson, requestStream, stringifyJsonValue, toOpenAICompatibleMessages, toOpenAICompatibleTools, unwrapToolInputSchema, } from "../runtime-loader.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/veryfront-cloud/provider.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAShD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/veryfront-cloud/provider.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAShD,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAwEvE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createError, toError } from "../../errors/veryfront-error.js";
|
|
2
|
-
import { createAnthropicModelRuntime
|
|
2
|
+
import { createAnthropicModelRuntime } from "../runtime-loader.js";
|
|
3
3
|
import { tryResolve } from "../../extensions/contracts.js";
|
|
4
4
|
import { AIProviderRegistryName } from "../../extensions/interfaces/index.js";
|
|
5
5
|
import { createVeryfrontCloudFetch, getVeryfrontCloudGatewayBaseUrl, parseVeryfrontCloudModelId, requireVeryfrontCloudBootstrap, } from "./shared.js";
|
|
@@ -22,9 +22,6 @@ export function createVeryfrontCloudModel(modelId) {
|
|
|
22
22
|
fetch,
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
// Fall back to the built-in runtime-loader when the extension is not
|
|
26
|
-
// registered. Keeps Anthropic working until @veryfront/ext-anthropic is
|
|
27
|
-
// published to npm and adopted by all consumers.
|
|
28
25
|
return createAnthropicModelRuntime({
|
|
29
26
|
authToken: apiToken,
|
|
30
27
|
baseURL,
|
|
@@ -32,13 +29,19 @@ export function createVeryfrontCloudModel(modelId) {
|
|
|
32
29
|
fetch,
|
|
33
30
|
}, upstreamModelId);
|
|
34
31
|
}
|
|
35
|
-
case "google":
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
case "google": {
|
|
33
|
+
const registry = tryResolve(AIProviderRegistryName);
|
|
34
|
+
const google = registry?.get("google");
|
|
35
|
+
if (google) {
|
|
36
|
+
return google.createModel(upstreamModelId, {
|
|
37
|
+
credential: apiToken,
|
|
38
|
+
baseURL,
|
|
39
|
+
name: "veryfront-cloud",
|
|
40
|
+
fetch,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
throw new Error("Google provider not installed. Add @veryfront/ext-google to use google/* models via veryfront-cloud.");
|
|
44
|
+
}
|
|
42
45
|
case "openai":
|
|
43
46
|
case "moonshotai": {
|
|
44
47
|
const registry = tryResolve(AIProviderRegistryName);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.374";
|
|
2
2
|
//# sourceMappingURL=version-constant.d.ts.map
|
package/package.json
CHANGED
package/src/deno.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
"name": "veryfront",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.374",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"nodeModulesDir": "auto",
|
|
6
6
|
"workspace": [
|
|
7
7
|
"./extensions/ext-anthropic",
|
|
8
8
|
"./extensions/ext-babel",
|
|
9
|
+
"./extensions/ext-google",
|
|
9
10
|
"./extensions/ext-jwt",
|
|
10
11
|
"./extensions/ext-mdx",
|
|
11
12
|
"./extensions/ext-node-compat",
|
|
@@ -287,6 +288,17 @@ export default {
|
|
|
287
288
|
"unist": "npm:@types/unist@3.0.2",
|
|
288
289
|
"unified": "npm:unified@11.0.5",
|
|
289
290
|
"vfile": "npm:vfile@6.0.3",
|
|
291
|
+
"tailwindcss": "https://esm.sh/tailwindcss@4.2.2",
|
|
292
|
+
"tailwindcss/plugin": "https://esm.sh/tailwindcss@4.2.2/plugin",
|
|
293
|
+
"tailwindcss/defaultTheme": "https://esm.sh/tailwindcss@4.2.2/defaultTheme",
|
|
294
|
+
"tailwindcss/colors": "https://esm.sh/tailwindcss@4.2.2/colors",
|
|
295
|
+
"@opentelemetry/api": "npm:@opentelemetry/api@1.9.0",
|
|
296
|
+
"@opentelemetry/core": "npm:@opentelemetry/core@2.6.0",
|
|
297
|
+
"@opentelemetry/context-async-hooks": "npm:@opentelemetry/context-async-hooks@2.6.0",
|
|
298
|
+
"@opentelemetry/sdk-trace-base": "npm:@opentelemetry/sdk-trace-base@2.6.0",
|
|
299
|
+
"@opentelemetry/exporter-trace-otlp-http": "npm:@opentelemetry/exporter-trace-otlp-http@0.213.0",
|
|
300
|
+
"@opentelemetry/resources": "npm:@opentelemetry/resources@2.6.0",
|
|
301
|
+
"@opentelemetry/semantic-conventions": "npm:@opentelemetry/semantic-conventions@1.40.0",
|
|
290
302
|
"class-variance-authority": "npm:class-variance-authority@0.7.1",
|
|
291
303
|
"tailwind-merge": "npm:tailwind-merge@3.5.0",
|
|
292
304
|
"veryfront/chat/conversation": "./src/chat/conversation.ts",
|