@moxt-ai/mobius 0.0.111 → 0.0.113
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 +76 -3
- package/dist/acp/codex/agent.js.map +1 -1
- package/dist/acp/codex/app-server-protocol.d.ts +3 -0
- package/dist/acp/codex/app-server-protocol.d.ts.map +1 -1
- package/dist/acp/codex/app-server-protocol.js +1 -0
- package/dist/acp/codex/app-server-protocol.js.map +1 -1
- package/dist/acp/codex/items.d.ts +1 -1
- package/dist/acp/codex/items.d.ts.map +1 -1
- package/dist/acp/codex/items.js +6 -3
- package/dist/acp/codex/items.js.map +1 -1
- package/dist/cli.js +201 -25
- package/dist/cli.js.map +2 -2
- package/dist/daemon-session-commands.d.ts +8 -1
- package/dist/daemon-session-commands.d.ts.map +1 -1
- package/dist/daemon-session-commands.js +9 -6
- package/dist/daemon-session-commands.js.map +1 -1
- package/dist/daemon-turn-reconciliation.d.ts +4 -1
- package/dist/daemon-turn-reconciliation.d.ts.map +1 -1
- package/dist/daemon-turn-reconciliation.js +27 -5
- package/dist/daemon-turn-reconciliation.js.map +1 -1
- package/dist/index.js +200 -24
- package/dist/index.js.map +2 -2
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +32 -10
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +200 -24
- package/dist/runtime.js.map +2 -2
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3381,7 +3381,7 @@ var program = new Command();
|
|
|
3381
3381
|
// package.json
|
|
3382
3382
|
var package_default = {
|
|
3383
3383
|
name: "@moxt-ai/mobius",
|
|
3384
|
-
version: "0.0.
|
|
3384
|
+
version: "0.0.113",
|
|
3385
3385
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
3386
3386
|
type: "module",
|
|
3387
3387
|
bin: {
|
|
@@ -24607,6 +24607,7 @@ var turnSchema = external_exports.object({
|
|
|
24607
24607
|
id: boundedText(256),
|
|
24608
24608
|
status: turnStatusSchema
|
|
24609
24609
|
});
|
|
24610
|
+
var turnSteerResponseSchema = external_exports.object({ turnId: boundedText(256) });
|
|
24610
24611
|
var turnNotificationSchema = external_exports.object({
|
|
24611
24612
|
thread: external_exports.object({ id: boundedText(256) }).nullish(),
|
|
24612
24613
|
threadId: boundedText(256),
|
|
@@ -24991,7 +24992,10 @@ function presentToolItem(item) {
|
|
|
24991
24992
|
kind: "execute",
|
|
24992
24993
|
locations: [],
|
|
24993
24994
|
rawInput: { command: item.command, cwd: item.cwd },
|
|
24994
|
-
rawOutput: {
|
|
24995
|
+
rawOutput: {
|
|
24996
|
+
...item.exitCode == null ? {} : { exitCode: item.exitCode },
|
|
24997
|
+
output: truncate(output2, TOOL_OUTPUT_CHARACTER_LIMIT)
|
|
24998
|
+
},
|
|
24995
24999
|
status: commandStatus(item.status),
|
|
24996
25000
|
title: truncate(firstLine(item.command), TITLE_CHARACTER_LIMIT)
|
|
24997
25001
|
};
|
|
@@ -25047,7 +25051,7 @@ function presentToolItem(item) {
|
|
|
25047
25051
|
}
|
|
25048
25052
|
return null;
|
|
25049
25053
|
}
|
|
25050
|
-
function toolCallUpdate(item) {
|
|
25054
|
+
function toolCallUpdate(item, lifecycle) {
|
|
25051
25055
|
const presentation = presentToolItem(item);
|
|
25052
25056
|
if (presentation === null) {
|
|
25053
25057
|
return null;
|
|
@@ -25058,7 +25062,7 @@ function toolCallUpdate(item) {
|
|
|
25058
25062
|
locations: [...presentation.locations],
|
|
25059
25063
|
rawInput: presentation.rawInput,
|
|
25060
25064
|
rawOutput: presentation.rawOutput,
|
|
25061
|
-
status: presentation.status,
|
|
25065
|
+
status: lifecycle === "completed" && presentation.status === "in_progress" ? "completed" : presentation.status,
|
|
25062
25066
|
title: presentation.title,
|
|
25063
25067
|
toolCallId: item.id
|
|
25064
25068
|
};
|
|
@@ -25167,6 +25171,54 @@ function promptInput(prompt) {
|
|
|
25167
25171
|
}
|
|
25168
25172
|
return input2;
|
|
25169
25173
|
}
|
|
25174
|
+
function steeringPromptInput(prompt) {
|
|
25175
|
+
const input2 = [];
|
|
25176
|
+
for (const block of prompt) {
|
|
25177
|
+
if (typeof block !== "object" || block === null) {
|
|
25178
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25179
|
+
}
|
|
25180
|
+
const type = Reflect.get(block, "type");
|
|
25181
|
+
if (type === "text") {
|
|
25182
|
+
const text = Reflect.get(block, "text");
|
|
25183
|
+
if (typeof text !== "string") {
|
|
25184
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25185
|
+
}
|
|
25186
|
+
input2.push({ text, text_elements: [], type: "text" });
|
|
25187
|
+
continue;
|
|
25188
|
+
}
|
|
25189
|
+
if (type === "image") {
|
|
25190
|
+
const data = Reflect.get(block, "data");
|
|
25191
|
+
const mimeType = Reflect.get(block, "mimeType");
|
|
25192
|
+
if (typeof data !== "string" || typeof mimeType !== "string") {
|
|
25193
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25194
|
+
}
|
|
25195
|
+
input2.push({ type: "image", url: `data:${mimeType};base64,${data}` });
|
|
25196
|
+
continue;
|
|
25197
|
+
}
|
|
25198
|
+
if (type === "resource") {
|
|
25199
|
+
const resource = Reflect.get(block, "resource");
|
|
25200
|
+
if (typeof resource !== "object" || resource === null) {
|
|
25201
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25202
|
+
}
|
|
25203
|
+
const text = Reflect.get(resource, "text");
|
|
25204
|
+
if (text !== void 0 && typeof text !== "string") {
|
|
25205
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25206
|
+
}
|
|
25207
|
+
input2.push({ text: text ?? "", text_elements: [], type: "text" });
|
|
25208
|
+
continue;
|
|
25209
|
+
}
|
|
25210
|
+
if (type === "resource_link") {
|
|
25211
|
+
const uri = Reflect.get(block, "uri");
|
|
25212
|
+
if (typeof uri !== "string") {
|
|
25213
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
25214
|
+
}
|
|
25215
|
+
input2.push({ text: `Resource: ${uri}`, text_elements: [], type: "text" });
|
|
25216
|
+
continue;
|
|
25217
|
+
}
|
|
25218
|
+
throw new AcpExecutionError("Codex received an unsupported steering prompt", {}, "invalid_request");
|
|
25219
|
+
}
|
|
25220
|
+
return input2;
|
|
25221
|
+
}
|
|
25170
25222
|
function modelValues(models) {
|
|
25171
25223
|
return models.map((model) => ({
|
|
25172
25224
|
description: model.description ?? "",
|
|
@@ -25345,6 +25397,7 @@ var CodexAcpAgent = class {
|
|
|
25345
25397
|
this.#app = createAgentApp({ name: "mobius-codex" }).onConnect((connection) => {
|
|
25346
25398
|
this.#connection = connection;
|
|
25347
25399
|
}).onRequest(methods.agent.initialize, async () => ({
|
|
25400
|
+
_meta: { steering: { supported: true } },
|
|
25348
25401
|
agentCapabilities: {
|
|
25349
25402
|
loadSession: true,
|
|
25350
25403
|
promptCapabilities: { embeddedContext: true, image: true },
|
|
@@ -25418,7 +25471,11 @@ var CodexAcpAgent = class {
|
|
|
25418
25471
|
return { configOptions: this.#configOptions() };
|
|
25419
25472
|
}).onRequest(methods.agent.session.prompt, async (context) => {
|
|
25420
25473
|
return await this.#runTurn(promptInput(context.params.prompt), context.signal);
|
|
25421
|
-
}).onRequest(
|
|
25474
|
+
}).onRequest(
|
|
25475
|
+
"_session/steering",
|
|
25476
|
+
(params) => params,
|
|
25477
|
+
async (context) => await this.#steerTurn(context.params, context.signal)
|
|
25478
|
+
).onRequest(methods.agent.session.list, async (context) => {
|
|
25422
25479
|
const decoded = threadListResponseSchema.parse(
|
|
25423
25480
|
await this.#appServer.request(
|
|
25424
25481
|
"thread/list",
|
|
@@ -25585,7 +25642,7 @@ var CodexAcpAgent = class {
|
|
|
25585
25642
|
});
|
|
25586
25643
|
continue;
|
|
25587
25644
|
}
|
|
25588
|
-
const update = toolCallUpdate(item);
|
|
25645
|
+
const update = toolCallUpdate(item, "snapshot");
|
|
25589
25646
|
if (update !== null) {
|
|
25590
25647
|
await this.#emit({ ...update, sessionUpdate: "tool_call_update" });
|
|
25591
25648
|
}
|
|
@@ -25782,7 +25839,7 @@ var CodexAcpAgent = class {
|
|
|
25782
25839
|
});
|
|
25783
25840
|
return;
|
|
25784
25841
|
}
|
|
25785
|
-
const update = toolCallUpdate(item);
|
|
25842
|
+
const update = toolCallUpdate(item, method === "item/completed" ? "completed" : "started");
|
|
25786
25843
|
if (update !== null) {
|
|
25787
25844
|
await this.#enqueue(async () => {
|
|
25788
25845
|
await this.#emit({ ...update, sessionUpdate: "tool_call_update" });
|
|
@@ -25968,6 +26025,35 @@ var CodexAcpAgent = class {
|
|
|
25968
26025
|
}
|
|
25969
26026
|
}
|
|
25970
26027
|
};
|
|
26028
|
+
#steerTurn = async (params, signal) => {
|
|
26029
|
+
if (typeof params !== "object" || params === null) {
|
|
26030
|
+
throw new AcpExecutionError("Codex received an invalid steering request", {}, "invalid_request");
|
|
26031
|
+
}
|
|
26032
|
+
const sessionId = Reflect.get(params, "sessionId");
|
|
26033
|
+
const prompt = Reflect.get(params, "prompt");
|
|
26034
|
+
if (typeof sessionId !== "string" || !Array.isArray(prompt)) {
|
|
26035
|
+
throw new AcpExecutionError("Codex received an invalid steering request", {}, "invalid_request");
|
|
26036
|
+
}
|
|
26037
|
+
const active = this.#turn;
|
|
26038
|
+
if (sessionId !== this.#nativeSessionId || active === null || active.turn.id.length === 0) {
|
|
26039
|
+
return { outcome: "promptRequired", reason: "noRunningTurn" };
|
|
26040
|
+
}
|
|
26041
|
+
const input2 = steeringPromptInput(prompt);
|
|
26042
|
+
if (input2.length === 0) {
|
|
26043
|
+
throw new AcpExecutionError("Codex received an empty steering request", {}, "invalid_request");
|
|
26044
|
+
}
|
|
26045
|
+
const response = turnSteerResponseSchema.parse(
|
|
26046
|
+
await this.#appServer.request(
|
|
26047
|
+
"turn/steer",
|
|
26048
|
+
{ expectedTurnId: active.turn.id, input: input2, threadId: this.#nativeSessionId },
|
|
26049
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
26050
|
+
)
|
|
26051
|
+
);
|
|
26052
|
+
if (response.turnId !== active.turn.id) {
|
|
26053
|
+
throw new AcpExecutionError("Codex steered an unexpected turn", {}, "steering_target_unavailable");
|
|
26054
|
+
}
|
|
26055
|
+
return { outcome: "injected" };
|
|
26056
|
+
};
|
|
25971
26057
|
#interruptTurn = async () => {
|
|
25972
26058
|
const turn = this.#turn;
|
|
25973
26059
|
if (turn === null) {
|
|
@@ -28567,12 +28653,14 @@ var encodeAgentInstallCancelledEvent = (message) => encode3(message, agentInstal
|
|
|
28567
28653
|
|
|
28568
28654
|
// ../protocol/src/messages.ts
|
|
28569
28655
|
var SESSION_PROMPT_KIND = "session.prompt";
|
|
28656
|
+
var SESSION_PROMPT_DISPOSITION_KIND = "session.prompt.disposition";
|
|
28570
28657
|
var RUNTIME_WORKSPACE_BINDING_ID = "workspace";
|
|
28571
28658
|
var SESSION_CANCEL_KIND = "session.cancel";
|
|
28572
28659
|
var RUNTIME_LIVENESS_READY_KIND = "runtime.liveness.ready";
|
|
28573
28660
|
var RUNTIME_HEARTBEAT_KIND = "runtime.heartbeat";
|
|
28574
28661
|
var RUNTIME_HEARTBEAT_ACK_KIND = "runtime.heartbeat.ack";
|
|
28575
28662
|
var SESSION_STARTED_KIND = "session.started";
|
|
28663
|
+
var SESSION_QUEUED_KIND = "session.queued";
|
|
28576
28664
|
var AGENT_MESSAGE_DELTA_KIND = "agent.message.delta";
|
|
28577
28665
|
var AGENT_ACTIVITY_KIND = "agent.activity";
|
|
28578
28666
|
var AGENT_ACTIVITY_NARRATION_KIND = "agent.activity.narration";
|
|
@@ -28856,6 +28944,30 @@ function decodeSessionCancelCommand(encoded) {
|
|
|
28856
28944
|
sessionId: readIdentifier(value, "sessionId")
|
|
28857
28945
|
};
|
|
28858
28946
|
}
|
|
28947
|
+
function decodeSessionPromptDispositionCommand(encoded) {
|
|
28948
|
+
const value = parseJson2(encoded);
|
|
28949
|
+
assertExactKeys(value, ["commandId", "disposition", "kind", "sessionId"]);
|
|
28950
|
+
assertKind(value, SESSION_PROMPT_DISPOSITION_KIND);
|
|
28951
|
+
if (readPromptDisposition(value) !== SessionPromptDisposition.Steer) {
|
|
28952
|
+
throw new ProtocolMessageError("Only queued prompts can be steered");
|
|
28953
|
+
}
|
|
28954
|
+
return {
|
|
28955
|
+
commandId: readIdentifier(value, "commandId"),
|
|
28956
|
+
disposition: SessionPromptDisposition.Steer,
|
|
28957
|
+
kind: SESSION_PROMPT_DISPOSITION_KIND,
|
|
28958
|
+
sessionId: readIdentifier(value, "sessionId")
|
|
28959
|
+
};
|
|
28960
|
+
}
|
|
28961
|
+
function decodeSessionQueuedEvent(encoded) {
|
|
28962
|
+
const value = parseJson2(encoded);
|
|
28963
|
+
assertExactKeys(value, ["commandId", "kind", "sessionId"]);
|
|
28964
|
+
assertKind(value, SESSION_QUEUED_KIND);
|
|
28965
|
+
return {
|
|
28966
|
+
commandId: readIdentifier(value, "commandId"),
|
|
28967
|
+
kind: SESSION_QUEUED_KIND,
|
|
28968
|
+
sessionId: readIdentifier(value, "sessionId")
|
|
28969
|
+
};
|
|
28970
|
+
}
|
|
28859
28971
|
function decodeRuntimeLivenessReadyEvent(encoded) {
|
|
28860
28972
|
const value = parseJson2(encoded);
|
|
28861
28973
|
assertExactKeys(value, ["kind"]);
|
|
@@ -28983,6 +29095,12 @@ function encodeSessionPromptCommand(message) {
|
|
|
28983
29095
|
function encodeSessionCancelCommand(message) {
|
|
28984
29096
|
return JSON.stringify(decodeSessionCancelCommand(JSON.stringify(message)));
|
|
28985
29097
|
}
|
|
29098
|
+
function encodeSessionPromptDispositionCommand(message) {
|
|
29099
|
+
return JSON.stringify(decodeSessionPromptDispositionCommand(JSON.stringify(message)));
|
|
29100
|
+
}
|
|
29101
|
+
function encodeSessionQueuedEvent(message) {
|
|
29102
|
+
return JSON.stringify(decodeSessionQueuedEvent(JSON.stringify(message)));
|
|
29103
|
+
}
|
|
28986
29104
|
function encodeRuntimeLivenessReadyEvent(message) {
|
|
28987
29105
|
return JSON.stringify(decodeRuntimeLivenessReadyEvent(JSON.stringify(message)));
|
|
28988
29106
|
}
|
|
@@ -29493,6 +29611,11 @@ var serviceToDaemonSignatures = {
|
|
|
29493
29611
|
encodeSessionPromptCommand,
|
|
29494
29612
|
decodeSessionPromptCommand
|
|
29495
29613
|
),
|
|
29614
|
+
[SESSION_PROMPT_DISPOSITION_KIND]: defineMessageSignature(
|
|
29615
|
+
SESSION_PROMPT_DISPOSITION_KIND,
|
|
29616
|
+
encodeSessionPromptDispositionCommand,
|
|
29617
|
+
decodeSessionPromptDispositionCommand
|
|
29618
|
+
),
|
|
29496
29619
|
[WORKSPACE_LIST_KIND]: defineMessageSignature(
|
|
29497
29620
|
WORKSPACE_LIST_KIND,
|
|
29498
29621
|
encodeWorkspaceListCommand,
|
|
@@ -29563,6 +29686,11 @@ var daemonToServiceSignatures = {
|
|
|
29563
29686
|
encodeSessionsQueriedEvent,
|
|
29564
29687
|
decodeSessionsQueriedEvent
|
|
29565
29688
|
),
|
|
29689
|
+
[SESSION_QUEUED_KIND]: defineMessageSignature(
|
|
29690
|
+
SESSION_QUEUED_KIND,
|
|
29691
|
+
encodeSessionQueuedEvent,
|
|
29692
|
+
decodeSessionQueuedEvent
|
|
29693
|
+
),
|
|
29566
29694
|
[NATIVE_SESSION_RESULT_KIND]: defineMessageSignature(
|
|
29567
29695
|
NATIVE_SESSION_RESULT_KIND,
|
|
29568
29696
|
encodeNativeSessionResult,
|
|
@@ -35999,7 +36127,7 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
35999
36127
|
reportOperationFailure(socket, command.requestId, command.sessionId, error62);
|
|
36000
36128
|
}
|
|
36001
36129
|
}
|
|
36002
|
-
async function executePrompt(operations, publisher, command, config2, directories, audit, sessions, attemptId, activateAttempt, waitForSessionAvailability, timer, signal, recordLiveText, cancellationRequested) {
|
|
36130
|
+
async function executePrompt(operations, publisher, command, config2, directories, audit, sessions, attemptId, activateAttempt, acknowledgeQueued, waitForSessionAvailability, timer, signal, recordLiveText, cancellationRequested) {
|
|
36003
36131
|
const activities = new CoalescingDaemonActivityPublisher(timer, (activity2) => {
|
|
36004
36132
|
publisher.publish(command.sessionId, daemonActivity(command, activity2));
|
|
36005
36133
|
});
|
|
@@ -36037,6 +36165,9 @@ async function executePrompt(operations, publisher, command, config2, directorie
|
|
|
36037
36165
|
AGENT_TEXT_MAXIMUM_LENGTH
|
|
36038
36166
|
);
|
|
36039
36167
|
try {
|
|
36168
|
+
if (command.disposition === SessionPromptDisposition.Queue) {
|
|
36169
|
+
acknowledgeQueued();
|
|
36170
|
+
}
|
|
36040
36171
|
const resolved = await resolveSessionDirectories(
|
|
36041
36172
|
directories,
|
|
36042
36173
|
command.bindingId,
|
|
@@ -36046,10 +36177,10 @@ async function executePrompt(operations, publisher, command, config2, directorie
|
|
|
36046
36177
|
);
|
|
36047
36178
|
const agent = config2.catalog.find(command.agentId);
|
|
36048
36179
|
const availability = await waitForSessionAvailability(signal);
|
|
36049
|
-
if (availability === "busy") {
|
|
36180
|
+
if (availability.kind === "busy") {
|
|
36050
36181
|
throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
|
|
36051
36182
|
}
|
|
36052
|
-
if (availability === "queue-target-unavailable") {
|
|
36183
|
+
if (availability.kind === "queue-target-unavailable") {
|
|
36053
36184
|
throw new AcpExecutionError(
|
|
36054
36185
|
"The queued prompt target is unavailable",
|
|
36055
36186
|
{},
|
|
@@ -36067,7 +36198,7 @@ async function executePrompt(operations, publisher, command, config2, directorie
|
|
|
36067
36198
|
sessionId: command.sessionId,
|
|
36068
36199
|
signal
|
|
36069
36200
|
});
|
|
36070
|
-
if (
|
|
36201
|
+
if (availability.disposition === SessionPromptDisposition.Steer) {
|
|
36071
36202
|
assertAppliedSessionConfiguration(prepared.configOptions, sessionConfigurations ?? []);
|
|
36072
36203
|
} else {
|
|
36073
36204
|
await applyCompleteSessionConfiguration(
|
|
@@ -36102,7 +36233,7 @@ async function executePrompt(operations, publisher, command, config2, directorie
|
|
|
36102
36233
|
});
|
|
36103
36234
|
const attachments = await resolvePromptArtifacts(config2, command, signal);
|
|
36104
36235
|
let stopReason;
|
|
36105
|
-
if (
|
|
36236
|
+
if (availability.disposition === SessionPromptDisposition.Steer) {
|
|
36106
36237
|
await sessions.steerPrompt({
|
|
36107
36238
|
additionalDirectories: resolved.additionalDirectories,
|
|
36108
36239
|
agent: executionAgent,
|
|
@@ -36122,7 +36253,7 @@ async function executePrompt(operations, publisher, command, config2, directorie
|
|
|
36122
36253
|
agent: executionAgent,
|
|
36123
36254
|
commandId: command.commandId,
|
|
36124
36255
|
cwd: resolved.cwd,
|
|
36125
|
-
disposition:
|
|
36256
|
+
disposition: availability.disposition,
|
|
36126
36257
|
images: attachments.images,
|
|
36127
36258
|
onActivity: activities.record,
|
|
36128
36259
|
onNarration: (increment) => {
|
|
@@ -37689,7 +37820,7 @@ var ActiveDaemonTurn = class {
|
|
|
37689
37820
|
#controller;
|
|
37690
37821
|
#finished = Promise.withResolvers();
|
|
37691
37822
|
#cancellationRequested = false;
|
|
37692
|
-
#
|
|
37823
|
+
#dispatch;
|
|
37693
37824
|
#text = "";
|
|
37694
37825
|
#truncated = false;
|
|
37695
37826
|
#sequence = 0;
|
|
@@ -37699,15 +37830,32 @@ var ActiveDaemonTurn = class {
|
|
|
37699
37830
|
this.attemptId = attemptId;
|
|
37700
37831
|
this.command = command;
|
|
37701
37832
|
this.#controller = new AbortController();
|
|
37833
|
+
this.#dispatch = command.disposition === SessionPromptDisposition.Queue ? { kind: "queued", promotion: Promise.withResolvers() } : { kind: "pending" };
|
|
37702
37834
|
}
|
|
37703
37835
|
abortDaemon = () => {
|
|
37704
37836
|
this.#controller.abort();
|
|
37705
37837
|
};
|
|
37706
37838
|
finish = () => this.#finished.resolve();
|
|
37707
37839
|
accept = () => {
|
|
37708
|
-
this.#
|
|
37840
|
+
this.#dispatch = { kind: "accepted" };
|
|
37709
37841
|
return { epoch: this.#epoch, sequence: 0 };
|
|
37710
37842
|
};
|
|
37843
|
+
promoteQueuedPrompt = (command) => {
|
|
37844
|
+
if (command.commandId !== this.command.commandId || command.sessionId !== this.command.sessionId || this.#dispatch.kind !== "queued") {
|
|
37845
|
+
return false;
|
|
37846
|
+
}
|
|
37847
|
+
const promotion = this.#dispatch.promotion;
|
|
37848
|
+
this.#dispatch = { kind: "promoted" };
|
|
37849
|
+
promotion.resolve();
|
|
37850
|
+
return true;
|
|
37851
|
+
};
|
|
37852
|
+
queuePromotion = () => {
|
|
37853
|
+
if (this.#dispatch.kind === "queued") {
|
|
37854
|
+
return this.#dispatch.promotion.promise;
|
|
37855
|
+
}
|
|
37856
|
+
return this.#dispatch.kind === "promoted" ? Promise.resolve() : null;
|
|
37857
|
+
};
|
|
37858
|
+
effectiveDisposition = () => this.#dispatch.kind === "promoted" ? SessionPromptDisposition.Steer : this.command.disposition;
|
|
37711
37859
|
recordText = (delta) => {
|
|
37712
37860
|
this.#sequence += 1;
|
|
37713
37861
|
this.#text += delta;
|
|
@@ -37729,7 +37877,7 @@ var ActiveDaemonTurn = class {
|
|
|
37729
37877
|
this.#interaction = null;
|
|
37730
37878
|
}
|
|
37731
37879
|
};
|
|
37732
|
-
snapshot = () => this.#accepted ? {
|
|
37880
|
+
snapshot = () => this.#dispatch.kind === "accepted" ? {
|
|
37733
37881
|
commandId: decodeIdentifier(this.command.commandId),
|
|
37734
37882
|
prompt: this.command.prompt,
|
|
37735
37883
|
text: this.#text,
|
|
@@ -37745,7 +37893,7 @@ var ActiveDaemonTurn = class {
|
|
|
37745
37893
|
return "already-requested";
|
|
37746
37894
|
}
|
|
37747
37895
|
this.#cancellationRequested = true;
|
|
37748
|
-
if (
|
|
37896
|
+
if (this.#dispatch.kind !== "accepted") {
|
|
37749
37897
|
this.#controller.abort(new Error("The queued Agent turn was cancelled"));
|
|
37750
37898
|
return "pending";
|
|
37751
37899
|
}
|
|
@@ -39549,24 +39697,34 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
39549
39697
|
);
|
|
39550
39698
|
});
|
|
39551
39699
|
};
|
|
39552
|
-
const waitForSessionAvailability = async (command, waitSignal) => {
|
|
39553
|
-
if (
|
|
39554
|
-
return "available";
|
|
39700
|
+
const waitForSessionAvailability = async (command, queuedTurn, waitSignal) => {
|
|
39701
|
+
if (queuedTurn.effectiveDisposition() === SessionPromptDisposition.Steer) {
|
|
39702
|
+
return { disposition: SessionPromptDisposition.Steer, kind: "available" };
|
|
39555
39703
|
}
|
|
39556
39704
|
for (; ; ) {
|
|
39557
39705
|
const first = [...activeTurns.values()].find(
|
|
39558
39706
|
(turn) => turn.command.sessionId === command.sessionId && turn.command.disposition !== SessionPromptDisposition.Steer
|
|
39559
39707
|
);
|
|
39560
39708
|
if (first === void 0 || first.command.commandId === command.commandId) {
|
|
39561
|
-
return command.disposition !== SessionPromptDisposition.Queue || operations.isTerminalExecution(command.targetCommandId, command.sessionId) ? "available" : "queue-target-unavailable";
|
|
39709
|
+
return command.disposition !== SessionPromptDisposition.Queue || operations.isTerminalExecution(command.targetCommandId, command.sessionId) ? { disposition: queuedTurn.effectiveDisposition(), kind: "available" } : { kind: "queue-target-unavailable" };
|
|
39562
39710
|
}
|
|
39563
39711
|
if (command.disposition !== SessionPromptDisposition.Queue) {
|
|
39564
|
-
return "busy";
|
|
39712
|
+
return { kind: "busy" };
|
|
39565
39713
|
}
|
|
39566
39714
|
if (first.command.commandId !== command.targetCommandId) {
|
|
39567
|
-
return "queue-target-unavailable";
|
|
39715
|
+
return { kind: "queue-target-unavailable" };
|
|
39716
|
+
}
|
|
39717
|
+
const promotion = queuedTurn.queuePromotion();
|
|
39718
|
+
if (promotion === null) {
|
|
39719
|
+
throw new Error("The queued prompt cannot be promoted");
|
|
39720
|
+
}
|
|
39721
|
+
const decision = await Promise.race([
|
|
39722
|
+
waitForTurnCompletion(first, waitSignal).then(() => "target-completed"),
|
|
39723
|
+
promotion.then(() => "promoted")
|
|
39724
|
+
]);
|
|
39725
|
+
if (decision === "promoted") {
|
|
39726
|
+
return { disposition: SessionPromptDisposition.Steer, kind: "available" };
|
|
39568
39727
|
}
|
|
39569
|
-
await waitForTurnCompletion(first, waitSignal);
|
|
39570
39728
|
}
|
|
39571
39729
|
};
|
|
39572
39730
|
const connectionLiveness = new RelayConnectionLiveness(timer, {
|
|
@@ -39719,6 +39877,19 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
39719
39877
|
});
|
|
39720
39878
|
return;
|
|
39721
39879
|
}
|
|
39880
|
+
if (kind === SESSION_PROMPT_DISPOSITION_KIND) {
|
|
39881
|
+
const disposition = message;
|
|
39882
|
+
const turn2 = activeTurns.get(disposition.commandId);
|
|
39883
|
+
if (turn2 === void 0 || !turn2.promoteQueuedPrompt(disposition)) {
|
|
39884
|
+
reportOperationFailure(
|
|
39885
|
+
socket,
|
|
39886
|
+
disposition.commandId,
|
|
39887
|
+
disposition.sessionId,
|
|
39888
|
+
new Error("The queued prompt is unavailable")
|
|
39889
|
+
);
|
|
39890
|
+
}
|
|
39891
|
+
return;
|
|
39892
|
+
}
|
|
39722
39893
|
if (kind === WORKSPACE_LIST_KIND) {
|
|
39723
39894
|
const command2 = message;
|
|
39724
39895
|
void executeWorkspaceList(socket, command2, directories, audit, connectionController.signal);
|
|
@@ -39828,7 +39999,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
39828
39999
|
sessions,
|
|
39829
40000
|
receipt.attemptId,
|
|
39830
40001
|
turn.accept,
|
|
39831
|
-
(
|
|
40002
|
+
() => send(socket, {
|
|
40003
|
+
commandId: command.commandId,
|
|
40004
|
+
kind: SESSION_QUEUED_KIND,
|
|
40005
|
+
sessionId: command.sessionId
|
|
40006
|
+
}),
|
|
40007
|
+
(waitSignal) => waitForSessionAvailability(command, turn, waitSignal),
|
|
39832
40008
|
timer,
|
|
39833
40009
|
turn.signal,
|
|
39834
40010
|
turn.recordText,
|