@evident-ai/cli 3.5.2-dev.07822ab → 3.5.2-dev.2bb04b2
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/dist/index.js +203 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1069,6 +1069,76 @@ import chalk7 from "chalk";
|
|
|
1069
1069
|
// ../../packages/types/src/agents/index.ts
|
|
1070
1070
|
var MICROVM_MAX_LIFETIME_MS = 8 * 60 * 6e4;
|
|
1071
1071
|
|
|
1072
|
+
// ../../packages/types/src/opencode/index.ts
|
|
1073
|
+
function roleOf(m) {
|
|
1074
|
+
if (!m || typeof m !== "object") return void 0;
|
|
1075
|
+
if (typeof m.role === "string") return m.role;
|
|
1076
|
+
const infoRole = m.info?.role;
|
|
1077
|
+
return typeof infoRole === "string" ? infoRole : void 0;
|
|
1078
|
+
}
|
|
1079
|
+
function idOf(m) {
|
|
1080
|
+
if (!m || typeof m !== "object") return void 0;
|
|
1081
|
+
if (typeof m.id === "string") return m.id;
|
|
1082
|
+
const infoId = m.info?.id;
|
|
1083
|
+
return typeof infoId === "string" ? infoId : void 0;
|
|
1084
|
+
}
|
|
1085
|
+
function parentIdOf(m) {
|
|
1086
|
+
if (!m || typeof m !== "object") return void 0;
|
|
1087
|
+
if (typeof m.parentID === "string") return m.parentID;
|
|
1088
|
+
const infoParent = m.info?.parentID;
|
|
1089
|
+
return typeof infoParent === "string" ? infoParent : void 0;
|
|
1090
|
+
}
|
|
1091
|
+
function textPartsOf(m) {
|
|
1092
|
+
if (!m || typeof m !== "object") return [];
|
|
1093
|
+
const parts = Array.isArray(m.parts) ? m.parts : [];
|
|
1094
|
+
return parts.filter((p) => p.type === "text" && typeof p.text === "string").map((p) => p.text ?? "").filter(Boolean);
|
|
1095
|
+
}
|
|
1096
|
+
function correlatedAssistantRun(messages, userMessageId) {
|
|
1097
|
+
if (!messages || messages.length === 0) return [];
|
|
1098
|
+
const byParent = messages.filter(
|
|
1099
|
+
(m) => roleOf(m) === "assistant" && parentIdOf(m) === userMessageId
|
|
1100
|
+
);
|
|
1101
|
+
if (byParent.length > 0) return byParent;
|
|
1102
|
+
const userIndex = messages.findIndex((m) => idOf(m) === userMessageId);
|
|
1103
|
+
if (userIndex === -1) return [];
|
|
1104
|
+
const run2 = [];
|
|
1105
|
+
for (let i = userIndex + 1; i < messages.length; i++) {
|
|
1106
|
+
const role = roleOf(messages[i]);
|
|
1107
|
+
if (role === "user") break;
|
|
1108
|
+
if (role === "assistant") run2.push(messages[i]);
|
|
1109
|
+
}
|
|
1110
|
+
return run2;
|
|
1111
|
+
}
|
|
1112
|
+
function lastText(assistantRun) {
|
|
1113
|
+
for (let i = assistantRun.length - 1; i >= 0; i--) {
|
|
1114
|
+
const textParts = textPartsOf(assistantRun[i]);
|
|
1115
|
+
if (textParts.length > 0) return textParts.join("\n").trim() || null;
|
|
1116
|
+
}
|
|
1117
|
+
return null;
|
|
1118
|
+
}
|
|
1119
|
+
function effectiveCorrelatedRun(messages, userMessageId) {
|
|
1120
|
+
const run2 = correlatedAssistantRun(messages, userMessageId);
|
|
1121
|
+
if (lastText(run2) !== null) return run2;
|
|
1122
|
+
const userIndex = messages?.findIndex((m) => idOf(m) === userMessageId) ?? -1;
|
|
1123
|
+
if (userIndex === -1) return run2;
|
|
1124
|
+
let continuation;
|
|
1125
|
+
for (let i = userIndex + 1; messages && i < messages.length; i++) {
|
|
1126
|
+
if (roleOf(messages[i]) === "user") {
|
|
1127
|
+
continuation = messages[i];
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
const continuationId = idOf(continuation);
|
|
1132
|
+
if (roleOf(continuation) === "user" && textPartsOf(continuation).join("\n").trim().toLowerCase() === "continue" && continuationId) {
|
|
1133
|
+
const continuationRun = correlatedAssistantRun(messages, continuationId);
|
|
1134
|
+
if (continuationRun.length > 0) return continuationRun;
|
|
1135
|
+
}
|
|
1136
|
+
return run2;
|
|
1137
|
+
}
|
|
1138
|
+
function extractReplyTextForMessage(messages, opencodeUserMessageId) {
|
|
1139
|
+
return lastText(effectiveCorrelatedRun(messages, opencodeUserMessageId));
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1072
1142
|
// ../../packages/types/src/telemetry/index.ts
|
|
1073
1143
|
var TelemetryEventTypes = {
|
|
1074
1144
|
// Agent activity events (shown in web UI activity log)
|
|
@@ -1157,7 +1227,7 @@ import ora4 from "ora";
|
|
|
1157
1227
|
import { select as select4 } from "@inquirer/prompts";
|
|
1158
1228
|
|
|
1159
1229
|
// src/lib/telemetry.ts
|
|
1160
|
-
var CLI_VERSION = (true ? "3.5.2-dev.
|
|
1230
|
+
var CLI_VERSION = (true ? "3.5.2-dev.2bb04b2" : void 0) ?? process.env.npm_package_version ?? "unknown";
|
|
1161
1231
|
function getCliVersion() {
|
|
1162
1232
|
return CLI_VERSION;
|
|
1163
1233
|
}
|
|
@@ -2144,7 +2214,7 @@ async function getOpenCodeDirectory(port, client) {
|
|
|
2144
2214
|
return null;
|
|
2145
2215
|
}
|
|
2146
2216
|
}
|
|
2147
|
-
function
|
|
2217
|
+
function roleOf2(m) {
|
|
2148
2218
|
if (!m || typeof m !== "object") return void 0;
|
|
2149
2219
|
if (typeof m.role === "string") return m.role;
|
|
2150
2220
|
const infoRole = m.info?.role;
|
|
@@ -2158,13 +2228,13 @@ function createdOf(m) {
|
|
|
2158
2228
|
if (!m || typeof m !== "object") return void 0;
|
|
2159
2229
|
return m.info?.time?.created ?? m.time?.created;
|
|
2160
2230
|
}
|
|
2161
|
-
function
|
|
2231
|
+
function idOf2(m) {
|
|
2162
2232
|
if (!m || typeof m !== "object") return void 0;
|
|
2163
2233
|
if (typeof m.id === "string") return m.id;
|
|
2164
2234
|
const infoId = m.info?.id;
|
|
2165
2235
|
return typeof infoId === "string" ? infoId : void 0;
|
|
2166
2236
|
}
|
|
2167
|
-
function
|
|
2237
|
+
function parentIdOf2(m) {
|
|
2168
2238
|
if (!m || typeof m !== "object") return void 0;
|
|
2169
2239
|
if (typeof m.parentID === "string") return m.parentID;
|
|
2170
2240
|
const infoParent = m.info?.parentID;
|
|
@@ -2229,7 +2299,7 @@ async function pollSessionMessagesForRedrive(port, sessionId, client) {
|
|
|
2229
2299
|
function isSessionActivelyGenerating(messages) {
|
|
2230
2300
|
if (!messages || messages.length === 0) return false;
|
|
2231
2301
|
const last = messages[messages.length - 1];
|
|
2232
|
-
if (
|
|
2302
|
+
if (roleOf2(last) !== "assistant") return false;
|
|
2233
2303
|
return completedOf(last) == null;
|
|
2234
2304
|
}
|
|
2235
2305
|
var FULL_SESSION_ENUMERATION_MAX_SESSIONS = 3200;
|
|
@@ -2541,7 +2611,7 @@ function messageText(m) {
|
|
|
2541
2611
|
async function sendPromptAsync(port, sessionId, content, options, attachments, client) {
|
|
2542
2612
|
const before = await getSessionMessages(port, sessionId, client);
|
|
2543
2613
|
const knownUserIds = new Set(
|
|
2544
|
-
(before ?? []).filter((m) =>
|
|
2614
|
+
(before ?? []).filter((m) => roleOf2(m) === "user").map((m) => idOf2(m)).filter((id) => typeof id === "string")
|
|
2545
2615
|
);
|
|
2546
2616
|
const parts = [{ type: "text", text: content }];
|
|
2547
2617
|
let pendingOutcomes = null;
|
|
@@ -2584,8 +2654,8 @@ async function sendPromptAsync(port, sessionId, content, options, attachments, c
|
|
|
2584
2654
|
if (after) {
|
|
2585
2655
|
let best = null;
|
|
2586
2656
|
for (const m of after) {
|
|
2587
|
-
if (
|
|
2588
|
-
const id =
|
|
2657
|
+
if (roleOf2(m) !== "user") continue;
|
|
2658
|
+
const id = idOf2(m);
|
|
2589
2659
|
if (typeof id !== "string" || knownUserIds.has(id)) continue;
|
|
2590
2660
|
if (messageText(m) !== content) continue;
|
|
2591
2661
|
const created = createdOf(m) ?? 0;
|
|
@@ -2607,13 +2677,13 @@ async function sendPromptAsync(port, sessionId, content, options, attachments, c
|
|
|
2607
2677
|
function findAssistantReplyAfter(messages, userMessageId) {
|
|
2608
2678
|
if (!messages || messages.length === 0) return null;
|
|
2609
2679
|
const byParent = messages.find(
|
|
2610
|
-
(m) =>
|
|
2680
|
+
(m) => roleOf2(m) === "assistant" && parentIdOf2(m) === userMessageId
|
|
2611
2681
|
);
|
|
2612
2682
|
if (byParent) return byParent;
|
|
2613
|
-
const userIndex = messages.findIndex((m) =>
|
|
2683
|
+
const userIndex = messages.findIndex((m) => idOf2(m) === userMessageId);
|
|
2614
2684
|
if (userIndex === -1) return null;
|
|
2615
2685
|
for (let i = userIndex + 1; i < messages.length; i++) {
|
|
2616
|
-
if (
|
|
2686
|
+
if (roleOf2(messages[i]) === "assistant") return messages[i];
|
|
2617
2687
|
}
|
|
2618
2688
|
return null;
|
|
2619
2689
|
}
|
|
@@ -2623,7 +2693,7 @@ function findLastAssistantReplyFor(messages, userMessageId) {
|
|
|
2623
2693
|
let lastNonErrored = null;
|
|
2624
2694
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
2625
2695
|
const m = messages[i];
|
|
2626
|
-
if (
|
|
2696
|
+
if (roleOf2(m) !== "assistant" || parentIdOf2(m) !== userMessageId) continue;
|
|
2627
2697
|
if (lastCorrelated === null) lastCorrelated = m;
|
|
2628
2698
|
if (errorOf(m) == null) {
|
|
2629
2699
|
lastNonErrored = m;
|
|
@@ -2631,12 +2701,12 @@ function findLastAssistantReplyFor(messages, userMessageId) {
|
|
|
2631
2701
|
}
|
|
2632
2702
|
}
|
|
2633
2703
|
if (lastCorrelated) return lastNonErrored ?? lastCorrelated;
|
|
2634
|
-
const userIndex = messages.findIndex((m) =>
|
|
2704
|
+
const userIndex = messages.findIndex((m) => idOf2(m) === userMessageId);
|
|
2635
2705
|
if (userIndex === -1) return null;
|
|
2636
2706
|
let last = null;
|
|
2637
2707
|
let lastOk = null;
|
|
2638
2708
|
for (let i = userIndex + 1; i < messages.length; i++) {
|
|
2639
|
-
const role =
|
|
2709
|
+
const role = roleOf2(messages[i]);
|
|
2640
2710
|
if (role === "user") break;
|
|
2641
2711
|
if (role === "assistant") {
|
|
2642
2712
|
last = messages[i];
|
|
@@ -2648,16 +2718,16 @@ function findLastAssistantReplyFor(messages, userMessageId) {
|
|
|
2648
2718
|
function collectSubagentSessions(messages, userMessageId) {
|
|
2649
2719
|
if (!messages || messages.length === 0) return [];
|
|
2650
2720
|
const byParent = messages.filter(
|
|
2651
|
-
(message) =>
|
|
2721
|
+
(message) => roleOf2(message) === "assistant" && parentIdOf2(message) === userMessageId
|
|
2652
2722
|
);
|
|
2653
2723
|
const assistants = byParent.length > 0 ? byParent : [];
|
|
2654
2724
|
if (assistants.length === 0) {
|
|
2655
|
-
const userIndex = messages.findIndex((message) =>
|
|
2725
|
+
const userIndex = messages.findIndex((message) => idOf2(message) === userMessageId);
|
|
2656
2726
|
if (userIndex === -1) return [];
|
|
2657
2727
|
for (let i = userIndex + 1; i < messages.length; i++) {
|
|
2658
2728
|
const message = messages[i];
|
|
2659
|
-
if (
|
|
2660
|
-
if (
|
|
2729
|
+
if (roleOf2(message) === "user") break;
|
|
2730
|
+
if (roleOf2(message) === "assistant") assistants.push(message);
|
|
2661
2731
|
}
|
|
2662
2732
|
}
|
|
2663
2733
|
const refs = [];
|
|
@@ -2697,7 +2767,7 @@ function collectTaskCalls(messages, userMessageId) {
|
|
|
2697
2767
|
if (!messages || messages.length === 0) return [];
|
|
2698
2768
|
const calls = [];
|
|
2699
2769
|
for (const message of messages) {
|
|
2700
|
-
if (
|
|
2770
|
+
if (roleOf2(message) !== "assistant" || parentIdOf2(message) !== userMessageId) continue;
|
|
2701
2771
|
for (const part of message.parts ?? []) {
|
|
2702
2772
|
if (part.tool !== "task" || !part.callID || !part.state || part.state.status === "pending") {
|
|
2703
2773
|
continue;
|
|
@@ -2727,7 +2797,7 @@ function attributeTaskCallUsage(messages, windows) {
|
|
|
2727
2797
|
for (const window of eligibleWindows) assignments.set(window.callID, []);
|
|
2728
2798
|
const unattributed = [];
|
|
2729
2799
|
for (const message of messages ?? []) {
|
|
2730
|
-
if (
|
|
2800
|
+
if (roleOf2(message) !== "assistant") continue;
|
|
2731
2801
|
const created = finiteNumber(createdOf(message));
|
|
2732
2802
|
const matching = created === null ? [] : eligibleWindows.filter(
|
|
2733
2803
|
(window) => window.timeStart <= created && (window.timeEnd === null || window.timeEnd === void 0 || created <= window.timeEnd)
|
|
@@ -2804,7 +2874,7 @@ function sumAssistantUsage(messages) {
|
|
|
2804
2874
|
function messageUsage(messages, userMessageId) {
|
|
2805
2875
|
if (!messages || messages.length === 0) return null;
|
|
2806
2876
|
const byParentAll = messages.filter(
|
|
2807
|
-
(m) =>
|
|
2877
|
+
(m) => roleOf2(m) === "assistant" && parentIdOf2(m) === userMessageId
|
|
2808
2878
|
);
|
|
2809
2879
|
const byParentNonErrored = byParentAll.filter((m) => errorOf(m) == null);
|
|
2810
2880
|
const byParent = byParentNonErrored.length > 0 ? byParentNonErrored : byParentAll;
|
|
@@ -2820,7 +2890,7 @@ function messageUsage(messages, userMessageId) {
|
|
|
2820
2890
|
}
|
|
2821
2891
|
function messageRunState(messages, userMessageId) {
|
|
2822
2892
|
if (!messages || messages.length === 0) return "unknown";
|
|
2823
|
-
const hasUser = messages.some((m) =>
|
|
2893
|
+
const hasUser = messages.some((m) => idOf2(m) === userMessageId);
|
|
2824
2894
|
const reply = findLastAssistantReplyFor(messages, userMessageId);
|
|
2825
2895
|
if (!hasUser) {
|
|
2826
2896
|
if (!reply) return "unknown";
|
|
@@ -2912,7 +2982,7 @@ function findLatestSubagentAuthOutcome(messages, sinceMs) {
|
|
|
2912
2982
|
if (!messages || messages.length === 0) return null;
|
|
2913
2983
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
2914
2984
|
const message = messages[i];
|
|
2915
|
-
if (
|
|
2985
|
+
if (roleOf2(message) !== "assistant") continue;
|
|
2916
2986
|
const created = createdOf(message);
|
|
2917
2987
|
if (sinceMs !== null && typeof created === "number" && created < sinceMs) continue;
|
|
2918
2988
|
const failure = classifyReplyAuthError(message);
|
|
@@ -2944,25 +3014,25 @@ function applyZeroProviderFallback(classified, hasConfiguredProvider, replyProvi
|
|
|
2944
3014
|
function hasRunningAssistantExcept(messages, exceptUserMessageId) {
|
|
2945
3015
|
if (!messages || messages.length === 0) return false;
|
|
2946
3016
|
return messages.some(
|
|
2947
|
-
(m) =>
|
|
3017
|
+
(m) => roleOf2(m) === "assistant" && parentIdOf2(m) !== exceptUserMessageId && isAssistantInFlight(m)
|
|
2948
3018
|
);
|
|
2949
3019
|
}
|
|
2950
3020
|
function hasLaterSiblingTurnStarted(messages, userMessageId, siblingUserMessageIds) {
|
|
2951
3021
|
if (!messages || messages.length === 0) return false;
|
|
2952
|
-
const userIndex = messages.findIndex((message) =>
|
|
3022
|
+
const userIndex = messages.findIndex((message) => idOf2(message) === userMessageId);
|
|
2953
3023
|
if (userIndex === -1) return false;
|
|
2954
3024
|
let hasLaterUser = false;
|
|
2955
3025
|
let hasStartedLaterUser = false;
|
|
2956
3026
|
for (let i = userIndex + 1; i < messages.length; i++) {
|
|
2957
3027
|
const message = messages[i];
|
|
2958
|
-
if (
|
|
3028
|
+
if (roleOf2(message) !== "user") continue;
|
|
2959
3029
|
hasLaterUser = true;
|
|
2960
|
-
const laterUserMessageId =
|
|
3030
|
+
const laterUserMessageId = idOf2(message);
|
|
2961
3031
|
if (laterUserMessageId === void 0 || !siblingUserMessageIds.has(laterUserMessageId)) {
|
|
2962
3032
|
return false;
|
|
2963
3033
|
}
|
|
2964
3034
|
if (messages.some(
|
|
2965
|
-
(candidate) =>
|
|
3035
|
+
(candidate) => roleOf2(candidate) === "assistant" && parentIdOf2(candidate) === laterUserMessageId
|
|
2966
3036
|
)) {
|
|
2967
3037
|
hasStartedLaterUser = true;
|
|
2968
3038
|
}
|
|
@@ -8749,6 +8819,7 @@ var ChannelDriver = class _ChannelDriver {
|
|
|
8749
8819
|
b2LastDescendantCheckMs: 0,
|
|
8750
8820
|
b2RootOngoingHeldLogged: false,
|
|
8751
8821
|
b2AbandonedSignalled: false,
|
|
8822
|
+
b2AbandonedWithoutAnswer: false,
|
|
8752
8823
|
ambiguousPinnedSinceMs: 0,
|
|
8753
8824
|
ambiguousResolved: false,
|
|
8754
8825
|
sessionStoreFailurePending: false,
|
|
@@ -8868,6 +8939,7 @@ var ChannelDriver = class _ChannelDriver {
|
|
|
8868
8939
|
b2LastDescendantCheckMs: 0,
|
|
8869
8940
|
b2RootOngoingHeldLogged: false,
|
|
8870
8941
|
b2AbandonedSignalled: false,
|
|
8942
|
+
b2AbandonedWithoutAnswer: false,
|
|
8871
8943
|
ambiguousPinnedSinceMs: 0,
|
|
8872
8944
|
ambiguousResolved: false,
|
|
8873
8945
|
sessionStoreFailurePending: false,
|
|
@@ -9447,10 +9519,22 @@ var ChannelDriver = class _ChannelDriver {
|
|
|
9447
9519
|
inFlight.b2LastDescendantCheckMs = 0;
|
|
9448
9520
|
inFlight.b2RootOngoingHeldLogged = false;
|
|
9449
9521
|
inFlight.b2AbandonedSignalled = false;
|
|
9522
|
+
inFlight.b2AbandonedWithoutAnswer = false;
|
|
9450
9523
|
}
|
|
9451
9524
|
} else {
|
|
9452
9525
|
if (inFlight.b2AbandonedSignalled) {
|
|
9453
|
-
|
|
9526
|
+
if (inFlight.b2AbandonedWithoutAnswer) {
|
|
9527
|
+
const reply = findLastAssistantReplyFor(messages, inFlight.opencodeMessageId);
|
|
9528
|
+
await this.settleMessageAbandonedWithoutAnswer(
|
|
9529
|
+
sessionId,
|
|
9530
|
+
watcher,
|
|
9531
|
+
inFlight,
|
|
9532
|
+
messages,
|
|
9533
|
+
reply?.info?.finish ?? reply?.finish
|
|
9534
|
+
);
|
|
9535
|
+
} else {
|
|
9536
|
+
await this.settleMessageDone(sessionId, watcher, inFlight, messages);
|
|
9537
|
+
}
|
|
9454
9538
|
return;
|
|
9455
9539
|
}
|
|
9456
9540
|
if (inFlight.b2PinnedSinceMs === 0) inFlight.b2PinnedSinceMs = this.now();
|
|
@@ -9478,16 +9562,36 @@ var ChannelDriver = class _ChannelDriver {
|
|
|
9478
9562
|
return;
|
|
9479
9563
|
}
|
|
9480
9564
|
inFlight.b2AbandonedSignalled = true;
|
|
9565
|
+
const reply = findLastAssistantReplyFor(messages, inFlight.opencodeMessageId);
|
|
9566
|
+
const finish = reply?.info?.finish ?? reply?.finish;
|
|
9567
|
+
if (extractReplyTextForMessage(messages, inFlight.opencodeMessageId) === null) {
|
|
9568
|
+
inFlight.b2AbandonedWithoutAnswer = true;
|
|
9569
|
+
void this.postSignal(conv.id, id, "b2_abandoned_resolved", {
|
|
9570
|
+
watched_for_ms: pinnedForMs,
|
|
9571
|
+
run_state: "failed",
|
|
9572
|
+
finish,
|
|
9573
|
+
...rootOngoing != null ? { root_ongoing: rootOngoing } : {},
|
|
9574
|
+
...descendantOngoing != null ? { descendant_ongoing: descendantOngoing } : {},
|
|
9575
|
+
opencode_message_id: inFlight.opencodeMessageId
|
|
9576
|
+
});
|
|
9577
|
+
await this.settleMessageAbandonedWithoutAnswer(
|
|
9578
|
+
sessionId,
|
|
9579
|
+
watcher,
|
|
9580
|
+
inFlight,
|
|
9581
|
+
messages,
|
|
9582
|
+
finish
|
|
9583
|
+
);
|
|
9584
|
+
return;
|
|
9585
|
+
}
|
|
9481
9586
|
this.log({
|
|
9482
9587
|
level: "warn",
|
|
9483
9588
|
message: `Message ${id.slice(0, 8)} b2-pinned for ${Math.round(pinnedForMs / 1e3)}s with no ongoing descendant sub-agent session (status-map confirmed) \u2014 treating the delegated/tool turn as abandoned, resolving done`,
|
|
9484
9589
|
conversation_id: conv.id,
|
|
9485
9590
|
message_id: id
|
|
9486
9591
|
});
|
|
9487
|
-
const reply = findLastAssistantReplyFor(messages, inFlight.opencodeMessageId);
|
|
9488
9592
|
void this.postSignal(conv.id, id, "b2_abandoned_resolved", {
|
|
9489
9593
|
watched_for_ms: pinnedForMs,
|
|
9490
|
-
finish
|
|
9594
|
+
finish,
|
|
9491
9595
|
...rootOngoing != null ? { root_ongoing: rootOngoing } : {},
|
|
9492
9596
|
...descendantOngoing != null ? { descendant_ongoing: descendantOngoing } : {},
|
|
9493
9597
|
opencode_message_id: inFlight.opencodeMessageId
|
|
@@ -9769,6 +9873,74 @@ var ChannelDriver = class _ChannelDriver {
|
|
|
9769
9873
|
}
|
|
9770
9874
|
this.removeInFlight(watcher, inFlight.evidentMessageId);
|
|
9771
9875
|
}
|
|
9876
|
+
/** Report a confirmed b2 abandonment that produced no answer text. */
|
|
9877
|
+
async settleMessageAbandonedWithoutAnswer(sessionId, watcher, inFlight, messages, finish) {
|
|
9878
|
+
const conv = watcher.conv;
|
|
9879
|
+
const error2 = `OpenCode ended this turn after a tool call (finish="${finish ?? "(unknown)"}") without writing an answer, and confirmed it is no longer working on this conversation. Evident is reporting the run as failed so the failure and its reason are visible in failed runs.`;
|
|
9880
|
+
this.anchorDeliveryDeadline(inFlight);
|
|
9881
|
+
this.log({
|
|
9882
|
+
level: "warn",
|
|
9883
|
+
message: `Message ${inFlight.evidentMessageId.slice(0, 8)} was abandoned without an answer \u2014 ${error2}`,
|
|
9884
|
+
conversation_id: conv.id,
|
|
9885
|
+
message_id: inFlight.evidentMessageId
|
|
9886
|
+
});
|
|
9887
|
+
const usage = messageUsage(messages, inFlight.opencodeMessageId);
|
|
9888
|
+
const usageAgentName = this.usageAgentName(messages ?? [], inFlight.opencodeMessageId);
|
|
9889
|
+
const subagentInvocations = await this.resolveSubagentInvocations(
|
|
9890
|
+
messages,
|
|
9891
|
+
inFlight.opencodeMessageId,
|
|
9892
|
+
inFlight.evidentMessageId
|
|
9893
|
+
);
|
|
9894
|
+
try {
|
|
9895
|
+
await this.markFailed(
|
|
9896
|
+
conv.id,
|
|
9897
|
+
inFlight.evidentMessageId,
|
|
9898
|
+
sessionId,
|
|
9899
|
+
error2,
|
|
9900
|
+
usage,
|
|
9901
|
+
void 0,
|
|
9902
|
+
usageAgentName,
|
|
9903
|
+
subagentInvocations
|
|
9904
|
+
);
|
|
9905
|
+
} catch (err) {
|
|
9906
|
+
if (err instanceof ChannelAuthError) throw err;
|
|
9907
|
+
if (err instanceof ChannelTerminalError) {
|
|
9908
|
+
this.log({
|
|
9909
|
+
level: "warn",
|
|
9910
|
+
message: `Failed to report abandoned no-answer message ${inFlight.evidentMessageId.slice(0, 8)} as failed (terminal HTTP ${err.status}) \u2014 leaving it for the cron safety net: ${err.message}`,
|
|
9911
|
+
conversation_id: conv.id,
|
|
9912
|
+
message_id: inFlight.evidentMessageId
|
|
9913
|
+
});
|
|
9914
|
+
this.removeInFlight(watcher, inFlight.evidentMessageId);
|
|
9915
|
+
return;
|
|
9916
|
+
}
|
|
9917
|
+
if (this.now() >= inFlight.deadline) {
|
|
9918
|
+
this.log({
|
|
9919
|
+
level: "warn",
|
|
9920
|
+
message: `Failed to report abandoned no-answer message ${inFlight.evidentMessageId.slice(0, 8)} as failed within the delivery window \u2014 leaving it for the cron safety net: ${err instanceof Error ? err.message : String(err)}`,
|
|
9921
|
+
conversation_id: conv.id,
|
|
9922
|
+
message_id: inFlight.evidentMessageId
|
|
9923
|
+
});
|
|
9924
|
+
this.removeInFlight(watcher, inFlight.evidentMessageId);
|
|
9925
|
+
return;
|
|
9926
|
+
}
|
|
9927
|
+
this.log({
|
|
9928
|
+
level: "warn",
|
|
9929
|
+
message: `Failed to report abandoned no-answer message ${inFlight.evidentMessageId.slice(0, 8)} as failed (will retry next tick): ${err instanceof Error ? err.message : String(err)}`,
|
|
9930
|
+
conversation_id: conv.id,
|
|
9931
|
+
message_id: inFlight.evidentMessageId
|
|
9932
|
+
});
|
|
9933
|
+
return;
|
|
9934
|
+
}
|
|
9935
|
+
inFlight.done = true;
|
|
9936
|
+
await this.reportSubagentAuthFailures(
|
|
9937
|
+
watcher.conv.id,
|
|
9938
|
+
inFlight.opencodeMessageId,
|
|
9939
|
+
inFlight.evidentMessageId,
|
|
9940
|
+
messages
|
|
9941
|
+
);
|
|
9942
|
+
this.removeInFlight(watcher, inFlight.evidentMessageId);
|
|
9943
|
+
}
|
|
9772
9944
|
/**
|
|
9773
9945
|
* Report a queued message as failed after the never-started bound. The accepted
|
|
9774
9946
|
* OpenCode copy is not cancelled, so the local fence remains on unsuccessful
|