nolo-cli 0.33.0-alpha.9 → 0.34.0-alpha.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-2WR4RTZZ.js → _executeModel-TMUXL7J5.js} +64 -65
- package/{action-OQWPNKAH.js → action-KMBZ3LCZ.js} +12 -12
- package/{addContentAction-YVINZQTF.js → addContentAction-KQ44UT2U.js} +10 -10
- package/{addDialogAgentAction-6IOCIEPI.js → addDialogAgentAction-ILSDCMYL.js} +9 -9
- package/{agentDeleteCommand-H22WRYC6.js → agentDeleteCommand-KA2IQAPG.js} +40 -39
- package/{agentEmailCommands-DGJVCMCG.js → agentEmailCommands-UIYBGCZW.js} +74 -75
- package/{agentListCommands-6NWMLIMQ.js → agentListCommands-L6JNUOLH.js} +47 -37
- package/{agentMachineCommands-5MUO6RDI.js → agentMachineCommands-5CQW5NZR.js} +37 -36
- package/agentProviderCommands-65ZC2WB4.js +122 -0
- package/{agentPullCommand-YH5GEBK4.js → agentPullCommand-TSWAJPS2.js} +1 -1
- package/agentRecordCommands-VUDJQIZH.js +112 -0
- package/agentRunCommand-EJWYF3BL.js +132 -0
- package/{agentRunControl-SCIVRZWX.js → agentRunControl-7MUPSYDQ.js} +7 -1
- package/{agentRuntimeLocal-PRAR3NCW.js → agentRuntimeLocal-XXBMDMBU.js} +33 -33
- package/{agentSlice-AMDSTXP5.js → agentSlice-HTIEYKIU.js} +12 -12
- package/agentSuperviseCommands-MKWW3ICX.js +640 -0
- package/{appDeleteCommands-L5PKC42V.js → appDeleteCommands-OUBL6VHB.js} +35 -34
- package/{appDeployCommands-3J7Z4XWV.js → appDeployCommands-BZSS2MX4.js} +35 -34
- package/{appDeployStatusCommands-YTRPXE72.js → appDeployStatusCommands-P2ZQOY5X.js} +35 -34
- package/{appGetCommands-JVXV5WXD.js → appGetCommands-WCFWQZZM.js} +35 -34
- package/{appListCommands-7KDEOJSO.js → appListCommands-FVJ3QNL7.js} +35 -34
- package/{authCommand-6Y5LTMZB.js → authCommand-B2XRHNJH.js} +19 -19
- package/{authCommands-EAPFGNHN.js → authCommands-GWABTFMR.js} +6 -6
- package/{chatQueueReduxAdapter-ZKSS6XRV.js → chatQueueReduxAdapter-ZP2ZS63U.js} +28 -28
- package/{chunk-UM4H3URE.js → chunk-23KKIMD5.js} +7 -7
- package/chunk-2BWU4ORW.js +2574 -0
- package/{chunk-2UECQ7RE.js → chunk-3AOLVADY.js} +1 -1
- package/{chunk-M2YMQOLC.js → chunk-4APLX2RT.js} +75 -10
- package/{chunk-ZHYK3N56.js → chunk-4AWH4LQA.js} +3 -1
- package/{chunk-3GZXL6FM.js → chunk-4DMPISV6.js} +7 -3
- package/{chunk-BQ3OHLR5.js → chunk-5GQ6XCJY.js} +1217 -691
- package/{chunk-GOIDVXK5.js → chunk-5LDKQUOT.js} +21 -8
- package/{chunk-OIQPORYI.js → chunk-64KIQZA2.js} +175 -2
- package/{chunk-6XIE5ZGI.js → chunk-6HIGYUBQ.js} +1 -1
- package/chunk-6XG52ZQ6.js +146 -0
- package/{chunk-FMEVI5TG.js → chunk-7CH6U3FL.js} +1 -1
- package/chunk-AA2YUJNV.js +54 -0
- package/{chunk-7INB7NXF.js → chunk-AE5GVFMG.js} +294 -54
- package/{chunk-UNOTBWZZ.js → chunk-B6H5XCT2.js} +8 -8
- package/{chunk-NNWHHCVP.js → chunk-BMB563Y6.js} +10 -4
- package/{chunk-DFUPZE6V.js → chunk-C6ELZQ7H.js} +249 -34
- package/{chunk-7KNERA53.js → chunk-E2OQ5N2F.js} +87 -13
- package/{chunk-6HYVJV7B.js → chunk-ESHYE7WU.js} +2 -1
- package/{chunk-KHCLMKZZ.js → chunk-EY7V7REW.js} +280 -6
- package/{chunk-JZPBVBIY.js → chunk-FD36SCCD.js} +19 -8
- package/{chunk-DKMOY3QI.js → chunk-FGLKRJDI.js} +54 -3
- package/{chunk-MQWVAOIU.js → chunk-FT4XBCK4.js} +33 -158
- package/{chunk-2QTEYCR7.js → chunk-FTM4KUOZ.js} +17 -17
- package/{chunk-U4TRT5V4.js → chunk-GEPHJJW4.js} +1 -1
- package/{chunk-7YYHKBJP.js → chunk-GKHV4UH5.js} +1 -1
- package/{chunk-2IVEXF7P.js → chunk-GUYMR3JL.js} +6 -33
- package/{chunk-YDTYDA5W.js → chunk-GZRMWK5R.js} +6 -4
- package/{chunk-X664KVEV.js → chunk-HHBXCRJS.js} +204 -123
- package/{chunk-AN7DGYMW.js → chunk-I7VDDN45.js} +4579 -3131
- package/{chunk-DSBGWT2C.js → chunk-IEEEWIVO.js} +10 -10
- package/{chunk-75U775RZ.js → chunk-IFS5CUEH.js} +1 -1
- package/{chunk-WLH5BAKX.js → chunk-IIOHYLIG.js} +9 -4
- package/{chunk-UEAUAXYS.js → chunk-ILZY5B4U.js} +2063 -214
- package/chunk-IMHO5LC6.js +370 -0
- package/{chunk-ADLYMQB6.js → chunk-IZCHPD7T.js} +52 -3
- package/{chunk-ITIA6OAQ.js → chunk-IZNJDUJ4.js} +5 -5
- package/{chunk-X2DAEZ3X.js → chunk-J5NMOM35.js} +1 -1
- package/{chunk-RPRRIFXV.js → chunk-JI2TIPLP.js} +1 -1
- package/{chunk-EGRJC4ZN.js → chunk-JIADXJYU.js} +1 -1
- package/{chunk-IHEC7VBF.js → chunk-K4KIFRIN.js} +1 -1
- package/{chunk-WJSW43QZ.js → chunk-L3JWI7WX.js} +0 -1
- package/{chunk-3RUW3ONU.js → chunk-LD6Y6RJY.js} +4 -4
- package/chunk-M3JQWYBC.js +387 -0
- package/{chunk-GM6PU7B6.js → chunk-MEYIRKDN.js} +0 -1
- package/{chunk-6YXDOOSH.js → chunk-MGIHZ5CJ.js} +4 -4
- package/{chunk-4F5M2MW5.js → chunk-MJWX4JQO.js} +2 -2
- package/{chunk-Q5ITEGIN.js → chunk-N4XRDM26.js} +1 -1
- package/{chunk-5CS33IBL.js → chunk-NQ4N4IGO.js} +11 -12
- package/{chunk-ZZ2MH7LE.js → chunk-O6OSWFZQ.js} +0 -1
- package/{chunk-RJKIB55Y.js → chunk-OSCSEJJR.js} +15 -8
- package/{chunk-HUCT7HID.js → chunk-P2I7ELDC.js} +3 -3
- package/{chunk-BXPBZVRE.js → chunk-PILJX4DH.js} +285 -251
- package/{chunk-SCUETSRP.js → chunk-PV734VZX.js} +1 -1
- package/{chunk-XLLTJXAD.js → chunk-QI3CHZUT.js} +39 -2672
- package/{chunk-WNHST4IE.js → chunk-RKRXAL3V.js} +5451 -5013
- package/{chunk-7E72JMBB.js → chunk-SMPAUSX5.js} +46 -5
- package/{chunk-5X4GQ53C.js → chunk-TLBZMLLJ.js} +7 -7
- package/{chunk-ASDXPOJH.js → chunk-U6QQLXWI.js} +1 -1
- package/{chunk-NUO3QFWD.js → chunk-UNHKVD2N.js} +1 -1
- package/{chunk-GE6IWA5N.js → chunk-UNZDCI3O.js} +126 -1
- package/{chunk-CPYYM4RJ.js → chunk-V5GA74HI.js} +19 -5
- package/{chunk-FXFGNOT2.js → chunk-VFVCYIRQ.js} +1 -1
- package/{chunk-G7E4NWFE.js → chunk-W445DPVT.js} +1 -1
- package/{chunk-EMW55KKX.js → chunk-WBZE7C6S.js} +1 -1
- package/{chunk-3UG2IIZ3.js → chunk-WN5AJG5I.js} +1 -1
- package/{chunk-KSRFVP36.js → chunk-WRN7L5CS.js} +1 -1
- package/{chunk-GJXRIOLS.js → chunk-WRP5TTM6.js} +4 -84
- package/chunk-X2K2JSO4.js +163 -0
- package/{chunk-OR2HNLVO.js → chunk-X6EN3KJX.js} +279 -477
- package/{chunk-VWY2CZD2.js → chunk-XMFDQYWA.js} +3 -3
- package/{chunk-IKWTTKWG.js → chunk-XQES6LXQ.js} +2 -2
- package/{chunk-IR6W62Q6.js → chunk-XT73C4VH.js} +18 -21
- package/{chunk-7L5CQQIT.js → chunk-Y5W623XU.js} +15 -15
- package/{chunk-RY57GLGW.js → chunk-YPREESF4.js} +42 -5
- package/{chunk-BQXOGBFN.js → chunk-YZ2WE6CW.js} +2 -2
- package/{chunk-DNQK7M7K.js → chunk-Z7COG62J.js} +4 -4
- package/{chunk-3WXRAHCG.js → chunk-ZBB3MZR3.js} +3 -3
- package/{cliExecutor-DW3PHGEL.js → cliExecutor-BBUVQU4L.js} +2 -2
- package/{clipboardy-MMBYVRLF.js → clipboardy-PRUHGPGC.js} +4 -3
- package/{codingSkills-DY5MINPG.js → codingSkills-6F4EQFCM.js} +4 -5
- package/cooldownCommands-C2SZLEEO.js +90 -0
- package/{createAgentAutomationAction-GVSJL2CI.js → createAgentAutomationAction-TGUXUZCY.js} +28 -30
- package/createDialogAction-FD5AEOUF.js +58 -0
- package/{createPageAction-M2VDKBYS.js → createPageAction-NPC3LYNK.js} +31 -34
- package/{dbSlice-UI2VCBLG.js → dbSlice-PIQGICNM.js} +9 -9
- package/{deleteFile-XQXPBFFB.js → deleteFile-NPZ64DFN.js} +4 -4
- package/{dialogCommands-26DBYNBT.js → dialogCommands-ZF2RSNCG.js} +37 -36
- package/{dialogSlice-FFGLRCBL.js → dialogSlice-6BINHWQT.js} +27 -27
- package/dist-VODFSGNG.js +7442 -0
- package/{docCreateCommands-F2ASWG6B.js → docCreateCommands-4VQ5MOHP.js} +36 -36
- package/{docDeleteCommands-A4URDZPI.js → docDeleteCommands-M7WLNVPB.js} +37 -37
- package/{docReadCommands-DO6VHDZD.js → docReadCommands-6LU6P2WT.js} +36 -36
- package/{docStore-EDAE7RNT.js → docStore-SIUFLABN.js} +29 -31
- package/{docUpdateCommands-ZTXZ3RTP.js → docUpdateCommands-S2LX4ENL.js} +39 -39
- package/{fetchMessages-7QRCCRYK.js → fetchMessages-CUEFN4GQ.js} +4 -4
- package/{getPricing-L2ENXWHV.js → getPricing-P3E2WRIH.js} +5 -5
- package/{handleSendMessageAction-CIRLGHOC.js → handleSendMessageAction-QVG5YNZY.js} +29 -29
- package/index.js +92 -77
- package/{localDialogRead-SLMPV5SK.js → localDialogRead-P7CHFMIC.js} +1 -1
- package/{localRuntimeAuthority-E3R24J4T.js → localRuntimeAuthority-S77B5QVB.js} +6 -2
- package/{localRuntimeDb-DDZCJFQZ.js → localRuntimeDb-N3H3HQ7G.js} +1 -1
- package/{machineCommands-NIQNCYJV.js → machineCommands-OSEBN7BZ.js} +76 -77
- package/{machineInfo-M6KB6HZN.js → machineInfo-66ZFUMLE.js} +1 -1
- package/{machineWsRunDispatch-EMTSQGAR.js → machineWsRunDispatch-NTJQCIIF.js} +68 -69
- package/{models-OX2S5C6Q.js → models-L7S2EKPM.js} +2 -2
- package/package.json +1 -1
- package/{read-2VHEHCAN.js → read-6C2XD3YZ.js} +5 -5
- package/{readDocTool-CSWD6NPC.js → readDocTool-Y7AB365O.js} +1 -1
- package/{readlineWorkspace-A2JBJWLI.js → readlineWorkspace-JPME5S7A.js} +4860 -3476
- package/{removeDialogAgentAction-2T7BPM3T.js → removeDialogAgentAction-KG5WMJRZ.js} +13 -13
- package/{runAgentClientLoop-BV4736ED.js → runAgentClientLoop-SOKEXCUF.js} +61 -61
- package/{runtimeDoctorCommands-KIKM6BIO.js → runtimeDoctorCommands-HT4O2PXL.js} +6 -6
- package/{setDialogExtraReferencesAction-GPT37HTW.js → setDialogExtraReferencesAction-O2NLXMSM.js} +10 -10
- package/{setPrimaryDialogAgentAction-3746P7IW.js → setPrimaryDialogAgentAction-FYYUY7PB.js} +13 -13
- package/{settingSlice-FIFOQ6OR.js → settingSlice-GPLI6E3M.js} +11 -11
- package/{skillDiscovery-KLLKXPUO.js → skillDiscovery-GPUDHDTZ.js} +3 -4
- package/{slateUtils-VO2FU36K.js → slateUtils-RIZES3PV.js} +1 -1
- package/{spaceCommands-AYZQHDB3.js → spaceCommands-Z5JLMFFJ.js} +223 -37
- package/{spaceSlice-43BNF22B.js → spaceSlice-Z3BGCLGX.js} +28 -30
- package/{streamAgentChatTurn-OLLRSITV.js → streamAgentChatTurn-INF5RGK4.js} +115 -129
- package/{switchDialogAgentAction-MQTUTQHL.js → switchDialogAgentAction-GH5P6Q3Z.js} +9 -9
- package/{chunk-IDAU4UFS.js → syncMapping-N6RGXGBW.js} +11 -11
- package/{tableCommands-QE47K72R.js → tableCommands-PQUJ55AS.js} +3 -3
- package/{tools-2SI3FXLL.js → tools-ZELMSJZ3.js} +45 -47
- package/{tuiSummaryLlmCaller-EAWQ3IZX.js → tuiSummaryLlmCaller-LH7F2SP7.js} +18 -18
- package/{updateCommands-AK2RDOFR.js → updateCommands-MNDUIKN7.js} +2 -2
- package/{updateDialogTitleAction-YJEQFYOA.js → updateDialogTitleAction-EDUCIB7G.js} +31 -33
- package/agentRecordCommands-YMGKT2WF.js +0 -113
- package/agentRunCommand-LYEMVQJH.js +0 -131
- package/chunk-AETZ7AD6.js +0 -274
- package/chunk-D5JI6VDM.js +0 -1800
- package/chunk-M3JEW6N6.js +0 -193
- package/chunk-ZURFOV5J.js +0 -105
- package/chunk-ZWS6DUHX.js +0 -480
- package/createDialogAction-VVR46Q2A.js +0 -61
- package/syncMapping-RK2MANUX.js +0 -43
- package/{chunk-KMSZPTM6.js → chunk-2WKUUY2E.js} +3 -3
- package/{chunk-CWMSB67P.js → chunk-AGGIDPCZ.js} +0 -0
- package/{chunk-SAQQLJZ5.js → chunk-JDSUTNYY.js} +3 -3
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clearCliLocalRuntimePreparedAgentCache
|
|
3
|
+
} from "./chunk-RKRXAL3V.js";
|
|
1
4
|
import {
|
|
2
5
|
getReadableCliDb
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UNHKVD2N.js";
|
|
4
7
|
import {
|
|
5
8
|
buildCreatedAgentRecord,
|
|
6
9
|
buildUpdatedAgentRecord,
|
|
@@ -9,10 +12,7 @@ import {
|
|
|
9
12
|
resolveAgentRecordFromHybridStore,
|
|
10
13
|
sanitizeAgentRecordForCliOutput,
|
|
11
14
|
writeAgentRecord
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import {
|
|
14
|
-
clearCliLocalRuntimePreparedAgentCache
|
|
15
|
-
} from "./chunk-WNHST4IE.js";
|
|
15
|
+
} from "./chunk-GZRMWK5R.js";
|
|
16
16
|
import {
|
|
17
17
|
resolveCliAgentKeyInput
|
|
18
18
|
} from "./chunk-EKLRRZIN.js";
|
|
@@ -94,7 +94,7 @@ async function runAgentUpdateCommand(args, deps = {}) {
|
|
|
94
94
|
}
|
|
95
95
|
if (!parsed) {
|
|
96
96
|
output.write(
|
|
97
|
-
"Usage: nolo agent update <agent> [--model <id>] [--cli-provider <provider>] [--api-source <source>] [--max-concurrent <n>] [--expires-at <iso>] [--prompt <text> | --prompt-file <path> | --prompt-doc <pageKey>] [--tools <json>] [--copy-provider-from <agent>] [--field key=value]\n".replace("[--field key=value]", `[--handle <name>] [--field key=value] (e.g. --field disabledTools='["exa_search"]' to disable default tools)`)
|
|
97
|
+
"Usage: nolo agent update <agent> [--model <id>] [--cli-provider <provider>] [--api-source <source>] [--max-concurrent <n>] [--expires-at <iso>] [--prompt <text> | --prompt-file <path> | --prompt-doc <pageKey>] [--tools <json>] [--copy-provider-from <agent>] [--name <name>] [--custom-provider-url <url>] [--api-key <key>|--provider-api-key <key>] [--field key=value]\n".replace("[--field key=value]", `[--handle <name>] [--field key=value] (e.g. --field disabledTools='["exa_search"]' to disable default tools)`)
|
|
98
98
|
);
|
|
99
99
|
return args[0] ? 0 : 1;
|
|
100
100
|
}
|
|
@@ -167,7 +167,7 @@ async function runAgentCreateCommand(args, deps = {}) {
|
|
|
167
167
|
}
|
|
168
168
|
if (!parsed) {
|
|
169
169
|
output.write(
|
|
170
|
-
"Usage: nolo agent create <agent> [--model <id>] [--cli-provider <provider>] [--api-source <source>] [--max-concurrent <n>] [--expires-at <iso>] [--prompt <text> | --prompt-file <path> | --prompt-doc <pageKey>] [--tools <json>] [--copy-provider-from <agent>] [--name <name>] [--custom-provider-url <url>] [--provider-api-key <key>] [--field key=value]\n".replace("[--field key=value]", "[--handle <name>] [--field key=value]")
|
|
170
|
+
"Usage: nolo agent create <agent> [--model <id>] [--cli-provider <provider>] [--api-source <source>] [--max-concurrent <n>] [--expires-at <iso>] [--prompt <text> | --prompt-file <path> | --prompt-doc <pageKey>] [--tools <json>] [--copy-provider-from <agent>] [--name <name>] [--custom-provider-url <url>] [--api-key <key>|--provider-api-key <key>] [--verify] [--field key=value]\n".replace("[--field key=value]", "[--handle <name>] [--field key=value]")
|
|
171
171
|
);
|
|
172
172
|
return args[0] ? 0 : 1;
|
|
173
173
|
}
|
|
@@ -210,12 +210,25 @@ async function runAgentCreateCommand(args, deps = {}) {
|
|
|
210
210
|
serverOrigin: built.serverUrl
|
|
211
211
|
});
|
|
212
212
|
clearCliLocalRuntimePreparedAgentCache();
|
|
213
|
+
let verifyResult;
|
|
214
|
+
if (parsed.verify) {
|
|
215
|
+
const { verifyCustomProvider } = await import("./agentProviderCommands-65ZC2WB4.js");
|
|
216
|
+
const rec = built.nextRecord;
|
|
217
|
+
verifyResult = await verifyCustomProvider({
|
|
218
|
+
providerUrl: rec.customProviderUrl,
|
|
219
|
+
apiKey: rec.apiKey,
|
|
220
|
+
model: rec.model,
|
|
221
|
+
prompt: parsed.verifyPrompt,
|
|
222
|
+
fetchImpl
|
|
223
|
+
});
|
|
224
|
+
}
|
|
213
225
|
output.write(JSON.stringify({
|
|
214
226
|
ok: true,
|
|
215
227
|
agentKey: built.agentKey,
|
|
216
228
|
baseUrl: built.serverUrl,
|
|
217
229
|
updates: sanitizeAgentRecordForCliOutput(built.updates),
|
|
218
|
-
record: sanitizeAgentRecordForCliOutput(built.nextRecord)
|
|
230
|
+
record: sanitizeAgentRecordForCliOutput(built.nextRecord),
|
|
231
|
+
...verifyResult ? { verify: verifyResult } : {}
|
|
219
232
|
}, null, 2));
|
|
220
233
|
output.write("\n");
|
|
221
234
|
return 0;
|
|
@@ -1,16 +1,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
findModelConfig,
|
|
3
|
+
getProviderByModelName
|
|
4
|
+
} from "./chunk-C6ELZQ7H.js";
|
|
1
5
|
import {
|
|
2
6
|
asOptionalFiniteNumber
|
|
3
7
|
} from "./chunk-WWC7I6TA.js";
|
|
4
8
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
asTrimmedLowercaseString
|
|
10
|
+
} from "./chunk-QSJ3HFEF.js";
|
|
7
11
|
import {
|
|
8
12
|
isRecord
|
|
9
13
|
} from "./chunk-KUG52IAP.js";
|
|
14
|
+
import {
|
|
15
|
+
asTrimmedString
|
|
16
|
+
} from "./chunk-3EUW3WEO.js";
|
|
10
17
|
import {
|
|
11
18
|
asOptionalTrimmedString
|
|
12
19
|
} from "./chunk-G3SUCT4W.js";
|
|
13
20
|
|
|
21
|
+
// packages/ai/llm/agentCapabilities.ts
|
|
22
|
+
var ANTIGRAVITY_EFFORT_SUFFIXES = [
|
|
23
|
+
"-tiered",
|
|
24
|
+
"-extra-low",
|
|
25
|
+
"-low",
|
|
26
|
+
"-medium",
|
|
27
|
+
"-high"
|
|
28
|
+
];
|
|
29
|
+
function stripEffortSuffix(model) {
|
|
30
|
+
for (const suffix of ANTIGRAVITY_EFFORT_SUFFIXES) {
|
|
31
|
+
if (model.endsWith(suffix) && model.length > suffix.length) {
|
|
32
|
+
return model.slice(0, -suffix.length);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return model;
|
|
36
|
+
}
|
|
37
|
+
function stripPreviewSuffix(model) {
|
|
38
|
+
const suffix = "-preview";
|
|
39
|
+
if (model.endsWith(suffix) && model.length > suffix.length) {
|
|
40
|
+
return model.slice(0, -suffix.length);
|
|
41
|
+
}
|
|
42
|
+
return model;
|
|
43
|
+
}
|
|
44
|
+
var lookupKnownModelVision = (provider, model) => {
|
|
45
|
+
if (!model) return void 0;
|
|
46
|
+
const candidates = [model];
|
|
47
|
+
const strippedEffort = stripEffortSuffix(model);
|
|
48
|
+
if (strippedEffort !== model) candidates.push(strippedEffort);
|
|
49
|
+
const strippedPreview = stripPreviewSuffix(model);
|
|
50
|
+
if (strippedPreview !== model) candidates.push(strippedPreview);
|
|
51
|
+
for (const candidate of candidates) {
|
|
52
|
+
if (provider && provider !== "custom") {
|
|
53
|
+
const direct = findModelConfig(provider, candidate);
|
|
54
|
+
if (direct && typeof direct.hasVision === "boolean") return direct.hasVision;
|
|
55
|
+
}
|
|
56
|
+
const detected = getProviderByModelName(candidate);
|
|
57
|
+
if (detected) {
|
|
58
|
+
const found = findModelConfig(detected, candidate)?.hasVision;
|
|
59
|
+
if (found !== void 0) return found;
|
|
60
|
+
}
|
|
61
|
+
if (candidate.includes("/")) {
|
|
62
|
+
const slash = candidate.indexOf("/");
|
|
63
|
+
const modelProvider = candidate.slice(0, slash).toLowerCase();
|
|
64
|
+
const modelName = candidate.slice(slash + 1);
|
|
65
|
+
const nested = findModelConfig(modelProvider, modelName);
|
|
66
|
+
if (nested && typeof nested.hasVision === "boolean") return nested.hasVision;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return void 0;
|
|
70
|
+
};
|
|
71
|
+
var resolveAgentImageInputSupport = (agent) => {
|
|
72
|
+
if (!agent) return true;
|
|
73
|
+
const provider = asTrimmedLowercaseString(agent.provider) || null;
|
|
74
|
+
const model = asOptionalTrimmedString(agent.model) ?? "";
|
|
75
|
+
const catalogHasVision = lookupKnownModelVision(
|
|
76
|
+
provider,
|
|
77
|
+
model
|
|
78
|
+
);
|
|
79
|
+
if (catalogHasVision !== void 0) {
|
|
80
|
+
return catalogHasVision;
|
|
81
|
+
}
|
|
82
|
+
if (typeof agent.hasVision === "boolean") {
|
|
83
|
+
return agent.hasVision;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// packages/ai/agent/imagePreprocessing.ts
|
|
89
|
+
function extractImageUrlsFromMessages(messages) {
|
|
90
|
+
const urls = [];
|
|
91
|
+
for (const msg of messages) {
|
|
92
|
+
if (!Array.isArray(msg.content)) continue;
|
|
93
|
+
for (const part of msg.content) {
|
|
94
|
+
if (part && typeof part === "object" && part.type === "image_url" && part.image_url && typeof part.image_url.url === "string" && part.image_url.url.trim()) {
|
|
95
|
+
urls.push(part.image_url.url);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return urls;
|
|
100
|
+
}
|
|
101
|
+
function hasImageInRuntimeMessages(messages) {
|
|
102
|
+
return extractImageUrlsFromMessages(messages).length > 0;
|
|
103
|
+
}
|
|
104
|
+
var IMAGE_OMITTED_PLACEHOLDER = "[Image content omitted: model does not support image input]";
|
|
105
|
+
function stripImagePartsFromContent(content) {
|
|
106
|
+
if (!Array.isArray(content)) return content;
|
|
107
|
+
const filtered = content.filter((part) => part?.type !== "image_url");
|
|
108
|
+
if (filtered.length === 0) return IMAGE_OMITTED_PLACEHOLDER;
|
|
109
|
+
return filtered;
|
|
110
|
+
}
|
|
111
|
+
function stripImagePartsFromMessages(messages) {
|
|
112
|
+
return messages.map((msg) => ({
|
|
113
|
+
...msg,
|
|
114
|
+
content: stripImagePartsFromContent(msg.content)
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
117
|
+
async function stripImagePartsForTextOnlyAgent(messages, agentConfig) {
|
|
118
|
+
const supportsVision = resolveAgentImageInputSupport(agentConfig);
|
|
119
|
+
const hasImages = hasImageInRuntimeMessages(messages);
|
|
120
|
+
return { messages: !supportsVision && hasImages ? stripImagePartsFromMessages(messages) : messages };
|
|
121
|
+
}
|
|
122
|
+
|
|
14
123
|
// packages/agent-runtime/agentRecordConfig.ts
|
|
15
124
|
function stringField(record, key) {
|
|
16
125
|
const value = record[key];
|
|
@@ -97,6 +206,60 @@ function resolveAgentRuntimeConfigFromRecord(key, record) {
|
|
|
97
206
|
};
|
|
98
207
|
}
|
|
99
208
|
|
|
209
|
+
// packages/ai/agent/toolOutputPolicy.ts
|
|
210
|
+
var MAX_HISTORICAL_TOOL_CONTENT_CHARS = 1600;
|
|
211
|
+
var MAX_IN_TURN_TOOL_CONTENT_CHARS = 4e3;
|
|
212
|
+
var FRESH_TOOL_OUTPUT_MAX_CHARS = 32e3;
|
|
213
|
+
var DEFAULT_TOOL_OUTPUT_PROFILE = {
|
|
214
|
+
maxChars: MAX_IN_TURN_TOOL_CONTENT_CHARS,
|
|
215
|
+
headRatio: 0.5
|
|
216
|
+
};
|
|
217
|
+
var TOOL_OUTPUT_PROFILES = {
|
|
218
|
+
readFile: { maxChars: 4800, headRatio: 0.68, historicalMaxChars: 4800 },
|
|
219
|
+
read_file: { maxChars: 4800, headRatio: 0.68, historicalMaxChars: 4800 },
|
|
220
|
+
readWorkspaceFile: { maxChars: 4800, headRatio: 0.68, historicalMaxChars: 4800 },
|
|
221
|
+
globFiles: { maxChars: 2800, headRatio: 0.85 },
|
|
222
|
+
execShell: { maxChars: 4e3, headRatio: 0.35 },
|
|
223
|
+
runCommand: { maxChars: 4e3, headRatio: 0.35 },
|
|
224
|
+
launchProcess: { maxChars: 2800, headRatio: 0.35 },
|
|
225
|
+
editFile: { maxChars: 2800, headRatio: 0.62 },
|
|
226
|
+
writeFile: { maxChars: 2400, headRatio: 0.62 },
|
|
227
|
+
readPastedText: { maxChars: 4800, headRatio: 0.5, historicalMaxChars: 4800 }
|
|
228
|
+
};
|
|
229
|
+
function resolveToolOutputProfile(toolName) {
|
|
230
|
+
return (toolName ? TOOL_OUTPUT_PROFILES[toolName] : void 0) ?? DEFAULT_TOOL_OUTPUT_PROFILE;
|
|
231
|
+
}
|
|
232
|
+
function resolveHistoricalToolContentCap(toolName, historicalMaxChars) {
|
|
233
|
+
const profile = toolName ? TOOL_OUTPUT_PROFILES[toolName] : void 0;
|
|
234
|
+
return profile?.historicalMaxChars !== void 0 ? Math.max(historicalMaxChars, profile.historicalMaxChars) : historicalMaxChars;
|
|
235
|
+
}
|
|
236
|
+
function projectToolMessageContent(input) {
|
|
237
|
+
const { content, isFresh, toolName, historicalMaxChars } = input;
|
|
238
|
+
if (isFresh) {
|
|
239
|
+
if (content.length <= FRESH_TOOL_OUTPUT_MAX_CHARS) return content;
|
|
240
|
+
return clipToolText(
|
|
241
|
+
content,
|
|
242
|
+
FRESH_TOOL_OUTPUT_MAX_CHARS,
|
|
243
|
+
resolveToolOutputProfile(toolName).headRatio,
|
|
244
|
+
`
|
|
245
|
+
\u2026[\u622A\u65AD\uFF0C\u539F\u59CB\u957F\u5EA6 ${content.length} \u5B57\u7B26]`
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
const cap = resolveHistoricalToolContentCap(toolName, historicalMaxChars);
|
|
249
|
+
if (content.length <= cap) return content;
|
|
250
|
+
return content.slice(0, cap) + `
|
|
251
|
+
\u2026[\u622A\u65AD\uFF0C\u539F\u59CB\u957F\u5EA6 ${content.length} \u5B57\u7B26]`;
|
|
252
|
+
}
|
|
253
|
+
function clipToolText(content, maxChars, headRatio, marker = "\n\n[... tool output middle omitted; head/tail preserved ...]\n\n") {
|
|
254
|
+
const normalized = content.replace(/\r\n/g, "\n").trim();
|
|
255
|
+
if (normalized.length <= maxChars) return normalized;
|
|
256
|
+
if (maxChars <= marker.length + 2) return normalized.slice(0, maxChars);
|
|
257
|
+
const available = maxChars - marker.length;
|
|
258
|
+
const headChars = Math.max(1, Math.floor(available * headRatio));
|
|
259
|
+
const tailChars = Math.max(1, available - headChars);
|
|
260
|
+
return `${normalized.slice(0, headChars)}${marker}${normalized.slice(-tailChars)}`;
|
|
261
|
+
}
|
|
262
|
+
|
|
100
263
|
// packages/agent-runtime/desktopRequestSnapshot.ts
|
|
101
264
|
var DESKTOP_AGENT_CONFIG_SNAPSHOT_STRING_FIELDS = [
|
|
102
265
|
"name",
|
|
@@ -376,6 +539,16 @@ function assertDesktopAgentRuntimeTurnBodyHasNoRawSecrets(body) {
|
|
|
376
539
|
}
|
|
377
540
|
|
|
378
541
|
export {
|
|
542
|
+
resolveAgentImageInputSupport,
|
|
543
|
+
hasImageInRuntimeMessages,
|
|
544
|
+
stripImagePartsFromMessages,
|
|
545
|
+
stripImagePartsForTextOnlyAgent,
|
|
546
|
+
MAX_HISTORICAL_TOOL_CONTENT_CHARS,
|
|
547
|
+
FRESH_TOOL_OUTPUT_MAX_CHARS,
|
|
548
|
+
resolveToolOutputProfile,
|
|
549
|
+
resolveHistoricalToolContentCap,
|
|
550
|
+
projectToolMessageContent,
|
|
551
|
+
clipToolText,
|
|
379
552
|
resolveAgentRuntimeConfigFromRecord,
|
|
380
553
|
buildDesktopAgentRuntimeAgentConfigSnapshot,
|
|
381
554
|
buildDesktopAgentRuntimeDialogHistorySnapshot,
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mergeAvailabilityDeadline
|
|
3
|
+
} from "./chunk-X2K2JSO4.js";
|
|
4
|
+
|
|
5
|
+
// packages/cli/credentialAvailability.ts
|
|
6
|
+
import { homedir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
9
|
+
var FILE_NAME = "credential-availability.json";
|
|
10
|
+
function resolveNoloHome(env = process.env) {
|
|
11
|
+
return env.NOLO_HOME?.trim() || join(homedir(), ".nolo");
|
|
12
|
+
}
|
|
13
|
+
function resolveCredentialAvailabilityPath(env = process.env) {
|
|
14
|
+
return join(resolveNoloHome(env), FILE_NAME);
|
|
15
|
+
}
|
|
16
|
+
function resolveCredentialKey(agent) {
|
|
17
|
+
if (!agent || typeof agent !== "object") return void 0;
|
|
18
|
+
for (const field of ["apiKeyRef", "credentialRef"]) {
|
|
19
|
+
const value = agent[field];
|
|
20
|
+
if (typeof value === "string") {
|
|
21
|
+
const trimmed = value.trim();
|
|
22
|
+
if (trimmed) return trimmed;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
function parseFile(raw) {
|
|
28
|
+
const parsed = JSON.parse(raw);
|
|
29
|
+
if (!parsed || typeof parsed !== "object") return { entries: {} };
|
|
30
|
+
const entries = parsed.entries;
|
|
31
|
+
if (!entries || typeof entries !== "object") return { entries: {} };
|
|
32
|
+
return { entries };
|
|
33
|
+
}
|
|
34
|
+
async function readCredentialEntries(env = process.env, now = Date.now()) {
|
|
35
|
+
const path = resolveCredentialAvailabilityPath(env);
|
|
36
|
+
let raw;
|
|
37
|
+
try {
|
|
38
|
+
raw = await readFile(path, "utf8");
|
|
39
|
+
} catch {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
let file;
|
|
43
|
+
try {
|
|
44
|
+
file = parseFile(raw);
|
|
45
|
+
} catch {
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
48
|
+
const live = {};
|
|
49
|
+
for (const [key, entry] of Object.entries(file.entries)) {
|
|
50
|
+
const normalized = normalizeEntry(entry);
|
|
51
|
+
if (normalized && normalized.nextAvailableAt > now) {
|
|
52
|
+
live[key] = normalized;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return live;
|
|
56
|
+
}
|
|
57
|
+
function normalizeEntry(entry) {
|
|
58
|
+
if (typeof entry === "number") {
|
|
59
|
+
return Number.isFinite(entry) ? { nextAvailableAt: entry } : void 0;
|
|
60
|
+
}
|
|
61
|
+
if (!entry || typeof entry !== "object") return void 0;
|
|
62
|
+
const at = entry.nextAvailableAt;
|
|
63
|
+
if (typeof at !== "number" || !Number.isFinite(at)) return void 0;
|
|
64
|
+
if ("lastProbeAt" in entry) {
|
|
65
|
+
const probe = entry.lastProbeAt;
|
|
66
|
+
if (typeof probe !== "number" || !Number.isFinite(probe)) return void 0;
|
|
67
|
+
return { nextAvailableAt: at, lastProbeAt: probe };
|
|
68
|
+
}
|
|
69
|
+
return { nextAvailableAt: at };
|
|
70
|
+
}
|
|
71
|
+
async function readCredentialAvailability(env = process.env, now = Date.now()) {
|
|
72
|
+
const entries = await readCredentialEntries(env, now);
|
|
73
|
+
return Object.fromEntries(
|
|
74
|
+
Object.entries(entries).map(([key, entry]) => [key, entry.nextAvailableAt])
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
async function readCredentialEntry(credentialKey, env = process.env, now = Date.now()) {
|
|
78
|
+
if (!credentialKey) return void 0;
|
|
79
|
+
const entries = await readCredentialEntries(env, now);
|
|
80
|
+
return entries[credentialKey];
|
|
81
|
+
}
|
|
82
|
+
async function writeCredentialAvailability(live, env = process.env) {
|
|
83
|
+
const path = resolveCredentialAvailabilityPath(env);
|
|
84
|
+
await mkdir(resolveNoloHome(env), { recursive: true }).catch(() => void 0);
|
|
85
|
+
const file = {
|
|
86
|
+
entries: live
|
|
87
|
+
};
|
|
88
|
+
const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;
|
|
89
|
+
await writeFile(tmp, `${JSON.stringify(file, null, 2)}
|
|
90
|
+
`, "utf8");
|
|
91
|
+
await rename(tmp, path);
|
|
92
|
+
}
|
|
93
|
+
async function markCredentialUnavailable(credentialKey, nextAvailableAt, env = process.env, now = Date.now()) {
|
|
94
|
+
if (!credentialKey) return;
|
|
95
|
+
const live = await readCredentialEntries(env, now);
|
|
96
|
+
const existing = live[credentialKey];
|
|
97
|
+
const merged = mergeAvailabilityDeadline(existing?.nextAvailableAt, nextAvailableAt);
|
|
98
|
+
if (typeof merged !== "number" || !Number.isFinite(merged)) return;
|
|
99
|
+
live[credentialKey] = {
|
|
100
|
+
nextAvailableAt: merged,
|
|
101
|
+
...existing?.lastProbeAt !== void 0 ? { lastProbeAt: existing.lastProbeAt } : {}
|
|
102
|
+
};
|
|
103
|
+
await writeCredentialAvailability(live, env);
|
|
104
|
+
}
|
|
105
|
+
async function clearCredentialAvailability(credentialKey, env = process.env, now = Date.now()) {
|
|
106
|
+
if (!credentialKey) return;
|
|
107
|
+
const live = await readCredentialEntries(env, now);
|
|
108
|
+
if (!(credentialKey in live)) return;
|
|
109
|
+
delete live[credentialKey];
|
|
110
|
+
await writeCredentialAvailability(live, env);
|
|
111
|
+
}
|
|
112
|
+
async function recordCredentialProbe(credentialKey, env = process.env, now = Date.now()) {
|
|
113
|
+
if (!credentialKey) return;
|
|
114
|
+
const live = await readCredentialEntries(env, now);
|
|
115
|
+
const existing = live[credentialKey];
|
|
116
|
+
if (!existing) return;
|
|
117
|
+
live[credentialKey] = { ...existing, lastProbeAt: now };
|
|
118
|
+
await writeCredentialAvailability(live, env);
|
|
119
|
+
}
|
|
120
|
+
function applyCredentialAvailability(agents, credentialAvailability) {
|
|
121
|
+
if (Object.keys(credentialAvailability).length === 0) return agents;
|
|
122
|
+
return agents.map((agent) => {
|
|
123
|
+
const key = resolveCredentialKey(agent);
|
|
124
|
+
if (!key) return agent;
|
|
125
|
+
const at = credentialAvailability[key];
|
|
126
|
+
if (typeof at !== "number") return agent;
|
|
127
|
+
const merged = mergeAvailabilityDeadline(
|
|
128
|
+
agent.nextAvailableAt,
|
|
129
|
+
at
|
|
130
|
+
);
|
|
131
|
+
if (typeof merged !== "number" || merged === agent.nextAvailableAt) {
|
|
132
|
+
return agent;
|
|
133
|
+
}
|
|
134
|
+
return { ...agent, nextAvailableAt: merged };
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export {
|
|
139
|
+
resolveCredentialKey,
|
|
140
|
+
readCredentialAvailability,
|
|
141
|
+
readCredentialEntry,
|
|
142
|
+
markCredentialUnavailable,
|
|
143
|
+
clearCredentialAvailability,
|
|
144
|
+
recordCredentialProbe,
|
|
145
|
+
applyCredentialAvailability
|
|
146
|
+
};
|
|
@@ -81,7 +81,7 @@ var MEMORY_USE_GUIDANCE = `--- \u8BB0\u5FC6\u4F7F\u7528\u65B9\u5F0F ---
|
|
|
81
81
|
- \u63A8\u65AD\u578B\u8BB0\u5FC6\uFF08inferred\uFF09\u53EA\u7528\u4E8E\u628A\u63E1\u8BED\u6C14\u3001\u72B6\u6001\u548C\u672A\u5B8C\u6210\u4E8B\u9879\uFF0C\u4E0D\u8981\u8BF4\u6210\u201C\u4F60\u660E\u786E\u544A\u8BC9\u8FC7\u6211\u201D\u6216\u5F53\u6210\u7528\u6237\u5DF2\u6388\u6743\u4FDD\u5B58\u7684\u4E8B\u5B9E\u3002\u51B2\u7A81\u6216\u573A\u666F\u4E0D\u660E\u65F6\u8BF4\u660E\u4F9D\u636E\u6216\u7B80\u77ED\u786E\u8BA4\uFF0C\u4E0D\u8981\u786C\u5957\u3002
|
|
82
82
|
- \u3010\u7F6E\u4FE1\u5EA6\u6765\u6E90\u3011\u6BCF\u6761\u8BB0\u5FC6\u6709\u6765\u6E90\uFF1Averified\uFF08\u5B9E\u6D4B\u9A8C\u8BC1\uFF0C\u9AD8\u7F6E\u4FE1\u5EA6\uFF09\u3001stated\uFF08\u7528\u6237\u9648\u8FF0\uFF0C\u4E2D\u9AD8\uFF09\u3001inferred\uFF08\u6A21\u578B\u63A8\u65AD\uFF0C\u4F4E\u2014\u2014\u5BB9\u6613\u7F16\u9020\uFF0C\u4F18\u5148\u5B58\u7591\uFF09\u3002\u53EC\u56DE\u65F6\u4F18\u5148\u4F7F\u7528 verified/stated\uFF0Cinferred \u9700\u9A8C\u8BC1\u540E\u518D\u91C7\u7EB3\u3002
|
|
83
83
|
- \u3010\u53EC\u56DE\u89C4\u5219\u3011\u53EC\u56DE\u8BB0\u5FC6\u5FC5\u987B\u5E26\u5B8C\u6574\u5386\u53F2\u4E0A\u4E0B\u6587\uFF08\u6765\u6E90\u3001\u7F6E\u4FE1\u5EA6\u3001\u53D8\u66F4\u8BB0\u5F55\uFF09\uFF0C\u7981\u6B62\u81EA\u884C\u63A8\u7406\u586B\u8865\u3002\u4E0D\u8981\u51ED\u5370\u8C61\u62FC\u51FA\u672A\u9A8C\u8BC1\u7684\u4FE1\u606F\u3002
|
|
84
|
-
- \u3010\u964D\u6743
|
|
84
|
+
- \u3010\u964D\u6743\u4E0E\u5220\u9664\u3011\u65E5\u5E38\u9519\u8BEF\u8BB0\u5FC6\u4F18\u5148\u964D\u6743/\u5F52\u6863\u4E0E\u8986\u76D6\uFF08\u964D\u4F4E\u7F6E\u4FE1\u5EA6\uFF09\uFF0C\u4FDD\u7559\u6863\u6848\u4F9B\u5BA1\u8BA1\uFF1B\u82E5\u7528\u6237\u660E\u786E/\u5F3A\u5236\u8981\u6C42\u5220\u9664\uFF0C\u4E14\u5728\u7528\u6237\u81EA\u8EAB\u6743\u9650\u8303\u56F4\u5185\uFF0C\u5141\u8BB8\u7269\u7406\u5220\u9664\uFF08\u4EC5\u9650\u4E8E\u5F53\u524D\u7528\u6237\u62E5\u6709\u7684\u8BB0\u5FC6\uFF0C\u4E25\u7981\u8D8A\u6743\uFF09\u3002`;
|
|
85
85
|
|
|
86
86
|
export {
|
|
87
87
|
buildUserResponseLanguageContext,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// packages/agent-runtime/emptyAssistantRepair.ts
|
|
2
|
+
var EMPTY_ASSISTANT_REPAIR_PROMPT = "\u8BF7\u7ED9\u51FA\u660E\u786E\u7684\u6587\u5B57\u56DE\u7B54\u6216\u6267\u884C\u4E0B\u4E00\u6B65\uFF1A\u5982\u679C\u4EFB\u52A1\u5DF2\u5B8C\u6210\uFF0C\u8BF7\u76F4\u63A5\u603B\u7ED3\u7ED3\u679C\uFF1B\u5982\u679C\u9700\u8981\u8C03\u7528\u5DE5\u5177\uFF0C\u8BF7\u76F4\u63A5\u8F93\u51FA tool_calls\u3002\u8BF7\u5207\u52FF\u8FD4\u56DE\u7A7A\u5185\u5BB9\u3002";
|
|
3
|
+
var EMPTY_ASSISTANT_FALLBACK_MESSAGE = "\u6A21\u578B\u8FDE\u7EED\u8FD4\u56DE\u7A7A\u6D88\u606F\uFF0C\u5F53\u524D\u4EFB\u52A1\u672A\u5B8C\u6210\u3002\u8BF7\u91CD\u8BD5\u5F53\u524D\u6B65\u9AA4\uFF0C\u6216\u7ED9\u51FA\u66F4\u5177\u4F53\u7684\u4FEE\u6539\u8303\u56F4\u3002";
|
|
4
|
+
var LENGTH_TRUNCATED_FALLBACK_MESSAGE = "\u8F93\u51FA\u8FBE\u5230\u957F\u5EA6\u4E0A\u9650\u88AB\u622A\u65AD\uFF0C\u5EFA\u8BAE\u7F29\u77ED\u4EFB\u52A1\u6216\u63D0\u9AD8\u8F93\u51FA\u4E0A\u9650\u3002";
|
|
5
|
+
var STREAM_TRUNCATED_FALLBACK_MESSAGE = "\u4E0A\u6E38\u54CD\u5E94\u6D41\u5728\u6536\u5C3E\u524D\u88AB\u4E2D\u65AD\uFF08\u672A\u6536\u5230\u7ED3\u675F\u6807\u8BB0\uFF09\uFF0C\u672C\u8F6E\u8F93\u51FA\u4E0D\u5B8C\u6574\u3002\u8BF7\u91CD\u8BD5\u5F53\u524D\u6B65\u9AA4\u3002";
|
|
6
|
+
var MAX_REASONING_ONLY_REPAIRS = 2;
|
|
7
|
+
function resolveEmptyAssistantOutcome(args) {
|
|
8
|
+
if (args.hasToolCalls || args.hasVisibleOutput) return { kind: "ok" };
|
|
9
|
+
if (args.finishReason === "length") return { kind: "fallback", reason: "length_truncated" };
|
|
10
|
+
if (!args.finishReason && !args.streamComplete) {
|
|
11
|
+
if (!args.repairUsed) return { kind: "repair" };
|
|
12
|
+
return { kind: "fallback", reason: "stream_truncated" };
|
|
13
|
+
}
|
|
14
|
+
if (args.hasReasoning && (args.reasoningRepairCount ?? 0) < MAX_REASONING_ONLY_REPAIRS) {
|
|
15
|
+
return { kind: "repair" };
|
|
16
|
+
}
|
|
17
|
+
if (!args.repairUsed) return { kind: "repair" };
|
|
18
|
+
return { kind: "fallback", reason: "empty_completion" };
|
|
19
|
+
}
|
|
20
|
+
function resolveEmptyAssistantFallbackMessage(reason) {
|
|
21
|
+
if (reason === "length_truncated") return LENGTH_TRUNCATED_FALLBACK_MESSAGE;
|
|
22
|
+
if (reason === "stream_truncated") return STREAM_TRUNCATED_FALLBACK_MESSAGE;
|
|
23
|
+
return EMPTY_ASSISTANT_FALLBACK_MESSAGE;
|
|
24
|
+
}
|
|
25
|
+
function hasAssistantVisibleOutput(content) {
|
|
26
|
+
if (typeof content === "string") return content.trim().length > 0;
|
|
27
|
+
if (!Array.isArray(content)) return false;
|
|
28
|
+
return content.some((part) => {
|
|
29
|
+
if (part?.type === "text" && String(part.text ?? "").trim()) return true;
|
|
30
|
+
if (part?.type === "image_url") {
|
|
31
|
+
const url = part?.image_url?.url;
|
|
32
|
+
return typeof url === "string" && url.trim().length > 0;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
var LENGTH_TRUNCATED_REASONING_MARKER = "[length_truncated_reasoning_tail]";
|
|
38
|
+
var MAX_TRUNCATED_REASONING_CHARS = 2e3;
|
|
39
|
+
function formatLengthTruncatedReasoningTail(reasoning_content, maxChars = MAX_TRUNCATED_REASONING_CHARS) {
|
|
40
|
+
if (typeof reasoning_content !== "string") return null;
|
|
41
|
+
const trimmed = reasoning_content.trim();
|
|
42
|
+
if (trimmed.length === 0) return null;
|
|
43
|
+
const tail = trimmed.length > maxChars ? trimmed.slice(-maxChars) : trimmed;
|
|
44
|
+
return `[nolo] ${LENGTH_TRUNCATED_REASONING_MARKER}
|
|
45
|
+
${tail}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
EMPTY_ASSISTANT_REPAIR_PROMPT,
|
|
50
|
+
resolveEmptyAssistantOutcome,
|
|
51
|
+
resolveEmptyAssistantFallbackMessage,
|
|
52
|
+
hasAssistantVisibleOutput,
|
|
53
|
+
formatLengthTruncatedReasoningTail
|
|
54
|
+
};
|