replicas-engine 0.1.1131 → 0.1.1134
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/src/{asp-host-E2SCOMMR.js → asp-host-S7BIIAWW.js} +5 -5
- package/dist/src/{chunk-2DUTASPN.js → chunk-3VA2LHCU.js} +6 -6
- package/dist/src/{chunk-VGTLNIUB.js → chunk-7CN57E6D.js} +3 -3
- package/dist/src/{chunk-OSFRT5G2.js → chunk-DQAC2NPC.js} +2 -2
- package/dist/src/{chunk-U3JW7S33.js → chunk-FBVBQJIW.js} +1 -1
- package/dist/src/{chunk-PXVHESRP.js → chunk-FDEJF43L.js} +1 -1
- package/dist/src/{chunk-OFWFQNCJ.js → chunk-HMFANNVD.js} +2 -2
- package/dist/src/{chunk-H5J44SSK.js → chunk-TLCDNLK6.js} +2 -2
- package/dist/src/{chunk-ZTXHD46S.js → chunk-WR6M3Z4N.js} +36 -31
- package/dist/src/command-protection-hook.js +4 -4
- package/dist/src/headless-agent.js +4 -4
- package/dist/src/index.js +43 -39
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/subagent-mcp.js +1 -1
- package/package.json +1 -1
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
listRunningCodexModels,
|
|
9
9
|
restartCodexAspHost,
|
|
10
10
|
restartCodexAspHostIfRunning
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-3VA2LHCU.js";
|
|
12
|
+
import "./chunk-DQAC2NPC.js";
|
|
13
|
+
import "./chunk-7CN57E6D.js";
|
|
14
|
+
import "./chunk-FBVBQJIW.js";
|
|
15
15
|
import "./chunk-UZSNFLDQ.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-WR6M3Z4N.js";
|
|
17
17
|
import "./chunk-VEQXQN22.js";
|
|
18
18
|
export {
|
|
19
19
|
CODEX_ULTRAFAST_SERVICE_TIER,
|
|
@@ -10,15 +10,15 @@ import {
|
|
|
10
10
|
resolveDiffBase,
|
|
11
11
|
runGitCommand,
|
|
12
12
|
setAgentCredentialSnapshot
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-DQAC2NPC.js";
|
|
14
14
|
import {
|
|
15
15
|
AppServerProcess,
|
|
16
16
|
buildCodexAgentEnv
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-7CN57E6D.js";
|
|
18
18
|
import {
|
|
19
19
|
SUBPROCESS_MAX_BUFFER,
|
|
20
20
|
execFileAsync
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-FBVBQJIW.js";
|
|
22
22
|
import {
|
|
23
23
|
isRecord
|
|
24
24
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
resolveOpenAICompatibleModelsUrl,
|
|
56
56
|
splitMothershipInstructions,
|
|
57
57
|
withTimeout
|
|
58
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-WR6M3Z4N.js";
|
|
59
59
|
|
|
60
60
|
// src/managers/codex-token-manager.ts
|
|
61
61
|
import { promises as fs } from "fs";
|
|
@@ -291,7 +291,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
291
291
|
await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
|
|
292
292
|
await this.applyCredentialsResponse(data);
|
|
293
293
|
setAgentCredentialSnapshot("codex", data);
|
|
294
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
294
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-S7BIIAWW.js");
|
|
295
295
|
await restartCodexAspHostIfRunning2();
|
|
296
296
|
});
|
|
297
297
|
await this.start(true);
|
|
@@ -312,7 +312,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
312
312
|
const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
|
|
313
313
|
await this.applyCredentialsResponse(data);
|
|
314
314
|
if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
|
|
315
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
315
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-S7BIIAWW.js");
|
|
316
316
|
await restartCodexAspHostIfRunning2();
|
|
317
317
|
}
|
|
318
318
|
setAgentCredentialSnapshot("codex", data);
|
|
@@ -3,10 +3,10 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
execFileAsync
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FBVBQJIW.js";
|
|
7
7
|
import {
|
|
8
8
|
isVersionBelow
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-WR6M3Z4N.js";
|
|
10
10
|
|
|
11
11
|
// src/utils/codex-agent-env.ts
|
|
12
12
|
function buildCodexAgentEnv(source = process.env) {
|
|
@@ -240,7 +240,7 @@ function getCodexModelProvider(method) {
|
|
|
240
240
|
if (method === "foundry") return "azure";
|
|
241
241
|
return method === "ollama" || method === "openai-compatible" ? "replicas_openai_compatible" : "openai";
|
|
242
242
|
}
|
|
243
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
243
|
+
var ENGINE_PACKAGE_VERSION = "0.1.1134";
|
|
244
244
|
var INITIALIZE_METHOD = "initialize";
|
|
245
245
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
246
246
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
|
|
|
4
4
|
import {
|
|
5
5
|
SUBPROCESS_MAX_BUFFER,
|
|
6
6
|
execFileAsync
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-FBVBQJIW.js";
|
|
8
8
|
import {
|
|
9
9
|
isRecord as isRecord2
|
|
10
10
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
isValidAgentProvider,
|
|
19
19
|
parsePosixEnvFile,
|
|
20
20
|
readReplicasRuntimeEnv
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-WR6M3Z4N.js";
|
|
22
22
|
|
|
23
23
|
// src/runtime-env-loader.ts
|
|
24
24
|
import { readFileSync } from "fs";
|
|
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
HOOK_EXEC_MAX_BUFFER_BYTES
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WR6M3Z4N.js";
|
|
7
7
|
|
|
8
8
|
// src/utils/exec.ts
|
|
9
9
|
import { exec, execFile } from "child_process";
|
|
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
AspClient
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7CN57E6D.js";
|
|
7
7
|
import {
|
|
8
8
|
ASTER_BASE_URL,
|
|
9
9
|
ASTER_PROVIDER,
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
codexReasoningEffortForThinkingLevel,
|
|
12
12
|
isRecord,
|
|
13
13
|
readOllamaAuthEnv
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-WR6M3Z4N.js";
|
|
15
15
|
|
|
16
16
|
// src/managers/codex-asp/notification-dispatch.ts
|
|
17
17
|
var TURN_STARTED_METHOD = "turn/started";
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
getOriginDefaultBranch,
|
|
6
6
|
monolithRequest,
|
|
7
7
|
runGitCommand
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-DQAC2NPC.js";
|
|
9
9
|
import {
|
|
10
10
|
extractCommandProtectionCommandText,
|
|
11
11
|
findCommandProtectionGitLookups,
|
|
12
12
|
findGitCommitSignals,
|
|
13
13
|
findPrMergeSignals,
|
|
14
14
|
parseCommandProtectionRequest
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-WR6M3Z4N.js";
|
|
16
16
|
|
|
17
17
|
// src/services/command-protection-service.ts
|
|
18
18
|
import { readFile, stat } from "fs/promises";
|
|
@@ -864,6 +864,36 @@ function paginateEngineLogContent(input) {
|
|
|
864
864
|
};
|
|
865
865
|
}
|
|
866
866
|
|
|
867
|
+
// ../shared/src/agent-quota.ts
|
|
868
|
+
var AGENT_FALLBACK_REASONS = ["rate_limit", "out_of_credits", "auth_failed"];
|
|
869
|
+
function isAgentFallbackReason(value) {
|
|
870
|
+
return AGENT_FALLBACK_REASONS.some((reason) => reason === value);
|
|
871
|
+
}
|
|
872
|
+
var OUT_OF_CREDITS_PATTERNS = [
|
|
873
|
+
/credit balance is too low/,
|
|
874
|
+
/out.of.credits/,
|
|
875
|
+
/credits?.?(?:depleted|exhausted|remaining)/,
|
|
876
|
+
/insufficient credits/,
|
|
877
|
+
/insufficient_quota/
|
|
878
|
+
];
|
|
879
|
+
var RATE_LIMIT_PATTERNS = [
|
|
880
|
+
// Loose on purpose: providers word this as "rate limit", "rate_limit",
|
|
881
|
+
// "usageLimitExceeded" and so on, and these only ever run against error text.
|
|
882
|
+
/rate.?limit/,
|
|
883
|
+
/usage.?limit/,
|
|
884
|
+
/too many requests/,
|
|
885
|
+
/\bquota\b/
|
|
886
|
+
];
|
|
887
|
+
var HTTP_429_PATTERN = /(?:^|[^0-9])429(?:$|[^0-9])/;
|
|
888
|
+
var HTTP_CONTEXT_PATTERN = /(api error|request|response|status|http)/;
|
|
889
|
+
function detectAgentQuotaLimit(text3) {
|
|
890
|
+
const normalized = text3.toLowerCase();
|
|
891
|
+
if (!normalized) return null;
|
|
892
|
+
if (OUT_OF_CREDITS_PATTERNS.some((pattern) => pattern.test(normalized))) return "out_of_credits";
|
|
893
|
+
if (RATE_LIMIT_PATTERNS.some((pattern) => pattern.test(normalized))) return "rate_limit";
|
|
894
|
+
return HTTP_429_PATTERN.test(normalized) && HTTP_CONTEXT_PATTERN.test(normalized) ? "rate_limit" : null;
|
|
895
|
+
}
|
|
896
|
+
|
|
867
897
|
// ../shared/src/analytics/types.ts
|
|
868
898
|
import { z as z3 } from "zod";
|
|
869
899
|
|
|
@@ -1400,7 +1430,7 @@ function coerceAuthFallbackPayload(payload) {
|
|
|
1400
1430
|
const { provider: provider2, reason, exhaustedMethod, exhaustedScope, candidateMethod, candidateScope, status, detail } = payload;
|
|
1401
1431
|
const exhaustedAccount = credentialAccountSchema.safeParse(payload.exhaustedAccount).data;
|
|
1402
1432
|
const candidateAccount = credentialAccountSchema.safeParse(payload.candidateAccount).data;
|
|
1403
|
-
if (typeof provider2 !== "string" || !isValidAgentProvider(provider2) || reason
|
|
1433
|
+
if (typeof provider2 !== "string" || !isValidAgentProvider(provider2) || !isAgentFallbackReason(reason) || !isAuthMethod(exhaustedMethod) || !isAuthMethod(candidateMethod) || !isCredentialScope(candidateScope) || status !== "switched" && status !== "failed") {
|
|
1404
1434
|
return null;
|
|
1405
1435
|
}
|
|
1406
1436
|
return {
|
|
@@ -2110,32 +2140,6 @@ async function readSseStream(body, onEvent, shouldContinue = () => true) {
|
|
|
2110
2140
|
// ../shared/src/types.ts
|
|
2111
2141
|
var ENGINE_SEND_MESSAGE_FAILED_ERROR = "Failed to send message";
|
|
2112
2142
|
|
|
2113
|
-
// ../shared/src/agent-quota.ts
|
|
2114
|
-
var OUT_OF_CREDITS_PATTERNS = [
|
|
2115
|
-
/credit balance is too low/,
|
|
2116
|
-
/out.of.credits/,
|
|
2117
|
-
/credits?.?(?:depleted|exhausted|remaining)/,
|
|
2118
|
-
/insufficient credits/,
|
|
2119
|
-
/insufficient_quota/
|
|
2120
|
-
];
|
|
2121
|
-
var RATE_LIMIT_PATTERNS = [
|
|
2122
|
-
// Loose on purpose: providers word this as "rate limit", "rate_limit",
|
|
2123
|
-
// "usageLimitExceeded" and so on, and these only ever run against error text.
|
|
2124
|
-
/rate.?limit/,
|
|
2125
|
-
/usage.?limit/,
|
|
2126
|
-
/too many requests/,
|
|
2127
|
-
/\bquota\b/
|
|
2128
|
-
];
|
|
2129
|
-
var HTTP_429_PATTERN = /(?:^|[^0-9])429(?:$|[^0-9])/;
|
|
2130
|
-
var HTTP_CONTEXT_PATTERN = /(api error|request|response|status|http)/;
|
|
2131
|
-
function detectAgentQuotaLimit(text3) {
|
|
2132
|
-
const normalized = text3.toLowerCase();
|
|
2133
|
-
if (!normalized) return null;
|
|
2134
|
-
if (OUT_OF_CREDITS_PATTERNS.some((pattern) => pattern.test(normalized))) return "out_of_credits";
|
|
2135
|
-
if (RATE_LIMIT_PATTERNS.some((pattern) => pattern.test(normalized))) return "rate_limit";
|
|
2136
|
-
return HTTP_429_PATTERN.test(normalized) && HTTP_CONTEXT_PATTERN.test(normalized) ? "rate_limit" : null;
|
|
2137
|
-
}
|
|
2138
|
-
|
|
2139
2143
|
// ../shared/src/auth-fallback.ts
|
|
2140
2144
|
function describeCredential(provider2, credential) {
|
|
2141
2145
|
const { ownerName, email, ordinal } = credential.account ?? {};
|
|
@@ -2152,7 +2156,7 @@ function describeAuthFallback(payload) {
|
|
|
2152
2156
|
});
|
|
2153
2157
|
const switched = payload.status === "switched";
|
|
2154
2158
|
return {
|
|
2155
|
-
headline: payload.reason === "out_of_credits" ? `${agent} is out of credits on ${exhausted}` : `${agent} hit its usage limit on ${exhausted}`,
|
|
2159
|
+
headline: payload.reason === "out_of_credits" ? `${agent} is out of credits on ${exhausted}` : payload.reason === "auth_failed" ? `${agent} could not authenticate with ${exhausted}` : `${agent} hit its usage limit on ${exhausted}`,
|
|
2156
2160
|
outcomeClause: switched ? `switched to ${describeCredential(payload.provider, {
|
|
2157
2161
|
method: payload.candidateMethod,
|
|
2158
2162
|
scope: payload.candidateScope,
|
|
@@ -2199,7 +2203,7 @@ var fallbackPlanStepSchema = z8.discriminatedUnion("kind", [
|
|
|
2199
2203
|
var fallbackPlanResponseSchema = z8.object({ steps: z8.array(fallbackPlanStepSchema) });
|
|
2200
2204
|
|
|
2201
2205
|
// ../shared/src/chat-fork.ts
|
|
2202
|
-
var
|
|
2206
|
+
var fallbackReasonSchema = z9.enum(AGENT_FALLBACK_REASONS);
|
|
2203
2207
|
var chatForkInfoSchema = z9.object({
|
|
2204
2208
|
source: z9.object({
|
|
2205
2209
|
chatId: z9.string().min(1),
|
|
@@ -2207,7 +2211,7 @@ var chatForkInfoSchema = z9.object({
|
|
|
2207
2211
|
title: z9.string()
|
|
2208
2212
|
}),
|
|
2209
2213
|
trigger: z9.enum(["manual", "auto", "side"]),
|
|
2210
|
-
reason:
|
|
2214
|
+
reason: fallbackReasonSchema.optional(),
|
|
2211
2215
|
state: z9.enum(["preparing", "ready", "failed"]),
|
|
2212
2216
|
error: z9.string().optional(),
|
|
2213
2217
|
startedAt: z9.string(),
|
|
@@ -2233,6 +2237,7 @@ var forkChatRequestSchema = z9.object({
|
|
|
2233
2237
|
senderAvatarUrl: z9.string().optional()
|
|
2234
2238
|
});
|
|
2235
2239
|
function describeQuotaLimit(reason) {
|
|
2240
|
+
if (reason === "auth_failed") return "could not authenticate";
|
|
2236
2241
|
return reason === "out_of_credits" ? "ran out of credits" : "hit its usage limit";
|
|
2237
2242
|
}
|
|
2238
2243
|
function describeChatForkReason(reason, provider2) {
|
|
@@ -2241,7 +2246,7 @@ function describeChatForkReason(reason, provider2) {
|
|
|
2241
2246
|
var AGENT_QUOTA_EXHAUSTED_EVENT_TYPE = "agent-quota-exhausted";
|
|
2242
2247
|
var agentQuotaExhaustedPayloadSchema = z9.object({
|
|
2243
2248
|
provider: z9.enum(VALID_AGENT_PROVIDERS),
|
|
2244
|
-
reason:
|
|
2249
|
+
reason: fallbackReasonSchema,
|
|
2245
2250
|
detail: z9.string().optional(),
|
|
2246
2251
|
forkTo: fallbackHarnessStepSchema.optional()
|
|
2247
2252
|
});
|
|
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
evaluateCommandProtection
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-TLCDNLK6.js";
|
|
7
|
+
import "./chunk-DQAC2NPC.js";
|
|
8
|
+
import "./chunk-FBVBQJIW.js";
|
|
9
9
|
import {
|
|
10
10
|
isRecord
|
|
11
11
|
} from "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-WR6M3Z4N.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
|
|
15
15
|
// src/command-protection-hook.ts
|
|
@@ -13,12 +13,12 @@ import {
|
|
|
13
13
|
recoverCompletedTurn,
|
|
14
14
|
spawnMuseMsp,
|
|
15
15
|
startMuseSession
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-HMFANNVD.js";
|
|
17
17
|
import {
|
|
18
18
|
AppServerProcess,
|
|
19
19
|
buildCodexAgentEnv
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-7CN57E6D.js";
|
|
21
|
+
import "./chunk-FBVBQJIW.js";
|
|
22
22
|
import {
|
|
23
23
|
AGENT,
|
|
24
24
|
OPENCODE_GO_PROVIDER,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
headlessAgentUsagePath,
|
|
29
29
|
isRecord,
|
|
30
30
|
withTimeout
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-WR6M3Z4N.js";
|
|
32
32
|
import "./chunk-VEQXQN22.js";
|
|
33
33
|
|
|
34
34
|
// src/headless-agent.ts
|
package/dist/src/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
evaluateCommandProtection,
|
|
28
28
|
extractToolCommand,
|
|
29
29
|
reportCommandProtectionBlock
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-TLCDNLK6.js";
|
|
31
31
|
import {
|
|
32
32
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
33
33
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -64,10 +64,10 @@ import {
|
|
|
64
64
|
spawnMuseMsp,
|
|
65
65
|
startMuseSession,
|
|
66
66
|
uuidV7
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-HMFANNVD.js";
|
|
68
68
|
import {
|
|
69
69
|
publishedPullRequestUrls
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-FDEJF43L.js";
|
|
71
71
|
import {
|
|
72
72
|
ACCOUNT_RATE_LIMITS_READ_METHOD,
|
|
73
73
|
AsyncLock,
|
|
@@ -130,7 +130,7 @@ import {
|
|
|
130
130
|
timestampFromSeconds,
|
|
131
131
|
upsertCredentialFileLines,
|
|
132
132
|
writeSecureCredentialFile
|
|
133
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-3VA2LHCU.js";
|
|
134
134
|
import {
|
|
135
135
|
ENGINE_ENV,
|
|
136
136
|
monolithRequest,
|
|
@@ -139,15 +139,15 @@ import {
|
|
|
139
139
|
reloadEngineEnv,
|
|
140
140
|
resolveDiffBase,
|
|
141
141
|
setAgentCredentialSnapshot
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-DQAC2NPC.js";
|
|
143
143
|
import {
|
|
144
144
|
getCodexModelProvider
|
|
145
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-7CN57E6D.js";
|
|
146
146
|
import {
|
|
147
147
|
SUBPROCESS_MAX_BUFFER,
|
|
148
148
|
execAsync,
|
|
149
149
|
execFileAsync
|
|
150
|
-
} from "./chunk-
|
|
150
|
+
} from "./chunk-FBVBQJIW.js";
|
|
151
151
|
import {
|
|
152
152
|
isRecord as isRecord2
|
|
153
153
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -374,7 +374,7 @@ import {
|
|
|
374
374
|
workspaceTokenRequestSchema,
|
|
375
375
|
workspaceTokenResponseSchema,
|
|
376
376
|
wrapInTag
|
|
377
|
-
} from "./chunk-
|
|
377
|
+
} from "./chunk-WR6M3Z4N.js";
|
|
378
378
|
import {
|
|
379
379
|
cloneMcpConfig,
|
|
380
380
|
ensureCompatibilityImports,
|
|
@@ -10440,7 +10440,7 @@ import { join as join29 } from "path";
|
|
|
10440
10440
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
10441
10441
|
|
|
10442
10442
|
// ../shared/src/workspace-chat.ts
|
|
10443
|
-
var WORKSPACE_CHATS_QUERY_SCHEMA_VERSION =
|
|
10443
|
+
var WORKSPACE_CHATS_QUERY_SCHEMA_VERSION = 13;
|
|
10444
10444
|
var WORKSPACE_CHATS_QUERY_ROOT = `workspace-chats:v${WORKSPACE_CHATS_QUERY_SCHEMA_VERSION}`;
|
|
10445
10445
|
function isAcceptedUserMessage(event) {
|
|
10446
10446
|
return getUserMessage(event) !== null && event.payload.source === ACCEPTED_USER_MESSAGE_SOURCE;
|
|
@@ -11053,7 +11053,7 @@ var QUOTA_STOP_NEXT_STEP = {
|
|
|
11053
11053
|
function describeQuotaExhaustion(provider, reason, credential, fallback) {
|
|
11054
11054
|
const agent = getProviderDisplayName(provider);
|
|
11055
11055
|
const account = credential ? describeCredential(provider, credential) : "the credential this workspace is using";
|
|
11056
|
-
const limit = reason === "out_of_credits" ? `${agent} ran out of credits on ${account}.` : `${agent} hit the usage limit on ${account}.`;
|
|
11056
|
+
const limit = reason === "out_of_credits" ? `${agent} ran out of credits on ${account}.` : reason === "auth_failed" ? `${agent} could not authenticate with ${account}.` : `${agent} hit the usage limit on ${account}.`;
|
|
11057
11057
|
const next = fallback.outcome === "fork" ? `Forking this chat to ${getProviderDisplayName(fallback.target.provider, "long")}.` : QUOTA_STOP_NEXT_STEP[fallback.outcome];
|
|
11058
11058
|
return `${limit} ${next}`;
|
|
11059
11059
|
}
|
|
@@ -11091,7 +11091,9 @@ var AuthFallbackCoordinator = class {
|
|
|
11091
11091
|
if (!tokenManager || !exhausted) continue;
|
|
11092
11092
|
const swap = await tokenManager.fetchFreshCredentials(
|
|
11093
11093
|
`${this.provider} ${describeQuotaLimit(reason)}: ${detail}`,
|
|
11094
|
-
|
|
11094
|
+
// A rejected login is skipped through the exclusion above rather than rested
|
|
11095
|
+
// like a spent quota, which Settings would show as a usage limit.
|
|
11096
|
+
reason === "auth_failed" ? "rejected" : "exhausted",
|
|
11095
11097
|
void 0,
|
|
11096
11098
|
step.methods.length > 0 ? step.methods : void 0
|
|
11097
11099
|
);
|
|
@@ -12585,7 +12587,7 @@ var ClaudeQuotaError = class extends Error {
|
|
|
12585
12587
|
kind;
|
|
12586
12588
|
};
|
|
12587
12589
|
var MAX_AUTH_RETRIES = 2;
|
|
12588
|
-
var
|
|
12590
|
+
var MAX_FALLBACKS = 2;
|
|
12589
12591
|
var MAX_TRANSIENT_RETRIES = 2;
|
|
12590
12592
|
var MAX_MIDTURN_CONTINUE_RETRIES = 2;
|
|
12591
12593
|
var TRANSIENT_RETRY_DELAYS_MS = [1e3, 2500];
|
|
@@ -12950,7 +12952,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
12950
12952
|
let lastError;
|
|
12951
12953
|
let authRetryExhausted = false;
|
|
12952
12954
|
let revokedLogin;
|
|
12953
|
-
let
|
|
12955
|
+
let fallbacks = 0;
|
|
12954
12956
|
let attempt = 0;
|
|
12955
12957
|
let authRetries = 0;
|
|
12956
12958
|
let transientRetries = 0;
|
|
@@ -12974,24 +12976,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
12974
12976
|
currentRequest = { ...currentRequest, message: CLAUDE_RETRY_PROMPT, images: [], goalMode: false };
|
|
12975
12977
|
}
|
|
12976
12978
|
const quotaKind = _ClaudeManager.quotaLimitKind(error);
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
const fallback = quotaFallbacks < MAX_QUOTA_FALLBACKS ? await this.fallBackCredential(quotaKind, detail) : { outcome: "unavailable" };
|
|
12980
|
-
if (fallback.outcome === "switched") {
|
|
12981
|
-
if (fallback.model) currentRequest = { ...currentRequest, model: fallback.model };
|
|
12982
|
-
quotaFallbacks++;
|
|
12983
|
-
await this.tearDownSession();
|
|
12984
|
-
attempt++;
|
|
12985
|
-
continue;
|
|
12986
|
-
}
|
|
12987
|
-
await this.emitQuotaExhaustedEvent(quotaKind, fallback, detail, attemptedCredential);
|
|
12988
|
-
return;
|
|
12989
|
-
}
|
|
12990
|
-
if (_ClaudeManager.isAuthError(error)) {
|
|
12991
|
-
if (authRetries >= MAX_AUTH_RETRIES) {
|
|
12992
|
-
authRetryExhausted = true;
|
|
12993
|
-
throw error;
|
|
12994
|
-
}
|
|
12979
|
+
const isAuthError = !quotaKind && _ClaudeManager.isAuthError(error);
|
|
12980
|
+
if (isAuthError && authRetries < MAX_AUTH_RETRIES) {
|
|
12995
12981
|
authRetries++;
|
|
12996
12982
|
console.error(
|
|
12997
12983
|
`[ClaudeManager] Auth failure detected (attempt ${authRetries}/${MAX_AUTH_RETRIES}), refreshing credentials and retrying...`,
|
|
@@ -13003,15 +12989,33 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13003
12989
|
"rejected",
|
|
13004
12990
|
attemptedCredential
|
|
13005
12991
|
);
|
|
13006
|
-
if (
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
revokedLogin = attemptedCredential;
|
|
13010
|
-
}
|
|
13011
|
-
throw error;
|
|
12992
|
+
if (refreshed.ok) {
|
|
12993
|
+
attempt++;
|
|
12994
|
+
continue;
|
|
13012
12995
|
}
|
|
13013
|
-
|
|
13014
|
-
|
|
12996
|
+
if (attemptedCredential?.method === "oauth" && refreshed.error.message.includes('"code":"oauth_disconnected"')) {
|
|
12997
|
+
revokedLogin = attemptedCredential;
|
|
12998
|
+
}
|
|
12999
|
+
}
|
|
13000
|
+
if (quotaKind || isAuthError) {
|
|
13001
|
+
const reason = quotaKind ?? "auth_failed";
|
|
13002
|
+
const detail = error instanceof ClaudeQuotaError ? error.message : extractErrorText(error);
|
|
13003
|
+
const fallback = fallbacks < MAX_FALLBACKS ? await this.fallBackCredential(reason, detail) : { outcome: "unavailable" };
|
|
13004
|
+
if (fallback.outcome === "switched") {
|
|
13005
|
+
if (fallback.model) currentRequest = { ...currentRequest, model: fallback.model };
|
|
13006
|
+
fallbacks++;
|
|
13007
|
+
authRetries = 0;
|
|
13008
|
+
revokedLogin = void 0;
|
|
13009
|
+
await this.tearDownSession();
|
|
13010
|
+
attempt++;
|
|
13011
|
+
continue;
|
|
13012
|
+
}
|
|
13013
|
+
if (quotaKind || fallback.outcome === "fork") {
|
|
13014
|
+
await this.emitQuotaExhaustedEvent(reason, fallback, detail, attemptedCredential);
|
|
13015
|
+
return;
|
|
13016
|
+
}
|
|
13017
|
+
authRetryExhausted = true;
|
|
13018
|
+
throw error;
|
|
13015
13019
|
}
|
|
13016
13020
|
if (error instanceof ClaudeMissingSessionError && !missingSessionReset) {
|
|
13017
13021
|
missingSessionReset = true;
|
|
@@ -3,13 +3,13 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
publishedPullRequestUrls
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-FDEJF43L.js";
|
|
7
7
|
import {
|
|
8
8
|
isRecord
|
|
9
9
|
} from "./chunk-UZSNFLDQ.js";
|
|
10
10
|
import {
|
|
11
11
|
shouldRefreshPullRequests
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-WR6M3Z4N.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
|
|
15
15
|
// src/services/post-tool-pr-notifier.ts
|
package/dist/src/subagent-mcp.js
CHANGED