nolo-cli 0.50.0-alpha.1 → 0.50.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-4BPV4B2U.js → _executeModel-JKEH7ACW.js} +48 -42
- package/{action-IU6ON7ZB.js → action-VSG2IYP3.js} +8 -8
- package/{addContentAction-5V5CCI3I.js → addContentAction-2HJJITDI.js} +8 -7
- package/{addDialogAgentAction-KF3KZZNZ.js → addDialogAgentAction-7BSQVVL5.js} +10 -9
- package/{agentDeleteCommand-KZSETRE3.js → agentDeleteCommand-SVXKS5SC.js} +30 -28
- package/{agentEmailCommands-5TEW64UO.js → agentEmailCommands-WN7QBTP3.js} +57 -52
- package/{agentListCommands-KVLURCS7.js → agentListCommands-2BEBOQIG.js} +42 -33
- package/{agentMachineCommands-4LQF5YB5.js → agentMachineCommands-WALP3ONU.js} +30 -28
- package/{agentRecordCommands-OXC6JSH6.js → agentRecordCommands-E652SW57.js} +55 -50
- package/{agentRunCommand-4AXTA7MR.js → agentRunCommand-6VXWXKCS.js} +60 -53
- package/{agentRunControl-4GHHSXFZ.js → agentRunControl-LJVFDJGU.js} +3 -1
- package/{agentRuntimeLocal-SIQYQGSK.js → agentRuntimeLocal-SBG7BDFQ.js} +30 -26
- package/{agentSlice-VD3BAJAU.js → agentSlice-3WYXIGEO.js} +8 -8
- package/{agentSuperviseCommands-VB6BUS5H.js → agentSuperviseCommands-F3RFAL7K.js} +2 -2
- package/{appDeleteCommands-LSIIQFYN.js → appDeleteCommands-NTUNMEXY.js} +31 -29
- package/{appDeployCommands-VYGKN7HU.js → appDeployCommands-DISWXRTL.js} +31 -29
- package/{appDeployStatusCommands-ODFHFUR7.js → appDeployStatusCommands-IKRA6B6F.js} +31 -29
- package/{appGetCommands-DPQY67UZ.js → appGetCommands-UMOP2DFV.js} +31 -29
- package/{appListCommands-EFXENXWX.js → appListCommands-ZKFD2AKS.js} +31 -29
- package/{authCommand-WLWOEVYI.js → authCommand-BS3CQC6I.js} +11 -11
- package/{chatQueueReduxAdapter-N5432EP2.js → chatQueueReduxAdapter-A3YH4MT4.js} +24 -21
- package/{chunk-76UA7376.js → chunk-273FJUYI.js} +6 -6
- package/{chunk-7CH6U3FL.js → chunk-2GRGFCF6.js} +2 -4
- package/{chunk-T27IEBNQ.js → chunk-2QDDKFG5.js} +74 -1
- package/{chunk-WWXZYFWM.js → chunk-2TLYVDTN.js} +464 -1135
- package/{chunk-6BYAXNH5.js → chunk-3QOCS5IF.js} +11 -2
- package/chunk-6IGD47IC.js +19 -0
- package/{chunk-QDNFRWAX.js → chunk-6TUT5ZJD.js} +4 -6
- package/chunk-6YTOJY35.js +352 -0
- package/{chunk-B54WOZ77.js → chunk-7H7GQL6V.js} +2 -2
- package/{chunk-OYNDYVSE.js → chunk-B45YNDAE.js} +1 -1
- package/{chunk-OZ4JNDIL.js → chunk-BKIDF5LV.js} +1 -1
- package/{chunk-5XCW6RQG.js → chunk-BUBPRCIU.js} +1 -1
- package/chunk-BYXBJQAS.js +0 -0
- package/{chunk-X7S7OFUX.js → chunk-CEVCRRHU.js} +4 -4
- package/{chunk-JBL24PK6.js → chunk-DEIGUGP6.js} +2 -2
- package/{chunk-V2IPBG5U.js → chunk-DGEPT6FH.js} +1 -1
- package/{chunk-3AOLVADY.js → chunk-DVINR3PL.js} +1 -1
- package/{chunk-HMMOAG2I.js → chunk-DXOELY7S.js} +67 -69
- package/{chunk-OFZPJ3NT.js → chunk-E4MARS3Q.js} +1 -1
- package/{chunk-27MWS6HD.js → chunk-EAYBPWHX.js} +179 -86
- package/{chunk-DQLYEGP7.js → chunk-EGVY3GMT.js} +1 -1
- package/{chunk-2JYSSXLY.js → chunk-EJFW7TRP.js} +5 -26
- package/{chunk-4YAMAMNA.js → chunk-FGRCSLPV.js} +36 -46
- package/{chunk-VFN256RI.js → chunk-G4WSLTQF.js} +56 -97
- package/{chunk-HR5XDXYM.js → chunk-G5SQVIFZ.js} +3 -3
- package/{chunk-J3UALFHL.js → chunk-GHE5XMVR.js} +1 -1
- package/{chunk-7M72YPM2.js → chunk-GKB4AZKV.js} +440 -2981
- package/{chunk-S3HB4CQY.js → chunk-GKNGRBE6.js} +256 -40
- package/{chunk-Q24S4NDF.js → chunk-HQTK2SFT.js} +1 -1
- package/{chunk-XB7ACJFH.js → chunk-IPTZ5TVU.js} +7 -6
- package/{chunk-4RXXP6WD.js → chunk-J7KDNHUO.js} +5 -64
- package/{chunk-BO3YFOZR.js → chunk-KNQ5LYVZ.js} +57 -2
- package/{chunk-AV4Z57LV.js → chunk-KVVNC5V3.js} +2 -2
- package/{chunk-VKSBVRGP.js → chunk-LVCAWHI5.js} +4 -4
- package/{chunk-5JXRVJAC.js → chunk-N6SLQMSA.js} +6 -6
- package/{chunk-SQTVMYMU.js → chunk-NTZO3KX2.js} +3 -3
- package/{chunk-LGUQHYAL.js → chunk-O5FLGN2L.js} +3 -2
- package/{chunk-72COHDZR.js → chunk-OSUZKICS.js} +1600 -190
- package/{chunk-HIDPTO4B.js → chunk-Q2QN2RHG.js} +7 -7
- package/{chunk-L3JWI7WX.js → chunk-QOKAKDPE.js} +15 -11
- package/{chunk-4ZL2KBI7.js → chunk-RFYXK6KI.js} +1 -1
- package/chunk-RQSN75DW.js +1766 -0
- package/{chunk-RPO6WAZV.js → chunk-S3JNURSO.js} +2 -2
- package/{chunk-YZ2WE6CW.js → chunk-SAJSBPI2.js} +2 -2
- package/{chunk-WHVQA7PJ.js → chunk-SCBBGS2N.js} +23 -5
- package/chunk-SGSJBBKP.js +297 -0
- package/{chunk-FTSPVLKJ.js → chunk-TUBNQ3OF.js} +2 -2
- package/{chunk-BANYWEYY.js → chunk-TY3ADTX5.js} +1 -1
- package/chunk-UAD2WT54.js +64 -0
- package/{chunk-F22JQTSX.js → chunk-UEV5WVQV.js} +3 -3
- package/{chunk-MCX2LX27.js → chunk-UMCMW5R3.js} +51 -34
- package/{chunk-6L6UPZNH.js → chunk-VFDRZHPM.js} +16 -16
- package/{chunk-C2WF2OY7.js → chunk-W22UTILW.js} +3 -3
- package/{chunk-W3RZLXMA.js → chunk-WERPP2S7.js} +2 -2
- package/{chunk-AZ6DT2UD.js → chunk-WSUHBABG.js} +1 -1
- package/{chunk-3YVCM5PE.js → chunk-X3OGKR5Q.js} +4 -4
- package/{chunk-IERBSHMR.js → chunk-X5LRMXTS.js} +10 -10
- package/{chunk-DIQCV4FR.js → chunk-X665UCNM.js} +1 -1
- package/{chunk-HCBQVVFZ.js → chunk-X7P6EJUY.js} +4 -4
- package/{chunk-HHBXCRJS.js → chunk-XOJRZUPF.js} +4 -4
- package/{chunk-MRWGHF56.js → chunk-YDH3FDFQ.js} +12 -356
- package/{chunk-TNPCQNGQ.js → chunk-YEFRCO5N.js} +4 -9
- package/{chunk-RO2IUWZE.js → chunk-YUKTCDVN.js} +1 -1
- package/{chunk-Y7TGWSUN.js → chunk-YWY25N4V.js} +1 -1
- package/{chunk-Z7A54NFZ.js → chunk-ZDS63Y4O.js} +2 -2
- package/chunk-ZJ7UHBJS.js +89 -0
- package/{chunk-SG65C33A.js → chunk-ZLMG6NRV.js} +4 -4
- package/{codingSkills-BYQI6EPT.js → codingSkills-FQPCEIWL.js} +2 -2
- package/contentThunks-J33BZB3E.js +71 -0
- package/{createAgentAutomationAction-IHKV53QC.js → createAgentAutomationAction-HTMTGX6Q.js} +25 -21
- package/{createDialogAction-4ARDCKPP.js → createDialogAction-WYQBSN6A.js} +27 -23
- package/{createPageAction-GQOCPICU.js → createPageAction-ICRRK3SA.js} +27 -22
- package/{dbSlice-FWF5F4L7.js → dbSlice-YORO4VL4.js} +6 -6
- package/{deleteFile-NPZ64DFN.js → deleteFile-JYKRT7C3.js} +4 -4
- package/{dialogCommands-YOTCP26N.js → dialogCommands-FRSIAPKY.js} +31 -29
- package/{dialogSlice-NX26W623.js → dialogSlice-5KPVIAWH.js} +24 -21
- package/{docCreateCommands-JVAMHES4.js → docCreateCommands-DBRJMPDX.js} +30 -28
- package/{docDeleteCommands-LW5DWICT.js → docDeleteCommands-BCYPLWXN.js} +31 -29
- package/{docReadCommands-AQOZS3I5.js → docReadCommands-L5JX4Q7G.js} +30 -28
- package/{docStore-YAE7GYHZ.js → docStore-34NXLCEO.js} +8 -33
- package/{docUpdateCommands-FFGGX5RG.js → docUpdateCommands-RELG7XJD.js} +30 -28
- package/fetchMessages-KZQVBXKY.js +1 -1
- package/{getPricing-JNOCWYDH.js → getPricing-FM7TJZFV.js} +4 -4
- package/{handleSendMessageAction-7YKH4UBI.js → handleSendMessageAction-MEYK7RPD.js} +25 -22
- package/index.js +64 -64
- package/{machineCommands-FMMFBMCQ.js → machineCommands-YSXTOWHQ.js} +59 -54
- package/{machineWsRunDispatch-UODRJY63.js → machineWsRunDispatch-DNAYOPQT.js} +54 -49
- package/memberThunks-KVPBG4V7.js +638 -0
- package/{models-N4NXQ44D.js → models-CW5EL6Z7.js} +2 -2
- package/package.json +2 -3
- package/{read-J7RVVCHH.js → read-NIOV5F7W.js} +4 -4
- package/{readDocTool-G2WBM4IH.js → readDocTool-ULKJ5BEM.js} +1 -1
- package/{readlineWorkspace-GVDEA7RH.js → readlineWorkspace-KZ3LPQG2.js} +866 -377
- package/{removeDialogAgentAction-RMPISD42.js → removeDialogAgentAction-JGSCPML3.js} +12 -11
- package/{runAgentClientLoop-6NCW5AS6.js → runAgentClientLoop-O2AUHIJT.js} +46 -40
- package/{setDialogExtraReferencesAction-7BUTHDAL.js → setDialogExtraReferencesAction-CORU64NM.js} +9 -8
- package/{setPrimaryDialogAgentAction-WCYIBGZ4.js → setPrimaryDialogAgentAction-5VS2VKLZ.js} +12 -11
- package/{settingSlice-7NN2MI6Y.js → settingSlice-3GNGTC2T.js} +7 -7
- package/{skillDiscovery-COX56OBO.js → skillDiscovery-CYUCJMAG.js} +3 -3
- package/{spaceCommands-7MJVL4XR.js → spaceCommands-OI7RIB2T.js} +30 -28
- package/{streamAgentChatTurn-UAKCHWFN.js → streamAgentChatTurn-TA3PGS6C.js} +61 -54
- package/{switchDialogAgentAction-WGMMQHDI.js → switchDialogAgentAction-LP433X4D.js} +10 -9
- package/{tableCommands-P2TXJ3CF.js → tableCommands-R6WFRDYF.js} +1 -1
- package/{toolApiClient-B2MFXMEG.js → toolApiClient-53U4UDFF.js} +3 -2
- package/{tools-ROUITGAR.js → tools-6ZPQ75XA.js} +37 -32
- package/{tuiSummaryLlmCaller-U4EGD2SX.js → tuiSummaryLlmCaller-YKYQB4ZL.js} +17 -15
- package/{updateDialogTitleAction-R4M6ZXCX.js → updateDialogTitleAction-LRJ7NSOS.js} +26 -22
- package/chunk-EUG45QJR.js +0 -6104
- package/spaceSlice-JVVDCGA3.js +0 -127
- package/{chunk-NQ4N4IGO.js → chunk-CS6TCJ7E.js} +3 -3
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
providerHttpFailure,
|
|
8
8
|
readSseFrames,
|
|
9
9
|
throwIfChatCompletionStreamFailed
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-IPTZ5TVU.js";
|
|
11
11
|
import {
|
|
12
12
|
FRESH_TOOL_OUTPUT_MAX_CHARS,
|
|
13
13
|
MAX_HISTORICAL_TOOL_CONTENT_CHARS,
|
|
@@ -17,10 +17,12 @@ import {
|
|
|
17
17
|
resolveHistoricalToolContentCap,
|
|
18
18
|
resolveToolOutputProfile,
|
|
19
19
|
stripImagePartsFromMessages
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-LVCAWHI5.js";
|
|
21
21
|
import {
|
|
22
|
+
downgradeUnparsableToolCalls,
|
|
23
|
+
hasParsableObjectArguments,
|
|
22
24
|
sanitizeForOutbound
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-2QDDKFG5.js";
|
|
24
26
|
import {
|
|
25
27
|
createThinkParserState,
|
|
26
28
|
createToolCallAccumulator,
|
|
@@ -29,6 +31,7 @@ import {
|
|
|
29
31
|
finalizeAccumulatedToolCalls
|
|
30
32
|
} from "./chunk-N7J63Q6C.js";
|
|
31
33
|
import {
|
|
34
|
+
TOOL_GUIDED_SECTION_ORDER,
|
|
32
35
|
buildCurrentTimeBlock,
|
|
33
36
|
buildIdentityBlock,
|
|
34
37
|
buildRuntimeGuidanceBlocks,
|
|
@@ -36,7 +39,7 @@ import {
|
|
|
36
39
|
requiresBareImageUrl,
|
|
37
40
|
resolveToolGuidedSections,
|
|
38
41
|
toBareImageUrlMessages
|
|
39
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-DXOELY7S.js";
|
|
40
43
|
import {
|
|
41
44
|
convertMessagesToResponsesInput,
|
|
42
45
|
extractReasoningFromResponseOutput,
|
|
@@ -46,11 +49,11 @@ import {
|
|
|
46
49
|
shouldStripReasoningContentForOutbound,
|
|
47
50
|
toOpenAiCompatibleMessages,
|
|
48
51
|
toResponsesTools
|
|
49
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-3QOCS5IF.js";
|
|
50
53
|
import {
|
|
51
54
|
buildProviderAuthHeaders,
|
|
52
55
|
buildProviderExecutionPlan
|
|
53
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-DEIGUGP6.js";
|
|
54
57
|
import {
|
|
55
58
|
NOLO_WORKSPACE_TOOL_NAMES,
|
|
56
59
|
buildNoloWorkspaceCommandArgs,
|
|
@@ -58,7 +61,7 @@ import {
|
|
|
58
61
|
noloStringArg,
|
|
59
62
|
parseNoloWorkspaceToolArguments,
|
|
60
63
|
resolveNoloDialogInput
|
|
61
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-YEFRCO5N.js";
|
|
62
65
|
import {
|
|
63
66
|
buildDialogFallbackTitleFromUserInput
|
|
64
67
|
} from "./chunk-2MBTWINN.js";
|
|
@@ -69,7 +72,7 @@ import {
|
|
|
69
72
|
resolveEmptyAssistantFallbackMessage,
|
|
70
73
|
resolveEmptyAssistantOutcome,
|
|
71
74
|
resolveTruncatedReasoningTailLog
|
|
72
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-UEV5WVQV.js";
|
|
73
76
|
import {
|
|
74
77
|
COMPACTION_SUMMARY_SCHEMA_VERSION,
|
|
75
78
|
COMPACTION_SUMMARY_SYSTEM_PROMPT,
|
|
@@ -83,7 +86,7 @@ import {
|
|
|
83
86
|
formatMessagesForSummaryWithTruncation,
|
|
84
87
|
planCompression,
|
|
85
88
|
planContextUsage
|
|
86
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-G5SQVIFZ.js";
|
|
87
90
|
import {
|
|
88
91
|
resolveNoloStateDir
|
|
89
92
|
} from "./chunk-FD36SCCD.js";
|
|
@@ -92,10 +95,10 @@ import {
|
|
|
92
95
|
} from "./chunk-HNMXYYJR.js";
|
|
93
96
|
import {
|
|
94
97
|
buildDialogSummaryLayer
|
|
95
|
-
} from "./chunk-
|
|
98
|
+
} from "./chunk-DVINR3PL.js";
|
|
96
99
|
import {
|
|
97
100
|
buildUserResponseLanguageContext
|
|
98
|
-
} from "./chunk-
|
|
101
|
+
} from "./chunk-2GRGFCF6.js";
|
|
99
102
|
import {
|
|
100
103
|
canonicalizeToolName,
|
|
101
104
|
canonicalizeToolNames
|
|
@@ -116,15 +119,15 @@ import {
|
|
|
116
119
|
import {
|
|
117
120
|
asTrimmedLowercaseString
|
|
118
121
|
} from "./chunk-QSJ3HFEF.js";
|
|
119
|
-
import {
|
|
120
|
-
isRecord
|
|
121
|
-
} from "./chunk-KUG52IAP.js";
|
|
122
122
|
import {
|
|
123
123
|
asTrimmedString
|
|
124
124
|
} from "./chunk-3EUW3WEO.js";
|
|
125
125
|
import {
|
|
126
126
|
asOptionalPositiveFiniteNumber
|
|
127
127
|
} from "./chunk-U6VC4MU4.js";
|
|
128
|
+
import {
|
|
129
|
+
isRecord
|
|
130
|
+
} from "./chunk-KUG52IAP.js";
|
|
128
131
|
import {
|
|
129
132
|
normalizeServerOrigin
|
|
130
133
|
} from "./chunk-CF7PE763.js";
|
|
@@ -174,6 +177,26 @@ function readTitleParams(value) {
|
|
|
174
177
|
return Object.fromEntries(entries);
|
|
175
178
|
}
|
|
176
179
|
|
|
180
|
+
// packages/agent-runtime/fileWritePolicy.ts
|
|
181
|
+
function evaluateFileWritePolicy(args) {
|
|
182
|
+
if (args.sessionApproved) return { permissionDecision: "allow" };
|
|
183
|
+
return {
|
|
184
|
+
permissionDecision: "ask",
|
|
185
|
+
permissionRequest: {
|
|
186
|
+
id: "permission-file-write-session",
|
|
187
|
+
tool: args.tool,
|
|
188
|
+
action: "file_write",
|
|
189
|
+
title: "\u786E\u8BA4\u5199\u5165\u6587\u4EF6",
|
|
190
|
+
body: `\u672C\u4F1A\u8BDD\u9996\u6B21\u5199\u5165\u6587\u4EF6\uFF1A${args.path}\u3002\u6279\u51C6\u540E\u672C\u4F1A\u8BDD\u540E\u7EED\u5199\u5165\u4E0D\u518D\u9010\u6B21\u786E\u8BA4\u3002`,
|
|
191
|
+
command: args.path,
|
|
192
|
+
suggestedRule: {
|
|
193
|
+
scope: "session",
|
|
194
|
+
pattern: { capability: "file_write", target: "session" }
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
177
200
|
// packages/agent-runtime/toolCallPairing.ts
|
|
178
201
|
function readToolCallId(message) {
|
|
179
202
|
if (typeof message.tool_call_id === "string" && message.tool_call_id) {
|
|
@@ -339,6 +362,9 @@ import { existsSync, mkdirSync, readdirSync, renameSync, statSync, unlinkSync, u
|
|
|
339
362
|
import { isAbsolute, join, relative } from "node:path";
|
|
340
363
|
var DEFAULT_MAX_SPILL_DIR_BYTES = 50 * 1024 * 1024;
|
|
341
364
|
var DEFAULT_SPILL_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
365
|
+
var SPILL_CLEANUP_THROTTLE_MS = 60 * 1e3;
|
|
366
|
+
var SPILL_THROTTLE_MAX_DIRS = 64;
|
|
367
|
+
var lastSpillCleanupAtMsByDir = /* @__PURE__ */ new Map();
|
|
342
368
|
function resolveSpillDirectory(options) {
|
|
343
369
|
if (options?.baseDir) {
|
|
344
370
|
return options.baseDir;
|
|
@@ -360,6 +386,16 @@ function countLines(text) {
|
|
|
360
386
|
}
|
|
361
387
|
function cleanupExpiredSpills(spillDir, options) {
|
|
362
388
|
if (!existsSync(spillDir)) return;
|
|
389
|
+
const throttleMs = options?.throttleMs ?? 0;
|
|
390
|
+
if (throttleMs > 0) {
|
|
391
|
+
const now2 = Date.now();
|
|
392
|
+
const last = lastSpillCleanupAtMsByDir.get(spillDir);
|
|
393
|
+
if (last !== void 0 && now2 - last < throttleMs) return;
|
|
394
|
+
if (lastSpillCleanupAtMsByDir.size >= SPILL_THROTTLE_MAX_DIRS) {
|
|
395
|
+
lastSpillCleanupAtMsByDir.clear();
|
|
396
|
+
}
|
|
397
|
+
lastSpillCleanupAtMsByDir.set(spillDir, now2);
|
|
398
|
+
}
|
|
363
399
|
const maxAge = options?.maxAgeMs ?? DEFAULT_SPILL_TTL_MS;
|
|
364
400
|
const maxBytes = options?.maxTotalBytes ?? DEFAULT_MAX_SPILL_DIR_BYTES;
|
|
365
401
|
const now = Date.now();
|
|
@@ -410,7 +446,8 @@ function spillToolOutput(options) {
|
|
|
410
446
|
}
|
|
411
447
|
cleanupExpiredSpills(spillDir, {
|
|
412
448
|
maxAgeMs: options.ttlMs,
|
|
413
|
-
maxTotalBytes: options.maxRetentionBytes
|
|
449
|
+
maxTotalBytes: options.maxRetentionBytes,
|
|
450
|
+
throttleMs: SPILL_CLEANUP_THROTTLE_MS
|
|
414
451
|
});
|
|
415
452
|
const hash = createHash("sha256").update(content).digest("hex").slice(0, 12);
|
|
416
453
|
const safeToolName = (options.toolName || "tool").replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 24);
|
|
@@ -916,6 +953,34 @@ function createLocalLoopProgressGuard(config, env) {
|
|
|
916
953
|
}
|
|
917
954
|
|
|
918
955
|
// packages/agent-runtime/localLoop.ts
|
|
956
|
+
var LOOP_TIMING_ENABLED = typeof process !== "undefined" && process.env?.NOLO_LOOP_TIMING === "1";
|
|
957
|
+
var LOOP_TIMING_FILE = typeof process !== "undefined" ? process.env?.NOLO_LOOP_TIMING_FILE : void 0;
|
|
958
|
+
var loopTimingRows = [];
|
|
959
|
+
var loopTimingLastMark;
|
|
960
|
+
function loopTimingMark(phase, round) {
|
|
961
|
+
if (!LOOP_TIMING_ENABLED) return;
|
|
962
|
+
const now = performance.now();
|
|
963
|
+
if (loopTimingLastMark !== void 0) {
|
|
964
|
+
loopTimingRows.push({ phase, round, durationMs: now - loopTimingLastMark });
|
|
965
|
+
}
|
|
966
|
+
loopTimingLastMark = now;
|
|
967
|
+
}
|
|
968
|
+
async function loopTimingFlush() {
|
|
969
|
+
if (!LOOP_TIMING_ENABLED) return;
|
|
970
|
+
const lines = loopTimingRows.map((row) => JSON.stringify(row)).join("\n");
|
|
971
|
+
loopTimingRows = [];
|
|
972
|
+
loopTimingLastMark = void 0;
|
|
973
|
+
if (!lines) return;
|
|
974
|
+
if (LOOP_TIMING_FILE) {
|
|
975
|
+
try {
|
|
976
|
+
const { appendFileSync } = await import("node:fs");
|
|
977
|
+
appendFileSync(LOOP_TIMING_FILE, lines + "\n");
|
|
978
|
+
} catch {
|
|
979
|
+
}
|
|
980
|
+
} else {
|
|
981
|
+
process.stderr.write(lines + "\n");
|
|
982
|
+
}
|
|
983
|
+
}
|
|
919
984
|
var LOCAL_AGENT_CONFIG_MISSING_CODE = "LOCAL_AGENT_CONFIG_MISSING";
|
|
920
985
|
function formatToolExecutionError(args) {
|
|
921
986
|
const message = toErrorMessage(args.error);
|
|
@@ -1417,18 +1482,21 @@ function buildMessages(args) {
|
|
|
1417
1482
|
const dynamicParts = blocks2.filter((b) => b.cacheScope === "turn").map((b) => b.content).map((block) => block.trim()).filter(Boolean);
|
|
1418
1483
|
const stableContent = stableParts.join("\n\n");
|
|
1419
1484
|
const dynamicContent = dynamicParts.join("\n\n");
|
|
1420
|
-
const
|
|
1485
|
+
const userContent = dynamicContent ? typeof args.input === "string" ? `${dynamicContent}
|
|
1421
1486
|
|
|
1422
|
-
${
|
|
1487
|
+
${args.input}` : [
|
|
1488
|
+
{ type: "text", text: dynamicContent },
|
|
1489
|
+
...Array.isArray(args.input) ? args.input : args.input ? [args.input] : []
|
|
1490
|
+
] : args.input;
|
|
1423
1491
|
return {
|
|
1424
1492
|
messages: [
|
|
1425
|
-
...
|
|
1493
|
+
...stableContent ? [{
|
|
1426
1494
|
role: "system",
|
|
1427
|
-
content:
|
|
1495
|
+
content: stableContent,
|
|
1428
1496
|
...stableContent ? { stable_prefix_chars: stableContent.length } : {}
|
|
1429
1497
|
}] : [],
|
|
1430
1498
|
...prepareHistoryForNextTurn(args.history, args.contextReferenceResolver),
|
|
1431
|
-
{ role: "user", content:
|
|
1499
|
+
{ role: "user", content: userContent }
|
|
1432
1500
|
],
|
|
1433
1501
|
stableContextChars: stableContent.length,
|
|
1434
1502
|
dynamicContextChars: dynamicContent.length
|
|
@@ -1540,7 +1608,43 @@ function applyPersistedTurnInput(messages, persistedInput, persistedInputReferen
|
|
|
1540
1608
|
};
|
|
1541
1609
|
});
|
|
1542
1610
|
}
|
|
1611
|
+
var fileWriteSessionApproval = /* @__PURE__ */ new WeakMap();
|
|
1612
|
+
var fileWriteSessionKeys = /* @__PURE__ */ new Map();
|
|
1613
|
+
function getFileWriteSessionApproval(input) {
|
|
1614
|
+
if (input.fileWriteSessionId) {
|
|
1615
|
+
let key2 = fileWriteSessionKeys.get(input.fileWriteSessionId);
|
|
1616
|
+
if (!key2) {
|
|
1617
|
+
key2 = {};
|
|
1618
|
+
fileWriteSessionKeys.set(input.fileWriteSessionId, key2);
|
|
1619
|
+
}
|
|
1620
|
+
const existing2 = fileWriteSessionApproval.get(key2);
|
|
1621
|
+
if (existing2) return existing2;
|
|
1622
|
+
const created2 = { approved: false };
|
|
1623
|
+
fileWriteSessionApproval.set(key2, created2);
|
|
1624
|
+
return created2;
|
|
1625
|
+
}
|
|
1626
|
+
const key = input.adapter;
|
|
1627
|
+
const existing = fileWriteSessionApproval.get(key);
|
|
1628
|
+
if (existing) return existing;
|
|
1629
|
+
const created = { approved: false };
|
|
1630
|
+
fileWriteSessionApproval.set(key, created);
|
|
1631
|
+
return created;
|
|
1632
|
+
}
|
|
1633
|
+
function readToolPathForWriteGate(argumentsValue) {
|
|
1634
|
+
try {
|
|
1635
|
+
const parsed = JSON.parse(argumentsValue);
|
|
1636
|
+
return typeof parsed.path === "string" && parsed.path.trim() ? parsed.path.trim() : "the requested file";
|
|
1637
|
+
} catch {
|
|
1638
|
+
return "the requested file";
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
function isCompletedActionGateResult(value) {
|
|
1642
|
+
return Boolean(
|
|
1643
|
+
value && typeof value === "object" && value.status === "completed"
|
|
1644
|
+
);
|
|
1645
|
+
}
|
|
1543
1646
|
async function runLocalAgentTurn(input) {
|
|
1647
|
+
loopTimingMark("turnStart", 0);
|
|
1544
1648
|
const agentConfig = await input.adapter.loadAgentConfig(input.agentRef);
|
|
1545
1649
|
if (!agentConfig) {
|
|
1546
1650
|
const error = new Error(
|
|
@@ -1577,6 +1681,7 @@ async function runLocalAgentTurn(input) {
|
|
|
1577
1681
|
attachDialogIdToError(error, dialogId);
|
|
1578
1682
|
throw error;
|
|
1579
1683
|
}
|
|
1684
|
+
loopTimingMark("loadDialogHistory", 0);
|
|
1580
1685
|
const identityBlock = buildIdentityBlock({
|
|
1581
1686
|
agentName: agentConfig.name,
|
|
1582
1687
|
agentId: agentConfig.key,
|
|
@@ -1592,7 +1697,9 @@ async function runLocalAgentTurn(input) {
|
|
|
1592
1697
|
guidanceBlocks.startupProtocol,
|
|
1593
1698
|
guidanceBlocks.contextLayerContract,
|
|
1594
1699
|
guidanceBlocks.emailRegistrationWorkflow,
|
|
1595
|
-
|
|
1700
|
+
// 注入顺序遵循 TOOL_GUIDED_SECTION_ORDER(与 buildSystemPrompt 的显式
|
|
1701
|
+
// layer 列表同源),禁止用 Object.values 自行定序。
|
|
1702
|
+
...TOOL_GUIDED_SECTION_ORDER.map((id) => toolGuidedSections[id] ?? "")
|
|
1596
1703
|
].map((content) => content.trim()).filter((content) => content.length > 0).map((content) => ({ content, cacheScope: "session" }));
|
|
1597
1704
|
const currentTimeScope = [
|
|
1598
1705
|
{ content: buildCurrentTimeBlock(/* @__PURE__ */ new Date(), void 0), cacheScope: "turn" }
|
|
@@ -1607,6 +1714,7 @@ async function runLocalAgentTurn(input) {
|
|
|
1607
1714
|
...currentTimeScope,
|
|
1608
1715
|
...callerScopes
|
|
1609
1716
|
];
|
|
1717
|
+
loopTimingMark("buildContextBlocks", 0);
|
|
1610
1718
|
let resolvedProvider;
|
|
1611
1719
|
const resolveProviderOnce = async () => {
|
|
1612
1720
|
if (!resolvedProvider) {
|
|
@@ -1641,10 +1749,12 @@ async function runLocalAgentTurn(input) {
|
|
|
1641
1749
|
} catch (error) {
|
|
1642
1750
|
console.warn("[localLoop] auto-compaction unexpected error:", error);
|
|
1643
1751
|
}
|
|
1752
|
+
loopTimingMark("maybeAutoCompactLocalHistory", 0);
|
|
1644
1753
|
const trimmedHistory = trimHistoryToContextBudget(history, agentConfig.model);
|
|
1645
1754
|
if (trimmedHistory.droppedCount > 0) {
|
|
1646
1755
|
history = trimmedHistory.history;
|
|
1647
1756
|
}
|
|
1757
|
+
loopTimingMark("trimHistoryToContextBudget", 0);
|
|
1648
1758
|
const hasContextBlocks = callerScopes.some((block) => block.content.trim()) || mergedContextBlockScopes.some((block) => block.content.trim());
|
|
1649
1759
|
const promptMessageCount = agentConfig.prompt?.trim() || hasContextBlocks ? 1 : 0;
|
|
1650
1760
|
const turnStartIndex = promptMessageCount + history.length;
|
|
@@ -1656,6 +1766,14 @@ async function runLocalAgentTurn(input) {
|
|
|
1656
1766
|
contextReferenceResolver: input.adapter.host === "cli" ? input.contextReferenceResolver : void 0
|
|
1657
1767
|
});
|
|
1658
1768
|
let messages = builtMessages.messages;
|
|
1769
|
+
loopTimingMark("buildMessages", 0);
|
|
1770
|
+
const poisonDowngrade = downgradeUnparsableToolCalls(messages);
|
|
1771
|
+
if (poisonDowngrade.downgraded > 0) {
|
|
1772
|
+
messages = poisonDowngrade.messages;
|
|
1773
|
+
console.warn(
|
|
1774
|
+
`[nolo] downgraded ${poisonDowngrade.downgraded} tool_call(s) with unparsable JSON arguments from outbound history (suspected upstream stream truncation); persisted history untouched`
|
|
1775
|
+
);
|
|
1776
|
+
}
|
|
1659
1777
|
const supportsImages = resolveAgentImageInputSupport({
|
|
1660
1778
|
apiSource: agentConfig.apiSource,
|
|
1661
1779
|
provider: agentConfig.provider,
|
|
@@ -1686,9 +1804,28 @@ async function runLocalAgentTurn(input) {
|
|
|
1686
1804
|
const progressGuard = createLocalLoopProgressGuard(input.progressGuardConfig);
|
|
1687
1805
|
try {
|
|
1688
1806
|
const provider = await resolveProviderOnce();
|
|
1807
|
+
const applyPendingInjections = () => {
|
|
1808
|
+
if (!input.drainInjections) return false;
|
|
1809
|
+
let pending = [];
|
|
1810
|
+
try {
|
|
1811
|
+
pending = input.drainInjections() ?? [];
|
|
1812
|
+
} catch (error) {
|
|
1813
|
+
console.warn("[localLoop] drainInjections failed:", error);
|
|
1814
|
+
return false;
|
|
1815
|
+
}
|
|
1816
|
+
let injected = false;
|
|
1817
|
+
for (const text of pending) {
|
|
1818
|
+
if (typeof text !== "string" || !text.trim()) continue;
|
|
1819
|
+
messages.push({ role: "user", content: text });
|
|
1820
|
+
injected = true;
|
|
1821
|
+
}
|
|
1822
|
+
return injected;
|
|
1823
|
+
};
|
|
1689
1824
|
while (true) {
|
|
1690
1825
|
partialContent = "";
|
|
1691
1826
|
throwIfAborted(input);
|
|
1827
|
+
loopTimingMark("roundStart", round);
|
|
1828
|
+
applyPendingInjections();
|
|
1692
1829
|
const preparedMessages = prepareMessagesForProviderCall(messages);
|
|
1693
1830
|
const baseRequestMessages = filterImagePartsFromMessages(
|
|
1694
1831
|
preparedMessages.messages,
|
|
@@ -1706,6 +1843,7 @@ async function runLocalAgentTurn(input) {
|
|
|
1706
1843
|
dynamicContextChars: builtMessages.dynamicContextChars
|
|
1707
1844
|
};
|
|
1708
1845
|
emptyAssistantRepairPending = false;
|
|
1846
|
+
loopTimingMark("prepareMessagesForProviderCall", round);
|
|
1709
1847
|
result = await runCompleteWithTimeout({
|
|
1710
1848
|
provider,
|
|
1711
1849
|
messages: requestMessages,
|
|
@@ -1733,6 +1871,7 @@ async function runLocalAgentTurn(input) {
|
|
|
1733
1871
|
providerName: agentConfig.provider,
|
|
1734
1872
|
model: provider.model
|
|
1735
1873
|
});
|
|
1874
|
+
loopTimingMark("llmCall", round);
|
|
1736
1875
|
turnUsage = mergeTurnUsage(turnUsage, result.usage);
|
|
1737
1876
|
contextUsage = result.usage;
|
|
1738
1877
|
if (result.usage && Object.keys(result.usage).length > 0) {
|
|
@@ -1762,6 +1901,7 @@ async function runLocalAgentTurn(input) {
|
|
|
1762
1901
|
}
|
|
1763
1902
|
const toolCalls = result.tool_calls ?? [];
|
|
1764
1903
|
const rawToolCallsCount = (result.tool_calls?.length ?? 0) || (Array.isArray(result.raw_tool_calls) ? result.raw_tool_calls.length : 0);
|
|
1904
|
+
loopTimingMark("postLlmProcessing", round);
|
|
1765
1905
|
if (toolCalls.length === 0 && rawToolCallsCount === 0) {
|
|
1766
1906
|
const outcome = resolveEmptyAssistantOutcome({
|
|
1767
1907
|
hasToolCalls: rawToolCallsCount > 0,
|
|
@@ -1807,6 +1947,20 @@ ${reasoningTailLog}
|
|
|
1807
1947
|
};
|
|
1808
1948
|
break;
|
|
1809
1949
|
}
|
|
1950
|
+
if (input.drainInjections) {
|
|
1951
|
+
const assistantMessage = {
|
|
1952
|
+
role: "assistant",
|
|
1953
|
+
content: result.content,
|
|
1954
|
+
...result.reasoning_content ? { reasoning_content: result.reasoning_content } : {}
|
|
1955
|
+
};
|
|
1956
|
+
messages.push(assistantMessage);
|
|
1957
|
+
if (applyPendingInjections()) {
|
|
1958
|
+
loopTimingMark("roundEnd", round);
|
|
1959
|
+
round += 1;
|
|
1960
|
+
continue;
|
|
1961
|
+
}
|
|
1962
|
+
messages.pop();
|
|
1963
|
+
}
|
|
1810
1964
|
break;
|
|
1811
1965
|
}
|
|
1812
1966
|
const outputBlocks = result.output ?? [];
|
|
@@ -1840,11 +1994,13 @@ ${reasoningTailLog}
|
|
|
1840
1994
|
tool_calls: toolCalls
|
|
1841
1995
|
});
|
|
1842
1996
|
const executedToolResults = [];
|
|
1997
|
+
loopTimingMark("toolLoopStart", round);
|
|
1843
1998
|
for (const toolCall of toolCalls) {
|
|
1844
1999
|
throwIfAborted(input);
|
|
1845
2000
|
const toolName = toolCall.function.name;
|
|
1846
2001
|
let toolResult;
|
|
1847
2002
|
const startedAt = Date.now();
|
|
2003
|
+
loopTimingMark("toolCallStart", round);
|
|
1848
2004
|
const argumentsPreview = summarizeToolArguments(toolName, toolCall.function.arguments);
|
|
1849
2005
|
emitLoopEvent(
|
|
1850
2006
|
input,
|
|
@@ -1865,25 +2021,68 @@ ${reasoningTailLog}
|
|
|
1865
2021
|
}
|
|
1866
2022
|
);
|
|
1867
2023
|
try {
|
|
1868
|
-
const
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
2024
|
+
const rawPoisonArguments = toolCall.function?.arguments;
|
|
2025
|
+
if (typeof rawPoisonArguments === "string" && rawPoisonArguments.trim() !== "" && !hasParsableObjectArguments(rawPoisonArguments)) {
|
|
2026
|
+
throw new Error(
|
|
2027
|
+
`\u6A21\u578B\u751F\u6210\u7684 tool_call arguments \u4E0D\u662F\u5408\u6CD5 JSON\uFF08\u7591\u4F3C\u4E0A\u6E38\u6D41\u5F0F\u622A\u65AD\uFF0C\u539F\u59CB\u957F\u5EA6 ${rawPoisonArguments.length}\uFF09\u3002\u8BF7\u91CD\u65B0\u5B8C\u6574\u8C03\u7528 ${toolName}\uFF0C\u786E\u4FDD arguments \u662F\u95ED\u5408\u7684 JSON \u5BF9\u8C61\u3002`
|
|
2028
|
+
);
|
|
2029
|
+
}
|
|
2030
|
+
const writeTool = toolName === "writeFile" || toolName === "editFile";
|
|
2031
|
+
if (writeTool && input.onActionGate && input.fileWriteGateEnabled !== false) {
|
|
2032
|
+
const writeSession = getFileWriteSessionApproval(input);
|
|
2033
|
+
const policy = evaluateFileWritePolicy({
|
|
2034
|
+
tool: toolName,
|
|
2035
|
+
path: readToolPathForWriteGate(toolCall.function.arguments),
|
|
2036
|
+
sessionApproved: writeSession.approved
|
|
2037
|
+
});
|
|
2038
|
+
if (policy.permissionDecision === "ask") {
|
|
2039
|
+
const gate = {
|
|
2040
|
+
...policy.permissionRequest,
|
|
2041
|
+
id: `${policy.permissionRequest.id}-${toolCall.id}`,
|
|
2042
|
+
kind: "confirm",
|
|
2043
|
+
toolName,
|
|
2044
|
+
toolCallId: toolCall.id
|
|
2045
|
+
};
|
|
2046
|
+
const replacement = await raceWithAbort(
|
|
2047
|
+
input,
|
|
2048
|
+
input.onActionGate(gate),
|
|
2049
|
+
`${toolName} confirmation`
|
|
2050
|
+
);
|
|
2051
|
+
const gateResult = replacement?.metadata?.actionGateResult;
|
|
2052
|
+
if (replacement !== void 0 && isCompletedActionGateResult(gateResult)) {
|
|
2053
|
+
writeSession.approved = true;
|
|
2054
|
+
} else {
|
|
2055
|
+
toolResult = replacement ?? {
|
|
2056
|
+
content: `${toolName} cancelled: user declined file write confirmation.`,
|
|
2057
|
+
metadata: {
|
|
2058
|
+
cancelled: true,
|
|
2059
|
+
actionGateResult: { gateId: gate.id, status: "cancelled" }
|
|
2060
|
+
}
|
|
2061
|
+
};
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
if (!toolResult) {
|
|
2066
|
+
const executePromise = input.adapter.executeTool({
|
|
2067
|
+
id: toolCall.id,
|
|
2068
|
+
name: toolName,
|
|
2069
|
+
arguments: toolCall.function.arguments,
|
|
2070
|
+
...userInputText ? { userInput: userInputText } : {},
|
|
2071
|
+
...input.runtimeContext ? { runtimeContext: input.runtimeContext } : {},
|
|
2072
|
+
...input.abortSignal ? { abortSignal: input.abortSignal } : {}
|
|
2073
|
+
}, {
|
|
2074
|
+
...input.abortSignal ? { abortSignal: input.abortSignal } : {},
|
|
2075
|
+
...input.runtimeContext ? { runtimeContext: input.runtimeContext } : {}
|
|
2076
|
+
});
|
|
2077
|
+
toolResult = await raceWithAbort(input, executePromise, toolName);
|
|
2078
|
+
}
|
|
1880
2079
|
const actionGate = buildActionGate({
|
|
1881
2080
|
toolName,
|
|
1882
2081
|
toolCallId: toolCall.id,
|
|
1883
2082
|
metadata: toolResult.metadata
|
|
1884
2083
|
});
|
|
1885
2084
|
if (actionGate && input.onActionGate) {
|
|
1886
|
-
const replacement = await input.onActionGate(actionGate);
|
|
2085
|
+
const replacement = await raceWithAbort(input, input.onActionGate(actionGate), `${toolName} action gate`);
|
|
1887
2086
|
if (replacement) {
|
|
1888
2087
|
toolResult = replacement;
|
|
1889
2088
|
}
|
|
@@ -1891,6 +2090,7 @@ ${reasoningTailLog}
|
|
|
1891
2090
|
const finishedAt = Date.now();
|
|
1892
2091
|
const summary = summarizeToolResult(toolResult.content, toolResult.metadata);
|
|
1893
2092
|
const safeMetadata = projectSafeToolObservationMetadata(toolResult.metadata);
|
|
2093
|
+
loopTimingMark("toolExecute", round);
|
|
1894
2094
|
emitLoopEvent(
|
|
1895
2095
|
input,
|
|
1896
2096
|
{
|
|
@@ -1899,7 +2099,7 @@ ${reasoningTailLog}
|
|
|
1899
2099
|
toolCallId: toolCall.id,
|
|
1900
2100
|
toolName,
|
|
1901
2101
|
atMs: finishedAt,
|
|
1902
|
-
ok: true,
|
|
2102
|
+
ok: toolResult.metadata?.cancelled !== true && toolResult.metadata?.actionGateResult?.status !== "cancelled" && toolResult.metadata?.actionGateResult?.status !== "failed",
|
|
1903
2103
|
elapsedMs: Math.max(0, finishedAt - startedAt),
|
|
1904
2104
|
...summary ? { summary } : {},
|
|
1905
2105
|
...safeMetadata ? { metadata: safeMetadata } : {}
|
|
@@ -1957,6 +2157,7 @@ ${reasoningTailLog}
|
|
|
1957
2157
|
content: toolResult.content,
|
|
1958
2158
|
metadata: toolResult.metadata
|
|
1959
2159
|
});
|
|
2160
|
+
loopTimingMark("toolResultFormat", round);
|
|
1960
2161
|
messages.push({
|
|
1961
2162
|
role: "tool",
|
|
1962
2163
|
content: formatToolMessageContent({
|
|
@@ -1989,6 +2190,7 @@ ${reasoningTailLog}
|
|
|
1989
2190
|
};
|
|
1990
2191
|
break;
|
|
1991
2192
|
}
|
|
2193
|
+
loopTimingMark("roundEnd", round);
|
|
1992
2194
|
round += 1;
|
|
1993
2195
|
}
|
|
1994
2196
|
} catch (error) {
|
|
@@ -2023,6 +2225,7 @@ ${reasoningTailLog}
|
|
|
2023
2225
|
input
|
|
2024
2226
|
});
|
|
2025
2227
|
attachDialogIdToError(loopError, dialogId);
|
|
2228
|
+
await loopTimingFlush();
|
|
2026
2229
|
throw loopError;
|
|
2027
2230
|
}
|
|
2028
2231
|
result = result;
|
|
@@ -2054,6 +2257,7 @@ ${reasoningTailLog}
|
|
|
2054
2257
|
});
|
|
2055
2258
|
}
|
|
2056
2259
|
const accountingUsage = addOutOfBandUsage(turnUsage, compactionUsage);
|
|
2260
|
+
loopTimingMark("saveTurnStart", round);
|
|
2057
2261
|
const saved = await input.adapter.saveTurn({
|
|
2058
2262
|
agentKey: agentConfig.key,
|
|
2059
2263
|
messages: turnMessages,
|
|
@@ -2072,6 +2276,8 @@ ${reasoningTailLog}
|
|
|
2072
2276
|
...input.inheritedFromDialogKey ? { inheritedFromDialogKey: input.inheritedFromDialogKey } : {},
|
|
2073
2277
|
...input.parentDialogId ? { parentDialogId: input.parentDialogId } : {}
|
|
2074
2278
|
});
|
|
2279
|
+
loopTimingMark("saveTurn", round);
|
|
2280
|
+
await loopTimingFlush();
|
|
2075
2281
|
return {
|
|
2076
2282
|
...result,
|
|
2077
2283
|
...usageRecords.length > 0 ? { usageRecords } : {},
|
|
@@ -2304,7 +2510,10 @@ function buildOpenAiCompatibleChatCompletionRequest(args) {
|
|
|
2304
2510
|
stream: args.stream ?? false,
|
|
2305
2511
|
...args.providerConfig.requestOptions,
|
|
2306
2512
|
...args.tools && args.tools.length > 0 ? { tools: args.tools } : {},
|
|
2307
|
-
...!isResponses && args.stream ? getUsageRequestOptions(args.providerConfig.usageProvider ?? args.providerConfig.provider, {
|
|
2513
|
+
...!isResponses && args.stream ? getUsageRequestOptions(args.providerConfig.usageProvider ?? args.providerConfig.provider, {
|
|
2514
|
+
api: "chat-completions",
|
|
2515
|
+
endpoint: args.providerConfig.endpoint
|
|
2516
|
+
}) : {}
|
|
2308
2517
|
};
|
|
2309
2518
|
const body = isResponses ? buildResponsesRequestBody(rawBody, args.providerConfig.model) : normalizeChatCompletionsBodyForProvider({
|
|
2310
2519
|
body: rawBody,
|
|
@@ -3008,19 +3217,24 @@ function parseSyncServersEnv(env) {
|
|
|
3008
3217
|
if (!raw) return [];
|
|
3009
3218
|
return raw.split(",").map((value) => value.trim()).filter((value) => value.length > 0);
|
|
3010
3219
|
}
|
|
3220
|
+
var DEFAULT_HYBRID_READ_TIMEOUT_MS = 250;
|
|
3011
3221
|
function createHybridRecordStore(deps) {
|
|
3012
3222
|
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
3223
|
+
const requestTimeoutMs = deps.requestTimeoutMs ?? DEFAULT_HYBRID_READ_TIMEOUT_MS;
|
|
3013
3224
|
return {
|
|
3014
3225
|
read: async (dbKey, options) => {
|
|
3015
3226
|
const localRecord = await readHybridLocalRecord(deps.db, dbKey);
|
|
3016
3227
|
const normalizedLocalRecord = normalizeHybridRecord(dbKey, localRecord);
|
|
3017
3228
|
if (normalizedLocalRecord && options?.remote !== true) return normalizedLocalRecord;
|
|
3018
3229
|
if (options?.remote === false) return null;
|
|
3230
|
+
const fallbackDeadlineMs = requestTimeoutMs > 0 ? Date.now() + requestTimeoutMs : null;
|
|
3019
3231
|
for (const server of resolveHybridServers(
|
|
3020
3232
|
deps.defaultServer,
|
|
3021
3233
|
options?.preferredServerOrigin,
|
|
3022
3234
|
deps.fallbackServers
|
|
3023
3235
|
)) {
|
|
3236
|
+
const remainingMs = fallbackDeadlineMs === null ? null : fallbackDeadlineMs - Date.now();
|
|
3237
|
+
if (remainingMs !== null && remainingMs <= 0) break;
|
|
3024
3238
|
let remoteRecord = null;
|
|
3025
3239
|
try {
|
|
3026
3240
|
remoteRecord = await fetchHybridRemoteRecord({
|
|
@@ -3028,7 +3242,7 @@ function createHybridRecordStore(deps) {
|
|
|
3028
3242
|
server,
|
|
3029
3243
|
authToken: deps.authToken,
|
|
3030
3244
|
fetchImpl,
|
|
3031
|
-
...
|
|
3245
|
+
...remainingMs !== null ? { signal: AbortSignal.timeout(remainingMs) } : {}
|
|
3032
3246
|
});
|
|
3033
3247
|
} catch {
|
|
3034
3248
|
continue;
|
|
@@ -6894,10 +7108,10 @@ function buildLoadSkillExecutor(args) {
|
|
|
6894
7108
|
metadata: { loadSkill: true, resolved: false }
|
|
6895
7109
|
};
|
|
6896
7110
|
}
|
|
6897
|
-
const { resolveSkillByName } = await import("./skillDiscovery-
|
|
7111
|
+
const { resolveSkillByName } = await import("./skillDiscovery-CYUCJMAG.js");
|
|
6898
7112
|
const resolved = resolveSkillByName(args.cwd, name);
|
|
6899
7113
|
if (!resolved) {
|
|
6900
|
-
const { resolveCodingBuiltinSlug, buildCodingSkillContentBySlug } = await import("./codingSkills-
|
|
7114
|
+
const { resolveCodingBuiltinSlug, buildCodingSkillContentBySlug } = await import("./codingSkills-FQPCEIWL.js");
|
|
6901
7115
|
const builtinSlug = resolveCodingBuiltinSlug(name);
|
|
6902
7116
|
if (builtinSlug) {
|
|
6903
7117
|
const body = buildCodingSkillContentBySlug(builtinSlug);
|
|
@@ -6932,7 +7146,7 @@ ${body}`,
|
|
|
6932
7146
|
};
|
|
6933
7147
|
}
|
|
6934
7148
|
async function formatUnknownSkillMessage(cwd, requestedName) {
|
|
6935
|
-
const { discoverSkills } = await import("./skillDiscovery-
|
|
7149
|
+
const { discoverSkills } = await import("./skillDiscovery-CYUCJMAG.js");
|
|
6936
7150
|
let available = [];
|
|
6937
7151
|
try {
|
|
6938
7152
|
available = discoverSkills(cwd).map((s) => s.name);
|
|
@@ -6950,6 +7164,7 @@ Available skills: ${available.join(", ")}`;
|
|
|
6950
7164
|
export {
|
|
6951
7165
|
readCommandActionGatePayload,
|
|
6952
7166
|
readActionGate,
|
|
7167
|
+
evaluateFileWritePolicy,
|
|
6953
7168
|
summarizeToolArguments,
|
|
6954
7169
|
LOCAL_AGENT_CONFIG_MISSING_CODE,
|
|
6955
7170
|
LOCAL_TURN_ABORTED_CODE,
|
|
@@ -6967,6 +7182,7 @@ export {
|
|
|
6967
7182
|
buildAgentRuntimeDialogWritePlan,
|
|
6968
7183
|
shouldCacheHybridRemoteRecord,
|
|
6969
7184
|
parseSyncServersEnv,
|
|
7185
|
+
DEFAULT_HYBRID_READ_TIMEOUT_MS,
|
|
6970
7186
|
createHybridRecordStore,
|
|
6971
7187
|
isDestructiveShellCommand,
|
|
6972
7188
|
evaluateShellCommandPolicy,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sanitizeForOutbound
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2QDDKFG5.js";
|
|
4
4
|
import {
|
|
5
5
|
accumulateToolCallDelta,
|
|
6
6
|
createThinkParserState,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
shouldStripReasoningContentForOutbound,
|
|
24
24
|
toOpenAiCompatibleMessages,
|
|
25
25
|
toResponsesTools
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-3QOCS5IF.js";
|
|
27
27
|
import {
|
|
28
28
|
buildProviderExecutionPlan,
|
|
29
29
|
canUsePlatformChatProvider,
|
|
@@ -33,13 +33,13 @@ import {
|
|
|
33
33
|
resolvePlatformAuthToken,
|
|
34
34
|
resolvePlatformServerUrl,
|
|
35
35
|
resolveProviderTransportDecision
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-DEIGUGP6.js";
|
|
37
37
|
import {
|
|
38
38
|
clipCompactText
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-G5SQVIFZ.js";
|
|
40
40
|
import {
|
|
41
41
|
NOLO_CLIENT_VERSION_HEADER
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-G4WSLTQF.js";
|
|
43
43
|
import {
|
|
44
44
|
isRecord
|
|
45
45
|
} from "./chunk-KUG52IAP.js";
|
|
@@ -477,7 +477,8 @@ function buildPlatformChatCompletionRequest(args) {
|
|
|
477
477
|
},
|
|
478
478
|
stream: args.stream ?? false,
|
|
479
479
|
...args.stream ? getUsageRequestOptions(args.providerConfig.usageProvider ?? args.providerConfig.provider, {
|
|
480
|
-
api: usesResponsesApi ? "responses" : "chat-completions"
|
|
480
|
+
api: usesResponsesApi ? "responses" : "chat-completions",
|
|
481
|
+
endpoint: usesResponsesApi ? null : args.providerConfig.endpoint
|
|
481
482
|
}) : {},
|
|
482
483
|
...requestOptions,
|
|
483
484
|
...args.tools && args.tools.length > 0 ? {
|