@moxt-ai/mobius 0.0.107 → 0.0.108

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/runtime.js CHANGED
@@ -25616,8 +25616,6 @@ var nativeMessagePageSchema = external_exports.discriminatedUnion("status", [
25616
25616
  var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
25617
25617
  var NATIVE_SESSION_RESULT_KIND = "native.session.result";
25618
25618
  var NATIVE_SESSION_CANCEL_KIND = "native.session.cancel";
25619
- var NATIVE_SESSION_TURN_FORK_REQUEST_KIND = "native.session.turn-fork.request";
25620
- var NATIVE_SESSION_TURN_FORK_KIND = "native.session.turn-fork";
25621
25619
  var ACTIVE_TURN_TEXT_LIMIT = 1e6;
25622
25620
  var identifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/);
25623
25621
  var directoryId = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
@@ -25633,28 +25631,6 @@ var identity = {
25633
25631
  bindingId: identifier,
25634
25632
  directoryId
25635
25633
  };
25636
- var turnForkIdentity = {
25637
- additionalDirectoryIds: external_exports.array(directoryId).max(16).readonly(),
25638
- agentId: identifier,
25639
- bindingId: identifier,
25640
- directoryId,
25641
- requestId: identifier,
25642
- sessionId: identifier,
25643
- sourceCommandId: identifier,
25644
- targetSessionId: identifier
25645
- };
25646
- var nativeSessionTurnForkRequestSchema = external_exports.strictObject({
25647
- ...turnForkIdentity,
25648
- kind: external_exports.literal(NATIVE_SESSION_TURN_FORK_REQUEST_KIND)
25649
- }).readonly();
25650
- var nativeSessionTurnForkCommandSchema = external_exports.strictObject({
25651
- ...turnForkIdentity,
25652
- kind: external_exports.literal(NATIVE_SESSION_TURN_FORK_KIND),
25653
- messageFingerprint: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/),
25654
- messageId: external_exports.string().min(1).max(255),
25655
- messageOccurrence: external_exports.number().int().positive(),
25656
- title: external_exports.string().max(500)
25657
- }).readonly();
25658
25634
  var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
25659
25635
  external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
25660
25636
  external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
@@ -25812,8 +25788,6 @@ var decodeNativeSessionResult = (encoded) => decode4(nativeSessionResultSchema,
25812
25788
  var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
25813
25789
  var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
25814
25790
  var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
25815
- var decodeNativeSessionTurnForkCommand = (encoded) => decode4(nativeSessionTurnForkCommandSchema, encoded);
25816
- var encodeNativeSessionTurnForkCommand = (value) => JSON.stringify(nativeSessionTurnForkCommandSchema.parse(value));
25817
25791
 
25818
25792
  // ../protocol/src/session-events.ts
25819
25793
  var SESSION_EVENT_KIND = "session.event";
@@ -26000,11 +25974,6 @@ var serviceToDaemonSignatures = {
26000
25974
  encodeNativeSessionCommand,
26001
25975
  decodeNativeSessionCommand
26002
25976
  ),
26003
- [NATIVE_SESSION_TURN_FORK_KIND]: defineMessageSignature(
26004
- NATIVE_SESSION_TURN_FORK_KIND,
26005
- encodeNativeSessionTurnForkCommand,
26006
- decodeNativeSessionTurnForkCommand
26007
- ),
26008
25977
  [RUNTIME_HEARTBEAT_ACK_KIND]: defineMessageSignature(
26009
25978
  RUNTIME_HEARTBEAT_ACK_KIND,
26010
25979
  encodeRuntimeHeartbeatAckEvent,
@@ -28363,17 +28332,6 @@ var AcpProcessSession = class _AcpProcessSession {
28363
28332
  async (runtime) => await runtime.#initializeAgent(options.signal),
28364
28333
  unmeasuredOperationMetrics
28365
28334
  );
28366
- static startSessionForkAtTurn = async (options, sourceNativeSessionId, forkPoint, getObserver, store) => await _AcpProcessSession.#start(
28367
- options,
28368
- getObserver,
28369
- store,
28370
- async (runtime) => await runtime.initialize(
28371
- options.signal,
28372
- { kind: "fork", nativeSessionId: sourceNativeSessionId },
28373
- forkPoint
28374
- ),
28375
- unmeasuredOperationMetrics
28376
- );
28377
28335
  belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
28378
28336
  usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
28379
28337
  canRebind = () => !this.#prompted && !this.#turn.running;
@@ -28556,7 +28514,7 @@ var AcpProcessSession = class _AcpProcessSession {
28556
28514
  128
28557
28515
  );
28558
28516
  }
28559
- initialize = async (signal, origin, forkPoint) => {
28517
+ initialize = async (signal, origin) => {
28560
28518
  await this.#initializeAgent(signal);
28561
28519
  let stored = this.#metrics.measureSync(
28562
28520
  "session-state-read",
@@ -28608,21 +28566,7 @@ var AcpProcessSession = class _AcpProcessSession {
28608
28566
  sessionId: nativeSessionIdSchema.parse(origin.nativeSessionId),
28609
28567
  cwd: this.#cwd,
28610
28568
  additionalDirectories: [...this.#additionalDirectories],
28611
- mcpServers: [],
28612
- ...forkPoint === void 0 ? {} : {
28613
- _meta: {
28614
- jetbrains: {
28615
- air: {
28616
- fork: {
28617
- version: 1,
28618
- messageFingerprint: forkPoint.messageFingerprint,
28619
- messageId: forkPoint.messageId,
28620
- messageOccurrence: forkPoint.messageOccurrence
28621
- }
28622
- }
28623
- }
28624
- }
28625
- }
28569
+ mcpServers: []
28626
28570
  },
28627
28571
  { cancellationSignal: signal }
28628
28572
  ),
@@ -29862,27 +29806,6 @@ var AcpSessionManager = class {
29862
29806
  this.#preparing.set(options.sessionId, operation);
29863
29807
  return await operation;
29864
29808
  }
29865
- async #startSessionForkAtTurnPreparation(options, sourceNativeSessionId, forkPoint) {
29866
- const operation = (async () => {
29867
- try {
29868
- return await this.#startRetainedSessionProcess(
29869
- options,
29870
- async () => await AcpProcessSession.startSessionForkAtTurn(
29871
- options,
29872
- sourceNativeSessionId,
29873
- forkPoint,
29874
- () => this.#observer,
29875
- this.#store
29876
- )
29877
- );
29878
- } finally {
29879
- this.#preparing.delete(options.sessionId);
29880
- this.#notifyProcessCapacityChanged();
29881
- }
29882
- })();
29883
- this.#preparing.set(options.sessionId, operation);
29884
- return await operation;
29885
- }
29886
29809
  async #replacePreparation(existing, options, metrics) {
29887
29810
  const operation = (async () => {
29888
29811
  try {
@@ -30518,70 +30441,6 @@ var AcpSessionManager = class {
30518
30441
  this.#endSessionUse(options.sessionId);
30519
30442
  }
30520
30443
  };
30521
- forkSessionAtTurn = async (options, sourceSessionId, forkPoint) => {
30522
- if (sourceSessionId === options.sessionId) {
30523
- throw new AcpExecutionError(
30524
- "The fork destination must be a new conversation",
30525
- {},
30526
- "session_identity_mismatch"
30527
- );
30528
- }
30529
- const source = this.#store.read(sourceSessionId);
30530
- if (!(source instanceof FoundAcpStoredSession) || !source.session.prompted) {
30531
- throw new AcpExecutionError(
30532
- "The source conversation has no resumable native Agent session",
30533
- {},
30534
- "native_session_not_found"
30535
- );
30536
- }
30537
- if (source.session.agentId !== options.agent.id || source.session.cwd !== options.cwd || !arraysEqual(source.session.additionalDirectories, options.additionalDirectories)) {
30538
- throw new AcpExecutionError(
30539
- "The source conversation execution target does not match the fork request",
30540
- {},
30541
- "native_session_target_changed"
30542
- );
30543
- }
30544
- const key = `${options.agent.id}:${source.session.nativeSessionId}`;
30545
- const linked = this.#store.findNative(options.agent.id, source.session.nativeSessionId);
30546
- if (this.#nativeOperations.has(key) || linked.some((entry) => this.#activeSessionIds.has(entry.sessionId) || this.#preparing.has(entry.sessionId))) {
30547
- throw new AcpExecutionError(
30548
- "Wait for the source conversation's running operation to finish",
30549
- {},
30550
- "session_busy"
30551
- );
30552
- }
30553
- if (this.#sessions.has(options.sessionId) || this.#preparing.has(options.sessionId) || this.#store.read(options.sessionId) instanceof FoundAcpStoredSession || this.#store.read(options.sessionId) instanceof DeletedAcpStoredSession) {
30554
- throw new AcpExecutionError("The destination conversation already exists", {}, "session_identity_mismatch");
30555
- }
30556
- this.#beginSessionUse(options.sessionId);
30557
- this.#nativeOperations.add(key);
30558
- try {
30559
- const runtime = await this.#startSessionForkAtTurnPreparation(
30560
- options,
30561
- source.session.nativeSessionId,
30562
- forkPoint
30563
- );
30564
- const openedKey = `${options.agent.id}:${runtime.nativeSessionId()}`;
30565
- this.#nativeOperations.add(openedKey);
30566
- try {
30567
- return {
30568
- history: await runtime.loadHistory(options.signal),
30569
- prepared: runtime.prepared(),
30570
- sessionId: options.sessionId
30571
- };
30572
- } catch (error62) {
30573
- this.#store.remove(options.sessionId);
30574
- await this.#retireSessionProcess(options.sessionId, runtime, async () => await runtime.closeProcess());
30575
- throw error62;
30576
- } finally {
30577
- this.#nativeOperations.delete(openedKey);
30578
- this.#notifyProcessCapacityChanged();
30579
- }
30580
- } finally {
30581
- this.#nativeOperations.delete(key);
30582
- this.#endSessionUse(options.sessionId);
30583
- }
30584
- };
30585
30444
  deleteNativeSession = async (options, nativeSessionId) => {
30586
30445
  this.#beginNativeBrowserUse(options.sessionId);
30587
30446
  try {
@@ -34162,7 +34021,7 @@ function createNativeSessionRequestHandler(dependencies) {
34162
34021
  };
34163
34022
  const handle = (command) => {
34164
34023
  const previous = [...pending.values()].filter((request) => request.agentId === command.agentId);
34165
- const parallelRead = command.kind === NATIVE_SESSION_REQUEST_KIND && (command.action === "linked-history" || command.action === "active-turn");
34024
+ const parallelRead = command.action === "linked-history" || command.action === "active-turn";
34166
34025
  if (pending.has(command.requestId) || pending.size >= 4 || !parallelRead && previous.some((request) => !request.controller.signal.aborted)) {
34167
34026
  reportOperationFailure(
34168
34027
  socket,
@@ -34183,7 +34042,7 @@ function createNativeSessionRequestHandler(dependencies) {
34183
34042
  const completion = (async () => {
34184
34043
  try {
34185
34044
  operationSignal.throwIfAborted();
34186
- const skipPrevious = command.kind === NATIVE_SESSION_REQUEST_KIND && command.action === "active-turn";
34045
+ const skipPrevious = command.action === "active-turn";
34187
34046
  if (previous.length > 0 && !skipPrevious) {
34188
34047
  await new Promise((resolve8, reject) => {
34189
34048
  const onAbort = () => reject(operationSignal.reason);
@@ -34201,13 +34060,13 @@ function createNativeSessionRequestHandler(dependencies) {
34201
34060
  });
34202
34061
  }
34203
34062
  operationSignal.throwIfAborted();
34204
- const result = command.kind === NATIVE_SESSION_REQUEST_KIND ? await nativeSessions.execute(command, operationSignal) : await nativeSessions.executeTurnFork(command, operationSignal);
34063
+ const result = await nativeSessions.execute(command, operationSignal);
34205
34064
  if (socket.readyState === WebSocket5.OPEN) {
34206
34065
  send(socket, result);
34207
34066
  }
34208
34067
  } catch (error62) {
34209
34068
  const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError("Native session operation cancelled", {}, "native_session_cancelled") : error62;
34210
- const event = command.kind === NATIVE_SESSION_REQUEST_KIND ? "native_session_operation_failed" : "native_session_turn_fork_failed";
34069
+ const event = "native_session_operation_failed";
34211
34070
  audit.record({
34212
34071
  commandId: command.requestId,
34213
34072
  sessionId: command.sessionId,
@@ -34218,7 +34077,7 @@ function createNativeSessionRequestHandler(dependencies) {
34218
34077
  event,
34219
34078
  command.requestId,
34220
34079
  {
34221
- ...command.kind === NATIVE_SESSION_REQUEST_KIND ? { action: command.action } : {},
34080
+ action: command.action,
34222
34081
  agentId: command.agentId,
34223
34082
  code: operationErrorCode(failure2),
34224
34083
  sessionId: command.sessionId
@@ -34246,7 +34105,6 @@ function createNativeSessionRequestHandler(dependencies) {
34246
34105
 
34247
34106
  // src/native-sessions/service.ts
34248
34107
  import { randomUUID as randomUUID3 } from "node:crypto";
34249
- import { basename as basename6 } from "node:path";
34250
34108
 
34251
34109
  // src/native-sessions/acp-history.ts
34252
34110
  async function readAcpHistory(sessions, directories, bindingId, options, nativeSessionId) {
@@ -34696,74 +34554,6 @@ var NativeSessionService = class {
34696
34554
  }
34697
34555
  return entries;
34698
34556
  };
34699
- executeTurnFork = async (command, signal) => {
34700
- signal.throwIfAborted();
34701
- const cwd = await this.#directories.resolve(this.#config.bindingId, command.directoryId, signal);
34702
- const additionalDirectories = [];
34703
- const additionalEntries = [];
34704
- const resolvedPaths = /* @__PURE__ */ new Set([cwd]);
34705
- for (const directoryId2 of command.additionalDirectoryIds) {
34706
- const path2 = await this.#directories.resolve(this.#config.bindingId, directoryId2, signal);
34707
- if (resolvedPaths.has(path2)) {
34708
- throw new LocalAuthorizationError("Workspace directories must resolve to distinct locations");
34709
- }
34710
- resolvedPaths.add(path2);
34711
- additionalDirectories.push(path2);
34712
- additionalEntries.push({ directoryId: directoryId2, name: basename6(path2) });
34713
- }
34714
- const listing = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
34715
- const opened = await this.#sessions.forkSessionAtTurn(
34716
- {
34717
- additionalDirectories,
34718
- agent: this.#config.catalog.find(command.agentId),
34719
- cwd,
34720
- sessionId: command.targetSessionId,
34721
- signal
34722
- },
34723
- command.sessionId,
34724
- {
34725
- messageFingerprint: command.messageFingerprint,
34726
- messageId: command.messageId,
34727
- messageOccurrence: command.messageOccurrence
34728
- }
34729
- );
34730
- signal.throwIfAborted();
34731
- const ready = {
34732
- additionalDirectories: additionalEntries,
34733
- agentId: command.agentId,
34734
- agentName: opened.prepared.agentName,
34735
- agentVersion: opened.prepared.agentVersion,
34736
- capabilities: opened.prepared.capabilities,
34737
- commands: opened.prepared.commands,
34738
- configOptions: opened.prepared.configOptions,
34739
- directoryId: command.directoryId,
34740
- directoryLabel: listing.directoryLabel,
34741
- kind: "session.ready",
34742
- requestId: command.requestId,
34743
- restored: true,
34744
- sessionId: opened.sessionId
34745
- };
34746
- this.#audit.record({
34747
- commandId: command.requestId,
34748
- details: {
34749
- agentId: command.agentId,
34750
- messageId: command.messageId,
34751
- sourceCommandId: command.sourceCommandId
34752
- },
34753
- event: "native_session_turn_forked",
34754
- sessionId: command.sessionId
34755
- });
34756
- return {
34757
- action: "fork",
34758
- history: opened.history,
34759
- kind: "native.session.result",
34760
- ready,
34761
- requestId: command.requestId,
34762
- sessionId: command.sessionId,
34763
- targetSessionId: command.targetSessionId,
34764
- title: command.title
34765
- };
34766
- };
34767
34557
  authorizeEntry = async (command, options, info) => {
34768
34558
  try {
34769
34559
  const primary = await this.#directories.identify(command.bindingId, info.cwd, options.signal);
@@ -35656,7 +35446,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
35656
35446
  handleCatalogRefresh.handle(message);
35657
35447
  return;
35658
35448
  }
35659
- if (kind === NATIVE_SESSION_REQUEST_KIND || kind === NATIVE_SESSION_TURN_FORK_KIND) {
35449
+ if (kind === NATIVE_SESSION_REQUEST_KIND) {
35660
35450
  nativeRequestHandler.handle(message);
35661
35451
  return;
35662
35452
  }
@@ -36067,7 +35857,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
36067
35857
  // src/pairing/pair-local-machine.ts
36068
35858
  import { mkdir as mkdir5, realpath as realpath9, stat as stat8 } from "node:fs/promises";
36069
35859
  import { hostname as hostname3 } from "node:os";
36070
- import { basename as basename7, resolve as resolve6 } from "node:path";
35860
+ import { basename as basename6, resolve as resolve6 } from "node:path";
36071
35861
  import { fetch as fetch5 } from "undici";
36072
35862
 
36073
35863
  // src/storage/runtime-installation-store.ts
@@ -36711,7 +36501,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
36711
36501
  installableAgents,
36712
36502
  machineName: hostname3(),
36713
36503
  pairingCode: options.code,
36714
- workspaceName: basename7(defaultWorkspace) || "Local workspace"
36504
+ workspaceName: basename6(defaultWorkspace) || "Local workspace"
36715
36505
  }),
36716
36506
  dispatcher: environmentProxyDispatcher,
36717
36507
  headers: { "content-type": "application/json" },