nolo-cli 0.102.2 → 0.102.3

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 (58) hide show
  1. package/{_executeModel-B6SS2ISV.js → _executeModel-TOH473HN.js} +10 -10
  2. package/{agentDeleteCommand-MEKEAJS6.js → agentDeleteCommand-3EV2EOUI.js} +12 -12
  3. package/{agentEmailCommands-NCQSCDX7.js → agentEmailCommands-V2V54ZIH.js} +13 -13
  4. package/{agentListCommands-VLNQH2BR.js → agentListCommands-SRRN3TCW.js} +4 -4
  5. package/{agentMachineCommands-ZYKZGX65.js → agentMachineCommands-JYJMU27G.js} +5 -5
  6. package/{agentRecordCommands-2INKPT2O.js → agentRecordCommands-KQMZLZHW.js} +13 -13
  7. package/{agentRunCommand-2SZBC7BP.js → agentRunCommand-IWKQO47Q.js} +13 -13
  8. package/{agentRuntimeLocal-7VIX3R3R.js → agentRuntimeLocal-3QKZ76C7.js} +4 -4
  9. package/{agentSlice-4JIT2XG4.js → agentSlice-MR6JWMM5.js} +1 -1
  10. package/{appDeleteCommands-YLCAVP4I.js → appDeleteCommands-SZFKFV4S.js} +4 -4
  11. package/{appDeployCommands-7PQPIIEL.js → appDeployCommands-JWH5HMET.js} +4 -4
  12. package/{appDeployStatusCommands-Z3YBCYU3.js → appDeployStatusCommands-CLONFBVO.js} +4 -4
  13. package/{appGetCommands-MCY6JLD3.js → appGetCommands-4Z7V7UYA.js} +4 -4
  14. package/{appListCommands-O6QDXYKT.js → appListCommands-IIUS64VI.js} +4 -4
  15. package/{authCommand-I6LVUQKM.js → authCommand-NQPMGYHP.js} +1 -1
  16. package/{chunk-VPNDYFUB.js → chunk-3MSJ4XDQ.js} +2 -2
  17. package/{chunk-2K54PIZY.js → chunk-6XHM3LNF.js} +2 -2
  18. package/{chunk-S7HQBOEA.js → chunk-AFRHU2JO.js} +5 -6
  19. package/{chunk-ZQZZJIQI.js → chunk-BML3APFI.js} +28 -5
  20. package/{chunk-Z5X5MD6D.js → chunk-CMKQ7RCH.js} +1 -1
  21. package/{chunk-NMMU6M4Z.js → chunk-GLD6Q25H.js} +8 -8
  22. package/{chunk-NGO72MN2.js → chunk-HDYUKPEB.js} +3 -3
  23. package/{chunk-TAPMD4SO.js → chunk-JVP74JRH.js} +3 -3
  24. package/{chunk-V3R3UZ4F.js → chunk-MEZSLGQZ.js} +7 -7
  25. package/chunk-NKWIS6G2.js +442 -0
  26. package/{chunk-5UQRASYE.js → chunk-NR7N2RWA.js} +2 -2
  27. package/{chunk-XTM4WSXT.js → chunk-O2LBWZLR.js} +5 -5
  28. package/{chunk-GJ647AYV.js → chunk-REPRKRB2.js} +1 -1
  29. package/{chunk-DLXHN5XZ.js → chunk-S274RDSE.js} +3 -3
  30. package/{chunk-ERFIIS4C.js → chunk-USTPPV3J.js} +1 -1
  31. package/{chunk-K4URP6NQ.js → chunk-VL3H5ZU3.js} +47 -6
  32. package/{chunk-TTMNMJVI.js → chunk-YIEUDVD6.js} +8 -8
  33. package/{chunk-OW4APERY.js → chunk-YK5MHOWM.js} +54 -9
  34. package/{commandRegistry-X7FA6WJQ.js → commandRegistry-POKHERIN.js} +47 -47
  35. package/{contentThunks-CH5Z3XAD.js → contentThunks-HEEW3GBT.js} +3 -3
  36. package/{createAgentAutomationAction-4MV3MWVE.js → createAgentAutomationAction-C5UTM2ZI.js} +3 -3
  37. package/{createDialogAction-BYCJKWFY.js → createDialogAction-VODZCSHM.js} +4 -4
  38. package/{createPageAction-XWDTQHFL.js → createPageAction-XUFSVLBC.js} +3 -3
  39. package/{dialogCommands-NNSKMYZR.js → dialogCommands-4XNYPCE7.js} +4 -4
  40. package/{dialogSlice-LUUVLJKZ.js → dialogSlice-KXBFWRVK.js} +2 -2
  41. package/{docCreateCommands-BKCYZTJW.js → docCreateCommands-P4XCR2SW.js} +4 -4
  42. package/{docDeleteCommands-AJDU5BUV.js → docDeleteCommands-KZZ3L6LS.js} +4 -4
  43. package/{docReadCommands-PPI2UAIW.js → docReadCommands-JN6HL4BC.js} +4 -4
  44. package/{docStore-RRAGFCNQ.js → docStore-PLGBTV5U.js} +1 -1
  45. package/{docUpdateCommands-62WIRKAN.js → docUpdateCommands-EYE7BTXW.js} +4 -4
  46. package/{handleSendMessageAction-CW5HSH4E.js → handleSendMessageAction-BBB6A54Z.js} +2 -2
  47. package/index.js +3 -3
  48. package/{machineCommands-FG6HBFB7.js → machineCommands-4LP4XFEY.js} +13 -13
  49. package/{machineWsRunDispatch-7JCANNGT.js → machineWsRunDispatch-4PWOZYRA.js} +13 -13
  50. package/package.json +1 -1
  51. package/{readlineWorkspace-HISW3JNJ.js → readlineWorkspace-CFUUABFV.js} +41 -42
  52. package/{runAgentClientLoop-4XIIPXH3.js → runAgentClientLoop-CAPNBF7Q.js} +8 -8
  53. package/{spaceCommands-BBEY2U7J.js → spaceCommands-QCZUWUMS.js} +4 -4
  54. package/{streamAgentChatTurn-WRLQAWTW.js → streamAgentChatTurn-XX3N3P4J.js} +10 -10
  55. package/{tools-NPSZ3DTN.js → tools-U6BT6H56.js} +6 -6
  56. package/{tuiSummaryLlmCaller-O3DZKOHE.js → tuiSummaryLlmCaller-QCHCULPM.js} +2 -2
  57. package/{updateDialogTitleAction-DBW4OTMM.js → updateDialogTitleAction-NKHQ5LCX.js} +3 -3
  58. package/chunk-CQ3WA2NE.js +0 -299
@@ -15,11 +15,11 @@ import {
15
15
  readStreamChunk,
16
16
  sendOpenAICompletionsRequest,
17
17
  updateTotalUsage
18
- } from "./chunk-XTM4WSXT.js";
18
+ } from "./chunk-O2LBWZLR.js";
19
19
  import "./chunk-JEXVIMYZ.js";
20
20
  import {
21
21
  prepareTools
22
- } from "./chunk-2K54PIZY.js";
22
+ } from "./chunk-6XHM3LNF.js";
23
23
  import {
24
24
  INVALID_TOOL_ARGS_REPLACEMENT,
25
25
  buildInvalidToolCallSelfHealResult,
@@ -37,7 +37,7 @@ import {
37
37
  sanitizeOutboundResponsesInput,
38
38
  selectResponsesConversationState,
39
39
  updateResponsesConversationState
40
- } from "./chunk-DLXHN5XZ.js";
40
+ } from "./chunk-S274RDSE.js";
41
41
  import "./chunk-EOARMOVD.js";
42
42
  import "./chunk-HS7MLR74.js";
43
43
  import {
@@ -51,7 +51,7 @@ import {
51
51
  selectMaxExecutionTime,
52
52
  selectSpaceContextLevel,
53
53
  selectUserTonePreset
54
- } from "./chunk-TTMNMJVI.js";
54
+ } from "./chunk-YIEUDVD6.js";
55
55
  import "./chunk-NF64D32W.js";
56
56
  import "./chunk-YGCJITP3.js";
57
57
  import "./chunk-AOTBKDRK.js";
@@ -89,12 +89,12 @@ import "./chunk-63W5N6P3.js";
89
89
  import "./chunk-VF4K2QE6.js";
90
90
  import {
91
91
  getDocState
92
- } from "./chunk-VPNDYFUB.js";
93
- import "./chunk-5UQRASYE.js";
92
+ } from "./chunk-3MSJ4XDQ.js";
93
+ import "./chunk-NR7N2RWA.js";
94
94
  import "./chunk-E3YWHWCR.js";
95
95
  import {
96
96
  getTableState
97
- } from "./chunk-GJ647AYV.js";
97
+ } from "./chunk-REPRKRB2.js";
98
98
  import {
99
99
  getCurrentSpaceId,
100
100
  getCurrentSpaceIdRaw,
@@ -118,12 +118,12 @@ import {
118
118
  selectDialogConfigByKey,
119
119
  updateTokens,
120
120
  updateToolMessage
121
- } from "./chunk-NMMU6M4Z.js";
121
+ } from "./chunk-GLD6Q25H.js";
122
122
  import "./chunk-YYLHWIW6.js";
123
123
  import "./chunk-CUF4MYKI.js";
124
124
  import "./chunk-523DITKR.js";
125
125
  import "./chunk-AGGIDPCZ.js";
126
- import "./chunk-TAPMD4SO.js";
126
+ import "./chunk-JVP74JRH.js";
127
127
  import {
128
128
  createCliChatTurnStream,
129
129
  getCliChatSession,
@@ -171,7 +171,7 @@ import {
171
171
  stripImagePartsForTextOnlyAgent
172
172
  } from "./chunk-HD3S2F7U.js";
173
173
  import "./chunk-5ZUL4CUO.js";
174
- import "./chunk-CQ3WA2NE.js";
174
+ import "./chunk-NKWIS6G2.js";
175
175
  import "./chunk-N7J63Q6C.js";
176
176
  import "./chunk-KNVDNYH7.js";
177
177
  import {
@@ -8,7 +8,7 @@ import {
8
8
  toolQueryFunc,
9
9
  toolQueryFunctionSchema,
10
10
  toolRegistry
11
- } from "./chunk-TTMNMJVI.js";
11
+ } from "./chunk-YIEUDVD6.js";
12
12
  import "./chunk-NF64D32W.js";
13
13
  import "./chunk-YGCJITP3.js";
14
14
  import "./chunk-AOTBKDRK.js";
@@ -24,17 +24,17 @@ import "./chunk-NUHHBEJC.js";
24
24
  import "./chunk-AGIM7IMJ.js";
25
25
  import "./chunk-63W5N6P3.js";
26
26
  import "./chunk-VF4K2QE6.js";
27
- import "./chunk-VPNDYFUB.js";
28
- import "./chunk-5UQRASYE.js";
27
+ import "./chunk-3MSJ4XDQ.js";
28
+ import "./chunk-NR7N2RWA.js";
29
29
  import "./chunk-E3YWHWCR.js";
30
- import "./chunk-GJ647AYV.js";
30
+ import "./chunk-REPRKRB2.js";
31
31
  import "./chunk-ZJ7UHBJS.js";
32
- import "./chunk-NMMU6M4Z.js";
32
+ import "./chunk-GLD6Q25H.js";
33
33
  import "./chunk-YYLHWIW6.js";
34
34
  import "./chunk-CUF4MYKI.js";
35
35
  import "./chunk-523DITKR.js";
36
36
  import "./chunk-AGGIDPCZ.js";
37
- import "./chunk-TAPMD4SO.js";
37
+ import "./chunk-JVP74JRH.js";
38
38
  import "./chunk-2K4TM6AW.js";
39
39
  import "./chunk-5RGU3J7P.js";
40
40
  import "./chunk-ZRAU6T47.js";
@@ -7,9 +7,9 @@ import {
7
7
  canUsePlatformChatProvider,
8
8
  parsePlatformChatCompletionResponse,
9
9
  resolvePlatformChatProviderConfig
10
- } from "./chunk-K4URP6NQ.js";
10
+ } from "./chunk-VL3H5ZU3.js";
11
11
  import "./chunk-GMZLP5DV.js";
12
- import "./chunk-CQ3WA2NE.js";
12
+ import "./chunk-NKWIS6G2.js";
13
13
  import "./chunk-N7J63Q6C.js";
14
14
  import "./chunk-M7VLQGQP.js";
15
15
  import {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  updateContentTitle
3
- } from "./chunk-GJ647AYV.js";
3
+ } from "./chunk-REPRKRB2.js";
4
4
  import "./chunk-ZJ7UHBJS.js";
5
5
  import {
6
6
  format,
7
7
  isAssistantToolStub,
8
8
  selectAllMsgs
9
- } from "./chunk-NMMU6M4Z.js";
9
+ } from "./chunk-GLD6Q25H.js";
10
10
  import "./chunk-YYLHWIW6.js";
11
11
  import "./chunk-CUF4MYKI.js";
12
12
  import {
@@ -16,7 +16,7 @@ import {
16
16
  import "./chunk-AGGIDPCZ.js";
17
17
  import {
18
18
  runLlm
19
- } from "./chunk-TAPMD4SO.js";
19
+ } from "./chunk-JVP74JRH.js";
20
20
  import "./chunk-2K4TM6AW.js";
21
21
  import "./chunk-5RGU3J7P.js";
22
22
  import "./chunk-ZRAU6T47.js";
package/chunk-CQ3WA2NE.js DELETED
@@ -1,299 +0,0 @@
1
- // packages/agent-runtime/declaredToolNames.ts
2
- function extractDeclaredToolNames(tools) {
3
- if (!Array.isArray(tools)) return void 0;
4
- const names = /* @__PURE__ */ new Set();
5
- for (const t of tools) {
6
- const fn = t?.function;
7
- if (fn && typeof fn.name === "string" && fn.name) names.add(fn.name);
8
- }
9
- return names;
10
- }
11
-
12
- // packages/agent-runtime/outboundHistorySanitize.ts
13
- function sanitizeForOutbound(messages, tools) {
14
- return sanitizeOutboundHistory(messages, {
15
- declaredToolNames: extractDeclaredToolNames(tools)
16
- });
17
- }
18
- function stableToolCallId(assistantIndex, callIndex) {
19
- return `call_sanitize_${assistantIndex}_${callIndex}`;
20
- }
21
- function isString(v) {
22
- return typeof v === "string";
23
- }
24
- function isNonEmptyString(v) {
25
- return typeof v === "string" && v.length > 0;
26
- }
27
- function joinLines(...parts) {
28
- return parts.filter(isNonEmptyString).join("\n");
29
- }
30
- function jsonStringifyArguments(args) {
31
- if (typeof args === "string") return args;
32
- try {
33
- return JSON.stringify(args ?? "");
34
- } catch {
35
- return "";
36
- }
37
- }
38
- function renderToolCallAsText(call) {
39
- const name = call?.function?.name ?? "unknown";
40
- const rawArgs = call?.function?.arguments;
41
- const args = jsonStringifyArguments(rawArgs);
42
- return `[tool_call: ${name}(${args})]`;
43
- }
44
- function renderToolResultAsText(message) {
45
- const name = isNonEmptyString(message.toolName) ? message.toolName : "tool";
46
- const body = typeof message.content === "string" ? message.content : "";
47
- return `[tool_result: ${name}: ${body}]`;
48
- }
49
- function normalizeToolCall(call, assistantIndex, callIndex) {
50
- if (!call || typeof call !== "object") return null;
51
- const c = call;
52
- const fn = c.function;
53
- if (!fn || typeof fn !== "object" || !isString(fn.name)) return null;
54
- const id = isNonEmptyString(c.id) ? c.id : stableToolCallId(assistantIndex, callIndex);
55
- return {
56
- id,
57
- type: isString(c.type) && c.type ? c.type : "function",
58
- function: { name: fn.name, arguments: jsonStringifyArguments(fn.arguments) },
59
- ...typeof c.thought_signature === "string" ? { thought_signature: c.thought_signature } : {}
60
- };
61
- }
62
- function sanitizeOutboundHistory(messages, options) {
63
- if (!Array.isArray(messages) || messages.length === 0) return messages;
64
- const declared = options?.declaredToolNames;
65
- const candidateCallIds = /* @__PURE__ */ new Set();
66
- for (let i = 0; i < messages.length; i++) {
67
- const m = messages[i];
68
- if (m.role !== "assistant" || !Array.isArray(m.tool_calls)) continue;
69
- m.tool_calls.forEach((call, callIndex) => {
70
- const name = call?.function?.name;
71
- const declaredAllows = !declared || isString(name) && declared.has(name);
72
- if (!declaredAllows) return;
73
- if (!hasParsableObjectArguments(call?.function?.arguments)) {
74
- return;
75
- }
76
- const id = isNonEmptyString(call?.id) ? call.id : stableToolCallId(i, callIndex);
77
- candidateCallIds.add(id);
78
- });
79
- }
80
- const resultIds = /* @__PURE__ */ new Set();
81
- for (const m of messages) {
82
- if (m.role === "tool" && isNonEmptyString(m.tool_call_id)) {
83
- resultIds.add(m.tool_call_id);
84
- }
85
- }
86
- const keepCallIds = /* @__PURE__ */ new Set();
87
- for (const id of candidateCallIds) {
88
- if (resultIds.has(id)) keepCallIds.add(id);
89
- }
90
- const out = [];
91
- for (let i = 0; i < messages.length; i++) {
92
- const m = messages[i];
93
- if (m.role === "assistant") {
94
- let toolCalls;
95
- const downgradedLines = [];
96
- if (Array.isArray(m.tool_calls) && m.tool_calls.length > 0) {
97
- const kept = [];
98
- m.tool_calls.forEach((call, callIndex) => {
99
- const name = call?.function?.name;
100
- const declaredAllows = !declared || isString(name) && declared.has(name);
101
- const id = isNonEmptyString(call?.id) ? call.id : stableToolCallId(i, callIndex);
102
- const keepStructural = declaredAllows && keepCallIds.has(id);
103
- if (keepStructural) {
104
- const normalized = normalizeToolCall(call, i, callIndex);
105
- if (normalized) kept.push(normalized);
106
- } else {
107
- downgradedLines.push(renderToolCallAsText(call));
108
- }
109
- });
110
- toolCalls = kept.length > 0 ? kept : void 0;
111
- }
112
- const downgradedText = joinLines(...downgradedLines);
113
- const contentWithDowngrade = downgradedText.length > 0 ? combineContentWithText(m.content, downgradedText) : m.content;
114
- const sanitizedAssistant = {
115
- ...m,
116
- content: contentWithDowngrade,
117
- tool_calls: toolCalls
118
- };
119
- if (!toolCalls) delete sanitizedAssistant.tool_calls;
120
- out.push(sanitizedAssistant);
121
- continue;
122
- }
123
- if (m.role === "tool") {
124
- const id = isNonEmptyString(m.tool_call_id) ? m.tool_call_id : "";
125
- if (id && keepCallIds.has(id)) {
126
- out.push({ ...m, content: m.content ?? "", tool_call_id: id });
127
- } else {
128
- out.push({
129
- role: "assistant",
130
- content: renderToolResultAsText(m)
131
- });
132
- }
133
- continue;
134
- }
135
- out.push({ ...m });
136
- }
137
- return out;
138
- }
139
- function combineContentWithText(base, extra) {
140
- if (typeof base === "string") {
141
- return base ? `${base}
142
- ${extra}` : extra;
143
- }
144
- if (Array.isArray(base)) {
145
- return [...base, { type: "text", text: extra }];
146
- }
147
- return extra;
148
- }
149
- function hasParsableObjectArguments(raw) {
150
- if (raw === void 0) return true;
151
- if (raw === null || typeof raw === "number" || typeof raw === "boolean") {
152
- return false;
153
- }
154
- if (typeof raw !== "string") return true;
155
- if (raw.trim() === "") return true;
156
- try {
157
- const parsed = JSON.parse(raw);
158
- return parsed !== null && typeof parsed === "object";
159
- } catch {
160
- return false;
161
- }
162
- }
163
- var STRICT_JSON_STRING_TOKEN = /^"(?:[^"\\\u0000-\u001F]|\\["\\/bfnrt]|\\u[0-9A-Fa-f]{4})*"$/;
164
- function isStrictJsonStringToken(value) {
165
- if (!STRICT_JSON_STRING_TOKEN.test(value)) return false;
166
- try {
167
- return typeof JSON.parse(value) === "string";
168
- } catch {
169
- return false;
170
- }
171
- }
172
- function closersOf(openStack) {
173
- return openStack.slice().reverse().map((ch) => ch === "{" ? "}" : "]").join("");
174
- }
175
- function scanJsonForTailRepair(input) {
176
- const stack = [];
177
- let inString = false;
178
- let escaped = false;
179
- let lastCommaOutsideString = null;
180
- for (let i = 0; i < input.length; i += 1) {
181
- const ch = input[i];
182
- if (inString) {
183
- if (escaped) escaped = false;
184
- else if (ch === "\\") escaped = true;
185
- else if (ch === '"') inString = false;
186
- continue;
187
- }
188
- if (ch === '"') {
189
- inString = true;
190
- continue;
191
- }
192
- if (ch === "{" || ch === "[") {
193
- stack.push(ch);
194
- continue;
195
- }
196
- if (ch === "}" || ch === "]") {
197
- const open = stack.pop();
198
- if (open !== (ch === "}" ? "{" : "[")) return null;
199
- continue;
200
- }
201
- if (ch === ",") {
202
- lastCommaOutsideString = { index: i, closers: closersOf(stack) };
203
- continue;
204
- }
205
- }
206
- return { inString, closers: closersOf(stack), lastCommaOutsideString };
207
- }
208
- function repairTruncatedToolArguments(raw) {
209
- if (typeof raw !== "string") return null;
210
- const withoutTrailingSpace = raw.replace(/\s+$/, "");
211
- const endsWithComma = withoutTrailingSpace.endsWith(",");
212
- const trimmed = endsWithComma ? withoutTrailingSpace.slice(0, -1).replace(/\s+$/, "") : withoutTrailingSpace;
213
- if (trimmed === "" || trimmed.endsWith(",")) return null;
214
- const scan = scanJsonForTailRepair(trimmed);
215
- if (!scan || scan.inString) return null;
216
- const lastChar = trimmed[trimmed.length - 1];
217
- const tailIsCompleteToken = endsWithComma || lastChar === '"' || lastChar === "}" || lastChar === "]";
218
- if (!tailIsCompleteToken) return null;
219
- const candidates = [trimmed + scan.closers];
220
- const lastComma = scan.lastCommaOutsideString;
221
- if (lastComma && lastComma.index > 0) {
222
- const tailAfterComma = trimmed.slice(lastComma.index + 1).trim();
223
- if (isStrictJsonStringToken(tailAfterComma)) {
224
- const head = trimmed.slice(0, lastComma.index);
225
- candidates.push(head + lastComma.closers);
226
- }
227
- }
228
- for (const candidate of candidates) {
229
- try {
230
- const parsed = JSON.parse(candidate);
231
- if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) && Object.keys(parsed).length > 0) {
232
- return candidate;
233
- }
234
- } catch {
235
- }
236
- }
237
- return null;
238
- }
239
- function downgradeUnparsableToolCalls(messages) {
240
- if (!Array.isArray(messages) || messages.length === 0) {
241
- return { messages, downgraded: 0 };
242
- }
243
- const poisonIds = /* @__PURE__ */ new Set();
244
- for (let i = 0; i < messages.length; i++) {
245
- const m = messages[i];
246
- if (m.role !== "assistant" || !Array.isArray(m.tool_calls)) continue;
247
- m.tool_calls.forEach((call, callIndex) => {
248
- if (!hasParsableObjectArguments(call?.function?.arguments)) {
249
- const id = isNonEmptyString(call?.id) ? call.id : stableToolCallId(i, callIndex);
250
- poisonIds.add(id);
251
- }
252
- });
253
- }
254
- if (poisonIds.size === 0) return { messages, downgraded: 0 };
255
- let downgraded = 0;
256
- const out = [];
257
- for (const m of messages) {
258
- if (m.role === "assistant" && Array.isArray(m.tool_calls) && m.tool_calls.length > 0) {
259
- const kept = [];
260
- const lines = [];
261
- for (const call of m.tool_calls) {
262
- if (!hasParsableObjectArguments(call?.function?.arguments)) {
263
- lines.push(renderToolCallAsText(call));
264
- downgraded++;
265
- } else {
266
- kept.push(call);
267
- }
268
- }
269
- if (lines.length === 0) {
270
- out.push(m);
271
- continue;
272
- }
273
- const sanitized = {
274
- ...m,
275
- content: combineContentWithText(m.content, joinLines(...lines)),
276
- tool_calls: kept.length > 0 ? kept : void 0
277
- };
278
- if (kept.length === 0) delete sanitized.tool_calls;
279
- out.push(sanitized);
280
- continue;
281
- }
282
- if (m.role === "tool") {
283
- const id = isNonEmptyString(m.tool_call_id) ? m.tool_call_id : "";
284
- if (id && poisonIds.has(id)) {
285
- out.push({ role: "assistant", content: renderToolResultAsText(m) });
286
- continue;
287
- }
288
- }
289
- out.push(m);
290
- }
291
- return { messages: out, downgraded };
292
- }
293
-
294
- export {
295
- sanitizeForOutbound,
296
- hasParsableObjectArguments,
297
- repairTruncatedToolArguments,
298
- downgradeUnparsableToolCalls
299
- };