nolo-cli 0.14.0 → 0.15.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 (100) hide show
  1. package/{_executeModel-TURRLTZ2.js → _executeModel-QAUS6B7J.js} +24 -24
  2. package/{action-N3KXFO5V.js → action-GUOZYYGN.js} +4 -4
  3. package/{addContentAction-4Z762DMR.js → addContentAction-QDGHGUBH.js} +3 -3
  4. package/{addDialogAgentAction-FALLEKPR.js → addDialogAgentAction-Z4YCYZIV.js} +2 -2
  5. package/{agentDeleteCommand-AZDVM4HQ.js → agentDeleteCommand-QDO62EZA.js} +20 -20
  6. package/{agentEmailCommands-M4AHOEZ3.js → agentEmailCommands-UZ5BKX3P.js} +38 -38
  7. package/{agentGrantCommands-B4MB23VQ.js → agentGrantCommands-JNDE4RWR.js} +2 -2
  8. package/{agentListCommands-OJLOXSKL.js → agentListCommands-ZC33UDWT.js} +22 -22
  9. package/{agentMachineCommands-NPMM4Z53.js → agentMachineCommands-RZGZEZRL.js} +20 -20
  10. package/{agentPullCommand-KRBRIFIY.js → agentPullCommand-6HWUT3SW.js} +2 -2
  11. package/{agentRecordCommands-RVUH7XLZ.js → agentRecordCommands-DGDXE2VH.js} +33 -33
  12. package/{agentRunCommand-F6W2WKKZ.js → agentRunCommand-SRZWFOPH.js} +35 -35
  13. package/{agentRunControl-IX4F5W2C.js → agentRunControl-6ADXVYMR.js} +2 -2
  14. package/{agentRuntimeLocal-DSUBT77I.js → agentRuntimeLocal-4YCF6IRF.js} +11 -11
  15. package/{agentSlice-PCEL26Z7.js → agentSlice-IVE735EV.js} +3 -3
  16. package/appDeleteCommands-7I26L64I.js +124 -0
  17. package/appDeployCommands-TZLZNTJN.js +163 -0
  18. package/appDeployStatusCommands-OPPTLHRW.js +144 -0
  19. package/appGetCommands-N2S4HYKY.js +119 -0
  20. package/appListCommands-OBTPPKUM.js +122 -0
  21. package/{authCommand-66ME4KZX.js → authCommand-YFTR3347.js} +5 -5
  22. package/{authCommands-GH5T6RYV.js → authCommands-YXGOXNBZ.js} +3 -3
  23. package/{chunk-3B2LFO6R.js → browser-image-compression-MFDTD7K6.js} +4 -518
  24. package/{chunk-4UUJFFMK.js → chunk-472E5RMQ.js} +1 -1
  25. package/chunk-4QQFLN5C.js +552 -0
  26. package/{chunk-33K5FKRL.js → chunk-5VMYGIIL.js} +110 -39
  27. package/{chunk-LNSRTNH7.js → chunk-6565R2TI.js} +20 -16
  28. package/{chunk-VQFY3VXW.js → chunk-6MHDWKOT.js} +3 -2
  29. package/{chunk-5NBHQD4D.js → chunk-A7GB5UGH.js} +1 -1
  30. package/{chunk-NZFWHBW5.js → chunk-AWDOJBHW.js} +487 -441
  31. package/{chunk-MYE5X27Y.js → chunk-BFRVXJJJ.js} +43 -16
  32. package/{chunk-PYAJ6ZSK.js → chunk-G2MKOQCB.js} +1 -1
  33. package/chunk-GFUIQ4RY.js +136 -0
  34. package/{chunk-KTFJUPDW.js → chunk-HRQCKQA5.js} +31 -31
  35. package/{chunk-TQCONXQ3.js → chunk-IOQ7IBPU.js} +1 -1
  36. package/{chunk-OIMX7MM4.js → chunk-ISYE6GZB.js} +1 -1
  37. package/{chunk-RZALKBP4.js → chunk-IZ2QRVEU.js} +2 -2
  38. package/{chunk-XIDYAII4.js → chunk-JBKVPAYK.js} +7 -140
  39. package/{chunk-V6VXDXGY.js → chunk-JS33TCQ3.js} +2 -2
  40. package/{chunk-5R73BS7Y.js → chunk-K53477EY.js} +5 -5
  41. package/{chunk-7JJCGV7N.js → chunk-K6EUAOW3.js} +1 -1
  42. package/{chunk-OHEKYYJF.js → chunk-KMQPSTMJ.js} +6 -6
  43. package/{chunk-3WGLLTK4.js → chunk-LSFAWXKC.js} +100 -3
  44. package/{chunk-4ON5AV72.js → chunk-MYMMNKYL.js} +1 -1
  45. package/{chunk-BHK5ZAW7.js → chunk-N5424GSW.js} +1 -1
  46. package/chunk-NTC6I2FN.js +107 -0
  47. package/{chunk-7LAIOHOL.js → chunk-O53CP2QR.js} +3 -3
  48. package/{chunk-TLNEQI2R.js → chunk-OKSYPTDZ.js} +9 -9
  49. package/{chunk-IMZ7AFIJ.js → chunk-OQMPU2ML.js} +4 -4
  50. package/{chunk-IYGQF62W.js → chunk-P4MJQWWF.js} +3 -3
  51. package/{chunk-UW3WOIWJ.js → chunk-RKM3K52F.js} +1 -1
  52. package/{chunk-A5V7UEZJ.js → chunk-SFXYKGK2.js} +3 -3
  53. package/{chunk-S5UACFUP.js → chunk-TTGAVETO.js} +10 -2
  54. package/{chunk-BOJVWKNA.js → chunk-U7LEGLEB.js} +1 -1
  55. package/{chunk-E6KIDMTW.js → chunk-UXKQQ2MR.js} +9 -9
  56. package/{chunk-R5AOLZZV.js → chunk-VE6XMVKG.js} +203 -45
  57. package/{chunk-NJVPXLRY.js → chunk-VPTJB4HM.js} +1 -1
  58. package/{chunk-PB2DHBEQ.js → chunk-WA6KZL5V.js} +25 -6
  59. package/{chunk-T3X232L6.js → chunk-WNLPAOIT.js} +1 -1
  60. package/{chunk-NFPO7274.js → chunk-WRN5EQT7.js} +1 -1
  61. package/{chunk-4F4FJPFM.js → chunk-XGQZFBO5.js} +90 -209
  62. package/{chunk-3FCSMQAC.js → chunk-XVP3C2KY.js} +1 -1
  63. package/{chunk-TYRTLSGX.js → chunk-YNHQIXX5.js} +833 -5746
  64. package/{chunk-7TN6V43T.js → chunk-Z24FGIU2.js} +2 -2
  65. package/{cliEnvHelpers-VYC2OPTB.js → cliEnvHelpers-ZXNMX7VV.js} +1 -1
  66. package/{createAgentAutomationAction-VLNDOHSP.js → createAgentAutomationAction-TS6NNZ4X.js} +9 -9
  67. package/{createDialogAction-6WYTS62Z.js → createDialogAction-5HVQ33EX.js} +10 -10
  68. package/{createPageAction-YKHOC3LW.js → createPageAction-4F3ZGQJD.js} +9 -9
  69. package/{dbSlice-7Q23HSWH.js → dbSlice-OP6UPXKA.js} +2 -2
  70. package/{dialogCommands-BQDGLVMO.js → dialogCommands-3GEPXHFB.js} +16 -16
  71. package/{dialogSlice-2A2JOFZW.js → dialogSlice-FAWUQDJW.js} +9 -9
  72. package/{docCreateCommands-K2MPMXYF.js → docCreateCommands-ZE3S6BCP.js} +22 -20
  73. package/{docDeleteCommands-NBAARB77.js → docDeleteCommands-TW6PGTRT.js} +21 -19
  74. package/{docReadCommands-S3MO5RPS.js → docReadCommands-LDXL3B6J.js} +20 -18
  75. package/{docStore-JJP5PUR7.js → docStore-2UHVWLTV.js} +10 -10
  76. package/{docUpdateCommands-EHEI7FCE.js → docUpdateCommands-GYD6XI5O.js} +21 -19
  77. package/{handleSendMessageAction-UAXTF73I.js → handleSendMessageAction-LJPUYNOH.js} +15 -11
  78. package/index.js +109 -78
  79. package/{machineCommands-BQ46IS5M.js → machineCommands-OKNDYS3M.js} +36 -36
  80. package/{machineWsRunDispatch-R33NXNNI.js → machineWsRunDispatch-ZX5AJ6FJ.js} +32 -32
  81. package/{memoryCommands-AFMES3LN.js → memoryCommands-EBMICQR6.js} +1 -1
  82. package/package.json +1 -1
  83. package/{read-SIWMJRHC.js → read-HXHAZBKH.js} +1 -1
  84. package/{readDocTool-TCYJY4PP.js → readDocTool-VPBDTO4G.js} +1 -1
  85. package/{readlineWorkspace-KBG4DKLX.js → readlineWorkspace-MB3ANKHM.js} +123 -103
  86. package/{removeDialogAgentAction-WKHZT6VJ.js → removeDialogAgentAction-HUFVN35S.js} +4 -4
  87. package/{runAgentClientLoop-MUV5YIRK.js → runAgentClientLoop-A75BUU6D.js} +19 -19
  88. package/{runtimeDoctorCommands-QNF3J3UV.js → runtimeDoctorCommands-THIHX2SY.js} +1 -1
  89. package/{setDialogExtraReferencesAction-GCI5QU6E.js → setDialogExtraReferencesAction-2VLGWQKG.js} +2 -2
  90. package/{setPrimaryDialogAgentAction-NRO57AS6.js → setPrimaryDialogAgentAction-VB4UV2CC.js} +4 -4
  91. package/{settingSlice-FTWZ5ZHT.js → settingSlice-7JYPQNAC.js} +3 -3
  92. package/{spaceCommands-4R63UST3.js → spaceCommands-O3KJNCON.js} +21 -21
  93. package/{spaceSlice-VTC3QXP3.js → spaceSlice-444MFUP6.js} +11 -9
  94. package/{streamAgentChatTurn-43N7BNV2.js → streamAgentChatTurn-DJAE7USZ.js} +42 -39
  95. package/{tableCommands-E4SQWDOX.js → tableCommands-3P7MJ3PF.js} +4 -4
  96. package/{tools-PX6PEJLE.js → tools-YB6LXSVN.js} +14 -14
  97. package/{tuiSummaryLlmCaller-2D65LKWM.js → tuiSummaryLlmCaller-QQL3JA5I.js} +3 -3
  98. package/{updateCommands-XZDOOYFH.js → updateCommands-XTW55TOT.js} +2 -2
  99. package/{updateDialogTitleAction-NPQZWAKG.js → updateDialogTitleAction-6HGFBM64.js} +9 -9
  100. package/{chunk-3QAF2LTL.js → chunk-DZ3XJVET.js} +3 -3
@@ -1,27 +1,5 @@
1
1
  import {
2
- MODEL_LOOKUP_MAP
3
- } from "./chunk-OGGHETUE.js";
4
- import {
5
- ALL_MODELS
6
- } from "./chunk-IKXL2HZ3.js";
7
- import {
8
- addContentAction
9
- } from "./chunk-3FCSMQAC.js";
10
- import {
11
- upload
12
- } from "./chunk-A5V7UEZJ.js";
13
- import {
14
- getRuntimeServerContext
15
- } from "./chunk-DVRHHFEA.js";
16
- import {
17
- API_ENDPOINTS
18
- } from "./chunk-LCBAMY2M.js";
19
- import {
20
- normalizeServerOrigin
21
- } from "./chunk-CF7PE763.js";
22
- import {
23
- __commonJS,
24
- __toESM
2
+ __commonJS
25
3
  } from "./chunk-4VNS5WPM.js";
26
4
 
27
5
  // node_modules/browser-image-compression/dist/browser-image-compression.js
@@ -1721,7 +1699,7 @@ var require_browser_image_compression = __commonJS({
1721
1699
  }), o2.postMessage({ file: e2, imageCompressionLibUrl: t2.libURL, options: { ...t2, onProgress: void 0, signal: void 0 } });
1722
1700
  });
1723
1701
  }
1724
- function imageCompression2(e2, t2) {
1702
+ function imageCompression(e2, t2) {
1725
1703
  return new Promise(function(r2, i2) {
1726
1704
  let o2, a2, s2, f2, l2, c;
1727
1705
  if (o2 = { ...t2 }, s2 = 0, { onProgress: f2 } = o2, o2.maxSizeMB = o2.maxSizeMB || Number.POSITIVE_INFINITY, l2 = "boolean" != typeof o2.useWebWorker || o2.useWebWorker, delete o2.useWebWorker, o2.onProgress = (e3) => {
@@ -1778,500 +1756,8 @@ var require_browser_image_compression = __commonJS({
1778
1756
  }
1779
1757
  });
1780
1758
  }
1781
- return imageCompression2.getDataUrlFromFile = getDataUrlFromFile, imageCompression2.getFilefromDataUrl = getFilefromDataUrl, imageCompression2.loadImage = loadImage, imageCompression2.drawImageInCanvas = drawImageInCanvas, imageCompression2.drawFileInCanvas = drawFileInCanvas, imageCompression2.canvasToFile = canvasToFile, imageCompression2.getExifOrientation = getExifOrientation, imageCompression2.handleMaxWidthOrHeight = handleMaxWidthOrHeight, imageCompression2.followExifOrientation = followExifOrientation, imageCompression2.cleanupCanvasMemory = cleanupCanvasMemory, imageCompression2.isAutoOrientationInBrowser = isAutoOrientationInBrowser, imageCompression2.approximateBelowMaximumCanvasSizeOfBrowser = approximateBelowMaximumCanvasSizeOfBrowser, imageCompression2.copyExifWithoutOrientation = copyExifWithoutOrientation, imageCompression2.getBrowserName = getBrowserName, imageCompression2.version = "2.0.2", imageCompression2;
1782
- });
1783
- }
1784
- });
1785
-
1786
- // packages/ai/context/tokenUtils.ts
1787
- var estimateTokenCount = (text) => {
1788
- if (!text) return 0;
1789
- const chineseChars = (text.match(/[\u4e00-\u9fa5\u3400-\u4dbf]/g) || []).length;
1790
- const otherChars = text.length - chineseChars;
1791
- return Math.ceil(chineseChars * 1.5 + otherChars * 0.25);
1792
- };
1793
-
1794
- // packages/ai/llm/getModelContextWindow.ts
1795
- var DEFAULT_CONTEXT_WINDOW = 256e3;
1796
- var QWEN_3_6_CONTEXT_WINDOW = 262144;
1797
- var GLM_5_2_CONTEXT_WINDOW = 1e6;
1798
- var fullModelMap = null;
1799
- var getFullModelMap = () => {
1800
- if (!fullModelMap) {
1801
- fullModelMap = /* @__PURE__ */ new Map();
1802
- for (const [provider, models] of Object.entries(MODEL_LOOKUP_MAP)) {
1803
- for (const model of models) {
1804
- const entry = { ...model, provider };
1805
- fullModelMap.set(model.name, entry);
1806
- if (model.displayName) {
1807
- fullModelMap.set(model.displayName.toLowerCase(), entry);
1808
- }
1809
- }
1810
- }
1811
- }
1812
- return fullModelMap;
1813
- };
1814
- var legacyModelMap = null;
1815
- var getLegacyModelMap = () => {
1816
- if (!legacyModelMap) {
1817
- legacyModelMap = /* @__PURE__ */ new Map();
1818
- for (const model of ALL_MODELS) {
1819
- legacyModelMap.set(model.name, model);
1820
- if (model.displayName) {
1821
- legacyModelMap.set(model.displayName.toLowerCase(), model);
1822
- }
1823
- }
1824
- }
1825
- return legacyModelMap;
1826
- };
1827
- function fuzzyContextWindow(normalizedName) {
1828
- if (normalizedName.includes("qwen-long") || normalizedName.includes("qwen3-long")) return 10485760;
1829
- if (normalizedName.includes("qwen-coder") || normalizedName.includes("qwen3-coder")) return 1048576;
1830
- if (normalizedName.includes("qwen3.8") || normalizedName.includes("qwen3p8")) return 1e6;
1831
- if (normalizedName.includes("minimax-m3") || normalizedName.includes("minimax_m3")) return 1e6;
1832
- if (normalizedName.includes("glm-5.2") || normalizedName.includes("glm5.2")) return GLM_5_2_CONTEXT_WINDOW;
1833
- if (normalizedName.includes("deepseek")) return 1e6;
1834
- if (normalizedName.includes("gpt-5") || normalizedName.includes("gpt-4.1")) return 1047576;
1835
- if (normalizedName.startsWith("cursor-grok-4.5")) return 1e6;
1836
- if (normalizedName.includes("claude-4.6")) return 1e6;
1837
- if (normalizedName.includes("gemini-3.1")) return 1e6;
1838
- if (normalizedName.includes("qwen3.6") || normalizedName.includes("qwen3p6")) return QWEN_3_6_CONTEXT_WINDOW;
1839
- if (normalizedName.includes("qwen3.7") || normalizedName.includes("qwen3p7")) return 262144;
1840
- if (normalizedName.includes("minimax-m2") || normalizedName.includes("minimax_m2")) return 262144;
1841
- if (normalizedName.includes("claude")) return 2e5;
1842
- return void 0;
1843
- }
1844
- var getModelContextWindow = (modelName) => {
1845
- if (!modelName) return DEFAULT_CONTEXT_WINDOW;
1846
- const normalizedName = modelName.toLowerCase();
1847
- const map = getFullModelMap();
1848
- const model = map.get(modelName) || map.get(normalizedName);
1849
- if (model?.contextWindow) {
1850
- return typeof model.contextWindow === "number" ? model.contextWindow : DEFAULT_CONTEXT_WINDOW;
1851
- }
1852
- return fuzzyContextWindow(normalizedName) ?? DEFAULT_CONTEXT_WINDOW;
1853
- };
1854
- var getModelInfo = (modelName) => {
1855
- if (!modelName) return null;
1856
- const map = getLegacyModelMap();
1857
- return map.get(modelName) || map.get(modelName.toLowerCase()) || null;
1858
- };
1859
-
1860
- // packages/core/chat/messageContentSerialize.ts
1861
- var serializeMessageContent = (content, imagePlaceholder = "[\u56FE\u7247]") => {
1862
- if (typeof content === "string") {
1863
- return content.trim() || null;
1864
- }
1865
- if (Array.isArray(content)) {
1866
- const fragments = [];
1867
- for (const part of content) {
1868
- if (!part || typeof part !== "object") continue;
1869
- if (part.type === "text" && typeof part.text === "string") {
1870
- const text = part.text.trim();
1871
- if (text) fragments.push(text);
1872
- } else if (part.type === "image_url") {
1873
- fragments.push(imagePlaceholder);
1874
- }
1875
- }
1876
- const joined = fragments.join("\n").trim();
1877
- return joined || null;
1878
- }
1879
- return null;
1880
- };
1881
-
1882
- // packages/app/utils/imageUtils.ts
1883
- var import_browser_image_compression = __toESM(require_browser_image_compression());
1884
- var BYTES_PER_MB = 1024 * 1024;
1885
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
1886
- var parseDataUrl = (dataUrl) => {
1887
- const trimmed = dataUrl.trim();
1888
- const parts = trimmed.split(",");
1889
- if (parts.length < 2 || !parts[0] || !parts[1]) {
1890
- console.warn("[imageUtils] parseDataUrl: invalid data URL", {
1891
- hasHeader: !!parts[0],
1892
- hasBody: !!parts[1]
1759
+ return imageCompression.getDataUrlFromFile = getDataUrlFromFile, imageCompression.getFilefromDataUrl = getFilefromDataUrl, imageCompression.loadImage = loadImage, imageCompression.drawImageInCanvas = drawImageInCanvas, imageCompression.drawFileInCanvas = drawFileInCanvas, imageCompression.canvasToFile = canvasToFile, imageCompression.getExifOrientation = getExifOrientation, imageCompression.handleMaxWidthOrHeight = handleMaxWidthOrHeight, imageCompression.followExifOrientation = followExifOrientation, imageCompression.cleanupCanvasMemory = cleanupCanvasMemory, imageCompression.isAutoOrientationInBrowser = isAutoOrientationInBrowser, imageCompression.approximateBelowMaximumCanvasSizeOfBrowser = approximateBelowMaximumCanvasSizeOfBrowser, imageCompression.copyExifWithoutOrientation = copyExifWithoutOrientation, imageCompression.getBrowserName = getBrowserName, imageCompression.version = "2.0.2", imageCompression;
1893
1760
  });
1894
- return null;
1895
- }
1896
- const header = parts[0];
1897
- const base64 = parts[1];
1898
- const mimeMatch = header.match(/:(.*?);/);
1899
- const mime = mimeMatch?.[1];
1900
- if (!mime) {
1901
- console.warn("[imageUtils] parseDataUrl: cannot extract mime from", header);
1902
- return null;
1903
- }
1904
- return { mime, base64 };
1905
- };
1906
- function dataURLtoFile(dataUrl, filename) {
1907
- try {
1908
- const parsed = parseDataUrl(dataUrl);
1909
- if (!parsed) return null;
1910
- const { mime, base64 } = parsed;
1911
- const binaryString = atob(base64);
1912
- const length = binaryString.length;
1913
- const u8arr = new Uint8Array(length);
1914
- for (let i = 0; i < length; i++) {
1915
- u8arr[i] = binaryString.charCodeAt(i);
1916
- }
1917
- return new File([u8arr], filename, { type: mime });
1918
- } catch (error) {
1919
- console.error("[imageUtils] Error converting data URL to File:", error);
1920
- return null;
1921
- }
1922
- }
1923
- var appendNoCacheQuery = (url) => {
1924
- const stamp = `_t=${Date.now()}`;
1925
- return url.includes("?") ? `${url}&${stamp}` : `${url}?${stamp}`;
1926
- };
1927
- var tryLoadImage = (url) => new Promise((resolve) => {
1928
- const img = new Image();
1929
- const cleanup = () => {
1930
- img.onload = null;
1931
- img.onerror = null;
1932
- };
1933
- img.onload = () => {
1934
- cleanup();
1935
- resolve(true);
1936
- };
1937
- img.onerror = () => {
1938
- cleanup();
1939
- resolve(false);
1940
- };
1941
- img.src = url;
1942
- });
1943
- var waitForFileReady = async (url, {
1944
- maxWaitMs = 4e3,
1945
- intervalMs = 250
1946
- } = {}) => {
1947
- const start = Date.now();
1948
- while (Date.now() - start < maxWaitMs) {
1949
- const tryUrl = appendNoCacheQuery(url);
1950
- const ok = await tryLoadImage(tryUrl);
1951
- if (ok) {
1952
- console.debug("[imageUtils] waitForFileReady: image loaded for", url);
1953
- return true;
1954
- }
1955
- await sleep(intervalMs);
1956
- }
1957
- console.warn("[imageUtils] waitForFileReady: timeout for", url);
1958
- return false;
1959
- };
1960
-
1961
- // packages/database/fileUrl.ts
1962
- var normalizeFileId = (fileId) => {
1963
- if (typeof fileId !== "string") return "";
1964
- return fileId.trim();
1965
- };
1966
- var buildDatabaseFileContentUrl = (serverOrigin, fileId) => {
1967
- const normalizedServer = normalizeServerOrigin(serverOrigin);
1968
- const normalizedFileId = normalizeFileId(fileId);
1969
- if (!normalizedServer || !normalizedFileId) {
1970
- return null;
1971
- }
1972
- return `${normalizedServer}${API_ENDPOINTS.DATABASE}/file/content/${normalizedFileId}`;
1973
- };
1974
-
1975
- // packages/chat/messages/fileUrl.ts
1976
- var buildMessageFileContentUrl = (serverOrigin, fileId) => buildDatabaseFileContentUrl(serverOrigin, fileId);
1977
-
1978
- // packages/chat/messages/imagePayloadPersistence.ts
1979
- var stripDurableImageInlinePayload = (part) => {
1980
- if (!part || typeof part !== "object") return part;
1981
- const { original_data_url: _originalDataUrl, ...withoutOriginalDataUrl } = part;
1982
- if (withoutOriginalDataUrl.type !== "image_url" || !withoutOriginalDataUrl.google_native || typeof withoutOriginalDataUrl.google_native !== "object") {
1983
- return withoutOriginalDataUrl;
1984
- }
1985
- const { google_native: _googleNative, ...durablePart } = withoutOriginalDataUrl;
1986
- return durablePart;
1987
- };
1988
-
1989
- // packages/chat/messages/messageContent.ts
1990
- var isDataUrlImage = (url) => typeof url === "string" && url.startsWith("data:image");
1991
- var uploadGeneratedImageDataUrl = async (url, dialogId, messageId, index, dispatch, getState, options) => {
1992
- const fileName = `generated-image-${dialogId}-${messageId}-${index}.png`;
1993
- const file = dataURLtoFile(url, fileName);
1994
- if (!file) {
1995
- console.warn(
1996
- "[messageContent] dataURLtoFile failed, drop generated image inline payload"
1997
- );
1998
- return null;
1999
- }
2000
- const customKey = `generated-image-${dialogId}-${messageId}-${index}`;
2001
- let metadata;
2002
- try {
2003
- metadata = await dispatch(upload({ file, customKey })).unwrap();
2004
- } catch (err) {
2005
- console.warn(
2006
- "[messageContent] upload generated image failed, drop inline payload:",
2007
- err
2008
- );
2009
- return null;
2010
- }
2011
- const state = getState();
2012
- const { currentServer } = getRuntimeServerContext(state);
2013
- const fileId = metadata?.dbKey || metadata?.id;
2014
- if (!currentServer || !fileId) {
2015
- console.warn(
2016
- "[messageContent] missing currentServer or fileId, drop inline payload",
2017
- { currentServer, fileId }
2018
- );
2019
- return null;
2020
- }
2021
- if (options?.spaceId) {
2022
- try {
2023
- const agentPrefix = options.agentName ? `[${options.agentName}] ` : "";
2024
- const title = `${agentPrefix}Generated Image ${index + 1}`;
2025
- await addContentAction({
2026
- spaceId: options.spaceId,
2027
- contentKey: fileId,
2028
- title,
2029
- type: "image" /* IMAGE */
2030
- }, { dispatch, getState });
2031
- console.log(`[messageContent] Saved generated image to space: ${options.spaceId}`);
2032
- } catch (err) {
2033
- console.error("[messageContent] Failed to save generated image to space:", err);
2034
- }
2035
- }
2036
- const imageUrl = buildMessageFileContentUrl(currentServer, fileId);
2037
- if (!imageUrl) {
2038
- return null;
2039
- }
2040
- const ready = await waitForFileReady(imageUrl);
2041
- if (!ready) {
2042
- console.warn(
2043
- "[messageContent] uploaded generated image not ready, drop inline payload:",
2044
- imageUrl
2045
- );
2046
- return null;
2047
- }
2048
- return imageUrl;
2049
- };
2050
- var normalizeAssistantContentBuffer = async (contentBuffer, dialogId, messageId, dispatch, getState, options) => {
2051
- if (!Array.isArray(contentBuffer) || contentBuffer.length === 0) {
2052
- return contentBuffer;
2053
- }
2054
- const updated = await Promise.all(
2055
- contentBuffer.map(async (part, index) => {
2056
- if (!part || part.type !== "image_url" || !part.image_url || !isDataUrlImage(part.image_url.url)) {
2057
- return part;
2058
- }
2059
- const newUrl = await uploadGeneratedImageDataUrl(
2060
- part.image_url.url,
2061
- dialogId,
2062
- messageId,
2063
- index,
2064
- dispatch,
2065
- getState,
2066
- options
2067
- );
2068
- if (!newUrl) {
2069
- return {
2070
- type: "text",
2071
- text: "[\u56FE\u7247\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u751F\u6210\u56FE\u7247]"
2072
- };
2073
- }
2074
- return stripDurableImageInlinePayload({
2075
- ...part,
2076
- image_url: {
2077
- ...part.image_url,
2078
- url: newUrl
2079
- }
2080
- });
2081
- })
2082
- );
2083
- return updated;
2084
- };
2085
-
2086
- // packages/ai/context/retention.ts
2087
- var SAFE_BUFFER_RATIO = 0.95;
2088
- var CACHE_FIRST_RETENTION_STRENGTH = 0.95;
2089
- var clamp = (v, min, max) => Math.min(max, Math.max(min, v));
2090
- var planContextUsage = (params) => {
2091
- const { contextWindow, summaryTokens, recentLoad } = params;
2092
- const safeWindowLimit = Math.floor(contextWindow * SAFE_BUFFER_RATIO);
2093
- const iq = CACHE_FIRST_RETENTION_STRENGTH;
2094
- const isLargeWindow = contextWindow >= 512e3;
2095
- const isSmallWindow = contextWindow <= 64e3;
2096
- let baseHistoryRatio;
2097
- if (isLargeWindow) {
2098
- baseHistoryRatio = 0.8 + 0.2 * iq;
2099
- } else if (isSmallWindow) {
2100
- baseHistoryRatio = 0.35 + 0.3 * iq;
2101
- } else {
2102
- baseHistoryRatio = 0.55 + 0.3 * iq;
2103
- }
2104
- let historyRatio = baseHistoryRatio;
2105
- switch (recentLoad) {
2106
- case "light": {
2107
- const maxRatio = isLargeWindow ? 1 : isSmallWindow ? 0.75 : 0.85;
2108
- historyRatio = clamp(historyRatio * 1.05, 0.3, maxRatio);
2109
- break;
2110
- }
2111
- case "heavy": {
2112
- const maxRatio = isLargeWindow ? 0.98 : isSmallWindow ? 0.7 : 0.8;
2113
- const multiplier = isLargeWindow ? 0.98 : isSmallWindow ? 0.9 : 0.9;
2114
- historyRatio = clamp(historyRatio * multiplier, 0.3, maxRatio);
2115
- break;
2116
- }
2117
- case "medium":
2118
- default: {
2119
- const maxRatio = isLargeWindow ? 1 : isSmallWindow ? 0.75 : 0.85;
2120
- historyRatio = clamp(historyRatio, 0.3, maxRatio);
2121
- break;
2122
- }
2123
- }
2124
- const historyBudget = Math.max(
2125
- 0,
2126
- Math.floor(safeWindowLimit * historyRatio)
2127
- );
2128
- const minRawRatio = isSmallWindow ? 0.5 : isLargeWindow ? 0.2 : 0.3;
2129
- const rawMessageBudget = Math.max(
2130
- Math.floor(historyBudget * minRawRatio),
2131
- historyBudget - summaryTokens,
2132
- 0
2133
- );
2134
- let minTailTokens;
2135
- if (recentLoad === "light") {
2136
- minTailTokens = Math.min(
2137
- Math.floor(safeWindowLimit * 0.3),
2138
- 8e3
2139
- );
2140
- } else if (recentLoad === "heavy") {
2141
- minTailTokens = Math.max(
2142
- Math.floor(safeWindowLimit * 0.25),
2143
- 16e3
2144
- );
2145
- } else {
2146
- minTailTokens = Math.floor(safeWindowLimit * 0.2);
2147
- }
2148
- return { historyBudget, rawMessageBudget, minTailTokens };
2149
- };
2150
-
2151
- // packages/ai/context/planCompression.ts
2152
- var MIN_COMPRESS_COUNT = 5;
2153
- var ACTIVE_SUMMARY_TAIL_KEEP_COUNT = 2;
2154
- var getMessageTokenCount = (msg) => {
2155
- if (msg.usage?.completion_tokens) {
2156
- return msg.usage.completion_tokens;
2157
- }
2158
- const content = serializeMessageContent(msg.content) || "";
2159
- return estimateTokenCount(content);
2160
- };
2161
- var hasOpenEndedToolCall = (msg) => !!msg && Array.isArray(msg.tool_calls) && msg.tool_calls.length > 0;
2162
- var isActiveSummaryWorthDoing = (pendingTokens, contextWindow) => {
2163
- const minTokens = Math.min(
2164
- 4e4,
2165
- Math.max(1e4, Math.floor(contextWindow * 0.05))
2166
- );
2167
- return pendingTokens >= minTokens;
2168
- };
2169
- var classifyConversationLoad = (msgs) => {
2170
- const N = 20;
2171
- if (!Array.isArray(msgs) || msgs.length === 0) return "light";
2172
- const tail = msgs.slice(-N);
2173
- const tokenSamples = tail.map(getMessageTokenCount);
2174
- if (tokenSamples.length === 0) return "light";
2175
- const sum = tokenSamples.reduce((acc, v) => acc + v, 0);
2176
- const avg = sum / tokenSamples.length;
2177
- const sorted = [...tokenSamples].sort((a, b) => a - b);
2178
- const p95 = sorted[Math.floor((sorted.length - 1) * 0.95)];
2179
- if (p95 < 200 && avg < 120) {
2180
- return "light";
2181
1761
  }
2182
- if (p95 > 2e3 || avg > 1200) {
2183
- return "heavy";
2184
- }
2185
- return "medium";
2186
- };
2187
- var emptyPlan = (startIndex) => ({
2188
- shouldCompress: false,
2189
- compressCount: 0,
2190
- msgsToCompress: [],
2191
- msgsToKeep: [],
2192
- newSummarizedBeforeId: void 0,
2193
- startIndex
2194
1762
  });
2195
- function planCompression(input) {
2196
- const {
2197
- allMsgs,
2198
- summarizedBeforeId,
2199
- summary,
2200
- contextWindow,
2201
- force = false,
2202
- reason
2203
- } = input;
2204
- let startIndex = 0;
2205
- if (summarizedBeforeId) {
2206
- const found = allMsgs.findIndex((m) => m.id === summarizedBeforeId);
2207
- if (found !== -1) {
2208
- startIndex = found + 1;
2209
- }
2210
- }
2211
- const pendingMsgs = allMsgs.slice(startIndex);
2212
- if (pendingMsgs.length === 0) {
2213
- return emptyPlan(startIndex);
2214
- }
2215
- const summaryTokens = estimateTokenCount(summary || "");
2216
- const pendingTokens = pendingMsgs.reduce(
2217
- (sum, msg) => sum + getMessageTokenCount(msg),
2218
- 0
2219
- );
2220
- const totalUsed = summaryTokens + pendingTokens;
2221
- const adjustedSummaryTokens = Math.max(summaryTokens, 1e3);
2222
- const recentLoad = classifyConversationLoad(pendingMsgs);
2223
- const { historyBudget, rawMessageBudget } = planContextUsage({
2224
- contextWindow,
2225
- summaryTokens: adjustedSummaryTokens,
2226
- recentLoad
2227
- });
2228
- const shouldRunActiveSummary = force && reason === "manual" && !hasOpenEndedToolCall(pendingMsgs[pendingMsgs.length - 1]) && isActiveSummaryWorthDoing(pendingTokens, contextWindow);
2229
- if (totalUsed < historyBudget && !shouldRunActiveSummary) {
2230
- return emptyPlan(startIndex);
2231
- }
2232
- let tokensToKeep = 0;
2233
- let keepCount = 0;
2234
- for (let i = pendingMsgs.length - 1; i >= 0; i--) {
2235
- const t = getMessageTokenCount(pendingMsgs[i]);
2236
- if (tokensToKeep + t > rawMessageBudget) break;
2237
- tokensToKeep += t;
2238
- keepCount++;
2239
- }
2240
- let compressCount = shouldRunActiveSummary && totalUsed < historyBudget ? Math.max(0, pendingMsgs.length - ACTIVE_SUMMARY_TAIL_KEEP_COUNT) : pendingMsgs.length - keepCount;
2241
- while (compressCount > 0 && compressCount < pendingMsgs.length && pendingMsgs[compressCount].role === "tool") {
2242
- compressCount--;
2243
- }
2244
- if (compressCount > 0) {
2245
- const lastCompressed = pendingMsgs[compressCount - 1];
2246
- const hasToolCalls = Array.isArray(lastCompressed.tool_calls) && lastCompressed.tool_calls.length > 0;
2247
- if (hasToolCalls) {
2248
- compressCount--;
2249
- }
2250
- }
2251
- if (compressCount < MIN_COMPRESS_COUNT) {
2252
- return emptyPlan(startIndex);
2253
- }
2254
- const msgsToCompress = pendingMsgs.slice(0, compressCount);
2255
- const msgsToKeep = pendingMsgs.slice(compressCount);
2256
- const newSummarizedBeforeId = msgsToCompress[msgsToCompress.length - 1].id;
2257
- return {
2258
- shouldCompress: true,
2259
- compressCount,
2260
- msgsToCompress,
2261
- msgsToKeep,
2262
- newSummarizedBeforeId,
2263
- startIndex
2264
- };
2265
- }
2266
-
2267
- export {
2268
- planContextUsage,
2269
- estimateTokenCount,
2270
- DEFAULT_CONTEXT_WINDOW,
2271
- getModelContextWindow,
2272
- getModelInfo,
2273
- buildDatabaseFileContentUrl,
2274
- serializeMessageContent,
2275
- normalizeAssistantContentBuffer,
2276
- planCompression
2277
- };
1763
+ export default require_browser_image_compression();
@@ -2,7 +2,7 @@ import {
2
2
  deleteDbRecord,
3
3
  queryUserRecords,
4
4
  readDbRecord
5
- } from "./chunk-5R73BS7Y.js";
5
+ } from "./chunk-K53477EY.js";
6
6
  import {
7
7
  mergeAndDedupUserData
8
8
  } from "./chunk-KQHGZWSV.js";