@moxt-ai/mobius 0.0.130 → 0.0.131
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/acp/codex/agent.d.ts.map +1 -1
- package/dist/acp/codex/agent.js +26 -403
- package/dist/acp/codex/agent.js.map +1 -1
- package/dist/acp/codex/settings.d.ts +36 -0
- package/dist/acp/codex/settings.d.ts.map +1 -0
- package/dist/acp/codex/settings.js +388 -0
- package/dist/acp/codex/settings.js.map +1 -0
- package/dist/cli.js +380 -353
- package/dist/cli.js.map +4 -4
- package/dist/daemon-turn-registry.d.ts +13 -13
- package/dist/index.js +379 -352
- package/dist/index.js.map +4 -4
- package/dist/runtime.js +379 -352
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3381,7 +3381,7 @@ var program = new Command();
|
|
|
3381
3381
|
// package.json
|
|
3382
3382
|
var package_default = {
|
|
3383
3383
|
name: "@moxt-ai/mobius",
|
|
3384
|
-
version: "0.0.
|
|
3384
|
+
version: "0.0.131",
|
|
3385
3385
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
3386
3386
|
type: "module",
|
|
3387
3387
|
bin: {
|
|
@@ -25105,11 +25105,8 @@ function agentMessageMeta(phase) {
|
|
|
25105
25105
|
return { [CODEX_META_KEY]: { phase } };
|
|
25106
25106
|
}
|
|
25107
25107
|
|
|
25108
|
-
// src/acp/codex/
|
|
25109
|
-
var APPROVAL_REASON_CHARACTER_LIMIT = 500;
|
|
25108
|
+
// src/acp/codex/settings.ts
|
|
25110
25109
|
var APPROVAL_TIMEOUT_MILLISECONDS = 36e5;
|
|
25111
|
-
var CODEX_AGENT_VERSION = "0.154.0";
|
|
25112
|
-
var SESSION_LIST_TIMEOUT_MILLISECONDS = 3e4;
|
|
25113
25110
|
var MODEL_SETTING_ID = "model";
|
|
25114
25111
|
var REASONING_EFFORT_SETTING_ID = "reasoning_effort";
|
|
25115
25112
|
var MODE_SETTING_ID = "mode";
|
|
@@ -25118,7 +25115,6 @@ var COLLABORATION_MODE_SETTING_ID = "collaboration_mode";
|
|
|
25118
25115
|
var MODEL_CATALOG_LIMIT = 1e3;
|
|
25119
25116
|
var FAST_TIER = "fast";
|
|
25120
25117
|
var SERVICE_TIER_FAST = "priority";
|
|
25121
|
-
var CODEX_COMMANDS = Object.freeze([{ description: "Compact the conversation context", name: "compact" }]);
|
|
25122
25118
|
var WORKSPACE_WRITE_POLICY = Object.freeze({
|
|
25123
25119
|
excludeSlashTmp: false,
|
|
25124
25120
|
excludeTmpdirEnvVar: false,
|
|
@@ -25162,94 +25158,6 @@ function initialMode(environment) {
|
|
|
25162
25158
|
function capitalize(value) {
|
|
25163
25159
|
return value.length === 0 ? value : value.charAt(0).toUpperCase() + value.slice(1);
|
|
25164
25160
|
}
|
|
25165
|
-
var APPROVAL_OPTIONS = Object.freeze([
|
|
25166
|
-
{ kind: "allow_once", name: "Allow once", optionId: "accept" },
|
|
25167
|
-
{ kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
|
|
25168
|
-
{ kind: "reject_once", name: "Deny", optionId: "decline" }
|
|
25169
|
-
]);
|
|
25170
|
-
function permissionDecision(optionId) {
|
|
25171
|
-
if (optionId === "accept" || optionId === "acceptForSession" || optionId === "decline") {
|
|
25172
|
-
return optionId;
|
|
25173
|
-
}
|
|
25174
|
-
return "cancel";
|
|
25175
|
-
}
|
|
25176
|
-
function promptInput(prompt) {
|
|
25177
|
-
const input2 = [];
|
|
25178
|
-
for (const block of prompt) {
|
|
25179
|
-
if (block.type === "text") {
|
|
25180
|
-
input2.push({ text: block.text, text_elements: [], type: "text" });
|
|
25181
|
-
continue;
|
|
25182
|
-
}
|
|
25183
|
-
if (block.type === "image") {
|
|
25184
|
-
input2.push({ type: "image", url: `data:${block.mimeType};base64,${block.data}` });
|
|
25185
|
-
continue;
|
|
25186
|
-
}
|
|
25187
|
-
if (block.type === "resource") {
|
|
25188
|
-
const resource = block.resource;
|
|
25189
|
-
input2.push({
|
|
25190
|
-
text: "text" in resource ? resource.text ?? "" : "",
|
|
25191
|
-
text_elements: [],
|
|
25192
|
-
type: "text"
|
|
25193
|
-
});
|
|
25194
|
-
continue;
|
|
25195
|
-
}
|
|
25196
|
-
if (block.type === "resource_link") {
|
|
25197
|
-
input2.push({ text: `Resource: ${block.uri}`, text_elements: [], type: "text" });
|
|
25198
|
-
}
|
|
25199
|
-
}
|
|
25200
|
-
return input2;
|
|
25201
|
-
}
|
|
25202
|
-
function isCompactPrompt(prompt) {
|
|
25203
|
-
return prompt.length === 1 && prompt[0]?.type === "text" && prompt[0].text.trim() === "/compact";
|
|
25204
|
-
}
|
|
25205
|
-
function steeringPromptInput(prompt) {
|
|
25206
|
-
const input2 = [];
|
|
25207
|
-
for (const block of prompt) {
|
|
25208
|
-
if (typeof block !== "object" || block === null) {
|
|
25209
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25210
|
-
}
|
|
25211
|
-
const type = Reflect.get(block, "type");
|
|
25212
|
-
if (type === "text") {
|
|
25213
|
-
const text2 = Reflect.get(block, "text");
|
|
25214
|
-
if (typeof text2 !== "string") {
|
|
25215
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25216
|
-
}
|
|
25217
|
-
input2.push({ text: text2, text_elements: [], type: "text" });
|
|
25218
|
-
continue;
|
|
25219
|
-
}
|
|
25220
|
-
if (type === "image") {
|
|
25221
|
-
const data = Reflect.get(block, "data");
|
|
25222
|
-
const mimeType = Reflect.get(block, "mimeType");
|
|
25223
|
-
if (typeof data !== "string" || typeof mimeType !== "string") {
|
|
25224
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25225
|
-
}
|
|
25226
|
-
input2.push({ type: "image", url: `data:${mimeType};base64,${data}` });
|
|
25227
|
-
continue;
|
|
25228
|
-
}
|
|
25229
|
-
if (type === "resource") {
|
|
25230
|
-
const resource = Reflect.get(block, "resource");
|
|
25231
|
-
if (typeof resource !== "object" || resource === null) {
|
|
25232
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25233
|
-
}
|
|
25234
|
-
const text2 = Reflect.get(resource, "text");
|
|
25235
|
-
if (text2 !== void 0 && typeof text2 !== "string") {
|
|
25236
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25237
|
-
}
|
|
25238
|
-
input2.push({ text: text2 ?? "", text_elements: [], type: "text" });
|
|
25239
|
-
continue;
|
|
25240
|
-
}
|
|
25241
|
-
if (type === "resource_link") {
|
|
25242
|
-
const uri = Reflect.get(block, "uri");
|
|
25243
|
-
if (typeof uri !== "string") {
|
|
25244
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25245
|
-
}
|
|
25246
|
-
input2.push({ text: `Resource: ${uri}`, text_elements: [], type: "text" });
|
|
25247
|
-
continue;
|
|
25248
|
-
}
|
|
25249
|
-
throw new AcpExecutionError("Codex received an unsupported steering prompt", {}, "invalid_request");
|
|
25250
|
-
}
|
|
25251
|
-
return input2;
|
|
25252
|
-
}
|
|
25253
25161
|
function modelValues(models) {
|
|
25254
25162
|
return models.map((model) => ({
|
|
25255
25163
|
description: model.description ?? "",
|
|
@@ -25340,19 +25248,352 @@ function effortSetting(model, currentValue) {
|
|
|
25340
25248
|
if (values.length === 0) {
|
|
25341
25249
|
return null;
|
|
25342
25250
|
}
|
|
25343
|
-
const current = values.some((value) => value.value === currentValue) ? currentValue : values[0]?.value ?? "";
|
|
25344
|
-
if (current.length === 0) {
|
|
25345
|
-
return null;
|
|
25251
|
+
const current = values.some((value) => value.value === currentValue) ? currentValue : values[0]?.value ?? "";
|
|
25252
|
+
if (current.length === 0) {
|
|
25253
|
+
return null;
|
|
25254
|
+
}
|
|
25255
|
+
return {
|
|
25256
|
+
category: "thought_level",
|
|
25257
|
+
currentValue: current,
|
|
25258
|
+
description: "How much reasoning effort the model should use",
|
|
25259
|
+
id: REASONING_EFFORT_SETTING_ID,
|
|
25260
|
+
name: "Reasoning effort",
|
|
25261
|
+
options: values,
|
|
25262
|
+
type: "select"
|
|
25263
|
+
};
|
|
25264
|
+
}
|
|
25265
|
+
var CodexSettings = class {
|
|
25266
|
+
#appServer;
|
|
25267
|
+
#models = [];
|
|
25268
|
+
// Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
|
|
25269
|
+
// configuration decides, so `turn/start` omits the fields and inherits what the host set up.
|
|
25270
|
+
#policySelected = false;
|
|
25271
|
+
// Whether a collaboration mode choice has been made in this session. A restored thread keeps
|
|
25272
|
+
// the mode Codex already persisted, so the first turn does not reset it to Build.
|
|
25273
|
+
#collaborationModeSelected = false;
|
|
25274
|
+
// Whether the app-server accepts collaboration mode on `turn/start`, probed once per
|
|
25275
|
+
// app-server. An older Codex rejects the experimental field, and the setting must disappear
|
|
25276
|
+
// rather than break every turn.
|
|
25277
|
+
#collaborationModeSupported = null;
|
|
25278
|
+
#selection;
|
|
25279
|
+
constructor(appServer, environment) {
|
|
25280
|
+
this.#appServer = appServer;
|
|
25281
|
+
this.#selection = {
|
|
25282
|
+
collaborationMode: "default",
|
|
25283
|
+
effort: "",
|
|
25284
|
+
fastMode: false,
|
|
25285
|
+
mode: initialMode(environment),
|
|
25286
|
+
model: ""
|
|
25287
|
+
};
|
|
25288
|
+
}
|
|
25289
|
+
selectNewThread = (created) => {
|
|
25290
|
+
const supported = supportedSelection(this.#models, created.model ?? "", created.reasoningEffort ?? "");
|
|
25291
|
+
this.#selection = {
|
|
25292
|
+
...this.#selection,
|
|
25293
|
+
collaborationMode: "default",
|
|
25294
|
+
...supported
|
|
25295
|
+
};
|
|
25296
|
+
this.#collaborationModeSelected = false;
|
|
25297
|
+
};
|
|
25298
|
+
observeCollaborationMode = (mode) => {
|
|
25299
|
+
if (mode === void 0 || mode === this.#selection.collaborationMode) {
|
|
25300
|
+
return false;
|
|
25301
|
+
}
|
|
25302
|
+
this.#selection = { ...this.#selection, collaborationMode: mode };
|
|
25303
|
+
return true;
|
|
25304
|
+
};
|
|
25305
|
+
turnParameters = () => {
|
|
25306
|
+
const selection = this.#selection;
|
|
25307
|
+
const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
|
|
25308
|
+
const supportsFast = this.#model(selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) === true;
|
|
25309
|
+
return {
|
|
25310
|
+
// Until a mode is chosen, `config.toml` decides the sandbox and approval
|
|
25311
|
+
// policy, and those fields stay off the turn so the host's own setup is
|
|
25312
|
+
// inherited rather than overridden.
|
|
25313
|
+
...this.#policySelected ? {
|
|
25314
|
+
approvalPolicy: mode.approvalPolicy,
|
|
25315
|
+
approvalsReviewer: mode.approvalsReviewer,
|
|
25316
|
+
sandboxPolicy: mode.sandboxPolicy
|
|
25317
|
+
} : {},
|
|
25318
|
+
// The collaboration mode rides on the turn: Codex applies it to the
|
|
25319
|
+
// thread, where it persists until changed. "Build" is Codex's `default`
|
|
25320
|
+
// mode, so it is only sent once a choice exists to apply.
|
|
25321
|
+
...this.#collaborationModeSupported && (selection.collaborationMode !== "default" || this.#collaborationModeSelected) ? {
|
|
25322
|
+
collaborationMode: {
|
|
25323
|
+
mode: selection.collaborationMode,
|
|
25324
|
+
settings: {
|
|
25325
|
+
developer_instructions: null,
|
|
25326
|
+
model: selection.model,
|
|
25327
|
+
reasoning_effort: selection.effort.length === 0 ? null : selection.effort
|
|
25328
|
+
}
|
|
25329
|
+
}
|
|
25330
|
+
} : {},
|
|
25331
|
+
...selection.effort.length === 0 ? {} : { effort: selection.effort },
|
|
25332
|
+
...selection.model.length === 0 ? {} : { model: selection.model },
|
|
25333
|
+
...selection.fastMode && supportsFast ? { serviceTier: SERVICE_TIER_FAST } : {}
|
|
25334
|
+
};
|
|
25335
|
+
};
|
|
25336
|
+
loadModels = async (signal) => {
|
|
25337
|
+
const models = [];
|
|
25338
|
+
let cursor = null;
|
|
25339
|
+
try {
|
|
25340
|
+
do {
|
|
25341
|
+
const decoded = modelListResponseSchema.parse(
|
|
25342
|
+
await this.#appServer.request(
|
|
25343
|
+
"model/list",
|
|
25344
|
+
{ cursor, limit: null },
|
|
25345
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
25346
|
+
)
|
|
25347
|
+
);
|
|
25348
|
+
models.push(...decoded.data);
|
|
25349
|
+
cursor = decoded.nextCursor ?? null;
|
|
25350
|
+
} while (cursor !== null && models.length < MODEL_CATALOG_LIMIT);
|
|
25351
|
+
} catch (error62) {
|
|
25352
|
+
signal.throwIfAborted();
|
|
25353
|
+
process.stderr.write(`[codex-acp] model catalog unavailable: ${String(error62)}
|
|
25354
|
+
`);
|
|
25355
|
+
}
|
|
25356
|
+
this.#models = Object.freeze(models.slice(0, MODEL_CATALOG_LIMIT));
|
|
25357
|
+
};
|
|
25358
|
+
#model = (id) => this.#models.find((model) => model.id === id);
|
|
25359
|
+
/**
|
|
25360
|
+
* Learns, once per app-server, whether collaboration mode can be applied. An empty settings
|
|
25361
|
+
* update is a no-op on a supporting Codex; an older Codex answers an error, which costs the
|
|
25362
|
+
* Build/Plan selector alone without changing a restored thread's persisted mode.
|
|
25363
|
+
*/
|
|
25364
|
+
probeCollaborationMode = async (threadId, signal) => {
|
|
25365
|
+
if (this.#collaborationModeSupported !== null) {
|
|
25366
|
+
return;
|
|
25367
|
+
}
|
|
25368
|
+
try {
|
|
25369
|
+
await this.#appServer.request(
|
|
25370
|
+
"thread/settings/update",
|
|
25371
|
+
{ threadId },
|
|
25372
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
25373
|
+
);
|
|
25374
|
+
this.#collaborationModeSupported = true;
|
|
25375
|
+
} catch {
|
|
25376
|
+
signal.throwIfAborted();
|
|
25377
|
+
this.#collaborationModeSupported = false;
|
|
25378
|
+
}
|
|
25379
|
+
};
|
|
25380
|
+
/** The ACP settings Mobius discovers and renders in Run settings. */
|
|
25381
|
+
configOptions = () => {
|
|
25382
|
+
const options = [];
|
|
25383
|
+
const model = modelSetting(this.#models, this.#selection.model);
|
|
25384
|
+
if (model !== null) {
|
|
25385
|
+
options.push(model);
|
|
25386
|
+
}
|
|
25387
|
+
const effort = effortSetting(this.#model(this.#selection.model), this.#selection.effort);
|
|
25388
|
+
if (effort !== null) {
|
|
25389
|
+
options.push(effort);
|
|
25390
|
+
}
|
|
25391
|
+
const fastMode = fastModeSetting(this.#model(this.#selection.model), this.#selection.fastMode);
|
|
25392
|
+
if (fastMode !== null) {
|
|
25393
|
+
options.push(fastMode);
|
|
25394
|
+
}
|
|
25395
|
+
if (this.#collaborationModeSupported === true) {
|
|
25396
|
+
options.push(collaborationModeSetting(this.#selection.collaborationMode));
|
|
25397
|
+
}
|
|
25398
|
+
options.push(modeSetting(this.#selection.mode));
|
|
25399
|
+
return options;
|
|
25400
|
+
};
|
|
25401
|
+
selectRestoredThread = (thread) => {
|
|
25402
|
+
const supported = supportedSelection(
|
|
25403
|
+
this.#models,
|
|
25404
|
+
thread.model ?? this.#selection.model,
|
|
25405
|
+
thread.reasoningEffort ?? this.#selection.effort
|
|
25406
|
+
);
|
|
25407
|
+
this.#selection = {
|
|
25408
|
+
...this.#selection,
|
|
25409
|
+
...supported,
|
|
25410
|
+
fastMode: thread.serviceTier === SERVICE_TIER_FAST
|
|
25411
|
+
};
|
|
25412
|
+
};
|
|
25413
|
+
/**
|
|
25414
|
+
* Applies one `session/set_config_option`. Switching models re-resolves the effort the way Codex
|
|
25415
|
+
* does — the current effort when the new model supports it, otherwise the model's own default —
|
|
25416
|
+
* so the reply never advertises an effort the selected model cannot run.
|
|
25417
|
+
*/
|
|
25418
|
+
applySelection = (configId, value) => {
|
|
25419
|
+
if (configId === FAST_MODE_SETTING_ID) {
|
|
25420
|
+
if (typeof value !== "boolean") {
|
|
25421
|
+
throw new AcpExecutionError(
|
|
25422
|
+
"The requested Codex setting is invalid",
|
|
25423
|
+
{},
|
|
25424
|
+
"invalid_session_configuration"
|
|
25425
|
+
);
|
|
25426
|
+
}
|
|
25427
|
+
if (value && this.#model(this.#selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
|
|
25428
|
+
throw new AcpExecutionError(
|
|
25429
|
+
"The selected Codex model has no fast mode",
|
|
25430
|
+
{},
|
|
25431
|
+
"invalid_session_configuration"
|
|
25432
|
+
);
|
|
25433
|
+
}
|
|
25434
|
+
this.#selection = { ...this.#selection, fastMode: value };
|
|
25435
|
+
return;
|
|
25436
|
+
}
|
|
25437
|
+
if (typeof value !== "string") {
|
|
25438
|
+
throw new AcpExecutionError("The requested Codex setting is invalid", {}, "invalid_session_configuration");
|
|
25439
|
+
}
|
|
25440
|
+
if (configId === MODE_SETTING_ID) {
|
|
25441
|
+
if (!AGENT_MODES.some((mode) => mode.id === value)) {
|
|
25442
|
+
throw new AcpExecutionError(
|
|
25443
|
+
"The requested Codex mode is unavailable",
|
|
25444
|
+
{},
|
|
25445
|
+
"invalid_session_configuration"
|
|
25446
|
+
);
|
|
25447
|
+
}
|
|
25448
|
+
this.#selection = { ...this.#selection, mode: value };
|
|
25449
|
+
this.#policySelected = true;
|
|
25450
|
+
return;
|
|
25451
|
+
}
|
|
25452
|
+
if (configId === COLLABORATION_MODE_SETTING_ID) {
|
|
25453
|
+
if (!COLLABORATION_MODES.some((mode) => mode.value === value)) {
|
|
25454
|
+
throw new AcpExecutionError(
|
|
25455
|
+
"The requested Codex collaboration mode is unavailable",
|
|
25456
|
+
{},
|
|
25457
|
+
"invalid_session_configuration"
|
|
25458
|
+
);
|
|
25459
|
+
}
|
|
25460
|
+
this.#selection = { ...this.#selection, collaborationMode: value };
|
|
25461
|
+
this.#collaborationModeSelected = true;
|
|
25462
|
+
return;
|
|
25463
|
+
}
|
|
25464
|
+
if (configId === MODEL_SETTING_ID) {
|
|
25465
|
+
if (value === this.#selection.model) {
|
|
25466
|
+
return;
|
|
25467
|
+
}
|
|
25468
|
+
const model = this.#model(value);
|
|
25469
|
+
if (model === void 0) {
|
|
25470
|
+
throw new AcpExecutionError(
|
|
25471
|
+
"The requested Codex model is unavailable",
|
|
25472
|
+
{},
|
|
25473
|
+
"invalid_session_configuration"
|
|
25474
|
+
);
|
|
25475
|
+
}
|
|
25476
|
+
const supported = (model.supportedReasoningEfforts ?? []).map((option) => option.reasoningEffort);
|
|
25477
|
+
const effort = supported.includes(this.#selection.effort) ? this.#selection.effort : model.defaultReasoningEffort ?? supported[0] ?? "";
|
|
25478
|
+
this.#selection = {
|
|
25479
|
+
...this.#selection,
|
|
25480
|
+
effort,
|
|
25481
|
+
fastMode: this.#selection.fastMode && model.additionalSpeedTiers?.includes(FAST_TIER) === true,
|
|
25482
|
+
model: value
|
|
25483
|
+
};
|
|
25484
|
+
return;
|
|
25485
|
+
}
|
|
25486
|
+
if (configId === REASONING_EFFORT_SETTING_ID) {
|
|
25487
|
+
const supported = (this.#model(this.#selection.model)?.supportedReasoningEfforts ?? []).map(
|
|
25488
|
+
(option) => option.reasoningEffort
|
|
25489
|
+
);
|
|
25490
|
+
if (!supported.includes(value)) {
|
|
25491
|
+
throw new AcpExecutionError(
|
|
25492
|
+
"The requested Codex reasoning effort is unavailable",
|
|
25493
|
+
{},
|
|
25494
|
+
"invalid_session_configuration"
|
|
25495
|
+
);
|
|
25496
|
+
}
|
|
25497
|
+
this.#selection = { ...this.#selection, effort: value };
|
|
25498
|
+
return;
|
|
25499
|
+
}
|
|
25500
|
+
throw new AcpExecutionError("The requested Codex setting is unavailable", {}, "invalid_session_configuration");
|
|
25501
|
+
};
|
|
25502
|
+
};
|
|
25503
|
+
|
|
25504
|
+
// src/acp/codex/agent.ts
|
|
25505
|
+
var APPROVAL_REASON_CHARACTER_LIMIT = 500;
|
|
25506
|
+
var APPROVAL_TIMEOUT_MILLISECONDS2 = 36e5;
|
|
25507
|
+
var CODEX_AGENT_VERSION = "0.154.0";
|
|
25508
|
+
var SESSION_LIST_TIMEOUT_MILLISECONDS = 3e4;
|
|
25509
|
+
var CODEX_COMMANDS = Object.freeze([{ description: "Compact the conversation context", name: "compact" }]);
|
|
25510
|
+
var APPROVAL_OPTIONS = Object.freeze([
|
|
25511
|
+
{ kind: "allow_once", name: "Allow once", optionId: "accept" },
|
|
25512
|
+
{ kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
|
|
25513
|
+
{ kind: "reject_once", name: "Deny", optionId: "decline" }
|
|
25514
|
+
]);
|
|
25515
|
+
function permissionDecision(optionId) {
|
|
25516
|
+
if (optionId === "accept" || optionId === "acceptForSession" || optionId === "decline") {
|
|
25517
|
+
return optionId;
|
|
25518
|
+
}
|
|
25519
|
+
return "cancel";
|
|
25520
|
+
}
|
|
25521
|
+
function promptInput(prompt) {
|
|
25522
|
+
const input2 = [];
|
|
25523
|
+
for (const block of prompt) {
|
|
25524
|
+
if (block.type === "text") {
|
|
25525
|
+
input2.push({ text: block.text, text_elements: [], type: "text" });
|
|
25526
|
+
continue;
|
|
25527
|
+
}
|
|
25528
|
+
if (block.type === "image") {
|
|
25529
|
+
input2.push({ type: "image", url: `data:${block.mimeType};base64,${block.data}` });
|
|
25530
|
+
continue;
|
|
25531
|
+
}
|
|
25532
|
+
if (block.type === "resource") {
|
|
25533
|
+
const resource = block.resource;
|
|
25534
|
+
input2.push({
|
|
25535
|
+
text: "text" in resource ? resource.text ?? "" : "",
|
|
25536
|
+
text_elements: [],
|
|
25537
|
+
type: "text"
|
|
25538
|
+
});
|
|
25539
|
+
continue;
|
|
25540
|
+
}
|
|
25541
|
+
if (block.type === "resource_link") {
|
|
25542
|
+
input2.push({ text: `Resource: ${block.uri}`, text_elements: [], type: "text" });
|
|
25543
|
+
}
|
|
25544
|
+
}
|
|
25545
|
+
return input2;
|
|
25546
|
+
}
|
|
25547
|
+
function isCompactPrompt(prompt) {
|
|
25548
|
+
return prompt.length === 1 && prompt[0]?.type === "text" && prompt[0].text.trim() === "/compact";
|
|
25549
|
+
}
|
|
25550
|
+
function steeringPromptInput(prompt) {
|
|
25551
|
+
const input2 = [];
|
|
25552
|
+
for (const block of prompt) {
|
|
25553
|
+
if (typeof block !== "object" || block === null) {
|
|
25554
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25555
|
+
}
|
|
25556
|
+
const type = Reflect.get(block, "type");
|
|
25557
|
+
if (type === "text") {
|
|
25558
|
+
const text2 = Reflect.get(block, "text");
|
|
25559
|
+
if (typeof text2 !== "string") {
|
|
25560
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25561
|
+
}
|
|
25562
|
+
input2.push({ text: text2, text_elements: [], type: "text" });
|
|
25563
|
+
continue;
|
|
25564
|
+
}
|
|
25565
|
+
if (type === "image") {
|
|
25566
|
+
const data = Reflect.get(block, "data");
|
|
25567
|
+
const mimeType = Reflect.get(block, "mimeType");
|
|
25568
|
+
if (typeof data !== "string" || typeof mimeType !== "string") {
|
|
25569
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25570
|
+
}
|
|
25571
|
+
input2.push({ type: "image", url: `data:${mimeType};base64,${data}` });
|
|
25572
|
+
continue;
|
|
25573
|
+
}
|
|
25574
|
+
if (type === "resource") {
|
|
25575
|
+
const resource = Reflect.get(block, "resource");
|
|
25576
|
+
if (typeof resource !== "object" || resource === null) {
|
|
25577
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25578
|
+
}
|
|
25579
|
+
const text2 = Reflect.get(resource, "text");
|
|
25580
|
+
if (text2 !== void 0 && typeof text2 !== "string") {
|
|
25581
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25582
|
+
}
|
|
25583
|
+
input2.push({ text: text2 ?? "", text_elements: [], type: "text" });
|
|
25584
|
+
continue;
|
|
25585
|
+
}
|
|
25586
|
+
if (type === "resource_link") {
|
|
25587
|
+
const uri = Reflect.get(block, "uri");
|
|
25588
|
+
if (typeof uri !== "string") {
|
|
25589
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25590
|
+
}
|
|
25591
|
+
input2.push({ text: `Resource: ${uri}`, text_elements: [], type: "text" });
|
|
25592
|
+
continue;
|
|
25593
|
+
}
|
|
25594
|
+
throw new AcpExecutionError("Codex received an unsupported steering prompt", {}, "invalid_request");
|
|
25346
25595
|
}
|
|
25347
|
-
return
|
|
25348
|
-
category: "thought_level",
|
|
25349
|
-
currentValue: current,
|
|
25350
|
-
description: "How much reasoning effort the model should use",
|
|
25351
|
-
id: REASONING_EFFORT_SETTING_ID,
|
|
25352
|
-
name: "Reasoning effort",
|
|
25353
|
-
options: values,
|
|
25354
|
-
type: "select"
|
|
25355
|
-
};
|
|
25596
|
+
return input2;
|
|
25356
25597
|
}
|
|
25357
25598
|
function userInputSchema(questions) {
|
|
25358
25599
|
const properties = {};
|
|
@@ -25380,31 +25621,13 @@ var CodexAcpAgent = class {
|
|
|
25380
25621
|
terminated;
|
|
25381
25622
|
#closePromise = null;
|
|
25382
25623
|
#connection = null;
|
|
25383
|
-
#
|
|
25624
|
+
#settings;
|
|
25384
25625
|
#nativeSessionId = "";
|
|
25385
|
-
// Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
|
|
25386
|
-
// configuration decides, so `turn/start` omits the fields and inherits what the host set up.
|
|
25387
|
-
#policySelected = false;
|
|
25388
|
-
// Whether a collaboration mode choice has been made in this session. A restored thread keeps
|
|
25389
|
-
// the mode Codex already persisted, so the first turn does not reset it to Build.
|
|
25390
|
-
#collaborationModeSelected = false;
|
|
25391
|
-
// Whether the app-server accepts collaboration mode on `turn/start`, probed once per
|
|
25392
|
-
// app-server. An older Codex rejects the experimental field, and the setting must disappear
|
|
25393
|
-
// rather than break every turn.
|
|
25394
|
-
#collaborationModeSupported = null;
|
|
25395
|
-
#selection;
|
|
25396
25626
|
#streamedReasoningItemIds = /* @__PURE__ */ new Set();
|
|
25397
25627
|
#turn = null;
|
|
25398
25628
|
#nativeTurnId = null;
|
|
25399
25629
|
#updateTail = Promise.resolve();
|
|
25400
25630
|
constructor(options) {
|
|
25401
|
-
this.#selection = {
|
|
25402
|
-
collaborationMode: "default",
|
|
25403
|
-
effort: "",
|
|
25404
|
-
fastMode: false,
|
|
25405
|
-
mode: initialMode(options.environment),
|
|
25406
|
-
model: ""
|
|
25407
|
-
};
|
|
25408
25631
|
this.#appServer = new CodexAppServerClient({
|
|
25409
25632
|
command: options.command,
|
|
25410
25633
|
cwd: options.cwd,
|
|
@@ -25418,6 +25641,7 @@ var CodexAcpAgent = class {
|
|
|
25418
25641
|
}
|
|
25419
25642
|
}
|
|
25420
25643
|
});
|
|
25644
|
+
this.#settings = new CodexSettings(this.#appServer, options.environment);
|
|
25421
25645
|
this.terminated = this.#appServer.terminated;
|
|
25422
25646
|
void this.terminated.then((termination) => {
|
|
25423
25647
|
this.#turn?.completion.reject(acpEndpointTerminationError(termination));
|
|
@@ -25444,39 +25668,34 @@ var CodexAcpAgent = class {
|
|
|
25444
25668
|
await this.#appServer.request(
|
|
25445
25669
|
"thread/start",
|
|
25446
25670
|
{ cwd: context.params.cwd },
|
|
25447
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
25671
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
25448
25672
|
)
|
|
25449
25673
|
);
|
|
25450
25674
|
this.#nativeSessionId = created.thread.id;
|
|
25451
|
-
|
|
25452
|
-
this.#
|
|
25453
|
-
...this.#selection,
|
|
25454
|
-
collaborationMode: "default",
|
|
25455
|
-
...supported
|
|
25456
|
-
};
|
|
25457
|
-
this.#collaborationModeSelected = false;
|
|
25458
|
-
await this.#probeCollaborationMode(context.signal);
|
|
25675
|
+
this.#settings.selectNewThread(created);
|
|
25676
|
+
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
25459
25677
|
await this.#emitAvailableCommands();
|
|
25460
|
-
return { configOptions: this.#configOptions(), sessionId: created.thread.id };
|
|
25678
|
+
return { configOptions: this.#settings.configOptions(), sessionId: created.thread.id };
|
|
25461
25679
|
}).onRequest(methods.agent.session.setConfigOption, async (context) => {
|
|
25462
|
-
this.#applySelection(context.params.configId, context.params.value);
|
|
25463
|
-
return { configOptions: this.#configOptions() };
|
|
25680
|
+
this.#settings.applySelection(context.params.configId, context.params.value);
|
|
25681
|
+
return { configOptions: this.#settings.configOptions() };
|
|
25464
25682
|
}).onRequest(methods.agent.session.setMode, async (context) => {
|
|
25465
|
-
this.#applySelection(
|
|
25683
|
+
this.#settings.applySelection("mode", context.params.modeId);
|
|
25466
25684
|
return {};
|
|
25467
25685
|
}).onRequest(methods.agent.session.load, async (context) => {
|
|
25468
25686
|
const resumed = threadResumeResponseSchema.parse(
|
|
25469
25687
|
await this.#appServer.request(
|
|
25470
25688
|
"thread/resume",
|
|
25471
25689
|
{ cwd: context.params.cwd, excludeTurns: false, threadId: context.params.sessionId },
|
|
25472
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
25690
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
25473
25691
|
)
|
|
25474
25692
|
);
|
|
25475
|
-
this.#
|
|
25476
|
-
|
|
25693
|
+
this.#nativeSessionId = resumed.thread.id;
|
|
25694
|
+
this.#settings.selectRestoredThread(resumed);
|
|
25695
|
+
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
25477
25696
|
await this.#replayHistory(resumed.turns);
|
|
25478
25697
|
await this.#emitAvailableCommands();
|
|
25479
|
-
return { configOptions: this.#configOptions() };
|
|
25698
|
+
return { configOptions: this.#settings.configOptions() };
|
|
25480
25699
|
}).onRequest(methods.agent.session.fork, async (context) => {
|
|
25481
25700
|
const forked = threadForkResponseSchema.parse(
|
|
25482
25701
|
await this.#appServer.request(
|
|
@@ -25486,26 +25705,28 @@ var CodexAcpAgent = class {
|
|
|
25486
25705
|
excludeTurns: false,
|
|
25487
25706
|
threadId: context.params.sessionId
|
|
25488
25707
|
},
|
|
25489
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
25708
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
25490
25709
|
)
|
|
25491
25710
|
);
|
|
25492
|
-
this.#
|
|
25493
|
-
|
|
25711
|
+
this.#nativeSessionId = forked.thread.id;
|
|
25712
|
+
this.#settings.selectRestoredThread(forked);
|
|
25713
|
+
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
25494
25714
|
await this.#replayHistory(forked.turns);
|
|
25495
25715
|
await this.#emitAvailableCommands();
|
|
25496
|
-
return { configOptions: this.#configOptions(), sessionId: forked.thread.id };
|
|
25716
|
+
return { configOptions: this.#settings.configOptions(), sessionId: forked.thread.id };
|
|
25497
25717
|
}).onRequest(methods.agent.session.resume, async (context) => {
|
|
25498
25718
|
const resumed = threadResumeResponseSchema.parse(
|
|
25499
25719
|
await this.#appServer.request(
|
|
25500
25720
|
"thread/resume",
|
|
25501
25721
|
{ cwd: context.params.cwd, excludeTurns: true, threadId: context.params.sessionId },
|
|
25502
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
25722
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
25503
25723
|
)
|
|
25504
25724
|
);
|
|
25505
|
-
this.#
|
|
25506
|
-
|
|
25725
|
+
this.#nativeSessionId = resumed.thread.id;
|
|
25726
|
+
this.#settings.selectRestoredThread(resumed);
|
|
25727
|
+
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
25507
25728
|
await this.#emitAvailableCommands();
|
|
25508
|
-
return { configOptions: this.#configOptions() };
|
|
25729
|
+
return { configOptions: this.#settings.configOptions() };
|
|
25509
25730
|
}).onRequest(methods.agent.session.prompt, async (context) => {
|
|
25510
25731
|
if (isCompactPrompt(context.params.prompt)) {
|
|
25511
25732
|
return await this.#compact(context.signal);
|
|
@@ -25545,7 +25766,7 @@ var CodexAcpAgent = class {
|
|
|
25545
25766
|
/** Starts the app-server, performs its handshake, and reads the model catalog Codex offers. */
|
|
25546
25767
|
initialize = async (signal) => {
|
|
25547
25768
|
await this.#appServer.initialize(signal);
|
|
25548
|
-
await this.#loadModels(signal);
|
|
25769
|
+
await this.#settings.loadModels(signal);
|
|
25549
25770
|
};
|
|
25550
25771
|
/**
|
|
25551
25772
|
* Releases the app-server and every process it started. Mirrors the adapter path's teardown so a
|
|
@@ -25571,84 +25792,6 @@ var CodexAcpAgent = class {
|
|
|
25571
25792
|
* the Run settings panel its model selector; it must not cost the conversation itself, so the
|
|
25572
25793
|
* turn lifecycle continues without settings rather than failing initialization.
|
|
25573
25794
|
*/
|
|
25574
|
-
#loadModels = async (signal) => {
|
|
25575
|
-
const models = [];
|
|
25576
|
-
let cursor = null;
|
|
25577
|
-
try {
|
|
25578
|
-
do {
|
|
25579
|
-
const decoded = modelListResponseSchema.parse(
|
|
25580
|
-
await this.#appServer.request(
|
|
25581
|
-
"model/list",
|
|
25582
|
-
{ cursor, limit: null },
|
|
25583
|
-
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
25584
|
-
)
|
|
25585
|
-
);
|
|
25586
|
-
models.push(...decoded.data);
|
|
25587
|
-
cursor = decoded.nextCursor ?? null;
|
|
25588
|
-
} while (cursor !== null && models.length < MODEL_CATALOG_LIMIT);
|
|
25589
|
-
} catch (error62) {
|
|
25590
|
-
signal.throwIfAborted();
|
|
25591
|
-
process.stderr.write(`[codex-acp] model catalog unavailable: ${String(error62)}
|
|
25592
|
-
`);
|
|
25593
|
-
}
|
|
25594
|
-
this.#models = Object.freeze(models.slice(0, MODEL_CATALOG_LIMIT));
|
|
25595
|
-
};
|
|
25596
|
-
#model = (id) => this.#models.find((model) => model.id === id);
|
|
25597
|
-
/**
|
|
25598
|
-
* Learns, once per app-server, whether collaboration mode can be applied. An empty settings
|
|
25599
|
-
* update is a no-op on a supporting Codex; an older Codex answers an error, which costs the
|
|
25600
|
-
* Build/Plan selector alone without changing a restored thread's persisted mode.
|
|
25601
|
-
*/
|
|
25602
|
-
#probeCollaborationMode = async (signal) => {
|
|
25603
|
-
if (this.#collaborationModeSupported !== null) {
|
|
25604
|
-
return;
|
|
25605
|
-
}
|
|
25606
|
-
try {
|
|
25607
|
-
await this.#appServer.request(
|
|
25608
|
-
"thread/settings/update",
|
|
25609
|
-
{ threadId: this.#nativeSessionId },
|
|
25610
|
-
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
25611
|
-
);
|
|
25612
|
-
this.#collaborationModeSupported = true;
|
|
25613
|
-
} catch {
|
|
25614
|
-
signal.throwIfAborted();
|
|
25615
|
-
this.#collaborationModeSupported = false;
|
|
25616
|
-
}
|
|
25617
|
-
};
|
|
25618
|
-
/** The ACP settings Mobius discovers and renders in Run settings. */
|
|
25619
|
-
#configOptions = () => {
|
|
25620
|
-
const options = [];
|
|
25621
|
-
const model = modelSetting(this.#models, this.#selection.model);
|
|
25622
|
-
if (model !== null) {
|
|
25623
|
-
options.push(model);
|
|
25624
|
-
}
|
|
25625
|
-
const effort = effortSetting(this.#model(this.#selection.model), this.#selection.effort);
|
|
25626
|
-
if (effort !== null) {
|
|
25627
|
-
options.push(effort);
|
|
25628
|
-
}
|
|
25629
|
-
const fastMode = fastModeSetting(this.#model(this.#selection.model), this.#selection.fastMode);
|
|
25630
|
-
if (fastMode !== null) {
|
|
25631
|
-
options.push(fastMode);
|
|
25632
|
-
}
|
|
25633
|
-
if (this.#collaborationModeSupported === true) {
|
|
25634
|
-
options.push(collaborationModeSetting(this.#selection.collaborationMode));
|
|
25635
|
-
}
|
|
25636
|
-
options.push(modeSetting(this.#selection.mode));
|
|
25637
|
-
return options;
|
|
25638
|
-
};
|
|
25639
|
-
#selectRestoredThread = (thread) => {
|
|
25640
|
-
this.#nativeSessionId = thread.thread.id;
|
|
25641
|
-
const supported = supportedSelection(
|
|
25642
|
-
this.#models,
|
|
25643
|
-
thread.model ?? this.#selection.model,
|
|
25644
|
-
thread.reasoningEffort ?? this.#selection.effort
|
|
25645
|
-
);
|
|
25646
|
-
this.#selection = {
|
|
25647
|
-
...this.#selection,
|
|
25648
|
-
...supported,
|
|
25649
|
-
fastMode: thread.serviceTier === SERVICE_TIER_FAST
|
|
25650
|
-
};
|
|
25651
|
-
};
|
|
25652
25795
|
#replayHistory = async (turns) => {
|
|
25653
25796
|
for (const turn of turns ?? []) {
|
|
25654
25797
|
for (const rawItem of turn.items) {
|
|
@@ -25690,95 +25833,6 @@ var CodexAcpAgent = class {
|
|
|
25690
25833
|
}
|
|
25691
25834
|
}
|
|
25692
25835
|
};
|
|
25693
|
-
/**
|
|
25694
|
-
* Applies one `session/set_config_option`. Switching models re-resolves the effort the way Codex
|
|
25695
|
-
* does — the current effort when the new model supports it, otherwise the model's own default —
|
|
25696
|
-
* so the reply never advertises an effort the selected model cannot run.
|
|
25697
|
-
*/
|
|
25698
|
-
#applySelection = (configId, value) => {
|
|
25699
|
-
if (configId === FAST_MODE_SETTING_ID) {
|
|
25700
|
-
if (typeof value !== "boolean") {
|
|
25701
|
-
throw new AcpExecutionError(
|
|
25702
|
-
"The requested Codex setting is invalid",
|
|
25703
|
-
{},
|
|
25704
|
-
"invalid_session_configuration"
|
|
25705
|
-
);
|
|
25706
|
-
}
|
|
25707
|
-
if (value && this.#model(this.#selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
|
|
25708
|
-
throw new AcpExecutionError(
|
|
25709
|
-
"The selected Codex model has no fast mode",
|
|
25710
|
-
{},
|
|
25711
|
-
"invalid_session_configuration"
|
|
25712
|
-
);
|
|
25713
|
-
}
|
|
25714
|
-
this.#selection = { ...this.#selection, fastMode: value };
|
|
25715
|
-
return;
|
|
25716
|
-
}
|
|
25717
|
-
if (typeof value !== "string") {
|
|
25718
|
-
throw new AcpExecutionError("The requested Codex setting is invalid", {}, "invalid_session_configuration");
|
|
25719
|
-
}
|
|
25720
|
-
if (configId === MODE_SETTING_ID) {
|
|
25721
|
-
if (!AGENT_MODES.some((mode) => mode.id === value)) {
|
|
25722
|
-
throw new AcpExecutionError(
|
|
25723
|
-
"The requested Codex mode is unavailable",
|
|
25724
|
-
{},
|
|
25725
|
-
"invalid_session_configuration"
|
|
25726
|
-
);
|
|
25727
|
-
}
|
|
25728
|
-
this.#selection = { ...this.#selection, mode: value };
|
|
25729
|
-
this.#policySelected = true;
|
|
25730
|
-
return;
|
|
25731
|
-
}
|
|
25732
|
-
if (configId === COLLABORATION_MODE_SETTING_ID) {
|
|
25733
|
-
if (!COLLABORATION_MODES.some((mode) => mode.value === value)) {
|
|
25734
|
-
throw new AcpExecutionError(
|
|
25735
|
-
"The requested Codex collaboration mode is unavailable",
|
|
25736
|
-
{},
|
|
25737
|
-
"invalid_session_configuration"
|
|
25738
|
-
);
|
|
25739
|
-
}
|
|
25740
|
-
this.#selection = { ...this.#selection, collaborationMode: value };
|
|
25741
|
-
this.#collaborationModeSelected = true;
|
|
25742
|
-
return;
|
|
25743
|
-
}
|
|
25744
|
-
if (configId === MODEL_SETTING_ID) {
|
|
25745
|
-
if (value === this.#selection.model) {
|
|
25746
|
-
return;
|
|
25747
|
-
}
|
|
25748
|
-
const model = this.#model(value);
|
|
25749
|
-
if (model === void 0) {
|
|
25750
|
-
throw new AcpExecutionError(
|
|
25751
|
-
"The requested Codex model is unavailable",
|
|
25752
|
-
{},
|
|
25753
|
-
"invalid_session_configuration"
|
|
25754
|
-
);
|
|
25755
|
-
}
|
|
25756
|
-
const supported = (model.supportedReasoningEfforts ?? []).map((option) => option.reasoningEffort);
|
|
25757
|
-
const effort = supported.includes(this.#selection.effort) ? this.#selection.effort : model.defaultReasoningEffort ?? supported[0] ?? "";
|
|
25758
|
-
this.#selection = {
|
|
25759
|
-
...this.#selection,
|
|
25760
|
-
effort,
|
|
25761
|
-
fastMode: this.#selection.fastMode && model.additionalSpeedTiers?.includes(FAST_TIER) === true,
|
|
25762
|
-
model: value
|
|
25763
|
-
};
|
|
25764
|
-
return;
|
|
25765
|
-
}
|
|
25766
|
-
if (configId === REASONING_EFFORT_SETTING_ID) {
|
|
25767
|
-
const supported = (this.#model(this.#selection.model)?.supportedReasoningEfforts ?? []).map(
|
|
25768
|
-
(option) => option.reasoningEffort
|
|
25769
|
-
);
|
|
25770
|
-
if (!supported.includes(value)) {
|
|
25771
|
-
throw new AcpExecutionError(
|
|
25772
|
-
"The requested Codex reasoning effort is unavailable",
|
|
25773
|
-
{},
|
|
25774
|
-
"invalid_session_configuration"
|
|
25775
|
-
);
|
|
25776
|
-
}
|
|
25777
|
-
this.#selection = { ...this.#selection, effort: value };
|
|
25778
|
-
return;
|
|
25779
|
-
}
|
|
25780
|
-
throw new AcpExecutionError("The requested Codex setting is unavailable", {}, "invalid_session_configuration");
|
|
25781
|
-
};
|
|
25782
25836
|
#emit = async (update) => {
|
|
25783
25837
|
const connection = this.#connection;
|
|
25784
25838
|
if (connection === null || this.#nativeSessionId.length === 0) {
|
|
@@ -25803,7 +25857,7 @@ var CodexAcpAgent = class {
|
|
|
25803
25857
|
}
|
|
25804
25858
|
await connection.client.notify(methods.client.session.update, {
|
|
25805
25859
|
sessionId: this.#nativeSessionId,
|
|
25806
|
-
update: { configOptions: this.#configOptions(), sessionUpdate: "config_option_update" }
|
|
25860
|
+
update: { configOptions: this.#settings.configOptions(), sessionUpdate: "config_option_update" }
|
|
25807
25861
|
});
|
|
25808
25862
|
};
|
|
25809
25863
|
// Notifications are serialized so two app-server items cannot interleave into one ACP update
|
|
@@ -25843,8 +25897,7 @@ var CodexAcpAgent = class {
|
|
|
25843
25897
|
const decoded = threadSettingsUpdatedSchema.safeParse(params);
|
|
25844
25898
|
if (decoded.success && decoded.data.threadId === this.#nativeSessionId) {
|
|
25845
25899
|
const mode = decoded.data.threadSettings.collaborationMode?.mode;
|
|
25846
|
-
if (
|
|
25847
|
-
this.#selection = { ...this.#selection, collaborationMode: mode };
|
|
25900
|
+
if (this.#settings.observeCollaborationMode(mode)) {
|
|
25848
25901
|
await this.#enqueue(async () => {
|
|
25849
25902
|
await this.#emitConfigOptionsUpdate();
|
|
25850
25903
|
});
|
|
@@ -25966,7 +26019,7 @@ var CodexAcpAgent = class {
|
|
|
25966
26019
|
const decision = await this.#askPermission(
|
|
25967
26020
|
title2,
|
|
25968
26021
|
params.itemId,
|
|
25969
|
-
AbortSignal.timeout(
|
|
26022
|
+
AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)
|
|
25970
26023
|
);
|
|
25971
26024
|
void turn;
|
|
25972
26025
|
this.#appServer.respond(request.id, { decision });
|
|
@@ -25988,7 +26041,7 @@ var CodexAcpAgent = class {
|
|
|
25988
26041
|
sessionId: this.#nativeSessionId,
|
|
25989
26042
|
...decoded.data.itemId == null ? {} : { toolCallId: decoded.data.itemId }
|
|
25990
26043
|
},
|
|
25991
|
-
{ cancellationSignal: AbortSignal.timeout(
|
|
26044
|
+
{ cancellationSignal: AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2) }
|
|
25992
26045
|
);
|
|
25993
26046
|
const content = response.action === "accept" ? Reflect.get(response, "content") : void 0;
|
|
25994
26047
|
const answers = {};
|
|
@@ -26006,7 +26059,7 @@ var CodexAcpAgent = class {
|
|
|
26006
26059
|
return;
|
|
26007
26060
|
}
|
|
26008
26061
|
const params = decoded.data;
|
|
26009
|
-
const signal = AbortSignal.timeout(
|
|
26062
|
+
const signal = AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2);
|
|
26010
26063
|
if (params.mode === "url" && params.url !== void 0) {
|
|
26011
26064
|
const response2 = await connection.client.request(
|
|
26012
26065
|
methods.client.elicitation.create,
|
|
@@ -26055,38 +26108,12 @@ var CodexAcpAgent = class {
|
|
|
26055
26108
|
this.#turn = turn;
|
|
26056
26109
|
this.#nativeTurnId = null;
|
|
26057
26110
|
try {
|
|
26058
|
-
const selection = this.#selection;
|
|
26059
|
-
const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
|
|
26060
|
-
const supportsFast = this.#model(selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) === true;
|
|
26061
26111
|
const started = turnSchema.parse(
|
|
26062
26112
|
(await this.#appServer.request(
|
|
26063
26113
|
"turn/start",
|
|
26064
26114
|
{
|
|
26065
|
-
|
|
26066
|
-
// policy, and those fields stay off the turn so the host's own setup is
|
|
26067
|
-
// inherited rather than overridden.
|
|
26068
|
-
...this.#policySelected ? {
|
|
26069
|
-
approvalPolicy: mode.approvalPolicy,
|
|
26070
|
-
approvalsReviewer: mode.approvalsReviewer,
|
|
26071
|
-
sandboxPolicy: mode.sandboxPolicy
|
|
26072
|
-
} : {},
|
|
26073
|
-
// The collaboration mode rides on the turn: Codex applies it to the
|
|
26074
|
-
// thread, where it persists until changed. "Build" is Codex's `default`
|
|
26075
|
-
// mode, so it is only sent once a choice exists to apply.
|
|
26076
|
-
...this.#collaborationModeSupported && (selection.collaborationMode !== "default" || this.#collaborationModeSelected) ? {
|
|
26077
|
-
collaborationMode: {
|
|
26078
|
-
mode: selection.collaborationMode,
|
|
26079
|
-
settings: {
|
|
26080
|
-
developer_instructions: null,
|
|
26081
|
-
model: selection.model,
|
|
26082
|
-
reasoning_effort: selection.effort.length === 0 ? null : selection.effort
|
|
26083
|
-
}
|
|
26084
|
-
}
|
|
26085
|
-
} : {},
|
|
26086
|
-
...selection.effort.length === 0 ? {} : { effort: selection.effort },
|
|
26115
|
+
...this.#settings.turnParameters(),
|
|
26087
26116
|
input: input2,
|
|
26088
|
-
...selection.model.length === 0 ? {} : { model: selection.model },
|
|
26089
|
-
...selection.fastMode && supportsFast ? { serviceTier: SERVICE_TIER_FAST } : {},
|
|
26090
26117
|
threadId: this.#nativeSessionId
|
|
26091
26118
|
},
|
|
26092
26119
|
signal
|
|
@@ -26155,7 +26182,7 @@ var CodexAcpAgent = class {
|
|
|
26155
26182
|
await this.#appServer.request(
|
|
26156
26183
|
"turn/steer",
|
|
26157
26184
|
{ expectedTurnId: active.turn.id, input: input2, threadId: this.#nativeSessionId },
|
|
26158
|
-
AbortSignal.any([signal, AbortSignal.timeout(
|
|
26185
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
26159
26186
|
)
|
|
26160
26187
|
);
|
|
26161
26188
|
if (response.turnId !== active.turn.id) {
|
|
@@ -26174,7 +26201,7 @@ var CodexAcpAgent = class {
|
|
|
26174
26201
|
await this.#appServer.request(
|
|
26175
26202
|
"turn/interrupt",
|
|
26176
26203
|
{ threadId: this.#nativeSessionId, turnId: turn.turn.id },
|
|
26177
|
-
AbortSignal.timeout(
|
|
26204
|
+
AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)
|
|
26178
26205
|
);
|
|
26179
26206
|
} catch {
|
|
26180
26207
|
}
|