@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/index.js
CHANGED
|
@@ -34927,10 +34927,29 @@ var threadStartResponseSchema = external_exports.object({
|
|
|
34927
34927
|
serviceTier: boundedText(256).nullish(),
|
|
34928
34928
|
thread: external_exports.object({ id: boundedText(256) })
|
|
34929
34929
|
});
|
|
34930
|
-
var
|
|
34930
|
+
var threadLifecycleResponseSchema = external_exports.object({
|
|
34931
34931
|
model: boundedText(256).nullish(),
|
|
34932
34932
|
reasoningEffort: boundedText(256).nullish(),
|
|
34933
|
-
|
|
34933
|
+
serviceTier: boundedText(256).nullish(),
|
|
34934
|
+
thread: external_exports.object({ id: boundedText(256) }),
|
|
34935
|
+
turns: external_exports.array(
|
|
34936
|
+
external_exports.object({
|
|
34937
|
+
items: external_exports.array(external_exports.unknown()).max(1e5)
|
|
34938
|
+
})
|
|
34939
|
+
).max(1e5).nullish()
|
|
34940
|
+
});
|
|
34941
|
+
var threadResumeResponseSchema = threadLifecycleResponseSchema;
|
|
34942
|
+
var threadForkResponseSchema = threadLifecycleResponseSchema;
|
|
34943
|
+
var threadSummarySchema = external_exports.object({
|
|
34944
|
+
cwd: boundedText(2048),
|
|
34945
|
+
id: boundedText(256),
|
|
34946
|
+
name: boundedText(500).nullish(),
|
|
34947
|
+
preview: boundedText(500).nullish(),
|
|
34948
|
+
updatedAt: external_exports.number().int().nonnegative()
|
|
34949
|
+
});
|
|
34950
|
+
var threadListResponseSchema = external_exports.object({
|
|
34951
|
+
data: external_exports.array(threadSummarySchema).max(500),
|
|
34952
|
+
nextCursor: boundedText(1024).nullish()
|
|
34934
34953
|
});
|
|
34935
34954
|
var reasoningEffortOptionSchema = external_exports.object({
|
|
34936
34955
|
description: boundedText(4096).nullish(),
|
|
@@ -34949,19 +34968,14 @@ var modelListResponseSchema = external_exports.object({
|
|
|
34949
34968
|
data: external_exports.array(modelSchema).max(1e3),
|
|
34950
34969
|
nextCursor: boundedText(1024).nullish()
|
|
34951
34970
|
});
|
|
34952
|
-
var
|
|
34953
|
-
|
|
34954
|
-
|
|
34955
|
-
|
|
34956
|
-
|
|
34957
|
-
|
|
34958
|
-
|
|
34959
|
-
});
|
|
34960
|
-
var threadListResponseSchema = external_exports.object({
|
|
34961
|
-
data: external_exports.array(threadSchema).max(1e4),
|
|
34962
|
-
nextCursor: boundedText(1024).nullish()
|
|
34971
|
+
var threadSettingsUpdatedSchema = external_exports.object({
|
|
34972
|
+
threadId: boundedText(256),
|
|
34973
|
+
threadSettings: external_exports.object({
|
|
34974
|
+
collaborationMode: external_exports.object({
|
|
34975
|
+
mode: external_exports.enum(["default", "plan"])
|
|
34976
|
+
}).nullish()
|
|
34977
|
+
})
|
|
34963
34978
|
});
|
|
34964
|
-
var turnSteerResponseSchema = external_exports.object({ turnId: boundedText(256) });
|
|
34965
34979
|
|
|
34966
34980
|
// src/acp/codex/app-server-client.ts
|
|
34967
34981
|
var INITIALIZE_TIMEOUT_MILLISECONDS = 3e4;
|
|
@@ -35146,7 +35160,10 @@ var CodexAppServerClient = class {
|
|
|
35146
35160
|
initialize = async (signal) => {
|
|
35147
35161
|
await this.request(
|
|
35148
35162
|
"initialize",
|
|
35149
|
-
{
|
|
35163
|
+
{
|
|
35164
|
+
capabilities: { experimentalApi: true },
|
|
35165
|
+
clientInfo: { name: "mobius", version: "1.0.0" }
|
|
35166
|
+
},
|
|
35150
35167
|
AbortSignal.any([signal, AbortSignal.timeout(INITIALIZE_TIMEOUT_MILLISECONDS)])
|
|
35151
35168
|
);
|
|
35152
35169
|
this.notify("initialized", void 0);
|
|
@@ -35301,11 +35318,12 @@ function agentMessageMeta(phase) {
|
|
|
35301
35318
|
var APPROVAL_REASON_CHARACTER_LIMIT = 500;
|
|
35302
35319
|
var APPROVAL_TIMEOUT_MILLISECONDS = 36e5;
|
|
35303
35320
|
var CODEX_AGENT_VERSION = "0.154.0";
|
|
35304
|
-
var
|
|
35321
|
+
var SESSION_LIST_TIMEOUT_MILLISECONDS = 3e4;
|
|
35305
35322
|
var MODEL_SETTING_ID = "model";
|
|
35306
35323
|
var REASONING_EFFORT_SETTING_ID = "reasoning_effort";
|
|
35307
35324
|
var MODE_SETTING_ID = "mode";
|
|
35308
35325
|
var FAST_MODE_SETTING_ID = "fast-mode";
|
|
35326
|
+
var COLLABORATION_MODE_SETTING_ID = "collaboration_mode";
|
|
35309
35327
|
var MODEL_CATALOG_LIMIT = 1e3;
|
|
35310
35328
|
var FAST_TIER = "fast";
|
|
35311
35329
|
var SERVICE_TIER_FAST = "priority";
|
|
@@ -35352,26 +35370,6 @@ function initialMode(environment) {
|
|
|
35352
35370
|
function capitalize(value) {
|
|
35353
35371
|
return value.length === 0 ? value : value.charAt(0).toUpperCase() + value.slice(1);
|
|
35354
35372
|
}
|
|
35355
|
-
function threadTitle(thread) {
|
|
35356
|
-
const named = thread.name?.trim() ?? "";
|
|
35357
|
-
if (named.length > 0) {
|
|
35358
|
-
return named;
|
|
35359
|
-
}
|
|
35360
|
-
return thread.preview?.trim() ?? "";
|
|
35361
|
-
}
|
|
35362
|
-
function isoTimestamp(seconds) {
|
|
35363
|
-
if (seconds == null || !Number.isFinite(seconds)) {
|
|
35364
|
-
return null;
|
|
35365
|
-
}
|
|
35366
|
-
return new Date(seconds * 1e3).toISOString();
|
|
35367
|
-
}
|
|
35368
|
-
function steeringParams(params) {
|
|
35369
|
-
const prompt = typeof params === "object" && params !== null ? Reflect.get(params, "prompt") : void 0;
|
|
35370
|
-
if (!Array.isArray(prompt)) {
|
|
35371
|
-
throw new AcpExecutionError("The steering prompt is invalid", {}, "steering_failed");
|
|
35372
|
-
}
|
|
35373
|
-
return { prompt };
|
|
35374
|
-
}
|
|
35375
35373
|
var APPROVAL_OPTIONS = Object.freeze([
|
|
35376
35374
|
{ kind: "allow_once", name: "Allow once", optionId: "accept" },
|
|
35377
35375
|
{ kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
|
|
@@ -35455,6 +35453,22 @@ function modeSetting(currentValue) {
|
|
|
35455
35453
|
type: "select"
|
|
35456
35454
|
};
|
|
35457
35455
|
}
|
|
35456
|
+
var COLLABORATION_MODES = Object.freeze([
|
|
35457
|
+
{ description: "Codex answers and makes changes directly", name: "Build", value: "default" },
|
|
35458
|
+
{ description: "Codex plans before making changes", name: "Plan", value: "plan" }
|
|
35459
|
+
]);
|
|
35460
|
+
function collaborationModeSetting(currentValue) {
|
|
35461
|
+
const current = COLLABORATION_MODES.some((mode) => mode.value === currentValue) ? currentValue : COLLABORATION_MODES[0]?.value ?? "default";
|
|
35462
|
+
return {
|
|
35463
|
+
category: "collaboration_mode",
|
|
35464
|
+
currentValue: current,
|
|
35465
|
+
description: "How Codex collaborates for subsequent turns",
|
|
35466
|
+
id: COLLABORATION_MODE_SETTING_ID,
|
|
35467
|
+
name: "Collaboration mode",
|
|
35468
|
+
options: [...COLLABORATION_MODES],
|
|
35469
|
+
type: "select"
|
|
35470
|
+
};
|
|
35471
|
+
}
|
|
35458
35472
|
function fastModeSetting(model, enabled) {
|
|
35459
35473
|
if (model?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
|
|
35460
35474
|
return null;
|
|
@@ -35516,11 +35530,19 @@ var CodexAcpAgent = class {
|
|
|
35516
35530
|
// Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
|
|
35517
35531
|
// configuration decides, so `turn/start` omits the fields and inherits what the host set up.
|
|
35518
35532
|
#policySelected = false;
|
|
35533
|
+
// Whether a collaboration mode choice has been made in this session. A restored thread keeps
|
|
35534
|
+
// the mode Codex already persisted, so the first turn does not reset it to Build.
|
|
35535
|
+
#collaborationModeSelected = false;
|
|
35536
|
+
// Whether the app-server accepts collaboration mode on `turn/start`, probed once per
|
|
35537
|
+
// app-server. An older Codex rejects the experimental field, and the setting must disappear
|
|
35538
|
+
// rather than break every turn.
|
|
35539
|
+
#collaborationModeSupported = null;
|
|
35519
35540
|
#selection;
|
|
35520
35541
|
#turn = null;
|
|
35521
35542
|
#updateTail = Promise.resolve();
|
|
35522
35543
|
constructor(options) {
|
|
35523
35544
|
this.#selection = {
|
|
35545
|
+
collaborationMode: "default",
|
|
35524
35546
|
effort: "",
|
|
35525
35547
|
fastMode: false,
|
|
35526
35548
|
mode: initialMode(options.environment),
|
|
@@ -35543,14 +35565,12 @@ var CodexAcpAgent = class {
|
|
|
35543
35565
|
this.#connection = connection;
|
|
35544
35566
|
}).onRequest(methods4.agent.initialize, async () => ({
|
|
35545
35567
|
agentCapabilities: {
|
|
35546
|
-
loadSession:
|
|
35568
|
+
loadSession: true,
|
|
35547
35569
|
promptCapabilities: { embeddedContext: true, image: true },
|
|
35548
|
-
sessionCapabilities: { close: {},
|
|
35570
|
+
sessionCapabilities: { close: {}, fork: {}, list: {} }
|
|
35549
35571
|
},
|
|
35550
35572
|
agentInfo: { name: "Codex", version: CODEX_AGENT_VERSION },
|
|
35551
35573
|
authMethods: [],
|
|
35552
|
-
// Mobius reads this to decide whether mid-turn steering can be attempted at all.
|
|
35553
|
-
_meta: { steering: { supported: true } },
|
|
35554
35574
|
protocolVersion: PROTOCOL_VERSION2
|
|
35555
35575
|
})).onRequest(methods4.agent.session.new, async (context) => {
|
|
35556
35576
|
const created = threadStartResponseSchema.parse(
|
|
@@ -35563,90 +35583,78 @@ var CodexAcpAgent = class {
|
|
|
35563
35583
|
this.#nativeSessionId = created.thread.id;
|
|
35564
35584
|
this.#selection = {
|
|
35565
35585
|
...this.#selection,
|
|
35586
|
+
collaborationMode: "default",
|
|
35566
35587
|
effort: created.reasoningEffort ?? "",
|
|
35567
35588
|
model: created.model ?? ""
|
|
35568
35589
|
};
|
|
35590
|
+
this.#collaborationModeSelected = false;
|
|
35591
|
+
await this.#probeCollaborationMode(context.signal);
|
|
35569
35592
|
return { configOptions: this.#configOptions(), sessionId: created.thread.id };
|
|
35593
|
+
}).onRequest(methods4.agent.session.setConfigOption, async (context) => {
|
|
35594
|
+
this.#applySelection(context.params.configId, context.params.value);
|
|
35595
|
+
return { configOptions: this.#configOptions() };
|
|
35596
|
+
}).onRequest(methods4.agent.session.setMode, async (context) => {
|
|
35597
|
+
this.#applySelection(MODE_SETTING_ID, context.params.modeId);
|
|
35598
|
+
return {};
|
|
35599
|
+
}).onRequest(methods4.agent.session.load, async (context) => {
|
|
35600
|
+
const resumed = threadResumeResponseSchema.parse(
|
|
35601
|
+
await this.#appServer.request(
|
|
35602
|
+
"thread/resume",
|
|
35603
|
+
{ cwd: context.params.cwd, excludeTurns: false, threadId: context.params.sessionId },
|
|
35604
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
35605
|
+
)
|
|
35606
|
+
);
|
|
35607
|
+
this.#selectRestoredThread(resumed);
|
|
35608
|
+
await this.#probeCollaborationMode(context.signal);
|
|
35609
|
+
await this.#replayHistory(resumed.turns);
|
|
35610
|
+
return { configOptions: this.#configOptions() };
|
|
35611
|
+
}).onRequest(methods4.agent.session.fork, async (context) => {
|
|
35612
|
+
const forked = threadForkResponseSchema.parse(
|
|
35613
|
+
await this.#appServer.request(
|
|
35614
|
+
"thread/fork",
|
|
35615
|
+
{
|
|
35616
|
+
cwd: context.params.cwd,
|
|
35617
|
+
excludeTurns: false,
|
|
35618
|
+
threadId: context.params.sessionId
|
|
35619
|
+
},
|
|
35620
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
35621
|
+
)
|
|
35622
|
+
);
|
|
35623
|
+
this.#selectRestoredThread(forked);
|
|
35624
|
+
await this.#probeCollaborationMode(context.signal);
|
|
35625
|
+
await this.#replayHistory(forked.turns);
|
|
35626
|
+
return { configOptions: this.#configOptions(), sessionId: forked.thread.id };
|
|
35570
35627
|
}).onRequest(methods4.agent.session.resume, async (context) => {
|
|
35571
35628
|
const resumed = threadResumeResponseSchema.parse(
|
|
35572
35629
|
await this.#appServer.request(
|
|
35573
35630
|
"thread/resume",
|
|
35574
|
-
{ cwd: context.params.cwd, threadId: context.params.sessionId },
|
|
35631
|
+
{ cwd: context.params.cwd, excludeTurns: true, threadId: context.params.sessionId },
|
|
35575
35632
|
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
35576
35633
|
)
|
|
35577
35634
|
);
|
|
35578
|
-
|
|
35579
|
-
|
|
35580
|
-
"Codex no longer has the native session this conversation belongs to",
|
|
35581
|
-
{},
|
|
35582
|
-
"session_restore_unsupported"
|
|
35583
|
-
);
|
|
35584
|
-
}
|
|
35585
|
-
this.#nativeSessionId = resumed.thread.id;
|
|
35586
|
-
this.#selection = {
|
|
35587
|
-
...this.#selection,
|
|
35588
|
-
effort: resumed.reasoningEffort ?? this.#selection.effort,
|
|
35589
|
-
model: resumed.model ?? this.#selection.model
|
|
35590
|
-
};
|
|
35635
|
+
this.#selectRestoredThread(resumed);
|
|
35636
|
+
await this.#probeCollaborationMode(context.signal);
|
|
35591
35637
|
return { configOptions: this.#configOptions() };
|
|
35638
|
+
}).onRequest(methods4.agent.session.prompt, async (context) => {
|
|
35639
|
+
return await this.#runTurn(promptInput(context.params.prompt), context.signal);
|
|
35592
35640
|
}).onRequest(methods4.agent.session.list, async (context) => {
|
|
35593
|
-
const
|
|
35641
|
+
const decoded = threadListResponseSchema.parse(
|
|
35594
35642
|
await this.#appServer.request(
|
|
35595
35643
|
"thread/list",
|
|
35596
|
-
|
|
35597
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
35644
|
+
{ cursor: context.params.cursor ?? null },
|
|
35645
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(SESSION_LIST_TIMEOUT_MILLISECONDS)])
|
|
35598
35646
|
)
|
|
35599
35647
|
);
|
|
35600
35648
|
return {
|
|
35601
|
-
nextCursor:
|
|
35602
|
-
sessions:
|
|
35603
|
-
// The thread id is a UUID, which satisfies the native session id contract.
|
|
35649
|
+
nextCursor: decoded.nextCursor ?? null,
|
|
35650
|
+
sessions: decoded.data.map((thread) => ({
|
|
35604
35651
|
additionalDirectories: [],
|
|
35605
|
-
cwd: thread.cwd
|
|
35652
|
+
cwd: thread.cwd,
|
|
35606
35653
|
sessionId: thread.id,
|
|
35607
|
-
title:
|
|
35608
|
-
updatedAt:
|
|
35654
|
+
title: thread.name ?? thread.preview ?? null,
|
|
35655
|
+
updatedAt: new Date(thread.updatedAt * 1e3).toISOString()
|
|
35609
35656
|
}))
|
|
35610
35657
|
};
|
|
35611
|
-
}).onRequest(methods4.agent.session.delete, async (context) => {
|
|
35612
|
-
await this.#appServer.request(
|
|
35613
|
-
"thread/archive",
|
|
35614
|
-
{ threadId: context.params.sessionId },
|
|
35615
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
35616
|
-
);
|
|
35617
|
-
return {};
|
|
35618
|
-
}).onRequest(methods4.agent.session.setConfigOption, async (context) => {
|
|
35619
|
-
this.#applySelection(context.params.configId, context.params.value);
|
|
35620
|
-
return { configOptions: this.#configOptions() };
|
|
35621
|
-
}).onRequest(methods4.agent.session.setMode, async (context) => {
|
|
35622
|
-
this.#applySelection(MODE_SETTING_ID, context.params.modeId);
|
|
35623
|
-
return {};
|
|
35624
|
-
}).onRequest(methods4.agent.session.prompt, async (context) => {
|
|
35625
|
-
return await this.#runTurn(promptInput(context.params.prompt), context.signal);
|
|
35626
|
-
}).onRequest(STEERING_METHOD, steeringParams, async (context) => {
|
|
35627
|
-
const turn = this.#turn;
|
|
35628
|
-
if (turn === null || turn.turn.id.length === 0) {
|
|
35629
|
-
return { outcome: "promptRequired" };
|
|
35630
|
-
}
|
|
35631
|
-
try {
|
|
35632
|
-
const steered = turnSteerResponseSchema.parse(
|
|
35633
|
-
await this.#appServer.request(
|
|
35634
|
-
"turn/steer",
|
|
35635
|
-
{
|
|
35636
|
-
expectedTurnId: turn.turn.id,
|
|
35637
|
-
input: promptInput(context.params.prompt),
|
|
35638
|
-
threadId: this.#nativeSessionId
|
|
35639
|
-
},
|
|
35640
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
35641
|
-
)
|
|
35642
|
-
);
|
|
35643
|
-
return { outcome: steered.turnId === turn.turn.id ? "injected" : "startedNewTurn" };
|
|
35644
|
-
} catch (error62) {
|
|
35645
|
-
if (error62 instanceof CodexAppServerError) {
|
|
35646
|
-
return { outcome: "promptRequired" };
|
|
35647
|
-
}
|
|
35648
|
-
throw error62;
|
|
35649
|
-
}
|
|
35650
35658
|
}).onRequest(methods4.agent.session.close, async () => {
|
|
35651
35659
|
await this.#interruptTurn();
|
|
35652
35660
|
}).onNotification(methods4.agent.session.cancel, async () => {
|
|
@@ -35698,6 +35706,27 @@ var CodexAcpAgent = class {
|
|
|
35698
35706
|
this.#models = Object.freeze(models.slice(0, MODEL_CATALOG_LIMIT));
|
|
35699
35707
|
};
|
|
35700
35708
|
#model = (id) => this.#models.find((model) => model.id === id);
|
|
35709
|
+
/**
|
|
35710
|
+
* Learns, once per app-server, whether collaboration mode can be applied. An empty settings
|
|
35711
|
+
* update is a no-op on a supporting Codex; an older Codex answers an error, which costs the
|
|
35712
|
+
* Build/Plan selector alone without changing a restored thread's persisted mode.
|
|
35713
|
+
*/
|
|
35714
|
+
#probeCollaborationMode = async (signal) => {
|
|
35715
|
+
if (this.#collaborationModeSupported !== null) {
|
|
35716
|
+
return;
|
|
35717
|
+
}
|
|
35718
|
+
try {
|
|
35719
|
+
await this.#appServer.request(
|
|
35720
|
+
"thread/settings/update",
|
|
35721
|
+
{ threadId: this.#nativeSessionId },
|
|
35722
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
35723
|
+
);
|
|
35724
|
+
this.#collaborationModeSupported = true;
|
|
35725
|
+
} catch {
|
|
35726
|
+
signal.throwIfAborted();
|
|
35727
|
+
this.#collaborationModeSupported = false;
|
|
35728
|
+
}
|
|
35729
|
+
};
|
|
35701
35730
|
/** The ACP settings Mobius discovers and renders in Run settings. */
|
|
35702
35731
|
#configOptions = () => {
|
|
35703
35732
|
const options = [];
|
|
@@ -35713,9 +35742,62 @@ var CodexAcpAgent = class {
|
|
|
35713
35742
|
if (fastMode !== null) {
|
|
35714
35743
|
options.push(fastMode);
|
|
35715
35744
|
}
|
|
35745
|
+
if (this.#collaborationModeSupported === true) {
|
|
35746
|
+
options.push(collaborationModeSetting(this.#selection.collaborationMode));
|
|
35747
|
+
}
|
|
35716
35748
|
options.push(modeSetting(this.#selection.mode));
|
|
35717
35749
|
return options;
|
|
35718
35750
|
};
|
|
35751
|
+
#selectRestoredThread = (thread) => {
|
|
35752
|
+
this.#nativeSessionId = thread.thread.id;
|
|
35753
|
+
this.#selection = {
|
|
35754
|
+
...this.#selection,
|
|
35755
|
+
effort: thread.reasoningEffort ?? this.#selection.effort,
|
|
35756
|
+
model: thread.model ?? this.#selection.model,
|
|
35757
|
+
fastMode: thread.serviceTier === SERVICE_TIER_FAST
|
|
35758
|
+
};
|
|
35759
|
+
};
|
|
35760
|
+
#replayHistory = async (turns) => {
|
|
35761
|
+
for (const turn of turns ?? []) {
|
|
35762
|
+
for (const rawItem of turn.items) {
|
|
35763
|
+
const item = decodeThreadItem(rawItem);
|
|
35764
|
+
if (item === null) {
|
|
35765
|
+
continue;
|
|
35766
|
+
}
|
|
35767
|
+
if (item.type === "userMessage") {
|
|
35768
|
+
const text3 = item.content.flatMap((content3) => {
|
|
35769
|
+
if (typeof content3 !== "object" || content3 === null) {
|
|
35770
|
+
return [];
|
|
35771
|
+
}
|
|
35772
|
+
const type = Reflect.get(content3, "type");
|
|
35773
|
+
const text4 = Reflect.get(content3, "text");
|
|
35774
|
+
return type === "text" && typeof text4 === "string" ? [text4] : [];
|
|
35775
|
+
}).join("");
|
|
35776
|
+
if (text3.length > 0) {
|
|
35777
|
+
await this.#emit({
|
|
35778
|
+
content: { text: text3, type: "text" },
|
|
35779
|
+
messageId: item.id,
|
|
35780
|
+
sessionUpdate: "user_message_chunk"
|
|
35781
|
+
});
|
|
35782
|
+
}
|
|
35783
|
+
continue;
|
|
35784
|
+
}
|
|
35785
|
+
if (item.type === "agentMessage") {
|
|
35786
|
+
await this.#emit({
|
|
35787
|
+
_meta: agentMessageMeta(item.phase),
|
|
35788
|
+
content: { text: item.text, type: "text" },
|
|
35789
|
+
messageId: item.id,
|
|
35790
|
+
sessionUpdate: "agent_message_chunk"
|
|
35791
|
+
});
|
|
35792
|
+
continue;
|
|
35793
|
+
}
|
|
35794
|
+
const update = toolCallUpdate(item);
|
|
35795
|
+
if (update !== null) {
|
|
35796
|
+
await this.#emit({ ...update, sessionUpdate: "tool_call_update" });
|
|
35797
|
+
}
|
|
35798
|
+
}
|
|
35799
|
+
}
|
|
35800
|
+
};
|
|
35719
35801
|
/**
|
|
35720
35802
|
* Applies one `session/set_config_option`. Switching models re-resolves the effort the way Codex
|
|
35721
35803
|
* does — the current effort when the new model supports it, otherwise the model's own default —
|
|
@@ -35755,6 +35837,18 @@ var CodexAcpAgent = class {
|
|
|
35755
35837
|
this.#policySelected = true;
|
|
35756
35838
|
return;
|
|
35757
35839
|
}
|
|
35840
|
+
if (configId === COLLABORATION_MODE_SETTING_ID) {
|
|
35841
|
+
if (!COLLABORATION_MODES.some((mode) => mode.value === value)) {
|
|
35842
|
+
throw new AcpExecutionError(
|
|
35843
|
+
"The requested Codex collaboration mode is unavailable",
|
|
35844
|
+
{},
|
|
35845
|
+
"invalid_session_configuration"
|
|
35846
|
+
);
|
|
35847
|
+
}
|
|
35848
|
+
this.#selection = { ...this.#selection, collaborationMode: value };
|
|
35849
|
+
this.#collaborationModeSelected = true;
|
|
35850
|
+
return;
|
|
35851
|
+
}
|
|
35758
35852
|
if (configId === MODEL_SETTING_ID) {
|
|
35759
35853
|
if (value === this.#selection.model) {
|
|
35760
35854
|
return;
|
|
@@ -35803,6 +35897,17 @@ var CodexAcpAgent = class {
|
|
|
35803
35897
|
update
|
|
35804
35898
|
});
|
|
35805
35899
|
};
|
|
35900
|
+
/** Pushes the current settings so a mode change Codex applied reaches the Run settings panel. */
|
|
35901
|
+
#emitConfigOptionsUpdate = async () => {
|
|
35902
|
+
const connection = this.#connection;
|
|
35903
|
+
if (connection === null || this.#nativeSessionId.length === 0) {
|
|
35904
|
+
return;
|
|
35905
|
+
}
|
|
35906
|
+
await connection.client.notify(methods4.client.session.update, {
|
|
35907
|
+
sessionId: this.#nativeSessionId,
|
|
35908
|
+
update: { configOptions: this.#configOptions(), sessionUpdate: "config_option_update" }
|
|
35909
|
+
});
|
|
35910
|
+
};
|
|
35806
35911
|
// Notifications are serialized so two app-server items cannot interleave into one ACP update
|
|
35807
35912
|
// stream, and the caller awaits the result: `turn/completed` must not resolve the prompt before
|
|
35808
35913
|
// the updates it precedes have reached the client.
|
|
@@ -35835,6 +35940,19 @@ var CodexAcpAgent = class {
|
|
|
35835
35940
|
}
|
|
35836
35941
|
return;
|
|
35837
35942
|
}
|
|
35943
|
+
if (method === "thread/settings/updated") {
|
|
35944
|
+
const decoded = threadSettingsUpdatedSchema.safeParse(params);
|
|
35945
|
+
if (decoded.success && decoded.data.threadId === this.#nativeSessionId) {
|
|
35946
|
+
const mode = decoded.data.threadSettings.collaborationMode?.mode;
|
|
35947
|
+
if (mode !== void 0 && mode !== this.#selection.collaborationMode) {
|
|
35948
|
+
this.#selection = { ...this.#selection, collaborationMode: mode };
|
|
35949
|
+
await this.#enqueue(async () => {
|
|
35950
|
+
await this.#emitConfigOptionsUpdate();
|
|
35951
|
+
});
|
|
35952
|
+
}
|
|
35953
|
+
}
|
|
35954
|
+
return;
|
|
35955
|
+
}
|
|
35838
35956
|
if (method === "turn/plan/updated") {
|
|
35839
35957
|
const plan = params.plan;
|
|
35840
35958
|
if (Array.isArray(plan) && params.threadId === this.#nativeSessionId) {
|
|
@@ -36013,6 +36131,19 @@ var CodexAcpAgent = class {
|
|
|
36013
36131
|
approvalsReviewer: mode.approvalsReviewer,
|
|
36014
36132
|
sandboxPolicy: mode.sandboxPolicy
|
|
36015
36133
|
} : {},
|
|
36134
|
+
// The collaboration mode rides on the turn: Codex applies it to the
|
|
36135
|
+
// thread, where it persists until changed. "Build" is Codex's `default`
|
|
36136
|
+
// mode, so it is only sent once a choice exists to apply.
|
|
36137
|
+
...this.#collaborationModeSupported && (selection.collaborationMode !== "default" || this.#collaborationModeSelected) ? {
|
|
36138
|
+
collaborationMode: {
|
|
36139
|
+
mode: selection.collaborationMode,
|
|
36140
|
+
settings: {
|
|
36141
|
+
developer_instructions: null,
|
|
36142
|
+
model: selection.model,
|
|
36143
|
+
reasoning_effort: selection.effort.length === 0 ? null : selection.effort
|
|
36144
|
+
}
|
|
36145
|
+
}
|
|
36146
|
+
} : {},
|
|
36016
36147
|
...selection.effort.length === 0 ? {} : { effort: selection.effort },
|
|
36017
36148
|
input: input2,
|
|
36018
36149
|
...selection.model.length === 0 ? {} : { model: selection.model },
|
|
@@ -39625,7 +39756,7 @@ var responseSchema = external_exports.union([
|
|
|
39625
39756
|
external_exports.object({ id: external_exports.number(), result: external_exports.unknown() }),
|
|
39626
39757
|
external_exports.object({ method: external_exports.string() })
|
|
39627
39758
|
]);
|
|
39628
|
-
var
|
|
39759
|
+
var threadSchema = external_exports.object({
|
|
39629
39760
|
thread: external_exports.object({
|
|
39630
39761
|
id: nativeSessionIdSchema,
|
|
39631
39762
|
cwd: external_exports.string().min(1).max(2048).refine((path2) => !path2.includes("\0"))
|
|
@@ -39929,7 +40060,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
39929
40060
|
});
|
|
39930
40061
|
break;
|
|
39931
40062
|
case "metadata": {
|
|
39932
|
-
const { thread } =
|
|
40063
|
+
const { thread } = threadSchema.parse(message.result);
|
|
39933
40064
|
state = { kind: "turns", requestId: 3, thread };
|
|
39934
40065
|
send2({
|
|
39935
40066
|
id: state.requestId,
|