nolo-cli 0.54.0 → 0.61.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/{_executeModel-OPTKYHJA.js → _executeModel-CKT6RGTL.js} +48 -45
- package/{action-ORXWW2ZG.js → action-76JX3JX3.js} +7 -6
- package/{addContentAction-53BZ34AE.js → addContentAction-V3NAZRTJ.js} +6 -5
- package/{addDialogAgentAction-JRYUS54Y.js → addDialogAgentAction-RZOAF46K.js} +5 -4
- package/{agentDeleteCommand-FJIWU2BS.js → agentDeleteCommand-VN7NPXQ4.js} +30 -27
- package/{agentEmailCommands-CE32L43B.js → agentEmailCommands-F2TNAV4A.js} +59 -56
- package/{agentGrantCommands-2LEZDADN.js → agentGrantCommands-R3VQEZJR.js} +1 -1
- package/{agentListCommands-VJNKULIK.js → agentListCommands-OSM2ANI3.js} +61 -31
- package/{agentMachineCommands-HCJ3WQXL.js → agentMachineCommands-MTPWYVRV.js} +31 -28
- package/{agentPullCommand-M552CYSI.js → agentPullCommand-N7L2CT7L.js} +2 -2
- package/{agentRecordCommands-QFWERED4.js → agentRecordCommands-VWAWTVVC.js} +57 -54
- package/{agentRunCommand-G3GQMUNN.js → agentRunCommand-PLZOBNVK.js} +61 -58
- package/{agentRunControl-INKFDXDA.js → agentRunControl-WECMOO6O.js} +11 -6
- package/{agentRuntimeLocal-K327ELSL.js → agentRuntimeLocal-XCJLRWQE.js} +26 -23
- package/{agentSlice-ODKF4J6M.js → agentSlice-F6DOP4IW.js} +8 -7
- package/{appDeleteCommands-XUXMFDI4.js → appDeleteCommands-3BCFTRFJ.js} +30 -27
- package/{appDeployCommands-37F4GPCU.js → appDeployCommands-B4GMHCYA.js} +30 -27
- package/{appDeployStatusCommands-WSPU7TUK.js → appDeployStatusCommands-4MN36WIG.js} +30 -27
- package/{appGetCommands-YLOBA3EM.js → appGetCommands-4GJIEUAX.js} +30 -27
- package/{appListCommands-UD62R5ME.js → appListCommands-CHU53GSX.js} +30 -27
- package/{authCommand-OK6HLHGS.js → authCommand-WOTWLJNF.js} +35 -29
- package/{authCommands-2DUIUEMT.js → authCommands-ILTBI6JV.js} +7 -5
- package/{chatQueueReduxAdapter-TV2TUOQS.js → chatQueueReduxAdapter-HNSQXNIR.js} +20 -18
- package/{chunk-HPW5MNDQ.js → chunk-22BTGNSP.js} +113 -57
- package/{chunk-TR4DXUYX.js → chunk-2HPRMEEZ.js} +1180 -736
- package/{chunk-UNZDCI3O.js → chunk-2KDR4CWE.js} +35 -4
- package/{chunk-3ZTR7ZO4.js → chunk-2PGGC63K.js} +1 -1
- package/{chunk-JXIP6ZWH.js → chunk-37QVS7BU.js} +18 -5
- package/{chunk-EA5OYZVD.js → chunk-37XDGCY7.js} +1 -1
- package/chunk-3BLB7QKO.js +433 -0
- package/{chunk-CS6TCJ7E.js → chunk-3JQ2NRYU.js} +30 -7
- package/{chunk-RHMDMTDK.js → chunk-3JWKQDA4.js} +2 -2
- package/{chunk-3LKZRP7E.js → chunk-3QGUVVX5.js} +2 -2
- package/{chunk-SSXTSPSG.js → chunk-45YO6H7P.js} +71 -30
- package/{chunk-EJE33XNR.js → chunk-4C4ST2YE.js} +1521 -565
- package/{chunk-YLCUU3WM.js → chunk-4NJEIGBQ.js} +5 -5
- package/{chunk-K4NISKOR.js → chunk-5ZYA4JJ3.js} +47 -17
- package/{chunk-3Y2K5O2R.js → chunk-7A3RRUCQ.js} +125 -40
- package/{chunk-5FCIPEKT.js → chunk-7O7KH4X5.js} +1051 -926
- package/{chunk-6HDYSFLO.js → chunk-7UF7CQ6B.js} +3 -3
- package/{chunk-SUEIAK5N.js → chunk-AQMVUA7N.js} +1 -0
- package/{chunk-WQHGJHAL.js → chunk-AVE2YR4F.js} +732 -726
- package/{chunk-6COJEAYH.js → chunk-B7DXRX7F.js} +44 -37
- package/chunk-BFU6C242.js +66 -0
- package/{chunk-IA3A5373.js → chunk-C3FZR5EC.js} +1 -1
- package/{chunk-IWUMSAQF.js → chunk-CJCJF5XB.js} +26 -3
- package/{chunk-UGBHDMHI.js → chunk-CP7VIDZ7.js} +1 -1
- package/{chunk-JON2PHYT.js → chunk-CTCW7U7N.js} +1 -1
- package/{chunk-YBFJQC2M.js → chunk-D5XKNNUV.js} +65 -42
- package/{chunk-7NYDJAQ7.js → chunk-DNNSCSA2.js} +5 -5
- package/{chunk-NI2BS6UD.js → chunk-DWUCB2A3.js} +1 -1
- package/{chunk-AA564GBL.js → chunk-DZZL7UBV.js} +1 -1
- package/{chunk-75MSWWUE.js → chunk-E6RGHPDR.js} +5 -3
- package/chunk-EDKF7RX4.js +30 -0
- package/{chunk-FJHMLRDQ.js → chunk-ES6CVKVD.js} +21 -27
- package/{chunk-SYYUU7EV.js → chunk-FHAGENAS.js} +2 -3
- package/{chunk-NJUQBYFJ.js → chunk-FKFMIBTT.js} +3 -1
- package/{chunk-INZZJSQF.js → chunk-FZGV4FGK.js} +24 -12
- package/{chunk-YQBXOHE6.js → chunk-GAL47RNP.js} +1 -1
- package/{chunk-UOWXD4VN.js → chunk-HBPV76EK.js} +335 -243
- package/{chunk-MLEZPE3U.js → chunk-HLU5Q2GV.js} +4 -4
- package/{chunk-TC6P4NDR.js → chunk-HQP7HJDL.js} +6 -6
- package/{chunk-7FAS3NEF.js → chunk-IYCUMIYS.js} +19 -15
- package/{chunk-AUVFJGPC.js → chunk-JX5PJCWS.js} +7 -5
- package/{chunk-LYGNQHUW.js → chunk-JYYZCK2Z.js} +2 -4
- package/{chunk-XOJRZUPF.js → chunk-KWSQR2KK.js} +14 -29
- package/{chunk-2WBFJHQA.js → chunk-L7B47JXR.js} +34 -39
- package/{chunk-EICIFHVS.js → chunk-LAFC3B2I.js} +1 -1
- package/{chunk-N4JKMCY3.js → chunk-LJKICKVC.js} +2 -2
- package/chunk-M3JEW6N6.js +193 -0
- package/{chunk-LRGKOI5Y.js → chunk-MBOEV4L2.js} +7 -3
- package/{chunk-SVDMVX4G.js → chunk-MMZ6ZTVO.js} +112 -73
- package/{chunk-JDSUTNYY.js → chunk-MP64VFGD.js} +2 -2
- package/{chunk-NFLA6GSU.js → chunk-MXUDQZXQ.js} +44 -5
- package/chunk-N4G4PKQ6.js +23 -0
- package/{chunk-KXKQO4Q6.js → chunk-NTW5GWDM.js} +58 -1
- package/chunk-ONXOABJR.js +215 -0
- package/{chunk-TY3ADTX5.js → chunk-OZX2IPKM.js} +7 -2
- package/{chunk-Q4XZVZPN.js → chunk-P7OOB7QP.js} +1 -1
- package/{chunk-XIJZOCSP.js → chunk-PEZJEQAO.js} +1 -1
- package/{chunk-SWJGJMTW.js → chunk-PQDIDWGX.js} +1 -1
- package/chunk-PSCNXBYA.js +11 -0
- package/{chunk-BY2FF2C4.js → chunk-QEFJJS2I.js} +55 -73
- package/{chunk-BG7J6Y5X.js → chunk-QEW2MFDQ.js} +1 -1
- package/{chunk-KLIBF3BY.js → chunk-RDBARW6T.js} +8 -3
- package/{chunk-ZVOHVJI3.js → chunk-RJ2SAFB5.js} +82 -35
- package/{chunk-MYMBBB6Q.js → chunk-RVWRKFUB.js} +5 -3
- package/{chunk-43CXXVJD.js → chunk-RXX4GDIH.js} +1 -1
- package/chunk-SEJ5OS6F.js +49 -0
- package/{chunk-SAJSBPI2.js → chunk-SOJM57FX.js} +5 -2
- package/{chunk-EKLRRZIN.js → chunk-SPAQ4PVV.js} +0 -5
- package/{chunk-L7NG2M6H.js → chunk-TRV2MIDW.js} +89 -74
- package/{chunk-5UAYZEXO.js → chunk-UZPQSVM6.js} +1 -1
- package/{chunk-SVC3GGUA.js → chunk-VMWYBIXG.js} +7 -5
- package/{chunk-ZHXJ6M7T.js → chunk-W7XHHYWM.js} +4 -0
- package/{chunk-UR66XPVF.js → chunk-XAVSS3KE.js} +21 -3
- package/{chunk-A65UV3M5.js → chunk-XOKOSO35.js} +10 -19
- package/{chunk-VZMUOPYG.js → chunk-XTJTN3RW.js} +46 -3
- package/{chunk-T5HJEUQN.js → chunk-YCDWJX45.js} +1 -1
- package/{chunk-BBTN4NQD.js → chunk-Z4QSJILV.js} +85 -13
- package/{chunk-O5FLGN2L.js → chunk-ZRSJ3JEH.js} +6 -2
- package/{cliExecutor-BBUVQU4L.js → cliExecutor-HG3S345O.js} +1 -1
- package/{codingSkills-BCQXRZOI.js → codingSkills-VDXQYWX4.js} +2 -2
- package/{contentThunks-KNI6VXLT.js → contentThunks-7YG2ZYQC.js} +21 -19
- package/{cooldownCommands-GI5NNWGL.js → cooldownCommands-BSCH2W7P.js} +2 -2
- package/{createAgentAutomationAction-OK4L33KF.js → createAgentAutomationAction-PJQSCAIO.js} +23 -21
- package/{createDialogAction-JDSMY4AY.js → createDialogAction-SFEJX6SP.js} +23 -21
- package/{createPageAction-T7RA3HCG.js → createPageAction-B7WRHOQO.js} +24 -22
- package/{dbSlice-TVX6SN2T.js → dbSlice-IBVOBVMS.js} +5 -4
- package/{deleteFile-JYKRT7C3.js → deleteFile-FWP2PSBG.js} +3 -2
- package/{dialogCommands-UQZYWOOV.js → dialogCommands-VL2X22QC.js} +30 -27
- package/{dialogSlice-TYW2G7IL.js → dialogSlice-ANMACABO.js} +20 -18
- package/{docCreateCommands-OA6HZBWO.js → docCreateCommands-ITLGZ5YI.js} +29 -26
- package/{docDeleteCommands-KBB3YQI2.js → docDeleteCommands-LH3YNL4C.js} +30 -27
- package/{docReadCommands-ZLMFVC67.js → docReadCommands-YAJ77F36.js} +29 -26
- package/{docStore-2URPBVCS.js → docStore-D4HGHPWI.js} +6 -5
- package/{docUpdateCommands-HMH5KUON.js → docUpdateCommands-DQBOMH2G.js} +29 -26
- package/{getPricing-RFOPUWHY.js → getPricing-NM3NUTAS.js} +4 -4
- package/handleSendMessageAction-DF2OABGW.js +675 -0
- package/index.js +79 -88
- package/{lib-2ZTNRXR4.js → lib-FRRS27KN.js} +63 -28
- package/{localRuntimeAuthority-KQDAE64E.js → localRuntimeAuthority-R5UBODT3.js} +6 -4
- package/{localRuntimeDb-PF7CFKDL.js → localRuntimeDb-P37ZTX55.js} +1 -1
- package/{machineCommands-RK6L7ZWL.js → machineCommands-JXDYQ5LB.js} +296 -79
- package/{machineWsRunDispatch-3X64DW2Z.js → machineWsRunDispatch-3QHI7JX5.js} +55 -52
- package/{memberThunks-THZYZFSN.js → memberThunks-VZI6G7YZ.js} +10 -8
- package/{models-JVKUEER5.js → models-FAMINFZ7.js} +2 -2
- package/package.json +3 -2
- package/{read-K4JU4MQC.js → read-2BYWW7AA.js} +3 -2
- package/{readDocTool-LQGR6FUN.js → readDocTool-LC3A7QTB.js} +1 -1
- package/{readlineWorkspace-XUFJV3RS.js → readlineWorkspace-KVZTEAHB.js} +4365 -2795
- package/{removeDialogAgentAction-ECHCFB7N.js → removeDialogAgentAction-SFYZXHNK.js} +8 -7
- package/{runAgentClientLoop-24GQ2AW6.js → runAgentClientLoop-KGTEL7ZP.js} +49 -45
- package/{runtimeDoctorCommands-JKTTN723.js → runtimeDoctorCommands-CROTMULY.js} +7 -5
- package/{setDialogExtraReferencesAction-KCVJNGMB.js → setDialogExtraReferencesAction-Q32RGFTA.js} +6 -5
- package/{setPrimaryDialogAgentAction-VDOBOMKC.js → setPrimaryDialogAgentAction-BFYJHUJS.js} +8 -7
- package/{settingSlice-VR2IJSXC.js → settingSlice-IRUU4VFB.js} +6 -5
- package/{skillDiscovery-2QTZINON.js → skillDiscovery-NTRLM6KP.js} +1 -1
- package/{spaceCommands-S5YJJXL7.js → spaceCommands-KNAYWMCZ.js} +33 -215
- package/{streamAgentChatTurn-QHKP3ABO.js → streamAgentChatTurn-FLYPTXKZ.js} +105 -73
- package/{switchDialogAgentAction-5L4UP7VI.js → switchDialogAgentAction-L2KOKCGG.js} +5 -4
- package/{tableCommands-R6WFRDYF.js → tableCommands-SUNTHAYX.js} +1 -1
- package/{toolApiClient-53U4UDFF.js → toolApiClient-VGYUB4P5.js} +2 -1
- package/{tools-SSXSTC3O.js → tools-CVLUXK6P.js} +37 -34
- package/{tuiSummaryLlmCaller-URFJHFC5.js → tuiSummaryLlmCaller-F3DPFFZM.js} +15 -13
- package/{updateCommands-IYKLF3JX.js → updateCommands-AJYSD73Y.js} +2 -2
- package/{updateDialogTitleAction-YFYAEW3T.js → updateDialogTitleAction-HWJIZEIV.js} +23 -21
- package/agentSuperviseCommands-5AR3DKNN.js +0 -640
- package/chunk-6IGD47IC.js +0 -19
- package/chunk-FD36SCCD.js +0 -105
- package/chunk-GRFK2XP4.js +0 -230
- package/chunk-HJTAGT3W.js +0 -370
- package/handleSendMessageAction-GO53TY7U.js +0 -409
|
@@ -6,18 +6,17 @@ import {
|
|
|
6
6
|
flushChatCompletionStream,
|
|
7
7
|
providerHttpFailure,
|
|
8
8
|
readSseFrames,
|
|
9
|
+
streamSseDataValues,
|
|
9
10
|
throwIfChatCompletionStreamFailed
|
|
10
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-7A3RRUCQ.js";
|
|
11
12
|
import {
|
|
12
|
-
FRESH_TOOL_OUTPUT_MAX_CHARS,
|
|
13
|
-
MAX_HISTORICAL_TOOL_CONTENT_CHARS,
|
|
14
13
|
clipToolText,
|
|
15
14
|
hasImageInRuntimeMessages,
|
|
16
15
|
resolveAgentImageInputSupport,
|
|
17
16
|
resolveHistoricalToolContentCap,
|
|
18
17
|
resolveToolOutputProfile,
|
|
19
18
|
stripImagePartsFromMessages
|
|
20
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-XOKOSO35.js";
|
|
21
20
|
import {
|
|
22
21
|
downgradeUnparsableToolCalls,
|
|
23
22
|
hasParsableObjectArguments,
|
|
@@ -32,7 +31,6 @@ import {
|
|
|
32
31
|
} from "./chunk-N7J63Q6C.js";
|
|
33
32
|
import {
|
|
34
33
|
TOOL_GUIDED_SECTION_ORDER,
|
|
35
|
-
buildCurrentTimeBlock,
|
|
36
34
|
buildIdentityBlock,
|
|
37
35
|
buildRuntimeGuidanceBlocks,
|
|
38
36
|
estimateContextTokens,
|
|
@@ -41,7 +39,7 @@ import {
|
|
|
41
39
|
requiresBareImageUrl,
|
|
42
40
|
resolveToolGuidedSections,
|
|
43
41
|
toBareImageUrlMessages
|
|
44
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-QEFJJS2I.js";
|
|
45
43
|
import {
|
|
46
44
|
convertMessagesToResponsesInput,
|
|
47
45
|
extractReasoningFromResponseOutput,
|
|
@@ -51,19 +49,25 @@ import {
|
|
|
51
49
|
shouldStripReasoningContentForOutbound,
|
|
52
50
|
toOpenAiCompatibleMessages,
|
|
53
51
|
toResponsesTools
|
|
54
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-XTJTN3RW.js";
|
|
53
|
+
import {
|
|
54
|
+
getAntigravityUserAgent,
|
|
55
|
+
readAntigravityProjectId,
|
|
56
|
+
resolveAntigravityCloudCodeBaseUrl
|
|
57
|
+
} from "./chunk-QEW2MFDQ.js";
|
|
55
58
|
import {
|
|
56
59
|
buildProviderAuthHeaders,
|
|
57
60
|
buildProviderExecutionPlan
|
|
58
|
-
} from "./chunk-
|
|
61
|
+
} from "./chunk-RDBARW6T.js";
|
|
59
62
|
import {
|
|
60
63
|
NOLO_WORKSPACE_TOOL_NAMES,
|
|
64
|
+
applyToolSurfaceConstraints,
|
|
61
65
|
buildNoloWorkspaceCommandArgs,
|
|
62
66
|
noloPositiveIntegerString,
|
|
63
67
|
noloStringArg,
|
|
64
68
|
parseNoloWorkspaceToolArguments,
|
|
65
69
|
resolveNoloDialogInput
|
|
66
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-RJ2SAFB5.js";
|
|
67
71
|
import {
|
|
68
72
|
buildDialogFallbackTitleFromUserInput
|
|
69
73
|
} from "./chunk-2MBTWINN.js";
|
|
@@ -76,7 +80,7 @@ import {
|
|
|
76
80
|
resolveEmptyAssistantFallbackMessage,
|
|
77
81
|
resolveEmptyAssistantOutcome,
|
|
78
82
|
resolveTruncatedReasoningTailLog
|
|
79
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-5ZYA4JJ3.js";
|
|
80
84
|
import {
|
|
81
85
|
COMPACTION_SUMMARY_SCHEMA_VERSION,
|
|
82
86
|
COMPACTION_SUMMARY_SYSTEM_PROMPT,
|
|
@@ -84,16 +88,23 @@ import {
|
|
|
84
88
|
buildCompactionMetricsFromPlan,
|
|
85
89
|
buildCompactionUserContent,
|
|
86
90
|
clipCompactText,
|
|
87
|
-
|
|
91
|
+
createProviderCallTimingTracker,
|
|
92
|
+
finalizeProviderCallTiming,
|
|
88
93
|
formatCompactionMetricsLog,
|
|
89
94
|
formatFileOperationsFromMessages,
|
|
90
95
|
formatMessagesForSummaryWithTruncation,
|
|
96
|
+
isMeaningfulResponsesOutput,
|
|
97
|
+
observeMeaningfulProviderResponse,
|
|
91
98
|
planCompression,
|
|
92
|
-
planContextUsage
|
|
93
|
-
|
|
99
|
+
planContextUsage,
|
|
100
|
+
withProviderCallTimingFields
|
|
101
|
+
} from "./chunk-Z4QSJILV.js";
|
|
102
|
+
import {
|
|
103
|
+
estimateTokenCount
|
|
104
|
+
} from "./chunk-PSCNXBYA.js";
|
|
94
105
|
import {
|
|
95
106
|
resolveNoloStateDir
|
|
96
|
-
} from "./chunk-
|
|
107
|
+
} from "./chunk-ONXOABJR.js";
|
|
97
108
|
import {
|
|
98
109
|
toErrorMessage
|
|
99
110
|
} from "./chunk-HNMXYYJR.js";
|
|
@@ -693,14 +704,14 @@ var make2 = (isEquivalent) => (self, that) => self === that || isEquivalent(self
|
|
|
693
704
|
var isArrayNonEmpty = (self) => self.length > 0;
|
|
694
705
|
|
|
695
706
|
// node_modules/effect/dist/internal/doNotation.js
|
|
696
|
-
var let_ = (
|
|
707
|
+
var let_ = (map8) => dual(3, (self, name, f) => map8(self, (a) => ({
|
|
697
708
|
...a,
|
|
698
709
|
[name]: f(a)
|
|
699
710
|
})));
|
|
700
|
-
var bindTo = (
|
|
711
|
+
var bindTo = (map8) => dual(2, (self, name) => map8(self, (a) => ({
|
|
701
712
|
[name]: a
|
|
702
713
|
})));
|
|
703
|
-
var bind = (
|
|
714
|
+
var bind = (map8, flatMap6) => dual(3, (self, name, f) => flatMap6(self, (a) => map8(f(a), (b) => ({
|
|
704
715
|
...a,
|
|
705
716
|
[name]: b
|
|
706
717
|
}))));
|
|
@@ -2002,22 +2013,22 @@ var makeImpl = (cacheRoot, base, overlay, depth) => {
|
|
|
2002
2013
|
self.baseHits = 0;
|
|
2003
2014
|
return self;
|
|
2004
2015
|
};
|
|
2005
|
-
var applyOverlays = (
|
|
2016
|
+
var applyOverlays = (map8, overlay) => {
|
|
2006
2017
|
if (!overlay) return;
|
|
2007
|
-
applyOverlays(
|
|
2008
|
-
|
|
2018
|
+
applyOverlays(map8, overlay.parent);
|
|
2019
|
+
map8.set(overlay.key, overlay.value);
|
|
2009
2020
|
};
|
|
2010
2021
|
var flatten3 = (self) => {
|
|
2011
2022
|
if (self._flat) return self._flat;
|
|
2012
2023
|
if (!self.overlay) return self._flat = self.base;
|
|
2013
|
-
const
|
|
2014
|
-
applyOverlays(
|
|
2015
|
-
return self._flat =
|
|
2024
|
+
const map8 = new Map(self.base);
|
|
2025
|
+
applyOverlays(map8, self.overlay);
|
|
2026
|
+
return self._flat = map8;
|
|
2016
2027
|
};
|
|
2017
2028
|
var withFlat = (self, f) => {
|
|
2018
|
-
const
|
|
2019
|
-
f(
|
|
2020
|
-
return makeUnsafe(
|
|
2029
|
+
const map8 = new Map(self.mapUnsafe);
|
|
2030
|
+
f(map8);
|
|
2031
|
+
return makeUnsafe(map8);
|
|
2021
2032
|
};
|
|
2022
2033
|
var notFound = /* @__PURE__ */ Symbol();
|
|
2023
2034
|
var lookup = (self, key) => {
|
|
@@ -2077,9 +2088,9 @@ var addUnsafe = (self, key, service4) => {
|
|
|
2077
2088
|
const impl = self;
|
|
2078
2089
|
const cacheRoot = cacheKeys.has(key) ? void 0 : impl.cacheRoot;
|
|
2079
2090
|
if (impl.depth >= MaxDepth) {
|
|
2080
|
-
const
|
|
2081
|
-
|
|
2082
|
-
return makeImpl(cacheRoot,
|
|
2091
|
+
const map8 = new Map(impl.mapUnsafe);
|
|
2092
|
+
map8.set(key, service4);
|
|
2093
|
+
return makeImpl(cacheRoot, map8, void 0, 0);
|
|
2083
2094
|
}
|
|
2084
2095
|
return makeImpl(cacheRoot, impl.base, {
|
|
2085
2096
|
key,
|
|
@@ -2125,16 +2136,16 @@ var getOption = /* @__PURE__ */ dual(2, (self, service4) => {
|
|
|
2125
2136
|
var merge = /* @__PURE__ */ dual(2, (self, that) => {
|
|
2126
2137
|
if (self.mapUnsafe.size === 0) return that;
|
|
2127
2138
|
if (that.mapUnsafe.size === 0) return self;
|
|
2128
|
-
return withFlat(self, (
|
|
2139
|
+
return withFlat(self, (map8) => that.mapUnsafe.forEach((value, key) => map8.set(key, value)));
|
|
2129
2140
|
});
|
|
2130
2141
|
var mergeAll = (...ctxs) => {
|
|
2131
|
-
const
|
|
2142
|
+
const map8 = /* @__PURE__ */ new Map();
|
|
2132
2143
|
for (let i = 0; i < ctxs.length; i++) {
|
|
2133
2144
|
ctxs[i].mapUnsafe.forEach((value, key) => {
|
|
2134
|
-
|
|
2145
|
+
map8.set(key, value);
|
|
2135
2146
|
});
|
|
2136
2147
|
}
|
|
2137
|
-
return makeUnsafe(
|
|
2148
|
+
return makeUnsafe(map8);
|
|
2138
2149
|
};
|
|
2139
2150
|
var Reference = Service;
|
|
2140
2151
|
|
|
@@ -2726,6 +2737,15 @@ var ReducerSum = /* @__PURE__ */ make(sum, zero);
|
|
|
2726
2737
|
var CombinerMax = /* @__PURE__ */ max(Order);
|
|
2727
2738
|
var CombinerMin = /* @__PURE__ */ min(Order);
|
|
2728
2739
|
|
|
2740
|
+
// node_modules/effect/dist/Filter.js
|
|
2741
|
+
var composePassthrough = /* @__PURE__ */ dual(2, (left, right) => (input) => {
|
|
2742
|
+
const leftOut = left(input);
|
|
2743
|
+
if (isFailure2(leftOut)) return fail2(input);
|
|
2744
|
+
const rightOut = right(leftOut.success);
|
|
2745
|
+
if (isFailure2(rightOut)) return fail2(input);
|
|
2746
|
+
return rightOut;
|
|
2747
|
+
});
|
|
2748
|
+
|
|
2729
2749
|
// node_modules/effect/dist/Scheduler.js
|
|
2730
2750
|
var Scheduler = /* @__PURE__ */ Reference("effect/Scheduler", {
|
|
2731
2751
|
fiberCached: true,
|
|
@@ -3955,7 +3975,7 @@ var flatMapEager = /* @__PURE__ */ dual(2, (self, f) => {
|
|
|
3955
3975
|
var flatten4 = (self) => flatMap2(self, identity);
|
|
3956
3976
|
var map3 = /* @__PURE__ */ dual(2, (self, f) => flatMap2(self, (a) => succeed3(internalCall(() => f(a)))));
|
|
3957
3977
|
var mapEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMap(self, f) : map3(self, f));
|
|
3958
|
-
var mapErrorEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMapError(self, f) :
|
|
3978
|
+
var mapErrorEager = /* @__PURE__ */ dual(2, (self, f) => effectIsExit(self) ? exitMapError(self, f) : mapError2(self, f));
|
|
3959
3979
|
var mapBothEager = /* @__PURE__ */ dual(2, (self, options) => effectIsExit(self) ? exitMapBoth(self, options) : mapBoth(self, options));
|
|
3960
3980
|
var catchEager = /* @__PURE__ */ dual(2, (self, f) => {
|
|
3961
3981
|
if (effectIsExit(self)) {
|
|
@@ -3968,8 +3988,16 @@ var catchEager = /* @__PURE__ */ dual(2, (self, f) => {
|
|
|
3968
3988
|
});
|
|
3969
3989
|
var exitInterrupt = (fiberId3) => exitFailCause(causeInterrupt(fiberId3));
|
|
3970
3990
|
var exitIsSuccess = (self) => self._tag === "Success";
|
|
3991
|
+
var exitFilterSuccess = (self) => self._tag === "Success" ? succeed2(self) : fail2(self);
|
|
3992
|
+
var exitFilterValue = (self) => self._tag === "Success" ? succeed2(self.value) : fail2(self);
|
|
3971
3993
|
var exitIsFailure = (self) => self._tag === "Failure";
|
|
3994
|
+
var exitFilterFailure = (self) => self._tag === "Failure" ? succeed2(self) : fail2(self);
|
|
3972
3995
|
var exitFilterCause = (self) => self._tag === "Failure" ? succeed2(self.cause) : fail2(self);
|
|
3996
|
+
var exitFindError = /* @__PURE__ */ composePassthrough(exitFilterCause, findError);
|
|
3997
|
+
var exitFindDefect = /* @__PURE__ */ composePassthrough(exitFilterCause, findDefect);
|
|
3998
|
+
var exitHasInterrupts = (self) => self._tag === "Failure" && hasInterrupts(self.cause);
|
|
3999
|
+
var exitHasDies = (self) => self._tag === "Failure" && hasDies(self.cause);
|
|
4000
|
+
var exitHasFails = (self) => self._tag === "Failure" && hasFails(self.cause);
|
|
3973
4001
|
var exitVoid = /* @__PURE__ */ exitSucceed(void 0);
|
|
3974
4002
|
var exitMap = /* @__PURE__ */ dual(2, (self, f) => self._tag === "Success" ? exitSucceed(f(self.value)) : self);
|
|
3975
4003
|
var exitMapError = /* @__PURE__ */ dual(2, (self, f) => {
|
|
@@ -3984,8 +4012,10 @@ var exitMapBoth = /* @__PURE__ */ dual(2, (self, options) => {
|
|
|
3984
4012
|
if (isFailure2(error)) return self;
|
|
3985
4013
|
return exitFail(options.onFailure(error.success));
|
|
3986
4014
|
});
|
|
4015
|
+
var exitAs = /* @__PURE__ */ dual(2, (self, b) => exitIsSuccess(self) ? exitSucceed(b) : self);
|
|
3987
4016
|
var exitZipRight = /* @__PURE__ */ dual(2, (self, that) => exitIsSuccess(self) ? that : self);
|
|
3988
4017
|
var exitMatch = /* @__PURE__ */ dual(2, (self, options) => exitIsSuccess(self) ? options.onSuccess(self.value) : options.onFailure(self.cause));
|
|
4018
|
+
var exitAsVoid = /* @__PURE__ */ exitAs(void 0);
|
|
3989
4019
|
var exitAsVoidAll = (exits) => {
|
|
3990
4020
|
const failures = [];
|
|
3991
4021
|
for (const exit3 of exits) {
|
|
@@ -3995,6 +4025,12 @@ var exitAsVoidAll = (exits) => {
|
|
|
3995
4025
|
}
|
|
3996
4026
|
return failures.length === 0 ? exitVoid : exitFailCause(causeFromReasons(failures));
|
|
3997
4027
|
};
|
|
4028
|
+
var exitGetSuccess = (self) => exitIsSuccess(self) ? some2(self.value) : none2();
|
|
4029
|
+
var exitGetCause = (self) => exitIsFailure(self) ? some2(self.cause) : none2();
|
|
4030
|
+
var exitFindErrorOption = (self) => {
|
|
4031
|
+
const error = exitFindError(self);
|
|
4032
|
+
return isFailure2(error) ? none2() : some2(error.success);
|
|
4033
|
+
};
|
|
3998
4034
|
var service = (service4) => service4;
|
|
3999
4035
|
var serviceOption = (service4) => withFiber((fiber3) => succeed3(getOption(fiber3.context, service4)));
|
|
4000
4036
|
var serviceOptional = (service4) => withFiber((fiber3) => fromOption2(getOption(fiber3.context, service4)));
|
|
@@ -4156,7 +4192,7 @@ var unwrapReason = /* @__PURE__ */ dual(2, (self, errorTag) => catchFilter(self,
|
|
|
4156
4192
|
}
|
|
4157
4193
|
return fail2(e);
|
|
4158
4194
|
}, fail3));
|
|
4159
|
-
var
|
|
4195
|
+
var mapError2 = /* @__PURE__ */ dual(2, (self, f) => catch_(self, (error) => failSync(() => f(error))));
|
|
4160
4196
|
var mapBoth = /* @__PURE__ */ dual(2, (self, options) => matchEffect(self, {
|
|
4161
4197
|
onFailure: (e) => failSync(() => options.onFailure(e)),
|
|
4162
4198
|
onSuccess: (a) => sync(() => options.onSuccess(a))
|
|
@@ -4979,8 +5015,8 @@ var runPromiseExitWith = (context3) => {
|
|
|
4979
5015
|
const runFork3 = runForkWith(context3);
|
|
4980
5016
|
return (effect, options) => {
|
|
4981
5017
|
const fiber3 = runFork3(effect, options);
|
|
4982
|
-
return new Promise((
|
|
4983
|
-
fiber3.addObserver((exit3) =>
|
|
5018
|
+
return new Promise((resolve5) => {
|
|
5019
|
+
fiber3.addObserver((exit3) => resolve5(exit3));
|
|
4984
5020
|
});
|
|
4985
5021
|
};
|
|
4986
5022
|
};
|
|
@@ -5638,7 +5674,7 @@ __export(Effect_exports, {
|
|
|
5638
5674
|
annotateSpans: () => annotateSpans2,
|
|
5639
5675
|
as: () => as3,
|
|
5640
5676
|
asSome: () => asSome2,
|
|
5641
|
-
asVoid: () =>
|
|
5677
|
+
asVoid: () => asVoid4,
|
|
5642
5678
|
awaitAllChildren: () => awaitAllChildren2,
|
|
5643
5679
|
bind: () => bind4,
|
|
5644
5680
|
bindTo: () => bindTo4,
|
|
@@ -5724,11 +5760,11 @@ __export(Effect_exports, {
|
|
|
5724
5760
|
logWithLevel: () => logWithLevel2,
|
|
5725
5761
|
makeSpan: () => makeSpan2,
|
|
5726
5762
|
makeSpanScoped: () => makeSpanScoped2,
|
|
5727
|
-
map: () =>
|
|
5728
|
-
mapBoth: () =>
|
|
5763
|
+
map: () => map5,
|
|
5764
|
+
mapBoth: () => mapBoth3,
|
|
5729
5765
|
mapBothEager: () => mapBothEager2,
|
|
5730
5766
|
mapEager: () => mapEager2,
|
|
5731
|
-
mapError: () =>
|
|
5767
|
+
mapError: () => mapError4,
|
|
5732
5768
|
mapErrorEager: () => mapErrorEager2,
|
|
5733
5769
|
match: () => match6,
|
|
5734
5770
|
matchCause: () => matchCause2,
|
|
@@ -5853,6 +5889,36 @@ __export(Effect_exports, {
|
|
|
5853
5889
|
});
|
|
5854
5890
|
|
|
5855
5891
|
// node_modules/effect/dist/Exit.js
|
|
5892
|
+
var Exit_exports = {};
|
|
5893
|
+
__export(Exit_exports, {
|
|
5894
|
+
asVoid: () => asVoid3,
|
|
5895
|
+
asVoidAll: () => asVoidAll,
|
|
5896
|
+
die: () => die3,
|
|
5897
|
+
fail: () => fail4,
|
|
5898
|
+
failCause: () => failCause2,
|
|
5899
|
+
filterCause: () => filterCause,
|
|
5900
|
+
filterFailure: () => filterFailure,
|
|
5901
|
+
filterSuccess: () => filterSuccess,
|
|
5902
|
+
filterValue: () => filterValue,
|
|
5903
|
+
findDefect: () => findDefect2,
|
|
5904
|
+
findError: () => findError3,
|
|
5905
|
+
findErrorOption: () => findErrorOption2,
|
|
5906
|
+
getCause: () => getCause,
|
|
5907
|
+
getSuccess: () => getSuccess3,
|
|
5908
|
+
hasDies: () => hasDies2,
|
|
5909
|
+
hasFails: () => hasFails3,
|
|
5910
|
+
hasInterrupts: () => hasInterrupts2,
|
|
5911
|
+
interrupt: () => interrupt2,
|
|
5912
|
+
isExit: () => isExit2,
|
|
5913
|
+
isFailure: () => isFailure4,
|
|
5914
|
+
isSuccess: () => isSuccess4,
|
|
5915
|
+
map: () => map4,
|
|
5916
|
+
mapBoth: () => mapBoth2,
|
|
5917
|
+
mapError: () => mapError3,
|
|
5918
|
+
match: () => match5,
|
|
5919
|
+
succeed: () => succeed4,
|
|
5920
|
+
void: () => void_3
|
|
5921
|
+
});
|
|
5856
5922
|
var isExit2 = isExit;
|
|
5857
5923
|
var succeed4 = exitSucceed;
|
|
5858
5924
|
var failCause2 = exitFailCause;
|
|
@@ -5862,7 +5928,24 @@ var interrupt2 = exitInterrupt;
|
|
|
5862
5928
|
var void_3 = exitVoid;
|
|
5863
5929
|
var isSuccess4 = exitIsSuccess;
|
|
5864
5930
|
var isFailure4 = exitIsFailure;
|
|
5931
|
+
var hasFails3 = exitHasFails;
|
|
5932
|
+
var hasDies2 = exitHasDies;
|
|
5933
|
+
var hasInterrupts2 = exitHasInterrupts;
|
|
5934
|
+
var filterSuccess = exitFilterSuccess;
|
|
5935
|
+
var filterValue = exitFilterValue;
|
|
5936
|
+
var filterFailure = exitFilterFailure;
|
|
5937
|
+
var filterCause = exitFilterCause;
|
|
5938
|
+
var findError3 = exitFindError;
|
|
5939
|
+
var findDefect2 = exitFindDefect;
|
|
5865
5940
|
var match5 = exitMatch;
|
|
5941
|
+
var map4 = exitMap;
|
|
5942
|
+
var mapError3 = exitMapError;
|
|
5943
|
+
var mapBoth2 = exitMapBoth;
|
|
5944
|
+
var asVoid3 = exitAsVoid;
|
|
5945
|
+
var asVoidAll = exitAsVoidAll;
|
|
5946
|
+
var getSuccess3 = exitGetSuccess;
|
|
5947
|
+
var getCause = exitGetCause;
|
|
5948
|
+
var findErrorOption2 = exitFindErrorOption;
|
|
5866
5949
|
|
|
5867
5950
|
// node_modules/effect/dist/Deferred.js
|
|
5868
5951
|
var TypeId5 = "~effect/Deferred";
|
|
@@ -6639,10 +6722,10 @@ var tap3 = tap2;
|
|
|
6639
6722
|
var result2 = result;
|
|
6640
6723
|
var option2 = option;
|
|
6641
6724
|
var exit2 = exit;
|
|
6642
|
-
var
|
|
6725
|
+
var map5 = map3;
|
|
6643
6726
|
var as3 = as2;
|
|
6644
6727
|
var asSome2 = asSome;
|
|
6645
|
-
var
|
|
6728
|
+
var asVoid4 = asVoid2;
|
|
6646
6729
|
var flip2 = flip;
|
|
6647
6730
|
var zip2 = zip;
|
|
6648
6731
|
var zipWith3 = zipWith2;
|
|
@@ -6659,8 +6742,8 @@ var catchFilter2 = catchFilter;
|
|
|
6659
6742
|
var catchNoSuchElement2 = catchNoSuchElement;
|
|
6660
6743
|
var catchCauseIf2 = catchCauseIf;
|
|
6661
6744
|
var catchCauseFilter2 = catchCauseFilter;
|
|
6662
|
-
var
|
|
6663
|
-
var
|
|
6745
|
+
var mapError4 = mapError2;
|
|
6746
|
+
var mapBoth3 = mapBoth;
|
|
6664
6747
|
var orDie2 = orDie;
|
|
6665
6748
|
var tapError2 = tapError;
|
|
6666
6749
|
var tapErrorTag2 = tapErrorTag;
|
|
@@ -7309,7 +7392,7 @@ var makeAtomicUnbounded = (options) => {
|
|
|
7309
7392
|
};
|
|
7310
7393
|
var shutdown = (self) => uninterruptible2(withFiber2((fiber3) => {
|
|
7311
7394
|
set2(self.shutdownFlag, true);
|
|
7312
|
-
return close(self.scope, interrupt2(fiber3.id)).pipe(andThen3(self.strategy.shutdown), when2(self.shutdownHook.open),
|
|
7395
|
+
return close(self.scope, interrupt2(fiber3.id)).pipe(andThen3(self.strategy.shutdown), when2(self.shutdownHook.open), asVoid4);
|
|
7313
7396
|
}));
|
|
7314
7397
|
var publish = /* @__PURE__ */ dual(2, (self, value) => suspend2(() => {
|
|
7315
7398
|
if (self.shutdownFlag.current) {
|
|
@@ -7348,7 +7431,7 @@ var unsubscribe = (self) => uninterruptible2(withFiber2((state) => {
|
|
|
7348
7431
|
self.subscription.unsubscribe();
|
|
7349
7432
|
self.replayWindow.close();
|
|
7350
7433
|
self.strategy.onPubSubEmptySpaceUnsafe(self.pubsub, self.subscribers);
|
|
7351
|
-
})), when2(self.shutdownHook.open),
|
|
7434
|
+
})), when2(self.shutdownHook.open), asVoid4);
|
|
7352
7435
|
}));
|
|
7353
7436
|
var take2 = (self) => suspend2(() => {
|
|
7354
7437
|
if (self.shutdownFlag.current) {
|
|
@@ -8959,7 +9042,7 @@ var asyncQueue = (scope3, f, options) => make12({
|
|
|
8959
9042
|
capacity: options?.bufferSize,
|
|
8960
9043
|
strategy: options?.strategy
|
|
8961
9044
|
}).pipe(tap3((queue) => addFinalizer2(scope3, shutdown2(queue))), tap3((queue) => forkIn2(provide(f(queue), scope3), scope3)));
|
|
8962
|
-
var callbackArray = (f, options) => fromTransform((_, scope3) =>
|
|
9045
|
+
var callbackArray = (f, options) => fromTransform((_, scope3) => map5(asyncQueue(scope3, f, options), takeAll3));
|
|
8963
9046
|
var suspend3 = (evaluate2) => fromTransform((upstream, scope3) => suspend2(() => toTransform(evaluate2())(upstream, scope3)));
|
|
8964
9047
|
var acquireUseRelease3 = (acquire, use, release2) => fromTransformBracket(fnUntraced2(function* (upstream, scope3, forkedScope) {
|
|
8965
9048
|
let option3 = none2();
|
|
@@ -9015,8 +9098,8 @@ var fromEffectDrain = (effect) => fromPull(flatMap3(effect, () => done2()));
|
|
|
9015
9098
|
var fromEffectTake = (effect) => fromPull(succeed5(flatMap3(effect, toPull)));
|
|
9016
9099
|
var fromQueueArray = (queue) => fromPull(succeed5(takeAll3(queue)));
|
|
9017
9100
|
var fromSubscriptionArray = (subscription) => fromPull(succeed5(onInterrupt2(takeAll2(subscription), () => done2())));
|
|
9018
|
-
var fromPubSubArray = (pubsub) => unwrap(
|
|
9019
|
-
var fromPubSubTake = (pubsub) => unwrap(
|
|
9101
|
+
var fromPubSubArray = (pubsub) => unwrap(map5(subscribe(pubsub), fromSubscriptionArray));
|
|
9102
|
+
var fromPubSubTake = (pubsub) => unwrap(map5(subscribe(pubsub), (sub) => fromEffectTake(take2(sub))));
|
|
9020
9103
|
var fromReadableStream = (options) => fromTransform((_, scope3) => readableStreamToPullUnsafe({
|
|
9021
9104
|
scope: scope3,
|
|
9022
9105
|
readable: options.evaluate(),
|
|
@@ -9054,16 +9137,16 @@ var fromAsyncIterable = (iterable, onError5) => fromTransform(fnUntraced2(functi
|
|
|
9054
9137
|
catch: onError5
|
|
9055
9138
|
}), (result4) => result4.done ? done2(result4.value) : succeed5(result4.value));
|
|
9056
9139
|
}));
|
|
9057
|
-
var fromAsyncIterableArray = (iterable, onError5) =>
|
|
9058
|
-
var
|
|
9140
|
+
var fromAsyncIterableArray = (iterable, onError5) => map6(fromAsyncIterable(iterable, onError5), of);
|
|
9141
|
+
var map6 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync2(() => {
|
|
9059
9142
|
let i = 0;
|
|
9060
|
-
return
|
|
9143
|
+
return map5(pull, (o) => f(o, i++));
|
|
9061
9144
|
})));
|
|
9062
9145
|
var concurrencyIsSequential = (concurrency) => concurrency === void 0 || concurrency !== "unbounded" && concurrency <= 1;
|
|
9063
9146
|
var mapEffect = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self, f, options) => concurrencyIsSequential(options?.concurrency) ? mapEffectSequential(self, f) : mapEffectConcurrent(self, f, options));
|
|
9064
9147
|
var mapEffectSequential = (self, f) => fromTransform((upstream, scope3) => {
|
|
9065
9148
|
let i = 0;
|
|
9066
|
-
return
|
|
9149
|
+
return map5(toTransform(self)(upstream, scope3), flatMap3((o) => f(o, i++)));
|
|
9067
9150
|
});
|
|
9068
9151
|
var mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntraced2(function* (upstream, scope3, forkedScope) {
|
|
9069
9152
|
let i = 0;
|
|
@@ -9111,7 +9194,7 @@ var mapEffectConcurrent = (self, f, options) => fromTransformBracket(fnUntraced2
|
|
|
9111
9194
|
return take3(queue);
|
|
9112
9195
|
}));
|
|
9113
9196
|
var flatMap4 = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self, f, options) => concurrencyIsSequential(options?.concurrency) ? flatMapSequential(self, f) : flatMapConcurrent(self, f, options));
|
|
9114
|
-
var flatMapSequential = (self, f) => fromTransform((upstream, scope3) =>
|
|
9197
|
+
var flatMapSequential = (self, f) => fromTransform((upstream, scope3) => map5(toTransform(self)(upstream, scope3), (pull) => {
|
|
9115
9198
|
let childPull;
|
|
9116
9199
|
let childScope;
|
|
9117
9200
|
const makePull = flatMap3(pull, (value) => {
|
|
@@ -9132,7 +9215,7 @@ var flatMapSequential = (self, f) => fromTransform((upstream, scope3) => map4(to
|
|
|
9132
9215
|
});
|
|
9133
9216
|
return suspend2(() => childPull ?? makePull);
|
|
9134
9217
|
}));
|
|
9135
|
-
var flatMapConcurrent = (self, f, options) => self.pipe(
|
|
9218
|
+
var flatMapConcurrent = (self, f, options) => self.pipe(map6(f), mergeAll3(options));
|
|
9136
9219
|
var concatWith = /* @__PURE__ */ dual(2, (self, f) => fromTransform((upstream, scope3) => sync2(() => {
|
|
9137
9220
|
let currentPull;
|
|
9138
9221
|
const forkedScope = forkUnsafe2(scope3);
|
|
@@ -9153,7 +9236,7 @@ var combine2 = /* @__PURE__ */ dual(4, (self, that, s, f) => fromTransform(fnUnt
|
|
|
9153
9236
|
let state = s();
|
|
9154
9237
|
return suspend2(() => {
|
|
9155
9238
|
const combinedPull = f(state, leftPull, rightPull);
|
|
9156
|
-
return
|
|
9239
|
+
return map5(combinedPull, ([a, s1]) => {
|
|
9157
9240
|
state = s1;
|
|
9158
9241
|
return a;
|
|
9159
9242
|
});
|
|
@@ -9206,20 +9289,20 @@ var flattenTake = (self) => mapEffectSequential(self, toPull);
|
|
|
9206
9289
|
var drain = (self) => transformPull(self, (pull) => succeed5(forever4(pull, {
|
|
9207
9290
|
disableYield: true
|
|
9208
9291
|
})));
|
|
9209
|
-
var repeat4 = /* @__PURE__ */ dual(2, (self, schedule4) => toStepWithMetadata(typeof schedule4 === "function" ? schedule4(identity) : schedule4).pipe(
|
|
9292
|
+
var repeat4 = /* @__PURE__ */ dual(2, (self, schedule4) => toStepWithMetadata(typeof schedule4 === "function" ? schedule4(identity) : schedule4).pipe(map5((step) => {
|
|
9210
9293
|
let meta = CurrentMetadata2.defaultValue();
|
|
9211
|
-
const loop = concatWith(provideServiceEffect3(self, CurrentMetadata2, sync2(() => meta)), (done4) => step(done4).pipe(
|
|
9294
|
+
const loop = concatWith(provideServiceEffect3(self, CurrentMetadata2, sync2(() => meta)), (done4) => step(done4).pipe(map5((meta_) => {
|
|
9212
9295
|
meta = meta_;
|
|
9213
9296
|
return loop;
|
|
9214
9297
|
}), catchDone(() => succeed5(end2(done4))), unwrap));
|
|
9215
9298
|
return loop;
|
|
9216
9299
|
}), unwrap));
|
|
9217
9300
|
var forever5 = (self) => concatWith(self, () => forever5(self));
|
|
9218
|
-
var schedule2 = /* @__PURE__ */ dual(2, (self, schedule4) => transformPull(self, (pull, _scope) =>
|
|
9301
|
+
var schedule2 = /* @__PURE__ */ dual(2, (self, schedule4) => transformPull(self, (pull, _scope) => map5(toStepWithSleep(schedule4), (step) => {
|
|
9219
9302
|
const pullWithStep = tap3(pull, step);
|
|
9220
9303
|
return pullWithStep;
|
|
9221
9304
|
})));
|
|
9222
|
-
var filter7 = /* @__PURE__ */ dual(2, (self, predicate) => fromTransform((upstream, scope3) =>
|
|
9305
|
+
var filter7 = /* @__PURE__ */ dual(2, (self, predicate) => fromTransform((upstream, scope3) => map5(toTransform(self)(upstream, scope3), (pull) => flatMap3(pull, function loop(elem) {
|
|
9223
9306
|
return predicate(elem) ? succeed5(elem) : flatMap3(pull, loop);
|
|
9224
9307
|
}))));
|
|
9225
9308
|
var filterArray = /* @__PURE__ */ dual(2, (self, predicate) => transformPull(self, (pull) => succeed5(flatMap3(pull, function loop(arr) {
|
|
@@ -9250,7 +9333,7 @@ var filterArrayEffect = /* @__PURE__ */ dual(2, (self, predicate) => transformPu
|
|
|
9250
9333
|
var filterMapArrayEffect = /* @__PURE__ */ dual(2, (self, filter9) => transformPull(self, (pull) => succeed5(flatMap3(pull, function loop(arr) {
|
|
9251
9334
|
return flatMap3(filterMapEffect2(arr, filter9), (passes) => isReadonlyArrayNonEmpty(passes) ? succeed5(passes) : flatMap3(pull, loop));
|
|
9252
9335
|
}))));
|
|
9253
|
-
var mapAccum = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self, initial, f, options) => fromTransform((upstream, scope3) =>
|
|
9336
|
+
var mapAccum = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self, initial, f, options) => fromTransform((upstream, scope3) => map5(toTransform(self)(upstream, scope3), (pull) => {
|
|
9254
9337
|
let state = initial();
|
|
9255
9338
|
let current;
|
|
9256
9339
|
let index = 0;
|
|
@@ -9289,7 +9372,7 @@ var mapAccum = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self, initi
|
|
|
9289
9372
|
});
|
|
9290
9373
|
return pump;
|
|
9291
9374
|
})));
|
|
9292
|
-
var scanEffect = /* @__PURE__ */ dual(3, (self, initial, f) => fromTransform((upstream, scope3) =>
|
|
9375
|
+
var scanEffect = /* @__PURE__ */ dual(3, (self, initial, f) => fromTransform((upstream, scope3) => map5(toTransform(self)(upstream, scope3), (pull) => {
|
|
9293
9376
|
let state = initial;
|
|
9294
9377
|
let isFirst = true;
|
|
9295
9378
|
return suspend2(() => {
|
|
@@ -9297,7 +9380,7 @@ var scanEffect = /* @__PURE__ */ dual(3, (self, initial, f) => fromTransform((up
|
|
|
9297
9380
|
isFirst = false;
|
|
9298
9381
|
return succeed5(state);
|
|
9299
9382
|
}
|
|
9300
|
-
return
|
|
9383
|
+
return map5(flatMap3(pull, (a) => f(state, a)), (newState) => {
|
|
9301
9384
|
state = newState;
|
|
9302
9385
|
return state;
|
|
9303
9386
|
});
|
|
@@ -9305,7 +9388,7 @@ var scanEffect = /* @__PURE__ */ dual(3, (self, initial, f) => fromTransform((up
|
|
|
9305
9388
|
})));
|
|
9306
9389
|
var catchCause3 = /* @__PURE__ */ dual(2, (self, f) => fromTransform((upstream, scope3) => {
|
|
9307
9390
|
let forkedScope = forkUnsafe2(scope3);
|
|
9308
|
-
return
|
|
9391
|
+
return map5(toTransform(self)(upstream, forkedScope), (pull) => {
|
|
9309
9392
|
let currentPull = pull.pipe(catchCause2((cause) => {
|
|
9310
9393
|
if (isDoneCause(cause)) {
|
|
9311
9394
|
return failCause4(cause);
|
|
@@ -9329,7 +9412,7 @@ var catchCauseFilter3 = /* @__PURE__ */ dual(3, (self, filter9, f) => catchCause
|
|
|
9329
9412
|
return isFailure2(result4) ? failCause6(result4.failure) : f(result4.success, cause);
|
|
9330
9413
|
}));
|
|
9331
9414
|
var catch_3 = /* @__PURE__ */ dual(2, (self, f) => catchCauseFilter3(self, findError2, (e) => f(e)));
|
|
9332
|
-
var tapError3 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed5(tapError2(pull, (err) => isDone2(err) ? void_4 :
|
|
9415
|
+
var tapError3 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => succeed5(tapError2(pull, (err) => isDone2(err) ? void_4 : asVoid4(f(err))))));
|
|
9333
9416
|
var catchIf3 = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self, predicate, f, orElse2) => catch_3(self, (err) => {
|
|
9334
9417
|
return predicate(err) ? f(err) : orElse2 ? orElse2(err) : fail7(err);
|
|
9335
9418
|
}));
|
|
@@ -9361,7 +9444,7 @@ var catchReasons3 = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self,
|
|
|
9361
9444
|
return fail7(error);
|
|
9362
9445
|
});
|
|
9363
9446
|
});
|
|
9364
|
-
var
|
|
9447
|
+
var mapError5 = /* @__PURE__ */ dual(2, (self, f) => catch_3(self, (err) => fail7(f(err))));
|
|
9365
9448
|
var orDie3 = (self) => catch_3(self, die5);
|
|
9366
9449
|
var ignore3 = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self, options) => {
|
|
9367
9450
|
if (!options?.log) {
|
|
@@ -9394,7 +9477,7 @@ var retry3 = /* @__PURE__ */ dual(2, (self, schedule4) => suspend3(() => {
|
|
|
9394
9477
|
}, (effect, error) => catchDone(effect, () => succeed5(fail7(error))), unwrap));
|
|
9395
9478
|
return loop;
|
|
9396
9479
|
}));
|
|
9397
|
-
var switchMap = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self, f, options) => self.pipe(
|
|
9480
|
+
var switchMap = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self, f, options) => self.pipe(map6(f), mergeAll3({
|
|
9398
9481
|
...options,
|
|
9399
9482
|
concurrency: options?.concurrency ?? 1,
|
|
9400
9483
|
switch: true
|
|
@@ -9566,7 +9649,7 @@ var splitLines = () => fromTransform((upstream, _scope) => sync2(() => {
|
|
|
9566
9649
|
var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope3) => flatMap3(toTransform(self)(upstream, scope3), (upstream2) => toTransform(that)(upstream2, scope3))));
|
|
9567
9650
|
var pipeToOrFail = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope3) => flatMap3(toTransform(self)(upstream, scope3), (upstream2) => {
|
|
9568
9651
|
const upstreamPull = catchCause2(upstream2, (cause) => isDoneCause(cause) ? failCause4(cause) : die4(Done2(cause)));
|
|
9569
|
-
return
|
|
9652
|
+
return map5(toTransform(that)(upstreamPull, scope3), (pull) => catchDefect2(pull, (defect) => isDone2(defect) ? failCause4(defect.value) : die4(defect)));
|
|
9570
9653
|
})));
|
|
9571
9654
|
var unwrap = (channel) => fromTransform((upstream, scope3) => {
|
|
9572
9655
|
let pull;
|
|
@@ -9575,7 +9658,7 @@ var unwrap = (channel) => fromTransform((upstream, scope3) => {
|
|
|
9575
9658
|
return channel.pipe(provide(scope3), flatMap3((channel2) => toTransform(channel2)(upstream, scope3)), flatMap3((pull_) => pull = pull_));
|
|
9576
9659
|
}));
|
|
9577
9660
|
});
|
|
9578
|
-
var scoped3 = (self) => fromTransformBracket((upstream, scope3, forkedScope) =>
|
|
9661
|
+
var scoped3 = (self) => fromTransformBracket((upstream, scope3, forkedScope) => map5(provide(toTransform(self)(upstream, scope3), forkedScope), provide(forkedScope)));
|
|
9579
9662
|
var buffer = /* @__PURE__ */ dual(2, (self, options) => fromTransform(fnUntraced2(function* (upstream, scope3) {
|
|
9580
9663
|
const pull = yield* toTransform(self)(upstream, scope3);
|
|
9581
9664
|
const queue = yield* make12({
|
|
@@ -9634,10 +9717,10 @@ var runWith = (self, f, onHalt) => suspend2(() => {
|
|
|
9634
9717
|
const makePull = toTransform(self)(done2(), scope3);
|
|
9635
9718
|
return catchDone(flatMap3(makePull, f), onHalt ? onHalt : succeed5).pipe(onExit2((exit3) => close(scope3, exit3)));
|
|
9636
9719
|
});
|
|
9637
|
-
var provideContext3 = /* @__PURE__ */ dual(2, (self, context3) => fromTransform((upstream, scope3) =>
|
|
9638
|
-
var provideService3 = /* @__PURE__ */ dual(3, (self, key, service4) => fromTransform((upstream, scope3) =>
|
|
9720
|
+
var provideContext3 = /* @__PURE__ */ dual(2, (self, context3) => fromTransform((upstream, scope3) => map5(provideContext2(toTransform(self)(upstream, scope3), context3), provideContext2(context3))));
|
|
9721
|
+
var provideService3 = /* @__PURE__ */ dual(3, (self, key, service4) => fromTransform((upstream, scope3) => map5(provideService2(toTransform(self)(upstream, scope3), key, service4), provideService2(key, service4))));
|
|
9639
9722
|
var provideServiceEffect3 = /* @__PURE__ */ dual(3, (self, key, service4) => fromTransform((upstream, scope3) => flatMap3(service4, (s) => toTransform(provideService3(self, key, s))(upstream, scope3))));
|
|
9640
|
-
var provide5 = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self, layer, options) => isContext(layer) ? provideContext3(self, layer) : fromTransform((upstream, scope3) => flatMap3(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope3) : buildWithScope(layer, scope3), (context3) =>
|
|
9723
|
+
var provide5 = /* @__PURE__ */ dual((args2) => isChannel(args2[0]), (self, layer, options) => isContext(layer) ? provideContext3(self, layer) : fromTransform((upstream, scope3) => flatMap3(options?.local ? buildWithMemoMap(layer, makeMemoMapUnsafe(), scope3) : buildWithScope(layer, scope3), (context3) => map5(provideContext2(toTransform(self)(upstream, scope3), context3), provideContext2(context3)))));
|
|
9641
9724
|
var updateContext3 = /* @__PURE__ */ dual(2, (self, f) => fromTransform((upstream, scope3) => contextWith2((context3) => {
|
|
9642
9725
|
const toProvide = f(context3);
|
|
9643
9726
|
return toTransform(provideContext3(self, toProvide))(upstream, scope3);
|
|
@@ -9666,7 +9749,7 @@ var runForEach = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => fo
|
|
|
9666
9749
|
var runForEachWhile = /* @__PURE__ */ dual(2, (self, f) => runWith(self, (pull) => pull.pipe(flatMap3(f), flatMap3((cont) => cont ? void_4 : done2()), forever4({
|
|
9667
9750
|
disableYield: true
|
|
9668
9751
|
}))));
|
|
9669
|
-
var mkUint8Array = (self) =>
|
|
9752
|
+
var mkUint8Array = (self) => map5(runFold(self, () => ({
|
|
9670
9753
|
bytes: 0,
|
|
9671
9754
|
arrays: []
|
|
9672
9755
|
}), (acc, chunk) => {
|
|
@@ -9719,7 +9802,7 @@ var runFoldEffect = /* @__PURE__ */ dual(3, (self, initial, f) => suspend2(() =>
|
|
|
9719
9802
|
let state = initial();
|
|
9720
9803
|
return runWith(self, (pull) => whileLoop2({
|
|
9721
9804
|
while: constTrue,
|
|
9722
|
-
body: constant(pull.pipe(flatMap3((o) => f(state, o)),
|
|
9805
|
+
body: constant(pull.pipe(flatMap3((o) => f(state, o)), map5((s) => {
|
|
9723
9806
|
state = s;
|
|
9724
9807
|
}))),
|
|
9725
9808
|
step: constVoid
|
|
@@ -9945,16 +10028,16 @@ __export(Stream_exports, {
|
|
|
9945
10028
|
let: () => let_5,
|
|
9946
10029
|
limitBytes: () => limitBytes,
|
|
9947
10030
|
make: () => make16,
|
|
9948
|
-
map: () =>
|
|
10031
|
+
map: () => map7,
|
|
9949
10032
|
mapAccum: () => mapAccum2,
|
|
9950
10033
|
mapAccumArray: () => mapAccumArray,
|
|
9951
10034
|
mapAccumArrayEffect: () => mapAccumArrayEffect,
|
|
9952
10035
|
mapAccumEffect: () => mapAccumEffect,
|
|
9953
10036
|
mapArray: () => mapArray,
|
|
9954
10037
|
mapArrayEffect: () => mapArrayEffect,
|
|
9955
|
-
mapBoth: () =>
|
|
10038
|
+
mapBoth: () => mapBoth4,
|
|
9956
10039
|
mapEffect: () => mapEffect2,
|
|
9957
|
-
mapError: () =>
|
|
10040
|
+
mapError: () => mapError6,
|
|
9958
10041
|
merge: () => merge3,
|
|
9959
10042
|
mergeAll: () => mergeAll4,
|
|
9960
10043
|
mergeEffect: () => mergeEffect2,
|
|
@@ -10107,12 +10190,12 @@ var make13 = (options) => withFiber2((fiber3) => {
|
|
|
10107
10190
|
if (self.state._tag === "Closed") {
|
|
10108
10191
|
return void_4;
|
|
10109
10192
|
}
|
|
10110
|
-
const
|
|
10193
|
+
const map8 = self.state.map;
|
|
10111
10194
|
self.state = {
|
|
10112
10195
|
_tag: "Closed"
|
|
10113
10196
|
};
|
|
10114
|
-
return forEach2(
|
|
10115
|
-
clear(
|
|
10197
|
+
return forEach2(map8, ([, entry]) => exit2(close(entry.scope, void_3))).pipe(tap3(() => sync2(() => {
|
|
10198
|
+
clear(map8);
|
|
10116
10199
|
})));
|
|
10117
10200
|
}), self);
|
|
10118
10201
|
});
|
|
@@ -10248,7 +10331,7 @@ var getState = (self) => uninterruptibleMask2(function loop(restore) {
|
|
|
10248
10331
|
if (self.state._tag !== "Empty") {
|
|
10249
10332
|
return loop(restore);
|
|
10250
10333
|
}
|
|
10251
|
-
return restore(provideContext2(self.acquire, add(self.context, Scope, scope3))).pipe(
|
|
10334
|
+
return restore(provideContext2(self.acquire, add(self.context, Scope, scope3))).pipe(map5((value) => {
|
|
10252
10335
|
const state = {
|
|
10253
10336
|
_tag: "Acquired",
|
|
10254
10337
|
value,
|
|
@@ -10305,16 +10388,16 @@ var TypeId21 = "~effect/Stream";
|
|
|
10305
10388
|
var isStream = (u) => hasProperty(u, TypeId21);
|
|
10306
10389
|
var DefaultChunkSize2 = DefaultChunkSize;
|
|
10307
10390
|
var fromChannel2 = fromChannel;
|
|
10308
|
-
var fromEffect2 = (effect) => fromChannel2(fromEffect(
|
|
10391
|
+
var fromEffect2 = (effect) => fromChannel2(fromEffect(map5(effect, of)));
|
|
10309
10392
|
var service3 = (service4) => fromEffect2(service2(service4));
|
|
10310
10393
|
var serviceOption3 = (service4) => fromEffect2(serviceOption2(service4));
|
|
10311
10394
|
var fromEffectDrain2 = (effect) => fromPull2(succeed5(flatMap3(effect, () => done2())));
|
|
10312
|
-
var fromEffectRepeat = (effect) => fromPull2(succeed5(
|
|
10395
|
+
var fromEffectRepeat = (effect) => fromPull2(succeed5(map5(effect, of)));
|
|
10313
10396
|
var fromEffectSchedule = (effect, schedule4) => fromPull2(gen3(function* () {
|
|
10314
10397
|
const step = yield* toStepWithMetadata(schedule4);
|
|
10315
10398
|
let s = yield* provideService2(effect, CurrentMetadata2, CurrentMetadata2.defaultValue());
|
|
10316
10399
|
let initial = true;
|
|
10317
|
-
const pull = suspend2(() => step(s)).pipe(flatMap3((meta) => provideService2(effect, CurrentMetadata2, meta)),
|
|
10400
|
+
const pull = suspend2(() => step(s)).pipe(flatMap3((meta) => provideService2(effect, CurrentMetadata2, meta)), map5((next) => {
|
|
10318
10401
|
s = next;
|
|
10319
10402
|
return of(next);
|
|
10320
10403
|
}));
|
|
@@ -10355,17 +10438,17 @@ var die6 = (defect) => fromChannel2(die5(defect));
|
|
|
10355
10438
|
var failCauseSync4 = (evaluate2) => fromChannel2(failCauseSync3(evaluate2));
|
|
10356
10439
|
var fromIteratorSucceed = (iterator, maxChunkSize) => fromChannel2(fromIteratorArray(() => iterator, maxChunkSize));
|
|
10357
10440
|
var fromIterable3 = (iterable, options) => Array.isArray(iterable) && options?.chunkSize === void 0 ? fromArray2(iterable) : fromChannel2(fromIterableArray(iterable, options?.chunkSize));
|
|
10358
|
-
var fromIterableEffect = (iterable) => unwrap2(
|
|
10441
|
+
var fromIterableEffect = (iterable) => unwrap2(map5(iterable, fromIterable3));
|
|
10359
10442
|
var fromIterableEffectRepeat = (iterable) => flatMap5(fromEffectRepeat(iterable), fromIterable3);
|
|
10360
10443
|
var fromArray2 = (array2) => isReadonlyArrayNonEmpty(array2) ? fromChannel2(succeed6(array2)) : empty5;
|
|
10361
|
-
var fromArrayEffect = (effect) => unwrap2(
|
|
10444
|
+
var fromArrayEffect = (effect) => unwrap2(map5(effect, fromArray2));
|
|
10362
10445
|
var fromArrays = (...arrays) => fromChannel2(fromArray(filter3(arrays, isReadonlyArrayNonEmpty)));
|
|
10363
10446
|
var fromQueue = (queue) => fromChannel2(fromQueueArray(queue));
|
|
10364
10447
|
var fromPubSub = (pubsub) => fromChannel2(fromPubSubArray(pubsub));
|
|
10365
10448
|
var fromPubSubTake2 = (pubsub) => fromChannel2(fromPubSubTake(pubsub));
|
|
10366
10449
|
var fromReadableStream2 = (options) => fromChannel2(fromReadableStream(options));
|
|
10367
10450
|
var fromAsyncIterable2 = (iterable, onError5) => fromChannel2(fromAsyncIterableArray(iterable, onError5));
|
|
10368
|
-
var fromSchedule = (schedule4) => fromPull2(
|
|
10451
|
+
var fromSchedule = (schedule4) => fromPull2(map5(toStepWithSleep(schedule4), (step) => catchDone(map5(step(void 0), of), () => done2())));
|
|
10369
10452
|
var fromSubscription = (pubsub) => fromChannel2(fromSubscriptionArray(pubsub));
|
|
10370
10453
|
var fromEventListener = (target, type, options) => callback3((queue) => {
|
|
10371
10454
|
function emit(event) {
|
|
@@ -10418,18 +10501,18 @@ var range2 = (min4, max4, chunkSize = DefaultChunkSize) => min4 > max4 ? empty5
|
|
|
10418
10501
|
});
|
|
10419
10502
|
}));
|
|
10420
10503
|
var never4 = /* @__PURE__ */ fromChannel2(never3);
|
|
10421
|
-
var unwrap2 = (effect) => fromChannel2(unwrap(
|
|
10504
|
+
var unwrap2 = (effect) => fromChannel2(unwrap(map5(effect, toChannel2)));
|
|
10422
10505
|
var scoped4 = (self) => fromChannel2(scoped3(self.channel));
|
|
10423
|
-
var
|
|
10506
|
+
var map7 = /* @__PURE__ */ dual(2, (self, f) => suspend4(() => {
|
|
10424
10507
|
let i = 0;
|
|
10425
|
-
return fromChannel2(
|
|
10508
|
+
return fromChannel2(map6(self.channel, map2((o) => f(o, i++))));
|
|
10426
10509
|
}));
|
|
10427
|
-
var
|
|
10428
|
-
var mapArray = /* @__PURE__ */ dual(2, (self, f) => fromChannel2(
|
|
10429
|
-
var mapEffect2 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, f, options) => self.channel.pipe(flattenArray, mapEffect(f, options),
|
|
10510
|
+
var mapBoth4 = /* @__PURE__ */ dual(2, (self, options) => self.pipe(map7(options.onSuccess), mapError6(options.onFailure)));
|
|
10511
|
+
var mapArray = /* @__PURE__ */ dual(2, (self, f) => fromChannel2(map6(self.channel, f)));
|
|
10512
|
+
var mapEffect2 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, f, options) => self.channel.pipe(flattenArray, mapEffect(f, options), map6(of), fromChannel2));
|
|
10430
10513
|
var flattenEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, options) => mapEffect2(self, identity, options));
|
|
10431
10514
|
var mapArrayEffect = /* @__PURE__ */ dual(2, (self, f) => fromChannel2(mapEffect(self.channel, f)));
|
|
10432
|
-
var result3 = (self) => self.pipe(
|
|
10515
|
+
var result3 = (self) => self.pipe(map7(succeed2), catch_4((e) => succeed7(fail2(e))));
|
|
10433
10516
|
var tap4 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, f, options) => mapEffect2(self, (a) => as3(f(a), a), options));
|
|
10434
10517
|
var tapBoth = /* @__PURE__ */ dual(2, (self, options) => self.pipe(tapError4(options.onError), tap4(options.onElement, {
|
|
10435
10518
|
concurrency: options.concurrency
|
|
@@ -10484,7 +10567,7 @@ var flattenArray2 = (self) => fromChannel2(flattenArray(self.channel));
|
|
|
10484
10567
|
var drain2 = (self) => fromChannel2(drain(self.channel));
|
|
10485
10568
|
var drainFork = /* @__PURE__ */ dual(2, (self, that) => mergeEffect2(self, runDrain2(that)));
|
|
10486
10569
|
var repeat5 = /* @__PURE__ */ dual(2, (self, schedule4) => fromChannel2(repeat4(self.channel, schedule4)));
|
|
10487
|
-
var schedule3 = /* @__PURE__ */ dual(2, (self, schedule4) => self.channel.pipe(flattenArray, schedule2(schedule4),
|
|
10570
|
+
var schedule3 = /* @__PURE__ */ dual(2, (self, schedule4) => self.channel.pipe(flattenArray, schedule2(schedule4), map6(of), fromChannel2));
|
|
10488
10571
|
var timeout3 = /* @__PURE__ */ dual(2, (self, duration) => timeoutOrElse3(self, {
|
|
10489
10572
|
duration,
|
|
10490
10573
|
orElse: () => empty5
|
|
@@ -10504,7 +10587,7 @@ var timeoutOrElse3 = /* @__PURE__ */ dual(2, (self, options) => {
|
|
|
10504
10587
|
deadline = clock.currentTimeMillisUnsafe() + durationMs;
|
|
10505
10588
|
latch.openUnsafe();
|
|
10506
10589
|
return pull;
|
|
10507
|
-
}).pipe(
|
|
10590
|
+
}).pipe(map5((arr) => {
|
|
10508
10591
|
latch.closeUnsafe();
|
|
10509
10592
|
deadline = void 0;
|
|
10510
10593
|
return arr;
|
|
@@ -10527,7 +10610,7 @@ var timeoutOrElse3 = /* @__PURE__ */ dual(2, (self, options) => {
|
|
|
10527
10610
|
return failCause7(cause);
|
|
10528
10611
|
});
|
|
10529
10612
|
});
|
|
10530
|
-
var repeatElements = /* @__PURE__ */ dual(2, (self, schedule4) => fromChannel2(fromTransform((upstream, scope3) =>
|
|
10613
|
+
var repeatElements = /* @__PURE__ */ dual(2, (self, schedule4) => fromChannel2(fromTransform((upstream, scope3) => map5(toTransform(flattenArray(self.channel))(upstream, scope3), (pullElement) => {
|
|
10531
10614
|
let pullRepeat = void 0;
|
|
10532
10615
|
const pull = gen3(function* () {
|
|
10533
10616
|
const element = yield* pullElement;
|
|
@@ -10548,12 +10631,12 @@ var concat = /* @__PURE__ */ dual(2, (self, that) => flatten6(fromArray2([self,
|
|
|
10548
10631
|
var prepend2 = /* @__PURE__ */ dual(2, (self, values) => concat(fromIterable3(values), self));
|
|
10549
10632
|
var merge3 = /* @__PURE__ */ dual((args2) => isStream(args2[0]) && isStream(args2[1]), (self, that, options) => fromChannel2(merge2(toChannel2(self), toChannel2(that), options)));
|
|
10550
10633
|
var mergeEffect2 = /* @__PURE__ */ dual(2, (self, effect) => self.channel.pipe(mergeEffect(effect), fromChannel2));
|
|
10551
|
-
var mergeResult = /* @__PURE__ */ dual(2, (self, that) => merge3(
|
|
10634
|
+
var mergeResult = /* @__PURE__ */ dual(2, (self, that) => merge3(map7(self, succeed2), map7(that, fail2)));
|
|
10552
10635
|
var mergeLeft = /* @__PURE__ */ dual(2, (left, right) => mergeEffect2(left, runDrain2(right)));
|
|
10553
10636
|
var mergeRight = /* @__PURE__ */ dual(2, (left, right) => mergeEffect2(right, runDrain2(left)));
|
|
10554
10637
|
var mergeAll4 = /* @__PURE__ */ dual(2, (streams, options) => flatten6(fromIterable3(streams), options));
|
|
10555
10638
|
var cross = /* @__PURE__ */ dual(2, (left, right) => crossWith(left, right, (l, r) => [l, r]));
|
|
10556
|
-
var crossWith = /* @__PURE__ */ dual(3, (left, right, f) => flatMap5(left, (l) =>
|
|
10639
|
+
var crossWith = /* @__PURE__ */ dual(3, (left, right, f) => flatMap5(left, (l) => map7(right, (r) => f(l, r))));
|
|
10557
10640
|
var zipWith4 = /* @__PURE__ */ dual(3, (left, right, f) => zipWithArray(left, right, zipArrays(f)));
|
|
10558
10641
|
var zipArrays = (f) => (leftArr, rightArr) => {
|
|
10559
10642
|
const minLength = Math.min(leftArr.length, rightArr.length);
|
|
@@ -10612,7 +10695,7 @@ var zipRight2 = /* @__PURE__ */ dual(2, (left, right) => zipWithArray(left, righ
|
|
|
10612
10695
|
return [output, leftoverLeft, leftoverRight];
|
|
10613
10696
|
}));
|
|
10614
10697
|
var zipFlatten = /* @__PURE__ */ dual(2, (self, that) => zipWith4(self, that, (a, a2) => [...a, a2]));
|
|
10615
|
-
var zipWithIndex = (self) =>
|
|
10698
|
+
var zipWithIndex = (self) => map7(self, (a, i) => [a, i]);
|
|
10616
10699
|
var zipWithNext = (self) => mapAccumArray(self, none2, (acc, arr) => {
|
|
10617
10700
|
let i = 0;
|
|
10618
10701
|
if (acc._tag === "None") {
|
|
@@ -10687,7 +10770,7 @@ var zipLatestAll = (...streams) => fromChannel2(suspend3(() => {
|
|
|
10687
10770
|
});
|
|
10688
10771
|
}));
|
|
10689
10772
|
var zipLatest = /* @__PURE__ */ dual(2, (left, right) => zipLatestAll(left, right));
|
|
10690
|
-
var zipLatestWith = /* @__PURE__ */ dual(3, (left, right, f) =>
|
|
10773
|
+
var zipLatestWith = /* @__PURE__ */ dual(3, (left, right, f) => map7(zipLatestAll(left, right), ([a, a2]) => f(a, a2)));
|
|
10691
10774
|
var raceAll3 = (...streams) => fromChannel2(fromTransform((_, scope3) => sync2(() => {
|
|
10692
10775
|
let winner;
|
|
10693
10776
|
const race4 = raceAll2(streams.map((stream) => {
|
|
@@ -10701,7 +10784,7 @@ var raceAll3 = (...streams) => fromChannel2(fromTransform((_, scope3) => sync2((
|
|
|
10701
10784
|
return void_4;
|
|
10702
10785
|
}
|
|
10703
10786
|
return close(childScope, exit3);
|
|
10704
|
-
}),
|
|
10787
|
+
}), map5(([, chunk]) => chunk));
|
|
10705
10788
|
}));
|
|
10706
10789
|
return suspend2(() => winner ?? race4);
|
|
10707
10790
|
})));
|
|
@@ -10755,11 +10838,11 @@ var partitionQueue = /* @__PURE__ */ dual((args2) => isStream(args2[0]), /* @__P
|
|
|
10755
10838
|
}), forkIn2(scope3));
|
|
10756
10839
|
return [passes, fails];
|
|
10757
10840
|
}));
|
|
10758
|
-
var partitionEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, filter9, options) =>
|
|
10759
|
-
var partition4 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, filter9, options) =>
|
|
10841
|
+
var partitionEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, filter9, options) => map5(partitionQueue(mapEffect2(self, (a) => filter9(a), options), (result4) => result4, options), ([passes, fails]) => [fromQueue(passes), fromQueue(fails)]));
|
|
10842
|
+
var partition4 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, filter9, options) => map5(partitionQueue(self, filter9, {
|
|
10760
10843
|
capacity: options?.bufferSize ?? 16
|
|
10761
10844
|
}), ([passes, fails]) => [fromQueue(fails), fromQueue(passes)]));
|
|
10762
|
-
var when3 = /* @__PURE__ */ dual(2, (self, test) => test.pipe(
|
|
10845
|
+
var when3 = /* @__PURE__ */ dual(2, (self, test) => test.pipe(map5((pass) => pass ? self : empty5), unwrap2));
|
|
10763
10846
|
var peel = /* @__PURE__ */ dual(2, /* @__PURE__ */ fnUntraced2(function* (self, sink) {
|
|
10764
10847
|
let cause = void 0;
|
|
10765
10848
|
const originalPull = yield* toPull2(self.channel);
|
|
@@ -10802,7 +10885,7 @@ var catchReasons4 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, e
|
|
|
10802
10885
|
const orElseHandler = orElse2 && ((reason, error) => orElse2(reason, error).channel);
|
|
10803
10886
|
return fromChannel2(catchReasons3(self.channel, errorTag, handlers, orElseHandler));
|
|
10804
10887
|
});
|
|
10805
|
-
var
|
|
10888
|
+
var mapError6 = /* @__PURE__ */ dual(2, (self, f) => fromChannel2(mapError5(self.channel, f)));
|
|
10806
10889
|
var catchCauseIf4 = /* @__PURE__ */ dual(3, (self, predicate, f) => fromChannel2(catchCauseIf3(self.channel, predicate, (cause) => f(cause).channel)));
|
|
10807
10890
|
var catchCauseFilter4 = /* @__PURE__ */ dual(3, (self, filter9, f) => fromChannel2(catchCauseFilter3(self.channel, filter9, (failure, cause) => f(failure, cause).channel)));
|
|
10808
10891
|
var orElseIfEmpty2 = /* @__PURE__ */ dual(2, (self, orElse2) => fromChannel2(orElseIfEmpty(self.channel, (_) => toChannel2(orElse2()))));
|
|
@@ -10811,9 +10894,9 @@ var orDie4 = (self) => fromChannel2(orDie3(self.channel));
|
|
|
10811
10894
|
var ignore4 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, options) => fromChannel2(ignore3(self.channel, options)));
|
|
10812
10895
|
var ignoreCause4 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, options) => fromChannel2(ignoreCause3(self.channel, options)));
|
|
10813
10896
|
var retry4 = /* @__PURE__ */ dual(2, (self, policy) => fromChannel2(retry3(self.channel, policy)));
|
|
10814
|
-
var retryWithoutReset = (self, schedule4) => unwrap2(
|
|
10897
|
+
var retryWithoutReset = (self, schedule4) => unwrap2(map5(toStepWithMetadata(schedule4), (step) => {
|
|
10815
10898
|
let meta = CurrentMetadata2.defaultValue();
|
|
10816
|
-
const loop = () => catch_4(provideServiceEffect4(self, CurrentMetadata2, sync2(() => meta)), (error) => unwrap2(catchDone(
|
|
10899
|
+
const loop = () => catch_4(provideServiceEffect4(self, CurrentMetadata2, sync2(() => meta)), (error) => unwrap2(catchDone(map5(step(error), (meta_) => {
|
|
10817
10900
|
meta = meta_;
|
|
10818
10901
|
return unwrap2(as3(yieldNow2, loop()));
|
|
10819
10902
|
}), () => succeed5(fail8(error)))));
|
|
@@ -10835,7 +10918,7 @@ var withExecutionPlan3 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (se
|
|
|
10835
10918
|
}));
|
|
10836
10919
|
const emitter = options?.onEvent === void 0 ? void 0 : makeEventEmitter(options.onEvent, () => meta);
|
|
10837
10920
|
let attemptState;
|
|
10838
|
-
const instrument = emitter === void 0 ? identity : (attempt) => onExit4(onStart2(attempt,
|
|
10921
|
+
const instrument = emitter === void 0 ? identity : (attempt) => onExit4(onStart2(attempt, map5(emitter.begin, (state) => {
|
|
10839
10922
|
attemptState = state;
|
|
10840
10923
|
})), (exit3) => suspend2(() => {
|
|
10841
10924
|
if (attemptState === void 0) return void_4;
|
|
@@ -10967,7 +11050,7 @@ var takeWhileFilter = /* @__PURE__ */ dual(2, (self, filter9) => transformPull2(
|
|
|
10967
11050
|
});
|
|
10968
11051
|
return pump;
|
|
10969
11052
|
})));
|
|
10970
|
-
var takeWhileEffect = /* @__PURE__ */ dual(2, (self, predicate) => takeUntilEffect(self, (a, n) =>
|
|
11053
|
+
var takeWhileEffect = /* @__PURE__ */ dual(2, (self, predicate) => takeUntilEffect(self, (a, n) => map5(predicate(a, n), (b) => !b), {
|
|
10971
11054
|
excludeLast: true
|
|
10972
11055
|
}));
|
|
10973
11056
|
var drop = /* @__PURE__ */ dual(2, (self, n) => transformPull2(self, (pull, _scope) => sync2(() => {
|
|
@@ -10981,7 +11064,7 @@ var drop = /* @__PURE__ */ dual(2, (self, n) => transformPull2(self, (pull, _sco
|
|
|
10981
11064
|
return pump;
|
|
10982
11065
|
})));
|
|
10983
11066
|
var dropUntil = /* @__PURE__ */ dual(2, (self, predicate) => drop(dropWhile(self, (a, i) => !predicate(a, i)), 1));
|
|
10984
|
-
var dropUntilEffect = /* @__PURE__ */ dual(2, (self, predicate) => drop(dropWhileEffect(self, (a, i) =>
|
|
11067
|
+
var dropUntilEffect = /* @__PURE__ */ dual(2, (self, predicate) => drop(dropWhileEffect(self, (a, i) => map5(predicate(a, i), (b) => !b)), 1));
|
|
10985
11068
|
var dropWhile = /* @__PURE__ */ dual(2, (self, predicate) => transformPull2(self, (pull, _scope) => sync2(() => {
|
|
10986
11069
|
let dropping3 = true;
|
|
10987
11070
|
let index = 0;
|
|
@@ -11032,7 +11115,7 @@ var dropRight = /* @__PURE__ */ dual(2, (self, n) => {
|
|
|
11032
11115
|
return emit;
|
|
11033
11116
|
}));
|
|
11034
11117
|
});
|
|
11035
|
-
var chunks = (self) => self.channel.pipe(
|
|
11118
|
+
var chunks = (self) => self.channel.pipe(map6(of), fromChannel2);
|
|
11036
11119
|
var rechunk = /* @__PURE__ */ dual(2, (self, target) => {
|
|
11037
11120
|
target = Math.max(1, target);
|
|
11038
11121
|
return transformPull2(self, (pull, _scope) => sync2(() => {
|
|
@@ -11134,7 +11217,7 @@ var split = /* @__PURE__ */ dual(2, (self, predicate) => mapAccumArray(self, emp
|
|
|
11134
11217
|
return isArrayNonEmpty2(arr) ? of(arr) : emptyArr;
|
|
11135
11218
|
}
|
|
11136
11219
|
}));
|
|
11137
|
-
var combine3 = /* @__PURE__ */ dual(4, (self, that, s, f) => combine2(flattenArray(self.channel), flattenArray(that.channel), s, f).pipe(
|
|
11220
|
+
var combine3 = /* @__PURE__ */ dual(4, (self, that, s, f) => combine2(flattenArray(self.channel), flattenArray(that.channel), s, f).pipe(map6(of), fromChannel2));
|
|
11138
11221
|
var combineArray = /* @__PURE__ */ dual(4, (self, that, s, f) => fromChannel2(combine2(self.channel, that.channel, s, f)));
|
|
11139
11222
|
var mapAccum2 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, initial, f, options) => fromChannel2(mapAccum(self.channel, initial, (state, arr) => {
|
|
11140
11223
|
const acc = empty();
|
|
@@ -11161,13 +11244,13 @@ var mapAccumArray = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, i
|
|
|
11161
11244
|
}
|
|
11162
11245
|
} : void 0)));
|
|
11163
11246
|
var emptyArr = /* @__PURE__ */ empty();
|
|
11164
|
-
var mapAccumEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, initial, f, options) => self.channel.pipe(flattenArray, mapAccum(initial, (state, a) =>
|
|
11247
|
+
var mapAccumEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, initial, f, options) => self.channel.pipe(flattenArray, mapAccum(initial, (state, a) => map5(f(state, a), ([state2, values]) => [state2, isReadonlyArrayNonEmpty(values) ? of(values) : empty()]), options?.onHalt ? {
|
|
11165
11248
|
onHalt(state) {
|
|
11166
11249
|
const arr = options.onHalt(state);
|
|
11167
11250
|
return isReadonlyArrayNonEmpty(arr) ? of(arr) : emptyArr;
|
|
11168
11251
|
}
|
|
11169
11252
|
} : void 0), fromChannel2));
|
|
11170
|
-
var mapAccumArrayEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, initial, f, options) => self.channel.pipe(mapAccum(initial, (state, a) =>
|
|
11253
|
+
var mapAccumArrayEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, initial, f, options) => self.channel.pipe(mapAccum(initial, (state, a) => map5(f(state, a), ([state2, values]) => [state2, isReadonlyArrayNonEmpty(values) ? of(values) : emptyArr]), options?.onHalt ? {
|
|
11171
11254
|
onHalt(state) {
|
|
11172
11255
|
const arr = options.onHalt(state);
|
|
11173
11256
|
return isReadonlyArrayNonEmpty(arr) ? of(arr) : emptyArr;
|
|
@@ -11188,7 +11271,7 @@ var scan = /* @__PURE__ */ dual(3, (self, initial, f) => suspend4(() => {
|
|
|
11188
11271
|
return [state, of(states)];
|
|
11189
11272
|
}));
|
|
11190
11273
|
}));
|
|
11191
|
-
var scanEffect2 = /* @__PURE__ */ dual(3, (self, initial, f) => self.channel.pipe(flattenArray, scanEffect(initial, f),
|
|
11274
|
+
var scanEffect2 = /* @__PURE__ */ dual(3, (self, initial, f) => self.channel.pipe(flattenArray, scanEffect(initial, f), map6(of), fromChannel2));
|
|
11192
11275
|
var debounce = /* @__PURE__ */ dual(2, (self, duration) => transformPull2(self, fnUntraced2(function* (pull, scope3) {
|
|
11193
11276
|
const clock = yield* Clock;
|
|
11194
11277
|
const durationMs = toMillis(fromInputUnsafe(duration));
|
|
@@ -11411,7 +11494,7 @@ var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (up
|
|
|
11411
11494
|
done4 = fail4(error);
|
|
11412
11495
|
return done2();
|
|
11413
11496
|
}));
|
|
11414
|
-
const pull =
|
|
11497
|
+
const pull = map5(suspend2(() => sink.transform(upstreamWithLeftover, scope3)), ([value, leftover_]) => {
|
|
11415
11498
|
leftover = leftover_;
|
|
11416
11499
|
return of(value);
|
|
11417
11500
|
});
|
|
@@ -11488,8 +11571,8 @@ var broadcastN = /* @__PURE__ */ dual(2, /* @__PURE__ */ fnUntraced2(function* (
|
|
|
11488
11571
|
return streams;
|
|
11489
11572
|
}));
|
|
11490
11573
|
var makePubSub2 = (options) => acquireRelease2(options.capacity === "unbounded" ? unbounded(options) : options.strategy === "dropping" ? dropping(options) : options.strategy === "sliding" ? sliding(options) : bounded(options), shutdown);
|
|
11491
|
-
var broadcast = /* @__PURE__ */ dual(2, (self, options) =>
|
|
11492
|
-
var share = /* @__PURE__ */ dual(2, (self, options) =>
|
|
11574
|
+
var broadcast = /* @__PURE__ */ dual(2, (self, options) => map5(toPubSubTake2(self, options), fromPubSubTake2));
|
|
11575
|
+
var share = /* @__PURE__ */ dual(2, (self, options) => map5(make15({
|
|
11493
11576
|
acquire: broadcast(self, options),
|
|
11494
11577
|
idleTimeToLive: options.idleTimeToLive
|
|
11495
11578
|
}), (ref) => unwrap2(get6(ref))));
|
|
@@ -11546,13 +11629,13 @@ var changesWithEffect = /* @__PURE__ */ dual(2, (self, f) => transformPull2(self
|
|
|
11546
11629
|
})));
|
|
11547
11630
|
var decodeText = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, options) => suspend4(() => {
|
|
11548
11631
|
const decoder = new TextDecoder(options?.encoding);
|
|
11549
|
-
return
|
|
11632
|
+
return map7(self, (chunk) => decoder.decode(chunk, {
|
|
11550
11633
|
stream: true
|
|
11551
11634
|
}));
|
|
11552
11635
|
}));
|
|
11553
11636
|
var encodeText = (self) => suspend4(() => {
|
|
11554
11637
|
const encoder = new TextEncoder();
|
|
11555
|
-
return
|
|
11638
|
+
return map7(self, (chunk) => encoder.encode(chunk));
|
|
11556
11639
|
});
|
|
11557
11640
|
var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel2);
|
|
11558
11641
|
var intersperse = /* @__PURE__ */ dual(2, (self, element) => mapArray(self, (arr, i) => {
|
|
@@ -11621,22 +11704,22 @@ var withSpan4 = function() {
|
|
|
11621
11704
|
return (self) => fromChannel2(withSpan3(self.channel, name, options));
|
|
11622
11705
|
};
|
|
11623
11706
|
var Do4 = /* @__PURE__ */ succeed7({});
|
|
11624
|
-
var let_5 = /* @__PURE__ */ dual(3, (self, name, f) =>
|
|
11707
|
+
var let_5 = /* @__PURE__ */ dual(3, (self, name, f) => map7(self, (a) => ({
|
|
11625
11708
|
...a,
|
|
11626
11709
|
[name]: f(a)
|
|
11627
11710
|
})));
|
|
11628
|
-
var bind5 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, tag, f, options) => flatMap5(self, (a) =>
|
|
11711
|
+
var bind5 = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, tag, f, options) => flatMap5(self, (a) => map7(f(a), (b) => ({
|
|
11629
11712
|
...a,
|
|
11630
11713
|
[tag]: b
|
|
11631
11714
|
})), options));
|
|
11632
|
-
var bindEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, tag, f, options) => mapEffect2(self, (a) =>
|
|
11715
|
+
var bindEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, tag, f, options) => mapEffect2(self, (a) => map5(f(a), (b) => ({
|
|
11633
11716
|
...a,
|
|
11634
11717
|
[tag]: b
|
|
11635
11718
|
})), options));
|
|
11636
|
-
var bindTo5 = /* @__PURE__ */ dual(2, (self, name) =>
|
|
11719
|
+
var bindTo5 = /* @__PURE__ */ dual(2, (self, name) => map7(self, (a) => ({
|
|
11637
11720
|
[name]: a
|
|
11638
11721
|
})));
|
|
11639
|
-
var run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope3) => toPullScoped(self.channel, scope3).pipe(flatMap3((upstream) => sink.transform(upstream, scope3)),
|
|
11722
|
+
var run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope3) => toPullScoped(self.channel, scope3).pipe(flatMap3((upstream) => sink.transform(upstream, scope3)), map5(([a]) => a))));
|
|
11640
11723
|
var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => {
|
|
11641
11724
|
for (let i = 0; i < chunk.length; i++) {
|
|
11642
11725
|
acc.push(chunk[i]);
|
|
@@ -11659,7 +11742,7 @@ var runFold2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFold(self.channe
|
|
|
11659
11742
|
var runFoldEffect2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFoldEffect(self.channel, initial, (acc, arr) => {
|
|
11660
11743
|
let i = 0;
|
|
11661
11744
|
let s = acc;
|
|
11662
|
-
return
|
|
11745
|
+
return map5(whileLoop2({
|
|
11663
11746
|
while: () => i < arr.length,
|
|
11664
11747
|
body: () => f(s, arr[i]),
|
|
11665
11748
|
step(z) {
|
|
@@ -11668,8 +11751,8 @@ var runFoldEffect2 = /* @__PURE__ */ dual(3, (self, initial, f) => runFoldEffect
|
|
|
11668
11751
|
}
|
|
11669
11752
|
}), () => s);
|
|
11670
11753
|
}));
|
|
11671
|
-
var runHead2 = (self) =>
|
|
11672
|
-
var runLast2 = (self) =>
|
|
11754
|
+
var runHead2 = (self) => map5(runHead(self.channel), map(getUnsafe(0)));
|
|
11755
|
+
var runLast2 = (self) => map5(runLast(self.channel), map(lastNonEmpty));
|
|
11673
11756
|
var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, (arr) => {
|
|
11674
11757
|
let i = 0;
|
|
11675
11758
|
return whileLoop2({
|
|
@@ -11681,7 +11764,7 @@ var runForEach2 = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel,
|
|
|
11681
11764
|
var runForEachWhile2 = /* @__PURE__ */ dual(2, (self, f) => runForEachWhile(self.channel, (arr) => {
|
|
11682
11765
|
let done4 = false;
|
|
11683
11766
|
let i = 0;
|
|
11684
|
-
return
|
|
11767
|
+
return map5(whileLoop2({
|
|
11685
11768
|
while: () => !done4 && i < arr.length,
|
|
11686
11769
|
body: () => f(arr[i]),
|
|
11687
11770
|
step(b) {
|
|
@@ -11694,7 +11777,7 @@ var runForEachArray = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.chann
|
|
|
11694
11777
|
var runDrain2 = (self) => runDrain(self.channel);
|
|
11695
11778
|
var toPull3 = (self) => toPull2(self.channel);
|
|
11696
11779
|
var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join(""));
|
|
11697
|
-
var mkArrayBuffer = (self) =>
|
|
11780
|
+
var mkArrayBuffer = (self) => map5(mkUint8Array(self.channel), (bytes) => bytes.buffer);
|
|
11698
11781
|
var mkUint8Array2 = (self) => mkUint8Array(self.channel);
|
|
11699
11782
|
var toReadableStreamWith = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, context3, options) => {
|
|
11700
11783
|
let currentResolve = void 0;
|
|
@@ -11719,19 +11802,19 @@ var toReadableStreamWith = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (
|
|
|
11719
11802
|
});
|
|
11720
11803
|
},
|
|
11721
11804
|
pull() {
|
|
11722
|
-
return new Promise((
|
|
11723
|
-
currentResolve =
|
|
11805
|
+
return new Promise((resolve5) => {
|
|
11806
|
+
currentResolve = resolve5;
|
|
11724
11807
|
latch.openUnsafe();
|
|
11725
11808
|
});
|
|
11726
11809
|
},
|
|
11727
11810
|
cancel() {
|
|
11728
11811
|
if (!fiber3) return;
|
|
11729
|
-
return runPromise2(
|
|
11812
|
+
return runPromise2(asVoid4(interrupt4(fiber3)));
|
|
11730
11813
|
}
|
|
11731
11814
|
}, options?.strategy);
|
|
11732
11815
|
});
|
|
11733
11816
|
var toReadableStream = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, options) => toReadableStreamWith(self, empty2(), options));
|
|
11734
|
-
var toReadableStreamEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, options) =>
|
|
11817
|
+
var toReadableStreamEffect = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, options) => map5(context2(), (context3) => toReadableStreamWith(self, context3, options)));
|
|
11735
11818
|
var toAsyncIterableWith = /* @__PURE__ */ dual(2, (self, context3) => ({
|
|
11736
11819
|
[Symbol.asyncIterator]() {
|
|
11737
11820
|
const runPromise3 = runPromiseWith2(context3);
|
|
@@ -11796,7 +11879,7 @@ var toAsyncIterableWith = /* @__PURE__ */ dual(2, (self, context3) => ({
|
|
|
11796
11879
|
};
|
|
11797
11880
|
}
|
|
11798
11881
|
}));
|
|
11799
|
-
var toAsyncIterableEffect = (self) =>
|
|
11882
|
+
var toAsyncIterableEffect = (self) => map5(context2(), (context3) => toAsyncIterableWith(self, context3));
|
|
11800
11883
|
var toAsyncIterable = (self) => toAsyncIterableWith(self, empty2());
|
|
11801
11884
|
var runIntoPubSub = /* @__PURE__ */ dual((args2) => isStream(args2[0]), (self, pubsub, options) => runIntoPubSubArray(self.channel, pubsub, options));
|
|
11802
11885
|
var toPubSub = /* @__PURE__ */ dual(2, (self, options) => toPubSubArray(self.channel, options));
|
|
@@ -12109,6 +12192,9 @@ function summarizeToolArguments(toolName, rawArgs) {
|
|
|
12109
12192
|
);
|
|
12110
12193
|
}
|
|
12111
12194
|
|
|
12195
|
+
// packages/agent-runtime/leafFinalHandoff.ts
|
|
12196
|
+
var LEAF_FINAL_HANDOFF_INSTRUCTIONS = `Leaf subtask final: return only the result, blockers/findings, and minimal evidence the parent needs. Do not narrate your process or restate the task. Keep success minimal (a one-line result is enough); on failure include the blocker, severity when relevant, and an evidence reference (file:line, test command, commit, artifact, or run/dialog). If the task explicitly requires a long-form deliverable (document, translation, dataset, code, or other artifact), provide that deliverable in full and keep only the handoff around it concise.`;
|
|
12197
|
+
|
|
12112
12198
|
// packages/agent-runtime/contextBlockScope.ts
|
|
12113
12199
|
var isContextBlockScope = (value) => {
|
|
12114
12200
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -12860,6 +12946,10 @@ async function runCompleteWithTimeout(args2) {
|
|
|
12860
12946
|
...model ? { model } : {},
|
|
12861
12947
|
...typeof usage?.provider_call_id === "string" && usage.provider_call_id.trim() ? { providerCallId: usage.provider_call_id.trim() } : {},
|
|
12862
12948
|
...errorMessage ? { errorMessage } : {},
|
|
12949
|
+
// 原始 usage 帧随行:CLI TUI 的实时积分(liveTurnCredits)靠它逐帧
|
|
12950
|
+
// 折算,不必等整轮结束才看到 ⚡ 增长。与 cache 投影互补——cache 是
|
|
12951
|
+
// token 级分析口径,usage 是计费口径(cost / billing_unit)。
|
|
12952
|
+
...usage && Object.keys(usage).length > 0 ? { usage } : {},
|
|
12863
12953
|
...inputTokens > 0 || cacheHit > 0 || cacheMiss > 0 ? {
|
|
12864
12954
|
cache: {
|
|
12865
12955
|
inputTokens,
|
|
@@ -13098,6 +13188,11 @@ ${metadataText}` : "";
|
|
|
13098
13188
|
if (embeddedMetadataIndex >= 0 && content.length <= args2.maxChars) {
|
|
13099
13189
|
return content;
|
|
13100
13190
|
}
|
|
13191
|
+
if (content.length <= args2.maxChars && content.includes(`
|
|
13192
|
+
|
|
13193
|
+
[${args2.label}; originalChars=`)) {
|
|
13194
|
+
return content;
|
|
13195
|
+
}
|
|
13101
13196
|
const headRatio = resolveToolOutputProfile(args2.toolName).headRatio;
|
|
13102
13197
|
const initialBudget = Math.max(
|
|
13103
13198
|
1,
|
|
@@ -13138,29 +13233,30 @@ ${suffix(clipped.length)}`;
|
|
|
13138
13233
|
}
|
|
13139
13234
|
return projected.length <= args2.maxChars ? projected : projected.slice(0, args2.maxChars);
|
|
13140
13235
|
}
|
|
13236
|
+
var TOOL_OUTPUT_PROJECTION_LABEL = "in-turn tool result truncated/projected before next provider call";
|
|
13141
13237
|
function summarizeHistoricalToolContent(content, toolName, metadata) {
|
|
13142
13238
|
return projectToolContentForProvider({
|
|
13143
13239
|
content,
|
|
13144
13240
|
toolName,
|
|
13145
13241
|
metadata,
|
|
13146
|
-
//
|
|
13147
|
-
//
|
|
13148
|
-
//
|
|
13149
|
-
|
|
13150
|
-
|
|
13242
|
+
// Stable projection contract: the SAME per-tool profile budget and label
|
|
13243
|
+
// as prepareMessagesForProviderCall, so the first provider-visible
|
|
13244
|
+
// representation of a tool execution is byte-identical on every later
|
|
13245
|
+
// round and across turns. Read-family profiles keep their ledger cap
|
|
13246
|
+
// (4800); unprofiled tools use the default profile (4000) instead of the
|
|
13247
|
+
// old flat 1600 — a historical rewrite below the fresh budget was itself
|
|
13248
|
+
// a cache-prefix break (see docs/plans/2026-09-05-tool-output-cache-stability.md).
|
|
13249
|
+
maxChars: resolveToolOutputProfile(toolName).maxChars,
|
|
13250
|
+
label: TOOL_OUTPUT_PROJECTION_LABEL
|
|
13151
13251
|
});
|
|
13152
13252
|
}
|
|
13153
13253
|
function prepareMessagesForProviderCall(messages) {
|
|
13154
13254
|
const paired = sanitizeToolCallPairing(messages);
|
|
13155
|
-
let freshRunStart = paired.length;
|
|
13156
|
-
while (freshRunStart > 0 && paired[freshRunStart - 1].role === "tool") {
|
|
13157
|
-
freshRunStart -= 1;
|
|
13158
|
-
}
|
|
13159
13255
|
let toolMessageCount = 0;
|
|
13160
13256
|
let rawToolContentChars = 0;
|
|
13161
13257
|
let projectedToolContentChars = 0;
|
|
13162
13258
|
let truncatedToolResults = 0;
|
|
13163
|
-
const projected = paired.map((message
|
|
13259
|
+
const projected = paired.map((message) => {
|
|
13164
13260
|
const { context_reference: _contextReference, ...providerMessage } = message;
|
|
13165
13261
|
const sanitizedContent = providerMessage.content == null ? "" : typeof providerMessage.content === "string" ? providerMessage.content : providerMessage.content;
|
|
13166
13262
|
if (providerMessage.role !== "tool") {
|
|
@@ -13171,14 +13267,12 @@ function prepareMessagesForProviderCall(messages) {
|
|
|
13171
13267
|
}
|
|
13172
13268
|
toolMessageCount += 1;
|
|
13173
13269
|
rawToolContentChars += contentCharCount(sanitizedContent);
|
|
13174
|
-
const isFresh = index >= freshRunStart;
|
|
13175
|
-
const maxChars = isFresh ? FRESH_TOOL_OUTPUT_MAX_CHARS : resolveToolOutputProfile(providerMessage.toolName).maxChars;
|
|
13176
13270
|
const projectedContent = projectToolContentForProvider({
|
|
13177
13271
|
content: sanitizedContent,
|
|
13178
13272
|
toolName: providerMessage.toolName,
|
|
13179
13273
|
metadata: providerMessage.tool_result_metadata,
|
|
13180
|
-
maxChars,
|
|
13181
|
-
label:
|
|
13274
|
+
maxChars: resolveToolOutputProfile(providerMessage.toolName).maxChars,
|
|
13275
|
+
label: TOOL_OUTPUT_PROJECTION_LABEL
|
|
13182
13276
|
});
|
|
13183
13277
|
projectedToolContentChars += contentCharCount(projectedContent);
|
|
13184
13278
|
if (contentCharCount(projectedContent) < contentCharCount(sanitizedContent)) {
|
|
@@ -13415,7 +13509,7 @@ async function runLocalAgentTurn(input) {
|
|
|
13415
13509
|
}
|
|
13416
13510
|
try {
|
|
13417
13511
|
loopTimingMark("turnStart", 0);
|
|
13418
|
-
|
|
13512
|
+
let agentConfig = await input.adapter.loadAgentConfig(input.agentRef);
|
|
13419
13513
|
if (!agentConfig) {
|
|
13420
13514
|
const error = new Error(
|
|
13421
13515
|
`agentRef "${input.agentRef}" \u672A\u5339\u914D\u5230\u672C\u5730 agent\u3002\u8FD9\u4E0D\u662F\u914D\u7F6E\u7F3A\u5931\uFF0C\u8BF7\u7528 listAgents \u67E5\u770B\u53EF\u7528 agent\uFF0C\u518D\u7528 readAgent \u89E3\u6790 agentKey\uFF0C\u52FF\u624B\u5DE5\u62FC key\u3002`
|
|
@@ -13424,6 +13518,26 @@ async function runLocalAgentTurn(input) {
|
|
|
13424
13518
|
error.agentRef = input.agentRef;
|
|
13425
13519
|
throw error;
|
|
13426
13520
|
}
|
|
13521
|
+
const runtimeContext = input.runtimeContext;
|
|
13522
|
+
const runConstraints = {
|
|
13523
|
+
allowedToolNames: Array.isArray(runtimeContext?.allowedToolNames) ? runtimeContext.allowedToolNames : void 0,
|
|
13524
|
+
blockedToolNames: Array.isArray(runtimeContext?.blockedToolNames) ? runtimeContext.blockedToolNames : void 0
|
|
13525
|
+
};
|
|
13526
|
+
if (runConstraints.allowedToolNames !== void 0 || runConstraints.blockedToolNames !== void 0) {
|
|
13527
|
+
const toolNames = Array.isArray(agentConfig.toolNames) ? agentConfig.toolNames : [];
|
|
13528
|
+
const constrainedSurface = applyToolSurfaceConstraints(
|
|
13529
|
+
{ explicitToolNames: toolNames, injectedToolNames: [], finalToolNames: toolNames },
|
|
13530
|
+
runConstraints
|
|
13531
|
+
);
|
|
13532
|
+
agentConfig = {
|
|
13533
|
+
...agentConfig,
|
|
13534
|
+
toolNames: constrainedSurface.finalToolNames,
|
|
13535
|
+
exposedToolNames: constrainedSurface.finalToolNames,
|
|
13536
|
+
...agentConfig.rawRecord ? { rawRecord: { ...agentConfig.rawRecord, toolNames: constrainedSurface.finalToolNames } } : {},
|
|
13537
|
+
toolSurface: constrainedSurface,
|
|
13538
|
+
runScopedToolSurface: constrainedSurface
|
|
13539
|
+
};
|
|
13540
|
+
}
|
|
13427
13541
|
const rawBillingConfig = agentConfig.rawRecord ?? {};
|
|
13428
13542
|
const billingConfig = {
|
|
13429
13543
|
model: agentConfig.model || "unknown",
|
|
@@ -13469,11 +13583,9 @@ async function runLocalAgentTurn(input) {
|
|
|
13469
13583
|
guidanceBlocks.emailRegistrationWorkflow,
|
|
13470
13584
|
// 注入顺序遵循 TOOL_GUIDED_SECTION_ORDER(与 buildSystemPrompt 的显式
|
|
13471
13585
|
// layer 列表同源),禁止用 Object.values 自行定序。
|
|
13472
|
-
...TOOL_GUIDED_SECTION_ORDER.map((id) => toolGuidedSections[id] ?? "")
|
|
13586
|
+
...TOOL_GUIDED_SECTION_ORDER.map((id) => toolGuidedSections[id] ?? ""),
|
|
13587
|
+
...input.runKind === "subtask" ? [LEAF_FINAL_HANDOFF_INSTRUCTIONS] : []
|
|
13473
13588
|
].map((content) => content.trim()).filter((content) => content.length > 0).map((content) => ({ content, cacheScope: "session" }));
|
|
13474
|
-
const currentTimeScope = [
|
|
13475
|
-
{ content: buildCurrentTimeBlock(/* @__PURE__ */ new Date(), void 0), cacheScope: "turn" }
|
|
13476
|
-
];
|
|
13477
13589
|
const callerScopes = normalizeContextBlockScopes(
|
|
13478
13590
|
input.contextBlocks,
|
|
13479
13591
|
input.contextBlockScopes
|
|
@@ -13481,7 +13593,6 @@ async function runLocalAgentTurn(input) {
|
|
|
13481
13593
|
const mergedContextBlockScopes = [
|
|
13482
13594
|
{ content: identityBlock, cacheScope: "session" },
|
|
13483
13595
|
...guidanceScopes,
|
|
13484
|
-
...currentTimeScope,
|
|
13485
13596
|
...callerScopes
|
|
13486
13597
|
];
|
|
13487
13598
|
loopTimingMark("buildContextBlocks", 0);
|
|
@@ -13702,6 +13813,14 @@ async function runLocalAgentTurn(input) {
|
|
|
13702
13813
|
};
|
|
13703
13814
|
break;
|
|
13704
13815
|
}
|
|
13816
|
+
if (result4.runtimeProviderFailure) {
|
|
13817
|
+
result4 = {
|
|
13818
|
+
...result4,
|
|
13819
|
+
error: true,
|
|
13820
|
+
errorMessage: result4.runtimeProviderFailure.message
|
|
13821
|
+
};
|
|
13822
|
+
break;
|
|
13823
|
+
}
|
|
13705
13824
|
const toolCalls = result4.tool_calls ?? [];
|
|
13706
13825
|
const rawToolCallsCount = (result4.tool_calls?.length ?? 0) || (Array.isArray(result4.raw_tool_calls) ? result4.raw_tool_calls.length : 0);
|
|
13707
13826
|
loopTimingMark("postLlmProcessing", round);
|
|
@@ -13877,6 +13996,7 @@ ${reasoningTailLog}
|
|
|
13877
13996
|
arguments: toolCall.function.arguments,
|
|
13878
13997
|
...userInputText ? { userInput: userInputText } : {},
|
|
13879
13998
|
...input.runtimeContext ? { runtimeContext: input.runtimeContext } : {},
|
|
13999
|
+
...agentConfig.runScopedToolSurface?.finalToolNames ? { runToolNames: agentConfig.runScopedToolSurface.finalToolNames } : {},
|
|
13880
14000
|
...input.abortSignal ? { abortSignal: input.abortSignal } : {}
|
|
13881
14001
|
}, {
|
|
13882
14002
|
...input.abortSignal ? { abortSignal: input.abortSignal } : {},
|
|
@@ -14187,7 +14307,14 @@ function createResponsesStreamCollector(callbacks) {
|
|
|
14187
14307
|
let usage;
|
|
14188
14308
|
let failure;
|
|
14189
14309
|
let completedResponse;
|
|
14310
|
+
let sawMeaningfulDelta = false;
|
|
14311
|
+
const observeMeaningfulOnce = () => {
|
|
14312
|
+
if (sawMeaningfulDelta) return;
|
|
14313
|
+
sawMeaningfulDelta = true;
|
|
14314
|
+
callbacks?.onMeaningfulDelta?.();
|
|
14315
|
+
};
|
|
14190
14316
|
const processEvent = (ev) => {
|
|
14317
|
+
if (isMeaningfulResponsesOutput(ev)) observeMeaningfulOnce();
|
|
14191
14318
|
const type = String(ev.type ?? "");
|
|
14192
14319
|
if (type === "error") {
|
|
14193
14320
|
failure = failure ?? toResponsesStreamFailure(ev.error, callbacks?.fallbackPrefix);
|
|
@@ -14264,7 +14391,10 @@ function createResponsesStreamCollector(callbacks) {
|
|
|
14264
14391
|
};
|
|
14265
14392
|
}
|
|
14266
14393
|
function aggregateResponsesStream(events, options) {
|
|
14267
|
-
const collector = createResponsesStreamCollector({
|
|
14394
|
+
const collector = createResponsesStreamCollector({
|
|
14395
|
+
fallbackPrefix: options?.fallbackPrefix ?? "Codex",
|
|
14396
|
+
...options?.onMeaningfulDelta ? { onMeaningfulDelta: options.onMeaningfulDelta } : {}
|
|
14397
|
+
});
|
|
14268
14398
|
for (const ev of events) {
|
|
14269
14399
|
collector.processEvent(ev);
|
|
14270
14400
|
}
|
|
@@ -14280,6 +14410,7 @@ async function readResponsesSseCompletion(args2) {
|
|
|
14280
14410
|
const collector = createResponsesStreamCollector({
|
|
14281
14411
|
onTextDelta: args2.onTextDelta,
|
|
14282
14412
|
onReasoningDelta: args2.onReasoningDelta,
|
|
14413
|
+
...args2.onMeaningfulDelta ? { onMeaningfulDelta: args2.onMeaningfulDelta } : {},
|
|
14283
14414
|
fallbackPrefix: args2.fallbackPrefix ?? "Responses"
|
|
14284
14415
|
});
|
|
14285
14416
|
for await (const frame of readSseFrames(args2.response)) {
|
|
@@ -14338,7 +14469,8 @@ function buildOpenAiCompatibleChatCompletionRequest(args2) {
|
|
|
14338
14469
|
const body = isResponses ? buildResponsesRequestBody(rawBody, args2.providerConfig.model) : normalizeChatCompletionsBodyForProvider({
|
|
14339
14470
|
body: rawBody,
|
|
14340
14471
|
provider: args2.providerConfig.provider,
|
|
14341
|
-
model: args2.providerConfig.model
|
|
14472
|
+
model: args2.providerConfig.model,
|
|
14473
|
+
endpoint: args2.providerConfig.endpoint
|
|
14342
14474
|
});
|
|
14343
14475
|
const endpoint = args2.providerConfig.endpoint;
|
|
14344
14476
|
const headers = {
|
|
@@ -14423,6 +14555,7 @@ async function readOpenAiCompatibleSseCompletion(args2) {
|
|
|
14423
14555
|
toolCallTextState: createToolCallTextParserState(),
|
|
14424
14556
|
onTextDelta: args2.onTextDelta,
|
|
14425
14557
|
onReasoningDelta: args2.onReasoningDelta,
|
|
14558
|
+
...args2.onMeaningfulDelta ? { onMeaningfulDelta: args2.onMeaningfulDelta } : {},
|
|
14426
14559
|
sawDone: false
|
|
14427
14560
|
};
|
|
14428
14561
|
for await (const frame of readSseFrames(args2.response)) {
|
|
@@ -14443,6 +14576,8 @@ async function readOpenAiCompatibleSseCompletion(args2) {
|
|
|
14443
14576
|
}
|
|
14444
14577
|
async function executeOpenAiCompatibleChatCompletion(args2) {
|
|
14445
14578
|
const isResponses = resolveOpenAiCompatibleWire(args2.providerConfig) === "responses";
|
|
14579
|
+
const timingTracker = createProviderCallTimingTracker();
|
|
14580
|
+
const observeMeaningful = () => observeMeaningfulProviderResponse(timingTracker);
|
|
14446
14581
|
const send = async (apiKey2) => {
|
|
14447
14582
|
const request3 = buildOpenAiCompatibleChatCompletionRequest({
|
|
14448
14583
|
providerConfig: apiKey2 === args2.providerConfig.apiKey ? args2.providerConfig : { ...args2.providerConfig, apiKey: apiKey2 },
|
|
@@ -14486,14 +14621,22 @@ async function executeOpenAiCompatibleChatCompletion(args2) {
|
|
|
14486
14621
|
await args2.onHttpResult?.({ status: res.status });
|
|
14487
14622
|
const contentType = res.headers.get("content-type") ?? "";
|
|
14488
14623
|
const isEventStream = contentType.includes("text/event-stream");
|
|
14624
|
+
const withTiming = (result4) => {
|
|
14625
|
+
const usage = withProviderCallTimingFields(
|
|
14626
|
+
result4.usage,
|
|
14627
|
+
finalizeProviderCallTiming(timingTracker)
|
|
14628
|
+
);
|
|
14629
|
+
return { ...result4, ...usage ? { usage } : {} };
|
|
14630
|
+
};
|
|
14489
14631
|
if (isEventStream) {
|
|
14490
14632
|
if (isResponses) {
|
|
14491
14633
|
const streamed2 = await readResponsesSseCompletion({
|
|
14492
14634
|
response: res,
|
|
14493
14635
|
...args2.onTextDelta ? { onTextDelta: args2.onTextDelta } : {},
|
|
14494
|
-
...args2.onReasoningDelta ? { onReasoningDelta: args2.onReasoningDelta } : {}
|
|
14636
|
+
...args2.onReasoningDelta ? { onReasoningDelta: args2.onReasoningDelta } : {},
|
|
14637
|
+
onMeaningfulDelta: observeMeaningful
|
|
14495
14638
|
});
|
|
14496
|
-
return {
|
|
14639
|
+
return withTiming({
|
|
14497
14640
|
content: streamed2.content,
|
|
14498
14641
|
model: args2.providerConfig.model,
|
|
14499
14642
|
provider: args2.providerConfig.provider,
|
|
@@ -14503,14 +14646,15 @@ async function executeOpenAiCompatibleChatCompletion(args2) {
|
|
|
14503
14646
|
...streamed2.stream_complete ? { stream_complete: true } : {},
|
|
14504
14647
|
...streamed2.finish_reason ? { finish_reason: streamed2.finish_reason } : {},
|
|
14505
14648
|
trace: args2.messages
|
|
14506
|
-
};
|
|
14649
|
+
});
|
|
14507
14650
|
}
|
|
14508
14651
|
const streamed = await readOpenAiCompatibleSseCompletion({
|
|
14509
14652
|
response: res,
|
|
14510
14653
|
...args2.onTextDelta ? { onTextDelta: args2.onTextDelta } : {},
|
|
14511
|
-
...args2.onReasoningDelta ? { onReasoningDelta: args2.onReasoningDelta } : {}
|
|
14654
|
+
...args2.onReasoningDelta ? { onReasoningDelta: args2.onReasoningDelta } : {},
|
|
14655
|
+
onMeaningfulDelta: observeMeaningful
|
|
14512
14656
|
});
|
|
14513
|
-
return {
|
|
14657
|
+
return withTiming({
|
|
14514
14658
|
content: streamed.content,
|
|
14515
14659
|
model: args2.providerConfig.model,
|
|
14516
14660
|
provider: args2.providerConfig.provider,
|
|
@@ -14520,7 +14664,7 @@ async function executeOpenAiCompatibleChatCompletion(args2) {
|
|
|
14520
14664
|
...streamed.stream_complete ? { stream_complete: true } : {},
|
|
14521
14665
|
...streamed.finish_reason ? { finish_reason: streamed.finish_reason } : {},
|
|
14522
14666
|
trace: args2.messages
|
|
14523
|
-
};
|
|
14667
|
+
});
|
|
14524
14668
|
}
|
|
14525
14669
|
const raw = await res.text().catch(() => "");
|
|
14526
14670
|
let data = {};
|
|
@@ -14530,17 +14674,17 @@ async function executeOpenAiCompatibleChatCompletion(args2) {
|
|
|
14530
14674
|
data = {};
|
|
14531
14675
|
}
|
|
14532
14676
|
if (isResponses) {
|
|
14533
|
-
return parseOpenAiCompatibleResponsesResponse({
|
|
14677
|
+
return withTiming(parseOpenAiCompatibleResponsesResponse({
|
|
14534
14678
|
providerConfig: args2.providerConfig,
|
|
14535
14679
|
data,
|
|
14536
14680
|
trace: args2.messages
|
|
14537
|
-
});
|
|
14681
|
+
}));
|
|
14538
14682
|
}
|
|
14539
|
-
return parseOpenAiCompatibleChatCompletionResponse({
|
|
14683
|
+
return withTiming(parseOpenAiCompatibleChatCompletionResponse({
|
|
14540
14684
|
providerConfig: args2.providerConfig,
|
|
14541
14685
|
data,
|
|
14542
14686
|
trace: args2.messages
|
|
14543
|
-
});
|
|
14687
|
+
}));
|
|
14544
14688
|
}
|
|
14545
14689
|
|
|
14546
14690
|
// packages/agent-runtime/openAiCompatibleProviderConfig.ts
|
|
@@ -14703,6 +14847,11 @@ function dialogMessageRecordToAgentRuntimeMessage(record) {
|
|
|
14703
14847
|
...typeof record.toolCallId === "string" ? { tool_call_id: record.toolCallId } : {},
|
|
14704
14848
|
...Array.isArray(record.tool_calls) ? { tool_calls: record.tool_calls } : {},
|
|
14705
14849
|
...typeof record.toolName === "string" ? { toolName: record.toolName } : {},
|
|
14850
|
+
// 写侧(dialogWritePlan)把 tool_result_metadata 以 `metadata` 字段落库;
|
|
14851
|
+
// 回读必须还原,否则跨 turn 投影丢失 metadata 后缀,同一 tool 消息的字节
|
|
14852
|
+
// 在 turn 边界漂移 → provider 前缀缓存断裂(stable projection 契约,
|
|
14853
|
+
// 见 docs/plans/2026-09-05-tool-output-cache-stability.md)。
|
|
14854
|
+
...record.metadata && typeof record.metadata === "object" ? { tool_result_metadata: record.metadata } : {},
|
|
14706
14855
|
...(() => {
|
|
14707
14856
|
const raw = record.createdAt;
|
|
14708
14857
|
const ms = typeof raw === "number" ? raw : typeof raw === "string" ? Date.parse(raw) : NaN;
|
|
@@ -15460,6 +15609,9 @@ function resolveLocalToolPolicy(args2) {
|
|
|
15460
15609
|
};
|
|
15461
15610
|
}
|
|
15462
15611
|
async function executeLocalToolWithPolicy(args2) {
|
|
15612
|
+
if (args2.runToolNames !== void 0 && !args2.runToolNames.includes(normalizeLocalToolName(args2.call.name))) {
|
|
15613
|
+
throw new Error(`${args2.call.name} is outside the final run tool surface.`);
|
|
15614
|
+
}
|
|
15463
15615
|
const decision = resolveLocalToolPolicy({
|
|
15464
15616
|
env: args2.env,
|
|
15465
15617
|
agentToolNames: args2.agentToolNames,
|
|
@@ -15502,9 +15654,9 @@ async function executeLocalToolWithPolicy(args2) {
|
|
|
15502
15654
|
// packages/agent-runtime/localWorkspaceTools.ts
|
|
15503
15655
|
import { existsSync as existsSync3 } from "node:fs";
|
|
15504
15656
|
import { createHash as createHash3 } from "node:crypto";
|
|
15505
|
-
import { mkdir, readdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
15506
|
-
import { dirname, relative as
|
|
15507
|
-
import { spawn as
|
|
15657
|
+
import { lstat, mkdir, readdir as readdir2, readFile as readFile3, realpath, stat as stat3, writeFile } from "node:fs/promises";
|
|
15658
|
+
import { dirname, isAbsolute as isAbsolute2, relative as relative3, resolve as resolve4, sep } from "node:path";
|
|
15659
|
+
import { spawn as spawnChildProcess3 } from "node:child_process";
|
|
15508
15660
|
|
|
15509
15661
|
// packages/core/readRangeLedger.ts
|
|
15510
15662
|
function filterRetainedLedgerRecords(records, retainedCap) {
|
|
@@ -15691,9 +15843,9 @@ function spawnToWebStreams(options) {
|
|
|
15691
15843
|
env: options.env,
|
|
15692
15844
|
stdio: ["ignore", "pipe", "pipe"]
|
|
15693
15845
|
});
|
|
15694
|
-
const exited = new Promise((
|
|
15695
|
-
child.on("exit", (code) =>
|
|
15696
|
-
child.on("error", () =>
|
|
15846
|
+
const exited = new Promise((resolve5) => {
|
|
15847
|
+
child.on("exit", (code) => resolve5(code ?? 1));
|
|
15848
|
+
child.on("error", () => resolve5(127));
|
|
15697
15849
|
});
|
|
15698
15850
|
const toWeb = (stream) => {
|
|
15699
15851
|
if (!stream) return null;
|
|
@@ -15712,6 +15864,200 @@ function spawnToWebStreams(options) {
|
|
|
15712
15864
|
};
|
|
15713
15865
|
}
|
|
15714
15866
|
|
|
15867
|
+
// packages/agent-runtime/fileTextSearch.ts
|
|
15868
|
+
import { readdir, readFile as readFile2, stat as stat2 } from "node:fs/promises";
|
|
15869
|
+
import { basename, relative as relative2, resolve as resolve2 } from "node:path";
|
|
15870
|
+
import { spawn as spawnChildProcess } from "node:child_process";
|
|
15871
|
+
|
|
15872
|
+
// packages/agent-runtime/gitignore.ts
|
|
15873
|
+
import { readFile, stat } from "node:fs/promises";
|
|
15874
|
+
import { resolve } from "node:path";
|
|
15875
|
+
async function readRootGitignorePatterns(workspaceRoot) {
|
|
15876
|
+
const content = await readFile(resolve(workspaceRoot, ".gitignore"), "utf8").catch(() => null);
|
|
15877
|
+
if (content === null) return [];
|
|
15878
|
+
return content.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("#") && !line.startsWith("!")).flatMap((line) => {
|
|
15879
|
+
const unanchored = line.replace(/^\//, "");
|
|
15880
|
+
if (unanchored.endsWith("/")) return [`${unanchored}**`];
|
|
15881
|
+
if (unanchored.includes("**")) return [unanchored];
|
|
15882
|
+
return [unanchored, `${unanchored}/**`];
|
|
15883
|
+
});
|
|
15884
|
+
}
|
|
15885
|
+
async function hasRootGitignore(workspaceRoot) {
|
|
15886
|
+
try {
|
|
15887
|
+
await stat(resolve(workspaceRoot, ".gitignore"));
|
|
15888
|
+
return true;
|
|
15889
|
+
} catch {
|
|
15890
|
+
return false;
|
|
15891
|
+
}
|
|
15892
|
+
}
|
|
15893
|
+
|
|
15894
|
+
// packages/agent-runtime/fileTextSearch.ts
|
|
15895
|
+
var normalizePath = (value) => value.replaceAll("\\", "/");
|
|
15896
|
+
var pathFor = (root, file, absolute = false) => absolute ? normalizePath(file) : normalizePath(relative2(root, file) || basename(file));
|
|
15897
|
+
var COMMAND_LIMIT_HEADROOM = 1;
|
|
15898
|
+
async function runCommand(binary, args2, cwd, maxResults) {
|
|
15899
|
+
const recordLimit = maxResults === void 0 ? 0 : Math.max(0, maxResults) + COMMAND_LIMIT_HEADROOM;
|
|
15900
|
+
return await new Promise((done4) => {
|
|
15901
|
+
let stdout = "", stderr = "", recordCount = 0, stopped = false;
|
|
15902
|
+
try {
|
|
15903
|
+
const child = spawnChildProcess(binary, args2, { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
15904
|
+
child.stdout.on("data", (chunk) => {
|
|
15905
|
+
stdout += chunk.toString();
|
|
15906
|
+
recordCount = parseMatches(cwd, stdout).length;
|
|
15907
|
+
if (recordLimit > 0 && recordCount >= recordLimit && !stopped) {
|
|
15908
|
+
stopped = true;
|
|
15909
|
+
child.kill();
|
|
15910
|
+
}
|
|
15911
|
+
});
|
|
15912
|
+
child.stderr.on("data", (chunk) => {
|
|
15913
|
+
stderr += chunk.toString();
|
|
15914
|
+
});
|
|
15915
|
+
child.on("error", () => done4({ stdout, stderr, outcome: { kind: "spawn-failed" } }));
|
|
15916
|
+
child.on("close", (exitCode) => done4({ stdout, stderr, outcome: stopped ? { kind: "stopped-by-limit" } : { kind: "completed", exitCode } }));
|
|
15917
|
+
} catch {
|
|
15918
|
+
done4({ stdout, stderr, outcome: { kind: "spawn-failed" } });
|
|
15919
|
+
}
|
|
15920
|
+
});
|
|
15921
|
+
}
|
|
15922
|
+
function commandArgs(o, binary, target) {
|
|
15923
|
+
const args2 = binary === "rg" ? ["--line-number", "--no-heading", "--color", "never", "--null"] : ["-RIn", "--binary-files=without-match", "--null"];
|
|
15924
|
+
if (binary === "rg") args2.push("--no-require-git");
|
|
15925
|
+
if (o.regex !== true) args2.push(binary === "rg" ? "--fixed-strings" : "-F");
|
|
15926
|
+
else if (binary === "grep") args2.push("-E");
|
|
15927
|
+
if (o.caseSensitive === false) args2.push("-i");
|
|
15928
|
+
if (binary === "rg") {
|
|
15929
|
+
if (o.includeIgnored) args2.push("--no-ignore");
|
|
15930
|
+
for (const x of o.exclude ?? []) args2.push("--glob", `!${x}`);
|
|
15931
|
+
if (o.include) args2.push("--glob", o.include);
|
|
15932
|
+
} else {
|
|
15933
|
+
for (const x of o.exclude ?? []) {
|
|
15934
|
+
const clean = x.replace(/\/\*\*$/, "");
|
|
15935
|
+
if (clean && !clean.includes("/")) args2.push("--exclude-dir", clean);
|
|
15936
|
+
}
|
|
15937
|
+
if (o.include) args2.push("--include", o.include);
|
|
15938
|
+
}
|
|
15939
|
+
args2.push("--", o.query, target);
|
|
15940
|
+
return args2;
|
|
15941
|
+
}
|
|
15942
|
+
function parseMatches(root, output) {
|
|
15943
|
+
const records = [];
|
|
15944
|
+
const pattern = /(?:^|\n)([^\0\n]+)\0(\d+):(.*?)(?=\n[^\0\n]+\0|$)/gs;
|
|
15945
|
+
for (const match7 of output.matchAll(pattern)) {
|
|
15946
|
+
records.push({ file: resolve2(root, match7[1] ?? ""), line: Number(match7[2]), text: (match7[3] ?? "").replace(/\n$/, "") });
|
|
15947
|
+
}
|
|
15948
|
+
return records;
|
|
15949
|
+
}
|
|
15950
|
+
async function decorate(root, raw, context3, absolute = false) {
|
|
15951
|
+
const cache = /* @__PURE__ */ new Map(), out = [];
|
|
15952
|
+
for (const x of raw) {
|
|
15953
|
+
let lines = cache.get(x.file);
|
|
15954
|
+
if (!lines) {
|
|
15955
|
+
try {
|
|
15956
|
+
lines = (await readFile2(x.file, "utf8")).split(/\r\n|\r|\n/);
|
|
15957
|
+
} catch {
|
|
15958
|
+
continue;
|
|
15959
|
+
}
|
|
15960
|
+
cache.set(x.file, lines);
|
|
15961
|
+
}
|
|
15962
|
+
const i = x.line - 1;
|
|
15963
|
+
out.push({ path: pathFor(root, x.file, absolute), line: x.line, text: lines[i] ?? x.text, before: lines.slice(Math.max(0, i - context3), i), after: lines.slice(i + 1, i + context3 + 1) });
|
|
15964
|
+
}
|
|
15965
|
+
return out;
|
|
15966
|
+
}
|
|
15967
|
+
function globMatch(pattern, value) {
|
|
15968
|
+
const p = normalizePath(pattern).replace(/^!/, "");
|
|
15969
|
+
let source = "";
|
|
15970
|
+
for (let i = 0; i < p.length; i++) {
|
|
15971
|
+
const c = p[i];
|
|
15972
|
+
if (c === "*" && p[i + 1] === "*") {
|
|
15973
|
+
i++;
|
|
15974
|
+
if (p[i + 1] === "/") {
|
|
15975
|
+
i++;
|
|
15976
|
+
source += "(?:.*/)?";
|
|
15977
|
+
} else source += ".*";
|
|
15978
|
+
} else if (c === "*") source += "[^/]*";
|
|
15979
|
+
else if (c === "?") source += "[^/]";
|
|
15980
|
+
else source += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
15981
|
+
}
|
|
15982
|
+
const r = new RegExp(`^${source}$`);
|
|
15983
|
+
return r.test(value) || r.test(basename(value));
|
|
15984
|
+
}
|
|
15985
|
+
var defaultReadTextFile = (filePath) => readFile2(filePath, "utf8").catch(() => "");
|
|
15986
|
+
async function jsSearch(o, targetPath) {
|
|
15987
|
+
const max4 = o.maxResults ?? Number.MAX_SAFE_INTEGER;
|
|
15988
|
+
const excludes = o.exclude ?? [];
|
|
15989
|
+
const readText = o.readTextFile ?? defaultReadTextFile;
|
|
15990
|
+
const files = [];
|
|
15991
|
+
const targetStat = await stat2(targetPath).catch(() => null);
|
|
15992
|
+
if (!targetStat) return { matches: [], totalMatches: 0, truncated: false, engine: "js" };
|
|
15993
|
+
const ignorePatterns = o.includeIgnored ? [] : await readRootGitignorePatterns(o.root);
|
|
15994
|
+
const isIgnored = (rel) => ignorePatterns.some((pattern) => globMatch(pattern, rel));
|
|
15995
|
+
const isSearchableFile = (filePath) => {
|
|
15996
|
+
const rel = pathFor(o.root, filePath);
|
|
15997
|
+
return !excludes.some((pattern) => globMatch(pattern, rel)) && !isIgnored(rel) && (!o.include || globMatch(o.include, rel));
|
|
15998
|
+
};
|
|
15999
|
+
if (targetStat.isFile()) {
|
|
16000
|
+
if (isSearchableFile(targetPath)) files.push(targetPath);
|
|
16001
|
+
} else {
|
|
16002
|
+
const walk = async (dir) => {
|
|
16003
|
+
for (const e of await readdir(dir, { withFileTypes: true })) {
|
|
16004
|
+
const f = resolve2(dir, e.name), rel = pathFor(o.root, f);
|
|
16005
|
+
if (e.isDirectory()) {
|
|
16006
|
+
if (!excludes.some((p) => globMatch(p, rel))) await walk(f);
|
|
16007
|
+
} else if (e.isFile() && !excludes.some((p) => globMatch(p, rel)) && !isIgnored(rel) && (!o.include || globMatch(o.include, rel))) {
|
|
16008
|
+
files.push(f);
|
|
16009
|
+
}
|
|
16010
|
+
}
|
|
16011
|
+
};
|
|
16012
|
+
await walk(targetPath);
|
|
16013
|
+
}
|
|
16014
|
+
const matcher = o.regex ? new RegExp(o.query, o.caseSensitive === false ? "i" : "") : null;
|
|
16015
|
+
const needle = o.caseSensitive === false ? o.query.toLowerCase() : o.query;
|
|
16016
|
+
const out = [], context3 = o.contextLines ?? 0;
|
|
16017
|
+
for (const file of files) {
|
|
16018
|
+
const text = await readText(file);
|
|
16019
|
+
if (!text || text.includes("\0")) continue;
|
|
16020
|
+
const lines = text.split(/\r\n|\r|\n/);
|
|
16021
|
+
for (let i = 0; i < lines.length; i++) {
|
|
16022
|
+
const line = lines[i] ?? "";
|
|
16023
|
+
const hit = matcher ? matcher.test(line) : o.caseSensitive === false ? line.toLowerCase().includes(needle) : line.includes(needle);
|
|
16024
|
+
if (!hit) continue;
|
|
16025
|
+
if (out.length >= max4) return { matches: out, totalMatches: max4, truncated: true, engine: "js" };
|
|
16026
|
+
out.push({ path: pathFor(o.root, file, o.absolutePaths === true), line: i + 1, text: line, before: lines.slice(Math.max(0, i - context3), i), after: lines.slice(i + 1, i + context3 + 1) });
|
|
16027
|
+
}
|
|
16028
|
+
}
|
|
16029
|
+
return { matches: out, totalMatches: out.length, truncated: false, engine: "js" };
|
|
16030
|
+
}
|
|
16031
|
+
var COMMAND_ENGINES = [
|
|
16032
|
+
{ engine: "ripgrep", binaryOption: "resolveRipgrepBinary", binaryName: "rg", argsKey: "rg" },
|
|
16033
|
+
{ engine: "grep", binaryOption: "resolveGrepBinary", binaryName: "grep", argsKey: "grep" }
|
|
16034
|
+
];
|
|
16035
|
+
async function searchFileTextMatches(o) {
|
|
16036
|
+
const targetPath = resolve2(o.root, o.target || ".");
|
|
16037
|
+
const targetStat = await stat2(targetPath).catch(() => null);
|
|
16038
|
+
if (!targetStat) return { matches: [], totalMatches: 0, truncated: false, engine: "js" };
|
|
16039
|
+
if (targetStat.isFile()) return jsSearch(o, targetPath);
|
|
16040
|
+
const run2 = o.runCommand ?? runCommand, max4 = o.maxResults;
|
|
16041
|
+
for (const entry of COMMAND_ENGINES) {
|
|
16042
|
+
const injectedResolver = o[entry.binaryOption];
|
|
16043
|
+
const binary = injectedResolver ? injectedResolver() : resolveExecutableOnPath(entry.binaryName);
|
|
16044
|
+
if (!binary) continue;
|
|
16045
|
+
const result4 = await run2(binary, commandArgs(o, entry.argsKey, o.target || "."), o.root, max4);
|
|
16046
|
+
const raw = parseMatches(o.root, result4.stdout);
|
|
16047
|
+
const hardFailed = result4.outcome.kind === "spawn-failed" || result4.outcome.kind === "completed" && result4.outcome.exitCode !== 0 && result4.outcome.exitCode !== 1;
|
|
16048
|
+
if (hardFailed) continue;
|
|
16049
|
+
const truncated = raw.length > (max4 ?? Number.MAX_SAFE_INTEGER);
|
|
16050
|
+
const matches = await decorate(o.root, raw.slice(0, max4), o.contextLines ?? 0, o.absolutePaths === true);
|
|
16051
|
+
return {
|
|
16052
|
+
matches,
|
|
16053
|
+
totalMatches: truncated ? matches.length : raw.length,
|
|
16054
|
+
truncated,
|
|
16055
|
+
engine: entry.engine
|
|
16056
|
+
};
|
|
16057
|
+
}
|
|
16058
|
+
return jsSearch(o, targetPath);
|
|
16059
|
+
}
|
|
16060
|
+
|
|
15715
16061
|
// packages/agent-runtime/processTask.ts
|
|
15716
16062
|
var PROCESS_TASK_TERMINAL_STATUSES = [
|
|
15717
16063
|
"stopped",
|
|
@@ -15844,9 +16190,38 @@ var ProcessRegistry = class {
|
|
|
15844
16190
|
processes = /* @__PURE__ */ new Map();
|
|
15845
16191
|
byTaskId = /* @__PURE__ */ new Map();
|
|
15846
16192
|
eventLog;
|
|
16193
|
+
terminalListeners = /* @__PURE__ */ new Set();
|
|
15847
16194
|
constructor(eventLogOptions) {
|
|
15848
16195
|
this.eventLog = new ProcessTaskEventLog(eventLogOptions);
|
|
15849
16196
|
}
|
|
16197
|
+
/**
|
|
16198
|
+
* Subscribe to terminal transitions (markExited / kill). Fired synchronously
|
|
16199
|
+
* at the same instant the terminal event is appended to the task event log,
|
|
16200
|
+
* so consumers (TUI pending-notice buffer) observe the same ordering as the
|
|
16201
|
+
* audit stream. Each task fires at most once: markExited is gated on the
|
|
16202
|
+
* "running" status, kill()/stopAll() on the same guard, and late close
|
|
16203
|
+
* events after a user stop are already suppressed by the status check.
|
|
16204
|
+
*
|
|
16205
|
+
* Returns an unsubscribe function. Registration does NOT replay terminal
|
|
16206
|
+
* states for tasks that already terminated before subscription (no
|
|
16207
|
+
* backfill): the event log keeps the audit trail, and replaying would
|
|
16208
|
+
* double-notify tasks the previous session already surfaced.
|
|
16209
|
+
*/
|
|
16210
|
+
onProcessTerminal(listener) {
|
|
16211
|
+
this.terminalListeners.add(listener);
|
|
16212
|
+
return () => {
|
|
16213
|
+
this.terminalListeners.delete(listener);
|
|
16214
|
+
};
|
|
16215
|
+
}
|
|
16216
|
+
/** Emit a terminal notice synchronously; listener errors must not break registry callers. */
|
|
16217
|
+
emitTerminal(notice) {
|
|
16218
|
+
for (const listener of [...this.terminalListeners]) {
|
|
16219
|
+
try {
|
|
16220
|
+
listener(notice);
|
|
16221
|
+
} catch {
|
|
16222
|
+
}
|
|
16223
|
+
}
|
|
16224
|
+
}
|
|
15850
16225
|
/**
|
|
15851
16226
|
* Pre-register an envelope right after a successful spawn and emit the
|
|
15852
16227
|
* `started` event. Returns the stored record (with its stable taskId).
|
|
@@ -15944,6 +16319,13 @@ var ProcessRegistry = class {
|
|
|
15944
16319
|
}
|
|
15945
16320
|
item.status = "stopped";
|
|
15946
16321
|
this.eventLog.append({ taskId: item.taskId, pid, type: "killed" });
|
|
16322
|
+
this.emitTerminal({
|
|
16323
|
+
taskId: item.taskId,
|
|
16324
|
+
pid,
|
|
16325
|
+
label: item.label,
|
|
16326
|
+
command: item.command,
|
|
16327
|
+
status: "stopped"
|
|
16328
|
+
});
|
|
15947
16329
|
return true;
|
|
15948
16330
|
}
|
|
15949
16331
|
return false;
|
|
@@ -15958,6 +16340,13 @@ var ProcessRegistry = class {
|
|
|
15958
16340
|
}
|
|
15959
16341
|
item.status = "stopped";
|
|
15960
16342
|
this.eventLog.append({ taskId: item.taskId, pid: item.pid, type: "killed" });
|
|
16343
|
+
this.emitTerminal({
|
|
16344
|
+
taskId: item.taskId,
|
|
16345
|
+
pid: item.pid,
|
|
16346
|
+
label: item.label,
|
|
16347
|
+
command: item.command,
|
|
16348
|
+
status: "stopped"
|
|
16349
|
+
});
|
|
15961
16350
|
}
|
|
15962
16351
|
}
|
|
15963
16352
|
}
|
|
@@ -15972,6 +16361,14 @@ var ProcessRegistry = class {
|
|
|
15972
16361
|
type: "exited",
|
|
15973
16362
|
exitCode
|
|
15974
16363
|
});
|
|
16364
|
+
this.emitTerminal({
|
|
16365
|
+
taskId: item.taskId,
|
|
16366
|
+
pid,
|
|
16367
|
+
label: item.label,
|
|
16368
|
+
command: item.command,
|
|
16369
|
+
status: item.status,
|
|
16370
|
+
exitCode
|
|
16371
|
+
});
|
|
15975
16372
|
}
|
|
15976
16373
|
}
|
|
15977
16374
|
/**
|
|
@@ -16000,6 +16397,7 @@ var ProcessRegistry = class {
|
|
|
16000
16397
|
this.processes.clear();
|
|
16001
16398
|
this.byTaskId.clear();
|
|
16002
16399
|
this.eventLog.clear();
|
|
16400
|
+
this.terminalListeners.clear();
|
|
16003
16401
|
}
|
|
16004
16402
|
};
|
|
16005
16403
|
var registry = null;
|
|
@@ -16011,8 +16409,8 @@ function getProcessRegistry() {
|
|
|
16011
16409
|
}
|
|
16012
16410
|
|
|
16013
16411
|
// packages/agent-runtime/workspaceShell.ts
|
|
16014
|
-
import { resolve } from "node:path";
|
|
16015
|
-
import { spawn as
|
|
16412
|
+
import { resolve as resolve3 } from "node:path";
|
|
16413
|
+
import { spawn as spawnChildProcess2 } from "node:child_process";
|
|
16016
16414
|
var EXEC_SHELL_TIMEOUT_ENV = "NOLO_EXEC_SHELL_TIMEOUT_MS";
|
|
16017
16415
|
var EXEC_SHELL_DETACH_ENV = "NOLO_EXEC_SHELL_DETACH_MS";
|
|
16018
16416
|
var DEFAULT_EXEC_SHELL_DETACH_MS = 12e4;
|
|
@@ -16121,30 +16519,34 @@ function tokenizeShellPrefix(command) {
|
|
|
16121
16519
|
}
|
|
16122
16520
|
return tokens;
|
|
16123
16521
|
}
|
|
16124
|
-
function
|
|
16522
|
+
function resolvePowerShellShellKind(executable) {
|
|
16523
|
+
const base = (executable.split(/[\\/]/).pop() ?? "").toLowerCase();
|
|
16524
|
+
return base === "pwsh" || base === "pwsh.exe" ? "pwsh" : "powershell5";
|
|
16525
|
+
}
|
|
16526
|
+
function wrapPowerShellCommand(command, shellKind = "pwsh") {
|
|
16125
16527
|
return [
|
|
16126
16528
|
"[Console]::InputEncoding=[System.Text.Encoding]::UTF8",
|
|
16127
16529
|
"[Console]::OutputEncoding=[System.Text.Encoding]::UTF8",
|
|
16128
16530
|
"$OutputEncoding=[System.Text.Encoding]::UTF8",
|
|
16129
|
-
|
|
16531
|
+
// $PSStyle only exists on PowerShell 7+; injecting it on 5.1 makes every
|
|
16532
|
+
// command emit a PropertyNotFound error on stderr.
|
|
16533
|
+
...shellKind === "pwsh" ? ["$PSStyle.OutputRendering='PlainText'"] : [],
|
|
16130
16534
|
command
|
|
16131
16535
|
].join("; ");
|
|
16132
16536
|
}
|
|
16133
16537
|
function findPowerShellExecutable() {
|
|
16134
16538
|
return resolveExecutableOnPath("pwsh") || resolveExecutableOnPath("powershell.exe") || resolveExecutableOnPath("powershell");
|
|
16135
16539
|
}
|
|
16136
|
-
function
|
|
16137
|
-
const executable = findPowerShellExecutable();
|
|
16138
|
-
if (!executable) throw new Error("PowerShell is not available on this machine.");
|
|
16540
|
+
function buildPowerShellSpawnArgs(args2) {
|
|
16139
16541
|
return [
|
|
16140
|
-
executable,
|
|
16542
|
+
args2.executable,
|
|
16141
16543
|
"-NoLogo",
|
|
16142
16544
|
"-NoProfile",
|
|
16143
16545
|
"-NonInteractive",
|
|
16144
16546
|
"-ExecutionPolicy",
|
|
16145
16547
|
"Bypass",
|
|
16146
16548
|
"-Command",
|
|
16147
|
-
wrapPowerShellCommand(command)
|
|
16549
|
+
wrapPowerShellCommand(args2.command, resolvePowerShellShellKind(args2.executable))
|
|
16148
16550
|
];
|
|
16149
16551
|
}
|
|
16150
16552
|
function buildBashCommand(command) {
|
|
@@ -16152,10 +16554,26 @@ function buildBashCommand(command) {
|
|
|
16152
16554
|
if (!executable) throw new Error("bash/sh is not available on this machine.");
|
|
16153
16555
|
return [executable, "-lc", command];
|
|
16154
16556
|
}
|
|
16557
|
+
function buildWorkspaceShellPlan(args2) {
|
|
16558
|
+
if (args2.shell === "bash") {
|
|
16559
|
+
const argv2 = buildBashCommand(args2.command);
|
|
16560
|
+
return { argv: argv2, resolvedShell: "bash", executable: argv2[0] ?? "bash" };
|
|
16561
|
+
}
|
|
16562
|
+
if (args2.shell === "powershell" || process.platform === "win32") {
|
|
16563
|
+
const executable = findPowerShellExecutable();
|
|
16564
|
+
if (!executable) throw new Error("PowerShell is not available on this machine.");
|
|
16565
|
+
return {
|
|
16566
|
+
argv: buildPowerShellSpawnArgs({ executable, command: args2.command }),
|
|
16567
|
+
resolvedShell: "powershell",
|
|
16568
|
+
executable,
|
|
16569
|
+
shellKind: resolvePowerShellShellKind(executable)
|
|
16570
|
+
};
|
|
16571
|
+
}
|
|
16572
|
+
const argv = buildBashCommand(args2.command);
|
|
16573
|
+
return { argv, resolvedShell: "bash", executable: argv[0] ?? "bash" };
|
|
16574
|
+
}
|
|
16155
16575
|
function buildWorkspaceShellCommand(args2) {
|
|
16156
|
-
|
|
16157
|
-
if (args2.shell === "bash") return buildBashCommand(args2.command);
|
|
16158
|
-
return process.platform === "win32" ? buildPowerShellCommand(args2.command) : buildBashCommand(args2.command);
|
|
16576
|
+
return buildWorkspaceShellPlan(args2).argv;
|
|
16159
16577
|
}
|
|
16160
16578
|
function findWorkspaceShellEscapeToken(command) {
|
|
16161
16579
|
const tokens = tokenizeShellPrefix(command);
|
|
@@ -16379,8 +16797,8 @@ async function runWorkspaceCommand(args2) {
|
|
|
16379
16797
|
...args2.commandPrefix ?? [],
|
|
16380
16798
|
...args2.command
|
|
16381
16799
|
];
|
|
16382
|
-
const proc =
|
|
16383
|
-
cwd:
|
|
16800
|
+
const proc = spawnChildProcess2(command[0] ?? "", command.slice(1), {
|
|
16801
|
+
cwd: resolve3(args2.workspaceRoot),
|
|
16384
16802
|
stdio: [
|
|
16385
16803
|
args2.stdin === void 0 ? "ignore" : "pipe",
|
|
16386
16804
|
"pipe",
|
|
@@ -16588,7 +17006,7 @@ var TASK_WAIT_POLL_INTERVAL_MS = 250;
|
|
|
16588
17006
|
var TASK_STOP_GRACE_MS = 2e3;
|
|
16589
17007
|
var TERMINAL_EVENT_TYPES = /* @__PURE__ */ new Set(["exited", "killed"]);
|
|
16590
17008
|
function defaultSleep(ms) {
|
|
16591
|
-
return new Promise((
|
|
17009
|
+
return new Promise((resolve5) => setTimeout(resolve5, ms));
|
|
16592
17010
|
}
|
|
16593
17011
|
function defaultSignalSender(pid, signal) {
|
|
16594
17012
|
process.kill(pid, signal);
|
|
@@ -16823,7 +17241,7 @@ function buildExecShellToolDefinition(toolName = "execShell") {
|
|
|
16823
17241
|
type: "function",
|
|
16824
17242
|
function: {
|
|
16825
17243
|
name: toolName,
|
|
16826
|
-
description: `Execute a shell command from the workspace root. Prefer one compound command (e.g. 'git status && git diff --stat') to perform complete verification in one step instead of multiple small roundtrips. Do not cd into guessed paths; commands already run from the workspace root. Commands block until exit. Long-running commands (sleep over ${IMMEDIATE_DETACH_SLEEP_THRESHOLD_SECONDS}s, dev servers, watchers) automatically detach to background returning {detached: true, pid, label}; for persistent services, prefer launchProcess.`,
|
|
17244
|
+
description: `Execute a shell command from the workspace root. Prefer one compound command (e.g. 'git status && git diff --stat') to perform complete verification in one step instead of multiple small roundtrips. Do not cd into guessed paths; commands already run from the workspace root. Commands block until exit. Long-running commands (sleep over ${IMMEDIATE_DETACH_SLEEP_THRESHOLD_SECONDS}s, dev servers, watchers) automatically detach to background returning {detached: true, pid, label}; for persistent services, prefer launchProcess. On Windows the resolved shell may be Windows PowerShell 5.1 (metadata.shellKind="powershell5"): it does not support '&&'/'||' or $PSStyle \u2014 join commands with ';' or split into multiple calls. metadata.shellKind="pwsh" means PowerShell 7+ with full syntax. Read resolvedShell/shellKind from any execShell result before writing Windows-specific syntax.`,
|
|
16827
17245
|
parameters: {
|
|
16828
17246
|
type: "object",
|
|
16829
17247
|
properties: {
|
|
@@ -16911,13 +17329,14 @@ var execShellCapability = {
|
|
|
16911
17329
|
}
|
|
16912
17330
|
};
|
|
16913
17331
|
}
|
|
17332
|
+
const shellPlan = buildWorkspaceShellPlan({
|
|
17333
|
+
toolName: "execShell",
|
|
17334
|
+
command,
|
|
17335
|
+
shell: normalized.shell
|
|
17336
|
+
});
|
|
16914
17337
|
const result4 = await runWorkspaceCommand({
|
|
16915
17338
|
workspaceRoot,
|
|
16916
|
-
command:
|
|
16917
|
-
toolName: "execShell",
|
|
16918
|
-
command,
|
|
16919
|
-
shell: normalized.shell
|
|
16920
|
-
}),
|
|
17339
|
+
command: shellPlan.argv,
|
|
16921
17340
|
timeoutMs: resolveExecShellTimeoutMs(ctx.commandTimeoutMs),
|
|
16922
17341
|
outputLimit: ctx.commandOutputLimit,
|
|
16923
17342
|
commandPrefix: ctx.commandPrefix,
|
|
@@ -16931,6 +17350,8 @@ var execShellCapability = {
|
|
|
16931
17350
|
command,
|
|
16932
17351
|
exitCode: result4.exitCode,
|
|
16933
17352
|
timedOut: result4.timedOut,
|
|
17353
|
+
resolvedShell: shellPlan.resolvedShell,
|
|
17354
|
+
...shellPlan.shellKind ? { shellKind: shellPlan.shellKind } : {},
|
|
16934
17355
|
...result4.aborted ? { aborted: true } : {},
|
|
16935
17356
|
...result4.detached ? {
|
|
16936
17357
|
detached: true,
|
|
@@ -16960,7 +17381,8 @@ var WORKSPACE_TOOL_NAMES = [
|
|
|
16960
17381
|
"taskWait",
|
|
16961
17382
|
"taskLogs",
|
|
16962
17383
|
"taskStop",
|
|
16963
|
-
"tasks"
|
|
17384
|
+
"tasks",
|
|
17385
|
+
"openDesktopPreview"
|
|
16964
17386
|
];
|
|
16965
17387
|
var SHELL_TOOL_NAMES = [
|
|
16966
17388
|
"execShell",
|
|
@@ -17181,6 +17603,25 @@ function buildLaunchProcessTool() {
|
|
|
17181
17603
|
}
|
|
17182
17604
|
};
|
|
17183
17605
|
}
|
|
17606
|
+
function buildOpenDesktopPreviewTool() {
|
|
17607
|
+
return {
|
|
17608
|
+
type: "function",
|
|
17609
|
+
function: {
|
|
17610
|
+
name: "openDesktopPreview",
|
|
17611
|
+
description: "Open the desktop app's local preview split (main-area iframe) at the given URL. Use after `launchProcess` once the dev server is confirmed healthy. The preview appears inside the main window (right side of the split becomes the artifact area), keeping the conversation on the right. Only available on the desktop runtime; returns an error elsewhere.",
|
|
17612
|
+
parameters: {
|
|
17613
|
+
type: "object",
|
|
17614
|
+
properties: {
|
|
17615
|
+
url: {
|
|
17616
|
+
type: "string",
|
|
17617
|
+
description: "Absolute http(s) URL to load in the preview browser window."
|
|
17618
|
+
}
|
|
17619
|
+
},
|
|
17620
|
+
required: ["url"]
|
|
17621
|
+
}
|
|
17622
|
+
}
|
|
17623
|
+
};
|
|
17624
|
+
}
|
|
17184
17625
|
function buildListProcessesTool() {
|
|
17185
17626
|
return {
|
|
17186
17627
|
type: "function",
|
|
@@ -17291,6 +17732,7 @@ function buildWorkspaceToolDefinition(toolName) {
|
|
|
17291
17732
|
if (toolName === "captureVisualState") return buildCaptureVisualStateTool();
|
|
17292
17733
|
if (toolName === "execShell") return buildExecShellTool(toolName);
|
|
17293
17734
|
if (toolName === "launchProcess") return buildLaunchProcessTool();
|
|
17735
|
+
if (toolName === "openDesktopPreview") return buildOpenDesktopPreviewTool();
|
|
17294
17736
|
if (toolName === "listProcesses") return buildListProcessesTool();
|
|
17295
17737
|
if (toolName === "taskWait") return buildTaskWaitTool();
|
|
17296
17738
|
if (toolName === "taskLogs") return buildTaskLogsTool();
|
|
@@ -17322,8 +17764,17 @@ async function invokeCapability(capabilityOrName, input, ctx = {}) {
|
|
|
17322
17764
|
}
|
|
17323
17765
|
|
|
17324
17766
|
// packages/agent-runtime/localWorkspaceTools.ts
|
|
17767
|
+
async function hasRootGitignore2(workspaceRoot) {
|
|
17768
|
+
return hasRootGitignore(workspaceRoot);
|
|
17769
|
+
}
|
|
17770
|
+
async function readRootGitignorePatterns2(workspaceRoot) {
|
|
17771
|
+
return readRootGitignorePatterns(workspaceRoot);
|
|
17772
|
+
}
|
|
17325
17773
|
var DEFAULT_LOCAL_API_ORIGIN = "http://127.0.0.1:38123";
|
|
17326
17774
|
var ALWAYS_EXCLUDED_GLOBS = [
|
|
17775
|
+
".git/**",
|
|
17776
|
+
".nolo/**",
|
|
17777
|
+
"node_modules/**",
|
|
17327
17778
|
"*.tsbuildinfo",
|
|
17328
17779
|
"dist/**",
|
|
17329
17780
|
"build/**",
|
|
@@ -17411,11 +17862,11 @@ function parseWorkspaceToolArguments(raw) {
|
|
|
17411
17862
|
}
|
|
17412
17863
|
}
|
|
17413
17864
|
function normalizeWorkspaceRelativePath(args2) {
|
|
17414
|
-
const relativePath =
|
|
17865
|
+
const relativePath = relative3(args2.workspaceRoot, args2.targetPath);
|
|
17415
17866
|
return relativePath || ".";
|
|
17416
17867
|
}
|
|
17417
17868
|
function isPathInsideWorkspace(args2) {
|
|
17418
|
-
const relativePath =
|
|
17869
|
+
const relativePath = relative3(args2.workspaceRoot, args2.targetPath);
|
|
17419
17870
|
return relativePath === "" || !relativePath.startsWith("..") && !relativePath.includes(`..${sep}`);
|
|
17420
17871
|
}
|
|
17421
17872
|
var PATH_FIELD_ALIASES = ["path", "file_path", "filePath", "filename", "file", "target_file", "targetFile", "file_to_read", "fileToRead", "target_path", "read_path", "path_to_read", "pathToRead"];
|
|
@@ -17681,7 +18132,7 @@ function readVisualStateCaptureArgs(args2) {
|
|
|
17681
18132
|
}
|
|
17682
18133
|
async function readWorkspacePackageScripts(workspaceRoot) {
|
|
17683
18134
|
try {
|
|
17684
|
-
const raw = await
|
|
18135
|
+
const raw = await readFile3(resolve4(workspaceRoot, "package.json"), "utf8");
|
|
17685
18136
|
const parsed = JSON.parse(raw);
|
|
17686
18137
|
const scripts = parsed && typeof parsed === "object" && parsed.scripts && typeof parsed.scripts === "object" ? Object.keys(parsed.scripts).sort() : [];
|
|
17687
18138
|
return { scripts };
|
|
@@ -17755,108 +18206,29 @@ function resolveRipgrepBinary(env = process.env) {
|
|
|
17755
18206
|
}
|
|
17756
18207
|
return resolveExecutableOnPath("rg");
|
|
17757
18208
|
}
|
|
17758
|
-
function resolveGrepBinary() {
|
|
17759
|
-
return resolveExecutableOnPath("grep");
|
|
17760
|
-
}
|
|
17761
18209
|
var SEARCH_OUTPUT_CHAR_LIMIT = 2e4;
|
|
17762
|
-
|
|
17763
|
-
const
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
const
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17771
|
-
});
|
|
17772
|
-
const exitSettled = waitForNodeProcessExit(proc).then(
|
|
17773
|
-
(code) => ({ ok: true, code }),
|
|
17774
|
-
(error) => ({ ok: false, error })
|
|
17775
|
-
);
|
|
17776
|
-
const stderrPromise = readNodeStream(proc.stderr);
|
|
17777
|
-
const lines = [];
|
|
17778
|
-
let pending = "";
|
|
17779
|
-
let limitedByMaxResults = false;
|
|
17780
|
-
const stdoutPromise = new Promise((resolveRead, rejectRead) => {
|
|
17781
|
-
proc.on("error", rejectRead);
|
|
17782
|
-
proc.stdout?.on("data", (chunk) => {
|
|
17783
|
-
pending += Buffer.isBuffer(chunk) ? chunk.toString("utf8") : String(chunk);
|
|
17784
|
-
const parts2 = pending.split(/\r?\n/);
|
|
17785
|
-
pending = parts2.pop() ?? "";
|
|
17786
|
-
for (const part of parts2) {
|
|
17787
|
-
if (!part) continue;
|
|
17788
|
-
lines.push(part);
|
|
17789
|
-
if (lines.length >= args2.maxLines) {
|
|
17790
|
-
limitedByMaxResults = true;
|
|
17791
|
-
try {
|
|
17792
|
-
proc.kill("SIGTERM");
|
|
17793
|
-
} catch {
|
|
17794
|
-
}
|
|
17795
|
-
break;
|
|
17796
|
-
}
|
|
17797
|
-
}
|
|
17798
|
-
});
|
|
17799
|
-
proc.stdout?.on("error", rejectRead);
|
|
17800
|
-
proc.stdout?.on("end", () => resolveRead());
|
|
17801
|
-
proc.stdout?.on("close", () => resolveRead());
|
|
17802
|
-
if (!proc.stdout) {
|
|
17803
|
-
void exitSettled.then((result4) => {
|
|
17804
|
-
if (!result4.ok) rejectRead(result4.error);
|
|
17805
|
-
else resolveRead();
|
|
17806
|
-
});
|
|
17807
|
-
}
|
|
17808
|
-
});
|
|
18210
|
+
function isPathInsideRoot(root, targetPath) {
|
|
18211
|
+
const rel = relative3(resolve4(root), resolve4(targetPath));
|
|
18212
|
+
return rel === "" || rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute2(rel);
|
|
18213
|
+
}
|
|
18214
|
+
async function resolveRuntimeOwnedSpillPath(targetPath) {
|
|
18215
|
+
const spillRoot = resolveNoloStateDir("spills");
|
|
18216
|
+
if (!isPathInsideRoot(spillRoot, targetPath)) return null;
|
|
18217
|
+
const rootStat = await lstat(spillRoot).catch(() => void 0);
|
|
18218
|
+
if (rootStat?.isDirectory() !== true) return null;
|
|
17809
18219
|
try {
|
|
17810
|
-
await Promise.all([
|
|
17811
|
-
|
|
17812
|
-
|
|
17813
|
-
|
|
17814
|
-
return {
|
|
17815
|
-
stdout: "",
|
|
17816
|
-
stderr: `spawn failed: ${toErrorMessage(settled2.error)}
|
|
17817
|
-
`,
|
|
17818
|
-
exitCode: 127,
|
|
17819
|
-
limitedByMaxResults: false,
|
|
17820
|
-
spawnFailed: true
|
|
17821
|
-
};
|
|
17822
|
-
}
|
|
17823
|
-
if (isSpawnFailureError(error)) {
|
|
17824
|
-
return {
|
|
17825
|
-
stdout: "",
|
|
17826
|
-
stderr: `spawn failed: ${toErrorMessage(error)}
|
|
17827
|
-
`,
|
|
17828
|
-
exitCode: 127,
|
|
17829
|
-
limitedByMaxResults: false,
|
|
17830
|
-
spawnFailed: true
|
|
17831
|
-
};
|
|
17832
|
-
}
|
|
17833
|
-
throw error;
|
|
17834
|
-
}
|
|
17835
|
-
if (!limitedByMaxResults && pending.trim()) lines.push(pending);
|
|
17836
|
-
const settled = await exitSettled;
|
|
17837
|
-
if (!settled.ok) {
|
|
17838
|
-
return {
|
|
17839
|
-
stdout: "",
|
|
17840
|
-
stderr: `spawn failed: ${toErrorMessage(settled.error)}
|
|
17841
|
-
`,
|
|
17842
|
-
exitCode: 127,
|
|
17843
|
-
limitedByMaxResults: false,
|
|
17844
|
-
spawnFailed: true
|
|
17845
|
-
};
|
|
18220
|
+
const [realRoot, realTarget] = await Promise.all([realpath(spillRoot), realpath(targetPath)]);
|
|
18221
|
+
return isPathInsideRoot(realRoot, realTarget) ? realTarget : null;
|
|
18222
|
+
} catch {
|
|
18223
|
+
return null;
|
|
17846
18224
|
}
|
|
17847
|
-
const exitCode = limitedByMaxResults ? 0 : settled.code;
|
|
17848
|
-
const stderr = await stderrPromise;
|
|
17849
|
-
return {
|
|
17850
|
-
stdout: lines.slice(0, args2.maxLines).join("\n"),
|
|
17851
|
-
stderr,
|
|
17852
|
-
exitCode,
|
|
17853
|
-
limitedByMaxResults
|
|
17854
|
-
};
|
|
17855
18225
|
}
|
|
17856
18226
|
async function resolveLocalWorkspaceToolPath(args2) {
|
|
17857
|
-
const workspaceRoot =
|
|
17858
|
-
const targetPath =
|
|
17859
|
-
|
|
18227
|
+
const workspaceRoot = resolve4(args2.workspaceRoot);
|
|
18228
|
+
const targetPath = resolve4(workspaceRoot, args2.requestedPath);
|
|
18229
|
+
const insideWorkspace = isPathInsideWorkspace({ workspaceRoot, targetPath });
|
|
18230
|
+
const trustedSpillPath = !insideWorkspace && args2.allowRuntimeOwnedSpill === true ? await resolveRuntimeOwnedSpillPath(targetPath) : null;
|
|
18231
|
+
if (!insideWorkspace && trustedSpillPath === null) {
|
|
17860
18232
|
if (args2.confirmExternalFileAccess) {
|
|
17861
18233
|
const request3 = {
|
|
17862
18234
|
id: "permission-file-external-access",
|
|
@@ -17881,7 +18253,7 @@ async function resolveLocalWorkspaceToolPath(args2) {
|
|
|
17881
18253
|
}
|
|
17882
18254
|
}
|
|
17883
18255
|
}
|
|
17884
|
-
return targetPath;
|
|
18256
|
+
return trustedSpillPath ?? targetPath;
|
|
17885
18257
|
}
|
|
17886
18258
|
var READ_FILE_MAX_CHAR_LIMIT = 32e3;
|
|
17887
18259
|
function defensivelyTruncateReadFile(args2) {
|
|
@@ -17933,9 +18305,10 @@ async function readFileTool(args2) {
|
|
|
17933
18305
|
const absolutePath = await resolveLocalWorkspaceToolPath({
|
|
17934
18306
|
workspaceRoot: args2.workspaceRoot,
|
|
17935
18307
|
requestedPath,
|
|
18308
|
+
allowRuntimeOwnedSpill: true,
|
|
17936
18309
|
...args2.confirmExternalFileAccess ? { confirmExternalFileAccess: args2.confirmExternalFileAccess } : {}
|
|
17937
18310
|
});
|
|
17938
|
-
const content = await
|
|
18311
|
+
const content = await readFile3(absolutePath, "utf8");
|
|
17939
18312
|
const activity = extractActivity(parsed);
|
|
17940
18313
|
const sliced = sliceReadFileContent({
|
|
17941
18314
|
content,
|
|
@@ -17947,7 +18320,7 @@ async function readFileTool(args2) {
|
|
|
17947
18320
|
});
|
|
17948
18321
|
const isTruncated = sliced.truncated || truncatedRead.truncatedByCharLimit;
|
|
17949
18322
|
const relativePath = normalizeWorkspaceRelativePath({
|
|
17950
|
-
workspaceRoot:
|
|
18323
|
+
workspaceRoot: resolve4(args2.workspaceRoot),
|
|
17951
18324
|
targetPath: absolutePath
|
|
17952
18325
|
});
|
|
17953
18326
|
const force = parsed.force === true;
|
|
@@ -18014,7 +18387,7 @@ async function writeFileTool(args2) {
|
|
|
18014
18387
|
await mkdir(dirname(absolutePath), { recursive: true });
|
|
18015
18388
|
await writeFile(absolutePath, content, "utf8");
|
|
18016
18389
|
const relativePath = normalizeWorkspaceRelativePath({
|
|
18017
|
-
workspaceRoot:
|
|
18390
|
+
workspaceRoot: resolve4(args2.workspaceRoot),
|
|
18018
18391
|
targetPath: absolutePath
|
|
18019
18392
|
});
|
|
18020
18393
|
const activity = extractActivity(parsed);
|
|
@@ -18039,7 +18412,7 @@ async function editFileTool(args2) {
|
|
|
18039
18412
|
requestedPath,
|
|
18040
18413
|
...args2.confirmExternalFileAccess ? { confirmExternalFileAccess: args2.confirmExternalFileAccess } : {}
|
|
18041
18414
|
});
|
|
18042
|
-
const content = await
|
|
18415
|
+
const content = await readFile3(absolutePath, "utf8");
|
|
18043
18416
|
const { count: replacementCount, result: nextContent } = countAndReplaceEolTolerant({
|
|
18044
18417
|
content,
|
|
18045
18418
|
oldText,
|
|
@@ -18052,7 +18425,7 @@ async function editFileTool(args2) {
|
|
|
18052
18425
|
}
|
|
18053
18426
|
await writeFile(absolutePath, nextContent, "utf8");
|
|
18054
18427
|
const relativePath = normalizeWorkspaceRelativePath({
|
|
18055
|
-
workspaceRoot:
|
|
18428
|
+
workspaceRoot: resolve4(args2.workspaceRoot),
|
|
18056
18429
|
targetPath: absolutePath
|
|
18057
18430
|
});
|
|
18058
18431
|
const activity = extractActivity(parsed);
|
|
@@ -18068,28 +18441,9 @@ async function editFileTool(args2) {
|
|
|
18068
18441
|
}
|
|
18069
18442
|
};
|
|
18070
18443
|
}
|
|
18071
|
-
async function hasRootGitignore(workspaceRoot) {
|
|
18072
|
-
try {
|
|
18073
|
-
await stat(resolve2(workspaceRoot, ".gitignore"));
|
|
18074
|
-
return true;
|
|
18075
|
-
} catch {
|
|
18076
|
-
return false;
|
|
18077
|
-
}
|
|
18078
|
-
}
|
|
18079
|
-
async function readRootGitignorePatterns(workspaceRoot) {
|
|
18080
|
-
try {
|
|
18081
|
-
const content = await readFile(resolve2(workspaceRoot, ".gitignore"), "utf8");
|
|
18082
|
-
return content.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("#") && !line.startsWith("!")).map((line) => {
|
|
18083
|
-
const unanchored = line.replace(/^\//, "");
|
|
18084
|
-
return unanchored.endsWith("/") ? `${unanchored}**` : unanchored;
|
|
18085
|
-
});
|
|
18086
|
-
} catch {
|
|
18087
|
-
return [];
|
|
18088
|
-
}
|
|
18089
|
-
}
|
|
18090
18444
|
async function filterRootGitignoredFiles(args2) {
|
|
18091
18445
|
if (args2.includeIgnored) return args2.files;
|
|
18092
|
-
const patterns = await
|
|
18446
|
+
const patterns = await readRootGitignorePatterns2(args2.workspaceRoot);
|
|
18093
18447
|
if (patterns.length === 0) return args2.files;
|
|
18094
18448
|
const globs = patterns.map((pattern) => createGlob(pattern));
|
|
18095
18449
|
return args2.files.filter((file) => !globs.some((glob) => glob.match(file)));
|
|
@@ -18102,94 +18456,18 @@ function scanWorkspaceGlobFiles(args2) {
|
|
|
18102
18456
|
onlyFiles: true
|
|
18103
18457
|
})).map((line) => line.trim().replace(/^\.\//, "")).filter(Boolean).filter((line) => !line.startsWith(".git/") && !line.startsWith("node_modules/")).filter((line) => !pathPrefix || line === args2.relativeSearchPath || line.startsWith(pathPrefix)).filter((line) => !args2.exclude.some((pattern) => createGlob(pattern).match(line))).sort((left, right) => left.localeCompare(right));
|
|
18104
18458
|
}
|
|
18105
|
-
function dropAlwaysExcludedLines(lines) {
|
|
18106
|
-
const globs = ALWAYS_EXCLUDED_GLOBS.map((pattern) => createGlob(pattern));
|
|
18107
|
-
return lines.filter((line) => {
|
|
18108
|
-
const filePath = line.match(/^(.*?):\d+[:-]/)?.[1];
|
|
18109
|
-
if (!filePath) return true;
|
|
18110
|
-
return !globs.some((glob) => glob.match(filePath));
|
|
18111
|
-
});
|
|
18112
|
-
}
|
|
18113
|
-
function limitSearchOutputByMatches(lines, maxResults) {
|
|
18114
|
-
if (!maxResults) return { lines, truncated: false };
|
|
18115
|
-
const limited = [];
|
|
18116
|
-
let matches = 0;
|
|
18117
|
-
for (const line of lines) {
|
|
18118
|
-
if (/:\d+:/.test(line)) {
|
|
18119
|
-
if (matches >= maxResults) {
|
|
18120
|
-
return { lines: limited, truncated: true };
|
|
18121
|
-
}
|
|
18122
|
-
matches += 1;
|
|
18123
|
-
}
|
|
18124
|
-
limited.push(line);
|
|
18125
|
-
}
|
|
18126
|
-
return { lines: limited, truncated: false };
|
|
18127
|
-
}
|
|
18128
|
-
async function scanWorkspaceTextMatches(args2) {
|
|
18129
|
-
const files = scanWorkspaceGlobFiles({
|
|
18130
|
-
workspaceRoot: args2.workspaceRoot,
|
|
18131
|
-
pattern: "**/*",
|
|
18132
|
-
relativeSearchPath: args2.relativeSearchPath,
|
|
18133
|
-
exclude: args2.exclude
|
|
18134
|
-
});
|
|
18135
|
-
const results = [];
|
|
18136
|
-
const seenContext = /* @__PURE__ */ new Set();
|
|
18137
|
-
let matchCount = 0;
|
|
18138
|
-
const literalQuery = args2.caseSensitive ? args2.query : args2.query.toLowerCase();
|
|
18139
|
-
const regex = args2.literal ? void 0 : new RegExp(args2.query, args2.caseSensitive ? "" : "i");
|
|
18140
|
-
const pushLine = (file, lineNumber, text, isMatch) => {
|
|
18141
|
-
const separator = isMatch ? ":" : "-";
|
|
18142
|
-
const key = `${file}:${lineNumber}:${separator}`;
|
|
18143
|
-
if (seenContext.has(key)) return;
|
|
18144
|
-
seenContext.add(key);
|
|
18145
|
-
results.push(`${file}${separator}${lineNumber}${separator}${text}`);
|
|
18146
|
-
};
|
|
18147
|
-
for (const file of files) {
|
|
18148
|
-
let content = "";
|
|
18149
|
-
try {
|
|
18150
|
-
content = await readFile(resolve2(args2.workspaceRoot, file), "utf8");
|
|
18151
|
-
} catch {
|
|
18152
|
-
continue;
|
|
18153
|
-
}
|
|
18154
|
-
if (content.includes("\0")) continue;
|
|
18155
|
-
const lines = content.split(/\r?\n/);
|
|
18156
|
-
for (let index = 0; index < lines.length; index += 1) {
|
|
18157
|
-
const line = lines[index] ?? "";
|
|
18158
|
-
const haystack = args2.caseSensitive ? line : line.toLowerCase();
|
|
18159
|
-
const matched = args2.literal ? haystack.includes(literalQuery) : regex?.test(line) === true;
|
|
18160
|
-
if (!matched) continue;
|
|
18161
|
-
matchCount += 1;
|
|
18162
|
-
const contextLines = args2.contextLines ?? 0;
|
|
18163
|
-
const start = Math.max(0, index - contextLines);
|
|
18164
|
-
const end3 = Math.min(lines.length - 1, index + contextLines);
|
|
18165
|
-
for (let contextIndex = start; contextIndex <= end3; contextIndex += 1) {
|
|
18166
|
-
pushLine(file, contextIndex + 1, lines[contextIndex] ?? "", contextIndex === index);
|
|
18167
|
-
}
|
|
18168
|
-
if (args2.maxResults && matchCount >= args2.maxResults) {
|
|
18169
|
-
return {
|
|
18170
|
-
lines: results,
|
|
18171
|
-
limitedByMaxResults: true
|
|
18172
|
-
};
|
|
18173
|
-
}
|
|
18174
|
-
}
|
|
18175
|
-
}
|
|
18176
|
-
return {
|
|
18177
|
-
lines: results,
|
|
18178
|
-
limitedByMaxResults: false
|
|
18179
|
-
};
|
|
18180
|
-
}
|
|
18181
18459
|
async function listWorkspaceEntries(args2) {
|
|
18182
18460
|
const entries = [];
|
|
18183
18461
|
let truncated = false;
|
|
18184
18462
|
let limitedByMaxDepth = false;
|
|
18185
18463
|
const visit = async (dirPath, depth) => {
|
|
18186
18464
|
if (truncated) return;
|
|
18187
|
-
const names = (await
|
|
18465
|
+
const names = (await readdir2(dirPath)).sort((left, right) => left.localeCompare(right));
|
|
18188
18466
|
for (const name of names) {
|
|
18189
18467
|
if (truncated) break;
|
|
18190
|
-
const absolutePath =
|
|
18191
|
-
const info = await
|
|
18192
|
-
const relativePath =
|
|
18468
|
+
const absolutePath = resolve4(dirPath, name);
|
|
18469
|
+
const info = await stat3(absolutePath);
|
|
18470
|
+
const relativePath = relative3(args2.dirPath, absolutePath) || ".";
|
|
18193
18471
|
const isDirectory = info.isDirectory();
|
|
18194
18472
|
entries.push(isDirectory ? `${relativePath}/` : relativePath);
|
|
18195
18473
|
if (args2.maxResults && entries.length >= args2.maxResults) {
|
|
@@ -18199,7 +18477,7 @@ async function listWorkspaceEntries(args2) {
|
|
|
18199
18477
|
if (isDirectory && depth < args2.maxDepth) {
|
|
18200
18478
|
await visit(absolutePath, depth + 1);
|
|
18201
18479
|
} else if (isDirectory && depth >= args2.maxDepth && !limitedByMaxDepth) {
|
|
18202
|
-
const childNames = await
|
|
18480
|
+
const childNames = await readdir2(absolutePath);
|
|
18203
18481
|
limitedByMaxDepth = childNames.length > 0;
|
|
18204
18482
|
}
|
|
18205
18483
|
}
|
|
@@ -18209,169 +18487,48 @@ async function listWorkspaceEntries(args2) {
|
|
|
18209
18487
|
}
|
|
18210
18488
|
async function internalSearchWorkspace(args2) {
|
|
18211
18489
|
const requestedPath = args2.path ?? ".";
|
|
18212
|
-
|
|
18213
|
-
if (!query) {
|
|
18214
|
-
throw new Error("internalSearchWorkspace requires a non-empty query.");
|
|
18215
|
-
}
|
|
18216
|
-
const maxResults = args2.maxResults ?? 200;
|
|
18217
|
-
const contextLines = args2.contextLines;
|
|
18218
|
-
const literal = false;
|
|
18219
|
-
const caseSensitive = args2.caseSensitive === false ? false : true;
|
|
18220
|
-
const exclude = [];
|
|
18490
|
+
if (!args2.query) throw new Error("internalSearchWorkspace requires a non-empty query.");
|
|
18221
18491
|
const searchPath = await resolveLocalWorkspaceToolPath({
|
|
18222
18492
|
workspaceRoot: args2.workspaceRoot,
|
|
18223
18493
|
requestedPath,
|
|
18494
|
+
allowRuntimeOwnedSpill: true,
|
|
18224
18495
|
...args2.confirmExternalFileAccess ? { confirmExternalFileAccess: args2.confirmExternalFileAccess } : {}
|
|
18225
18496
|
});
|
|
18226
|
-
const
|
|
18227
|
-
|
|
18228
|
-
|
|
18497
|
+
const workspaceRoot = resolve4(args2.workspaceRoot);
|
|
18498
|
+
const inside = isPathInsideWorkspace({ workspaceRoot, targetPath: searchPath });
|
|
18499
|
+
const result4 = await searchFileTextMatches({
|
|
18500
|
+
root: inside ? workspaceRoot : searchPath,
|
|
18501
|
+
target: inside ? normalizeWorkspaceRelativePath({ workspaceRoot, targetPath: searchPath }) : ".",
|
|
18502
|
+
query: args2.query,
|
|
18503
|
+
regex: true,
|
|
18504
|
+
caseSensitive: args2.caseSensitive !== false,
|
|
18505
|
+
contextLines: args2.contextLines,
|
|
18506
|
+
maxResults: args2.maxResults ?? 200,
|
|
18507
|
+
includeIgnored: args2.workspaceRoot.includes(".worktrees") || !inside,
|
|
18508
|
+
absolutePaths: !inside,
|
|
18509
|
+
exclude: inside ? [...ALWAYS_EXCLUDED_GLOBS] : []
|
|
18229
18510
|
});
|
|
18230
|
-
const
|
|
18231
|
-
|
|
18232
|
-
|
|
18233
|
-
|
|
18234
|
-
|
|
18235
|
-
}) : ".";
|
|
18236
|
-
const rgBinary = resolveRipgrepBinary();
|
|
18237
|
-
const grepBinary = resolveGrepBinary();
|
|
18238
|
-
const rgCommand = rgBinary ? [
|
|
18239
|
-
rgBinary,
|
|
18240
|
-
"--line-number",
|
|
18241
|
-
"--no-heading",
|
|
18242
|
-
"--hidden",
|
|
18243
|
-
...literal ? ["--fixed-strings"] : [],
|
|
18244
|
-
...caseSensitive ? [] : ["--ignore-case"],
|
|
18245
|
-
...contextLines !== void 0 ? ["--context", String(contextLines)] : [],
|
|
18246
|
-
...includeIgnored ? ["--no-ignore"] : [],
|
|
18247
|
-
"--glob",
|
|
18248
|
-
"!node_modules",
|
|
18249
|
-
"--glob",
|
|
18250
|
-
"!.git",
|
|
18251
|
-
...isInside ? ALWAYS_EXCLUDED_GLOBS.flatMap((g) => ["--glob", `!${g}`]) : [],
|
|
18252
|
-
...exclude.flatMap((excludePattern) => ["--glob", `!${excludePattern}`]),
|
|
18253
|
-
"--",
|
|
18254
|
-
query,
|
|
18255
|
-
relativeSearchPath
|
|
18256
|
-
] : null;
|
|
18257
|
-
const grepExcludeArgs = [
|
|
18258
|
-
...ALWAYS_EXCLUDED_GLOBS.flatMap((g) => {
|
|
18259
|
-
if (!g.endsWith("/**")) return ["--exclude", g];
|
|
18260
|
-
const dir = g.replace(/\/\*\*$/, "");
|
|
18261
|
-
return dir.includes("/") ? [] : [`--exclude-dir=${dir}`];
|
|
18262
|
-
}),
|
|
18263
|
-
...exclude.flatMap((excludePattern) => ["--exclude", excludePattern])
|
|
18264
|
-
];
|
|
18265
|
-
let searchEngine = "js";
|
|
18266
|
-
let binariesUnavailable = !rgBinary && !grepBinary;
|
|
18267
|
-
const result4 = await (async () => {
|
|
18268
|
-
if (rgCommand) {
|
|
18269
|
-
try {
|
|
18270
|
-
const rgResult = maxResults && contextLines === void 0 ? await runWorkspaceCommandLimitedLines({
|
|
18271
|
-
workspaceRoot: execWorkspaceRoot,
|
|
18272
|
-
command: rgCommand,
|
|
18273
|
-
maxLines: maxResults
|
|
18274
|
-
}) : await runWorkspaceCommand({
|
|
18275
|
-
workspaceRoot: execWorkspaceRoot,
|
|
18276
|
-
command: rgCommand
|
|
18277
|
-
});
|
|
18278
|
-
if (!rgResult.spawnFailed) {
|
|
18279
|
-
searchEngine = "ripgrep";
|
|
18280
|
-
return rgResult;
|
|
18281
|
-
}
|
|
18282
|
-
} catch {
|
|
18283
|
-
}
|
|
18284
|
-
}
|
|
18285
|
-
if (grepBinary) {
|
|
18286
|
-
const grepCommand = [
|
|
18287
|
-
grepBinary,
|
|
18288
|
-
"-R",
|
|
18289
|
-
"-n",
|
|
18290
|
-
"-I",
|
|
18291
|
-
...literal ? ["-F"] : [],
|
|
18292
|
-
...caseSensitive ? [] : ["-i"],
|
|
18293
|
-
...contextLines !== void 0 ? ["-C", String(contextLines)] : [],
|
|
18294
|
-
"--exclude-dir=node_modules",
|
|
18295
|
-
"--exclude-dir=.git",
|
|
18296
|
-
...grepExcludeArgs,
|
|
18297
|
-
query,
|
|
18298
|
-
relativeSearchPath
|
|
18299
|
-
];
|
|
18300
|
-
try {
|
|
18301
|
-
const grepResult = maxResults && contextLines === void 0 ? await runWorkspaceCommandLimitedLines({
|
|
18302
|
-
workspaceRoot: execWorkspaceRoot,
|
|
18303
|
-
command: grepCommand,
|
|
18304
|
-
maxLines: maxResults
|
|
18305
|
-
}) : await runWorkspaceCommand({
|
|
18306
|
-
workspaceRoot: execWorkspaceRoot,
|
|
18307
|
-
command: grepCommand
|
|
18308
|
-
});
|
|
18309
|
-
if (!grepResult.spawnFailed) {
|
|
18310
|
-
searchEngine = "grep";
|
|
18311
|
-
return grepResult;
|
|
18312
|
-
}
|
|
18313
|
-
binariesUnavailable = true;
|
|
18314
|
-
} catch {
|
|
18315
|
-
binariesUnavailable = true;
|
|
18316
|
-
}
|
|
18317
|
-
} else {
|
|
18318
|
-
binariesUnavailable = true;
|
|
18319
|
-
}
|
|
18320
|
-
return {
|
|
18321
|
-
stdout: "",
|
|
18322
|
-
stderr: "",
|
|
18323
|
-
exitCode: 0,
|
|
18324
|
-
limitedByMaxResults: false,
|
|
18325
|
-
spawnFailed: true
|
|
18326
|
-
};
|
|
18327
|
-
})();
|
|
18328
|
-
let outputLines = result4.stdout.split(/\r?\n/).map((line) => line.trimEnd().replace(/^\.\//, "")).filter(Boolean);
|
|
18329
|
-
outputLines = dropAlwaysExcludedLines(outputLines);
|
|
18330
|
-
let limitedByMaxResults = "limitedByMaxResults" in result4 && result4.limitedByMaxResults === true;
|
|
18331
|
-
const forceJsFallback = binariesUnavailable || result4.spawnFailed === true;
|
|
18332
|
-
if (outputLines.length === 0 && (forceJsFallback || result4.exitCode === 0 && (includeIgnored || !await hasRootGitignore(execWorkspaceRoot)))) {
|
|
18333
|
-
const fallback = await scanWorkspaceTextMatches({
|
|
18334
|
-
workspaceRoot: execWorkspaceRoot,
|
|
18335
|
-
relativeSearchPath,
|
|
18336
|
-
query,
|
|
18337
|
-
exclude: [...ALWAYS_EXCLUDED_GLOBS, ...exclude],
|
|
18338
|
-
maxResults,
|
|
18339
|
-
literal,
|
|
18340
|
-
caseSensitive,
|
|
18341
|
-
contextLines
|
|
18342
|
-
});
|
|
18343
|
-
outputLines = fallback.lines;
|
|
18344
|
-
limitedByMaxResults = fallback.limitedByMaxResults;
|
|
18345
|
-
searchEngine = "js";
|
|
18346
|
-
}
|
|
18347
|
-
if (contextLines !== void 0 && outputLines.length > 0) {
|
|
18348
|
-
const limited = limitSearchOutputByMatches(outputLines, maxResults);
|
|
18349
|
-
outputLines = limited.lines;
|
|
18350
|
-
limitedByMaxResults = limitedByMaxResults || limited.truncated;
|
|
18351
|
-
}
|
|
18352
|
-
const matchLines = outputLines.filter((line) => /:\d+:/.test(line));
|
|
18353
|
-
const matchedFiles = Array.from(new Set(matchLines.flatMap((line) => {
|
|
18354
|
-
const match7 = line.match(/^(.*?):\d+:/);
|
|
18355
|
-
return match7?.[1] ? [match7[1]] : [];
|
|
18356
|
-
})));
|
|
18511
|
+
const outputLines = result4.matches.flatMap((match7) => [
|
|
18512
|
+
...match7.before.map((line, index) => `${match7.path}:${Math.max(1, match7.line - match7.before.length + index)}-${line}`),
|
|
18513
|
+
`${match7.path}:${match7.line}:${match7.text}`,
|
|
18514
|
+
...match7.after.map((line, index) => `${match7.path}:${match7.line + index + 1}-${line}`)
|
|
18515
|
+
]);
|
|
18357
18516
|
const rawContent = outputLines.join("\n");
|
|
18358
18517
|
const content = truncateToolOutput(rawContent, SEARCH_OUTPUT_CHAR_LIMIT);
|
|
18359
|
-
const
|
|
18518
|
+
const matchLines = result4.matches.map((match7) => `${match7.path}:${match7.line}:${match7.text}`);
|
|
18360
18519
|
return {
|
|
18361
18520
|
content,
|
|
18362
18521
|
metadata: {
|
|
18363
|
-
query,
|
|
18522
|
+
query: args2.query,
|
|
18364
18523
|
path: requestedPath,
|
|
18365
|
-
searchedPath:
|
|
18524
|
+
searchedPath: inside ? normalizeWorkspaceRelativePath({ workspaceRoot, targetPath: searchPath }) : ".",
|
|
18366
18525
|
count: outputLines.length,
|
|
18367
|
-
matchCount:
|
|
18368
|
-
matchedFiles,
|
|
18369
|
-
truncated:
|
|
18370
|
-
limitedByMaxResults,
|
|
18371
|
-
...
|
|
18372
|
-
|
|
18373
|
-
exitCode: result4.exitCode,
|
|
18374
|
-
searchEngine
|
|
18526
|
+
matchCount: result4.totalMatches,
|
|
18527
|
+
matchedFiles: Array.from(new Set(result4.matches.map((match7) => match7.path))),
|
|
18528
|
+
truncated: result4.truncated || content.length !== rawContent.length,
|
|
18529
|
+
limitedByMaxResults: result4.truncated,
|
|
18530
|
+
...args2.maxResults ? { maxResults: args2.maxResults } : {},
|
|
18531
|
+
searchEngine: result4.engine
|
|
18375
18532
|
}
|
|
18376
18533
|
};
|
|
18377
18534
|
}
|
|
@@ -18417,7 +18574,7 @@ async function globFilesTool(args2) {
|
|
|
18417
18574
|
...args2.confirmExternalFileAccess ? { confirmExternalFileAccess: args2.confirmExternalFileAccess } : {}
|
|
18418
18575
|
});
|
|
18419
18576
|
const relativeSearchPath = normalizeWorkspaceRelativePath({
|
|
18420
|
-
workspaceRoot:
|
|
18577
|
+
workspaceRoot: resolve4(args2.workspaceRoot),
|
|
18421
18578
|
targetPath: searchPath
|
|
18422
18579
|
});
|
|
18423
18580
|
const pathPrefix = relativeSearchPath === "." ? "" : `${relativeSearchPath.replace(/\/+$/, "")}/`;
|
|
@@ -18465,7 +18622,7 @@ async function globFilesTool(args2) {
|
|
|
18465
18622
|
files,
|
|
18466
18623
|
includeIgnored
|
|
18467
18624
|
});
|
|
18468
|
-
if (files.length === 0 && (includeIgnored || !await
|
|
18625
|
+
if (files.length === 0 && (includeIgnored || !await hasRootGitignore2(args2.workspaceRoot))) {
|
|
18469
18626
|
files = scanWorkspaceGlobFiles({
|
|
18470
18627
|
workspaceRoot: args2.workspaceRoot,
|
|
18471
18628
|
pattern,
|
|
@@ -18618,8 +18775,8 @@ async function launchProcessTool(args2) {
|
|
|
18618
18775
|
...fullCommand
|
|
18619
18776
|
];
|
|
18620
18777
|
const detached = process.platform !== "win32";
|
|
18621
|
-
const proc =
|
|
18622
|
-
cwd:
|
|
18778
|
+
const proc = spawnChildProcess3(cmdArgs[0] ?? "", cmdArgs.slice(1), {
|
|
18779
|
+
cwd: resolve4(args2.workspaceRoot),
|
|
18623
18780
|
stdio: ["ignore", "pipe", "pipe"],
|
|
18624
18781
|
detached
|
|
18625
18782
|
});
|
|
@@ -18766,9 +18923,66 @@ async function tasksTool(_args) {
|
|
|
18766
18923
|
metadata: { count: result4.count, tasks: result4.tasks }
|
|
18767
18924
|
};
|
|
18768
18925
|
}
|
|
18926
|
+
async function openDesktopPreviewTool(args2) {
|
|
18927
|
+
const parsed = parseWorkspaceToolArguments(args2.call.arguments);
|
|
18928
|
+
const url = typeof parsed.url === "string" ? parsed.url.trim() : "";
|
|
18929
|
+
if (!url) {
|
|
18930
|
+
return {
|
|
18931
|
+
content: JSON.stringify({ error: "openDesktopPreview requires a non-empty url." }),
|
|
18932
|
+
metadata: { status: "failed" }
|
|
18933
|
+
};
|
|
18934
|
+
}
|
|
18935
|
+
try {
|
|
18936
|
+
const parsedUrl = new URL(url);
|
|
18937
|
+
if (parsedUrl.protocol !== "http:" && parsedUrl.protocol !== "https:") {
|
|
18938
|
+
return {
|
|
18939
|
+
content: JSON.stringify({ error: "url must be an absolute http(s) URL." }),
|
|
18940
|
+
metadata: { status: "failed" }
|
|
18941
|
+
};
|
|
18942
|
+
}
|
|
18943
|
+
} catch {
|
|
18944
|
+
return {
|
|
18945
|
+
content: JSON.stringify({ error: "url must be an absolute http(s) URL." }),
|
|
18946
|
+
metadata: { status: "failed" }
|
|
18947
|
+
};
|
|
18948
|
+
}
|
|
18949
|
+
const port = Number(process.env.NOLO_DESKTOP_SERVER_PORT ?? 3233);
|
|
18950
|
+
try {
|
|
18951
|
+
const response = await fetch(`http://127.0.0.1:${port}/api/desktop/preview/open`, {
|
|
18952
|
+
method: "POST",
|
|
18953
|
+
headers: { "Content-Type": "application/json" },
|
|
18954
|
+
body: JSON.stringify({ url })
|
|
18955
|
+
});
|
|
18956
|
+
const bodyText = await response.text();
|
|
18957
|
+
let body;
|
|
18958
|
+
try {
|
|
18959
|
+
body = JSON.parse(bodyText);
|
|
18960
|
+
} catch {
|
|
18961
|
+
body = { raw: bodyText };
|
|
18962
|
+
}
|
|
18963
|
+
if (!response.ok) {
|
|
18964
|
+
const message = isRecord(body) && typeof body.error === "string" ? body.error : `preview open failed (HTTP ${response.status})`;
|
|
18965
|
+
return {
|
|
18966
|
+
content: JSON.stringify({ error: message }),
|
|
18967
|
+
metadata: { status: "failed", httpStatus: response.status }
|
|
18968
|
+
};
|
|
18969
|
+
}
|
|
18970
|
+
return {
|
|
18971
|
+
content: JSON.stringify({ ok: true, url, note: "desktop preview opened" }),
|
|
18972
|
+
metadata: { status: "done", url }
|
|
18973
|
+
};
|
|
18974
|
+
} catch (error) {
|
|
18975
|
+
return {
|
|
18976
|
+
content: JSON.stringify({
|
|
18977
|
+
error: "Desktop preview bridge unreachable; this tool only works inside Nolo Desktop. " + toErrorMessage(error)
|
|
18978
|
+
}),
|
|
18979
|
+
metadata: { status: "failed" }
|
|
18980
|
+
};
|
|
18981
|
+
}
|
|
18982
|
+
}
|
|
18769
18983
|
function createLocalWorkspaceToolExecutors(args2) {
|
|
18770
18984
|
const fileAccess = args2.confirmExternalFileAccess ? { confirmExternalFileAccess: args2.confirmExternalFileAccess } : {};
|
|
18771
|
-
const readFileLedger = /* @__PURE__ */ new Map();
|
|
18985
|
+
const readFileLedger = args2.readFileNoLedger === true ? null : /* @__PURE__ */ new Map();
|
|
18772
18986
|
return {
|
|
18773
18987
|
editFile: (call) => editFileTool({
|
|
18774
18988
|
call,
|
|
@@ -18784,7 +18998,7 @@ function createLocalWorkspaceToolExecutors(args2) {
|
|
|
18784
18998
|
readFile: (call) => readFileTool({
|
|
18785
18999
|
call,
|
|
18786
19000
|
workspaceRoot: args2.workspaceRoot,
|
|
18787
|
-
readLedger: readFileLedger,
|
|
19001
|
+
...readFileLedger ? { readLedger: readFileLedger } : {},
|
|
18788
19002
|
...fileAccess
|
|
18789
19003
|
}),
|
|
18790
19004
|
writeFile: (call) => writeFileTool({
|
|
@@ -18828,7 +19042,8 @@ function createLocalWorkspaceToolExecutors(args2) {
|
|
|
18828
19042
|
...args2.commandOutputLimit !== void 0 ? { commandOutputLimit: args2.commandOutputLimit } : {}
|
|
18829
19043
|
}),
|
|
18830
19044
|
taskStop: (call) => taskStopTool({ call }),
|
|
18831
|
-
tasks: (call) => tasksTool({ call })
|
|
19045
|
+
tasks: (call) => tasksTool({ call }),
|
|
19046
|
+
openDesktopPreview: (call) => openDesktopPreviewTool({ call })
|
|
18832
19047
|
};
|
|
18833
19048
|
}
|
|
18834
19049
|
|
|
@@ -18963,10 +19178,10 @@ function buildLoadSkillExecutor(args2) {
|
|
|
18963
19178
|
metadata: { loadSkill: true, resolved: false }
|
|
18964
19179
|
};
|
|
18965
19180
|
}
|
|
18966
|
-
const { resolveSkillByName } = await import("./skillDiscovery-
|
|
19181
|
+
const { resolveSkillByName } = await import("./skillDiscovery-NTRLM6KP.js");
|
|
18967
19182
|
const resolved = resolveSkillByName(args2.cwd, name);
|
|
18968
19183
|
if (!resolved) {
|
|
18969
|
-
const { resolveCodingBuiltinSlug, buildCodingSkillContentBySlug } = await import("./codingSkills-
|
|
19184
|
+
const { resolveCodingBuiltinSlug, buildCodingSkillContentBySlug } = await import("./codingSkills-VDXQYWX4.js");
|
|
18970
19185
|
const builtinSlug = resolveCodingBuiltinSlug(name);
|
|
18971
19186
|
if (builtinSlug) {
|
|
18972
19187
|
const body = buildCodingSkillContentBySlug(builtinSlug);
|
|
@@ -19001,7 +19216,7 @@ ${body}`,
|
|
|
19001
19216
|
};
|
|
19002
19217
|
}
|
|
19003
19218
|
async function formatUnknownSkillMessage(cwd, requestedName) {
|
|
19004
|
-
const { discoverSkills } = await import("./skillDiscovery-
|
|
19219
|
+
const { discoverSkills } = await import("./skillDiscovery-NTRLM6KP.js");
|
|
19005
19220
|
let available = [];
|
|
19006
19221
|
try {
|
|
19007
19222
|
available = discoverSkills(cwd).map((s) => s.name);
|
|
@@ -19016,7 +19231,740 @@ No skills were discovered in this workspace.`;
|
|
|
19016
19231
|
Available skills: ${available.join(", ")}`;
|
|
19017
19232
|
}
|
|
19018
19233
|
|
|
19234
|
+
// packages/core/chat/upstreamErrorBody.ts
|
|
19235
|
+
function parseUpstreamErrorBody(errorText, statusText) {
|
|
19236
|
+
if (errorText) {
|
|
19237
|
+
try {
|
|
19238
|
+
const parsed = JSON.parse(errorText);
|
|
19239
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
19240
|
+
const error = parsed.error;
|
|
19241
|
+
if (error && typeof error === "object" && !Array.isArray(error)) {
|
|
19242
|
+
return parsed;
|
|
19243
|
+
}
|
|
19244
|
+
}
|
|
19245
|
+
} catch {
|
|
19246
|
+
}
|
|
19247
|
+
}
|
|
19248
|
+
return { error: { message: errorText || statusText } };
|
|
19249
|
+
}
|
|
19250
|
+
|
|
19251
|
+
// packages/agent-runtime/antigravityCloudCodeProvider.ts
|
|
19252
|
+
import { randomUUID } from "node:crypto";
|
|
19253
|
+
|
|
19254
|
+
// packages/agent-runtime/antigravityWireModel.ts
|
|
19255
|
+
var WIRE_PROFILES = {
|
|
19256
|
+
// Antigravity discovery exposes 3.7 Flash as one tiered wire model.
|
|
19257
|
+
// The UI labels its effort variants (Low/Medium/High), but the literal
|
|
19258
|
+
// -medium/-high ids return 404 from streamGenerateContent.
|
|
19259
|
+
"gemini-3.7-flash-tiered": { modelEnum: "MODEL_PLACEHOLDER_M301", maxOutputTokens: 65536 },
|
|
19260
|
+
// Gemini 3.8 Flash 沿用 3.7 的 tiered 兼容策略:仓库内暂无 Antigravity discovery
|
|
19261
|
+
// 证据确认 3.8 的 wire modelEnum,禁止虚构,先只声明同档输出上限;enum 待
|
|
19262
|
+
// discovery 证据到位后补齐。
|
|
19263
|
+
"gemini-3.8-flash-tiered": { maxOutputTokens: 65536 },
|
|
19264
|
+
"gemini-3.6-flash-low": { maxOutputTokens: 65536 },
|
|
19265
|
+
"gemini-3.6-flash-medium": { maxOutputTokens: 65536 },
|
|
19266
|
+
"gemini-3.6-flash-high": { maxOutputTokens: 65536 },
|
|
19267
|
+
// 旧模型 wire 映射保留:存量自定义 agent 仍可能引用(注册表已下线不影响此处)。
|
|
19268
|
+
"gemini-3.5-flash-extra-low": { modelEnum: "MODEL_PLACEHOLDER_M187", maxOutputTokens: 65536 },
|
|
19269
|
+
"gemini-3.5-flash-low": { modelEnum: "MODEL_PLACEHOLDER_M20", maxOutputTokens: 65536 },
|
|
19270
|
+
"gemini-3-flash-agent": { modelEnum: "MODEL_PLACEHOLDER_M132", maxOutputTokens: 65536 },
|
|
19271
|
+
"gemini-3.1-pro-low": { modelEnum: "MODEL_PLACEHOLDER_M36", maxOutputTokens: 65535 },
|
|
19272
|
+
"gemini-pro-agent": { modelEnum: "MODEL_PLACEHOLDER_M16", maxOutputTokens: 65535 },
|
|
19273
|
+
"claude-sonnet-5": { maxOutputTokens: 64e3 },
|
|
19274
|
+
"claude-sonnet-4-6": { maxOutputTokens: 64e3 },
|
|
19275
|
+
"claude-opus-4-6-thinking": { maxOutputTokens: 64e3 },
|
|
19276
|
+
"gemini-2.5-flash": { maxOutputTokens: 65536 },
|
|
19277
|
+
"gemini-2.5-pro": { maxOutputTokens: 65536 }
|
|
19278
|
+
};
|
|
19279
|
+
function resolveAntigravityWireModel(logicalModelId) {
|
|
19280
|
+
const id = logicalModelId.trim();
|
|
19281
|
+
const lower = id.toLowerCase();
|
|
19282
|
+
if (lower === "gemini-3.5-flash") {
|
|
19283
|
+
const wireModelId = "gemini-3.5-flash-low";
|
|
19284
|
+
return { wireModelId, profile: WIRE_PROFILES[wireModelId] };
|
|
19285
|
+
}
|
|
19286
|
+
if (lower === "gemini-3.7-flash" || ["gemini-3.7-flash-low", "gemini-3.7-flash-medium", "gemini-3.7-flash-high"].includes(lower)) {
|
|
19287
|
+
const wireModelId = "gemini-3.7-flash-tiered";
|
|
19288
|
+
return { wireModelId, profile: WIRE_PROFILES[wireModelId] };
|
|
19289
|
+
}
|
|
19290
|
+
if (lower === "gemini-3.8-flash" || ["gemini-3.8-flash-low", "gemini-3.8-flash-medium", "gemini-3.8-flash-high"].includes(lower)) {
|
|
19291
|
+
const wireModelId = "gemini-3.8-flash-tiered";
|
|
19292
|
+
return { wireModelId, profile: WIRE_PROFILES[wireModelId] };
|
|
19293
|
+
}
|
|
19294
|
+
if (lower === "gemini-3.6-flash") {
|
|
19295
|
+
const wireModelId = "gemini-3.6-flash-low";
|
|
19296
|
+
return { wireModelId, profile: WIRE_PROFILES[wireModelId] };
|
|
19297
|
+
}
|
|
19298
|
+
if (lower === "gemini-3.1-pro" || lower === "gemini-3.1-pro-preview") {
|
|
19299
|
+
const wireModelId = "gemini-3.1-pro-low";
|
|
19300
|
+
return { wireModelId, profile: WIRE_PROFILES[wireModelId] };
|
|
19301
|
+
}
|
|
19302
|
+
if (WIRE_PROFILES[id]) {
|
|
19303
|
+
return { wireModelId: id, profile: WIRE_PROFILES[id] };
|
|
19304
|
+
}
|
|
19305
|
+
return { wireModelId: id };
|
|
19306
|
+
}
|
|
19307
|
+
|
|
19308
|
+
// packages/agent-runtime/geminiNativeShared.ts
|
|
19309
|
+
var SKIP_THOUGHT_SIGNATURE = "skip_thought_signature_validator";
|
|
19310
|
+
function resolveGeminiModelQuirks(modelId) {
|
|
19311
|
+
const lower = modelId.toLowerCase();
|
|
19312
|
+
const isGemini3 = lower.includes("gemini-3");
|
|
19313
|
+
const isStrictSignatureModel = lower.includes("gemini-3.5") || lower.includes("flash-preview");
|
|
19314
|
+
const isClaude = lower.includes("claude");
|
|
19315
|
+
return {
|
|
19316
|
+
requiresThoughtSignature: isGemini3,
|
|
19317
|
+
allowsThoughtSignatureSentinel: isGemini3 && !isStrictSignatureModel,
|
|
19318
|
+
isClaudeCrossModel: isClaude
|
|
19319
|
+
};
|
|
19320
|
+
}
|
|
19321
|
+
function isGemini3Model(modelId) {
|
|
19322
|
+
return resolveGeminiModelQuirks(modelId).requiresThoughtSignature;
|
|
19323
|
+
}
|
|
19324
|
+
function messageText(content) {
|
|
19325
|
+
if (typeof content === "string") return content;
|
|
19326
|
+
if (!Array.isArray(content)) return "";
|
|
19327
|
+
return content.filter(
|
|
19328
|
+
(part) => part?.type === "text"
|
|
19329
|
+
).map((part) => part.text).join("\n").trim();
|
|
19330
|
+
}
|
|
19331
|
+
function parseDataUrlToInlineData(url) {
|
|
19332
|
+
const match7 = /^data:([A-Za-z0-9.+-]+\/[A-Za-z0-9.+-]+);base64,([A-Za-z0-9+/=]*)$/.exec(
|
|
19333
|
+
url
|
|
19334
|
+
);
|
|
19335
|
+
if (!match7) return null;
|
|
19336
|
+
return { mimeType: match7[1], data: match7[2] };
|
|
19337
|
+
}
|
|
19338
|
+
function extractInlineDataParts(content) {
|
|
19339
|
+
if (!Array.isArray(content)) return [];
|
|
19340
|
+
const parts2 = [];
|
|
19341
|
+
for (const part of content) {
|
|
19342
|
+
if (!part || typeof part !== "object") continue;
|
|
19343
|
+
if (part.type !== "image_url") continue;
|
|
19344
|
+
const url = part.image_url?.url;
|
|
19345
|
+
if (typeof url !== "string" || !url.trim()) continue;
|
|
19346
|
+
const inline = parseDataUrlToInlineData(url);
|
|
19347
|
+
if (inline) parts2.push({ inlineData: inline });
|
|
19348
|
+
}
|
|
19349
|
+
return parts2;
|
|
19350
|
+
}
|
|
19351
|
+
function convertOpenAiMessagesToGemini(messages, options) {
|
|
19352
|
+
const contents = [];
|
|
19353
|
+
const systemTexts = [];
|
|
19354
|
+
let toolCallIndex = 0;
|
|
19355
|
+
let pendingFunctionCalls = [];
|
|
19356
|
+
const pushOrMergeContent = (role, parts2) => {
|
|
19357
|
+
if (parts2.length === 0) return;
|
|
19358
|
+
const last = contents[contents.length - 1];
|
|
19359
|
+
if (last && last.role === role) {
|
|
19360
|
+
last.parts.push(...parts2);
|
|
19361
|
+
} else {
|
|
19362
|
+
contents.push({ role, parts: parts2 });
|
|
19363
|
+
}
|
|
19364
|
+
};
|
|
19365
|
+
const flushPendingFunctionCalls = () => {
|
|
19366
|
+
if (pendingFunctionCalls.length === 0) return;
|
|
19367
|
+
const dummyResponses = pendingFunctionCalls.map(
|
|
19368
|
+
({ name, id }) => ({
|
|
19369
|
+
functionResponse: {
|
|
19370
|
+
name,
|
|
19371
|
+
response: { output: "{}" },
|
|
19372
|
+
...id ? { id } : {}
|
|
19373
|
+
}
|
|
19374
|
+
})
|
|
19375
|
+
);
|
|
19376
|
+
pendingFunctionCalls = [];
|
|
19377
|
+
pushOrMergeContent("user", dummyResponses);
|
|
19378
|
+
};
|
|
19379
|
+
for (const raw of messages) {
|
|
19380
|
+
if (!raw || typeof raw !== "object" || !("role" in raw)) continue;
|
|
19381
|
+
const role = String(raw.role);
|
|
19382
|
+
const content = "content" in raw ? raw.content : null;
|
|
19383
|
+
if (role === "system") {
|
|
19384
|
+
const text = messageText(
|
|
19385
|
+
content
|
|
19386
|
+
);
|
|
19387
|
+
if (text) systemTexts.push(text);
|
|
19388
|
+
continue;
|
|
19389
|
+
}
|
|
19390
|
+
if (role === "user") {
|
|
19391
|
+
flushPendingFunctionCalls();
|
|
19392
|
+
const text = messageText(
|
|
19393
|
+
content
|
|
19394
|
+
);
|
|
19395
|
+
const imageParts = extractInlineDataParts(
|
|
19396
|
+
content
|
|
19397
|
+
);
|
|
19398
|
+
if (!text && imageParts.length === 0) continue;
|
|
19399
|
+
const parts2 = [];
|
|
19400
|
+
if (text) parts2.push({ text });
|
|
19401
|
+
for (const img of imageParts) parts2.push(img);
|
|
19402
|
+
pushOrMergeContent("user", parts2);
|
|
19403
|
+
continue;
|
|
19404
|
+
}
|
|
19405
|
+
if (role === "assistant") {
|
|
19406
|
+
flushPendingFunctionCalls();
|
|
19407
|
+
const text = messageText(
|
|
19408
|
+
content
|
|
19409
|
+
);
|
|
19410
|
+
const toolCalls = "tool_calls" in raw && Array.isArray(raw.tool_calls) ? raw.tool_calls ?? [] : [];
|
|
19411
|
+
const parts2 = [];
|
|
19412
|
+
if (text) {
|
|
19413
|
+
parts2.push({ text });
|
|
19414
|
+
}
|
|
19415
|
+
for (const call of toolCalls) {
|
|
19416
|
+
const name = call?.function?.name?.trim();
|
|
19417
|
+
if (!name) continue;
|
|
19418
|
+
const id = call.id?.trim() || `${name}_${toolCallIndex++}`;
|
|
19419
|
+
pendingFunctionCalls.push({ name, id });
|
|
19420
|
+
const realSignature = typeof call.thought_signature === "string" && call.thought_signature ? call.thought_signature : void 0;
|
|
19421
|
+
const isFirstFunctionCallPart = !parts2.some(
|
|
19422
|
+
(p) => "functionCall" in p
|
|
19423
|
+
);
|
|
19424
|
+
const signature = realSignature ?? (options.attachSkipThoughtSignature && isFirstFunctionCallPart ? SKIP_THOUGHT_SIGNATURE : void 0);
|
|
19425
|
+
const part = {
|
|
19426
|
+
functionCall: {
|
|
19427
|
+
name,
|
|
19428
|
+
args: parseToolArgs(call.function?.arguments),
|
|
19429
|
+
...id ? { id } : {}
|
|
19430
|
+
},
|
|
19431
|
+
...signature ? { thoughtSignature: signature } : {}
|
|
19432
|
+
};
|
|
19433
|
+
parts2.push(part);
|
|
19434
|
+
}
|
|
19435
|
+
pushOrMergeContent("model", parts2);
|
|
19436
|
+
continue;
|
|
19437
|
+
}
|
|
19438
|
+
if (role === "tool") {
|
|
19439
|
+
const toolCallId = "tool_call_id" in raw && typeof raw.tool_call_id === "string" ? raw.tool_call_id : "";
|
|
19440
|
+
const rawName = "name" in raw && typeof raw.name === "string" ? raw.name.trim() : "";
|
|
19441
|
+
const pendingIndex = pendingFunctionCalls.findIndex(
|
|
19442
|
+
(p) => toolCallId ? p.id === toolCallId : rawName ? p.name === rawName : true
|
|
19443
|
+
);
|
|
19444
|
+
if (pendingIndex === -1) continue;
|
|
19445
|
+
const [{ name, id }] = pendingFunctionCalls.splice(pendingIndex, 1);
|
|
19446
|
+
const output = messageText(content) || "{}";
|
|
19447
|
+
pushOrMergeContent("user", [
|
|
19448
|
+
{
|
|
19449
|
+
functionResponse: {
|
|
19450
|
+
name,
|
|
19451
|
+
response: { output },
|
|
19452
|
+
// 保留 OpenAI tool_call_id:antigravity Cloud Code Assist 网关把
|
|
19453
|
+
// Gemini contents 转成 Claude messages 时需要 functionResponse →
|
|
19454
|
+
// tool_result 的 tool_use_id;缺 id 时网关报
|
|
19455
|
+
// "tool_result.tool_use_id: Field required"(HTTP 400)。
|
|
19456
|
+
...id ? { id } : {}
|
|
19457
|
+
}
|
|
19458
|
+
}
|
|
19459
|
+
]);
|
|
19460
|
+
}
|
|
19461
|
+
}
|
|
19462
|
+
flushPendingFunctionCalls();
|
|
19463
|
+
if (contents.length > 0 && contents[0]?.role === "model") {
|
|
19464
|
+
contents.unshift({
|
|
19465
|
+
role: "user",
|
|
19466
|
+
parts: [{ text: "Continue the conversation." }]
|
|
19467
|
+
});
|
|
19468
|
+
}
|
|
19469
|
+
return { contents, systemTexts };
|
|
19470
|
+
}
|
|
19471
|
+
function parseToolArgs(raw) {
|
|
19472
|
+
if (typeof raw === "string") {
|
|
19473
|
+
try {
|
|
19474
|
+
const parsed = JSON.parse(raw);
|
|
19475
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
19476
|
+
return parsed;
|
|
19477
|
+
}
|
|
19478
|
+
} catch {
|
|
19479
|
+
}
|
|
19480
|
+
}
|
|
19481
|
+
if (raw && typeof raw === "object" && !Array.isArray(raw)) {
|
|
19482
|
+
return raw;
|
|
19483
|
+
}
|
|
19484
|
+
return {};
|
|
19485
|
+
}
|
|
19486
|
+
function sanitizeGeminiSchemaNode(node, active) {
|
|
19487
|
+
const out = {};
|
|
19488
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) {
|
|
19489
|
+
return { type: "string" };
|
|
19490
|
+
}
|
|
19491
|
+
if (active?.has(node)) {
|
|
19492
|
+
return { type: "object", description: "(circular schema reference)" };
|
|
19493
|
+
}
|
|
19494
|
+
const seen = active ?? /* @__PURE__ */ new WeakSet();
|
|
19495
|
+
seen.add(node);
|
|
19496
|
+
try {
|
|
19497
|
+
return sanitizeGeminiSchemaNodeInner(node, out, seen);
|
|
19498
|
+
} finally {
|
|
19499
|
+
seen.delete(node);
|
|
19500
|
+
}
|
|
19501
|
+
}
|
|
19502
|
+
function sanitizeGeminiSchemaNodeInner(src, out, seen) {
|
|
19503
|
+
if (Array.isArray(src.type)) {
|
|
19504
|
+
const firstNonNull = src.type.find((t) => t !== "null");
|
|
19505
|
+
if (typeof firstNonNull === "string") out.type = firstNonNull;
|
|
19506
|
+
out.nullable = true;
|
|
19507
|
+
} else if (typeof src.type === "string") {
|
|
19508
|
+
out.type = src.type;
|
|
19509
|
+
}
|
|
19510
|
+
if (typeof src.description === "string") out.description = src.description;
|
|
19511
|
+
if (typeof src.minimum === "number") out.minimum = src.minimum;
|
|
19512
|
+
if (typeof src.maximum === "number") out.maximum = src.maximum;
|
|
19513
|
+
if (Array.isArray(src.enum) && src.enum.length > 0) out.enum = src.enum;
|
|
19514
|
+
if (src.nullable === true) out.nullable = true;
|
|
19515
|
+
if ("const" in src && src.const !== void 0 && !out.enum) {
|
|
19516
|
+
out.enum = [src.const];
|
|
19517
|
+
}
|
|
19518
|
+
const variantBranches = [
|
|
19519
|
+
...Array.isArray(src.oneOf) ? src.oneOf : [],
|
|
19520
|
+
...Array.isArray(src.anyOf) ? src.anyOf : []
|
|
19521
|
+
];
|
|
19522
|
+
if (variantBranches.length > 0) {
|
|
19523
|
+
const mergedProperties = {};
|
|
19524
|
+
let requiredIntersection;
|
|
19525
|
+
for (const branch of variantBranches) {
|
|
19526
|
+
const sanitized = sanitizeGeminiSchemaNode(branch, seen);
|
|
19527
|
+
const branchProperties = sanitized.properties ?? {};
|
|
19528
|
+
for (const [key, value] of Object.entries(branchProperties)) {
|
|
19529
|
+
const previous = mergedProperties[key];
|
|
19530
|
+
const prevEnum = previous?.enum;
|
|
19531
|
+
const nextEnum = value?.enum;
|
|
19532
|
+
if (prevEnum && nextEnum) {
|
|
19533
|
+
mergedProperties[key] = {
|
|
19534
|
+
...value,
|
|
19535
|
+
enum: [.../* @__PURE__ */ new Set([...prevEnum, ...nextEnum])]
|
|
19536
|
+
};
|
|
19537
|
+
} else {
|
|
19538
|
+
mergedProperties[key] = value;
|
|
19539
|
+
}
|
|
19540
|
+
}
|
|
19541
|
+
const branchRequired = Array.isArray(sanitized.required) ? sanitized.required : [];
|
|
19542
|
+
requiredIntersection = requiredIntersection === void 0 ? [...branchRequired] : requiredIntersection.filter((r) => branchRequired.includes(r));
|
|
19543
|
+
}
|
|
19544
|
+
out.properties = {
|
|
19545
|
+
...out.properties ?? {},
|
|
19546
|
+
...mergedProperties
|
|
19547
|
+
};
|
|
19548
|
+
if (requiredIntersection !== void 0 && requiredIntersection.length > 0) {
|
|
19549
|
+
out.required = requiredIntersection;
|
|
19550
|
+
}
|
|
19551
|
+
if (typeof out.type !== "string") out.type = "object";
|
|
19552
|
+
}
|
|
19553
|
+
if (Array.isArray(src.allOf)) {
|
|
19554
|
+
for (const branch of src.allOf) {
|
|
19555
|
+
const sanitized = sanitizeGeminiSchemaNode(branch, seen);
|
|
19556
|
+
out.properties = {
|
|
19557
|
+
...out.properties ?? {},
|
|
19558
|
+
...sanitized.properties ?? {}
|
|
19559
|
+
};
|
|
19560
|
+
if (Array.isArray(sanitized.required)) {
|
|
19561
|
+
out.required = [
|
|
19562
|
+
.../* @__PURE__ */ new Set([
|
|
19563
|
+
...out.required ?? [],
|
|
19564
|
+
...sanitized.required ?? []
|
|
19565
|
+
])
|
|
19566
|
+
];
|
|
19567
|
+
}
|
|
19568
|
+
}
|
|
19569
|
+
if (typeof out.type !== "string") out.type = "object";
|
|
19570
|
+
}
|
|
19571
|
+
if (src.properties && typeof src.properties === "object") {
|
|
19572
|
+
const properties = {};
|
|
19573
|
+
for (const [key, value] of Object.entries(
|
|
19574
|
+
src.properties
|
|
19575
|
+
)) {
|
|
19576
|
+
properties[key] = sanitizeGeminiSchemaNode(value, seen);
|
|
19577
|
+
}
|
|
19578
|
+
out.properties = properties;
|
|
19579
|
+
if (typeof out.type !== "string") out.type = "object";
|
|
19580
|
+
}
|
|
19581
|
+
if (Array.isArray(src.required)) {
|
|
19582
|
+
const properties = out.properties ?? {};
|
|
19583
|
+
const required = [...new Set(src.required)].filter(
|
|
19584
|
+
(r) => typeof r === "string" && r in properties
|
|
19585
|
+
);
|
|
19586
|
+
if (required.length > 0) out.required = required;
|
|
19587
|
+
}
|
|
19588
|
+
if (src.items !== void 0) {
|
|
19589
|
+
out.items = sanitizeGeminiSchemaNode(src.items, seen);
|
|
19590
|
+
if (typeof out.type !== "string") out.type = "array";
|
|
19591
|
+
}
|
|
19592
|
+
if (typeof out.type !== "string") out.type = "object";
|
|
19593
|
+
return out;
|
|
19594
|
+
}
|
|
19595
|
+
function convertOpenAiToolsToGemini(tools) {
|
|
19596
|
+
if (!Array.isArray(tools) || tools.length === 0) return void 0;
|
|
19597
|
+
const declarations = [];
|
|
19598
|
+
for (const tool of tools) {
|
|
19599
|
+
if (!tool || typeof tool !== "object" || !("function" in tool)) continue;
|
|
19600
|
+
const fn3 = tool.function;
|
|
19601
|
+
const name = typeof fn3.name === "string" ? fn3.name : "";
|
|
19602
|
+
if (!name) continue;
|
|
19603
|
+
declarations.push({
|
|
19604
|
+
name,
|
|
19605
|
+
description: typeof fn3.description === "string" ? fn3.description : "",
|
|
19606
|
+
parameters: sanitizeGeminiSchemaNode(
|
|
19607
|
+
fn3.parameters ?? { type: "object", properties: {} }
|
|
19608
|
+
)
|
|
19609
|
+
});
|
|
19610
|
+
}
|
|
19611
|
+
if (declarations.length === 0) return void 0;
|
|
19612
|
+
return [{ functionDeclarations: declarations }];
|
|
19613
|
+
}
|
|
19614
|
+
function createGeminiAccumulatorState() {
|
|
19615
|
+
return {
|
|
19616
|
+
text: "",
|
|
19617
|
+
toolCalls: [],
|
|
19618
|
+
reasoning: "",
|
|
19619
|
+
events: []
|
|
19620
|
+
};
|
|
19621
|
+
}
|
|
19622
|
+
function applyGeminiChunk(chunk, state, options) {
|
|
19623
|
+
if (!chunk || typeof chunk !== "object") return;
|
|
19624
|
+
const response = "response" in chunk && chunk.response && typeof chunk.response === "object" ? chunk.response : chunk;
|
|
19625
|
+
if ("usageMetadata" in response && response.usageMetadata && typeof response.usageMetadata === "object") {
|
|
19626
|
+
const meta = response.usageMetadata;
|
|
19627
|
+
const prompt = typeof meta.promptTokenCount === "number" ? meta.promptTokenCount : 0;
|
|
19628
|
+
const candidates2 = typeof meta.candidatesTokenCount === "number" ? meta.candidatesTokenCount : 0;
|
|
19629
|
+
const total = typeof meta.totalTokenCount === "number" ? meta.totalTokenCount : prompt + candidates2;
|
|
19630
|
+
const cached3 = typeof meta.cachedContentTokenCount === "number" && Number.isFinite(meta.cachedContentTokenCount) ? (
|
|
19631
|
+
// cached ⊆ prompt;对畸形上游防御性钳位,避免 cache_read > input 破坏归一化与计费
|
|
19632
|
+
Math.min(Math.max(0, Math.floor(meta.cachedContentTokenCount)), prompt)
|
|
19633
|
+
) : 0;
|
|
19634
|
+
state.usage = {
|
|
19635
|
+
prompt_tokens: prompt,
|
|
19636
|
+
completion_tokens: candidates2,
|
|
19637
|
+
total_tokens: total,
|
|
19638
|
+
...cached3 > 0 ? { cache_read_input_tokens: cached3 } : {}
|
|
19639
|
+
};
|
|
19640
|
+
state.events.push({ kind: "usage", usage: state.usage });
|
|
19641
|
+
}
|
|
19642
|
+
const candidates = Array.isArray(response.candidates) ? response.candidates : [];
|
|
19643
|
+
for (const candidate of candidates) {
|
|
19644
|
+
if (!candidate || typeof candidate !== "object") continue;
|
|
19645
|
+
const candidateFinishReason = candidate.finishReason;
|
|
19646
|
+
if (typeof candidateFinishReason === "string" && candidateFinishReason.trim()) {
|
|
19647
|
+
state.finishReason = candidateFinishReason.trim();
|
|
19648
|
+
state.events.push({ kind: "finish", reason: state.finishReason });
|
|
19649
|
+
}
|
|
19650
|
+
const parts2 = Array.isArray(
|
|
19651
|
+
candidate.content?.parts
|
|
19652
|
+
) ? candidate.content.parts : [];
|
|
19653
|
+
for (const part of parts2) {
|
|
19654
|
+
if (!part || typeof part !== "object") continue;
|
|
19655
|
+
const partSignature = part.thoughtSignature;
|
|
19656
|
+
const isThought = Boolean(part.thought);
|
|
19657
|
+
if ("text" in part && typeof part.text === "string") {
|
|
19658
|
+
const piece = part.text;
|
|
19659
|
+
if (!isThought) {
|
|
19660
|
+
state.text += piece;
|
|
19661
|
+
if (piece) {
|
|
19662
|
+
state.events.push({ kind: "text", text: piece });
|
|
19663
|
+
if (options?.onTextDelta) options.onTextDelta(piece);
|
|
19664
|
+
}
|
|
19665
|
+
} else {
|
|
19666
|
+
state.reasoning += piece;
|
|
19667
|
+
if (piece) {
|
|
19668
|
+
state.events.push({ kind: "reasoning", text: piece });
|
|
19669
|
+
if (options?.onReasoningDelta) options.onReasoningDelta(piece);
|
|
19670
|
+
}
|
|
19671
|
+
}
|
|
19672
|
+
}
|
|
19673
|
+
if (isThought && typeof partSignature === "string" && partSignature) {
|
|
19674
|
+
state.pendingThoughtSignature = partSignature;
|
|
19675
|
+
}
|
|
19676
|
+
if ("functionCall" in part && part.functionCall) {
|
|
19677
|
+
const call = part.functionCall;
|
|
19678
|
+
const name = typeof call.name === "string" ? call.name : "tool";
|
|
19679
|
+
const id = typeof call.id === "string" ? call.id : `${name}_${state.toolCalls.length}`;
|
|
19680
|
+
const argsObj = call.args && typeof call.args === "object" ? call.args : {};
|
|
19681
|
+
const resolvedSignature = typeof partSignature === "string" && partSignature ? partSignature : state.pendingThoughtSignature;
|
|
19682
|
+
state.pendingThoughtSignature = void 0;
|
|
19683
|
+
const toolCall = {
|
|
19684
|
+
id,
|
|
19685
|
+
type: "function",
|
|
19686
|
+
function: { name, arguments: JSON.stringify(argsObj) },
|
|
19687
|
+
...typeof resolvedSignature === "string" && resolvedSignature ? { thought_signature: resolvedSignature } : {}
|
|
19688
|
+
};
|
|
19689
|
+
state.toolCalls.push(toolCall);
|
|
19690
|
+
state.events.push({ kind: "tool_call", toolCall });
|
|
19691
|
+
}
|
|
19692
|
+
}
|
|
19693
|
+
}
|
|
19694
|
+
}
|
|
19695
|
+
function accumulateGeminiChunks(chunks2, options) {
|
|
19696
|
+
const state = createGeminiAccumulatorState();
|
|
19697
|
+
for (const chunk of chunks2) {
|
|
19698
|
+
applyGeminiChunk(chunk, state, options);
|
|
19699
|
+
}
|
|
19700
|
+
return {
|
|
19701
|
+
text: state.text,
|
|
19702
|
+
toolCalls: state.toolCalls,
|
|
19703
|
+
usage: state.usage,
|
|
19704
|
+
finishReason: state.finishReason,
|
|
19705
|
+
reasoningContent: state.reasoning,
|
|
19706
|
+
events: state.events
|
|
19707
|
+
};
|
|
19708
|
+
}
|
|
19709
|
+
async function accumulateGeminiStream(stream, options) {
|
|
19710
|
+
const state = createGeminiAccumulatorState();
|
|
19711
|
+
for await (const chunk of stream) {
|
|
19712
|
+
applyGeminiChunk(chunk, state, options);
|
|
19713
|
+
}
|
|
19714
|
+
return {
|
|
19715
|
+
text: state.text,
|
|
19716
|
+
toolCalls: state.toolCalls,
|
|
19717
|
+
usage: state.usage,
|
|
19718
|
+
finishReason: state.finishReason,
|
|
19719
|
+
reasoningContent: state.reasoning,
|
|
19720
|
+
events: state.events
|
|
19721
|
+
};
|
|
19722
|
+
}
|
|
19723
|
+
function shouldUseGeminiNativeToolRoute(provider, model, tools, isImageModel) {
|
|
19724
|
+
return provider === "google" && !isImageModel(model) && isGemini3Model(model) && Array.isArray(tools) && tools.length > 0;
|
|
19725
|
+
}
|
|
19726
|
+
function buildGeminiGenerateContentRequest(args2) {
|
|
19727
|
+
const { contents, systemTexts } = convertOpenAiMessagesToGemini(
|
|
19728
|
+
args2.messages,
|
|
19729
|
+
{ attachSkipThoughtSignature: args2.attachSkipThoughtSignature }
|
|
19730
|
+
);
|
|
19731
|
+
const request3 = { contents };
|
|
19732
|
+
if (systemTexts.length > 0) {
|
|
19733
|
+
request3.systemInstruction = {
|
|
19734
|
+
role: "user",
|
|
19735
|
+
parts: systemTexts.map((text) => ({ text }))
|
|
19736
|
+
};
|
|
19737
|
+
}
|
|
19738
|
+
const toolsResult = convertOpenAiToolsToGemini(args2.tools);
|
|
19739
|
+
if (toolsResult) {
|
|
19740
|
+
request3.tools = toolsResult;
|
|
19741
|
+
request3.toolConfig = { functionCallingConfig: { mode: "VALIDATED" } };
|
|
19742
|
+
}
|
|
19743
|
+
const generationConfig = {};
|
|
19744
|
+
if (typeof args2.maxTokens === "number" && args2.maxTokens > 0) {
|
|
19745
|
+
generationConfig.maxOutputTokens = args2.maxTokens;
|
|
19746
|
+
}
|
|
19747
|
+
if (typeof args2.temperature === "number") {
|
|
19748
|
+
generationConfig.temperature = args2.temperature;
|
|
19749
|
+
}
|
|
19750
|
+
if (Object.keys(generationConfig).length > 0) {
|
|
19751
|
+
request3.generationConfig = generationConfig;
|
|
19752
|
+
}
|
|
19753
|
+
return request3;
|
|
19754
|
+
}
|
|
19755
|
+
|
|
19756
|
+
// packages/agent-runtime/antigravityCloudCodeProvider.ts
|
|
19757
|
+
var STREAM_PATH = "/v1internal:streamGenerateContent?alt=sse";
|
|
19758
|
+
function buildCloudCodeAssistPayload(args2) {
|
|
19759
|
+
const projectId = readAntigravityProjectId(args2.metadata);
|
|
19760
|
+
if (!projectId) {
|
|
19761
|
+
throw new Error(
|
|
19762
|
+
"Antigravity OAuth credential is missing metadata.projectId. Re-run `nolo auth antigravity`."
|
|
19763
|
+
);
|
|
19764
|
+
}
|
|
19765
|
+
const logicalModel = asOptionalTrimmedString(args2.openAiBody.model) ?? asOptionalTrimmedString(args2.agentConfig.model) ?? "gemini-3.1-pro";
|
|
19766
|
+
const { wireModelId: model, profile } = resolveAntigravityWireModel(logicalModel);
|
|
19767
|
+
const rawMessages = Array.isArray(args2.openAiBody.messages) ? args2.openAiBody.messages : [];
|
|
19768
|
+
const quirks = resolveGeminiModelQuirks(model);
|
|
19769
|
+
const isClaude = quirks.isClaudeCrossModel;
|
|
19770
|
+
const { contents, systemTexts } = convertOpenAiMessagesToGemini(rawMessages, {
|
|
19771
|
+
attachSkipThoughtSignature: quirks.allowsThoughtSignatureSentinel
|
|
19772
|
+
});
|
|
19773
|
+
if (contents.length === 0) {
|
|
19774
|
+
throw new Error("Antigravity Cloud Code Assist request has no user/model contents.");
|
|
19775
|
+
}
|
|
19776
|
+
const prompt = args2.agentConfig.prompt?.trim();
|
|
19777
|
+
if (prompt) systemTexts.unshift(prompt);
|
|
19778
|
+
const request3 = { contents };
|
|
19779
|
+
if (systemTexts.length > 0) {
|
|
19780
|
+
request3.systemInstruction = {
|
|
19781
|
+
role: "user",
|
|
19782
|
+
parts: systemTexts.map((text) => ({ text }))
|
|
19783
|
+
};
|
|
19784
|
+
}
|
|
19785
|
+
const tools = convertOpenAiToolsToGemini(
|
|
19786
|
+
Array.isArray(args2.openAiBody.tools) ? args2.openAiBody.tools : void 0
|
|
19787
|
+
);
|
|
19788
|
+
if (tools) {
|
|
19789
|
+
request3.tools = tools;
|
|
19790
|
+
request3.toolConfig = { functionCallingConfig: { mode: "VALIDATED" } };
|
|
19791
|
+
}
|
|
19792
|
+
const generationConfig = {};
|
|
19793
|
+
if (profile?.maxOutputTokens) {
|
|
19794
|
+
generationConfig.maxOutputTokens = profile.maxOutputTokens;
|
|
19795
|
+
} else if (typeof args2.agentConfig.max_tokens === "number" && args2.agentConfig.max_tokens > 0) {
|
|
19796
|
+
generationConfig.maxOutputTokens = args2.agentConfig.max_tokens;
|
|
19797
|
+
}
|
|
19798
|
+
if (typeof args2.agentConfig.temperature === "number") {
|
|
19799
|
+
generationConfig.temperature = args2.agentConfig.temperature;
|
|
19800
|
+
}
|
|
19801
|
+
if (Object.keys(generationConfig).length > 0) {
|
|
19802
|
+
request3.generationConfig = generationConfig;
|
|
19803
|
+
}
|
|
19804
|
+
const agentId = randomUUID();
|
|
19805
|
+
const trajectoryId = randomUUID();
|
|
19806
|
+
const step = 2;
|
|
19807
|
+
const requestId = `agent/${agentId}/${Date.now()}/${trajectoryId}/${step}`;
|
|
19808
|
+
const labels = {
|
|
19809
|
+
trajectory_id: trajectoryId,
|
|
19810
|
+
last_step_index: String(step - 1),
|
|
19811
|
+
used_claude: String(isClaude),
|
|
19812
|
+
used_claude_conservative: String(isClaude)
|
|
19813
|
+
};
|
|
19814
|
+
if (profile?.modelEnum) {
|
|
19815
|
+
labels.model_enum = profile.modelEnum;
|
|
19816
|
+
}
|
|
19817
|
+
request3.labels = labels;
|
|
19818
|
+
request3.sessionId = `-${Math.floor(Math.random() * 9e15)}`;
|
|
19819
|
+
return {
|
|
19820
|
+
url: `${resolveAntigravityCloudCodeBaseUrl(args2.agentConfig.customProviderUrl)}${STREAM_PATH}`,
|
|
19821
|
+
envelope: {
|
|
19822
|
+
project: projectId,
|
|
19823
|
+
model,
|
|
19824
|
+
request: request3,
|
|
19825
|
+
requestId,
|
|
19826
|
+
requestType: "agent",
|
|
19827
|
+
userAgent: "antigravity"
|
|
19828
|
+
}
|
|
19829
|
+
};
|
|
19830
|
+
}
|
|
19831
|
+
function resolveAntigravityFinishReason(upstream) {
|
|
19832
|
+
const normalized = (upstream ?? "").trim().toUpperCase();
|
|
19833
|
+
if (normalized === "MAX_TOKENS") return "length";
|
|
19834
|
+
if (normalized === "SAFETY" || normalized === "RECITATION" || normalized === "PROHIBITED_CONTENT" || normalized === "BLOCKLIST") {
|
|
19835
|
+
return "content_filter";
|
|
19836
|
+
}
|
|
19837
|
+
return "stop";
|
|
19838
|
+
}
|
|
19839
|
+
function normalizeAntigravityCompletion(decoded) {
|
|
19840
|
+
const { text, toolCalls, usage, finishReason, reasoningContent, events } = decoded;
|
|
19841
|
+
const normalizedFinishReason = (finishReason ?? "").trim().toUpperCase();
|
|
19842
|
+
if (!text && !reasoningContent && toolCalls.length === 0 && !finishReason && !usage) {
|
|
19843
|
+
const body = {
|
|
19844
|
+
error: {
|
|
19845
|
+
message: "antigravity upstream returned an empty stream (no content, finishReason or usage); channel degradation, not model emptiness"
|
|
19846
|
+
},
|
|
19847
|
+
provider_events: events
|
|
19848
|
+
};
|
|
19849
|
+
return {
|
|
19850
|
+
status: 502,
|
|
19851
|
+
text: "",
|
|
19852
|
+
toolCalls: [],
|
|
19853
|
+
providerEvents: events,
|
|
19854
|
+
body
|
|
19855
|
+
};
|
|
19856
|
+
}
|
|
19857
|
+
if (normalizedFinishReason === "MALFORMED_FUNCTION_CALL") {
|
|
19858
|
+
const message2 = "antigravity upstream returned MALFORMED_FUNCTION_CALL (model generated an invalid function call or tool arguments were rejected by upstream)";
|
|
19859
|
+
const providerFailure = {
|
|
19860
|
+
kind: "provider_failure",
|
|
19861
|
+
provider: "antigravity",
|
|
19862
|
+
code: "MALFORMED_FUNCTION_CALL",
|
|
19863
|
+
message: message2,
|
|
19864
|
+
providerReason: "MALFORMED_FUNCTION_CALL",
|
|
19865
|
+
retryable: false,
|
|
19866
|
+
status: 502
|
|
19867
|
+
};
|
|
19868
|
+
return {
|
|
19869
|
+
status: 502,
|
|
19870
|
+
text: "",
|
|
19871
|
+
toolCalls: [],
|
|
19872
|
+
finishReason,
|
|
19873
|
+
providerEvents: events,
|
|
19874
|
+
providerFailure,
|
|
19875
|
+
runtimeProviderFailure: {
|
|
19876
|
+
message: providerFailure.message,
|
|
19877
|
+
retryable: providerFailure.retryable
|
|
19878
|
+
},
|
|
19879
|
+
body: {
|
|
19880
|
+
error: {
|
|
19881
|
+
message: message2,
|
|
19882
|
+
code: "MALFORMED_FUNCTION_CALL",
|
|
19883
|
+
category: "malformed_function_call",
|
|
19884
|
+
providerReason: "MALFORMED_FUNCTION_CALL",
|
|
19885
|
+
retryable: false
|
|
19886
|
+
},
|
|
19887
|
+
provider_failure: providerFailure,
|
|
19888
|
+
provider_events: events
|
|
19889
|
+
}
|
|
19890
|
+
};
|
|
19891
|
+
}
|
|
19892
|
+
const message = {
|
|
19893
|
+
role: "assistant",
|
|
19894
|
+
content: text || null
|
|
19895
|
+
};
|
|
19896
|
+
if (toolCalls.length > 0) message.tool_calls = toolCalls;
|
|
19897
|
+
if (reasoningContent) message.reasoning_content = reasoningContent;
|
|
19898
|
+
return {
|
|
19899
|
+
status: 200,
|
|
19900
|
+
text,
|
|
19901
|
+
...reasoningContent ? { reasoningContent } : {},
|
|
19902
|
+
toolCalls,
|
|
19903
|
+
...usage ? { usage } : {},
|
|
19904
|
+
...finishReason ? { finishReason } : {},
|
|
19905
|
+
providerEvents: events,
|
|
19906
|
+
body: {
|
|
19907
|
+
choices: [{
|
|
19908
|
+
index: 0,
|
|
19909
|
+
message,
|
|
19910
|
+
finish_reason: toolCalls.length > 0 ? "tool_calls" : resolveAntigravityFinishReason(finishReason)
|
|
19911
|
+
}],
|
|
19912
|
+
...usage ? { usage } : {},
|
|
19913
|
+
provider_events: events
|
|
19914
|
+
}
|
|
19915
|
+
};
|
|
19916
|
+
}
|
|
19917
|
+
async function fetchAntigravityCloudCodeCompletion(args2) {
|
|
19918
|
+
const fetchImpl = args2.fetchImpl ?? fetch;
|
|
19919
|
+
const { url, envelope } = buildCloudCodeAssistPayload(args2);
|
|
19920
|
+
const response = await fetchImpl(url, {
|
|
19921
|
+
method: "POST",
|
|
19922
|
+
headers: {
|
|
19923
|
+
Authorization: `Bearer ${args2.accessToken}`,
|
|
19924
|
+
"Content-Type": "application/json",
|
|
19925
|
+
"User-Agent": getAntigravityUserAgent()
|
|
19926
|
+
},
|
|
19927
|
+
body: JSON.stringify(envelope),
|
|
19928
|
+
signal: args2.signal
|
|
19929
|
+
});
|
|
19930
|
+
if (!response.ok) {
|
|
19931
|
+
const errorText = await response.text();
|
|
19932
|
+
return {
|
|
19933
|
+
status: response.status,
|
|
19934
|
+
text: "",
|
|
19935
|
+
toolCalls: [],
|
|
19936
|
+
providerEvents: [],
|
|
19937
|
+
// 保留上游结构:Antigravity 的限流 body 同样携带结构化的重置信息,
|
|
19938
|
+
// 压成字符串会让冷却退化成 5 分钟默认值。
|
|
19939
|
+
body: parseUpstreamErrorBody(errorText, response.statusText)
|
|
19940
|
+
};
|
|
19941
|
+
}
|
|
19942
|
+
const chunkStream = streamSseDataValues(response, parseSseDataLineJson);
|
|
19943
|
+
const { text, toolCalls, usage, finishReason, reasoningContent, events } = await accumulateGeminiStream(chunkStream, {
|
|
19944
|
+
onTextDelta: args2.onTextDelta,
|
|
19945
|
+
onReasoningDelta: args2.onReasoningDelta
|
|
19946
|
+
});
|
|
19947
|
+
const normalized = normalizeAntigravityCompletion({
|
|
19948
|
+
text,
|
|
19949
|
+
toolCalls,
|
|
19950
|
+
usage,
|
|
19951
|
+
finishReason,
|
|
19952
|
+
reasoningContent,
|
|
19953
|
+
events
|
|
19954
|
+
});
|
|
19955
|
+
if (normalized.status !== 200 || !text && toolCalls.length === 0) {
|
|
19956
|
+
console.warn(
|
|
19957
|
+
`[antigravity] empty completion: finishReason=${JSON.stringify(finishReason)} reasoningLen=${reasoningContent?.length ?? 0} usage=${JSON.stringify(usage) ?? "none"} model=${String(envelope.model)} base=${new URL(url).host}`
|
|
19958
|
+
);
|
|
19959
|
+
}
|
|
19960
|
+
return normalized;
|
|
19961
|
+
}
|
|
19962
|
+
|
|
19019
19963
|
export {
|
|
19964
|
+
Option_exports,
|
|
19965
|
+
Duration_exports,
|
|
19966
|
+
Exit_exports,
|
|
19967
|
+
Effect_exports,
|
|
19020
19968
|
readCommandActionGatePayload,
|
|
19021
19969
|
readActionGate,
|
|
19022
19970
|
evaluateFileWritePolicy,
|
|
@@ -19049,11 +19997,19 @@ export {
|
|
|
19049
19997
|
buildLocalWorkspaceToolset,
|
|
19050
19998
|
buildLocalWorkspacePolicyToolNames,
|
|
19051
19999
|
buildLocalWorkspaceOpenAiTools,
|
|
20000
|
+
PATH_FIELD_ALIASES,
|
|
19052
20001
|
internalSearchWorkspace,
|
|
19053
20002
|
internalListWorkspaceEntries,
|
|
19054
20003
|
createLocalWorkspaceToolExecutors,
|
|
19055
20004
|
localDialogMessageRecordToRuntimeMessage,
|
|
19056
20005
|
buildLocalDialogWritePlan,
|
|
19057
20006
|
buildNoloWorkspaceCliToolExecutors,
|
|
19058
|
-
buildLoadSkillExecutor
|
|
20007
|
+
buildLoadSkillExecutor,
|
|
20008
|
+
parseUpstreamErrorBody,
|
|
20009
|
+
isGemini3Model,
|
|
20010
|
+
accumulateGeminiChunks,
|
|
20011
|
+
shouldUseGeminiNativeToolRoute,
|
|
20012
|
+
buildGeminiGenerateContentRequest,
|
|
20013
|
+
resolveAntigravityFinishReason,
|
|
20014
|
+
fetchAntigravityCloudCodeCompletion
|
|
19059
20015
|
};
|