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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/README.md +1 -1
  2. package/_executeModel-42U3VOVZ.js +205 -0
  3. package/action-TLI3V62L.js +28 -0
  4. package/addContentAction-57RSIIMR.js +26 -0
  5. package/addDialogAgentAction-G3VWEA6E.js +68 -0
  6. package/agentDeleteCommand-5DD2IM3J.js +327 -0
  7. package/agentEmailCommands-6FACJBU4.js +628 -0
  8. package/agentListCommands-I6KZYCIG.js +223 -0
  9. package/agentMachineCommands-VKLIGMZA.js +425 -0
  10. package/agentPullCommand-O2MTUAFR.js +122 -0
  11. package/agentRecordCommands-7TZICYDT.js +96 -0
  12. package/agentRunCommand-L4OM23KV.js +114 -0
  13. package/agentRunControl-K4VKNEHF.js +57 -0
  14. package/agentRuntimeLocal-ZYEIPTY4.js +104 -0
  15. package/agentSlice-BX7GXSNO.js +42 -0
  16. package/authCommand-EB5JSOX5.js +581 -0
  17. package/authCommands-XPEHTKSM.js +35 -0
  18. package/chunk-25LCXTML.js +175 -0
  19. package/chunk-2ECQG4YX.js +22296 -0
  20. package/chunk-2FTTDCD4.js +675 -0
  21. package/chunk-2JCXITPK.js +1078 -0
  22. package/chunk-3ASDTTEI.js +1774 -0
  23. package/chunk-3EUW3WEO.js +8 -0
  24. package/chunk-3LY4F7SV.js +9293 -0
  25. package/chunk-4CQLVGRV.js +50 -0
  26. package/chunk-4IJYA27C.js +342 -0
  27. package/chunk-4O3CARJ4.js +231 -0
  28. package/chunk-4QEWT7KD.js +933 -0
  29. package/chunk-4SN6J65J.js +38 -0
  30. package/chunk-4VNS5WPM.js +42 -0
  31. package/chunk-4XENYTF5.js +222 -0
  32. package/chunk-4ZDM73SD.js +34 -0
  33. package/chunk-5CS33IBL.js +301 -0
  34. package/chunk-5EFXE3O7.js +138 -0
  35. package/chunk-5KLGBAAR.js +386 -0
  36. package/chunk-5MIDPSSK.js +206 -0
  37. package/chunk-5MMAK75Q.js +15 -0
  38. package/chunk-63W5N6P3.js +150 -0
  39. package/chunk-6HYVJV7B.js +102 -0
  40. package/chunk-6KHNO3SK.js +1948 -0
  41. package/chunk-6WD3OOJS.js +20 -0
  42. package/chunk-7DAJ4AI4.js +191 -0
  43. package/chunk-7GNGZRLZ.js +1939 -0
  44. package/chunk-7KCUSYT2.js +354 -0
  45. package/chunk-7U44LYTR.js +238 -0
  46. package/chunk-AFON4QUU.js +112 -0
  47. package/chunk-AGFH73SK.js +239 -0
  48. package/chunk-AL2KDGR2.js +27339 -0
  49. package/chunk-AS4PVWA4.js +221 -0
  50. package/chunk-ATNTHIZI.js +13 -0
  51. package/chunk-AVMKZHBC.js +85 -0
  52. package/chunk-AZPCASRE.js +36 -0
  53. package/chunk-BBYVOSU2.js +792 -0
  54. package/chunk-C3RUNRHT.js +51 -0
  55. package/chunk-C4FTUXVF.js +146 -0
  56. package/chunk-CF2WZF4N.js +134 -0
  57. package/chunk-CF7PE763.js +10 -0
  58. package/chunk-CKOJQDKR.js +198 -0
  59. package/chunk-CMKUBIGW.js +1550 -0
  60. package/chunk-CWMSB67P.js +34 -0
  61. package/chunk-DCOA4QSN.js +105 -0
  62. package/chunk-DFFIZ25G.js +30 -0
  63. package/chunk-DSZUWUYB.js +478 -0
  64. package/chunk-DWLEOOGR.js +8 -0
  65. package/chunk-DZ3XJVET.js +231 -0
  66. package/chunk-EHLHSX7R.js +1433 -0
  67. package/chunk-ENOG22KJ.js +939 -0
  68. package/chunk-FSO5B7GH.js +171 -0
  69. package/chunk-FVYY6MCS.js +1447 -0
  70. package/chunk-G3SUCT4W.js +8 -0
  71. package/chunk-GAKEBQD6.js +30 -0
  72. package/chunk-GBRG75BQ.js +86 -0
  73. package/chunk-GU3PEVGZ.js +4723 -0
  74. package/chunk-H33743XH.js +25 -0
  75. package/chunk-HNMXYYJR.js +12 -0
  76. package/chunk-HNW7IJSK.js +71 -0
  77. package/chunk-I42VC5KR.js +15 -0
  78. package/chunk-I6XMPTMR.js +113 -0
  79. package/chunk-IDZTNRP2.js +85 -0
  80. package/chunk-ISNCLGUZ.js +146 -0
  81. package/chunk-IWX4UW2E.js +548 -0
  82. package/chunk-JBTJAPUF.js +35 -0
  83. package/chunk-JEXVIMYZ.js +55 -0
  84. package/chunk-JRKKFRAV.js +537 -0
  85. package/chunk-JZPBVBIY.js +94 -0
  86. package/chunk-KKY4B2Q2.js +21 -0
  87. package/chunk-KQHGZWSV.js +63 -0
  88. package/chunk-KUG52IAP.js +8 -0
  89. package/chunk-KX6YBIHG.js +8 -0
  90. package/chunk-LCBAMY2M.js +60 -0
  91. package/chunk-LM6IYQ3F.js +16 -0
  92. package/chunk-LTRXGFMS.js +83 -0
  93. package/chunk-M76ECQRD.js +13658 -0
  94. package/chunk-MRC4Q34M.js +188 -0
  95. package/chunk-MTU75CZ2.js +91 -0
  96. package/chunk-N54XAP77.js +19 -0
  97. package/chunk-O2ZNTTET.js +3272 -0
  98. package/chunk-O4BU24WZ.js +3212 -0
  99. package/chunk-OLZBQWZU.js +6 -0
  100. package/chunk-OOSFSFMA.js +271 -0
  101. package/chunk-OPZYGHUC.js +89 -0
  102. package/chunk-OWOHNGCN.js +50 -0
  103. package/chunk-P3PKED2I.js +962 -0
  104. package/chunk-QSJ3HFEF.js +8 -0
  105. package/chunk-RCSJFQPB.js +9036 -0
  106. package/chunk-RL776AGR.js +190 -0
  107. package/chunk-ROWQEJRP.js +139 -0
  108. package/chunk-S7Z2HMCN.js +25 -0
  109. package/chunk-SDJDLO5W.js +628 -0
  110. package/chunk-SOTZ6RDN.js +69 -0
  111. package/chunk-TILFE6LV.js +381 -0
  112. package/chunk-U4TRT5V4.js +246 -0
  113. package/chunk-U6VC4MU4.js +8 -0
  114. package/chunk-UAD2WT54.js +64 -0
  115. package/chunk-UB6SN4NJ.js +421 -0
  116. package/chunk-URUUZLPA.js +807 -0
  117. package/chunk-UTLZINAP.js +3066 -0
  118. package/chunk-VC6OZXO5.js +298 -0
  119. package/chunk-VF4K2QE6.js +21 -0
  120. package/chunk-VHBWHNVT.js +59 -0
  121. package/chunk-VIDPVFP3.js +20 -0
  122. package/chunk-VP4WJWKW.js +8882 -0
  123. package/chunk-VUW5FBDB.js +573 -0
  124. package/chunk-VVX233PH.js +482 -0
  125. package/chunk-VX3SXJ3N.js +2052 -0
  126. package/chunk-W4NVOSFF.js +37 -0
  127. package/chunk-WWC7I6TA.js +8 -0
  128. package/chunk-WZSRQNQG.js +2587 -0
  129. package/chunk-XBUBEFNX.js +34 -0
  130. package/chunk-XENYHRUE.js +104 -0
  131. package/chunk-Y5GCAMGP.js +9 -0
  132. package/chunk-YPRZSPF3.js +148 -0
  133. package/chunk-Z4NR32XR.js +50 -0
  134. package/chunk-ZNFJWEN4.js +56 -0
  135. package/cliExecutor-K3F7DMRO.js +36 -0
  136. package/clipboardy-BVE3LVEH.js +12001 -0
  137. package/createAgentAutomationAction-RJF3N2QY.js +866 -0
  138. package/createDialogAction-DRSPS6CE.js +55 -0
  139. package/createPageAction-6B2WMNO3.js +172 -0
  140. package/db-HCJ5PRB5.js +271 -0
  141. package/dbSlice-Q3TM2FJV.js +60 -0
  142. package/deleteFile-OW53A6BX.js +41 -0
  143. package/dialogCommands-4IX4XIZE.js +63 -0
  144. package/dialogSlice-3M7KX2TX.js +148 -0
  145. package/docCreateCommands-SIL3NPGT.js +220 -0
  146. package/docDeleteCommands-7IOMLUS4.js +181 -0
  147. package/docReadCommands-FNFXUA5L.js +134 -0
  148. package/docStore-SV7E34D4.js +98 -0
  149. package/docUpdateCommands-X2HNDVUC.js +318 -0
  150. package/fetchMessages-KTNM7QAR.js +17 -0
  151. package/getPricing-3E6UNPKL.js +30 -0
  152. package/handleSendMessageAction-JYETO5RZ.js +185 -0
  153. package/index.js +188 -112958
  154. package/lib-FYYBQIXS.js +19839 -0
  155. package/localDialogRead-2VRI24F4.js +26 -0
  156. package/localFirstLog-DHNOY2NA.js +19 -0
  157. package/localRuntimeAuthority-TEGCOWX4.js +471 -0
  158. package/localRuntimeDb-LGDF6FQP.js +12 -0
  159. package/machineCommands-RIO3RP5Q.js +781 -0
  160. package/machineInfo-M6KB6HZN.js +10 -0
  161. package/machineWsRunDispatch-W7UYLGB5.js +112 -0
  162. package/memoryCommands-O4MIPIWQ.js +476 -0
  163. package/models-4OPOOLFS.js +9 -0
  164. package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
  165. package/package.json +4 -24
  166. package/read-GW7ZEI23.js +17 -0
  167. package/readDocTool-HUFU6OCT.js +16 -0
  168. package/readlineWorkspace-27JR7WPW.js +5682 -0
  169. package/removeDialogAgentAction-CXKR4NJI.js +73 -0
  170. package/runAgentClientLoop-HZFAPJHS.js +293 -0
  171. package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
  172. package/setDialogExtraReferencesAction-6RKUSXHX.js +60 -0
  173. package/setPrimaryDialogAgentAction-T3UTBEFG.js +80 -0
  174. package/settingSlice-IVKXJXMG.js +199 -0
  175. package/skillDiscovery-UGSQGX2U.js +16 -0
  176. package/skillSummaryMarker-42HKSXYY.js +9 -0
  177. package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
  178. package/slateUtils-2M7MUTWX.js +19 -0
  179. package/spaceCommands-E7VOF4LO.js +450 -0
  180. package/spaceSlice-TSVROA5U.js +149 -0
  181. package/streamAgentChatTurn-3C5RQZJF.js +4510 -0
  182. package/tableCommands-O7O2LBEG.js +1286 -0
  183. package/toolApiClient-QI3YBNWB.js +26 -0
  184. package/tools-EQDEKR6N.js +87 -0
  185. package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
  186. package/understanding-3CUQQ6SV.js +271 -0
  187. package/updateCommands-VOSPKXFF.js +31 -0
  188. package/updateDialogTitleAction-3XV7VWSZ.js +188 -0
package/README.md CHANGED
@@ -232,7 +232,7 @@ nolo table add-column --table meta-0e95801d90-01KWSK4Q4TESXQ06SW39JN2TTJ --schem
232
232
  - `nolo agent email create-and-provision <slug> --name <display> [--local-part pay] [--copy-provider-from <agent>]` 一步创建 agent 并开通邮箱。
233
233
  - `nolo auth cloudflare [--client-id <id>] [--generate-token] [--zone-name <domain>] [--write-to-env [path]]` 通过 Cloudflare 自托管 OAuth 授权并可选生成 `Zone:Email Routing:Edit` 的 API Token,还可直接写入 `.env`。
234
234
  - `nolo auth claude [--no-browser] [--sync-to-server]` 通过 PKCE + `localhost:54545` 回调授权 Claude Pro/Max;`--no-browser` 时可粘贴最终回调 URL/授权码。凭据保存到 `~/.nolo/credentials/claude.json`。Agent 使用 `provider: "anthropic"`、`apiKeyRef: "claude"`。
235
- - `nolo auth cursor [--no-browser] [--sync-to-server]` 通过 poll-based device flow 授权 Cursor Pro(无需回调端口)。打开 `https://cursor.com/loginDeepControl` 并轮询 `api2.cursor.sh/auth/poll` 获取 token。凭据保存到 `~/.nolo/credentials/cursor.json`。Agent 使用 `provider: "cursor"`、`apiKeyRef: "cursor"`,模型如 `cursor-grok-4.5`。
235
+ - `nolo auth cursor [--no-browser] [--sync-to-server]` 通过 poll-based device flow 授权 Cursor Pro(无需回调端口)。打开 `https://cursor.com/loginDeepControl` 并轮询 `api2.cursor.sh/auth/poll` 获取 token。凭据保存到 `~/.nolo/credentials/cursor.json`。Agent 使用 `provider: "cursor"`、`apiKeyRef: "cursor"`,模型如 `cursor-grok-4.5-high`(Cursor Models 池;裸 `cursor-grok-4.5` 会由 provider 兼容映射到 high)。
236
236
 
237
237
  账户所有权对私有 agent 维护很重要。默认的新测试、验证 dialogs、任务板写入、机器绑定的 agent 运行和用户可见的结果应写入当前操作员账户 `0e95801d90`。原有的 `b2e06f801f` / platform-demo 账户已删除,仅在极少数维护旧公开/共享记录场景时保留。使用 `nolo agent read`、`nolo agent update` 和仓库原生助手作为正常入口点;只有明确针对旧记录的所有者专属操作才应使用维护的 platform-demo token(来自 `scripts/testUtils.ts`)或重新生成的 token(来自 `scripts/generateToken.ts`)。不要将 token 字符串复制到文档、日志或提示词中。
238
238
 
@@ -0,0 +1,205 @@
1
+ import {
2
+ fetchAgentContexts
3
+ } from "./chunk-XBUBEFNX.js";
4
+ import {
5
+ filterAndCleanMessages,
6
+ sendOpenAICompletionsRequest
7
+ } from "./chunk-6KHNO3SK.js";
8
+ import "./chunk-JEXVIMYZ.js";
9
+ import "./chunk-FSO5B7GH.js";
10
+ import {
11
+ generateRequestBody,
12
+ mergeReferences,
13
+ performFetchRequest
14
+ } from "./chunk-7GNGZRLZ.js";
15
+ import "./chunk-C3RUNRHT.js";
16
+ import "./chunk-VIDPVFP3.js";
17
+ import "./chunk-AL2KDGR2.js";
18
+ import "./chunk-GAKEBQD6.js";
19
+ import "./chunk-KQHGZWSV.js";
20
+ import "./chunk-AS4PVWA4.js";
21
+ import "./chunk-3LY4F7SV.js";
22
+ import "./chunk-VP4WJWKW.js";
23
+ import "./chunk-63W5N6P3.js";
24
+ import "./chunk-VF4K2QE6.js";
25
+ import "./chunk-UB6SN4NJ.js";
26
+ import "./chunk-ENOG22KJ.js";
27
+ import "./chunk-VC6OZXO5.js";
28
+ import "./chunk-25LCXTML.js";
29
+ import "./chunk-XENYHRUE.js";
30
+ import {
31
+ selectAllMsgs,
32
+ selectCurrentDialogConfig,
33
+ updateTokensAction
34
+ } from "./chunk-2ECQG4YX.js";
35
+ import "./chunk-4ZDM73SD.js";
36
+ import "./chunk-MRC4Q34M.js";
37
+ import "./chunk-MTU75CZ2.js";
38
+ import "./chunk-CWMSB67P.js";
39
+ import "./chunk-VUW5FBDB.js";
40
+ import "./chunk-5EFXE3O7.js";
41
+ import "./chunk-Z4NR32XR.js";
42
+ import "./chunk-M76ECQRD.js";
43
+ import "./chunk-SOTZ6RDN.js";
44
+ import "./chunk-I6XMPTMR.js";
45
+ import "./chunk-UAD2WT54.js";
46
+ import "./chunk-DCOA4QSN.js";
47
+ import "./chunk-KKY4B2Q2.js";
48
+ import "./chunk-WZSRQNQG.js";
49
+ import "./chunk-4QEWT7KD.js";
50
+ import "./chunk-OPZYGHUC.js";
51
+ import "./chunk-AGFH73SK.js";
52
+ import "./chunk-JRKKFRAV.js";
53
+ import "./chunk-P3PKED2I.js";
54
+ import "./chunk-5MMAK75Q.js";
55
+ import {
56
+ getApiEndpoint
57
+ } from "./chunk-BBYVOSU2.js";
58
+ import "./chunk-5CS33IBL.js";
59
+ import "./chunk-JZPBVBIY.js";
60
+ import "./chunk-IWX4UW2E.js";
61
+ import "./chunk-5MIDPSSK.js";
62
+ import {
63
+ extractCustomId
64
+ } from "./chunk-DFFIZ25G.js";
65
+ import "./chunk-3ASDTTEI.js";
66
+ import "./chunk-DWLEOOGR.js";
67
+ import "./chunk-HNMXYYJR.js";
68
+ import {
69
+ selectCurrentServer
70
+ } from "./chunk-VX3SXJ3N.js";
71
+ import "./chunk-Y5GCAMGP.js";
72
+ import {
73
+ read
74
+ } from "./chunk-URUUZLPA.js";
75
+ import "./chunk-AZPCASRE.js";
76
+ import "./chunk-7U44LYTR.js";
77
+ import "./chunk-KX6YBIHG.js";
78
+ import "./chunk-O4BU24WZ.js";
79
+ import "./chunk-I42VC5KR.js";
80
+ import "./chunk-WWC7I6TA.js";
81
+ import "./chunk-QSJ3HFEF.js";
82
+ import "./chunk-DSZUWUYB.js";
83
+ import {
84
+ selectIdentityToken
85
+ } from "./chunk-UTLZINAP.js";
86
+ import "./chunk-OOSFSFMA.js";
87
+ import "./chunk-GBRG75BQ.js";
88
+ import "./chunk-4SN6J65J.js";
89
+ import "./chunk-LCBAMY2M.js";
90
+ import "./chunk-3EUW3WEO.js";
91
+ import "./chunk-U6VC4MU4.js";
92
+ import "./chunk-CF7PE763.js";
93
+ import "./chunk-G3SUCT4W.js";
94
+ import "./chunk-KUG52IAP.js";
95
+ import "./chunk-4VNS5WPM.js";
96
+
97
+ // packages/integrations/openai/chatCompletionStreamMode.ts
98
+ var applyChatCompletionsStreamMode = (body, stream) => {
99
+ const nextBody = { ...body, stream };
100
+ if (!stream) {
101
+ delete nextBody.stream_options;
102
+ }
103
+ return nextBody;
104
+ };
105
+
106
+ // packages/ai/agent/_executeModel.ts
107
+ var _executeModel = async (options, args, thunkApi) => {
108
+ const { isStreaming, withAgentContext, withChatHistory, agentConfigOverrides } = options;
109
+ const { getState, dispatch, rejectWithValue } = thunkApi;
110
+ const { content } = args;
111
+ const state = getState();
112
+ let agentConfig;
113
+ if (args.llmConfig) {
114
+ agentConfig = args.llmConfig;
115
+ } else if (args.agentConfig) {
116
+ agentConfig = args.agentConfig;
117
+ } else {
118
+ const agentKey = args.agentKey || selectCurrentDialogConfig(state)?.cybots?.[0];
119
+ if (!agentKey) {
120
+ const msg = "Model execution failed: No llmConfig, agentConfig, or agentKey provided.";
121
+ console.error(msg);
122
+ return rejectWithValue(msg);
123
+ }
124
+ try {
125
+ agentConfig = await dispatch(read({ dbKey: agentKey })).unwrap();
126
+ } catch (error) {
127
+ console.error(`_executeModel failed to load agent [${agentKey}]`, error);
128
+ return rejectWithValue(error.message);
129
+ }
130
+ }
131
+ try {
132
+ const resolvedConfig = agentConfigOverrides ? { ...agentConfig, ...agentConfigOverrides } : agentConfig;
133
+ const resolvedAgentConfig = resolvedConfig;
134
+ const agentContexts = withAgentContext ? await fetchAgentContexts(mergeReferences(resolvedAgentConfig.references, selectCurrentDialogConfig(state)?.extraReferences), dispatch) : {};
135
+ let messages;
136
+ if (withChatHistory) {
137
+ messages = filterAndCleanMessages(selectAllMsgs(state));
138
+ messages.push({ role: "user", content: args.content });
139
+ } else {
140
+ messages = [{ role: "user", content: args.content }];
141
+ }
142
+ const requestBody = generateRequestBody({
143
+ agentConfig: resolvedAgentConfig,
144
+ messages,
145
+ userInput: content,
146
+ contexts: agentContexts
147
+ });
148
+ const bodyData = applyChatCompletionsStreamMode(requestBody, isStreaming);
149
+ const currentDialogKey = selectCurrentDialogConfig(state)?.dbKey ?? "";
150
+ if (isStreaming) {
151
+ await sendOpenAICompletionsRequest({
152
+ bodyData,
153
+ agentConfig: resolvedAgentConfig,
154
+ thunkApi,
155
+ dialogKey: currentDialogKey,
156
+ parentMessageId: args.parentMessageId
157
+ });
158
+ } else {
159
+ const response = await performFetchRequest({
160
+ agentConfig: resolvedAgentConfig,
161
+ api: getApiEndpoint(resolvedAgentConfig),
162
+ bodyData,
163
+ currentServer: selectCurrentServer(state),
164
+ token: selectIdentityToken(state) ?? "",
165
+ dialogId: extractCustomId(args.billingDialogKey ?? currentDialogKey) || void 0
166
+ });
167
+ if (!response.ok) {
168
+ let message = `Model request failed with HTTP ${response.status}`;
169
+ try {
170
+ const errorBody = await response.json();
171
+ const upstreamMessage = typeof errorBody?.error?.message === "string" ? errorBody.error.message : typeof errorBody?.message === "string" ? errorBody.message : "";
172
+ if (upstreamMessage.trim()) message = upstreamMessage.trim();
173
+ } catch {
174
+ }
175
+ throw new Error(message);
176
+ }
177
+ const result = await response.json();
178
+ const content2 = result?.choices?.[0]?.message?.content;
179
+ if (typeof content2 !== "string") {
180
+ const upstreamMessage = typeof result?.error?.message === "string" ? result.error.message : "";
181
+ throw new Error(
182
+ upstreamMessage.trim() || "Model response missing choices[0].message.content"
183
+ );
184
+ }
185
+ if (args.billingDialogKey && result?.usage) {
186
+ await updateTokensAction(
187
+ {
188
+ dialogId: extractCustomId(args.billingDialogKey),
189
+ dialogKey: args.billingDialogKey,
190
+ usage: result.usage,
191
+ agentConfig: resolvedAgentConfig
192
+ },
193
+ thunkApi
194
+ );
195
+ }
196
+ return content2;
197
+ }
198
+ } catch (error) {
199
+ console.error(`_executeModel failed`, error);
200
+ return rejectWithValue(error.message);
201
+ }
202
+ };
203
+ export {
204
+ _executeModel
205
+ };
@@ -0,0 +1,28 @@
1
+ import {
2
+ shareResourceAction
3
+ } from "./chunk-25LCXTML.js";
4
+ import "./chunk-VX3SXJ3N.js";
5
+ import "./chunk-Y5GCAMGP.js";
6
+ import "./chunk-URUUZLPA.js";
7
+ import "./chunk-AZPCASRE.js";
8
+ import "./chunk-7U44LYTR.js";
9
+ import "./chunk-KX6YBIHG.js";
10
+ import "./chunk-O4BU24WZ.js";
11
+ import "./chunk-I42VC5KR.js";
12
+ import "./chunk-WWC7I6TA.js";
13
+ import "./chunk-QSJ3HFEF.js";
14
+ import "./chunk-DSZUWUYB.js";
15
+ import "./chunk-UTLZINAP.js";
16
+ import "./chunk-OOSFSFMA.js";
17
+ import "./chunk-GBRG75BQ.js";
18
+ import "./chunk-4SN6J65J.js";
19
+ import "./chunk-LCBAMY2M.js";
20
+ import "./chunk-3EUW3WEO.js";
21
+ import "./chunk-U6VC4MU4.js";
22
+ import "./chunk-CF7PE763.js";
23
+ import "./chunk-G3SUCT4W.js";
24
+ import "./chunk-KUG52IAP.js";
25
+ import "./chunk-4VNS5WPM.js";
26
+ export {
27
+ shareResourceAction
28
+ };
@@ -0,0 +1,26 @@
1
+ import {
2
+ addContentAction
3
+ } from "./chunk-I6XMPTMR.js";
4
+ import "./chunk-UAD2WT54.js";
5
+ import "./chunk-URUUZLPA.js";
6
+ import "./chunk-AZPCASRE.js";
7
+ import "./chunk-7U44LYTR.js";
8
+ import "./chunk-O4BU24WZ.js";
9
+ import "./chunk-I42VC5KR.js";
10
+ import "./chunk-WWC7I6TA.js";
11
+ import "./chunk-QSJ3HFEF.js";
12
+ import "./chunk-DSZUWUYB.js";
13
+ import "./chunk-UTLZINAP.js";
14
+ import "./chunk-OOSFSFMA.js";
15
+ import "./chunk-GBRG75BQ.js";
16
+ import "./chunk-4SN6J65J.js";
17
+ import "./chunk-LCBAMY2M.js";
18
+ import "./chunk-3EUW3WEO.js";
19
+ import "./chunk-U6VC4MU4.js";
20
+ import "./chunk-CF7PE763.js";
21
+ import "./chunk-G3SUCT4W.js";
22
+ import "./chunk-KUG52IAP.js";
23
+ import "./chunk-4VNS5WPM.js";
24
+ export {
25
+ addContentAction
26
+ };
@@ -0,0 +1,68 @@
1
+ import {
2
+ addDialogAgentIds
3
+ } from "./chunk-Z4NR32XR.js";
4
+ import {
5
+ require_date_fns
6
+ } from "./chunk-M76ECQRD.js";
7
+ import {
8
+ getActiveDialogKey
9
+ } from "./chunk-3ASDTTEI.js";
10
+ import {
11
+ patch,
12
+ selectById
13
+ } from "./chunk-URUUZLPA.js";
14
+ import "./chunk-AZPCASRE.js";
15
+ import "./chunk-7U44LYTR.js";
16
+ import "./chunk-O4BU24WZ.js";
17
+ import "./chunk-I42VC5KR.js";
18
+ import "./chunk-WWC7I6TA.js";
19
+ import "./chunk-QSJ3HFEF.js";
20
+ import "./chunk-DSZUWUYB.js";
21
+ import "./chunk-UTLZINAP.js";
22
+ import "./chunk-OOSFSFMA.js";
23
+ import "./chunk-GBRG75BQ.js";
24
+ import "./chunk-4SN6J65J.js";
25
+ import "./chunk-LCBAMY2M.js";
26
+ import "./chunk-3EUW3WEO.js";
27
+ import "./chunk-U6VC4MU4.js";
28
+ import "./chunk-CF7PE763.js";
29
+ import "./chunk-G3SUCT4W.js";
30
+ import "./chunk-KUG52IAP.js";
31
+ import {
32
+ __toESM
33
+ } from "./chunk-4VNS5WPM.js";
34
+
35
+ // packages/chat/dialog/actions/addDialogAgentAction.ts
36
+ var import_date_fns = __toESM(require_date_fns());
37
+ var addDialogAgentAction = async (agentIds, thunkApi) => {
38
+ const { dispatch, getState } = thunkApi;
39
+ const state = getState();
40
+ const currentDialogKey = getActiveDialogKey();
41
+ if (!currentDialogKey) {
42
+ throw new Error("No current dialog selected");
43
+ }
44
+ const dialogConfig = selectById(state, currentDialogKey);
45
+ if (!dialogConfig) {
46
+ throw new Error("Dialog configuration not found");
47
+ }
48
+ const idsToAdd = Array.isArray(agentIds) ? agentIds : [agentIds];
49
+ if (idsToAdd.length === 0) {
50
+ throw new Error("No agent IDs provided");
51
+ }
52
+ const validIds = idsToAdd.filter((id) => id && typeof id === "string");
53
+ if (validIds.length === 0) {
54
+ throw new Error("No valid agent IDs provided");
55
+ }
56
+ const updatedAgents = addDialogAgentIds(dialogConfig.cybots || [], validIds);
57
+ const changes = {
58
+ cybots: updatedAgents,
59
+ updatedAt: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date())
60
+ };
61
+ const updatedConfig = await dispatch(
62
+ patch({ dbKey: currentDialogKey, changes })
63
+ ).unwrap();
64
+ return updatedConfig;
65
+ };
66
+ export {
67
+ addDialogAgentAction
68
+ };
@@ -0,0 +1,327 @@
1
+ import {
2
+ deleteDbRecordOnServers
3
+ } from "./chunk-RL776AGR.js";
4
+ import {
5
+ getReadableCliDb
6
+ } from "./chunk-W4NVOSFF.js";
7
+ import {
8
+ resolveAgentRecordFromHybridStore
9
+ } from "./chunk-SDJDLO5W.js";
10
+ import "./chunk-N54XAP77.js";
11
+ import {
12
+ resolveCliAgentKeyInput
13
+ } from "./chunk-VHBWHNVT.js";
14
+ import "./chunk-KQHGZWSV.js";
15
+ import "./chunk-IDZTNRP2.js";
16
+ import {
17
+ parseUserIdFromAuthToken,
18
+ resolveAuthToken,
19
+ resolveDeleteServerCandidates,
20
+ resolveServerUrl
21
+ } from "./chunk-ISNCLGUZ.js";
22
+ import "./chunk-OLZBQWZU.js";
23
+ import "./chunk-O2ZNTTET.js";
24
+ import "./chunk-5KLGBAAR.js";
25
+ import "./chunk-ZNFJWEN4.js";
26
+ import "./chunk-TILFE6LV.js";
27
+ import "./chunk-4QEWT7KD.js";
28
+ import "./chunk-OPZYGHUC.js";
29
+ import "./chunk-AGFH73SK.js";
30
+ import "./chunk-JRKKFRAV.js";
31
+ import "./chunk-P3PKED2I.js";
32
+ import "./chunk-5MMAK75Q.js";
33
+ import "./chunk-BBYVOSU2.js";
34
+ import "./chunk-5CS33IBL.js";
35
+ import "./chunk-JZPBVBIY.js";
36
+ import "./chunk-IWX4UW2E.js";
37
+ import "./chunk-DWLEOOGR.js";
38
+ import {
39
+ Level
40
+ } from "./chunk-6WD3OOJS.js";
41
+ import {
42
+ toErrorMessage
43
+ } from "./chunk-HNMXYYJR.js";
44
+ import "./chunk-KX6YBIHG.js";
45
+ import "./chunk-O4BU24WZ.js";
46
+ import "./chunk-I42VC5KR.js";
47
+ import "./chunk-WWC7I6TA.js";
48
+ import "./chunk-QSJ3HFEF.js";
49
+ import "./chunk-GBRG75BQ.js";
50
+ import "./chunk-4SN6J65J.js";
51
+ import "./chunk-LCBAMY2M.js";
52
+ import "./chunk-3EUW3WEO.js";
53
+ import "./chunk-U6VC4MU4.js";
54
+ import "./chunk-CF7PE763.js";
55
+ import "./chunk-G3SUCT4W.js";
56
+ import "./chunk-KUG52IAP.js";
57
+ import "./chunk-4VNS5WPM.js";
58
+
59
+ // packages/cli/localLevelDbCleanup.ts
60
+ import fs from "node:fs";
61
+ import path from "node:path";
62
+ import os from "node:os";
63
+ async function clearAgentKeysFromLocalLevelDbs(args) {
64
+ const home = os.homedir();
65
+ const noloHome = process.env.NOLO_HOME?.trim() || path.join(home, ".nolo");
66
+ const dbPaths = [];
67
+ const cliDb = path.join(noloHome, "data", "leveldb");
68
+ if (fs.existsSync(cliDb)) dbPaths.push(cliDb);
69
+ const serverDbPath = process.env.NOLO_SERVER_DB_PATH?.trim();
70
+ if (serverDbPath && fs.existsSync(serverDbPath) && !dbPaths.includes(serverDbPath)) {
71
+ dbPaths.push(serverDbPath);
72
+ }
73
+ const cleaned = [];
74
+ for (const dbPath of dbPaths) {
75
+ try {
76
+ const db = new Level(dbPath, { valueEncoding: "json" });
77
+ await db.open();
78
+ try {
79
+ for (const key of args.keys) {
80
+ try {
81
+ await db.del(key);
82
+ } catch {
83
+ }
84
+ }
85
+ cleaned.push(dbPath);
86
+ } finally {
87
+ await db.close();
88
+ }
89
+ } catch {
90
+ }
91
+ }
92
+ return cleaned;
93
+ }
94
+
95
+ // packages/cli/agentDeleteCommand.ts
96
+ var AGENT_PRIVATE_KEY_RE = /^agent-([^-]+)-(.+)$/i;
97
+ var AGENT_PUBLIC_KEY_RE = /^agent-pub-(.+)$/i;
98
+ function hasFlag(args, flag) {
99
+ return args.includes(flag);
100
+ }
101
+ function readOption(args, flag) {
102
+ const idx = args.indexOf(flag);
103
+ return idx !== -1 ? args[idx + 1] : void 0;
104
+ }
105
+ function readAllPositional(args) {
106
+ const out = [];
107
+ for (let i = 0; i < args.length; i += 1) {
108
+ const a = args[i];
109
+ if (!a || a.startsWith("-")) continue;
110
+ out.push(a);
111
+ }
112
+ return out;
113
+ }
114
+ function extractAgentId(agentKey) {
115
+ const pub = agentKey.match(AGENT_PUBLIC_KEY_RE);
116
+ if (pub) return pub[1];
117
+ const priv = agentKey.match(AGENT_PRIVATE_KEY_RE);
118
+ if (priv) return priv[2];
119
+ return void 0;
120
+ }
121
+ function extractUserId(agentKey) {
122
+ const priv = agentKey.match(AGENT_PRIVATE_KEY_RE);
123
+ if (priv) return priv[1];
124
+ return void 0;
125
+ }
126
+ function buildAgentKeys(agentKey, fallbackUserId) {
127
+ const agentId = extractAgentId(agentKey);
128
+ if (!agentId) return null;
129
+ const privateUserId = extractUserId(agentKey) ?? fallbackUserId;
130
+ if (!privateUserId) return null;
131
+ return {
132
+ agentId,
133
+ privateKey: `agent-${privateUserId}-${agentId}`,
134
+ publicKey: `agent-pub-${agentId}`
135
+ };
136
+ }
137
+ function printUsage(output) {
138
+ output.write("Usage: nolo agent delete <agentId|agentKey|agentUrl> [--yes] [--json]\n");
139
+ output.write(
140
+ " nolo agent delete --id <agentId|agentKey|agentUrl> [--yes] [--json]\n"
141
+ );
142
+ output.write("\n");
143
+ output.write("\u5220\u9664\u4E00\u4E2A agent \u7684\u79C1\u6709\u8BB0\u5F55 (agent-{userId}-{id}) \u4E0E\u516C\u5F00\u8BB0\u5F55 (agent-pub-{id})\u3002\n");
144
+ output.write("\u670D\u52A1\u5668\u7AEF\u4E3A tombstone \u8F6F\u5220\u9664\uFF0CDELETE \u540E\u518D\u6B21 read \u4F1A\u8FD4\u56DE 404\u3002\n");
145
+ output.write("\n");
146
+ output.write("Flags:\n");
147
+ output.write(" --yes \u771F\u6B63\u6267\u884C\u5220\u9664\uFF1B\u7F3A\u7701\u65F6\u4EC5 dry-run \u8F93\u51FA\u76EE\u6807\u6458\u8981\u3002\n");
148
+ output.write(" --json \u8F93\u51FA JSON \u7ED3\u679C\u3002\n");
149
+ output.write(" --id <agent> \u4E0E\u4F4D\u7F6E\u53C2\u6570\u7B49\u4EF7\uFF0C\u4F20\u5165 alias / dbKey / URL / 26-char id\u3002\n");
150
+ output.write(" --server / --server-url \u4EC5\u5220\u9664\u6307\u5B9A\u670D\u52A1\u5668\uFF08\u4ECD\u4FDD\u7559\u96C6\u7FA4 fan-out \u4E4B\u5916\u7684\u526F\u672C\uFF09\u3002\n");
151
+ output.write(" --user <userId> \u663E\u5F0F\u8986\u76D6 userId\uFF08\u4E0E AUTH_TOKEN \u4E0D\u4E00\u81F4\u5219\u62A5\u9519\uFF09\u3002\n");
152
+ output.write(" --token / --machine-key \u4E34\u65F6\u8986\u76D6 AUTH_TOKEN\u3002\n");
153
+ output.write("\n");
154
+ output.write("Examples:\n");
155
+ output.write(" nolo agent delete 01MIMOREALPLUS0608 --yes\n");
156
+ output.write(" nolo agent delete https://nolo.chat/agent-0e95801d90-01MIMOREALPLUS0608 --yes --json\n");
157
+ }
158
+ async function runAgentDeleteCommand(args, deps = {}) {
159
+ const env = deps.env ?? process.env;
160
+ const output = deps.output ?? process.stdout;
161
+ if (hasFlag(args, "--help") || hasFlag(args, "-h")) {
162
+ printUsage(output);
163
+ return 0;
164
+ }
165
+ const explicitId = readOption(args, "--id");
166
+ const positionals = readAllPositional(args);
167
+ const agentInput = explicitId?.trim() || positionals[0]?.trim();
168
+ if (!agentInput) {
169
+ printUsage(output);
170
+ return 1;
171
+ }
172
+ const authToken = resolveAuthToken(args, env);
173
+ if (!authToken) {
174
+ output.write(
175
+ "[nolo] agent delete requires an auth token. Run `nolo login` or set AUTH_TOKEN.\n"
176
+ );
177
+ return 1;
178
+ }
179
+ const tokenUserId = parseUserIdFromAuthToken(authToken);
180
+ if (!tokenUserId) {
181
+ output.write(
182
+ "[nolo] agent delete could not read userId from AUTH_TOKEN.\n"
183
+ );
184
+ return 1;
185
+ }
186
+ const userOverride = readOption(args, "--user");
187
+ if (userOverride && userOverride !== tokenUserId) {
188
+ output.write(
189
+ `[nolo] agent delete --user (${userOverride}) does not match AUTH_TOKEN userId (${tokenUserId}).
190
+ `
191
+ );
192
+ return 1;
193
+ }
194
+ const agentKey = resolveCliAgentKeyInput(agentInput);
195
+ const db = deps.db ?? await getReadableCliDb(output);
196
+ const fetchImpl = deps.fetchImpl ?? fetch;
197
+ const fallbackFetchImpl = deps.fallbackFetchImpl;
198
+ const json = hasFlag(args, "--json");
199
+ const shouldDelete = hasFlag(args, "--yes");
200
+ const serverUrl = resolveServerUrl(args, env);
201
+ const serverUrls = resolveDeleteServerCandidates(args, env, serverUrl);
202
+ let resolved;
203
+ try {
204
+ resolved = await resolveAgentRecordFromHybridStore({
205
+ agentInput,
206
+ cliArgs: args,
207
+ env,
208
+ db,
209
+ fetchImpl,
210
+ fallbackFetchImpl
211
+ });
212
+ } catch (error) {
213
+ const msg = toErrorMessage(error);
214
+ output.write(`[nolo] agent delete failed to resolve "${agentInput}": ${msg}
215
+ `);
216
+ return 1;
217
+ }
218
+ if (!resolved) {
219
+ output.write(`[nolo] agent delete: agent not found: ${agentInput}
220
+ `);
221
+ return 1;
222
+ }
223
+ const keys = buildAgentKeys(resolved.agentKey, tokenUserId);
224
+ if (!keys) {
225
+ output.write(
226
+ `[nolo] agent delete: cannot derive agent id from resolved key ${resolved.agentKey}.
227
+ `
228
+ );
229
+ return 1;
230
+ }
231
+ const record = resolved.record;
232
+ const agentName = typeof record?.name === "string" && record.name.trim() ? record.name : "(unnamed)";
233
+ const resolvedBase = typeof record?.serverOrigin === "string" && record.serverOrigin ? record.serverOrigin : "";
234
+ let privateDeleteResults = [];
235
+ let publicDeleteResults = [];
236
+ if (shouldDelete) {
237
+ try {
238
+ privateDeleteResults = await deleteDbRecordOnServers({
239
+ authToken,
240
+ dbKey: keys.privateKey,
241
+ fetchImpl,
242
+ fallbackFetchImpl,
243
+ serverUrls
244
+ });
245
+ publicDeleteResults = await deleteDbRecordOnServers({
246
+ authToken,
247
+ dbKey: keys.publicKey,
248
+ fetchImpl,
249
+ fallbackFetchImpl,
250
+ serverUrls
251
+ });
252
+ } catch (error) {
253
+ const msg = toErrorMessage(error);
254
+ output.write(`[nolo] agent delete fan-out failed: ${msg}
255
+ `);
256
+ return 1;
257
+ }
258
+ }
259
+ if (shouldDelete) {
260
+ try {
261
+ const cleanedPaths = await clearAgentKeysFromLocalLevelDbs({
262
+ keys: [keys.privateKey, keys.publicKey]
263
+ });
264
+ if (cleanedPaths.length > 0 && !json) {
265
+ output.write(`Cleaned local LevelDB copies: ${cleanedPaths.length}
266
+ `);
267
+ }
268
+ } catch (error) {
269
+ const msg = toErrorMessage(error);
270
+ if (!json) output.write(`[nolo] local LevelDB cleanup skipped: ${msg}
271
+ `);
272
+ }
273
+ }
274
+ const allResults = [...privateDeleteResults, ...publicDeleteResults];
275
+ const failed = allResults.filter((r) => !r.ok);
276
+ const succeededCount = allResults.length - failed.length;
277
+ const payload = {
278
+ agentKey: resolved.agentKey,
279
+ agentName,
280
+ agentId: keys.agentId,
281
+ privateKey: keys.privateKey,
282
+ publicKey: keys.publicKey,
283
+ resolvedBase: resolvedBase || null,
284
+ targetServers: serverUrls,
285
+ dryRun: !shouldDelete,
286
+ deleted: shouldDelete,
287
+ deleteResults: shouldDelete ? {
288
+ private: privateDeleteResults,
289
+ public: publicDeleteResults
290
+ } : void 0
291
+ };
292
+ if (json) {
293
+ output.write(JSON.stringify(payload, null, 2));
294
+ output.write("\n");
295
+ } else {
296
+ output.write(`agent: ${agentName}
297
+ `);
298
+ output.write(`agentKey: ${resolved.agentKey}
299
+ `);
300
+ output.write(`privateKey: ${keys.privateKey}
301
+ `);
302
+ output.write(`publicKey: ${keys.publicKey}
303
+ `);
304
+ output.write(`targetServers: ${serverUrls.join(", ")}
305
+ `);
306
+ if (resolvedBase) output.write(`resolvedBase: ${resolvedBase}
307
+ `);
308
+ if (!shouldDelete) {
309
+ output.write(
310
+ "\nDry-run only. Re-run with --yes to tombstone this agent on the target servers.\n"
311
+ );
312
+ } else {
313
+ if (privateDeleteResults.length || publicDeleteResults.length) {
314
+ output.write(
315
+ `Deleted on ${succeededCount}/${allResults.length} targets. ${failed.length ? `Failures: ${failed.map((r) => `${r.dbKey ?? ""}@${r.serverUrl} (${r.error ?? "unknown"})`).join("; ")}` : ""}
316
+ `
317
+ );
318
+ } else {
319
+ output.write("No delete requests issued.\n");
320
+ }
321
+ }
322
+ }
323
+ return failed.length > 0 ? 1 : 0;
324
+ }
325
+ export {
326
+ runAgentDeleteCommand
327
+ };