@moxt-ai/mobius 0.0.366 → 0.0.369
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/NOTICE +27 -0
- package/THIRD-PARTY-NOTICES.txt +586 -0
- package/dist/{chunk-6B5KEII2.js → chunk-2RHEJMMU.js} +6 -4
- package/dist/chunk-2RHEJMMU.js.map +7 -0
- package/dist/{chunk-T6KRS6AF.js → chunk-3GFBCVGZ.js} +147 -75
- package/dist/{chunk-T6KRS6AF.js.map → chunk-3GFBCVGZ.js.map} +3 -3
- package/dist/{chunk-YLRX5R7J.js → chunk-PG7W3R2P.js} +2 -2
- package/dist/{cli-UAVS5HNF.js → cli-5UCO7ZEY.js} +4 -4
- package/dist/cli.js +3 -3
- package/dist/engine/runtime/command/registry/interactions.d.ts.map +1 -1
- package/dist/engine/runtime/command/registry/interactions.js +14 -7
- package/dist/engine/runtime/command/registry/interactions.js.map +1 -1
- package/dist/engine/session/api/session-layer.d.ts.map +1 -1
- package/dist/engine/session/api/session-layer.js +1 -1
- package/dist/engine/session/api/session-layer.js.map +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.d.ts +2 -1
- package/dist/engine/session/prompt/prompt-lifecycle.d.ts.map +1 -1
- package/dist/engine/session/prompt/prompt-lifecycle.js +6 -5
- package/dist/engine/session/prompt/prompt-lifecycle.js.map +1 -1
- package/dist/engine/session/turn/active-turn.d.ts +2 -1
- package/dist/engine/session/turn/active-turn.d.ts.map +1 -1
- package/dist/engine/session/turn/active-turn.js +28 -7
- package/dist/engine/session/turn/active-turn.js.map +1 -1
- package/dist/engine/session/turn/execution-receipts.d.ts.map +1 -1
- package/dist/engine/session/turn/execution-receipts.js +96 -42
- package/dist/engine/session/turn/execution-receipts.js.map +1 -1
- package/dist/engine/session/turn/session-execution.js +3 -3
- package/dist/engine/session/turn/session-execution.js.map +1 -1
- package/dist/engine.js +2 -2
- package/package.json +6 -4
- package/dist/chunk-6B5KEII2.js.map +0 -7
- /package/dist/{chunk-YLRX5R7J.js.map → chunk-PG7W3R2P.js.map} +0 -0
- /package/dist/{cli-UAVS5HNF.js.map → cli-5UCO7ZEY.js.map} +0 -0
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
__export,
|
|
4
4
|
__using,
|
|
5
5
|
package_default
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2RHEJMMU.js";
|
|
7
7
|
|
|
8
8
|
// src/engine/runtime/relay/runtime-revocation.ts
|
|
9
9
|
var runtimeRevocationCloseCode = 1008;
|
|
@@ -88347,10 +88347,12 @@ var PromptLifecycle = class {
|
|
|
88347
88347
|
#publications = /* @__PURE__ */ new Map();
|
|
88348
88348
|
#queued = /* @__PURE__ */ new Map();
|
|
88349
88349
|
#recordActiveTurn;
|
|
88350
|
+
#hasStarted;
|
|
88350
88351
|
#recordLifecycle;
|
|
88351
|
-
constructor(sink, recordLifecycle, recordActiveTurn) {
|
|
88352
|
+
constructor(sink, recordLifecycle, recordActiveTurn, hasStarted) {
|
|
88352
88353
|
this.#recordLifecycle = recordLifecycle;
|
|
88353
88354
|
this.#recordActiveTurn = recordActiveTurn;
|
|
88355
|
+
this.#hasStarted = hasStarted;
|
|
88354
88356
|
this.#sink = sink;
|
|
88355
88357
|
}
|
|
88356
88358
|
requested = (command) => {
|
|
@@ -88363,15 +88365,14 @@ var PromptLifecycle = class {
|
|
|
88363
88365
|
directoryId: command.directoryId,
|
|
88364
88366
|
additionalDirectoryIds: command.additionalDirectoryIds
|
|
88365
88367
|
},
|
|
88366
|
-
phase: "queued",
|
|
88367
88368
|
sessionId: command.sessionId,
|
|
88368
88369
|
...command.targetCommandId.length === 0 ? {} : { targetCommandId: command.targetCommandId }
|
|
88369
88370
|
});
|
|
88370
88371
|
};
|
|
88372
|
+
/** Metadata for an execution already claimed by the receipt owner. */
|
|
88371
88373
|
started = (sessionId, commandId, attemptId, epoch, disposition) => {
|
|
88372
88374
|
const request = this.#queued.get(commandId);
|
|
88373
88375
|
if (request?.sessionId === sessionId) {
|
|
88374
|
-
this.#queued.set(commandId, { ...request, phase: "running" });
|
|
88375
88376
|
return {
|
|
88376
88377
|
attemptId,
|
|
88377
88378
|
content: request.content,
|
|
@@ -88446,7 +88447,7 @@ var PromptLifecycle = class {
|
|
|
88446
88447
|
kind: "prompt.completed",
|
|
88447
88448
|
commandId,
|
|
88448
88449
|
stopReason,
|
|
88449
|
-
...
|
|
88450
|
+
...this.#hasStarted(commandId, sessionId) ? {} : { execution: "not-started" }
|
|
88450
88451
|
}
|
|
88451
88452
|
});
|
|
88452
88453
|
if (!recorded) {
|
|
@@ -88472,7 +88473,7 @@ var PromptLifecycle = class {
|
|
|
88472
88473
|
}
|
|
88473
88474
|
};
|
|
88474
88475
|
promptRequestRecovery = (sessionId) => ({
|
|
88475
|
-
queuedPromptRequests: [...this.#queued.values()].filter((request) => request.sessionId === sessionId && request.
|
|
88476
|
+
queuedPromptRequests: [...this.#queued.values()].filter((request) => request.sessionId === sessionId && !this.#hasStarted(request.commandId, sessionId)).map(({ commandId, content, disposition, targetCommandId }) => ({
|
|
88476
88477
|
commandId,
|
|
88477
88478
|
content,
|
|
88478
88479
|
...disposition === void 0 ? {} : { disposition },
|
|
@@ -88503,35 +88504,79 @@ async function settleAbandonedTurn(projection, operations, cancellation) {
|
|
|
88503
88504
|
// src/engine/session/turn/execution-receipts.ts
|
|
88504
88505
|
import { createHash as createHash7, randomUUID as randomUUID15 } from "node:crypto";
|
|
88505
88506
|
var MAX_TERMINAL_RECEIPTS = 1024;
|
|
88507
|
+
function executionStarted(state) {
|
|
88508
|
+
switch (state.kind) {
|
|
88509
|
+
case "pending":
|
|
88510
|
+
case "settled-before-start":
|
|
88511
|
+
return false;
|
|
88512
|
+
case "started":
|
|
88513
|
+
case "settled-after-start":
|
|
88514
|
+
return true;
|
|
88515
|
+
default: {
|
|
88516
|
+
const unreachable3 = state;
|
|
88517
|
+
throw new Error("Unexpected execution state", { cause: unreachable3 });
|
|
88518
|
+
}
|
|
88519
|
+
}
|
|
88520
|
+
}
|
|
88521
|
+
function executionOutcome(state) {
|
|
88522
|
+
switch (state.kind) {
|
|
88523
|
+
case "pending":
|
|
88524
|
+
case "started":
|
|
88525
|
+
return null;
|
|
88526
|
+
case "settled-before-start":
|
|
88527
|
+
case "settled-after-start":
|
|
88528
|
+
return state.outcome;
|
|
88529
|
+
default: {
|
|
88530
|
+
const unreachable3 = state;
|
|
88531
|
+
throw new Error("Unexpected execution state", { cause: unreachable3 });
|
|
88532
|
+
}
|
|
88533
|
+
}
|
|
88534
|
+
}
|
|
88535
|
+
function settledExecution(state, outcome) {
|
|
88536
|
+
return { kind: executionStarted(state) ? "settled-after-start" : "settled-before-start", outcome };
|
|
88537
|
+
}
|
|
88506
88538
|
var ExecutionReceipts = class {
|
|
88507
88539
|
#executions = /* @__PURE__ */ new Map();
|
|
88508
88540
|
#recoveredCommands = /* @__PURE__ */ new Set();
|
|
88509
88541
|
#table;
|
|
88510
88542
|
#closing = false;
|
|
88511
|
-
#activeCount = 0;
|
|
88512
88543
|
#onCount;
|
|
88513
88544
|
constructor(table, onCount = () => void 0) {
|
|
88514
88545
|
this.#onCount = onCount;
|
|
88515
88546
|
this.#table = table;
|
|
88516
|
-
for (const
|
|
88517
|
-
|
|
88518
|
-
this.#
|
|
88519
|
-
|
|
88520
|
-
|
|
88521
|
-
}
|
|
88547
|
+
for (const { commandId, started, outcome, updatedAt: _updatedAt, ...identity2 } of table.list()) {
|
|
88548
|
+
const state = { kind: started ? "started" : "pending" };
|
|
88549
|
+
this.#executions.set(commandId, {
|
|
88550
|
+
...identity2,
|
|
88551
|
+
state: outcome === null ? state : settledExecution(state, outcome)
|
|
88552
|
+
});
|
|
88553
|
+
this.#recoveredCommands.add(commandId);
|
|
88522
88554
|
}
|
|
88523
88555
|
}
|
|
88524
|
-
#save = (commandId, receipt,
|
|
88525
|
-
const
|
|
88526
|
-
const
|
|
88527
|
-
|
|
88528
|
-
|
|
88556
|
+
#save = (commandId, receipt, durableOutcome = executionOutcome(receipt.state)) => {
|
|
88557
|
+
const { state, ...identity2 } = receipt;
|
|
88558
|
+
const evicted = this.#closing ? [] : this.#table.save(
|
|
88559
|
+
{
|
|
88560
|
+
...identity2,
|
|
88561
|
+
commandId,
|
|
88562
|
+
started: executionStarted(state),
|
|
88563
|
+
outcome: durableOutcome,
|
|
88564
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
88565
|
+
},
|
|
88566
|
+
MAX_TERMINAL_RECEIPTS
|
|
88567
|
+
);
|
|
88568
|
+
this.#executions.set(commandId, receipt);
|
|
88529
88569
|
for (const evictedCommandId of evicted) {
|
|
88530
88570
|
this.#executions.delete(evictedCommandId);
|
|
88531
88571
|
this.#recoveredCommands.delete(evictedCommandId);
|
|
88532
88572
|
}
|
|
88533
|
-
|
|
88534
|
-
this.#
|
|
88573
|
+
let activeCount = 0;
|
|
88574
|
+
for (const entry of this.#executions.values()) {
|
|
88575
|
+
if (executionOutcome(entry.state) === null) {
|
|
88576
|
+
activeCount += 1;
|
|
88577
|
+
}
|
|
88578
|
+
}
|
|
88579
|
+
this.#onCount(activeCount);
|
|
88535
88580
|
};
|
|
88536
88581
|
#nextAdmissionOrder = () => {
|
|
88537
88582
|
let latest = 0;
|
|
@@ -88545,7 +88590,8 @@ var ExecutionReceipts = class {
|
|
|
88545
88590
|
};
|
|
88546
88591
|
outcome = (commandId) => {
|
|
88547
88592
|
const receipt = this.#executions.get(commandId);
|
|
88548
|
-
|
|
88593
|
+
const outcome = receipt === void 0 ? null : executionOutcome(receipt.state);
|
|
88594
|
+
return outcome === null ? void 0 : decodeKnownSessionEventPayload(JSON.parse(outcome)) ?? void 0;
|
|
88549
88595
|
};
|
|
88550
88596
|
/** The command's delivery as these receipts know it; another Session's command reads as unknown. */
|
|
88551
88597
|
delivery = (commandId, sessionId) => {
|
|
@@ -88556,7 +88602,7 @@ var ExecutionReceipts = class {
|
|
|
88556
88602
|
if (receipt.sessionId !== sessionId) {
|
|
88557
88603
|
return { state: "unknown" };
|
|
88558
88604
|
}
|
|
88559
|
-
if (receipt.
|
|
88605
|
+
if (executionOutcome(receipt.state) === null) {
|
|
88560
88606
|
return { state: "accepted" };
|
|
88561
88607
|
}
|
|
88562
88608
|
const outcome = this.outcome(commandId);
|
|
@@ -88585,9 +88631,9 @@ var ExecutionReceipts = class {
|
|
|
88585
88631
|
if (receipt.sessionId !== sessionId) {
|
|
88586
88632
|
continue;
|
|
88587
88633
|
}
|
|
88588
|
-
const outcome2 =
|
|
88634
|
+
const outcome2 = this.outcome(commandId);
|
|
88589
88635
|
const failedBeforeStart = outcome2?.type === "lifecycle-metadata" && outcome2.payload.kind === "prompt.failed-before-start";
|
|
88590
|
-
if ((receipt.
|
|
88636
|
+
if ((executionStarted(receipt.state) || failedBeforeStart) && receipt.admissionOrder > latestOrder) {
|
|
88591
88637
|
last = commandId;
|
|
88592
88638
|
latestOrder = receipt.admissionOrder;
|
|
88593
88639
|
}
|
|
@@ -88614,7 +88660,7 @@ var ExecutionReceipts = class {
|
|
|
88614
88660
|
/** Started identities remain authoritative after their detailed receipt is evicted. */
|
|
88615
88661
|
hasStarted = (commandId, sessionId) => {
|
|
88616
88662
|
const receipt = this.#executions.get(commandId);
|
|
88617
|
-
return receipt?.sessionId === sessionId && receipt.
|
|
88663
|
+
return receipt?.sessionId === sessionId && executionStarted(receipt.state) || this.#table.identity(commandId)?.sessionId === sessionId;
|
|
88618
88664
|
};
|
|
88619
88665
|
/** Reserves an unseen command for cancellation before a delayed prompt can claim its identity. */
|
|
88620
88666
|
recordCancellationBeforeAdmission = (commandId, sessionId) => {
|
|
@@ -88645,8 +88691,10 @@ var ExecutionReceipts = class {
|
|
|
88645
88691
|
attemptId: randomUUID15(),
|
|
88646
88692
|
commandHash,
|
|
88647
88693
|
sessionId,
|
|
88648
|
-
|
|
88649
|
-
|
|
88694
|
+
state: {
|
|
88695
|
+
kind: "settled-before-start",
|
|
88696
|
+
outcome: JSON.stringify({ ...outcome, recordedAt: (/* @__PURE__ */ new Date()).toISOString() })
|
|
88697
|
+
}
|
|
88650
88698
|
});
|
|
88651
88699
|
return outcome;
|
|
88652
88700
|
};
|
|
@@ -88666,16 +88714,17 @@ var ExecutionReceipts = class {
|
|
|
88666
88714
|
const outcome = { type: "lifecycle-metadata", payload, recordedAt: event.recordedAt };
|
|
88667
88715
|
this.#save(
|
|
88668
88716
|
payload.commandId,
|
|
88669
|
-
{ ...receipt,
|
|
88670
|
-
JSON.stringify(outcome)
|
|
88717
|
+
{ ...receipt, state: settledExecution(receipt.state, JSON.stringify(outcome)) },
|
|
88718
|
+
JSON.stringify({ ...outcome, payload: sanitized })
|
|
88671
88719
|
);
|
|
88672
88720
|
};
|
|
88673
88721
|
recover = () => {
|
|
88674
88722
|
const recovered = [];
|
|
88675
88723
|
for (const [commandId, receipt] of [...this.#executions]) {
|
|
88676
|
-
const
|
|
88724
|
+
const outcome = executionOutcome(receipt.state);
|
|
88725
|
+
const event = outcome === null ? {
|
|
88677
88726
|
type: "lifecycle-metadata",
|
|
88678
|
-
payload: receipt.
|
|
88727
|
+
payload: executionStarted(receipt.state) ? {
|
|
88679
88728
|
kind: "prompt.failed",
|
|
88680
88729
|
commandId,
|
|
88681
88730
|
attemptId: receipt.attemptId,
|
|
@@ -88687,14 +88736,17 @@ var ExecutionReceipts = class {
|
|
|
88687
88736
|
code: "runtime_restarted",
|
|
88688
88737
|
message: "The local runtime restarted before this request started"
|
|
88689
88738
|
}
|
|
88690
|
-
} : decodeKnownSessionEventPayload(JSON.parse(
|
|
88739
|
+
} : decodeKnownSessionEventPayload(JSON.parse(outcome));
|
|
88691
88740
|
if (event === null) {
|
|
88692
88741
|
continue;
|
|
88693
88742
|
}
|
|
88694
|
-
const recordedAt =
|
|
88743
|
+
const recordedAt = outcome === null ? (/* @__PURE__ */ new Date()).toISOString() : external_exports.object({ recordedAt: external_exports.string() }).parse(JSON.parse(outcome)).recordedAt;
|
|
88695
88744
|
recovered.push({ sessionId: receipt.sessionId, event, recordedAt });
|
|
88696
|
-
if (
|
|
88697
|
-
this.#save(commandId, {
|
|
88745
|
+
if (outcome === null) {
|
|
88746
|
+
this.#save(commandId, {
|
|
88747
|
+
...receipt,
|
|
88748
|
+
state: settledExecution(receipt.state, JSON.stringify({ ...event, recordedAt }))
|
|
88749
|
+
});
|
|
88698
88750
|
}
|
|
88699
88751
|
}
|
|
88700
88752
|
return recovered;
|
|
@@ -88703,7 +88755,7 @@ var ExecutionReceipts = class {
|
|
|
88703
88755
|
const commandHash = createHash7("sha256").update(commandJson).digest("hex");
|
|
88704
88756
|
let existing = this.#executions.get(commandId);
|
|
88705
88757
|
const previous = this.outcome(commandId);
|
|
88706
|
-
if (existing?.sessionId === sessionId && !existing.
|
|
88758
|
+
if (existing?.sessionId === sessionId && !executionStarted(existing.state) && previous?.type === "lifecycle-metadata" && previous.payload.kind === "prompt.failed-before-start" && previous.payload.code === "runtime_restarted") {
|
|
88707
88759
|
this.#table.remove(commandId);
|
|
88708
88760
|
this.#executions.delete(commandId);
|
|
88709
88761
|
this.#recoveredCommands.delete(commandId);
|
|
@@ -88730,8 +88782,7 @@ var ExecutionReceipts = class {
|
|
|
88730
88782
|
attemptId,
|
|
88731
88783
|
commandHash,
|
|
88732
88784
|
sessionId,
|
|
88733
|
-
|
|
88734
|
-
outcome: null
|
|
88785
|
+
state: { kind: "pending" }
|
|
88735
88786
|
});
|
|
88736
88787
|
return { attemptId, commandId, kind: "accepted" };
|
|
88737
88788
|
};
|
|
@@ -88740,26 +88791,34 @@ var ExecutionReceipts = class {
|
|
|
88740
88791
|
if (current === void 0) {
|
|
88741
88792
|
throw new Error("The runtime execution receipt does not exist");
|
|
88742
88793
|
}
|
|
88743
|
-
|
|
88744
|
-
|
|
88745
|
-
|
|
88746
|
-
|
|
88747
|
-
|
|
88794
|
+
const state = current.state;
|
|
88795
|
+
switch (state.kind) {
|
|
88796
|
+
case "pending":
|
|
88797
|
+
this.#save(commandId, { ...current, state: { kind: "started" } });
|
|
88798
|
+
return;
|
|
88799
|
+
case "started":
|
|
88800
|
+
return;
|
|
88801
|
+
case "settled-before-start":
|
|
88802
|
+
case "settled-after-start":
|
|
88803
|
+
throw new Error("The runtime execution transition is invalid");
|
|
88804
|
+
default: {
|
|
88805
|
+
const unreachable3 = state;
|
|
88806
|
+
throw new Error("Unexpected execution state", { cause: unreachable3 });
|
|
88807
|
+
}
|
|
88748
88808
|
}
|
|
88749
88809
|
};
|
|
88750
88810
|
/** Only commands without a terminal result can still be cancelled. */
|
|
88751
88811
|
findUnsettledAttemptId = (commandId, sessionId) => {
|
|
88752
88812
|
const receipt = this.#executions.get(commandId);
|
|
88753
|
-
return receipt?.sessionId === sessionId && receipt.
|
|
88813
|
+
return receipt?.sessionId === sessionId && executionOutcome(receipt.state) === null ? receipt.attemptId : null;
|
|
88754
88814
|
};
|
|
88755
88815
|
isTerminalExecution = (commandId, sessionId) => {
|
|
88756
88816
|
const receipt = this.#executions.get(commandId);
|
|
88757
|
-
return receipt?.sessionId === sessionId && receipt.
|
|
88817
|
+
return receipt?.sessionId === sessionId && executionOutcome(receipt.state) !== null;
|
|
88758
88818
|
};
|
|
88759
88819
|
close = () => {
|
|
88760
88820
|
this.#executions.clear();
|
|
88761
88821
|
this.#recoveredCommands.clear();
|
|
88762
|
-
this.#activeCount = 0;
|
|
88763
88822
|
};
|
|
88764
88823
|
};
|
|
88765
88824
|
|
|
@@ -88874,7 +88933,7 @@ var ActiveRuntimeTurn = class {
|
|
|
88874
88933
|
}
|
|
88875
88934
|
this.#dispatch = { kind: "queued", promotion: Promise.withResolvers() };
|
|
88876
88935
|
};
|
|
88877
|
-
isQueued = () => this.#dispatch.kind === "queued" && !this.#controller.signal.aborted;
|
|
88936
|
+
isQueued = () => (this.#dispatch.kind === "queued" || this.#dispatch.kind === "admitted" && this.#dispatch.disposition === SessionPromptDisposition.Queue) && !this.#controller.signal.aborted;
|
|
88878
88937
|
abortRuntime = () => {
|
|
88879
88938
|
this.#controller.abort();
|
|
88880
88939
|
};
|
|
@@ -88886,13 +88945,30 @@ var ActiveRuntimeTurn = class {
|
|
|
88886
88945
|
return { epoch: this.#epoch, sequence: 0 };
|
|
88887
88946
|
};
|
|
88888
88947
|
promoteQueuedPrompt = (command) => {
|
|
88889
|
-
if (command.commandId !== this.command.commandId || command.sessionId !== this.command.sessionId || this.#
|
|
88890
|
-
return
|
|
88948
|
+
if (command.commandId !== this.command.commandId || command.sessionId !== this.command.sessionId || this.#controller.signal.aborted) {
|
|
88949
|
+
return "unavailable";
|
|
88950
|
+
}
|
|
88951
|
+
switch (this.#dispatch.kind) {
|
|
88952
|
+
case "queued": {
|
|
88953
|
+
const promotion = this.#dispatch.promotion;
|
|
88954
|
+
this.#dispatch = { kind: "promoted" };
|
|
88955
|
+
promotion.resolve();
|
|
88956
|
+
return "accepted";
|
|
88957
|
+
}
|
|
88958
|
+
case "promoted":
|
|
88959
|
+
return "accepted";
|
|
88960
|
+
case "admitted":
|
|
88961
|
+
return this.#dispatch.disposition === SessionPromptDisposition.Steer ? "accepted" : "already-started";
|
|
88962
|
+
case "running":
|
|
88963
|
+
return "already-started";
|
|
88964
|
+
case "pending":
|
|
88965
|
+
return "unavailable";
|
|
88891
88966
|
}
|
|
88892
|
-
|
|
88893
|
-
|
|
88894
|
-
|
|
88895
|
-
|
|
88967
|
+
};
|
|
88968
|
+
admit = () => {
|
|
88969
|
+
const disposition = this.effectiveDisposition();
|
|
88970
|
+
this.#dispatch = { kind: "admitted", disposition };
|
|
88971
|
+
return disposition;
|
|
88896
88972
|
};
|
|
88897
88973
|
queuePromotion = () => {
|
|
88898
88974
|
if (this.#dispatch.kind === "queued") {
|
|
@@ -89036,13 +89112,13 @@ var SessionExecutionState = class {
|
|
|
89036
89112
|
onQueued();
|
|
89037
89113
|
}
|
|
89038
89114
|
if (turn.effectiveDisposition() === SessionPromptDisposition.Steer) {
|
|
89039
|
-
return { disposition:
|
|
89115
|
+
return { disposition: turn.admit(), kind: "available" };
|
|
89040
89116
|
}
|
|
89041
89117
|
for (; ; ) {
|
|
89042
89118
|
waitSignal.throwIfAborted();
|
|
89043
89119
|
const first = head();
|
|
89044
89120
|
if (first === void 0 || first === turn) {
|
|
89045
|
-
return { disposition: turn.
|
|
89121
|
+
return { disposition: turn.admit(), kind: "available" };
|
|
89046
89122
|
}
|
|
89047
89123
|
if (command.disposition !== SessionPromptDisposition.Queue) {
|
|
89048
89124
|
return { kind: "busy" };
|
|
@@ -89056,7 +89132,7 @@ var SessionExecutionState = class {
|
|
|
89056
89132
|
promotion.then(() => "promoted")
|
|
89057
89133
|
]);
|
|
89058
89134
|
if (decision === "promoted") {
|
|
89059
|
-
return { disposition:
|
|
89135
|
+
return { disposition: turn.admit(), kind: "available" };
|
|
89060
89136
|
}
|
|
89061
89137
|
}
|
|
89062
89138
|
};
|
|
@@ -89374,7 +89450,8 @@ function buildSessionLayer(options) {
|
|
|
89374
89450
|
eventProjection.record(recorded);
|
|
89375
89451
|
return true;
|
|
89376
89452
|
},
|
|
89377
|
-
activeSessions.recordSessionEvent
|
|
89453
|
+
activeSessions.recordSessionEvent,
|
|
89454
|
+
operations.hasStarted
|
|
89378
89455
|
);
|
|
89379
89456
|
const nativeSessions = new NativeSessionService(
|
|
89380
89457
|
bindingId,
|
|
@@ -91253,15 +91330,6 @@ var sessionCancelBeforeStartCommand = {
|
|
|
91253
91330
|
);
|
|
91254
91331
|
return;
|
|
91255
91332
|
}
|
|
91256
|
-
if (turn.snapshot() !== null) {
|
|
91257
|
-
reportOperationFailure(
|
|
91258
|
-
socket,
|
|
91259
|
-
message.commandId,
|
|
91260
|
-
message.sessionId,
|
|
91261
|
-
new SessionError("turn_already_started", "The command already started")
|
|
91262
|
-
);
|
|
91263
|
-
return;
|
|
91264
|
-
}
|
|
91265
91333
|
turn.requestCancellation();
|
|
91266
91334
|
}
|
|
91267
91335
|
};
|
|
@@ -91280,19 +91348,23 @@ var sessionCloseCommand = {
|
|
|
91280
91348
|
};
|
|
91281
91349
|
var promptDispositionCommand = {
|
|
91282
91350
|
kind: SESSION_PROMPT_DISPOSITION_KIND,
|
|
91283
|
-
handle: ({ sessionTurns, socket }, message) => {
|
|
91351
|
+
handle: ({ diagnostics, operations, sessionTurns, socket }, message) => {
|
|
91284
91352
|
if (message.kind !== SESSION_PROMPT_DISPOSITION_KIND) {
|
|
91285
91353
|
throw new Error("Command kind mismatch");
|
|
91286
91354
|
}
|
|
91287
91355
|
const turn = sessionTurns.get(message.commandId, message.sessionId);
|
|
91288
|
-
|
|
91289
|
-
|
|
91290
|
-
|
|
91291
|
-
message.commandId,
|
|
91292
|
-
message.sessionId,
|
|
91293
|
-
new Error("The queued prompt is unavailable")
|
|
91294
|
-
);
|
|
91356
|
+
const result = turn?.promoteQueuedPrompt(message) ?? "unavailable";
|
|
91357
|
+
if (result === "accepted") {
|
|
91358
|
+
return;
|
|
91295
91359
|
}
|
|
91360
|
+
const started = result === "already-started" || operations.hasStarted(message.commandId, message.sessionId);
|
|
91361
|
+
const error62 = started ? new SessionError("turn_already_started", "The message already left the queue and could not be steered") : new SessionError("turn_not_active", "The message is no longer waiting to be steered");
|
|
91362
|
+
diagnostics.daemonDiagnostic("session_prompt_disposition_failed", message.commandId, {
|
|
91363
|
+
code: error62.code,
|
|
91364
|
+
commandId: message.commandId,
|
|
91365
|
+
sessionId: message.sessionId
|
|
91366
|
+
});
|
|
91367
|
+
reportOperationFailure(socket, message.commandId, message.sessionId, error62);
|
|
91296
91368
|
}
|
|
91297
91369
|
};
|
|
91298
91370
|
var permissionRespondCommand = {
|
|
@@ -93458,4 +93530,4 @@ export {
|
|
|
93458
93530
|
* MIT Licensed
|
|
93459
93531
|
*)
|
|
93460
93532
|
*/
|
|
93461
|
-
//# sourceMappingURL=chunk-
|
|
93533
|
+
//# sourceMappingURL=chunk-3GFBCVGZ.js.map
|