nolo-cli 0.8.0 → 0.9.1

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 (183) hide show
  1. package/_executeModel-UD44KGZ4.js +203 -0
  2. package/action-ZJWE3Y5S.js +28 -0
  3. package/addContentAction-TVDBNJM5.js +26 -0
  4. package/addDialogAgentAction-EKH774VT.js +68 -0
  5. package/agentDeleteCommand-TCPEFJTF.js +327 -0
  6. package/agentEmailCommands-CZ3UILZ4.js +626 -0
  7. package/agentListCommands-SJKO2FFB.js +223 -0
  8. package/agentMachineCommands-PSNABISZ.js +425 -0
  9. package/agentPullCommand-O2MTUAFR.js +122 -0
  10. package/agentRecordCommands-MH2JKFHS.js +94 -0
  11. package/agentRunCommand-4KH6MIZR.js +110 -0
  12. package/agentRunControl-K4VKNEHF.js +57 -0
  13. package/agentRuntimeLocal-SKHJUWSS.js +104 -0
  14. package/agentSlice-3WXXN4VK.js +42 -0
  15. package/authCommand-PXFX6JDT.js +581 -0
  16. package/authCommands-356AYWEK.js +35 -0
  17. package/chunk-2EISRLRC.js +238 -0
  18. package/chunk-2FTTDCD4.js +675 -0
  19. package/chunk-2K2ECKSG.js +222 -0
  20. package/chunk-2PUGVR6E.js +19 -0
  21. package/chunk-3ASDTTEI.js +1774 -0
  22. package/chunk-3EUW3WEO.js +8 -0
  23. package/chunk-3LY4F7SV.js +9293 -0
  24. package/chunk-3TZDXYSF.js +71 -0
  25. package/chunk-3WYQEUBI.js +34 -0
  26. package/chunk-4CQLVGRV.js +50 -0
  27. package/chunk-4IJYA27C.js +342 -0
  28. package/chunk-4K2KKCSD.js +577 -0
  29. package/chunk-4SN6J65J.js +38 -0
  30. package/chunk-4VNS5WPM.js +42 -0
  31. package/chunk-4ZDM73SD.js +34 -0
  32. package/chunk-5CS33IBL.js +301 -0
  33. package/chunk-5KLGBAAR.js +386 -0
  34. package/chunk-5MIDPSSK.js +206 -0
  35. package/chunk-5MMAK75Q.js +15 -0
  36. package/chunk-5PJ3VWCS.js +360 -0
  37. package/chunk-63SLEOLK.js +175 -0
  38. package/chunk-63W5N6P3.js +150 -0
  39. package/chunk-6GANEXVO.js +231 -0
  40. package/chunk-6HYVJV7B.js +102 -0
  41. package/chunk-6WD3OOJS.js +20 -0
  42. package/chunk-7OOXPE3N.js +628 -0
  43. package/chunk-7QRKCBOP.js +1078 -0
  44. package/chunk-ATNTHIZI.js +13 -0
  45. package/chunk-AUQ747NZ.js +902 -0
  46. package/chunk-AVMKZHBC.js +85 -0
  47. package/chunk-AZPCASRE.js +36 -0
  48. package/chunk-BBYVOSU2.js +792 -0
  49. package/chunk-C3RUNRHT.js +51 -0
  50. package/chunk-CF2WZF4N.js +134 -0
  51. package/chunk-CF7PE763.js +10 -0
  52. package/chunk-CKOJQDKR.js +198 -0
  53. package/chunk-COMXDWNM.js +807 -0
  54. package/chunk-CPB2YM4D.js +171 -0
  55. package/chunk-CWMSB67P.js +34 -0
  56. package/chunk-DCOA4QSN.js +105 -0
  57. package/chunk-DFFIZ25G.js +30 -0
  58. package/chunk-DWLEOOGR.js +8 -0
  59. package/chunk-DZ3XJVET.js +231 -0
  60. package/chunk-EHLHSX7R.js +1433 -0
  61. package/chunk-ELRRLDWI.js +478 -0
  62. package/chunk-EXTIQUCI.js +482 -0
  63. package/chunk-EYEEHCU4.js +3066 -0
  64. package/chunk-G3SUCT4W.js +8 -0
  65. package/chunk-G43KEVSC.js +1447 -0
  66. package/chunk-GAKEBQD6.js +30 -0
  67. package/chunk-GBRG75BQ.js +86 -0
  68. package/chunk-GG4AJPSR.js +191 -0
  69. package/chunk-H33743XH.js +25 -0
  70. package/chunk-HNMXYYJR.js +12 -0
  71. package/chunk-I42VC5KR.js +15 -0
  72. package/chunk-IDZTNRP2.js +85 -0
  73. package/chunk-ISNCLGUZ.js +146 -0
  74. package/chunk-IWX4UW2E.js +548 -0
  75. package/chunk-JBTJAPUF.js +35 -0
  76. package/chunk-JEXVIMYZ.js +55 -0
  77. package/chunk-JRKKFRAV.js +537 -0
  78. package/chunk-JZPBVBIY.js +94 -0
  79. package/chunk-KKY4B2Q2.js +21 -0
  80. package/chunk-KOCA5FCS.js +4750 -0
  81. package/chunk-KQHGZWSV.js +63 -0
  82. package/chunk-KTVVPRJS.js +138 -0
  83. package/chunk-KUG52IAP.js +8 -0
  84. package/chunk-KX6YBIHG.js +8 -0
  85. package/chunk-LARL2V6G.js +9017 -0
  86. package/chunk-LCBAMY2M.js +60 -0
  87. package/chunk-LM6IYQ3F.js +16 -0
  88. package/chunk-M76ECQRD.js +13658 -0
  89. package/chunk-MGOJ5R6J.js +113 -0
  90. package/chunk-MKMWT7SA.js +27196 -0
  91. package/chunk-MRC4Q34M.js +188 -0
  92. package/chunk-OLZBQWZU.js +6 -0
  93. package/chunk-OPZYGHUC.js +89 -0
  94. package/chunk-OWOHNGCN.js +50 -0
  95. package/chunk-PAKN26FP.js +239 -0
  96. package/chunk-PCWC3JTN.js +91 -0
  97. package/chunk-PG5PNA7Y.js +939 -0
  98. package/chunk-Q2YZULBH.js +104 -0
  99. package/chunk-QSJ3HFEF.js +8 -0
  100. package/chunk-QYXLLLGL.js +4519 -0
  101. package/chunk-ROWQEJRP.js +139 -0
  102. package/chunk-S7Z2HMCN.js +25 -0
  103. package/chunk-SBR32ZZS.js +1901 -0
  104. package/chunk-SH2CFQOH.js +3391 -0
  105. package/chunk-SL35K7AH.js +226 -0
  106. package/chunk-TILFE6LV.js +381 -0
  107. package/chunk-TSS3XJY4.js +2052 -0
  108. package/chunk-U4TRT5V4.js +246 -0
  109. package/chunk-U6VC4MU4.js +8 -0
  110. package/chunk-UAD2WT54.js +64 -0
  111. package/chunk-UUJDGGAK.js +421 -0
  112. package/chunk-VF4K2QE6.js +21 -0
  113. package/chunk-VHBWHNVT.js +59 -0
  114. package/chunk-VIDPVFP3.js +20 -0
  115. package/chunk-VP4WJWKW.js +8882 -0
  116. package/chunk-W4NVOSFF.js +37 -0
  117. package/chunk-WKM6FH35.js +190 -0
  118. package/chunk-WWC7I6TA.js +8 -0
  119. package/chunk-X7W4TNB4.js +1550 -0
  120. package/chunk-XE635NI4.js +1948 -0
  121. package/chunk-XKIMRZO2.js +221 -0
  122. package/chunk-XS466O7S.js +933 -0
  123. package/chunk-Y5GCAMGP.js +9 -0
  124. package/chunk-YBWOP46I.js +3272 -0
  125. package/chunk-YPRZSPF3.js +148 -0
  126. package/chunk-YYUCRDOK.js +69 -0
  127. package/chunk-Z4NR32XR.js +50 -0
  128. package/chunk-ZIG5LJ7X.js +24765 -0
  129. package/chunk-ZNFJWEN4.js +56 -0
  130. package/chunk-ZQ2UM4KG.js +2878 -0
  131. package/cliExecutor-DNE7TCC4.js +36 -0
  132. package/clipboardy-BVE3LVEH.js +12001 -0
  133. package/createAgentAutomationAction-63OIP6X5.js +866 -0
  134. package/createDialogAction-ZLYZDYBB.js +54 -0
  135. package/createPageAction-AL5FSDCK.js +171 -0
  136. package/db-HCJ5PRB5.js +271 -0
  137. package/dbSlice-PR44QPXY.js +60 -0
  138. package/deleteFile-4SKGPHOZ.js +41 -0
  139. package/dialogCommands-F6YI5742.js +63 -0
  140. package/dialogSlice-JSBNZRLR.js +148 -0
  141. package/docCreateCommands-4CTO7ERT.js +219 -0
  142. package/docDeleteCommands-VBWERDRG.js +180 -0
  143. package/docReadCommands-KNP4MFYB.js +133 -0
  144. package/docStore-ADP5VYY4.js +98 -0
  145. package/docUpdateCommands-4BCBJQHA.js +317 -0
  146. package/fetchMessages-U6ZHN56A.js +17 -0
  147. package/getPricing-3E6UNPKL.js +30 -0
  148. package/handleSendMessageAction-IJDQ6ARA.js +185 -0
  149. package/index.js +188 -112943
  150. package/lib-FYYBQIXS.js +19839 -0
  151. package/localDialogRead-Z5UTAJPU.js +26 -0
  152. package/localFirstLog-DHNOY2NA.js +19 -0
  153. package/localRuntimeAuthority-TEGCOWX4.js +471 -0
  154. package/localRuntimeDb-LGDF6FQP.js +12 -0
  155. package/machineCommands-EA3M4XTN.js +779 -0
  156. package/machineInfo-M6KB6HZN.js +10 -0
  157. package/machineWsRunDispatch-NAPKE5ZA.js +110 -0
  158. package/memoryCommands-O4MIPIWQ.js +476 -0
  159. package/models-4OPOOLFS.js +9 -0
  160. package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
  161. package/package.json +3 -25
  162. package/read-RIJCIVKX.js +17 -0
  163. package/readDocTool-GZD2N3LO.js +16 -0
  164. package/readlineWorkspace-KMWT4T4S.js +5509 -0
  165. package/removeDialogAgentAction-GJQJNDW6.js +73 -0
  166. package/runAgentClientLoop-U5Q6NDTJ.js +291 -0
  167. package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
  168. package/setDialogExtraReferencesAction-M7OQG54N.js +60 -0
  169. package/setPrimaryDialogAgentAction-46UNFJDL.js +80 -0
  170. package/settingSlice-FVUUH4JA.js +199 -0
  171. package/skillSummaryMarker-42HKSXYY.js +9 -0
  172. package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
  173. package/slateUtils-2M7MUTWX.js +19 -0
  174. package/spaceCommands-E2CFRPZJ.js +454 -0
  175. package/spaceSlice-L3R6IMXE.js +147 -0
  176. package/streamAgentChatTurn-UBDAOQWE.js +4528 -0
  177. package/tableCommands-GOFP7QKA.js +1286 -0
  178. package/toolApiClient-QI3YBNWB.js +26 -0
  179. package/tools-TMJXZTCA.js +85 -0
  180. package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
  181. package/understanding-GQKNDDWM.js +271 -0
  182. package/updateCommands-VOSPKXFF.js +31 -0
  183. package/updateDialogTitleAction-ZTWRDXI2.js +188 -0
@@ -0,0 +1,175 @@
1
+ import {
2
+ selectCurrentServer,
3
+ selectRemoteServers
4
+ } from "./chunk-TSS3XJY4.js";
5
+ import {
6
+ createUserKey,
7
+ extractAgentInfo,
8
+ extractCoverImage,
9
+ resolveShareAuthorIdentity,
10
+ sanitizeShareData,
11
+ shareKey,
12
+ toNonEmptyString
13
+ } from "./chunk-SH2CFQOH.js";
14
+ import {
15
+ noloDeleteRequest,
16
+ noloWriteRequest,
17
+ selectIdentityUser,
18
+ selectIdentityUserId
19
+ } from "./chunk-EYEEHCU4.js";
20
+ import {
21
+ normalizeTimeFields
22
+ } from "./chunk-QYXLLLGL.js";
23
+
24
+ // packages/share/action.ts
25
+ var generateToken = () => {
26
+ const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
27
+ const charsLen = chars.length;
28
+ const maxValid = 252;
29
+ let token = "";
30
+ while (token.length < 10) {
31
+ const bytes = new Uint8Array(16);
32
+ crypto.getRandomValues(bytes);
33
+ for (let i = 0; i < bytes.length && token.length < 10; i++) {
34
+ if (bytes[i] < maxValid) {
35
+ token += chars.charAt(bytes[i] % charsLen);
36
+ }
37
+ }
38
+ }
39
+ return token;
40
+ };
41
+ var assertDialogShareMessagesPresent = (type, data) => {
42
+ if (type !== "dialog") return;
43
+ const messages = Array.isArray(data.messages) ? data.messages : Array.isArray(data.history) ? data.history : [];
44
+ if (messages.length > 0) return;
45
+ throw new Error("Cannot share dialog without persisted messages.");
46
+ };
47
+ var resolveTableSharePayload = (type, data, userId, originServer) => {
48
+ if (type !== "table") return sanitizeShareData(data);
49
+ const tableDbKey = typeof data.dbKey === "string" && data.dbKey.trim().length > 0 ? data.dbKey : void 0;
50
+ const tableOwnerId = typeof data.tenantId === "string" && data.tenantId.trim().length > 0 ? data.tenantId : userId;
51
+ if (!tableDbKey) {
52
+ throw new Error("Table share requires a dbKey.");
53
+ }
54
+ return {
55
+ mode: "live",
56
+ tableDbKey,
57
+ tableOwnerId,
58
+ originServer
59
+ };
60
+ };
61
+ var shareResourceAction = async (config, thunkApi) => {
62
+ const state = thunkApi.getState();
63
+ const userId = selectIdentityUserId(state);
64
+ const currentUser = selectIdentityUser(state);
65
+ if (!userId) {
66
+ throw new Error("User must be logged in to share resources.");
67
+ }
68
+ const token = generateToken();
69
+ const key = shareKey.create(token);
70
+ const currentServer = selectCurrentServer(state);
71
+ assertDialogShareMessagesPresent(config.type, config.data);
72
+ const snapshotData = resolveTableSharePayload(
73
+ config.type,
74
+ config.data,
75
+ userId,
76
+ currentServer
77
+ );
78
+ const coverImage = extractCoverImage(config.type, snapshotData);
79
+ const agentInfo = extractAgentInfo(config.type, snapshotData);
80
+ const createdAt = Date.now();
81
+ const { db: clientDb } = thunkApi.extra;
82
+ let authorProfile = null;
83
+ if (clientDb) {
84
+ try {
85
+ authorProfile = await clientDb.get(createUserKey.profile(userId));
86
+ } catch {
87
+ authorProfile = null;
88
+ }
89
+ }
90
+ const { authorName, authorAvatar } = resolveShareAuthorIdentity({
91
+ user: currentUser,
92
+ profile: authorProfile
93
+ });
94
+ if (agentInfo.sourceAgentKey && !agentInfo.sourceAgentName) {
95
+ if (clientDb) {
96
+ try {
97
+ const agentData = await clientDb.get(agentInfo.sourceAgentKey);
98
+ const name = toNonEmptyString(agentData?.name);
99
+ if (name) agentInfo.sourceAgentName = name;
100
+ } catch {
101
+ }
102
+ }
103
+ }
104
+ const sharedObject = {
105
+ type: config.type,
106
+ version: 1,
107
+ data: snapshotData,
108
+ meta: {
109
+ authorId: userId,
110
+ ...authorName ? { authorName } : {},
111
+ ...authorAvatar ? { authorAvatar } : {},
112
+ createdAt,
113
+ visibility: config.visibility ?? "private",
114
+ title: config.title,
115
+ description: config.description,
116
+ originalId: config.data.dbKey ?? config.data.id,
117
+ coverImage,
118
+ ...agentInfo
119
+ }
120
+ };
121
+ const servers = [
122
+ currentServer,
123
+ ...selectRemoteServers(state).filter((server) => server !== currentServer)
124
+ ].filter(Boolean);
125
+ const replicaServers = servers.filter((server) => server !== currentServer);
126
+ if (servers.length === 0) {
127
+ throw new Error("No available server to publish share.");
128
+ }
129
+ if (config.type === "table" && sharedObject.data.mode === "live") {
130
+ sharedObject.data = {
131
+ ...sharedObject.data,
132
+ originServer: currentServer
133
+ };
134
+ sharedObject.meta = {
135
+ ...sharedObject.meta,
136
+ mode: "live",
137
+ tableDbKey: typeof sharedObject.data.tableDbKey === "string" ? sharedObject.data.tableDbKey : void 0,
138
+ tableOwnerId: typeof sharedObject.data.tableOwnerId === "string" ? sharedObject.data.tableOwnerId : void 0,
139
+ originServer: currentServer,
140
+ replicaServers
141
+ };
142
+ }
143
+ const persistedSharedObject = normalizeTimeFields({
144
+ ...sharedObject,
145
+ dbKey: key,
146
+ userId
147
+ });
148
+ const indexKeys = shareKey.allIndexKeysFromShare(key, persistedSharedObject);
149
+ const results = await Promise.all(
150
+ servers.map(
151
+ (server) => noloWriteRequest(server, { data: persistedSharedObject, customKey: key, userId, indexKeys }, state)
152
+ )
153
+ );
154
+ const [originPublished, ...replicaPublishResults] = results;
155
+ if (!originPublished) {
156
+ const successfulReplicaServers = replicaServers.filter(
157
+ (_, index) => replicaPublishResults[index]
158
+ );
159
+ await Promise.all(
160
+ successfulReplicaServers.map(
161
+ (server) => noloDeleteRequest(server, key, { type: "single" }, state)
162
+ )
163
+ );
164
+ throw new Error("Failed to publish share to origin server.");
165
+ }
166
+ if (!clientDb) {
167
+ throw new Error("Client database instance is required in shareResourceAction");
168
+ }
169
+ await clientDb.put(key, persistedSharedObject);
170
+ return { token, key };
171
+ };
172
+
173
+ export {
174
+ shareResourceAction
175
+ };
@@ -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,231 @@
1
+ import {
2
+ DEFAULT_AGENT_BASE_POLICY,
3
+ DEFAULT_USER_PREFERENCE_PROFILE
4
+ } from "./chunk-TSS3XJY4.js";
5
+
6
+ // packages/ai/policy/runtimePolicy.ts
7
+ var clampLevel = (value, fallback) => {
8
+ const n = Number(value);
9
+ if (n === 1 || n === 2 || n === 3 || n === 4) {
10
+ return n;
11
+ }
12
+ return fallback;
13
+ };
14
+ var normalizeTonePreset = (value, fallback) => {
15
+ switch (value) {
16
+ case "professional":
17
+ case "friendly":
18
+ case "direct":
19
+ case "pragmatic":
20
+ case "default":
21
+ return value;
22
+ default:
23
+ return fallback;
24
+ }
25
+ };
26
+ var normalizeToneResolutionMode = (value, fallback) => {
27
+ switch (value) {
28
+ case "agent_first":
29
+ case "user_first":
30
+ case "blend":
31
+ return value;
32
+ default:
33
+ return fallback;
34
+ }
35
+ };
36
+ var normalizeSelfEvolutionMode = (value, fallback) => {
37
+ switch (value) {
38
+ case "none":
39
+ case "knowledge_only":
40
+ case "prompt_and_refs":
41
+ case "full":
42
+ return value;
43
+ default:
44
+ return fallback;
45
+ }
46
+ };
47
+ var resolveAgentBasePolicy = (agentConfig) => {
48
+ const raw = agentConfig?.basePolicy ?? {};
49
+ return {
50
+ version: 1,
51
+ tone: {
52
+ preset: normalizeTonePreset(
53
+ raw?.tone?.preset,
54
+ DEFAULT_AGENT_BASE_POLICY.tone?.preset ?? "default"
55
+ ),
56
+ resolutionMode: normalizeToneResolutionMode(
57
+ raw?.tone?.resolutionMode,
58
+ DEFAULT_AGENT_BASE_POLICY.tone?.resolutionMode ?? "blend"
59
+ )
60
+ },
61
+ knowledgeCaptureMaxLevel: clampLevel(
62
+ raw?.knowledgeCaptureMaxLevel,
63
+ DEFAULT_AGENT_BASE_POLICY.knowledgeCaptureMaxLevel
64
+ ),
65
+ spaceContextMaxLevel: clampLevel(
66
+ raw?.spaceContextMaxLevel,
67
+ DEFAULT_AGENT_BASE_POLICY.spaceContextMaxLevel
68
+ ),
69
+ selfEvolutionMode: normalizeSelfEvolutionMode(
70
+ raw?.selfEvolutionMode,
71
+ DEFAULT_AGENT_BASE_POLICY.selfEvolutionMode
72
+ )
73
+ };
74
+ };
75
+ var resolveUserPreferenceProfile = (settingsRecord) => {
76
+ const fallbackSpaceLevel = settingsRecord?.enableReadCurrentSpace === false ? 1 : DEFAULT_USER_PREFERENCE_PROFILE.spaceContextLevel;
77
+ return {
78
+ version: 1,
79
+ tone: {
80
+ preset: normalizeTonePreset(
81
+ settingsRecord?.userTonePreset,
82
+ DEFAULT_USER_PREFERENCE_PROFILE.tone?.preset ?? "default"
83
+ )
84
+ },
85
+ knowledgeCaptureLevel: clampLevel(
86
+ settingsRecord?.knowledgeCaptureLevel,
87
+ DEFAULT_USER_PREFERENCE_PROFILE.knowledgeCaptureLevel
88
+ ),
89
+ spaceContextLevel: clampLevel(
90
+ settingsRecord?.spaceContextLevel,
91
+ fallbackSpaceLevel
92
+ )
93
+ };
94
+ };
95
+ var containsAny = (text, patterns) => patterns.some((pattern) => text.includes(pattern));
96
+ var inferCaptureIntent = (userInput) => {
97
+ const normalized = userInput.toLowerCase();
98
+ if (containsAny(normalized, [
99
+ "\u4FDD\u5B58",
100
+ "\u5B58\u4E00\u4E0B",
101
+ "\u6C89\u6DC0",
102
+ "\u8BB0\u4F4F",
103
+ "\u5199\u5165\u6587\u6863",
104
+ "\u5EFA\u6587\u6863",
105
+ "\u521B\u5EFA\u6587\u6863",
106
+ "\u5BFC\u5165 skill",
107
+ "\u5BFC\u5165\u8FD9\u4E2A skill",
108
+ "\u786E\u8BA4\u5BFC\u5165",
109
+ "\u786E\u8BA4\u5BFC\u5165\u8FD9\u4E2A skill",
110
+ "\u5BFC\u5165\u8FD9\u4E2A\u6280\u80FD",
111
+ "\u786E\u8BA4\u5BFC\u5165\u8FD9\u4E2A\u6280\u80FD",
112
+ "\u521B\u5EFA skill",
113
+ "\u521B\u5EFA\u8FD9\u4E2A skill",
114
+ "skill \u6587\u6863",
115
+ "\u521B\u5EFA\u8868\u683C",
116
+ "createtable",
117
+ "addtablerow",
118
+ "addtablerows",
119
+ "\u5EFA\u8868",
120
+ "\u5EFA\u4E2A\u8868",
121
+ "\u505A\u4E2A\u8868",
122
+ "\u505A\u4E00\u5F20\u8868",
123
+ "\u5199\u8868",
124
+ "\u5199\u5165\u8868",
125
+ "\u5199\u5165\u4E00\u884C",
126
+ "\u5199\u5165 table",
127
+ "\u653E\u5230 table",
128
+ "\u5B58\u5230 table",
129
+ "\u4FDD\u5B58\u5230 table",
130
+ "\u8BB0\u5F55\u4E0B\u6765",
131
+ "\u91C7\u96C6",
132
+ "\u505A\u6570\u636E\u96C6",
133
+ "\u505A\u6210\u6570\u636E\u96C6",
134
+ "\u6574\u7406\u6210\u6570\u636E\u96C6",
135
+ "\u6574\u7406\u6210\u8868",
136
+ "\u6574\u7406\u6210\u4E00\u5F20\u8868",
137
+ "\u5EFA\u7ACB\u4E00\u4E2A\u8868",
138
+ "\u5EFA\u7ACB\u4E00\u5F20\u8868",
139
+ "\u5EFA\u7ACB\u6210\u8868",
140
+ "\u5EFA\u7ACB\u6210\u4E00\u5F20\u8868",
141
+ "\u521B\u5EFA\u8FD9\u4E2A\u8868\u683C",
142
+ "\u786E\u8BA4\u521B\u5EFA",
143
+ "\u786E\u8BA4\u521B\u5EFA\u8FD9\u5F20\u8868\u683C",
144
+ "create doc",
145
+ "import skill",
146
+ "confirm import",
147
+ "create skill",
148
+ "create table",
149
+ "write table",
150
+ "save to table",
151
+ "dataset",
152
+ "save this",
153
+ "remember this",
154
+ "document this"
155
+ ])) {
156
+ return "strong";
157
+ }
158
+ if (containsAny(normalized, [
159
+ "\u603B\u7ED3",
160
+ "\u65B9\u6848",
161
+ "\u8C03\u7814",
162
+ "\u89C4\u8303",
163
+ "\u4F1A\u8BAE\u7EAA\u8981",
164
+ "\u603B\u7ED3\u4E00\u4E0B",
165
+ "research",
166
+ "proposal",
167
+ "spec",
168
+ "summary"
169
+ ])) {
170
+ return "possible";
171
+ }
172
+ return "none";
173
+ };
174
+ var resolveTonePreset = (agentTone, userTone, mode) => {
175
+ if (mode === "agent_first") {
176
+ return agentTone === "default" ? userTone : agentTone;
177
+ }
178
+ if (mode === "user_first") {
179
+ return userTone === "default" ? agentTone : userTone;
180
+ }
181
+ if (userTone !== "default") return userTone;
182
+ return agentTone;
183
+ };
184
+ var preloadSummaryCountByLevel = (level) => ({ 1: 0, 2: 0, 3: 8, 4: 16 })[level];
185
+ var preloadBudgetRatioByLevel = (level) => ({ 1: 0, 2: 0.01, 3: 0.04, 4: 0.08 })[level];
186
+ var knowledgeCaptureLevelLabel = (level) => ({
187
+ 1: "\u4E0D\u4E3B\u52A8\u521B\u5EFA",
188
+ 2: "\u5148\u95EE\u518D\u521B\u5EFA",
189
+ 3: "\u56DE\u7B54\u540E\u5EFA\u8BAE\u521B\u5EFA",
190
+ 4: "\u9AD8\u4EF7\u503C\u7ED3\u679C\u53EF\u81EA\u52A8\u521B\u5EFA"
191
+ })[level] ?? "\u672A\u77E5\u7EA7\u522B";
192
+ var spaceContextLevelLabel = (level) => ({
193
+ 1: "\u4E0D\u81EA\u52A8\u8BFB\u53D6",
194
+ 2: "\u53EA\u770B\u7ED3\u6784\u548C\u6807\u9898",
195
+ 3: "\u8F7B\u91CF\u8BFB\u53D6",
196
+ 4: "\u81EA\u9002\u5E94\u8BFB\u53D6"
197
+ })[level] ?? "\u672A\u77E5\u7EA7\u522B";
198
+ var buildStaticUserPolicyContext = (params) => {
199
+ const agentBasePolicy = resolveAgentBasePolicy(params.agentConfig);
200
+ const userPreferenceProfile = resolveUserPreferenceProfile(params.settingsRecord);
201
+ const tonePreset = resolveTonePreset(
202
+ agentBasePolicy.tone?.preset ?? "default",
203
+ userPreferenceProfile.tone?.preset ?? "default",
204
+ agentBasePolicy.tone?.resolutionMode ?? "blend"
205
+ );
206
+ const knowledgeLevel = Math.min(
207
+ agentBasePolicy.knowledgeCaptureMaxLevel,
208
+ userPreferenceProfile.knowledgeCaptureLevel
209
+ );
210
+ const spaceLevel = Math.min(
211
+ agentBasePolicy.spaceContextMaxLevel,
212
+ userPreferenceProfile.spaceContextLevel
213
+ );
214
+ return [
215
+ `\u7528\u6237\u8BED\u6C14\u504F\u597D\uFF1A${tonePreset}`,
216
+ `\u77E5\u8BC6\u6C89\u6DC0\u7EA7\u522B\uFF1A${knowledgeLevel}\uFF08${knowledgeCaptureLevelLabel(knowledgeLevel)}\uFF09`,
217
+ `\u7A7A\u95F4\u4E0A\u4E0B\u6587\u7EA7\u522B\uFF1A${spaceLevel}\uFF08${spaceContextLevelLabel(spaceLevel)}\uFF09`,
218
+ "\u8BF7\u5C3D\u91CF\u4FDD\u7559 agent \u81EA\u8EAB\u89D2\u8272\u8BBE\u5B9A\uFF0C\u540C\u65F6\u6309\u7528\u6237\u504F\u597D\u8C03\u6574\u8868\u8FBE\u548C\u81EA\u52A8\u5316\u7A0B\u5EA6\u3002"
219
+ ].join("\n");
220
+ };
221
+ var resolveSpaceContextPreloadPlan = (level) => ({
222
+ preloadSummaryCount: preloadSummaryCountByLevel(level),
223
+ preloadBudgetRatio: preloadBudgetRatioByLevel(level),
224
+ includeRecentContent: level >= 3
225
+ });
226
+
227
+ export {
228
+ inferCaptureIntent,
229
+ buildStaticUserPolicyContext,
230
+ resolveSpaceContextPreloadPlan
231
+ };
@@ -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
+ };
@@ -0,0 +1,20 @@
1
+ // packages/cli/levelLazyShim.mjs
2
+ import { createRequire } from "node:module";
3
+ var _require = createRequire(import.meta.url);
4
+ var _RealLevel;
5
+ function ensureLevel() {
6
+ if (!_RealLevel) {
7
+ _RealLevel = _require("level").Level;
8
+ }
9
+ return _RealLevel;
10
+ }
11
+ var Level = class {
12
+ constructor(...args) {
13
+ const RealLevel = ensureLevel();
14
+ return new RealLevel(...args);
15
+ }
16
+ };
17
+
18
+ export {
19
+ Level
20
+ };