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