@moxt-ai/mobius 0.0.76 → 0.0.78
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 +199 -106
- package/dist/acp/codex/agent.js.map +1 -1
- package/dist/acp/codex/app-server-client.d.ts.map +1 -1
- package/dist/acp/codex/app-server-client.js +4 -1
- package/dist/acp/codex/app-server-client.js.map +1 -1
- package/dist/acp/codex/app-server-protocol.d.ts +37 -28
- package/dist/acp/codex/app-server-protocol.d.ts.map +1 -1
- package/dist/acp/codex/app-server-protocol.js +37 -22
- package/dist/acp/codex/app-server-protocol.js.map +1 -1
- package/dist/cli.js +236 -105
- package/dist/cli.js.map +3 -3
- package/dist/index.js +235 -104
- package/dist/index.js.map +3 -3
- package/dist/runtime.js +235 -104
- package/dist/runtime.js.map +3 -3
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -21148,10 +21148,29 @@ var threadStartResponseSchema = external_exports.object({
|
|
|
21148
21148
|
serviceTier: boundedText(256).nullish(),
|
|
21149
21149
|
thread: external_exports.object({ id: boundedText(256) })
|
|
21150
21150
|
});
|
|
21151
|
-
var
|
|
21151
|
+
var threadLifecycleResponseSchema = external_exports.object({
|
|
21152
21152
|
model: boundedText(256).nullish(),
|
|
21153
21153
|
reasoningEffort: boundedText(256).nullish(),
|
|
21154
|
-
|
|
21154
|
+
serviceTier: boundedText(256).nullish(),
|
|
21155
|
+
thread: external_exports.object({ id: boundedText(256) }),
|
|
21156
|
+
turns: external_exports.array(
|
|
21157
|
+
external_exports.object({
|
|
21158
|
+
items: external_exports.array(external_exports.unknown()).max(1e5)
|
|
21159
|
+
})
|
|
21160
|
+
).max(1e5).nullish()
|
|
21161
|
+
});
|
|
21162
|
+
var threadResumeResponseSchema = threadLifecycleResponseSchema;
|
|
21163
|
+
var threadForkResponseSchema = threadLifecycleResponseSchema;
|
|
21164
|
+
var threadSummarySchema = external_exports.object({
|
|
21165
|
+
cwd: boundedText(2048),
|
|
21166
|
+
id: boundedText(256),
|
|
21167
|
+
name: boundedText(500).nullish(),
|
|
21168
|
+
preview: boundedText(500).nullish(),
|
|
21169
|
+
updatedAt: external_exports.number().int().nonnegative()
|
|
21170
|
+
});
|
|
21171
|
+
var threadListResponseSchema = external_exports.object({
|
|
21172
|
+
data: external_exports.array(threadSummarySchema).max(500),
|
|
21173
|
+
nextCursor: boundedText(1024).nullish()
|
|
21155
21174
|
});
|
|
21156
21175
|
var reasoningEffortOptionSchema = external_exports.object({
|
|
21157
21176
|
description: boundedText(4096).nullish(),
|
|
@@ -21170,19 +21189,14 @@ var modelListResponseSchema = external_exports.object({
|
|
|
21170
21189
|
data: external_exports.array(modelSchema).max(1e3),
|
|
21171
21190
|
nextCursor: boundedText(1024).nullish()
|
|
21172
21191
|
});
|
|
21173
|
-
var
|
|
21174
|
-
|
|
21175
|
-
|
|
21176
|
-
|
|
21177
|
-
|
|
21178
|
-
|
|
21179
|
-
|
|
21180
|
-
});
|
|
21181
|
-
var threadListResponseSchema = external_exports.object({
|
|
21182
|
-
data: external_exports.array(threadSchema).max(1e4),
|
|
21183
|
-
nextCursor: boundedText(1024).nullish()
|
|
21192
|
+
var threadSettingsUpdatedSchema = external_exports.object({
|
|
21193
|
+
threadId: boundedText(256),
|
|
21194
|
+
threadSettings: external_exports.object({
|
|
21195
|
+
collaborationMode: external_exports.object({
|
|
21196
|
+
mode: external_exports.enum(["default", "plan"])
|
|
21197
|
+
}).nullish()
|
|
21198
|
+
})
|
|
21184
21199
|
});
|
|
21185
|
-
var turnSteerResponseSchema = external_exports.object({ turnId: boundedText(256) });
|
|
21186
21200
|
|
|
21187
21201
|
// src/acp/codex/app-server-client.ts
|
|
21188
21202
|
var INITIALIZE_TIMEOUT_MILLISECONDS = 3e4;
|
|
@@ -21367,7 +21381,10 @@ var CodexAppServerClient = class {
|
|
|
21367
21381
|
initialize = async (signal) => {
|
|
21368
21382
|
await this.request(
|
|
21369
21383
|
"initialize",
|
|
21370
|
-
{
|
|
21384
|
+
{
|
|
21385
|
+
capabilities: { experimentalApi: true },
|
|
21386
|
+
clientInfo: { name: "mobius", version: "1.0.0" }
|
|
21387
|
+
},
|
|
21371
21388
|
AbortSignal.any([signal, AbortSignal.timeout(INITIALIZE_TIMEOUT_MILLISECONDS)])
|
|
21372
21389
|
);
|
|
21373
21390
|
this.notify("initialized", void 0);
|
|
@@ -21522,11 +21539,12 @@ function agentMessageMeta(phase) {
|
|
|
21522
21539
|
var APPROVAL_REASON_CHARACTER_LIMIT = 500;
|
|
21523
21540
|
var APPROVAL_TIMEOUT_MILLISECONDS = 36e5;
|
|
21524
21541
|
var CODEX_AGENT_VERSION = "0.154.0";
|
|
21525
|
-
var
|
|
21542
|
+
var SESSION_LIST_TIMEOUT_MILLISECONDS = 3e4;
|
|
21526
21543
|
var MODEL_SETTING_ID = "model";
|
|
21527
21544
|
var REASONING_EFFORT_SETTING_ID = "reasoning_effort";
|
|
21528
21545
|
var MODE_SETTING_ID = "mode";
|
|
21529
21546
|
var FAST_MODE_SETTING_ID = "fast-mode";
|
|
21547
|
+
var COLLABORATION_MODE_SETTING_ID = "collaboration_mode";
|
|
21530
21548
|
var MODEL_CATALOG_LIMIT = 1e3;
|
|
21531
21549
|
var FAST_TIER = "fast";
|
|
21532
21550
|
var SERVICE_TIER_FAST = "priority";
|
|
@@ -21573,26 +21591,6 @@ function initialMode(environment) {
|
|
|
21573
21591
|
function capitalize(value) {
|
|
21574
21592
|
return value.length === 0 ? value : value.charAt(0).toUpperCase() + value.slice(1);
|
|
21575
21593
|
}
|
|
21576
|
-
function threadTitle(thread) {
|
|
21577
|
-
const named = thread.name?.trim() ?? "";
|
|
21578
|
-
if (named.length > 0) {
|
|
21579
|
-
return named;
|
|
21580
|
-
}
|
|
21581
|
-
return thread.preview?.trim() ?? "";
|
|
21582
|
-
}
|
|
21583
|
-
function isoTimestamp(seconds) {
|
|
21584
|
-
if (seconds == null || !Number.isFinite(seconds)) {
|
|
21585
|
-
return null;
|
|
21586
|
-
}
|
|
21587
|
-
return new Date(seconds * 1e3).toISOString();
|
|
21588
|
-
}
|
|
21589
|
-
function steeringParams(params) {
|
|
21590
|
-
const prompt = typeof params === "object" && params !== null ? Reflect.get(params, "prompt") : void 0;
|
|
21591
|
-
if (!Array.isArray(prompt)) {
|
|
21592
|
-
throw new AcpExecutionError("The steering prompt is invalid", {}, "steering_failed");
|
|
21593
|
-
}
|
|
21594
|
-
return { prompt };
|
|
21595
|
-
}
|
|
21596
21594
|
var APPROVAL_OPTIONS = Object.freeze([
|
|
21597
21595
|
{ kind: "allow_once", name: "Allow once", optionId: "accept" },
|
|
21598
21596
|
{ kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
|
|
@@ -21676,6 +21674,22 @@ function modeSetting(currentValue) {
|
|
|
21676
21674
|
type: "select"
|
|
21677
21675
|
};
|
|
21678
21676
|
}
|
|
21677
|
+
var COLLABORATION_MODES = Object.freeze([
|
|
21678
|
+
{ description: "Codex answers and makes changes directly", name: "Build", value: "default" },
|
|
21679
|
+
{ description: "Codex plans before making changes", name: "Plan", value: "plan" }
|
|
21680
|
+
]);
|
|
21681
|
+
function collaborationModeSetting(currentValue) {
|
|
21682
|
+
const current = COLLABORATION_MODES.some((mode) => mode.value === currentValue) ? currentValue : COLLABORATION_MODES[0]?.value ?? "default";
|
|
21683
|
+
return {
|
|
21684
|
+
category: "collaboration_mode",
|
|
21685
|
+
currentValue: current,
|
|
21686
|
+
description: "How Codex collaborates for subsequent turns",
|
|
21687
|
+
id: COLLABORATION_MODE_SETTING_ID,
|
|
21688
|
+
name: "Collaboration mode",
|
|
21689
|
+
options: [...COLLABORATION_MODES],
|
|
21690
|
+
type: "select"
|
|
21691
|
+
};
|
|
21692
|
+
}
|
|
21679
21693
|
function fastModeSetting(model, enabled) {
|
|
21680
21694
|
if (model?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
|
|
21681
21695
|
return null;
|
|
@@ -21737,11 +21751,19 @@ var CodexAcpAgent = class {
|
|
|
21737
21751
|
// Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
|
|
21738
21752
|
// configuration decides, so `turn/start` omits the fields and inherits what the host set up.
|
|
21739
21753
|
#policySelected = false;
|
|
21754
|
+
// Whether a collaboration mode choice has been made in this session. A restored thread keeps
|
|
21755
|
+
// the mode Codex already persisted, so the first turn does not reset it to Build.
|
|
21756
|
+
#collaborationModeSelected = false;
|
|
21757
|
+
// Whether the app-server accepts collaboration mode on `turn/start`, probed once per
|
|
21758
|
+
// app-server. An older Codex rejects the experimental field, and the setting must disappear
|
|
21759
|
+
// rather than break every turn.
|
|
21760
|
+
#collaborationModeSupported = null;
|
|
21740
21761
|
#selection;
|
|
21741
21762
|
#turn = null;
|
|
21742
21763
|
#updateTail = Promise.resolve();
|
|
21743
21764
|
constructor(options) {
|
|
21744
21765
|
this.#selection = {
|
|
21766
|
+
collaborationMode: "default",
|
|
21745
21767
|
effort: "",
|
|
21746
21768
|
fastMode: false,
|
|
21747
21769
|
mode: initialMode(options.environment),
|
|
@@ -21764,14 +21786,12 @@ var CodexAcpAgent = class {
|
|
|
21764
21786
|
this.#connection = connection;
|
|
21765
21787
|
}).onRequest(methods.agent.initialize, async () => ({
|
|
21766
21788
|
agentCapabilities: {
|
|
21767
|
-
loadSession:
|
|
21789
|
+
loadSession: true,
|
|
21768
21790
|
promptCapabilities: { embeddedContext: true, image: true },
|
|
21769
|
-
sessionCapabilities: { close: {},
|
|
21791
|
+
sessionCapabilities: { close: {}, fork: {}, list: {} }
|
|
21770
21792
|
},
|
|
21771
21793
|
agentInfo: { name: "Codex", version: CODEX_AGENT_VERSION },
|
|
21772
21794
|
authMethods: [],
|
|
21773
|
-
// Mobius reads this to decide whether mid-turn steering can be attempted at all.
|
|
21774
|
-
_meta: { steering: { supported: true } },
|
|
21775
21795
|
protocolVersion: PROTOCOL_VERSION
|
|
21776
21796
|
})).onRequest(methods.agent.session.new, async (context) => {
|
|
21777
21797
|
const created = threadStartResponseSchema.parse(
|
|
@@ -21784,90 +21804,78 @@ var CodexAcpAgent = class {
|
|
|
21784
21804
|
this.#nativeSessionId = created.thread.id;
|
|
21785
21805
|
this.#selection = {
|
|
21786
21806
|
...this.#selection,
|
|
21807
|
+
collaborationMode: "default",
|
|
21787
21808
|
effort: created.reasoningEffort ?? "",
|
|
21788
21809
|
model: created.model ?? ""
|
|
21789
21810
|
};
|
|
21811
|
+
this.#collaborationModeSelected = false;
|
|
21812
|
+
await this.#probeCollaborationMode(context.signal);
|
|
21790
21813
|
return { configOptions: this.#configOptions(), sessionId: created.thread.id };
|
|
21814
|
+
}).onRequest(methods.agent.session.setConfigOption, async (context) => {
|
|
21815
|
+
this.#applySelection(context.params.configId, context.params.value);
|
|
21816
|
+
return { configOptions: this.#configOptions() };
|
|
21817
|
+
}).onRequest(methods.agent.session.setMode, async (context) => {
|
|
21818
|
+
this.#applySelection(MODE_SETTING_ID, context.params.modeId);
|
|
21819
|
+
return {};
|
|
21820
|
+
}).onRequest(methods.agent.session.load, async (context) => {
|
|
21821
|
+
const resumed = threadResumeResponseSchema.parse(
|
|
21822
|
+
await this.#appServer.request(
|
|
21823
|
+
"thread/resume",
|
|
21824
|
+
{ cwd: context.params.cwd, excludeTurns: false, threadId: context.params.sessionId },
|
|
21825
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21826
|
+
)
|
|
21827
|
+
);
|
|
21828
|
+
this.#selectRestoredThread(resumed);
|
|
21829
|
+
await this.#probeCollaborationMode(context.signal);
|
|
21830
|
+
await this.#replayHistory(resumed.turns);
|
|
21831
|
+
return { configOptions: this.#configOptions() };
|
|
21832
|
+
}).onRequest(methods.agent.session.fork, async (context) => {
|
|
21833
|
+
const forked = threadForkResponseSchema.parse(
|
|
21834
|
+
await this.#appServer.request(
|
|
21835
|
+
"thread/fork",
|
|
21836
|
+
{
|
|
21837
|
+
cwd: context.params.cwd,
|
|
21838
|
+
excludeTurns: false,
|
|
21839
|
+
threadId: context.params.sessionId
|
|
21840
|
+
},
|
|
21841
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21842
|
+
)
|
|
21843
|
+
);
|
|
21844
|
+
this.#selectRestoredThread(forked);
|
|
21845
|
+
await this.#probeCollaborationMode(context.signal);
|
|
21846
|
+
await this.#replayHistory(forked.turns);
|
|
21847
|
+
return { configOptions: this.#configOptions(), sessionId: forked.thread.id };
|
|
21791
21848
|
}).onRequest(methods.agent.session.resume, async (context) => {
|
|
21792
21849
|
const resumed = threadResumeResponseSchema.parse(
|
|
21793
21850
|
await this.#appServer.request(
|
|
21794
21851
|
"thread/resume",
|
|
21795
|
-
{ cwd: context.params.cwd, threadId: context.params.sessionId },
|
|
21852
|
+
{ cwd: context.params.cwd, excludeTurns: true, threadId: context.params.sessionId },
|
|
21796
21853
|
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21797
21854
|
)
|
|
21798
21855
|
);
|
|
21799
|
-
|
|
21800
|
-
|
|
21801
|
-
"Codex no longer has the native session this conversation belongs to",
|
|
21802
|
-
{},
|
|
21803
|
-
"session_restore_unsupported"
|
|
21804
|
-
);
|
|
21805
|
-
}
|
|
21806
|
-
this.#nativeSessionId = resumed.thread.id;
|
|
21807
|
-
this.#selection = {
|
|
21808
|
-
...this.#selection,
|
|
21809
|
-
effort: resumed.reasoningEffort ?? this.#selection.effort,
|
|
21810
|
-
model: resumed.model ?? this.#selection.model
|
|
21811
|
-
};
|
|
21856
|
+
this.#selectRestoredThread(resumed);
|
|
21857
|
+
await this.#probeCollaborationMode(context.signal);
|
|
21812
21858
|
return { configOptions: this.#configOptions() };
|
|
21859
|
+
}).onRequest(methods.agent.session.prompt, async (context) => {
|
|
21860
|
+
return await this.#runTurn(promptInput(context.params.prompt), context.signal);
|
|
21813
21861
|
}).onRequest(methods.agent.session.list, async (context) => {
|
|
21814
|
-
const
|
|
21862
|
+
const decoded = threadListResponseSchema.parse(
|
|
21815
21863
|
await this.#appServer.request(
|
|
21816
21864
|
"thread/list",
|
|
21817
|
-
|
|
21818
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
21865
|
+
{ cursor: context.params.cursor ?? null },
|
|
21866
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(SESSION_LIST_TIMEOUT_MILLISECONDS)])
|
|
21819
21867
|
)
|
|
21820
21868
|
);
|
|
21821
21869
|
return {
|
|
21822
|
-
nextCursor:
|
|
21823
|
-
sessions:
|
|
21824
|
-
// The thread id is a UUID, which satisfies the native session id contract.
|
|
21870
|
+
nextCursor: decoded.nextCursor ?? null,
|
|
21871
|
+
sessions: decoded.data.map((thread) => ({
|
|
21825
21872
|
additionalDirectories: [],
|
|
21826
|
-
cwd: thread.cwd
|
|
21873
|
+
cwd: thread.cwd,
|
|
21827
21874
|
sessionId: thread.id,
|
|
21828
|
-
title:
|
|
21829
|
-
updatedAt:
|
|
21875
|
+
title: thread.name ?? thread.preview ?? null,
|
|
21876
|
+
updatedAt: new Date(thread.updatedAt * 1e3).toISOString()
|
|
21830
21877
|
}))
|
|
21831
21878
|
};
|
|
21832
|
-
}).onRequest(methods.agent.session.delete, async (context) => {
|
|
21833
|
-
await this.#appServer.request(
|
|
21834
|
-
"thread/archive",
|
|
21835
|
-
{ threadId: context.params.sessionId },
|
|
21836
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21837
|
-
);
|
|
21838
|
-
return {};
|
|
21839
|
-
}).onRequest(methods.agent.session.setConfigOption, async (context) => {
|
|
21840
|
-
this.#applySelection(context.params.configId, context.params.value);
|
|
21841
|
-
return { configOptions: this.#configOptions() };
|
|
21842
|
-
}).onRequest(methods.agent.session.setMode, async (context) => {
|
|
21843
|
-
this.#applySelection(MODE_SETTING_ID, context.params.modeId);
|
|
21844
|
-
return {};
|
|
21845
|
-
}).onRequest(methods.agent.session.prompt, async (context) => {
|
|
21846
|
-
return await this.#runTurn(promptInput(context.params.prompt), context.signal);
|
|
21847
|
-
}).onRequest(STEERING_METHOD, steeringParams, async (context) => {
|
|
21848
|
-
const turn = this.#turn;
|
|
21849
|
-
if (turn === null || turn.turn.id.length === 0) {
|
|
21850
|
-
return { outcome: "promptRequired" };
|
|
21851
|
-
}
|
|
21852
|
-
try {
|
|
21853
|
-
const steered = turnSteerResponseSchema.parse(
|
|
21854
|
-
await this.#appServer.request(
|
|
21855
|
-
"turn/steer",
|
|
21856
|
-
{
|
|
21857
|
-
expectedTurnId: turn.turn.id,
|
|
21858
|
-
input: promptInput(context.params.prompt),
|
|
21859
|
-
threadId: this.#nativeSessionId
|
|
21860
|
-
},
|
|
21861
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21862
|
-
)
|
|
21863
|
-
);
|
|
21864
|
-
return { outcome: steered.turnId === turn.turn.id ? "injected" : "startedNewTurn" };
|
|
21865
|
-
} catch (error62) {
|
|
21866
|
-
if (error62 instanceof CodexAppServerError) {
|
|
21867
|
-
return { outcome: "promptRequired" };
|
|
21868
|
-
}
|
|
21869
|
-
throw error62;
|
|
21870
|
-
}
|
|
21871
21879
|
}).onRequest(methods.agent.session.close, async () => {
|
|
21872
21880
|
await this.#interruptTurn();
|
|
21873
21881
|
}).onNotification(methods.agent.session.cancel, async () => {
|
|
@@ -21919,6 +21927,27 @@ var CodexAcpAgent = class {
|
|
|
21919
21927
|
this.#models = Object.freeze(models.slice(0, MODEL_CATALOG_LIMIT));
|
|
21920
21928
|
};
|
|
21921
21929
|
#model = (id) => this.#models.find((model) => model.id === id);
|
|
21930
|
+
/**
|
|
21931
|
+
* Learns, once per app-server, whether collaboration mode can be applied. An empty settings
|
|
21932
|
+
* update is a no-op on a supporting Codex; an older Codex answers an error, which costs the
|
|
21933
|
+
* Build/Plan selector alone without changing a restored thread's persisted mode.
|
|
21934
|
+
*/
|
|
21935
|
+
#probeCollaborationMode = async (signal) => {
|
|
21936
|
+
if (this.#collaborationModeSupported !== null) {
|
|
21937
|
+
return;
|
|
21938
|
+
}
|
|
21939
|
+
try {
|
|
21940
|
+
await this.#appServer.request(
|
|
21941
|
+
"thread/settings/update",
|
|
21942
|
+
{ threadId: this.#nativeSessionId },
|
|
21943
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21944
|
+
);
|
|
21945
|
+
this.#collaborationModeSupported = true;
|
|
21946
|
+
} catch {
|
|
21947
|
+
signal.throwIfAborted();
|
|
21948
|
+
this.#collaborationModeSupported = false;
|
|
21949
|
+
}
|
|
21950
|
+
};
|
|
21922
21951
|
/** The ACP settings Mobius discovers and renders in Run settings. */
|
|
21923
21952
|
#configOptions = () => {
|
|
21924
21953
|
const options = [];
|
|
@@ -21934,9 +21963,62 @@ var CodexAcpAgent = class {
|
|
|
21934
21963
|
if (fastMode !== null) {
|
|
21935
21964
|
options.push(fastMode);
|
|
21936
21965
|
}
|
|
21966
|
+
if (this.#collaborationModeSupported === true) {
|
|
21967
|
+
options.push(collaborationModeSetting(this.#selection.collaborationMode));
|
|
21968
|
+
}
|
|
21937
21969
|
options.push(modeSetting(this.#selection.mode));
|
|
21938
21970
|
return options;
|
|
21939
21971
|
};
|
|
21972
|
+
#selectRestoredThread = (thread) => {
|
|
21973
|
+
this.#nativeSessionId = thread.thread.id;
|
|
21974
|
+
this.#selection = {
|
|
21975
|
+
...this.#selection,
|
|
21976
|
+
effort: thread.reasoningEffort ?? this.#selection.effort,
|
|
21977
|
+
model: thread.model ?? this.#selection.model,
|
|
21978
|
+
fastMode: thread.serviceTier === SERVICE_TIER_FAST
|
|
21979
|
+
};
|
|
21980
|
+
};
|
|
21981
|
+
#replayHistory = async (turns) => {
|
|
21982
|
+
for (const turn of turns ?? []) {
|
|
21983
|
+
for (const rawItem of turn.items) {
|
|
21984
|
+
const item = decodeThreadItem(rawItem);
|
|
21985
|
+
if (item === null) {
|
|
21986
|
+
continue;
|
|
21987
|
+
}
|
|
21988
|
+
if (item.type === "userMessage") {
|
|
21989
|
+
const text3 = item.content.flatMap((content3) => {
|
|
21990
|
+
if (typeof content3 !== "object" || content3 === null) {
|
|
21991
|
+
return [];
|
|
21992
|
+
}
|
|
21993
|
+
const type = Reflect.get(content3, "type");
|
|
21994
|
+
const text4 = Reflect.get(content3, "text");
|
|
21995
|
+
return type === "text" && typeof text4 === "string" ? [text4] : [];
|
|
21996
|
+
}).join("");
|
|
21997
|
+
if (text3.length > 0) {
|
|
21998
|
+
await this.#emit({
|
|
21999
|
+
content: { text: text3, type: "text" },
|
|
22000
|
+
messageId: item.id,
|
|
22001
|
+
sessionUpdate: "user_message_chunk"
|
|
22002
|
+
});
|
|
22003
|
+
}
|
|
22004
|
+
continue;
|
|
22005
|
+
}
|
|
22006
|
+
if (item.type === "agentMessage") {
|
|
22007
|
+
await this.#emit({
|
|
22008
|
+
_meta: agentMessageMeta(item.phase),
|
|
22009
|
+
content: { text: item.text, type: "text" },
|
|
22010
|
+
messageId: item.id,
|
|
22011
|
+
sessionUpdate: "agent_message_chunk"
|
|
22012
|
+
});
|
|
22013
|
+
continue;
|
|
22014
|
+
}
|
|
22015
|
+
const update = toolCallUpdate(item);
|
|
22016
|
+
if (update !== null) {
|
|
22017
|
+
await this.#emit({ ...update, sessionUpdate: "tool_call_update" });
|
|
22018
|
+
}
|
|
22019
|
+
}
|
|
22020
|
+
}
|
|
22021
|
+
};
|
|
21940
22022
|
/**
|
|
21941
22023
|
* Applies one `session/set_config_option`. Switching models re-resolves the effort the way Codex
|
|
21942
22024
|
* does — the current effort when the new model supports it, otherwise the model's own default —
|
|
@@ -21976,6 +22058,18 @@ var CodexAcpAgent = class {
|
|
|
21976
22058
|
this.#policySelected = true;
|
|
21977
22059
|
return;
|
|
21978
22060
|
}
|
|
22061
|
+
if (configId === COLLABORATION_MODE_SETTING_ID) {
|
|
22062
|
+
if (!COLLABORATION_MODES.some((mode) => mode.value === value)) {
|
|
22063
|
+
throw new AcpExecutionError(
|
|
22064
|
+
"The requested Codex collaboration mode is unavailable",
|
|
22065
|
+
{},
|
|
22066
|
+
"invalid_session_configuration"
|
|
22067
|
+
);
|
|
22068
|
+
}
|
|
22069
|
+
this.#selection = { ...this.#selection, collaborationMode: value };
|
|
22070
|
+
this.#collaborationModeSelected = true;
|
|
22071
|
+
return;
|
|
22072
|
+
}
|
|
21979
22073
|
if (configId === MODEL_SETTING_ID) {
|
|
21980
22074
|
if (value === this.#selection.model) {
|
|
21981
22075
|
return;
|
|
@@ -22024,6 +22118,17 @@ var CodexAcpAgent = class {
|
|
|
22024
22118
|
update
|
|
22025
22119
|
});
|
|
22026
22120
|
};
|
|
22121
|
+
/** Pushes the current settings so a mode change Codex applied reaches the Run settings panel. */
|
|
22122
|
+
#emitConfigOptionsUpdate = async () => {
|
|
22123
|
+
const connection = this.#connection;
|
|
22124
|
+
if (connection === null || this.#nativeSessionId.length === 0) {
|
|
22125
|
+
return;
|
|
22126
|
+
}
|
|
22127
|
+
await connection.client.notify(methods.client.session.update, {
|
|
22128
|
+
sessionId: this.#nativeSessionId,
|
|
22129
|
+
update: { configOptions: this.#configOptions(), sessionUpdate: "config_option_update" }
|
|
22130
|
+
});
|
|
22131
|
+
};
|
|
22027
22132
|
// Notifications are serialized so two app-server items cannot interleave into one ACP update
|
|
22028
22133
|
// stream, and the caller awaits the result: `turn/completed` must not resolve the prompt before
|
|
22029
22134
|
// the updates it precedes have reached the client.
|
|
@@ -22056,6 +22161,19 @@ var CodexAcpAgent = class {
|
|
|
22056
22161
|
}
|
|
22057
22162
|
return;
|
|
22058
22163
|
}
|
|
22164
|
+
if (method === "thread/settings/updated") {
|
|
22165
|
+
const decoded = threadSettingsUpdatedSchema.safeParse(params);
|
|
22166
|
+
if (decoded.success && decoded.data.threadId === this.#nativeSessionId) {
|
|
22167
|
+
const mode = decoded.data.threadSettings.collaborationMode?.mode;
|
|
22168
|
+
if (mode !== void 0 && mode !== this.#selection.collaborationMode) {
|
|
22169
|
+
this.#selection = { ...this.#selection, collaborationMode: mode };
|
|
22170
|
+
await this.#enqueue(async () => {
|
|
22171
|
+
await this.#emitConfigOptionsUpdate();
|
|
22172
|
+
});
|
|
22173
|
+
}
|
|
22174
|
+
}
|
|
22175
|
+
return;
|
|
22176
|
+
}
|
|
22059
22177
|
if (method === "turn/plan/updated") {
|
|
22060
22178
|
const plan = params.plan;
|
|
22061
22179
|
if (Array.isArray(plan) && params.threadId === this.#nativeSessionId) {
|
|
@@ -22234,6 +22352,19 @@ var CodexAcpAgent = class {
|
|
|
22234
22352
|
approvalsReviewer: mode.approvalsReviewer,
|
|
22235
22353
|
sandboxPolicy: mode.sandboxPolicy
|
|
22236
22354
|
} : {},
|
|
22355
|
+
// The collaboration mode rides on the turn: Codex applies it to the
|
|
22356
|
+
// thread, where it persists until changed. "Build" is Codex's `default`
|
|
22357
|
+
// mode, so it is only sent once a choice exists to apply.
|
|
22358
|
+
...this.#collaborationModeSupported && (selection.collaborationMode !== "default" || this.#collaborationModeSelected) ? {
|
|
22359
|
+
collaborationMode: {
|
|
22360
|
+
mode: selection.collaborationMode,
|
|
22361
|
+
settings: {
|
|
22362
|
+
developer_instructions: null,
|
|
22363
|
+
model: selection.model,
|
|
22364
|
+
reasoning_effort: selection.effort.length === 0 ? null : selection.effort
|
|
22365
|
+
}
|
|
22366
|
+
}
|
|
22367
|
+
} : {},
|
|
22237
22368
|
...selection.effort.length === 0 ? {} : { effort: selection.effort },
|
|
22238
22369
|
input: input2,
|
|
22239
22370
|
...selection.model.length === 0 ? {} : { model: selection.model },
|
|
@@ -38690,7 +38821,7 @@ var responseSchema = external_exports.union([
|
|
|
38690
38821
|
external_exports.object({ id: external_exports.number(), result: external_exports.unknown() }),
|
|
38691
38822
|
external_exports.object({ method: external_exports.string() })
|
|
38692
38823
|
]);
|
|
38693
|
-
var
|
|
38824
|
+
var threadSchema = external_exports.object({
|
|
38694
38825
|
thread: external_exports.object({
|
|
38695
38826
|
id: nativeSessionIdSchema,
|
|
38696
38827
|
cwd: external_exports.string().min(1).max(2048).refine((path2) => !path2.includes("\0"))
|
|
@@ -38994,7 +39125,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
38994
39125
|
});
|
|
38995
39126
|
break;
|
|
38996
39127
|
case "metadata": {
|
|
38997
|
-
const { thread } =
|
|
39128
|
+
const { thread } = threadSchema.parse(message.result);
|
|
38998
39129
|
state = { kind: "turns", requestId: 3, thread };
|
|
38999
39130
|
send2({
|
|
39000
39131
|
id: state.requestId,
|