@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/cli.js CHANGED
@@ -3381,7 +3381,7 @@ var program = new Command();
3381
3381
  // package.json
3382
3382
  var package_default = {
3383
3383
  name: "@moxt-ai/mobius",
3384
- version: "0.0.107",
3384
+ version: "0.0.110",
3385
3385
  description: "Mobius CLI for pairing and running local AI agent services.",
3386
3386
  type: "module",
3387
3387
  bin: {
@@ -29095,8 +29095,6 @@ var nativeMessagePageSchema = external_exports.discriminatedUnion("status", [
29095
29095
  var NATIVE_SESSION_REQUEST_KIND = "native.session.request";
29096
29096
  var NATIVE_SESSION_RESULT_KIND = "native.session.result";
29097
29097
  var NATIVE_SESSION_CANCEL_KIND = "native.session.cancel";
29098
- var NATIVE_SESSION_TURN_FORK_REQUEST_KIND = "native.session.turn-fork.request";
29099
- var NATIVE_SESSION_TURN_FORK_KIND = "native.session.turn-fork";
29100
29098
  var ACTIVE_TURN_TEXT_LIMIT = 1e6;
29101
29099
  var identifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/);
29102
29100
  var directoryId = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/);
@@ -29112,31 +29110,8 @@ var identity = {
29112
29110
  bindingId: identifier,
29113
29111
  directoryId
29114
29112
  };
29115
- var turnForkIdentity = {
29116
- additionalDirectoryIds: external_exports.array(directoryId).max(16).readonly(),
29117
- agentId: identifier,
29118
- bindingId: identifier,
29119
- directoryId,
29120
- requestId: identifier,
29121
- sessionId: identifier,
29122
- sourceCommandId: identifier,
29123
- targetSessionId: identifier
29124
- };
29125
- var nativeSessionTurnForkRequestSchema = external_exports.strictObject({
29126
- ...turnForkIdentity,
29127
- kind: external_exports.literal(NATIVE_SESSION_TURN_FORK_REQUEST_KIND)
29128
- }).readonly();
29129
- var nativeSessionTurnForkCommandSchema = external_exports.strictObject({
29130
- ...turnForkIdentity,
29131
- kind: external_exports.literal(NATIVE_SESSION_TURN_FORK_KIND),
29132
- messageFingerprint: external_exports.string().regex(/^sha256:[a-f0-9]{64}$/),
29133
- messageId: external_exports.string().min(1).max(255),
29134
- messageOccurrence: external_exports.number().int().positive(),
29135
- title: external_exports.string().max(500)
29136
- }).readonly();
29137
29113
  var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
29138
29114
  external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
29139
- external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
29140
29115
  external_exports.strictObject({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifier }).readonly(),
29141
29116
  external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
29142
29117
  external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
@@ -29160,7 +29135,6 @@ var nativeSessionRequestSchema = external_exports.discriminatedUnion("action", [
29160
29135
  ]);
29161
29136
  var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
29162
29137
  external_exports.strictObject({ ...identity, action: external_exports.literal("create") }).readonly(),
29163
- external_exports.strictObject({ ...identity, action: external_exports.literal("linked-history"), targetSessionId: identifier }).readonly(),
29164
29138
  external_exports.strictObject({ ...identity, action: external_exports.literal("active-turn"), targetSessionId: identifier }).readonly(),
29165
29139
  external_exports.strictObject({ ...identity, action: external_exports.literal("preview"), entryId: identifier }).readonly(),
29166
29140
  external_exports.strictObject({ ...identity, action: external_exports.literal("history"), entryId: identifier }).readonly(),
@@ -29176,12 +29150,6 @@ var nativeSessionCommandSchema = external_exports.discriminatedUnion("action", [
29176
29150
  entryId: identifier,
29177
29151
  targetSessionId: identifier
29178
29152
  }).readonly(),
29179
- external_exports.strictObject({
29180
- ...identity,
29181
- action: external_exports.enum(["import-only", "fork-only"]),
29182
- entryId: identifier,
29183
- targetSessionId: identifier
29184
- }).readonly(),
29185
29153
  external_exports.strictObject({
29186
29154
  ...identity,
29187
29155
  action: external_exports.literal("delete"),
@@ -29204,12 +29172,6 @@ var resultEnvelope = {
29204
29172
  };
29205
29173
  var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
29206
29174
  external_exports.strictObject({ ...resultEnvelope, action: external_exports.literal("create"), nativeSessionId: identifier }).readonly(),
29207
- external_exports.strictObject({
29208
- ...resultEnvelope,
29209
- action: external_exports.literal("linked-history"),
29210
- targetSessionId: identifier,
29211
- history: sessionHistorySchema
29212
- }).readonly(),
29213
29175
  external_exports.strictObject({
29214
29176
  ...resultEnvelope,
29215
29177
  action: external_exports.literal("active-turn"),
@@ -29228,11 +29190,6 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
29228
29190
  state: external_exports.literal("running")
29229
29191
  }).readonly().nullable()
29230
29192
  }).readonly(),
29231
- external_exports.strictObject({
29232
- ...resultEnvelope,
29233
- action: external_exports.literal("unlinked-history"),
29234
- targetSessionId: identifier
29235
- }).readonly(),
29236
29193
  external_exports.strictObject({
29237
29194
  ...resultEnvelope,
29238
29195
  action: external_exports.literal("find"),
@@ -29250,7 +29207,6 @@ var nativeSessionResultSchema = external_exports.discriminatedUnion("action", [
29250
29207
  action: external_exports.enum(["import", "fork"]),
29251
29208
  targetSessionId: identifier,
29252
29209
  ready: sessionReadyEventSchema,
29253
- history: sessionHistorySchema,
29254
29210
  title: external_exports.string().max(500)
29255
29211
  }).readonly(),
29256
29212
  external_exports.strictObject({
@@ -29291,8 +29247,6 @@ var decodeNativeSessionResult = (encoded) => decode4(nativeSessionResultSchema,
29291
29247
  var encodeNativeSessionResult = (value) => JSON.stringify(nativeSessionResultSchema.parse(value));
29292
29248
  var decodeNativeSessionCancel = (encoded) => decode4(nativeSessionCancelSchema, encoded);
29293
29249
  var encodeNativeSessionCancel = (value) => JSON.stringify(nativeSessionCancelSchema.parse(value));
29294
- var decodeNativeSessionTurnForkCommand = (encoded) => decode4(nativeSessionTurnForkCommandSchema, encoded);
29295
- var encodeNativeSessionTurnForkCommand = (value) => JSON.stringify(nativeSessionTurnForkCommandSchema.parse(value));
29296
29250
 
29297
29251
  // ../protocol/src/session-events.ts
29298
29252
  var SESSION_EVENT_KIND = "session.event";
@@ -29479,11 +29433,6 @@ var serviceToDaemonSignatures = {
29479
29433
  encodeNativeSessionCommand,
29480
29434
  decodeNativeSessionCommand
29481
29435
  ),
29482
- [NATIVE_SESSION_TURN_FORK_KIND]: defineMessageSignature(
29483
- NATIVE_SESSION_TURN_FORK_KIND,
29484
- encodeNativeSessionTurnForkCommand,
29485
- decodeNativeSessionTurnForkCommand
29486
- ),
29487
29436
  [RUNTIME_HEARTBEAT_ACK_KIND]: defineMessageSignature(
29488
29437
  RUNTIME_HEARTBEAT_ACK_KIND,
29489
29438
  encodeRuntimeHeartbeatAckEvent,
@@ -32384,15 +32333,6 @@ var PendingElicitation = class {
32384
32333
  var PROCESS_STOP_TIMEOUT_MILLISECONDS = 1e3;
32385
32334
  var MAX_PRE_SESSION_UPDATES = 100;
32386
32335
  var MAX_PRE_SESSION_UPDATE_BYTES = 1024 * 1024;
32387
- function nativeHistoryNotRetained() {
32388
- return {
32389
- cause: {
32390
- code: "native_history_not_retained",
32391
- message: "Native message history is not retained in the cloud for this Session."
32392
- },
32393
- status: "unavailable"
32394
- };
32395
- }
32396
32336
  var NullAcpSessionObserver = class {
32397
32337
  onCommands = () => Promise.resolve();
32398
32338
  onConfig = () => Promise.resolve();
@@ -32679,17 +32619,6 @@ var AcpProcessSession = class _AcpProcessSession {
32679
32619
  async (runtime) => await runtime.#initializeAgent(options.signal),
32680
32620
  unmeasuredOperationMetrics
32681
32621
  );
32682
- static startSessionForkAtTurn = async (options, sourceNativeSessionId, forkPoint, getObserver, store) => await _AcpProcessSession.#start(
32683
- options,
32684
- getObserver,
32685
- store,
32686
- async (runtime) => await runtime.initialize(
32687
- options.signal,
32688
- { kind: "fork", nativeSessionId: sourceNativeSessionId },
32689
- forkPoint
32690
- ),
32691
- unmeasuredOperationMetrics
32692
- );
32693
32622
  belongsTo = (agentId, cwd, additionalDirectories) => this.#agentId === agentId && this.#cwd === cwd && arraysEqual(this.#additionalDirectories, additionalDirectories);
32694
32623
  usesEnvironment = (environment) => recordsEqual(this.#environment, environment);
32695
32624
  canRebind = () => !this.#prompted && !this.#turn.running;
@@ -32872,7 +32801,7 @@ var AcpProcessSession = class _AcpProcessSession {
32872
32801
  128
32873
32802
  );
32874
32803
  }
32875
- initialize = async (signal, origin, forkPoint) => {
32804
+ initialize = async (signal, origin) => {
32876
32805
  await this.#initializeAgent(signal);
32877
32806
  let stored = this.#metrics.measureSync(
32878
32807
  "session-state-read",
@@ -32924,21 +32853,7 @@ var AcpProcessSession = class _AcpProcessSession {
32924
32853
  sessionId: nativeSessionIdSchema.parse(origin.nativeSessionId),
32925
32854
  cwd: this.#cwd,
32926
32855
  additionalDirectories: [...this.#additionalDirectories],
32927
- mcpServers: [],
32928
- ...forkPoint === void 0 ? {} : {
32929
- _meta: {
32930
- jetbrains: {
32931
- air: {
32932
- fork: {
32933
- version: 1,
32934
- messageFingerprint: forkPoint.messageFingerprint,
32935
- messageId: forkPoint.messageId,
32936
- messageOccurrence: forkPoint.messageOccurrence
32937
- }
32938
- }
32939
- }
32940
- }
32941
- }
32856
+ mcpServers: []
32942
32857
  },
32943
32858
  { cancellationSignal: signal }
32944
32859
  ),
@@ -34164,7 +34079,7 @@ var AcpSessionManager = class {
34164
34079
  return await this.#startRetainedSessionProcess(
34165
34080
  options,
34166
34081
  async () => await AcpProcessSession.start(
34167
- this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
34082
+ 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,
34168
34083
  () => this.#observer,
34169
34084
  this.#store,
34170
34085
  metrics
@@ -34178,27 +34093,6 @@ var AcpSessionManager = class {
34178
34093
  this.#preparing.set(options.sessionId, operation);
34179
34094
  return await operation;
34180
34095
  }
34181
- async #startSessionForkAtTurnPreparation(options, sourceNativeSessionId, forkPoint) {
34182
- const operation = (async () => {
34183
- try {
34184
- return await this.#startRetainedSessionProcess(
34185
- options,
34186
- async () => await AcpProcessSession.startSessionForkAtTurn(
34187
- options,
34188
- sourceNativeSessionId,
34189
- forkPoint,
34190
- () => this.#observer,
34191
- this.#store
34192
- )
34193
- );
34194
- } finally {
34195
- this.#preparing.delete(options.sessionId);
34196
- this.#notifyProcessCapacityChanged();
34197
- }
34198
- })();
34199
- this.#preparing.set(options.sessionId, operation);
34200
- return await operation;
34201
- }
34202
34096
  async #replacePreparation(existing, options, metrics) {
34203
34097
  const operation = (async () => {
34204
34098
  try {
@@ -34728,26 +34622,7 @@ var AcpSessionManager = class {
34728
34622
  this.#endSessionUse(options.sessionId);
34729
34623
  }
34730
34624
  };
34731
- loadLinkedSessionHistory = async (options) => {
34732
- options.signal.throwIfAborted();
34733
- const stored = this.#store.read(options.sessionId);
34734
- if (!(stored instanceof FoundAcpStoredSession) || !stored.session.prompted) {
34735
- return null;
34736
- }
34737
- const linked = stored.session;
34738
- 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])) {
34739
- throw new AcpExecutionError(
34740
- "The session belongs to another Agent or workspace",
34741
- {},
34742
- "session_identity_mismatch"
34743
- );
34744
- }
34745
- if (this.#nativeHistoryReader === null) {
34746
- return await this.loadSessionHistory(options);
34747
- }
34748
- return await this.#nativeHistoryReader.read(options, linked.nativeSessionId) ?? await this.loadSessionHistory(options);
34749
- };
34750
- openNativeSession = async (options, origin, loadHistory) => {
34625
+ openNativeSession = async (options, origin) => {
34751
34626
  const key = `${options.agent.id}:${origin.nativeSessionId}`;
34752
34627
  if (this.#nativeOperations.has(key)) {
34753
34628
  throw new AcpExecutionError("The native session is being managed", {}, "session_busy");
@@ -34777,19 +34652,10 @@ var AcpSessionManager = class {
34777
34652
  }
34778
34653
  this.#nativeOperations.add(key);
34779
34654
  try {
34780
- const history = loadHistory ? await runtime.loadHistory(options.signal) : nativeHistoryNotRetained();
34781
34655
  return {
34782
34656
  prepared: runtime.prepared(),
34783
- sessionId: existing.sessionId,
34784
- history
34657
+ sessionId: existing.sessionId
34785
34658
  };
34786
- } catch (error62) {
34787
- await this.#retireSessionProcess(
34788
- existing.sessionId,
34789
- runtime,
34790
- async () => await runtime.closeProcess()
34791
- );
34792
- throw error62;
34793
34659
  } finally {
34794
34660
  this.#nativeOperations.delete(key);
34795
34661
  this.#notifyProcessCapacityChanged();
@@ -34808,16 +34674,10 @@ var AcpSessionManager = class {
34808
34674
  const openedKey = `${options.agent.id}:${runtime.nativeSessionId()}`;
34809
34675
  this.#nativeOperations.add(openedKey);
34810
34676
  try {
34811
- const history = loadHistory ? await runtime.loadHistory(options.signal) : nativeHistoryNotRetained();
34812
34677
  return {
34813
34678
  sessionId: options.sessionId,
34814
- prepared: runtime.prepared(),
34815
- history
34679
+ prepared: runtime.prepared()
34816
34680
  };
34817
- } catch (error62) {
34818
- this.#store.remove(options.sessionId);
34819
- await this.#retireSessionProcess(options.sessionId, runtime, async () => await runtime.closeProcess());
34820
- throw error62;
34821
34681
  } finally {
34822
34682
  this.#nativeOperations.delete(openedKey);
34823
34683
  this.#notifyProcessCapacityChanged();
@@ -34834,70 +34694,6 @@ var AcpSessionManager = class {
34834
34694
  this.#endSessionUse(options.sessionId);
34835
34695
  }
34836
34696
  };
34837
- forkSessionAtTurn = async (options, sourceSessionId, forkPoint) => {
34838
- if (sourceSessionId === options.sessionId) {
34839
- throw new AcpExecutionError(
34840
- "The fork destination must be a new conversation",
34841
- {},
34842
- "session_identity_mismatch"
34843
- );
34844
- }
34845
- const source = this.#store.read(sourceSessionId);
34846
- if (!(source instanceof FoundAcpStoredSession) || !source.session.prompted) {
34847
- throw new AcpExecutionError(
34848
- "The source conversation has no resumable native Agent session",
34849
- {},
34850
- "native_session_not_found"
34851
- );
34852
- }
34853
- if (source.session.agentId !== options.agent.id || source.session.cwd !== options.cwd || !arraysEqual(source.session.additionalDirectories, options.additionalDirectories)) {
34854
- throw new AcpExecutionError(
34855
- "The source conversation execution target does not match the fork request",
34856
- {},
34857
- "native_session_target_changed"
34858
- );
34859
- }
34860
- const key = `${options.agent.id}:${source.session.nativeSessionId}`;
34861
- const linked = this.#store.findNative(options.agent.id, source.session.nativeSessionId);
34862
- if (this.#nativeOperations.has(key) || linked.some((entry) => this.#activeSessionIds.has(entry.sessionId) || this.#preparing.has(entry.sessionId))) {
34863
- throw new AcpExecutionError(
34864
- "Wait for the source conversation's running operation to finish",
34865
- {},
34866
- "session_busy"
34867
- );
34868
- }
34869
- 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) {
34870
- throw new AcpExecutionError("The destination conversation already exists", {}, "session_identity_mismatch");
34871
- }
34872
- this.#beginSessionUse(options.sessionId);
34873
- this.#nativeOperations.add(key);
34874
- try {
34875
- const runtime = await this.#startSessionForkAtTurnPreparation(
34876
- options,
34877
- source.session.nativeSessionId,
34878
- forkPoint
34879
- );
34880
- const openedKey = `${options.agent.id}:${runtime.nativeSessionId()}`;
34881
- this.#nativeOperations.add(openedKey);
34882
- try {
34883
- return {
34884
- history: await runtime.loadHistory(options.signal),
34885
- prepared: runtime.prepared(),
34886
- sessionId: options.sessionId
34887
- };
34888
- } catch (error62) {
34889
- this.#store.remove(options.sessionId);
34890
- await this.#retireSessionProcess(options.sessionId, runtime, async () => await runtime.closeProcess());
34891
- throw error62;
34892
- } finally {
34893
- this.#nativeOperations.delete(openedKey);
34894
- this.#notifyProcessCapacityChanged();
34895
- }
34896
- } finally {
34897
- this.#nativeOperations.delete(key);
34898
- this.#endSessionUse(options.sessionId);
34899
- }
34900
- };
34901
34697
  deleteNativeSession = async (options, nativeSessionId) => {
34902
34698
  this.#beginNativeBrowserUse(options.sessionId);
34903
34699
  try {
@@ -38478,7 +38274,7 @@ function createNativeSessionRequestHandler(dependencies) {
38478
38274
  };
38479
38275
  const handle = (command) => {
38480
38276
  const previous = [...pending.values()].filter((request) => request.agentId === command.agentId);
38481
- const parallelRead = command.kind === NATIVE_SESSION_REQUEST_KIND && (command.action === "linked-history" || command.action === "active-turn");
38277
+ const parallelRead = command.action === "active-turn";
38482
38278
  if (pending.has(command.requestId) || pending.size >= 4 || !parallelRead && previous.some((request) => !request.controller.signal.aborted)) {
38483
38279
  reportOperationFailure(
38484
38280
  socket,
@@ -38499,7 +38295,7 @@ function createNativeSessionRequestHandler(dependencies) {
38499
38295
  const completion = (async () => {
38500
38296
  try {
38501
38297
  operationSignal.throwIfAborted();
38502
- const skipPrevious = command.kind === NATIVE_SESSION_REQUEST_KIND && command.action === "active-turn";
38298
+ const skipPrevious = command.action === "active-turn";
38503
38299
  if (previous.length > 0 && !skipPrevious) {
38504
38300
  await new Promise((resolve8, reject) => {
38505
38301
  const onAbort = () => reject(operationSignal.reason);
@@ -38517,13 +38313,13 @@ function createNativeSessionRequestHandler(dependencies) {
38517
38313
  });
38518
38314
  }
38519
38315
  operationSignal.throwIfAborted();
38520
- const result = command.kind === NATIVE_SESSION_REQUEST_KIND ? await nativeSessions.execute(command, operationSignal) : await nativeSessions.executeTurnFork(command, operationSignal);
38316
+ const result = await nativeSessions.execute(command, operationSignal);
38521
38317
  if (socket.readyState === WebSocket5.OPEN) {
38522
38318
  send(socket, result);
38523
38319
  }
38524
38320
  } catch (error62) {
38525
38321
  const failure2 = operationSignal.aborted ? controller.signal.reason ?? new AcpExecutionError("Native session operation cancelled", {}, "native_session_cancelled") : error62;
38526
- const event = command.kind === NATIVE_SESSION_REQUEST_KIND ? "native_session_operation_failed" : "native_session_turn_fork_failed";
38322
+ const event = "native_session_operation_failed";
38527
38323
  audit.record({
38528
38324
  commandId: command.requestId,
38529
38325
  sessionId: command.sessionId,
@@ -38534,7 +38330,7 @@ function createNativeSessionRequestHandler(dependencies) {
38534
38330
  event,
38535
38331
  command.requestId,
38536
38332
  {
38537
- ...command.kind === NATIVE_SESSION_REQUEST_KIND ? { action: command.action } : {},
38333
+ action: command.action,
38538
38334
  agentId: command.agentId,
38539
38335
  code: operationErrorCode(failure2),
38540
38336
  sessionId: command.sessionId
@@ -38562,7 +38358,6 @@ function createNativeSessionRequestHandler(dependencies) {
38562
38358
 
38563
38359
  // src/native-sessions/service.ts
38564
38360
  import { randomUUID as randomUUID4 } from "node:crypto";
38565
- import { basename as basename7 } from "node:path";
38566
38361
 
38567
38362
  // src/native-sessions/acp-history.ts
38568
38363
  async function readAcpHistory(sessions, directories, bindingId, options, nativeSessionId) {
@@ -38598,7 +38393,6 @@ async function readAcpHistory(sessions, directories, bindingId, options, nativeS
38598
38393
 
38599
38394
  // src/native-sessions/acp-adapter.ts
38600
38395
  var acpSessionAdapter = {
38601
- linkedHistory: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
38602
38396
  history: async ({ sessions, directories, bindingId, options, nativeSessionId }) => await readAcpHistory(sessions, directories, bindingId, options, nativeSessionId),
38603
38397
  preview: async ({ sessions, options, nativeSessionId }) => await sessions.previewNativeSession(options, nativeSessionId)
38604
38398
  };
@@ -38618,7 +38412,6 @@ async function verifiedHistory(context, full) {
38618
38412
  return snapshot.history;
38619
38413
  }
38620
38414
  var codexSessionAdapter = {
38621
- linkedHistory: async (context) => await verifiedHistory(context, true),
38622
38415
  history: async (context) => await verifiedHistory(context, true),
38623
38416
  // Codex enforces an exclusive writer per thread. Its read-only app-server
38624
38417
  // history path keeps externally owned conversations previewable.
@@ -38627,9 +38420,6 @@ var codexSessionAdapter = {
38627
38420
 
38628
38421
  // src/native-sessions/agent-adapter.ts
38629
38422
  var genericSessionAdapter = {
38630
- linkedHistory: async () => {
38631
- throw new AcpExecutionError("This Agent does not support Chat history", {}, "native_session_unsupported");
38632
- },
38633
38423
  history: async () => {
38634
38424
  throw new AcpExecutionError("Native history is unavailable for this Agent", {}, "native_session_unsupported");
38635
38425
  },
@@ -38689,42 +38479,6 @@ var NativeSessionService = class {
38689
38479
  turn: this.#activeTurn(command)
38690
38480
  };
38691
38481
  }
38692
- if (command.action === "linked-history") {
38693
- const nativeSessionId = nativeSessionIdSchema.parse(command.targetSessionId);
38694
- if (this.#sessions.hasPreparedSession(nativeSessionId, options.agent.id, cwd, additionalDirectories) && await this.#sessions.loadLinkedSessionHistory({ ...options, sessionId: nativeSessionId }) === null) {
38695
- this.record(command, "native_session_history_read");
38696
- return {
38697
- action: "linked-history",
38698
- history: {
38699
- status: "available",
38700
- messages: [],
38701
- truncated: false,
38702
- coveredCommandIds: [],
38703
- coveredMessageIds: []
38704
- },
38705
- kind: "native.session.result",
38706
- requestId: command.requestId,
38707
- sessionId: command.sessionId,
38708
- targetSessionId: command.targetSessionId
38709
- };
38710
- }
38711
- const history = await nativeSessionAdapter(options.agent.id).linkedHistory({
38712
- sessions: this.#sessions,
38713
- directories: this.#directories,
38714
- bindingId: command.bindingId,
38715
- options,
38716
- nativeSessionId
38717
- });
38718
- this.record(command, "native_session_history_read");
38719
- return {
38720
- action: "linked-history",
38721
- history,
38722
- kind: "native.session.result",
38723
- requestId: command.requestId,
38724
- sessionId: command.sessionId,
38725
- targetSessionId: command.targetSessionId
38726
- };
38727
- }
38728
38482
  if (command.action === "create") {
38729
38483
  if (!supportsNativeChat(options.agent.id)) {
38730
38484
  throw new AcpExecutionError(
@@ -38935,7 +38689,7 @@ var NativeSessionService = class {
38935
38689
  deletedSessionIds
38936
38690
  };
38937
38691
  }
38938
- const action = command.action === "import-only" ? "import" : command.action === "fork-only" ? "fork" : command.action;
38692
+ const action = command.action;
38939
38693
  if (action === "import" && !prepared.capabilities.loadSession && !prepared.capabilities.resumeSession) {
38940
38694
  throw new AcpExecutionError("This Agent cannot import native sessions", {}, "native_session_unsupported");
38941
38695
  }
@@ -38960,8 +38714,7 @@ var NativeSessionService = class {
38960
38714
  sessionId: command.targetSessionId,
38961
38715
  additionalDirectories: target.additionalDirectories
38962
38716
  },
38963
- { kind: action, nativeSessionId: target.info.sessionId },
38964
- command.action !== "import-only" && command.action !== "fork-only"
38717
+ { kind: action, nativeSessionId: target.info.sessionId }
38965
38718
  );
38966
38719
  signal.throwIfAborted();
38967
38720
  const ready = {
@@ -38985,8 +38738,7 @@ var NativeSessionService = class {
38985
38738
  action,
38986
38739
  ready,
38987
38740
  targetSessionId: command.targetSessionId,
38988
- title: target.info.title ?? "Untitled session",
38989
- history: opened.history
38741
+ title: target.info.title ?? "Untitled session"
38990
38742
  };
38991
38743
  };
38992
38744
  querySessions = async (sessionIds, signal) => {
@@ -39012,74 +38764,6 @@ var NativeSessionService = class {
39012
38764
  }
39013
38765
  return entries;
39014
38766
  };
39015
- executeTurnFork = async (command, signal) => {
39016
- signal.throwIfAborted();
39017
- const cwd = await this.#directories.resolve(this.#config.bindingId, command.directoryId, signal);
39018
- const additionalDirectories = [];
39019
- const additionalEntries = [];
39020
- const resolvedPaths = /* @__PURE__ */ new Set([cwd]);
39021
- for (const directoryId2 of command.additionalDirectoryIds) {
39022
- const path3 = await this.#directories.resolve(this.#config.bindingId, directoryId2, signal);
39023
- if (resolvedPaths.has(path3)) {
39024
- throw new LocalAuthorizationError("Workspace directories must resolve to distinct locations");
39025
- }
39026
- resolvedPaths.add(path3);
39027
- additionalDirectories.push(path3);
39028
- additionalEntries.push({ directoryId: directoryId2, name: basename7(path3) });
39029
- }
39030
- const listing = await this.#directories.list(this.#config.bindingId, command.directoryId, signal);
39031
- const opened = await this.#sessions.forkSessionAtTurn(
39032
- {
39033
- additionalDirectories,
39034
- agent: this.#config.catalog.find(command.agentId),
39035
- cwd,
39036
- sessionId: command.targetSessionId,
39037
- signal
39038
- },
39039
- command.sessionId,
39040
- {
39041
- messageFingerprint: command.messageFingerprint,
39042
- messageId: command.messageId,
39043
- messageOccurrence: command.messageOccurrence
39044
- }
39045
- );
39046
- signal.throwIfAborted();
39047
- const ready = {
39048
- additionalDirectories: additionalEntries,
39049
- agentId: command.agentId,
39050
- agentName: opened.prepared.agentName,
39051
- agentVersion: opened.prepared.agentVersion,
39052
- capabilities: opened.prepared.capabilities,
39053
- commands: opened.prepared.commands,
39054
- configOptions: opened.prepared.configOptions,
39055
- directoryId: command.directoryId,
39056
- directoryLabel: listing.directoryLabel,
39057
- kind: "session.ready",
39058
- requestId: command.requestId,
39059
- restored: true,
39060
- sessionId: opened.sessionId
39061
- };
39062
- this.#audit.record({
39063
- commandId: command.requestId,
39064
- details: {
39065
- agentId: command.agentId,
39066
- messageId: command.messageId,
39067
- sourceCommandId: command.sourceCommandId
39068
- },
39069
- event: "native_session_turn_forked",
39070
- sessionId: command.sessionId
39071
- });
39072
- return {
39073
- action: "fork",
39074
- history: opened.history,
39075
- kind: "native.session.result",
39076
- ready,
39077
- requestId: command.requestId,
39078
- sessionId: command.sessionId,
39079
- targetSessionId: command.targetSessionId,
39080
- title: command.title
39081
- };
39082
- };
39083
38767
  authorizeEntry = async (command, options, info) => {
39084
38768
  try {
39085
38769
  const primary = await this.#directories.identify(command.bindingId, info.cwd, options.signal);
@@ -39972,7 +39656,7 @@ async function runRelayConnection(config2, directories, audit, sessions, install
39972
39656
  handleCatalogRefresh.handle(message);
39973
39657
  return;
39974
39658
  }
39975
- if (kind === NATIVE_SESSION_REQUEST_KIND || kind === NATIVE_SESSION_TURN_FORK_KIND) {
39659
+ if (kind === NATIVE_SESSION_REQUEST_KIND) {
39976
39660
  nativeRequestHandler.handle(message);
39977
39661
  return;
39978
39662
  }
@@ -40061,6 +39745,19 @@ async function runRelayConnection(config2, directories, audit, sessions, install
40061
39745
  );
40062
39746
  return;
40063
39747
  }
39748
+ if (kind === SESSION_QUERY_KIND) {
39749
+ const command2 = message;
39750
+ void nativeSessions.querySessions(command2.sessionIds, connectionController.signal).then((entries) => {
39751
+ send(socket, {
39752
+ entries,
39753
+ kind: SESSION_QUERIED_KIND,
39754
+ requestId: command2.requestId
39755
+ });
39756
+ }).catch((error62) => {
39757
+ reportOperationFailure(socket, command2.requestId, "", error62);
39758
+ });
39759
+ return;
39760
+ }
40064
39761
  if (kind === SESSION_PERMISSION_RESPOND_KIND) {
40065
39762
  const command2 = message;
40066
39763
  void sessions.respondPermission(command2).then(() => {