@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/index.js
CHANGED
|
@@ -33506,11 +33506,8 @@ function agentMessageMeta(phase) {
|
|
|
33506
33506
|
return { [CODEX_META_KEY]: { phase } };
|
|
33507
33507
|
}
|
|
33508
33508
|
|
|
33509
|
-
// src/acp/codex/
|
|
33510
|
-
var APPROVAL_REASON_CHARACTER_LIMIT = 500;
|
|
33509
|
+
// src/acp/codex/settings.ts
|
|
33511
33510
|
var APPROVAL_TIMEOUT_MILLISECONDS = 36e5;
|
|
33512
|
-
var CODEX_AGENT_VERSION = "0.154.0";
|
|
33513
|
-
var SESSION_LIST_TIMEOUT_MILLISECONDS = 3e4;
|
|
33514
33511
|
var MODEL_SETTING_ID = "model";
|
|
33515
33512
|
var REASONING_EFFORT_SETTING_ID = "reasoning_effort";
|
|
33516
33513
|
var MODE_SETTING_ID = "mode";
|
|
@@ -33519,7 +33516,6 @@ var COLLABORATION_MODE_SETTING_ID = "collaboration_mode";
|
|
|
33519
33516
|
var MODEL_CATALOG_LIMIT = 1e3;
|
|
33520
33517
|
var FAST_TIER = "fast";
|
|
33521
33518
|
var SERVICE_TIER_FAST = "priority";
|
|
33522
|
-
var CODEX_COMMANDS = Object.freeze([{ description: "Compact the conversation context", name: "compact" }]);
|
|
33523
33519
|
var WORKSPACE_WRITE_POLICY = Object.freeze({
|
|
33524
33520
|
excludeSlashTmp: false,
|
|
33525
33521
|
excludeTmpdirEnvVar: false,
|
|
@@ -33563,94 +33559,6 @@ function initialMode(environment) {
|
|
|
33563
33559
|
function capitalize(value) {
|
|
33564
33560
|
return value.length === 0 ? value : value.charAt(0).toUpperCase() + value.slice(1);
|
|
33565
33561
|
}
|
|
33566
|
-
var APPROVAL_OPTIONS = Object.freeze([
|
|
33567
|
-
{ kind: "allow_once", name: "Allow once", optionId: "accept" },
|
|
33568
|
-
{ kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
|
|
33569
|
-
{ kind: "reject_once", name: "Deny", optionId: "decline" }
|
|
33570
|
-
]);
|
|
33571
|
-
function permissionDecision(optionId) {
|
|
33572
|
-
if (optionId === "accept" || optionId === "acceptForSession" || optionId === "decline") {
|
|
33573
|
-
return optionId;
|
|
33574
|
-
}
|
|
33575
|
-
return "cancel";
|
|
33576
|
-
}
|
|
33577
|
-
function promptInput(prompt) {
|
|
33578
|
-
const input2 = [];
|
|
33579
|
-
for (const block of prompt) {
|
|
33580
|
-
if (block.type === "text") {
|
|
33581
|
-
input2.push({ text: block.text, text_elements: [], type: "text" });
|
|
33582
|
-
continue;
|
|
33583
|
-
}
|
|
33584
|
-
if (block.type === "image") {
|
|
33585
|
-
input2.push({ type: "image", url: `data:${block.mimeType};base64,${block.data}` });
|
|
33586
|
-
continue;
|
|
33587
|
-
}
|
|
33588
|
-
if (block.type === "resource") {
|
|
33589
|
-
const resource = block.resource;
|
|
33590
|
-
input2.push({
|
|
33591
|
-
text: "text" in resource ? resource.text ?? "" : "",
|
|
33592
|
-
text_elements: [],
|
|
33593
|
-
type: "text"
|
|
33594
|
-
});
|
|
33595
|
-
continue;
|
|
33596
|
-
}
|
|
33597
|
-
if (block.type === "resource_link") {
|
|
33598
|
-
input2.push({ text: `Resource: ${block.uri}`, text_elements: [], type: "text" });
|
|
33599
|
-
}
|
|
33600
|
-
}
|
|
33601
|
-
return input2;
|
|
33602
|
-
}
|
|
33603
|
-
function isCompactPrompt(prompt) {
|
|
33604
|
-
return prompt.length === 1 && prompt[0]?.type === "text" && prompt[0].text.trim() === "/compact";
|
|
33605
|
-
}
|
|
33606
|
-
function steeringPromptInput(prompt) {
|
|
33607
|
-
const input2 = [];
|
|
33608
|
-
for (const block of prompt) {
|
|
33609
|
-
if (typeof block !== "object" || block === null) {
|
|
33610
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
33611
|
-
}
|
|
33612
|
-
const type = Reflect.get(block, "type");
|
|
33613
|
-
if (type === "text") {
|
|
33614
|
-
const text2 = Reflect.get(block, "text");
|
|
33615
|
-
if (typeof text2 !== "string") {
|
|
33616
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
33617
|
-
}
|
|
33618
|
-
input2.push({ text: text2, text_elements: [], type: "text" });
|
|
33619
|
-
continue;
|
|
33620
|
-
}
|
|
33621
|
-
if (type === "image") {
|
|
33622
|
-
const data = Reflect.get(block, "data");
|
|
33623
|
-
const mimeType = Reflect.get(block, "mimeType");
|
|
33624
|
-
if (typeof data !== "string" || typeof mimeType !== "string") {
|
|
33625
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
33626
|
-
}
|
|
33627
|
-
input2.push({ type: "image", url: `data:${mimeType};base64,${data}` });
|
|
33628
|
-
continue;
|
|
33629
|
-
}
|
|
33630
|
-
if (type === "resource") {
|
|
33631
|
-
const resource = Reflect.get(block, "resource");
|
|
33632
|
-
if (typeof resource !== "object" || resource === null) {
|
|
33633
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
33634
|
-
}
|
|
33635
|
-
const text2 = Reflect.get(resource, "text");
|
|
33636
|
-
if (text2 !== void 0 && typeof text2 !== "string") {
|
|
33637
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
33638
|
-
}
|
|
33639
|
-
input2.push({ text: text2 ?? "", text_elements: [], type: "text" });
|
|
33640
|
-
continue;
|
|
33641
|
-
}
|
|
33642
|
-
if (type === "resource_link") {
|
|
33643
|
-
const uri = Reflect.get(block, "uri");
|
|
33644
|
-
if (typeof uri !== "string") {
|
|
33645
|
-
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
33646
|
-
}
|
|
33647
|
-
input2.push({ text: `Resource: ${uri}`, text_elements: [], type: "text" });
|
|
33648
|
-
continue;
|
|
33649
|
-
}
|
|
33650
|
-
throw new AcpExecutionError("Codex received an unsupported steering prompt", {}, "invalid_request");
|
|
33651
|
-
}
|
|
33652
|
-
return input2;
|
|
33653
|
-
}
|
|
33654
33562
|
function modelValues(models) {
|
|
33655
33563
|
return models.map((model) => ({
|
|
33656
33564
|
description: model.description ?? "",
|
|
@@ -33741,19 +33649,352 @@ function effortSetting(model, currentValue) {
|
|
|
33741
33649
|
if (values.length === 0) {
|
|
33742
33650
|
return null;
|
|
33743
33651
|
}
|
|
33744
|
-
const current = values.some((value) => value.value === currentValue) ? currentValue : values[0]?.value ?? "";
|
|
33745
|
-
if (current.length === 0) {
|
|
33746
|
-
return null;
|
|
33652
|
+
const current = values.some((value) => value.value === currentValue) ? currentValue : values[0]?.value ?? "";
|
|
33653
|
+
if (current.length === 0) {
|
|
33654
|
+
return null;
|
|
33655
|
+
}
|
|
33656
|
+
return {
|
|
33657
|
+
category: "thought_level",
|
|
33658
|
+
currentValue: current,
|
|
33659
|
+
description: "How much reasoning effort the model should use",
|
|
33660
|
+
id: REASONING_EFFORT_SETTING_ID,
|
|
33661
|
+
name: "Reasoning effort",
|
|
33662
|
+
options: values,
|
|
33663
|
+
type: "select"
|
|
33664
|
+
};
|
|
33665
|
+
}
|
|
33666
|
+
var CodexSettings = class {
|
|
33667
|
+
#appServer;
|
|
33668
|
+
#models = [];
|
|
33669
|
+
// Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
|
|
33670
|
+
// configuration decides, so `turn/start` omits the fields and inherits what the host set up.
|
|
33671
|
+
#policySelected = false;
|
|
33672
|
+
// Whether a collaboration mode choice has been made in this session. A restored thread keeps
|
|
33673
|
+
// the mode Codex already persisted, so the first turn does not reset it to Build.
|
|
33674
|
+
#collaborationModeSelected = false;
|
|
33675
|
+
// Whether the app-server accepts collaboration mode on `turn/start`, probed once per
|
|
33676
|
+
// app-server. An older Codex rejects the experimental field, and the setting must disappear
|
|
33677
|
+
// rather than break every turn.
|
|
33678
|
+
#collaborationModeSupported = null;
|
|
33679
|
+
#selection;
|
|
33680
|
+
constructor(appServer, environment) {
|
|
33681
|
+
this.#appServer = appServer;
|
|
33682
|
+
this.#selection = {
|
|
33683
|
+
collaborationMode: "default",
|
|
33684
|
+
effort: "",
|
|
33685
|
+
fastMode: false,
|
|
33686
|
+
mode: initialMode(environment),
|
|
33687
|
+
model: ""
|
|
33688
|
+
};
|
|
33689
|
+
}
|
|
33690
|
+
selectNewThread = (created) => {
|
|
33691
|
+
const supported = supportedSelection(this.#models, created.model ?? "", created.reasoningEffort ?? "");
|
|
33692
|
+
this.#selection = {
|
|
33693
|
+
...this.#selection,
|
|
33694
|
+
collaborationMode: "default",
|
|
33695
|
+
...supported
|
|
33696
|
+
};
|
|
33697
|
+
this.#collaborationModeSelected = false;
|
|
33698
|
+
};
|
|
33699
|
+
observeCollaborationMode = (mode) => {
|
|
33700
|
+
if (mode === void 0 || mode === this.#selection.collaborationMode) {
|
|
33701
|
+
return false;
|
|
33702
|
+
}
|
|
33703
|
+
this.#selection = { ...this.#selection, collaborationMode: mode };
|
|
33704
|
+
return true;
|
|
33705
|
+
};
|
|
33706
|
+
turnParameters = () => {
|
|
33707
|
+
const selection = this.#selection;
|
|
33708
|
+
const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
|
|
33709
|
+
const supportsFast = this.#model(selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) === true;
|
|
33710
|
+
return {
|
|
33711
|
+
// Until a mode is chosen, `config.toml` decides the sandbox and approval
|
|
33712
|
+
// policy, and those fields stay off the turn so the host's own setup is
|
|
33713
|
+
// inherited rather than overridden.
|
|
33714
|
+
...this.#policySelected ? {
|
|
33715
|
+
approvalPolicy: mode.approvalPolicy,
|
|
33716
|
+
approvalsReviewer: mode.approvalsReviewer,
|
|
33717
|
+
sandboxPolicy: mode.sandboxPolicy
|
|
33718
|
+
} : {},
|
|
33719
|
+
// The collaboration mode rides on the turn: Codex applies it to the
|
|
33720
|
+
// thread, where it persists until changed. "Build" is Codex's `default`
|
|
33721
|
+
// mode, so it is only sent once a choice exists to apply.
|
|
33722
|
+
...this.#collaborationModeSupported && (selection.collaborationMode !== "default" || this.#collaborationModeSelected) ? {
|
|
33723
|
+
collaborationMode: {
|
|
33724
|
+
mode: selection.collaborationMode,
|
|
33725
|
+
settings: {
|
|
33726
|
+
developer_instructions: null,
|
|
33727
|
+
model: selection.model,
|
|
33728
|
+
reasoning_effort: selection.effort.length === 0 ? null : selection.effort
|
|
33729
|
+
}
|
|
33730
|
+
}
|
|
33731
|
+
} : {},
|
|
33732
|
+
...selection.effort.length === 0 ? {} : { effort: selection.effort },
|
|
33733
|
+
...selection.model.length === 0 ? {} : { model: selection.model },
|
|
33734
|
+
...selection.fastMode && supportsFast ? { serviceTier: SERVICE_TIER_FAST } : {}
|
|
33735
|
+
};
|
|
33736
|
+
};
|
|
33737
|
+
loadModels = async (signal) => {
|
|
33738
|
+
const models = [];
|
|
33739
|
+
let cursor = null;
|
|
33740
|
+
try {
|
|
33741
|
+
do {
|
|
33742
|
+
const decoded = modelListResponseSchema.parse(
|
|
33743
|
+
await this.#appServer.request(
|
|
33744
|
+
"model/list",
|
|
33745
|
+
{ cursor, limit: null },
|
|
33746
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
33747
|
+
)
|
|
33748
|
+
);
|
|
33749
|
+
models.push(...decoded.data);
|
|
33750
|
+
cursor = decoded.nextCursor ?? null;
|
|
33751
|
+
} while (cursor !== null && models.length < MODEL_CATALOG_LIMIT);
|
|
33752
|
+
} catch (error62) {
|
|
33753
|
+
signal.throwIfAborted();
|
|
33754
|
+
process.stderr.write(`[codex-acp] model catalog unavailable: ${String(error62)}
|
|
33755
|
+
`);
|
|
33756
|
+
}
|
|
33757
|
+
this.#models = Object.freeze(models.slice(0, MODEL_CATALOG_LIMIT));
|
|
33758
|
+
};
|
|
33759
|
+
#model = (id) => this.#models.find((model) => model.id === id);
|
|
33760
|
+
/**
|
|
33761
|
+
* Learns, once per app-server, whether collaboration mode can be applied. An empty settings
|
|
33762
|
+
* update is a no-op on a supporting Codex; an older Codex answers an error, which costs the
|
|
33763
|
+
* Build/Plan selector alone without changing a restored thread's persisted mode.
|
|
33764
|
+
*/
|
|
33765
|
+
probeCollaborationMode = async (threadId, signal) => {
|
|
33766
|
+
if (this.#collaborationModeSupported !== null) {
|
|
33767
|
+
return;
|
|
33768
|
+
}
|
|
33769
|
+
try {
|
|
33770
|
+
await this.#appServer.request(
|
|
33771
|
+
"thread/settings/update",
|
|
33772
|
+
{ threadId },
|
|
33773
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
33774
|
+
);
|
|
33775
|
+
this.#collaborationModeSupported = true;
|
|
33776
|
+
} catch {
|
|
33777
|
+
signal.throwIfAborted();
|
|
33778
|
+
this.#collaborationModeSupported = false;
|
|
33779
|
+
}
|
|
33780
|
+
};
|
|
33781
|
+
/** The ACP settings Mobius discovers and renders in Run settings. */
|
|
33782
|
+
configOptions = () => {
|
|
33783
|
+
const options = [];
|
|
33784
|
+
const model = modelSetting(this.#models, this.#selection.model);
|
|
33785
|
+
if (model !== null) {
|
|
33786
|
+
options.push(model);
|
|
33787
|
+
}
|
|
33788
|
+
const effort = effortSetting(this.#model(this.#selection.model), this.#selection.effort);
|
|
33789
|
+
if (effort !== null) {
|
|
33790
|
+
options.push(effort);
|
|
33791
|
+
}
|
|
33792
|
+
const fastMode = fastModeSetting(this.#model(this.#selection.model), this.#selection.fastMode);
|
|
33793
|
+
if (fastMode !== null) {
|
|
33794
|
+
options.push(fastMode);
|
|
33795
|
+
}
|
|
33796
|
+
if (this.#collaborationModeSupported === true) {
|
|
33797
|
+
options.push(collaborationModeSetting(this.#selection.collaborationMode));
|
|
33798
|
+
}
|
|
33799
|
+
options.push(modeSetting(this.#selection.mode));
|
|
33800
|
+
return options;
|
|
33801
|
+
};
|
|
33802
|
+
selectRestoredThread = (thread) => {
|
|
33803
|
+
const supported = supportedSelection(
|
|
33804
|
+
this.#models,
|
|
33805
|
+
thread.model ?? this.#selection.model,
|
|
33806
|
+
thread.reasoningEffort ?? this.#selection.effort
|
|
33807
|
+
);
|
|
33808
|
+
this.#selection = {
|
|
33809
|
+
...this.#selection,
|
|
33810
|
+
...supported,
|
|
33811
|
+
fastMode: thread.serviceTier === SERVICE_TIER_FAST
|
|
33812
|
+
};
|
|
33813
|
+
};
|
|
33814
|
+
/**
|
|
33815
|
+
* Applies one `session/set_config_option`. Switching models re-resolves the effort the way Codex
|
|
33816
|
+
* does — the current effort when the new model supports it, otherwise the model's own default —
|
|
33817
|
+
* so the reply never advertises an effort the selected model cannot run.
|
|
33818
|
+
*/
|
|
33819
|
+
applySelection = (configId, value) => {
|
|
33820
|
+
if (configId === FAST_MODE_SETTING_ID) {
|
|
33821
|
+
if (typeof value !== "boolean") {
|
|
33822
|
+
throw new AcpExecutionError(
|
|
33823
|
+
"The requested Codex setting is invalid",
|
|
33824
|
+
{},
|
|
33825
|
+
"invalid_session_configuration"
|
|
33826
|
+
);
|
|
33827
|
+
}
|
|
33828
|
+
if (value && this.#model(this.#selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
|
|
33829
|
+
throw new AcpExecutionError(
|
|
33830
|
+
"The selected Codex model has no fast mode",
|
|
33831
|
+
{},
|
|
33832
|
+
"invalid_session_configuration"
|
|
33833
|
+
);
|
|
33834
|
+
}
|
|
33835
|
+
this.#selection = { ...this.#selection, fastMode: value };
|
|
33836
|
+
return;
|
|
33837
|
+
}
|
|
33838
|
+
if (typeof value !== "string") {
|
|
33839
|
+
throw new AcpExecutionError("The requested Codex setting is invalid", {}, "invalid_session_configuration");
|
|
33840
|
+
}
|
|
33841
|
+
if (configId === MODE_SETTING_ID) {
|
|
33842
|
+
if (!AGENT_MODES.some((mode) => mode.id === value)) {
|
|
33843
|
+
throw new AcpExecutionError(
|
|
33844
|
+
"The requested Codex mode is unavailable",
|
|
33845
|
+
{},
|
|
33846
|
+
"invalid_session_configuration"
|
|
33847
|
+
);
|
|
33848
|
+
}
|
|
33849
|
+
this.#selection = { ...this.#selection, mode: value };
|
|
33850
|
+
this.#policySelected = true;
|
|
33851
|
+
return;
|
|
33852
|
+
}
|
|
33853
|
+
if (configId === COLLABORATION_MODE_SETTING_ID) {
|
|
33854
|
+
if (!COLLABORATION_MODES.some((mode) => mode.value === value)) {
|
|
33855
|
+
throw new AcpExecutionError(
|
|
33856
|
+
"The requested Codex collaboration mode is unavailable",
|
|
33857
|
+
{},
|
|
33858
|
+
"invalid_session_configuration"
|
|
33859
|
+
);
|
|
33860
|
+
}
|
|
33861
|
+
this.#selection = { ...this.#selection, collaborationMode: value };
|
|
33862
|
+
this.#collaborationModeSelected = true;
|
|
33863
|
+
return;
|
|
33864
|
+
}
|
|
33865
|
+
if (configId === MODEL_SETTING_ID) {
|
|
33866
|
+
if (value === this.#selection.model) {
|
|
33867
|
+
return;
|
|
33868
|
+
}
|
|
33869
|
+
const model = this.#model(value);
|
|
33870
|
+
if (model === void 0) {
|
|
33871
|
+
throw new AcpExecutionError(
|
|
33872
|
+
"The requested Codex model is unavailable",
|
|
33873
|
+
{},
|
|
33874
|
+
"invalid_session_configuration"
|
|
33875
|
+
);
|
|
33876
|
+
}
|
|
33877
|
+
const supported = (model.supportedReasoningEfforts ?? []).map((option) => option.reasoningEffort);
|
|
33878
|
+
const effort = supported.includes(this.#selection.effort) ? this.#selection.effort : model.defaultReasoningEffort ?? supported[0] ?? "";
|
|
33879
|
+
this.#selection = {
|
|
33880
|
+
...this.#selection,
|
|
33881
|
+
effort,
|
|
33882
|
+
fastMode: this.#selection.fastMode && model.additionalSpeedTiers?.includes(FAST_TIER) === true,
|
|
33883
|
+
model: value
|
|
33884
|
+
};
|
|
33885
|
+
return;
|
|
33886
|
+
}
|
|
33887
|
+
if (configId === REASONING_EFFORT_SETTING_ID) {
|
|
33888
|
+
const supported = (this.#model(this.#selection.model)?.supportedReasoningEfforts ?? []).map(
|
|
33889
|
+
(option) => option.reasoningEffort
|
|
33890
|
+
);
|
|
33891
|
+
if (!supported.includes(value)) {
|
|
33892
|
+
throw new AcpExecutionError(
|
|
33893
|
+
"The requested Codex reasoning effort is unavailable",
|
|
33894
|
+
{},
|
|
33895
|
+
"invalid_session_configuration"
|
|
33896
|
+
);
|
|
33897
|
+
}
|
|
33898
|
+
this.#selection = { ...this.#selection, effort: value };
|
|
33899
|
+
return;
|
|
33900
|
+
}
|
|
33901
|
+
throw new AcpExecutionError("The requested Codex setting is unavailable", {}, "invalid_session_configuration");
|
|
33902
|
+
};
|
|
33903
|
+
};
|
|
33904
|
+
|
|
33905
|
+
// src/acp/codex/agent.ts
|
|
33906
|
+
var APPROVAL_REASON_CHARACTER_LIMIT = 500;
|
|
33907
|
+
var APPROVAL_TIMEOUT_MILLISECONDS2 = 36e5;
|
|
33908
|
+
var CODEX_AGENT_VERSION = "0.154.0";
|
|
33909
|
+
var SESSION_LIST_TIMEOUT_MILLISECONDS = 3e4;
|
|
33910
|
+
var CODEX_COMMANDS = Object.freeze([{ description: "Compact the conversation context", name: "compact" }]);
|
|
33911
|
+
var APPROVAL_OPTIONS = Object.freeze([
|
|
33912
|
+
{ kind: "allow_once", name: "Allow once", optionId: "accept" },
|
|
33913
|
+
{ kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
|
|
33914
|
+
{ kind: "reject_once", name: "Deny", optionId: "decline" }
|
|
33915
|
+
]);
|
|
33916
|
+
function permissionDecision(optionId) {
|
|
33917
|
+
if (optionId === "accept" || optionId === "acceptForSession" || optionId === "decline") {
|
|
33918
|
+
return optionId;
|
|
33919
|
+
}
|
|
33920
|
+
return "cancel";
|
|
33921
|
+
}
|
|
33922
|
+
function promptInput(prompt) {
|
|
33923
|
+
const input2 = [];
|
|
33924
|
+
for (const block of prompt) {
|
|
33925
|
+
if (block.type === "text") {
|
|
33926
|
+
input2.push({ text: block.text, text_elements: [], type: "text" });
|
|
33927
|
+
continue;
|
|
33928
|
+
}
|
|
33929
|
+
if (block.type === "image") {
|
|
33930
|
+
input2.push({ type: "image", url: `data:${block.mimeType};base64,${block.data}` });
|
|
33931
|
+
continue;
|
|
33932
|
+
}
|
|
33933
|
+
if (block.type === "resource") {
|
|
33934
|
+
const resource = block.resource;
|
|
33935
|
+
input2.push({
|
|
33936
|
+
text: "text" in resource ? resource.text ?? "" : "",
|
|
33937
|
+
text_elements: [],
|
|
33938
|
+
type: "text"
|
|
33939
|
+
});
|
|
33940
|
+
continue;
|
|
33941
|
+
}
|
|
33942
|
+
if (block.type === "resource_link") {
|
|
33943
|
+
input2.push({ text: `Resource: ${block.uri}`, text_elements: [], type: "text" });
|
|
33944
|
+
}
|
|
33945
|
+
}
|
|
33946
|
+
return input2;
|
|
33947
|
+
}
|
|
33948
|
+
function isCompactPrompt(prompt) {
|
|
33949
|
+
return prompt.length === 1 && prompt[0]?.type === "text" && prompt[0].text.trim() === "/compact";
|
|
33950
|
+
}
|
|
33951
|
+
function steeringPromptInput(prompt) {
|
|
33952
|
+
const input2 = [];
|
|
33953
|
+
for (const block of prompt) {
|
|
33954
|
+
if (typeof block !== "object" || block === null) {
|
|
33955
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
33956
|
+
}
|
|
33957
|
+
const type = Reflect.get(block, "type");
|
|
33958
|
+
if (type === "text") {
|
|
33959
|
+
const text2 = Reflect.get(block, "text");
|
|
33960
|
+
if (typeof text2 !== "string") {
|
|
33961
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
33962
|
+
}
|
|
33963
|
+
input2.push({ text: text2, text_elements: [], type: "text" });
|
|
33964
|
+
continue;
|
|
33965
|
+
}
|
|
33966
|
+
if (type === "image") {
|
|
33967
|
+
const data = Reflect.get(block, "data");
|
|
33968
|
+
const mimeType = Reflect.get(block, "mimeType");
|
|
33969
|
+
if (typeof data !== "string" || typeof mimeType !== "string") {
|
|
33970
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
33971
|
+
}
|
|
33972
|
+
input2.push({ type: "image", url: `data:${mimeType};base64,${data}` });
|
|
33973
|
+
continue;
|
|
33974
|
+
}
|
|
33975
|
+
if (type === "resource") {
|
|
33976
|
+
const resource = Reflect.get(block, "resource");
|
|
33977
|
+
if (typeof resource !== "object" || resource === null) {
|
|
33978
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
33979
|
+
}
|
|
33980
|
+
const text2 = Reflect.get(resource, "text");
|
|
33981
|
+
if (text2 !== void 0 && typeof text2 !== "string") {
|
|
33982
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
33983
|
+
}
|
|
33984
|
+
input2.push({ text: text2 ?? "", text_elements: [], type: "text" });
|
|
33985
|
+
continue;
|
|
33986
|
+
}
|
|
33987
|
+
if (type === "resource_link") {
|
|
33988
|
+
const uri = Reflect.get(block, "uri");
|
|
33989
|
+
if (typeof uri !== "string") {
|
|
33990
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
33991
|
+
}
|
|
33992
|
+
input2.push({ text: `Resource: ${uri}`, text_elements: [], type: "text" });
|
|
33993
|
+
continue;
|
|
33994
|
+
}
|
|
33995
|
+
throw new AcpExecutionError("Codex received an unsupported steering prompt", {}, "invalid_request");
|
|
33747
33996
|
}
|
|
33748
|
-
return
|
|
33749
|
-
category: "thought_level",
|
|
33750
|
-
currentValue: current,
|
|
33751
|
-
description: "How much reasoning effort the model should use",
|
|
33752
|
-
id: REASONING_EFFORT_SETTING_ID,
|
|
33753
|
-
name: "Reasoning effort",
|
|
33754
|
-
options: values,
|
|
33755
|
-
type: "select"
|
|
33756
|
-
};
|
|
33997
|
+
return input2;
|
|
33757
33998
|
}
|
|
33758
33999
|
function userInputSchema(questions) {
|
|
33759
34000
|
const properties = {};
|
|
@@ -33781,31 +34022,13 @@ var CodexAcpAgent = class {
|
|
|
33781
34022
|
terminated;
|
|
33782
34023
|
#closePromise = null;
|
|
33783
34024
|
#connection = null;
|
|
33784
|
-
#
|
|
34025
|
+
#settings;
|
|
33785
34026
|
#nativeSessionId = "";
|
|
33786
|
-
// Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
|
|
33787
|
-
// configuration decides, so `turn/start` omits the fields and inherits what the host set up.
|
|
33788
|
-
#policySelected = false;
|
|
33789
|
-
// Whether a collaboration mode choice has been made in this session. A restored thread keeps
|
|
33790
|
-
// the mode Codex already persisted, so the first turn does not reset it to Build.
|
|
33791
|
-
#collaborationModeSelected = false;
|
|
33792
|
-
// Whether the app-server accepts collaboration mode on `turn/start`, probed once per
|
|
33793
|
-
// app-server. An older Codex rejects the experimental field, and the setting must disappear
|
|
33794
|
-
// rather than break every turn.
|
|
33795
|
-
#collaborationModeSupported = null;
|
|
33796
|
-
#selection;
|
|
33797
34027
|
#streamedReasoningItemIds = /* @__PURE__ */ new Set();
|
|
33798
34028
|
#turn = null;
|
|
33799
34029
|
#nativeTurnId = null;
|
|
33800
34030
|
#updateTail = Promise.resolve();
|
|
33801
34031
|
constructor(options) {
|
|
33802
|
-
this.#selection = {
|
|
33803
|
-
collaborationMode: "default",
|
|
33804
|
-
effort: "",
|
|
33805
|
-
fastMode: false,
|
|
33806
|
-
mode: initialMode(options.environment),
|
|
33807
|
-
model: ""
|
|
33808
|
-
};
|
|
33809
34032
|
this.#appServer = new CodexAppServerClient({
|
|
33810
34033
|
command: options.command,
|
|
33811
34034
|
cwd: options.cwd,
|
|
@@ -33819,6 +34042,7 @@ var CodexAcpAgent = class {
|
|
|
33819
34042
|
}
|
|
33820
34043
|
}
|
|
33821
34044
|
});
|
|
34045
|
+
this.#settings = new CodexSettings(this.#appServer, options.environment);
|
|
33822
34046
|
this.terminated = this.#appServer.terminated;
|
|
33823
34047
|
void this.terminated.then((termination) => {
|
|
33824
34048
|
this.#turn?.completion.reject(acpEndpointTerminationError(termination));
|
|
@@ -33845,39 +34069,34 @@ var CodexAcpAgent = class {
|
|
|
33845
34069
|
await this.#appServer.request(
|
|
33846
34070
|
"thread/start",
|
|
33847
34071
|
{ cwd: context.params.cwd },
|
|
33848
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
34072
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
33849
34073
|
)
|
|
33850
34074
|
);
|
|
33851
34075
|
this.#nativeSessionId = created.thread.id;
|
|
33852
|
-
|
|
33853
|
-
this.#
|
|
33854
|
-
...this.#selection,
|
|
33855
|
-
collaborationMode: "default",
|
|
33856
|
-
...supported
|
|
33857
|
-
};
|
|
33858
|
-
this.#collaborationModeSelected = false;
|
|
33859
|
-
await this.#probeCollaborationMode(context.signal);
|
|
34076
|
+
this.#settings.selectNewThread(created);
|
|
34077
|
+
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
33860
34078
|
await this.#emitAvailableCommands();
|
|
33861
|
-
return { configOptions: this.#configOptions(), sessionId: created.thread.id };
|
|
34079
|
+
return { configOptions: this.#settings.configOptions(), sessionId: created.thread.id };
|
|
33862
34080
|
}).onRequest(methods4.agent.session.setConfigOption, async (context) => {
|
|
33863
|
-
this.#applySelection(context.params.configId, context.params.value);
|
|
33864
|
-
return { configOptions: this.#configOptions() };
|
|
34081
|
+
this.#settings.applySelection(context.params.configId, context.params.value);
|
|
34082
|
+
return { configOptions: this.#settings.configOptions() };
|
|
33865
34083
|
}).onRequest(methods4.agent.session.setMode, async (context) => {
|
|
33866
|
-
this.#applySelection(
|
|
34084
|
+
this.#settings.applySelection("mode", context.params.modeId);
|
|
33867
34085
|
return {};
|
|
33868
34086
|
}).onRequest(methods4.agent.session.load, async (context) => {
|
|
33869
34087
|
const resumed = threadResumeResponseSchema.parse(
|
|
33870
34088
|
await this.#appServer.request(
|
|
33871
34089
|
"thread/resume",
|
|
33872
34090
|
{ cwd: context.params.cwd, excludeTurns: false, threadId: context.params.sessionId },
|
|
33873
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
34091
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
33874
34092
|
)
|
|
33875
34093
|
);
|
|
33876
|
-
this.#
|
|
33877
|
-
|
|
34094
|
+
this.#nativeSessionId = resumed.thread.id;
|
|
34095
|
+
this.#settings.selectRestoredThread(resumed);
|
|
34096
|
+
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
33878
34097
|
await this.#replayHistory(resumed.turns);
|
|
33879
34098
|
await this.#emitAvailableCommands();
|
|
33880
|
-
return { configOptions: this.#configOptions() };
|
|
34099
|
+
return { configOptions: this.#settings.configOptions() };
|
|
33881
34100
|
}).onRequest(methods4.agent.session.fork, async (context) => {
|
|
33882
34101
|
const forked = threadForkResponseSchema.parse(
|
|
33883
34102
|
await this.#appServer.request(
|
|
@@ -33887,26 +34106,28 @@ var CodexAcpAgent = class {
|
|
|
33887
34106
|
excludeTurns: false,
|
|
33888
34107
|
threadId: context.params.sessionId
|
|
33889
34108
|
},
|
|
33890
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
34109
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
33891
34110
|
)
|
|
33892
34111
|
);
|
|
33893
|
-
this.#
|
|
33894
|
-
|
|
34112
|
+
this.#nativeSessionId = forked.thread.id;
|
|
34113
|
+
this.#settings.selectRestoredThread(forked);
|
|
34114
|
+
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
33895
34115
|
await this.#replayHistory(forked.turns);
|
|
33896
34116
|
await this.#emitAvailableCommands();
|
|
33897
|
-
return { configOptions: this.#configOptions(), sessionId: forked.thread.id };
|
|
34117
|
+
return { configOptions: this.#settings.configOptions(), sessionId: forked.thread.id };
|
|
33898
34118
|
}).onRequest(methods4.agent.session.resume, async (context) => {
|
|
33899
34119
|
const resumed = threadResumeResponseSchema.parse(
|
|
33900
34120
|
await this.#appServer.request(
|
|
33901
34121
|
"thread/resume",
|
|
33902
34122
|
{ cwd: context.params.cwd, excludeTurns: true, threadId: context.params.sessionId },
|
|
33903
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
34123
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
33904
34124
|
)
|
|
33905
34125
|
);
|
|
33906
|
-
this.#
|
|
33907
|
-
|
|
34126
|
+
this.#nativeSessionId = resumed.thread.id;
|
|
34127
|
+
this.#settings.selectRestoredThread(resumed);
|
|
34128
|
+
await this.#settings.probeCollaborationMode(this.#nativeSessionId, context.signal);
|
|
33908
34129
|
await this.#emitAvailableCommands();
|
|
33909
|
-
return { configOptions: this.#configOptions() };
|
|
34130
|
+
return { configOptions: this.#settings.configOptions() };
|
|
33910
34131
|
}).onRequest(methods4.agent.session.prompt, async (context) => {
|
|
33911
34132
|
if (isCompactPrompt(context.params.prompt)) {
|
|
33912
34133
|
return await this.#compact(context.signal);
|
|
@@ -33946,7 +34167,7 @@ var CodexAcpAgent = class {
|
|
|
33946
34167
|
/** Starts the app-server, performs its handshake, and reads the model catalog Codex offers. */
|
|
33947
34168
|
initialize = async (signal) => {
|
|
33948
34169
|
await this.#appServer.initialize(signal);
|
|
33949
|
-
await this.#loadModels(signal);
|
|
34170
|
+
await this.#settings.loadModels(signal);
|
|
33950
34171
|
};
|
|
33951
34172
|
/**
|
|
33952
34173
|
* Releases the app-server and every process it started. Mirrors the adapter path's teardown so a
|
|
@@ -33972,84 +34193,6 @@ var CodexAcpAgent = class {
|
|
|
33972
34193
|
* the Run settings panel its model selector; it must not cost the conversation itself, so the
|
|
33973
34194
|
* turn lifecycle continues without settings rather than failing initialization.
|
|
33974
34195
|
*/
|
|
33975
|
-
#loadModels = async (signal) => {
|
|
33976
|
-
const models = [];
|
|
33977
|
-
let cursor = null;
|
|
33978
|
-
try {
|
|
33979
|
-
do {
|
|
33980
|
-
const decoded = modelListResponseSchema.parse(
|
|
33981
|
-
await this.#appServer.request(
|
|
33982
|
-
"model/list",
|
|
33983
|
-
{ cursor, limit: null },
|
|
33984
|
-
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
33985
|
-
)
|
|
33986
|
-
);
|
|
33987
|
-
models.push(...decoded.data);
|
|
33988
|
-
cursor = decoded.nextCursor ?? null;
|
|
33989
|
-
} while (cursor !== null && models.length < MODEL_CATALOG_LIMIT);
|
|
33990
|
-
} catch (error62) {
|
|
33991
|
-
signal.throwIfAborted();
|
|
33992
|
-
process.stderr.write(`[codex-acp] model catalog unavailable: ${String(error62)}
|
|
33993
|
-
`);
|
|
33994
|
-
}
|
|
33995
|
-
this.#models = Object.freeze(models.slice(0, MODEL_CATALOG_LIMIT));
|
|
33996
|
-
};
|
|
33997
|
-
#model = (id) => this.#models.find((model) => model.id === id);
|
|
33998
|
-
/**
|
|
33999
|
-
* Learns, once per app-server, whether collaboration mode can be applied. An empty settings
|
|
34000
|
-
* update is a no-op on a supporting Codex; an older Codex answers an error, which costs the
|
|
34001
|
-
* Build/Plan selector alone without changing a restored thread's persisted mode.
|
|
34002
|
-
*/
|
|
34003
|
-
#probeCollaborationMode = async (signal) => {
|
|
34004
|
-
if (this.#collaborationModeSupported !== null) {
|
|
34005
|
-
return;
|
|
34006
|
-
}
|
|
34007
|
-
try {
|
|
34008
|
-
await this.#appServer.request(
|
|
34009
|
-
"thread/settings/update",
|
|
34010
|
-
{ threadId: this.#nativeSessionId },
|
|
34011
|
-
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
34012
|
-
);
|
|
34013
|
-
this.#collaborationModeSupported = true;
|
|
34014
|
-
} catch {
|
|
34015
|
-
signal.throwIfAborted();
|
|
34016
|
-
this.#collaborationModeSupported = false;
|
|
34017
|
-
}
|
|
34018
|
-
};
|
|
34019
|
-
/** The ACP settings Mobius discovers and renders in Run settings. */
|
|
34020
|
-
#configOptions = () => {
|
|
34021
|
-
const options = [];
|
|
34022
|
-
const model = modelSetting(this.#models, this.#selection.model);
|
|
34023
|
-
if (model !== null) {
|
|
34024
|
-
options.push(model);
|
|
34025
|
-
}
|
|
34026
|
-
const effort = effortSetting(this.#model(this.#selection.model), this.#selection.effort);
|
|
34027
|
-
if (effort !== null) {
|
|
34028
|
-
options.push(effort);
|
|
34029
|
-
}
|
|
34030
|
-
const fastMode = fastModeSetting(this.#model(this.#selection.model), this.#selection.fastMode);
|
|
34031
|
-
if (fastMode !== null) {
|
|
34032
|
-
options.push(fastMode);
|
|
34033
|
-
}
|
|
34034
|
-
if (this.#collaborationModeSupported === true) {
|
|
34035
|
-
options.push(collaborationModeSetting(this.#selection.collaborationMode));
|
|
34036
|
-
}
|
|
34037
|
-
options.push(modeSetting(this.#selection.mode));
|
|
34038
|
-
return options;
|
|
34039
|
-
};
|
|
34040
|
-
#selectRestoredThread = (thread) => {
|
|
34041
|
-
this.#nativeSessionId = thread.thread.id;
|
|
34042
|
-
const supported = supportedSelection(
|
|
34043
|
-
this.#models,
|
|
34044
|
-
thread.model ?? this.#selection.model,
|
|
34045
|
-
thread.reasoningEffort ?? this.#selection.effort
|
|
34046
|
-
);
|
|
34047
|
-
this.#selection = {
|
|
34048
|
-
...this.#selection,
|
|
34049
|
-
...supported,
|
|
34050
|
-
fastMode: thread.serviceTier === SERVICE_TIER_FAST
|
|
34051
|
-
};
|
|
34052
|
-
};
|
|
34053
34196
|
#replayHistory = async (turns) => {
|
|
34054
34197
|
for (const turn of turns ?? []) {
|
|
34055
34198
|
for (const rawItem of turn.items) {
|
|
@@ -34091,95 +34234,6 @@ var CodexAcpAgent = class {
|
|
|
34091
34234
|
}
|
|
34092
34235
|
}
|
|
34093
34236
|
};
|
|
34094
|
-
/**
|
|
34095
|
-
* Applies one `session/set_config_option`. Switching models re-resolves the effort the way Codex
|
|
34096
|
-
* does — the current effort when the new model supports it, otherwise the model's own default —
|
|
34097
|
-
* so the reply never advertises an effort the selected model cannot run.
|
|
34098
|
-
*/
|
|
34099
|
-
#applySelection = (configId, value) => {
|
|
34100
|
-
if (configId === FAST_MODE_SETTING_ID) {
|
|
34101
|
-
if (typeof value !== "boolean") {
|
|
34102
|
-
throw new AcpExecutionError(
|
|
34103
|
-
"The requested Codex setting is invalid",
|
|
34104
|
-
{},
|
|
34105
|
-
"invalid_session_configuration"
|
|
34106
|
-
);
|
|
34107
|
-
}
|
|
34108
|
-
if (value && this.#model(this.#selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
|
|
34109
|
-
throw new AcpExecutionError(
|
|
34110
|
-
"The selected Codex model has no fast mode",
|
|
34111
|
-
{},
|
|
34112
|
-
"invalid_session_configuration"
|
|
34113
|
-
);
|
|
34114
|
-
}
|
|
34115
|
-
this.#selection = { ...this.#selection, fastMode: value };
|
|
34116
|
-
return;
|
|
34117
|
-
}
|
|
34118
|
-
if (typeof value !== "string") {
|
|
34119
|
-
throw new AcpExecutionError("The requested Codex setting is invalid", {}, "invalid_session_configuration");
|
|
34120
|
-
}
|
|
34121
|
-
if (configId === MODE_SETTING_ID) {
|
|
34122
|
-
if (!AGENT_MODES.some((mode) => mode.id === value)) {
|
|
34123
|
-
throw new AcpExecutionError(
|
|
34124
|
-
"The requested Codex mode is unavailable",
|
|
34125
|
-
{},
|
|
34126
|
-
"invalid_session_configuration"
|
|
34127
|
-
);
|
|
34128
|
-
}
|
|
34129
|
-
this.#selection = { ...this.#selection, mode: value };
|
|
34130
|
-
this.#policySelected = true;
|
|
34131
|
-
return;
|
|
34132
|
-
}
|
|
34133
|
-
if (configId === COLLABORATION_MODE_SETTING_ID) {
|
|
34134
|
-
if (!COLLABORATION_MODES.some((mode) => mode.value === value)) {
|
|
34135
|
-
throw new AcpExecutionError(
|
|
34136
|
-
"The requested Codex collaboration mode is unavailable",
|
|
34137
|
-
{},
|
|
34138
|
-
"invalid_session_configuration"
|
|
34139
|
-
);
|
|
34140
|
-
}
|
|
34141
|
-
this.#selection = { ...this.#selection, collaborationMode: value };
|
|
34142
|
-
this.#collaborationModeSelected = true;
|
|
34143
|
-
return;
|
|
34144
|
-
}
|
|
34145
|
-
if (configId === MODEL_SETTING_ID) {
|
|
34146
|
-
if (value === this.#selection.model) {
|
|
34147
|
-
return;
|
|
34148
|
-
}
|
|
34149
|
-
const model = this.#model(value);
|
|
34150
|
-
if (model === void 0) {
|
|
34151
|
-
throw new AcpExecutionError(
|
|
34152
|
-
"The requested Codex model is unavailable",
|
|
34153
|
-
{},
|
|
34154
|
-
"invalid_session_configuration"
|
|
34155
|
-
);
|
|
34156
|
-
}
|
|
34157
|
-
const supported = (model.supportedReasoningEfforts ?? []).map((option) => option.reasoningEffort);
|
|
34158
|
-
const effort = supported.includes(this.#selection.effort) ? this.#selection.effort : model.defaultReasoningEffort ?? supported[0] ?? "";
|
|
34159
|
-
this.#selection = {
|
|
34160
|
-
...this.#selection,
|
|
34161
|
-
effort,
|
|
34162
|
-
fastMode: this.#selection.fastMode && model.additionalSpeedTiers?.includes(FAST_TIER) === true,
|
|
34163
|
-
model: value
|
|
34164
|
-
};
|
|
34165
|
-
return;
|
|
34166
|
-
}
|
|
34167
|
-
if (configId === REASONING_EFFORT_SETTING_ID) {
|
|
34168
|
-
const supported = (this.#model(this.#selection.model)?.supportedReasoningEfforts ?? []).map(
|
|
34169
|
-
(option) => option.reasoningEffort
|
|
34170
|
-
);
|
|
34171
|
-
if (!supported.includes(value)) {
|
|
34172
|
-
throw new AcpExecutionError(
|
|
34173
|
-
"The requested Codex reasoning effort is unavailable",
|
|
34174
|
-
{},
|
|
34175
|
-
"invalid_session_configuration"
|
|
34176
|
-
);
|
|
34177
|
-
}
|
|
34178
|
-
this.#selection = { ...this.#selection, effort: value };
|
|
34179
|
-
return;
|
|
34180
|
-
}
|
|
34181
|
-
throw new AcpExecutionError("The requested Codex setting is unavailable", {}, "invalid_session_configuration");
|
|
34182
|
-
};
|
|
34183
34237
|
#emit = async (update) => {
|
|
34184
34238
|
const connection = this.#connection;
|
|
34185
34239
|
if (connection === null || this.#nativeSessionId.length === 0) {
|
|
@@ -34204,7 +34258,7 @@ var CodexAcpAgent = class {
|
|
|
34204
34258
|
}
|
|
34205
34259
|
await connection.client.notify(methods4.client.session.update, {
|
|
34206
34260
|
sessionId: this.#nativeSessionId,
|
|
34207
|
-
update: { configOptions: this.#configOptions(), sessionUpdate: "config_option_update" }
|
|
34261
|
+
update: { configOptions: this.#settings.configOptions(), sessionUpdate: "config_option_update" }
|
|
34208
34262
|
});
|
|
34209
34263
|
};
|
|
34210
34264
|
// Notifications are serialized so two app-server items cannot interleave into one ACP update
|
|
@@ -34244,8 +34298,7 @@ var CodexAcpAgent = class {
|
|
|
34244
34298
|
const decoded = threadSettingsUpdatedSchema.safeParse(params);
|
|
34245
34299
|
if (decoded.success && decoded.data.threadId === this.#nativeSessionId) {
|
|
34246
34300
|
const mode = decoded.data.threadSettings.collaborationMode?.mode;
|
|
34247
|
-
if (
|
|
34248
|
-
this.#selection = { ...this.#selection, collaborationMode: mode };
|
|
34301
|
+
if (this.#settings.observeCollaborationMode(mode)) {
|
|
34249
34302
|
await this.#enqueue(async () => {
|
|
34250
34303
|
await this.#emitConfigOptionsUpdate();
|
|
34251
34304
|
});
|
|
@@ -34367,7 +34420,7 @@ var CodexAcpAgent = class {
|
|
|
34367
34420
|
const decision = await this.#askPermission(
|
|
34368
34421
|
title2,
|
|
34369
34422
|
params.itemId,
|
|
34370
|
-
AbortSignal.timeout(
|
|
34423
|
+
AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)
|
|
34371
34424
|
);
|
|
34372
34425
|
void turn;
|
|
34373
34426
|
this.#appServer.respond(request.id, { decision });
|
|
@@ -34389,7 +34442,7 @@ var CodexAcpAgent = class {
|
|
|
34389
34442
|
sessionId: this.#nativeSessionId,
|
|
34390
34443
|
...decoded.data.itemId == null ? {} : { toolCallId: decoded.data.itemId }
|
|
34391
34444
|
},
|
|
34392
|
-
{ cancellationSignal: AbortSignal.timeout(
|
|
34445
|
+
{ cancellationSignal: AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2) }
|
|
34393
34446
|
);
|
|
34394
34447
|
const content = response.action === "accept" ? Reflect.get(response, "content") : void 0;
|
|
34395
34448
|
const answers = {};
|
|
@@ -34407,7 +34460,7 @@ var CodexAcpAgent = class {
|
|
|
34407
34460
|
return;
|
|
34408
34461
|
}
|
|
34409
34462
|
const params = decoded.data;
|
|
34410
|
-
const signal = AbortSignal.timeout(
|
|
34463
|
+
const signal = AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2);
|
|
34411
34464
|
if (params.mode === "url" && params.url !== void 0) {
|
|
34412
34465
|
const response2 = await connection.client.request(
|
|
34413
34466
|
methods4.client.elicitation.create,
|
|
@@ -34456,38 +34509,12 @@ var CodexAcpAgent = class {
|
|
|
34456
34509
|
this.#turn = turn;
|
|
34457
34510
|
this.#nativeTurnId = null;
|
|
34458
34511
|
try {
|
|
34459
|
-
const selection = this.#selection;
|
|
34460
|
-
const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
|
|
34461
|
-
const supportsFast = this.#model(selection.model)?.additionalSpeedTiers?.includes(FAST_TIER) === true;
|
|
34462
34512
|
const started = turnSchema.parse(
|
|
34463
34513
|
(await this.#appServer.request(
|
|
34464
34514
|
"turn/start",
|
|
34465
34515
|
{
|
|
34466
|
-
|
|
34467
|
-
// policy, and those fields stay off the turn so the host's own setup is
|
|
34468
|
-
// inherited rather than overridden.
|
|
34469
|
-
...this.#policySelected ? {
|
|
34470
|
-
approvalPolicy: mode.approvalPolicy,
|
|
34471
|
-
approvalsReviewer: mode.approvalsReviewer,
|
|
34472
|
-
sandboxPolicy: mode.sandboxPolicy
|
|
34473
|
-
} : {},
|
|
34474
|
-
// The collaboration mode rides on the turn: Codex applies it to the
|
|
34475
|
-
// thread, where it persists until changed. "Build" is Codex's `default`
|
|
34476
|
-
// mode, so it is only sent once a choice exists to apply.
|
|
34477
|
-
...this.#collaborationModeSupported && (selection.collaborationMode !== "default" || this.#collaborationModeSelected) ? {
|
|
34478
|
-
collaborationMode: {
|
|
34479
|
-
mode: selection.collaborationMode,
|
|
34480
|
-
settings: {
|
|
34481
|
-
developer_instructions: null,
|
|
34482
|
-
model: selection.model,
|
|
34483
|
-
reasoning_effort: selection.effort.length === 0 ? null : selection.effort
|
|
34484
|
-
}
|
|
34485
|
-
}
|
|
34486
|
-
} : {},
|
|
34487
|
-
...selection.effort.length === 0 ? {} : { effort: selection.effort },
|
|
34516
|
+
...this.#settings.turnParameters(),
|
|
34488
34517
|
input: input2,
|
|
34489
|
-
...selection.model.length === 0 ? {} : { model: selection.model },
|
|
34490
|
-
...selection.fastMode && supportsFast ? { serviceTier: SERVICE_TIER_FAST } : {},
|
|
34491
34518
|
threadId: this.#nativeSessionId
|
|
34492
34519
|
},
|
|
34493
34520
|
signal
|
|
@@ -34556,7 +34583,7 @@ var CodexAcpAgent = class {
|
|
|
34556
34583
|
await this.#appServer.request(
|
|
34557
34584
|
"turn/steer",
|
|
34558
34585
|
{ expectedTurnId: active.turn.id, input: input2, threadId: this.#nativeSessionId },
|
|
34559
|
-
AbortSignal.any([signal, AbortSignal.timeout(
|
|
34586
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)])
|
|
34560
34587
|
)
|
|
34561
34588
|
);
|
|
34562
34589
|
if (response.turnId !== active.turn.id) {
|
|
@@ -34575,7 +34602,7 @@ var CodexAcpAgent = class {
|
|
|
34575
34602
|
await this.#appServer.request(
|
|
34576
34603
|
"turn/interrupt",
|
|
34577
34604
|
{ threadId: this.#nativeSessionId, turnId: turn.turn.id },
|
|
34578
|
-
AbortSignal.timeout(
|
|
34605
|
+
AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS2)
|
|
34579
34606
|
);
|
|
34580
34607
|
} catch {
|
|
34581
34608
|
}
|