nolo-cli 0.8.0-alpha.2 → 0.8.0-alpha.21

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 (188) hide show
  1. package/README.md +1 -1
  2. package/_executeModel-42U3VOVZ.js +205 -0
  3. package/action-TLI3V62L.js +28 -0
  4. package/addContentAction-57RSIIMR.js +26 -0
  5. package/addDialogAgentAction-G3VWEA6E.js +68 -0
  6. package/agentDeleteCommand-5DD2IM3J.js +327 -0
  7. package/agentEmailCommands-6FACJBU4.js +628 -0
  8. package/agentListCommands-I6KZYCIG.js +223 -0
  9. package/agentMachineCommands-VKLIGMZA.js +425 -0
  10. package/agentPullCommand-O2MTUAFR.js +122 -0
  11. package/agentRecordCommands-7TZICYDT.js +96 -0
  12. package/agentRunCommand-L4OM23KV.js +114 -0
  13. package/agentRunControl-K4VKNEHF.js +57 -0
  14. package/agentRuntimeLocal-ZYEIPTY4.js +104 -0
  15. package/agentSlice-BX7GXSNO.js +42 -0
  16. package/authCommand-EB5JSOX5.js +581 -0
  17. package/authCommands-XPEHTKSM.js +35 -0
  18. package/chunk-25LCXTML.js +175 -0
  19. package/chunk-2ECQG4YX.js +22296 -0
  20. package/chunk-2FTTDCD4.js +675 -0
  21. package/chunk-2JCXITPK.js +1078 -0
  22. package/chunk-3ASDTTEI.js +1774 -0
  23. package/chunk-3EUW3WEO.js +8 -0
  24. package/chunk-3LY4F7SV.js +9293 -0
  25. package/chunk-4CQLVGRV.js +50 -0
  26. package/chunk-4IJYA27C.js +342 -0
  27. package/chunk-4O3CARJ4.js +231 -0
  28. package/chunk-4QEWT7KD.js +933 -0
  29. package/chunk-4SN6J65J.js +38 -0
  30. package/chunk-4VNS5WPM.js +42 -0
  31. package/chunk-4XENYTF5.js +222 -0
  32. package/chunk-4ZDM73SD.js +34 -0
  33. package/chunk-5CS33IBL.js +301 -0
  34. package/chunk-5EFXE3O7.js +138 -0
  35. package/chunk-5KLGBAAR.js +386 -0
  36. package/chunk-5MIDPSSK.js +206 -0
  37. package/chunk-5MMAK75Q.js +15 -0
  38. package/chunk-63W5N6P3.js +150 -0
  39. package/chunk-6HYVJV7B.js +102 -0
  40. package/chunk-6KHNO3SK.js +1948 -0
  41. package/chunk-6WD3OOJS.js +20 -0
  42. package/chunk-7DAJ4AI4.js +191 -0
  43. package/chunk-7GNGZRLZ.js +1939 -0
  44. package/chunk-7KCUSYT2.js +354 -0
  45. package/chunk-7U44LYTR.js +238 -0
  46. package/chunk-AFON4QUU.js +112 -0
  47. package/chunk-AGFH73SK.js +239 -0
  48. package/chunk-AL2KDGR2.js +27339 -0
  49. package/chunk-AS4PVWA4.js +221 -0
  50. package/chunk-ATNTHIZI.js +13 -0
  51. package/chunk-AVMKZHBC.js +85 -0
  52. package/chunk-AZPCASRE.js +36 -0
  53. package/chunk-BBYVOSU2.js +792 -0
  54. package/chunk-C3RUNRHT.js +51 -0
  55. package/chunk-C4FTUXVF.js +146 -0
  56. package/chunk-CF2WZF4N.js +134 -0
  57. package/chunk-CF7PE763.js +10 -0
  58. package/chunk-CKOJQDKR.js +198 -0
  59. package/chunk-CMKUBIGW.js +1550 -0
  60. package/chunk-CWMSB67P.js +34 -0
  61. package/chunk-DCOA4QSN.js +105 -0
  62. package/chunk-DFFIZ25G.js +30 -0
  63. package/chunk-DSZUWUYB.js +478 -0
  64. package/chunk-DWLEOOGR.js +8 -0
  65. package/chunk-DZ3XJVET.js +231 -0
  66. package/chunk-EHLHSX7R.js +1433 -0
  67. package/chunk-ENOG22KJ.js +939 -0
  68. package/chunk-FSO5B7GH.js +171 -0
  69. package/chunk-FVYY6MCS.js +1447 -0
  70. package/chunk-G3SUCT4W.js +8 -0
  71. package/chunk-GAKEBQD6.js +30 -0
  72. package/chunk-GBRG75BQ.js +86 -0
  73. package/chunk-GU3PEVGZ.js +4723 -0
  74. package/chunk-H33743XH.js +25 -0
  75. package/chunk-HNMXYYJR.js +12 -0
  76. package/chunk-HNW7IJSK.js +71 -0
  77. package/chunk-I42VC5KR.js +15 -0
  78. package/chunk-I6XMPTMR.js +113 -0
  79. package/chunk-IDZTNRP2.js +85 -0
  80. package/chunk-ISNCLGUZ.js +146 -0
  81. package/chunk-IWX4UW2E.js +548 -0
  82. package/chunk-JBTJAPUF.js +35 -0
  83. package/chunk-JEXVIMYZ.js +55 -0
  84. package/chunk-JRKKFRAV.js +537 -0
  85. package/chunk-JZPBVBIY.js +94 -0
  86. package/chunk-KKY4B2Q2.js +21 -0
  87. package/chunk-KQHGZWSV.js +63 -0
  88. package/chunk-KUG52IAP.js +8 -0
  89. package/chunk-KX6YBIHG.js +8 -0
  90. package/chunk-LCBAMY2M.js +60 -0
  91. package/chunk-LM6IYQ3F.js +16 -0
  92. package/chunk-LTRXGFMS.js +83 -0
  93. package/chunk-M76ECQRD.js +13658 -0
  94. package/chunk-MRC4Q34M.js +188 -0
  95. package/chunk-MTU75CZ2.js +91 -0
  96. package/chunk-N54XAP77.js +19 -0
  97. package/chunk-O2ZNTTET.js +3272 -0
  98. package/chunk-O4BU24WZ.js +3212 -0
  99. package/chunk-OLZBQWZU.js +6 -0
  100. package/chunk-OOSFSFMA.js +271 -0
  101. package/chunk-OPZYGHUC.js +89 -0
  102. package/chunk-OWOHNGCN.js +50 -0
  103. package/chunk-P3PKED2I.js +962 -0
  104. package/chunk-QSJ3HFEF.js +8 -0
  105. package/chunk-RCSJFQPB.js +9036 -0
  106. package/chunk-RL776AGR.js +190 -0
  107. package/chunk-ROWQEJRP.js +139 -0
  108. package/chunk-S7Z2HMCN.js +25 -0
  109. package/chunk-SDJDLO5W.js +628 -0
  110. package/chunk-SOTZ6RDN.js +69 -0
  111. package/chunk-TILFE6LV.js +381 -0
  112. package/chunk-U4TRT5V4.js +246 -0
  113. package/chunk-U6VC4MU4.js +8 -0
  114. package/chunk-UAD2WT54.js +64 -0
  115. package/chunk-UB6SN4NJ.js +421 -0
  116. package/chunk-URUUZLPA.js +807 -0
  117. package/chunk-UTLZINAP.js +3066 -0
  118. package/chunk-VC6OZXO5.js +298 -0
  119. package/chunk-VF4K2QE6.js +21 -0
  120. package/chunk-VHBWHNVT.js +59 -0
  121. package/chunk-VIDPVFP3.js +20 -0
  122. package/chunk-VP4WJWKW.js +8882 -0
  123. package/chunk-VUW5FBDB.js +573 -0
  124. package/chunk-VVX233PH.js +482 -0
  125. package/chunk-VX3SXJ3N.js +2052 -0
  126. package/chunk-W4NVOSFF.js +37 -0
  127. package/chunk-WWC7I6TA.js +8 -0
  128. package/chunk-WZSRQNQG.js +2587 -0
  129. package/chunk-XBUBEFNX.js +34 -0
  130. package/chunk-XENYHRUE.js +104 -0
  131. package/chunk-Y5GCAMGP.js +9 -0
  132. package/chunk-YPRZSPF3.js +148 -0
  133. package/chunk-Z4NR32XR.js +50 -0
  134. package/chunk-ZNFJWEN4.js +56 -0
  135. package/cliExecutor-K3F7DMRO.js +36 -0
  136. package/clipboardy-BVE3LVEH.js +12001 -0
  137. package/createAgentAutomationAction-RJF3N2QY.js +866 -0
  138. package/createDialogAction-DRSPS6CE.js +55 -0
  139. package/createPageAction-6B2WMNO3.js +172 -0
  140. package/db-HCJ5PRB5.js +271 -0
  141. package/dbSlice-Q3TM2FJV.js +60 -0
  142. package/deleteFile-OW53A6BX.js +41 -0
  143. package/dialogCommands-4IX4XIZE.js +63 -0
  144. package/dialogSlice-3M7KX2TX.js +148 -0
  145. package/docCreateCommands-SIL3NPGT.js +220 -0
  146. package/docDeleteCommands-7IOMLUS4.js +181 -0
  147. package/docReadCommands-FNFXUA5L.js +134 -0
  148. package/docStore-SV7E34D4.js +98 -0
  149. package/docUpdateCommands-X2HNDVUC.js +318 -0
  150. package/fetchMessages-KTNM7QAR.js +17 -0
  151. package/getPricing-3E6UNPKL.js +30 -0
  152. package/handleSendMessageAction-JYETO5RZ.js +185 -0
  153. package/index.js +188 -112958
  154. package/lib-FYYBQIXS.js +19839 -0
  155. package/localDialogRead-2VRI24F4.js +26 -0
  156. package/localFirstLog-DHNOY2NA.js +19 -0
  157. package/localRuntimeAuthority-TEGCOWX4.js +471 -0
  158. package/localRuntimeDb-LGDF6FQP.js +12 -0
  159. package/machineCommands-RIO3RP5Q.js +781 -0
  160. package/machineInfo-M6KB6HZN.js +10 -0
  161. package/machineWsRunDispatch-W7UYLGB5.js +112 -0
  162. package/memoryCommands-O4MIPIWQ.js +476 -0
  163. package/models-4OPOOLFS.js +9 -0
  164. package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
  165. package/package.json +4 -24
  166. package/read-GW7ZEI23.js +17 -0
  167. package/readDocTool-HUFU6OCT.js +16 -0
  168. package/readlineWorkspace-27JR7WPW.js +5682 -0
  169. package/removeDialogAgentAction-CXKR4NJI.js +73 -0
  170. package/runAgentClientLoop-HZFAPJHS.js +293 -0
  171. package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
  172. package/setDialogExtraReferencesAction-6RKUSXHX.js +60 -0
  173. package/setPrimaryDialogAgentAction-T3UTBEFG.js +80 -0
  174. package/settingSlice-IVKXJXMG.js +199 -0
  175. package/skillDiscovery-UGSQGX2U.js +16 -0
  176. package/skillSummaryMarker-42HKSXYY.js +9 -0
  177. package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
  178. package/slateUtils-2M7MUTWX.js +19 -0
  179. package/spaceCommands-E7VOF4LO.js +450 -0
  180. package/spaceSlice-TSVROA5U.js +149 -0
  181. package/streamAgentChatTurn-3C5RQZJF.js +4510 -0
  182. package/tableCommands-O7O2LBEG.js +1286 -0
  183. package/toolApiClient-QI3YBNWB.js +26 -0
  184. package/tools-EQDEKR6N.js +87 -0
  185. package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
  186. package/understanding-3CUQQ6SV.js +271 -0
  187. package/updateCommands-VOSPKXFF.js +31 -0
  188. package/updateDialogTitleAction-3XV7VWSZ.js +188 -0
@@ -0,0 +1,206 @@
1
+ import {
2
+ extractCustomId
3
+ } from "./chunk-DFFIZ25G.js";
4
+ import {
5
+ getActiveDialogKey
6
+ } from "./chunk-3ASDTTEI.js";
7
+ import {
8
+ compactWhitespace
9
+ } from "./chunk-DWLEOOGR.js";
10
+ import {
11
+ asTrimmedLowercaseString
12
+ } from "./chunk-QSJ3HFEF.js";
13
+ import {
14
+ isRecord
15
+ } from "./chunk-KUG52IAP.js";
16
+
17
+ // packages/ai/tools/toolApiClient.ts
18
+ var MAIN_SERVER = "https://nolo.chat";
19
+ var getIsDesktopApp = () => typeof window !== "undefined" && Boolean(window.__NOLO_DESKTOP__);
20
+ var isLocalServerUrl = (value) => {
21
+ if (!value) return false;
22
+ try {
23
+ const hostname = new URL(value).hostname.toLowerCase();
24
+ return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1";
25
+ } catch {
26
+ return false;
27
+ }
28
+ };
29
+ var resolveDesktopSafeServer = (value) => {
30
+ if (!getIsDesktopApp()) return value || MAIN_SERVER;
31
+ return isLocalServerUrl(value) ? MAIN_SERVER : value || MAIN_SERVER;
32
+ };
33
+ var selectCurrentServerFromState = (state) => resolveDesktopSafeServer(state?.settings?.currentServer);
34
+ var selectCurrentTokenFromState = (state) => typeof state?.auth?.currentToken === "string" ? state.auth.currentToken : null;
35
+ var selectCurrentDialogKeyFromState = (_state) => getActiveDialogKey();
36
+ var resolveToolBaseUrl = (currentServer) => {
37
+ const _window = globalThis.window;
38
+ if (!_window) return (currentServer || "").replace(/\/+$/, "");
39
+ const fallbackLocal = _window.location.origin;
40
+ if (!currentServer) return fallbackLocal;
41
+ return currentServer.replace(/\/+$/, "");
42
+ };
43
+ var DESKTOP_LOCAL_TOOL_PATHS = /* @__PURE__ */ new Set([
44
+ "/api/exec-shell",
45
+ "/api/check-env",
46
+ "/api/read-file",
47
+ "/api/write-file",
48
+ "/api/apply-edit",
49
+ "/api/apply-line-edits",
50
+ "/api/code-search",
51
+ "/api/search-repo",
52
+ "/api/desktop/files/roots",
53
+ "/api/desktop/files/roots/request",
54
+ "/api/desktop/files/list",
55
+ "/api/desktop/files/read",
56
+ "/api/desktop/files/plan",
57
+ "/api/desktop/files/approve",
58
+ "/api/desktop/files/execute",
59
+ "/api/desktop/files/undo",
60
+ "/api/desktop/files/history"
61
+ ]);
62
+ var getWindowOrigin = () => {
63
+ const _window = globalThis.window;
64
+ const origin = _window?.location?.origin;
65
+ return typeof origin === "string" && origin ? origin.replace(/\/+$/, "") : null;
66
+ };
67
+ var resolveToolApiBaseUrl = (currentServer, path) => {
68
+ if (path && DESKTOP_LOCAL_TOOL_PATHS.has(path) && getIsDesktopApp()) {
69
+ const localOrigin = getWindowOrigin();
70
+ if (localOrigin) return localOrigin;
71
+ }
72
+ return resolveToolBaseUrl(currentServer);
73
+ };
74
+ var getRequestConfig = (thunkApi) => {
75
+ const state = thunkApi.getState();
76
+ const currentServer = selectCurrentServerFromState(state);
77
+ const token = selectCurrentTokenFromState(state);
78
+ if (!currentServer) throw new Error("\u65E0\u6CD5\u83B7\u53D6\u5F53\u524D\u670D\u52A1\u5668\u5730\u5740\u3002");
79
+ return { currentServer, token };
80
+ };
81
+ var getToolBaseUrl = (thunkApi) => {
82
+ const { currentServer } = getRequestConfig(thunkApi);
83
+ const baseUrl = resolveToolBaseUrl(currentServer);
84
+ if (!baseUrl) throw new Error("\u65E0\u6CD5\u83B7\u53D6\u5DE5\u5177\u670D\u52A1\u5668\u5730\u5740\u3002");
85
+ return baseUrl;
86
+ };
87
+ var getToolRequestContext = (thunkApi) => {
88
+ const { currentServer, token } = getRequestConfig(thunkApi);
89
+ const baseUrl = resolveToolBaseUrl(currentServer);
90
+ if (!baseUrl) throw new Error("\u65E0\u6CD5\u83B7\u53D6\u5DE5\u5177\u670D\u52A1\u5668\u5730\u5740\u3002");
91
+ return {
92
+ currentServer,
93
+ token,
94
+ baseUrl
95
+ };
96
+ };
97
+ var maybeAttachDialogId = (thunkApi, body) => {
98
+ if (!isRecord(body)) return body;
99
+ if ("dialogId" in body) return body;
100
+ const state = thunkApi.getState();
101
+ const currentDialogKey = selectCurrentDialogKeyFromState(state);
102
+ const dialogId = currentDialogKey ? extractCustomId(currentDialogKey) : null;
103
+ if (!dialogId) return body;
104
+ return {
105
+ ...body,
106
+ dialogId
107
+ };
108
+ };
109
+ var ToolApiError = class extends Error {
110
+ status;
111
+ code;
112
+ details;
113
+ constructor(message, options) {
114
+ super(message);
115
+ this.name = "ToolApiError";
116
+ this.status = options?.status;
117
+ this.code = options?.code;
118
+ this.details = options?.details;
119
+ }
120
+ };
121
+ var buildToolRequestHeaders = (thunkApi, options = {}) => {
122
+ const { withAuth = false, agentKey } = options;
123
+ const { token } = getRequestConfig(thunkApi);
124
+ const headers = { "Content-Type": "application/json" };
125
+ if (withAuth && token) {
126
+ headers["Authorization"] = `Bearer ${token}`;
127
+ }
128
+ if (agentKey && typeof agentKey === "string" && agentKey.trim()) {
129
+ headers["X-Nolo-Agent-Key"] = agentKey.trim();
130
+ }
131
+ if (typeof window !== "undefined" && window.__NOLO_DESKTOP__) {
132
+ headers["X-Nolo-Desktop-Tool"] = "1";
133
+ }
134
+ return headers;
135
+ };
136
+ var buildResponsePreview = (text) => compactWhitespace(text).slice(0, 240);
137
+ var looksLikeHtmlResponse = (text, contentType) => {
138
+ if (contentType?.toLowerCase().includes("text/html")) return true;
139
+ const trimmed = asTrimmedLowercaseString(text);
140
+ return trimmed.startsWith("<!doctype html") || trimmed.startsWith("<html");
141
+ };
142
+ async function callToolApi(thunkApi, path, body, options = {}) {
143
+ const { currentServer } = getRequestConfig(thunkApi);
144
+ const baseUrl = resolveToolApiBaseUrl(currentServer, path);
145
+ if (!baseUrl) throw new Error("\u65E0\u6CD5\u83B7\u53D6\u5DE5\u5177\u670D\u52A1\u5668\u5730\u5740\u3002");
146
+ const url = `${baseUrl}${path}`;
147
+ const headers = buildToolRequestHeaders(thunkApi, options);
148
+ const response = await fetch(url, {
149
+ method: "POST",
150
+ headers,
151
+ body: JSON.stringify(maybeAttachDialogId(thunkApi, body))
152
+ });
153
+ const contentType = response.headers.get("content-type");
154
+ const responseText = await response.text();
155
+ if (!response.ok) {
156
+ let errorMessage = `API \u8BF7\u6C42\u5931\u8D25\uFF0C\u72B6\u6001\u7801: ${response.status}`;
157
+ let errorCode;
158
+ let errorDetails;
159
+ try {
160
+ const errorData = JSON.parse(responseText);
161
+ const err = errorData?.error;
162
+ if (err) {
163
+ errorMessage += `: ${err.message ?? JSON.stringify(err)}`;
164
+ errorCode = typeof err.code === "string" ? err.code : void 0;
165
+ errorDetails = err.details;
166
+ }
167
+ } catch {
168
+ errorCode = looksLikeHtmlResponse(responseText, contentType) ? "HTML_ERROR_RESPONSE" : "NON_JSON_ERROR_RESPONSE";
169
+ errorDetails = {
170
+ contentType,
171
+ responsePreview: buildResponsePreview(responseText)
172
+ };
173
+ if (typeof errorDetails.responsePreview === "string" && errorDetails.responsePreview) {
174
+ errorMessage += `: ${errorDetails.responsePreview}`;
175
+ }
176
+ }
177
+ throw new ToolApiError(errorMessage, {
178
+ status: response.status,
179
+ code: errorCode,
180
+ details: errorDetails
181
+ });
182
+ }
183
+ try {
184
+ return JSON.parse(responseText);
185
+ } catch {
186
+ throw new ToolApiError("\u670D\u52A1\u7AEF\u8FD4\u56DE\u4E86\u65E0\u6CD5\u89E3\u6790\u7684\u975E JSON \u54CD\u5E94", {
187
+ status: response.status,
188
+ code: looksLikeHtmlResponse(responseText, contentType) ? "HTML_RESPONSE" : "INVALID_JSON_RESPONSE",
189
+ details: {
190
+ contentType,
191
+ responsePreview: buildResponsePreview(responseText)
192
+ }
193
+ });
194
+ }
195
+ }
196
+
197
+ export {
198
+ resolveToolBaseUrl,
199
+ resolveToolApiBaseUrl,
200
+ getRequestConfig,
201
+ getToolBaseUrl,
202
+ getToolRequestContext,
203
+ ToolApiError,
204
+ buildToolRequestHeaders,
205
+ callToolApi
206
+ };
@@ -0,0 +1,15 @@
1
+ import {
2
+ compactWhitespace
3
+ } from "./chunk-DWLEOOGR.js";
4
+
5
+ // packages/core/clipCompactText.ts
6
+ function clipCompactText(value, max, ellipsis = "...") {
7
+ const compact = compactWhitespace(value);
8
+ if (compact.length <= max) return compact;
9
+ if (max <= ellipsis.length) return compact.slice(0, max);
10
+ return `${compact.slice(0, max - ellipsis.length)}${ellipsis}`;
11
+ }
12
+
13
+ export {
14
+ clipCompactText
15
+ };
@@ -0,0 +1,150 @@
1
+ // packages/create/editor/transforms/slateToRenderMarkdown.ts
2
+ function renderTextNode(node) {
3
+ if (!node || typeof node.text !== "string") return "";
4
+ let text = node.text;
5
+ if (!text) return "";
6
+ if (node.bold) text = `**${text}**`;
7
+ if (node.italic) text = `*${text}*`;
8
+ if (node.strikethrough) text = `~~${text}~~`;
9
+ return text;
10
+ }
11
+ function renderPlainText(node, options = {}) {
12
+ if (!node) return "";
13
+ if (typeof node.text === "string") return renderTextNode(node);
14
+ if (!Array.isArray(node.children)) return "";
15
+ return node.children.map((child) => renderPlainText(child, options)).join("");
16
+ }
17
+ function renderTable(node, options) {
18
+ const rows = Array.isArray(node.children) ? node.children : [];
19
+ if (rows.length === 0) return "";
20
+ const alignments = Array.isArray(node.columns) ? node.columns.map((column) => column?.align || "left") : [];
21
+ const renderedRows = rows.map(
22
+ (row) => (Array.isArray(row?.children) ? row.children : []).map((cell) => {
23
+ const content = renderPlainText(cell, options).replace(/\n+/g, " ").trim();
24
+ return content || " ";
25
+ })
26
+ );
27
+ const header = renderedRows[0] || [];
28
+ const divider = header.map((_, index) => {
29
+ const align = alignments[index];
30
+ if (align === "center") return ":---:";
31
+ if (align === "right") return "---:";
32
+ return "---";
33
+ });
34
+ const body = renderedRows.slice(1);
35
+ return [header, divider, ...body].map((cells) => `| ${cells.join(" | ")} |`).join("\n") + "\n\n";
36
+ }
37
+ function renderListItem(node, listDepth, ordered, start, index, options = {}) {
38
+ const indentation = " ".repeat(listDepth);
39
+ const marker = node.checked === true ? "- [x]" : node.checked === false ? "- [ ]" : ordered ? `${start + index}.` : "-";
40
+ const segments = Array.isArray(node.children) ? node.children : [];
41
+ const renderedSegments = segments.flatMap((child) => {
42
+ const rendered = renderNode(child, listDepth + 1, options).trimEnd();
43
+ return rendered ? [rendered] : [];
44
+ });
45
+ if (renderedSegments.length === 0) {
46
+ return `${indentation}${marker}
47
+ `;
48
+ }
49
+ const [first, ...rest] = renderedSegments;
50
+ const lines = first.split("\n");
51
+ const firstLine = lines.shift() || "";
52
+ const restFirst = lines.map((line) => `${indentation} ${line}`).join("\n");
53
+ const restBlocks = rest.map((block) => `${indentation} ${block}`).join("\n");
54
+ return [
55
+ `${indentation}${marker} ${firstLine}`,
56
+ restFirst,
57
+ restBlocks
58
+ ].filter(Boolean).join("\n") + "\n";
59
+ }
60
+ function renderNode(node, listDepth = 0, options = {}) {
61
+ if (!node) return "";
62
+ switch (node.type) {
63
+ case "heading-one":
64
+ return `# ${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
65
+
66
+ `;
67
+ case "heading-two":
68
+ return `## ${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
69
+
70
+ `;
71
+ case "heading-three":
72
+ return `### ${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
73
+
74
+ `;
75
+ case "heading-four":
76
+ return `#### ${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
77
+
78
+ `;
79
+ case "heading-five":
80
+ return `##### ${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
81
+
82
+ `;
83
+ case "heading-six":
84
+ return `###### ${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
85
+
86
+ `;
87
+ case "paragraph":
88
+ return `${node.children.map((n) => renderNode(n, listDepth, options)).join("")}
89
+
90
+ `;
91
+ case "list":
92
+ return node.children.map(
93
+ (item, index) => renderListItem(item, listDepth, !!node.ordered, node.start || 1, index, options)
94
+ ).join("");
95
+ case "list-item":
96
+ return renderListItem(node, listDepth, false, 1, 0, options);
97
+ case "quote": {
98
+ const content = node.children.map((n) => renderNode(n, listDepth, options)).join("").trim();
99
+ return `> ${content.replace(/\n/g, "\n> ")}
100
+
101
+ `;
102
+ }
103
+ case "code-block": {
104
+ const code = node.children.map(
105
+ (line) => (line.children || []).map((text) => text.text).join("")
106
+ ).join("\n");
107
+ return "```" + (node.language || "") + "\n" + code + "\n```\n\n";
108
+ }
109
+ case "link": {
110
+ const linkText = node.children.map((n) => renderNode(n, listDepth, options)).join("");
111
+ return `[${linkText}](${node.url})`;
112
+ }
113
+ case "table":
114
+ return renderTable(node, options);
115
+ case "code-inline":
116
+ return `\`${node.children.map((n) => renderNode(n, listDepth, options)).join("")}\``;
117
+ case "mention": {
118
+ if (options.mentionResolver) {
119
+ return options.mentionResolver(node);
120
+ }
121
+ const label = node.label || node.resourceId || "mention";
122
+ const resourceType = node.resourceType || "unknown";
123
+ const resourceId = node.resourceId || "unknown";
124
+ return `@[${resourceType}:${resourceId}|${label}]`;
125
+ }
126
+ case "image": {
127
+ const alt = node.alt || "";
128
+ const title = node.title ? ` "${node.title}"` : "";
129
+ return `![${alt}](${node.url || ""}${title})`;
130
+ }
131
+ case "html-inline":
132
+ return typeof node.html === "string" ? node.html : "";
133
+ case "html-block":
134
+ return typeof node.html === "string" ? `${node.html}
135
+
136
+ ` : "";
137
+ case "thematic-break":
138
+ return "---\n\n";
139
+ default:
140
+ return renderTextNode(node) || (node.children ? node.children.map((child) => renderNode(child, listDepth, options)).join("") : "");
141
+ }
142
+ }
143
+ function slateToRenderMarkdown(nodes, options = {}) {
144
+ if (!nodes || nodes.length === 0) return "";
145
+ return nodes.map((node) => renderNode(node, 0, options)).join("").trim() + "\n";
146
+ }
147
+
148
+ export {
149
+ slateToRenderMarkdown
150
+ };
@@ -0,0 +1,102 @@
1
+ import {
2
+ resolveLaunchableCodexCommand
3
+ } from "./chunk-JBTJAPUF.js";
4
+
5
+ // packages/connector-experimental/machineInfo.ts
6
+ import { existsSync as existsSync2, readFileSync, writeFileSync, mkdirSync } from "node:fs";
7
+ import { dirname, join as join2 } from "node:path";
8
+ import { arch, hostname, homedir, platform } from "node:os";
9
+ import { randomUUID } from "node:crypto";
10
+
11
+ // packages/connector-experimental/capabilities.ts
12
+ import { spawnSync } from "node:child_process";
13
+ import { existsSync } from "node:fs";
14
+ import { join } from "node:path";
15
+ var COMMAND_CAPABILITIES = [
16
+ [[{ command: "codex", args: ["--version"] }], ["codex-cli"]],
17
+ [[{ command: "claude", args: ["--version"] }], ["claude-code"]],
18
+ [
19
+ [
20
+ { command: "gh", args: ["--version"] },
21
+ { command: "gh", args: ["copilot", "--", "--help"] }
22
+ ],
23
+ ["copilot-cli"]
24
+ ],
25
+ [[{ command: "gemini", args: ["--version"] }], ["gemini-cli"]],
26
+ [[{ command: "kimi", args: ["--version"] }], ["kimi-cli"]],
27
+ [[{ command: "agy", args: ["--help"] }], ["agy-cli"]],
28
+ [[{ command: "qoder", args: ["--version"] }], ["qoder-cli"]],
29
+ [[{ command: "opencode", args: ["--version"] }], ["opencode-cli"]],
30
+ [[{ command: "grok", args: ["--version"] }], ["grok-cli"]]
31
+ ];
32
+ function defaultCommandExists(command) {
33
+ const pathEntries = (process.env.PATH ?? "").split(process.platform === "win32" ? ";" : ":");
34
+ const extensions = process.platform === "win32" ? [".exe", ".cmd", ".bat", ""] : [""];
35
+ return pathEntries.some(
36
+ (entry) => extensions.some((extension) => existsSync(join(entry, `${command}${extension}`)))
37
+ );
38
+ }
39
+ function defaultCommandLaunchable(command, args) {
40
+ const executable = command === "codex" ? resolveLaunchableCodexCommand() : command;
41
+ const result = spawnSync(executable, args, {
42
+ stdio: "pipe",
43
+ timeout: 3e3,
44
+ windowsHide: true
45
+ });
46
+ return !result.error && result.status === 0;
47
+ }
48
+ function detectRuntimeCapabilities(options = {}) {
49
+ const commandExists = options.commandExists ?? defaultCommandExists;
50
+ const commandLaunchable = options.commandLaunchable ?? defaultCommandLaunchable;
51
+ const env = options.env ?? process.env;
52
+ const capabilities = [];
53
+ for (const [probes, detectedCapabilities] of COMMAND_CAPABILITIES) {
54
+ if (!probes.every((probe) => commandExists(probe.command))) continue;
55
+ if (options.probeLaunchable && !probes.every((probe) => commandLaunchable(probe.command, probe.args))) {
56
+ continue;
57
+ }
58
+ capabilities.push(...detectedCapabilities);
59
+ }
60
+ if (env.NOLO_LOCAL_LLM_ENDPOINT || env.LLAMA_SERVER_URL) {
61
+ capabilities.push("local-llm");
62
+ }
63
+ return capabilities;
64
+ }
65
+
66
+ // packages/connector-experimental/machineInfo.ts
67
+ var CONNECTOR_VERSION = "0.1.0-experimental";
68
+ function defaultMachineIdPath() {
69
+ return join2(homedir(), ".nolo", "machine-id");
70
+ }
71
+ function resolveMachineId(path = defaultMachineIdPath()) {
72
+ try {
73
+ if (existsSync2(path)) {
74
+ const existing = readFileSync(path, "utf8").trim();
75
+ if (existing) return existing;
76
+ }
77
+ const next = `machine-${randomUUID()}`;
78
+ mkdirSync(dirname(path), { recursive: true });
79
+ writeFileSync(path, `${next}
80
+ `, "utf8");
81
+ return next;
82
+ } catch {
83
+ return `machine-${hostname().toLowerCase()}`;
84
+ }
85
+ }
86
+ function detectMachineInfo(overrides) {
87
+ return {
88
+ machineId: overrides?.machineId ?? resolveMachineId(),
89
+ name: overrides?.name ?? hostname(),
90
+ platform: platform(),
91
+ arch: arch(),
92
+ connectorVersion: CONNECTOR_VERSION,
93
+ capabilities: overrides?.capabilities ?? detectRuntimeCapabilities({
94
+ probeLaunchable: overrides?.probeLaunchable
95
+ })
96
+ };
97
+ }
98
+
99
+ export {
100
+ resolveMachineId,
101
+ detectMachineInfo
102
+ };