nolo-cli 0.77.0-alpha.1 → 0.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{_executeModel-MONX3AUM.js → _executeModel-G6BRN2BO.js} +43 -43
- package/{action-D22U6CTH.js → action-7GHFPDSQ.js} +10 -10
- package/{addContentAction-XAPUTGL4.js → addContentAction-ZNVB2NOV.js} +8 -8
- package/{addDialogAgentAction-M7VLLBZM.js → addDialogAgentAction-CIDFWATM.js} +7 -7
- package/{agentDeleteCommand-2TYFURBN.js → agentDeleteCommand-C5JTDBIX.js} +28 -26
- package/{agentEmailCommands-HXIX4KJE.js → agentEmailCommands-AYSYNUSH.js} +56 -54
- package/{agentListCommands-IFUOWXP3.js → agentListCommands-CVFL3P3D.js} +30 -28
- package/{agentMachineCommands-NEJEQV5S.js → agentMachineCommands-2EPX7IYC.js} +28 -26
- package/{agentProviderCommands-65ZC2WB4.js → agentProviderCommands-EHR3PV2V.js} +87 -0
- package/{agentPullCommand-N7L2CT7L.js → agentPullCommand-U73W5IBM.js} +1 -1
- package/{agentRecordCommands-USSLZKED.js → agentRecordCommands-DPZVHOOA.js} +54 -52
- package/{agentRunCommand-WZZSCEEP.js → agentRunCommand-BE53VNNN.js} +54 -52
- package/{agentRuntimeLocal-PUZINLWJ.js → agentRuntimeLocal-BPN5IOFT.js} +27 -25
- package/{agentSlice-BLCUNM5V.js → agentSlice-PYJFXGZL.js} +9 -9
- package/{appDeleteCommands-U4NTEJYQ.js → appDeleteCommands-TREMNXCA.js} +28 -26
- package/{appDeployCommands-FXF45Q7F.js → appDeployCommands-7FYCMERT.js} +28 -26
- package/{appDeployStatusCommands-KONVRM53.js → appDeployStatusCommands-7LAYH7IX.js} +28 -26
- package/{appGetCommands-3VOGIZ7T.js → appGetCommands-BONTQ2XH.js} +28 -26
- package/{appListCommands-A6ROBW7P.js → appListCommands-BYIELWUL.js} +28 -26
- package/{authCommand-EVGFLAHO.js → authCommand-J5C7GS33.js} +92 -17
- package/{authCommands-ILTBI6JV.js → authCommands-VOTT6XWX.js} +3 -4
- package/builtinSkillRegistry-YITVDLWG.js +33 -0
- package/{chatQueueReduxAdapter-ROFM5SW7.js → chatQueueReduxAdapter-PIOXZBGH.js} +23 -23
- package/{chunk-EXMHJN7C.js → chunk-2F4VYGFW.js} +2 -2
- package/{chunk-C3FZR5EC.js → chunk-2F7RJC6L.js} +1 -1
- package/{chunk-3QPYFHAH.js → chunk-2XEVK4BT.js} +1 -1
- package/{chunk-HQUORJTM.js → chunk-3BMYXEUW.js} +1 -1
- package/{chunk-AFIWC5NH.js → chunk-3DZIWHJ6.js} +1 -1
- package/{chunk-L2Y24GRM.js → chunk-4PAFEM6V.js} +3 -3
- package/{chunk-ERD7UXVL.js → chunk-5DAMTON3.js} +1 -1
- package/{chunk-YFADVSZE.js → chunk-5EJZGJS2.js} +6 -6
- package/chunk-5ZUL4CUO.js +10 -0
- package/{chunk-KIS76A2P.js → chunk-6HCLDVEI.js} +38 -4
- package/{chunk-FPTQQSS6.js → chunk-6LWO3QQS.js} +25 -4
- package/{chunk-BYEJ7K2Z.js → chunk-7S4YWN7P.js} +1 -1
- package/{chunk-2SFNAHL6.js → chunk-7TEU3WX2.js} +41 -25
- package/{chunk-SREASRV5.js → chunk-ABQYVJBJ.js} +1 -1
- package/{chunk-N7DNNV6J.js → chunk-ACFF7U3F.js} +340 -76
- package/{chunk-AFIKMMGC.js → chunk-AGX5TE5W.js} +1 -1
- package/{chunk-AJHEFRGJ.js → chunk-ASGDO77C.js} +122 -1
- package/{chunk-ZDONXM5U.js → chunk-D4TJCP3V.js} +7 -7
- package/{chunk-PYXL2CJL.js → chunk-DNQPPRHY.js} +1 -1
- package/{chunk-QH6NK22I.js → chunk-DQD4PYQY.js} +60 -788
- package/{chunk-PI4DWFYV.js → chunk-FSISQCCB.js} +1132 -31
- package/{chunk-3SPWIDHH.js → chunk-FWGPT6VI.js} +3 -3
- package/{chunk-SZLVDREM.js → chunk-GIG262ZG.js} +3 -3
- package/{chunk-PZM3EENV.js → chunk-GXWEF4IZ.js} +1 -1
- package/chunk-HJKGQPYF.js +266 -0
- package/{chunk-QA6YKM3H.js → chunk-HLRYI5XO.js} +31 -3
- package/{chunk-3JQ2NRYU.js → chunk-HVURBGF3.js} +4 -4
- package/{chunk-UPQF3C7O.js → chunk-IEILL33V.js} +135 -56
- package/{chunk-UZ6XXCVR.js → chunk-IZAWJCG7.js} +15 -2
- package/{chunk-XWNRAIUL.js → chunk-JITSBA52.js} +6 -16
- package/{chunk-6XIE5ZGI.js → chunk-JPGCXHNM.js} +1 -1
- package/{chunk-BGIWMGSP.js → chunk-JRFQPOPS.js} +10 -172
- package/chunk-JT7FRJP5.js +1625 -0
- package/{chunk-CMH2SYHX.js → chunk-K7M3MWCE.js} +2 -2
- package/{chunk-E36HZARC.js → chunk-KT6LENVP.js} +3 -3
- package/{chunk-FSFQ3A7S.js → chunk-LGSXBNWH.js} +9 -9
- package/{chunk-RXX4GDIH.js → chunk-LS2ZANRJ.js} +1 -1
- package/{chunk-4EJ5QYB5.js → chunk-LSV2BOJL.js} +1 -1
- package/{chunk-EVBFYPDC.js → chunk-MC4XLIJ7.js} +6 -2
- package/{chunk-PGSKWZCB.js → chunk-MJHQ3NRV.js} +1 -1
- package/{chunk-G3O3PD6Q.js → chunk-MRT4KARW.js} +14 -14
- package/{chunk-K7AG465Q.js → chunk-ND2J3NRB.js} +4 -2
- package/{chunk-Q6FF2MCK.js → chunk-OAJRZ35U.js} +1 -1
- package/{chunk-5J7W2VWW.js → chunk-OHUU52T3.js} +6 -265
- package/{chunk-V3ZKNK5D.js → chunk-OKCTLCKS.js} +9 -9
- package/{chunk-2R5EVB2O.js → chunk-PGO7O65Q.js} +5 -5
- package/{chunk-ZZCJUXUI.js → chunk-PHDKTASK.js} +2 -2
- package/{chunk-AETZ7AD6.js → chunk-Q554LLSI.js} +1 -1
- package/chunk-Q5FJJ6XI.js +103 -0
- package/{chunk-RILY7TKG.js → chunk-RHB6OCZS.js} +9 -9
- package/chunk-RJ3TDODF.js +665 -0
- package/{chunk-QC5LGHYP.js → chunk-TIJK4PBP.js} +10 -5
- package/{chunk-CGRJWXTE.js → chunk-UDK3ZSMN.js} +19 -15
- package/{chunk-E6RGHPDR.js → chunk-UINEAQ2R.js} +3 -5
- package/{chunk-DWPNOYMB.js → chunk-UQ45IHLM.js} +1 -1
- package/{chunk-ZY4K4CZR.js → chunk-UQYEVBMM.js} +684 -96
- package/{chunk-BJCWNHVU.js → chunk-US463UAD.js} +2 -2
- package/{chunk-ZLPA7K55.js → chunk-UUVQJZ75.js} +28 -9
- package/{chunk-DSRXPQWA.js → chunk-VEJ4BOQV.js} +43 -43
- package/{chunk-NHRQCXIQ.js → chunk-VMFTFOWF.js} +13 -3
- package/{chunk-UJ63UXGE.js → chunk-VRLI2WNW.js} +1073 -752
- package/{chunk-NG4UT4K4.js → chunk-WS22FPWT.js} +1 -1
- package/{chunk-MYU3MJCF.js → chunk-XCSSFPTB.js} +175 -7
- package/{chunk-MQ25G6VQ.js → chunk-XIYOAH3S.js} +3 -3
- package/{chunk-UDQWGU7F.js → chunk-YZHP76TR.js} +1 -1
- package/{chunk-GBPZKFYK.js → chunk-Z33ARZCP.js} +4 -4
- package/{contentThunks-3BFZJFHI.js → contentThunks-RYZTYVUV.js} +24 -24
- package/{createAgentAutomationAction-YCWUKLMK.js → createAgentAutomationAction-GUBB2LWY.js} +24 -24
- package/{createDialogAction-VULS2PKA.js → createDialogAction-577E6FB2.js} +27 -27
- package/{createPageAction-MZZLQPFE.js → createPageAction-4CNYIRJ5.js} +25 -25
- package/{dbSlice-GKGGFNOB.js → dbSlice-4CUQE35F.js} +7 -7
- package/{deleteFile-LWSR674W.js → deleteFile-YG6QMJLU.js} +3 -3
- package/{dialogCommands-G223U5WU.js → dialogCommands-U4RQIRKK.js} +29 -27
- package/{dialogSlice-NQO5ZETL.js → dialogSlice-YXMORK5T.js} +23 -23
- package/{docCreateCommands-2P47IJDK.js → docCreateCommands-AXXATGCL.js} +29 -27
- package/{docDeleteCommands-N3EGDOIC.js → docDeleteCommands-CRPIFYFA.js} +30 -28
- package/{docReadCommands-6BFV2HI7.js → docReadCommands-4IMZXFDR.js} +29 -27
- package/{docStore-AEJONTM4.js → docStore-3U5FBN2O.js} +8 -8
- package/{docUpdateCommands-ZTMPXHC5.js → docUpdateCommands-RRPRZXCE.js} +29 -27
- package/{fetchMessages-DRABNDPZ.js → fetchMessages-EIU7UFFK.js} +3 -4
- package/{getPricing-HRMSOF3E.js → getPricing-F2C65RIX.js} +4 -4
- package/{handleSendMessageAction-WIUO466V.js → handleSendMessageAction-BQIRKHC6.js} +23 -23
- package/index.js +61 -53
- package/{localDialogRead-PUQKFI73.js → localDialogRead-BTFJ4V2I.js} +2 -2
- package/{localRuntimeDb-P37ZTX55.js → localRuntimeDb-SYQGUF4U.js} +1 -1
- package/{machineCommands-FUA7HBND.js → machineCommands-RNBADNTE.js} +54 -52
- package/{machineWsRunDispatch-URIG5N2V.js → machineWsRunDispatch-7J6WNF57.js} +52 -50
- package/{memberThunks-KATHH3F4.js → memberThunks-N35XAOC6.js} +8 -8
- package/{models-GS72DVJS.js → models-WW7VFNXB.js} +2 -2
- package/package.json +1 -1
- package/providerPresetApply-SAJAK7C3.js +214 -0
- package/providerRegistry-COD57OVY.js +31 -0
- package/{read-LC6HVYBN.js → read-2PV4PN2E.js} +4 -3
- package/{readDocTool-N3ERJHHF.js → readDocTool-FGK5XGAW.js} +1 -1
- package/{readlineWorkspace-HVQLD7T3.js → readlineWorkspace-ZO2W3N4U.js} +135 -75
- package/{removeDialogAgentAction-F5GPTALR.js → removeDialogAgentAction-O2POGBOE.js} +10 -10
- package/{runAgentClientLoop-QHL2HNAI.js → runAgentClientLoop-KJZ7DK6D.js} +42 -42
- package/{runtimeDoctorCommands-CROTMULY.js → runtimeDoctorCommands-X6WDBEQX.js} +2 -2
- package/{setDialogExtraReferencesAction-AY4ZCF3A.js → setDialogExtraReferencesAction-KPSVVY3C.js} +8 -8
- package/{setPrimaryDialogAgentAction-HPMG7V3R.js → setPrimaryDialogAgentAction-RMJETONI.js} +10 -10
- package/{settingSlice-OEJA4NQO.js → settingSlice-I6MTTNDX.js} +9 -9
- package/{spaceCommands-MRP5U3C3.js → spaceCommands-VZRYKVWZ.js} +27 -25
- package/{streamAgentChatTurn-CE2H23VD.js → streamAgentChatTurn-L3SO4N2R.js} +54 -53
- package/{switchDialogAgentAction-HMDZTZ4I.js → switchDialogAgentAction-OQSGWVQQ.js} +7 -7
- package/{tools-F25QG6XS.js → tools-GRV74JPO.js} +38 -36
- package/tuiSummaryLlmCaller-ATDKMGI5.js +127 -0
- package/{updateDialogTitleAction-Z333XUN4.js → updateDialogTitleAction-KRUWX66L.js} +44 -27
- package/chunk-3IT2PFHL.js +0 -611
- package/chunk-I42VC5KR.js +0 -15
- package/codingSkills-E6KSDNSJ.js +0 -48
- package/tuiSummaryLlmCaller-3Z24VUWM.js +0 -116
- package/{chunk-3RAG2NAD.js → chunk-UKWGR5SS.js} +3 -3
- package/{db-VQSAOWAO.js → db-WK5MDZVN.js} +1 -1
- package/{localRuntimeAuthority-R5UBODT3.js → localRuntimeAuthority-6IR6BBXE.js} +3 -3
|
@@ -8,15 +8,19 @@ import {
|
|
|
8
8
|
readSseFrames,
|
|
9
9
|
streamSseDataValues,
|
|
10
10
|
throwIfChatCompletionStreamFailed
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-TIJK4PBP.js";
|
|
12
|
+
import {
|
|
13
|
+
DEVIN_CONNECT_URL
|
|
14
|
+
} from "./chunk-Q5FJJ6XI.js";
|
|
12
15
|
import {
|
|
13
16
|
clipToolText,
|
|
14
17
|
hasImageInRuntimeMessages,
|
|
18
|
+
resolveAgentContextWindow,
|
|
15
19
|
resolveAgentImageInputSupport,
|
|
16
20
|
resolveHistoricalToolContentCap,
|
|
17
21
|
resolveToolOutputProfile,
|
|
18
22
|
stripImagePartsFromMessages
|
|
19
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-6HCLDVEI.js";
|
|
20
24
|
import {
|
|
21
25
|
downgradeUnparsableToolCalls,
|
|
22
26
|
hasParsableObjectArguments,
|
|
@@ -40,7 +44,7 @@ import {
|
|
|
40
44
|
requiresBareImageUrl,
|
|
41
45
|
resolveToolGuidedSections,
|
|
42
46
|
toBareImageUrlMessages
|
|
43
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-UUVQJZ75.js";
|
|
44
48
|
import {
|
|
45
49
|
convertMessagesToResponsesInput,
|
|
46
50
|
extractReasoningFromResponseOutput,
|
|
@@ -51,15 +55,6 @@ import {
|
|
|
51
55
|
toOpenAiCompatibleMessages,
|
|
52
56
|
toResponsesTools
|
|
53
57
|
} from "./chunk-PUOC4YRO.js";
|
|
54
|
-
import {
|
|
55
|
-
getAntigravityUserAgent,
|
|
56
|
-
readAntigravityProjectId,
|
|
57
|
-
resolveAntigravityCloudCodeBaseUrl
|
|
58
|
-
} from "./chunk-PGSKWZCB.js";
|
|
59
|
-
import {
|
|
60
|
-
buildProviderAuthHeaders,
|
|
61
|
-
buildProviderExecutionPlan
|
|
62
|
-
} from "./chunk-CMH2SYHX.js";
|
|
63
58
|
import {
|
|
64
59
|
BRIDGE_STREAM_MAX_CHARS,
|
|
65
60
|
DEFAULT_READ_DIALOG_MAX_RESPONSE_CHARS,
|
|
@@ -73,7 +68,16 @@ import {
|
|
|
73
68
|
parseNoloWorkspaceToolArguments,
|
|
74
69
|
readTextStreamUpToChars,
|
|
75
70
|
resolveNoloDialogInput
|
|
76
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-OKCTLCKS.js";
|
|
72
|
+
import {
|
|
73
|
+
getAntigravityUserAgent,
|
|
74
|
+
readAntigravityProjectId,
|
|
75
|
+
resolveAntigravityCloudCodeBaseUrl
|
|
76
|
+
} from "./chunk-MJHQ3NRV.js";
|
|
77
|
+
import {
|
|
78
|
+
buildProviderAuthHeaders,
|
|
79
|
+
buildProviderExecutionPlan
|
|
80
|
+
} from "./chunk-K7M3MWCE.js";
|
|
77
81
|
import {
|
|
78
82
|
buildDialogFallbackTitleFromUserInput
|
|
79
83
|
} from "./chunk-2MBTWINN.js";
|
|
@@ -87,7 +91,7 @@ import {
|
|
|
87
91
|
resolveEmptyAssistantFallbackMessage,
|
|
88
92
|
resolveEmptyAssistantOutcome,
|
|
89
93
|
resolveTruncatedReasoningTailLog
|
|
90
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-VEJ4BOQV.js";
|
|
91
95
|
import {
|
|
92
96
|
COMPACTION_SUMMARY_SCHEMA_VERSION,
|
|
93
97
|
COMPACTION_SUMMARY_SYSTEM_PROMPT,
|
|
@@ -106,7 +110,7 @@ import {
|
|
|
106
110
|
resolveCompressionTriggerRatio,
|
|
107
111
|
truncateToolOutputForContext,
|
|
108
112
|
withProviderCallTimingFields
|
|
109
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-KT6LENVP.js";
|
|
110
114
|
import {
|
|
111
115
|
estimateTokenCount
|
|
112
116
|
} from "./chunk-PSCNXBYA.js";
|
|
@@ -130,27 +134,25 @@ import {
|
|
|
130
134
|
asRecordOrEmpty
|
|
131
135
|
} from "./chunk-KX6YBIHG.js";
|
|
132
136
|
import {
|
|
137
|
+
asTrimmedNonEmptyStringArray,
|
|
133
138
|
dialogMessageKey,
|
|
134
139
|
dialogMessageRange
|
|
135
|
-
} from "./chunk-
|
|
140
|
+
} from "./chunk-VMFTFOWF.js";
|
|
136
141
|
import {
|
|
137
142
|
asOptionalFiniteNumber
|
|
138
143
|
} from "./chunk-WWC7I6TA.js";
|
|
139
|
-
import {
|
|
140
|
-
asTrimmedNonEmptyStringArray
|
|
141
|
-
} from "./chunk-I42VC5KR.js";
|
|
142
144
|
import {
|
|
143
145
|
asTrimmedLowercaseString
|
|
144
146
|
} from "./chunk-QSJ3HFEF.js";
|
|
147
|
+
import {
|
|
148
|
+
isRecord
|
|
149
|
+
} from "./chunk-KUG52IAP.js";
|
|
145
150
|
import {
|
|
146
151
|
asTrimmedString
|
|
147
152
|
} from "./chunk-3EUW3WEO.js";
|
|
148
153
|
import {
|
|
149
154
|
asOptionalPositiveFiniteNumber
|
|
150
155
|
} from "./chunk-U6VC4MU4.js";
|
|
151
|
-
import {
|
|
152
|
-
isRecord
|
|
153
|
-
} from "./chunk-KUG52IAP.js";
|
|
154
156
|
import {
|
|
155
157
|
normalizeServerOrigin
|
|
156
158
|
} from "./chunk-CF7PE763.js";
|
|
@@ -12201,7 +12203,7 @@ function summarizeToolArguments(toolName, rawArgs) {
|
|
|
12201
12203
|
}
|
|
12202
12204
|
|
|
12203
12205
|
// packages/agent-runtime/leafFinalHandoff.ts
|
|
12204
|
-
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.`;
|
|
12206
|
+
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. During execution, follow the brief as given: only when new evidence would materially change the goal, risk, irreversibility, or DoD should you surface it as a blocker/finding in the handoff \u2014 do not silently expand scope or re-litigate the settled direction.`;
|
|
12205
12207
|
|
|
12206
12208
|
// packages/agent-runtime/contextBlockScope.ts
|
|
12207
12209
|
var isContextBlockScope = (value) => {
|
|
@@ -13046,10 +13048,10 @@ var TOOL_METADATA_KEYS = [
|
|
|
13046
13048
|
"pasteId",
|
|
13047
13049
|
"source"
|
|
13048
13050
|
];
|
|
13049
|
-
function trimHistoryToContextBudget(history, model) {
|
|
13051
|
+
function trimHistoryToContextBudget(history, model, contextWindowOverride) {
|
|
13050
13052
|
if (history.length === 0) return { history, droppedCount: 0 };
|
|
13051
13053
|
const { rawMessageBudget } = planContextUsage({
|
|
13052
|
-
contextWindow: getModelContextWindow(model ?? ""),
|
|
13054
|
+
contextWindow: contextWindowOverride ?? getModelContextWindow(model ?? ""),
|
|
13053
13055
|
summaryTokens: 0,
|
|
13054
13056
|
// localLoop 没有 web 端的负载分档器;medium 是中性默认值,
|
|
13055
13057
|
// 不为了省几个 token 在这里复制一份分类逻辑。
|
|
@@ -13540,7 +13542,7 @@ async function runLocalAgentTurn(input) {
|
|
|
13540
13542
|
}
|
|
13541
13543
|
return resolvedProvider;
|
|
13542
13544
|
};
|
|
13543
|
-
const contextWindow =
|
|
13545
|
+
const contextWindow = resolveAgentContextWindow(agentConfig);
|
|
13544
13546
|
const compressionTriggerRatio = resolveCompressionTriggerRatio(contextWindow);
|
|
13545
13547
|
let realContextUsagePercent;
|
|
13546
13548
|
if (input.continueDialogId && typeof input.adapter.loadLastContextUsage === "function") {
|
|
@@ -13582,6 +13584,7 @@ async function runLocalAgentTurn(input) {
|
|
|
13582
13584
|
history,
|
|
13583
13585
|
model: agentConfig.model,
|
|
13584
13586
|
resolveProvider: resolveProviderOnce,
|
|
13587
|
+
contextWindow,
|
|
13585
13588
|
realContextUsagePercent
|
|
13586
13589
|
});
|
|
13587
13590
|
history = compacted.history;
|
|
@@ -13591,7 +13594,7 @@ async function runLocalAgentTurn(input) {
|
|
|
13591
13594
|
console.warn("[localLoop] auto-compaction unexpected error:", error);
|
|
13592
13595
|
}
|
|
13593
13596
|
loopTimingMark("maybeAutoCompactLocalHistory", 0);
|
|
13594
|
-
const trimmedHistory = trimHistoryToContextBudget(history, agentConfig.model);
|
|
13597
|
+
const trimmedHistory = trimHistoryToContextBudget(history, agentConfig.model, contextWindow);
|
|
13595
13598
|
if (trimmedHistory.droppedCount > 0) {
|
|
13596
13599
|
history = trimmedHistory.history;
|
|
13597
13600
|
}
|
|
@@ -13678,6 +13681,7 @@ async function runLocalAgentTurn(input) {
|
|
|
13678
13681
|
],
|
|
13679
13682
|
model: agentConfig.model,
|
|
13680
13683
|
resolveProvider: resolveProviderOnce,
|
|
13684
|
+
contextWindow,
|
|
13681
13685
|
realContextUsagePercent: ratio
|
|
13682
13686
|
});
|
|
13683
13687
|
if (compacted.usage) {
|
|
@@ -15568,13 +15572,13 @@ var DEFAULT_LOCAL_TOOLS = /* @__PURE__ */ new Set([
|
|
|
15568
15572
|
"execShell",
|
|
15569
15573
|
"launchProcess",
|
|
15570
15574
|
"listProcesses",
|
|
15571
|
-
// ProcessTask follow-up tools
|
|
15572
|
-
//
|
|
15573
|
-
//
|
|
15575
|
+
// ProcessTask follow-up tools. Same tier as listProcesses: they observe/stop
|
|
15576
|
+
// tasks the agent itself already spawned, so their blast radius is strictly
|
|
15577
|
+
// narrower than launchProcess (which is default-enabled). Model-facing
|
|
15578
|
+
// follow-ups are taskWait/taskStop only — lifecycle history (taskLogs) stays
|
|
15579
|
+
// runtime-internal.
|
|
15574
15580
|
"taskWait",
|
|
15575
|
-
"taskLogs",
|
|
15576
15581
|
"taskStop",
|
|
15577
|
-
"tasks",
|
|
15578
15582
|
// Scheduling tools: forking/observing sub-agents is a declared capability
|
|
15579
15583
|
// of capable agents, and the blast radius is strictly narrower than
|
|
15580
15584
|
// execShell (already default-enabled). Requiring an env allowlist for these
|
|
@@ -16210,6 +16214,24 @@ var ProcessTaskEventLog = class {
|
|
|
16210
16214
|
};
|
|
16211
16215
|
|
|
16212
16216
|
// packages/agent-runtime/processRegistry.ts
|
|
16217
|
+
function toProcessTaskView(record) {
|
|
16218
|
+
const capsule = record.resultCapsule;
|
|
16219
|
+
return {
|
|
16220
|
+
taskId: record.taskId,
|
|
16221
|
+
pid: record.pid,
|
|
16222
|
+
pgid: record.pgid,
|
|
16223
|
+
command: record.command,
|
|
16224
|
+
label: record.label,
|
|
16225
|
+
startedAt: record.startedAt,
|
|
16226
|
+
status: record.status,
|
|
16227
|
+
...record.exitCode !== void 0 ? { exitCode: record.exitCode } : {},
|
|
16228
|
+
persist: record.persist,
|
|
16229
|
+
promoted: record.promoted,
|
|
16230
|
+
transient: record.transient,
|
|
16231
|
+
...capsule?.durationMs !== void 0 ? { durationMs: capsule.durationMs } : {},
|
|
16232
|
+
...capsule?.spill ? { outputRef: capsule.spill.displayPath } : {}
|
|
16233
|
+
};
|
|
16234
|
+
}
|
|
16213
16235
|
var taskIdCounter = 0;
|
|
16214
16236
|
function mintTaskId(pid) {
|
|
16215
16237
|
taskIdCounter += 1;
|
|
@@ -16265,7 +16287,7 @@ var ProcessRegistry = class {
|
|
|
16265
16287
|
startedAt: Date.now(),
|
|
16266
16288
|
status: "running",
|
|
16267
16289
|
persist: proc.persist ?? false,
|
|
16268
|
-
promoted: false,
|
|
16290
|
+
promoted: proc.promoted ?? false,
|
|
16269
16291
|
transient: proc.transient ?? false,
|
|
16270
16292
|
owner: proc.owner ?? null
|
|
16271
16293
|
};
|
|
@@ -16362,7 +16384,8 @@ var ProcessRegistry = class {
|
|
|
16362
16384
|
pid,
|
|
16363
16385
|
label: item.label,
|
|
16364
16386
|
command: item.command,
|
|
16365
|
-
status: "stopped"
|
|
16387
|
+
status: "stopped",
|
|
16388
|
+
promoted: item.promoted
|
|
16366
16389
|
});
|
|
16367
16390
|
return true;
|
|
16368
16391
|
}
|
|
@@ -16391,15 +16414,17 @@ var ProcessRegistry = class {
|
|
|
16391
16414
|
pid: item.pid,
|
|
16392
16415
|
label: item.label,
|
|
16393
16416
|
command: item.command,
|
|
16394
|
-
status: "stopped"
|
|
16417
|
+
status: "stopped",
|
|
16418
|
+
promoted: item.promoted
|
|
16395
16419
|
});
|
|
16396
16420
|
}
|
|
16397
16421
|
}
|
|
16398
16422
|
}
|
|
16399
|
-
markExited(pid, exitCode) {
|
|
16423
|
+
markExited(pid, exitCode, resultCapsule) {
|
|
16400
16424
|
const item = this.processes.get(pid);
|
|
16401
16425
|
if (item && item.status === "running") {
|
|
16402
16426
|
item.exitCode = exitCode;
|
|
16427
|
+
if (resultCapsule) item.resultCapsule = resultCapsule;
|
|
16403
16428
|
item.status = exitCode === 0 ? "exited" : "failed";
|
|
16404
16429
|
this.eventLog.append({
|
|
16405
16430
|
taskId: item.taskId,
|
|
@@ -16413,7 +16438,9 @@ var ProcessRegistry = class {
|
|
|
16413
16438
|
label: item.label,
|
|
16414
16439
|
command: item.command,
|
|
16415
16440
|
status: item.status,
|
|
16416
|
-
exitCode
|
|
16441
|
+
exitCode,
|
|
16442
|
+
promoted: item.promoted,
|
|
16443
|
+
...item.resultCapsule ? { resultCapsule: item.resultCapsule } : {}
|
|
16417
16444
|
});
|
|
16418
16445
|
}
|
|
16419
16446
|
}
|
|
@@ -16476,6 +16503,62 @@ function readProcessOwner(runtimeContext) {
|
|
|
16476
16503
|
// packages/agent-runtime/workspaceShell.ts
|
|
16477
16504
|
import { resolve as resolve3 } from "node:path";
|
|
16478
16505
|
import { spawn as spawnChildProcess2 } from "node:child_process";
|
|
16506
|
+
|
|
16507
|
+
// packages/agent-runtime/processTaskResult.ts
|
|
16508
|
+
var PROCESS_RESULT_CAPSULE_TAIL_CHARS = 4e3;
|
|
16509
|
+
var PROCESS_RESULT_CAPSULE_SPILL_THRESHOLD_CHARS = 2e4;
|
|
16510
|
+
function tailText(value, maxChars) {
|
|
16511
|
+
if (value.length <= maxChars) return { text: value, truncated: false };
|
|
16512
|
+
return { text: value.slice(-maxChars), truncated: true };
|
|
16513
|
+
}
|
|
16514
|
+
function formatCapsuleStream(name, value) {
|
|
16515
|
+
return value.trim() ? `${name}:
|
|
16516
|
+
${value.replace(/\n+$/, "")}` : "";
|
|
16517
|
+
}
|
|
16518
|
+
function buildProcessTaskResultCapsule(args2) {
|
|
16519
|
+
const tailChars = args2.tailChars ?? PROCESS_RESULT_CAPSULE_TAIL_CHARS;
|
|
16520
|
+
const spillThresholdChars = args2.spillThresholdChars ?? PROCESS_RESULT_CAPSULE_SPILL_THRESHOLD_CHARS;
|
|
16521
|
+
const stdout = typeof args2.stdout === "string" ? args2.stdout : "";
|
|
16522
|
+
const stderr = typeof args2.stderr === "string" ? args2.stderr : "";
|
|
16523
|
+
const exitCode = args2.exitCode;
|
|
16524
|
+
const captureError = args2.captureError?.trim() || void 0;
|
|
16525
|
+
const durationMs = typeof args2.startedAt === "number" && Number.isFinite(args2.startedAt) ? Math.max(0, (args2.endedAt ?? Date.now()) - args2.startedAt) : void 0;
|
|
16526
|
+
const stdoutTail = tailText(stdout, tailChars);
|
|
16527
|
+
const stderrTail = tailText(stderr, tailChars);
|
|
16528
|
+
const inlineSize = stdout.length + stderr.length;
|
|
16529
|
+
const inlineTruncated = stdoutTail.truncated || stderrTail.truncated;
|
|
16530
|
+
const shouldSpill = inlineTruncated || inlineSize > spillThresholdChars;
|
|
16531
|
+
let spill;
|
|
16532
|
+
if (shouldSpill) {
|
|
16533
|
+
try {
|
|
16534
|
+
const result4 = spillToolOutput({
|
|
16535
|
+
content: [
|
|
16536
|
+
formatCapsuleStream("stdout", stdout),
|
|
16537
|
+
formatCapsuleStream("stderr", stderr)
|
|
16538
|
+
].filter(Boolean).join("\n\n"),
|
|
16539
|
+
toolName: "execShell",
|
|
16540
|
+
...args2.workspaceRoot !== void 0 ? { workspaceRoot: args2.workspaceRoot } : {}
|
|
16541
|
+
});
|
|
16542
|
+
spill = {
|
|
16543
|
+
displayPath: result4.displayPath,
|
|
16544
|
+
totalChars: result4.totalChars,
|
|
16545
|
+
totalLines: result4.totalLines
|
|
16546
|
+
};
|
|
16547
|
+
} catch {
|
|
16548
|
+
}
|
|
16549
|
+
}
|
|
16550
|
+
return {
|
|
16551
|
+
stdout: stdoutTail.text,
|
|
16552
|
+
stderr: stderrTail.text,
|
|
16553
|
+
exitCode,
|
|
16554
|
+
...durationMs !== void 0 ? { durationMs } : {},
|
|
16555
|
+
...captureError ? { captureError } : {},
|
|
16556
|
+
truncated: inlineTruncated || Boolean(captureError),
|
|
16557
|
+
...spill ? { spill } : {}
|
|
16558
|
+
};
|
|
16559
|
+
}
|
|
16560
|
+
|
|
16561
|
+
// packages/agent-runtime/workspaceShell.ts
|
|
16479
16562
|
var EXEC_SHELL_TIMEOUT_ENV = "NOLO_EXEC_SHELL_TIMEOUT_MS";
|
|
16480
16563
|
var EXEC_SHELL_DETACH_ENV = "NOLO_EXEC_SHELL_DETACH_MS";
|
|
16481
16564
|
var DEFAULT_EXEC_SHELL_DETACH_MS = 12e4;
|
|
@@ -16855,6 +16938,15 @@ ${stderr.trim()}`, "exitCode: 127"].filter(Boolean).join("\n\n"),
|
|
|
16855
16938
|
)
|
|
16856
16939
|
};
|
|
16857
16940
|
}
|
|
16941
|
+
function stdoutPromiseResult(promise3) {
|
|
16942
|
+
return promise3.then(
|
|
16943
|
+
(value) => ({ value }),
|
|
16944
|
+
(error) => ({
|
|
16945
|
+
value: "",
|
|
16946
|
+
error: error instanceof Error ? error.message : String(error)
|
|
16947
|
+
})
|
|
16948
|
+
);
|
|
16949
|
+
}
|
|
16858
16950
|
async function runWorkspaceCommand(args2) {
|
|
16859
16951
|
const timeoutMs = asOptionalPositiveFiniteNumber(args2.timeoutMs);
|
|
16860
16952
|
const detached = process.platform !== "win32";
|
|
@@ -16913,8 +17005,8 @@ async function runWorkspaceCommand(args2) {
|
|
|
16913
17005
|
process.removeListener("SIGINT", cleanupChildOnHostSignal);
|
|
16914
17006
|
};
|
|
16915
17007
|
exitPromise.then(detachSignalCleanup, detachSignalCleanup);
|
|
16916
|
-
const
|
|
16917
|
-
const
|
|
17008
|
+
const stdoutCapture = stdoutPromiseResult(readNodeStream(proc.stdout));
|
|
17009
|
+
const stderrCapture = stdoutPromiseResult(readNodeStream(proc.stderr));
|
|
16918
17010
|
const killChild = (signal) => {
|
|
16919
17011
|
if (detached && typeof proc.pid === "number") {
|
|
16920
17012
|
try {
|
|
@@ -17007,12 +17099,36 @@ async function runWorkspaceCommand(args2) {
|
|
|
17007
17099
|
pgid,
|
|
17008
17100
|
command: args2.command.join(" "),
|
|
17009
17101
|
label,
|
|
17102
|
+
promoted: true,
|
|
17010
17103
|
owner: args2.owner ?? null
|
|
17011
17104
|
});
|
|
17012
17105
|
const taskId = envelope.taskId;
|
|
17013
17106
|
proc.on("close", (code) => {
|
|
17014
17107
|
detachSignalCleanup();
|
|
17015
|
-
|
|
17108
|
+
const exitCode2 = code ?? 1;
|
|
17109
|
+
void (async () => {
|
|
17110
|
+
const [stdoutResult, stderrResult] = await Promise.all([
|
|
17111
|
+
stdoutCapture,
|
|
17112
|
+
stderrCapture
|
|
17113
|
+
]);
|
|
17114
|
+
const stdout2 = stdoutResult.value;
|
|
17115
|
+
const stderr2 = stderrResult.value;
|
|
17116
|
+
let capsule;
|
|
17117
|
+
try {
|
|
17118
|
+
capsule = buildProcessTaskResultCapsule({
|
|
17119
|
+
stdout: stdout2,
|
|
17120
|
+
stderr: stderr2,
|
|
17121
|
+
exitCode: exitCode2,
|
|
17122
|
+
// Duration is measured from the registry envelope's startedAt
|
|
17123
|
+
// (spawn moment), not from the detach moment.
|
|
17124
|
+
startedAt: registry2.get(pid)?.startedAt,
|
|
17125
|
+
workspaceRoot: args2.workspaceRoot,
|
|
17126
|
+
captureError: [stdoutResult.error, stderrResult.error].filter(Boolean).join("; ")
|
|
17127
|
+
});
|
|
17128
|
+
} catch {
|
|
17129
|
+
}
|
|
17130
|
+
registry2.markExited(pid, exitCode2, capsule);
|
|
17131
|
+
})();
|
|
17016
17132
|
});
|
|
17017
17133
|
const immediate = effectiveDetachMs === 0;
|
|
17018
17134
|
const reason = immediate ? `command looks long-running; moved to background immediately (pid=${pid}, label=${label})` : `command detached to background after ${effectiveDetachMs}ms (pid=${pid}, label=${label})`;
|
|
@@ -17036,10 +17152,13 @@ Use listProcesses to inspect or stop it.`,
|
|
|
17036
17152
|
})
|
|
17037
17153
|
};
|
|
17038
17154
|
}
|
|
17039
|
-
const [
|
|
17040
|
-
|
|
17041
|
-
|
|
17155
|
+
const [stdoutCaptureResult, stderrCaptureResult] = await Promise.all([
|
|
17156
|
+
stdoutCapture,
|
|
17157
|
+
stderrCapture
|
|
17042
17158
|
]);
|
|
17159
|
+
const stdout = stdoutCaptureResult.value;
|
|
17160
|
+
const rawStderr = stderrCaptureResult.value;
|
|
17161
|
+
const streamCaptureError = [stdoutCaptureResult.error, stderrCaptureResult.error].filter(Boolean).join("; ");
|
|
17043
17162
|
const exitCode = aborted ? 130 : timedOut ? 124 : Number(raceWinner);
|
|
17044
17163
|
if (typeof proc.pid === "number") {
|
|
17045
17164
|
registry2.completeTransient(proc.pid, exitCode);
|
|
@@ -17456,9 +17575,7 @@ var WORKSPACE_TOOL_NAMES = [
|
|
|
17456
17575
|
"launchProcess",
|
|
17457
17576
|
"listProcesses",
|
|
17458
17577
|
"taskWait",
|
|
17459
|
-
"taskLogs",
|
|
17460
17578
|
"taskStop",
|
|
17461
|
-
"tasks",
|
|
17462
17579
|
"openDesktopPreview"
|
|
17463
17580
|
];
|
|
17464
17581
|
var SHELL_TOOL_NAMES = [
|
|
@@ -17466,9 +17583,7 @@ var SHELL_TOOL_NAMES = [
|
|
|
17466
17583
|
"launchProcess",
|
|
17467
17584
|
"listProcesses",
|
|
17468
17585
|
"taskWait",
|
|
17469
|
-
"
|
|
17470
|
-
"taskStop",
|
|
17471
|
-
"tasks"
|
|
17586
|
+
"taskStop"
|
|
17472
17587
|
];
|
|
17473
17588
|
var WORKSPACE_TOOL_NAME_SET = new Set(WORKSPACE_TOOL_NAMES);
|
|
17474
17589
|
function buildWorkspacePathProperty() {
|
|
@@ -17717,7 +17832,7 @@ function buildTaskWaitTool() {
|
|
|
17717
17832
|
type: "function",
|
|
17718
17833
|
function: {
|
|
17719
17834
|
name: "taskWait",
|
|
17720
|
-
description: 'Block until a background task (from launchProcess, or an execShell command that detached) reaches a terminal state, or until timeoutMs elapses. Returns {outcome, status, exitCode?, cursor, events}: outcome "terminal" with status exited|failed|stopped when it finished, outcome "timeout" with status "running" when it outlived the whole budget, outcome "not-found" for an unknown taskId, or outcome "evicted" when the event trail aged out (never wait again in that case). One call already waits the maximum budget and returns the moment the task ends, so a "timeout" means the task is genuinely longer than that \u2014 go do other work and come back, rather than re-waiting in a loop (each re-wait costs a full model round-trip).
|
|
17835
|
+
description: 'Block until a background task (from launchProcess, or an execShell command that detached) reaches a terminal state, or until timeoutMs elapses. Returns {outcome, status, exitCode?, cursor, events}: outcome "terminal" with status exited|failed|stopped when it finished, outcome "timeout" with status "running" when it outlived the whole budget, outcome "not-found" for an unknown taskId, or outcome "evicted" when the event trail aged out (never wait again in that case). One call already waits the maximum budget and returns the moment the task ends, so a "timeout" means the task is genuinely longer than that \u2014 go do other work and come back, rather than re-waiting in a loop (each re-wait costs a full model round-trip). Pass a small timeoutMs for a cheap liveness peek instead of the full result. `cursor` is the highest event seq covered by this response.',
|
|
17721
17836
|
parameters: {
|
|
17722
17837
|
type: "object",
|
|
17723
17838
|
properties: {
|
|
@@ -17736,30 +17851,6 @@ function buildTaskWaitTool() {
|
|
|
17736
17851
|
}
|
|
17737
17852
|
};
|
|
17738
17853
|
}
|
|
17739
|
-
function buildTaskLogsTool() {
|
|
17740
|
-
return {
|
|
17741
|
-
type: "function",
|
|
17742
|
-
function: {
|
|
17743
|
-
name: "taskLogs",
|
|
17744
|
-
description: "Read a background task's lifecycle events incrementally. Returns {outcome, status, cursor, events} where events are the started|promoted|exited|killed records with seq greater than the cursor you passed, and the returned `cursor` is the new high-water mark to pass next time (omit cursor to read from the beginning; repeating the same cursor is idempotent). Oversized output is spilled to a file and reported as `logRef`, which you can open with readFile.",
|
|
17745
|
-
parameters: {
|
|
17746
|
-
type: "object",
|
|
17747
|
-
properties: {
|
|
17748
|
-
taskId: {
|
|
17749
|
-
type: "string",
|
|
17750
|
-
minLength: 1,
|
|
17751
|
-
description: "Task id returned by launchProcess or by a detached execShell result."
|
|
17752
|
-
},
|
|
17753
|
-
cursor: {
|
|
17754
|
-
type: "number",
|
|
17755
|
-
description: "Last event seq you already consumed; only events with a higher seq are returned. Defaults to 0 (all retained events)."
|
|
17756
|
-
}
|
|
17757
|
-
},
|
|
17758
|
-
required: ["taskId"]
|
|
17759
|
-
}
|
|
17760
|
-
}
|
|
17761
|
-
};
|
|
17762
|
-
}
|
|
17763
17854
|
function buildTaskStopTool() {
|
|
17764
17855
|
return {
|
|
17765
17856
|
type: "function",
|
|
@@ -17780,19 +17871,6 @@ function buildTaskStopTool() {
|
|
|
17780
17871
|
}
|
|
17781
17872
|
};
|
|
17782
17873
|
}
|
|
17783
|
-
function buildTasksTool() {
|
|
17784
|
-
return {
|
|
17785
|
-
type: "function",
|
|
17786
|
-
function: {
|
|
17787
|
-
name: "tasks",
|
|
17788
|
-
description: "List background tasks you can still wait on, read logs from, or stop. Returns {count, tasks: {taskId, pid, label, status, startedAt, persist}[]}. Use it to recover a taskId you lost track of; foreground commands still running inside execShell are not listed.",
|
|
17789
|
-
parameters: {
|
|
17790
|
-
type: "object",
|
|
17791
|
-
properties: {}
|
|
17792
|
-
}
|
|
17793
|
-
}
|
|
17794
|
-
};
|
|
17795
|
-
}
|
|
17796
17874
|
function buildWorkspaceToolDefinition(toolName) {
|
|
17797
17875
|
if (toolName === "readFile") {
|
|
17798
17876
|
return buildReadWorkspaceFileTool();
|
|
@@ -17812,9 +17890,7 @@ function buildWorkspaceToolDefinition(toolName) {
|
|
|
17812
17890
|
if (toolName === "openDesktopPreview") return buildOpenDesktopPreviewTool();
|
|
17813
17891
|
if (toolName === "listProcesses") return buildListProcessesTool();
|
|
17814
17892
|
if (toolName === "taskWait") return buildTaskWaitTool();
|
|
17815
|
-
if (toolName === "taskLogs") return buildTaskLogsTool();
|
|
17816
17893
|
if (toolName === "taskStop") return buildTaskStopTool();
|
|
17817
|
-
if (toolName === "tasks") return buildTasksTool();
|
|
17818
17894
|
return null;
|
|
17819
17895
|
}
|
|
17820
17896
|
function filterDeclaredWorkspaceToolNames(args2) {
|
|
@@ -18923,7 +18999,7 @@ async function launchProcessTool(args2) {
|
|
|
18923
18999
|
};
|
|
18924
19000
|
}
|
|
18925
19001
|
async function listProcessesTool(args2) {
|
|
18926
|
-
const list = getProcessRegistry().list();
|
|
19002
|
+
const list = getProcessRegistry().list().map(toProcessTaskView);
|
|
18927
19003
|
return {
|
|
18928
19004
|
content: JSON.stringify(list),
|
|
18929
19005
|
metadata: {
|
|
@@ -19280,15 +19356,23 @@ function buildLoadSkillExecutor(args2) {
|
|
|
19280
19356
|
const { resolveSkillByName } = await import("./skillDiscovery-CYUCJMAG.js");
|
|
19281
19357
|
const resolved = resolveSkillByName(args2.cwd, name);
|
|
19282
19358
|
if (!resolved) {
|
|
19283
|
-
const {
|
|
19284
|
-
const
|
|
19285
|
-
if (
|
|
19286
|
-
const body = buildCodingSkillContentBySlug(builtinSlug);
|
|
19359
|
+
const { resolveBuiltinSkillByName } = await import("./builtinSkillRegistry-YITVDLWG.js");
|
|
19360
|
+
const builtin = resolveBuiltinSkillByName(name);
|
|
19361
|
+
if (builtin) {
|
|
19287
19362
|
return {
|
|
19288
19363
|
content: `Skill "${name}" loaded inline. Follow its instructions.
|
|
19289
19364
|
|
|
19290
|
-
${
|
|
19291
|
-
|
|
19365
|
+
${builtin.content}`,
|
|
19366
|
+
// toolNames 进 metadata:回退面已扩到全注册表,其中授工具型 skill
|
|
19367
|
+
// (search-* 等)的工具在本宿主未必接线,宿主可据此降级提示。
|
|
19368
|
+
metadata: {
|
|
19369
|
+
loadSkill: true,
|
|
19370
|
+
resolved: true,
|
|
19371
|
+
name,
|
|
19372
|
+
requestedName: name,
|
|
19373
|
+
builtin: true,
|
|
19374
|
+
...builtin.config.toolNames?.length ? { toolNames: [...builtin.config.toolNames] } : {}
|
|
19375
|
+
}
|
|
19292
19376
|
};
|
|
19293
19377
|
}
|
|
19294
19378
|
return {
|
|
@@ -20059,6 +20143,508 @@ async function fetchAntigravityCloudCodeCompletion(args2) {
|
|
|
20059
20143
|
return normalized;
|
|
20060
20144
|
}
|
|
20061
20145
|
|
|
20146
|
+
// packages/agent-runtime/devin/devinProvider.ts
|
|
20147
|
+
import { randomBytes, randomUUID as randomUUID2 } from "node:crypto";
|
|
20148
|
+
var CLIENT_NAME = "chisel";
|
|
20149
|
+
var CLIENT_VERSION = "2026.8.18";
|
|
20150
|
+
function writeVarint(fieldNum, value) {
|
|
20151
|
+
const tag = fieldNum << 3 | 0;
|
|
20152
|
+
const bytes = [];
|
|
20153
|
+
let t = tag;
|
|
20154
|
+
while (t >= 128) {
|
|
20155
|
+
bytes.push(t & 127 | 128);
|
|
20156
|
+
t >>>= 7;
|
|
20157
|
+
}
|
|
20158
|
+
bytes.push(t);
|
|
20159
|
+
let v = value;
|
|
20160
|
+
while (v >= 128) {
|
|
20161
|
+
bytes.push(v & 127 | 128);
|
|
20162
|
+
v >>>= 7;
|
|
20163
|
+
}
|
|
20164
|
+
bytes.push(v);
|
|
20165
|
+
return Buffer.from(bytes);
|
|
20166
|
+
}
|
|
20167
|
+
function writeLengthDelimited(fieldNum, content) {
|
|
20168
|
+
const tag = fieldNum << 3 | 2;
|
|
20169
|
+
const tagBytes = [];
|
|
20170
|
+
let t = tag;
|
|
20171
|
+
while (t >= 128) {
|
|
20172
|
+
tagBytes.push(t & 127 | 128);
|
|
20173
|
+
t >>>= 7;
|
|
20174
|
+
}
|
|
20175
|
+
tagBytes.push(t);
|
|
20176
|
+
const lenBytes = [];
|
|
20177
|
+
let len = content.length;
|
|
20178
|
+
while (len >= 128) {
|
|
20179
|
+
lenBytes.push(len & 127 | 128);
|
|
20180
|
+
len >>>= 7;
|
|
20181
|
+
}
|
|
20182
|
+
lenBytes.push(len);
|
|
20183
|
+
return Buffer.concat([Buffer.from(tagBytes), Buffer.from(lenBytes), content]);
|
|
20184
|
+
}
|
|
20185
|
+
function writeStringField(fieldNum, str) {
|
|
20186
|
+
return writeLengthDelimited(fieldNum, Buffer.from(str, "utf8"));
|
|
20187
|
+
}
|
|
20188
|
+
function writeMessageField(fieldNum, message) {
|
|
20189
|
+
return writeLengthDelimited(fieldNum, message);
|
|
20190
|
+
}
|
|
20191
|
+
function generateFingerprint() {
|
|
20192
|
+
return randomBytes(366).toString("hex");
|
|
20193
|
+
}
|
|
20194
|
+
function encodeDevinClientMetadata(token) {
|
|
20195
|
+
return Buffer.concat([
|
|
20196
|
+
writeStringField(1, CLIENT_NAME),
|
|
20197
|
+
writeStringField(2, CLIENT_VERSION),
|
|
20198
|
+
writeStringField(3, token),
|
|
20199
|
+
writeStringField(4, "en"),
|
|
20200
|
+
writeStringField(5, process.platform === "win32" ? "windows" : "linux"),
|
|
20201
|
+
writeStringField(7, CLIENT_VERSION),
|
|
20202
|
+
writeStringField(12, CLIENT_NAME),
|
|
20203
|
+
writeStringField(31, generateFingerprint())
|
|
20204
|
+
]);
|
|
20205
|
+
}
|
|
20206
|
+
function encodeDevinChatMessage(msg) {
|
|
20207
|
+
const source = msg.role === "assistant" ? 2 : msg.role === "tool" ? 4 : 1;
|
|
20208
|
+
return Buffer.concat([
|
|
20209
|
+
writeStringField(1, randomUUID2()),
|
|
20210
|
+
writeVarint(2, source),
|
|
20211
|
+
writeStringField(3, msg.text),
|
|
20212
|
+
...(msg.toolCalls ?? []).map(
|
|
20213
|
+
(toolCall) => writeMessageField(
|
|
20214
|
+
6,
|
|
20215
|
+
Buffer.concat([
|
|
20216
|
+
writeStringField(1, toolCall.id),
|
|
20217
|
+
writeStringField(2, toolCall.function.name),
|
|
20218
|
+
writeStringField(3, toolCall.function.arguments)
|
|
20219
|
+
])
|
|
20220
|
+
)
|
|
20221
|
+
),
|
|
20222
|
+
...msg.toolCallId ? [writeStringField(7, msg.toolCallId)] : []
|
|
20223
|
+
]);
|
|
20224
|
+
}
|
|
20225
|
+
function encodeDevinToolDefinition(tool) {
|
|
20226
|
+
const fn3 = tool.function ?? {};
|
|
20227
|
+
const name = typeof fn3.name === "string" ? fn3.name : "";
|
|
20228
|
+
const description = typeof fn3.description === "string" ? fn3.description : "";
|
|
20229
|
+
const parameters = fn3.parameters ?? {};
|
|
20230
|
+
return Buffer.concat([
|
|
20231
|
+
writeStringField(1, name),
|
|
20232
|
+
writeStringField(2, description.length > 6998 ? `${description.slice(0, 6995)}...` : description),
|
|
20233
|
+
writeStringField(3, JSON.stringify(parameters))
|
|
20234
|
+
]);
|
|
20235
|
+
}
|
|
20236
|
+
function writeFixed64Field(fieldNum, val) {
|
|
20237
|
+
const b = Buffer.alloc(8);
|
|
20238
|
+
b.writeDoubleLE(val, 0);
|
|
20239
|
+
const tag = fieldNum << 3 | 1;
|
|
20240
|
+
const tagBytes = [];
|
|
20241
|
+
let t = tag;
|
|
20242
|
+
while (t >= 128) {
|
|
20243
|
+
tagBytes.push(t & 127 | 128);
|
|
20244
|
+
t >>>= 7;
|
|
20245
|
+
}
|
|
20246
|
+
tagBytes.push(t);
|
|
20247
|
+
return Buffer.concat([Buffer.from(tagBytes), b]);
|
|
20248
|
+
}
|
|
20249
|
+
function buildCompletionConfig(params) {
|
|
20250
|
+
const maxTokens = params?.maxTokens ?? 128e3;
|
|
20251
|
+
const maxNewlines = params?.maxNewlines ?? 400;
|
|
20252
|
+
const temp = params?.temperature ?? 1;
|
|
20253
|
+
const topP = params?.topP ?? 0.95;
|
|
20254
|
+
return Buffer.concat([
|
|
20255
|
+
writeVarint(1, 1),
|
|
20256
|
+
writeVarint(2, maxTokens),
|
|
20257
|
+
writeVarint(3, maxNewlines),
|
|
20258
|
+
writeFixed64Field(5, temp),
|
|
20259
|
+
writeVarint(7, 40),
|
|
20260
|
+
writeFixed64Field(8, topP)
|
|
20261
|
+
]);
|
|
20262
|
+
}
|
|
20263
|
+
function buildGetChatMessageRequest(params) {
|
|
20264
|
+
const { token, messages, model, tools = [], temperature } = params;
|
|
20265
|
+
const metadata = encodeDevinClientMetadata(token);
|
|
20266
|
+
let systemPrompt = "";
|
|
20267
|
+
const filteredMessages = [];
|
|
20268
|
+
for (const m of messages) {
|
|
20269
|
+
const text = typeof m.content === "string" ? m.content : Array.isArray(m.content) ? m.content.filter((p) => p?.type === "text").map((p) => p.text).join("\n") : "";
|
|
20270
|
+
if (m.role === "system") {
|
|
20271
|
+
systemPrompt = systemPrompt ? `${systemPrompt}
|
|
20272
|
+
|
|
20273
|
+
${text}` : text;
|
|
20274
|
+
} else if (m.role === "user" || m.role === "assistant" || m.role === "tool") {
|
|
20275
|
+
filteredMessages.push({
|
|
20276
|
+
role: m.role,
|
|
20277
|
+
text,
|
|
20278
|
+
...m.tool_call_id ? { toolCallId: m.tool_call_id } : {},
|
|
20279
|
+
...m.tool_calls?.length ? { toolCalls: m.tool_calls } : {}
|
|
20280
|
+
});
|
|
20281
|
+
}
|
|
20282
|
+
}
|
|
20283
|
+
const coalesced = [];
|
|
20284
|
+
for (const item of filteredMessages) {
|
|
20285
|
+
const last = coalesced[coalesced.length - 1];
|
|
20286
|
+
if (last && last.role === item.role && item.role !== "tool" && !last.toolCalls?.length && !item.toolCalls?.length) {
|
|
20287
|
+
last.text = `${last.text}
|
|
20288
|
+
|
|
20289
|
+
${item.text}`;
|
|
20290
|
+
} else {
|
|
20291
|
+
coalesced.push({ ...item });
|
|
20292
|
+
}
|
|
20293
|
+
}
|
|
20294
|
+
const chatMessageBuffers = coalesced.map((m) => encodeDevinChatMessage(m));
|
|
20295
|
+
const completionConfig = buildCompletionConfig({ temperature });
|
|
20296
|
+
const modelConfig = Buffer.concat([
|
|
20297
|
+
writeStringField(1, randomUUID2()),
|
|
20298
|
+
writeVarint(2, 1),
|
|
20299
|
+
writeVarint(3, 4)
|
|
20300
|
+
]);
|
|
20301
|
+
return Buffer.concat([
|
|
20302
|
+
writeMessageField(1, metadata),
|
|
20303
|
+
writeStringField(2, systemPrompt),
|
|
20304
|
+
...chatMessageBuffers.map((b) => writeMessageField(3, b)),
|
|
20305
|
+
writeVarint(7, 5),
|
|
20306
|
+
writeMessageField(8, completionConfig),
|
|
20307
|
+
...tools.map((tool) => writeMessageField(10, encodeDevinToolDefinition(tool))),
|
|
20308
|
+
writeMessageField(15, modelConfig),
|
|
20309
|
+
writeStringField(16, randomUUID2()),
|
|
20310
|
+
writeVarint(20, 1),
|
|
20311
|
+
writeStringField(21, model)
|
|
20312
|
+
]);
|
|
20313
|
+
}
|
|
20314
|
+
function buildDevinConnectFrame(payload, flags = 0) {
|
|
20315
|
+
const header = Buffer.alloc(5);
|
|
20316
|
+
header[0] = flags & 255;
|
|
20317
|
+
header.writeUInt32BE(payload.length, 1);
|
|
20318
|
+
return Buffer.concat([header, payload]);
|
|
20319
|
+
}
|
|
20320
|
+
function parseDevinConnectFrames(buffer3) {
|
|
20321
|
+
const frames = [];
|
|
20322
|
+
let offset = 0;
|
|
20323
|
+
while (offset + 5 <= buffer3.length) {
|
|
20324
|
+
const flags = buffer3[offset];
|
|
20325
|
+
const length = buffer3.readUInt32BE(offset + 1);
|
|
20326
|
+
if (offset + 5 + length > buffer3.length) {
|
|
20327
|
+
break;
|
|
20328
|
+
}
|
|
20329
|
+
const payload = buffer3.subarray(offset + 5, offset + 5 + length);
|
|
20330
|
+
frames.push({ flags, payload });
|
|
20331
|
+
offset += 5 + length;
|
|
20332
|
+
}
|
|
20333
|
+
return {
|
|
20334
|
+
frames,
|
|
20335
|
+
remainder: buffer3.subarray(offset)
|
|
20336
|
+
};
|
|
20337
|
+
}
|
|
20338
|
+
function parseDevinMetadataUsage(metaBytes) {
|
|
20339
|
+
let prompt = 0;
|
|
20340
|
+
let completion;
|
|
20341
|
+
let cacheRead = 0;
|
|
20342
|
+
let cacheWrite = 0;
|
|
20343
|
+
let sawAny = false;
|
|
20344
|
+
let offset = 0;
|
|
20345
|
+
while (offset < metaBytes.length) {
|
|
20346
|
+
let tag = 0;
|
|
20347
|
+
let shift = 0;
|
|
20348
|
+
while (offset < metaBytes.length) {
|
|
20349
|
+
const b = metaBytes[offset++];
|
|
20350
|
+
tag |= (b & 127) << shift;
|
|
20351
|
+
if (!(b & 128)) break;
|
|
20352
|
+
shift += 7;
|
|
20353
|
+
}
|
|
20354
|
+
const fieldNum = tag >>> 3;
|
|
20355
|
+
const wireType = tag & 7;
|
|
20356
|
+
if (wireType === 0) {
|
|
20357
|
+
let val = 0;
|
|
20358
|
+
let s = 0;
|
|
20359
|
+
while (offset < metaBytes.length) {
|
|
20360
|
+
const b = metaBytes[offset++];
|
|
20361
|
+
val |= (b & 127) << s;
|
|
20362
|
+
if (!(b & 128)) break;
|
|
20363
|
+
s += 7;
|
|
20364
|
+
}
|
|
20365
|
+
if (fieldNum === 2) {
|
|
20366
|
+
prompt = val;
|
|
20367
|
+
sawAny = true;
|
|
20368
|
+
} else if (fieldNum === 3) {
|
|
20369
|
+
completion = val;
|
|
20370
|
+
sawAny = true;
|
|
20371
|
+
} else if (fieldNum === 4) {
|
|
20372
|
+
cacheWrite = val;
|
|
20373
|
+
sawAny = true;
|
|
20374
|
+
} else if (fieldNum === 5) {
|
|
20375
|
+
cacheRead = val;
|
|
20376
|
+
sawAny = true;
|
|
20377
|
+
}
|
|
20378
|
+
} else if (wireType === 2) {
|
|
20379
|
+
let len = 0;
|
|
20380
|
+
let s = 0;
|
|
20381
|
+
while (offset < metaBytes.length) {
|
|
20382
|
+
const b = metaBytes[offset++];
|
|
20383
|
+
len |= (b & 127) << s;
|
|
20384
|
+
if (!(b & 128)) break;
|
|
20385
|
+
s += 7;
|
|
20386
|
+
}
|
|
20387
|
+
offset += len;
|
|
20388
|
+
} else {
|
|
20389
|
+
break;
|
|
20390
|
+
}
|
|
20391
|
+
}
|
|
20392
|
+
return sawAny ? { prompt, completion, cacheRead, cacheWrite } : null;
|
|
20393
|
+
}
|
|
20394
|
+
function parseDevinConnectTrailer(payload) {
|
|
20395
|
+
const text = payload.toString("utf8").trim();
|
|
20396
|
+
if (!text || text === "{}") return null;
|
|
20397
|
+
try {
|
|
20398
|
+
const parsed = JSON.parse(text);
|
|
20399
|
+
if (!parsed.error) {
|
|
20400
|
+
return new Error(`Devin Connect invalid terminal trailer: ${text}`);
|
|
20401
|
+
}
|
|
20402
|
+
const code = typeof parsed.error.code === "string" ? parsed.error.code : "unknown";
|
|
20403
|
+
const message = typeof parsed.error.message === "string" ? parsed.error.message : "Unknown error";
|
|
20404
|
+
return new Error(`Devin Connect upstream error ${code}: ${message}`);
|
|
20405
|
+
} catch {
|
|
20406
|
+
return new Error(`Devin Connect invalid terminal trailer: ${text}`);
|
|
20407
|
+
}
|
|
20408
|
+
}
|
|
20409
|
+
function decodeDevinResponsePayload(payload) {
|
|
20410
|
+
let offset = 0;
|
|
20411
|
+
let content = "";
|
|
20412
|
+
let reasoning = "";
|
|
20413
|
+
let finishReason = null;
|
|
20414
|
+
let usage = null;
|
|
20415
|
+
const events = [];
|
|
20416
|
+
while (offset < payload.length) {
|
|
20417
|
+
let tag = 0;
|
|
20418
|
+
let shift = 0;
|
|
20419
|
+
while (offset < payload.length) {
|
|
20420
|
+
const b = payload[offset++];
|
|
20421
|
+
tag |= (b & 127) << shift;
|
|
20422
|
+
if (!(b & 128)) break;
|
|
20423
|
+
shift += 7;
|
|
20424
|
+
}
|
|
20425
|
+
const fieldNum = tag >>> 3;
|
|
20426
|
+
const wireType = tag & 7;
|
|
20427
|
+
if (wireType === 0) {
|
|
20428
|
+
let val = 0;
|
|
20429
|
+
let s = 0;
|
|
20430
|
+
while (offset < payload.length) {
|
|
20431
|
+
const b = payload[offset++];
|
|
20432
|
+
val |= (b & 127) << s;
|
|
20433
|
+
if (!(b & 128)) break;
|
|
20434
|
+
s += 7;
|
|
20435
|
+
}
|
|
20436
|
+
if (fieldNum === 5) {
|
|
20437
|
+
finishReason = val === 10 ? "tool_calls" : val === 1 || val === 3 ? "length" : "stop";
|
|
20438
|
+
}
|
|
20439
|
+
} else if (wireType === 2) {
|
|
20440
|
+
let len = 0;
|
|
20441
|
+
let s = 0;
|
|
20442
|
+
while (offset < payload.length) {
|
|
20443
|
+
const b = payload[offset++];
|
|
20444
|
+
len |= (b & 127) << s;
|
|
20445
|
+
if (!(b & 128)) break;
|
|
20446
|
+
s += 7;
|
|
20447
|
+
}
|
|
20448
|
+
const valBytes = payload.subarray(offset, offset + len);
|
|
20449
|
+
offset += len;
|
|
20450
|
+
if (fieldNum === 3) {
|
|
20451
|
+
const text = valBytes.toString("utf8");
|
|
20452
|
+
content += text;
|
|
20453
|
+
events.push({ type: "content", text });
|
|
20454
|
+
} else if (fieldNum === 9) {
|
|
20455
|
+
const text = valBytes.toString("utf8");
|
|
20456
|
+
reasoning += text;
|
|
20457
|
+
events.push({ type: "reasoning", text });
|
|
20458
|
+
} else if (fieldNum === 6) {
|
|
20459
|
+
let nestedOffset = 0;
|
|
20460
|
+
let id;
|
|
20461
|
+
let name;
|
|
20462
|
+
let argsDelta;
|
|
20463
|
+
while (nestedOffset < valBytes.length) {
|
|
20464
|
+
let nestedTag = 0;
|
|
20465
|
+
let nestedShift = 0;
|
|
20466
|
+
while (nestedOffset < valBytes.length) {
|
|
20467
|
+
const b = valBytes[nestedOffset++];
|
|
20468
|
+
nestedTag |= (b & 127) << nestedShift;
|
|
20469
|
+
if (!(b & 128)) break;
|
|
20470
|
+
nestedShift += 7;
|
|
20471
|
+
}
|
|
20472
|
+
const nestedField = nestedTag >>> 3;
|
|
20473
|
+
const nestedWire = nestedTag & 7;
|
|
20474
|
+
if (nestedWire !== 2) break;
|
|
20475
|
+
let nestedLength = 0;
|
|
20476
|
+
let lengthShift = 0;
|
|
20477
|
+
while (nestedOffset < valBytes.length) {
|
|
20478
|
+
const b = valBytes[nestedOffset++];
|
|
20479
|
+
nestedLength |= (b & 127) << lengthShift;
|
|
20480
|
+
if (!(b & 128)) break;
|
|
20481
|
+
lengthShift += 7;
|
|
20482
|
+
}
|
|
20483
|
+
const nestedValue = valBytes.subarray(nestedOffset, nestedOffset + nestedLength);
|
|
20484
|
+
nestedOffset += nestedLength;
|
|
20485
|
+
const text = nestedValue.toString("utf8");
|
|
20486
|
+
if (nestedField === 1) id = text;
|
|
20487
|
+
else if (nestedField === 2) name = text;
|
|
20488
|
+
else if (nestedField === 3) argsDelta = (argsDelta ?? "") + text;
|
|
20489
|
+
}
|
|
20490
|
+
if (id !== void 0 && name !== void 0) {
|
|
20491
|
+
events.push({ type: "tool-call-start", id, name });
|
|
20492
|
+
}
|
|
20493
|
+
if (argsDelta !== void 0) {
|
|
20494
|
+
events.push({ type: "tool-call-args", argsDelta, ...id ? { id } : {} });
|
|
20495
|
+
}
|
|
20496
|
+
} else if (fieldNum === 7) {
|
|
20497
|
+
usage = parseDevinMetadataUsage(valBytes);
|
|
20498
|
+
}
|
|
20499
|
+
} else {
|
|
20500
|
+
break;
|
|
20501
|
+
}
|
|
20502
|
+
}
|
|
20503
|
+
return { content, reasoning, finishReason, events, usage };
|
|
20504
|
+
}
|
|
20505
|
+
function createDevinProvider(options) {
|
|
20506
|
+
const { token, model = "swe-2-max", fetchImpl = fetch, tools = [], temperature } = options;
|
|
20507
|
+
return {
|
|
20508
|
+
model,
|
|
20509
|
+
async complete(messages, opts) {
|
|
20510
|
+
const selectedModel = model;
|
|
20511
|
+
const requestPayload = buildGetChatMessageRequest({
|
|
20512
|
+
token,
|
|
20513
|
+
messages,
|
|
20514
|
+
model: selectedModel,
|
|
20515
|
+
tools,
|
|
20516
|
+
temperature
|
|
20517
|
+
});
|
|
20518
|
+
const frame = buildDevinConnectFrame(requestPayload);
|
|
20519
|
+
const response = await fetchImpl(DEVIN_CONNECT_URL, {
|
|
20520
|
+
method: "POST",
|
|
20521
|
+
headers: {
|
|
20522
|
+
"authorization": `Basic ${token}-${token}`,
|
|
20523
|
+
"content-type": "application/connect+proto",
|
|
20524
|
+
"connect-protocol-version": "1"
|
|
20525
|
+
},
|
|
20526
|
+
body: new Uint8Array(frame),
|
|
20527
|
+
signal: opts?.signal
|
|
20528
|
+
});
|
|
20529
|
+
if (!response.ok) {
|
|
20530
|
+
const errText = await response.text().catch(() => "");
|
|
20531
|
+
throw new Error(
|
|
20532
|
+
`Devin Connect upstream returned error ${response.status}: ${errText}`
|
|
20533
|
+
);
|
|
20534
|
+
}
|
|
20535
|
+
if (!response.body) {
|
|
20536
|
+
throw new Error("Devin Connect response body is null");
|
|
20537
|
+
}
|
|
20538
|
+
let text = "";
|
|
20539
|
+
let reasoning = "";
|
|
20540
|
+
let finishReason = null;
|
|
20541
|
+
let frameUsage = null;
|
|
20542
|
+
const toolCallOrder = [];
|
|
20543
|
+
const toolCallById = /* @__PURE__ */ new Map();
|
|
20544
|
+
let currentToolCallId = null;
|
|
20545
|
+
let buffer3 = Buffer.alloc(0);
|
|
20546
|
+
let sawTrailer = false;
|
|
20547
|
+
const reader = response.body.getReader();
|
|
20548
|
+
try {
|
|
20549
|
+
while (true) {
|
|
20550
|
+
const { done: done4, value } = await reader.read();
|
|
20551
|
+
if (done4) break;
|
|
20552
|
+
buffer3 = Buffer.concat([buffer3, Buffer.from(value)]);
|
|
20553
|
+
const { frames, remainder } = parseDevinConnectFrames(buffer3);
|
|
20554
|
+
buffer3 = Buffer.from(remainder);
|
|
20555
|
+
for (const f of frames) {
|
|
20556
|
+
if (sawTrailer) {
|
|
20557
|
+
throw new Error("Devin Connect received a frame after the terminal trailer");
|
|
20558
|
+
}
|
|
20559
|
+
if (f.flags & 2) {
|
|
20560
|
+
sawTrailer = true;
|
|
20561
|
+
const trailerError = parseDevinConnectTrailer(f.payload);
|
|
20562
|
+
if (trailerError) throw trailerError;
|
|
20563
|
+
continue;
|
|
20564
|
+
}
|
|
20565
|
+
const delta = decodeDevinResponsePayload(f.payload);
|
|
20566
|
+
if (delta.usage?.completion !== void 0) {
|
|
20567
|
+
frameUsage = delta.usage;
|
|
20568
|
+
}
|
|
20569
|
+
text += delta.content;
|
|
20570
|
+
reasoning += delta.reasoning;
|
|
20571
|
+
if (delta.finishReason) finishReason = delta.finishReason;
|
|
20572
|
+
for (const event of delta.events) {
|
|
20573
|
+
if (event.type === "reasoning") {
|
|
20574
|
+
opts?.onReasoningDelta?.(event.text);
|
|
20575
|
+
} else if (event.type === "content") {
|
|
20576
|
+
opts?.onTextDelta?.(event.text);
|
|
20577
|
+
} else if (event.type === "tool-call-start") {
|
|
20578
|
+
const existing = toolCallById.get(event.id);
|
|
20579
|
+
if (existing) {
|
|
20580
|
+
existing.name = event.name;
|
|
20581
|
+
} else {
|
|
20582
|
+
toolCallOrder.push(event.id);
|
|
20583
|
+
toolCallById.set(event.id, {
|
|
20584
|
+
id: event.id,
|
|
20585
|
+
name: event.name,
|
|
20586
|
+
argumentsText: ""
|
|
20587
|
+
});
|
|
20588
|
+
}
|
|
20589
|
+
currentToolCallId = event.id;
|
|
20590
|
+
} else {
|
|
20591
|
+
const targetId = event.id ?? currentToolCallId;
|
|
20592
|
+
const target = targetId ? toolCallById.get(targetId) : void 0;
|
|
20593
|
+
if (target) target.argumentsText += event.argsDelta;
|
|
20594
|
+
}
|
|
20595
|
+
}
|
|
20596
|
+
}
|
|
20597
|
+
}
|
|
20598
|
+
} finally {
|
|
20599
|
+
reader.releaseLock();
|
|
20600
|
+
}
|
|
20601
|
+
if (buffer3.length > 0) {
|
|
20602
|
+
throw new Error("Devin Connect upstream ended with an incomplete frame");
|
|
20603
|
+
}
|
|
20604
|
+
if (!sawTrailer) {
|
|
20605
|
+
throw new Error("Devin Connect upstream ended before the terminal trailer");
|
|
20606
|
+
}
|
|
20607
|
+
const toolCalls = toolCallOrder.map((id) => {
|
|
20608
|
+
const call = toolCallById.get(id);
|
|
20609
|
+
return {
|
|
20610
|
+
id: call.id,
|
|
20611
|
+
type: "function",
|
|
20612
|
+
function: {
|
|
20613
|
+
name: call.name,
|
|
20614
|
+
arguments: call.argumentsText || "{}"
|
|
20615
|
+
}
|
|
20616
|
+
};
|
|
20617
|
+
});
|
|
20618
|
+
if (!text && !reasoning && toolCalls.length === 0) {
|
|
20619
|
+
throw new Error("Devin Connect upstream completed without content or tool calls");
|
|
20620
|
+
}
|
|
20621
|
+
const usage = frameUsage ? {
|
|
20622
|
+
prompt_tokens: frameUsage.prompt + frameUsage.cacheRead,
|
|
20623
|
+
completion_tokens: frameUsage.completion ?? 0,
|
|
20624
|
+
total_tokens: frameUsage.prompt + frameUsage.cacheRead + (frameUsage.completion ?? 0) + frameUsage.cacheWrite,
|
|
20625
|
+
...frameUsage.cacheRead > 0 ? { prompt_tokens_details: { cached_tokens: frameUsage.cacheRead } } : {},
|
|
20626
|
+
...frameUsage.cacheWrite > 0 ? { cache_creation_input_tokens: frameUsage.cacheWrite } : {}
|
|
20627
|
+
} : void 0;
|
|
20628
|
+
return {
|
|
20629
|
+
content: text,
|
|
20630
|
+
model: selectedModel,
|
|
20631
|
+
provider: "devin",
|
|
20632
|
+
...usage ? { usage } : {},
|
|
20633
|
+
...reasoning ? { reasoning_content: reasoning } : {},
|
|
20634
|
+
...toolCalls.length > 0 ? { tool_calls: toolCalls } : {},
|
|
20635
|
+
// The upstream finish event wins whenever it is present. A tool call
|
|
20636
|
+
// cut off by the length limit has to stay "length" instead of being
|
|
20637
|
+
// relabelled "tool_calls", so probes/telemetry and any downstream
|
|
20638
|
+
// consumer of the final finish_reason no longer see a truncated turn
|
|
20639
|
+
// mislabelled as a normal one. localLoop keeps its own truncation
|
|
20640
|
+
// gates and excludes tool-bearing turns from them.
|
|
20641
|
+
finish_reason: finishReason ?? (toolCalls.length > 0 ? "tool_calls" : "stop"),
|
|
20642
|
+
stream_complete: true
|
|
20643
|
+
};
|
|
20644
|
+
}
|
|
20645
|
+
};
|
|
20646
|
+
}
|
|
20647
|
+
|
|
20062
20648
|
export {
|
|
20063
20649
|
Option_exports,
|
|
20064
20650
|
Duration_exports,
|
|
@@ -20068,6 +20654,7 @@ export {
|
|
|
20068
20654
|
readActionGate,
|
|
20069
20655
|
evaluateFileWritePolicy,
|
|
20070
20656
|
summarizeToolArguments,
|
|
20657
|
+
formatToolOverflowMarker,
|
|
20071
20658
|
LOCAL_AGENT_CONFIG_MISSING_CODE,
|
|
20072
20659
|
LOCAL_TURN_ABORTED_CODE,
|
|
20073
20660
|
runLocalAgentTurn,
|
|
@@ -20110,5 +20697,6 @@ export {
|
|
|
20110
20697
|
shouldUseGeminiNativeToolRoute,
|
|
20111
20698
|
buildGeminiGenerateContentRequest,
|
|
20112
20699
|
resolveAntigravityFinishReason,
|
|
20113
|
-
fetchAntigravityCloudCodeCompletion
|
|
20700
|
+
fetchAntigravityCloudCodeCompletion,
|
|
20701
|
+
createDevinProvider
|
|
20114
20702
|
};
|