@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/cli.js
CHANGED
|
@@ -3381,7 +3381,7 @@ var program = new Command();
|
|
|
3381
3381
|
// package.json
|
|
3382
3382
|
var package_default = {
|
|
3383
3383
|
name: "@moxt-ai/mobius",
|
|
3384
|
-
version: "0.0.
|
|
3384
|
+
version: "0.0.198",
|
|
3385
3385
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
3386
3386
|
type: "module",
|
|
3387
3387
|
bin: {
|
|
@@ -3406,19 +3406,23 @@ var package_default = {
|
|
|
3406
3406
|
exports: {
|
|
3407
3407
|
".": {
|
|
3408
3408
|
types: "./dist/index.d.ts",
|
|
3409
|
-
import: "./dist/index.js"
|
|
3409
|
+
import: "./dist/index.js",
|
|
3410
|
+
default: "./dist/index.js"
|
|
3410
3411
|
},
|
|
3411
3412
|
"./runtime": {
|
|
3412
3413
|
types: "./dist/runtime.d.ts",
|
|
3413
|
-
import: "./dist/runtime.js"
|
|
3414
|
+
import: "./dist/runtime.js",
|
|
3415
|
+
default: "./dist/runtime.js"
|
|
3414
3416
|
},
|
|
3415
3417
|
"./process": {
|
|
3416
3418
|
types: "./dist/process/executable.d.ts",
|
|
3417
|
-
import: "./dist/process/executable.js"
|
|
3419
|
+
import: "./dist/process/executable.js",
|
|
3420
|
+
default: "./dist/process/executable.js"
|
|
3418
3421
|
},
|
|
3419
3422
|
"./filesystem": {
|
|
3420
3423
|
types: "./dist/filesystem/private-path.d.ts",
|
|
3421
|
-
import: "./dist/filesystem/private-path.js"
|
|
3424
|
+
import: "./dist/filesystem/private-path.js",
|
|
3425
|
+
default: "./dist/filesystem/private-path.js"
|
|
3422
3426
|
}
|
|
3423
3427
|
}
|
|
3424
3428
|
},
|
|
@@ -39073,6 +39077,73 @@ var sessionEventV2 = sqliteTable(
|
|
|
39073
39077
|
// src/acp/session-event-store-v2.ts
|
|
39074
39078
|
var HOT_EVENT_HIGH_WATER_MARK = 256;
|
|
39075
39079
|
var HOT_EVENT_RETENTION = 128;
|
|
39080
|
+
var PositionedSessionEventV2 = class {
|
|
39081
|
+
#event;
|
|
39082
|
+
position;
|
|
39083
|
+
constructor(event, position) {
|
|
39084
|
+
this.#event = event;
|
|
39085
|
+
this.position = position;
|
|
39086
|
+
}
|
|
39087
|
+
get event() {
|
|
39088
|
+
return this.#event;
|
|
39089
|
+
}
|
|
39090
|
+
replaceEvent = (event) => {
|
|
39091
|
+
this.#event = event;
|
|
39092
|
+
};
|
|
39093
|
+
};
|
|
39094
|
+
var SessionEventsV2 = class {
|
|
39095
|
+
hot = [];
|
|
39096
|
+
#toolCallUpdateMap = /* @__PURE__ */ new Map();
|
|
39097
|
+
sessionGenerationId;
|
|
39098
|
+
nextPosition = 1;
|
|
39099
|
+
constructor() {
|
|
39100
|
+
this.sessionGenerationId = randomUUID2();
|
|
39101
|
+
}
|
|
39102
|
+
getToolCallUpdate = (toolCallId) => this.#toolCallUpdateMap.get(toolCallId);
|
|
39103
|
+
updateToolCallUpdate = (toolCallId, item) => {
|
|
39104
|
+
const current = this.#toolCallUpdateMap.get(toolCallId);
|
|
39105
|
+
if (current === void 0 || current.position !== item.position) {
|
|
39106
|
+
return false;
|
|
39107
|
+
}
|
|
39108
|
+
current.replaceEvent(item.event);
|
|
39109
|
+
return true;
|
|
39110
|
+
};
|
|
39111
|
+
append = (item) => {
|
|
39112
|
+
this.hot.push(item);
|
|
39113
|
+
const event = item.event;
|
|
39114
|
+
if (event.type === "acp" && (event.payload.sessionUpdate === "tool_call" || event.payload.sessionUpdate === "tool_call_update")) {
|
|
39115
|
+
this.#toolCallUpdateMap.set(event.payload.toolCallId, item);
|
|
39116
|
+
}
|
|
39117
|
+
};
|
|
39118
|
+
removeHotHead = (count) => {
|
|
39119
|
+
this.hot.splice(0, count);
|
|
39120
|
+
};
|
|
39121
|
+
};
|
|
39122
|
+
function projectAppend(session, event, position) {
|
|
39123
|
+
if (event.type !== "acp" || event.payload.sessionUpdate !== "tool_call_update") {
|
|
39124
|
+
return { item: new PositionedSessionEventV2(event, position), kind: "append" };
|
|
39125
|
+
}
|
|
39126
|
+
const update = event.payload;
|
|
39127
|
+
const previous = session.getToolCallUpdate(update.toolCallId);
|
|
39128
|
+
const previousPayload = previous?.event.type === "acp" ? previous.event.payload : void 0;
|
|
39129
|
+
const previousUpdate = previousPayload?.sessionUpdate === "tool_call" || previousPayload?.sessionUpdate === "tool_call_update" ? previousPayload : void 0;
|
|
39130
|
+
const merged = {
|
|
39131
|
+
...previousUpdate,
|
|
39132
|
+
...update,
|
|
39133
|
+
sessionUpdate: "tool_call_update",
|
|
39134
|
+
toolCallId: update.toolCallId
|
|
39135
|
+
};
|
|
39136
|
+
const item = new PositionedSessionEventV2({ payload: merged, type: "acp" }, position);
|
|
39137
|
+
return previousPayload?.sessionUpdate !== "tool_call_update" || previous === void 0 ? { item, kind: "append" } : {
|
|
39138
|
+
item,
|
|
39139
|
+
kind: "compact-and-append",
|
|
39140
|
+
previous: new PositionedSessionEventV2(compactedToolCallUpdate(update.toolCallId), previous.position),
|
|
39141
|
+
toolCallId: update.toolCallId
|
|
39142
|
+
};
|
|
39143
|
+
}
|
|
39144
|
+
function compactedToolCallUpdate(toolCallId) {
|
|
39145
|
+
return { payload: { sessionUpdate: "tool_call_update", toolCallId }, type: "acp" };
|
|
39146
|
+
}
|
|
39076
39147
|
function eventPage(sessionGenerationId, eventCount, eventLimit, cursor, read) {
|
|
39077
39148
|
const parsedCursor = cursor === null ? eventCount : Number(cursor);
|
|
39078
39149
|
if (!Number.isSafeInteger(parsedCursor) || parsedCursor < 0 || parsedCursor > eventCount) {
|
|
@@ -39100,18 +39171,18 @@ function pageAcpSessionEventsV2(sessionGenerationId, events, eventLimit, cursor)
|
|
|
39100
39171
|
var MemoryAcpSessionEventStoreV2 = class {
|
|
39101
39172
|
#events = /* @__PURE__ */ new Map();
|
|
39102
39173
|
#session = (sessionId) => {
|
|
39103
|
-
const session = this.#events.get(sessionId) ??
|
|
39104
|
-
hot: [],
|
|
39105
|
-
nextPosition: 1,
|
|
39106
|
-
sessionGenerationId: randomUUID2()
|
|
39107
|
-
};
|
|
39174
|
+
const session = this.#events.get(sessionId) ?? new SessionEventsV2();
|
|
39108
39175
|
this.#events.set(sessionId, session);
|
|
39109
39176
|
return session;
|
|
39110
39177
|
};
|
|
39111
39178
|
append = (sessionId, event) => {
|
|
39112
39179
|
const session = this.#session(sessionId);
|
|
39113
39180
|
const position = session.nextPosition;
|
|
39114
|
-
session
|
|
39181
|
+
const projected = projectAppend(session, event, position);
|
|
39182
|
+
if (projected.kind === "compact-and-append") {
|
|
39183
|
+
session.updateToolCallUpdate(projected.toolCallId, projected.previous);
|
|
39184
|
+
}
|
|
39185
|
+
session.append(projected.item);
|
|
39115
39186
|
session.nextPosition += 1;
|
|
39116
39187
|
return { position, sessionGenerationId: session.sessionGenerationId };
|
|
39117
39188
|
};
|
|
@@ -39130,7 +39201,7 @@ var MemoryAcpSessionEventStoreV2 = class {
|
|
|
39130
39201
|
this.#events.delete(sessionId);
|
|
39131
39202
|
};
|
|
39132
39203
|
reset = (sessionId) => {
|
|
39133
|
-
this.#events.set(sessionId,
|
|
39204
|
+
this.#events.set(sessionId, new SessionEventsV2());
|
|
39134
39205
|
};
|
|
39135
39206
|
};
|
|
39136
39207
|
var cachedEventRowSchema = external_exports.object({ eventJson: external_exports.string(), position: external_exports.number().int().positive() });
|
|
@@ -39165,11 +39236,7 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
39165
39236
|
}
|
|
39166
39237
|
}
|
|
39167
39238
|
#session = (sessionId) => {
|
|
39168
|
-
const session = this.#sessions.get(sessionId) ??
|
|
39169
|
-
hot: [],
|
|
39170
|
-
nextPosition: 1,
|
|
39171
|
-
sessionGenerationId: randomUUID2()
|
|
39172
|
-
};
|
|
39239
|
+
const session = this.#sessions.get(sessionId) ?? new SessionEventsV2();
|
|
39173
39240
|
this.#sessions.set(sessionId, session);
|
|
39174
39241
|
return session;
|
|
39175
39242
|
};
|
|
@@ -39179,7 +39246,11 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
39179
39246
|
}
|
|
39180
39247
|
const session = this.#session(sessionId);
|
|
39181
39248
|
const position = session.nextPosition;
|
|
39182
|
-
session
|
|
39249
|
+
const projected = projectAppend(session, event, position);
|
|
39250
|
+
if (projected.kind === "compact-and-append") {
|
|
39251
|
+
this.#updateToolCallUpdate(sessionId, session, projected.toolCallId, projected.previous);
|
|
39252
|
+
}
|
|
39253
|
+
session.append(projected.item);
|
|
39183
39254
|
session.nextPosition += 1;
|
|
39184
39255
|
this.#sessions.set(sessionId, session);
|
|
39185
39256
|
if (session.hot.length > HOT_EVENT_HIGH_WATER_MARK) {
|
|
@@ -39187,6 +39258,23 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
39187
39258
|
}
|
|
39188
39259
|
return { position, sessionGenerationId: session.sessionGenerationId };
|
|
39189
39260
|
};
|
|
39261
|
+
#updateToolCallUpdate = (sessionId, session, toolCallId, item) => {
|
|
39262
|
+
if (!session.updateToolCallUpdate(toolCallId, item) || !this.#isLocalDBAvailable) {
|
|
39263
|
+
return;
|
|
39264
|
+
}
|
|
39265
|
+
try {
|
|
39266
|
+
this.#database.update(sessionEventV2).set({ eventJson: JSON.stringify(item.event) }).where(
|
|
39267
|
+
and(
|
|
39268
|
+
eq(sessionEventV2.generationId, session.sessionGenerationId),
|
|
39269
|
+
eq(sessionEventV2.sessionId, sessionId),
|
|
39270
|
+
eq(sessionEventV2.position, item.position)
|
|
39271
|
+
)
|
|
39272
|
+
).run();
|
|
39273
|
+
} catch (cause) {
|
|
39274
|
+
this.#isLocalDBAvailable = false;
|
|
39275
|
+
console.warn("Mobius V2 Session event cache writes are unavailable; retaining events in memory", cause);
|
|
39276
|
+
}
|
|
39277
|
+
};
|
|
39190
39278
|
#scheduleFlush = () => {
|
|
39191
39279
|
if (!this.#isLocalDBAvailable || this.#flushSchedule.kind !== "idle") {
|
|
39192
39280
|
return;
|
|
@@ -39233,7 +39321,10 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
39233
39321
|
}
|
|
39234
39322
|
});
|
|
39235
39323
|
for (const batch of batches) {
|
|
39236
|
-
this.#sessions.get(batch.sessionId)
|
|
39324
|
+
const session = this.#sessions.get(batch.sessionId);
|
|
39325
|
+
if (session !== void 0) {
|
|
39326
|
+
session.removeHotHead(batch.count);
|
|
39327
|
+
}
|
|
39237
39328
|
}
|
|
39238
39329
|
} catch (cause) {
|
|
39239
39330
|
this.#isLocalDBAvailable = false;
|
|
@@ -39254,7 +39345,10 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
39254
39345
|
)
|
|
39255
39346
|
).orderBy(asc(sessionEventV2.position)).all().map((value) => {
|
|
39256
39347
|
const row = cachedEventRowSchema.parse(value);
|
|
39257
|
-
return
|
|
39348
|
+
return new PositionedSessionEventV2(
|
|
39349
|
+
decodeCachedEvent(JSON.parse(row.eventJson)),
|
|
39350
|
+
row.position
|
|
39351
|
+
);
|
|
39258
39352
|
});
|
|
39259
39353
|
const hot = (session?.hot ?? []).filter(
|
|
39260
39354
|
({ position }) => position >= startPosition && position <= endPosition
|
|
@@ -39288,7 +39382,7 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
39288
39382
|
reset = (sessionId) => {
|
|
39289
39383
|
const previous = this.#sessions.get(sessionId);
|
|
39290
39384
|
this.#deletePersisted(sessionId, previous?.sessionGenerationId);
|
|
39291
|
-
this.#sessions.set(sessionId,
|
|
39385
|
+
this.#sessions.set(sessionId, new SessionEventsV2());
|
|
39292
39386
|
};
|
|
39293
39387
|
close = () => {
|
|
39294
39388
|
if (this.#flushSchedule.kind === "closed") {
|
|
@@ -43223,7 +43317,7 @@ function send(socket, message) {
|
|
|
43223
43317
|
}
|
|
43224
43318
|
socket.send(encodeDaemonToServiceMessage(message));
|
|
43225
43319
|
}
|
|
43226
|
-
async function settleAbandonedTurn(
|
|
43320
|
+
async function settleAbandonedTurn(projection, operations, audit, cancellation) {
|
|
43227
43321
|
const attemptId = operations.findUnsettledAttemptId(cancellation.commandId, cancellation.sessionId);
|
|
43228
43322
|
if (attemptId === null) {
|
|
43229
43323
|
console.warn("Mobius daemon ignored cancellation for an inactive turn");
|
|
@@ -43234,14 +43328,14 @@ async function settleAbandonedTurn(eventLog, operations, audit, cancellation) {
|
|
|
43234
43328
|
event: "session_abandoned_turn_settled",
|
|
43235
43329
|
sessionId: cancellation.sessionId
|
|
43236
43330
|
});
|
|
43237
|
-
await
|
|
43331
|
+
await projection.failed(
|
|
43238
43332
|
cancellation.sessionId,
|
|
43239
43333
|
cancellation.commandId,
|
|
43240
43334
|
"agent_execution_abandoned",
|
|
43241
43335
|
"The local Agent execution was abandoned before it completed"
|
|
43242
43336
|
);
|
|
43243
43337
|
operations.transitionExecution(cancellation.commandId, "failed");
|
|
43244
|
-
|
|
43338
|
+
projection.publishTerminal(cancellation.sessionId, cancellation.commandId);
|
|
43245
43339
|
}
|
|
43246
43340
|
function operationErrorCode(error62) {
|
|
43247
43341
|
if (error62 instanceof AcpExecutionError || error62 instanceof LocalAuthorizationError || error62 instanceof LocalAgentCatalogError || error62 instanceof PromptArtifactError) {
|
|
@@ -46378,7 +46472,7 @@ function omitAgentReasoning(events) {
|
|
|
46378
46472
|
}
|
|
46379
46473
|
return retained;
|
|
46380
46474
|
}
|
|
46381
|
-
async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load,
|
|
46475
|
+
async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load, eventProjectionV2) {
|
|
46382
46476
|
let cursor = initialCursor;
|
|
46383
46477
|
let loaded = [];
|
|
46384
46478
|
let sessionGenerationId = null;
|
|
@@ -46390,7 +46484,7 @@ async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoni
|
|
|
46390
46484
|
}
|
|
46391
46485
|
sessionGenerationId = replay.sessionGenerationId;
|
|
46392
46486
|
const events2 = replay.events.map(
|
|
46393
|
-
(event, index2) =>
|
|
46487
|
+
(event, index2) => eventProjectionV2.event(
|
|
46394
46488
|
sessionId,
|
|
46395
46489
|
replay.sessionGenerationId,
|
|
46396
46490
|
replay.startPosition + index2,
|
|
@@ -46426,7 +46520,7 @@ async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoni
|
|
|
46426
46520
|
queuedPromptRequests
|
|
46427
46521
|
};
|
|
46428
46522
|
}
|
|
46429
|
-
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions,
|
|
46523
|
+
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventProjectionV2, signal) {
|
|
46430
46524
|
let agentId;
|
|
46431
46525
|
try {
|
|
46432
46526
|
const [entry] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
@@ -46448,7 +46542,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
46448
46542
|
sessionId: command.sessionId,
|
|
46449
46543
|
signal
|
|
46450
46544
|
};
|
|
46451
|
-
const recovery =
|
|
46545
|
+
const recovery = eventProjectionV2.promptRequestRecovery(command.sessionId);
|
|
46452
46546
|
const events = await loadHistoryPage(
|
|
46453
46547
|
command.sessionId,
|
|
46454
46548
|
command.eventLimit,
|
|
@@ -46456,7 +46550,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
46456
46550
|
command.omit?.includes("agent-reasoning") === true,
|
|
46457
46551
|
recovery.queuedPromptRequests,
|
|
46458
46552
|
async (eventLimit, cursor) => await sessions.loadSessionEventsV2(loadOptions, eventLimit, cursor),
|
|
46459
|
-
|
|
46553
|
+
eventProjectionV2
|
|
46460
46554
|
);
|
|
46461
46555
|
signal.throwIfAborted();
|
|
46462
46556
|
audit.record({
|
|
@@ -46495,7 +46589,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
46495
46589
|
}
|
|
46496
46590
|
}
|
|
46497
46591
|
}
|
|
46498
|
-
async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions,
|
|
46592
|
+
async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventProjectionV2, signal) {
|
|
46499
46593
|
try {
|
|
46500
46594
|
const resolved = await resolveSessionDirectories(
|
|
46501
46595
|
directories,
|
|
@@ -46518,7 +46612,7 @@ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, di
|
|
|
46518
46612
|
command.omit?.includes("agent-reasoning") === true,
|
|
46519
46613
|
[],
|
|
46520
46614
|
async (eventLimit, cursor) => await sessions.previewNativeSessionEventsV2(loadOptions, command.sessionId, eventLimit, cursor),
|
|
46521
|
-
|
|
46615
|
+
eventProjectionV2
|
|
46522
46616
|
);
|
|
46523
46617
|
signal.throwIfAborted();
|
|
46524
46618
|
audit.record({
|
|
@@ -46761,7 +46855,7 @@ function daemonActivity(command, activity2) {
|
|
|
46761
46855
|
}
|
|
46762
46856
|
async function executePrompt({
|
|
46763
46857
|
operations,
|
|
46764
|
-
|
|
46858
|
+
eventProjectionV2,
|
|
46765
46859
|
command,
|
|
46766
46860
|
config: config2,
|
|
46767
46861
|
directories,
|
|
@@ -46841,7 +46935,7 @@ async function executePrompt({
|
|
|
46841
46935
|
}
|
|
46842
46936
|
}
|
|
46843
46937
|
const stream = activateAttempt();
|
|
46844
|
-
const lifecycleV2 =
|
|
46938
|
+
const lifecycleV2 = eventProjectionV2.started(
|
|
46845
46939
|
command.sessionId,
|
|
46846
46940
|
command.commandId,
|
|
46847
46941
|
attemptId,
|
|
@@ -46896,7 +46990,7 @@ async function executePrompt({
|
|
|
46896
46990
|
});
|
|
46897
46991
|
stopReason = result.stopReason;
|
|
46898
46992
|
}
|
|
46899
|
-
await
|
|
46993
|
+
await eventProjectionV2.completed(command.sessionId, command.commandId, stopReason);
|
|
46900
46994
|
operations.transitionExecution(command.commandId, stopReason === "cancelled" ? "cancelled" : "succeeded");
|
|
46901
46995
|
audit.record({
|
|
46902
46996
|
commandId: command.commandId,
|
|
@@ -46905,7 +46999,7 @@ async function executePrompt({
|
|
|
46905
46999
|
});
|
|
46906
47000
|
} catch (error62) {
|
|
46907
47001
|
if (signal.aborted && cancellationRequested()) {
|
|
46908
|
-
await
|
|
47002
|
+
await eventProjectionV2.completed(command.sessionId, command.commandId, "cancelled");
|
|
46909
47003
|
operations.transitionExecution(command.commandId, "cancelled");
|
|
46910
47004
|
audit.record({
|
|
46911
47005
|
commandId: command.commandId,
|
|
@@ -46922,7 +47016,7 @@ async function executePrompt({
|
|
|
46922
47016
|
const code = operationErrorCode(error62);
|
|
46923
47017
|
const failureCode = code === "session_operation_failed" ? "agent_execution_failed" : code;
|
|
46924
47018
|
const failureMessage = code === "session_operation_failed" ? "The local agent could not complete the request" : operationErrorMessage(error62);
|
|
46925
|
-
await
|
|
47019
|
+
await eventProjectionV2.failed(command.sessionId, command.commandId, failureCode, failureMessage);
|
|
46926
47020
|
operations.transitionExecution(command.commandId, "failed");
|
|
46927
47021
|
console.error("Mobius daemon command failed", error62);
|
|
46928
47022
|
}
|
|
@@ -47034,7 +47128,7 @@ function createDaemonCommandHandler({
|
|
|
47034
47128
|
installations,
|
|
47035
47129
|
nativeSessions,
|
|
47036
47130
|
operations,
|
|
47037
|
-
|
|
47131
|
+
eventProjectionV2,
|
|
47038
47132
|
externalContent,
|
|
47039
47133
|
activeTurns,
|
|
47040
47134
|
diagnostics,
|
|
@@ -47054,7 +47148,7 @@ function createDaemonCommandHandler({
|
|
|
47054
47148
|
timer
|
|
47055
47149
|
});
|
|
47056
47150
|
const queueChanged = (sessionId) => {
|
|
47057
|
-
void
|
|
47151
|
+
void eventProjectionV2.queueChanged(sessionId).catch((error62) => {
|
|
47058
47152
|
console.error("Could not record queue change", error62);
|
|
47059
47153
|
});
|
|
47060
47154
|
};
|
|
@@ -47114,7 +47208,7 @@ function createDaemonCommandHandler({
|
|
|
47114
47208
|
diagnostics,
|
|
47115
47209
|
sessions,
|
|
47116
47210
|
nativeSessions,
|
|
47117
|
-
|
|
47211
|
+
eventProjectionV2,
|
|
47118
47212
|
signal
|
|
47119
47213
|
);
|
|
47120
47214
|
return;
|
|
@@ -47128,7 +47222,7 @@ function createDaemonCommandHandler({
|
|
|
47128
47222
|
audit,
|
|
47129
47223
|
diagnostics,
|
|
47130
47224
|
sessions,
|
|
47131
|
-
|
|
47225
|
+
eventProjectionV2,
|
|
47132
47226
|
signal
|
|
47133
47227
|
);
|
|
47134
47228
|
return;
|
|
@@ -47171,9 +47265,11 @@ function createDaemonCommandHandler({
|
|
|
47171
47265
|
const cancellation = message;
|
|
47172
47266
|
const turn2 = activeTurns.get(cancellation.commandId);
|
|
47173
47267
|
if (turn2 === void 0 || !turn2.matches(cancellation)) {
|
|
47174
|
-
void settleAbandonedTurn(
|
|
47175
|
-
|
|
47176
|
-
|
|
47268
|
+
void settleAbandonedTurn(eventProjectionV2, operations, audit, cancellation).catch(
|
|
47269
|
+
(error62) => {
|
|
47270
|
+
console.error("Could not settle abandoned turn", error62);
|
|
47271
|
+
}
|
|
47272
|
+
);
|
|
47177
47273
|
return;
|
|
47178
47274
|
}
|
|
47179
47275
|
const cancellationState = turn2.requestCancellation();
|
|
@@ -47332,10 +47428,10 @@ function createDaemonCommandHandler({
|
|
|
47332
47428
|
return;
|
|
47333
47429
|
}
|
|
47334
47430
|
const turn = activeTurns.start(command, receipt.attemptId);
|
|
47335
|
-
|
|
47431
|
+
eventProjectionV2.requested(command);
|
|
47336
47432
|
void executePrompt({
|
|
47337
47433
|
operations,
|
|
47338
|
-
|
|
47434
|
+
eventProjectionV2,
|
|
47339
47435
|
command,
|
|
47340
47436
|
config: config2,
|
|
47341
47437
|
directories,
|
|
@@ -47359,7 +47455,7 @@ function createDaemonCommandHandler({
|
|
|
47359
47455
|
console.error("Mobius daemon turn failed", error62);
|
|
47360
47456
|
}).finally(() => {
|
|
47361
47457
|
activeTurns.finish(turn);
|
|
47362
|
-
|
|
47458
|
+
eventProjectionV2.publishTerminal(command.sessionId, command.commandId);
|
|
47363
47459
|
if (command.disposition === SessionPromptDisposition.Queue) {
|
|
47364
47460
|
queueChanged(command.sessionId);
|
|
47365
47461
|
}
|
|
@@ -47621,7 +47717,7 @@ async function runRelayConnection({
|
|
|
47621
47717
|
nativeSessions,
|
|
47622
47718
|
operations,
|
|
47623
47719
|
publisher,
|
|
47624
|
-
|
|
47720
|
+
eventProjectionV2,
|
|
47625
47721
|
externalContent,
|
|
47626
47722
|
activeTurns,
|
|
47627
47723
|
connectionEpoch,
|
|
@@ -47643,7 +47739,7 @@ async function runRelayConnection({
|
|
|
47643
47739
|
installations,
|
|
47644
47740
|
nativeSessions,
|
|
47645
47741
|
operations,
|
|
47646
|
-
|
|
47742
|
+
eventProjectionV2,
|
|
47647
47743
|
externalContent,
|
|
47648
47744
|
activeTurns,
|
|
47649
47745
|
diagnostics,
|
|
@@ -47886,7 +47982,7 @@ var SystemDaemonTimer = class {
|
|
|
47886
47982
|
};
|
|
47887
47983
|
var systemDaemonTimer = new SystemDaemonTimer();
|
|
47888
47984
|
|
|
47889
|
-
// src/session-event-
|
|
47985
|
+
// src/session-event-projection-v2.ts
|
|
47890
47986
|
function promptContent(command) {
|
|
47891
47987
|
const content = [];
|
|
47892
47988
|
if (command.prompt.length > 0) {
|
|
@@ -47910,7 +48006,7 @@ function promptContent(command) {
|
|
|
47910
48006
|
}
|
|
47911
48007
|
return content;
|
|
47912
48008
|
}
|
|
47913
|
-
function
|
|
48009
|
+
function projectSessionEventV2(sessionGenerationId, sessionId, position, event, recordedAt) {
|
|
47914
48010
|
return {
|
|
47915
48011
|
eventId: `event-${sessionGenerationId}-${position.toString().padStart(16, "0")}`,
|
|
47916
48012
|
...event,
|
|
@@ -47921,7 +48017,7 @@ function sessionEventV22(sessionGenerationId, sessionId, position, event, record
|
|
|
47921
48017
|
sessionId
|
|
47922
48018
|
};
|
|
47923
48019
|
}
|
|
47924
|
-
var
|
|
48020
|
+
var DaemonSessionEventProjectionV2 = class {
|
|
47925
48021
|
#publisher;
|
|
47926
48022
|
#terminal = /* @__PURE__ */ new Map();
|
|
47927
48023
|
#publications = /* @__PURE__ */ new Map();
|
|
@@ -48005,7 +48101,7 @@ var DaemonSessionEventLogV2 = class {
|
|
|
48005
48101
|
}
|
|
48006
48102
|
this.#queued.delete(commandId);
|
|
48007
48103
|
};
|
|
48008
|
-
event = (sessionId, sessionGenerationId, position, event, recordedAt) =>
|
|
48104
|
+
event = (sessionId, sessionGenerationId, position, event, recordedAt) => projectSessionEventV2(sessionGenerationId, sessionId, position, event, recordedAt);
|
|
48009
48105
|
queueChanged = async (sessionId) => {
|
|
48010
48106
|
await this.#recordLifecycle(sessionId, {
|
|
48011
48107
|
type: "lifecycle-metadata",
|
|
@@ -48134,7 +48230,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
48134
48230
|
await using externalContent = new LocalExternalContentStore(stateDirectory);
|
|
48135
48231
|
const operations = new DaemonOperationState();
|
|
48136
48232
|
const publisher = new DaemonSessionEventPublisher(timer);
|
|
48137
|
-
const
|
|
48233
|
+
const eventProjectionV2 = new DaemonSessionEventProjectionV2(
|
|
48138
48234
|
publisher,
|
|
48139
48235
|
(sessionId, event) => agentRuntime.recordLifecycleEventV2(sessionId, event)
|
|
48140
48236
|
);
|
|
@@ -48145,7 +48241,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
48145
48241
|
if (event.kind === "session.info.updated") {
|
|
48146
48242
|
publisher.publishInfo(event);
|
|
48147
48243
|
}
|
|
48148
|
-
},
|
|
48244
|
+
}, eventProjectionV2.record),
|
|
48149
48245
|
sessionStore,
|
|
48150
48246
|
{
|
|
48151
48247
|
access: (options2) => options2.agent.id === "codex" ? {
|
|
@@ -48270,7 +48366,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
48270
48366
|
nativeSessions,
|
|
48271
48367
|
operations,
|
|
48272
48368
|
publisher,
|
|
48273
|
-
|
|
48369
|
+
eventProjectionV2,
|
|
48274
48370
|
externalContent,
|
|
48275
48371
|
activeTurns,
|
|
48276
48372
|
connectionEpoch,
|