nolo-cli 0.102.1 → 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.
- package/{_executeModel-WLFACVFR.js → _executeModel-TOH473HN.js} +32 -32
- package/{action-PNPQLJHG.js → action-C4KMTCJF.js} +2 -2
- package/{addContentAction-RBOUD7SJ.js → addContentAction-7TNIOVZI.js} +6 -6
- package/{addDialogAgentAction-IODCR6TB.js → addDialogAgentAction-O47J3MVW.js} +5 -5
- package/{agentDeleteCommand-XHHDYJ3U.js → agentDeleteCommand-3EV2EOUI.js} +38 -38
- package/{agentEmailCommands-GJ2TE3CV.js → agentEmailCommands-V2V54ZIH.js} +38 -38
- package/{agentListCommands-B3YHJQNM.js → agentListCommands-SRRN3TCW.js} +21 -21
- package/{agentMachineCommands-KQLRJF5O.js → agentMachineCommands-JYJMU27G.js} +19 -19
- package/{agentRecordCommands-LXDIXYQM.js → agentRecordCommands-KQMZLZHW.js} +38 -38
- package/{agentRunCommand-P2KLVSYL.js → agentRunCommand-IWKQO47Q.js} +38 -38
- package/{agentRuntimeLocal-SXYAKX3A.js → agentRuntimeLocal-3QKZ76C7.js} +16 -16
- package/{agentSlice-WBSSBKBB.js → agentSlice-MR6JWMM5.js} +7 -7
- package/{appDeleteCommands-4EX37I4K.js → appDeleteCommands-SZFKFV4S.js} +20 -20
- package/{appDeployCommands-SDBR3J75.js → appDeployCommands-JWH5HMET.js} +20 -20
- package/{appDeployStatusCommands-764PQNYN.js → appDeployStatusCommands-CLONFBVO.js} +20 -20
- package/{appGetCommands-BBCN3XJC.js → appGetCommands-4Z7V7UYA.js} +20 -20
- package/{appListCommands-OGTABCS3.js → appListCommands-IIUS64VI.js} +20 -20
- package/{authCommand-NHDLY3IB.js → authCommand-NQPMGYHP.js} +3 -3
- package/{authCommands-UDBJVSZU.js → authCommands-LWLOZETU.js} +2 -2
- package/{builtinSkillRegistry-MAR5LPAC.js → builtinSkillRegistry-GFY77VRN.js} +4 -4
- package/{chunk-UM4PH574.js → chunk-22RVE2PC.js} +1 -1
- package/{chunk-XFUBXRVI.js → chunk-2H6SEVDS.js} +1 -1
- package/{chunk-PCF3QU5Q.js → chunk-2K4TM6AW.js} +1 -1
- package/{chunk-ODTDLPBV.js → chunk-3MSJ4XDQ.js} +3 -3
- package/{chunk-VEYL5MO5.js → chunk-4G4C5SXT.js} +3 -3
- package/{chunk-WCGC6S77.js → chunk-4HTMUQIZ.js} +2 -2
- package/{chunk-4FFUDT6D.js → chunk-56HJ2LAA.js} +17 -7
- package/{chunk-E73ON47R.js → chunk-5EPHWMP5.js} +2 -2
- package/{chunk-7EPXUZOX.js → chunk-6UEJDFF7.js} +2 -2
- package/{chunk-5LTAPGPV.js → chunk-6XHM3LNF.js} +2 -2
- package/{chunk-5OA5HMTL.js → chunk-7JWCVINR.js} +1 -1
- package/{chunk-4YSOUKUR.js → chunk-7KWFIKKK.js} +1 -1
- package/{chunk-AOJB5QYD.js → chunk-AFRHU2JO.js} +10 -11
- package/{chunk-G53AA7RW.js → chunk-BML3APFI.js} +90 -18
- package/{chunk-YXZYNMYK.js → chunk-CMKQ7RCH.js} +2 -2
- package/{chunk-6O4IK4V2.js → chunk-CUF4MYKI.js} +1 -1
- package/{chunk-PTDYOADJ.js → chunk-D2GQE6AF.js} +1 -1
- package/{chunk-46Y5D2BZ.js → chunk-EV235ILT.js} +1 -1
- package/{chunk-HRYFI64G.js → chunk-F6DFZLO4.js} +3 -3
- package/{chunk-FJ5BGMNM.js → chunk-FBTNYNAL.js} +1 -1
- package/{chunk-EHER73LN.js → chunk-GCTKWVLU.js} +1 -1
- package/{chunk-CJN5OERD.js → chunk-GLD6Q25H.js} +22 -22
- package/{chunk-SEB5HAUU.js → chunk-HD3S2F7U.js} +1 -1
- package/{chunk-XIRXOUBV.js → chunk-HDYUKPEB.js} +6 -6
- package/{chunk-LKERWYPX.js → chunk-IRZTHHNM.js} +2 -2
- package/{chunk-CHNCM7EF.js → chunk-JVP74JRH.js} +7 -7
- package/{chunk-7TKWCTSY.js → chunk-KNVDNYH7.js} +2 -2
- package/{chunk-7MMSLEPA.js → chunk-LB5A6JTU.js} +3 -3
- package/{chunk-PH275YDS.js → chunk-MEZSLGQZ.js} +25 -18
- package/{chunk-TVCAR26G.js → chunk-MSFZ7FMO.js} +1 -1
- package/chunk-NKWIS6G2.js +442 -0
- package/{chunk-DNHENQ3T.js → chunk-NR7N2RWA.js} +5 -5
- package/{chunk-Z56IK6UT.js → chunk-O2LBWZLR.js} +8 -8
- package/{chunk-UJXNKP5V.js → chunk-O7SVKKLY.js} +129 -14
- package/{chunk-SNMQMOD2.js → chunk-Q7O72MF5.js} +1 -1
- package/{chunk-U6IGAJT4.js → chunk-REPRKRB2.js} +7 -7
- package/{chunk-GARACBQB.js → chunk-RILRSUGC.js} +1 -1
- package/{chunk-OYPMWCIQ.js → chunk-S274RDSE.js} +9 -9
- package/{chunk-SEA64CDY.js → chunk-TSXNDTXL.js} +1 -1
- package/{chunk-W72ISAKC.js → chunk-UNAOTLKO.js} +1 -1
- package/{chunk-KLUBZL6X.js → chunk-USTPPV3J.js} +1 -1
- package/{chunk-N4QIAW6W.js → chunk-V6YASAZR.js} +1 -1
- package/{chunk-V5OWQOJZ.js → chunk-VL3H5ZU3.js} +48 -7
- package/{chunk-AUDNYVRC.js → chunk-VLGL7FOL.js} +1 -1
- package/{chunk-NTDEBTK5.js → chunk-XMUZHRSB.js} +6 -6
- package/{chunk-ADBZWMFB.js → chunk-YDO5ERB4.js} +1 -1
- package/{chunk-U7XXEI5R.js → chunk-YGCJITP3.js} +2 -2
- package/{chunk-GUYEMTRK.js → chunk-YIEUDVD6.js} +45 -32
- package/{chunk-OW4APERY.js → chunk-YK5MHOWM.js} +54 -9
- package/{commandRegistry-TDXN5OP7.js → commandRegistry-POKHERIN.js} +50 -50
- package/{contentThunks-F2BNWOZV.js → contentThunks-HEEW3GBT.js} +15 -15
- package/{createAgentAutomationAction-5N2NRNR7.js → createAgentAutomationAction-C5UTM2ZI.js} +15 -15
- package/{createDialogAction-DSEG4L5Y.js → createDialogAction-VODZCSHM.js} +18 -18
- package/{createPageAction-K32FYQPE.js → createPageAction-XUFSVLBC.js} +16 -16
- package/{dbSlice-Q25STFGJ.js → dbSlice-QOLNF5GN.js} +5 -5
- package/{deleteFile-AJ2EZMHT.js → deleteFile-KESP65GC.js} +2 -2
- package/{dialogCommands-ODG2OKLO.js → dialogCommands-4XNYPCE7.js} +21 -21
- package/{dialogSlice-4GBOUTGL.js → dialogSlice-KXBFWRVK.js} +14 -14
- package/{docCreateCommands-Q6FQUHUF.js → docCreateCommands-P4XCR2SW.js} +21 -21
- package/{docDeleteCommands-N224CFZL.js → docDeleteCommands-KZZ3L6LS.js} +22 -22
- package/{docReadCommands-CJWAEAB4.js → docReadCommands-JN6HL4BC.js} +21 -21
- package/{docStore-ZTYSP3YE.js → docStore-PLGBTV5U.js} +6 -6
- package/{docUpdateCommands-OPG6ZY4H.js → docUpdateCommands-EYE7BTXW.js} +21 -21
- package/{fetchMessages-I5ICDDHM.js → fetchMessages-5L7OVM5Y.js} +2 -2
- package/{handleSendMessageAction-XFZH2TQS.js → handleSendMessageAction-BBB6A54Z.js} +14 -14
- package/index.js +3 -3
- package/{localDialogRead-ZHZ3KXDM.js → localDialogRead-O5A26FDK.js} +1 -1
- package/{machineCommands-KMU3D5I5.js → machineCommands-4LP4XFEY.js} +37 -37
- package/{machineWsRunDispatch-6GJ5YOSW.js → machineWsRunDispatch-4PWOZYRA.js} +37 -37
- package/{memberThunks-R75S3RWP.js → memberThunks-25K6DDRA.js} +6 -6
- package/package.json +1 -1
- package/{read-SRQMNO26.js → read-PJIT2YEJ.js} +2 -2
- package/{readDocTool-RC3JUNJ2.js → readDocTool-DRSXHGNL.js} +1 -1
- package/{readlineWorkspace-EXCG3IFX.js → readlineWorkspace-CFUUABFV.js} +70 -71
- package/{removeDialogAgentAction-46XQV5Q7.js → removeDialogAgentAction-VIWJL6MX.js} +6 -6
- package/{runAgentClientLoop-URRDZ5WG.js → runAgentClientLoop-CAPNBF7Q.js} +30 -30
- package/{setDialogExtraReferencesAction-J4V5ADQF.js → setDialogExtraReferencesAction-A7VA3NFM.js} +6 -6
- package/{setPrimaryDialogAgentAction-UHHV2QZW.js → setPrimaryDialogAgentAction-B4P7YQX2.js} +6 -6
- package/{settingThunks-PPZZZOWN.js → settingThunks-KOYSAT65.js} +5 -5
- package/{spaceCommands-7CLUNI2I.js → spaceCommands-QCZUWUMS.js} +19 -19
- package/{streamAgentChatTurn-YPUYKXDX.js → streamAgentChatTurn-XX3N3P4J.js} +33 -33
- package/{switchDialogAgentAction-A2TMVGAE.js → switchDialogAgentAction-3VYWHZKH.js} +5 -5
- package/{tools-M5ENXZRJ.js → tools-U6BT6H56.js} +27 -27
- package/{tuiSummaryLlmCaller-Q65IBDGO.js → tuiSummaryLlmCaller-QCHCULPM.js} +9 -9
- package/{updateDialogTitleAction-7PNUE23W.js → updateDialogTitleAction-NKHQ5LCX.js} +15 -15
- package/chunk-CQ3WA2NE.js +0 -299
- /package/{chunk-3AH7LNUB.js → chunk-ODAPITXL.js} +0 -0
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./chunk-EADNWBAZ.js";
|
|
23
23
|
import {
|
|
24
24
|
buildLocalAgentLookupKeys
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-MSFZ7FMO.js";
|
|
26
26
|
import {
|
|
27
27
|
LOCAL_CODEX_AGENT_ID,
|
|
28
28
|
LOCAL_CODEX_AGENT_KEY,
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
import {
|
|
46
46
|
inlineImageUrlsForCustomProvider,
|
|
47
47
|
prepareTools
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-6XHM3LNF.js";
|
|
49
49
|
import {
|
|
50
50
|
getServerProviderSecret
|
|
51
51
|
} from "./chunk-HS7MLR74.js";
|
|
@@ -63,11 +63,11 @@ import {
|
|
|
63
63
|
rememberMemoryFunctionSchema,
|
|
64
64
|
resolveAgentRequiredPackIds,
|
|
65
65
|
setTodoListFunc
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-YIEUDVD6.js";
|
|
67
67
|
import {
|
|
68
68
|
deriveCredentialGroup,
|
|
69
69
|
deriveCustomProviderCredentialGroup
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-YGCJITP3.js";
|
|
71
71
|
import {
|
|
72
72
|
fetchWithTransientRetry,
|
|
73
73
|
isTransientFetchError
|
|
@@ -115,14 +115,14 @@ import {
|
|
|
115
115
|
prepareTokenUsageData,
|
|
116
116
|
resolveBuiltinPlatformAgentConfig,
|
|
117
117
|
runKeyed
|
|
118
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-GLD6Q25H.js";
|
|
119
119
|
import {
|
|
120
120
|
BUILTIN_DIALOG_LLM_CHAT_FALLBACK_MODEL,
|
|
121
121
|
BUILTIN_TITLE_LLM_CONFIG
|
|
122
122
|
} from "./chunk-523DITKR.js";
|
|
123
123
|
import {
|
|
124
124
|
fetchServerSyncedCredential
|
|
125
|
-
} from "./chunk-
|
|
125
|
+
} from "./chunk-JVP74JRH.js";
|
|
126
126
|
import {
|
|
127
127
|
FORCED_TOOLS,
|
|
128
128
|
addDefaultLightWebToolsForConfiguredAgents,
|
|
@@ -132,7 +132,7 @@ import {
|
|
|
132
132
|
applySystemBuiltinSkillFilter,
|
|
133
133
|
expandEnabledPacks,
|
|
134
134
|
resolveEffectiveEnabledPacks
|
|
135
|
-
} from "./chunk-
|
|
135
|
+
} from "./chunk-4HTMUQIZ.js";
|
|
136
136
|
import {
|
|
137
137
|
DEFAULT_HYBRID_READ_TIMEOUT_MS,
|
|
138
138
|
Duration_exports,
|
|
@@ -163,7 +163,7 @@ import {
|
|
|
163
163
|
readDevinUpstreamFailure,
|
|
164
164
|
resolveOpenAiCompatibleProviderConfig,
|
|
165
165
|
resolveSessionKey
|
|
166
|
-
} from "./chunk-
|
|
166
|
+
} from "./chunk-BML3APFI.js";
|
|
167
167
|
import {
|
|
168
168
|
accumulateGeminiChunks,
|
|
169
169
|
buildGeminiGenerateContentRequest,
|
|
@@ -174,7 +174,7 @@ import {
|
|
|
174
174
|
parseUpstreamErrorBody,
|
|
175
175
|
resolveAntigravityFinishReason,
|
|
176
176
|
shouldUseGeminiNativeToolRoute
|
|
177
|
-
} from "./chunk-
|
|
177
|
+
} from "./chunk-YK5MHOWM.js";
|
|
178
178
|
import {
|
|
179
179
|
PlatformStreamInterruptedError,
|
|
180
180
|
buildPlatformChatCompletionRequest,
|
|
@@ -185,14 +185,14 @@ import {
|
|
|
185
185
|
readPlatformChatSseCompletion,
|
|
186
186
|
resolvePlatformChatProviderConfig,
|
|
187
187
|
shouldUsePlatformChatProvider
|
|
188
|
-
} from "./chunk-
|
|
188
|
+
} from "./chunk-VL3H5ZU3.js";
|
|
189
189
|
import {
|
|
190
190
|
readSseDataValues
|
|
191
191
|
} from "./chunk-GMZLP5DV.js";
|
|
192
192
|
import {
|
|
193
193
|
resolveAgentRuntimeConfigFromRecord,
|
|
194
194
|
resolveHistoricalToolContentCap
|
|
195
|
-
} from "./chunk-
|
|
195
|
+
} from "./chunk-HD3S2F7U.js";
|
|
196
196
|
import {
|
|
197
197
|
isDevinOAuthAgent
|
|
198
198
|
} from "./chunk-5ZUL4CUO.js";
|
|
@@ -206,7 +206,7 @@ import {
|
|
|
206
206
|
buildNoloWorkspaceOpenAiTools,
|
|
207
207
|
parseNoloWorkspaceToolArguments,
|
|
208
208
|
resolveRuntimeToolSurfaceForAgent
|
|
209
|
-
} from "./chunk-
|
|
209
|
+
} from "./chunk-7KWFIKKK.js";
|
|
210
210
|
import {
|
|
211
211
|
mergeAvailabilityDeadline,
|
|
212
212
|
resolveAvailabilityAction,
|
|
@@ -219,14 +219,14 @@ import {
|
|
|
219
219
|
} from "./chunk-2MBTWINN.js";
|
|
220
220
|
import {
|
|
221
221
|
normalizeUsage
|
|
222
|
-
} from "./chunk-
|
|
222
|
+
} from "./chunk-IRZTHHNM.js";
|
|
223
223
|
import {
|
|
224
224
|
createProviderCallTimingTracker,
|
|
225
225
|
finalizeProviderCallTiming,
|
|
226
226
|
observeMeaningfulProviderResponse,
|
|
227
227
|
observeMeaningfulProviderResponseAt,
|
|
228
228
|
withProviderCallTimingFields
|
|
229
|
-
} from "./chunk-
|
|
229
|
+
} from "./chunk-LB5A6JTU.js";
|
|
230
230
|
import {
|
|
231
231
|
clipCompactText
|
|
232
232
|
} from "./chunk-5MMAK75Q.js";
|
|
@@ -238,7 +238,7 @@ import {
|
|
|
238
238
|
resolveCurrentRunRuntimeToolPolicy,
|
|
239
239
|
resolveLocalWorkspaceExecutorOptionsFromPolicy,
|
|
240
240
|
resolveRequestedRuntimeToolNames
|
|
241
|
-
} from "./chunk-
|
|
241
|
+
} from "./chunk-2H6SEVDS.js";
|
|
242
242
|
import {
|
|
243
243
|
estimateTokenCount
|
|
244
244
|
} from "./chunk-PSCNXBYA.js";
|
|
@@ -311,7 +311,7 @@ import {
|
|
|
311
311
|
createTokenStatsKey,
|
|
312
312
|
createUserKey,
|
|
313
313
|
dialogMessageRange
|
|
314
|
-
} from "./chunk-
|
|
314
|
+
} from "./chunk-ODAPITXL.js";
|
|
315
315
|
import {
|
|
316
316
|
asTrimmedString
|
|
317
317
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -4035,7 +4035,7 @@ var resolvePlatformProxyTransport = async (ctx) => {
|
|
|
4035
4035
|
return {
|
|
4036
4036
|
model: providerConfig.model,
|
|
4037
4037
|
complete: async (messages, options) => {
|
|
4038
|
-
const requestId = crypto.randomUUID();
|
|
4038
|
+
const requestId = options?.requestId ?? crypto.randomUUID();
|
|
4039
4039
|
const usesResponsesApi = providerConfig.endpoint.includes("/responses");
|
|
4040
4040
|
const stream = Boolean(options?.onTextDelta);
|
|
4041
4041
|
const request = buildPlatformChatCompletionRequest({
|
|
@@ -4064,7 +4064,14 @@ var resolvePlatformProxyTransport = async (ctx) => {
|
|
|
4064
4064
|
fetchImpl,
|
|
4065
4065
|
request.url,
|
|
4066
4066
|
{
|
|
4067
|
-
...request.init
|
|
4067
|
+
...request.init,
|
|
4068
|
+
// 取消信号必须落到 fetch init 上:否则 abort 只停止 runtime 侧
|
|
4069
|
+
// 的等待,HTTP 请求仍在途,与 fallback / 下一轮请求重叠。
|
|
4070
|
+
// fetchWithTransientRetry 在 init.signal.aborted 时直接抛出、
|
|
4071
|
+
// 不做任何重试判定(错误分类前先看 aborted),所以 abort 既
|
|
4072
|
+
// 不会被当成可重试的网络错误,也不会重放这个已发起的 POST。
|
|
4073
|
+
// 注意:客户端取消不等于服务端一定停止生成或停止计费。
|
|
4074
|
+
...options?.signal ? { signal: options.signal } : {}
|
|
4068
4075
|
},
|
|
4069
4076
|
{
|
|
4070
4077
|
sleep: deps.sleep,
|
|
@@ -0,0 +1,442 @@
|
|
|
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 c = call && typeof call === "object" ? call : {};
|
|
40
|
+
const name = isString(c.function?.name) && c.function.name.length > 0 ? c.function.name : "unknown";
|
|
41
|
+
const rawArgs = c.function?.arguments;
|
|
42
|
+
const args = jsonStringifyArguments(rawArgs);
|
|
43
|
+
return `[tool_call: ${name}(${args})]`;
|
|
44
|
+
}
|
|
45
|
+
function renderToolResultAsText(message) {
|
|
46
|
+
const name = isNonEmptyString(message.toolName) ? message.toolName : "tool";
|
|
47
|
+
const body = typeof message.content === "string" ? message.content : "";
|
|
48
|
+
return `[tool_result: ${name}: ${body}]`;
|
|
49
|
+
}
|
|
50
|
+
function normalizeToolCall(call, assistantIndex, callIndex) {
|
|
51
|
+
if (!call || typeof call !== "object") return null;
|
|
52
|
+
const c = call;
|
|
53
|
+
const fn = c.function;
|
|
54
|
+
if (!fn || typeof fn !== "object" || !isString(fn.name) || fn.name.length === 0) return null;
|
|
55
|
+
const id = isNonEmptyString(c.id) ? c.id : stableToolCallId(assistantIndex, callIndex);
|
|
56
|
+
return {
|
|
57
|
+
id,
|
|
58
|
+
type: isString(c.type) && c.type ? c.type : "function",
|
|
59
|
+
function: { name: fn.name, arguments: jsonStringifyArguments(fn.arguments) },
|
|
60
|
+
...typeof c.thought_signature === "string" ? { thought_signature: c.thought_signature } : {}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function classifyAssistantCalls(toolCalls, assistantIndex) {
|
|
64
|
+
const callIds = [];
|
|
65
|
+
const idCounts = /* @__PURE__ */ new Map();
|
|
66
|
+
const unparsableIndices = /* @__PURE__ */ new Set();
|
|
67
|
+
const unparsableIds = /* @__PURE__ */ new Set();
|
|
68
|
+
toolCalls.forEach((rawCall, callIndex) => {
|
|
69
|
+
const c = rawCall && typeof rawCall === "object" ? rawCall : {};
|
|
70
|
+
const id = isNonEmptyString(c.id) ? c.id : stableToolCallId(assistantIndex, callIndex);
|
|
71
|
+
callIds.push(id);
|
|
72
|
+
idCounts.set(id, (idCounts.get(id) ?? 0) + 1);
|
|
73
|
+
if (!hasParsableObjectArguments(c.function?.arguments)) {
|
|
74
|
+
unparsableIndices.add(callIndex);
|
|
75
|
+
unparsableIds.add(id);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const duplicateIds = /* @__PURE__ */ new Set();
|
|
79
|
+
for (const [id, count] of idCounts) {
|
|
80
|
+
if (count > 1) duplicateIds.add(id);
|
|
81
|
+
}
|
|
82
|
+
return { callIds, duplicateIds, unparsableIndices, unparsableIds };
|
|
83
|
+
}
|
|
84
|
+
function sanitizeOutboundHistory(messages, options) {
|
|
85
|
+
if (!Array.isArray(messages) || messages.length === 0) return messages;
|
|
86
|
+
const declared = options?.declaredToolNames;
|
|
87
|
+
const keptCallIndicesPerAssistant = /* @__PURE__ */ new Map();
|
|
88
|
+
const keptToolIndices = /* @__PURE__ */ new Set();
|
|
89
|
+
let i = 0;
|
|
90
|
+
while (i < messages.length) {
|
|
91
|
+
const m = messages[i];
|
|
92
|
+
if (m.role === "assistant" && Array.isArray(m.tool_calls) && m.tool_calls.length > 0) {
|
|
93
|
+
const asstIdx = i;
|
|
94
|
+
const { callIds, duplicateIds, unparsableIndices } = classifyAssistantCalls(m.tool_calls, asstIdx);
|
|
95
|
+
const candidateCallMap = /* @__PURE__ */ new Map();
|
|
96
|
+
m.tool_calls.forEach((call, callIndex) => {
|
|
97
|
+
const id = callIds[callIndex];
|
|
98
|
+
if (duplicateIds.has(id)) return;
|
|
99
|
+
if (unparsableIndices.has(callIndex)) return;
|
|
100
|
+
const name = call?.function?.name;
|
|
101
|
+
if (!isString(name) || name.length === 0) return;
|
|
102
|
+
const declaredAllows = !declared || declared.has(name);
|
|
103
|
+
if (!declaredAllows) return;
|
|
104
|
+
candidateCallMap.set(id, callIndex);
|
|
105
|
+
});
|
|
106
|
+
let j = i + 1;
|
|
107
|
+
const matchedCallIndices = /* @__PURE__ */ new Set();
|
|
108
|
+
const matchedToolIds = /* @__PURE__ */ new Set();
|
|
109
|
+
while (j < messages.length && messages[j].role === "tool") {
|
|
110
|
+
const toolMsg = messages[j];
|
|
111
|
+
const toolCallId = isNonEmptyString(toolMsg.tool_call_id) ? toolMsg.tool_call_id : "";
|
|
112
|
+
if (toolCallId && candidateCallMap.has(toolCallId) && !matchedToolIds.has(toolCallId)) {
|
|
113
|
+
matchedToolIds.add(toolCallId);
|
|
114
|
+
matchedCallIndices.add(candidateCallMap.get(toolCallId));
|
|
115
|
+
keptToolIndices.add(j);
|
|
116
|
+
}
|
|
117
|
+
j++;
|
|
118
|
+
}
|
|
119
|
+
keptCallIndicesPerAssistant.set(asstIdx, matchedCallIndices);
|
|
120
|
+
i = j;
|
|
121
|
+
} else {
|
|
122
|
+
i++;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const out = [];
|
|
126
|
+
let k = 0;
|
|
127
|
+
while (k < messages.length) {
|
|
128
|
+
const m = messages[k];
|
|
129
|
+
if (m.role === "assistant" && Array.isArray(m.tool_calls) && m.tool_calls.length > 0) {
|
|
130
|
+
const asstIdx = k;
|
|
131
|
+
const keptIndices = keptCallIndicesPerAssistant.get(asstIdx) ?? /* @__PURE__ */ new Set();
|
|
132
|
+
const keptToolCalls = [];
|
|
133
|
+
const downgradedCallLines = [];
|
|
134
|
+
m.tool_calls.forEach((call, callIndex) => {
|
|
135
|
+
const name = call?.function?.name;
|
|
136
|
+
const declaredAllows = !declared || isString(name) && declared.has(name);
|
|
137
|
+
const keep = keptIndices.has(callIndex) && declaredAllows && hasParsableObjectArguments(call?.function?.arguments);
|
|
138
|
+
if (keep) {
|
|
139
|
+
const normalized = normalizeToolCall(call, asstIdx, callIndex);
|
|
140
|
+
if (normalized) {
|
|
141
|
+
keptToolCalls.push(normalized);
|
|
142
|
+
} else {
|
|
143
|
+
downgradedCallLines.push(renderToolCallAsText(call));
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
downgradedCallLines.push(renderToolCallAsText(call));
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
if (keptToolCalls.length === 0) {
|
|
150
|
+
const downgradedText = joinLines(...downgradedCallLines);
|
|
151
|
+
const contentWithDowngrade = downgradedText.length > 0 ? combineContentWithText(m.content, downgradedText) : m.content;
|
|
152
|
+
const sanitizedAssistant2 = {
|
|
153
|
+
...m,
|
|
154
|
+
content: contentWithDowngrade
|
|
155
|
+
};
|
|
156
|
+
delete sanitizedAssistant2.tool_calls;
|
|
157
|
+
out.push(sanitizedAssistant2);
|
|
158
|
+
let nextIdx2 = k + 1;
|
|
159
|
+
while (nextIdx2 < messages.length && messages[nextIdx2].role === "tool") {
|
|
160
|
+
out.push({
|
|
161
|
+
role: "assistant",
|
|
162
|
+
content: renderToolResultAsText(messages[nextIdx2])
|
|
163
|
+
});
|
|
164
|
+
nextIdx2++;
|
|
165
|
+
}
|
|
166
|
+
k = nextIdx2;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const sanitizedAssistant = {
|
|
170
|
+
...m,
|
|
171
|
+
tool_calls: keptToolCalls
|
|
172
|
+
};
|
|
173
|
+
out.push(sanitizedAssistant);
|
|
174
|
+
let nextIdx = k + 1;
|
|
175
|
+
const deferredResultLines = [];
|
|
176
|
+
while (nextIdx < messages.length && messages[nextIdx].role === "tool") {
|
|
177
|
+
if (keptToolIndices.has(nextIdx)) {
|
|
178
|
+
const toolMsg = messages[nextIdx];
|
|
179
|
+
out.push({
|
|
180
|
+
...toolMsg,
|
|
181
|
+
content: toolMsg.content ?? "",
|
|
182
|
+
tool_call_id: toolMsg.tool_call_id
|
|
183
|
+
});
|
|
184
|
+
} else {
|
|
185
|
+
deferredResultLines.push(renderToolResultAsText(messages[nextIdx]));
|
|
186
|
+
}
|
|
187
|
+
nextIdx++;
|
|
188
|
+
}
|
|
189
|
+
const deferredLines = [...downgradedCallLines, ...deferredResultLines];
|
|
190
|
+
if (deferredLines.length > 0) {
|
|
191
|
+
out.push({
|
|
192
|
+
role: "assistant",
|
|
193
|
+
content: joinLines(...deferredLines)
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
k = nextIdx;
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
if (m.role === "tool") {
|
|
200
|
+
out.push({
|
|
201
|
+
role: "assistant",
|
|
202
|
+
content: renderToolResultAsText(m)
|
|
203
|
+
});
|
|
204
|
+
k++;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
out.push({ ...m });
|
|
208
|
+
k++;
|
|
209
|
+
}
|
|
210
|
+
return out;
|
|
211
|
+
}
|
|
212
|
+
function combineContentWithText(base, extra) {
|
|
213
|
+
if (typeof base === "string") {
|
|
214
|
+
return base ? `${base}
|
|
215
|
+
${extra}` : extra;
|
|
216
|
+
}
|
|
217
|
+
if (Array.isArray(base)) {
|
|
218
|
+
return [...base, { type: "text", text: extra }];
|
|
219
|
+
}
|
|
220
|
+
return extra;
|
|
221
|
+
}
|
|
222
|
+
function hasParsableObjectArguments(raw) {
|
|
223
|
+
if (raw === void 0) return true;
|
|
224
|
+
if (raw === null || typeof raw === "number" || typeof raw === "boolean") {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
if (typeof raw !== "string") return true;
|
|
228
|
+
if (raw.trim() === "") return true;
|
|
229
|
+
try {
|
|
230
|
+
const parsed = JSON.parse(raw);
|
|
231
|
+
return parsed !== null && typeof parsed === "object";
|
|
232
|
+
} catch {
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
var STRICT_JSON_STRING_TOKEN = /^"(?:[^"\\\u0000-\u001F]|\\["\\/bfnrt]|\\u[0-9A-Fa-f]{4})*"$/;
|
|
237
|
+
function isStrictJsonStringToken(value) {
|
|
238
|
+
if (!STRICT_JSON_STRING_TOKEN.test(value)) return false;
|
|
239
|
+
try {
|
|
240
|
+
return typeof JSON.parse(value) === "string";
|
|
241
|
+
} catch {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function closersOf(openStack) {
|
|
246
|
+
return openStack.slice().reverse().map((ch) => ch === "{" ? "}" : "]").join("");
|
|
247
|
+
}
|
|
248
|
+
function scanJsonForTailRepair(input) {
|
|
249
|
+
const stack = [];
|
|
250
|
+
let inString = false;
|
|
251
|
+
let escaped = false;
|
|
252
|
+
let lastCommaOutsideString = null;
|
|
253
|
+
for (let i = 0; i < input.length; i += 1) {
|
|
254
|
+
const ch = input[i];
|
|
255
|
+
if (inString) {
|
|
256
|
+
if (escaped) escaped = false;
|
|
257
|
+
else if (ch === "\\") escaped = true;
|
|
258
|
+
else if (ch === '"') inString = false;
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if (ch === '"') {
|
|
262
|
+
inString = true;
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (ch === "{" || ch === "[") {
|
|
266
|
+
stack.push(ch);
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
if (ch === "}" || ch === "]") {
|
|
270
|
+
const open = stack.pop();
|
|
271
|
+
if (open !== (ch === "}" ? "{" : "[")) return null;
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
if (ch === ",") {
|
|
275
|
+
lastCommaOutsideString = { index: i, closers: closersOf(stack) };
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return { inString, closers: closersOf(stack), lastCommaOutsideString };
|
|
280
|
+
}
|
|
281
|
+
function repairTruncatedToolArguments(raw) {
|
|
282
|
+
if (typeof raw !== "string") return null;
|
|
283
|
+
const withoutTrailingSpace = raw.replace(/\s+$/, "");
|
|
284
|
+
const endsWithComma = withoutTrailingSpace.endsWith(",");
|
|
285
|
+
const trimmed = endsWithComma ? withoutTrailingSpace.slice(0, -1).replace(/\s+$/, "") : withoutTrailingSpace;
|
|
286
|
+
if (trimmed === "" || trimmed.endsWith(",")) return null;
|
|
287
|
+
const scan = scanJsonForTailRepair(trimmed);
|
|
288
|
+
if (!scan || scan.inString) return null;
|
|
289
|
+
const lastChar = trimmed[trimmed.length - 1];
|
|
290
|
+
const tailIsCompleteToken = endsWithComma || lastChar === '"' || lastChar === "}" || lastChar === "]";
|
|
291
|
+
if (!tailIsCompleteToken) return null;
|
|
292
|
+
const candidates = [trimmed + scan.closers];
|
|
293
|
+
const lastComma = scan.lastCommaOutsideString;
|
|
294
|
+
if (lastComma && lastComma.index > 0) {
|
|
295
|
+
const tailAfterComma = trimmed.slice(lastComma.index + 1).trim();
|
|
296
|
+
if (isStrictJsonStringToken(tailAfterComma)) {
|
|
297
|
+
const head = trimmed.slice(0, lastComma.index);
|
|
298
|
+
candidates.push(head + lastComma.closers);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
for (const candidate of candidates) {
|
|
302
|
+
try {
|
|
303
|
+
const parsed = JSON.parse(candidate);
|
|
304
|
+
if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed) && Object.keys(parsed).length > 0) {
|
|
305
|
+
return candidate;
|
|
306
|
+
}
|
|
307
|
+
} catch {
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
function downgradeUnparsableToolCalls(messages) {
|
|
313
|
+
if (!Array.isArray(messages) || messages.length === 0) {
|
|
314
|
+
return { messages, downgraded: 0 };
|
|
315
|
+
}
|
|
316
|
+
let hasAnyPoison = false;
|
|
317
|
+
for (const m of messages) {
|
|
318
|
+
if (m.role === "assistant" && Array.isArray(m.tool_calls)) {
|
|
319
|
+
for (const call of m.tool_calls) {
|
|
320
|
+
if (!hasParsableObjectArguments(call?.function?.arguments)) {
|
|
321
|
+
hasAnyPoison = true;
|
|
322
|
+
break;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
if (hasAnyPoison) break;
|
|
327
|
+
}
|
|
328
|
+
if (!hasAnyPoison) return { messages, downgraded: 0 };
|
|
329
|
+
const poisonedCallsPerAssistant = /* @__PURE__ */ new Map();
|
|
330
|
+
const poisonedToolIndices = /* @__PURE__ */ new Set();
|
|
331
|
+
let i = 0;
|
|
332
|
+
while (i < messages.length) {
|
|
333
|
+
const m = messages[i];
|
|
334
|
+
if (m.role === "assistant" && Array.isArray(m.tool_calls) && m.tool_calls.length > 0) {
|
|
335
|
+
const asstIdx = i;
|
|
336
|
+
const { unparsableIds } = classifyAssistantCalls(m.tool_calls, asstIdx);
|
|
337
|
+
let j = i + 1;
|
|
338
|
+
while (j < messages.length && messages[j].role === "tool") {
|
|
339
|
+
const toolMsg = messages[j];
|
|
340
|
+
const toolCallId = isNonEmptyString(toolMsg.tool_call_id) ? toolMsg.tool_call_id : "";
|
|
341
|
+
if (toolCallId && unparsableIds.has(toolCallId)) {
|
|
342
|
+
poisonedToolIndices.add(j);
|
|
343
|
+
}
|
|
344
|
+
j++;
|
|
345
|
+
}
|
|
346
|
+
if (unparsableIds.size > 0) {
|
|
347
|
+
poisonedCallsPerAssistant.set(asstIdx, unparsableIds);
|
|
348
|
+
}
|
|
349
|
+
i = j;
|
|
350
|
+
} else {
|
|
351
|
+
i++;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
let downgraded = 0;
|
|
355
|
+
const out = [];
|
|
356
|
+
let k = 0;
|
|
357
|
+
while (k < messages.length) {
|
|
358
|
+
const m = messages[k];
|
|
359
|
+
if (m.role === "assistant" && Array.isArray(m.tool_calls) && m.tool_calls.length > 0) {
|
|
360
|
+
const badIds = poisonedCallsPerAssistant.get(k);
|
|
361
|
+
if (!badIds || badIds.size === 0) {
|
|
362
|
+
out.push(m);
|
|
363
|
+
k++;
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
const kept = [];
|
|
367
|
+
const lines = [];
|
|
368
|
+
const { callIds } = classifyAssistantCalls(m.tool_calls, k);
|
|
369
|
+
m.tool_calls.forEach((call, callIndex) => {
|
|
370
|
+
const id = callIds[callIndex];
|
|
371
|
+
if (badIds.has(id)) {
|
|
372
|
+
lines.push(renderToolCallAsText(call));
|
|
373
|
+
downgraded++;
|
|
374
|
+
} else {
|
|
375
|
+
kept.push(call);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
if (kept.length === 0) {
|
|
379
|
+
const sanitized2 = {
|
|
380
|
+
...m,
|
|
381
|
+
content: combineContentWithText(m.content, joinLines(...lines))
|
|
382
|
+
};
|
|
383
|
+
delete sanitized2.tool_calls;
|
|
384
|
+
out.push(sanitized2);
|
|
385
|
+
let nextIdx2 = k + 1;
|
|
386
|
+
while (nextIdx2 < messages.length && messages[nextIdx2].role === "tool") {
|
|
387
|
+
if (poisonedToolIndices.has(nextIdx2)) {
|
|
388
|
+
out.push({ role: "assistant", content: renderToolResultAsText(messages[nextIdx2]) });
|
|
389
|
+
} else {
|
|
390
|
+
out.push(messages[nextIdx2]);
|
|
391
|
+
}
|
|
392
|
+
nextIdx2++;
|
|
393
|
+
}
|
|
394
|
+
k = nextIdx2;
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
const sanitized = {
|
|
398
|
+
...m,
|
|
399
|
+
content: lines.length > 0 ? combineContentWithText(m.content, joinLines(...lines)) : m.content,
|
|
400
|
+
tool_calls: kept
|
|
401
|
+
};
|
|
402
|
+
out.push(sanitized);
|
|
403
|
+
let nextIdx = k + 1;
|
|
404
|
+
const deferredResultLines = [];
|
|
405
|
+
while (nextIdx < messages.length && messages[nextIdx].role === "tool") {
|
|
406
|
+
if (poisonedToolIndices.has(nextIdx)) {
|
|
407
|
+
deferredResultLines.push(renderToolResultAsText(messages[nextIdx]));
|
|
408
|
+
} else {
|
|
409
|
+
out.push(messages[nextIdx]);
|
|
410
|
+
}
|
|
411
|
+
nextIdx++;
|
|
412
|
+
}
|
|
413
|
+
if (deferredResultLines.length > 0) {
|
|
414
|
+
out.push({
|
|
415
|
+
role: "assistant",
|
|
416
|
+
content: joinLines(...deferredResultLines)
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
k = nextIdx;
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
if (m.role === "tool") {
|
|
423
|
+
if (poisonedToolIndices.has(k)) {
|
|
424
|
+
out.push({ role: "assistant", content: renderToolResultAsText(m) });
|
|
425
|
+
} else {
|
|
426
|
+
out.push(m);
|
|
427
|
+
}
|
|
428
|
+
k++;
|
|
429
|
+
continue;
|
|
430
|
+
}
|
|
431
|
+
out.push(m);
|
|
432
|
+
k++;
|
|
433
|
+
}
|
|
434
|
+
return { messages: out, downgraded };
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export {
|
|
438
|
+
sanitizeForOutbound,
|
|
439
|
+
hasParsableObjectArguments,
|
|
440
|
+
repairTruncatedToolArguments,
|
|
441
|
+
downgradeUnparsableToolCalls
|
|
442
|
+
};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
addContentToSpace
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-REPRKRB2.js";
|
|
4
4
|
import {
|
|
5
5
|
format,
|
|
6
6
|
prepareAndPersistMessage,
|
|
7
7
|
uiAskChoiceFunc,
|
|
8
8
|
uiAskChoiceFunctionSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GLD6Q25H.js";
|
|
10
10
|
import {
|
|
11
11
|
formatISO
|
|
12
12
|
} from "./chunk-ZRAU6T47.js";
|
|
13
13
|
import {
|
|
14
14
|
buildBuiltinObjectSkillReference
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-4HTMUQIZ.js";
|
|
16
16
|
import {
|
|
17
17
|
read,
|
|
18
18
|
readAndWait,
|
|
19
19
|
removeCachedEntity,
|
|
20
20
|
upsertSSREntity,
|
|
21
21
|
write
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-56HJ2LAA.js";
|
|
23
23
|
import {
|
|
24
24
|
PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL,
|
|
25
25
|
PLATFORM_HOSTED_KIMI_PROVIDER
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
dialogMessageRange,
|
|
38
38
|
memoryOwnerRange,
|
|
39
39
|
memorySubjectKindRange
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-ODAPITXL.js";
|
|
41
41
|
import {
|
|
42
42
|
isDevelopment
|
|
43
43
|
} from "./chunk-HIM3FCLF.js";
|