@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/index.js
CHANGED
|
@@ -20433,12 +20433,14 @@ var encodeAgentInstallCancelledEvent = (message) => encode3(message, agentInstal
|
|
|
20433
20433
|
|
|
20434
20434
|
// ../protocol/src/messages.ts
|
|
20435
20435
|
var SESSION_PROMPT_KIND = "session.prompt";
|
|
20436
|
+
var SESSION_PROMPT_DISPOSITION_KIND = "session.prompt.disposition";
|
|
20436
20437
|
var RUNTIME_WORKSPACE_BINDING_ID = "workspace";
|
|
20437
20438
|
var SESSION_CANCEL_KIND = "session.cancel";
|
|
20438
20439
|
var RUNTIME_LIVENESS_READY_KIND = "runtime.liveness.ready";
|
|
20439
20440
|
var RUNTIME_HEARTBEAT_KIND = "runtime.heartbeat";
|
|
20440
20441
|
var RUNTIME_HEARTBEAT_ACK_KIND = "runtime.heartbeat.ack";
|
|
20441
20442
|
var SESSION_STARTED_KIND = "session.started";
|
|
20443
|
+
var SESSION_QUEUED_KIND = "session.queued";
|
|
20442
20444
|
var AGENT_MESSAGE_DELTA_KIND = "agent.message.delta";
|
|
20443
20445
|
var AGENT_ACTIVITY_KIND = "agent.activity";
|
|
20444
20446
|
var AGENT_ACTIVITY_NARRATION_KIND = "agent.activity.narration";
|
|
@@ -20722,6 +20724,30 @@ function decodeSessionCancelCommand(encoded) {
|
|
|
20722
20724
|
sessionId: readIdentifier(value, "sessionId")
|
|
20723
20725
|
};
|
|
20724
20726
|
}
|
|
20727
|
+
function decodeSessionPromptDispositionCommand(encoded) {
|
|
20728
|
+
const value = parseJson2(encoded);
|
|
20729
|
+
assertExactKeys(value, ["commandId", "disposition", "kind", "sessionId"]);
|
|
20730
|
+
assertKind(value, SESSION_PROMPT_DISPOSITION_KIND);
|
|
20731
|
+
if (readPromptDisposition(value) !== SessionPromptDisposition.Steer) {
|
|
20732
|
+
throw new ProtocolMessageError("Only queued prompts can be steered");
|
|
20733
|
+
}
|
|
20734
|
+
return {
|
|
20735
|
+
commandId: readIdentifier(value, "commandId"),
|
|
20736
|
+
disposition: SessionPromptDisposition.Steer,
|
|
20737
|
+
kind: SESSION_PROMPT_DISPOSITION_KIND,
|
|
20738
|
+
sessionId: readIdentifier(value, "sessionId")
|
|
20739
|
+
};
|
|
20740
|
+
}
|
|
20741
|
+
function decodeSessionQueuedEvent(encoded) {
|
|
20742
|
+
const value = parseJson2(encoded);
|
|
20743
|
+
assertExactKeys(value, ["commandId", "kind", "sessionId"]);
|
|
20744
|
+
assertKind(value, SESSION_QUEUED_KIND);
|
|
20745
|
+
return {
|
|
20746
|
+
commandId: readIdentifier(value, "commandId"),
|
|
20747
|
+
kind: SESSION_QUEUED_KIND,
|
|
20748
|
+
sessionId: readIdentifier(value, "sessionId")
|
|
20749
|
+
};
|
|
20750
|
+
}
|
|
20725
20751
|
function decodeRuntimeLivenessReadyEvent(encoded) {
|
|
20726
20752
|
const value = parseJson2(encoded);
|
|
20727
20753
|
assertExactKeys(value, ["kind"]);
|
|
@@ -20849,6 +20875,12 @@ function encodeSessionPromptCommand(message) {
|
|
|
20849
20875
|
function encodeSessionCancelCommand(message) {
|
|
20850
20876
|
return JSON.stringify(decodeSessionCancelCommand(JSON.stringify(message)));
|
|
20851
20877
|
}
|
|
20878
|
+
function encodeSessionPromptDispositionCommand(message) {
|
|
20879
|
+
return JSON.stringify(decodeSessionPromptDispositionCommand(JSON.stringify(message)));
|
|
20880
|
+
}
|
|
20881
|
+
function encodeSessionQueuedEvent(message) {
|
|
20882
|
+
return JSON.stringify(decodeSessionQueuedEvent(JSON.stringify(message)));
|
|
20883
|
+
}
|
|
20852
20884
|
function encodeRuntimeLivenessReadyEvent(message) {
|
|
20853
20885
|
return JSON.stringify(decodeRuntimeLivenessReadyEvent(JSON.stringify(message)));
|
|
20854
20886
|
}
|
|
@@ -21359,6 +21391,11 @@ var serviceToDaemonSignatures = {
|
|
|
21359
21391
|
encodeSessionPromptCommand,
|
|
21360
21392
|
decodeSessionPromptCommand
|
|
21361
21393
|
),
|
|
21394
|
+
[SESSION_PROMPT_DISPOSITION_KIND]: defineMessageSignature(
|
|
21395
|
+
SESSION_PROMPT_DISPOSITION_KIND,
|
|
21396
|
+
encodeSessionPromptDispositionCommand,
|
|
21397
|
+
decodeSessionPromptDispositionCommand
|
|
21398
|
+
),
|
|
21362
21399
|
[WORKSPACE_LIST_KIND]: defineMessageSignature(
|
|
21363
21400
|
WORKSPACE_LIST_KIND,
|
|
21364
21401
|
encodeWorkspaceListCommand,
|
|
@@ -21429,6 +21466,11 @@ var daemonToServiceSignatures = {
|
|
|
21429
21466
|
encodeSessionsQueriedEvent,
|
|
21430
21467
|
decodeSessionsQueriedEvent
|
|
21431
21468
|
),
|
|
21469
|
+
[SESSION_QUEUED_KIND]: defineMessageSignature(
|
|
21470
|
+
SESSION_QUEUED_KIND,
|
|
21471
|
+
encodeSessionQueuedEvent,
|
|
21472
|
+
decodeSessionQueuedEvent
|
|
21473
|
+
),
|
|
21432
21474
|
[NATIVE_SESSION_RESULT_KIND]: defineMessageSignature(
|
|
21433
21475
|
NATIVE_SESSION_RESULT_KIND,
|
|
21434
21476
|
encodeNativeSessionResult,
|
|
@@ -27291,6 +27333,7 @@ var turnSchema = external_exports.object({
|
|
|
27291
27333
|
id: boundedText(256),
|
|
27292
27334
|
status: turnStatusSchema
|
|
27293
27335
|
});
|
|
27336
|
+
var turnSteerResponseSchema = external_exports.object({ turnId: boundedText(256) });
|
|
27294
27337
|
var turnNotificationSchema = external_exports.object({
|
|
27295
27338
|
thread: external_exports.object({ id: boundedText(256) }).nullish(),
|
|
27296
27339
|
threadId: boundedText(256),
|
|
@@ -27675,7 +27718,10 @@ function presentToolItem(item) {
|
|
|
27675
27718
|
kind: "execute",
|
|
27676
27719
|
locations: [],
|
|
27677
27720
|
rawInput: { command: item.command, cwd: item.cwd },
|
|
27678
|
-
rawOutput: {
|
|
27721
|
+
rawOutput: {
|
|
27722
|
+
...item.exitCode == null ? {} : { exitCode: item.exitCode },
|
|
27723
|
+
output: truncate4(output2, TOOL_OUTPUT_CHARACTER_LIMIT)
|
|
27724
|
+
},
|
|
27679
27725
|
status: commandStatus(item.status),
|
|
27680
27726
|
title: truncate4(firstLine(item.command), TITLE_CHARACTER_LIMIT)
|
|
27681
27727
|
};
|
|
@@ -27731,7 +27777,7 @@ function presentToolItem(item) {
|
|
|
27731
27777
|
}
|
|
27732
27778
|
return null;
|
|
27733
27779
|
}
|
|
27734
|
-
function toolCallUpdate(item) {
|
|
27780
|
+
function toolCallUpdate(item, lifecycle) {
|
|
27735
27781
|
const presentation = presentToolItem(item);
|
|
27736
27782
|
if (presentation === null) {
|
|
27737
27783
|
return null;
|
|
@@ -27742,7 +27788,7 @@ function toolCallUpdate(item) {
|
|
|
27742
27788
|
locations: [...presentation.locations],
|
|
27743
27789
|
rawInput: presentation.rawInput,
|
|
27744
27790
|
rawOutput: presentation.rawOutput,
|
|
27745
|
-
status: presentation.status,
|
|
27791
|
+
status: lifecycle === "completed" && presentation.status === "in_progress" ? "completed" : presentation.status,
|
|
27746
27792
|
title: presentation.title,
|
|
27747
27793
|
toolCallId: item.id
|
|
27748
27794
|
};
|
|
@@ -27851,6 +27897,54 @@ function promptInput(prompt) {
|
|
|
27851
27897
|
}
|
|
27852
27898
|
return input2;
|
|
27853
27899
|
}
|
|
27900
|
+
function steeringPromptInput(prompt) {
|
|
27901
|
+
const input2 = [];
|
|
27902
|
+
for (const block of prompt) {
|
|
27903
|
+
if (typeof block !== "object" || block === null) {
|
|
27904
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
27905
|
+
}
|
|
27906
|
+
const type = Reflect.get(block, "type");
|
|
27907
|
+
if (type === "text") {
|
|
27908
|
+
const text = Reflect.get(block, "text");
|
|
27909
|
+
if (typeof text !== "string") {
|
|
27910
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
27911
|
+
}
|
|
27912
|
+
input2.push({ text, text_elements: [], type: "text" });
|
|
27913
|
+
continue;
|
|
27914
|
+
}
|
|
27915
|
+
if (type === "image") {
|
|
27916
|
+
const data = Reflect.get(block, "data");
|
|
27917
|
+
const mimeType = Reflect.get(block, "mimeType");
|
|
27918
|
+
if (typeof data !== "string" || typeof mimeType !== "string") {
|
|
27919
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
27920
|
+
}
|
|
27921
|
+
input2.push({ type: "image", url: `data:${mimeType};base64,${data}` });
|
|
27922
|
+
continue;
|
|
27923
|
+
}
|
|
27924
|
+
if (type === "resource") {
|
|
27925
|
+
const resource = Reflect.get(block, "resource");
|
|
27926
|
+
if (typeof resource !== "object" || resource === null) {
|
|
27927
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
27928
|
+
}
|
|
27929
|
+
const text = Reflect.get(resource, "text");
|
|
27930
|
+
if (text !== void 0 && typeof text !== "string") {
|
|
27931
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
27932
|
+
}
|
|
27933
|
+
input2.push({ text: text ?? "", text_elements: [], type: "text" });
|
|
27934
|
+
continue;
|
|
27935
|
+
}
|
|
27936
|
+
if (type === "resource_link") {
|
|
27937
|
+
const uri = Reflect.get(block, "uri");
|
|
27938
|
+
if (typeof uri !== "string") {
|
|
27939
|
+
throw new AcpExecutionError("Codex received an invalid steering prompt", {}, "invalid_request");
|
|
27940
|
+
}
|
|
27941
|
+
input2.push({ text: `Resource: ${uri}`, text_elements: [], type: "text" });
|
|
27942
|
+
continue;
|
|
27943
|
+
}
|
|
27944
|
+
throw new AcpExecutionError("Codex received an unsupported steering prompt", {}, "invalid_request");
|
|
27945
|
+
}
|
|
27946
|
+
return input2;
|
|
27947
|
+
}
|
|
27854
27948
|
function modelValues(models) {
|
|
27855
27949
|
return models.map((model) => ({
|
|
27856
27950
|
description: model.description ?? "",
|
|
@@ -28029,6 +28123,7 @@ var CodexAcpAgent = class {
|
|
|
28029
28123
|
this.#app = createAgentApp({ name: "mobius-codex" }).onConnect((connection) => {
|
|
28030
28124
|
this.#connection = connection;
|
|
28031
28125
|
}).onRequest(methods4.agent.initialize, async () => ({
|
|
28126
|
+
_meta: { steering: { supported: true } },
|
|
28032
28127
|
agentCapabilities: {
|
|
28033
28128
|
loadSession: true,
|
|
28034
28129
|
promptCapabilities: { embeddedContext: true, image: true },
|
|
@@ -28102,7 +28197,11 @@ var CodexAcpAgent = class {
|
|
|
28102
28197
|
return { configOptions: this.#configOptions() };
|
|
28103
28198
|
}).onRequest(methods4.agent.session.prompt, async (context) => {
|
|
28104
28199
|
return await this.#runTurn(promptInput(context.params.prompt), context.signal);
|
|
28105
|
-
}).onRequest(
|
|
28200
|
+
}).onRequest(
|
|
28201
|
+
"_session/steering",
|
|
28202
|
+
(params) => params,
|
|
28203
|
+
async (context) => await this.#steerTurn(context.params, context.signal)
|
|
28204
|
+
).onRequest(methods4.agent.session.list, async (context) => {
|
|
28106
28205
|
const decoded = threadListResponseSchema.parse(
|
|
28107
28206
|
await this.#appServer.request(
|
|
28108
28207
|
"thread/list",
|
|
@@ -28269,7 +28368,7 @@ var CodexAcpAgent = class {
|
|
|
28269
28368
|
});
|
|
28270
28369
|
continue;
|
|
28271
28370
|
}
|
|
28272
|
-
const update = toolCallUpdate(item);
|
|
28371
|
+
const update = toolCallUpdate(item, "snapshot");
|
|
28273
28372
|
if (update !== null) {
|
|
28274
28373
|
await this.#emit({ ...update, sessionUpdate: "tool_call_update" });
|
|
28275
28374
|
}
|
|
@@ -28466,7 +28565,7 @@ var CodexAcpAgent = class {
|
|
|
28466
28565
|
});
|
|
28467
28566
|
return;
|
|
28468
28567
|
}
|
|
28469
|
-
const update = toolCallUpdate(item);
|
|
28568
|
+
const update = toolCallUpdate(item, method === "item/completed" ? "completed" : "started");
|
|
28470
28569
|
if (update !== null) {
|
|
28471
28570
|
await this.#enqueue(async () => {
|
|
28472
28571
|
await this.#emit({ ...update, sessionUpdate: "tool_call_update" });
|
|
@@ -28652,6 +28751,35 @@ var CodexAcpAgent = class {
|
|
|
28652
28751
|
}
|
|
28653
28752
|
}
|
|
28654
28753
|
};
|
|
28754
|
+
#steerTurn = async (params, signal) => {
|
|
28755
|
+
if (typeof params !== "object" || params === null) {
|
|
28756
|
+
throw new AcpExecutionError("Codex received an invalid steering request", {}, "invalid_request");
|
|
28757
|
+
}
|
|
28758
|
+
const sessionId = Reflect.get(params, "sessionId");
|
|
28759
|
+
const prompt = Reflect.get(params, "prompt");
|
|
28760
|
+
if (typeof sessionId !== "string" || !Array.isArray(prompt)) {
|
|
28761
|
+
throw new AcpExecutionError("Codex received an invalid steering request", {}, "invalid_request");
|
|
28762
|
+
}
|
|
28763
|
+
const active = this.#turn;
|
|
28764
|
+
if (sessionId !== this.#nativeSessionId || active === null || active.turn.id.length === 0) {
|
|
28765
|
+
return { outcome: "promptRequired", reason: "noRunningTurn" };
|
|
28766
|
+
}
|
|
28767
|
+
const input2 = steeringPromptInput(prompt);
|
|
28768
|
+
if (input2.length === 0) {
|
|
28769
|
+
throw new AcpExecutionError("Codex received an empty steering request", {}, "invalid_request");
|
|
28770
|
+
}
|
|
28771
|
+
const response = turnSteerResponseSchema.parse(
|
|
28772
|
+
await this.#appServer.request(
|
|
28773
|
+
"turn/steer",
|
|
28774
|
+
{ expectedTurnId: active.turn.id, input: input2, threadId: this.#nativeSessionId },
|
|
28775
|
+
AbortSignal.any([signal, AbortSignal.timeout(APPROVAL_TIMEOUT_MILLISECONDS)])
|
|
28776
|
+
)
|
|
28777
|
+
);
|
|
28778
|
+
if (response.turnId !== active.turn.id) {
|
|
28779
|
+
throw new AcpExecutionError("Codex steered an unexpected turn", {}, "steering_target_unavailable");
|
|
28780
|
+
}
|
|
28781
|
+
return { outcome: "injected" };
|
|
28782
|
+
};
|
|
28655
28783
|
#interruptTurn = async () => {
|
|
28656
28784
|
const turn = this.#turn;
|
|
28657
28785
|
if (turn === null) {
|
|
@@ -32561,7 +32689,7 @@ async function executeSessionConfigure(publisher, socket, command, config2, dire
|
|
|
32561
32689
|
reportOperationFailure(socket, command.requestId, command.sessionId, error62);
|
|
32562
32690
|
}
|
|
32563
32691
|
}
|
|
32564
|
-
async function executePrompt(operations, publisher, command, config2, directories, audit, sessions, attemptId, activateAttempt, waitForSessionAvailability, timer, signal, recordLiveText, cancellationRequested) {
|
|
32692
|
+
async function executePrompt(operations, publisher, command, config2, directories, audit, sessions, attemptId, activateAttempt, acknowledgeQueued, waitForSessionAvailability, timer, signal, recordLiveText, cancellationRequested) {
|
|
32565
32693
|
const activities = new CoalescingDaemonActivityPublisher(timer, (activity2) => {
|
|
32566
32694
|
publisher.publish(command.sessionId, daemonActivity(command, activity2));
|
|
32567
32695
|
});
|
|
@@ -32599,6 +32727,9 @@ async function executePrompt(operations, publisher, command, config2, directorie
|
|
|
32599
32727
|
AGENT_TEXT_MAXIMUM_LENGTH
|
|
32600
32728
|
);
|
|
32601
32729
|
try {
|
|
32730
|
+
if (command.disposition === SessionPromptDisposition.Queue) {
|
|
32731
|
+
acknowledgeQueued();
|
|
32732
|
+
}
|
|
32602
32733
|
const resolved = await resolveSessionDirectories(
|
|
32603
32734
|
directories,
|
|
32604
32735
|
command.bindingId,
|
|
@@ -32608,10 +32739,10 @@ async function executePrompt(operations, publisher, command, config2, directorie
|
|
|
32608
32739
|
);
|
|
32609
32740
|
const agent = config2.catalog.find(command.agentId);
|
|
32610
32741
|
const availability = await waitForSessionAvailability(signal);
|
|
32611
|
-
if (availability === "busy") {
|
|
32742
|
+
if (availability.kind === "busy") {
|
|
32612
32743
|
throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
|
|
32613
32744
|
}
|
|
32614
|
-
if (availability === "queue-target-unavailable") {
|
|
32745
|
+
if (availability.kind === "queue-target-unavailable") {
|
|
32615
32746
|
throw new AcpExecutionError(
|
|
32616
32747
|
"The queued prompt target is unavailable",
|
|
32617
32748
|
{},
|
|
@@ -32629,7 +32760,7 @@ async function executePrompt(operations, publisher, command, config2, directorie
|
|
|
32629
32760
|
sessionId: command.sessionId,
|
|
32630
32761
|
signal
|
|
32631
32762
|
});
|
|
32632
|
-
if (
|
|
32763
|
+
if (availability.disposition === SessionPromptDisposition.Steer) {
|
|
32633
32764
|
assertAppliedSessionConfiguration(prepared.configOptions, sessionConfigurations ?? []);
|
|
32634
32765
|
} else {
|
|
32635
32766
|
await applyCompleteSessionConfiguration(
|
|
@@ -32664,7 +32795,7 @@ async function executePrompt(operations, publisher, command, config2, directorie
|
|
|
32664
32795
|
});
|
|
32665
32796
|
const attachments = await resolvePromptArtifacts(config2, command, signal);
|
|
32666
32797
|
let stopReason;
|
|
32667
|
-
if (
|
|
32798
|
+
if (availability.disposition === SessionPromptDisposition.Steer) {
|
|
32668
32799
|
await sessions.steerPrompt({
|
|
32669
32800
|
additionalDirectories: resolved.additionalDirectories,
|
|
32670
32801
|
agent: executionAgent,
|
|
@@ -32684,7 +32815,7 @@ async function executePrompt(operations, publisher, command, config2, directorie
|
|
|
32684
32815
|
agent: executionAgent,
|
|
32685
32816
|
commandId: command.commandId,
|
|
32686
32817
|
cwd: resolved.cwd,
|
|
32687
|
-
disposition:
|
|
32818
|
+
disposition: availability.disposition,
|
|
32688
32819
|
images: attachments.images,
|
|
32689
32820
|
onActivity: activities.record,
|
|
32690
32821
|
onNarration: (increment) => {
|
|
@@ -34251,7 +34382,7 @@ var ActiveDaemonTurn = class {
|
|
|
34251
34382
|
#controller;
|
|
34252
34383
|
#finished = Promise.withResolvers();
|
|
34253
34384
|
#cancellationRequested = false;
|
|
34254
|
-
#
|
|
34385
|
+
#dispatch;
|
|
34255
34386
|
#text = "";
|
|
34256
34387
|
#truncated = false;
|
|
34257
34388
|
#sequence = 0;
|
|
@@ -34261,15 +34392,32 @@ var ActiveDaemonTurn = class {
|
|
|
34261
34392
|
this.attemptId = attemptId;
|
|
34262
34393
|
this.command = command;
|
|
34263
34394
|
this.#controller = new AbortController();
|
|
34395
|
+
this.#dispatch = command.disposition === SessionPromptDisposition.Queue ? { kind: "queued", promotion: Promise.withResolvers() } : { kind: "pending" };
|
|
34264
34396
|
}
|
|
34265
34397
|
abortDaemon = () => {
|
|
34266
34398
|
this.#controller.abort();
|
|
34267
34399
|
};
|
|
34268
34400
|
finish = () => this.#finished.resolve();
|
|
34269
34401
|
accept = () => {
|
|
34270
|
-
this.#
|
|
34402
|
+
this.#dispatch = { kind: "accepted" };
|
|
34271
34403
|
return { epoch: this.#epoch, sequence: 0 };
|
|
34272
34404
|
};
|
|
34405
|
+
promoteQueuedPrompt = (command) => {
|
|
34406
|
+
if (command.commandId !== this.command.commandId || command.sessionId !== this.command.sessionId || this.#dispatch.kind !== "queued") {
|
|
34407
|
+
return false;
|
|
34408
|
+
}
|
|
34409
|
+
const promotion = this.#dispatch.promotion;
|
|
34410
|
+
this.#dispatch = { kind: "promoted" };
|
|
34411
|
+
promotion.resolve();
|
|
34412
|
+
return true;
|
|
34413
|
+
};
|
|
34414
|
+
queuePromotion = () => {
|
|
34415
|
+
if (this.#dispatch.kind === "queued") {
|
|
34416
|
+
return this.#dispatch.promotion.promise;
|
|
34417
|
+
}
|
|
34418
|
+
return this.#dispatch.kind === "promoted" ? Promise.resolve() : null;
|
|
34419
|
+
};
|
|
34420
|
+
effectiveDisposition = () => this.#dispatch.kind === "promoted" ? SessionPromptDisposition.Steer : this.command.disposition;
|
|
34273
34421
|
recordText = (delta) => {
|
|
34274
34422
|
this.#sequence += 1;
|
|
34275
34423
|
this.#text += delta;
|
|
@@ -34291,7 +34439,7 @@ var ActiveDaemonTurn = class {
|
|
|
34291
34439
|
this.#interaction = null;
|
|
34292
34440
|
}
|
|
34293
34441
|
};
|
|
34294
|
-
snapshot = () => this.#accepted ? {
|
|
34442
|
+
snapshot = () => this.#dispatch.kind === "accepted" ? {
|
|
34295
34443
|
commandId: decodeIdentifier(this.command.commandId),
|
|
34296
34444
|
prompt: this.command.prompt,
|
|
34297
34445
|
text: this.#text,
|
|
@@ -34307,7 +34455,7 @@ var ActiveDaemonTurn = class {
|
|
|
34307
34455
|
return "already-requested";
|
|
34308
34456
|
}
|
|
34309
34457
|
this.#cancellationRequested = true;
|
|
34310
|
-
if (
|
|
34458
|
+
if (this.#dispatch.kind !== "accepted") {
|
|
34311
34459
|
this.#controller.abort(new Error("The queued Agent turn was cancelled"));
|
|
34312
34460
|
return "pending";
|
|
34313
34461
|
}
|
|
@@ -36091,24 +36239,34 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
36091
36239
|
);
|
|
36092
36240
|
});
|
|
36093
36241
|
};
|
|
36094
|
-
const waitForSessionAvailability = async (command, waitSignal) => {
|
|
36095
|
-
if (
|
|
36096
|
-
return "available";
|
|
36242
|
+
const waitForSessionAvailability = async (command, queuedTurn, waitSignal) => {
|
|
36243
|
+
if (queuedTurn.effectiveDisposition() === SessionPromptDisposition.Steer) {
|
|
36244
|
+
return { disposition: SessionPromptDisposition.Steer, kind: "available" };
|
|
36097
36245
|
}
|
|
36098
36246
|
for (; ; ) {
|
|
36099
36247
|
const first = [...activeTurns.values()].find(
|
|
36100
36248
|
(turn) => turn.command.sessionId === command.sessionId && turn.command.disposition !== SessionPromptDisposition.Steer
|
|
36101
36249
|
);
|
|
36102
36250
|
if (first === void 0 || first.command.commandId === command.commandId) {
|
|
36103
|
-
return command.disposition !== SessionPromptDisposition.Queue || operations.isTerminalExecution(command.targetCommandId, command.sessionId) ? "available" : "queue-target-unavailable";
|
|
36251
|
+
return command.disposition !== SessionPromptDisposition.Queue || operations.isTerminalExecution(command.targetCommandId, command.sessionId) ? { disposition: queuedTurn.effectiveDisposition(), kind: "available" } : { kind: "queue-target-unavailable" };
|
|
36104
36252
|
}
|
|
36105
36253
|
if (command.disposition !== SessionPromptDisposition.Queue) {
|
|
36106
|
-
return "busy";
|
|
36254
|
+
return { kind: "busy" };
|
|
36107
36255
|
}
|
|
36108
36256
|
if (first.command.commandId !== command.targetCommandId) {
|
|
36109
|
-
return "queue-target-unavailable";
|
|
36257
|
+
return { kind: "queue-target-unavailable" };
|
|
36258
|
+
}
|
|
36259
|
+
const promotion = queuedTurn.queuePromotion();
|
|
36260
|
+
if (promotion === null) {
|
|
36261
|
+
throw new Error("The queued prompt cannot be promoted");
|
|
36262
|
+
}
|
|
36263
|
+
const decision = await Promise.race([
|
|
36264
|
+
waitForTurnCompletion(first, waitSignal).then(() => "target-completed"),
|
|
36265
|
+
promotion.then(() => "promoted")
|
|
36266
|
+
]);
|
|
36267
|
+
if (decision === "promoted") {
|
|
36268
|
+
return { disposition: SessionPromptDisposition.Steer, kind: "available" };
|
|
36110
36269
|
}
|
|
36111
|
-
await waitForTurnCompletion(first, waitSignal);
|
|
36112
36270
|
}
|
|
36113
36271
|
};
|
|
36114
36272
|
const connectionLiveness = new RelayConnectionLiveness(timer, {
|
|
@@ -36261,6 +36419,19 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
36261
36419
|
});
|
|
36262
36420
|
return;
|
|
36263
36421
|
}
|
|
36422
|
+
if (kind === SESSION_PROMPT_DISPOSITION_KIND) {
|
|
36423
|
+
const disposition = message;
|
|
36424
|
+
const turn2 = activeTurns.get(disposition.commandId);
|
|
36425
|
+
if (turn2 === void 0 || !turn2.promoteQueuedPrompt(disposition)) {
|
|
36426
|
+
reportOperationFailure(
|
|
36427
|
+
socket,
|
|
36428
|
+
disposition.commandId,
|
|
36429
|
+
disposition.sessionId,
|
|
36430
|
+
new Error("The queued prompt is unavailable")
|
|
36431
|
+
);
|
|
36432
|
+
}
|
|
36433
|
+
return;
|
|
36434
|
+
}
|
|
36264
36435
|
if (kind === WORKSPACE_LIST_KIND) {
|
|
36265
36436
|
const command2 = message;
|
|
36266
36437
|
void executeWorkspaceList(socket, command2, directories, audit, connectionController.signal);
|
|
@@ -36370,7 +36541,12 @@ async function runRelayConnection(config2, directories, audit, sessions, install
|
|
|
36370
36541
|
sessions,
|
|
36371
36542
|
receipt.attemptId,
|
|
36372
36543
|
turn.accept,
|
|
36373
|
-
(
|
|
36544
|
+
() => send(socket, {
|
|
36545
|
+
commandId: command.commandId,
|
|
36546
|
+
kind: SESSION_QUEUED_KIND,
|
|
36547
|
+
sessionId: command.sessionId
|
|
36548
|
+
}),
|
|
36549
|
+
(waitSignal) => waitForSessionAvailability(command, turn, waitSignal),
|
|
36374
36550
|
timer,
|
|
36375
36551
|
turn.signal,
|
|
36376
36552
|
turn.recordText,
|