nolo-cli 0.12.0-alpha.6 → 0.12.0-alpha.8
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/{_executeModel-3B6MKHQV.js → _executeModel-PKRZBH3J.js} +20 -19
- package/{action-RAXNQQKC.js → action-OTOWUMPW.js} +3 -3
- package/{addContentAction-ZHI7TVV3.js → addContentAction-JGBUVR7K.js} +2 -2
- package/{addDialogAgentAction-JWXPKXNC.js → addDialogAgentAction-V6CL2UCF.js} +1 -1
- package/{agentDeleteCommand-3R7OCLBN.js → agentDeleteCommand-OKQ5CSX2.js} +12 -11
- package/{agentEmailCommands-OENXTOPM.js → agentEmailCommands-7DORWXQH.js} +24 -23
- package/{agentListCommands-GX5YRFFK.js → agentListCommands-VTR33V4B.js} +13 -12
- package/{agentMachineCommands-5ZEL4NOJ.js → agentMachineCommands-XHFM4UQB.js} +12 -11
- package/{agentRecordCommands-EKGPNDCG.js → agentRecordCommands-XB7XBNJ7.js} +24 -23
- package/{agentRunCommand-KQYY46WS.js → agentRunCommand-XACEWDVO.js} +24 -23
- package/{agentRuntimeLocal-C2KYWS6H.js → agentRuntimeLocal-NYFVPD5P.js} +9 -8
- package/{agentSlice-N5RKI23B.js → agentSlice-NGZWIMZX.js} +2 -2
- package/{chunk-6TISG7CK.js → chunk-3GOA33JO.js} +69 -12
- package/{chunk-5HANPK6S.js → chunk-4LNEIK4O.js} +3 -3
- package/chunk-5MMAK75Q.js +15 -0
- package/{chunk-2VILMENT.js → chunk-6KTC3MPK.js} +1 -1
- package/{chunk-6VDWNLHX.js → chunk-7CQLSRAC.js} +2 -2
- package/{chunk-OLKX3NZI.js → chunk-7F5C7ILS.js} +3 -3
- package/{chunk-NIU4ERVM.js → chunk-A22NOC7Y.js} +24 -22
- package/{chunk-RFRU3HAL.js → chunk-CGAYFFIB.js} +1 -1
- package/{chunk-7MYHLZ3F.js → chunk-DPFWKRHG.js} +1 -1
- package/{chunk-Y3BLUPNS.js → chunk-H5Y2H2N6.js} +1 -1
- package/{chunk-ELYHT6P6.js → chunk-HO7RHQIN.js} +2 -2
- package/{chunk-RGJFQERV.js → chunk-HYJNPPQ6.js} +4 -4
- package/{chunk-NKD3Q4RN.js → chunk-JFANOO7I.js} +2 -14
- package/{chunk-WTYKCU4W.js → chunk-JU7J7EAV.js} +37 -37
- package/{chunk-NRJFU6WZ.js → chunk-LBWFOYJJ.js} +2 -2
- package/{chunk-Y3COB2JR.js → chunk-LKVDZQGM.js} +2 -2
- package/{chunk-7HV5OHEM.js → chunk-LUKQQJFL.js} +38 -1
- package/{chunk-FF7Y6DC4.js → chunk-NS3DRNUZ.js} +39 -12
- package/{chunk-7TNQ4ZZL.js → chunk-P3J54V3I.js} +1 -1
- package/{chunk-UG3WOFU6.js → chunk-QJSTNKJY.js} +1 -1
- package/{chunk-ISZEBXEV.js → chunk-QYZ46ZC3.js} +1 -1
- package/{chunk-B2Z7OJBT.js → chunk-REQCG2PB.js} +12 -99
- package/{chunk-6LMFFG3K.js → chunk-RWO5DGXI.js} +2 -2
- package/{chunk-J6PV7OYE.js → chunk-SDYIF6SV.js} +94 -1
- package/{chunk-MRX4BSKQ.js → chunk-SKURMCJF.js} +151 -15
- package/{chunk-6ADBTFFE.js → chunk-TA7VKOHU.js} +10 -5
- package/{chunk-WO24IT3V.js → chunk-TYPHUVK5.js} +12 -0
- package/{chunk-WMU5EZLC.js → chunk-UNEZBV37.js} +27 -13
- package/{chunk-KJTP7JTN.js → chunk-UP6JMU6C.js} +1 -1
- package/{chunk-I6IVZIIO.js → chunk-UWTMBOPF.js} +15 -10
- package/{chunk-NITP2JDG.js → chunk-VKG4HXYV.js} +1 -1
- package/{chunk-3HHTVM6G.js → chunk-WVTBAALN.js} +1 -1
- package/{chunk-OSGJQTG6.js → chunk-XNV42PMD.js} +18 -18
- package/{createAgentAutomationAction-NNXHZFSA.js → createAgentAutomationAction-AHSBJKGX.js} +8 -7
- package/{createDialogAction-TQCW67HG.js → createDialogAction-RSNVGR5E.js} +9 -8
- package/{createPageAction-QUFKG6A2.js → createPageAction-47G4D5WU.js} +8 -7
- package/{dbSlice-WDP2ZZHK.js → dbSlice-J4PUZ6Y5.js} +1 -1
- package/{dialogCommands-C6ERN2I7.js → dialogCommands-MPUFCOBR.js} +13 -12
- package/{dialogSlice-DAA3CWOV.js → dialogSlice-YNEFYFSU.js} +8 -7
- package/{docCreateCommands-KMYVYGZM.js → docCreateCommands-LV6KUDP3.js} +12 -11
- package/{docDeleteCommands-DZHIJA5D.js → docDeleteCommands-Y7FOYWMY.js} +13 -12
- package/{docReadCommands-VLJFYLR2.js → docReadCommands-UCCHERCP.js} +12 -11
- package/{docStore-67RBJMFZ.js → docStore-OBBYKQVD.js} +9 -8
- package/{docUpdateCommands-GOHV5JC5.js → docUpdateCommands-FBKQBFWG.js} +12 -11
- package/{handleSendMessageAction-7PNLNSPL.js → handleSendMessageAction-U5AX6CGB.js} +8 -7
- package/index.js +36 -36
- package/{machineCommands-J7FIVAZV.js → machineCommands-EXVWHGWU.js} +23 -22
- package/{machineWsRunDispatch-RWXFY6YG.js → machineWsRunDispatch-QZXCW3SI.js} +23 -22
- package/package.json +1 -1
- package/{readlineWorkspace-EMKKVMNH.js → readlineWorkspace-QKMGLM33.js} +134 -34
- package/{removeDialogAgentAction-GTX5AN54.js → removeDialogAgentAction-XUZYQBV4.js} +3 -3
- package/{runAgentClientLoop-VTA6RAHT.js → runAgentClientLoop-5DIJHAPN.js} +17 -16
- package/{setDialogExtraReferencesAction-WFQ63KYO.js → setDialogExtraReferencesAction-PTAIFKGM.js} +1 -1
- package/{setPrimaryDialogAgentAction-P57FXTSU.js → setPrimaryDialogAgentAction-HRFTDB44.js} +3 -3
- package/{settingSlice-CK5YZGNI.js → settingSlice-VGRJUSE5.js} +2 -2
- package/{spaceCommands-HLOEZVOV.js → spaceCommands-KDZYXP5N.js} +12 -11
- package/{spaceSlice-2X2TVI2V.js → spaceSlice-EO6JQRMP.js} +8 -7
- package/{streamAgentChatTurn-GFQ4YRJF.js → streamAgentChatTurn-PLKJ3MZ6.js} +20 -19
- package/{tools-PR47LTGM.js → tools-5QNY6YKE.js} +12 -11
- package/{tuiSummaryLlmCaller-YEHSPGXZ.js → tuiSummaryLlmCaller-TQ34DAM5.js} +4 -2
- package/{updateDialogTitleAction-4GI3W4LJ.js → updateDialogTitleAction-V5AD52MZ.js} +8 -7
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
buildLocalAgentLookupKeys,
|
|
13
13
|
normalizeAgentHandle,
|
|
14
14
|
shouldReadAgentKeyRemotely
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QYZ46ZC3.js";
|
|
16
16
|
import {
|
|
17
17
|
LOCAL_CODEX_AGENT_ID,
|
|
18
18
|
LOCAL_CODEX_AGENT_KEY,
|
|
@@ -21,19 +21,20 @@ import {
|
|
|
21
21
|
} from "./chunk-VHBWHNVT.js";
|
|
22
22
|
import {
|
|
23
23
|
inferCaptureIntent
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-QJSTNKJY.js";
|
|
25
25
|
import {
|
|
26
26
|
buildCliPrompt
|
|
27
27
|
} from "./chunk-ATNTHIZI.js";
|
|
28
28
|
import {
|
|
29
|
+
inlineImageUrlsForCustomProvider,
|
|
29
30
|
prepareTools
|
|
30
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-SDYIF6SV.js";
|
|
31
32
|
import {
|
|
32
33
|
getAntigravityUserAgent,
|
|
33
34
|
isAntigravityOAuthAgent,
|
|
34
35
|
readAntigravityProjectId,
|
|
35
36
|
resolveAntigravityCloudCodeBaseUrl
|
|
36
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-H5Y2H2N6.js";
|
|
37
38
|
import {
|
|
38
39
|
FORCED_TOOLS,
|
|
39
40
|
addDefaultLightWebToolsForConfiguredAgents,
|
|
@@ -49,7 +50,7 @@ import {
|
|
|
49
50
|
readXPostFunctionSchema,
|
|
50
51
|
readXhsProfileFunc,
|
|
51
52
|
readXhsProfileFunctionSchema
|
|
52
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-SKURMCJF.js";
|
|
53
54
|
import {
|
|
54
55
|
createDrainExhaustedResponse,
|
|
55
56
|
isCoreDrainingBody,
|
|
@@ -61,13 +62,13 @@ import {
|
|
|
61
62
|
} from "./chunk-OWOHNGCN.js";
|
|
62
63
|
import {
|
|
63
64
|
prepareTokenUsageData
|
|
64
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-XNV42PMD.js";
|
|
65
66
|
import {
|
|
66
67
|
BUILTIN_TITLE_LLM_CONFIG
|
|
67
68
|
} from "./chunk-V2J635L5.js";
|
|
68
69
|
import {
|
|
69
70
|
fetchServerSyncedCredential
|
|
70
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-HYJNPPQ6.js";
|
|
71
72
|
import {
|
|
72
73
|
buildAgentRuntimeDialogWritePlan,
|
|
73
74
|
buildLocalWorkspaceOpenAiTools,
|
|
@@ -80,7 +81,7 @@ import {
|
|
|
80
81
|
parseSseDataLineJson,
|
|
81
82
|
readOpenAiCompatibleSseCompletion,
|
|
82
83
|
resolveOpenAiCompatibleProviderConfig
|
|
83
|
-
} from "./chunk-
|
|
84
|
+
} from "./chunk-UNEZBV37.js";
|
|
84
85
|
import {
|
|
85
86
|
buildPlatformChatCompletionRequest,
|
|
86
87
|
canUsePlatformChatProvider,
|
|
@@ -90,14 +91,14 @@ import {
|
|
|
90
91
|
resolveLegacyDeepSeekProxyChatFallback,
|
|
91
92
|
resolvePlatformChatProviderConfig,
|
|
92
93
|
shouldUsePlatformChatProvider
|
|
93
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-3GOA33JO.js";
|
|
94
95
|
import {
|
|
95
96
|
resolveAgentRuntimeConfigFromRecord
|
|
96
97
|
} from "./chunk-NCGFB7NN.js";
|
|
97
98
|
import {
|
|
98
99
|
parseToolArgumentsJson,
|
|
99
100
|
summarizeToolArguments
|
|
100
|
-
} from "./chunk-
|
|
101
|
+
} from "./chunk-TA7VKOHU.js";
|
|
101
102
|
import {
|
|
102
103
|
buildLoadSkillExecutor,
|
|
103
104
|
buildNoloWorkspaceCliToolExecutors,
|
|
@@ -108,7 +109,7 @@ import {
|
|
|
108
109
|
} from "./chunk-B4KT7RN2.js";
|
|
109
110
|
import {
|
|
110
111
|
clipCompactText
|
|
111
|
-
} from "./chunk-
|
|
112
|
+
} from "./chunk-5MMAK75Q.js";
|
|
112
113
|
import {
|
|
113
114
|
createFileCredentialBroker,
|
|
114
115
|
resolveCurrentRunRuntimeToolPolicy,
|
|
@@ -10287,6 +10288,32 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
10287
10288
|
model: providerConfig.model,
|
|
10288
10289
|
complete: async (messages, options) => {
|
|
10289
10290
|
const stream = Boolean(options?.onTextDelta);
|
|
10291
|
+
const inlinedMessages = (await inlineImageUrlsForCustomProvider(
|
|
10292
|
+
{ messages },
|
|
10293
|
+
{
|
|
10294
|
+
shouldInline: true,
|
|
10295
|
+
isAllowedImageUrl: (url) => {
|
|
10296
|
+
try {
|
|
10297
|
+
return new URL(url).origin === new URL(serverUrl).origin;
|
|
10298
|
+
} catch {
|
|
10299
|
+
return false;
|
|
10300
|
+
}
|
|
10301
|
+
},
|
|
10302
|
+
fetchImage: async (url) => {
|
|
10303
|
+
const response = await fetchImpl(url, {
|
|
10304
|
+
headers: authToken ? { Authorization: `Bearer ${authToken}` } : void 0
|
|
10305
|
+
});
|
|
10306
|
+
if (!response.ok) {
|
|
10307
|
+
return { ok: false, error: `HTTP ${response.status}` };
|
|
10308
|
+
}
|
|
10309
|
+
return {
|
|
10310
|
+
ok: true,
|
|
10311
|
+
mimeType: response.headers.get("content-type") ?? "application/octet-stream",
|
|
10312
|
+
bytes: new Uint8Array(await response.arrayBuffer())
|
|
10313
|
+
};
|
|
10314
|
+
}
|
|
10315
|
+
}
|
|
10316
|
+
)).messages;
|
|
10290
10317
|
logLocalRuntimeDiagnostic("provider.request.start", {
|
|
10291
10318
|
agentKey: agentConfig.key,
|
|
10292
10319
|
transport: "direct-openai-compatible",
|
|
@@ -10300,7 +10327,7 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
10300
10327
|
});
|
|
10301
10328
|
const result = await executeOpenAiCompatibleChatCompletion({
|
|
10302
10329
|
providerConfig,
|
|
10303
|
-
messages,
|
|
10330
|
+
messages: inlinedMessages,
|
|
10304
10331
|
tools,
|
|
10305
10332
|
fetchImpl: (url, init) => fetchWithTransientRetry(fetchImpl, url, init, {
|
|
10306
10333
|
sleep: deps.sleep,
|
|
@@ -2,11 +2,13 @@ import {
|
|
|
2
2
|
clipHeadAndTail
|
|
3
3
|
} from "./chunk-JEXVIMYZ.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
inlineImageUrlsForCustomProvider,
|
|
6
|
+
prepareTools,
|
|
7
|
+
shouldInlineImageUrlsForAgent
|
|
8
|
+
} from "./chunk-SDYIF6SV.js";
|
|
7
9
|
import {
|
|
8
10
|
performFetchRequest
|
|
9
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-UWTMBOPF.js";
|
|
10
12
|
import {
|
|
11
13
|
createSSEParser,
|
|
12
14
|
createToolRunId,
|
|
@@ -17,7 +19,7 @@ import {
|
|
|
17
19
|
toolRunSetPending,
|
|
18
20
|
toolRunStarted,
|
|
19
21
|
toolRunSucceeded
|
|
20
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-SKURMCJF.js";
|
|
21
23
|
import {
|
|
22
24
|
getPublicImageAgentMode
|
|
23
25
|
} from "./chunk-VIDPVFP3.js";
|
|
@@ -27,13 +29,13 @@ import {
|
|
|
27
29
|
messageStreaming,
|
|
28
30
|
selectCurrentSpaceId,
|
|
29
31
|
updateToolMessage
|
|
30
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-XNV42PMD.js";
|
|
31
33
|
import {
|
|
32
34
|
streamAgentChatTurn
|
|
33
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-HYJNPPQ6.js";
|
|
34
36
|
import {
|
|
35
37
|
EMPTY_ASSISTANT_REPAIR_PROMPT
|
|
36
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-TA7VKOHU.js";
|
|
37
39
|
import {
|
|
38
40
|
createThinkParserState,
|
|
39
41
|
flushThinkParser,
|
|
@@ -41,7 +43,7 @@ import {
|
|
|
41
43
|
} from "./chunk-OPZYGHUC.js";
|
|
42
44
|
import {
|
|
43
45
|
getModelInfo
|
|
44
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-JFANOO7I.js";
|
|
45
47
|
import {
|
|
46
48
|
getApiEndpoint
|
|
47
49
|
} from "./chunk-OGGHETUE.js";
|
|
@@ -56,15 +58,12 @@ import {
|
|
|
56
58
|
import {
|
|
57
59
|
toErrorMessage
|
|
58
60
|
} from "./chunk-HNMXYYJR.js";
|
|
59
|
-
import {
|
|
60
|
-
isNoloHostedProvider
|
|
61
|
-
} from "./chunk-524BDL33.js";
|
|
62
61
|
import {
|
|
63
62
|
selectCurrentServer
|
|
64
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-JU7J7EAV.js";
|
|
65
64
|
import {
|
|
66
65
|
write
|
|
67
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-VKG4HXYV.js";
|
|
68
67
|
import {
|
|
69
68
|
createDialogMessageKeyAndId,
|
|
70
69
|
dialogMessageKey,
|
|
@@ -998,92 +997,6 @@ function sanitizeOutboundResponsesInput(input, opts = {}) {
|
|
|
998
997
|
return result;
|
|
999
998
|
}
|
|
1000
999
|
|
|
1001
|
-
// packages/ai/chat/inlineImageUrlsForCustomProvider.ts
|
|
1002
|
-
var FILE_CONTENT_PATH = "/api/v1/db/file/content/";
|
|
1003
|
-
var shouldInlineImageUrlsForAgent = (agentConfig) => {
|
|
1004
|
-
const apiSource = agentConfig?.apiSource?.toLowerCase();
|
|
1005
|
-
const provider = agentConfig?.provider?.toLowerCase();
|
|
1006
|
-
const model = agentConfig?.model?.toLowerCase();
|
|
1007
|
-
if (apiSource === "custom" || provider === "custom") return true;
|
|
1008
|
-
if (isNoloHostedProvider(provider)) return true;
|
|
1009
|
-
return provider === "openrouter" && model === "minimax/minimax-m3";
|
|
1010
|
-
};
|
|
1011
|
-
var isInlineCandidate = (url) => /^https?:\/\//i.test(url) && url.includes(FILE_CONTENT_PATH);
|
|
1012
|
-
var bytesToBase64 = (bytes) => {
|
|
1013
|
-
let binary = "";
|
|
1014
|
-
for (const byte of bytes) {
|
|
1015
|
-
binary += String.fromCharCode(byte);
|
|
1016
|
-
}
|
|
1017
|
-
return btoa(binary);
|
|
1018
|
-
};
|
|
1019
|
-
var defaultFetchImage = async (url) => {
|
|
1020
|
-
const response = await fetch(url);
|
|
1021
|
-
if (!response.ok) {
|
|
1022
|
-
return {
|
|
1023
|
-
ok: false,
|
|
1024
|
-
error: `HTTP ${response.status}`
|
|
1025
|
-
};
|
|
1026
|
-
}
|
|
1027
|
-
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
1028
|
-
return {
|
|
1029
|
-
ok: true,
|
|
1030
|
-
mimeType: response.headers.get("content-type") ?? "application/octet-stream",
|
|
1031
|
-
bytes
|
|
1032
|
-
};
|
|
1033
|
-
};
|
|
1034
|
-
var cloneImagePartWithDataUrl = async (part, fetchImage) => {
|
|
1035
|
-
const url = part?.image_url?.url;
|
|
1036
|
-
if (typeof url !== "string" || !isInlineCandidate(url)) return part;
|
|
1037
|
-
const result = await fetchImage(url);
|
|
1038
|
-
if (!result.ok || !result.bytes) {
|
|
1039
|
-
throw new Error(
|
|
1040
|
-
`Failed to inline custom provider image URL ${url}: ${result.error ?? "unknown error"}`
|
|
1041
|
-
);
|
|
1042
|
-
}
|
|
1043
|
-
const mimeType = result.mimeType || "application/octet-stream";
|
|
1044
|
-
return {
|
|
1045
|
-
...part,
|
|
1046
|
-
image_url: {
|
|
1047
|
-
...part.image_url,
|
|
1048
|
-
url: `data:${mimeType};base64,${bytesToBase64(result.bytes)}`
|
|
1049
|
-
}
|
|
1050
|
-
};
|
|
1051
|
-
};
|
|
1052
|
-
var inlineImageUrlsForCustomProvider = async (bodyData, options) => {
|
|
1053
|
-
if (!options.shouldInline) return bodyData;
|
|
1054
|
-
const body = bodyData;
|
|
1055
|
-
if (!Array.isArray(body?.messages)) return bodyData;
|
|
1056
|
-
const fetchImage = options.fetchImage ?? defaultFetchImage;
|
|
1057
|
-
let changed = false;
|
|
1058
|
-
const messages = [];
|
|
1059
|
-
for (const message of body.messages) {
|
|
1060
|
-
if (!Array.isArray(message?.content)) {
|
|
1061
|
-
messages.push(message);
|
|
1062
|
-
continue;
|
|
1063
|
-
}
|
|
1064
|
-
const content = await Promise.all(
|
|
1065
|
-
message.content.map(async (part) => {
|
|
1066
|
-
if (part?.type !== "image_url") return part;
|
|
1067
|
-
return cloneImagePartWithDataUrl(part, fetchImage);
|
|
1068
|
-
})
|
|
1069
|
-
);
|
|
1070
|
-
let messageChanged = false;
|
|
1071
|
-
for (let i = 0; i < content.length; i++) {
|
|
1072
|
-
if (content[i] !== message.content[i]) {
|
|
1073
|
-
changed = true;
|
|
1074
|
-
messageChanged = true;
|
|
1075
|
-
break;
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1078
|
-
messages.push(messageChanged ? { ...message, content } : message);
|
|
1079
|
-
}
|
|
1080
|
-
if (!changed) return bodyData;
|
|
1081
|
-
return {
|
|
1082
|
-
...body,
|
|
1083
|
-
messages
|
|
1084
|
-
};
|
|
1085
|
-
};
|
|
1086
|
-
|
|
1087
1000
|
// packages/ai/chat/streamReader.ts
|
|
1088
1001
|
function createAbortError(message = "The operation was aborted.") {
|
|
1089
1002
|
return new DOMException(message, "AbortError");
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
i18n_default,
|
|
3
3
|
toolRegistry
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SKURMCJF.js";
|
|
5
5
|
import {
|
|
6
6
|
canonicalizeToolNames
|
|
7
7
|
} from "./chunk-B4KT7RN2.js";
|
|
8
|
+
import {
|
|
9
|
+
isNoloHostedProvider
|
|
10
|
+
} from "./chunk-524BDL33.js";
|
|
8
11
|
import {
|
|
9
12
|
asTrimmedLowercaseString
|
|
10
13
|
} from "./chunk-QSJ3HFEF.js";
|
|
@@ -12,6 +15,94 @@ import {
|
|
|
12
15
|
isRecord
|
|
13
16
|
} from "./chunk-KUG52IAP.js";
|
|
14
17
|
|
|
18
|
+
// packages/ai/chat/inlineImageUrlsForCustomProvider.ts
|
|
19
|
+
var FILE_CONTENT_PATH = "/api/v1/db/file/content/";
|
|
20
|
+
var shouldInlineImageUrlsForAgent = (agentConfig) => {
|
|
21
|
+
const apiSource = agentConfig?.apiSource?.toLowerCase();
|
|
22
|
+
const provider = agentConfig?.provider?.toLowerCase();
|
|
23
|
+
const model = agentConfig?.model?.toLowerCase();
|
|
24
|
+
if (apiSource === "custom" || provider === "custom") return true;
|
|
25
|
+
if (isNoloHostedProvider(provider)) return true;
|
|
26
|
+
return provider === "openrouter" && model === "minimax/minimax-m3";
|
|
27
|
+
};
|
|
28
|
+
var isInlineCandidate = (url) => /^https?:\/\//i.test(url) && url.includes(FILE_CONTENT_PATH);
|
|
29
|
+
var bytesToBase64 = (bytes) => {
|
|
30
|
+
let binary = "";
|
|
31
|
+
for (const byte of bytes) {
|
|
32
|
+
binary += String.fromCharCode(byte);
|
|
33
|
+
}
|
|
34
|
+
return btoa(binary);
|
|
35
|
+
};
|
|
36
|
+
var defaultFetchImage = async (url) => {
|
|
37
|
+
const response = await fetch(url);
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
return {
|
|
40
|
+
ok: false,
|
|
41
|
+
error: `HTTP ${response.status}`
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
45
|
+
return {
|
|
46
|
+
ok: true,
|
|
47
|
+
mimeType: response.headers.get("content-type") ?? "application/octet-stream",
|
|
48
|
+
bytes
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
var cloneImagePartWithDataUrl = async (part, fetchImage, isAllowedImageUrl) => {
|
|
52
|
+
const url = part?.image_url?.url;
|
|
53
|
+
if (typeof url !== "string" || !isInlineCandidate(url) || isAllowedImageUrl && !isAllowedImageUrl(url)) {
|
|
54
|
+
return part;
|
|
55
|
+
}
|
|
56
|
+
const result = await fetchImage(url);
|
|
57
|
+
if (!result.ok || !result.bytes) return part;
|
|
58
|
+
const mimeType = result.mimeType || "application/octet-stream";
|
|
59
|
+
return {
|
|
60
|
+
...part,
|
|
61
|
+
image_url: {
|
|
62
|
+
...part.image_url,
|
|
63
|
+
url: `data:${mimeType};base64,${bytesToBase64(result.bytes)}`
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
var inlineImageUrlsForCustomProvider = async (bodyData, options) => {
|
|
68
|
+
if (!options.shouldInline) return bodyData;
|
|
69
|
+
const body = bodyData;
|
|
70
|
+
if (!Array.isArray(body?.messages)) return bodyData;
|
|
71
|
+
const fetchImage = options.fetchImage ?? defaultFetchImage;
|
|
72
|
+
let changed = false;
|
|
73
|
+
const messages = [];
|
|
74
|
+
for (const message of body.messages) {
|
|
75
|
+
if (!Array.isArray(message?.content)) {
|
|
76
|
+
messages.push(message);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const content = await Promise.all(
|
|
80
|
+
message.content.map(async (part) => {
|
|
81
|
+
if (part?.type !== "image_url") return part;
|
|
82
|
+
return cloneImagePartWithDataUrl(
|
|
83
|
+
part,
|
|
84
|
+
fetchImage,
|
|
85
|
+
options.isAllowedImageUrl
|
|
86
|
+
);
|
|
87
|
+
})
|
|
88
|
+
);
|
|
89
|
+
let messageChanged = false;
|
|
90
|
+
for (let i = 0; i < content.length; i++) {
|
|
91
|
+
if (content[i] !== message.content[i]) {
|
|
92
|
+
changed = true;
|
|
93
|
+
messageChanged = true;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
messages.push(messageChanged ? { ...message, content } : message);
|
|
98
|
+
}
|
|
99
|
+
if (!changed) return bodyData;
|
|
100
|
+
return {
|
|
101
|
+
...body,
|
|
102
|
+
messages
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
15
106
|
// packages/ai/tools/toolSchemaCompatibility.ts
|
|
16
107
|
var COMPOSITION_KEYS = ["anyOf", "oneOf", "allOf"];
|
|
17
108
|
var LIMITED_JSON_SCHEMA_PROVIDERS = /* @__PURE__ */ new Set([
|
|
@@ -167,5 +258,7 @@ var prepareTools = (toolNames, options) => {
|
|
|
167
258
|
};
|
|
168
259
|
|
|
169
260
|
export {
|
|
261
|
+
shouldInlineImageUrlsForAgent,
|
|
262
|
+
inlineImageUrlsForCustomProvider,
|
|
170
263
|
prepareTools
|
|
171
264
|
};
|