nolo-cli 0.154.0-alpha.1 → 0.154.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-SDGDBNX5.js → _executeModel-3HHZYHHB.js} +54 -54
- package/{accountResolver-7RYB4D2P.js → accountResolver-55EDKEIK.js} +1 -1
- package/{action-SXJD5N5R.js → action-GPPJC5TI.js} +5 -5
- package/{addContentAction-65ONHX2T.js → addContentAction-XJQEJ4XW.js} +8 -8
- package/{addDialogAgentAction-WOLK7RB4.js → addDialogAgentAction-5WZX5CAY.js} +7 -7
- package/{agentDeleteCommand-W2XXF27A.js → agentDeleteCommand-ON2KVSJ5.js} +74 -75
- package/{agentEmailCommands-MSFGRDUZ.js → agentEmailCommands-2QPD5VP3.js} +77 -78
- package/{agentListCommands-G36AMSBR.js → agentListCommands-L33M3I6V.js} +35 -35
- package/{agentMachineCommands-YVVPDIHJ.js → agentMachineCommands-V44DPSED.js} +34 -31
- package/{agentProviderCommands-X2HQE6HY.js → agentProviderCommands-CXBHNONN.js} +5 -5
- package/{agentPullCommand-FA43RBRU.js → agentPullCommand-GXXEDOSA.js} +4 -4
- package/{agentRecordCommands-7G3DDI4L.js → agentRecordCommands-CKILCNQZ.js} +71 -72
- package/{agentRunCommand-ET7LIY7J.js → agentRunCommand-6IN7NK7H.js} +74 -74
- package/{agentRunControl-2C5GM3BW.js → agentRunControl-XBSNHHZE.js} +7 -7
- package/{agentRuntimeLocal-Q7ZOMZC7.js → agentRuntimeLocal-XCKO5FVP.js} +20 -18
- package/{agentSlice-MK5JTSZR.js → agentSlice-YT3VCCEW.js} +8 -8
- package/{appDeleteCommands-MMWT54BR.js → appDeleteCommands-2PJFNLAJ.js} +30 -28
- package/{appDeployCommands-OIFXVDOF.js → appDeployCommands-AZCMCMK6.js} +30 -28
- package/{appDeployStatusCommands-OTXMSDFB.js → appDeployStatusCommands-HSIKPVJN.js} +30 -28
- package/{appGetCommands-JPY36ANL.js → appGetCommands-IUZCPAP7.js} +30 -28
- package/{appListCommands-IHJGN36O.js → appListCommands-JLFVS44M.js} +30 -28
- package/{authCommand-J3XILHWW.js → authCommand-3Z52KJID.js} +22 -302
- package/{authCommands-77CHYBGF.js → authCommands-QOCKVPX3.js} +5 -5
- package/{builtinSkillRegistry-A6VSPJEJ.js → builtinSkillRegistry-LJV7FHNI.js} +4 -4
- package/{chromeCommands-OBBNJCLS.js → chromeCommands-IY4NVSXZ.js} +17 -10
- package/{chunk-SW4S4XYB.js → chunk-2AB2HA4M.js} +84 -34
- package/{chunk-YBNHPX4S.js → chunk-2ODX2C4E.js} +155 -31
- package/{chunk-FDT27L7S.js → chunk-2XDQAWBM.js} +18 -16
- package/{chunk-UGN77YJU.js → chunk-2ZYCNT2O.js} +232 -76
- package/{chunk-QFEW2ULV.js → chunk-32ZKZET7.js} +1 -1
- package/{chunk-QRRFQFFU.js → chunk-3GTVM7NJ.js} +22 -22
- package/{chunk-XPWGOTBQ.js → chunk-3L2WKC3W.js} +1 -8
- package/{chunk-LGCICX53.js → chunk-3L5MSPWX.js} +1 -1
- package/{chunk-4YRTZIVN.js → chunk-43OFVLWJ.js} +6 -6
- package/{chunk-6TF64IF2.js → chunk-4L4K6YR7.js} +16 -2
- package/{chunk-P5QACQDK.js → chunk-62TBKWTV.js} +1 -1
- package/{chunk-TRW43TSC.js → chunk-6EQD4AQL.js} +41 -1
- package/{chunk-YLMMECCH.js → chunk-6XIE5ZGI.js} +1 -1
- package/{chunk-UUPR3TD7.js → chunk-7RF4O6AT.js} +1 -3
- package/{chunk-OGI4JKBD.js → chunk-BAWAKW7X.js} +2 -2
- package/{chunk-2GGXHQIW.js → chunk-BLVSFYQ3.js} +4 -2
- package/{chunk-A7HQF6YH.js → chunk-CDLP56BS.js} +9 -9
- package/{chunk-5MM7NNO6.js → chunk-CNWKLQRL.js} +8 -3
- package/{chunk-TJ2VPCBE.js → chunk-DD2EOI6S.js} +2 -2
- package/{chunk-36OMEXXR.js → chunk-DLV3H464.js} +8 -8
- package/{chunk-4WLENVCW.js → chunk-DT7EWFTY.js} +6 -6
- package/{chunk-C5DLHL3R.js → chunk-ESMZW5PE.js} +3 -3
- package/{chunk-FJRGRIVL.js → chunk-EVPKKBSI.js} +17 -16
- package/{chunk-PSJWPSKS.js → chunk-EWO77ZGF.js} +9 -43
- package/{chunk-ZWG3C7VI.js → chunk-F3SOW2EU.js} +81 -1
- package/{chunk-RGBBF2RB.js → chunk-F5WASHQA.js} +279 -138
- package/{chunk-GJRCYN5X.js → chunk-FB5WLEOD.js} +21 -17
- package/{chunk-HHC5FJHS.js → chunk-FCUKCVKN.js} +12 -8
- package/{chunk-FY4SDK2E.js → chunk-FDLDMJTM.js} +1 -1
- package/{chunk-EM3YOZJ4.js → chunk-FFHV45HO.js} +3 -3
- package/{chunk-SWZEIKWQ.js → chunk-FZYKQFBQ.js} +3 -3
- package/{chunk-7KYVUFDG.js → chunk-G3VYRPTV.js} +5 -267
- package/{chunk-6MJNEXUU.js → chunk-HGDKT2D6.js} +4 -0
- package/{chunk-LXTNZVD4.js → chunk-HW7EBEC5.js} +35 -207
- package/{chunk-B2EGWZJG.js → chunk-I7S63QUU.js} +1 -1
- package/{chunk-PDJ6ZODI.js → chunk-IF7V3CBU.js} +1 -1
- package/{chunk-T6CBQ6BN.js → chunk-INFHX73M.js} +1 -1
- package/{chunk-N37ERV4O.js → chunk-JDKSYQQN.js} +5 -5
- package/{chunk-K43ZF2C3.js → chunk-JPPQ3GUO.js} +1 -1
- package/{chunk-PSYTZ4LK.js → chunk-JSB2OPQT.js} +134 -126
- package/{chunk-VEJFPTX7.js → chunk-JWEXJ573.js} +3 -3
- package/{chunk-ZG73GDYU.js → chunk-K25WQPP3.js} +253 -57
- package/{chunk-HKT6QXP3.js → chunk-KABQ74UQ.js} +5 -5
- package/{chunk-I2ZMGXXF.js → chunk-KFHREHUQ.js} +1 -1
- package/{chunk-3C2QLERX.js → chunk-KMDDG73K.js} +1 -1
- package/{chunk-AIZE5TDM.js → chunk-MAYW6V3E.js} +2 -2
- package/{chunk-IPAW7XLD.js → chunk-MFVOJ6KF.js} +2 -2
- package/{chunk-CBHGZRCE.js → chunk-MYOH447Z.js} +1 -1
- package/{chunk-TPG4CZHI.js → chunk-NHEWV5FD.js} +17 -3
- package/{chunk-G47IPDOK.js → chunk-O2IWR23M.js} +1 -1
- package/{chunk-OU7WCUB5.js → chunk-OLVOR45M.js} +2 -2
- package/{chunk-SUKSWFLP.js → chunk-PIG2IUVZ.js} +1 -1
- package/{chunk-SEJ5OS6F.js → chunk-PXYBUFDB.js} +4 -0
- package/{chunk-2MTE2PEH.js → chunk-QA2C5NKI.js} +5 -739
- package/{chunk-TYND6RDQ.js → chunk-QI2WVWXV.js} +73 -2
- package/{chunk-L6EQV5OC.js → chunk-QXZH5UDF.js} +3 -3
- package/{chunk-24UXUXPR.js → chunk-QZIOZDM6.js} +10 -10
- package/{chunk-C7M4N5RA.js → chunk-R2KWTENX.js} +3 -3
- package/{chunk-TNIX77YM.js → chunk-R5GO3YZP.js} +34 -1
- package/{chunk-UTIMX333.js → chunk-RIHQGFFA.js} +1 -1
- package/{chunk-4Z245KOA.js → chunk-SH3XD4E2.js} +8 -4
- package/{chunk-MM3662RS.js → chunk-SNAWGDXT.js} +263 -4
- package/{chunk-JGRPBIZZ.js → chunk-SQX235S2.js} +1 -1
- package/chunk-TT644UJD.js +188 -0
- package/{chunk-IYBIRCQV.js → chunk-U34KT53V.js} +29 -11
- package/{chunk-ANJTRG52.js → chunk-ULQAD7ZY.js} +18 -43
- package/{chunk-LOLOIIIP.js → chunk-UY73HNIN.js} +704 -663
- package/{chunk-I2RMFLLH.js → chunk-V7PCFWX3.js} +1 -1
- package/{chunk-KX6LPG7W.js → chunk-VXS4YYJ2.js} +8 -8
- package/{chunk-HXHSTRGH.js → chunk-VYNMQ6HW.js} +0 -27
- package/{chunk-IJERIUXS.js → chunk-WRCZXJ4N.js} +6 -3
- package/chunk-Y5GCAMGP.js +9 -0
- package/{chunk-JZX2XLKC.js → chunk-YCRROBDY.js} +1 -1
- package/{chunk-EYWJT7A2.js → chunk-YPG7TUQD.js} +3 -3
- package/chunk-YR47Y7CN.js +2685 -0
- package/{chunk-NEJZ5GLD.js → chunk-ZAV4YVEA.js} +18 -2
- package/{chunk-YANF2RR4.js → chunk-ZPKUJROL.js} +1 -1
- package/{chunk-WUR6LY7R.js → chunk-ZSLIYVIQ.js} +7 -7
- package/{commandRegistry-VSJPFX6B.js → commandRegistry-4LWXIPNX.js} +88 -96
- package/{contentThunks-65BTQQQE.js → contentThunks-QBL5NK2W.js} +21 -21
- package/{createAgentAutomationAction-SRMBZTAO.js → createAgentAutomationAction-5UWBLR2N.js} +21 -21
- package/{createDialogAction-OWAU72JP.js → createDialogAction-NJ2LE7KC.js} +25 -25
- package/{createPageAction-D4XGNX3P.js → createPageAction-7T3RINS2.js} +24 -25
- package/{dbSlice-S2HYXURM.js → dbSlice-6PVPY44C.js} +7 -7
- package/{deleteFile-6JWDDRVP.js → deleteFile-YM6NDPAR.js} +5 -5
- package/{dialogCommands-H3K7PTF6.js → dialogCommands-KMECTGCW.js} +34 -31
- package/{dialogSlice-GEBK3X5L.js → dialogSlice-GQMTD4HR.js} +20 -20
- package/{dist-NJC2W7I4.js → dist-Q2JSMAKA.js} +7 -361
- package/{docCreateCommands-KP64KMVL.js → docCreateCommands-4IT5PUAL.js} +31 -29
- package/{docDeleteCommands-C3F4SZSR.js → docDeleteCommands-QS66YNZV.js} +32 -30
- package/{docReadCommands-7H6BDOUR.js → docReadCommands-3SAI46YC.js} +31 -29
- package/{docStore-ARTZTJRA.js → docStore-PM5PYKPZ.js} +8 -8
- package/{docUpdateCommands-JDW4BRBH.js → docUpdateCommands-OGYG5BRC.js} +31 -29
- package/{getPricing-TX35D7PI.js → getPricing-XQ3N3RBP.js} +2 -2
- package/{handleSendMessageAction-SPGAO47U.js → handleSendMessageAction-EQ3U6K5N.js} +43 -39
- package/index.js +8 -8
- package/{localRuntimeAdapter-CHLHJSA3.js → localRuntimeAdapter-MO64KEOS.js} +69 -68
- package/{localRuntimeAuthority-JDAD7CB6.js → localRuntimeAuthority-BPN5OAQG.js} +2 -2
- package/{localRuntimeDb-CVC62PM5.js → localRuntimeDb-QIVAXMUL.js} +1 -1
- package/{machineCommands-GVFN64CM.js → machineCommands-7MBJJY4K.js} +79 -78
- package/{machineWsRunDispatch-3WXQ57DN.js → machineWsRunDispatch-T4LFRJL3.js} +69 -70
- package/{memberThunks-VPTET5M2.js → memberThunks-AZINUM4S.js} +10 -10
- package/package.json +6 -2
- package/{profileConfig-ZGOFORWV.js → profileConfig-KN3N2BLF.js} +7 -1
- package/{providerPresetApply-CRZFMQD5.js → providerPresetApply-PKUOHQJT.js} +5 -5
- package/{providerRegistry-7IS43D3X.js → providerRegistry-HNQLIFN2.js} +5 -5
- package/{read-VMMIHEAK.js → read-7JPIWRBQ.js} +5 -5
- package/{readDocTool-4XSLKYSQ.js → readDocTool-AAQTB2Y3.js} +1 -1
- package/{readlineWorkspace-2WGUU7KH.js → readlineWorkspace-2DR5GHLQ.js} +374 -199
- package/{removeDialogAgentAction-YIV37ENV.js → removeDialogAgentAction-RMVRILLK.js} +9 -9
- package/{runAgentClientLoop-WS2HFGIR.js → runAgentClientLoop-EXIQDX7G.js} +58 -53
- package/{runtimeDoctorCommands-56NWKNON.js → runtimeDoctorCommands-MMCP4B4U.js} +12 -12
- package/{secretCommands-ZXZRLR3R.js → secretCommands-DNY56NSU.js} +11 -1
- package/{setDialogExtraReferencesAction-FWVD656I.js → setDialogExtraReferencesAction-L3V7JTMG.js} +8 -8
- package/{setPrimaryDialogAgentAction-HIPQTT6N.js → setPrimaryDialogAgentAction-X52JQGTJ.js} +9 -9
- package/settingThunks-N6XFWPOU.js +923 -0
- package/{spaceCommands-JQN7D4FE.js → spaceCommands-WQMUCGV7.js} +28 -26
- package/{streamAgentChatTurn-OSGLMHT6.js → streamAgentChatTurn-DI2334G3.js} +153 -94
- package/{switchDialogAgentAction-SLTPB635.js → switchDialogAgentAction-ZJ5CGU7J.js} +7 -7
- package/{tableCommands-U3QDY4L6.js → tableCommands-IVC5S7Y3.js} +11 -11
- package/{toolApiClient-7WSJJJBV.js → toolApiClient-HGNO53TC.js} +2 -2
- package/{tools-XF5A6N2B.js → tools-23VQGJOX.js} +42 -43
- package/{tuiSummaryLlmCaller-KLK6K3Q3.js → tuiSummaryLlmCaller-FESHBDTT.js} +7 -7
- package/{updateCommands-NQXAGFM7.js → updateCommands-ODWC7SK7.js} +5 -3
- package/{updateDialogTitleAction-IN5TBR23.js → updateDialogTitleAction-AGAYHWS7.js} +21 -21
- package/{workloadLifecycle-36DXRZKU.js → workloadLifecycle-6O6PMISX.js} +2 -2
- package/chunk-IA7TRNNR.js +0 -11
- package/chunk-ON3WLDG2.js +0 -7012
- package/chunk-UKZX3NHN.js +0 -48
- package/chunk-W4S6OTSC.js +0 -35
- package/clipboardy-GCO3GT3I.js +0 -11793
- package/settingThunks-SB37UY4C.js +0 -1371
- package/{agentGrantCommands-HOJ3JBBQ.js → agentGrantCommands-5DPHYEKP.js} +3 -3
- package/{chromeOpsCommands-3Z34RKSE.js → chromeOpsCommands-GZVVK7HU.js} +4 -4
- package/{chunk-XETG4RIX.js → chunk-AETZ7AD6.js} +4 -4
- package/{chunk-2IXDJNZI.js → chunk-GAGGEA7D.js} +3 -3
- package/{memoryCommands-CUNBFRVS.js → memoryCommands-ZS3VQJAL.js} +3 -3
- package/{offlineMarxistsAgentCommand-2QTHJCHV.js → offlineMarxistsAgentCommand-3GLX4QQY.js} +3 -3
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
anthropicRefresh,
|
|
3
3
|
cursorRefresh,
|
|
4
|
-
getWorkBuddyHeaders,
|
|
5
4
|
refreshAntigravityOAuthToken,
|
|
6
5
|
refreshOpenAiCodexToken,
|
|
7
6
|
resolveServerSyncConfig,
|
|
8
|
-
workbuddyRefresh,
|
|
9
7
|
xaiRefresh
|
|
10
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-G3VYRPTV.js";
|
|
11
9
|
import {
|
|
12
10
|
clearCredentialAvailability,
|
|
13
11
|
markCredentialUnavailable,
|
|
@@ -18,14 +16,14 @@ import {
|
|
|
18
16
|
import {
|
|
19
17
|
agentRunCardLabels,
|
|
20
18
|
t
|
|
21
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-2AB2HA4M.js";
|
|
22
20
|
import {
|
|
23
21
|
defaultLoopbackRequest
|
|
24
22
|
} from "./chunk-VP3BINY7.js";
|
|
25
23
|
import {
|
|
26
24
|
OAUTH_PROVIDER_REFS,
|
|
27
25
|
buildLocalAgentLookupKeys
|
|
28
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-7RF4O6AT.js";
|
|
29
27
|
import {
|
|
30
28
|
LOCAL_CODEX_AGENT_ID,
|
|
31
29
|
LOCAL_CODEX_AGENT_KEY,
|
|
@@ -41,10 +39,14 @@ import {
|
|
|
41
39
|
isCursorOAuthAgent
|
|
42
40
|
} from "./chunk-VIWDGTDA.js";
|
|
43
41
|
import {
|
|
42
|
+
SANDBOX_HELPER_PATH,
|
|
43
|
+
SANDBOX_OUTPUT_LIMITS,
|
|
44
44
|
SANDBOX_WORKSPACE_ROOT,
|
|
45
45
|
buildSandboxHelperUploadArgv,
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
buildWorkspaceHelperSource,
|
|
47
|
+
dockerExecutionToolNames,
|
|
48
|
+
parseToolOutput
|
|
49
|
+
} from "./chunk-HGDKT2D6.js";
|
|
48
50
|
import {
|
|
49
51
|
createChromeConnectorClientResolver,
|
|
50
52
|
createVerifiedChromeConnectorClient,
|
|
@@ -52,17 +54,17 @@ import {
|
|
|
52
54
|
} from "./chunk-BU2YQBV4.js";
|
|
53
55
|
import {
|
|
54
56
|
applyPublicAgentCatalogOverride
|
|
55
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-MFVOJ6KF.js";
|
|
56
58
|
import {
|
|
57
59
|
buildCliPrompt
|
|
58
60
|
} from "./chunk-ATNTHIZI.js";
|
|
59
61
|
import {
|
|
60
62
|
inferCaptureIntent
|
|
61
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-INFHX73M.js";
|
|
62
64
|
import {
|
|
63
65
|
inlineImageUrlsForCustomProvider,
|
|
64
66
|
prepareTools
|
|
65
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-OLVOR45M.js";
|
|
66
68
|
import {
|
|
67
69
|
getServerProviderSecret
|
|
68
70
|
} from "./chunk-HS7MLR74.js";
|
|
@@ -84,18 +86,18 @@ import {
|
|
|
84
86
|
resolveCliLocalRuntimeKeyCapability,
|
|
85
87
|
resolveCliLocalSpawnDispatch,
|
|
86
88
|
resolveStartAgentRunCwd
|
|
87
|
-
} from "./chunk-
|
|
89
|
+
} from "./chunk-2ZYCNT2O.js";
|
|
88
90
|
import {
|
|
89
91
|
deriveCredentialGroup,
|
|
90
92
|
deriveCustomProviderCredentialGroup
|
|
91
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-VXS4YYJ2.js";
|
|
92
94
|
import {
|
|
93
95
|
fetchWithTransientRetry,
|
|
94
96
|
isTransientFetchError
|
|
95
|
-
} from "./chunk-
|
|
97
|
+
} from "./chunk-KFHREHUQ.js";
|
|
96
98
|
import {
|
|
97
99
|
resolveAgentRequiredPackIds
|
|
98
|
-
} from "./chunk-
|
|
100
|
+
} from "./chunk-FCUKCVKN.js";
|
|
99
101
|
import {
|
|
100
102
|
applyBuiltinAgentRuntimeOverride,
|
|
101
103
|
applyTokenUsageToDayStats,
|
|
@@ -104,17 +106,14 @@ import {
|
|
|
104
106
|
resolveBuiltinPlatformAgentConfig,
|
|
105
107
|
runKeyed,
|
|
106
108
|
validateAskChoiceInput
|
|
107
|
-
} from "./chunk-
|
|
109
|
+
} from "./chunk-F5WASHQA.js";
|
|
108
110
|
import {
|
|
109
111
|
BUILTIN_DIALOG_LLM_CHAT_FALLBACK_MODEL,
|
|
110
112
|
BUILTIN_TITLE_LLM_CONFIG
|
|
111
113
|
} from "./chunk-523DITKR.js";
|
|
112
|
-
import {
|
|
113
|
-
isOAuthApiKeyRef
|
|
114
|
-
} from "./chunk-UKZX3NHN.js";
|
|
115
114
|
import {
|
|
116
115
|
fetchServerSyncedCredential
|
|
117
|
-
} from "./chunk-
|
|
116
|
+
} from "./chunk-DT7EWFTY.js";
|
|
118
117
|
import {
|
|
119
118
|
isTombstoneRecord
|
|
120
119
|
} from "./chunk-D2MDMY2M.js";
|
|
@@ -127,7 +126,7 @@ import {
|
|
|
127
126
|
applySystemBuiltinSkillFilter,
|
|
128
127
|
expandEnabledPacks,
|
|
129
128
|
resolveEffectiveEnabledPacks
|
|
130
|
-
} from "./chunk-
|
|
129
|
+
} from "./chunk-YCRROBDY.js";
|
|
131
130
|
import {
|
|
132
131
|
DEFAULT_HYBRID_READ_TIMEOUT_MS,
|
|
133
132
|
Duration_exports,
|
|
@@ -171,7 +170,7 @@ import {
|
|
|
171
170
|
runExecShellGates,
|
|
172
171
|
validateConfiguredRootExecutionLease,
|
|
173
172
|
verifyOwnerRouteAck
|
|
174
|
-
} from "./chunk-
|
|
173
|
+
} from "./chunk-K25WQPP3.js";
|
|
175
174
|
import {
|
|
176
175
|
accumulateGeminiChunks,
|
|
177
176
|
buildGeminiGenerateContentRequest,
|
|
@@ -183,7 +182,7 @@ import {
|
|
|
183
182
|
resolveAntigravityFinishReason,
|
|
184
183
|
resolveGeminiModelQuirks,
|
|
185
184
|
shouldUseGeminiNativeToolRoute
|
|
186
|
-
} from "./chunk-
|
|
185
|
+
} from "./chunk-KMDDG73K.js";
|
|
187
186
|
import {
|
|
188
187
|
PlatformStreamInterruptedError,
|
|
189
188
|
buildPlatformChatCompletionRequest,
|
|
@@ -194,27 +193,24 @@ import {
|
|
|
194
193
|
readPlatformChatSseCompletion,
|
|
195
194
|
resolvePlatformChatProviderConfig,
|
|
196
195
|
shouldUsePlatformChatProvider
|
|
197
|
-
} from "./chunk-
|
|
196
|
+
} from "./chunk-QXZH5UDF.js";
|
|
198
197
|
import {
|
|
199
198
|
readSseDataValues,
|
|
200
199
|
readSseFrames
|
|
201
200
|
} from "./chunk-HNUWUO75.js";
|
|
202
201
|
import {
|
|
203
202
|
resolveAgentRuntimeConfigFromRecord
|
|
204
|
-
} from "./chunk-
|
|
205
|
-
import {
|
|
206
|
-
isDevinOAuthAgent
|
|
207
|
-
} from "./chunk-5ZUL4CUO.js";
|
|
203
|
+
} from "./chunk-ULQAD7ZY.js";
|
|
208
204
|
import {
|
|
209
205
|
resolveHistoricalToolContentCap
|
|
210
|
-
} from "./chunk-
|
|
206
|
+
} from "./chunk-U34KT53V.js";
|
|
211
207
|
import {
|
|
212
208
|
collectStablePromptPrefix,
|
|
213
209
|
convertMessagesToResponsesInput,
|
|
214
210
|
findAgentStatePairingIssues,
|
|
215
211
|
stablePromptCacheKey,
|
|
216
212
|
toResponsesTools
|
|
217
|
-
} from "./chunk-
|
|
213
|
+
} from "./chunk-4L4K6YR7.js";
|
|
218
214
|
import {
|
|
219
215
|
buildNoloWorkspaceOpenAiTools,
|
|
220
216
|
parseNoloWorkspaceToolArguments,
|
|
@@ -231,15 +227,19 @@ import {
|
|
|
231
227
|
normalizeDialogTitle
|
|
232
228
|
} from "./chunk-2MBTWINN.js";
|
|
233
229
|
import {
|
|
230
|
+
isOAuthApiKeyRef,
|
|
234
231
|
normalizeUsage
|
|
235
|
-
} from "./chunk-
|
|
232
|
+
} from "./chunk-F3SOW2EU.js";
|
|
233
|
+
import {
|
|
234
|
+
isDevinOAuthAgent
|
|
235
|
+
} from "./chunk-5ZUL4CUO.js";
|
|
236
236
|
import {
|
|
237
237
|
createProviderCallTimingTracker,
|
|
238
238
|
finalizeProviderCallTiming,
|
|
239
239
|
observeMeaningfulProviderResponse,
|
|
240
240
|
observeMeaningfulProviderResponseAt,
|
|
241
241
|
withProviderCallTimingFields
|
|
242
|
-
} from "./chunk-
|
|
242
|
+
} from "./chunk-QA2C5NKI.js";
|
|
243
243
|
import {
|
|
244
244
|
clipCompactText
|
|
245
245
|
} from "./chunk-5MMAK75Q.js";
|
|
@@ -278,9 +278,6 @@ import {
|
|
|
278
278
|
dialogMessagePrefix,
|
|
279
279
|
dialogMessageRange
|
|
280
280
|
} from "./chunk-5EMSBTQ6.js";
|
|
281
|
-
import {
|
|
282
|
-
isAntigravityOAuthAgent
|
|
283
|
-
} from "./chunk-JGRPBIZZ.js";
|
|
284
281
|
import {
|
|
285
282
|
ackRunRecord,
|
|
286
283
|
appendRunQueue,
|
|
@@ -301,7 +298,7 @@ import {
|
|
|
301
298
|
terminateRunProcess,
|
|
302
299
|
transitionRunToTerminal,
|
|
303
300
|
withQueueLock
|
|
304
|
-
} from "./chunk-
|
|
301
|
+
} from "./chunk-SNAWGDXT.js";
|
|
305
302
|
import {
|
|
306
303
|
TASK_PREVIEW_MAX,
|
|
307
304
|
formatListRunsCard,
|
|
@@ -318,15 +315,36 @@ import {
|
|
|
318
315
|
import {
|
|
319
316
|
estimateTokenCount
|
|
320
317
|
} from "./chunk-PSCNXBYA.js";
|
|
318
|
+
import {
|
|
319
|
+
getDefaultCliLocalRuntimeDb
|
|
320
|
+
} from "./chunk-FDLDMJTM.js";
|
|
321
|
+
import {
|
|
322
|
+
getLogger
|
|
323
|
+
} from "./chunk-EYLGAEB4.js";
|
|
324
|
+
import {
|
|
325
|
+
isCompiledBinary,
|
|
326
|
+
parseUserIdFromAuthToken,
|
|
327
|
+
resolveAuthToken,
|
|
328
|
+
resolveServerUrl
|
|
329
|
+
} from "./chunk-A7GB5UGH.js";
|
|
330
|
+
import {
|
|
331
|
+
DEFAULT_NOLO_SERVER_URL
|
|
332
|
+
} from "./chunk-OLZBQWZU.js";
|
|
333
|
+
import {
|
|
334
|
+
NOLO_CLUSTER_SERVERS
|
|
335
|
+
} from "./chunk-LCBAMY2M.js";
|
|
336
|
+
import {
|
|
337
|
+
isAntigravityOAuthAgent
|
|
338
|
+
} from "./chunk-SQX235S2.js";
|
|
321
339
|
import {
|
|
322
340
|
buildProviderSessionHeaders,
|
|
323
341
|
resolvePlatformAuthToken
|
|
324
|
-
} from "./chunk-
|
|
342
|
+
} from "./chunk-PIG2IUVZ.js";
|
|
325
343
|
import {
|
|
326
344
|
anthropicOAuthModelMaxOutputTokens,
|
|
327
345
|
findModelConfig,
|
|
328
346
|
isAdaptiveThinkingModelId
|
|
329
|
-
} from "./chunk-
|
|
347
|
+
} from "./chunk-6EQD4AQL.js";
|
|
330
348
|
import {
|
|
331
349
|
CLI_PROVIDER_VALUES,
|
|
332
350
|
isCliProvider
|
|
@@ -340,24 +358,6 @@ import {
|
|
|
340
358
|
import {
|
|
341
359
|
toErrorMessage
|
|
342
360
|
} from "./chunk-HNMXYYJR.js";
|
|
343
|
-
import {
|
|
344
|
-
getDefaultCliLocalRuntimeDb
|
|
345
|
-
} from "./chunk-FY4SDK2E.js";
|
|
346
|
-
import {
|
|
347
|
-
getLogger
|
|
348
|
-
} from "./chunk-EYLGAEB4.js";
|
|
349
|
-
import {
|
|
350
|
-
isCompiledBinary,
|
|
351
|
-
parseUserIdFromAuthToken,
|
|
352
|
-
resolveAuthToken,
|
|
353
|
-
resolveServerUrl
|
|
354
|
-
} from "./chunk-A7GB5UGH.js";
|
|
355
|
-
import {
|
|
356
|
-
DEFAULT_NOLO_SERVER_URL
|
|
357
|
-
} from "./chunk-OLZBQWZU.js";
|
|
358
|
-
import {
|
|
359
|
-
NOLO_CLUSTER_SERVERS
|
|
360
|
-
} from "./chunk-LCBAMY2M.js";
|
|
361
361
|
import {
|
|
362
362
|
isLoopbackUrl
|
|
363
363
|
} from "./chunk-4SN6J65J.js";
|
|
@@ -3301,447 +3301,6 @@ var resolveDevinTransport = async (ctx) => {
|
|
|
3301
3301
|
return null;
|
|
3302
3302
|
};
|
|
3303
3303
|
|
|
3304
|
-
// packages/agent-runtime/workbuddyRequestAdapter.ts
|
|
3305
|
-
var DEFAULT_SYSTEM = "You are a helpful assistant.";
|
|
3306
|
-
var SAFE_NAME = /^[A-Za-z0-9_-]{1,64}$/;
|
|
3307
|
-
function record(value) {
|
|
3308
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
3309
|
-
}
|
|
3310
|
-
function safeName(name, reserved) {
|
|
3311
|
-
const stem = name.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 48) || "tool";
|
|
3312
|
-
let candidate = stem;
|
|
3313
|
-
if (reserved.has(candidate)) {
|
|
3314
|
-
let suffix = 1;
|
|
3315
|
-
do
|
|
3316
|
-
candidate = `${stem.slice(0, 64 - String(suffix).length - 1)}_${suffix++}`;
|
|
3317
|
-
while (reserved.has(candidate));
|
|
3318
|
-
}
|
|
3319
|
-
reserved.add(candidate);
|
|
3320
|
-
return candidate;
|
|
3321
|
-
}
|
|
3322
|
-
function adaptSchema(schema, path) {
|
|
3323
|
-
if (!record(schema)) throw new TypeError(`${path} must be a JSON Schema object`);
|
|
3324
|
-
if (schema.type !== "object" && schema.type !== "array" && schema.type !== "string" && schema.type !== "number" && schema.type !== "integer" && schema.type !== "boolean" && schema.type !== "null" && schema.type !== void 0) throw new TypeError(`${path}.type is unsupported`);
|
|
3325
|
-
if (schema.properties !== void 0) {
|
|
3326
|
-
if (!record(schema.properties)) throw new TypeError(`${path}.properties must be an object`);
|
|
3327
|
-
for (const [key, value] of Object.entries(schema.properties)) adaptSchema(value, `${path}.properties.${key}`);
|
|
3328
|
-
}
|
|
3329
|
-
for (const key of ["items", "additionalProperties", "not", "if", "then", "else"]) {
|
|
3330
|
-
const value = schema[key];
|
|
3331
|
-
if (value === false || value === true) continue;
|
|
3332
|
-
if (record(value)) adaptSchema(value, `${path}.${key}`);
|
|
3333
|
-
else if (Array.isArray(value)) value.forEach((item, i) => adaptSchema(item, `${path}.${key}[${i}]`));
|
|
3334
|
-
}
|
|
3335
|
-
for (const key of ["oneOf", "anyOf", "allOf", "prefixItems"]) {
|
|
3336
|
-
if (schema[key] !== void 0) {
|
|
3337
|
-
if (!Array.isArray(schema[key])) throw new TypeError(`${path}.${key} must be an array`);
|
|
3338
|
-
schema[key].forEach((item, i) => adaptSchema(item, `${path}.${key}[${i}]`));
|
|
3339
|
-
}
|
|
3340
|
-
}
|
|
3341
|
-
}
|
|
3342
|
-
function adaptWorkBuddyRequest(body) {
|
|
3343
|
-
const adapted = structuredClone(body);
|
|
3344
|
-
const originalNames = /* @__PURE__ */ Object.create(null);
|
|
3345
|
-
const safeToOriginal = /* @__PURE__ */ new Map();
|
|
3346
|
-
const tools = adapted.tools;
|
|
3347
|
-
if (tools !== void 0 && !Array.isArray(tools)) throw new TypeError("tools must be an array");
|
|
3348
|
-
const reserved = /* @__PURE__ */ new Set();
|
|
3349
|
-
for (const tool of tools ?? []) {
|
|
3350
|
-
if (!record(tool) || !record(tool.function) || typeof tool.function.name !== "string") throw new TypeError("Each tool must have a named function");
|
|
3351
|
-
if (SAFE_NAME.test(tool.function.name)) reserved.add(tool.function.name);
|
|
3352
|
-
}
|
|
3353
|
-
for (const tool of tools ?? []) {
|
|
3354
|
-
const fn = tool.function;
|
|
3355
|
-
const original = fn.name;
|
|
3356
|
-
if (!SAFE_NAME.test(original)) {
|
|
3357
|
-
const safe = safeName(original, reserved);
|
|
3358
|
-
Object.defineProperty(originalNames, safe, { value: original, enumerable: true, configurable: true, writable: true });
|
|
3359
|
-
safeToOriginal.set(safe, original);
|
|
3360
|
-
fn.name = safe;
|
|
3361
|
-
}
|
|
3362
|
-
if (fn.parameters !== void 0) {
|
|
3363
|
-
if (!record(fn.parameters)) throw new TypeError(`Tool ${original} parameters must be a JSON Schema object`);
|
|
3364
|
-
adaptSchema(fn.parameters, `Tool ${original} parameters`);
|
|
3365
|
-
if (fn.parameters.type !== "object") throw new TypeError(`Tool ${original} parameters root must be type object`);
|
|
3366
|
-
}
|
|
3367
|
-
}
|
|
3368
|
-
const safeFor = (name) => typeof name === "string" ? [...safeToOriginal].find(([, original]) => original === name)?.[0] : void 0;
|
|
3369
|
-
if (Array.isArray(adapted.messages)) {
|
|
3370
|
-
for (const message of adapted.messages) {
|
|
3371
|
-
if (!record(message)) continue;
|
|
3372
|
-
if (message.role === "developer") message.role = "system";
|
|
3373
|
-
if (Array.isArray(message.tool_calls)) for (const call of message.tool_calls) {
|
|
3374
|
-
if (record(call) && record(call.function)) call.function.name = safeFor(call.function.name) ?? call.function.name;
|
|
3375
|
-
}
|
|
3376
|
-
if (message.role === "tool") message.name = safeFor(message.name) ?? message.name;
|
|
3377
|
-
}
|
|
3378
|
-
if (!adapted.messages.some((message) => record(message) && message.role === "system")) adapted.messages.unshift({ role: "system", content: DEFAULT_SYSTEM });
|
|
3379
|
-
} else adapted.messages = [{ role: "system", content: DEFAULT_SYSTEM }];
|
|
3380
|
-
const choice = adapted.tool_choice;
|
|
3381
|
-
if (choice === "none") delete adapted.tools;
|
|
3382
|
-
else if (record(choice) && record(choice.function)) choice.function.name = safeFor(choice.function.name) ?? choice.function.name;
|
|
3383
|
-
else if (typeof choice === "string" && !["auto", "required", "none"].includes(choice)) adapted.tool_choice = { type: "function", function: { name: safeFor(choice) ?? choice } };
|
|
3384
|
-
if (adapted.max_completion_tokens !== void 0) {
|
|
3385
|
-
if (adapted.max_tokens === void 0) adapted.max_tokens = adapted.max_completion_tokens;
|
|
3386
|
-
delete adapted.max_completion_tokens;
|
|
3387
|
-
}
|
|
3388
|
-
adapted.stream = true;
|
|
3389
|
-
return { body: adapted, originalNames };
|
|
3390
|
-
}
|
|
3391
|
-
function restoreWorkBuddyToolNames(payload, originalNames) {
|
|
3392
|
-
const copy = structuredClone(payload);
|
|
3393
|
-
if (!record(copy) || !Array.isArray(copy.choices)) return copy;
|
|
3394
|
-
for (const choice of copy.choices) for (const part of [choice?.delta, choice?.message]) {
|
|
3395
|
-
if (!record(part) || !Array.isArray(part.tool_calls)) continue;
|
|
3396
|
-
for (const call of part.tool_calls) {
|
|
3397
|
-
if (!record(call) || !record(call.function) || typeof call.function.name !== "string") continue;
|
|
3398
|
-
if (Object.prototype.hasOwnProperty.call(originalNames, call.function.name)) call.function.name = originalNames[call.function.name];
|
|
3399
|
-
}
|
|
3400
|
-
}
|
|
3401
|
-
return copy;
|
|
3402
|
-
}
|
|
3403
|
-
|
|
3404
|
-
// packages/cli/client/providerResolution/workbuddyTransport.ts
|
|
3405
|
-
var WORKBUDDY_ENDPOINTS = {
|
|
3406
|
-
workbuddy: "https://copilot.tencent.com/v2/chat/completions",
|
|
3407
|
-
"workbuddy-ai": "https://www.workbuddy.ai/v2/chat/completions"
|
|
3408
|
-
};
|
|
3409
|
-
function resolveWorkBuddySite(agentConfig) {
|
|
3410
|
-
const ref = agentConfig.apiKeyRef?.trim().toLowerCase();
|
|
3411
|
-
const prov = agentConfig.provider?.trim().toLowerCase();
|
|
3412
|
-
if (ref === "workbuddy-ai" || ref?.startsWith(["api-key", "workbuddy-ai"].join(":")) || prov === "workbuddy-ai") {
|
|
3413
|
-
return "workbuddy-ai";
|
|
3414
|
-
}
|
|
3415
|
-
if (ref === "workbuddy" || ref?.startsWith(["api-key", "workbuddy"].join(":")) || prov === "workbuddy") {
|
|
3416
|
-
return "workbuddy";
|
|
3417
|
-
}
|
|
3418
|
-
return null;
|
|
3419
|
-
}
|
|
3420
|
-
function record2(value) {
|
|
3421
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3422
|
-
}
|
|
3423
|
-
var QUOTA_EXCEEDED_MESSAGE = "WorkBuddy \u989D\u5EA6\u4E0D\u8DB3 (14018)\uFF1AWorkBuddy \u975E\u65E0\u9650\u514D\u8D39\u670D\u52A1\uFF0C\u5F53\u524D\u8D26\u53F7\u989D\u5EA6\u5DF2\u8017\u5C3D\u3002";
|
|
3424
|
-
function wrapWorkBuddySseResponse(response, names) {
|
|
3425
|
-
if (!response.body) return response;
|
|
3426
|
-
const decoder = new TextDecoder("utf-8");
|
|
3427
|
-
const encoder = new TextEncoder();
|
|
3428
|
-
let pending = "";
|
|
3429
|
-
let lines = [];
|
|
3430
|
-
const fragments = /* @__PURE__ */ new Map();
|
|
3431
|
-
const processEvent = () => {
|
|
3432
|
-
const dataLines = lines.filter((line) => line.startsWith("data:")).map((line) => line.slice(5).replace(/^ /, ""));
|
|
3433
|
-
const data = dataLines.join("\n");
|
|
3434
|
-
if (!data || data === "[DONE]") {
|
|
3435
|
-
const result = lines.join("\n") + "\n\n";
|
|
3436
|
-
lines = [];
|
|
3437
|
-
return result;
|
|
3438
|
-
}
|
|
3439
|
-
let payload;
|
|
3440
|
-
try {
|
|
3441
|
-
payload = JSON.parse(data);
|
|
3442
|
-
} catch {
|
|
3443
|
-
const result = lines.join("\n") + "\n\n";
|
|
3444
|
-
lines = [];
|
|
3445
|
-
return result;
|
|
3446
|
-
}
|
|
3447
|
-
if (record2(payload)) {
|
|
3448
|
-
if (payload.code === 14018 || payload.errcode === 14018 || record2(payload.error) && payload.error.code === 14018) {
|
|
3449
|
-
throw new Error(QUOTA_EXCEEDED_MESSAGE);
|
|
3450
|
-
}
|
|
3451
|
-
const choices = Array.isArray(payload.choices) ? payload.choices : [];
|
|
3452
|
-
for (const choice of choices) {
|
|
3453
|
-
if (!record2(choice)) continue;
|
|
3454
|
-
const delta = record2(choice.delta) ? choice.delta : void 0;
|
|
3455
|
-
const toolCalls = delta && Array.isArray(delta.tool_calls) ? delta.tool_calls : [];
|
|
3456
|
-
for (const call of toolCalls) {
|
|
3457
|
-
if (!record2(call) || !record2(call.function) || typeof call.function.name !== "string") {
|
|
3458
|
-
continue;
|
|
3459
|
-
}
|
|
3460
|
-
const key = `${choice.index ?? 0}:${call.index ?? 0}`;
|
|
3461
|
-
const accumulated = (fragments.get(key) ?? "") + call.function.name;
|
|
3462
|
-
if (Object.prototype.hasOwnProperty.call(names, accumulated)) {
|
|
3463
|
-
call.function.name = accumulated;
|
|
3464
|
-
fragments.delete(key);
|
|
3465
|
-
} else if (Object.keys(names).some((safe) => safe.startsWith(accumulated))) {
|
|
3466
|
-
fragments.set(key, accumulated);
|
|
3467
|
-
call.function.name = "";
|
|
3468
|
-
} else {
|
|
3469
|
-
call.function.name = accumulated;
|
|
3470
|
-
fragments.delete(key);
|
|
3471
|
-
}
|
|
3472
|
-
}
|
|
3473
|
-
}
|
|
3474
|
-
}
|
|
3475
|
-
const restored = restoreWorkBuddyToolNames(payload, names);
|
|
3476
|
-
const nonDataFields = lines.filter((line) => !line.startsWith("data:"));
|
|
3477
|
-
lines = [];
|
|
3478
|
-
return [...nonDataFields, `data: ${JSON.stringify(restored)}`, "", ""].join(
|
|
3479
|
-
"\n"
|
|
3480
|
-
);
|
|
3481
|
-
};
|
|
3482
|
-
const drain = (final) => {
|
|
3483
|
-
let output = "";
|
|
3484
|
-
while (true) {
|
|
3485
|
-
const match = /[\r\n]/.exec(pending);
|
|
3486
|
-
if (!match) break;
|
|
3487
|
-
const i = match.index;
|
|
3488
|
-
if (!final && pending[i] === "\r" && i === pending.length - 1) break;
|
|
3489
|
-
const line = pending.slice(0, i);
|
|
3490
|
-
pending = pending.slice(
|
|
3491
|
-
i + (pending[i] === "\r" && pending[i + 1] === "\n" ? 2 : 1)
|
|
3492
|
-
);
|
|
3493
|
-
if (line === "") {
|
|
3494
|
-
output += processEvent();
|
|
3495
|
-
} else {
|
|
3496
|
-
lines.push(line);
|
|
3497
|
-
}
|
|
3498
|
-
}
|
|
3499
|
-
if (final) {
|
|
3500
|
-
if (pending) {
|
|
3501
|
-
lines.push(pending);
|
|
3502
|
-
pending = "";
|
|
3503
|
-
}
|
|
3504
|
-
if (lines.length > 0) {
|
|
3505
|
-
output += processEvent();
|
|
3506
|
-
}
|
|
3507
|
-
}
|
|
3508
|
-
return output;
|
|
3509
|
-
};
|
|
3510
|
-
const transformStream = new TransformStream({
|
|
3511
|
-
transform: (chunk, controller) => {
|
|
3512
|
-
pending += decoder.decode(chunk, { stream: true });
|
|
3513
|
-
const output = drain(false);
|
|
3514
|
-
if (output) controller.enqueue(encoder.encode(output));
|
|
3515
|
-
},
|
|
3516
|
-
flush: (controller) => {
|
|
3517
|
-
pending += decoder.decode();
|
|
3518
|
-
const output = drain(true);
|
|
3519
|
-
if (output) controller.enqueue(encoder.encode(output));
|
|
3520
|
-
}
|
|
3521
|
-
});
|
|
3522
|
-
const body = response.body.pipeThrough(transformStream);
|
|
3523
|
-
const headers = new Headers(response.headers);
|
|
3524
|
-
headers.delete("content-length");
|
|
3525
|
-
headers.delete("content-encoding");
|
|
3526
|
-
return new Response(body, {
|
|
3527
|
-
status: response.status,
|
|
3528
|
-
statusText: response.statusText,
|
|
3529
|
-
headers
|
|
3530
|
-
});
|
|
3531
|
-
}
|
|
3532
|
-
async function wrapWorkBuddyJsonResponse(response, names) {
|
|
3533
|
-
const rawText = await response.text();
|
|
3534
|
-
let json;
|
|
3535
|
-
try {
|
|
3536
|
-
json = JSON.parse(rawText);
|
|
3537
|
-
} catch {
|
|
3538
|
-
return new Response(rawText, {
|
|
3539
|
-
status: response.status,
|
|
3540
|
-
statusText: response.statusText,
|
|
3541
|
-
headers: response.headers
|
|
3542
|
-
});
|
|
3543
|
-
}
|
|
3544
|
-
if (record2(json) && (json.code === 14018 || json.errcode === 14018 || record2(json.error) && json.error.code === 14018 || rawText.includes("14018"))) {
|
|
3545
|
-
throw new Error(QUOTA_EXCEEDED_MESSAGE);
|
|
3546
|
-
}
|
|
3547
|
-
const restored = restoreWorkBuddyToolNames(json, names);
|
|
3548
|
-
return new Response(JSON.stringify(restored), {
|
|
3549
|
-
status: response.status,
|
|
3550
|
-
statusText: response.statusText,
|
|
3551
|
-
headers: response.headers
|
|
3552
|
-
});
|
|
3553
|
-
}
|
|
3554
|
-
var resolveWorkbuddyTransport = async (ctx) => {
|
|
3555
|
-
const {
|
|
3556
|
-
agentConfig,
|
|
3557
|
-
deps,
|
|
3558
|
-
fetchImpl,
|
|
3559
|
-
additionalToolNames,
|
|
3560
|
-
buildProviderOpenAiTools,
|
|
3561
|
-
recordLocalAvailability,
|
|
3562
|
-
apiKeyRefResolver
|
|
3563
|
-
} = ctx;
|
|
3564
|
-
const site = resolveWorkBuddySite(agentConfig);
|
|
3565
|
-
if (!site) return null;
|
|
3566
|
-
const fixedEndpoint = WORKBUDDY_ENDPOINTS[site];
|
|
3567
|
-
if (agentConfig.customProviderUrl) {
|
|
3568
|
-
const trimmedUrl = agentConfig.customProviderUrl.trim();
|
|
3569
|
-
if (trimmedUrl && trimmedUrl !== fixedEndpoint) {
|
|
3570
|
-
throw new Error(
|
|
3571
|
-
`Custom provider URL "${trimmedUrl}" is forbidden for WorkBuddy (${site}). Requests must only target ${fixedEndpoint}.`
|
|
3572
|
-
);
|
|
3573
|
-
}
|
|
3574
|
-
}
|
|
3575
|
-
const rawRef = asTrimmedLowercaseString(agentConfig.apiKeyRef);
|
|
3576
|
-
const isApiKeyRef = rawRef.startsWith("api-key:");
|
|
3577
|
-
const providerRef = isApiKeyRef ? rawRef : site;
|
|
3578
|
-
const initialToken = await apiKeyRefResolver(providerRef);
|
|
3579
|
-
if (!initialToken) {
|
|
3580
|
-
throw new Error(
|
|
3581
|
-
`OAuth credential for "${site}" not found locally. Run \`nolo auth ${site}\`.`
|
|
3582
|
-
);
|
|
3583
|
-
}
|
|
3584
|
-
const legacyCredentialMigration = { enableLegacyMigration: true };
|
|
3585
|
-
let currentCredential = readOAuthCredential(
|
|
3586
|
-
site,
|
|
3587
|
-
void 0,
|
|
3588
|
-
legacyCredentialMigration
|
|
3589
|
-
);
|
|
3590
|
-
if (!currentCredential || !currentCredential.accessToken) {
|
|
3591
|
-
throw new Error(
|
|
3592
|
-
`OAuth credential for "${site}" not found locally. Run \`nolo auth ${site}\`.`
|
|
3593
|
-
);
|
|
3594
|
-
}
|
|
3595
|
-
const uid = typeof currentCredential.metadata?.uid === "string" && currentCredential.metadata.uid.trim() || typeof currentCredential.accountId === "string" && currentCredential.accountId.trim() || "";
|
|
3596
|
-
if (!uid) {
|
|
3597
|
-
throw new Error(
|
|
3598
|
-
`WorkBuddy credential for "${site}" is missing uid. Re-run \`nolo auth ${site}\`.`
|
|
3599
|
-
);
|
|
3600
|
-
}
|
|
3601
|
-
if (currentCredential.accessToken !== initialToken) {
|
|
3602
|
-
currentCredential = { ...currentCredential, accessToken: initialToken };
|
|
3603
|
-
}
|
|
3604
|
-
const { requestedToolNames, tools } = resolveProviderOpenAiToolBundle(
|
|
3605
|
-
agentConfig,
|
|
3606
|
-
deps.env,
|
|
3607
|
-
buildProviderOpenAiTools,
|
|
3608
|
-
additionalToolNames
|
|
3609
|
-
);
|
|
3610
|
-
const resolveRequestApiKey = async ({
|
|
3611
|
-
force
|
|
3612
|
-
}) => {
|
|
3613
|
-
if (isApiKeyRef && force) {
|
|
3614
|
-
return currentCredential.accessToken;
|
|
3615
|
-
}
|
|
3616
|
-
const before = readOAuthCredential(
|
|
3617
|
-
site,
|
|
3618
|
-
void 0,
|
|
3619
|
-
legacyCredentialMigration
|
|
3620
|
-
);
|
|
3621
|
-
if (before) {
|
|
3622
|
-
currentCredential = before;
|
|
3623
|
-
}
|
|
3624
|
-
if (!force) {
|
|
3625
|
-
return currentCredential.accessToken;
|
|
3626
|
-
}
|
|
3627
|
-
const refreshedToken = await apiKeyRefResolver(providerRef, {
|
|
3628
|
-
force: true
|
|
3629
|
-
});
|
|
3630
|
-
const after = readOAuthCredential(
|
|
3631
|
-
site,
|
|
3632
|
-
void 0,
|
|
3633
|
-
legacyCredentialMigration
|
|
3634
|
-
);
|
|
3635
|
-
if (after) {
|
|
3636
|
-
currentCredential = after;
|
|
3637
|
-
}
|
|
3638
|
-
if (refreshedToken && currentCredential.accessToken !== refreshedToken) {
|
|
3639
|
-
currentCredential = {
|
|
3640
|
-
...currentCredential,
|
|
3641
|
-
accessToken: refreshedToken
|
|
3642
|
-
};
|
|
3643
|
-
}
|
|
3644
|
-
return refreshedToken ?? currentCredential.accessToken;
|
|
3645
|
-
};
|
|
3646
|
-
const wrappedFetch = async (inputUrl, init) => {
|
|
3647
|
-
const targetUrl = typeof inputUrl === "string" ? inputUrl : inputUrl instanceof URL ? inputUrl.toString() : inputUrl.url;
|
|
3648
|
-
if (targetUrl !== fixedEndpoint) {
|
|
3649
|
-
throw new Error(
|
|
3650
|
-
`WorkBuddy request blocked: target URL "${targetUrl}" does not match fixed endpoint "${fixedEndpoint}". Token will not be sent.`
|
|
3651
|
-
);
|
|
3652
|
-
}
|
|
3653
|
-
let originalNames = {};
|
|
3654
|
-
let body = init?.body;
|
|
3655
|
-
if (typeof body === "string") {
|
|
3656
|
-
try {
|
|
3657
|
-
const parsed = JSON.parse(body);
|
|
3658
|
-
const adapted = adaptWorkBuddyRequest(parsed);
|
|
3659
|
-
originalNames = adapted.originalNames;
|
|
3660
|
-
body = JSON.stringify(adapted.body);
|
|
3661
|
-
} catch {
|
|
3662
|
-
}
|
|
3663
|
-
}
|
|
3664
|
-
const wbHeaders = getWorkBuddyHeaders(currentCredential);
|
|
3665
|
-
const mergedHeaders = new Headers(init?.headers);
|
|
3666
|
-
for (const [key, value] of Object.entries(wbHeaders)) {
|
|
3667
|
-
mergedHeaders.set(key, value);
|
|
3668
|
-
}
|
|
3669
|
-
mergedHeaders.set("Content-Type", "application/json");
|
|
3670
|
-
const upstreamRes = await fetchImpl(fixedEndpoint, {
|
|
3671
|
-
...init,
|
|
3672
|
-
body,
|
|
3673
|
-
headers: mergedHeaders,
|
|
3674
|
-
redirect: "error"
|
|
3675
|
-
});
|
|
3676
|
-
if (upstreamRes.status === 401) {
|
|
3677
|
-
return upstreamRes;
|
|
3678
|
-
}
|
|
3679
|
-
if (!upstreamRes.ok) {
|
|
3680
|
-
const clone = upstreamRes.clone();
|
|
3681
|
-
const errorText = await clone.text().catch(() => "");
|
|
3682
|
-
if (errorText.includes("14018")) {
|
|
3683
|
-
throw new Error(QUOTA_EXCEEDED_MESSAGE);
|
|
3684
|
-
}
|
|
3685
|
-
return upstreamRes;
|
|
3686
|
-
}
|
|
3687
|
-
const contentType = upstreamRes.headers.get("content-type") ?? "";
|
|
3688
|
-
if (contentType.includes("text/event-stream")) {
|
|
3689
|
-
return wrapWorkBuddySseResponse(upstreamRes, originalNames);
|
|
3690
|
-
} else {
|
|
3691
|
-
return wrapWorkBuddyJsonResponse(upstreamRes, originalNames);
|
|
3692
|
-
}
|
|
3693
|
-
};
|
|
3694
|
-
return {
|
|
3695
|
-
model: agentConfig.model || "gpt-4o",
|
|
3696
|
-
complete: async (messages, options) => {
|
|
3697
|
-
logLocalRuntimeDiagnostic("provider.request.start", {
|
|
3698
|
-
agentKey: agentConfig.key,
|
|
3699
|
-
transport: "workbuddy",
|
|
3700
|
-
model: agentConfig.model ?? "gpt-4o",
|
|
3701
|
-
messageCount: messages.length,
|
|
3702
|
-
toolCount: tools.length,
|
|
3703
|
-
requestedToolNames,
|
|
3704
|
-
openAiToolNames: summarizeOpenAiToolNames(tools),
|
|
3705
|
-
stream: true
|
|
3706
|
-
});
|
|
3707
|
-
try {
|
|
3708
|
-
const result = await executeOpenAiCompatibleChatCompletion({
|
|
3709
|
-
providerConfig: {
|
|
3710
|
-
endpoint: fixedEndpoint,
|
|
3711
|
-
apiKey: currentCredential.accessToken,
|
|
3712
|
-
model: agentConfig.model || "gpt-4o",
|
|
3713
|
-
provider: site
|
|
3714
|
-
},
|
|
3715
|
-
messages,
|
|
3716
|
-
tools,
|
|
3717
|
-
fetchImpl: wrappedFetch,
|
|
3718
|
-
stream: true,
|
|
3719
|
-
sessionId: asOptionalTrimmedString(options?.dialogId) ?? asOptionalTrimmedString(agentConfig.key),
|
|
3720
|
-
onTextDelta: options?.onTextDelta,
|
|
3721
|
-
onReasoningDelta: options?.onReasoningDelta,
|
|
3722
|
-
onHttpResult: ({ status, body }) => recordLocalAvailability(status, body),
|
|
3723
|
-
resolveApiKey: resolveRequestApiKey
|
|
3724
|
-
});
|
|
3725
|
-
await recordLocalAvailability(200);
|
|
3726
|
-
logLocalRuntimeDiagnostic("provider.request.result", {
|
|
3727
|
-
agentKey: agentConfig.key,
|
|
3728
|
-
transport: "workbuddy",
|
|
3729
|
-
ok: true,
|
|
3730
|
-
contentChars: result.content.length,
|
|
3731
|
-
toolCallCount: result.tool_calls?.length ?? 0
|
|
3732
|
-
});
|
|
3733
|
-
return result;
|
|
3734
|
-
} catch (error) {
|
|
3735
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
3736
|
-
if (message.includes("14018")) {
|
|
3737
|
-
throw new Error(QUOTA_EXCEEDED_MESSAGE);
|
|
3738
|
-
}
|
|
3739
|
-
throw error;
|
|
3740
|
-
}
|
|
3741
|
-
}
|
|
3742
|
-
};
|
|
3743
|
-
};
|
|
3744
|
-
|
|
3745
3304
|
// packages/cli/client/providerResolution/directOpenAiCompatibleTransport.ts
|
|
3746
3305
|
var resolveDirectOpenAiCompatibleTransport = async (ctx) => {
|
|
3747
3306
|
const { agentConfig, deps, fetchImpl, loopbackRequest, additionalToolNames, buildProviderOpenAiTools, recordLocalAvailability, apiKeyRefResolver, credentialBroker, syncFetcher, serverUrl, authToken } = ctx;
|
|
@@ -4385,7 +3944,6 @@ var TRANSPORTS = [
|
|
|
4385
3944
|
resolveCodexOAuthTransport,
|
|
4386
3945
|
resolveCursorTransport,
|
|
4387
3946
|
resolveDevinTransport,
|
|
4388
|
-
resolveWorkbuddyTransport,
|
|
4389
3947
|
resolveGeminiNativeToolTransport,
|
|
4390
3948
|
// 三条 custom native wire(gemini / openai-responses / anthropic-messages)由
|
|
4391
3949
|
// 这一个 resolver 按目录 `nativeProtocol` 分派:三种 wire 互斥(一个模型的
|
|
@@ -4556,11 +4114,11 @@ function withProviderStreamRetry(provider, deps) {
|
|
|
4556
4114
|
|
|
4557
4115
|
// packages/cli/client/cliRemoteDialogSync.ts
|
|
4558
4116
|
function prepareRemoteDialogEvidenceRecord(key, value) {
|
|
4559
|
-
const
|
|
4560
|
-
if (key.includes("-msg-") && typeof
|
|
4561
|
-
|
|
4117
|
+
const record = isRecord(value) ? { ...value } : {};
|
|
4118
|
+
if (key.includes("-msg-") && typeof record.type !== "string") {
|
|
4119
|
+
record.type = "msg";
|
|
4562
4120
|
}
|
|
4563
|
-
return
|
|
4121
|
+
return record;
|
|
4564
4122
|
}
|
|
4565
4123
|
function normalizeRemoteSubjectRef(value) {
|
|
4566
4124
|
if (!isRecord(value)) return null;
|
|
@@ -4852,13 +4410,13 @@ function resolveBuiltinLocalCliAgentConfig(agentRef, userId) {
|
|
|
4852
4410
|
}
|
|
4853
4411
|
async function readAgentFromStore(args) {
|
|
4854
4412
|
for (const key of buildLocalAgentLookupKeys(args)) {
|
|
4855
|
-
const
|
|
4856
|
-
if (!
|
|
4413
|
+
const record = await args.store.read(key);
|
|
4414
|
+
if (!record || typeof record !== "object") continue;
|
|
4857
4415
|
return applyBuiltinAgentRuntimeOverride(
|
|
4858
4416
|
args.agentRef,
|
|
4859
4417
|
resolveAgentRuntimeConfigFromRecord(
|
|
4860
4418
|
key,
|
|
4861
|
-
applyPublicAgentCatalogOverride(
|
|
4419
|
+
applyPublicAgentCatalogOverride(record)
|
|
4862
4420
|
)
|
|
4863
4421
|
);
|
|
4864
4422
|
}
|
|
@@ -4893,8 +4451,8 @@ async function readDialogMessages(args) {
|
|
|
4893
4451
|
function createChildShellApprovalHostResolver(args) {
|
|
4894
4452
|
return async (agentKey) => {
|
|
4895
4453
|
const config = await args.readAgentConfig(agentKey);
|
|
4896
|
-
const
|
|
4897
|
-
const ownerUserId = asOptionalTrimmedString(
|
|
4454
|
+
const record = config?.rawRecord;
|
|
4455
|
+
const ownerUserId = asOptionalTrimmedString(record?.userId) ?? asOptionalTrimmedString(record?.ownerUserId);
|
|
4898
4456
|
if (!ownerUserId) return void 0;
|
|
4899
4457
|
const deviceId = asOptionalTrimmedString(await args.resolveDeviceId());
|
|
4900
4458
|
if (!deviceId) return void 0;
|
|
@@ -5161,8 +4719,8 @@ function describeIssues(issues) {
|
|
|
5161
4719
|
function asNonEmptyString(value) {
|
|
5162
4720
|
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
5163
4721
|
}
|
|
5164
|
-
function resolveCreatedAtMs(
|
|
5165
|
-
const raw =
|
|
4722
|
+
function resolveCreatedAtMs(record) {
|
|
4723
|
+
const raw = record.createdAt;
|
|
5166
4724
|
const ms = typeof raw === "number" ? raw : typeof raw === "string" ? Date.parse(raw) : Number.NaN;
|
|
5167
4725
|
return Number.isFinite(ms) ? ms : null;
|
|
5168
4726
|
}
|
|
@@ -5222,18 +4780,18 @@ function analyzeRemoteDialogRecords(args) {
|
|
|
5222
4780
|
}
|
|
5223
4781
|
seenIds.add(messageId);
|
|
5224
4782
|
const key = dialogMessageKey(args.dialogId, messageId);
|
|
5225
|
-
const
|
|
4783
|
+
const record = {
|
|
5226
4784
|
...raw,
|
|
5227
4785
|
id: messageId,
|
|
5228
4786
|
dbKey: key,
|
|
5229
4787
|
...asNonEmptyString(raw.dialogId) ? {} : { dialogId: args.dialogId }
|
|
5230
4788
|
};
|
|
5231
|
-
const message = dialogMessageRecordToAgentRuntimeMessage(
|
|
4789
|
+
const message = dialogMessageRecordToAgentRuntimeMessage(record);
|
|
5232
4790
|
if (!message) {
|
|
5233
4791
|
issues.push({ code: "unconvertible-record", detail: `${role} index ${index}` });
|
|
5234
4792
|
continue;
|
|
5235
4793
|
}
|
|
5236
|
-
entries.push({ key, messageId, record
|
|
4794
|
+
entries.push({ key, messageId, record, message });
|
|
5237
4795
|
}
|
|
5238
4796
|
const messages = entries.map((entry) => entry.message);
|
|
5239
4797
|
for (const detail of findAgentStatePairingIssues(messages)) {
|
|
@@ -5507,14 +5065,27 @@ function buildServerPlatformToolExecutors(args) {
|
|
|
5507
5065
|
}
|
|
5508
5066
|
const body = {
|
|
5509
5067
|
query: parsed.query,
|
|
5510
|
-
numResults: parsed.numResults
|
|
5511
|
-
useAutoprompt: parsed.useAutoprompt ?? true,
|
|
5512
|
-
type: parsed.type ?? "neural",
|
|
5513
|
-
// Model schema uses `includeContent` (boolean); the Exa API
|
|
5514
|
-
// expects `contents: { text: true }`. Mirror exaSearchFunc's
|
|
5515
|
-
// conversion so CLI proxy results match web behavior.
|
|
5516
|
-
contents: parsed.includeContent !== false ? { text: true } : void 0
|
|
5068
|
+
...parsed.numResults !== void 0 ? { numResults: parsed.numResults } : {}
|
|
5517
5069
|
};
|
|
5070
|
+
if (typeof parsed.intent === "string" && parsed.intent) {
|
|
5071
|
+
body.intent = parsed.intent;
|
|
5072
|
+
}
|
|
5073
|
+
if (typeof parsed.category === "string" && parsed.category) {
|
|
5074
|
+
body.category = parsed.category;
|
|
5075
|
+
}
|
|
5076
|
+
if (typeof parsed.timeRange === "string" && parsed.timeRange) {
|
|
5077
|
+
body.timeRange = parsed.timeRange;
|
|
5078
|
+
}
|
|
5079
|
+
if (Array.isArray(parsed.includeDomains) && parsed.includeDomains.length > 0) {
|
|
5080
|
+
body.includeDomains = parsed.includeDomains;
|
|
5081
|
+
}
|
|
5082
|
+
if (Array.isArray(parsed.excludeDomains) && parsed.excludeDomains.length > 0) {
|
|
5083
|
+
body.excludeDomains = parsed.excludeDomains;
|
|
5084
|
+
}
|
|
5085
|
+
if (typeof parsed.includeContent === "boolean") {
|
|
5086
|
+
body.includeContent = parsed.includeContent;
|
|
5087
|
+
}
|
|
5088
|
+
if (call?.origin) body.origin = call.origin;
|
|
5518
5089
|
const content = await postServer("/api/exa-search", body);
|
|
5519
5090
|
return {
|
|
5520
5091
|
content,
|
|
@@ -6094,9 +5665,9 @@ var boundedOutputPage = (items, total, offset, budget = 8 * 1024) => {
|
|
|
6094
5665
|
return { items, hasMore: offset + items.length < total, nextOffset: offset + items.length };
|
|
6095
5666
|
};
|
|
6096
5667
|
var resolveNowMs = (deps) => typeof deps.nowMs === "function" ? deps.nowMs() : Date.now();
|
|
6097
|
-
function buildProgressField(
|
|
6098
|
-
const activity =
|
|
6099
|
-
if (!activity || isAgentRunTerminalStatus(
|
|
5668
|
+
function buildProgressField(record, nowMs) {
|
|
5669
|
+
const activity = record.activity;
|
|
5670
|
+
if (!activity || isAgentRunTerminalStatus(record.status)) return {};
|
|
6100
5671
|
const lastEventAt = Date.parse(activity.lastEventAt ?? "");
|
|
6101
5672
|
const inFlight = activity.inFlight;
|
|
6102
5673
|
const progress = {
|
|
@@ -6193,15 +5764,15 @@ async function assertCredentialFanoutAllowed(deps, args) {
|
|
|
6193
5764
|
}
|
|
6194
5765
|
const { batchId, parentDialogId } = args;
|
|
6195
5766
|
if (!batchId && !parentDialogId) return candidateGroup;
|
|
6196
|
-
const active = queryRunRecords({ limit: 500 }, deps).runs.filter((
|
|
6197
|
-
if (isRunTerminalStatus(
|
|
6198
|
-
if (batchId &&
|
|
6199
|
-
if (parentDialogId &&
|
|
5767
|
+
const active = queryRunRecords({ limit: 500 }, deps).runs.filter((record) => {
|
|
5768
|
+
if (isRunTerminalStatus(record.status)) return false;
|
|
5769
|
+
if (batchId && record.batchId === batchId) return true;
|
|
5770
|
+
if (parentDialogId && record.parentDialogId === parentDialogId) return true;
|
|
6200
5771
|
return false;
|
|
6201
|
-
}).map((
|
|
6202
|
-
runId:
|
|
6203
|
-
agentKey:
|
|
6204
|
-
credentialGroup:
|
|
5772
|
+
}).map((record) => ({
|
|
5773
|
+
runId: record.runId,
|
|
5774
|
+
agentKey: record.agentKey,
|
|
5775
|
+
credentialGroup: record.credentialGroup
|
|
6205
5776
|
}));
|
|
6206
5777
|
if (active.length === 0) return candidateGroup;
|
|
6207
5778
|
const verdict = checkCredentialFanout({
|
|
@@ -6230,6 +5801,12 @@ function createCliStartAgentRunExecutor(deps = {}) {
|
|
|
6230
5801
|
// F1:runtimeKey=local 是「在宿主文件系统上改代码」,需要调用方的显式确认
|
|
6231
5802
|
// (allowHostWrites: true);缺失即派发前拒绝(零 spawn、零 run 记录)。
|
|
6232
5803
|
allowHostWrites: args.allowHostWrites,
|
|
5804
|
+
// 政策第 5 条:显式宿主 cwd × 沙盒落点必须在派发前失败(沙盒不兑现宿主
|
|
5805
|
+
// 路径,cwd 会被静默替换、改动随沙盒消失)。这里传的是调用方**原始**
|
|
5806
|
+
// args.cwd —— `requestedCwd` 走 resolveStartAgentRunCwd,要读 fs 探测,
|
|
5807
|
+
// 排在这条判定之后;守卫自己只认宿主绝对路径(相对/空白自行跳过,交给
|
|
5808
|
+
// resolveStartAgentRunCwd 报「必须是绝对路径」)。
|
|
5809
|
+
...typeof args.cwd === "string" && args.cwd.trim() ? { cwd: args.cwd } : {},
|
|
6233
5810
|
...bindingMachineId ? { bindingMachineId } : {},
|
|
6234
5811
|
...localMachineId ? { localMachineId } : {}
|
|
6235
5812
|
});
|
|
@@ -6438,16 +6015,16 @@ function createCliControlAgentRunExecutor(deps = {}) {
|
|
|
6438
6015
|
},
|
|
6439
6016
|
deps
|
|
6440
6017
|
);
|
|
6441
|
-
const runs = records.map((
|
|
6018
|
+
const runs = records.map((record2) => {
|
|
6442
6019
|
return {
|
|
6443
|
-
runId:
|
|
6444
|
-
status:
|
|
6445
|
-
agentKey:
|
|
6446
|
-
...
|
|
6447
|
-
...typeof
|
|
6448
|
-
...
|
|
6449
|
-
pid:
|
|
6450
|
-
startedAt:
|
|
6020
|
+
runId: record2.runId,
|
|
6021
|
+
status: record2.status,
|
|
6022
|
+
agentKey: record2.agentKey,
|
|
6023
|
+
...record2.agentName ? { agentName: record2.agentName.slice(0, 120) } : {},
|
|
6024
|
+
...typeof record2.title === "string" ? { title: record2.title.slice(0, 160) } : {},
|
|
6025
|
+
...record2.batchId ? { batchId: record2.batchId } : {},
|
|
6026
|
+
pid: record2.pid ?? null,
|
|
6027
|
+
startedAt: record2.startedAt
|
|
6451
6028
|
};
|
|
6452
6029
|
});
|
|
6453
6030
|
const outputBudgetBytes = 8 * 1024;
|
|
@@ -6533,15 +6110,15 @@ function createCliControlAgentRunExecutor(deps = {}) {
|
|
|
6533
6110
|
if (!args.runId) throw new Error(t("agentRunTool.appendMissingRunId"));
|
|
6534
6111
|
const userInput = typeof args.userInput === "string" ? args.userInput.trim() : "";
|
|
6535
6112
|
if (!userInput) throw new Error(t("agentRunTool.appendMissingUserInput"));
|
|
6536
|
-
const
|
|
6537
|
-
if (!
|
|
6113
|
+
const record2 = findRunRecord(String(args.runId), deps);
|
|
6114
|
+
if (!record2) {
|
|
6538
6115
|
const labels2 = agentRunCardLabels();
|
|
6539
6116
|
return {
|
|
6540
6117
|
content: JSON.stringify({ runId: args.runId, found: false }),
|
|
6541
6118
|
metadata: { displayData: formatNotFoundRunCard(labels2) }
|
|
6542
6119
|
};
|
|
6543
6120
|
}
|
|
6544
|
-
let reconciled2 = checkStaleRun(
|
|
6121
|
+
let reconciled2 = checkStaleRun(record2.runId, deps) ?? record2;
|
|
6545
6122
|
if (!isAgentRunTerminalStatus(reconciled2.status)) {
|
|
6546
6123
|
if (!reconciled2.queuePath) {
|
|
6547
6124
|
throw new Error(t("agentRunTool.appendQueueUnsupported"));
|
|
@@ -6621,8 +6198,8 @@ function createCliControlAgentRunExecutor(deps = {}) {
|
|
|
6621
6198
|
throw new Error(t("agentRunTool.unknownAction", String(action)));
|
|
6622
6199
|
}
|
|
6623
6200
|
if (!args.runId) throw new Error(t("agentRunTool.missingRunId", String(action)));
|
|
6624
|
-
const
|
|
6625
|
-
if (!
|
|
6201
|
+
const record = findRunRecord(String(args.runId), deps);
|
|
6202
|
+
if (!record) {
|
|
6626
6203
|
const labels2 = agentRunCardLabels();
|
|
6627
6204
|
return {
|
|
6628
6205
|
content: JSON.stringify({ runId: args.runId, found: false }),
|
|
@@ -6630,15 +6207,15 @@ function createCliControlAgentRunExecutor(deps = {}) {
|
|
|
6630
6207
|
};
|
|
6631
6208
|
}
|
|
6632
6209
|
if (action === "status") {
|
|
6633
|
-
const reconciled2 = checkStaleRun(
|
|
6634
|
-
const logTail = tailLines > 0 ? tailFile(
|
|
6210
|
+
const reconciled2 = checkStaleRun(record.runId, deps) ?? record;
|
|
6211
|
+
const logTail = tailLines > 0 ? tailFile(record.logPath, tailLines, resolveFs(deps)) : void 0;
|
|
6635
6212
|
return buildRunStatusPayload(reconciled2, deps, { logTail });
|
|
6636
6213
|
}
|
|
6637
6214
|
if (action === "wait") {
|
|
6638
6215
|
const timeoutMs = typeof args.timeoutMs === "number" && args.timeoutMs > 0 ? args.timeoutMs : DEFAULT_WAIT_TIMEOUT_MS;
|
|
6639
6216
|
let claimToken = null;
|
|
6640
6217
|
const result = await waitForRunTerminal({
|
|
6641
|
-
read: () => checkStaleRun(
|
|
6218
|
+
read: () => checkStaleRun(record.runId, deps) ?? record,
|
|
6642
6219
|
isTerminal: (state) => isAgentRunTerminalStatus(state.status),
|
|
6643
6220
|
pollIntervalMs: WAIT_POLL_INTERVAL_MS,
|
|
6644
6221
|
timeoutMs,
|
|
@@ -6646,28 +6223,28 @@ function createCliControlAgentRunExecutor(deps = {}) {
|
|
|
6646
6223
|
sleep: deps.sleep,
|
|
6647
6224
|
claim: {
|
|
6648
6225
|
acquire: () => {
|
|
6649
|
-
claimToken = claimRunRecord(
|
|
6226
|
+
claimToken = claimRunRecord(record.runId, { ...deps, ttlMs: timeoutMs + ACK_LEASE_GRACE_MS });
|
|
6650
6227
|
return claimToken;
|
|
6651
6228
|
},
|
|
6652
6229
|
commit: (token) => {
|
|
6653
|
-
if (token) commitRunRecordClaim(
|
|
6654
|
-
else ackRunRecord(
|
|
6230
|
+
if (token) commitRunRecordClaim(record.runId, token, deps);
|
|
6231
|
+
else ackRunRecord(record.runId, deps);
|
|
6655
6232
|
},
|
|
6656
6233
|
release: (token) => {
|
|
6657
|
-
if (token) releaseRunRecordAck(
|
|
6234
|
+
if (token) releaseRunRecordAck(record.runId, token, deps);
|
|
6658
6235
|
}
|
|
6659
6236
|
}
|
|
6660
6237
|
});
|
|
6661
6238
|
if (result.kind === "aborted") throw new Error(t("agentRunTool.waitAborted"));
|
|
6662
6239
|
if (result.kind === "failed") throw result.error;
|
|
6663
6240
|
if (result.kind === "timeout") {
|
|
6664
|
-
const reconciled2 = result.lastState ??
|
|
6241
|
+
const reconciled2 = result.lastState ?? record;
|
|
6665
6242
|
const nowMs = resolveNowMs(deps);
|
|
6666
6243
|
return { content: JSON.stringify({ runId: reconciled2.runId, found: true, status: "timeout", runStatus: reconciled2.status, pid: reconciled2.pid ?? null, agentKey: reconciled2.agentKey, ...reconciled2.agentName ? { agentName: reconciled2.agentName } : {}, startedAt: reconciled2.startedAt, waitedMs: result.waitedMs, timeoutMs, ...buildProgressField(reconciled2, nowMs) }), metadata: { displayData: t("agentRunWaitTimeout", String(Math.round(result.waitedMs / 1e3))) } };
|
|
6667
6244
|
}
|
|
6668
6245
|
return buildRunStatusPayload(result.state, deps);
|
|
6669
6246
|
}
|
|
6670
|
-
const reconciled = checkStaleRun(
|
|
6247
|
+
const reconciled = checkStaleRun(record.runId, deps) ?? record;
|
|
6671
6248
|
if (isAgentRunTerminalStatus(reconciled.status)) {
|
|
6672
6249
|
const labels2 = agentRunCardLabels();
|
|
6673
6250
|
return {
|
|
@@ -6686,13 +6263,13 @@ function createCliControlAgentRunExecutor(deps = {}) {
|
|
|
6686
6263
|
if (!confirmed) {
|
|
6687
6264
|
return {
|
|
6688
6265
|
content: JSON.stringify({
|
|
6689
|
-
runId:
|
|
6266
|
+
runId: record.runId,
|
|
6690
6267
|
found: true,
|
|
6691
6268
|
status: reconciled.status,
|
|
6692
6269
|
stopConfirmed: false
|
|
6693
6270
|
}),
|
|
6694
6271
|
metadata: {
|
|
6695
|
-
displayData: t("agentRunStopFailedAlive", String(
|
|
6272
|
+
displayData: t("agentRunStopFailedAlive", String(record.pid))
|
|
6696
6273
|
}
|
|
6697
6274
|
};
|
|
6698
6275
|
}
|
|
@@ -7160,12 +6737,10 @@ var REFRESH_BY_PROVIDER = {
|
|
|
7160
6737
|
antigravity: refreshAntigravityOAuthToken,
|
|
7161
6738
|
xai: xaiRefresh,
|
|
7162
6739
|
claude: anthropicRefresh,
|
|
7163
|
-
cursor: cursorRefresh
|
|
7164
|
-
workbuddy: workbuddyRefresh,
|
|
7165
|
-
"workbuddy-ai": workbuddyRefresh
|
|
6740
|
+
cursor: cursorRefresh
|
|
7166
6741
|
};
|
|
7167
6742
|
function isOAuthProvider(value) {
|
|
7168
|
-
return value === "chatgpt" || value === "xai" || value === "antigravity" || value === "claude" || value === "cursor" || value === "devin"
|
|
6743
|
+
return value === "chatgpt" || value === "xai" || value === "antigravity" || value === "claude" || value === "cursor" || value === "devin";
|
|
7169
6744
|
}
|
|
7170
6745
|
function createOAuthApiKeyRefResolver(options = {}) {
|
|
7171
6746
|
const pullServerAccessToken = options.pullServerAccessToken ?? createServerAccessTokenPuller({
|
|
@@ -7212,10 +6787,10 @@ function encodeFailure(error, stderr) {
|
|
|
7212
6787
|
function readStreams(output) {
|
|
7213
6788
|
if (typeof output === "string") return { stdout: output, stderr: "" };
|
|
7214
6789
|
if (!output || typeof output !== "object") return { stdout: "", stderr: "" };
|
|
7215
|
-
const
|
|
6790
|
+
const record = output;
|
|
7216
6791
|
return {
|
|
7217
|
-
stdout: typeof
|
|
7218
|
-
stderr: typeof
|
|
6792
|
+
stdout: typeof record.stdout === "string" ? record.stdout : "",
|
|
6793
|
+
stderr: typeof record.stderr === "string" ? record.stderr : ""
|
|
7219
6794
|
};
|
|
7220
6795
|
}
|
|
7221
6796
|
function describeMessage(error) {
|
|
@@ -8622,8 +8197,8 @@ async function createLocalDockerWorkload(args) {
|
|
|
8622
8197
|
}
|
|
8623
8198
|
const createLifecycle = args.createLifecycle ?? (async () => {
|
|
8624
8199
|
const [{ DockerWorkloadLifecycle, createDockerBindingAuthorizer }, accounts] = await Promise.all([
|
|
8625
|
-
import("./workloadLifecycle-
|
|
8626
|
-
import("./accountResolver-
|
|
8200
|
+
import("./workloadLifecycle-6O6PMISX.js"),
|
|
8201
|
+
import("./accountResolver-55EDKEIK.js")
|
|
8627
8202
|
]);
|
|
8628
8203
|
const resolveAccount = args.resolveAccount ?? accounts.createDockerAccountResolver({
|
|
8629
8204
|
env: args.env,
|
|
@@ -8640,7 +8215,28 @@ async function createLocalDockerWorkload(args) {
|
|
|
8640
8215
|
resolveAccount
|
|
8641
8216
|
});
|
|
8642
8217
|
});
|
|
8643
|
-
const
|
|
8218
|
+
const phaseLogEnabled = () => {
|
|
8219
|
+
const env = args.env;
|
|
8220
|
+
return env.NOLO_DEBUG === "1" || env.NOLO_CLI_DEBUG_DETAIL === "1";
|
|
8221
|
+
};
|
|
8222
|
+
const phaseLog = (event, payload) => {
|
|
8223
|
+
if (!phaseLogEnabled()) return;
|
|
8224
|
+
console.warn(`[docker-workload-phase] ${event}`, payload);
|
|
8225
|
+
};
|
|
8226
|
+
const phase = async (name, operation) => {
|
|
8227
|
+
const startedAt = Date.now();
|
|
8228
|
+
phaseLog("start", { phase: name, runId: args.runId });
|
|
8229
|
+
try {
|
|
8230
|
+
const result = await operation();
|
|
8231
|
+
phaseLog("complete", { phase: name, runId: args.runId, elapsedMs: Date.now() - startedAt });
|
|
8232
|
+
return result;
|
|
8233
|
+
} catch (error) {
|
|
8234
|
+
const safeError = error && typeof error === "object" ? error : {};
|
|
8235
|
+
phaseLog("failed", { phase: name, runId: args.runId, elapsedMs: Date.now() - startedAt, errorCode: typeof safeError.code === "string" ? safeError.code : void 0, errorName: typeof safeError.name === "string" ? safeError.name : void 0 });
|
|
8236
|
+
throw error;
|
|
8237
|
+
}
|
|
8238
|
+
};
|
|
8239
|
+
const lifecycle = await phase("create-lifecycle", () => createLifecycle());
|
|
8644
8240
|
const grant = {
|
|
8645
8241
|
version: 1,
|
|
8646
8242
|
grantId: `grant-${args.runId}`,
|
|
@@ -8658,25 +8254,29 @@ async function createLocalDockerWorkload(args) {
|
|
|
8658
8254
|
}
|
|
8659
8255
|
};
|
|
8660
8256
|
const workspaceRoot = args.workspaceRoot ?? process.cwd();
|
|
8257
|
+
const workspaceMode = args.workspaceMode ?? "git";
|
|
8661
8258
|
const prepareDelivery = args.prepareWorkspaceDelivery ?? prepareHostWorkspaceDelivery;
|
|
8662
8259
|
const applyDelivery = args.applyWorkspaceDelivery ?? applyDockerWorkspaceDelivery;
|
|
8663
8260
|
let deliveryApplied = false;
|
|
8664
8261
|
const deliverWorkspace = async (runtime) => {
|
|
8665
8262
|
if (deliveryApplied) return;
|
|
8666
8263
|
deliveryApplied = true;
|
|
8667
|
-
const prepared =
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8264
|
+
const prepared = await phase("host-archive", () => {
|
|
8265
|
+
const result = prepareDelivery({ workspaceRoot });
|
|
8266
|
+
if (!result.ok) {
|
|
8267
|
+
throw new LocalWorkspaceDeliveryError(
|
|
8268
|
+
result.code,
|
|
8269
|
+
`${result.message}\uFF08\u5BBF\u4E3B\u4FA7\u6295\u9001\u51C6\u5907\u5931\u8D25\uFF0C\u672C run \u62D2\u7EDD\u8FDB\u5165\u5DE5\u5177\u5FAA\u73AF\uFF09`
|
|
8270
|
+
);
|
|
8271
|
+
}
|
|
8272
|
+
return result;
|
|
8273
|
+
});
|
|
8674
8274
|
if (args.signal?.aborted) {
|
|
8675
8275
|
await prepared.cleanup();
|
|
8676
8276
|
throw new LocalWorkspaceDeliveryError("delivery_cancelled", "run \u5DF2\u53D6\u6D88\uFF0C\u653E\u5F03\u5DE5\u4F5C\u533A\u6295\u9001\u3002");
|
|
8677
8277
|
}
|
|
8678
8278
|
try {
|
|
8679
|
-
await applyDelivery(runtime, prepared.selection);
|
|
8279
|
+
await phase("delivery", () => applyDelivery(runtime, prepared.selection));
|
|
8680
8280
|
} catch (error) {
|
|
8681
8281
|
const code = isDockerWorkspaceDeliveryError(error) ? error.code : "delivery_failed";
|
|
8682
8282
|
throw new LocalWorkspaceDeliveryError(
|
|
@@ -8725,11 +8325,39 @@ async function createLocalDockerWorkload(args) {
|
|
|
8725
8325
|
},
|
|
8726
8326
|
async (workload2, runtime) => {
|
|
8727
8327
|
if (runtime) {
|
|
8728
|
-
|
|
8729
|
-
|
|
8730
|
-
|
|
8328
|
+
await phase("sandbox-helper-upload", async () => {
|
|
8329
|
+
const uploaded = await runtime.exec(buildSandboxHelperUploadArgv());
|
|
8330
|
+
if (!uploaded.ok) {
|
|
8331
|
+
throw Object.assign(new Error("docker_helper_upload_failed"), { code: "docker_helper_upload_failed" });
|
|
8332
|
+
}
|
|
8333
|
+
});
|
|
8334
|
+
if (workspaceMode === "git") {
|
|
8335
|
+
await deliverWorkspace(runtime);
|
|
8336
|
+
} else {
|
|
8337
|
+
await phase("empty-workspace-root", async () => {
|
|
8338
|
+
const root = await runtime.exec([
|
|
8339
|
+
"bash",
|
|
8340
|
+
"-lc",
|
|
8341
|
+
`mkdir -p '${SANDBOX_WORKSPACE_ROOT}' && test -d '${SANDBOX_WORKSPACE_ROOT}' && test -w '${SANDBOX_WORKSPACE_ROOT}'`
|
|
8342
|
+
]);
|
|
8343
|
+
if (!root.ok) {
|
|
8344
|
+
throw Object.assign(new Error("docker_empty_workspace_root_failed"), { code: "docker_empty_workspace_root_failed" });
|
|
8345
|
+
}
|
|
8346
|
+
const gitInstall = await runtime.exec(buildInstallGitArgv());
|
|
8347
|
+
if (!gitInstall.ok) {
|
|
8348
|
+
throw Object.assign(
|
|
8349
|
+
new Error(`docker_empty_workspace_git_install_failed (exit ${gitInstall.exitCode})`),
|
|
8350
|
+
{ code: "docker_empty_workspace_git_install_failed" }
|
|
8351
|
+
);
|
|
8352
|
+
}
|
|
8353
|
+
const gitProbe = await runtime.exec(["bash", "-lc", "command -v git"]);
|
|
8354
|
+
if (!gitProbe.ok) {
|
|
8355
|
+
throw Object.assign(new Error("docker_empty_workspace_git_missing"), { code: "docker_empty_workspace_git_missing" });
|
|
8356
|
+
}
|
|
8357
|
+
});
|
|
8358
|
+
}
|
|
8731
8359
|
}
|
|
8732
|
-
resolveReady(workload2);
|
|
8360
|
+
await phase("ready", () => resolveReady(workload2));
|
|
8733
8361
|
await waitForReleaseOrAbort();
|
|
8734
8362
|
return void 0;
|
|
8735
8363
|
}
|
|
@@ -8786,6 +8414,7 @@ async function createLocalDockerWorkload(args) {
|
|
|
8786
8414
|
var INSTABOX_BACKEND_ID = "instabox";
|
|
8787
8415
|
var INSTABOX_DEFAULT_BASE_URL = "https://api.instabox.sh/v1";
|
|
8788
8416
|
var INSTABOX_MAX_EXEC_SECONDS = 600;
|
|
8417
|
+
var INSTABOX_MAX_STDIN_BYTES = 1024 * 1024;
|
|
8789
8418
|
var SAFE_MESSAGE3 = {
|
|
8790
8419
|
"instabox_invalid_config": "Rejected: instabox backend needs an apiKey and a templateId",
|
|
8791
8420
|
"instabox_invalid_ticket": "Rejected: execution ticket cannot be satisfied by the instabox backend",
|
|
@@ -8951,9 +8580,9 @@ var InstaboxBackend = class {
|
|
|
8951
8580
|
`create HTTP ${created.status}${created.transportError ? ` ${created.transportError}` : ""}`
|
|
8952
8581
|
);
|
|
8953
8582
|
}
|
|
8954
|
-
const
|
|
8955
|
-
const machineId = readString2(
|
|
8956
|
-
const operationId = readString2(
|
|
8583
|
+
const record = asRecord(created.payload);
|
|
8584
|
+
const machineId = readString2(record?.machineId);
|
|
8585
|
+
const operationId = readString2(record?.id);
|
|
8957
8586
|
if (!machineId || !operationId) {
|
|
8958
8587
|
throw new InstaboxBackendError(
|
|
8959
8588
|
"instabox_create_failed",
|
|
@@ -9019,12 +8648,7 @@ var InstaboxBackend = class {
|
|
|
9019
8648
|
"argv must be a non-empty array"
|
|
9020
8649
|
);
|
|
9021
8650
|
}
|
|
9022
|
-
|
|
9023
|
-
throw new InstaboxBackendError(
|
|
9024
|
-
"instabox_unsupported_request",
|
|
9025
|
-
"instabox exec has no stdin channel"
|
|
9026
|
-
);
|
|
9027
|
-
}
|
|
8651
|
+
const stdin = this.#resolveStdin(request.stdin);
|
|
9028
8652
|
const timeoutSeconds = this.#resolveExecTimeoutSeconds(request.timeoutMs);
|
|
9029
8653
|
const cmd = this.#buildCommand(request);
|
|
9030
8654
|
const executionId = `${entry.machineId}:${this.#now().toString(36)}`;
|
|
@@ -9033,7 +8657,7 @@ var InstaboxBackend = class {
|
|
|
9033
8657
|
const response = await this.#call({
|
|
9034
8658
|
method: "POST",
|
|
9035
8659
|
path: `/machines/${encodeURIComponent(entry.machineId)}/exec`,
|
|
9036
|
-
body: { cmd, timeoutSeconds }
|
|
8660
|
+
body: { cmd, timeoutSeconds, ...stdin === void 0 ? {} : { stdin } }
|
|
9037
8661
|
});
|
|
9038
8662
|
if (!isSuccess(response.status)) {
|
|
9039
8663
|
throw new InstaboxBackendError(
|
|
@@ -9161,6 +8785,27 @@ var InstaboxBackend = class {
|
|
|
9161
8785
|
}
|
|
9162
8786
|
return entry;
|
|
9163
8787
|
}
|
|
8788
|
+
/**
|
|
8789
|
+
* stdin 直通校验:`undefined` = 请求里没提供(body 里也不加字段,保持原报文兼容);
|
|
8790
|
+
* 字符串(含空串)在 1 MiB / UTF-8 字节以内原样透传;其他类型或超限立即拒绝,
|
|
8791
|
+
* 错误文案只带上限数字,**绝不回显输入内容**。
|
|
8792
|
+
*/
|
|
8793
|
+
#resolveStdin(stdin) {
|
|
8794
|
+
if (stdin === void 0) return void 0;
|
|
8795
|
+
if (typeof stdin !== "string") {
|
|
8796
|
+
throw new InstaboxBackendError(
|
|
8797
|
+
"instabox_unsupported_request",
|
|
8798
|
+
"stdin must be a string"
|
|
8799
|
+
);
|
|
8800
|
+
}
|
|
8801
|
+
if (utf8ByteLengthExceeds(stdin, INSTABOX_MAX_STDIN_BYTES)) {
|
|
8802
|
+
throw new InstaboxBackendError(
|
|
8803
|
+
"instabox_unsupported_request",
|
|
8804
|
+
`stdin exceeds the ${INSTABOX_MAX_STDIN_BYTES} byte limit`
|
|
8805
|
+
);
|
|
8806
|
+
}
|
|
8807
|
+
return stdin;
|
|
8808
|
+
}
|
|
9164
8809
|
#resolveExecTimeoutSeconds(timeoutMs) {
|
|
9165
8810
|
const boundMs = INSTABOX_MAX_EXEC_SECONDS * 1e3;
|
|
9166
8811
|
if (timeoutMs === void 0) return this.#execTimeoutSeconds;
|
|
@@ -9178,7 +8823,7 @@ var InstaboxBackend = class {
|
|
|
9178
8823
|
}
|
|
9179
8824
|
return clampExecSeconds(Math.ceil(timeoutMs / 1e3));
|
|
9180
8825
|
}
|
|
9181
|
-
/** cwd / env
|
|
8826
|
+
/** cwd / env 仍用 `cd` + 赋值前缀表达(exec body 只多一个可选 stdin,不承载 cwd/env)。 */
|
|
9182
8827
|
#buildCommand(request) {
|
|
9183
8828
|
const script = argvToInstaboxCommand(request.argv);
|
|
9184
8829
|
const segments = [];
|
|
@@ -9236,15 +8881,15 @@ var InstaboxBackend = class {
|
|
|
9236
8881
|
path: `/machines/${encodeURIComponent(machineId)}/usage`
|
|
9237
8882
|
});
|
|
9238
8883
|
if (!isSuccess(response.status)) return null;
|
|
9239
|
-
const
|
|
9240
|
-
const runningSeconds = readFiniteNumber(
|
|
8884
|
+
const record = asRecord(response.payload);
|
|
8885
|
+
const runningSeconds = readFiniteNumber(record?.runningSeconds);
|
|
9241
8886
|
if (runningSeconds === null) return null;
|
|
9242
8887
|
const sample = { runningSeconds };
|
|
9243
|
-
const vcpuSeconds = readFiniteNumber(
|
|
8888
|
+
const vcpuSeconds = readFiniteNumber(record?.vcpuSeconds);
|
|
9244
8889
|
if (vcpuSeconds !== null) sample.vcpuSeconds = vcpuSeconds;
|
|
9245
|
-
const memGiBSeconds = readFiniteNumber(
|
|
8890
|
+
const memGiBSeconds = readFiniteNumber(record?.memGiBSeconds);
|
|
9246
8891
|
if (memGiBSeconds !== null) sample.memGiBSeconds = memGiBSeconds;
|
|
9247
|
-
const diskGiBSeconds = readFiniteNumber(
|
|
8892
|
+
const diskGiBSeconds = readFiniteNumber(record?.diskGiBSeconds);
|
|
9248
8893
|
if (diskGiBSeconds !== null) sample.diskGiBSeconds = diskGiBSeconds;
|
|
9249
8894
|
return sample;
|
|
9250
8895
|
}
|
|
@@ -9264,13 +8909,13 @@ var InstaboxBackend = class {
|
|
|
9264
8909
|
path: `/operations/${encodeURIComponent(args.operationId)}?wait=${this.#operationWaitSeconds}s`
|
|
9265
8910
|
});
|
|
9266
8911
|
lastStatus = response.status;
|
|
9267
|
-
const
|
|
9268
|
-
const state = readString2(
|
|
8912
|
+
const record = isSuccess(response.status) ? asRecord(response.payload) : null;
|
|
8913
|
+
const state = readString2(record?.state);
|
|
9269
8914
|
if (state === "succeeded") return;
|
|
9270
8915
|
if (state === "failed") {
|
|
9271
8916
|
throw new InstaboxBackendError(
|
|
9272
8917
|
args.failCode,
|
|
9273
|
-
`operation ${args.operationId} failed${readString2(
|
|
8918
|
+
`operation ${args.operationId} failed${readString2(record?.error) ? `: ${readString2(record?.error)}` : ""}`,
|
|
9274
8919
|
args.cleanupPendingOnFailure
|
|
9275
8920
|
);
|
|
9276
8921
|
}
|
|
@@ -9294,6 +8939,10 @@ function truncateOutput(value, limitChars) {
|
|
|
9294
8939
|
if (value.length <= limitChars) return value;
|
|
9295
8940
|
return `${value.slice(0, limitChars)}\u2026[truncated ${value.length - limitChars} chars]`;
|
|
9296
8941
|
}
|
|
8942
|
+
function utf8ByteLengthExceeds(value, limit) {
|
|
8943
|
+
if (value.length > limit) return true;
|
|
8944
|
+
return new TextEncoder().encode(value).length > limit;
|
|
8945
|
+
}
|
|
9297
8946
|
function createInstaboxExecutionBackend(options) {
|
|
9298
8947
|
return new InstaboxBackend(options);
|
|
9299
8948
|
}
|
|
@@ -9308,6 +8957,213 @@ function asExecutionBackend(backend) {
|
|
|
9308
8957
|
};
|
|
9309
8958
|
}
|
|
9310
8959
|
|
|
8960
|
+
// packages/cli/client/localInstaboxFileBridge.ts
|
|
8961
|
+
var INSTABOX_HELPER_PATH = SANDBOX_HELPER_PATH;
|
|
8962
|
+
var INSTABOX_WORKSPACE_ROOT = "/data/home";
|
|
8963
|
+
var INSTABOX_FILE_TOOL_NAMES = [
|
|
8964
|
+
"readFile",
|
|
8965
|
+
"writeFile",
|
|
8966
|
+
"editFile",
|
|
8967
|
+
"globFiles"
|
|
8968
|
+
];
|
|
8969
|
+
var PROBE_FILE_NAME = "nolo-bridge-probe";
|
|
8970
|
+
function escapeForShell(value) {
|
|
8971
|
+
const cleaned = String(value).replace(/[^A-Za-z0-9._-]/g, "-").slice(0, 40);
|
|
8972
|
+
return cleaned || "run";
|
|
8973
|
+
}
|
|
8974
|
+
var PROBE_FILE_CONTENT = "nolo-bridge-ok";
|
|
8975
|
+
function posixQuote(value) {
|
|
8976
|
+
return `'${String(value).replace(/'/g, `'\\''`)}'`;
|
|
8977
|
+
}
|
|
8978
|
+
function buildInstaboxHelperSource(root) {
|
|
8979
|
+
const source = buildWorkspaceHelperSource();
|
|
8980
|
+
const rootLiteral = /const ROOT = "[^"]*";/;
|
|
8981
|
+
if (!rootLiteral.test(source)) {
|
|
8982
|
+
throw new Error("instabox_helper_root_patch_failed");
|
|
8983
|
+
}
|
|
8984
|
+
if (!root.startsWith("/") || root.includes('"') || root.includes("\\")) {
|
|
8985
|
+
throw new Error("instabox_invalid_workspace_root");
|
|
8986
|
+
}
|
|
8987
|
+
return source.replace(rootLiteral, `const ROOT = "${root}";`);
|
|
8988
|
+
}
|
|
8989
|
+
function buildInstaboxBridgeBootstrapScript(root, probeId) {
|
|
8990
|
+
let helperPayload;
|
|
8991
|
+
if (!root.startsWith("/") || root.includes('"') || root.includes("\\")) {
|
|
8992
|
+
return `printf 'NOLO_BRIDGE_REASON=root_unavailable
|
|
8993
|
+
'`;
|
|
8994
|
+
}
|
|
8995
|
+
try {
|
|
8996
|
+
helperPayload = Buffer.from(buildInstaboxHelperSource(root), "utf8").toString("base64");
|
|
8997
|
+
} catch (error) {
|
|
8998
|
+
return `printf 'NOLO_BRIDGE_REASON=helper_source_invalid
|
|
8999
|
+
'`;
|
|
9000
|
+
}
|
|
9001
|
+
const dir = INSTABOX_HELPER_PATH.slice(0, INSTABOX_HELPER_PATH.lastIndexOf("/"));
|
|
9002
|
+
return [
|
|
9003
|
+
`root=${posixQuote(root)}`,
|
|
9004
|
+
`mkdir -p "$root" 2>/dev/null || true`,
|
|
9005
|
+
`if [ ! -w "$root" ]; then printf 'NOLO_BRIDGE_REASON=root_unavailable\\n'; exit 0; fi`,
|
|
9006
|
+
`printf 'NOLO_BRIDGE_ROOT=%s\\n' "$root"`,
|
|
9007
|
+
"rt=''",
|
|
9008
|
+
`for cand in bun node; do if command -v "$cand" >/dev/null 2>&1; then rt="$cand"; break; fi; done`,
|
|
9009
|
+
`printf 'NOLO_BRIDGE_RUNTIME=%s\\n' "\${rt:-none}"`,
|
|
9010
|
+
`if [ -z "$rt" ]; then printf 'NOLO_BRIDGE_REASON=runtime_missing\\n'; exit 0; fi`,
|
|
9011
|
+
`mkdir -p ${posixQuote(dir)} 2>/dev/null || true`,
|
|
9012
|
+
`if ! printf %s ${posixQuote(helperPayload)} | base64 -d > ${posixQuote(INSTABOX_HELPER_PATH)}; then printf 'NOLO_BRIDGE_REASON=upload_failed\\n'; exit 0; fi`,
|
|
9013
|
+
`chmod 0644 ${posixQuote(INSTABOX_HELPER_PATH)} 2>/dev/null || true`,
|
|
9014
|
+
// 探针文件名带本次 run 的唯一 id:**只创建自己的**,绝不覆盖/删除同名既有文件
|
|
9015
|
+
`probe=$root/${escapeForShell(probeId)}-${PROBE_FILE_NAME}`,
|
|
9016
|
+
`if [ -e "$probe" ]; then printf 'NOLO_BRIDGE_REASON=probe_failed\\n'; exit 0; fi`,
|
|
9017
|
+
`printf %s ${posixQuote(PROBE_FILE_CONTENT)} > "$probe" || { printf 'NOLO_BRIDGE_REASON=upload_failed\\n'; exit 0; }`,
|
|
9018
|
+
`printf 'NOLO_BRIDGE_PROBE=%s\\n' "$probe"`,
|
|
9019
|
+
`printf 'NOLO_BRIDGE_UPLOAD=ok\\n'`
|
|
9020
|
+
].join("\n");
|
|
9021
|
+
}
|
|
9022
|
+
function parseInstaboxBootstrapOutput(stdout) {
|
|
9023
|
+
let root = null;
|
|
9024
|
+
let probePath = null;
|
|
9025
|
+
let runtime = null;
|
|
9026
|
+
let reason;
|
|
9027
|
+
let uploadOk = false;
|
|
9028
|
+
for (const rawLine of stdout.split(String.fromCharCode(10))) {
|
|
9029
|
+
const line = rawLine.trim();
|
|
9030
|
+
if (line.startsWith("NOLO_BRIDGE_ROOT=")) {
|
|
9031
|
+
const value = line.slice("NOLO_BRIDGE_ROOT=".length).trim();
|
|
9032
|
+
root = value.startsWith("/") ? value : null;
|
|
9033
|
+
} else if (line.startsWith("NOLO_BRIDGE_RUNTIME=")) {
|
|
9034
|
+
const value = line.slice("NOLO_BRIDGE_RUNTIME=".length).trim();
|
|
9035
|
+
runtime = value === "bun" || value === "node" ? value : null;
|
|
9036
|
+
} else if (line.startsWith("NOLO_BRIDGE_UPLOAD=")) {
|
|
9037
|
+
uploadOk = line.slice("NOLO_BRIDGE_UPLOAD=".length).trim() === "ok";
|
|
9038
|
+
} else if (line.startsWith("NOLO_BRIDGE_PROBE=")) {
|
|
9039
|
+
const value = line.slice("NOLO_BRIDGE_PROBE=".length).trim();
|
|
9040
|
+
probePath = value.startsWith("/") ? value : null;
|
|
9041
|
+
} else if (line.startsWith("NOLO_BRIDGE_REASON=")) {
|
|
9042
|
+
const value = line.slice("NOLO_BRIDGE_REASON=".length).trim();
|
|
9043
|
+
reason = value === "runtime_missing" || value === "root_unavailable" || value === "upload_failed" || value === "probe_failed" || value === "root_mismatch" || value === "helper_source_invalid" ? value : "probe_failed";
|
|
9044
|
+
}
|
|
9045
|
+
}
|
|
9046
|
+
if (!root) return { root: null, runtime: null, probePath: null, reason: reason ?? "root_unavailable" };
|
|
9047
|
+
if (!runtime) return { root, runtime: null, probePath, reason: reason ?? "runtime_missing" };
|
|
9048
|
+
if (!uploadOk) return { root, runtime, probePath, reason: reason ?? "upload_failed" };
|
|
9049
|
+
if (!probePath) return { root, runtime, probePath: null, reason: reason ?? "probe_failed" };
|
|
9050
|
+
return { root, runtime, probePath };
|
|
9051
|
+
}
|
|
9052
|
+
function resolveInstaboxPath(root, input) {
|
|
9053
|
+
if (typeof input !== "string" || !input.trim() || input.includes("\0")) {
|
|
9054
|
+
return { ok: false, error: "invalid_path" };
|
|
9055
|
+
}
|
|
9056
|
+
const normalizedRoot = root.endsWith("/") ? root.slice(0, -1) : root;
|
|
9057
|
+
const isAbs = input.startsWith("/");
|
|
9058
|
+
if (isAbs && input !== normalizedRoot && !input.startsWith(`${normalizedRoot}/`)) {
|
|
9059
|
+
return { ok: false, error: "path_outside_workspace" };
|
|
9060
|
+
}
|
|
9061
|
+
const resolved = isAbs ? posixNormalize(input) : posixNormalize(`${normalizedRoot}/${input}`);
|
|
9062
|
+
if (resolved !== normalizedRoot && !resolved.startsWith(`${normalizedRoot}/`)) {
|
|
9063
|
+
return { ok: false, error: "path_escape" };
|
|
9064
|
+
}
|
|
9065
|
+
return { ok: true, path: resolved };
|
|
9066
|
+
}
|
|
9067
|
+
function posixNormalize(input) {
|
|
9068
|
+
const parts = [];
|
|
9069
|
+
for (const segment of input.split("/")) {
|
|
9070
|
+
if (!segment || segment === ".") continue;
|
|
9071
|
+
if (segment === "..") {
|
|
9072
|
+
parts.pop();
|
|
9073
|
+
continue;
|
|
9074
|
+
}
|
|
9075
|
+
parts.push(segment);
|
|
9076
|
+
}
|
|
9077
|
+
return `/${parts.join("/")}`;
|
|
9078
|
+
}
|
|
9079
|
+
function buildInstaboxToolArgv(toolName, args, bridge) {
|
|
9080
|
+
const validated = {};
|
|
9081
|
+
let op;
|
|
9082
|
+
switch (toolName) {
|
|
9083
|
+
case "readFile": {
|
|
9084
|
+
const res = resolveInstaboxPath(bridge.root, String(args.path ?? ""));
|
|
9085
|
+
if (!res.ok) return { ok: false, error: res.error };
|
|
9086
|
+
op = "readFile";
|
|
9087
|
+
validated.path = res.path;
|
|
9088
|
+
if (typeof args.lines === "string") validated.lines = args.lines;
|
|
9089
|
+
break;
|
|
9090
|
+
}
|
|
9091
|
+
case "writeFile": {
|
|
9092
|
+
if (typeof args.content !== "string") return { ok: false, error: "missing_content" };
|
|
9093
|
+
if (Buffer.byteLength(args.content, "utf-8") > SANDBOX_OUTPUT_LIMITS.maxContentBytes) {
|
|
9094
|
+
return { ok: false, error: "content_too_large" };
|
|
9095
|
+
}
|
|
9096
|
+
const res = resolveInstaboxPath(bridge.root, String(args.path ?? ""));
|
|
9097
|
+
if (!res.ok) return { ok: false, error: res.error };
|
|
9098
|
+
op = "writeFile";
|
|
9099
|
+
validated.path = res.path;
|
|
9100
|
+
validated.content = args.content;
|
|
9101
|
+
break;
|
|
9102
|
+
}
|
|
9103
|
+
case "editFile": {
|
|
9104
|
+
if (typeof args.oldText !== "string" || typeof args.newText !== "string") {
|
|
9105
|
+
return { ok: false, error: "missing_edit_text" };
|
|
9106
|
+
}
|
|
9107
|
+
if (args.oldText === args.newText) return { ok: false, error: "edit_text_identical" };
|
|
9108
|
+
if (Buffer.byteLength(args.newText, "utf-8") > SANDBOX_OUTPUT_LIMITS.maxContentBytes) {
|
|
9109
|
+
return { ok: false, error: "content_too_large" };
|
|
9110
|
+
}
|
|
9111
|
+
const res = resolveInstaboxPath(bridge.root, String(args.path ?? ""));
|
|
9112
|
+
if (!res.ok) return { ok: false, error: res.error };
|
|
9113
|
+
op = "editFile";
|
|
9114
|
+
validated.path = res.path;
|
|
9115
|
+
validated.oldText = args.oldText;
|
|
9116
|
+
validated.newText = args.newText;
|
|
9117
|
+
break;
|
|
9118
|
+
}
|
|
9119
|
+
case "globFiles":
|
|
9120
|
+
case "glob": {
|
|
9121
|
+
if (typeof args.pattern !== "string" || !args.pattern.trim()) {
|
|
9122
|
+
return { ok: false, error: "missing_pattern" };
|
|
9123
|
+
}
|
|
9124
|
+
op = "glob";
|
|
9125
|
+
validated.pattern = args.pattern;
|
|
9126
|
+
if (typeof args.path === "string" && args.path.trim()) {
|
|
9127
|
+
const res = resolveInstaboxPath(bridge.root, args.path);
|
|
9128
|
+
if (!res.ok) return { ok: false, error: res.error };
|
|
9129
|
+
validated.path = res.path;
|
|
9130
|
+
}
|
|
9131
|
+
break;
|
|
9132
|
+
}
|
|
9133
|
+
default:
|
|
9134
|
+
return { ok: false, error: "unsupported_tool" };
|
|
9135
|
+
}
|
|
9136
|
+
const payload = Buffer.from(JSON.stringify({ op, args: validated }), "utf-8").toString("base64");
|
|
9137
|
+
if (payload.length > SANDBOX_OUTPUT_LIMITS.maxArgvBytes) {
|
|
9138
|
+
return { ok: false, error: "content_too_large" };
|
|
9139
|
+
}
|
|
9140
|
+
return { ok: true, argv: [bridge.runtime, INSTABOX_HELPER_PATH, payload] };
|
|
9141
|
+
}
|
|
9142
|
+
function buildInstaboxBridgeProbeRequest(bridge, probePath) {
|
|
9143
|
+
const payload = Buffer.from(
|
|
9144
|
+
JSON.stringify({ op: "readFile", args: { path: probePath } }),
|
|
9145
|
+
"utf-8"
|
|
9146
|
+
).toString("base64");
|
|
9147
|
+
return { kind: "command", argv: [bridge.runtime, INSTABOX_HELPER_PATH, payload] };
|
|
9148
|
+
}
|
|
9149
|
+
function readInstaboxProbeResult(stdout) {
|
|
9150
|
+
if (typeof stdout !== "string") return { ready: false, reason: "probe_failed" };
|
|
9151
|
+
const text = stdout.trim();
|
|
9152
|
+
if (!text) return { ready: false, reason: "probe_failed" };
|
|
9153
|
+
if (text.includes('"ok":false') || text.includes("'ok':false")) {
|
|
9154
|
+
return { ready: false, reason: "probe_failed" };
|
|
9155
|
+
}
|
|
9156
|
+
if (text.includes(PROBE_FILE_CONTENT)) return { ready: true };
|
|
9157
|
+
const parsed = parseToolOutput(text);
|
|
9158
|
+
if (!parsed.ok) return { ready: false, reason: "probe_failed" };
|
|
9159
|
+
const value = parsed.value;
|
|
9160
|
+
return typeof value === "object" && value !== null && typeof value.content === "string" && value.content.includes(PROBE_FILE_CONTENT) ? { ready: true } : { ready: false, reason: "probe_failed" };
|
|
9161
|
+
}
|
|
9162
|
+
function describeInstaboxBridgeUnavailable(bridge) {
|
|
9163
|
+
const detail = bridge.reason === "runtime_missing" ? "Instabox \u6A21\u677F\u5185\u65E2\u6CA1\u6709 bun \u4E5F\u6CA1\u6709 node\uFF0C\u5BB9\u5668\u5185 helper \u65E0\u6CD5\u6267\u884C" : bridge.reason === "root_unavailable" ? "Instabox \u5BB9\u5668\u5185\u65E0\u6CD5\u521B\u5EFA\u53EF\u5199\u5DE5\u4F5C\u76EE\u5F55" : bridge.reason === "upload_failed" ? "\u5BB9\u5668\u5185 helper \u4E0A\u4F20\u5931\u8D25" : bridge.reason === "root_mismatch" ? "\u5BB9\u5668\u5185\u56FA\u5B9A\u5DE5\u4F5C\u76EE\u5F55\u4E0E helper ROOT \u4E0D\u4E00\u81F4" : bridge.reason === "helper_source_invalid" ? "\u5171\u4EAB helper \u6E90\u7801\u5F62\u72B6\u53D8\u5316\uFF0C\u65E0\u6CD5\u5B89\u5168\u6539\u5199 ROOT" : "\u5BB9\u5668\u5185 helper \u63A2\u9488\u8BFB\u56DE\u5931\u8D25";
|
|
9164
|
+
return `instabox \u6587\u4EF6\u5DE5\u5177 bridge \u672A\u5C31\u7EEA\uFF08${bridge.reason ?? "probe_failed"}\uFF09\uFF1A${detail}\uFF1B\u6587\u4EF6\u5DE5\u5177\u5DF2\u663E\u5F0F\u62D2\u7EDD\uFF0C\u7EDD\u4E0D\u56DE\u843D\u5BBF\u4E3B\u6267\u884C\uFF08execShell \u4ECD\u53EF\u7528\uFF09\u3002`;
|
|
9165
|
+
}
|
|
9166
|
+
|
|
9311
9167
|
// packages/cli/client/localInstaboxWorkload.ts
|
|
9312
9168
|
var LOCAL_INSTABOX_BACKEND_ID = INSTABOX_BACKEND_ID;
|
|
9313
9169
|
function resolveInstaboxApiKey(env) {
|
|
@@ -9328,6 +9184,35 @@ function assertInstaboxPrerequisites(env) {
|
|
|
9328
9184
|
}
|
|
9329
9185
|
return apiKey;
|
|
9330
9186
|
}
|
|
9187
|
+
function resolveInstaboxWorkspaceRoot(env) {
|
|
9188
|
+
const override = env.INSTABOX_WORKSPACE_ROOT?.trim();
|
|
9189
|
+
if (override && override.startsWith("/") && !override.includes('"')) return override;
|
|
9190
|
+
return INSTABOX_WORKSPACE_ROOT;
|
|
9191
|
+
}
|
|
9192
|
+
function posixQuote2(value) {
|
|
9193
|
+
return `'${String(value).replace(/'/g, `'\\''`)}'`;
|
|
9194
|
+
}
|
|
9195
|
+
async function prepareFileBridge(execDirect, root, probeId) {
|
|
9196
|
+
const bootstrapStdout = await execDirect({
|
|
9197
|
+
kind: "command",
|
|
9198
|
+
argv: ["bash", "-lc", buildInstaboxBridgeBootstrapScript(root, probeId)]
|
|
9199
|
+
});
|
|
9200
|
+
const parsed = parseInstaboxBootstrapOutput(bootstrapStdout);
|
|
9201
|
+
if (!parsed.root || !parsed.runtime || !parsed.probePath || parsed.reason) {
|
|
9202
|
+
return {
|
|
9203
|
+
root: parsed.root,
|
|
9204
|
+
runtime: parsed.runtime,
|
|
9205
|
+
ready: false,
|
|
9206
|
+
reason: parsed.reason ?? "probe_failed"
|
|
9207
|
+
};
|
|
9208
|
+
}
|
|
9209
|
+
const pinned = { root: parsed.root, runtime: parsed.runtime };
|
|
9210
|
+
const probeStdout = await execDirect(
|
|
9211
|
+
buildInstaboxBridgeProbeRequest(pinned, parsed.probePath)
|
|
9212
|
+
);
|
|
9213
|
+
const verdict = readInstaboxProbeResult(probeStdout);
|
|
9214
|
+
return verdict.ready ? { root: pinned.root, runtime: pinned.runtime, ready: true } : { root: pinned.root, runtime: pinned.runtime, ready: false, reason: verdict.reason ?? "probe_failed" };
|
|
9215
|
+
}
|
|
9331
9216
|
async function createLocalInstaboxWorkload(args) {
|
|
9332
9217
|
if (args.runtimeKey.trim() !== "instabox") {
|
|
9333
9218
|
throw new LocalRuntimeKeyUnsupportedError(
|
|
@@ -9342,6 +9227,7 @@ async function createLocalInstaboxWorkload(args) {
|
|
|
9342
9227
|
templateId: args.templateId ?? args.env.INSTABOX_TEMPLATE_ID?.trim() ?? "universal"
|
|
9343
9228
|
})
|
|
9344
9229
|
);
|
|
9230
|
+
const workspaceRoot = resolveInstaboxWorkspaceRoot(args.env);
|
|
9345
9231
|
const ticket = {
|
|
9346
9232
|
version: 1,
|
|
9347
9233
|
ticketId: `ticket-${args.runId}`,
|
|
@@ -9351,12 +9237,14 @@ async function createLocalInstaboxWorkload(args) {
|
|
|
9351
9237
|
callerUserId: args.authenticatedCaller || "local-caller",
|
|
9352
9238
|
executionClass: "session",
|
|
9353
9239
|
target: { kind: "server" },
|
|
9354
|
-
|
|
9240
|
+
// 本 workload 真的会执行这些工具(shell + 容器内结构化文件工具),授权声明必须一致
|
|
9241
|
+
toolNames: [EXECUTION_SHELL_TOOL, ...INSTABOX_FILE_TOOL_NAMES],
|
|
9355
9242
|
filesystem: {
|
|
9356
|
-
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
|
|
9243
|
+
// 钉住的固定工作目录:读写范围都声明成它,不写 "none" 再偷偷写文件
|
|
9244
|
+
readScope: "configured-roots",
|
|
9245
|
+
readableRoots: [workspaceRoot],
|
|
9246
|
+
writeScope: "configured-roots",
|
|
9247
|
+
writableRoots: [workspaceRoot]
|
|
9360
9248
|
},
|
|
9361
9249
|
shellAllowed: true,
|
|
9362
9250
|
requestedIsolation: "container",
|
|
@@ -9371,37 +9259,118 @@ async function createLocalInstaboxWorkload(args) {
|
|
|
9371
9259
|
`runtimeKey \u6307\u5411 instabox\uFF0C\u4F46\u4E91\u6C99\u76D2\u521D\u59CB\u5316\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}\u3002${instaboxFailureHint}`
|
|
9372
9260
|
);
|
|
9373
9261
|
}
|
|
9262
|
+
let releaseState = "active";
|
|
9263
|
+
let releasePromise = null;
|
|
9264
|
+
const releaseBackend = () => {
|
|
9265
|
+
if (releaseState === "released") return Promise.resolve();
|
|
9266
|
+
if (releasePromise) return releasePromise;
|
|
9267
|
+
releaseState = "releasing";
|
|
9268
|
+
let attempt;
|
|
9269
|
+
try {
|
|
9270
|
+
attempt = Promise.resolve(backend.release(lease, "completed"));
|
|
9271
|
+
} catch (error) {
|
|
9272
|
+
attempt = Promise.reject(error);
|
|
9273
|
+
}
|
|
9274
|
+
releasePromise = attempt.then(
|
|
9275
|
+
() => {
|
|
9276
|
+
releaseState = "released";
|
|
9277
|
+
},
|
|
9278
|
+
(error) => {
|
|
9279
|
+
releaseState = "cleanup_pending";
|
|
9280
|
+
throw error;
|
|
9281
|
+
}
|
|
9282
|
+
).finally(() => {
|
|
9283
|
+
releasePromise = null;
|
|
9284
|
+
});
|
|
9285
|
+
return releasePromise;
|
|
9286
|
+
};
|
|
9287
|
+
const describeReleaseFailure = (error) => {
|
|
9288
|
+
const record = error;
|
|
9289
|
+
const cleanupPending = record?.cleanupPending === true || record?.code === "instabox_cleanup_pending";
|
|
9290
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
9291
|
+
return cleanupPending ? `\u4E14\u673A\u5668\u5220\u9664\u672A\u786E\u8BA4\uFF1Acleanup_pending\uFF08${detail}\uFF09\u2014\u2014\u4E91\u7AEF\u53EF\u80FD\u4ECD\u6709\u5B58\u6D3B\u673A\u5668\uFF0C\u4E0D\u5F97\u5F53\u4F5C\u5DF2\u6E05\u7406\uFF0C\u9700\u4EBA\u5DE5\u6838\u5BF9\u540E\u5220\u9664` : `\u4E14 release \u4E5F\u5931\u8D25\uFF08${detail}\uFF09`;
|
|
9292
|
+
};
|
|
9293
|
+
const execDirect = async (request) => {
|
|
9294
|
+
const result = await backend.execute(lease, request);
|
|
9295
|
+
const streams = result.output;
|
|
9296
|
+
const stdout = typeof streams?.stdout === "string" ? streams.stdout : "";
|
|
9297
|
+
const stderr = typeof streams?.stderr === "string" ? streams.stderr : "";
|
|
9298
|
+
if (result.ok === false) {
|
|
9299
|
+
throw new Error(`instabox \u5BB9\u5668\u5185\u6267\u884C\u5931\u8D25\uFF1A${stderr || `exit_code:${result.exitCode ?? "unknown"}`}`);
|
|
9300
|
+
}
|
|
9301
|
+
return stdout;
|
|
9302
|
+
};
|
|
9303
|
+
let bridge;
|
|
9304
|
+
try {
|
|
9305
|
+
bridge = await prepareFileBridge(execDirect, workspaceRoot, args.runId);
|
|
9306
|
+
} catch (error) {
|
|
9307
|
+
let cleanupNote = "\u672C\u6B21 lease \u5DF2\u91CA\u653E";
|
|
9308
|
+
try {
|
|
9309
|
+
await releaseBackend();
|
|
9310
|
+
} catch (releaseError) {
|
|
9311
|
+
cleanupNote = describeReleaseFailure(releaseError);
|
|
9312
|
+
}
|
|
9313
|
+
throw new LocalRuntimeKeyUnsupportedError(
|
|
9314
|
+
"instabox_bridge_bootstrap_failed",
|
|
9315
|
+
`runtimeKey \u6307\u5411 instabox\uFF0C\u4F46\u5BB9\u5668\u5185\u6587\u4EF6\u5DE5\u5177\u6865 bootstrap \u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}\uFF1B${cleanupNote}\u3002${instaboxFailureHint}`
|
|
9316
|
+
);
|
|
9317
|
+
}
|
|
9374
9318
|
const rawChannel = createExecutionChannel({
|
|
9375
9319
|
backend,
|
|
9376
9320
|
lease,
|
|
9377
|
-
timeoutMs: 10 * 60 * 1e3
|
|
9321
|
+
timeoutMs: 10 * 60 * 1e3,
|
|
9322
|
+
...bridge.ready && bridge.root && bridge.runtime ? {
|
|
9323
|
+
helper: {
|
|
9324
|
+
path: INSTABOX_HELPER_PATH,
|
|
9325
|
+
buildArgv: (toolName, toolArgs) => buildInstaboxToolArgv(toolName, toolArgs, {
|
|
9326
|
+
root: bridge.root,
|
|
9327
|
+
runtime: bridge.runtime
|
|
9328
|
+
})
|
|
9329
|
+
}
|
|
9330
|
+
} : {}
|
|
9378
9331
|
});
|
|
9379
|
-
let released = false;
|
|
9380
9332
|
const release = async () => {
|
|
9381
|
-
|
|
9382
|
-
released = true;
|
|
9383
|
-
try {
|
|
9384
|
-
await backend.release(lease, "completed");
|
|
9385
|
-
} catch {
|
|
9386
|
-
}
|
|
9333
|
+
await releaseBackend();
|
|
9387
9334
|
};
|
|
9388
9335
|
const channel = async (toolName, toolArgs, signal) => {
|
|
9389
|
-
if (
|
|
9336
|
+
if (releaseState !== "active") {
|
|
9390
9337
|
throw new Error(
|
|
9391
|
-
"instabox workload \u5DF2\u91CA\u653E\uFF1A\u672C run \u7684 lease \u5DF2\u5931\u6548\uFF0C\u62D2\u7EDD\u5728\u5BBF\u4E3B\u6267\u884C\u5DE5\u5177"
|
|
9338
|
+
releaseState === "cleanup_pending" ? "instabox workload cleanup_pending\uFF1A\u4E0A\u4E00\u6B21\u6E05\u7406\u672A\u786E\u8BA4\uFF0Clease \u72B6\u6001\u4E0D\u53EF\u4FE1\uFF0C\u62D2\u7EDD\u6267\u884C\u5DE5\u5177" : "instabox workload \u5DF2\u91CA\u653E\uFF1A\u672C run \u7684 lease \u5DF2\u5931\u6548\uFF0C\u62D2\u7EDD\u5728\u5BBF\u4E3B\u6267\u884C\u5DE5\u5177"
|
|
9392
9339
|
);
|
|
9393
9340
|
}
|
|
9394
9341
|
if (toolName === "execShell") {
|
|
9342
|
+
const command = typeof toolArgs.command === "string" ? toolArgs.command : void 0;
|
|
9343
|
+
if (bridge.root && command !== void 0) {
|
|
9344
|
+
return await rawChannel(EXECUTION_SHELL_TOOL, {
|
|
9345
|
+
...toolArgs,
|
|
9346
|
+
command: `cd ${posixQuote2(bridge.root)} && ${command}`
|
|
9347
|
+
}, signal);
|
|
9348
|
+
}
|
|
9395
9349
|
return await rawChannel(EXECUTION_SHELL_TOOL, toolArgs, signal);
|
|
9396
9350
|
}
|
|
9351
|
+
if (INSTABOX_FILE_TOOL_NAMES.includes(toolName)) {
|
|
9352
|
+
if (!bridge.ready) {
|
|
9353
|
+
throw new Error(describeInstaboxBridgeUnavailable(bridge));
|
|
9354
|
+
}
|
|
9355
|
+
const output = await rawChannel(toolName, toolArgs, signal);
|
|
9356
|
+
const parsed = parseToolOutput(output);
|
|
9357
|
+
if (!parsed.ok) {
|
|
9358
|
+
return JSON.stringify({ ok: false, error: parsed.error, workloadLocation: "instabox" });
|
|
9359
|
+
}
|
|
9360
|
+
const value = parsed.value;
|
|
9361
|
+
const payload = typeof value === "object" && value !== null ? { ok: true, ...value, value, workloadLocation: "instabox" } : { ok: true, value, workloadLocation: "instabox" };
|
|
9362
|
+
return JSON.stringify(payload);
|
|
9363
|
+
}
|
|
9397
9364
|
throw new Error(
|
|
9398
|
-
`instabox workload \u6682\
|
|
9365
|
+
`instabox workload \u6682\u4E0D\u652F\u6301\u5DE5\u5177 "${toolName}"\uFF08\u672C\u5757\u53EA\u6865\u63A5 readFile/writeFile/editFile/globFiles\uFF09\uFF1B\u62D2\u7EDD\u5728\u5BBF\u4E3B\u6267\u884C\u3002`
|
|
9399
9366
|
);
|
|
9400
9367
|
};
|
|
9401
9368
|
return {
|
|
9402
9369
|
backendId: LOCAL_INSTABOX_BACKEND_ID,
|
|
9403
9370
|
runId: args.runId,
|
|
9404
9371
|
channel,
|
|
9372
|
+
workspaceRoot: bridge.root,
|
|
9373
|
+
fileBridge: bridge,
|
|
9405
9374
|
release
|
|
9406
9375
|
};
|
|
9407
9376
|
}
|
|
@@ -9608,12 +9577,12 @@ function parseExecShellChannelOutput(raw) {
|
|
|
9608
9577
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
9609
9578
|
return { stdout: text, exitCode: 0, ...isTruncated(text) ? { truncated: true } : {} };
|
|
9610
9579
|
}
|
|
9611
|
-
const
|
|
9612
|
-
const output =
|
|
9613
|
-
const stdout = firstString(output?.stdout,
|
|
9614
|
-
const truncated =
|
|
9615
|
-
const explicitFailure =
|
|
9616
|
-
const rawExit =
|
|
9580
|
+
const record = parsed;
|
|
9581
|
+
const output = record.output && typeof record.output === "object" ? record.output : void 0;
|
|
9582
|
+
const stdout = firstString(output?.stdout, record.stdout, record.output, record.content) ?? "";
|
|
9583
|
+
const truncated = record.truncated === true || output?.truncated === true || isTruncated(stdout) || isTruncated(firstString(output?.stderr, record.stderr) ?? "");
|
|
9584
|
+
const explicitFailure = record.ok === false || typeof record.error === "string";
|
|
9585
|
+
const rawExit = record.exitCode ?? record.exit_code;
|
|
9617
9586
|
const exitCode = typeof rawExit === "number" ? rawExit : explicitFailure ? 1 : 0;
|
|
9618
9587
|
if (explicitFailure && stdout.trim() === "") return { stdout: "", exitCode: exitCode === 0 ? 1 : exitCode, ...truncated ? { truncated: true } : {} };
|
|
9619
9588
|
return { stdout, exitCode, ...truncated ? { truncated: true } : {} };
|
|
@@ -9661,9 +9630,9 @@ async function exportRunDiffArtifact(args) {
|
|
|
9661
9630
|
return null;
|
|
9662
9631
|
}
|
|
9663
9632
|
if (args.writeAudit) {
|
|
9664
|
-
const
|
|
9633
|
+
const record = { runId: args.runId, kind: "diff", key, ref };
|
|
9665
9634
|
try {
|
|
9666
|
-
await args.writeAudit(
|
|
9635
|
+
await args.writeAudit(record);
|
|
9667
9636
|
} catch (error) {
|
|
9668
9637
|
warn(`run \u7EC8\u6001\u5BFC\u51FA\u5BA1\u8BA1\u5199\u5165\u5931\u8D25\uFF08\u4E0D\u5F71\u54CD run \u7ED3\u679C\uFF09\uFF1A${describeError2(error)}`);
|
|
9669
9638
|
}
|
|
@@ -9740,8 +9709,8 @@ async function exportRunWorktreeDiffArtifacts(args) {
|
|
|
9740
9709
|
}
|
|
9741
9710
|
return summary;
|
|
9742
9711
|
}
|
|
9743
|
-
function serializeRunArtifactAudit(
|
|
9744
|
-
return `${JSON.stringify(
|
|
9712
|
+
function serializeRunArtifactAudit(record) {
|
|
9713
|
+
return `${JSON.stringify(record, null, 2)}
|
|
9745
9714
|
`;
|
|
9746
9715
|
}
|
|
9747
9716
|
|
|
@@ -10306,9 +10275,9 @@ async function writeLocalTokenRecord(args) {
|
|
|
10306
10275
|
function extractLastProviderInputTokens(input) {
|
|
10307
10276
|
if (input.usageRecords && input.usageRecords.length > 0) {
|
|
10308
10277
|
for (let i = input.usageRecords.length - 1; i >= 0; i--) {
|
|
10309
|
-
const
|
|
10310
|
-
if (!
|
|
10311
|
-
const normalized = normalizeUsage(
|
|
10278
|
+
const record = input.usageRecords[i];
|
|
10279
|
+
if (!record?.usage) continue;
|
|
10280
|
+
const normalized = normalizeUsage(record.usage);
|
|
10312
10281
|
if (normalized.input_tokens > 0) {
|
|
10313
10282
|
return normalized.input_tokens;
|
|
10314
10283
|
}
|
|
@@ -10491,21 +10460,21 @@ function resolveCliDialogRecordKey(userId, dialogId) {
|
|
|
10491
10460
|
}
|
|
10492
10461
|
async function loadCliDialogSummary(args) {
|
|
10493
10462
|
const dialogKey = resolveCliDialogRecordKey(args.userId, args.dialogId);
|
|
10494
|
-
const
|
|
10495
|
-
if (!
|
|
10496
|
-
const summary = typeof
|
|
10463
|
+
const record = await args.store.read(dialogKey);
|
|
10464
|
+
if (!record || typeof record !== "object") return null;
|
|
10465
|
+
const summary = typeof record.summary === "string" ? record.summary.trim() : "";
|
|
10497
10466
|
if (!summary) return null;
|
|
10498
|
-
const summarizedBeforeId =
|
|
10499
|
-
const sourceHash =
|
|
10500
|
-
const sourceCount =
|
|
10501
|
-
const schemaVersion =
|
|
10467
|
+
const summarizedBeforeId = record.summarizedBeforeId;
|
|
10468
|
+
const sourceHash = record.sourceHash;
|
|
10469
|
+
const sourceCount = record.sourceCount;
|
|
10470
|
+
const schemaVersion = record.schemaVersion;
|
|
10502
10471
|
return {
|
|
10503
10472
|
summary,
|
|
10504
10473
|
...typeof summarizedBeforeId === "string" && summarizedBeforeId ? { summarizedBeforeId } : {},
|
|
10505
10474
|
...typeof sourceHash === "string" && sourceHash ? { sourceHash } : {},
|
|
10506
10475
|
...typeof sourceCount === "number" && sourceCount > 0 ? { sourceCount } : {},
|
|
10507
|
-
..."schemaVersion" in
|
|
10508
|
-
...Array.isArray(
|
|
10476
|
+
..."schemaVersion" in record ? { schemaVersion } : {},
|
|
10477
|
+
...Array.isArray(record.referenceKeys) ? { referenceKeys: record.referenceKeys.filter((key) => typeof key === "string") } : {}
|
|
10509
10478
|
};
|
|
10510
10479
|
}
|
|
10511
10480
|
async function saveCliDialogSummary(args) {
|
|
@@ -10534,9 +10503,9 @@ async function saveCliDialogSummary(args) {
|
|
|
10534
10503
|
}
|
|
10535
10504
|
async function loadCliDialogLastContextUsage(args) {
|
|
10536
10505
|
const dialogKey = resolveCliDialogRecordKey(args.userId, args.dialogId);
|
|
10537
|
-
const
|
|
10538
|
-
if (!
|
|
10539
|
-
const lastInputTokens =
|
|
10506
|
+
const record = await args.store.read(dialogKey, { remote: false });
|
|
10507
|
+
if (!record || typeof record !== "object") return null;
|
|
10508
|
+
const lastInputTokens = record.lastInputTokens;
|
|
10540
10509
|
if (typeof lastInputTokens === "number" && Number.isFinite(lastInputTokens) && lastInputTokens > 0) {
|
|
10541
10510
|
return { inputTokens: lastInputTokens };
|
|
10542
10511
|
}
|
|
@@ -10553,6 +10522,36 @@ function parseTitleUpdatedAtMs(existingDialog) {
|
|
|
10553
10522
|
}
|
|
10554
10523
|
|
|
10555
10524
|
// packages/cli/client/localRuntimeAdapter.ts
|
|
10525
|
+
var LOCAL_INSTABOX_TOOL_NAMES = [
|
|
10526
|
+
EXECUTION_SHELL_TOOL,
|
|
10527
|
+
...INSTABOX_FILE_TOOL_NAMES
|
|
10528
|
+
];
|
|
10529
|
+
function resolveLocalInstaboxToolRoute(args) {
|
|
10530
|
+
const toolName = normalizeLocalToolName(args.toolName);
|
|
10531
|
+
if (!LOCAL_INSTABOX_TOOL_NAMES.includes(toolName)) {
|
|
10532
|
+
return WORKSPACE_TOOL_NAMES.includes(toolName) ? {
|
|
10533
|
+
action: "reject",
|
|
10534
|
+
toolName,
|
|
10535
|
+
reason: `instabox workload \u4E0D\u652F\u6301\u5DE5\u4F5C\u533A\u5DE5\u5177 "${toolName}"\uFF08instabox \u5DE5\u5177\u9762\uFF1A${LOCAL_INSTABOX_TOOL_NAMES.join(", ")}\uFF09\uFF1B\u62D2\u7EDD\u56DE\u843D\u5230\u5BBF\u4E3B\u6267\u884C`
|
|
10536
|
+
} : { action: "passthrough", toolName };
|
|
10537
|
+
}
|
|
10538
|
+
const agentToolNames = (args.agentToolNames ?? []).map(
|
|
10539
|
+
normalizeLocalToolName
|
|
10540
|
+
);
|
|
10541
|
+
const deniedBySurfaceOrPolicy = !agentToolNames.includes(toolName) || !resolveLocalToolPolicy({
|
|
10542
|
+
env: args.env ?? {},
|
|
10543
|
+
agentToolNames,
|
|
10544
|
+
toolName
|
|
10545
|
+
}).allowed;
|
|
10546
|
+
if (deniedBySurfaceOrPolicy) {
|
|
10547
|
+
return {
|
|
10548
|
+
action: "reject",
|
|
10549
|
+
toolName,
|
|
10550
|
+
reason: `${toolName} is outside the run tool surface / policy \u2014 instabox workload \u4E0D\u662F\u7ED5\u8FC7 deny \u7684\u901A\u9053\uFF1B\u62D2\u7EDD\u5728\u5BBF\u4E3B\u6267\u884C\u5DE5\u4F5C\u533A\u5DE5\u5177`
|
|
10551
|
+
};
|
|
10552
|
+
}
|
|
10553
|
+
return { action: "intercept", toolName };
|
|
10554
|
+
}
|
|
10556
10555
|
var currentMetaFile = fileURLToPath(import.meta.url);
|
|
10557
10556
|
var isJsBundle = extname(currentMetaFile) === ".js";
|
|
10558
10557
|
var SOURCE_CLI_DIR = isJsBundle ? dirname4(currentMetaFile) : dirname4(dirname4(currentMetaFile));
|
|
@@ -10592,13 +10591,13 @@ async function recordLocalAvailabilityForAgent(args) {
|
|
|
10592
10591
|
);
|
|
10593
10592
|
return typeof entry?.nextAvailableAt === "number" ? entry.nextAvailableAt : action.nextAvailableAt;
|
|
10594
10593
|
}
|
|
10595
|
-
const
|
|
10596
|
-
if (action.kind === "clear" && !("nextAvailableAt" in
|
|
10597
|
-
const next = { ...
|
|
10594
|
+
const record = current;
|
|
10595
|
+
if (action.kind === "clear" && !("nextAvailableAt" in record)) return void 0;
|
|
10596
|
+
const next = { ...record };
|
|
10598
10597
|
let effectiveNextAvailableAt;
|
|
10599
10598
|
if (action.kind === "mark") {
|
|
10600
10599
|
const merged = mergeAvailabilityDeadline(
|
|
10601
|
-
|
|
10600
|
+
record.nextAvailableAt,
|
|
10602
10601
|
action.nextAvailableAt
|
|
10603
10602
|
);
|
|
10604
10603
|
next.nextAvailableAt = merged;
|
|
@@ -10640,13 +10639,13 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
10640
10639
|
const additionalToolNames = deps.pastedTextStore ? ["readPastedText"] : [];
|
|
10641
10640
|
const resolveAgentCredentialGroup = async (agentRef) => {
|
|
10642
10641
|
try {
|
|
10643
|
-
const
|
|
10642
|
+
const record = await readAgentFromStore({
|
|
10644
10643
|
agentRef,
|
|
10645
10644
|
store: await getOrCreateSharedStore(deps),
|
|
10646
10645
|
userId
|
|
10647
10646
|
});
|
|
10648
|
-
if (!
|
|
10649
|
-
const rec =
|
|
10647
|
+
if (!record || typeof record !== "object") return void 0;
|
|
10648
|
+
const rec = record;
|
|
10650
10649
|
const existing = typeof rec.credentialGroup === "string" && rec.credentialGroup.trim() ? rec.credentialGroup.trim() : void 0;
|
|
10651
10650
|
if (existing) return existing;
|
|
10652
10651
|
const ref = typeof rec.apiKeyRef === "string" && rec.apiKeyRef.trim() ? rec.apiKeyRef : typeof rec.credentialRef === "string" && rec.credentialRef.trim() ? rec.credentialRef : void 0;
|
|
@@ -10660,13 +10659,13 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
10660
10659
|
};
|
|
10661
10660
|
const resolveAgentDisplayName = async (agentRef) => {
|
|
10662
10661
|
try {
|
|
10663
|
-
const
|
|
10662
|
+
const record = await readAgentFromStore({
|
|
10664
10663
|
agentRef,
|
|
10665
10664
|
store: await getOrCreateSharedStore(deps),
|
|
10666
10665
|
userId
|
|
10667
10666
|
});
|
|
10668
|
-
if (!
|
|
10669
|
-
const name =
|
|
10667
|
+
if (!record || typeof record !== "object") return void 0;
|
|
10668
|
+
const name = record.name;
|
|
10670
10669
|
return typeof name === "string" && name.trim() ? name.trim() : void 0;
|
|
10671
10670
|
} catch {
|
|
10672
10671
|
return void 0;
|
|
@@ -10674,12 +10673,12 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
10674
10673
|
};
|
|
10675
10674
|
const resolveAgentRuntimeBindingMachineId = async (agentRef) => {
|
|
10676
10675
|
try {
|
|
10677
|
-
const
|
|
10676
|
+
const record = await readAgentFromStore({
|
|
10678
10677
|
agentRef,
|
|
10679
10678
|
store: await getOrCreateSharedStore(deps),
|
|
10680
10679
|
userId
|
|
10681
10680
|
});
|
|
10682
|
-
const rec =
|
|
10681
|
+
const rec = record;
|
|
10683
10682
|
const binding = asRecordOrEmpty(rec?.runtimeBinding);
|
|
10684
10683
|
return asOptionalTrimmedString(binding.machineId);
|
|
10685
10684
|
} catch {
|
|
@@ -10723,16 +10722,24 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
10723
10722
|
authenticatedCaller: resolveLocalUserId(deps.env),
|
|
10724
10723
|
agentKey: "cli-local-run",
|
|
10725
10724
|
env: deps.env,
|
|
10726
|
-
workspaceRoot
|
|
10725
|
+
workspaceRoot,
|
|
10726
|
+
...deps.dockerWorkspaceMode ? { workspaceMode: deps.dockerWorkspaceMode } : {}
|
|
10727
10727
|
}))();
|
|
10728
10728
|
return dockerWorkloadLoad;
|
|
10729
10729
|
};
|
|
10730
10730
|
const instaboxRuntimeEnabled = runtimeKey === "instabox";
|
|
10731
10731
|
let instaboxWorkloadLoad = null;
|
|
10732
10732
|
let instaboxWorkloadReleased = false;
|
|
10733
|
+
let instaboxReleasePending = false;
|
|
10734
|
+
let instaboxReleasePromise = null;
|
|
10733
10735
|
const createInstaboxWorkload = deps.createLocalInstaboxWorkload ?? createLocalInstaboxWorkload;
|
|
10734
10736
|
const loadLocalInstaboxWorkload = () => {
|
|
10735
10737
|
if (!instaboxRuntimeEnabled) return Promise.resolve(null);
|
|
10738
|
+
if (instaboxReleasePending) {
|
|
10739
|
+
return Promise.reject(
|
|
10740
|
+
new Error("instabox workload cleanup_pending\uFF1Alease cleanup \u5C1A\u672A\u786E\u8BA4\uFF0C\u62D2\u7EDD\u6267\u884C\u5DE5\u5177")
|
|
10741
|
+
);
|
|
10742
|
+
}
|
|
10736
10743
|
if (instaboxWorkloadReleased) {
|
|
10737
10744
|
return Promise.reject(
|
|
10738
10745
|
new Error(
|
|
@@ -10759,7 +10766,7 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
10759
10766
|
const recordRunExecutionIsolation = async () => {
|
|
10760
10767
|
try {
|
|
10761
10768
|
const { writeFileSync: writeFileSync4, mkdirSync: mkdirSync4 } = await import("node:fs");
|
|
10762
|
-
const { resolveRunsDir } = await import("./agentRunControl-
|
|
10769
|
+
const { resolveRunsDir } = await import("./agentRunControl-XBSNHHZE.js");
|
|
10763
10770
|
const fact = resolveLocalRunExecutionIsolationFact({
|
|
10764
10771
|
// F1:显式点名宿主执行的 run 在审计里必须与 docker 沙盒区分开
|
|
10765
10772
|
// (reason: host-explicit-writes vs docker-workload)。
|
|
@@ -10791,7 +10798,7 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
10791
10798
|
dockerWorkloadReleased = true;
|
|
10792
10799
|
dockerWorkloadLoad = null;
|
|
10793
10800
|
if (loaded) {
|
|
10794
|
-
const { resolveRunsDir } = await import("./agentRunControl-
|
|
10801
|
+
const { resolveRunsDir } = await import("./agentRunControl-XBSNHHZE.js");
|
|
10795
10802
|
const exportRunDiff = deps.exportDockerRunDiffArtifact ?? exportDockerRunDiffArtifact;
|
|
10796
10803
|
const warn = (message) => process.stderr.write(`[nolo] ${message}
|
|
10797
10804
|
`);
|
|
@@ -10814,13 +10821,34 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
10814
10821
|
const loadLocalSandboxWorkload = () => localSandboxLoad ??= createSandboxWorkload({ workspaceRoot }).catch(
|
|
10815
10822
|
() => null
|
|
10816
10823
|
);
|
|
10817
|
-
const releaseLocalInstaboxWorkload =
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
+
const releaseLocalInstaboxWorkload = () => {
|
|
10825
|
+
if (instaboxReleasePromise) return instaboxReleasePromise;
|
|
10826
|
+
const attempt = (async () => {
|
|
10827
|
+
const loaded = instaboxWorkloadLoad ? await instaboxWorkloadLoad.catch(() => null) : null;
|
|
10828
|
+
if (!loaded) {
|
|
10829
|
+
instaboxWorkloadReleased = true;
|
|
10830
|
+
instaboxWorkloadLoad = null;
|
|
10831
|
+
return;
|
|
10832
|
+
}
|
|
10833
|
+
try {
|
|
10834
|
+
await loaded.release();
|
|
10835
|
+
instaboxWorkloadReleased = true;
|
|
10836
|
+
instaboxReleasePending = false;
|
|
10837
|
+
instaboxWorkloadLoad = null;
|
|
10838
|
+
} catch (error) {
|
|
10839
|
+
instaboxReleasePending = true;
|
|
10840
|
+
const record = error;
|
|
10841
|
+
const code = record?.code === "instabox_cleanup_pending" || record?.cleanupPending === true ? "cleanup_pending" : "release_failed";
|
|
10842
|
+
process.stderr.write(`[nolo] instabox_release_${code}
|
|
10843
|
+
`);
|
|
10844
|
+
throw error;
|
|
10845
|
+
}
|
|
10846
|
+
})();
|
|
10847
|
+
instaboxReleasePromise = attempt;
|
|
10848
|
+
void attempt.finally(() => {
|
|
10849
|
+
if (instaboxReleasePromise === attempt) instaboxReleasePromise = null;
|
|
10850
|
+
}).catch(() => void 0);
|
|
10851
|
+
return attempt;
|
|
10824
10852
|
};
|
|
10825
10853
|
const releaseLocalSandboxWorkload = async () => {
|
|
10826
10854
|
await releaseLocalDockerWorkload();
|
|
@@ -11297,18 +11325,30 @@ function createCliLocalRuntimeAdapter(deps) {
|
|
|
11297
11325
|
}
|
|
11298
11326
|
}
|
|
11299
11327
|
if (instaboxRuntimeEnabled) {
|
|
11300
|
-
const
|
|
11301
|
-
|
|
11302
|
-
|
|
11328
|
+
const instaboxRoute = resolveLocalInstaboxToolRoute({
|
|
11329
|
+
toolName: call.name,
|
|
11330
|
+
env: deps.env,
|
|
11331
|
+
agentToolNames: activeAgentToolNames
|
|
11332
|
+
});
|
|
11333
|
+
if (instaboxRoute.action === "reject") {
|
|
11334
|
+
throw new Error(instaboxRoute.reason);
|
|
11335
|
+
}
|
|
11336
|
+
if (instaboxRoute.action === "intercept") {
|
|
11337
|
+
const instaboxHandle = await loadLocalInstaboxWorkload();
|
|
11338
|
+
if (!instaboxHandle) {
|
|
11339
|
+
throw new Error(
|
|
11340
|
+
`instabox workload \u4E0D\u53EF\u7528\uFF08\u65E0 handle\uFF09\uFF1A\u62D2\u7EDD\u5728\u5BBF\u4E3B\u6267\u884C\u5DE5\u4F5C\u533A\u5DE5\u5177 "${instaboxRoute.toolName}"`
|
|
11341
|
+
);
|
|
11342
|
+
}
|
|
11303
11343
|
const instaboxArgs = parseToolArgumentsObject(injectedCall.arguments) ?? {};
|
|
11304
11344
|
const instaboxOutput = await instaboxHandle.channel(
|
|
11305
|
-
|
|
11345
|
+
instaboxRoute.toolName,
|
|
11306
11346
|
instaboxArgs,
|
|
11307
11347
|
opts?.abortSignal
|
|
11308
11348
|
);
|
|
11309
11349
|
if (typeof instaboxOutput !== "string") {
|
|
11310
11350
|
throw new Error(
|
|
11311
|
-
`instabox workload \u672A\u8FD4\u56DE\u7ED3\u679C\uFF08tool=${
|
|
11351
|
+
`instabox workload \u672A\u8FD4\u56DE\u7ED3\u679C\uFF08tool=${instaboxRoute.toolName}\uFF09\uFF1A\u62D2\u7EDD\u56DE\u843D\u5230\u5BBF\u4E3B\u6267\u884C`
|
|
11312
11352
|
);
|
|
11313
11353
|
}
|
|
11314
11354
|
return { content: instaboxOutput };
|
|
@@ -11506,6 +11546,7 @@ export {
|
|
|
11506
11546
|
loadCliDialogSummary,
|
|
11507
11547
|
saveCliDialogSummary,
|
|
11508
11548
|
loadCliDialogLastContextUsage,
|
|
11549
|
+
resolveLocalInstaboxToolRoute,
|
|
11509
11550
|
recordLocalAvailabilityForAgent,
|
|
11510
11551
|
setCliAutoCompactionSummaryFallback,
|
|
11511
11552
|
getCliAutoCompactionSummaryFallback,
|