nolo-cli 0.8.0-alpha.5 → 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.
- package/_executeModel-XIGO7HW5.js +198 -0
- package/action-PAXRPJJF.js +27 -0
- package/addContentAction-CZVWF3QZ.js +25 -0
- package/addDialogAgentAction-CCIDTPHC.js +67 -0
- package/agentDeleteCommand-47B24JYG.js +323 -0
- package/agentEmailCommands-D4FC6OZJ.js +621 -0
- package/agentListCommands-UFET7CC4.js +219 -0
- package/agentMachineCommands-LH7QDQPP.js +421 -0
- package/agentPullCommand-O2MTUAFR.js +122 -0
- package/agentRecordCommands-CWS2B5IA.js +89 -0
- package/agentRunCommand-3FRPISLG.js +102 -0
- package/agentRunControl-K4VKNEHF.js +57 -0
- package/agentRuntimeLocal-JNQQC2WG.js +99 -0
- package/agentSlice-XDFSELFJ.js +41 -0
- package/authCommand-WXMD3IPR.js +574 -0
- package/authCommands-X74AFDTC.js +26 -0
- package/chunk-2EISRLRC.js +238 -0
- package/chunk-2FTTDCD4.js +675 -0
- package/chunk-2JHWPW5B.js +2127 -0
- package/chunk-2LMT6K6N.js +171 -0
- package/chunk-2MALU52L.js +51 -0
- package/chunk-364VYAX2.js +19 -0
- package/chunk-3ASDTTEI.js +1774 -0
- package/chunk-3EUW3WEO.js +8 -0
- package/chunk-3LY4F7SV.js +9293 -0
- package/chunk-4CQLVGRV.js +50 -0
- package/chunk-4IJYA27C.js +342 -0
- package/chunk-4SN6J65J.js +38 -0
- package/chunk-4VNS5WPM.js +42 -0
- package/chunk-543C7RDK.js +562 -0
- package/chunk-572EKYLF.js +792 -0
- package/chunk-5MIDPSSK.js +206 -0
- package/chunk-5MMAK75Q.js +15 -0
- package/chunk-5XH3NZ4T.js +3631 -0
- package/chunk-63W5N6P3.js +150 -0
- package/chunk-6HYVJV7B.js +102 -0
- package/chunk-6PWWWMI7.js +628 -0
- package/chunk-6WD3OOJS.js +20 -0
- package/chunk-A3X4Y7MO.js +4294 -0
- package/chunk-AR7ZSGDI.js +929 -0
- package/chunk-ATNTHIZI.js +13 -0
- package/chunk-AUGHVUFE.js +69 -0
- package/chunk-AVMKZHBC.js +85 -0
- package/chunk-AZPCASRE.js +36 -0
- package/chunk-B76D3JJK.js +1447 -0
- package/chunk-BR2WP3DF.js +548 -0
- package/chunk-BSTNFPHD.js +231 -0
- package/chunk-CF2WZF4N.js +134 -0
- package/chunk-CF7PE763.js +10 -0
- package/chunk-CKOJQDKR.js +198 -0
- package/chunk-CM54RSSA.js +206 -0
- package/chunk-CWMSB67P.js +34 -0
- package/chunk-DA2OEKS6.js +27 -0
- package/chunk-DFFIZ25G.js +30 -0
- package/chunk-DWLEOOGR.js +8 -0
- package/chunk-DZ3XJVET.js +231 -0
- package/chunk-E5HMHIKL.js +222 -0
- package/chunk-EHLHSX7R.js +1433 -0
- package/chunk-ELRRLDWI.js +478 -0
- package/chunk-EYEEHCU4.js +3066 -0
- package/chunk-G3SUCT4W.js +8 -0
- package/chunk-G5H7RNFL.js +807 -0
- package/chunk-GAKEBQD6.js +30 -0
- package/chunk-GBRG75BQ.js +86 -0
- package/chunk-GEKCOPTN.js +190 -0
- package/chunk-H2RMRZJE.js +113 -0
- package/chunk-H33743XH.js +25 -0
- package/chunk-HEIIIZBX.js +104 -0
- package/chunk-HNMXYYJR.js +12 -0
- package/chunk-IAXBCTTE.js +175 -0
- package/chunk-IDZTNRP2.js +85 -0
- package/chunk-IECI4YHR.js +421 -0
- package/chunk-ISNCLGUZ.js +146 -0
- package/chunk-IYQV26RA.js +138 -0
- package/chunk-JBTJAPUF.js +35 -0
- package/chunk-JZPBVBIY.js +94 -0
- package/chunk-KK6SWS5B.js +1078 -0
- package/chunk-KQHGZWSV.js +63 -0
- package/chunk-KTI2WDDG.js +24674 -0
- package/chunk-KUG52IAP.js +8 -0
- package/chunk-KX6YBIHG.js +8 -0
- package/chunk-LCBAMY2M.js +60 -0
- package/chunk-LM25IZBJ.js +902 -0
- package/chunk-LM6IYQ3F.js +16 -0
- package/chunk-M76ECQRD.js +13658 -0
- package/chunk-MRC4Q34M.js +188 -0
- package/chunk-NE3E3XJ2.js +936 -0
- package/chunk-NXZGF7F7.js +2878 -0
- package/chunk-OF5H3QWS.js +300 -0
- package/chunk-OLZBQWZU.js +6 -0
- package/chunk-OVGXXUVI.js +91 -0
- package/chunk-OWOHNGCN.js +50 -0
- package/chunk-PN7AFLOK.js +3401 -0
- package/chunk-QSJ3HFEF.js +8 -0
- package/chunk-QYXLLLGL.js +4519 -0
- package/chunk-ROWQEJRP.js +139 -0
- package/chunk-S7Z2HMCN.js +25 -0
- package/chunk-SL3EPWB4.js +1949 -0
- package/chunk-TDIQFT2F.js +301 -0
- package/chunk-TILFE6LV.js +381 -0
- package/chunk-U4TRT5V4.js +246 -0
- package/chunk-U6VC4MU4.js +8 -0
- package/chunk-UAD2WT54.js +64 -0
- package/chunk-USZDUWOV.js +191 -0
- package/chunk-USZMK5UT.js +105 -0
- package/chunk-UVPF33PW.js +46995 -0
- package/chunk-V2F4OGYM.js +9013 -0
- package/chunk-VEJLAVTC.js +2052 -0
- package/chunk-VF4K2QE6.js +21 -0
- package/chunk-VHBWHNVT.js +59 -0
- package/chunk-VIDPVFP3.js +20 -0
- package/chunk-VP4WJWKW.js +8882 -0
- package/chunk-VQ2AJRGD.js +148 -0
- package/chunk-W4NVOSFF.js +37 -0
- package/chunk-WWC7I6TA.js +8 -0
- package/chunk-X7W4TNB4.js +1550 -0
- package/chunk-XDVAYP26.js +537 -0
- package/chunk-XKIMRZO2.js +221 -0
- package/chunk-Y5GCAMGP.js +9 -0
- package/chunk-YD43KPCK.js +360 -0
- package/chunk-YIJFUVKA.js +34 -0
- package/chunk-Z4NR32XR.js +50 -0
- package/chunk-ZNFJWEN4.js +56 -0
- package/cliExecutor-DNE7TCC4.js +36 -0
- package/clipboardy-BVE3LVEH.js +12001 -0
- package/createAgentAutomationAction-3QTGNYJC.js +864 -0
- package/createDialogAction-5YX3ARBK.js +52 -0
- package/createPageAction-EQNQQRCW.js +169 -0
- package/db-HCJ5PRB5.js +271 -0
- package/dbSlice-C4UJLRZP.js +59 -0
- package/deleteFile-4SKGPHOZ.js +41 -0
- package/dialogCommands-AOQS23FV.js +59 -0
- package/dialogSlice-GZE3NCMC.js +146 -0
- package/docCreateCommands-GVOQVJON.js +215 -0
- package/docDeleteCommands-GEB7YAUZ.js +176 -0
- package/docReadCommands-XYKI2DF2.js +129 -0
- package/docStore-MLM5AME5.js +96 -0
- package/docUpdateCommands-4L3RAMHZ.js +313 -0
- package/fetchMessages-JOCYIFKL.js +16 -0
- package/getPricing-PWPJ6MNV.js +30 -0
- package/handleSendMessageAction-WG2GKTGZ.js +183 -0
- package/index.js +184 -112986
- package/localDialogRead-D3BELSTF.js +26 -0
- package/localFirstLog-DHNOY2NA.js +19 -0
- package/localRuntimeAuthority-TEGCOWX4.js +471 -0
- package/localRuntimeDb-LGDF6FQP.js +12 -0
- package/machineCommands-ZNXKLH6Q.js +774 -0
- package/machineInfo-M6KB6HZN.js +10 -0
- package/machineWsRunDispatch-7WRG6HNV.js +105 -0
- package/memoryCommands-O4MIPIWQ.js +476 -0
- package/models-XLEOET3E.js +9 -0
- package/offlineMarxistsAgentCommand-BCPJITJL.js +242 -0
- package/package.json +3 -25
- package/read-RIJCIVKX.js +17 -0
- package/readDocTool-GZD2N3LO.js +16 -0
- package/readlineWorkspace-AQURUDN4.js +5357 -0
- package/removeDialogAgentAction-CXLST3N6.js +72 -0
- package/runAgentClientLoop-VQUEKGA5.js +288 -0
- package/runtimeDoctorCommands-LRHLPDRC.js +289 -0
- package/setDialogExtraReferencesAction-LP6VYGU7.js +59 -0
- package/setPrimaryDialogAgentAction-D3GGH23T.js +79 -0
- package/settingSlice-J4I3Z5H7.js +198 -0
- package/skillSummaryMarker-42HKSXYY.js +9 -0
- package/slateToRenderMarkdown-Y5IYN73U.js +7 -0
- package/slateUtils-2M7MUTWX.js +19 -0
- package/spaceCommands-R2RXD5UY.js +450 -0
- package/spaceSlice-5UT4JNIN.js +145 -0
- package/streamAgentChatTurn-NRWSQKFN.js +4503 -0
- package/tableCommands-66XEWHAK.js +1286 -0
- package/toolApiClient-QI3YBNWB.js +26 -0
- package/tools-TNMUDDRK.js +83 -0
- package/understanding-HCSFPE7R.js +318 -0
- package/updateCommands-VOSPKXFF.js +31 -0
- package/updateDialogTitleAction-IXOKAVX3.js +185 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
filterAndCleanMessages,
|
|
3
|
+
sendOpenAICompletionsRequest
|
|
4
|
+
} from "./chunk-SL3EPWB4.js";
|
|
5
|
+
import "./chunk-2LMT6K6N.js";
|
|
6
|
+
import "./chunk-VIDPVFP3.js";
|
|
7
|
+
import {
|
|
8
|
+
fetchAgentContexts
|
|
9
|
+
} from "./chunk-YIJFUVKA.js";
|
|
10
|
+
import {
|
|
11
|
+
generateRequestBody,
|
|
12
|
+
mergeReferences,
|
|
13
|
+
performFetchRequest
|
|
14
|
+
} from "./chunk-2JHWPW5B.js";
|
|
15
|
+
import "./chunk-DA2OEKS6.js";
|
|
16
|
+
import "./chunk-2MALU52L.js";
|
|
17
|
+
import "./chunk-UVPF33PW.js";
|
|
18
|
+
import "./chunk-GAKEBQD6.js";
|
|
19
|
+
import "./chunk-KQHGZWSV.js";
|
|
20
|
+
import "./chunk-XKIMRZO2.js";
|
|
21
|
+
import "./chunk-3LY4F7SV.js";
|
|
22
|
+
import "./chunk-VP4WJWKW.js";
|
|
23
|
+
import "./chunk-63W5N6P3.js";
|
|
24
|
+
import "./chunk-IECI4YHR.js";
|
|
25
|
+
import "./chunk-AR7ZSGDI.js";
|
|
26
|
+
import "./chunk-NXZGF7F7.js";
|
|
27
|
+
import "./chunk-HEIIIZBX.js";
|
|
28
|
+
import {
|
|
29
|
+
selectAllMsgs,
|
|
30
|
+
selectCurrentDialogConfig,
|
|
31
|
+
updateTokensAction
|
|
32
|
+
} from "./chunk-KTI2WDDG.js";
|
|
33
|
+
import "./chunk-MRC4Q34M.js";
|
|
34
|
+
import "./chunk-OVGXXUVI.js";
|
|
35
|
+
import "./chunk-CWMSB67P.js";
|
|
36
|
+
import "./chunk-543C7RDK.js";
|
|
37
|
+
import "./chunk-IYQV26RA.js";
|
|
38
|
+
import "./chunk-Z4NR32XR.js";
|
|
39
|
+
import "./chunk-M76ECQRD.js";
|
|
40
|
+
import "./chunk-AUGHVUFE.js";
|
|
41
|
+
import "./chunk-H2RMRZJE.js";
|
|
42
|
+
import "./chunk-UAD2WT54.js";
|
|
43
|
+
import "./chunk-USZMK5UT.js";
|
|
44
|
+
import "./chunk-NE3E3XJ2.js";
|
|
45
|
+
import "./chunk-XDVAYP26.js";
|
|
46
|
+
import "./chunk-LM25IZBJ.js";
|
|
47
|
+
import "./chunk-5MMAK75Q.js";
|
|
48
|
+
import {
|
|
49
|
+
getApiEndpoint
|
|
50
|
+
} from "./chunk-572EKYLF.js";
|
|
51
|
+
import "./chunk-TDIQFT2F.js";
|
|
52
|
+
import "./chunk-JZPBVBIY.js";
|
|
53
|
+
import "./chunk-BR2WP3DF.js";
|
|
54
|
+
import "./chunk-5MIDPSSK.js";
|
|
55
|
+
import {
|
|
56
|
+
extractCustomId
|
|
57
|
+
} from "./chunk-DFFIZ25G.js";
|
|
58
|
+
import "./chunk-3ASDTTEI.js";
|
|
59
|
+
import "./chunk-DWLEOOGR.js";
|
|
60
|
+
import "./chunk-HNMXYYJR.js";
|
|
61
|
+
import "./chunk-IAXBCTTE.js";
|
|
62
|
+
import {
|
|
63
|
+
selectCurrentServer
|
|
64
|
+
} from "./chunk-VEJLAVTC.js";
|
|
65
|
+
import "./chunk-Y5GCAMGP.js";
|
|
66
|
+
import {
|
|
67
|
+
read
|
|
68
|
+
} from "./chunk-G5H7RNFL.js";
|
|
69
|
+
import "./chunk-AZPCASRE.js";
|
|
70
|
+
import "./chunk-2EISRLRC.js";
|
|
71
|
+
import "./chunk-KX6YBIHG.js";
|
|
72
|
+
import "./chunk-PN7AFLOK.js";
|
|
73
|
+
import "./chunk-WWC7I6TA.js";
|
|
74
|
+
import "./chunk-QSJ3HFEF.js";
|
|
75
|
+
import "./chunk-ELRRLDWI.js";
|
|
76
|
+
import {
|
|
77
|
+
selectIdentityToken
|
|
78
|
+
} from "./chunk-EYEEHCU4.js";
|
|
79
|
+
import "./chunk-QYXLLLGL.js";
|
|
80
|
+
import "./chunk-GBRG75BQ.js";
|
|
81
|
+
import "./chunk-4SN6J65J.js";
|
|
82
|
+
import "./chunk-LCBAMY2M.js";
|
|
83
|
+
import "./chunk-3EUW3WEO.js";
|
|
84
|
+
import "./chunk-U6VC4MU4.js";
|
|
85
|
+
import "./chunk-CF7PE763.js";
|
|
86
|
+
import "./chunk-G3SUCT4W.js";
|
|
87
|
+
import "./chunk-KUG52IAP.js";
|
|
88
|
+
import "./chunk-4VNS5WPM.js";
|
|
89
|
+
|
|
90
|
+
// packages/integrations/openai/chatCompletionStreamMode.ts
|
|
91
|
+
var applyChatCompletionsStreamMode = (body, stream) => {
|
|
92
|
+
const nextBody = { ...body, stream };
|
|
93
|
+
if (!stream) {
|
|
94
|
+
delete nextBody.stream_options;
|
|
95
|
+
}
|
|
96
|
+
return nextBody;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
// packages/ai/agent/_executeModel.ts
|
|
100
|
+
var _executeModel = async (options, args, thunkApi) => {
|
|
101
|
+
const { isStreaming, withAgentContext, withChatHistory, agentConfigOverrides } = options;
|
|
102
|
+
const { getState, dispatch, rejectWithValue } = thunkApi;
|
|
103
|
+
const { content } = args;
|
|
104
|
+
const state = getState();
|
|
105
|
+
let agentConfig;
|
|
106
|
+
if (args.llmConfig) {
|
|
107
|
+
agentConfig = args.llmConfig;
|
|
108
|
+
} else if (args.agentConfig) {
|
|
109
|
+
agentConfig = args.agentConfig;
|
|
110
|
+
} else {
|
|
111
|
+
const agentKey = args.agentKey || selectCurrentDialogConfig(state)?.cybots?.[0];
|
|
112
|
+
if (!agentKey) {
|
|
113
|
+
const msg = "Model execution failed: No llmConfig, agentConfig, or agentKey provided.";
|
|
114
|
+
console.error(msg);
|
|
115
|
+
return rejectWithValue(msg);
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
agentConfig = await dispatch(read({ dbKey: agentKey })).unwrap();
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error(`_executeModel failed to load agent [${agentKey}]`, error);
|
|
121
|
+
return rejectWithValue(error.message);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const resolvedConfig = agentConfigOverrides ? { ...agentConfig, ...agentConfigOverrides } : agentConfig;
|
|
126
|
+
const resolvedAgentConfig = resolvedConfig;
|
|
127
|
+
const agentContexts = withAgentContext ? await fetchAgentContexts(mergeReferences(resolvedAgentConfig.references, selectCurrentDialogConfig(state)?.extraReferences), dispatch) : {};
|
|
128
|
+
let messages;
|
|
129
|
+
if (withChatHistory) {
|
|
130
|
+
messages = filterAndCleanMessages(selectAllMsgs(state));
|
|
131
|
+
messages.push({ role: "user", content: args.content });
|
|
132
|
+
} else {
|
|
133
|
+
messages = [{ role: "user", content: args.content }];
|
|
134
|
+
}
|
|
135
|
+
const requestBody = generateRequestBody({
|
|
136
|
+
agentConfig: resolvedAgentConfig,
|
|
137
|
+
messages,
|
|
138
|
+
userInput: content,
|
|
139
|
+
contexts: agentContexts
|
|
140
|
+
});
|
|
141
|
+
const bodyData = applyChatCompletionsStreamMode(requestBody, isStreaming);
|
|
142
|
+
const currentDialogKey = selectCurrentDialogConfig(state)?.dbKey ?? "";
|
|
143
|
+
if (isStreaming) {
|
|
144
|
+
await sendOpenAICompletionsRequest({
|
|
145
|
+
bodyData,
|
|
146
|
+
agentConfig: resolvedAgentConfig,
|
|
147
|
+
thunkApi,
|
|
148
|
+
dialogKey: currentDialogKey,
|
|
149
|
+
parentMessageId: args.parentMessageId
|
|
150
|
+
});
|
|
151
|
+
} else {
|
|
152
|
+
const response = await performFetchRequest({
|
|
153
|
+
agentConfig: resolvedAgentConfig,
|
|
154
|
+
api: getApiEndpoint(resolvedAgentConfig),
|
|
155
|
+
bodyData,
|
|
156
|
+
currentServer: selectCurrentServer(state),
|
|
157
|
+
token: selectIdentityToken(state) ?? "",
|
|
158
|
+
dialogId: extractCustomId(args.billingDialogKey ?? currentDialogKey) || void 0
|
|
159
|
+
});
|
|
160
|
+
if (!response.ok) {
|
|
161
|
+
let message = `Model request failed with HTTP ${response.status}`;
|
|
162
|
+
try {
|
|
163
|
+
const errorBody = await response.json();
|
|
164
|
+
const upstreamMessage = typeof errorBody?.error?.message === "string" ? errorBody.error.message : typeof errorBody?.message === "string" ? errorBody.message : "";
|
|
165
|
+
if (upstreamMessage.trim()) message = upstreamMessage.trim();
|
|
166
|
+
} catch {
|
|
167
|
+
}
|
|
168
|
+
throw new Error(message);
|
|
169
|
+
}
|
|
170
|
+
const result = await response.json();
|
|
171
|
+
const content2 = result?.choices?.[0]?.message?.content;
|
|
172
|
+
if (typeof content2 !== "string") {
|
|
173
|
+
const upstreamMessage = typeof result?.error?.message === "string" ? result.error.message : "";
|
|
174
|
+
throw new Error(
|
|
175
|
+
upstreamMessage.trim() || "Model response missing choices[0].message.content"
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
if (args.billingDialogKey && result?.usage) {
|
|
179
|
+
await updateTokensAction(
|
|
180
|
+
{
|
|
181
|
+
dialogId: extractCustomId(args.billingDialogKey),
|
|
182
|
+
dialogKey: args.billingDialogKey,
|
|
183
|
+
usage: result.usage,
|
|
184
|
+
agentConfig: resolvedAgentConfig
|
|
185
|
+
},
|
|
186
|
+
thunkApi
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return content2;
|
|
190
|
+
}
|
|
191
|
+
} catch (error) {
|
|
192
|
+
console.error(`_executeModel failed`, error);
|
|
193
|
+
return rejectWithValue(error.message);
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
export {
|
|
197
|
+
_executeModel
|
|
198
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
shareResourceAction
|
|
3
|
+
} from "./chunk-IAXBCTTE.js";
|
|
4
|
+
import "./chunk-VEJLAVTC.js";
|
|
5
|
+
import "./chunk-Y5GCAMGP.js";
|
|
6
|
+
import "./chunk-G5H7RNFL.js";
|
|
7
|
+
import "./chunk-AZPCASRE.js";
|
|
8
|
+
import "./chunk-2EISRLRC.js";
|
|
9
|
+
import "./chunk-KX6YBIHG.js";
|
|
10
|
+
import "./chunk-PN7AFLOK.js";
|
|
11
|
+
import "./chunk-WWC7I6TA.js";
|
|
12
|
+
import "./chunk-QSJ3HFEF.js";
|
|
13
|
+
import "./chunk-ELRRLDWI.js";
|
|
14
|
+
import "./chunk-EYEEHCU4.js";
|
|
15
|
+
import "./chunk-QYXLLLGL.js";
|
|
16
|
+
import "./chunk-GBRG75BQ.js";
|
|
17
|
+
import "./chunk-4SN6J65J.js";
|
|
18
|
+
import "./chunk-LCBAMY2M.js";
|
|
19
|
+
import "./chunk-3EUW3WEO.js";
|
|
20
|
+
import "./chunk-U6VC4MU4.js";
|
|
21
|
+
import "./chunk-CF7PE763.js";
|
|
22
|
+
import "./chunk-G3SUCT4W.js";
|
|
23
|
+
import "./chunk-KUG52IAP.js";
|
|
24
|
+
import "./chunk-4VNS5WPM.js";
|
|
25
|
+
export {
|
|
26
|
+
shareResourceAction
|
|
27
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addContentAction
|
|
3
|
+
} from "./chunk-H2RMRZJE.js";
|
|
4
|
+
import "./chunk-UAD2WT54.js";
|
|
5
|
+
import "./chunk-G5H7RNFL.js";
|
|
6
|
+
import "./chunk-AZPCASRE.js";
|
|
7
|
+
import "./chunk-2EISRLRC.js";
|
|
8
|
+
import "./chunk-PN7AFLOK.js";
|
|
9
|
+
import "./chunk-WWC7I6TA.js";
|
|
10
|
+
import "./chunk-QSJ3HFEF.js";
|
|
11
|
+
import "./chunk-ELRRLDWI.js";
|
|
12
|
+
import "./chunk-EYEEHCU4.js";
|
|
13
|
+
import "./chunk-QYXLLLGL.js";
|
|
14
|
+
import "./chunk-GBRG75BQ.js";
|
|
15
|
+
import "./chunk-4SN6J65J.js";
|
|
16
|
+
import "./chunk-LCBAMY2M.js";
|
|
17
|
+
import "./chunk-3EUW3WEO.js";
|
|
18
|
+
import "./chunk-U6VC4MU4.js";
|
|
19
|
+
import "./chunk-CF7PE763.js";
|
|
20
|
+
import "./chunk-G3SUCT4W.js";
|
|
21
|
+
import "./chunk-KUG52IAP.js";
|
|
22
|
+
import "./chunk-4VNS5WPM.js";
|
|
23
|
+
export {
|
|
24
|
+
addContentAction
|
|
25
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
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-G5H7RNFL.js";
|
|
14
|
+
import "./chunk-AZPCASRE.js";
|
|
15
|
+
import "./chunk-2EISRLRC.js";
|
|
16
|
+
import "./chunk-PN7AFLOK.js";
|
|
17
|
+
import "./chunk-WWC7I6TA.js";
|
|
18
|
+
import "./chunk-QSJ3HFEF.js";
|
|
19
|
+
import "./chunk-ELRRLDWI.js";
|
|
20
|
+
import "./chunk-EYEEHCU4.js";
|
|
21
|
+
import "./chunk-QYXLLLGL.js";
|
|
22
|
+
import "./chunk-GBRG75BQ.js";
|
|
23
|
+
import "./chunk-4SN6J65J.js";
|
|
24
|
+
import "./chunk-LCBAMY2M.js";
|
|
25
|
+
import "./chunk-3EUW3WEO.js";
|
|
26
|
+
import "./chunk-U6VC4MU4.js";
|
|
27
|
+
import "./chunk-CF7PE763.js";
|
|
28
|
+
import "./chunk-G3SUCT4W.js";
|
|
29
|
+
import "./chunk-KUG52IAP.js";
|
|
30
|
+
import {
|
|
31
|
+
__toESM
|
|
32
|
+
} from "./chunk-4VNS5WPM.js";
|
|
33
|
+
|
|
34
|
+
// packages/chat/dialog/actions/addDialogAgentAction.ts
|
|
35
|
+
var import_date_fns = __toESM(require_date_fns());
|
|
36
|
+
var addDialogAgentAction = async (agentIds, thunkApi) => {
|
|
37
|
+
const { dispatch, getState } = thunkApi;
|
|
38
|
+
const state = getState();
|
|
39
|
+
const currentDialogKey = getActiveDialogKey();
|
|
40
|
+
if (!currentDialogKey) {
|
|
41
|
+
throw new Error("No current dialog selected");
|
|
42
|
+
}
|
|
43
|
+
const dialogConfig = selectById(state, currentDialogKey);
|
|
44
|
+
if (!dialogConfig) {
|
|
45
|
+
throw new Error("Dialog configuration not found");
|
|
46
|
+
}
|
|
47
|
+
const idsToAdd = Array.isArray(agentIds) ? agentIds : [agentIds];
|
|
48
|
+
if (idsToAdd.length === 0) {
|
|
49
|
+
throw new Error("No agent IDs provided");
|
|
50
|
+
}
|
|
51
|
+
const validIds = idsToAdd.filter((id) => id && typeof id === "string");
|
|
52
|
+
if (validIds.length === 0) {
|
|
53
|
+
throw new Error("No valid agent IDs provided");
|
|
54
|
+
}
|
|
55
|
+
const updatedAgents = addDialogAgentIds(dialogConfig.cybots || [], validIds);
|
|
56
|
+
const changes = {
|
|
57
|
+
cybots: updatedAgents,
|
|
58
|
+
updatedAt: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date())
|
|
59
|
+
};
|
|
60
|
+
const updatedConfig = await dispatch(
|
|
61
|
+
patch({ dbKey: currentDialogKey, changes })
|
|
62
|
+
).unwrap();
|
|
63
|
+
return updatedConfig;
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
addDialogAgentAction
|
|
67
|
+
};
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deleteDbRecordOnServers
|
|
3
|
+
} from "./chunk-GEKCOPTN.js";
|
|
4
|
+
import {
|
|
5
|
+
getReadableCliDb
|
|
6
|
+
} from "./chunk-W4NVOSFF.js";
|
|
7
|
+
import {
|
|
8
|
+
resolveAgentRecordFromHybridStore
|
|
9
|
+
} from "./chunk-6PWWWMI7.js";
|
|
10
|
+
import "./chunk-364VYAX2.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-5XH3NZ4T.js";
|
|
24
|
+
import "./chunk-ZNFJWEN4.js";
|
|
25
|
+
import "./chunk-TILFE6LV.js";
|
|
26
|
+
import "./chunk-NE3E3XJ2.js";
|
|
27
|
+
import "./chunk-XDVAYP26.js";
|
|
28
|
+
import "./chunk-LM25IZBJ.js";
|
|
29
|
+
import "./chunk-5MMAK75Q.js";
|
|
30
|
+
import "./chunk-572EKYLF.js";
|
|
31
|
+
import "./chunk-TDIQFT2F.js";
|
|
32
|
+
import "./chunk-JZPBVBIY.js";
|
|
33
|
+
import "./chunk-BR2WP3DF.js";
|
|
34
|
+
import "./chunk-DWLEOOGR.js";
|
|
35
|
+
import {
|
|
36
|
+
Level
|
|
37
|
+
} from "./chunk-6WD3OOJS.js";
|
|
38
|
+
import {
|
|
39
|
+
toErrorMessage
|
|
40
|
+
} from "./chunk-HNMXYYJR.js";
|
|
41
|
+
import "./chunk-KX6YBIHG.js";
|
|
42
|
+
import "./chunk-PN7AFLOK.js";
|
|
43
|
+
import "./chunk-WWC7I6TA.js";
|
|
44
|
+
import "./chunk-QSJ3HFEF.js";
|
|
45
|
+
import "./chunk-GBRG75BQ.js";
|
|
46
|
+
import "./chunk-4SN6J65J.js";
|
|
47
|
+
import "./chunk-LCBAMY2M.js";
|
|
48
|
+
import "./chunk-3EUW3WEO.js";
|
|
49
|
+
import "./chunk-U6VC4MU4.js";
|
|
50
|
+
import "./chunk-CF7PE763.js";
|
|
51
|
+
import "./chunk-G3SUCT4W.js";
|
|
52
|
+
import "./chunk-KUG52IAP.js";
|
|
53
|
+
import "./chunk-4VNS5WPM.js";
|
|
54
|
+
|
|
55
|
+
// packages/cli/localLevelDbCleanup.ts
|
|
56
|
+
import fs from "node:fs";
|
|
57
|
+
import path from "node:path";
|
|
58
|
+
import os from "node:os";
|
|
59
|
+
async function clearAgentKeysFromLocalLevelDbs(args) {
|
|
60
|
+
const home = os.homedir();
|
|
61
|
+
const noloHome = process.env.NOLO_HOME?.trim() || path.join(home, ".nolo");
|
|
62
|
+
const dbPaths = [];
|
|
63
|
+
const cliDb = path.join(noloHome, "data", "leveldb");
|
|
64
|
+
if (fs.existsSync(cliDb)) dbPaths.push(cliDb);
|
|
65
|
+
const serverDbPath = process.env.NOLO_SERVER_DB_PATH?.trim();
|
|
66
|
+
if (serverDbPath && fs.existsSync(serverDbPath) && !dbPaths.includes(serverDbPath)) {
|
|
67
|
+
dbPaths.push(serverDbPath);
|
|
68
|
+
}
|
|
69
|
+
const cleaned = [];
|
|
70
|
+
for (const dbPath of dbPaths) {
|
|
71
|
+
try {
|
|
72
|
+
const db = new Level(dbPath, { valueEncoding: "json" });
|
|
73
|
+
await db.open();
|
|
74
|
+
try {
|
|
75
|
+
for (const key of args.keys) {
|
|
76
|
+
try {
|
|
77
|
+
await db.del(key);
|
|
78
|
+
} catch {
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
cleaned.push(dbPath);
|
|
82
|
+
} finally {
|
|
83
|
+
await db.close();
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return cleaned;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// packages/cli/agentDeleteCommand.ts
|
|
92
|
+
var AGENT_PRIVATE_KEY_RE = /^agent-([^-]+)-(.+)$/i;
|
|
93
|
+
var AGENT_PUBLIC_KEY_RE = /^agent-pub-(.+)$/i;
|
|
94
|
+
function hasFlag(args, flag) {
|
|
95
|
+
return args.includes(flag);
|
|
96
|
+
}
|
|
97
|
+
function readOption(args, flag) {
|
|
98
|
+
const idx = args.indexOf(flag);
|
|
99
|
+
return idx !== -1 ? args[idx + 1] : void 0;
|
|
100
|
+
}
|
|
101
|
+
function readAllPositional(args) {
|
|
102
|
+
const out = [];
|
|
103
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
104
|
+
const a = args[i];
|
|
105
|
+
if (!a || a.startsWith("-")) continue;
|
|
106
|
+
out.push(a);
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
function extractAgentId(agentKey) {
|
|
111
|
+
const pub = agentKey.match(AGENT_PUBLIC_KEY_RE);
|
|
112
|
+
if (pub) return pub[1];
|
|
113
|
+
const priv = agentKey.match(AGENT_PRIVATE_KEY_RE);
|
|
114
|
+
if (priv) return priv[2];
|
|
115
|
+
return void 0;
|
|
116
|
+
}
|
|
117
|
+
function extractUserId(agentKey) {
|
|
118
|
+
const priv = agentKey.match(AGENT_PRIVATE_KEY_RE);
|
|
119
|
+
if (priv) return priv[1];
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
function buildAgentKeys(agentKey, fallbackUserId) {
|
|
123
|
+
const agentId = extractAgentId(agentKey);
|
|
124
|
+
if (!agentId) return null;
|
|
125
|
+
const privateUserId = extractUserId(agentKey) ?? fallbackUserId;
|
|
126
|
+
if (!privateUserId) return null;
|
|
127
|
+
return {
|
|
128
|
+
agentId,
|
|
129
|
+
privateKey: `agent-${privateUserId}-${agentId}`,
|
|
130
|
+
publicKey: `agent-pub-${agentId}`
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function printUsage(output) {
|
|
134
|
+
output.write("Usage: nolo agent delete <agentId|agentKey|agentUrl> [--yes] [--json]\n");
|
|
135
|
+
output.write(
|
|
136
|
+
" nolo agent delete --id <agentId|agentKey|agentUrl> [--yes] [--json]\n"
|
|
137
|
+
);
|
|
138
|
+
output.write("\n");
|
|
139
|
+
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");
|
|
140
|
+
output.write("\u670D\u52A1\u5668\u7AEF\u4E3A tombstone \u8F6F\u5220\u9664\uFF0CDELETE \u540E\u518D\u6B21 read \u4F1A\u8FD4\u56DE 404\u3002\n");
|
|
141
|
+
output.write("\n");
|
|
142
|
+
output.write("Flags:\n");
|
|
143
|
+
output.write(" --yes \u771F\u6B63\u6267\u884C\u5220\u9664\uFF1B\u7F3A\u7701\u65F6\u4EC5 dry-run \u8F93\u51FA\u76EE\u6807\u6458\u8981\u3002\n");
|
|
144
|
+
output.write(" --json \u8F93\u51FA JSON \u7ED3\u679C\u3002\n");
|
|
145
|
+
output.write(" --id <agent> \u4E0E\u4F4D\u7F6E\u53C2\u6570\u7B49\u4EF7\uFF0C\u4F20\u5165 alias / dbKey / URL / 26-char id\u3002\n");
|
|
146
|
+
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");
|
|
147
|
+
output.write(" --user <userId> \u663E\u5F0F\u8986\u76D6 userId\uFF08\u4E0E AUTH_TOKEN \u4E0D\u4E00\u81F4\u5219\u62A5\u9519\uFF09\u3002\n");
|
|
148
|
+
output.write(" --token / --machine-key \u4E34\u65F6\u8986\u76D6 AUTH_TOKEN\u3002\n");
|
|
149
|
+
output.write("\n");
|
|
150
|
+
output.write("Examples:\n");
|
|
151
|
+
output.write(" nolo agent delete 01MIMOREALPLUS0608 --yes\n");
|
|
152
|
+
output.write(" nolo agent delete https://nolo.chat/agent-0e95801d90-01MIMOREALPLUS0608 --yes --json\n");
|
|
153
|
+
}
|
|
154
|
+
async function runAgentDeleteCommand(args, deps = {}) {
|
|
155
|
+
const env = deps.env ?? process.env;
|
|
156
|
+
const output = deps.output ?? process.stdout;
|
|
157
|
+
if (hasFlag(args, "--help") || hasFlag(args, "-h")) {
|
|
158
|
+
printUsage(output);
|
|
159
|
+
return 0;
|
|
160
|
+
}
|
|
161
|
+
const explicitId = readOption(args, "--id");
|
|
162
|
+
const positionals = readAllPositional(args);
|
|
163
|
+
const agentInput = explicitId?.trim() || positionals[0]?.trim();
|
|
164
|
+
if (!agentInput) {
|
|
165
|
+
printUsage(output);
|
|
166
|
+
return 1;
|
|
167
|
+
}
|
|
168
|
+
const authToken = resolveAuthToken(args, env);
|
|
169
|
+
if (!authToken) {
|
|
170
|
+
output.write(
|
|
171
|
+
"[nolo] agent delete requires an auth token. Run `nolo login` or set AUTH_TOKEN.\n"
|
|
172
|
+
);
|
|
173
|
+
return 1;
|
|
174
|
+
}
|
|
175
|
+
const tokenUserId = parseUserIdFromAuthToken(authToken);
|
|
176
|
+
if (!tokenUserId) {
|
|
177
|
+
output.write(
|
|
178
|
+
"[nolo] agent delete could not read userId from AUTH_TOKEN.\n"
|
|
179
|
+
);
|
|
180
|
+
return 1;
|
|
181
|
+
}
|
|
182
|
+
const userOverride = readOption(args, "--user");
|
|
183
|
+
if (userOverride && userOverride !== tokenUserId) {
|
|
184
|
+
output.write(
|
|
185
|
+
`[nolo] agent delete --user (${userOverride}) does not match AUTH_TOKEN userId (${tokenUserId}).
|
|
186
|
+
`
|
|
187
|
+
);
|
|
188
|
+
return 1;
|
|
189
|
+
}
|
|
190
|
+
const agentKey = resolveCliAgentKeyInput(agentInput);
|
|
191
|
+
const db = deps.db ?? await getReadableCliDb(output);
|
|
192
|
+
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
193
|
+
const fallbackFetchImpl = deps.fallbackFetchImpl;
|
|
194
|
+
const json = hasFlag(args, "--json");
|
|
195
|
+
const shouldDelete = hasFlag(args, "--yes");
|
|
196
|
+
const serverUrl = resolveServerUrl(args, env);
|
|
197
|
+
const serverUrls = resolveDeleteServerCandidates(args, env, serverUrl);
|
|
198
|
+
let resolved;
|
|
199
|
+
try {
|
|
200
|
+
resolved = await resolveAgentRecordFromHybridStore({
|
|
201
|
+
agentInput,
|
|
202
|
+
cliArgs: args,
|
|
203
|
+
env,
|
|
204
|
+
db,
|
|
205
|
+
fetchImpl,
|
|
206
|
+
fallbackFetchImpl
|
|
207
|
+
});
|
|
208
|
+
} catch (error) {
|
|
209
|
+
const msg = toErrorMessage(error);
|
|
210
|
+
output.write(`[nolo] agent delete failed to resolve "${agentInput}": ${msg}
|
|
211
|
+
`);
|
|
212
|
+
return 1;
|
|
213
|
+
}
|
|
214
|
+
if (!resolved) {
|
|
215
|
+
output.write(`[nolo] agent delete: agent not found: ${agentInput}
|
|
216
|
+
`);
|
|
217
|
+
return 1;
|
|
218
|
+
}
|
|
219
|
+
const keys = buildAgentKeys(resolved.agentKey, tokenUserId);
|
|
220
|
+
if (!keys) {
|
|
221
|
+
output.write(
|
|
222
|
+
`[nolo] agent delete: cannot derive agent id from resolved key ${resolved.agentKey}.
|
|
223
|
+
`
|
|
224
|
+
);
|
|
225
|
+
return 1;
|
|
226
|
+
}
|
|
227
|
+
const record = resolved.record;
|
|
228
|
+
const agentName = typeof record?.name === "string" && record.name.trim() ? record.name : "(unnamed)";
|
|
229
|
+
const resolvedBase = typeof record?.serverOrigin === "string" && record.serverOrigin ? record.serverOrigin : "";
|
|
230
|
+
let privateDeleteResults = [];
|
|
231
|
+
let publicDeleteResults = [];
|
|
232
|
+
if (shouldDelete) {
|
|
233
|
+
try {
|
|
234
|
+
privateDeleteResults = await deleteDbRecordOnServers({
|
|
235
|
+
authToken,
|
|
236
|
+
dbKey: keys.privateKey,
|
|
237
|
+
fetchImpl,
|
|
238
|
+
fallbackFetchImpl,
|
|
239
|
+
serverUrls
|
|
240
|
+
});
|
|
241
|
+
publicDeleteResults = await deleteDbRecordOnServers({
|
|
242
|
+
authToken,
|
|
243
|
+
dbKey: keys.publicKey,
|
|
244
|
+
fetchImpl,
|
|
245
|
+
fallbackFetchImpl,
|
|
246
|
+
serverUrls
|
|
247
|
+
});
|
|
248
|
+
} catch (error) {
|
|
249
|
+
const msg = toErrorMessage(error);
|
|
250
|
+
output.write(`[nolo] agent delete fan-out failed: ${msg}
|
|
251
|
+
`);
|
|
252
|
+
return 1;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (shouldDelete) {
|
|
256
|
+
try {
|
|
257
|
+
const cleanedPaths = await clearAgentKeysFromLocalLevelDbs({
|
|
258
|
+
keys: [keys.privateKey, keys.publicKey]
|
|
259
|
+
});
|
|
260
|
+
if (cleanedPaths.length > 0 && !json) {
|
|
261
|
+
output.write(`Cleaned local LevelDB copies: ${cleanedPaths.length}
|
|
262
|
+
`);
|
|
263
|
+
}
|
|
264
|
+
} catch (error) {
|
|
265
|
+
const msg = toErrorMessage(error);
|
|
266
|
+
if (!json) output.write(`[nolo] local LevelDB cleanup skipped: ${msg}
|
|
267
|
+
`);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const allResults = [...privateDeleteResults, ...publicDeleteResults];
|
|
271
|
+
const failed = allResults.filter((r) => !r.ok);
|
|
272
|
+
const succeededCount = allResults.length - failed.length;
|
|
273
|
+
const payload = {
|
|
274
|
+
agentKey: resolved.agentKey,
|
|
275
|
+
agentName,
|
|
276
|
+
agentId: keys.agentId,
|
|
277
|
+
privateKey: keys.privateKey,
|
|
278
|
+
publicKey: keys.publicKey,
|
|
279
|
+
resolvedBase: resolvedBase || null,
|
|
280
|
+
targetServers: serverUrls,
|
|
281
|
+
dryRun: !shouldDelete,
|
|
282
|
+
deleted: shouldDelete,
|
|
283
|
+
deleteResults: shouldDelete ? {
|
|
284
|
+
private: privateDeleteResults,
|
|
285
|
+
public: publicDeleteResults
|
|
286
|
+
} : void 0
|
|
287
|
+
};
|
|
288
|
+
if (json) {
|
|
289
|
+
output.write(JSON.stringify(payload, null, 2));
|
|
290
|
+
output.write("\n");
|
|
291
|
+
} else {
|
|
292
|
+
output.write(`agent: ${agentName}
|
|
293
|
+
`);
|
|
294
|
+
output.write(`agentKey: ${resolved.agentKey}
|
|
295
|
+
`);
|
|
296
|
+
output.write(`privateKey: ${keys.privateKey}
|
|
297
|
+
`);
|
|
298
|
+
output.write(`publicKey: ${keys.publicKey}
|
|
299
|
+
`);
|
|
300
|
+
output.write(`targetServers: ${serverUrls.join(", ")}
|
|
301
|
+
`);
|
|
302
|
+
if (resolvedBase) output.write(`resolvedBase: ${resolvedBase}
|
|
303
|
+
`);
|
|
304
|
+
if (!shouldDelete) {
|
|
305
|
+
output.write(
|
|
306
|
+
"\nDry-run only. Re-run with --yes to tombstone this agent on the target servers.\n"
|
|
307
|
+
);
|
|
308
|
+
} else {
|
|
309
|
+
if (privateDeleteResults.length || publicDeleteResults.length) {
|
|
310
|
+
output.write(
|
|
311
|
+
`Deleted on ${succeededCount}/${allResults.length} targets. ${failed.length ? `Failures: ${failed.map((r) => `${r.dbKey ?? ""}@${r.serverUrl} (${r.error ?? "unknown"})`).join("; ")}` : ""}
|
|
312
|
+
`
|
|
313
|
+
);
|
|
314
|
+
} else {
|
|
315
|
+
output.write("No delete requests issued.\n");
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return failed.length > 0 ? 1 : 0;
|
|
320
|
+
}
|
|
321
|
+
export {
|
|
322
|
+
runAgentDeleteCommand
|
|
323
|
+
};
|