replicas-engine 0.1.989 → 0.1.991
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-O3JY7A6A.js → asp-host-44AGB7NP.js} +5 -5
- package/dist/src/{chunk-LM4J2GLY.js → chunk-4OFU44QS.js} +1 -2
- package/dist/src/{chunk-VUUSZ5JS.js → chunk-5QXFYKQB.js} +6 -7
- package/dist/src/{chunk-BAJGQWIO.js → chunk-6REBKQ2X.js} +3 -3
- package/dist/src/{chunk-TFUEJW43.js → chunk-DFCNT76A.js} +1 -1
- package/dist/src/{chunk-WYERDOJD.js → chunk-KRUN7VY2.js} +1 -1
- package/dist/src/{chunk-RZBMLP2H.js → chunk-V7ADTVCG.js} +0 -1
- package/dist/src/{chunk-JBMI42EJ.js → chunk-XTEQAQO3.js} +3 -3
- package/dist/src/command-protection-hook.js +4 -4
- package/dist/src/headless-agent.js +3 -3
- package/dist/src/index.js +35 -138
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/subagent-mcp.js +1 -1
- package/package.json +1 -1
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
getCodexAspHost,
|
|
6
6
|
restartCodexAspHost,
|
|
7
7
|
restartCodexAspHostIfRunning
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-5QXFYKQB.js";
|
|
9
|
+
import "./chunk-4OFU44QS.js";
|
|
10
|
+
import "./chunk-6REBKQ2X.js";
|
|
11
|
+
import "./chunk-DFCNT76A.js";
|
|
12
12
|
import "./chunk-UZSNFLDQ.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-V7ADTVCG.js";
|
|
14
14
|
import "./chunk-VEQXQN22.js";
|
|
15
15
|
export {
|
|
16
16
|
getCodexAspHost,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
isValidAgentProvider,
|
|
15
15
|
parsePosixEnvFile,
|
|
16
16
|
readReplicasRuntimeEnv
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-V7ADTVCG.js";
|
|
18
18
|
|
|
19
19
|
// src/runtime-env-loader.ts
|
|
20
20
|
import { readFileSync } from "fs";
|
|
@@ -217,7 +217,6 @@ var MonolithService = class {
|
|
|
217
217
|
const query = new URLSearchParams({ provider: params.provider, exclude: params.exclude.join(",") });
|
|
218
218
|
if (params.exhaustedMethod) query.set("exhaustedMethod", params.exhaustedMethod);
|
|
219
219
|
if (params.userId) query.set("userId", params.userId);
|
|
220
|
-
if (params.chatId) query.set("chatId", params.chatId);
|
|
221
220
|
try {
|
|
222
221
|
const response = await monolithRequest(`/v1/engine/fallback-plan?${query}`, { method: "GET" });
|
|
223
222
|
if (response.status === 404) return createErrorResult({ message: "Monolith has no fallback-plan route", code: "unsupported" });
|
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
ENGINE_ENV,
|
|
6
6
|
monolithRequest,
|
|
7
7
|
setAgentCredentialSnapshot
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4OFU44QS.js";
|
|
9
9
|
import {
|
|
10
10
|
AppServerProcess,
|
|
11
11
|
buildCodexAgentEnv
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-6REBKQ2X.js";
|
|
13
13
|
import {
|
|
14
14
|
SUBPROCESS_MAX_BUFFER,
|
|
15
15
|
execFileAsync
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-DFCNT76A.js";
|
|
17
17
|
import {
|
|
18
18
|
isRecord
|
|
19
19
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
listOpenAICompatibleModels,
|
|
28
28
|
readOllamaAuthEnv,
|
|
29
29
|
resolveOpenAICompatibleModelsUrl
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-V7ADTVCG.js";
|
|
31
31
|
|
|
32
32
|
// src/managers/codex-token-manager.ts
|
|
33
33
|
import { promises as fs } from "fs";
|
|
@@ -260,7 +260,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
260
260
|
await this.applyCredentialUpdate(++this.credentialGeneration, async () => {
|
|
261
261
|
await this.applyCredentialsResponse(data);
|
|
262
262
|
setAgentCredentialSnapshot("codex", data);
|
|
263
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
263
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-44AGB7NP.js");
|
|
264
264
|
await restartCodexAspHostIfRunning2();
|
|
265
265
|
});
|
|
266
266
|
await this.start(true);
|
|
@@ -280,7 +280,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
280
280
|
await this.applyCredentialUpdate(generation, async () => {
|
|
281
281
|
await this.applyCredentialsResponse(data);
|
|
282
282
|
if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
|
|
283
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
283
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-44AGB7NP.js");
|
|
284
284
|
await restartCodexAspHostIfRunning2();
|
|
285
285
|
}
|
|
286
286
|
setAgentCredentialSnapshot("codex", data);
|
|
@@ -511,7 +511,6 @@ export {
|
|
|
511
511
|
listCredentialFallbacks,
|
|
512
512
|
routineRefreshExclusions,
|
|
513
513
|
recordExhaustedCredential,
|
|
514
|
-
credentialSwapError,
|
|
515
514
|
refreshDelayMs,
|
|
516
515
|
BaseRefreshManager,
|
|
517
516
|
applyAuthEnvTransition,
|
|
@@ -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-DFCNT76A.js";
|
|
7
7
|
import {
|
|
8
8
|
isVersionBelow
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-V7ADTVCG.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.991";
|
|
244
244
|
var INITIALIZE_METHOD = "initialize";
|
|
245
245
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
246
246
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -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-V7ADTVCG.js";
|
|
7
7
|
|
|
8
8
|
// src/utils/exec.ts
|
|
9
9
|
import { exec, execFile } from "child_process";
|
|
@@ -1240,7 +1240,6 @@ var sendChatMessageRequestSchema = z3.object({
|
|
|
1240
1240
|
idempotencyKey: z3.string().min(1).max(128).optional(),
|
|
1241
1241
|
automationId: z3.string().optional(),
|
|
1242
1242
|
environmentId: z3.string().min(1).optional(),
|
|
1243
|
-
chatCredentials: z3.boolean().optional(),
|
|
1244
1243
|
senderUserId: z3.string().optional(),
|
|
1245
1244
|
senderEmail: z3.string().optional(),
|
|
1246
1245
|
senderDisplayName: z3.string().optional(),
|
|
@@ -3,18 +3,18 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
monolithRequest
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4OFU44QS.js";
|
|
7
7
|
import {
|
|
8
8
|
SUBPROCESS_MAX_BUFFER,
|
|
9
9
|
execFileAsync
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-DFCNT76A.js";
|
|
11
11
|
import {
|
|
12
12
|
extractCommandProtectionCommandText,
|
|
13
13
|
findCommandProtectionGitLookups,
|
|
14
14
|
findGitCommitSignals,
|
|
15
15
|
findPrMergeSignals,
|
|
16
16
|
parseCommandProtectionRequest
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-V7ADTVCG.js";
|
|
18
18
|
|
|
19
19
|
// src/services/command-protection-service.ts
|
|
20
20
|
import { readFile, stat } from "fs/promises";
|
|
@@ -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-XTEQAQO3.js";
|
|
7
|
+
import "./chunk-4OFU44QS.js";
|
|
8
|
+
import "./chunk-DFCNT76A.js";
|
|
9
9
|
import {
|
|
10
10
|
isRecord
|
|
11
11
|
} from "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-V7ADTVCG.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
|
|
15
15
|
// src/command-protection-hook.ts
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
AppServerProcess,
|
|
9
9
|
buildCodexAgentEnv
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-6REBKQ2X.js";
|
|
11
|
+
import "./chunk-DFCNT76A.js";
|
|
12
12
|
import {
|
|
13
13
|
AGENT,
|
|
14
14
|
headlessAgentRequestSchema
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-V7ADTVCG.js";
|
|
16
16
|
import "./chunk-VEQXQN22.js";
|
|
17
17
|
|
|
18
18
|
// src/headless-agent.ts
|
package/dist/src/index.js
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
reportCommandProtectionBlock,
|
|
33
33
|
resolveDiffBase,
|
|
34
34
|
runGitCommand
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-XTEQAQO3.js";
|
|
36
36
|
import {
|
|
37
37
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
38
38
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -57,14 +57,13 @@ import {
|
|
|
57
57
|
} from "./chunk-P73LGPQO.js";
|
|
58
58
|
import {
|
|
59
59
|
publishedPullRequestUrls
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-KRUN7VY2.js";
|
|
61
61
|
import {
|
|
62
62
|
BaseRefreshManager,
|
|
63
63
|
CodexAspAuthMethodChangedError,
|
|
64
64
|
applyAuthEnvTransition,
|
|
65
65
|
clearCredentialFallbacks,
|
|
66
66
|
codexTokenManager,
|
|
67
|
-
credentialSwapError,
|
|
68
67
|
getCodexAspHost,
|
|
69
68
|
listCredentialFallbacks,
|
|
70
69
|
recordCredentialFallback,
|
|
@@ -72,7 +71,7 @@ import {
|
|
|
72
71
|
refreshDelayMs,
|
|
73
72
|
restartCodexAspHost,
|
|
74
73
|
routineRefreshExclusions
|
|
75
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-5QXFYKQB.js";
|
|
76
75
|
import {
|
|
77
76
|
ENGINE_ENV,
|
|
78
77
|
monolithRequest,
|
|
@@ -80,16 +79,16 @@ import {
|
|
|
80
79
|
readRuntimeEnvFile,
|
|
81
80
|
reloadEngineEnv,
|
|
82
81
|
setAgentCredentialSnapshot
|
|
83
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-4OFU44QS.js";
|
|
84
83
|
import {
|
|
85
84
|
AspClient,
|
|
86
85
|
getCodexModelProvider
|
|
87
|
-
} from "./chunk-
|
|
86
|
+
} from "./chunk-6REBKQ2X.js";
|
|
88
87
|
import {
|
|
89
88
|
SUBPROCESS_MAX_BUFFER,
|
|
90
89
|
execAsync,
|
|
91
90
|
execFileAsync
|
|
92
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-DFCNT76A.js";
|
|
93
92
|
import {
|
|
94
93
|
isRecord as isRecord2
|
|
95
94
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -315,7 +314,7 @@ import {
|
|
|
315
314
|
workspaceCredentialProviderSchema,
|
|
316
315
|
workspaceTokenRequestSchema,
|
|
317
316
|
workspaceTokenResponseSchema
|
|
318
|
-
} from "./chunk-
|
|
317
|
+
} from "./chunk-V7ADTVCG.js";
|
|
319
318
|
import {
|
|
320
319
|
cloneMcpConfig,
|
|
321
320
|
ensureCompatibilityImports,
|
|
@@ -11684,21 +11683,16 @@ var AuthFallbackCoordinator = class {
|
|
|
11684
11683
|
provider;
|
|
11685
11684
|
record;
|
|
11686
11685
|
context;
|
|
11687
|
-
async fallBack(reason, detail
|
|
11688
|
-
const tokenManager =
|
|
11689
|
-
const
|
|
11690
|
-
|
|
11691
|
-
if (exhausted) {
|
|
11692
|
-
if (chatCredentials) chatCredentials.markExhausted(exhausted);
|
|
11693
|
-
else recordExhaustedCredential(this.provider, exhausted);
|
|
11694
|
-
}
|
|
11686
|
+
async fallBack(reason, detail) {
|
|
11687
|
+
const tokenManager = SWAPPABLE_AGENTS[this.provider];
|
|
11688
|
+
const exhausted = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS[this.provider];
|
|
11689
|
+
if (exhausted) recordExhaustedCredential(this.provider, exhausted);
|
|
11695
11690
|
const { userId, excludeProviders, forkable } = this.context();
|
|
11696
11691
|
const plan = await monolithService.getFallbackPlan({
|
|
11697
11692
|
provider: this.provider,
|
|
11698
11693
|
exhaustedMethod: exhausted?.method,
|
|
11699
11694
|
exclude: excludeProviders,
|
|
11700
|
-
userId
|
|
11701
|
-
chatId: chatCredentials?.chatId
|
|
11695
|
+
userId
|
|
11702
11696
|
});
|
|
11703
11697
|
if (!plan.ok && plan.error.code === "unavailable") {
|
|
11704
11698
|
console.error(`[AuthFallback] ${this.provider} fallback stopped; plan unavailable:`, plan.error.message);
|
|
@@ -11722,21 +11716,21 @@ var AuthFallbackCoordinator = class {
|
|
|
11722
11716
|
failed ||= swap.error.code !== "no_credentials";
|
|
11723
11717
|
continue;
|
|
11724
11718
|
}
|
|
11725
|
-
const applied =
|
|
11719
|
+
const applied = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS[this.provider] ?? exhausted;
|
|
11726
11720
|
if (applied.method === exhausted.method && applied.scope === exhausted.scope) {
|
|
11727
11721
|
failed = true;
|
|
11728
11722
|
continue;
|
|
11729
11723
|
}
|
|
11730
|
-
this.recordNotice(reason, exhausted, applied, "switched", detail
|
|
11724
|
+
this.recordNotice(reason, exhausted, applied, "switched", detail);
|
|
11731
11725
|
const model = step.models?.[applied.method];
|
|
11732
11726
|
return { outcome: "switched", ...model ? { model } : {} };
|
|
11733
11727
|
}
|
|
11734
11728
|
if (!tokenManager || !exhausted) return { outcome: "unavailable" };
|
|
11735
11729
|
if (!failed) return { outcome: "not_configured" };
|
|
11736
|
-
this.recordNotice(reason, exhausted, exhausted, "failed", "Replicas could not load an alternate credential."
|
|
11730
|
+
this.recordNotice(reason, exhausted, exhausted, "failed", "Replicas could not load an alternate credential.");
|
|
11737
11731
|
return { outcome: "failed" };
|
|
11738
11732
|
}
|
|
11739
|
-
recordNotice(reason, exhausted, applied, status, detail
|
|
11733
|
+
recordNotice(reason, exhausted, applied, status, detail) {
|
|
11740
11734
|
const payload = {
|
|
11741
11735
|
provider: this.provider,
|
|
11742
11736
|
reason,
|
|
@@ -11751,7 +11745,7 @@ var AuthFallbackCoordinator = class {
|
|
|
11751
11745
|
};
|
|
11752
11746
|
const at = (/* @__PURE__ */ new Date()).toISOString();
|
|
11753
11747
|
this.record({ timestamp: at, type: AUTH_FALLBACK_EVENT_TYPE, payload: { ...payload } });
|
|
11754
|
-
|
|
11748
|
+
recordCredentialFallback({ ...payload, at });
|
|
11755
11749
|
}
|
|
11756
11750
|
};
|
|
11757
11751
|
|
|
@@ -12024,9 +12018,9 @@ var CodingAgentManager = class {
|
|
|
12024
12018
|
this.getHistorySink()?.append(event);
|
|
12025
12019
|
}, options.fallbackContext ?? (() => ({ excludeProviders: [], forkable: false }))) : null;
|
|
12026
12020
|
}
|
|
12027
|
-
async fallBackCredential(reason, detail
|
|
12021
|
+
async fallBackCredential(reason, detail) {
|
|
12028
12022
|
if (!this.authFallback) return { outcome: "unavailable" };
|
|
12029
|
-
const result = await this.authFallback.fallBack(reason, detail
|
|
12023
|
+
const result = await this.authFallback.fallBack(reason, detail);
|
|
12030
12024
|
if (result.outcome === "switched" && result.model) await this.onModelSwitched(result.model);
|
|
12031
12025
|
return result;
|
|
12032
12026
|
}
|
|
@@ -12353,12 +12347,12 @@ function resolveClaudeAuthMethodForMessage(env = ENGINE_ENV) {
|
|
|
12353
12347
|
if (env.ANTHROPIC_API_KEY) return "api_key";
|
|
12354
12348
|
return "unknown";
|
|
12355
12349
|
}
|
|
12356
|
-
function buildClaudeAgentEnv(overrides
|
|
12357
|
-
const env = { ...
|
|
12350
|
+
function buildClaudeAgentEnv(overrides) {
|
|
12351
|
+
const env = { ...process.env };
|
|
12358
12352
|
if (overrides) {
|
|
12359
12353
|
Object.assign(env, overrides);
|
|
12360
12354
|
}
|
|
12361
|
-
const method =
|
|
12355
|
+
const method = ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD;
|
|
12362
12356
|
const isBedrock = method === "bedrock" || env.REPLICAS_CLAUDE_AUTH_METHOD === "bedrock" || env.CLAUDE_CODE_USE_BEDROCK === "1";
|
|
12363
12357
|
if (method === "oauth" || method === "bedrock" || method === "foundry" || isBedrock) {
|
|
12364
12358
|
env.ANTHROPIC_API_KEY = void 0;
|
|
@@ -12390,90 +12384,6 @@ async function getAgentAdditionalDirectories() {
|
|
|
12390
12384
|
}
|
|
12391
12385
|
}
|
|
12392
12386
|
|
|
12393
|
-
// src/managers/chat-claude-credentials.ts
|
|
12394
|
-
var EXHAUSTED_RETRY_MS = 60 * 60 * 1e3;
|
|
12395
|
-
var AUTH_SELECTOR_KEYS = [
|
|
12396
|
-
"ANTHROPIC_API_KEY",
|
|
12397
|
-
"ANTHROPIC_AUTH_TOKEN",
|
|
12398
|
-
"ANTHROPIC_BASE_URL",
|
|
12399
|
-
"CLAUDE_CODE_USE_BEDROCK",
|
|
12400
|
-
"CLAUDE_CODE_USE_FOUNDRY"
|
|
12401
|
-
];
|
|
12402
|
-
var ChatClaudeCredentials = class {
|
|
12403
|
-
constructor(chatId) {
|
|
12404
|
-
this.chatId = chatId;
|
|
12405
|
-
}
|
|
12406
|
-
chatId;
|
|
12407
|
-
credential = null;
|
|
12408
|
-
exhausted = /* @__PURE__ */ new Map();
|
|
12409
|
-
get method() {
|
|
12410
|
-
return this.credential?.type;
|
|
12411
|
-
}
|
|
12412
|
-
snapshot() {
|
|
12413
|
-
const credential = this.credential;
|
|
12414
|
-
if (!credential?.scope) return void 0;
|
|
12415
|
-
return {
|
|
12416
|
-
method: credential.type,
|
|
12417
|
-
scope: credential.scope,
|
|
12418
|
-
...credential.revision ? { revision: credential.revision } : {},
|
|
12419
|
-
...credential.account ? { account: credential.account } : {}
|
|
12420
|
-
};
|
|
12421
|
-
}
|
|
12422
|
-
/** The process env authenticated as this credential, without touching the workspace's. */
|
|
12423
|
-
env() {
|
|
12424
|
-
const env = { ...process.env, CLAUDE_CODE_OAUTH_TOKEN: void 0 };
|
|
12425
|
-
if (!this.credential) return env;
|
|
12426
|
-
for (const key of AUTH_SELECTOR_KEYS) env[key] = void 0;
|
|
12427
|
-
applyAuthEnvTransition({
|
|
12428
|
-
prevMethod: ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD ?? "none",
|
|
12429
|
-
authKeys: CLAUDE_AUTH_ENV_KEYS,
|
|
12430
|
-
authKeysByMethod: CLAUDE_AUTH_ENV_KEYS_BY_METHOD,
|
|
12431
|
-
newEnvVars: claudeAuthEnvFromResponse(this.credential),
|
|
12432
|
-
envs: [env]
|
|
12433
|
-
});
|
|
12434
|
-
if (this.credential.type === "oauth") env.CLAUDE_CODE_OAUTH_TOKEN = this.credential.accessToken;
|
|
12435
|
-
return env;
|
|
12436
|
-
}
|
|
12437
|
-
markExhausted(credential) {
|
|
12438
|
-
this.exhausted.set(`${credential.method}|${credential.scope}`, { credential, at: Date.now() });
|
|
12439
|
-
}
|
|
12440
|
-
async refresh() {
|
|
12441
|
-
const live = this.snapshot();
|
|
12442
|
-
const excludeCredentials = this.spent().filter((spent) => spent.method !== live?.method || spent.scope !== live?.scope);
|
|
12443
|
-
try {
|
|
12444
|
-
await this.request(excludeCredentials.length > 0 ? { excludeCredentials } : {});
|
|
12445
|
-
} catch (error) {
|
|
12446
|
-
if (!this.credential) throw error;
|
|
12447
|
-
console.warn(`[ChatClaudeCredentials] Keeping the current credential for chat ${this.chatId}:`, error);
|
|
12448
|
-
}
|
|
12449
|
-
}
|
|
12450
|
-
async fetchFreshCredentials(failureReason, failureKind, failedCredential = this.snapshot(), allowedMethods) {
|
|
12451
|
-
const failedMethod = this.credential?.type;
|
|
12452
|
-
const excludeCredentials = this.spent();
|
|
12453
|
-
try {
|
|
12454
|
-
await this.request({
|
|
12455
|
-
...failedMethod ? { failedMethod } : {},
|
|
12456
|
-
...failedCredential?.method === failedMethod ? { failedCredential } : {},
|
|
12457
|
-
failureReason,
|
|
12458
|
-
failureKind,
|
|
12459
|
-
...excludeCredentials.length > 0 ? { excludeCredentials } : {},
|
|
12460
|
-
...allowedMethods ? { allowedMethods: [...allowedMethods] } : {}
|
|
12461
|
-
});
|
|
12462
|
-
return createSuccessResult();
|
|
12463
|
-
} catch (error) {
|
|
12464
|
-
console.error(`[ChatClaudeCredentials] Failed to fetch fresh credentials for chat ${this.chatId}:`, error);
|
|
12465
|
-
return credentialSwapError(error);
|
|
12466
|
-
}
|
|
12467
|
-
}
|
|
12468
|
-
spent() {
|
|
12469
|
-
const cutoff = Date.now() - EXHAUSTED_RETRY_MS;
|
|
12470
|
-
return [...this.exhausted.values()].filter(({ at }) => at >= cutoff).map(({ credential }) => credential);
|
|
12471
|
-
}
|
|
12472
|
-
async request(body) {
|
|
12473
|
-
this.credential = await requestClaudeCredentials({ ...body, chatId: this.chatId });
|
|
12474
|
-
}
|
|
12475
|
-
};
|
|
12476
|
-
|
|
12477
12387
|
// src/utils/linear-event-forwarder.ts
|
|
12478
12388
|
function isLinearThoughtEvent(event) {
|
|
12479
12389
|
return event.content.type === "thought";
|
|
@@ -13388,8 +13298,6 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13388
13298
|
goalClear = null;
|
|
13389
13299
|
lastRequest = null;
|
|
13390
13300
|
onChatCredential;
|
|
13391
|
-
chatCredentials = null;
|
|
13392
|
-
turnCredentials = null;
|
|
13393
13301
|
constructor(options) {
|
|
13394
13302
|
super({
|
|
13395
13303
|
...options,
|
|
@@ -13707,10 +13615,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13707
13615
|
await this.goalClear?.catch(() => {
|
|
13708
13616
|
});
|
|
13709
13617
|
try {
|
|
13710
|
-
this.turnCredentials = request.chatCredentials && this.chatId ? this.chatCredentials ??= new ChatClaudeCredentials(this.chatId) : null;
|
|
13711
|
-
await this.turnCredentials?.refresh();
|
|
13712
13618
|
while (true) {
|
|
13713
|
-
const attemptedCredential =
|
|
13619
|
+
const attemptedCredential = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.claude;
|
|
13714
13620
|
const steers = carriedSteers;
|
|
13715
13621
|
carriedSteers = /* @__PURE__ */ new Map();
|
|
13716
13622
|
try {
|
|
@@ -13721,7 +13627,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13721
13627
|
const quotaKind = _ClaudeManager.quotaLimitKind(error);
|
|
13722
13628
|
if (quotaKind) {
|
|
13723
13629
|
const detail = error instanceof ClaudeQuotaError ? error.message : extractErrorText(error);
|
|
13724
|
-
const fallback = quotaFallbacks < MAX_QUOTA_FALLBACKS ? await this.fallBackCredential(quotaKind, detail
|
|
13630
|
+
const fallback = quotaFallbacks < MAX_QUOTA_FALLBACKS ? await this.fallBackCredential(quotaKind, detail) : { outcome: "unavailable" };
|
|
13725
13631
|
if (fallback.outcome === "switched") {
|
|
13726
13632
|
if (fallback.model) currentRequest = { ...currentRequest, model: fallback.model };
|
|
13727
13633
|
quotaFallbacks++;
|
|
@@ -13743,7 +13649,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13743
13649
|
error
|
|
13744
13650
|
);
|
|
13745
13651
|
this.setAuthRetrying(true);
|
|
13746
|
-
const refreshed = await
|
|
13652
|
+
const refreshed = await claudeTokenManager.fetchFreshCredentials(
|
|
13747
13653
|
error instanceof Error ? error.message : String(error),
|
|
13748
13654
|
"rejected",
|
|
13749
13655
|
attemptedCredential
|
|
@@ -13836,11 +13742,8 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13836
13742
|
[this.claudeAuthFailureMessage()]
|
|
13837
13743
|
);
|
|
13838
13744
|
}
|
|
13839
|
-
claudeAuthMethod() {
|
|
13840
|
-
return this.turnCredentials ? this.turnCredentials.method ?? "unknown" : resolveClaudeAuthMethodForMessage();
|
|
13841
|
-
}
|
|
13842
13745
|
claudeAuthFailureMessage() {
|
|
13843
|
-
switch (
|
|
13746
|
+
switch (resolveClaudeAuthMethodForMessage()) {
|
|
13844
13747
|
case "oauth":
|
|
13845
13748
|
return "Claude Code OAuth authentication failed after refreshing credentials. Reconnect Claude Code in Settings \u2192 Agents and try again.";
|
|
13846
13749
|
case "api_key":
|
|
@@ -13908,19 +13811,16 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
13908
13811
|
this.buildCombinedInstructions(customInstructions, true),
|
|
13909
13812
|
"Background tasks must have a concrete completion condition. Use foreground commands for sequential work and managed workspace services for servers. Reserve persistent Monitor tasks for ongoing watches the user requested. You may end a turn while actual background work continues, but do not promise a later update unless a task was successfully launched. Report completion or failure when its notification arrives."
|
|
13910
13813
|
].filter(Boolean).join("\n\n");
|
|
13911
|
-
const resolvedModel = normalizeClaudeModel(model) || (
|
|
13912
|
-
const claudeCodeModel = toClaudeCodeModel(
|
|
13814
|
+
const resolvedModel = normalizeClaudeModel(model) || (resolveClaudeAuthMethodForMessage() === "ollama" ? DEFAULT_OLLAMA_MODEL : void 0) || DEFAULT_CLAUDE_MODEL;
|
|
13815
|
+
const claudeCodeModel = toClaudeCodeModel(
|
|
13816
|
+
resolvedModel,
|
|
13817
|
+
ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD === "bedrock" || ENGINE_ENV.CLAUDE_CODE_USE_BEDROCK === "1"
|
|
13818
|
+
);
|
|
13913
13819
|
const resolvedPermissionMode = planMode ? "plan" : "bypassPermissions";
|
|
13914
13820
|
const resolvedFastMode = Boolean(fastMode && canUseClaudeFastMode(resolvedModel));
|
|
13915
|
-
|
|
13916
|
-
this.onChatCredential(chatCredential ? {
|
|
13917
|
-
method: chatCredential.method,
|
|
13918
|
-
scope: chatCredential.scope,
|
|
13919
|
-
...chatCredential.account ? { account: chatCredential.account } : {}
|
|
13920
|
-
} : "workspace");
|
|
13821
|
+
this.onChatCredential("workspace");
|
|
13921
13822
|
const signature = {
|
|
13922
|
-
|
|
13923
|
-
credential: this.turnCredentials ? `chat:${JSON.stringify(this.turnCredentials.snapshot())}` : JSON.stringify(ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.claude),
|
|
13823
|
+
credential: JSON.stringify(ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.claude),
|
|
13924
13824
|
combinedInstructions,
|
|
13925
13825
|
thinkingLevel,
|
|
13926
13826
|
enableInteractiveTools: Boolean(enableInteractiveTools),
|
|
@@ -14029,10 +13929,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
14029
13929
|
}
|
|
14030
13930
|
/** Query inputs shared by real sessions and slash-command discovery. */
|
|
14031
13931
|
async buildSharedQueryOptions() {
|
|
14032
|
-
const env = buildClaudeAgentEnv(
|
|
14033
|
-
this.subagentMcpParentChatId() ? { CLAUDE_CODE_STREAM_CLOSE_TIMEOUT: "900000" } : void 0,
|
|
14034
|
-
this.turnCredentials?.env()
|
|
14035
|
-
);
|
|
13932
|
+
const env = buildClaudeAgentEnv(this.subagentMcpParentChatId() ? { CLAUDE_CODE_STREAM_CLOSE_TIMEOUT: "900000" } : void 0);
|
|
14036
13933
|
const additionalDirectories = await getAgentAdditionalDirectories();
|
|
14037
13934
|
let plugins = [];
|
|
14038
13935
|
let enableAllSkills = false;
|
|
@@ -14093,7 +13990,7 @@ var ClaudeManager = class _ClaudeManager extends CodingAgentManager {
|
|
|
14093
13990
|
...shared.enableAllSkills ? { skills: "all" } : {},
|
|
14094
13991
|
env: {
|
|
14095
13992
|
...shared.env,
|
|
14096
|
-
...
|
|
13993
|
+
...resolveClaudeAuthMethodForMessage() === "ollama" ? {
|
|
14097
13994
|
ANTHROPIC_DEFAULT_SONNET_MODEL: resolvedModel,
|
|
14098
13995
|
ANTHROPIC_DEFAULT_OPUS_MODEL: resolvedModel,
|
|
14099
13996
|
ANTHROPIC_DEFAULT_HAIKU_MODEL: resolvedModel
|
|
@@ -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-KRUN7VY2.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-V7ADTVCG.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