nolo-cli 0.7.0 → 0.8.0-alpha.11

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 (175) hide show
  1. package/_executeModel-GPU2276G.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-4ZZFM6AT.js +323 -0
  6. package/agentEmailCommands-C4FIVQYV.js +621 -0
  7. package/agentListCommands-VQAKVNEX.js +219 -0
  8. package/agentMachineCommands-ONFDXZUQ.js +421 -0
  9. package/agentPullCommand-O2MTUAFR.js +122 -0
  10. package/agentRecordCommands-QANUGHLK.js +89 -0
  11. package/agentRunCommand-A3OSRB5Q.js +102 -0
  12. package/agentRunControl-K4VKNEHF.js +57 -0
  13. package/agentRuntimeLocal-62ZB2ODP.js +99 -0
  14. package/agentSlice-GCGLVR2N.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-2MALU52L.js +51 -0
  20. package/chunk-2UZXR7WO.js +3631 -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-4CQLVGRV.js +50 -0
  25. package/chunk-4IJYA27C.js +342 -0
  26. package/chunk-4SN6J65J.js +38 -0
  27. package/chunk-4VNS5WPM.js +42 -0
  28. package/chunk-53DNV5AT.js +421 -0
  29. package/chunk-572EKYLF.js +792 -0
  30. package/chunk-5MIDPSSK.js +206 -0
  31. package/chunk-5MMAK75Q.js +15 -0
  32. package/chunk-63W5N6P3.js +150 -0
  33. package/chunk-6B7G54GE.js +1078 -0
  34. package/chunk-6HYVJV7B.js +102 -0
  35. package/chunk-6WD3OOJS.js +20 -0
  36. package/chunk-7OC5VCLW.js +929 -0
  37. package/chunk-7YLKNMOM.js +562 -0
  38. package/chunk-ATNTHIZI.js +13 -0
  39. package/chunk-AUGHVUFE.js +69 -0
  40. package/chunk-AVMKZHBC.js +85 -0
  41. package/chunk-AZPCASRE.js +36 -0
  42. package/chunk-BR2WP3DF.js +548 -0
  43. package/chunk-BSTNFPHD.js +231 -0
  44. package/chunk-CF2WZF4N.js +134 -0
  45. package/chunk-CF7PE763.js +10 -0
  46. package/chunk-CJH2VTEU.js +360 -0
  47. package/chunk-CKOJQDKR.js +198 -0
  48. package/chunk-CM54RSSA.js +206 -0
  49. package/chunk-CQAHS7YO.js +4300 -0
  50. package/chunk-CWMSB67P.js +34 -0
  51. package/chunk-DFFIZ25G.js +30 -0
  52. package/chunk-DWLEOOGR.js +8 -0
  53. package/chunk-DZ3XJVET.js +231 -0
  54. package/chunk-EHLHSX7R.js +1433 -0
  55. package/chunk-ELRRLDWI.js +478 -0
  56. package/chunk-EYEEHCU4.js +3066 -0
  57. package/chunk-F6QQI5YI.js +19 -0
  58. package/chunk-G3SUCT4W.js +8 -0
  59. package/chunk-G5H7RNFL.js +807 -0
  60. package/chunk-GAKEBQD6.js +30 -0
  61. package/chunk-GBRG75BQ.js +86 -0
  62. package/chunk-GCMRDRCQ.js +190 -0
  63. package/chunk-GGUO4FKF.js +27158 -0
  64. package/chunk-GGXABIPP.js +628 -0
  65. package/chunk-H2RMRZJE.js +113 -0
  66. package/chunk-H33743XH.js +25 -0
  67. package/chunk-HEIIIZBX.js +104 -0
  68. package/chunk-HNMXYYJR.js +12 -0
  69. package/chunk-I3D64LRJ.js +1447 -0
  70. package/chunk-IAXBCTTE.js +175 -0
  71. package/chunk-IDZTNRP2.js +85 -0
  72. package/chunk-ISNCLGUZ.js +146 -0
  73. package/chunk-IYQV26RA.js +138 -0
  74. package/chunk-J4576WMJ.js +91 -0
  75. package/chunk-J5KV47ZW.js +222 -0
  76. package/chunk-JBTJAPUF.js +35 -0
  77. package/chunk-JZPBVBIY.js +94 -0
  78. package/chunk-KB7YFGL6.js +34 -0
  79. package/chunk-KKY4B2Q2.js +21 -0
  80. package/chunk-KQHGZWSV.js +63 -0
  81. package/chunk-KUG52IAP.js +8 -0
  82. package/chunk-KX6YBIHG.js +8 -0
  83. package/chunk-LAWBMYBC.js +171 -0
  84. package/chunk-LCBAMY2M.js +60 -0
  85. package/chunk-LM25IZBJ.js +902 -0
  86. package/chunk-LM6IYQ3F.js +16 -0
  87. package/chunk-M76ECQRD.js +13658 -0
  88. package/chunk-MRC4Q34M.js +188 -0
  89. package/chunk-NXZGF7F7.js +2878 -0
  90. package/chunk-OF5H3QWS.js +300 -0
  91. package/chunk-OLZBQWZU.js +6 -0
  92. package/chunk-OWOHNGCN.js +50 -0
  93. package/chunk-PN7AFLOK.js +3401 -0
  94. package/chunk-QR5IPGT3.js +24674 -0
  95. package/chunk-QSJ3HFEF.js +8 -0
  96. package/chunk-QYXLLLGL.js +4519 -0
  97. package/chunk-R2HXWML7.js +1949 -0
  98. package/chunk-ROWQEJRP.js +139 -0
  99. package/chunk-S7Z2HMCN.js +25 -0
  100. package/chunk-SYOF5TAS.js +962 -0
  101. package/chunk-TDIQFT2F.js +301 -0
  102. package/chunk-TILFE6LV.js +381 -0
  103. package/chunk-TZNCFAUP.js +2157 -0
  104. package/chunk-U4TRT5V4.js +246 -0
  105. package/chunk-U6VC4MU4.js +8 -0
  106. package/chunk-UAD2WT54.js +64 -0
  107. package/chunk-USZMK5UT.js +105 -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-XBIUN5CR.js +191 -0
  118. package/chunk-XDVAYP26.js +537 -0
  119. package/chunk-XKIMRZO2.js +221 -0
  120. package/chunk-Y5GCAMGP.js +9 -0
  121. package/chunk-YOUZDXU7.js +9013 -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-537X433B.js +864 -0
  127. package/createDialogAction-YUD4RKBS.js +52 -0
  128. package/createPageAction-KJMFHL4C.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-H74KJKHC.js +59 -0
  133. package/dialogSlice-ETSD4YWS.js +146 -0
  134. package/docCreateCommands-ADUSU34K.js +215 -0
  135. package/docDeleteCommands-ZXV3S5OS.js +176 -0
  136. package/docReadCommands-YYYI6LT7.js +129 -0
  137. package/docStore-ZBF5DDKR.js +96 -0
  138. package/docUpdateCommands-7MGJ3BYA.js +313 -0
  139. package/fetchMessages-JOCYIFKL.js +16 -0
  140. package/getPricing-PWPJ6MNV.js +30 -0
  141. package/handleSendMessageAction-MGKI62Y6.js +183 -0
  142. package/index.js +184 -112288
  143. package/lib-FYYBQIXS.js +19839 -0
  144. package/localDialogRead-D3BELSTF.js +26 -0
  145. package/localFirstLog-DHNOY2NA.js +19 -0
  146. package/localRuntimeAuthority-TEGCOWX4.js +471 -0
  147. package/localRuntimeDb-LGDF6FQP.js +12 -0
  148. package/machineCommands-RMTMN7VQ.js +774 -0
  149. package/machineInfo-M6KB6HZN.js +10 -0
  150. package/machineWsRunDispatch-UIP355FN.js +105 -0
  151. package/memoryCommands-O4MIPIWQ.js +476 -0
  152. package/models-XLEOET3E.js +9 -0
  153. package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
  154. package/package.json +3 -25
  155. package/read-RIJCIVKX.js +17 -0
  156. package/readDocTool-GZD2N3LO.js +16 -0
  157. package/readlineWorkspace-CRNQRZ6D.js +5374 -0
  158. package/removeDialogAgentAction-CXLST3N6.js +72 -0
  159. package/runAgentClientLoop-2S334SGA.js +288 -0
  160. package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
  161. package/setDialogExtraReferencesAction-LP6VYGU7.js +59 -0
  162. package/setPrimaryDialogAgentAction-D3GGH23T.js +79 -0
  163. package/settingSlice-J4I3Z5H7.js +198 -0
  164. package/skillSummaryMarker-42HKSXYY.js +9 -0
  165. package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
  166. package/slateUtils-2M7MUTWX.js +19 -0
  167. package/spaceCommands-NDEWMFZJ.js +450 -0
  168. package/spaceSlice-RLB6RTHO.js +145 -0
  169. package/streamAgentChatTurn-Y2TTYPBD.js +4503 -0
  170. package/tableCommands-GOFP7QKA.js +1286 -0
  171. package/toolApiClient-QI3YBNWB.js +26 -0
  172. package/tools-YZYLY2ZQ.js +83 -0
  173. package/understanding-HCSFPE7R.js +318 -0
  174. package/updateCommands-VOSPKXFF.js +31 -0
  175. package/updateDialogTitleAction-LQV6QLBW.js +185 -0
@@ -0,0 +1,10 @@
1
+ import {
2
+ detectMachineInfo,
3
+ resolveMachineId
4
+ } from "./chunk-6HYVJV7B.js";
5
+ import "./chunk-JBTJAPUF.js";
6
+ import "./chunk-4VNS5WPM.js";
7
+ export {
8
+ detectMachineInfo,
9
+ resolveMachineId
10
+ };
@@ -0,0 +1,105 @@
1
+ import {
2
+ buildArtifactProgress,
3
+ defaultRunConnectorLocalRuntimeAgent,
4
+ extractMultimodalUserInput,
5
+ handleConnectorRunMessage,
6
+ hasExplicitMachinePermissions,
7
+ isMachineBoundLocalCustomProvider,
8
+ localRuntimeEnvFromPolicy,
9
+ requestsLocalWorkspaceRuntime,
10
+ runtimePolicyFromConnectorPayload,
11
+ runtimeWorkspacePermissionPolicy,
12
+ scopePermissionPolicyToRuntimeWorkspace,
13
+ summarizeAgentConfigForLogs
14
+ } from "./chunk-6B7G54GE.js";
15
+ import "./chunk-YOUZDXU7.js";
16
+ import "./chunk-EHLHSX7R.js";
17
+ import "./chunk-F6QQI5YI.js";
18
+ import "./chunk-VHBWHNVT.js";
19
+ import "./chunk-BSTNFPHD.js";
20
+ import "./chunk-X7W4TNB4.js";
21
+ import "./chunk-ATNTHIZI.js";
22
+ import "./chunk-JBTJAPUF.js";
23
+ import "./chunk-LAWBMYBC.js";
24
+ import "./chunk-2MALU52L.js";
25
+ import "./chunk-GGUO4FKF.js";
26
+ import "./chunk-GAKEBQD6.js";
27
+ import "./chunk-KQHGZWSV.js";
28
+ import "./chunk-XKIMRZO2.js";
29
+ import "./chunk-3LY4F7SV.js";
30
+ import "./chunk-VP4WJWKW.js";
31
+ import "./chunk-63W5N6P3.js";
32
+ import "./chunk-53DNV5AT.js";
33
+ import "./chunk-7OC5VCLW.js";
34
+ import "./chunk-NXZGF7F7.js";
35
+ import "./chunk-OWOHNGCN.js";
36
+ import "./chunk-HEIIIZBX.js";
37
+ import "./chunk-QR5IPGT3.js";
38
+ import "./chunk-MRC4Q34M.js";
39
+ import "./chunk-J4576WMJ.js";
40
+ import "./chunk-CWMSB67P.js";
41
+ import "./chunk-7YLKNMOM.js";
42
+ import "./chunk-IYQV26RA.js";
43
+ import "./chunk-Z4NR32XR.js";
44
+ import "./chunk-M76ECQRD.js";
45
+ import "./chunk-AUGHVUFE.js";
46
+ import "./chunk-H2RMRZJE.js";
47
+ import "./chunk-UAD2WT54.js";
48
+ import "./chunk-USZMK5UT.js";
49
+ import "./chunk-IDZTNRP2.js";
50
+ import "./chunk-ISNCLGUZ.js";
51
+ import "./chunk-OLZBQWZU.js";
52
+ import "./chunk-2UZXR7WO.js";
53
+ import "./chunk-ZNFJWEN4.js";
54
+ import "./chunk-TILFE6LV.js";
55
+ import "./chunk-SYOF5TAS.js";
56
+ import "./chunk-XDVAYP26.js";
57
+ import "./chunk-LM25IZBJ.js";
58
+ import "./chunk-5MMAK75Q.js";
59
+ import "./chunk-572EKYLF.js";
60
+ import "./chunk-TDIQFT2F.js";
61
+ import "./chunk-JZPBVBIY.js";
62
+ import "./chunk-BR2WP3DF.js";
63
+ import "./chunk-5MIDPSSK.js";
64
+ import "./chunk-DFFIZ25G.js";
65
+ import "./chunk-3ASDTTEI.js";
66
+ import "./chunk-DWLEOOGR.js";
67
+ import "./chunk-HNMXYYJR.js";
68
+ import "./chunk-H33743XH.js";
69
+ import "./chunk-LM6IYQ3F.js";
70
+ import "./chunk-IAXBCTTE.js";
71
+ import "./chunk-VEJLAVTC.js";
72
+ import "./chunk-Y5GCAMGP.js";
73
+ import "./chunk-G5H7RNFL.js";
74
+ import "./chunk-AZPCASRE.js";
75
+ import "./chunk-2EISRLRC.js";
76
+ import "./chunk-KX6YBIHG.js";
77
+ import "./chunk-PN7AFLOK.js";
78
+ import "./chunk-WWC7I6TA.js";
79
+ import "./chunk-QSJ3HFEF.js";
80
+ import "./chunk-ELRRLDWI.js";
81
+ import "./chunk-EYEEHCU4.js";
82
+ import "./chunk-QYXLLLGL.js";
83
+ import "./chunk-GBRG75BQ.js";
84
+ import "./chunk-4SN6J65J.js";
85
+ import "./chunk-LCBAMY2M.js";
86
+ import "./chunk-3EUW3WEO.js";
87
+ import "./chunk-U6VC4MU4.js";
88
+ import "./chunk-CF7PE763.js";
89
+ import "./chunk-G3SUCT4W.js";
90
+ import "./chunk-KUG52IAP.js";
91
+ import "./chunk-4VNS5WPM.js";
92
+ export {
93
+ buildArtifactProgress,
94
+ defaultRunConnectorLocalRuntimeAgent,
95
+ extractMultimodalUserInput,
96
+ handleConnectorRunMessage,
97
+ hasExplicitMachinePermissions,
98
+ isMachineBoundLocalCustomProvider,
99
+ localRuntimeEnvFromPolicy,
100
+ requestsLocalWorkspaceRuntime,
101
+ runtimePolicyFromConnectorPayload,
102
+ runtimeWorkspacePermissionPolicy,
103
+ scopePermissionPolicyToRuntimeWorkspace,
104
+ summarizeAgentConfigForLogs
105
+ };
@@ -0,0 +1,476 @@
1
+ import {
2
+ readOption,
3
+ resolveAuthToken,
4
+ resolveServerCandidates,
5
+ resolveServerUrl
6
+ } from "./chunk-ISNCLGUZ.js";
7
+ import "./chunk-OLZBQWZU.js";
8
+ import {
9
+ toErrorMessage
10
+ } from "./chunk-HNMXYYJR.js";
11
+ import "./chunk-4SN6J65J.js";
12
+ import "./chunk-LCBAMY2M.js";
13
+ import "./chunk-CF7PE763.js";
14
+ import {
15
+ asOptionalTrimmedString
16
+ } from "./chunk-G3SUCT4W.js";
17
+ import "./chunk-4VNS5WPM.js";
18
+
19
+ // packages/cli/memoryCommands.ts
20
+ var VALUE_FLAGS = /* @__PURE__ */ new Set([
21
+ "--content",
22
+ "--cursor",
23
+ "--dialog-id",
24
+ "--facet",
25
+ "--id",
26
+ "--ids",
27
+ "--kind",
28
+ "--limit",
29
+ "--pattern-prefix",
30
+ "--scope",
31
+ "--server",
32
+ "--server-url",
33
+ "--space",
34
+ "--source-dialog",
35
+ "--subject",
36
+ "--subject-id",
37
+ "--subject-type",
38
+ "--tag",
39
+ "--token"
40
+ ]);
41
+ function hasFlag(args, flag) {
42
+ return args.includes(flag);
43
+ }
44
+ function printMemoryDeleteUsage(output) {
45
+ output.write(`Usage:
46
+ nolo memory delete --source-dialog <dialogId> --yes [--json]
47
+ nolo memory delete --tag <tag> --kind <kind> --yes
48
+ nolo memory delete --pattern-prefix <prefix> --limit <n> --yes
49
+
50
+ Options:
51
+ --id <memoryId> Delete a specific memory id. Repeatable.
52
+ --ids <a,b,c> Delete specific memory ids.
53
+ --source-dialog <dialogId> Delete memories created from one dialog.
54
+ --tag <tag> Require a tag. Repeatable.
55
+ --kind <kind> Filter episodic / semantic / procedural. Repeatable.
56
+ --facet <facet> Filter preference / tension / unfinished / goal / style. Repeatable.
57
+ --subject-type <type> Filter user / agent / space / project / system.
58
+ --subject <subjectId> Filter subjectId.
59
+ --pattern-prefix <prefix> Filter patternKey prefix.
60
+ --limit <n> Maximum memories to delete.
61
+ --yes Actually delete. Without this, command is a dry-run.
62
+ --json Print machine-readable JSON.
63
+ --server <url> Prefer this server and include known Nolo peers.
64
+ --token <jwt> Override AUTH_TOKEN.
65
+
66
+ At least one filter is required; this command will not delete all memory implicitly.
67
+ `);
68
+ }
69
+ function readRepeated(args, flag) {
70
+ const values = [];
71
+ for (let index = 0; index < args.length; index += 1) {
72
+ if (args[index] !== flag) continue;
73
+ const value = args[index + 1];
74
+ const trimmed = asOptionalTrimmedString(value);
75
+ if (trimmed) values.push(trimmed);
76
+ }
77
+ return values;
78
+ }
79
+ function readCsvValues(args, flag) {
80
+ const raw = readRepeated(args, flag).join(",");
81
+ return raw.split(",").map((value) => value.trim()).filter(Boolean);
82
+ }
83
+ function readLimit(args) {
84
+ const raw = readOption(args, "--limit");
85
+ if (!raw) return void 0;
86
+ if (!/^\d+$/.test(raw)) throw new Error(`invalid --limit: ${raw}`);
87
+ const parsed = Number(raw);
88
+ return parsed > 0 ? parsed : void 0;
89
+ }
90
+ function assertNoUnknownFlags(args) {
91
+ for (let index = 0; index < args.length; index += 1) {
92
+ const value = args[index];
93
+ if (!value.startsWith("-")) continue;
94
+ if (value === "--help" || value === "-h" || value === "--yes" || value === "--json") continue;
95
+ if (VALUE_FLAGS.has(value)) {
96
+ index += 1;
97
+ continue;
98
+ }
99
+ throw new Error(`unknown option: ${value}`);
100
+ }
101
+ }
102
+ function buildDeleteBody(args) {
103
+ const ids = [...readRepeated(args, "--id"), ...readCsvValues(args, "--ids")];
104
+ const kinds = readRepeated(args, "--kind");
105
+ const facets = readRepeated(args, "--facet");
106
+ const tags = readRepeated(args, "--tag");
107
+ const sourceDialogId = readOption(args, "--source-dialog")?.trim();
108
+ const subjectType = readOption(args, "--subject-type")?.trim();
109
+ const subjectId = (readOption(args, "--subject") ?? readOption(args, "--subject-id"))?.trim();
110
+ const patternKeyPrefix = readOption(args, "--pattern-prefix")?.trim();
111
+ const limit = readLimit(args);
112
+ const body = {};
113
+ if (ids.length) body.ids = [...new Set(ids)];
114
+ if (kinds.length) body.kinds = [...new Set(kinds)];
115
+ if (facets.length) body.facets = [...new Set(facets)];
116
+ if (tags.length) body.tags = [...new Set(tags)];
117
+ if (sourceDialogId) body.sourceDialogId = sourceDialogId;
118
+ if (subjectType) body.subjectType = subjectType;
119
+ if (subjectId) body.subjectId = subjectId;
120
+ if (patternKeyPrefix) body.patternKeyPrefix = patternKeyPrefix;
121
+ if (typeof limit === "number") body.limit = limit;
122
+ return body;
123
+ }
124
+ function hasDeleteFilter(body) {
125
+ return Object.keys(body).some((key) => key !== "limit");
126
+ }
127
+ async function postMemoryDelete(args) {
128
+ const res = await args.fetchImpl(`${args.serverUrl}/api/memory/delete`, {
129
+ method: "POST",
130
+ headers: {
131
+ Authorization: `Bearer ${args.authToken}`,
132
+ "Content-Type": "application/json"
133
+ },
134
+ body: JSON.stringify(args.body)
135
+ });
136
+ const text = await res.text();
137
+ let payload = null;
138
+ try {
139
+ payload = text ? JSON.parse(text) : null;
140
+ } catch {
141
+ payload = { raw: text };
142
+ }
143
+ if (!res.ok || payload?.error) {
144
+ const message = payload?.error?.message ?? payload?.message ?? payload?.error ?? `HTTP ${res.status}`;
145
+ throw new Error(`${message}`);
146
+ }
147
+ return payload;
148
+ }
149
+ async function runMemoryDeleteCommand(args, deps = {}) {
150
+ const env = deps.env ?? process.env;
151
+ const output = deps.output ?? process.stdout;
152
+ if (hasFlag(args, "--help") || hasFlag(args, "-h")) {
153
+ printMemoryDeleteUsage(output);
154
+ return 0;
155
+ }
156
+ try {
157
+ assertNoUnknownFlags(args);
158
+ const authToken = resolveAuthToken(args, env);
159
+ if (!authToken) {
160
+ output.write("[nolo] memory delete requires an auth token. Run `nolo login` or set AUTH_TOKEN.\n");
161
+ return 1;
162
+ }
163
+ const body = buildDeleteBody(args);
164
+ if (!hasDeleteFilter(body)) {
165
+ output.write("[nolo] memory delete requires at least one filter; use --help for examples.\n");
166
+ return 1;
167
+ }
168
+ const shouldDelete = hasFlag(args, "--yes");
169
+ const wantJson = hasFlag(args, "--json");
170
+ const fetchImpl = deps.fetchImpl ?? fetch;
171
+ const serverUrl = resolveServerUrl(args, env);
172
+ const serverUrls = resolveServerCandidates(args, env, serverUrl);
173
+ if (!shouldDelete) {
174
+ const payload2 = {
175
+ dryRun: true,
176
+ deleted: false,
177
+ targetServers: serverUrls,
178
+ request: body,
179
+ nextStep: "rerun with --yes to delete matching memories"
180
+ };
181
+ if (wantJson) {
182
+ output.write(`${JSON.stringify(payload2, null, 2)}
183
+ `);
184
+ } else {
185
+ output.write("dryRun: true\n");
186
+ output.write(`targetServers: ${serverUrls.join(", ")}
187
+ `);
188
+ output.write(`request: ${JSON.stringify(body)}
189
+ `);
190
+ output.write("rerun with --yes to delete matching memories\n");
191
+ }
192
+ return 0;
193
+ }
194
+ const promises = serverUrls.map(async (target) => {
195
+ try {
196
+ const result = await postMemoryDelete({
197
+ authToken,
198
+ body,
199
+ fetchImpl,
200
+ serverUrl: target
201
+ });
202
+ return { serverUrl: target, ok: true, result };
203
+ } catch (error) {
204
+ return {
205
+ serverUrl: target,
206
+ ok: false,
207
+ error: toErrorMessage(error)
208
+ };
209
+ }
210
+ });
211
+ const deleteResults = await Promise.all(promises);
212
+ const deletedCount = deleteResults.reduce(
213
+ (sum, item) => sum + (item.ok ? Number(item.result?.deletedCount ?? 0) : 0),
214
+ 0
215
+ );
216
+ const payload = {
217
+ dryRun: false,
218
+ deleted: true,
219
+ deletedCount,
220
+ request: body,
221
+ targetServers: serverUrls,
222
+ deleteResults
223
+ };
224
+ if (wantJson) {
225
+ output.write(`${JSON.stringify(payload, null, 2)}
226
+ `);
227
+ } else {
228
+ output.write(`deletedCount: ${deletedCount}
229
+ `);
230
+ for (const result of deleteResults) {
231
+ output.write(
232
+ result.ok ? `${result.serverUrl}: ok deleted=${result.result?.deletedCount ?? 0}
233
+ ` : `${result.serverUrl}: failed ${result.error}
234
+ `
235
+ );
236
+ }
237
+ }
238
+ return deleteResults.some((result) => result.ok) ? 0 : 1;
239
+ } catch (error) {
240
+ output.write(`[nolo] memory delete failed: ${toErrorMessage(error)}
241
+ `);
242
+ return 1;
243
+ }
244
+ }
245
+ function printMemoryListUsage(output) {
246
+ output.write(`Usage:
247
+ nolo memory list [--limit 50] [--kind episodic] [--subject-type agent]
248
+ nolo memory list --subject-type agent --subject <subjectId> --json
249
+
250
+ Options:
251
+ --limit <n> Page size (1-200, default 50).
252
+ --cursor <cursor> Continue from a previous page's nextCursor.
253
+ --kind <kind> Filter episodic / semantic / procedural.
254
+ --subject-type <type> Filter user / agent / space / project / system.
255
+ --subject <subjectId> Filter subjectId (requires --subject-type).
256
+ --json Print machine-readable JSON.
257
+ --server <url> Prefer this server and include known Nolo peers.
258
+ --token <jwt> Override AUTH_TOKEN.
259
+
260
+ Listing is scoped to the authenticated user's memories.
261
+ `);
262
+ }
263
+ function buildListBody(args) {
264
+ const body = {};
265
+ const limit = readLimit(args);
266
+ if (typeof limit === "number") body.limit = limit;
267
+ const cursor = readOption(args, "--cursor")?.trim();
268
+ if (cursor) body.cursor = cursor;
269
+ const kind = readOption(args, "--kind")?.trim();
270
+ if (kind) body.kind = kind;
271
+ const subjectType = readOption(args, "--subject-type")?.trim();
272
+ if (subjectType) body.subjectType = subjectType;
273
+ const subjectId = (readOption(args, "--subject") ?? readOption(args, "--subject-id"))?.trim();
274
+ if (subjectId) body.subjectId = subjectId;
275
+ return body;
276
+ }
277
+ function parseMemoryResponse(text) {
278
+ if (!text) return { result: null, errorMessage: void 0 };
279
+ try {
280
+ const parsed = JSON.parse(text);
281
+ if (typeof parsed === "object" && parsed !== null && "error" in parsed) {
282
+ const err = parsed.error;
283
+ const message = typeof err === "object" && err !== null && "message" in err ? String(err.message ?? "") : "";
284
+ return { result: parsed, errorMessage: message || parsed.message };
285
+ }
286
+ return { result: parsed, errorMessage: void 0 };
287
+ } catch {
288
+ return { result: { raw: text }, errorMessage: void 0 };
289
+ }
290
+ }
291
+ async function postMemoryList(args) {
292
+ const res = await args.fetchImpl(`${args.serverUrl}/api/memory/list`, {
293
+ method: "POST",
294
+ headers: {
295
+ Authorization: `Bearer ${args.authToken}`,
296
+ "Content-Type": "application/json"
297
+ },
298
+ body: JSON.stringify(args.body)
299
+ });
300
+ const text = await res.text();
301
+ const parsed = parseMemoryResponse(text);
302
+ if (!res.ok) {
303
+ throw new Error(parsed.errorMessage ?? `HTTP ${res.status}`);
304
+ }
305
+ if (parsed.errorMessage) {
306
+ throw new Error(parsed.errorMessage);
307
+ }
308
+ return parsed.result;
309
+ }
310
+ function renderMemoryItem(item) {
311
+ if (typeof item !== "object" || item === null) return String(item);
312
+ const record = item;
313
+ const parts = [];
314
+ if (record.id) parts.push(record.id);
315
+ if (record.kind) parts.push(`kind=${record.kind}`);
316
+ if (record.subjectType) parts.push(`subject=${record.subjectType}${record.subjectId ? `:${record.subjectId}` : ""}`);
317
+ if (record.scope) parts.push(`scope=${record.scope}`);
318
+ const content = record.content ? record.content.length > 80 ? `${record.content.slice(0, 80)}\u2026` : record.content : "";
319
+ return [parts.join(" "), content].filter(Boolean).join("\n ");
320
+ }
321
+ async function runMemoryListCommand(args, deps = {}) {
322
+ const env = deps.env ?? process.env;
323
+ const output = deps.output ?? process.stdout;
324
+ if (hasFlag(args, "--help") || hasFlag(args, "-h")) {
325
+ printMemoryListUsage(output);
326
+ return 0;
327
+ }
328
+ try {
329
+ assertNoUnknownFlags(args);
330
+ const authToken = resolveAuthToken(args, env);
331
+ if (!authToken) {
332
+ output.write("[nolo] memory list requires an auth token. Run `nolo login` or set AUTH_TOKEN.\n");
333
+ return 1;
334
+ }
335
+ const body = buildListBody(args);
336
+ const wantJson = hasFlag(args, "--json");
337
+ const fetchImpl = deps.fetchImpl ?? fetch;
338
+ const serverUrl = resolveServerUrl(args, env);
339
+ const serverUrls = resolveServerCandidates(args, env, serverUrl);
340
+ const target = serverUrls[0] ?? serverUrl;
341
+ try {
342
+ const result = await postMemoryList({ authToken, body, fetchImpl, serverUrl: target });
343
+ const items = Array.isArray(result.items) ? result.items : [];
344
+ if (wantJson) {
345
+ output.write(`${JSON.stringify({ items, nextCursor: result.nextCursor, truncated: result.truncated }, null, 2)}
346
+ `);
347
+ } else {
348
+ output.write(`${target}: ${items.length} memor${items.length === 1 ? "y" : "ies"}
349
+ `);
350
+ for (const item of items) {
351
+ output.write(` ${renderMemoryItem(item)}
352
+ `);
353
+ }
354
+ if (result.nextCursor) {
355
+ output.write(`nextCursor: ${result.nextCursor}
356
+ `);
357
+ }
358
+ if (result.truncated) {
359
+ output.write("truncated: true (more entries may exist; page with --cursor)\n");
360
+ }
361
+ }
362
+ return 0;
363
+ } catch (error) {
364
+ output.write(`[nolo] memory list failed: ${toErrorMessage(error)}
365
+ `);
366
+ return 1;
367
+ }
368
+ } catch (error) {
369
+ output.write(`[nolo] memory list failed: ${toErrorMessage(error)}
370
+ `);
371
+ return 1;
372
+ }
373
+ }
374
+ function printMemoryRememberUsage(output) {
375
+ output.write(`Usage:
376
+ nolo memory remember --content "\u7528\u6237\u504F\u597D\u5148\u770B\u7ED3\u8BBA" --kind semantic
377
+ nolo memory remember --content "..." --kind episodic --scope auto --dialog-id <id>
378
+
379
+ Options:
380
+ --content <text> The memory text to store (required).
381
+ --kind <kind> episodic / semantic / procedural (required).
382
+ --scope <scope> auto / user / space (default auto).
383
+ --dialog-id <id> Attach to a dialog.
384
+ --space <spaceId> Store under a space (requires space membership).
385
+ --json Print machine-readable JSON.
386
+ --server <url> Prefer this server and include known Nolo peers.
387
+ --token <jwt> Override AUTH_TOKEN.
388
+ `);
389
+ }
390
+ function buildRememberBody(args) {
391
+ const content = readOption(args, "--content")?.trim();
392
+ const kind = readOption(args, "--kind")?.trim();
393
+ const scope = readOption(args, "--scope")?.trim();
394
+ const dialogId = readOption(args, "--dialog-id")?.trim();
395
+ const spaceId = readOption(args, "--space")?.trim();
396
+ return { content, kind, scope, dialogId, spaceId };
397
+ }
398
+ async function postMemoryRemember(args) {
399
+ const res = await args.fetchImpl(`${args.serverUrl}/api/memory/remember`, {
400
+ method: "POST",
401
+ headers: {
402
+ Authorization: `Bearer ${args.authToken}`,
403
+ "Content-Type": "application/json"
404
+ },
405
+ body: JSON.stringify(args.body)
406
+ });
407
+ const text = await res.text();
408
+ const parsed = parseMemoryResponse(text);
409
+ if (!res.ok) {
410
+ throw new Error(parsed.errorMessage ?? `HTTP ${res.status}`);
411
+ }
412
+ if (parsed.errorMessage) {
413
+ throw new Error(parsed.errorMessage);
414
+ }
415
+ return parsed.result;
416
+ }
417
+ var REMEMBER_KINDS = /* @__PURE__ */ new Set(["episodic", "semantic", "procedural"]);
418
+ var REMEMBER_SCOPES = /* @__PURE__ */ new Set(["auto", "user", "space"]);
419
+ async function runMemoryRememberCommand(args, deps = {}) {
420
+ const env = deps.env ?? process.env;
421
+ const output = deps.output ?? process.stdout;
422
+ if (hasFlag(args, "--help") || hasFlag(args, "-h")) {
423
+ printMemoryRememberUsage(output);
424
+ return 0;
425
+ }
426
+ try {
427
+ assertNoUnknownFlags(args);
428
+ const authToken = resolveAuthToken(args, env);
429
+ if (!authToken) {
430
+ output.write("[nolo] memory remember requires an auth token. Run `nolo login` or set AUTH_TOKEN.\n");
431
+ return 1;
432
+ }
433
+ const { content, kind, scope, dialogId, spaceId } = buildRememberBody(args);
434
+ if (!content) {
435
+ output.write("[nolo] memory remember requires --content <text>; use --help for examples.\n");
436
+ return 1;
437
+ }
438
+ if (!kind || !REMEMBER_KINDS.has(kind)) {
439
+ output.write("[nolo] memory remember requires --kind <episodic|semantic|procedural>.\n");
440
+ return 1;
441
+ }
442
+ const normalizedScope = scope && REMEMBER_SCOPES.has(scope) ? scope : "auto";
443
+ const body = { content, kind, scope: normalizedScope };
444
+ if (dialogId) body.dialogId = dialogId;
445
+ if (spaceId) body.spaceId = spaceId;
446
+ const wantJson = hasFlag(args, "--json");
447
+ const fetchImpl = deps.fetchImpl ?? fetch;
448
+ const serverUrl = resolveServerUrl(args, env);
449
+ const serverUrls = resolveServerCandidates(args, env, serverUrl);
450
+ const target = serverUrls[0] ?? serverUrl;
451
+ try {
452
+ const result = await postMemoryRemember({ authToken, body, fetchImpl, serverUrl: target });
453
+ if (wantJson) {
454
+ output.write(`${JSON.stringify(result, null, 2)}
455
+ `);
456
+ } else {
457
+ output.write(`${target}: remembered ${kind}
458
+ `);
459
+ }
460
+ return 0;
461
+ } catch (error) {
462
+ output.write(`[nolo] memory remember failed: ${toErrorMessage(error)}
463
+ `);
464
+ return 1;
465
+ }
466
+ } catch (error) {
467
+ output.write(`[nolo] memory remember failed: ${toErrorMessage(error)}
468
+ `);
469
+ return 1;
470
+ }
471
+ }
472
+ export {
473
+ runMemoryDeleteCommand,
474
+ runMemoryListCommand,
475
+ runMemoryRememberCommand
476
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ ALL_MODELS
3
+ } from "./chunk-USZMK5UT.js";
4
+ import "./chunk-BR2WP3DF.js";
5
+ import "./chunk-QSJ3HFEF.js";
6
+ import "./chunk-4VNS5WPM.js";
7
+ export {
8
+ ALL_MODELS
9
+ };