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

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-WRUCQIV5.js +205 -0
  3. package/action-R4M4ORGA.js +28 -0
  4. package/addContentAction-UYFFTEWJ.js +26 -0
  5. package/addDialogAgentAction-OT4XZAVP.js +68 -0
  6. package/agentDeleteCommand-5DD2IM3J.js +327 -0
  7. package/agentEmailCommands-IASM2YBQ.js +628 -0
  8. package/agentListCommands-I6KZYCIG.js +223 -0
  9. package/agentMachineCommands-OUP3YQP7.js +425 -0
  10. package/agentPullCommand-O2MTUAFR.js +122 -0
  11. package/agentRecordCommands-QKGE2JTA.js +96 -0
  12. package/agentRunCommand-TVZXUBQ5.js +114 -0
  13. package/agentRunControl-K4VKNEHF.js +57 -0
  14. package/agentRuntimeLocal-ZYEIPTY4.js +104 -0
  15. package/agentSlice-T4PMW7W6.js +42 -0
  16. package/authCommand-EB5JSOX5.js +581 -0
  17. package/authCommands-XPEHTKSM.js +35 -0
  18. package/chunk-2EHX7F5G.js +1948 -0
  19. package/chunk-2FTTDCD4.js +675 -0
  20. package/chunk-3ASDTTEI.js +1774 -0
  21. package/chunk-3EUW3WEO.js +8 -0
  22. package/chunk-3LY4F7SV.js +9293 -0
  23. package/chunk-4CQLVGRV.js +50 -0
  24. package/chunk-4FBRSEV4.js +573 -0
  25. package/chunk-4IJYA27C.js +342 -0
  26. package/chunk-4QEWT7KD.js +933 -0
  27. package/chunk-4SN6J65J.js +38 -0
  28. package/chunk-4VNS5WPM.js +42 -0
  29. package/chunk-4ZDM73SD.js +34 -0
  30. package/chunk-5CS33IBL.js +301 -0
  31. package/chunk-5KLGBAAR.js +386 -0
  32. package/chunk-5MIDPSSK.js +206 -0
  33. package/chunk-5MMAK75Q.js +15 -0
  34. package/chunk-5W3VUFOX.js +34 -0
  35. package/chunk-63W5N6P3.js +150 -0
  36. package/chunk-6HYVJV7B.js +102 -0
  37. package/chunk-6WD3OOJS.js +20 -0
  38. package/chunk-7DAJ4AI4.js +191 -0
  39. package/chunk-7KCUSYT2.js +354 -0
  40. package/chunk-7T5PWAZN.js +171 -0
  41. package/chunk-AFON4QUU.js +112 -0
  42. package/chunk-AGFH73SK.js +239 -0
  43. package/chunk-ATNTHIZI.js +13 -0
  44. package/chunk-AVMKZHBC.js +85 -0
  45. package/chunk-AZPCASRE.js +36 -0
  46. package/chunk-BBYVOSU2.js +792 -0
  47. package/chunk-BCIOM4NZ.js +1078 -0
  48. package/chunk-C3RUNRHT.js +51 -0
  49. package/chunk-C4FTUXVF.js +146 -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-CMKUBIGW.js +1550 -0
  54. package/chunk-CWMSB67P.js +34 -0
  55. package/chunk-DCOA4QSN.js +105 -0
  56. package/chunk-DFFIZ25G.js +30 -0
  57. package/chunk-DWLEOOGR.js +8 -0
  58. package/chunk-DZ3XJVET.js +231 -0
  59. package/chunk-EHLHSX7R.js +1433 -0
  60. package/chunk-FM5IVZXO.js +4723 -0
  61. package/chunk-FVYY6MCS.js +1447 -0
  62. package/chunk-G3SUCT4W.js +8 -0
  63. package/chunk-GAKEBQD6.js +30 -0
  64. package/chunk-GBRG75BQ.js +86 -0
  65. package/chunk-GLYVN7EQ.js +238 -0
  66. package/chunk-H33743XH.js +25 -0
  67. package/chunk-HNMXYYJR.js +12 -0
  68. package/chunk-HNW7IJSK.js +71 -0
  69. package/chunk-I42VC5KR.js +15 -0
  70. package/chunk-IDZTNRP2.js +85 -0
  71. package/chunk-IHBCLYEE.js +22310 -0
  72. package/chunk-IJGXKGXW.js +421 -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-K6BPOQLF.js +2052 -0
  80. package/chunk-K777STIO.js +478 -0
  81. package/chunk-KKY4B2Q2.js +21 -0
  82. package/chunk-KQHGZWSV.js +63 -0
  83. package/chunk-KUG52IAP.js +8 -0
  84. package/chunk-KX6YBIHG.js +8 -0
  85. package/chunk-LCBAMY2M.js +60 -0
  86. package/chunk-LM6IYQ3F.js +16 -0
  87. package/chunk-LTRXGFMS.js +83 -0
  88. package/chunk-M76ECQRD.js +13658 -0
  89. package/chunk-MNJDFJND.js +222 -0
  90. package/chunk-MRC4Q34M.js +188 -0
  91. package/chunk-MTU75CZ2.js +91 -0
  92. package/chunk-N54XAP77.js +19 -0
  93. package/chunk-O2ZNTTET.js +3272 -0
  94. package/chunk-O4BU24WZ.js +3212 -0
  95. package/chunk-OLZBQWZU.js +6 -0
  96. package/chunk-OPZYGHUC.js +89 -0
  97. package/chunk-OWOHNGCN.js +50 -0
  98. package/chunk-P3PKED2I.js +962 -0
  99. package/chunk-PFTAG6DY.js +1939 -0
  100. package/chunk-PMKQGGGM.js +221 -0
  101. package/chunk-PP4S6RTL.js +175 -0
  102. package/chunk-QJ7FZNYN.js +939 -0
  103. package/chunk-QSJ3HFEF.js +8 -0
  104. package/chunk-RGIM3WLT.js +113 -0
  105. package/chunk-RL776AGR.js +190 -0
  106. package/chunk-ROWQEJRP.js +139 -0
  107. package/chunk-S7Z2HMCN.js +25 -0
  108. package/chunk-SDJDLO5W.js +628 -0
  109. package/chunk-SOTZ6RDN.js +69 -0
  110. package/chunk-TILFE6LV.js +381 -0
  111. package/chunk-TIMLUWQA.js +231 -0
  112. package/chunk-TISCADJH.js +807 -0
  113. package/chunk-U4TRT5V4.js +246 -0
  114. package/chunk-U6VC4MU4.js +8 -0
  115. package/chunk-UAD2WT54.js +64 -0
  116. package/chunk-VC6OZXO5.js +298 -0
  117. package/chunk-VF4K2QE6.js +21 -0
  118. package/chunk-VHBWHNVT.js +59 -0
  119. package/chunk-VIDPVFP3.js +20 -0
  120. package/chunk-VP4WJWKW.js +8882 -0
  121. package/chunk-VVX233PH.js +482 -0
  122. package/chunk-W4NVOSFF.js +37 -0
  123. package/chunk-WI4XWASA.js +208 -0
  124. package/chunk-WWC7I6TA.js +8 -0
  125. package/chunk-WZSRQNQG.js +2587 -0
  126. package/chunk-XBROXIGL.js +3066 -0
  127. package/chunk-XENYHRUE.js +104 -0
  128. package/chunk-Y5GCAMGP.js +9 -0
  129. package/chunk-YN4XDB7B.js +9036 -0
  130. package/chunk-YPRZSPF3.js +148 -0
  131. package/chunk-Z4NR32XR.js +50 -0
  132. package/chunk-Z6EKEXJW.js +138 -0
  133. package/chunk-ZDRZMLKO.js +27339 -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-CCABEOM6.js +866 -0
  138. package/createDialogAction-YPKF5ITI.js +55 -0
  139. package/createPageAction-YEZ7EK5F.js +172 -0
  140. package/db-HCJ5PRB5.js +271 -0
  141. package/dbSlice-QPVZHBOE.js +60 -0
  142. package/deleteFile-SV5MS23W.js +41 -0
  143. package/dialogCommands-4IX4XIZE.js +63 -0
  144. package/dialogSlice-OVTO7QGW.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-ZAYLW2HN.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-TZMZ4EP5.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-M4ZJZIMS.js +781 -0
  160. package/machineInfo-M6KB6HZN.js +10 -0
  161. package/machineWsRunDispatch-TPJAUGLP.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 -23
  166. package/read-EBMWX4Z6.js +17 -0
  167. package/readDocTool-2MWHSTQE.js +16 -0
  168. package/readlineWorkspace-OMCIU3WT.js +5682 -0
  169. package/removeDialogAgentAction-SNZ662NP.js +73 -0
  170. package/runAgentClientLoop-H6NGOUAM.js +293 -0
  171. package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
  172. package/setDialogExtraReferencesAction-XDI2KM2N.js +60 -0
  173. package/setPrimaryDialogAgentAction-PYEC4N4Z.js +80 -0
  174. package/settingSlice-NOWHY2FK.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-QHBPICA2.js +149 -0
  181. package/streamAgentChatTurn-3XTBA2HN.js +4510 -0
  182. package/tableCommands-R5UCM63M.js +1286 -0
  183. package/toolApiClient-QI3YBNWB.js +26 -0
  184. package/tools-GHLZ3XD6.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-XA2OZTLP.js +188 -0
@@ -0,0 +1,8 @@
1
+ // packages/core/optionalString.ts
2
+ function asOptionalTrimmedString(value) {
3
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
4
+ }
5
+
6
+ export {
7
+ asOptionalTrimmedString
8
+ };
@@ -0,0 +1,30 @@
1
+ // packages/core/retryAfterMs.ts
2
+ function normalizeNonNegativeMs(value, fallbackMs) {
3
+ const parsed = Number(value);
4
+ return Number.isFinite(parsed) && parsed >= 0 ? Math.round(parsed) : Math.round(Number(fallbackMs)) || 0;
5
+ }
6
+ function parseRetryAfterHeaderMs(value, nowMs = Date.now()) {
7
+ if (typeof value !== "string" || !value.trim()) return null;
8
+ const trimmed = value.trim();
9
+ const seconds = Number(trimmed);
10
+ if (Number.isFinite(seconds)) {
11
+ if (seconds < 0) return null;
12
+ return Math.round(seconds * 1e3);
13
+ }
14
+ const parsedDateMs = Date.parse(trimmed);
15
+ if (Number.isFinite(parsedDateMs)) {
16
+ return Math.max(0, parsedDateMs - nowMs);
17
+ }
18
+ return null;
19
+ }
20
+
21
+ // packages/core/gatewayHttpStatus.ts
22
+ function isGatewayHttpStatus(status) {
23
+ return status === 502 || status === 503 || status === 504;
24
+ }
25
+
26
+ export {
27
+ normalizeNonNegativeMs,
28
+ parseRetryAfterHeaderMs,
29
+ isGatewayHttpStatus
30
+ };
@@ -0,0 +1,86 @@
1
+ import {
2
+ asOptionalPositiveFiniteNumber
3
+ } from "./chunk-U6VC4MU4.js";
4
+
5
+ // packages/database/tombstones.ts
6
+ var TOMBSTONE_DETAIL_RETENTION_MS = 90 * 24 * 60 * 60 * 1e3;
7
+ var isRecord = (value) => value !== null && typeof value === "object";
8
+ var readRecord = (value) => isRecord(value) ? value : null;
9
+ var parseTimestamp = (value) => {
10
+ const asNumber = asOptionalPositiveFiniteNumber(value);
11
+ if (asNumber !== void 0) return asNumber;
12
+ if (typeof value === "string" && value.trim()) {
13
+ return asOptionalPositiveFiniteNumber(Date.parse(value)) ?? 0;
14
+ }
15
+ return 0;
16
+ };
17
+ var getRecordTimestamp = (record) => {
18
+ const value = readRecord(record);
19
+ if (!value) return 0;
20
+ const candidates = [
21
+ value.updatedAt,
22
+ value.updated_at,
23
+ value.createdAt,
24
+ value.created,
25
+ isRecord(value.meta) ? value.meta.createdAt : void 0
26
+ ];
27
+ for (const candidate of candidates) {
28
+ const timestamp = parseTimestamp(candidate);
29
+ if (timestamp > 0) return timestamp;
30
+ }
31
+ return 0;
32
+ };
33
+ var getTombstoneTimestamp = (record) => {
34
+ const value = readRecord(record);
35
+ if (!value) return 0;
36
+ return parseTimestamp(value.deletedAt) || getRecordTimestamp(value);
37
+ };
38
+ var getRestoreTimestamp = (record) => {
39
+ const value = readRecord(record);
40
+ if (!value) return 0;
41
+ return parseTimestamp(value.restoredAt);
42
+ };
43
+ var isTombstoneRecord = (record) => {
44
+ const value = readRecord(record);
45
+ if (!value) return false;
46
+ const deletedAt = value.deletedAt;
47
+ if (typeof deletedAt === "string") return deletedAt.trim().length > 0;
48
+ return Boolean(deletedAt);
49
+ };
50
+ var isRestoredAfterTombstone = (activeRecord, tombstoneRecord) => {
51
+ if (isTombstoneRecord(activeRecord) || !isTombstoneRecord(tombstoneRecord)) {
52
+ return false;
53
+ }
54
+ const restoreTs = getRestoreTimestamp(activeRecord);
55
+ const tombstoneTs = getTombstoneTimestamp(tombstoneRecord);
56
+ return restoreTs > 0 && tombstoneTs > 0 && restoreTs > tombstoneTs;
57
+ };
58
+ var shouldReplaceWithNextRecord = (nextRecord, currentRecord) => {
59
+ const nextIsTombstone = isTombstoneRecord(nextRecord);
60
+ const currentIsTombstone = isTombstoneRecord(currentRecord);
61
+ if (currentIsTombstone && !nextIsTombstone) {
62
+ return isRestoredAfterTombstone(nextRecord, currentRecord);
63
+ }
64
+ if (nextIsTombstone && !currentIsTombstone) {
65
+ return !isRestoredAfterTombstone(currentRecord, nextRecord);
66
+ }
67
+ const nextTs = nextIsTombstone ? getTombstoneTimestamp(nextRecord) : getRecordTimestamp(nextRecord);
68
+ const currentTs = currentIsTombstone ? getTombstoneTimestamp(currentRecord) : getRecordTimestamp(currentRecord);
69
+ if (nextTs !== currentTs) return nextTs > currentTs;
70
+ return nextIsTombstone && !currentIsTombstone;
71
+ };
72
+ var buildTombstoneRecord = (record, nowIso) => {
73
+ const { restoredAt: _restoredAt, ...baseRecord } = record;
74
+ return {
75
+ ...baseRecord,
76
+ deletedAt: nowIso,
77
+ updatedAt: nowIso
78
+ };
79
+ };
80
+
81
+ export {
82
+ getRecordTimestamp,
83
+ isTombstoneRecord,
84
+ shouldReplaceWithNextRecord,
85
+ buildTombstoneRecord
86
+ };
@@ -0,0 +1,238 @@
1
+ import {
2
+ getRuntimeServerContext,
3
+ scheduleDeleteReplication
4
+ } from "./chunk-XBROXIGL.js";
5
+ import {
6
+ fetchFromClientDb
7
+ } from "./chunk-WI4XWASA.js";
8
+ import {
9
+ buildTombstoneRecord
10
+ } from "./chunk-GBRG75BQ.js";
11
+
12
+ // packages/database/fileStorage.ts
13
+ var DB_NAME = "nolo-file-storage";
14
+ var STORE_NAME = "files";
15
+ var DB_VERSION = 1;
16
+ var dbPromise = null;
17
+ var openFileDb = () => {
18
+ if (dbPromise) return dbPromise;
19
+ if (typeof indexedDB === "undefined") {
20
+ console.warn(
21
+ "[fileStorage] indexedDB is not available in this environment. File caching is disabled."
22
+ );
23
+ dbPromise = Promise.reject(
24
+ new Error("indexedDB is not available in this environment")
25
+ );
26
+ return dbPromise;
27
+ }
28
+ dbPromise = new Promise((resolve, reject) => {
29
+ const request = indexedDB.open(DB_NAME, DB_VERSION);
30
+ request.onerror = () => {
31
+ console.error("[fileStorage] Failed to open IndexedDB:", request.error);
32
+ reject(request.error);
33
+ };
34
+ request.onupgradeneeded = () => {
35
+ const db = request.result;
36
+ if (!db.objectStoreNames.contains(STORE_NAME)) {
37
+ const store = db.createObjectStore(STORE_NAME, {
38
+ keyPath: "id"
39
+ });
40
+ store.createIndex("createdAt", "createdAt", { unique: false });
41
+ }
42
+ };
43
+ request.onsuccess = () => {
44
+ const db = request.result;
45
+ db.onversionchange = () => {
46
+ db.close();
47
+ console.warn(
48
+ "[fileStorage] IndexedDB version change detected, closing old connection."
49
+ );
50
+ };
51
+ resolve(db);
52
+ };
53
+ });
54
+ return dbPromise;
55
+ };
56
+ var saveFileToIndexedDb = async (fileId, file) => {
57
+ try {
58
+ const db = await openFileDb();
59
+ const tx = db.transaction(STORE_NAME, "readwrite");
60
+ const store = tx.objectStore(STORE_NAME);
61
+ const blob = file instanceof Blob ? file : new Blob([file]);
62
+ const record = {
63
+ id: fileId,
64
+ blob,
65
+ size: blob.size,
66
+ type: blob.type || "application/octet-stream",
67
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
68
+ };
69
+ const request = store.put(record);
70
+ await new Promise((resolve, reject) => {
71
+ request.onsuccess = () => {
72
+ console.debug(
73
+ "[fileStorage] Saved file to IndexedDB:",
74
+ fileId,
75
+ "size=",
76
+ record.size,
77
+ "type=",
78
+ record.type
79
+ );
80
+ resolve();
81
+ };
82
+ request.onerror = () => {
83
+ console.error(
84
+ "[fileStorage] Failed to save file to IndexedDB:",
85
+ fileId,
86
+ request.error
87
+ );
88
+ reject(request.error);
89
+ };
90
+ });
91
+ await new Promise((resolve, reject) => {
92
+ tx.oncomplete = () => resolve();
93
+ tx.onerror = () => reject(tx.error);
94
+ tx.onabort = () => reject(tx.error);
95
+ });
96
+ } catch (err) {
97
+ console.warn(
98
+ "[fileStorage] saveFileToIndexedDb error (non-fatal, caching disabled for this file):",
99
+ err
100
+ );
101
+ }
102
+ };
103
+ var loadFileFromIndexedDb = async (fileId) => {
104
+ try {
105
+ const db = await openFileDb();
106
+ const tx = db.transaction(STORE_NAME, "readonly");
107
+ const store = tx.objectStore(STORE_NAME);
108
+ const request = store.get(fileId);
109
+ const record = await new Promise(
110
+ (resolve, reject) => {
111
+ request.onsuccess = () => {
112
+ const result = request.result;
113
+ if (result) {
114
+ console.debug(
115
+ "[fileStorage] Loaded file from IndexedDB:",
116
+ fileId,
117
+ "size=",
118
+ result.size,
119
+ "type=",
120
+ result.type
121
+ );
122
+ } else {
123
+ console.debug(
124
+ "[fileStorage] No local file found in IndexedDB for id:",
125
+ fileId
126
+ );
127
+ }
128
+ resolve(result ?? null);
129
+ };
130
+ request.onerror = () => {
131
+ console.error(
132
+ "[fileStorage] Failed to load file from IndexedDB:",
133
+ fileId,
134
+ request.error
135
+ );
136
+ reject(request.error);
137
+ };
138
+ }
139
+ );
140
+ return record ?? null;
141
+ } catch (err) {
142
+ console.warn(
143
+ "[fileStorage] loadFileFromIndexedDb error, treat as cache miss:",
144
+ err
145
+ );
146
+ return null;
147
+ }
148
+ };
149
+ var deleteFileFromIndexedDb = async (fileId) => {
150
+ try {
151
+ const db = await openFileDb();
152
+ const tx = db.transaction(STORE_NAME, "readwrite");
153
+ const store = tx.objectStore(STORE_NAME);
154
+ const request = store.delete(fileId);
155
+ await new Promise((resolve, reject) => {
156
+ request.onsuccess = () => {
157
+ console.debug("[fileStorage] Deleted file from IndexedDB:", fileId);
158
+ resolve();
159
+ };
160
+ request.onerror = () => {
161
+ console.error(
162
+ "[fileStorage] Failed to delete file from IndexedDB:",
163
+ fileId,
164
+ request.error
165
+ );
166
+ reject(request.error);
167
+ };
168
+ });
169
+ await new Promise((resolve, reject) => {
170
+ tx.oncomplete = () => resolve();
171
+ tx.onerror = () => reject(tx.error);
172
+ tx.onabort = () => reject(tx.error);
173
+ });
174
+ } catch (err) {
175
+ console.warn("[fileStorage] deleteFileFromIndexedDb error:", err);
176
+ }
177
+ };
178
+
179
+ // packages/database/actions/remove.ts
180
+ var removeAction = async (payload, thunkApi) => {
181
+ const { db: clientDb } = thunkApi.extra;
182
+ const dbKey = typeof payload === "string" ? payload : payload.dbKey;
183
+ const preferredServerOrigin = typeof payload === "string" ? void 0 : payload.preferredServerOrigin;
184
+ if (!clientDb) {
185
+ throw new Error("Client database is undefined in removeAction");
186
+ }
187
+ const state = thunkApi.getState();
188
+ const { currentServer, syncServers } = getRuntimeServerContext(state);
189
+ console.log("[removeAction] START", {
190
+ dbKey,
191
+ preferredServerOrigin,
192
+ currentServer,
193
+ syncServers,
194
+ hasToken: Boolean(state?.auth?.currentToken)
195
+ });
196
+ const localData = await fetchFromClientDb(clientDb, dbKey);
197
+ const hadLocalData = Boolean(localData);
198
+ console.log("[removeAction] replication inputs", {
199
+ currentServer,
200
+ syncServers,
201
+ preferredServerOrigin,
202
+ hadLocalData
203
+ });
204
+ const nowIso = (/* @__PURE__ */ new Date()).toISOString();
205
+ if (localData) {
206
+ if (localData.id && typeof localData.id === "string") {
207
+ void deleteFileFromIndexedDb(localData.id).catch((err) => {
208
+ console.warn("[removeAction] Failed to delete associated file:", localData.id, err);
209
+ });
210
+ }
211
+ await clientDb.put(dbKey, buildTombstoneRecord(localData, nowIso));
212
+ } else {
213
+ await clientDb.put(dbKey, buildTombstoneRecord({ dbKey }, nowIso));
214
+ }
215
+ scheduleDeleteReplication({
216
+ currentServer,
217
+ syncServers,
218
+ preferredServerOrigin,
219
+ dbKey,
220
+ state,
221
+ onResult: (result) => {
222
+ if (result.failed.length > 0) {
223
+ console.warn("[removeAction] Server delete failures after local tombstone:", result.failed);
224
+ }
225
+ },
226
+ onError: (err) => {
227
+ console.warn("[removeAction] Background server delete error:", err);
228
+ }
229
+ });
230
+ return { dbKey };
231
+ };
232
+
233
+ export {
234
+ saveFileToIndexedDb,
235
+ loadFileFromIndexedDb,
236
+ deleteFileFromIndexedDb,
237
+ removeAction
238
+ };
@@ -0,0 +1,25 @@
1
+ import {
2
+ resolveNoloHome
3
+ } from "./chunk-LM6IYQ3F.js";
4
+
5
+ // packages/cli/localRuntimeDb.ts
6
+ import path from "node:path";
7
+ function resolveCliLocalRuntimeDbPath(options = {}) {
8
+ return path.join(resolveNoloHome(options), "data", "leveldb");
9
+ }
10
+ function buildCliLocalRuntimeDbEnv(env = process.env) {
11
+ return {
12
+ ...env,
13
+ NOLO_SERVER_DB_PATH: env.NOLO_SERVER_DB_PATH?.trim() || resolveCliLocalRuntimeDbPath({ env })
14
+ };
15
+ }
16
+ async function getDefaultCliLocalRuntimeDb(options = {}) {
17
+ const { getDefaultCliLocalRuntimeDb: getAuthorityBackedDb } = await import("./localRuntimeAuthority-TEGCOWX4.js");
18
+ return getAuthorityBackedDb(options);
19
+ }
20
+
21
+ export {
22
+ resolveCliLocalRuntimeDbPath,
23
+ buildCliLocalRuntimeDbEnv,
24
+ getDefaultCliLocalRuntimeDb
25
+ };
@@ -0,0 +1,12 @@
1
+ // packages/core/errorMessage.ts
2
+ function toErrorMessage(error) {
3
+ if (error instanceof Error) return error.message;
4
+ if (error !== null && typeof error === "object" && "message" in error && typeof error.message === "string") {
5
+ return error.message;
6
+ }
7
+ return String(error);
8
+ }
9
+
10
+ export {
11
+ toErrorMessage
12
+ };
@@ -0,0 +1,71 @@
1
+ import {
2
+ createMemoryKey,
3
+ createMemoryOwnerIndexKey,
4
+ createMemorySubjectKindIndexKey,
5
+ ulid
6
+ } from "./chunk-O4BU24WZ.js";
7
+
8
+ // packages/ai/memory/storeShared.ts
9
+ var createMemoryItem = (input) => {
10
+ const now = (/* @__PURE__ */ new Date()).toISOString();
11
+ return {
12
+ id: ulid(),
13
+ createdAt: now,
14
+ lastActivatedAt: now,
15
+ activationCount: 0,
16
+ ...input
17
+ };
18
+ };
19
+ var writeMemoryItemWithIndexesToDb = async (db, item) => {
20
+ const batch = db.batch();
21
+ batch.put(createMemoryKey(item.ownerType, item.ownerId, item.id), item);
22
+ batch.put(
23
+ createMemoryOwnerIndexKey(
24
+ item.ownerType,
25
+ item.ownerId,
26
+ item.createdAt,
27
+ item.id
28
+ ),
29
+ {
30
+ memoryKey: createMemoryKey(item.ownerType, item.ownerId, item.id),
31
+ ownerType: item.ownerType,
32
+ ownerId: item.ownerId,
33
+ memoryId: item.id
34
+ }
35
+ );
36
+ batch.put(
37
+ createMemorySubjectKindIndexKey(
38
+ item.subjectType,
39
+ item.subjectId,
40
+ item.kind,
41
+ item.createdAt,
42
+ item.id
43
+ ),
44
+ {
45
+ memoryKey: createMemoryKey(item.ownerType, item.ownerId, item.id),
46
+ subjectType: item.subjectType,
47
+ subjectId: item.subjectId,
48
+ kind: item.kind,
49
+ memoryId: item.id
50
+ }
51
+ );
52
+ await batch.write();
53
+ };
54
+ var touchMemoryItemsInDb = async (db, items, now = (/* @__PURE__ */ new Date()).toISOString()) => {
55
+ if (items.length === 0) return;
56
+ const batch = db.batch();
57
+ for (const item of items) {
58
+ batch.put(createMemoryKey(item.ownerType, item.ownerId, item.id), {
59
+ ...item,
60
+ lastActivatedAt: now,
61
+ activationCount: (item.activationCount ?? 0) + 1
62
+ });
63
+ }
64
+ await batch.write();
65
+ };
66
+
67
+ export {
68
+ createMemoryItem,
69
+ writeMemoryItemWithIndexesToDb,
70
+ touchMemoryItemsInDb
71
+ };
@@ -0,0 +1,15 @@
1
+ // packages/core/stringArray.ts
2
+ function asNonEmptyStringArray(value) {
3
+ if (!Array.isArray(value)) return [];
4
+ return value.filter(
5
+ (item) => typeof item === "string" && !!item.trim()
6
+ );
7
+ }
8
+ function asTrimmedNonEmptyStringArray(value) {
9
+ return asNonEmptyStringArray(value).map((item) => item.trim());
10
+ }
11
+
12
+ export {
13
+ asNonEmptyStringArray,
14
+ asTrimmedNonEmptyStringArray
15
+ };
@@ -0,0 +1,85 @@
1
+ // packages/cli/processSpawn.ts
2
+ import { spawn } from "node:child_process";
3
+ function spawnProcess(options) {
4
+ let [command, ...args] = options.cmd;
5
+ if (process.platform === "win32") {
6
+ const lower = command.toLowerCase();
7
+ if ((lower === "npm" || lower === "npx" || lower === "pnpm" || lower === "yarn" || lower === "nolo") && !lower.endsWith(".cmd") && !lower.endsWith(".exe") && !lower.endsWith(".bat")) {
8
+ command = `${command}.cmd`;
9
+ }
10
+ }
11
+ let child;
12
+ try {
13
+ child = spawn(command, args, {
14
+ cwd: options.cwd,
15
+ env: options.env,
16
+ stdio: [
17
+ options.stdin ?? "pipe",
18
+ options.stdout ?? "pipe",
19
+ options.stderr ?? "pipe"
20
+ ]
21
+ });
22
+ } catch {
23
+ return {
24
+ exited: Promise.resolve(127),
25
+ stdin: null,
26
+ stdout: null,
27
+ stderr: null
28
+ };
29
+ }
30
+ const exited = new Promise((resolve) => {
31
+ child.on("exit", (code) => resolve(code ?? 1));
32
+ child.on("error", () => resolve(127));
33
+ });
34
+ return {
35
+ exited,
36
+ stdin: child.stdin,
37
+ stdout: child.stdout,
38
+ stderr: child.stderr
39
+ };
40
+ }
41
+ async function readPipeText(stream) {
42
+ if (!stream) return "";
43
+ const anyStream = stream;
44
+ if (typeof anyStream.setEncoding !== "function" && typeof anyStream[Symbol.asyncIterator] === "function") {
45
+ const chunks = [];
46
+ for await (const chunk of anyStream) {
47
+ if (typeof chunk === "string") chunks.push(chunk);
48
+ else if (chunk instanceof Uint8Array) chunks.push(Buffer.from(chunk).toString("utf8"));
49
+ else if (Buffer.isBuffer(chunk)) chunks.push(chunk.toString("utf8"));
50
+ else chunks.push(String(chunk ?? ""));
51
+ }
52
+ return chunks.join("");
53
+ }
54
+ return new Promise((resolve) => {
55
+ let data = "";
56
+ let done = false;
57
+ const finish = () => {
58
+ if (done) return;
59
+ done = true;
60
+ resolve(data);
61
+ };
62
+ if (typeof anyStream.setEncoding === "function") {
63
+ anyStream.setEncoding("utf8");
64
+ }
65
+ stream.on("data", (chunk) => {
66
+ data += typeof chunk === "string" ? chunk : Buffer.from(chunk).toString("utf8");
67
+ });
68
+ stream.on("end", finish);
69
+ stream.on("close", finish);
70
+ stream.on("error", finish);
71
+ });
72
+ }
73
+ function resolveDefaultSpawn() {
74
+ const bunSpawn = globalThis.Bun?.spawn;
75
+ if (typeof bunSpawn === "function") {
76
+ return bunSpawn;
77
+ }
78
+ return spawnProcess;
79
+ }
80
+
81
+ export {
82
+ spawnProcess,
83
+ readPipeText,
84
+ resolveDefaultSpawn
85
+ };