replicas-engine 0.1.1191 → 0.1.1193
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-XOH4VZ54.js → asp-host-J2LJFIX7.js} +5 -5
- package/dist/src/{chunk-IXT5Q2OM.js → chunk-2G62KJLA.js} +1 -1
- package/dist/src/{chunk-VPJCBNAX.js → chunk-5ZVVCDEG.js} +3 -3
- package/dist/src/{chunk-XCLNV3EB.js → chunk-G6OGB6HX.js} +14 -7
- package/dist/src/{chunk-2U32TFQX.js → chunk-GMZHK5QI.js} +2 -2
- package/dist/src/{chunk-4OY2UIEC.js → chunk-NAX7OMFI.js} +11 -7
- package/dist/src/{chunk-3PVMBGPZ.js → chunk-VV6RUT4F.js} +18 -7
- package/dist/src/{chunk-6GGRJKT4.js → chunk-WJAKGFYD.js} +2 -2
- package/dist/src/{chunk-TX3C2WLH.js → chunk-ZKSO7G5X.js} +1 -1
- package/dist/src/command-protection-hook.js +4 -4
- package/dist/src/headless-agent.js +4 -4
- package/dist/src/index.js +45 -15
- 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-NAX7OMFI.js";
|
|
12
|
+
import "./chunk-WJAKGFYD.js";
|
|
13
|
+
import "./chunk-5ZVVCDEG.js";
|
|
14
|
+
import "./chunk-2G62KJLA.js";
|
|
15
15
|
import "./chunk-UZSNFLDQ.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-G6OGB6HX.js";
|
|
17
17
|
import "./chunk-VEQXQN22.js";
|
|
18
18
|
export {
|
|
19
19
|
CODEX_ULTRAFAST_SERVICE_TIER,
|
|
@@ -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-G6OGB6HX.js";
|
|
7
7
|
|
|
8
8
|
// src/utils/exec.ts
|
|
9
9
|
import { exec, execFile } from "child_process";
|
|
@@ -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-2G62KJLA.js";
|
|
7
7
|
import {
|
|
8
8
|
isVersionBelow
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-G6OGB6HX.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.1193";
|
|
244
244
|
var INITIALIZE_METHOD = "initialize";
|
|
245
245
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
246
246
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -996,10 +996,7 @@ async function listOpenAICompatibleModels(credential) {
|
|
|
996
996
|
for (let page = 0; page < MAX_CATALOG_PAGES; page += 1) {
|
|
997
997
|
validateExternalApiHost(modelsUrl, "Models endpoint");
|
|
998
998
|
const response = await fetch(modelsUrl, {
|
|
999
|
-
headers: {
|
|
1000
|
-
Accept: "application/json",
|
|
1001
|
-
Authorization: credential.authorizationHeader || `Bearer ${credential.apiKey}`
|
|
1002
|
-
},
|
|
999
|
+
headers: { Accept: "application/json", Authorization: credential.authorizationHeader || `Bearer ${credential.apiKey}` },
|
|
1003
1000
|
redirect: "error",
|
|
1004
1001
|
signal
|
|
1005
1002
|
});
|
|
@@ -1021,6 +1018,13 @@ async function listOpenAICompatibleModels(credential) {
|
|
|
1021
1018
|
function resolveOpenAICompatibleModelsUrl(values) {
|
|
1022
1019
|
return values.modelsUrl || `${values.baseUrl}/models`;
|
|
1023
1020
|
}
|
|
1021
|
+
function openAICompatibleAuthEnvKeys(agent) {
|
|
1022
|
+
return ["API_KEY", "BASE_URL", "MODELS_URL", "AUTHORIZATION_HEADER"].map((key) => `REPLICAS_${agent.toUpperCase()}_OPENAI_COMPATIBLE_${key}`);
|
|
1023
|
+
}
|
|
1024
|
+
function readOpenAICompatibleAuthEnv(agent, env) {
|
|
1025
|
+
const [apiKey, baseUrl, modelsUrl, authorizationHeader] = openAICompatibleAuthEnvKeys(agent).map((key) => env[key] || void 0);
|
|
1026
|
+
return baseUrl && (apiKey || authorizationHeader) ? { apiKey, baseUrl, modelsUrl, authorizationHeader } : null;
|
|
1027
|
+
}
|
|
1024
1028
|
|
|
1025
1029
|
// ../shared/src/credentials/ollama.ts
|
|
1026
1030
|
var OLLAMA_AGENTS = ["claude", "codex", "opencode", "pi"];
|
|
@@ -1152,7 +1156,8 @@ var INFERENCE_PROVIDER_LABELS = {
|
|
|
1152
1156
|
[CREDENTIAL_METHOD.OLLAMA]: "Ollama",
|
|
1153
1157
|
[CREDENTIAL_METHOD.OPENCODE_GO]: "OpenCode Go",
|
|
1154
1158
|
[CREDENTIAL_METHOD.ASTER]: "Aster",
|
|
1155
|
-
[CREDENTIAL_METHOD.OPENROUTER]: "OpenRouter"
|
|
1159
|
+
[CREDENTIAL_METHOD.OPENROUTER]: "OpenRouter",
|
|
1160
|
+
[CREDENTIAL_METHOD.OPENAI_COMPATIBLE]: "OpenAI-compatible endpoint"
|
|
1156
1161
|
};
|
|
1157
1162
|
var AGENT_CREDENTIAL_METHODS_IN_ORDER = {
|
|
1158
1163
|
[AGENT.CLAUDE]: [
|
|
@@ -1180,12 +1185,14 @@ var AGENT_CREDENTIAL_METHODS_IN_ORDER = {
|
|
|
1180
1185
|
{ method: CREDENTIAL_METHOD.OPENCODE_GO, credentialType: CREDENTIAL_TYPE.OPENCODE_GO_API_KEY },
|
|
1181
1186
|
{ method: CREDENTIAL_METHOD.ASTER, credentialType: CREDENTIAL_TYPE.ASTER_API_KEY },
|
|
1182
1187
|
{ method: CREDENTIAL_METHOD.OPENROUTER, credentialType: CREDENTIAL_TYPE.OPENROUTER_API_KEY },
|
|
1188
|
+
{ method: CREDENTIAL_METHOD.OPENAI_COMPATIBLE, credentialType: CREDENTIAL_TYPE.OPENAI_COMPATIBLE },
|
|
1183
1189
|
{ method: CREDENTIAL_METHOD.OLLAMA, credentialType: CREDENTIAL_TYPE.OLLAMA }
|
|
1184
1190
|
],
|
|
1185
1191
|
[AGENT.PI]: [
|
|
1186
1192
|
{ method: CREDENTIAL_METHOD.OPENCODE_GO, credentialType: CREDENTIAL_TYPE.OPENCODE_GO_API_KEY },
|
|
1187
1193
|
{ method: CREDENTIAL_METHOD.ASTER, credentialType: CREDENTIAL_TYPE.ASTER_API_KEY },
|
|
1188
1194
|
{ method: CREDENTIAL_METHOD.OPENROUTER, credentialType: CREDENTIAL_TYPE.OPENROUTER_API_KEY },
|
|
1195
|
+
{ method: CREDENTIAL_METHOD.OPENAI_COMPATIBLE, credentialType: CREDENTIAL_TYPE.OPENAI_COMPATIBLE },
|
|
1189
1196
|
{ method: CREDENTIAL_METHOD.OLLAMA, credentialType: CREDENTIAL_TYPE.OLLAMA }
|
|
1190
1197
|
]
|
|
1191
1198
|
};
|
|
@@ -1202,8 +1209,6 @@ function getCredentialMethodLabel(agent, method) {
|
|
|
1202
1209
|
if (agent === AGENT.CURSOR) return "Cursor API key";
|
|
1203
1210
|
if (agent === AGENT.MUSE) return "Muse API key";
|
|
1204
1211
|
return "Anthropic API key";
|
|
1205
|
-
case CREDENTIAL_METHOD.OPENAI_COMPATIBLE:
|
|
1206
|
-
return "OpenAI-compatible endpoint";
|
|
1207
1212
|
case CREDENTIAL_METHOD.FOUNDRY:
|
|
1208
1213
|
return "Microsoft Foundry";
|
|
1209
1214
|
case CREDENTIAL_METHOD.BEDROCK:
|
|
@@ -1212,6 +1217,7 @@ function getCredentialMethodLabel(agent, method) {
|
|
|
1212
1217
|
case CREDENTIAL_METHOD.OPENCODE_GO:
|
|
1213
1218
|
case CREDENTIAL_METHOD.ASTER:
|
|
1214
1219
|
case CREDENTIAL_METHOD.OPENROUTER:
|
|
1220
|
+
case CREDENTIAL_METHOD.OPENAI_COMPATIBLE:
|
|
1215
1221
|
return INFERENCE_PROVIDER_LABELS[method];
|
|
1216
1222
|
case CREDENTIAL_METHOD.MUSE_OAUTH:
|
|
1217
1223
|
return "Muse account";
|
|
@@ -9924,6 +9930,7 @@ export {
|
|
|
9924
9930
|
detectAgentQuotaLimit,
|
|
9925
9931
|
listOpenAICompatibleModels,
|
|
9926
9932
|
resolveOpenAICompatibleModelsUrl,
|
|
9933
|
+
readOpenAICompatibleAuthEnv,
|
|
9927
9934
|
OLLAMA_AGENTS,
|
|
9928
9935
|
readOllamaAuthEnv,
|
|
9929
9936
|
DEFAULT_OLLAMA_MODEL,
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
getOriginDefaultBranch,
|
|
6
6
|
monolithRequest,
|
|
7
7
|
runGitCommand
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-WJAKGFYD.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-G6OGB6HX.js";
|
|
16
16
|
|
|
17
17
|
// src/services/command-protection-service.ts
|
|
18
18
|
import { readFile, stat } from "fs/promises";
|
|
@@ -10,15 +10,15 @@ import {
|
|
|
10
10
|
resolveDiffBase,
|
|
11
11
|
runGitCommand,
|
|
12
12
|
setAgentCredentialSnapshot
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-WJAKGFYD.js";
|
|
14
14
|
import {
|
|
15
15
|
AppServerProcess,
|
|
16
16
|
buildCodexAgentEnv
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-5ZVVCDEG.js";
|
|
18
18
|
import {
|
|
19
19
|
SUBPROCESS_MAX_BUFFER,
|
|
20
20
|
execFileAsync
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-2G62KJLA.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-G6OGB6HX.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-J2LJFIX7.js");
|
|
295
295
|
await restartCodexAspHostIfRunning2();
|
|
296
296
|
});
|
|
297
297
|
await this.start(true);
|
|
@@ -313,7 +313,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
313
313
|
const accountChanged = ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex?.credentialId !== data.credentialId;
|
|
314
314
|
await this.applyCredentialsResponse(data);
|
|
315
315
|
if (restartOnChange && (accountChanged || CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index]))) {
|
|
316
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
316
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-J2LJFIX7.js");
|
|
317
317
|
await restartCodexAspHostIfRunning2();
|
|
318
318
|
}
|
|
319
319
|
setAgentCredentialSnapshot("codex", data);
|
|
@@ -1897,7 +1897,11 @@ async function writeCodexModelCatalog(modelsUrl) {
|
|
|
1897
1897
|
if (!isRecord(template)) throw new Error("Codex did not return a model catalog template");
|
|
1898
1898
|
const catalog = models.flatMap((model) => model.contextWindow ? [{
|
|
1899
1899
|
...template,
|
|
1900
|
-
|
|
1900
|
+
// The template's freeform apply_patch, verbosity and tool search are OpenAI-only; other models reject the request.
|
|
1901
|
+
apply_patch_tool_type: null,
|
|
1902
|
+
support_verbosity: false,
|
|
1903
|
+
supports_search_tool: false,
|
|
1904
|
+
...ollama ? { input_modalities: ["text"] } : {},
|
|
1901
1905
|
slug: model.id,
|
|
1902
1906
|
display_name: model.displayName,
|
|
1903
1907
|
description: model.description ?? model.displayName,
|
|
@@ -3,15 +3,17 @@ 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-5ZVVCDEG.js";
|
|
7
7
|
import {
|
|
8
8
|
ASTER_BASE_URL,
|
|
9
9
|
ASTER_PROVIDER,
|
|
10
|
+
CREDENTIAL_METHOD,
|
|
10
11
|
OPENCODE_GO_PROVIDER,
|
|
11
12
|
codexReasoningEffortForThinkingLevel,
|
|
12
13
|
isRecord,
|
|
13
|
-
readOllamaAuthEnv
|
|
14
|
-
|
|
14
|
+
readOllamaAuthEnv,
|
|
15
|
+
readOpenAICompatibleAuthEnv
|
|
16
|
+
} from "./chunk-G6OGB6HX.js";
|
|
15
17
|
|
|
16
18
|
// src/managers/codex-asp/notification-dispatch.ts
|
|
17
19
|
var TURN_STARTED_METHOD = "turn/started";
|
|
@@ -90,6 +92,7 @@ var opencodeAuthSchema = z.record(z.string(), z.object({
|
|
|
90
92
|
}));
|
|
91
93
|
async function hasOpencodeCredentials(provider) {
|
|
92
94
|
if (provider === "ollama") return !!readOllamaAuthEnv("opencode", process.env);
|
|
95
|
+
if (provider === CREDENTIAL_METHOD.OPENAI_COMPATIBLE) return !!readOpenAICompatibleAuthEnv("opencode", process.env);
|
|
93
96
|
if (!existsSync(OPENCODE_AUTH_PATH)) return false;
|
|
94
97
|
try {
|
|
95
98
|
const auth = opencodeAuthSchema.safeParse(JSON.parse(await readFile(OPENCODE_AUTH_PATH, "utf8")));
|
|
@@ -100,6 +103,7 @@ async function hasOpencodeCredentials(provider) {
|
|
|
100
103
|
}
|
|
101
104
|
async function getOpencodeProvider() {
|
|
102
105
|
if (readOllamaAuthEnv("opencode", process.env)) return "ollama";
|
|
106
|
+
if (readOpenAICompatibleAuthEnv("opencode", process.env)) return CREDENTIAL_METHOD.OPENAI_COMPATIBLE;
|
|
103
107
|
if (await hasOpencodeCredentials(OPENCODE_GO_PROVIDER)) return OPENCODE_GO_PROVIDER;
|
|
104
108
|
if (await hasOpencodeCredentials(ASTER_PROVIDER)) return ASTER_PROVIDER;
|
|
105
109
|
return "openrouter";
|
|
@@ -121,16 +125,23 @@ function opencodeConfig(provider, model, providerModels = [model]) {
|
|
|
121
125
|
permission: OPENCODE_WORKSPACE_PERMISSION,
|
|
122
126
|
share: "disabled"
|
|
123
127
|
};
|
|
124
|
-
} else if (provider === ASTER_PROVIDER || provider === "ollama") {
|
|
128
|
+
} else if (provider === ASTER_PROVIDER || provider === "ollama" || provider === CREDENTIAL_METHOD.OPENAI_COMPATIBLE) {
|
|
125
129
|
const ollama = provider === "ollama" ? readOllamaAuthEnv("opencode", process.env) : null;
|
|
130
|
+
const compatible = provider === CREDENTIAL_METHOD.OPENAI_COMPATIBLE ? readOpenAICompatibleAuthEnv("opencode", process.env) : null;
|
|
126
131
|
config = {
|
|
127
132
|
enabled_providers: [provider],
|
|
128
133
|
model: `${provider}/${model}`,
|
|
129
134
|
provider: {
|
|
130
135
|
[provider]: {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
// Responses API: OpenAI models reject function tools with reasoning on Chat Completions.
|
|
137
|
+
npm: compatible ? "@ai-sdk/openai" : "@ai-sdk/openai-compatible",
|
|
138
|
+
name: ollama ? "Ollama" : compatible ? "OpenAI-compatible endpoint" : "Aster",
|
|
139
|
+
options: ollama ? { baseURL: `${ollama.baseUrl}/v1`, apiKey: ollama.apiKey } : compatible ? {
|
|
140
|
+
baseURL: compatible.baseUrl,
|
|
141
|
+
// The SDK refuses to start without a key; an exact Authorization header replaces the bearer it builds.
|
|
142
|
+
apiKey: compatible.apiKey ?? "unused",
|
|
143
|
+
...compatible.authorizationHeader ? { headers: { Authorization: compatible.authorizationHeader } } : {}
|
|
144
|
+
} : { baseURL: ASTER_BASE_URL },
|
|
134
145
|
models: Object.fromEntries(providerModels.map((candidate) => [candidate, {}]))
|
|
135
146
|
}
|
|
136
147
|
},
|
|
@@ -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-2G62KJLA.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-G6OGB6HX.js";
|
|
22
22
|
|
|
23
23
|
// src/runtime-env-loader.ts
|
|
24
24
|
import { readFileSync } from "fs";
|
|
@@ -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-GMZHK5QI.js";
|
|
7
|
+
import "./chunk-WJAKGFYD.js";
|
|
8
|
+
import "./chunk-2G62KJLA.js";
|
|
9
9
|
import {
|
|
10
10
|
isRecord
|
|
11
11
|
} from "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-G6OGB6HX.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-VV6RUT4F.js";
|
|
17
17
|
import {
|
|
18
18
|
AppServerProcess,
|
|
19
19
|
buildCodexAgentEnv
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-5ZVVCDEG.js";
|
|
21
|
+
import "./chunk-2G62KJLA.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-G6OGB6HX.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-GMZHK5QI.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-VV6RUT4F.js";
|
|
68
68
|
import {
|
|
69
69
|
publishedPullRequestUrls
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-ZKSO7G5X.js";
|
|
71
71
|
import {
|
|
72
72
|
ACCOUNT_RATE_LIMITS_READ_METHOD,
|
|
73
73
|
AsyncLock,
|
|
@@ -139,7 +139,7 @@ import {
|
|
|
139
139
|
timestampFromSeconds,
|
|
140
140
|
upsertCredentialFileLines,
|
|
141
141
|
writeSecureCredentialFile
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-NAX7OMFI.js";
|
|
143
143
|
import {
|
|
144
144
|
ENGINE_ENV,
|
|
145
145
|
monolithRequest,
|
|
@@ -148,15 +148,15 @@ import {
|
|
|
148
148
|
reloadEngineEnv,
|
|
149
149
|
resolveDiffBase,
|
|
150
150
|
setAgentCredentialSnapshot
|
|
151
|
-
} from "./chunk-
|
|
151
|
+
} from "./chunk-WJAKGFYD.js";
|
|
152
152
|
import {
|
|
153
153
|
getCodexModelProvider
|
|
154
|
-
} from "./chunk-
|
|
154
|
+
} from "./chunk-5ZVVCDEG.js";
|
|
155
155
|
import {
|
|
156
156
|
SUBPROCESS_MAX_BUFFER,
|
|
157
157
|
execAsync,
|
|
158
158
|
execFileAsync
|
|
159
|
-
} from "./chunk-
|
|
159
|
+
} from "./chunk-2G62KJLA.js";
|
|
160
160
|
import {
|
|
161
161
|
isRecord as isRecord2
|
|
162
162
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -338,6 +338,7 @@ import {
|
|
|
338
338
|
learnedSkillsManifestSchema,
|
|
339
339
|
legacyWorkspaceTokenBundleSchema,
|
|
340
340
|
listOllamaModels,
|
|
341
|
+
listOpenAICompatibleModels,
|
|
341
342
|
mergeSlashCommands,
|
|
342
343
|
messageSubagentRequestSchema,
|
|
343
344
|
normalizeAutoCompactThreshold,
|
|
@@ -361,6 +362,7 @@ import {
|
|
|
361
362
|
readJsonlAppended,
|
|
362
363
|
readJsonlPage,
|
|
363
364
|
readOllamaAuthEnv,
|
|
365
|
+
readOpenAICompatibleAuthEnv,
|
|
364
366
|
readReplicasRuntimeEnv,
|
|
365
367
|
resolveWarmHookConfig,
|
|
366
368
|
safeJsonParse,
|
|
@@ -384,7 +386,7 @@ import {
|
|
|
384
386
|
workspaceTokenRequestSchema,
|
|
385
387
|
workspaceTokenResponseSchema,
|
|
386
388
|
wrapInTag
|
|
387
|
-
} from "./chunk-
|
|
389
|
+
} from "./chunk-G6OGB6HX.js";
|
|
388
390
|
import {
|
|
389
391
|
cloneMcpConfig,
|
|
390
392
|
ensureCompatibilityImports,
|
|
@@ -9498,9 +9500,9 @@ function detectAgentAuthMethod(provider) {
|
|
|
9498
9500
|
if (ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.muse?.method === "muse-oauth") return "oauth";
|
|
9499
9501
|
return ENGINE_ENV.REPLICAS_MUSE_AUTH_METHOD ?? "oauth";
|
|
9500
9502
|
case AGENT.OPENCODE:
|
|
9501
|
-
return existsSync(OPENCODE_AUTH_PATH) ? "api_key" : "none";
|
|
9502
9503
|
case AGENT.PI:
|
|
9503
|
-
|
|
9504
|
+
if (readOpenAICompatibleAuthEnv(provider, process.env)) return "openai-compatible";
|
|
9505
|
+
return existsSync(provider === AGENT.OPENCODE ? OPENCODE_AUTH_PATH : PI_AUTH_PATH) ? "api_key" : "none";
|
|
9504
9506
|
}
|
|
9505
9507
|
}
|
|
9506
9508
|
function isAgentAvailable(provider) {
|
|
@@ -9512,6 +9514,8 @@ import { readFile } from "fs/promises";
|
|
|
9512
9514
|
async function getPiProviderCredentials() {
|
|
9513
9515
|
const ollama = readOllamaAuthEnv("pi", process.env);
|
|
9514
9516
|
if (ollama) return createSuccessResult({ provider: "ollama", apiKey: ollama.apiKey });
|
|
9517
|
+
const compatible = readOpenAICompatibleAuthEnv("pi", process.env);
|
|
9518
|
+
if (compatible) return createSuccessResult({ provider: "openai-compatible", apiKey: compatible.apiKey ?? "" });
|
|
9515
9519
|
let credentials;
|
|
9516
9520
|
try {
|
|
9517
9521
|
credentials = JSON.parse(await readFile(PI_AUTH_PATH, "utf8"));
|
|
@@ -16350,6 +16354,8 @@ async function getDefaultOpencodeModel(provider) {
|
|
|
16350
16354
|
if (!model) throw new Error("Select a tool-capable Ollama model in the model picker.");
|
|
16351
16355
|
return model;
|
|
16352
16356
|
}
|
|
16357
|
+
const compatible = provider === CREDENTIAL_METHOD.OPENAI_COMPATIBLE ? readOpenAICompatibleAuthEnv("opencode", process.env) : null;
|
|
16358
|
+
if (compatible) return (await listOpenAICompatibleModels(compatible))[0].id;
|
|
16353
16359
|
if (provider === OPENCODE_GO_PROVIDER) return DEFAULT_OPENCODE_GO_MODEL;
|
|
16354
16360
|
if (provider === ASTER_PROVIDER) return DEFAULT_ASTER_MODEL;
|
|
16355
16361
|
return (await getAllowedOpenRouterModels())[0] ?? DEFAULT_OPENCODE_MODEL;
|
|
@@ -16577,7 +16583,8 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
16577
16583
|
this.providerId = providerId;
|
|
16578
16584
|
const configuredModel = providerId === OPENCODE_GO_PROVIDER ? getOpenCodeGoModel(model) : model;
|
|
16579
16585
|
const ollama = providerId === "ollama" ? readOllamaAuthEnv("opencode", process.env) : null;
|
|
16580
|
-
const
|
|
16586
|
+
const compatible = providerId === CREDENTIAL_METHOD.OPENAI_COMPATIBLE ? readOpenAICompatibleAuthEnv("opencode", process.env) : null;
|
|
16587
|
+
const providerModels = ollama ? (await listOllamaModels(ollama)).map(({ id }) => id) : compatible ? (await listOpenAICompatibleModels(compatible)).map(({ id }) => id) : providerId === OPENCODE_GO_PROVIDER ? Object.keys((await fetchOpenCodeGoCatalog()).models) : providerId === ASTER_PROVIDER ? ASTER_MODELS : await getAllowedOpenRouterModels();
|
|
16581
16588
|
if (!providerModels.includes(configuredModel)) {
|
|
16582
16589
|
throw new Error(`Model ${configuredModel} is not available through ${providerId}.`);
|
|
16583
16590
|
}
|
|
@@ -16585,7 +16592,7 @@ var OpencodeManager = class extends CodingAgentManager {
|
|
|
16585
16592
|
return this.client;
|
|
16586
16593
|
}
|
|
16587
16594
|
if (!await hasOpencodeCredentials(providerId)) {
|
|
16588
|
-
throw new Error("OpenCode Go, Aster, OpenRouter, or Ollama credentials are not configured for Opencode in this workspace.");
|
|
16595
|
+
throw new Error("OpenCode Go, Aster, OpenRouter, OpenAI-compatible, or Ollama credentials are not configured for Opencode in this workspace.");
|
|
16589
16596
|
}
|
|
16590
16597
|
if (!existsSync8(OPENCODE_COMMAND_PROTECTION_PLUGIN_SOURCE)) {
|
|
16591
16598
|
throw new Error("Opencode command protection plugin is missing from the engine package.");
|
|
@@ -57422,6 +57429,7 @@ function registerPiProvider(modelRegistry, {
|
|
|
57422
57429
|
name,
|
|
57423
57430
|
apiKey,
|
|
57424
57431
|
baseUrl,
|
|
57432
|
+
headers,
|
|
57425
57433
|
models
|
|
57426
57434
|
}) {
|
|
57427
57435
|
modelRegistry.registerProvider(providerId, {
|
|
@@ -57429,7 +57437,8 @@ function registerPiProvider(modelRegistry, {
|
|
|
57429
57437
|
api: "openai-completions",
|
|
57430
57438
|
apiKey,
|
|
57431
57439
|
baseUrl,
|
|
57432
|
-
authHeader:
|
|
57440
|
+
authHeader: !headers?.Authorization,
|
|
57441
|
+
...headers ? { headers } : {},
|
|
57433
57442
|
models: models.map((model) => {
|
|
57434
57443
|
const builtin = modelRegistry.find(providerId, model.id);
|
|
57435
57444
|
const api = model.api ?? builtin?.api ?? "openai-completions";
|
|
@@ -57533,7 +57542,7 @@ var PiManager = class extends CodingAgentManager {
|
|
|
57533
57542
|
async enqueueMessage(request, onAccepted) {
|
|
57534
57543
|
await this.initialized;
|
|
57535
57544
|
if (!this.session && !(await getPiProviderCredentials()).ok) {
|
|
57536
|
-
throw new Error("OpenCode Go, Aster, or
|
|
57545
|
+
throw new Error("OpenCode Go, Aster, OpenRouter, or OpenAI-compatible authentication is missing for Pi. Add one in Settings \u2192 Coding agents.");
|
|
57537
57546
|
}
|
|
57538
57547
|
return this.messageQueue.enqueue(request, onAccepted);
|
|
57539
57548
|
}
|
|
@@ -57578,7 +57587,7 @@ var PiManager = class extends CodingAgentManager {
|
|
|
57578
57587
|
}
|
|
57579
57588
|
const modelRuntime = await this.getModelRuntime();
|
|
57580
57589
|
const credentialResult = await getPiProviderCredentials();
|
|
57581
|
-
if (!credentialResult.ok) throw new Error("OpenCode Go, Aster, or
|
|
57590
|
+
if (!credentialResult.ok) throw new Error("OpenCode Go, Aster, OpenRouter, or OpenAI-compatible credentials are not configured for Pi.");
|
|
57582
57591
|
const credentials = credentialResult.data;
|
|
57583
57592
|
this.providerId = credentials.provider;
|
|
57584
57593
|
this.providerApiKey = credentials.apiKey;
|
|
@@ -57606,6 +57615,27 @@ var PiManager = class extends CodingAgentManager {
|
|
|
57606
57615
|
input: model2.capabilities?.includes("vision") ? ["text", "image"] : ["text"]
|
|
57607
57616
|
}))
|
|
57608
57617
|
});
|
|
57618
|
+
} else if (this.providerId === CREDENTIAL_METHOD.OPENAI_COMPATIBLE) {
|
|
57619
|
+
const compatible = readOpenAICompatibleAuthEnv("pi", process.env);
|
|
57620
|
+
if (!compatible) throw new Error("OpenAI-compatible endpoint is not configured for Pi.");
|
|
57621
|
+
const models = await listOpenAICompatibleModels(compatible);
|
|
57622
|
+
defaultModel = models[0].id;
|
|
57623
|
+
registerPiProvider(modelRegistry, {
|
|
57624
|
+
providerId: CREDENTIAL_METHOD.OPENAI_COMPATIBLE,
|
|
57625
|
+
name: "OpenAI-compatible endpoint",
|
|
57626
|
+
apiKey: compatible.apiKey ?? "",
|
|
57627
|
+
baseUrl: compatible.baseUrl,
|
|
57628
|
+
...compatible.authorizationHeader ? { headers: { Authorization: compatible.authorizationHeader } } : {},
|
|
57629
|
+
// The catalog says nothing about reasoning or output limits, so ask for neither beyond what any chat model accepts.
|
|
57630
|
+
models: models.map((model2) => ({
|
|
57631
|
+
id: model2.id,
|
|
57632
|
+
name: model2.displayName,
|
|
57633
|
+
api: "openai-responses",
|
|
57634
|
+
reasoning: false,
|
|
57635
|
+
maxTokens: 16384,
|
|
57636
|
+
...model2.contextWindow ? { contextWindow: model2.contextWindow } : {}
|
|
57637
|
+
}))
|
|
57638
|
+
});
|
|
57609
57639
|
} else if (this.providerId === OPENCODE_GO_PROVIDER) {
|
|
57610
57640
|
const catalog = await fetchOpenCodeGoCatalog([request.model ?? DEFAULT_OPENCODE_GO_MODEL]);
|
|
57611
57641
|
const models = Object.entries(catalog.models);
|
|
@@ -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-ZKSO7G5X.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-G6OGB6HX.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