@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/runtime.js
CHANGED
|
@@ -23465,11 +23465,8 @@ function agentMessageMeta(phase) {
|
|
|
23465
23465
|
return { [CODEX_META_KEY]: { phase } };
|
|
23466
23466
|
}
|
|
23467
23467
|
|
|
23468
|
-
// src/acp/codex/
|
|
23469
|
-
var APPROVAL_REASON_CHARACTER_LIMIT = 500;
|
|
23468
|
+
// src/acp/codex/settings.ts
|
|
23470
23469
|
var APPROVAL_TIMEOUT_MILLISECONDS = 36e5;
|
|
23471
|
-
var CODEX_AGENT_VERSION = "0.154.0";
|
|
23472
|
-
var SESSION_LIST_TIMEOUT_MILLISECONDS = 3e4;
|
|
23473
23470
|
var MODEL_SETTING_ID = "model";
|
|
23474
23471
|
var REASONING_EFFORT_SETTING_ID = "reasoning_effort";
|
|
23475
23472
|
var MODE_SETTING_ID = "mode";
|
|
@@ -23478,7 +23475,6 @@ var COLLABORATION_MODE_SETTING_ID = "collaboration_mode";
|
|
|
23478
23475
|
var MODEL_CATALOG_LIMIT = 1e3;
|
|
23479
23476
|
var FAST_TIER = "fast";
|
|
23480
23477
|
var SERVICE_TIER_FAST = "priority";
|
|
23481
|
-
var CODEX_COMMANDS = Object.freeze([{ description: "Compact the conversation context", name: "compact" }]);
|
|
23482
23478
|
var WORKSPACE_WRITE_POLICY = Object.freeze({
|
|
23483
23479
|
excludeSlashTmp: false,
|
|
23484
23480
|
excludeTmpdirEnvVar: false,
|
|
@@ -23522,94 +23518,6 @@ function initialMode(environment) {
|
|
|
23522
23518
|
function capitalize(value) {
|
|
23523
23519
|
return value.length === 0 ? value : value.charAt(0).toUpperCase() + value.slice(1);
|
|
23524
23520
|
}
|
|
23525
|
-
var APPROVAL_OPTIONS = Object.freeze([
|
|
23526
|
-
{ kind: "allow_once", name: "Allow once", optionId: "accept" },
|
|
23527
|
-
{ kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
|
|
23528
|
-
{ kind: "reject_once", name: "Deny", optionId: "decline" }
|
|
23529
|
-
]);
|
|
23530
|
-
function permissionDecision(optionId) {
|
|
23531
|
-
if (optionId === "accept" || optionId === "acceptForSession" || optionId === "decline") {
|
|
23532
|
-
return optionId;
|
|
23533
|
-
}
|
|
23534
|
-
return "cancel";
|
|
23535
|
-
}
|
|
23536
|
-
function promptInput(prompt) {
|
|
23537
|
-
const input2 = [];
|
|
23538
|
-
for (const block of prompt) {
|
|
23539
|
-
if (block.type === "text") {
|
|
23540
|
-
input2.push({ text: block.text, text_elements: [], type: "text" });
|
|
23541
|
-
continue;
|
|
23542
|
-
}
|
|
23543
|
-
if (block.type === "image") {
|
|
23544
|
-
input2.push({ type: "image", url: `data:${block.mimeType};base64,${block.data}` });
|
|
23545
|
-
continue;
|
|
23546
|
-
}
|
|
23547
|
-
if (block.type === "resource") {
|
|
23548
|
-
const resource = block.resource;
|
|
23549
|
-
input2.push({
|
|
23550
|
-
text: "text" in resource ? resource.text ?? "" : "",
|
|
23551
|
-
text_elements: [],
|
|
23552
|
-
type: "text"
|
|
23553
|
-
});
|
|
23554
|
-
continue;
|
|
23555
|
-
}
|
|
23556
|
-
if (block.type === "resource_link") {
|
|
23557
|
-
input2.push({ text: `Resource: ${block.uri}`, text_elements: [], type: "text" });
|
|
23558
|
-
}
|
|
23559
|
-
}
|
|
23560
|
-
return input2;
|
|
23561
|
-
}
|
|
23562
|
-
function isCompactPrompt(prompt) {
|
|
23563
|
-
return prompt.length === 1 && prompt[0]?.type === "text" && prompt[0].text.trim() === "/compact";
|
|
23564
|
-
}
|
|
23565
|
-
function steeringPromptInput(prompt) {
|
|
23566
|
-
const input2 = [];
|
|
23567
|
-
for (const block of prompt) {
|
|
23568
|
-
if (typeof block !== "object" || block === null) {
|
|
23569
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
23570
|
-
}
|
|
23571
|
-
const type = Reflect.get(block, "type");
|
|
23572
|
-
if (type === "text") {
|
|
23573
|
-
const text2 = Reflect.get(block, "text");
|
|
23574
|
-
if (typeof text2 !== "string") {
|
|
23575
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
23576
|
-
}
|
|
23577
|
-
input2.push({ text: text2, text_elements: [], type: "text" });
|
|
23578
|
-
continue;
|
|
23579
|
-
}
|
|
23580
|
-
if (type === "image") {
|
|
23581
|
-
const data = Reflect.get(block, "data");
|
|
23582
|
-
const mimeType = Reflect.get(block, "mimeType");
|
|
23583
|
-
if (typeof data !== "string" || typeof mimeType !== "string") {
|
|
23584
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
23585
|
-
}
|
|
23586
|
-
input2.push({ type: "image", url: `data:${mimeType};base64,${data}` });
|
|
23587
|
-
continue;
|
|
23588
|
-
}
|
|
23589
|
-
if (type === "resource") {
|
|
23590
|
-
const resource = Reflect.get(block, "resource");
|
|
23591
|
-
if (typeof resource !== "object" || resource === null) {
|
|
23592
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
23593
|
-
}
|
|
23594
|
-
const text2 = Reflect.get(resource, "text");
|
|
23595
|
-
if (text2 !== void 0 && typeof text2 !== "string") {
|
|
23596
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
23597
|
-
}
|
|
23598
|
-
input2.push({ text: text2 ?? "", text_elements: [], type: "text" });
|
|
23599
|
-
continue;
|
|
23600
|
-
}
|
|
23601
|
-
if (type === "resource_link") {
|
|
23602
|
-
const uri = Reflect.get(block, "uri");
|
|
23603
|
-
if (typeof uri !== "string") {
|
|
23604
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
23605
|
-
}
|
|
23606
|
-
input2.push({ text: `Resource: ${uri}`, text_elements: [], type: "text" });
|
|
23607
|
-
continue;
|
|
23608
|
-
}
|
|
23609
|
-
throw new AcpExecutionError("Codex received an unsupported steering prompt", {}, "invalid_request");
|
|
23610
|
-
}
|
|
23611
|
-
return input2;
|
|
23612
|
-
}
|
|
23613
23521
|
function modelValues(models) {
|
|
23614
23522
|
return models.map((model) => ({
|
|
23615
23523
|
description: model.description ?? "",
|
|
@@ -23700,19 +23608,352 @@ function effortSetting(model, currentValue) {
|
|
|
23700
23608
|
if (values.length === 0) {
|
|
23701
23609
|
return null;
|
|
23702
23610
|
}
|
|
23703
|
-
const current = values.some((value) => value.value === currentValue) ? currentValue : values[0]?.value ?? "";
|
|
23704
|
-
if (current.length === 0) {
|
|
23705
|
-
return null;
|
|
23611
|
+
const current = values.some((value) => value.value === currentValue) ? currentValue : values[0]?.value ?? "";
|
|
23612
|
+
if (current.length === 0) {
|
|
23613
|
+
return null;
|
|
23614
|
+
}
|
|
23615
|
+
return {
|
|
23616
|
+
category: "thought_level",
|
|
23617
|
+
currentValue: current,
|
|
23618
|
+
description: "How much reasoning effort the model should use",
|
|
23619
|
+
id: REASONING_EFFORT_SETTING_ID,
|
|
23620
|
+
name: "Reasoning effort",
|
|
23621
|
+
options: values,
|
|
23622
|
+
type: "select"
|
|
23623
|
+
};
|
|
23624
|
+
}
|
|
23625
|
+
var CodexSettings = class {
|
|
23626
|
+
#appServer;
|
|
23627
|
+
#models = [];
|
|
23628
|
+
// Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
|
|
23629
|
+
// configuration decides, so `turn/start` omits the fields and inherits what the host set up.
|
|
23630
|
+
#policySelected = false;
|
|
23631
|
+
// Whether a collaboration mode choice has been made in this session. A restored thread keeps
|
|
23632
|
+
// the mode Codex already persisted, so the first turn does not reset it to Build.
|
|
23633
|
+
#collaborationModeSelected = false;
|
|
23634
|
+
// Whether the app-server accepts collaboration mode on `turn/start`, probed once per
|
|
23635
|
+
// app-server. An older Codex rejects the experimental field, and the setting must disappear
|
|
23636
|
+
// rather than break every turn.
|
|
23637
|
+
#collaborationModeSupported = null;
|
|
23638
|
+
#selection;
|
|
23639
|
+
constructor(appServer, environment) {
|
|
23640
|
+
this.#appServer = appServer;
|
|
23641
|
+
this.#selection = {
|
|
23642
|
+
collaborationMode: "default",
|
|
23643
|
+
effort: "",
|
|
23644
|
+
fastMode: false,
|
|
23645
|
+
mode: initialMode(environment),
|
|
23646
|
+
model: ""
|
|
23647
|
+
};
|
|
23648
|
+
}
|
|
23649
|
+
selectNewThread = (created) => {
|
|
23650
|
+
const supported = supportedSelection(this.#models, created.model ?? "", created.reasoningEffort ?? "");
|
|
23651
|
+
this.#selection = {
|
|
23652
|
+
...this.#selection,
|
|
23653
|
+
collaborationMode: "default",
|
|
23654
|
+
...supported
|
|
23655
|
+
};
|
|
23656
|
+
this.#collaborationModeSelected = false;
|
|
23657
|
+
};
|
|
23658
|
+
observeCollaborationMode = (mode) => {
|
|
23659
|
+
if (mode === void 0 || mode === this.#selection.collaborationMode) {
|
|
23660
|
+
return false;
|
|
23661
|
+
}
|
|
23662
|
+
this.#selection = { ...this.#selection, collaborationMode: mode };
|
|
23663
|
+
return true;
|
|
23664
|
+
};
|
|
23665
|
+
turnParameters = () => {
|
|
23666
|
+
const selection = this.#selection;
|
|
23667
|
+
const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
|
|
23668
|
+
const supportsFast = this.#model(selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) === true;
|
|
23669
|
+
return {
|
|
23670
|
+
// Until a mode is chosen, `config.toml` decides the sandbox and approval
|
|
23671
|
+
// policy, and those fields stay off the turn so the host's own setup is
|
|
23672
|
+
// inherited rather than overridden.
|
|
23673
|
+
...this.#policySelected ? {
|
|
23674
|
+
approvalPolicy: mode.approvalPolicy,
|
|
23675
|
+
approvalsReviewer: mode.approvalsReviewer,
|
|
23676
|
+
sandboxPolicy: mode.sandboxPolicy
|
|
23677
|
+
} : {},
|
|
23678
|
+
// The collaboration mode rides on the turn: Codex applies it to the
|
|
23679
|
+
// thread, where it persists until changed. "Build" is Codex's `default`
|
|
23680
|
+
// mode, so it is only sent once a choice exists to apply.
|
|
23681
|
+
...this.#collaborationModeSupported && (selection.collaborationMode !== "default" || this.#collaborationModeSelected) ? {
|
|
23682
|
+
collaborationMode: {
|
|
23683
|
+
mode: selection.collaborationMode,
|
|
23684
|
+
settings: {
|
|
23685
|
+
developer_instructions: null,
|
|
23686
|
+
model: selection.model,
|
|
23687
|
+
reasoning_effort: selection.effort.length === 0 ? null : selection.effort
|
|
23688
|
+
}
|
|
23689
|
+
}
|
|
23690
|
+
} : {},
|
|
23691
|
+
...selection.effort.length === 0 ? {} : { effort: selection.effort },
|
|
23692
|
+
...selection.model.length === 0 ? {} : { model: selection.model },
|
|
23693
|
+
...selection.fastMode && supportsFast ? { serviceTier: SERVICE_TIER_FAST } : {}
|
|
23694
|
+
};
|
|
23695
|
+
};
|
|
23696
|
+
loadModels = async (signal) => {
|
|
23697
|
+
const models = [];
|
|
23698
|
+
let cursor = null;
|
|
23699
|
+
try {
|
|
23700
|
+
do {
|
|
23701
|
+
const decoded = modelListResponseSchema.parse(
|
|
23702
|
+
await this.#appServer.request(
|
|
23703
|
+
"model/list",
|
|
23704
|
+
{ cursor, limit: null },
|
|
23705
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
23706
|
+
)
|
|
23707
|
+
);
|
|
23708
|
+
models.push(...decoded.data);
|
|
23709
|
+
cursor = decoded.nextCursor ?? null;
|
|
23710
|
+
} while (cursor !== null && models.length < MODEL_CATALOG_LIMIT);
|
|
23711
|
+
} catch (error62) {
|
|
23712
|
+
signal.throwIfAborted();
|
|
23713
|
+
process.stderr.write(`[codex-acp] model catalog unavailable: ${String(error62)}
|
|
23714
|
+
`);
|
|
23715
|
+
}
|
|
23716
|
+
this.#models = Object.freeze(models.slice(0, MODEL_CATALOG_LIMIT));
|
|
23717
|
+
};
|
|
23718
|
+
#model = (id) => this.#models.find((model) => model.id === id);
|
|
23719
|
+
/**
|
|
23720
|
+
* Learns, once per app-server, whether collaboration mode can be applied. An empty settings
|
|
23721
|
+
* update is a no-op on a supporting Codex; an older Codex answers an error, which costs the
|
|
23722
|
+
* Build/Plan selector alone without changing a restored thread's persisted mode.
|
|
23723
|
+
*/
|
|
23724
|
+
probeCollaborationMode = async (threadId, signal) => {
|
|
23725
|
+
if (this.#collaborationModeSupported !== null) {
|
|
23726
|
+
return;
|
|
23727
|
+
}
|
|
23728
|
+
try {
|
|
23729
|
+
await this.#appServer.request(
|
|
23730
|
+
"thread/settings/update",
|
|
23731
|
+
{ threadId },
|
|
23732
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
23733
|
+
);
|
|
23734
|
+
this.#collaborationModeSupported = true;
|
|
23735
|
+
} catch {
|
|
23736
|
+
signal.throwIfAborted();
|
|
23737
|
+
this.#collaborationModeSupported = false;
|
|
23738
|
+
}
|
|
23739
|
+
};
|
|
23740
|
+
/** The ACP settings Mobius discovers and renders in Run settings. */
|
|
23741
|
+
configOptions = () => {
|
|
23742
|
+
const options = [];
|
|
23743
|
+
const model = modelSetting(this.#models, this.#selection.model);
|
|
23744
|
+
if (model !== null) {
|
|
23745
|
+
options.push(model);
|
|
23746
|
+
}
|
|
23747
|
+
const effort = effortSetting(this.#model(this.#selection.model), this.#selection.effort);
|
|
23748
|
+
if (effort !== null) {
|
|
23749
|
+
options.push(effort);
|
|
23750
|
+
}
|
|
23751
|
+
const fastMode = fastModeSetting(this.#model(this.#selection.model), this.#selection.fastMode);
|
|
23752
|
+
if (fastMode !== null) {
|
|
23753
|
+
options.push(fastMode);
|
|
23754
|
+
}
|
|
23755
|
+
if (this.#collaborationModeSupported === true) {
|
|
23756
|
+
options.push(collaborationModeSetting(this.#selection.collaborationMode));
|
|
23757
|
+
}
|
|
23758
|
+
options.push(modeSetting(this.#selection.mode));
|
|
23759
|
+
return options;
|
|
23760
|
+
};
|
|
23761
|
+
selectRestoredThread = (thread) => {
|
|
23762
|
+
const supported = supportedSelection(
|
|
23763
|
+
this.#models,
|
|
23764
|
+
thread.model ?? this.#selection.model,
|
|
23765
|
+
thread.reasoningEffort ?? this.#selection.effort
|
|
23766
|
+
);
|
|
23767
|
+
this.#selection = {
|
|
23768
|
+
...this.#selection,
|
|
23769
|
+
...supported,
|
|
23770
|
+
fastMode: thread.serviceTier === SERVICE_TIER_FAST
|
|
23771
|
+
};
|
|
23772
|
+
};
|
|
23773
|
+
/**
|
|
23774
|
+
* Applies one `session/set_config_option`. Switching models re-resolves the effort the way Codex
|
|
23775
|
+
* does — the current effort when the new model supports it, otherwise the model's own default —
|
|
23776
|
+
* so the reply never advertises an effort the selected model cannot run.
|
|
23777
|
+
*/
|
|
23778
|
+
applySelection = (configId, value) => {
|
|
23779
|
+
if (configId === FAST_MODE_SETTING_ID) {
|
|
23780
|
+
if (typeof value !== "boolean") {
|
|
23781
|
+
throw new AcpExecutionError(
|
|
23782
|
+
"The requested Codex setting is invalid",
|
|
23783
|
+
{},
|
|
23784
|
+
"invalid_session_configuration"
|
|
23785
|
+
);
|
|
23786
|
+
}
|
|
23787
|
+
if (value && this.#model(this.#selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
|
|
23788
|
+
throw new AcpExecutionError(
|
|
23789
|
+
"The selected Codex model has no fast mode",
|
|
23790
|
+
{},
|
|
23791
|
+
"invalid_session_configuration"
|
|
23792
|
+
);
|
|
23793
|
+
}
|
|
23794
|
+
this.#selection = { ...this.#selection, fastMode: value };
|
|
23795
|
+
return;
|
|
23796
|
+
}
|
|
23797
|
+
if (typeof value !== "string") {
|
|
23798
|
+
throw new AcpExecutionError("The requested Codex setting is invalid", {}, "invalid_session_configuration");
|
|
23799
|
+
}
|
|
23800
|
+
if (configId === MODE_SETTING_ID) {
|
|
23801
|
+
if (!AGENT_MODES.some((mode) => mode.id === value)) {
|
|
23802
|
+
throw new AcpExecutionError(
|
|
23803
|
+
"The requested Codex mode is unavailable",
|
|
23804
|
+
{},
|
|
23805
|
+
"invalid_session_configuration"
|
|
23806
|
+
);
|
|
23807
|
+
}
|
|
23808
|
+
this.#selection = { ...this.#selection, mode: value };
|
|
23809
|
+
this.#policySelected = true;
|
|
23810
|
+
return;
|
|
23811
|
+
}
|
|
23812
|
+
if (configId === COLLABORATION_MODE_SETTING_ID) {
|
|
23813
|
+
if (!COLLABORATION_MODES.some((mode) => mode.value === value)) {
|
|
23814
|
+
throw new AcpExecutionError(
|
|
23815
|
+
"The requested Codex collaboration mode is unavailable",
|
|
23816
|
+
{},
|
|
23817
|
+
"invalid_session_configuration"
|
|
23818
|
+
);
|
|
23819
|
+
}
|
|
23820
|
+
this.#selection = { ...this.#selection, collaborationMode: value };
|
|
23821
|
+
this.#collaborationModeSelected = true;
|
|
23822
|
+
return;
|
|
23823
|
+
}
|
|
23824
|
+
if (configId === MODEL_SETTING_ID) {
|
|
23825
|
+
if (value === this.#selection.model) {
|
|
23826
|
+
return;
|
|
23827
|
+
}
|
|
23828
|
+
const model = this.#model(value);
|
|
23829
|
+
if (model === void 0) {
|
|
23830
|
+
throw new AcpExecutionError(
|
|
23831
|
+
"The requested Codex model is unavailable",
|
|
23832
|
+
{},
|
|
23833
|
+
"invalid_session_configuration"
|
|
23834
|
+
);
|
|
23835
|
+
}
|
|
23836
|
+
const supported = (model.supportedReasoningEfforts ?? []).map((option) => option.reasoningEffort);
|
|
23837
|
+
const effort = supported.includes(this.#selection.effort) ? this.#selection.effort : model.defaultReasoningEffort ?? supported[0] ?? "";
|
|
23838
|
+
this.#selection = {
|
|
23839
|
+
...this.#selection,
|
|
23840
|
+
effort,
|
|
23841
|
+
fastMode: this.#selection.fastMode && model.additionalSpeedTiers?.includes(FAST_TIER) === true,
|
|
23842
|
+
model: value
|
|
23843
|
+
};
|
|
23844
|
+
return;
|
|
23845
|
+
}
|
|
23846
|
+
if (configId === REASONING_EFFORT_SETTING_ID) {
|
|
23847
|
+
const supported = (this.#model(this.#selection.model)?.supportedReasoningEfforts ?? []).map(
|
|
23848
|
+
(option) => option.reasoningEffort
|
|
23849
|
+
);
|
|
23850
|
+
if (!supported.includes(value)) {
|
|
23851
|
+
throw new AcpExecutionError(
|
|
23852
|
+
"The requested Codex reasoning effort is unavailable",
|
|
23853
|
+
{},
|
|
23854
|
+
"invalid_session_configuration"
|
|
23855
|
+
);
|
|
23856
|
+
}
|
|
23857
|
+
this.#selection = { ...this.#selection, effort: value };
|
|
23858
|
+
return;
|
|
23859
|
+
}
|
|
23860
|
+
throw new AcpExecutionError("The requested Codex setting is unavailable", {}, "invalid_session_configuration");
|
|
23861
|
+
};
|
|
23862
|
+
};
|
|
23863
|
+
|
|
23864
|
+
// src/acp/codex/agent.ts
|
|
23865
|
+
var APPROVAL_REASON_CHARACTER_LIMIT = 500;
|
|
23866
|
+
var APPROVAL_TIMEOUT_MILLISECONDS2 = 36e5;
|
|
23867
|
+
var CODEX_AGENT_VERSION = "0.154.0";
|
|
23868
|
+
var SESSION_LIST_TIMEOUT_MILLISECONDS = 3e4;
|
|
23869
|
+
var CODEX_COMMANDS = Object.freeze([{ description: "Compact the conversation context", name: "compact" }]);
|
|
23870
|
+
var APPROVAL_OPTIONS = Object.freeze([
|
|
23871
|
+
{ kind: "allow_once", name: "Allow once", optionId: "accept" },
|
|
23872
|
+
{ kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
|
|
23873
|
+
{ kind: "reject_once", name: "Deny", optionId: "decline" }
|
|
23874
|
+
]);
|
|
23875
|
+
function permissionDecision(optionId) {
|
|
23876
|
+
if (optionId === "accept" || optionId === "acceptForSession" || optionId === "decline") {
|
|
23877
|
+
return optionId;
|
|
23878
|
+
}
|
|
23879
|
+
return "cancel";
|
|
23880
|
+
}
|
|
23881
|
+
function promptInput(prompt) {
|
|
23882
|
+
const input2 = [];
|
|
23883
|
+
for (const block of prompt) {
|
|
23884
|
+
if (block.type === "text") {
|
|
23885
|
+
input2.push({ text: block.text, text_elements: [], type: "text" });
|
|
23886
|
+
continue;
|
|
23887
|
+
}
|
|
23888
|
+
if (block.type === "image") {
|
|
23889
|
+
input2.push({ type: "image", url: `data:${block.mimeType};base64,${block.data}` });
|
|
23890
|
+
continue;
|
|
23891
|
+
}
|
|
23892
|
+
if (block.type === "resource") {
|
|
23893
|
+
const resource = block.resource;
|
|
23894
|
+
input2.push({
|
|
23895
|
+
text: "text" in resource ? resource.text ?? "" : "",
|
|
23896
|
+
text_elements: [],
|
|
23897
|
+
type: "text"
|
|
23898
|
+
});
|
|
23899
|
+
continue;
|
|
23900
|
+
}
|
|
23901
|
+
if (block.type === "resource_link") {
|
|
23902
|
+
input2.push({ text: `Resource: ${block.uri}`, text_elements: [], type: "text" });
|
|
23903
|
+
}
|
|
23904
|
+
}
|
|
23905
|
+
return input2;
|
|
23906
|
+
}
|
|
23907
|
+
function isCompactPrompt(prompt) {
|
|
23908
|
+
return prompt.length === 1 && prompt[0]?.type === "text" && prompt[0].text.trim() === "/compact";
|
|
23909
|
+
}
|
|
23910
|
+
function steeringPromptInput(prompt) {
|
|
23911
|
+
const input2 = [];
|
|
23912
|
+
for (const block of prompt) {
|
|
23913
|
+
if (typeof block !== "object" || block === null) {
|
|
23914
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
23915
|
+
}
|
|
23916
|
+
const type = Reflect.get(block, "type");
|
|
23917
|
+
if (type === "text") {
|
|
23918
|
+
const text2 = Reflect.get(block, "text");
|
|
23919
|
+
if (typeof text2 !== "string") {
|
|
23920
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
23921
|
+
}
|
|
23922
|
+
input2.push({ text: text2, text_elements: [], type: "text" });
|
|
23923
|
+
continue;
|
|
23924
|
+
}
|
|
23925
|
+
if (type === "image") {
|
|
23926
|
+
const data = Reflect.get(block, "data");
|
|
23927
|
+
const mimeType = Reflect.get(block, "mimeType");
|
|
23928
|
+
if (typeof data !== "string" || typeof mimeType !== "string") {
|
|
23929
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
23930
|
+
}
|
|
23931
|
+
input2.push({ type: "image", url: `data:${mimeType};base64,${data}` });
|
|
23932
|
+
continue;
|
|
23933
|
+
}
|
|
23934
|
+
if (type === "resource") {
|
|
23935
|
+
const resource = Reflect.get(block, "resource");
|
|
23936
|
+
if (typeof resource !== "object" || resource === null) {
|
|
23937
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
23938
|
+
}
|
|
23939
|
+
const text2 = Reflect.get(resource, "text");
|
|
23940
|
+
if (text2 !== void 0 && typeof text2 !== "string") {
|
|
23941
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
23942
|
+
}
|
|
23943
|
+
input2.push({ text: text2 ?? "", text_elements: [], type: "text" });
|
|
23944
|
+
continue;
|
|
23945
|
+
}
|
|
23946
|
+
if (type === "resource_link") {
|
|
23947
|
+
const uri = Reflect.get(block, "uri");
|
|
23948
|
+
if (typeof uri !== "string") {
|
|
23949
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
23950
|
+
}
|
|
23951
|
+
input2.push({ text: `Resource: ${uri}`, text_elements: [], type: "text" });
|
|
23952
|
+
continue;
|
|
23953
|
+
}
|
|
23954
|
+
throw new AcpExecutionError("Codex received an unsupported steering prompt", {}, "invalid_request");
|
|
23706
23955
|
}
|
|
23707
|
-
return
|
|
23708
|
-
category: "thought_level",
|
|
23709
|
-
currentValue: current,
|
|
23710
|
-
description: "How much reasoning effort the model should use",
|
|
23711
|
-
id: REASONING_EFFORT_SETTING_ID,
|
|
23712
|
-
name: "Reasoning effort",
|
|
23713
|
-
options: values,
|
|
23714
|
-
type: "select"
|
|
23715
|
-
};
|
|
23956
|
+
return input2;
|
|
23716
23957
|
}
|
|
23717
23958
|
function userInputSchema(questions) {
|
|
23718
23959
|
const properties = {};
|
|
@@ -23740,31 +23981,13 @@ var CodexAcpAgent = class {
|
|
|
23740
23981
|
terminated;
|
|
23741
23982
|
#closePromise = null;
|
|
23742
23983
|
#connection = null;
|
|
23743
|
-
#
|
|
23984
|
+
#settings;
|
|
23744
23985
|
#nativeSessionId = "";
|
|
23745
|
-
// Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
|
|
23746
|
-
// configuration decides, so `turn/start` omits the fields and inherits what the host set up.
|
|
23747
|
-
#policySelected = false;
|
|
23748
|
-
// Whether a collaboration mode choice has been made in this session. A restored thread keeps
|
|
23749
|
-
// the mode Codex already persisted, so the first turn does not reset it to Build.
|
|
23750
|
-
#collaborationModeSelected = false;
|
|
23751
|
-
// Whether the app-server accepts collaboration mode on `turn/start`, probed once per
|
|
23752
|
-
// app-server. An older Codex rejects the experimental field, and the setting must disappear
|
|
23753
|
-
// rather than break every turn.
|
|
23754
|
-
#collaborationModeSupported = null;
|
|
23755
|
-
#selection;
|
|
23756
23986
|
#streamedReasoningItemIds = /* @__PURE__ */ new Set();
|
|
23757
23987
|
#turn = null;
|
|
23758
23988
|
#nativeTurnId = null;
|
|
23759
23989
|
#updateTail = Promise.resolve();
|
|
23760
23990
|
constructor(options) {
|
|
23761
|
-
this.#selection = {
|
|
23762
|
-
collaborationMode: "default",
|
|
23763
|
-
effort: "",
|
|
23764
|
-
fastMode: false,
|
|
23765
|
-
mode: initialMode(options.environment),
|
|
23766
|
-
model: ""
|
|
23767
|
-
};
|
|
23768
23991
|
this.#appServer = new CodexAppServerClient({
|
|
23769
23992
|
command: options.command,
|
|
23770
23993
|
cwd: options.cwd,
|
|
@@ -23778,6 +24001,7 @@ var CodexAcpAgent = class {
|
|
|
23778
24001
|
}
|
|
23779
24002
|
}
|
|
23780
24003
|
});
|
|
24004
|
+
this.#settings = new CodexSettings(this.#appServer, options.environment);
|
|
23781
24005
|
this.terminated = this.#appServer.terminated;
|
|
23782
24006
|
void this.terminated.then((termination) => {
|
|
23783
24007
|
this.#turn?.completion.reject(acpEndpointTerminationError(termination));
|
|
@@ -23804,39 +24028,34 @@ var CodexAcpAgent = class {
|
|
|
23804
24028
|
await this.#appServer.request(
|
|
23805
24029
|
"thread/start",
|
|
23806
24030
|
{ cwd: context.params.cwd },
|
|
23807
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
24031
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
23808
24032
|
)
|
|
23809
24033
|
);
|
|
23810
24034
|
this.#nativeSessionId = created.thread.id;
|
|
23811
|
-
|
|
23812
|
-
this.#
|
|
23813
|
-
...this.#selection,
|
|
23814
|
-
collaborationMode: "default",
|
|
23815
|
-
...supported
|
|
23816
|
-
};
|
|
23817
|
-
this.#collaborationModeSelected = false;
|
|
23818
|
-
await this.#probeCollaborationMode(context.signal);
|
|
24035
|
+
this.#settings.selectNewThread(created);
|
|
24036
|
+
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
23819
24037
|
await this.#emitAvailableCommands();
|
|
23820
|
-
return { configOptions: this.#configOptions(), sessionId: created.thread.id };
|
|
24038
|
+
return { configOptions: this.#settings.configOptions(), sessionId: created.thread.id };
|
|
23821
24039
|
}).onRequest(methods.agent.session.setConfigOption, async (context) => {
|
|
23822
|
-
this.#applySelection(context.params.configId, context.params.value);
|
|
23823
|
-
return { configOptions: this.#configOptions() };
|
|
24040
|
+
this.#settings.applySelection(context.params.configId, context.params.value);
|
|
24041
|
+
return { configOptions: this.#settings.configOptions() };
|
|
23824
24042
|
}).onRequest(methods.agent.session.setMode, async (context) => {
|
|
23825
|
-
this.#applySelection(
|
|
24043
|
+
this.#settings.applySelection("mode", context.params.modeId);
|
|
23826
24044
|
return {};
|
|
23827
24045
|
}).onRequest(methods.agent.session.load, async (context) => {
|
|
23828
24046
|
const resumed = threadResumeResponseSchema.parse(
|
|
23829
24047
|
await this.#appServer.request(
|
|
23830
24048
|
"thread/resume",
|
|
23831
24049
|
{ cwd: context.params.cwd, excludeTurns: false, threadId: context.params.sessionId },
|
|
23832
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
24050
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
23833
24051
|
)
|
|
23834
24052
|
);
|
|
23835
|
-
this.#
|
|
23836
|
-
|
|
24053
|
+
this.#nativeSessionId = resumed.thread.id;
|
|
24054
|
+
this.#settings.selectRestoredThread(resumed);
|
|
24055
|
+
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
23837
24056
|
await this.#replayHistory(resumed.turns);
|
|
23838
24057
|
await this.#emitAvailableCommands();
|
|
23839
|
-
return { configOptions: this.#configOptions() };
|
|
24058
|
+
return { configOptions: this.#settings.configOptions() };
|
|
23840
24059
|
}).onRequest(methods.agent.session.fork, async (context) => {
|
|
23841
24060
|
const forked = threadForkResponseSchema.parse(
|
|
23842
24061
|
await this.#appServer.request(
|
|
@@ -23846,26 +24065,28 @@ var CodexAcpAgent = class {
|
|
|
23846
24065
|
excludeTurns: false,
|
|
23847
24066
|
threadId: context.params.sessionId
|
|
23848
24067
|
},
|
|
23849
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
24068
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
23850
24069
|
)
|
|
23851
24070
|
);
|
|
23852
|
-
this.#
|
|
23853
|
-
|
|
24071
|
+
this.#nativeSessionId = forked.thread.id;
|
|
24072
|
+
this.#settings.selectRestoredThread(forked);
|
|
24073
|
+
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
23854
24074
|
await this.#replayHistory(forked.turns);
|
|
23855
24075
|
await this.#emitAvailableCommands();
|
|
23856
|
-
return { configOptions: this.#configOptions(), sessionId: forked.thread.id };
|
|
24076
|
+
return { configOptions: this.#settings.configOptions(), sessionId: forked.thread.id };
|
|
23857
24077
|
}).onRequest(methods.agent.session.resume, async (context) => {
|
|
23858
24078
|
const resumed = threadResumeResponseSchema.parse(
|
|
23859
24079
|
await this.#appServer.request(
|
|
23860
24080
|
"thread/resume",
|
|
23861
24081
|
{ cwd: context.params.cwd, excludeTurns: true, threadId: context.params.sessionId },
|
|
23862
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
24082
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
23863
24083
|
)
|
|
23864
24084
|
);
|
|
23865
|
-
this.#
|
|
23866
|
-
|
|
24085
|
+
this.#nativeSessionId = resumed.thread.id;
|
|
24086
|
+
this.#settings.selectRestoredThread(resumed);
|
|
24087
|
+
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
23867
24088
|
await this.#emitAvailableCommands();
|
|
23868
|
-
return { configOptions: this.#configOptions() };
|
|
24089
|
+
return { configOptions: this.#settings.configOptions() };
|
|
23869
24090
|
}).onRequest(methods.agent.session.prompt, async (context) => {
|
|
23870
24091
|
if (isCompactPrompt(context.params.prompt)) {
|
|
23871
24092
|
return await this.#compact(context.signal);
|
|
@@ -23905,7 +24126,7 @@ var CodexAcpAgent = class {
|
|
|
23905
24126
|
/** Starts the app-server, performs its handshake, and reads the model catalog Codex offers. */
|
|
23906
24127
|
initialize = async (signal) => {
|
|
23907
24128
|
await this.#appServer.initialize(signal);
|
|
23908
|
-
await this.#loadModels(signal);
|
|
24129
|
+
await this.#settings.loadModels(signal);
|
|
23909
24130
|
};
|
|
23910
24131
|
/**
|
|
23911
24132
|
* Releases the app-server and every process it started. Mirrors the adapter path's teardown so a
|
|
@@ -23931,84 +24152,6 @@ var CodexAcpAgent = class {
|
|
|
23931
24152
|
* the Run settings panel its model selector; it must not cost the conversation itself, so the
|
|
23932
24153
|
* turn lifecycle continues without settings rather than failing initialization.
|
|
23933
24154
|
*/
|
|
23934
|
-
#loadModels = async (signal) => {
|
|
23935
|
-
const models = [];
|
|
23936
|
-
let cursor = null;
|
|
23937
|
-
try {
|
|
23938
|
-
do {
|
|
23939
|
-
const decoded = modelListResponseSchema.parse(
|
|
23940
|
-
await this.#appServer.request(
|
|
23941
|
-
"model/list",
|
|
23942
|
-
{ cursor, limit: null },
|
|
23943
|
-
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
23944
|
-
)
|
|
23945
|
-
);
|
|
23946
|
-
models.push(...decoded.data);
|
|
23947
|
-
cursor = decoded.nextCursor ?? null;
|
|
23948
|
-
} while (cursor !== null && models.length < MODEL_CATALOG_LIMIT);
|
|
23949
|
-
} catch (error62) {
|
|
23950
|
-
signal.throwIfAborted();
|
|
23951
|
-
process.stderr.write(`[codex-acp] model catalog unavailable: ${String(error62)}
|
|
23952
|
-
`);
|
|
23953
|
-
}
|
|
23954
|
-
this.#models = Object.freeze(models.slice(0, MODEL_CATALOG_LIMIT));
|
|
23955
|
-
};
|
|
23956
|
-
#model = (id) => this.#models.find((model) => model.id === id);
|
|
23957
|
-
/**
|
|
23958
|
-
* Learns, once per app-server, whether collaboration mode can be applied. An empty settings
|
|
23959
|
-
* update is a no-op on a supporting Codex; an older Codex answers an error, which costs the
|
|
23960
|
-
* Build/Plan selector alone without changing a restored thread's persisted mode.
|
|
23961
|
-
*/
|
|
23962
|
-
#probeCollaborationMode = async (signal) => {
|
|
23963
|
-
if (this.#collaborationModeSupported !== null) {
|
|
23964
|
-
return;
|
|
23965
|
-
}
|
|
23966
|
-
try {
|
|
23967
|
-
await this.#appServer.request(
|
|
23968
|
-
"thread/settings/update",
|
|
23969
|
-
{ threadId: this.#nativeSessionId },
|
|
23970
|
-
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
23971
|
-
);
|
|
23972
|
-
this.#collaborationModeSupported = true;
|
|
23973
|
-
} catch {
|
|
23974
|
-
signal.throwIfAborted();
|
|
23975
|
-
this.#collaborationModeSupported = false;
|
|
23976
|
-
}
|
|
23977
|
-
};
|
|
23978
|
-
/** The ACP settings Mobius discovers and renders in Run settings. */
|
|
23979
|
-
#configOptions = () => {
|
|
23980
|
-
const options = [];
|
|
23981
|
-
const model = modelSetting(this.#models, this.#selection.model);
|
|
23982
|
-
if (model !== null) {
|
|
23983
|
-
options.push(model);
|
|
23984
|
-
}
|
|
23985
|
-
const effort = effortSetting(this.#model(this.#selection.model), this.#selection.effort);
|
|
23986
|
-
if (effort !== null) {
|
|
23987
|
-
options.push(effort);
|
|
23988
|
-
}
|
|
23989
|
-
const fastMode = fastModeSetting(this.#model(this.#selection.model), this.#selection.fastMode);
|
|
23990
|
-
if (fastMode !== null) {
|
|
23991
|
-
options.push(fastMode);
|
|
23992
|
-
}
|
|
23993
|
-
if (this.#collaborationModeSupported === true) {
|
|
23994
|
-
options.push(collaborationModeSetting(this.#selection.collaborationMode));
|
|
23995
|
-
}
|
|
23996
|
-
options.push(modeSetting(this.#selection.mode));
|
|
23997
|
-
return options;
|
|
23998
|
-
};
|
|
23999
|
-
#selectRestoredThread = (thread) => {
|
|
24000
|
-
this.#nativeSessionId = thread.thread.id;
|
|
24001
|
-
const supported = supportedSelection(
|
|
24002
|
-
this.#models,
|
|
24003
|
-
thread.model ?? this.#selection.model,
|
|
24004
|
-
thread.reasoningEffort ?? this.#selection.effort
|
|
24005
|
-
);
|
|
24006
|
-
this.#selection = {
|
|
24007
|
-
...this.#selection,
|
|
24008
|
-
...supported,
|
|
24009
|
-
fastMode: thread.serviceTier === SERVICE_TIER_FAST
|
|
24010
|
-
};
|
|
24011
|
-
};
|
|
24012
24155
|
#replayHistory = async (turns) => {
|
|
24013
24156
|
for (const turn of turns ?? []) {
|
|
24014
24157
|
for (const rawItem of turn.items) {
|
|
@@ -24050,95 +24193,6 @@ var CodexAcpAgent = class {
|
|
|
24050
24193
|
}
|
|
24051
24194
|
}
|
|
24052
24195
|
};
|
|
24053
|
-
/**
|
|
24054
|
-
* Applies one `session/set_config_option`. Switching models re-resolves the effort the way Codex
|
|
24055
|
-
* does — the current effort when the new model supports it, otherwise the model's own default —
|
|
24056
|
-
* so the reply never advertises an effort the selected model cannot run.
|
|
24057
|
-
*/
|
|
24058
|
-
#applySelection = (configId, value) => {
|
|
24059
|
-
if (configId === FAST_MODE_SETTING_ID) {
|
|
24060
|
-
if (typeof value !== "boolean") {
|
|
24061
|
-
throw new AcpExecutionError(
|
|
24062
|
-
"The requested Codex setting is invalid",
|
|
24063
|
-
{},
|
|
24064
|
-
"invalid_session_configuration"
|
|
24065
|
-
);
|
|
24066
|
-
}
|
|
24067
|
-
if (value && this.#model(this.#selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
|
|
24068
|
-
throw new AcpExecutionError(
|
|
24069
|
-
"The selected Codex model has no fast mode",
|
|
24070
|
-
{},
|
|
24071
|
-
"invalid_session_configuration"
|
|
24072
|
-
);
|
|
24073
|
-
}
|
|
24074
|
-
this.#selection = { ...this.#selection, fastMode: value };
|
|
24075
|
-
return;
|
|
24076
|
-
}
|
|
24077
|
-
if (typeof value !== "string") {
|
|
24078
|
-
throw new AcpExecutionError("The requested Codex setting is invalid", {}, "invalid_session_configuration");
|
|
24079
|
-
}
|
|
24080
|
-
if (configId === MODE_SETTING_ID) {
|
|
24081
|
-
if (!AGENT_MODES.some((mode) => mode.id === value)) {
|
|
24082
|
-
throw new AcpExecutionError(
|
|
24083
|
-
"The requested Codex mode is unavailable",
|
|
24084
|
-
{},
|
|
24085
|
-
"invalid_session_configuration"
|
|
24086
|
-
);
|
|
24087
|
-
}
|
|
24088
|
-
this.#selection = { ...this.#selection, mode: value };
|
|
24089
|
-
this.#policySelected = true;
|
|
24090
|
-
return;
|
|
24091
|
-
}
|
|
24092
|
-
if (configId === COLLABORATION_MODE_SETTING_ID) {
|
|
24093
|
-
if (!COLLABORATION_MODES.some((mode) => mode.value === value)) {
|
|
24094
|
-
throw new AcpExecutionError(
|
|
24095
|
-
"The requested Codex collaboration mode is unavailable",
|
|
24096
|
-
{},
|
|
24097
|
-
"invalid_session_configuration"
|
|
24098
|
-
);
|
|
24099
|
-
}
|
|
24100
|
-
this.#selection = { ...this.#selection, collaborationMode: value };
|
|
24101
|
-
this.#collaborationModeSelected = true;
|
|
24102
|
-
return;
|
|
24103
|
-
}
|
|
24104
|
-
if (configId === MODEL_SETTING_ID) {
|
|
24105
|
-
if (value === this.#selection.model) {
|
|
24106
|
-
return;
|
|
24107
|
-
}
|
|
24108
|
-
const model = this.#model(value);
|
|
24109
|
-
if (model === void 0) {
|
|
24110
|
-
throw new AcpExecutionError(
|
|
24111
|
-
"The requested Codex model is unavailable",
|
|
24112
|
-
{},
|
|
24113
|
-
"invalid_session_configuration"
|
|
24114
|
-
);
|
|
24115
|
-
}
|
|
24116
|
-
const supported = (model.supportedReasoningEfforts ?? []).map((option) => option.reasoningEffort);
|
|
24117
|
-
const effort = supported.includes(this.#selection.effort) ? this.#selection.effort : model.defaultReasoningEffort ?? supported[0] ?? "";
|
|
24118
|
-
this.#selection = {
|
|
24119
|
-
...this.#selection,
|
|
24120
|
-
effort,
|
|
24121
|
-
fastMode: this.#selection.fastMode && model.additionalSpeedTiers?.includes(FAST_TIER) === true,
|
|
24122
|
-
model: value
|
|
24123
|
-
};
|
|
24124
|
-
return;
|
|
24125
|
-
}
|
|
24126
|
-
if (configId === REASONING_EFFORT_SETTING_ID) {
|
|
24127
|
-
const supported = (this.#model(this.#selection.model)?.supportedReasoningEfforts ?? []).map(
|
|
24128
|
-
(option) => option.reasoningEffort
|
|
24129
|
-
);
|
|
24130
|
-
if (!supported.includes(value)) {
|
|
24131
|
-
throw new AcpExecutionError(
|
|
24132
|
-
"The requested Codex reasoning effort is unavailable",
|
|
24133
|
-
{},
|
|
24134
|
-
"invalid_session_configuration"
|
|
24135
|
-
);
|
|
24136
|
-
}
|
|
24137
|
-
this.#selection = { ...this.#selection, effort: value };
|
|
24138
|
-
return;
|
|
24139
|
-
}
|
|
24140
|
-
throw new AcpExecutionError("The requested Codex setting is unavailable", {}, "invalid_session_configuration");
|
|
24141
|
-
};
|
|
24142
24196
|
#emit = async (update) => {
|
|
24143
24197
|
const connection = this.#connection;
|
|
24144
24198
|
if (connection === null || this.#nativeSessionId.length === 0) {
|
|
@@ -24163,7 +24217,7 @@ var CodexAcpAgent = class {
|
|
|
24163
24217
|
}
|
|
24164
24218
|
await connection.client.notify(methods.client.session.update, {
|
|
24165
24219
|
sessionId: this.#nativeSessionId,
|
|
24166
|
-
update: { configOptions: this.#configOptions(), sessionUpdate: "config_option_update" }
|
|
24220
|
+
update: { configOptions: this.#settings.configOptions(), sessionUpdate: "config_option_update" }
|
|
24167
24221
|
});
|
|
24168
24222
|
};
|
|
24169
24223
|
// Notifications are serialized so two app-server items cannot interleave into one ACP update
|
|
@@ -24203,8 +24257,7 @@ var CodexAcpAgent = class {
|
|
|
24203
24257
|
const decoded = threadSettingsUpdatedSchema.safeParse(params);
|
|
24204
24258
|
if (decoded.success && decoded.data.threadId === this.#nativeSessionId) {
|
|
24205
24259
|
const mode = decoded.data.threadSettings.collaborationMode?.mode;
|
|
24206
|
-
if (
|
|
24207
|
-
this.#selection = { ...this.#selection, collaborationMode: mode };
|
|
24260
|
+
if (this.#settings.observeCollaborationMode(mode)) {
|
|
24208
24261
|
await this.#enqueue(async () => {
|
|
24209
24262
|
await this.#emitConfigOptionsUpdate();
|
|
24210
24263
|
});
|
|
@@ -24326,7 +24379,7 @@ var CodexAcpAgent = class {
|
|
|
24326
24379
|
const decision = await this.#askPermission(
|
|
24327
24380
|
title2,
|
|
24328
24381
|
params.itemId,
|
|
24329
|
-
AbortSignal.timeout(
|
|
24382
|
+
AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)
|
|
24330
24383
|
);
|
|
24331
24384
|
void turn;
|
|
24332
24385
|
this.#appServer.respond(request.id, { decision });
|
|
@@ -24348,7 +24401,7 @@ var CodexAcpAgent = class {
|
|
|
24348
24401
|
sessionId: this.#nativeSessionId,
|
|
24349
24402
|
...decoded.data.itemId == null ? {} : { toolCallId: decoded.data.itemId }
|
|
24350
24403
|
},
|
|
24351
|
-
{ cancellationSignal: AbortSignal.timeout(
|
|
24404
|
+
{ cancellationSignal: AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2) }
|
|
24352
24405
|
);
|
|
24353
24406
|
const content = response.action === "accept" ? Reflect.get(response, "content") : void 0;
|
|
24354
24407
|
const answers = {};
|
|
@@ -24366,7 +24419,7 @@ var CodexAcpAgent = class {
|
|
|
24366
24419
|
return;
|
|
24367
24420
|
}
|
|
24368
24421
|
const params = decoded.data;
|
|
24369
|
-
const signal = AbortSignal.timeout(
|
|
24422
|
+
const signal = AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2);
|
|
24370
24423
|
if (params.mode === "url" && params.url !== void 0) {
|
|
24371
24424
|
const response2 = await connection.client.request(
|
|
24372
24425
|
methods.client.elicitation.create,
|
|
@@ -24415,38 +24468,12 @@ var CodexAcpAgent = class {
|
|
|
24415
24468
|
this.#turn = turn;
|
|
24416
24469
|
this.#nativeTurnId = null;
|
|
24417
24470
|
try {
|
|
24418
|
-
const selection = this.#selection;
|
|
24419
|
-
const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
|
|
24420
|
-
const supportsFast = this.#model(selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) === true;
|
|
24421
24471
|
const started = turnSchema.parse(
|
|
24422
24472
|
(await this.#appServer.request(
|
|
24423
24473
|
"turn/start",
|
|
24424
24474
|
{
|
|
24425
|
-
|
|
24426
|
-
// policy, and those fields stay off the turn so the host's own setup is
|
|
24427
|
-
// inherited rather than overridden.
|
|
24428
|
-
...this.#policySelected ? {
|
|
24429
|
-
approvalPolicy: mode.approvalPolicy,
|
|
24430
|
-
approvalsReviewer: mode.approvalsReviewer,
|
|
24431
|
-
sandboxPolicy: mode.sandboxPolicy
|
|
24432
|
-
} : {},
|
|
24433
|
-
// The collaboration mode rides on the turn: Codex applies it to the
|
|
24434
|
-
// thread, where it persists until changed. "Build" is Codex's `default`
|
|
24435
|
-
// mode, so it is only sent once a choice exists to apply.
|
|
24436
|
-
...this.#collaborationModeSupported && (selection.collaborationMode !== "default" || this.#collaborationModeSelected) ? {
|
|
24437
|
-
collaborationMode: {
|
|
24438
|
-
mode: selection.collaborationMode,
|
|
24439
|
-
settings: {
|
|
24440
|
-
developer_instructions: null,
|
|
24441
|
-
model: selection.model,
|
|
24442
|
-
reasoning_effort: selection.effort.length === 0 ? null : selection.effort
|
|
24443
|
-
}
|
|
24444
|
-
}
|
|
24445
|
-
} : {},
|
|
24446
|
-
...selection.effort.length === 0 ? {} : { effort: selection.effort },
|
|
24475
|
+
...this.#settings.turnParameters(),
|
|
24447
24476
|
input: input2,
|
|
24448
|
-
...selection.model.length === 0 ? {} : { model: selection.model },
|
|
24449
|
-
...selection.fastMode && supportsFast ? { serviceTier: SERVICE_TIER_FAST } : {},
|
|
24450
24477
|
threadId: this.#nativeSessionId
|
|
24451
24478
|
},
|
|
24452
24479
|
signal
|
|
@@ -24515,7 +24542,7 @@ var CodexAcpAgent = class {
|
|
|
24515
24542
|
await this.#appServer.request(
|
|
24516
24543
|
"turn/steer",
|
|
24517
24544
|
{ expectedTurnId: active.turn.id, input: input2, threadId: this.#nativeSessionId },
|
|
24518
|
-
AbortSignal.any([signal, AbortSignal.timeout(
|
|
24545
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
24519
24546
|
)
|
|
24520
24547
|
);
|
|
24521
24548
|
if (response.turnId !== active.turn.id) {
|
|
@@ -24534,7 +24561,7 @@ var CodexAcpAgent = class {
|
|
|
24534
24561
|
await this.#appServer.request(
|
|
24535
24562
|
"turn/interrupt",
|
|
24536
24563
|
{ threadId: this.#nativeSessionId, turnId: turn.turn.id },
|
|
24537
|
-
AbortSignal.timeout(
|
|
24564
|
+
AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)
|
|
24538
24565
|
);
|
|
24539
24566
|
} catch {
|
|
24540
24567
|
}
|