@gakr-gakr/codex 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client-DNN2uyJW.js +642 -0
- package/dist/client-factory-Bu9OClHJ.js +9 -0
- package/dist/command-formatters-BpPOTePl.js +520 -0
- package/dist/command-handlers-BBs7Vws9.js +1533 -0
- package/dist/compact-CDboBy7o.js +329 -0
- package/dist/computer-use-DCZB46Sw.js +367 -0
- package/dist/config-CLMSw0p2.js +510 -0
- package/dist/doctor-contract-api.js +53 -0
- package/dist/harness.js +51 -0
- package/dist/index.js +1171 -0
- package/dist/media-understanding-provider.js +335 -0
- package/dist/models-jLA2SIvd.js +110 -0
- package/dist/node-cli-sessions-BLRDs_US.js +1216 -0
- package/dist/plugin-activation-CEy_oYpx.js +452 -0
- package/dist/prompt-overlay.js +12 -0
- package/dist/protocol-C9UWI98H.js +9 -0
- package/dist/protocol-validators-BGBspNmF.js +5988 -0
- package/dist/provider-catalog.js +84 -0
- package/dist/provider-discovery.js +33 -0
- package/dist/provider.js +150 -0
- package/dist/rate-limit-cache-9LxQdE0K.js +24 -0
- package/dist/request-DbSPeTcV.js +89 -0
- package/dist/rolldown-runtime-DUslC3ob.js +14 -0
- package/dist/run-attempt-BoEwzQCv.js +5463 -0
- package/dist/session-binding-e2GFp9VH.js +222 -0
- package/dist/shared-client-D7Vy0glq.js +631 -0
- package/dist/side-question-BDLuEzFP.js +668 -0
- package/dist/test-api.js +49 -0
- package/dist/thread-lifecycle-Clo0EHMk.js +1565 -0
- package/dist/vision-tools-Cofrv35p.js +1379 -0
- package/package.json +16 -1
- package/doctor-contract-api.ts +0 -68
- package/harness.ts +0 -72
- package/index.ts +0 -124
- package/media-understanding-provider.ts +0 -521
- package/prompt-overlay.ts +0 -21
- package/provider-catalog.ts +0 -83
- package/provider-discovery.ts +0 -45
- package/provider.ts +0 -243
- package/src/app-server/app-inventory-cache.ts +0 -324
- package/src/app-server/approval-bridge.ts +0 -1211
- package/src/app-server/auth-bridge.ts +0 -614
- package/src/app-server/capabilities.ts +0 -27
- package/src/app-server/client-factory.ts +0 -24
- package/src/app-server/client.ts +0 -715
- package/src/app-server/compact.ts +0 -512
- package/src/app-server/computer-use.ts +0 -683
- package/src/app-server/config.ts +0 -1038
- package/src/app-server/context-engine-projection.ts +0 -403
- package/src/app-server/dynamic-tool-diagnostics.ts +0 -73
- package/src/app-server/dynamic-tool-profile.ts +0 -70
- package/src/app-server/dynamic-tools.ts +0 -623
- package/src/app-server/elicitation-bridge.ts +0 -783
- package/src/app-server/event-projector.ts +0 -2065
- package/src/app-server/image-payload-sanitizer.ts +0 -167
- package/src/app-server/local-runtime-attribution.ts +0 -39
- package/src/app-server/managed-binary.ts +0 -193
- package/src/app-server/models.ts +0 -172
- package/src/app-server/native-hook-relay.ts +0 -150
- package/src/app-server/native-subagent-task-mirror.ts +0 -497
- package/src/app-server/plugin-activation.ts +0 -283
- package/src/app-server/plugin-app-cache-key.ts +0 -74
- package/src/app-server/plugin-approval-roundtrip.ts +0 -122
- package/src/app-server/plugin-inventory.ts +0 -357
- package/src/app-server/plugin-thread-config.ts +0 -455
- package/src/app-server/protocol-generated/json/DynamicToolCallParams.json +0 -33
- package/src/app-server/protocol-generated/json/v2/ErrorNotification.json +0 -199
- package/src/app-server/protocol-generated/json/v2/GetAccountResponse.json +0 -102
- package/src/app-server/protocol-generated/json/v2/ModelListResponse.json +0 -227
- package/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json +0 -2630
- package/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json +0 -2630
- package/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json +0 -1659
- package/src/app-server/protocol-generated/json/v2/TurnStartResponse.json +0 -1655
- package/src/app-server/protocol-validators.ts +0 -203
- package/src/app-server/protocol.ts +0 -520
- package/src/app-server/rate-limit-cache.ts +0 -48
- package/src/app-server/rate-limits.ts +0 -583
- package/src/app-server/request.ts +0 -73
- package/src/app-server/run-attempt.ts +0 -4862
- package/src/app-server/session-binding.ts +0 -398
- package/src/app-server/session-history.ts +0 -44
- package/src/app-server/shared-client.ts +0 -289
- package/src/app-server/side-question.ts +0 -1009
- package/src/app-server/test-support.ts +0 -48
- package/src/app-server/thread-lifecycle.ts +0 -959
- package/src/app-server/timeout.ts +0 -9
- package/src/app-server/tool-progress-normalization.ts +0 -77
- package/src/app-server/trajectory.ts +0 -368
- package/src/app-server/transcript-mirror.ts +0 -208
- package/src/app-server/transport-stdio.ts +0 -107
- package/src/app-server/transport-websocket.ts +0 -90
- package/src/app-server/transport.ts +0 -117
- package/src/app-server/user-input-bridge.ts +0 -316
- package/src/app-server/version.ts +0 -4
- package/src/app-server/vision-tools.ts +0 -12
- package/src/command-account.ts +0 -544
- package/src/command-formatters.ts +0 -426
- package/src/command-handlers.ts +0 -2021
- package/src/command-plugins-management.ts +0 -137
- package/src/command-rpc.ts +0 -142
- package/src/commands.ts +0 -65
- package/src/conversation-binding-data.ts +0 -124
- package/src/conversation-binding.ts +0 -561
- package/src/conversation-control.ts +0 -303
- package/src/conversation-turn-collector.ts +0 -186
- package/src/conversation-turn-input.ts +0 -106
- package/src/migration/apply.ts +0 -501
- package/src/migration/helpers.ts +0 -55
- package/src/migration/plan.ts +0 -461
- package/src/migration/provider.ts +0 -41
- package/src/migration/source.ts +0 -643
- package/src/migration/targets.ts +0 -25
- package/src/node-cli-sessions.ts +0 -711
- package/test-api.ts +0 -95
- package/tsconfig.json +0 -16
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region extensions/codex/provider-catalog.ts
|
|
2
|
+
const CODEX_PROVIDER_ID = "codex";
|
|
3
|
+
const CODEX_BASE_URL = "https://chatgpt.com/backend-api";
|
|
4
|
+
const CODEX_APP_SERVER_AUTH_MARKER = "codex-app-server";
|
|
5
|
+
const DEFAULT_CONTEXT_WINDOW = 272e3;
|
|
6
|
+
const DEFAULT_MAX_TOKENS = 128e3;
|
|
7
|
+
const FALLBACK_CODEX_MODELS = [
|
|
8
|
+
{
|
|
9
|
+
id: "gpt-5.5",
|
|
10
|
+
model: "gpt-5.5",
|
|
11
|
+
displayName: "gpt-5.5",
|
|
12
|
+
description: "Latest frontier agentic coding model.",
|
|
13
|
+
isDefault: true,
|
|
14
|
+
inputModalities: ["text", "image"],
|
|
15
|
+
supportedReasoningEfforts: [
|
|
16
|
+
"low",
|
|
17
|
+
"medium",
|
|
18
|
+
"high",
|
|
19
|
+
"xhigh"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "gpt-5.4-mini",
|
|
24
|
+
model: "gpt-5.4-mini",
|
|
25
|
+
displayName: "GPT-5.4-Mini",
|
|
26
|
+
description: "Smaller frontier agentic coding model.",
|
|
27
|
+
inputModalities: ["text", "image"],
|
|
28
|
+
supportedReasoningEfforts: [
|
|
29
|
+
"low",
|
|
30
|
+
"medium",
|
|
31
|
+
"high",
|
|
32
|
+
"xhigh"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "gpt-5.2",
|
|
37
|
+
model: "gpt-5.2",
|
|
38
|
+
displayName: "gpt-5.2",
|
|
39
|
+
inputModalities: ["text", "image"],
|
|
40
|
+
supportedReasoningEfforts: [
|
|
41
|
+
"low",
|
|
42
|
+
"medium",
|
|
43
|
+
"high",
|
|
44
|
+
"xhigh"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
];
|
|
48
|
+
function buildCodexModelDefinition(model) {
|
|
49
|
+
const id = model.id.trim() || model.model.trim();
|
|
50
|
+
return {
|
|
51
|
+
id,
|
|
52
|
+
name: model.displayName?.trim() || id,
|
|
53
|
+
api: "openai-codex-responses",
|
|
54
|
+
reasoning: model.supportedReasoningEfforts.length > 0 || shouldDefaultToReasoningModel(id),
|
|
55
|
+
input: model.inputModalities.includes("image") ? ["text", "image"] : ["text"],
|
|
56
|
+
cost: {
|
|
57
|
+
input: 0,
|
|
58
|
+
output: 0,
|
|
59
|
+
cacheRead: 0,
|
|
60
|
+
cacheWrite: 0
|
|
61
|
+
},
|
|
62
|
+
contextWindow: DEFAULT_CONTEXT_WINDOW,
|
|
63
|
+
maxTokens: DEFAULT_MAX_TOKENS,
|
|
64
|
+
compat: {
|
|
65
|
+
supportsReasoningEffort: model.supportedReasoningEfforts.length > 0,
|
|
66
|
+
supportsUsageInStreaming: true
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function buildCodexProviderConfig(models) {
|
|
71
|
+
return {
|
|
72
|
+
baseUrl: CODEX_BASE_URL,
|
|
73
|
+
apiKey: CODEX_APP_SERVER_AUTH_MARKER,
|
|
74
|
+
auth: "token",
|
|
75
|
+
api: "openai-codex-responses",
|
|
76
|
+
models: models.map(buildCodexModelDefinition)
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function shouldDefaultToReasoningModel(modelId) {
|
|
80
|
+
const lower = modelId.toLowerCase();
|
|
81
|
+
return lower.startsWith("gpt-5") || lower.startsWith("o1") || lower.startsWith("o3") || lower.startsWith("o4");
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { CODEX_APP_SERVER_AUTH_MARKER, CODEX_BASE_URL, CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS, buildCodexModelDefinition, buildCodexProviderConfig };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CODEX_APP_SERVER_AUTH_MARKER, CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS, buildCodexProviderConfig } from "./provider-catalog.js";
|
|
2
|
+
//#region extensions/codex/provider-discovery.ts
|
|
3
|
+
function resolveCodexPluginConfig(ctx) {
|
|
4
|
+
return (ctx.config.plugins?.entries)?.codex?.config;
|
|
5
|
+
}
|
|
6
|
+
async function runCodexCatalog(ctx) {
|
|
7
|
+
const { buildCodexProviderCatalog } = await import("./provider.js");
|
|
8
|
+
return await buildCodexProviderCatalog({
|
|
9
|
+
env: ctx.env,
|
|
10
|
+
pluginConfig: resolveCodexPluginConfig(ctx)
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
const codexProviderDiscovery = {
|
|
14
|
+
id: CODEX_PROVIDER_ID,
|
|
15
|
+
label: "Codex",
|
|
16
|
+
docsPath: "/providers/models",
|
|
17
|
+
auth: [],
|
|
18
|
+
catalog: {
|
|
19
|
+
order: "late",
|
|
20
|
+
run: runCodexCatalog
|
|
21
|
+
},
|
|
22
|
+
staticCatalog: {
|
|
23
|
+
order: "late",
|
|
24
|
+
run: async () => ({ provider: buildCodexProviderConfig(FALLBACK_CODEX_MODELS) })
|
|
25
|
+
},
|
|
26
|
+
resolveSyntheticAuth: () => ({
|
|
27
|
+
apiKey: CODEX_APP_SERVER_AUTH_MARKER,
|
|
28
|
+
source: "codex-app-server",
|
|
29
|
+
mode: "token"
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { codexProviderDiscovery, codexProviderDiscovery as default };
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { CODEX_APP_SERVER_AUTH_MARKER, CODEX_BASE_URL, CODEX_PROVIDER_ID, FALLBACK_CODEX_MODELS, buildCodexModelDefinition, buildCodexProviderConfig } from "./provider-catalog.js";
|
|
2
|
+
import { c as resolveCodexAppServerRuntimeOptions, s as readCodexPluginConfig } from "./config-CLMSw0p2.js";
|
|
3
|
+
import { resolveCodexSystemPromptContribution } from "./prompt-overlay.js";
|
|
4
|
+
import { resolvePluginConfigObject } from "autobot/plugin-sdk/plugin-config-runtime";
|
|
5
|
+
import { createSubsystemLogger } from "autobot/plugin-sdk/core";
|
|
6
|
+
import { normalizeModelCompat } from "autobot/plugin-sdk/provider-model-shared";
|
|
7
|
+
//#region extensions/codex/provider.ts
|
|
8
|
+
const DEFAULT_DISCOVERY_TIMEOUT_MS = 2500;
|
|
9
|
+
const LIVE_DISCOVERY_ENV = "AUTOBOT_CODEX_DISCOVERY_LIVE";
|
|
10
|
+
const MODEL_DISCOVERY_PAGE_LIMIT = 100;
|
|
11
|
+
const CODEX_APP_SERVER_SETUP_METHOD_ID = "app-server";
|
|
12
|
+
const CODEX_DEFAULT_MODEL_REF = `${CODEX_PROVIDER_ID}/${FALLBACK_CODEX_MODELS[0].id}`;
|
|
13
|
+
const codexCatalogLog = createSubsystemLogger("codex/catalog");
|
|
14
|
+
function buildCodexProvider(options = {}) {
|
|
15
|
+
return {
|
|
16
|
+
id: CODEX_PROVIDER_ID,
|
|
17
|
+
label: "Codex",
|
|
18
|
+
docsPath: "/providers/models",
|
|
19
|
+
auth: [{
|
|
20
|
+
id: CODEX_APP_SERVER_SETUP_METHOD_ID,
|
|
21
|
+
label: "Codex app-server",
|
|
22
|
+
hint: "Use the Codex app-server runtime and managed model catalog.",
|
|
23
|
+
kind: "custom",
|
|
24
|
+
wizard: {
|
|
25
|
+
choiceId: CODEX_PROVIDER_ID,
|
|
26
|
+
choiceLabel: "Codex app-server",
|
|
27
|
+
choiceHint: "Use the Codex app-server runtime and managed model catalog.",
|
|
28
|
+
assistantPriority: -40,
|
|
29
|
+
groupId: CODEX_PROVIDER_ID,
|
|
30
|
+
groupLabel: "Codex",
|
|
31
|
+
groupHint: "Codex app-server model provider",
|
|
32
|
+
onboardingScopes: ["text-inference"]
|
|
33
|
+
},
|
|
34
|
+
run: async () => ({
|
|
35
|
+
profiles: [],
|
|
36
|
+
defaultModel: CODEX_DEFAULT_MODEL_REF
|
|
37
|
+
})
|
|
38
|
+
}],
|
|
39
|
+
catalog: {
|
|
40
|
+
order: "late",
|
|
41
|
+
run: async (ctx) => {
|
|
42
|
+
const pluginConfig = resolvePluginConfigObject(ctx.config, "codex") ?? (ctx.config ? void 0 : options.pluginConfig);
|
|
43
|
+
return await buildCodexProviderCatalog({
|
|
44
|
+
env: ctx.env,
|
|
45
|
+
pluginConfig,
|
|
46
|
+
listModels: options.listModels
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
staticCatalog: {
|
|
51
|
+
order: "late",
|
|
52
|
+
run: async () => ({ provider: buildCodexProviderConfig(FALLBACK_CODEX_MODELS) })
|
|
53
|
+
},
|
|
54
|
+
resolveDynamicModel: (ctx) => resolveCodexDynamicModel(ctx.modelId),
|
|
55
|
+
resolveSyntheticAuth: () => ({
|
|
56
|
+
apiKey: CODEX_APP_SERVER_AUTH_MARKER,
|
|
57
|
+
source: "codex-app-server",
|
|
58
|
+
mode: "token"
|
|
59
|
+
}),
|
|
60
|
+
resolveThinkingProfile: ({ modelId }) => ({ levels: [
|
|
61
|
+
{ id: "off" },
|
|
62
|
+
{ id: "minimal" },
|
|
63
|
+
{ id: "low" },
|
|
64
|
+
{ id: "medium" },
|
|
65
|
+
{ id: "high" },
|
|
66
|
+
...isKnownXHighCodexModel(modelId) ? [{ id: "xhigh" }] : []
|
|
67
|
+
] }),
|
|
68
|
+
resolveSystemPromptContribution: ({ config, modelId }) => resolveCodexSystemPromptContribution({
|
|
69
|
+
config,
|
|
70
|
+
modelId
|
|
71
|
+
}),
|
|
72
|
+
isModernModelRef: ({ modelId }) => isModernCodexModel(modelId)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async function buildCodexProviderCatalog(options = {}) {
|
|
76
|
+
const config = readCodexPluginConfig(options.pluginConfig);
|
|
77
|
+
const appServer = resolveCodexAppServerRuntimeOptions({ pluginConfig: options.pluginConfig });
|
|
78
|
+
const timeoutMs = normalizeTimeoutMs(config.discovery?.timeoutMs);
|
|
79
|
+
let discovered = [];
|
|
80
|
+
if (config.discovery?.enabled !== false && !shouldSkipLiveDiscovery(options.env)) discovered = await listModelsBestEffort({
|
|
81
|
+
listModels: options.listModels ?? listCodexAppServerModelsLazy,
|
|
82
|
+
timeoutMs,
|
|
83
|
+
startOptions: appServer.start,
|
|
84
|
+
onDiscoveryFailure: options.onDiscoveryFailure
|
|
85
|
+
});
|
|
86
|
+
return { provider: buildCodexProviderConfig(discovered.length > 0 ? discovered : FALLBACK_CODEX_MODELS) };
|
|
87
|
+
}
|
|
88
|
+
function resolveCodexDynamicModel(modelId) {
|
|
89
|
+
const id = modelId.trim();
|
|
90
|
+
if (!id) return;
|
|
91
|
+
const fallbackModel = FALLBACK_CODEX_MODELS.find((model) => model.id === id);
|
|
92
|
+
return normalizeModelCompat({
|
|
93
|
+
...buildCodexModelDefinition({
|
|
94
|
+
id,
|
|
95
|
+
model: id,
|
|
96
|
+
inputModalities: fallbackModel?.inputModalities ?? ["text"],
|
|
97
|
+
supportedReasoningEfforts: fallbackModel?.supportedReasoningEfforts ?? (shouldDefaultToReasoningModel(id) ? ["medium"] : [])
|
|
98
|
+
}),
|
|
99
|
+
provider: CODEX_PROVIDER_ID,
|
|
100
|
+
baseUrl: CODEX_BASE_URL
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async function listModelsBestEffort(params) {
|
|
104
|
+
try {
|
|
105
|
+
const models = [];
|
|
106
|
+
let cursor;
|
|
107
|
+
do {
|
|
108
|
+
const result = await params.listModels({
|
|
109
|
+
timeoutMs: params.timeoutMs,
|
|
110
|
+
limit: MODEL_DISCOVERY_PAGE_LIMIT,
|
|
111
|
+
cursor,
|
|
112
|
+
startOptions: params.startOptions,
|
|
113
|
+
sharedClient: false
|
|
114
|
+
});
|
|
115
|
+
models.push(...result.models.filter((model) => !model.hidden));
|
|
116
|
+
cursor = result.nextCursor;
|
|
117
|
+
} while (cursor);
|
|
118
|
+
return models;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
params.onDiscoveryFailure?.(error);
|
|
121
|
+
codexCatalogLog.debug("codex model discovery failed; using fallback catalog", { error: error instanceof Error ? error.message : String(error) });
|
|
122
|
+
return [];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async function listCodexAppServerModelsLazy(options) {
|
|
126
|
+
const { listCodexAppServerModels } = await import("./models-jLA2SIvd.js").then((n) => n.r);
|
|
127
|
+
return listCodexAppServerModels(options);
|
|
128
|
+
}
|
|
129
|
+
function normalizeTimeoutMs(value) {
|
|
130
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : DEFAULT_DISCOVERY_TIMEOUT_MS;
|
|
131
|
+
}
|
|
132
|
+
function shouldSkipLiveDiscovery(env = process.env) {
|
|
133
|
+
const override = env[LIVE_DISCOVERY_ENV]?.trim().toLowerCase();
|
|
134
|
+
if (override === "0" || override === "false") return true;
|
|
135
|
+
return Boolean(env.VITEST) && override !== "1";
|
|
136
|
+
}
|
|
137
|
+
function shouldDefaultToReasoningModel(modelId) {
|
|
138
|
+
const lower = modelId.toLowerCase();
|
|
139
|
+
return lower.startsWith("gpt-5") || lower.startsWith("o1") || lower.startsWith("o3") || lower.startsWith("o4");
|
|
140
|
+
}
|
|
141
|
+
function isKnownXHighCodexModel(modelId) {
|
|
142
|
+
const lower = modelId.trim().toLowerCase();
|
|
143
|
+
return lower.startsWith("gpt-5") || lower.startsWith("o3") || lower.startsWith("o4") || lower.includes("codex");
|
|
144
|
+
}
|
|
145
|
+
function isModernCodexModel(modelId) {
|
|
146
|
+
const lower = modelId.trim().toLowerCase();
|
|
147
|
+
return lower === "gpt-5.5" || lower === "gpt-5.4" || lower === "gpt-5.4-mini" || lower === "gpt-5.2";
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
export { buildCodexProvider, buildCodexProviderCatalog, isModernCodexModel };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region extensions/codex/src/app-server/rate-limit-cache.ts
|
|
2
|
+
const DEFAULT_CODEX_RATE_LIMIT_CACHE_MAX_AGE_MS = 10 * 6e4;
|
|
3
|
+
const CODEX_RATE_LIMIT_CACHE_STATE = Symbol.for("autobot.codexRateLimitCacheState");
|
|
4
|
+
function getCodexRateLimitCacheState() {
|
|
5
|
+
const globalState = globalThis;
|
|
6
|
+
globalState[CODEX_RATE_LIMIT_CACHE_STATE] ??= {};
|
|
7
|
+
return globalState[CODEX_RATE_LIMIT_CACHE_STATE];
|
|
8
|
+
}
|
|
9
|
+
function rememberCodexRateLimits(value, nowMs = Date.now()) {
|
|
10
|
+
if (value === void 0) return;
|
|
11
|
+
const state = getCodexRateLimitCacheState();
|
|
12
|
+
state.value = value;
|
|
13
|
+
state.updatedAtMs = nowMs;
|
|
14
|
+
}
|
|
15
|
+
function readRecentCodexRateLimits(options) {
|
|
16
|
+
const state = getCodexRateLimitCacheState();
|
|
17
|
+
if (state.value === void 0 || state.updatedAtMs === void 0) return;
|
|
18
|
+
const nowMs = options?.nowMs ?? Date.now();
|
|
19
|
+
const maxAgeMs = options?.maxAgeMs ?? DEFAULT_CODEX_RATE_LIMIT_CACHE_MAX_AGE_MS;
|
|
20
|
+
if (maxAgeMs >= 0 && nowMs - state.updatedAtMs > maxAgeMs) return;
|
|
21
|
+
return state.value;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { rememberCodexRateLimits as n, readRecentCodexRateLimits as t };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { n as CodexAppServerRpcError } from "./client-DNN2uyJW.js";
|
|
2
|
+
import { f as resolveCodexAppServerHomeDir, i as getSharedCodexAppServerClient, o as withTimeout, r as createIsolatedCodexAppServerClient } from "./shared-client-D7Vy0glq.js";
|
|
3
|
+
import { i as buildCodexAppInventoryCacheKey } from "./plugin-activation-CEy_oYpx.js";
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
//#region extensions/codex/src/app-server/capabilities.ts
|
|
6
|
+
const CODEX_CONTROL_METHODS = {
|
|
7
|
+
account: "account/read",
|
|
8
|
+
compact: "thread/compact/start",
|
|
9
|
+
feedback: "feedback/upload",
|
|
10
|
+
listMcpServers: "mcpServerStatus/list",
|
|
11
|
+
listSkills: "skills/list",
|
|
12
|
+
listThreads: "thread/list",
|
|
13
|
+
rateLimits: "account/rateLimits/read",
|
|
14
|
+
resumeThread: "thread/resume",
|
|
15
|
+
review: "review/start"
|
|
16
|
+
};
|
|
17
|
+
function describeControlFailure(error) {
|
|
18
|
+
if (isUnsupportedControlError(error)) return "unsupported by this Codex app-server";
|
|
19
|
+
return error instanceof Error ? error.message : String(error);
|
|
20
|
+
}
|
|
21
|
+
function isUnsupportedControlError(error) {
|
|
22
|
+
return error instanceof CodexAppServerRpcError && error.code === -32601;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region extensions/codex/src/app-server/plugin-app-cache-key.ts
|
|
26
|
+
function buildCodexPluginAppCacheKey(params) {
|
|
27
|
+
return buildCodexAppInventoryCacheKey({
|
|
28
|
+
codexHome: resolveCodexPluginAppCacheCodexHome(params.appServer, params.agentDir),
|
|
29
|
+
endpoint: resolveCodexPluginAppCacheEndpoint(params.appServer),
|
|
30
|
+
authProfileId: params.authProfileId,
|
|
31
|
+
accountId: params.accountId,
|
|
32
|
+
envApiKeyFingerprint: params.envApiKeyFingerprint,
|
|
33
|
+
appServerVersion: params.appServerVersion
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function resolveCodexPluginAppCacheEndpoint(appServer) {
|
|
37
|
+
return JSON.stringify({
|
|
38
|
+
transport: appServer.start.transport,
|
|
39
|
+
command: appServer.start.command,
|
|
40
|
+
args: appServer.start.args,
|
|
41
|
+
url: appServer.start.url ?? null,
|
|
42
|
+
credentialFingerprint: fingerprintCodexPluginAppCacheCredentials(appServer.start)
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function resolveCodexPluginAppCacheCodexHome(appServer, agentDir) {
|
|
46
|
+
const configuredCodexHome = appServer.start.env?.CODEX_HOME?.trim();
|
|
47
|
+
if (configuredCodexHome) return configuredCodexHome;
|
|
48
|
+
return appServer.start.transport === "stdio" && agentDir ? resolveCodexAppServerHomeDir(agentDir) : void 0;
|
|
49
|
+
}
|
|
50
|
+
function fingerprintCodexPluginAppCacheCredentials(startOptions) {
|
|
51
|
+
const authToken = startOptions.authToken ?? "";
|
|
52
|
+
const headers = Object.entries(startOptions.headers).map(([key, value]) => [key.toLowerCase(), value]).toSorted(([left], [right]) => left.localeCompare(right));
|
|
53
|
+
if (!authToken && headers.length === 0) return null;
|
|
54
|
+
const hash = createHash("sha256");
|
|
55
|
+
hash.update("autobot:codex:plugin-app-cache-credentials:v1");
|
|
56
|
+
hash.update("\0");
|
|
57
|
+
hash.update(authToken);
|
|
58
|
+
for (const [key, value] of headers) {
|
|
59
|
+
hash.update("\0");
|
|
60
|
+
hash.update(key);
|
|
61
|
+
hash.update("\0");
|
|
62
|
+
hash.update(value);
|
|
63
|
+
}
|
|
64
|
+
return `sha256:${hash.digest("hex")}`;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region extensions/codex/src/app-server/request.ts
|
|
68
|
+
async function requestCodexAppServerJson(params) {
|
|
69
|
+
const timeoutMs = params.timeoutMs ?? 6e4;
|
|
70
|
+
return await withTimeout((async () => {
|
|
71
|
+
const client = await (params.isolated ? createIsolatedCodexAppServerClient : getSharedCodexAppServerClient)({
|
|
72
|
+
startOptions: params.startOptions,
|
|
73
|
+
timeoutMs,
|
|
74
|
+
authProfileId: params.authProfileId,
|
|
75
|
+
agentDir: params.agentDir,
|
|
76
|
+
config: params.config
|
|
77
|
+
});
|
|
78
|
+
try {
|
|
79
|
+
return await client.request(params.method, params.requestParams, { timeoutMs });
|
|
80
|
+
} finally {
|
|
81
|
+
if (params.isolated) await client.closeAndWait({
|
|
82
|
+
exitTimeoutMs: 2e3,
|
|
83
|
+
forceKillDelayMs: 250
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
})(), timeoutMs, `codex app-server ${params.method} timed out`);
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
export { describeControlFailure as i, buildCodexPluginAppCacheKey as n, CODEX_CONTROL_METHODS as r, requestCodexAppServerJson as t };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __exportAll = (all, no_symbols) => {
|
|
5
|
+
let target = {};
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { __exportAll as t };
|