nolo-cli 0.219.0 → 0.220.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-WW57SJN4.js → _executeModel-BNEMFCAO.js} +74 -74
- package/{action-CK64LS6S.js → action-GDZDXPMB.js} +7 -7
- package/{addContentAction-EQXMFNPR.js → addContentAction-7RO4AMRI.js} +12 -12
- package/{addDialogAgentAction-RSDZDASD.js → addDialogAgentAction-EVYBGTXB.js} +14 -14
- package/{agentDeleteCommand-X2VWEKUA.js → agentDeleteCommand-7QTQNFCO.js} +114 -115
- package/{agentEmailCommands-6IE773VW.js → agentEmailCommands-I7SHOSD6.js} +115 -116
- package/{agentFavoriteCommands-2LKGKSUD.js → agentFavoriteCommands-7LOP3HUD.js} +5 -5
- package/{agentGrantCommands-QQV4N4JW.js → agentGrantCommands-L6O2HVJI.js} +5 -5
- package/{agentListCommands-5UNM7CGG.js → agentListCommands-GUGMORTK.js} +84 -70
- package/{agentMachineCommands-EVWFKK6Q.js → agentMachineCommands-UMDKILU3.js} +56 -55
- package/{agentProviderCommands-ZCH37KAL.js → agentProviderCommands-STI3DQ6A.js} +6 -6
- package/{agentPullCommand-XN6ZPBUW.js → agentPullCommand-KHV4EELF.js} +5 -5
- package/{agentRecordCommands-DX2WE6BH.js → agentRecordCommands-YTAMTHOY.js} +102 -103
- package/{agentRunCommand-KGOT2AFB.js → agentRunCommand-DBM6YNO6.js} +113 -112
- package/{agentRunControl-QDFW5P2T.js → agentRunControl-MBG4U6SL.js} +20 -14
- package/{agentRuntimeLocal-SD7U2EGY.js → agentRuntimeLocal-TU4LA353.js} +39 -39
- package/{agentSlice-ACZGTZVW.js → agentSlice-DPG7Q7IA.js} +16 -16
- package/{appDeleteCommands-NE3NQQJL.js → appDeleteCommands-JWP3XPUA.js} +50 -49
- package/{appDeployCommands-2BAHY522.js → appDeployCommands-6E4TQCWI.js} +50 -49
- package/{appDeployStatusCommands-JTW6LZNC.js → appDeployStatusCommands-ALU4SADG.js} +50 -49
- package/{appGetCommands-WKFEJO6A.js → appGetCommands-JEY4L6L4.js} +50 -49
- package/{appListCommands-HNAZZLFX.js → appListCommands-PCAVHU7M.js} +50 -49
- package/{authCommand-4FDPL7WG.js → authCommand-CGRIIOOV.js} +26 -23
- package/{authCommands-GAJ3NIXO.js → authCommands-55OGQGCR.js} +9 -6
- package/{builtinSkillRegistry-PXH7EGQB.js → builtinSkillRegistry-BAE2LDXF.js} +4 -4
- package/{chromeOpsCommands-YKX2QX3A.js → chromeOpsCommands-WAA45NCS.js} +6 -6
- package/{chunk-OB6DVWPF.js → chunk-262R3XNN.js} +16 -2
- package/{chunk-5OZC7R7Y.js → chunk-2MCB7CD7.js} +13 -12
- package/{chunk-IWH5SOU4.js → chunk-2NPD3FTX.js} +3 -3
- package/{chunk-OGHP3CTL.js → chunk-2X7WFDT6.js} +1 -1
- package/{chunk-XI2BWJM5.js → chunk-324FWHUA.js} +20 -3
- package/{chunk-QWYFFHCJ.js → chunk-3NNXR7EH.js} +10 -10
- package/{chunk-JWXITTQB.js → chunk-3P54D2E4.js} +1 -1
- package/{chunk-EGXPAWLG.js → chunk-3U44JB3O.js} +1 -1
- package/{chunk-KAVGK4ES.js → chunk-44J7Z5AQ.js} +18 -18
- package/{chunk-YL3EFYL3.js → chunk-4D4QD7FT.js} +3 -1
- package/{chunk-EUCFKKDM.js → chunk-4I2MXV5Q.js} +38 -10
- package/{chunk-C4WTX5TU.js → chunk-4ZGPHFLE.js} +2 -2
- package/{chunk-FVZW66K4.js → chunk-53MFERZ3.js} +177 -94
- package/{chunk-MOMR7NMG.js → chunk-547ENH5T.js} +1 -1
- package/{chunk-N7HVLYOY.js → chunk-5WKDR7HS.js} +3 -3
- package/chunk-5ZUOVCKT.js +32 -0
- package/{chunk-TRWT3EE3.js → chunk-62HXNQVV.js} +1 -1
- package/{chunk-KOXKKHFE.js → chunk-6QHKRARD.js} +2 -2
- package/{chunk-N3J4VDGV.js → chunk-6RDBLXVQ.js} +15 -15
- package/{chunk-YGMBIXCF.js → chunk-6XRPBZRS.js} +4 -2
- package/{chunk-JC5XLWZK.js → chunk-7JGMNKKG.js} +19 -15
- package/{chunk-FRSBYNWI.js → chunk-AGYPUBFW.js} +31 -205
- package/{chunk-UYOICCYG.js → chunk-ALAES342.js} +59 -88
- package/{chunk-VREDDN25.js → chunk-ATEKLSLR.js} +1 -1
- package/{chunk-6NKA6RKF.js → chunk-AUAJTAFM.js} +8 -8
- package/{chunk-7UH3DGV6.js → chunk-AWIL6EHN.js} +7 -7
- package/chunk-BIDSIRTS.js +307 -0
- package/chunk-BIWI5M4E.js +62 -0
- package/{chunk-L5I543VB.js → chunk-BNMPUQW6.js} +1 -1
- package/{chunk-BGGHA5DV.js → chunk-BP5ZJ6B4.js} +1 -1
- package/{chunk-Q6HOUF4O.js → chunk-CBUZ6DKA.js} +3 -3
- package/{chunk-LE6LGAJE.js → chunk-CD3RU7XL.js} +17 -2
- package/{chunk-AVHRSJUH.js → chunk-CMMI3DAT.js} +13 -13
- package/{chunk-H7R3365N.js → chunk-CYWNWA77.js} +5 -5
- package/{chunk-6D7NVU66.js → chunk-D6YNCNM6.js} +17 -14
- package/{chunk-6RQFZCKH.js → chunk-DBUR22G5.js} +6 -6
- package/{chunk-PVZY6P3S.js → chunk-DEA37IUY.js} +2 -2
- package/{chunk-QLFCTYRH.js → chunk-DGYCDA6W.js} +3 -3
- package/{chunk-SRL56PI2.js → chunk-DUUDXSLX.js} +21 -7
- package/{chunk-KFHREHUQ.js → chunk-DXWGFL2Z.js} +89 -1
- package/{chunk-PFJNLBRU.js → chunk-EEOOBRA7.js} +6 -6
- package/{chunk-KN3HEZIQ.js → chunk-EVGU5P4U.js} +1 -1
- package/{chunk-CXDPIPZ4.js → chunk-F6Z6ZCUV.js} +2 -2
- package/{chunk-EOWLBDY6.js → chunk-FJSNBZXR.js} +1 -1
- package/{chunk-GNHMRBYZ.js → chunk-G7IUT2V3.js} +4 -3
- package/{chunk-4NMHE7CX.js → chunk-GPOV42YM.js} +14 -14
- package/{chunk-SASHAZ67.js → chunk-GUXZK7SE.js} +2 -2
- package/{chunk-65XXHYZ5.js → chunk-GV6PRJBU.js} +3 -3
- package/{chunk-G2EJ7NL4.js → chunk-HBRDSQ3M.js} +2 -2
- package/{chunk-OOF7XDZF.js → chunk-HHFGE2WF.js} +6 -6
- package/{chunk-DJSTBAOU.js → chunk-HSSBDZLD.js} +4 -4
- package/{chunk-GIABSSWQ.js → chunk-HYLRQDEE.js} +4 -4
- package/{chunk-UJKTI5PG.js → chunk-ILHQ2AXT.js} +0 -1
- package/{chunk-S7SB7L2I.js → chunk-JJMR2EA3.js} +19 -19
- package/{chunk-3ESU44FG.js → chunk-JLAMNSBC.js} +3 -3
- package/{chunk-TVFRV3UQ.js → chunk-JUSHVFNF.js} +238 -185
- package/{chunk-MKQ2UTTX.js → chunk-KHVFJSVE.js} +22 -19
- package/{chunk-7WPAI5JJ.js → chunk-KRI6N5QZ.js} +14 -14
- package/{chunk-HCJFGH6Y.js → chunk-L32W3PRP.js} +46 -16
- package/{chunk-3N4ASIP6.js → chunk-LMRRCEDE.js} +11 -11
- package/{chunk-2KTUDBG7.js → chunk-M4SFKP5L.js} +1 -1
- package/{chunk-VHPAA6MT.js → chunk-MSMHU36U.js} +6 -6
- package/{chunk-F3TQURKK.js → chunk-MXKWTPUM.js} +19 -19
- package/{chunk-XFJ4ZPFC.js → chunk-MXRUXMZ3.js} +25 -25
- package/{chunk-OXKUPBAQ.js → chunk-NHY322ZU.js} +151 -10
- package/{chunk-UMRI2IRY.js → chunk-OBIC6EG7.js} +6 -6
- package/{chunk-VALBGPM6.js → chunk-OBSEKCVK.js} +17 -20
- package/{chunk-SYQR7FQS.js → chunk-OG6MQOQG.js} +96 -28
- package/{chunk-AMEOV5VZ.js → chunk-OOJNQK6V.js} +33 -33
- package/{chunk-K5FNYHZC.js → chunk-OWKNSIXL.js} +149 -54
- package/{chunk-CKT6QUE2.js → chunk-Q3IVPFVO.js} +1 -1
- package/{chunk-AFHOCBSP.js → chunk-QBZCGP34.js} +1 -1
- package/{chunk-2ZKFCIJJ.js → chunk-QCB42576.js} +1 -1
- package/{chunk-HOCHUZQ7.js → chunk-QJTZ76CP.js} +24 -6
- package/{chunk-XWGDCWXY.js → chunk-QRGDJA4B.js} +9 -9
- package/{chunk-4A2JIXR2.js → chunk-QYB23WUH.js} +1 -1
- package/{chunk-652XYZGP.js → chunk-R44TU3MZ.js} +8 -3
- package/{chunk-2VUZSVAS.js → chunk-R6Z5S5GA.js} +7 -7
- package/{chunk-MK2Q7ZJD.js → chunk-R7XWZDOH.js} +58 -24
- package/{chunk-GGKNJ42M.js → chunk-RBPUNSG5.js} +2 -2
- package/{chunk-GVGOEMNV.js → chunk-RG2DGNL6.js} +3 -3
- package/{chunk-2OLYKYNY.js → chunk-RTHFJZ6M.js} +8 -8
- package/{chunk-C4VAR65S.js → chunk-RYOLWYBK.js} +120 -116
- package/{chunk-T3O6BLYU.js → chunk-S5NA3C52.js} +147 -115
- package/{chunk-D726I5AZ.js → chunk-S6FDXXZV.js} +2 -2
- package/{chunk-JVRQ6YVK.js → chunk-S6K5F3KP.js} +1 -1
- package/{chunk-IWQAOW2X.js → chunk-SRCCSTIM.js} +8 -8
- package/{chunk-KO63FPG3.js → chunk-SZVMASJ2.js} +750 -2523
- package/{chunk-Q7WP5RPC.js → chunk-TGNIKIHR.js} +5 -5
- package/{chunk-AK5O76CC.js → chunk-TI2EPRHE.js} +2 -2
- package/{chunk-5R63B62U.js → chunk-TSPMLCWI.js} +7 -7
- package/{chunk-QVBXJNZ2.js → chunk-TUSTONB3.js} +1 -1
- package/{chunk-KEN3N2TN.js → chunk-VMJVAJ6W.js} +13 -10
- package/{chunk-SOF4OWDM.js → chunk-VS276URX.js} +0 -2
- package/{chunk-FIYSMXHY.js → chunk-WWTSEBDF.js} +1 -1
- package/{chunk-E2BESSAW.js → chunk-X4O7FJF5.js} +2 -0
- package/{chunk-J6T25AJ6.js → chunk-XSW4EXQV.js} +82 -18
- package/{chunk-O2CYENYJ.js → chunk-XTETTSKN.js} +2107 -1092
- package/{chunk-DVQH4BTR.js → chunk-YKY4OVOX.js} +14 -10
- package/{chunk-5RKUPJYL.js → chunk-ZH3KXFHS.js} +11 -3
- package/chunk-ZOHO6MOF.js +376 -0
- package/{cliAgentConfigHelpers-PO3MVDME.js → cliAgentConfigHelpers-BTRHMPW2.js} +12 -12
- package/{cliEnvHelpers-VPSJ4XWC.js → cliEnvHelpers-CNMP3RDX.js} +1 -1
- package/{cliExecutor-4MAX3PZL.js → cliExecutor-K6FDZTQ2.js} +3 -1
- package/{cliLocalAgentRecordReader-Z7CH4K4R.js → cliLocalAgentRecordReader-M3F76NIP.js} +45 -45
- package/{commandRegistry-SDSYBKMC.js → commandRegistry-T3UBK6OA.js} +93 -93
- package/{contentThunks-G3TRPEAU.js → contentThunks-YEPZAHXU.js} +36 -35
- package/{cooldownCommands-X7P5M2V5.js → cooldownCommands-YB5H5BBK.js} +4 -4
- package/{createAgentAutomationAction-KHA4MXUJ.js → createAgentAutomationAction-TBIIO5WT.js} +36 -35
- package/{createDialogAction-KWSBNAPJ.js → createDialogAction-KBKMYFTQ.js} +37 -36
- package/{createPageAction-HXKJ7OFG.js → createPageAction-3FGAPLJO.js} +37 -36
- package/{db-CS4ZJQKV.js → db-M7FU2GNK.js} +9 -6
- package/{dbSlice-ZJPDIFER.js → dbSlice-XRUZOGSU.js} +11 -11
- package/{deleteFile-Q3YDB4ML.js → deleteFile-6URDHYRB.js} +7 -7
- package/{dialogCommands-6KQEBHSG.js → dialogCommands-NRLCOPJR.js} +52 -52
- package/{dialogNotifyCommand-WIZFFEY3.js → dialogNotifyCommand-SHGPCU22.js} +13 -13
- package/{dialogSlice-HXPKFGRL.js → dialogSlice-DP2WTMNO.js} +34 -33
- package/{dialogUsageCommand-HTVPR2CX.js → dialogUsageCommand-W2WCSGKF.js} +1 -1
- package/{docCreateCommands-XZOLWBRC.js → docCreateCommands-YJRDA3RX.js} +48 -47
- package/{docDeleteCommands-ZSO4LGWE.js → docDeleteCommands-A5QIHZNF.js} +50 -49
- package/{docReadCommands-TTMXCDER.js → docReadCommands-CF2LTMYH.js} +48 -47
- package/{docStore-A2B3GH33.js → docStore-NDY3K3PK.js} +12 -12
- package/{docUpdateCommands-PRG6WOXL.js → docUpdateCommands-QRKV4ZXE.js} +48 -47
- package/fetchMessages-TQEUZD7H.js +1 -1
- package/{getPricing-YH3VMSVU.js → getPricing-LF5C4XSI.js} +5 -5
- package/{handleSendMessageAction-NWYG3Q72.js → handleSendMessageAction-IUGVVJ43.js} +65 -65
- package/{hostCredentialCreate-WS6D3EHT.js → hostCredentialCreate-X2ZFRXDR.js} +102 -103
- package/index.js +56 -18
- package/keys-RWF7UCB4.js +1 -1
- package/{localDialogRead-SVTPA5GY.js → localDialogRead-CCOCVGAP.js} +1 -1
- package/{localRecall-2J6QPOK2.js → localRecall-BDYKXB46.js} +3 -1
- package/{localRuntimeAdapter-TFYOA6YE.js → localRuntimeAdapter-KAG3T4LF.js} +109 -110
- package/{machineCommands-WFWV25IR.js → machineCommands-6NIQJE2A.js} +111 -112
- package/{machineWsRunDispatch-ZGXC3F2R.js → machineWsRunDispatch-RA5NOSGG.js} +100 -101
- package/{memberThunks-JRYNONYV.js → memberThunks-7Y3OYSJQ.js} +15 -15
- package/{memoryCommands-5WC3T66U.js → memoryCommands-BC6REPQB.js} +4 -4
- package/{models-CXINDUJA.js → models-H5NNZRLH.js} +2 -2
- package/{overlay-THLKYIWY.js → overlay-BBQZXGYI.js} +5 -3
- package/package.json +1 -1
- package/{projectArchive-ULJDLUA6.js → projectArchive-OIUP63MV.js} +42 -41
- package/{providerPresetApply-SHT2SUVB.js → providerPresetApply-WHAMP2D5.js} +6 -6
- package/{providerRegistry-TA7EGCVZ.js → providerRegistry-ZI2KORJ7.js} +6 -6
- package/{read-Q7GOHGNP.js → read-TYMBGEXO.js} +8 -8
- package/{readDocTool-Z5OQ6422.js → readDocTool-SKQVHBLO.js} +1 -1
- package/{readlineWorkspace-LTCV2BFW.js → readlineWorkspace-ZGC4KSXG.js} +3946 -4393
- package/{removeDialogAgentAction-U3F2MNAY.js → removeDialogAgentAction-F5QE2O2B.js} +16 -16
- package/{runAgentClientLoop-BVIEQUB3.js → runAgentClientLoop-NKUW2DSJ.js} +71 -67
- package/{runtimeDoctorCommands-I47JN4HS.js → runtimeDoctorCommands-RRKPBGVO.js} +14 -14
- package/{secretCommands-LJXOOYA7.js → secretCommands-KZWBZIYS.js} +4 -4
- package/{setDialogExtraReferencesAction-G3WSJ7EM.js → setDialogExtraReferencesAction-72L27ERM.js} +13 -13
- package/{setPrimaryDialogAgentAction-6FHAHZBB.js → setPrimaryDialogAgentAction-GJJDUSGJ.js} +16 -16
- package/{settingThunks-AXTBX3Q5.js → settingThunks-ZRGWVGZD.js} +15 -15
- package/{skillDiscovery-B5V23AXP.js → skillDiscovery-I37M5KJC.js} +3 -3
- package/{spaceCommands-IB6FKWIC.js → spaceCommands-MEH3HJBC.js} +53 -52
- package/{store-JRVN62NM.js → store-Z53ICFL3.js} +3 -1
- package/{streamAgentChatTurn-DNYFHBJM.js → streamAgentChatTurn-FJTUUXHJ.js} +89 -128
- package/{switchDialogAgentAction-UOFIAGPL.js → switchDialogAgentAction-IIJBPND3.js} +14 -14
- package/{tableCommands-HITDSLHS.js → tableCommands-FTAOCBTX.js} +11 -11
- package/{tools-JVOJ5HC4.js → tools-ZXHIAOSP.js} +58 -58
- package/tuiRestart-2IL37YIB.js +41 -0
- package/{tuiSummaryLlmCaller-7LWYTHLM.js → tuiSummaryLlmCaller-W2QN4VAC.js} +18 -18
- package/{updateCommands-RJVCRSBP.js → updateCommands-CPATDG6J.js} +8 -6
- package/{updateDialogTitleAction-Q57BOSXG.js → updateDialogTitleAction-JMKLKL4P.js} +36 -35
- package/{usageCommand-RVKHEPLU.js → usageCommand-2BF74MKF.js} +2 -2
- package/{usageRebuildCommand-GRAFOZF2.js → usageRebuildCommand-UHB55BQM.js} +3 -3
- package/{windowsSelfUpdate-KERHIAB4.js → windowsSelfUpdate-ZFD6J5HF.js} +2 -2
- package/chunk-2THCNKE4.js +0 -147
- package/chunk-KEPOVMF4.js +0 -91
- package/{accountResolver-EK2S4PWF.js → accountResolver-QETKNC7T.js} +3 -3
- package/{chunk-AGP3YSEC.js → chunk-4N6G2CKP.js} +3 -3
- package/{chunk-BLVSFYQ3.js → chunk-LISC7BD4.js} +3 -3
- package/{chunk-SNBZZPYH.js → chunk-OQHIVPG4.js} +3 -3
- package/{chunk-47ITIXO7.js → chunk-USGHJSGO.js} +3 -3
- package/{offlineMarxistsAgentCommand-4IC3Y4C6.js → offlineMarxistsAgentCommand-XVXUE6G5.js} +3 -3
- package/{workloadLifecycle-O2I3NZ2Q.js → workloadLifecycle-HFJIN5IZ.js} +8 -8
|
@@ -1,49 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BROWSER_SHELL_BRIDGE_ENV
|
|
3
3
|
} from "./chunk-2YGBI2XB.js";
|
|
4
|
-
import {
|
|
5
|
-
findPotentialSecrets
|
|
6
|
-
} from "./chunk-6QDYSCPW.js";
|
|
7
|
-
import {
|
|
8
|
-
defaultLoopbackRequest
|
|
9
|
-
} from "./chunk-VP3BINY7.js";
|
|
10
|
-
import {
|
|
11
|
-
clearCredentialAvailability,
|
|
12
|
-
markCredentialUnavailable,
|
|
13
|
-
readCredentialEntry
|
|
14
|
-
} from "./chunk-FIYSMXHY.js";
|
|
15
|
-
import {
|
|
16
|
-
CREDENTIAL_STORE_SESSION_FALLBACK_WARNING,
|
|
17
|
-
OAUTH_PROVIDER_REFS,
|
|
18
|
-
getSharedSessionCredentialBroker
|
|
19
|
-
} from "./chunk-6D7NVU66.js";
|
|
20
|
-
import {
|
|
21
|
-
customNativeAuthHeaders,
|
|
22
|
-
detectDeclaredCustomNativeWire,
|
|
23
|
-
isCallerCancellation,
|
|
24
|
-
resolveCustomNativeApiKeyHeader,
|
|
25
|
-
resolveCustomNativeEndpoint
|
|
26
|
-
} from "./chunk-WOAZVUSN.js";
|
|
27
4
|
import {
|
|
28
5
|
adoptRequiredClaudeCodeVersion,
|
|
29
6
|
anthropicRefresh,
|
|
30
7
|
cursorRefresh,
|
|
8
|
+
fetchAntigravityAvailableModels,
|
|
31
9
|
getClaudeCodeUserAgent,
|
|
32
10
|
refreshAntigravityOAuthToken,
|
|
33
11
|
refreshOpenAiCodexToken,
|
|
34
12
|
resolveClaudeCodeVersion,
|
|
35
13
|
resolveServerSyncConfig,
|
|
36
|
-
stripAnsi,
|
|
37
14
|
xaiRefresh
|
|
38
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-XSW4EXQV.js";
|
|
39
16
|
import {
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
clearCredentialAvailability,
|
|
18
|
+
markCredentialUnavailable,
|
|
19
|
+
readCredentialEntry
|
|
20
|
+
} from "./chunk-WWTSEBDF.js";
|
|
42
21
|
import {
|
|
43
22
|
DialogNotifyError,
|
|
44
23
|
deliverDialogNotification,
|
|
45
24
|
sha256Hex
|
|
46
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-M4SFKP5L.js";
|
|
47
26
|
import {
|
|
48
27
|
SANDBOX_HELPER_PATH,
|
|
49
28
|
SANDBOX_OUTPUT_LIMITS,
|
|
@@ -60,30 +39,40 @@ import {
|
|
|
60
39
|
validateChromeConnectorPayload
|
|
61
40
|
} from "./chunk-UAIHKQIA.js";
|
|
62
41
|
import {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
42
|
+
customNativeAuthHeaders,
|
|
43
|
+
detectDeclaredCustomNativeWire,
|
|
44
|
+
isCallerCancellation,
|
|
45
|
+
resolveCustomNativeApiKeyHeader,
|
|
46
|
+
resolveCustomNativeEndpoint
|
|
47
|
+
} from "./chunk-WOAZVUSN.js";
|
|
68
48
|
import {
|
|
69
49
|
createTuiSummaryLlmCaller
|
|
70
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-TSPMLCWI.js";
|
|
71
51
|
import {
|
|
72
52
|
CliProviderQuotaError,
|
|
73
53
|
executeCli,
|
|
74
54
|
executeCliStreaming
|
|
75
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-R7XWZDOH.js";
|
|
56
|
+
import {
|
|
57
|
+
isCursorOAuthAgent
|
|
58
|
+
} from "./chunk-VIWDGTDA.js";
|
|
76
59
|
import {
|
|
77
60
|
buildCliPrompt
|
|
78
61
|
} from "./chunk-ATNTHIZI.js";
|
|
62
|
+
import {
|
|
63
|
+
extractLastUserText,
|
|
64
|
+
localTurnHasSubjectRefs,
|
|
65
|
+
resolveLocalUserId,
|
|
66
|
+
withResolvedRuntimeToolSurface
|
|
67
|
+
} from "./chunk-HHFGE2WF.js";
|
|
79
68
|
import {
|
|
80
69
|
inferCaptureIntent,
|
|
81
70
|
resolveUserSkillRuntime
|
|
82
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-R44TU3MZ.js";
|
|
83
72
|
import {
|
|
84
73
|
inlineImageUrlsForCustomProvider,
|
|
85
74
|
prepareTools
|
|
86
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-JLAMNSBC.js";
|
|
87
76
|
import {
|
|
88
77
|
getServerProviderSecret
|
|
89
78
|
} from "./chunk-HS7MLR74.js";
|
|
@@ -106,24 +95,20 @@ import {
|
|
|
106
95
|
resolveCliLocalSpawnDispatch,
|
|
107
96
|
resolveRunContextFacts,
|
|
108
97
|
resolveStartAgentRunCwd
|
|
109
|
-
} from "./chunk-
|
|
110
|
-
import {
|
|
111
|
-
fetchWithTransientRetry,
|
|
112
|
-
isTransientFetchError
|
|
113
|
-
} from "./chunk-KFHREHUQ.js";
|
|
98
|
+
} from "./chunk-S5NA3C52.js";
|
|
114
99
|
import {
|
|
115
100
|
deriveCredentialGroup,
|
|
116
101
|
deriveCustomProviderCredentialGroup
|
|
117
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-NHY322ZU.js";
|
|
118
103
|
import {
|
|
119
104
|
normalizeEnabledPromptSkills,
|
|
120
105
|
resolveUserEnabledSkills
|
|
121
|
-
} from "./chunk-
|
|
106
|
+
} from "./chunk-RBPUNSG5.js";
|
|
122
107
|
import {
|
|
123
108
|
prepareTokenUsageData,
|
|
124
109
|
runKeyed,
|
|
125
110
|
validateAskChoiceInput
|
|
126
|
-
} from "./chunk-
|
|
111
|
+
} from "./chunk-53MFERZ3.js";
|
|
127
112
|
import {
|
|
128
113
|
applyTokenUsageToDayStats,
|
|
129
114
|
require_format
|
|
@@ -134,10 +119,69 @@ import {
|
|
|
134
119
|
} from "./chunk-523DITKR.js";
|
|
135
120
|
import {
|
|
136
121
|
fetchServerSyncedCredential
|
|
137
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-3NNXR7EH.js";
|
|
123
|
+
import {
|
|
124
|
+
defaultLoopbackRequest
|
|
125
|
+
} from "./chunk-VP3BINY7.js";
|
|
126
|
+
import {
|
|
127
|
+
CREDENTIAL_STORE_SESSION_FALLBACK_WARNING,
|
|
128
|
+
OAUTH_PROVIDER_REFS,
|
|
129
|
+
getSharedSessionCredentialBroker
|
|
130
|
+
} from "./chunk-D6YNCNM6.js";
|
|
131
|
+
import {
|
|
132
|
+
fetchWithTransientRetry,
|
|
133
|
+
isTransientFetchError
|
|
134
|
+
} from "./chunk-DXWGFL2Z.js";
|
|
138
135
|
import {
|
|
139
136
|
getDefaultCliLocalRuntimeDb
|
|
140
137
|
} from "./chunk-N5Z2V73W.js";
|
|
138
|
+
import {
|
|
139
|
+
_readQueueEntriesLocked,
|
|
140
|
+
ackRunRecord,
|
|
141
|
+
appendRunQueue,
|
|
142
|
+
assertHostMemoryAdmission,
|
|
143
|
+
checkStaleRun,
|
|
144
|
+
claimRunRecord,
|
|
145
|
+
commitRunRecordClaim,
|
|
146
|
+
findRunRecord,
|
|
147
|
+
gcRunRecords,
|
|
148
|
+
isRunTerminalStatus,
|
|
149
|
+
listRunRecords,
|
|
150
|
+
localWriterRecovery,
|
|
151
|
+
queryRunRecords,
|
|
152
|
+
readHostMemory,
|
|
153
|
+
releaseRunRecordAck,
|
|
154
|
+
resolveLocalContinuation,
|
|
155
|
+
resolveRunsDir,
|
|
156
|
+
revokePreparedWriterLaunch,
|
|
157
|
+
serializeQueueEntries,
|
|
158
|
+
spawnLocalBackgroundRun,
|
|
159
|
+
terminateRunProcess,
|
|
160
|
+
transitionRunToTerminal,
|
|
161
|
+
withQueueLock
|
|
162
|
+
} from "./chunk-OWKNSIXL.js";
|
|
163
|
+
import {
|
|
164
|
+
remoteDialogSyncTimeout,
|
|
165
|
+
resolveRuntimeAuthToken,
|
|
166
|
+
resolveRuntimeServerUrl
|
|
167
|
+
} from "./chunk-2X7WFDT6.js";
|
|
168
|
+
import {
|
|
169
|
+
TASK_PREVIEW_MAX,
|
|
170
|
+
formatControlRunMessageCard,
|
|
171
|
+
formatDuration,
|
|
172
|
+
formatListRunsCard,
|
|
173
|
+
formatNotFoundRunCard,
|
|
174
|
+
formatRunAge,
|
|
175
|
+
formatStartRunCard,
|
|
176
|
+
formatStatusRunCard,
|
|
177
|
+
formatStopRunCard,
|
|
178
|
+
isAgentNameFallback,
|
|
179
|
+
isAgentRunTerminalStatus,
|
|
180
|
+
normalizeRunTitle,
|
|
181
|
+
resolveAgentRunName,
|
|
182
|
+
resolveRunLabel,
|
|
183
|
+
shortRunId
|
|
184
|
+
} from "./chunk-OOJNQK6V.js";
|
|
141
185
|
import {
|
|
142
186
|
isTombstoneRecord
|
|
143
187
|
} from "./chunk-BV3FLP2L.js";
|
|
@@ -146,7 +190,7 @@ import {
|
|
|
146
190
|
readDialogMessageRecords,
|
|
147
191
|
readDialogMessages,
|
|
148
192
|
resolveBuiltinLocalCliAgentConfig
|
|
149
|
-
} from "./chunk-
|
|
193
|
+
} from "./chunk-2MCB7CD7.js";
|
|
150
194
|
import {
|
|
151
195
|
LOCAL_CODEX_AGENT_KEY,
|
|
152
196
|
isLocalCliAgentKey,
|
|
@@ -188,6 +232,7 @@ import {
|
|
|
188
232
|
isLineRangeCovered,
|
|
189
233
|
isStableSessionIdentityEnabled,
|
|
190
234
|
normalizeLocalToolName,
|
|
235
|
+
orderDialogHistory,
|
|
191
236
|
parseSyncServersEnv,
|
|
192
237
|
projectToolExecutionLocation,
|
|
193
238
|
readDevinUpstreamFailure,
|
|
@@ -201,7 +246,7 @@ import {
|
|
|
201
246
|
runExecShellGates,
|
|
202
247
|
validateConfiguredRootExecutionLease,
|
|
203
248
|
verifyOwnerRouteAck
|
|
204
|
-
} from "./chunk-
|
|
249
|
+
} from "./chunk-JUSHVFNF.js";
|
|
205
250
|
import {
|
|
206
251
|
accumulateGeminiChunks,
|
|
207
252
|
buildGeminiGenerateContentRequest,
|
|
@@ -213,7 +258,10 @@ import {
|
|
|
213
258
|
resolveAntigravityFinishReason,
|
|
214
259
|
resolveGeminiModelQuirks,
|
|
215
260
|
shouldUseGeminiNativeToolRoute
|
|
216
|
-
} from "./chunk-
|
|
261
|
+
} from "./chunk-2NPD3FTX.js";
|
|
262
|
+
import {
|
|
263
|
+
readLocalImage
|
|
264
|
+
} from "./chunk-AL3TYDIF.js";
|
|
217
265
|
import {
|
|
218
266
|
PlatformStreamInterruptedError,
|
|
219
267
|
buildPlatformChatCompletionRequest,
|
|
@@ -225,7 +273,7 @@ import {
|
|
|
225
273
|
readPlatformChatSseCompletion,
|
|
226
274
|
resolvePlatformChatProviderConfig,
|
|
227
275
|
shouldUsePlatformChatProvider
|
|
228
|
-
} from "./chunk-
|
|
276
|
+
} from "./chunk-HSSBDZLD.js";
|
|
229
277
|
import {
|
|
230
278
|
readSseDataValues,
|
|
231
279
|
readSseFrames
|
|
@@ -234,45 +282,53 @@ import {
|
|
|
234
282
|
resolveHistoricalToolContentCap
|
|
235
283
|
} from "./chunk-2WZXXAQD.js";
|
|
236
284
|
import {
|
|
237
|
-
|
|
238
|
-
|
|
285
|
+
resolveAgentImageInputSupport,
|
|
286
|
+
resolveCatalogImageSupport,
|
|
287
|
+
resolveToolImagePolicy,
|
|
288
|
+
withLiveImageSupport
|
|
289
|
+
} from "./chunk-DUUDXSLX.js";
|
|
290
|
+
import {
|
|
291
|
+
collectStablePromptPrefix,
|
|
292
|
+
convertMessagesToResponsesInput,
|
|
293
|
+
findAgentStatePairingIssues,
|
|
294
|
+
stablePromptCacheKey,
|
|
295
|
+
toResponsesTools
|
|
296
|
+
} from "./chunk-EEOOBRA7.js";
|
|
297
|
+
import {
|
|
298
|
+
EMPTY_TOOL_RESULT_TEXT,
|
|
299
|
+
MAX_TOOL_IMAGES_PER_REQUEST,
|
|
300
|
+
MAX_TOOL_IMAGE_BASE64_BYTES_PER_REQUEST,
|
|
301
|
+
createToolImageBudget,
|
|
302
|
+
hadToolImages,
|
|
303
|
+
toolImageNotices,
|
|
304
|
+
toolImageOmission,
|
|
305
|
+
toolImageSource,
|
|
306
|
+
toolImages
|
|
307
|
+
} from "./chunk-X4O7FJF5.js";
|
|
239
308
|
import {
|
|
240
309
|
assertDispatchSelectionAdmission,
|
|
241
310
|
buildNoloWorkspaceOpenAiTools,
|
|
242
311
|
filterClientNoloWorkspaceToolNames,
|
|
243
312
|
parseNoloWorkspaceToolArguments
|
|
244
|
-
} from "./chunk-
|
|
313
|
+
} from "./chunk-RYOLWYBK.js";
|
|
245
314
|
import {
|
|
246
315
|
extractQuotaSnapshot,
|
|
247
316
|
isCapacitySaturatedRateLimit,
|
|
248
317
|
mergeAvailabilityDeadline,
|
|
249
318
|
resolveAvailabilityAction,
|
|
250
319
|
resolveCredentialKeyWithFallback
|
|
251
|
-
} from "./chunk-
|
|
320
|
+
} from "./chunk-QJTZ76CP.js";
|
|
252
321
|
import {
|
|
253
322
|
HIGH_RISK_MUTATION_TOOL_NAMES,
|
|
254
323
|
resolveRequestToolSurface
|
|
255
|
-
} from "./chunk-
|
|
256
|
-
import {
|
|
257
|
-
collectStablePromptPrefix,
|
|
258
|
-
convertMessagesToResponsesInput,
|
|
259
|
-
findAgentStatePairingIssues,
|
|
260
|
-
stablePromptCacheKey,
|
|
261
|
-
toResponsesTools
|
|
262
|
-
} from "./chunk-PFJNLBRU.js";
|
|
324
|
+
} from "./chunk-VS276URX.js";
|
|
263
325
|
import {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
hadToolImages,
|
|
267
|
-
toolImageNotices,
|
|
268
|
-
toolImageOmission,
|
|
269
|
-
toolImageSource,
|
|
270
|
-
toolImages
|
|
271
|
-
} from "./chunk-E2BESSAW.js";
|
|
326
|
+
resolveAgentCallPlan
|
|
327
|
+
} from "./chunk-OBIC6EG7.js";
|
|
272
328
|
import {
|
|
273
329
|
resolveAgentRequiredPackIds,
|
|
274
330
|
resolveAgentSkillConfig
|
|
275
|
-
} from "./chunk-
|
|
331
|
+
} from "./chunk-FJSNBZXR.js";
|
|
276
332
|
import {
|
|
277
333
|
buildDialogFallbackTitleFromUserInput,
|
|
278
334
|
normalizeDialogTitle
|
|
@@ -286,13 +342,13 @@ import {
|
|
|
286
342
|
isCodexOAuthAgent,
|
|
287
343
|
markCodexOAuthCatalogFailure,
|
|
288
344
|
resolveCodexOAuthEffectiveModel
|
|
289
|
-
} from "./chunk-
|
|
345
|
+
} from "./chunk-QRGDJA4B.js";
|
|
290
346
|
import {
|
|
291
347
|
isDevinOAuthAgent
|
|
292
348
|
} from "./chunk-5ZUL4CUO.js";
|
|
293
349
|
import {
|
|
294
350
|
normalizeUsage
|
|
295
|
-
} from "./chunk-
|
|
351
|
+
} from "./chunk-L32W3PRP.js";
|
|
296
352
|
import {
|
|
297
353
|
createProviderCallTimingTracker,
|
|
298
354
|
finalizeProviderCallTiming,
|
|
@@ -310,19 +366,28 @@ import {
|
|
|
310
366
|
resolveCurrentRunRuntimeToolPolicy,
|
|
311
367
|
resolveLocalWorkspaceExecutorOptionsFromPolicy,
|
|
312
368
|
resolveRequestedRuntimeToolNames
|
|
313
|
-
} from "./chunk-
|
|
369
|
+
} from "./chunk-USGHJSGO.js";
|
|
314
370
|
import {
|
|
315
371
|
asRecordOrEmpty
|
|
316
372
|
} from "./chunk-KX6YBIHG.js";
|
|
317
373
|
import {
|
|
318
374
|
createFileCredentialBroker
|
|
319
|
-
} from "./chunk-
|
|
375
|
+
} from "./chunk-OQHIVPG4.js";
|
|
320
376
|
import {
|
|
321
377
|
compactWhitespace
|
|
322
378
|
} from "./chunk-DWLEOOGR.js";
|
|
323
379
|
import {
|
|
324
|
-
|
|
325
|
-
} from "./chunk-
|
|
380
|
+
withShellChildEnvironment
|
|
381
|
+
} from "./chunk-VMJVAJ6W.js";
|
|
382
|
+
import {
|
|
383
|
+
estimateTokenCount
|
|
384
|
+
} from "./chunk-PSCNXBYA.js";
|
|
385
|
+
import {
|
|
386
|
+
createOAuthTokenStore,
|
|
387
|
+
isTokenExpired,
|
|
388
|
+
readOAuthCredential,
|
|
389
|
+
resolveFreshAccessToken
|
|
390
|
+
} from "./chunk-G7Y4GXTY.js";
|
|
326
391
|
import {
|
|
327
392
|
FORCED_TOOLS,
|
|
328
393
|
addDefaultLightWebToolsForConfiguredAgents,
|
|
@@ -334,7 +399,7 @@ import {
|
|
|
334
399
|
expandEnabledPacks,
|
|
335
400
|
resolveBuiltinSkillEntry,
|
|
336
401
|
resolveEffectiveEnabledPacks
|
|
337
|
-
} from "./chunk-
|
|
402
|
+
} from "./chunk-G7IUT2V3.js";
|
|
338
403
|
import {
|
|
339
404
|
CHROME_CONNECTOR_ACCEPTED_TOOL_NAMES,
|
|
340
405
|
canonicalizeChromeConnectorToolNames,
|
|
@@ -352,80 +417,38 @@ import {
|
|
|
352
417
|
import {
|
|
353
418
|
dialogIdFromKey
|
|
354
419
|
} from "./chunk-YZMNK53S.js";
|
|
420
|
+
import {
|
|
421
|
+
asOptionalPositiveFiniteNumber
|
|
422
|
+
} from "./chunk-U6VC4MU4.js";
|
|
355
423
|
import {
|
|
356
424
|
classifyDialogSyncFailure,
|
|
357
425
|
getLogger,
|
|
358
426
|
startOwnedDialogSync
|
|
359
|
-
} from "./chunk-
|
|
360
|
-
import {
|
|
361
|
-
readPipeText,
|
|
362
|
-
spawnProcess
|
|
363
|
-
} from "./chunk-4O22PGNQ.js";
|
|
364
|
-
import {
|
|
365
|
-
agentRunCardLabels,
|
|
366
|
-
t
|
|
367
|
-
} from "./chunk-OB6DVWPF.js";
|
|
427
|
+
} from "./chunk-6XRPBZRS.js";
|
|
368
428
|
import {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
commitRunRecordClaim,
|
|
376
|
-
finalizeRunRecord,
|
|
377
|
-
findRunRecord,
|
|
378
|
-
gcRunRecords,
|
|
379
|
-
isRunTerminalStatus,
|
|
380
|
-
listRunRecords,
|
|
381
|
-
localWriterRecovery,
|
|
382
|
-
queryRunRecords,
|
|
383
|
-
readHostMemory,
|
|
384
|
-
readRunRecord,
|
|
385
|
-
releaseRunRecordAck,
|
|
386
|
-
resolveLocalContinuation,
|
|
387
|
-
resolveRunsDir,
|
|
388
|
-
revokePreparedWriterLaunch,
|
|
389
|
-
serializeQueueEntries,
|
|
390
|
-
spawnLocalBackgroundRun,
|
|
391
|
-
stripResultFrontMatter,
|
|
392
|
-
terminateRunProcess,
|
|
393
|
-
transitionRunToTerminal,
|
|
394
|
-
withQueueLock,
|
|
395
|
-
writeRunRecord
|
|
396
|
-
} from "./chunk-K5FNYHZC.js";
|
|
429
|
+
getHostRuntimeExecutable,
|
|
430
|
+
isCompiledBinary,
|
|
431
|
+
parseUserIdFromAuthToken,
|
|
432
|
+
resolveAuthToken,
|
|
433
|
+
resolveServerUrl
|
|
434
|
+
} from "./chunk-BIDSIRTS.js";
|
|
397
435
|
import {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
resolveRuntimeServerUrl
|
|
401
|
-
} from "./chunk-OGHP3CTL.js";
|
|
436
|
+
DEFAULT_NOLO_SERVER_URL
|
|
437
|
+
} from "./chunk-OLZBQWZU.js";
|
|
402
438
|
import {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
formatDuration,
|
|
406
|
-
formatListRunsCard,
|
|
407
|
-
formatNotFoundRunCard,
|
|
408
|
-
formatRunAge,
|
|
409
|
-
formatStartRunCard,
|
|
410
|
-
formatStatusRunCard,
|
|
411
|
-
formatStopRunCard,
|
|
412
|
-
isAgentNameFallback,
|
|
413
|
-
isAgentRunTerminalStatus,
|
|
414
|
-
normalizeRunTitle,
|
|
415
|
-
resolveAgentRunName,
|
|
416
|
-
resolveRunLabel,
|
|
417
|
-
shortRunId
|
|
418
|
-
} from "./chunk-AMEOV5VZ.js";
|
|
439
|
+
NOLO_CLUSTER_SERVERS
|
|
440
|
+
} from "./chunk-LCBAMY2M.js";
|
|
419
441
|
import {
|
|
420
|
-
|
|
421
|
-
|
|
442
|
+
agentRunCardLabels,
|
|
443
|
+
t
|
|
444
|
+
} from "./chunk-262R3XNN.js";
|
|
422
445
|
import {
|
|
423
|
-
|
|
424
|
-
} from "./chunk-
|
|
446
|
+
isAntigravityOAuthAgent
|
|
447
|
+
} from "./chunk-7JGMNKKG.js";
|
|
425
448
|
import {
|
|
426
449
|
buildProviderSessionHeaders,
|
|
427
450
|
resolvePlatformAuthToken
|
|
428
|
-
} from "./chunk-
|
|
451
|
+
} from "./chunk-RTHFJZ6M.js";
|
|
429
452
|
import {
|
|
430
453
|
toErrorMessage
|
|
431
454
|
} from "./chunk-HNMXYYJR.js";
|
|
@@ -436,1414 +459,53 @@ import {
|
|
|
436
459
|
anthropicOAuthModelMaxOutputTokens,
|
|
437
460
|
findModelConfig,
|
|
438
461
|
isAdaptiveThinkingModelId
|
|
439
|
-
} from "./chunk-
|
|
462
|
+
} from "./chunk-CD3RU7XL.js";
|
|
440
463
|
import {
|
|
441
464
|
CLI_PROVIDER_VALUES,
|
|
442
465
|
isCliProvider
|
|
443
466
|
} from "./chunk-JRTNUU5Z.js";
|
|
444
467
|
import {
|
|
445
|
-
isRecord
|
|
446
|
-
} from "./chunk-KUG52IAP.js";
|
|
447
|
-
import {
|
|
448
|
-
|
|
449
|
-
} from "./chunk-
|
|
450
|
-
import {
|
|
451
|
-
|
|
452
|
-
} from "./chunk-
|
|
453
|
-
import {
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
} from "./chunk-
|
|
459
|
-
import {
|
|
460
|
-
|
|
461
|
-
} from "./chunk-
|
|
462
|
-
import {
|
|
463
|
-
NOLO_CLUSTER_SERVERS
|
|
464
|
-
} from "./chunk-LCBAMY2M.js";
|
|
465
|
-
import {
|
|
466
|
-
asOptionalTrimmedString
|
|
467
|
-
} from "./chunk-G3SUCT4W.js";
|
|
468
|
-
import {
|
|
469
|
-
isLoopbackUrl
|
|
470
|
-
} from "./chunk-4SN6J65J.js";
|
|
471
|
-
import {
|
|
472
|
-
normalizeServerOrigin
|
|
473
|
-
} from "./chunk-CF7PE763.js";
|
|
474
|
-
import {
|
|
475
|
-
createOAuthTokenStore,
|
|
476
|
-
isTokenExpired,
|
|
477
|
-
readOAuthCredential,
|
|
478
|
-
resolveFreshAccessToken
|
|
479
|
-
} from "./chunk-G7Y4GXTY.js";
|
|
480
|
-
import {
|
|
481
|
-
__toESM
|
|
482
|
-
} from "./chunk-U67V476Y.js";
|
|
483
|
-
|
|
484
|
-
// packages/agent-runtime/agentRunIsolation.ts
|
|
485
|
-
var ORCHESTRATION_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
486
|
-
"startAgentRun",
|
|
487
|
-
"controlAgentRun",
|
|
488
|
-
"requestTaskReview",
|
|
489
|
-
"recordTaskReviewDecision",
|
|
490
|
-
"listAgents",
|
|
491
|
-
"readAgent",
|
|
492
|
-
"runStreamingAgent"
|
|
493
|
-
]);
|
|
494
|
-
var INTERACTION_REQUIRED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
495
|
-
"ask_user",
|
|
496
|
-
// 凭据请求:需要宿主交互面板(Block 1a);desktop 无通道时同 ask_user 剥离。
|
|
497
|
-
"secret-request"
|
|
498
|
-
]);
|
|
499
|
-
var SELF_MUTATION_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
500
|
-
"updateSelf",
|
|
501
|
-
"updateAgent"
|
|
502
|
-
]);
|
|
503
|
-
var SUBTASK_REMOVED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
504
|
-
...ORCHESTRATION_TOOL_NAMES,
|
|
505
|
-
...INTERACTION_REQUIRED_TOOL_NAMES,
|
|
506
|
-
...SELF_MUTATION_TOOL_NAMES
|
|
507
|
-
]);
|
|
508
|
-
function isSubtaskRun(env) {
|
|
509
|
-
if (!env) return false;
|
|
510
|
-
const value = env.NOLO_AGENT_RUN_CHILD;
|
|
511
|
-
return typeof value === "string" && value.length > 0 && value !== "0";
|
|
512
|
-
}
|
|
513
|
-
var RUN_WAKE_CHANNEL_ENV = "NOLO_RUN_WAKE";
|
|
514
|
-
function hasRunWakeChannel(env) {
|
|
515
|
-
if (!env) return false;
|
|
516
|
-
const value = env[RUN_WAKE_CHANNEL_ENV];
|
|
517
|
-
return typeof value === "string" && value.length > 0 && value !== "0";
|
|
518
|
-
}
|
|
519
|
-
function filterToolNamesForRunKind(toolNames, isSubtask) {
|
|
520
|
-
if (!isSubtask) return [...toolNames];
|
|
521
|
-
return toolNames.filter((name) => !SUBTASK_REMOVED_TOOL_NAMES.has(name));
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
// packages/cli/client/hostReviewDispatch.ts
|
|
525
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
526
|
-
import { createHash as createHash4, randomUUID } from "node:crypto";
|
|
527
|
-
import { appendFileSync, mkdirSync as mkdirSync2, readFileSync as readFileSync2, readdirSync as readdirSync2, renameSync, writeFileSync as writeFileSync2, lstatSync as lstatSync2, realpathSync as realpathSync2 } from "node:fs";
|
|
528
|
-
import { join as join4, resolve as resolve4 } from "node:path";
|
|
529
|
-
|
|
530
|
-
// packages/cli/client/reviewVerdict.ts
|
|
531
|
-
var SEVERITIES = ["CRITICAL", "HIGH", "MEDIUM", "LOW"];
|
|
532
|
-
var BLOCKERS = ["CRITICAL", "HIGH"];
|
|
533
|
-
var FIRST_LINE_RE = /^VERDICT: (APPROVE|BLOCK)(?:\s*[—–\-::]\s*.*)?$/;
|
|
534
|
-
var VERDICT_DECL_RE = /^VERDICT\s*[::]/i;
|
|
535
|
-
var CONFLICT_RE = /VERDICT\s*[::]\s*`{0,2}\*{0,2}(APPROVE|BLOCK)\b(?!\s*[|/])/gi;
|
|
536
|
-
var HEADING_RE = /^(#{1,2})\s+(.*)$/;
|
|
537
|
-
var HEADING_SEV_RE = /^[*`_\s]*(CRITICAL|HIGH|MEDIUM|LOW)\b/i;
|
|
538
|
-
var TABLE_ROW_RE = /^\s*\|(.*)\|\s*$/;
|
|
539
|
-
var FENCE_RE = /^\s*```/;
|
|
540
|
-
var EMPTY_SECTION_RE = /^(?:无。?|None|0)$/i;
|
|
541
|
-
function invalid(reason) {
|
|
542
|
-
return { status: "INVALID", reason, exitCode: 2 };
|
|
543
|
-
}
|
|
544
|
-
function stripDecoration(line) {
|
|
545
|
-
return line.replace(/^\s*(?:[-*+>]|\d+[.)])\s*/, "").replace(/[*_`]/g, "").trim();
|
|
546
|
-
}
|
|
547
|
-
function unwrap(line) {
|
|
548
|
-
return line.trim().replace(/^\*\*(.*)\*\*$/, "$1").trim();
|
|
549
|
-
}
|
|
550
|
-
function isEmptySection(body) {
|
|
551
|
-
const content = body.filter((line) => line.trim() !== "");
|
|
552
|
-
return content.length === 1 && EMPTY_SECTION_RE.test(unwrap(content[0]));
|
|
553
|
-
}
|
|
554
|
-
function stripFrontmatter(markdown) {
|
|
555
|
-
return markdown.replace(/^---[\r\n]+[\s\S]*?[\r\n]+---(?:\r?\n|$)/, "");
|
|
556
|
-
}
|
|
557
|
-
function parseStructuredReview(text) {
|
|
558
|
-
const body = stripFrontmatter(text).trim();
|
|
559
|
-
if (!body.startsWith("{")) return { kind: "legacy" };
|
|
560
|
-
const nonempty2 = (v) => typeof v === "string" && v.trim().length > 0;
|
|
561
|
-
try {
|
|
562
|
-
const value = JSON.parse(body);
|
|
563
|
-
const keys = ["schemaVersion", "revision", "status", "reason", "findings"];
|
|
564
|
-
if (!value || value.schemaVersion !== 1 || Object.keys(value).some((k) => !keys.includes(k)) || !["completed", "incomplete"].includes(value.status) || !nonempty2(value.revision) || !Array.isArray(value.findings) || value.reason !== void 0 && (value.status !== "incomplete" || !nonempty2(value.reason)) || value.status === "incomplete" && !nonempty2(value.reason))
|
|
565
|
-
return { kind: "invalid", reason: "\u7ED3\u6784\u5316\u5BA1\u67E5\u5B57\u6BB5\u65E0\u6548\u6216\u672A\u5B8C\u6210\u539F\u56E0\u7F3A\u5931" };
|
|
566
|
-
const ids = /* @__PURE__ */ new Set();
|
|
567
|
-
const findingKeys = ["id", "severity", "file", "line", "evidence", "impact"];
|
|
568
|
-
for (const f of value.findings) {
|
|
569
|
-
if (!f || Object.keys(f).some((k) => !findingKeys.includes(k)) || !nonempty2(f.id) || ids.has(f.id.trim()) || !SEVERITIES.includes(f.severity) || !nonempty2(f.file) || !Number.isSafeInteger(f.line) || f.line < 1 || !nonempty2(f.evidence) || !nonempty2(f.impact))
|
|
570
|
-
return { kind: "invalid", reason: "\u7ED3\u6784\u5316 finding \u65E0\u6548\u6216 id \u91CD\u590D" };
|
|
571
|
-
ids.add(f.id.trim());
|
|
572
|
-
}
|
|
573
|
-
return { kind: "structured", review: value };
|
|
574
|
-
} catch {
|
|
575
|
-
return { kind: "invalid", reason: "\u7ED3\u6784\u5316\u5BA1\u67E5 JSON \u65E0\u6548" };
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
function structuredReviewVerdict(review) {
|
|
579
|
-
return review.status === "completed" && !review.findings.some((f) => BLOCKERS.includes(f.severity)) ? "APPROVE" : "BLOCK";
|
|
580
|
-
}
|
|
581
|
-
function evaluateVerdict(markdown, expectedRevision) {
|
|
582
|
-
const parsed = parseStructuredReview(markdown);
|
|
583
|
-
if (parsed.kind === "invalid") return invalid(parsed.reason);
|
|
584
|
-
if (parsed.kind === "structured") {
|
|
585
|
-
if (expectedRevision !== void 0 && parsed.review.revision !== expectedRevision)
|
|
586
|
-
return invalid("\u7ED3\u6784\u5316\u5BA1\u67E5\u7248\u672C\u4E0E\u5BBF\u4E3B\u53D7\u68C0\u7248\u672C\u4E0D\u5339\u914D");
|
|
587
|
-
return { status: structuredReviewVerdict(parsed.review) === "APPROVE" ? "OK APPROVE" : "OK BLOCK", exitCode: 0 };
|
|
588
|
-
}
|
|
589
|
-
const stripped = stripFrontmatter(markdown);
|
|
590
|
-
const lines = stripped.split(/\r?\n/);
|
|
591
|
-
const firstIdx = lines.findIndex((line) => line.trim() !== "");
|
|
592
|
-
if (firstIdx < 0) return invalid("\u6587\u4EF6\u4E3A\u7A7A\uFF1A\u627E\u4E0D\u5230\u9996\u884C VERDICT");
|
|
593
|
-
const head = lines[firstIdx].trim();
|
|
594
|
-
const matched = FIRST_LINE_RE.exec(head);
|
|
595
|
-
if (!matched) {
|
|
596
|
-
return invalid(
|
|
597
|
-
`\u9996\u884C\u672A\u7CBE\u786E\u5339\u914D ^VERDICT: (APPROVE|BLOCK)$\uFF08\u5B9E\u9645\uFF1A${head.slice(0, 80)}\uFF09`
|
|
598
|
-
);
|
|
599
|
-
}
|
|
600
|
-
const verdict = matched[1].toUpperCase();
|
|
601
|
-
const suffix = head.replace(/^VERDICT\s*[::]\s*(?:APPROVE|BLOCK)\b/i, "");
|
|
602
|
-
if (/\bVERDICT\s*[::]/i.test(suffix)) return invalid("\u9996\u884C\u540E\u7F00\u4E0D\u5F97\u5305\u542B\u7B2C\u4E8C\u4E2A VERDICT \u58F0\u660E");
|
|
603
|
-
const declared = {};
|
|
604
|
-
const nonEmpty = {};
|
|
605
|
-
for (const sev of SEVERITIES) {
|
|
606
|
-
declared[sev] = false;
|
|
607
|
-
nonEmpty[sev] = false;
|
|
608
|
-
}
|
|
609
|
-
let inFence = false;
|
|
610
|
-
for (let i = firstIdx + 1; i < lines.length; i++) {
|
|
611
|
-
const raw = lines[i];
|
|
612
|
-
if (FENCE_RE.test(raw)) {
|
|
613
|
-
inFence = !inFence;
|
|
614
|
-
continue;
|
|
615
|
-
}
|
|
616
|
-
if (inFence || !VERDICT_DECL_RE.test(stripDecoration(raw))) continue;
|
|
617
|
-
for (const hit of raw.matchAll(CONFLICT_RE)) {
|
|
618
|
-
const other = hit[1].toUpperCase();
|
|
619
|
-
if (other !== verdict) {
|
|
620
|
-
return invalid(
|
|
621
|
-
`\u7B2C ${i + 1} \u884C\u51FA\u73B0\u4E0E\u9996\u884C\u77DB\u76FE\u7684\u7ED3\u8BBA\uFF08\u9996\u884C ${verdict}\uFF0C\u6B64\u5904 ${other}\uFF09\uFF1A${raw.trim().slice(0, 80)}`
|
|
622
|
-
);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
const record = (sev, body2) => {
|
|
627
|
-
if (!sev) return;
|
|
628
|
-
declared[sev] = true;
|
|
629
|
-
if (!isEmptySection(body2)) nonEmpty[sev] = true;
|
|
630
|
-
};
|
|
631
|
-
let current = null;
|
|
632
|
-
let body = [];
|
|
633
|
-
inFence = false;
|
|
634
|
-
for (let i = firstIdx + 1; i < lines.length; i++) {
|
|
635
|
-
const raw = lines[i];
|
|
636
|
-
if (FENCE_RE.test(raw)) {
|
|
637
|
-
inFence = !inFence;
|
|
638
|
-
continue;
|
|
639
|
-
}
|
|
640
|
-
if (inFence) continue;
|
|
641
|
-
const heading = HEADING_RE.exec(raw);
|
|
642
|
-
if (heading) {
|
|
643
|
-
record(current, body);
|
|
644
|
-
const sev = HEADING_SEV_RE.exec(heading[2]);
|
|
645
|
-
current = sev ? sev[1].toUpperCase() : null;
|
|
646
|
-
body = [];
|
|
647
|
-
continue;
|
|
648
|
-
}
|
|
649
|
-
const row = TABLE_ROW_RE.exec(raw);
|
|
650
|
-
if (row) {
|
|
651
|
-
const cells = row[1].split("|");
|
|
652
|
-
const severity = SEVERITIES.find(
|
|
653
|
-
(s) => unwrap(cells[0] ?? "").toUpperCase() === s
|
|
654
|
-
);
|
|
655
|
-
if (!severity) continue;
|
|
656
|
-
const rawCount = cells[1] ?? "";
|
|
657
|
-
const count2 = unwrap(rawCount);
|
|
658
|
-
if (!/^\d+$/.test(count2)) {
|
|
659
|
-
return invalid(
|
|
660
|
-
`\u8868\u683C ${severity} \u7684 Count \u5FC5\u987B\u4E3A\u7EAF\u6570\u5B57\uFF08\u5B9E\u9645\uFF1A${rawCount.trim() || "(\u7A7A)"}\uFF09`
|
|
661
|
-
);
|
|
662
|
-
}
|
|
663
|
-
declared[severity] = true;
|
|
664
|
-
if (Number(count2) !== 0) nonEmpty[severity] = true;
|
|
665
|
-
continue;
|
|
666
|
-
}
|
|
667
|
-
if (current) body.push(raw);
|
|
668
|
-
}
|
|
669
|
-
record(current, body);
|
|
670
|
-
const missing = BLOCKERS.filter((sev) => !declared[sev]);
|
|
671
|
-
if (missing.length > 0) {
|
|
672
|
-
return invalid(
|
|
673
|
-
`\u7F3A\u5C11 ${missing.join("\u3001")} \u7EA7\u522B\u58F0\u660E\uFF08\u9700 "## CRITICAL"/"## HIGH" \u6BB5\u6216 "| CRITICAL | 0 |" \u8868\u683C\u884C\uFF09`
|
|
674
|
-
);
|
|
675
|
-
}
|
|
676
|
-
const blockers = BLOCKERS.filter((sev) => nonEmpty[sev]);
|
|
677
|
-
if (verdict === "APPROVE") {
|
|
678
|
-
if (blockers.length > 0) {
|
|
679
|
-
return invalid(
|
|
680
|
-
`APPROVE \u4F46 ${blockers.join("\u3001")} \u975E\u7A7A\uFF08APPROVE \u8981\u6C42\u8FD9\u4E24\u6BB5\u5404\u53EA\u5199\u4E00\u884C\u300C\u65E0\u3002\u300D\uFF09`
|
|
681
|
-
);
|
|
682
|
-
}
|
|
683
|
-
return { status: "OK APPROVE", exitCode: 0 };
|
|
684
|
-
}
|
|
685
|
-
if (blockers.length === 0) {
|
|
686
|
-
return invalid(
|
|
687
|
-
"BLOCK \u4F46 CRITICAL \u4E0E HIGH \u5747\u4E3A\u7A7A\uFF1A\u7ED3\u8BBA\u7F3A\u5C11\u963B\u65AD\u4F9D\u636E\uFF08\u82E5\u5B9E\u9645\u5E94\u653E\u884C\uFF0C\u9996\u884C\u8BF7\u5199 APPROVE\uFF09"
|
|
688
|
-
);
|
|
689
|
-
}
|
|
690
|
-
return { status: "OK BLOCK", exitCode: 0 };
|
|
691
|
-
}
|
|
468
|
+
isRecord
|
|
469
|
+
} from "./chunk-KUG52IAP.js";
|
|
470
|
+
import {
|
|
471
|
+
asOptionalTrimmedString
|
|
472
|
+
} from "./chunk-G3SUCT4W.js";
|
|
473
|
+
import {
|
|
474
|
+
isLoopbackUrl
|
|
475
|
+
} from "./chunk-4SN6J65J.js";
|
|
476
|
+
import {
|
|
477
|
+
normalizeServerOrigin
|
|
478
|
+
} from "./chunk-CF7PE763.js";
|
|
479
|
+
import {
|
|
480
|
+
asTrimmedLowercaseString
|
|
481
|
+
} from "./chunk-QSJ3HFEF.js";
|
|
482
|
+
import {
|
|
483
|
+
__toESM
|
|
484
|
+
} from "./chunk-U67V476Y.js";
|
|
692
485
|
|
|
693
|
-
// packages/cli/client/
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
/(^|\/)\.npmrc$/i,
|
|
707
|
-
/(^|\/)\.pypirc$/i,
|
|
708
|
-
/(^|\/)\.pgpass$/i,
|
|
709
|
-
/(^|\/)\.git-credentials$/i,
|
|
710
|
-
/(^|\/)\.htpasswd$/i,
|
|
711
|
-
/(^|\/)\.docker\/config\.json$/i,
|
|
712
|
-
/(^|\/)\.kube\/config$/i,
|
|
713
|
-
/(^|\/)id_(rsa|dsa|ecdsa|ed25519)(\.pub)?$/i,
|
|
714
|
-
/\.(pem|key|p12|pfx|jks|keystore|ppk|asc)$/i,
|
|
715
|
-
/(^|\/)(credentials|secrets?|service[-_]?account|service[-_]?key|token|tokens|apikey|api[-_]?key)s?\.(json|ya?ml|toml)$/i,
|
|
716
|
-
/(^|\/)\.aws\/credentials$/i,
|
|
717
|
-
/(^|\/)\.config\/gcloud\/[^\/]*\.json$/i
|
|
718
|
-
];
|
|
719
|
-
var GIT_ENV_DROP_KEYS = [
|
|
720
|
-
"GIT_DIR",
|
|
721
|
-
"GIT_WORK_TREE",
|
|
722
|
-
"GIT_INDEX_FILE",
|
|
723
|
-
"GIT_COMMON_DIR",
|
|
724
|
-
"GIT_OBJECT_DIRECTORY",
|
|
725
|
-
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
|
726
|
-
"GIT_CEILING_DIRECTORIES",
|
|
727
|
-
"GIT_NAMESPACE",
|
|
728
|
-
"GIT_CONFIG",
|
|
729
|
-
"GIT_CONFIG_COUNT",
|
|
730
|
-
"GIT_CONFIG_PARAMETERS",
|
|
731
|
-
"GIT_CONFIG_KEY_0",
|
|
732
|
-
"GIT_CONFIG_VALUE_0",
|
|
733
|
-
"GIT_REPLACE_REF_BASE",
|
|
734
|
-
"GIT_SHALLOW_FILE",
|
|
735
|
-
"GIT_ATTR_NOSYSTEM"
|
|
736
|
-
];
|
|
737
|
-
function isCredentialLikePath(repoRelativePath) {
|
|
738
|
-
const normalized = repoRelativePath.replace(/\\/g, "/");
|
|
739
|
-
return CREDENTIAL_PATTERNS.some((pattern) => pattern.test(normalized));
|
|
740
|
-
}
|
|
741
|
-
function toMessage(error) {
|
|
742
|
-
if (error instanceof Error) return error.message;
|
|
743
|
-
return String(error);
|
|
744
|
-
}
|
|
745
|
-
function errorCode(error) {
|
|
746
|
-
const code = error?.code;
|
|
747
|
-
return typeof code === "string" ? code : null;
|
|
748
|
-
}
|
|
749
|
-
function sha256(bytes) {
|
|
750
|
-
return createHash("sha256").update(bytes).digest("hex");
|
|
751
|
-
}
|
|
752
|
-
function looksBinary(bytes) {
|
|
753
|
-
const limit = Math.min(bytes.length, BINARY_SNIFF_BYTES);
|
|
754
|
-
for (let index = 0; index < limit; index += 1) {
|
|
755
|
-
if (bytes[index] === 0) return true;
|
|
756
|
-
}
|
|
757
|
-
return false;
|
|
758
|
-
}
|
|
759
|
-
function hashFileStreaming(absPath) {
|
|
760
|
-
const fd = openSync(absPath, "r");
|
|
761
|
-
try {
|
|
762
|
-
const head = Buffer.alloc(BINARY_SNIFF_BYTES);
|
|
763
|
-
const headRead = readSync(fd, head, 0, BINARY_SNIFF_BYTES, null);
|
|
764
|
-
const sniff = head.subarray(0, headRead);
|
|
765
|
-
const hash2 = createHash("sha256");
|
|
766
|
-
hash2.update(sniff);
|
|
767
|
-
let size = headRead;
|
|
768
|
-
const chunk = Buffer.alloc(HASH_CHUNK_BYTES);
|
|
769
|
-
for (; ; ) {
|
|
770
|
-
const read = readSync(fd, chunk, 0, chunk.length, null);
|
|
771
|
-
if (read <= 0) break;
|
|
772
|
-
hash2.update(chunk.subarray(0, read));
|
|
773
|
-
size += read;
|
|
774
|
-
}
|
|
775
|
-
return { hash: hash2.digest("hex"), binary: looksBinary(sniff), size };
|
|
776
|
-
} finally {
|
|
777
|
-
closeSync(fd);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
function gitEnv() {
|
|
781
|
-
const env = {};
|
|
782
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
783
|
-
if (typeof value === "string") env[key] = value;
|
|
784
|
-
}
|
|
785
|
-
for (const key of GIT_ENV_DROP_KEYS) delete env[key];
|
|
786
|
-
env.GIT_OPTIONAL_LOCKS = "0";
|
|
787
|
-
env.GIT_TERMINAL_PROMPT = "0";
|
|
788
|
-
env.GIT_CONFIG_GLOBAL = "/dev/null";
|
|
789
|
-
env.GIT_CONFIG_SYSTEM = "/dev/null";
|
|
790
|
-
env.LC_ALL = "C";
|
|
791
|
-
return env;
|
|
792
|
-
}
|
|
793
|
-
function gitArgs(args) {
|
|
794
|
-
return ["-c", "safe.directory=*", "-c", "diff.renames=copies", "-c", "diff.noprefix=false", ...args];
|
|
795
|
-
}
|
|
796
|
-
async function readPipeBytes(stream) {
|
|
797
|
-
if (!stream) return Buffer.alloc(0);
|
|
798
|
-
const anyStream = stream;
|
|
799
|
-
const chunks = [];
|
|
800
|
-
if (typeof anyStream[Symbol.asyncIterator] === "function") {
|
|
801
|
-
for await (const chunk of anyStream) {
|
|
802
|
-
if (typeof chunk === "string") chunks.push(Buffer.from(chunk, "utf8"));
|
|
803
|
-
else if (chunk instanceof Uint8Array) chunks.push(Buffer.from(chunk));
|
|
804
|
-
else chunks.push(Buffer.from(String(chunk ?? ""), "utf8"));
|
|
805
|
-
}
|
|
806
|
-
return Buffer.concat(chunks);
|
|
807
|
-
}
|
|
808
|
-
return new Promise((resolvePromise) => {
|
|
809
|
-
let done = false;
|
|
810
|
-
const finish = () => {
|
|
811
|
-
if (done) return;
|
|
812
|
-
done = true;
|
|
813
|
-
resolvePromise(Buffer.concat(chunks));
|
|
814
|
-
};
|
|
815
|
-
stream.on("data", (chunk) => {
|
|
816
|
-
chunks.push(typeof chunk === "string" ? Buffer.from(chunk, "utf8") : Buffer.from(chunk));
|
|
486
|
+
// packages/cli/client/liveImageSupport.ts
|
|
487
|
+
function createLiveImageSupportResolver(userId, discover, timeoutMs = 5e3) {
|
|
488
|
+
let discovery;
|
|
489
|
+
return async (config) => {
|
|
490
|
+
if (resolveCatalogImageSupport(config) !== void 0) return config;
|
|
491
|
+
const plan = resolveAgentCallPlan({ ...config, key: config.key ?? "" });
|
|
492
|
+
if (plan.authMethod.kind !== "oauth" || plan.authMethod.ref !== "antigravity") return config;
|
|
493
|
+
const raw = config.rawRecord ?? config;
|
|
494
|
+
const owner = typeof raw.userId === "string" && raw.userId.trim() ? raw.userId.trim() : typeof raw.ownerUserId === "string" ? raw.ownerUserId.trim() : void 0;
|
|
495
|
+
if (!userId || owner !== userId) return withLiveImageSupport(config, false);
|
|
496
|
+
discovery ??= new Promise((resolve7) => {
|
|
497
|
+
const timer = setTimeout(() => resolve7({}), timeoutMs);
|
|
498
|
+
Promise.resolve().then(discover).then(resolve7, () => resolve7({})).finally(() => clearTimeout(timer));
|
|
817
499
|
});
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
}
|
|
823
|
-
async function runGit(args, cwd) {
|
|
824
|
-
const proc = spawnProcess({
|
|
825
|
-
cmd: ["git", ...gitArgs(args)],
|
|
826
|
-
cwd,
|
|
827
|
-
stdout: "pipe",
|
|
828
|
-
stderr: "pipe",
|
|
829
|
-
stdin: "ignore",
|
|
830
|
-
env: gitEnv()
|
|
831
|
-
});
|
|
832
|
-
const [stdout, stderr, exitCode] = await Promise.all([
|
|
833
|
-
readPipeBytes(proc.stdout),
|
|
834
|
-
readPipeText(proc.stderr),
|
|
835
|
-
new Promise((resolvePromise) => {
|
|
836
|
-
const timer = setTimeout(() => {
|
|
837
|
-
proc.kill();
|
|
838
|
-
resolvePromise(-1);
|
|
839
|
-
}, GIT_TIMEOUT_MS);
|
|
840
|
-
void proc.exited.then((code) => {
|
|
841
|
-
clearTimeout(timer);
|
|
842
|
-
resolvePromise(code);
|
|
843
|
-
});
|
|
844
|
-
})
|
|
845
|
-
]);
|
|
846
|
-
return { exitCode, stdout, stderr };
|
|
847
|
-
}
|
|
848
|
-
async function gitText(args, cwd) {
|
|
849
|
-
const result = await runGit(args, cwd);
|
|
850
|
-
if (result.exitCode !== 0) {
|
|
851
|
-
throw new Error(`git ${args.join(" ")} failed (exit ${result.exitCode}): ${result.stderr.trim()}`);
|
|
852
|
-
}
|
|
853
|
-
return result.stdout.toString("utf8");
|
|
854
|
-
}
|
|
855
|
-
function parseNameStatusZ(text) {
|
|
856
|
-
const fields = text.split("\0");
|
|
857
|
-
const out = [];
|
|
858
|
-
let index = 0;
|
|
859
|
-
while (index < fields.length) {
|
|
860
|
-
const status = fields[index];
|
|
861
|
-
if (!status) {
|
|
862
|
-
index += 1;
|
|
863
|
-
continue;
|
|
864
|
-
}
|
|
865
|
-
const letter = status[0];
|
|
866
|
-
if (letter === "R" || letter === "C") {
|
|
867
|
-
const previousPath = fields[index + 1];
|
|
868
|
-
const path2 = fields[index + 2];
|
|
869
|
-
if (!previousPath || !path2) break;
|
|
870
|
-
out.push({ status: letter, path: path2, previousPath });
|
|
871
|
-
index += 3;
|
|
872
|
-
continue;
|
|
873
|
-
}
|
|
874
|
-
const path = fields[index + 1];
|
|
875
|
-
if (!path) break;
|
|
876
|
-
out.push({ status: letter, path });
|
|
877
|
-
index += 2;
|
|
878
|
-
}
|
|
879
|
-
return out;
|
|
880
|
-
}
|
|
881
|
-
function parseLsTreeZ(text) {
|
|
882
|
-
const map = /* @__PURE__ */ new Map();
|
|
883
|
-
for (const record of text.split("\0")) {
|
|
884
|
-
if (!record) continue;
|
|
885
|
-
const tabIndex = record.indexOf(" ");
|
|
886
|
-
if (tabIndex < 0) continue;
|
|
887
|
-
const meta = record.slice(0, tabIndex).split(" ");
|
|
888
|
-
const path = record.slice(tabIndex + 1);
|
|
889
|
-
if (meta.length < 3 || !path) continue;
|
|
890
|
-
map.set(path, { mode: meta[0], sha: meta[2] });
|
|
891
|
-
}
|
|
892
|
-
return map;
|
|
893
|
-
}
|
|
894
|
-
function parseLsFilesZ(text) {
|
|
895
|
-
const map = /* @__PURE__ */ new Map();
|
|
896
|
-
for (const record of text.split("\0")) {
|
|
897
|
-
if (!record) continue;
|
|
898
|
-
const tabIndex = record.indexOf(" ");
|
|
899
|
-
if (tabIndex < 0) continue;
|
|
900
|
-
const meta = record.slice(0, tabIndex).split(" ");
|
|
901
|
-
const path = record.slice(tabIndex + 1);
|
|
902
|
-
if (meta.length < 3 || !path) continue;
|
|
903
|
-
if (meta[2] !== "0") continue;
|
|
904
|
-
map.set(path, { mode: meta[0], sha: meta[1] });
|
|
905
|
-
}
|
|
906
|
-
return map;
|
|
907
|
-
}
|
|
908
|
-
function parseUnmergedPaths(text) {
|
|
909
|
-
const paths = /* @__PURE__ */ new Set();
|
|
910
|
-
for (const record of text.split("\0")) {
|
|
911
|
-
if (!record) continue;
|
|
912
|
-
const tabIndex = record.indexOf(" ");
|
|
913
|
-
if (tabIndex < 0) continue;
|
|
914
|
-
paths.add(record.slice(tabIndex + 1));
|
|
915
|
-
}
|
|
916
|
-
return paths;
|
|
917
|
-
}
|
|
918
|
-
function toPosixRelative(repoRoot, absolutePath) {
|
|
919
|
-
const rel = relative(repoRoot, absolutePath);
|
|
920
|
-
if (!rel || rel.startsWith("..")) return null;
|
|
921
|
-
return rel.split("\\").join("/");
|
|
922
|
-
}
|
|
923
|
-
function isInsideDir(root, candidate) {
|
|
924
|
-
if (candidate === root) return true;
|
|
925
|
-
return candidate.startsWith(root.endsWith(sep) ? root : `${root}${sep}`);
|
|
926
|
-
}
|
|
927
|
-
function realpathBounded(absPath) {
|
|
928
|
-
let current = resolve(absPath);
|
|
929
|
-
const rest = [];
|
|
930
|
-
for (; ; ) {
|
|
931
|
-
try {
|
|
932
|
-
const real = realpathSync(current);
|
|
933
|
-
return rest.length ? join(real, ...rest) : real;
|
|
934
|
-
} catch (error) {
|
|
935
|
-
const code = errorCode(error);
|
|
936
|
-
if (code !== "ENOENT" && code !== "ENOTDIR") return null;
|
|
937
|
-
const parent = dirname(current);
|
|
938
|
-
if (parent === current) return null;
|
|
939
|
-
rest.unshift(basename(current));
|
|
940
|
-
current = parent;
|
|
941
|
-
}
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
function modeType(mode) {
|
|
945
|
-
if (!mode) return null;
|
|
946
|
-
if (mode === "120000") return "symlink";
|
|
947
|
-
if (mode === "160000") return "gitlink";
|
|
948
|
-
if (mode === "040000") return "tree";
|
|
949
|
-
if (mode.startsWith("100")) return "file";
|
|
950
|
-
return "other";
|
|
951
|
-
}
|
|
952
|
-
function normalizeScopePaths(args) {
|
|
953
|
-
const lexical = [];
|
|
954
|
-
const real = [];
|
|
955
|
-
for (const raw of args.taskPaths) {
|
|
956
|
-
const trimmed = raw.trim();
|
|
957
|
-
if (!trimmed) continue;
|
|
958
|
-
const absolute = isAbsolute(trimmed) ? resolve(trimmed) : resolve(args.repoRoot, trimmed);
|
|
959
|
-
const rel = relative(args.repoRoot, absolute);
|
|
960
|
-
if (rel.startsWith("..")) {
|
|
961
|
-
throw new Error(`task path escapes repository root: ${raw}`);
|
|
962
|
-
}
|
|
963
|
-
const relativePath = rel === "" ? "" : rel.split("\\").join("/");
|
|
964
|
-
lexical.push(relativePath);
|
|
965
|
-
const realPath = realpathBounded(absolute);
|
|
966
|
-
real.push(realPath ?? absolute);
|
|
967
|
-
}
|
|
968
|
-
if (lexical.length === 0) {
|
|
969
|
-
throw new Error("taskPaths allowlist is required: no task path given");
|
|
970
|
-
}
|
|
971
|
-
return { lexical, real };
|
|
972
|
-
}
|
|
973
|
-
function isWithinScope(repoRelativePath, scopes) {
|
|
974
|
-
return scopes.some((scope) => {
|
|
975
|
-
if (scope === "") return true;
|
|
976
|
-
if (repoRelativePath === scope) return true;
|
|
977
|
-
return repoRelativePath.startsWith(scope.endsWith("/") ? scope : `${scope}/`);
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
function isWithinRealScope(realPath, scopes) {
|
|
981
|
-
return scopes.some((scope) => isInsideDir(scope, realPath));
|
|
982
|
-
}
|
|
983
|
-
async function hashGitBlob(args) {
|
|
984
|
-
const result = await runGit(["cat-file", "blob", args.sha], args.repoRoot);
|
|
985
|
-
if (result.exitCode !== 0) {
|
|
986
|
-
throw new Error(`git cat-file blob ${args.sha} failed: ${result.stderr.trim()}`);
|
|
987
|
-
}
|
|
988
|
-
return { hash: sha256(result.stdout), binary: looksBinary(result.stdout) };
|
|
989
|
-
}
|
|
990
|
-
function assertSafeBaseline(baseline) {
|
|
991
|
-
if (baseline.startsWith("-")) {
|
|
992
|
-
throw new Error(`baseline must not be parsed as a git option: ${baseline}`);
|
|
993
|
-
}
|
|
994
|
-
for (const char of baseline) {
|
|
995
|
-
const code = char.codePointAt(0) ?? 0;
|
|
996
|
-
if (code <= 32 || code === 127) {
|
|
997
|
-
throw new Error("baseline must not contain control characters or whitespace");
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
function isHexSha(value) {
|
|
1002
|
-
return /^[0-9a-f]{40}$/.test(value) || /^[0-9a-f]{64}$/.test(value);
|
|
1003
|
-
}
|
|
1004
|
-
function computeTaskRevisionEntriesDigest(entries, baselineSha, outcome) {
|
|
1005
|
-
const canonicalEntries = entries.map((entry) => ({
|
|
1006
|
-
path: entry.path,
|
|
1007
|
-
previousPath: entry.previousPath ?? null,
|
|
1008
|
-
changeKind: entry.changeKind,
|
|
1009
|
-
staged: entry.staged,
|
|
1010
|
-
unstaged: entry.unstaged,
|
|
1011
|
-
untracked: entry.untracked,
|
|
1012
|
-
baselineMode: entry.baselineMode,
|
|
1013
|
-
indexMode: entry.indexMode,
|
|
1014
|
-
worktreeMode: entry.worktreeMode,
|
|
1015
|
-
baselineHash: entry.baselineHash,
|
|
1016
|
-
indexHash: entry.indexHash,
|
|
1017
|
-
worktreeHash: entry.worktreeHash,
|
|
1018
|
-
linkTextHash: entry.linkTextHash ?? null,
|
|
1019
|
-
symlinkTargetHash: entry.symlinkTargetHash ?? null,
|
|
1020
|
-
binary: entry.binary,
|
|
1021
|
-
error: entry.error ?? null,
|
|
1022
|
-
hardLinkAlias: entry.hardLinkAlias ?? false,
|
|
1023
|
-
credentialLike: entry.credentialLike ?? false,
|
|
1024
|
-
outOfScopeSymlink: entry.outOfScopeSymlink ?? false,
|
|
1025
|
-
symlinkTargetOutOfScope: entry.symlinkTargetOutOfScope ?? false,
|
|
1026
|
-
followedSymlink: entry.followedSymlink ?? false
|
|
1027
|
-
}));
|
|
1028
|
-
return sha256(
|
|
1029
|
-
JSON.stringify({
|
|
1030
|
-
baselineSha,
|
|
1031
|
-
complete: outcome.complete,
|
|
1032
|
-
failures: outcome.failures.map((failure3) => ({ path: failure3.path, reason: failure3.reason })),
|
|
1033
|
-
entries: canonicalEntries
|
|
1034
|
-
})
|
|
1035
|
-
);
|
|
1036
|
-
}
|
|
1037
|
-
async function collectTaskRevisionEvidence(options) {
|
|
1038
|
-
const cwd = resolve(options.cwd);
|
|
1039
|
-
const requestedBaseline = (options.baseline ?? "").trim();
|
|
1040
|
-
if (!requestedBaseline) {
|
|
1041
|
-
throw new Error("baseline is required: caller must pass an explicit baseline commit");
|
|
1042
|
-
}
|
|
1043
|
-
if (!Array.isArray(options.taskPaths) || options.taskPaths.length === 0) {
|
|
1044
|
-
throw new Error("taskPaths allowlist is required: caller must pass the task-owned paths");
|
|
1045
|
-
}
|
|
1046
|
-
assertSafeBaseline(requestedBaseline);
|
|
1047
|
-
const repoRootText = await gitText(["rev-parse", "--show-toplevel"], cwd);
|
|
1048
|
-
const repoRoot = resolve(repoRootText.trim());
|
|
1049
|
-
const repoRootReal = realpathSync(repoRoot);
|
|
1050
|
-
const scopes = normalizeScopePaths({ repoRoot, repoRootReal, taskPaths: options.taskPaths });
|
|
1051
|
-
const baselineSha = (await gitText(["rev-parse", "--verify", "--end-of-options", `${requestedBaseline}^{commit}`], cwd)).trim();
|
|
1052
|
-
if (!isHexSha(baselineSha)) {
|
|
1053
|
-
throw new Error(`baseline did not resolve to a commit object id: ${requestedBaseline}`);
|
|
1054
|
-
}
|
|
1055
|
-
const [baselineDiffText, stagedDiffText, unstagedDiffText, untrackedText, indexText, treeText, unmergedText] = await Promise.all([
|
|
1056
|
-
gitText(["diff", "--no-ext-diff", "--no-textconv", "--find-copies-harder", "--name-status", "-z", baselineSha, "--"], cwd),
|
|
1057
|
-
gitText(["diff", "--no-ext-diff", "--no-textconv", "--find-copies-harder", "--cached", "--name-status", "-z", baselineSha, "--"], cwd),
|
|
1058
|
-
gitText(["diff", "--no-ext-diff", "--no-textconv", "--find-copies-harder", "--name-status", "-z"], cwd),
|
|
1059
|
-
gitText(["ls-files", "--others", "--exclude-standard", "-z"], cwd),
|
|
1060
|
-
gitText(["ls-files", "-s", "-z"], cwd),
|
|
1061
|
-
gitText(["ls-tree", "-r", "-z", baselineSha], cwd),
|
|
1062
|
-
gitText(["ls-files", "-u", "-z"], cwd)
|
|
1063
|
-
]);
|
|
1064
|
-
const baselineDiff = parseNameStatusZ(baselineDiffText);
|
|
1065
|
-
const stagedDiff = parseNameStatusZ(stagedDiffText);
|
|
1066
|
-
const unstagedDiff = parseNameStatusZ(unstagedDiffText);
|
|
1067
|
-
const indexEntries = parseLsFilesZ(indexText);
|
|
1068
|
-
const baselineTree = parseLsTreeZ(treeText);
|
|
1069
|
-
const unmergedPaths = parseUnmergedPaths(unmergedText);
|
|
1070
|
-
const candidates = /* @__PURE__ */ new Map();
|
|
1071
|
-
const ensure = (path) => {
|
|
1072
|
-
const existing = candidates.get(path);
|
|
1073
|
-
if (existing) return existing;
|
|
1074
|
-
const created = { path, untracked: false };
|
|
1075
|
-
candidates.set(path, created);
|
|
1076
|
-
return created;
|
|
1077
|
-
};
|
|
1078
|
-
for (const item of baselineDiff) {
|
|
1079
|
-
const candidate = ensure(item.path);
|
|
1080
|
-
candidate.baselineStatus = item.status;
|
|
1081
|
-
if (item.previousPath) candidate.previousPath = item.previousPath;
|
|
1082
|
-
}
|
|
1083
|
-
for (const item of stagedDiff) {
|
|
1084
|
-
const candidate = ensure(item.path);
|
|
1085
|
-
candidate.stagedStatus = item.status;
|
|
1086
|
-
if (item.previousPath) candidate.previousPath = item.previousPath;
|
|
1087
|
-
}
|
|
1088
|
-
for (const item of unstagedDiff) {
|
|
1089
|
-
const candidate = ensure(item.path);
|
|
1090
|
-
candidate.unstagedStatus = item.status;
|
|
1091
|
-
if (item.previousPath) candidate.previousPath = item.previousPath;
|
|
1092
|
-
}
|
|
1093
|
-
for (const path of untrackedText.split("\0")) {
|
|
1094
|
-
if (!path) continue;
|
|
1095
|
-
const candidate = ensure(path);
|
|
1096
|
-
candidate.untracked = true;
|
|
1097
|
-
}
|
|
1098
|
-
for (const path of unmergedPaths) {
|
|
1099
|
-
const candidate = ensure(path);
|
|
1100
|
-
candidate.stagedStatus = candidate.stagedStatus ?? "U";
|
|
1101
|
-
candidate.unstagedStatus = candidate.unstagedStatus ?? "U";
|
|
1102
|
-
}
|
|
1103
|
-
const failures = [];
|
|
1104
|
-
const entries = [];
|
|
1105
|
-
let excludedDirtyPathCount = 0;
|
|
1106
|
-
const sortedPaths = [...candidates.keys()].sort();
|
|
1107
|
-
for (const path of sortedPaths) {
|
|
1108
|
-
const absolutePath = resolve(repoRoot, path);
|
|
1109
|
-
const lexicalMatch = isWithinScope(path, scopes.lexical);
|
|
1110
|
-
const realMatch = lexicalMatch ? true : isWithinRealScope(realpathBounded(absolutePath) ?? "", scopes.real);
|
|
1111
|
-
if (!realMatch) {
|
|
1112
|
-
excludedDirtyPathCount += 1;
|
|
1113
|
-
continue;
|
|
1114
|
-
}
|
|
1115
|
-
const candidate = candidates.get(path);
|
|
1116
|
-
const baselineEntry = baselineTree.get(path) ?? null;
|
|
1117
|
-
const indexEntry = indexEntries.get(path) ?? null;
|
|
1118
|
-
let worktreeMode = null;
|
|
1119
|
-
let worktreeHash = null;
|
|
1120
|
-
let worktreeBinary = false;
|
|
1121
|
-
let linkTextHash;
|
|
1122
|
-
let symlinkTargetHash;
|
|
1123
|
-
let symlinkTarget;
|
|
1124
|
-
let followedSymlink;
|
|
1125
|
-
let outOfScopeSymlink;
|
|
1126
|
-
let symlinkTargetOutOfScope;
|
|
1127
|
-
let credentialTarget;
|
|
1128
|
-
let credentialLike = false;
|
|
1129
|
-
let hardLinkAlias;
|
|
1130
|
-
let isGitlink = false;
|
|
1131
|
-
let entryError;
|
|
1132
|
-
let worktreeExists = false;
|
|
1133
|
-
let worktreeIsSymlink = false;
|
|
1134
|
-
let worktreeIsDirectory = false;
|
|
1135
|
-
let worktreeLinks = 1;
|
|
1136
|
-
try {
|
|
1137
|
-
const stats = lstatSync(absolutePath);
|
|
1138
|
-
worktreeExists = true;
|
|
1139
|
-
worktreeIsSymlink = stats.isSymbolicLink();
|
|
1140
|
-
worktreeIsDirectory = stats.isDirectory();
|
|
1141
|
-
worktreeLinks = stats.nlink;
|
|
1142
|
-
worktreeMode = worktreeIsSymlink ? "120000" : stats.isDirectory() ? "040000" : stats.mode & 73 ? "100755" : "100644";
|
|
1143
|
-
} catch (error) {
|
|
1144
|
-
const code = errorCode(error);
|
|
1145
|
-
if (code !== "ENOENT") {
|
|
1146
|
-
entryError = `worktree-stat-failed: ${code ?? toMessage(error)}`;
|
|
1147
|
-
}
|
|
1148
|
-
worktreeExists = false;
|
|
1149
|
-
}
|
|
1150
|
-
if (worktreeLinks > 1) hardLinkAlias = true;
|
|
1151
|
-
if (unmergedPaths.has(path)) {
|
|
1152
|
-
entryError = "unmerged-index-entry";
|
|
1153
|
-
} else if (isCredentialLikePath(path)) {
|
|
1154
|
-
credentialLike = true;
|
|
1155
|
-
entryError = "credential-file-refused";
|
|
1156
|
-
} else if (modeType(baselineEntry?.mode ?? null) === "gitlink" || modeType(indexEntry?.mode ?? null) === "gitlink") {
|
|
1157
|
-
entryError = "gitlink-entry-not-hashable";
|
|
1158
|
-
isGitlink = true;
|
|
1159
|
-
} else if (worktreeIsDirectory) {
|
|
1160
|
-
entryError = "worktree-directory-not-hashable";
|
|
1161
|
-
} else if (worktreeIsSymlink) {
|
|
1162
|
-
let linkTarget;
|
|
1163
|
-
try {
|
|
1164
|
-
linkTarget = readlinkSync(absolutePath);
|
|
1165
|
-
} catch (error) {
|
|
1166
|
-
linkTarget = void 0;
|
|
1167
|
-
entryError = `symlink-read-failed: ${toMessage(error)}`;
|
|
1168
|
-
}
|
|
1169
|
-
if (linkTarget !== void 0) {
|
|
1170
|
-
symlinkTarget = linkTarget;
|
|
1171
|
-
const linkTextHashValue = sha256(Buffer.from(linkTarget, "utf8"));
|
|
1172
|
-
linkTextHash = linkTextHashValue;
|
|
1173
|
-
worktreeHash = linkTextHashValue;
|
|
1174
|
-
const targetAbsolute = resolve(dirname(absolutePath), linkTarget);
|
|
1175
|
-
const targetReal = realpathBounded(targetAbsolute);
|
|
1176
|
-
if (!targetReal || !isInsideDir(repoRootReal, targetReal)) {
|
|
1177
|
-
outOfScopeSymlink = true;
|
|
1178
|
-
followedSymlink = false;
|
|
1179
|
-
entryError = "out-of-scope-symlink";
|
|
1180
|
-
} else {
|
|
1181
|
-
const targetRelative = toPosixRelative(repoRootReal, targetReal);
|
|
1182
|
-
if (!targetRelative || isCredentialLikePath(targetRelative)) {
|
|
1183
|
-
credentialTarget = true;
|
|
1184
|
-
followedSymlink = false;
|
|
1185
|
-
entryError = "credential-target-refused";
|
|
1186
|
-
} else if (!isWithinRealScope(targetReal, scopes.real)) {
|
|
1187
|
-
symlinkTargetOutOfScope = true;
|
|
1188
|
-
followedSymlink = false;
|
|
1189
|
-
} else {
|
|
1190
|
-
try {
|
|
1191
|
-
const targetStats = lstatSync(targetReal);
|
|
1192
|
-
if (targetStats.isDirectory()) {
|
|
1193
|
-
followedSymlink = false;
|
|
1194
|
-
entryError = "symlink-target-is-directory";
|
|
1195
|
-
} else {
|
|
1196
|
-
const hashed = hashFileStreaming(targetReal);
|
|
1197
|
-
symlinkTargetHash = hashed.hash;
|
|
1198
|
-
worktreeBinary = hashed.binary;
|
|
1199
|
-
followedSymlink = true;
|
|
1200
|
-
}
|
|
1201
|
-
} catch (error) {
|
|
1202
|
-
followedSymlink = false;
|
|
1203
|
-
entryError = `symlink-target-unreadable: ${toMessage(error)}`;
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
} else if (worktreeExists) {
|
|
1209
|
-
if (worktreeLinks > 1) {
|
|
1210
|
-
entryError = "hard-link-alias-refused";
|
|
1211
|
-
} else {
|
|
1212
|
-
const realPath = realpathBounded(absolutePath);
|
|
1213
|
-
if (!realPath || !isInsideDir(repoRootReal, realPath)) {
|
|
1214
|
-
entryError = "out-of-repo-realpath";
|
|
1215
|
-
} else if (!isWithinRealScope(realPath, scopes.real)) {
|
|
1216
|
-
entryError = "out-of-scope-realpath";
|
|
1217
|
-
} else {
|
|
1218
|
-
try {
|
|
1219
|
-
const hashed = hashFileStreaming(realPath);
|
|
1220
|
-
worktreeHash = hashed.hash;
|
|
1221
|
-
worktreeBinary = hashed.binary;
|
|
1222
|
-
} catch (error) {
|
|
1223
|
-
entryError = `worktree-unreadable: ${toMessage(error)}`;
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
}
|
|
1228
|
-
const skipBlobRead = credentialLike || isGitlink;
|
|
1229
|
-
const readBlob = async (sha3) => {
|
|
1230
|
-
try {
|
|
1231
|
-
const hashed = await hashGitBlob({ repoRoot, sha: sha3 });
|
|
1232
|
-
return { hash: hashed.hash, binary: hashed.binary };
|
|
1233
|
-
} catch (error) {
|
|
1234
|
-
return { error };
|
|
1235
|
-
}
|
|
1236
|
-
};
|
|
1237
|
-
const [baselineBlob, indexBlob] = await Promise.all([
|
|
1238
|
-
baselineEntry && !skipBlobRead ? readBlob(baselineEntry.sha) : Promise.resolve(null),
|
|
1239
|
-
indexEntry && !skipBlobRead ? readBlob(indexEntry.sha) : Promise.resolve(null)
|
|
1240
|
-
]);
|
|
1241
|
-
let baselineHash = null;
|
|
1242
|
-
let baselineBinary = false;
|
|
1243
|
-
if (baselineBlob) {
|
|
1244
|
-
if (baselineBlob.error !== void 0) {
|
|
1245
|
-
entryError = entryError ?? `baseline-blob-unreadable: ${toMessage(baselineBlob.error)}`;
|
|
1246
|
-
} else {
|
|
1247
|
-
baselineHash = baselineBlob.hash ?? null;
|
|
1248
|
-
baselineBinary = baselineBlob.binary ?? false;
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
let indexHash = null;
|
|
1252
|
-
let indexBinary = false;
|
|
1253
|
-
if (indexBlob) {
|
|
1254
|
-
if (indexBlob.error !== void 0) {
|
|
1255
|
-
entryError = entryError ?? `index-blob-unreadable: ${toMessage(indexBlob.error)}`;
|
|
1256
|
-
} else {
|
|
1257
|
-
indexHash = indexBlob.hash ?? null;
|
|
1258
|
-
indexBinary = indexBlob.binary ?? false;
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
const staged = candidate.stagedStatus !== void 0;
|
|
1262
|
-
const unstaged = candidate.unstagedStatus !== void 0 || candidate.untracked;
|
|
1263
|
-
const baselineType = modeType(baselineEntry?.mode ?? null);
|
|
1264
|
-
const worktreeType = modeType(worktreeMode);
|
|
1265
|
-
let changeKind = "modified";
|
|
1266
|
-
if (candidate.untracked && !baselineEntry && !indexEntry) {
|
|
1267
|
-
changeKind = "untracked";
|
|
1268
|
-
} else if (baselineEntry && !worktreeExists && worktreeType !== "tree") {
|
|
1269
|
-
changeKind = "deleted";
|
|
1270
|
-
} else if (candidate.previousPath) {
|
|
1271
|
-
const renameStatus = candidate.stagedStatus ?? candidate.unstagedStatus ?? candidate.baselineStatus ?? "";
|
|
1272
|
-
changeKind = renameStatus.startsWith("C") ? "copied" : "renamed";
|
|
1273
|
-
} else if (!baselineEntry) {
|
|
1274
|
-
changeKind = "added";
|
|
1275
|
-
} else if (baselineType && worktreeType && baselineType !== worktreeType) {
|
|
1276
|
-
changeKind = "type-changed";
|
|
1277
|
-
} else if (!staged && !unstaged) {
|
|
1278
|
-
changeKind = "unchanged";
|
|
1279
|
-
}
|
|
1280
|
-
const entry = {
|
|
1281
|
-
path,
|
|
1282
|
-
...candidate.previousPath ? { previousPath: candidate.previousPath } : {},
|
|
1283
|
-
changeKind,
|
|
1284
|
-
staged,
|
|
1285
|
-
unstaged,
|
|
1286
|
-
untracked: candidate.untracked,
|
|
1287
|
-
baselineMode: baselineEntry?.mode ?? null,
|
|
1288
|
-
indexMode: indexEntry?.mode ?? null,
|
|
1289
|
-
worktreeMode,
|
|
1290
|
-
baselineHash,
|
|
1291
|
-
indexHash,
|
|
1292
|
-
worktreeHash,
|
|
1293
|
-
binary: worktreeBinary || indexBinary || baselineBinary,
|
|
1294
|
-
...linkTextHash !== void 0 ? { linkTextHash } : {},
|
|
1295
|
-
...symlinkTargetHash !== void 0 ? { symlinkTargetHash } : {},
|
|
1296
|
-
...symlinkTarget !== void 0 ? { symlinkTarget } : {},
|
|
1297
|
-
...followedSymlink !== void 0 ? { followedSymlink } : {},
|
|
1298
|
-
...outOfScopeSymlink !== void 0 ? { outOfScopeSymlink } : {},
|
|
1299
|
-
...symlinkTargetOutOfScope !== void 0 ? { symlinkTargetOutOfScope } : {},
|
|
1300
|
-
...credentialTarget !== void 0 ? { credentialTarget } : {},
|
|
1301
|
-
...credentialLike ? { credentialLike: true } : {},
|
|
1302
|
-
...hardLinkAlias ? { hardLinkAlias: true } : {},
|
|
1303
|
-
...entryError ? { error: entryError } : {}
|
|
1304
|
-
};
|
|
1305
|
-
entries.push(entry);
|
|
1306
|
-
if (entryError) {
|
|
1307
|
-
failures.push({ path, reason: entryError });
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
const complete = failures.length === 0;
|
|
1311
|
-
const entriesDigest = computeTaskRevisionEntriesDigest(entries, baselineSha, {
|
|
1312
|
-
complete,
|
|
1313
|
-
failures
|
|
1314
|
-
});
|
|
1315
|
-
return {
|
|
1316
|
-
cwd,
|
|
1317
|
-
repoRoot,
|
|
1318
|
-
baseline: { requested: requestedBaseline, resolvedSha: baselineSha },
|
|
1319
|
-
collectedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1320
|
-
complete,
|
|
1321
|
-
entries,
|
|
1322
|
-
failures,
|
|
1323
|
-
excludedDirtyPathCount,
|
|
1324
|
-
entriesDigest
|
|
1325
|
-
};
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
// packages/cli/client/taskProgressEvidence.ts
|
|
1329
|
-
import { execFile } from "node:child_process";
|
|
1330
|
-
import { promisify } from "node:util";
|
|
1331
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
1332
|
-
|
|
1333
|
-
// packages/cli/client/taskReviewEvidence.ts
|
|
1334
|
-
import { join as join2, resolve as resolve2 } from "node:path";
|
|
1335
|
-
function sameTaskScope(a, b) {
|
|
1336
|
-
return a.taskId === b.taskId && a.dialogId === b.dialogId && resolve2(a.workspace) === resolve2(b.workspace);
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
// packages/cli/client/taskProgressEvidence.ts
|
|
1340
|
-
var exec = promisify(execFile);
|
|
1341
|
-
var sha = (b) => createHash2("sha256").update(b).digest("hex");
|
|
1342
|
-
function taskContentRevision(evidence) {
|
|
1343
|
-
return sha(Buffer.from(JSON.stringify({
|
|
1344
|
-
baseline: evidence.baseline.resolvedSha,
|
|
1345
|
-
entries: evidence.entries.map((e) => ({ path: e.path, baselineMode: e.baselineMode, baselineHash: e.baselineHash, mode: e.worktreeMode, hash: e.worktreeHash })).sort((a, b) => a.path.localeCompare(b.path))
|
|
1346
|
-
})));
|
|
1347
|
-
}
|
|
1348
|
-
|
|
1349
|
-
// packages/cli/client/hostTaskEvents.ts
|
|
1350
|
-
import { mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
1351
|
-
import { homedir } from "node:os";
|
|
1352
|
-
import { join as join3, resolve as resolve3 } from "node:path";
|
|
1353
|
-
import { createHash as createHash3 } from "node:crypto";
|
|
1354
|
-
var nonempty = (v) => typeof v === "string" && v.trim().length > 0;
|
|
1355
|
-
function scopeOf(ref) {
|
|
1356
|
-
if (!nonempty(ref.taskId) || !nonempty(ref.workspace) || !nonempty(ref.dialogId)) throw new Error("Invalid host task scope");
|
|
1357
|
-
return { taskId: ref.taskId, workspace: resolve3(ref.workspace), dialogId: ref.dialogId, ...ref.taskInstanceId ? { taskInstanceId: ref.taskInstanceId } : {} };
|
|
1358
|
-
}
|
|
1359
|
-
function same(a, b) {
|
|
1360
|
-
return a.taskId === b.taskId && a.workspace === b.workspace && a.dialogId === b.dialogId && a.taskInstanceId === b.taskInstanceId;
|
|
1361
|
-
}
|
|
1362
|
-
function validChange(c) {
|
|
1363
|
-
if (!c || typeof c !== "object") return false;
|
|
1364
|
-
switch (c.type) {
|
|
1365
|
-
case "admitted":
|
|
1366
|
-
return ["owner", "implementation-leaf"].includes(c.role);
|
|
1367
|
-
case "role":
|
|
1368
|
-
return ["owner", "implementation-leaf"].includes(c.value);
|
|
1369
|
-
case "authorization":
|
|
1370
|
-
return ["active", "paused", "revoked"].includes(c.value);
|
|
1371
|
-
case "acceptance":
|
|
1372
|
-
return ["pending", "waived", "accepted", "unknown"].includes(c.value);
|
|
1373
|
-
case "progress":
|
|
1374
|
-
return !!c.value && ["complete", "incomplete", "unknown"].includes(c.value.implementation) && ["changed", "unchanged", "unknown"].includes(c.value.changes);
|
|
1375
|
-
default:
|
|
1376
|
-
return false;
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
function reduce(events, scope) {
|
|
1380
|
-
let contract;
|
|
1381
|
-
let taskStart;
|
|
1382
|
-
for (let i = 0; i < events.length; i++) {
|
|
1383
|
-
const e = events[i];
|
|
1384
|
-
if (!e || !e.scope || !e.source) return { authorization: "unknown", reason: "invalid" };
|
|
1385
|
-
if (!same(e.scope, scope)) return { authorization: "unknown", reason: "scope_mismatch" };
|
|
1386
|
-
if (e.sequence !== i + 1 || !nonempty(e.source?.actorId) || !nonempty(e.source?.sourceId) || !["user-control", "trusted-host"].includes(e.source.kind) || !validChange(e.change)) return { authorization: "unknown", reason: "invalid" };
|
|
1387
|
-
const c = e.change;
|
|
1388
|
-
if (c.type === "admitted") {
|
|
1389
|
-
if (contract) return { authorization: "unknown", reason: "invalid" };
|
|
1390
|
-
if (e.source.kind === "user-control" && c.role !== "owner") return { authorization: "unknown", reason: "invalid" };
|
|
1391
|
-
taskStart = c.taskStart;
|
|
1392
|
-
if (taskStart && (e.source.kind !== "trusted-host" || taskStart.taskInstanceId !== scope.taskInstanceId || taskStart.userId !== e.source.actorId || !nonempty(taskStart.userMessageId) || !/^[a-f0-9]{64}$/.test(taskStart.contentSha256))) return { authorization: "unknown", reason: "invalid" };
|
|
1393
|
-
contract = { taskId: scope.taskId, role: c.role, authorization: "active", acceptance: "unknown", implementation: "unknown", changes: "unknown" };
|
|
1394
|
-
} else {
|
|
1395
|
-
if (!contract) return { authorization: "unknown", reason: "invalid" };
|
|
1396
|
-
if (contract.authorization === "revoked") return { authorization: "unknown", reason: "invalid" };
|
|
1397
|
-
if (c.type === "progress") {
|
|
1398
|
-
if (e.source.kind !== "trusted-host") return { authorization: "unknown", reason: "invalid" };
|
|
1399
|
-
const { implementation, changes, revision, authorInstanceId, review, commit, localMerge } = c.value;
|
|
1400
|
-
contract = { ...contract, implementation, changes, revision, authorInstanceId, review, commit, localMerge };
|
|
1401
|
-
} else if (c.type === "authorization") contract.authorization = c.value;
|
|
1402
|
-
else if (c.type === "acceptance") contract.acceptance = c.value;
|
|
1403
|
-
else if (c.type === "role") {
|
|
1404
|
-
if (e.source.kind !== "trusted-host") return { authorization: "unknown", reason: "invalid" };
|
|
1405
|
-
contract.role = c.value;
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
return contract ? { authorization: contract.authorization, sequence: events.length, contract, ...taskStart ? { taskStart } : {} } : { authorization: "unknown", reason: "missing" };
|
|
1410
|
-
}
|
|
1411
|
-
function directory(root, ref) {
|
|
1412
|
-
return join3(root, createHash3("sha256").update(JSON.stringify(ref)).digest("hex"));
|
|
1413
|
-
}
|
|
1414
|
-
function hostTaskEventsRoot(env) {
|
|
1415
|
-
return join3(env.NOLO_HOME || join3(homedir(), ".nolo"), "host-task-events");
|
|
1416
|
-
}
|
|
1417
|
-
function readHostTask(root, reference) {
|
|
1418
|
-
try {
|
|
1419
|
-
const scope = scopeOf(reference);
|
|
1420
|
-
const dir2 = directory(root, scope);
|
|
1421
|
-
let names;
|
|
1422
|
-
try {
|
|
1423
|
-
names = readdirSync(dir2);
|
|
1424
|
-
} catch (e) {
|
|
1425
|
-
if (e.code === "ENOENT") return { authorization: "unknown", reason: "missing" };
|
|
1426
|
-
throw e;
|
|
1427
|
-
}
|
|
1428
|
-
if (names.some((n) => !/^\d{12}\.json$/.test(n))) return { authorization: "unknown", reason: "invalid" };
|
|
1429
|
-
return reduce(names.sort().map((n) => JSON.parse(readFileSync(join3(dir2, n), "utf8"))), scope);
|
|
1430
|
-
} catch {
|
|
1431
|
-
return { authorization: "unknown", reason: "invalid" };
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
function createHostTaskController(root, source) {
|
|
1435
|
-
if (!nonempty(source.actorId) || !nonempty(source.sourceId) || !["user-control", "trusted-host"].includes(source.kind)) throw new Error("Invalid host source");
|
|
1436
|
-
const boundSource = { ...source };
|
|
1437
|
-
if (root.trim().length === 0) throw new Error("Invalid host event store root");
|
|
1438
|
-
return {
|
|
1439
|
-
append(reference, expectedSequence, change) {
|
|
1440
|
-
const scope = scopeOf(reference);
|
|
1441
|
-
const state = readHostTask(root, scope);
|
|
1442
|
-
if (!Number.isSafeInteger(expectedSequence) || expectedSequence < 0 || (state.authorization === "unknown" ? state.reason !== "missing" || expectedSequence !== 0 : state.sequence !== expectedSequence)) throw new Error("Host task sequence conflict or invalid history");
|
|
1443
|
-
const dir2 = directory(root, scope);
|
|
1444
|
-
const previous = expectedSequence ? readdirSync(dir2).sort().map((n) => JSON.parse(readFileSync(join3(dir2, n), "utf8"))) : [];
|
|
1445
|
-
const event = { scope, sequence: expectedSequence + 1, source: boundSource, change };
|
|
1446
|
-
const next = reduce([...previous, event], scope);
|
|
1447
|
-
if (next.authorization === "unknown") throw new Error("Invalid host task transition");
|
|
1448
|
-
mkdirSync(dir2, { recursive: true, mode: 448 });
|
|
1449
|
-
writeFileSync(join3(dir2, `${String(event.sequence).padStart(12, "0")}.json`), JSON.stringify(event), { flag: "wx", mode: 384 });
|
|
1450
|
-
return next;
|
|
1451
|
-
}
|
|
500
|
+
const models = await discovery;
|
|
501
|
+
const model = config.model?.trim() ?? "";
|
|
502
|
+
const entry = Object.hasOwn(models, model) ? models[model] : void 0;
|
|
503
|
+
return withLiveImageSupport(config, entry?.supportsImages === true && entry.disabled !== true);
|
|
1452
504
|
};
|
|
1453
505
|
}
|
|
1454
|
-
function unknownTaskCompletion(taskId) {
|
|
1455
|
-
return { taskId, status: "blocked", reasons: ["invalid_contract"] };
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
// packages/cli/client/hostReviewDispatch.ts
|
|
1459
|
-
var context = new AsyncLocalStorage();
|
|
1460
|
-
var currentHostReviewDispatch = () => context.getStore();
|
|
1461
|
-
function withHostReviewDispatch(value, action) {
|
|
1462
|
-
return context.run(value ? structuredClone(value) : void 0, action);
|
|
1463
|
-
}
|
|
1464
|
-
function matchesHostReviewDispatch(c, call, args) {
|
|
1465
|
-
return !!c?.target && call.id === c.toolCallId && args.agentKey === c.target.agentKey && args.task === c.target.task;
|
|
1466
|
-
}
|
|
1467
|
-
function consumeHostReviewDispatch(c, env) {
|
|
1468
|
-
if (!safe(c.dispatchId) || !c.toolCallId || !c.target.agentKey || !c.target.task) throw new Error("Invalid review dispatch identity");
|
|
1469
|
-
mkdirSync2(dir(env), { recursive: true, mode: 448 });
|
|
1470
|
-
writeFileSync2(join4(dir(env), `dispatch-${c.dispatchId}.consumed`), JSON.stringify(c), { flag: "wx", mode: 384 });
|
|
1471
|
-
}
|
|
1472
|
-
async function settleHostReviewsForScope(scope, env, accept) {
|
|
1473
|
-
let names;
|
|
1474
|
-
try {
|
|
1475
|
-
names = readdirSync2(dir(env));
|
|
1476
|
-
} catch {
|
|
1477
|
-
return;
|
|
1478
|
-
}
|
|
1479
|
-
for (const name of names.filter((n) => n.endsWith(".json") && !n.startsWith("author-"))) {
|
|
1480
|
-
try {
|
|
1481
|
-
const intent = JSON.parse(readFileSync2(join4(dir(env), name), "utf8"));
|
|
1482
|
-
if (intent.scope.taskId === scope.taskId && intent.scope.dialogId === scope.dialogId && resolve4(intent.scope.workspace) === resolve4(scope.workspace)) {
|
|
1483
|
-
await settleHostReviewDispatch(intent.reviewerRunId, env, accept);
|
|
1484
|
-
}
|
|
1485
|
-
} catch {
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
var safe = (id) => /^[A-Za-z0-9._-]{1,128}$/.test(id);
|
|
1490
|
-
function dir(env) {
|
|
1491
|
-
const path = join4(resolveRunsDir(env), "host-review-dispatch");
|
|
1492
|
-
try {
|
|
1493
|
-
if (lstatSync2(path).isSymbolicLink() || realpathSync2(path) !== resolve4(path)) throw new Error("Unsafe review dispatch directory");
|
|
1494
|
-
} catch (error) {
|
|
1495
|
-
if (error.code !== "ENOENT") throw error;
|
|
1496
|
-
}
|
|
1497
|
-
return path;
|
|
1498
|
-
}
|
|
1499
|
-
function file(env, id) {
|
|
1500
|
-
if (!safe(id)) throw new Error("Invalid review run id");
|
|
1501
|
-
return join4(dir(env), `${id}.json`);
|
|
1502
|
-
}
|
|
1503
|
-
function createHostAuthorExecution(env, scope, turnId) {
|
|
1504
|
-
const task = readHostTask(hostTaskEventsRoot(env), scope);
|
|
1505
|
-
const executionId = task.authorization !== "unknown" && task.contract.authorInstanceId || randomUUID();
|
|
1506
|
-
if (!safe(executionId)) throw new Error("Invalid author execution identity");
|
|
1507
|
-
mkdirSync2(dir(env), { recursive: true, mode: 448 });
|
|
1508
|
-
try {
|
|
1509
|
-
writeFileSync2(join4(dir(env), `author-${executionId}.json`), JSON.stringify({ executionId, scope, turnId }), { flag: "wx", mode: 384 });
|
|
1510
|
-
} catch (error) {
|
|
1511
|
-
const existing = JSON.parse(readFileSync2(join4(dir(env), `author-${executionId}.json`), "utf8"));
|
|
1512
|
-
if (existing.executionId !== executionId || JSON.stringify(existing.scope) !== JSON.stringify(scope)) throw error;
|
|
1513
|
-
}
|
|
1514
|
-
return executionId;
|
|
1515
|
-
}
|
|
1516
|
-
async function validateHostReviewDispatch(c, env, cwd) {
|
|
1517
|
-
if (resolve4(c.scope.workspace) !== resolve4(cwd) || !safe(c.authorExecutionId) || !/^[a-f0-9]{40}(?:[a-f0-9]{24})?$/.test(c.baseline) || !c.taskPaths.length) throw new Error("Invalid trusted review context");
|
|
1518
|
-
const task = readHostTask(hostTaskEventsRoot(env), c.scope);
|
|
1519
|
-
if (task.authorization !== "active") throw new Error("Review task is not active");
|
|
1520
|
-
if (task.contract.authorInstanceId && task.contract.authorInstanceId !== c.authorExecutionId) throw new Error("Author execution identity mismatch");
|
|
1521
|
-
const author = JSON.parse(readFileSync2(join4(dir(env), `author-${c.authorExecutionId}.json`), "utf8"));
|
|
1522
|
-
if (author.executionId !== c.authorExecutionId || JSON.stringify(author.scope) !== JSON.stringify(c.scope) || !author.turnId) throw new Error("Author turn binding missing");
|
|
1523
|
-
const revision = await collectTaskRevisionEvidence({ cwd, baseline: c.baseline, taskPaths: c.taskPaths });
|
|
1524
|
-
if (!revision.complete || taskContentRevision(revision) !== c.revision) throw new Error("Review revision changed or incomplete");
|
|
1525
|
-
}
|
|
1526
|
-
async function bindHostReviewRun(c, runId, env) {
|
|
1527
|
-
if (runId === c.authorExecutionId) throw new Error("Self review rejected");
|
|
1528
|
-
await validateHostReviewDispatch(c, env, c.scope.workspace);
|
|
1529
|
-
mkdirSync2(dir(env), { recursive: true, mode: 448 });
|
|
1530
|
-
const consumed = JSON.parse(readFileSync2(join4(dir(env), `dispatch-${c.dispatchId}.consumed`), "utf8"));
|
|
1531
|
-
if (JSON.stringify(consumed) !== JSON.stringify(c)) throw new Error("Review dispatch not consumed by this invocation");
|
|
1532
|
-
writeFileSync2(join4(dir(env), `dispatch-${c.dispatchId}.bound`), runId, { flag: "wx", mode: 384 });
|
|
1533
|
-
const intent = { ...structuredClone(c), reviewerRunId: runId };
|
|
1534
|
-
writeFileSync2(file(env, runId), JSON.stringify(intent), { flag: "wx", mode: 384 });
|
|
1535
|
-
}
|
|
1536
|
-
async function settleHostReviewDispatch(runId, env, accept, options) {
|
|
1537
|
-
try {
|
|
1538
|
-
const intentPath = file(env, runId);
|
|
1539
|
-
if (lstatSync2(intentPath).isSymbolicLink() || realpathSync2(intentPath) !== resolve4(intentPath)) throw new Error("Unsafe intent path");
|
|
1540
|
-
const intent = JSON.parse(readFileSync2(intentPath, "utf8"));
|
|
1541
|
-
if (intent.reviewerRunId !== runId || intent.authorExecutionId === runId || readFileSync2(join4(dir(env), `dispatch-${intent.dispatchId}.bound`), "utf8") !== runId) throw new Error("Review identity mismatch");
|
|
1542
|
-
await validateHostReviewDispatch(intent, env, intent.scope.workspace);
|
|
1543
|
-
const storedDecision = readDecisionRecord(`${intentPath}.decision`);
|
|
1544
|
-
if (!storedDecision) throw new Error("review_decision_missing");
|
|
1545
|
-
if (storedDecision.state !== "committed" && !(storedDecision.state === "pending" && options?.allowPending)) throw new Error(`review_decision_${storedDecision.state === "pending" ? "pending" : "failed"}`);
|
|
1546
|
-
if (storedDecision.action !== "continue") throw new Error("review_decision_does_not_continue");
|
|
1547
|
-
if (storedDecision.dispatchId !== intent.dispatchId || storedDecision.runId !== runId || storedDecision.revision !== intent.revision) throw new Error("review_decision_binding_mismatch");
|
|
1548
|
-
const run = readRunRecord(runId, { env });
|
|
1549
|
-
const expected = join4(resolveRunsDir(env), `${runId}.result.md`);
|
|
1550
|
-
if (!run || run.runId !== runId || run.status !== "done" || run.exitCode !== 0 || !run.resultFile || resolve4(run.resultFile) !== resolve4(expected)) throw new Error("Review not a successful canonical terminal");
|
|
1551
|
-
if (lstatSync2(expected).isSymbolicLink() || !lstatSync2(expected).isFile() || lstatSync2(expected).size > 2 * 1024 * 1024 || realpathSync2(expected) !== resolve4(expected)) throw new Error("Unsafe result path");
|
|
1552
|
-
const bytes = readFileSync2(expected);
|
|
1553
|
-
const digest2 = createHash4("sha256").update(bytes).digest("hex");
|
|
1554
|
-
if (storedDecision.resultSha256 !== digest2) throw new Error("review_decision_result_changed");
|
|
1555
|
-
if (intent.resultSha256 && intent.resultSha256 !== digest2) throw new Error("Review result changed");
|
|
1556
|
-
const text = stripResultFrontMatter(bytes.toString("utf8"));
|
|
1557
|
-
const verdict = evaluateVerdict(text, intent.revision);
|
|
1558
|
-
if (verdict.status !== "OK APPROVE") throw new Error("Review is not strict APPROVE");
|
|
1559
|
-
const summary = summarizeReview(text);
|
|
1560
|
-
await validateHostReviewDispatch(intent, env, intent.scope.workspace);
|
|
1561
|
-
const pin = `${intentPath}.result-sha256`;
|
|
1562
|
-
try {
|
|
1563
|
-
writeFileSync2(pin, digest2, { flag: "wx", mode: 384 });
|
|
1564
|
-
} catch {
|
|
1565
|
-
if (readFileSync2(pin, "utf8") !== digest2) throw new Error("Review result changed");
|
|
1566
|
-
}
|
|
1567
|
-
const acknowledgement = `${intentPath}.content-accepted`;
|
|
1568
|
-
let accepted = false;
|
|
1569
|
-
try {
|
|
1570
|
-
accepted = readFileSync2(acknowledgement, "utf8") === digest2;
|
|
1571
|
-
} catch {
|
|
1572
|
-
}
|
|
1573
|
-
if (!accepted) {
|
|
1574
|
-
if (!accept || !await accept({ runId, dispatchId: intent.dispatchId, revision: intent.revision, sha256: digest2, text })) throw new Error("Review content not acknowledged by host orchestration");
|
|
1575
|
-
await validateHostReviewDispatch(intent, env, intent.scope.workspace);
|
|
1576
|
-
if (createHash4("sha256").update(readFileSync2(expected)).digest("hex") !== digest2) throw new Error("Review result changed during acknowledgement");
|
|
1577
|
-
try {
|
|
1578
|
-
writeFileSync2(acknowledgement, digest2, { flag: "wx", mode: 384 });
|
|
1579
|
-
} catch {
|
|
1580
|
-
if (readFileSync2(acknowledgement, "utf8") !== digest2) throw new Error("Review acknowledgement mismatch");
|
|
1581
|
-
}
|
|
1582
|
-
}
|
|
1583
|
-
await validateHostReviewDispatch(intent, env, intent.scope.workspace);
|
|
1584
|
-
if (options?.allowPending) return { status: "validated" };
|
|
1585
|
-
const committed = readDecisionRecord(`${intentPath}.decision`);
|
|
1586
|
-
if (!committed || committed.state !== "committed" || committed.action !== "continue" || committed.resultSha256 !== digest2 || committed.dispatchId !== intent.dispatchId || committed.runId !== runId || committed.revision !== intent.revision) throw new Error("review_decision_not_committed");
|
|
1587
|
-
const latest = readHostTask(hostTaskEventsRoot(env), intent.scope);
|
|
1588
|
-
if (latest.authorization !== "active") throw new Error("Task no longer active");
|
|
1589
|
-
if (latest.contract.review?.evidenceRef === `run:${runId}:sha256:${digest2}` && latest.contract.review.revision === intent.revision) return { status: "verified" };
|
|
1590
|
-
createHostTaskController(hostTaskEventsRoot(env), { kind: "trusted-host", actorId: "review-settlement", sourceId: intent.dispatchId }).append(intent.scope, latest.sequence, {
|
|
1591
|
-
type: "progress",
|
|
1592
|
-
value: {
|
|
1593
|
-
...preservedProgress(latest.contract, intent.revision),
|
|
1594
|
-
revision: intent.revision,
|
|
1595
|
-
authorInstanceId: latest.contract.revision === intent.revision ? latest.contract.authorInstanceId ?? intent.authorExecutionId : intent.authorExecutionId,
|
|
1596
|
-
review: { revision: intent.revision, reviewerInstanceId: runId, verdict: summary.verdict, hasCriticalOrHigh: summary.counts.critical > 0 || summary.counts.high > 0, evidenceRef: `run:${runId}:sha256:${digest2}` }
|
|
1597
|
-
}
|
|
1598
|
-
});
|
|
1599
|
-
return { status: "verified" };
|
|
1600
|
-
} catch (e) {
|
|
1601
|
-
try {
|
|
1602
|
-
const intent = JSON.parse(readFileSync2(file(env, runId), "utf8"));
|
|
1603
|
-
const latest = readHostTask(hostTaskEventsRoot(env), intent.scope);
|
|
1604
|
-
if (latest.authorization === "active" && latest.contract.review?.reviewerInstanceId === runId) {
|
|
1605
|
-
const current = await collectTaskRevisionEvidence({ cwd: intent.scope.workspace, baseline: intent.baseline, taskPaths: intent.taskPaths });
|
|
1606
|
-
createHostTaskController(hostTaskEventsRoot(env), { kind: "trusted-host", actorId: "review-settlement", sourceId: `invalidate-${intent.dispatchId}` }).append(intent.scope, latest.sequence, {
|
|
1607
|
-
type: "progress",
|
|
1608
|
-
value: { ...preservedProgress(latest.contract, current.complete ? taskContentRevision(current) : ""), review: void 0 }
|
|
1609
|
-
});
|
|
1610
|
-
}
|
|
1611
|
-
} catch {
|
|
1612
|
-
}
|
|
1613
|
-
return { status: "unknown", reason: e instanceof Error ? e.message : "host binding missing" };
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
function preservedProgress(contract, revision) {
|
|
1617
|
-
if (contract.revision !== revision) return { implementation: "unknown", changes: "unknown", revision: void 0, authorInstanceId: void 0, review: void 0, commit: void 0, localMerge: void 0 };
|
|
1618
|
-
const { implementation, changes, authorInstanceId, review, commit, localMerge } = contract;
|
|
1619
|
-
return { implementation, changes, revision, authorInstanceId, review, commit, localMerge };
|
|
1620
|
-
}
|
|
1621
|
-
async function recordHostTaskReviewDecision(scope, decision, env) {
|
|
1622
|
-
const intentPath = file(env, decision.runId);
|
|
1623
|
-
if (lstatSync2(intentPath).isSymbolicLink() || realpathSync2(intentPath) !== resolve4(intentPath)) throw new Error("Unsafe intent path");
|
|
1624
|
-
const intent = JSON.parse(readFileSync2(intentPath, "utf8"));
|
|
1625
|
-
if (JSON.stringify(intent.scope) !== JSON.stringify(scope) || intent.dispatchId !== decision.dispatchId || intent.reviewerRunId !== decision.runId || intent.revision !== decision.revision || readFileSync2(join4(dir(env), `dispatch-${intent.dispatchId}.bound`), "utf8") !== decision.runId) throw new Error("review_decision_binding_mismatch");
|
|
1626
|
-
const run = readRunRecord(decision.runId, { env });
|
|
1627
|
-
const resultPath = join4(resolveRunsDir(env), `${decision.runId}.result.md`);
|
|
1628
|
-
if (!run || run.status !== "done" || run.exitCode !== 0 || resolve4(run.resultFile ?? "") !== resolve4(resultPath) || lstatSync2(resultPath).isSymbolicLink() || realpathSync2(resultPath) !== resolve4(resultPath) || !lstatSync2(resultPath).isFile() || lstatSync2(resultPath).size > 2 * 1024 * 1024) throw new Error("review_decision_result_unavailable");
|
|
1629
|
-
const bytes = readFileSync2(resultPath);
|
|
1630
|
-
if (createHash4("sha256").update(bytes).digest("hex") !== decision.resultSha256) throw new Error("review_decision_result_changed");
|
|
1631
|
-
const decisionPath = `${intentPath}.decision`;
|
|
1632
|
-
const auditPath = `${decisionPath}.audit`;
|
|
1633
|
-
const pending = { ...structuredClone(decision), state: "pending" };
|
|
1634
|
-
try {
|
|
1635
|
-
writeFileSync2(decisionPath, JSON.stringify(pending), { flag: "wx", mode: 384 });
|
|
1636
|
-
} catch (error) {
|
|
1637
|
-
appendFileSync(auditPath, `${JSON.stringify({ ...pending, state: "failed", reason: "review_decision_already_claimed", at: (/* @__PURE__ */ new Date()).toISOString() })}
|
|
1638
|
-
`, { mode: 384 });
|
|
1639
|
-
throw new Error("review_decision_already_claimed", { cause: error });
|
|
1640
|
-
}
|
|
1641
|
-
try {
|
|
1642
|
-
appendFileSync(auditPath, `${JSON.stringify(pending)}
|
|
1643
|
-
`, { mode: 384 });
|
|
1644
|
-
await validateHostReviewDispatch(intent, env, scope.workspace);
|
|
1645
|
-
const text = stripResultFrontMatter(bytes.toString("utf8"));
|
|
1646
|
-
const summary = summarizeReview(text);
|
|
1647
|
-
pending.counts = summary.counts;
|
|
1648
|
-
if (decision.action === "continue") {
|
|
1649
|
-
if (evaluateVerdict(text, intent.revision).status !== "OK APPROVE") throw new Error("review_decision_not_approved");
|
|
1650
|
-
if (decision.findings.some((f) => f.disposition === "fix")) throw new Error("review_decision_unresolved_findings");
|
|
1651
|
-
assertFindingCoverage(decision.findings, summary);
|
|
1652
|
-
}
|
|
1653
|
-
if (decision.action === "continue") {
|
|
1654
|
-
const validated = await settleHostReviewDispatch(decision.runId, env, (review) => Promise.resolve(review.dispatchId === decision.dispatchId && review.revision === decision.revision && review.sha256 === decision.resultSha256), { allowPending: true });
|
|
1655
|
-
if (validated.status !== "validated") throw new Error(validated.reason ?? "review_decision_not_approved");
|
|
1656
|
-
} else {
|
|
1657
|
-
const latest = readHostTask(hostTaskEventsRoot(env), scope);
|
|
1658
|
-
if (latest.authorization === "unknown") throw new Error("review_decision_task_unresolved");
|
|
1659
|
-
createHostTaskController(hostTaskEventsRoot(env), { kind: "trusted-host", actorId: "review-decision", sourceId: intent.dispatchId }).append(scope, latest.sequence, {
|
|
1660
|
-
type: "progress",
|
|
1661
|
-
value: { ...preservedProgress(latest.contract, intent.revision), review: void 0 }
|
|
1662
|
-
});
|
|
1663
|
-
}
|
|
1664
|
-
writeDecisionRecord(decisionPath, auditPath, { ...pending, state: "committed" }, "committed");
|
|
1665
|
-
if (decision.action === "continue") {
|
|
1666
|
-
const published = await settleHostReviewDispatch(decision.runId, env);
|
|
1667
|
-
if (published.status !== "verified") throw new Error(published.reason ?? "review_decision_not_published");
|
|
1668
|
-
}
|
|
1669
|
-
} catch (error) {
|
|
1670
|
-
writeDecisionRecord(decisionPath, auditPath, { ...pending, state: "failed", reason: error instanceof Error ? error.message : String(error) }, "failed");
|
|
1671
|
-
await settleHostReviewDispatch(decision.runId, env);
|
|
1672
|
-
throw error;
|
|
1673
|
-
}
|
|
1674
|
-
}
|
|
1675
|
-
var FULL_TEXT_COVERAGE_ID = "full-text";
|
|
1676
|
-
var SEVERITY_HEADING_RE = /^#{1,2}\s*[*`_\s]*(CRITICAL|HIGH|MEDIUM|LOW)\b/i;
|
|
1677
|
-
var ANY_HEADING_RE = /^#{1,6}\s/;
|
|
1678
|
-
var EMPTY_DECLARATION_RE = /^(?:无。?|None|0)$/i;
|
|
1679
|
-
var BULLET_RE = /^[-*+]\s+(.*)$/;
|
|
1680
|
-
function summarizeReview(text) {
|
|
1681
|
-
const parsed = parseStructuredReview(text);
|
|
1682
|
-
if (parsed.kind === "invalid") throw new Error(parsed.reason);
|
|
1683
|
-
if (parsed.kind === "structured") {
|
|
1684
|
-
const counts2 = { critical: 0, high: 0, medium: 0, low: 0 };
|
|
1685
|
-
for (const finding of parsed.review.findings)
|
|
1686
|
-
counts2[finding.severity.toLowerCase()]++;
|
|
1687
|
-
return {
|
|
1688
|
-
verdict: structuredReviewVerdict(parsed.review),
|
|
1689
|
-
counts: counts2,
|
|
1690
|
-
findingIds: parsed.review.findings.map((f) => f.id),
|
|
1691
|
-
unlabelled: 0
|
|
1692
|
-
};
|
|
1693
|
-
}
|
|
1694
|
-
const counts = { critical: 0, high: 0, medium: 0, low: 0 };
|
|
1695
|
-
const findingIds = [];
|
|
1696
|
-
let unlabelled = 0;
|
|
1697
|
-
let section = null;
|
|
1698
|
-
let declared = null;
|
|
1699
|
-
for (const raw of text.split("\n")) {
|
|
1700
|
-
const line = raw.trim();
|
|
1701
|
-
if (!line) continue;
|
|
1702
|
-
const verdict2 = line.match(/^VERDICT\s*[::]\s*(APPROVE|BLOCK)\b/);
|
|
1703
|
-
if (verdict2) {
|
|
1704
|
-
declared = verdict2[1];
|
|
1705
|
-
continue;
|
|
1706
|
-
}
|
|
1707
|
-
const severity = line.match(SEVERITY_HEADING_RE);
|
|
1708
|
-
if (severity) {
|
|
1709
|
-
section = severity[1].toLowerCase();
|
|
1710
|
-
continue;
|
|
1711
|
-
}
|
|
1712
|
-
if (ANY_HEADING_RE.test(line)) {
|
|
1713
|
-
section = null;
|
|
1714
|
-
continue;
|
|
1715
|
-
}
|
|
1716
|
-
if (!section) continue;
|
|
1717
|
-
if (line.startsWith("|") || line.startsWith("```") || /^[-=]{3,}$/.test(line)) continue;
|
|
1718
|
-
if (EMPTY_DECLARATION_RE.test(line.replace(/[*`_]/g, "").trim())) continue;
|
|
1719
|
-
const bullet = line.match(BULLET_RE);
|
|
1720
|
-
const body = bullet ? bullet[1] : line;
|
|
1721
|
-
counts[section]++;
|
|
1722
|
-
const id = bullet ? extractFindingId(body) : null;
|
|
1723
|
-
if (id) findingIds.push(id);
|
|
1724
|
-
else unlabelled++;
|
|
1725
|
-
}
|
|
1726
|
-
const verdict = declared === "APPROVE" ? "APPROVE" : declared === "BLOCK" ? "BLOCK" : "WARNING";
|
|
1727
|
-
return { verdict, counts, findingIds, unlabelled };
|
|
1728
|
-
}
|
|
1729
|
-
var SEVERITY_LABEL_RE = /^(?:CRITICAL|HIGH|MEDIUM|LOW)$/i;
|
|
1730
|
-
var LABELLED_FILE_LINE_RE = /(?:^|[\s*`])File\*{0,2}\s*[::]\s*`?([^\s`*:]+?\.[A-Za-z0-9]{1,8}):(\d+(?:-\d+)?)`?(?=$|[\s,;.)])/;
|
|
1731
|
-
function extractFindingId(body) {
|
|
1732
|
-
const bracket = body.match(/^\[([^\]]{1,64})\]/);
|
|
1733
|
-
if (bracket && !SEVERITY_LABEL_RE.test(bracket[1].trim())) return bracket[1].trim();
|
|
1734
|
-
const prefixed = body.match(/\b((?:CRITICAL|HIGH|MEDIUM|LOW|F)-[A-Za-z0-9._-]{1,32})\b/i);
|
|
1735
|
-
if (prefixed) return prefixed[1];
|
|
1736
|
-
const labelled = body.match(LABELLED_FILE_LINE_RE);
|
|
1737
|
-
if (labelled) return `${labelled[1]}:${labelled[2]}`;
|
|
1738
|
-
const reference = body.match(/`([^`\n]+?):(\d+(?:-\d+)?)`/);
|
|
1739
|
-
if (reference) return `${reference[1]}:${reference[2]}`;
|
|
1740
|
-
return null;
|
|
1741
|
-
}
|
|
1742
|
-
function normalizeFindingId(raw) {
|
|
1743
|
-
let id = raw.trim();
|
|
1744
|
-
id = id.replace(/^[`"'\u201c\u201d\u2018\u2019]+|[`"'\u201c\u201d\u2018\u2019]+$/g, "").trim();
|
|
1745
|
-
id = id.replace(/^\[|\]$/g, "").trim();
|
|
1746
|
-
id = id.replace(/\s+/g, " ");
|
|
1747
|
-
id = id.replace(/[.,;]+$/, "").trim();
|
|
1748
|
-
if (/^(?:critical|high|medium|low|f)-/i.test(id)) id = id.toLowerCase();
|
|
1749
|
-
return id;
|
|
1750
|
-
}
|
|
1751
|
-
function assertFindingCoverage(findings, summary) {
|
|
1752
|
-
const declared = findings.map((f) => normalizeFindingId(f.id)).filter((id) => id.length > 0);
|
|
1753
|
-
const uncovered = summary.findingIds.filter((id) => !declared.includes(normalizeFindingId(id)));
|
|
1754
|
-
if (uncovered.length > 0) throw new Error(`review_decision_findings_incomplete: ${uncovered.join(", ")}`);
|
|
1755
|
-
if (summary.unlabelled > 0 && !declared.includes(FULL_TEXT_COVERAGE_ID)) throw new Error("review_decision_findings_incomplete: full-text disposition required");
|
|
1756
|
-
}
|
|
1757
|
-
function readDecisionRecord(path) {
|
|
1758
|
-
try {
|
|
1759
|
-
return JSON.parse(readFileSync2(path, "utf8"));
|
|
1760
|
-
} catch {
|
|
1761
|
-
return null;
|
|
1762
|
-
}
|
|
1763
|
-
}
|
|
1764
|
-
function writeDecisionRecord(decisionPath, auditPath, record, transition) {
|
|
1765
|
-
const tmp = `${decisionPath}.${randomUUID()}.tmp`;
|
|
1766
|
-
writeFileSync2(tmp, JSON.stringify(record), { mode: 384 });
|
|
1767
|
-
renameSync(tmp, decisionPath);
|
|
1768
|
-
appendFileSync(auditPath, `${JSON.stringify({ state: transition, action: record.action, reason: record.reason, counts: record.counts, at: (/* @__PURE__ */ new Date()).toISOString() })}
|
|
1769
|
-
`, { mode: 384 });
|
|
1770
|
-
}
|
|
1771
|
-
|
|
1772
|
-
// packages/cli/client/localRuntimeAdapter.ts
|
|
1773
|
-
import { createHash as createHash14 } from "node:crypto";
|
|
1774
|
-
import { resolve as resolveReviewWorkspace } from "node:path";
|
|
1775
|
-
|
|
1776
|
-
// packages/cli/client/hostTaskWorkspace.ts
|
|
1777
|
-
import { execFileSync } from "node:child_process";
|
|
1778
|
-
import { createHash as createHash5 } from "node:crypto";
|
|
1779
|
-
import { lstatSync as lstatSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, realpathSync as realpathSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
1780
|
-
import { dirname as dirname2, join as join5, relative as relative2, resolve as resolve5 } from "node:path";
|
|
1781
|
-
function git(cwd, args) {
|
|
1782
|
-
const env = { ...process.env, GIT_OPTIONAL_LOCKS: "0", GIT_NO_REPLACE_OBJECTS: "1" };
|
|
1783
|
-
for (const key of ["GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_COMMON_DIR", "GIT_OBJECT_DIRECTORY", "GIT_ALTERNATE_OBJECT_DIRECTORIES"]) delete env[key];
|
|
1784
|
-
return execFileSync("git", ["--no-optional-locks", ...args], { cwd, env, timeout: 15e3, maxBuffer: 8 * 1024 * 1024, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
1785
|
-
}
|
|
1786
|
-
function pathFor(scope, env) {
|
|
1787
|
-
return join5(hostTaskEventsRoot(env), "workspace-snapshots", createHash5("sha256").update(JSON.stringify([scope.taskId, resolve5(scope.workspace), scope.dialogId])).digest("hex") + ".json");
|
|
1788
|
-
}
|
|
1789
|
-
function admitHostTaskWorkspace(scope, env) {
|
|
1790
|
-
const path = pathFor(scope, env);
|
|
1791
|
-
try {
|
|
1792
|
-
return readHostTaskWorkspace(scope, env);
|
|
1793
|
-
} catch (e) {
|
|
1794
|
-
if (e.code !== "ENOENT") throw e;
|
|
1795
|
-
}
|
|
1796
|
-
const snapshot = { version: 1, scope: { ...scope, workspace: resolve5(scope.workspace) }, repoRoot: "", baseline: "", taskPaths: [], existingDirtyPaths: [], status: "blocked" };
|
|
1797
|
-
try {
|
|
1798
|
-
const cwd = realpathSync3(scope.workspace);
|
|
1799
|
-
if (git(cwd, ["rev-parse", "--is-inside-work-tree"]).trim() !== "true") throw new Error("not_git_worktree");
|
|
1800
|
-
snapshot.repoRoot = realpathSync3(git(cwd, ["rev-parse", "--show-toplevel"]).trim());
|
|
1801
|
-
if (cwd !== resolve5(scope.workspace)) throw new Error("workspace_symlink_or_noncanonical");
|
|
1802
|
-
snapshot.baseline = git(cwd, ["rev-parse", "--verify", "HEAD^{commit}"]).trim();
|
|
1803
|
-
const sub = relative2(snapshot.repoRoot, cwd).replaceAll("\\", "/");
|
|
1804
|
-
snapshot.taskPaths = [sub || "."];
|
|
1805
|
-
const status = git(snapshot.repoRoot, ["status", "--porcelain=v1", "-z", "--untracked-files=all"]);
|
|
1806
|
-
const rows = status.split("\0").filter(Boolean);
|
|
1807
|
-
for (let i = 0; i < rows.length; i++) {
|
|
1808
|
-
const row = rows[i];
|
|
1809
|
-
snapshot.existingDirtyPaths.push(row.slice(3));
|
|
1810
|
-
if (row[0] === "R" || row[0] === "C" || row[1] === "R" || row[1] === "C") snapshot.existingDirtyPaths.push(rows[++i] ?? "");
|
|
1811
|
-
}
|
|
1812
|
-
if (snapshot.existingDirtyPaths.length) throw new Error("existing_dirty_paths_ownership_unknown");
|
|
1813
|
-
if (git(cwd, ["rev-parse", "HEAD"]).trim() !== snapshot.baseline) throw new Error("head_changed_during_admission");
|
|
1814
|
-
snapshot.status = "ready";
|
|
1815
|
-
} catch (e) {
|
|
1816
|
-
snapshot.reason = e instanceof Error ? e.message : "workspace_unavailable";
|
|
1817
|
-
}
|
|
1818
|
-
mkdirSync3(dirname2(path), { recursive: true, mode: 448 });
|
|
1819
|
-
writeFileSync3(path, JSON.stringify(snapshot), { flag: "wx", mode: 384 });
|
|
1820
|
-
return snapshot;
|
|
1821
|
-
}
|
|
1822
|
-
function readHostTaskWorkspace(scope, env) {
|
|
1823
|
-
const path = pathFor(scope, env);
|
|
1824
|
-
if (lstatSync3(path).isSymbolicLink() || realpathSync3(path) !== resolve5(path)) throw new Error("unsafe_workspace_snapshot_path");
|
|
1825
|
-
const s = JSON.parse(readFileSync3(path, "utf8"));
|
|
1826
|
-
if (s.version !== 1 || s.scope.taskId !== scope.taskId || s.scope.dialogId !== scope.dialogId || s.scope.workspace !== resolve5(scope.workspace) || s.scope.taskInstanceId !== scope.taskInstanceId) throw new Error("workspace_snapshot_scope_mismatch");
|
|
1827
|
-
return s;
|
|
1828
|
-
}
|
|
1829
|
-
async function collectHostTaskWorkspace(scope, env) {
|
|
1830
|
-
try {
|
|
1831
|
-
const s = readHostTaskWorkspace(scope, env);
|
|
1832
|
-
if (s.status !== "ready" || s.existingDirtyPaths.length) throw new Error(s.reason ?? "workspace_blocked");
|
|
1833
|
-
if (realpathSync3(scope.workspace) !== s.scope.workspace || realpathSync3(git(scope.workspace, ["rev-parse", "--show-toplevel"]).trim()) !== s.repoRoot) throw new Error("workspace_identity_changed");
|
|
1834
|
-
const paths = [relative2(s.repoRoot, s.scope.workspace).replaceAll("\\", "/") || "."];
|
|
1835
|
-
if (JSON.stringify(paths) !== JSON.stringify(s.taskPaths)) throw new Error("workspace_scope_changed");
|
|
1836
|
-
git(scope.workspace, ["merge-base", "--is-ancestor", s.baseline, "HEAD"]);
|
|
1837
|
-
const evidence = await collectTaskRevisionEvidence({ cwd: scope.workspace, baseline: s.baseline, taskPaths: s.taskPaths });
|
|
1838
|
-
if (!evidence.complete || evidence.baseline.resolvedSha !== s.baseline) throw new Error("revision_incomplete");
|
|
1839
|
-
return { status: "ready", context: { scope, baseline: s.baseline, taskPaths: s.taskPaths, revision: taskContentRevision(evidence) } };
|
|
1840
|
-
} catch (e) {
|
|
1841
|
-
return { status: "blocked", reason: e instanceof Error ? e.message : "workspace_snapshot_missing" };
|
|
1842
|
-
}
|
|
1843
|
-
}
|
|
1844
506
|
|
|
1845
507
|
// packages/agent-runtime/anthropicMessagesProvider.ts
|
|
1846
|
-
import { randomUUID
|
|
508
|
+
import { randomUUID } from "node:crypto";
|
|
1847
509
|
|
|
1848
510
|
// packages/agent-runtime/anthropicMessagesStream.ts
|
|
1849
511
|
var ANTHROPIC_STREAM_ERROR_STATUS = {
|
|
@@ -2308,7 +970,7 @@ function buildAnthropicMessagesBody(args) {
|
|
|
2308
970
|
}
|
|
2309
971
|
blocks.push({
|
|
2310
972
|
type: "tool_use",
|
|
2311
|
-
id: stringValue(call.id) ?? `toolu_${
|
|
973
|
+
id: stringValue(call.id) ?? `toolu_${randomUUID()}`,
|
|
2312
974
|
name,
|
|
2313
975
|
input
|
|
2314
976
|
});
|
|
@@ -2403,7 +1065,7 @@ function mapAnthropicMessageToOpenAi(payload) {
|
|
|
2403
1065
|
if (block.type === "thinking" && typeof block.thinking === "string") reasoning += block.thinking;
|
|
2404
1066
|
if (block.type === "tool_use" && typeof block.name === "string") {
|
|
2405
1067
|
toolCalls.push({
|
|
2406
|
-
id: stringValue(block.id) ?? `toolu_${
|
|
1068
|
+
id: stringValue(block.id) ?? `toolu_${randomUUID()}`,
|
|
2407
1069
|
type: "function",
|
|
2408
1070
|
function: { name: block.name, arguments: JSON.stringify(block.input ?? {}) }
|
|
2409
1071
|
});
|
|
@@ -2422,7 +1084,7 @@ function mapAnthropicMessageToOpenAi(payload) {
|
|
|
2422
1084
|
(raw) => raw && typeof raw === "object" && typeof raw.type === "string" ? [String(raw.type)] : []
|
|
2423
1085
|
);
|
|
2424
1086
|
return {
|
|
2425
|
-
id: stringValue(payload.id) ?? `chatcmpl_${
|
|
1087
|
+
id: stringValue(payload.id) ?? `chatcmpl_${randomUUID()}`,
|
|
2426
1088
|
object: "chat.completion",
|
|
2427
1089
|
model: stringValue(payload.model) ?? "claude",
|
|
2428
1090
|
choices: [{
|
|
@@ -2630,33 +1292,43 @@ var REGISTRY_INJECTED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
|
2630
1292
|
"read_xhs_profile"
|
|
2631
1293
|
]);
|
|
2632
1294
|
|
|
2633
|
-
// packages/
|
|
2634
|
-
var
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
}
|
|
1295
|
+
// packages/agent-runtime/agentRunIsolation.ts
|
|
1296
|
+
var ORCHESTRATION_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
1297
|
+
"startAgentRun",
|
|
1298
|
+
"controlAgentRun",
|
|
1299
|
+
"listAgents",
|
|
1300
|
+
"readAgent",
|
|
1301
|
+
"runStreamingAgent"
|
|
1302
|
+
]);
|
|
1303
|
+
var INTERACTION_REQUIRED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
1304
|
+
"ask_user",
|
|
1305
|
+
// 凭据请求:需要宿主交互面板(Block 1a);desktop 无通道时同 ask_user 剥离。
|
|
1306
|
+
"secret-request"
|
|
1307
|
+
]);
|
|
1308
|
+
var SELF_MUTATION_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
1309
|
+
"updateSelf",
|
|
1310
|
+
"updateAgent"
|
|
1311
|
+
]);
|
|
1312
|
+
var SUBTASK_REMOVED_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
1313
|
+
...ORCHESTRATION_TOOL_NAMES,
|
|
1314
|
+
...INTERACTION_REQUIRED_TOOL_NAMES,
|
|
1315
|
+
...SELF_MUTATION_TOOL_NAMES
|
|
1316
|
+
]);
|
|
1317
|
+
function isSubtaskRun(env) {
|
|
1318
|
+
if (!env) return false;
|
|
1319
|
+
const value = env.NOLO_AGENT_RUN_CHILD;
|
|
1320
|
+
return typeof value === "string" && value.length > 0 && value !== "0";
|
|
1321
|
+
}
|
|
1322
|
+
var RUN_WAKE_CHANNEL_ENV = "NOLO_RUN_WAKE";
|
|
1323
|
+
function hasRunWakeChannel(env) {
|
|
1324
|
+
if (!env) return false;
|
|
1325
|
+
const value = env[RUN_WAKE_CHANNEL_ENV];
|
|
1326
|
+
return typeof value === "string" && value.length > 0 && value !== "0";
|
|
1327
|
+
}
|
|
1328
|
+
function filterToolNamesForRunKind(toolNames, isSubtask) {
|
|
1329
|
+
if (!isSubtask) return [...toolNames];
|
|
1330
|
+
return toolNames.filter((name) => !SUBTASK_REMOVED_TOOL_NAMES.has(name));
|
|
1331
|
+
}
|
|
2660
1332
|
|
|
2661
1333
|
// packages/cli/client/localRuntimeTools.ts
|
|
2662
1334
|
var CLI_CHROME_CONNECTOR_TOOL_NAME_SET = new Set(
|
|
@@ -2733,11 +1405,7 @@ function buildOrchestrationOpenAiTools(args) {
|
|
|
2733
1405
|
const names = ["startAgentRun", "controlAgentRun"].filter(
|
|
2734
1406
|
(name) => args.toolNameSet.has(name)
|
|
2735
1407
|
);
|
|
2736
|
-
|
|
2737
|
-
...args.toolNameSet.has("requestTaskReview") ? [{ type: "function", function: requestTaskReviewFunctionSchema }] : [],
|
|
2738
|
-
...args.toolNameSet.has("recordTaskReviewDecision") ? [{ type: "function", function: recordTaskReviewDecisionFunctionSchema }] : []
|
|
2739
|
-
];
|
|
2740
|
-
if (names.length === 0) return reviewTools;
|
|
1408
|
+
if (names.length === 0) return [];
|
|
2741
1409
|
const waitCapableActions = CONTROL_AGENT_RUN_ACTIONS.filter(
|
|
2742
1410
|
(action) => action !== "wait"
|
|
2743
1411
|
);
|
|
@@ -2751,7 +1419,6 @@ function buildOrchestrationOpenAiTools(args) {
|
|
|
2751
1419
|
wakeEnabled: wakeChannel
|
|
2752
1420
|
});
|
|
2753
1421
|
return [
|
|
2754
|
-
...reviewTools,
|
|
2755
1422
|
...prepareTools(names).map((tool) => {
|
|
2756
1423
|
if (tool?.function?.name === "controlAgentRun") {
|
|
2757
1424
|
return { ...tool, function: controlSchema };
|
|
@@ -3639,9 +2306,9 @@ function calculateDelegatedPayloadMetrics(task, input, delegatedContent) {
|
|
|
3639
2306
|
}
|
|
3640
2307
|
var isCliProviderAgent = isCliProviderAgentConfig;
|
|
3641
2308
|
function resolveCliProviderName(agentConfig) {
|
|
3642
|
-
const
|
|
3643
|
-
if (
|
|
3644
|
-
if (isCliProvider(
|
|
2309
|
+
const explicit = asTrimmedLowercaseString(agentConfig?.cliProvider);
|
|
2310
|
+
if (explicit) {
|
|
2311
|
+
if (isCliProvider(explicit)) return explicit;
|
|
3645
2312
|
throw new Error(
|
|
3646
2313
|
`Unknown CLI provider: "${agentConfig?.cliProvider}". Expected one of: ${CLI_PROVIDER_VALUES.join(", ")}`
|
|
3647
2314
|
);
|
|
@@ -3774,14 +2441,14 @@ var resolveCliProviderTransport = async (ctx) => {
|
|
|
3774
2441
|
};
|
|
3775
2442
|
|
|
3776
2443
|
// packages/agent-runtime/codexResponsesProvider.ts
|
|
3777
|
-
import { createHash
|
|
3778
|
-
import { randomUUID as
|
|
2444
|
+
import { createHash } from "node:crypto";
|
|
2445
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
3779
2446
|
var CODEX_RESPONSES_URL = "https://chatgpt.com/backend-api/codex/responses";
|
|
3780
2447
|
var CODEX_CLIENT_VERSION = "0.162.1";
|
|
3781
2448
|
var CODEX_ORIGINATOR = "codex_cli_rs";
|
|
3782
2449
|
var CODEX_OPENAI_BETA = "responses=experimental";
|
|
3783
2450
|
var OPENAI_AUTH_CLAIM = "https://api.openai.com/auth";
|
|
3784
|
-
var CODEX_INSTALLATION_ID =
|
|
2451
|
+
var CODEX_INSTALLATION_ID = randomUUID2();
|
|
3785
2452
|
function decodeCodexAccountId(accessToken) {
|
|
3786
2453
|
const parts = accessToken.split(".");
|
|
3787
2454
|
if (parts.length < 2) return void 0;
|
|
@@ -3799,10 +2466,10 @@ function decodeCodexAccountId(accessToken) {
|
|
|
3799
2466
|
var turnStartedAtByTurn = /* @__PURE__ */ new Map();
|
|
3800
2467
|
function createCodexRequestIdentity(installationId = CODEX_INSTALLATION_ID, stable) {
|
|
3801
2468
|
const key = stable?.sessionKey && isStableSessionIdentityEnabled() ? stable.sessionKey : void 0;
|
|
3802
|
-
const sessionId = key ? deriveStableUuid(key, "session") :
|
|
3803
|
-
const threadId = key ? sessionId :
|
|
3804
|
-
const windowId = key ? deriveStableUuid(key, "window") :
|
|
3805
|
-
const turnId = key ? deriveStableUuid(key, `turn:${stable?.turnToken ?? ""}`) :
|
|
2469
|
+
const sessionId = key ? deriveStableUuid(key, "session") : randomUUID2();
|
|
2470
|
+
const threadId = key ? sessionId : randomUUID2();
|
|
2471
|
+
const windowId = key ? deriveStableUuid(key, "window") : randomUUID2();
|
|
2472
|
+
const turnId = key ? deriveStableUuid(key, `turn:${stable?.turnToken ?? ""}`) : randomUUID2();
|
|
3806
2473
|
let turnStartedAt = Date.now();
|
|
3807
2474
|
if (key) {
|
|
3808
2475
|
const tk = `${key}\0${stable?.turnToken ?? ""}`;
|
|
@@ -3961,7 +2628,7 @@ function throwIfAborted(signal) {
|
|
|
3961
2628
|
}
|
|
3962
2629
|
function waitBackoff(ms, signal, injectedSleep) {
|
|
3963
2630
|
throwIfAborted(signal);
|
|
3964
|
-
return new Promise((
|
|
2631
|
+
return new Promise((resolve7, reject) => {
|
|
3965
2632
|
let timer;
|
|
3966
2633
|
const cleanup = () => {
|
|
3967
2634
|
signal?.removeEventListener("abort", onAbort);
|
|
@@ -3976,7 +2643,7 @@ function waitBackoff(ms, signal, injectedSleep) {
|
|
|
3976
2643
|
injectedSleep(ms).then(
|
|
3977
2644
|
() => {
|
|
3978
2645
|
cleanup();
|
|
3979
|
-
|
|
2646
|
+
resolve7();
|
|
3980
2647
|
},
|
|
3981
2648
|
(error) => {
|
|
3982
2649
|
cleanup();
|
|
@@ -3986,7 +2653,7 @@ function waitBackoff(ms, signal, injectedSleep) {
|
|
|
3986
2653
|
} else {
|
|
3987
2654
|
timer = setTimeout(() => {
|
|
3988
2655
|
cleanup();
|
|
3989
|
-
|
|
2656
|
+
resolve7();
|
|
3990
2657
|
}, ms);
|
|
3991
2658
|
}
|
|
3992
2659
|
});
|
|
@@ -3995,7 +2662,7 @@ async function callCodexResponsesOnce(args, accountId, timingTracker) {
|
|
|
3995
2662
|
const fetchImpl = args.fetchImpl ?? fetch;
|
|
3996
2663
|
const msgs = Array.isArray(args.openAiBody.messages) ? args.openAiBody.messages : [];
|
|
3997
2664
|
const lastUser = [...msgs].reverse().find((m) => m && m.role === "user");
|
|
3998
|
-
const turnToken =
|
|
2665
|
+
const turnToken = createHash("sha256").update(JSON.stringify(lastUser?.content ?? "")).digest("hex").slice(0, 24);
|
|
3999
2666
|
const identity = createCodexRequestIdentity(
|
|
4000
2667
|
void 0,
|
|
4001
2668
|
args.sessionKey ? { sessionKey: args.sessionKey, turnToken } : void 0
|
|
@@ -4239,14 +2906,14 @@ function countCodexInputChars(messages) {
|
|
|
4239
2906
|
}
|
|
4240
2907
|
function abortableSleep(sleepFn, ms, signal) {
|
|
4241
2908
|
let timer;
|
|
4242
|
-
const waitOnce = () => sleepFn ? Promise.resolve(sleepFn(ms)) : new Promise((
|
|
4243
|
-
timer = setTimeout(
|
|
2909
|
+
const waitOnce = () => sleepFn ? Promise.resolve(sleepFn(ms)) : new Promise((resolve7) => {
|
|
2910
|
+
timer = setTimeout(resolve7, ms);
|
|
4244
2911
|
});
|
|
4245
2912
|
if (!signal) return waitOnce().then(() => void 0);
|
|
4246
2913
|
if (signal.aborted) {
|
|
4247
2914
|
return Promise.reject(signal.reason ?? new DOMException("aborted", "AbortError"));
|
|
4248
2915
|
}
|
|
4249
|
-
return new Promise((
|
|
2916
|
+
return new Promise((resolve7, reject) => {
|
|
4250
2917
|
let settled = false;
|
|
4251
2918
|
const finish = (settle) => {
|
|
4252
2919
|
if (settled) return;
|
|
@@ -4260,7 +2927,7 @@ function abortableSleep(sleepFn, ms, signal) {
|
|
|
4260
2927
|
);
|
|
4261
2928
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
4262
2929
|
waitOnce().then(
|
|
4263
|
-
() => finish(
|
|
2930
|
+
() => finish(resolve7),
|
|
4264
2931
|
(error) => finish(() => reject(error))
|
|
4265
2932
|
);
|
|
4266
2933
|
});
|
|
@@ -5163,7 +3830,7 @@ function waitWithAbort(ms, signal) {
|
|
|
5163
3830
|
if (signal?.aborted) {
|
|
5164
3831
|
return Promise.reject(signal.reason ?? new Error("owner-required proxy aborted"));
|
|
5165
3832
|
}
|
|
5166
|
-
return new Promise((
|
|
3833
|
+
return new Promise((resolve7, reject) => {
|
|
5167
3834
|
let timer;
|
|
5168
3835
|
const cleanup = () => {
|
|
5169
3836
|
if (timer !== void 0) clearTimeout(timer);
|
|
@@ -5175,7 +3842,7 @@ function waitWithAbort(ms, signal) {
|
|
|
5175
3842
|
};
|
|
5176
3843
|
timer = setTimeout(() => {
|
|
5177
3844
|
cleanup();
|
|
5178
|
-
|
|
3845
|
+
resolve7();
|
|
5179
3846
|
}, ms);
|
|
5180
3847
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
5181
3848
|
});
|
|
@@ -5692,14 +4359,19 @@ function resolveProviderResolveOverrides(agentConfig, options) {
|
|
|
5692
4359
|
}
|
|
5693
4360
|
|
|
5694
4361
|
// packages/cli/client/localRuntimePaths.ts
|
|
5695
|
-
import { dirname
|
|
4362
|
+
import { dirname, extname, join } from "node:path";
|
|
5696
4363
|
import { fileURLToPath } from "node:url";
|
|
4364
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
5697
4365
|
function resolveLocalRuntimePaths(moduleUrl, compiled, execPath) {
|
|
5698
|
-
if (compiled)
|
|
5699
|
-
|
|
4366
|
+
if (compiled) {
|
|
4367
|
+
const entry = execPath === process.execPath ? getHostRuntimeExecutable() : realpathSync(execPath);
|
|
4368
|
+
return { cliDir: dirname(entry), cliEntrypoint: entry };
|
|
4369
|
+
}
|
|
4370
|
+
const path = fileURLToPath(moduleUrl);
|
|
4371
|
+
const modulePath = existsSync(path) ? realpathSync(path) : path;
|
|
5700
4372
|
const extension = extname(modulePath) === ".js" ? ".js" : ".ts";
|
|
5701
|
-
const cliDir = extension === ".js" ?
|
|
5702
|
-
return { cliDir, cliEntrypoint:
|
|
4373
|
+
const cliDir = extension === ".js" ? dirname(modulePath) : dirname(dirname(modulePath));
|
|
4374
|
+
return { cliDir, cliEntrypoint: join(cliDir, `index${extension}`) };
|
|
5703
4375
|
}
|
|
5704
4376
|
|
|
5705
4377
|
// packages/cli/client/localRunExecutionIsolation.ts
|
|
@@ -5826,7 +4498,7 @@ function describeLocalRunExecutionIsolation(fact) {
|
|
|
5826
4498
|
var emittedNoticeKeys = /* @__PURE__ */ new Set();
|
|
5827
4499
|
function createLocalRunIsolationNoticeEmitter(args) {
|
|
5828
4500
|
const seen = args.seen ?? emittedNoticeKeys;
|
|
5829
|
-
return (fact,
|
|
4501
|
+
return (fact, context) => {
|
|
5830
4502
|
const notice = fact.notice;
|
|
5831
4503
|
if (!notice) return false;
|
|
5832
4504
|
const key = `${notice.platform}:${notice.sandboxBackend}:${notice.reason}`;
|
|
@@ -5844,7 +4516,7 @@ function createLocalRunIsolationNoticeEmitter(args) {
|
|
|
5844
4516
|
reason: fact.reason,
|
|
5845
4517
|
platform: fact.platform,
|
|
5846
4518
|
sandboxBackend: fact.sandboxBackend,
|
|
5847
|
-
...
|
|
4519
|
+
...context ?? {}
|
|
5848
4520
|
}
|
|
5849
4521
|
});
|
|
5850
4522
|
return true;
|
|
@@ -5860,10 +4532,10 @@ function recordLocalRunExecutionIsolation(args) {
|
|
|
5860
4532
|
);
|
|
5861
4533
|
return path;
|
|
5862
4534
|
}
|
|
5863
|
-
function joinPath(
|
|
5864
|
-
if (!
|
|
5865
|
-
const
|
|
5866
|
-
return
|
|
4535
|
+
function joinPath(dir, name) {
|
|
4536
|
+
if (!dir) return name;
|
|
4537
|
+
const sep2 = dir.includes("\\") && !dir.includes("/") ? "\\" : "/";
|
|
4538
|
+
return dir.endsWith(sep2) ? `${dir}${name}` : `${dir}${sep2}${name}`;
|
|
5867
4539
|
}
|
|
5868
4540
|
|
|
5869
4541
|
// packages/core/settingsSyncFreshness.ts
|
|
@@ -5930,7 +4602,7 @@ function isBusyProviderStreamError(error) {
|
|
|
5930
4602
|
return BUSY_STREAM_ERROR_RE.test(toErrorMessage(error));
|
|
5931
4603
|
}
|
|
5932
4604
|
async function defaultSleep(ms) {
|
|
5933
|
-
await new Promise((
|
|
4605
|
+
await new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
5934
4606
|
}
|
|
5935
4607
|
function isRetryableProviderStreamError(error) {
|
|
5936
4608
|
const message = toErrorMessage(error);
|
|
@@ -6392,13 +5064,68 @@ function mergeNoticeGroup(turns, noticeTasks, styleContent) {
|
|
|
6392
5064
|
}
|
|
6393
5065
|
|
|
6394
5066
|
// packages/cli/client/cliRemoteDialogSync.ts
|
|
6395
|
-
|
|
5067
|
+
var RESERVED_AUTHORITY_FIELDS = [
|
|
5068
|
+
"userBatchOwner",
|
|
5069
|
+
"userBatchPhase",
|
|
5070
|
+
"userBatchReceipt",
|
|
5071
|
+
"acceptedUserBatchId"
|
|
5072
|
+
];
|
|
5073
|
+
function hasReservedBatchAuthority(metadata) {
|
|
5074
|
+
if (!isRecord(metadata)) return false;
|
|
5075
|
+
return Object.keys(metadata).some((key) => RESERVED_AUTHORITY_FIELDS.some(
|
|
5076
|
+
(field) => key === field || key.startsWith(`${field}.`) || key === `metadata.${field}` || key.startsWith(`metadata.${field}.`)
|
|
5077
|
+
));
|
|
5078
|
+
}
|
|
5079
|
+
function prepareRemoteDialogEvidenceRecord(key, value, options) {
|
|
6396
5080
|
const record = isRecord(value) ? { ...value } : {};
|
|
6397
5081
|
if (key.includes("-msg-") && typeof record.type !== "string") {
|
|
6398
5082
|
record.type = "msg";
|
|
6399
5083
|
}
|
|
5084
|
+
const metadata = record.metadata;
|
|
5085
|
+
if (key.includes("-msg-") && record.role === "user" && isRecord(metadata) && metadata.queueState === "accepted" && (metadata.cliBatchPhase === "requested" || metadata.cliBatchPhase === "completed" || typeof metadata.cliBatchId === "string" && metadata.cliBatchId.length > 0 || options?.isAcceptedBatchMember === true) && !hasReservedBatchAuthority(metadata)) {
|
|
5086
|
+
const { queueState: _localQueueState, ...evidenceMetadata } = metadata;
|
|
5087
|
+
record.metadata = evidenceMetadata;
|
|
5088
|
+
}
|
|
6400
5089
|
return record;
|
|
6401
5090
|
}
|
|
5091
|
+
async function collectAcceptedUserBatchMessageKeys(ops, localStore) {
|
|
5092
|
+
const memberKeys = /* @__PURE__ */ new Set();
|
|
5093
|
+
const collectReceipt = (op) => {
|
|
5094
|
+
if (op.type !== "put" || !op.key.includes("-msg-")) return;
|
|
5095
|
+
const record = op.value;
|
|
5096
|
+
if (!isRecord(record) || record.role !== "user" || !isRecord(record.metadata)) return;
|
|
5097
|
+
const metadata = record.metadata;
|
|
5098
|
+
if (metadata.cliBatchPhase !== "requested" && metadata.cliBatchPhase !== "completed") {
|
|
5099
|
+
return;
|
|
5100
|
+
}
|
|
5101
|
+
if (hasReservedBatchAuthority(record) || hasReservedBatchAuthority(metadata)) return;
|
|
5102
|
+
if (!Array.isArray(metadata.acceptedUserMessageIds)) return;
|
|
5103
|
+
const match = /^((?:dialog-[^]+?)-msg-)[^]+$/.exec(op.key);
|
|
5104
|
+
if (!match) return;
|
|
5105
|
+
const prefix = match[1];
|
|
5106
|
+
for (const memberId of metadata.acceptedUserMessageIds) {
|
|
5107
|
+
if (typeof memberId === "string" && memberId.length > 0) {
|
|
5108
|
+
memberKeys.add(`${prefix}${memberId}`);
|
|
5109
|
+
}
|
|
5110
|
+
}
|
|
5111
|
+
};
|
|
5112
|
+
for (const op of ops) collectReceipt(op);
|
|
5113
|
+
const prefixes = /* @__PURE__ */ new Set();
|
|
5114
|
+
for (const op of ops) {
|
|
5115
|
+
const record = op.value;
|
|
5116
|
+
if (op.type !== "put" || memberKeys.has(op.key) || record?.role !== "user" || record?.metadata?.queueState !== "accepted" || hasReservedBatchAuthority(record.metadata) || record.metadata.cliBatchPhase === "requested" || record.metadata.cliBatchPhase === "completed" || typeof record.metadata.cliBatchId === "string" && record.metadata.cliBatchId.length > 0) continue;
|
|
5117
|
+
const prefix = typeof record.dialogId === "string" ? `dialog-${record.dialogId}-msg-` : /^((?:dialog-[^]+?)-msg-)[^]+$/.exec(op.key)?.[1];
|
|
5118
|
+
if (prefix && op.key.startsWith(prefix)) prefixes.add(prefix);
|
|
5119
|
+
}
|
|
5120
|
+
if (localStore) {
|
|
5121
|
+
for (const prefix of prefixes) {
|
|
5122
|
+
for await (const [key, value] of localStore.iterator({ gte: prefix, lt: `${prefix}\uFFFF` })) {
|
|
5123
|
+
if (key.startsWith(prefix)) collectReceipt({ type: "put", key, value });
|
|
5124
|
+
}
|
|
5125
|
+
}
|
|
5126
|
+
}
|
|
5127
|
+
return memberKeys;
|
|
5128
|
+
}
|
|
6402
5129
|
function normalizeRemoteSubjectRef(value) {
|
|
6403
5130
|
if (!isRecord(value)) return null;
|
|
6404
5131
|
const kind = asOptionalTrimmedString(value.kind);
|
|
@@ -6464,7 +5191,7 @@ function buildLocalParentWakeMessage(args) {
|
|
|
6464
5191
|
var EVIDENCE_WRITE_BATCH_SIZE = 4;
|
|
6465
5192
|
var EVIDENCE_WRITE_BATCH_GAP_MS = 300;
|
|
6466
5193
|
async function defaultEvidenceSleep(ms) {
|
|
6467
|
-
await new Promise((
|
|
5194
|
+
await new Promise((resolve7) => setTimeout(resolve7, ms));
|
|
6468
5195
|
}
|
|
6469
5196
|
async function runThrottledBatches(items, run, options = {}) {
|
|
6470
5197
|
const batchSize = options.batchSize ?? EVIDENCE_WRITE_BATCH_SIZE;
|
|
@@ -6491,7 +5218,9 @@ async function postRemoteRecord(args) {
|
|
|
6491
5218
|
body: JSON.stringify({
|
|
6492
5219
|
customKey: args.key,
|
|
6493
5220
|
userId: args.userId,
|
|
6494
|
-
data: prepareRemoteDialogEvidenceRecord(args.key, args.data
|
|
5221
|
+
data: prepareRemoteDialogEvidenceRecord(args.key, args.data, {
|
|
5222
|
+
isAcceptedBatchMember: args.isAcceptedBatchMember
|
|
5223
|
+
})
|
|
6495
5224
|
}),
|
|
6496
5225
|
signal: AbortSignal.timeout(remoteDialogSyncTimeout())
|
|
6497
5226
|
},
|
|
@@ -6624,12 +5353,14 @@ async function syncLocalDialogEvidenceToRemote(args) {
|
|
|
6624
5353
|
}
|
|
6625
5354
|
}
|
|
6626
5355
|
orderedOps.push(...nonMsgOps);
|
|
5356
|
+
const acceptedBatchKeys = await collectAcceptedUserBatchMessageKeys(orderedOps, args.localStore);
|
|
6627
5357
|
await runThrottledBatches(
|
|
6628
5358
|
orderedOps.filter((op) => op.type === "put"),
|
|
6629
5359
|
(op) => postRemoteRecord({
|
|
6630
5360
|
authToken,
|
|
6631
5361
|
data: op.value,
|
|
6632
5362
|
fetchImpl: args.fetchImpl,
|
|
5363
|
+
isAcceptedBatchMember: acceptedBatchKeys.has(op.key),
|
|
6633
5364
|
key: op.key,
|
|
6634
5365
|
serverUrl,
|
|
6635
5366
|
userId: args.userId
|
|
@@ -6935,7 +5666,7 @@ function entriesToMessages(entries) {
|
|
|
6935
5666
|
const message = dialogMessageRecordToAgentRuntimeMessage(entry.record);
|
|
6936
5667
|
if (message) messages.push(message);
|
|
6937
5668
|
}
|
|
6938
|
-
return messages;
|
|
5669
|
+
return orderDialogHistory(messages);
|
|
6939
5670
|
}
|
|
6940
5671
|
async function persistIncompleteState(args) {
|
|
6941
5672
|
const persisted = await writeCliDialogHistoryState({
|
|
@@ -7036,7 +5767,7 @@ function analyzeRemoteDialogRecords(args) {
|
|
|
7036
5767
|
}
|
|
7037
5768
|
entries.push({ key, messageId, record, message });
|
|
7038
5769
|
}
|
|
7039
|
-
const messages = entries.map((entry) => entry.message);
|
|
5770
|
+
const messages = orderDialogHistory(entries.map((entry) => entry.message));
|
|
7040
5771
|
for (const detail of findAgentStatePairingIssues(messages)) {
|
|
7041
5772
|
issues.push({ code: "tool-pairing", detail });
|
|
7042
5773
|
}
|
|
@@ -7334,8 +6065,8 @@ function createHostApprovalCardQueue() {
|
|
|
7334
6065
|
return {
|
|
7335
6066
|
/** Resolves with the user's answer once this card reaches the head of the queue. */
|
|
7336
6067
|
present(card, present) {
|
|
7337
|
-
return new Promise((
|
|
7338
|
-
waiting.push({ card, present, resolve:
|
|
6068
|
+
return new Promise((resolve7) => {
|
|
6069
|
+
waiting.push({ card, present, resolve: resolve7 });
|
|
7339
6070
|
void Promise.resolve().then(drain);
|
|
7340
6071
|
});
|
|
7341
6072
|
},
|
|
@@ -7429,13 +6160,13 @@ async function createBrowserShellApprovalBridge(args) {
|
|
|
7429
6160
|
},
|
|
7430
6161
|
...args.awaitHostApproval ? { awaitHostApproval: async (card) => {
|
|
7431
6162
|
requireActive();
|
|
7432
|
-
const decision = await new Promise((
|
|
6163
|
+
const decision = await new Promise((resolve7, reject) => {
|
|
7433
6164
|
const abort = () => reject(new Error("Browser approval bridge revoked"));
|
|
7434
6165
|
lifetime.signal.addEventListener("abort", abort, { once: true });
|
|
7435
6166
|
Promise.resolve().then(() => {
|
|
7436
6167
|
requireActive();
|
|
7437
6168
|
return args.awaitHostApproval(card, lifetime.signal);
|
|
7438
|
-
}).then(
|
|
6169
|
+
}).then(resolve7, reject).finally(() => lifetime.signal.removeEventListener("abort", abort));
|
|
7439
6170
|
});
|
|
7440
6171
|
requireActive();
|
|
7441
6172
|
if (decision !== "allow_once" && decision !== "deny") throw new Error("Invalid host decision");
|
|
@@ -7458,17 +6189,17 @@ async function createBrowserShellApprovalBridge(args) {
|
|
|
7458
6189
|
clearTimeout(timer);
|
|
7459
6190
|
args.signal?.removeEventListener("abort", onAbort);
|
|
7460
6191
|
bindings.clear();
|
|
7461
|
-
closing = new Promise((
|
|
7462
|
-
server.close(() =>
|
|
6192
|
+
closing = new Promise((resolve7) => {
|
|
6193
|
+
server.close(() => resolve7());
|
|
7463
6194
|
server.closeAllConnections();
|
|
7464
6195
|
});
|
|
7465
6196
|
return closing;
|
|
7466
6197
|
}
|
|
7467
|
-
await new Promise((
|
|
6198
|
+
await new Promise((resolve7, reject) => {
|
|
7468
6199
|
server.once("error", reject);
|
|
7469
6200
|
server.listen(0, "127.0.0.1", () => {
|
|
7470
6201
|
server.removeListener("error", reject);
|
|
7471
|
-
|
|
6202
|
+
resolve7();
|
|
7472
6203
|
});
|
|
7473
6204
|
});
|
|
7474
6205
|
const address = server.address();
|
|
@@ -7559,559 +6290,6 @@ Expires: ${new Date(card.expiresAt).toISOString()}`;
|
|
|
7559
6290
|
}
|
|
7560
6291
|
}
|
|
7561
6292
|
|
|
7562
|
-
// packages/cli/client/taskReviewTools.ts
|
|
7563
|
-
import { lstatSync as lstatSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync5, realpathSync as realpathSync4 } from "node:fs";
|
|
7564
|
-
import { join as join8, resolve as resolve8 } from "node:path";
|
|
7565
|
-
|
|
7566
|
-
// packages/cli/tui/redactSecrets.ts
|
|
7567
|
-
var REDACTED = "\u27E8redacted\u27E9";
|
|
7568
|
-
function redactSecrets(text) {
|
|
7569
|
-
return text.replace(/\b(?:sk|pk)-[A-Za-z0-9_-]{10,}/g, REDACTED).replace(/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{12,}/gi, `$1${REDACTED}`).replace(
|
|
7570
|
-
/\b((?:api[_-]?key|apikey|access[_-]?token|auth[_-]?token|token|secret|password|passwd|credential)s?\s*[=:]\s*["']?)[^\s"',;]{8,}/gi,
|
|
7571
|
-
`$1${REDACTED}`
|
|
7572
|
-
).replace(
|
|
7573
|
-
/\b((?:--[a-z-]*(?:token|key|secret|password|credential)[a-z-]*)\s+)[^\s"']{8,}/gi,
|
|
7574
|
-
`$1${REDACTED}`
|
|
7575
|
-
);
|
|
7576
|
-
}
|
|
7577
|
-
|
|
7578
|
-
// packages/cli/tui/askTextSanitize.ts
|
|
7579
|
-
var ASK_SECRET_PLACEHOLDER = "\u27E8redacted\u27E9";
|
|
7580
|
-
var C0_C1_CONTROL_REGEX = /[\x00-\x1f\x7f-\x9f]/g;
|
|
7581
|
-
var NORMAL_GIST_SECRET_PATTERNS = [
|
|
7582
|
-
/\bbearer\s+[A-Za-z0-9._~+/=-]{8,}/i,
|
|
7583
|
-
/\bsk-(?:ant-)?(?:api)?[0-9a-zA-Z-]{10,}/,
|
|
7584
|
-
/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{10,}/,
|
|
7585
|
-
/\bxox[baprs]-[A-Za-z0-9-]{10,}/
|
|
7586
|
-
];
|
|
7587
|
-
function withholdIfSecretLike(gist) {
|
|
7588
|
-
if (!gist) return "";
|
|
7589
|
-
if (findPotentialSecrets(gist).length > 0) return "";
|
|
7590
|
-
if (NORMAL_GIST_SECRET_PATTERNS.some((pattern) => pattern.test(gist))) return "";
|
|
7591
|
-
return gist;
|
|
7592
|
-
}
|
|
7593
|
-
function toText(value) {
|
|
7594
|
-
return typeof value === "string" ? value : String(value ?? "");
|
|
7595
|
-
}
|
|
7596
|
-
function cleanAskText(value) {
|
|
7597
|
-
return stripAnsi(toText(value)).replace(/[\r\n]+/g, " ").replace(/\s+/g, " ").replace(C0_C1_CONTROL_REGEX, "").replace(/\s+/g, " ").trim();
|
|
7598
|
-
}
|
|
7599
|
-
function safeAskText(value, max) {
|
|
7600
|
-
const cleaned = redactSecrets(cleanAskText(value));
|
|
7601
|
-
if (!cleaned) return "";
|
|
7602
|
-
const guarded = withholdIfSecretLike(cleaned) || ASK_SECRET_PLACEHOLDER;
|
|
7603
|
-
return max === void 0 ? guarded : clipCompactText(guarded, max, "\u2026");
|
|
7604
|
-
}
|
|
7605
|
-
function safeApprovalMultilineText(value) {
|
|
7606
|
-
const lines = stripAnsi(String(value ?? "")).replace(/\r\n?|\u2028|\u2029/g, "\n").split("\n");
|
|
7607
|
-
return lines.map((line) => {
|
|
7608
|
-
const cleaned = line.replace(/\t/g, " ").replace(C0_C1_CONTROL_REGEX, "");
|
|
7609
|
-
const redacted = redactSecrets(cleaned);
|
|
7610
|
-
return redacted ? withholdIfSecretLike(redacted) || ASK_SECRET_PLACEHOLDER : "";
|
|
7611
|
-
}).join("\n");
|
|
7612
|
-
}
|
|
7613
|
-
|
|
7614
|
-
// packages/cli/client/hostTaskProgressProducer.ts
|
|
7615
|
-
import { createHash as createHash8 } from "node:crypto";
|
|
7616
|
-
import { lstatSync as lstatSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync4, readdirSync as readdirSync3, writeFileSync as writeFileSync4 } from "node:fs";
|
|
7617
|
-
import { join as join7, relative as relative3, resolve as resolve7 } from "node:path";
|
|
7618
|
-
|
|
7619
|
-
// packages/cli/agentRunLocalWorkspace.ts
|
|
7620
|
-
import { createHash as createHash7 } from "node:crypto";
|
|
7621
|
-
import { constants } from "node:fs";
|
|
7622
|
-
import { lstat, open } from "node:fs/promises";
|
|
7623
|
-
import { resolve as resolve6 } from "node:path";
|
|
7624
|
-
function unknownLocalRunAcceptance(cwd, base) {
|
|
7625
|
-
return {
|
|
7626
|
-
schemaVersion: 1,
|
|
7627
|
-
source: "local-runtime",
|
|
7628
|
-
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7629
|
-
cwd,
|
|
7630
|
-
base,
|
|
7631
|
-
deliveryHead: null,
|
|
7632
|
-
workspace: { status: "unknown", fingerprint: null, changedPaths: null, atomic: false },
|
|
7633
|
-
checks: { status: "unknown", reason: "No version-bound command execution evidence collected" },
|
|
7634
|
-
review: { status: "unknown" }
|
|
7635
|
-
};
|
|
7636
|
-
}
|
|
7637
|
-
async function runGitForLocalSummary(args, deps = {}) {
|
|
7638
|
-
const spawn = deps.spawnProcess ?? spawnProcess;
|
|
7639
|
-
const read = deps.readPipeText ?? readPipeText;
|
|
7640
|
-
const proc = spawn({
|
|
7641
|
-
cmd: ["git", ...args.gitArgs],
|
|
7642
|
-
cwd: args.cwd,
|
|
7643
|
-
stdout: "pipe",
|
|
7644
|
-
stderr: "pipe"
|
|
7645
|
-
});
|
|
7646
|
-
const [stdout, stderr, exitCode] = await Promise.all([
|
|
7647
|
-
read(proc.stdout),
|
|
7648
|
-
read(proc.stderr),
|
|
7649
|
-
proc.exited
|
|
7650
|
-
]);
|
|
7651
|
-
if (exitCode !== 0) {
|
|
7652
|
-
throw new Error((stderr || stdout || `git ${args.gitArgs.join(" ")} failed`).trim());
|
|
7653
|
-
}
|
|
7654
|
-
return args.gitArgs.includes("-z") || args.gitArgs.includes("--binary") ? stdout : stdout.trim();
|
|
7655
|
-
}
|
|
7656
|
-
async function inspectLocalRunWorkspace(cwd, deps = {}, acceptanceBase) {
|
|
7657
|
-
if (acceptanceBase !== void 0) {
|
|
7658
|
-
const acceptance = unknownLocalRunAcceptance(cwd, acceptanceBase);
|
|
7659
|
-
const sample = acceptanceBase === null ? null : await captureBoundedWorkspace(cwd, {
|
|
7660
|
-
spawn: deps.spawnProcess,
|
|
7661
|
-
signal: deps.signal,
|
|
7662
|
-
limits: deps.sampleLimits,
|
|
7663
|
-
base: acceptanceBase
|
|
7664
|
-
});
|
|
7665
|
-
if (sample) {
|
|
7666
|
-
acceptance.deliveryHead = sample.head;
|
|
7667
|
-
acceptance.workspace = {
|
|
7668
|
-
status: "observed",
|
|
7669
|
-
fingerprint: sample.fingerprint,
|
|
7670
|
-
changedPaths: sample.changedPaths,
|
|
7671
|
-
atomic: false
|
|
7672
|
-
};
|
|
7673
|
-
}
|
|
7674
|
-
return {
|
|
7675
|
-
cwd,
|
|
7676
|
-
clean: sample ? sample.status.trim() === "" : false,
|
|
7677
|
-
status: sample?.status ?? "workspace inspection unavailable (unknown)",
|
|
7678
|
-
acceptance,
|
|
7679
|
-
...sample?.commit ? { commit: sample.commit } : {}
|
|
7680
|
-
};
|
|
7681
|
-
}
|
|
7682
|
-
const run = (gitArgs2) => runGitForLocalSummary({ cwd, gitArgs: gitArgs2 }, deps);
|
|
7683
|
-
const status = await run(["status", "--short"]);
|
|
7684
|
-
const rawCommit = await run(["log", "-1", "--format=%h%x00%s"]).catch(() => "");
|
|
7685
|
-
const [hash2, subject] = rawCommit.split("\0");
|
|
7686
|
-
return {
|
|
7687
|
-
cwd,
|
|
7688
|
-
clean: status.trim() === "",
|
|
7689
|
-
status,
|
|
7690
|
-
...hash2 ? { commit: { hash: hash2, subject: subject ?? "" } } : {}
|
|
7691
|
-
};
|
|
7692
|
-
}
|
|
7693
|
-
function shouldPrintLocalRunSummary(args) {
|
|
7694
|
-
return Boolean(args.localRuntimeCwd && args.parsed.runtimeMode === "local");
|
|
7695
|
-
}
|
|
7696
|
-
function formatLocalRunSummary(args) {
|
|
7697
|
-
return [
|
|
7698
|
-
"",
|
|
7699
|
-
"[nolo] local run summary",
|
|
7700
|
-
`workspace: ${args.inspection.cwd}`,
|
|
7701
|
-
...args.dialogId ? [`dialog: ${args.dialogId}`] : [],
|
|
7702
|
-
...args.inspection.commit ? [`commit: ${args.inspection.commit.hash} ${args.inspection.commit.subject}`] : [],
|
|
7703
|
-
`dirty: ${args.inspection.clean ? "clean" : "dirty"}`,
|
|
7704
|
-
...!args.inspection.clean && args.inspection.status.trim() ? [`status:
|
|
7705
|
-
${args.inspection.status.trim()}`] : [],
|
|
7706
|
-
""
|
|
7707
|
-
].join("\n");
|
|
7708
|
-
}
|
|
7709
|
-
async function captureLocalRunBase(cwd, options = {}) {
|
|
7710
|
-
if (options.signal?.aborted) return null;
|
|
7711
|
-
const controller = new AbortController();
|
|
7712
|
-
const abort = () => controller.abort();
|
|
7713
|
-
options.signal?.addEventListener("abort", abort, { once: true });
|
|
7714
|
-
const timer = setTimeout(abort, options.timeoutMs ?? 2e3);
|
|
7715
|
-
let child;
|
|
7716
|
-
let bytesRead = 0;
|
|
7717
|
-
let onAbort;
|
|
7718
|
-
const stop = () => {
|
|
7719
|
-
child?.kill();
|
|
7720
|
-
child?.stdout?.destroy();
|
|
7721
|
-
child?.stderr?.destroy();
|
|
7722
|
-
};
|
|
7723
|
-
controller.signal.addEventListener("abort", stop, { once: true });
|
|
7724
|
-
const work = async () => {
|
|
7725
|
-
child = (options.spawn ?? spawnProcess)({
|
|
7726
|
-
cmd: ["git", "rev-parse", "HEAD"],
|
|
7727
|
-
cwd,
|
|
7728
|
-
stdin: "ignore",
|
|
7729
|
-
stdout: "pipe",
|
|
7730
|
-
stderr: "pipe",
|
|
7731
|
-
env: { ...process.env, GIT_OPTIONAL_LOCKS: "0", GIT_TERMINAL_PROMPT: "0" }
|
|
7732
|
-
});
|
|
7733
|
-
const read = async (stream) => {
|
|
7734
|
-
const chunks = [];
|
|
7735
|
-
if (stream) for await (const chunk of stream) {
|
|
7736
|
-
if (controller.signal.aborted) throw new Error("base capture cancelled");
|
|
7737
|
-
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
7738
|
-
bytesRead += bytes.length;
|
|
7739
|
-
if (bytesRead > (options.outputBytes ?? 4096)) {
|
|
7740
|
-
controller.abort();
|
|
7741
|
-
throw new Error("base output budget");
|
|
7742
|
-
}
|
|
7743
|
-
chunks.push(bytes);
|
|
7744
|
-
}
|
|
7745
|
-
return Buffer.concat(chunks).toString("utf8").trim();
|
|
7746
|
-
};
|
|
7747
|
-
const [head, , code] = await Promise.all([read(child.stdout), read(child.stderr), child.exited]);
|
|
7748
|
-
if (controller.signal.aborted || code !== 0 || !/^[a-f0-9]{40,64}$/.test(head)) return null;
|
|
7749
|
-
return head;
|
|
7750
|
-
};
|
|
7751
|
-
try {
|
|
7752
|
-
return await Promise.race([work(), new Promise((resolve15) => {
|
|
7753
|
-
onAbort = () => resolve15(null);
|
|
7754
|
-
controller.signal.addEventListener("abort", onAbort, { once: true });
|
|
7755
|
-
if (controller.signal.aborted) resolve15(null);
|
|
7756
|
-
})]);
|
|
7757
|
-
} catch {
|
|
7758
|
-
return null;
|
|
7759
|
-
} finally {
|
|
7760
|
-
controller.abort();
|
|
7761
|
-
clearTimeout(timer);
|
|
7762
|
-
options.signal?.removeEventListener("abort", abort);
|
|
7763
|
-
controller.signal.removeEventListener("abort", stop);
|
|
7764
|
-
if (onAbort) controller.signal.removeEventListener("abort", onAbort);
|
|
7765
|
-
}
|
|
7766
|
-
}
|
|
7767
|
-
function observeLocalCommandResult(event, cwd) {
|
|
7768
|
-
if (event.type !== "tool-result" || event.toolName !== "execShell") return;
|
|
7769
|
-
const meta = event.metadata;
|
|
7770
|
-
if (!meta || meta.executionState !== "synchronous-complete" || meta.detached === true || meta.aborted === true || typeof meta.command !== "string" || typeof meta.timedOut !== "boolean" || !meta.timedOut && (typeof meta.exitCode !== "number" || !Number.isInteger(meta.exitCode))) return;
|
|
7771
|
-
return {
|
|
7772
|
-
commandFingerprint: `sha256:${createHash7("sha256").update(meta.command).digest("hex")}`,
|
|
7773
|
-
cwd,
|
|
7774
|
-
cwdSource: "configured-workspace",
|
|
7775
|
-
exitCode: meta.timedOut ? "timeout" : meta.exitCode,
|
|
7776
|
-
// Settlement replaces this with the containing result-file JSON pointer.
|
|
7777
|
-
evidence: "runtime-tool-result",
|
|
7778
|
-
versionBinding: "unknown",
|
|
7779
|
-
source: "execShell-tool-result",
|
|
7780
|
-
toolCallId: event.toolCallId,
|
|
7781
|
-
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
7782
|
-
};
|
|
7783
|
-
}
|
|
7784
|
-
function attachLocalCommandObservations(acceptance, observations, resultReference) {
|
|
7785
|
-
if (!observations.length) return;
|
|
7786
|
-
const existing = acceptance.checks.observations ?? [];
|
|
7787
|
-
acceptance.checks.observations = [...existing, ...observations.map((observation, index) => ({
|
|
7788
|
-
...observation,
|
|
7789
|
-
evidence: `${resultReference}#/acceptance/checks/observations/${existing.length + index}`
|
|
7790
|
-
}))];
|
|
7791
|
-
acceptance.checks.reason = "Command exits observed; execution cwd is configured only and execution-time version stability is unproven";
|
|
7792
|
-
}
|
|
7793
|
-
var COMMAND_WORKSPACE_SAMPLE_LIMITS = {
|
|
7794
|
-
timeoutMs: 2e3,
|
|
7795
|
-
gitOutputBytes: 1024 * 1024,
|
|
7796
|
-
files: 128,
|
|
7797
|
-
fileBytes: 1024 * 1024,
|
|
7798
|
-
totalFileBytes: 4 * 1024 * 1024,
|
|
7799
|
-
concurrentSamples: 1
|
|
7800
|
-
};
|
|
7801
|
-
var activeCommandWorkspaceSamples = 0;
|
|
7802
|
-
async function captureBoundedWorkspace(cwd, options = {}) {
|
|
7803
|
-
if (options.signal?.aborted || activeCommandWorkspaceSamples >= COMMAND_WORKSPACE_SAMPLE_LIMITS.concurrentSamples) return null;
|
|
7804
|
-
activeCommandWorkspaceSamples++;
|
|
7805
|
-
const limits = { ...COMMAND_WORKSPACE_SAMPLE_LIMITS, ...options.limits };
|
|
7806
|
-
const controller = new AbortController();
|
|
7807
|
-
const abort = () => controller.abort();
|
|
7808
|
-
options.signal?.addEventListener("abort", abort, { once: true });
|
|
7809
|
-
const timer = setTimeout(abort, limits.timeoutMs);
|
|
7810
|
-
let outputBytes = 0;
|
|
7811
|
-
let fileBytes = 0;
|
|
7812
|
-
const check = () => {
|
|
7813
|
-
if (controller.signal.aborted) throw new Error("sample cancelled");
|
|
7814
|
-
};
|
|
7815
|
-
const git2 = async (args) => {
|
|
7816
|
-
check();
|
|
7817
|
-
const child = (options.spawn ?? spawnProcess)({
|
|
7818
|
-
cmd: ["git", ...args],
|
|
7819
|
-
cwd,
|
|
7820
|
-
stdin: "ignore",
|
|
7821
|
-
stdout: "pipe",
|
|
7822
|
-
stderr: "pipe",
|
|
7823
|
-
env: { ...process.env, GIT_OPTIONAL_LOCKS: "0", GIT_TERMINAL_PROMPT: "0" }
|
|
7824
|
-
});
|
|
7825
|
-
const stop = () => {
|
|
7826
|
-
child.kill();
|
|
7827
|
-
child.stdout?.destroy();
|
|
7828
|
-
child.stderr?.destroy();
|
|
7829
|
-
};
|
|
7830
|
-
controller.signal.addEventListener("abort", stop, { once: true });
|
|
7831
|
-
const read = async (stream) => {
|
|
7832
|
-
const chunks = [];
|
|
7833
|
-
if (stream) for await (const chunk of stream) {
|
|
7834
|
-
check();
|
|
7835
|
-
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
7836
|
-
outputBytes += bytes.length;
|
|
7837
|
-
if (outputBytes > limits.gitOutputBytes) {
|
|
7838
|
-
controller.abort();
|
|
7839
|
-
throw new Error("git output budget");
|
|
7840
|
-
}
|
|
7841
|
-
chunks.push(bytes);
|
|
7842
|
-
}
|
|
7843
|
-
return Buffer.concat(chunks);
|
|
7844
|
-
};
|
|
7845
|
-
try {
|
|
7846
|
-
const [stdout, , code] = await Promise.all([read(child.stdout), read(child.stderr), child.exited]);
|
|
7847
|
-
check();
|
|
7848
|
-
if (code !== 0) throw new Error("git inspection failed");
|
|
7849
|
-
return stdout;
|
|
7850
|
-
} finally {
|
|
7851
|
-
controller.signal.removeEventListener("abort", stop);
|
|
7852
|
-
stop();
|
|
7853
|
-
}
|
|
7854
|
-
};
|
|
7855
|
-
const work = async () => {
|
|
7856
|
-
const head = await git2(["rev-parse", "HEAD"]);
|
|
7857
|
-
const root = (await git2(["rev-parse", "--show-toplevel"])).toString("utf8").trim();
|
|
7858
|
-
const digest2 = createHash7("sha256").update(head);
|
|
7859
|
-
const summary = options.base !== void 0 ? (await git2(["log", "-1", "--format=%h%x00%s"])).toString("utf8").trim() : "";
|
|
7860
|
-
const paths = options.base !== void 0 ? (await git2(["-C", root, "diff", "--name-only", "-z", options.base, "--"])).toString("utf8").split("\0").filter(Boolean) : [];
|
|
7861
|
-
if (paths.length > limits.files) throw new Error("base changed file count budget");
|
|
7862
|
-
const status = await git2(["-C", root, "status", "--porcelain=v1", "-z", "--untracked-files=all"]);
|
|
7863
|
-
if (status.toString("utf8").split("\0").filter(Boolean).length > limits.files) throw new Error("changed file count budget");
|
|
7864
|
-
digest2.update(status);
|
|
7865
|
-
for (const args of [
|
|
7866
|
-
["diff", "--no-ext-diff", "--no-textconv", "--binary", "HEAD", "--"],
|
|
7867
|
-
["diff", "--cached", "--no-ext-diff", "--no-textconv", "--binary", "HEAD", "--"]
|
|
7868
|
-
]) digest2.update(await git2(["-C", root, ...args]));
|
|
7869
|
-
const names = (await git2(["-C", root, "ls-files", "--others", "--exclude-standard", "-z"])).toString("utf8").split("\0").filter(Boolean).sort();
|
|
7870
|
-
if (names.length > limits.files) throw new Error("file count budget");
|
|
7871
|
-
for (const name of names) {
|
|
7872
|
-
check();
|
|
7873
|
-
const path = resolve6(root, name);
|
|
7874
|
-
const stat = await lstat(path);
|
|
7875
|
-
check();
|
|
7876
|
-
if (!stat.isFile() || stat.size > limits.fileBytes || fileBytes + stat.size > limits.totalFileBytes) throw new Error("file budget");
|
|
7877
|
-
digest2.update(JSON.stringify([name, stat.mode, stat.size]));
|
|
7878
|
-
if (stat.size === 0) {
|
|
7879
|
-
const after2 = await lstat(path);
|
|
7880
|
-
check();
|
|
7881
|
-
if (!after2.isFile() || after2.size !== 0 || after2.ino !== stat.ino || after2.mtimeMs !== stat.mtimeMs) throw new Error("racing empty file");
|
|
7882
|
-
continue;
|
|
7883
|
-
}
|
|
7884
|
-
let readBytes = 0;
|
|
7885
|
-
const file2 = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
7886
|
-
try {
|
|
7887
|
-
check();
|
|
7888
|
-
const opened = await file2.stat();
|
|
7889
|
-
check();
|
|
7890
|
-
if (!opened.isFile() || opened.ino !== stat.ino || opened.size !== stat.size) throw new Error("racing open");
|
|
7891
|
-
const stream = file2.createReadStream({
|
|
7892
|
-
autoClose: false,
|
|
7893
|
-
highWaterMark: Math.min(32 * 1024, stat.size),
|
|
7894
|
-
end: stat.size - 1,
|
|
7895
|
-
signal: controller.signal
|
|
7896
|
-
});
|
|
7897
|
-
try {
|
|
7898
|
-
for await (const chunk of stream) {
|
|
7899
|
-
check();
|
|
7900
|
-
const bytes = chunk;
|
|
7901
|
-
readBytes += bytes.length;
|
|
7902
|
-
fileBytes += bytes.length;
|
|
7903
|
-
if (readBytes > limits.fileBytes || fileBytes > limits.totalFileBytes) throw new Error("read budget");
|
|
7904
|
-
digest2.update(bytes);
|
|
7905
|
-
}
|
|
7906
|
-
} finally {
|
|
7907
|
-
stream.destroy();
|
|
7908
|
-
}
|
|
7909
|
-
} finally {
|
|
7910
|
-
await file2.close();
|
|
7911
|
-
}
|
|
7912
|
-
const after = await lstat(path);
|
|
7913
|
-
check();
|
|
7914
|
-
if (readBytes !== stat.size || after.size !== stat.size || after.mtimeMs !== stat.mtimeMs || after.ino !== stat.ino || !after.isFile()) throw new Error("racing file");
|
|
7915
|
-
}
|
|
7916
|
-
check();
|
|
7917
|
-
const [hash2, subject] = summary.split("\0");
|
|
7918
|
-
return {
|
|
7919
|
-
fingerprint: `sha256:${digest2.digest("hex")}`,
|
|
7920
|
-
head: head.toString("utf8").trim(),
|
|
7921
|
-
status: status.toString("utf8").replace(/\0/g, "\n"),
|
|
7922
|
-
changedPaths: [.../* @__PURE__ */ new Set([...paths, ...names])].sort(),
|
|
7923
|
-
...hash2 ? { commit: { hash: hash2, subject: subject ?? "" } } : {}
|
|
7924
|
-
};
|
|
7925
|
-
};
|
|
7926
|
-
let onAbort;
|
|
7927
|
-
try {
|
|
7928
|
-
const pending = work().finally(() => {
|
|
7929
|
-
activeCommandWorkspaceSamples--;
|
|
7930
|
-
});
|
|
7931
|
-
return await Promise.race([pending, new Promise((resolve15) => {
|
|
7932
|
-
onAbort = () => resolve15(null);
|
|
7933
|
-
controller.signal.addEventListener("abort", onAbort, { once: true });
|
|
7934
|
-
if (controller.signal.aborted) resolve15(null);
|
|
7935
|
-
})]);
|
|
7936
|
-
} catch {
|
|
7937
|
-
return null;
|
|
7938
|
-
} finally {
|
|
7939
|
-
controller.abort();
|
|
7940
|
-
clearTimeout(timer);
|
|
7941
|
-
options.signal?.removeEventListener("abort", abort);
|
|
7942
|
-
if (onAbort) controller.signal.removeEventListener("abort", onAbort);
|
|
7943
|
-
}
|
|
7944
|
-
}
|
|
7945
|
-
async function captureCommandWorkspaceFingerprint(cwd, options = {}) {
|
|
7946
|
-
return (await captureBoundedWorkspace(cwd, options))?.fingerprint ?? null;
|
|
7947
|
-
}
|
|
7948
|
-
function wrapLocalCommandWorkspaceObservation(adapter, cwd, bindings, capture = captureCommandWorkspaceFingerprint, signal) {
|
|
7949
|
-
const safeCapture = (callSignal) => capture(cwd, { signal: signal ?? callSignal }).catch(() => null);
|
|
7950
|
-
return {
|
|
7951
|
-
...adapter,
|
|
7952
|
-
async executeTool(call, options) {
|
|
7953
|
-
if (call.name !== "execShell") return adapter.executeTool.call(adapter, call, options);
|
|
7954
|
-
try {
|
|
7955
|
-
if (JSON.parse(call.arguments).background === true) return adapter.executeTool.call(adapter, call, options);
|
|
7956
|
-
} catch {
|
|
7957
|
-
}
|
|
7958
|
-
const before = await safeCapture(options?.abortSignal);
|
|
7959
|
-
const result = await adapter.executeTool.call(adapter, call, options);
|
|
7960
|
-
if (result.metadata?.executionState === "synchronous-complete" && result.metadata.detached !== true && result.metadata.aborted !== true) {
|
|
7961
|
-
const after = await safeCapture(options?.abortSignal);
|
|
7962
|
-
bindings.set(call.id, {
|
|
7963
|
-
versionBinding: !before || !after ? "unknown" : before === after ? "observed-unchanged" : "stale",
|
|
7964
|
-
executionWorkspace: {
|
|
7965
|
-
before,
|
|
7966
|
-
after,
|
|
7967
|
-
atomic: false,
|
|
7968
|
-
limitation: "ABA and external concurrent writes are not excluded"
|
|
7969
|
-
}
|
|
7970
|
-
});
|
|
7971
|
-
}
|
|
7972
|
-
return result;
|
|
7973
|
-
}
|
|
7974
|
-
};
|
|
7975
|
-
}
|
|
7976
|
-
|
|
7977
|
-
// packages/cli/client/hostTaskProgressProducer.ts
|
|
7978
|
-
var digest = (text) => createHash8("sha256").update(text).digest("hex");
|
|
7979
|
-
var explicit = (paths) => paths.length > 0 && paths.every((p) => typeof p === "string" && p !== "." && !p.startsWith("/") && !p.includes("\\") && !p.includes("\0") && p.split("/").every((s) => s && s !== "." && s !== ".."));
|
|
7980
|
-
var planPath = (scope, env) => join7(hostTaskEventsRoot(env), "plans", `${digest(JSON.stringify(scope))}.json`);
|
|
7981
|
-
function readHostTaskAcceptancePlan(scope, env) {
|
|
7982
|
-
try {
|
|
7983
|
-
const path = planPath(scope, env);
|
|
7984
|
-
if (lstatSync4(path).isSymbolicLink()) return;
|
|
7985
|
-
const saved = JSON.parse(readFileSync4(path, "utf8"));
|
|
7986
|
-
if (sameTaskScope(saved.scope, scope) && saved.scope.taskInstanceId === scope.taskInstanceId) return saved.plan;
|
|
7987
|
-
} catch {
|
|
7988
|
-
}
|
|
7989
|
-
}
|
|
7990
|
-
function readHostTaskUserAssignment(scope, env) {
|
|
7991
|
-
const path = join7(hostTaskEventsRoot(env), "assignments", `${digest(JSON.stringify(scope))}.json`);
|
|
7992
|
-
try {
|
|
7993
|
-
if (lstatSync4(path).isSymbolicLink()) return;
|
|
7994
|
-
const evidence = JSON.parse(readFileSync4(path, "utf8"));
|
|
7995
|
-
if (!sameTaskScope(evidence.scope, scope) || evidence.scope.taskInstanceId !== scope.taskInstanceId || digest(evidence.body) !== evidence.bodySha256 || evidence.complete && evidence.bodySha256 !== evidence.source.contentSha256) return;
|
|
7996
|
-
return { path, source: evidence.source, complete: evidence.complete, bodySha256: evidence.bodySha256 };
|
|
7997
|
-
} catch {
|
|
7998
|
-
return;
|
|
7999
|
-
}
|
|
8000
|
-
}
|
|
8001
|
-
function readHostTaskReviewPlanEvidence(scope, env) {
|
|
8002
|
-
const plan = readHostTaskAcceptancePlan(scope, env);
|
|
8003
|
-
if (!plan) throw new Error("task_acceptance_plan_required_continue_author");
|
|
8004
|
-
const planFile = planPath(scope, env);
|
|
8005
|
-
const saved = JSON.parse(readFileSync4(planFile, "utf8"));
|
|
8006
|
-
const observationFile = join7(hostTaskEventsRoot(env), "producer", `${digest(JSON.stringify(scope))}.json`);
|
|
8007
|
-
let observations = [];
|
|
8008
|
-
try {
|
|
8009
|
-
if (lstatSync4(observationFile).isSymbolicLink()) throw new Error("unsafe_observation_file");
|
|
8010
|
-
const record = JSON.parse(readFileSync4(observationFile, "utf8"));
|
|
8011
|
-
if (sameTaskScope(record.scope, scope) && JSON.stringify(record.plan) === JSON.stringify(plan)) observations = record.observations;
|
|
8012
|
-
} catch {
|
|
8013
|
-
}
|
|
8014
|
-
return { plan, assignment: readHostTaskUserAssignment(scope, env), source: saved.source, planFile, observationFile: observations.length ? observationFile : void 0, observations };
|
|
8015
|
-
}
|
|
8016
|
-
async function collectHostTaskPlannedWorkspace(scope, env) {
|
|
8017
|
-
const plan = readHostTaskAcceptancePlan(scope, env);
|
|
8018
|
-
if (!plan || !explicit(plan.taskPaths)) throw new Error("task_acceptance_plan_required_continue_author");
|
|
8019
|
-
const evidence = await collectTaskRevisionEvidence({ cwd: scope.workspace, baseline: plan.baseline, taskPaths: plan.taskPaths });
|
|
8020
|
-
if (!evidence.complete) throw new Error("task_revision_incomplete");
|
|
8021
|
-
return { scope, baseline: plan.baseline, taskPaths: plan.taskPaths, revision: taskContentRevision(evidence) };
|
|
8022
|
-
}
|
|
8023
|
-
|
|
8024
|
-
// packages/cli/client/taskReviewTools.ts
|
|
8025
|
-
import { createHash as createHash9, randomUUID as randomUUID4 } from "node:crypto";
|
|
8026
|
-
function createTaskReviewExecutors(deps) {
|
|
8027
|
-
const host = async () => {
|
|
8028
|
-
if (!deps.host) throw Object.assign(new Error("Task review requires a registered local host scope and account authorization binding"), { code: "task_review_host_unavailable" });
|
|
8029
|
-
await deps.host.authorize();
|
|
8030
|
-
return deps.host;
|
|
8031
|
-
};
|
|
8032
|
-
const argsOf = (call) => {
|
|
8033
|
-
const value = call.arguments ?? call.args;
|
|
8034
|
-
return typeof value === "string" ? JSON.parse(value) : value;
|
|
8035
|
-
};
|
|
8036
|
-
return {
|
|
8037
|
-
requestTaskReview: async (call) => {
|
|
8038
|
-
const h = await host();
|
|
8039
|
-
const a = argsOf(call);
|
|
8040
|
-
if (!a || typeof a.reviewerAgentKey !== "string" || !a.reviewerAgentKey.trim()) throw new Error("reviewerAgentKey required");
|
|
8041
|
-
if (!readHostTaskAcceptancePlan(h.scope, deps.env)) throw new Error("task_plan_required");
|
|
8042
|
-
const workspace = await collectHostTaskWorkspace(h.scope, deps.env);
|
|
8043
|
-
if (workspace.status !== "ready") throw new Error(`task_review_workspace_unavailable: ${workspace.reason}`);
|
|
8044
|
-
const c = readHostTaskAcceptancePlan(h.scope, deps.env) ? await collectHostTaskPlannedWorkspace(h.scope, deps.env) : workspace.context;
|
|
8045
|
-
if (c.taskPaths.includes(".")) throw new Error("task_acceptance_plan_required_continue_author");
|
|
8046
|
-
if (a.revision !== c.revision) throw new Error("task_review_revision_changed");
|
|
8047
|
-
const facts = readHostTaskReviewPlanEvidence(h.scope, deps.env);
|
|
8048
|
-
if (!facts.assignment || facts.assignment.source.messageId !== facts.source?.messageId || facts.assignment.source.contentSha256 !== facts.source?.contentSha256) throw new Error("task_assignment_evidence_unavailable");
|
|
8049
|
-
const dispatchId = randomUUID4();
|
|
8050
|
-
const evidenceRoot = join8(resolveRunsDir(deps.env), "host-review-dispatch");
|
|
8051
|
-
mkdirSync5(evidenceRoot, { recursive: true, mode: 448 });
|
|
8052
|
-
const evidenceFile = join8(evidenceRoot, `plan-${dispatchId}.json`);
|
|
8053
|
-
const checks = facts.plan.commands.map((command) => {
|
|
8054
|
-
const fingerprint = `sha256:${createHash9("sha256").update(command.command).digest("hex")}`;
|
|
8055
|
-
const index = facts.observations.findLastIndex((o) => o.commandFingerprint === fingerprint && o.revision === c.revision);
|
|
8056
|
-
const observation = facts.observations[index];
|
|
8057
|
-
return {
|
|
8058
|
-
...command,
|
|
8059
|
-
status: observation ? "observed (not a semantic pass)" : "not executed / evidence unavailable",
|
|
8060
|
-
...observation ? { observation, evidenceRef: `${evidenceFile}#/checks/${facts.plan.commands.indexOf(command)}/observation`, originalEvidenceRef: `${facts.observationFile}#/observations/${index}` } : {}
|
|
8061
|
-
};
|
|
8062
|
-
});
|
|
8063
|
-
writeFileSync5(evidenceFile, JSON.stringify({
|
|
8064
|
-
scope: h.scope,
|
|
8065
|
-
baseline: c.baseline,
|
|
8066
|
-
revision: c.revision,
|
|
8067
|
-
taskPaths: c.taskPaths,
|
|
8068
|
-
planId: facts.plan.planId,
|
|
8069
|
-
userSource: facts.source,
|
|
8070
|
-
assignment: facts.assignment,
|
|
8071
|
-
planFile: facts.planFile,
|
|
8072
|
-
checks
|
|
8073
|
-
}), { flag: "wx", mode: 384 });
|
|
8074
|
-
const task = `Read-only review of worktree ${h.scope.workspace}. Files/scope: ${JSON.stringify(c.taskPaths)}. Revision: ${c.revision}. Host planId: ${facts.plan.planId}. Host evidence: ${evidenceFile}.
|
|
8075
|
-
All acceptanceCommands: ${JSON.stringify(checks.map(({ commandId, command, status, evidenceRef }) => ({ commandId, command, status, evidenceRef })))}.
|
|
8076
|
-
Read the host-captured user assignment JSON at ${facts.assignment.path} using readFile. Verify SHA-256 of its body equals ${facts.assignment.bodySha256}; original source hash: ${facts.source.contentSha256}. Assignment completeness: ${facts.assignment.complete ? "complete; body hash must also equal original source hash" : "INCOMPLETE credential-filtered projection; original source hash cannot be verified from the redacted body; do not claim full evidence"}; the frozen plan is a model proposal, not proof of task completeness. Verify that the explicit files and ALL planned checks cover the user's assigned scope and that checks meaningfully exercise the required behavior. Inspect host observations in the evidence file (toolCallId, revision, exit/status, workspace before/after). Exit 0, including true, does not prove implementation complete. If coverage/check effectiveness is insufficient, record a concrete finding; if required assignment/evidence is unavailable, return status incomplete with reason. Return one JSON object, no fence: {"schemaVersion":1,"revision":"${c.revision}","status":"completed" or "incomplete","findings":[{"id":"M-1","severity":"MEDIUM","file":"path","line":1,"evidence":"observable evidence or reproduction","impact":"concrete consequence"}]}. Use findings:[] if none. incomplete requires a nonempty reason; completed must not contain reason. No verdict or separate report; put every issue in findings. The host computes approval. Do not invent findings to fill the schema. Do not edit files.`;
|
|
8077
|
-
const dispatch = {
|
|
8078
|
-
...c,
|
|
8079
|
-
authorExecutionId: h.authorExecutionId,
|
|
8080
|
-
dispatchId,
|
|
8081
|
-
planId: facts.plan.planId,
|
|
8082
|
-
planEvidenceFile: evidenceFile,
|
|
8083
|
-
toolCallId: call.id || randomUUID4(),
|
|
8084
|
-
target: { agentKey: a.reviewerAgentKey, task }
|
|
8085
|
-
};
|
|
8086
|
-
await validateHostReviewDispatch(dispatch, deps.env, h.scope.workspace);
|
|
8087
|
-
const selectionReason = `Host review dispatch: reviewer ${a.reviewerAgentKey} is fixed by the host task-review seam and was validated as an agent other than the author ${h.authorExecutionId} (review independence), so the reviewer's own model tier is used as-is rather than swapping to a difficulty-matched agent.`;
|
|
8088
|
-
const result = await withHostReviewDispatch(dispatch, () => deps.start({ ...call, id: dispatch.toolCallId, name: "startAgentRun", arguments: JSON.stringify({
|
|
8089
|
-
agentKey: a.reviewerAgentKey,
|
|
8090
|
-
title: "Task review",
|
|
8091
|
-
task,
|
|
8092
|
-
readOnly: true,
|
|
8093
|
-
parentDialogId: h.scope.dialogId,
|
|
8094
|
-
cwd: h.scope.workspace,
|
|
8095
|
-
selectionReason
|
|
8096
|
-
}) }));
|
|
8097
|
-
return { ...result, content: JSON.stringify({ dispatchId: dispatch.dispatchId, revision: dispatch.revision, launch: result.content }) };
|
|
8098
|
-
},
|
|
8099
|
-
recordTaskReviewDecision: async (call) => {
|
|
8100
|
-
const h = await host();
|
|
8101
|
-
const a = argsOf(call);
|
|
8102
|
-
if (!a || !["continue", "fix", "stop"].includes(a.action) || !["dispatchId", "runId", "revision", "rationale"].every((k) => typeof a[k] === "string" && a[k].trim()) || !/^[a-f0-9]{64}$/.test(a.resultSha256) || !Array.isArray(a.findings) || a.findings.some((f) => !f || typeof f.id !== "string" || !f.id.trim() || !["accepted", "fix", "disputed"].includes(f.disposition) || typeof f.rationale !== "string" || !f.rationale.trim())) throw new Error("invalid_task_review_decision");
|
|
8103
|
-
if (!/^[A-Za-z0-9._-]{1,128}$/.test(a.runId)) throw new Error("review_decision_binding_mismatch");
|
|
8104
|
-
const intentPath = join8(resolveRunsDir(deps.env), "host-review-dispatch", `${a.runId}.json`);
|
|
8105
|
-
if (lstatSync5(intentPath).isSymbolicLink() || realpathSync4(intentPath) !== resolve8(intentPath)) throw new Error("unsafe_review_plan_binding");
|
|
8106
|
-
const intent = JSON.parse(readFileSync5(intentPath, "utf8"));
|
|
8107
|
-
const plan = readHostTaskAcceptancePlan(h.scope, deps.env);
|
|
8108
|
-
if (!plan || intent.planId !== plan.planId) throw new Error("review_decision_plan_mismatch");
|
|
8109
|
-
await recordHostTaskReviewDecision(h.scope, a, deps.env);
|
|
8110
|
-
return { content: JSON.stringify({ recorded: true, action: a.action, dispatchId: a.dispatchId }) };
|
|
8111
|
-
}
|
|
8112
|
-
};
|
|
8113
|
-
}
|
|
8114
|
-
|
|
8115
6293
|
// packages/core/fetchWebpageShaping.ts
|
|
8116
6294
|
var FETCH_WEBPAGE_PREVIEW_LENGTH = 1200;
|
|
8117
6295
|
var FETCH_WEBPAGE_MAX_CONTENT_LENGTH = 12 * 1024;
|
|
@@ -8217,7 +6395,7 @@ async function fetchWebpageLocally(args) {
|
|
|
8217
6395
|
}
|
|
8218
6396
|
|
|
8219
6397
|
// packages/cli/client/cliServerPlatformToolExecutors.ts
|
|
8220
|
-
import { createHash as
|
|
6398
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
8221
6399
|
function buildServerPlatformToolExecutors(args) {
|
|
8222
6400
|
const postServer = async (path, body, opts) => {
|
|
8223
6401
|
const serverUrl = resolveRuntimeServerUrl(args.env);
|
|
@@ -8354,7 +6532,7 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
8354
6532
|
}
|
|
8355
6533
|
])
|
|
8356
6534
|
);
|
|
8357
|
-
const shortHash = (value, len) =>
|
|
6535
|
+
const shortHash = (value, len) => createHash2("sha256").update(value).digest("hex").slice(0, len);
|
|
8358
6536
|
const localMemoryContext = async () => {
|
|
8359
6537
|
const openCliLocalRuntimeDb = async () => {
|
|
8360
6538
|
const { getDefaultCliLocalRuntimeDb: getDefaultCliLocalRuntimeDb2 } = await import("./localRuntimeDb-N7KHDXS2.js");
|
|
@@ -8381,8 +6559,8 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
8381
6559
|
}
|
|
8382
6560
|
const remoteItems = Array.isArray(remote?.selectedItems) ? remote.selectedItems : [];
|
|
8383
6561
|
const [{ loadMemoryVNextCatalog }, { recallMemoryVNextLocal }] = await Promise.all([
|
|
8384
|
-
import("./store-
|
|
8385
|
-
import("./localRecall-
|
|
6562
|
+
import("./store-Z53ICFL3.js"),
|
|
6563
|
+
import("./localRecall-BDYKXB46.js")
|
|
8386
6564
|
]);
|
|
8387
6565
|
const catalog = await loadMemoryVNextCatalog(ctx.db, ctx.principal);
|
|
8388
6566
|
const hits = recallMemoryVNextLocal({
|
|
@@ -8432,7 +6610,7 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
8432
6610
|
for (let i = ordered.length - 1; i >= 0; i -= 1) {
|
|
8433
6611
|
if (isTombstoneRecord2(ordered[i])) ordered.splice(i, 1);
|
|
8434
6612
|
}
|
|
8435
|
-
const { buildMemoryOverlay, DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET } = await import("./overlay-
|
|
6613
|
+
const { buildMemoryOverlay, DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET } = await import("./overlay-BBQZXGYI.js");
|
|
8436
6614
|
const promptBlock = buildMemoryOverlay(ordered, {
|
|
8437
6615
|
maxTokens: DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET
|
|
8438
6616
|
});
|
|
@@ -8442,7 +6620,7 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
8442
6620
|
const ctx = await localMemoryContext();
|
|
8443
6621
|
if (!ctx) return false;
|
|
8444
6622
|
const [{ putMemoryEntityVNext, putMemoryStateVNext, putMemoryEvidenceVNext }, { buildLegacyMemoryEvidence }] = await Promise.all([
|
|
8445
|
-
import("./store-
|
|
6623
|
+
import("./store-Z53ICFL3.js"),
|
|
8446
6624
|
import("./legacyMigration-TF4SYJCZ.js")
|
|
8447
6625
|
]);
|
|
8448
6626
|
const contentKey = `mem-${shortHash(
|
|
@@ -8495,7 +6673,7 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
8495
6673
|
const retireLocalMemory = async (filter) => {
|
|
8496
6674
|
const ctx = await localMemoryContext();
|
|
8497
6675
|
if (!ctx) return { retired: 0, localOnlyRetired: 0, skippedRemoteMiss: 0 };
|
|
8498
|
-
const { loadMemoryVNextCatalog, retireMemoryStateVNext } = await import("./store-
|
|
6676
|
+
const { loadMemoryVNextCatalog, retireMemoryStateVNext } = await import("./store-Z53ICFL3.js");
|
|
8499
6677
|
const catalog = await loadMemoryVNextCatalog(ctx.db, ctx.principal);
|
|
8500
6678
|
if (catalog.states.length === 0) {
|
|
8501
6679
|
return { retired: 0, localOnlyRetired: 0, skippedRemoteMiss: 0 };
|
|
@@ -8734,8 +6912,44 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
8734
6912
|
};
|
|
8735
6913
|
}
|
|
8736
6914
|
|
|
6915
|
+
// packages/cli/client/childRunImages.ts
|
|
6916
|
+
import { isAbsolute } from "node:path";
|
|
6917
|
+
function validateChildImagePaths(value) {
|
|
6918
|
+
if (value === void 0) return [];
|
|
6919
|
+
if (!Array.isArray(value) || value.length < 1 || value.length > MAX_TOOL_IMAGES_PER_REQUEST || value.some((path) => typeof path !== "string" || !isAbsolute(path) || path.includes("\0"))) {
|
|
6920
|
+
throw new Error("image_input_invalid: expected 1\u20134 absolute local image paths");
|
|
6921
|
+
}
|
|
6922
|
+
return value;
|
|
6923
|
+
}
|
|
6924
|
+
async function validateChildImages(paths) {
|
|
6925
|
+
let total = 0;
|
|
6926
|
+
const urls = [];
|
|
6927
|
+
for (let index = 0; index < paths.length; index++) {
|
|
6928
|
+
try {
|
|
6929
|
+
const result = await readLocalImage(paths[index]);
|
|
6930
|
+
const image = result.images?.[0];
|
|
6931
|
+
if (!image) throw new Error();
|
|
6932
|
+
total += image.dataBase64.length;
|
|
6933
|
+
if (total > MAX_TOOL_IMAGE_BASE64_BYTES_PER_REQUEST) throw new Error();
|
|
6934
|
+
urls.push(`data:${image.mimeType};base64,${image.dataBase64}`);
|
|
6935
|
+
} catch (error) {
|
|
6936
|
+
const code = error?.code;
|
|
6937
|
+
const reason = code === "ENOENT" ? "not found" : code === "EACCES" || code === "EPERM" ? "not accessible" : "invalid type/content or exceeds image budget";
|
|
6938
|
+
throw new Error(`image_input_invalid: image ${index + 1} unreadable (${reason})`);
|
|
6939
|
+
}
|
|
6940
|
+
}
|
|
6941
|
+
return urls;
|
|
6942
|
+
}
|
|
6943
|
+
async function normalizeCliRunImages(inputs, normalizeRemote) {
|
|
6944
|
+
const local = inputs.filter((input) => !/^(https?:|data:|file:)/i.test(input));
|
|
6945
|
+
if (local.length > MAX_TOOL_IMAGES_PER_REQUEST) throw new Error("image_input_invalid: expected at most 4 local images");
|
|
6946
|
+
const urls = await validateChildImages(local);
|
|
6947
|
+
let index = 0;
|
|
6948
|
+
return inputs.map((input) => /^(https?:|data:|file:)/i.test(input) ? normalizeRemote(input) : urls[index++]);
|
|
6949
|
+
}
|
|
6950
|
+
|
|
8737
6951
|
// packages/cli/agentRunArgs.ts
|
|
8738
|
-
import { readFileSync
|
|
6952
|
+
import { readFileSync } from "node:fs";
|
|
8739
6953
|
import { isAbsolute as isAbsolute2 } from "node:path";
|
|
8740
6954
|
function readFlagValue(args, flag) {
|
|
8741
6955
|
const index = args.indexOf(flag);
|
|
@@ -8877,7 +7091,7 @@ function parseAgentRunArgs(args, options = {}) {
|
|
|
8877
7091
|
const agentKey = rawAgentKey ? resolveCliAgentKeyInput(rawAgentKey) : void 0;
|
|
8878
7092
|
const explicitMsg = readFlagValue(args, "--msg");
|
|
8879
7093
|
const msgFile = readFlagValue(args, "--msg-file");
|
|
8880
|
-
const fileMessage = msgFile ? (options.readTextFile ?? ((path) =>
|
|
7094
|
+
const fileMessage = msgFile ? (options.readTextFile ?? ((path) => readFileSync(path, "utf8")))(msgFile) : void 0;
|
|
8881
7095
|
const rawMessage = explicitMsg ?? fileMessage ?? positional.slice(isNoLoginRunShorthand ? 0 : 1).join(" ");
|
|
8882
7096
|
if (!agentKey || !rawMessage.trim()) return null;
|
|
8883
7097
|
const message = rawMessage.trim();
|
|
@@ -9043,8 +7257,8 @@ function parseAgentRunArgs(args, options = {}) {
|
|
|
9043
7257
|
}
|
|
9044
7258
|
|
|
9045
7259
|
// packages/cli/client/cliAgentRunToolExecutors.ts
|
|
9046
|
-
import { join as
|
|
9047
|
-
import { randomUUID as
|
|
7260
|
+
import { join as join3, resolve as resolve3 } from "node:path";
|
|
7261
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
9048
7262
|
import * as nodeFs2 from "node:fs";
|
|
9049
7263
|
|
|
9050
7264
|
// packages/agent-runtime/waitForRunTerminal.ts
|
|
@@ -9107,7 +7321,7 @@ function waitForRunTerminal(args) {
|
|
|
9107
7321
|
}
|
|
9108
7322
|
|
|
9109
7323
|
// packages/cli/client/cliAgentRunToolExecutors.ts
|
|
9110
|
-
import { existsSync as
|
|
7324
|
+
import { existsSync as existsSync3, readFileSync as readFileSync4 } from "node:fs";
|
|
9111
7325
|
|
|
9112
7326
|
// packages/cli/client/agentRunSnapshot.ts
|
|
9113
7327
|
function readString(value) {
|
|
@@ -9353,24 +7567,24 @@ function deriveAgentRunTodoStatus(input) {
|
|
|
9353
7567
|
}
|
|
9354
7568
|
|
|
9355
7569
|
// packages/cli/client/fileSystemStores.ts
|
|
9356
|
-
import { existsSync
|
|
7570
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
9357
7571
|
import { homedir as nodeHomedir } from "node:os";
|
|
9358
|
-
import { dirname as
|
|
7572
|
+
import { dirname as dirname2, join as join2 } from "node:path";
|
|
9359
7573
|
var nodeFs = {
|
|
9360
|
-
mkdirSync
|
|
9361
|
-
writeFileSync
|
|
9362
|
-
readFileSync:
|
|
9363
|
-
existsSync
|
|
7574
|
+
mkdirSync,
|
|
7575
|
+
writeFileSync,
|
|
7576
|
+
readFileSync: readFileSync2,
|
|
7577
|
+
existsSync: existsSync2
|
|
9364
7578
|
};
|
|
9365
|
-
function resolveNoloHome(env,
|
|
7579
|
+
function resolveNoloHome(env, homedir2) {
|
|
9366
7580
|
const custom = env?.NOLO_HOME;
|
|
9367
7581
|
if (custom && custom.trim()) return custom.trim();
|
|
9368
7582
|
const ambient = process.env.NOLO_HOME?.trim();
|
|
9369
7583
|
if (ambient) return ambient;
|
|
9370
|
-
return
|
|
7584
|
+
return join2(homedir2(), ".nolo");
|
|
9371
7585
|
}
|
|
9372
|
-
function ensureDir(
|
|
9373
|
-
fs.mkdirSync(
|
|
7586
|
+
function ensureDir(dir, fs) {
|
|
7587
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
9374
7588
|
}
|
|
9375
7589
|
function readJson(path, fs) {
|
|
9376
7590
|
if (!fs.existsSync(path)) return void 0;
|
|
@@ -9386,11 +7600,11 @@ function writeJson(path, data, fs) {
|
|
|
9386
7600
|
}
|
|
9387
7601
|
function createFileSystemTodoStore(opts = {}) {
|
|
9388
7602
|
const env = opts.env ?? process.env;
|
|
9389
|
-
const
|
|
7603
|
+
const homedir2 = opts.homedir ?? nodeHomedir;
|
|
9390
7604
|
const fs = opts.fs ?? nodeFs;
|
|
9391
|
-
const noloHome = resolveNoloHome(env,
|
|
9392
|
-
const filePath = opts.filePath ??
|
|
9393
|
-
const oldFilePath =
|
|
7605
|
+
const noloHome = resolveNoloHome(env, homedir2);
|
|
7606
|
+
const filePath = opts.filePath ?? join2(noloHome, "agent_run_todos.json");
|
|
7607
|
+
const oldFilePath = join2(noloHome, "todos.json");
|
|
9394
7608
|
const loadMap = () => {
|
|
9395
7609
|
if (!opts.filePath && !fs.existsSync(filePath) && fs.existsSync(oldFilePath)) {
|
|
9396
7610
|
const oldData = readJson(oldFilePath, fs);
|
|
@@ -9415,7 +7629,7 @@ function createFileSystemTodoStore(opts = {}) {
|
|
|
9415
7629
|
}
|
|
9416
7630
|
}
|
|
9417
7631
|
}
|
|
9418
|
-
ensureDir(
|
|
7632
|
+
ensureDir(dirname2(filePath), fs);
|
|
9419
7633
|
writeJson(filePath, { todos: [...map2.values()] }, fs);
|
|
9420
7634
|
return map2;
|
|
9421
7635
|
}
|
|
@@ -9429,7 +7643,7 @@ function createFileSystemTodoStore(opts = {}) {
|
|
|
9429
7643
|
return map;
|
|
9430
7644
|
};
|
|
9431
7645
|
const persist = (map) => {
|
|
9432
|
-
ensureDir(
|
|
7646
|
+
ensureDir(dirname2(filePath), fs);
|
|
9433
7647
|
writeJson(filePath, { todos: [...map.values()] }, fs);
|
|
9434
7648
|
};
|
|
9435
7649
|
return {
|
|
@@ -9460,13 +7674,13 @@ function createFileSystemTodoStore(opts = {}) {
|
|
|
9460
7674
|
}
|
|
9461
7675
|
|
|
9462
7676
|
// packages/cli/client/instaboxRunConfig.ts
|
|
9463
|
-
import { lstatSync
|
|
9464
|
-
import { isAbsolute as isAbsolute3, normalize, resolve as
|
|
7677
|
+
import { lstatSync, readFileSync as readFileSync3, realpathSync as realpathSync2 } from "node:fs";
|
|
7678
|
+
import { isAbsolute as isAbsolute3, normalize, resolve as resolve2 } from "node:path";
|
|
9465
7679
|
|
|
9466
7680
|
// packages/cli/client/localInstaboxWorkspaceDelivery.ts
|
|
9467
|
-
import { constants
|
|
9468
|
-
import { open
|
|
9469
|
-
import { createHash as
|
|
7681
|
+
import { constants } from "node:fs";
|
|
7682
|
+
import { open, realpath } from "node:fs/promises";
|
|
7683
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
9470
7684
|
|
|
9471
7685
|
// packages/agent-runtime/instaboxBackend.ts
|
|
9472
7686
|
var INSTABOX_BACKEND_ID = "instabox";
|
|
@@ -9640,7 +7854,7 @@ var InstaboxBackend = class {
|
|
|
9640
7854
|
...rawBody === void 0 ? {} : { body: rawBody }
|
|
9641
7855
|
});
|
|
9642
7856
|
});
|
|
9643
|
-
this.#sleep = options.sleepImpl ?? ((ms) => new Promise((
|
|
7857
|
+
this.#sleep = options.sleepImpl ?? ((ms) => new Promise((resolve7) => setTimeout(resolve7, ms)));
|
|
9644
7858
|
this.#machineTimeoutSeconds = options.machineTimeoutSeconds ?? 1800;
|
|
9645
7859
|
this.#createTimeoutMs = options.createTimeoutMs ?? 18e4;
|
|
9646
7860
|
this.#deleteTimeoutMs = options.deleteTimeoutMs ?? 12e4;
|
|
@@ -9669,15 +7883,15 @@ var InstaboxBackend = class {
|
|
|
9669
7883
|
* 成功时刻(不采信 202 响应时间,那是「已受理」不是「可用」)。
|
|
9670
7884
|
*/
|
|
9671
7885
|
async prepare(ticket) {
|
|
9672
|
-
const
|
|
7886
|
+
const context = {};
|
|
9673
7887
|
try {
|
|
9674
|
-
return await this.#prepare(ticket,
|
|
7888
|
+
return await this.#prepare(ticket, context);
|
|
9675
7889
|
} catch (error) {
|
|
9676
|
-
if (
|
|
7890
|
+
if (context.record) throw this.#withRecovery(error, context.record);
|
|
9677
7891
|
throw error;
|
|
9678
7892
|
}
|
|
9679
7893
|
}
|
|
9680
|
-
async #prepare(ticket,
|
|
7894
|
+
async #prepare(ticket, context) {
|
|
9681
7895
|
if (ticket.version !== 1 || !ticket.ticketId || !ticket.grantId) {
|
|
9682
7896
|
throw new InstaboxBackendError("instabox_invalid_ticket");
|
|
9683
7897
|
}
|
|
@@ -9711,7 +7925,7 @@ var InstaboxBackend = class {
|
|
|
9711
7925
|
const expectedSpec = this.#freeOrgObservation.allowedSpecs.find(
|
|
9712
7926
|
(s) => s.vcpus === plan.vcpus && s.memMiB === plan.memMiB
|
|
9713
7927
|
);
|
|
9714
|
-
|
|
7928
|
+
context.record = {
|
|
9715
7929
|
version: 1,
|
|
9716
7930
|
recordId: crypto.randomUUID(),
|
|
9717
7931
|
revision: 0,
|
|
@@ -9732,7 +7946,7 @@ var InstaboxBackend = class {
|
|
|
9732
7946
|
},
|
|
9733
7947
|
stop: { intent: false, accepted: false }
|
|
9734
7948
|
};
|
|
9735
|
-
await this.#saveRecovery(
|
|
7949
|
+
await this.#saveRecovery(context.record);
|
|
9736
7950
|
}
|
|
9737
7951
|
const created = await this.#call({
|
|
9738
7952
|
method: "POST",
|
|
@@ -9740,11 +7954,11 @@ var InstaboxBackend = class {
|
|
|
9740
7954
|
idempotencyKey: createKey2,
|
|
9741
7955
|
body: createBody
|
|
9742
7956
|
});
|
|
9743
|
-
if (
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
if (isSuccess(created.status))
|
|
9747
|
-
await this.#saveRecovery(
|
|
7957
|
+
if (context.record) {
|
|
7958
|
+
context.record.machineId = readString2(asRecord(created.payload)?.machineId) ?? void 0;
|
|
7959
|
+
context.record.createOperationId = readString2(asRecord(created.payload)?.id) ?? void 0;
|
|
7960
|
+
if (isSuccess(created.status)) context.record.create.state = "responded";
|
|
7961
|
+
await this.#saveRecovery(context.record);
|
|
9748
7962
|
}
|
|
9749
7963
|
if (!isSuccess(created.status)) {
|
|
9750
7964
|
const upstreamCode = extractInstaboxErrorCode(created.payload);
|
|
@@ -9864,7 +8078,7 @@ var InstaboxBackend = class {
|
|
|
9864
8078
|
const usageBaselineRunningMs = baseline === null ? null : Math.round(baseline.runningSeconds * 1e3);
|
|
9865
8079
|
const leaseId = `${machineId}:${ticket.ticketId}`;
|
|
9866
8080
|
this.#leases.set(leaseId, {
|
|
9867
|
-
recovery:
|
|
8081
|
+
recovery: context.record,
|
|
9868
8082
|
machineId,
|
|
9869
8083
|
ticketId: ticket.ticketId,
|
|
9870
8084
|
grantId: ticket.grantId,
|
|
@@ -9886,7 +8100,7 @@ var InstaboxBackend = class {
|
|
|
9886
8100
|
readableRoots: [...ticket.filesystem.readableRoots],
|
|
9887
8101
|
writableRoots: [...ticket.filesystem.writableRoots],
|
|
9888
8102
|
metadata: {
|
|
9889
|
-
...
|
|
8103
|
+
...context.record ? { recoveryRecordId: context.record.recordId } : {},
|
|
9890
8104
|
machineId,
|
|
9891
8105
|
machineName,
|
|
9892
8106
|
templateId: this.#templateId,
|
|
@@ -10158,8 +8372,8 @@ var InstaboxBackend = class {
|
|
|
10158
8372
|
try {
|
|
10159
8373
|
await Promise.race([
|
|
10160
8374
|
this.#sleep(Math.min(this.#pollIntervalMs, remaining())),
|
|
10161
|
-
new Promise((
|
|
10162
|
-
timer = setTimeout(
|
|
8375
|
+
new Promise((resolve7) => {
|
|
8376
|
+
timer = setTimeout(resolve7, remaining());
|
|
10163
8377
|
})
|
|
10164
8378
|
]);
|
|
10165
8379
|
} finally {
|
|
@@ -10461,8 +8675,8 @@ var InstaboxBackend = class {
|
|
|
10461
8675
|
try {
|
|
10462
8676
|
return await Promise.race([
|
|
10463
8677
|
this.#call({ ...args, timeoutMs: void 0 }),
|
|
10464
|
-
new Promise((
|
|
10465
|
-
timer = setTimeout(() =>
|
|
8678
|
+
new Promise((resolve7) => {
|
|
8679
|
+
timer = setTimeout(() => resolve7({ status: 0, payload: null, transportError: "Timeout" }), args.timeoutMs);
|
|
10466
8680
|
})
|
|
10467
8681
|
]);
|
|
10468
8682
|
} finally {
|
|
@@ -10600,7 +8814,7 @@ function extractInstaboxErrorCode(payload) {
|
|
|
10600
8814
|
|
|
10601
8815
|
// packages/cli/client/localInstaboxWorkspaceDelivery.ts
|
|
10602
8816
|
var SNAPSHOT_LIMITS = { files: 256, fileBytes: 8 * 1024 * 1024, totalBytes: 32 * 1024 * 1024, chunkBytes: 384 * 1024 };
|
|
10603
|
-
var hash = (bytes) =>
|
|
8817
|
+
var hash = (bytes) => createHash3("sha256").update(bytes).digest("hex");
|
|
10604
8818
|
var fail = (code) => {
|
|
10605
8819
|
throw new Error(`instabox_workspace_delivery:${code}`);
|
|
10606
8820
|
};
|
|
@@ -10645,10 +8859,10 @@ function validateInstaboxWorkspaceSelection(selection) {
|
|
|
10645
8859
|
async function readApprovedFiles(m) {
|
|
10646
8860
|
if (process.platform !== "linux") fail("secure_host_reader_unavailable");
|
|
10647
8861
|
if (await realpath(m.hostRoot) !== m.hostRoot) fail("host_root_not_canonical");
|
|
10648
|
-
let root = await
|
|
8862
|
+
let root = await open("/", constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
10649
8863
|
try {
|
|
10650
8864
|
for (const part of m.hostRoot.split("/").filter(Boolean)) {
|
|
10651
|
-
const next = await
|
|
8865
|
+
const next = await open(`/proc/self/fd/${root.fd}/${part}`, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
10652
8866
|
await root.close();
|
|
10653
8867
|
root = next;
|
|
10654
8868
|
}
|
|
@@ -10664,30 +8878,30 @@ async function readApprovedFiles(m) {
|
|
|
10664
8878
|
try {
|
|
10665
8879
|
const parts = entry.path.split("/");
|
|
10666
8880
|
for (const part of parts.slice(0, -1)) {
|
|
10667
|
-
const
|
|
10668
|
-
dirs.push(
|
|
10669
|
-
parent =
|
|
8881
|
+
const dir = await open(`/proc/self/fd/${parent.fd}/${part}`, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
8882
|
+
dirs.push(dir);
|
|
8883
|
+
parent = dir;
|
|
10670
8884
|
}
|
|
10671
|
-
const
|
|
8885
|
+
const file = await open(`/proc/self/fd/${parent.fd}/${parts.at(-1)}`, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
10672
8886
|
try {
|
|
10673
|
-
const before = await
|
|
8887
|
+
const before = await file.stat();
|
|
10674
8888
|
if (!before.isFile() || before.nlink !== 1 || before.size !== entry.sizeBytes) fail("file_metadata_mismatch");
|
|
10675
8889
|
const bytes = Buffer.alloc(entry.sizeBytes);
|
|
10676
8890
|
let offset = 0;
|
|
10677
8891
|
while (offset < bytes.length) {
|
|
10678
|
-
const { bytesRead } = await
|
|
8892
|
+
const { bytesRead } = await file.read(bytes, offset, bytes.length - offset, offset);
|
|
10679
8893
|
if (!bytesRead) fail("file_changed");
|
|
10680
8894
|
offset += bytesRead;
|
|
10681
8895
|
}
|
|
10682
|
-
const after = await
|
|
8896
|
+
const after = await file.stat();
|
|
10683
8897
|
if (after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs || hash(bytes) !== entry.sha256) fail("file_hash_mismatch");
|
|
10684
8898
|
if (/-----BEGIN [A-Z ]*PRIVATE KEY-----|(?:api[_-]?key|access[_-]?token|password)\s*[:=]\s*["']?[A-Za-z0-9_+\/-]{12,}/i.test(bytes.toString("utf8"))) fail("sensitive_content");
|
|
10685
8899
|
result.push(bytes);
|
|
10686
8900
|
} finally {
|
|
10687
|
-
await
|
|
8901
|
+
await file.close();
|
|
10688
8902
|
}
|
|
10689
8903
|
} finally {
|
|
10690
|
-
for (const
|
|
8904
|
+
for (const dir of dirs.reverse()) await dir.close();
|
|
10691
8905
|
}
|
|
10692
8906
|
}
|
|
10693
8907
|
} finally {
|
|
@@ -10822,14 +9036,14 @@ function resolveInstaboxRunConfigPath(options) {
|
|
|
10822
9036
|
fail2("missing_path", `\u73AF\u5883\u53D8\u91CF ${INSTABOX_RUN_CONFIG_ENV} \u672A\u8BBE\u7F6E\u6216\u4E3A\u7A7A`);
|
|
10823
9037
|
}
|
|
10824
9038
|
const runsDir = options?.runsDir ?? resolveRunsDir(env);
|
|
10825
|
-
const normalizedRunsDir = normalize(
|
|
10826
|
-
const resolvedTarget = isAbsolute3(explicitPath) ? normalize(explicitPath) : normalize(
|
|
9039
|
+
const normalizedRunsDir = normalize(resolve2(runsDir));
|
|
9040
|
+
const resolvedTarget = isAbsolute3(explicitPath) ? normalize(explicitPath) : normalize(resolve2(normalizedRunsDir, explicitPath));
|
|
10827
9041
|
if (resolvedTarget !== normalizedRunsDir && !resolvedTarget.startsWith(normalizedRunsDir.endsWith("/") ? normalizedRunsDir : `${normalizedRunsDir}/`)) {
|
|
10828
9042
|
fail2("path_traversal", `\u914D\u7F6E\u8DEF\u5F84 "${explicitPath}" \u8D8A\u51FA\u4E86\u9650\u5B9A\u7684 runs \u76EE\u5F55 "${normalizedRunsDir}"`);
|
|
10829
9043
|
}
|
|
10830
9044
|
let stats;
|
|
10831
9045
|
try {
|
|
10832
|
-
stats =
|
|
9046
|
+
stats = lstatSync(resolvedTarget);
|
|
10833
9047
|
} catch (err) {
|
|
10834
9048
|
fail2("file_unreadable", `\u914D\u7F6E\u6587\u4EF6\u4E0D\u53EF\u8BFB\u6216\u4E0D\u5B58\u5728: ${resolvedTarget}`);
|
|
10835
9049
|
}
|
|
@@ -10843,8 +9057,8 @@ function resolveInstaboxRunConfigPath(options) {
|
|
|
10843
9057
|
fail2("file_too_large", `\u914D\u7F6E\u6587\u4EF6\u5927\u5C0F (${stats.size} \u5B57\u8282) \u8D85\u8FC7\u4E0A\u9650 (${INSTABOX_RUN_CONFIG_MAX_BYTES} \u5B57\u8282)`);
|
|
10844
9058
|
}
|
|
10845
9059
|
try {
|
|
10846
|
-
const realTarget =
|
|
10847
|
-
const realRuns =
|
|
9060
|
+
const realTarget = realpathSync2(resolvedTarget);
|
|
9061
|
+
const realRuns = realpathSync2(normalizedRunsDir);
|
|
10848
9062
|
if (realTarget !== realRuns && !realTarget.startsWith(realRuns.endsWith("/") ? realRuns : `${realRuns}/`)) {
|
|
10849
9063
|
fail2("symlink_traversal", `\u914D\u7F6E\u771F\u5B9E\u8DEF\u5F84 "${realTarget}" \u8D8A\u51FA runs \u771F\u5B9E\u76EE\u5F55 "${realRuns}"`);
|
|
10850
9064
|
}
|
|
@@ -10856,7 +9070,7 @@ function loadInstaboxRunConfig(options) {
|
|
|
10856
9070
|
const { resolvedPath } = resolveInstaboxRunConfigPath(options);
|
|
10857
9071
|
let rawText;
|
|
10858
9072
|
try {
|
|
10859
|
-
rawText =
|
|
9073
|
+
rawText = readFileSync3(resolvedPath, "utf8");
|
|
10860
9074
|
} catch (err) {
|
|
10861
9075
|
fail2("file_read_failed", `\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6\u5931\u8D25: ${err instanceof Error ? err.message : String(err)}`);
|
|
10862
9076
|
}
|
|
@@ -11138,7 +9352,7 @@ var parseCallArgs = (call) => {
|
|
|
11138
9352
|
return {};
|
|
11139
9353
|
}
|
|
11140
9354
|
};
|
|
11141
|
-
var resolveFs = (deps) => deps.fs ?? { existsSync:
|
|
9355
|
+
var resolveFs = (deps) => deps.fs ?? { existsSync: existsSync3, readFileSync: readFileSync4 };
|
|
11142
9356
|
var probeRunCwd = (deps) => {
|
|
11143
9357
|
const fs = deps.fs;
|
|
11144
9358
|
const stat = fs?.statSync ?? nodeFs2.statSync;
|
|
@@ -11223,6 +9437,8 @@ function buildRunStatusPayload(reconciled, deps, opts = {}) {
|
|
|
11223
9437
|
// 排在 2000 字 lastAssistantText 之后的键会被整段省略,模型连路径都看
|
|
11224
9438
|
// 不到。挂在头部才能保证「结论在哪」永远可见。
|
|
11225
9439
|
...reconciled.resultFile ? { resultFile: reconciled.resultFile } : {},
|
|
9440
|
+
...reconciled.continuedFrom ? { continuedFrom: reconciled.continuedFrom } : {},
|
|
9441
|
+
...isAgentRunTerminalStatus(reconciled.status) ? { resultNote: "Process terminal status is not delivery, test, review, user acceptance or integration/release approval. lastAssistantText is a preview, not a complete report; read resultFile for current scope, blockers and evidence. Runtime acceptance contains observations only; unknown stays unknown. continuedFrom is lineage, not inherited approval." } : {},
|
|
11226
9442
|
...typeof reconciled.toolCallCount === "number" ? { toolCallCount: reconciled.toolCallCount } : {},
|
|
11227
9443
|
...reconciled.lastAssistantText ? { lastAssistantText: reconciled.lastAssistantText } : {},
|
|
11228
9444
|
// Non-ephemeral runs expose dialogId so the caller can read the
|
|
@@ -11294,6 +9510,8 @@ async function assertCredentialFanoutAllowed(deps, args) {
|
|
|
11294
9510
|
function createCliStartAgentRunExecutor(deps = {}) {
|
|
11295
9511
|
return async (call) => {
|
|
11296
9512
|
const args = parseCallArgs(call);
|
|
9513
|
+
const imagePaths = validateChildImagePaths(args.imagePaths);
|
|
9514
|
+
if (imagePaths.length && args.runtimeKey !== "local") throw new Error("image_backend_unsupported: imagePaths requires explicit host-local runtimeKey=local");
|
|
11297
9515
|
const continueDialogId = normalizeContinueDialogId(args.continueDialogId);
|
|
11298
9516
|
const continuedRecord = continueDialogId ? await deps.dialogExistsForCurrentUser?.(continueDialogId) : void 0;
|
|
11299
9517
|
if (continueDialogId && !continuedRecord) {
|
|
@@ -11312,13 +9530,13 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
11312
9530
|
if (previousRecord && previousCacheHitRatio === void 0 && previousRecord.resultFile) {
|
|
11313
9531
|
try {
|
|
11314
9532
|
const fs = deps.fs ?? nodeFs2;
|
|
11315
|
-
const runsDir =
|
|
11316
|
-
const expected =
|
|
11317
|
-
if (previousRecord.runId.includes("/") || previousRecord.runId.includes("\\") ||
|
|
9533
|
+
const runsDir = resolve3(resolveRunsDir(deps.env, deps.homedir));
|
|
9534
|
+
const expected = resolve3(runsDir, `${previousRecord.runId}.result.md`);
|
|
9535
|
+
if (previousRecord.runId.includes("/") || previousRecord.runId.includes("\\") || resolve3(previousRecord.resultFile) !== expected || !fs.realpathSync || !fs.lstatSync) throw new Error("Unverified result path");
|
|
11318
9536
|
const stat = fs.lstatSync(expected);
|
|
11319
9537
|
if (!stat.isFile() || stat.isSymbolicLink()) throw new Error("Non-regular result file");
|
|
11320
9538
|
const canonicalDir = String(fs.realpathSync(runsDir));
|
|
11321
|
-
if (String(fs.realpathSync(expected)) !==
|
|
9539
|
+
if (String(fs.realpathSync(expected)) !== join3(canonicalDir, `${previousRecord.runId}.result.md`)) throw new Error("Result escapes runs directory");
|
|
11322
9540
|
if ((deps.platform ?? process.platform) !== "linux" || !fs.fstatSync || !fs.readSync || !fs.closeSync || !nodeFs2.constants.O_NOFOLLOW || !nodeFs2.constants.O_DIRECTORY) throw new Error("FD proof unavailable");
|
|
11323
9541
|
let dirFd;
|
|
11324
9542
|
let resultFd;
|
|
@@ -11327,7 +9545,7 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
11327
9545
|
dirFd = fs.openSync(runsDir, nodeFs2.constants.O_RDONLY | nodeFs2.constants.O_DIRECTORY | nodeFs2.constants.O_NOFOLLOW);
|
|
11328
9546
|
if (!fs.fstatSync(dirFd).isDirectory() || String(fs.realpathSync(`/proc/self/fd/${dirFd}`)) !== canonicalDir) throw new Error("Unverified directory fd");
|
|
11329
9547
|
resultFd = fs.openSync(`/proc/self/fd/${dirFd}/${previousRecord.runId}.result.md`, nodeFs2.constants.O_RDONLY | nodeFs2.constants.O_NOFOLLOW | nodeFs2.constants.O_NONBLOCK);
|
|
11330
|
-
if (!fs.fstatSync(resultFd).isFile() || String(fs.realpathSync(`/proc/self/fd/${resultFd}`)) !==
|
|
9548
|
+
if (!fs.fstatSync(resultFd).isFile() || String(fs.realpathSync(`/proc/self/fd/${resultFd}`)) !== join3(canonicalDir, `${previousRecord.runId}.result.md`)) throw new Error("Unverified result fd");
|
|
11331
9549
|
const bytes = Buffer.alloc(16 * 1024);
|
|
11332
9550
|
let offset = 0;
|
|
11333
9551
|
while (offset < bytes.length) {
|
|
@@ -11411,6 +9629,15 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
11411
9629
|
selectedModel = await deps.resolveAgentModel?.(agentKey);
|
|
11412
9630
|
} catch {
|
|
11413
9631
|
}
|
|
9632
|
+
if (imagePaths.length) {
|
|
9633
|
+
let imageSupport = false;
|
|
9634
|
+
try {
|
|
9635
|
+
imageSupport = await deps.resolveAgentImageSupport?.(agentKey) === true;
|
|
9636
|
+
} catch {
|
|
9637
|
+
}
|
|
9638
|
+
if (!imageSupport) throw new Error("image_model_unsupported: child model image capability is unsupported or unknown");
|
|
9639
|
+
await validateChildImages(imagePaths);
|
|
9640
|
+
}
|
|
11414
9641
|
const selectionCheck = assertDispatchSelectionAdmission({
|
|
11415
9642
|
dimension: args.dimension,
|
|
11416
9643
|
difficulty: args.difficulty,
|
|
@@ -11432,10 +9659,10 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
11432
9659
|
const manifest = typeof args.instaboxManifest === "string" ? args.instaboxManifest.trim() : "";
|
|
11433
9660
|
if (workspace === "snapshot" && !manifest) throw new Error("instaboxWorkspace=snapshot \u5FC5\u987B\u63D0\u4F9B instaboxManifest");
|
|
11434
9661
|
if (workspace === "empty" && args.instaboxManifest !== void 0) throw new Error("instaboxWorkspace=empty \u4E0D\u5F97\u63D0\u4F9B instaboxManifest");
|
|
11435
|
-
const artifactDir = args.instaboxArtifactDir ??
|
|
9662
|
+
const artifactDir = args.instaboxArtifactDir ?? join3(
|
|
11436
9663
|
resolveRunsDir(deps.env, deps.homedir),
|
|
11437
9664
|
"instabox-artifacts",
|
|
11438
|
-
|
|
9665
|
+
randomUUID3()
|
|
11439
9666
|
);
|
|
11440
9667
|
if (typeof artifactDir !== "string" || !artifactDir.startsWith("/") || artifactDir.includes("\0") || artifactDir.split("/").includes("..")) {
|
|
11441
9668
|
throw new Error("instaboxArtifactDir \u5FC5\u987B\u4E3A\u5408\u6CD5\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u5305\u542B .. \u6216\u7A7A\u5B57\u7B26");
|
|
@@ -11463,7 +9690,8 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
11463
9690
|
// 执行后端(默认 docker 沙盒;只读派发留宿主):唯一产出 `--runtime-key`
|
|
11464
9691
|
// 的地方,成对不变式在 buildCliLocalRuntimeForwardArgs 内机械断言。
|
|
11465
9692
|
...buildCliLocalRuntimeForwardArgs(dispatch),
|
|
11466
|
-
...instaboxArgs
|
|
9693
|
+
...instaboxArgs,
|
|
9694
|
+
...imagePaths.flatMap((path) => ["--image", path])
|
|
11467
9695
|
];
|
|
11468
9696
|
const agentName = await resolveAgentRunName(
|
|
11469
9697
|
agentKey,
|
|
@@ -11483,13 +9711,6 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
11483
9711
|
allowCredentialConcurrency: effectiveAllowCredentialConcurrency
|
|
11484
9712
|
});
|
|
11485
9713
|
const dodCommands = Array.isArray(args.dodCommands) ? args.dodCommands.filter((c) => typeof c === "string" && c.trim().length > 0).map((c) => c.trim()) : typeof args.dod === "string" && args.dod.trim().length > 0 ? [args.dod.trim()] : Array.isArray(args.dod) ? args.dod.filter((c) => typeof c === "string" && c.trim().length > 0).map((c) => c.trim()) : void 0;
|
|
11486
|
-
const candidateReview = deps.reviewDispatchContext ?? currentHostReviewDispatch();
|
|
11487
|
-
const reviewContext = matchesHostReviewDispatch(candidateReview, call, args) ? candidateReview : void 0;
|
|
11488
|
-
if (reviewContext) {
|
|
11489
|
-
if (continueDialogId || args.readOnly !== true) throw new Error("Typed review requires a fresh readOnly run");
|
|
11490
|
-
await validateHostReviewDispatch(reviewContext, deps.env ?? process.env, requestedCwd ?? deps.cwd ?? process.cwd());
|
|
11491
|
-
consumeHostReviewDispatch(reviewContext, deps.env ?? process.env);
|
|
11492
|
-
}
|
|
11493
9714
|
const childPolicy = parseAgentRunArgs(rawArgs, { readTextFile: () => message });
|
|
11494
9715
|
const { runId, batchId: resolvedBatchId } = await spawnLocalBackgroundRun(
|
|
11495
9716
|
{
|
|
@@ -11529,24 +9750,6 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
11529
9750
|
},
|
|
11530
9751
|
{ ...deps, shellApprovalHost: deps.shellApprovalHostForAgent ? await deps.shellApprovalHostForAgent(agentKey) : deps.shellApprovalHost }
|
|
11531
9752
|
);
|
|
11532
|
-
if (reviewContext) {
|
|
11533
|
-
try {
|
|
11534
|
-
await bindHostReviewRun(reviewContext, runId, deps.env ?? process.env);
|
|
11535
|
-
} catch (error) {
|
|
11536
|
-
const record = readRunRecord(runId, deps);
|
|
11537
|
-
let stopped = false;
|
|
11538
|
-
try {
|
|
11539
|
-
if (record) stopped = await (deps.terminateRunProcess ?? terminateRunProcess)(record, "SIGTERM", deps);
|
|
11540
|
-
} catch {
|
|
11541
|
-
}
|
|
11542
|
-
if (stopped) finalizeRunRecord(runId, { status: "killed", note: "Host review binding failed; newly created run cancelled" }, deps);
|
|
11543
|
-
else {
|
|
11544
|
-
const latest = readRunRecord(runId, deps);
|
|
11545
|
-
if (latest) writeRunRecord({ ...latest, note: "Host review binding failed; cancellation unconfirmed" }, deps);
|
|
11546
|
-
}
|
|
11547
|
-
throw new Error(`Host review binding failed for ${runId}; cancellation=${stopped ? "confirmed" : "unconfirmed"}: ${error instanceof Error ? error.message : String(error)}`);
|
|
11548
|
-
}
|
|
11549
|
-
}
|
|
11550
9753
|
const displayName = resolveRunLabel({ agentName, agentKey, runId });
|
|
11551
9754
|
const labels = agentRunCardLabels();
|
|
11552
9755
|
const taskPreview = typeof args.task === "string" ? args.task.replace(/\s+/g, " ").trim().slice(0, TASK_PREVIEW_MAX) : "";
|
|
@@ -11934,7 +10137,7 @@ ${entry.text}`).join("\n\n");
|
|
|
11934
10137
|
const transferred = new Set(remainingEntries.map((entry) => entry.id));
|
|
11935
10138
|
const current = _readQueueEntriesLocked(queuePath, fs);
|
|
11936
10139
|
if (typeof fs.renameSync !== "function") throw new Error("atomic queue replacement requires renameSync");
|
|
11937
|
-
const pendingQueue = `${queuePath}.${
|
|
10140
|
+
const pendingQueue = `${queuePath}.${randomUUID3()}.tmp`;
|
|
11938
10141
|
fs.writeFileSync(pendingQueue, serializeQueueEntries(current.filter((entry) => !transferred.has(entry.id))), { encoding: "utf8", flag: "wx" });
|
|
11939
10142
|
fs.renameSync(pendingQueue, queuePath);
|
|
11940
10143
|
return result;
|
|
@@ -12215,6 +10418,7 @@ function pickAgentRunResolverDeps(args) {
|
|
|
12215
10418
|
return {
|
|
12216
10419
|
...args.resolveAgentCredentialGroup ? { resolveAgentCredentialGroup: args.resolveAgentCredentialGroup } : {},
|
|
12217
10420
|
...args.dialogExistsForCurrentUser ? { dialogExistsForCurrentUser: args.dialogExistsForCurrentUser } : {},
|
|
10421
|
+
...args.resolveAgentImageSupport ? { resolveAgentImageSupport: args.resolveAgentImageSupport } : {},
|
|
12218
10422
|
...args.resolveAgentModel ? { resolveAgentModel: args.resolveAgentModel } : {},
|
|
12219
10423
|
...args.resolveAgentDisplayName ? { resolveAgentDisplayName: args.resolveAgentDisplayName } : {},
|
|
12220
10424
|
...args.resolveAgentRuntimeBindingMachineId ? { resolveAgentRuntimeBindingMachineId: args.resolveAgentRuntimeBindingMachineId } : {},
|
|
@@ -12225,7 +10429,8 @@ function buildCliWorkspaceToolExecutors(args) {
|
|
|
12225
10429
|
return buildNoloWorkspaceCliToolExecutors({
|
|
12226
10430
|
cliEntrypoint: args.cliEntrypoint ?? process.argv[1] ?? "",
|
|
12227
10431
|
env: args.env,
|
|
12228
|
-
metadataKind: "cliWorkspaceTool"
|
|
10432
|
+
metadataKind: "cliWorkspaceTool",
|
|
10433
|
+
planningCaller: args.planningCaller
|
|
12229
10434
|
});
|
|
12230
10435
|
}
|
|
12231
10436
|
function buildLocalToolExecutors(args) {
|
|
@@ -12249,6 +10454,7 @@ function buildLocalToolExecutors(args) {
|
|
|
12249
10454
|
agentKey: args.agentKey
|
|
12250
10455
|
}),
|
|
12251
10456
|
...buildCliWorkspaceToolExecutors({
|
|
10457
|
+
planningCaller: args.planningCaller,
|
|
12252
10458
|
env: args.env,
|
|
12253
10459
|
cliEntrypoint: args.cliEntrypoint
|
|
12254
10460
|
}),
|
|
@@ -12392,18 +10598,8 @@ function buildLocalToolExecutors(args) {
|
|
|
12392
10598
|
metadata: { uiAskChoice: true }
|
|
12393
10599
|
};
|
|
12394
10600
|
},
|
|
12395
|
-
|
|
12396
|
-
|
|
12397
|
-
host: args.taskReviewHost,
|
|
12398
|
-
start: createCliStartAgentRunExecutor({
|
|
12399
|
-
shellApprovalHostForAgent: args.shellApprovalHostForAgent,
|
|
12400
|
-
...pickAgentRunResolverDeps(args),
|
|
12401
|
-
env: args.env,
|
|
12402
|
-
cliEntrypoint: args.cliEntrypoint,
|
|
12403
|
-
cwd: args.workspaceRoot,
|
|
12404
|
-
currentAgentKey: args.agentKey
|
|
12405
|
-
})
|
|
12406
|
-
}),
|
|
10601
|
+
// typed review executor(requestTaskReview / recordTaskReviewDecision)已移除;
|
|
10602
|
+
// 这两个工具随之从工具面消失(2026-11-15 owner 决定放弃 typed review)。
|
|
12407
10603
|
// agent-orchestration 能力包:startAgentRun / controlAgentRun 本地 --bg 执行器
|
|
12408
10604
|
// (复用 ~/.nolo/runs/ 注册表,MED-1 修复)。
|
|
12409
10605
|
startAgentRun: createCliStartAgentRunExecutor({
|
|
@@ -12414,7 +10610,6 @@ function buildLocalToolExecutors(args) {
|
|
|
12414
10610
|
env: args.env,
|
|
12415
10611
|
cliEntrypoint: args.cliEntrypoint,
|
|
12416
10612
|
cwd: args.workspaceRoot,
|
|
12417
|
-
reviewDispatchContext: args.reviewDispatchContext,
|
|
12418
10613
|
currentAgentKey: args.agentKey
|
|
12419
10614
|
}),
|
|
12420
10615
|
controlAgentRun: createCliControlAgentRunExecutor({
|
|
@@ -12600,8 +10795,8 @@ function createOAuthApiKeyRefResolver(options = {}) {
|
|
|
12600
10795
|
}
|
|
12601
10796
|
|
|
12602
10797
|
// packages/agent-runtime/localSandboxWorkload.ts
|
|
12603
|
-
import { existsSync as
|
|
12604
|
-
import { resolve as
|
|
10798
|
+
import { existsSync as existsSync4 } from "node:fs";
|
|
10799
|
+
import { resolve as resolve5 } from "node:path";
|
|
12605
10800
|
|
|
12606
10801
|
// packages/agent-runtime/executionChannel.ts
|
|
12607
10802
|
var EXECUTION_SHELL_TOOL = "execShell";
|
|
@@ -12680,19 +10875,19 @@ function createExecutionChannel(args) {
|
|
|
12680
10875
|
|
|
12681
10876
|
// packages/agent-runtime/linuxBubblewrapBackend.ts
|
|
12682
10877
|
import {
|
|
12683
|
-
closeSync
|
|
10878
|
+
closeSync,
|
|
12684
10879
|
constants as fsConstants,
|
|
12685
10880
|
fstatSync,
|
|
12686
10881
|
mkdtempSync,
|
|
12687
|
-
openSync
|
|
12688
|
-
readlinkSync
|
|
10882
|
+
openSync,
|
|
10883
|
+
readlinkSync,
|
|
12689
10884
|
rmdirSync,
|
|
12690
10885
|
unlinkSync,
|
|
12691
10886
|
writeSync
|
|
12692
10887
|
} from "node:fs";
|
|
12693
10888
|
import { access } from "node:fs/promises";
|
|
12694
10889
|
import { tmpdir } from "node:os";
|
|
12695
|
-
import { isAbsolute as isAbsolute4, join as
|
|
10890
|
+
import { isAbsolute as isAbsolute4, join as join4, relative, resolve as resolve4 } from "node:path";
|
|
12696
10891
|
|
|
12697
10892
|
// packages/agent-runtime/linuxSandboxSeccomp.ts
|
|
12698
10893
|
var AUDIT_ARCH_X86_64 = 3221225534;
|
|
@@ -12785,45 +10980,45 @@ var MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
|
12785
10980
|
var PSEUDO_FS = ["/proc", "/sys", "/dev", "/run"];
|
|
12786
10981
|
var SANDBOX_MOUNTS = ["/", "/usr", "/bin", "/lib", "/lib64", "/tmp"];
|
|
12787
10982
|
var inside = (parent, child) => {
|
|
12788
|
-
const rel =
|
|
10983
|
+
const rel = relative(parent, child);
|
|
12789
10984
|
return rel === "" || rel !== ".." && !rel.startsWith("../") && !isAbsolute4(rel);
|
|
12790
10985
|
};
|
|
12791
10986
|
function openRootHandle(path) {
|
|
12792
10987
|
if (typeof path !== "string" || !isAbsolute4(path) || path.includes("\0")) {
|
|
12793
10988
|
throw new Error("Sandbox root must be absolute");
|
|
12794
10989
|
}
|
|
12795
|
-
const expected =
|
|
10990
|
+
const expected = resolve4(path);
|
|
12796
10991
|
if (SANDBOX_MOUNTS.includes(expected) || PSEUDO_FS.some((reserved) => inside(reserved, expected))) {
|
|
12797
10992
|
throw new Error("Sandbox root overlaps a reserved sandbox/pseudo filesystem path");
|
|
12798
10993
|
}
|
|
12799
10994
|
let fd;
|
|
12800
10995
|
try {
|
|
12801
|
-
fd =
|
|
10996
|
+
fd = openSync(expected, fsConstants.O_RDONLY | fsConstants.O_DIRECTORY | fsConstants.O_NOFOLLOW);
|
|
12802
10997
|
} catch {
|
|
12803
10998
|
throw new Error("Sandbox root must be an existing directory without symlinks");
|
|
12804
10999
|
}
|
|
12805
11000
|
try {
|
|
12806
|
-
if (
|
|
11001
|
+
if (readlinkSync(`/proc/self/fd/${fd}`) !== expected) {
|
|
12807
11002
|
throw new Error("Sandbox root cannot contain symlinks");
|
|
12808
11003
|
}
|
|
12809
11004
|
const st = fstatSync(fd);
|
|
12810
11005
|
if (!st.isDirectory()) throw new Error("Sandbox root must be a directory");
|
|
12811
11006
|
return { fd, identity: { path: expected, dev: st.dev, ino: st.ino } };
|
|
12812
11007
|
} catch (error) {
|
|
12813
|
-
|
|
11008
|
+
closeSync(fd);
|
|
12814
11009
|
throw error;
|
|
12815
11010
|
}
|
|
12816
11011
|
}
|
|
12817
11012
|
var SECCOMP_TEMP_DIR_PREFIX = "nolo-bwrap-seccomp-";
|
|
12818
11013
|
function openSeccompFd(program) {
|
|
12819
|
-
const
|
|
12820
|
-
const
|
|
11014
|
+
const dir = mkdtempSync(join4(tmpdir(), SECCOMP_TEMP_DIR_PREFIX));
|
|
11015
|
+
const file = join4(dir, "filter.bpf");
|
|
12821
11016
|
let writer = -1;
|
|
12822
11017
|
let reader = -1;
|
|
12823
11018
|
try {
|
|
12824
|
-
writer =
|
|
11019
|
+
writer = openSync(file, fsConstants.O_WRONLY | fsConstants.O_CREAT | fsConstants.O_EXCL | fsConstants.O_NOFOLLOW, 384);
|
|
12825
11020
|
if (writeSync(writer, program) !== program.byteLength) throw new Error("Short seccomp write");
|
|
12826
|
-
reader =
|
|
11021
|
+
reader = openSync(file, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW);
|
|
12827
11022
|
const w = fstatSync(writer);
|
|
12828
11023
|
const r = fstatSync(reader);
|
|
12829
11024
|
if (w.ino !== r.ino || w.dev !== r.dev || r.size !== program.byteLength) {
|
|
@@ -12831,29 +11026,29 @@ function openSeccompFd(program) {
|
|
|
12831
11026
|
}
|
|
12832
11027
|
return reader;
|
|
12833
11028
|
} catch (error) {
|
|
12834
|
-
if (reader >= 0)
|
|
11029
|
+
if (reader >= 0) closeSync(reader);
|
|
12835
11030
|
throw new Error(`Cannot prepare seccomp policy; refusing sandbox (${error.message})`);
|
|
12836
11031
|
} finally {
|
|
12837
|
-
if (writer >= 0)
|
|
11032
|
+
if (writer >= 0) closeSync(writer);
|
|
12838
11033
|
try {
|
|
12839
|
-
unlinkSync(
|
|
11034
|
+
unlinkSync(file);
|
|
12840
11035
|
} catch {
|
|
12841
11036
|
}
|
|
12842
11037
|
try {
|
|
12843
|
-
rmdirSync(
|
|
11038
|
+
rmdirSync(dir);
|
|
12844
11039
|
} catch {
|
|
12845
11040
|
}
|
|
12846
11041
|
}
|
|
12847
11042
|
}
|
|
12848
11043
|
function identifyRoot(path) {
|
|
12849
11044
|
const { fd, identity } = openRootHandle(path);
|
|
12850
|
-
|
|
11045
|
+
closeSync(fd);
|
|
12851
11046
|
return identity;
|
|
12852
11047
|
}
|
|
12853
11048
|
function reopenAuthorizedRoot(expected) {
|
|
12854
11049
|
const { fd, identity } = openRootHandle(expected.path);
|
|
12855
11050
|
if (identity.dev !== expected.dev || identity.ino !== expected.ino) {
|
|
12856
|
-
|
|
11051
|
+
closeSync(fd);
|
|
12857
11052
|
throw new Error("Sandbox root identity changed since prepare");
|
|
12858
11053
|
}
|
|
12859
11054
|
return fd;
|
|
@@ -12975,7 +11170,7 @@ var LinuxBubblewrapBackend = class {
|
|
|
12975
11170
|
if (request.timeoutMs !== void 0 && (!Number.isFinite(request.timeoutMs) || request.timeoutMs <= 0)) {
|
|
12976
11171
|
throw new Error("Sandbox timeout must be finite and positive");
|
|
12977
11172
|
}
|
|
12978
|
-
if (request.cwd && !active.writable.some(({ path: root }) => isAbsolute4(request.cwd) && inside(root,
|
|
11173
|
+
if (request.cwd && !active.writable.some(({ path: root }) => isAbsolute4(request.cwd) && inside(root, resolve4(request.cwd)))) {
|
|
12979
11174
|
throw new Error("Command cwd outside writable sandbox roots");
|
|
12980
11175
|
}
|
|
12981
11176
|
if (!validateConfiguredRootExecutionLease(active.ticket, active.lease)) {
|
|
@@ -12987,7 +11182,7 @@ var LinuxBubblewrapBackend = class {
|
|
|
12987
11182
|
for (const root of [...active.readable, ...active.writable]) rootFds.push(reopenAuthorizedRoot(root));
|
|
12988
11183
|
rootFds.push(openSeccompFd(active.seccomp));
|
|
12989
11184
|
} catch (error) {
|
|
12990
|
-
for (const fd of rootFds)
|
|
11185
|
+
for (const fd of rootFds) closeSync(fd);
|
|
12991
11186
|
throw error;
|
|
12992
11187
|
}
|
|
12993
11188
|
const seccompChildFd = 3 + active.readable.length + active.writable.length;
|
|
@@ -13016,10 +11211,10 @@ var LinuxBubblewrapBackend = class {
|
|
|
13016
11211
|
"--tmpfs",
|
|
13017
11212
|
"/tmp"
|
|
13018
11213
|
];
|
|
13019
|
-
for (const
|
|
11214
|
+
for (const dir of ["/bin", "/lib", "/lib64"]) {
|
|
13020
11215
|
try {
|
|
13021
|
-
await access(
|
|
13022
|
-
args.push("--ro-bind",
|
|
11216
|
+
await access(dir);
|
|
11217
|
+
args.push("--ro-bind", dir, dir);
|
|
13023
11218
|
} catch {
|
|
13024
11219
|
}
|
|
13025
11220
|
}
|
|
@@ -13035,7 +11230,7 @@ var LinuxBubblewrapBackend = class {
|
|
|
13035
11230
|
env: { PATH: "/usr/bin:/bin" }
|
|
13036
11231
|
});
|
|
13037
11232
|
} finally {
|
|
13038
|
-
for (const fd of rootFds)
|
|
11233
|
+
for (const fd of rootFds) closeSync(fd);
|
|
13039
11234
|
}
|
|
13040
11235
|
active.running.add(processHandle);
|
|
13041
11236
|
onEvent?.({ type: "started", executionId, at: Date.now() });
|
|
@@ -13132,7 +11327,7 @@ async function createLocalSandboxWorkload(args) {
|
|
|
13132
11327
|
const envRoots = typeof env.NOLO_LOCAL_SANDBOX_ROOTS === "string" ? env.NOLO_LOCAL_SANDBOX_ROOTS.split(":").map((entry) => entry.trim()) : [];
|
|
13133
11328
|
const readableRoots = normalizeRoots(
|
|
13134
11329
|
args.readableRoots && args.readableRoots.length > 0 ? args.readableRoots : [...DEFAULT_SANDBOX_READABLE_ROOTS, ...envRoots]
|
|
13135
|
-
).filter((root) => !FORBIDDEN_EXTRA_ROOTS.has(
|
|
11330
|
+
).filter((root) => !FORBIDDEN_EXTRA_ROOTS.has(resolve5(root)));
|
|
13136
11331
|
const backend = args.backend ?? new LinuxBubblewrapBackend();
|
|
13137
11332
|
const ticket = {
|
|
13138
11333
|
version: 1,
|
|
@@ -13180,7 +11375,7 @@ async function createLocalSandboxWorkload(args) {
|
|
|
13180
11375
|
if (canonicalToolName(toolName) !== EXECUTION_SHELL_TOOL) return null;
|
|
13181
11376
|
const callArgs = toolArgs ?? {};
|
|
13182
11377
|
const command = typeof callArgs.command === "string" ? callArgs.command : "";
|
|
13183
|
-
const mountedBins = readableRoots.map((root) => `${root}/bin`).filter((
|
|
11378
|
+
const mountedBins = readableRoots.map((root) => `${root}/bin`).filter((dir) => existsSync4(dir));
|
|
13184
11379
|
const sandboxPath = [
|
|
13185
11380
|
...mountedBins,
|
|
13186
11381
|
process.env.PATH ?? "/usr/local/bin:/usr/bin:/bin"
|
|
@@ -13715,10 +11910,10 @@ async function applyDockerWorkspaceDelivery(runtime, selection) {
|
|
|
13715
11910
|
|
|
13716
11911
|
// packages/cli/client/localWorkspaceArchive.ts
|
|
13717
11912
|
import { spawnSync } from "node:child_process";
|
|
13718
|
-
import { mkdtempSync as mkdtempSync2, statSync as statSync2, writeFileSync as
|
|
11913
|
+
import { mkdtempSync as mkdtempSync2, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
13719
11914
|
import { rm } from "node:fs/promises";
|
|
13720
11915
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
13721
|
-
import { join as
|
|
11916
|
+
import { join as join5 } from "node:path";
|
|
13722
11917
|
var runHostCommand = (argv, { cwd }) => {
|
|
13723
11918
|
const result = spawnSync(argv[0], argv.slice(1), {
|
|
13724
11919
|
cwd,
|
|
@@ -13778,11 +11973,11 @@ function prepareHostWorkspaceDelivery(args) {
|
|
|
13778
11973
|
`\u5DE5\u4F5C\u533A\u6587\u4EF6\u6570 ${tracked.length} \u8D85\u8FC7\u4E0A\u9650 ${MAX_DELIVERY_FILE_COUNT}\uFF1A\u7591\u4F3C\u628A node_modules / \u6784\u5EFA\u4EA7\u7269\u6253\u8FDB\u4E86\u5F52\u6863\uFF08\u5F52\u6863\u53EA\u53D6 git ls-files\uFF09\u3002`
|
|
13779
11974
|
);
|
|
13780
11975
|
}
|
|
13781
|
-
const stagingDir = mkdtempSync2(
|
|
11976
|
+
const stagingDir = mkdtempSync2(join5(args.tmpDir ?? tmpdir2(), "nolo-workspace-delivery-"));
|
|
13782
11977
|
const stamp = `${process.pid}-${Date.now()}`;
|
|
13783
|
-
const archivePath =
|
|
13784
|
-
const bundlePath =
|
|
13785
|
-
const listPath =
|
|
11978
|
+
const archivePath = join5(stagingDir, `workspace-${stamp}.tar.gz`);
|
|
11979
|
+
const bundlePath = join5(stagingDir, `workspace-${stamp}.bundle`);
|
|
11980
|
+
const listPath = join5(stagingDir, `filelist-${stamp}.z`);
|
|
13786
11981
|
const removeFile = args.removeFile ?? (async (filePath) => {
|
|
13787
11982
|
await rm(filePath, { force: true });
|
|
13788
11983
|
});
|
|
@@ -13844,7 +12039,7 @@ function prepareHostWorkspaceDelivery(args) {
|
|
|
13844
12039
|
fallbackReason = bundled.reason;
|
|
13845
12040
|
}
|
|
13846
12041
|
try {
|
|
13847
|
-
|
|
12042
|
+
writeFileSync2(listPath, listed.stdout, "utf8");
|
|
13848
12043
|
const tarred = run(
|
|
13849
12044
|
["tar", "-czf", archivePath, "-C", root, "--null", "-T", listPath],
|
|
13850
12045
|
{ cwd: root }
|
|
@@ -14026,8 +12221,8 @@ async function createLocalDockerWorkload(args) {
|
|
|
14026
12221
|
}
|
|
14027
12222
|
const createLifecycle = args.createLifecycle ?? (async () => {
|
|
14028
12223
|
const [{ DockerWorkloadLifecycle, createDockerBindingAuthorizer }, accounts] = await Promise.all([
|
|
14029
|
-
import("./workloadLifecycle-
|
|
14030
|
-
import("./accountResolver-
|
|
12224
|
+
import("./workloadLifecycle-HFJIN5IZ.js"),
|
|
12225
|
+
import("./accountResolver-QETKNC7T.js")
|
|
14031
12226
|
]);
|
|
14032
12227
|
const resolveAccount = args.resolveAccount ?? accounts.createDockerAccountResolver({
|
|
14033
12228
|
env: args.env,
|
|
@@ -14122,28 +12317,28 @@ async function createLocalDockerWorkload(args) {
|
|
|
14122
12317
|
};
|
|
14123
12318
|
let rejectReady = () => {
|
|
14124
12319
|
};
|
|
14125
|
-
const ready = new Promise((
|
|
14126
|
-
resolveReady =
|
|
12320
|
+
const ready = new Promise((resolve7, reject) => {
|
|
12321
|
+
resolveReady = resolve7;
|
|
14127
12322
|
rejectReady = reject;
|
|
14128
12323
|
});
|
|
14129
12324
|
let releaseRun = () => {
|
|
14130
12325
|
};
|
|
14131
|
-
const releaseGate = new Promise((
|
|
14132
|
-
releaseRun =
|
|
12326
|
+
const releaseGate = new Promise((resolve7) => {
|
|
12327
|
+
releaseRun = resolve7;
|
|
14133
12328
|
});
|
|
14134
12329
|
const waitForReleaseOrAbort = () => {
|
|
14135
12330
|
const signal = args.signal;
|
|
14136
12331
|
if (!signal) return releaseGate;
|
|
14137
12332
|
if (signal.aborted) return Promise.resolve();
|
|
14138
|
-
return new Promise((
|
|
12333
|
+
return new Promise((resolve7) => {
|
|
14139
12334
|
const onAbort = () => {
|
|
14140
12335
|
signal.removeEventListener("abort", onAbort);
|
|
14141
|
-
|
|
12336
|
+
resolve7();
|
|
14142
12337
|
};
|
|
14143
12338
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
14144
12339
|
void releaseGate.then(() => {
|
|
14145
12340
|
signal.removeEventListener("abort", onAbort);
|
|
14146
|
-
|
|
12341
|
+
resolve7();
|
|
14147
12342
|
});
|
|
14148
12343
|
});
|
|
14149
12344
|
};
|
|
@@ -14468,7 +12663,7 @@ function buildInstaboxBridgeBootstrapScript(root, probeId) {
|
|
|
14468
12663
|
return `printf 'NOLO_BRIDGE_REASON=helper_source_invalid
|
|
14469
12664
|
'`;
|
|
14470
12665
|
}
|
|
14471
|
-
const
|
|
12666
|
+
const dir = INSTABOX_HELPER_PATH.slice(0, INSTABOX_HELPER_PATH.lastIndexOf("/"));
|
|
14472
12667
|
return [
|
|
14473
12668
|
`root=${posixQuote(root)}`,
|
|
14474
12669
|
`mkdir -p "$root" 2>/dev/null || true`,
|
|
@@ -14478,7 +12673,7 @@ function buildInstaboxBridgeBootstrapScript(root, probeId) {
|
|
|
14478
12673
|
`for cand in bun node; do if command -v "$cand" >/dev/null 2>&1; then rt="$cand"; break; fi; done`,
|
|
14479
12674
|
`printf 'NOLO_BRIDGE_RUNTIME=%s\\n' "\${rt:-none}"`,
|
|
14480
12675
|
`if [ -z "$rt" ]; then printf 'NOLO_BRIDGE_REASON=runtime_missing\\n'; exit 0; fi`,
|
|
14481
|
-
`mkdir -p ${posixQuote(
|
|
12676
|
+
`mkdir -p ${posixQuote(dir)} 2>/dev/null || true`,
|
|
14482
12677
|
`if ! printf %s ${posixQuote(helperPayload)} | base64 -d > ${posixQuote(INSTABOX_HELPER_PATH)}; then printf 'NOLO_BRIDGE_REASON=upload_failed\\n'; exit 0; fi`,
|
|
14483
12678
|
`chmod 0644 ${posixQuote(INSTABOX_HELPER_PATH)} 2>/dev/null || true`,
|
|
14484
12679
|
// 探针文件名带本次 run 的唯一 id:**只创建自己的**,绝不覆盖/删除同名既有文件
|
|
@@ -14635,14 +12830,14 @@ function describeInstaboxBridgeUnavailable(bridge) {
|
|
|
14635
12830
|
}
|
|
14636
12831
|
|
|
14637
12832
|
// packages/cli/client/localInstaboxWorkspaceRecovery.ts
|
|
14638
|
-
import { constants as
|
|
14639
|
-
import { open as
|
|
14640
|
-
import { createHash as
|
|
12833
|
+
import { constants as constants3 } from "node:fs";
|
|
12834
|
+
import { open as open2 } from "node:fs/promises";
|
|
12835
|
+
import { createHash as createHash5, randomUUID as randomUUID4 } from "node:crypto";
|
|
14641
12836
|
|
|
14642
12837
|
// packages/agent-runtime/artifactStore.ts
|
|
14643
|
-
import { createHash as
|
|
12838
|
+
import { createHash as createHash4, createHmac } from "node:crypto";
|
|
14644
12839
|
import { mkdir, readFile, unlink, writeFile } from "node:fs/promises";
|
|
14645
|
-
import { dirname as
|
|
12840
|
+
import { dirname as dirname3, resolve as resolve6, sep } from "node:path";
|
|
14646
12841
|
var ArtifactStoreError = class extends Error {
|
|
14647
12842
|
code;
|
|
14648
12843
|
key;
|
|
@@ -14692,12 +12887,12 @@ function isNotFoundError(error) {
|
|
|
14692
12887
|
return error?.code === "ENOENT";
|
|
14693
12888
|
}
|
|
14694
12889
|
function createLocalArtifactStore(options) {
|
|
14695
|
-
const root =
|
|
12890
|
+
const root = resolve6(options.rootDir);
|
|
14696
12891
|
const now = options.now ?? Date.now;
|
|
14697
|
-
const
|
|
12892
|
+
const pathFor = (key) => {
|
|
14698
12893
|
assertArtifactKey(key);
|
|
14699
|
-
const target =
|
|
14700
|
-
if (target !== root && !target.startsWith(`${root}${
|
|
12894
|
+
const target = resolve6(root, key);
|
|
12895
|
+
if (target !== root && !target.startsWith(`${root}${sep}`)) {
|
|
14701
12896
|
throw new ArtifactStoreError(
|
|
14702
12897
|
"invalid_key",
|
|
14703
12898
|
`artifact key \u89E3\u6790\u540E\u8D8A\u51FA rootDir\uFF1A${describeKey(key)}`,
|
|
@@ -14709,9 +12904,9 @@ function createLocalArtifactStore(options) {
|
|
|
14709
12904
|
return {
|
|
14710
12905
|
async put(key, data, opts) {
|
|
14711
12906
|
const bytes = toBytes(data);
|
|
14712
|
-
const target =
|
|
12907
|
+
const target = pathFor(key);
|
|
14713
12908
|
try {
|
|
14714
|
-
await mkdir(
|
|
12909
|
+
await mkdir(dirname3(target), { recursive: true });
|
|
14715
12910
|
await writeFile(target, bytes);
|
|
14716
12911
|
} catch (error) {
|
|
14717
12912
|
if (error instanceof ArtifactStoreError) throw error;
|
|
@@ -14729,7 +12924,7 @@ function createLocalArtifactStore(options) {
|
|
|
14729
12924
|
};
|
|
14730
12925
|
},
|
|
14731
12926
|
async get(key) {
|
|
14732
|
-
const target =
|
|
12927
|
+
const target = pathFor(key);
|
|
14733
12928
|
try {
|
|
14734
12929
|
return new Uint8Array(await readFile(target));
|
|
14735
12930
|
} catch (error) {
|
|
@@ -14748,7 +12943,7 @@ function createLocalArtifactStore(options) {
|
|
|
14748
12943
|
}
|
|
14749
12944
|
},
|
|
14750
12945
|
async delete(key) {
|
|
14751
|
-
const target =
|
|
12946
|
+
const target = pathFor(key);
|
|
14752
12947
|
try {
|
|
14753
12948
|
await unlink(target);
|
|
14754
12949
|
} catch (error) {
|
|
@@ -14767,12 +12962,12 @@ function createLocalArtifactStore(options) {
|
|
|
14767
12962
|
};
|
|
14768
12963
|
}
|
|
14769
12964
|
function sha256Hex2(data) {
|
|
14770
|
-
return
|
|
12965
|
+
return createHash4("sha256").update(data).digest("hex");
|
|
14771
12966
|
}
|
|
14772
12967
|
var EMPTY_SHA256 = sha256Hex2("");
|
|
14773
12968
|
|
|
14774
12969
|
// packages/cli/client/localInstaboxWorkspaceRecovery.ts
|
|
14775
|
-
var
|
|
12970
|
+
var sha = (b) => createHash5("sha256").update(b).digest("hex");
|
|
14776
12971
|
function fail4(code) {
|
|
14777
12972
|
throw Object.assign(new Error(`instabox_workspace_recovery:${code}; cleanup_pending`), { code: "instabox_cleanup_pending", cleanupPending: true });
|
|
14778
12973
|
}
|
|
@@ -14815,14 +13010,14 @@ async function captureInstaboxBaseline(args) {
|
|
|
14815
13010
|
return fail4("baseline_failed");
|
|
14816
13011
|
}
|
|
14817
13012
|
};
|
|
14818
|
-
let
|
|
13013
|
+
let digest = "", count2 = -1;
|
|
14819
13014
|
const files = [];
|
|
14820
13015
|
const skipped = [];
|
|
14821
13016
|
do {
|
|
14822
13017
|
const r = await call({ op: "scan", offset: files.length });
|
|
14823
|
-
if (!/^[a-f0-9]{64}$/.test(r.manifestSha256) || !Number.isInteger(r.total) || r.total < 0 || r.total > SNAPSHOT_LIMITS.files || !Array.isArray(r.files) || r.files.length !== Math.min(8, r.total - files.length) || r.skipped !== void 0 && (!Array.isArray(r.skipped) || r.skipped.length > SNAPSHOT_LIMITS.files) || count2 !== -1 && (count2 !== r.total ||
|
|
13018
|
+
if (!/^[a-f0-9]{64}$/.test(r.manifestSha256) || !Number.isInteger(r.total) || r.total < 0 || r.total > SNAPSHOT_LIMITS.files || !Array.isArray(r.files) || r.files.length !== Math.min(8, r.total - files.length) || r.skipped !== void 0 && (!Array.isArray(r.skipped) || r.skipped.length > SNAPSHOT_LIMITS.files) || count2 !== -1 && (count2 !== r.total || digest !== r.manifestSha256)) fail4("baseline_failed");
|
|
14824
13019
|
count2 = r.total;
|
|
14825
|
-
|
|
13020
|
+
digest = r.manifestSha256;
|
|
14826
13021
|
files.push(...r.files);
|
|
14827
13022
|
if (Array.isArray(r.skipped)) {
|
|
14828
13023
|
for (const s of r.skipped) {
|
|
@@ -14837,8 +13032,8 @@ async function captureInstaboxBaseline(args) {
|
|
|
14837
13032
|
seen.add(f.path);
|
|
14838
13033
|
total += f.sizeBytes;
|
|
14839
13034
|
}
|
|
14840
|
-
if (total > SNAPSHOT_LIMITS.totalBytes ||
|
|
14841
|
-
return { files, digest
|
|
13035
|
+
if (total > SNAPSHOT_LIMITS.totalBytes || sha(JSON.stringify(files)) !== digest) fail4("baseline_failed");
|
|
13036
|
+
return { files, digest, skipped };
|
|
14842
13037
|
}
|
|
14843
13038
|
async function recoverInstaboxWorkspace(args) {
|
|
14844
13039
|
const policy = args.policy;
|
|
@@ -14853,14 +13048,14 @@ async function recoverInstaboxWorkspace(args) {
|
|
|
14853
13048
|
}
|
|
14854
13049
|
};
|
|
14855
13050
|
const scan = async () => {
|
|
14856
|
-
let
|
|
13051
|
+
let digest = "", count2 = -1;
|
|
14857
13052
|
const files = [];
|
|
14858
13053
|
const skipped = [];
|
|
14859
13054
|
do {
|
|
14860
13055
|
const r = await call({ op: "scan", offset: files.length });
|
|
14861
|
-
if (!/^[a-f0-9]{64}$/.test(r.manifestSha256) || !Number.isInteger(r.total) || r.total < 0 || r.total > SNAPSHOT_LIMITS.files || !Array.isArray(r.files) || r.files.length !== Math.min(8, r.total - files.length) || r.skipped !== void 0 && (!Array.isArray(r.skipped) || r.skipped.length > SNAPSHOT_LIMITS.files) || count2 !== -1 && (count2 !== r.total ||
|
|
13056
|
+
if (!/^[a-f0-9]{64}$/.test(r.manifestSha256) || !Number.isInteger(r.total) || r.total < 0 || r.total > SNAPSHOT_LIMITS.files || !Array.isArray(r.files) || r.files.length !== Math.min(8, r.total - files.length) || r.skipped !== void 0 && (!Array.isArray(r.skipped) || r.skipped.length > SNAPSHOT_LIMITS.files) || count2 !== -1 && (count2 !== r.total || digest !== r.manifestSha256)) fail4("manifest_changed");
|
|
14862
13057
|
count2 = r.total;
|
|
14863
|
-
|
|
13058
|
+
digest = r.manifestSha256;
|
|
14864
13059
|
files.push(...r.files);
|
|
14865
13060
|
if (Array.isArray(r.skipped)) {
|
|
14866
13061
|
for (const s of r.skipped) {
|
|
@@ -14875,11 +13070,11 @@ async function recoverInstaboxWorkspace(args) {
|
|
|
14875
13070
|
seen.add(f.path);
|
|
14876
13071
|
total += f.sizeBytes;
|
|
14877
13072
|
}
|
|
14878
|
-
if (total > SNAPSHOT_LIMITS.totalBytes ||
|
|
13073
|
+
if (total > SNAPSHOT_LIMITS.totalBytes || sha(JSON.stringify(files)) !== digest) fail4("manifest_mismatch");
|
|
14879
13074
|
for (const s of skipped) {
|
|
14880
13075
|
if (policy.allowedPaths.includes(s)) fail4("allowed_path_unreadable");
|
|
14881
13076
|
}
|
|
14882
|
-
return { files, digest
|
|
13077
|
+
return { files, digest, skipped };
|
|
14883
13078
|
};
|
|
14884
13079
|
await policy.quiesce();
|
|
14885
13080
|
const initial = await scan();
|
|
@@ -14899,12 +13094,12 @@ async function recoverInstaboxWorkspace(args) {
|
|
|
14899
13094
|
const r = await call({ op: "read", path: f.path, offset, manifestSha256: initial.digest });
|
|
14900
13095
|
if (typeof r.data !== "string" || !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(r.data)) fail4("invalid_chunk");
|
|
14901
13096
|
const b = Buffer.from(r.data, "base64");
|
|
14902
|
-
if (b.length !== Math.min(49152, f.sizeBytes - offset) ||
|
|
13097
|
+
if (b.length !== Math.min(49152, f.sizeBytes - offset) || sha(b) !== r.sha256) fail4("chunk_mismatch");
|
|
14903
13098
|
chunks.push(b);
|
|
14904
13099
|
offset += b.length;
|
|
14905
13100
|
}
|
|
14906
13101
|
const bytes2 = Buffer.concat(chunks);
|
|
14907
|
-
if (
|
|
13102
|
+
if (sha(bytes2) !== f.sha256 || sensitive(bytes2)) fail4("unsafe_content");
|
|
14908
13103
|
output.push({ path: f.path, data: bytes2.toString("base64") });
|
|
14909
13104
|
}
|
|
14910
13105
|
if ((await scan()).digest !== initial.digest) fail4("workspace_changed");
|
|
@@ -14919,37 +13114,37 @@ async function recoverInstaboxWorkspace(args) {
|
|
|
14919
13114
|
deletedPaths,
|
|
14920
13115
|
output
|
|
14921
13116
|
}));
|
|
14922
|
-
let root = await
|
|
13117
|
+
let root = await open2("/", constants3.O_RDONLY | constants3.O_DIRECTORY | constants3.O_NOFOLLOW);
|
|
14923
13118
|
try {
|
|
14924
13119
|
for (const part of policy.artifactRoot.split("/").filter(Boolean)) {
|
|
14925
13120
|
if (part === "." || part === "..") fail4("invalid_destination");
|
|
14926
|
-
const next = await
|
|
13121
|
+
const next = await open2(`/proc/self/fd/${root.fd}/${part}`, constants3.O_RDONLY | constants3.O_DIRECTORY | constants3.O_NOFOLLOW);
|
|
14927
13122
|
await root.close();
|
|
14928
13123
|
root = next;
|
|
14929
13124
|
}
|
|
14930
13125
|
const { mkdir: mkdir2, rename } = await import("node:fs/promises");
|
|
14931
|
-
const id = `instabox-${
|
|
13126
|
+
const id = `instabox-${randomUUID4()}`;
|
|
14932
13127
|
const namespace = `/proc/self/fd/${root.fd}/${id}`;
|
|
14933
13128
|
await mkdir2(namespace, { mode: 448 });
|
|
14934
|
-
const
|
|
13129
|
+
const dir = await open2(namespace, constants3.O_RDONLY | constants3.O_DIRECTORY | constants3.O_NOFOLLOW);
|
|
14935
13130
|
try {
|
|
14936
|
-
const prefix = `/proc/self/fd/${
|
|
14937
|
-
const
|
|
13131
|
+
const prefix = `/proc/self/fd/${dir.fd}`;
|
|
13132
|
+
const file = await open2(`${prefix}/snapshot.pending`, constants3.O_WRONLY | constants3.O_CREAT | constants3.O_EXCL | constants3.O_NOFOLLOW, 384);
|
|
14938
13133
|
try {
|
|
14939
|
-
await
|
|
14940
|
-
await
|
|
13134
|
+
await file.writeFile(bytes);
|
|
13135
|
+
await file.sync();
|
|
14941
13136
|
} finally {
|
|
14942
|
-
await
|
|
13137
|
+
await file.close();
|
|
14943
13138
|
}
|
|
14944
13139
|
await rename(`${prefix}/snapshot.pending`, `${prefix}/snapshot.json`);
|
|
14945
|
-
await
|
|
13140
|
+
await dir.sync();
|
|
14946
13141
|
await root.sync();
|
|
14947
13142
|
const stored = await createLocalArtifactStore({ rootDir: prefix }).get("snapshot.json");
|
|
14948
|
-
if (
|
|
13143
|
+
if (sha(stored) !== sha(bytes)) fail4("artifact_readback_mismatch");
|
|
14949
13144
|
if ((await scan()).digest !== initial.digest) fail4("workspace_changed_after_persist");
|
|
14950
|
-
return { artifact: { id: `${id}/snapshot.json`, sizeBytes: bytes.length, contentType: "application/json", createdAt: Date.now() }, sha256:
|
|
13145
|
+
return { artifact: { id: `${id}/snapshot.json`, sizeBytes: bytes.length, contentType: "application/json", createdAt: Date.now() }, sha256: sha(bytes), files: changed, deletedPaths };
|
|
14951
13146
|
} finally {
|
|
14952
|
-
await
|
|
13147
|
+
await dir.close();
|
|
14953
13148
|
}
|
|
14954
13149
|
} finally {
|
|
14955
13150
|
await root.close();
|
|
@@ -14960,13 +13155,13 @@ async function recoverInstaboxWorkspace(args) {
|
|
|
14960
13155
|
function sanitizeReleaseError(error) {
|
|
14961
13156
|
const raw = error instanceof Error ? error.message : String(error);
|
|
14962
13157
|
const sanitized = raw.replace(/(?:api[_-]?key|bearer|token|password|secret)[=:\s]+[A-Za-z0-9_\-\.]{8,}/gi, "[REDACTED]").replace(/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g, "[REDACTED]").slice(0, 500);
|
|
14963
|
-
const
|
|
13158
|
+
const safe = new Error(sanitized);
|
|
14964
13159
|
if (error instanceof Error) {
|
|
14965
|
-
|
|
14966
|
-
if (error.code)
|
|
14967
|
-
if (error.cleanupPending !== void 0)
|
|
13160
|
+
safe.name = error.name;
|
|
13161
|
+
if (error.code) safe.code = error.code;
|
|
13162
|
+
if (error.cleanupPending !== void 0) safe.cleanupPending = error.cleanupPending;
|
|
14968
13163
|
}
|
|
14969
|
-
return
|
|
13164
|
+
return safe;
|
|
14970
13165
|
}
|
|
14971
13166
|
var LOCAL_INSTABOX_BACKEND_ID = INSTABOX_BACKEND_ID;
|
|
14972
13167
|
function resolveInstaboxApiKey(env) {
|
|
@@ -15017,8 +13212,8 @@ async function prepareFileBridge(execDirect, root, probeId) {
|
|
|
15017
13212
|
return verdict.ready ? { root: pinned.root, runtime: pinned.runtime, ready: true, probeId, probePath: parsed.probePath } : { root: pinned.root, runtime: pinned.runtime, ready: false, reason: verdict.reason ?? "probe_failed", probeId, probePath: parsed.probePath };
|
|
15018
13213
|
}
|
|
15019
13214
|
function resolveInstaboxTemplateId(options) {
|
|
15020
|
-
const
|
|
15021
|
-
if (
|
|
13215
|
+
const explicit = options.templateId?.trim();
|
|
13216
|
+
if (explicit) return explicit;
|
|
15022
13217
|
const envOverride = options.env?.INSTABOX_TEMPLATE_ID?.trim();
|
|
15023
13218
|
if (envOverride) return envOverride;
|
|
15024
13219
|
const tier = options.orgTier?.trim().toLowerCase();
|
|
@@ -15277,8 +13472,8 @@ async function createLocalInstaboxWorkload(args) {
|
|
|
15277
13472
|
}
|
|
15278
13473
|
|
|
15279
13474
|
// packages/cli/client/localRunArtifactExport.ts
|
|
15280
|
-
import { mkdirSync as
|
|
15281
|
-
import { dirname as
|
|
13475
|
+
import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
13476
|
+
import { dirname as dirname4, join as join6 } from "node:path";
|
|
15282
13477
|
|
|
15283
13478
|
// packages/agent-runtime/runArtifactExport.ts
|
|
15284
13479
|
var RUN_DIFF_COMMAND = "git add -A && git diff --cached --binary";
|
|
@@ -15317,8 +13512,8 @@ var UNSAFE_WORKTREE_NAME = /[^A-Za-z0-9._-]+/g;
|
|
|
15317
13512
|
function worktreeArtifactName(path) {
|
|
15318
13513
|
const trimmed = String(path ?? "").replace(/[/\\]+$/, "");
|
|
15319
13514
|
const base = trimmed.split(/[/\\]/).pop() ?? "";
|
|
15320
|
-
const
|
|
15321
|
-
return
|
|
13515
|
+
const safe = base.replace(UNSAFE_WORKTREE_NAME, "-").replace(/^[-.]+|[-.]+$/g, "");
|
|
13516
|
+
return safe || "worktree";
|
|
15322
13517
|
}
|
|
15323
13518
|
function worktreeDiffArtifactKey(runId, name) {
|
|
15324
13519
|
return `runs/${runId}/worktrees/${name}.patch`;
|
|
@@ -15486,11 +13681,11 @@ function serializeRunArtifactAudit(record) {
|
|
|
15486
13681
|
// packages/cli/client/localRunArtifactExport.ts
|
|
15487
13682
|
function resolveRunArtifactsRootDir(runsDir) {
|
|
15488
13683
|
const normalized = runsDir.replace(/[/\\]+$/, "");
|
|
15489
|
-
return
|
|
13684
|
+
return join6(dirname4(normalized || runsDir), "artifacts");
|
|
15490
13685
|
}
|
|
15491
13686
|
function writeRunArtifactAudit(args) {
|
|
15492
|
-
const fs = args.fs ?? { mkdirSync:
|
|
15493
|
-
const path =
|
|
13687
|
+
const fs = args.fs ?? { mkdirSync: mkdirSync2, writeFileSync: writeFileSync3 };
|
|
13688
|
+
const path = join6(args.runsDir, `${args.record.runId}.artifacts.json`);
|
|
15494
13689
|
fs.mkdirSync?.(args.runsDir, { recursive: true });
|
|
15495
13690
|
fs.writeFileSync(path, serializeRunArtifactAudit(args.record));
|
|
15496
13691
|
return path;
|
|
@@ -15842,9 +14037,78 @@ function buildTokenDialogIndexOps(args) {
|
|
|
15842
14037
|
|
|
15843
14038
|
// packages/cli/client/localRuntimeDialog.ts
|
|
15844
14039
|
var import_format = __toESM(require_format(), 1);
|
|
15845
|
-
import { appendFileSync
|
|
15846
|
-
import { homedir
|
|
15847
|
-
import { join as
|
|
14040
|
+
import { appendFileSync, mkdirSync as mkdirSync3 } from "fs";
|
|
14041
|
+
import { homedir } from "os";
|
|
14042
|
+
import { join as join7 } from "path";
|
|
14043
|
+
|
|
14044
|
+
// packages/cli/client/cliCompletedTurnCapture.ts
|
|
14045
|
+
async function readCliCaptureSources(args) {
|
|
14046
|
+
if (args.input.result.stopReason !== "done" || args.input.result.error) return [];
|
|
14047
|
+
const explicitIds = args.input.cliCaptureUserMessageIds;
|
|
14048
|
+
const ids = [...new Set([
|
|
14049
|
+
...args.input.messages.filter((message) => message.role === "user").map((message) => message.cliMessageId),
|
|
14050
|
+
...Array.isArray(explicitIds) ? explicitIds : [],
|
|
14051
|
+
...args.persistedUserMessageIds ?? []
|
|
14052
|
+
].filter((id) => typeof id === "string" && /^[A-Za-z0-9_-]{1,128}$/.test(id)))];
|
|
14053
|
+
const sources = [];
|
|
14054
|
+
for (const id of ids) {
|
|
14055
|
+
const key = `dialog-${args.dialogId}-msg-${id}`;
|
|
14056
|
+
const record = await args.read(key);
|
|
14057
|
+
if (record?.id !== id || record?.dialogId !== args.dialogId || record?.userId !== args.userId || record?.role !== "user" || isTombstoneRecord(record) || typeof record?.content !== "string" || !record.content.trim() || typeof record?.createdAt !== "string" || !Number.isFinite(Date.parse(record.createdAt))) continue;
|
|
14058
|
+
sources.push({ type: "put", key, value: record });
|
|
14059
|
+
}
|
|
14060
|
+
return sources;
|
|
14061
|
+
}
|
|
14062
|
+
async function captureCliCompletedTurn(args) {
|
|
14063
|
+
if (args.input.result.stopReason !== "done" || args.input.result.error) {
|
|
14064
|
+
return [{ status: "skipped", reason: "turn_not_completed" }];
|
|
14065
|
+
}
|
|
14066
|
+
if (!args.sources.length) return [{ status: "deferred", reason: "missing_persisted_source" }];
|
|
14067
|
+
const serverUrl = resolveRuntimeServerUrl(args.env);
|
|
14068
|
+
if (!serverUrl) return [{ status: "deferred", reason: "server_not_configured" }];
|
|
14069
|
+
const authToken = resolveRuntimeAuthToken(args.env);
|
|
14070
|
+
if (!authToken) return [{ status: "deferred", reason: "not_authenticated" }];
|
|
14071
|
+
const results = [];
|
|
14072
|
+
for (const source of args.sources) {
|
|
14073
|
+
const userMessageId = source.value.id;
|
|
14074
|
+
try {
|
|
14075
|
+
const response = await fetchWithTransientRetry(
|
|
14076
|
+
args.fetchImpl,
|
|
14077
|
+
`${serverUrl}/api/memory/capture-turn`,
|
|
14078
|
+
{
|
|
14079
|
+
method: "POST",
|
|
14080
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${authToken}` },
|
|
14081
|
+
// The transitional validator requires nonempty userInput; native capture ignores it.
|
|
14082
|
+
// A short inert marker also avoids legacy text extraction on older servers.
|
|
14083
|
+
body: JSON.stringify({
|
|
14084
|
+
agentKey: args.input.agentKey,
|
|
14085
|
+
dialogId: args.dialogId,
|
|
14086
|
+
userMessageId,
|
|
14087
|
+
userInput: "native source"
|
|
14088
|
+
}),
|
|
14089
|
+
signal: AbortSignal.timeout(remoteDialogSyncTimeout())
|
|
14090
|
+
},
|
|
14091
|
+
{ retryableStatuses: /* @__PURE__ */ new Set([429, 502, 503]) }
|
|
14092
|
+
);
|
|
14093
|
+
if (!response.ok) {
|
|
14094
|
+
results.push({ status: "deferred", reason: `http_${response.status}`, userMessageId });
|
|
14095
|
+
continue;
|
|
14096
|
+
}
|
|
14097
|
+
const body = await response.json();
|
|
14098
|
+
const native = body?.protocol === "native" ? body.nativeCapture : null;
|
|
14099
|
+
if (!native || !["captured", "skipped"].includes(native.capture) || !["applied", "no_op", "deferred", "failed"].includes(native.formation)) {
|
|
14100
|
+
results.push({ status: "deferred", reason: "native_capture_unconfirmed", userMessageId });
|
|
14101
|
+
} else {
|
|
14102
|
+
results.push({ status: native.capture, reason: `formation_${native.formation}`, userMessageId });
|
|
14103
|
+
}
|
|
14104
|
+
} catch {
|
|
14105
|
+
results.push({ status: "deferred", reason: "transport_or_response_error", userMessageId });
|
|
14106
|
+
}
|
|
14107
|
+
}
|
|
14108
|
+
return results;
|
|
14109
|
+
}
|
|
14110
|
+
|
|
14111
|
+
// packages/cli/client/localRuntimeDialog.ts
|
|
15848
14112
|
var diagLog = {
|
|
15849
14113
|
warn: (msg) => getLogger("cli.localRuntimeDialog").warn(msg),
|
|
15850
14114
|
info: (msg) => getLogger("cli.localRuntimeDialog").info(msg)
|
|
@@ -15895,11 +14159,11 @@ function projectRawUsage(usage) {
|
|
|
15895
14159
|
function debugCaptureRawUsage(item) {
|
|
15896
14160
|
if (!process.env.NOLO_DEBUG_RAW_USAGE) return;
|
|
15897
14161
|
try {
|
|
15898
|
-
const noloHome = process.env.NOLO_HOME?.trim() ||
|
|
15899
|
-
const
|
|
15900
|
-
|
|
15901
|
-
|
|
15902
|
-
|
|
14162
|
+
const noloHome = process.env.NOLO_HOME?.trim() || join7(homedir(), ".nolo");
|
|
14163
|
+
const dir = join7(noloHome, "logs");
|
|
14164
|
+
mkdirSync3(dir, { recursive: true });
|
|
14165
|
+
appendFileSync(
|
|
14166
|
+
join7(dir, "raw-usage.jsonl"),
|
|
15903
14167
|
JSON.stringify({
|
|
15904
14168
|
ts: Date.now(),
|
|
15905
14169
|
model: item.model,
|
|
@@ -16142,6 +14406,16 @@ async function writeDialog(args) {
|
|
|
16142
14406
|
existingDialog,
|
|
16143
14407
|
cwd: args.cwd
|
|
16144
14408
|
});
|
|
14409
|
+
for (const id of plan.captureUserMessageIds) {
|
|
14410
|
+
const op = plan.ops.find((op2) => op2.value.id === id && op2.value.role === "user");
|
|
14411
|
+
const existing = await args.store.read(op.key, { remote: false });
|
|
14412
|
+
if (existing) {
|
|
14413
|
+
if (existing.id !== id || existing.dialogId !== plan.dialogId || existing.userId !== args.userId || existing.role !== "user" || JSON.stringify(existing.content) !== JSON.stringify(op.value.content)) {
|
|
14414
|
+
throw new Error("CLI persisted turn source conflict");
|
|
14415
|
+
}
|
|
14416
|
+
op.value = existing;
|
|
14417
|
+
}
|
|
14418
|
+
}
|
|
16145
14419
|
const lastInputTokens = extractLastProviderInputTokens(args.input) ?? (typeof existingDialog?.lastInputTokens === "number" && Number.isFinite(existingDialog.lastInputTokens) && existingDialog.lastInputTokens > 0 ? existingDialog.lastInputTokens : void 0);
|
|
16146
14420
|
if (typeof lastInputTokens === "number" && lastInputTokens > 0) {
|
|
16147
14421
|
const dialogOp = plan.ops.find(
|
|
@@ -16190,40 +14464,56 @@ async function writeDialog(args) {
|
|
|
16190
14464
|
diagLog.info(`perf writeDialog D:token-record (cumulative): ${ms}ms`);
|
|
16191
14465
|
}
|
|
16192
14466
|
const hasSubjectRefs = localTurnHasSubjectRefs(args.input);
|
|
16193
|
-
|
|
16194
|
-
|
|
16195
|
-
|
|
16196
|
-
|
|
16197
|
-
|
|
16198
|
-
|
|
16199
|
-
|
|
16200
|
-
|
|
16201
|
-
|
|
16202
|
-
|
|
16203
|
-
|
|
16204
|
-
|
|
16205
|
-
|
|
16206
|
-
|
|
16207
|
-
|
|
16208
|
-
|
|
16209
|
-
|
|
16210
|
-
}
|
|
16211
|
-
})();
|
|
16212
|
-
await remoteSyncPromise;
|
|
16213
|
-
} else {
|
|
16214
|
-
remoteSyncPromise = startOwnedDialogSync(args.fetchImpl, (fetchImpl) => syncLocalDialogEvidenceToRemote({
|
|
14467
|
+
let memoryCaptureResults = [];
|
|
14468
|
+
const reportCapture = (results) => {
|
|
14469
|
+
memoryCaptureResults = results;
|
|
14470
|
+
for (const result of results) {
|
|
14471
|
+
diagLog.info(`memory_capture ${result.status}: ${result.reason}`);
|
|
14472
|
+
}
|
|
14473
|
+
};
|
|
14474
|
+
const captureSources = await readCliCaptureSources({
|
|
14475
|
+
input: args.input,
|
|
14476
|
+
dialogId: plan.dialogId,
|
|
14477
|
+
userId: args.userId,
|
|
14478
|
+
persistedUserMessageIds: plan.captureUserMessageIds,
|
|
14479
|
+
read: (key) => args.store.read(key, { remote: false })
|
|
14480
|
+
}).catch(() => []);
|
|
14481
|
+
const syncAndCapture = async (fetchImpl) => {
|
|
14482
|
+
try {
|
|
14483
|
+
const syncResult = args.userId === "local" ? { attempted: false } : await syncLocalDialogEvidenceToRemote({
|
|
16215
14484
|
env: args.env,
|
|
16216
14485
|
fetchImpl,
|
|
16217
14486
|
input: args.input,
|
|
16218
|
-
ops: [...plan.ops, ...tokenOps],
|
|
14487
|
+
ops: [...plan.ops, ...tokenOps, ...captureSources],
|
|
14488
|
+
localStore: args.store,
|
|
16219
14489
|
output: args.output,
|
|
16220
14490
|
userId: args.userId
|
|
16221
|
-
})).catch((error) => {
|
|
16222
|
-
args.output?.write(`[nolo] Remote dialog evidence sync failed; class=${classifyDialogSyncFailure(error)}; local history retained; remote sync incomplete.
|
|
16223
|
-
`);
|
|
16224
14491
|
});
|
|
14492
|
+
if (!syncResult.attempted) {
|
|
14493
|
+
if (hasSubjectRefs) args.output?.write(
|
|
14494
|
+
"[nolo] Local dialog evidence is local-only; set NOLO_SERVER and AUTH_TOKEN to make subjectRefs remotely queryable.\n"
|
|
14495
|
+
);
|
|
14496
|
+
const result = args.input.result.stopReason !== "done" || args.input.result.error ? { status: "skipped", reason: "turn_not_completed" } : { status: "deferred", reason: !resolveRuntimeServerUrl(args.env) ? "server_not_configured" : args.userId === "local" || !resolveRuntimeAuthToken(args.env) ? "not_authenticated" : "remote_sync_unavailable" };
|
|
14497
|
+
reportCapture([result]);
|
|
14498
|
+
return;
|
|
14499
|
+
}
|
|
14500
|
+
reportCapture(await captureCliCompletedTurn({
|
|
14501
|
+
input: args.input,
|
|
14502
|
+
dialogId: plan.dialogId,
|
|
14503
|
+
sources: captureSources,
|
|
14504
|
+
env: args.env,
|
|
14505
|
+
fetchImpl
|
|
14506
|
+
}));
|
|
14507
|
+
} catch (error) {
|
|
14508
|
+
reportCapture([{ status: "deferred", reason: "remote_sync_failed" }]);
|
|
14509
|
+
throw error;
|
|
16225
14510
|
}
|
|
16226
|
-
}
|
|
14511
|
+
};
|
|
14512
|
+
const remoteSyncPromise = hasSubjectRefs ? syncAndCapture(args.fetchImpl) : startOwnedDialogSync(args.fetchImpl, syncAndCapture).catch((error) => {
|
|
14513
|
+
args.output?.write(`[nolo] Remote dialog evidence sync failed; class=${classifyDialogSyncFailure(error)}; local history retained; remote sync incomplete.
|
|
14514
|
+
`);
|
|
14515
|
+
});
|
|
14516
|
+
if (hasSubjectRefs) await remoteSyncPromise;
|
|
16227
14517
|
let titlePatchPromise;
|
|
16228
14518
|
if (titlePromise) {
|
|
16229
14519
|
const dialogKey = `dialog-${args.userId}-${plan.dialogId}`;
|
|
@@ -16251,7 +14541,9 @@ async function writeDialog(args) {
|
|
|
16251
14541
|
const ms = (performance.now() - __perfT0).toFixed(1);
|
|
16252
14542
|
diagLog.info(`perf writeDialog total (blocking): ${ms}ms`);
|
|
16253
14543
|
}
|
|
16254
|
-
return { dialogId: plan.dialogId, title: plan.title, titlePatchPromise, remoteSyncPromise
|
|
14544
|
+
return { dialogId: plan.dialogId, title: plan.title, titlePatchPromise, remoteSyncPromise, get memoryCaptureResults() {
|
|
14545
|
+
return memoryCaptureResults;
|
|
14546
|
+
} };
|
|
16255
14547
|
}
|
|
16256
14548
|
function resolveCliDialogRecordKey(userId, dialogId) {
|
|
16257
14549
|
if (dialogId.startsWith("dialog-") && !dialogId.includes("-msg-")) {
|
|
@@ -16571,6 +14863,14 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
16571
14863
|
const defaultCompactionSummary = createTuiSummaryLlmCaller(deps.env, { fetchImpl, platformPrimary: true });
|
|
16572
14864
|
const loopbackRequest = deps.loopbackRequest ?? (deps.fetchImpl ? void 0 : defaultLoopbackRequest);
|
|
16573
14865
|
const userId = resolveLocalUserId(deps.env);
|
|
14866
|
+
const resolveLiveImageSupport = createLiveImageSupportResolver(userId, async () => {
|
|
14867
|
+
const token = await createOAuthApiKeyRefResolver({
|
|
14868
|
+
migration: { enableLegacyMigration: true },
|
|
14869
|
+
localUserId: userId
|
|
14870
|
+
})("antigravity");
|
|
14871
|
+
if (!token) return {};
|
|
14872
|
+
return fetchAntigravityAvailableModels(fetchImpl, token);
|
|
14873
|
+
});
|
|
16574
14874
|
const localToolBudgets = parseLocalToolBudgets(deps.env);
|
|
16575
14875
|
const localToolUsage = /* @__PURE__ */ new Map();
|
|
16576
14876
|
const buildProviderOpenAiTools = deps.buildProviderOpenAiTools ?? buildOpenAiTools;
|
|
@@ -16738,15 +15038,15 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
16738
15038
|
const runId = asOptionalTrimmedString(deps.env?.NOLO_AGENT_RUN_ID) ?? "interactive";
|
|
16739
15039
|
emitRunIsolationNotice(fact, { runId });
|
|
16740
15040
|
try {
|
|
16741
|
-
const { writeFileSync:
|
|
16742
|
-
const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-
|
|
15041
|
+
const { writeFileSync: writeFileSync4, mkdirSync: mkdirSync4 } = await import("node:fs");
|
|
15042
|
+
const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-MBG4U6SL.js");
|
|
16743
15043
|
recordLocalRunExecutionIsolation({
|
|
16744
15044
|
runId,
|
|
16745
15045
|
runsDir: resolveRunsDir2(deps.env),
|
|
16746
15046
|
fact,
|
|
16747
15047
|
fs: {
|
|
16748
|
-
writeFileSync: (path, data) =>
|
|
16749
|
-
mkdirSync: (path, options) =>
|
|
15048
|
+
writeFileSync: (path, data) => writeFileSync4(path, data),
|
|
15049
|
+
mkdirSync: (path, options) => mkdirSync4(path, options)
|
|
16750
15050
|
}
|
|
16751
15051
|
});
|
|
16752
15052
|
getLogger("cli.localRuntimeAdapter").info(
|
|
@@ -16764,7 +15064,7 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
16764
15064
|
dockerWorkloadReleased = true;
|
|
16765
15065
|
dockerWorkloadLoad = null;
|
|
16766
15066
|
if (loaded) {
|
|
16767
|
-
const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-
|
|
15067
|
+
const { resolveRunsDir: resolveRunsDir2 } = await import("./agentRunControl-MBG4U6SL.js");
|
|
16768
15068
|
const exportRunDiff = deps.exportDockerRunDiffArtifact ?? exportDockerRunDiffArtifact;
|
|
16769
15069
|
const warn = (message) => process.stderr.write(`[nolo] ${message}
|
|
16770
15070
|
`);
|
|
@@ -16846,8 +15146,8 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
16846
15146
|
};
|
|
16847
15147
|
let runtimeToolExecutionLimits = {};
|
|
16848
15148
|
const skillPolicyFingerprint = (source) => JSON.stringify(Object.entries(resolveAgentSkillConfig(source)).sort(([a], [b]) => a.localeCompare(b)));
|
|
16849
|
-
let installedTaskReviewHost;
|
|
16850
15149
|
let reviewAgentConfig;
|
|
15150
|
+
let planningCaller = {};
|
|
16851
15151
|
const isCanonicalAutoReviewAdmitted = (visits) => {
|
|
16852
15152
|
const canonical = resolveBuiltinSkillEntry("auto-review");
|
|
16853
15153
|
if (!canonical || !visits) return false;
|
|
@@ -16855,36 +15155,7 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
16855
15155
|
(visit) => visit.dbKey === canonical.skillId && visit.meta?.skillConfig?.id === canonical.skillId
|
|
16856
15156
|
);
|
|
16857
15157
|
};
|
|
16858
|
-
const accountReviewScope = (dialogId, taskInstanceId) => ({
|
|
16859
|
-
taskId: `tui-local-alpha-v1-${createHash14("sha256").update(JSON.stringify([userId, dialogId, resolveReviewWorkspace(workspaceRoot), "local-alpha-v1", ...taskInstanceId ? [taskInstanceId] : []])).digest("hex")}`,
|
|
16860
|
-
dialogId,
|
|
16861
|
-
workspace: resolveReviewWorkspace(workspaceRoot),
|
|
16862
|
-
...taskInstanceId ? { taskInstanceId } : {}
|
|
16863
|
-
});
|
|
16864
|
-
const requireAccountReview = async (scope) => {
|
|
16865
|
-
if (!userId || userId === "local" || !scope.dialogId?.trim()) throw new Error("task_review_authenticated_user_missing");
|
|
16866
|
-
if (scope.taskId !== accountReviewScope(scope.dialogId, scope.taskInstanceId).taskId || resolveReviewWorkspace(scope.workspace) !== resolveReviewWorkspace(workspaceRoot)) throw new Error("task_review_user_scope_mismatch");
|
|
16867
|
-
const store = await getOrCreateSharedStore(deps);
|
|
16868
|
-
const dialog = await store.read(`dialog-${userId}-${scope.dialogId}`);
|
|
16869
|
-
if (dialog?.userId && dialog.userId !== userId) throw new Error("task_review_user_scope_mismatch");
|
|
16870
|
-
const settings = await store.read(createUserKey.settings(userId));
|
|
16871
|
-
const skills = await resolveUserSkillRuntime(reviewAgentConfig, settings && typeof settings === "object" ? settings : {});
|
|
16872
|
-
if (!isCanonicalAutoReviewAdmitted(skills.visits)) throw new Error("task_review_account_optin_required");
|
|
16873
|
-
};
|
|
16874
|
-
const authorizedReviewHost = () => {
|
|
16875
|
-
const host = installedTaskReviewHost ?? deps.taskReviewHost;
|
|
16876
|
-
if (!host) return void 0;
|
|
16877
|
-
return { ...host, authorize: async () => {
|
|
16878
|
-
await host.authorize();
|
|
16879
|
-
await requireAccountReview(host.scope);
|
|
16880
|
-
const task = readHostTask(hostTaskEventsRoot(deps.env), host.scope);
|
|
16881
|
-
if (task.authorization !== "active") throw new Error(`task_review_authorization_${task.authorization}`);
|
|
16882
|
-
const workspace = await collectHostTaskWorkspace(host.scope, deps.env);
|
|
16883
|
-
if (workspace.status !== "ready") throw new Error(`task_review_workspace_unavailable: ${workspace.reason}`);
|
|
16884
|
-
} };
|
|
16885
|
-
};
|
|
16886
15158
|
const buildCurrentToolExecutors = (agentConfig) => buildLocalToolExecutors({
|
|
16887
|
-
taskReviewHost: authorizedReviewHost(),
|
|
16888
15159
|
workspaceRoot,
|
|
16889
15160
|
sourceParentDialogId: deps.parentDialogId,
|
|
16890
15161
|
env: deps.env,
|
|
@@ -16908,6 +15179,10 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
16908
15179
|
const deleted = Boolean(rec?.deletedAt || rec?.deleted || rec?.isDeleted);
|
|
16909
15180
|
return !deleted && typeof rec?.name === "string" && rec.name.trim() ? rec.name.trim() : void 0;
|
|
16910
15181
|
},
|
|
15182
|
+
resolveAgentImageSupport: async (agentRef) => {
|
|
15183
|
+
const record = await readAgentFromStore({ agentRef, store: await getOrCreateSharedStore(deps), userId });
|
|
15184
|
+
return !!record && resolveAgentImageInputSupport(await resolveLiveImageSupport({ ...record, hasVision: record.hasVision ?? false }));
|
|
15185
|
+
},
|
|
16911
15186
|
resolveAgentModel,
|
|
16912
15187
|
dialogExistsForCurrentUser: async (dialogId) => {
|
|
16913
15188
|
const store = await getOrCreateSharedStore(deps);
|
|
@@ -16936,6 +15211,11 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
16936
15211
|
...deps.requestUserChoice ? { requestUserChoice: deps.requestUserChoice } : {},
|
|
16937
15212
|
...deps.pastedTextStore ? { pastedTextStore: deps.pastedTextStore } : {},
|
|
16938
15213
|
agentKey: agentConfig?.key,
|
|
15214
|
+
planningCaller: planningCaller = {
|
|
15215
|
+
agentKey: agentConfig?.key,
|
|
15216
|
+
effectiveModel: agentConfig?.model,
|
|
15217
|
+
runKind: deps.env.NOLO_AGENT_RUN_CHILD === "1" || agentConfig?.toolSurface?.runKind === "subtask" ? "subtask" : "interactive"
|
|
15218
|
+
},
|
|
16939
15219
|
agentSkillSource: agentConfig?.rawRecord,
|
|
16940
15220
|
...agentConfig ? { resolveAgentSkillSource: async () => {
|
|
16941
15221
|
const store = await getOrCreateSharedStore(deps);
|
|
@@ -17088,7 +15368,7 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
17088
15368
|
runtimeToolExecutionLimits = cached.runtimeToolExecutionLimits;
|
|
17089
15369
|
reviewAgentConfig = cached.agentConfig;
|
|
17090
15370
|
localToolExecutors = buildCurrentToolExecutors(cached.agentConfig);
|
|
17091
|
-
return cached.agentConfig;
|
|
15371
|
+
return resolveLiveImageSupport(cached.agentConfig);
|
|
17092
15372
|
}
|
|
17093
15373
|
}
|
|
17094
15374
|
const storedAgentConfig = await readAgentFromStore({
|
|
@@ -17174,7 +15454,7 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
17174
15454
|
runtimeToolExecutionLimits
|
|
17175
15455
|
});
|
|
17176
15456
|
}
|
|
17177
|
-
return exposedAgentConfig;
|
|
15457
|
+
return exposedAgentConfig ? resolveLiveImageSupport(exposedAgentConfig) : exposedAgentConfig;
|
|
17178
15458
|
},
|
|
17179
15459
|
loadDialogHistory: async (dialogId) => {
|
|
17180
15460
|
const loaded = await loadCliDialogHistoryWithSource({
|
|
@@ -17598,38 +15878,6 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
17598
15878
|
};
|
|
17599
15879
|
return {
|
|
17600
15880
|
...adapterBase,
|
|
17601
|
-
async admitAccountReviewTurn(dialogId, turnId, taskStart) {
|
|
17602
|
-
if (taskStart && (taskStart.userId !== userId || !taskStart.taskInstanceId?.trim() || !taskStart.userMessageId?.trim() || !/^[a-f0-9]{64}$/.test(taskStart.contentSha256))) throw new Error("task_review_user_turn_source_invalid");
|
|
17603
|
-
if (isSubtaskRun(deps.env) || !activeAgentToolNames.some((name) => ["requestTaskReview", "recordTaskReviewDecision"].includes(name))) throw new Error("task_review_outside_final_run_surface");
|
|
17604
|
-
const scope = accountReviewScope(dialogId, taskStart?.taskInstanceId);
|
|
17605
|
-
await requireAccountReview(scope);
|
|
17606
|
-
const root = hostTaskEventsRoot(deps.env);
|
|
17607
|
-
const current = readHostTask(root, scope);
|
|
17608
|
-
if (current.authorization !== "unknown" && taskStart && (current.taskStart?.taskInstanceId !== taskStart.taskInstanceId || current.taskStart?.userId !== taskStart.userId || current.taskStart?.userMessageId !== taskStart.userMessageId || current.taskStart?.contentSha256 !== taskStart.contentSha256)) throw new Error("task_review_user_turn_source_mismatch");
|
|
17609
|
-
if (current.authorization === "unknown") {
|
|
17610
|
-
if (current.reason !== "missing") throw new Error("task_review_task_history_invalid");
|
|
17611
|
-
if (!taskStart) throw new Error("task_review_explicit_task_start_required");
|
|
17612
|
-
const snapshot = admitHostTaskWorkspace(scope, deps.env);
|
|
17613
|
-
if (snapshot.status !== "ready") throw new Error(`task_review_workspace_unavailable: ${snapshot.reason}`);
|
|
17614
|
-
createHostTaskController(root, { kind: "trusted-host", actorId: userId, sourceId: taskStart ? `account-task-start:${taskStart.userMessageId}:${taskStart.contentSha256}` : `account-auto-review-admission:${turnId}` }).append(scope, 0, { type: "admitted", role: "owner", ...taskStart ? { taskStart } : {} });
|
|
17615
|
-
} else if (current.authorization !== "active") throw new Error(`task_review_authorization_${current.authorization}`);
|
|
17616
|
-
const workspace = await collectHostTaskWorkspace(scope, deps.env);
|
|
17617
|
-
if (workspace.status !== "ready") throw new Error(`task_review_workspace_unavailable: ${workspace.reason}`);
|
|
17618
|
-
const host = { scope, authorExecutionId: createHostAuthorExecution(deps.env, scope, turnId), authorize: async () => {
|
|
17619
|
-
} };
|
|
17620
|
-
installedTaskReviewHost = host;
|
|
17621
|
-
localToolExecutors = buildCurrentToolExecutors(reviewAgentConfig);
|
|
17622
|
-
return scope;
|
|
17623
|
-
},
|
|
17624
|
-
async authorizeAccountTask(scope) {
|
|
17625
|
-
await requireAccountReview(scope);
|
|
17626
|
-
const current = readHostTask(hostTaskEventsRoot(deps.env), scope);
|
|
17627
|
-
if (current.authorization !== "active") throw new Error(`task_review_authorization_${current.authorization}`);
|
|
17628
|
-
},
|
|
17629
|
-
installTaskReviewHost(host) {
|
|
17630
|
-
installedTaskReviewHost = host;
|
|
17631
|
-
localToolExecutors = buildCurrentToolExecutors(reviewAgentConfig);
|
|
17632
|
-
},
|
|
17633
15881
|
releaseLocalSandboxWorkload,
|
|
17634
15882
|
prepareLocalRuntimeWorkload,
|
|
17635
15883
|
// Session override or host-owned default; headless receives the same paid admission.
|
|
@@ -17642,6 +15890,9 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
17642
15890
|
agentConfig,
|
|
17643
15891
|
options
|
|
17644
15892
|
);
|
|
15893
|
+
if (!options?.textOnly && planningCaller.agentKey === agentConfig.key) {
|
|
15894
|
+
planningCaller.effectiveModel = provider.model;
|
|
15895
|
+
}
|
|
17645
15896
|
const retryingProvider = shouldUsePlatformChatProvider(deps.env, agentConfig) ? withProviderStreamRetry(provider, {
|
|
17646
15897
|
...deps,
|
|
17647
15898
|
retryOnly: isBusyProviderStreamError
|
|
@@ -17663,16 +15914,6 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
17663
15914
|
}
|
|
17664
15915
|
|
|
17665
15916
|
export {
|
|
17666
|
-
hostTaskEventsRoot,
|
|
17667
|
-
readHostTask,
|
|
17668
|
-
createHostTaskController,
|
|
17669
|
-
unknownTaskCompletion,
|
|
17670
|
-
sameTaskScope,
|
|
17671
|
-
admitHostTaskWorkspace,
|
|
17672
|
-
collectHostTaskWorkspace,
|
|
17673
|
-
readTimestamp,
|
|
17674
|
-
parseAgentRunEvent,
|
|
17675
|
-
isLiveAgentRunObservation,
|
|
17676
15917
|
matchContextualFragment,
|
|
17677
15918
|
renderNoticeElements,
|
|
17678
15919
|
renderCliNotice,
|
|
@@ -17681,10 +15922,9 @@ export {
|
|
|
17681
15922
|
buildNoticeTasksFromRuns,
|
|
17682
15923
|
setTurnNoticeMeta,
|
|
17683
15924
|
mergeNoticeGroup,
|
|
17684
|
-
|
|
17685
|
-
|
|
17686
|
-
|
|
17687
|
-
safeApprovalMultilineText,
|
|
15925
|
+
readTimestamp,
|
|
15926
|
+
parseAgentRunEvent,
|
|
15927
|
+
isLiveAgentRunObservation,
|
|
17688
15928
|
formatApprovalRemaining,
|
|
17689
15929
|
createHostApprovalCardQueue,
|
|
17690
15930
|
registerHostApprovalRenderer,
|
|
@@ -17712,18 +15952,6 @@ export {
|
|
|
17712
15952
|
loadCliDialogSummary,
|
|
17713
15953
|
saveCliDialogSummary,
|
|
17714
15954
|
loadCliDialogLastContextUsage,
|
|
17715
|
-
withHostReviewDispatch,
|
|
17716
|
-
matchesHostReviewDispatch,
|
|
17717
|
-
settleHostReviewsForScope,
|
|
17718
|
-
createHostAuthorExecution,
|
|
17719
|
-
unknownLocalRunAcceptance,
|
|
17720
|
-
inspectLocalRunWorkspace,
|
|
17721
|
-
shouldPrintLocalRunSummary,
|
|
17722
|
-
formatLocalRunSummary,
|
|
17723
|
-
captureLocalRunBase,
|
|
17724
|
-
observeLocalCommandResult,
|
|
17725
|
-
attachLocalCommandObservations,
|
|
17726
|
-
wrapLocalCommandWorkspaceObservation,
|
|
17727
15955
|
LOCAL_SERVER_TABLE_TOOL_NAMES,
|
|
17728
15956
|
LOCAL_SERVER_TABLE_TOOL_NAME_SET,
|
|
17729
15957
|
LOCAL_SERVER_WEB_TOOL_NAMES,
|
|
@@ -17744,8 +15972,7 @@ export {
|
|
|
17744
15972
|
resolveBoundMachineId,
|
|
17745
15973
|
isCliProviderAgentConfig,
|
|
17746
15974
|
detectCurrentMachineId,
|
|
17747
|
-
|
|
17748
|
-
collectHostTaskPlannedWorkspace,
|
|
15975
|
+
normalizeCliRunImages,
|
|
17749
15976
|
readFlagValue,
|
|
17750
15977
|
isFullstackCodingAgentRef,
|
|
17751
15978
|
positionalArgs,
|