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.
Files changed (73) hide show
  1. package/{_executeModel-3B6MKHQV.js → _executeModel-PKRZBH3J.js} +20 -19
  2. package/{action-RAXNQQKC.js → action-OTOWUMPW.js} +3 -3
  3. package/{addContentAction-ZHI7TVV3.js → addContentAction-JGBUVR7K.js} +2 -2
  4. package/{addDialogAgentAction-JWXPKXNC.js → addDialogAgentAction-V6CL2UCF.js} +1 -1
  5. package/{agentDeleteCommand-3R7OCLBN.js → agentDeleteCommand-OKQ5CSX2.js} +12 -11
  6. package/{agentEmailCommands-OENXTOPM.js → agentEmailCommands-7DORWXQH.js} +24 -23
  7. package/{agentListCommands-GX5YRFFK.js → agentListCommands-VTR33V4B.js} +13 -12
  8. package/{agentMachineCommands-5ZEL4NOJ.js → agentMachineCommands-XHFM4UQB.js} +12 -11
  9. package/{agentRecordCommands-EKGPNDCG.js → agentRecordCommands-XB7XBNJ7.js} +24 -23
  10. package/{agentRunCommand-KQYY46WS.js → agentRunCommand-XACEWDVO.js} +24 -23
  11. package/{agentRuntimeLocal-C2KYWS6H.js → agentRuntimeLocal-NYFVPD5P.js} +9 -8
  12. package/{agentSlice-N5RKI23B.js → agentSlice-NGZWIMZX.js} +2 -2
  13. package/{chunk-6TISG7CK.js → chunk-3GOA33JO.js} +69 -12
  14. package/{chunk-5HANPK6S.js → chunk-4LNEIK4O.js} +3 -3
  15. package/chunk-5MMAK75Q.js +15 -0
  16. package/{chunk-2VILMENT.js → chunk-6KTC3MPK.js} +1 -1
  17. package/{chunk-6VDWNLHX.js → chunk-7CQLSRAC.js} +2 -2
  18. package/{chunk-OLKX3NZI.js → chunk-7F5C7ILS.js} +3 -3
  19. package/{chunk-NIU4ERVM.js → chunk-A22NOC7Y.js} +24 -22
  20. package/{chunk-RFRU3HAL.js → chunk-CGAYFFIB.js} +1 -1
  21. package/{chunk-7MYHLZ3F.js → chunk-DPFWKRHG.js} +1 -1
  22. package/{chunk-Y3BLUPNS.js → chunk-H5Y2H2N6.js} +1 -1
  23. package/{chunk-ELYHT6P6.js → chunk-HO7RHQIN.js} +2 -2
  24. package/{chunk-RGJFQERV.js → chunk-HYJNPPQ6.js} +4 -4
  25. package/{chunk-NKD3Q4RN.js → chunk-JFANOO7I.js} +2 -14
  26. package/{chunk-WTYKCU4W.js → chunk-JU7J7EAV.js} +37 -37
  27. package/{chunk-NRJFU6WZ.js → chunk-LBWFOYJJ.js} +2 -2
  28. package/{chunk-Y3COB2JR.js → chunk-LKVDZQGM.js} +2 -2
  29. package/{chunk-7HV5OHEM.js → chunk-LUKQQJFL.js} +38 -1
  30. package/{chunk-FF7Y6DC4.js → chunk-NS3DRNUZ.js} +39 -12
  31. package/{chunk-7TNQ4ZZL.js → chunk-P3J54V3I.js} +1 -1
  32. package/{chunk-UG3WOFU6.js → chunk-QJSTNKJY.js} +1 -1
  33. package/{chunk-ISZEBXEV.js → chunk-QYZ46ZC3.js} +1 -1
  34. package/{chunk-B2Z7OJBT.js → chunk-REQCG2PB.js} +12 -99
  35. package/{chunk-6LMFFG3K.js → chunk-RWO5DGXI.js} +2 -2
  36. package/{chunk-J6PV7OYE.js → chunk-SDYIF6SV.js} +94 -1
  37. package/{chunk-MRX4BSKQ.js → chunk-SKURMCJF.js} +151 -15
  38. package/{chunk-6ADBTFFE.js → chunk-TA7VKOHU.js} +10 -5
  39. package/{chunk-WO24IT3V.js → chunk-TYPHUVK5.js} +12 -0
  40. package/{chunk-WMU5EZLC.js → chunk-UNEZBV37.js} +27 -13
  41. package/{chunk-KJTP7JTN.js → chunk-UP6JMU6C.js} +1 -1
  42. package/{chunk-I6IVZIIO.js → chunk-UWTMBOPF.js} +15 -10
  43. package/{chunk-NITP2JDG.js → chunk-VKG4HXYV.js} +1 -1
  44. package/{chunk-3HHTVM6G.js → chunk-WVTBAALN.js} +1 -1
  45. package/{chunk-OSGJQTG6.js → chunk-XNV42PMD.js} +18 -18
  46. package/{createAgentAutomationAction-NNXHZFSA.js → createAgentAutomationAction-AHSBJKGX.js} +8 -7
  47. package/{createDialogAction-TQCW67HG.js → createDialogAction-RSNVGR5E.js} +9 -8
  48. package/{createPageAction-QUFKG6A2.js → createPageAction-47G4D5WU.js} +8 -7
  49. package/{dbSlice-WDP2ZZHK.js → dbSlice-J4PUZ6Y5.js} +1 -1
  50. package/{dialogCommands-C6ERN2I7.js → dialogCommands-MPUFCOBR.js} +13 -12
  51. package/{dialogSlice-DAA3CWOV.js → dialogSlice-YNEFYFSU.js} +8 -7
  52. package/{docCreateCommands-KMYVYGZM.js → docCreateCommands-LV6KUDP3.js} +12 -11
  53. package/{docDeleteCommands-DZHIJA5D.js → docDeleteCommands-Y7FOYWMY.js} +13 -12
  54. package/{docReadCommands-VLJFYLR2.js → docReadCommands-UCCHERCP.js} +12 -11
  55. package/{docStore-67RBJMFZ.js → docStore-OBBYKQVD.js} +9 -8
  56. package/{docUpdateCommands-GOHV5JC5.js → docUpdateCommands-FBKQBFWG.js} +12 -11
  57. package/{handleSendMessageAction-7PNLNSPL.js → handleSendMessageAction-U5AX6CGB.js} +8 -7
  58. package/index.js +36 -36
  59. package/{machineCommands-J7FIVAZV.js → machineCommands-EXVWHGWU.js} +23 -22
  60. package/{machineWsRunDispatch-RWXFY6YG.js → machineWsRunDispatch-QZXCW3SI.js} +23 -22
  61. package/package.json +1 -1
  62. package/{readlineWorkspace-EMKKVMNH.js → readlineWorkspace-QKMGLM33.js} +134 -34
  63. package/{removeDialogAgentAction-GTX5AN54.js → removeDialogAgentAction-XUZYQBV4.js} +3 -3
  64. package/{runAgentClientLoop-VTA6RAHT.js → runAgentClientLoop-5DIJHAPN.js} +17 -16
  65. package/{setDialogExtraReferencesAction-WFQ63KYO.js → setDialogExtraReferencesAction-PTAIFKGM.js} +1 -1
  66. package/{setPrimaryDialogAgentAction-P57FXTSU.js → setPrimaryDialogAgentAction-HRFTDB44.js} +3 -3
  67. package/{settingSlice-CK5YZGNI.js → settingSlice-VGRJUSE5.js} +2 -2
  68. package/{spaceCommands-HLOEZVOV.js → spaceCommands-KDZYXP5N.js} +12 -11
  69. package/{spaceSlice-2X2TVI2V.js → spaceSlice-EO6JQRMP.js} +8 -7
  70. package/{streamAgentChatTurn-GFQ4YRJF.js → streamAgentChatTurn-PLKJ3MZ6.js} +20 -19
  71. package/{tools-PR47LTGM.js → tools-5QNY6YKE.js} +12 -11
  72. package/{tuiSummaryLlmCaller-YEHSPGXZ.js → tuiSummaryLlmCaller-TQ34DAM5.js} +4 -2
  73. 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-ISZEBXEV.js";
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-UG3WOFU6.js";
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-J6PV7OYE.js";
31
+ } from "./chunk-SDYIF6SV.js";
31
32
  import {
32
33
  getAntigravityUserAgent,
33
34
  isAntigravityOAuthAgent,
34
35
  readAntigravityProjectId,
35
36
  resolveAntigravityCloudCodeBaseUrl
36
- } from "./chunk-Y3BLUPNS.js";
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-MRX4BSKQ.js";
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-OSGJQTG6.js";
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-RGJFQERV.js";
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-WMU5EZLC.js";
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-6TISG7CK.js";
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-6ADBTFFE.js";
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-NKD3Q4RN.js";
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,7 +2,7 @@ import {
2
2
  deleteDbRecord,
3
3
  queryUserRecords,
4
4
  readDbRecord
5
- } from "./chunk-RFRU3HAL.js";
5
+ } from "./chunk-CGAYFFIB.js";
6
6
  import {
7
7
  mergeAndDedupUserData
8
8
  } from "./chunk-KQHGZWSV.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_AGENT_BASE_POLICY,
3
3
  DEFAULT_USER_PREFERENCE_PROFILE
4
- } from "./chunk-WTYKCU4W.js";
4
+ } from "./chunk-JU7J7EAV.js";
5
5
 
6
6
  // packages/ai/policy/runtimePolicy.ts
7
7
  var clampLevel = (value, fallback) => {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildAgentRuntimeAgentLookupKeys,
3
3
  shouldFetchAgentRuntimeRecordRemotely
4
- } from "./chunk-WMU5EZLC.js";
4
+ } from "./chunk-UNEZBV37.js";
5
5
 
6
6
  // packages/cli/client/localAgentRecords.ts
7
7
  var buildLocalAgentLookupKeys = buildAgentRuntimeAgentLookupKeys;
@@ -2,11 +2,13 @@ import {
2
2
  clipHeadAndTail
3
3
  } from "./chunk-JEXVIMYZ.js";
4
4
  import {
5
- prepareTools
6
- } from "./chunk-J6PV7OYE.js";
5
+ inlineImageUrlsForCustomProvider,
6
+ prepareTools,
7
+ shouldInlineImageUrlsForAgent
8
+ } from "./chunk-SDYIF6SV.js";
7
9
  import {
8
10
  performFetchRequest
9
- } from "./chunk-I6IVZIIO.js";
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-MRX4BSKQ.js";
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-OSGJQTG6.js";
32
+ } from "./chunk-XNV42PMD.js";
31
33
  import {
32
34
  streamAgentChatTurn
33
- } from "./chunk-RGJFQERV.js";
35
+ } from "./chunk-HYJNPPQ6.js";
34
36
  import {
35
37
  EMPTY_ASSISTANT_REPAIR_PROMPT
36
- } from "./chunk-6ADBTFFE.js";
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-NKD3Q4RN.js";
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-WTYKCU4W.js";
63
+ } from "./chunk-JU7J7EAV.js";
65
64
  import {
66
65
  write
67
- } from "./chunk-NITP2JDG.js";
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,9 +1,9 @@
1
1
  import {
2
2
  selectCurrentServer
3
- } from "./chunk-WTYKCU4W.js";
3
+ } from "./chunk-JU7J7EAV.js";
4
4
  import {
5
5
  patch
6
- } from "./chunk-NITP2JDG.js";
6
+ } from "./chunk-VKG4HXYV.js";
7
7
  import {
8
8
  selectIdentityToken
9
9
  } from "./chunk-TSUJOM6N.js";
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  i18n_default,
3
3
  toolRegistry
4
- } from "./chunk-MRX4BSKQ.js";
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
  };