@rallycry/conveyor-agent 5.11.0 → 5.11.1
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.
|
@@ -427,6 +427,23 @@ var ConveyorConnection = class _ConveyorConnection {
|
|
|
427
427
|
triggerIdentification() {
|
|
428
428
|
return triggerIdentification(this.socket);
|
|
429
429
|
}
|
|
430
|
+
async refreshAuthToken() {
|
|
431
|
+
const codespaceName = process.env.CODESPACE_NAME;
|
|
432
|
+
const apiUrl = process.env.CONVEYOR_API_URL ?? this.config.conveyorApiUrl;
|
|
433
|
+
if (!codespaceName || !apiUrl) return false;
|
|
434
|
+
try {
|
|
435
|
+
const response = await fetch(`${apiUrl}/api/codespace/bootstrap/${codespaceName}`);
|
|
436
|
+
if (!response.ok) return false;
|
|
437
|
+
const config = await response.json();
|
|
438
|
+
if (config.envVars?.CLAUDE_CODE_OAUTH_TOKEN) {
|
|
439
|
+
process.env.CLAUDE_CODE_OAUTH_TOKEN = config.envVars.CLAUDE_CODE_OAUTH_TOKEN;
|
|
440
|
+
return true;
|
|
441
|
+
}
|
|
442
|
+
return false;
|
|
443
|
+
} catch {
|
|
444
|
+
return false;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
430
447
|
emitModeTransition(payload) {
|
|
431
448
|
if (!this.socket) return;
|
|
432
449
|
this.socket.emit("agentRunner:modeTransition", payload);
|
|
@@ -842,6 +859,10 @@ async function processAssistantEvent(event, host, turnToolCalls) {
|
|
|
842
859
|
}
|
|
843
860
|
var API_ERROR_PATTERN = /API Error: [45]\d\d/;
|
|
844
861
|
var IMAGE_ERROR_PATTERN = /Could not process image/i;
|
|
862
|
+
var AUTH_ERROR_PATTERN = /Not logged in|Please run \/login|authentication failed|invalid.*token|unauthorized/i;
|
|
863
|
+
function isAuthError(msg) {
|
|
864
|
+
return AUTH_ERROR_PATTERN.test(msg);
|
|
865
|
+
}
|
|
845
866
|
function isRetriableMessage(msg) {
|
|
846
867
|
if (IMAGE_ERROR_PATTERN.test(msg)) return true;
|
|
847
868
|
if (API_ERROR_PATTERN.test(msg)) return true;
|
|
@@ -922,6 +943,10 @@ function handleErrorResult(event, host) {
|
|
|
922
943
|
if (isStaleSession) {
|
|
923
944
|
return { retriable: false, staleSession: true };
|
|
924
945
|
}
|
|
946
|
+
if (isAuthError(errorMsg)) {
|
|
947
|
+
host.connection.sendEvent({ type: "error", message: errorMsg });
|
|
948
|
+
return { retriable: false, authError: true };
|
|
949
|
+
}
|
|
925
950
|
const retriable = isRetriableMessage(errorMsg);
|
|
926
951
|
host.connection.sendEvent({ type: "error", message: errorMsg });
|
|
927
952
|
return { retriable };
|
|
@@ -961,7 +986,8 @@ async function emitResultEvent(event, host, context, startTime, lastAssistantUsa
|
|
|
961
986
|
return {
|
|
962
987
|
retriable: result.retriable,
|
|
963
988
|
resultSummary: result.resultSummary,
|
|
964
|
-
staleSession: result.staleSession
|
|
989
|
+
staleSession: result.staleSession,
|
|
990
|
+
authError: result.authError
|
|
965
991
|
};
|
|
966
992
|
}
|
|
967
993
|
function handleRateLimitEvent(event, host) {
|
|
@@ -1061,6 +1087,7 @@ async function handleResultCase(event, host, context, startTime, isTyping, lastA
|
|
|
1061
1087
|
retriable: resultInfo.retriable,
|
|
1062
1088
|
resultSummary: resultInfo.resultSummary,
|
|
1063
1089
|
staleSession: resultInfo.staleSession,
|
|
1090
|
+
authError: resultInfo.authError,
|
|
1064
1091
|
stoppedTyping
|
|
1065
1092
|
};
|
|
1066
1093
|
}
|
|
@@ -1108,6 +1135,7 @@ async function processResultCase(event, host, context, startTime, state) {
|
|
|
1108
1135
|
state.retriable = info.retriable;
|
|
1109
1136
|
state.resultSummary = info.resultSummary;
|
|
1110
1137
|
if (info.staleSession) state.staleSession = true;
|
|
1138
|
+
if (info.authError) state.authError = true;
|
|
1111
1139
|
}
|
|
1112
1140
|
async function processEvents(events, context, host) {
|
|
1113
1141
|
const startTime = Date.now();
|
|
@@ -1121,6 +1149,7 @@ async function processEvents(events, context, host) {
|
|
|
1121
1149
|
resultSummary: void 0,
|
|
1122
1150
|
rateLimitResetsAt: void 0,
|
|
1123
1151
|
staleSession: void 0,
|
|
1152
|
+
authError: void 0,
|
|
1124
1153
|
lastAssistantUsage: void 0,
|
|
1125
1154
|
turnToolCalls: []
|
|
1126
1155
|
};
|
|
@@ -1160,7 +1189,8 @@ async function processEvents(events, context, host) {
|
|
|
1160
1189
|
retriable: state.retriable || state.sawApiError,
|
|
1161
1190
|
resultSummary: state.resultSummary,
|
|
1162
1191
|
rateLimitResetsAt: state.rateLimitResetsAt,
|
|
1163
|
-
...state.staleSession && { staleSession: state.staleSession }
|
|
1192
|
+
...state.staleSession && { staleSession: state.staleSession },
|
|
1193
|
+
...state.authError && { authError: state.authError }
|
|
1164
1194
|
};
|
|
1165
1195
|
}
|
|
1166
1196
|
|
|
@@ -3115,6 +3145,29 @@ async function buildRetryQuery(host, context, options, lastErrorWasImage) {
|
|
|
3115
3145
|
options: { ...options, resume: void 0 }
|
|
3116
3146
|
});
|
|
3117
3147
|
}
|
|
3148
|
+
async function handleAuthError(context, host, options) {
|
|
3149
|
+
host.connection.postChatMessage("Authentication expired. Re-bootstrapping credentials...");
|
|
3150
|
+
const refreshed = await host.connection.refreshAuthToken();
|
|
3151
|
+
if (!refreshed) {
|
|
3152
|
+
host.connection.postChatMessage("Failed to refresh authentication. Agent will restart.");
|
|
3153
|
+
host.connection.sendEvent({
|
|
3154
|
+
type: "error",
|
|
3155
|
+
message: "Auth re-bootstrap failed, exiting for restart"
|
|
3156
|
+
});
|
|
3157
|
+
process.exit(1);
|
|
3158
|
+
}
|
|
3159
|
+
context.claudeSessionId = null;
|
|
3160
|
+
host.connection.storeSessionId("");
|
|
3161
|
+
const freshPrompt = buildMultimodalPrompt(
|
|
3162
|
+
await buildInitialPrompt(host.config.mode, context, host.config.isAuto, host.agentMode),
|
|
3163
|
+
context
|
|
3164
|
+
);
|
|
3165
|
+
const freshQuery = query({
|
|
3166
|
+
prompt: host.createInputStream(freshPrompt),
|
|
3167
|
+
options: { ...options, resume: void 0 }
|
|
3168
|
+
});
|
|
3169
|
+
return runWithRetry(freshQuery, context, host, options);
|
|
3170
|
+
}
|
|
3118
3171
|
async function handleStaleSession(context, host, options) {
|
|
3119
3172
|
context.claudeSessionId = null;
|
|
3120
3173
|
host.connection.storeSessionId("");
|
|
@@ -3183,26 +3236,41 @@ function handleRetryError(error, context, host, options, prevImageError) {
|
|
|
3183
3236
|
if (isStaleOrExitedSession(error, context) && context.claudeSessionId) {
|
|
3184
3237
|
return handleStaleSession(context, host, options);
|
|
3185
3238
|
}
|
|
3239
|
+
if (isAuthError(getErrorMessage(error))) {
|
|
3240
|
+
return handleAuthError(context, host, options);
|
|
3241
|
+
}
|
|
3186
3242
|
if (!isRetriableError(error)) throw error;
|
|
3187
3243
|
return { action: "continue", lastErrorWasImage: classifyImageError(error) || prevImageError };
|
|
3188
3244
|
}
|
|
3245
|
+
function handleProcessResult(result, context, host, options) {
|
|
3246
|
+
if (result.modeRestart || host.isStopped()) return { action: "return" };
|
|
3247
|
+
if (result.rateLimitResetsAt) {
|
|
3248
|
+
handleRateLimitPause(host, result.rateLimitResetsAt);
|
|
3249
|
+
return { action: "return" };
|
|
3250
|
+
}
|
|
3251
|
+
if (result.staleSession && context.claudeSessionId) {
|
|
3252
|
+
return { action: "return_promise", promise: handleStaleSession(context, host, options) };
|
|
3253
|
+
}
|
|
3254
|
+
if (result.authError) {
|
|
3255
|
+
return { action: "return_promise", promise: handleAuthError(context, host, options) };
|
|
3256
|
+
}
|
|
3257
|
+
if (!result.retriable) return { action: "return" };
|
|
3258
|
+
return {
|
|
3259
|
+
action: "continue",
|
|
3260
|
+
lastErrorWasImage: IMAGE_ERROR_PATTERN2.test(result.resultSummary ?? "")
|
|
3261
|
+
};
|
|
3262
|
+
}
|
|
3189
3263
|
async function runWithRetry(initialQuery, context, host, options) {
|
|
3190
3264
|
let lastErrorWasImage = false;
|
|
3191
3265
|
for (let attempt = 0; attempt <= RETRY_DELAYS_MS.length; attempt++) {
|
|
3192
3266
|
if (host.isStopped()) return;
|
|
3193
3267
|
const agentQuery = attempt === 0 ? initialQuery : await buildRetryQuery(host, context, options, lastErrorWasImage);
|
|
3194
3268
|
try {
|
|
3195
|
-
const
|
|
3196
|
-
|
|
3197
|
-
if (
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
}
|
|
3201
|
-
if (staleSession && context.claudeSessionId) {
|
|
3202
|
-
return handleStaleSession(context, host, options);
|
|
3203
|
-
}
|
|
3204
|
-
if (!retriable) return;
|
|
3205
|
-
lastErrorWasImage = IMAGE_ERROR_PATTERN2.test(resultSummary ?? "");
|
|
3269
|
+
const result = await processEvents(agentQuery, context, host);
|
|
3270
|
+
const outcome = handleProcessResult(result, context, host, options);
|
|
3271
|
+
if (outcome.action === "return") return;
|
|
3272
|
+
if (outcome.action === "return_promise") return outcome.promise;
|
|
3273
|
+
lastErrorWasImage = outcome.lastErrorWasImage;
|
|
3206
3274
|
} catch (error) {
|
|
3207
3275
|
const outcome = handleRetryError(error, context, host, options, lastErrorWasImage);
|
|
3208
3276
|
if (outcome instanceof Promise) return outcome;
|
|
@@ -4674,7 +4742,7 @@ async function runAuditQuery(request, connection, projectDir) {
|
|
|
4674
4742
|
allowDangerouslySkipPermissions: true,
|
|
4675
4743
|
tools: { type: "preset", preset: "claude_code" },
|
|
4676
4744
|
mcpServers: { "tag-audit": createAuditMcpServer(collector, onRecommendation) },
|
|
4677
|
-
maxTurns: settings.maxTurns ??
|
|
4745
|
+
maxTurns: settings.maxTurns ?? 75,
|
|
4678
4746
|
maxBudgetUsd: settings.maxBudgetUsd ?? 5,
|
|
4679
4747
|
effort: settings.effort,
|
|
4680
4748
|
thinking: settings.thinking
|
|
@@ -5388,4 +5456,4 @@ export {
|
|
|
5388
5456
|
ProjectRunner,
|
|
5389
5457
|
FileCache
|
|
5390
5458
|
};
|
|
5391
|
-
//# sourceMappingURL=chunk-
|
|
5459
|
+
//# sourceMappingURL=chunk-U3YWTVH3.js.map
|