nolo-cli 0.99.0-alpha.1 → 0.99.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-CJP7VSJB.js → _executeModel-F324DLT6.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-2YAHAZFJ.js → agentDeleteCommand-EFWZSSZA.js} +47 -42
- package/{agentEmailCommands-UH7KTTCN.js → agentEmailCommands-3TQXT2DZ.js} +97 -87
- package/agentListCommands-EDV4RJ4D.js +742 -0
- package/{agentMachineCommands-6NVUXZGQ.js → agentMachineCommands-HCHRMJRJ.js} +48 -43
- package/{agentProviderCommands-GNPTL5XR.js → agentProviderCommands-IRNZXVGE.js} +1 -1
- package/{agentPullCommand-O5MPVJ5E.js → agentPullCommand-B4T2DJ5H.js} +1 -1
- package/agentRecordCommands-YX7CN2PH.js +138 -0
- package/agentRunCommand-BT5U3G5Q.js +167 -0
- package/{agentRunControl-AVJR4JW4.js → agentRunControl-3HWA2LLQ.js} +2 -2
- package/{agentRuntimeLocal-VXZSDIGT.js → agentRuntimeLocal-SXYAKX3A.js} +48 -39
- package/{agentSlice-OU6TZKQP.js → agentSlice-TFZX3W5R.js} +14 -13
- package/{appDeleteCommands-32MHLR4L.js → appDeleteCommands-GTTBG53T.js} +46 -41
- package/{appDeployCommands-WCQOUSOB.js → appDeployCommands-ZZCHUJAT.js} +46 -41
- package/{appDeployStatusCommands-6QKB7DYN.js → appDeployStatusCommands-GZLLGY7Z.js} +46 -41
- package/{appGetCommands-SFAPP5PB.js → appGetCommands-ZRLWHJ3C.js} +46 -41
- package/{appListCommands-EKUBDRUO.js → appListCommands-OHARWLIL.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-36XI7AVG.js +7881 -0
- package/{chunk-CSSGXQJ3.js → chunk-3AD37QCF.js} +551 -516
- 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-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-GQBOR3G6.js → chunk-7KVZ5LDQ.js} +2 -2
- package/{chunk-DNCEALKX.js → chunk-7MMSLEPA.js} +22 -29
- package/{chunk-L5UXH3B2.js → chunk-7TKWCTSY.js} +22 -6
- package/chunk-7UEMHIFV.js +13536 -0
- 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-53SXIJK6.js → chunk-AW2UF3FF.js} +19 -17
- package/chunk-BMQ2MJUK.js +153 -0
- package/{chunk-6YTOJY35.js → chunk-BZ7NPA6G.js} +35 -2
- 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-BA63USCV.js → chunk-ED7UD6EF.js} +1 -1
- 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-6IG4XSS6.js → chunk-FY7DCYW7.js} +88 -17
- package/{chunk-6VFARHZW.js → chunk-G53AA7RW.js} +934 -1091
- package/{chunk-J4MOO56S.js → chunk-GARACBQB.js} +10 -2
- 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-WCI7KQ4F.js → chunk-HPATMUWW.js} +24 -77
- package/{chunk-WP7SWVOM.js → chunk-I5L5CBSE.js} +20 -11
- package/{chunk-7KBQIEEW.js → chunk-J6ZXSIBA.js} +11 -9
- package/{chunk-GPCZ7UXG.js → chunk-K6U4NKFJ.js} +1 -1
- package/{chunk-FXRSQVU4.js → chunk-L6VWRPBW.js} +24 -5
- package/{chunk-4OEFYTWL.js → chunk-LKERWYPX.js} +67 -48
- package/{chunk-OEVAY4J6.js → chunk-LNVJHIGA.js} +18 -20
- package/{chunk-LS2ZANRJ.js → chunk-LOCNXNOU.js} +1 -1
- package/{chunk-PUOC4YRO.js → chunk-M7VLQGQP.js} +11 -0
- package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
- package/{chunk-FZGV4FGK.js → chunk-NUHHBEJC.js} +378 -187
- package/chunk-NWENLDMM.js +42 -0
- package/{chunk-AEOE4Z6Q.js → chunk-NZWAO6LH.js} +13 -15
- package/chunk-OCZKATRC.js +129 -0
- package/chunk-OW4APERY.js +870 -0
- package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
- package/{chunk-KIOVECFO.js → chunk-OYA47B3D.js} +873 -227
- package/{chunk-TOP2VXOR.js → chunk-PCF3QU5Q.js} +5 -5
- package/{chunk-WV42OMV7.js → chunk-PTDYOADJ.js} +8 -8
- package/{chunk-5H7KJX7J.js → chunk-SEB5HAUU.js} +5 -5
- 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-ICLAW6SN.js → chunk-TWYWQFJR.js} +10 -10
- 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-GEPUP7OO.js → chunk-UVKDJUTL.js} +3 -3
- package/{chunk-S2YPVYRY.js → chunk-UW4JVRYR.js} +67 -45
- package/{chunk-ZCYXJSTU.js → chunk-V5OWQOJZ.js} +19 -88
- package/{chunk-NA35QHCF.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-VA2M2T36.js → chunk-VNR63IV3.js} +23 -28
- package/{chunk-UKWGR5SS.js → chunk-VY6VFGKR.js} +194 -1144
- package/{chunk-BP4XNZRM.js → chunk-W72ISAKC.js} +4 -4
- package/{chunk-DHDMC6FO.js → chunk-WCGC6S77.js} +14 -9
- package/{chunk-ZDXFQMB4.js → chunk-WHZ67DFH.js} +47 -67
- package/{chunk-QDSINZM3.js → chunk-WJ3B6FX6.js} +1 -14
- 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-ETI2NYVF.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-MODC2W5M.js +833 -0
- package/{contentThunks-I3AWWOK4.js → contentThunks-636N2NA7.js} +36 -34
- package/{cooldownCommands-REAWYVTY.js → cooldownCommands-ZLEPIB4A.js} +2 -2
- package/{createAgentAutomationAction-QNNIWYI3.js → createAgentAutomationAction-2ZGYUIT4.js} +38 -36
- package/createDialogAction-DOZD7XW7.js +69 -0
- package/{createPageAction-G2ASSMFZ.js → createPageAction-FJQVAHIK.js} +45 -42
- package/{chunk-Q6NAY3XN.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-5J56DFWN.js → dialogCommands-LF7PLYAD.js} +49 -45
- package/{dialogSlice-HQLYBDH7.js → dialogSlice-FOWUVVPW.js} +40 -33
- package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
- package/{docCreateCommands-KYI2DC2U.js → docCreateCommands-NQR3S7A4.js} +48 -43
- package/{docDeleteCommands-67REUSRY.js → docDeleteCommands-V3IAQ2HT.js} +49 -44
- package/{docReadCommands-HOSVSBDJ.js → docReadCommands-GDX4CLSU.js} +47 -42
- package/{docStore-5LMRNCZG.js → docStore-F645L3JQ.js} +16 -12
- package/{docUpdateCommands-EMGCSMXY.js → docUpdateCommands-QMYXWQOU.js} +48 -43
- package/{fetchMessages-EIU7UFFK.js → fetchMessages-I5ICDDHM.js} +5 -5
- package/{getPricing-LUSEABA6.js → getPricing-NMMFT3YI.js} +4 -4
- package/{handleSendMessageAction-DMWWDWN5.js → handleSendMessageAction-6DCDAY6A.js} +110 -86
- package/index.js +87 -884
- package/{lib-FRRS27KN.js → lib-PU2G2MSO.js} +523 -191
- 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-T4T4AUNA.js → machineCommands-465OUHT4.js} +91 -81
- package/machineWsRunDispatch-M3FUGFP4.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-LN2D7OGW.js → readlineWorkspace-LFCVKGAB.js} +2704 -2060
- package/{removeDialogAgentAction-IX3MN2ZO.js → removeDialogAgentAction-46XQV5Q7.js} +21 -25
- package/{runAgentClientLoop-I773V27D.js → runAgentClientLoop-KBRADH67.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-NKJVJCQQ.js → spaceCommands-2P2X37MC.js} +51 -46
- package/{streamAgentChatTurn-PSF5RYKO.js → streamAgentChatTurn-CCOW4CUC.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-QNXUF3LE.js +116 -0
- package/{tuiSummaryLlmCaller-WFRWERGK.js → tuiSummaryLlmCaller-Q65IBDGO.js} +24 -21
- package/{updateCommands-2M74UL7P.js → updateCommands-4EHDLF5J.js} +3 -3
- package/{updateDialogTitleAction-QBT5WOLY.js → updateDialogTitleAction-ZLUQE6XC.js} +82 -44
- package/action-YVYQEAAV.js +0 -31
- package/agentListCommands-KMS675GZ.js +0 -406
- package/agentRecordCommands-A7AIQPNG.js +0 -128
- package/agentRunCommand-KO5UM7O6.js +0 -155
- package/browser-image-compression-MFDTD7K6.js +0 -1763
- package/chatQueueReduxAdapter-JS633LXU.js +0 -186
- 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-YHYPCMKI.js +0 -19005
- package/chunk-YPREESF4.js +0 -225
- package/createDialogAction-STKILXXW.js +0 -65
- package/machineWsRunDispatch-F6XWVLKA.js +0 -144
- package/settingSlice-ZQZVUPKK.js +0 -204
- package/syncMapping-N6RGXGBW.js +0 -437
- package/tools-2ZTTVIGF.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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BUILTIN_NOLO_AGENT_KEY
|
|
3
|
+
} from "./chunk-BNGW5ASC.js";
|
|
4
|
+
|
|
5
|
+
// packages/core/init.ts
|
|
6
|
+
var nolotusId = "0e95801d90";
|
|
7
|
+
var ADMIN_IDS = /* @__PURE__ */ new Set([nolotusId]);
|
|
8
|
+
var isSystemAdmin = (userId) => userId != null && ADMIN_IDS.has(userId);
|
|
9
|
+
var noloAgentId = BUILTIN_NOLO_AGENT_KEY;
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
nolotusId,
|
|
13
|
+
isSystemAdmin,
|
|
14
|
+
noloAgentId
|
|
15
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
dialogMessageRange
|
|
3
|
-
} from "./chunk-VMFTFOWF.js";
|
|
4
1
|
import {
|
|
5
2
|
isTombstoneRecord
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-D2MDMY2M.js";
|
|
7
4
|
import {
|
|
8
5
|
isRecord
|
|
9
6
|
} from "./chunk-KUG52IAP.js";
|
|
7
|
+
import {
|
|
8
|
+
dialogMessageRange
|
|
9
|
+
} from "./chunk-3AH7LNUB.js";
|
|
10
10
|
|
|
11
11
|
// packages/chat/messages/fetchMessages.ts
|
|
12
12
|
function isUnboundedMessageLimit(limit) {
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// packages/create/editor/utils/slateUtils.ts
|
|
2
|
+
var slateNodeToString = (node) => {
|
|
3
|
+
if (typeof node?.text === "string") return node.text;
|
|
4
|
+
const children = Array.isArray(node?.children) ? node.children : [];
|
|
5
|
+
return children.map(slateNodeToString).join("");
|
|
6
|
+
};
|
|
7
|
+
var createEmptyParagraph = () => ({
|
|
8
|
+
type: "paragraph",
|
|
9
|
+
children: [{ text: "" }]
|
|
10
|
+
});
|
|
11
|
+
var ensureEditorContent = (slateData) => Array.isArray(slateData) && slateData.length > 0 ? slateData : [createEmptyParagraph()];
|
|
12
|
+
var deepEqual = (a, b) => {
|
|
13
|
+
if (a === b) return true;
|
|
14
|
+
if (a == null || b == null) return false;
|
|
15
|
+
if (typeof a !== "object" || typeof b !== "object") return false;
|
|
16
|
+
const isArrayA = Array.isArray(a);
|
|
17
|
+
const isArrayB = Array.isArray(b);
|
|
18
|
+
if (isArrayA || isArrayB) {
|
|
19
|
+
if (!isArrayA || !isArrayB) return false;
|
|
20
|
+
if (a.length !== b.length) return false;
|
|
21
|
+
for (let i = 0; i < a.length; i++) {
|
|
22
|
+
if (!deepEqual(a[i], b[i])) return false;
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
const keysA = Object.keys(a);
|
|
27
|
+
const keysB = Object.keys(b);
|
|
28
|
+
if (keysA.length !== keysB.length) return false;
|
|
29
|
+
for (const key of keysA) {
|
|
30
|
+
if (!Object.prototype.hasOwnProperty.call(b, key)) return false;
|
|
31
|
+
if (!deepEqual(a[key], b[key])) return false;
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
};
|
|
35
|
+
var compareSlateContent = (newContent, oldContent) => {
|
|
36
|
+
if (newContent === oldContent) return false;
|
|
37
|
+
if (!newContent || !oldContent) return true;
|
|
38
|
+
if (newContent.length !== oldContent.length) return true;
|
|
39
|
+
return !deepEqual(newContent, oldContent);
|
|
40
|
+
};
|
|
41
|
+
var extractTitleFromSlate = (slateData) => {
|
|
42
|
+
if (!Array.isArray(slateData) || slateData.length === 0) return "\u65B0\u9875\u9762";
|
|
43
|
+
const titleNode = slateData.find((node) => node.type === "heading-one");
|
|
44
|
+
if (titleNode) {
|
|
45
|
+
const text = slateNodeToString(titleNode).trim();
|
|
46
|
+
if (text) {
|
|
47
|
+
return text;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for (const node of slateData) {
|
|
51
|
+
const text = slateNodeToString(node).trim();
|
|
52
|
+
if (text) {
|
|
53
|
+
return text.length > 30 ? `${text.substring(0, 30)}...` : text;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return "\u65B0\u9875\u9762";
|
|
57
|
+
};
|
|
58
|
+
var splitSlateTitleAndBody = (slateData, explicitTitle) => {
|
|
59
|
+
const content = ensureEditorContent(slateData);
|
|
60
|
+
const firstNode = content[0];
|
|
61
|
+
const hasExplicitTitle = explicitTitle !== void 0 && explicitTitle !== null;
|
|
62
|
+
const normalizedExplicitTitle = hasExplicitTitle ? explicitTitle.trim() : null;
|
|
63
|
+
const firstNonEmptyText = content.map((node) => slateNodeToString(node).trim()).find(Boolean);
|
|
64
|
+
if (firstNode?.type === "heading-one") {
|
|
65
|
+
const firstText = slateNodeToString(firstNode).trim();
|
|
66
|
+
const shouldTreatAsTitle = !!firstText && (normalizedExplicitTitle == null || normalizedExplicitTitle === firstText);
|
|
67
|
+
if (shouldTreatAsTitle) {
|
|
68
|
+
const body = content.slice(1);
|
|
69
|
+
return {
|
|
70
|
+
title: firstText,
|
|
71
|
+
body: ensureEditorContent(body)
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
title: normalizedExplicitTitle ?? (firstNonEmptyText || ""),
|
|
77
|
+
body: content
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
var extractMentionsFromSlate = (slateData) => {
|
|
81
|
+
const tools = /* @__PURE__ */ new Set();
|
|
82
|
+
const traverse = (nodes) => {
|
|
83
|
+
for (const node of nodes) {
|
|
84
|
+
if (node.type === "mention" && node.resourceId) {
|
|
85
|
+
if (node.resourceType === "tool") {
|
|
86
|
+
tools.add(node.resourceId);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (node.children && Array.isArray(node.children)) {
|
|
90
|
+
traverse(node.children);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
if (Array.isArray(slateData)) {
|
|
95
|
+
traverse(slateData);
|
|
96
|
+
}
|
|
97
|
+
return Array.from(tools);
|
|
98
|
+
};
|
|
99
|
+
var extractCategorizedMentions = (slateData) => {
|
|
100
|
+
const result = {
|
|
101
|
+
tools: [],
|
|
102
|
+
pages: [],
|
|
103
|
+
agents: [],
|
|
104
|
+
spaces: []
|
|
105
|
+
};
|
|
106
|
+
const traverse = (nodes) => {
|
|
107
|
+
for (const node of nodes) {
|
|
108
|
+
if (node.type === "mention" && node.resourceId && node.resourceType) {
|
|
109
|
+
switch (node.resourceType) {
|
|
110
|
+
case "tool":
|
|
111
|
+
result.tools.push(node.resourceId);
|
|
112
|
+
break;
|
|
113
|
+
case "page":
|
|
114
|
+
result.pages.push(node.resourceId);
|
|
115
|
+
break;
|
|
116
|
+
case "agent":
|
|
117
|
+
result.agents.push(node.resourceId);
|
|
118
|
+
break;
|
|
119
|
+
case "space":
|
|
120
|
+
result.spaces.push(node.resourceId);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (node.children && Array.isArray(node.children)) {
|
|
125
|
+
traverse(node.children);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
if (Array.isArray(slateData)) {
|
|
130
|
+
traverse(slateData);
|
|
131
|
+
}
|
|
132
|
+
result.tools = [...new Set(result.tools)];
|
|
133
|
+
result.pages = [...new Set(result.pages)];
|
|
134
|
+
result.agents = [...new Set(result.agents)];
|
|
135
|
+
result.spaces = [...new Set(result.spaces)];
|
|
136
|
+
return result;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export {
|
|
140
|
+
createEmptyParagraph,
|
|
141
|
+
ensureEditorContent,
|
|
142
|
+
compareSlateContent,
|
|
143
|
+
extractTitleFromSlate,
|
|
144
|
+
splitSlateTitleAndBody,
|
|
145
|
+
extractMentionsFromSlate,
|
|
146
|
+
extractCategorizedMentions
|
|
147
|
+
};
|
|
@@ -11,6 +11,12 @@ import {
|
|
|
11
11
|
isLoopbackHostname
|
|
12
12
|
} from "./chunk-4SN6J65J.js";
|
|
13
13
|
|
|
14
|
+
// packages/core/positiveFiniteNumberOrFallback.ts
|
|
15
|
+
function parsePositiveFiniteNumberOrFallback(value, fallback) {
|
|
16
|
+
const parsed = Number(value);
|
|
17
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
// packages/core/fetchWithTransientRetry.ts
|
|
15
21
|
var TRANSIENT_FETCH_MAX_ATTEMPTS = 3;
|
|
16
22
|
var TRANSIENT_FETCH_RETRY_BASE_DELAY_MS = 250;
|
|
@@ -120,6 +126,7 @@ async function fetchWithTransientRetry(fetchImpl, input, init, options = {}) {
|
|
|
120
126
|
}
|
|
121
127
|
|
|
122
128
|
export {
|
|
129
|
+
parsePositiveFiniteNumberOrFallback,
|
|
123
130
|
isTransientFetchError,
|
|
124
131
|
fetchWithTransientRetry
|
|
125
132
|
};
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createCliLocalRuntimeAdapter,
|
|
3
3
|
summarizeEndpoint
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-36XI7AVG.js";
|
|
5
5
|
import {
|
|
6
6
|
clipMultilineText
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3AD37QCF.js";
|
|
8
8
|
import {
|
|
9
9
|
runLocalAgentTurn
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-G53AA7RW.js";
|
|
11
11
|
import {
|
|
12
12
|
applyToolSurfaceConstraints
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-4YSOUKUR.js";
|
|
14
14
|
import {
|
|
15
15
|
resolveLocalRuntimeEnvFromPolicy
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-XFUBXRVI.js";
|
|
17
|
+
import {
|
|
18
|
+
asRecordOrEmpty
|
|
19
|
+
} from "./chunk-KX6YBIHG.js";
|
|
17
20
|
import {
|
|
18
21
|
toErrorMessage
|
|
19
22
|
} from "./chunk-HNMXYYJR.js";
|
|
20
|
-
import {
|
|
21
|
-
readPipeText,
|
|
22
|
-
spawnProcess
|
|
23
|
-
} from "./chunk-X7HHHIOZ.js";
|
|
24
23
|
import {
|
|
25
24
|
parseUserIdFromAuthToken
|
|
26
25
|
} from "./chunk-A7GB5UGH.js";
|
|
@@ -28,11 +27,9 @@ import {
|
|
|
28
27
|
DEFAULT_NOLO_SERVER_URL
|
|
29
28
|
} from "./chunk-OLZBQWZU.js";
|
|
30
29
|
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
asTrimmedNonEmptyStringArray
|
|
35
|
-
} from "./chunk-VMFTFOWF.js";
|
|
30
|
+
readPipeText,
|
|
31
|
+
spawnProcess
|
|
32
|
+
} from "./chunk-Y6ROFCZO.js";
|
|
36
33
|
import {
|
|
37
34
|
ownedAgentKey
|
|
38
35
|
} from "./chunk-M2EJHDJP.js";
|
|
@@ -40,11 +37,14 @@ import {
|
|
|
40
37
|
isRecord
|
|
41
38
|
} from "./chunk-KUG52IAP.js";
|
|
42
39
|
import {
|
|
43
|
-
|
|
44
|
-
} from "./chunk-
|
|
40
|
+
asTrimmedNonEmptyStringArray
|
|
41
|
+
} from "./chunk-3AH7LNUB.js";
|
|
45
42
|
import {
|
|
46
43
|
asOptionalPositiveFiniteNumber
|
|
47
44
|
} from "./chunk-U6VC4MU4.js";
|
|
45
|
+
import {
|
|
46
|
+
asTrimmedString
|
|
47
|
+
} from "./chunk-3EUW3WEO.js";
|
|
48
48
|
import {
|
|
49
49
|
asOptionalTrimmedString
|
|
50
50
|
} from "./chunk-G3SUCT4W.js";
|
|
@@ -781,7 +781,9 @@ async function runChatgptWebImageLocalJob(input, deps = {}) {
|
|
|
781
781
|
});
|
|
782
782
|
assertOutputImage(outPath);
|
|
783
783
|
const userAuthToken = input.userAuthToken?.trim() || "";
|
|
784
|
-
|
|
784
|
+
if (!userAuthToken) throw new Error("Cannot upload generated image without a user authentication token.");
|
|
785
|
+
const userId = parseUserIdFromAuthToken(userAuthToken);
|
|
786
|
+
if (!userId) throw new Error("Cannot determine authenticated user from the user authentication token.");
|
|
785
787
|
const serverBase = (input.serverBase?.trim() || DEFAULT_NOLO_SERVER_URL).replace(/\/+$/, "");
|
|
786
788
|
const uploaded = await uploadPngToNoloFs({
|
|
787
789
|
outPath,
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isRecord
|
|
3
|
+
} from "./chunk-KUG52IAP.js";
|
|
4
|
+
|
|
5
|
+
// packages/core/chat/validationUrl.ts
|
|
6
|
+
function safeUrl(raw) {
|
|
7
|
+
if (typeof raw !== "string") return void 0;
|
|
8
|
+
const trimmed = raw.trim();
|
|
9
|
+
if (!/^https?:\/\//i.test(trimmed)) return void 0;
|
|
10
|
+
try {
|
|
11
|
+
const parsed = new URL(trimmed);
|
|
12
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
return parsed.href;
|
|
16
|
+
} catch {
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function scanValidationDetails(details) {
|
|
21
|
+
if (!Array.isArray(details)) return {};
|
|
22
|
+
let url;
|
|
23
|
+
let text;
|
|
24
|
+
let learnMoreUrl;
|
|
25
|
+
for (const detail of details) {
|
|
26
|
+
if (url && learnMoreUrl) break;
|
|
27
|
+
if (!isRecord(detail)) continue;
|
|
28
|
+
const metadata = isRecord(detail.metadata) ? detail.metadata : void 0;
|
|
29
|
+
if (metadata) {
|
|
30
|
+
url = url ?? safeUrl(metadata.validation_url);
|
|
31
|
+
text = text ?? (typeof metadata.validation_url_link_text === "string" ? metadata.validation_url_link_text : void 0);
|
|
32
|
+
learnMoreUrl = learnMoreUrl ?? safeUrl(metadata.validation_learn_more_url);
|
|
33
|
+
}
|
|
34
|
+
const links = Array.isArray(detail.links) ? detail.links : [];
|
|
35
|
+
for (const link of links) {
|
|
36
|
+
if (!isRecord(link)) continue;
|
|
37
|
+
const linkUrl = safeUrl(link.url);
|
|
38
|
+
if (!linkUrl) continue;
|
|
39
|
+
const desc = typeof link.description === "string" ? link.description : "";
|
|
40
|
+
if (!url && /verify|continue/i.test(desc)) {
|
|
41
|
+
url = linkUrl;
|
|
42
|
+
text = text ?? desc;
|
|
43
|
+
} else if (!learnMoreUrl && /learn more/i.test(desc)) {
|
|
44
|
+
learnMoreUrl = linkUrl;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { url, text, learnMoreUrl };
|
|
49
|
+
}
|
|
50
|
+
function unescapeJsonString(text) {
|
|
51
|
+
return text.replace(
|
|
52
|
+
/\\(["\\/nrtbf]|u[0-9a-fA-F]{4})/g,
|
|
53
|
+
(_match, esc) => {
|
|
54
|
+
switch (esc[0]) {
|
|
55
|
+
case "n":
|
|
56
|
+
return "\n";
|
|
57
|
+
case "r":
|
|
58
|
+
return "\r";
|
|
59
|
+
case "t":
|
|
60
|
+
return " ";
|
|
61
|
+
case "b":
|
|
62
|
+
return "\b";
|
|
63
|
+
case "f":
|
|
64
|
+
return "\f";
|
|
65
|
+
case "u":
|
|
66
|
+
return String.fromCharCode(parseInt(esc.slice(1), 16));
|
|
67
|
+
default:
|
|
68
|
+
return esc;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
function sliceBalancedJsonObject(text) {
|
|
74
|
+
const start = text.indexOf("{");
|
|
75
|
+
if (start < 0) return void 0;
|
|
76
|
+
let depth = 0;
|
|
77
|
+
let inString = false;
|
|
78
|
+
let escaped = false;
|
|
79
|
+
for (let i = start; i < text.length; i += 1) {
|
|
80
|
+
const ch = text[i];
|
|
81
|
+
if (inString) {
|
|
82
|
+
if (escaped) escaped = false;
|
|
83
|
+
else if (ch === "\\") escaped = true;
|
|
84
|
+
else if (ch === '"') inString = false;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (ch === '"') inString = true;
|
|
88
|
+
else if (ch === "{") depth += 1;
|
|
89
|
+
else if (ch === "}") {
|
|
90
|
+
depth -= 1;
|
|
91
|
+
if (depth === 0) return text.slice(start, i + 1);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return void 0;
|
|
95
|
+
}
|
|
96
|
+
function parseBalancedJson(text) {
|
|
97
|
+
const slice = sliceBalancedJsonObject(text);
|
|
98
|
+
if (!slice) return void 0;
|
|
99
|
+
try {
|
|
100
|
+
return JSON.parse(slice);
|
|
101
|
+
} catch {
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function findValidationInParsed(parsed, depth = 0) {
|
|
106
|
+
if (depth > 3 || !isRecord(parsed)) return {};
|
|
107
|
+
const err = isRecord(parsed.error) ? parsed.error : parsed;
|
|
108
|
+
const fromDetails = scanValidationDetails(isRecord(err) ? err.details : void 0);
|
|
109
|
+
if (fromDetails.url) return fromDetails;
|
|
110
|
+
const nested = isRecord(err) ? err.message : void 0;
|
|
111
|
+
if (typeof nested === "string" && nested.trim().startsWith("{")) {
|
|
112
|
+
try {
|
|
113
|
+
const reparsed = findValidationInParsed(JSON.parse(nested), depth + 1);
|
|
114
|
+
if (reparsed.url) return reparsed;
|
|
115
|
+
} catch {
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
120
|
+
function stripTerminalControlChars(raw) {
|
|
121
|
+
return raw.replace(/[\u0000-\u001f\u007f]/g, "");
|
|
122
|
+
}
|
|
123
|
+
function regexValidationFallback(text) {
|
|
124
|
+
const urlMatch = text.match(
|
|
125
|
+
/validation_url[^h]{0,10}(https?:\/\/[^\s"\\]+)/i
|
|
126
|
+
);
|
|
127
|
+
if (!urlMatch) return {};
|
|
128
|
+
const textMatch = text.match(
|
|
129
|
+
/validation_url_link_text[^A-Za-z]{0,10}([^"\\\n]{1,60})/i
|
|
130
|
+
);
|
|
131
|
+
return {
|
|
132
|
+
// safeUrl first (normalizes C0 into %XX); fall back to stripping controls
|
|
133
|
+
// so a truncated-but-real link is still emitted rather than dropped.
|
|
134
|
+
url: safeUrl(urlMatch[1]) ?? stripTerminalControlChars(urlMatch[1]),
|
|
135
|
+
text: textMatch?.[1] ? stripTerminalControlChars(textMatch[1].trim()) || void 0 : void 0
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function extractGoogleValidationLink(errorText) {
|
|
139
|
+
for (const candidate of [
|
|
140
|
+
parseBalancedJson(errorText),
|
|
141
|
+
parseBalancedJson(unescapeJsonString(errorText))
|
|
142
|
+
]) {
|
|
143
|
+
if (candidate === void 0) continue;
|
|
144
|
+
const found = findValidationInParsed(candidate);
|
|
145
|
+
if (found.url) return found;
|
|
146
|
+
}
|
|
147
|
+
return regexValidationFallback(errorText);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export {
|
|
151
|
+
scanValidationDetails,
|
|
152
|
+
extractGoogleValidationLink
|
|
153
|
+
};
|
|
@@ -21,6 +21,8 @@ var createEmptyDialogRuntimeState = () => ({
|
|
|
21
21
|
activeControllers: {},
|
|
22
22
|
pendingRawData: {},
|
|
23
23
|
loopStopReason: null,
|
|
24
|
+
turnPhase: null,
|
|
25
|
+
turnPhaseTurnId: null,
|
|
24
26
|
pendingUserInputQueue: []
|
|
25
27
|
});
|
|
26
28
|
var activeDialogKey = null;
|
|
@@ -67,6 +69,8 @@ function resetDialogRuntimeSessionState(dialogKey) {
|
|
|
67
69
|
const runtime = ensureDialogRuntimeState(dialogKey);
|
|
68
70
|
runtime.tokens = createEmptyTokenStats();
|
|
69
71
|
runtime.loopStopReason = null;
|
|
72
|
+
runtime.turnPhase = null;
|
|
73
|
+
runtime.turnPhaseTurnId = null;
|
|
70
74
|
runtime.pendingUserInputQueue = [];
|
|
71
75
|
notify();
|
|
72
76
|
}
|
|
@@ -114,6 +118,26 @@ function setLoopStopReason(payload) {
|
|
|
114
118
|
notify();
|
|
115
119
|
return action("dialogRuntime/setLoopStopReason", payload);
|
|
116
120
|
}
|
|
121
|
+
function claimDialogTurnPhase(payload) {
|
|
122
|
+
const runtime = ensureDialogRuntimeState(payload.dialogKey);
|
|
123
|
+
runtime.turnPhaseTurnId = payload.turnId;
|
|
124
|
+
runtime.turnPhase = null;
|
|
125
|
+
notify();
|
|
126
|
+
return action("dialogRuntime/claimDialogTurnPhase", payload);
|
|
127
|
+
}
|
|
128
|
+
function setDialogTurnPhase(payload) {
|
|
129
|
+
const runtime = ensureDialogRuntimeState(payload.dialogKey);
|
|
130
|
+
if (typeof payload.turnId === "string" && runtime.turnPhaseTurnId !== null && runtime.turnPhaseTurnId !== payload.turnId) {
|
|
131
|
+
return action("dialogRuntime/setDialogTurnPhase:rejected", payload);
|
|
132
|
+
}
|
|
133
|
+
runtime.turnPhase = payload.phase;
|
|
134
|
+
runtime.turnPhaseTurnId = payload.phase === null ? null : payload.turnId ?? null;
|
|
135
|
+
notify();
|
|
136
|
+
return action("dialogRuntime/setDialogTurnPhase", payload);
|
|
137
|
+
}
|
|
138
|
+
function clearDialogTurnPhase(payload = {}) {
|
|
139
|
+
return setDialogTurnPhase({ phase: null, dialogKey: payload.dialogKey, turnId: payload.turnId });
|
|
140
|
+
}
|
|
117
141
|
function clearDialogRuntimeState(payload) {
|
|
118
142
|
delete runtimeByKey[payload.dialogKey];
|
|
119
143
|
notify();
|
|
@@ -258,6 +282,9 @@ function getPendingUserInputQueue(dialogKey) {
|
|
|
258
282
|
function getLoopStopReason(dialogKey) {
|
|
259
283
|
return getDialogRuntimeState(dialogKey).loopStopReason;
|
|
260
284
|
}
|
|
285
|
+
function getDialogTurnPhase(dialogKey) {
|
|
286
|
+
return getDialogRuntimeState(dialogKey).turnPhase;
|
|
287
|
+
}
|
|
261
288
|
var selectDialogRuntimeByKey = (_state, dialogKey) => getDialogRuntimeState(dialogKey);
|
|
262
289
|
var selectPendingFiles = (_state, dialogKey) => getPendingFiles(dialogKey);
|
|
263
290
|
var selectActiveControllers = (_state, dialogKey) => getActiveControllers(dialogKey);
|
|
@@ -293,6 +320,10 @@ function useLoopStopReason(dialogKey) {
|
|
|
293
320
|
(0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
294
321
|
return getLoopStopReason(dialogKey);
|
|
295
322
|
}
|
|
323
|
+
function useDialogTurnPhase(dialogKey) {
|
|
324
|
+
(0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
325
|
+
return getDialogTurnPhase(dialogKey);
|
|
326
|
+
}
|
|
296
327
|
function useDialogRuntimeTokens(dialogKey) {
|
|
297
328
|
(0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
298
329
|
return getDialogRuntimeTokens(dialogKey);
|
|
@@ -316,6 +347,9 @@ export {
|
|
|
316
347
|
removePendingFile,
|
|
317
348
|
clearPendingAttachments,
|
|
318
349
|
setLoopStopReason,
|
|
350
|
+
claimDialogTurnPhase,
|
|
351
|
+
setDialogTurnPhase,
|
|
352
|
+
clearDialogTurnPhase,
|
|
319
353
|
clearDialogRuntimeState,
|
|
320
354
|
addActiveController,
|
|
321
355
|
removeActiveController,
|
|
@@ -330,8 +364,6 @@ export {
|
|
|
330
364
|
deleteDialogRuntime,
|
|
331
365
|
abortActiveControllers,
|
|
332
366
|
getDialogRuntimeTokens,
|
|
333
|
-
getPendingUserInputQueue,
|
|
334
|
-
getLoopStopReason,
|
|
335
367
|
selectDialogRuntimeByKey,
|
|
336
368
|
selectPendingFiles,
|
|
337
369
|
selectActiveControllers,
|
|
@@ -346,6 +378,7 @@ export {
|
|
|
346
378
|
useActiveControllers,
|
|
347
379
|
usePendingUserInputQueue,
|
|
348
380
|
useLoopStopReason,
|
|
381
|
+
useDialogTurnPhase,
|
|
349
382
|
useDialogRuntimeTokens,
|
|
350
383
|
useCurrentDialogKey,
|
|
351
384
|
useDialogConfigError
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clipCompactText
|
|
3
|
+
} from "./chunk-5MMAK75Q.js";
|
|
4
|
+
import {
|
|
5
|
+
asRecordOrEmpty
|
|
6
|
+
} from "./chunk-KX6YBIHG.js";
|
|
7
|
+
import {
|
|
8
|
+
asOptionalTrimmedString
|
|
9
|
+
} from "./chunk-G3SUCT4W.js";
|
|
10
|
+
|
|
11
|
+
// packages/agent-runtime/fileWritePolicy.ts
|
|
12
|
+
function evaluateFileWritePolicy(args) {
|
|
13
|
+
if (args.sessionApproved) return { permissionDecision: "allow" };
|
|
14
|
+
return {
|
|
15
|
+
permissionDecision: "ask",
|
|
16
|
+
permissionRequest: {
|
|
17
|
+
id: "permission-file-write-session",
|
|
18
|
+
tool: args.tool,
|
|
19
|
+
action: "file_write",
|
|
20
|
+
title: "\u786E\u8BA4\u5199\u5165\u6587\u4EF6",
|
|
21
|
+
body: `\u672C\u4F1A\u8BDD\u9996\u6B21\u5199\u5165\u6587\u4EF6\uFF1A${args.path}\u3002\u6279\u51C6\u540E\u672C\u4F1A\u8BDD\u540E\u7EED\u5199\u5165\u4E0D\u518D\u9010\u6B21\u786E\u8BA4\u3002`,
|
|
22
|
+
command: args.path,
|
|
23
|
+
suggestedRule: {
|
|
24
|
+
scope: "session",
|
|
25
|
+
pattern: { capability: "file_write", target: "session" }
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// packages/agent-runtime/parseToolArguments.ts
|
|
32
|
+
function parseToolArgumentsJson(raw) {
|
|
33
|
+
if (!raw?.trim()) return {};
|
|
34
|
+
try {
|
|
35
|
+
return asRecordOrEmpty(JSON.parse(raw));
|
|
36
|
+
} catch {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// packages/agent-runtime/summarizeToolArguments.ts
|
|
42
|
+
function clip(value, max = 240) {
|
|
43
|
+
return clipCompactText(value, max);
|
|
44
|
+
}
|
|
45
|
+
function summarizeToolArguments(toolName, rawArgs) {
|
|
46
|
+
const args = parseToolArgumentsJson(rawArgs);
|
|
47
|
+
const pick = (...keys2) => {
|
|
48
|
+
for (const key of keys2) {
|
|
49
|
+
const value = asOptionalTrimmedString(args[key]);
|
|
50
|
+
if (value) return value;
|
|
51
|
+
}
|
|
52
|
+
return "";
|
|
53
|
+
};
|
|
54
|
+
const command = pick("command", "cmd", "runCommand", "executeCommand", "bash");
|
|
55
|
+
if (command) return clip(command);
|
|
56
|
+
const query = pick("query", "pattern", "search", "q");
|
|
57
|
+
if (query) return clip(query);
|
|
58
|
+
const filePath = pick("filePath", "file_path", "path", "filename", "file");
|
|
59
|
+
if (filePath) return clip(filePath);
|
|
60
|
+
const keys = Object.keys(args);
|
|
61
|
+
if (keys.length === 0) return "";
|
|
62
|
+
return clip(
|
|
63
|
+
keys.slice(0, 6).map((key) => {
|
|
64
|
+
const value = args[key];
|
|
65
|
+
if (typeof value === "string") return `${key}=${clip(value, 80)}`;
|
|
66
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
67
|
+
return `${key}=${String(value)}`;
|
|
68
|
+
}
|
|
69
|
+
if (Array.isArray(value)) return `${key}[${value.length}]`;
|
|
70
|
+
return `${key}=${value === null ? "null" : typeof value}`;
|
|
71
|
+
}).join(" ")
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
evaluateFileWritePolicy,
|
|
77
|
+
summarizeToolArguments
|
|
78
|
+
};
|