@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/index.js CHANGED
@@ -20961,8 +20961,6 @@ var nativeMessagePageSchema = external_exports.discriminatedUnion("status", [
20961
20961
  var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
20962
20962
  var NATIVE_SESSION_RESULT_KIND = "native.session.result";
20963
20963
  var NATIVE_SESSION_CANCEL_KIND = "native.session.cancel";
20964
- var NATIVE_SESSION_TURN_FORK_REQUEST_KIND = "native.session.turn-fork.request";
20965
- var NATIVE_SESSION_TURN_FORK_KIND = "native.session.turn-fork";
20966
20964
  var ACTIVE_TURN_TEXT_LIMIT = 1e6;
20967
20965
  var identifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/);
20968
20966
  var directoryId = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
@@ -20978,28 +20976,6 @@ var identity = {
20978
20976
  bindingId: identifier,
20979
20977
  directoryId
20980
20978
  };
20981
- var turnForkIdentity = {
20982
- additionalDirectoryIds: external_exports.array(directoryId).max(16).readonly(),
20983
- agentId: identifier,
20984
- bindingId: identifier,
20985
- directoryId,
20986
- requestId: identifier,
20987
- sessionId: identifier,
20988
- sourceCommandId: identifier,
20989
- targetSessionId: identifier
20990
- };
20991
- var nativeSessionTurnForkRequestSchema = external_exports.strictObject({
20992
- ...turnForkIdentity,
20993
- kind: external_exports.literal(NATIVE_SESSION_TURN_FORK_REQUEST_KIND)
20994
- }).readonly();
20995
- var nativeSessionTurnForkCommandSchema = external_exports.strictObject({
20996
- ...turnForkIdentity,
20997
- kind: external_exports.literal(NATIVE_SESSION_TURN_FORK_KIND),
20998
- messageFingerprint: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/),
20999
- messageId: external_exports.string().min(1).max(255),
21000
- messageOccurrence: external_exports.number().int().positive(),
21001
- title: external_exports.string().max(500)
21002
- }).readonly();
21003
20979
  var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
21004
20980
  external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
21005
20981
  external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
@@ -21157,8 +21133,6 @@ var decodeNativeSessionResult = (encoded) => decode4(nativeSessionResultSchema,
21157
21133
  var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
21158
21134
  var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
21159
21135
  var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
21160
- var decodeNativeSessionTurnForkCommand = (encoded) => decode4(nativeSessionTurnForkCommandSchema, encoded);
21161
- var encodeNativeSessionTurnForkCommand = (value) => JSON.stringify(nativeSessionTurnForkCommandSchema.parse(value));
21162
21136
 
21163
21137
  // ../protocol/src/session-events.ts
21164
21138
  var SESSION_EVENT_KIND = "session.event";
@@ -21345,11 +21319,6 @@ var serviceToDaemonSignatures = {
21345
21319
  encodeNativeSessionCommand,
21346
21320
  decodeNativeSessionCommand
21347
21321
  ),
21348
- [NATIVE_SESSION_TURN_FORK_KIND]: defineMessageSignature(
21349
- NATIVE_SESSION_TURN_FORK_KIND,
21350
- encodeNativeSessionTurnForkCommand,
21351
- decodeNativeSessionTurnForkCommand
21352
- ),
21353
21322
  [RUNTIME_HEARTBEAT_ACK_KIND]: defineMessageSignature(
21354
21323
  RUNTIME_HEARTBEAT_ACK_KIND,
21355
21324
  encodeRuntimeHeartbeatAckEvent,
@@ -24505,17 +24474,6 @@ var AcpProcessSession = class _AcpProcessSession {
24505
24474
  async (runtime) => await runtime.#initializeAgent(options.signal),
24506
24475
  unmeasuredOperationMetrics
24507
24476
  );
24508
- static startSessionForkAtTurn = async (options, sourceNativeSessionId, forkPoint, getObserver, store) => await _AcpProcessSession.#start(
24509
- options,
24510
- getObserver,
24511
- store,
24512
- async (runtime) => await runtime.initialize(
24513
- options.signal,
24514
- { kind: "fork", nativeSessionId: sourceNativeSessionId },
24515
- forkPoint
24516
- ),
24517
- unmeasuredOperationMetrics
24518
- );
24519
24477
  belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
24520
24478
  usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
24521
24479
  canRebind = () => !this.#prompted && !this.#turn.running;
@@ -24698,7 +24656,7 @@ var AcpProcessSession = class _AcpProcessSession {
24698
24656
  128
24699
24657
  );
24700
24658
  }
24701
- initialize = async (signal, origin, forkPoint) => {
24659
+ initialize = async (signal, origin) => {
24702
24660
  await this.#initializeAgent(signal);
24703
24661
  let stored = this.#metrics.measureSync(
24704
24662
  "session-state-read",
@@ -24750,21 +24708,7 @@ var AcpProcessSession = class _AcpProcessSession {
24750
24708
  sessionId: nativeSessionIdSchema.parse(origin.nativeSessionId),
24751
24709
  cwd: this.#cwd,
24752
24710
  additionalDirectories: [...this.#additionalDirectories],
24753
- mcpServers: [],
24754
- ...forkPoint === void 0 ? {} : {
24755
- _meta: {
24756
- jetbrains: {
24757
- air: {
24758
- fork: {
24759
- version: 1,
24760
- messageFingerprint: forkPoint.messageFingerprint,
24761
- messageId: forkPoint.messageId,
24762
- messageOccurrence: forkPoint.messageOccurrence
24763
- }
24764
- }
24765
- }
24766
- }
24767
- }
24711
+ mcpServers: []
24768
24712
  },
24769
24713
  { cancellationSignal: signal }
24770
24714
  ),
@@ -26004,27 +25948,6 @@ var AcpSessionManager = class {
26004
25948
  this.#preparing.set(options.sessionId, operation);
26005
25949
  return await operation;
26006
25950
  }
26007
- async #startSessionForkAtTurnPreparation(options, sourceNativeSessionId, forkPoint) {
26008
- const operation = (async () => {
26009
- try {
26010
- return await this.#startRetainedSessionProcess(
26011
- options,
26012
- async () => await AcpProcessSession.startSessionForkAtTurn(
26013
- options,
26014
- sourceNativeSessionId,
26015
- forkPoint,
26016
- () => this.#observer,
26017
- this.#store
26018
- )
26019
- );
26020
- } finally {
26021
- this.#preparing.delete(options.sessionId);
26022
- this.#notifyProcessCapacityChanged();
26023
- }
26024
- })();
26025
- this.#preparing.set(options.sessionId, operation);
26026
- return await operation;
26027
- }
26028
25951
  async #replacePreparation(existing, options, metrics) {
26029
25952
  const operation = (async () => {
26030
25953
  try {
@@ -26660,70 +26583,6 @@ var AcpSessionManager = class {
26660
26583
  this.#endSessionUse(options.sessionId);
26661
26584
  }
26662
26585
  };
26663
- forkSessionAtTurn = async (options, sourceSessionId, forkPoint) => {
26664
- if (sourceSessionId === options.sessionId) {
26665
- throw new AcpExecutionError(
26666
- "The fork destination must be a new conversation",
26667
- {},
26668
- "session_identity_mismatch"
26669
- );
26670
- }
26671
- const source = this.#store.read(sourceSessionId);
26672
- if (!(source instanceof FoundAcpStoredSession) || !source.session.prompted) {
26673
- throw new AcpExecutionError(
26674
- "The source conversation has no resumable native Agent session",
26675
- {},
26676
- "native_session_not_found"
26677
- );
26678
- }
26679
- if (source.session.agentId !== options.agent.id || source.session.cwd !== options.cwd || !arraysEqual(source.session.additionalDirectories, options.additionalDirectories)) {
26680
- throw new AcpExecutionError(
26681
- "The source conversation execution target does not match the fork request",
26682
- {},
26683
- "native_session_target_changed"
26684
- );
26685
- }
26686
- const key = `${options.agent.id}:${source.session.nativeSessionId}`;
26687
- const linked = this.#store.findNative(options.agent.id, source.session.nativeSessionId);
26688
- if (this.#nativeOperations.has(key) || linked.some((entry) => this.#activeSessionIds.has(entry.sessionId) || this.#preparing.has(entry.sessionId))) {
26689
- throw new AcpExecutionError(
26690
- "Wait for the source conversation's running operation to finish",
26691
- {},
26692
- "session_busy"
26693
- );
26694
- }
26695
- 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) {
26696
- throw new AcpExecutionError("The destination conversation already exists", {}, "session_identity_mismatch");
26697
- }
26698
- this.#beginSessionUse(options.sessionId);
26699
- this.#nativeOperations.add(key);
26700
- try {
26701
- const runtime = await this.#startSessionForkAtTurnPreparation(
26702
- options,
26703
- source.session.nativeSessionId,
26704
- forkPoint
26705
- );
26706
- const openedKey = `${options.agent.id}:${runtime.nativeSessionId()}`;
26707
- this.#nativeOperations.add(openedKey);
26708
- try {
26709
- return {
26710
- history: await runtime.loadHistory(options.signal),
26711
- prepared: runtime.prepared(),
26712
- sessionId: options.sessionId
26713
- };
26714
- } catch (error62) {
26715
- this.#store.remove(options.sessionId);
26716
- await this.#retireSessionProcess(options.sessionId, runtime, async () => await runtime.closeProcess());
26717
- throw error62;
26718
- } finally {
26719
- this.#nativeOperations.delete(openedKey);
26720
- this.#notifyProcessCapacityChanged();
26721
- }
26722
- } finally {
26723
- this.#nativeOperations.delete(key);
26724
- this.#endSessionUse(options.sessionId);
26725
- }
26726
- };
26727
26586
  deleteNativeSession = async (options, nativeSessionId) => {
26728
26587
  this.#beginNativeBrowserUse(options.sessionId);
26729
26588
  try {
@@ -35040,7 +34899,7 @@ function createNativeSessionRequestHandler(dependencies) {
35040
34899
  };
35041
34900
  const handle = (command) => {
35042
34901
  const previous = [...pending.values()].filter((request) => request.agentId === command.agentId);
35043
- const parallelRead = command.kind === NATIVE_SESSION_REQUEST_KIND && (command.action === "linked-history" || command.action === "active-turn");
34902
+ const parallelRead = command.action === "linked-history" || command.action === "active-turn";
35044
34903
  if (pending.has(command.requestId) || pending.size >= 4 || !parallelRead && previous.some((request) => !request.controller.signal.aborted)) {
35045
34904
  reportOperationFailure(
35046
34905
  socket,
@@ -35061,7 +34920,7 @@ function createNativeSessionRequestHandler(dependencies) {
35061
34920
  const completion = (async () => {
35062
34921
  try {
35063
34922
  operationSignal.throwIfAborted();
35064
- const skipPrevious = command.kind === NATIVE_SESSION_REQUEST_KIND && command.action === "active-turn";
34923
+ const skipPrevious = command.action === "active-turn";
35065
34924
  if (previous.length > 0 && !skipPrevious) {
35066
34925
  await new Promise((resolve8, reject) => {
35067
34926
  const onAbort = () => reject(operationSignal.reason);
@@ -35079,13 +34938,13 @@ function createNativeSessionRequestHandler(dependencies) {
35079
34938
  });
35080
34939
  }
35081
34940
  operationSignal.throwIfAborted();
35082
- const result = command.kind === NATIVE_SESSION_REQUEST_KIND ? await nativeSessions.execute(command, operationSignal) : await nativeSessions.executeTurnFork(command, operationSignal);
34941
+ const result = await nativeSessions.execute(command, operationSignal);
35083
34942
  if (socket.readyState === WebSocket5.OPEN) {
35084
34943
  send(socket, result);
35085
34944
  }
35086
34945
  } catch (error62) {
35087
34946
  const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError("Native session operation cancelled", {}, "native_session_cancelled") : error62;
35088
- const event = command.kind === NATIVE_SESSION_REQUEST_KIND ? "native_session_operation_failed" : "native_session_turn_fork_failed";
34947
+ const event = "native_session_operation_failed";
35089
34948
  audit.record({
35090
34949
  commandId: command.requestId,
35091
34950
  sessionId: command.sessionId,
@@ -35096,7 +34955,7 @@ function createNativeSessionRequestHandler(dependencies) {
35096
34955
  event,
35097
34956
  command.requestId,
35098
34957
  {
35099
- ...command.kind === NATIVE_SESSION_REQUEST_KIND ? { action: command.action } : {},
34958
+ action: command.action,
35100
34959
  agentId: command.agentId,
35101
34960
  code: operationErrorCode(failure2),
35102
34961
  sessionId: command.sessionId
@@ -35124,7 +34983,6 @@ function createNativeSessionRequestHandler(dependencies) {
35124
34983
 
35125
34984
  // src/native-sessions/service.ts
35126
34985
  import { randomUUID as randomUUID4 } from "node:crypto";
35127
- import { basename as basename7 } from "node:path";
35128
34986
 
35129
34987
  // src/native-sessions/acp-history.ts
35130
34988
  async function readAcpHistory(sessions, directories, bindingId, options, nativeSessionId) {
@@ -35574,74 +35432,6 @@ var NativeSessionService = class {
35574
35432
  }
35575
35433
  return entries;
35576
35434
  };
35577
- executeTurnFork = async (command, signal) => {
35578
- signal.throwIfAborted();
35579
- const cwd = await this.#directories.resolve(this.#config.bindingId, command.directoryId, signal);
35580
- const additionalDirectories = [];
35581
- const additionalEntries = [];
35582
- const resolvedPaths = /* @__PURE__ */ new Set([cwd]);
35583
- for (const directoryId2 of command.additionalDirectoryIds) {
35584
- const path2 = await this.#directories.resolve(this.#config.bindingId, directoryId2, signal);
35585
- if (resolvedPaths.has(path2)) {
35586
- throw new LocalAuthorizationError("Workspace directories must resolve to distinct locations");
35587
- }
35588
- resolvedPaths.add(path2);
35589
- additionalDirectories.push(path2);
35590
- additionalEntries.push({ directoryId: directoryId2, name: basename7(path2) });
35591
- }
35592
- const listing = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
35593
- const opened = await this.#sessions.forkSessionAtTurn(
35594
- {
35595
- additionalDirectories,
35596
- agent: this.#config.catalog.find(command.agentId),
35597
- cwd,
35598
- sessionId: command.targetSessionId,
35599
- signal
35600
- },
35601
- command.sessionId,
35602
- {
35603
- messageFingerprint: command.messageFingerprint,
35604
- messageId: command.messageId,
35605
- messageOccurrence: command.messageOccurrence
35606
- }
35607
- );
35608
- signal.throwIfAborted();
35609
- const ready = {
35610
- additionalDirectories: additionalEntries,
35611
- agentId: command.agentId,
35612
- agentName: opened.prepared.agentName,
35613
- agentVersion: opened.prepared.agentVersion,
35614
- capabilities: opened.prepared.capabilities,
35615
- commands: opened.prepared.commands,
35616
- configOptions: opened.prepared.configOptions,
35617
- directoryId: command.directoryId,
35618
- directoryLabel: listing.directoryLabel,
35619
- kind: "session.ready",
35620
- requestId: command.requestId,
35621
- restored: true,
35622
- sessionId: opened.sessionId
35623
- };
35624
- this.#audit.record({
35625
- commandId: command.requestId,
35626
- details: {
35627
- agentId: command.agentId,
35628
- messageId: command.messageId,
35629
- sourceCommandId: command.sourceCommandId
35630
- },
35631
- event: "native_session_turn_forked",
35632
- sessionId: command.sessionId
35633
- });
35634
- return {
35635
- action: "fork",
35636
- history: opened.history,
35637
- kind: "native.session.result",
35638
- ready,
35639
- requestId: command.requestId,
35640
- sessionId: command.sessionId,
35641
- targetSessionId: command.targetSessionId,
35642
- title: command.title
35643
- };
35644
- };
35645
35435
  authorizeEntry = async (command, options, info) => {
35646
35436
  try {
35647
35437
  const primary = await this.#directories.identify(command.bindingId, info.cwd, options.signal);
@@ -36514,7 +36304,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
36514
36304
  handleCatalogRefresh.handle(message);
36515
36305
  return;
36516
36306
  }
36517
- if (kind === NATIVE_SESSION_REQUEST_KIND || kind === NATIVE_SESSION_TURN_FORK_KIND) {
36307
+ if (kind === NATIVE_SESSION_REQUEST_KIND) {
36518
36308
  nativeRequestHandler.handle(message);
36519
36309
  return;
36520
36310
  }