nolo-cli 0.8.0-alpha.7 → 0.9.0
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 → _executeModel-UD44KGZ4.js} +33 -28
- package/{action-PAXRPJJF.js → action-ZJWE3Y5S.js} +5 -4
- package/{addContentAction-CZVWF3QZ.js → addContentAction-TVDBNJM5.js} +4 -3
- package/{addDialogAgentAction-CCIDTPHC.js → addDialogAgentAction-EKH774VT.js} +3 -2
- package/{agentDeleteCommand-47B24JYG.js → agentDeleteCommand-TCPEFJTF.js} +15 -11
- package/{agentEmailCommands-D4FC6OZJ.js → agentEmailCommands-CZ3UILZ4.js} +36 -31
- package/{agentListCommands-UFET7CC4.js → agentListCommands-SJKO2FFB.js} +16 -12
- package/{agentMachineCommands-LH7QDQPP.js → agentMachineCommands-PSNABISZ.js} +15 -11
- package/{agentRecordCommands-CWS2B5IA.js → agentRecordCommands-MH2JKFHS.js} +36 -31
- package/{agentRunCommand-3FRPISLG.js → agentRunCommand-4KH6MIZR.js} +42 -34
- package/{agentRuntimeLocal-JNQQC2WG.js → agentRuntimeLocal-SKHJUWSS.js} +20 -15
- package/{agentSlice-XDFSELFJ.js → agentSlice-3WXXN4VK.js} +5 -4
- package/{authCommand-WXMD3IPR.js → authCommand-PXFX6JDT.js} +8 -1
- package/{authCommands-X74AFDTC.js → authCommands-356AYWEK.js} +10 -1
- package/{chunk-E5HMHIKL.js → chunk-2K2ECKSG.js} +4 -4
- package/{chunk-364VYAX2.js → chunk-2PUGVR6E.js} +1 -1
- package/chunk-3TZDXYSF.js +71 -0
- package/{chunk-YIJFUVKA.js → chunk-3WYQEUBI.js} +1 -1
- package/{chunk-543C7RDK.js → chunk-4K2KKCSD.js} +23 -8
- package/chunk-4ZDM73SD.js +34 -0
- package/{chunk-TDIQFT2F.js → chunk-5CS33IBL.js} +1 -1
- package/chunk-5KLGBAAR.js +386 -0
- package/{chunk-YD43KPCK.js → chunk-5PJ3VWCS.js} +3 -3
- package/{chunk-IAXBCTTE.js → chunk-63SLEOLK.js} +2 -2
- package/{chunk-BSTNFPHD.js → chunk-6GANEXVO.js} +1 -1
- package/{chunk-6PWWWMI7.js → chunk-7OOXPE3N.js} +2 -2
- package/{chunk-KK6SWS5B.js → chunk-7QRKCBOP.js} +5 -5
- package/{chunk-LM25IZBJ.js → chunk-AUQ747NZ.js} +2 -2
- package/{chunk-572EKYLF.js → chunk-BBYVOSU2.js} +1 -1
- package/{chunk-2MALU52L.js → chunk-C3RUNRHT.js} +1 -1
- package/{chunk-G5H7RNFL.js → chunk-COMXDWNM.js} +2 -2
- package/{chunk-2LMT6K6N.js → chunk-CPB2YM4D.js} +2 -2
- package/{chunk-USZMK5UT.js → chunk-DCOA4QSN.js} +1 -1
- package/{chunk-OF5H3QWS.js → chunk-EXTIQUCI.js} +182 -0
- package/{chunk-B76D3JJK.js → chunk-G43KEVSC.js} +4 -4
- package/{chunk-USZDUWOV.js → chunk-GG4AJPSR.js} +2 -2
- package/chunk-I42VC5KR.js +15 -0
- package/{chunk-BR2WP3DF.js → chunk-IWX4UW2E.js} +9 -9
- package/chunk-JEXVIMYZ.js +55 -0
- package/{chunk-XDVAYP26.js → chunk-JRKKFRAV.js} +1 -1
- package/{chunk-DA2OEKS6.js → chunk-KKY4B2Q2.js} +2 -8
- package/{chunk-A3X4Y7MO.js → chunk-KOCA5FCS.js} +482 -26
- package/{chunk-IYQV26RA.js → chunk-KTVVPRJS.js} +2 -2
- package/{chunk-V2F4OGYM.js → chunk-LARL2V6G.js} +22 -18
- package/{chunk-H2RMRZJE.js → chunk-MGOJ5R6J.js} +1 -1
- package/{chunk-UVPF33PW.js → chunk-MKMWT7SA.js} +63 -19862
- package/chunk-OPZYGHUC.js +89 -0
- package/chunk-PAKN26FP.js +239 -0
- package/{chunk-OVGXXUVI.js → chunk-PCWC3JTN.js} +2 -2
- package/{chunk-AR7ZSGDI.js → chunk-PG5PNA7Y.js} +16 -6
- package/{chunk-HEIIIZBX.js → chunk-Q2YZULBH.js} +1 -1
- package/{chunk-2JHWPW5B.js → chunk-SBR32ZZS.js} +77 -303
- package/{chunk-PN7AFLOK.js → chunk-SH2CFQOH.js} +3 -13
- package/{chunk-CM54RSSA.js → chunk-SL35K7AH.js} +21 -1
- package/{chunk-VEJLAVTC.js → chunk-TSS3XJY4.js} +4 -4
- package/{chunk-IECI4YHR.js → chunk-UUJDGGAK.js} +3 -3
- package/{chunk-GEKCOPTN.js → chunk-WKM6FH35.js} +1 -1
- package/{chunk-SL3EPWB4.js → chunk-XE635NI4.js} +21 -22
- package/{chunk-NE3E3XJ2.js → chunk-XS466O7S.js} +96 -99
- package/{chunk-5XH3NZ4T.js → chunk-YBWOP46I.js} +20 -379
- package/{chunk-VQ2AJRGD.js → chunk-YPRZSPF3.js} +1 -1
- package/{chunk-AUGHVUFE.js → chunk-YYUCRDOK.js} +1 -1
- package/{chunk-KTI2WDDG.js → chunk-ZIG5LJ7X.js} +357 -266
- package/{chunk-NXZGF7F7.js → chunk-ZQ2UM4KG.js} +1 -1
- package/{createAgentAutomationAction-3QTGNYJC.js → createAgentAutomationAction-63OIP6X5.js} +15 -13
- package/{createDialogAction-5YX3ARBK.js → createDialogAction-ZLYZDYBB.js} +18 -16
- package/{createPageAction-EQNQQRCW.js → createPageAction-AL5FSDCK.js} +16 -14
- package/{dbSlice-C4UJLRZP.js → dbSlice-PR44QPXY.js} +3 -2
- package/{dialogCommands-AOQS23FV.js → dialogCommands-F6YI5742.js} +17 -13
- package/{dialogSlice-GZE3NCMC.js → dialogSlice-JSBNZRLR.js} +15 -13
- package/{docCreateCommands-GVOQVJON.js → docCreateCommands-4CTO7ERT.js} +16 -12
- package/{docDeleteCommands-GEB7YAUZ.js → docDeleteCommands-VBWERDRG.js} +17 -13
- package/{docReadCommands-XYKI2DF2.js → docReadCommands-KNP4MFYB.js} +16 -12
- package/{docStore-MLM5AME5.js → docStore-ADP5VYY4.js} +16 -14
- package/{docUpdateCommands-4L3RAMHZ.js → docUpdateCommands-4BCBJQHA.js} +16 -12
- package/{fetchMessages-JOCYIFKL.js → fetchMessages-U6ZHN56A.js} +3 -2
- package/{getPricing-PWPJ6MNV.js → getPricing-3E6UNPKL.js} +3 -3
- package/{handleSendMessageAction-WG2GKTGZ.js → handleSendMessageAction-IJDQ6ARA.js} +15 -13
- package/index.js +60 -56
- package/lib-FYYBQIXS.js +19839 -0
- package/{localDialogRead-D3BELSTF.js → localDialogRead-Z5UTAJPU.js} +1 -1
- package/{machineCommands-ZNXKLH6Q.js → machineCommands-EA3M4XTN.js} +38 -33
- package/{machineWsRunDispatch-7WRG6HNV.js → machineWsRunDispatch-NAPKE5ZA.js} +34 -29
- package/{models-XLEOET3E.js → models-4OPOOLFS.js} +2 -2
- package/package.json +1 -1
- package/{readlineWorkspace-AQURUDN4.js → readlineWorkspace-KMWT4T4S.js} +196 -44
- package/{removeDialogAgentAction-CXLST3N6.js → removeDialogAgentAction-GJQJNDW6.js} +5 -4
- package/{runAgentClientLoop-VQUEKGA5.js → runAgentClientLoop-U5Q6NDTJ.js} +28 -25
- package/{setDialogExtraReferencesAction-LP6VYGU7.js → setDialogExtraReferencesAction-M7OQG54N.js} +3 -2
- package/{setPrimaryDialogAgentAction-D3GGH23T.js → setPrimaryDialogAgentAction-46UNFJDL.js} +5 -4
- package/{settingSlice-J4I3Z5H7.js → settingSlice-FVUUH4JA.js} +4 -3
- package/{spaceCommands-R2RXD5UY.js → spaceCommands-E2CFRPZJ.js} +15 -11
- package/{spaceSlice-5UT4JNIN.js → spaceSlice-L3R6IMXE.js} +15 -13
- package/{streamAgentChatTurn-NRWSQKFN.js → streamAgentChatTurn-UBDAOQWE.js} +60 -35
- package/{tableCommands-66XEWHAK.js → tableCommands-GOFP7QKA.js} +1 -1
- package/{tools-TNMUDDRK.js → tools-TMJXZTCA.js} +22 -20
- package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
- package/{understanding-HCSFPE7R.js → understanding-GQKNDDWM.js} +7 -54
- package/{updateDialogTitleAction-IXOKAVX3.js → updateDialogTitleAction-ZTWRDXI2.js} +17 -14
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractThinkContent,
|
|
3
|
+
flushThinkParser,
|
|
4
|
+
processThinkChunk
|
|
5
|
+
} from "./chunk-OPZYGHUC.js";
|
|
6
|
+
import {
|
|
7
|
+
buildProviderExecutionPlan,
|
|
8
|
+
canUsePlatformChatProvider,
|
|
9
|
+
convertMessagesToResponsesInput,
|
|
10
|
+
extractTextFromResponseOutput,
|
|
11
|
+
extractToolCallsFromResponseOutput,
|
|
12
|
+
hasDirectOpenAiCompatibleProvider,
|
|
13
|
+
resolveAgentRuntimeLocation,
|
|
14
|
+
resolvePlatformAuthToken,
|
|
15
|
+
resolvePlatformServerUrl,
|
|
16
|
+
resolveProviderTransportDecision,
|
|
17
|
+
toResponsesTools
|
|
18
|
+
} from "./chunk-JRKKFRAV.js";
|
|
19
|
+
|
|
20
|
+
// packages/agent-runtime/openAiCompatibleMessages.ts
|
|
21
|
+
function toOpenAiCompatibleMessages(messages) {
|
|
22
|
+
return messages.map((message) => ({
|
|
23
|
+
role: message.role,
|
|
24
|
+
content: message.content ?? "",
|
|
25
|
+
...message.tool_call_id ? { tool_call_id: message.tool_call_id } : {},
|
|
26
|
+
...Array.isArray(message.tool_calls) ? { tool_calls: message.tool_calls } : {},
|
|
27
|
+
...message.reasoning_content ? { reasoning_content: message.reasoning_content } : {}
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// packages/agent-runtime/toolCallAccumulator.ts
|
|
32
|
+
function accumulateToolCallDelta(accumulated, deltas) {
|
|
33
|
+
for (const delta of deltas) {
|
|
34
|
+
const index = typeof delta.index === "number" ? delta.index : 0;
|
|
35
|
+
const current = accumulated[index] ?? {
|
|
36
|
+
id: "",
|
|
37
|
+
type: "function",
|
|
38
|
+
function: { name: "", arguments: "" }
|
|
39
|
+
};
|
|
40
|
+
if (typeof delta.id === "string" && delta.id) current.id = delta.id;
|
|
41
|
+
const fn = delta.function;
|
|
42
|
+
if (fn && typeof fn === "object") {
|
|
43
|
+
const functionDelta = fn;
|
|
44
|
+
if (typeof functionDelta.name === "string" && functionDelta.name) {
|
|
45
|
+
current.function.name += functionDelta.name;
|
|
46
|
+
}
|
|
47
|
+
if (typeof functionDelta.arguments === "string" && functionDelta.arguments) {
|
|
48
|
+
current.function.arguments += functionDelta.arguments;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
accumulated[index] = current;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function finalizeAccumulatedToolCalls(accumulated) {
|
|
55
|
+
return Object.keys(accumulated).map((key) => accumulated[Number(key)]).filter((call) => call?.function?.name);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// packages/agent-runtime/processChatCompletionDelta.ts
|
|
59
|
+
function extractChatCompletionStreamError(parsed) {
|
|
60
|
+
const raw = parsed?.error;
|
|
61
|
+
if (!raw) return null;
|
|
62
|
+
if (typeof raw === "string") {
|
|
63
|
+
return raw.trim() ? { message: raw.trim() } : null;
|
|
64
|
+
}
|
|
65
|
+
if (typeof raw !== "object") return null;
|
|
66
|
+
const message = typeof raw.msg === "string" && raw.msg.trim() ? raw.msg.trim() : typeof raw.message === "string" && raw.message.trim() ? raw.message.trim() : "";
|
|
67
|
+
const code = typeof raw.code === "string" && raw.code.trim() ? raw.code.trim() : typeof raw.type === "string" && raw.type.trim() ? raw.type.trim() : void 0;
|
|
68
|
+
if (!message && !code) return null;
|
|
69
|
+
return {
|
|
70
|
+
message: message || "upstream stream error",
|
|
71
|
+
...code ? { code } : {}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function throwIfChatCompletionStreamFailed(state) {
|
|
75
|
+
const failure = state.streamError;
|
|
76
|
+
if (!failure) return;
|
|
77
|
+
const error = new Error(
|
|
78
|
+
failure.code ? `${failure.message} (${failure.code})` : failure.message
|
|
79
|
+
);
|
|
80
|
+
if (failure.code) error.code = failure.code;
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
function applyChatCompletionDelta(parsed, state) {
|
|
84
|
+
const streamError = extractChatCompletionStreamError(parsed);
|
|
85
|
+
if (streamError && !state.streamError) {
|
|
86
|
+
state.streamError = streamError;
|
|
87
|
+
}
|
|
88
|
+
if (parsed?.usage && typeof parsed.usage === "object") {
|
|
89
|
+
state.usage = parsed.usage;
|
|
90
|
+
}
|
|
91
|
+
const rawFinishReason = parsed?.choices?.[0]?.finish_reason;
|
|
92
|
+
if (typeof rawFinishReason === "string" && rawFinishReason.length > 0) {
|
|
93
|
+
state.finishReason = rawFinishReason;
|
|
94
|
+
}
|
|
95
|
+
const delta = parsed?.choices?.[0]?.delta;
|
|
96
|
+
if (!delta || typeof delta !== "object") return false;
|
|
97
|
+
const reasoningChunk = typeof delta.reasoning_content === "string" ? delta.reasoning_content : typeof delta.reasoning === "string" ? delta.reasoning : "";
|
|
98
|
+
if (reasoningChunk) {
|
|
99
|
+
state.reasoning += reasoningChunk;
|
|
100
|
+
state.onReasoningDelta?.(reasoningChunk);
|
|
101
|
+
}
|
|
102
|
+
if (Array.isArray(delta.tool_calls) && delta.tool_calls.length > 0) {
|
|
103
|
+
accumulateToolCallDelta(state.accumulatedToolCalls, delta.tool_calls);
|
|
104
|
+
}
|
|
105
|
+
const textChunk = typeof delta.content === "string" ? delta.content : "";
|
|
106
|
+
if (textChunk) {
|
|
107
|
+
const parsedChunk = processThinkChunk(textChunk, state.thinkState);
|
|
108
|
+
state.thinkState = parsedChunk.state;
|
|
109
|
+
if (parsedChunk.content) {
|
|
110
|
+
state.content += parsedChunk.content;
|
|
111
|
+
state.onTextDelta?.(parsedChunk.content);
|
|
112
|
+
}
|
|
113
|
+
if (parsedChunk.reasoning) {
|
|
114
|
+
state.reasoning += parsedChunk.reasoning;
|
|
115
|
+
state.onReasoningDelta?.(parsedChunk.reasoning);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
function flushChatCompletionStream(state) {
|
|
121
|
+
const flushed = flushThinkParser(state.thinkState);
|
|
122
|
+
state.thinkState = flushed.state;
|
|
123
|
+
if (flushed.content) {
|
|
124
|
+
state.content += flushed.content;
|
|
125
|
+
state.onTextDelta?.(flushed.content);
|
|
126
|
+
}
|
|
127
|
+
if (flushed.reasoning) {
|
|
128
|
+
state.reasoning += flushed.reasoning;
|
|
129
|
+
state.onReasoningDelta?.(flushed.reasoning);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// packages/agent-runtime/sseFrames.ts
|
|
134
|
+
async function* readSseFrames(response) {
|
|
135
|
+
const reader = response.body?.getReader();
|
|
136
|
+
if (!reader) {
|
|
137
|
+
throw new Error("SSE response did not include a readable body.");
|
|
138
|
+
}
|
|
139
|
+
const decoder = new TextDecoder();
|
|
140
|
+
let buffer = "";
|
|
141
|
+
while (true) {
|
|
142
|
+
const { done, value } = await reader.read();
|
|
143
|
+
if (done) break;
|
|
144
|
+
buffer += decoder.decode(value, { stream: true });
|
|
145
|
+
let boundary = buffer.indexOf("\n\n");
|
|
146
|
+
while (boundary !== -1) {
|
|
147
|
+
yield buffer.slice(0, boundary);
|
|
148
|
+
buffer = buffer.slice(boundary + 2);
|
|
149
|
+
boundary = buffer.indexOf("\n\n");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (buffer.trim()) yield buffer;
|
|
153
|
+
}
|
|
154
|
+
async function readSseDataValues(response, parse) {
|
|
155
|
+
const reader = response.body?.getReader();
|
|
156
|
+
if (!reader) return [];
|
|
157
|
+
const decoder = new TextDecoder();
|
|
158
|
+
const values = [];
|
|
159
|
+
let buffer = "";
|
|
160
|
+
while (true) {
|
|
161
|
+
const { done, value } = await reader.read();
|
|
162
|
+
if (done) break;
|
|
163
|
+
buffer += decoder.decode(value, { stream: true });
|
|
164
|
+
const lines = buffer.split("\n");
|
|
165
|
+
buffer = lines.pop() ?? "";
|
|
166
|
+
for (const line of lines) {
|
|
167
|
+
const parsed = parse(line);
|
|
168
|
+
if (parsed) values.push(parsed);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (buffer.trim()) {
|
|
172
|
+
const parsed = parse(buffer);
|
|
173
|
+
if (parsed) values.push(parsed);
|
|
174
|
+
}
|
|
175
|
+
return values;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// packages/agent-runtime/platformChatProvider.ts
|
|
179
|
+
var CHAT_PROXY_PATH = "/api/v1/chat";
|
|
180
|
+
function shouldDisableThinking(providerConfig) {
|
|
181
|
+
return providerConfig.provider.toLowerCase() === "mimo" || /xiaomimimo\.com/i.test(providerConfig.endpoint);
|
|
182
|
+
}
|
|
183
|
+
function isResponsesEndpoint(endpoint) {
|
|
184
|
+
return /\/responses$/i.test(endpoint.trim());
|
|
185
|
+
}
|
|
186
|
+
function toResponsesRequestOptions(options) {
|
|
187
|
+
const next = { ...options };
|
|
188
|
+
const reasoningEffort = next.reasoning_effort;
|
|
189
|
+
if (typeof reasoningEffort === "string" && reasoningEffort) {
|
|
190
|
+
next.reasoning = { effort: reasoningEffort };
|
|
191
|
+
delete next.reasoning_effort;
|
|
192
|
+
}
|
|
193
|
+
if (next.max_tokens !== void 0) {
|
|
194
|
+
next.max_output_tokens = next.max_tokens;
|
|
195
|
+
delete next.max_tokens;
|
|
196
|
+
}
|
|
197
|
+
return next;
|
|
198
|
+
}
|
|
199
|
+
async function resolvePlatformChatProviderConfig(args) {
|
|
200
|
+
const plan = await buildProviderExecutionPlan({
|
|
201
|
+
agentConfig: args.agentConfig,
|
|
202
|
+
env: args.env,
|
|
203
|
+
runtimeKind: "local",
|
|
204
|
+
...args.apiKeyRefResolver ? { apiKeyRefResolver: args.apiKeyRefResolver } : {},
|
|
205
|
+
...args.credentialBroker ? { credentialBroker: args.credentialBroker } : {},
|
|
206
|
+
...args.syncFetcher ? { syncFetcher: args.syncFetcher } : {}
|
|
207
|
+
});
|
|
208
|
+
if (plan.mode === "cli") {
|
|
209
|
+
throw new Error("Platform chat provider does not support cli agents.");
|
|
210
|
+
}
|
|
211
|
+
if (plan.transport === "direct") {
|
|
212
|
+
return {
|
|
213
|
+
serverUrl: resolvePlatformServerUrl(args.env),
|
|
214
|
+
authToken: resolvePlatformAuthToken(args.env),
|
|
215
|
+
agentKey: args.agentConfig.key,
|
|
216
|
+
model: plan.model,
|
|
217
|
+
provider: plan.provider,
|
|
218
|
+
endpoint: plan.endpoint,
|
|
219
|
+
requestOptions: plan.requestOptions,
|
|
220
|
+
...plan.apiKey ? { apiKey: plan.apiKey } : {},
|
|
221
|
+
...plan.apiKeyHeader ? { apiKeyHeader: plan.apiKeyHeader } : {},
|
|
222
|
+
...args.agentConfig.apiSource ? { apiSource: args.agentConfig.apiSource } : {}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
serverUrl: plan.serverUrl,
|
|
227
|
+
authToken: plan.authToken,
|
|
228
|
+
agentKey: plan.agentKey,
|
|
229
|
+
model: plan.model,
|
|
230
|
+
provider: plan.provider,
|
|
231
|
+
endpoint: plan.endpoint,
|
|
232
|
+
requestOptions: plan.requestOptions,
|
|
233
|
+
...plan.apiKey ? { apiKey: plan.apiKey } : {},
|
|
234
|
+
...plan.apiKeyHeader ? { apiKeyHeader: plan.apiKeyHeader } : {},
|
|
235
|
+
...plan.apiSource ? { apiSource: plan.apiSource } : {}
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function buildPlatformChatCompletionRequest(args) {
|
|
239
|
+
const usesResponsesApi = isResponsesEndpoint(args.providerConfig.endpoint);
|
|
240
|
+
const requestOptions = usesResponsesApi ? toResponsesRequestOptions(args.providerConfig.requestOptions) : args.providerConfig.requestOptions;
|
|
241
|
+
const body = {
|
|
242
|
+
model: args.providerConfig.model,
|
|
243
|
+
...usesResponsesApi ? { input: convertMessagesToResponsesInput(args.messages) } : { messages: toOpenAiCompatibleMessages(args.messages) },
|
|
244
|
+
stream: args.stream ?? false,
|
|
245
|
+
...args.stream ? { stream_options: { include_usage: true } } : {},
|
|
246
|
+
...requestOptions,
|
|
247
|
+
...args.tools && args.tools.length > 0 ? {
|
|
248
|
+
tools: usesResponsesApi ? toResponsesTools(args.tools) : args.tools,
|
|
249
|
+
...usesResponsesApi ? {} : { tool_choice: "auto" }
|
|
250
|
+
} : {},
|
|
251
|
+
...shouldDisableThinking(args.providerConfig) ? { thinking: { type: "disabled" } } : {},
|
|
252
|
+
url: args.providerConfig.endpoint,
|
|
253
|
+
provider: args.providerConfig.provider,
|
|
254
|
+
agentKey: args.providerConfig.agentKey,
|
|
255
|
+
...args.providerConfig.apiSource ? { apiSource: args.providerConfig.apiSource } : {},
|
|
256
|
+
...args.providerConfig.apiKey ? { KEY: args.providerConfig.apiKey } : {},
|
|
257
|
+
...args.providerConfig.apiKeyHeader ? { apiKeyHeader: args.providerConfig.apiKeyHeader } : {}
|
|
258
|
+
};
|
|
259
|
+
return {
|
|
260
|
+
url: `${args.providerConfig.serverUrl}${CHAT_PROXY_PATH}`,
|
|
261
|
+
init: {
|
|
262
|
+
method: "POST",
|
|
263
|
+
headers: {
|
|
264
|
+
"Content-Type": "application/json",
|
|
265
|
+
Authorization: `Bearer ${args.providerConfig.authToken}`
|
|
266
|
+
},
|
|
267
|
+
body: JSON.stringify(body)
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
function tryParseJson(raw) {
|
|
272
|
+
try {
|
|
273
|
+
return JSON.parse(raw);
|
|
274
|
+
} catch {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function extractJsonObjects(raw) {
|
|
279
|
+
const objects = [];
|
|
280
|
+
let depth = 0;
|
|
281
|
+
let start = -1;
|
|
282
|
+
let inString = false;
|
|
283
|
+
let escaped = false;
|
|
284
|
+
for (let index = 0; index < raw.length; index += 1) {
|
|
285
|
+
const char = raw[index];
|
|
286
|
+
if (inString) {
|
|
287
|
+
if (escaped) {
|
|
288
|
+
escaped = false;
|
|
289
|
+
} else if (char === "\\") {
|
|
290
|
+
escaped = true;
|
|
291
|
+
} else if (char === '"') {
|
|
292
|
+
inString = false;
|
|
293
|
+
}
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
if (char === '"') {
|
|
297
|
+
inString = true;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (char === "{") {
|
|
301
|
+
if (depth === 0) start = index;
|
|
302
|
+
depth += 1;
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
if (char !== "}" || depth === 0) continue;
|
|
306
|
+
depth -= 1;
|
|
307
|
+
if (depth === 0 && start >= 0) {
|
|
308
|
+
const parsed = tryParseJson(raw.slice(start, index + 1));
|
|
309
|
+
if (parsed) objects.push(parsed);
|
|
310
|
+
start = -1;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return objects;
|
|
314
|
+
}
|
|
315
|
+
function parsePlatformChatCompletionData(raw) {
|
|
316
|
+
const direct = tryParseJson(raw.trim());
|
|
317
|
+
if (direct) return direct;
|
|
318
|
+
const objects = extractJsonObjects(raw);
|
|
319
|
+
return objects.find((object) => Array.isArray(object?.choices)) ?? objects[0] ?? {};
|
|
320
|
+
}
|
|
321
|
+
function parsePlatformChatCompletionResponse(args) {
|
|
322
|
+
if (isResponsesEndpoint(args.providerConfig.endpoint)) {
|
|
323
|
+
const content2 = extractTextFromResponseOutput(args.data);
|
|
324
|
+
const tool_calls = extractToolCallsFromResponseOutput(args.data);
|
|
325
|
+
return {
|
|
326
|
+
content: content2,
|
|
327
|
+
model: args.providerConfig.model,
|
|
328
|
+
provider: args.providerConfig.provider,
|
|
329
|
+
...tool_calls.length > 0 ? { tool_calls } : {},
|
|
330
|
+
usage: args.data?.usage,
|
|
331
|
+
trace: args.trace
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
const choiceMessage = args.data?.choices?.[0]?.message ?? {};
|
|
335
|
+
const rawContent = String(choiceMessage?.content ?? "");
|
|
336
|
+
const { content, reasoning } = extractThinkContent(rawContent);
|
|
337
|
+
return {
|
|
338
|
+
content,
|
|
339
|
+
model: args.providerConfig.model,
|
|
340
|
+
provider: args.providerConfig.provider,
|
|
341
|
+
...Array.isArray(choiceMessage?.tool_calls) ? { tool_calls: choiceMessage.tool_calls } : {},
|
|
342
|
+
...reasoning ? { reasoning_content: reasoning } : typeof choiceMessage?.reasoning_content === "string" && choiceMessage.reasoning_content ? { reasoning_content: choiceMessage.reasoning_content } : {},
|
|
343
|
+
usage: args.data?.usage,
|
|
344
|
+
trace: args.trace
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function canUsePlatformChatProvider2(env) {
|
|
348
|
+
return canUsePlatformChatProvider(env);
|
|
349
|
+
}
|
|
350
|
+
function hasDirectOpenAiCompatibleProvider2(env) {
|
|
351
|
+
return hasDirectOpenAiCompatibleProvider(env);
|
|
352
|
+
}
|
|
353
|
+
function shouldUsePlatformChatProvider(env, agentConfig) {
|
|
354
|
+
if (!agentConfig) {
|
|
355
|
+
return resolveProviderTransportDecision({
|
|
356
|
+
agentConfig: { key: "default-platform" },
|
|
357
|
+
env,
|
|
358
|
+
runtimeLocation: "local-host"
|
|
359
|
+
}).transport === "proxy";
|
|
360
|
+
}
|
|
361
|
+
return resolveProviderTransportDecision({
|
|
362
|
+
agentConfig,
|
|
363
|
+
env,
|
|
364
|
+
runtimeLocation: resolveAgentRuntimeLocation({
|
|
365
|
+
agentConfig,
|
|
366
|
+
runtimeKind: "local"
|
|
367
|
+
})
|
|
368
|
+
}).transport === "proxy";
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export {
|
|
372
|
+
finalizeAccumulatedToolCalls,
|
|
373
|
+
throwIfChatCompletionStreamFailed,
|
|
374
|
+
applyChatCompletionDelta,
|
|
375
|
+
flushChatCompletionStream,
|
|
376
|
+
toOpenAiCompatibleMessages,
|
|
377
|
+
readSseFrames,
|
|
378
|
+
readSseDataValues,
|
|
379
|
+
resolvePlatformChatProviderConfig,
|
|
380
|
+
buildPlatformChatCompletionRequest,
|
|
381
|
+
parsePlatformChatCompletionData,
|
|
382
|
+
parsePlatformChatCompletionResponse,
|
|
383
|
+
canUsePlatformChatProvider2 as canUsePlatformChatProvider,
|
|
384
|
+
hasDirectOpenAiCompatibleProvider2 as hasDirectOpenAiCompatibleProvider,
|
|
385
|
+
shouldUsePlatformChatProvider
|
|
386
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
readDbRecord,
|
|
3
3
|
writeAgentRecord
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7OOXPE3N.js";
|
|
5
5
|
import {
|
|
6
6
|
buildSkillSummaryMarker
|
|
7
7
|
} from "./chunk-VF4K2QE6.js";
|
|
8
8
|
import {
|
|
9
9
|
buildSkillDocMarkdown
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZQ2UM4KG.js";
|
|
11
11
|
import {
|
|
12
12
|
createSpaceKey
|
|
13
13
|
} from "./chunk-UAD2WT54.js";
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "./chunk-ISNCLGUZ.js";
|
|
20
20
|
import {
|
|
21
21
|
require_index_umd
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-SH2CFQOH.js";
|
|
23
23
|
import {
|
|
24
24
|
asTrimmedLowercaseString
|
|
25
25
|
} from "./chunk-QSJ3HFEF.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
selectCurrentServer,
|
|
3
3
|
selectRemoteServers
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-TSS3XJY4.js";
|
|
5
5
|
import {
|
|
6
6
|
createUserKey,
|
|
7
7
|
extractAgentInfo,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
sanitizeShareData,
|
|
11
11
|
shareKey,
|
|
12
12
|
toNonEmptyString
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-SH2CFQOH.js";
|
|
14
14
|
import {
|
|
15
15
|
noloDeleteRequest,
|
|
16
16
|
noloWriteRequest,
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
buildLocalAgentLookupKeys,
|
|
3
3
|
normalizeAgentHandle,
|
|
4
4
|
shouldReadAgentKeyRemotely
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2PUGVR6E.js";
|
|
6
6
|
import {
|
|
7
7
|
resolveCliAgentKeyInput
|
|
8
8
|
} from "./chunk-VHBWHNVT.js";
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./chunk-HNMXYYJR.js";
|
|
23
23
|
import {
|
|
24
24
|
createAgentKey
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-SH2CFQOH.js";
|
|
26
26
|
|
|
27
27
|
// packages/cli/agentRecordHelpers.ts
|
|
28
28
|
import { readFileSync } from "node:fs";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCliLocalRuntimeAdapter,
|
|
3
3
|
summarizeEndpoint
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LARL2V6G.js";
|
|
5
5
|
import {
|
|
6
6
|
clipMultilineText
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MKMWT7SA.js";
|
|
8
8
|
import {
|
|
9
9
|
readPipeText,
|
|
10
10
|
spawnProcess
|
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
} from "./chunk-OLZBQWZU.js";
|
|
18
18
|
import {
|
|
19
19
|
runLocalAgentTurn
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-XS466O7S.js";
|
|
21
21
|
import {
|
|
22
22
|
resolveLocalRuntimeEnvFromPolicy
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-5CS33IBL.js";
|
|
24
24
|
import {
|
|
25
25
|
toErrorMessage
|
|
26
26
|
} from "./chunk-HNMXYYJR.js";
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
} from "./chunk-KX6YBIHG.js";
|
|
30
30
|
import {
|
|
31
31
|
asTrimmedNonEmptyStringArray
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-I42VC5KR.js";
|
|
33
33
|
import {
|
|
34
34
|
asTrimmedString
|
|
35
35
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
asNonEmptyStringArray,
|
|
6
6
|
asTrimmedNonEmptyStringArray
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-I42VC5KR.js";
|
|
8
8
|
import {
|
|
9
9
|
asOptionalFiniteNumber
|
|
10
10
|
} from "./chunk-WWC7I6TA.js";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
isRecord
|
|
16
16
|
} from "./chunk-KUG52IAP.js";
|
|
17
17
|
|
|
18
|
-
// packages/
|
|
18
|
+
// packages/agent-runtime/toolNameAliases.ts
|
|
19
19
|
var LEGACY_TOOL_NAME_ALIASES = {
|
|
20
20
|
createPage: "createDoc",
|
|
21
21
|
updatePage: "updateDoc",
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
fileKey,
|
|
11
11
|
getFileIdFromKey,
|
|
12
12
|
ulid
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-SH2CFQOH.js";
|
|
14
14
|
import {
|
|
15
15
|
readAction,
|
|
16
16
|
readRequestManager,
|
|
@@ -748,7 +748,7 @@ var dbSlice = createSliceWithThunks({
|
|
|
748
748
|
// 这里改成动态 import,运行期才解析,彻底断开这条边。
|
|
749
749
|
share: create.asyncThunk(
|
|
750
750
|
async (config, thunkApi) => {
|
|
751
|
-
const { shareResourceAction } = await import("./action-
|
|
751
|
+
const { shareResourceAction } = await import("./action-ZJWE3Y5S.js");
|
|
752
752
|
return shareResourceAction(config, thunkApi);
|
|
753
753
|
}
|
|
754
754
|
),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
i18n_default,
|
|
3
3
|
toolRegistry
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MKMWT7SA.js";
|
|
5
5
|
import {
|
|
6
6
|
canonicalizeToolNames
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-AUQ747NZ.js";
|
|
8
8
|
import {
|
|
9
9
|
asTrimmedLowercaseString
|
|
10
10
|
} from "./chunk-QSJ3HFEF.js";
|