nolo-cli 0.92.0-alpha.1 → 0.92.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/README.md +1 -1
- package/{_executeModel-SKXPDRHT.js → _executeModel-SCZL7EYW.js} +63 -61
- package/{action-5DATYWOM.js → action-3ZOODRBC.js} +11 -11
- package/{addContentAction-5OLTVWIE.js → addContentAction-IJHG2ZV7.js} +9 -9
- package/{addDialogAgentAction-BRGMORV4.js → addDialogAgentAction-IGFS2UBX.js} +11 -11
- package/{agentDeleteCommand-KIJCEDIQ.js → agentDeleteCommand-CTZYXUBY.js} +45 -43
- package/{agentEmailCommands-KVJQBG6I.js → agentEmailCommands-M4RKRMV5.js} +84 -79
- package/{agentGrantCommands-YW6PQAQ2.js → agentGrantCommands-M3XFO6EN.js} +2 -2
- package/{agentListCommands-S2WK34WE.js → agentListCommands-QWBMMYNO.js} +74 -81
- package/{agentMachineCommands-ESEVMWBG.js → agentMachineCommands-CFGNRGKC.js} +39 -37
- package/{agentProviderCommands-I26OTLEQ.js → agentProviderCommands-TWB6E5WD.js} +1 -1
- package/{agentPullCommand-GLOOXJ2E.js → agentPullCommand-HF4A42D4.js} +3 -3
- package/agentRecordCommands-ZTUVMJOZ.js +131 -0
- package/{agentRunCommand-PQ2D3MTU.js → agentRunCommand-NARA7GSD.js} +82 -76
- package/{agentRunControl-XLGD3UZ5.js → agentRunControl-AVJR4JW4.js} +2 -2
- package/{agentRuntimeLocal-ZLZCZO3C.js → agentRuntimeLocal-OKYH7XBH.js} +40 -34
- package/{agentSlice-JF7MQKXG.js → agentSlice-L6BEWT2Q.js} +11 -11
- package/{appDeleteCommands-KHSC6H42.js → appDeleteCommands-2D2R56YU.js} +39 -37
- package/{appDeployCommands-KCCU76AG.js → appDeployCommands-R5PAA5YI.js} +39 -37
- package/{appDeployStatusCommands-UBGX7463.js → appDeployStatusCommands-VHTBTS3W.js} +39 -37
- package/{appGetCommands-CGVGNM5J.js → appGetCommands-G35QG2QG.js} +39 -37
- package/{appListCommands-JUVQUOGH.js → appListCommands-YQ2PKESX.js} +39 -37
- package/{authCommand-ETL233F2.js → authCommand-W6I6GD3F.js} +115 -23
- package/{authCommands-RGOGCPP6.js → authCommands-GBIFZWD3.js} +5 -5
- package/{builtinSkillRegistry-PJU2R6ST.js → builtinSkillRegistry-XG6RUDWO.js} +9 -8
- package/{chatQueueReduxAdapter-NIJ6XFDN.js → chatQueueReduxAdapter-OINFB5SN.js} +29 -29
- package/{chromeCommands-FZYAU75D.js → chromeCommands-K27J4OVZ.js} +124 -28
- package/{chromeOpsCommands-62P2Q2YB.js → chromeOpsCommands-IXRLN57H.js} +4 -3
- package/{chunk-UYJKSCJ4.js → chunk-27ONFIEY.js} +22 -4
- package/{chunk-2HBFQM4C.js → chunk-2QX2MTNK.js} +25 -6
- package/{chunk-JEDZAO7L.js → chunk-2SYTUTLI.js} +257 -37
- package/{chunk-QTV7ZYBE.js → chunk-3BXNTXYI.js} +310 -136
- package/{chunk-6R425QS6.js → chunk-3IYMTWYZ.js} +22 -22
- package/{chunk-NTW5GWDM.js → chunk-3VNWWVKB.js} +2 -0
- package/{chunk-PNBZBDRM.js → chunk-4DPP773Q.js} +2 -2
- package/chunk-5J3PYNUP.js +255 -0
- package/{chunk-JPGCXHNM.js → chunk-5OA5HMTL.js} +1 -1
- package/{chunk-CDS4FQMP.js → chunk-5RUECWE2.js} +165 -15
- package/{chunk-DWUCB2A3.js → chunk-62IL3KQV.js} +4 -34
- package/{chunk-ZIK2FIX4.js → chunk-66MWFK6R.js} +9 -9
- package/{chunk-6YTOJY35.js → chunk-6D2JFXLY.js} +35 -0
- package/{chunk-3BMYXEUW.js → chunk-6O4IK4V2.js} +1 -1
- package/{chunk-NNJ4EAEH.js → chunk-6PPDYAMH.js} +7517 -1091
- package/{chunk-I2MX6JST.js → chunk-7KVZ5LDQ.js} +2 -2
- package/{chunk-Q554LLSI.js → chunk-AUDNYVRC.js} +1 -1
- package/{chunk-UKWGR5SS.js → chunk-AUXHZ2M5.js} +186 -397
- package/{chunk-TLPTMSX3.js → chunk-AVKLJP6J.js} +94 -94
- package/{chunk-5NHGLCPL.js → chunk-AZRHIN5B.js} +1 -1
- package/{chunk-5LRIZC2W.js → chunk-B7ANJQWZ.js} +2 -2
- package/{chunk-3QC3NGWZ.js → chunk-BDHW7EBD.js} +4 -4
- package/{chunk-HNUNYXYB.js → chunk-BJUDYFV5.js} +10 -2
- package/chunk-BMQ2MJUK.js +153 -0
- package/{chunk-3JIXYIXV.js → chunk-BNGW5ASC.js} +12 -2
- package/{chunk-2D6QK26I.js → chunk-BPCPBG2O.js} +16 -16
- package/{chunk-SATOEEL6.js → chunk-BTSYHR7J.js} +4 -4
- package/{chunk-4B3TDK3S.js → chunk-CCOXTK3I.js} +30 -7
- package/{chunk-LS2ZANRJ.js → chunk-CTUQJVQM.js} +1 -1
- package/{chunk-43WRG6QQ.js → chunk-CUBJUVQS.js} +13 -13
- package/chunk-CYSYR67N.js +93 -0
- package/{chunk-PIOIPOSY.js → chunk-D76D3RTR.js} +2 -2
- package/{chunk-HQCSU3DI.js → chunk-DCLMZ5TX.js} +4 -4
- package/{chunk-UT5NALV3.js → chunk-EFZKILX6.js} +4 -4
- package/{chunk-2L3O7RDP.js → chunk-EMBK4B7D.js} +9 -4
- package/{chunk-HVURBGF3.js → chunk-ESRMFY7G.js} +2 -2
- package/{chunk-ABQYVJBJ.js → chunk-ETZWFV6M.js} +1 -1
- package/{chunk-TRV2MIDW.js → chunk-EXAJ6DCR.js} +1 -0
- package/{chunk-RAYTIPJ5.js → chunk-F64B2W3R.js} +110 -34
- package/{chunk-S6SP3GWJ.js → chunk-FIZ5TAVE.js} +1 -1
- package/{chunk-MOH3ETXO.js → chunk-GA77XY7N.js} +542 -447
- package/{chunk-2WHQZTB7.js → chunk-GMVELWJG.js} +3 -3
- package/chunk-GMZLP5DV.js +82 -0
- package/{chunk-CJCJF5XB.js → chunk-H6A6X4EK.js} +36 -3
- package/{chunk-ONXOABJR.js → chunk-HNGRBWYF.js} +3 -0
- package/{chunk-46TSVHGZ.js → chunk-HNRASX3X.js} +8 -8
- package/{chunk-CPH3W5A7.js → chunk-I3TQJXQ7.js} +94 -3
- package/{chunk-TZB6Y4OD.js → chunk-IBQ6NJI4.js} +34 -20
- package/{chunk-IP2RNQU3.js → chunk-LNPYTNMG.js} +9 -5
- package/{chunk-TLO2X5C6.js → chunk-LNUOUGIY.js} +1 -1
- package/{chunk-GII32WZW.js → chunk-M2EJHDJP.js} +3 -0
- package/{chunk-G3V74DVM.js → chunk-MV26343G.js} +75 -18
- package/{chunk-7S4YWN7P.js → chunk-MX574M24.js} +1 -1
- package/{chunk-U7HSBX3I.js → chunk-O26PCYLS.js} +80 -13
- package/chunk-OCZKATRC.js +129 -0
- package/{chunk-YNI45YOE.js → chunk-P4U2QMT5.js} +65 -37
- package/chunk-P6GMCCAT.js +870 -0
- package/{chunk-YQPWX5EE.js → chunk-PEXU23PJ.js} +23 -76
- package/{chunk-7GDFU22A.js → chunk-PHINMJJZ.js} +983 -226
- package/{chunk-YC2MP5NP.js → chunk-Q3SKC2TQ.js} +7 -7
- package/{chunk-NU2SOATM.js → chunk-Q7JFHTQT.js} +3 -3
- package/{chunk-YNNVVLMV.js → chunk-QALRKMHF.js} +11 -10
- package/{chunk-T67757YH.js → chunk-QDSINZM3.js} +1 -1
- package/{chunk-TUEPUNFO.js → chunk-QJLEMM2V.js} +1 -1
- package/{chunk-FEAPBZQW.js → chunk-QL32RJFG.js} +98 -22
- package/{chunk-EONDQISD.js → chunk-QMQBSKUP.js} +886 -154
- package/{chunk-BJ7HBUL2.js → chunk-QZYL5UNG.js} +1003 -1041
- package/{chunk-YDEMAQEY.js → chunk-R4SQ3LGW.js} +1 -1
- package/{chunk-TSD5BVVP.js → chunk-RESDFLXS.js} +13 -13
- package/{chunk-ZKYHTHNE.js → chunk-S5XGT6GB.js} +5 -3
- package/{chunk-SAFZABH7.js → chunk-SV5IJK6K.js} +1 -1
- package/{chunk-W6MEYAGX.js → chunk-TC6TTNZW.js} +45 -45
- package/{chunk-BYMV6QZG.js → chunk-TNIX77YM.js} +4 -0
- package/{chunk-S46FYEWL.js → chunk-U7ZDIW37.js} +1 -1
- package/chunk-UNYJU5L6.js +780 -0
- package/{chunk-VUHXTHIK.js → chunk-V2AB7ULS.js} +5 -5
- package/{chunk-QFMFJZLO.js → chunk-V7E4PXQD.js} +1 -1
- package/chunk-VJVNU77E.js +83 -0
- package/{chunk-6D6VBVEW.js → chunk-VPFEPRME.js} +9 -9
- package/{chunk-EKXNV6EM.js → chunk-X5VY2LEV.js} +2 -2
- package/{chunk-O6OSWFZQ.js → chunk-XUWRURDF.js} +6 -0
- package/{chunk-Q67DOFOO.js → chunk-Y3PMXGLH.js} +2 -0
- package/{chunk-IMCXPAQV.js → chunk-YFIUVDQY.js} +6 -83
- package/{chunk-FZGV4FGK.js → chunk-YRRASA5Q.js} +268 -143
- package/{chunk-SH43IESU.js → chunk-YUNJN43V.js} +44 -9
- package/{chunk-2F7RJC6L.js → chunk-ZOVKKMF6.js} +1 -1
- package/commandRegistry-T4PY3XBY.js +833 -0
- package/{contentThunks-N7MGBLZJ.js → contentThunks-7SBK3Y7B.js} +29 -29
- package/{cooldownCommands-BSCH2W7P.js → cooldownCommands-ZLEPIB4A.js} +2 -2
- package/{createAgentAutomationAction-DNOR2HPB.js → createAgentAutomationAction-NPD23L7Y.js} +29 -29
- package/{createDialogAction-Y5CTGDHJ.js → createDialogAction-2JVPW2WV.js} +33 -32
- package/{createPageAction-HIQCWUNG.js → createPageAction-UUIPRGHK.js} +35 -35
- package/{dbSlice-NP52Y5TF.js → dbSlice-HFPIJT5P.js} +8 -8
- package/{deleteFile-YG6QMJLU.js → deleteFile-UEAD5A5Z.js} +3 -3
- package/{dialogCommands-RDCQ2IFS.js → dialogCommands-7JXIBGPD.js} +42 -40
- package/{dialogSlice-CCADNU4F.js → dialogSlice-Q2QUTMHK.js} +35 -29
- package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
- package/{docCreateCommands-7BQO7QFJ.js → docCreateCommands-2JDSCRGB.js} +41 -39
- package/{docDeleteCommands-AXWDDTVX.js → docDeleteCommands-Y4XRBWKE.js} +41 -39
- package/{docReadCommands-NMDWZKZW.js → docReadCommands-35FY3PYU.js} +40 -38
- package/{docStore-RSIMI5PS.js → docStore-FWQIXF33.js} +9 -9
- package/{docUpdateCommands-KFIRA6WM.js → docUpdateCommands-MT7YKSP7.js} +41 -39
- package/{fetchMessages-EIU7UFFK.js → fetchMessages-67MEFPZR.js} +2 -2
- package/{getPricing-SLZYHJXY.js → getPricing-NMMFT3YI.js} +3 -3
- package/{handleSendMessageAction-ZIABBL3A.js → handleSendMessageAction-W33QLNXQ.js} +85 -82
- package/index.js +87 -884
- package/{localDialogRead-BTFJ4V2I.js → localDialogRead-EBRS242U.js} +2 -2
- package/{localRuntimeAuthority-6IR6BBXE.js → localRuntimeAuthority-5W6IJRAD.js} +6 -6
- package/{localRuntimeDb-SYQGUF4U.js → localRuntimeDb-3LRMNLCM.js} +1 -1
- package/{machineCommands-H6TGKZYD.js → machineCommands-HLEUUEKS.js} +77 -72
- package/{machineWsRunDispatch-YU4MGUB5.js → machineWsRunDispatch-DWBXW7XY.js} +75 -70
- package/{memberThunks-XJFHFZ5M.js → memberThunks-SKFZ37VS.js} +9 -9
- package/{models-WYXEJZAX.js → models-ZPU5EDF4.js} +2 -2
- package/oauthTokenStore-ITEB663N.js +23 -0
- package/{offlineMarxistsAgentCommand-JEWCIAWM.js → offlineMarxistsAgentCommand-HGXZV4XJ.js} +1 -1
- package/package.json +1 -1
- package/pdf-U6KSUEZZ.js +26435 -0
- package/processSpawn-SOAV3FEV.js +11 -0
- package/profileConfig-ZGOFORWV.js +43 -0
- package/{providerPresetApply-RWISXOW7.js → providerPresetApply-XTEXOH7X.js} +7 -7
- package/{providerRegistry-5KY7YV6K.js → providerRegistry-ADYDSLKR.js} +7 -7
- package/{read-KFAALANF.js → read-IEJLLUXY.js} +5 -5
- package/{readDocTool-XNMCT64I.js → readDocTool-4SPYCP2Y.js} +5 -3
- package/{readlineWorkspace-JTU5LTZI.js → readlineWorkspace-32ILQXZJ.js} +2398 -2019
- package/{removeDialogAgentAction-X3IS7JNU.js → removeDialogAgentAction-LILXTOQY.js} +14 -14
- package/{runAgentClientLoop-5TPQBYB6.js → runAgentClientLoop-MSCR5Y3E.js} +57 -56
- package/{runtimeDoctorCommands-X6WDBEQX.js → runtimeDoctorCommands-3USD722U.js} +3 -3
- package/runtimeModeArgs-2Y7BALTO.js +31 -0
- package/{setDialogExtraReferencesAction-QTV3ZJNH.js → setDialogExtraReferencesAction-LVNHLNT5.js} +10 -10
- package/{setPrimaryDialogAgentAction-EUUISNQ2.js → setPrimaryDialogAgentAction-DCKO5NTW.js} +14 -14
- package/{settingSlice-UMATY3PD.js → settingSlice-CNE75ISY.js} +10 -10
- package/{spaceCommands-PR6QHSEG.js → spaceCommands-UYWX63IP.js} +41 -39
- package/{streamAgentChatTurn-TXMNTXML.js → streamAgentChatTurn-73OAEDOJ.js} +146 -85
- package/{switchDialogAgentAction-HWFDQNY5.js → switchDialogAgentAction-JSYUQ5CG.js} +11 -11
- package/{tableCommands-O6NWHFKV.js → tableCommands-G7RV3RU3.js} +4 -4
- package/{toolApiClient-7PSIFQPJ.js → toolApiClient-INIQCPGY.js} +3 -3
- package/{tools-GEVUKUVY.js → tools-6IUC3EFI.js} +51 -50
- package/{tuiSummaryLlmCaller-PKZYGY3B.js → tuiSummaryLlmCaller-RVWN63CP.js} +16 -15
- package/{updateCommands-2M74UL7P.js → updateCommands-4EHDLF5J.js} +3 -3
- package/{updateDialogTitleAction-MFR3UGL5.js → updateDialogTitleAction-KCAY2OZF.js} +32 -32
- package/agentRecordCommands-TTYG2GYM.js +0 -126
- package/chunk-DMFLXNFM.js +0 -79
- package/chunk-Q5FJJ6XI.js +0 -103
- package/chunk-S7Z2HMCN.js +0 -25
- package/{chunk-VMFTFOWF.js → chunk-3AH7LNUB.js} +7 -7
- package/{chunk-X7HHHIOZ.js → chunk-Y6ROFCZO.js} +0 -0
- package/{db-WK5MDZVN.js → db-VQSAOWAO.js} +1 -1
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
listUserRecordsFromServers,
|
|
3
3
|
readLiveDbRecordAfterTombstoneMerge
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LNUOUGIY.js";
|
|
5
5
|
import {
|
|
6
6
|
agentRecordHasConfiguredCredential
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-IBQ6NJI4.js";
|
|
8
8
|
import {
|
|
9
|
-
deriveCredentialGroup
|
|
10
|
-
|
|
11
|
-
} from "./chunk-CDS4FQMP.js";
|
|
9
|
+
deriveCredentialGroup
|
|
10
|
+
} from "./chunk-5RUECWE2.js";
|
|
12
11
|
import {
|
|
13
12
|
PUBLIC_AGENT_KEY_PREFIX,
|
|
14
|
-
isOwnedAgentKey,
|
|
15
13
|
ownedAgentKey,
|
|
16
14
|
ownedAgentKeyPrefix,
|
|
17
15
|
parseOwnedAgentId,
|
|
18
16
|
publicAgentKey
|
|
19
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-M2EJHDJP.js";
|
|
20
18
|
|
|
21
19
|
// packages/cli/agentListHelpers.ts
|
|
22
20
|
function parseAgentRecordId(privateKey, explicitId) {
|
|
@@ -67,16 +65,10 @@ function normalizeListedAgent(record) {
|
|
|
67
65
|
...credentialKind !== void 0 ? { credentialKind } : {},
|
|
68
66
|
...typeof record?.apiSource === "string" && record.apiSource ? { apiSource: record.apiSource } : {},
|
|
69
67
|
...typeof record?.cliProvider === "string" && record.cliProvider ? { cliProvider: record.cliProvider } : {},
|
|
70
|
-
...typeof record?.nextAvailableAt === "number" && Number.isFinite(record.nextAvailableAt) ? { nextAvailableAt: record.nextAvailableAt } : {}
|
|
68
|
+
...typeof record?.nextAvailableAt === "number" && Number.isFinite(record.nextAvailableAt) ? { nextAvailableAt: record.nextAvailableAt } : {},
|
|
69
|
+
...record?.quota && typeof record.quota === "object" && Array.isArray(record.quota.windows) ? { quota: record.quota } : {}
|
|
71
70
|
};
|
|
72
71
|
}
|
|
73
|
-
function toSafeListedAgentSummary(agent, options) {
|
|
74
|
-
const summary = toSafeAgentSummary(agent, options);
|
|
75
|
-
if (agent.publicRecordExists === false) {
|
|
76
|
-
delete summary.publicKey;
|
|
77
|
-
}
|
|
78
|
-
return summary;
|
|
79
|
-
}
|
|
80
72
|
function sortListedAgents(agents) {
|
|
81
73
|
agents.sort((a, b) => {
|
|
82
74
|
const ta = a.updatedAt == null ? 0 : new Date(a.updatedAt).getTime();
|
|
@@ -97,6 +89,7 @@ function parseAgentListArgs(args) {
|
|
|
97
89
|
publicOnly: args.includes("--public-only"),
|
|
98
90
|
idsOnly: args.includes("--ids-only"),
|
|
99
91
|
scope: readArgValue(args, "--scope"),
|
|
92
|
+
query: readArgValue(args, "--query"),
|
|
100
93
|
showUnavailable: args.includes("--show-unavailable"),
|
|
101
94
|
// --safe 默认输出精简投影(与 server listAgents 一致,防大列表被截断);
|
|
102
95
|
// --verbose 拿回完整字段集排障。
|
|
@@ -110,7 +103,7 @@ async function listLocalCachedAgents(args) {
|
|
|
110
103
|
for (const prefix of [ownedPrefix, PUBLIC_AGENT_KEY_PREFIX]) {
|
|
111
104
|
for await (const [key, value] of args.db.iterator({ gte: prefix, lte: `${prefix}\uFFFF` })) {
|
|
112
105
|
if (typeof key !== "string" || !value || typeof value !== "object") continue;
|
|
113
|
-
if (
|
|
106
|
+
if (key.startsWith(ownedPrefix)) {
|
|
114
107
|
privateRecords.set(key, { ...value, dbKey: key });
|
|
115
108
|
continue;
|
|
116
109
|
}
|
|
@@ -237,14 +230,78 @@ async function decorateAgentsWithPublicStatusAcrossServers(args) {
|
|
|
237
230
|
return args.agents;
|
|
238
231
|
}
|
|
239
232
|
|
|
233
|
+
// packages/ai/agent/quotaSnapshot.ts
|
|
234
|
+
function findTightestQuotaWindow(quota, now = Date.now()) {
|
|
235
|
+
if (!quota || !Array.isArray(quota.windows) || quota.windows.length === 0) {
|
|
236
|
+
return void 0;
|
|
237
|
+
}
|
|
238
|
+
let best;
|
|
239
|
+
let bestScore = -Infinity;
|
|
240
|
+
for (const w of quota.windows) {
|
|
241
|
+
let score = 0;
|
|
242
|
+
if (typeof w.utilization === "number" && w.utilization >= 0) {
|
|
243
|
+
score = 500 + Math.min(w.utilization, 1) * 500;
|
|
244
|
+
} else if (typeof w.remaining === "number" && typeof w.limit === "number" && w.limit > 0) {
|
|
245
|
+
const util = Math.max(0, 1 - w.remaining / w.limit);
|
|
246
|
+
score = 500 + util * 500;
|
|
247
|
+
} else if (typeof w.resetAt === "number" && w.resetAt > now) {
|
|
248
|
+
score = 200;
|
|
249
|
+
} else if (typeof w.remaining === "number") {
|
|
250
|
+
score = 100;
|
|
251
|
+
}
|
|
252
|
+
if (score > bestScore) {
|
|
253
|
+
bestScore = score;
|
|
254
|
+
best = w;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return best ?? quota.windows[0];
|
|
258
|
+
}
|
|
259
|
+
function formatQuotaSummary(quota, now = Date.now(), options) {
|
|
260
|
+
const tightest = findTightestQuotaWindow(quota, now);
|
|
261
|
+
if (!tightest) return void 0;
|
|
262
|
+
const compact = options?.compact === true;
|
|
263
|
+
const parts = [];
|
|
264
|
+
if (typeof tightest.utilization === "number") {
|
|
265
|
+
const pct = Math.round(tightest.utilization * 100);
|
|
266
|
+
parts.push(`${pct}%\u5DF2\u7528`);
|
|
267
|
+
} else if (typeof tightest.remaining === "number") {
|
|
268
|
+
if (typeof tightest.limit === "number") {
|
|
269
|
+
parts.push(`${tightest.remaining}/${tightest.limit}${tightest.unit ? ` ${tightest.unit}` : ""}`);
|
|
270
|
+
} else {
|
|
271
|
+
parts.push(`\u4F59${tightest.remaining}${tightest.unit ? ` ${tightest.unit}` : ""}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (compact) return parts.length > 0 ? parts[0] : void 0;
|
|
275
|
+
if (tightest.scope && tightest.scope !== "user" && tightest.scope !== "project" && tightest.scope !== tightest.unit) {
|
|
276
|
+
parts.push(tightest.scope);
|
|
277
|
+
}
|
|
278
|
+
if (typeof tightest.resetAt === "number" && tightest.resetAt > now) {
|
|
279
|
+
const diffSec = Math.round((tightest.resetAt - now) / 1e3);
|
|
280
|
+
if (diffSec < 60) {
|
|
281
|
+
parts.push(`${diffSec}s\u540E\u91CD\u7F6E`);
|
|
282
|
+
} else if (diffSec < 3600) {
|
|
283
|
+
parts.push(`${Math.round(diffSec / 60)}m\u540E\u91CD\u7F6E`);
|
|
284
|
+
} else if (diffSec < 86400) {
|
|
285
|
+
const hours = (diffSec / 3600).toFixed(1).replace(/\.0$/, "");
|
|
286
|
+
parts.push(`${hours}h\u540E\u91CD\u7F6E`);
|
|
287
|
+
} else {
|
|
288
|
+
const days = (diffSec / 86400).toFixed(1).replace(/\.0$/, "");
|
|
289
|
+
parts.push(`${days}d\u540E\u91CD\u7F6E`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (parts.length === 0) return void 0;
|
|
293
|
+
if (parts.length === 1 && parts[0] === tightest.scope) return void 0;
|
|
294
|
+
return parts.join(" \xB7 ");
|
|
295
|
+
}
|
|
296
|
+
|
|
240
297
|
export {
|
|
241
298
|
normalizeListedAgent,
|
|
242
|
-
toSafeListedAgentSummary,
|
|
243
299
|
parseAgentListArgs,
|
|
244
300
|
listLocalCachedAgents,
|
|
245
301
|
listRemotePublicAgents,
|
|
246
302
|
listRemoteAgents,
|
|
247
303
|
listRemoteAgentsAcrossServers,
|
|
248
304
|
listFavoriteAgentIdsAcrossServers,
|
|
249
|
-
decorateAgentsWithPublicStatusAcrossServers
|
|
305
|
+
decorateAgentsWithPublicStatusAcrossServers,
|
|
306
|
+
formatQuotaSummary
|
|
250
307
|
};
|
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
getAntigravityUserAgent,
|
|
12
12
|
normalizeAntigravityTokenPayload,
|
|
13
13
|
refreshAntigravityToken
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import {
|
|
16
|
-
writeOAuthCredential
|
|
17
|
-
} from "./chunk-ONXOABJR.js";
|
|
14
|
+
} from "./chunk-S5XGT6GB.js";
|
|
18
15
|
import {
|
|
19
16
|
toErrorMessage
|
|
20
17
|
} from "./chunk-HNMXYYJR.js";
|
|
18
|
+
import {
|
|
19
|
+
writeOAuthCredential
|
|
20
|
+
} from "./chunk-HNGRBWYF.js";
|
|
21
21
|
import {
|
|
22
22
|
asOptionalFiniteNumber
|
|
23
23
|
} from "./chunk-WWC7I6TA.js";
|
|
@@ -367,6 +367,77 @@ async function refreshAntigravityOAuthToken(credential, deps = {}) {
|
|
|
367
367
|
// packages/cli/oauth/flows/openai-codex.ts
|
|
368
368
|
import { createHash as createHash2 } from "node:crypto";
|
|
369
369
|
|
|
370
|
+
// packages/agent-runtime/oauthRefreshError.ts
|
|
371
|
+
var PERMANENT_REFRESH_CODES = /* @__PURE__ */ new Set([
|
|
372
|
+
"invalid_grant",
|
|
373
|
+
// OpenAI 令牌端点对失效/不存在的 refresh token 返回 401
|
|
374
|
+
// {"error":{"code":"invalid_refresh_token",...}}(2026-10-01 用必然无效的
|
|
375
|
+
// token 实测)。线上 chatgpt 凭据正是因为没认出它,被当成临时的
|
|
376
|
+
// "unauthorized"、每 15 分钟重试一次且永远不提示重新授权。
|
|
377
|
+
"invalid_refresh_token",
|
|
378
|
+
"refresh_token_reused",
|
|
379
|
+
"invalid_client"
|
|
380
|
+
]);
|
|
381
|
+
var SAFE_MESSAGES = {
|
|
382
|
+
invalid_grant: "refresh token \u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u6388\u6743",
|
|
383
|
+
invalid_refresh_token: "refresh token \u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u6388\u6743",
|
|
384
|
+
refresh_token_reused: "refresh token \u5DF2\u88AB\u5176\u4ED6\u526F\u672C\u4F7F\u7528\uFF0C\u8BF7\u91CD\u65B0\u6388\u6743",
|
|
385
|
+
invalid_client: "OAuth \u5BA2\u6237\u7AEF\u88AB\u62D2\u7EDD\uFF0C\u8BF7\u91CD\u65B0\u6388\u6743",
|
|
386
|
+
unauthorized: "\u4E0A\u6E38\u62D2\u7EDD\u4E86\u5237\u65B0\u8BF7\u6C42\uFF08401/403\uFF09",
|
|
387
|
+
rate_limited: "\u4E0A\u6E38\u9650\u6D41\uFF0C\u7A0D\u540E\u91CD\u8BD5",
|
|
388
|
+
http_5xx: "\u4E0A\u6E38\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528",
|
|
389
|
+
network: "\u65E0\u6CD5\u8FDE\u63A5\u4E0A\u6E38",
|
|
390
|
+
bad_response: "\u4E0A\u6E38\u8FD4\u56DE\u4E86\u65E0\u6CD5\u8BC6\u522B\u7684\u54CD\u5E94",
|
|
391
|
+
unknown: "\u5237\u65B0\u5931\u8D25"
|
|
392
|
+
};
|
|
393
|
+
var OAuthRefreshError = class extends Error {
|
|
394
|
+
code;
|
|
395
|
+
status;
|
|
396
|
+
retryAfterMs;
|
|
397
|
+
constructor(code, opts = {}) {
|
|
398
|
+
super(SAFE_MESSAGES[code]);
|
|
399
|
+
this.name = "OAuthRefreshError";
|
|
400
|
+
this.code = code;
|
|
401
|
+
if (opts.status !== void 0) this.status = opts.status;
|
|
402
|
+
if (opts.retryAfterMs !== void 0) this.retryAfterMs = opts.retryAfterMs;
|
|
403
|
+
}
|
|
404
|
+
get permanent() {
|
|
405
|
+
return PERMANENT_REFRESH_CODES.has(this.code);
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
function readErrorCode(payload) {
|
|
409
|
+
if (!payload || typeof payload !== "object") return void 0;
|
|
410
|
+
const err = payload.error;
|
|
411
|
+
if (typeof err === "string") return err;
|
|
412
|
+
if (err && typeof err === "object") {
|
|
413
|
+
const code = err.code;
|
|
414
|
+
if (typeof code === "string") return code;
|
|
415
|
+
}
|
|
416
|
+
return void 0;
|
|
417
|
+
}
|
|
418
|
+
function classifyOAuthRefreshHttpFailure(status, payload, headers) {
|
|
419
|
+
const raw = readErrorCode(payload)?.toLowerCase();
|
|
420
|
+
if (raw === "invalid_grant") return new OAuthRefreshError("invalid_grant", { status });
|
|
421
|
+
if (raw === "invalid_refresh_token") {
|
|
422
|
+
return new OAuthRefreshError("invalid_refresh_token", { status });
|
|
423
|
+
}
|
|
424
|
+
if (raw === "refresh_token_reused") {
|
|
425
|
+
return new OAuthRefreshError("refresh_token_reused", { status });
|
|
426
|
+
}
|
|
427
|
+
if (raw === "invalid_client") return new OAuthRefreshError("invalid_client", { status });
|
|
428
|
+
if (status === 429) {
|
|
429
|
+
const seconds = Number(headers?.get("retry-after"));
|
|
430
|
+
return new OAuthRefreshError("rate_limited", {
|
|
431
|
+
status,
|
|
432
|
+
...Number.isFinite(seconds) && seconds > 0 ? { retryAfterMs: seconds * 1e3 } : {}
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
if (status === 401 || status === 403) return new OAuthRefreshError("unauthorized", { status });
|
|
436
|
+
if (status >= 500) return new OAuthRefreshError("http_5xx", { status });
|
|
437
|
+
return new OAuthRefreshError("unknown", { status });
|
|
438
|
+
}
|
|
439
|
+
var TRANSIENT_MAX_MS = 15 * 6e4;
|
|
440
|
+
|
|
370
441
|
// packages/agent-runtime/openaiCodexOAuth.ts
|
|
371
442
|
var OPENAI_CODEX_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
372
443
|
var OPENAI_CODEX_SCOPES = [
|
|
@@ -463,17 +534,14 @@ async function refreshOpenAiCodexToken(credential, deps = {}) {
|
|
|
463
534
|
signal: AbortSignal.timeout(OPENAI_CODEX_TOKEN_REQUEST_TIMEOUT_MS)
|
|
464
535
|
});
|
|
465
536
|
} catch (error) {
|
|
466
|
-
throw new
|
|
467
|
-
`OpenAI Codex token refresh failed: ${toErrorMessage(error)}`
|
|
468
|
-
);
|
|
537
|
+
throw new OAuthRefreshError("network");
|
|
469
538
|
}
|
|
470
539
|
const payload = await response.json().catch(() => ({}));
|
|
471
540
|
if (!response.ok) {
|
|
472
|
-
|
|
473
|
-
throw new Error(`OpenAI Codex token refresh failed: ${detail}`);
|
|
541
|
+
throw classifyOAuthRefreshHttpFailure(response.status, payload, response.headers);
|
|
474
542
|
}
|
|
475
543
|
if (typeof payload.access_token !== "string" || !payload.access_token.trim()) {
|
|
476
|
-
throw new
|
|
544
|
+
throw new OAuthRefreshError("bad_response");
|
|
477
545
|
}
|
|
478
546
|
const now = deps.now?.() ?? Date.now();
|
|
479
547
|
return normalizeOpenAiCodexTokenPayload({
|
|
@@ -1047,11 +1115,10 @@ async function refreshAnthropicToken(credential, deps = {}) {
|
|
|
1047
1115
|
});
|
|
1048
1116
|
const payload = await response.json().catch(() => ({}));
|
|
1049
1117
|
if (!response.ok) {
|
|
1050
|
-
|
|
1051
|
-
throw new Error(`Claude token refresh failed: ${detail}`);
|
|
1118
|
+
throw classifyOAuthRefreshHttpFailure(response.status, payload, response.headers);
|
|
1052
1119
|
}
|
|
1053
1120
|
if (typeof payload.access_token !== "string" || !payload.access_token.trim()) {
|
|
1054
|
-
throw new
|
|
1121
|
+
throw new OAuthRefreshError("bad_response");
|
|
1055
1122
|
}
|
|
1056
1123
|
const now = deps.now?.() ?? Date.now();
|
|
1057
1124
|
return normalizeAnthropicTokenPayload({
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// packages/ai/chat/parseApiError.ts
|
|
2
|
+
var CONTEXT_OVERFLOW_ACTIONS = [
|
|
3
|
+
"compact-and-retry",
|
|
4
|
+
"new-dialog",
|
|
5
|
+
"switch-model",
|
|
6
|
+
"retry"
|
|
7
|
+
];
|
|
8
|
+
var CONTEXT_TOO_LARGE_ACTIONS = [
|
|
9
|
+
"new-dialog",
|
|
10
|
+
"switch-model",
|
|
11
|
+
"retry"
|
|
12
|
+
];
|
|
13
|
+
var truncateErrorMessage = (message, maxChars = 320) => message.length <= maxChars ? message : `${message.slice(0, maxChars)}\u2026`;
|
|
14
|
+
var isContextOverflowText = (message) => /maximum context|context (length|window|overflow|limit)|context_length_exceed\w*|requested about .*tokens|too many tokens|prompt is too long|exceeds? (the )?(model|max)/i.test(
|
|
15
|
+
message
|
|
16
|
+
);
|
|
17
|
+
function classifyApiError(input) {
|
|
18
|
+
const { status, message, body, code } = input;
|
|
19
|
+
const errorMessage = message;
|
|
20
|
+
let defaultMessage = `\u72B6\u6001\u7801 ${status} ${input.statusText ?? ""}`;
|
|
21
|
+
switch (status) {
|
|
22
|
+
case 400:
|
|
23
|
+
if (isContextOverflowText(errorMessage) || isContextOverflowText(body) || code === "UPSTREAM_400") {
|
|
24
|
+
return {
|
|
25
|
+
kind: "context_overflow",
|
|
26
|
+
message: "\u4E0A\u4E0B\u6587\u8FC7\u957F\uFF1A\u672C\u8F6E\u6D88\u606F\u6216\u5DE5\u5177\u7ED3\u679C\u592A\u5927\u3002\u8BF7\u7F29\u5C0F\u8303\u56F4\uFF0C\u6216\u5148\u8BFB\u53D6\u66F4\u5C0F\u7247\u6BB5\u540E\u518D\u7EE7\u7EED\u3002",
|
|
27
|
+
code,
|
|
28
|
+
status,
|
|
29
|
+
retryable: true,
|
|
30
|
+
actions: [...CONTEXT_OVERFLOW_ACTIONS]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (code === "MISSING_PROVIDER_API_KEY") {
|
|
34
|
+
return {
|
|
35
|
+
kind: "generic",
|
|
36
|
+
message: truncateErrorMessage(errorMessage),
|
|
37
|
+
code,
|
|
38
|
+
status,
|
|
39
|
+
retryable: false
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (errorMessage && errorMessage !== defaultMessage) {
|
|
43
|
+
return {
|
|
44
|
+
kind: "generic",
|
|
45
|
+
message: `\u8BF7\u6C42\u53C2\u6570\u9519\u8BEF: ${truncateErrorMessage(errorMessage)}`,
|
|
46
|
+
code,
|
|
47
|
+
status,
|
|
48
|
+
retryable: false
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return { kind: "generic", message: "\u8BF7\u6C42\u53C2\u6570\u9519\u8BEF\uFF0C\u8BF7\u68C0\u67E5\u8F93\u5165", code, status, retryable: false };
|
|
52
|
+
case 413:
|
|
53
|
+
return {
|
|
54
|
+
kind: "context_too_large",
|
|
55
|
+
message: "\u8BF7\u6C42\u5185\u5BB9\u8FC7\u5927\uFF1A\u8BF7\u51CF\u5C11\u4E00\u6B21\u53D1\u9001\u7684\u6D88\u606F\u3001\u6587\u4EF6\u6216\u5DE5\u5177\u7ED3\u679C\u3002",
|
|
56
|
+
code,
|
|
57
|
+
status,
|
|
58
|
+
retryable: true,
|
|
59
|
+
actions: [...CONTEXT_TOO_LARGE_ACTIONS]
|
|
60
|
+
};
|
|
61
|
+
case 401:
|
|
62
|
+
return {
|
|
63
|
+
kind: "auth",
|
|
64
|
+
message: code === "AUTH_TOKEN_EXPIRED" ? "\u767B\u5F55\u72B6\u6001\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u5148\u767B\u51FA\u540E\u91CD\u65B0\u767B\u5F55" : code === "AUTH_ACCOUNT_INVALID" ? "\u8D26\u6237\u65E0\u6548\u6216\u5DF2\u88AB\u505C\u7528\uFF0C\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458" : code === "AUTH_NO_TOKEN" ? "\u672A\u68C0\u6D4B\u5230\u767B\u5F55\u72B6\u6001\uFF0C\u8BF7\u5148\u767B\u5F55" : code === "AUTH_INVALID_TOKEN" ? "\u767B\u5F55\u51ED\u8BC1\u65E0\u6548\uFF0C\u8BF7\u5148\u767B\u51FA\u540E\u91CD\u65B0\u767B\u5F55" : code === "AUTH_TOKEN_NOT_ACTIVE" ? "\u4EE4\u724C\u5C1A\u672A\u751F\u6548\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5" : errorMessage && errorMessage !== `\u72B6\u6001\u7801 401 Unauthorized` ? `\u8BA4\u8BC1\u9519\u8BEF: ${truncateErrorMessage(errorMessage)}` : "\u8EAB\u4EFD\u9A8C\u8BC1\u5931\u8D25\uFF0C\u8BF7\u5148\u767B\u51FA\u540E\u91CD\u65B0\u767B\u5F55",
|
|
65
|
+
code,
|
|
66
|
+
status,
|
|
67
|
+
retryable: true,
|
|
68
|
+
actions: ["retry"]
|
|
69
|
+
};
|
|
70
|
+
case 503:
|
|
71
|
+
return {
|
|
72
|
+
kind: "server",
|
|
73
|
+
message: errorMessage && errorMessage !== `\u72B6\u6001\u7801 503 Service Unavailable` ? truncateErrorMessage(errorMessage) : "\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",
|
|
74
|
+
code,
|
|
75
|
+
status,
|
|
76
|
+
retryable: true,
|
|
77
|
+
actions: ["retry"]
|
|
78
|
+
};
|
|
79
|
+
case 504:
|
|
80
|
+
return {
|
|
81
|
+
kind: "timeout",
|
|
82
|
+
message: "\u8BF7\u6C42\u8D85\u65F6\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",
|
|
83
|
+
code,
|
|
84
|
+
status,
|
|
85
|
+
retryable: true,
|
|
86
|
+
actions: ["retry"]
|
|
87
|
+
};
|
|
88
|
+
default:
|
|
89
|
+
return {
|
|
90
|
+
kind: "generic",
|
|
91
|
+
message: `API\u8BF7\u6C42\u5931\u8D25: ${truncateErrorMessage(errorMessage)}`,
|
|
92
|
+
code,
|
|
93
|
+
status,
|
|
94
|
+
retryable: true,
|
|
95
|
+
actions: ["retry"]
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async function parseApiErrorInfo(response) {
|
|
100
|
+
const errorBody = await response.text();
|
|
101
|
+
let errorMessage = `\u72B6\u6001\u7801 ${response.status} ${response.statusText}`;
|
|
102
|
+
let errorCode = `E${response.status}`;
|
|
103
|
+
try {
|
|
104
|
+
const errorJson = JSON.parse(errorBody);
|
|
105
|
+
errorMessage = errorJson?.error?.message || errorJson?.message || errorJson?.msg || errorBody || errorMessage;
|
|
106
|
+
errorCode = errorJson?.error?.code || errorJson?.code || errorCode;
|
|
107
|
+
} catch (_e) {
|
|
108
|
+
if (errorBody) {
|
|
109
|
+
errorMessage = errorBody;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return classifyApiError({
|
|
113
|
+
status: response.status,
|
|
114
|
+
statusText: response.statusText,
|
|
115
|
+
message: errorMessage,
|
|
116
|
+
body: errorBody,
|
|
117
|
+
code: errorCode
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
async function parseApiError(response) {
|
|
121
|
+
return (await parseApiErrorInfo(response)).message;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export {
|
|
125
|
+
CONTEXT_OVERFLOW_ACTIONS,
|
|
126
|
+
CONTEXT_TOO_LARGE_ACTIONS,
|
|
127
|
+
isContextOverflowText,
|
|
128
|
+
parseApiError
|
|
129
|
+
};
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
clipMultilineText,
|
|
9
9
|
fetchAndSerializeTable
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-GA77XY7N.js";
|
|
11
11
|
import {
|
|
12
12
|
isGatewayHttpStatus
|
|
13
13
|
} from "./chunk-NF64D32W.js";
|
|
@@ -17,37 +17,40 @@ import {
|
|
|
17
17
|
normalizeNonNegativeMs,
|
|
18
18
|
parseRetryAfterHeaderMs
|
|
19
19
|
} from "./chunk-3L2WKC3W.js";
|
|
20
|
-
import {
|
|
21
|
-
slateToSimplifiedMarkdown
|
|
22
|
-
} from "./chunk-HNUNYXYB.js";
|
|
23
20
|
import {
|
|
24
21
|
waitForAbortableDelay
|
|
25
22
|
} from "./chunk-N4G4PKQ6.js";
|
|
23
|
+
import {
|
|
24
|
+
resolvePageReadMarkdown,
|
|
25
|
+
slateToSimplifiedMarkdown
|
|
26
|
+
} from "./chunk-BJUDYFV5.js";
|
|
26
27
|
import {
|
|
27
28
|
extractCategorizedMentions
|
|
28
29
|
} from "./chunk-MEYIRKDN.js";
|
|
29
30
|
import {
|
|
30
31
|
fetchAndCacheMessages
|
|
31
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-6PPDYAMH.js";
|
|
32
33
|
import {
|
|
33
34
|
shouldUseServerProxy
|
|
34
35
|
} from "./chunk-YYLHWIW6.js";
|
|
35
36
|
import {
|
|
36
37
|
fetchServerSyncedCredential
|
|
37
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-Q3SKC2TQ.js";
|
|
38
39
|
import {
|
|
39
40
|
buildSkillGuidancePromptBlock,
|
|
40
41
|
extractRuntimePageCapabilities,
|
|
41
42
|
resolveBuiltinSkillPage,
|
|
42
43
|
resolveSkillGraphFromRoots
|
|
43
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-V2AB7ULS.js";
|
|
44
45
|
import {
|
|
46
|
+
DELETE_SAFETY_RED_LINE,
|
|
45
47
|
buildIdentityBlock,
|
|
46
48
|
buildRuntimeGuidanceBlocks,
|
|
47
49
|
compileContextLayers,
|
|
50
|
+
detectDispatchIntentFromMessages,
|
|
48
51
|
normalizeChatCompletionsBodyForProvider,
|
|
49
52
|
resolveToolGuidedSections
|
|
50
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-QL32RJFG.js";
|
|
51
54
|
import {
|
|
52
55
|
convertMessagesToResponsesInput,
|
|
53
56
|
getUsageRequestOptions,
|
|
@@ -57,29 +60,32 @@ import {
|
|
|
57
60
|
import {
|
|
58
61
|
ANTIGRAVITY_CLOUD_CODE_BASE_URL,
|
|
59
62
|
isAntigravityOAuthAgent
|
|
60
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-S5XGT6GB.js";
|
|
61
64
|
import {
|
|
62
65
|
buildProviderAuthHeaders
|
|
63
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-27ONFIEY.js";
|
|
64
67
|
import {
|
|
65
68
|
estimateTokenCount
|
|
66
69
|
} from "./chunk-PSCNXBYA.js";
|
|
70
|
+
import {
|
|
71
|
+
createFileCredentialBroker
|
|
72
|
+
} from "./chunk-ESRMFY7G.js";
|
|
67
73
|
import {
|
|
68
74
|
isOpenAiResponsesModel,
|
|
69
75
|
resolvePlatformChatCompletionsEndpoint,
|
|
70
76
|
resolvePlatformResponsesEndpoint
|
|
71
|
-
} from "./chunk-
|
|
77
|
+
} from "./chunk-7KVZ5LDQ.js";
|
|
78
|
+
import {
|
|
79
|
+
toErrorMessage
|
|
80
|
+
} from "./chunk-HNMXYYJR.js";
|
|
72
81
|
import {
|
|
73
82
|
clampReasoningEffort,
|
|
74
83
|
getModelConfig,
|
|
75
84
|
isModelSupportReasoningEffort
|
|
76
|
-
} from "./chunk-
|
|
77
|
-
import {
|
|
78
|
-
createFileCredentialBroker
|
|
79
|
-
} from "./chunk-HVURBGF3.js";
|
|
85
|
+
} from "./chunk-3BXNTXYI.js";
|
|
80
86
|
import {
|
|
81
|
-
|
|
82
|
-
} from "./chunk-
|
|
87
|
+
createSpaceKey
|
|
88
|
+
} from "./chunk-UAD2WT54.js";
|
|
83
89
|
import {
|
|
84
90
|
MEMORY_USE_GUIDANCE,
|
|
85
91
|
buildUserResponseLanguageContext,
|
|
@@ -87,34 +93,31 @@ import {
|
|
|
87
93
|
} from "./chunk-2GRGFCF6.js";
|
|
88
94
|
import {
|
|
89
95
|
canonicalizeToolNames
|
|
90
|
-
} from "./chunk-
|
|
96
|
+
} from "./chunk-XUWRURDF.js";
|
|
91
97
|
import {
|
|
92
98
|
isDeepInfraKimiModel,
|
|
93
99
|
isFireworksKimiModel,
|
|
94
100
|
isPlatformMimoProviderModel,
|
|
95
101
|
resolveFireworksKimiModel
|
|
96
|
-
} from "./chunk-
|
|
97
|
-
import {
|
|
98
|
-
createSpaceKey
|
|
99
|
-
} from "./chunk-UAD2WT54.js";
|
|
102
|
+
} from "./chunk-Y3PMXGLH.js";
|
|
100
103
|
import {
|
|
101
104
|
read
|
|
102
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-QALRKMHF.js";
|
|
103
106
|
import {
|
|
104
107
|
asTrimmedLowercaseString
|
|
105
108
|
} from "./chunk-QSJ3HFEF.js";
|
|
106
|
-
import {
|
|
107
|
-
extractCustomId
|
|
108
|
-
} from "./chunk-GII32WZW.js";
|
|
109
109
|
import {
|
|
110
110
|
getRuntimeServerContext
|
|
111
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-AUXHZ2M5.js";
|
|
112
112
|
import {
|
|
113
113
|
isAbortError
|
|
114
114
|
} from "./chunk-QOKAKDPE.js";
|
|
115
115
|
import {
|
|
116
116
|
isRecord
|
|
117
117
|
} from "./chunk-KUG52IAP.js";
|
|
118
|
+
import {
|
|
119
|
+
extractCustomId
|
|
120
|
+
} from "./chunk-M2EJHDJP.js";
|
|
118
121
|
import {
|
|
119
122
|
asTrimmedString
|
|
120
123
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -619,7 +622,9 @@ var buildSystemPromptContext = (options) => {
|
|
|
619
622
|
${mainPrompt}` : "";
|
|
620
623
|
const agentTools = canonicalizeToolNames(agentConfig.tools ?? []);
|
|
621
624
|
const hasAskTool = agentTools.includes("ask_user");
|
|
622
|
-
const toolSections = resolveToolGuidedSections(agentTools
|
|
625
|
+
const toolSections = resolveToolGuidedSections(agentTools, {
|
|
626
|
+
dispatchIntent: options.dispatchIntent === true
|
|
627
|
+
});
|
|
623
628
|
const {
|
|
624
629
|
startupProtocol,
|
|
625
630
|
contextLayerContract,
|
|
@@ -645,6 +650,14 @@ ${contexts.userGlobalPrompt.trim()} ` : "";
|
|
|
645
650
|
const dialogSummarySection = contexts.dialogSummary?.trim() ? `--- \u5386\u53F2\u5BF9\u8BDD\u6458\u8981 ---
|
|
646
651
|
${wrapHistoricalSummaryWithReplayGuard(contexts.dialogSummary)}` : "";
|
|
647
652
|
return compileContextLayers([
|
|
653
|
+
// 删除安全红线:系统层最高优先级约束,位于所有层之前(含身份信息),
|
|
654
|
+
// owner 要求常驻「根本提示词」的最顶部(2026-09-26 批量误删事故)。
|
|
655
|
+
{
|
|
656
|
+
id: "delete-safety-red-line",
|
|
657
|
+
owner: "platform",
|
|
658
|
+
cacheScope: "static",
|
|
659
|
+
content: DELETE_SAFETY_RED_LINE
|
|
660
|
+
},
|
|
648
661
|
{ id: "identity", owner: "platform", cacheScope: "session", content: identitySection },
|
|
649
662
|
{ id: "user-response-language", owner: "platform", cacheScope: "session", content: buildUserResponseLanguageContext({ language: safeLanguage }) },
|
|
650
663
|
{ id: "startup-protocol", owner: "platform", cacheScope: "static", content: startupProtocol },
|
|
@@ -652,6 +665,7 @@ ${wrapHistoricalSummaryWithReplayGuard(contexts.dialogSummary)}` : "";
|
|
|
652
665
|
{ id: "tool-round-economy", owner: "platform", cacheScope: "session", content: toolSections.toolRoundEconomy },
|
|
653
666
|
{ id: "tool-use-guidance", owner: "platform", cacheScope: "session", content: toolSections.toolUseGuidance },
|
|
654
667
|
{ id: "privilege-escalation", owner: "platform", cacheScope: "session", content: toolSections.privilegeEscalation },
|
|
668
|
+
{ id: "shell-task-lifecycle", owner: "platform", cacheScope: "session", content: toolSections.shellTaskLifecycle },
|
|
655
669
|
{ id: "agent-orchestration", owner: "platform", cacheScope: "session", content: toolSections.agentOrchestration },
|
|
656
670
|
{ id: "agent-collaboration", owner: "platform", cacheScope: "session", content: toolSections.agentCollaboration },
|
|
657
671
|
{ id: "web-access", owner: "platform", cacheScope: "session", content: toolSections.webAccess },
|
|
@@ -699,8 +713,9 @@ var applyClaudeCache = (stableContent, dynamicContent) => {
|
|
|
699
713
|
var prependPromptMessage = (messages, agentConfig, resolvedModel, language, contexts, prependSystemPrompt = true) => {
|
|
700
714
|
if (!prependSystemPrompt) return messages;
|
|
701
715
|
if (!contexts && !agentConfig.prompt) return messages;
|
|
716
|
+
const dispatchIntent = detectDispatchIntentFromMessages(messages);
|
|
702
717
|
if (isClaudeModel(resolvedModel)) {
|
|
703
|
-
const compiled = buildSystemPromptContext({ agentConfig, language, contexts });
|
|
718
|
+
const compiled = buildSystemPromptContext({ agentConfig, language, contexts, dispatchIntent });
|
|
704
719
|
if (!compiled.content.trim()) return messages;
|
|
705
720
|
const content = applyClaudeCache(
|
|
706
721
|
compiled.stablePrefixContent,
|
|
@@ -709,7 +724,7 @@ var prependPromptMessage = (messages, agentConfig, resolvedModel, language, cont
|
|
|
709
724
|
const systemMessage2 = { role: "system", content };
|
|
710
725
|
return [systemMessage2, ...messages];
|
|
711
726
|
}
|
|
712
|
-
const promptContent = buildSystemPrompt({ agentConfig, language, contexts });
|
|
727
|
+
const promptContent = buildSystemPrompt({ agentConfig, language, contexts, dispatchIntent });
|
|
713
728
|
if (!promptContent.trim()) return messages;
|
|
714
729
|
const systemMessage = { role: "system", content: promptContent };
|
|
715
730
|
return [systemMessage, ...messages];
|
|
@@ -772,8 +787,13 @@ var buildRequestBody = (options) => {
|
|
|
772
787
|
endpoint: customProviderUrl
|
|
773
788
|
});
|
|
774
789
|
Object.assign(bodyData, usageRequestOptions);
|
|
775
|
-
|
|
776
|
-
|
|
790
|
+
const effectiveProviderForReasoning = providerName?.toLowerCase() === "openrouter" || customProviderUrl?.toLowerCase().includes("openrouter.ai") ? "openrouter" : providerName;
|
|
791
|
+
if (reasoning_effort && isModelSupportReasoningEffort(model, effectiveProviderForReasoning)) {
|
|
792
|
+
const clamped = clampReasoningEffort(
|
|
793
|
+
reasoning_effort,
|
|
794
|
+
effectiveProviderForReasoning,
|
|
795
|
+
model
|
|
796
|
+
);
|
|
777
797
|
if (clamped) {
|
|
778
798
|
bodyData.reasoning_effort = clamped;
|
|
779
799
|
}
|
|
@@ -892,7 +912,9 @@ function generateResponseRequestBody(agentConfig, msgs, contexts, prependSystemP
|
|
|
892
912
|
const promptContent = buildSystemPrompt({
|
|
893
913
|
agentConfig,
|
|
894
914
|
language,
|
|
895
|
-
contexts
|
|
915
|
+
contexts,
|
|
916
|
+
// 按当前用户输入检测派发意图:无意图只注入最小派发协议(安全硬门常在)。
|
|
917
|
+
dispatchIntent: detectDispatchIntentFromMessages(msgs)
|
|
896
918
|
});
|
|
897
919
|
body.instructions = promptContent;
|
|
898
920
|
}
|
|
@@ -1202,7 +1224,7 @@ var buildProxyPayload = (bodyData, api, agentConfig, dialogId) => {
|
|
|
1202
1224
|
};
|
|
1203
1225
|
};
|
|
1204
1226
|
var fetchDirectly = async (params) => {
|
|
1205
|
-
const { api, agentConfig, bodyData, signal, currentServer, token } = params;
|
|
1227
|
+
const { api, agentConfig, bodyData, signal, currentServer, token, dialogId } = params;
|
|
1206
1228
|
try {
|
|
1207
1229
|
const apiKey = await resolveDirectRequestApiKey(agentConfig, {
|
|
1208
1230
|
syncFetcher: currentServer && token ? (ref) => fetchServerSyncedCredential({ currentServer, authToken: token }, ref) : void 0,
|
|
@@ -1222,7 +1244,8 @@ var fetchDirectly = async (params) => {
|
|
|
1222
1244
|
const authHeaders = buildProviderAuthHeaders({
|
|
1223
1245
|
endpoint: api,
|
|
1224
1246
|
apiKey: apiKey ?? "",
|
|
1225
|
-
apiKeyHeader: agentConfig.apiKeyHeader
|
|
1247
|
+
apiKeyHeader: agentConfig.apiKeyHeader,
|
|
1248
|
+
sessionId: dialogId || agentConfig.dbKey || agentConfig.key
|
|
1226
1249
|
});
|
|
1227
1250
|
return await fetch(api, {
|
|
1228
1251
|
method: "POST",
|
|
@@ -1788,12 +1811,17 @@ ${tableMd}
|
|
|
1788
1811
|
`;
|
|
1789
1812
|
};
|
|
1790
1813
|
var fetchSlateReference = async (dbKey, refContent, dispatch, options) => {
|
|
1791
|
-
|
|
1814
|
+
const hasSlate = Array.isArray(refContent?.slateData) && refContent.slateData.length > 0;
|
|
1815
|
+
const legacyContent = hasSlate ? null : resolvePageReadMarkdown(refContent).trim() || null;
|
|
1816
|
+
if (!hasSlate && !legacyContent) return null;
|
|
1792
1817
|
const title = refContent.title || `Untitled (${dbKey})`;
|
|
1793
1818
|
let contentString;
|
|
1794
1819
|
let contentType;
|
|
1795
1820
|
const inlineMentionMeta = options.inlineMentionMeta ?? options.format === "simplified_markdown";
|
|
1796
|
-
|
|
1821
|
+
if (legacyContent) {
|
|
1822
|
+
contentType = "Markdown (legacy content)";
|
|
1823
|
+
contentString = legacyContent;
|
|
1824
|
+
} else switch (options.format) {
|
|
1797
1825
|
case "text":
|
|
1798
1826
|
contentType = "Plain Text";
|
|
1799
1827
|
contentString = slateToText(refContent.slateData);
|