nolo-cli 0.16.0-alpha.9 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{_executeModel-ABTND4KZ.js → _executeModel-WPNX5DH4.js} +46 -41
- package/{action-F5JACQBG.js → action-LT7BRFLK.js} +10 -9
- package/{addContentAction-AQXEYRBE.js → addContentAction-PL3KKBDH.js} +9 -8
- package/{addDialogAgentAction-EJHHJZWW.js → addDialogAgentAction-FCMSKYAF.js} +8 -7
- package/{agentDeleteCommand-ARMAV46L.js → agentDeleteCommand-L3357EFL.js} +28 -26
- package/{agentEmailCommands-BKPZP4UP.js → agentEmailCommands-N65AVLEI.js} +58 -53
- package/{agentListCommands-5J7RRXUO.js → agentListCommands-CH27FTI2.js} +27 -25
- package/{agentMachineCommands-VXWJXXPF.js → agentMachineCommands-PPK5HJZB.js} +26 -24
- package/{agentPullCommand-6HWUT3SW.js → agentPullCommand-ZZGU5KOY.js} +4 -4
- package/{agentRecordCommands-INDJINPN.js → agentRecordCommands-HTVXD4TT.js} +53 -48
- package/{agentRunCommand-KBN6HBY4.js → agentRunCommand-MGLVJUA5.js} +59 -51
- package/{agentRunControl-6ADXVYMR.js → agentRunControl-P75VPTGS.js} +24 -1
- package/{agentRuntimeLocal-AH2RYWGP.js → agentRuntimeLocal-QUTBSY3I.js} +22 -20
- package/{agentSlice-R4PELU57.js → agentSlice-DOGRCMWK.js} +9 -8
- package/{appDeleteCommands-FRWMPQNS.js → appDeleteCommands-FEEVXUBG.js} +25 -23
- package/{appDeployCommands-IRF3T35Z.js → appDeployCommands-C4HCGC4B.js} +25 -23
- package/{appDeployStatusCommands-ADFERYPU.js → appDeployStatusCommands-IR5ZUZBQ.js} +25 -23
- package/{appGetCommands-FTEOXWMS.js → appGetCommands-6RJGZ66Z.js} +25 -23
- package/{appListCommands-WBY7UWYD.js → appListCommands-VMTF5YZF.js} +25 -23
- package/{authCommand-QU5BXRBH.js → authCommand-WJZPOLSS.js} +13 -12
- package/{authCommands-YXGOXNBZ.js → authCommands-XTBV7OFZ.js} +6 -5
- package/{chunk-XPC5C7BK.js → chunk-3ND52WIL.js} +2 -2
- package/{chunk-SOTZ6RDN.js → chunk-3Q7WHGCB.js} +1 -1
- package/{chunk-WVDAUR2S.js → chunk-45BY7RLP.js} +2 -8
- package/{chunk-KKY4B2Q2.js → chunk-4PWB7JRR.js} +4 -1
- package/{chunk-6N4KODMN.js → chunk-4T5F7YZQ.js} +1 -1
- package/chunk-7BUYEZ6U.js +671 -0
- package/{chunk-AS3ZQ3O2.js → chunk-7OBMZCRD.js} +1 -1
- package/{chunk-4N7QA72L.js → chunk-AAODAAUQ.js} +1 -1
- package/{chunk-QLUFR47U.js → chunk-AL2V7U3E.js} +1 -1
- package/{chunk-MTU75CZ2.js → chunk-B5TOXZAK.js} +1 -1
- package/{chunk-VK2HVKAO.js → chunk-BT6K76S7.js} +192 -249
- package/{chunk-G63IH3ZK.js → chunk-CEFXYF66.js} +1 -1
- package/{chunk-RLCXU7A5.js → chunk-D3HVJJIA.js} +1 -1
- package/{chunk-B4KT7RN2.js → chunk-DKZFOK24.js} +18 -89
- package/chunk-DL6EPNIK.js +50 -0
- package/{chunk-OELQ67TN.js → chunk-EGPCU42M.js} +57 -7
- package/{chunk-IWLUTMYX.js → chunk-ELT65PZW.js} +2 -2
- package/chunk-FKXFCYVO.js +221 -0
- package/{chunk-5Y5KEB7V.js → chunk-FPKLD4KB.js} +4 -4
- package/{chunk-FMYTM25W.js → chunk-FVIPEIVX.js} +10 -3
- package/{chunk-66X4VSRC.js → chunk-HQPG2PIV.js} +41 -1
- package/{chunk-ZPPTWRPT.js → chunk-HV2A3B4W.js} +1 -1
- package/{chunk-ASZ2C44S.js → chunk-IOOMJJ4Z.js} +1 -1
- package/{setDialogExtraReferencesAction-LR6MSIXO.js → chunk-JLA4FXYC.js} +2 -17
- package/{chunk-IFPY2BIE.js → chunk-JP7REMYP.js} +18 -0
- package/{chunk-R6ALN5F5.js → chunk-L2MLZQXU.js} +3 -3
- package/{chunk-HSLJ7QER.js → chunk-L6NVTGI7.js} +1 -1
- package/{chunk-BHVBFI6B.js → chunk-MD3V54DA.js} +6 -6
- package/{chunk-ZVDRAEZL.js → chunk-MUCU6ATG.js} +1 -1
- package/{chunk-KFHN5NGJ.js → chunk-MVQ4TBSD.js} +1 -1
- package/{chunk-7HECYFOI.js → chunk-NEKFSXOP.js} +316 -212
- package/{chunk-LSHKV3S7.js → chunk-NVB267BZ.js} +397 -324
- package/{chunk-SGRDLYRZ.js → chunk-NYUXSXLY.js} +33 -14
- package/{chunk-PEDT43JF.js → chunk-PZCBZO4J.js} +2 -2
- package/{chunk-LZYEWFPK.js → chunk-QCJITMYO.js} +16 -10
- package/{chunk-OOSFSFMA.js → chunk-R5V5G73M.js} +2 -0
- package/{chunk-QLWU2KOT.js → chunk-RG2U2MTJ.js} +1 -1
- package/{chunk-2XA3QGOH.js → chunk-RRGVDPH3.js} +3 -3
- package/{chunk-EABWT43X.js → chunk-RVOUXDFU.js} +5 -5
- package/{chunk-JTINRTBT.js → chunk-SKDNBYZK.js} +2 -2
- package/{chunk-BG7AP3Q7.js → chunk-SNZV4QCE.js} +34 -18
- package/{chunk-KMQPSTMJ.js → chunk-TRT4I4UD.js} +2 -2
- package/{chunk-MYMMNKYL.js → chunk-TSIYZBTH.js} +156 -6
- package/{chunk-J3VQSU5W.js → chunk-UB4RYYNQ.js} +1 -1
- package/{chunk-YJKXGHJ6.js → chunk-UGUW3FHG.js} +4 -4
- package/{chunk-XECKIDGJ.js → chunk-UZY4BEBR.js} +938 -91
- package/chunk-V5R4NZP2.js +78 -0
- package/{chunk-GWESD7AS.js → chunk-VDNQF5VI.js} +6 -6
- package/{chunk-ZVC2PCZN.js → chunk-VGMJ6PDJ.js} +5 -5
- package/{chunk-W4NVOSFF.js → chunk-WFHXMLHZ.js} +1 -1
- package/{chunk-H33743XH.js → chunk-WJRJDX2W.js} +1 -1
- package/chunk-X4Q4UZEY.js +26 -0
- package/{chunk-RPDGJO4D.js → chunk-XHG22OEX.js} +4 -4
- package/{chunk-DVRHHFEA.js → chunk-XMLRJUU5.js} +1 -1
- package/{chunk-3S2VOMIF.js → chunk-XRZJGPFI.js} +7 -7
- package/{chunk-AFNJWHKL.js → chunk-YLRTBX4Y.js} +26 -14
- package/{chunk-4EME3YTO.js → chunk-YXTRNO5W.js} +3 -3
- package/{chunk-VAT72PDP.js → chunk-ZJZCMKOR.js} +103 -174
- package/{chunk-F6JSVFHX.js → chunk-ZVOZH2HW.js} +1 -1
- package/chunk-ZZ2MH7LE.js +84 -0
- package/{cliExecutor-K3F7DMRO.js → cliExecutor-DNE7TCC4.js} +2 -2
- package/codingSkills-36KN5NQT.js +48 -0
- package/{createAgentAutomationAction-3KKRAYGE.js → createAgentAutomationAction-PMOLEPGJ.js} +18 -17
- package/{createDialogAction-S7NMQ4TZ.js → createDialogAction-DPRTYNAK.js} +20 -19
- package/{createPageAction-2EFBT4LQ.js → createPageAction-JGZK3WAM.js} +24 -23
- package/{dbSlice-7KQH6GOU.js → dbSlice-CGSRFJN3.js} +8 -7
- package/{deleteFile-WPWVZE4B.js → deleteFile-WDZ3VM7B.js} +3 -3
- package/{dialogCommands-J7XFIQRD.js → dialogCommands-XED6DKLV.js} +26 -24
- package/{dialogSlice-LNRRBUIC.js → dialogSlice-KO4NRNKC.js} +18 -17
- package/{docCreateCommands-MKO5WB34.js → docCreateCommands-P6DYWHH3.js} +24 -22
- package/{docDeleteCommands-RCBHRKUE.js → docDeleteCommands-KUWXAMSN.js} +25 -23
- package/{docReadCommands-66527P4G.js → docReadCommands-ECW55TKB.js} +24 -22
- package/{docStore-67MYPX7P.js → docStore-6KMERNUY.js} +19 -18
- package/{docUpdateCommands-UT5HSLOJ.js → docUpdateCommands-5J4BTJQN.js} +24 -22
- package/{fetchMessages-KTNM7QAR.js → fetchMessages-BMGVZVSE.js} +4 -3
- package/{getPricing-P4XRJRZB.js → getPricing-RYY6OBA4.js} +2 -2
- package/{handleSendMessageAction-VZ7226PB.js → handleSendMessageAction-R3ZHTVU4.js} +19 -18
- package/index.js +68 -68
- package/{localDialogRead-2VRI24F4.js → localDialogRead-HQZPVIE3.js} +1 -1
- package/{localRuntimeDb-LGDF6FQP.js → localRuntimeDb-THJZGAOJ.js} +1 -1
- package/{machineCommands-ATA7OSBJ.js → machineCommands-JF2YL34J.js} +59 -54
- package/{machineWsRunDispatch-ZDCZ645H.js → machineWsRunDispatch-ON4AEOJL.js} +51 -46
- package/package.json +1 -1
- package/queryRunOverlay-O4LOMMPO.js +161 -0
- package/{read-CN3TNXIP.js → read-3FMPZPER.js} +3 -3
- package/{readDocTool-WF3675ED.js → readDocTool-VSYHKK3V.js} +1 -1
- package/{readlineWorkspace-UUNABTLB.js → readlineWorkspace-SUCINTL7.js} +302 -134
- package/{removeDialogAgentAction-YDHBFEGI.js → removeDialogAgentAction-OAGA2G3U.js} +10 -9
- package/{runAgentClientLoop-2A577WBM.js → runAgentClientLoop-OBD2AVEL.js} +41 -36
- package/runOverlayPresentation-ZO4VCWEU.js +11 -0
- package/{runtimeDoctorCommands-THIHX2SY.js → runtimeDoctorCommands-E2OUORHK.js} +6 -6
- package/setDialogExtraReferencesAction-JZEXA5SL.js +27 -0
- package/{setPrimaryDialogAgentAction-IIVDCY5C.js → setPrimaryDialogAgentAction-4ZUQQKDG.js} +26 -17
- package/{settingSlice-O23YDK2O.js → settingSlice-7MNKHZ6R.js} +9 -8
- package/{skillDiscovery-6M2BZUFN.js → skillDiscovery-KJWT7JBU.js} +3 -3
- package/{spaceCommands-UNZVR2OS.js → spaceCommands-32NTNLHS.js} +27 -25
- package/{spaceSlice-MC7FYPMZ.js → spaceSlice-P7VOXLY6.js} +18 -17
- package/{streamAgentChatTurn-IEKPNM33.js → streamAgentChatTurn-UHEMNI3X.js} +91 -48
- package/{tableCommands-3P7MJ3PF.js → tableCommands-BEQAGE4I.js} +1 -1
- package/{tools-E6FHKTCF.js → tools-BMXIXHMB.js} +31 -26
- package/{tuiSummaryLlmCaller-QHPDD4WP.js → tuiSummaryLlmCaller-VUNVBRX3.js} +3 -3
- package/types-ZSTJ7MPR.js +7 -0
- package/{updateDialogTitleAction-SQJEEW2K.js → updateDialogTitleAction-LJBDYZLH.js} +21 -20
- package/{chunk-O4BU24WZ.js → chunk-6Y7A3OQQ.js} +3 -3
- package/{chunk-CMKUBIGW.js → chunk-X7W4TNB4.js} +3 -3
- package/{localRuntimeAuthority-TEGCOWX4.js → localRuntimeAuthority-4IXJCHZ7.js} +3 -3
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
prepareAndPersistMessage,
|
|
4
4
|
uiAskChoiceFunc,
|
|
5
5
|
uiAskChoiceFunctionSchema
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NVB267BZ.js";
|
|
7
7
|
import {
|
|
8
8
|
require_date_fns
|
|
9
9
|
} from "./chunk-M76ECQRD.js";
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
removeCachedEntity,
|
|
22
22
|
upsertSSREntity,
|
|
23
23
|
write
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-XRZJGPFI.js";
|
|
25
25
|
import {
|
|
26
26
|
createAgentKey,
|
|
27
27
|
createDialogKey,
|
|
@@ -30,10 +30,13 @@ import {
|
|
|
30
30
|
dialogMessageRange,
|
|
31
31
|
memoryOwnerRange,
|
|
32
32
|
memorySubjectKindRange
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-6Y7A3OQQ.js";
|
|
34
34
|
import {
|
|
35
35
|
selectIdentityUserId
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-XMLRJUU5.js";
|
|
37
|
+
import {
|
|
38
|
+
isDevelopment
|
|
39
|
+
} from "./chunk-R5V5G73M.js";
|
|
37
40
|
import {
|
|
38
41
|
asTrimmedString
|
|
39
42
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -333,11 +336,18 @@ function resolveAgentMemoryPolicy(input) {
|
|
|
333
336
|
}
|
|
334
337
|
function buildMemorySubjectsForAgent(input) {
|
|
335
338
|
const policy = input.policy ?? resolveAgentMemoryPolicy({ agentKey: input.agentKey });
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
339
|
+
const result = [];
|
|
340
|
+
const agentSubject = input.memorySubjectId?.trim();
|
|
341
|
+
if (agentSubject) {
|
|
342
|
+
result.push({ subjectType: "agent", subjectId: agentSubject });
|
|
343
|
+
}
|
|
344
|
+
if (policy.includeUserSubject && input.userId) {
|
|
345
|
+
result.push({ subjectType: "user", subjectId: input.userId });
|
|
346
|
+
}
|
|
347
|
+
if (input.spaceId) {
|
|
348
|
+
result.push({ subjectType: "space", subjectId: input.spaceId });
|
|
349
|
+
}
|
|
350
|
+
return result;
|
|
341
351
|
}
|
|
342
352
|
|
|
343
353
|
// packages/ai/memory/recentRelationshipRecap.ts
|
|
@@ -832,7 +842,9 @@ var notifyUserDataUpdated = () => {
|
|
|
832
842
|
};
|
|
833
843
|
var createDialogAction = async (args, thunkApi) => {
|
|
834
844
|
const {
|
|
835
|
-
cybots,
|
|
845
|
+
cybots: requestedCybots = [],
|
|
846
|
+
agentMode: requestedAgentMode,
|
|
847
|
+
autoRoute,
|
|
836
848
|
category,
|
|
837
849
|
spaceId: explicitSpaceId,
|
|
838
850
|
inheritFromDialogKey,
|
|
@@ -846,6 +858,8 @@ var createDialogAction = async (args, thunkApi) => {
|
|
|
846
858
|
} = args;
|
|
847
859
|
const { dispatch: dispatchRaw, getState, extra } = thunkApi;
|
|
848
860
|
const dispatch = dispatchRaw;
|
|
861
|
+
const agentMode = requestedAgentMode ?? (requestedCybots.length > 0 ? "fixed" : "auto");
|
|
862
|
+
const cybots = agentMode === "auto" ? [] : requestedCybots;
|
|
849
863
|
const agentKey = cybots[0];
|
|
850
864
|
const currentUserId = selectIdentityUserId(getState()) ?? null;
|
|
851
865
|
const isDeviceLocalDialog = isLocalOwnerDialogAgents(cybots);
|
|
@@ -861,6 +875,7 @@ var createDialogAction = async (args, thunkApi) => {
|
|
|
861
875
|
} catch {
|
|
862
876
|
}
|
|
863
877
|
const readAgentConfig = async () => {
|
|
878
|
+
if (!agentKey) return null;
|
|
864
879
|
const existing = await dispatch(
|
|
865
880
|
readAndWait({
|
|
866
881
|
dbKey: agentKey,
|
|
@@ -884,9 +899,9 @@ var createDialogAction = async (args, thunkApi) => {
|
|
|
884
899
|
).unwrap();
|
|
885
900
|
return recoveredBuiltinAgent;
|
|
886
901
|
};
|
|
887
|
-
const canSkipAgentConfigRead = !!skipAgentConfigRead && !!args.skipGreeting && !!titleOverride;
|
|
902
|
+
const canSkipAgentConfigRead = agentMode === "auto" || !!skipAgentConfigRead && !!args.skipGreeting && !!titleOverride;
|
|
888
903
|
const agentConfig = canSkipAgentConfigRead ? null : await readAgentConfig();
|
|
889
|
-
if (!agentConfig && !canSkipAgentConfigRead) {
|
|
904
|
+
if (agentMode === "fixed" && !agentConfig && !canSkipAgentConfigRead) {
|
|
890
905
|
throw new Error(`Agent with key ${agentKey} not found.`);
|
|
891
906
|
}
|
|
892
907
|
const shouldUseRelationshipGreeting = shouldUseRecentRelationshipRecap({
|
|
@@ -909,7 +924,8 @@ var createDialogAction = async (args, thunkApi) => {
|
|
|
909
924
|
agentKey,
|
|
910
925
|
currentSpaceId: explicitSpaceId
|
|
911
926
|
}).catch(() => ({ recap: null, reason: "no-db", sourceDialogKey: void 0 })) : null;
|
|
912
|
-
if (typeof window !== "undefined" && recentRelationshipRecapResolution && process
|
|
927
|
+
if (typeof window !== "undefined" && recentRelationshipRecapResolution && // 浏览器端没有 process:走 app/utils/env 的安全读法。
|
|
928
|
+
isDevelopment) {
|
|
913
929
|
console.debug("[dialog] recent relationship recap", {
|
|
914
930
|
agentKey,
|
|
915
931
|
userId,
|
|
@@ -919,7 +935,7 @@ var createDialogAction = async (args, thunkApi) => {
|
|
|
919
935
|
});
|
|
920
936
|
}
|
|
921
937
|
const time = (0, import_date_fns.format)(/* @__PURE__ */ new Date(), "MM-dd HH:mm");
|
|
922
|
-
const title = titleOverride || (agentConfig?.name || "Agent") + " " + time;
|
|
938
|
+
const title = titleOverride || (agentMode === "auto" ? "\u65B0\u5BF9\u8BDD" : agentConfig?.name || "Agent") + " " + time;
|
|
923
939
|
const spaceId = explicitSpaceId;
|
|
924
940
|
const dialogPath = createDialogKey(userId);
|
|
925
941
|
const dialogId = extractCustomId(dialogPath);
|
|
@@ -954,7 +970,10 @@ var createDialogAction = async (args, thunkApi) => {
|
|
|
954
970
|
id: dialogId,
|
|
955
971
|
dbKey: dialogPath,
|
|
956
972
|
userId,
|
|
973
|
+
agentMode,
|
|
957
974
|
cybots,
|
|
975
|
+
...agentMode === "fixed" && agentKey ? { primaryAgentKey: agentKey } : {},
|
|
976
|
+
...agentMode === "auto" && autoRoute ? { autoRoute } : {},
|
|
958
977
|
title,
|
|
959
978
|
type: "dialog" /* DIALOG */,
|
|
960
979
|
createdAt: (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date()),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
i18n_default,
|
|
3
3
|
toolRegistry
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NEKFSXOP.js";
|
|
5
5
|
import {
|
|
6
6
|
canonicalizeToolNames
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ZZ2MH7LE.js";
|
|
8
8
|
import {
|
|
9
9
|
isNoloHostedProvider
|
|
10
10
|
} from "./chunk-O6W2O2DA.js";
|
|
@@ -2,30 +2,30 @@ import {
|
|
|
2
2
|
buildCurrentTimeBlock,
|
|
3
3
|
buildIdentityBlock,
|
|
4
4
|
buildRuntimeGuidanceBlocks
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
canonicalizeToolNames
|
|
8
|
-
} from "./chunk-B4KT7RN2.js";
|
|
5
|
+
} from "./chunk-IOOMJJ4Z.js";
|
|
9
6
|
import {
|
|
10
7
|
estimateTokenCount,
|
|
11
8
|
getModelContextWindow,
|
|
12
9
|
planCompression,
|
|
13
10
|
planContextUsage,
|
|
14
11
|
serializeMessageContent
|
|
15
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-EGPCU42M.js";
|
|
16
13
|
import {
|
|
17
14
|
clipCompactText
|
|
18
15
|
} from "./chunk-5MMAK75Q.js";
|
|
19
16
|
import {
|
|
20
17
|
findModelConfig,
|
|
21
18
|
getProviderByModelName
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import {
|
|
24
|
-
buildDialogSummaryLayer
|
|
25
|
-
} from "./chunk-QLUFR47U.js";
|
|
19
|
+
} from "./chunk-HQPG2PIV.js";
|
|
26
20
|
import {
|
|
27
21
|
toErrorMessage
|
|
28
22
|
} from "./chunk-HNMXYYJR.js";
|
|
23
|
+
import {
|
|
24
|
+
buildDialogSummaryLayer
|
|
25
|
+
} from "./chunk-AL2V7U3E.js";
|
|
26
|
+
import {
|
|
27
|
+
canonicalizeToolNames
|
|
28
|
+
} from "./chunk-ZZ2MH7LE.js";
|
|
29
29
|
import {
|
|
30
30
|
asRecordOrEmpty
|
|
31
31
|
} from "./chunk-KX6YBIHG.js";
|
|
@@ -1151,7 +1151,9 @@ function applyPersistedTurnInput(messages, persistedInput, persistedInputReferen
|
|
|
1151
1151
|
async function runLocalAgentTurn(input) {
|
|
1152
1152
|
const agentConfig = await input.adapter.loadAgentConfig(input.agentRef);
|
|
1153
1153
|
if (!agentConfig) {
|
|
1154
|
-
const error = new Error(
|
|
1154
|
+
const error = new Error(
|
|
1155
|
+
`agentRef "${input.agentRef}" \u672A\u5339\u914D\u5230\u672C\u5730 agent\u3002\u8FD9\u4E0D\u662F\u914D\u7F6E\u7F3A\u5931\uFF0C\u8BF7\u7528 listAgents \u67E5\u770B\u53EF\u7528 agent\uFF0C\u518D\u7528 readAgent \u89E3\u6790 agentKey\uFF0C\u52FF\u624B\u5DE5\u62FC key\u3002`
|
|
1156
|
+
);
|
|
1155
1157
|
error.code = LOCAL_AGENT_CONFIG_MISSING_CODE;
|
|
1156
1158
|
error.agentRef = input.agentRef;
|
|
1157
1159
|
throw error;
|
|
@@ -1374,7 +1376,11 @@ async function runLocalAgentTurn(input) {
|
|
|
1374
1376
|
name: toolName,
|
|
1375
1377
|
arguments: toolCall.function.arguments,
|
|
1376
1378
|
...userInputText ? { userInput: userInputText } : {},
|
|
1379
|
+
...input.runtimeContext ? { runtimeContext: input.runtimeContext } : {},
|
|
1377
1380
|
...input.abortSignal ? { abortSignal: input.abortSignal } : {}
|
|
1381
|
+
}, {
|
|
1382
|
+
...input.abortSignal ? { abortSignal: input.abortSignal } : {},
|
|
1383
|
+
...input.runtimeContext ? { runtimeContext: input.runtimeContext } : {}
|
|
1378
1384
|
});
|
|
1379
1385
|
toolResult = await raceWithAbort(input, executePromise, toolName);
|
|
1380
1386
|
const actionGate = buildActionGate({
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
var processEnv = typeof process !== "undefined" ? process.env : void 0;
|
|
14
14
|
var reactNativeDev = typeof globalThis !== "undefined" && "__DEV__" in globalThis ? globalThis.__DEV__ : void 0;
|
|
15
15
|
var isProduction = processEnv?.NOLO_FORCE_PRODUCTION === "1" || processEnv?.NODE_ENV === "production" || reactNativeDev === false;
|
|
16
|
+
var isDevelopment = !isProduction;
|
|
16
17
|
var getIsDesktopApp = () => (typeof process !== "undefined" ? process.env?.NOLO_DESKTOP : processEnv?.NOLO_DESKTOP) === "1" || typeof window !== "undefined" && window.__NOLO_DESKTOP__ === true;
|
|
17
18
|
var isDesktopApp = getIsDesktopApp();
|
|
18
19
|
|
|
@@ -258,6 +259,7 @@ var normalizeTimeFields = (data) => ({
|
|
|
258
259
|
|
|
259
260
|
export {
|
|
260
261
|
isProduction,
|
|
262
|
+
isDevelopment,
|
|
261
263
|
getIsDesktopApp,
|
|
262
264
|
createClientLogger,
|
|
263
265
|
isAbortError,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
listUserRecordsFromServers,
|
|
3
3
|
readLiveDbRecordAfterTombstoneMerge
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ZVOZH2HW.js";
|
|
5
5
|
import {
|
|
6
6
|
agentRecordHasConfiguredCredential
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FVIPEIVX.js";
|
|
8
8
|
import {
|
|
9
9
|
toSafeAgentSummary
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-JP7REMYP.js";
|
|
11
11
|
|
|
12
12
|
// packages/cli/agentListHelpers.ts
|
|
13
13
|
function parseAgentRecordId(privateKey, explicitId) {
|
|
@@ -10,18 +10,18 @@ import {
|
|
|
10
10
|
toTimestampMs,
|
|
11
11
|
upsert,
|
|
12
12
|
write
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XRZJGPFI.js";
|
|
14
14
|
import {
|
|
15
15
|
createUserKey,
|
|
16
16
|
createUserPreferenceKey,
|
|
17
17
|
ulid
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-6Y7A3OQQ.js";
|
|
19
19
|
import {
|
|
20
20
|
asTrimmedLowercaseString
|
|
21
21
|
} from "./chunk-QSJ3HFEF.js";
|
|
22
22
|
import {
|
|
23
23
|
BUILTIN_NOLO_AGENT_KEY
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-3ND52WIL.js";
|
|
25
25
|
import {
|
|
26
26
|
asyncThunkCreator,
|
|
27
27
|
buildCreateSlice,
|
|
@@ -29,12 +29,12 @@ import {
|
|
|
29
29
|
createAsyncThunk,
|
|
30
30
|
createSelector,
|
|
31
31
|
selectIdentityUserId
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-XMLRJUU5.js";
|
|
33
33
|
import {
|
|
34
34
|
getAllServers,
|
|
35
35
|
getIsDesktopApp,
|
|
36
36
|
isProduction
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-R5V5G73M.js";
|
|
38
38
|
import {
|
|
39
39
|
SERVERS
|
|
40
40
|
} from "./chunk-LCBAMY2M.js";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getRuntimeServerContext,
|
|
3
3
|
scheduleDeleteReplication
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XMLRJUU5.js";
|
|
5
5
|
import {
|
|
6
6
|
fetchFromClientDb
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-R5V5G73M.js";
|
|
8
8
|
import {
|
|
9
9
|
buildTombstoneRecord
|
|
10
10
|
} from "./chunk-GBRG75BQ.js";
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
inlineImageUrlsForCustomProvider,
|
|
6
6
|
prepareTools,
|
|
7
7
|
shouldInlineImageUrlsForAgent
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-PZCBZO4J.js";
|
|
9
9
|
import {
|
|
10
10
|
performFetchRequest
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ZJZCMKOR.js";
|
|
12
12
|
import {
|
|
13
13
|
createSSEParser,
|
|
14
14
|
createToolRunId,
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
toolRunSetPending,
|
|
20
20
|
toolRunStarted,
|
|
21
21
|
toolRunSucceeded
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-NEKFSXOP.js";
|
|
23
23
|
import {
|
|
24
24
|
getPublicImageAgentMode
|
|
25
25
|
} from "./chunk-VIDPVFP3.js";
|
|
@@ -29,13 +29,13 @@ import {
|
|
|
29
29
|
messageStreaming,
|
|
30
30
|
selectCurrentSpaceId,
|
|
31
31
|
updateToolMessage
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-NVB267BZ.js";
|
|
33
33
|
import {
|
|
34
34
|
streamAgentChatTurn
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-MD3V54DA.js";
|
|
36
36
|
import {
|
|
37
37
|
EMPTY_ASSISTANT_REPAIR_PROMPT
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-QCJITMYO.js";
|
|
39
39
|
import {
|
|
40
40
|
accumulateToolCallDelta,
|
|
41
41
|
createThinkParserState,
|
|
@@ -47,10 +47,13 @@ import {
|
|
|
47
47
|
} from "./chunk-LSFAWXKC.js";
|
|
48
48
|
import {
|
|
49
49
|
getModelInfo
|
|
50
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-EGPCU42M.js";
|
|
51
51
|
import {
|
|
52
52
|
getApiEndpoint
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-HQPG2PIV.js";
|
|
54
|
+
import {
|
|
55
|
+
toErrorMessage
|
|
56
|
+
} from "./chunk-HNMXYYJR.js";
|
|
54
57
|
import {
|
|
55
58
|
extractCustomId
|
|
56
59
|
} from "./chunk-DFFIZ25G.js";
|
|
@@ -59,27 +62,24 @@ import {
|
|
|
59
62
|
removeActiveController,
|
|
60
63
|
tokenUsageLiveUpdate
|
|
61
64
|
} from "./chunk-3ASDTTEI.js";
|
|
62
|
-
import {
|
|
63
|
-
toErrorMessage
|
|
64
|
-
} from "./chunk-HNMXYYJR.js";
|
|
65
65
|
import {
|
|
66
66
|
selectCurrentServer
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-RVOUXDFU.js";
|
|
68
68
|
import {
|
|
69
69
|
write
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-XRZJGPFI.js";
|
|
71
71
|
import {
|
|
72
72
|
createDialogMessageKeyAndId,
|
|
73
73
|
dialogMessageKey,
|
|
74
74
|
toTrimmedString
|
|
75
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-6Y7A3OQQ.js";
|
|
76
76
|
import {
|
|
77
77
|
createAsyncThunk,
|
|
78
78
|
selectIdentityToken
|
|
79
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-XMLRJUU5.js";
|
|
80
80
|
import {
|
|
81
81
|
isAbortError
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-R5V5G73M.js";
|
|
83
83
|
import {
|
|
84
84
|
asTrimmedString
|
|
85
85
|
} from "./chunk-3EUW3WEO.js";
|
|
@@ -507,7 +507,7 @@ var processToolData = createAsyncThunk(
|
|
|
507
507
|
...llmContext ? { llmContext } : {},
|
|
508
508
|
...activity ? { activity } : {}
|
|
509
509
|
};
|
|
510
|
-
const isUiAskChoice = canonicalName === "
|
|
510
|
+
const isUiAskChoice = canonicalName === "ask_user";
|
|
511
511
|
const blocking = typeof executionToolArgs?.blocking === "boolean" ? executionToolArgs.blocking : true;
|
|
512
512
|
const hasPendingInteraction = isUiAskChoice && blocking === true;
|
|
513
513
|
return {
|
|
@@ -1595,7 +1595,23 @@ var sendOpenAICompletionsRequest = async ({
|
|
|
1595
1595
|
currentServer: selectCurrentServer(getState()),
|
|
1596
1596
|
signal,
|
|
1597
1597
|
token,
|
|
1598
|
-
dialogId
|
|
1598
|
+
dialogId,
|
|
1599
|
+
onRetry: (info) => {
|
|
1600
|
+
dispatch(
|
|
1601
|
+
messageStreaming({
|
|
1602
|
+
id: messageId,
|
|
1603
|
+
dialogId,
|
|
1604
|
+
dbKey: msgKey,
|
|
1605
|
+
content: "",
|
|
1606
|
+
role: "assistant",
|
|
1607
|
+
agentKey: agentConfig.dbKey,
|
|
1608
|
+
cybotKey: agentConfig.dbKey,
|
|
1609
|
+
...activeMessageMetadata ?? {},
|
|
1610
|
+
isStreaming: true,
|
|
1611
|
+
retryProgress: info
|
|
1612
|
+
})
|
|
1613
|
+
);
|
|
1614
|
+
}
|
|
1599
1615
|
});
|
|
1600
1616
|
logQuickChatPerfStage(quickChatPerfStartedAt, "openai-completions-fetch-response", {
|
|
1601
1617
|
ok: response.ok,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-6HYVJV7B.js";
|
|
4
4
|
import {
|
|
5
5
|
getDefaultCliLocalRuntimeDb
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WJRJDX2W.js";
|
|
7
7
|
import {
|
|
8
8
|
buildCliRuntimeEnv,
|
|
9
9
|
clearProfileAuthToken,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
createMemoryOwnerIndexKey,
|
|
24
24
|
createMemorySubjectKindIndexKey,
|
|
25
25
|
memoryOwnerRange
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-6Y7A3OQQ.js";
|
|
27
27
|
import {
|
|
28
28
|
asTrimmedNonEmptyStringArray
|
|
29
29
|
} from "./chunk-I42VC5KR.js";
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAgentRunTerminalStatus
|
|
3
|
+
} from "./chunk-FKXFCYVO.js";
|
|
1
4
|
import {
|
|
2
5
|
isCompiledBinary,
|
|
3
6
|
resolveCliEntrypointPath
|
|
@@ -7,7 +10,17 @@ import {
|
|
|
7
10
|
import { homedir as nodeHomedir } from "node:os";
|
|
8
11
|
import { isAbsolute, join, resolve } from "node:path";
|
|
9
12
|
import * as nodeFs from "node:fs";
|
|
10
|
-
import { spawn as nodeSpawn } from "node:child_process";
|
|
13
|
+
import { execFileSync as nodeExecFileSync, spawn as nodeSpawn } from "node:child_process";
|
|
14
|
+
var RUN_TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
15
|
+
"done",
|
|
16
|
+
"failed",
|
|
17
|
+
"timeout",
|
|
18
|
+
"killed",
|
|
19
|
+
"orphaned"
|
|
20
|
+
]);
|
|
21
|
+
function isRunTerminalStatus(status) {
|
|
22
|
+
return isAgentRunTerminalStatus(status);
|
|
23
|
+
}
|
|
11
24
|
function resolveNoloHome(env, homedir = nodeHomedir) {
|
|
12
25
|
const fromEnv = env?.NOLO_HOME;
|
|
13
26
|
if (typeof fromEnv === "string" && fromEnv.length > 0) return fromEnv;
|
|
@@ -27,6 +40,11 @@ function defaultGenerateRunId() {
|
|
|
27
40
|
const random = Math.random().toString(36).slice(2, 8);
|
|
28
41
|
return `run-${timestamp}-${random}`;
|
|
29
42
|
}
|
|
43
|
+
function defaultGenerateBatchId() {
|
|
44
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
45
|
+
const random = Math.random().toString(36).slice(2, 8);
|
|
46
|
+
return `batch-${timestamp}-${random}`;
|
|
47
|
+
}
|
|
30
48
|
function writeRunRecord(record, deps = {}) {
|
|
31
49
|
const fs = deps.fs ?? nodeFs;
|
|
32
50
|
const path = resolveRunRecordPath(record.runId, deps.env, deps.homedir);
|
|
@@ -149,6 +167,89 @@ function findRunRecord(target, deps = {}) {
|
|
|
149
167
|
}
|
|
150
168
|
return readRunRecord(target, deps) ?? void 0;
|
|
151
169
|
}
|
|
170
|
+
var DEFAULT_LIST_LIMIT = 20;
|
|
171
|
+
var MAX_LIST_LIMIT = 200;
|
|
172
|
+
function parseStatusFilter(status) {
|
|
173
|
+
if (typeof status !== "string" || status.trim() === "" || status === "all") {
|
|
174
|
+
return void 0;
|
|
175
|
+
}
|
|
176
|
+
const parts = status.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
177
|
+
return parts.length > 0 ? new Set(parts) : void 0;
|
|
178
|
+
}
|
|
179
|
+
function clampLimit(limit) {
|
|
180
|
+
if (typeof limit !== "number" || !Number.isFinite(limit) || limit <= 0) {
|
|
181
|
+
return DEFAULT_LIST_LIMIT;
|
|
182
|
+
}
|
|
183
|
+
const floored = Math.floor(limit);
|
|
184
|
+
if (floored > MAX_LIST_LIMIT) return MAX_LIST_LIMIT;
|
|
185
|
+
if (floored < 1) return 1;
|
|
186
|
+
return floored;
|
|
187
|
+
}
|
|
188
|
+
function queryRunRecords(query, deps = {}) {
|
|
189
|
+
let records = listRunRecords(deps);
|
|
190
|
+
records = records.map(
|
|
191
|
+
(record) => record.status === "running" ? checkStaleRun(record.runId, deps) ?? record : record
|
|
192
|
+
);
|
|
193
|
+
const statusSet = parseStatusFilter(query.status);
|
|
194
|
+
const batchId = typeof query.batchId === "string" && query.batchId.trim() !== "" ? query.batchId.trim() : void 0;
|
|
195
|
+
const parentDialogId = typeof query.parentDialogId === "string" && query.parentDialogId.trim() !== "" ? query.parentDialogId.trim() : void 0;
|
|
196
|
+
let filtered = records.filter((record) => {
|
|
197
|
+
if (batchId && record.batchId !== batchId) return false;
|
|
198
|
+
if (parentDialogId && record.parentDialogId !== parentDialogId) return false;
|
|
199
|
+
if (statusSet && !statusSet.has(record.status)) return false;
|
|
200
|
+
return true;
|
|
201
|
+
});
|
|
202
|
+
const total = filtered.length;
|
|
203
|
+
const limit = clampLimit(query.limit);
|
|
204
|
+
const offset = typeof query.offset === "number" && Number.isFinite(query.offset) && query.offset > 0 ? Math.floor(query.offset) : 0;
|
|
205
|
+
const sliced = filtered.slice(offset, offset + limit);
|
|
206
|
+
const hasMore = offset + sliced.length < total;
|
|
207
|
+
return { runs: sliced, total, hasMore };
|
|
208
|
+
}
|
|
209
|
+
var DEFAULT_GC_RETENTION_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
210
|
+
function tryUnlinkFile(fs, path) {
|
|
211
|
+
if (typeof path !== "string" || path.length === 0) return true;
|
|
212
|
+
try {
|
|
213
|
+
if (fs.existsSync(path)) {
|
|
214
|
+
fs.unlinkSync(path);
|
|
215
|
+
}
|
|
216
|
+
return true;
|
|
217
|
+
} catch (error) {
|
|
218
|
+
const code = error.code;
|
|
219
|
+
return code === "ENOENT";
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function gcRunRecords(deps = {}, options = {}) {
|
|
223
|
+
const fs = deps.fs ?? nodeFs;
|
|
224
|
+
const now = (deps.now ?? (() => /* @__PURE__ */ new Date()))();
|
|
225
|
+
const nowMs = now instanceof Date ? now.getTime() : Date.parse(String(now));
|
|
226
|
+
const retentionMs = typeof options.retentionMs === "number" && options.retentionMs >= 0 ? options.retentionMs : DEFAULT_GC_RETENTION_MS;
|
|
227
|
+
const records = listRunRecords(deps);
|
|
228
|
+
const sweptIds = [];
|
|
229
|
+
const failedIds = [];
|
|
230
|
+
for (const record of records) {
|
|
231
|
+
if (!isRunTerminalStatus(record.status)) continue;
|
|
232
|
+
const ts = record.reconciledAt ?? record.endedAt ?? record.startedAt;
|
|
233
|
+
const ageMs = nowMs - new Date(ts).getTime();
|
|
234
|
+
if (!Number.isFinite(ageMs) || ageMs < retentionMs) continue;
|
|
235
|
+
const jsonPath = resolveRunRecordPath(record.runId, deps.env, deps.homedir);
|
|
236
|
+
const logPath = resolveRunLogPath(record.runId, deps.env, deps.homedir);
|
|
237
|
+
const msgPath = record.msgFile ?? join(resolveRunsDir(deps.env, deps.homedir), `${record.runId}.msg.md`);
|
|
238
|
+
const logOk = tryUnlinkFile(fs, logPath);
|
|
239
|
+
const msgOk = tryUnlinkFile(fs, msgPath);
|
|
240
|
+
if (!logOk || !msgOk) {
|
|
241
|
+
failedIds.push(record.runId);
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
const jsonOk = tryUnlinkFile(fs, jsonPath);
|
|
245
|
+
if (jsonOk) {
|
|
246
|
+
sweptIds.push(record.runId);
|
|
247
|
+
} else {
|
|
248
|
+
failedIds.push(record.runId);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return { swept: sweptIds.length, sweptIds, failedIds };
|
|
252
|
+
}
|
|
152
253
|
function stripBackgroundFlag(args) {
|
|
153
254
|
const result = [];
|
|
154
255
|
for (const arg of args) {
|
|
@@ -219,6 +320,7 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
219
320
|
const generateRunId = deps.generateRunId ?? defaultGenerateRunId;
|
|
220
321
|
const now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
221
322
|
const runId = generateRunId();
|
|
323
|
+
const batchId = input.batchId ?? (deps.generateBatchId ?? defaultGenerateBatchId)();
|
|
222
324
|
const logPath = resolveRunLogPath(runId, env, homedir);
|
|
223
325
|
const recordPath = resolveRunRecordPath(runId, env, homedir);
|
|
224
326
|
const runsDir = resolveRunsDir(env, homedir);
|
|
@@ -237,7 +339,9 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
237
339
|
startedAt: now().toISOString(),
|
|
238
340
|
...typeof input.timeoutMs === "number" ? { timeoutMs: input.timeoutMs } : {},
|
|
239
341
|
status: "running",
|
|
240
|
-
logPath
|
|
342
|
+
logPath,
|
|
343
|
+
batchId,
|
|
344
|
+
...typeof input.parentDialogId === "string" && input.parentDialogId.trim() ? { parentDialogId: input.parentDialogId.trim() } : {}
|
|
241
345
|
};
|
|
242
346
|
fs.writeFileSync(recordPath, JSON.stringify(record, null, 2));
|
|
243
347
|
const { execPath, childArgs } = buildAgentRunChildCommand({
|
|
@@ -261,9 +365,11 @@ async function spawnLocalBackgroundRun(input, deps = {}) {
|
|
|
261
365
|
proc.unref();
|
|
262
366
|
if (typeof proc.pid === "number") {
|
|
263
367
|
record.pid = proc.pid;
|
|
368
|
+
const processStartedAt = (deps.getProcessStartTime ?? defaultGetProcessStartTime)(proc.pid);
|
|
369
|
+
if (processStartedAt) record.processStartedAt = processStartedAt.toISOString();
|
|
264
370
|
fs.writeFileSync(recordPath, JSON.stringify(record, null, 2));
|
|
265
371
|
}
|
|
266
|
-
return { runId, pid: proc.pid, logPath };
|
|
372
|
+
return { runId, pid: proc.pid, logPath, batchId };
|
|
267
373
|
}
|
|
268
374
|
function finalizeRunRecord(runId, update, deps = {}) {
|
|
269
375
|
const record = readRunRecord(runId, deps);
|
|
@@ -285,16 +391,49 @@ function isPidGone(pid, deps = {}) {
|
|
|
285
391
|
return code === "ESRCH";
|
|
286
392
|
}
|
|
287
393
|
}
|
|
394
|
+
function defaultGetProcessStartTime(pid) {
|
|
395
|
+
try {
|
|
396
|
+
const output = nodeExecFileSync("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
397
|
+
encoding: "utf8",
|
|
398
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
399
|
+
timeout: 1e3
|
|
400
|
+
}).trim();
|
|
401
|
+
if (!output) return null;
|
|
402
|
+
const d = new Date(output);
|
|
403
|
+
return isNaN(d.getTime()) ? null : d;
|
|
404
|
+
} catch {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
var MAX_PROCESS_START_TIME_DIFF_MS = 3e4;
|
|
409
|
+
var MAX_PERSISTED_PROCESS_START_TIME_DIFF_MS = 1e3;
|
|
410
|
+
function isPidReused(pid, expectedStartedAt, deps = {}, maxDiffMs = MAX_PROCESS_START_TIME_DIFF_MS) {
|
|
411
|
+
const getStartTime = deps.getProcessStartTime ?? defaultGetProcessStartTime;
|
|
412
|
+
const procStartTime = getStartTime(pid);
|
|
413
|
+
if (!procStartTime) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
const recordTime = new Date(expectedStartedAt).getTime();
|
|
417
|
+
if (isNaN(recordTime)) return false;
|
|
418
|
+
const diffMs = Math.abs(procStartTime.getTime() - recordTime);
|
|
419
|
+
return diffMs > maxDiffMs;
|
|
420
|
+
}
|
|
288
421
|
function checkStaleRun(runId, deps = {}) {
|
|
289
422
|
const record = readRunRecord(runId, deps);
|
|
290
423
|
if (!record) return null;
|
|
291
424
|
if (record.status !== "running") return record;
|
|
292
425
|
if (typeof record.pid !== "number") return record;
|
|
293
|
-
|
|
426
|
+
const pidGone = isPidGone(record.pid, deps);
|
|
427
|
+
const expectedStartedAt = record.processStartedAt ?? record.startedAt;
|
|
428
|
+
const maxStartTimeDiffMs = record.processStartedAt ? MAX_PERSISTED_PROCESS_START_TIME_DIFF_MS : MAX_PROCESS_START_TIME_DIFF_MS;
|
|
429
|
+
const pidReused = !pidGone && isPidReused(record.pid, expectedStartedAt, deps, maxStartTimeDiffMs);
|
|
430
|
+
if (!pidGone && !pidReused) return record;
|
|
294
431
|
const now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
295
|
-
record.status = "
|
|
296
|
-
record.note = "process gone
|
|
432
|
+
record.status = "orphaned";
|
|
433
|
+
record.note = pidReused ? "orphaned: process gone (pid reused by another process)" : "orphaned: process gone without writing terminal status";
|
|
297
434
|
record.endedAt = now().toISOString();
|
|
435
|
+
record.reconciledAt = now().toISOString();
|
|
436
|
+
record.pid = void 0;
|
|
298
437
|
writeRunRecord(record, deps);
|
|
299
438
|
return record;
|
|
300
439
|
}
|
|
@@ -650,23 +789,34 @@ async function runAgentKillCommand(args, deps) {
|
|
|
650
789
|
}
|
|
651
790
|
|
|
652
791
|
export {
|
|
792
|
+
RUN_TERMINAL_STATUSES,
|
|
793
|
+
isRunTerminalStatus,
|
|
653
794
|
resolveNoloHome,
|
|
654
795
|
resolveRunsDir,
|
|
655
796
|
resolveRunRecordPath,
|
|
656
797
|
resolveRunLogPath,
|
|
657
798
|
defaultGenerateRunId,
|
|
799
|
+
defaultGenerateBatchId,
|
|
658
800
|
writeRunRecord,
|
|
659
801
|
createRunActivityTracker,
|
|
660
802
|
readRunRecord,
|
|
661
803
|
listRunRecords,
|
|
662
804
|
findRunRecordByPid,
|
|
663
805
|
findRunRecord,
|
|
806
|
+
DEFAULT_LIST_LIMIT,
|
|
807
|
+
MAX_LIST_LIMIT,
|
|
808
|
+
queryRunRecords,
|
|
809
|
+
DEFAULT_GC_RETENTION_MS,
|
|
810
|
+
gcRunRecords,
|
|
664
811
|
stripBackgroundFlag,
|
|
665
812
|
absolutizeSkillArgs,
|
|
666
813
|
rewriteMsgFileArg,
|
|
667
814
|
spawnLocalBackgroundRun,
|
|
668
815
|
finalizeRunRecord,
|
|
669
816
|
isPidGone,
|
|
817
|
+
defaultGetProcessStartTime,
|
|
818
|
+
MAX_PROCESS_START_TIME_DIFF_MS,
|
|
819
|
+
isPidReused,
|
|
670
820
|
checkStaleRun,
|
|
671
821
|
runAgentPsCommand,
|
|
672
822
|
runAgentStatusCommand,
|