nolo-cli 0.84.0-alpha.1 → 0.84.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 +2 -2
- package/{_executeModel-IULR47HG.js → _executeModel-BPUR2QYH.js} +51 -50
- package/{action-D22U6CTH.js → action-P4TNFGAD.js} +11 -11
- package/{addContentAction-XAPUTGL4.js → addContentAction-MB2HHMDZ.js} +9 -9
- package/{addDialogAgentAction-M7VLLBZM.js → addDialogAgentAction-S2NRBCWW.js} +9 -9
- package/{agentDeleteCommand-2S4WCDQC.js → agentDeleteCommand-MNAA6MIG.js} +32 -30
- package/{agentEmailCommands-V3ADGHX7.js → agentEmailCommands-SK34WJKU.js} +70 -66
- package/{agentGrantCommands-R3VQEZJR.js → agentGrantCommands-M3XFO6EN.js} +2 -2
- package/{agentListCommands-EPK3S274.js → agentListCommands-I26MKI4T.js} +55 -36
- package/{agentMachineCommands-XMZWK7P3.js → agentMachineCommands-M6QDR6P3.js} +32 -30
- package/{agentProviderCommands-65ZC2WB4.js → agentProviderCommands-X3UNW77C.js} +87 -0
- package/{agentPullCommand-N7L2CT7L.js → agentPullCommand-O5MPVJ5E.js} +3 -3
- package/agentRecordCommands-HTHLO2MM.js +129 -0
- package/{agentRunCommand-VUWNWC7C.js → agentRunCommand-IAIRCMTH.js} +70 -65
- package/{agentRunControl-T44MESII.js → agentRunControl-AVJR4JW4.js} +2 -2
- package/{agentRuntimeLocal-YRONTDLM.js → agentRuntimeLocal-3WTYYIT2.js} +32 -26
- package/{agentSlice-2P7OJFES.js → agentSlice-TVP3HINW.js} +10 -10
- package/{appDeleteCommands-YS7UGMP3.js → appDeleteCommands-SB5TNLKY.js} +32 -30
- package/{appDeployCommands-XIE5Z4BE.js → appDeployCommands-2IPKZINV.js} +32 -30
- package/{appDeployStatusCommands-54UDVYET.js → appDeployStatusCommands-K63TFUID.js} +32 -30
- package/{appGetCommands-6XYLBCRN.js → appGetCommands-VU2SLNEH.js} +32 -30
- package/{appListCommands-VEGH7SF5.js → appListCommands-S3T4DJ36.js} +32 -30
- package/{authCommand-JIEOFHXW.js → authCommand-HGP2XTKC.js} +185 -28
- package/{authCommands-ILTBI6JV.js → authCommands-RGOGCPP6.js} +4 -5
- package/builtinSkillRegistry-Q2VVY3SC.js +33 -0
- package/{chatQueueReduxAdapter-GPYCH5Z2.js → chatQueueReduxAdapter-TWIYKVIZ.js} +25 -25
- package/{chromeCommands-VOIRNJBL.js → chromeCommands-FZYAU75D.js} +1 -1
- package/{chromeOpsCommands-M7DPCX2T.js → chromeOpsCommands-62P2Q2YB.js} +31 -1
- package/{chunk-C3FZR5EC.js → chunk-2F7RJC6L.js} +1 -1
- package/{chunk-BOYUESO7.js → chunk-3AMA42ZI.js} +1 -1
- package/{chunk-RZOJRTKR.js → chunk-3BGIKIPF.js} +444 -920
- package/{chunk-HQUORJTM.js → chunk-3BMYXEUW.js} +1 -1
- package/{chunk-EBKMQULC.js → chunk-3IUWIAHP.js} +13 -15
- package/{chunk-NTW5GWDM.js → chunk-3VNWWVKB.js} +2 -0
- package/{chunk-4SZ37KLL.js → chunk-3VUWPRFW.js} +50 -30
- package/{chunk-WL2RKIBF.js → chunk-3YIAR5UI.js} +1 -1
- package/{chunk-DWUCB2A3.js → chunk-42V6BK2E.js} +1 -1
- package/{chunk-AX7RMXSH.js → chunk-4MK3I7Y4.js} +38 -4
- package/{chunk-PF6O3GR3.js → chunk-52Q2IW2X.js} +1340 -1273
- package/{chunk-Y3NZYLPG.js → chunk-5MEYHVIB.js} +1 -1
- package/{chunk-5XTOKQLW.js → chunk-5UTFL4QJ.js} +6 -2
- package/chunk-5ZUL4CUO.js +10 -0
- package/{chunk-6YTOJY35.js → chunk-6D2JFXLY.js} +35 -0
- package/{chunk-E6RGHPDR.js → chunk-6D6VBVEW.js} +4 -6
- package/{chunk-FZGV4FGK.js → chunk-6GFOD3TK.js} +260 -140
- package/{chunk-TMPLPCVX.js → chunk-6OZ36FXI.js} +2 -2
- package/{chunk-PZM3EENV.js → chunk-6Z7MY3V7.js} +1 -1
- package/{chunk-BYEJ7K2Z.js → chunk-7S4YWN7P.js} +1 -1
- package/{chunk-SREASRV5.js → chunk-ABQYVJBJ.js} +1 -1
- package/chunk-ACTMNVHM.js +93 -0
- package/{chunk-ZZCJUXUI.js → chunk-AHAHBQMU.js} +2 -2
- package/{chunk-BJCWNHVU.js → chunk-BFDFRLLQ.js} +2 -2
- package/chunk-BMQ2MJUK.js +153 -0
- package/chunk-BNGW5ASC.js +344 -0
- package/{chunk-2KDR4CWE.js → chunk-BYMV6QZG.js} +24 -1
- package/{chunk-73BR2IQT.js → chunk-CWQINZEA.js} +127 -7
- package/{chunk-HTMVBPOF.js → chunk-DD6XE56O.js} +19 -72
- package/{chunk-CADAR6QU.js → chunk-EYAQT56M.js} +4 -3
- package/{chunk-CJCJF5XB.js → chunk-FDTR4QJ6.js} +4 -2
- package/{chunk-D6XYLSOS.js → chunk-FKNWP6SG.js} +1 -1
- package/{chunk-3VPDELAP.js → chunk-FP76KI2Y.js} +1500 -84
- package/chunk-FV3JEYR3.js +870 -0
- package/{chunk-GCJ3IS5M.js → chunk-GIVFXPWK.js} +177 -6
- package/chunk-GMZLP5DV.js +82 -0
- package/{chunk-LHDV2QUI.js → chunk-GNCCNNZD.js} +4 -2
- package/{chunk-XWNRAIUL.js → chunk-GP5LKBUZ.js} +6 -16
- package/{chunk-PZCTYKGU.js → chunk-GQBOR3G6.js} +2 -2
- package/{chunk-NFT2AOK5.js → chunk-H4AHY5BU.js} +13 -85
- package/{chunk-FNGAF7C4.js → chunk-HAFJ3NDE.js} +137 -12
- package/{chunk-ZVN6I33J.js → chunk-HCT7U36O.js} +9 -5
- package/{chunk-7QVPPOEC.js → chunk-HKNXJGEC.js} +43 -43
- package/{chunk-3JQ2NRYU.js → chunk-HVURBGF3.js} +4 -4
- package/{chunk-OZX2IPKM.js → chunk-HYJFRTLW.js} +2 -2
- package/{chunk-HH65VA5U.js → chunk-I3TQJXQ7.js} +109 -6
- package/{chunk-UDQWGU7F.js → chunk-J4MOO56S.js} +1 -1
- package/{chunk-KC5FAHVS.js → chunk-JEDZAO7L.js} +1 -1
- package/{chunk-6XIE5ZGI.js → chunk-JPGCXHNM.js} +1 -1
- package/{chunk-DUJWWUGV.js → chunk-K36IXSCQ.js} +1 -1
- package/{chunk-KRMWO2NN.js → chunk-KAUSRTO6.js} +3 -3
- package/{chunk-7FWPLK4M.js → chunk-LJ5VW2UJ.js} +1 -1
- package/{chunk-GHEJJGJI.js → chunk-LMREEBWT.js} +833 -109
- package/{chunk-RXX4GDIH.js → chunk-LS2ZANRJ.js} +1 -1
- package/chunk-LVIFM7VW.js +1625 -0
- package/{chunk-BJIRLHJR.js → chunk-M2EJHDJP.js} +4 -0
- package/{chunk-EVBFYPDC.js → chunk-MC4XLIJ7.js} +6 -2
- package/{chunk-KEZNSFGD.js → chunk-MZYBSTMH.js} +11 -173
- package/chunk-OCZKATRC.js +129 -0
- package/{chunk-MXUSPS2N.js → chunk-OIVSQH2O.js} +1510 -1592
- package/{chunk-E36HZARC.js → chunk-P5EVSOPA.js} +93 -17
- package/{chunk-SZLVDREM.js → chunk-PBA4UJBK.js} +3 -3
- package/{chunk-URWDSZRW.js → chunk-PMAIQX7A.js} +3 -3
- package/{chunk-AETZ7AD6.js → chunk-Q554LLSI.js} +1 -1
- package/{chunk-AJHEFRGJ.js → chunk-Q67DOFOO.js} +214 -5
- package/{chunk-UZ6XXCVR.js → chunk-QDSINZM3.js} +15 -2
- package/{chunk-NRALD3CC.js → chunk-QSHEEA5N.js} +54 -10
- package/chunk-QU7KDSZX.js +677 -0
- package/{chunk-T25L377S.js → chunk-RPJUFEGR.js} +10 -10
- package/{chunk-QCZX4FTW.js → chunk-SH43IESU.js} +173 -15
- package/{chunk-SPAQ4PVV.js → chunk-SV5IJK6K.js} +1 -1
- package/{chunk-BKJO7LDP.js → chunk-U4OKDZFH.js} +6 -6
- package/{chunk-DM4FBSWG.js → chunk-UDVH2P4A.js} +7 -7
- package/{chunk-4EJ5QYB5.js → chunk-UEVXFHQB.js} +2 -2
- package/{chunk-JYYZCK2Z.js → chunk-V7E4PXQD.js} +1 -1
- package/{chunk-NHRQCXIQ.js → chunk-VMFTFOWF.js} +13 -3
- package/{chunk-YFADVSZE.js → chunk-VRTTFDBM.js} +7 -6
- package/{chunk-U7YP7ECK.js → chunk-WP5UXDA5.js} +84 -13
- package/{chunk-5J7W2VWW.js → chunk-WV42OMV7.js} +6 -265
- package/{chunk-3QPYFHAH.js → chunk-XD2MJFUG.js} +1 -1
- package/{chunk-IDGYOD2O.js → chunk-XP3VVAPG.js} +3174 -223
- package/{chunk-ETLZZQJE.js → chunk-Z2PV6O2T.js} +121 -26
- package/{chunk-BZNGCVAW.js → chunk-Z5625XML.js} +4 -4
- package/{contentThunks-THSCADSK.js → contentThunks-JYWI7G7I.js} +26 -26
- package/{cooldownCommands-BSCH2W7P.js → cooldownCommands-REAWYVTY.js} +2 -2
- package/{createAgentAutomationAction-WGN3UQ5A.js → createAgentAutomationAction-Z4SUJ54Y.js} +26 -26
- package/{createDialogAction-3EN2NLH7.js → createDialogAction-RCHFLVJ2.js} +29 -29
- package/{createPageAction-4VK473QV.js → createPageAction-YK2253XQ.js} +28 -28
- package/{dbSlice-GKGGFNOB.js → dbSlice-A6C6H32X.js} +8 -8
- package/{deleteFile-LWSR674W.js → deleteFile-YG6QMJLU.js} +3 -3
- package/{dialogCommands-PS4NWYY7.js → dialogCommands-X4UOZQWX.js} +36 -32
- package/{dialogSlice-CLV7SVOZ.js → dialogSlice-IVTWLCE2.js} +31 -25
- package/{docCreateCommands-4KANZJR6.js → docCreateCommands-VD6TGHG4.js} +33 -31
- package/{docDeleteCommands-F2S2TRUF.js → docDeleteCommands-OT3R2G4W.js} +34 -32
- package/{docReadCommands-B2WDPZQE.js → docReadCommands-2G7BIXSH.js} +33 -31
- package/{docStore-TDLCHWPF.js → docStore-UENKCCDX.js} +9 -9
- package/{docUpdateCommands-E7TKHRIO.js → docUpdateCommands-45MVJKZA.js} +33 -31
- package/{fetchMessages-DRABNDPZ.js → fetchMessages-EIU7UFFK.js} +3 -4
- package/{getPricing-QVTUQQTM.js → getPricing-LUSEABA6.js} +4 -4
- package/{handleSendMessageAction-AHL3ZHE4.js → handleSendMessageAction-LM2J4HC3.js} +66 -74
- package/index.js +99 -86
- package/{localDialogRead-PUQKFI73.js → localDialogRead-BTFJ4V2I.js} +2 -2
- package/{localRuntimeDb-P37ZTX55.js → localRuntimeDb-SYQGUF4U.js} +1 -1
- package/{machineCommands-OTABVXOA.js → machineCommands-6N6MQIE6.js} +69 -65
- package/{machineWsRunDispatch-V4EVQSMZ.js → machineWsRunDispatch-7MFKVQCR.js} +65 -61
- package/{memberThunks-KATHH3F4.js → memberThunks-P2ECUJ56.js} +9 -9
- package/{models-GS72DVJS.js → models-T3SG6MJ5.js} +2 -2
- package/{offlineMarxistsAgentCommand-GEH6SNNA.js → offlineMarxistsAgentCommand-HGXZV4XJ.js} +1 -1
- package/package.json +1 -1
- package/pdf-U6KSUEZZ.js +26435 -0
- package/providerPresetApply-XI3WUPTI.js +214 -0
- package/providerRegistry-KEPWWGXD.js +31 -0
- package/{read-LC6HVYBN.js → read-COE3ZYR6.js} +5 -4
- package/{readDocTool-N3ERJHHF.js → readDocTool-5USN4A6V.js} +1 -1
- package/{readlineWorkspace-IIT3FQ6I.js → readlineWorkspace-JWBON5CX.js} +291 -135
- package/{removeDialogAgentAction-F5GPTALR.js → removeDialogAgentAction-W66BJ7CF.js} +12 -12
- package/{runAgentClientLoop-7TQM7IAR.js → runAgentClientLoop-TA4SSPHE.js} +49 -49
- package/{runtimeDoctorCommands-CROTMULY.js → runtimeDoctorCommands-X6WDBEQX.js} +2 -2
- package/{setDialogExtraReferencesAction-AY4ZCF3A.js → setDialogExtraReferencesAction-2ALKG3WA.js} +10 -10
- package/{setPrimaryDialogAgentAction-HPMG7V3R.js → setPrimaryDialogAgentAction-TQZB55F6.js} +12 -12
- package/{settingSlice-OEJA4NQO.js → settingSlice-P4ZW7K5X.js} +10 -10
- package/{spaceCommands-FSYH7AL4.js → spaceCommands-6NSAXB7D.js} +31 -29
- package/{streamAgentChatTurn-6EF6TVFK.js → streamAgentChatTurn-X5ENGUIS.js} +126 -65
- package/{switchDialogAgentAction-HMDZTZ4I.js → switchDialogAgentAction-3KI72HHS.js} +9 -9
- package/{tableCommands-SUNTHAYX.js → tableCommands-O6NWHFKV.js} +1 -1
- package/{toolApiClient-VGYUB4P5.js → toolApiClient-G3M73RTB.js} +3 -3
- package/{tools-R3QNWWTD.js → tools-XRQR7ZZR.js} +45 -45
- package/tuiSummaryLlmCaller-UFGFOIIW.js +128 -0
- package/{updateCommands-Y363MC3L.js → updateCommands-2M74UL7P.js} +2 -2
- package/{updateDialogTitleAction-F3EUOWOB.js → updateDialogTitleAction-ESUUD3GT.js} +46 -29
- package/agentRecordCommands-WFPWLWOF.js +0 -125
- package/chunk-FMODTASJ.js +0 -109
- package/chunk-I42VC5KR.js +0 -15
- package/chunk-NB5SIWC4.js +0 -611
- package/chunk-NG4UT4K4.js +0 -79
- package/codingSkills-7S6523WH.js +0 -48
- package/tuiSummaryLlmCaller-PWOXTCBF.js +0 -116
- package/{chunk-3RAG2NAD.js → chunk-UKWGR5SS.js} +3 -3
- package/{db-VQSAOWAO.js → db-WK5MDZVN.js} +1 -1
- package/{localRuntimeAuthority-R5UBODT3.js → localRuntimeAuthority-6IR6BBXE.js} +3 -3
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCliLocalRuntimeAdapter,
|
|
3
3
|
summarizeEndpoint
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LMREEBWT.js";
|
|
5
5
|
import {
|
|
6
6
|
clipMultilineText
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3BGIKIPF.js";
|
|
8
8
|
import {
|
|
9
9
|
runLocalAgentTurn
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-52Q2IW2X.js";
|
|
11
11
|
import {
|
|
12
12
|
applyToolSurfaceConstraints
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-HCT7U36O.js";
|
|
14
14
|
import {
|
|
15
15
|
resolveLocalRuntimeEnvFromPolicy
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-HVURBGF3.js";
|
|
17
17
|
import {
|
|
18
18
|
toErrorMessage
|
|
19
19
|
} from "./chunk-HNMXYYJR.js";
|
|
@@ -32,19 +32,19 @@ import {
|
|
|
32
32
|
} from "./chunk-KX6YBIHG.js";
|
|
33
33
|
import {
|
|
34
34
|
asTrimmedNonEmptyStringArray
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-VMFTFOWF.js";
|
|
36
36
|
import {
|
|
37
37
|
ownedAgentKey
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-M2EJHDJP.js";
|
|
39
|
+
import {
|
|
40
|
+
isRecord
|
|
41
|
+
} from "./chunk-KUG52IAP.js";
|
|
39
42
|
import {
|
|
40
43
|
asTrimmedString
|
|
41
44
|
} from "./chunk-3EUW3WEO.js";
|
|
42
45
|
import {
|
|
43
46
|
asOptionalPositiveFiniteNumber
|
|
44
47
|
} from "./chunk-U6VC4MU4.js";
|
|
45
|
-
import {
|
|
46
|
-
isRecord
|
|
47
|
-
} from "./chunk-KUG52IAP.js";
|
|
48
48
|
import {
|
|
49
49
|
asOptionalTrimmedString
|
|
50
50
|
} from "./chunk-G3SUCT4W.js";
|
|
@@ -6,19 +6,146 @@ import {
|
|
|
6
6
|
} from "./chunk-KUG52IAP.js";
|
|
7
7
|
|
|
8
8
|
// packages/desktop-chrome-connector/chromeConnector.ts
|
|
9
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
10
|
-
import { resolve } from "node:path";
|
|
9
|
+
import { existsSync as existsSync2, readFileSync } from "node:fs";
|
|
10
|
+
import { resolve as resolve2 } from "node:path";
|
|
11
|
+
|
|
12
|
+
// packages/desktop-chrome-connector/uploadSecurity.mjs
|
|
13
|
+
import { existsSync, realpathSync, statSync } from "node:fs";
|
|
14
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
15
|
+
var DEFAULT_MAX_FILE_BYTES = 25 * 1024 * 1024;
|
|
16
|
+
var DEFAULT_MAX_FILES = 10;
|
|
17
|
+
var UploadSecurityError = class extends Error {
|
|
18
|
+
constructor(code, message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "UploadSecurityError";
|
|
21
|
+
this.code = code;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
function createUploadSecurityError(code, message) {
|
|
25
|
+
return new UploadSecurityError(code, message);
|
|
26
|
+
}
|
|
27
|
+
function isSubpath(parent, child) {
|
|
28
|
+
const rel = relative(parent, child);
|
|
29
|
+
return !rel.startsWith("..") && !isAbsolute(rel);
|
|
30
|
+
}
|
|
31
|
+
function parseAllowedRoots(env = process.env) {
|
|
32
|
+
const raw = env?.NOLO_CHROME_UPLOAD_ROOTS;
|
|
33
|
+
if (!raw || typeof raw !== "string") {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
return raw.split(",").map((entry) => entry.trim()).filter(Boolean).filter((entry) => isAbsolute(entry)).map((entry) => {
|
|
37
|
+
const resolved = resolve(entry);
|
|
38
|
+
if (existsSync(resolved)) {
|
|
39
|
+
try {
|
|
40
|
+
return realpathSync(resolved);
|
|
41
|
+
} catch {
|
|
42
|
+
return resolved;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return resolved;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function validateUploadFiles(options = {}) {
|
|
49
|
+
const {
|
|
50
|
+
files,
|
|
51
|
+
env = process.env,
|
|
52
|
+
maxFiles = DEFAULT_MAX_FILES,
|
|
53
|
+
maxFileBytes = DEFAULT_MAX_FILE_BYTES
|
|
54
|
+
} = options;
|
|
55
|
+
if (!Array.isArray(files) || files.length === 0) {
|
|
56
|
+
throw createUploadSecurityError("no_files", "Provide at least one file to upload.");
|
|
57
|
+
}
|
|
58
|
+
if (files.length > maxFiles) {
|
|
59
|
+
throw createUploadSecurityError(
|
|
60
|
+
"too_many_files",
|
|
61
|
+
`Too many files: ${files.length} provided, maximum allowed is ${maxFiles}.`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const allowedRoots = parseAllowedRoots(env);
|
|
65
|
+
if (allowedRoots.length === 0) {
|
|
66
|
+
throw createUploadSecurityError(
|
|
67
|
+
"path_not_allowed",
|
|
68
|
+
"Upload roots not configured in NOLO_CHROME_UPLOAD_ROOTS; all uploads are refused."
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
const fileStats = [];
|
|
72
|
+
const canonicalFiles = [];
|
|
73
|
+
let totalBytes = 0;
|
|
74
|
+
for (const rawFile of files) {
|
|
75
|
+
if (typeof rawFile !== "string" || !rawFile.trim()) {
|
|
76
|
+
throw createUploadSecurityError("path_not_allowed", "File path must be a non-empty string.");
|
|
77
|
+
}
|
|
78
|
+
const trimmed = rawFile.trim();
|
|
79
|
+
const resolvedCandidate = resolve(trimmed);
|
|
80
|
+
if (!existsSync(resolvedCandidate)) {
|
|
81
|
+
throw createUploadSecurityError("path_not_allowed", `File not found or inaccessible: ${rawFile}`);
|
|
82
|
+
}
|
|
83
|
+
let real;
|
|
84
|
+
try {
|
|
85
|
+
real = realpathSync(resolvedCandidate);
|
|
86
|
+
} catch {
|
|
87
|
+
throw createUploadSecurityError("path_not_allowed", `Could not resolve canonical path for: ${rawFile}`);
|
|
88
|
+
}
|
|
89
|
+
let st;
|
|
90
|
+
try {
|
|
91
|
+
st = statSync(real);
|
|
92
|
+
} catch {
|
|
93
|
+
throw createUploadSecurityError("path_not_allowed", `Could not stat file: ${rawFile}`);
|
|
94
|
+
}
|
|
95
|
+
if (!st.isFile()) {
|
|
96
|
+
throw createUploadSecurityError("path_not_allowed", `Target path is not a regular file: ${rawFile}`);
|
|
97
|
+
}
|
|
98
|
+
if (st.size > maxFileBytes) {
|
|
99
|
+
throw createUploadSecurityError(
|
|
100
|
+
"too_large",
|
|
101
|
+
`File size ${st.size} bytes exceeds maximum allowed limit of ${maxFileBytes} bytes: ${rawFile}`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
const realInside = allowedRoots.some((root) => isSubpath(root, real));
|
|
105
|
+
if (!realInside) {
|
|
106
|
+
throw createUploadSecurityError(
|
|
107
|
+
"path_not_allowed",
|
|
108
|
+
`Path '${rawFile}' (resolved: '${real}') is not within allowed upload roots.`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
canonicalFiles.push(real);
|
|
112
|
+
fileStats.push({ path: real, bytes: st.size });
|
|
113
|
+
totalBytes += st.size;
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
ok: true,
|
|
117
|
+
files: canonicalFiles,
|
|
118
|
+
fileStats,
|
|
119
|
+
totalBytes
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function formatUploadAuditLog(entry = {}) {
|
|
123
|
+
const ts = entry.timestamp || (/* @__PURE__ */ new Date()).toISOString();
|
|
124
|
+
const safeTabId = String(entry.tabId ?? "").replace(/[\x00-\x1f\x7f-\x9f]+/g, " ");
|
|
125
|
+
const safeTarget = String(entry.target ?? "").replace(/[\x00-\x1f\x7f-\x9f]+/g, " ");
|
|
126
|
+
const files = Array.isArray(entry.files) ? entry.files : [];
|
|
127
|
+
const totalBytes = files.reduce((sum, f) => sum + (Number(f.bytes) || 0), 0);
|
|
128
|
+
const fileDetails = files.map((f) => `${String(f.path || "").replace(/[\x00-\x1f\x7f-\x9f]+/g, " ")}(${f.bytes || 0}B)`).join(", ");
|
|
129
|
+
return `[chrome-upload] ${ts} tabId=${safeTabId} target=${safeTarget} files=[${fileDetails}] totalBytes=${totalBytes}`;
|
|
130
|
+
}
|
|
131
|
+
function logUploadAudit(entry, logFn = console.warn) {
|
|
132
|
+
const line = formatUploadAuditLog(entry);
|
|
133
|
+
logFn(line);
|
|
134
|
+
return line;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// packages/desktop-chrome-connector/chromeConnector.ts
|
|
11
138
|
var NOLO_CHROME_CONNECTOR_EXTENSION_ID = "ahpdoopadkamnglhlacfjdfnonpjdplg";
|
|
12
139
|
var NOLO_CHROME_CONNECTOR_PROTOCOL_VERSION = "2";
|
|
13
140
|
function defaultTokenPath() {
|
|
14
|
-
return
|
|
141
|
+
return resolve2(
|
|
15
142
|
process.env.HOME || "",
|
|
16
143
|
"Library/Application Support/Nolo/ChromeConnector/token"
|
|
17
144
|
);
|
|
18
145
|
}
|
|
19
146
|
function readConnectorToken(tokenPath = defaultTokenPath()) {
|
|
20
147
|
if (process.env.NOLO_CHROME_CONNECTOR_TOKEN) return process.env.NOLO_CHROME_CONNECTOR_TOKEN;
|
|
21
|
-
if (!
|
|
148
|
+
if (!existsSync2(tokenPath)) return "";
|
|
22
149
|
return readFileSync(tokenPath, "utf8").trim();
|
|
23
150
|
}
|
|
24
151
|
var CHROME_TOOL_ACTIONS = {
|
|
@@ -32,7 +159,10 @@ var CHROME_TOOL_ACTIONS = {
|
|
|
32
159
|
chrome_scroll: "scroll",
|
|
33
160
|
chrome_screenshot: "screenshot",
|
|
34
161
|
chrome_read_console: "read_console",
|
|
35
|
-
chrome_read_network: "read_network"
|
|
162
|
+
chrome_read_network: "read_network",
|
|
163
|
+
chrome_set_files: "set_files",
|
|
164
|
+
chrome_upload_file: "set_files",
|
|
165
|
+
chrome_upload: "set_files"
|
|
36
166
|
};
|
|
37
167
|
function createConnectorError(code, message, details) {
|
|
38
168
|
const error = new Error(message);
|
|
@@ -59,8 +189,8 @@ function errorPayload(error) {
|
|
|
59
189
|
...error?.details !== void 0 ? { details: error.details } : {}
|
|
60
190
|
};
|
|
61
191
|
}
|
|
62
|
-
var TARGET_REQUIRED_ACTIONS = /* @__PURE__ */ new Set(["click", "type"]);
|
|
63
|
-
var TAB_ID_REQUIRED_ACTIONS = /* @__PURE__ */ new Set(["close_tab", "detach"]);
|
|
192
|
+
var TARGET_REQUIRED_ACTIONS = /* @__PURE__ */ new Set(["click", "type", "set_files"]);
|
|
193
|
+
var TAB_ID_REQUIRED_ACTIONS = /* @__PURE__ */ new Set(["close_tab", "detach", "set_files"]);
|
|
64
194
|
function validateChromeConnectorPayload(action, payload) {
|
|
65
195
|
if (TAB_ID_REQUIRED_ACTIONS.has(action)) {
|
|
66
196
|
const raw = payload.tabId;
|
|
@@ -71,16 +201,42 @@ function validateChromeConnectorPayload(action, payload) {
|
|
|
71
201
|
`Provide the tabId from chrome_list_tabs before calling ${action}.`
|
|
72
202
|
);
|
|
73
203
|
}
|
|
74
|
-
return;
|
|
204
|
+
if (!TARGET_REQUIRED_ACTIONS.has(action)) return;
|
|
75
205
|
}
|
|
76
206
|
if (!TARGET_REQUIRED_ACTIONS.has(action)) return;
|
|
77
|
-
const
|
|
207
|
+
const rawRef = typeof payload.elementRef === "string" ? payload.elementRef : typeof payload.ref === "string" ? payload.ref : "";
|
|
208
|
+
const elementRef = rawRef.trim();
|
|
78
209
|
const selector = typeof payload.selector === "string" ? payload.selector.trim() : "";
|
|
79
|
-
if (elementRef
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
210
|
+
if (!elementRef && !selector) {
|
|
211
|
+
throw createConnectorError(
|
|
212
|
+
"ELEMENT_TARGET_REQUIRED",
|
|
213
|
+
"Provide elementRef from chrome_read_page or a CSS selector."
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
if (action === "set_files") {
|
|
217
|
+
if (!Array.isArray(payload.files) || payload.files.length === 0) {
|
|
218
|
+
throw createConnectorError(
|
|
219
|
+
"no_files",
|
|
220
|
+
"Provide at least one file path in files array."
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
const validated = validateUploadFiles({
|
|
225
|
+
files: payload.files,
|
|
226
|
+
env: process.env
|
|
227
|
+
});
|
|
228
|
+
payload.files = validated.files;
|
|
229
|
+
const targetStr = elementRef ? `ref:${elementRef}` : `selector:${selector}`;
|
|
230
|
+
logUploadAudit({
|
|
231
|
+
tabId: String(payload.tabId),
|
|
232
|
+
target: targetStr,
|
|
233
|
+
files: validated.fileStats
|
|
234
|
+
});
|
|
235
|
+
} catch (err) {
|
|
236
|
+
const code = err?.code ?? "path_not_allowed";
|
|
237
|
+
throw createConnectorError(code, toErrorMessage(err));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
84
240
|
}
|
|
85
241
|
function createChromeConnectorClient(args) {
|
|
86
242
|
if (args?.request) return { request: args.request };
|
|
@@ -90,6 +246,7 @@ function createChromeConnectorClient(args) {
|
|
|
90
246
|
const token = args?.token ?? readConnectorToken(args?.tokenPath);
|
|
91
247
|
return {
|
|
92
248
|
async request(action, payload) {
|
|
249
|
+
validateChromeConnectorPayload(action, payload);
|
|
93
250
|
let response;
|
|
94
251
|
try {
|
|
95
252
|
response = await fetchImpl(endpoint, {
|
|
@@ -131,7 +288,8 @@ var REQUIRED_CHROME_CONNECTOR_FEATURES = {
|
|
|
131
288
|
screenshot: ["browser_debug"],
|
|
132
289
|
read_console: ["browser_debug"],
|
|
133
290
|
read_network: ["browser_debug"],
|
|
134
|
-
detach: ["browser_debug"]
|
|
291
|
+
detach: ["browser_debug"],
|
|
292
|
+
set_files: ["compact_observation_v2", "file_upload"]
|
|
135
293
|
};
|
|
136
294
|
function requiredFeaturesForConnectorAction(action) {
|
|
137
295
|
return [...REQUIRED_CHROME_CONNECTOR_FEATURES[action] ?? []];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
clearCliLocalRuntimePreparedAgentCache
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LMREEBWT.js";
|
|
4
4
|
import {
|
|
5
5
|
getReadableCliDb
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-LS2ZANRJ.js";
|
|
7
7
|
import {
|
|
8
8
|
buildCreatedAgentRecord,
|
|
9
9
|
buildUpdatedAgentRecord,
|
|
@@ -12,10 +12,10 @@ import {
|
|
|
12
12
|
resolveAgentRecordFromHybridStore,
|
|
13
13
|
sanitizeAgentRecordForCliOutput,
|
|
14
14
|
writeAgentRecord
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-QSHEEA5N.js";
|
|
16
16
|
import {
|
|
17
17
|
resolveCliAgentKeyInput
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-SV5IJK6K.js";
|
|
19
19
|
import {
|
|
20
20
|
toErrorMessage
|
|
21
21
|
} from "./chunk-HNMXYYJR.js";
|
|
@@ -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>] [--api-key <key>|--provider-api-key <key>] [--verify] [--field key=value]\n".replace("[--field key=value]", "[--handle <name>] [--field key=value]")
|
|
170
|
+
"Usage: nolo agent create <agent> [--preset <id>] [--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" + " --preset <id> resolves a `nolo agent providers` preset (e.g. step-plan) into provider/baseUrl/model; explicit flags override it.\n".replace("[--field key=value]", "[--handle <name>] [--field key=value]")
|
|
171
171
|
);
|
|
172
172
|
return args[0] ? 0 : 1;
|
|
173
173
|
}
|
|
@@ -212,7 +212,7 @@ async function runAgentCreateCommand(args, deps = {}) {
|
|
|
212
212
|
clearCliLocalRuntimePreparedAgentCache();
|
|
213
213
|
let verifyResult;
|
|
214
214
|
if (parsed.verify) {
|
|
215
|
-
const { verifyCustomProvider } = await import("./agentProviderCommands-
|
|
215
|
+
const { verifyCustomProvider } = await import("./agentProviderCommands-X3UNW77C.js");
|
|
216
216
|
const rec = built.nextRecord;
|
|
217
217
|
verifyResult = await verifyCustomProvider({
|
|
218
218
|
providerUrl: rec.customProviderUrl,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createFileCredentialBroker,
|
|
4
4
|
migrateAgentSecrets,
|
|
5
5
|
normalizeAgentRuntimeToolPolicy
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HVURBGF3.js";
|
|
7
7
|
import {
|
|
8
8
|
asRecordOrEmpty
|
|
9
9
|
} from "./chunk-KX6YBIHG.js";
|
|
@@ -11,16 +11,16 @@ import {
|
|
|
11
11
|
patch,
|
|
12
12
|
remove,
|
|
13
13
|
write
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-VRTTFDBM.js";
|
|
15
15
|
import {
|
|
16
16
|
createAgentKey,
|
|
17
17
|
toTrimmedString
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-VMFTFOWF.js";
|
|
19
19
|
import {
|
|
20
20
|
asyncThunkCreator,
|
|
21
21
|
buildCreateSlice,
|
|
22
22
|
getRuntimeServerContext
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-UKWGR5SS.js";
|
|
24
24
|
import {
|
|
25
25
|
asTrimmedString
|
|
26
26
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -304,7 +304,7 @@ var slice = createSliceWithThunks({
|
|
|
304
304
|
const overrides = {};
|
|
305
305
|
if (args.systemPromptOverride !== void 0) overrides.prompt = args.systemPromptOverride;
|
|
306
306
|
if (args.toolsOverride !== void 0) overrides.tools = args.toolsOverride;
|
|
307
|
-
const { _executeModel } = await import("./_executeModel-
|
|
307
|
+
const { _executeModel } = await import("./_executeModel-BPUR2QYH.js");
|
|
308
308
|
return _executeModel(
|
|
309
309
|
{
|
|
310
310
|
isStreaming: args.isStreaming ?? false,
|
|
@@ -325,7 +325,7 @@ var slice = createSliceWithThunks({
|
|
|
325
325
|
* - 循环直到无工具调用或触发其他运行时停止条件
|
|
326
326
|
*/
|
|
327
327
|
runAgent: create.asyncThunk(async (args, thunkApi) => {
|
|
328
|
-
const { runAgentClientLoop } = await import("./runAgentClientLoop-
|
|
328
|
+
const { runAgentClientLoop } = await import("./runAgentClientLoop-TA4SSPHE.js");
|
|
329
329
|
const { content: loopContent, toolCallCount } = await runAgentClientLoop(
|
|
330
330
|
{
|
|
331
331
|
agentKey: args.agentKey,
|
|
@@ -341,7 +341,7 @@ var slice = createSliceWithThunks({
|
|
|
341
341
|
* 聊天轮次流式 Agent 调用
|
|
342
342
|
*/
|
|
343
343
|
streamAgentChatTurn: create.asyncThunk(async (args, thunkApi) => {
|
|
344
|
-
const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-
|
|
344
|
+
const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-X5ENGUIS.js");
|
|
345
345
|
return streamAgentChatTurnHandler(args, thunkApi);
|
|
346
346
|
}),
|
|
347
347
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getActiveDialogKey
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-6D2JFXLY.js";
|
|
4
4
|
import {
|
|
5
5
|
require_date_fns
|
|
6
6
|
} from "./chunk-M76ECQRD.js";
|
|
7
7
|
import {
|
|
8
8
|
patch,
|
|
9
9
|
selectById
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-VRTTFDBM.js";
|
|
11
11
|
import {
|
|
12
12
|
__toESM
|
|
13
13
|
} from "./chunk-4VNS5WPM.js";
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
asOptionalFiniteNumber
|
|
3
3
|
} from "./chunk-WWC7I6TA.js";
|
|
4
|
-
import {
|
|
5
|
-
asNonEmptyStringArray
|
|
6
|
-
} from "./chunk-I42VC5KR.js";
|
|
7
4
|
import {
|
|
8
5
|
asTrimmedString
|
|
9
6
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -2393,6 +2390,17 @@ var require_rambda = __commonJS({
|
|
|
2393
2390
|
}
|
|
2394
2391
|
});
|
|
2395
2392
|
|
|
2393
|
+
// packages/core/stringArray.ts
|
|
2394
|
+
function asNonEmptyStringArray(value) {
|
|
2395
|
+
if (!Array.isArray(value)) return [];
|
|
2396
|
+
return value.filter(
|
|
2397
|
+
(item) => typeof item === "string" && !!item.trim()
|
|
2398
|
+
);
|
|
2399
|
+
}
|
|
2400
|
+
function asTrimmedNonEmptyStringArray(value) {
|
|
2401
|
+
return asNonEmptyStringArray(value).map((item) => item.trim());
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2396
2404
|
// packages/core/toTrimmedString.ts
|
|
2397
2405
|
function toTrimmedString(value) {
|
|
2398
2406
|
return typeof value === "string" ? value.trim() : value == null ? "" : String(value).trim();
|
|
@@ -3169,6 +3177,8 @@ var sanitizeShareData = (data) => {
|
|
|
3169
3177
|
};
|
|
3170
3178
|
|
|
3171
3179
|
export {
|
|
3180
|
+
asNonEmptyStringArray,
|
|
3181
|
+
asTrimmedNonEmptyStringArray,
|
|
3172
3182
|
ulid,
|
|
3173
3183
|
toTrimmedString,
|
|
3174
3184
|
toNonEmptyString,
|
|
@@ -2,17 +2,17 @@ import {
|
|
|
2
2
|
fileKey,
|
|
3
3
|
getFileIdFromKey,
|
|
4
4
|
ulid
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-VMFTFOWF.js";
|
|
6
6
|
import {
|
|
7
7
|
loadFileFromIndexedDb,
|
|
8
8
|
removeAction,
|
|
9
9
|
saveFileToIndexedDb
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-ABQYVJBJ.js";
|
|
11
11
|
import {
|
|
12
12
|
readAction,
|
|
13
13
|
readRequestManager,
|
|
14
14
|
resolveAgentReadServers
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-WV42OMV7.js";
|
|
16
16
|
import {
|
|
17
17
|
asyncThunkCreator,
|
|
18
18
|
buildCreateSlice,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
shouldReplaceLocalWithRemoteRecord,
|
|
33
33
|
shouldReplicateLocalRecord,
|
|
34
34
|
uploadToCurrentServer
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-UKWGR5SS.js";
|
|
36
36
|
import {
|
|
37
37
|
fetchFromClientDb,
|
|
38
38
|
fetchFromServer,
|
|
@@ -712,7 +712,7 @@ var dbSlice = createSliceWithThunks({
|
|
|
712
712
|
// 动态 import 在调用期解析,避开 TDZ/求值顺序问题(同下方 share)。
|
|
713
713
|
read: create.asyncThunk(
|
|
714
714
|
async (payload, thunkApi) => {
|
|
715
|
-
const { readAction: readAction2 } = await import("./read-
|
|
715
|
+
const { readAction: readAction2 } = await import("./read-COE3ZYR6.js");
|
|
716
716
|
return readAction2(payload, thunkApi);
|
|
717
717
|
},
|
|
718
718
|
{
|
|
@@ -786,7 +786,7 @@ var dbSlice = createSliceWithThunks({
|
|
|
786
786
|
// 这里改成动态 import,运行期才解析,彻底断开这条边。
|
|
787
787
|
share: create.asyncThunk(
|
|
788
788
|
async (config, thunkApi) => {
|
|
789
|
-
const { shareResourceAction } = await import("./action-
|
|
789
|
+
const { shareResourceAction } = await import("./action-P4TNFGAD.js");
|
|
790
790
|
return shareResourceAction(config, thunkApi);
|
|
791
791
|
}
|
|
792
792
|
),
|
|
@@ -824,6 +824,7 @@ export {
|
|
|
824
824
|
toTimestampMs,
|
|
825
825
|
resolveFileCategory,
|
|
826
826
|
uploadFileAction,
|
|
827
|
+
readFileContentAction,
|
|
827
828
|
dbAdapter,
|
|
828
829
|
selectById,
|
|
829
830
|
selectEntities,
|
|
@@ -1,21 +1,86 @@
|
|
|
1
1
|
import {
|
|
2
2
|
listUserRecordsFromServers,
|
|
3
3
|
readLiveDbRecordAfterTombstoneMerge
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3YIAR5UI.js";
|
|
5
5
|
import {
|
|
6
6
|
agentRecordHasConfiguredCredential
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QSHEEA5N.js";
|
|
8
8
|
import {
|
|
9
9
|
deriveCredentialGroup,
|
|
10
10
|
toSafeAgentSummary
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-CWQINZEA.js";
|
|
12
12
|
import {
|
|
13
13
|
PUBLIC_AGENT_KEY_PREFIX,
|
|
14
14
|
isOwnedAgentKey,
|
|
15
15
|
ownedAgentKey,
|
|
16
|
+
ownedAgentKeyPrefix,
|
|
16
17
|
parseOwnedAgentId,
|
|
17
18
|
publicAgentKey
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-M2EJHDJP.js";
|
|
20
|
+
|
|
21
|
+
// packages/ai/agent/quotaSnapshot.ts
|
|
22
|
+
function findTightestQuotaWindow(quota, now = Date.now()) {
|
|
23
|
+
if (!quota || !Array.isArray(quota.windows) || quota.windows.length === 0) {
|
|
24
|
+
return void 0;
|
|
25
|
+
}
|
|
26
|
+
let best;
|
|
27
|
+
let bestScore = -Infinity;
|
|
28
|
+
for (const w of quota.windows) {
|
|
29
|
+
let score = 0;
|
|
30
|
+
if (typeof w.utilization === "number" && w.utilization >= 0) {
|
|
31
|
+
score = 500 + Math.min(w.utilization, 1) * 500;
|
|
32
|
+
} else if (typeof w.remaining === "number" && typeof w.limit === "number" && w.limit > 0) {
|
|
33
|
+
const util = Math.max(0, 1 - w.remaining / w.limit);
|
|
34
|
+
score = 500 + util * 500;
|
|
35
|
+
} else if (typeof w.resetAt === "number" && w.resetAt > now) {
|
|
36
|
+
score = 200;
|
|
37
|
+
} else if (typeof w.remaining === "number") {
|
|
38
|
+
score = 100;
|
|
39
|
+
}
|
|
40
|
+
if (score > bestScore) {
|
|
41
|
+
bestScore = score;
|
|
42
|
+
best = w;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return best ?? quota.windows[0];
|
|
46
|
+
}
|
|
47
|
+
function formatQuotaSummary(quota, now = Date.now(), options) {
|
|
48
|
+
const tightest = findTightestQuotaWindow(quota, now);
|
|
49
|
+
if (!tightest) return void 0;
|
|
50
|
+
const compact = options?.compact === true;
|
|
51
|
+
const parts = [];
|
|
52
|
+
if (typeof tightest.utilization === "number") {
|
|
53
|
+
const pct = Math.round(tightest.utilization * 100);
|
|
54
|
+
parts.push(`${pct}%\u5DF2\u7528`);
|
|
55
|
+
} else if (typeof tightest.remaining === "number") {
|
|
56
|
+
if (typeof tightest.limit === "number") {
|
|
57
|
+
parts.push(`${tightest.remaining}/${tightest.limit}${tightest.unit ? ` ${tightest.unit}` : ""}`);
|
|
58
|
+
} else {
|
|
59
|
+
parts.push(`\u4F59${tightest.remaining}${tightest.unit ? ` ${tightest.unit}` : ""}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (compact) return parts.length > 0 ? parts[0] : void 0;
|
|
63
|
+
if (tightest.scope && tightest.scope !== "user" && tightest.scope !== "project" && tightest.scope !== tightest.unit) {
|
|
64
|
+
parts.push(tightest.scope);
|
|
65
|
+
}
|
|
66
|
+
if (typeof tightest.resetAt === "number" && tightest.resetAt > now) {
|
|
67
|
+
const diffSec = Math.round((tightest.resetAt - now) / 1e3);
|
|
68
|
+
if (diffSec < 60) {
|
|
69
|
+
parts.push(`${diffSec}s\u540E\u91CD\u7F6E`);
|
|
70
|
+
} else if (diffSec < 3600) {
|
|
71
|
+
parts.push(`${Math.round(diffSec / 60)}m\u540E\u91CD\u7F6E`);
|
|
72
|
+
} else if (diffSec < 86400) {
|
|
73
|
+
const hours = (diffSec / 3600).toFixed(1).replace(/\.0$/, "");
|
|
74
|
+
parts.push(`${hours}h\u540E\u91CD\u7F6E`);
|
|
75
|
+
} else {
|
|
76
|
+
const days = (diffSec / 86400).toFixed(1).replace(/\.0$/, "");
|
|
77
|
+
parts.push(`${days}d\u540E\u91CD\u7F6E`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (parts.length === 0) return void 0;
|
|
81
|
+
if (parts.length === 1 && parts[0] === tightest.scope) return void 0;
|
|
82
|
+
return parts.join(" \xB7 ");
|
|
83
|
+
}
|
|
19
84
|
|
|
20
85
|
// packages/cli/agentListHelpers.ts
|
|
21
86
|
function parseAgentRecordId(privateKey, explicitId) {
|
|
@@ -66,7 +131,8 @@ function normalizeListedAgent(record) {
|
|
|
66
131
|
...credentialKind !== void 0 ? { credentialKind } : {},
|
|
67
132
|
...typeof record?.apiSource === "string" && record.apiSource ? { apiSource: record.apiSource } : {},
|
|
68
133
|
...typeof record?.cliProvider === "string" && record.cliProvider ? { cliProvider: record.cliProvider } : {},
|
|
69
|
-
...typeof record?.nextAvailableAt === "number" && Number.isFinite(record.nextAvailableAt) ? { nextAvailableAt: record.nextAvailableAt } : {}
|
|
134
|
+
...typeof record?.nextAvailableAt === "number" && Number.isFinite(record.nextAvailableAt) ? { nextAvailableAt: record.nextAvailableAt } : {},
|
|
135
|
+
...record?.quota && typeof record.quota === "object" && Array.isArray(record.quota.windows) ? { quota: record.quota } : {}
|
|
70
136
|
};
|
|
71
137
|
}
|
|
72
138
|
function toSafeListedAgentSummary(agent, options) {
|
|
@@ -96,6 +162,7 @@ function parseAgentListArgs(args) {
|
|
|
96
162
|
publicOnly: args.includes("--public-only"),
|
|
97
163
|
idsOnly: args.includes("--ids-only"),
|
|
98
164
|
scope: readArgValue(args, "--scope"),
|
|
165
|
+
query: readArgValue(args, "--query"),
|
|
99
166
|
showUnavailable: args.includes("--show-unavailable"),
|
|
100
167
|
// --safe 默认输出精简投影(与 server listAgents 一致,防大列表被截断);
|
|
101
168
|
// --verbose 拿回完整字段集排障。
|
|
@@ -105,14 +172,17 @@ function parseAgentListArgs(args) {
|
|
|
105
172
|
async function listLocalCachedAgents(args) {
|
|
106
173
|
const privateRecords = /* @__PURE__ */ new Map();
|
|
107
174
|
const publicKeys = /* @__PURE__ */ new Set();
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
175
|
+
const ownedPrefix = ownedAgentKeyPrefix(args.userId);
|
|
176
|
+
for (const prefix of [ownedPrefix, PUBLIC_AGENT_KEY_PREFIX]) {
|
|
177
|
+
for await (const [key, value] of args.db.iterator({ gte: prefix, lte: `${prefix}\uFFFF` })) {
|
|
178
|
+
if (typeof key !== "string" || !value || typeof value !== "object") continue;
|
|
179
|
+
if (isOwnedAgentKey(key, args.userId)) {
|
|
180
|
+
privateRecords.set(key, { ...value, dbKey: key });
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (key.startsWith(PUBLIC_AGENT_KEY_PREFIX)) {
|
|
184
|
+
publicKeys.add(key);
|
|
185
|
+
}
|
|
116
186
|
}
|
|
117
187
|
}
|
|
118
188
|
const agents = sortListedAgents(
|
|
@@ -234,6 +304,7 @@ async function decorateAgentsWithPublicStatusAcrossServers(args) {
|
|
|
234
304
|
}
|
|
235
305
|
|
|
236
306
|
export {
|
|
307
|
+
formatQuotaSummary,
|
|
237
308
|
normalizeListedAgent,
|
|
238
309
|
toSafeListedAgentSummary,
|
|
239
310
|
parseAgentListArgs,
|