replicas-engine 0.1.832 → 0.1.834
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-KKPQQCUV.js → asp-host-WR4AXITI.js} +4 -4
- package/dist/src/{chunk-DSZMTRC3.js → chunk-32NJI2LJ.js} +72 -9
- package/dist/src/{chunk-VZ6VMXC7.js → chunk-4T7IB2IL.js} +2 -1
- package/dist/src/{chunk-3ZA72VWO.js → chunk-MYD5ZGCU.js} +1 -1
- package/dist/src/{chunk-GLZE6UHB.js → chunk-NGAPGKWO.js} +2 -2
- package/dist/src/{chunk-X7NVCXNL.js → chunk-RAXPRO4T.js} +2 -2
- package/dist/src/{chunk-EJKLU7KX.js → chunk-YIBBAGHQ.js} +135 -1
- package/dist/src/command-protection-hook.js +3 -3
- package/dist/src/deepseek-command-protection-plugin.js +4 -4
- package/dist/src/headless-agent.js +2 -2
- package/dist/src/index.js +10 -7
- package/dist/src/post-tool-pr-hook.js +2 -2
- package/dist/src/relay-mcp.js +1 -1
- package/package.json +1 -1
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
getCodexAspHost,
|
|
6
6
|
restartCodexAspHost,
|
|
7
7
|
restartCodexAspHostIfRunning
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-32NJI2LJ.js";
|
|
9
|
+
import "./chunk-4T7IB2IL.js";
|
|
10
|
+
import "./chunk-RAXPRO4T.js";
|
|
11
11
|
import "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-YIBBAGHQ.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
export {
|
|
15
15
|
getCodexAspHost,
|
|
@@ -5,18 +5,25 @@ import {
|
|
|
5
5
|
ENGINE_ENV,
|
|
6
6
|
monolithRequest,
|
|
7
7
|
setAgentCredentialSnapshot
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4T7IB2IL.js";
|
|
9
9
|
import {
|
|
10
10
|
AppServerProcess,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
SUBPROCESS_MAX_BUFFER,
|
|
12
|
+
buildCodexAgentEnv,
|
|
13
|
+
execFileAsync
|
|
14
|
+
} from "./chunk-RAXPRO4T.js";
|
|
15
|
+
import {
|
|
16
|
+
isRecord
|
|
17
|
+
} from "./chunk-UZSNFLDQ.js";
|
|
13
18
|
import {
|
|
14
19
|
CODEX_AUTH_ENV_KEYS,
|
|
15
20
|
CODEX_AUTH_ENV_KEYS_BY_METHOD,
|
|
16
21
|
codexAuthEnvFromResponse,
|
|
17
22
|
createErrorResult,
|
|
18
|
-
createSuccessResult
|
|
19
|
-
|
|
23
|
+
createSuccessResult,
|
|
24
|
+
listOpenAICompatibleModels,
|
|
25
|
+
resolveOpenAICompatibleModelsUrl
|
|
26
|
+
} from "./chunk-YIBBAGHQ.js";
|
|
20
27
|
|
|
21
28
|
// src/managers/codex-token-manager.ts
|
|
22
29
|
import { promises as fs } from "fs";
|
|
@@ -24,7 +31,6 @@ import path from "path";
|
|
|
24
31
|
|
|
25
32
|
// src/managers/auth-env-transition.ts
|
|
26
33
|
function applyAuthEnvTransition(params) {
|
|
27
|
-
const newOwned = new Set(params.authKeysByMethod[params.newMethod]);
|
|
28
34
|
const prevOwned = new Set(params.authKeysByMethod[params.prevMethod]);
|
|
29
35
|
for (const key of params.authKeys) {
|
|
30
36
|
const value = params.newEnvVars[key];
|
|
@@ -32,7 +38,7 @@ function applyAuthEnvTransition(params) {
|
|
|
32
38
|
for (const env of params.envs) {
|
|
33
39
|
env[key] = value;
|
|
34
40
|
}
|
|
35
|
-
} else if (prevOwned.has(key)
|
|
41
|
+
} else if (prevOwned.has(key)) {
|
|
36
42
|
for (const env of params.envs) {
|
|
37
43
|
delete env[key];
|
|
38
44
|
}
|
|
@@ -232,7 +238,7 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
232
238
|
const data = await response.json();
|
|
233
239
|
await this.applyCredentialsResponse(data);
|
|
234
240
|
if (restartOnChange && CODEX_AUTH_ENV_KEYS.some((key, index) => process.env[key] !== previousEnv[index])) {
|
|
235
|
-
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-
|
|
241
|
+
const { restartCodexAspHostIfRunning: restartCodexAspHostIfRunning2 } = await import("./asp-host-WR4AXITI.js");
|
|
236
242
|
await restartCodexAspHostIfRunning2();
|
|
237
243
|
}
|
|
238
244
|
if (data.scope) {
|
|
@@ -317,7 +323,6 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
317
323
|
const envVars = codexAuthEnvFromResponse(response);
|
|
318
324
|
applyAuthEnvTransition({
|
|
319
325
|
prevMethod: ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD ?? "none",
|
|
320
|
-
newMethod: envVars.REPLICAS_CODEX_AUTH_METHOD ?? "none",
|
|
321
326
|
authKeys: CODEX_AUTH_ENV_KEYS,
|
|
322
327
|
authKeysByMethod: CODEX_AUTH_ENV_KEYS_BY_METHOD,
|
|
323
328
|
newEnvVars: envVars,
|
|
@@ -353,6 +358,63 @@ var CodexTokenManager = class extends BaseRefreshManager {
|
|
|
353
358
|
};
|
|
354
359
|
var codexTokenManager = new CodexTokenManager();
|
|
355
360
|
|
|
361
|
+
// src/managers/codex-asp/openai-compatible-model-catalog.ts
|
|
362
|
+
import { writeFile } from "fs/promises";
|
|
363
|
+
import { tmpdir } from "os";
|
|
364
|
+
import { join } from "path";
|
|
365
|
+
var CATALOG_TTL_MS = 6e4;
|
|
366
|
+
var CODEX_MODEL_CATALOG_PATH = join(tmpdir(), "replicas-openai-compatible-model-catalog.json");
|
|
367
|
+
var cachedCatalog = null;
|
|
368
|
+
async function writeCodexModelCatalog(modelsUrl) {
|
|
369
|
+
const [models, { stdout }] = await Promise.all([
|
|
370
|
+
listOpenAICompatibleModels({
|
|
371
|
+
apiKey: ENGINE_ENV.OPENAI_API_KEY,
|
|
372
|
+
authorizationHeader: ENGINE_ENV.CODEX_OPENAI_AUTHORIZATION_HEADER,
|
|
373
|
+
baseUrl: ENGINE_ENV.CODEX_OPENAI_BASE_URL ?? "",
|
|
374
|
+
modelsUrl
|
|
375
|
+
}),
|
|
376
|
+
execFileAsync("codex", ["debug", "models"], { maxBuffer: SUBPROCESS_MAX_BUFFER })
|
|
377
|
+
]);
|
|
378
|
+
const payload = JSON.parse(stdout);
|
|
379
|
+
const template = isRecord(payload) && Array.isArray(payload.models) ? payload.models.find((model) => isRecord(model) && model.slug === "gpt-5.2") ?? payload.models.find(isRecord) : null;
|
|
380
|
+
if (!isRecord(template)) throw new Error("Codex did not return a model catalog template");
|
|
381
|
+
await writeFile(CODEX_MODEL_CATALOG_PATH, JSON.stringify({
|
|
382
|
+
models: models.flatMap((model) => model.contextWindow ? [{
|
|
383
|
+
...template,
|
|
384
|
+
slug: model.id,
|
|
385
|
+
display_name: model.displayName,
|
|
386
|
+
description: model.description ?? model.displayName,
|
|
387
|
+
context_window: model.contextWindow,
|
|
388
|
+
max_context_window: model.contextWindow,
|
|
389
|
+
effective_context_window_percent: 100,
|
|
390
|
+
auto_compact_token_limit: Math.floor(model.contextWindow * 0.9)
|
|
391
|
+
}] : [])
|
|
392
|
+
}));
|
|
393
|
+
return [
|
|
394
|
+
`model_catalog_json=${JSON.stringify(CODEX_MODEL_CATALOG_PATH)}`,
|
|
395
|
+
"features.remote_models=false"
|
|
396
|
+
];
|
|
397
|
+
}
|
|
398
|
+
async function getOpenAICompatibleCodexModelCatalogConfig() {
|
|
399
|
+
if (ENGINE_ENV.REPLICAS_CODEX_AUTH_METHOD !== "openai-compatible" || !ENGINE_ENV.CODEX_OPENAI_BASE_URL) return [];
|
|
400
|
+
const modelsUrl = resolveOpenAICompatibleModelsUrl({
|
|
401
|
+
baseUrl: ENGINE_ENV.CODEX_OPENAI_BASE_URL,
|
|
402
|
+
modelsUrl: ENGINE_ENV.CODEX_OPENAI_MODELS_URL ?? ""
|
|
403
|
+
});
|
|
404
|
+
const key = `${modelsUrl}:${JSON.stringify(ENGINE_ENV.REPLICAS_AGENT_CREDENTIALS.codex ?? null)}`;
|
|
405
|
+
if (!cachedCatalog || cachedCatalog.key !== key || cachedCatalog.expiresAt <= Date.now()) {
|
|
406
|
+
cachedCatalog = {
|
|
407
|
+
key,
|
|
408
|
+
expiresAt: Date.now() + CATALOG_TTL_MS,
|
|
409
|
+
config: writeCodexModelCatalog(modelsUrl).catch((error) => {
|
|
410
|
+
console.warn("[CodexAspManager] Failed to prepare OpenAI-compatible model catalog:", error);
|
|
411
|
+
return [];
|
|
412
|
+
})
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
return cachedCatalog.config;
|
|
416
|
+
}
|
|
417
|
+
|
|
356
418
|
// src/managers/codex-asp/asp-host.ts
|
|
357
419
|
var hostPromise = null;
|
|
358
420
|
var activeProcess = null;
|
|
@@ -367,6 +429,7 @@ async function getCodexAspHost() {
|
|
|
367
429
|
const process2 = new AppServerProcess({
|
|
368
430
|
cwd: ENGINE_ENV.WORKSPACE_ROOT,
|
|
369
431
|
env: buildCodexAgentEnv(),
|
|
432
|
+
configOverrides: await getOpenAICompatibleCodexModelCatalogConfig(),
|
|
370
433
|
...oauthOptions
|
|
371
434
|
});
|
|
372
435
|
const { client } = await process2.start();
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
isValidRelayBaseProvider,
|
|
16
16
|
parsePosixEnvFile,
|
|
17
17
|
readReplicasRuntimeEnv
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-YIBBAGHQ.js";
|
|
19
19
|
|
|
20
20
|
// src/engine-env.ts
|
|
21
21
|
import { readFileSync as readFileSync2 } from "fs";
|
|
@@ -137,6 +137,7 @@ function loadEngineEnv() {
|
|
|
137
137
|
ANTHROPIC_API_KEY: readEnv("ANTHROPIC_API_KEY"),
|
|
138
138
|
OPENAI_API_KEY: readEnv("OPENAI_API_KEY"),
|
|
139
139
|
CODEX_OPENAI_BASE_URL: readEnv("CODEX_OPENAI_BASE_URL"),
|
|
140
|
+
CODEX_OPENAI_MODELS_URL: readEnv("CODEX_OPENAI_MODELS_URL"),
|
|
140
141
|
CODEX_OPENAI_AUTHORIZATION_HEADER: readEnv("CODEX_OPENAI_AUTHORIZATION_HEADER"),
|
|
141
142
|
CURSOR_API_KEY: readEnv("CURSOR_API_KEY"),
|
|
142
143
|
AI_GATEWAY_API_KEY: readEnv("AI_GATEWAY_API_KEY"),
|
|
@@ -3,7 +3,7 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
shouldRefreshPullRequests
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YIBBAGHQ.js";
|
|
7
7
|
|
|
8
8
|
// src/services/post-tool-pr-notifier.ts
|
|
9
9
|
async function notifyPostToolUse(toolName, toolInput) {
|
|
@@ -3,12 +3,12 @@ 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-4T7IB2IL.js";
|
|
7
7
|
import {
|
|
8
8
|
extractCommandProtectionCommandText,
|
|
9
9
|
findGitCommitSignals,
|
|
10
10
|
findPrMergeSignals
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-YIBBAGHQ.js";
|
|
12
12
|
|
|
13
13
|
// src/services/command-protection-service.ts
|
|
14
14
|
var DEFAULT_COMMAND_PROTECTION_BLOCK_MESSAGE = "Blocked by Replicas command protection.";
|
|
@@ -4,7 +4,7 @@ const require = __createRequire(import.meta.url);
|
|
|
4
4
|
import {
|
|
5
5
|
HOOK_EXEC_MAX_BUFFER_BYTES,
|
|
6
6
|
isVersionBelow
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YIBBAGHQ.js";
|
|
8
8
|
|
|
9
9
|
// src/utils/codex-agent-env.ts
|
|
10
10
|
function buildCodexAgentEnv(source = process.env) {
|
|
@@ -241,7 +241,7 @@ var DEFAULT_CODEX_ARGS = [
|
|
|
241
241
|
var MIN_CODEX_CLI_VERSION = "0.153.3";
|
|
242
242
|
var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
|
|
243
243
|
var codexCliVersionEnsured = null;
|
|
244
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
244
|
+
var ENGINE_PACKAGE_VERSION = "0.1.834";
|
|
245
245
|
var INITIALIZE_METHOD = "initialize";
|
|
246
246
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
247
247
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -658,6 +658,127 @@ function createErrorResult(error) {
|
|
|
658
658
|
};
|
|
659
659
|
}
|
|
660
660
|
|
|
661
|
+
// ../shared/src/external-api-host.ts
|
|
662
|
+
function validateExternalApiHost(url, providerLabel) {
|
|
663
|
+
let parsed;
|
|
664
|
+
try {
|
|
665
|
+
parsed = new URL(url);
|
|
666
|
+
} catch {
|
|
667
|
+
throw new Error(`Invalid ${providerLabel}: ${url}`);
|
|
668
|
+
}
|
|
669
|
+
if (parsed.protocol !== "https:") throw new Error(`${providerLabel} must use HTTPS`);
|
|
670
|
+
const hostname = parsed.hostname.toLowerCase();
|
|
671
|
+
if (hostname.includes(":") || hostname.startsWith("[")) {
|
|
672
|
+
throw new Error(`${providerLabel} cannot be an IP address literal`);
|
|
673
|
+
}
|
|
674
|
+
if (hostname === "localhost" || hostname === "127.0.0.1") {
|
|
675
|
+
throw new Error(`${providerLabel} cannot point to localhost`);
|
|
676
|
+
}
|
|
677
|
+
if (/^(10\.|127\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.|169\.254\.|0\.)/.test(hostname)) {
|
|
678
|
+
throw new Error(`${providerLabel} cannot point to a private or internal IP address`);
|
|
679
|
+
}
|
|
680
|
+
if (hostname === "0.0.0.0" || hostname.endsWith(".internal") || hostname.endsWith(".local")) {
|
|
681
|
+
throw new Error(`${providerLabel} cannot point to a non-routable address`);
|
|
682
|
+
}
|
|
683
|
+
if (!hostname.includes(".")) throw new Error(`${providerLabel} must be a fully qualified domain name`);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
// ../shared/src/credentials/openai.ts
|
|
687
|
+
function positiveInteger(value) {
|
|
688
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : null;
|
|
689
|
+
}
|
|
690
|
+
var CONTEXT_WINDOW_KEYS = /* @__PURE__ */ new Set([
|
|
691
|
+
"context_window",
|
|
692
|
+
"context_length",
|
|
693
|
+
"contextWindow",
|
|
694
|
+
"contextLength",
|
|
695
|
+
"max_context_length",
|
|
696
|
+
"maxContextLength"
|
|
697
|
+
]);
|
|
698
|
+
var MAX_CATALOG_PAGES = 20;
|
|
699
|
+
function getModelContextWindow(model) {
|
|
700
|
+
const directValues = Object.entries(model).flatMap(([key, value]) => {
|
|
701
|
+
const contextWindow = CONTEXT_WINDOW_KEYS.has(key) ? positiveInteger(value) : null;
|
|
702
|
+
return contextWindow === null ? [] : [contextWindow];
|
|
703
|
+
});
|
|
704
|
+
if (directValues.length > 0) return Math.max(...directValues);
|
|
705
|
+
const values = [];
|
|
706
|
+
const pending = Object.entries(model).filter(([key]) => !CONTEXT_WINDOW_KEYS.has(key)).map(([, value]) => value);
|
|
707
|
+
for (let inspected = 0; pending.length > 0 && inspected < 1e3; inspected += 1) {
|
|
708
|
+
const current = pending.pop();
|
|
709
|
+
if (Array.isArray(current)) {
|
|
710
|
+
pending.push(...current);
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
if (!isRecord(current)) continue;
|
|
714
|
+
if (current.availability_status !== void 0 && current.availability_status !== "available") continue;
|
|
715
|
+
for (const [key, value] of Object.entries(current)) {
|
|
716
|
+
if (CONTEXT_WINDOW_KEYS.has(key)) {
|
|
717
|
+
const contextWindow = positiveInteger(value);
|
|
718
|
+
if (contextWindow !== null) values.push(contextWindow);
|
|
719
|
+
} else if (Array.isArray(value) || isRecord(value)) {
|
|
720
|
+
pending.push(value);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
return values.length > 0 ? Math.max(...values) : null;
|
|
725
|
+
}
|
|
726
|
+
function parseOpenAICompatibleModels(payload) {
|
|
727
|
+
if (!isRecord(payload) || !Array.isArray(payload.data)) {
|
|
728
|
+
throw new Error("The models endpoint returned an invalid catalog");
|
|
729
|
+
}
|
|
730
|
+
return [...new Map(payload.data.flatMap((value) => {
|
|
731
|
+
if (!isRecord(value) || value.availability_status !== void 0 && value.availability_status !== "available") {
|
|
732
|
+
return [];
|
|
733
|
+
}
|
|
734
|
+
const id = typeof value.id === "string" ? value.id : typeof value.model === "string" ? value.model : null;
|
|
735
|
+
if (!id) return [];
|
|
736
|
+
const displayName = typeof value.display_name === "string" ? value.display_name : typeof value.name === "string" ? value.name : id;
|
|
737
|
+
const contextWindow = getModelContextWindow(value);
|
|
738
|
+
return [[id, {
|
|
739
|
+
id,
|
|
740
|
+
displayName,
|
|
741
|
+
...typeof value.description === "string" ? { description: value.description } : {},
|
|
742
|
+
...contextWindow !== null ? { contextWindow } : {}
|
|
743
|
+
}]];
|
|
744
|
+
})).values()];
|
|
745
|
+
}
|
|
746
|
+
async function listOpenAICompatibleModels(credential) {
|
|
747
|
+
const models = /* @__PURE__ */ new Map();
|
|
748
|
+
const signal = AbortSignal.timeout(1e4);
|
|
749
|
+
let modelsUrl = resolveOpenAICompatibleModelsUrl({
|
|
750
|
+
baseUrl: credential.baseUrl ?? "",
|
|
751
|
+
modelsUrl: credential.modelsUrl ?? ""
|
|
752
|
+
});
|
|
753
|
+
for (let page = 0; page < MAX_CATALOG_PAGES; page += 1) {
|
|
754
|
+
validateExternalApiHost(modelsUrl, "Models endpoint");
|
|
755
|
+
const response = await fetch(modelsUrl, {
|
|
756
|
+
headers: {
|
|
757
|
+
Accept: "application/json",
|
|
758
|
+
Authorization: credential.authorizationHeader || `Bearer ${credential.apiKey}`
|
|
759
|
+
},
|
|
760
|
+
redirect: "error",
|
|
761
|
+
signal
|
|
762
|
+
});
|
|
763
|
+
if (!response.ok) throw new Error(`Models request failed with status ${response.status}`);
|
|
764
|
+
const payload = await response.json();
|
|
765
|
+
for (const model of parseOpenAICompatibleModels(payload)) models.set(model.id, model);
|
|
766
|
+
if (!isRecord(payload) || payload.has_more !== true) break;
|
|
767
|
+
if (page === MAX_CATALOG_PAGES - 1) throw new Error(`The models endpoint exceeded ${MAX_CATALOG_PAGES} pages`);
|
|
768
|
+
if (typeof payload.next_cursor !== "string" || !payload.next_cursor) {
|
|
769
|
+
throw new Error("The models endpoint did not return a cursor for the next page");
|
|
770
|
+
}
|
|
771
|
+
const nextUrl = new URL(modelsUrl);
|
|
772
|
+
nextUrl.searchParams.set("cursor", payload.next_cursor);
|
|
773
|
+
modelsUrl = nextUrl.toString();
|
|
774
|
+
}
|
|
775
|
+
if (models.size === 0) throw new Error("The models endpoint returned no available models");
|
|
776
|
+
return [...models.values()];
|
|
777
|
+
}
|
|
778
|
+
function resolveOpenAICompatibleModelsUrl(values) {
|
|
779
|
+
return values.modelsUrl || `${values.baseUrl}/models`;
|
|
780
|
+
}
|
|
781
|
+
|
|
661
782
|
// ../shared/src/analytics/types.ts
|
|
662
783
|
function hasAgentChatActivityFields(value) {
|
|
663
784
|
return isRecord(value) && typeof value.chatId === "string" && typeof value.model === "string" && (value.credentialMethod === void 0 || isAuthMethod(value.credentialMethod)) && (value.credentialScope === void 0 || isCredentialScope(value.credentialScope)) && value.credentialMethod === void 0 === (value.credentialScope === void 0) && (value.senderUserId === void 0 || typeof value.senderUserId === "string") && typeof value.occurredAt === "string";
|
|
@@ -804,12 +925,20 @@ function getChatScopedEngineEventChatId(event) {
|
|
|
804
925
|
return event.type === "chat.created" || event.type === "chat.updated" ? event.payload.chat.id : event.payload.chatId;
|
|
805
926
|
}
|
|
806
927
|
var CHAT_STREAM_RESYNC_EVENT_TYPE = "chat.stream.resync";
|
|
928
|
+
var CHAT_STREAM_READY_EVENT_TYPE = "chat.stream.ready";
|
|
929
|
+
var chatEventSubscriptionsSchema = z3.object({
|
|
930
|
+
chats: z3.array(z3.object({
|
|
931
|
+
workspaceId: z3.string().uuid(),
|
|
932
|
+
chatId: z3.string().min(1).max(256),
|
|
933
|
+
after: z3.string().regex(/^\d+-\d+$/)
|
|
934
|
+
})).min(1).max(256)
|
|
935
|
+
});
|
|
807
936
|
function isChatStreamEvent(value) {
|
|
808
937
|
return isRecord(value) && typeof value.id === "string" && typeof value.ts === "string" && typeof value.type === "string" && value.type.startsWith("chat.") && isRecord(value.payload);
|
|
809
938
|
}
|
|
810
939
|
var ENGINE_CHAT_EVENTS_PUSH_MAX_EVENTS = 500;
|
|
811
940
|
var chatScopedEngineEventSchema = z3.custom(
|
|
812
|
-
(value) => isChatStreamEvent(value) && value.type !== CHAT_STREAM_RESYNC_EVENT_TYPE
|
|
941
|
+
(value) => isChatStreamEvent(value) && value.type !== CHAT_STREAM_RESYNC_EVENT_TYPE && value.type !== CHAT_STREAM_READY_EVENT_TYPE
|
|
813
942
|
);
|
|
814
943
|
var engineChatEventsPushRequestSchema = z3.object({
|
|
815
944
|
epoch: z3.string().min(1).max(64),
|
|
@@ -6697,6 +6826,7 @@ function hasChatStarted(chat) {
|
|
|
6697
6826
|
var CODEX_AUTH_ENV_KEYS = [
|
|
6698
6827
|
"OPENAI_API_KEY",
|
|
6699
6828
|
"CODEX_OPENAI_BASE_URL",
|
|
6829
|
+
"CODEX_OPENAI_MODELS_URL",
|
|
6700
6830
|
"CODEX_OPENAI_AUTHORIZATION_HEADER",
|
|
6701
6831
|
"AZURE_OPENAI_API_KEY",
|
|
6702
6832
|
"CODEX_FOUNDRY_BASE_URL",
|
|
@@ -6707,6 +6837,7 @@ function codexOpenAICompatibleAuthEnv(response) {
|
|
|
6707
6837
|
return {
|
|
6708
6838
|
...response.apiKey && !response.authorizationHeader ? { OPENAI_API_KEY: response.apiKey } : {},
|
|
6709
6839
|
...response.baseUrl ? { CODEX_OPENAI_BASE_URL: response.baseUrl } : {},
|
|
6840
|
+
...response.modelsUrl ? { CODEX_OPENAI_MODELS_URL: response.modelsUrl } : {},
|
|
6710
6841
|
...response.authorizationHeader ? { CODEX_OPENAI_AUTHORIZATION_HEADER: response.authorizationHeader } : {},
|
|
6711
6842
|
REPLICAS_CODEX_AUTH_METHOD: "openai-compatible"
|
|
6712
6843
|
};
|
|
@@ -6744,6 +6875,7 @@ var CODEX_AUTH_ENV_KEYS_BY_METHOD = {
|
|
|
6744
6875
|
"openai-compatible": [
|
|
6745
6876
|
"OPENAI_API_KEY",
|
|
6746
6877
|
"CODEX_OPENAI_BASE_URL",
|
|
6878
|
+
"CODEX_OPENAI_MODELS_URL",
|
|
6747
6879
|
"CODEX_OPENAI_AUTHORIZATION_HEADER",
|
|
6748
6880
|
"REPLICAS_CODEX_AUTH_METHOD"
|
|
6749
6881
|
],
|
|
@@ -7662,6 +7794,8 @@ export {
|
|
|
7662
7794
|
detectAgentQuotaLimit,
|
|
7663
7795
|
CREDENTIAL_METHOD,
|
|
7664
7796
|
AGENT_CREDENTIAL_METHODS_IN_ORDER,
|
|
7797
|
+
listOpenAICompatibleModels,
|
|
7798
|
+
resolveOpenAICompatibleModelsUrl,
|
|
7665
7799
|
agentCredentialSnapshotSchema,
|
|
7666
7800
|
isAgentChatTurnActivityRecord,
|
|
7667
7801
|
isAgentChatSkillActivityRecord,
|
|
@@ -3,12 +3,12 @@ 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-
|
|
6
|
+
} from "./chunk-NGAPGKWO.js";
|
|
7
|
+
import "./chunk-4T7IB2IL.js";
|
|
8
8
|
import {
|
|
9
9
|
isRecord
|
|
10
10
|
} from "./chunk-UZSNFLDQ.js";
|
|
11
|
-
import "./chunk-
|
|
11
|
+
import "./chunk-YIBBAGHQ.js";
|
|
12
12
|
import "./chunk-VEQXQN22.js";
|
|
13
13
|
|
|
14
14
|
// src/command-protection-hook.ts
|
|
@@ -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-
|
|
6
|
+
} from "./chunk-NGAPGKWO.js";
|
|
7
7
|
import {
|
|
8
8
|
notifyPostToolUse
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-
|
|
9
|
+
} from "./chunk-MYD5ZGCU.js";
|
|
10
|
+
import "./chunk-4T7IB2IL.js";
|
|
11
11
|
import "./chunk-UZSNFLDQ.js";
|
|
12
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-YIBBAGHQ.js";
|
|
13
13
|
import "./chunk-VEQXQN22.js";
|
|
14
14
|
|
|
15
15
|
// src/deepseek-command-protection-plugin.ts
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
AppServerProcess,
|
|
10
10
|
buildCodexAgentEnv
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-RAXPRO4T.js";
|
|
12
12
|
import {
|
|
13
13
|
AGENT,
|
|
14
14
|
getMemoryOutputSafetyViolation,
|
|
15
15
|
headlessAgentRequestSchema
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-YIBBAGHQ.js";
|
|
17
17
|
import "./chunk-VEQXQN22.js";
|
|
18
18
|
|
|
19
19
|
// src/headless-agent.ts
|
package/dist/src/index.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
evaluateCommandProtection,
|
|
92
92
|
extractToolCommand,
|
|
93
93
|
reportCommandProtectionBlock
|
|
94
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-NGAPGKWO.js";
|
|
95
95
|
import {
|
|
96
96
|
ACCOUNT_RATE_LIMITS_UPDATED_METHOD,
|
|
97
97
|
AGENT_MESSAGE_DELTA_METHOD,
|
|
@@ -131,20 +131,20 @@ import {
|
|
|
131
131
|
recordCredentialFallback,
|
|
132
132
|
recordExhaustedCredential,
|
|
133
133
|
restartCodexAspHost
|
|
134
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-32NJI2LJ.js";
|
|
135
135
|
import {
|
|
136
136
|
ENGINE_ENV,
|
|
137
137
|
IS_WARMING_MODE,
|
|
138
138
|
monolithRequest,
|
|
139
139
|
monolithService,
|
|
140
140
|
setAgentCredentialSnapshot
|
|
141
|
-
} from "./chunk-
|
|
141
|
+
} from "./chunk-4T7IB2IL.js";
|
|
142
142
|
import {
|
|
143
143
|
AspClient,
|
|
144
144
|
SUBPROCESS_MAX_BUFFER,
|
|
145
145
|
execAsync,
|
|
146
146
|
execFileAsync
|
|
147
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-RAXPRO4T.js";
|
|
148
148
|
import {
|
|
149
149
|
isRecord as isRecord2
|
|
150
150
|
} from "./chunk-UZSNFLDQ.js";
|
|
@@ -352,7 +352,7 @@ import {
|
|
|
352
352
|
spawnRelaySubagentRequestSchema,
|
|
353
353
|
stripAgentDiagnosticErrors,
|
|
354
354
|
withTimeout
|
|
355
|
-
} from "./chunk-
|
|
355
|
+
} from "./chunk-YIBBAGHQ.js";
|
|
356
356
|
import {
|
|
357
357
|
__commonJS,
|
|
358
358
|
__export,
|
|
@@ -9476,7 +9476,6 @@ var ClaudeTokenManager = class extends BaseRefreshManager {
|
|
|
9476
9476
|
const envVars = claudeAuthEnvFromResponse(response);
|
|
9477
9477
|
applyAuthEnvTransition({
|
|
9478
9478
|
prevMethod: ENGINE_ENV.REPLICAS_CLAUDE_AUTH_METHOD ?? "none",
|
|
9479
|
-
newMethod: envVars.REPLICAS_CLAUDE_AUTH_METHOD ?? "none",
|
|
9480
9479
|
authKeys: CLAUDE_AUTH_ENV_KEYS,
|
|
9481
9480
|
authKeysByMethod: CLAUDE_AUTH_ENV_KEYS_BY_METHOD,
|
|
9482
9481
|
newEnvVars: envVars,
|
|
@@ -14847,6 +14846,7 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
14847
14846
|
currentThreadId = null;
|
|
14848
14847
|
activeTurnId = null;
|
|
14849
14848
|
threadAttached = false;
|
|
14849
|
+
attachedModel = null;
|
|
14850
14850
|
attachedDeveloperInstructions = null;
|
|
14851
14851
|
historyFile;
|
|
14852
14852
|
codexAspTranscript = null;
|
|
@@ -15253,8 +15253,9 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
15253
15253
|
async ensureThread(host, request, developerInstructions) {
|
|
15254
15254
|
await this.applySkillRegistries(host);
|
|
15255
15255
|
const existingThreadId = this.currentThreadId;
|
|
15256
|
+
const requestedModel = request.model ?? DEFAULT_MODEL;
|
|
15256
15257
|
if (existingThreadId) {
|
|
15257
|
-
if (!this.threadAttached || (developerInstructions ?? null) !== this.attachedDeveloperInstructions) {
|
|
15258
|
+
if (!this.threadAttached || requestedModel !== this.attachedModel || (developerInstructions ?? null) !== this.attachedDeveloperInstructions) {
|
|
15258
15259
|
const serviceTier2 = await this.resolveRequestedServiceTier(host, request);
|
|
15259
15260
|
const response = await host.client.request(
|
|
15260
15261
|
THREAD_RESUME_METHOD,
|
|
@@ -15263,6 +15264,7 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
15263
15264
|
this.currentThreadId = response.thread.id;
|
|
15264
15265
|
this.activeServiceTier = response.serviceTier;
|
|
15265
15266
|
this.threadAttached = true;
|
|
15267
|
+
this.attachedModel = requestedModel;
|
|
15266
15268
|
this.attachedDeveloperInstructions = developerInstructions ?? null;
|
|
15267
15269
|
this.seedHistoryFromThread(response.thread);
|
|
15268
15270
|
await this.onSaveSessionId(this.currentThreadId);
|
|
@@ -15278,6 +15280,7 @@ var CodexAspManager = class extends CodingAgentManager {
|
|
|
15278
15280
|
this.currentThreadId = threadId;
|
|
15279
15281
|
this.activeServiceTier = threadStartResponse.serviceTier;
|
|
15280
15282
|
this.threadAttached = true;
|
|
15283
|
+
this.attachedModel = requestedModel;
|
|
15281
15284
|
this.attachedDeveloperInstructions = developerInstructions ?? null;
|
|
15282
15285
|
await this.onSaveSessionId(this.currentThreadId);
|
|
15283
15286
|
return threadId;
|
|
@@ -3,11 +3,11 @@ import { createRequire as __createRequire } from 'node:module';
|
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
4
|
import {
|
|
5
5
|
notifyPostToolUse
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-MYD5ZGCU.js";
|
|
7
7
|
import {
|
|
8
8
|
isRecord
|
|
9
9
|
} from "./chunk-UZSNFLDQ.js";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-YIBBAGHQ.js";
|
|
11
11
|
import "./chunk-VEQXQN22.js";
|
|
12
12
|
|
|
13
13
|
// src/post-tool-pr-hook.ts
|
package/dist/src/relay-mcp.js
CHANGED