@moxt-ai/mobius 0.0.196 → 0.0.198
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/session-event-store-v2.d.ts.map +1 -1
- package/dist/acp/session-event-store-v2.js +108 -16
- package/dist/acp/session-event-store-v2.js.map +1 -1
- package/dist/cli.js +151 -55
- package/dist/cli.js.map +4 -4
- package/dist/daemon-command-handler.d.ts +3 -3
- package/dist/daemon-command-handler.d.ts.map +1 -1
- package/dist/daemon-command-handler.js +8 -8
- package/dist/daemon-command-handler.js.map +1 -1
- package/dist/daemon-command-results.d.ts +2 -2
- package/dist/daemon-command-results.d.ts.map +1 -1
- package/dist/daemon-command-results.js +3 -3
- package/dist/daemon-command-results.js.map +1 -1
- package/dist/daemon-history-commands.d.ts +3 -3
- package/dist/daemon-history-commands.d.ts.map +1 -1
- package/dist/daemon-history-commands.js +7 -7
- package/dist/daemon-history-commands.js.map +1 -1
- package/dist/daemon-prompt-executor.d.ts +3 -3
- package/dist/daemon-prompt-executor.d.ts.map +1 -1
- package/dist/daemon-prompt-executor.js +5 -5
- package/dist/daemon-prompt-executor.js.map +1 -1
- package/dist/index.js +151 -55
- package/dist/index.js.map +4 -4
- package/dist/relay-connection/run-relay-connection.d.ts +3 -3
- package/dist/relay-connection/run-relay-connection.d.ts.map +1 -1
- package/dist/relay-connection/run-relay-connection.js +2 -2
- package/dist/relay-connection/run-relay-connection.js.map +1 -1
- package/dist/run-daemon.js +4 -4
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +151 -55
- package/dist/runtime.js.map +4 -4
- package/dist/{session-event-log-v2.d.ts → session-event-projection-v2.d.ts} +3 -3
- package/dist/session-event-projection-v2.d.ts.map +1 -0
- package/dist/{session-event-log-v2.js → session-event-projection-v2.js} +4 -4
- package/dist/session-event-projection-v2.js.map +1 -0
- package/package.json +11 -7
- package/dist/session-event-log-v2.d.ts.map +0 -1
- package/dist/session-event-log-v2.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -30271,6 +30271,73 @@ var sessionEventV2 = sqliteTable(
|
|
|
30271
30271
|
// src/acp/session-event-store-v2.ts
|
|
30272
30272
|
var HOT_EVENT_HIGH_WATER_MARK = 256;
|
|
30273
30273
|
var HOT_EVENT_RETENTION = 128;
|
|
30274
|
+
var PositionedSessionEventV2 = class {
|
|
30275
|
+
#event;
|
|
30276
|
+
position;
|
|
30277
|
+
constructor(event, position) {
|
|
30278
|
+
this.#event = event;
|
|
30279
|
+
this.position = position;
|
|
30280
|
+
}
|
|
30281
|
+
get event() {
|
|
30282
|
+
return this.#event;
|
|
30283
|
+
}
|
|
30284
|
+
replaceEvent = (event) => {
|
|
30285
|
+
this.#event = event;
|
|
30286
|
+
};
|
|
30287
|
+
};
|
|
30288
|
+
var SessionEventsV2 = class {
|
|
30289
|
+
hot = [];
|
|
30290
|
+
#toolCallUpdateMap = /* @__PURE__ */ new Map();
|
|
30291
|
+
sessionGenerationId;
|
|
30292
|
+
nextPosition = 1;
|
|
30293
|
+
constructor() {
|
|
30294
|
+
this.sessionGenerationId = randomUUID();
|
|
30295
|
+
}
|
|
30296
|
+
getToolCallUpdate = (toolCallId) => this.#toolCallUpdateMap.get(toolCallId);
|
|
30297
|
+
updateToolCallUpdate = (toolCallId, item) => {
|
|
30298
|
+
const current = this.#toolCallUpdateMap.get(toolCallId);
|
|
30299
|
+
if (current === void 0 || current.position !== item.position) {
|
|
30300
|
+
return false;
|
|
30301
|
+
}
|
|
30302
|
+
current.replaceEvent(item.event);
|
|
30303
|
+
return true;
|
|
30304
|
+
};
|
|
30305
|
+
append = (item) => {
|
|
30306
|
+
this.hot.push(item);
|
|
30307
|
+
const event = item.event;
|
|
30308
|
+
if (event.type === "acp" && (event.payload.sessionUpdate === "tool_call" || event.payload.sessionUpdate === "tool_call_update")) {
|
|
30309
|
+
this.#toolCallUpdateMap.set(event.payload.toolCallId, item);
|
|
30310
|
+
}
|
|
30311
|
+
};
|
|
30312
|
+
removeHotHead = (count) => {
|
|
30313
|
+
this.hot.splice(0, count);
|
|
30314
|
+
};
|
|
30315
|
+
};
|
|
30316
|
+
function projectAppend(session, event, position) {
|
|
30317
|
+
if (event.type !== "acp" || event.payload.sessionUpdate !== "tool_call_update") {
|
|
30318
|
+
return { item: new PositionedSessionEventV2(event, position), kind: "append" };
|
|
30319
|
+
}
|
|
30320
|
+
const update = event.payload;
|
|
30321
|
+
const previous = session.getToolCallUpdate(update.toolCallId);
|
|
30322
|
+
const previousPayload = previous?.event.type === "acp" ? previous.event.payload : void 0;
|
|
30323
|
+
const previousUpdate = previousPayload?.sessionUpdate === "tool_call" || previousPayload?.sessionUpdate === "tool_call_update" ? previousPayload : void 0;
|
|
30324
|
+
const merged = {
|
|
30325
|
+
...previousUpdate,
|
|
30326
|
+
...update,
|
|
30327
|
+
sessionUpdate: "tool_call_update",
|
|
30328
|
+
toolCallId: update.toolCallId
|
|
30329
|
+
};
|
|
30330
|
+
const item = new PositionedSessionEventV2({ payload: merged, type: "acp" }, position);
|
|
30331
|
+
return previousPayload?.sessionUpdate !== "tool_call_update" || previous === void 0 ? { item, kind: "append" } : {
|
|
30332
|
+
item,
|
|
30333
|
+
kind: "compact-and-append",
|
|
30334
|
+
previous: new PositionedSessionEventV2(compactedToolCallUpdate(update.toolCallId), previous.position),
|
|
30335
|
+
toolCallId: update.toolCallId
|
|
30336
|
+
};
|
|
30337
|
+
}
|
|
30338
|
+
function compactedToolCallUpdate(toolCallId) {
|
|
30339
|
+
return { payload: { sessionUpdate: "tool_call_update", toolCallId }, type: "acp" };
|
|
30340
|
+
}
|
|
30274
30341
|
function eventPage(sessionGenerationId, eventCount, eventLimit, cursor, read) {
|
|
30275
30342
|
const parsedCursor = cursor === null ? eventCount : Number(cursor);
|
|
30276
30343
|
if (!Number.isSafeInteger(parsedCursor) || parsedCursor < 0 || parsedCursor > eventCount) {
|
|
@@ -30298,18 +30365,18 @@ function pageAcpSessionEventsV2(sessionGenerationId, events, eventLimit, cursor)
|
|
|
30298
30365
|
var MemoryAcpSessionEventStoreV2 = class {
|
|
30299
30366
|
#events = /* @__PURE__ */ new Map();
|
|
30300
30367
|
#session = (sessionId) => {
|
|
30301
|
-
const session = this.#events.get(sessionId) ??
|
|
30302
|
-
hot: [],
|
|
30303
|
-
nextPosition: 1,
|
|
30304
|
-
sessionGenerationId: randomUUID()
|
|
30305
|
-
};
|
|
30368
|
+
const session = this.#events.get(sessionId) ?? new SessionEventsV2();
|
|
30306
30369
|
this.#events.set(sessionId, session);
|
|
30307
30370
|
return session;
|
|
30308
30371
|
};
|
|
30309
30372
|
append = (sessionId, event) => {
|
|
30310
30373
|
const session = this.#session(sessionId);
|
|
30311
30374
|
const position = session.nextPosition;
|
|
30312
|
-
session
|
|
30375
|
+
const projected = projectAppend(session, event, position);
|
|
30376
|
+
if (projected.kind === "compact-and-append") {
|
|
30377
|
+
session.updateToolCallUpdate(projected.toolCallId, projected.previous);
|
|
30378
|
+
}
|
|
30379
|
+
session.append(projected.item);
|
|
30313
30380
|
session.nextPosition += 1;
|
|
30314
30381
|
return { position, sessionGenerationId: session.sessionGenerationId };
|
|
30315
30382
|
};
|
|
@@ -30328,7 +30395,7 @@ var MemoryAcpSessionEventStoreV2 = class {
|
|
|
30328
30395
|
this.#events.delete(sessionId);
|
|
30329
30396
|
};
|
|
30330
30397
|
reset = (sessionId) => {
|
|
30331
|
-
this.#events.set(sessionId,
|
|
30398
|
+
this.#events.set(sessionId, new SessionEventsV2());
|
|
30332
30399
|
};
|
|
30333
30400
|
};
|
|
30334
30401
|
var cachedEventRowSchema = external_exports.object({ eventJson: external_exports.string(), position: external_exports.number().int().positive() });
|
|
@@ -30363,11 +30430,7 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
30363
30430
|
}
|
|
30364
30431
|
}
|
|
30365
30432
|
#session = (sessionId) => {
|
|
30366
|
-
const session = this.#sessions.get(sessionId) ??
|
|
30367
|
-
hot: [],
|
|
30368
|
-
nextPosition: 1,
|
|
30369
|
-
sessionGenerationId: randomUUID()
|
|
30370
|
-
};
|
|
30433
|
+
const session = this.#sessions.get(sessionId) ?? new SessionEventsV2();
|
|
30371
30434
|
this.#sessions.set(sessionId, session);
|
|
30372
30435
|
return session;
|
|
30373
30436
|
};
|
|
@@ -30377,7 +30440,11 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
30377
30440
|
}
|
|
30378
30441
|
const session = this.#session(sessionId);
|
|
30379
30442
|
const position = session.nextPosition;
|
|
30380
|
-
session
|
|
30443
|
+
const projected = projectAppend(session, event, position);
|
|
30444
|
+
if (projected.kind === "compact-and-append") {
|
|
30445
|
+
this.#updateToolCallUpdate(sessionId, session, projected.toolCallId, projected.previous);
|
|
30446
|
+
}
|
|
30447
|
+
session.append(projected.item);
|
|
30381
30448
|
session.nextPosition += 1;
|
|
30382
30449
|
this.#sessions.set(sessionId, session);
|
|
30383
30450
|
if (session.hot.length > HOT_EVENT_HIGH_WATER_MARK) {
|
|
@@ -30385,6 +30452,23 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
30385
30452
|
}
|
|
30386
30453
|
return { position, sessionGenerationId: session.sessionGenerationId };
|
|
30387
30454
|
};
|
|
30455
|
+
#updateToolCallUpdate = (sessionId, session, toolCallId, item) => {
|
|
30456
|
+
if (!session.updateToolCallUpdate(toolCallId, item) || !this.#isLocalDBAvailable) {
|
|
30457
|
+
return;
|
|
30458
|
+
}
|
|
30459
|
+
try {
|
|
30460
|
+
this.#database.update(sessionEventV2).set({ eventJson: JSON.stringify(item.event) }).where(
|
|
30461
|
+
and(
|
|
30462
|
+
eq(sessionEventV2.generationId, session.sessionGenerationId),
|
|
30463
|
+
eq(sessionEventV2.sessionId, sessionId),
|
|
30464
|
+
eq(sessionEventV2.position, item.position)
|
|
30465
|
+
)
|
|
30466
|
+
).run();
|
|
30467
|
+
} catch (cause) {
|
|
30468
|
+
this.#isLocalDBAvailable = false;
|
|
30469
|
+
console.warn("Mobius V2 Session event cache writes are unavailable; retaining events in memory", cause);
|
|
30470
|
+
}
|
|
30471
|
+
};
|
|
30388
30472
|
#scheduleFlush = () => {
|
|
30389
30473
|
if (!this.#isLocalDBAvailable || this.#flushSchedule.kind !== "idle") {
|
|
30390
30474
|
return;
|
|
@@ -30431,7 +30515,10 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
30431
30515
|
}
|
|
30432
30516
|
});
|
|
30433
30517
|
for (const batch of batches) {
|
|
30434
|
-
this.#sessions.get(batch.sessionId)
|
|
30518
|
+
const session = this.#sessions.get(batch.sessionId);
|
|
30519
|
+
if (session !== void 0) {
|
|
30520
|
+
session.removeHotHead(batch.count);
|
|
30521
|
+
}
|
|
30435
30522
|
}
|
|
30436
30523
|
} catch (cause) {
|
|
30437
30524
|
this.#isLocalDBAvailable = false;
|
|
@@ -30452,7 +30539,10 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
30452
30539
|
)
|
|
30453
30540
|
).orderBy(asc(sessionEventV2.position)).all().map((value) => {
|
|
30454
30541
|
const row = cachedEventRowSchema.parse(value);
|
|
30455
|
-
return
|
|
30542
|
+
return new PositionedSessionEventV2(
|
|
30543
|
+
decodeCachedEvent(JSON.parse(row.eventJson)),
|
|
30544
|
+
row.position
|
|
30545
|
+
);
|
|
30456
30546
|
});
|
|
30457
30547
|
const hot = (session?.hot ?? []).filter(
|
|
30458
30548
|
({ position }) => position >= startPosition && position <= endPosition
|
|
@@ -30486,7 +30576,7 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
30486
30576
|
reset = (sessionId) => {
|
|
30487
30577
|
const previous = this.#sessions.get(sessionId);
|
|
30488
30578
|
this.#deletePersisted(sessionId, previous?.sessionGenerationId);
|
|
30489
|
-
this.#sessions.set(sessionId,
|
|
30579
|
+
this.#sessions.set(sessionId, new SessionEventsV2());
|
|
30490
30580
|
};
|
|
30491
30581
|
close = () => {
|
|
30492
30582
|
if (this.#flushSchedule.kind === "closed") {
|
|
@@ -39732,7 +39822,7 @@ function send(socket, message) {
|
|
|
39732
39822
|
}
|
|
39733
39823
|
socket.send(encodeDaemonToServiceMessage(message));
|
|
39734
39824
|
}
|
|
39735
|
-
async function settleAbandonedTurn(
|
|
39825
|
+
async function settleAbandonedTurn(projection, operations, audit, cancellation) {
|
|
39736
39826
|
const attemptId = operations.findUnsettledAttemptId(cancellation.commandId, cancellation.sessionId);
|
|
39737
39827
|
if (attemptId === null) {
|
|
39738
39828
|
console.warn("Mobius daemon ignored cancellation for an inactive turn");
|
|
@@ -39743,14 +39833,14 @@ async function settleAbandonedTurn(eventLog, operations, audit, cancellation) {
|
|
|
39743
39833
|
event: "session_abandoned_turn_settled",
|
|
39744
39834
|
sessionId: cancellation.sessionId
|
|
39745
39835
|
});
|
|
39746
|
-
await
|
|
39836
|
+
await projection.failed(
|
|
39747
39837
|
cancellation.sessionId,
|
|
39748
39838
|
cancellation.commandId,
|
|
39749
39839
|
"agent_execution_abandoned",
|
|
39750
39840
|
"The local Agent execution was abandoned before it completed"
|
|
39751
39841
|
);
|
|
39752
39842
|
operations.transitionExecution(cancellation.commandId, "failed");
|
|
39753
|
-
|
|
39843
|
+
projection.publishTerminal(cancellation.sessionId, cancellation.commandId);
|
|
39754
39844
|
}
|
|
39755
39845
|
function operationErrorCode(error62) {
|
|
39756
39846
|
if (error62 instanceof AcpExecutionError || error62 instanceof LocalAuthorizationError || error62 instanceof LocalAgentCatalogError || error62 instanceof PromptArtifactError) {
|
|
@@ -41900,7 +41990,7 @@ import { WebSocket as WebSocket5 } from "undici";
|
|
|
41900
41990
|
// package.json
|
|
41901
41991
|
var package_default = {
|
|
41902
41992
|
name: "@moxt-ai/mobius",
|
|
41903
|
-
version: "0.0.
|
|
41993
|
+
version: "0.0.198",
|
|
41904
41994
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
41905
41995
|
type: "module",
|
|
41906
41996
|
bin: {
|
|
@@ -41925,19 +42015,23 @@ var package_default = {
|
|
|
41925
42015
|
exports: {
|
|
41926
42016
|
".": {
|
|
41927
42017
|
types: "./dist/index.d.ts",
|
|
41928
|
-
import: "./dist/index.js"
|
|
42018
|
+
import: "./dist/index.js",
|
|
42019
|
+
default: "./dist/index.js"
|
|
41929
42020
|
},
|
|
41930
42021
|
"./runtime": {
|
|
41931
42022
|
types: "./dist/runtime.d.ts",
|
|
41932
|
-
import: "./dist/runtime.js"
|
|
42023
|
+
import: "./dist/runtime.js",
|
|
42024
|
+
default: "./dist/runtime.js"
|
|
41933
42025
|
},
|
|
41934
42026
|
"./process": {
|
|
41935
42027
|
types: "./dist/process/executable.d.ts",
|
|
41936
|
-
import: "./dist/process/executable.js"
|
|
42028
|
+
import: "./dist/process/executable.js",
|
|
42029
|
+
default: "./dist/process/executable.js"
|
|
41937
42030
|
},
|
|
41938
42031
|
"./filesystem": {
|
|
41939
42032
|
types: "./dist/filesystem/private-path.d.ts",
|
|
41940
|
-
import: "./dist/filesystem/private-path.js"
|
|
42033
|
+
import: "./dist/filesystem/private-path.js",
|
|
42034
|
+
default: "./dist/filesystem/private-path.js"
|
|
41941
42035
|
}
|
|
41942
42036
|
}
|
|
41943
42037
|
},
|
|
@@ -42973,7 +43067,7 @@ function omitAgentReasoning(events) {
|
|
|
42973
43067
|
}
|
|
42974
43068
|
return retained;
|
|
42975
43069
|
}
|
|
42976
|
-
async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load,
|
|
43070
|
+
async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load, eventProjectionV2) {
|
|
42977
43071
|
let cursor = initialCursor;
|
|
42978
43072
|
let loaded = [];
|
|
42979
43073
|
let sessionGenerationId = null;
|
|
@@ -42985,7 +43079,7 @@ async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoni
|
|
|
42985
43079
|
}
|
|
42986
43080
|
sessionGenerationId = replay.sessionGenerationId;
|
|
42987
43081
|
const events2 = replay.events.map(
|
|
42988
|
-
(event, index2) =>
|
|
43082
|
+
(event, index2) => eventProjectionV2.event(
|
|
42989
43083
|
sessionId,
|
|
42990
43084
|
replay.sessionGenerationId,
|
|
42991
43085
|
replay.startPosition + index2,
|
|
@@ -43021,7 +43115,7 @@ async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoni
|
|
|
43021
43115
|
queuedPromptRequests
|
|
43022
43116
|
};
|
|
43023
43117
|
}
|
|
43024
|
-
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions,
|
|
43118
|
+
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventProjectionV2, signal) {
|
|
43025
43119
|
let agentId;
|
|
43026
43120
|
try {
|
|
43027
43121
|
const [entry] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
@@ -43043,7 +43137,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
43043
43137
|
sessionId: command.sessionId,
|
|
43044
43138
|
signal
|
|
43045
43139
|
};
|
|
43046
|
-
const recovery =
|
|
43140
|
+
const recovery = eventProjectionV2.promptRequestRecovery(command.sessionId);
|
|
43047
43141
|
const events = await loadHistoryPage(
|
|
43048
43142
|
command.sessionId,
|
|
43049
43143
|
command.eventLimit,
|
|
@@ -43051,7 +43145,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
43051
43145
|
command.omit?.includes("agent-reasoning") === true,
|
|
43052
43146
|
recovery.queuedPromptRequests,
|
|
43053
43147
|
async (eventLimit, cursor) => await sessions.loadSessionEventsV2(loadOptions, eventLimit, cursor),
|
|
43054
|
-
|
|
43148
|
+
eventProjectionV2
|
|
43055
43149
|
);
|
|
43056
43150
|
signal.throwIfAborted();
|
|
43057
43151
|
audit.record({
|
|
@@ -43090,7 +43184,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
43090
43184
|
}
|
|
43091
43185
|
}
|
|
43092
43186
|
}
|
|
43093
|
-
async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions,
|
|
43187
|
+
async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventProjectionV2, signal) {
|
|
43094
43188
|
try {
|
|
43095
43189
|
const resolved = await resolveSessionDirectories(
|
|
43096
43190
|
directories,
|
|
@@ -43113,7 +43207,7 @@ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, di
|
|
|
43113
43207
|
command.omit?.includes("agent-reasoning") === true,
|
|
43114
43208
|
[],
|
|
43115
43209
|
async (eventLimit, cursor) => await sessions.previewNativeSessionEventsV2(loadOptions, command.sessionId, eventLimit, cursor),
|
|
43116
|
-
|
|
43210
|
+
eventProjectionV2
|
|
43117
43211
|
);
|
|
43118
43212
|
signal.throwIfAborted();
|
|
43119
43213
|
audit.record({
|
|
@@ -43356,7 +43450,7 @@ function daemonActivity(command, activity2) {
|
|
|
43356
43450
|
}
|
|
43357
43451
|
async function executePrompt({
|
|
43358
43452
|
operations,
|
|
43359
|
-
|
|
43453
|
+
eventProjectionV2,
|
|
43360
43454
|
command,
|
|
43361
43455
|
config: config2,
|
|
43362
43456
|
directories,
|
|
@@ -43436,7 +43530,7 @@ async function executePrompt({
|
|
|
43436
43530
|
}
|
|
43437
43531
|
}
|
|
43438
43532
|
const stream = activateAttempt();
|
|
43439
|
-
const lifecycleV2 =
|
|
43533
|
+
const lifecycleV2 = eventProjectionV2.started(
|
|
43440
43534
|
command.sessionId,
|
|
43441
43535
|
command.commandId,
|
|
43442
43536
|
attemptId,
|
|
@@ -43491,7 +43585,7 @@ async function executePrompt({
|
|
|
43491
43585
|
});
|
|
43492
43586
|
stopReason = result.stopReason;
|
|
43493
43587
|
}
|
|
43494
|
-
await
|
|
43588
|
+
await eventProjectionV2.completed(command.sessionId, command.commandId, stopReason);
|
|
43495
43589
|
operations.transitionExecution(command.commandId, stopReason === "cancelled" ? "cancelled" : "succeeded");
|
|
43496
43590
|
audit.record({
|
|
43497
43591
|
commandId: command.commandId,
|
|
@@ -43500,7 +43594,7 @@ async function executePrompt({
|
|
|
43500
43594
|
});
|
|
43501
43595
|
} catch (error62) {
|
|
43502
43596
|
if (signal.aborted && cancellationRequested()) {
|
|
43503
|
-
await
|
|
43597
|
+
await eventProjectionV2.completed(command.sessionId, command.commandId, "cancelled");
|
|
43504
43598
|
operations.transitionExecution(command.commandId, "cancelled");
|
|
43505
43599
|
audit.record({
|
|
43506
43600
|
commandId: command.commandId,
|
|
@@ -43517,7 +43611,7 @@ async function executePrompt({
|
|
|
43517
43611
|
const code = operationErrorCode(error62);
|
|
43518
43612
|
const failureCode = code === "session_operation_failed" ? "agent_execution_failed" : code;
|
|
43519
43613
|
const failureMessage = code === "session_operation_failed" ? "The local agent could not complete the request" : operationErrorMessage(error62);
|
|
43520
|
-
await
|
|
43614
|
+
await eventProjectionV2.failed(command.sessionId, command.commandId, failureCode, failureMessage);
|
|
43521
43615
|
operations.transitionExecution(command.commandId, "failed");
|
|
43522
43616
|
console.error("Mobius daemon command failed", error62);
|
|
43523
43617
|
}
|
|
@@ -43629,7 +43723,7 @@ function createDaemonCommandHandler({
|
|
|
43629
43723
|
installations,
|
|
43630
43724
|
nativeSessions,
|
|
43631
43725
|
operations,
|
|
43632
|
-
|
|
43726
|
+
eventProjectionV2,
|
|
43633
43727
|
externalContent,
|
|
43634
43728
|
activeTurns,
|
|
43635
43729
|
diagnostics,
|
|
@@ -43649,7 +43743,7 @@ function createDaemonCommandHandler({
|
|
|
43649
43743
|
timer
|
|
43650
43744
|
});
|
|
43651
43745
|
const queueChanged = (sessionId) => {
|
|
43652
|
-
void
|
|
43746
|
+
void eventProjectionV2.queueChanged(sessionId).catch((error62) => {
|
|
43653
43747
|
console.error("Could not record queue change", error62);
|
|
43654
43748
|
});
|
|
43655
43749
|
};
|
|
@@ -43709,7 +43803,7 @@ function createDaemonCommandHandler({
|
|
|
43709
43803
|
diagnostics,
|
|
43710
43804
|
sessions,
|
|
43711
43805
|
nativeSessions,
|
|
43712
|
-
|
|
43806
|
+
eventProjectionV2,
|
|
43713
43807
|
signal
|
|
43714
43808
|
);
|
|
43715
43809
|
return;
|
|
@@ -43723,7 +43817,7 @@ function createDaemonCommandHandler({
|
|
|
43723
43817
|
audit,
|
|
43724
43818
|
diagnostics,
|
|
43725
43819
|
sessions,
|
|
43726
|
-
|
|
43820
|
+
eventProjectionV2,
|
|
43727
43821
|
signal
|
|
43728
43822
|
);
|
|
43729
43823
|
return;
|
|
@@ -43766,9 +43860,11 @@ function createDaemonCommandHandler({
|
|
|
43766
43860
|
const cancellation = message;
|
|
43767
43861
|
const turn2 = activeTurns.get(cancellation.commandId);
|
|
43768
43862
|
if (turn2 === void 0 || !turn2.matches(cancellation)) {
|
|
43769
|
-
void settleAbandonedTurn(
|
|
43770
|
-
|
|
43771
|
-
|
|
43863
|
+
void settleAbandonedTurn(eventProjectionV2, operations, audit, cancellation).catch(
|
|
43864
|
+
(error62) => {
|
|
43865
|
+
console.error("Could not settle abandoned turn", error62);
|
|
43866
|
+
}
|
|
43867
|
+
);
|
|
43772
43868
|
return;
|
|
43773
43869
|
}
|
|
43774
43870
|
const cancellationState = turn2.requestCancellation();
|
|
@@ -43927,10 +44023,10 @@ function createDaemonCommandHandler({
|
|
|
43927
44023
|
return;
|
|
43928
44024
|
}
|
|
43929
44025
|
const turn = activeTurns.start(command, receipt.attemptId);
|
|
43930
|
-
|
|
44026
|
+
eventProjectionV2.requested(command);
|
|
43931
44027
|
void executePrompt({
|
|
43932
44028
|
operations,
|
|
43933
|
-
|
|
44029
|
+
eventProjectionV2,
|
|
43934
44030
|
command,
|
|
43935
44031
|
config: config2,
|
|
43936
44032
|
directories,
|
|
@@ -43954,7 +44050,7 @@ function createDaemonCommandHandler({
|
|
|
43954
44050
|
console.error("Mobius daemon turn failed", error62);
|
|
43955
44051
|
}).finally(() => {
|
|
43956
44052
|
activeTurns.finish(turn);
|
|
43957
|
-
|
|
44053
|
+
eventProjectionV2.publishTerminal(command.sessionId, command.commandId);
|
|
43958
44054
|
if (command.disposition === SessionPromptDisposition.Queue) {
|
|
43959
44055
|
queueChanged(command.sessionId);
|
|
43960
44056
|
}
|
|
@@ -44196,7 +44292,7 @@ async function runRelayConnection({
|
|
|
44196
44292
|
nativeSessions,
|
|
44197
44293
|
operations,
|
|
44198
44294
|
publisher,
|
|
44199
|
-
|
|
44295
|
+
eventProjectionV2,
|
|
44200
44296
|
externalContent,
|
|
44201
44297
|
activeTurns,
|
|
44202
44298
|
connectionEpoch,
|
|
@@ -44218,7 +44314,7 @@ async function runRelayConnection({
|
|
|
44218
44314
|
installations,
|
|
44219
44315
|
nativeSessions,
|
|
44220
44316
|
operations,
|
|
44221
|
-
|
|
44317
|
+
eventProjectionV2,
|
|
44222
44318
|
externalContent,
|
|
44223
44319
|
activeTurns,
|
|
44224
44320
|
diagnostics,
|
|
@@ -44461,7 +44557,7 @@ var SystemDaemonTimer = class {
|
|
|
44461
44557
|
};
|
|
44462
44558
|
var systemDaemonTimer = new SystemDaemonTimer();
|
|
44463
44559
|
|
|
44464
|
-
// src/session-event-
|
|
44560
|
+
// src/session-event-projection-v2.ts
|
|
44465
44561
|
function promptContent(command) {
|
|
44466
44562
|
const content = [];
|
|
44467
44563
|
if (command.prompt.length > 0) {
|
|
@@ -44485,7 +44581,7 @@ function promptContent(command) {
|
|
|
44485
44581
|
}
|
|
44486
44582
|
return content;
|
|
44487
44583
|
}
|
|
44488
|
-
function
|
|
44584
|
+
function projectSessionEventV2(sessionGenerationId, sessionId, position, event, recordedAt) {
|
|
44489
44585
|
return {
|
|
44490
44586
|
eventId: `event-${sessionGenerationId}-${position.toString().padStart(16, "0")}`,
|
|
44491
44587
|
...event,
|
|
@@ -44496,7 +44592,7 @@ function sessionEventV22(sessionGenerationId, sessionId, position, event, record
|
|
|
44496
44592
|
sessionId
|
|
44497
44593
|
};
|
|
44498
44594
|
}
|
|
44499
|
-
var
|
|
44595
|
+
var DaemonSessionEventProjectionV2 = class {
|
|
44500
44596
|
#publisher;
|
|
44501
44597
|
#terminal = /* @__PURE__ */ new Map();
|
|
44502
44598
|
#publications = /* @__PURE__ */ new Map();
|
|
@@ -44580,7 +44676,7 @@ var DaemonSessionEventLogV2 = class {
|
|
|
44580
44676
|
}
|
|
44581
44677
|
this.#queued.delete(commandId);
|
|
44582
44678
|
};
|
|
44583
|
-
event = (sessionId, sessionGenerationId, position, event, recordedAt) =>
|
|
44679
|
+
event = (sessionId, sessionGenerationId, position, event, recordedAt) => projectSessionEventV2(sessionGenerationId, sessionId, position, event, recordedAt);
|
|
44584
44680
|
queueChanged = async (sessionId) => {
|
|
44585
44681
|
await this.#recordLifecycle(sessionId, {
|
|
44586
44682
|
type: "lifecycle-metadata",
|
|
@@ -44709,7 +44805,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44709
44805
|
await using externalContent = new LocalExternalContentStore(stateDirectory);
|
|
44710
44806
|
const operations = new DaemonOperationState();
|
|
44711
44807
|
const publisher = new DaemonSessionEventPublisher(timer);
|
|
44712
|
-
const
|
|
44808
|
+
const eventProjectionV2 = new DaemonSessionEventProjectionV2(
|
|
44713
44809
|
publisher,
|
|
44714
44810
|
(sessionId, event) => agentRuntime.recordLifecycleEventV2(sessionId, event)
|
|
44715
44811
|
);
|
|
@@ -44720,7 +44816,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44720
44816
|
if (event.kind === "session.info.updated") {
|
|
44721
44817
|
publisher.publishInfo(event);
|
|
44722
44818
|
}
|
|
44723
|
-
},
|
|
44819
|
+
}, eventProjectionV2.record),
|
|
44724
44820
|
sessionStore,
|
|
44725
44821
|
{
|
|
44726
44822
|
access: (options2) => options2.agent.id === "codex" ? {
|
|
@@ -44845,7 +44941,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44845
44941
|
nativeSessions,
|
|
44846
44942
|
operations,
|
|
44847
44943
|
publisher,
|
|
44848
|
-
|
|
44944
|
+
eventProjectionV2,
|
|
44849
44945
|
externalContent,
|
|
44850
44946
|
activeTurns,
|
|
44851
44947
|
connectionEpoch,
|