nolo-cli 0.32.0 → 0.33.0-alpha.11
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 +6 -12
- package/{_executeModel-LTMSIBS4.js → _executeModel-YXWAXPWQ.js} +77 -67
- package/{action-HI3VRQLP.js → action-OQWPNKAH.js} +17 -15
- package/{addContentAction-NCURJ6PK.js → addContentAction-YVINZQTF.js} +14 -13
- package/{addDialogAgentAction-RCY4ECF4.js → addDialogAgentAction-6IOCIEPI.js} +14 -13
- package/{agentDeleteCommand-D3MYZK6E.js → agentDeleteCommand-VGHWJN5T.js} +44 -60
- package/{agentEmailCommands-6BXS574I.js → agentEmailCommands-ZLRF35I3.js} +91 -81
- package/{agentGrantCommands-E7ZZFRHK.js → agentGrantCommands-2LEZDADN.js} +2 -2
- package/{agentListCommands-SF3HEUTT.js → agentListCommands-OHZJ7AFP.js} +75 -79
- package/{agentMachineCommands-YARVXRR6.js → agentMachineCommands-62PHPGTK.js} +43 -59
- package/{agentPullCommand-ARSIDNVC.js → agentPullCommand-TSWAJPS2.js} +5 -5
- package/agentRecordCommands-CW2JWERD.js +113 -0
- package/agentRunCommand-O4HV7YWA.js +131 -0
- package/{agentRuntimeLocal-ATGJY6WC.js → agentRuntimeLocal-4PSBNUOE.js} +37 -51
- package/{agentSlice-4XWW344Y.js → agentSlice-OUTQ5O72.js} +16 -14
- package/{appDeleteCommands-63JO7RXS.js → appDeleteCommands-VTDBVHYR.js} +40 -56
- package/{appDeployCommands-Y7EWYUGM.js → appDeployCommands-WOUP7MDA.js} +40 -56
- package/{appDeployStatusCommands-ZBEY3DWB.js → appDeployStatusCommands-N2NWZKEN.js} +40 -56
- package/{appGetCommands-QSSOSEYL.js → appGetCommands-GYKLWWCA.js} +40 -56
- package/{appListCommands-PH3XWNDX.js → appListCommands-RUWBSEJK.js} +40 -56
- package/{authCommand-BBDHMSO6.js → authCommand-YVXVH25I.js} +21 -20
- package/{authCommands-4UDEKRE6.js → authCommands-WTW6MEYS.js} +10 -10
- package/chatQueueReduxAdapter-2QJAD4KQ.js +181 -0
- package/{chunk-EEF23OOK.js → chunk-266VUBLK.js} +7 -7
- package/{chunk-TEYN42N3.js → chunk-2IVEXF7P.js} +11 -4
- package/{chunk-2HXKAPH7.js → chunk-2QLAVHVK.js} +6 -6
- package/{chunk-WTGCTVJG.js → chunk-2QTEYCR7.js} +3 -6
- package/{chunk-DOISARTV.js → chunk-2UECQ7RE.js} +1 -1
- package/{chunk-E3APEOIM.js → chunk-3GZXL6FM.js} +4 -19
- package/{chunk-KGEVMUMI.js → chunk-3RUW3ONU.js} +11 -11
- package/{chunk-RXVX5LFR.js → chunk-3UG2IIZ3.js} +1 -1
- package/{chunk-O5OMJPPF.js → chunk-3WXRAHCG.js} +6 -5
- package/{chunk-V54H24CQ.js → chunk-4F5M2MW5.js} +3 -3
- package/{chunk-2ZRP5RUG.js → chunk-4OV7DXFJ.js} +12 -11
- package/{chunk-W367V5CH.js → chunk-54BAYVCY.js} +404 -117
- package/{chunk-GAF5X6B7.js → chunk-5QW3O3ET.js} +284 -310
- package/{chunk-DLWCWUNW.js → chunk-64OVNZXE.js} +1197 -757
- package/{chunk-ODS2MVMU.js → chunk-66CWPJK2.js} +19 -303
- package/{chunk-PTHDLIRB.js → chunk-6KOS7ZBZ.js} +1 -1
- package/{chunk-MXFQHRSS.js → chunk-6XIE5ZGI.js} +1 -1
- package/{chunk-ATK5WJOA.js → chunk-6YXDOOSH.js} +4 -4
- package/{chunk-SWYMCHM7.js → chunk-75U775RZ.js} +69 -1
- package/{chunk-UDA3ZYLW.js → chunk-7YYHKBJP.js} +31 -72
- package/chunk-ADLYMQB6.js +642 -0
- package/{chunk-ZWJOGMKH.js → chunk-AETZ7AD6.js} +1 -1
- package/{chunk-43EPBPZ2.js → chunk-ASDXPOJH.js} +2 -2
- package/{chunk-44HACRCK.js → chunk-BANYWEYY.js} +4 -4
- package/chunk-BFPSVRCQ.js +1799 -0
- package/{chunk-TOW4E763.js → chunk-BJIRLHJR.js} +2 -0
- package/{chunk-ZJ2WITOO.js → chunk-BQXOGBFN.js} +2 -2
- package/{chunk-4PNU7W7K.js → chunk-C7H5GMXT.js} +107 -125
- package/chunk-CPYYM4RJ.js +98 -0
- package/{chunk-3GZT3L6F.js → chunk-DDVIBKIB.js} +326 -481
- package/{chunk-2K4NDPT5.js → chunk-DFUPZE6V.js} +20 -12
- package/{chunk-BGTUGS3T.js → chunk-DKMOY3QI.js} +4 -30
- package/chunk-EGRJC4ZN.js +91 -0
- package/{chunk-K6QEHQZ3.js → chunk-EKLRRZIN.js} +1 -1
- package/{chunk-6HYVJV7B.js → chunk-ESHYE7WU.js} +2 -1
- package/{chunk-XFG3BAKN.js → chunk-FMEVI5TG.js} +65 -0
- package/{chunk-U4TRT5V4.js → chunk-GEPHJJW4.js} +1 -1
- package/chunk-GJXRIOLS.js +241 -0
- package/{chunk-VP4WJWKW.js → chunk-GM6PU7B6.js} +431 -345
- package/chunk-HS7MLR74.js +38 -0
- package/{chunk-3AUWC6EM.js → chunk-HUCT7HID.js} +5 -84
- package/chunk-IDAU4UFS.js +437 -0
- package/{chunk-Q76I4SXI.js → chunk-IHEC7VBF.js} +1 -1
- package/{chunk-OWHNFZNW.js → chunk-IKWTTKWG.js} +4 -4
- package/{chunk-3LY4F7SV.js → chunk-INZZJSQF.js} +348 -331
- package/{chunk-ZJH3LKEW.js → chunk-IR6W62Q6.js} +102 -15
- package/{chunk-RH53LMEJ.js → chunk-J44TVX2O.js} +2 -4
- package/{chunk-CF2WZF4N.js → chunk-J6WH4PYZ.js} +0 -8
- package/chunk-KHCLMKZZ.js +3062 -0
- package/{chunk-WHLVPK32.js → chunk-KMSZPTM6.js} +27 -3
- package/{chunk-L3GCUVOH.js → chunk-KSRFVP36.js} +1 -1
- package/{chunk-XDHHF73Q.js → chunk-LUIHOUZC.js} +95 -95
- package/{chunk-UOJRKY5J.js → chunk-M2YMQOLC.js} +44 -53
- package/chunk-M3JEW6N6.js +193 -0
- package/{chunk-MITD7CON.js → chunk-MDIAECHA.js} +1461 -301
- package/{chunk-IXZX5CJK.js → chunk-MQRZ5QUH.js} +1 -1
- package/{chunk-3ASDTTEI.js → chunk-MRWGHF56.js} +2 -0
- package/{chunk-Q3CSL43H.js → chunk-N4XRDM26.js} +1 -1
- package/{chunk-D34RI6NI.js → chunk-NNWHHCVP.js} +75 -1
- package/{chunk-CAENRKNJ.js → chunk-OR2HNLVO.js} +126 -88
- package/chunk-OW765XBU.js +10 -0
- package/{chunk-VMWR7VNI.js → chunk-PRMMCFIN.js} +13 -9
- package/{chunk-JZPBVBIY.js → chunk-QTZD6HBK.js} +18 -8
- package/chunk-RCFIB45Q.js +28 -0
- package/{chunk-7S54ZGF6.js → chunk-RJKIB55Y.js} +256 -12
- package/chunk-RPRRIFXV.js +231 -0
- package/chunk-RQFO3CAF.js +300 -0
- package/chunk-RY57GLGW.js +188 -0
- package/{chunk-YHGHADBQ.js → chunk-SCUETSRP.js} +4 -4
- package/{chunk-TA6EA2A3.js → chunk-TFK3HUNQ.js} +182 -20
- package/{chunk-LAXMH7JY.js → chunk-UM4H3URE.js} +18 -15
- package/{chunk-6YABCOFU.js → chunk-UNHKVD2N.js} +1 -1
- package/{chunk-G5GVZAXF.js → chunk-UNOTBWZZ.js} +15 -19
- package/{chunk-GE6IWA5N.js → chunk-UNZDCI3O.js} +126 -1
- package/chunk-URMS4XY2.js +10 -0
- package/{chunk-SFWZUTCI.js → chunk-VBUQYOX7.js} +2 -2
- package/{chunk-FXFGNOT2.js → chunk-VFVCYIRQ.js} +1 -1
- package/chunk-VIDPVFP3.js +20 -0
- package/{chunk-5RDLGLAP.js → chunk-WJSW43QZ.js} +4 -7
- package/{chunk-CF7S2RYZ.js → chunk-WLH5BAKX.js} +6 -6
- package/{chunk-VVEH6XUE.js → chunk-X2DAEZ3X.js} +1 -1
- package/{chunk-2IJAKBK2.js → chunk-X664KVEV.js} +426 -246
- package/{chunk-3FCNXC2J.js → chunk-XRO5VGQ6.js} +3735 -1394
- package/chunk-Y5GCAMGP.js +9 -0
- package/{chunk-O3JR45Q2.js → chunk-YBMI5JAH.js} +44 -44
- package/{chunk-V42OE5HT.js → chunk-YDTYDA5W.js} +3 -3
- package/chunk-YYLHWIW6.js +48 -0
- package/{chunk-AOS5IN2I.js → chunk-ZHYK3N56.js} +1 -1
- package/{chunk-PJ2DDQQM.js → chunk-ZURFOV5J.js} +2 -2
- package/{chunk-3UGKATZQ.js → chunk-ZWS6DUHX.js} +26 -435
- package/chunk-ZZ2MH7LE.js +84 -0
- package/{cliExecutor-BBUVQU4L.js → cliExecutor-DW3PHGEL.js} +2 -2
- package/{clipboardy-BVE3LVEH.js → clipboardy-MMBYVRLF.js} +166 -372
- package/{codingSkills-V35TRR4Y.js → codingSkills-DY5MINPG.js} +5 -4
- package/{createAgentAutomationAction-WLRNE7C4.js → createAgentAutomationAction-H6ZRPXBR.js} +41 -31
- package/createDialogAction-UJ6LFJYM.js +61 -0
- package/{createPageAction-7YROVZ3W.js → createPageAction-KVPT3IRK.js} +57 -47
- package/{db-6DPSJ6WT.js → db-3H3JECGY.js} +45 -5
- package/{dbSlice-BBL3PEVW.js → dbSlice-UI2VCBLG.js} +13 -12
- package/{deleteFile-RJTEPOT4.js → deleteFile-XQXPBFFB.js} +7 -6
- package/dialogCommands-6ASXJP3H.js +82 -0
- package/{dialogSlice-N4HPG6HM.js → dialogSlice-B7KCGHMY.js} +37 -29
- package/{docCreateCommands-GRA5BHSA.js → docCreateCommands-S4E4MKVC.js} +42 -56
- package/{docDeleteCommands-ONIJM5MD.js → docDeleteCommands-M7XLKWRM.js} +44 -58
- package/{docReadCommands-H55VQ2US.js → docReadCommands-LSCMW2FR.js} +42 -56
- package/{docStore-B5AHDNW5.js → docStore-ZYWZWIRB.js} +40 -30
- package/{docUpdateCommands-ZQIQVGC2.js → docUpdateCommands-OMRBAFOB.js} +45 -59
- package/{fetchMessages-VPPQDDZ4.js → fetchMessages-7QRCCRYK.js} +3 -3
- package/{getPricing-QO5TYNCK.js → getPricing-L2ENXWHV.js} +7 -6
- package/{handleSendMessageAction-IN5XX5U7.js → handleSendMessageAction-Y2XKODRT.js} +39 -31
- package/index.js +74 -74
- package/{lib-FYYBQIXS.js → lib-2ZTNRXR4.js} +432 -183
- package/{localDialogRead-3DBXVYXS.js → localDialogRead-SLMPV5SK.js} +2 -2
- package/{localRuntimeAuthority-NDUA2D7Y.js → localRuntimeAuthority-S77B5QVB.js} +10 -4
- package/{localRuntimeDb-GKYRBWLQ.js → localRuntimeDb-N3H3HQ7G.js} +1 -1
- package/{machineCommands-H3UMKE76.js → machineCommands-62RUZVSW.js} +95 -85
- package/{machineInfo-M6KB6HZN.js → machineInfo-66ZFUMLE.js} +1 -1
- package/machineWsRunDispatch-L3HD3FSF.js +129 -0
- package/{models-WDUTTYFS.js → models-OX2S5C6Q.js} +2 -2
- package/{offlineMarxistsAgentCommand-E6LUG63A.js → offlineMarxistsAgentCommand-GEH6SNNA.js} +1 -1
- package/package.json +1 -4
- package/{read-64OQDO3I.js → read-2VHEHCAN.js} +8 -7
- package/{readDocTool-MXM3T6PE.js → readDocTool-CSWD6NPC.js} +1 -2
- package/{readlineWorkspace-XVJZDCSC.js → readlineWorkspace-3MOJWFM7.js} +3358 -3409
- package/{removeDialogAgentAction-NEKVAMSH.js → removeDialogAgentAction-2T7BPM3T.js} +19 -17
- package/{runAgentClientLoop-H7U53QB6.js → runAgentClientLoop-Y5UW544I.js} +73 -64
- package/{runtimeDoctorCommands-WI2YZUSJ.js → runtimeDoctorCommands-KHGQKT3B.js} +6 -6
- package/{setDialogExtraReferencesAction-WTOHQDIV.js → setDialogExtraReferencesAction-GPT37HTW.js} +15 -14
- package/{setPrimaryDialogAgentAction-LDJOYC4F.js → setPrimaryDialogAgentAction-3746P7IW.js} +19 -17
- package/{settingSlice-4M37TN7V.js → settingSlice-FIFOQ6OR.js} +16 -14
- package/{skillDiscovery-5U6RYAHN.js → skillDiscovery-KLLKXPUO.js} +4 -4
- package/{slateUtils-2M7MUTWX.js → slateUtils-VO2FU36K.js} +1 -1
- package/{spaceCommands-7VVKJBDV.js → spaceCommands-NKSBD5G3.js} +45 -241
- package/{spaceSlice-T6YK6D34.js → spaceSlice-L44CI2QR.js} +39 -61
- package/{streamAgentChatTurn-RQ63QFQ7.js → streamAgentChatTurn-7DU4Z2VJ.js} +1262 -150
- package/{switchDialogAgentAction-XVWGKR2Z.js → switchDialogAgentAction-MQTUTQHL.js} +14 -13
- package/syncMapping-RK2MANUX.js +43 -0
- package/{tableCommands-RJZ3V4TF.js → tableCommands-64FZBAI3.js} +9 -8
- package/{toolApiClient-ARGFDJAG.js → toolApiClient-B2MFXMEG.js} +3 -3
- package/tools-2JI52WJP.js +99 -0
- package/{tuiSummaryLlmCaller-SRZ4QQUP.js → tuiSummaryLlmCaller-EAWQ3IZX.js} +25 -21
- package/{updateCommands-AK2RDOFR.js → updateCommands-MNDUIKN7.js} +2 -2
- package/{updateDialogTitleAction-BBDSWHNG.js → updateDialogTitleAction-HW33OIJI.js} +49 -38
- package/agentRecordCommands-JFZRQJQ4.js +0 -103
- package/agentRunCommand-NOX5FLKO.js +0 -121
- package/chunk-AYMOSAHE.js +0 -3158
- package/chunk-D2BPX6DQ.js +0 -1707
- package/chunk-DCDL3GC4.js +0 -171
- package/chunk-F3MP7CP6.js +0 -73
- package/chunk-WZSRQNQG.js +0 -2587
- package/createDialogAction-Y6YV64QB.js +0 -52
- package/dialogCommands-XLO5CAHZ.js +0 -95
- package/machineWsRunDispatch-HONRUK3R.js +0 -119
- package/tools-KYZX3BGO.js +0 -90
- package/{chunk-Z5MXSEOJ.js → chunk-RQSOAMPJ.js} +2 -2
- package/{chunk-JDSUTNYY.js → chunk-SAQQLJZ5.js} +3 -3
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getCredentialsDir
|
|
3
|
+
} from "./chunk-QTZD6HBK.js";
|
|
4
|
+
import {
|
|
5
|
+
asNonEmptyStringArray
|
|
6
|
+
} from "./chunk-I42VC5KR.js";
|
|
7
|
+
import {
|
|
8
|
+
asTrimmedString
|
|
9
|
+
} from "./chunk-3EUW3WEO.js";
|
|
10
|
+
import {
|
|
11
|
+
asOptionalPositiveFiniteNumber
|
|
12
|
+
} from "./chunk-U6VC4MU4.js";
|
|
13
|
+
import {
|
|
14
|
+
isRecord
|
|
15
|
+
} from "./chunk-KUG52IAP.js";
|
|
16
|
+
|
|
17
|
+
// packages/agent-runtime/fileCredentialBroker.ts
|
|
18
|
+
import {
|
|
19
|
+
chmodSync,
|
|
20
|
+
existsSync,
|
|
21
|
+
mkdirSync,
|
|
22
|
+
readFileSync,
|
|
23
|
+
unlinkSync,
|
|
24
|
+
writeFileSync
|
|
25
|
+
} from "node:fs";
|
|
26
|
+
import { join } from "node:path";
|
|
27
|
+
|
|
28
|
+
// packages/agent-runtime/credentialBroker.ts
|
|
29
|
+
function assertCredentialRef(ref) {
|
|
30
|
+
const trimmed = asTrimmedString(ref);
|
|
31
|
+
if (!trimmed) {
|
|
32
|
+
throw new Error("invalid_ref");
|
|
33
|
+
}
|
|
34
|
+
if (trimmed.includes("..") || trimmed.includes("/") || trimmed.includes("\\")) {
|
|
35
|
+
throw new Error("invalid_ref");
|
|
36
|
+
}
|
|
37
|
+
return trimmed;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// packages/agent-runtime/fileCredentialBroker.ts
|
|
41
|
+
function getApiKeyCredentialsDir(homeDir) {
|
|
42
|
+
return join(getCredentialsDir(homeDir), "keys");
|
|
43
|
+
}
|
|
44
|
+
function credentialRefToFileName(ref) {
|
|
45
|
+
const safe = assertCredentialRef(ref).replace(/[^a-zA-Z0-9._-]+/g, "_");
|
|
46
|
+
if (!safe || safe === "." || safe === "..") {
|
|
47
|
+
throw new Error(`Credential ref is not filesystem-safe: ${ref}`);
|
|
48
|
+
}
|
|
49
|
+
return `${safe}.json`;
|
|
50
|
+
}
|
|
51
|
+
function getApiKeyCredentialPath(ref, homeDir) {
|
|
52
|
+
return join(getApiKeyCredentialsDir(homeDir), credentialRefToFileName(ref));
|
|
53
|
+
}
|
|
54
|
+
function ensurePrivateDir(dir) {
|
|
55
|
+
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
56
|
+
try {
|
|
57
|
+
chmodSync(dir, 448);
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function writePrivateFile(path, body) {
|
|
62
|
+
writeFileSync(path, body, { encoding: "utf8", mode: 384 });
|
|
63
|
+
try {
|
|
64
|
+
chmodSync(path, 384);
|
|
65
|
+
} catch {
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function readApiKeyCredential(ref, homeDir) {
|
|
69
|
+
const path = getApiKeyCredentialPath(ref, homeDir);
|
|
70
|
+
if (!existsSync(path)) return null;
|
|
71
|
+
try {
|
|
72
|
+
const raw = readFileSync(path, "utf8");
|
|
73
|
+
const parsed = JSON.parse(raw);
|
|
74
|
+
if (typeof parsed?.secret !== "string" || !parsed.secret) return null;
|
|
75
|
+
return parsed.secret;
|
|
76
|
+
} catch {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function writeApiKeyCredential(ref, secret, homeDir, now = Date.now()) {
|
|
81
|
+
const trimmedSecret = secret.trim();
|
|
82
|
+
if (!trimmedSecret) {
|
|
83
|
+
throw new Error("Cannot store an empty credential secret.");
|
|
84
|
+
}
|
|
85
|
+
assertCredentialRef(ref);
|
|
86
|
+
const dir = getApiKeyCredentialsDir(homeDir);
|
|
87
|
+
ensurePrivateDir(dir);
|
|
88
|
+
const path = getApiKeyCredentialPath(ref, homeDir);
|
|
89
|
+
const payload = {
|
|
90
|
+
secret: trimmedSecret,
|
|
91
|
+
updatedAt: now
|
|
92
|
+
};
|
|
93
|
+
writePrivateFile(path, `${JSON.stringify(payload, null, 2)}
|
|
94
|
+
`);
|
|
95
|
+
}
|
|
96
|
+
function removeApiKeyCredential(ref, homeDir) {
|
|
97
|
+
assertCredentialRef(ref);
|
|
98
|
+
const path = getApiKeyCredentialPath(ref, homeDir);
|
|
99
|
+
if (!existsSync(path)) return;
|
|
100
|
+
unlinkSync(path);
|
|
101
|
+
}
|
|
102
|
+
function hasApiKeyCredential(ref, homeDir) {
|
|
103
|
+
return readApiKeyCredential(ref, homeDir) !== null;
|
|
104
|
+
}
|
|
105
|
+
function createFileCredentialBroker(options = {}) {
|
|
106
|
+
const homeDir = options.homeDir;
|
|
107
|
+
const now = options.now ?? Date.now;
|
|
108
|
+
return {
|
|
109
|
+
get(ref) {
|
|
110
|
+
return readApiKeyCredential(ref, homeDir);
|
|
111
|
+
},
|
|
112
|
+
put(ref, secret) {
|
|
113
|
+
writeApiKeyCredential(ref, secret, homeDir, now());
|
|
114
|
+
},
|
|
115
|
+
delete(ref) {
|
|
116
|
+
removeApiKeyCredential(ref, homeDir);
|
|
117
|
+
},
|
|
118
|
+
has(ref) {
|
|
119
|
+
return hasApiKeyCredential(ref, homeDir);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// packages/agent-runtime/migrateAgentSecrets.ts
|
|
125
|
+
function buildAgentApiKeyCredentialRef(agentKey) {
|
|
126
|
+
const key = asTrimmedString(agentKey);
|
|
127
|
+
if (!key) throw new Error("agentKey is required to build a credential ref.");
|
|
128
|
+
return `api-key:${key}`;
|
|
129
|
+
}
|
|
130
|
+
function readRawApiKey(agent) {
|
|
131
|
+
return asTrimmedString(agent.apiKey);
|
|
132
|
+
}
|
|
133
|
+
function resolveTargetRef(agent) {
|
|
134
|
+
const fromCredential = asTrimmedString(agent.credentialRef);
|
|
135
|
+
if (fromCredential) return fromCredential;
|
|
136
|
+
const fromApiKeyRef = asTrimmedString(agent.apiKeyRef);
|
|
137
|
+
if (fromApiKeyRef.startsWith("api-key:")) return fromApiKeyRef;
|
|
138
|
+
return buildAgentApiKeyCredentialRef(agent.key);
|
|
139
|
+
}
|
|
140
|
+
async function brokerHas(broker, ref) {
|
|
141
|
+
return Boolean(await broker.has(ref));
|
|
142
|
+
}
|
|
143
|
+
async function brokerPut(broker, ref, secret) {
|
|
144
|
+
await broker.put(ref, secret);
|
|
145
|
+
}
|
|
146
|
+
async function migrateAgentSecrets(args) {
|
|
147
|
+
const { agent, broker } = args;
|
|
148
|
+
const raw = readRawApiKey(agent);
|
|
149
|
+
const migration = asTrimmedString(agent.credentialMigration);
|
|
150
|
+
if (migration === "done" && !raw) {
|
|
151
|
+
const ref = typeof agent.credentialRef === "string" && agent.credentialRef.trim() || (typeof agent.apiKeyRef === "string" && agent.apiKeyRef.startsWith("api-key:") ? agent.apiKeyRef.trim() : "") || void 0;
|
|
152
|
+
return {
|
|
153
|
+
updates: {},
|
|
154
|
+
status: "already-done",
|
|
155
|
+
...ref ? { credentialRef: ref } : {},
|
|
156
|
+
phase: "complete"
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (!raw && migration !== "pending") {
|
|
160
|
+
return { updates: {}, status: "noop", phase: "none" };
|
|
161
|
+
}
|
|
162
|
+
const targetRef = resolveTargetRef(agent);
|
|
163
|
+
if (raw) {
|
|
164
|
+
await brokerPut(broker, targetRef, raw);
|
|
165
|
+
const stored2 = await brokerHas(broker, targetRef);
|
|
166
|
+
if (!stored2) {
|
|
167
|
+
return {
|
|
168
|
+
updates: {
|
|
169
|
+
credentialRef: targetRef,
|
|
170
|
+
credentialMigration: "pending"
|
|
171
|
+
},
|
|
172
|
+
status: "resumed-pending",
|
|
173
|
+
credentialRef: targetRef,
|
|
174
|
+
phase: "put"
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
updates: {
|
|
179
|
+
apiKey: null,
|
|
180
|
+
credentialRef: targetRef,
|
|
181
|
+
// Keep apiKeyRef for resolution if not already an OAuth provider name.
|
|
182
|
+
// Prefer explicit credentialRef; set apiKeyRef only when empty so OAuth agents stay intact.
|
|
183
|
+
...!(typeof agent.apiKeyRef === "string" && agent.apiKeyRef.trim()) ? { apiKeyRef: targetRef } : {},
|
|
184
|
+
credentialMigration: "done"
|
|
185
|
+
},
|
|
186
|
+
status: migration === "pending" ? "resumed-pending" : "migrated",
|
|
187
|
+
credentialRef: targetRef,
|
|
188
|
+
phase: "strip"
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
const stored = await brokerHas(broker, targetRef);
|
|
192
|
+
if (stored) {
|
|
193
|
+
return {
|
|
194
|
+
updates: {
|
|
195
|
+
credentialRef: targetRef,
|
|
196
|
+
credentialMigration: "done",
|
|
197
|
+
...!(typeof agent.apiKeyRef === "string" && agent.apiKeyRef.trim()) ? { apiKeyRef: targetRef } : {}
|
|
198
|
+
},
|
|
199
|
+
status: "resumed-pending",
|
|
200
|
+
credentialRef: targetRef,
|
|
201
|
+
phase: "complete"
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
updates: {
|
|
206
|
+
credentialRef: targetRef,
|
|
207
|
+
credentialMigration: "pending"
|
|
208
|
+
},
|
|
209
|
+
status: "awaiting-secret",
|
|
210
|
+
credentialRef: targetRef,
|
|
211
|
+
phase: "put"
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function applyAgentSecretMigrationUpdates(record, updates) {
|
|
215
|
+
const next = { ...record };
|
|
216
|
+
if ("apiKey" in updates) {
|
|
217
|
+
if (updates.apiKey === null || updates.apiKey === "") {
|
|
218
|
+
delete next.apiKey;
|
|
219
|
+
} else if (typeof updates.apiKey === "string") {
|
|
220
|
+
next.apiKey = updates.apiKey;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (updates.apiKeyRef !== void 0) next.apiKeyRef = updates.apiKeyRef;
|
|
224
|
+
if (updates.credentialRef !== void 0) next.credentialRef = updates.credentialRef;
|
|
225
|
+
if (updates.credentialMigration !== void 0) {
|
|
226
|
+
next.credentialMigration = updates.credentialMigration;
|
|
227
|
+
}
|
|
228
|
+
return next;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// packages/agent-runtime/runtimeToolPolicy.ts
|
|
232
|
+
function unique(values) {
|
|
233
|
+
return [...new Set(values)];
|
|
234
|
+
}
|
|
235
|
+
function normalizeAgentRuntimeToolPolicy(value) {
|
|
236
|
+
if (!isRecord(value)) return void 0;
|
|
237
|
+
return {
|
|
238
|
+
version: 1,
|
|
239
|
+
...asNonEmptyStringArray(value.agentTools).length ? { agentTools: unique(asNonEmptyStringArray(value.agentTools)) } : {},
|
|
240
|
+
...asNonEmptyStringArray(value.runtimeTools).length ? { runtimeTools: unique(asNonEmptyStringArray(value.runtimeTools)) } : {},
|
|
241
|
+
...isRecord(value.workspace) ? { workspace: { ...value.workspace } } : {},
|
|
242
|
+
...isRecord(value.shell) ? { shell: { ...value.shell } } : {},
|
|
243
|
+
...isRecord(value.isolation) ? { isolation: { ...value.isolation } } : {},
|
|
244
|
+
...isRecord(value.git) ? { git: { ...value.git } } : {},
|
|
245
|
+
...isRecord(value.budget) ? { budget: { ...value.budget } } : {},
|
|
246
|
+
...isRecord(value.audit) ? { audit: { ...value.audit } } : {}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
function runtimeBindingRecord(runtimeBinding) {
|
|
250
|
+
return isRecord(runtimeBinding) ? runtimeBinding : void 0;
|
|
251
|
+
}
|
|
252
|
+
function runtimeToolNamesFromPolicy(policy) {
|
|
253
|
+
return asNonEmptyStringArray(policy?.runtimeTools);
|
|
254
|
+
}
|
|
255
|
+
function readPositiveNumber(value) {
|
|
256
|
+
return asOptionalPositiveFiniteNumber(Number(value));
|
|
257
|
+
}
|
|
258
|
+
function resolveRequestedRuntimeToolNames(args) {
|
|
259
|
+
const runtimeBinding = runtimeBindingRecord(args.agentConfig.runtimeBinding);
|
|
260
|
+
const bindingPolicy = normalizeAgentRuntimeToolPolicy(
|
|
261
|
+
runtimeBinding?.runtimeToolPolicy
|
|
262
|
+
);
|
|
263
|
+
const bindingSnapshotPolicy = normalizeAgentRuntimeToolPolicy(
|
|
264
|
+
runtimeBinding?.runtimeToolPolicySnapshot
|
|
265
|
+
);
|
|
266
|
+
return unique([
|
|
267
|
+
...asNonEmptyStringArray(args.agentConfig.toolNames),
|
|
268
|
+
...runtimeToolNamesFromPolicy(
|
|
269
|
+
normalizeAgentRuntimeToolPolicy(args.agentConfig.runtimeToolPolicy)
|
|
270
|
+
),
|
|
271
|
+
...runtimeToolNamesFromPolicy(bindingPolicy),
|
|
272
|
+
...runtimeToolNamesFromPolicy(bindingSnapshotPolicy)
|
|
273
|
+
]);
|
|
274
|
+
}
|
|
275
|
+
function resolveCurrentRunRuntimeToolPolicy(agentConfig) {
|
|
276
|
+
const runtimeBinding = runtimeBindingRecord(agentConfig?.runtimeBinding);
|
|
277
|
+
return normalizeAgentRuntimeToolPolicy(
|
|
278
|
+
runtimeBinding?.runtimeToolPolicySnapshot ?? agentConfig?.runtimeToolPolicy ?? runtimeBinding?.runtimeToolPolicy
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
function resolveLocalRuntimeEnvFromPolicy(runtimeEnv, policy) {
|
|
282
|
+
return { ...runtimeEnv };
|
|
283
|
+
}
|
|
284
|
+
function resolveLocalWorkspaceExecutorOptionsFromPolicy(policy) {
|
|
285
|
+
const maxOutputBytes = readPositiveNumber(policy?.shell?.maxOutputBytes);
|
|
286
|
+
return {
|
|
287
|
+
...maxOutputBytes ? { commandOutputLimit: Math.floor(maxOutputBytes) } : {}
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export {
|
|
292
|
+
createFileCredentialBroker,
|
|
293
|
+
migrateAgentSecrets,
|
|
294
|
+
applyAgentSecretMigrationUpdates,
|
|
295
|
+
normalizeAgentRuntimeToolPolicy,
|
|
296
|
+
resolveRequestedRuntimeToolNames,
|
|
297
|
+
resolveCurrentRunRuntimeToolPolicy,
|
|
298
|
+
resolveLocalRuntimeEnvFromPolicy,
|
|
299
|
+
resolveLocalWorkspaceExecutorOptionsFromPolicy
|
|
300
|
+
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// packages/core/chat/internalTurnEvent.ts
|
|
2
|
+
function normalizeRunCompletionShape(record) {
|
|
3
|
+
const runId = String(record.runId ?? record.id ?? "");
|
|
4
|
+
const agentKey = String(record.agentKey ?? record.agent ?? "");
|
|
5
|
+
const status = String(record.status ?? "done");
|
|
6
|
+
const counters = record.activity?.counters;
|
|
7
|
+
return {
|
|
8
|
+
runId,
|
|
9
|
+
agentKey,
|
|
10
|
+
...typeof record.agentName === "string" ? { agentName: record.agentName } : {},
|
|
11
|
+
status,
|
|
12
|
+
...typeof record.exitCode === "number" ? { exitCode: record.exitCode } : {},
|
|
13
|
+
...typeof record.parentDialogId === "string" ? { parentDialogId: record.parentDialogId } : {},
|
|
14
|
+
...typeof record.dialogId === "string" ? { dialogId: record.dialogId } : {},
|
|
15
|
+
...typeof record.ephemeral === "boolean" ? { ephemeral: record.ephemeral } : {},
|
|
16
|
+
...record.startedAt !== void 0 ? { startedAt: record.startedAt } : {},
|
|
17
|
+
...record.endedAt !== void 0 ? { endedAt: record.endedAt } : {},
|
|
18
|
+
...typeof record.note === "string" ? { note: record.note } : {},
|
|
19
|
+
...typeof record.error === "string" ? { error: record.error } : {},
|
|
20
|
+
...typeof record.ack === "boolean" ? { ack: record.ack } : {},
|
|
21
|
+
...counters ? {
|
|
22
|
+
activity: {
|
|
23
|
+
counters: {
|
|
24
|
+
toolCalls: typeof counters.toolCalls === "number" ? counters.toolCalls : 0,
|
|
25
|
+
llmCalls: typeof counters.llmCalls === "number" ? counters.llmCalls : 0,
|
|
26
|
+
fileEdits: typeof counters.fileEdits === "number" ? counters.fileEdits : 0
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
} : {}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function createTurnRequest(input) {
|
|
33
|
+
if (typeof input === "string") {
|
|
34
|
+
return {
|
|
35
|
+
event: { kind: "user", text: input },
|
|
36
|
+
text: input
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if ("event" in input && typeof input.event === "object" && typeof input.text === "string") {
|
|
40
|
+
return input;
|
|
41
|
+
}
|
|
42
|
+
const event = input;
|
|
43
|
+
return {
|
|
44
|
+
event,
|
|
45
|
+
text: event.text
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// packages/core/chat/chatQueueMachine.ts
|
|
50
|
+
var initialChatQueueState = {
|
|
51
|
+
running: false,
|
|
52
|
+
queue: [],
|
|
53
|
+
drainPaused: false,
|
|
54
|
+
lastDrainError: null
|
|
55
|
+
};
|
|
56
|
+
function reduceChatQueue(state, event) {
|
|
57
|
+
switch (event.type) {
|
|
58
|
+
case "turn-start":
|
|
59
|
+
if (state.running && state.lastDrainError === null) return state;
|
|
60
|
+
return {
|
|
61
|
+
...state,
|
|
62
|
+
running: true,
|
|
63
|
+
lastDrainError: null
|
|
64
|
+
};
|
|
65
|
+
case "turn-end":
|
|
66
|
+
return {
|
|
67
|
+
...state,
|
|
68
|
+
running: false,
|
|
69
|
+
queue: event.aborted ? [] : state.queue,
|
|
70
|
+
lastDrainError: !event.ok && !event.aborted ? "previous turn failed" : state.lastDrainError
|
|
71
|
+
};
|
|
72
|
+
case "enqueue": {
|
|
73
|
+
const req = createTurnRequest(event.text);
|
|
74
|
+
if (!req.text.trim() && req.event.kind === "user") {
|
|
75
|
+
return state;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
...state,
|
|
79
|
+
queue: [...state.queue, req]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
case "dequeue":
|
|
83
|
+
if (state.queue.length === 0) return state;
|
|
84
|
+
return {
|
|
85
|
+
...state,
|
|
86
|
+
queue: state.queue.slice(1)
|
|
87
|
+
};
|
|
88
|
+
case "clear":
|
|
89
|
+
if (state.queue.length === 0 && state.lastDrainError === null) return state;
|
|
90
|
+
return {
|
|
91
|
+
...state,
|
|
92
|
+
queue: [],
|
|
93
|
+
lastDrainError: null
|
|
94
|
+
};
|
|
95
|
+
case "pause-drain":
|
|
96
|
+
if (state.drainPaused) return state;
|
|
97
|
+
return {
|
|
98
|
+
...state,
|
|
99
|
+
drainPaused: true
|
|
100
|
+
};
|
|
101
|
+
case "resume-drain":
|
|
102
|
+
if (!state.drainPaused) return state;
|
|
103
|
+
return {
|
|
104
|
+
...state,
|
|
105
|
+
drainPaused: false
|
|
106
|
+
};
|
|
107
|
+
case "drain-error":
|
|
108
|
+
return {
|
|
109
|
+
...state,
|
|
110
|
+
lastDrainError: event.message || null
|
|
111
|
+
};
|
|
112
|
+
default:
|
|
113
|
+
return state;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function shouldDrainAfterTurnEnd(state, cleanTurnEnd) {
|
|
117
|
+
return cleanTurnEnd && !state.running && !state.drainPaused && state.queue.length > 0;
|
|
118
|
+
}
|
|
119
|
+
function applyChatQueueEvent(state, event) {
|
|
120
|
+
const prevQueueLen = state.queue.length;
|
|
121
|
+
const prevRunning = state.running;
|
|
122
|
+
const prevPaused = state.drainPaused;
|
|
123
|
+
const next = reduceChatQueue(state, event);
|
|
124
|
+
const outgoing = [];
|
|
125
|
+
if (next.queue.length !== prevQueueLen) {
|
|
126
|
+
outgoing.push({ type: "queue-changed", length: next.queue.length });
|
|
127
|
+
}
|
|
128
|
+
if (next.running !== prevRunning) {
|
|
129
|
+
outgoing.push({ type: "running-changed", running: next.running });
|
|
130
|
+
}
|
|
131
|
+
if (next.drainPaused !== prevPaused) {
|
|
132
|
+
outgoing.push({ type: "drain-paused-changed", paused: next.drainPaused });
|
|
133
|
+
}
|
|
134
|
+
if (event.type === "turn-end" && !event.aborted && event.ok) {
|
|
135
|
+
if (shouldDrainAfterTurnEnd(next, true)) {
|
|
136
|
+
const head = next.queue[0];
|
|
137
|
+
outgoing.push({ type: "drain-ready", text: head.text, request: head });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return { state: next, outgoing };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// packages/core/chat/chatQueueRuntime.ts
|
|
144
|
+
function createChatQueueRuntime(initialState = initialChatQueueState) {
|
|
145
|
+
let state = initialState;
|
|
146
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
147
|
+
const dispatch = (events) => {
|
|
148
|
+
for (const e of events) {
|
|
149
|
+
for (const l of listeners) l(e);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
return {
|
|
153
|
+
getState: () => state,
|
|
154
|
+
send(event) {
|
|
155
|
+
const result = applyChatQueueEvent(state, event);
|
|
156
|
+
state = result.state;
|
|
157
|
+
dispatch(result.outgoing);
|
|
158
|
+
return state;
|
|
159
|
+
},
|
|
160
|
+
subscribe(listener) {
|
|
161
|
+
listeners.add(listener);
|
|
162
|
+
return () => {
|
|
163
|
+
listeners.delete(listener);
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
on(type, listener) {
|
|
167
|
+
const wrapped = (e) => {
|
|
168
|
+
if (e.type === type) {
|
|
169
|
+
listener(e);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
listeners.add(wrapped);
|
|
173
|
+
return () => {
|
|
174
|
+
listeners.delete(wrapped);
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
dispose() {
|
|
178
|
+
listeners.clear();
|
|
179
|
+
state = initialChatQueueState;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export {
|
|
185
|
+
normalizeRunCompletionShape,
|
|
186
|
+
createTurnRequest,
|
|
187
|
+
createChatQueueRuntime
|
|
188
|
+
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
trimTrailingSlash
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-7YYHKBJP.js";
|
|
4
4
|
import {
|
|
5
5
|
toErrorMessage
|
|
6
6
|
} from "./chunk-HNMXYYJR.js";
|
|
7
|
-
import {
|
|
8
|
-
asTrimmedLowercaseString
|
|
9
|
-
} from "./chunk-QSJ3HFEF.js";
|
|
10
7
|
import {
|
|
11
8
|
asOptionalFiniteNumber
|
|
12
9
|
} from "./chunk-WWC7I6TA.js";
|
|
10
|
+
import {
|
|
11
|
+
asTrimmedLowercaseString
|
|
12
|
+
} from "./chunk-QSJ3HFEF.js";
|
|
13
13
|
import {
|
|
14
14
|
asOptionalTrimmedString
|
|
15
15
|
} from "./chunk-G3SUCT4W.js";
|