nolo-cli 0.8.0-alpha.7 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{_executeModel-XIGO7HW5.js → _executeModel-UD44KGZ4.js} +33 -28
- package/{action-PAXRPJJF.js → action-ZJWE3Y5S.js} +5 -4
- package/{addContentAction-CZVWF3QZ.js → addContentAction-TVDBNJM5.js} +4 -3
- package/{addDialogAgentAction-CCIDTPHC.js → addDialogAgentAction-EKH774VT.js} +3 -2
- package/{agentDeleteCommand-47B24JYG.js → agentDeleteCommand-TCPEFJTF.js} +15 -11
- package/{agentEmailCommands-D4FC6OZJ.js → agentEmailCommands-CZ3UILZ4.js} +36 -31
- package/{agentListCommands-UFET7CC4.js → agentListCommands-SJKO2FFB.js} +16 -12
- package/{agentMachineCommands-LH7QDQPP.js → agentMachineCommands-PSNABISZ.js} +15 -11
- package/{agentRecordCommands-CWS2B5IA.js → agentRecordCommands-MH2JKFHS.js} +36 -31
- package/{agentRunCommand-3FRPISLG.js → agentRunCommand-4KH6MIZR.js} +42 -34
- package/{agentRuntimeLocal-JNQQC2WG.js → agentRuntimeLocal-SKHJUWSS.js} +20 -15
- package/{agentSlice-XDFSELFJ.js → agentSlice-3WXXN4VK.js} +5 -4
- package/{authCommand-WXMD3IPR.js → authCommand-PXFX6JDT.js} +8 -1
- package/{authCommands-X74AFDTC.js → authCommands-356AYWEK.js} +10 -1
- package/{chunk-E5HMHIKL.js → chunk-2K2ECKSG.js} +4 -4
- package/{chunk-364VYAX2.js → chunk-2PUGVR6E.js} +1 -1
- package/chunk-3TZDXYSF.js +71 -0
- package/{chunk-YIJFUVKA.js → chunk-3WYQEUBI.js} +1 -1
- package/{chunk-543C7RDK.js → chunk-4K2KKCSD.js} +23 -8
- package/chunk-4ZDM73SD.js +34 -0
- package/{chunk-TDIQFT2F.js → chunk-5CS33IBL.js} +1 -1
- package/chunk-5KLGBAAR.js +386 -0
- package/{chunk-YD43KPCK.js → chunk-5PJ3VWCS.js} +3 -3
- package/{chunk-IAXBCTTE.js → chunk-63SLEOLK.js} +2 -2
- package/{chunk-BSTNFPHD.js → chunk-6GANEXVO.js} +1 -1
- package/{chunk-6PWWWMI7.js → chunk-7OOXPE3N.js} +2 -2
- package/{chunk-KK6SWS5B.js → chunk-7QRKCBOP.js} +5 -5
- package/{chunk-LM25IZBJ.js → chunk-AUQ747NZ.js} +2 -2
- package/{chunk-572EKYLF.js → chunk-BBYVOSU2.js} +1 -1
- package/{chunk-2MALU52L.js → chunk-C3RUNRHT.js} +1 -1
- package/{chunk-G5H7RNFL.js → chunk-COMXDWNM.js} +2 -2
- package/{chunk-2LMT6K6N.js → chunk-CPB2YM4D.js} +2 -2
- package/{chunk-USZMK5UT.js → chunk-DCOA4QSN.js} +1 -1
- package/{chunk-OF5H3QWS.js → chunk-EXTIQUCI.js} +182 -0
- package/{chunk-B76D3JJK.js → chunk-G43KEVSC.js} +4 -4
- package/{chunk-USZDUWOV.js → chunk-GG4AJPSR.js} +2 -2
- package/chunk-I42VC5KR.js +15 -0
- package/{chunk-BR2WP3DF.js → chunk-IWX4UW2E.js} +9 -9
- package/chunk-JEXVIMYZ.js +55 -0
- package/{chunk-XDVAYP26.js → chunk-JRKKFRAV.js} +1 -1
- package/{chunk-DA2OEKS6.js → chunk-KKY4B2Q2.js} +2 -8
- package/{chunk-A3X4Y7MO.js → chunk-KOCA5FCS.js} +482 -26
- package/{chunk-IYQV26RA.js → chunk-KTVVPRJS.js} +2 -2
- package/{chunk-V2F4OGYM.js → chunk-LARL2V6G.js} +22 -18
- package/{chunk-H2RMRZJE.js → chunk-MGOJ5R6J.js} +1 -1
- package/{chunk-UVPF33PW.js → chunk-MKMWT7SA.js} +63 -19862
- package/chunk-OPZYGHUC.js +89 -0
- package/chunk-PAKN26FP.js +239 -0
- package/{chunk-OVGXXUVI.js → chunk-PCWC3JTN.js} +2 -2
- package/{chunk-AR7ZSGDI.js → chunk-PG5PNA7Y.js} +16 -6
- package/{chunk-HEIIIZBX.js → chunk-Q2YZULBH.js} +1 -1
- package/{chunk-2JHWPW5B.js → chunk-SBR32ZZS.js} +77 -303
- package/{chunk-PN7AFLOK.js → chunk-SH2CFQOH.js} +3 -13
- package/{chunk-CM54RSSA.js → chunk-SL35K7AH.js} +21 -1
- package/{chunk-VEJLAVTC.js → chunk-TSS3XJY4.js} +4 -4
- package/{chunk-IECI4YHR.js → chunk-UUJDGGAK.js} +3 -3
- package/{chunk-GEKCOPTN.js → chunk-WKM6FH35.js} +1 -1
- package/{chunk-SL3EPWB4.js → chunk-XE635NI4.js} +21 -22
- package/{chunk-NE3E3XJ2.js → chunk-XS466O7S.js} +96 -99
- package/{chunk-5XH3NZ4T.js → chunk-YBWOP46I.js} +20 -379
- package/{chunk-VQ2AJRGD.js → chunk-YPRZSPF3.js} +1 -1
- package/{chunk-AUGHVUFE.js → chunk-YYUCRDOK.js} +1 -1
- package/{chunk-KTI2WDDG.js → chunk-ZIG5LJ7X.js} +357 -266
- package/{chunk-NXZGF7F7.js → chunk-ZQ2UM4KG.js} +1 -1
- package/{createAgentAutomationAction-3QTGNYJC.js → createAgentAutomationAction-63OIP6X5.js} +15 -13
- package/{createDialogAction-5YX3ARBK.js → createDialogAction-ZLYZDYBB.js} +18 -16
- package/{createPageAction-EQNQQRCW.js → createPageAction-AL5FSDCK.js} +16 -14
- package/{dbSlice-C4UJLRZP.js → dbSlice-PR44QPXY.js} +3 -2
- package/{dialogCommands-AOQS23FV.js → dialogCommands-F6YI5742.js} +17 -13
- package/{dialogSlice-GZE3NCMC.js → dialogSlice-JSBNZRLR.js} +15 -13
- package/{docCreateCommands-GVOQVJON.js → docCreateCommands-4CTO7ERT.js} +16 -12
- package/{docDeleteCommands-GEB7YAUZ.js → docDeleteCommands-VBWERDRG.js} +17 -13
- package/{docReadCommands-XYKI2DF2.js → docReadCommands-KNP4MFYB.js} +16 -12
- package/{docStore-MLM5AME5.js → docStore-ADP5VYY4.js} +16 -14
- package/{docUpdateCommands-4L3RAMHZ.js → docUpdateCommands-4BCBJQHA.js} +16 -12
- package/{fetchMessages-JOCYIFKL.js → fetchMessages-U6ZHN56A.js} +3 -2
- package/{getPricing-PWPJ6MNV.js → getPricing-3E6UNPKL.js} +3 -3
- package/{handleSendMessageAction-WG2GKTGZ.js → handleSendMessageAction-IJDQ6ARA.js} +15 -13
- package/index.js +60 -56
- package/lib-FYYBQIXS.js +19839 -0
- package/{localDialogRead-D3BELSTF.js → localDialogRead-Z5UTAJPU.js} +1 -1
- package/{machineCommands-ZNXKLH6Q.js → machineCommands-EA3M4XTN.js} +38 -33
- package/{machineWsRunDispatch-7WRG6HNV.js → machineWsRunDispatch-NAPKE5ZA.js} +34 -29
- package/{models-XLEOET3E.js → models-4OPOOLFS.js} +2 -2
- package/package.json +1 -1
- package/{readlineWorkspace-AQURUDN4.js → readlineWorkspace-KMWT4T4S.js} +196 -44
- package/{removeDialogAgentAction-CXLST3N6.js → removeDialogAgentAction-GJQJNDW6.js} +5 -4
- package/{runAgentClientLoop-VQUEKGA5.js → runAgentClientLoop-U5Q6NDTJ.js} +28 -25
- package/{setDialogExtraReferencesAction-LP6VYGU7.js → setDialogExtraReferencesAction-M7OQG54N.js} +3 -2
- package/{setPrimaryDialogAgentAction-D3GGH23T.js → setPrimaryDialogAgentAction-46UNFJDL.js} +5 -4
- package/{settingSlice-J4I3Z5H7.js → settingSlice-FVUUH4JA.js} +4 -3
- package/{spaceCommands-R2RXD5UY.js → spaceCommands-E2CFRPZJ.js} +15 -11
- package/{spaceSlice-5UT4JNIN.js → spaceSlice-L3R6IMXE.js} +15 -13
- package/{streamAgentChatTurn-NRWSQKFN.js → streamAgentChatTurn-UBDAOQWE.js} +60 -35
- package/{tableCommands-66XEWHAK.js → tableCommands-GOFP7QKA.js} +1 -1
- package/{tools-TNMUDDRK.js → tools-TMJXZTCA.js} +22 -20
- package/tuiSummaryLlmCaller-RV3THLZF.js +78 -0
- package/{understanding-HCSFPE7R.js → understanding-GQKNDDWM.js} +7 -54
- package/{updateDialogTitleAction-IXOKAVX3.js → updateDialogTitleAction-ZTWRDXI2.js} +17 -14
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clipHeadAndTail
|
|
3
|
+
} from "./chunk-JEXVIMYZ.js";
|
|
1
4
|
import {
|
|
2
5
|
prepareTools
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-CPB2YM4D.js";
|
|
4
7
|
import {
|
|
5
8
|
getPublicImageAgentMode
|
|
6
9
|
} from "./chunk-VIDPVFP3.js";
|
|
7
10
|
import {
|
|
8
11
|
performFetchRequest
|
|
9
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-SBR32ZZS.js";
|
|
10
13
|
import {
|
|
11
14
|
createSSEParser,
|
|
12
15
|
createToolRunId,
|
|
@@ -17,7 +20,7 @@ import {
|
|
|
17
20
|
toolRunSetPending,
|
|
18
21
|
toolRunStarted,
|
|
19
22
|
toolRunSucceeded
|
|
20
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-MKMWT7SA.js";
|
|
21
24
|
import {
|
|
22
25
|
addToolMessage,
|
|
23
26
|
getModelInfo,
|
|
@@ -25,22 +28,24 @@ import {
|
|
|
25
28
|
messageStreaming,
|
|
26
29
|
selectCurrentSpaceId,
|
|
27
30
|
updateToolMessage
|
|
28
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-ZIG5LJ7X.js";
|
|
29
32
|
import {
|
|
30
33
|
streamAgentChatTurn
|
|
31
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-4K2KKCSD.js";
|
|
35
|
+
import {
|
|
36
|
+
EMPTY_ASSISTANT_REPAIR_PROMPT
|
|
37
|
+
} from "./chunk-XS466O7S.js";
|
|
32
38
|
import {
|
|
33
|
-
EMPTY_ASSISTANT_REPAIR_PROMPT,
|
|
34
39
|
createThinkParserState,
|
|
35
40
|
flushThinkParser,
|
|
36
41
|
processThinkChunk
|
|
37
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-OPZYGHUC.js";
|
|
38
43
|
import {
|
|
39
44
|
getApiEndpoint
|
|
40
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-BBYVOSU2.js";
|
|
41
46
|
import {
|
|
42
47
|
isNoloHostedProvider
|
|
43
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-IWX4UW2E.js";
|
|
44
49
|
import {
|
|
45
50
|
extractCustomId
|
|
46
51
|
} from "./chunk-DFFIZ25G.js";
|
|
@@ -54,15 +59,15 @@ import {
|
|
|
54
59
|
} from "./chunk-HNMXYYJR.js";
|
|
55
60
|
import {
|
|
56
61
|
selectCurrentServer
|
|
57
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-TSS3XJY4.js";
|
|
58
63
|
import {
|
|
59
64
|
write
|
|
60
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-COMXDWNM.js";
|
|
61
66
|
import {
|
|
62
67
|
createDialogMessageKeyAndId,
|
|
63
68
|
dialogMessageKey,
|
|
64
69
|
toTrimmedString
|
|
65
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-SH2CFQOH.js";
|
|
66
71
|
import {
|
|
67
72
|
createAsyncThunk,
|
|
68
73
|
selectIdentityToken
|
|
@@ -81,12 +86,6 @@ import {
|
|
|
81
86
|
} from "./chunk-KUG52IAP.js";
|
|
82
87
|
|
|
83
88
|
// packages/integrations/openai/filterAndCleanMessages.ts
|
|
84
|
-
var TOOL_CONTEXT_MAX_CHARS = 4e3;
|
|
85
|
-
var truncateText = (text, maxChars = TOOL_CONTEXT_MAX_CHARS) => {
|
|
86
|
-
if (text.length <= maxChars) return text;
|
|
87
|
-
return `${text.slice(0, maxChars)}
|
|
88
|
-
\u2026[\u622A\u65AD\uFF0C\u539F\u59CB\u957F\u5EA6 ${text.length} \u5B57\u7B26]`;
|
|
89
|
-
};
|
|
90
89
|
var isValidMessagePart = (part) => {
|
|
91
90
|
if (!part || typeof part !== "object") return false;
|
|
92
91
|
if (part.type === "text") return typeof part.text === "string";
|
|
@@ -99,11 +98,11 @@ var isValidMessagePart = (part) => {
|
|
|
99
98
|
var extractContent = (msg) => {
|
|
100
99
|
if (msg.role === "tool") {
|
|
101
100
|
const llmContext = asTrimmedString(msg.toolPayload?.llmContext);
|
|
102
|
-
if (llmContext) return
|
|
101
|
+
if (llmContext) return clipHeadAndTail(llmContext, { toolCallId: extractToolCallId(msg) ?? void 0 }).content;
|
|
103
102
|
const summary = asTrimmedString(msg.toolPayload?.summary);
|
|
104
|
-
if (summary) return
|
|
105
|
-
if (typeof msg.content === "string") return
|
|
106
|
-
if (msg.content != null) return
|
|
103
|
+
if (summary) return clipHeadAndTail(summary, { toolCallId: extractToolCallId(msg) ?? void 0 }).content;
|
|
104
|
+
if (typeof msg.content === "string") return clipHeadAndTail(msg.content, { toolCallId: extractToolCallId(msg) ?? void 0 }).content;
|
|
105
|
+
if (msg.content != null) return clipHeadAndTail(JSON.stringify(msg.content), { toolCallId: extractToolCallId(msg) ?? void 0 }).content;
|
|
107
106
|
return null;
|
|
108
107
|
}
|
|
109
108
|
if (typeof msg.content === "string") return msg.content;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildCurrentTimeBlock,
|
|
3
|
+
buildIdentityBlock,
|
|
4
|
+
buildRuntimeGuidanceBlocks
|
|
5
|
+
} from "./chunk-PAKN26FP.js";
|
|
6
|
+
import {
|
|
7
|
+
canonicalizeToolNames
|
|
8
|
+
} from "./chunk-AUQ747NZ.js";
|
|
1
9
|
import {
|
|
2
10
|
clipCompactText
|
|
3
11
|
} from "./chunk-5MMAK75Q.js";
|
|
4
12
|
import {
|
|
5
13
|
findModelConfig,
|
|
6
14
|
getProviderByModelName
|
|
7
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-BBYVOSU2.js";
|
|
8
16
|
import {
|
|
9
17
|
compactWhitespace
|
|
10
18
|
} from "./chunk-DWLEOOGR.js";
|
|
@@ -368,8 +376,9 @@ async function runCompleteWithTimeout(args) {
|
|
|
368
376
|
})
|
|
369
377
|
);
|
|
370
378
|
}
|
|
379
|
+
let result;
|
|
371
380
|
try {
|
|
372
|
-
|
|
381
|
+
result = racers.length === 0 ? await complete : await Promise.race([complete, ...racers]);
|
|
373
382
|
ok = true;
|
|
374
383
|
return result;
|
|
375
384
|
} catch (error) {
|
|
@@ -383,7 +392,26 @@ async function runCompleteWithTimeout(args) {
|
|
|
383
392
|
} finally {
|
|
384
393
|
if (timer) clearTimeout(timer);
|
|
385
394
|
if (signal && abortListener) signal.removeEventListener("abort", abortListener);
|
|
386
|
-
|
|
395
|
+
const usage = result?.usage;
|
|
396
|
+
const cacheHit = Number(usage?.cache_read_input_tokens ?? usage?.prompt_cache_hit_tokens ?? 0);
|
|
397
|
+
const cacheMiss = Number(usage?.cache_creation_input_tokens ?? usage?.prompt_cache_miss_tokens ?? 0);
|
|
398
|
+
const inputTokens = Number(usage?.input_tokens ?? usage?.prompt_tokens ?? 0);
|
|
399
|
+
const outputTokens = Number(usage?.output_tokens ?? usage?.completion_tokens ?? 0);
|
|
400
|
+
emitLoopEvent(input, {
|
|
401
|
+
kind: "llm-end",
|
|
402
|
+
round,
|
|
403
|
+
atMs: Date.now(),
|
|
404
|
+
ok,
|
|
405
|
+
...inputTokens > 0 || cacheHit > 0 || cacheMiss > 0 ? {
|
|
406
|
+
cache: {
|
|
407
|
+
inputTokens,
|
|
408
|
+
outputTokens,
|
|
409
|
+
cacheHitTokens: cacheHit,
|
|
410
|
+
cacheMissTokens: cacheMiss,
|
|
411
|
+
hitRatio: inputTokens > 0 ? Math.round(cacheHit / inputTokens * 1e4) / 1e4 : 0
|
|
412
|
+
}
|
|
413
|
+
} : {}
|
|
414
|
+
});
|
|
387
415
|
}
|
|
388
416
|
}
|
|
389
417
|
function clip2(value, max = 240) {
|
|
@@ -483,8 +511,8 @@ function buildActionGate(args) {
|
|
|
483
511
|
toolCallId: args.toolCallId
|
|
484
512
|
};
|
|
485
513
|
}
|
|
486
|
-
var MAX_HISTORICAL_TOOL_CONTENT_CHARS =
|
|
487
|
-
var MAX_IN_TURN_TOOL_CONTENT_CHARS =
|
|
514
|
+
var MAX_HISTORICAL_TOOL_CONTENT_CHARS = 1600;
|
|
515
|
+
var MAX_IN_TURN_TOOL_CONTENT_CHARS = 4e3;
|
|
488
516
|
function summarizeToolContentForProvider(content, maxChars, label) {
|
|
489
517
|
if (typeof content !== "string") return content;
|
|
490
518
|
if (content.length <= maxChars) return content;
|
|
@@ -547,6 +575,21 @@ function filterImagePartsFromMessages(messages, supportsImages) {
|
|
|
547
575
|
}));
|
|
548
576
|
}
|
|
549
577
|
function buildMessages(args) {
|
|
578
|
+
if (args.contextBlockScopes?.length) {
|
|
579
|
+
const blocks2 = args.contextBlockScopes.filter((b) => b.content.trim());
|
|
580
|
+
const stableParts = [args.prompt?.trim(), ...blocks2.filter((b) => b.cacheScope === "session").map((b) => b.content)].filter(Boolean);
|
|
581
|
+
const dynamicParts = blocks2.filter((b) => b.cacheScope === "turn").map((b) => b.content).filter(Boolean);
|
|
582
|
+
const stableContent = stableParts.join("\n\n");
|
|
583
|
+
const dynamicContent = dynamicParts.join("\n\n");
|
|
584
|
+
const systemContent2 = dynamicContent ? `${stableContent}
|
|
585
|
+
|
|
586
|
+
${dynamicContent}` : stableContent;
|
|
587
|
+
return [
|
|
588
|
+
...systemContent2 ? [{ role: "system", content: systemContent2 }] : [],
|
|
589
|
+
...prepareHistoryForNextTurn(args.history),
|
|
590
|
+
{ role: "user", content: args.input }
|
|
591
|
+
];
|
|
592
|
+
}
|
|
550
593
|
const blocks = (args.contextBlocks ?? []).map((block) => block.trim()).filter(Boolean);
|
|
551
594
|
const systemContent = [args.prompt?.trim(), ...blocks].filter(Boolean).join("\n\n");
|
|
552
595
|
return [
|
|
@@ -559,13 +602,21 @@ function mergeTurnUsage(current, next) {
|
|
|
559
602
|
if (!next) return current;
|
|
560
603
|
const read = (usage) => ({
|
|
561
604
|
input: Number(usage.input_tokens ?? usage.prompt_tokens ?? 0),
|
|
562
|
-
output: Number(usage.output_tokens ?? usage.completion_tokens ?? 0)
|
|
605
|
+
output: Number(usage.output_tokens ?? usage.completion_tokens ?? 0),
|
|
606
|
+
cacheHit: Number(
|
|
607
|
+
usage.cache_read_input_tokens ?? usage.prompt_cache_hit_tokens ?? 0
|
|
608
|
+
),
|
|
609
|
+
cacheMiss: Number(
|
|
610
|
+
usage.cache_creation_input_tokens ?? usage.prompt_cache_miss_tokens ?? 0
|
|
611
|
+
)
|
|
563
612
|
});
|
|
564
613
|
const right = read(next);
|
|
565
|
-
const left = current ? read(current) : { input: 0, output: 0 };
|
|
614
|
+
const left = current ? read(current) : { input: 0, output: 0, cacheHit: 0, cacheMiss: 0 };
|
|
566
615
|
return {
|
|
567
616
|
input_tokens: right.input || left.input,
|
|
568
|
-
output_tokens: left.output + right.output
|
|
617
|
+
output_tokens: left.output + right.output,
|
|
618
|
+
cache_read_input_tokens: left.cacheHit + right.cacheHit,
|
|
619
|
+
cache_creation_input_tokens: left.cacheMiss + right.cacheMiss
|
|
569
620
|
};
|
|
570
621
|
}
|
|
571
622
|
function extractUserInputText(content) {
|
|
@@ -582,14 +633,39 @@ async function runLocalAgentTurn(input) {
|
|
|
582
633
|
throw error;
|
|
583
634
|
}
|
|
584
635
|
const history = input.continueDialogId ? await input.adapter.loadDialogHistory(input.continueDialogId) : [];
|
|
636
|
+
const identityBlock = buildIdentityBlock({
|
|
637
|
+
agentName: agentConfig.name,
|
|
638
|
+
agentId: agentConfig.key,
|
|
639
|
+
model: agentConfig.model
|
|
640
|
+
});
|
|
641
|
+
const agentTools = canonicalizeToolNames(agentConfig.toolNames ?? []);
|
|
642
|
+
const guidanceBlocks = buildRuntimeGuidanceBlocks(agentTools);
|
|
643
|
+
const guidanceScopes = [
|
|
644
|
+
guidanceBlocks.startupProtocol,
|
|
645
|
+
guidanceBlocks.contextLayerContract,
|
|
646
|
+
guidanceBlocks.emailRegistrationWorkflow,
|
|
647
|
+
guidanceBlocks.webResearchToolPolicy
|
|
648
|
+
].map((content) => content.trim()).filter((content) => content.length > 0).map((content) => ({ content, cacheScope: "session" }));
|
|
649
|
+
const currentTimeScope = [
|
|
650
|
+
{ content: buildCurrentTimeBlock(/* @__PURE__ */ new Date(), void 0), cacheScope: "turn" }
|
|
651
|
+
];
|
|
652
|
+
const mergedContextBlockScopes = [
|
|
653
|
+
{ content: identityBlock, cacheScope: "session" },
|
|
654
|
+
...guidanceScopes,
|
|
655
|
+
...currentTimeScope,
|
|
656
|
+
...input.contextBlockScopes ?? []
|
|
657
|
+
];
|
|
585
658
|
const hasContextBlocks = (input.contextBlocks ?? []).some(
|
|
586
659
|
(block) => block.trim()
|
|
660
|
+
) || mergedContextBlockScopes.some(
|
|
661
|
+
(block) => block.content.trim()
|
|
587
662
|
);
|
|
588
663
|
const promptMessageCount = agentConfig.prompt?.trim() || hasContextBlocks ? 1 : 0;
|
|
589
664
|
const turnStartIndex = promptMessageCount + history.length;
|
|
590
665
|
const messages = buildMessages({
|
|
591
666
|
prompt: agentConfig.prompt,
|
|
592
667
|
contextBlocks: input.contextBlocks,
|
|
668
|
+
contextBlockScopes: mergedContextBlockScopes,
|
|
593
669
|
history,
|
|
594
670
|
input: input.input
|
|
595
671
|
});
|
|
@@ -610,8 +686,10 @@ async function runLocalAgentTurn(input) {
|
|
|
610
686
|
let emptyAssistantRepairUsed = false;
|
|
611
687
|
let imageDowngradeNotified = false;
|
|
612
688
|
let skipFinalAppend = false;
|
|
689
|
+
let partialContent = "";
|
|
613
690
|
try {
|
|
614
691
|
while (true) {
|
|
692
|
+
partialContent = "";
|
|
615
693
|
throwIfAborted(input);
|
|
616
694
|
const baseRequestMessages = filterImagePartsFromMessages(
|
|
617
695
|
prepareMessagesForProviderCall(messages),
|
|
@@ -632,7 +710,10 @@ async function runLocalAgentTurn(input) {
|
|
|
632
710
|
messages: requestMessages,
|
|
633
711
|
options: {
|
|
634
712
|
...typeof input.timeoutMs === "number" ? { timeoutMs: input.timeoutMs } : {},
|
|
635
|
-
...input.onTextDelta ? { onTextDelta:
|
|
713
|
+
...input.onTextDelta ? { onTextDelta: (chunk) => {
|
|
714
|
+
partialContent += chunk;
|
|
715
|
+
input.onTextDelta(chunk);
|
|
716
|
+
} } : {},
|
|
636
717
|
...input.onReasoningDelta ? { onReasoningDelta: input.onReasoningDelta } : {},
|
|
637
718
|
...input.onToolEvent ? { onToolEvent: input.onToolEvent } : {},
|
|
638
719
|
...input.onToolEvent ? { toolEventRound: round } : {}
|
|
@@ -779,11 +860,11 @@ async function runLocalAgentTurn(input) {
|
|
|
779
860
|
if (loopError) {
|
|
780
861
|
const errorMessage = toErrorMessage(loopError);
|
|
781
862
|
const turnMessages2 = messages.slice(turnStartIndex);
|
|
782
|
-
await input.adapter.saveTurn({
|
|
863
|
+
const saved2 = await input.adapter.saveTurn({
|
|
783
864
|
agentKey: agentConfig.key,
|
|
784
865
|
messages: turnMessages2,
|
|
785
866
|
result: {
|
|
786
|
-
content: `[nolo] Agent run failed: ${errorMessage}`,
|
|
867
|
+
content: partialContent || `[nolo] Agent run failed: ${errorMessage}`,
|
|
787
868
|
model: agentConfig.model ?? "unknown",
|
|
788
869
|
toolCallCount,
|
|
789
870
|
error: true,
|
|
@@ -796,6 +877,9 @@ async function runLocalAgentTurn(input) {
|
|
|
796
877
|
...input.inheritedFromDialogKey ? { inheritedFromDialogKey: input.inheritedFromDialogKey } : {},
|
|
797
878
|
...input.parentDialogId ? { parentDialogId: input.parentDialogId } : {}
|
|
798
879
|
});
|
|
880
|
+
if (saved2?.dialogId && typeof loopError === "object" && loopError !== null) {
|
|
881
|
+
loopError.dialogId = saved2.dialogId;
|
|
882
|
+
}
|
|
799
883
|
throw loopError;
|
|
800
884
|
}
|
|
801
885
|
result = result;
|
|
@@ -836,89 +920,6 @@ async function runLocalAgentTurn(input) {
|
|
|
836
920
|
};
|
|
837
921
|
}
|
|
838
922
|
|
|
839
|
-
// packages/agent-runtime/thinkTagParser.ts
|
|
840
|
-
var OPEN_TAG = "<think>";
|
|
841
|
-
var CLOSE_TAG = "</think>";
|
|
842
|
-
function longestTagPrefixLength(buffer, tag) {
|
|
843
|
-
const max = Math.min(buffer.length, tag.length - 1);
|
|
844
|
-
for (let len = max; len > 0; len--) {
|
|
845
|
-
if (tag.startsWith(buffer.slice(-len))) {
|
|
846
|
-
return len;
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
return 0;
|
|
850
|
-
}
|
|
851
|
-
function extractThinkContent(content) {
|
|
852
|
-
const regex = new RegExp(`${OPEN_TAG}([\\s\\S]*?)${CLOSE_TAG}`, "g");
|
|
853
|
-
const matches = [...content.matchAll(regex)];
|
|
854
|
-
if (matches.length === 0) {
|
|
855
|
-
return { content };
|
|
856
|
-
}
|
|
857
|
-
const reasoning = matches.map((m) => m[1]).join("\n");
|
|
858
|
-
const cleaned = content.replace(regex, "");
|
|
859
|
-
return { content: cleaned.replace(/^\n/, ""), reasoning };
|
|
860
|
-
}
|
|
861
|
-
function createThinkParserState() {
|
|
862
|
-
return { mode: "content", buffer: "", trimNextVisible: false };
|
|
863
|
-
}
|
|
864
|
-
function processThinkChunk(chunk, state) {
|
|
865
|
-
let visible = "";
|
|
866
|
-
let reasoning = "";
|
|
867
|
-
let { mode, buffer, trimNextVisible } = state;
|
|
868
|
-
buffer += chunk;
|
|
869
|
-
while (true) {
|
|
870
|
-
if (mode === "content") {
|
|
871
|
-
const idx = buffer.indexOf(OPEN_TAG);
|
|
872
|
-
if (idx === -1) {
|
|
873
|
-
const keep = longestTagPrefixLength(buffer, OPEN_TAG);
|
|
874
|
-
visible += buffer.slice(0, buffer.length - keep);
|
|
875
|
-
buffer = buffer.slice(buffer.length - keep);
|
|
876
|
-
break;
|
|
877
|
-
}
|
|
878
|
-
visible += buffer.slice(0, idx);
|
|
879
|
-
buffer = buffer.slice(idx + OPEN_TAG.length);
|
|
880
|
-
mode = "reasoning";
|
|
881
|
-
} else {
|
|
882
|
-
const idx = buffer.indexOf(CLOSE_TAG);
|
|
883
|
-
if (idx === -1) {
|
|
884
|
-
const keep = longestTagPrefixLength(buffer, CLOSE_TAG);
|
|
885
|
-
reasoning += buffer.slice(0, buffer.length - keep);
|
|
886
|
-
buffer = buffer.slice(buffer.length - keep);
|
|
887
|
-
break;
|
|
888
|
-
}
|
|
889
|
-
reasoning += buffer.slice(0, idx);
|
|
890
|
-
buffer = buffer.slice(idx + CLOSE_TAG.length);
|
|
891
|
-
mode = "content";
|
|
892
|
-
trimNextVisible = true;
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
if (mode === "content" && visible.length > 0 && trimNextVisible) {
|
|
896
|
-
visible = visible.replace(/^\n/, "");
|
|
897
|
-
trimNextVisible = false;
|
|
898
|
-
}
|
|
899
|
-
return { content: visible, reasoning, state: { mode, buffer, trimNextVisible } };
|
|
900
|
-
}
|
|
901
|
-
function flushThinkParser(state) {
|
|
902
|
-
const { mode, buffer, trimNextVisible } = state;
|
|
903
|
-
if (mode === "reasoning") {
|
|
904
|
-
return {
|
|
905
|
-
content: "",
|
|
906
|
-
reasoning: buffer,
|
|
907
|
-
state: { mode: "content", buffer: "", trimNextVisible: false }
|
|
908
|
-
};
|
|
909
|
-
}
|
|
910
|
-
let visible = buffer;
|
|
911
|
-
const nextTrim = trimNextVisible;
|
|
912
|
-
if (nextTrim) {
|
|
913
|
-
visible = visible.replace(/^\n/, "");
|
|
914
|
-
}
|
|
915
|
-
return {
|
|
916
|
-
content: visible,
|
|
917
|
-
reasoning: "",
|
|
918
|
-
state: { mode: "content", buffer: "", trimNextVisible: false }
|
|
919
|
-
};
|
|
920
|
-
}
|
|
921
|
-
|
|
922
923
|
export {
|
|
923
924
|
readCommandActionGatePayload,
|
|
924
925
|
readActionGate,
|
|
@@ -928,9 +929,5 @@ export {
|
|
|
928
929
|
LOCAL_AGENT_CONFIG_MISSING_CODE,
|
|
929
930
|
EMPTY_ASSISTANT_REPAIR_PROMPT,
|
|
930
931
|
LOCAL_TURN_ABORTED_CODE,
|
|
931
|
-
runLocalAgentTurn
|
|
932
|
-
extractThinkContent,
|
|
933
|
-
createThinkParserState,
|
|
934
|
-
processThinkChunk,
|
|
935
|
-
flushThinkParser
|
|
932
|
+
runLocalAgentTurn
|
|
936
933
|
};
|