@moxt-ai/mobius 0.0.76 → 0.0.77
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 +92 -106
- package/dist/acp/codex/agent.js.map +1 -1
- package/dist/acp/codex/app-server-protocol.d.ts +27 -29
- package/dist/acp/codex/app-server-protocol.d.ts.map +1 -1
- package/dist/acp/codex/app-server-protocol.js +25 -23
- package/dist/acp/codex/app-server-protocol.js.map +1 -1
- package/dist/cli.js +122 -106
- package/dist/cli.js.map +3 -3
- package/dist/index.js +121 -105
- package/dist/index.js.map +3 -3
- package/dist/runtime.js +121 -105
- 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,6 @@ var modelListResponseSchema = external_exports.object({
|
|
|
21170
21189
|
data: external_exports.array(modelSchema).max(1e3),
|
|
21171
21190
|
nextCursor: boundedText(1024).nullish()
|
|
21172
21191
|
});
|
|
21173
|
-
var threadSchema = external_exports.object({
|
|
21174
|
-
createdAt: external_exports.number().nullish(),
|
|
21175
|
-
cwd: boundedText(4096).nullish(),
|
|
21176
|
-
id: boundedText(256),
|
|
21177
|
-
name: boundedText(4096).nullish(),
|
|
21178
|
-
preview: boundedText(4096).nullish(),
|
|
21179
|
-
updatedAt: external_exports.number().nullish()
|
|
21180
|
-
});
|
|
21181
|
-
var threadListResponseSchema = external_exports.object({
|
|
21182
|
-
data: external_exports.array(threadSchema).max(1e4),
|
|
21183
|
-
nextCursor: boundedText(1024).nullish()
|
|
21184
|
-
});
|
|
21185
|
-
var turnSteerResponseSchema = external_exports.object({ turnId: boundedText(256) });
|
|
21186
21192
|
|
|
21187
21193
|
// src/acp/codex/app-server-client.ts
|
|
21188
21194
|
var INITIALIZE_TIMEOUT_MILLISECONDS = 3e4;
|
|
@@ -21522,7 +21528,7 @@ function agentMessageMeta(phase) {
|
|
|
21522
21528
|
var APPROVAL_REASON_CHARACTER_LIMIT = 500;
|
|
21523
21529
|
var APPROVAL_TIMEOUT_MILLISECONDS = 36e5;
|
|
21524
21530
|
var CODEX_AGENT_VERSION = "0.154.0";
|
|
21525
|
-
var
|
|
21531
|
+
var SESSION_LIST_TIMEOUT_MILLISECONDS = 3e4;
|
|
21526
21532
|
var MODEL_SETTING_ID = "model";
|
|
21527
21533
|
var REASONING_EFFORT_SETTING_ID = "reasoning_effort";
|
|
21528
21534
|
var MODE_SETTING_ID = "mode";
|
|
@@ -21573,26 +21579,6 @@ function initialMode(environment) {
|
|
|
21573
21579
|
function capitalize(value) {
|
|
21574
21580
|
return value.length === 0 ? value : value.charAt(0).toUpperCase() + value.slice(1);
|
|
21575
21581
|
}
|
|
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
21582
|
var APPROVAL_OPTIONS = Object.freeze([
|
|
21597
21583
|
{ kind: "allow_once", name: "Allow once", optionId: "accept" },
|
|
21598
21584
|
{ kind: "allow_always", name: "Allow for this session", optionId: "acceptForSession" },
|
|
@@ -21764,14 +21750,12 @@ var CodexAcpAgent = class {
|
|
|
21764
21750
|
this.#connection = connection;
|
|
21765
21751
|
}).onRequest(methods.agent.initialize, async () => ({
|
|
21766
21752
|
agentCapabilities: {
|
|
21767
|
-
loadSession:
|
|
21753
|
+
loadSession: true,
|
|
21768
21754
|
promptCapabilities: { embeddedContext: true, image: true },
|
|
21769
|
-
sessionCapabilities: { close: {},
|
|
21755
|
+
sessionCapabilities: { close: {}, fork: {}, list: {} }
|
|
21770
21756
|
},
|
|
21771
21757
|
agentInfo: { name: "Codex", version: CODEX_AGENT_VERSION },
|
|
21772
21758
|
authMethods: [],
|
|
21773
|
-
// Mobius reads this to decide whether mid-turn steering can be attempted at all.
|
|
21774
|
-
_meta: { steering: { supported: true } },
|
|
21775
21759
|
protocolVersion: PROTOCOL_VERSION
|
|
21776
21760
|
})).onRequest(methods.agent.session.new, async (context) => {
|
|
21777
21761
|
const created = threadStartResponseSchema.parse(
|
|
@@ -21788,86 +21772,68 @@ var CodexAcpAgent = class {
|
|
|
21788
21772
|
model: created.model ?? ""
|
|
21789
21773
|
};
|
|
21790
21774
|
return { configOptions: this.#configOptions(), sessionId: created.thread.id };
|
|
21775
|
+
}).onRequest(methods.agent.session.setConfigOption, async (context) => {
|
|
21776
|
+
this.#applySelection(context.params.configId, context.params.value);
|
|
21777
|
+
return { configOptions: this.#configOptions() };
|
|
21778
|
+
}).onRequest(methods.agent.session.setMode, async (context) => {
|
|
21779
|
+
this.#applySelection(MODE_SETTING_ID, context.params.modeId);
|
|
21780
|
+
return {};
|
|
21781
|
+
}).onRequest(methods.agent.session.load, async (context) => {
|
|
21782
|
+
const resumed = threadResumeResponseSchema.parse(
|
|
21783
|
+
await this.#appServer.request(
|
|
21784
|
+
"thread/resume",
|
|
21785
|
+
{ cwd: context.params.cwd, excludeTurns: false, threadId: context.params.sessionId },
|
|
21786
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21787
|
+
)
|
|
21788
|
+
);
|
|
21789
|
+
this.#selectRestoredThread(resumed);
|
|
21790
|
+
await this.#replayHistory(resumed.turns);
|
|
21791
|
+
return {};
|
|
21792
|
+
}).onRequest(methods.agent.session.fork, async (context) => {
|
|
21793
|
+
const forked = threadForkResponseSchema.parse(
|
|
21794
|
+
await this.#appServer.request(
|
|
21795
|
+
"thread/fork",
|
|
21796
|
+
{
|
|
21797
|
+
cwd: context.params.cwd,
|
|
21798
|
+
excludeTurns: false,
|
|
21799
|
+
threadId: context.params.sessionId
|
|
21800
|
+
},
|
|
21801
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21802
|
+
)
|
|
21803
|
+
);
|
|
21804
|
+
this.#selectRestoredThread(forked);
|
|
21805
|
+
await this.#replayHistory(forked.turns);
|
|
21806
|
+
return { sessionId: forked.thread.id };
|
|
21791
21807
|
}).onRequest(methods.agent.session.resume, async (context) => {
|
|
21792
21808
|
const resumed = threadResumeResponseSchema.parse(
|
|
21793
21809
|
await this.#appServer.request(
|
|
21794
21810
|
"thread/resume",
|
|
21795
|
-
{ cwd: context.params.cwd, threadId: context.params.sessionId },
|
|
21811
|
+
{ cwd: context.params.cwd, excludeTurns: true, threadId: context.params.sessionId },
|
|
21796
21812
|
AbortSignal.any([context.signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
21797
21813
|
)
|
|
21798
21814
|
);
|
|
21799
|
-
|
|
21800
|
-
|
|
21801
|
-
|
|
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
|
-
};
|
|
21812
|
-
return { configOptions: this.#configOptions() };
|
|
21815
|
+
this.#selectRestoredThread(resumed);
|
|
21816
|
+
return {};
|
|
21817
|
+
}).onRequest(methods.agent.session.prompt, async (context) => {
|
|
21818
|
+
return await this.#runTurn(promptInput(context.params.prompt), context.signal);
|
|
21813
21819
|
}).onRequest(methods.agent.session.list, async (context) => {
|
|
21814
|
-
const
|
|
21820
|
+
const decoded = threadListResponseSchema.parse(
|
|
21815
21821
|
await this.#appServer.request(
|
|
21816
21822
|
"thread/list",
|
|
21817
|
-
|
|
21818
|
-
AbortSignal.any([context.signal, AbortSignal.timeout(
|
|
21823
|
+
{ cursor: context.params.cursor ?? null },
|
|
21824
|
+
AbortSignal.any([context.signal, AbortSignal.timeout(SESSION_LIST_TIMEOUT_MILLISECONDS)])
|
|
21819
21825
|
)
|
|
21820
21826
|
);
|
|
21821
21827
|
return {
|
|
21822
|
-
nextCursor:
|
|
21823
|
-
sessions:
|
|
21824
|
-
// The thread id is a UUID, which satisfies the native session id contract.
|
|
21828
|
+
nextCursor: decoded.nextCursor ?? null,
|
|
21829
|
+
sessions: decoded.data.map((thread) => ({
|
|
21825
21830
|
additionalDirectories: [],
|
|
21826
|
-
cwd: thread.cwd
|
|
21831
|
+
cwd: thread.cwd,
|
|
21827
21832
|
sessionId: thread.id,
|
|
21828
|
-
title:
|
|
21829
|
-
updatedAt:
|
|
21833
|
+
title: thread.name ?? thread.preview ?? null,
|
|
21834
|
+
updatedAt: new Date(thread.updatedAt * 1e3).toISOString()
|
|
21830
21835
|
}))
|
|
21831
21836
|
};
|
|
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
21837
|
}).onRequest(methods.agent.session.close, async () => {
|
|
21872
21838
|
await this.#interruptTurn();
|
|
21873
21839
|
}).onNotification(methods.agent.session.cancel, async () => {
|
|
@@ -21937,6 +21903,56 @@ var CodexAcpAgent = class {
|
|
|
21937
21903
|
options.push(modeSetting(this.#selection.mode));
|
|
21938
21904
|
return options;
|
|
21939
21905
|
};
|
|
21906
|
+
#selectRestoredThread = (thread) => {
|
|
21907
|
+
this.#nativeSessionId = thread.thread.id;
|
|
21908
|
+
this.#selection = {
|
|
21909
|
+
...this.#selection,
|
|
21910
|
+
effort: thread.reasoningEffort ?? this.#selection.effort,
|
|
21911
|
+
model: thread.model ?? this.#selection.model,
|
|
21912
|
+
fastMode: thread.serviceTier === SERVICE_TIER_FAST
|
|
21913
|
+
};
|
|
21914
|
+
};
|
|
21915
|
+
#replayHistory = async (turns) => {
|
|
21916
|
+
for (const turn of turns ?? []) {
|
|
21917
|
+
for (const rawItem of turn.items) {
|
|
21918
|
+
const item = decodeThreadItem(rawItem);
|
|
21919
|
+
if (item === null) {
|
|
21920
|
+
continue;
|
|
21921
|
+
}
|
|
21922
|
+
if (item.type === "userMessage") {
|
|
21923
|
+
const text3 = item.content.flatMap((content3) => {
|
|
21924
|
+
if (typeof content3 !== "object" || content3 === null) {
|
|
21925
|
+
return [];
|
|
21926
|
+
}
|
|
21927
|
+
const type = Reflect.get(content3, "type");
|
|
21928
|
+
const text4 = Reflect.get(content3, "text");
|
|
21929
|
+
return type === "text" && typeof text4 === "string" ? [text4] : [];
|
|
21930
|
+
}).join("");
|
|
21931
|
+
if (text3.length > 0) {
|
|
21932
|
+
await this.#emit({
|
|
21933
|
+
content: { text: text3, type: "text" },
|
|
21934
|
+
messageId: item.id,
|
|
21935
|
+
sessionUpdate: "user_message_chunk"
|
|
21936
|
+
});
|
|
21937
|
+
}
|
|
21938
|
+
continue;
|
|
21939
|
+
}
|
|
21940
|
+
if (item.type === "agentMessage") {
|
|
21941
|
+
await this.#emit({
|
|
21942
|
+
_meta: agentMessageMeta(item.phase),
|
|
21943
|
+
content: { text: item.text, type: "text" },
|
|
21944
|
+
messageId: item.id,
|
|
21945
|
+
sessionUpdate: "agent_message_chunk"
|
|
21946
|
+
});
|
|
21947
|
+
continue;
|
|
21948
|
+
}
|
|
21949
|
+
const update = toolCallUpdate(item);
|
|
21950
|
+
if (update !== null) {
|
|
21951
|
+
await this.#emit({ ...update, sessionUpdate: "tool_call_update" });
|
|
21952
|
+
}
|
|
21953
|
+
}
|
|
21954
|
+
}
|
|
21955
|
+
};
|
|
21940
21956
|
/**
|
|
21941
21957
|
* Applies one `session/set_config_option`. Switching models re-resolves the effort the way Codex
|
|
21942
21958
|
* does — the current effort when the new model supports it, otherwise the model's own default —
|
|
@@ -38690,7 +38706,7 @@ var responseSchema = external_exports.union([
|
|
|
38690
38706
|
external_exports.object({ id: external_exports.number(), result: external_exports.unknown() }),
|
|
38691
38707
|
external_exports.object({ method: external_exports.string() })
|
|
38692
38708
|
]);
|
|
38693
|
-
var
|
|
38709
|
+
var threadSchema = external_exports.object({
|
|
38694
38710
|
thread: external_exports.object({
|
|
38695
38711
|
id: nativeSessionIdSchema,
|
|
38696
38712
|
cwd: external_exports.string().min(1).max(2048).refine((path2) => !path2.includes("\0"))
|
|
@@ -38994,7 +39010,7 @@ async function readCodexHistoryWithOptions(agent, cwd, nativeSessionId, signal,
|
|
|
38994
39010
|
});
|
|
38995
39011
|
break;
|
|
38996
39012
|
case "metadata": {
|
|
38997
|
-
const { thread } =
|
|
39013
|
+
const { thread } = threadSchema.parse(message.result);
|
|
38998
39014
|
state = { kind: "turns", requestId: 3, thread };
|
|
38999
39015
|
send2({
|
|
39000
39016
|
id: state.requestId,
|