nolo-cli 0.29.2 → 0.30.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 (138) hide show
  1. package/{_executeModel-BFVTGZXE.js → _executeModel-5ARVVUIK.js} +64 -69
  2. package/{action-LG32A6DJ.js → action-HI3VRQLP.js} +15 -16
  3. package/{addContentAction-MPGMBJTQ.js → addContentAction-NCURJ6PK.js} +13 -13
  4. package/{addDialogAgentAction-ZH23WDID.js → addDialogAgentAction-RCY4ECF4.js} +12 -12
  5. package/{agentDeleteCommand-4S4STG42.js → agentDeleteCommand-5Q6TDCJU.js} +62 -40
  6. package/{agentEmailCommands-3F4IP4DI.js → agentEmailCommands-DSX4BJ2I.js} +77 -81
  7. package/{agentGrantCommands-JNDE4RWR.js → agentGrantCommands-E7ZZFRHK.js} +2 -1
  8. package/{agentListCommands-JCRV2XF6.js → agentListCommands-S66HL5RO.js} +59 -41
  9. package/{agentMachineCommands-KYXPYSFP.js → agentMachineCommands-ULCQ5ZNN.js} +55 -36
  10. package/{agentPullCommand-ZZGU5KOY.js → agentPullCommand-4V36XNGV.js} +4 -3
  11. package/{agentRecordCommands-UADUPIXO.js → agentRecordCommands-2AA3GEGO.js} +75 -79
  12. package/{agentRunCommand-MJWSR53W.js → agentRunCommand-3KOT77XY.js} +79 -83
  13. package/{agentRunControl-SNUKXN6J.js → agentRunControl-AKBN2366.js} +13 -1
  14. package/{agentRuntimeLocal-PC5RRRPT.js → agentRuntimeLocal-7TMDJD4S.js} +50 -31
  15. package/{agentSlice-C5OYLNBT.js → agentSlice-6IQRQZX3.js} +13 -14
  16. package/{appDeleteCommands-ZXODZ5AD.js → appDeleteCommands-UUDIWLNE.js} +55 -36
  17. package/{appDeployCommands-AWC6JPZH.js → appDeployCommands-CO6SZ7YP.js} +55 -36
  18. package/{appDeployStatusCommands-74NXMDAI.js → appDeployStatusCommands-QEVKVECJ.js} +55 -36
  19. package/{appGetCommands-6YGIAP5L.js → appGetCommands-3YSCCLK4.js} +55 -36
  20. package/{appListCommands-DZWBHMNK.js → appListCommands-FBJAFZKK.js} +55 -36
  21. package/{authCommand-XMQHBK5L.js → authCommand-3ADNCFKD.js} +16 -16
  22. package/{authCommands-JSOG2H4E.js → authCommands-CXJ6PI2O.js} +7 -7
  23. package/{chunk-TOGGHWHI.js → chunk-2CYGIPJH.js} +3 -3
  24. package/{chunk-HRJEPMZY.js → chunk-2HQ4OG6N.js} +2 -2
  25. package/{chunk-XMLRJUU5.js → chunk-2IJAKBK2.js} +12 -10
  26. package/{chunk-OLWMGSW2.js → chunk-2SOQY5L6.js} +41 -39
  27. package/{chunk-7H3UTGPM.js → chunk-3AUWC6EM.js} +82 -3
  28. package/{chunk-6HTWA77J.js → chunk-43EPBPZ2.js} +1 -1
  29. package/{chunk-RJBTU7AS.js → chunk-4F77PJBR.js} +302 -14
  30. package/{chunk-RZNYL4LW.js → chunk-4SAV7BD7.js} +65 -1
  31. package/{chunk-R5V5G73M.js → chunk-5RDLGLAP.js} +0 -1
  32. package/{chunk-VKBTAQWT.js → chunk-6JH2DF7J.js} +6 -6
  33. package/{chunk-DZ3XJVET.js → chunk-AOS5IN2I.js} +1 -1
  34. package/{chunk-5ZXNLOAG.js → chunk-ARPAHODF.js} +17 -10
  35. package/{chunk-IC7W63RM.js → chunk-ATK5WJOA.js} +4 -4
  36. package/{chunk-OEWEE4VW.js → chunk-BIPRFBC2.js} +4 -2
  37. package/{chunk-YTA2QOEE.js → chunk-CAENRKNJ.js} +15 -0
  38. package/chunk-CYRMUTGB.js +1707 -0
  39. package/chunk-DCDL3GC4.js +171 -0
  40. package/{chunk-WX3ZOSTL.js → chunk-EBNSAABL.js} +24 -26
  41. package/{chunk-2TYLTEAH.js → chunk-EDWM6D6L.js} +1 -1
  42. package/{chunk-GT3GG2H7.js → chunk-EIQDGAAE.js} +148 -2
  43. package/chunk-F3MP7CP6.js +73 -0
  44. package/{chunk-R7LOFGRE.js → chunk-G5GVZAXF.js} +19 -15
  45. package/{chunk-KEF5OBOZ.js → chunk-GKXS4F2I.js} +33 -27
  46. package/{chunk-R3JSTDQO.js → chunk-GVPMJPCT.js} +1 -1
  47. package/{chunk-WMB7GVPN.js → chunk-IPSPETAL.js} +152 -1177
  48. package/{chunk-MQRZ5QUH.js → chunk-IXZX5CJK.js} +1 -1
  49. package/{chunk-2FX23RGA.js → chunk-J3LHGBNO.js} +5 -5
  50. package/{chunk-VHBWHNVT.js → chunk-K6QEHQZ3.js} +8 -4
  51. package/{chunk-HRPWRVBI.js → chunk-KGEVMUMI.js} +11 -11
  52. package/{chunk-L65QKSVJ.js → chunk-L3GCUVOH.js} +1 -1
  53. package/{chunk-G2BZ43DV.js → chunk-LAXMH7JY.js} +14 -14
  54. package/chunk-LEVCXTDN.js +5558 -0
  55. package/{chunk-HEXXIS77.js → chunk-N2IX3ZYK.js} +1 -1
  56. package/{chunk-32ZM6HVI.js → chunk-NZBH7FTB.js} +95 -95
  57. package/{chunk-XOIF2TNF.js → chunk-OB6FBSH3.js} +13 -0
  58. package/{chunk-PSK2RUHV.js → chunk-OIW2RJ74.js} +360 -2
  59. package/{chunk-FRN5QOKN.js → chunk-PACNSC37.js} +19 -4
  60. package/{chunk-QC6ZWDSV.js → chunk-PIC6Z7VI.js} +3 -3
  61. package/{chunk-H5S4XUGI.js → chunk-Q243PXRU.js} +185 -158
  62. package/{chunk-BBGRJB5E.js → chunk-QBOW6RZN.js} +4 -4
  63. package/{chunk-FVOSIYXM.js → chunk-R5Y4XELF.js} +43 -394
  64. package/{chunk-DF7SMWEV.js → chunk-RWJPDKPB.js} +1 -1
  65. package/{chunk-NXMJ55RU.js → chunk-S2BMRBR2.js} +3 -3
  66. package/{chunk-GC34RRTQ.js → chunk-SWYMCHM7.js} +1 -69
  67. package/chunk-T27IEBNQ.js +149 -0
  68. package/{chunk-GMJS5AYP.js → chunk-T4X4GCYT.js} +19 -179
  69. package/{chunk-4BDPDTJU.js → chunk-TXVSNFHC.js} +8 -8
  70. package/{chunk-JSB4N6NU.js → chunk-V54H24CQ.js} +3 -3
  71. package/chunk-VQ4QPCKE.js +3226 -0
  72. package/{chunk-Q5RXHXKU.js → chunk-W3UDJJMA.js} +189 -122
  73. package/{chunk-L3QFIBZG.js → chunk-WTGCTVJG.js} +1 -1
  74. package/{chunk-XS7UPVR7.js → chunk-WTPC3XD4.js} +5 -5
  75. package/{chunk-WSQLK2KR.js → chunk-XFGM5PJP.js} +6 -6
  76. package/{chunk-HALKDXKP.js → chunk-XORE26Z4.js} +8 -4
  77. package/chunk-YLC42PIE.js +7889 -0
  78. package/{chunk-SKDNBYZK.js → chunk-ZJ2WITOO.js} +2 -2
  79. package/{chunk-L6RBX4L4.js → chunk-ZJH3LKEW.js} +21 -9
  80. package/{codingSkills-EN6Z6G6U.js → codingSkills-V35TRR4Y.js} +1 -2
  81. package/{createAgentAutomationAction-BK4UZJKU.js → createAgentAutomationAction-EYNYY2LB.js} +31 -37
  82. package/{createDialogAction-MJJUI2MK.js → createDialogAction-OUIRWYZP.js} +34 -39
  83. package/{createPageAction-YMZ7K363.js → createPageAction-2I5PHJFF.js} +45 -51
  84. package/{dbSlice-6QJYQUBV.js → dbSlice-BBL3PEVW.js} +12 -12
  85. package/{deleteFile-WDZ3VM7B.js → deleteFile-RJTEPOT4.js} +6 -6
  86. package/{dialogCommands-OKH45ASS.js → dialogCommands-5CL4QYQ7.js} +55 -38
  87. package/{dialogSlice-UDOKNDHB.js → dialogSlice-EKKVFKBJ.js} +28 -35
  88. package/{docCreateCommands-MCLMR4TE.js → docCreateCommands-QHCLYGNW.js} +54 -37
  89. package/{docDeleteCommands-ONDHI7JV.js → docDeleteCommands-DS6KOU6N.js} +56 -39
  90. package/{docReadCommands-FCXBMISW.js → docReadCommands-FRI5DAKH.js} +54 -37
  91. package/{docStore-N66O4CGH.js → docStore-V7EJS4PX.js} +30 -36
  92. package/{docUpdateCommands-T3XN6XOX.js → docUpdateCommands-RQO5ZTXT.js} +57 -40
  93. package/{fetchMessages-W4IKHPCS.js → fetchMessages-VPPQDDZ4.js} +3 -3
  94. package/{getPricing-X6I23RN6.js → getPricing-67TQVKFV.js} +6 -7
  95. package/{handleSendMessageAction-KC4AYUZP.js → handleSendMessageAction-KCF7KII4.js} +30 -37
  96. package/index.js +72 -72
  97. package/{localDialogRead-UFLBS6OT.js → localDialogRead-P72W2U2R.js} +1 -1
  98. package/{machineCommands-DIMRFA3Y.js → machineCommands-IAGAKTHV.js} +78 -82
  99. package/{machineWsRunDispatch-2DYJZI6Z.js → machineWsRunDispatch-JGKC2HEK.js} +73 -77
  100. package/{models-YT32CTT5.js → models-WDUTTYFS.js} +2 -2
  101. package/{offlineMarxistsAgentCommand-5OOWZLJI.js → offlineMarxistsAgentCommand-E6LUG63A.js} +6 -2
  102. package/package.json +1 -1
  103. package/{read-C7Y6LSBM.js → read-64OQDO3I.js} +7 -7
  104. package/{readDocTool-TOHRYJHP.js → readDocTool-MXM3T6PE.js} +2 -1
  105. package/{readlineWorkspace-HUPHMLDG.js → readlineWorkspace-5AQHHIBK.js} +209 -183
  106. package/{removeDialogAgentAction-WZXPOH5S.js → removeDialogAgentAction-NEKVAMSH.js} +16 -17
  107. package/{runAgentClientLoop-5TGSUKHV.js → runAgentClientLoop-6OGPS6SI.js} +63 -67
  108. package/{setDialogExtraReferencesAction-INZY2ENI.js → setDialogExtraReferencesAction-WTOHQDIV.js} +13 -13
  109. package/{setPrimaryDialogAgentAction-WCVLPYCF.js → setPrimaryDialogAgentAction-LDJOYC4F.js} +16 -17
  110. package/{settingSlice-IDUM4LWU.js → settingSlice-4M37TN7V.js} +14 -15
  111. package/{skillDiscovery-ITA7BI7A.js → skillDiscovery-I3QRA7NE.js} +2 -2
  112. package/{spaceCommands-XSSDB3YK.js → spaceCommands-VTDNKTSF.js} +240 -41
  113. package/{spaceSlice-BXDCO6PT.js → spaceSlice-LGUZMB7Y.js} +29 -35
  114. package/{streamAgentChatTurn-HRFMVSVC.js → streamAgentChatTurn-TIGCZUNZ.js} +133 -1301
  115. package/{switchDialogAgentAction-YBFFCBOD.js → switchDialogAgentAction-XVWGKR2Z.js} +12 -12
  116. package/{tableCommands-QSZILI7I.js → tableCommands-RJZ3V4TF.js} +7 -7
  117. package/{toolApiClient-WVTUYOFM.js → toolApiClient-ARGFDJAG.js} +2 -2
  118. package/{tools-5V6FHWQU.js → tools-BQAOPYMR.js} +51 -56
  119. package/{tuiSummaryLlmCaller-GCUPULOV.js → tuiSummaryLlmCaller-YQBN5IMG.js} +12 -12
  120. package/{updateDialogTitleAction-W62C4W4K.js → updateDialogTitleAction-E6HMEDPH.js} +39 -45
  121. package/chunk-5CS33IBL.js +0 -301
  122. package/chunk-5MMAK75Q.js +0 -15
  123. package/chunk-HYSJHRWD.js +0 -669
  124. package/chunk-MRC4Q34M.js +0 -188
  125. package/chunk-SIZQB7BD.js +0 -91
  126. package/chunk-UEOPA6MV.js +0 -641
  127. package/chunk-UFL6WHHJ.js +0 -15419
  128. package/chunk-VIDPVFP3.js +0 -20
  129. package/chunk-W2LZV5GE.js +0 -231
  130. package/chunk-Y5GCAMGP.js +0 -9
  131. package/chunk-YYLHWIW6.js +0 -48
  132. package/chunk-Z54ZAZZC.js +0 -1791
  133. package/chunk-ZZ2MH7LE.js +0 -84
  134. package/{chunk-OMP5L5NF.js → chunk-44HACRCK.js} +3 -3
  135. package/{chunk-ZVZMT3EA.js → chunk-KWCLUYGQ.js} +3 -3
  136. package/{chunk-NRY4GCKJ.js → chunk-WHLVPK32.js} +3 -3
  137. package/{chunk-RQSOAMPJ.js → chunk-Z5MXSEOJ.js} +2 -2
  138. package/{runtimeDoctorCommands-HSU632DY.js → runtimeDoctorCommands-E2OUORHK.js} +3 -3
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  requireTokenUser
3
- } from "./chunk-BBGRJB5E.js";
3
+ } from "./chunk-QBOW6RZN.js";
4
4
  import {
5
5
  resolveServerUrl
6
6
  } from "./chunk-A7GB5UGH.js";
@@ -1,107 +1,19 @@
1
1
  import {
2
2
  i18n_default,
3
3
  toolRegistry
4
- } from "./chunk-WMB7GVPN.js";
5
- import {
6
- canonicalizeToolNames
7
- } from "./chunk-ZZ2MH7LE.js";
4
+ } from "./chunk-IPSPETAL.js";
8
5
  import {
9
6
  isNoloHostedProvider
10
- } from "./chunk-YTA2QOEE.js";
7
+ } from "./chunk-CAENRKNJ.js";
11
8
  import {
12
9
  asTrimmedLowercaseString
13
10
  } from "./chunk-QSJ3HFEF.js";
14
11
  import {
15
12
  isRecord
16
13
  } from "./chunk-KUG52IAP.js";
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
- };
14
+ import {
15
+ canonicalizeToolNames
16
+ } from "./chunk-3AUWC6EM.js";
105
17
 
106
18
  // packages/ai/tools/toolSchemaCompatibility.ts
107
19
  var COMPOSITION_KEYS = ["anyOf", "oneOf", "allOf"];
@@ -266,8 +178,96 @@ var prepareTools = (toolNames, options) => {
266
178
  return prepared.slice();
267
179
  };
268
180
 
181
+ // packages/ai/chat/inlineImageUrlsForCustomProvider.ts
182
+ var FILE_CONTENT_PATH = "/api/v1/db/file/content/";
183
+ var shouldInlineImageUrlsForAgent = (agentConfig) => {
184
+ const apiSource = agentConfig?.apiSource?.toLowerCase();
185
+ const provider = agentConfig?.provider?.toLowerCase();
186
+ const model = agentConfig?.model?.toLowerCase();
187
+ if (apiSource === "custom" || provider === "custom") return true;
188
+ if (isNoloHostedProvider(provider)) return true;
189
+ return provider === "openrouter" && model === "minimax/minimax-m3";
190
+ };
191
+ var isInlineCandidate = (url) => /^https?:\/\//i.test(url) && url.includes(FILE_CONTENT_PATH);
192
+ var bytesToBase64 = (bytes) => {
193
+ let binary = "";
194
+ for (const byte of bytes) {
195
+ binary += String.fromCharCode(byte);
196
+ }
197
+ return btoa(binary);
198
+ };
199
+ var defaultFetchImage = async (url) => {
200
+ const response = await fetch(url);
201
+ if (!response.ok) {
202
+ return {
203
+ ok: false,
204
+ error: `HTTP ${response.status}`
205
+ };
206
+ }
207
+ const bytes = new Uint8Array(await response.arrayBuffer());
208
+ return {
209
+ ok: true,
210
+ mimeType: response.headers.get("content-type") ?? "application/octet-stream",
211
+ bytes
212
+ };
213
+ };
214
+ var cloneImagePartWithDataUrl = async (part, fetchImage, isAllowedImageUrl) => {
215
+ const url = part?.image_url?.url;
216
+ if (typeof url !== "string" || !isInlineCandidate(url) || isAllowedImageUrl && !isAllowedImageUrl(url)) {
217
+ return part;
218
+ }
219
+ const result = await fetchImage(url);
220
+ if (!result.ok || !result.bytes) return part;
221
+ const mimeType = result.mimeType || "application/octet-stream";
222
+ return {
223
+ ...part,
224
+ image_url: {
225
+ ...part.image_url,
226
+ url: `data:${mimeType};base64,${bytesToBase64(result.bytes)}`
227
+ }
228
+ };
229
+ };
230
+ var inlineImageUrlsForCustomProvider = async (bodyData, options) => {
231
+ if (!options.shouldInline) return bodyData;
232
+ const body = bodyData;
233
+ if (!Array.isArray(body?.messages)) return bodyData;
234
+ const fetchImage = options.fetchImage ?? defaultFetchImage;
235
+ let changed = false;
236
+ const messages = [];
237
+ for (const message of body.messages) {
238
+ if (!Array.isArray(message?.content)) {
239
+ messages.push(message);
240
+ continue;
241
+ }
242
+ const content = await Promise.all(
243
+ message.content.map(async (part) => {
244
+ if (part?.type !== "image_url") return part;
245
+ return cloneImagePartWithDataUrl(
246
+ part,
247
+ fetchImage,
248
+ options.isAllowedImageUrl
249
+ );
250
+ })
251
+ );
252
+ let messageChanged = false;
253
+ for (let i = 0; i < content.length; i++) {
254
+ if (content[i] !== message.content[i]) {
255
+ changed = true;
256
+ messageChanged = true;
257
+ break;
258
+ }
259
+ }
260
+ messages.push(messageChanged ? { ...message, content } : message);
261
+ }
262
+ if (!changed) return bodyData;
263
+ return {
264
+ ...body,
265
+ messages
266
+ };
267
+ };
268
+
269
269
  export {
270
+ prepareTools,
270
271
  shouldInlineImageUrlsForAgent,
271
- inlineImageUrlsForCustomProvider,
272
- prepareTools
272
+ inlineImageUrlsForCustomProvider
273
273
  };
@@ -1,3 +1,7 @@
1
+ import {
2
+ compactWhitespace
3
+ } from "./chunk-DWLEOOGR.js";
4
+
1
5
  // packages/chat/dialog/actions/builtinDialogLlm.ts
2
6
  var BASE_BUILTIN_DIALOG_LLM_CONFIG = {
3
7
  apiSource: "platform",
@@ -27,7 +31,16 @@ ${previousSummary || "(\u65E0)"}
27
31
  ${messagesText}
28
32
  `.trim();
29
33
 
34
+ // packages/core/clipCompactText.ts
35
+ function clipCompactText(value, max, ellipsis = "...") {
36
+ const compact = compactWhitespace(value);
37
+ if (compact.length <= max) return compact;
38
+ if (max <= ellipsis.length) return compact.slice(0, max);
39
+ return `${compact.slice(0, max - ellipsis.length)}${ellipsis}`;
40
+ }
41
+
30
42
  export {
43
+ clipCompactText,
31
44
  BUILTIN_TITLE_LLM_CONFIG,
32
45
  BUILTIN_SUMMARY_LLM_CONFIG,
33
46
  buildBuiltinSummaryContent
@@ -2,14 +2,43 @@ import {
2
2
  isImageUrlPart
3
3
  } from "./chunk-D34RI6NI.js";
4
4
  import {
5
- canonicalizeToolNames
6
- } from "./chunk-ZZ2MH7LE.js";
5
+ wrapHistoricalSummaryWithReplayGuard
6
+ } from "./chunk-4PWB7JRR.js";
7
+ import {
8
+ clipMultilineText,
9
+ fetchAndSerializeTable
10
+ } from "./chunk-CYRMUTGB.js";
11
+ import {
12
+ slateToSimplifiedMarkdown
13
+ } from "./chunk-SWYMCHM7.js";
14
+ import {
15
+ estimateTokenCount,
16
+ fetchAndCacheMessages
17
+ } from "./chunk-LEVCXTDN.js";
18
+ import {
19
+ createSpaceKey
20
+ } from "./chunk-V54H24CQ.js";
21
+ import {
22
+ read
23
+ } from "./chunk-LAXMH7JY.js";
7
24
  import {
8
25
  asTrimmedLowercaseString
9
26
  } from "./chunk-QSJ3HFEF.js";
27
+ import {
28
+ extractCustomId
29
+ } from "./chunk-TOW4E763.js";
30
+ import {
31
+ getRuntimeServerContext
32
+ } from "./chunk-2IJAKBK2.js";
33
+ import {
34
+ extractCategorizedMentions
35
+ } from "./chunk-VP4WJWKW.js";
10
36
  import {
11
37
  asTrimmedString
12
38
  } from "./chunk-3EUW3WEO.js";
39
+ import {
40
+ canonicalizeToolNames
41
+ } from "./chunk-3AUWC6EM.js";
13
42
 
14
43
  // packages/agent-runtime/identityBlock.ts
15
44
  var buildIdentityBlock = (input) => {
@@ -23,6 +52,334 @@ var buildIdentityBlock = (input) => {
23
52
  return lines.join("\n");
24
53
  };
25
54
 
55
+ // packages/create/editor/transforms/slateToText.ts
56
+ function getNodeText(node) {
57
+ if (node.text) {
58
+ return node.text;
59
+ }
60
+ if (node.children && Array.isArray(node.children)) {
61
+ return node.children.map(getNodeText).join("\n");
62
+ }
63
+ return "";
64
+ }
65
+ function slateToText(nodes) {
66
+ if (!nodes || nodes.length === 0) {
67
+ return "";
68
+ }
69
+ return nodes.map(getNodeText).join("\n\n");
70
+ }
71
+
72
+ // packages/ai/context/buildReferenceContext.ts
73
+ var MAX_META_TEXT_LENGTH = 80;
74
+ var DIALOG_REFERENCE_MESSAGE_LIMIT = 20;
75
+ var DIALOG_REFERENCE_SNIPPET_CHARS = 1200;
76
+ var DIALOG_HANDOFF_SNIPPET_CHARS = 360;
77
+ var truncateMetaText = (value, max = MAX_META_TEXT_LENGTH) => {
78
+ if (!value) return "";
79
+ if (value.length <= max) return value;
80
+ return `${value.slice(0, max - 3)}...`;
81
+ };
82
+ var readSafe = async (dispatch, dbKey) => {
83
+ try {
84
+ return await dispatch(read({
85
+ dbKey
86
+ })).unwrap();
87
+ } catch {
88
+ return null;
89
+ }
90
+ };
91
+ var buildMentionMetaMap = async (slateData, dispatch) => {
92
+ const metaMap = /* @__PURE__ */ new Map();
93
+ const mentions = extractCategorizedMentions(slateData);
94
+ if (!mentions) return metaMap;
95
+ const pageEntries = await Promise.all(
96
+ (mentions.pages || []).map(async (pageId) => {
97
+ const pageData = await readSafe(dispatch, pageId);
98
+ if (!pageData) {
99
+ return [`page:${pageId}`, { displayType: "page", metaParts: [] }];
100
+ }
101
+ if (pageData.type === "dialog" /* DIALOG */) {
102
+ const agentCount = Array.isArray(pageData.cybots) ? pageData.cybots.length : 0;
103
+ return [
104
+ `page:${pageId}`,
105
+ {
106
+ displayType: "dialog",
107
+ title: pageData.title,
108
+ metaParts: [
109
+ `agents=${agentCount}`,
110
+ `updated=${pageData.updatedAt || pageData.updated_at || pageData.updated || "Unknown"}`
111
+ ]
112
+ }
113
+ ];
114
+ }
115
+ const tags = pageData.tags && pageData.tags.length > 0 ? pageData.tags.slice(0, 5).join(", ") : "";
116
+ return [
117
+ `page:${pageId}`,
118
+ {
119
+ displayType: "page",
120
+ title: pageData.title,
121
+ metaParts: [
122
+ pageData.spaceId ? `space=${pageData.spaceId}` : "",
123
+ tags ? `tags=${tags}` : "",
124
+ `updated=${pageData.updatedAt || pageData.updated_at || pageData.updated || "Unknown"}`
125
+ ].filter(Boolean)
126
+ }
127
+ ];
128
+ })
129
+ );
130
+ pageEntries.forEach((entry) => metaMap.set(entry[0], entry[1]));
131
+ const agentEntries = await Promise.all(
132
+ (mentions.agents || []).map(async (agentId) => {
133
+ const agentData = await readSafe(dispatch, agentId);
134
+ if (!agentData) {
135
+ return [`agent:${agentId}`, { displayType: "agent", metaParts: [] }];
136
+ }
137
+ const desc = truncateMetaText(
138
+ agentData.description || agentData.introduction || ""
139
+ );
140
+ return [
141
+ `agent:${agentId}`,
142
+ {
143
+ displayType: "agent",
144
+ title: agentData.name,
145
+ metaParts: [
146
+ `public=${agentData.isPublic ? "yes" : "no"}`,
147
+ desc ? `desc=${desc}` : ""
148
+ ].filter(Boolean)
149
+ }
150
+ ];
151
+ })
152
+ );
153
+ agentEntries.forEach((entry) => metaMap.set(entry[0], entry[1]));
154
+ const spaceEntries = await Promise.all(
155
+ (mentions.spaces || []).map(async (spaceId) => {
156
+ const spaceKey = createSpaceKey.space(spaceId);
157
+ const spaceData = await readSafe(dispatch, spaceKey);
158
+ if (!spaceData) {
159
+ return [`space:${spaceId}`, { displayType: "space", metaParts: [] }];
160
+ }
161
+ const desc = truncateMetaText(spaceData.description || "");
162
+ const categoriesCount = Object.keys(spaceData.categories || {}).length;
163
+ const contentsCount = Object.keys(spaceData.contents || {}).length;
164
+ return [
165
+ `space:${spaceId}`,
166
+ {
167
+ displayType: "space",
168
+ title: spaceData.name,
169
+ metaParts: [
170
+ desc ? `desc=${desc}` : "",
171
+ `categories=${categoriesCount}`,
172
+ `contents=${contentsCount}`
173
+ ].filter(Boolean)
174
+ }
175
+ ];
176
+ })
177
+ );
178
+ spaceEntries.forEach((entry) => metaMap.set(entry[0], entry[1]));
179
+ return metaMap;
180
+ };
181
+ var buildInlineMention = (node, metaMap) => {
182
+ const resourceType = node.resourceType || "unknown";
183
+ const resourceId = node.resourceId || "unknown";
184
+ const key = `${resourceType}:${resourceId}`;
185
+ const meta = metaMap.get(key);
186
+ const label = meta?.title || node.label || resourceId || "mention";
187
+ const displayType = meta?.displayType || resourceType;
188
+ const metaParts = meta?.metaParts ?? [];
189
+ const idPart = resourceType === "tool" ? `tool=${resourceId}` : `dbkey=${resourceId}`;
190
+ const metaSuffix = metaParts.length ? ` | ${metaParts.join(" | ")}` : "";
191
+ return `@${label}(${displayType} | ${idPart}${metaSuffix})`;
192
+ };
193
+ var clipReferenceText = (value, max) => {
194
+ const raw = typeof value === "string" ? value : value == null ? "" : JSON.stringify(value);
195
+ return clipMultilineText(raw, max);
196
+ };
197
+ var fetchDialogReference = async (dbKey, refContent, dispatch) => {
198
+ const dialogConfig = refContent;
199
+ const dialogTitle = dialogConfig.title || `Untitled Dialog (${dbKey})`;
200
+ const dialogId = extractCustomId(dbKey) || dbKey.replace(/^dialog-/, "");
201
+ const checkpoint = dialogConfig.runtimeCheckpoint || null;
202
+ const summary = asTrimmedString(dialogConfig.summary);
203
+ const messages = await dispatch(
204
+ async (_dispatch, getState, { db }) => {
205
+ const state = getState();
206
+ const { currentToken: token, remoteServers } = getRuntimeServerContext(state);
207
+ return await fetchAndCacheMessages({
208
+ db,
209
+ dialogId,
210
+ limit: DIALOG_REFERENCE_MESSAGE_LIMIT,
211
+ token,
212
+ remoteServers: remoteServers.length > 0 ? remoteServers : void 0
213
+ });
214
+ }
215
+ );
216
+ const sortedMessages = [...messages].reverse();
217
+ const formatContent = (content) => clipReferenceText(content, DIALOG_REFERENCE_SNIPPET_CHARS);
218
+ const transcript = sortedMessages.map((msg, index) => {
219
+ const toolLine = msg.toolName ? ` tool=${msg.toolName}` : "";
220
+ const agentLine = msg.cybotKey ? ` agent=${msg.cybotKey}` : "";
221
+ const createdLine = msg.createdAt ? ` at=${msg.createdAt}` : "";
222
+ return [
223
+ `### Message ${index + 1}: ${msg.role || "unknown"} id=${msg.id || "unknown"}${toolLine}${agentLine}${createdLine}`,
224
+ formatContent(msg.content) || "[empty]"
225
+ ].join("\n");
226
+ }).join("\n\n");
227
+ const checkpointLines = [];
228
+ if (checkpoint && typeof checkpoint === "object") {
229
+ if (checkpoint.status) checkpointLines.push(`- status: ${checkpoint.status}`);
230
+ if (checkpoint.lastUserInput) checkpointLines.push(`- lastUserInput: ${formatContent(checkpoint.lastUserInput)}`);
231
+ if (checkpoint.lastAssistantText) checkpointLines.push(`- lastAssistantText: ${formatContent(checkpoint.lastAssistantText)}`);
232
+ if (Array.isArray(checkpoint.lastToolNames) && checkpoint.lastToolNames.length) {
233
+ checkpointLines.push(`- lastToolNames: ${checkpoint.lastToolNames.join(", ")}`);
234
+ }
235
+ if (Array.isArray(checkpoint.availableToolNames) && checkpoint.availableToolNames.length) {
236
+ checkpointLines.push(`- availableToolNames: ${checkpoint.availableToolNames.join(", ")}`);
237
+ }
238
+ }
239
+ const recentToolEvidence = sortedMessages.filter((msg) => msg.role === "tool" || msg.toolName).slice(-3).map((msg) => {
240
+ const label = msg.toolName ? `${msg.toolName}` : "tool";
241
+ return `- ${label} id=${msg.id || "unknown"}: ${clipReferenceText(msg.content, DIALOG_HANDOFF_SNIPPET_CHARS) || "[empty]"}`;
242
+ });
243
+ const handoffLines = [
244
+ `- Use this when continuing work, transferring to another Agent, comparing with the current task, or preparing a document/plan from the prior discussion.`,
245
+ `- Current state source: ${checkpointLines.length ? "Runtime Checkpoint" : "summaries and recent transcript"}.`,
246
+ summary ? `- Compressed background: passive summary is available below; treat it as lossy, not original wording.` : "",
247
+ recentToolEvidence.length ? `- Recent tool evidence:
248
+ ${recentToolEvidence.join("\n")}` : `- Recent tool evidence: none loaded in the latest ${DIALOG_REFERENCE_MESSAGE_LIMIT} messages.`,
249
+ `- For exact claims, old decisions, original wording, files/tools mentioned earlier, or anything not visible in the recent transcript, call searchDialogMessages with DB Key ${dbKey}.`
250
+ ].filter(Boolean);
251
+ const referenceBody = [
252
+ `Conversation Reference:`,
253
+ `DB Key: ${dbKey}`,
254
+ `Title: ${dialogTitle}`,
255
+ `Status: ${dialogConfig.status || "unknown"}`,
256
+ `Loaded Recent Messages: ${sortedMessages.length}`,
257
+ `Conversation Handoff:
258
+ ${handoffLines.join("\n")}`,
259
+ checkpointLines.length ? `Runtime Checkpoint:
260
+ ${checkpointLines.join("\n")}` : "",
261
+ summary ? `Passive Summary (compressed history, not original wording):
262
+ ${wrapHistoricalSummaryWithReplayGuard(summary)}` : "",
263
+ `Recent Transcript (original message excerpts, oldest to newest):
264
+ ${transcript || "[no recent messages loaded]"}`,
265
+ [
266
+ `Coverage Note: This reference intentionally loads only the latest ${DIALOG_REFERENCE_MESSAGE_LIMIT} messages plus summaries/checkpoint to control token load.`,
267
+ `Original Message Lookup Policy: If the user asks for an exact old message, original wording, who said what, why a decision was made, early-history detail, file/tool evidence, failed attempts, or a comparison with prior work, use searchDialogMessages({ dialogKey: "${dbKey}", query: "..." }) before making a factual claim from this referenced conversation.`
268
+ ].join("\n")
269
+ ].filter(Boolean).join("\n\n");
270
+ const tokenEstimate = estimateTokenCount(referenceBody);
271
+ return `${referenceBody}
272
+
273
+ Token Load Estimate: ${tokenEstimate} tokens for this conversation reference.
274
+ ---
275
+
276
+ `;
277
+ };
278
+ var fetchTableReference = async (dbKey, refContent, dispatch) => {
279
+ const tableMeta = refContent;
280
+ const title = tableMeta.displayName || tableMeta.description || `Untitled Table (${dbKey})`;
281
+ const { markdown: tableMd } = await dispatch(
282
+ async (_dispatch, getState, { db }) => {
283
+ const state = getState();
284
+ const { currentToken: token, remoteServers } = getRuntimeServerContext(state);
285
+ return await fetchAndSerializeTable(tableMeta, db, {
286
+ token,
287
+ remoteServers
288
+ });
289
+ }
290
+ );
291
+ const tags = tableMeta.tags?.length ? tableMeta.tags.join(", ") : "None";
292
+ const description = tableMeta.description || "No description provided.";
293
+ return `Reference Item (Table):
294
+ DB Key: ${dbKey}
295
+ Title: ${title}
296
+ Description: ${description}
297
+ Tags: ${tags}
298
+ Content (Markdown Table):
299
+
300
+ ${tableMd}
301
+ ---
302
+
303
+ `;
304
+ };
305
+ var fetchSlateReference = async (dbKey, refContent, dispatch, options) => {
306
+ if (!refContent?.slateData) return null;
307
+ const title = refContent.title || `Untitled (${dbKey})`;
308
+ let contentString;
309
+ let contentType;
310
+ const inlineMentionMeta = options.inlineMentionMeta ?? options.format === "simplified_markdown";
311
+ switch (options.format) {
312
+ case "text":
313
+ contentType = "Plain Text";
314
+ contentString = slateToText(refContent.slateData);
315
+ break;
316
+ case "simplified_markdown":
317
+ contentType = "Simplified Markdown";
318
+ if (inlineMentionMeta) {
319
+ const metaMap = await buildMentionMetaMap(refContent.slateData, dispatch);
320
+ contentString = slateToSimplifiedMarkdown(refContent.slateData, {
321
+ mentionResolver: (node) => buildInlineMention(node, metaMap)
322
+ });
323
+ } else {
324
+ contentString = slateToSimplifiedMarkdown(refContent.slateData);
325
+ }
326
+ break;
327
+ case "json":
328
+ default:
329
+ contentType = "Slate JSON";
330
+ contentString = JSON.stringify(refContent.slateData, null, 2);
331
+ break;
332
+ }
333
+ if (!contentString || typeof contentString === "string" && !contentString.trim() || contentString === "[]") {
334
+ return null;
335
+ }
336
+ const tags = (refContent.tags || []).length > 0 ? refContent.tags.join(", ") : "None";
337
+ const createdAt = refContent.created || "Unknown Creation Date";
338
+ const updatedAt = refContent.updated || "Unknown Update Date";
339
+ return `Reference Item:
340
+ DB Key: ${dbKey}
341
+ Title: ${title}
342
+ Content (${contentType}):
343
+ ${contentString}
344
+ Tags: ${tags}
345
+ Created At: ${createdAt}
346
+ Updated At: ${updatedAt}
347
+ ---
348
+
349
+ `;
350
+ };
351
+ var fetchReferenceContents = async (references, dispatch, options = { format: "simplified_markdown" }) => {
352
+ const result = /* @__PURE__ */ new Map();
353
+ if (!references || references.length === 0) return result;
354
+ const referencePromises = references.map(async (dbKey) => {
355
+ try {
356
+ const hasPreloaded = options.preloaded?.has(dbKey);
357
+ const refContent = hasPreloaded ? options.preloaded?.get(dbKey) : await dispatch(read({
358
+ dbKey
359
+ })).unwrap();
360
+ if (!refContent) return null;
361
+ let formatted = null;
362
+ if (refContent.type === "dialog" /* DIALOG */) {
363
+ formatted = await fetchDialogReference(dbKey, refContent, dispatch);
364
+ } else if (refContent.type === "table" /* TABLE */) {
365
+ formatted = await fetchTableReference(dbKey, refContent, dispatch);
366
+ } else {
367
+ formatted = await fetchSlateReference(dbKey, refContent, dispatch, options);
368
+ }
369
+ if (formatted) return [dbKey, formatted];
370
+ return null;
371
+ } catch (error) {
372
+ console.error(`Error fetching reference ${dbKey}:`, error);
373
+ return null;
374
+ }
375
+ });
376
+ const resolved = await Promise.all(referencePromises);
377
+ resolved.forEach((item) => {
378
+ if (item) result.set(item[0], item[1]);
379
+ });
380
+ return result;
381
+ };
382
+
26
383
  // packages/agent-runtime/contextLayerContract.ts
27
384
  var buildContextLayerContractBlock = (options = {}) => {
28
385
  const lines = [
@@ -521,6 +878,7 @@ function toBareImageUrlMessages(messages) {
521
878
 
522
879
  export {
523
880
  buildIdentityBlock,
881
+ fetchReferenceContents,
524
882
  buildRuntimeGuidanceBlocks,
525
883
  resolveToolGuidedSections,
526
884
  buildCurrentTimeBlock,
@@ -1,12 +1,9 @@
1
- import {
2
- getPublicImageAgentDefaultProfile
3
- } from "./chunk-VIDPVFP3.js";
4
1
  import {
5
2
  getApproxPricePerImage
6
3
  } from "./chunk-CWMSB67P.js";
7
4
  import {
8
5
  getModelConfig
9
- } from "./chunk-GT3GG2H7.js";
6
+ } from "./chunk-EIQDGAAE.js";
10
7
  import {
11
8
  asOptionalFiniteNumber
12
9
  } from "./chunk-WWC7I6TA.js";
@@ -14,6 +11,22 @@ import {
14
11
  asOptionalPositiveFiniteNumber
15
12
  } from "./chunk-U6VC4MU4.js";
16
13
 
14
+ // packages/ai/agent/utils/publicImageAgentMode.ts
15
+ var getPublicImageAgentMode = (agent) => {
16
+ if (!agent) return null;
17
+ if (agent.imageWorkflow) return agent.imageWorkflow;
18
+ return null;
19
+ };
20
+ var getPublicImageAgentDefaultProfile = (mode) => {
21
+ if (mode === "generate") {
22
+ return { quality: "medium", size: "1024x1024", outputFormat: "png" };
23
+ }
24
+ if (mode === "edit") {
25
+ return { quality: "medium", size: "auto", outputFormat: "png" };
26
+ }
27
+ return { quality: "low", size: "auto", outputFormat: "png" };
28
+ };
29
+
17
30
  // packages/ai/llm/getPricing.ts
18
31
  var MAX_OUTPUT_TOKENS = 8192;
19
32
  var getModelPricing = (provider, modelName, _requestedServiceTier) => {
@@ -136,6 +149,8 @@ var formatCompactTurnPrice = (amount) => {
136
149
  };
137
150
 
138
151
  export {
152
+ getPublicImageAgentMode,
153
+ getPublicImageAgentDefaultProfile,
139
154
  getModelPricing,
140
155
  getModelPricingForModel,
141
156
  hasExplicitAgentPricing,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  buildLocalAgentLookupKeys,
3
3
  shouldReadAgentKeyRemotely
4
- } from "./chunk-R3JSTDQO.js";
4
+ } from "./chunk-GVPMJPCT.js";
5
5
  import {
6
6
  resolveCliAgentKeyInput
7
- } from "./chunk-VHBWHNVT.js";
7
+ } from "./chunk-K6QEHQZ3.js";
8
8
  import {
9
9
  toErrorMessage
10
10
  } from "./chunk-HNMXYYJR.js";
@@ -21,7 +21,7 @@ import {
21
21
  } from "./chunk-A7GB5UGH.js";
22
22
  import {
23
23
  createAgentKey
24
- } from "./chunk-NRY4GCKJ.js";
24
+ } from "./chunk-WHLVPK32.js";
25
25
 
26
26
  // packages/cli/agentRecordHelpers.ts
27
27
  import { readFileSync } from "node:fs";