nolo-cli 0.16.0 → 0.17.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-AVCA2NAV.js → _executeModel-WPNX5DH4.js} +49 -43
- package/{action-F5JACQBG.js → action-LT7BRFLK.js} +10 -9
- package/{addContentAction-AQXEYRBE.js → addContentAction-PL3KKBDH.js} +9 -8
- package/{addDialogAgentAction-EJHHJZWW.js → addDialogAgentAction-FCMSKYAF.js} +8 -7
- package/{agentDeleteCommand-QW5PUMDQ.js → agentDeleteCommand-L3357EFL.js} +31 -28
- package/{agentEmailCommands-4ORVLGVQ.js → agentEmailCommands-N65AVLEI.js} +61 -55
- package/{agentListCommands-YWBYRTYC.js → agentListCommands-CH27FTI2.js} +30 -27
- package/{agentMachineCommands-JSQW4FOA.js → agentMachineCommands-PPK5HJZB.js} +29 -26
- package/{agentPullCommand-6HWUT3SW.js → agentPullCommand-ZZGU5KOY.js} +4 -4
- package/{agentRecordCommands-AASIWOBT.js → agentRecordCommands-HTVXD4TT.js} +56 -50
- package/{agentRunCommand-TB5BHXUH.js → agentRunCommand-MGLVJUA5.js} +62 -53
- package/{agentRunControl-6ADXVYMR.js → agentRunControl-P75VPTGS.js} +24 -1
- package/{agentRuntimeLocal-QNPNJRVH.js → agentRuntimeLocal-QUTBSY3I.js} +24 -21
- package/{agentSlice-RUNXC62Y.js → agentSlice-DOGRCMWK.js} +9 -8
- package/appDeleteCommands-FEEVXUBG.js +127 -0
- package/appDeployCommands-C4HCGC4B.js +166 -0
- package/appDeployStatusCommands-IR5ZUZBQ.js +147 -0
- package/appGetCommands-6RJGZ66Z.js +122 -0
- package/appListCommands-VMTF5YZF.js +125 -0
- package/{authCommand-YFTR3347.js → authCommand-WJZPOLSS.js} +16 -9
- package/{authCommands-YXGOXNBZ.js → authCommands-XTBV7OFZ.js} +6 -5
- package/{chunk-XPC5C7BK.js → chunk-3ND52WIL.js} +2 -2
- package/{chunk-SOTZ6RDN.js → chunk-3Q7WHGCB.js} +1 -1
- package/{chunk-M43KDE25.js → chunk-45BY7RLP.js} +2 -8
- package/{chunk-KKY4B2Q2.js → chunk-4PWB7JRR.js} +4 -1
- package/{chunk-6N4KODMN.js → chunk-4T5F7YZQ.js} +1 -1
- package/chunk-7BUYEZ6U.js +671 -0
- package/{chunk-AS3ZQ3O2.js → chunk-7OBMZCRD.js} +1 -1
- package/{chunk-AVVZUXXC.js → chunk-AAODAAUQ.js} +34 -13
- package/{chunk-QLUFR47U.js → chunk-AL2V7U3E.js} +1 -1
- package/{chunk-MTU75CZ2.js → chunk-B5TOXZAK.js} +1 -1
- package/{chunk-AUURUT6L.js → chunk-BT6K76S7.js} +238 -424
- package/chunk-CEFXYF66.js +107 -0
- package/{chunk-RLCXU7A5.js → chunk-D3HVJJIA.js} +1 -1
- package/{chunk-JTMNCCWF.js → chunk-DKZFOK24.js} +16 -87
- package/chunk-DL6EPNIK.js +50 -0
- package/{chunk-4L2OJPCU.js → chunk-EGPCU42M.js} +58 -8
- package/{chunk-IWLUTMYX.js → chunk-ELT65PZW.js} +2 -2
- package/chunk-FKXFCYVO.js +221 -0
- package/{chunk-4FX6NVDW.js → chunk-FPKLD4KB.js} +3 -136
- package/{chunk-PCTUYVUM.js → chunk-FVIPEIVX.js} +10 -3
- package/chunk-GFUIQ4RY.js +136 -0
- package/{chunk-66X4VSRC.js → chunk-HQPG2PIV.js} +41 -1
- package/{chunk-IGXREZW2.js → chunk-HV2A3B4W.js} +1 -1
- package/{chunk-LPEUV5RE.js → chunk-IOOMJJ4Z.js} +2 -2
- package/{setDialogExtraReferencesAction-LR6MSIXO.js → chunk-JLA4FXYC.js} +2 -17
- package/{chunk-3OIRVWXA.js → chunk-JP7REMYP.js} +10 -1
- package/chunk-KFEVY3ST.js +255 -0
- package/{chunk-P3RIAYGG.js → chunk-L2MLZQXU.js} +3 -3
- package/{chunk-55NSNCFM.js → chunk-L6NVTGI7.js} +1 -1
- package/{chunk-3WGLLTK4.js → chunk-LSFAWXKC.js} +100 -3
- package/{chunk-S2LXHNHG.js → chunk-MD3V54DA.js} +6 -6
- package/{chunk-6EVITP2G.js → chunk-MUCU6ATG.js} +2 -251
- package/{chunk-KFHN5NGJ.js → chunk-MVQ4TBSD.js} +1 -1
- package/{chunk-ZQBL7LIC.js → chunk-NEKFSXOP.js} +310 -211
- package/{chunk-NSCHQQPU.js → chunk-NVB267BZ.js} +397 -324
- package/{chunk-Z5JQNBNY.js → chunk-NYUXSXLY.js} +33 -14
- package/{chunk-FRV6A633.js → chunk-PZCBZO4J.js} +2 -2
- package/{chunk-GSINCD4P.js → chunk-QCJITMYO.js} +21 -11
- package/{chunk-OOSFSFMA.js → chunk-R5V5G73M.js} +2 -0
- package/{chunk-4IJYA27C.js → chunk-RG2U2MTJ.js} +1 -1
- package/{chunk-BEBNFWDU.js → chunk-RRGVDPH3.js} +3 -3
- package/{chunk-EABWT43X.js → chunk-RVOUXDFU.js} +5 -5
- package/{chunk-JTINRTBT.js → chunk-SKDNBYZK.js} +2 -2
- package/{chunk-3663CXZN.js → chunk-SNZV4QCE.js} +65 -22
- package/{chunk-KMQPSTMJ.js → chunk-TRT4I4UD.js} +2 -2
- package/{chunk-MYMMNKYL.js → chunk-TSIYZBTH.js} +156 -6
- package/{chunk-EHLHSX7R.js → chunk-UB4RYYNQ.js} +9 -2
- package/{chunk-YJKXGHJ6.js → chunk-UGUW3FHG.js} +4 -4
- package/{chunk-DPAB4FQ7.js → chunk-UZY4BEBR.js} +1579 -212
- package/chunk-V5R4NZP2.js +78 -0
- package/{chunk-MR6ISAGB.js → chunk-VDNQF5VI.js} +6 -6
- package/{chunk-33BJUVK4.js → chunk-VGMJ6PDJ.js} +5 -5
- package/{chunk-W4NVOSFF.js → chunk-WFHXMLHZ.js} +1 -1
- package/{chunk-H33743XH.js → chunk-WJRJDX2W.js} +1 -1
- package/chunk-X4Q4UZEY.js +26 -0
- package/{chunk-RPDGJO4D.js → chunk-XHG22OEX.js} +4 -4
- package/{chunk-DVRHHFEA.js → chunk-XMLRJUU5.js} +1 -1
- package/{chunk-3S2VOMIF.js → chunk-XRZJGPFI.js} +7 -7
- package/{chunk-7UKFVQ5W.js → chunk-YLRTBX4Y.js} +105 -36
- package/{chunk-DGEYDWEZ.js → chunk-YXTRNO5W.js} +3 -3
- package/{chunk-FY233ZFU.js → chunk-ZJZCMKOR.js} +107 -177
- package/{chunk-NVEWUJVX.js → chunk-ZVOZH2HW.js} +1 -1
- package/chunk-ZZ2MH7LE.js +84 -0
- package/{cliExecutor-K3F7DMRO.js → cliExecutor-DNE7TCC4.js} +2 -2
- package/codingSkills-36KN5NQT.js +48 -0
- package/{createAgentAutomationAction-FNHPSKKO.js → createAgentAutomationAction-PMOLEPGJ.js} +19 -18
- package/{createDialogAction-TZCVQ3NU.js → createDialogAction-DPRTYNAK.js} +21 -20
- package/{createPageAction-EIGZ3BKT.js → createPageAction-JGZK3WAM.js} +25 -24
- package/{dbSlice-7KQH6GOU.js → dbSlice-CGSRFJN3.js} +8 -7
- package/{deleteFile-WPWVZE4B.js → deleteFile-WDZ3VM7B.js} +3 -3
- package/{dialogCommands-FO77J5DQ.js → dialogCommands-XED6DKLV.js} +29 -26
- package/{dialogSlice-MM5U4KE2.js → dialogSlice-KO4NRNKC.js} +19 -18
- package/{docCreateCommands-I3BS3AZI.js → docCreateCommands-P6DYWHH3.js} +32 -27
- package/{docDeleteCommands-Q2OPV52P.js → docDeleteCommands-KUWXAMSN.js} +31 -26
- package/{docReadCommands-YOOFACYZ.js → docReadCommands-ECW55TKB.js} +30 -25
- package/{docStore-NGYQ2JTR.js → docStore-6KMERNUY.js} +20 -19
- package/{docUpdateCommands-2B32ITHN.js → docUpdateCommands-5J4BTJQN.js} +31 -26
- package/{fetchMessages-KTNM7QAR.js → fetchMessages-BMGVZVSE.js} +4 -3
- package/{getPricing-P4XRJRZB.js → getPricing-RYY6OBA4.js} +2 -2
- package/{handleSendMessageAction-JRZWWBKP.js → handleSendMessageAction-R3ZHTVU4.js} +20 -19
- package/index.js +95 -64
- package/{localDialogRead-2VRI24F4.js → localDialogRead-HQZPVIE3.js} +1 -1
- package/{localRuntimeDb-LGDF6FQP.js → localRuntimeDb-THJZGAOJ.js} +1 -1
- package/{machineCommands-WRWF2ICZ.js → machineCommands-JF2YL34J.js} +62 -56
- package/{machineWsRunDispatch-ZX7Q3TWZ.js → machineWsRunDispatch-ON4AEOJL.js} +54 -48
- package/{models-WQ5N4OJM.js → models-5K5G2CZI.js} +1 -1
- package/package.json +1 -1
- package/queryRunOverlay-O4LOMMPO.js +161 -0
- package/{read-CN3TNXIP.js → read-3FMPZPER.js} +3 -3
- package/{readDocTool-WF3675ED.js → readDocTool-VSYHKK3V.js} +1 -1
- package/{readlineWorkspace-ZTGRGW46.js → readlineWorkspace-SUCINTL7.js} +354 -185
- package/{removeDialogAgentAction-YDHBFEGI.js → removeDialogAgentAction-OAGA2G3U.js} +10 -9
- package/{runAgentClientLoop-JZCOP7LG.js → runAgentClientLoop-OBD2AVEL.js} +43 -37
- package/runOverlayPresentation-ZO4VCWEU.js +11 -0
- package/{runtimeDoctorCommands-THIHX2SY.js → runtimeDoctorCommands-E2OUORHK.js} +6 -6
- package/setDialogExtraReferencesAction-JZEXA5SL.js +27 -0
- package/{setPrimaryDialogAgentAction-IIVDCY5C.js → setPrimaryDialogAgentAction-4ZUQQKDG.js} +26 -17
- package/{settingSlice-O23YDK2O.js → settingSlice-7MNKHZ6R.js} +9 -8
- package/{skillDiscovery-6M2BZUFN.js → skillDiscovery-KJWT7JBU.js} +3 -3
- package/{spaceCommands-VV4GTPQK.js → spaceCommands-32NTNLHS.js} +30 -27
- package/{spaceSlice-DRWWZJP7.js → spaceSlice-P7VOXLY6.js} +19 -18
- package/{streamAgentChatTurn-Y6WGATQR.js → streamAgentChatTurn-UHEMNI3X.js} +97 -56
- package/{tableCommands-3P7MJ3PF.js → tableCommands-BEQAGE4I.js} +1 -1
- package/{tools-PUNBY3AH.js → tools-BMXIXHMB.js} +32 -27
- package/{tuiSummaryLlmCaller-F64WLSAF.js → tuiSummaryLlmCaller-VUNVBRX3.js} +5 -4
- package/types-ZSTJ7MPR.js +7 -0
- package/{updateDialogTitleAction-YSR4TCMB.js → updateDialogTitleAction-LJBDYZLH.js} +22 -21
- package/{chunk-O4BU24WZ.js → chunk-6Y7A3OQQ.js} +3 -3
- package/{chunk-XBS2WYJ2.js → chunk-RK5NYQEL.js} +0 -0
- package/{chunk-CMKUBIGW.js → chunk-X7W4TNB4.js} +3 -3
- package/{localRuntimeAuthority-TEGCOWX4.js → localRuntimeAuthority-4IXJCHZ7.js} +3 -3
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isRecord
|
|
3
|
+
} from "./chunk-KUG52IAP.js";
|
|
4
|
+
import {
|
|
5
|
+
asOptionalTrimmedString
|
|
6
|
+
} from "./chunk-G3SUCT4W.js";
|
|
7
|
+
|
|
8
|
+
// packages/agent-runtime/openAiCompatibleMessages.ts
|
|
9
|
+
function preserveAgentStateFields(source, target, options) {
|
|
10
|
+
const mutableTarget = target;
|
|
11
|
+
if (source.role === "assistant") {
|
|
12
|
+
if (!options?.stripReasoningContent && typeof source.reasoning_content === "string") {
|
|
13
|
+
mutableTarget.reasoning_content = source.reasoning_content;
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(source.tool_calls)) {
|
|
16
|
+
mutableTarget.tool_calls = source.tool_calls;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (source.role === "tool") {
|
|
20
|
+
const toolCallId = typeof source.tool_call_id === "string" ? source.tool_call_id.trim() : typeof source.toolCallId === "string" ? source.toolCallId.trim() : "";
|
|
21
|
+
if (toolCallId) mutableTarget.tool_call_id = toolCallId;
|
|
22
|
+
}
|
|
23
|
+
return target;
|
|
24
|
+
}
|
|
25
|
+
function toOpenAiCompatibleMessages(messages, options) {
|
|
26
|
+
return messages.map(
|
|
27
|
+
(message) => preserveAgentStateFields(message, {
|
|
28
|
+
role: message.role,
|
|
29
|
+
content: message.content ?? ""
|
|
30
|
+
}, options)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
function shouldStripReasoningContentForOutbound(provider, model) {
|
|
34
|
+
const p = provider?.trim().toLowerCase();
|
|
35
|
+
const m = model?.trim().toLowerCase();
|
|
36
|
+
if (!p || !m) return false;
|
|
37
|
+
if (p === "deepseek" || p === "nolo") return m === "deepseek-v4-flash";
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// packages/integrations/openai/responsesHelpers.ts
|
|
42
|
+
var RESPONSES_TOP_LEVEL_SCHEMA_KEYS = ["anyOf", "oneOf", "allOf", "enum", "not"];
|
|
43
|
+
var sanitizeResponsesParameters = (parameters) => {
|
|
44
|
+
if (!isRecord(parameters)) {
|
|
45
|
+
return parameters;
|
|
46
|
+
}
|
|
47
|
+
const next = { ...parameters };
|
|
48
|
+
for (const key of RESPONSES_TOP_LEVEL_SCHEMA_KEYS) {
|
|
49
|
+
delete next[key];
|
|
50
|
+
}
|
|
51
|
+
return next;
|
|
52
|
+
};
|
|
53
|
+
var appendTextPart = (parts, text, role) => {
|
|
54
|
+
if (!text) return;
|
|
55
|
+
const last = parts.at(-1);
|
|
56
|
+
const textType = role === "assistant" ? "output_text" : "input_text";
|
|
57
|
+
if (last?.type === textType) {
|
|
58
|
+
last.text += text;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
parts.push({ type: textType, text });
|
|
62
|
+
};
|
|
63
|
+
var normalizeMessageParts = (content, role) => {
|
|
64
|
+
if (typeof content === "string") {
|
|
65
|
+
if (!content) return [];
|
|
66
|
+
return [
|
|
67
|
+
{
|
|
68
|
+
type: role === "assistant" ? "output_text" : "input_text",
|
|
69
|
+
text: content
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
const parts = [];
|
|
74
|
+
for (const part of content ?? []) {
|
|
75
|
+
const typedPart = part;
|
|
76
|
+
if (typedPart?.type === "text" && typeof typedPart.text === "string") {
|
|
77
|
+
appendTextPart(parts, typedPart.text, role);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (typedPart?.type === "image_url" && typeof typedPart.image_url?.url === "string" && typedPart.image_url.url) {
|
|
81
|
+
if (role === "assistant") continue;
|
|
82
|
+
parts.push({
|
|
83
|
+
type: "input_image",
|
|
84
|
+
image_url: typedPart.image_url.url,
|
|
85
|
+
detail: typedPart.image_url.detail
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return parts;
|
|
90
|
+
};
|
|
91
|
+
var normalizeToolOutput = (content) => {
|
|
92
|
+
if (typeof content === "string") return content;
|
|
93
|
+
return JSON.stringify(content ?? "");
|
|
94
|
+
};
|
|
95
|
+
var toResponsesTools = (tools) => {
|
|
96
|
+
if (!Array.isArray(tools) || tools.length === 0) return void 0;
|
|
97
|
+
return tools.map((tool) => {
|
|
98
|
+
const fn = tool?.function;
|
|
99
|
+
if (!fn?.name) return null;
|
|
100
|
+
return {
|
|
101
|
+
type: "function",
|
|
102
|
+
name: fn.name,
|
|
103
|
+
description: fn.description,
|
|
104
|
+
parameters: sanitizeResponsesParameters(fn.parameters),
|
|
105
|
+
strict: fn.strict
|
|
106
|
+
};
|
|
107
|
+
}).filter(Boolean);
|
|
108
|
+
};
|
|
109
|
+
var convertMessagesToResponsesInput = (messages, options) => {
|
|
110
|
+
const input = [];
|
|
111
|
+
for (const message of messages) {
|
|
112
|
+
if (!message?.role) continue;
|
|
113
|
+
if (message.role === "tool") {
|
|
114
|
+
if (!message.tool_call_id) continue;
|
|
115
|
+
input.push({
|
|
116
|
+
type: "function_call_output",
|
|
117
|
+
call_id: message.tool_call_id,
|
|
118
|
+
output: normalizeToolOutput(message.content)
|
|
119
|
+
});
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const role = message.role;
|
|
123
|
+
if (role === "assistant" && !options?.stripReasoningContent && typeof message.reasoning_content === "string" && message.reasoning_content) {
|
|
124
|
+
input.push({ type: "reasoning", content: message.reasoning_content });
|
|
125
|
+
}
|
|
126
|
+
const contentParts = normalizeMessageParts(message.content, role);
|
|
127
|
+
if (contentParts.length > 0) {
|
|
128
|
+
input.push({
|
|
129
|
+
type: "message",
|
|
130
|
+
role,
|
|
131
|
+
content: contentParts
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
if (role === "assistant" && Array.isArray(message.content)) {
|
|
135
|
+
const replayImages = message.content.map((part) => part).filter(
|
|
136
|
+
(part) => part?.type === "image_url" && typeof part.image_url?.url === "string" && Boolean(part.image_url.url)
|
|
137
|
+
).map((part) => ({
|
|
138
|
+
type: "input_image",
|
|
139
|
+
image_url: part.image_url.url,
|
|
140
|
+
detail: part.image_url.detail
|
|
141
|
+
}));
|
|
142
|
+
if (replayImages.length > 0) {
|
|
143
|
+
input.push({
|
|
144
|
+
type: "message",
|
|
145
|
+
role: "user",
|
|
146
|
+
content: replayImages
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (role === "assistant" && Array.isArray(message.tool_calls)) {
|
|
151
|
+
for (const toolCall of message.tool_calls) {
|
|
152
|
+
if (!toolCall?.id || !toolCall.function?.name) continue;
|
|
153
|
+
input.push({
|
|
154
|
+
type: "function_call",
|
|
155
|
+
call_id: toolCall.id,
|
|
156
|
+
name: toolCall.function.name,
|
|
157
|
+
arguments: typeof toolCall.function.arguments === "string" ? toolCall.function.arguments : JSON.stringify(toolCall.function.arguments ?? {})
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return input;
|
|
163
|
+
};
|
|
164
|
+
var extractTextFromResponseOutput = (response) => {
|
|
165
|
+
const parts = [];
|
|
166
|
+
for (const item of response?.output ?? []) {
|
|
167
|
+
if (item?.type !== "message") continue;
|
|
168
|
+
for (const content of item.content ?? []) {
|
|
169
|
+
if (content?.type === "output_text" && typeof content.text === "string") {
|
|
170
|
+
parts.push(content.text);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return parts.join("");
|
|
175
|
+
};
|
|
176
|
+
var toDataUrl = (base64Data, mimeType) => {
|
|
177
|
+
const normalizedMimeType = asOptionalTrimmedString(mimeType) ?? "image/png";
|
|
178
|
+
return `data:${normalizedMimeType};base64,${base64Data}`;
|
|
179
|
+
};
|
|
180
|
+
var extractImagePartsFromResponseOutput = (response) => {
|
|
181
|
+
const images = [];
|
|
182
|
+
for (const item of response?.output ?? []) {
|
|
183
|
+
if (item?.type === "image_generation_call") {
|
|
184
|
+
const result = asOptionalTrimmedString(item.result);
|
|
185
|
+
if (result) {
|
|
186
|
+
const outputFormat = asOptionalTrimmedString(item.output_format);
|
|
187
|
+
images.push({
|
|
188
|
+
type: "image_url",
|
|
189
|
+
image_url: {
|
|
190
|
+
url: toDataUrl(
|
|
191
|
+
result,
|
|
192
|
+
outputFormat ? `image/${outputFormat}` : void 0
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (item?.type !== "message") continue;
|
|
200
|
+
for (const content of item.content ?? []) {
|
|
201
|
+
const result = asOptionalTrimmedString(content?.result);
|
|
202
|
+
if (content?.type === "output_image" && result) {
|
|
203
|
+
images.push({
|
|
204
|
+
type: "image_url",
|
|
205
|
+
image_url: {
|
|
206
|
+
url: toDataUrl(
|
|
207
|
+
result,
|
|
208
|
+
content.mime_type ?? content.mimeType ?? null
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return images;
|
|
216
|
+
};
|
|
217
|
+
var extractToolCallsFromResponseOutput = (response) => {
|
|
218
|
+
const calls = [];
|
|
219
|
+
for (const item of response?.output ?? []) {
|
|
220
|
+
if (item?.type !== "function_call") continue;
|
|
221
|
+
if (!item.call_id || !item.name) continue;
|
|
222
|
+
calls.push({
|
|
223
|
+
id: item.call_id,
|
|
224
|
+
type: "function",
|
|
225
|
+
function: {
|
|
226
|
+
name: item.name,
|
|
227
|
+
arguments: typeof item.arguments === "string" ? item.arguments : JSON.stringify(item.arguments ?? {})
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return calls;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// packages/core/chat/imageParts.ts
|
|
235
|
+
function isImageUrlPart(part) {
|
|
236
|
+
return isRecord(part) && part.type === "image_url";
|
|
237
|
+
}
|
|
238
|
+
function hasImageParts(messages) {
|
|
239
|
+
return messages.some(
|
|
240
|
+
(message) => Array.isArray(message.content) && message.content.some(isImageUrlPart)
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export {
|
|
245
|
+
isImageUrlPart,
|
|
246
|
+
hasImageParts,
|
|
247
|
+
preserveAgentStateFields,
|
|
248
|
+
toOpenAiCompatibleMessages,
|
|
249
|
+
shouldStripReasoningContentForOutbound,
|
|
250
|
+
toResponsesTools,
|
|
251
|
+
convertMessagesToResponsesInput,
|
|
252
|
+
extractTextFromResponseOutput,
|
|
253
|
+
extractImagePartsFromResponseOutput,
|
|
254
|
+
extractToolCallsFromResponseOutput
|
|
255
|
+
};
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
listUserRecordsFromServers,
|
|
8
8
|
readDbRecordFromServers,
|
|
9
9
|
readLiveDbRecordAfterTombstoneMerge
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ZVOZH2HW.js";
|
|
11
11
|
import {
|
|
12
12
|
buildDialogAttachmentPlan,
|
|
13
13
|
extractFileContentIds
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-B5TOXZAK.js";
|
|
15
15
|
import {
|
|
16
16
|
toErrorMessage
|
|
17
17
|
} from "./chunk-HNMXYYJR.js";
|
|
@@ -625,7 +625,7 @@ async function tryHttpDialogCandidates(args) {
|
|
|
625
625
|
throw Object.assign(new Error("All HTTP dialog reads failed"), { attempts });
|
|
626
626
|
}
|
|
627
627
|
async function readDialogFromLocalDb(dialogKey, dialogId, limit) {
|
|
628
|
-
const { readDialogFromLocalDb: readLocalDialog } = await import("./localDialogRead-
|
|
628
|
+
const { readDialogFromLocalDb: readLocalDialog } = await import("./localDialogRead-HQZPVIE3.js");
|
|
629
629
|
const result = await readLocalDialog({ dialogKey, dialogId, limit });
|
|
630
630
|
return {
|
|
631
631
|
...result,
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
// packages/agent-runtime/
|
|
2
|
-
var OPEN_TAG = "<think>";
|
|
3
|
-
var CLOSE_TAG = "</think>";
|
|
1
|
+
// packages/agent-runtime/tagPrefixMatch.ts
|
|
4
2
|
function longestTagPrefixLength(buffer, tag) {
|
|
5
3
|
const max = Math.min(buffer.length, tag.length - 1);
|
|
6
4
|
for (let len = max; len > 0; len--) {
|
|
@@ -10,6 +8,10 @@ function longestTagPrefixLength(buffer, tag) {
|
|
|
10
8
|
}
|
|
11
9
|
return 0;
|
|
12
10
|
}
|
|
11
|
+
|
|
12
|
+
// packages/agent-runtime/thinkTagParser.ts
|
|
13
|
+
var OPEN_TAG = "<think>";
|
|
14
|
+
var CLOSE_TAG = "</think>";
|
|
13
15
|
function extractThinkContent(content) {
|
|
14
16
|
const regex = new RegExp(`${OPEN_TAG}([\\s\\S]*?)${CLOSE_TAG}`, "g");
|
|
15
17
|
const matches = [...content.matchAll(regex)];
|
|
@@ -81,6 +83,98 @@ function flushThinkParser(state) {
|
|
|
81
83
|
};
|
|
82
84
|
}
|
|
83
85
|
|
|
86
|
+
// packages/agent-runtime/toolCallTextParser.ts
|
|
87
|
+
var OPEN_TAG2 = "<tool_call>";
|
|
88
|
+
var CLOSE_TAG2 = "</tool_call>";
|
|
89
|
+
function createToolCallTextParserState() {
|
|
90
|
+
return { mode: "content", buffer: "" };
|
|
91
|
+
}
|
|
92
|
+
function processToolCallTextChunk(chunk, state) {
|
|
93
|
+
let visible = "";
|
|
94
|
+
let toolCallTexts = [];
|
|
95
|
+
let { mode, buffer } = state;
|
|
96
|
+
buffer += chunk;
|
|
97
|
+
while (true) {
|
|
98
|
+
if (mode === "content") {
|
|
99
|
+
const idx = buffer.indexOf(OPEN_TAG2);
|
|
100
|
+
if (idx === -1) {
|
|
101
|
+
const keep = longestTagPrefixLength(buffer, OPEN_TAG2);
|
|
102
|
+
visible += buffer.slice(0, buffer.length - keep);
|
|
103
|
+
buffer = buffer.slice(buffer.length - keep);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
visible += buffer.slice(0, idx);
|
|
107
|
+
buffer = buffer.slice(idx + OPEN_TAG2.length);
|
|
108
|
+
mode = "toolcall";
|
|
109
|
+
} else {
|
|
110
|
+
const idx = buffer.indexOf(CLOSE_TAG2);
|
|
111
|
+
if (idx === -1) {
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
toolCallTexts.push(buffer.slice(0, idx));
|
|
115
|
+
buffer = buffer.slice(idx + CLOSE_TAG2.length);
|
|
116
|
+
mode = "content";
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
content: visible,
|
|
121
|
+
toolCallTexts,
|
|
122
|
+
state: { mode, buffer }
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function flushToolCallTextParser(state) {
|
|
126
|
+
const { mode, buffer } = state;
|
|
127
|
+
if (mode === "toolcall") {
|
|
128
|
+
const keep = longestTagPrefixLength(buffer, CLOSE_TAG2);
|
|
129
|
+
const text = buffer.slice(0, buffer.length - keep);
|
|
130
|
+
return {
|
|
131
|
+
content: "",
|
|
132
|
+
toolCallTexts: text ? [text] : [],
|
|
133
|
+
state: { mode: "content", buffer: "" }
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
content: buffer,
|
|
138
|
+
toolCallTexts: [],
|
|
139
|
+
state: { mode: "content", buffer: "" }
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function tryParseToolCallText(text) {
|
|
143
|
+
const trimmed = text.trim();
|
|
144
|
+
if (!trimmed) return null;
|
|
145
|
+
try {
|
|
146
|
+
const parsed = JSON.parse(trimmed);
|
|
147
|
+
if (typeof parsed === "object" && parsed !== null && typeof parsed.name === "string") {
|
|
148
|
+
return {
|
|
149
|
+
name: parsed.name,
|
|
150
|
+
arguments: typeof parsed.arguments === "string" ? parsed.arguments : JSON.stringify(parsed.arguments ?? {})
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
} catch {
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
function processContentChunkWithToolCallStripping(chunk, state, onToolCall) {
|
|
158
|
+
const stripped = processToolCallTextChunk(chunk, state);
|
|
159
|
+
for (const text of stripped.toolCallTexts) {
|
|
160
|
+
const parsedTc = tryParseToolCallText(text);
|
|
161
|
+
if (parsedTc) {
|
|
162
|
+
onToolCall(parsedTc.name, parsedTc.arguments);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return { cleanedContent: stripped.content, state: stripped.state };
|
|
166
|
+
}
|
|
167
|
+
function flushToolCallTextParserIntoCallback(state, onToolCall) {
|
|
168
|
+
const flushed = flushToolCallTextParser(state);
|
|
169
|
+
for (const text of flushed.toolCallTexts) {
|
|
170
|
+
const parsedTc = tryParseToolCallText(text);
|
|
171
|
+
if (parsedTc) {
|
|
172
|
+
onToolCall(parsedTc.name, parsedTc.arguments);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return { residualContent: flushed.content, state: flushed.state };
|
|
176
|
+
}
|
|
177
|
+
|
|
84
178
|
// packages/agent-runtime/toolCallAccumulator.ts
|
|
85
179
|
function createToolCallAccumulator() {
|
|
86
180
|
return { slots: [] };
|
|
@@ -141,6 +235,9 @@ export {
|
|
|
141
235
|
createThinkParserState,
|
|
142
236
|
processThinkChunk,
|
|
143
237
|
flushThinkParser,
|
|
238
|
+
createToolCallTextParserState,
|
|
239
|
+
processContentChunkWithToolCallStripping,
|
|
240
|
+
flushToolCallTextParserIntoCallback,
|
|
144
241
|
createToolCallAccumulator,
|
|
145
242
|
accumulateToolCallDelta,
|
|
146
243
|
finalizeAccumulatedToolCalls
|
|
@@ -11,16 +11,16 @@ import {
|
|
|
11
11
|
patch,
|
|
12
12
|
remove,
|
|
13
13
|
write
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-XRZJGPFI.js";
|
|
15
15
|
import {
|
|
16
16
|
createAgentKey,
|
|
17
17
|
toTrimmedString
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-6Y7A3OQQ.js";
|
|
19
19
|
import {
|
|
20
20
|
asyncThunkCreator,
|
|
21
21
|
buildCreateSlice,
|
|
22
22
|
getRuntimeServerContext
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-XMLRJUU5.js";
|
|
24
24
|
import {
|
|
25
25
|
asTrimmedString
|
|
26
26
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -300,7 +300,7 @@ var slice = createSliceWithThunks({
|
|
|
300
300
|
const overrides = {};
|
|
301
301
|
if (args.systemPromptOverride !== void 0) overrides.prompt = args.systemPromptOverride;
|
|
302
302
|
if (args.toolsOverride !== void 0) overrides.tools = args.toolsOverride;
|
|
303
|
-
const { _executeModel } = await import("./_executeModel-
|
|
303
|
+
const { _executeModel } = await import("./_executeModel-WPNX5DH4.js");
|
|
304
304
|
return _executeModel(
|
|
305
305
|
{
|
|
306
306
|
isStreaming: args.isStreaming ?? false,
|
|
@@ -321,7 +321,7 @@ var slice = createSliceWithThunks({
|
|
|
321
321
|
* - 循环直到无工具调用或触发其他运行时停止条件
|
|
322
322
|
*/
|
|
323
323
|
runAgent: create.asyncThunk(async (args, thunkApi) => {
|
|
324
|
-
const { runAgentClientLoop } = await import("./runAgentClientLoop-
|
|
324
|
+
const { runAgentClientLoop } = await import("./runAgentClientLoop-OBD2AVEL.js");
|
|
325
325
|
const { content: loopContent, toolCallCount } = await runAgentClientLoop(
|
|
326
326
|
{
|
|
327
327
|
agentKey: args.agentKey,
|
|
@@ -337,7 +337,7 @@ var slice = createSliceWithThunks({
|
|
|
337
337
|
* 聊天轮次流式 Agent 调用
|
|
338
338
|
*/
|
|
339
339
|
streamAgentChatTurn: create.asyncThunk(async (args, thunkApi) => {
|
|
340
|
-
const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-
|
|
340
|
+
const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-UHEMNI3X.js");
|
|
341
341
|
return streamAgentChatTurnHandler(args, thunkApi);
|
|
342
342
|
}),
|
|
343
343
|
/**
|