@alpacakit/agents 0.1.0-beta.39 → 0.2.0-beta.3
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/README.md +142 -1
- package/dist/agents/builtin.d.ts +2 -2
- package/dist/agents/builtin.d.ts.map +1 -1
- package/dist/agents/builtin.js +6 -4
- package/dist/agents/claude/cli.d.ts +133 -0
- package/dist/agents/claude/cli.d.ts.map +1 -0
- package/dist/agents/claude/cli.js +182 -0
- package/dist/agents/claude/host.d.ts +14 -0
- package/dist/agents/claude/host.d.ts.map +1 -0
- package/dist/agents/claude/host.js +319 -0
- package/dist/agents/{claude.d.ts → claude/index.d.ts} +11 -11
- package/dist/agents/claude/index.d.ts.map +1 -0
- package/dist/agents/claude/index.js +134 -0
- package/dist/agents/claude/session.d.ts +25 -0
- package/dist/agents/claude/session.d.ts.map +1 -0
- package/dist/agents/claude/session.js +321 -0
- package/dist/agents/codex/cli.d.ts +132 -0
- package/dist/agents/codex/cli.d.ts.map +1 -0
- package/dist/agents/codex/cli.js +110 -0
- package/dist/agents/codex/host.d.ts +14 -0
- package/dist/agents/codex/host.d.ts.map +1 -0
- package/dist/agents/codex/host.js +221 -0
- package/dist/agents/codex/index.d.ts +14 -0
- package/dist/agents/codex/index.d.ts.map +1 -0
- package/dist/agents/codex/index.js +127 -0
- package/dist/agents/codex/session.d.ts +21 -0
- package/dist/agents/codex/session.d.ts.map +1 -0
- package/dist/agents/codex/session.js +390 -0
- package/dist/agents/openai-compatible/fetch-engine.d.ts.map +1 -1
- package/dist/agents/openai-compatible/fetch-engine.js +3 -2
- package/dist/agents/openai-compatible/pi/engine.js +1 -1
- package/dist/agents/openai-compatible/pi/{session.d.ts → run.d.ts} +1 -1
- package/dist/agents/openai-compatible/pi/run.d.ts.map +1 -0
- package/dist/agents/openai-compatible/pi/sandbox.d.ts.map +1 -1
- package/dist/auth/login-probe.d.ts +6 -4
- package/dist/auth/login-probe.d.ts.map +1 -1
- package/dist/auth/login-probe.js +19 -13
- package/dist/auth/material.d.ts +1 -1
- package/dist/auth/material.d.ts.map +1 -1
- package/dist/codex/app-server.d.ts +50 -1
- package/dist/codex/app-server.d.ts.map +1 -1
- package/dist/codex/app-server.js +140 -66
- package/dist/codex/index.d.ts +3 -2
- package/dist/codex/index.d.ts.map +1 -1
- package/dist/codex/index.js +2 -1
- package/dist/codex/protocol.d.ts +101 -0
- package/dist/codex/protocol.d.ts.map +1 -1
- package/dist/codex/protocol.js +78 -0
- package/dist/config/agent-config-validation.d.ts +1 -1
- package/dist/config/agent-config-validation.d.ts.map +1 -1
- package/dist/config/agent-configs.d.ts.map +1 -1
- package/dist/config/agent-configs.js +3 -3
- package/dist/config/compose.d.ts.map +1 -1
- package/dist/config/config.d.ts +1 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/model.d.ts +0 -1
- package/dist/config/model.d.ts.map +1 -1
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +1 -1
- package/dist/config/store.d.ts.map +1 -1
- package/dist/config/store.js +6 -24
- package/dist/config/support.d.ts +0 -1
- package/dist/config/support.d.ts.map +1 -1
- package/dist/config/support.js +0 -9
- package/dist/core/cli-child.d.ts +56 -0
- package/dist/core/cli-child.d.ts.map +1 -0
- package/dist/core/cli-child.js +105 -0
- package/dist/core/fs.d.ts +1 -1
- package/dist/core/fs.d.ts.map +1 -1
- package/dist/core/fs.js +10 -2
- package/dist/core/node-ports.d.ts.map +1 -1
- package/dist/core/node-ports.js +1 -5
- package/dist/core/session.d.ts +104 -0
- package/dist/core/session.d.ts.map +1 -0
- package/dist/core/session.js +29 -0
- package/dist/fleet/store.d.ts.map +1 -1
- package/dist/fleet/store.js +4 -3
- package/dist/host/availability.d.ts +2 -1
- package/dist/host/availability.d.ts.map +1 -1
- package/dist/host/github-dir.d.ts.map +1 -1
- package/dist/host/github-dir.js +2 -1
- package/dist/host/mcp-list.d.ts.map +1 -1
- package/dist/host/mcp-list.js +5 -6
- package/dist/host/run-command.d.ts +2 -1
- package/dist/host/run-command.d.ts.map +1 -1
- package/dist/host/run-command.js +10 -19
- package/dist/host/session-files.d.ts +23 -0
- package/dist/host/session-files.d.ts.map +1 -0
- package/dist/host/session-files.js +92 -0
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/internal/controlled-process/supervisor-runtime.js +27 -1
- package/dist/kernel/classify.d.ts +1 -2
- package/dist/kernel/classify.d.ts.map +1 -1
- package/dist/kernel/classify.js +1 -1
- package/dist/kernel/cli-agent.d.ts.map +1 -1
- package/dist/kernel/cli-agent.js +26 -85
- package/dist/kernel/cli-login.d.ts.map +1 -1
- package/dist/kernel/cli-login.js +9 -30
- package/dist/kernel/definition.d.ts +11 -2
- package/dist/kernel/definition.d.ts.map +1 -1
- package/dist/kernel/facets.d.ts +38 -1
- package/dist/kernel/facets.d.ts.map +1 -1
- package/dist/kernel/facets.js +20 -0
- package/dist/kernel/login.d.ts.map +1 -1
- package/dist/kernel/login.js +2 -1
- package/dist/kernel/options.d.ts +1 -1
- package/dist/kernel/options.d.ts.map +1 -1
- package/dist/kernel/run.d.ts.map +1 -1
- package/dist/kernel/run.js +2 -1
- package/dist/kernel/runtime.d.ts +10 -6
- package/dist/kernel/runtime.d.ts.map +1 -1
- package/dist/kernel/runtime.js +4 -1
- package/dist/kernel/session.d.ts +104 -0
- package/dist/kernel/session.d.ts.map +1 -0
- package/dist/kernel/session.js +314 -0
- package/dist/testing/fake-exec.d.ts +10 -5
- package/dist/testing/fake-exec.d.ts.map +1 -1
- package/dist/testing/fake-exec.js +17 -2
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -1
- package/package.json +2 -2
- package/dist/agents/claude.d.ts.map +0 -1
- package/dist/agents/claude.js +0 -543
- package/dist/agents/codex.d.ts +0 -19
- package/dist/agents/codex.d.ts.map +0 -1
- package/dist/agents/codex.js +0 -377
- package/dist/agents/openai-compatible/pi/session.d.ts.map +0 -1
- /package/dist/agents/openai-compatible/pi/{session.js → run.js} +0 -0
package/dist/agents/codex.js
DELETED
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Built-in codex CLI contract:
|
|
3
|
-
* `codex exec [--model m] [-c model_reasoning_effort="e"] --json
|
|
4
|
-
* --skip-git-repo-check --sandbox <mode> -C <workspace>`, prompt on
|
|
5
|
-
* stdin. Codex sandboxing is filesystem-level, so read-only grants have
|
|
6
|
-
* no argv mapping and are ignored here.
|
|
7
|
-
*/
|
|
8
|
-
import { LOGIN_METHOD } from "../auth/login.js";
|
|
9
|
-
import { cliLoginProbe } from "../auth/login-probe.js";
|
|
10
|
-
import { AUTH_MATERIAL_KIND, envVarAuthMaterial } from "../auth/material.js";
|
|
11
|
-
import { requireSecret } from "../auth/secrets.js";
|
|
12
|
-
import { listAllCodexMcpServerStatuses, withCodexAppServer, } from "../codex/app-server.js";
|
|
13
|
-
import { CODEX_APP_SERVER_METHOD } from "../codex/protocol.js";
|
|
14
|
-
import { AGENT_ERROR_CODE, AgentError, AUTH_FAILURE_REASON, } from "../core/error.js";
|
|
15
|
-
import { readJsonRecord, readRecord, readString } from "../core/json.js";
|
|
16
|
-
import { AGENT_EVENT_TYPE } from "../core/run.js";
|
|
17
|
-
import { cliAvailability } from "../host/availability.js";
|
|
18
|
-
import { INSTALL_STATUS, MCP_SCOPE, MCP_TRANSPORT, SKILL_SOURCE_KIND, } from "../host/capabilities.js";
|
|
19
|
-
import { runHostCommand } from "../host/run-command.js";
|
|
20
|
-
import { parseCooldownHint } from "../kernel/classify.js";
|
|
21
|
-
import { defineCliAgent } from "../kernel/cli-agent.js";
|
|
22
|
-
import { cliLoginCommand } from "../kernel/cli-login.js";
|
|
23
|
-
import { SANDBOX_MODE } from "../kernel/options.js";
|
|
24
|
-
export const CODEX_HOME_ENV_VAR = "CODEX_HOME";
|
|
25
|
-
export const CODEX_API_KEY_ENV_VAR = "OPENAI_API_KEY";
|
|
26
|
-
const CODEX = {
|
|
27
|
-
id: "codex",
|
|
28
|
-
command: "codex",
|
|
29
|
-
cli: {
|
|
30
|
-
exec: "exec",
|
|
31
|
-
model: "--model",
|
|
32
|
-
config: "-c",
|
|
33
|
-
reasoningEffortConfigKey: "model_reasoning_effort",
|
|
34
|
-
json: "--json",
|
|
35
|
-
skipGitRepoCheck: "--skip-git-repo-check",
|
|
36
|
-
sandbox: "--sandbox",
|
|
37
|
-
workspace: "-C",
|
|
38
|
-
},
|
|
39
|
-
sandbox: {
|
|
40
|
-
full: "danger-full-access",
|
|
41
|
-
readOnly: "read-only",
|
|
42
|
-
},
|
|
43
|
-
auth: {
|
|
44
|
-
// Exit-code-only login probe (E12): `codex login status` exits 0 when a
|
|
45
|
-
// credential is present, nonzero otherwise. The output format is not
|
|
46
|
-
// parsed — only the exit code decides valid/invalid, like claude's.
|
|
47
|
-
statusArgs: ["login", "status"],
|
|
48
|
-
oauthLoginArgs: ["login"],
|
|
49
|
-
deviceLoginArgs: ["login", "--device-auth"],
|
|
50
|
-
},
|
|
51
|
-
json: {
|
|
52
|
-
field: {
|
|
53
|
-
type: "type",
|
|
54
|
-
text: "text",
|
|
55
|
-
item: "item",
|
|
56
|
-
},
|
|
57
|
-
event: {
|
|
58
|
-
turnCompleted: "turn.completed",
|
|
59
|
-
agentMessage: "agent_message",
|
|
60
|
-
itemCompleted: "item.completed",
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
mcp: {
|
|
64
|
-
add: "add",
|
|
65
|
-
env: "--env",
|
|
66
|
-
executableSeparator: "--",
|
|
67
|
-
mcp: "mcp",
|
|
68
|
-
remove: "remove",
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
const COMPETING_API_KEY_VARS = ["OPENAI_API_KEY", "CODEX_API_KEY"];
|
|
72
|
-
const COMPETING_HOME_VARS = ["CODEX_HOME", "CODEX_API_KEY"];
|
|
73
|
-
const UNSUPPORTED_CWD_REASON = "unsupported codex stdio mcp cwd";
|
|
74
|
-
const UNSUPPORTED_SCOPE_REASON_PREFIX = "unsupported codex mcp scope";
|
|
75
|
-
const UNSUPPORTED_PLUGIN_OVERWRITE_REASON = "plugin install does not support overwrite";
|
|
76
|
-
const CODEX_PLUGIN_AUTH_REQUIRED_MESSAGE = "Codex plugin installation requires app authorization";
|
|
77
|
-
const CODEX_ALREADY_INSTALLED_STATUS = /already/i;
|
|
78
|
-
const CODEX_MCP_UNUSABLE_STATUS = /failed|error|invalid|missing|required/i;
|
|
79
|
-
/** Codex capacity phrasing (v1 F5 signals, kept verbatim). */
|
|
80
|
-
const CAPACITY_TEXT = /selected model is at capacity|model is at capacity/i;
|
|
81
|
-
const CAPACITY_COMBINED = /at capacity/i;
|
|
82
|
-
const CAPACITY_MODEL = /model/i;
|
|
83
|
-
function sharedArgs(ctx, sandboxValue) {
|
|
84
|
-
return [
|
|
85
|
-
CODEX.cli.exec,
|
|
86
|
-
...(ctx.model === null ? [] : [CODEX.cli.model, ctx.model]),
|
|
87
|
-
...(ctx.effort === null
|
|
88
|
-
? []
|
|
89
|
-
: [
|
|
90
|
-
CODEX.cli.config,
|
|
91
|
-
`${CODEX.cli.reasoningEffortConfigKey}="${ctx.effort}"`,
|
|
92
|
-
]),
|
|
93
|
-
CODEX.cli.json,
|
|
94
|
-
CODEX.cli.skipGitRepoCheck,
|
|
95
|
-
CODEX.cli.sandbox,
|
|
96
|
-
sandboxValue,
|
|
97
|
-
CODEX.cli.workspace,
|
|
98
|
-
ctx.workspace,
|
|
99
|
-
];
|
|
100
|
-
}
|
|
101
|
-
function parseCodexLine(line) {
|
|
102
|
-
const record = readJsonRecord(line);
|
|
103
|
-
if (record === null) {
|
|
104
|
-
return [];
|
|
105
|
-
}
|
|
106
|
-
const type = readString(record, CODEX.json.field.type);
|
|
107
|
-
if (type === CODEX.json.event.turnCompleted) {
|
|
108
|
-
return [{ type: AGENT_EVENT_TYPE.turn }];
|
|
109
|
-
}
|
|
110
|
-
if (type === CODEX.json.event.agentMessage) {
|
|
111
|
-
const text = readString(record, CODEX.json.field.text);
|
|
112
|
-
return text === null ? [] : [{ type: AGENT_EVENT_TYPE.message, text }];
|
|
113
|
-
}
|
|
114
|
-
if (type === CODEX.json.event.itemCompleted) {
|
|
115
|
-
const item = readRecord(record, CODEX.json.field.item);
|
|
116
|
-
if (item !== null &&
|
|
117
|
-
readString(item, CODEX.json.field.type) === CODEX.json.event.agentMessage) {
|
|
118
|
-
const text = readString(item, CODEX.json.field.text);
|
|
119
|
-
return text === null ? [] : [{ type: AGENT_EVENT_TYPE.message, text }];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return [];
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Codex "selected model is at capacity" phrasing, plus the looser
|
|
126
|
-
* "model ... at capacity" combination. Exported for custom agents that
|
|
127
|
-
* surface the same provider text.
|
|
128
|
-
*/
|
|
129
|
-
export function capacityTextMatcher() {
|
|
130
|
-
return (evidence) => {
|
|
131
|
-
const text = `${evidence.stderr}\n${evidence.stdout}`;
|
|
132
|
-
const matches = CAPACITY_TEXT.test(text) ||
|
|
133
|
-
(CAPACITY_COMBINED.test(text) && CAPACITY_MODEL.test(text));
|
|
134
|
-
if (!matches) {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
return {
|
|
138
|
-
code: AGENT_ERROR_CODE.capacity,
|
|
139
|
-
message: "Provider is at capacity",
|
|
140
|
-
data: { cooldownUntil: parseCooldownHint(text, evidence.now) },
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
function codexAppServerCwd(ctx) {
|
|
145
|
-
return ctx.location.projectDir ?? ctx.location.homeDir;
|
|
146
|
-
}
|
|
147
|
-
function codexAppServerCwds(ctx) {
|
|
148
|
-
return [codexAppServerCwd(ctx)];
|
|
149
|
-
}
|
|
150
|
-
async function listCodexSkills(ctx) {
|
|
151
|
-
return withCodexAppServer(codexAppServerOptions(ctx), async (client) => {
|
|
152
|
-
const result = await client.request(CODEX_APP_SERVER_METHOD.skillsList, {
|
|
153
|
-
cwds: codexAppServerCwds(ctx),
|
|
154
|
-
forceReload: true,
|
|
155
|
-
});
|
|
156
|
-
return skillsFromCodexResult(result);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
async function installCodexPlugin(ctx, source, options) {
|
|
160
|
-
if (options.overwrite === true) {
|
|
161
|
-
// `plugin/install` has no overwrite semantics; refusing is honest,
|
|
162
|
-
// silently ignoring the request is not (same contract as claude).
|
|
163
|
-
throw new AgentError({
|
|
164
|
-
code: AGENT_ERROR_CODE.invalidInput,
|
|
165
|
-
classification: AgentError.agentFailure(AGENT_ERROR_CODE.invalidInput),
|
|
166
|
-
message: "Codex plugin installation cannot overwrite an installed plugin",
|
|
167
|
-
data: { reason: UNSUPPORTED_PLUGIN_OVERWRITE_REASON },
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
return withCodexAppServer(codexAppServerOptions(ctx), async (client) => {
|
|
171
|
-
const result = await client.request(CODEX_APP_SERVER_METHOD.pluginInstall, {
|
|
172
|
-
pluginName: source.name,
|
|
173
|
-
marketplacePath: null,
|
|
174
|
-
remoteMarketplaceName: null,
|
|
175
|
-
});
|
|
176
|
-
return installOutcomeFromCodexPlugin(source.name, result);
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
async function listCodexMcp(ctx) {
|
|
180
|
-
return withCodexAppServer(codexAppServerOptions(ctx), async (client) => (await listAllCodexMcpServerStatuses(client)).map(codexMcpState));
|
|
181
|
-
}
|
|
182
|
-
async function addCodexStdioMcp(ctx, name, spec, options) {
|
|
183
|
-
assertCodexStdioMcpSupported(spec, options);
|
|
184
|
-
await runHostCommand(ctx, {
|
|
185
|
-
command: CODEX.command,
|
|
186
|
-
args: [
|
|
187
|
-
CODEX.mcp.mcp,
|
|
188
|
-
CODEX.mcp.add,
|
|
189
|
-
name,
|
|
190
|
-
...Object.entries(spec.env).flatMap(([key, value]) => [
|
|
191
|
-
CODEX.mcp.env,
|
|
192
|
-
`${key}=${value}`,
|
|
193
|
-
]),
|
|
194
|
-
CODEX.mcp.executableSeparator,
|
|
195
|
-
spec.command,
|
|
196
|
-
...spec.args,
|
|
197
|
-
],
|
|
198
|
-
});
|
|
199
|
-
return {
|
|
200
|
-
status: INSTALL_STATUS.installed,
|
|
201
|
-
location: `codex:${options.scope}:${name}`,
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
async function removeCodexMcp(ctx, name, options) {
|
|
205
|
-
assertCodexMcpScopeSupported(options.scope);
|
|
206
|
-
await runHostCommand(ctx, {
|
|
207
|
-
command: CODEX.command,
|
|
208
|
-
args: [CODEX.mcp.mcp, CODEX.mcp.remove, name],
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
function assertCodexStdioMcpSupported(spec, options) {
|
|
212
|
-
assertCodexMcpScopeSupported(options.scope);
|
|
213
|
-
if (spec.cwd !== null) {
|
|
214
|
-
throw new AgentError({
|
|
215
|
-
code: AGENT_ERROR_CODE.invalidInput,
|
|
216
|
-
classification: AgentError.agentFailure(AGENT_ERROR_CODE.invalidInput),
|
|
217
|
-
message: "Codex stdio MCP registration does not support server cwd",
|
|
218
|
-
data: { reason: UNSUPPORTED_CWD_REASON },
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
function assertCodexMcpScopeSupported(scope) {
|
|
223
|
-
if (scope === MCP_SCOPE.user) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
const reason = [UNSUPPORTED_SCOPE_REASON_PREFIX, scope].join(": ");
|
|
227
|
-
throw new AgentError({
|
|
228
|
-
code: AGENT_ERROR_CODE.invalidInput,
|
|
229
|
-
classification: AgentError.agentFailure(AGENT_ERROR_CODE.invalidInput),
|
|
230
|
-
message: `Codex MCP registration does not support scope "${scope}"`,
|
|
231
|
-
data: { reason },
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
function codexAppServerOptions(ctx) {
|
|
235
|
-
return {
|
|
236
|
-
exec: ctx.exec,
|
|
237
|
-
clock: ctx.clock,
|
|
238
|
-
env: ctx.env,
|
|
239
|
-
cwd: codexAppServerCwd(ctx),
|
|
240
|
-
command: CODEX.command,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
function skillsFromCodexResult(result) {
|
|
244
|
-
return result.data.flatMap((entry) => entry.skills.map((skill) => ({
|
|
245
|
-
id: skill.name,
|
|
246
|
-
name: skill.name,
|
|
247
|
-
description: skill.description,
|
|
248
|
-
location: skill.path,
|
|
249
|
-
source: `codex:${skill.scope}`,
|
|
250
|
-
})));
|
|
251
|
-
}
|
|
252
|
-
function installOutcomeFromCodexPlugin(name, result) {
|
|
253
|
-
if (result.appsNeedingAuth.length > 0) {
|
|
254
|
-
throw new AgentError({
|
|
255
|
-
code: AGENT_ERROR_CODE.auth,
|
|
256
|
-
classification: AgentError.agentFailure(AGENT_ERROR_CODE.auth),
|
|
257
|
-
message: CODEX_PLUGIN_AUTH_REQUIRED_MESSAGE,
|
|
258
|
-
data: {
|
|
259
|
-
reason: AUTH_FAILURE_REASON.notLoggedIn,
|
|
260
|
-
detail: result.authPolicy,
|
|
261
|
-
},
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
const location = result.location ?? `codex:plugin:${name}`;
|
|
265
|
-
const alreadyInstalled = result.alreadyInstalled === true ||
|
|
266
|
-
(result.status !== null &&
|
|
267
|
-
CODEX_ALREADY_INSTALLED_STATUS.test(result.status));
|
|
268
|
-
return {
|
|
269
|
-
status: alreadyInstalled
|
|
270
|
-
? INSTALL_STATUS.alreadyInstalled
|
|
271
|
-
: INSTALL_STATUS.installed,
|
|
272
|
-
location,
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
function codexMcpState(status) {
|
|
276
|
-
// tools === null = the app-server did not enumerate tools; McpServerState
|
|
277
|
-
// keeps that distinct from an enumerated-but-empty tool list.
|
|
278
|
-
const tools = status.tools === null
|
|
279
|
-
? null
|
|
280
|
-
: Object.entries(status.tools).map(([key, tool]) => tool.name ?? key);
|
|
281
|
-
return {
|
|
282
|
-
name: status.name,
|
|
283
|
-
transport: MCP_TRANSPORT.stdio,
|
|
284
|
-
usable: !CODEX_MCP_UNUSABLE_STATUS.test(status.authStatus),
|
|
285
|
-
tools,
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
function codexLogin(args) {
|
|
289
|
-
return (request, ctx) => cliLoginCommand({
|
|
290
|
-
command: CODEX.command,
|
|
291
|
-
args,
|
|
292
|
-
envPatch: {
|
|
293
|
-
set: { [CODEX_HOME_ENV_VAR]: request.homeDir },
|
|
294
|
-
unset: COMPETING_API_KEY_VARS,
|
|
295
|
-
},
|
|
296
|
-
request,
|
|
297
|
-
ctx,
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
export function codex() {
|
|
301
|
-
return defineCliAgent({
|
|
302
|
-
id: CODEX.id,
|
|
303
|
-
command: CODEX.command,
|
|
304
|
-
args: {
|
|
305
|
-
[SANDBOX_MODE.full]: (_sandbox, ctx) => sharedArgs(ctx, CODEX.sandbox.full),
|
|
306
|
-
[SANDBOX_MODE.readOnly]: (_sandbox, ctx) => sharedArgs(ctx, CODEX.sandbox.readOnly),
|
|
307
|
-
},
|
|
308
|
-
parseLine: parseCodexLine,
|
|
309
|
-
classify: [capacityTextMatcher()],
|
|
310
|
-
detectCompletion: (line, state) => {
|
|
311
|
-
if (state.messages.length === 0) {
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
const record = readJsonRecord(line);
|
|
315
|
-
return (record !== null &&
|
|
316
|
-
readString(record, CODEX.json.field.type) ===
|
|
317
|
-
CODEX.json.event.turnCompleted);
|
|
318
|
-
},
|
|
319
|
-
availability: cliAvailability({
|
|
320
|
-
command: CODEX.command,
|
|
321
|
-
commandMissingRemediation: {
|
|
322
|
-
detail: "Install Codex and ensure `codex` is on PATH.",
|
|
323
|
-
command: null,
|
|
324
|
-
},
|
|
325
|
-
authentication: {
|
|
326
|
-
args: CODEX.auth.statusArgs,
|
|
327
|
-
remediation: {
|
|
328
|
-
detail: "Sign in to Codex.",
|
|
329
|
-
command: {
|
|
330
|
-
executable: CODEX.command,
|
|
331
|
-
args: CODEX.auth.oauthLoginArgs,
|
|
332
|
-
},
|
|
333
|
-
},
|
|
334
|
-
},
|
|
335
|
-
}),
|
|
336
|
-
auth: {
|
|
337
|
-
[AUTH_MATERIAL_KIND.homeDir]: envVarAuthMaterial({
|
|
338
|
-
set: (material) => ({ [CODEX_HOME_ENV_VAR]: material.path }),
|
|
339
|
-
unset: COMPETING_API_KEY_VARS,
|
|
340
|
-
check: (material, ctx) => cliLoginProbe({
|
|
341
|
-
command: CODEX.command,
|
|
342
|
-
args: CODEX.auth.statusArgs,
|
|
343
|
-
envPatch: {
|
|
344
|
-
set: { [CODEX_HOME_ENV_VAR]: material.path },
|
|
345
|
-
unset: COMPETING_API_KEY_VARS,
|
|
346
|
-
},
|
|
347
|
-
ctx,
|
|
348
|
-
}),
|
|
349
|
-
}),
|
|
350
|
-
[AUTH_MATERIAL_KIND.apiKey]: envVarAuthMaterial({
|
|
351
|
-
set: async (material, secrets) => ({
|
|
352
|
-
[CODEX_API_KEY_ENV_VAR]: await requireSecret(secrets, material.secret),
|
|
353
|
-
}),
|
|
354
|
-
unset: COMPETING_HOME_VARS,
|
|
355
|
-
}),
|
|
356
|
-
},
|
|
357
|
-
login: {
|
|
358
|
-
methods: {
|
|
359
|
-
[LOGIN_METHOD.oauth]: codexLogin(CODEX.auth.oauthLoginArgs),
|
|
360
|
-
[LOGIN_METHOD.device]: codexLogin(CODEX.auth.deviceLoginArgs),
|
|
361
|
-
},
|
|
362
|
-
},
|
|
363
|
-
skills: {
|
|
364
|
-
list: listCodexSkills,
|
|
365
|
-
install: {
|
|
366
|
-
[SKILL_SOURCE_KIND.plugin]: installCodexPlugin,
|
|
367
|
-
},
|
|
368
|
-
},
|
|
369
|
-
mcp: {
|
|
370
|
-
list: listCodexMcp,
|
|
371
|
-
add: {
|
|
372
|
-
[MCP_TRANSPORT.stdio]: addCodexStdioMcp,
|
|
373
|
-
},
|
|
374
|
-
remove: removeCodexMcp,
|
|
375
|
-
},
|
|
376
|
-
});
|
|
377
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/agents/openai-compatible/pi/session.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAkB,QAAQ,EAAE,MAAM,aAAa,CAAC;AA8E5D,KAAK,iBAAiB,GAAG;IACvB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,8BAA8B,CAAC;IAChD,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;CAC1B,CAAC;AAWF,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,QAAQ,CAE/D"}
|
|
File without changes
|