nolo-cli 0.8.0-alpha.6 → 0.8.0-alpha.7

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 (174) hide show
  1. package/_executeModel-XIGO7HW5.js +198 -0
  2. package/action-PAXRPJJF.js +27 -0
  3. package/addContentAction-CZVWF3QZ.js +25 -0
  4. package/addDialogAgentAction-CCIDTPHC.js +67 -0
  5. package/agentDeleteCommand-47B24JYG.js +323 -0
  6. package/agentEmailCommands-D4FC6OZJ.js +621 -0
  7. package/agentListCommands-UFET7CC4.js +219 -0
  8. package/agentMachineCommands-LH7QDQPP.js +421 -0
  9. package/agentPullCommand-O2MTUAFR.js +122 -0
  10. package/agentRecordCommands-CWS2B5IA.js +89 -0
  11. package/agentRunCommand-3FRPISLG.js +102 -0
  12. package/agentRunControl-K4VKNEHF.js +57 -0
  13. package/agentRuntimeLocal-JNQQC2WG.js +99 -0
  14. package/agentSlice-XDFSELFJ.js +41 -0
  15. package/authCommand-WXMD3IPR.js +574 -0
  16. package/authCommands-X74AFDTC.js +26 -0
  17. package/chunk-2EISRLRC.js +238 -0
  18. package/chunk-2FTTDCD4.js +675 -0
  19. package/chunk-2JHWPW5B.js +2127 -0
  20. package/chunk-2LMT6K6N.js +171 -0
  21. package/chunk-2MALU52L.js +51 -0
  22. package/chunk-364VYAX2.js +19 -0
  23. package/chunk-3ASDTTEI.js +1774 -0
  24. package/chunk-3EUW3WEO.js +8 -0
  25. package/chunk-3LY4F7SV.js +9293 -0
  26. package/chunk-4CQLVGRV.js +50 -0
  27. package/chunk-4IJYA27C.js +342 -0
  28. package/chunk-4SN6J65J.js +38 -0
  29. package/chunk-4VNS5WPM.js +42 -0
  30. package/chunk-543C7RDK.js +562 -0
  31. package/chunk-572EKYLF.js +792 -0
  32. package/chunk-5MIDPSSK.js +206 -0
  33. package/chunk-5MMAK75Q.js +15 -0
  34. package/chunk-5XH3NZ4T.js +3631 -0
  35. package/chunk-63W5N6P3.js +150 -0
  36. package/chunk-6HYVJV7B.js +102 -0
  37. package/chunk-6PWWWMI7.js +628 -0
  38. package/chunk-6WD3OOJS.js +20 -0
  39. package/chunk-A3X4Y7MO.js +4294 -0
  40. package/chunk-AR7ZSGDI.js +929 -0
  41. package/chunk-ATNTHIZI.js +13 -0
  42. package/chunk-AUGHVUFE.js +69 -0
  43. package/chunk-AVMKZHBC.js +85 -0
  44. package/chunk-AZPCASRE.js +36 -0
  45. package/chunk-B76D3JJK.js +1447 -0
  46. package/chunk-BR2WP3DF.js +548 -0
  47. package/chunk-BSTNFPHD.js +231 -0
  48. package/chunk-CF2WZF4N.js +134 -0
  49. package/chunk-CF7PE763.js +10 -0
  50. package/chunk-CKOJQDKR.js +198 -0
  51. package/chunk-CM54RSSA.js +206 -0
  52. package/chunk-CWMSB67P.js +34 -0
  53. package/chunk-DA2OEKS6.js +27 -0
  54. package/chunk-DFFIZ25G.js +30 -0
  55. package/chunk-DWLEOOGR.js +8 -0
  56. package/chunk-DZ3XJVET.js +231 -0
  57. package/chunk-E5HMHIKL.js +222 -0
  58. package/chunk-EHLHSX7R.js +1433 -0
  59. package/chunk-ELRRLDWI.js +478 -0
  60. package/chunk-EYEEHCU4.js +3066 -0
  61. package/chunk-G3SUCT4W.js +8 -0
  62. package/chunk-G5H7RNFL.js +807 -0
  63. package/chunk-GAKEBQD6.js +30 -0
  64. package/chunk-GBRG75BQ.js +86 -0
  65. package/chunk-GEKCOPTN.js +190 -0
  66. package/chunk-H2RMRZJE.js +113 -0
  67. package/chunk-H33743XH.js +25 -0
  68. package/chunk-HEIIIZBX.js +104 -0
  69. package/chunk-HNMXYYJR.js +12 -0
  70. package/chunk-IAXBCTTE.js +175 -0
  71. package/chunk-IDZTNRP2.js +85 -0
  72. package/chunk-IECI4YHR.js +421 -0
  73. package/chunk-ISNCLGUZ.js +146 -0
  74. package/chunk-IYQV26RA.js +138 -0
  75. package/chunk-JBTJAPUF.js +35 -0
  76. package/chunk-JZPBVBIY.js +94 -0
  77. package/chunk-KK6SWS5B.js +1078 -0
  78. package/chunk-KQHGZWSV.js +63 -0
  79. package/chunk-KTI2WDDG.js +24674 -0
  80. package/chunk-KUG52IAP.js +8 -0
  81. package/chunk-KX6YBIHG.js +8 -0
  82. package/chunk-LCBAMY2M.js +60 -0
  83. package/chunk-LM25IZBJ.js +902 -0
  84. package/chunk-LM6IYQ3F.js +16 -0
  85. package/chunk-M76ECQRD.js +13658 -0
  86. package/chunk-MRC4Q34M.js +188 -0
  87. package/chunk-NE3E3XJ2.js +936 -0
  88. package/chunk-NXZGF7F7.js +2878 -0
  89. package/chunk-OF5H3QWS.js +300 -0
  90. package/chunk-OLZBQWZU.js +6 -0
  91. package/chunk-OVGXXUVI.js +91 -0
  92. package/chunk-OWOHNGCN.js +50 -0
  93. package/chunk-PN7AFLOK.js +3401 -0
  94. package/chunk-QSJ3HFEF.js +8 -0
  95. package/chunk-QYXLLLGL.js +4519 -0
  96. package/chunk-ROWQEJRP.js +139 -0
  97. package/chunk-S7Z2HMCN.js +25 -0
  98. package/chunk-SL3EPWB4.js +1949 -0
  99. package/chunk-TDIQFT2F.js +301 -0
  100. package/chunk-TILFE6LV.js +381 -0
  101. package/chunk-U4TRT5V4.js +246 -0
  102. package/chunk-U6VC4MU4.js +8 -0
  103. package/chunk-UAD2WT54.js +64 -0
  104. package/chunk-USZDUWOV.js +191 -0
  105. package/chunk-USZMK5UT.js +105 -0
  106. package/chunk-UVPF33PW.js +46995 -0
  107. package/chunk-V2F4OGYM.js +9013 -0
  108. package/chunk-VEJLAVTC.js +2052 -0
  109. package/chunk-VF4K2QE6.js +21 -0
  110. package/chunk-VHBWHNVT.js +59 -0
  111. package/chunk-VIDPVFP3.js +20 -0
  112. package/chunk-VP4WJWKW.js +8882 -0
  113. package/chunk-VQ2AJRGD.js +148 -0
  114. package/chunk-W4NVOSFF.js +37 -0
  115. package/chunk-WWC7I6TA.js +8 -0
  116. package/chunk-X7W4TNB4.js +1550 -0
  117. package/chunk-XDVAYP26.js +537 -0
  118. package/chunk-XKIMRZO2.js +221 -0
  119. package/chunk-Y5GCAMGP.js +9 -0
  120. package/chunk-YD43KPCK.js +360 -0
  121. package/chunk-YIJFUVKA.js +34 -0
  122. package/chunk-Z4NR32XR.js +50 -0
  123. package/chunk-ZNFJWEN4.js +56 -0
  124. package/cliExecutor-DNE7TCC4.js +36 -0
  125. package/clipboardy-BVE3LVEH.js +12001 -0
  126. package/createAgentAutomationAction-3QTGNYJC.js +864 -0
  127. package/createDialogAction-5YX3ARBK.js +52 -0
  128. package/createPageAction-EQNQQRCW.js +169 -0
  129. package/db-HCJ5PRB5.js +271 -0
  130. package/dbSlice-C4UJLRZP.js +59 -0
  131. package/deleteFile-4SKGPHOZ.js +41 -0
  132. package/dialogCommands-AOQS23FV.js +59 -0
  133. package/dialogSlice-GZE3NCMC.js +146 -0
  134. package/docCreateCommands-GVOQVJON.js +215 -0
  135. package/docDeleteCommands-GEB7YAUZ.js +176 -0
  136. package/docReadCommands-XYKI2DF2.js +129 -0
  137. package/docStore-MLM5AME5.js +96 -0
  138. package/docUpdateCommands-4L3RAMHZ.js +313 -0
  139. package/fetchMessages-JOCYIFKL.js +16 -0
  140. package/getPricing-PWPJ6MNV.js +30 -0
  141. package/handleSendMessageAction-WG2GKTGZ.js +183 -0
  142. package/index.js +188 -113035
  143. package/localDialogRead-D3BELSTF.js +26 -0
  144. package/localFirstLog-DHNOY2NA.js +19 -0
  145. package/localRuntimeAuthority-TEGCOWX4.js +471 -0
  146. package/localRuntimeDb-LGDF6FQP.js +12 -0
  147. package/machineCommands-ZNXKLH6Q.js +774 -0
  148. package/machineInfo-M6KB6HZN.js +10 -0
  149. package/machineWsRunDispatch-7WRG6HNV.js +105 -0
  150. package/memoryCommands-O4MIPIWQ.js +476 -0
  151. package/models-XLEOET3E.js +9 -0
  152. package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
  153. package/package.json +3 -25
  154. package/read-RIJCIVKX.js +17 -0
  155. package/readDocTool-GZD2N3LO.js +16 -0
  156. package/readlineWorkspace-AQURUDN4.js +5357 -0
  157. package/removeDialogAgentAction-CXLST3N6.js +72 -0
  158. package/runAgentClientLoop-VQUEKGA5.js +288 -0
  159. package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
  160. package/setDialogExtraReferencesAction-LP6VYGU7.js +59 -0
  161. package/setPrimaryDialogAgentAction-D3GGH23T.js +79 -0
  162. package/settingSlice-J4I3Z5H7.js +198 -0
  163. package/skillSummaryMarker-42HKSXYY.js +9 -0
  164. package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
  165. package/slateUtils-2M7MUTWX.js +19 -0
  166. package/spaceCommands-R2RXD5UY.js +450 -0
  167. package/spaceSlice-5UT4JNIN.js +145 -0
  168. package/streamAgentChatTurn-NRWSQKFN.js +4503 -0
  169. package/tableCommands-66XEWHAK.js +1286 -0
  170. package/toolApiClient-QI3YBNWB.js +26 -0
  171. package/tools-TNMUDDRK.js +83 -0
  172. package/understanding-HCSFPE7R.js +318 -0
  173. package/updateCommands-VOSPKXFF.js +31 -0
  174. package/updateDialogTitleAction-IXOKAVX3.js +185 -0
@@ -0,0 +1,246 @@
1
+ import {
2
+ resolveNoloHome
3
+ } from "./chunk-LM6IYQ3F.js";
4
+
5
+ // packages/database-engine/cliAuthorityBrokerClient.ts
6
+ import { createConnection } from "node:net";
7
+ var DEFAULT_ITERATOR_PAGE_SIZE = 200;
8
+ var CliAuthorityBrokerUnavailableError = class extends Error {
9
+ reason = "cli_authority_broker_unavailable";
10
+ status = 503;
11
+ endpoint;
12
+ constructor(endpoint, cause) {
13
+ super(`CLI authority broker unavailable at ${endpoint}. Start the local authority broker and retry.`);
14
+ this.name = "CliAuthorityBrokerUnavailableError";
15
+ this.endpoint = endpoint;
16
+ if (cause !== void 0) {
17
+ this.cause = cause;
18
+ }
19
+ }
20
+ };
21
+ var CliAuthorityBrokerProtocolError = class extends Error {
22
+ code;
23
+ retryable;
24
+ constructor(error) {
25
+ super(error.message);
26
+ this.name = "CliAuthorityBrokerProtocolError";
27
+ this.code = error.code;
28
+ this.retryable = error.retryable === true;
29
+ }
30
+ };
31
+ function isCliAuthorityBrokerUnavailableError(error) {
32
+ return error instanceof CliAuthorityBrokerUnavailableError || typeof error === "object" && error !== null && error.reason === "cli_authority_broker_unavailable" && error.status === 503;
33
+ }
34
+ function isCliAuthorityBrokerProtocolError(error) {
35
+ return error instanceof CliAuthorityBrokerProtocolError;
36
+ }
37
+ function resolveBrokerSocketTarget(endpoint) {
38
+ if (endpoint.startsWith("unix://")) {
39
+ return { kind: "unix", path: endpoint.slice("unix://".length) };
40
+ }
41
+ if (endpoint.startsWith("tcp://")) {
42
+ const url = new URL(endpoint);
43
+ return {
44
+ kind: "tcp",
45
+ host: url.hostname,
46
+ port: Number(url.port)
47
+ };
48
+ }
49
+ throw new Error(`Unsupported CLI authority broker endpoint: ${endpoint}`);
50
+ }
51
+ function createCliAuthorityBrokerSocketInvoker(options) {
52
+ const target = resolveBrokerSocketTarget(options.endpoint);
53
+ return async (request) => {
54
+ return await new Promise((resolve, reject) => {
55
+ const socket = target.kind === "unix" ? createConnection(target.path) : createConnection({ host: target.host, port: target.port });
56
+ let responseBuffer = "";
57
+ let settled = false;
58
+ const timeout = setTimeout(() => {
59
+ finish(() => {
60
+ socket.destroy();
61
+ reject(new Error(`CLI authority broker request at ${options.endpoint} timed out after 5000ms`));
62
+ });
63
+ }, 5e3);
64
+ const finish = (fn) => {
65
+ if (settled) return;
66
+ settled = true;
67
+ clearTimeout(timeout);
68
+ fn();
69
+ };
70
+ socket.setEncoding("utf8");
71
+ socket.on("connect", () => {
72
+ socket.write(`${JSON.stringify(request)}
73
+ `);
74
+ });
75
+ socket.on("data", (chunk) => {
76
+ responseBuffer += chunk;
77
+ });
78
+ socket.on("end", () => {
79
+ finish(() => {
80
+ const payload = responseBuffer.trim();
81
+ if (!payload) {
82
+ reject(new Error(`CLI authority broker at ${options.endpoint} returned no response`));
83
+ return;
84
+ }
85
+ try {
86
+ resolve(JSON.parse(payload));
87
+ } catch (error) {
88
+ reject(error);
89
+ }
90
+ });
91
+ });
92
+ socket.on("error", (error) => {
93
+ finish(() => reject(error));
94
+ });
95
+ });
96
+ };
97
+ }
98
+ async function invokeBrokerRequest(options, request) {
99
+ try {
100
+ const response = await options.invoke(request);
101
+ if (response.ok) return response.result;
102
+ if (response.error.code === "BROKER_UNAVAILABLE") {
103
+ throw new CliAuthorityBrokerUnavailableError(options.endpoint, response.error);
104
+ }
105
+ throw new CliAuthorityBrokerProtocolError(response.error);
106
+ } catch (error) {
107
+ if (isCliAuthorityBrokerUnavailableError(error)) throw error;
108
+ if (isCliAuthorityBrokerProtocolError(error)) throw error;
109
+ throw new CliAuthorityBrokerUnavailableError(options.endpoint, error);
110
+ }
111
+ }
112
+ function createCliAuthorityBrokerClient(options) {
113
+ const pageSize = options.iteratorPageSize ?? DEFAULT_ITERATOR_PAGE_SIZE;
114
+ return {
115
+ get location() {
116
+ return options.location ?? options.endpoint;
117
+ },
118
+ get status() {
119
+ return options.status ?? "broker";
120
+ },
121
+ async open() {
122
+ await invokeBrokerRequest(options, { type: "status" });
123
+ },
124
+ async close() {
125
+ },
126
+ async get(key) {
127
+ const result = await invokeBrokerRequest(options, { type: "get", key });
128
+ if (result.type !== "get") {
129
+ throw new Error(`CLI authority broker protocol mismatch for get at ${options.endpoint}`);
130
+ }
131
+ return result.value;
132
+ },
133
+ async put(key, value) {
134
+ await invokeBrokerRequest(options, { type: "put", key, value });
135
+ },
136
+ async del(key) {
137
+ await invokeBrokerRequest(options, { type: "del", key });
138
+ },
139
+ async batchWrite(ops) {
140
+ await invokeBrokerRequest(options, { type: "batchWrite", ops });
141
+ },
142
+ createBatch() {
143
+ const ops = [];
144
+ return {
145
+ put(key, value) {
146
+ ops.push({ type: "put", key, value });
147
+ },
148
+ del(key) {
149
+ ops.push({ type: "del", key });
150
+ },
151
+ async write() {
152
+ await invokeBrokerRequest(options, { type: "batchWrite", ops });
153
+ }
154
+ };
155
+ },
156
+ iterator(iteratorOptions = {}) {
157
+ return async function* iterate() {
158
+ let cursor = void 0;
159
+ while (true) {
160
+ const result = await invokeBrokerRequest(options, {
161
+ type: "iterator",
162
+ options: iteratorOptions,
163
+ cursor,
164
+ limit: pageSize
165
+ });
166
+ if (result.type !== "iterator") {
167
+ throw new Error(
168
+ `CLI authority broker protocol mismatch for iterator at ${options.endpoint}`
169
+ );
170
+ }
171
+ for (const entry of result.page.entries) {
172
+ yield entry;
173
+ }
174
+ if (result.page.done || !result.page.nextCursor) return;
175
+ cursor = result.page.nextCursor;
176
+ }
177
+ }();
178
+ }
179
+ };
180
+ }
181
+
182
+ // packages/database-engine/cliAuthorityStoreDriver.ts
183
+ import path from "node:path";
184
+ function readCliAuthorityDriver(env) {
185
+ const value = env.NOLO_CLI_AUTHORITY_DRIVER?.trim();
186
+ if (value === "broker") {
187
+ return { driver: "broker", invalidDriver: null };
188
+ }
189
+ return {
190
+ driver: "broker",
191
+ invalidDriver: value ? value : null
192
+ };
193
+ }
194
+ function resolveCliAuthorityRunDir(options = {}) {
195
+ return path.join(resolveNoloHome({
196
+ ...options,
197
+ env: options.env ?? {}
198
+ }), "run");
199
+ }
200
+ function hashString(value) {
201
+ let hash = 0;
202
+ for (let index = 0; index < value.length; index += 1) {
203
+ hash = (hash << 5) - hash + value.charCodeAt(index) | 0;
204
+ }
205
+ return Math.abs(hash);
206
+ }
207
+ function resolveCliAuthorityBrokerPort(options = {}) {
208
+ const envPort = options.env?.NOLO_CLI_AUTHORITY_BROKER_PORT?.trim();
209
+ if (envPort) {
210
+ const port = Number(envPort);
211
+ if (Number.isInteger(port) && port > 0 && port < 65536) return port;
212
+ }
213
+ const noloHome = resolveNoloHome({
214
+ ...options,
215
+ env: options.env ?? {}
216
+ });
217
+ return 47e3 + hashString(noloHome) % 2e3;
218
+ }
219
+ function resolveCliAuthorityStoreDriver(options = {}) {
220
+ return readCliAuthorityDriver(options.env ?? {}).driver;
221
+ }
222
+ function resolveCliAuthorityBrokerSocketPath(options) {
223
+ return path.join(resolveCliAuthorityRunDir(options), "authority-store-broker.sock");
224
+ }
225
+ function resolveCliAuthorityBrokerEndpoint(options) {
226
+ if (options.transport === "tcp") {
227
+ return `tcp://127.0.0.1:${resolveCliAuthorityBrokerPort(options)}`;
228
+ }
229
+ return `unix://${resolveCliAuthorityBrokerSocketPath(options)}`;
230
+ }
231
+ function resolveCliAuthorityBrokerMetadataPath(options) {
232
+ return path.join(resolveCliAuthorityRunDir(options), "authority-store-broker.json");
233
+ }
234
+ function resolveCliAuthorityBrokerHealthPath(options) {
235
+ return path.join(resolveCliAuthorityRunDir(options), "authority-store-broker.health.json");
236
+ }
237
+
238
+ export {
239
+ isCliAuthorityBrokerUnavailableError,
240
+ createCliAuthorityBrokerSocketInvoker,
241
+ createCliAuthorityBrokerClient,
242
+ resolveCliAuthorityStoreDriver,
243
+ resolveCliAuthorityBrokerEndpoint,
244
+ resolveCliAuthorityBrokerMetadataPath,
245
+ resolveCliAuthorityBrokerHealthPath
246
+ };
@@ -0,0 +1,8 @@
1
+ // packages/core/optionalPositiveNumber.ts
2
+ function asOptionalPositiveFiniteNumber(value) {
3
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
4
+ }
5
+
6
+ export {
7
+ asOptionalPositiveFiniteNumber
8
+ };
@@ -0,0 +1,64 @@
1
+ // packages/create/space/spaceKeys.ts
2
+ var SEPARATOR = "-";
3
+ var SPACE_PREFIX = "space";
4
+ var SPACE_PREFIX_WITH_SEPARATOR = `${SPACE_PREFIX}${SEPARATOR}`;
5
+ var normalizeSpaceId = (spaceId) => {
6
+ if (!spaceId) return spaceId;
7
+ return spaceId.startsWith(SPACE_PREFIX_WITH_SEPARATOR) ? spaceId.slice(SPACE_PREFIX_WITH_SEPARATOR.length) : spaceId;
8
+ };
9
+ var createSpaceKey = {
10
+ // 空间基础信息的key
11
+ space: (spaceId) => {
12
+ return [SPACE_PREFIX, normalizeSpaceId(spaceId)].join(SEPARATOR);
13
+ },
14
+ // 空间成员的key
15
+ member: (userId, spaceId) => {
16
+ return [SPACE_PREFIX, "member", userId, normalizeSpaceId(spaceId)].join(
17
+ SEPARATOR
18
+ );
19
+ },
20
+ // 查询用户所在的所有空间的范围
21
+ memberRange: (userId) => {
22
+ return {
23
+ start: [SPACE_PREFIX, "member", userId, ""].join(SEPARATOR),
24
+ end: [SPACE_PREFIX, "member", userId, "\uFFFF"].join(SEPARATOR)
25
+ };
26
+ },
27
+ /**
28
+ * 预留:未来若出现“按用户、按空间、且必须跨设备同步”的空间级偏好,
29
+ * 统一使用这个 key family。当前产品主链不要依赖它。
30
+ */
31
+ setting: (userId, spaceId) => {
32
+ return [SPACE_PREFIX, "setting", userId, normalizeSpaceId(spaceId)].join(
33
+ SEPARATOR
34
+ );
35
+ },
36
+ /**
37
+ * 预留:未来如确实需要批量读取空间级远端偏好,再使用这个范围。
38
+ */
39
+ settingRange: (userId) => {
40
+ return {
41
+ start: [SPACE_PREFIX, "setting", userId, ""].join(SEPARATOR),
42
+ end: [SPACE_PREFIX, "setting", userId, "\uFFFF"].join(SEPARATOR)
43
+ };
44
+ },
45
+ // 从成员key中提取空间key
46
+ // 成员 key 格式: space-member-{userId}-{spaceId}
47
+ // userId 是单段(无连字符),spaceId 是 ULID(无连字符)
48
+ spaceFromMember: (memberKey) => {
49
+ const parts = memberKey.split(SEPARATOR);
50
+ if (parts.length < 4) return "";
51
+ const spaceId = parts[parts.length - 1];
52
+ return [SPACE_PREFIX, spaceId].join(SEPARATOR);
53
+ },
54
+ // 从成员key中提取空间ID
55
+ spaceIdFromMember: (memberKey) => {
56
+ const parts = memberKey.split(SEPARATOR);
57
+ return parts.length >= 4 ? parts[parts.length - 1] : "";
58
+ }
59
+ };
60
+
61
+ export {
62
+ normalizeSpaceId,
63
+ createSpaceKey
64
+ };
@@ -0,0 +1,191 @@
1
+ import {
2
+ listUserRecordsFromServers,
3
+ readLiveDbRecordAfterTombstoneMerge
4
+ } from "./chunk-GEKCOPTN.js";
5
+ import {
6
+ agentRecordHasConfiguredCredential
7
+ } from "./chunk-6PWWWMI7.js";
8
+
9
+ // packages/cli/agentListHelpers.ts
10
+ function parseAgentRecordId(privateKey, explicitId) {
11
+ if (explicitId) return explicitId;
12
+ const agentMatch = privateKey.match(/^agent-[^-]+-(.+)$/i);
13
+ return agentMatch?.[1] ?? "";
14
+ }
15
+ function buildCompanionKeys(rawId, userId) {
16
+ return {
17
+ privateKey: `agent-${userId}-${rawId}`,
18
+ publicKey: `agent-pub-${rawId}`
19
+ };
20
+ }
21
+ function normalizeListedAgent(record) {
22
+ const privateKey = typeof record?.dbKey === "string" ? record.dbKey : "";
23
+ const explicitId = typeof record?.id === "string" && record.id ? record.id : void 0;
24
+ const ownerUserId = typeof record?.userId === "string" ? record.userId : "";
25
+ const rawId = explicitId || (ownerUserId && privateKey.startsWith(`agent-${ownerUserId}-`) ? privateKey.slice(`agent-${ownerUserId}-`.length) : parseAgentRecordId(privateKey, explicitId));
26
+ if (!privateKey || !rawId || !ownerUserId) return null;
27
+ const keys = buildCompanionKeys(rawId, ownerUserId);
28
+ const credentialConfigured = agentRecordHasConfiguredCredential(record);
29
+ const credentialRef = typeof record?.credentialRef === "string" && record.credentialRef ? record.credentialRef : void 0;
30
+ const apiKeyRef = typeof record?.apiKeyRef === "string" && record.apiKeyRef ? record.apiKeyRef : void 0;
31
+ return {
32
+ id: rawId,
33
+ privateKey,
34
+ publicKey: keys.publicKey,
35
+ name: typeof record?.name === "string" && record.name ? record.name : "(unnamed)",
36
+ model: typeof record?.model === "string" && record.model ? record.model : "-",
37
+ updatedAt: typeof record?.updatedAt === "string" || typeof record?.updatedAt === "number" ? record.updatedAt : typeof record?.createdAt === "string" || typeof record?.createdAt === "number" ? record.createdAt : typeof record?.created === "string" || typeof record?.created === "number" ? record.created : null,
38
+ isPublicFlag: !!record?.isPublic,
39
+ publicRecordExists: false,
40
+ type: typeof record?.type === "string" ? record.type : null,
41
+ tools: Array.isArray(record?.tools) ? record.tools.filter((tool) => typeof tool === "string") : [],
42
+ credentialConfigured,
43
+ credentialRef,
44
+ apiKeyRef,
45
+ ...typeof record?.apiSource === "string" && record.apiSource ? { apiSource: record.apiSource } : {},
46
+ ...typeof record?.cliProvider === "string" && record.cliProvider ? { cliProvider: record.cliProvider } : {}
47
+ };
48
+ }
49
+ function sortListedAgents(agents) {
50
+ agents.sort((a, b) => {
51
+ const ta = a.updatedAt == null ? 0 : new Date(a.updatedAt).getTime();
52
+ const tb = b.updatedAt == null ? 0 : new Date(b.updatedAt).getTime();
53
+ return tb - ta;
54
+ });
55
+ return agents;
56
+ }
57
+ function parseAgentListArgs(args) {
58
+ return {
59
+ wantJson: args.includes("--json"),
60
+ publicOnly: args.includes("--public-only"),
61
+ idsOnly: args.includes("--ids-only")
62
+ };
63
+ }
64
+ async function listLocalCachedAgents(args) {
65
+ const privateRecords = /* @__PURE__ */ new Map();
66
+ const publicKeys = /* @__PURE__ */ new Set();
67
+ for await (const [key, value] of args.db.iterator({ gte: "", lte: "\uFFFF" })) {
68
+ if (typeof key !== "string" || !value || typeof value !== "object") continue;
69
+ if (key.startsWith(`agent-${args.userId}-`)) {
70
+ privateRecords.set(key, { ...value, dbKey: key });
71
+ continue;
72
+ }
73
+ if (key.startsWith("agent-pub-")) {
74
+ publicKeys.add(key);
75
+ }
76
+ }
77
+ const agents = sortListedAgents(
78
+ [...privateRecords.values()].map((record) => normalizeListedAgent(record)).filter((agent) => agent != null)
79
+ );
80
+ for (const agent of agents) {
81
+ agent.publicRecordExists = publicKeys.has(agent.publicKey);
82
+ }
83
+ return agents;
84
+ }
85
+ async function hasReadableRecord(args) {
86
+ try {
87
+ await args.readDbRecord(args);
88
+ return true;
89
+ } catch {
90
+ return false;
91
+ }
92
+ }
93
+ async function listRemoteAgents(args) {
94
+ const recordGroups = [await args.queryUserRecords({ ...args, type: "agent" })];
95
+ const agents = sortListedAgents(
96
+ recordGroups.flat().map((record) => normalizeListedAgent(record)).filter((agent) => agent != null)
97
+ );
98
+ await Promise.all(
99
+ agents.map(async (agent) => {
100
+ agent.publicRecordExists = await hasReadableRecord({
101
+ authToken: args.authToken,
102
+ dbKey: agent.publicKey,
103
+ fallbackFetchImpl: args.fallbackFetchImpl,
104
+ fetchImpl: args.fetchImpl,
105
+ serverUrl: args.serverUrl,
106
+ readDbRecord: args.readDbRecord
107
+ });
108
+ })
109
+ );
110
+ return agents;
111
+ }
112
+ async function listRemoteAgentsAcrossServers(args) {
113
+ const remoteResult = await listUserRecordsFromServers({
114
+ authToken: args.authToken,
115
+ fallbackFetchImpl: args.fallbackFetchImpl,
116
+ fetchImpl: args.fetchImpl,
117
+ label: "agent query",
118
+ serverUrls: args.serverUrls,
119
+ type: "agent",
120
+ userId: args.userId
121
+ });
122
+ const agents = sortListedAgents(
123
+ remoteResult.records.map((record) => normalizeListedAgent(record)).filter((agent) => agent != null)
124
+ );
125
+ return { agents, failures: remoteResult.failures };
126
+ }
127
+ async function listFavoriteAgentIdsAcrossServers(args) {
128
+ const favoritedAtByKey = {};
129
+ await Promise.all(
130
+ args.serverUrls.map(async (serverUrl) => {
131
+ try {
132
+ const res = await args.fetchImpl(`${serverUrl}/rpc/listFavorites`, {
133
+ method: "POST",
134
+ headers: {
135
+ "Content-Type": "application/json",
136
+ Authorization: `Bearer ${args.authToken}`
137
+ },
138
+ body: JSON.stringify({ targetType: "agent" })
139
+ });
140
+ if (!res.ok) return;
141
+ const data = await res.json().catch(() => ({}));
142
+ const items = Array.isArray(data?.items) ? data.items : [];
143
+ for (const item of items) {
144
+ const id = typeof item?.id === "string" ? item.id : "";
145
+ if (!id) continue;
146
+ const at = Number(item?.favoritedAt) || 0;
147
+ favoritedAtByKey[id] = Math.max(
148
+ favoritedAtByKey[id] ?? 0,
149
+ at || Date.now()
150
+ );
151
+ }
152
+ const ids = Array.isArray(data?.ids) ? data.ids : [];
153
+ for (const id of ids) {
154
+ if (typeof id === "string" && id && !(id in favoritedAtByKey)) {
155
+ favoritedAtByKey[id] = 1;
156
+ }
157
+ }
158
+ } catch {
159
+ }
160
+ })
161
+ );
162
+ return favoritedAtByKey;
163
+ }
164
+ async function decorateAgentsWithPublicStatusAcrossServers(args) {
165
+ await Promise.all(
166
+ args.agents.map(async (agent) => {
167
+ try {
168
+ const result = await readLiveDbRecordAfterTombstoneMerge({
169
+ authToken: args.authToken,
170
+ dbKey: agent.publicKey,
171
+ fallbackFetchImpl: args.fallbackFetchImpl,
172
+ fetchImpl: args.fetchImpl,
173
+ serverUrls: args.serverUrls
174
+ });
175
+ agent.publicRecordExists = result.record?.isPublic === true;
176
+ } catch {
177
+ agent.publicRecordExists = false;
178
+ }
179
+ })
180
+ );
181
+ return args.agents;
182
+ }
183
+
184
+ export {
185
+ parseAgentListArgs,
186
+ listLocalCachedAgents,
187
+ listRemoteAgents,
188
+ listRemoteAgentsAcrossServers,
189
+ listFavoriteAgentIdsAcrossServers,
190
+ decorateAgentsWithPublicStatusAcrossServers
191
+ };
@@ -0,0 +1,105 @@
1
+ import {
2
+ OLLAMA_CLOUD_KIMI_K26_MODEL,
3
+ OLLAMA_CLOUD_KIMI_K27_CODE_MODEL,
4
+ OLLAMA_CLOUD_KIMI_K3_MODEL,
5
+ cloudflareModels,
6
+ deepSeekModels,
7
+ deepinfraModels,
8
+ fireworksModels,
9
+ gmiModels,
10
+ googleModels,
11
+ openAIModels,
12
+ openrouterModels,
13
+ xaiModels,
14
+ zaiModels
15
+ } from "./chunk-BR2WP3DF.js";
16
+
17
+ // packages/ai/llm/ollamaCloud.ts
18
+ var OLLAMA_CLOUD_KIMI_PRICE = {
19
+ input: 0.27,
20
+ output: 5.7
21
+ };
22
+ var OLLAMA_CLOUD_GLM_PRICE = {
23
+ input: 1.14,
24
+ output: 7.1
25
+ };
26
+ var OLLAMA_CLOUD_GLM_52_MODEL = "glm-5.2";
27
+ var OLLAMA_CLOUD_DEEPSEEK_FLASH_MODEL = "deepseek-v4-flash";
28
+ var OLLAMA_CLOUD_DEEPSEEK_FLASH_PRICE = {
29
+ input: 0.11,
30
+ output: 0.63
31
+ };
32
+ var OLLAMA_CLOUD_KIMI_K3_PRICE = {
33
+ input: 2.4,
34
+ output: 12
35
+ };
36
+ var ollamaCloudModels = [
37
+ {
38
+ name: OLLAMA_CLOUD_KIMI_K3_MODEL,
39
+ displayName: "Kimi K3",
40
+ hasVision: true,
41
+ price: { ...OLLAMA_CLOUD_KIMI_K3_PRICE },
42
+ maxOutputTokens: 262144,
43
+ contextWindow: 1e6,
44
+ supportsTool: true,
45
+ supportsReasoningEffort: true
46
+ },
47
+ {
48
+ name: OLLAMA_CLOUD_KIMI_K26_MODEL,
49
+ displayName: "Kimi K2.6",
50
+ hasVision: true,
51
+ price: { ...OLLAMA_CLOUD_KIMI_PRICE },
52
+ maxOutputTokens: 262144,
53
+ contextWindow: 262144,
54
+ supportsTool: true
55
+ },
56
+ {
57
+ name: OLLAMA_CLOUD_KIMI_K27_CODE_MODEL,
58
+ displayName: "Kimi K2.7 Coding",
59
+ hasVision: true,
60
+ price: { ...OLLAMA_CLOUD_KIMI_PRICE },
61
+ maxOutputTokens: 262144,
62
+ contextWindow: 256e3,
63
+ supportsTool: true
64
+ },
65
+ {
66
+ name: OLLAMA_CLOUD_GLM_52_MODEL,
67
+ displayName: "GLM 5.2",
68
+ hasVision: false,
69
+ price: { ...OLLAMA_CLOUD_GLM_PRICE },
70
+ maxOutputTokens: 131072,
71
+ contextWindow: 1e6,
72
+ supportsTool: true,
73
+ supportsReasoningEffort: true
74
+ },
75
+ {
76
+ name: OLLAMA_CLOUD_DEEPSEEK_FLASH_MODEL,
77
+ displayName: "DeepSeek V4 Flash",
78
+ hasVision: false,
79
+ price: { ...OLLAMA_CLOUD_DEEPSEEK_FLASH_PRICE },
80
+ maxOutputTokens: 384e3,
81
+ contextWindow: 1e6,
82
+ supportsTool: true,
83
+ supportsReasoningEffort: true
84
+ }
85
+ ];
86
+
87
+ // packages/ai/llm/models.ts
88
+ var withProvider = (provider) => (models) => models.map((model) => ({ ...model, provider }));
89
+ var ALL_MODELS = [
90
+ ...withProvider("nolo")(ollamaCloudModels),
91
+ ...withProvider("google")(googleModels),
92
+ ...withProvider("openai")(openAIModels),
93
+ ...withProvider("openrouter")(openrouterModels),
94
+ ...withProvider("xai")(xaiModels),
95
+ ...withProvider("deepseek")(deepSeekModels),
96
+ ...withProvider("deepinfra")(deepinfraModels),
97
+ ...withProvider("fireworks")(fireworksModels),
98
+ ...withProvider("cloudflare")(cloudflareModels),
99
+ ...withProvider("gmi")(gmiModels),
100
+ ...withProvider("zai")(zaiModels)
101
+ ];
102
+
103
+ export {
104
+ ALL_MODELS
105
+ };