@moxt-ai/mobius 0.0.107 → 0.0.110

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.
Files changed (36) hide show
  1. package/dist/acp/process-session.d.ts +1 -8
  2. package/dist/acp/process-session.d.ts.map +1 -1
  3. package/dist/acp/process-session.js +1 -27
  4. package/dist/acp/process-session.js.map +1 -1
  5. package/dist/acp/session-manager.d.ts +3 -76
  6. package/dist/acp/session-manager.d.ts.map +1 -1
  7. package/dist/acp/session-manager.js +4 -103
  8. package/dist/acp/session-manager.js.map +1 -1
  9. package/dist/cli.js +29 -332
  10. package/dist/cli.js.map +3 -3
  11. package/dist/index.js +28 -331
  12. package/dist/index.js.map +3 -3
  13. package/dist/native-sessions/acp-adapter.d.ts.map +1 -1
  14. package/dist/native-sessions/acp-adapter.js +0 -1
  15. package/dist/native-sessions/acp-adapter.js.map +1 -1
  16. package/dist/native-sessions/agent-adapter.d.ts +0 -1
  17. package/dist/native-sessions/agent-adapter.d.ts.map +1 -1
  18. package/dist/native-sessions/agent-adapter.js +0 -3
  19. package/dist/native-sessions/agent-adapter.js.map +1 -1
  20. package/dist/native-sessions/codex-adapter.d.ts.map +1 -1
  21. package/dist/native-sessions/codex-adapter.js +0 -1
  22. package/dist/native-sessions/codex-adapter.js.map +1 -1
  23. package/dist/native-sessions/handle-native-requests.d.ts +2 -3
  24. package/dist/native-sessions/handle-native-requests.d.ts.map +1 -1
  25. package/dist/native-sessions/handle-native-requests.js +5 -11
  26. package/dist/native-sessions/handle-native-requests.js.map +1 -1
  27. package/dist/native-sessions/service.d.ts +1 -2
  28. package/dist/native-sessions/service.d.ts.map +1 -1
  29. package/dist/native-sessions/service.js +2 -105
  30. package/dist/native-sessions/service.js.map +1 -1
  31. package/dist/run-daemon.d.ts.map +1 -1
  32. package/dist/run-daemon.js +18 -2
  33. package/dist/run-daemon.js.map +1 -1
  34. package/dist/runtime.js +30 -333
  35. package/dist/runtime.js.map +3 -3
  36. package/package.json +1 -1
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,31 +20976,8 @@ 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
- external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
21006
20981
  external_exports.strictObject({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifier }).readonly(),
21007
20982
  external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
21008
20983
  external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
@@ -21026,7 +21001,6 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
21026
21001
  ]);
21027
21002
  var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
21028
21003
  external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
21029
- external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
21030
21004
  external_exports.strictObject({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifier }).readonly(),
21031
21005
  external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
21032
21006
  external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
@@ -21042,12 +21016,6 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
21042
21016
  entryId: identifier,
21043
21017
  targetSessionId: identifier
21044
21018
  }).readonly(),
21045
- external_exports.strictObject({
21046
- ...identity,
21047
- action: external_exports.enum(["import-only", "fork-only"]),
21048
- entryId: identifier,
21049
- targetSessionId: identifier
21050
- }).readonly(),
21051
21019
  external_exports.strictObject({
21052
21020
  ...identity,
21053
21021
  action: external_exports.literal("delete"),
@@ -21070,12 +21038,6 @@ var resultEnvelope = {
21070
21038
  };
21071
21039
  var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
21072
21040
  external_exports.strictObject({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifier }).readonly(),
21073
- external_exports.strictObject({
21074
- ...resultEnvelope,
21075
- action: external_exports.literal("linked-history"),
21076
- targetSessionId: identifier,
21077
- history: sessionHistorySchema
21078
- }).readonly(),
21079
21041
  external_exports.strictObject({
21080
21042
  ...resultEnvelope,
21081
21043
  action: external_exports.literal("active-turn"),
@@ -21094,11 +21056,6 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
21094
21056
  state: external_exports.literal("running")
21095
21057
  }).readonly().nullable()
21096
21058
  }).readonly(),
21097
- external_exports.strictObject({
21098
- ...resultEnvelope,
21099
- action: external_exports.literal("unlinked-history"),
21100
- targetSessionId: identifier
21101
- }).readonly(),
21102
21059
  external_exports.strictObject({
21103
21060
  ...resultEnvelope,
21104
21061
  action: external_exports.literal("find"),
@@ -21116,7 +21073,6 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
21116
21073
  action: external_exports.enum(["import", "fork"]),
21117
21074
  targetSessionId: identifier,
21118
21075
  ready: sessionReadyEventSchema,
21119
- history: sessionHistorySchema,
21120
21076
  title: external_exports.string().max(500)
21121
21077
  }).readonly(),
21122
21078
  external_exports.strictObject({
@@ -21157,8 +21113,6 @@ var decodeNativeSessionResult = (encoded) => decode4(nativeSessionResultSchema,
21157
21113
  var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
21158
21114
  var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
21159
21115
  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
21116
 
21163
21117
  // ../protocol/src/session-events.ts
21164
21118
  var SESSION_EVENT_KIND = "session.event";
@@ -21345,11 +21299,6 @@ var serviceToDaemonSignatures = {
21345
21299
  encodeNativeSessionCommand,
21346
21300
  decodeNativeSessionCommand
21347
21301
  ),
21348
- [NATIVE_SESSION_TURN_FORK_KIND]: defineMessageSignature(
21349
- NATIVE_SESSION_TURN_FORK_KIND,
21350
- encodeNativeSessionTurnForkCommand,
21351
- decodeNativeSessionTurnForkCommand
21352
- ),
21353
21302
  [RUNTIME_HEARTBEAT_ACK_KIND]: defineMessageSignature(
21354
21303
  RUNTIME_HEARTBEAT_ACK_KIND,
21355
21304
  encodeRuntimeHeartbeatAckEvent,
@@ -24210,15 +24159,6 @@ var PendingElicitation = class {
24210
24159
  var PROCESS_STOP_TIMEOUT_MILLISECONDS = 1e3;
24211
24160
  var MAX_PRE_SESSION_UPDATES = 100;
24212
24161
  var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
24213
- function nativeHistoryNotRetained() {
24214
- return {
24215
- cause: {
24216
- code: "native_history_not_retained",
24217
- message: "Native message history is not retained in the cloud for this Session."
24218
- },
24219
- status: "unavailable"
24220
- };
24221
- }
24222
24162
  var NullAcpSessionObserver = class {
24223
24163
  onCommands = () => Promise.resolve();
24224
24164
  onConfig = () => Promise.resolve();
@@ -24505,17 +24445,6 @@ var AcpProcessSession = class _AcpProcessSession {
24505
24445
  async (runtime) => await runtime.#initializeAgent(options.signal),
24506
24446
  unmeasuredOperationMetrics
24507
24447
  );
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
24448
  belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
24520
24449
  usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
24521
24450
  canRebind = () => !this.#prompted && !this.#turn.running;
@@ -24698,7 +24627,7 @@ var AcpProcessSession = class _AcpProcessSession {
24698
24627
  128
24699
24628
  );
24700
24629
  }
24701
- initialize = async (signal, origin, forkPoint) => {
24630
+ initialize = async (signal, origin) => {
24702
24631
  await this.#initializeAgent(signal);
24703
24632
  let stored = this.#metrics.measureSync(
24704
24633
  "session-state-read",
@@ -24750,21 +24679,7 @@ var AcpProcessSession = class _AcpProcessSession {
24750
24679
  sessionId: nativeSessionIdSchema.parse(origin.nativeSessionId),
24751
24680
  cwd: this.#cwd,
24752
24681
  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
- }
24682
+ mcpServers: []
24768
24683
  },
24769
24684
  { cancellationSignal: signal }
24770
24685
  ),
@@ -25990,7 +25905,7 @@ var AcpSessionManager = class {
25990
25905
  return await this.#startRetainedSessionProcess(
25991
25906
  options,
25992
25907
  async () => await AcpProcessSession.start(
25993
- this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
25908
+ options.origin === void 0 && this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
25994
25909
  () => this.#observer,
25995
25910
  this.#store,
25996
25911
  metrics
@@ -26004,27 +25919,6 @@ var AcpSessionManager = class {
26004
25919
  this.#preparing.set(options.sessionId, operation);
26005
25920
  return await operation;
26006
25921
  }
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
25922
  async #replacePreparation(existing, options, metrics) {
26029
25923
  const operation = (async () => {
26030
25924
  try {
@@ -26554,26 +26448,7 @@ var AcpSessionManager = class {
26554
26448
  this.#endSessionUse(options.sessionId);
26555
26449
  }
26556
26450
  };
26557
- loadLinkedSessionHistory = async (options) => {
26558
- options.signal.throwIfAborted();
26559
- const stored = this.#store.read(options.sessionId);
26560
- if (!(stored instanceof FoundAcpStoredSession) || !stored.session.prompted) {
26561
- return null;
26562
- }
26563
- const linked = stored.session;
26564
- if (linked.agentId !== options.agent.id || linked.cwd !== options.cwd || linked.additionalDirectories.length !== options.additionalDirectories.length || linked.additionalDirectories.some((directory, index) => directory !== options.additionalDirectories[index])) {
26565
- throw new AcpExecutionError(
26566
- "The session belongs to another Agent or workspace",
26567
- {},
26568
- "session_identity_mismatch"
26569
- );
26570
- }
26571
- if (this.#nativeHistoryReader === null) {
26572
- return await this.loadSessionHistory(options);
26573
- }
26574
- return await this.#nativeHistoryReader.read(options, linked.nativeSessionId) ?? await this.loadSessionHistory(options);
26575
- };
26576
- openNativeSession = async (options, origin, loadHistory) => {
26451
+ openNativeSession = async (options, origin) => {
26577
26452
  const key = `${options.agent.id}:${origin.nativeSessionId}`;
26578
26453
  if (this.#nativeOperations.has(key)) {
26579
26454
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
@@ -26603,19 +26478,10 @@ var AcpSessionManager = class {
26603
26478
  }
26604
26479
  this.#nativeOperations.add(key);
26605
26480
  try {
26606
- const history = loadHistory ? await runtime.loadHistory(options.signal) : nativeHistoryNotRetained();
26607
26481
  return {
26608
26482
  prepared: runtime.prepared(),
26609
- sessionId: existing.sessionId,
26610
- history
26483
+ sessionId: existing.sessionId
26611
26484
  };
26612
- } catch (error62) {
26613
- await this.#retireSessionProcess(
26614
- existing.sessionId,
26615
- runtime,
26616
- async () => await runtime.closeProcess()
26617
- );
26618
- throw error62;
26619
26485
  } finally {
26620
26486
  this.#nativeOperations.delete(key);
26621
26487
  this.#notifyProcessCapacityChanged();
@@ -26634,16 +26500,10 @@ var AcpSessionManager = class {
26634
26500
  const openedKey = `${options.agent.id}:${runtime.nativeSessionId()}`;
26635
26501
  this.#nativeOperations.add(openedKey);
26636
26502
  try {
26637
- const history = loadHistory ? await runtime.loadHistory(options.signal) : nativeHistoryNotRetained();
26638
26503
  return {
26639
26504
  sessionId: options.sessionId,
26640
- prepared: runtime.prepared(),
26641
- history
26505
+ prepared: runtime.prepared()
26642
26506
  };
26643
- } catch (error62) {
26644
- this.#store.remove(options.sessionId);
26645
- await this.#retireSessionProcess(options.sessionId, runtime, async () => await runtime.closeProcess());
26646
- throw error62;
26647
26507
  } finally {
26648
26508
  this.#nativeOperations.delete(openedKey);
26649
26509
  this.#notifyProcessCapacityChanged();
@@ -26660,70 +26520,6 @@ var AcpSessionManager = class {
26660
26520
  this.#endSessionUse(options.sessionId);
26661
26521
  }
26662
26522
  };
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
26523
  deleteNativeSession = async (options, nativeSessionId) => {
26728
26524
  this.#beginNativeBrowserUse(options.sessionId);
26729
26525
  try {
@@ -35040,7 +34836,7 @@ function createNativeSessionRequestHandler(dependencies) {
35040
34836
  };
35041
34837
  const handle = (command) => {
35042
34838
  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");
34839
+ const parallelRead = command.action === "active-turn";
35044
34840
  if (pending.has(command.requestId) || pending.size >= 4 || !parallelRead && previous.some((request) => !request.controller.signal.aborted)) {
35045
34841
  reportOperationFailure(
35046
34842
  socket,
@@ -35061,7 +34857,7 @@ function createNativeSessionRequestHandler(dependencies) {
35061
34857
  const completion = (async () => {
35062
34858
  try {
35063
34859
  operationSignal.throwIfAborted();
35064
- const skipPrevious = command.kind === NATIVE_SESSION_REQUEST_KIND && command.action === "active-turn";
34860
+ const skipPrevious = command.action === "active-turn";
35065
34861
  if (previous.length > 0 && !skipPrevious) {
35066
34862
  await new Promise((resolve8, reject) => {
35067
34863
  const onAbort = () => reject(operationSignal.reason);
@@ -35079,13 +34875,13 @@ function createNativeSessionRequestHandler(dependencies) {
35079
34875
  });
35080
34876
  }
35081
34877
  operationSignal.throwIfAborted();
35082
- const result = command.kind === NATIVE_SESSION_REQUEST_KIND ? await nativeSessions.execute(command, operationSignal) : await nativeSessions.executeTurnFork(command, operationSignal);
34878
+ const result = await nativeSessions.execute(command, operationSignal);
35083
34879
  if (socket.readyState === WebSocket5.OPEN) {
35084
34880
  send(socket, result);
35085
34881
  }
35086
34882
  } catch (error62) {
35087
34883
  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";
34884
+ const event = "native_session_operation_failed";
35089
34885
  audit.record({
35090
34886
  commandId: command.requestId,
35091
34887
  sessionId: command.sessionId,
@@ -35096,7 +34892,7 @@ function createNativeSessionRequestHandler(dependencies) {
35096
34892
  event,
35097
34893
  command.requestId,
35098
34894
  {
35099
- ...command.kind === NATIVE_SESSION_REQUEST_KIND ? { action: command.action } : {},
34895
+ action: command.action,
35100
34896
  agentId: command.agentId,
35101
34897
  code: operationErrorCode(failure2),
35102
34898
  sessionId: command.sessionId
@@ -35124,7 +34920,6 @@ function createNativeSessionRequestHandler(dependencies) {
35124
34920
 
35125
34921
  // src/native-sessions/service.ts
35126
34922
  import { randomUUID as randomUUID4 } from "node:crypto";
35127
- import { basename as basename7 } from "node:path";
35128
34923
 
35129
34924
  // src/native-sessions/acp-history.ts
35130
34925
  async function readAcpHistory(sessions, directories, bindingId, options, nativeSessionId) {
@@ -35160,7 +34955,6 @@ async function readAcpHistory(sessions, directories, bindingId, options, nativeS
35160
34955
 
35161
34956
  // src/native-sessions/acp-adapter.ts
35162
34957
  var acpSessionAdapter = {
35163
- linkedHistory: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
35164
34958
  history: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
35165
34959
  preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
35166
34960
  };
@@ -35180,7 +34974,6 @@ async function verifiedHistory(context, full) {
35180
34974
  return snapshot.history;
35181
34975
  }
35182
34976
  var codexSessionAdapter = {
35183
- linkedHistory: async (context) => await verifiedHistory(context, true),
35184
34977
  history: async (context) => await verifiedHistory(context, true),
35185
34978
  // Codex enforces an exclusive writer per thread. Its read-only app-server
35186
34979
  // history path keeps externally owned conversations previewable.
@@ -35189,9 +34982,6 @@ var codexSessionAdapter = {
35189
34982
 
35190
34983
  // src/native-sessions/agent-adapter.ts
35191
34984
  var genericSessionAdapter = {
35192
- linkedHistory: async () => {
35193
- throw new AcpExecutionError("This Agent does not support Chat history", {}, "native_session_unsupported");
35194
- },
35195
34985
  history: async () => {
35196
34986
  throw new AcpExecutionError("Native history is unavailable for this Agent", {}, "native_session_unsupported");
35197
34987
  },
@@ -35251,42 +35041,6 @@ var NativeSessionService = class {
35251
35041
  turn: this.#activeTurn(command)
35252
35042
  };
35253
35043
  }
35254
- if (command.action === "linked-history") {
35255
- const nativeSessionId = nativeSessionIdSchema.parse(command.targetSessionId);
35256
- if (this.#sessions.hasPreparedSession(nativeSessionId, options.agent.id, cwd, additionalDirectories) && await this.#sessions.loadLinkedSessionHistory({ ...options, sessionId: nativeSessionId }) === null) {
35257
- this.record(command, "native_session_history_read");
35258
- return {
35259
- action: "linked-history",
35260
- history: {
35261
- status: "available",
35262
- messages: [],
35263
- truncated: false,
35264
- coveredCommandIds: [],
35265
- coveredMessageIds: []
35266
- },
35267
- kind: "native.session.result",
35268
- requestId: command.requestId,
35269
- sessionId: command.sessionId,
35270
- targetSessionId: command.targetSessionId
35271
- };
35272
- }
35273
- const history = await nativeSessionAdapter(options.agent.id).linkedHistory({
35274
- sessions: this.#sessions,
35275
- directories: this.#directories,
35276
- bindingId: command.bindingId,
35277
- options,
35278
- nativeSessionId
35279
- });
35280
- this.record(command, "native_session_history_read");
35281
- return {
35282
- action: "linked-history",
35283
- history,
35284
- kind: "native.session.result",
35285
- requestId: command.requestId,
35286
- sessionId: command.sessionId,
35287
- targetSessionId: command.targetSessionId
35288
- };
35289
- }
35290
35044
  if (command.action === "create") {
35291
35045
  if (!supportsNativeChat(options.agent.id)) {
35292
35046
  throw new AcpExecutionError(
@@ -35497,7 +35251,7 @@ var NativeSessionService = class {
35497
35251
  deletedSessionIds
35498
35252
  };
35499
35253
  }
35500
- const action = command.action === "import-only" ? "import" : command.action === "fork-only" ? "fork" : command.action;
35254
+ const action = command.action;
35501
35255
  if (action === "import" && !prepared.capabilities.loadSession && !prepared.capabilities.resumeSession) {
35502
35256
  throw new AcpExecutionError("This Agent cannot import native sessions", {}, "native_session_unsupported");
35503
35257
  }
@@ -35522,8 +35276,7 @@ var NativeSessionService = class {
35522
35276
  sessionId: command.targetSessionId,
35523
35277
  additionalDirectories: target.additionalDirectories
35524
35278
  },
35525
- { kind: action, nativeSessionId: target.info.sessionId },
35526
- command.action !== "import-only" && command.action !== "fork-only"
35279
+ { kind: action, nativeSessionId: target.info.sessionId }
35527
35280
  );
35528
35281
  signal.throwIfAborted();
35529
35282
  const ready = {
@@ -35547,8 +35300,7 @@ var NativeSessionService = class {
35547
35300
  action,
35548
35301
  ready,
35549
35302
  targetSessionId: command.targetSessionId,
35550
- title: target.info.title ?? "Untitled session",
35551
- history: opened.history
35303
+ title: target.info.title ?? "Untitled session"
35552
35304
  };
35553
35305
  };
35554
35306
  querySessions = async (sessionIds, signal) => {
@@ -35574,74 +35326,6 @@ var NativeSessionService = class {
35574
35326
  }
35575
35327
  return entries;
35576
35328
  };
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
35329
  authorizeEntry = async (command, options, info) => {
35646
35330
  try {
35647
35331
  const primary = await this.#directories.identify(command.bindingId, info.cwd, options.signal);
@@ -36514,7 +36198,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
36514
36198
  handleCatalogRefresh.handle(message);
36515
36199
  return;
36516
36200
  }
36517
- if (kind === NATIVE_SESSION_REQUEST_KIND || kind === NATIVE_SESSION_TURN_FORK_KIND) {
36201
+ if (kind === NATIVE_SESSION_REQUEST_KIND) {
36518
36202
  nativeRequestHandler.handle(message);
36519
36203
  return;
36520
36204
  }
@@ -36603,6 +36287,19 @@ async function runRelayConnection(config2, directories, audit, sessions, install
36603
36287
  );
36604
36288
  return;
36605
36289
  }
36290
+ if (kind === SESSION_QUERY_KIND) {
36291
+ const command2 = message;
36292
+ void nativeSessions.querySessions(command2.sessionIds, connectionController.signal).then((entries) => {
36293
+ send(socket, {
36294
+ entries,
36295
+ kind: SESSION_QUERIED_KIND,
36296
+ requestId: command2.requestId
36297
+ });
36298
+ }).catch((error62) => {
36299
+ reportOperationFailure(socket, command2.requestId, "", error62);
36300
+ });
36301
+ return;
36302
+ }
36606
36303
  if (kind === SESSION_PERMISSION_RESPOND_KIND) {
36607
36304
  const command2 = message;
36608
36305
  void sessions.respondPermission(command2).then(() => {