nolo-cli 0.96.0-alpha.1 → 0.96.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-AUQRMRWL.js → _executeModel-GWF37P7J.js} +68 -63
- package/{action-YVYQEAAV.js → action-GI44T4DR.js} +10 -10
- package/{addContentAction-O7R66HEX.js → addContentAction-B2DRF7P6.js} +9 -9
- package/{addDialogAgentAction-74OA7KYP.js → addDialogAgentAction-T3I7IXPK.js} +15 -17
- package/{agentDeleteCommand-4BAHJRU3.js → agentDeleteCommand-5SHJMUF7.js} +47 -43
- package/{agentEmailCommands-QISOY7Y6.js → agentEmailCommands-YC7RFNYN.js} +90 -82
- package/{agentListCommands-U46ODMQU.js → agentListCommands-O4DSVOHQ.js} +78 -82
- package/{agentMachineCommands-EHV2KM2C.js → agentMachineCommands-ZSQCK3SA.js} +42 -38
- package/{agentProviderCommands-GNPTL5XR.js → agentProviderCommands-EMZCM6VA.js} +1 -1
- package/{agentPullCommand-O5MPVJ5E.js → agentPullCommand-HF4A42D4.js} +1 -1
- package/agentRecordCommands-MUG5QMN7.js +136 -0
- package/{agentRunCommand-K4CLMA6B.js → agentRunCommand-5EBSIN74.js} +90 -80
- package/{agentRunControl-XLGD3UZ5.js → agentRunControl-5T64LM2M.js} +2 -2
- package/{agentRuntimeLocal-O4HPUJA4.js → agentRuntimeLocal-KTWDCVYZ.js} +44 -36
- package/{agentSlice-ZYT2OUR3.js → agentSlice-QA6WAKNE.js} +11 -11
- package/{appDeleteCommands-R5BBTKQK.js → appDeleteCommands-JPPKN55V.js} +42 -38
- package/{appDeployCommands-ZJIXOJWD.js → appDeployCommands-QU5PW23S.js} +42 -38
- package/{appDeployStatusCommands-B3R2ZTBF.js → appDeployStatusCommands-QVAJTRSP.js} +42 -38
- package/{appGetCommands-2AQSOV2A.js → appGetCommands-LT3KDTHJ.js} +42 -38
- package/{appListCommands-HCIJGZFY.js → appListCommands-V37HIWKN.js} +42 -38
- package/{authCommand-F4EFRRX6.js → authCommand-2YPMMIJN.js} +117 -23
- package/{authCommands-RGOGCPP6.js → authCommands-FFDS4FVX.js} +7 -5
- package/{builtinSkillRegistry-FUAVTRVZ.js → builtinSkillRegistry-CALVIJTX.js} +6 -5
- package/{chatQueueReduxAdapter-Q5V4YJVI.js → chatQueueReduxAdapter-YYIRKWPD.js} +30 -29
- 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-OIVSQH2O.js → chunk-3BXNTXYI.js} +299 -5
- package/{chunk-BLJWCTRL.js → chunk-45LEXXBA.js} +1 -1
- package/{chunk-EYAQT56M.js → chunk-4DPP773Q.js} +2 -2
- package/chunk-4LCOCOR5.js +50 -0
- package/{chunk-2GRGFCF6.js → chunk-4VJAC32I.js} +2 -1
- package/{chunk-LLT642J4.js → chunk-4W65H3KF.js} +24 -5
- package/{chunk-MC4XLIJ7.js → chunk-523DITKR.js} +1 -1
- package/chunk-5G7QSEFG.js +13349 -0
- 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-6YTOJY35.js → chunk-6D2JFXLY.js} +35 -0
- package/{chunk-3BMYXEUW.js → chunk-6O4IK4V2.js} +1 -1
- package/{chunk-WADCY6G6.js → chunk-6ZWMH6TJ.js} +111 -41
- package/{chunk-ABQYVJBJ.js → chunk-7CHC4W22.js} +1 -1
- package/{chunk-YQTQQX2H.js → chunk-7IJ3GSRH.js} +1 -1
- package/{chunk-GQBOR3G6.js → chunk-7KVZ5LDQ.js} +2 -2
- package/{chunk-OA6Q2A4I.js → chunk-A7RSPKU6.js} +98 -22
- package/chunk-ALY3N3HU.js +7600 -0
- package/{chunk-Q554LLSI.js → chunk-AUDNYVRC.js} +1 -1
- package/{chunk-GPCZ7UXG.js → chunk-AZRHIN5B.js} +1 -1
- package/chunk-BMQ2MJUK.js +153 -0
- package/{chunk-3IIEFNGY.js → chunk-C53ZG23R.js} +2 -2
- package/chunk-CHOZJMJS.js +78 -0
- package/{chunk-HJUYAD4A.js → chunk-CPUFH46E.js} +8 -8
- package/{chunk-LS2ZANRJ.js → chunk-CTUQJVQM.js} +1 -1
- package/{chunk-BP4XNZRM.js → chunk-CU3QB4HW.js} +3 -3
- package/{chunk-ACTMNVHM.js → chunk-CYSYR67N.js} +1 -1
- package/{chunk-KQ4ONNQD.js → chunk-DAWDCRIG.js} +82 -8
- package/{chunk-VLTIYV3X.js → chunk-DCLMZ5TX.js} +4 -4
- package/{chunk-UKZDAFYT.js → chunk-DSSTTEKI.js} +6 -10
- package/{chunk-HVURBGF3.js → chunk-ESRMFY7G.js} +2 -2
- package/{chunk-TRV2MIDW.js → chunk-EXAJ6DCR.js} +1 -0
- package/{chunk-ZLR5JN3E.js → chunk-FKBRWL4E.js} +7 -7
- package/{chunk-XOVEWFLK.js → chunk-G3BCMDJB.js} +100 -100
- 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-ONXOABJR.js → chunk-HNGRBWYF.js} +3 -0
- package/{chunk-IAO6JBYW.js → chunk-HP2HV7RZ.js} +171 -14
- package/{chunk-H62HCIUP.js → chunk-HYZIYH2H.js} +11 -10
- package/{chunk-NTW5GWDM.js → chunk-I3QNET24.js} +32 -17
- package/{chunk-WV42OMV7.js → chunk-IAESIMK7.js} +4 -4
- package/{chunk-JRQFUXY7.js → chunk-KCDUTE5V.js} +96 -19
- package/{chunk-XRWZB6CF.js → chunk-KLTTJFH2.js} +23 -76
- package/{chunk-IIVGDG4I.js → chunk-LNPYTNMG.js} +8 -4
- package/{chunk-AFDS2CVM.js → chunk-MDMTFGJ2.js} +15 -20
- package/{chunk-4MY4GLIW.js → chunk-MN3RHOFX.js} +969 -1090
- package/{chunk-7S4YWN7P.js → chunk-MX574M24.js} +1 -1
- package/{chunk-FZGV4FGK.js → chunk-NUHHBEJC.js} +378 -187
- package/{chunk-53HEEOTT.js → chunk-O26PCYLS.js} +80 -13
- package/{chunk-3DII57IT.js → chunk-O2OWEFII.js} +1 -1
- package/chunk-OCZKATRC.js +129 -0
- package/{chunk-6D6VBVEW.js → chunk-OTEMQQZI.js} +80 -14
- package/chunk-P6GMCCAT.js +870 -0
- package/{chunk-CPH3W5A7.js → chunk-Q4GP72HX.js} +94 -3
- package/{chunk-DHDMC6FO.js → chunk-QKUMVP3O.js} +11 -6
- package/{chunk-76WEAXJB.js → chunk-QXWGM7NK.js} +18 -15
- package/{chunk-JOHSKZQX.js → chunk-R2TEASHZ.js} +865 -207
- package/{chunk-Z77CRGTW.js → chunk-R4SQ3LGW.js} +1 -1
- package/{chunk-V4MJDUSR.js → chunk-RSEEDUMS.js} +2 -2
- package/{chunk-UZGQNTVW.js → chunk-S5XGT6GB.js} +5 -3
- package/{chunk-QIAVMDHY.js → chunk-SDAPKV2N.js} +4 -4
- package/{chunk-SNPMM7H3.js → chunk-SN2U5EE7.js} +13 -13
- package/{chunk-AFUORTY4.js → chunk-SONWNI3L.js} +21 -21
- package/{chunk-A6G32FNX.js → chunk-SYAMDUAL.js} +13 -13
- package/{chunk-BYMV6QZG.js → chunk-TNIX77YM.js} +4 -0
- package/{chunk-OF7AQZUG.js → chunk-TU5NE4U3.js} +9 -84
- package/{chunk-EGSKXKR5.js → chunk-TWROMK2A.js} +1 -1
- package/chunk-TY3TIUJK.js +89 -0
- package/chunk-UNYJU5L6.js +780 -0
- package/{chunk-J4MOO56S.js → chunk-UQNS32WZ.js} +10 -2
- package/chunk-VIWDGTDA.js +8 -0
- package/chunk-VJVNU77E.js +83 -0
- package/{chunk-MMPXJXHT.js → chunk-VKEMMN62.js} +584 -480
- package/{chunk-ZXKVPF4K.js → chunk-W5HY3V6I.js} +236 -36
- package/{chunk-JAXOVNM4.js → chunk-WILHZY7K.js} +45 -45
- package/{chunk-UKWGR5SS.js → chunk-WIWM4FE3.js} +187 -398
- package/{chunk-BGSLKVCP.js → chunk-XAAUXO27.js} +6 -7
- package/{chunk-O6OSWFZQ.js → chunk-XUWRURDF.js} +6 -0
- package/{chunk-Q67DOFOO.js → chunk-Y3PMXGLH.js} +2 -0
- package/{chunk-SH43IESU.js → chunk-YUNJN43V.js} +44 -9
- package/{chunk-BZWBEHGD.js → chunk-YYMTXN25.js} +66 -38
- package/{chunk-TOP2VXOR.js → chunk-Z4CSIXYP.js} +2 -2
- package/{chunk-DEUUPHOO.js → chunk-ZGESTNDD.js} +77 -17
- package/{chunk-2F7RJC6L.js → chunk-ZOVKKMF6.js} +1 -1
- package/chunk-ZRAU6T47.js +56 -0
- package/commandRegistry-JPJBZMSB.js +833 -0
- package/{contentThunks-PT23JWJX.js → contentThunks-S5S6Y7FH.js} +32 -30
- package/{cooldownCommands-REAWYVTY.js → cooldownCommands-ZLEPIB4A.js} +2 -2
- package/{createAgentAutomationAction-N27SYTLU.js → createAgentAutomationAction-E3V23HF4.js} +32 -30
- package/{createDialogAction-XZPLHD5G.js → createDialogAction-PS2N7OCP.js} +36 -33
- package/{createPageAction-KHVJQ3CS.js → createPageAction-6XUY3KXJ.js} +38 -36
- package/{chunk-3SJQXXGY.js → cursorProvider-YGGNMVWX.js} +2560 -9879
- package/{dbSlice-XVWBAGYN.js → dbSlice-DQ32LYTJ.js} +8 -8
- package/{deleteFile-YG6QMJLU.js → deleteFile-NX6QHCWZ.js} +3 -3
- package/{dialogCommands-ZUWW5UT6.js → dialogCommands-3YXLYO2W.js} +45 -41
- package/{dialogSlice-3YH242HS.js → dialogSlice-NTZ5GT5B.js} +36 -29
- package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
- package/{docCreateCommands-Q6FADDSJ.js → docCreateCommands-4JSMQDST.js} +44 -40
- package/{docDeleteCommands-ZKIH54PZ.js → docDeleteCommands-3KTE3KP6.js} +44 -40
- package/{docReadCommands-7BZT2QTW.js → docReadCommands-54BL4OYN.js} +43 -39
- package/{docStore-YSZRNUUD.js → docStore-QE6H3LDC.js} +11 -10
- package/{docUpdateCommands-WJXWTRL7.js → docUpdateCommands-BMBPTW5U.js} +44 -40
- package/{fetchMessages-EIU7UFFK.js → fetchMessages-67MEFPZR.js} +2 -2
- package/{getPricing-LUSEABA6.js → getPricing-NMMFT3YI.js} +3 -3
- package/{handleSendMessageAction-KJO2QDBM.js → handleSendMessageAction-34BJIBML.js} +91 -83
- package/index.js +87 -884
- package/{localDialogRead-BTFJ4V2I.js → localDialogRead-EBRS242U.js} +2 -2
- package/{localRuntimeAuthority-6IR6BBXE.js → localRuntimeAuthority-5W6IJRAD.js} +6 -6
- package/{localRuntimeDb-SYQGUF4U.js → localRuntimeDb-3LRMNLCM.js} +1 -1
- package/{machineCommands-QC4TD7GJ.js → machineCommands-KBMEZDL3.js} +85 -77
- package/{machineWsRunDispatch-XUOIAXO7.js → machineWsRunDispatch-FRANXJZJ.js} +82 -74
- package/{memberThunks-QGFLFVCI.js → memberThunks-5ZXPR63F.js} +9 -9
- 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-76AVU3HD.js} +7 -7
- package/{providerRegistry-757OWH3O.js → providerRegistry-Z62NC45X.js} +11 -7
- package/{read-COE3ZYR6.js → read-EPTJRAEF.js} +5 -5
- package/{readDocTool-5USN4A6V.js → readDocTool-W4NDXNEX.js} +5 -3
- package/{readlineWorkspace-74TXXSLO.js → readlineWorkspace-P7WDR4NG.js} +2450 -2022
- package/{removeDialogAgentAction-IX3MN2ZO.js → removeDialogAgentAction-BVAWQKXE.js} +17 -19
- package/{runAgentClientLoop-37BXJD62.js → runAgentClientLoop-5OQN64SG.js} +62 -58
- package/{runtimeDoctorCommands-X6WDBEQX.js → runtimeDoctorCommands-3USD722U.js} +3 -3
- package/runtimeModeArgs-2Y7BALTO.js +31 -0
- package/{setDialogExtraReferencesAction-X4HCPNZL.js → setDialogExtraReferencesAction-LYY45IAD.js} +12 -11
- package/{setPrimaryDialogAgentAction-4GMIQLOD.js → setPrimaryDialogAgentAction-73IL7DLU.js} +18 -20
- package/{settingSlice-ZQZVUPKK.js → settingSlice-Q6EKL7EQ.js} +9 -9
- package/{skillDiscovery-CYUCJMAG.js → skillDiscovery-ZBU76COE.js} +3 -3
- package/{spaceCommands-P3ONT6LL.js → spaceCommands-W7B34E7K.js} +44 -40
- package/{streamAgentChatTurn-FGXQXALU.js → streamAgentChatTurn-7AX7XVHL.js} +184 -91
- package/{switchDialogAgentAction-N52LRPA3.js → switchDialogAgentAction-UUXDSQ6X.js} +15 -17
- package/{tableCommands-O6NWHFKV.js → tableCommands-G7RV3RU3.js} +4 -4
- package/{toolApiClient-QVJ6HDNN.js → toolApiClient-INIQCPGY.js} +3 -3
- package/{tools-R5UF2KZO.js → tools-357446VN.js} +55 -51
- package/{tuiSummaryLlmCaller-T2SHYMDZ.js → tuiSummaryLlmCaller-74NRRLVW.js} +18 -16
- package/{updateCommands-2M74UL7P.js → updateCommands-4EHDLF5J.js} +3 -3
- package/{updateDialogTitleAction-RTADGV7A.js → updateDialogTitleAction-A2OK52IY.js} +81 -43
- package/agentRecordCommands-SIPURU2S.js +0 -128
- package/chunk-FOWEGIMF.js +0 -18881
- package/chunk-M76ECQRD.js +0 -13658
- package/chunk-Q5FJJ6XI.js +0 -103
- package/chunk-S7Z2HMCN.js +0 -25
- package/{chunk-VMFTFOWF.js → chunk-3AH7LNUB.js} +7 -7
- package/{chunk-X7HHHIOZ.js → chunk-Y6ROFCZO.js} +0 -0
- package/{db-WK5MDZVN.js → db-VQSAOWAO.js} +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
toolRegistry
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VKEMMN62.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
runtime_default
|
|
6
|
+
} from "./chunk-5G7QSEFG.js";
|
|
7
7
|
import {
|
|
8
8
|
canonicalizeToolNames
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XUWRURDF.js";
|
|
10
10
|
import {
|
|
11
11
|
isNoloHostedProvider
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-Y3PMXGLH.js";
|
|
13
13
|
import {
|
|
14
14
|
asTrimmedLowercaseString
|
|
15
15
|
} from "./chunk-QSJ3HFEF.js";
|
|
@@ -17,94 +17,6 @@ import {
|
|
|
17
17
|
isRecord
|
|
18
18
|
} from "./chunk-KUG52IAP.js";
|
|
19
19
|
|
|
20
|
-
// packages/ai/chat/inlineImageUrlsForCustomProvider.ts
|
|
21
|
-
var FILE_CONTENT_PATH = "/api/v1/db/file/content/";
|
|
22
|
-
var shouldInlineImageUrlsForAgent = (agentConfig) => {
|
|
23
|
-
const apiSource = agentConfig?.apiSource?.toLowerCase();
|
|
24
|
-
const provider = agentConfig?.provider?.toLowerCase();
|
|
25
|
-
const model = agentConfig?.model?.toLowerCase();
|
|
26
|
-
if (apiSource === "custom" || provider === "custom") return true;
|
|
27
|
-
if (isNoloHostedProvider(provider)) return true;
|
|
28
|
-
return provider === "openrouter" && model === "minimax/minimax-m3";
|
|
29
|
-
};
|
|
30
|
-
var isInlineCandidate = (url) => /^https?:\/\//i.test(url) && url.includes(FILE_CONTENT_PATH);
|
|
31
|
-
var bytesToBase64 = (bytes) => {
|
|
32
|
-
let binary = "";
|
|
33
|
-
for (const byte of bytes) {
|
|
34
|
-
binary += String.fromCharCode(byte);
|
|
35
|
-
}
|
|
36
|
-
return btoa(binary);
|
|
37
|
-
};
|
|
38
|
-
var defaultFetchImage = async (url) => {
|
|
39
|
-
const response = await fetch(url);
|
|
40
|
-
if (!response.ok) {
|
|
41
|
-
return {
|
|
42
|
-
ok: false,
|
|
43
|
-
error: `HTTP ${response.status}`
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
47
|
-
return {
|
|
48
|
-
ok: true,
|
|
49
|
-
mimeType: response.headers.get("content-type") ?? "application/octet-stream",
|
|
50
|
-
bytes
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
var cloneImagePartWithDataUrl = async (part, fetchImage, isAllowedImageUrl) => {
|
|
54
|
-
const url = part?.image_url?.url;
|
|
55
|
-
if (typeof url !== "string" || !isInlineCandidate(url) || isAllowedImageUrl && !isAllowedImageUrl(url)) {
|
|
56
|
-
return part;
|
|
57
|
-
}
|
|
58
|
-
const result = await fetchImage(url);
|
|
59
|
-
if (!result.ok || !result.bytes) return part;
|
|
60
|
-
const mimeType = result.mimeType || "application/octet-stream";
|
|
61
|
-
return {
|
|
62
|
-
...part,
|
|
63
|
-
image_url: {
|
|
64
|
-
...part.image_url,
|
|
65
|
-
url: `data:${mimeType};base64,${bytesToBase64(result.bytes)}`
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
var inlineImageUrlsForCustomProvider = async (bodyData, options) => {
|
|
70
|
-
if (!options.shouldInline) return bodyData;
|
|
71
|
-
const body = bodyData;
|
|
72
|
-
if (!Array.isArray(body?.messages)) return bodyData;
|
|
73
|
-
const fetchImage = options.fetchImage ?? defaultFetchImage;
|
|
74
|
-
let changed = false;
|
|
75
|
-
const messages = [];
|
|
76
|
-
for (const message of body.messages) {
|
|
77
|
-
if (!Array.isArray(message?.content)) {
|
|
78
|
-
messages.push(message);
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const content = await Promise.all(
|
|
82
|
-
message.content.map(async (part) => {
|
|
83
|
-
if (part?.type !== "image_url") return part;
|
|
84
|
-
return cloneImagePartWithDataUrl(
|
|
85
|
-
part,
|
|
86
|
-
fetchImage,
|
|
87
|
-
options.isAllowedImageUrl
|
|
88
|
-
);
|
|
89
|
-
})
|
|
90
|
-
);
|
|
91
|
-
let messageChanged = false;
|
|
92
|
-
for (let i = 0; i < content.length; i++) {
|
|
93
|
-
if (content[i] !== message.content[i]) {
|
|
94
|
-
changed = true;
|
|
95
|
-
messageChanged = true;
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
messages.push(messageChanged ? { ...message, content } : message);
|
|
100
|
-
}
|
|
101
|
-
if (!changed) return bodyData;
|
|
102
|
-
return {
|
|
103
|
-
...body,
|
|
104
|
-
messages
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
|
|
108
20
|
// packages/ai/tools/toolSchemaCompatibility.ts
|
|
109
21
|
var COMPOSITION_KEYS = ["anyOf", "oneOf", "allOf"];
|
|
110
22
|
var LIMITED_JSON_SCHEMA_PROVIDERS = /* @__PURE__ */ new Set([
|
|
@@ -151,12 +63,12 @@ var PREPARE_TOOLS_CACHE_LIMIT = 128;
|
|
|
151
63
|
var warnedUnknownToolNames = /* @__PURE__ */ new Set();
|
|
152
64
|
function getTranslation(keys, defaultVal) {
|
|
153
65
|
for (const key of keys) {
|
|
154
|
-
if (
|
|
155
|
-
return
|
|
66
|
+
if (runtime_default.exists(key)) {
|
|
67
|
+
return runtime_default.t(key);
|
|
156
68
|
}
|
|
157
69
|
const aiKey = key.startsWith("ai:") ? key : `ai:${key}`;
|
|
158
|
-
if (
|
|
159
|
-
return
|
|
70
|
+
if (runtime_default.exists(aiKey)) {
|
|
71
|
+
return runtime_default.t(aiKey);
|
|
160
72
|
}
|
|
161
73
|
}
|
|
162
74
|
return defaultVal;
|
|
@@ -203,7 +115,7 @@ function translateSchema(schema) {
|
|
|
203
115
|
return nextSchema;
|
|
204
116
|
}
|
|
205
117
|
function currentI18nLanguage() {
|
|
206
|
-
return typeof
|
|
118
|
+
return typeof runtime_default.language === "string" ? runtime_default.language : "";
|
|
207
119
|
}
|
|
208
120
|
function translateSchemaCached(schema) {
|
|
209
121
|
if (!schema || typeof schema !== "object") return schema;
|
|
@@ -268,8 +180,96 @@ var prepareTools = (toolNames, options) => {
|
|
|
268
180
|
return prepared.slice();
|
|
269
181
|
};
|
|
270
182
|
|
|
183
|
+
// packages/ai/chat/inlineImageUrlsForCustomProvider.ts
|
|
184
|
+
var FILE_CONTENT_PATH = "/api/v1/db/file/content/";
|
|
185
|
+
var shouldInlineImageUrlsForAgent = (agentConfig) => {
|
|
186
|
+
const apiSource = agentConfig?.apiSource?.toLowerCase();
|
|
187
|
+
const provider = agentConfig?.provider?.toLowerCase();
|
|
188
|
+
const model = agentConfig?.model?.toLowerCase();
|
|
189
|
+
if (apiSource === "custom" || provider === "custom") return true;
|
|
190
|
+
if (isNoloHostedProvider(provider)) return true;
|
|
191
|
+
return provider === "openrouter" && model === "minimax/minimax-m3";
|
|
192
|
+
};
|
|
193
|
+
var isInlineCandidate = (url) => /^https?:\/\//i.test(url) && url.includes(FILE_CONTENT_PATH);
|
|
194
|
+
var bytesToBase64 = (bytes) => {
|
|
195
|
+
let binary = "";
|
|
196
|
+
for (const byte of bytes) {
|
|
197
|
+
binary += String.fromCharCode(byte);
|
|
198
|
+
}
|
|
199
|
+
return btoa(binary);
|
|
200
|
+
};
|
|
201
|
+
var defaultFetchImage = async (url) => {
|
|
202
|
+
const response = await fetch(url);
|
|
203
|
+
if (!response.ok) {
|
|
204
|
+
return {
|
|
205
|
+
ok: false,
|
|
206
|
+
error: `HTTP ${response.status}`
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
210
|
+
return {
|
|
211
|
+
ok: true,
|
|
212
|
+
mimeType: response.headers.get("content-type") ?? "application/octet-stream",
|
|
213
|
+
bytes
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
var cloneImagePartWithDataUrl = async (part, fetchImage, isAllowedImageUrl) => {
|
|
217
|
+
const url = part?.image_url?.url;
|
|
218
|
+
if (typeof url !== "string" || !isInlineCandidate(url) || isAllowedImageUrl && !isAllowedImageUrl(url)) {
|
|
219
|
+
return part;
|
|
220
|
+
}
|
|
221
|
+
const result = await fetchImage(url);
|
|
222
|
+
if (!result.ok || !result.bytes) return part;
|
|
223
|
+
const mimeType = result.mimeType || "application/octet-stream";
|
|
224
|
+
return {
|
|
225
|
+
...part,
|
|
226
|
+
image_url: {
|
|
227
|
+
...part.image_url,
|
|
228
|
+
url: `data:${mimeType};base64,${bytesToBase64(result.bytes)}`
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
var inlineImageUrlsForCustomProvider = async (bodyData, options) => {
|
|
233
|
+
if (!options.shouldInline) return bodyData;
|
|
234
|
+
const body = bodyData;
|
|
235
|
+
if (!Array.isArray(body?.messages)) return bodyData;
|
|
236
|
+
const fetchImage = options.fetchImage ?? defaultFetchImage;
|
|
237
|
+
let changed = false;
|
|
238
|
+
const messages = [];
|
|
239
|
+
for (const message of body.messages) {
|
|
240
|
+
if (!Array.isArray(message?.content)) {
|
|
241
|
+
messages.push(message);
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
const content = await Promise.all(
|
|
245
|
+
message.content.map(async (part) => {
|
|
246
|
+
if (part?.type !== "image_url") return part;
|
|
247
|
+
return cloneImagePartWithDataUrl(
|
|
248
|
+
part,
|
|
249
|
+
fetchImage,
|
|
250
|
+
options.isAllowedImageUrl
|
|
251
|
+
);
|
|
252
|
+
})
|
|
253
|
+
);
|
|
254
|
+
let messageChanged = false;
|
|
255
|
+
for (let i = 0; i < content.length; i++) {
|
|
256
|
+
if (content[i] !== message.content[i]) {
|
|
257
|
+
changed = true;
|
|
258
|
+
messageChanged = true;
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
messages.push(messageChanged ? { ...message, content } : message);
|
|
263
|
+
}
|
|
264
|
+
if (!changed) return bodyData;
|
|
265
|
+
return {
|
|
266
|
+
...body,
|
|
267
|
+
messages
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
|
|
271
271
|
export {
|
|
272
|
+
prepareTools,
|
|
272
273
|
shouldInlineImageUrlsForAgent,
|
|
273
|
-
inlineImageUrlsForCustomProvider
|
|
274
|
-
prepareTools
|
|
274
|
+
inlineImageUrlsForCustomProvider
|
|
275
275
|
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// packages/agent-runtime/sseFrames.ts
|
|
2
|
+
async function* readSseFrames(response) {
|
|
3
|
+
const reader = response.body?.getReader();
|
|
4
|
+
if (!reader) {
|
|
5
|
+
throw new Error("SSE response did not include a readable body.");
|
|
6
|
+
}
|
|
7
|
+
const decoder = new TextDecoder();
|
|
8
|
+
let buffer = "";
|
|
9
|
+
while (true) {
|
|
10
|
+
const { done, value } = await reader.read();
|
|
11
|
+
if (done) break;
|
|
12
|
+
buffer += decoder.decode(value, { stream: true });
|
|
13
|
+
let boundary = findSseFrameBoundary(buffer);
|
|
14
|
+
while (boundary) {
|
|
15
|
+
yield buffer.slice(0, boundary.index);
|
|
16
|
+
buffer = buffer.slice(boundary.index + boundary.separatorLength);
|
|
17
|
+
boundary = findSseFrameBoundary(buffer);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const remaining = decoder.decode();
|
|
21
|
+
if (remaining) {
|
|
22
|
+
buffer += remaining;
|
|
23
|
+
let boundary = findSseFrameBoundary(buffer);
|
|
24
|
+
while (boundary) {
|
|
25
|
+
yield buffer.slice(0, boundary.index);
|
|
26
|
+
buffer = buffer.slice(boundary.index + boundary.separatorLength);
|
|
27
|
+
boundary = findSseFrameBoundary(buffer);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (buffer.trim()) yield buffer;
|
|
31
|
+
}
|
|
32
|
+
function findSseFrameBoundary(buffer) {
|
|
33
|
+
const lfLf = buffer.indexOf("\n\n");
|
|
34
|
+
const crLfCrLf = buffer.indexOf("\r\n\r\n");
|
|
35
|
+
if (lfLf === -1 && crLfCrLf === -1) return null;
|
|
36
|
+
const useLf = lfLf !== -1 && (crLfCrLf === -1 || lfLf < crLfCrLf);
|
|
37
|
+
return useLf ? { index: lfLf, separatorLength: 2 } : { index: crLfCrLf, separatorLength: 4 };
|
|
38
|
+
}
|
|
39
|
+
async function* streamSseDataValues(response, parse) {
|
|
40
|
+
const reader = response.body?.getReader();
|
|
41
|
+
if (!reader) return;
|
|
42
|
+
const decoder = new TextDecoder();
|
|
43
|
+
let buffer = "";
|
|
44
|
+
while (true) {
|
|
45
|
+
const { done, value } = await reader.read();
|
|
46
|
+
if (done) break;
|
|
47
|
+
buffer += decoder.decode(value, { stream: true });
|
|
48
|
+
const lines = buffer.split("\n");
|
|
49
|
+
buffer = lines.pop() ?? "";
|
|
50
|
+
for (const line of lines) {
|
|
51
|
+
const parsed = parse(line);
|
|
52
|
+
if (parsed) yield parsed;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const remaining = decoder.decode();
|
|
56
|
+
if (remaining) {
|
|
57
|
+
buffer += remaining;
|
|
58
|
+
const lines = buffer.split("\n");
|
|
59
|
+
buffer = lines.pop() ?? "";
|
|
60
|
+
for (const line of lines) {
|
|
61
|
+
const parsed = parse(line);
|
|
62
|
+
if (parsed) yield parsed;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (buffer.trim()) {
|
|
66
|
+
const parsed = parse(buffer);
|
|
67
|
+
if (parsed) yield parsed;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async function readSseDataValues(response, parse) {
|
|
71
|
+
const values = [];
|
|
72
|
+
for await (const value of streamSseDataValues(response, parse)) {
|
|
73
|
+
values.push(value);
|
|
74
|
+
}
|
|
75
|
+
return values;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export {
|
|
79
|
+
readSseFrames,
|
|
80
|
+
streamSseDataValues,
|
|
81
|
+
readSseDataValues
|
|
82
|
+
};
|
|
@@ -180,6 +180,36 @@ function resolveCooldownGate(input, now) {
|
|
|
180
180
|
}
|
|
181
181
|
return now - lastProbeAt >= PROBE_INTERVAL_MS ? "probe" : "blocked";
|
|
182
182
|
}
|
|
183
|
+
function resolveCredentialKey(agent) {
|
|
184
|
+
if (!agent || typeof agent !== "object") return void 0;
|
|
185
|
+
for (const field of ["apiKeyRef", "credentialRef"]) {
|
|
186
|
+
const value = agent[field];
|
|
187
|
+
if (typeof value === "string") {
|
|
188
|
+
const trimmed = value.trim();
|
|
189
|
+
if (trimmed) return trimmed;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return void 0;
|
|
193
|
+
}
|
|
194
|
+
function resolveCredentialKeyWithFallback(agent) {
|
|
195
|
+
const byRef = resolveCredentialKey(agent);
|
|
196
|
+
if (byRef) return byRef;
|
|
197
|
+
if (!agent || typeof agent !== "object") return void 0;
|
|
198
|
+
const endpoint = agent.customProviderUrl;
|
|
199
|
+
if (typeof endpoint === "string") {
|
|
200
|
+
const trimmed = endpoint.trim();
|
|
201
|
+
if (trimmed) {
|
|
202
|
+
try {
|
|
203
|
+
const origin = new URL(trimmed).origin;
|
|
204
|
+
if (origin && origin !== "null") return `custom-endpoint:${origin}`;
|
|
205
|
+
} catch {
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const key = agent.key;
|
|
210
|
+
if (typeof key === "string" && key.trim()) return `custom-agent:${key.trim()}`;
|
|
211
|
+
return void 0;
|
|
212
|
+
}
|
|
183
213
|
|
|
184
214
|
export {
|
|
185
215
|
QUOTA_ERROR_PATTERNS,
|
|
@@ -188,5 +218,6 @@ export {
|
|
|
188
218
|
isQuotaLimited403Body,
|
|
189
219
|
resolveAvailabilityAction,
|
|
190
220
|
mergeAvailabilityDeadline,
|
|
191
|
-
resolveCooldownGate
|
|
221
|
+
resolveCooldownGate,
|
|
222
|
+
resolveCredentialKeyWithFallback
|
|
192
223
|
};
|
|
@@ -206,9 +206,12 @@ export {
|
|
|
206
206
|
resolveNoloStateDir,
|
|
207
207
|
getLegacyCredentialPath,
|
|
208
208
|
migrateLegacyCredentialFile,
|
|
209
|
+
DEFAULT_REFRESH_SKEW_MS,
|
|
209
210
|
getCredentialsDir,
|
|
211
|
+
getCredentialPath,
|
|
210
212
|
readOAuthCredential,
|
|
211
213
|
writeOAuthCredential,
|
|
214
|
+
removeOAuthCredential,
|
|
212
215
|
createOAuthTokenStore,
|
|
213
216
|
isTokenExpired,
|
|
214
217
|
resolveFreshAccessToken
|
|
@@ -1,23 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isSubscriptionEndpoint,
|
|
3
|
+
isSubscriptionOAuthCredential
|
|
4
|
+
} from "./chunk-DAWDCRIG.js";
|
|
1
5
|
import {
|
|
2
6
|
isOAuthApiKeyRef
|
|
3
7
|
} from "./chunk-YYLHWIW6.js";
|
|
4
8
|
import {
|
|
5
9
|
compareAgentSelection
|
|
6
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-LNPYTNMG.js";
|
|
11
|
+
import {
|
|
12
|
+
isAgentUnavailableNow
|
|
13
|
+
} from "./chunk-H6A6X4EK.js";
|
|
7
14
|
import {
|
|
8
15
|
isAntigravityOAuthAgent
|
|
9
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-S5XGT6GB.js";
|
|
10
17
|
import {
|
|
11
18
|
getModelAbility
|
|
12
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-CYSYR67N.js";
|
|
20
|
+
import {
|
|
21
|
+
fnv1a32Hex
|
|
22
|
+
} from "./chunk-WIWM4FE3.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,8 +448,12 @@ 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 } : {},
|
|
454
|
+
// 「未知 ≠ 独立」:无 credentialGroup 时显式 credentialed:false,调用方
|
|
455
|
+
// 不得把缺失解读成独立凭证(并发扇出守卫依赖这个区分)。
|
|
456
|
+
credentialed: credentialGroup !== void 0,
|
|
423
457
|
updatedAt
|
|
424
458
|
};
|
|
425
459
|
}
|
|
@@ -445,8 +479,11 @@ var COMPACT_AGENT_SUMMARY_FIELDS = [
|
|
|
445
479
|
// 决策信息(CLI --show-unavailable 场景);默认列表已把这类 agent 过滤掉,
|
|
446
480
|
// 所以通常根本不占字节。
|
|
447
481
|
"nextAvailableAt",
|
|
482
|
+
// 额度快照:只有上游真上报过窗口的 agent 才带(通常是小对象)。
|
|
483
|
+
"quota",
|
|
448
484
|
"credentialGroup",
|
|
449
|
-
"credentialKind"
|
|
485
|
+
"credentialKind",
|
|
486
|
+
"credentialed"
|
|
450
487
|
];
|
|
451
488
|
function omitNullishAgentSummaryFields(summary) {
|
|
452
489
|
const result = {};
|
|
@@ -477,6 +514,7 @@ var UNAVAILABLE_AGENT_SUMMARY_FIELDS = [
|
|
|
477
514
|
"isOAuth",
|
|
478
515
|
"isOwned",
|
|
479
516
|
"nextAvailableAt",
|
|
517
|
+
"quota",
|
|
480
518
|
"favoritedAt",
|
|
481
519
|
"updatedAt"
|
|
482
520
|
];
|
|
@@ -496,12 +534,131 @@ function toUnavailableAgentSummary(summary) {
|
|
|
496
534
|
return item;
|
|
497
535
|
}
|
|
498
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
|
+
|
|
499
655
|
export {
|
|
500
656
|
deriveCredentialGroup,
|
|
657
|
+
deriveCustomProviderCredentialGroup,
|
|
501
658
|
summarizeCredentialGroups,
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
659
|
+
resolveDiscoveryScope,
|
|
660
|
+
matchesAgentQuery,
|
|
661
|
+
buildAgentDiscoveryResult,
|
|
662
|
+
toDiscoverySafeAgentSummary,
|
|
663
|
+
assembleAgentDiscoveryResult
|
|
507
664
|
};
|