nolo-cli 0.74.0-alpha.1 → 0.74.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-YEVZAJYX.js → _executeModel-IULR47HG.js} +20 -20
- package/{agentDeleteCommand-FSIMTL4K.js → agentDeleteCommand-2S4WCDQC.js} +16 -15
- package/{agentEmailCommands-HQT4EUOA.js → agentEmailCommands-V3ADGHX7.js} +30 -28
- package/{agentListCommands-2YWZYH52.js → agentListCommands-EPK3S274.js} +18 -17
- package/{agentMachineCommands-3TR7DVYO.js → agentMachineCommands-XMZWK7P3.js} +16 -15
- package/{agentRecordCommands-TRUY7Z6N.js → agentRecordCommands-WFPWLWOF.js} +29 -27
- package/{agentRunCommand-EHJOESHA.js → agentRunCommand-VUWNWC7C.js} +29 -27
- package/{agentRuntimeLocal-O6DZDTK4.js → agentRuntimeLocal-YRONTDLM.js} +15 -14
- package/{agentSlice-RRZS2UII.js → agentSlice-2P7OJFES.js} +1 -1
- package/{appDeleteCommands-HIJNWSK7.js → appDeleteCommands-YS7UGMP3.js} +17 -16
- package/{appDeployCommands-XULV2ZN6.js → appDeployCommands-XIE5Z4BE.js} +17 -16
- package/{appDeployStatusCommands-ETY4Z7K6.js → appDeployStatusCommands-54UDVYET.js} +17 -16
- package/{appGetCommands-M253LKDA.js → appGetCommands-6XYLBCRN.js} +17 -16
- package/{appListCommands-XYFXJMNP.js → appListCommands-VEGH7SF5.js} +17 -16
- package/{authCommand-EVGFLAHO.js → authCommand-JIEOFHXW.js} +84 -9
- package/{chatQueueReduxAdapter-LSBTGZW2.js → chatQueueReduxAdapter-GPYCH5Z2.js} +5 -5
- package/chromeCommands-VOIRNJBL.js +499 -0
- package/chromeOpsCommands-M7DPCX2T.js +258 -0
- package/{chunk-FARB62OB.js → chunk-3VPDELAP.js} +42 -31
- package/{chunk-CS36XM4N.js → chunk-4SZ37KLL.js} +21 -9
- package/{chunk-FPTQQSS6.js → chunk-73BR2IQT.js} +23 -2
- package/{chunk-PYXL2CJL.js → chunk-7FWPLK4M.js} +1 -1
- package/{chunk-DSRXPQWA.js → chunk-7QVPPOEC.js} +1 -1
- package/{chunk-KIS76A2P.js → chunk-AX7RMXSH.js} +1 -1
- package/{chunk-OXY5PKLG.js → chunk-BKJO7LDP.js} +2 -2
- package/{chunk-Q6FF2MCK.js → chunk-BOYUESO7.js} +1 -1
- package/{chunk-GBPZKFYK.js → chunk-BZNGCVAW.js} +1 -1
- package/{chunk-EXMHJN7C.js → chunk-CADAR6QU.js} +1 -1
- package/{chunk-2QDDKFG5.js → chunk-CQ3WA2NE.js} +77 -0
- package/{chunk-B62OSA77.js → chunk-D6XYLSOS.js} +1 -1
- package/{chunk-TI4CCL34.js → chunk-DM4FBSWG.js} +3 -3
- package/{chunk-JWO3RQSH.js → chunk-DUJWWUGV.js} +1 -1
- package/{chunk-XGZM6BTX.js → chunk-EBKMQULC.js} +66 -120
- package/{chunk-ZLPA7K55.js → chunk-ETLZZQJE.js} +2 -2
- package/chunk-FMODTASJ.js +109 -0
- package/{chunk-T7PQFKJU.js → chunk-FNGAF7C4.js} +2 -2
- package/{chunk-MYU3MJCF.js → chunk-GCJ3IS5M.js} +0 -1
- package/{chunk-XPQJXIF5.js → chunk-GHEJJGJI.js} +125 -25
- package/{chunk-DFY6PUV4.js → chunk-HTMVBPOF.js} +7 -7
- package/{chunk-VOEW2KF3.js → chunk-IDGYOD2O.js} +59 -55
- package/{chunk-YCDWJX45.js → chunk-KC5FAHVS.js} +1 -1
- package/{chunk-2JCTE5UN.js → chunk-KEZNSFGD.js} +3 -3
- package/{chunk-I4UWPYBH.js → chunk-KRMWO2NN.js} +2 -2
- package/{chunk-PGSKWZCB.js → chunk-LHDV2QUI.js} +1 -1
- package/{chunk-UJ63UXGE.js → chunk-MXUSPS2N.js} +289 -2
- package/{chunk-3IT2PFHL.js → chunk-NB5SIWC4.js} +1 -1
- package/{chunk-HXAINXPQ.js → chunk-NFT2AOK5.js} +2 -2
- package/{chunk-AUKZOZFG.js → chunk-NRALD3CC.js} +2 -2
- package/{chunk-CJ23A7U4.js → chunk-PF6O3GR3.js} +533 -57
- package/{chunk-K7AG465Q.js → chunk-PZCTYKGU.js} +3 -1
- package/chunk-QCZX4FTW.js +242 -0
- package/{chunk-QBA5KMJI.js → chunk-RZOJRTKR.js} +29 -15
- package/{chunk-OH5WRY7G.js → chunk-T25L377S.js} +18 -6
- package/{chunk-CMH2SYHX.js → chunk-TMPLPCVX.js} +1 -1
- package/{chunk-3U3EA3BO.js → chunk-U7YP7ECK.js} +3 -3
- package/{chunk-AWPU7GXU.js → chunk-URWDSZRW.js} +2 -2
- package/{chunk-Q4OT2DC7.js → chunk-WL2RKIBF.js} +1 -1
- package/{chunk-IDZTNRP2.js → chunk-X7HHHIOZ.js} +10 -2
- package/{chunk-57VRXRLF.js → chunk-Y3NZYLPG.js} +1 -1
- package/{chunk-V3ZKNK5D.js → chunk-ZVN6I33J.js} +5 -5
- package/{codingSkills-E6KSDNSJ.js → codingSkills-7S6523WH.js} +2 -2
- package/{contentThunks-476Y6CFR.js → contentThunks-THSCADSK.js} +6 -6
- package/{createAgentAutomationAction-DN4SFTP5.js → createAgentAutomationAction-WGN3UQ5A.js} +6 -6
- package/{createDialogAction-2GS4JCMU.js → createDialogAction-3EN2NLH7.js} +8 -8
- package/{createPageAction-44WTUMZ5.js → createPageAction-4VK473QV.js} +6 -6
- package/{dialogCommands-PE5FEFJ5.js → dialogCommands-PS4NWYY7.js} +17 -16
- package/{dialogSlice-7HEVCJFT.js → dialogSlice-CLV7SVOZ.js} +5 -5
- package/{docCreateCommands-IPDFZVPG.js → docCreateCommands-4KANZJR6.js} +16 -15
- package/{docDeleteCommands-VQ4Y66CM.js → docDeleteCommands-F2S2TRUF.js} +17 -16
- package/{docReadCommands-PD33VV27.js → docReadCommands-B2WDPZQE.js} +16 -15
- package/{docStore-LJ7KNKFB.js → docStore-TDLCHWPF.js} +1 -1
- package/{docUpdateCommands-CGUQ2JY3.js → docUpdateCommands-E7TKHRIO.js} +16 -15
- package/{getPricing-HRMSOF3E.js → getPricing-QVTUQQTM.js} +2 -2
- package/{handleSendMessageAction-ETA5QZIN.js → handleSendMessageAction-AHL3ZHE4.js} +5 -5
- package/index.js +118 -54
- package/{machineCommands-INAP62WH.js → machineCommands-OTABVXOA.js} +28 -26
- package/{machineWsRunDispatch-MT7VRNKX.js → machineWsRunDispatch-V4EVQSMZ.js} +28 -26
- package/package.json +1 -1
- package/{readlineWorkspace-5TV6ES57.js → readlineWorkspace-IIT3FQ6I.js} +439 -117
- package/{runAgentClientLoop-2PGZSCET.js → runAgentClientLoop-7TQM7IAR.js} +18 -18
- package/{spaceCommands-Y47DDAQD.js → spaceCommands-FSYH7AL4.js} +16 -15
- package/{streamAgentChatTurn-I6FUM6RV.js → streamAgentChatTurn-6EF6TVFK.js} +22 -22
- package/{tools-KU4X5HGZ.js → tools-R3QNWWTD.js} +15 -13
- package/{tuiSummaryLlmCaller-J5BEPLW5.js → tuiSummaryLlmCaller-PWOXTCBF.js} +5 -5
- package/{updateCommands-AJYSD73Y.js → updateCommands-Y363MC3L.js} +2 -2
- package/{updateDialogTitleAction-E3SNB75W.js → updateDialogTitleAction-F3EUOWOB.js} +6 -6
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
readSseFrames,
|
|
9
9
|
streamSseDataValues,
|
|
10
10
|
throwIfChatCompletionStreamFailed
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-NFT2AOK5.js";
|
|
12
|
+
import {
|
|
13
|
+
DEVIN_CONNECT_URL
|
|
14
|
+
} from "./chunk-FMODTASJ.js";
|
|
12
15
|
import {
|
|
13
16
|
clipToolText,
|
|
14
17
|
hasImageInRuntimeMessages,
|
|
@@ -16,12 +19,13 @@ import {
|
|
|
16
19
|
resolveHistoricalToolContentCap,
|
|
17
20
|
resolveToolOutputProfile,
|
|
18
21
|
stripImagePartsFromMessages
|
|
19
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-AX7RMXSH.js";
|
|
20
23
|
import {
|
|
21
24
|
downgradeUnparsableToolCalls,
|
|
22
25
|
hasParsableObjectArguments,
|
|
26
|
+
repairTruncatedToolArguments,
|
|
23
27
|
sanitizeForOutbound
|
|
24
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-CQ3WA2NE.js";
|
|
25
29
|
import {
|
|
26
30
|
createThinkParserState,
|
|
27
31
|
createToolCallAccumulator,
|
|
@@ -39,7 +43,7 @@ import {
|
|
|
39
43
|
requiresBareImageUrl,
|
|
40
44
|
resolveToolGuidedSections,
|
|
41
45
|
toBareImageUrlMessages
|
|
42
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-ETLZZQJE.js";
|
|
43
47
|
import {
|
|
44
48
|
convertMessagesToResponsesInput,
|
|
45
49
|
extractReasoningFromResponseOutput,
|
|
@@ -50,15 +54,6 @@ import {
|
|
|
50
54
|
toOpenAiCompatibleMessages,
|
|
51
55
|
toResponsesTools
|
|
52
56
|
} from "./chunk-PUOC4YRO.js";
|
|
53
|
-
import {
|
|
54
|
-
getAntigravityUserAgent,
|
|
55
|
-
readAntigravityProjectId,
|
|
56
|
-
resolveAntigravityCloudCodeBaseUrl
|
|
57
|
-
} from "./chunk-PGSKWZCB.js";
|
|
58
|
-
import {
|
|
59
|
-
buildProviderAuthHeaders,
|
|
60
|
-
buildProviderExecutionPlan
|
|
61
|
-
} from "./chunk-CMH2SYHX.js";
|
|
62
57
|
import {
|
|
63
58
|
BRIDGE_STREAM_MAX_CHARS,
|
|
64
59
|
DEFAULT_READ_DIALOG_MAX_RESPONSE_CHARS,
|
|
@@ -72,7 +67,16 @@ import {
|
|
|
72
67
|
parseNoloWorkspaceToolArguments,
|
|
73
68
|
readTextStreamUpToChars,
|
|
74
69
|
resolveNoloDialogInput
|
|
75
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-ZVN6I33J.js";
|
|
71
|
+
import {
|
|
72
|
+
getAntigravityUserAgent,
|
|
73
|
+
readAntigravityProjectId,
|
|
74
|
+
resolveAntigravityCloudCodeBaseUrl
|
|
75
|
+
} from "./chunk-LHDV2QUI.js";
|
|
76
|
+
import {
|
|
77
|
+
buildProviderAuthHeaders,
|
|
78
|
+
buildProviderExecutionPlan
|
|
79
|
+
} from "./chunk-TMPLPCVX.js";
|
|
76
80
|
import {
|
|
77
81
|
buildDialogFallbackTitleFromUserInput
|
|
78
82
|
} from "./chunk-2MBTWINN.js";
|
|
@@ -86,7 +90,7 @@ import {
|
|
|
86
90
|
resolveEmptyAssistantFallbackMessage,
|
|
87
91
|
resolveEmptyAssistantOutcome,
|
|
88
92
|
resolveTruncatedReasoningTailLog
|
|
89
|
-
} from "./chunk-
|
|
93
|
+
} from "./chunk-7QVPPOEC.js";
|
|
90
94
|
import {
|
|
91
95
|
COMPACTION_SUMMARY_SCHEMA_VERSION,
|
|
92
96
|
COMPACTION_SUMMARY_SYSTEM_PROMPT,
|
|
@@ -13966,9 +13970,17 @@ ${reasoningTailLog}
|
|
|
13966
13970
|
try {
|
|
13967
13971
|
const rawPoisonArguments = toolCall.function?.arguments;
|
|
13968
13972
|
if (typeof rawPoisonArguments === "string" && rawPoisonArguments.trim() !== "" && !hasParsableObjectArguments(rawPoisonArguments)) {
|
|
13969
|
-
|
|
13970
|
-
|
|
13971
|
-
|
|
13973
|
+
const repairedArguments = repairTruncatedToolArguments(rawPoisonArguments);
|
|
13974
|
+
if (repairedArguments) {
|
|
13975
|
+
console.log(
|
|
13976
|
+
`[tool-args-repair] ${toolName}: \u8865\u5168\u88AB\u622A\u65AD\u7684 arguments\uFF08${rawPoisonArguments.length} \u2192 ${repairedArguments.length} \u5B57\u7B26\uFF0C\u5185\u5BB9\u96F6\u635F\u5931\uFF09`
|
|
13977
|
+
);
|
|
13978
|
+
toolCall.function.arguments = repairedArguments;
|
|
13979
|
+
} else {
|
|
13980
|
+
throw new Error(
|
|
13981
|
+
`\u6A21\u578B\u751F\u6210\u7684 tool_call arguments \u4E0D\u662F\u5408\u6CD5 JSON\uFF08\u7591\u4F3C\u4E0A\u6E38\u6D41\u5F0F\u622A\u65AD\uFF0C\u539F\u59CB\u957F\u5EA6 ${rawPoisonArguments.length}\uFF09\u3002\u8BF7\u91CD\u65B0\u5B8C\u6574\u8C03\u7528 ${toolName}\uFF0C\u786E\u4FDD arguments \u662F\u95ED\u5408\u7684 JSON \u5BF9\u8C61\uFF1B\u82E5\u56E0\u53C2\u6570\u8FC7\u957F\u88AB\u622A\u65AD\uFF0C\u5148\u7CBE\u7B80\u53C2\u6570\uFF08\u4E0D\u8981\u5185\u5D4C diff/\u65E5\u5FD7\u7B49\u5927\u6BB5\u6587\u672C\uFF0C\u6539\u4F20\u8DEF\u5F84\u8BA9\u5BF9\u65B9\u81EA\u884C\u8BFB\u53D6\uFF09\u518D\u91CD\u8BD5\u3002`
|
|
13982
|
+
);
|
|
13983
|
+
}
|
|
13972
13984
|
}
|
|
13973
13985
|
const writeTool = toolName === "writeFile" || toolName === "editFile";
|
|
13974
13986
|
if (writeTool && input.onActionGate && input.fileWriteGateEnabled !== false) {
|
|
@@ -15565,7 +15577,6 @@ var DEFAULT_LOCAL_TOOLS = /* @__PURE__ */ new Set([
|
|
|
15565
15577
|
"taskWait",
|
|
15566
15578
|
"taskLogs",
|
|
15567
15579
|
"taskStop",
|
|
15568
|
-
"tasks",
|
|
15569
15580
|
// Scheduling tools: forking/observing sub-agents is a declared capability
|
|
15570
15581
|
// of capable agents, and the blast radius is strictly narrower than
|
|
15571
15582
|
// execShell (already default-enabled). Requiring an env allowlist for these
|
|
@@ -16201,6 +16212,24 @@ var ProcessTaskEventLog = class {
|
|
|
16201
16212
|
};
|
|
16202
16213
|
|
|
16203
16214
|
// packages/agent-runtime/processRegistry.ts
|
|
16215
|
+
function toProcessTaskView(record) {
|
|
16216
|
+
const capsule = record.resultCapsule;
|
|
16217
|
+
return {
|
|
16218
|
+
taskId: record.taskId,
|
|
16219
|
+
pid: record.pid,
|
|
16220
|
+
pgid: record.pgid,
|
|
16221
|
+
command: record.command,
|
|
16222
|
+
label: record.label,
|
|
16223
|
+
startedAt: record.startedAt,
|
|
16224
|
+
status: record.status,
|
|
16225
|
+
...record.exitCode !== void 0 ? { exitCode: record.exitCode } : {},
|
|
16226
|
+
persist: record.persist,
|
|
16227
|
+
promoted: record.promoted,
|
|
16228
|
+
transient: record.transient,
|
|
16229
|
+
...capsule?.durationMs !== void 0 ? { durationMs: capsule.durationMs } : {},
|
|
16230
|
+
...capsule?.spill ? { outputRef: capsule.spill.displayPath } : {}
|
|
16231
|
+
};
|
|
16232
|
+
}
|
|
16204
16233
|
var taskIdCounter = 0;
|
|
16205
16234
|
function mintTaskId(pid) {
|
|
16206
16235
|
taskIdCounter += 1;
|
|
@@ -16256,8 +16285,9 @@ var ProcessRegistry = class {
|
|
|
16256
16285
|
startedAt: Date.now(),
|
|
16257
16286
|
status: "running",
|
|
16258
16287
|
persist: proc.persist ?? false,
|
|
16259
|
-
promoted: false,
|
|
16260
|
-
transient: proc.transient ?? false
|
|
16288
|
+
promoted: proc.promoted ?? false,
|
|
16289
|
+
transient: proc.transient ?? false,
|
|
16290
|
+
owner: proc.owner ?? null
|
|
16261
16291
|
};
|
|
16262
16292
|
this.processes.set(proc.pid, record);
|
|
16263
16293
|
this.byTaskId.set(record.taskId, proc.pid);
|
|
@@ -16352,7 +16382,8 @@ var ProcessRegistry = class {
|
|
|
16352
16382
|
pid,
|
|
16353
16383
|
label: item.label,
|
|
16354
16384
|
command: item.command,
|
|
16355
|
-
status: "stopped"
|
|
16385
|
+
status: "stopped",
|
|
16386
|
+
promoted: item.promoted
|
|
16356
16387
|
});
|
|
16357
16388
|
return true;
|
|
16358
16389
|
}
|
|
@@ -16381,15 +16412,17 @@ var ProcessRegistry = class {
|
|
|
16381
16412
|
pid: item.pid,
|
|
16382
16413
|
label: item.label,
|
|
16383
16414
|
command: item.command,
|
|
16384
|
-
status: "stopped"
|
|
16415
|
+
status: "stopped",
|
|
16416
|
+
promoted: item.promoted
|
|
16385
16417
|
});
|
|
16386
16418
|
}
|
|
16387
16419
|
}
|
|
16388
16420
|
}
|
|
16389
|
-
markExited(pid, exitCode) {
|
|
16421
|
+
markExited(pid, exitCode, resultCapsule) {
|
|
16390
16422
|
const item = this.processes.get(pid);
|
|
16391
16423
|
if (item && item.status === "running") {
|
|
16392
16424
|
item.exitCode = exitCode;
|
|
16425
|
+
if (resultCapsule) item.resultCapsule = resultCapsule;
|
|
16393
16426
|
item.status = exitCode === 0 ? "exited" : "failed";
|
|
16394
16427
|
this.eventLog.append({
|
|
16395
16428
|
taskId: item.taskId,
|
|
@@ -16403,7 +16436,9 @@ var ProcessRegistry = class {
|
|
|
16403
16436
|
label: item.label,
|
|
16404
16437
|
command: item.command,
|
|
16405
16438
|
status: item.status,
|
|
16406
|
-
exitCode
|
|
16439
|
+
exitCode,
|
|
16440
|
+
promoted: item.promoted,
|
|
16441
|
+
...item.resultCapsule ? { resultCapsule: item.resultCapsule } : {}
|
|
16407
16442
|
});
|
|
16408
16443
|
}
|
|
16409
16444
|
}
|
|
@@ -16444,9 +16479,84 @@ function getProcessRegistry() {
|
|
|
16444
16479
|
return registry;
|
|
16445
16480
|
}
|
|
16446
16481
|
|
|
16482
|
+
// packages/agent-runtime/processOwnership.ts
|
|
16483
|
+
var asNonEmptyString = (value) => {
|
|
16484
|
+
if (typeof value !== "string") return null;
|
|
16485
|
+
const trimmed = value.trim();
|
|
16486
|
+
return trimmed ? trimmed : null;
|
|
16487
|
+
};
|
|
16488
|
+
function readProcessOwner(runtimeContext) {
|
|
16489
|
+
if (!runtimeContext || typeof runtimeContext !== "object") return null;
|
|
16490
|
+
const dialogId = asNonEmptyString(runtimeContext.dialogId) ?? asNonEmptyString(runtimeContext.parentThreadId);
|
|
16491
|
+
if (!dialogId) return null;
|
|
16492
|
+
const turnId = asNonEmptyString(runtimeContext.turnId);
|
|
16493
|
+
const ownerId = asNonEmptyString(runtimeContext.ownerId);
|
|
16494
|
+
return {
|
|
16495
|
+
dialogId,
|
|
16496
|
+
...turnId ? { turnId } : {},
|
|
16497
|
+
...ownerId ? { ownerId } : {}
|
|
16498
|
+
};
|
|
16499
|
+
}
|
|
16500
|
+
|
|
16447
16501
|
// packages/agent-runtime/workspaceShell.ts
|
|
16448
16502
|
import { resolve as resolve3 } from "node:path";
|
|
16449
16503
|
import { spawn as spawnChildProcess2 } from "node:child_process";
|
|
16504
|
+
|
|
16505
|
+
// packages/agent-runtime/processTaskResult.ts
|
|
16506
|
+
var PROCESS_RESULT_CAPSULE_TAIL_CHARS = 4e3;
|
|
16507
|
+
var PROCESS_RESULT_CAPSULE_SPILL_THRESHOLD_CHARS = 2e4;
|
|
16508
|
+
function tailText(value, maxChars) {
|
|
16509
|
+
if (value.length <= maxChars) return { text: value, truncated: false };
|
|
16510
|
+
return { text: value.slice(-maxChars), truncated: true };
|
|
16511
|
+
}
|
|
16512
|
+
function formatCapsuleStream(name, value) {
|
|
16513
|
+
return value.trim() ? `${name}:
|
|
16514
|
+
${value.replace(/\n+$/, "")}` : "";
|
|
16515
|
+
}
|
|
16516
|
+
function buildProcessTaskResultCapsule(args2) {
|
|
16517
|
+
const tailChars = args2.tailChars ?? PROCESS_RESULT_CAPSULE_TAIL_CHARS;
|
|
16518
|
+
const spillThresholdChars = args2.spillThresholdChars ?? PROCESS_RESULT_CAPSULE_SPILL_THRESHOLD_CHARS;
|
|
16519
|
+
const stdout = typeof args2.stdout === "string" ? args2.stdout : "";
|
|
16520
|
+
const stderr = typeof args2.stderr === "string" ? args2.stderr : "";
|
|
16521
|
+
const exitCode = args2.exitCode;
|
|
16522
|
+
const captureError = args2.captureError?.trim() || void 0;
|
|
16523
|
+
const durationMs = typeof args2.startedAt === "number" && Number.isFinite(args2.startedAt) ? Math.max(0, (args2.endedAt ?? Date.now()) - args2.startedAt) : void 0;
|
|
16524
|
+
const stdoutTail = tailText(stdout, tailChars);
|
|
16525
|
+
const stderrTail = tailText(stderr, tailChars);
|
|
16526
|
+
const inlineSize = stdout.length + stderr.length;
|
|
16527
|
+
const inlineTruncated = stdoutTail.truncated || stderrTail.truncated;
|
|
16528
|
+
const shouldSpill = inlineTruncated || inlineSize > spillThresholdChars;
|
|
16529
|
+
let spill;
|
|
16530
|
+
if (shouldSpill) {
|
|
16531
|
+
try {
|
|
16532
|
+
const result4 = spillToolOutput({
|
|
16533
|
+
content: [
|
|
16534
|
+
formatCapsuleStream("stdout", stdout),
|
|
16535
|
+
formatCapsuleStream("stderr", stderr)
|
|
16536
|
+
].filter(Boolean).join("\n\n"),
|
|
16537
|
+
toolName: "execShell",
|
|
16538
|
+
...args2.workspaceRoot !== void 0 ? { workspaceRoot: args2.workspaceRoot } : {}
|
|
16539
|
+
});
|
|
16540
|
+
spill = {
|
|
16541
|
+
displayPath: result4.displayPath,
|
|
16542
|
+
totalChars: result4.totalChars,
|
|
16543
|
+
totalLines: result4.totalLines
|
|
16544
|
+
};
|
|
16545
|
+
} catch {
|
|
16546
|
+
}
|
|
16547
|
+
}
|
|
16548
|
+
return {
|
|
16549
|
+
stdout: stdoutTail.text,
|
|
16550
|
+
stderr: stderrTail.text,
|
|
16551
|
+
exitCode,
|
|
16552
|
+
...durationMs !== void 0 ? { durationMs } : {},
|
|
16553
|
+
...captureError ? { captureError } : {},
|
|
16554
|
+
truncated: inlineTruncated || Boolean(captureError),
|
|
16555
|
+
...spill ? { spill } : {}
|
|
16556
|
+
};
|
|
16557
|
+
}
|
|
16558
|
+
|
|
16559
|
+
// packages/agent-runtime/workspaceShell.ts
|
|
16450
16560
|
var EXEC_SHELL_TIMEOUT_ENV = "NOLO_EXEC_SHELL_TIMEOUT_MS";
|
|
16451
16561
|
var EXEC_SHELL_DETACH_ENV = "NOLO_EXEC_SHELL_DETACH_MS";
|
|
16452
16562
|
var DEFAULT_EXEC_SHELL_DETACH_MS = 12e4;
|
|
@@ -16826,6 +16936,15 @@ ${stderr.trim()}`, "exitCode: 127"].filter(Boolean).join("\n\n"),
|
|
|
16826
16936
|
)
|
|
16827
16937
|
};
|
|
16828
16938
|
}
|
|
16939
|
+
function stdoutPromiseResult(promise3) {
|
|
16940
|
+
return promise3.then(
|
|
16941
|
+
(value) => ({ value }),
|
|
16942
|
+
(error) => ({
|
|
16943
|
+
value: "",
|
|
16944
|
+
error: error instanceof Error ? error.message : String(error)
|
|
16945
|
+
})
|
|
16946
|
+
);
|
|
16947
|
+
}
|
|
16829
16948
|
async function runWorkspaceCommand(args2) {
|
|
16830
16949
|
const timeoutMs = asOptionalPositiveFiniteNumber(args2.timeoutMs);
|
|
16831
16950
|
const detached = process.platform !== "win32";
|
|
@@ -16857,8 +16976,10 @@ async function runWorkspaceCommand(args2) {
|
|
|
16857
16976
|
// Foreground grace-period envelope: not a user-visible background task
|
|
16858
16977
|
// until promote() flips the marker on timeout detach (see
|
|
16859
16978
|
// listBackground). Keeps the status line / /procs / /stop semantics
|
|
16860
|
-
// identical to pre-Phase-0.
|
|
16861
|
-
|
|
16979
|
+
// identical to pre-Phase-0. Ownership rides along so the promoted record
|
|
16980
|
+
// stays attributable without any terminal-time inference.
|
|
16981
|
+
transient: true,
|
|
16982
|
+
owner: args2.owner ?? null
|
|
16862
16983
|
});
|
|
16863
16984
|
}
|
|
16864
16985
|
const exitPromise = waitForNodeProcessExit(proc);
|
|
@@ -16882,8 +17003,8 @@ async function runWorkspaceCommand(args2) {
|
|
|
16882
17003
|
process.removeListener("SIGINT", cleanupChildOnHostSignal);
|
|
16883
17004
|
};
|
|
16884
17005
|
exitPromise.then(detachSignalCleanup, detachSignalCleanup);
|
|
16885
|
-
const
|
|
16886
|
-
const
|
|
17006
|
+
const stdoutCapture = stdoutPromiseResult(readNodeStream(proc.stdout));
|
|
17007
|
+
const stderrCapture = stdoutPromiseResult(readNodeStream(proc.stderr));
|
|
16887
17008
|
const killChild = (signal) => {
|
|
16888
17009
|
if (detached && typeof proc.pid === "number") {
|
|
16889
17010
|
try {
|
|
@@ -16971,11 +17092,41 @@ async function runWorkspaceCommand(args2) {
|
|
|
16971
17092
|
const pid = typeof proc.pid === "number" ? proc.pid : 0;
|
|
16972
17093
|
const pgid = pid;
|
|
16973
17094
|
const promoted = registry2.promote(pid);
|
|
16974
|
-
const envelope = promoted ?? registry2.add({
|
|
17095
|
+
const envelope = promoted ?? registry2.add({
|
|
17096
|
+
pid,
|
|
17097
|
+
pgid,
|
|
17098
|
+
command: args2.command.join(" "),
|
|
17099
|
+
label,
|
|
17100
|
+
promoted: true,
|
|
17101
|
+
owner: args2.owner ?? null
|
|
17102
|
+
});
|
|
16975
17103
|
const taskId = envelope.taskId;
|
|
16976
17104
|
proc.on("close", (code) => {
|
|
16977
17105
|
detachSignalCleanup();
|
|
16978
|
-
|
|
17106
|
+
const exitCode2 = code ?? 1;
|
|
17107
|
+
void (async () => {
|
|
17108
|
+
const [stdoutResult, stderrResult] = await Promise.all([
|
|
17109
|
+
stdoutCapture,
|
|
17110
|
+
stderrCapture
|
|
17111
|
+
]);
|
|
17112
|
+
const stdout2 = stdoutResult.value;
|
|
17113
|
+
const stderr2 = stderrResult.value;
|
|
17114
|
+
let capsule;
|
|
17115
|
+
try {
|
|
17116
|
+
capsule = buildProcessTaskResultCapsule({
|
|
17117
|
+
stdout: stdout2,
|
|
17118
|
+
stderr: stderr2,
|
|
17119
|
+
exitCode: exitCode2,
|
|
17120
|
+
// Duration is measured from the registry envelope's startedAt
|
|
17121
|
+
// (spawn moment), not from the detach moment.
|
|
17122
|
+
startedAt: registry2.get(pid)?.startedAt,
|
|
17123
|
+
workspaceRoot: args2.workspaceRoot,
|
|
17124
|
+
captureError: [stdoutResult.error, stderrResult.error].filter(Boolean).join("; ")
|
|
17125
|
+
});
|
|
17126
|
+
} catch {
|
|
17127
|
+
}
|
|
17128
|
+
registry2.markExited(pid, exitCode2, capsule);
|
|
17129
|
+
})();
|
|
16979
17130
|
});
|
|
16980
17131
|
const immediate = effectiveDetachMs === 0;
|
|
16981
17132
|
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})`;
|
|
@@ -16999,10 +17150,13 @@ Use listProcesses to inspect or stop it.`,
|
|
|
16999
17150
|
})
|
|
17000
17151
|
};
|
|
17001
17152
|
}
|
|
17002
|
-
const [
|
|
17003
|
-
|
|
17004
|
-
|
|
17153
|
+
const [stdoutCaptureResult, stderrCaptureResult] = await Promise.all([
|
|
17154
|
+
stdoutCapture,
|
|
17155
|
+
stderrCapture
|
|
17005
17156
|
]);
|
|
17157
|
+
const stdout = stdoutCaptureResult.value;
|
|
17158
|
+
const rawStderr = stderrCaptureResult.value;
|
|
17159
|
+
const streamCaptureError = [stdoutCaptureResult.error, stderrCaptureResult.error].filter(Boolean).join("; ");
|
|
17006
17160
|
const exitCode = aborted ? 130 : timedOut ? 124 : Number(raceWinner);
|
|
17007
17161
|
if (typeof proc.pid === "number") {
|
|
17008
17162
|
registry2.completeTransient(proc.pid, exitCode);
|
|
@@ -17378,7 +17532,11 @@ var execShellCapability = {
|
|
|
17378
17532
|
commandPrefix: ctx.commandPrefix,
|
|
17379
17533
|
abortSignal: ctx.abortSignal,
|
|
17380
17534
|
detachMs: isImmediateDetachShellCommand({ command }) ? 0 : ctx.detachMs,
|
|
17381
|
-
stdin: typeof normalized.input === "string" ? normalized.input : void 0
|
|
17535
|
+
stdin: typeof normalized.input === "string" ? normalized.input : void 0,
|
|
17536
|
+
// Ownership of the turn that invoked this command: an auto-detached
|
|
17537
|
+
// command keeps its parent dialog so its terminal can resume that
|
|
17538
|
+
// conversation (see processOwnership.ts). Absent ctx.owner = unowned.
|
|
17539
|
+
owner: ctx.owner ?? null
|
|
17382
17540
|
});
|
|
17383
17541
|
return {
|
|
17384
17542
|
content: result4.content,
|
|
@@ -17417,7 +17575,6 @@ var WORKSPACE_TOOL_NAMES = [
|
|
|
17417
17575
|
"taskWait",
|
|
17418
17576
|
"taskLogs",
|
|
17419
17577
|
"taskStop",
|
|
17420
|
-
"tasks",
|
|
17421
17578
|
"openDesktopPreview"
|
|
17422
17579
|
];
|
|
17423
17580
|
var SHELL_TOOL_NAMES = [
|
|
@@ -17426,8 +17583,7 @@ var SHELL_TOOL_NAMES = [
|
|
|
17426
17583
|
"listProcesses",
|
|
17427
17584
|
"taskWait",
|
|
17428
17585
|
"taskLogs",
|
|
17429
|
-
"taskStop"
|
|
17430
|
-
"tasks"
|
|
17586
|
+
"taskStop"
|
|
17431
17587
|
];
|
|
17432
17588
|
var WORKSPACE_TOOL_NAME_SET = new Set(WORKSPACE_TOOL_NAMES);
|
|
17433
17589
|
function buildWorkspacePathProperty() {
|
|
@@ -17739,19 +17895,6 @@ function buildTaskStopTool() {
|
|
|
17739
17895
|
}
|
|
17740
17896
|
};
|
|
17741
17897
|
}
|
|
17742
|
-
function buildTasksTool() {
|
|
17743
|
-
return {
|
|
17744
|
-
type: "function",
|
|
17745
|
-
function: {
|
|
17746
|
-
name: "tasks",
|
|
17747
|
-
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.",
|
|
17748
|
-
parameters: {
|
|
17749
|
-
type: "object",
|
|
17750
|
-
properties: {}
|
|
17751
|
-
}
|
|
17752
|
-
}
|
|
17753
|
-
};
|
|
17754
|
-
}
|
|
17755
17898
|
function buildWorkspaceToolDefinition(toolName) {
|
|
17756
17899
|
if (toolName === "readFile") {
|
|
17757
17900
|
return buildReadWorkspaceFileTool();
|
|
@@ -17773,7 +17916,6 @@ function buildWorkspaceToolDefinition(toolName) {
|
|
|
17773
17916
|
if (toolName === "taskWait") return buildTaskWaitTool();
|
|
17774
17917
|
if (toolName === "taskLogs") return buildTaskLogsTool();
|
|
17775
17918
|
if (toolName === "taskStop") return buildTaskStopTool();
|
|
17776
|
-
if (toolName === "tasks") return buildTasksTool();
|
|
17777
17919
|
return null;
|
|
17778
17920
|
}
|
|
17779
17921
|
function filterDeclaredWorkspaceToolNames(args2) {
|
|
@@ -18790,7 +18932,10 @@ async function execShellTool(args2) {
|
|
|
18790
18932
|
enableDestructiveShellGuard: args2.enableDestructiveShellGuard,
|
|
18791
18933
|
confirmDestructiveAction: args2.confirmDestructiveAction,
|
|
18792
18934
|
blockDestructiveWithoutConfirmation: args2.blockDestructiveWithoutConfirmation,
|
|
18793
|
-
onInvoke: args2.onInvoke
|
|
18935
|
+
onInvoke: args2.onInvoke,
|
|
18936
|
+
// Ownership is captured here (launch time) from the host-injected turn
|
|
18937
|
+
// context, never re-derived when the task later reaches a terminal state.
|
|
18938
|
+
owner: readProcessOwner(args2.call.runtimeContext)
|
|
18794
18939
|
}
|
|
18795
18940
|
);
|
|
18796
18941
|
}
|
|
@@ -18830,7 +18975,16 @@ async function launchProcessTool(args2) {
|
|
|
18830
18975
|
}
|
|
18831
18976
|
const pgid = detached ? pid : pid;
|
|
18832
18977
|
const registry2 = getProcessRegistry();
|
|
18833
|
-
const envelope = registry2.add({
|
|
18978
|
+
const envelope = registry2.add({
|
|
18979
|
+
pid,
|
|
18980
|
+
pgid,
|
|
18981
|
+
command,
|
|
18982
|
+
label,
|
|
18983
|
+
persist,
|
|
18984
|
+
// Launch-time ownership: the dialog/turn that asked for this background
|
|
18985
|
+
// task. Terminal-time resume reads this record, never "current dialog".
|
|
18986
|
+
owner: readProcessOwner(args2.call.runtimeContext)
|
|
18987
|
+
});
|
|
18834
18988
|
const cleanupChildOnHostSignal = (signal) => {
|
|
18835
18989
|
try {
|
|
18836
18990
|
if (detached) {
|
|
@@ -18870,7 +19024,7 @@ async function launchProcessTool(args2) {
|
|
|
18870
19024
|
};
|
|
18871
19025
|
}
|
|
18872
19026
|
async function listProcessesTool(args2) {
|
|
18873
|
-
const list = getProcessRegistry().list();
|
|
19027
|
+
const list = getProcessRegistry().list().map(toProcessTaskView);
|
|
18874
19028
|
return {
|
|
18875
19029
|
content: JSON.stringify(list),
|
|
18876
19030
|
metadata: {
|
|
@@ -19227,7 +19381,7 @@ function buildLoadSkillExecutor(args2) {
|
|
|
19227
19381
|
const { resolveSkillByName } = await import("./skillDiscovery-CYUCJMAG.js");
|
|
19228
19382
|
const resolved = resolveSkillByName(args2.cwd, name);
|
|
19229
19383
|
if (!resolved) {
|
|
19230
|
-
const { resolveCodingBuiltinSlug, buildCodingSkillContentBySlug } = await import("./codingSkills-
|
|
19384
|
+
const { resolveCodingBuiltinSlug, buildCodingSkillContentBySlug } = await import("./codingSkills-7S6523WH.js");
|
|
19231
19385
|
const builtinSlug = resolveCodingBuiltinSlug(name);
|
|
19232
19386
|
if (builtinSlug) {
|
|
19233
19387
|
const body = buildCodingSkillContentBySlug(builtinSlug);
|
|
@@ -20006,6 +20160,326 @@ async function fetchAntigravityCloudCodeCompletion(args2) {
|
|
|
20006
20160
|
return normalized;
|
|
20007
20161
|
}
|
|
20008
20162
|
|
|
20163
|
+
// packages/agent-runtime/devin/devinProvider.ts
|
|
20164
|
+
import { randomBytes, randomUUID as randomUUID2 } from "node:crypto";
|
|
20165
|
+
var CLIENT_NAME = "chisel";
|
|
20166
|
+
var CLIENT_VERSION = "2026.8.18";
|
|
20167
|
+
function writeVarint(fieldNum, value) {
|
|
20168
|
+
const tag = fieldNum << 3 | 0;
|
|
20169
|
+
const bytes = [];
|
|
20170
|
+
let t = tag;
|
|
20171
|
+
while (t >= 128) {
|
|
20172
|
+
bytes.push(t & 127 | 128);
|
|
20173
|
+
t >>>= 7;
|
|
20174
|
+
}
|
|
20175
|
+
bytes.push(t);
|
|
20176
|
+
let v = value;
|
|
20177
|
+
while (v >= 128) {
|
|
20178
|
+
bytes.push(v & 127 | 128);
|
|
20179
|
+
v >>>= 7;
|
|
20180
|
+
}
|
|
20181
|
+
bytes.push(v);
|
|
20182
|
+
return Buffer.from(bytes);
|
|
20183
|
+
}
|
|
20184
|
+
function writeLengthDelimited(fieldNum, content) {
|
|
20185
|
+
const tag = fieldNum << 3 | 2;
|
|
20186
|
+
const tagBytes = [];
|
|
20187
|
+
let t = tag;
|
|
20188
|
+
while (t >= 128) {
|
|
20189
|
+
tagBytes.push(t & 127 | 128);
|
|
20190
|
+
t >>>= 7;
|
|
20191
|
+
}
|
|
20192
|
+
tagBytes.push(t);
|
|
20193
|
+
const lenBytes = [];
|
|
20194
|
+
let len = content.length;
|
|
20195
|
+
while (len >= 128) {
|
|
20196
|
+
lenBytes.push(len & 127 | 128);
|
|
20197
|
+
len >>>= 7;
|
|
20198
|
+
}
|
|
20199
|
+
lenBytes.push(len);
|
|
20200
|
+
return Buffer.concat([Buffer.from(tagBytes), Buffer.from(lenBytes), content]);
|
|
20201
|
+
}
|
|
20202
|
+
function writeStringField(fieldNum, str) {
|
|
20203
|
+
return writeLengthDelimited(fieldNum, Buffer.from(str, "utf8"));
|
|
20204
|
+
}
|
|
20205
|
+
function writeMessageField(fieldNum, message) {
|
|
20206
|
+
return writeLengthDelimited(fieldNum, message);
|
|
20207
|
+
}
|
|
20208
|
+
function generateFingerprint() {
|
|
20209
|
+
return randomBytes(366).toString("hex");
|
|
20210
|
+
}
|
|
20211
|
+
function encodeDevinClientMetadata(token) {
|
|
20212
|
+
return Buffer.concat([
|
|
20213
|
+
writeStringField(1, CLIENT_NAME),
|
|
20214
|
+
writeStringField(2, CLIENT_VERSION),
|
|
20215
|
+
writeStringField(3, token),
|
|
20216
|
+
writeStringField(4, "en"),
|
|
20217
|
+
writeStringField(5, process.platform === "win32" ? "windows" : "linux"),
|
|
20218
|
+
writeStringField(7, CLIENT_VERSION),
|
|
20219
|
+
writeStringField(12, CLIENT_NAME),
|
|
20220
|
+
writeStringField(31, generateFingerprint())
|
|
20221
|
+
]);
|
|
20222
|
+
}
|
|
20223
|
+
function encodeDevinChatMessage(msg) {
|
|
20224
|
+
const source = msg.role === "assistant" ? 2 : 1;
|
|
20225
|
+
return Buffer.concat([
|
|
20226
|
+
writeStringField(1, randomUUID2()),
|
|
20227
|
+
writeVarint(2, source),
|
|
20228
|
+
writeStringField(3, msg.text)
|
|
20229
|
+
]);
|
|
20230
|
+
}
|
|
20231
|
+
function writeFixed64Field(fieldNum, val) {
|
|
20232
|
+
const b = Buffer.alloc(8);
|
|
20233
|
+
b.writeDoubleLE(val, 0);
|
|
20234
|
+
const tag = fieldNum << 3 | 1;
|
|
20235
|
+
const tagBytes = [];
|
|
20236
|
+
let t = tag;
|
|
20237
|
+
while (t >= 128) {
|
|
20238
|
+
tagBytes.push(t & 127 | 128);
|
|
20239
|
+
t >>>= 7;
|
|
20240
|
+
}
|
|
20241
|
+
tagBytes.push(t);
|
|
20242
|
+
return Buffer.concat([Buffer.from(tagBytes), b]);
|
|
20243
|
+
}
|
|
20244
|
+
function buildCompletionConfig(params) {
|
|
20245
|
+
const maxTokens = params?.maxTokens ?? 4096;
|
|
20246
|
+
const temp = params?.temperature ?? 0.4;
|
|
20247
|
+
const topP = params?.topP ?? 0.95;
|
|
20248
|
+
return Buffer.concat([
|
|
20249
|
+
writeVarint(1, 1),
|
|
20250
|
+
writeVarint(2, maxTokens),
|
|
20251
|
+
writeVarint(3, 128e3),
|
|
20252
|
+
writeFixed64Field(5, temp),
|
|
20253
|
+
writeVarint(7, 40),
|
|
20254
|
+
writeFixed64Field(8, topP)
|
|
20255
|
+
]);
|
|
20256
|
+
}
|
|
20257
|
+
function buildGetChatMessageRequest(params) {
|
|
20258
|
+
const { token, messages, model } = params;
|
|
20259
|
+
const metadata = encodeDevinClientMetadata(token);
|
|
20260
|
+
let systemPrompt = "";
|
|
20261
|
+
const filteredMessages = [];
|
|
20262
|
+
for (const m of messages) {
|
|
20263
|
+
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") : "";
|
|
20264
|
+
if (m.role === "system") {
|
|
20265
|
+
systemPrompt = systemPrompt ? `${systemPrompt}
|
|
20266
|
+
|
|
20267
|
+
${text}` : text;
|
|
20268
|
+
} else if (m.role === "user" || m.role === "assistant") {
|
|
20269
|
+
filteredMessages.push({ role: m.role, text });
|
|
20270
|
+
}
|
|
20271
|
+
}
|
|
20272
|
+
const coalesced = [];
|
|
20273
|
+
for (const item of filteredMessages) {
|
|
20274
|
+
const last = coalesced[coalesced.length - 1];
|
|
20275
|
+
if (last && last.role === item.role) {
|
|
20276
|
+
last.text = `${last.text}
|
|
20277
|
+
|
|
20278
|
+
${item.text}`;
|
|
20279
|
+
} else {
|
|
20280
|
+
coalesced.push({ ...item });
|
|
20281
|
+
}
|
|
20282
|
+
}
|
|
20283
|
+
const chatMessageBuffers = coalesced.map((m) => encodeDevinChatMessage(m));
|
|
20284
|
+
const completionConfig = buildCompletionConfig();
|
|
20285
|
+
const modelConfig = Buffer.concat([
|
|
20286
|
+
writeStringField(1, randomUUID2()),
|
|
20287
|
+
writeVarint(2, 1),
|
|
20288
|
+
writeVarint(3, 4)
|
|
20289
|
+
]);
|
|
20290
|
+
return Buffer.concat([
|
|
20291
|
+
writeMessageField(1, metadata),
|
|
20292
|
+
writeStringField(2, systemPrompt),
|
|
20293
|
+
...chatMessageBuffers.map((b) => writeMessageField(3, b)),
|
|
20294
|
+
writeVarint(7, 5),
|
|
20295
|
+
writeMessageField(8, completionConfig),
|
|
20296
|
+
writeMessageField(15, modelConfig),
|
|
20297
|
+
writeStringField(16, randomUUID2()),
|
|
20298
|
+
writeVarint(20, 1),
|
|
20299
|
+
writeStringField(21, model)
|
|
20300
|
+
]);
|
|
20301
|
+
}
|
|
20302
|
+
function buildDevinConnectFrame(payload, flags = 0) {
|
|
20303
|
+
const header = Buffer.alloc(5);
|
|
20304
|
+
header[0] = flags & 255;
|
|
20305
|
+
header.writeUInt32BE(payload.length, 1);
|
|
20306
|
+
return Buffer.concat([header, payload]);
|
|
20307
|
+
}
|
|
20308
|
+
function parseDevinConnectFrames(buffer3) {
|
|
20309
|
+
const frames = [];
|
|
20310
|
+
let offset = 0;
|
|
20311
|
+
while (offset + 5 <= buffer3.length) {
|
|
20312
|
+
const flags = buffer3[offset];
|
|
20313
|
+
const length = buffer3.readUInt32BE(offset + 1);
|
|
20314
|
+
if (offset + 5 + length > buffer3.length) {
|
|
20315
|
+
break;
|
|
20316
|
+
}
|
|
20317
|
+
const payload = buffer3.subarray(offset + 5, offset + 5 + length);
|
|
20318
|
+
frames.push({ flags, payload });
|
|
20319
|
+
offset += 5 + length;
|
|
20320
|
+
}
|
|
20321
|
+
return {
|
|
20322
|
+
frames,
|
|
20323
|
+
remainder: buffer3.subarray(offset)
|
|
20324
|
+
};
|
|
20325
|
+
}
|
|
20326
|
+
function parseDevinConnectTrailer(payload) {
|
|
20327
|
+
const text = payload.toString("utf8").trim();
|
|
20328
|
+
if (!text || text === "{}") return null;
|
|
20329
|
+
try {
|
|
20330
|
+
const parsed = JSON.parse(text);
|
|
20331
|
+
if (!parsed.error) {
|
|
20332
|
+
return new Error(`Devin Connect invalid terminal trailer: ${text}`);
|
|
20333
|
+
}
|
|
20334
|
+
const code = typeof parsed.error.code === "string" ? parsed.error.code : "unknown";
|
|
20335
|
+
const message = typeof parsed.error.message === "string" ? parsed.error.message : "Unknown error";
|
|
20336
|
+
return new Error(`Devin Connect upstream error ${code}: ${message}`);
|
|
20337
|
+
} catch {
|
|
20338
|
+
return new Error(`Devin Connect invalid terminal trailer: ${text}`);
|
|
20339
|
+
}
|
|
20340
|
+
}
|
|
20341
|
+
function decodeDevinResponsePayload(payload) {
|
|
20342
|
+
let offset = 0;
|
|
20343
|
+
let content = "";
|
|
20344
|
+
let reasoning = "";
|
|
20345
|
+
let finishReason = null;
|
|
20346
|
+
const events = [];
|
|
20347
|
+
while (offset < payload.length) {
|
|
20348
|
+
let tag = 0;
|
|
20349
|
+
let shift = 0;
|
|
20350
|
+
while (offset < payload.length) {
|
|
20351
|
+
const b = payload[offset++];
|
|
20352
|
+
tag |= (b & 127) << shift;
|
|
20353
|
+
if (!(b & 128)) break;
|
|
20354
|
+
shift += 7;
|
|
20355
|
+
}
|
|
20356
|
+
const fieldNum = tag >>> 3;
|
|
20357
|
+
const wireType = tag & 7;
|
|
20358
|
+
if (wireType === 0) {
|
|
20359
|
+
let val = 0;
|
|
20360
|
+
let s = 0;
|
|
20361
|
+
while (offset < payload.length) {
|
|
20362
|
+
const b = payload[offset++];
|
|
20363
|
+
val |= (b & 127) << s;
|
|
20364
|
+
if (!(b & 128)) break;
|
|
20365
|
+
s += 7;
|
|
20366
|
+
}
|
|
20367
|
+
if (fieldNum === 5) {
|
|
20368
|
+
finishReason = val === 2 ? "stop" : "length";
|
|
20369
|
+
}
|
|
20370
|
+
} else if (wireType === 2) {
|
|
20371
|
+
let len = 0;
|
|
20372
|
+
let s = 0;
|
|
20373
|
+
while (offset < payload.length) {
|
|
20374
|
+
const b = payload[offset++];
|
|
20375
|
+
len |= (b & 127) << s;
|
|
20376
|
+
if (!(b & 128)) break;
|
|
20377
|
+
s += 7;
|
|
20378
|
+
}
|
|
20379
|
+
const valBytes = payload.subarray(offset, offset + len);
|
|
20380
|
+
offset += len;
|
|
20381
|
+
if (fieldNum === 3) {
|
|
20382
|
+
const text = valBytes.toString("utf8");
|
|
20383
|
+
content += text;
|
|
20384
|
+
events.push({ type: "content", text });
|
|
20385
|
+
} else if (fieldNum === 9) {
|
|
20386
|
+
const text = valBytes.toString("utf8");
|
|
20387
|
+
reasoning += text;
|
|
20388
|
+
events.push({ type: "reasoning", text });
|
|
20389
|
+
}
|
|
20390
|
+
} else {
|
|
20391
|
+
break;
|
|
20392
|
+
}
|
|
20393
|
+
}
|
|
20394
|
+
return { content, reasoning, finishReason, events };
|
|
20395
|
+
}
|
|
20396
|
+
function createDevinProvider(options) {
|
|
20397
|
+
const { token, model = "swe-2", fetchImpl = fetch } = options;
|
|
20398
|
+
return {
|
|
20399
|
+
model,
|
|
20400
|
+
async complete(messages, opts) {
|
|
20401
|
+
const selectedModel = model;
|
|
20402
|
+
const requestPayload = buildGetChatMessageRequest({
|
|
20403
|
+
token,
|
|
20404
|
+
messages,
|
|
20405
|
+
model: selectedModel
|
|
20406
|
+
});
|
|
20407
|
+
const frame = buildDevinConnectFrame(requestPayload);
|
|
20408
|
+
const response = await fetchImpl(DEVIN_CONNECT_URL, {
|
|
20409
|
+
method: "POST",
|
|
20410
|
+
headers: {
|
|
20411
|
+
"authorization": `Basic ${token}-${token}`,
|
|
20412
|
+
"content-type": "application/connect+proto",
|
|
20413
|
+
"connect-protocol-version": "1"
|
|
20414
|
+
},
|
|
20415
|
+
body: new Uint8Array(frame),
|
|
20416
|
+
signal: opts?.signal
|
|
20417
|
+
});
|
|
20418
|
+
if (!response.ok) {
|
|
20419
|
+
const errText = await response.text().catch(() => "");
|
|
20420
|
+
throw new Error(
|
|
20421
|
+
`Devin Connect upstream returned error ${response.status}: ${errText}`
|
|
20422
|
+
);
|
|
20423
|
+
}
|
|
20424
|
+
if (!response.body) {
|
|
20425
|
+
throw new Error("Devin Connect response body is null");
|
|
20426
|
+
}
|
|
20427
|
+
let text = "";
|
|
20428
|
+
let reasoning = "";
|
|
20429
|
+
let buffer3 = Buffer.alloc(0);
|
|
20430
|
+
let sawTrailer = false;
|
|
20431
|
+
const reader = response.body.getReader();
|
|
20432
|
+
try {
|
|
20433
|
+
while (true) {
|
|
20434
|
+
const { done: done4, value } = await reader.read();
|
|
20435
|
+
if (done4) break;
|
|
20436
|
+
buffer3 = Buffer.concat([buffer3, Buffer.from(value)]);
|
|
20437
|
+
const { frames, remainder } = parseDevinConnectFrames(buffer3);
|
|
20438
|
+
buffer3 = Buffer.from(remainder);
|
|
20439
|
+
for (const f of frames) {
|
|
20440
|
+
if (sawTrailer) {
|
|
20441
|
+
throw new Error("Devin Connect received a frame after the terminal trailer");
|
|
20442
|
+
}
|
|
20443
|
+
if (f.flags & 2) {
|
|
20444
|
+
sawTrailer = true;
|
|
20445
|
+
const trailerError = parseDevinConnectTrailer(f.payload);
|
|
20446
|
+
if (trailerError) throw trailerError;
|
|
20447
|
+
continue;
|
|
20448
|
+
}
|
|
20449
|
+
const delta = decodeDevinResponsePayload(f.payload);
|
|
20450
|
+
text += delta.content;
|
|
20451
|
+
reasoning += delta.reasoning;
|
|
20452
|
+
for (const event of delta.events) {
|
|
20453
|
+
if (event.type === "reasoning") {
|
|
20454
|
+
opts?.onReasoningDelta?.(event.text);
|
|
20455
|
+
} else {
|
|
20456
|
+
opts?.onTextDelta?.(event.text);
|
|
20457
|
+
}
|
|
20458
|
+
}
|
|
20459
|
+
}
|
|
20460
|
+
}
|
|
20461
|
+
} finally {
|
|
20462
|
+
reader.releaseLock();
|
|
20463
|
+
}
|
|
20464
|
+
if (buffer3.length > 0) {
|
|
20465
|
+
throw new Error("Devin Connect upstream ended with an incomplete frame");
|
|
20466
|
+
}
|
|
20467
|
+
if (!sawTrailer) {
|
|
20468
|
+
throw new Error("Devin Connect upstream ended before the terminal trailer");
|
|
20469
|
+
}
|
|
20470
|
+
if (!text && !reasoning) {
|
|
20471
|
+
throw new Error("Devin Connect upstream completed without content");
|
|
20472
|
+
}
|
|
20473
|
+
return {
|
|
20474
|
+
content: text,
|
|
20475
|
+
model: selectedModel,
|
|
20476
|
+
provider: "devin",
|
|
20477
|
+
reasoning_content: reasoning || void 0
|
|
20478
|
+
};
|
|
20479
|
+
}
|
|
20480
|
+
};
|
|
20481
|
+
}
|
|
20482
|
+
|
|
20009
20483
|
export {
|
|
20010
20484
|
Option_exports,
|
|
20011
20485
|
Duration_exports,
|
|
@@ -20015,6 +20489,7 @@ export {
|
|
|
20015
20489
|
readActionGate,
|
|
20016
20490
|
evaluateFileWritePolicy,
|
|
20017
20491
|
summarizeToolArguments,
|
|
20492
|
+
formatToolOverflowMarker,
|
|
20018
20493
|
LOCAL_AGENT_CONFIG_MISSING_CODE,
|
|
20019
20494
|
LOCAL_TURN_ABORTED_CODE,
|
|
20020
20495
|
runLocalAgentTurn,
|
|
@@ -20057,5 +20532,6 @@ export {
|
|
|
20057
20532
|
shouldUseGeminiNativeToolRoute,
|
|
20058
20533
|
buildGeminiGenerateContentRequest,
|
|
20059
20534
|
resolveAntigravityFinishReason,
|
|
20060
|
-
fetchAntigravityCloudCodeCompletion
|
|
20535
|
+
fetchAntigravityCloudCodeCompletion,
|
|
20536
|
+
createDevinProvider
|
|
20061
20537
|
};
|