nolo-cli 0.11.0 → 0.12.0-alpha.10

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 (123) hide show
  1. package/{_executeModel-ZEDPX6OF.js → _executeModel-4F7VZR5U.js} +52 -50
  2. package/{action-AA4IJ5K2.js → action-OTOWUMPW.js} +8 -9
  3. package/{addContentAction-QYVO4SYP.js → addContentAction-JGBUVR7K.js} +7 -9
  4. package/{addDialogAgentAction-WVVKT5WQ.js → addDialogAgentAction-V6CL2UCF.js} +9 -10
  5. package/{agentDeleteCommand-RDPGYIWF.js → agentDeleteCommand-MMRSG6AB.js} +39 -28
  6. package/{agentEmailCommands-2HJJKS5F.js → agentEmailCommands-YFVKOGM7.js} +65 -62
  7. package/{agentListCommands-HFEVV3ZW.js → agentListCommands-2PZHIQ3I.js} +128 -31
  8. package/{agentMachineCommands-25ZOENJU.js → agentMachineCommands-55UUZNHF.js} +38 -26
  9. package/{agentPullCommand-GOL2S4W2.js → agentPullCommand-KRBRIFIY.js} +7 -7
  10. package/{agentRecordCommands-GTCOAM3L.js → agentRecordCommands-BTP3OAPL.js} +57 -54
  11. package/{agentRunCommand-YBS3JDLD.js → agentRunCommand-AA4QLRQZ.js} +60 -59
  12. package/{agentRunControl-K4VKNEHF.js → agentRunControl-IX4F5W2C.js} +3 -3
  13. package/{agentRuntimeLocal-UQBMQI2M.js → agentRuntimeLocal-QDJCBXM2.js} +31 -15
  14. package/{agentSlice-6EKOBCCS.js → agentSlice-6JAJOU3X.js} +8 -9
  15. package/{authCommand-O2OWACN4.js → authCommand-DMW336GT.js} +15 -15
  16. package/{authCommands-H7365TZP.js → authCommands-GH5T6RYV.js} +6 -6
  17. package/{chunk-E4HNJSHC.js → chunk-2BVGERJ2.js} +81 -19
  18. package/{chunk-LP65VRCI.js → chunk-3MI5LDDU.js} +6 -6
  19. package/{chunk-OPZYGHUC.js → chunk-3WGLLTK4.js} +59 -1
  20. package/{chunk-KJR5KAUQ.js → chunk-3XF6LCCN.js} +20 -7
  21. package/{chunk-PXZAAB4L.js → chunk-4LG74DRG.js} +4 -4
  22. package/{chunk-2FTTDCD4.js → chunk-4ON5AV72.js} +2 -1
  23. package/{chunk-IWX4UW2E.js → chunk-524BDL33.js} +89 -8
  24. package/{chunk-ISNCLGUZ.js → chunk-5NBHQD4D.js} +4 -3
  25. package/{chunk-ZPRK73XY.js → chunk-5S4SWV5G.js} +51 -38
  26. package/{chunk-EVZKZF32.js → chunk-5V524MHX.js} +195 -78
  27. package/{chunk-CKOJQDKR.js → chunk-7JJCGV7N.js} +146 -3
  28. package/{chunk-NEM67FX7.js → chunk-ARSC56DC.js} +1 -1
  29. package/{chunk-AFON4QUU.js → chunk-AS3ZQ3O2.js} +19 -28
  30. package/{chunk-4SOKXIW4.js → chunk-B4KT7RN2.js} +10 -13
  31. package/chunk-BYXBJQAS.js +0 -0
  32. package/{chunk-PXQN7IBQ.js → chunk-C3BFP57W.js} +95 -2
  33. package/{chunk-AEZAORLG.js → chunk-CGDQDXKZ.js} +5 -5
  34. package/{chunk-MQI77IRB.js → chunk-DPFWKRHG.js} +2 -2
  35. package/{chunk-TACHTH5D.js → chunk-EIMX5ER5.js} +18 -18
  36. package/{chunk-5MOUAAMK.js → chunk-FSUZIGIG.js} +197 -2578
  37. package/{chunk-FXXSGWAJ.js → chunk-H5Y2H2N6.js} +1 -1
  38. package/chunk-IKXL2HZ3.js +70 -0
  39. package/{chunk-QNMFBBZK.js → chunk-IVAOVLM7.js} +1 -1
  40. package/chunk-JFANOO7I.js +2274 -0
  41. package/{chunk-YPRZSPF3.js → chunk-JKWWVF2I.js} +1 -1
  42. package/{chunk-3NSIQZZ6.js → chunk-JU7J7EAV.js} +45 -45
  43. package/{chunk-X2S7JTIG.js → chunk-KWBH4RAL.js} +1280 -137
  44. package/{chunk-OUI3ZHYD.js → chunk-LUKQQJFL.js} +39 -2
  45. package/{chunk-BX6U3ETE.js → chunk-MG6BVV3T.js} +320 -102
  46. package/{chunk-L53FGHA4.js → chunk-MQRZ5QUH.js} +1 -1
  47. package/{chunk-2W2VYVI5.js → chunk-MZHSAPZP.js} +675 -177
  48. package/{chunk-YOCHZD7D.js → chunk-NCGFB7NN.js} +5 -3
  49. package/{chunk-DWGAEFJL.js → chunk-O4FOPRCP.js} +1 -1
  50. package/chunk-OGGHETUE.js +4900 -0
  51. package/{chunk-PNEW2Z3T.js → chunk-OHEKYYJF.js} +7 -7
  52. package/chunk-OOIN7HSO.js +146 -0
  53. package/{chunk-SV5MWASH.js → chunk-OPM2DE2J.js} +12 -12
  54. package/{chunk-5OIFWVX7.js → chunk-QJSTNKJY.js} +1 -1
  55. package/{chunk-C4FTUXVF.js → chunk-QLUFR47U.js} +11 -1
  56. package/{chunk-LAX2JSTX.js → chunk-QUHUVG6Y.js} +20 -2
  57. package/{chunk-D6OQHXVG.js → chunk-RQSOAMPJ.js} +22 -6
  58. package/{chunk-ZEYDOXHF.js → chunk-RUGEW4P7.js} +1515 -884
  59. package/{chunk-GBDSZATH.js → chunk-RWO5DGXI.js} +3 -3
  60. package/{chunk-S3GS2PRL.js → chunk-TA7VKOHU.js} +613 -70
  61. package/{chunk-XYZA7S7V.js → chunk-TQYYGE6G.js} +6 -6
  62. package/{chunk-YTBMA7NO.js → chunk-TYPHUVK5.js} +70 -8
  63. package/{chunk-4ZDM73SD.js → chunk-V2J635L5.js} +1 -1
  64. package/{chunk-C2MDQQ4O.js → chunk-VBSWHE5W.js} +1 -1
  65. package/{chunk-O26GI2JP.js → chunk-VKG4HXYV.js} +39 -8
  66. package/{chunk-IPYUUY4E.js → chunk-WPHL6ALY.js} +1 -1
  67. package/{chunk-7D3JY6C2.js → chunk-WVTBAALN.js} +64 -5
  68. package/{chunk-XFOLQLDN.js → chunk-XHQWJUW4.js} +2 -2
  69. package/{chunk-Q3UKJVU4.js → chunk-Y5P3ZRGC.js} +10 -10
  70. package/{chunk-KQQVGRA3.js → chunk-YUMYYXPI.js} +53 -183
  71. package/cliEnvHelpers-VYC2OPTB.js +30 -0
  72. package/{createAgentAutomationAction-LTI5QU35.js → createAgentAutomationAction-4NY4JLOK.js} +26 -26
  73. package/{createDialogAction-OJJ7L3L3.js → createDialogAction-I5WUWFJ6.js} +26 -26
  74. package/{createPageAction-5MXWVRGY.js → createPageAction-HFTIQ7TW.js} +26 -26
  75. package/{dbSlice-RQFQQVHT.js → dbSlice-J4PUZ6Y5.js} +6 -7
  76. package/{deleteFile-7XP5BGC7.js → deleteFile-M7UNIUOO.js} +4 -4
  77. package/{dialogCommands-JTJ3RPPW.js → dialogCommands-SVXRJFZS.js} +34 -23
  78. package/{dialogSlice-OWROKURJ.js → dialogSlice-35LA3ZRG.js} +26 -26
  79. package/{docCreateCommands-WJBEW2V7.js → docCreateCommands-Z7RIAYKQ.js} +34 -23
  80. package/{docDeleteCommands-BVEHJOY5.js → docDeleteCommands-NEYHUVZF.js} +35 -25
  81. package/{docReadCommands-NEWOZIJV.js → docReadCommands-I4US2SDE.js} +34 -23
  82. package/{docStore-3DXRYBMD.js → docStore-3CP2IO6M.js} +25 -25
  83. package/{docUpdateCommands-C7WHT7UU.js → docUpdateCommands-UU5HQBRP.js} +34 -23
  84. package/fetchMessages-KTNM7QAR.js +1 -1
  85. package/{getPricing-3E6UNPKL.js → getPricing-UGDJHI7M.js} +7 -3
  86. package/{handleSendMessageAction-B5PRR7BE.js → handleSendMessageAction-FWTLQGOZ.js} +30 -30
  87. package/index.js +77 -76
  88. package/{localDialogRead-YSKFFRTT.js → localDialogRead-2VRI24F4.js} +1 -1
  89. package/{machineCommands-IIIREAEK.js → machineCommands-STHZKBDJ.js} +64 -61
  90. package/{machineWsRunDispatch-3SIU6ILW.js → machineWsRunDispatch-7YHT4TPT.js} +56 -53
  91. package/{memoryCommands-O4MIPIWQ.js → memoryCommands-AFMES3LN.js} +5 -5
  92. package/{models-4OPOOLFS.js → models-LSCRJJ6P.js} +2 -2
  93. package/package.json +1 -1
  94. package/{read-QJNKRROM.js → read-2MIMRBZ2.js} +4 -4
  95. package/{readDocTool-H6X6KO6X.js → readDocTool-QHVGQHUJ.js} +1 -1
  96. package/{readlineWorkspace-HGP3I3OC.js → readlineWorkspace-OMRWYMB6.js} +1279 -716
  97. package/{removeDialogAgentAction-TCT35SOF.js → removeDialogAgentAction-XUZYQBV4.js} +13 -13
  98. package/{runAgentClientLoop-EFM4PTVI.js → runAgentClientLoop-FP2K33ZO.js} +47 -46
  99. package/{runtimeDoctorCommands-ID43Z7VX.js → runtimeDoctorCommands-QNF3J3UV.js} +6 -6
  100. package/{setDialogExtraReferencesAction-CGYLZMFH.js → setDialogExtraReferencesAction-PTAIFKGM.js} +9 -10
  101. package/{setPrimaryDialogAgentAction-F6BFQDJU.js → setPrimaryDialogAgentAction-HRFTDB44.js} +13 -13
  102. package/{settingSlice-2I5HMG47.js → settingSlice-VGRJUSE5.js} +7 -8
  103. package/{skillDiscovery-UGSQGX2U.js → skillDiscovery-6M2BZUFN.js} +3 -3
  104. package/{spaceCommands-MT7BWCIL.js → spaceCommands-GN73BCOB.js} +38 -29
  105. package/{spaceSlice-BS5TSW3W.js → spaceSlice-WTFNKOVA.js} +30 -26
  106. package/{streamAgentChatTurn-I3VBFNR3.js → streamAgentChatTurn-HBAQQVNK.js} +442 -130
  107. package/{toolApiClient-C7P7YSE4.js → toolApiClient-QI3YBNWB.js} +2 -2
  108. package/{tools-XSD2BOEN.js → tools-TPQYTLQZ.js} +34 -33
  109. package/{tuiSummaryLlmCaller-32NRHTT2.js → tuiSummaryLlmCaller-XDC7WG4K.js} +11 -7
  110. package/{updateCommands-VOSPKXFF.js → updateCommands-XZDOOYFH.js} +13 -5
  111. package/{updateDialogTitleAction-7FYNJOGP.js → updateDialogTitleAction-AWXNPUQJ.js} +30 -29
  112. package/chunk-AZPCASRE.js +0 -36
  113. package/chunk-BBYVOSU2.js +0 -792
  114. package/chunk-DCOA4QSN.js +0 -105
  115. package/chunk-UAD2WT54.js +0 -64
  116. package/{chunk-JK7VW2FN.js → chunk-5MIDPSSK.js} +3 -3
  117. package/{chunk-5CS33IBL.js → chunk-PDL2AV3E.js} +3 -3
  118. package/{chunk-5MMZUWSG.js → chunk-TOILAPLH.js} +5 -5
  119. package/{chunk-OOM6SJNR.js → chunk-TSUJOM6N.js} +6 -6
  120. package/{db-6QED3ZVO.js → db-HCJ5PRB5.js} +3 -3
  121. package/{offlineMarxistsAgentCommand-BCPJITJL.js → offlineMarxistsAgentCommand-5OOWZLJI.js} +3 -3
  122. package/{tableCommands-M3DJUETS.js → tableCommands-E4SQWDOX.js} +6 -6
  123. package/{understanding-ZOESBLF3.js → understanding-3CUQQ6SV.js} +3 -3
@@ -1,15 +1,17 @@
1
- import {
2
- buildSkillDiscoveryLayer
3
- } from "./chunk-C4FTUXVF.js";
4
1
  import {
5
2
  load
6
3
  } from "./chunk-WZSRQNQG.js";
4
+ import {
5
+ buildSkillDiscoveryLayer
6
+ } from "./chunk-QLUFR47U.js";
7
7
 
8
8
  // packages/agent-runtime/skillDiscovery.ts
9
9
  import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
10
10
  import { join } from "node:path";
11
- var SKILL_SCAN_DIRS = [".agents/skills", "docs/skills"];
11
+ var SKILL_SCAN_DIRS = [".agents/skills"];
12
12
  var MAX_DISCOVERED_SKILLS = 50;
13
+ var MAX_DISCOVERY_DESC_BUDGET = 4e3;
14
+ var MIN_DESC_LENGTH = 80;
13
15
  function parseSkillFrontmatter(filePath) {
14
16
  try {
15
17
  const content = readFileSync(filePath, "utf8").slice(0, 2048);
@@ -20,8 +22,9 @@ function parseSkillFrontmatter(filePath) {
20
22
  const name = typeof fm.name === "string" ? fm.name : void 0;
21
23
  const rawDesc = fm.description;
22
24
  const description = typeof rawDesc === "string" ? rawDesc : rawDesc == null ? void 0 : String(rawDesc);
23
- const sanitize = (s) => s?.trim().replace(/^["']|["']$/g, "").replace(/[\n\r]+/g, " ").slice(0, 200);
24
- return { name: sanitize(name), description: sanitize(description) };
25
+ const sanitizeName = (s) => s?.trim().replace(/^["']|["']$/g, "").replace(/[\n\r]+/g, " ").slice(0, 200);
26
+ const sanitizeDesc = (s) => s?.trim().replace(/^["']|["']$/g, "").replace(/[\n\r]+/g, " ").slice(0, 200);
27
+ return { name: sanitizeName(name), description: sanitizeDesc(description) };
25
28
  } catch {
26
29
  return {};
27
30
  }
@@ -41,15 +44,20 @@ function discoverSkills(cwd) {
41
44
  skills.push({ name: name ?? entry, description: description ?? "", relativePath: join(dir, entry, "SKILL.md") });
42
45
  continue;
43
46
  }
44
- if (dir === "docs/skills" && entry.endsWith(".md")) {
45
- const flatPath = join(absDir, entry);
46
- const { name, description } = parseSkillFrontmatter(flatPath);
47
- skills.push({ name: name ?? entry.replace(/\.md$/, ""), description: description ?? "", relativePath: join(dir, entry) });
48
- }
49
47
  }
50
48
  } catch {
51
49
  }
52
50
  }
51
+ const totalDescLen = skills.reduce((sum, s) => sum + s.description.length, 0);
52
+ if (totalDescLen > MAX_DISCOVERY_DESC_BUDGET && skills.length > 0) {
53
+ const scale = MAX_DISCOVERY_DESC_BUDGET / totalDescLen;
54
+ for (const s of skills) {
55
+ const targetLen = Math.max(MIN_DESC_LENGTH, Math.floor(s.description.length * scale));
56
+ if (s.description.length > targetLen) {
57
+ s.description = s.description.slice(0, targetLen).trimEnd();
58
+ }
59
+ }
60
+ }
53
61
  return skills;
54
62
  }
55
63
  function resolveSkillByName(cwd, name) {
@@ -75,23 +83,6 @@ function resolveSkillByName(cwd, name) {
75
83
  } catch {
76
84
  }
77
85
  }
78
- const docsFlat = join(cwd, "docs", "skills", `${trimmed}.md`);
79
- if (existsSync(docsFlat)) return docsFlat;
80
- const docsDir = join(cwd, "docs", "skills");
81
- if (existsSync(docsDir) && statSync(docsDir).isDirectory()) {
82
- try {
83
- for (const entry of readdirSync(docsDir)) {
84
- if (!entry.endsWith(".md")) continue;
85
- const candidate = join(docsDir, entry);
86
- try {
87
- const { name: fmName } = parseSkillFrontmatter(candidate);
88
- if (fmName && fmName === trimmed) return candidate;
89
- } catch {
90
- }
91
- }
92
- } catch {
93
- }
94
- }
95
86
  return null;
96
87
  }
97
88
  function buildSkillDiscoveryContextBlock(cwd) {
@@ -63,7 +63,10 @@ var LEGACY_TOOL_NAME_ALIASES = {
63
63
  webfetch: "fetchWebpage",
64
64
  web_fetch: "fetchWebpage",
65
65
  fetchweb: "fetchWebpage",
66
- fetch_web: "fetchWebpage"
66
+ fetch_web: "fetchWebpage",
67
+ // 模型偶尔会把 loadSkill 幻觉成 readSkill(参数风格 name= 一致),
68
+ // 规范化到 loadSkill,避免 localToolPolicy 把这种调用直接拦死。
69
+ readSkill: "loadSkill"
67
70
  };
68
71
  var normalizeToolName = (name) => name.replace(/[-_]/g, "").toLowerCase();
69
72
  var canonicalizeToolName = (rawName) => {
@@ -401,12 +404,6 @@ var DIALOG_PATH_RE = /^\/(?:space\/([^/]+)\/)?dialog-(.+)-([0-9A-HJKMNP-TV-Z]{26
401
404
  function stringToolParam(description) {
402
405
  return { type: "string", description };
403
406
  }
404
- function isNoloWorkspaceToolName(toolName) {
405
- return typeof toolName === "string" && NOLO_WORKSPACE_TOOL_NAME_SET.has(toolName);
406
- }
407
- function filterNoloWorkspaceToolNames(toolNames) {
408
- return (toolNames ?? []).filter(isNoloWorkspaceToolName);
409
- }
410
407
  function buildNoloWorkspaceOpenAiTools(args) {
411
408
  const toolNames = new Set(args.toolNames ?? []);
412
409
  const tools = [];
@@ -457,7 +454,7 @@ function buildNoloWorkspaceOpenAiTools(args) {
457
454
  description: "Confirmed dialog ids or dbKeys to delete."
458
455
  }
459
456
  }, ["query"]);
460
- add("listAgents", "List the current user's agents in the Nolo workspace.", {
457
+ add("listAgents", "List the current user's agents as safe summaries; use readAgent to resolve the runnable agentKey before delegation.", {
461
458
  space: stringToolParam("Optional space id or URL."),
462
459
  publicOnly: { type: "boolean", description: "Only show public agents." }
463
460
  // 端间差异(LOW-R2-3):CLI 命令 `nolo agent list` 无 --limit(parseAgentListArgs
@@ -480,7 +477,7 @@ function buildNoloWorkspaceOpenAiTools(args) {
480
477
  add("readSkillDoc", "Read one skill doc in the Nolo workspace.", {
481
478
  doc: stringToolParam("Skill doc/page key.")
482
479
  }, ["doc"]);
483
- add("loadSkill", "Load a Skill by name from the workspace skill directories (.agents/skills/<name>/SKILL.md, then docs/skills/<name>.md) and return its full SKILL.md content inline so you can follow its instructions. Use this instead of readFile when you want to activate a skill. On an unknown name the tool returns a plain text list of available skill names rather than failing.", {
480
+ add("loadSkill", "Load a Skill by name from the workspace skill directory (.agents/skills/<name>/SKILL.md) and return its full SKILL.md content inline so you can follow its instructions. Use this instead of readFile when you want to activate a skill. On an unknown name the tool returns a plain text list of available skill names rather than failing.", {
484
481
  name: stringToolParam("Skill name (the name advertised in the skill-discovery layer).")
485
482
  }, ["name"]);
486
483
  add("listTables", "List tables in the current user scope or an optional space scope.", {
@@ -779,6 +776,7 @@ function buildNoloWorkspaceCommandArgs(call) {
779
776
  const space = noloStringArg(args.space);
780
777
  if (space) cliArgs.push("--space", space);
781
778
  if (args.publicOnly === true) cliArgs.push("--public-only");
779
+ cliArgs.push("--json", "--safe");
782
780
  return cliArgs;
783
781
  }
784
782
  case "readAgent": {
@@ -894,7 +892,7 @@ function buildLoadSkillExecutor(args) {
894
892
  metadata: { loadSkill: true, resolved: false }
895
893
  };
896
894
  }
897
- const { resolveSkillByName } = await import("./skillDiscovery-UGSQGX2U.js");
895
+ const { resolveSkillByName } = await import("./skillDiscovery-6M2BZUFN.js");
898
896
  const resolved = resolveSkillByName(args.cwd, name);
899
897
  if (!resolved) {
900
898
  return {
@@ -921,13 +919,13 @@ ${body}`,
921
919
  };
922
920
  }
923
921
  async function formatUnknownSkillMessage(cwd, requestedName) {
924
- const { discoverSkills } = await import("./skillDiscovery-UGSQGX2U.js");
922
+ const { discoverSkills } = await import("./skillDiscovery-6M2BZUFN.js");
925
923
  let available = [];
926
924
  try {
927
925
  available = discoverSkills(cwd).map((s) => s.name);
928
926
  } catch {
929
927
  }
930
- const header = `Skill "${requestedName}" not found in this workspace's skill directories (.agents/skills/<name>/SKILL.md, docs/skills/<name>.md).`;
928
+ const header = `Skill "${requestedName}" not found in this workspace's skill directory (.agents/skills/<name>/SKILL.md).`;
931
929
  if (available.length === 0) return `${header}
932
930
 
933
931
  No skills were discovered in this workspace.`;
@@ -948,7 +946,6 @@ export {
948
946
  resolveExecutableOnPath,
949
947
  createGlob,
950
948
  NOLO_WORKSPACE_TOOL_NAMES,
951
- filterNoloWorkspaceToolNames,
952
949
  buildNoloWorkspaceOpenAiTools,
953
950
  parseNoloWorkspaceToolArguments,
954
951
  clampNoloPositiveInteger,
File without changes
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  i18n_default,
3
3
  toolRegistry
4
- } from "./chunk-2W2VYVI5.js";
4
+ } from "./chunk-MZHSAPZP.js";
5
5
  import {
6
6
  canonicalizeToolNames
7
- } from "./chunk-4SOKXIW4.js";
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
  };
@@ -2,10 +2,13 @@ import {
2
2
  buildLocalAgentLookupKeys,
3
3
  normalizeAgentHandle,
4
4
  shouldReadAgentKeyRemotely
5
- } from "./chunk-C2MDQQ4O.js";
5
+ } from "./chunk-VBSWHE5W.js";
6
6
  import {
7
7
  resolveCliAgentKeyInput
8
8
  } from "./chunk-VHBWHNVT.js";
9
+ import {
10
+ toErrorMessage
11
+ } from "./chunk-HNMXYYJR.js";
9
12
  import {
10
13
  readPipeText,
11
14
  spawnProcess
@@ -19,10 +22,7 @@ import {
19
22
  resolveAuthToken,
20
23
  resolveServerCandidates,
21
24
  resolveServerUrl
22
- } from "./chunk-ISNCLGUZ.js";
23
- import {
24
- toErrorMessage
25
- } from "./chunk-HNMXYYJR.js";
25
+ } from "./chunk-5NBHQD4D.js";
26
26
 
27
27
  // packages/cli/agentRecordHelpers.ts
28
28
  import { readFileSync } from "node:fs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  selectCurrentServer,
3
3
  selectRemoteServers
4
- } from "./chunk-3NSIQZZ6.js";
4
+ } from "./chunk-JU7J7EAV.js";
5
5
  import {
6
6
  createUserKey,
7
7
  extractAgentInfo,
@@ -16,7 +16,7 @@ import {
16
16
  noloWriteRequest,
17
17
  selectIdentityUser,
18
18
  selectIdentityUserId
19
- } from "./chunk-OOM6SJNR.js";
19
+ } from "./chunk-TSUJOM6N.js";
20
20
  import {
21
21
  normalizeTimeFields
22
22
  } from "./chunk-OOSFSFMA.js";
@@ -1,20 +1,23 @@
1
1
  import {
2
2
  createCliLocalRuntimeAdapter,
3
3
  summarizeEndpoint
4
- } from "./chunk-X2S7JTIG.js";
4
+ } from "./chunk-KWBH4RAL.js";
5
5
  import {
6
6
  clipMultilineText
7
- } from "./chunk-2W2VYVI5.js";
8
- import {
9
- readPipeText,
10
- spawnProcess
11
- } from "./chunk-IDZTNRP2.js";
7
+ } from "./chunk-MZHSAPZP.js";
12
8
  import {
13
9
  runLocalAgentTurn
14
- } from "./chunk-S3GS2PRL.js";
10
+ } from "./chunk-TA7VKOHU.js";
15
11
  import {
16
12
  resolveLocalRuntimeEnvFromPolicy
17
- } from "./chunk-5CS33IBL.js";
13
+ } from "./chunk-PDL2AV3E.js";
14
+ import {
15
+ toErrorMessage
16
+ } from "./chunk-HNMXYYJR.js";
17
+ import {
18
+ readPipeText,
19
+ spawnProcess
20
+ } from "./chunk-IDZTNRP2.js";
18
21
  import {
19
22
  asRecordOrEmpty
20
23
  } from "./chunk-KX6YBIHG.js";
@@ -22,14 +25,8 @@ import {
22
25
  asTrimmedNonEmptyStringArray
23
26
  } from "./chunk-I42VC5KR.js";
24
27
  import {
25
- parseUserIdFromAuthToken
26
- } from "./chunk-ISNCLGUZ.js";
27
- import {
28
- DEFAULT_NOLO_SERVER_URL
29
- } from "./chunk-OLZBQWZU.js";
30
- import {
31
- toErrorMessage
32
- } from "./chunk-HNMXYYJR.js";
28
+ isRecord
29
+ } from "./chunk-KUG52IAP.js";
33
30
  import {
34
31
  asTrimmedString
35
32
  } from "./chunk-3EUW3WEO.js";
@@ -37,8 +34,11 @@ import {
37
34
  asOptionalPositiveFiniteNumber
38
35
  } from "./chunk-U6VC4MU4.js";
39
36
  import {
40
- isRecord
41
- } from "./chunk-KUG52IAP.js";
37
+ parseUserIdFromAuthToken
38
+ } from "./chunk-5NBHQD4D.js";
39
+ import {
40
+ DEFAULT_NOLO_SERVER_URL
41
+ } from "./chunk-OLZBQWZU.js";
42
42
  import {
43
43
  asOptionalTrimmedString
44
44
  } from "./chunk-G3SUCT4W.js";