@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/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ import { mkdir as mkdir6 } from "node:fs/promises";
|
|
|
11
11
|
// package.json
|
|
12
12
|
var package_default = {
|
|
13
13
|
name: "@moxt-ai/mobius",
|
|
14
|
-
version: "0.0.
|
|
14
|
+
version: "0.0.78",
|
|
15
15
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
16
16
|
type: "module",
|
|
17
17
|
bin: {
|
|
@@ -21276,10 +21276,29 @@ var threadStartResponseSchema = external_exports.object({
|
|
|
21276
21276
|
serviceTier: boundedText(256).nullish(),
|
|
21277
21277
|
thread: external_exports.object({ id: boundedText(256) })
|
|
21278
21278
|
});
|
|
21279
|
-
var
|
|
21279
|
+
var threadLifecycleResponseSchema = external_exports.object({
|
|
21280
21280
|
model: boundedText(256).nullish(),
|
|
21281
21281
|
reasoningEffort: boundedText(256).nullish(),
|
|
21282
|
-
|
|
21282
|
+
serviceTier: boundedText(256).nullish(),
|
|
21283
|
+
thread: external_exports.object({ id: boundedText(256) }),
|
|
21284
|
+
turns: external_exports.array(
|
|
21285
|
+
external_exports.object({
|
|
21286
|
+
items: external_exports.array(external_exports.unknown()).max(1e5)
|
|
21287
|
+
})
|
|
21288
|
+
).max(1e5).nullish()
|
|
21289
|
+
});
|
|
21290
|
+
var threadResumeResponseSchema = threadLifecycleResponseSchema;
|
|
21291
|
+
var threadForkResponseSchema = threadLifecycleResponseSchema;
|
|
21292
|
+
var threadSummarySchema = external_exports.object({
|
|
21293
|
+
cwd: boundedText(2048),
|
|
21294
|
+
id: boundedText(256),
|
|
21295
|
+
name: boundedText(500).nullish(),
|
|
21296
|
+
preview: boundedText(500).nullish(),
|
|
21297
|
+
updatedAt: external_exports.number().int().nonnegative()
|
|
21298
|
+
});
|
|
21299
|
+
var threadListResponseSchema = external_exports.object({
|
|
21300
|
+
data: external_exports.array(threadSummarySchema).max(500),
|
|
21301
|
+
nextCursor: boundedText(1024).nullish()
|
|
21283
21302
|
});
|
|
21284
21303
|
var reasoningEffortOptionSchema = external_exports.object({
|
|
21285
21304
|
description: boundedText(4096).nullish(),
|
|
@@ -21298,19 +21317,14 @@ var modelListResponseSchema = external_exports.object({
|
|
|
21298
21317
|
data: external_exports.array(modelSchema).max(1e3),
|
|
21299
21318
|
nextCursor: boundedText(1024).nullish()
|
|
21300
21319
|
});
|
|
21301
|
-
var
|
|
21302
|
-
|
|
21303
|
-
|
|
21304
|
-
|
|
21305
|
-
|
|
21306
|
-
|
|
21307
|
-
|
|
21308
|
-
});
|
|
21309
|
-
var threadListResponseSchema = external_exports.object({
|
|
21310
|
-
data: external_exports.array(threadSchema).max(1e4),
|
|
21311
|
-
nextCursor: boundedText(1024).nullish()
|
|
21320
|
+
var threadSettingsUpdatedSchema = external_exports.object({
|
|
21321
|
+
threadId: boundedText(256),
|
|
21322
|
+
threadSettings: external_exports.object({
|
|
21323
|
+
collaborationMode: external_exports.object({
|
|
21324
|
+
mode: external_exports.enum(["default", "plan"])
|
|
21325
|
+
}).nullish()
|
|
21326
|
+
})
|
|
21312
21327
|
});
|
|
21313
|
-
var turnSteerResponseSchema = external_exports.object({ turnId: boundedText(256) });
|
|
21314
21328
|
|
|
21315
21329
|
// src/acp/codex/app-server-client.ts
|
|
21316
21330
|
var INITIALIZE_TIMEOUT_MILLISECONDS = 3e4;
|
|
@@ -21495,7 +21509,10 @@ var CodexAppServerClient = class {
|
|
|
21495
21509
|
initialize = async (signal) => {
|
|
21496
21510
|
await this.request(
|
|
21497
21511
|
"initialize",
|
|
21498
|
-
{
|
|
21512
|
+
{
|
|
21513
|
+
capabilities: { experimentalApi: true },
|
|
21514
|
+
clientInfo: { name: "mobius", version: "1.0.0" }
|
|
21515
|
+
},
|
|
21499
21516
|
AbortSignal.any([signal, AbortSignal.timeout(INITIALIZE_TIMEOUT_MILLISECONDS)])
|
|
21500
21517
|
);
|
|
21501
21518
|
this.notify("initialized", void 0);
|
|
@@ -21650,11 +21667,12 @@ function agentMessageMeta(phase) {
|
|
|
21650
21667
|
var APPROVAL_REASON_CHARACTER_LIMIT = 500;
|
|
21651
21668
|
var APPROVAL_TIMEOUT_MILLISECONDS = 36e5;
|
|
21652
21669
|
var CODEX_AGENT_VERSION = "0.154.0";
|
|
21653
|
-
var
|
|
21670
|
+
var SESSION_LIST_TIMEOUT_MILLISECONDS = 3e4;
|
|
21654
21671
|
var MODEL_SETTING_ID = "model";
|
|
21655
21672
|
var REASONING_EFFORT_SETTING_ID = "reasoning_effort";
|
|
21656
21673
|
var MODE_SETTING_ID = "mode";
|
|
21657
21674
|
var FAST_MODE_SETTING_ID = "fast-mode";
|
|
21675
|
+
var COLLABORATION_MODE_SETTING_ID = "collaboration_mode";
|
|
21658
21676
|
var MODEL_CATALOG_LIMIT = 1e3;
|
|
21659
21677
|
var FAST_TIER = "fast";
|
|
21660
21678
|
var SERVICE_TIER_FAST = "priority";
|
|
@@ -21701,26 +21719,6 @@ function initialMode(environment) {
|
|
|
21701
21719
|
function capitalize(value) {
|
|
21702
21720
|
return value.length === 0 ? value : value.charAt(0).toUpperCase() + value.slice(1);
|
|
21703
21721
|
}
|
|
21704
|
-
function threadTitle(thread) {
|
|
21705
|
-
const named = thread.name?.trim() ?? "";
|
|
21706
|
-
if (named.length > 0) {
|
|
21707
|
-
return named;
|
|
21708
|
-
}
|
|
21709
|
-
return thread.preview?.trim() ?? "";
|
|
21710
|
-
}
|
|
21711
|
-
function isoTimestamp(seconds) {
|
|
21712
|
-
if (seconds == null || !Number.isFinite(seconds)) {
|
|
21713
|
-
return null;
|
|
21714
|
-
}
|
|
21715
|
-
return new Date(seconds * 1e3).toISOString();
|
|
21716
|
-
}
|
|
21717
|
-
function steeringParams(params) {
|
|
21718
|
-
const prompt = typeof params === "object" && params !== null ? Reflect.get(params, "prompt") : void 0;
|
|
21719
|
-
if (!Array.isArray(prompt)) {
|
|
21720
|
-
throw new AcpExecutionError("The steering prompt is invalid", {}, "steering_failed");
|
|
21721
|
-
}
|
|
21722
|
-
return { prompt };
|
|
21723
|
-
}
|
|
21724
21722
|
var APPROVAL_OPTIONS = Object.freeze([
|
|
21725
21723
|
{ kind: "allow_once", name: "Allow once", optionId: "accept" },
|
|
21726
21724
|
{ kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
|
|
@@ -21804,6 +21802,22 @@ function modeSetting(currentValue) {
|
|
|
21804
21802
|
type: "select"
|
|
21805
21803
|
};
|
|
21806
21804
|
}
|
|
21805
|
+
var COLLABORATION_MODES = Object.freeze([
|
|
21806
|
+
{ description: "Codex answers and makes changes directly", name: "Build", value: "default" },
|
|
21807
|
+
{ description: "Codex plans before making changes", name: "Plan", value: "plan" }
|
|
21808
|
+
]);
|
|
21809
|
+
function collaborationModeSetting(currentValue) {
|
|
21810
|
+
const current = COLLABORATION_MODES.some((mode) => mode.value === currentValue) ? currentValue : COLLABORATION_MODES[0]?.value ?? "default";
|
|
21811
|
+
return {
|
|
21812
|
+
category: "collaboration_mode",
|
|
21813
|
+
currentValue: current,
|
|
21814
|
+
description: "How Codex collaborates for subsequent turns",
|
|
21815
|
+
id: COLLABORATION_MODE_SETTING_ID,
|
|
21816
|
+
name: "Collaboration mode",
|
|
21817
|
+
options: [...COLLABORATION_MODES],
|
|
21818
|
+
type: "select"
|
|
21819
|
+
};
|
|
21820
|
+
}
|
|
21807
21821
|
function fastModeSetting(model, enabled) {
|
|
21808
21822
|
if (model?.additionalSpeedTiers?.includes(FAST_TIER) !== true) {
|
|
21809
21823
|
return null;
|
|
@@ -21865,11 +21879,19 @@ var CodexAcpAgent = class {
|
|
|
21865
21879
|
// Whether the current turn must carry a policy at all. Until the user picks a mode, Codex's own
|
|
21866
21880
|
// configuration decides, so `turn/start` omits the fields and inherits what the host set up.
|
|
21867
21881
|
#policySelected = false;
|
|
21882
|
+
// Whether a collaboration mode choice has been made in this session. A restored thread keeps
|
|
21883
|
+
// the mode Codex already persisted, so the first turn does not reset it to Build.
|
|
21884
|
+
#collaborationModeSelected = false;
|
|
21885
|
+
// Whether the app-server accepts collaboration mode on `turn/start`, probed once per
|
|
21886
|
+
// app-server. An older Codex rejects the experimental field, and the setting must disappear
|
|
21887
|
+
// rather than break every turn.
|
|
21888
|
+
#collaborationModeSupported = null;
|
|
21868
21889
|
#selection;
|
|
21869
21890
|
#turn = null;
|
|
21870
21891
|
#updateTail = Promise.resolve();
|
|
21871
21892
|
constructor(options) {
|
|
21872
21893
|
this.#selection = {
|
|
21894
|
+
collaborationMode: "default",
|
|
21873
21895
|
effort: "",
|
|
21874
21896
|
fastMode: false,
|
|
21875
21897
|
mode: initialMode(options.environment),
|
|
@@ -21892,14 +21914,12 @@ var CodexAcpAgent = class {
|
|
|
21892
21914
|
this.#connection = connection;
|
|
21893
21915
|
}).onRequest(methods.agent.initialize, async () => ({
|
|
21894
21916
|
agentCapabilities: {
|
|
21895
|
-
loadSession:
|
|
21917
|
+
loadSession: true,
|
|
21896
21918
|
promptCapabilities: { embeddedContext: true, image: true },
|
|
21897
|
-
sessionCapabilities: { close: {},
|
|
21919
|
+
sessionCapabilities: { close: {}, fork: {}, list: {} }
|
|
21898
21920
|
},
|
|
21899
21921
|
agentInfo: { name: "Codex", version: CODEX_AGENT_VERSION },
|
|
21900
21922
|
authMethods: [],
|
|
21901
|
-
// Mobius reads this to decide whether mid-turn steering can be attempted at all.
|
|
21902
|
-
_meta: { steering: { supported: true } },
|
|
21903
21923
|
protocolVersion: PROTOCOL_VERSION
|
|
21904
21924
|
})).onRequest(methods.agent.session.new, async (context) => {
|
|
21905
21925
|
const created = threadStartResponseSchema.parse(
|
|
@@ -21912,90 +21932,78 @@ var CodexAcpAgent = class {
|
|
|
21912
21932
|
this.#nativeSessionId = created.thread.id;
|
|
21913
21933
|
this.#selection = {
|
|
21914
21934
|
...this.#selection,
|
|
21935
|
+
collaborationMode: "default",
|
|
21915
21936
|
effort: created.reasoningEffort ?? "",
|
|
21916
21937
|
model: created.model ?? ""
|
|
21917
21938
|
};
|
|
21939
|
+
this.#collaborationModeSelected = false;
|
|
21940
|
+
await this.#probeCollaborationMode(context.signal);
|
|
21918
21941
|
return { configOptions: this.#configOptions(), sessionId: created.thread.id };
|
|
21942
|
+
}).onRequest(methods.agent.session.setConfigOption, async (context) => {
|
|
21943
|
+
this.#applySelection(context.params.configId, context.params.value);
|
|
21944
|
+
return { configOptions: this.#configOptions() };
|
|
21945
|
+
}).onRequest(methods.agent.session.setMode, async (context) => {
|
|
21946
|
+
this.#applySelection(MODE_SETTING_ID, context.params.modeId);
|
|
21947
|
+
return {};
|
|
21948
|
+
}).onRequest(methods.agent.session.load, async (context) => {
|
|
21949
|
+
const resumed = threadResumeResponseSchema.parse(
|
|
21950
|
+
await this.#appServer.request(
|
|
21951
|
+
"thread/resume",
|
|
21952
|
+
{ cwd: context.params.cwd, excludeTurns: false, threadId: context.params.sessionId },
|
|
21953
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21954
|
+
)
|
|
21955
|
+
);
|
|
21956
|
+
this.#selectRestoredThread(resumed);
|
|
21957
|
+
await this.#probeCollaborationMode(context.signal);
|
|
21958
|
+
await this.#replayHistory(resumed.turns);
|
|
21959
|
+
return { configOptions: this.#configOptions() };
|
|
21960
|
+
}).onRequest(methods.agent.session.fork, async (context) => {
|
|
21961
|
+
const forked = threadForkResponseSchema.parse(
|
|
21962
|
+
await this.#appServer.request(
|
|
21963
|
+
"thread/fork",
|
|
21964
|
+
{
|
|
21965
|
+
cwd: context.params.cwd,
|
|
21966
|
+
excludeTurns: false,
|
|
21967
|
+
threadId: context.params.sessionId
|
|
21968
|
+
},
|
|
21969
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21970
|
+
)
|
|
21971
|
+
);
|
|
21972
|
+
this.#selectRestoredThread(forked);
|
|
21973
|
+
await this.#probeCollaborationMode(context.signal);
|
|
21974
|
+
await this.#replayHistory(forked.turns);
|
|
21975
|
+
return { configOptions: this.#configOptions(), sessionId: forked.thread.id };
|
|
21919
21976
|
}).onRequest(methods.agent.session.resume, async (context) => {
|
|
21920
21977
|
const resumed = threadResumeResponseSchema.parse(
|
|
21921
21978
|
await this.#appServer.request(
|
|
21922
21979
|
"thread/resume",
|
|
21923
|
-
{ cwd: context.params.cwd, threadId: context.params.sessionId },
|
|
21980
|
+
{ cwd: context.params.cwd, excludeTurns: true, threadId: context.params.sessionId },
|
|
21924
21981
|
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21925
21982
|
)
|
|
21926
21983
|
);
|
|
21927
|
-
|
|
21928
|
-
|
|
21929
|
-
"Codex no longer has the native session this conversation belongs to",
|
|
21930
|
-
{},
|
|
21931
|
-
"session_restore_unsupported"
|
|
21932
|
-
);
|
|
21933
|
-
}
|
|
21934
|
-
this.#nativeSessionId = resumed.thread.id;
|
|
21935
|
-
this.#selection = {
|
|
21936
|
-
...this.#selection,
|
|
21937
|
-
effort: resumed.reasoningEffort ?? this.#selection.effort,
|
|
21938
|
-
model: resumed.model ?? this.#selection.model
|
|
21939
|
-
};
|
|
21984
|
+
this.#selectRestoredThread(resumed);
|
|
21985
|
+
await this.#probeCollaborationMode(context.signal);
|
|
21940
21986
|
return { configOptions: this.#configOptions() };
|
|
21987
|
+
}).onRequest(methods.agent.session.prompt, async (context) => {
|
|
21988
|
+
return await this.#runTurn(promptInput(context.params.prompt), context.signal);
|
|
21941
21989
|
}).onRequest(methods.agent.session.list, async (context) => {
|
|
21942
|
-
const
|
|
21990
|
+
const decoded = threadListResponseSchema.parse(
|
|
21943
21991
|
await this.#appServer.request(
|
|
21944
21992
|
"thread/list",
|
|
21945
|
-
|
|
21946
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
21993
|
+
{ cursor: context.params.cursor ?? null },
|
|
21994
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(SESSION_LIST_TIMEOUT_MILLISECONDS)])
|
|
21947
21995
|
)
|
|
21948
21996
|
);
|
|
21949
21997
|
return {
|
|
21950
|
-
nextCursor:
|
|
21951
|
-
sessions:
|
|
21952
|
-
// The thread id is a UUID, which satisfies the native session id contract.
|
|
21998
|
+
nextCursor: decoded.nextCursor ?? null,
|
|
21999
|
+
sessions: decoded.data.map((thread) => ({
|
|
21953
22000
|
additionalDirectories: [],
|
|
21954
|
-
cwd: thread.cwd
|
|
22001
|
+
cwd: thread.cwd,
|
|
21955
22002
|
sessionId: thread.id,
|
|
21956
|
-
title:
|
|
21957
|
-
updatedAt:
|
|
22003
|
+
title: thread.name ?? thread.preview ?? null,
|
|
22004
|
+
updatedAt: new Date(thread.updatedAt * 1e3).toISOString()
|
|
21958
22005
|
}))
|
|
21959
22006
|
};
|
|
21960
|
-
}).onRequest(methods.agent.session.delete, async (context) => {
|
|
21961
|
-
await this.#appServer.request(
|
|
21962
|
-
"thread/archive",
|
|
21963
|
-
{ threadId: context.params.sessionId },
|
|
21964
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21965
|
-
);
|
|
21966
|
-
return {};
|
|
21967
|
-
}).onRequest(methods.agent.session.setConfigOption, async (context) => {
|
|
21968
|
-
this.#applySelection(context.params.configId, context.params.value);
|
|
21969
|
-
return { configOptions: this.#configOptions() };
|
|
21970
|
-
}).onRequest(methods.agent.session.setMode, async (context) => {
|
|
21971
|
-
this.#applySelection(MODE_SETTING_ID, context.params.modeId);
|
|
21972
|
-
return {};
|
|
21973
|
-
}).onRequest(methods.agent.session.prompt, async (context) => {
|
|
21974
|
-
return await this.#runTurn(promptInput(context.params.prompt), context.signal);
|
|
21975
|
-
}).onRequest(STEERING_METHOD, steeringParams, async (context) => {
|
|
21976
|
-
const turn = this.#turn;
|
|
21977
|
-
if (turn === null || turn.turn.id.length === 0) {
|
|
21978
|
-
return { outcome: "promptRequired" };
|
|
21979
|
-
}
|
|
21980
|
-
try {
|
|
21981
|
-
const steered = turnSteerResponseSchema.parse(
|
|
21982
|
-
await this.#appServer.request(
|
|
21983
|
-
"turn/steer",
|
|
21984
|
-
{
|
|
21985
|
-
expectedTurnId: turn.turn.id,
|
|
21986
|
-
input: promptInput(context.params.prompt),
|
|
21987
|
-
threadId: this.#nativeSessionId
|
|
21988
|
-
},
|
|
21989
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21990
|
-
)
|
|
21991
|
-
);
|
|
21992
|
-
return { outcome: steered.turnId === turn.turn.id ? "injected" : "startedNewTurn" };
|
|
21993
|
-
} catch (error62) {
|
|
21994
|
-
if (error62 instanceof CodexAppServerError) {
|
|
21995
|
-
return { outcome: "promptRequired" };
|
|
21996
|
-
}
|
|
21997
|
-
throw error62;
|
|
21998
|
-
}
|
|
21999
22007
|
}).onRequest(methods.agent.session.close, async () => {
|
|
22000
22008
|
await this.#interruptTurn();
|
|
22001
22009
|
}).onNotification(methods.agent.session.cancel, async () => {
|
|
@@ -22047,6 +22055,27 @@ var CodexAcpAgent = class {
|
|
|
22047
22055
|
this.#models = Object.freeze(models.slice(0, MODEL_CATALOG_LIMIT));
|
|
22048
22056
|
};
|
|
22049
22057
|
#model = (id) => this.#models.find((model) => model.id === id);
|
|
22058
|
+
/**
|
|
22059
|
+
* Learns, once per app-server, whether collaboration mode can be applied. An empty settings
|
|
22060
|
+
* update is a no-op on a supporting Codex; an older Codex answers an error, which costs the
|
|
22061
|
+
* Build/Plan selector alone without changing a restored thread's persisted mode.
|
|
22062
|
+
*/
|
|
22063
|
+
#probeCollaborationMode = async (signal) => {
|
|
22064
|
+
if (this.#collaborationModeSupported !== null) {
|
|
22065
|
+
return;
|
|
22066
|
+
}
|
|
22067
|
+
try {
|
|
22068
|
+
await this.#appServer.request(
|
|
22069
|
+
"thread/settings/update",
|
|
22070
|
+
{ threadId: this.#nativeSessionId },
|
|
22071
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
22072
|
+
);
|
|
22073
|
+
this.#collaborationModeSupported = true;
|
|
22074
|
+
} catch {
|
|
22075
|
+
signal.throwIfAborted();
|
|
22076
|
+
this.#collaborationModeSupported = false;
|
|
22077
|
+
}
|
|
22078
|
+
};
|
|
22050
22079
|
/** The ACP settings Mobius discovers and renders in Run settings. */
|
|
22051
22080
|
#configOptions = () => {
|
|
22052
22081
|
const options = [];
|
|
@@ -22062,9 +22091,62 @@ var CodexAcpAgent = class {
|
|
|
22062
22091
|
if (fastMode !== null) {
|
|
22063
22092
|
options.push(fastMode);
|
|
22064
22093
|
}
|
|
22094
|
+
if (this.#collaborationModeSupported === true) {
|
|
22095
|
+
options.push(collaborationModeSetting(this.#selection.collaborationMode));
|
|
22096
|
+
}
|
|
22065
22097
|
options.push(modeSetting(this.#selection.mode));
|
|
22066
22098
|
return options;
|
|
22067
22099
|
};
|
|
22100
|
+
#selectRestoredThread = (thread) => {
|
|
22101
|
+
this.#nativeSessionId = thread.thread.id;
|
|
22102
|
+
this.#selection = {
|
|
22103
|
+
...this.#selection,
|
|
22104
|
+
effort: thread.reasoningEffort ?? this.#selection.effort,
|
|
22105
|
+
model: thread.model ?? this.#selection.model,
|
|
22106
|
+
fastMode: thread.serviceTier === SERVICE_TIER_FAST
|
|
22107
|
+
};
|
|
22108
|
+
};
|
|
22109
|
+
#replayHistory = async (turns) => {
|
|
22110
|
+
for (const turn of turns ?? []) {
|
|
22111
|
+
for (const rawItem of turn.items) {
|
|
22112
|
+
const item = decodeThreadItem(rawItem);
|
|
22113
|
+
if (item === null) {
|
|
22114
|
+
continue;
|
|
22115
|
+
}
|
|
22116
|
+
if (item.type === "userMessage") {
|
|
22117
|
+
const text3 = item.content.flatMap((content3) => {
|
|
22118
|
+
if (typeof content3 !== "object" || content3 === null) {
|
|
22119
|
+
return [];
|
|
22120
|
+
}
|
|
22121
|
+
const type = Reflect.get(content3, "type");
|
|
22122
|
+
const text4 = Reflect.get(content3, "text");
|
|
22123
|
+
return type === "text" && typeof text4 === "string" ? [text4] : [];
|
|
22124
|
+
}).join("");
|
|
22125
|
+
if (text3.length > 0) {
|
|
22126
|
+
await this.#emit({
|
|
22127
|
+
content: { text: text3, type: "text" },
|
|
22128
|
+
messageId: item.id,
|
|
22129
|
+
sessionUpdate: "user_message_chunk"
|
|
22130
|
+
});
|
|
22131
|
+
}
|
|
22132
|
+
continue;
|
|
22133
|
+
}
|
|
22134
|
+
if (item.type === "agentMessage") {
|
|
22135
|
+
await this.#emit({
|
|
22136
|
+
_meta: agentMessageMeta(item.phase),
|
|
22137
|
+
content: { text: item.text, type: "text" },
|
|
22138
|
+
messageId: item.id,
|
|
22139
|
+
sessionUpdate: "agent_message_chunk"
|
|
22140
|
+
});
|
|
22141
|
+
continue;
|
|
22142
|
+
}
|
|
22143
|
+
const update = toolCallUpdate(item);
|
|
22144
|
+
if (update !== null) {
|
|
22145
|
+
await this.#emit({ ...update, sessionUpdate: "tool_call_update" });
|
|
22146
|
+
}
|
|
22147
|
+
}
|
|
22148
|
+
}
|
|
22149
|
+
};
|
|
22068
22150
|
/**
|
|
22069
22151
|
* Applies one `session/set_config_option`. Switching models re-resolves the effort the way Codex
|
|
22070
22152
|
* does — the current effort when the new model supports it, otherwise the model's own default —
|
|
@@ -22104,6 +22186,18 @@ var CodexAcpAgent = class {
|
|
|
22104
22186
|
this.#policySelected = true;
|
|
22105
22187
|
return;
|
|
22106
22188
|
}
|
|
22189
|
+
if (configId === COLLABORATION_MODE_SETTING_ID) {
|
|
22190
|
+
if (!COLLABORATION_MODES.some((mode) => mode.value === value)) {
|
|
22191
|
+
throw new AcpExecutionError(
|
|
22192
|
+
"The requested Codex collaboration mode is unavailable",
|
|
22193
|
+
{},
|
|
22194
|
+
"invalid_session_configuration"
|
|
22195
|
+
);
|
|
22196
|
+
}
|
|
22197
|
+
this.#selection = { ...this.#selection, collaborationMode: value };
|
|
22198
|
+
this.#collaborationModeSelected = true;
|
|
22199
|
+
return;
|
|
22200
|
+
}
|
|
22107
22201
|
if (configId === MODEL_SETTING_ID) {
|
|
22108
22202
|
if (value === this.#selection.model) {
|
|
22109
22203
|
return;
|
|
@@ -22152,6 +22246,17 @@ var CodexAcpAgent = class {
|
|
|
22152
22246
|
update
|
|
22153
22247
|
});
|
|
22154
22248
|
};
|
|
22249
|
+
/** Pushes the current settings so a mode change Codex applied reaches the Run settings panel. */
|
|
22250
|
+
#emitConfigOptionsUpdate = async () => {
|
|
22251
|
+
const connection = this.#connection;
|
|
22252
|
+
if (connection === null || this.#nativeSessionId.length === 0) {
|
|
22253
|
+
return;
|
|
22254
|
+
}
|
|
22255
|
+
await connection.client.notify(methods.client.session.update, {
|
|
22256
|
+
sessionId: this.#nativeSessionId,
|
|
22257
|
+
update: { configOptions: this.#configOptions(), sessionUpdate: "config_option_update" }
|
|
22258
|
+
});
|
|
22259
|
+
};
|
|
22155
22260
|
// Notifications are serialized so two app-server items cannot interleave into one ACP update
|
|
22156
22261
|
// stream, and the caller awaits the result: `turn/completed` must not resolve the prompt before
|
|
22157
22262
|
// the updates it precedes have reached the client.
|
|
@@ -22184,6 +22289,19 @@ var CodexAcpAgent = class {
|
|
|
22184
22289
|
}
|
|
22185
22290
|
return;
|
|
22186
22291
|
}
|
|
22292
|
+
if (method === "thread/settings/updated") {
|
|
22293
|
+
const decoded = threadSettingsUpdatedSchema.safeParse(params);
|
|
22294
|
+
if (decoded.success && decoded.data.threadId === this.#nativeSessionId) {
|
|
22295
|
+
const mode = decoded.data.threadSettings.collaborationMode?.mode;
|
|
22296
|
+
if (mode !== void 0 && mode !== this.#selection.collaborationMode) {
|
|
22297
|
+
this.#selection = { ...this.#selection, collaborationMode: mode };
|
|
22298
|
+
await this.#enqueue(async () => {
|
|
22299
|
+
await this.#emitConfigOptionsUpdate();
|
|
22300
|
+
});
|
|
22301
|
+
}
|
|
22302
|
+
}
|
|
22303
|
+
return;
|
|
22304
|
+
}
|
|
22187
22305
|
if (method === "turn/plan/updated") {
|
|
22188
22306
|
const plan = params.plan;
|
|
22189
22307
|
if (Array.isArray(plan) && params.threadId === this.#nativeSessionId) {
|
|
@@ -22362,6 +22480,19 @@ var CodexAcpAgent = class {
|
|
|
22362
22480
|
approvalsReviewer: mode.approvalsReviewer,
|
|
22363
22481
|
sandboxPolicy: mode.sandboxPolicy
|
|
22364
22482
|
} : {},
|
|
22483
|
+
// The collaboration mode rides on the turn: Codex applies it to the
|
|
22484
|
+
// thread, where it persists until changed. "Build" is Codex's `default`
|
|
22485
|
+
// mode, so it is only sent once a choice exists to apply.
|
|
22486
|
+
...this.#collaborationModeSupported && (selection.collaborationMode !== "default" || this.#collaborationModeSelected) ? {
|
|
22487
|
+
collaborationMode: {
|
|
22488
|
+
mode: selection.collaborationMode,
|
|
22489
|
+
settings: {
|
|
22490
|
+
developer_instructions: null,
|
|
22491
|
+
model: selection.model,
|
|
22492
|
+
reasoning_effort: selection.effort.length === 0 ? null : selection.effort
|
|
22493
|
+
}
|
|
22494
|
+
}
|
|
22495
|
+
} : {},
|
|
22365
22496
|
...selection.effort.length === 0 ? {} : { effort: selection.effort },
|
|
22366
22497
|
input: input2,
|
|
22367
22498
|
...selection.model.length === 0 ? {} : { model: selection.model },
|
|
@@ -39685,7 +39816,7 @@ var responseSchema = external_exports.union([
|
|
|
39685
39816
|
external_exports.object({ id: external_exports.number(), result: external_exports.unknown() }),
|
|
39686
39817
|
external_exports.object({ method: external_exports.string() })
|
|
39687
39818
|
]);
|
|
39688
|
-
var
|
|
39819
|
+
var threadSchema = external_exports.object({
|
|
39689
39820
|
thread: external_exports.object({
|
|
39690
39821
|
id: nativeSessionIdSchema,
|
|
39691
39822
|
cwd: external_exports.string().min(1).max(2048).refine((path2) => !path2.includes("\0"))
|
|
@@ -39989,7 +40120,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
39989
40120
|
});
|
|
39990
40121
|
break;
|
|
39991
40122
|
case "metadata": {
|
|
39992
|
-
const { thread } =
|
|
40123
|
+
const { thread } = threadSchema.parse(message.result);
|
|
39993
40124
|
state = { kind: "turns", requestId: 3, thread };
|
|
39994
40125
|
send2({
|
|
39995
40126
|
id: state.requestId,
|