nolo-cli 0.98.0-alpha.3 → 0.98.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-MA3D2J4W.js → _executeModel-GJK4ZVU6.js} +74 -67
- package/action-PNPQLJHG.js +20 -0
- package/{addContentAction-O7R66HEX.js → addContentAction-RBOUD7SJ.js} +12 -11
- package/{addDialogAgentAction-74OA7KYP.js → addDialogAgentAction-IODCR6TB.js} +18 -19
- package/{agentDeleteCommand-FHUJH5X4.js → agentDeleteCommand-GHRF6CH5.js} +47 -42
- package/{agentEmailCommands-KNYBWNMA.js → agentEmailCommands-O5BTHYZK.js} +97 -87
- package/agentListCommands-3REEM63V.js +742 -0
- package/{agentMachineCommands-N62I3D5Q.js → agentMachineCommands-2GW3CV7Q.js} +48 -43
- package/{agentProviderCommands-GNPTL5XR.js → agentProviderCommands-IRNZXVGE.js} +1 -1
- package/{agentPullCommand-O5MPVJ5E.js → agentPullCommand-B4T2DJ5H.js} +1 -1
- package/agentRecordCommands-WYQODWZE.js +138 -0
- package/agentRunCommand-KAN65WPY.js +167 -0
- package/{agentRunControl-AVJR4JW4.js → agentRunControl-3HWA2LLQ.js} +2 -2
- package/{agentRuntimeLocal-VXZSDIGT.js → agentRuntimeLocal-IOFBNVIL.js} +48 -39
- package/{agentSlice-65ETD734.js → agentSlice-I45M32KO.js} +14 -13
- package/{appDeleteCommands-PDZ7HQYH.js → appDeleteCommands-SFS6IZEM.js} +46 -41
- package/{appDeployCommands-KLLW32YA.js → appDeployCommands-YZQESVRQ.js} +46 -41
- package/{appDeployStatusCommands-IPNJ445T.js → appDeployStatusCommands-FKUUDCKP.js} +46 -41
- package/{appGetCommands-QA57XGXS.js → appGetCommands-QUE7OQZC.js} +46 -41
- package/{appListCommands-YBTAUFZS.js → appListCommands-QEETFKMH.js} +46 -41
- package/{authCommand-F4EFRRX6.js → authCommand-NHDLY3IB.js} +118 -24
- package/{authCommands-RGOGCPP6.js → authCommands-UDBJVSZU.js} +7 -5
- package/{builtinSkillRegistry-FUAVTRVZ.js → builtinSkillRegistry-MAR5LPAC.js} +10 -8
- package/{chromeCommands-FZYAU75D.js → chromeCommands-K27J4OVZ.js} +124 -28
- package/{chromeOpsCommands-62P2Q2YB.js → chromeOpsCommands-IXRLN57H.js} +4 -3
- package/{chunk-6OZ36FXI.js → chunk-27ONFIEY.js} +22 -4
- package/{chunk-JEDZAO7L.js → chunk-2SYTUTLI.js} +257 -37
- package/{chunk-53HEEOTT.js → chunk-2WJ57RJA.js} +83 -16
- package/{chunk-OIVSQH2O.js → chunk-3BXNTXYI.js} +299 -5
- package/{chunk-ABQYVJBJ.js → chunk-46Y5D2BZ.js} +5 -5
- package/{chunk-EYAQT56M.js → chunk-4DPP773Q.js} +2 -2
- package/{chunk-H62HCIUP.js → chunk-4FFUDT6D.js} +24 -21
- package/chunk-4LCOCOR5.js +50 -0
- package/{chunk-2GRGFCF6.js → chunk-4VJAC32I.js} +2 -1
- package/{chunk-IIVGDG4I.js → chunk-4YSOUKUR.js} +13 -7
- package/{chunk-MC4XLIJ7.js → chunk-523DITKR.js} +1 -1
- package/{chunk-FSX24MR3.js → chunk-5AUJB66Z.js} +550 -515
- package/{chunk-E4MARS3Q.js → chunk-5GVBDNTO.js} +1 -1
- package/chunk-5J3PYNUP.js +255 -0
- package/chunk-5MMAK75Q.js +15 -0
- package/{chunk-JPGCXHNM.js → chunk-5OA5HMTL.js} +1 -1
- package/{chunk-42V6BK2E.js → chunk-62IL3KQV.js} +4 -34
- package/{chunk-3BMYXEUW.js → chunk-6O4IK4V2.js} +1 -1
- package/{chunk-D2QT5FW4.js → chunk-6XDD7N7P.js} +47 -67
- package/{chunk-GQBOR3G6.js → chunk-7KVZ5LDQ.js} +2 -2
- package/{chunk-DNCEALKX.js → chunk-7MMSLEPA.js} +22 -29
- package/chunk-A4SQRTZ6.js +15 -0
- package/{chunk-7S4YWN7P.js → chunk-ADBZWMFB.js} +4 -4
- package/chunk-AGIM7IMJ.js +147 -0
- package/{chunk-5UTFL4QJ.js → chunk-AOTBKDRK.js} +7 -0
- package/{chunk-Q554LLSI.js → chunk-AUDNYVRC.js} +1 -1
- package/{chunk-GZBATRJA.js → chunk-B2DEZY6J.js} +20 -11
- package/chunk-BMQ2MJUK.js +153 -0
- package/{chunk-6YTOJY35.js → chunk-BZ7NPA6G.js} +35 -2
- package/chunk-C4DVDM72.js +13536 -0
- package/chunk-CHOZJMJS.js +78 -0
- package/{chunk-ACTMNVHM.js → chunk-CYSYR67N.js} +1 -1
- package/{chunk-GBRG75BQ.js → chunk-D2MDMY2M.js} +1 -0
- package/chunk-DZ7R5V3Y.js +164 -0
- package/{chunk-3VNWWVKB.js → chunk-E3YWHWCR.js} +50 -18
- package/{chunk-V4MJDUSR.js → chunk-E73ON47R.js} +2 -2
- package/{chunk-UY2NBS4V.js → chunk-EIFYNGU4.js} +24 -5
- package/{chunk-KQ4ONNQD.js → chunk-EKPKW6RM.js} +155 -8
- package/{chunk-TRV2MIDW.js → chunk-EXAJ6DCR.js} +1 -0
- package/{chunk-HJUYAD4A.js → chunk-FJ5BGMNM.js} +5 -5
- package/{chunk-2F7RJC6L.js → chunk-FOXQ7BAB.js} +1 -1
- package/{chunk-TDRTS7QW.js → chunk-FY7DCYW7.js} +88 -17
- package/{chunk-J4MOO56S.js → chunk-GARACBQB.js} +10 -2
- package/{chunk-6VFARHZW.js → chunk-GDFA73QZ.js} +934 -1091
- package/chunk-GMZLP5DV.js +82 -0
- package/{chunk-FDTR4QJ6.js → chunk-H6A6X4EK.js} +32 -1
- package/{chunk-DVINR3PL.js → chunk-HDLLCBRF.js} +1 -1
- package/{chunk-QOKAKDPE.js → chunk-HIM3FCLF.js} +0 -1
- package/{chunk-ONXOABJR.js → chunk-HNGRBWYF.js} +3 -0
- package/{chunk-VLTIYV3X.js → chunk-HP57OUJO.js} +4 -4
- package/{chunk-AD2L6YCC.js → chunk-I76SDF7A.js} +10 -10
- package/{chunk-PELKTR62.js → chunk-I7BCBNWZ.js} +24 -77
- package/{chunk-GPCZ7UXG.js → chunk-K6U4NKFJ.js} +1 -1
- package/{chunk-4OEFYTWL.js → chunk-LDCAFLXD.js} +64 -48
- package/{chunk-SNPMM7H3.js → chunk-LNVJHIGA.js} +18 -20
- package/{chunk-LS2ZANRJ.js → chunk-LOCNXNOU.js} +1 -1
- package/{chunk-5H7KJX7J.js → chunk-LQ4PDQCI.js} +5 -5
- package/{chunk-GABFWSOQ.js → chunk-M33GWZIZ.js} +67 -45
- package/{chunk-PUOC4YRO.js → chunk-M7VLQGQP.js} +11 -0
- package/chunk-NHDMQZJM.js +7881 -0
- package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
- package/{chunk-L5UXH3B2.js → chunk-NNCYNBYV.js} +22 -6
- package/{chunk-FZGV4FGK.js → chunk-NUHHBEJC.js} +378 -187
- package/chunk-NWENLDMM.js +42 -0
- package/{chunk-76WEAXJB.js → chunk-NZWAO6LH.js} +20 -17
- package/chunk-OCZKATRC.js +129 -0
- package/{chunk-N2WELJE7.js → chunk-OU36O6OR.js} +23 -28
- package/chunk-OW4APERY.js +870 -0
- package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
- package/{chunk-TVYSVSA2.js → chunk-P5L7VVMT.js} +11 -9
- package/{chunk-TOP2VXOR.js → chunk-PCF3QU5Q.js} +5 -5
- package/{chunk-WV42OMV7.js → chunk-PTDYOADJ.js} +8 -8
- package/{chunk-6D6VBVEW.js → chunk-SNMQMOD2.js} +80 -14
- package/{chunk-BYMV6QZG.js → chunk-TNIX77YM.js} +4 -0
- package/{chunk-Z77CRGTW.js → chunk-TVCAR26G.js} +1 -1
- package/chunk-TY3TIUJK.js +89 -0
- package/{chunk-I3TQJXQ7.js → chunk-U3C3IA32.js} +9 -2
- package/{chunk-RG6JBBX5.js → chunk-U7XXEI5R.js} +166 -13
- package/{chunk-UZGQNTVW.js → chunk-UA324D4O.js} +8 -6
- package/chunk-UJXNKP5V.js +760 -0
- package/{chunk-UKZDAFYT.js → chunk-UM4PH574.js} +6 -10
- package/{chunk-BLJWCTRL.js → chunk-UVKDJUTL.js} +3 -3
- package/{chunk-ZCYXJSTU.js → chunk-V5OWQOJZ.js} +19 -88
- package/{chunk-YQTQQX2H.js → chunk-V7Y6KRAH.js} +1 -1
- package/{chunk-3DII57IT.js → chunk-VCAQFMVN.js} +1 -1
- package/{chunk-JRQFUXY7.js → chunk-VEYL5MO5.js} +99 -22
- package/chunk-VIWDGTDA.js +8 -0
- package/chunk-VJVNU77E.js +83 -0
- package/{chunk-UKWGR5SS.js → chunk-VY6VFGKR.js} +194 -1144
- package/{chunk-2FA3ITSX.js → chunk-W3RFFFFF.js} +873 -227
- package/{chunk-BP4XNZRM.js → chunk-W72ISAKC.js} +4 -4
- package/{chunk-DHDMC6FO.js → chunk-WCGC6S77.js} +14 -9
- package/{chunk-QDSINZM3.js → chunk-WJ3B6FX6.js} +1 -14
- package/{chunk-V4I3A7DR.js → chunk-WXHAOL7Y.js} +19 -17
- package/{chunk-FUUHG5LT.js → chunk-X2B2C4XD.js} +1 -1
- package/{chunk-HVURBGF3.js → chunk-XFUBXRVI.js} +6 -6
- package/{chunk-O6OSWFZQ.js → chunk-XUWRURDF.js} +6 -0
- package/{chunk-Q67DOFOO.js → chunk-Y3PMXGLH.js} +2 -0
- package/{chunk-QIAVMDHY.js → chunk-YPOPJAKN.js} +4 -4
- package/{chunk-SH43IESU.js → chunk-YUNJN43V.js} +44 -9
- package/chunk-YV25TM3R.js +780 -0
- package/chunk-ZRAU6T47.js +56 -0
- package/commandRegistry-RZNZ37BN.js +833 -0
- package/{contentThunks-Y6FA2TCW.js → contentThunks-DF7ZNCAG.js} +36 -34
- package/{cooldownCommands-REAWYVTY.js → cooldownCommands-ZLEPIB4A.js} +2 -2
- package/{createAgentAutomationAction-JXAFQO5V.js → createAgentAutomationAction-KPMOZ53Y.js} +38 -36
- package/createDialogAction-I2UDVAXN.js +69 -0
- package/{createPageAction-GUQDPKO5.js → createPageAction-IF5JXNKV.js} +45 -42
- package/{chunk-ZMD2CQFC.js → cursorProvider-YGGNMVWX.js} +2496 -9897
- package/{dbSlice-XVWBAGYN.js → dbSlice-Q25STFGJ.js} +11 -10
- package/{deleteFile-YG6QMJLU.js → deleteFile-AJ2EZMHT.js} +7 -6
- package/{dialogCommands-JJDASFIL.js → dialogCommands-LWHIIUQD.js} +49 -45
- package/{dialogSlice-J2YJNE6E.js → dialogSlice-74DFPFRV.js} +40 -33
- package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
- package/{docCreateCommands-OB3X3EQM.js → docCreateCommands-LVXQ6TNZ.js} +48 -43
- package/{docDeleteCommands-WMHRGF22.js → docDeleteCommands-7TVIGCLP.js} +49 -44
- package/{docReadCommands-NWGGLIAZ.js → docReadCommands-KYAXFLQ5.js} +47 -42
- package/{docStore-6KKYKAGQ.js → docStore-2JDRAYXJ.js} +16 -12
- package/{docUpdateCommands-3DDSOLPS.js → docUpdateCommands-TVC5KWPK.js} +48 -43
- package/{fetchMessages-EIU7UFFK.js → fetchMessages-I5ICDDHM.js} +5 -5
- package/{getPricing-LUSEABA6.js → getPricing-NMMFT3YI.js} +4 -4
- package/{handleSendMessageAction-A4XLEEPU.js → handleSendMessageAction-54GY3XOH.js} +110 -86
- package/index.js +87 -884
- package/{localDialogRead-BTFJ4V2I.js → localDialogRead-ZHZ3KXDM.js} +2 -2
- package/{localRuntimeAuthority-6IR6BBXE.js → localRuntimeAuthority-TU6OBC76.js} +9 -6
- package/{localRuntimeDb-SYQGUF4U.js → localRuntimeDb-VKWVOPPI.js} +1 -1
- package/{machineCommands-Y64KAIRW.js → machineCommands-54RNLVJE.js} +91 -81
- package/machineWsRunDispatch-WE3VTD57.js +154 -0
- package/{memberThunks-QGFLFVCI.js → memberThunks-R75S3RWP.js} +20 -18
- package/{models-T3SG6MJ5.js → models-ZPU5EDF4.js} +2 -2
- package/oauthTokenStore-ITEB663N.js +23 -0
- 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-FG6NZ57W.js → providerPresetApply-TEBH7FDX.js} +7 -7
- package/{providerRegistry-757OWH3O.js → providerRegistry-CBJLNCET.js} +11 -7
- package/{read-COE3ZYR6.js → read-SRQMNO26.js} +7 -6
- package/{readDocTool-5USN4A6V.js → readDocTool-RC3JUNJ2.js} +5 -3
- package/{readlineWorkspace-45XNHFXU.js → readlineWorkspace-UK5M5CJI.js} +2704 -2060
- package/{removeDialogAgentAction-IX3MN2ZO.js → removeDialogAgentAction-46XQV5Q7.js} +21 -25
- package/{runAgentClientLoop-ADZRHNG6.js → runAgentClientLoop-MTI5OU2W.js} +75 -69
- package/{runtimeDoctorCommands-X6WDBEQX.js → runtimeDoctorCommands-PIVSBZRZ.js} +4 -4
- package/runtimeModeArgs-2Y7BALTO.js +31 -0
- package/{setDialogExtraReferencesAction-X4HCPNZL.js → setDialogExtraReferencesAction-J4V5ADQF.js} +15 -13
- package/{setPrimaryDialogAgentAction-4GMIQLOD.js → setPrimaryDialogAgentAction-UHHV2QZW.js} +22 -26
- package/{chunk-AFUORTY4.js → settingThunks-PPZZZOWN.js} +226 -940
- package/{skillDiscovery-CYUCJMAG.js → skillDiscovery-ZBU76COE.js} +3 -3
- package/{slateUtils-RIZES3PV.js → slateUtils-NGV2NMKM.js} +1 -1
- package/{spaceCommands-E7MQ4VU2.js → spaceCommands-446WWA73.js} +51 -46
- package/{streamAgentChatTurn-TUP7YO3H.js → streamAgentChatTurn-IANOWAKR.js} +199 -104
- package/{switchDialogAgentAction-N52LRPA3.js → switchDialogAgentAction-A2TMVGAE.js} +18 -19
- package/{tableCommands-O6NWHFKV.js → tableCommands-6U4BMLRR.js} +10 -10
- package/{toolApiClient-QVJ6HDNN.js → toolApiClient-EJT6TMFG.js} +3 -3
- package/tools-WZZYTUNF.js +116 -0
- package/{tuiSummaryLlmCaller-WFRWERGK.js → tuiSummaryLlmCaller-Q65IBDGO.js} +24 -21
- package/{updateCommands-2M74UL7P.js → updateCommands-4EHDLF5J.js} +3 -3
- package/{updateDialogTitleAction-KSWXWWFT.js → updateDialogTitleAction-Z2JTYLXD.js} +82 -44
- package/action-YVYQEAAV.js +0 -31
- package/agentListCommands-GATRXEMT.js +0 -406
- package/agentRecordCommands-GOC5K27T.js +0 -128
- package/agentRunCommand-JP2U3MQF.js +0 -155
- package/browser-image-compression-MFDTD7K6.js +0 -1763
- package/chatQueueReduxAdapter-5QOW43T4.js +0 -186
- package/chunk-DHDVZFNC.js +0 -18885
- package/chunk-M76ECQRD.js +0 -13658
- package/chunk-MEYIRKDN.js +0 -8967
- package/chunk-Q5FJJ6XI.js +0 -103
- package/chunk-S7Z2HMCN.js +0 -25
- package/chunk-Y5GCAMGP.js +0 -9
- package/chunk-YPREESF4.js +0 -225
- package/createDialogAction-O2QABXZF.js +0 -65
- package/machineWsRunDispatch-M366L2LJ.js +0 -144
- package/settingSlice-ZQZVUPKK.js +0 -204
- package/syncMapping-N6RGXGBW.js +0 -437
- package/tools-2VDNDFET.js +0 -110
- 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
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createFileCredentialBroker,
|
|
4
4
|
migrateAgentSecrets,
|
|
5
5
|
normalizeAgentRuntimeToolPolicy
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-XFUBXRVI.js";
|
|
7
7
|
import {
|
|
8
8
|
asRecordOrEmpty
|
|
9
9
|
} from "./chunk-KX6YBIHG.js";
|
|
@@ -11,16 +11,18 @@ import {
|
|
|
11
11
|
patch,
|
|
12
12
|
remove,
|
|
13
13
|
write
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-4FFUDT6D.js";
|
|
15
|
+
import {
|
|
16
|
+
getRuntimeServerContext
|
|
17
|
+
} from "./chunk-UJXNKP5V.js";
|
|
15
18
|
import {
|
|
16
19
|
createAgentKey,
|
|
17
20
|
toTrimmedString
|
|
18
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-3AH7LNUB.js";
|
|
19
22
|
import {
|
|
20
23
|
asyncThunkCreator,
|
|
21
|
-
buildCreateSlice
|
|
22
|
-
|
|
23
|
-
} from "./chunk-UKWGR5SS.js";
|
|
24
|
+
buildCreateSlice
|
|
25
|
+
} from "./chunk-VY6VFGKR.js";
|
|
24
26
|
import {
|
|
25
27
|
asTrimmedString
|
|
26
28
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -304,7 +306,7 @@ var slice = createSliceWithThunks({
|
|
|
304
306
|
const overrides = {};
|
|
305
307
|
if (args.systemPromptOverride !== void 0) overrides.prompt = args.systemPromptOverride;
|
|
306
308
|
if (args.toolsOverride !== void 0) overrides.tools = args.toolsOverride;
|
|
307
|
-
const { _executeModel } = await import("./_executeModel-
|
|
309
|
+
const { _executeModel } = await import("./_executeModel-GJK4ZVU6.js");
|
|
308
310
|
return _executeModel(
|
|
309
311
|
{
|
|
310
312
|
isStreaming: args.isStreaming ?? false,
|
|
@@ -325,7 +327,7 @@ var slice = createSliceWithThunks({
|
|
|
325
327
|
* - 循环直到无工具调用或触发其他运行时停止条件
|
|
326
328
|
*/
|
|
327
329
|
runAgent: create.asyncThunk(async (args, thunkApi) => {
|
|
328
|
-
const { runAgentClientLoop } = await import("./runAgentClientLoop-
|
|
330
|
+
const { runAgentClientLoop } = await import("./runAgentClientLoop-MTI5OU2W.js");
|
|
329
331
|
const { content: loopContent, toolCallCount } = await runAgentClientLoop(
|
|
330
332
|
{
|
|
331
333
|
agentKey: args.agentKey,
|
|
@@ -341,7 +343,7 @@ var slice = createSliceWithThunks({
|
|
|
341
343
|
* 聊天轮次流式 Agent 调用
|
|
342
344
|
*/
|
|
343
345
|
streamAgentChatTurn: create.asyncThunk(async (args, thunkApi) => {
|
|
344
|
-
const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-
|
|
346
|
+
const { streamAgentChatTurnHandler } = await import("./streamAgentChatTurn-IANOWAKR.js");
|
|
345
347
|
return streamAgentChatTurnHandler(args, thunkApi);
|
|
346
348
|
}),
|
|
347
349
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
selectCurrentServer
|
|
3
|
-
} from "./chunk-AFUORTY4.js";
|
|
4
1
|
import {
|
|
5
2
|
patch
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4FFUDT6D.js";
|
|
4
|
+
import {
|
|
5
|
+
selectCurrentServer
|
|
6
|
+
} from "./chunk-NWENLDMM.js";
|
|
7
7
|
import {
|
|
8
8
|
getIsDesktopApp
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HIM3FCLF.js";
|
|
10
10
|
import {
|
|
11
11
|
selectIdentityToken
|
|
12
12
|
} from "./chunk-SEJ5OS6F.js";
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BUILTIN_PLATFORM_AGENT_KEYS
|
|
3
|
-
} from "./chunk-BNGW5ASC.js";
|
|
4
1
|
import {
|
|
5
2
|
getRuntimeServerContext,
|
|
6
3
|
partitionReadServers,
|
|
@@ -10,17 +7,20 @@ import {
|
|
|
10
7
|
scheduleExistingRecordReplication,
|
|
11
8
|
shouldReplaceLocalWithRemoteRecord,
|
|
12
9
|
shouldReplicateLocalRecord
|
|
13
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-UJXNKP5V.js";
|
|
11
|
+
import {
|
|
12
|
+
shouldReplaceWithNextRecord
|
|
13
|
+
} from "./chunk-D2MDMY2M.js";
|
|
14
|
+
import {
|
|
15
|
+
BUILTIN_PLATFORM_AGENT_KEYS
|
|
16
|
+
} from "./chunk-BNGW5ASC.js";
|
|
14
17
|
import {
|
|
15
18
|
fetchFromClientDb,
|
|
16
19
|
fetchFromServer,
|
|
17
20
|
isAbortError,
|
|
18
21
|
isReadTimeoutError,
|
|
19
22
|
logger
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import {
|
|
22
|
-
shouldReplaceWithNextRecord
|
|
23
|
-
} from "./chunk-GBRG75BQ.js";
|
|
23
|
+
} from "./chunk-HIM3FCLF.js";
|
|
24
24
|
import {
|
|
25
25
|
NOLO_CLUSTER_SERVERS,
|
|
26
26
|
normalizeKnownServerOrigin
|
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
_appendRetiredStateBatch,
|
|
3
|
+
loadMemoryVNextCatalog
|
|
4
|
+
} from "./chunk-TY3TIUJK.js";
|
|
1
5
|
import {
|
|
2
6
|
resolveMachineId
|
|
3
7
|
} from "./chunk-ESHYE7WU.js";
|
|
4
8
|
import {
|
|
5
9
|
getDefaultCliLocalRuntimeDb
|
|
6
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-FOXQ7BAB.js";
|
|
11
|
+
import {
|
|
12
|
+
resolveAuthTokenFromEnv
|
|
13
|
+
} from "./chunk-A7GB5UGH.js";
|
|
14
|
+
import {
|
|
15
|
+
DEFAULT_NOLO_SERVER_URL
|
|
16
|
+
} from "./chunk-OLZBQWZU.js";
|
|
7
17
|
import {
|
|
8
18
|
buildCliRuntimeEnv,
|
|
9
19
|
clearProfileAuthToken,
|
|
@@ -12,20 +22,14 @@ import {
|
|
|
12
22
|
getProfileTokens,
|
|
13
23
|
loadProfileConfig,
|
|
14
24
|
saveDefaultProfile
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import {
|
|
17
|
-
resolveAuthTokenFromEnv
|
|
18
|
-
} from "./chunk-A7GB5UGH.js";
|
|
19
|
-
import {
|
|
20
|
-
DEFAULT_NOLO_SERVER_URL
|
|
21
|
-
} from "./chunk-OLZBQWZU.js";
|
|
25
|
+
} from "./chunk-TNIX77YM.js";
|
|
22
26
|
import {
|
|
23
27
|
asTrimmedNonEmptyStringArray,
|
|
24
28
|
createMemoryKey,
|
|
25
29
|
createMemoryOwnerIndexKey,
|
|
26
30
|
createMemorySubjectKindIndexKey,
|
|
27
31
|
memoryOwnerRange
|
|
28
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-3AH7LNUB.js";
|
|
29
33
|
import {
|
|
30
34
|
asTrimmedString
|
|
31
35
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -39,6 +43,29 @@ import { stdin as input, stdout as output } from "node:process";
|
|
|
39
43
|
import { spawn } from "node:child_process";
|
|
40
44
|
|
|
41
45
|
// packages/ai/memory/delete.ts
|
|
46
|
+
var VNEXT_STATE_ID_PREFIX = "vnext-state-";
|
|
47
|
+
var toVNextMemoryItem = (state, owner) => ({
|
|
48
|
+
id: `${VNEXT_STATE_ID_PREFIX}${state.id}`,
|
|
49
|
+
ownerType: owner.ownerType,
|
|
50
|
+
ownerId: owner.ownerId,
|
|
51
|
+
visibility: "private",
|
|
52
|
+
subjectType: "user",
|
|
53
|
+
subjectId: owner.ownerId,
|
|
54
|
+
kind: "semantic",
|
|
55
|
+
content: state.text.trim(),
|
|
56
|
+
createdAt: state.createdAt,
|
|
57
|
+
lastActivatedAt: state.createdAt,
|
|
58
|
+
activationCount: 1,
|
|
59
|
+
importance: 0.9,
|
|
60
|
+
confidence: 0.9,
|
|
61
|
+
resident: state.facet === "preference" || state.facet === "style"
|
|
62
|
+
});
|
|
63
|
+
var matchesVNextFilters = (state, idSet, contentSub) => {
|
|
64
|
+
if (!idSet && !contentSub) return false;
|
|
65
|
+
if (idSet && !idSet.has(`${VNEXT_STATE_ID_PREFIX}${state.id}`)) return false;
|
|
66
|
+
if (contentSub && !state.text.toLowerCase().includes(contentSub)) return false;
|
|
67
|
+
return true;
|
|
68
|
+
};
|
|
42
69
|
function hasExplicitDeleteFilters(filters) {
|
|
43
70
|
return Boolean(
|
|
44
71
|
filters.ids && filters.ids.length > 0 || typeof filters.contentSubstring === "string" && filters.contentSubstring.trim().length > 0 || filters.tags && filters.tags.length > 0 || typeof filters.sourceDialogId === "string" && filters.sourceDialogId.trim().length > 0 || typeof filters.patternKeyPrefix === "string" && filters.patternKeyPrefix.trim().length > 0 || filters.facets && filters.facets.length > 0 || typeof filters.subjectId === "string" && filters.subjectId.trim().length > 0
|
|
@@ -127,8 +154,32 @@ var deleteMemoriesForOwnerFromDb = async (db, owner, filters = {}) => {
|
|
|
127
154
|
matchedItems.push(item);
|
|
128
155
|
if (matchedItems.length >= limit) break;
|
|
129
156
|
}
|
|
157
|
+
const idSet = normalizeSet(filters.ids);
|
|
158
|
+
const contentSub = asTrimmedString(filters.contentSubstring).toLowerCase();
|
|
159
|
+
const vnextStateIdsToRetire = [];
|
|
160
|
+
const vnextStatesToRetire = [];
|
|
161
|
+
const vnextMatchedItems = [];
|
|
162
|
+
let vnextPrincipalId = null;
|
|
163
|
+
const hasScopingFilters = Boolean(
|
|
164
|
+
normalizeSet(filters.kinds) || normalizeSet(filters.facets) || normalizeSet(filters.tags) || asTrimmedString(filters.subjectType) || asTrimmedString(filters.subjectId) || asTrimmedString(filters.patternKeyPrefix) || asTrimmedString(filters.sourceDialogId)
|
|
165
|
+
);
|
|
166
|
+
const canMatchVNext = !hasScopingFilters && (contentSub.length > 0 || idSet !== null && [...idSet].some((id) => id.startsWith(VNEXT_STATE_ID_PREFIX)));
|
|
167
|
+
if (canMatchVNext) {
|
|
168
|
+
vnextPrincipalId = `${owner.ownerType}:${encodeURIComponent(owner.ownerId)}`;
|
|
169
|
+
const catalog = await loadMemoryVNextCatalog(db, vnextPrincipalId);
|
|
170
|
+
for (const state of catalog.states) {
|
|
171
|
+
if (matchedItems.length >= limit) break;
|
|
172
|
+
if (state.retiredAt) continue;
|
|
173
|
+
if (!matchesVNextFilters(state, idSet, contentSub)) continue;
|
|
174
|
+
vnextStateIdsToRetire.push(state.id);
|
|
175
|
+
vnextStatesToRetire.push(state);
|
|
176
|
+
const projected = toVNextMemoryItem(state, owner);
|
|
177
|
+
vnextMatchedItems.push(projected);
|
|
178
|
+
matchedItems.push(projected);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
130
181
|
if (matchedItems.length === 0) {
|
|
131
|
-
return { deletedCount: 0, deletedIds: [], matchedItems: [] };
|
|
182
|
+
return { deletedCount: 0, deletedIds: [], retiredIds: [], matchedItems: [] };
|
|
132
183
|
}
|
|
133
184
|
const token = generateMemoryDeletionToken(
|
|
134
185
|
owner.ownerId,
|
|
@@ -138,6 +189,7 @@ var deleteMemoriesForOwnerFromDb = async (db, owner, filters = {}) => {
|
|
|
138
189
|
return {
|
|
139
190
|
deletedCount: 0,
|
|
140
191
|
deletedIds: [],
|
|
192
|
+
retiredIds: [],
|
|
141
193
|
matchedItems,
|
|
142
194
|
deletionToken: token
|
|
143
195
|
};
|
|
@@ -147,14 +199,28 @@ var deleteMemoriesForOwnerFromDb = async (db, owner, filters = {}) => {
|
|
|
147
199
|
"deletionToken mismatch: memory dataset changed since preview; please rerun dry-run preview before confirming."
|
|
148
200
|
);
|
|
149
201
|
}
|
|
150
|
-
const
|
|
151
|
-
|
|
152
|
-
|
|
202
|
+
const vnextMatchedIdSet = new Set(
|
|
203
|
+
vnextStateIdsToRetire.map((stateId) => `${VNEXT_STATE_ID_PREFIX}${stateId}`)
|
|
204
|
+
);
|
|
205
|
+
const legacyItems = matchedItems.filter((item) => !vnextMatchedIdSet.has(item.id));
|
|
206
|
+
const shouldRetireVNext = vnextStatesToRetire.length > 0;
|
|
207
|
+
if (legacyItems.length > 0 || shouldRetireVNext) {
|
|
208
|
+
const batch = db.batch();
|
|
209
|
+
for (const item of legacyItems) {
|
|
210
|
+
deleteMemoryItemWithIndexesInBatch(batch, item);
|
|
211
|
+
}
|
|
212
|
+
if (shouldRetireVNext) {
|
|
213
|
+
const nowIso = (/* @__PURE__ */ new Date()).toISOString();
|
|
214
|
+
for (const state of vnextStatesToRetire) {
|
|
215
|
+
_appendRetiredStateBatch(batch, { ...state, retiredAt: nowIso });
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
await batch.write();
|
|
153
219
|
}
|
|
154
|
-
await batch.write();
|
|
155
220
|
return {
|
|
156
221
|
deletedCount: matchedItems.length,
|
|
157
222
|
deletedIds: matchedItems.map((item) => item.id),
|
|
223
|
+
retiredIds: vnextMatchedItems.map((item) => item.id),
|
|
158
224
|
matchedItems,
|
|
159
225
|
deletionToken: token
|
|
160
226
|
};
|
|
@@ -308,6 +308,8 @@ function saveProfileOAuthSync(provider, sync, path = getDefaultProfileConfigPath
|
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
export {
|
|
311
|
+
normalizeProfileServerUrl,
|
|
312
|
+
isProtectedHomeProfileWrite,
|
|
311
313
|
getDefaultProfileConfigPath,
|
|
312
314
|
loadProfileConfig,
|
|
313
315
|
clearProfileAuthToken,
|
|
@@ -319,6 +321,8 @@ export {
|
|
|
319
321
|
getCurrentProfile,
|
|
320
322
|
saveProfileLocale,
|
|
321
323
|
getAgentSelectionAuditPath,
|
|
324
|
+
redactArgvSecrets,
|
|
325
|
+
appendAgentSelectionAudit,
|
|
322
326
|
readLastAgentSelectionAudit,
|
|
323
327
|
saveProfileAgentSelection,
|
|
324
328
|
getProfileOAuthSync,
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isLevelNotFoundError
|
|
3
|
+
} from "./chunk-OW765XBU.js";
|
|
4
|
+
|
|
5
|
+
// packages/ai/memory/vnext/store.ts
|
|
6
|
+
var enc = (value) => encodeURIComponent(value).replace(/-/g, "%2D");
|
|
7
|
+
var rangeOf = (prefix) => ({ gte: prefix, lte: `${prefix}\uFFFF` });
|
|
8
|
+
var entityKey = (ownerId, id) => `mem2-e-${enc(ownerId)}-${enc(id)}`;
|
|
9
|
+
var entityOwnerPrefix = (ownerId) => `mem2-e-${enc(ownerId)}-`;
|
|
10
|
+
var stateKey = (ownerId, id) => `mem2-s-${enc(ownerId)}-${enc(id)}`;
|
|
11
|
+
var stateEntityIndexKey = (ownerId, entityId, stateId) => `mem2-si-${enc(ownerId)}-${enc(entityId)}-${enc(stateId)}`;
|
|
12
|
+
var stateEntityIndexPrefix = (ownerId, entityId) => `mem2-si-${enc(ownerId)}-${enc(entityId)}-`;
|
|
13
|
+
var evidenceKey = (ownerId, id) => `mem2-v-${enc(ownerId)}-${enc(id)}`;
|
|
14
|
+
var relationKey = (ownerId, id) => `mem2-r-${enc(ownerId)}-${enc(id)}`;
|
|
15
|
+
var relationFromIndexKey = (ownerId, from, relationId) => `mem2-rf-${enc(ownerId)}-${enc(from)}-${enc(relationId)}`;
|
|
16
|
+
var relationToIndexKey = (ownerId, to, relationId) => `mem2-rt-${enc(ownerId)}-${enc(to)}-${enc(relationId)}`;
|
|
17
|
+
var readIndexed = async (db, prefix) => {
|
|
18
|
+
const refs = [];
|
|
19
|
+
for await (const [, value] of db.iterator({ ...rangeOf(prefix), reverse: false })) {
|
|
20
|
+
if (typeof value?.key === "string") refs.push(value.key);
|
|
21
|
+
}
|
|
22
|
+
const rows = await Promise.all(refs.map((key) => db.get(key).catch(() => null)));
|
|
23
|
+
return rows.filter((row) => !!row);
|
|
24
|
+
};
|
|
25
|
+
var getMemoryEntityVNext = async (db, ownerId, entityId) => db.get(entityKey(ownerId, entityId)).catch(() => null);
|
|
26
|
+
var listMemoryEntitiesVNext = async (db, ownerId) => {
|
|
27
|
+
const rows = [];
|
|
28
|
+
for await (const [, value] of db.iterator({
|
|
29
|
+
...rangeOf(entityOwnerPrefix(ownerId)),
|
|
30
|
+
reverse: false
|
|
31
|
+
})) {
|
|
32
|
+
if (value) rows.push(value);
|
|
33
|
+
}
|
|
34
|
+
return rows;
|
|
35
|
+
};
|
|
36
|
+
var loadMemoryVNextCatalog = async (db, ownerId) => {
|
|
37
|
+
const entities = await listMemoryEntitiesVNext(db, ownerId);
|
|
38
|
+
const states = (await Promise.all(entities.map((entity) => listMemoryStatesForEntityVNext(db, ownerId, entity.id)))).flat();
|
|
39
|
+
return { entities, states };
|
|
40
|
+
};
|
|
41
|
+
var getMemoryStateVNext = async (db, ownerId, stateId) => db.get(stateKey(ownerId, stateId)).catch(() => null);
|
|
42
|
+
var listMemoryStatesForEntityVNext = (db, ownerId, entityId) => readIndexed(db, stateEntityIndexPrefix(ownerId, entityId));
|
|
43
|
+
var putMemoryEvidenceVNext = async (db, evidence) => {
|
|
44
|
+
await db.put(evidenceKey(evidence.ownerId, evidence.id), evidence);
|
|
45
|
+
};
|
|
46
|
+
var getMemoryEvidenceVNext = async (db, ownerId, evidenceId) => db.get(evidenceKey(ownerId, evidenceId)).catch(() => null);
|
|
47
|
+
var getMemoryEvidenceVNextStrict = async (db, ownerId, evidenceId) => {
|
|
48
|
+
try {
|
|
49
|
+
return await db.get(evidenceKey(ownerId, evidenceId));
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (isLevelNotFoundError(error)) return null;
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var _appendEntityBatch = (batch, entity) => {
|
|
56
|
+
batch.put(entityKey(entity.ownerId, entity.id), entity);
|
|
57
|
+
};
|
|
58
|
+
var _appendEvidenceBatch = (batch, evidence) => {
|
|
59
|
+
batch.put(evidenceKey(evidence.ownerId, evidence.id), evidence);
|
|
60
|
+
};
|
|
61
|
+
var _appendStateBatch = (batch, state) => {
|
|
62
|
+
const key = stateKey(state.ownerId, state.id);
|
|
63
|
+
batch.put(key, state);
|
|
64
|
+
batch.put(stateEntityIndexKey(state.ownerId, state.entityId, state.id), { key });
|
|
65
|
+
};
|
|
66
|
+
var _appendRetiredStateBatch = (batch, state) => {
|
|
67
|
+
batch.put(stateKey(state.ownerId, state.id), state);
|
|
68
|
+
};
|
|
69
|
+
var _appendRelationBatch = (batch, relation) => {
|
|
70
|
+
const key = relationKey(relation.ownerId, relation.id);
|
|
71
|
+
batch.put(key, relation);
|
|
72
|
+
batch.put(relationFromIndexKey(relation.ownerId, relation.from, relation.id), { key });
|
|
73
|
+
batch.put(relationToIndexKey(relation.ownerId, relation.to, relation.id), { key });
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
getMemoryEntityVNext,
|
|
78
|
+
loadMemoryVNextCatalog,
|
|
79
|
+
getMemoryStateVNext,
|
|
80
|
+
listMemoryStatesForEntityVNext,
|
|
81
|
+
putMemoryEvidenceVNext,
|
|
82
|
+
getMemoryEvidenceVNext,
|
|
83
|
+
getMemoryEvidenceVNextStrict,
|
|
84
|
+
_appendEntityBatch,
|
|
85
|
+
_appendEvidenceBatch,
|
|
86
|
+
_appendStateBatch,
|
|
87
|
+
_appendRetiredStateBatch,
|
|
88
|
+
_appendRelationBatch
|
|
89
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isAgentRunTerminalStatus
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-E3YWHWCR.js";
|
|
4
4
|
import {
|
|
5
5
|
isCompiledBinary,
|
|
6
6
|
resolveCliEntrypointPath
|
|
@@ -1056,7 +1056,14 @@ function defaultGetProcessStartTime(pid) {
|
|
|
1056
1056
|
const output = nodeExecFileSync("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
1057
1057
|
encoding: "utf8",
|
|
1058
1058
|
stdio: ["ignore", "pipe", "ignore"],
|
|
1059
|
-
timeout: 1e3
|
|
1059
|
+
timeout: 1e3,
|
|
1060
|
+
// `ps -o lstart` 的日期串随系统 locale 变化:
|
|
1061
|
+
// LANG=en_US.UTF-8 → "Thu Oct 8 08:54:18 2026"(new Date 可解析)
|
|
1062
|
+
// LANG=zh_CN.UTF-8 → "四 10月 8 08:54:18 2026"(new Date → NaN → null)
|
|
1063
|
+
// 这会让 isPidReused 的结论依赖调用者环境:同一条 run 记录在英文
|
|
1064
|
+
// locale 下被判 pid reused → orphaned,中文 locale 下不判。强制 C
|
|
1065
|
+
// locale 让输出恒为可解析的英文格式,结果与 locale 无关。
|
|
1066
|
+
env: { ...process.env, LC_ALL: "C", LANG: "C" }
|
|
1060
1067
|
}).trim();
|
|
1061
1068
|
if (!output) return null;
|
|
1062
1069
|
const d = new Date(output);
|
|
@@ -3,21 +3,28 @@ import {
|
|
|
3
3
|
} from "./chunk-YYLHWIW6.js";
|
|
4
4
|
import {
|
|
5
5
|
compareAgentSelection
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4YSOUKUR.js";
|
|
7
|
+
import {
|
|
8
|
+
isAgentUnavailableNow
|
|
9
|
+
} from "./chunk-H6A6X4EK.js";
|
|
10
|
+
import {
|
|
11
|
+
isSubscriptionEndpoint,
|
|
12
|
+
isSubscriptionOAuthCredential
|
|
13
|
+
} from "./chunk-EKPKW6RM.js";
|
|
7
14
|
import {
|
|
8
15
|
isAntigravityOAuthAgent
|
|
9
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-UA324D4O.js";
|
|
10
17
|
import {
|
|
11
18
|
getModelAbility
|
|
12
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-CYSYR67N.js";
|
|
20
|
+
import {
|
|
21
|
+
fnv1a32Hex
|
|
22
|
+
} from "./chunk-UJXNKP5V.js";
|
|
13
23
|
import {
|
|
14
24
|
isOwnedAgentKey,
|
|
15
25
|
ownedAgentKey,
|
|
16
26
|
publicAgentKey
|
|
17
27
|
} from "./chunk-M2EJHDJP.js";
|
|
18
|
-
import {
|
|
19
|
-
fnv1a32Hex
|
|
20
|
-
} from "./chunk-UKWGR5SS.js";
|
|
21
28
|
|
|
22
29
|
// packages/ai/agent/agentBilling.ts
|
|
23
30
|
function resolveBillingSource(candidate) {
|
|
@@ -36,6 +43,9 @@ function resolveBillingSource(candidate) {
|
|
|
36
43
|
}
|
|
37
44
|
if (candidate?.isOAuth === true || candidate?.billingSource === "user_subscription" || candidate?.apiSource === "oauth" || isOAuthApiKeyRef(candidate?.apiKeyRef)) return "user_subscription";
|
|
38
45
|
if (candidate?.apiSource === "custom" || candidate?.billingSource === "user_api") {
|
|
46
|
+
if (isSubscriptionEndpoint(candidate?.customProviderUrl) || isSubscriptionOAuthCredential(candidate?.apiKeyRef)) {
|
|
47
|
+
return "user_subscription";
|
|
48
|
+
}
|
|
39
49
|
return "user_api";
|
|
40
50
|
}
|
|
41
51
|
return "platform_credits";
|
|
@@ -227,6 +237,16 @@ function deriveCredentialGroup(ref) {
|
|
|
227
237
|
credentialKind: "api-key"
|
|
228
238
|
};
|
|
229
239
|
}
|
|
240
|
+
function deriveCustomProviderCredentialGroup(userId, customProviderUrl) {
|
|
241
|
+
if (typeof customProviderUrl !== "string" || !customProviderUrl.trim()) {
|
|
242
|
+
return void 0;
|
|
243
|
+
}
|
|
244
|
+
const basis = `${userId ?? ""}|${customProviderUrl.trim().toLowerCase()}`;
|
|
245
|
+
return {
|
|
246
|
+
credentialGroup: `custom-${fnv1a32Hex(basis)}`,
|
|
247
|
+
credentialKind: "api-key"
|
|
248
|
+
};
|
|
249
|
+
}
|
|
230
250
|
function summarizeCredentialGroups(agents, now = Date.now()) {
|
|
231
251
|
const groups = /* @__PURE__ */ new Map();
|
|
232
252
|
for (const agent of agents) {
|
|
@@ -327,6 +347,15 @@ function resolveFavoriteStatus(record, options) {
|
|
|
327
347
|
}
|
|
328
348
|
return { isFavorite: false, favoritedAt: null };
|
|
329
349
|
}
|
|
350
|
+
function isOwnedAgentRecord(record, userId) {
|
|
351
|
+
if (!userId) return false;
|
|
352
|
+
if (typeof record?.userId === "string" && record.userId === userId || typeof record?.ownerId === "string" && record.ownerId === userId) {
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
355
|
+
return [record?.dbKey, record?.privateKey].some(
|
|
356
|
+
(key) => isOwnedAgentKey(key, userId)
|
|
357
|
+
);
|
|
358
|
+
}
|
|
330
359
|
function toSafeAgentSummary(record, options) {
|
|
331
360
|
const rawId = parseAgentRecordId(
|
|
332
361
|
typeof record?.privateKey === "string" ? record.privateKey : record?.dbKey,
|
|
@@ -356,12 +385,13 @@ function toSafeAgentSummary(record, options) {
|
|
|
356
385
|
const isPublic = record?.isPublic === true || record?.isPublicFlag === true || record?.publicRecordExists === true;
|
|
357
386
|
const updatedAt = safeTimestamp(record?.updatedAt ?? record?.createdAt ?? record?.created);
|
|
358
387
|
const nextAvailableAt = typeof record?.nextAvailableAt === "number" && Number.isFinite(record.nextAvailableAt) ? record.nextAvailableAt : void 0;
|
|
388
|
+
const rawQuota = record?.quota;
|
|
389
|
+
const quota = rawQuota && typeof rawQuota === "object" && Array.isArray(rawQuota.windows) && typeof rawQuota.observedAt === "number" && Number.isFinite(rawQuota.observedAt) ? rawQuota : void 0;
|
|
359
390
|
const currentUserId = options?.userId;
|
|
360
|
-
const isOwnedByRecord = Boolean(currentUserId) && (typeof record?.userId === "string" && record.userId === currentUserId || typeof record?.ownerId === "string" && record.ownerId === currentUserId);
|
|
361
391
|
const ownedKey = currentUserId ? [record?.dbKey, record?.privateKey].find(
|
|
362
392
|
(key) => isOwnedAgentKey(key, currentUserId)
|
|
363
393
|
) : void 0;
|
|
364
|
-
const isOwned =
|
|
394
|
+
const isOwned = isOwnedAgentRecord(record, currentUserId);
|
|
365
395
|
const isOAuth = isOAuthApiKeyRef(record?.apiKeyRef);
|
|
366
396
|
const billingSource = resolveBillingSource({
|
|
367
397
|
...record,
|
|
@@ -418,6 +448,7 @@ function toSafeAgentSummary(record, options) {
|
|
|
418
448
|
isOwned,
|
|
419
449
|
isOAuth,
|
|
420
450
|
...nextAvailableAt !== void 0 ? { nextAvailableAt } : {},
|
|
451
|
+
...quota !== void 0 ? { quota } : {},
|
|
421
452
|
...credentialGroup !== void 0 ? { credentialGroup } : {},
|
|
422
453
|
...credentialKind !== void 0 ? { credentialKind } : {},
|
|
423
454
|
// 「未知 ≠ 独立」:无 credentialGroup 时显式 credentialed:false,调用方
|
|
@@ -448,6 +479,8 @@ var COMPACT_AGENT_SUMMARY_FIELDS = [
|
|
|
448
479
|
// 决策信息(CLI --show-unavailable 场景);默认列表已把这类 agent 过滤掉,
|
|
449
480
|
// 所以通常根本不占字节。
|
|
450
481
|
"nextAvailableAt",
|
|
482
|
+
// 额度快照:只有上游真上报过窗口的 agent 才带(通常是小对象)。
|
|
483
|
+
"quota",
|
|
451
484
|
"credentialGroup",
|
|
452
485
|
"credentialKind",
|
|
453
486
|
"credentialed"
|
|
@@ -481,6 +514,7 @@ var UNAVAILABLE_AGENT_SUMMARY_FIELDS = [
|
|
|
481
514
|
"isOAuth",
|
|
482
515
|
"isOwned",
|
|
483
516
|
"nextAvailableAt",
|
|
517
|
+
"quota",
|
|
484
518
|
"favoritedAt",
|
|
485
519
|
"updatedAt"
|
|
486
520
|
];
|
|
@@ -500,12 +534,131 @@ function toUnavailableAgentSummary(summary) {
|
|
|
500
534
|
return item;
|
|
501
535
|
}
|
|
502
536
|
|
|
537
|
+
// packages/ai/agent/agentDiscovery.ts
|
|
538
|
+
function isPreferredAgent(agent) {
|
|
539
|
+
return agent.isFavorite === true || agent.isOwned === true || agent.isOAuth === true || agent.billingSource === "user_subscription" || agent.billingSource === "user_api" || agent.billingSource === "local";
|
|
540
|
+
}
|
|
541
|
+
function isPublicDiscoveryAgent(agent) {
|
|
542
|
+
return agent.isPublic === true && !isPreferredAgent(agent);
|
|
543
|
+
}
|
|
544
|
+
function resolveDiscoveryScope(args) {
|
|
545
|
+
const rawScope = typeof args?.scope === "string" ? args.scope.trim().toLowerCase() : void 0;
|
|
546
|
+
const hasScope = rawScope !== void 0 && rawScope !== "";
|
|
547
|
+
const hasPublicOnly = typeof args?.publicOnly === "boolean";
|
|
548
|
+
const publicOnly = args?.publicOnly === true;
|
|
549
|
+
if (hasScope) {
|
|
550
|
+
if (rawScope !== "preferred" && rawScope !== "public" && rawScope !== "all") {
|
|
551
|
+
throw new Error(`Invalid scope '${args?.scope}': must be 'preferred', 'public', or 'all'.`);
|
|
552
|
+
}
|
|
553
|
+
const scope = rawScope;
|
|
554
|
+
if (hasPublicOnly) {
|
|
555
|
+
if (publicOnly && scope !== "public") {
|
|
556
|
+
throw new Error(
|
|
557
|
+
`Conflicting arguments: scope='${args?.scope}' conflicts with publicOnly=true.`
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
if (!publicOnly && scope === "public") {
|
|
561
|
+
throw new Error(
|
|
562
|
+
`Conflicting arguments: scope='${args?.scope}' conflicts with publicOnly=false.`
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return scope;
|
|
567
|
+
}
|
|
568
|
+
if (hasPublicOnly && publicOnly) {
|
|
569
|
+
return "public";
|
|
570
|
+
}
|
|
571
|
+
return "preferred";
|
|
572
|
+
}
|
|
573
|
+
function agentIdentityKeys(agent) {
|
|
574
|
+
return [agent.agentKey, agent.publicKey, agent.id].filter(
|
|
575
|
+
(key) => typeof key === "string" && key.length > 0
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
function deduplicateAgentSummaries(agents) {
|
|
579
|
+
const byIdentity = /* @__PURE__ */ new Map();
|
|
580
|
+
for (const agent of agents) {
|
|
581
|
+
const keys = agentIdentityKeys(agent);
|
|
582
|
+
const existing = keys.map((key) => byIdentity.get(key)).find(Boolean);
|
|
583
|
+
if (!existing) {
|
|
584
|
+
for (const key of keys) byIdentity.set(key, agent);
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
const winner = isPreferredAgent(agent) && !isPreferredAgent(existing) ? agent : existing;
|
|
588
|
+
for (const key of /* @__PURE__ */ new Set([...agentIdentityKeys(existing), ...keys])) byIdentity.set(key, winner);
|
|
589
|
+
}
|
|
590
|
+
return [...new Set(byIdentity.values())];
|
|
591
|
+
}
|
|
592
|
+
function filterAgentsByScope(agents, scope) {
|
|
593
|
+
const unique = deduplicateAgentSummaries(agents);
|
|
594
|
+
if (scope === "preferred") return unique.filter((agent) => isPreferredAgent(agent));
|
|
595
|
+
if (scope === "public") return unique.filter((agent) => isPublicDiscoveryAgent(agent));
|
|
596
|
+
return unique.filter((agent) => isPreferredAgent(agent) || agent.isPublic === true);
|
|
597
|
+
}
|
|
598
|
+
function matchesAgentQuery(agent, query) {
|
|
599
|
+
if (!query || typeof query !== "string") return true;
|
|
600
|
+
const q = query.trim().toLowerCase();
|
|
601
|
+
if (!q) return true;
|
|
602
|
+
const candidates = [
|
|
603
|
+
agent.name,
|
|
604
|
+
agent.model,
|
|
605
|
+
agent.provider,
|
|
606
|
+
agent.handle,
|
|
607
|
+
agent.agentKey,
|
|
608
|
+
agent.publicKey,
|
|
609
|
+
agent.id
|
|
610
|
+
];
|
|
611
|
+
return candidates.some((text) => typeof text === "string" && text.toLowerCase().includes(q));
|
|
612
|
+
}
|
|
613
|
+
function buildAgentDiscoveryResult(options) {
|
|
614
|
+
const scope = resolveDiscoveryScope({
|
|
615
|
+
scope: options.scope,
|
|
616
|
+
publicOnly: options.publicOnly
|
|
617
|
+
});
|
|
618
|
+
const now = options.now ?? Date.now();
|
|
619
|
+
let scopedAgents = filterAgentsByScope(options.agents, scope);
|
|
620
|
+
if (options.query && typeof options.query === "string" && options.query.trim()) {
|
|
621
|
+
scopedAgents = scopedAgents.filter((a) => matchesAgentQuery(a, options.query));
|
|
622
|
+
}
|
|
623
|
+
const unavailableList = scopedAgents.filter((a) => isAgentUnavailableNow(a, now));
|
|
624
|
+
const unavailableCount = unavailableList.length;
|
|
625
|
+
const unavailableAgents = sortSafeAgentSummaries(unavailableList).map(toUnavailableAgentSummary);
|
|
626
|
+
const credentialGroups = summarizeCredentialGroups(scopedAgents, now);
|
|
627
|
+
if (options.showUnavailable !== true) {
|
|
628
|
+
scopedAgents = scopedAgents.filter((a) => !isAgentUnavailableNow(a, now));
|
|
629
|
+
}
|
|
630
|
+
const sortedAgents = sortSafeAgentSummaries(scopedAgents);
|
|
631
|
+
const projectedAgents = options.verbose === true ? sortedAgents.map(omitNullishAgentSummaryFields) : sortedAgents.map(toCompactAgentSummary);
|
|
632
|
+
return {
|
|
633
|
+
total: projectedAgents.length,
|
|
634
|
+
unavailableCount,
|
|
635
|
+
unavailableAgents,
|
|
636
|
+
credentialGroups,
|
|
637
|
+
agents: projectedAgents
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
function toDiscoverySafeAgentSummary(record, options) {
|
|
641
|
+
const mergedOptions = record?.publicRecordExists === true ? { ...options, publicRecordExists: true } : options;
|
|
642
|
+
return toSafeAgentSummary(record, mergedOptions);
|
|
643
|
+
}
|
|
644
|
+
function assembleAgentDiscoveryResult(options) {
|
|
645
|
+
const { records, summaryOptions, ...discoveryOptions } = options;
|
|
646
|
+
const agents = records.map(
|
|
647
|
+
(record) => toDiscoverySafeAgentSummary(
|
|
648
|
+
record,
|
|
649
|
+
typeof summaryOptions === "function" ? summaryOptions(record) : summaryOptions
|
|
650
|
+
)
|
|
651
|
+
);
|
|
652
|
+
return buildAgentDiscoveryResult({ ...discoveryOptions, agents });
|
|
653
|
+
}
|
|
654
|
+
|
|
503
655
|
export {
|
|
504
656
|
deriveCredentialGroup,
|
|
657
|
+
deriveCustomProviderCredentialGroup,
|
|
505
658
|
summarizeCredentialGroups,
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
659
|
+
resolveDiscoveryScope,
|
|
660
|
+
matchesAgentQuery,
|
|
661
|
+
buildAgentDiscoveryResult,
|
|
662
|
+
toDiscoverySafeAgentSummary,
|
|
663
|
+
assembleAgentDiscoveryResult
|
|
511
664
|
};
|