nolo-cli 0.211.0 → 0.213.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{_executeModel-VVQEOY3D.js → _executeModel-CUJLCFWR.js} +57 -54
- package/{action-U235TV4P.js → action-DF5UYSJF.js} +4 -4
- package/{addContentAction-7C76J7ST.js → addContentAction-WERAONNY.js} +9 -9
- package/{addDialogAgentAction-KTYANUEC.js → addDialogAgentAction-7VI7YRML.js} +16 -13
- package/{agentDeleteCommand-WHRU6VDJ.js → agentDeleteCommand-XJORXPGU.js} +80 -76
- package/{agentEmailCommands-ALLHXPW3.js → agentEmailCommands-XTYYFR6Z.js} +85 -80
- package/{agentListCommands-POKMEKMS.js → agentListCommands-OBLRBLHS.js} +237 -115
- package/{agentMachineCommands-WJLZLBPI.js → agentMachineCommands-5FMT3OT5.js} +33 -31
- package/{agentProviderCommands-MN3ABDME.js → agentProviderCommands-Q5O33MED.js} +33 -4
- package/{agentRecordCommands-OULZW3KM.js → agentRecordCommands-ZQ7SVYGG.js} +75 -70
- package/{agentRunCommand-ZNG4LGNQ.js → agentRunCommand-WS7IGO2W.js} +77 -73
- package/{agentRunControl-AF7BMR22.js → agentRunControl-TAMHJQSR.js} +8 -7
- package/{agentRuntimeLocal-YMUHFV5M.js → agentRuntimeLocal-SOO2OPJG.js} +30 -27
- package/{agentSlice-WNGUIMQZ.js → agentSlice-CHR6KOZN.js} +13 -13
- package/{appDeleteCommands-6MXPLAVF.js → appDeleteCommands-GUP6P5YE.js} +34 -32
- package/{appDeployCommands-ERRSVASW.js → appDeployCommands-MH2FX4O5.js} +34 -32
- package/{appDeployStatusCommands-ULICISLI.js → appDeployStatusCommands-SUHN3HPJ.js} +34 -32
- package/{appGetCommands-WYYYWROF.js → appGetCommands-YWDEX6Z4.js} +34 -32
- package/{appListCommands-DFCUCRCV.js → appListCommands-ZQVMLPAY.js} +34 -32
- package/{authCommand-ZJMWXFMA.js → authCommand-PWX2ZNUP.js} +15 -15
- package/{authCommands-WK6E42L2.js → authCommands-HV3EAU3V.js} +2 -2
- package/{builtinSkillRegistry-HH75G5J3.js → builtinSkillRegistry-2QETTQPM.js} +5 -4
- package/{chromeOpsCommands-HEN5AX2J.js → chromeOpsCommands-DIVM2K3T.js} +1 -1
- package/{chunk-TRZP7JZ7.js → chunk-2QHFH3DR.js} +1 -0
- package/{chunk-XE4Q46FF.js → chunk-3CGG2PAL.js} +1 -1
- package/{chunk-YUXQAVRD.js → chunk-3UKL3HPD.js} +251 -14
- package/{chunk-BSISWVB4.js → chunk-4I7ERB7F.js} +1 -1
- package/{chunk-5ORJGHTL.js → chunk-4T2WNOY7.js} +6 -6
- package/{chunk-W5VC7F7V.js → chunk-5MQRBSMW.js} +84 -91
- package/{chunk-YLTLB5A7.js → chunk-6DWMYIUY.js} +7 -6
- package/chunk-6VLJ6YA7.js +11751 -0
- package/{chunk-KSTEXKL6.js → chunk-75XIDFBW.js} +4 -3
- package/{chunk-BTYQAODF.js → chunk-7BT37FK3.js} +196 -308
- package/{chunk-27E2CBBY.js → chunk-7OCO4TDT.js} +1 -1
- package/{chunk-V3M6IXQI.js → chunk-7QTZCMKL.js} +335 -131
- package/chunk-7RFNTILS.js +2213 -0
- package/{chunk-NHQKWPLP.js → chunk-7Y4YTDQF.js} +25 -23
- package/{chunk-CKAHAVMK.js → chunk-A7TFUNZO.js} +35 -25
- package/{chunk-PJNFNEJE.js → chunk-ALQ3657A.js} +28 -2
- package/{chunk-NV572QM3.js → chunk-BBJ22CLB.js} +15 -15
- package/chunk-CJEIOP3E.js +0 -0
- package/{chunk-4WCEC56C.js → chunk-COFEN36Z.js} +2 -2
- package/{chunk-25OB36GU.js → chunk-CRHOO2ZR.js} +4 -4
- package/{chunk-NTSRCTUX.js → chunk-CTPXME7U.js} +2 -2
- package/{chunk-TPCDYNJK.js → chunk-EHGEOAHI.js} +3 -3
- package/{chunk-Y2WUYX4I.js → chunk-EHSZD5OI.js} +1 -1
- package/{chunk-SU3QL7YG.js → chunk-FUGMREBO.js} +2 -2
- package/{chunk-UMEGDH6A.js → chunk-FW6YHHLI.js} +8 -8
- package/chunk-FY7F4Q6X.js +127 -0
- package/{chunk-25M2K6OA.js → chunk-G2BQWAVT.js} +3 -3
- package/chunk-G7MLNNEX.js +84 -0
- package/{chunk-DQLB4NQ3.js → chunk-GPVRUGGY.js} +2 -2
- package/{chunk-RQ22OZD7.js → chunk-H2TJUNCH.js} +1 -1
- package/{chunk-XPHZK3PJ.js → chunk-H4UOTUOX.js} +165 -51
- package/{chunk-CVCRAO6Q.js → chunk-H5HF7TJA.js} +9 -7
- package/{chunk-OP7PTBAJ.js → chunk-H7PPIYWP.js} +9 -9
- package/{chunk-QQM464AL.js → chunk-HPFCI4SK.js} +3 -3
- package/chunk-HRMJUN5J.js +26 -0
- package/{chunk-WI6OGHXJ.js → chunk-HSVBJRF4.js} +5 -5
- package/{chunk-RYWO5AKN.js → chunk-HUBHAQK2.js} +10 -10
- package/{chunk-LKDF3ATR.js → chunk-INUFILG6.js} +1 -1
- package/{chunk-NXCGNS4N.js → chunk-IXNGOHV5.js} +2 -2
- package/{chunk-ET2CWLIJ.js → chunk-J2NHJ7WX.js} +4 -4
- package/{chunk-ECX3NKRD.js → chunk-JY5NGFFH.js} +11 -0
- package/chunk-KC4XDTT3.js +227 -0
- package/{chunk-ADBWFYJD.js → chunk-KFLT5KAD.js} +9 -9
- package/{chunk-PLYWH7XM.js → chunk-KIM6CLW5.js} +7 -7
- package/{chunk-7IYBN7IA.js → chunk-LLRPJECG.js} +22 -13
- package/{chunk-3J3U3KXB.js → chunk-MDB67IWP.js} +5 -5
- package/chunk-MMA3LZ3W.js +105 -0
- package/{chunk-XDMGY5IU.js → chunk-MOIJOHA5.js} +227 -11
- package/{chunk-NLT32XBZ.js → chunk-NJLL224W.js} +2 -2
- package/{chunk-JBOUVTZX.js → chunk-NOKUNJON.js} +15 -4
- package/{chunk-C2XZM3K4.js → chunk-NSAPDIN2.js} +12 -27
- package/{chunk-PAFTGNWA.js → chunk-O2TZF4AI.js} +2 -2
- package/{chunk-UIOEHFF6.js → chunk-OQHIVPG4.js} +1 -0
- package/{chunk-TCTSYFDM.js → chunk-OQPKUBPB.js} +19 -6
- package/{chunk-X4F26D5K.js → chunk-P5L7CXOC.js} +58 -33
- package/{chunk-OXME3PEE.js → chunk-PCLE46CE.js} +1 -1
- package/{chunk-UCPAVEQB.js → chunk-PYRUW7XN.js} +1 -1
- package/{chunk-YXOBCDNW.js → chunk-QG4AOSON.js} +12 -49
- package/{chunk-RXCCWVA2.js → chunk-QHPRUL4O.js} +3 -3
- package/{chunk-I5PBXF7O.js → chunk-R5O4QAWG.js} +1 -1
- package/{chunk-HD3WR3TD.js → chunk-RLBNLZVC.js} +1 -1
- package/{chunk-SN5XE6GQ.js → chunk-RPQXPZZF.js} +4 -4
- package/{chunk-ZOO3WJIE.js → chunk-RSHTSUEG.js} +948 -108
- package/{chunk-6HVBI6TI.js → chunk-RZOV7OMV.js} +12 -229
- package/{chunk-D2MDMY2M.js → chunk-SVYO6AO7.js} +7 -1
- package/{chunk-IIHY4ZAI.js → chunk-TAKB25RM.js} +8 -4
- package/{chunk-ZN5AH4BY.js → chunk-TX5EYMGT.js} +6 -6
- package/{chunk-CKOO42G5.js → chunk-UHJGXRJ4.js} +4 -4
- package/{chunk-M4NTDZG3.js → chunk-UYD5HQ6T.js} +857 -295
- package/{chunk-WTKYP6QO.js → chunk-V5Y3R6BT.js} +114 -6
- package/{chunk-3RQVYR4B.js → chunk-VNYYOX3V.js} +59 -20
- package/{chunk-4LEGTOSR.js → chunk-VO4WSAVP.js} +3 -3
- package/{chunk-LNYHAKBP.js → chunk-W4S457LU.js} +1 -1
- package/{chunk-RIALQUSF.js → chunk-WMTBPBMP.js} +6 -6
- package/chunk-WPORQFYN.js +74 -0
- package/{chunk-Y6M7KJOA.js → chunk-WRYQ35LQ.js} +5 -5
- package/{chunk-YKFP6UGT.js → chunk-WYDI6TGM.js} +17 -17
- package/{chunk-SCYQJPGA.js → chunk-X7SDOJUM.js} +147 -20
- package/chunk-XFYFMTOM.js +92 -0
- package/{chunk-LT3EAHJY.js → chunk-XHQC4PXX.js} +65 -49
- package/{chunk-2WZXXAQD.js → chunk-YB3YZK56.js} +67 -1
- package/{chunk-JKW6LERJ.js → chunk-YJAFKXMU.js} +14 -14
- package/{chunk-GSQNH63I.js → chunk-YTF4WH7J.js} +3 -19
- package/{chunk-DA7CTWT4.js → chunk-YWSEPJ7C.js} +5 -5
- package/{chunk-3V2QMRNN.js → chunk-ZL5RAEEB.js} +3 -3
- package/{chunk-NEZGPBL7.js → chunk-ZNWI6OVT.js} +2 -2
- package/{chunk-MBS6CTZB.js → chunk-ZXOUUDCG.js} +266 -2014
- package/cliAgentConfigHelpers-WJBZQTLW.js +41 -0
- package/{commandRegistry-FI2IOQ3U.js → commandRegistry-W63CYRZJ.js} +91 -87
- package/{contentThunks-5LKNNDGY.js → contentThunks-U7PL5MQD.js} +27 -26
- package/{cooldownCommands-YXLWOXWR.js → cooldownCommands-TIGUHXTD.js} +3 -3
- package/{createAgentAutomationAction-TI4QG4CY.js → createAgentAutomationAction-OLBQDD6R.js} +27 -26
- package/{createDialogAction-TJ3JKLO4.js → createDialogAction-SVH6B3SB.js} +29 -28
- package/{createPageAction-GKXT6WEH.js → createPageAction-F4DIWZ2Z.js} +29 -28
- package/{dbSlice-LPMZ2DGJ.js → dbSlice-BVH2YZPQ.js} +8 -8
- package/{deleteFile-EPUQHKPA.js → deleteFile-5YOEKV4U.js} +4 -4
- package/{dialogCommands-IWPXIZ5P.js → dialogCommands-KHIEPY3M.js} +38 -36
- package/{dialogSlice-ZWNNS7GZ.js → dialogSlice-ZCTDV2PZ.js} +25 -24
- package/{dialogUsageCommand-ZCPPHPJ5.js → dialogUsageCommand-7KCPYGHG.js} +1 -1
- package/{docCreateCommands-HFSPKJSI.js → docCreateCommands-DPMZI7G5.js} +32 -30
- package/{docDeleteCommands-CRL62POH.js → docDeleteCommands-IRQQLUBT.js} +34 -33
- package/{docReadCommands-QOTOX3XW.js → docReadCommands-LK37XH6L.js} +32 -30
- package/{docStore-WYLRB7ED.js → docStore-V2KECILA.js} +11 -11
- package/{docUpdateCommands-7BMH4MCA.js → docUpdateCommands-O6T3HJHH.js} +32 -30
- package/{fetchMessages-YY4SATNR.js → fetchMessages-NR4KNQLO.js} +3 -3
- package/{getPricing-OQXBJ6VZ.js → getPricing-2MNMXEVG.js} +3 -3
- package/{handleSendMessageAction-P27YP2DQ.js → handleSendMessageAction-2PE25WM3.js} +49 -47
- package/hostCredentialCreate-S233UMAP.js +357 -0
- package/index.js +7 -7
- package/{keys-P4ZDOVJW.js → keys-BEGDOTRL.js} +3 -1
- package/{localDialogRead-5VCMQQZF.js → localDialogRead-7NNDVVF7.js} +1 -1
- package/{localRuntimeAdapter-GP6ZSSO3.js → localRuntimeAdapter-KY6WXNBR.js} +82 -75
- package/{machineCommands-6Z6H4BFX.js → machineCommands-Q6HA3IXF.js} +74 -69
- package/{machineWsRunDispatch-F2ZIXMYM.js → machineWsRunDispatch-WWJQ6WR3.js} +74 -69
- package/{memberThunks-YSEFJF47.js → memberThunks-7EDJADWU.js} +9 -9
- package/package.json +1 -1
- package/{projectArchive-PIGEOX3D.js → projectArchive-DRTDIMEV.js} +29 -28
- package/{providerPresetApply-ZYMLQA46.js → providerPresetApply-YXGV6NXB.js} +4 -4
- package/{providerRegistry-E34XWDLJ.js → providerRegistry-S6UL6UNA.js} +4 -4
- package/{read-DIIQBOOO.js → read-4V2RMG7N.js} +4 -4
- package/{readDocTool-HXYGOEA7.js → readDocTool-BH6ATGQO.js} +1 -1
- package/{readlineWorkspace-UG25G7KC.js → readlineWorkspace-2W4WRCOU.js} +437 -217
- package/{removeDialogAgentAction-ALJDUJ2E.js → removeDialogAgentAction-LYAZGNKW.js} +18 -15
- package/{runAgentClientLoop-IO5F7TCZ.js → runAgentClientLoop-J2VQBS2Z.js} +55 -52
- package/{runtimeDoctorCommands-PGAA47G5.js → runtimeDoctorCommands-QAI3MBKQ.js} +6 -6
- package/{secretCommands-ZCZ4KVET.js → secretCommands-LXDWOLZ6.js} +4 -4
- package/{setDialogExtraReferencesAction-O3SVMD5A.js → setDialogExtraReferencesAction-OCRPGPYH.js} +11 -11
- package/{setPrimaryDialogAgentAction-HE7RVFFF.js → setPrimaryDialogAgentAction-HFJDQIBU.js} +19 -16
- package/{settingThunks-BWWJQG4L.js → settingThunks-RAMHMTGM.js} +13 -12
- package/{spaceCommands-UAELIFEI.js → spaceCommands-KVJZVKVO.js} +32 -31
- package/{streamAgentChatTurn-VUKZQYJR.js → streamAgentChatTurn-GHBMJJ6S.js} +63 -60
- package/{switchDialogAgentAction-3VZS7SOS.js → switchDialogAgentAction-EBRMW3RA.js} +16 -13
- package/{tools-VRXJAVYI.js → tools-EWKCPKMS.js} +49 -46
- package/{tuiSummaryLlmCaller-TGCHZLSW.js → tuiSummaryLlmCaller-ALQYUUWB.js} +48 -19
- package/{updateCommands-Q6CYAEYJ.js → updateCommands-ZQYU6SCI.js} +5 -3
- package/{updateDialogTitleAction-MULWCJCW.js → updateDialogTitleAction-5GGMBTDF.js} +40 -72
- package/usageCommand-F4IPVMIZ.js +32 -0
- package/usageRebuildCommand-HAW2AD5N.js +626 -0
- package/{windowsSelfUpdate-XSQVF2GK.js → windowsSelfUpdate-257DV2T6.js} +2 -2
- package/{workloadLifecycle-4BEQHMSD.js → workloadLifecycle-4C42SVBD.js} +1 -0
- package/chunk-4LCOCOR5.js +0 -50
- package/chunk-7AUQ3WCW.js +0 -51
- package/chunk-ZRAU6T47.js +0 -56
- package/{agentFavoriteCommands-GAFEXKKP.js → agentFavoriteCommands-EDK743YA.js} +1 -1
- package/{agentGrantCommands-V5FOQKFD.js → agentGrantCommands-RQWK2TEV.js} +1 -1
- package/{agentPullCommand-2JMJP5BS.js → agentPullCommand-6EM3URVK.js} +1 -1
- package/{chunk-A2ZMIRLN.js → chunk-INN4LTAJ.js} +5 -5
- package/{chunk-PV6JJAUB.js → chunk-TCZHTTUU.js} +8 -8
- package/{chunk-AKE53VMW.js → chunk-ZCWRMUWT.js} +0 -0
- package/{tableCommands-D7WR4QSM.js → tableCommands-MP6VFSVT.js} +3 -3
|
@@ -4,22 +4,28 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
getReadableCliDb
|
|
6
6
|
} from "./chunk-J5JTMQIA.js";
|
|
7
|
+
import {
|
|
8
|
+
BIGMODEL_PROVIDER_TARGET,
|
|
9
|
+
buildCredentialUseGrant,
|
|
10
|
+
verifyCredentialUseGrant
|
|
11
|
+
} from "./chunk-XFYFMTOM.js";
|
|
12
|
+
import {
|
|
13
|
+
clearCliLocalRuntimePreparedAgentCache
|
|
14
|
+
} from "./chunk-UYD5HQ6T.js";
|
|
15
|
+
import {
|
|
16
|
+
readCredentialAvailability
|
|
17
|
+
} from "./chunk-YTF4WH7J.js";
|
|
7
18
|
import {
|
|
8
19
|
buildCreatedAgentRecord,
|
|
9
20
|
buildUpdatedAgentRecord,
|
|
10
21
|
normalizeAgentRecordForOutput,
|
|
11
22
|
parseAgentUpdateArgs,
|
|
23
|
+
readBoundAgentCredential,
|
|
12
24
|
refreshAgentRecordCache,
|
|
13
25
|
resolveAgentRecordFromHybridStore,
|
|
14
26
|
sanitizeAgentRecordForCliOutput,
|
|
15
27
|
writeAgentRecord
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import {
|
|
18
|
-
clearCliLocalRuntimePreparedAgentCache
|
|
19
|
-
} from "./chunk-M4NTDZG3.js";
|
|
20
|
-
import {
|
|
21
|
-
readCredentialAvailability
|
|
22
|
-
} from "./chunk-GSQNH63I.js";
|
|
28
|
+
} from "./chunk-MOIJOHA5.js";
|
|
23
29
|
import {
|
|
24
30
|
resolveCliAgentKeyInput
|
|
25
31
|
} from "./chunk-NBTY7YJF.js";
|
|
@@ -150,7 +156,9 @@ async function runAgentUpdateCommand(args, deps = {}) {
|
|
|
150
156
|
db,
|
|
151
157
|
fetchImpl,
|
|
152
158
|
fallbackFetchImpl,
|
|
153
|
-
authToken
|
|
159
|
+
authToken,
|
|
160
|
+
credentialBroker: deps.credentialBroker,
|
|
161
|
+
hostApproval: deps.hostApproval
|
|
154
162
|
});
|
|
155
163
|
await writeAgentRecord({
|
|
156
164
|
agentKey: built.agentKey,
|
|
@@ -159,7 +167,8 @@ async function runAgentUpdateCommand(args, deps = {}) {
|
|
|
159
167
|
fetchImpl,
|
|
160
168
|
serverUrl: built.serverUrl,
|
|
161
169
|
userId,
|
|
162
|
-
record: built.nextRecord
|
|
170
|
+
record: built.nextRecord,
|
|
171
|
+
remoteIncludeApiKey: !deps.hostApproval?.gateId
|
|
163
172
|
});
|
|
164
173
|
await refreshAgentRecordCache({
|
|
165
174
|
db,
|
|
@@ -223,7 +232,9 @@ async function runAgentCreateCommand(args, deps = {}) {
|
|
|
223
232
|
db,
|
|
224
233
|
fetchImpl,
|
|
225
234
|
fallbackFetchImpl,
|
|
226
|
-
authToken
|
|
235
|
+
authToken,
|
|
236
|
+
credentialBroker: deps.credentialBroker,
|
|
237
|
+
hostApproval: deps.hostApproval
|
|
227
238
|
});
|
|
228
239
|
await writeAgentRecord({
|
|
229
240
|
agentKey: built.agentKey,
|
|
@@ -232,7 +243,8 @@ async function runAgentCreateCommand(args, deps = {}) {
|
|
|
232
243
|
fetchImpl,
|
|
233
244
|
serverUrl: built.serverUrl,
|
|
234
245
|
userId,
|
|
235
|
-
record: built.nextRecord
|
|
246
|
+
record: built.nextRecord,
|
|
247
|
+
remoteIncludeApiKey: !deps.hostApproval?.gateId
|
|
236
248
|
});
|
|
237
249
|
await db.put(built.agentKey, {
|
|
238
250
|
...built.nextRecord,
|
|
@@ -244,16 +256,131 @@ async function runAgentCreateCommand(args, deps = {}) {
|
|
|
244
256
|
let verifyResult;
|
|
245
257
|
if (parsed.verify) {
|
|
246
258
|
try {
|
|
247
|
-
const { verifyCustomProvider } = await import("./agentProviderCommands-
|
|
259
|
+
const { verifyCustomProvider } = await import("./agentProviderCommands-Q5O33MED.js");
|
|
248
260
|
const rec = built.nextRecord;
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
261
|
+
const verifyCredentialRef = typeof rec.credentialRef === "string" && rec.credentialRef.trim() ? rec.credentialRef.trim() : "";
|
|
262
|
+
if (verifyCredentialRef) {
|
|
263
|
+
const providerUrl = rec.customProviderUrl ?? "";
|
|
264
|
+
const hostGateId = (deps.hostApproval?.gateId ?? "").trim();
|
|
265
|
+
const confirmCredentialUse = hostGateId ? void 0 : deps.confirmCredentialUse;
|
|
266
|
+
let grantReason = "host-grant-unavailable: no in-process host approval in this entry point; credential not sent";
|
|
267
|
+
let grantedOrigin;
|
|
268
|
+
if (hostGateId) {
|
|
269
|
+
const gate = {
|
|
270
|
+
id: hostGateId,
|
|
271
|
+
kind: "confirm",
|
|
272
|
+
title: "Use pasted API key for this agent?",
|
|
273
|
+
body: `Target: ${providerUrl}`,
|
|
274
|
+
payload: { agentKey: built.agentKey, credentialRef: verifyCredentialRef }
|
|
275
|
+
};
|
|
276
|
+
const builtGrant = buildCredentialUseGrant({
|
|
277
|
+
gate,
|
|
278
|
+
result: { gateId: hostGateId, status: "completed", output: "confirmed" },
|
|
279
|
+
credentialRef: verifyCredentialRef,
|
|
280
|
+
agentKey: built.agentKey,
|
|
281
|
+
deviceId: deps.deviceId ?? "",
|
|
282
|
+
providerId: BIGMODEL_PROVIDER_TARGET.providerId,
|
|
283
|
+
providerUrl,
|
|
284
|
+
operations: ["verify"],
|
|
285
|
+
persistence: "os-store"
|
|
286
|
+
});
|
|
287
|
+
if (builtGrant.ok) {
|
|
288
|
+
const granted = verifyCredentialUseGrant({
|
|
289
|
+
grant: builtGrant.grant,
|
|
290
|
+
credentialRef: verifyCredentialRef,
|
|
291
|
+
agentKey: built.agentKey,
|
|
292
|
+
requestUrl: providerUrl,
|
|
293
|
+
operation: "verify"
|
|
294
|
+
});
|
|
295
|
+
if (granted.ok) {
|
|
296
|
+
grantedOrigin = builtGrant.grant.allowedOrigin;
|
|
297
|
+
} else {
|
|
298
|
+
grantReason = `host-grant-rejected: ${granted.reason}; credential not sent`;
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
grantReason = `host-grant-rejected: ${builtGrant.reason}; credential not sent`;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (confirmCredentialUse) {
|
|
305
|
+
const gate = {
|
|
306
|
+
id: `credential-use-${built.agentKey}`,
|
|
307
|
+
kind: "confirm",
|
|
308
|
+
title: "Use pasted API key for this agent?",
|
|
309
|
+
body: `Target: ${providerUrl}`,
|
|
310
|
+
payload: { agentKey: built.agentKey, credentialRef: verifyCredentialRef }
|
|
311
|
+
};
|
|
312
|
+
const gateResult = await confirmCredentialUse(gate);
|
|
313
|
+
const builtGrant = buildCredentialUseGrant({
|
|
314
|
+
gate,
|
|
315
|
+
result: gateResult,
|
|
316
|
+
credentialRef: verifyCredentialRef,
|
|
317
|
+
agentKey: built.agentKey,
|
|
318
|
+
deviceId: deps.deviceId ?? "",
|
|
319
|
+
providerId: BIGMODEL_PROVIDER_TARGET.providerId,
|
|
320
|
+
providerUrl,
|
|
321
|
+
operations: ["verify"],
|
|
322
|
+
persistence: "os-store"
|
|
323
|
+
});
|
|
324
|
+
if (builtGrant.ok) {
|
|
325
|
+
const granted = verifyCredentialUseGrant({
|
|
326
|
+
grant: builtGrant.grant,
|
|
327
|
+
credentialRef: verifyCredentialRef,
|
|
328
|
+
agentKey: built.agentKey,
|
|
329
|
+
requestUrl: providerUrl,
|
|
330
|
+
operation: "verify"
|
|
331
|
+
});
|
|
332
|
+
if (granted.ok) {
|
|
333
|
+
grantedOrigin = builtGrant.grant.allowedOrigin;
|
|
334
|
+
} else {
|
|
335
|
+
grantReason = `host-grant-rejected: ${granted.reason}; credential not sent`;
|
|
336
|
+
}
|
|
337
|
+
} else {
|
|
338
|
+
grantReason = `host-grant-rejected: ${builtGrant.reason}; credential not sent`;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
if (!grantedOrigin) {
|
|
342
|
+
if (grantReason.startsWith("host-grant-unavailable")) {
|
|
343
|
+
grantReason = "host-grant-unavailable: no in-process host approval for this credential/target in this entry point; credential not sent";
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (!grantedOrigin) {
|
|
347
|
+
verifyResult = {
|
|
348
|
+
ok: false,
|
|
349
|
+
providerUrl,
|
|
350
|
+
model: rec.model,
|
|
351
|
+
reason: grantReason
|
|
352
|
+
};
|
|
353
|
+
} else {
|
|
354
|
+
const secret = await readBoundAgentCredential(
|
|
355
|
+
verifyCredentialRef,
|
|
356
|
+
deps.credentialBroker
|
|
357
|
+
);
|
|
358
|
+
verifyResult = secret ? await verifyCustomProvider({
|
|
359
|
+
providerUrl,
|
|
360
|
+
apiKey: secret,
|
|
361
|
+
apiKeyHeader: rec.apiKeyHeader,
|
|
362
|
+
model: rec.model,
|
|
363
|
+
prompt: parsed.verifyPrompt,
|
|
364
|
+
fetchImpl,
|
|
365
|
+
// 实际请求目标必须等于授权的 origin;重定向一律拒绝。
|
|
366
|
+
allowedOrigin: grantedOrigin
|
|
367
|
+
}) : {
|
|
368
|
+
ok: false,
|
|
369
|
+
providerUrl,
|
|
370
|
+
model: rec.model,
|
|
371
|
+
reason: "host-grant-ok but credential is not readable from the OS store"
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
} else {
|
|
375
|
+
verifyResult = await verifyCustomProvider({
|
|
376
|
+
providerUrl: rec.customProviderUrl,
|
|
377
|
+
apiKey: rec.apiKey,
|
|
378
|
+
apiKeyHeader: rec.apiKeyHeader,
|
|
379
|
+
model: rec.model,
|
|
380
|
+
prompt: parsed.verifyPrompt,
|
|
381
|
+
fetchImpl
|
|
382
|
+
});
|
|
383
|
+
}
|
|
257
384
|
} catch (error) {
|
|
258
385
|
verifyResult = {
|
|
259
386
|
ok: false,
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// packages/agent-runtime/credentialUseGrant.ts
|
|
2
|
+
var BIGMODEL_PROVIDER_TARGET = {
|
|
3
|
+
providerId: "bigmodel",
|
|
4
|
+
/** 规范化 origin:协议 + 主机 + 端口,不含路径。 */
|
|
5
|
+
allowedOrigin: "https://open.bigmodel.cn"
|
|
6
|
+
};
|
|
7
|
+
function normalizeOrigin(url) {
|
|
8
|
+
const raw = typeof url === "string" ? url.trim() : "";
|
|
9
|
+
if (!raw) return null;
|
|
10
|
+
let parsed;
|
|
11
|
+
try {
|
|
12
|
+
parsed = new URL(raw);
|
|
13
|
+
} catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if (parsed.protocol !== "https:" && parsed.protocol !== "http:") return null;
|
|
17
|
+
if (parsed.username || parsed.password) return null;
|
|
18
|
+
return parsed.origin;
|
|
19
|
+
}
|
|
20
|
+
function buildCredentialUseGrant(input) {
|
|
21
|
+
const { gate, result } = input;
|
|
22
|
+
if (gate.kind !== "confirm") {
|
|
23
|
+
return { ok: false, reason: "grant-requires-confirm-gate" };
|
|
24
|
+
}
|
|
25
|
+
if (!result || result.gateId !== gate.id) {
|
|
26
|
+
return { ok: false, reason: "grant-result-does-not-match-gate" };
|
|
27
|
+
}
|
|
28
|
+
if (result.status !== "completed" || result.output !== "confirmed") {
|
|
29
|
+
return { ok: false, reason: "grant-not-confirmed-by-host" };
|
|
30
|
+
}
|
|
31
|
+
const providerId = (input.providerId ?? "").trim();
|
|
32
|
+
if (providerId !== BIGMODEL_PROVIDER_TARGET.providerId) {
|
|
33
|
+
return { ok: false, reason: "grant-provider-not-allowed" };
|
|
34
|
+
}
|
|
35
|
+
const origin = normalizeOrigin(input.providerUrl);
|
|
36
|
+
if (!origin || origin !== BIGMODEL_PROVIDER_TARGET.allowedOrigin) {
|
|
37
|
+
return { ok: false, reason: "grant-target-origin-not-allowed" };
|
|
38
|
+
}
|
|
39
|
+
const credentialRef = (input.credentialRef ?? "").trim();
|
|
40
|
+
const agentKey = (input.agentKey ?? "").trim();
|
|
41
|
+
const deviceId = (input.deviceId ?? "").trim();
|
|
42
|
+
if (!credentialRef || !agentKey || !deviceId) {
|
|
43
|
+
return { ok: false, reason: "grant-missing-identity" };
|
|
44
|
+
}
|
|
45
|
+
if (!input.operations.includes("verify")) {
|
|
46
|
+
return { ok: false, reason: "grant-missing-verify-operation" };
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
ok: true,
|
|
50
|
+
grant: {
|
|
51
|
+
credentialRef,
|
|
52
|
+
deviceId,
|
|
53
|
+
agentKey,
|
|
54
|
+
providerId,
|
|
55
|
+
allowedOrigin: origin,
|
|
56
|
+
operations: [...input.operations],
|
|
57
|
+
persistence: input.persistence,
|
|
58
|
+
userAuthorizationEventId: gate.id
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function verifyCredentialUseGrant(args) {
|
|
63
|
+
const { grant } = args;
|
|
64
|
+
if (!grant) return { ok: false, reason: "no-grant" };
|
|
65
|
+
if (grant.providerId !== BIGMODEL_PROVIDER_TARGET.providerId) {
|
|
66
|
+
return { ok: false, reason: "grant-provider-not-allowed" };
|
|
67
|
+
}
|
|
68
|
+
if (grant.allowedOrigin !== BIGMODEL_PROVIDER_TARGET.allowedOrigin) {
|
|
69
|
+
return { ok: false, reason: "grant-target-origin-not-allowed" };
|
|
70
|
+
}
|
|
71
|
+
if (grant.credentialRef !== args.credentialRef) {
|
|
72
|
+
return { ok: false, reason: "grant-credential-mismatch" };
|
|
73
|
+
}
|
|
74
|
+
if (grant.agentKey !== args.agentKey) {
|
|
75
|
+
return { ok: false, reason: "grant-agent-mismatch" };
|
|
76
|
+
}
|
|
77
|
+
if (!grant.operations.includes(args.operation)) {
|
|
78
|
+
return { ok: false, reason: "grant-operation-not-allowed" };
|
|
79
|
+
}
|
|
80
|
+
const requestOrigin = normalizeOrigin(args.requestUrl);
|
|
81
|
+
if (!requestOrigin || requestOrigin !== grant.allowedOrigin) {
|
|
82
|
+
return { ok: false, reason: "request-origin-not-allowed" };
|
|
83
|
+
}
|
|
84
|
+
return { ok: true };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export {
|
|
88
|
+
BIGMODEL_PROVIDER_TARGET,
|
|
89
|
+
normalizeOrigin,
|
|
90
|
+
buildCredentialUseGrant,
|
|
91
|
+
verifyCredentialUseGrant
|
|
92
|
+
};
|