@moxt-ai/mobius 0.0.161 → 0.0.163
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/authorization/workspace-directory.d.ts.map +1 -1
- package/dist/authorization/workspace-directory.js +9 -2
- package/dist/authorization/workspace-directory.js.map +1 -1
- package/dist/cli.js +27 -69
- package/dist/cli.js.map +3 -3
- package/dist/index.js +26 -68
- package/dist/index.js.map +3 -3
- package/dist/relay-connection/session-event-publisher.d.ts +6 -1
- package/dist/relay-connection/session-event-publisher.d.ts.map +1 -1
- package/dist/relay-connection/session-event-publisher.js +6 -1
- package/dist/relay-connection/session-event-publisher.js.map +1 -1
- package/dist/run-daemon.js +1 -1
- package/dist/run-daemon.js.map +1 -1
- package/dist/runtime.js +26 -68
- package/dist/runtime.js.map +3 -3
- package/dist/session-event-log-v2.d.ts.map +1 -1
- package/dist/session-event-log-v2.js +14 -61
- package/dist/session-event-log-v2.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38867,13 +38867,17 @@ function encodePath(path2) {
|
|
|
38867
38867
|
}
|
|
38868
38868
|
return `path-${encoded}`;
|
|
38869
38869
|
}
|
|
38870
|
+
function expandCurrentUserHome(path2) {
|
|
38871
|
+
return path2.replace(/^~(?=$|\/|\\)/, homedir2());
|
|
38872
|
+
}
|
|
38870
38873
|
function decodePath(value, prefix) {
|
|
38871
38874
|
const encoded = value.slice(prefix.length);
|
|
38872
38875
|
if (encoded.length === 0 || encoded.length > 2e3 || !/^[a-zA-Z0-9_-]+$/.test(encoded)) {
|
|
38873
38876
|
throw new LocalAuthorizationError("The directory identifier is invalid");
|
|
38874
38877
|
}
|
|
38875
38878
|
const decoded = Buffer.from(encoded, "base64url").toString("utf8");
|
|
38876
|
-
|
|
38879
|
+
const normalized = process.platform === "win32" && decoded.startsWith("~/") ? normalize3(decoded).replaceAll("\\", "/") : normalize3(decoded);
|
|
38880
|
+
if (Buffer.from(decoded, "utf8").toString("base64url") !== encoded || decoded.includes("\0") || normalized !== decoded) {
|
|
38877
38881
|
throw new LocalAuthorizationError("The directory identifier is invalid");
|
|
38878
38882
|
}
|
|
38879
38883
|
return decoded;
|
|
@@ -38898,7 +38902,7 @@ var WorkspaceDirectoryService = class {
|
|
|
38898
38902
|
return homedir2();
|
|
38899
38903
|
}
|
|
38900
38904
|
if (id.startsWith("path-")) {
|
|
38901
|
-
const path2 = decodePath(id, "path-");
|
|
38905
|
+
const path2 = expandCurrentUserHome(decodePath(id, "path-"));
|
|
38902
38906
|
if (isAbsolute9(path2)) {
|
|
38903
38907
|
return path2;
|
|
38904
38908
|
}
|
|
@@ -44253,6 +44257,10 @@ import { WebSocket as WebSocket9 } from "undici";
|
|
|
44253
44257
|
var MAX_BUFFERED_BYTES = 32 * 1024 * 1024;
|
|
44254
44258
|
var DaemonSessionEventPublisher = class {
|
|
44255
44259
|
#socket = null;
|
|
44260
|
+
#store;
|
|
44261
|
+
constructor(store) {
|
|
44262
|
+
this.#store = store;
|
|
44263
|
+
}
|
|
44256
44264
|
connect = (socket) => {
|
|
44257
44265
|
this.#socket = socket;
|
|
44258
44266
|
};
|
|
@@ -44289,6 +44297,7 @@ var DaemonSessionEventPublisher = class {
|
|
|
44289
44297
|
}
|
|
44290
44298
|
};
|
|
44291
44299
|
publishV2 = (event) => {
|
|
44300
|
+
this.#store.appendExecutingPromptEventV2(event);
|
|
44292
44301
|
const socket = this.#socket;
|
|
44293
44302
|
if (socket === null || socket.readyState !== WebSocket9.OPEN) {
|
|
44294
44303
|
return;
|
|
@@ -44316,15 +44325,6 @@ var systemDaemonTimer = new SystemDaemonTimer();
|
|
|
44316
44325
|
|
|
44317
44326
|
// src/session-event-log-v2.ts
|
|
44318
44327
|
var EXECUTING_PROMPT_EVENT_LIMIT = 1e4;
|
|
44319
|
-
function eventArray(tail) {
|
|
44320
|
-
const reversed = [];
|
|
44321
|
-
let node2 = tail;
|
|
44322
|
-
while (node2 !== null) {
|
|
44323
|
-
reversed.push(node2.event);
|
|
44324
|
-
node2 = node2.previous;
|
|
44325
|
-
}
|
|
44326
|
-
return reversed.reverse();
|
|
44327
|
-
}
|
|
44328
44328
|
function promptContent(command) {
|
|
44329
44329
|
const content = [];
|
|
44330
44330
|
if (command.prompt.length > 0) {
|
|
@@ -44372,37 +44372,18 @@ var DaemonSessionEventLogV2 = class {
|
|
|
44372
44372
|
}
|
|
44373
44373
|
for (const event of this.#loadStoredEvents(sessionId)) {
|
|
44374
44374
|
if (event.type === "acp") {
|
|
44375
|
-
const executing = [...this.#requests.values()].find(
|
|
44376
|
-
(request) => request.sessionId === sessionId && request.kind === "executing"
|
|
44377
|
-
);
|
|
44378
|
-
if (executing !== void 0) {
|
|
44379
|
-
this.#requests.set(executing.commandId, {
|
|
44380
|
-
...executing,
|
|
44381
|
-
eventTail: { event, previous: executing.eventTail }
|
|
44382
|
-
});
|
|
44383
|
-
}
|
|
44384
44375
|
continue;
|
|
44385
44376
|
}
|
|
44386
44377
|
const payload = event.payload;
|
|
44387
44378
|
if (payload.kind === "prompt.requested") {
|
|
44388
44379
|
this.#requests.set(payload.commandId, {
|
|
44389
44380
|
commandId: payload.commandId,
|
|
44390
|
-
eventTail: { event, previous: null },
|
|
44391
44381
|
kind: "requested",
|
|
44392
44382
|
sessionId
|
|
44393
44383
|
});
|
|
44394
44384
|
continue;
|
|
44395
44385
|
}
|
|
44396
44386
|
if ("event" in payload) {
|
|
44397
|
-
const executing = [...this.#requests.values()].find(
|
|
44398
|
-
(request) => request.sessionId === sessionId && request.kind === "executing"
|
|
44399
|
-
);
|
|
44400
|
-
if (executing !== void 0) {
|
|
44401
|
-
this.#requests.set(executing.commandId, {
|
|
44402
|
-
...executing,
|
|
44403
|
-
eventTail: { event, previous: executing.eventTail }
|
|
44404
|
-
});
|
|
44405
|
-
}
|
|
44406
44387
|
continue;
|
|
44407
44388
|
}
|
|
44408
44389
|
if (!("commandId" in payload)) {
|
|
@@ -44417,7 +44398,6 @@ var DaemonSessionEventLogV2 = class {
|
|
|
44417
44398
|
attemptId: payload.attemptId,
|
|
44418
44399
|
commandId: payload.commandId,
|
|
44419
44400
|
epoch: payload.epoch,
|
|
44420
|
-
eventTail: { event, previous: state.eventTail },
|
|
44421
44401
|
kind: "executing",
|
|
44422
44402
|
sessionId
|
|
44423
44403
|
});
|
|
@@ -44438,19 +44418,18 @@ var DaemonSessionEventLogV2 = class {
|
|
|
44438
44418
|
recordedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
44439
44419
|
sessionId
|
|
44440
44420
|
};
|
|
44441
|
-
this.#positions.set(sessionId, position);
|
|
44442
44421
|
this.#publisher.publishV2(event);
|
|
44422
|
+
this.#positions.set(sessionId, position);
|
|
44443
44423
|
return event;
|
|
44444
44424
|
};
|
|
44445
44425
|
requested = (command) => {
|
|
44446
44426
|
const content = promptContent(command);
|
|
44447
|
-
|
|
44427
|
+
this.#append(command.sessionId, {
|
|
44448
44428
|
payload: { commandId: command.commandId, content, kind: "prompt.requested" },
|
|
44449
44429
|
type: "lifecycle-metadata"
|
|
44450
44430
|
});
|
|
44451
44431
|
this.#requests.set(command.commandId, {
|
|
44452
44432
|
commandId: command.commandId,
|
|
44453
|
-
eventTail: { event, previous: null },
|
|
44454
44433
|
kind: "requested",
|
|
44455
44434
|
sessionId: command.sessionId
|
|
44456
44435
|
});
|
|
@@ -44461,7 +44440,7 @@ var DaemonSessionEventLogV2 = class {
|
|
|
44461
44440
|
if (request?.sessionId !== sessionId) {
|
|
44462
44441
|
return;
|
|
44463
44442
|
}
|
|
44464
|
-
|
|
44443
|
+
this.#append(sessionId, {
|
|
44465
44444
|
payload: { attemptId, commandId, epoch, kind: "prompt.started" },
|
|
44466
44445
|
type: "lifecycle-metadata"
|
|
44467
44446
|
});
|
|
@@ -44469,56 +44448,39 @@ var DaemonSessionEventLogV2 = class {
|
|
|
44469
44448
|
attemptId,
|
|
44470
44449
|
commandId,
|
|
44471
44450
|
epoch,
|
|
44472
|
-
eventTail: { event, previous: request.eventTail },
|
|
44473
44451
|
kind: "executing",
|
|
44474
44452
|
sessionId
|
|
44475
44453
|
});
|
|
44476
|
-
this.#store.startExecutingPromptEventsV2(sessionId, eventArray({ event, previous: request.eventTail }));
|
|
44477
44454
|
};
|
|
44478
44455
|
record = (sessionId, payload) => {
|
|
44479
44456
|
this.#loadRequests(sessionId);
|
|
44480
|
-
|
|
44481
|
-
this.#appendToExecutingRequest(sessionId, event);
|
|
44457
|
+
this.#append(sessionId, payload);
|
|
44482
44458
|
};
|
|
44483
|
-
#
|
|
44484
|
-
|
|
44485
|
-
(
|
|
44486
|
-
);
|
|
44487
|
-
if (executing !== void 0) {
|
|
44488
|
-
this.#requests.set(executing.commandId, {
|
|
44489
|
-
...executing,
|
|
44490
|
-
eventTail: { event, previous: executing.eventTail }
|
|
44491
|
-
});
|
|
44492
|
-
this.#store.appendExecutingPromptEventV2(event);
|
|
44459
|
+
#clearCompletedSession = (sessionId) => {
|
|
44460
|
+
if (![...this.#requests.values()].some((request) => request.sessionId === sessionId)) {
|
|
44461
|
+
this.#store.clearExecutingPromptEventsV2(sessionId);
|
|
44493
44462
|
}
|
|
44494
44463
|
};
|
|
44495
44464
|
queueChanged = (sessionId) => {
|
|
44496
|
-
|
|
44465
|
+
this.#append(sessionId, {
|
|
44497
44466
|
payload: { kind: "session.queue.changed" },
|
|
44498
44467
|
type: "lifecycle-metadata"
|
|
44499
44468
|
});
|
|
44500
|
-
this.#appendToExecutingRequest(sessionId, event);
|
|
44501
44469
|
};
|
|
44502
44470
|
completed = (sessionId, commandId, stopReason) => {
|
|
44503
44471
|
this.#loadRequests(sessionId);
|
|
44504
|
-
|
|
44505
|
-
const event = this.#append(sessionId, {
|
|
44472
|
+
this.#append(sessionId, {
|
|
44506
44473
|
payload: { commandId, kind: "prompt.completed", stopReason },
|
|
44507
44474
|
type: "lifecycle-metadata"
|
|
44508
44475
|
});
|
|
44509
44476
|
this.#requests.delete(commandId);
|
|
44510
|
-
|
|
44511
|
-
this.#store.clearExecutingPromptEventsV2(sessionId);
|
|
44512
|
-
} else {
|
|
44513
|
-
this.#appendToExecutingRequest(sessionId, event);
|
|
44514
|
-
}
|
|
44477
|
+
this.#clearCompletedSession(sessionId);
|
|
44515
44478
|
};
|
|
44516
44479
|
failed = (sessionId, commandId, code, message) => {
|
|
44517
44480
|
this.#loadRequests(sessionId);
|
|
44518
44481
|
const request = this.#requests.get(commandId);
|
|
44519
|
-
let event;
|
|
44520
44482
|
if (request?.kind === "executing" && request.commandId === commandId) {
|
|
44521
|
-
|
|
44483
|
+
this.#append(sessionId, {
|
|
44522
44484
|
payload: {
|
|
44523
44485
|
attemptId: request.attemptId,
|
|
44524
44486
|
code,
|
|
@@ -44529,17 +44491,13 @@ var DaemonSessionEventLogV2 = class {
|
|
|
44529
44491
|
type: "lifecycle-metadata"
|
|
44530
44492
|
});
|
|
44531
44493
|
} else {
|
|
44532
|
-
|
|
44494
|
+
this.#append(sessionId, {
|
|
44533
44495
|
payload: { code, commandId, kind: "prompt.failed-before-start", message },
|
|
44534
44496
|
type: "lifecycle-metadata"
|
|
44535
44497
|
});
|
|
44536
44498
|
}
|
|
44537
44499
|
this.#requests.delete(commandId);
|
|
44538
|
-
|
|
44539
|
-
this.#store.clearExecutingPromptEventsV2(sessionId);
|
|
44540
|
-
} else {
|
|
44541
|
-
this.#appendToExecutingRequest(sessionId, event);
|
|
44542
|
-
}
|
|
44500
|
+
this.#clearCompletedSession(sessionId);
|
|
44543
44501
|
};
|
|
44544
44502
|
executingPromptRequest = (sessionId) => {
|
|
44545
44503
|
this.#loadRequests(sessionId);
|
|
@@ -44549,7 +44507,7 @@ var DaemonSessionEventLogV2 = class {
|
|
|
44549
44507
|
if (request?.kind !== "executing") {
|
|
44550
44508
|
return null;
|
|
44551
44509
|
}
|
|
44552
|
-
const requestEvents =
|
|
44510
|
+
const requestEvents = this.#store.readExecutingPromptEventsV2(sessionId);
|
|
44553
44511
|
const events = requestEvents.slice(-EXECUTING_PROMPT_EVENT_LIMIT);
|
|
44554
44512
|
return {
|
|
44555
44513
|
attemptId: request.attemptId,
|
|
@@ -44632,7 +44590,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
44632
44590
|
join18(stateDirectory, "sessions", `${createHash7("sha256").update(config2.channelId).digest("hex")}.sqlite`)
|
|
44633
44591
|
);
|
|
44634
44592
|
const operations = new DaemonOperationState();
|
|
44635
|
-
const publisher = new DaemonSessionEventPublisher();
|
|
44593
|
+
const publisher = new DaemonSessionEventPublisher(sessionStore);
|
|
44636
44594
|
const eventLogV2 = new DaemonSessionEventLogV2(publisher, sessionStore);
|
|
44637
44595
|
const activeTurns = new DaemonTurnRegistry(operations);
|
|
44638
44596
|
const recordSessionEvent = (sessionId, event) => {
|