@moxt-ai/mobius 0.0.197 → 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 +143 -51
- 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 +143 -51
- 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 +143 -51
- 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 +1 -1
- 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: {
|
|
@@ -42977,7 +43067,7 @@ function omitAgentReasoning(events) {
|
|
|
42977
43067
|
}
|
|
42978
43068
|
return retained;
|
|
42979
43069
|
}
|
|
42980
|
-
async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load,
|
|
43070
|
+
async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load, eventProjectionV2) {
|
|
42981
43071
|
let cursor = initialCursor;
|
|
42982
43072
|
let loaded = [];
|
|
42983
43073
|
let sessionGenerationId = null;
|
|
@@ -42989,7 +43079,7 @@ async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoni
|
|
|
42989
43079
|
}
|
|
42990
43080
|
sessionGenerationId = replay.sessionGenerationId;
|
|
42991
43081
|
const events2 = replay.events.map(
|
|
42992
|
-
(event, index2) =>
|
|
43082
|
+
(event, index2) => eventProjectionV2.event(
|
|
42993
43083
|
sessionId,
|
|
42994
43084
|
replay.sessionGenerationId,
|
|
42995
43085
|
replay.startPosition + index2,
|
|
@@ -43025,7 +43115,7 @@ async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoni
|
|
|
43025
43115
|
queuedPromptRequests
|
|
43026
43116
|
};
|
|
43027
43117
|
}
|
|
43028
|
-
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) {
|
|
43029
43119
|
let agentId;
|
|
43030
43120
|
try {
|
|
43031
43121
|
const [entry] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
@@ -43047,7 +43137,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
43047
43137
|
sessionId: command.sessionId,
|
|
43048
43138
|
signal
|
|
43049
43139
|
};
|
|
43050
|
-
const recovery =
|
|
43140
|
+
const recovery = eventProjectionV2.promptRequestRecovery(command.sessionId);
|
|
43051
43141
|
const events = await loadHistoryPage(
|
|
43052
43142
|
command.sessionId,
|
|
43053
43143
|
command.eventLimit,
|
|
@@ -43055,7 +43145,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
43055
43145
|
command.omit?.includes("agent-reasoning") === true,
|
|
43056
43146
|
recovery.queuedPromptRequests,
|
|
43057
43147
|
async (eventLimit, cursor) => await sessions.loadSessionEventsV2(loadOptions, eventLimit, cursor),
|
|
43058
|
-
|
|
43148
|
+
eventProjectionV2
|
|
43059
43149
|
);
|
|
43060
43150
|
signal.throwIfAborted();
|
|
43061
43151
|
audit.record({
|
|
@@ -43094,7 +43184,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
43094
43184
|
}
|
|
43095
43185
|
}
|
|
43096
43186
|
}
|
|
43097
|
-
async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions,
|
|
43187
|
+
async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventProjectionV2, signal) {
|
|
43098
43188
|
try {
|
|
43099
43189
|
const resolved = await resolveSessionDirectories(
|
|
43100
43190
|
directories,
|
|
@@ -43117,7 +43207,7 @@ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, di
|
|
|
43117
43207
|
command.omit?.includes("agent-reasoning") === true,
|
|
43118
43208
|
[],
|
|
43119
43209
|
async (eventLimit, cursor) => await sessions.previewNativeSessionEventsV2(loadOptions, command.sessionId, eventLimit, cursor),
|
|
43120
|
-
|
|
43210
|
+
eventProjectionV2
|
|
43121
43211
|
);
|
|
43122
43212
|
signal.throwIfAborted();
|
|
43123
43213
|
audit.record({
|
|
@@ -43360,7 +43450,7 @@ function daemonActivity(command, activity2) {
|
|
|
43360
43450
|
}
|
|
43361
43451
|
async function executePrompt({
|
|
43362
43452
|
operations,
|
|
43363
|
-
|
|
43453
|
+
eventProjectionV2,
|
|
43364
43454
|
command,
|
|
43365
43455
|
config: config2,
|
|
43366
43456
|
directories,
|
|
@@ -43440,7 +43530,7 @@ async function executePrompt({
|
|
|
43440
43530
|
}
|
|
43441
43531
|
}
|
|
43442
43532
|
const stream = activateAttempt();
|
|
43443
|
-
const lifecycleV2 =
|
|
43533
|
+
const lifecycleV2 = eventProjectionV2.started(
|
|
43444
43534
|
command.sessionId,
|
|
43445
43535
|
command.commandId,
|
|
43446
43536
|
attemptId,
|
|
@@ -43495,7 +43585,7 @@ async function executePrompt({
|
|
|
43495
43585
|
});
|
|
43496
43586
|
stopReason = result.stopReason;
|
|
43497
43587
|
}
|
|
43498
|
-
await
|
|
43588
|
+
await eventProjectionV2.completed(command.sessionId, command.commandId, stopReason);
|
|
43499
43589
|
operations.transitionExecution(command.commandId, stopReason === "cancelled" ? "cancelled" : "succeeded");
|
|
43500
43590
|
audit.record({
|
|
43501
43591
|
commandId: command.commandId,
|
|
@@ -43504,7 +43594,7 @@ async function executePrompt({
|
|
|
43504
43594
|
});
|
|
43505
43595
|
} catch (error62) {
|
|
43506
43596
|
if (signal.aborted && cancellationRequested()) {
|
|
43507
|
-
await
|
|
43597
|
+
await eventProjectionV2.completed(command.sessionId, command.commandId, "cancelled");
|
|
43508
43598
|
operations.transitionExecution(command.commandId, "cancelled");
|
|
43509
43599
|
audit.record({
|
|
43510
43600
|
commandId: command.commandId,
|
|
@@ -43521,7 +43611,7 @@ async function executePrompt({
|
|
|
43521
43611
|
const code = operationErrorCode(error62);
|
|
43522
43612
|
const failureCode = code === "session_operation_failed" ? "agent_execution_failed" : code;
|
|
43523
43613
|
const failureMessage = code === "session_operation_failed" ? "The local agent could not complete the request" : operationErrorMessage(error62);
|
|
43524
|
-
await
|
|
43614
|
+
await eventProjectionV2.failed(command.sessionId, command.commandId, failureCode, failureMessage);
|
|
43525
43615
|
operations.transitionExecution(command.commandId, "failed");
|
|
43526
43616
|
console.error("Mobius daemon command failed", error62);
|
|
43527
43617
|
}
|
|
@@ -43633,7 +43723,7 @@ function createDaemonCommandHandler({
|
|
|
43633
43723
|
installations,
|
|
43634
43724
|
nativeSessions,
|
|
43635
43725
|
operations,
|
|
43636
|
-
|
|
43726
|
+
eventProjectionV2,
|
|
43637
43727
|
externalContent,
|
|
43638
43728
|
activeTurns,
|
|
43639
43729
|
diagnostics,
|
|
@@ -43653,7 +43743,7 @@ function createDaemonCommandHandler({
|
|
|
43653
43743
|
timer
|
|
43654
43744
|
});
|
|
43655
43745
|
const queueChanged = (sessionId) => {
|
|
43656
|
-
void
|
|
43746
|
+
void eventProjectionV2.queueChanged(sessionId).catch((error62) => {
|
|
43657
43747
|
console.error("Could not record queue change", error62);
|
|
43658
43748
|
});
|
|
43659
43749
|
};
|
|
@@ -43713,7 +43803,7 @@ function createDaemonCommandHandler({
|
|
|
43713
43803
|
diagnostics,
|
|
43714
43804
|
sessions,
|
|
43715
43805
|
nativeSessions,
|
|
43716
|
-
|
|
43806
|
+
eventProjectionV2,
|
|
43717
43807
|
signal
|
|
43718
43808
|
);
|
|
43719
43809
|
return;
|
|
@@ -43727,7 +43817,7 @@ function createDaemonCommandHandler({
|
|
|
43727
43817
|
audit,
|
|
43728
43818
|
diagnostics,
|
|
43729
43819
|
sessions,
|
|
43730
|
-
|
|
43820
|
+
eventProjectionV2,
|
|
43731
43821
|
signal
|
|
43732
43822
|
);
|
|
43733
43823
|
return;
|
|
@@ -43770,9 +43860,11 @@ function createDaemonCommandHandler({
|
|
|
43770
43860
|
const cancellation = message;
|
|
43771
43861
|
const turn2 = activeTurns.get(cancellation.commandId);
|
|
43772
43862
|
if (turn2 === void 0 || !turn2.matches(cancellation)) {
|
|
43773
|
-
void settleAbandonedTurn(
|
|
43774
|
-
|
|
43775
|
-
|
|
43863
|
+
void settleAbandonedTurn(eventProjectionV2, operations, audit, cancellation).catch(
|
|
43864
|
+
(error62) => {
|
|
43865
|
+
console.error("Could not settle abandoned turn", error62);
|
|
43866
|
+
}
|
|
43867
|
+
);
|
|
43776
43868
|
return;
|
|
43777
43869
|
}
|
|
43778
43870
|
const cancellationState = turn2.requestCancellation();
|
|
@@ -43931,10 +44023,10 @@ function createDaemonCommandHandler({
|
|
|
43931
44023
|
return;
|
|
43932
44024
|
}
|
|
43933
44025
|
const turn = activeTurns.start(command, receipt.attemptId);
|
|
43934
|
-
|
|
44026
|
+
eventProjectionV2.requested(command);
|
|
43935
44027
|
void executePrompt({
|
|
43936
44028
|
operations,
|
|
43937
|
-
|
|
44029
|
+
eventProjectionV2,
|
|
43938
44030
|
command,
|
|
43939
44031
|
config: config2,
|
|
43940
44032
|
directories,
|
|
@@ -43958,7 +44050,7 @@ function createDaemonCommandHandler({
|
|
|
43958
44050
|
console.error("Mobius daemon turn failed", error62);
|
|
43959
44051
|
}).finally(() => {
|
|
43960
44052
|
activeTurns.finish(turn);
|
|
43961
|
-
|
|
44053
|
+
eventProjectionV2.publishTerminal(command.sessionId, command.commandId);
|
|
43962
44054
|
if (command.disposition === SessionPromptDisposition.Queue) {
|
|
43963
44055
|
queueChanged(command.sessionId);
|
|
43964
44056
|
}
|
|
@@ -44200,7 +44292,7 @@ async function runRelayConnection({
|
|
|
44200
44292
|
nativeSessions,
|
|
44201
44293
|
operations,
|
|
44202
44294
|
publisher,
|
|
44203
|
-
|
|
44295
|
+
eventProjectionV2,
|
|
44204
44296
|
externalContent,
|
|
44205
44297
|
activeTurns,
|
|
44206
44298
|
connectionEpoch,
|
|
@@ -44222,7 +44314,7 @@ async function runRelayConnection({
|
|
|
44222
44314
|
installations,
|
|
44223
44315
|
nativeSessions,
|
|
44224
44316
|
operations,
|
|
44225
|
-
|
|
44317
|
+
eventProjectionV2,
|
|
44226
44318
|
externalContent,
|
|
44227
44319
|
activeTurns,
|
|
44228
44320
|
diagnostics,
|
|
@@ -44465,7 +44557,7 @@ var SystemDaemonTimer = class {
|
|
|
44465
44557
|
};
|
|
44466
44558
|
var systemDaemonTimer = new SystemDaemonTimer();
|
|
44467
44559
|
|
|
44468
|
-
// src/session-event-
|
|
44560
|
+
// src/session-event-projection-v2.ts
|
|
44469
44561
|
function promptContent(command) {
|
|
44470
44562
|
const content = [];
|
|
44471
44563
|
if (command.prompt.length > 0) {
|
|
@@ -44489,7 +44581,7 @@ function promptContent(command) {
|
|
|
44489
44581
|
}
|
|
44490
44582
|
return content;
|
|
44491
44583
|
}
|
|
44492
|
-
function
|
|
44584
|
+
function projectSessionEventV2(sessionGenerationId, sessionId, position, event, recordedAt) {
|
|
44493
44585
|
return {
|
|
44494
44586
|
eventId: `event-${sessionGenerationId}-${position.toString().padStart(16, "0")}`,
|
|
44495
44587
|
...event,
|
|
@@ -44500,7 +44592,7 @@ function sessionEventV22(sessionGenerationId, sessionId, position, event, record
|
|
|
44500
44592
|
sessionId
|
|
44501
44593
|
};
|
|
44502
44594
|
}
|
|
44503
|
-
var
|
|
44595
|
+
var DaemonSessionEventProjectionV2 = class {
|
|
44504
44596
|
#publisher;
|
|
44505
44597
|
#terminal = /* @__PURE__ */ new Map();
|
|
44506
44598
|
#publications = /* @__PURE__ */ new Map();
|
|
@@ -44584,7 +44676,7 @@ var DaemonSessionEventLogV2 = class {
|
|
|
44584
44676
|
}
|
|
44585
44677
|
this.#queued.delete(commandId);
|
|
44586
44678
|
};
|
|
44587
|
-
event = (sessionId, sessionGenerationId, position, event, recordedAt) =>
|
|
44679
|
+
event = (sessionId, sessionGenerationId, position, event, recordedAt) => projectSessionEventV2(sessionGenerationId, sessionId, position, event, recordedAt);
|
|
44588
44680
|
queueChanged = async (sessionId) => {
|
|
44589
44681
|
await this.#recordLifecycle(sessionId, {
|
|
44590
44682
|
type: "lifecycle-metadata",
|
|
@@ -44713,7 +44805,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44713
44805
|
await using externalContent = new LocalExternalContentStore(stateDirectory);
|
|
44714
44806
|
const operations = new DaemonOperationState();
|
|
44715
44807
|
const publisher = new DaemonSessionEventPublisher(timer);
|
|
44716
|
-
const
|
|
44808
|
+
const eventProjectionV2 = new DaemonSessionEventProjectionV2(
|
|
44717
44809
|
publisher,
|
|
44718
44810
|
(sessionId, event) => agentRuntime.recordLifecycleEventV2(sessionId, event)
|
|
44719
44811
|
);
|
|
@@ -44724,7 +44816,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44724
44816
|
if (event.kind === "session.info.updated") {
|
|
44725
44817
|
publisher.publishInfo(event);
|
|
44726
44818
|
}
|
|
44727
|
-
},
|
|
44819
|
+
}, eventProjectionV2.record),
|
|
44728
44820
|
sessionStore,
|
|
44729
44821
|
{
|
|
44730
44822
|
access: (options2) => options2.agent.id === "codex" ? {
|
|
@@ -44849,7 +44941,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44849
44941
|
nativeSessions,
|
|
44850
44942
|
operations,
|
|
44851
44943
|
publisher,
|
|
44852
|
-
|
|
44944
|
+
eventProjectionV2,
|
|
44853
44945
|
externalContent,
|
|
44854
44946
|
activeTurns,
|
|
44855
44947
|
connectionEpoch,
|