nolo-cli 0.154.0-alpha.1 → 0.154.0

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 (163) hide show
  1. package/{_executeModel-SDGDBNX5.js → _executeModel-3HHZYHHB.js} +54 -54
  2. package/{accountResolver-7RYB4D2P.js → accountResolver-55EDKEIK.js} +1 -1
  3. package/{action-SXJD5N5R.js → action-GPPJC5TI.js} +5 -5
  4. package/{addContentAction-65ONHX2T.js → addContentAction-XJQEJ4XW.js} +8 -8
  5. package/{addDialogAgentAction-WOLK7RB4.js → addDialogAgentAction-5WZX5CAY.js} +7 -7
  6. package/{agentDeleteCommand-W2XXF27A.js → agentDeleteCommand-ON2KVSJ5.js} +74 -75
  7. package/{agentEmailCommands-MSFGRDUZ.js → agentEmailCommands-2QPD5VP3.js} +77 -78
  8. package/{agentListCommands-G36AMSBR.js → agentListCommands-L33M3I6V.js} +35 -35
  9. package/{agentMachineCommands-YVVPDIHJ.js → agentMachineCommands-V44DPSED.js} +34 -31
  10. package/{agentProviderCommands-X2HQE6HY.js → agentProviderCommands-CXBHNONN.js} +5 -5
  11. package/{agentPullCommand-FA43RBRU.js → agentPullCommand-GXXEDOSA.js} +4 -4
  12. package/{agentRecordCommands-7G3DDI4L.js → agentRecordCommands-CKILCNQZ.js} +71 -72
  13. package/{agentRunCommand-ET7LIY7J.js → agentRunCommand-6IN7NK7H.js} +74 -74
  14. package/{agentRunControl-2C5GM3BW.js → agentRunControl-XBSNHHZE.js} +7 -7
  15. package/{agentRuntimeLocal-Q7ZOMZC7.js → agentRuntimeLocal-XCKO5FVP.js} +20 -18
  16. package/{agentSlice-MK5JTSZR.js → agentSlice-YT3VCCEW.js} +8 -8
  17. package/{appDeleteCommands-MMWT54BR.js → appDeleteCommands-2PJFNLAJ.js} +30 -28
  18. package/{appDeployCommands-OIFXVDOF.js → appDeployCommands-AZCMCMK6.js} +30 -28
  19. package/{appDeployStatusCommands-OTXMSDFB.js → appDeployStatusCommands-HSIKPVJN.js} +30 -28
  20. package/{appGetCommands-JPY36ANL.js → appGetCommands-IUZCPAP7.js} +30 -28
  21. package/{appListCommands-IHJGN36O.js → appListCommands-JLFVS44M.js} +30 -28
  22. package/{authCommand-J3XILHWW.js → authCommand-3Z52KJID.js} +22 -302
  23. package/{authCommands-77CHYBGF.js → authCommands-QOCKVPX3.js} +5 -5
  24. package/{builtinSkillRegistry-A6VSPJEJ.js → builtinSkillRegistry-LJV7FHNI.js} +4 -4
  25. package/{chromeCommands-OBBNJCLS.js → chromeCommands-IY4NVSXZ.js} +17 -10
  26. package/{chunk-SW4S4XYB.js → chunk-2AB2HA4M.js} +84 -34
  27. package/{chunk-YBNHPX4S.js → chunk-2ODX2C4E.js} +155 -31
  28. package/{chunk-FDT27L7S.js → chunk-2XDQAWBM.js} +18 -16
  29. package/{chunk-UGN77YJU.js → chunk-2ZYCNT2O.js} +232 -76
  30. package/{chunk-QFEW2ULV.js → chunk-32ZKZET7.js} +1 -1
  31. package/{chunk-QRRFQFFU.js → chunk-3GTVM7NJ.js} +22 -22
  32. package/{chunk-XPWGOTBQ.js → chunk-3L2WKC3W.js} +1 -8
  33. package/{chunk-LGCICX53.js → chunk-3L5MSPWX.js} +1 -1
  34. package/{chunk-4YRTZIVN.js → chunk-43OFVLWJ.js} +6 -6
  35. package/{chunk-6TF64IF2.js → chunk-4L4K6YR7.js} +16 -2
  36. package/{chunk-P5QACQDK.js → chunk-62TBKWTV.js} +1 -1
  37. package/{chunk-TRW43TSC.js → chunk-6EQD4AQL.js} +41 -1
  38. package/{chunk-YLMMECCH.js → chunk-6XIE5ZGI.js} +1 -1
  39. package/{chunk-UUPR3TD7.js → chunk-7RF4O6AT.js} +1 -3
  40. package/{chunk-OGI4JKBD.js → chunk-BAWAKW7X.js} +2 -2
  41. package/{chunk-2GGXHQIW.js → chunk-BLVSFYQ3.js} +4 -2
  42. package/{chunk-A7HQF6YH.js → chunk-CDLP56BS.js} +9 -9
  43. package/{chunk-5MM7NNO6.js → chunk-CNWKLQRL.js} +8 -3
  44. package/{chunk-TJ2VPCBE.js → chunk-DD2EOI6S.js} +2 -2
  45. package/{chunk-36OMEXXR.js → chunk-DLV3H464.js} +8 -8
  46. package/{chunk-4WLENVCW.js → chunk-DT7EWFTY.js} +6 -6
  47. package/{chunk-C5DLHL3R.js → chunk-ESMZW5PE.js} +3 -3
  48. package/{chunk-FJRGRIVL.js → chunk-EVPKKBSI.js} +17 -16
  49. package/{chunk-PSJWPSKS.js → chunk-EWO77ZGF.js} +9 -43
  50. package/{chunk-ZWG3C7VI.js → chunk-F3SOW2EU.js} +81 -1
  51. package/{chunk-RGBBF2RB.js → chunk-F5WASHQA.js} +279 -138
  52. package/{chunk-GJRCYN5X.js → chunk-FB5WLEOD.js} +21 -17
  53. package/{chunk-HHC5FJHS.js → chunk-FCUKCVKN.js} +12 -8
  54. package/{chunk-FY4SDK2E.js → chunk-FDLDMJTM.js} +1 -1
  55. package/{chunk-EM3YOZJ4.js → chunk-FFHV45HO.js} +3 -3
  56. package/{chunk-SWZEIKWQ.js → chunk-FZYKQFBQ.js} +3 -3
  57. package/{chunk-7KYVUFDG.js → chunk-G3VYRPTV.js} +5 -267
  58. package/{chunk-6MJNEXUU.js → chunk-HGDKT2D6.js} +4 -0
  59. package/{chunk-LXTNZVD4.js → chunk-HW7EBEC5.js} +35 -207
  60. package/{chunk-B2EGWZJG.js → chunk-I7S63QUU.js} +1 -1
  61. package/{chunk-PDJ6ZODI.js → chunk-IF7V3CBU.js} +1 -1
  62. package/{chunk-T6CBQ6BN.js → chunk-INFHX73M.js} +1 -1
  63. package/{chunk-N37ERV4O.js → chunk-JDKSYQQN.js} +5 -5
  64. package/{chunk-K43ZF2C3.js → chunk-JPPQ3GUO.js} +1 -1
  65. package/{chunk-PSYTZ4LK.js → chunk-JSB2OPQT.js} +134 -126
  66. package/{chunk-VEJFPTX7.js → chunk-JWEXJ573.js} +3 -3
  67. package/{chunk-ZG73GDYU.js → chunk-K25WQPP3.js} +253 -57
  68. package/{chunk-HKT6QXP3.js → chunk-KABQ74UQ.js} +5 -5
  69. package/{chunk-I2ZMGXXF.js → chunk-KFHREHUQ.js} +1 -1
  70. package/{chunk-3C2QLERX.js → chunk-KMDDG73K.js} +1 -1
  71. package/{chunk-AIZE5TDM.js → chunk-MAYW6V3E.js} +2 -2
  72. package/{chunk-IPAW7XLD.js → chunk-MFVOJ6KF.js} +2 -2
  73. package/{chunk-CBHGZRCE.js → chunk-MYOH447Z.js} +1 -1
  74. package/{chunk-TPG4CZHI.js → chunk-NHEWV5FD.js} +17 -3
  75. package/{chunk-G47IPDOK.js → chunk-O2IWR23M.js} +1 -1
  76. package/{chunk-OU7WCUB5.js → chunk-OLVOR45M.js} +2 -2
  77. package/{chunk-SUKSWFLP.js → chunk-PIG2IUVZ.js} +1 -1
  78. package/{chunk-SEJ5OS6F.js → chunk-PXYBUFDB.js} +4 -0
  79. package/{chunk-2MTE2PEH.js → chunk-QA2C5NKI.js} +5 -739
  80. package/{chunk-TYND6RDQ.js → chunk-QI2WVWXV.js} +73 -2
  81. package/{chunk-L6EQV5OC.js → chunk-QXZH5UDF.js} +3 -3
  82. package/{chunk-24UXUXPR.js → chunk-QZIOZDM6.js} +10 -10
  83. package/{chunk-C7M4N5RA.js → chunk-R2KWTENX.js} +3 -3
  84. package/{chunk-TNIX77YM.js → chunk-R5GO3YZP.js} +34 -1
  85. package/{chunk-UTIMX333.js → chunk-RIHQGFFA.js} +1 -1
  86. package/{chunk-4Z245KOA.js → chunk-SH3XD4E2.js} +8 -4
  87. package/{chunk-MM3662RS.js → chunk-SNAWGDXT.js} +263 -4
  88. package/{chunk-JGRPBIZZ.js → chunk-SQX235S2.js} +1 -1
  89. package/chunk-TT644UJD.js +188 -0
  90. package/{chunk-IYBIRCQV.js → chunk-U34KT53V.js} +29 -11
  91. package/{chunk-ANJTRG52.js → chunk-ULQAD7ZY.js} +18 -43
  92. package/{chunk-LOLOIIIP.js → chunk-UY73HNIN.js} +704 -663
  93. package/{chunk-I2RMFLLH.js → chunk-V7PCFWX3.js} +1 -1
  94. package/{chunk-KX6LPG7W.js → chunk-VXS4YYJ2.js} +8 -8
  95. package/{chunk-HXHSTRGH.js → chunk-VYNMQ6HW.js} +0 -27
  96. package/{chunk-IJERIUXS.js → chunk-WRCZXJ4N.js} +6 -3
  97. package/chunk-Y5GCAMGP.js +9 -0
  98. package/{chunk-JZX2XLKC.js → chunk-YCRROBDY.js} +1 -1
  99. package/{chunk-EYWJT7A2.js → chunk-YPG7TUQD.js} +3 -3
  100. package/chunk-YR47Y7CN.js +2685 -0
  101. package/{chunk-NEJZ5GLD.js → chunk-ZAV4YVEA.js} +18 -2
  102. package/{chunk-YANF2RR4.js → chunk-ZPKUJROL.js} +1 -1
  103. package/{chunk-WUR6LY7R.js → chunk-ZSLIYVIQ.js} +7 -7
  104. package/{commandRegistry-VSJPFX6B.js → commandRegistry-4LWXIPNX.js} +88 -96
  105. package/{contentThunks-65BTQQQE.js → contentThunks-QBL5NK2W.js} +21 -21
  106. package/{createAgentAutomationAction-SRMBZTAO.js → createAgentAutomationAction-5UWBLR2N.js} +21 -21
  107. package/{createDialogAction-OWAU72JP.js → createDialogAction-NJ2LE7KC.js} +25 -25
  108. package/{createPageAction-D4XGNX3P.js → createPageAction-7T3RINS2.js} +24 -25
  109. package/{dbSlice-S2HYXURM.js → dbSlice-6PVPY44C.js} +7 -7
  110. package/{deleteFile-6JWDDRVP.js → deleteFile-YM6NDPAR.js} +5 -5
  111. package/{dialogCommands-H3K7PTF6.js → dialogCommands-KMECTGCW.js} +34 -31
  112. package/{dialogSlice-GEBK3X5L.js → dialogSlice-GQMTD4HR.js} +20 -20
  113. package/{dist-NJC2W7I4.js → dist-Q2JSMAKA.js} +7 -361
  114. package/{docCreateCommands-KP64KMVL.js → docCreateCommands-4IT5PUAL.js} +31 -29
  115. package/{docDeleteCommands-C3F4SZSR.js → docDeleteCommands-QS66YNZV.js} +32 -30
  116. package/{docReadCommands-7H6BDOUR.js → docReadCommands-3SAI46YC.js} +31 -29
  117. package/{docStore-ARTZTJRA.js → docStore-PM5PYKPZ.js} +8 -8
  118. package/{docUpdateCommands-JDW4BRBH.js → docUpdateCommands-OGYG5BRC.js} +31 -29
  119. package/{getPricing-TX35D7PI.js → getPricing-XQ3N3RBP.js} +2 -2
  120. package/{handleSendMessageAction-SPGAO47U.js → handleSendMessageAction-EQ3U6K5N.js} +43 -39
  121. package/index.js +8 -8
  122. package/{localRuntimeAdapter-CHLHJSA3.js → localRuntimeAdapter-MO64KEOS.js} +69 -68
  123. package/{localRuntimeAuthority-JDAD7CB6.js → localRuntimeAuthority-BPN5OAQG.js} +2 -2
  124. package/{localRuntimeDb-CVC62PM5.js → localRuntimeDb-QIVAXMUL.js} +1 -1
  125. package/{machineCommands-GVFN64CM.js → machineCommands-7MBJJY4K.js} +79 -78
  126. package/{machineWsRunDispatch-3WXQ57DN.js → machineWsRunDispatch-T4LFRJL3.js} +69 -70
  127. package/{memberThunks-VPTET5M2.js → memberThunks-AZINUM4S.js} +10 -10
  128. package/package.json +6 -2
  129. package/{profileConfig-ZGOFORWV.js → profileConfig-KN3N2BLF.js} +7 -1
  130. package/{providerPresetApply-CRZFMQD5.js → providerPresetApply-PKUOHQJT.js} +5 -5
  131. package/{providerRegistry-7IS43D3X.js → providerRegistry-HNQLIFN2.js} +5 -5
  132. package/{read-VMMIHEAK.js → read-7JPIWRBQ.js} +5 -5
  133. package/{readDocTool-4XSLKYSQ.js → readDocTool-AAQTB2Y3.js} +1 -1
  134. package/{readlineWorkspace-2WGUU7KH.js → readlineWorkspace-2DR5GHLQ.js} +374 -199
  135. package/{removeDialogAgentAction-YIV37ENV.js → removeDialogAgentAction-RMVRILLK.js} +9 -9
  136. package/{runAgentClientLoop-WS2HFGIR.js → runAgentClientLoop-EXIQDX7G.js} +58 -53
  137. package/{runtimeDoctorCommands-56NWKNON.js → runtimeDoctorCommands-MMCP4B4U.js} +12 -12
  138. package/{secretCommands-ZXZRLR3R.js → secretCommands-DNY56NSU.js} +11 -1
  139. package/{setDialogExtraReferencesAction-FWVD656I.js → setDialogExtraReferencesAction-L3V7JTMG.js} +8 -8
  140. package/{setPrimaryDialogAgentAction-HIPQTT6N.js → setPrimaryDialogAgentAction-X52JQGTJ.js} +9 -9
  141. package/settingThunks-N6XFWPOU.js +923 -0
  142. package/{spaceCommands-JQN7D4FE.js → spaceCommands-WQMUCGV7.js} +28 -26
  143. package/{streamAgentChatTurn-OSGLMHT6.js → streamAgentChatTurn-DI2334G3.js} +153 -94
  144. package/{switchDialogAgentAction-SLTPB635.js → switchDialogAgentAction-ZJ5CGU7J.js} +7 -7
  145. package/{tableCommands-U3QDY4L6.js → tableCommands-IVC5S7Y3.js} +11 -11
  146. package/{toolApiClient-7WSJJJBV.js → toolApiClient-HGNO53TC.js} +2 -2
  147. package/{tools-XF5A6N2B.js → tools-23VQGJOX.js} +42 -43
  148. package/{tuiSummaryLlmCaller-KLK6K3Q3.js → tuiSummaryLlmCaller-FESHBDTT.js} +7 -7
  149. package/{updateCommands-NQXAGFM7.js → updateCommands-ODWC7SK7.js} +5 -3
  150. package/{updateDialogTitleAction-IN5TBR23.js → updateDialogTitleAction-AGAYHWS7.js} +21 -21
  151. package/{workloadLifecycle-36DXRZKU.js → workloadLifecycle-6O6PMISX.js} +2 -2
  152. package/chunk-IA7TRNNR.js +0 -11
  153. package/chunk-ON3WLDG2.js +0 -7012
  154. package/chunk-UKZX3NHN.js +0 -48
  155. package/chunk-W4S6OTSC.js +0 -35
  156. package/clipboardy-GCO3GT3I.js +0 -11793
  157. package/settingThunks-SB37UY4C.js +0 -1371
  158. package/{agentGrantCommands-HOJ3JBBQ.js → agentGrantCommands-5DPHYEKP.js} +3 -3
  159. package/{chromeOpsCommands-3Z34RKSE.js → chromeOpsCommands-GZVVK7HU.js} +4 -4
  160. package/{chunk-XETG4RIX.js → chunk-AETZ7AD6.js} +4 -4
  161. package/{chunk-2IXDJNZI.js → chunk-GAGGEA7D.js} +3 -3
  162. package/{memoryCommands-CUNBFRVS.js → memoryCommands-ZS3VQJAL.js} +3 -3
  163. package/{offlineMarxistsAgentCommand-2QTHJCHV.js → offlineMarxistsAgentCommand-3GLX4QQY.js} +3 -3
@@ -2,13 +2,13 @@ import {
2
2
  isAgentRunTerminalStatus,
3
3
  normalizeRunTitle
4
4
  } from "./chunk-PJNFNEJE.js";
5
- import {
6
- resolvePlatformAuthToken
7
- } from "./chunk-SUKSWFLP.js";
8
5
  import {
9
6
  isCompiledBinary,
10
7
  resolveCliEntrypointPath
11
8
  } from "./chunk-A7GB5UGH.js";
9
+ import {
10
+ resolvePlatformAuthToken
11
+ } from "./chunk-PIG2IUVZ.js";
12
12
 
13
13
  // packages/cli/client/originShellApprovalTransport.ts
14
14
  import { realpathSync } from "node:fs";
@@ -324,6 +324,233 @@ import { dirname, isAbsolute as isAbsolute2, join, resolve } from "node:path";
324
324
  import * as nodeFs from "node:fs";
325
325
  import { execFileSync as nodeExecFileSync, spawn as nodeSpawn } from "node:child_process";
326
326
 
327
+ // packages/cli/client/hostMemory.ts
328
+ import { readFileSync, existsSync } from "node:fs";
329
+ import { freemem as osFreemem, totalmem as osTotalmem } from "node:os";
330
+ var PROC_MEMINFO_PATH = "/proc/meminfo";
331
+ var PROC_MOUNTS_PATH = "/proc/mounts";
332
+ var DEFAULT_CGROUP2_MOUNT = "/sys/fs/cgroup";
333
+ var SANDBOX_MARKER_PATHS = ["/.dockerenv", "/run/.containerenv"];
334
+ var PROC_SELF_CGROUP_PATH = "/proc/self/cgroup";
335
+ var SANDBOX_CGROUP_PATTERN = /(docker|kubepods|instabox|containerd)/;
336
+ var MEMORY_AVAILABLE_RATIO_THRESHOLD = 0.15;
337
+ var SWAP_USED_RATIO_THRESHOLD = 0.7;
338
+ var HOST_MEMORY_PRESSURE_HINT = "\u26A0 \u5185\u5B58\u504F\u7D27\uFF0C\u5EFA\u8BAE\u91CD\u6D3B\u653E\u6C99\u76D2/\u8FDC\u7AEF\u6216\u51CF\u5C11\u5E76\u53D1";
339
+ var BYTES_PER_MB = 1024 * 1024;
340
+ function toMbFromBytes(bytes) {
341
+ return Math.round(bytes / BYTES_PER_MB);
342
+ }
343
+ function kbToMb(kb) {
344
+ return Math.round(kb / 1024);
345
+ }
346
+ function tryReadText(deps, path) {
347
+ try {
348
+ const reader = deps.readFile ?? ((p) => readFileSync(p, "utf8"));
349
+ const text = reader(path);
350
+ return typeof text === "string" ? text : null;
351
+ } catch {
352
+ return null;
353
+ }
354
+ }
355
+ function tryExists(deps, path) {
356
+ try {
357
+ const checker = deps.exists ?? ((p) => existsSync(p));
358
+ return checker(path) === true;
359
+ } catch {
360
+ return false;
361
+ }
362
+ }
363
+ function readKbValue(text, key) {
364
+ const match = new RegExp(`^${key}:\\s*(\\d+)`, "m").exec(text);
365
+ if (!match) return null;
366
+ const value = Number.parseInt(match[1], 10);
367
+ return Number.isFinite(value) ? value : null;
368
+ }
369
+ function parseProcMeminfo(text) {
370
+ if (typeof text !== "string" || text.length === 0) return null;
371
+ const totalKb = readKbValue(text, "MemTotal");
372
+ const availableKb = readKbValue(text, "MemAvailable");
373
+ if (totalKb === null || availableKb === null) return null;
374
+ if (!(totalKb > 0)) return null;
375
+ const swapTotalKb = readKbValue(text, "SwapTotal") ?? 0;
376
+ const swapFreeKb = readKbValue(text, "SwapFree") ?? 0;
377
+ return {
378
+ source: "proc-meminfo",
379
+ totalMb: kbToMb(totalKb),
380
+ availableMb: kbToMb(Math.max(0, availableKb)),
381
+ swapTotalMb: kbToMb(Math.max(0, swapTotalKb)),
382
+ swapUsedMb: kbToMb(Math.max(0, swapTotalKb - swapFreeKb)),
383
+ hostAvailableMb: null
384
+ };
385
+ }
386
+ function detectSandbox(deps = {}) {
387
+ const platform = deps.platform ?? process.platform;
388
+ if (platform !== "linux") return false;
389
+ for (const marker of SANDBOX_MARKER_PATHS) {
390
+ if (tryExists(deps, marker)) return true;
391
+ }
392
+ const selfCgroup = tryReadText(deps, PROC_SELF_CGROUP_PATH);
393
+ return selfCgroup !== null && SANDBOX_CGROUP_PATTERN.test(selfCgroup);
394
+ }
395
+ function readOsView(deps) {
396
+ const os = deps.os ?? { totalmem: osTotalmem, freemem: osFreemem };
397
+ try {
398
+ const totalMb = toMbFromBytes(os.totalmem());
399
+ const availableMb = toMbFromBytes(os.freemem());
400
+ if (!(totalMb > 0) || !Number.isFinite(availableMb)) return null;
401
+ return {
402
+ source: "os",
403
+ totalMb,
404
+ availableMb: Math.max(0, availableMb),
405
+ // os 没有可移植的 swap 口径:按契约显示 n/a,而不是编一个数字。
406
+ swapTotalMb: null,
407
+ swapUsedMb: null,
408
+ hostAvailableMb: null
409
+ };
410
+ } catch {
411
+ return null;
412
+ }
413
+ }
414
+ function readHostView(deps) {
415
+ const platform = deps.platform ?? process.platform;
416
+ if (platform === "linux") {
417
+ const text = tryReadText(deps, PROC_MEMINFO_PATH);
418
+ if (text !== null) {
419
+ const parsed = parseProcMeminfo(text);
420
+ if (parsed) return parsed;
421
+ }
422
+ }
423
+ return readOsView(deps);
424
+ }
425
+ function parseCgroup2RelativePath(text) {
426
+ for (const line of text.split("\n")) {
427
+ const trimmed = line.trim();
428
+ if (!trimmed) continue;
429
+ const parts = trimmed.split(":");
430
+ if (parts.length < 3 || parts[0] !== "0" || parts[1] !== "") continue;
431
+ const path = parts.slice(2).join(":").trim();
432
+ if (!path) continue;
433
+ return path.startsWith("/") ? path : `/${path}`;
434
+ }
435
+ return null;
436
+ }
437
+ function parseCgroup2MountPoint(mountsText) {
438
+ for (const line of mountsText.split("\n")) {
439
+ const fields = line.trim().split(/\s+/);
440
+ if (fields.length < 3) continue;
441
+ if (fields[2] !== "cgroup2") continue;
442
+ const mountPoint = fields[1].replace(/\\040/g, " ");
443
+ if (mountPoint.startsWith("/")) return mountPoint;
444
+ }
445
+ return null;
446
+ }
447
+ function cgroupAncestorDirs(mountPoint, relativePath) {
448
+ const base = mountPoint.length > 1 && mountPoint.endsWith("/") ? mountPoint.slice(0, -1) : mountPoint;
449
+ const dirs = [];
450
+ if (relativePath && relativePath !== "/") {
451
+ const rel = relativePath.startsWith("/") ? relativePath : `/${relativePath}`;
452
+ const segments = rel.split("/").filter(Boolean);
453
+ for (let depth = segments.length; depth >= 1; depth -= 1) {
454
+ dirs.push(`${base}/${segments.slice(0, depth).join("/")}`);
455
+ }
456
+ }
457
+ dirs.push(base);
458
+ return dirs;
459
+ }
460
+ function readCgroupMaxMb(deps, dir) {
461
+ const maxText = tryReadText(deps, `${dir}/memory.max`);
462
+ if (maxText === null) return null;
463
+ const maxRaw = maxText.trim();
464
+ if (maxRaw === "" || maxRaw === "max") return null;
465
+ const maxBytes = Number.parseInt(maxRaw, 10);
466
+ if (!Number.isFinite(maxBytes) || maxBytes <= 0) return null;
467
+ const totalMb = toMbFromBytes(maxBytes);
468
+ return totalMb > 0 ? totalMb : null;
469
+ }
470
+ function buildCgroupSnapshot(deps, dir, totalMb, hostView) {
471
+ const currentText = tryReadText(deps, `${dir}/memory.current`);
472
+ let usedMb = null;
473
+ if (currentText !== null) {
474
+ const currentBytes = Number.parseInt(currentText.trim(), 10);
475
+ if (Number.isFinite(currentBytes)) {
476
+ usedMb = Math.min(totalMb, Math.max(0, toMbFromBytes(currentBytes)));
477
+ }
478
+ }
479
+ return {
480
+ source: "cgroup",
481
+ totalMb,
482
+ availableMb: usedMb === null ? null : Math.max(0, totalMb - usedMb),
483
+ // swap 不是 cgroup 配额的一部分,只能借宿主视角(Linux 上就是 /proc/meminfo)。
484
+ swapTotalMb: hostView?.swapTotalMb ?? null,
485
+ swapUsedMb: hostView?.swapUsedMb ?? null,
486
+ hostAvailableMb: hostView?.availableMb ?? null
487
+ };
488
+ }
489
+ function readCgroupLimitView(deps, hostView) {
490
+ const selfCgroupText = tryReadText(deps, PROC_SELF_CGROUP_PATH) ?? "";
491
+ const relativePath = parseCgroup2RelativePath(selfCgroupText);
492
+ const mountsText = tryReadText(deps, PROC_MOUNTS_PATH) ?? "";
493
+ const mountPoint = parseCgroup2MountPoint(mountsText) ?? DEFAULT_CGROUP2_MOUNT;
494
+ let limitingDir = null;
495
+ let limitingMb = Number.POSITIVE_INFINITY;
496
+ for (const dir of cgroupAncestorDirs(mountPoint, relativePath)) {
497
+ const totalMb = readCgroupMaxMb(deps, dir);
498
+ if (totalMb === null) continue;
499
+ if (totalMb < limitingMb) {
500
+ limitingMb = totalMb;
501
+ limitingDir = dir;
502
+ }
503
+ }
504
+ if (limitingDir === null) return null;
505
+ return buildCgroupSnapshot(deps, limitingDir, limitingMb, hostView);
506
+ }
507
+ function readHostMemory(deps = {}) {
508
+ const platform = deps.platform ?? process.platform;
509
+ if (platform !== "linux") {
510
+ return readHostView(deps);
511
+ }
512
+ const hostView = readHostView(deps);
513
+ const cgroupView = readCgroupLimitView(deps, hostView);
514
+ if (!cgroupView) return hostView;
515
+ return {
516
+ ...cgroupView,
517
+ scope: detectSandbox(deps) ? "sandbox" : "cgroup-limit"
518
+ };
519
+ }
520
+ function isHostMemoryTight(mem) {
521
+ if (!(mem.totalMb > 0)) return false;
522
+ if (mem.availableMb !== null && mem.availableMb / mem.totalMb < MEMORY_AVAILABLE_RATIO_THRESHOLD) {
523
+ return true;
524
+ }
525
+ if (mem.swapTotalMb !== null && mem.swapUsedMb !== null && mem.swapTotalMb > 0 && mem.swapUsedMb / mem.swapTotalMb > SWAP_USED_RATIO_THRESHOLD) {
526
+ return true;
527
+ }
528
+ return false;
529
+ }
530
+ function formatHostMemoryMb(mb) {
531
+ const value = Math.max(0, Math.round(Number.isFinite(mb) ? mb : 0));
532
+ if (value >= 1024) return `${(value / 1024).toFixed(1)}G`;
533
+ return `${value}M`;
534
+ }
535
+ function formatSwapPart(mem) {
536
+ if (mem.swapTotalMb === null || mem.swapUsedMb === null) return "swap n/a";
537
+ return `swap ${formatHostMemoryMb(mem.swapUsedMb)}/${formatHostMemoryMb(mem.swapTotalMb)}`;
538
+ }
539
+ function formatHostMemoryLine(mem) {
540
+ const usedMb = mem.availableMb === null ? null : Math.max(0, mem.totalMb - mem.availableMb);
541
+ let line;
542
+ if (mem.source === "cgroup") {
543
+ const hostAvailable = mem.hostAvailableMb === null ? "n/a" : formatHostMemoryMb(mem.hostAvailableMb);
544
+ const prefix = (mem.scope ?? "sandbox") === "cgroup-limit" ? "[\u9650\u989D] \u672C\u8FDB\u7A0B\u5185\u5B58" : "[sandbox] \u5BB9\u5668\u5185\u5B58";
545
+ const usage = usedMb === null ? "\u5360\u7528\u672A\u77E5" : formatHostMemoryMb(usedMb);
546
+ line = `${prefix} ${usage}/${formatHostMemoryMb(mem.totalMb)} \xB7 \u5BBF\u4E3B\u53EF\u7528 ${hostAvailable}`;
547
+ } else {
548
+ const available = mem.availableMb === null ? "n/a" : formatHostMemoryMb(mem.availableMb);
549
+ line = `\u672C\u5730\u5185\u5B58 ${formatHostMemoryMb(usedMb ?? 0)}/${formatHostMemoryMb(mem.totalMb)}\uFF08\u53EF\u7528 ${available}\uFF09\xB7 ${formatSwapPart(mem)}`;
550
+ }
551
+ return isHostMemoryTight(mem) ? `${line} \xB7 ${HOST_MEMORY_PRESSURE_HINT}` : line;
552
+ }
553
+
327
554
  // packages/cli/client/localRuntimeHelpers.ts
328
555
  var REMOTE_DIALOG_SYNC_TIMEOUT_MS = 1e4;
329
556
  var remoteDialogSyncTimeoutMsForTest;
@@ -1183,6 +1410,29 @@ function buildAgentRunChildCommand(options, deps = {}) {
1183
1410
  }
1184
1411
  return { execPath, childArgs: [entrypoint, ...commandParts, ...strippedArgs] };
1185
1412
  }
1413
+ function safeReadHostMemory(reader) {
1414
+ try {
1415
+ return reader();
1416
+ } catch {
1417
+ return null;
1418
+ }
1419
+ }
1420
+ function emitHostMemoryNotice(mem, output) {
1421
+ if (!mem || !output) return void 0;
1422
+ let notice;
1423
+ try {
1424
+ notice = formatHostMemoryLine(mem);
1425
+ } catch {
1426
+ return void 0;
1427
+ }
1428
+ try {
1429
+ output.write(`${notice}
1430
+ `);
1431
+ } catch {
1432
+ return notice;
1433
+ }
1434
+ return notice;
1435
+ }
1186
1436
  async function spawnLocalBackgroundRun(input, deps = {}) {
1187
1437
  const env = deps.env ?? process.env;
1188
1438
  const homedir = deps.homedir ?? nodeHomedir;
@@ -1266,6 +1516,7 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
1266
1516
  NOLO_AGENT_RUN_CHILD: "1",
1267
1517
  NOLO_AGENT_RUN_ID: runId
1268
1518
  };
1519
+ const hostMemory = safeReadHostMemory(deps.readHostMemory ?? readHostMemory);
1269
1520
  const logFd = fs.openSync(logPath, "a");
1270
1521
  const proc = spawn(execPath, childArgs, {
1271
1522
  cwd: input.cwd,
@@ -1283,6 +1534,7 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
1283
1534
  proc.channel?.unref?.();
1284
1535
  }
1285
1536
  proc.unref();
1537
+ const hostMemoryNotice = emitHostMemoryNotice(hostMemory, input.output);
1286
1538
  if (typeof proc.pid === "number") {
1287
1539
  const processStartedAt = (deps.getProcessStartTime ?? defaultGetProcessStartTime)(proc.pid);
1288
1540
  withRunRecordLock(runId, deps, () => {
@@ -1292,7 +1544,14 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
1292
1544
  writeRunRecord(latest, deps);
1293
1545
  });
1294
1546
  }
1295
- return { runId, pid: proc.pid, logPath, queuePath, batchId };
1547
+ return {
1548
+ runId,
1549
+ pid: proc.pid,
1550
+ logPath,
1551
+ queuePath,
1552
+ batchId,
1553
+ ...hostMemoryNotice ? { hostMemoryNotice } : {}
1554
+ };
1296
1555
  }
1297
1556
  function ackRunRecord(runId, deps = {}) {
1298
1557
  withRunRecordLock(runId, deps, () => {
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-WWC7I6TA.js";
4
4
  import {
5
5
  trimTrailingSlash
6
- } from "./chunk-SUKSWFLP.js";
6
+ } from "./chunk-PIG2IUVZ.js";
7
7
  import {
8
8
  toErrorMessage
9
9
  } from "./chunk-HNMXYYJR.js";
@@ -0,0 +1,188 @@
1
+ import {
2
+ shouldUseServerProxy
3
+ } from "./chunk-F3SOW2EU.js";
4
+ import {
5
+ ANTIGRAVITY_CLOUD_CODE_BASE_URL,
6
+ isAntigravityCloudCodeBaseUrl,
7
+ isAntigravityOAuthAgent
8
+ } from "./chunk-SQX235S2.js";
9
+ import {
10
+ isOpenAiResponsesModel,
11
+ resolvePlatformChatCompletionsEndpoint,
12
+ resolvePlatformResponsesEndpoint
13
+ } from "./chunk-V7PCFWX3.js";
14
+ import {
15
+ findModelConfig
16
+ } from "./chunk-6EQD4AQL.js";
17
+ import {
18
+ asOptionalTrimmedString
19
+ } from "./chunk-G3SUCT4W.js";
20
+ import {
21
+ asTrimmedLowercaseString
22
+ } from "./chunk-QSJ3HFEF.js";
23
+
24
+ // packages/agent-runtime/agentCallPlan.ts
25
+ var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
26
+ var CURSOR_AGENT_URL = "https://api2.cursor.sh/agent.v1.AgentService/Run";
27
+ var DEVIN_CONNECT_URL = "https://server.codeium.com/exa.api_server_pb.ApiServerService/GetChatMessage";
28
+ function resolveClientWire(plan) {
29
+ if (plan.upstreamWire === "gemini-cca") return "chat.completions";
30
+ if (plan.upstreamWire === "anthropic-messages") return "chat.completions";
31
+ if (plan.upstreamWire === "cursor-connect") return "chat.completions";
32
+ if (plan.upstreamWire === "devin-connect") return "chat.completions";
33
+ if (plan.upstreamWire === "custom-gemini") return "chat.completions";
34
+ if (plan.upstreamWire === "custom-openai-responses") return "chat.completions";
35
+ if (plan.upstreamWire === "custom-anthropic-messages") return "chat.completions";
36
+ if (plan.upstreamWire === "responses" && plan.authMethod.kind === "oauth" && plan.authMethod.ref === "chatgpt") {
37
+ return "chat.completions";
38
+ }
39
+ return plan.upstreamWire;
40
+ }
41
+ var XAI_CHAT_COMPLETIONS_URL = "https://api.x.ai/v1/chat/completions";
42
+ var ANTHROPIC_MESSAGES_URL = "https://api.anthropic.com/v1/messages";
43
+ var CODEX_REQUIRED_HEADERS = [
44
+ "chatgpt-account-id",
45
+ "OpenAI-Beta",
46
+ "originator",
47
+ "version"
48
+ ];
49
+ var ANTIGRAVITY_REQUIRED_HEADERS = [
50
+ "User-Agent"
51
+ // antigravity-specific UA (matches getAntigravityUserAgent)
52
+ ];
53
+ function agentShouldUseServerProxy(agentConfig) {
54
+ return shouldUseServerProxy(agentConfig);
55
+ }
56
+ function resolveCustomUpstreamWire(endpoint, nativeProtocol) {
57
+ const responsesEndpoint = endpoint.includes("/responses");
58
+ if (nativeProtocol === "openai-responses" && responsesEndpoint) return "responses";
59
+ if (nativeProtocol === "gemini") return "custom-gemini";
60
+ if (nativeProtocol === "openai-responses") return "custom-openai-responses";
61
+ if (nativeProtocol === "anthropic-messages") return "custom-anthropic-messages";
62
+ return responsesEndpoint ? "responses" : "chat.completions";
63
+ }
64
+ function hasOwnCustomProviderKey(agentConfig) {
65
+ const endpoint = asOptionalTrimmedString(agentConfig.customProviderUrl);
66
+ if (!endpoint) return false;
67
+ if (isAntigravityCloudCodeBaseUrl(endpoint)) return false;
68
+ return Boolean(asOptionalTrimmedString(agentConfig.apiKey));
69
+ }
70
+ function resolveAgentCallPlan(agentConfig, _env) {
71
+ const apiKeyRef = asTrimmedLowercaseString(agentConfig.apiKeyRef);
72
+ const provider = asTrimmedLowercaseString(
73
+ agentConfig.provider ?? agentConfig.apiSource
74
+ );
75
+ const ownCustomKeyWins = hasOwnCustomProviderKey(agentConfig);
76
+ const oauthApiKeyRef = ownCustomKeyWins ? "" : apiKeyRef;
77
+ if (!ownCustomKeyWins && isAntigravityOAuthAgent(agentConfig)) {
78
+ return {
79
+ authMethod: { kind: "oauth", ref: "antigravity" },
80
+ transport: "server-proxy",
81
+ upstreamWire: "gemini-cca",
82
+ endpoint: ANTIGRAVITY_CLOUD_CODE_BASE_URL,
83
+ requiredHeaders: [...ANTIGRAVITY_REQUIRED_HEADERS],
84
+ vendor: provider || "google-antigravity"
85
+ };
86
+ }
87
+ if (oauthApiKeyRef === "chatgpt") {
88
+ return {
89
+ authMethod: { kind: "oauth", ref: "chatgpt" },
90
+ transport: "server-proxy",
91
+ upstreamWire: "responses",
92
+ endpoint: CODEX_RESPONSES_URL,
93
+ requiredHeaders: [...CODEX_REQUIRED_HEADERS],
94
+ vendor: provider || "openai"
95
+ };
96
+ }
97
+ if (oauthApiKeyRef === "claude") {
98
+ return {
99
+ authMethod: { kind: "oauth", ref: "claude" },
100
+ transport: "server-proxy",
101
+ upstreamWire: "anthropic-messages",
102
+ endpoint: ANTHROPIC_MESSAGES_URL,
103
+ requiredHeaders: ["anthropic-version", "anthropic-beta"],
104
+ vendor: provider || "anthropic"
105
+ };
106
+ }
107
+ if (oauthApiKeyRef === "xai") {
108
+ return {
109
+ authMethod: { kind: "oauth", ref: "xai" },
110
+ transport: "server-proxy",
111
+ upstreamWire: "chat.completions",
112
+ endpoint: XAI_CHAT_COMPLETIONS_URL,
113
+ requiredHeaders: [],
114
+ vendor: provider || "xai"
115
+ };
116
+ }
117
+ if (oauthApiKeyRef === "cursor") {
118
+ return {
119
+ authMethod: { kind: "oauth", ref: "cursor" },
120
+ transport: "server-proxy",
121
+ upstreamWire: "cursor-connect",
122
+ endpoint: CURSOR_AGENT_URL,
123
+ requiredHeaders: [
124
+ "x-cursor-client-version",
125
+ "x-cursor-client-type",
126
+ "x-ghost-mode"
127
+ ],
128
+ vendor: provider || "cursor"
129
+ };
130
+ }
131
+ if (oauthApiKeyRef === "devin" || !ownCustomKeyWins && provider === "devin") {
132
+ return {
133
+ authMethod: { kind: "oauth", ref: "devin" },
134
+ transport: "server-proxy",
135
+ upstreamWire: "devin-connect",
136
+ endpoint: DEVIN_CONNECT_URL,
137
+ requiredHeaders: ["connect-protocol-version"],
138
+ vendor: provider || "devin"
139
+ };
140
+ }
141
+ if (agentConfig.cliProvider || agentConfig.apiSource === "cli" || provider === "cli") {
142
+ return {
143
+ authMethod: { kind: "cli", provider: agentConfig.cliProvider || provider || "codex" },
144
+ transport: "direct",
145
+ upstreamWire: "cli",
146
+ endpoint: "",
147
+ requiredHeaders: [],
148
+ vendor: provider || "cli"
149
+ };
150
+ }
151
+ if (agentConfig.customProviderUrl || agentConfig.apiSource === "custom") {
152
+ const transport2 = agentShouldUseServerProxy(agentConfig) ? "server-proxy" : "direct";
153
+ const endpoint2 = asOptionalTrimmedString(agentConfig.customProviderUrl) ?? "";
154
+ const upstreamWire2 = resolveCustomUpstreamWire(
155
+ endpoint2,
156
+ findModelConfig(provider, agentConfig.model ?? "")?.nativeProtocol
157
+ );
158
+ return {
159
+ authMethod: { kind: "custom-key" },
160
+ transport: transport2,
161
+ upstreamWire: upstreamWire2,
162
+ endpoint: endpoint2,
163
+ requiredHeaders: [],
164
+ vendor: provider || "custom"
165
+ };
166
+ }
167
+ const transport = agentShouldUseServerProxy(agentConfig) ? "server-proxy" : "direct";
168
+ const useResponses = isOpenAiResponsesModel({
169
+ provider,
170
+ model: agentConfig.model,
171
+ endpointKey: agentConfig.endpointKey
172
+ });
173
+ const upstreamWire = useResponses ? "responses" : "chat.completions";
174
+ const endpoint = upstreamWire === "responses" ? resolvePlatformResponsesEndpoint(provider, agentConfig.model) ?? "" : resolvePlatformChatCompletionsEndpoint(provider, agentConfig.model) ?? "";
175
+ return {
176
+ authMethod: { kind: "platform-key" },
177
+ transport,
178
+ upstreamWire,
179
+ endpoint,
180
+ requiredHeaders: [],
181
+ vendor: provider || "openai"
182
+ };
183
+ }
184
+
185
+ export {
186
+ resolveClientWire,
187
+ resolveAgentCallPlan
188
+ };
@@ -1,7 +1,13 @@
1
+ import {
2
+ resolveAgentCallPlan
3
+ } from "./chunk-TT644UJD.js";
4
+ import {
5
+ SUBSCRIPTION_OAUTH_PROVIDERS
6
+ } from "./chunk-EWO77ZGF.js";
1
7
  import {
2
8
  findModelConfig,
3
9
  getProviderByModelName
4
- } from "./chunk-TRW43TSC.js";
10
+ } from "./chunk-6EQD4AQL.js";
5
11
  import {
6
12
  asOptionalTrimmedString
7
13
  } from "./chunk-G3SUCT4W.js";
@@ -90,16 +96,18 @@ var lookupKnownModelVision = (provider, model) => {
90
96
  if (provider && provider !== "custom") {
91
97
  const direct = findModelConfig(provider, candidate);
92
98
  if (direct && typeof direct.hasVision === "boolean") return direct.hasVision;
93
- }
94
- const detected = getProviderByModelName(candidate);
95
- if (detected) {
96
- const found = findModelConfig(detected, candidate)?.hasVision;
97
- if (found !== void 0) return found;
99
+ } else {
100
+ const detected = getProviderByModelName(candidate);
101
+ if (detected) {
102
+ const found = findModelConfig(detected, candidate)?.hasVision;
103
+ if (found !== void 0) return found;
104
+ }
98
105
  }
99
106
  if (candidate.includes("/")) {
100
107
  const slash = candidate.indexOf("/");
101
108
  const modelProvider = candidate.slice(0, slash).toLowerCase();
102
109
  const modelName = candidate.slice(slash + 1);
110
+ if (provider && provider !== "custom" && provider !== modelProvider) continue;
103
111
  const nested = findModelConfig(modelProvider, modelName);
104
112
  if (nested && typeof nested.hasVision === "boolean") return nested.hasVision;
105
113
  }
@@ -108,12 +116,22 @@ var lookupKnownModelVision = (provider, model) => {
108
116
  };
109
117
  var resolveAgentImageInputSupport = (agent) => {
110
118
  if (!agent) return true;
111
- const provider = asTrimmedLowercaseString(agent.provider) || null;
119
+ const provider = asTrimmedLowercaseString(agent.provider) || asTrimmedLowercaseString(agent.apiSource) || null;
112
120
  const model = asOptionalTrimmedString(agent.model) ?? "";
113
- const catalogHasVision = lookupKnownModelVision(
114
- provider,
115
- model
116
- );
121
+ const { authMethod } = resolveAgentCallPlan({
122
+ key: "",
123
+ provider: agent.provider ?? void 0,
124
+ apiSource: agent.apiSource ?? void 0,
125
+ cliProvider: agent.cliProvider ?? void 0,
126
+ model,
127
+ apiKeyRef: agent.apiKeyRef ?? void 0,
128
+ customProviderUrl: agent.customProviderUrl ?? void 0,
129
+ apiKey: agent.apiKey ?? void 0,
130
+ useServerProxy: agent.useServerProxy ?? void 0
131
+ });
132
+ const catalogHasVision = authMethod.kind === "oauth" ? SUBSCRIPTION_OAUTH_PROVIDERS.find((entry) => entry.apiKeyRef === authMethod.ref)?.modelOptions.find(
133
+ (entry) => [model, stripEffortSuffix(model), stripPreviewSuffix(model)].includes(entry.id)
134
+ )?.hasVision : lookupKnownModelVision(provider, model);
117
135
  if (catalogHasVision !== void 0) {
118
136
  return catalogHasVision;
119
137
  }
@@ -1,12 +1,6 @@
1
- import {
2
- isDevinOAuthAgent
3
- } from "./chunk-5ZUL4CUO.js";
4
1
  import {
5
2
  resolveAgentImageInputSupport
6
- } from "./chunk-IYBIRCQV.js";
7
- import {
8
- getModelContextWindow
9
- } from "./chunk-2MTE2PEH.js";
3
+ } from "./chunk-U34KT53V.js";
10
4
  import {
11
5
  asOptionalFiniteNumber
12
6
  } from "./chunk-WWC7I6TA.js";
@@ -39,9 +33,13 @@ function hasImageInRuntimeMessages(messages) {
39
33
  var IMAGE_OMITTED_PLACEHOLDER = "[Image content omitted: model does not support image input]";
40
34
  function stripImagePartsFromContent(content) {
41
35
  if (!Array.isArray(content)) return content;
42
- const filtered = content.filter((part) => part?.type !== "image_url");
43
- if (filtered.length === 0) return IMAGE_OMITTED_PLACEHOLDER;
44
- return filtered;
36
+ const hasImage = content.some((part) => part && typeof part === "object" && part.type === "image_url");
37
+ if (!hasImage) return content;
38
+ const hasNonImage = content.some((part) => part && typeof part === "object" && part.type !== "image_url");
39
+ if (!hasNonImage) return IMAGE_OMITTED_PLACEHOLDER;
40
+ return content.map(
41
+ (part) => part && typeof part === "object" && part.type === "image_url" ? { type: "text", text: IMAGE_OMITTED_PLACEHOLDER } : part
42
+ );
45
43
  }
46
44
  function stripImagePartsFromMessages(messages) {
47
45
  return messages.map((msg) => ({
@@ -51,39 +49,17 @@ function stripImagePartsFromMessages(messages) {
51
49
  }
52
50
  async function stripImagePartsForTextOnlyAgent(messages, agentConfig) {
53
51
  const supportsVision = resolveAgentImageInputSupport(agentConfig);
54
- const hasImages = hasImageInRuntimeMessages(messages);
55
- return { messages: !supportsVision && hasImages ? stripImagePartsFromMessages(messages) : messages };
52
+ const runtimeMessages = messages;
53
+ const hasImages = hasImageInRuntimeMessages(runtimeMessages);
54
+ const shouldStrip = !supportsVision && hasImages;
55
+ const omittedImageCount = shouldStrip ? extractImageUrlsFromMessages(runtimeMessages).length : 0;
56
+ return {
57
+ messages: shouldStrip ? stripImagePartsFromMessages(messages) : messages,
58
+ downgraded: shouldStrip,
59
+ omittedImageCount
60
+ };
56
61
  }
57
62
 
58
- // packages/agent-runtime/devin/devinChannelWindows.ts
59
- var DEVIN_CHANNEL_CONTEXT_WINDOWS = {
60
- // SWE-2 家族(catalog 无裸 swe-2 selector;旧点号/裸写法如 swe-2、
61
- // swe-1.7 实测均 permission_denied,已不是可用 selector)。
62
- "swe-2-max": 262e3,
63
- "swe-2-high": 262e3,
64
- "swe-2-medium": 262e3,
65
- // SWE-1.7 家族。
66
- "swe-1-7": 262e3,
67
- "swe-1-7-medium": 262e3,
68
- "swe-1-7-lightning": 202752,
69
- // SWE-1.6 家族(免费档默认)。
70
- "swe-1-6": 2e5,
71
- "swe-1-6-fast": 2e5,
72
- // 经 devin 通道转售、且与厂商原生窗口不同的模型(catalog 枚举型 selector)。
73
- "MODEL_GPT_5_2_LOW": 384e3,
74
- "MODEL_GPT_5_2_MEDIUM": 384e3,
75
- "MODEL_GPT_5_2_HIGH": 384e3,
76
- "MODEL_GPT_5_2_XHIGH": 384e3
77
- };
78
- var devinChannelContextWindow = (model) => {
79
- const raw = model?.trim();
80
- if (!raw) return void 0;
81
- return DEVIN_CHANNEL_CONTEXT_WINDOWS[raw];
82
- };
83
- var resolveAgentContextWindow = (agent) => (isDevinOAuthAgent(agent) ? devinChannelContextWindow(agent.model) : void 0) ?? // provider 透传给全局解析:平台托管通道(CF)与 Codex OAuth 等通道对同一 id
84
- // 窗口不同,按通道取真值,不做全局取大/取小。
85
- getModelContextWindow(agent.model ?? "", agent.provider);
86
-
87
63
  // packages/agent-runtime/agentRecordConfig.ts
88
64
  function stringField(record, key) {
89
65
  const value = record[key];
@@ -449,11 +425,10 @@ function assertDesktopAgentRuntimeTurnBodyHasNoRawSecrets(body) {
449
425
  }
450
426
 
451
427
  export {
428
+ extractImageUrlsFromMessages,
452
429
  hasImageInRuntimeMessages,
453
430
  stripImagePartsFromMessages,
454
431
  stripImagePartsForTextOnlyAgent,
455
- devinChannelContextWindow,
456
- resolveAgentContextWindow,
457
432
  resolveAgentRuntimeConfigFromRecord,
458
433
  buildDesktopAgentRuntimeAgentConfigSnapshot,
459
434
  buildDesktopAgentRuntimeDialogHistorySnapshot,