@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/codex/app-server.js
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Codex app-server client over stdio JSON-RPC. One client is one child
|
|
3
|
+
* process, held as long as the caller wants: host-plane calls create one
|
|
4
|
+
* per call (`withCodexAppServer`), a Session keeps one for the thread's
|
|
5
|
+
* whole life. Both directions are modeled — client requests get typed,
|
|
6
|
+
* decoded results; server notifications and server-initiated requests
|
|
7
|
+
* (approval prompts) arrive on `incoming`, and `respond` answers the latter.
|
|
8
|
+
* A request timeout fails that request only; it never kills the process,
|
|
9
|
+
* because a Session's other traffic shares it.
|
|
10
|
+
*/
|
|
11
|
+
import { AsyncQueue } from "../core/async-queue.js";
|
|
12
|
+
import { appendTail, endProcessGracefully, failureEvidence, LineBuffer, NO_FAILURE_EVIDENCE, resolveCommand, } from "../core/cli-child.js";
|
|
13
|
+
import { AGENT_ERROR_CODE, AgentError, TIMEOUT_KIND } from "../core/error.js";
|
|
2
14
|
import { readJsonRecord } from "../core/json.js";
|
|
3
15
|
import { redactSecrets } from "../core/redact.js";
|
|
4
|
-
import { OUTPUT_CHANNEL
|
|
16
|
+
import { OUTPUT_CHANNEL } from "../core/values.js";
|
|
5
17
|
import { CODEX_APP_SERVER_METHOD, CODEX_APP_SERVER_RESULT_DECODERS, CODEX_MCP_STATUS_DETAIL, } from "./protocol.js";
|
|
18
|
+
export const CODEX_INCOMING_KIND = {
|
|
19
|
+
notification: "notification",
|
|
20
|
+
request: "request",
|
|
21
|
+
};
|
|
6
22
|
const DEFAULT_CODEX_COMMAND = "codex";
|
|
7
23
|
const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
|
|
8
24
|
const APP_SERVER_ARGS = ["app-server"];
|
|
@@ -14,15 +30,14 @@ const APP_SERVER_ARGS = ["app-server"];
|
|
|
14
30
|
const DEFAULT_APP_SERVER_CLIENT_INFO = {
|
|
15
31
|
name: "agents",
|
|
16
32
|
title: "Agents",
|
|
17
|
-
version: "0.
|
|
33
|
+
version: "0.2.0",
|
|
18
34
|
};
|
|
19
|
-
const OUTPUT_TAIL_CHARS = 2_000;
|
|
20
35
|
const MCP_PAGE_LIMIT = 500;
|
|
21
36
|
const JSON_RPC_FRAME_SEPARATOR = "\n";
|
|
22
|
-
const JSON_RPC_FRAME_BOUNDARY = /\r?\n/u;
|
|
23
37
|
const JSON_RPC_FIELD = {
|
|
24
38
|
id: "id",
|
|
25
39
|
method: "method",
|
|
40
|
+
params: "params",
|
|
26
41
|
result: "result",
|
|
27
42
|
error: "error",
|
|
28
43
|
message: "message",
|
|
@@ -60,24 +75,66 @@ class ExecCodexAppServer {
|
|
|
60
75
|
connecting = null;
|
|
61
76
|
nextId = 1;
|
|
62
77
|
stderr = "";
|
|
63
|
-
|
|
78
|
+
stdoutLines = new LineBuffer();
|
|
79
|
+
/** Set by close(); no child is spawned after it. */
|
|
80
|
+
closing = false;
|
|
81
|
+
/** Set once every stream has ended (the child exited, or close() found none). */
|
|
82
|
+
closed = false;
|
|
64
83
|
pending = new Map();
|
|
84
|
+
subscribers = new Set();
|
|
85
|
+
settleExit = () => { };
|
|
86
|
+
exit;
|
|
87
|
+
get stderrTail() {
|
|
88
|
+
return this.stderr;
|
|
89
|
+
}
|
|
65
90
|
constructor(options) {
|
|
66
91
|
this.options = options;
|
|
92
|
+
this.exit = new Promise((resolve) => {
|
|
93
|
+
this.settleExit = resolve;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
get incoming() {
|
|
97
|
+
return {
|
|
98
|
+
[Symbol.asyncIterator]: () => {
|
|
99
|
+
const queue = new AsyncQueue();
|
|
100
|
+
if (this.closed) {
|
|
101
|
+
queue.end();
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
this.subscribers.add(queue);
|
|
105
|
+
}
|
|
106
|
+
return queue[Symbol.asyncIterator]();
|
|
107
|
+
},
|
|
108
|
+
};
|
|
67
109
|
}
|
|
68
110
|
async request(method, params) {
|
|
69
111
|
await this.connect();
|
|
70
112
|
return this.sendRequest(method, params);
|
|
71
113
|
}
|
|
114
|
+
respond(id, answer) {
|
|
115
|
+
const process = this.process;
|
|
116
|
+
if (process === null) {
|
|
117
|
+
// A request that arrives while the server is closing has nobody left
|
|
118
|
+
// to answer; dropping it is the only honest option.
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
process.writeStdin(`${JSON.stringify({ id, ...answer })}${JSON_RPC_FRAME_SEPARATOR}`);
|
|
122
|
+
}
|
|
72
123
|
async close() {
|
|
124
|
+
this.closing = true;
|
|
73
125
|
const process = this.process;
|
|
74
126
|
this.process = null;
|
|
75
127
|
this.initialized = false;
|
|
76
|
-
if (process !== null) {
|
|
77
|
-
process.endStdin();
|
|
78
|
-
process.kill(PROCESS_SIGNAL.sigterm);
|
|
79
|
-
}
|
|
80
128
|
this.rejectAll(appServerClosedError());
|
|
129
|
+
if (process === null) {
|
|
130
|
+
this.finish({ code: null, signal: null });
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
// EOF is what makes the server exit cleanly — it removes the thread
|
|
134
|
+
// writer lock on the way out, which a SIGTERM-ed server leaves behind
|
|
135
|
+
// (T61 lab). Signals follow only for a server that does not exit on EOF.
|
|
136
|
+
await endProcessGracefully(process, this.options.clock);
|
|
137
|
+
await this.exit;
|
|
81
138
|
}
|
|
82
139
|
async connect() {
|
|
83
140
|
if (this.initialized) {
|
|
@@ -103,14 +160,13 @@ class ExecCodexAppServer {
|
|
|
103
160
|
this.initialized = true;
|
|
104
161
|
}
|
|
105
162
|
async startProcess() {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
});
|
|
163
|
+
if (this.closing) {
|
|
164
|
+
throw appServerClosedError();
|
|
165
|
+
}
|
|
166
|
+
const command = await resolveCommand(this.options.exec, this.options.command, this.options.env, null);
|
|
167
|
+
if (this.closing) {
|
|
168
|
+
// close() ran while PATH was being resolved: spawning now would orphan a child.
|
|
169
|
+
throw appServerClosedError();
|
|
114
170
|
}
|
|
115
171
|
const process = this.options.exec.spawn({
|
|
116
172
|
command,
|
|
@@ -124,6 +180,7 @@ class ExecCodexAppServer {
|
|
|
124
180
|
void this.readProcess(process);
|
|
125
181
|
}
|
|
126
182
|
async readProcess(process) {
|
|
183
|
+
let exit = { code: null, signal: null };
|
|
127
184
|
try {
|
|
128
185
|
for await (const chunk of process.chunks) {
|
|
129
186
|
if (chunk.channel === OUTPUT_CHANNEL.stderr) {
|
|
@@ -133,30 +190,54 @@ class ExecCodexAppServer {
|
|
|
133
190
|
this.handleStdout(chunk.text);
|
|
134
191
|
}
|
|
135
192
|
}
|
|
136
|
-
|
|
193
|
+
exit = await process.exit;
|
|
194
|
+
this.rejectAll(appServerExitedError(exit.code, this.stderr));
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
this.rejectAll(appServerExitedError(null, error instanceof Error ? error.message : ""));
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
137
200
|
if (this.process === process) {
|
|
138
201
|
this.process = null;
|
|
139
202
|
this.initialized = false;
|
|
140
203
|
}
|
|
141
|
-
|
|
142
|
-
this.rejectAll(appServerExitedError(exit.code, this.stderr));
|
|
143
|
-
}
|
|
204
|
+
this.finish(exit);
|
|
144
205
|
}
|
|
145
|
-
|
|
146
|
-
|
|
206
|
+
}
|
|
207
|
+
/** The child is gone (or was never started and we closed): end every stream once. */
|
|
208
|
+
finish(exit) {
|
|
209
|
+
if (this.closed) {
|
|
210
|
+
return;
|
|
147
211
|
}
|
|
212
|
+
this.closed = true;
|
|
213
|
+
for (const queue of this.subscribers) {
|
|
214
|
+
queue.end();
|
|
215
|
+
}
|
|
216
|
+
this.subscribers.clear();
|
|
217
|
+
this.settleExit(exit);
|
|
148
218
|
}
|
|
149
219
|
handleStdout(text) {
|
|
150
|
-
this.
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
220
|
+
for (const line of this.stdoutLines.push(text)) {
|
|
221
|
+
const record = readJsonRecord(line);
|
|
222
|
+
if (record === null) {
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
const incoming = parseIncoming(record);
|
|
226
|
+
if (incoming !== null) {
|
|
227
|
+
this.publish(incoming);
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
const response = parseResponse(record);
|
|
155
231
|
if (response !== null) {
|
|
156
232
|
this.handleResponse(response);
|
|
157
233
|
}
|
|
158
234
|
}
|
|
159
235
|
}
|
|
236
|
+
publish(incoming) {
|
|
237
|
+
for (const queue of this.subscribers) {
|
|
238
|
+
queue.push(incoming);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
160
241
|
sendRequest(method, params) {
|
|
161
242
|
const process = this.process;
|
|
162
243
|
if (process === null) {
|
|
@@ -165,14 +246,11 @@ class ExecCodexAppServer {
|
|
|
165
246
|
const id = this.nextId;
|
|
166
247
|
this.nextId += 1;
|
|
167
248
|
return new Promise((resolve, reject) => {
|
|
249
|
+
// A timeout fails only this request. JSON-RPC has no per-call
|
|
250
|
+
// cancellation, but a Session's other turns share this process, so the
|
|
251
|
+
// client never kills it on a slow answer; `close()` is the caller's call.
|
|
168
252
|
const cancelTimeout = this.options.clock.setTimeout(() => {
|
|
169
253
|
this.pending.delete(id);
|
|
170
|
-
// A timeout kills the whole server, not just this request: JSON-RPC
|
|
171
|
-
// gives no per-call cancellation, and a hung app-server cannot be
|
|
172
|
-
// trusted with further requests. Other in-flight requests are then
|
|
173
|
-
// rejected as `failed` by the exit path; clients are created per
|
|
174
|
-
// host-plane call, so the blast radius is that one call.
|
|
175
|
-
process.kill(PROCESS_SIGNAL.sigkill);
|
|
176
254
|
reject(new AgentError({
|
|
177
255
|
code: AGENT_ERROR_CODE.timeout,
|
|
178
256
|
classification: AgentError.agentFailure(AGENT_ERROR_CODE.timeout),
|
|
@@ -243,23 +321,29 @@ function resultDecoderFor(method) {
|
|
|
243
321
|
? null
|
|
244
322
|
: CODEX_APP_SERVER_RESULT_DECODERS[method];
|
|
245
323
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (record === null) {
|
|
324
|
+
/**
|
|
325
|
+
* Server-originated frames carry `method`; a response never does. Their id
|
|
326
|
+
* space is the server's own, so an id on such a frame marks a request the
|
|
327
|
+
* server awaits an answer to, not one of our pending requests.
|
|
328
|
+
*/
|
|
329
|
+
function parseIncoming(record) {
|
|
330
|
+
const method = record[JSON_RPC_FIELD.method];
|
|
331
|
+
if (typeof method !== "string") {
|
|
255
332
|
return null;
|
|
256
333
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
334
|
+
const paramsValue = record[JSON_RPC_FIELD.params];
|
|
335
|
+
const params = typeof paramsValue === "object" &&
|
|
336
|
+
paramsValue !== null &&
|
|
337
|
+
!Array.isArray(paramsValue)
|
|
338
|
+
? paramsValue
|
|
339
|
+
: null;
|
|
340
|
+
const id = record[JSON_RPC_FIELD.id];
|
|
341
|
+
if (typeof id === "number" || typeof id === "string") {
|
|
342
|
+
return { kind: CODEX_INCOMING_KIND.request, id, method, params };
|
|
262
343
|
}
|
|
344
|
+
return { kind: CODEX_INCOMING_KIND.notification, method, params };
|
|
345
|
+
}
|
|
346
|
+
function parseResponse(record) {
|
|
263
347
|
const id = record[JSON_RPC_FIELD.id];
|
|
264
348
|
if (typeof id !== "number") {
|
|
265
349
|
return null;
|
|
@@ -285,37 +369,27 @@ function appServerResponseError(method, error) {
|
|
|
285
369
|
code: AGENT_ERROR_CODE.failed,
|
|
286
370
|
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
287
371
|
message: detail === "" ? `Codex app-server request failed: ${method}` : detail,
|
|
288
|
-
data: {
|
|
289
|
-
exitCode: null,
|
|
290
|
-
stdoutTail: null,
|
|
291
|
-
stderrTail: detail === "" ? null : detail.slice(-OUTPUT_TAIL_CHARS),
|
|
292
|
-
},
|
|
372
|
+
data: failureEvidence({ stdout: "", stderr: detail, exitCode: null }),
|
|
293
373
|
});
|
|
294
374
|
}
|
|
295
375
|
function appServerMalformedResultError(method, result) {
|
|
296
|
-
const detail = redactSecrets(JSON.stringify(result) ?? "");
|
|
297
376
|
return new AgentError({
|
|
298
377
|
code: AGENT_ERROR_CODE.failed,
|
|
299
378
|
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
300
379
|
message: `Codex app-server returned a malformed result: ${method}`,
|
|
301
|
-
data: {
|
|
380
|
+
data: failureEvidence({
|
|
381
|
+
stdout: JSON.stringify(result) ?? "",
|
|
382
|
+
stderr: "",
|
|
302
383
|
exitCode: null,
|
|
303
|
-
|
|
304
|
-
stderrTail: null,
|
|
305
|
-
},
|
|
384
|
+
}),
|
|
306
385
|
});
|
|
307
386
|
}
|
|
308
387
|
function appServerExitedError(exitCode, stderr) {
|
|
309
|
-
const stderrTail = redactSecrets(stderr.slice(-OUTPUT_TAIL_CHARS));
|
|
310
388
|
return new AgentError({
|
|
311
389
|
code: AGENT_ERROR_CODE.failed,
|
|
312
390
|
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
313
391
|
message: "Codex app-server exited before completing the request",
|
|
314
|
-
data: {
|
|
315
|
-
exitCode,
|
|
316
|
-
stdoutTail: null,
|
|
317
|
-
stderrTail: stderrTail === "" ? null : stderrTail,
|
|
318
|
-
},
|
|
392
|
+
data: failureEvidence({ stdout: "", stderr, exitCode }),
|
|
319
393
|
});
|
|
320
394
|
}
|
|
321
395
|
function appServerClosedError() {
|
|
@@ -323,6 +397,6 @@ function appServerClosedError() {
|
|
|
323
397
|
code: AGENT_ERROR_CODE.failed,
|
|
324
398
|
classification: AgentError.agentFailure(AGENT_ERROR_CODE.failed),
|
|
325
399
|
message: "Codex app-server connection closed",
|
|
326
|
-
data:
|
|
400
|
+
data: NO_FAILURE_EVIDENCE,
|
|
327
401
|
});
|
|
328
402
|
}
|
package/dist/codex/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { type AppServerClientInfo, type CodexAppServer, type CodexAppServerOptions, createCodexAppServer, listAllCodexMcpServerStatuses, withCodexAppServer, } from "./app-server.js";
|
|
2
|
-
export type { CodexAppServerMethods, CodexMcpServerStatus, CodexMcpServerStatusPage, CodexPluginInstallResult, CodexPluginListResult, CodexPluginMarketplace, CodexPluginSummary, CodexSkillListResult, } from "./protocol.js";
|
|
1
|
+
export { type AppServerClientInfo, CODEX_INCOMING_KIND, type CodexAppServer, type CodexAppServerOptions, type CodexIncoming, type CodexServerRequestAnswer, type CodexServerRequestId, createCodexAppServer, listAllCodexMcpServerStatuses, withCodexAppServer, } from "./app-server.js";
|
|
2
|
+
export type { CodexAppServerMethods, CodexConfigOverrides, CodexMcpServerStatus, CodexMcpServerStatusPage, CodexPluginInstallResult, CodexPluginListResult, CodexPluginMarketplace, CodexPluginSummary, CodexSandboxMode, CodexSkillListResult, CodexThreadPermissionParams, CodexThreadPermissionWireParams, CodexThreadRef, CodexTurnRef, CodexUserInput, CodexWorkspaceWriteConfig, } from "./protocol.js";
|
|
3
|
+
export { CODEX_APP_SERVER_INCOMING, CODEX_APP_SERVER_METHOD, CODEX_SANDBOX_MODE, encodeCodexThreadPermissions, } from "./protocol.js";
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codex/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,oBAAoB,EACpB,6BAA6B,EAC7B,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codex/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,mBAAmB,EACxB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,oBAAoB,EACpB,6BAA6B,EAC7B,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,oBAAoB,EACpB,2BAA2B,EAC3B,+BAA+B,EAC/B,cAAc,EACd,YAAY,EACZ,cAAc,EACd,yBAAyB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,kBAAkB,EAClB,4BAA4B,GAC7B,MAAM,eAAe,CAAC"}
|
package/dist/codex/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { createCodexAppServer, listAllCodexMcpServerStatuses, withCodexAppServer, } from "./app-server.js";
|
|
1
|
+
export { CODEX_INCOMING_KIND, createCodexAppServer, listAllCodexMcpServerStatuses, withCodexAppServer, } from "./app-server.js";
|
|
2
|
+
export { CODEX_APP_SERVER_INCOMING, CODEX_APP_SERVER_METHOD, CODEX_SANDBOX_MODE, encodeCodexThreadPermissions, } from "./protocol.js";
|
package/dist/codex/protocol.d.ts
CHANGED
|
@@ -15,6 +15,65 @@ export declare const CODEX_APP_SERVER_METHOD: {
|
|
|
15
15
|
readonly pluginInstall: "plugin/install";
|
|
16
16
|
readonly skillsList: "skills/list";
|
|
17
17
|
readonly mcpServerStatusList: "mcpServerStatus/list";
|
|
18
|
+
readonly threadStart: "thread/start";
|
|
19
|
+
readonly threadResume: "thread/resume";
|
|
20
|
+
readonly threadUnarchive: "thread/unarchive";
|
|
21
|
+
readonly turnStart: "turn/start";
|
|
22
|
+
readonly turnSteer: "turn/steer";
|
|
23
|
+
readonly turnInterrupt: "turn/interrupt";
|
|
24
|
+
};
|
|
25
|
+
/** Notifications and server-initiated requests the session adapter reads. */
|
|
26
|
+
export declare const CODEX_APP_SERVER_INCOMING: {
|
|
27
|
+
readonly itemStarted: "item/started";
|
|
28
|
+
readonly itemCompleted: "item/completed";
|
|
29
|
+
readonly turnCompleted: "turn/completed";
|
|
30
|
+
readonly commandExecutionRequestApproval: "item/commandExecution/requestApproval";
|
|
31
|
+
readonly fileChangeRequestApproval: "item/fileChange/requestApproval";
|
|
32
|
+
};
|
|
33
|
+
/** `thread/start` / `thread/resume` sandbox words (codex 0.153.4 `SandboxMode`). */
|
|
34
|
+
export declare const CODEX_SANDBOX_MODE: {
|
|
35
|
+
readonly readOnly: "read-only";
|
|
36
|
+
readonly workspaceWrite: "workspace-write";
|
|
37
|
+
readonly dangerFullAccess: "danger-full-access";
|
|
38
|
+
};
|
|
39
|
+
export type CodexSandboxMode = (typeof CODEX_SANDBOX_MODE)[keyof typeof CODEX_SANDBOX_MODE];
|
|
40
|
+
/**
|
|
41
|
+
* `workspace-write` details travel as config.toml overrides on
|
|
42
|
+
* `thread/start` / `thread/resume` (`config`), the same keys
|
|
43
|
+
* `codex -c sandbox_workspace_write.*` takes.
|
|
44
|
+
*/
|
|
45
|
+
export type CodexWorkspaceWriteConfig = {
|
|
46
|
+
readonly writableRoots: readonly string[];
|
|
47
|
+
readonly networkAccess: boolean;
|
|
48
|
+
readonly excludeTmpdirEnvVar: boolean;
|
|
49
|
+
readonly excludeSlashTmp: boolean;
|
|
50
|
+
};
|
|
51
|
+
export type CodexThreadPermissionParams = {
|
|
52
|
+
readonly sandbox: CodexSandboxMode;
|
|
53
|
+
readonly approvalPolicy: string;
|
|
54
|
+
readonly approvalsReviewer: string;
|
|
55
|
+
readonly workspaceWrite: CodexWorkspaceWriteConfig | null;
|
|
56
|
+
};
|
|
57
|
+
type CodexConfigScalar = boolean | string | readonly string[];
|
|
58
|
+
/** A `config.toml` override object as `thread/start` / `thread/resume` take it. */
|
|
59
|
+
export type CodexConfigOverrides = Readonly<Record<string, Readonly<Record<string, CodexConfigScalar>>>>;
|
|
60
|
+
/** The wire shape of the permission params (`config` carries workspace-write). */
|
|
61
|
+
export type CodexThreadPermissionWireParams = {
|
|
62
|
+
readonly sandbox: CodexSandboxMode;
|
|
63
|
+
readonly approvalPolicy: string;
|
|
64
|
+
readonly approvalsReviewer: string;
|
|
65
|
+
readonly config: CodexConfigOverrides | null;
|
|
66
|
+
};
|
|
67
|
+
export declare function encodeCodexThreadPermissions(input: CodexThreadPermissionParams): CodexThreadPermissionWireParams;
|
|
68
|
+
export type CodexThreadRef = {
|
|
69
|
+
readonly threadId: string;
|
|
70
|
+
};
|
|
71
|
+
export type CodexTurnRef = {
|
|
72
|
+
readonly turnId: string;
|
|
73
|
+
};
|
|
74
|
+
export type CodexUserInput = {
|
|
75
|
+
readonly type: "text";
|
|
76
|
+
readonly text: string;
|
|
18
77
|
};
|
|
19
78
|
export declare const CODEX_MCP_STATUS_DETAIL: {
|
|
20
79
|
readonly toolsAndAuthOnly: "toolsAndAuthOnly";
|
|
@@ -116,9 +175,51 @@ export type CodexAppServerMethods = {
|
|
|
116
175
|
};
|
|
117
176
|
readonly result: CodexMcpServerStatusPage;
|
|
118
177
|
};
|
|
178
|
+
[CODEX_APP_SERVER_METHOD.threadStart]: {
|
|
179
|
+
readonly params: {
|
|
180
|
+
readonly cwd: string;
|
|
181
|
+
} & CodexThreadPermissionWireParams;
|
|
182
|
+
readonly result: CodexThreadRef;
|
|
183
|
+
};
|
|
184
|
+
[CODEX_APP_SERVER_METHOD.threadResume]: {
|
|
185
|
+
readonly params: {
|
|
186
|
+
readonly threadId: string;
|
|
187
|
+
readonly excludeTurns: boolean;
|
|
188
|
+
} & CodexThreadPermissionWireParams;
|
|
189
|
+
readonly result: CodexThreadRef;
|
|
190
|
+
};
|
|
191
|
+
[CODEX_APP_SERVER_METHOD.threadUnarchive]: {
|
|
192
|
+
readonly params: {
|
|
193
|
+
readonly threadId: string;
|
|
194
|
+
};
|
|
195
|
+
readonly result: CodexThreadRef;
|
|
196
|
+
};
|
|
197
|
+
[CODEX_APP_SERVER_METHOD.turnStart]: {
|
|
198
|
+
readonly params: {
|
|
199
|
+
readonly threadId: string;
|
|
200
|
+
readonly input: readonly CodexUserInput[];
|
|
201
|
+
};
|
|
202
|
+
readonly result: CodexTurnRef;
|
|
203
|
+
};
|
|
204
|
+
[CODEX_APP_SERVER_METHOD.turnSteer]: {
|
|
205
|
+
readonly params: {
|
|
206
|
+
readonly threadId: string;
|
|
207
|
+
readonly expectedTurnId: string;
|
|
208
|
+
readonly input: readonly CodexUserInput[];
|
|
209
|
+
};
|
|
210
|
+
readonly result: CodexTurnRef;
|
|
211
|
+
};
|
|
212
|
+
[CODEX_APP_SERVER_METHOD.turnInterrupt]: {
|
|
213
|
+
readonly params: {
|
|
214
|
+
readonly threadId: string;
|
|
215
|
+
readonly turnId: string;
|
|
216
|
+
};
|
|
217
|
+
readonly result: Readonly<Record<string, never>>;
|
|
218
|
+
};
|
|
119
219
|
};
|
|
120
220
|
export type CodexAppServerResultDecoder<M extends keyof CodexAppServerMethods> = (value: unknown) => CodexAppServerMethods[M]["result"] | null;
|
|
121
221
|
export declare const CODEX_APP_SERVER_RESULT_DECODERS: {
|
|
122
222
|
readonly [M in keyof CodexAppServerMethods]: CodexAppServerResultDecoder<M>;
|
|
123
223
|
};
|
|
224
|
+
export {};
|
|
124
225
|
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/codex/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/codex/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;CAa1B,CAAC;AAEX,6EAA6E;AAC7E,eAAO,MAAM,yBAAyB;;;;;;CAM5B,CAAC;AAEX,oFAAoF;AACpF,eAAO,MAAM,kBAAkB;;;;CAIrB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAC1B,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,yBAAyB,GAAG,IAAI,CAAC;CAC3D,CAAC;AAEF,KAAK,iBAAiB,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;AAC9D,mFAAmF;AACnF,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CACzC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAC5D,CAAC;AAEF,kFAAkF;AAClF,MAAM,MAAM,+BA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,CAAC;CAY5E,CAAC"}
|
package/dist/codex/protocol.js
CHANGED
|
@@ -16,7 +16,53 @@ export const CODEX_APP_SERVER_METHOD = {
|
|
|
16
16
|
pluginInstall: "plugin/install",
|
|
17
17
|
skillsList: "skills/list",
|
|
18
18
|
mcpServerStatusList: "mcpServerStatus/list",
|
|
19
|
+
threadStart: "thread/start",
|
|
20
|
+
threadResume: "thread/resume",
|
|
21
|
+
threadUnarchive: "thread/unarchive",
|
|
22
|
+
turnStart: "turn/start",
|
|
23
|
+
turnSteer: "turn/steer",
|
|
24
|
+
turnInterrupt: "turn/interrupt",
|
|
19
25
|
};
|
|
26
|
+
/** Notifications and server-initiated requests the session adapter reads. */
|
|
27
|
+
export const CODEX_APP_SERVER_INCOMING = {
|
|
28
|
+
itemStarted: "item/started",
|
|
29
|
+
itemCompleted: "item/completed",
|
|
30
|
+
turnCompleted: "turn/completed",
|
|
31
|
+
commandExecutionRequestApproval: "item/commandExecution/requestApproval",
|
|
32
|
+
fileChangeRequestApproval: "item/fileChange/requestApproval",
|
|
33
|
+
};
|
|
34
|
+
/** `thread/start` / `thread/resume` sandbox words (codex 0.153.4 `SandboxMode`). */
|
|
35
|
+
export const CODEX_SANDBOX_MODE = {
|
|
36
|
+
readOnly: "read-only",
|
|
37
|
+
workspaceWrite: "workspace-write",
|
|
38
|
+
dangerFullAccess: "danger-full-access",
|
|
39
|
+
};
|
|
40
|
+
/** config.toml keys, spelled once (`codex -c sandbox_workspace_write.writable_roots=…`). */
|
|
41
|
+
const CODEX_CONFIG_KEY = {
|
|
42
|
+
sandboxWorkspaceWrite: "sandbox_workspace_write",
|
|
43
|
+
writableRoots: "writable_roots",
|
|
44
|
+
networkAccess: "network_access",
|
|
45
|
+
excludeTmpdirEnvVar: "exclude_tmpdir_env_var",
|
|
46
|
+
excludeSlashTmp: "exclude_slash_tmp",
|
|
47
|
+
};
|
|
48
|
+
export function encodeCodexThreadPermissions(input) {
|
|
49
|
+
const workspaceWrite = input.workspaceWrite;
|
|
50
|
+
return {
|
|
51
|
+
sandbox: input.sandbox,
|
|
52
|
+
approvalPolicy: input.approvalPolicy,
|
|
53
|
+
approvalsReviewer: input.approvalsReviewer,
|
|
54
|
+
config: workspaceWrite === null
|
|
55
|
+
? null
|
|
56
|
+
: {
|
|
57
|
+
[CODEX_CONFIG_KEY.sandboxWorkspaceWrite]: {
|
|
58
|
+
[CODEX_CONFIG_KEY.writableRoots]: workspaceWrite.writableRoots,
|
|
59
|
+
[CODEX_CONFIG_KEY.networkAccess]: workspaceWrite.networkAccess,
|
|
60
|
+
[CODEX_CONFIG_KEY.excludeTmpdirEnvVar]: workspaceWrite.excludeTmpdirEnvVar,
|
|
61
|
+
[CODEX_CONFIG_KEY.excludeSlashTmp]: workspaceWrite.excludeSlashTmp,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
20
66
|
export const CODEX_MCP_STATUS_DETAIL = {
|
|
21
67
|
toolsAndAuthOnly: "toolsAndAuthOnly",
|
|
22
68
|
};
|
|
@@ -50,14 +96,46 @@ const RESULT_FIELD = {
|
|
|
50
96
|
shortDescription: "shortDescription",
|
|
51
97
|
skills: "skills",
|
|
52
98
|
status: "status",
|
|
99
|
+
thread: "thread",
|
|
53
100
|
tools: "tools",
|
|
101
|
+
turn: "turn",
|
|
102
|
+
turnId: "turnId",
|
|
54
103
|
};
|
|
55
104
|
export const CODEX_APP_SERVER_RESULT_DECODERS = {
|
|
56
105
|
[CODEX_APP_SERVER_METHOD.pluginList]: decodePluginListResult,
|
|
57
106
|
[CODEX_APP_SERVER_METHOD.pluginInstall]: decodePluginInstallResult,
|
|
58
107
|
[CODEX_APP_SERVER_METHOD.skillsList]: decodeSkillListResult,
|
|
59
108
|
[CODEX_APP_SERVER_METHOD.mcpServerStatusList]: decodeMcpServerStatusPage,
|
|
109
|
+
[CODEX_APP_SERVER_METHOD.threadStart]: decodeThreadRef,
|
|
110
|
+
[CODEX_APP_SERVER_METHOD.threadResume]: decodeThreadRef,
|
|
111
|
+
[CODEX_APP_SERVER_METHOD.threadUnarchive]: decodeThreadRef,
|
|
112
|
+
[CODEX_APP_SERVER_METHOD.turnStart]: decodeTurnRefFromTurn,
|
|
113
|
+
[CODEX_APP_SERVER_METHOD.turnSteer]: decodeTurnRef,
|
|
114
|
+
[CODEX_APP_SERVER_METHOD.turnInterrupt]: decodeEmptyResult,
|
|
60
115
|
};
|
|
116
|
+
/** `{thread: {id}}` — the rest of the thread object is not modeled here. */
|
|
117
|
+
function decodeThreadRef(value) {
|
|
118
|
+
const record = readUnknownRecord(value);
|
|
119
|
+
const thread = record === null ? null : readUnknownRecord(record[RESULT_FIELD.thread]);
|
|
120
|
+
const threadId = thread === null ? null : readString(thread, RESULT_FIELD.id);
|
|
121
|
+
return threadId === null ? null : { threadId };
|
|
122
|
+
}
|
|
123
|
+
/** `turn/start` answers `{turn: {id, status, …}}`. */
|
|
124
|
+
function decodeTurnRefFromTurn(value) {
|
|
125
|
+
const record = readUnknownRecord(value);
|
|
126
|
+
const turn = record === null ? null : readUnknownRecord(record[RESULT_FIELD.turn]);
|
|
127
|
+
const turnId = turn === null ? null : readString(turn, RESULT_FIELD.id);
|
|
128
|
+
return turnId === null ? null : { turnId };
|
|
129
|
+
}
|
|
130
|
+
/** `turn/steer` answers `{turnId}`. */
|
|
131
|
+
function decodeTurnRef(value) {
|
|
132
|
+
const record = readUnknownRecord(value);
|
|
133
|
+
const turnId = record === null ? null : readString(record, RESULT_FIELD.turnId);
|
|
134
|
+
return turnId === null ? null : { turnId };
|
|
135
|
+
}
|
|
136
|
+
function decodeEmptyResult(value) {
|
|
137
|
+
return readUnknownRecord(value) === null ? null : {};
|
|
138
|
+
}
|
|
61
139
|
function decodeItems(values, decodeItem) {
|
|
62
140
|
const items = [];
|
|
63
141
|
for (const value of values) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type JsonObject } from "@alpacakit/core";
|
|
2
2
|
import type { AgentConfigKind } from "./ids.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { AgentConfig, AgentConfigType, AgentConfigTypeRegistry } from "./model.js";
|
|
4
4
|
export declare const AGENT_CONFIG_VALIDATION_RESULT: {
|
|
5
5
|
readonly valid: "valid";
|
|
6
6
|
readonly unknownKind: "unknown_kind";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-config-validation.d.ts","sourceRoot":"","sources":["../../src/config/agent-config-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EACV,eAAe,EACf,
|
|
1
|
+
{"version":3,"file":"agent-config-validation.d.ts","sourceRoot":"","sources":["../../src/config/agent-config-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,8BAA8B;;;;CAIjC,CAAC;AAEX,MAAM,MAAM,2BAA2B,GACnC;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,8BAA8B,CAAC,KAAK,CAAC;IAC3D,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC,eAAe,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;IAC1E,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;CAC3D,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,8BAA8B,CAAC,WAAW,CAAC;IACjE,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;CAC3C,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,8BAA8B,CAAC,cAAc,CAAC;IACpE,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC,CAAC;AAEN,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,CAAC,eAAe,EAAE,UAAU,CAAC,EAChD,gBAAgB,EAAE,uBAAuB,GACxC,2BAA2B,CA0B7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-configs.d.ts","sourceRoot":"","sources":["../../src/config/agent-configs.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EACV,WAAW,
|
|
1
|
+
{"version":3,"file":"agent-configs.d.ts","sourceRoot":"","sources":["../../src/config/agent-configs.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,KAAK,eAAe,EAAiB,MAAM,UAAU,CAAC;AAC/D,OAAO,KAAK,EACV,WAAW,EAGX,eAAe,EACf,uBAAuB,EAGxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,iBAAiB,EAKjB,KAAK,0BAA0B,EAChC,MAAM,aAAa,CAAC;AAQrB,KAAK,yBAAyB,GAAG;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC;AAOF,KAAK,kCAAkC,GAAG;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC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uB,CAoB9E;AAED,wBAAgB,qBAAqB,CACnC,IAAI,SAAS,eAAe,EAC5B,OAAO,SAAS,UAAU,EAC1B,OAAO,SAAS,MAAM,EAEtB,UAAU,EAAE,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,GAClD,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAEzC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { createKeyedRegistry, createSchemaRuntimeCodec, jsonValueSchema, } from "@alpacakit/core";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { claude } from "../agents/claude.js";
|
|
5
|
-
import { codex } from "../agents/codex.js";
|
|
6
|
-
import { openaiCompatible } from "../agents/openai-compatible.js";
|
|
4
|
+
import { claude } from "../agents/claude/index.js";
|
|
5
|
+
import { codex } from "../agents/codex/index.js";
|
|
7
6
|
import { piSessionEngine } from "../agents/openai-compatible/pi/engine.js";
|
|
7
|
+
import { openaiCompatible } from "../agents/openai-compatible.js";
|
|
8
8
|
import { agentConfigId } from "./ids.js";
|
|
9
9
|
import { formatFieldPath, ZOD_ISSUE_CODE } from "./support.js";
|
|
10
10
|
import { AGENT_CONFIG_KIND, AGENTS_CONFIG_DIRECTORY, BUILTIN_AGENT_ID, CANDIDATE_SOURCE_KIND, OPENAI_COMPATIBLE_ENGINE, } from "./values.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/config/compose.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"compose.d.ts","sourceRoot":"","sources":["../../src/config/compose.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EAEnB,UAAU,EACV,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAwBpB,KAAK,iCAAiC,GAAG;IACvC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,eAAe,EAAE,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IACjE,QAAQ,CAAC,gBAAgB,EAAE,uBAAuB,CAAC;IACnD,QAAQ,CAAC,eAAe,EAAE,SAAS,mBAAmB,EAAE,CAAC;CAC1D,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,iCAAiC,GACvC,mBAAmB,CA4CrB"}
|
package/dist/config/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SecretResolvers } from "../core/ports.js";
|
|
2
2
|
import type { Candidate } from "../fleet/fleet.js";
|
|
3
3
|
import type { FleetStateStore } from "../fleet/store.js";
|
|
4
|
-
import type { AgentConfigTypeRegistry,
|
|
4
|
+
import type { AgentConfigManager, AgentConfigTypeRegistry, AgentsConfigPaths, AgentsRuntimeConfig, NamedSecretResolver, ProfileManager } from "./model.js";
|
|
5
5
|
export type OpenAgentsConfigOptions = {
|
|
6
6
|
readonly rootDir: string;
|
|
7
7
|
readonly agentConfigTypes?: AgentConfigTypeRegistry;
|