@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/runtime.js
CHANGED
|
@@ -34673,6 +34673,73 @@ var sessionEventV2 = sqliteTable(
|
|
|
34673
34673
|
// src/acp/session-event-store-v2.ts
|
|
34674
34674
|
var HOT_EVENT_HIGH_WATER_MARK = 256;
|
|
34675
34675
|
var HOT_EVENT_RETENTION = 128;
|
|
34676
|
+
var PositionedSessionEventV2 = class {
|
|
34677
|
+
#event;
|
|
34678
|
+
position;
|
|
34679
|
+
constructor(event, position) {
|
|
34680
|
+
this.#event = event;
|
|
34681
|
+
this.position = position;
|
|
34682
|
+
}
|
|
34683
|
+
get event() {
|
|
34684
|
+
return this.#event;
|
|
34685
|
+
}
|
|
34686
|
+
replaceEvent = (event) => {
|
|
34687
|
+
this.#event = event;
|
|
34688
|
+
};
|
|
34689
|
+
};
|
|
34690
|
+
var SessionEventsV2 = class {
|
|
34691
|
+
hot = [];
|
|
34692
|
+
#toolCallUpdateMap = /* @__PURE__ */ new Map();
|
|
34693
|
+
sessionGenerationId;
|
|
34694
|
+
nextPosition = 1;
|
|
34695
|
+
constructor() {
|
|
34696
|
+
this.sessionGenerationId = randomUUID();
|
|
34697
|
+
}
|
|
34698
|
+
getToolCallUpdate = (toolCallId) => this.#toolCallUpdateMap.get(toolCallId);
|
|
34699
|
+
updateToolCallUpdate = (toolCallId, item) => {
|
|
34700
|
+
const current = this.#toolCallUpdateMap.get(toolCallId);
|
|
34701
|
+
if (current === void 0 || current.position !== item.position) {
|
|
34702
|
+
return false;
|
|
34703
|
+
}
|
|
34704
|
+
current.replaceEvent(item.event);
|
|
34705
|
+
return true;
|
|
34706
|
+
};
|
|
34707
|
+
append = (item) => {
|
|
34708
|
+
this.hot.push(item);
|
|
34709
|
+
const event = item.event;
|
|
34710
|
+
if (event.type === "acp" && (event.payload.sessionUpdate === "tool_call" || event.payload.sessionUpdate === "tool_call_update")) {
|
|
34711
|
+
this.#toolCallUpdateMap.set(event.payload.toolCallId, item);
|
|
34712
|
+
}
|
|
34713
|
+
};
|
|
34714
|
+
removeHotHead = (count) => {
|
|
34715
|
+
this.hot.splice(0, count);
|
|
34716
|
+
};
|
|
34717
|
+
};
|
|
34718
|
+
function projectAppend(session, event, position) {
|
|
34719
|
+
if (event.type !== "acp" || event.payload.sessionUpdate !== "tool_call_update") {
|
|
34720
|
+
return { item: new PositionedSessionEventV2(event, position), kind: "append" };
|
|
34721
|
+
}
|
|
34722
|
+
const update = event.payload;
|
|
34723
|
+
const previous = session.getToolCallUpdate(update.toolCallId);
|
|
34724
|
+
const previousPayload = previous?.event.type === "acp" ? previous.event.payload : void 0;
|
|
34725
|
+
const previousUpdate = previousPayload?.sessionUpdate === "tool_call" || previousPayload?.sessionUpdate === "tool_call_update" ? previousPayload : void 0;
|
|
34726
|
+
const merged = {
|
|
34727
|
+
...previousUpdate,
|
|
34728
|
+
...update,
|
|
34729
|
+
sessionUpdate: "tool_call_update",
|
|
34730
|
+
toolCallId: update.toolCallId
|
|
34731
|
+
};
|
|
34732
|
+
const item = new PositionedSessionEventV2({ payload: merged, type: "acp" }, position);
|
|
34733
|
+
return previousPayload?.sessionUpdate !== "tool_call_update" || previous === void 0 ? { item, kind: "append" } : {
|
|
34734
|
+
item,
|
|
34735
|
+
kind: "compact-and-append",
|
|
34736
|
+
previous: new PositionedSessionEventV2(compactedToolCallUpdate(update.toolCallId), previous.position),
|
|
34737
|
+
toolCallId: update.toolCallId
|
|
34738
|
+
};
|
|
34739
|
+
}
|
|
34740
|
+
function compactedToolCallUpdate(toolCallId) {
|
|
34741
|
+
return { payload: { sessionUpdate: "tool_call_update", toolCallId }, type: "acp" };
|
|
34742
|
+
}
|
|
34676
34743
|
function eventPage(sessionGenerationId, eventCount, eventLimit, cursor, read) {
|
|
34677
34744
|
const parsedCursor = cursor === null ? eventCount : Number(cursor);
|
|
34678
34745
|
if (!Number.isSafeInteger(parsedCursor) || parsedCursor < 0 || parsedCursor > eventCount) {
|
|
@@ -34700,18 +34767,18 @@ function pageAcpSessionEventsV2(sessionGenerationId, events, eventLimit, cursor)
|
|
|
34700
34767
|
var MemoryAcpSessionEventStoreV2 = class {
|
|
34701
34768
|
#events = /* @__PURE__ */ new Map();
|
|
34702
34769
|
#session = (sessionId) => {
|
|
34703
|
-
const session = this.#events.get(sessionId) ??
|
|
34704
|
-
hot: [],
|
|
34705
|
-
nextPosition: 1,
|
|
34706
|
-
sessionGenerationId: randomUUID()
|
|
34707
|
-
};
|
|
34770
|
+
const session = this.#events.get(sessionId) ?? new SessionEventsV2();
|
|
34708
34771
|
this.#events.set(sessionId, session);
|
|
34709
34772
|
return session;
|
|
34710
34773
|
};
|
|
34711
34774
|
append = (sessionId, event) => {
|
|
34712
34775
|
const session = this.#session(sessionId);
|
|
34713
34776
|
const position = session.nextPosition;
|
|
34714
|
-
session
|
|
34777
|
+
const projected = projectAppend(session, event, position);
|
|
34778
|
+
if (projected.kind === "compact-and-append") {
|
|
34779
|
+
session.updateToolCallUpdate(projected.toolCallId, projected.previous);
|
|
34780
|
+
}
|
|
34781
|
+
session.append(projected.item);
|
|
34715
34782
|
session.nextPosition += 1;
|
|
34716
34783
|
return { position, sessionGenerationId: session.sessionGenerationId };
|
|
34717
34784
|
};
|
|
@@ -34730,7 +34797,7 @@ var MemoryAcpSessionEventStoreV2 = class {
|
|
|
34730
34797
|
this.#events.delete(sessionId);
|
|
34731
34798
|
};
|
|
34732
34799
|
reset = (sessionId) => {
|
|
34733
|
-
this.#events.set(sessionId,
|
|
34800
|
+
this.#events.set(sessionId, new SessionEventsV2());
|
|
34734
34801
|
};
|
|
34735
34802
|
};
|
|
34736
34803
|
var cachedEventRowSchema = external_exports.object({ eventJson: external_exports.string(), position: external_exports.number().int().positive() });
|
|
@@ -34765,11 +34832,7 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
34765
34832
|
}
|
|
34766
34833
|
}
|
|
34767
34834
|
#session = (sessionId) => {
|
|
34768
|
-
const session = this.#sessions.get(sessionId) ??
|
|
34769
|
-
hot: [],
|
|
34770
|
-
nextPosition: 1,
|
|
34771
|
-
sessionGenerationId: randomUUID()
|
|
34772
|
-
};
|
|
34835
|
+
const session = this.#sessions.get(sessionId) ?? new SessionEventsV2();
|
|
34773
34836
|
this.#sessions.set(sessionId, session);
|
|
34774
34837
|
return session;
|
|
34775
34838
|
};
|
|
@@ -34779,7 +34842,11 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
34779
34842
|
}
|
|
34780
34843
|
const session = this.#session(sessionId);
|
|
34781
34844
|
const position = session.nextPosition;
|
|
34782
|
-
session
|
|
34845
|
+
const projected = projectAppend(session, event, position);
|
|
34846
|
+
if (projected.kind === "compact-and-append") {
|
|
34847
|
+
this.#updateToolCallUpdate(sessionId, session, projected.toolCallId, projected.previous);
|
|
34848
|
+
}
|
|
34849
|
+
session.append(projected.item);
|
|
34783
34850
|
session.nextPosition += 1;
|
|
34784
34851
|
this.#sessions.set(sessionId, session);
|
|
34785
34852
|
if (session.hot.length > HOT_EVENT_HIGH_WATER_MARK) {
|
|
@@ -34787,6 +34854,23 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
34787
34854
|
}
|
|
34788
34855
|
return { position, sessionGenerationId: session.sessionGenerationId };
|
|
34789
34856
|
};
|
|
34857
|
+
#updateToolCallUpdate = (sessionId, session, toolCallId, item) => {
|
|
34858
|
+
if (!session.updateToolCallUpdate(toolCallId, item) || !this.#isLocalDBAvailable) {
|
|
34859
|
+
return;
|
|
34860
|
+
}
|
|
34861
|
+
try {
|
|
34862
|
+
this.#database.update(sessionEventV2).set({ eventJson: JSON.stringify(item.event) }).where(
|
|
34863
|
+
and(
|
|
34864
|
+
eq(sessionEventV2.generationId, session.sessionGenerationId),
|
|
34865
|
+
eq(sessionEventV2.sessionId, sessionId),
|
|
34866
|
+
eq(sessionEventV2.position, item.position)
|
|
34867
|
+
)
|
|
34868
|
+
).run();
|
|
34869
|
+
} catch (cause) {
|
|
34870
|
+
this.#isLocalDBAvailable = false;
|
|
34871
|
+
console.warn("Mobius V2 Session event cache writes are unavailable; retaining events in memory", cause);
|
|
34872
|
+
}
|
|
34873
|
+
};
|
|
34790
34874
|
#scheduleFlush = () => {
|
|
34791
34875
|
if (!this.#isLocalDBAvailable || this.#flushSchedule.kind !== "idle") {
|
|
34792
34876
|
return;
|
|
@@ -34833,7 +34917,10 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
34833
34917
|
}
|
|
34834
34918
|
});
|
|
34835
34919
|
for (const batch of batches) {
|
|
34836
|
-
this.#sessions.get(batch.sessionId)
|
|
34920
|
+
const session = this.#sessions.get(batch.sessionId);
|
|
34921
|
+
if (session !== void 0) {
|
|
34922
|
+
session.removeHotHead(batch.count);
|
|
34923
|
+
}
|
|
34837
34924
|
}
|
|
34838
34925
|
} catch (cause) {
|
|
34839
34926
|
this.#isLocalDBAvailable = false;
|
|
@@ -34854,7 +34941,10 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
34854
34941
|
)
|
|
34855
34942
|
).orderBy(asc(sessionEventV2.position)).all().map((value) => {
|
|
34856
34943
|
const row = cachedEventRowSchema.parse(value);
|
|
34857
|
-
return
|
|
34944
|
+
return new PositionedSessionEventV2(
|
|
34945
|
+
decodeCachedEvent(JSON.parse(row.eventJson)),
|
|
34946
|
+
row.position
|
|
34947
|
+
);
|
|
34858
34948
|
});
|
|
34859
34949
|
const hot = (session?.hot ?? []).filter(
|
|
34860
34950
|
({ position }) => position >= startPosition && position <= endPosition
|
|
@@ -34888,7 +34978,7 @@ var CachedAcpSessionEventStoreV2 = class {
|
|
|
34888
34978
|
reset = (sessionId) => {
|
|
34889
34979
|
const previous = this.#sessions.get(sessionId);
|
|
34890
34980
|
this.#deletePersisted(sessionId, previous?.sessionGenerationId);
|
|
34891
|
-
this.#sessions.set(sessionId,
|
|
34981
|
+
this.#sessions.set(sessionId, new SessionEventsV2());
|
|
34892
34982
|
};
|
|
34893
34983
|
close = () => {
|
|
34894
34984
|
if (this.#flushSchedule.kind === "closed") {
|
|
@@ -38823,7 +38913,7 @@ function send(socket, message) {
|
|
|
38823
38913
|
}
|
|
38824
38914
|
socket.send(encodeDaemonToServiceMessage(message));
|
|
38825
38915
|
}
|
|
38826
|
-
async function settleAbandonedTurn(
|
|
38916
|
+
async function settleAbandonedTurn(projection, operations, audit, cancellation) {
|
|
38827
38917
|
const attemptId = operations.findUnsettledAttemptId(cancellation.commandId, cancellation.sessionId);
|
|
38828
38918
|
if (attemptId === null) {
|
|
38829
38919
|
console.warn("Mobius daemon ignored cancellation for an inactive turn");
|
|
@@ -38834,14 +38924,14 @@ async function settleAbandonedTurn(eventLog, operations, audit, cancellation) {
|
|
|
38834
38924
|
event: "session_abandoned_turn_settled",
|
|
38835
38925
|
sessionId: cancellation.sessionId
|
|
38836
38926
|
});
|
|
38837
|
-
await
|
|
38927
|
+
await projection.failed(
|
|
38838
38928
|
cancellation.sessionId,
|
|
38839
38929
|
cancellation.commandId,
|
|
38840
38930
|
"agent_execution_abandoned",
|
|
38841
38931
|
"The local Agent execution was abandoned before it completed"
|
|
38842
38932
|
);
|
|
38843
38933
|
operations.transitionExecution(cancellation.commandId, "failed");
|
|
38844
|
-
|
|
38934
|
+
projection.publishTerminal(cancellation.sessionId, cancellation.commandId);
|
|
38845
38935
|
}
|
|
38846
38936
|
function operationErrorCode(error62) {
|
|
38847
38937
|
if (error62 instanceof AcpExecutionError || error62 instanceof LocalAuthorizationError || error62 instanceof LocalAgentCatalogError || error62 instanceof PromptArtifactError) {
|
|
@@ -40991,7 +41081,7 @@ import { WebSocket as WebSocket5 } from "undici";
|
|
|
40991
41081
|
// package.json
|
|
40992
41082
|
var package_default = {
|
|
40993
41083
|
name: "@moxt-ai/mobius",
|
|
40994
|
-
version: "0.0.
|
|
41084
|
+
version: "0.0.198",
|
|
40995
41085
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
40996
41086
|
type: "module",
|
|
40997
41087
|
bin: {
|
|
@@ -41016,19 +41106,23 @@ var package_default = {
|
|
|
41016
41106
|
exports: {
|
|
41017
41107
|
".": {
|
|
41018
41108
|
types: "./dist/index.d.ts",
|
|
41019
|
-
import: "./dist/index.js"
|
|
41109
|
+
import: "./dist/index.js",
|
|
41110
|
+
default: "./dist/index.js"
|
|
41020
41111
|
},
|
|
41021
41112
|
"./runtime": {
|
|
41022
41113
|
types: "./dist/runtime.d.ts",
|
|
41023
|
-
import: "./dist/runtime.js"
|
|
41114
|
+
import: "./dist/runtime.js",
|
|
41115
|
+
default: "./dist/runtime.js"
|
|
41024
41116
|
},
|
|
41025
41117
|
"./process": {
|
|
41026
41118
|
types: "./dist/process/executable.d.ts",
|
|
41027
|
-
import: "./dist/process/executable.js"
|
|
41119
|
+
import: "./dist/process/executable.js",
|
|
41120
|
+
default: "./dist/process/executable.js"
|
|
41028
41121
|
},
|
|
41029
41122
|
"./filesystem": {
|
|
41030
41123
|
types: "./dist/filesystem/private-path.d.ts",
|
|
41031
|
-
import: "./dist/filesystem/private-path.js"
|
|
41124
|
+
import: "./dist/filesystem/private-path.js",
|
|
41125
|
+
default: "./dist/filesystem/private-path.js"
|
|
41032
41126
|
}
|
|
41033
41127
|
}
|
|
41034
41128
|
},
|
|
@@ -42064,7 +42158,7 @@ function omitAgentReasoning(events) {
|
|
|
42064
42158
|
}
|
|
42065
42159
|
return retained;
|
|
42066
42160
|
}
|
|
42067
|
-
async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load,
|
|
42161
|
+
async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load, eventProjectionV2) {
|
|
42068
42162
|
let cursor = initialCursor;
|
|
42069
42163
|
let loaded = [];
|
|
42070
42164
|
let sessionGenerationId = null;
|
|
@@ -42076,7 +42170,7 @@ async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoni
|
|
|
42076
42170
|
}
|
|
42077
42171
|
sessionGenerationId = replay.sessionGenerationId;
|
|
42078
42172
|
const events2 = replay.events.map(
|
|
42079
|
-
(event, index2) =>
|
|
42173
|
+
(event, index2) => eventProjectionV2.event(
|
|
42080
42174
|
sessionId,
|
|
42081
42175
|
replay.sessionGenerationId,
|
|
42082
42176
|
replay.startPosition + index2,
|
|
@@ -42112,7 +42206,7 @@ async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoni
|
|
|
42112
42206
|
queuedPromptRequests
|
|
42113
42207
|
};
|
|
42114
42208
|
}
|
|
42115
|
-
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions,
|
|
42209
|
+
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventProjectionV2, signal) {
|
|
42116
42210
|
let agentId;
|
|
42117
42211
|
try {
|
|
42118
42212
|
const [entry] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
@@ -42134,7 +42228,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
42134
42228
|
sessionId: command.sessionId,
|
|
42135
42229
|
signal
|
|
42136
42230
|
};
|
|
42137
|
-
const recovery =
|
|
42231
|
+
const recovery = eventProjectionV2.promptRequestRecovery(command.sessionId);
|
|
42138
42232
|
const events = await loadHistoryPage(
|
|
42139
42233
|
command.sessionId,
|
|
42140
42234
|
command.eventLimit,
|
|
@@ -42142,7 +42236,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
42142
42236
|
command.omit?.includes("agent-reasoning") === true,
|
|
42143
42237
|
recovery.queuedPromptRequests,
|
|
42144
42238
|
async (eventLimit, cursor) => await sessions.loadSessionEventsV2(loadOptions, eventLimit, cursor),
|
|
42145
|
-
|
|
42239
|
+
eventProjectionV2
|
|
42146
42240
|
);
|
|
42147
42241
|
signal.throwIfAborted();
|
|
42148
42242
|
audit.record({
|
|
@@ -42181,7 +42275,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
42181
42275
|
}
|
|
42182
42276
|
}
|
|
42183
42277
|
}
|
|
42184
|
-
async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions,
|
|
42278
|
+
async function executeSessionPreviewHistoryPageLoad(socket, command, config2, directories, audit, diagnostics, sessions, eventProjectionV2, signal) {
|
|
42185
42279
|
try {
|
|
42186
42280
|
const resolved = await resolveSessionDirectories(
|
|
42187
42281
|
directories,
|
|
@@ -42204,7 +42298,7 @@ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, di
|
|
|
42204
42298
|
command.omit?.includes("agent-reasoning") === true,
|
|
42205
42299
|
[],
|
|
42206
42300
|
async (eventLimit, cursor) => await sessions.previewNativeSessionEventsV2(loadOptions, command.sessionId, eventLimit, cursor),
|
|
42207
|
-
|
|
42301
|
+
eventProjectionV2
|
|
42208
42302
|
);
|
|
42209
42303
|
signal.throwIfAborted();
|
|
42210
42304
|
audit.record({
|
|
@@ -42447,7 +42541,7 @@ function daemonActivity(command, activity2) {
|
|
|
42447
42541
|
}
|
|
42448
42542
|
async function executePrompt({
|
|
42449
42543
|
operations,
|
|
42450
|
-
|
|
42544
|
+
eventProjectionV2,
|
|
42451
42545
|
command,
|
|
42452
42546
|
config: config2,
|
|
42453
42547
|
directories,
|
|
@@ -42527,7 +42621,7 @@ async function executePrompt({
|
|
|
42527
42621
|
}
|
|
42528
42622
|
}
|
|
42529
42623
|
const stream = activateAttempt();
|
|
42530
|
-
const lifecycleV2 =
|
|
42624
|
+
const lifecycleV2 = eventProjectionV2.started(
|
|
42531
42625
|
command.sessionId,
|
|
42532
42626
|
command.commandId,
|
|
42533
42627
|
attemptId,
|
|
@@ -42582,7 +42676,7 @@ async function executePrompt({
|
|
|
42582
42676
|
});
|
|
42583
42677
|
stopReason = result.stopReason;
|
|
42584
42678
|
}
|
|
42585
|
-
await
|
|
42679
|
+
await eventProjectionV2.completed(command.sessionId, command.commandId, stopReason);
|
|
42586
42680
|
operations.transitionExecution(command.commandId, stopReason === "cancelled" ? "cancelled" : "succeeded");
|
|
42587
42681
|
audit.record({
|
|
42588
42682
|
commandId: command.commandId,
|
|
@@ -42591,7 +42685,7 @@ async function executePrompt({
|
|
|
42591
42685
|
});
|
|
42592
42686
|
} catch (error62) {
|
|
42593
42687
|
if (signal.aborted && cancellationRequested()) {
|
|
42594
|
-
await
|
|
42688
|
+
await eventProjectionV2.completed(command.sessionId, command.commandId, "cancelled");
|
|
42595
42689
|
operations.transitionExecution(command.commandId, "cancelled");
|
|
42596
42690
|
audit.record({
|
|
42597
42691
|
commandId: command.commandId,
|
|
@@ -42608,7 +42702,7 @@ async function executePrompt({
|
|
|
42608
42702
|
const code = operationErrorCode(error62);
|
|
42609
42703
|
const failureCode = code === "session_operation_failed" ? "agent_execution_failed" : code;
|
|
42610
42704
|
const failureMessage = code === "session_operation_failed" ? "The local agent could not complete the request" : operationErrorMessage(error62);
|
|
42611
|
-
await
|
|
42705
|
+
await eventProjectionV2.failed(command.sessionId, command.commandId, failureCode, failureMessage);
|
|
42612
42706
|
operations.transitionExecution(command.commandId, "failed");
|
|
42613
42707
|
console.error("Mobius daemon command failed", error62);
|
|
42614
42708
|
}
|
|
@@ -42720,7 +42814,7 @@ function createDaemonCommandHandler({
|
|
|
42720
42814
|
installations,
|
|
42721
42815
|
nativeSessions,
|
|
42722
42816
|
operations,
|
|
42723
|
-
|
|
42817
|
+
eventProjectionV2,
|
|
42724
42818
|
externalContent,
|
|
42725
42819
|
activeTurns,
|
|
42726
42820
|
diagnostics,
|
|
@@ -42740,7 +42834,7 @@ function createDaemonCommandHandler({
|
|
|
42740
42834
|
timer
|
|
42741
42835
|
});
|
|
42742
42836
|
const queueChanged = (sessionId) => {
|
|
42743
|
-
void
|
|
42837
|
+
void eventProjectionV2.queueChanged(sessionId).catch((error62) => {
|
|
42744
42838
|
console.error("Could not record queue change", error62);
|
|
42745
42839
|
});
|
|
42746
42840
|
};
|
|
@@ -42800,7 +42894,7 @@ function createDaemonCommandHandler({
|
|
|
42800
42894
|
diagnostics,
|
|
42801
42895
|
sessions,
|
|
42802
42896
|
nativeSessions,
|
|
42803
|
-
|
|
42897
|
+
eventProjectionV2,
|
|
42804
42898
|
signal
|
|
42805
42899
|
);
|
|
42806
42900
|
return;
|
|
@@ -42814,7 +42908,7 @@ function createDaemonCommandHandler({
|
|
|
42814
42908
|
audit,
|
|
42815
42909
|
diagnostics,
|
|
42816
42910
|
sessions,
|
|
42817
|
-
|
|
42911
|
+
eventProjectionV2,
|
|
42818
42912
|
signal
|
|
42819
42913
|
);
|
|
42820
42914
|
return;
|
|
@@ -42857,9 +42951,11 @@ function createDaemonCommandHandler({
|
|
|
42857
42951
|
const cancellation = message;
|
|
42858
42952
|
const turn2 = activeTurns.get(cancellation.commandId);
|
|
42859
42953
|
if (turn2 === void 0 || !turn2.matches(cancellation)) {
|
|
42860
|
-
void settleAbandonedTurn(
|
|
42861
|
-
|
|
42862
|
-
|
|
42954
|
+
void settleAbandonedTurn(eventProjectionV2, operations, audit, cancellation).catch(
|
|
42955
|
+
(error62) => {
|
|
42956
|
+
console.error("Could not settle abandoned turn", error62);
|
|
42957
|
+
}
|
|
42958
|
+
);
|
|
42863
42959
|
return;
|
|
42864
42960
|
}
|
|
42865
42961
|
const cancellationState = turn2.requestCancellation();
|
|
@@ -43018,10 +43114,10 @@ function createDaemonCommandHandler({
|
|
|
43018
43114
|
return;
|
|
43019
43115
|
}
|
|
43020
43116
|
const turn = activeTurns.start(command, receipt.attemptId);
|
|
43021
|
-
|
|
43117
|
+
eventProjectionV2.requested(command);
|
|
43022
43118
|
void executePrompt({
|
|
43023
43119
|
operations,
|
|
43024
|
-
|
|
43120
|
+
eventProjectionV2,
|
|
43025
43121
|
command,
|
|
43026
43122
|
config: config2,
|
|
43027
43123
|
directories,
|
|
@@ -43045,7 +43141,7 @@ function createDaemonCommandHandler({
|
|
|
43045
43141
|
console.error("Mobius daemon turn failed", error62);
|
|
43046
43142
|
}).finally(() => {
|
|
43047
43143
|
activeTurns.finish(turn);
|
|
43048
|
-
|
|
43144
|
+
eventProjectionV2.publishTerminal(command.sessionId, command.commandId);
|
|
43049
43145
|
if (command.disposition === SessionPromptDisposition.Queue) {
|
|
43050
43146
|
queueChanged(command.sessionId);
|
|
43051
43147
|
}
|
|
@@ -43307,7 +43403,7 @@ async function runRelayConnection({
|
|
|
43307
43403
|
nativeSessions,
|
|
43308
43404
|
operations,
|
|
43309
43405
|
publisher,
|
|
43310
|
-
|
|
43406
|
+
eventProjectionV2,
|
|
43311
43407
|
externalContent,
|
|
43312
43408
|
activeTurns,
|
|
43313
43409
|
connectionEpoch,
|
|
@@ -43329,7 +43425,7 @@ async function runRelayConnection({
|
|
|
43329
43425
|
installations,
|
|
43330
43426
|
nativeSessions,
|
|
43331
43427
|
operations,
|
|
43332
|
-
|
|
43428
|
+
eventProjectionV2,
|
|
43333
43429
|
externalContent,
|
|
43334
43430
|
activeTurns,
|
|
43335
43431
|
diagnostics,
|
|
@@ -43572,7 +43668,7 @@ var SystemDaemonTimer = class {
|
|
|
43572
43668
|
};
|
|
43573
43669
|
var systemDaemonTimer = new SystemDaemonTimer();
|
|
43574
43670
|
|
|
43575
|
-
// src/session-event-
|
|
43671
|
+
// src/session-event-projection-v2.ts
|
|
43576
43672
|
function promptContent(command) {
|
|
43577
43673
|
const content = [];
|
|
43578
43674
|
if (command.prompt.length > 0) {
|
|
@@ -43596,7 +43692,7 @@ function promptContent(command) {
|
|
|
43596
43692
|
}
|
|
43597
43693
|
return content;
|
|
43598
43694
|
}
|
|
43599
|
-
function
|
|
43695
|
+
function projectSessionEventV2(sessionGenerationId, sessionId, position, event, recordedAt) {
|
|
43600
43696
|
return {
|
|
43601
43697
|
eventId: `event-${sessionGenerationId}-${position.toString().padStart(16, "0")}`,
|
|
43602
43698
|
...event,
|
|
@@ -43607,7 +43703,7 @@ function sessionEventV22(sessionGenerationId, sessionId, position, event, record
|
|
|
43607
43703
|
sessionId
|
|
43608
43704
|
};
|
|
43609
43705
|
}
|
|
43610
|
-
var
|
|
43706
|
+
var DaemonSessionEventProjectionV2 = class {
|
|
43611
43707
|
#publisher;
|
|
43612
43708
|
#terminal = /* @__PURE__ */ new Map();
|
|
43613
43709
|
#publications = /* @__PURE__ */ new Map();
|
|
@@ -43691,7 +43787,7 @@ var DaemonSessionEventLogV2 = class {
|
|
|
43691
43787
|
}
|
|
43692
43788
|
this.#queued.delete(commandId);
|
|
43693
43789
|
};
|
|
43694
|
-
event = (sessionId, sessionGenerationId, position, event, recordedAt) =>
|
|
43790
|
+
event = (sessionId, sessionGenerationId, position, event, recordedAt) => projectSessionEventV2(sessionGenerationId, sessionId, position, event, recordedAt);
|
|
43695
43791
|
queueChanged = async (sessionId) => {
|
|
43696
43792
|
await this.#recordLifecycle(sessionId, {
|
|
43697
43793
|
type: "lifecycle-metadata",
|
|
@@ -43820,7 +43916,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43820
43916
|
await using externalContent = new LocalExternalContentStore(stateDirectory);
|
|
43821
43917
|
const operations = new DaemonOperationState();
|
|
43822
43918
|
const publisher = new DaemonSessionEventPublisher(timer);
|
|
43823
|
-
const
|
|
43919
|
+
const eventProjectionV2 = new DaemonSessionEventProjectionV2(
|
|
43824
43920
|
publisher,
|
|
43825
43921
|
(sessionId, event) => agentRuntime.recordLifecycleEventV2(sessionId, event)
|
|
43826
43922
|
);
|
|
@@ -43831,7 +43927,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43831
43927
|
if (event.kind === "session.info.updated") {
|
|
43832
43928
|
publisher.publishInfo(event);
|
|
43833
43929
|
}
|
|
43834
|
-
},
|
|
43930
|
+
}, eventProjectionV2.record),
|
|
43835
43931
|
sessionStore,
|
|
43836
43932
|
{
|
|
43837
43933
|
access: (options2) => options2.agent.id === "codex" ? {
|
|
@@ -43956,7 +44052,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43956
44052
|
nativeSessions,
|
|
43957
44053
|
operations,
|
|
43958
44054
|
publisher,
|
|
43959
|
-
|
|
44055
|
+
eventProjectionV2,
|
|
43960
44056
|
externalContent,
|
|
43961
44057
|
activeTurns,
|
|
43962
44058
|
connectionEpoch,
|