@adhdev/session-host-core 1.0.82-rc.27 → 1.0.82-rc.29

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.d.mts CHANGED
@@ -148,6 +148,26 @@ interface ResizeSessionPayload {
148
148
  interface StopSessionPayload {
149
149
  sessionId: string;
150
150
  }
151
+ interface MeshWriterAssignment {
152
+ meshId: string;
153
+ nodeId: string;
154
+ taskId: string;
155
+ attemptId: string;
156
+ generation: number;
157
+ dispatchNonce: number;
158
+ ownerDaemonId: string;
159
+ }
160
+ interface MeshWriterStopTarget {
161
+ runtimeKey: string;
162
+ startedAt: number;
163
+ osPid: number;
164
+ providerType: string;
165
+ assignment: MeshWriterAssignment;
166
+ }
167
+ interface StopMeshWriterPayload extends MeshWriterStopTarget {
168
+ sessionId: string;
169
+ clientId: string;
170
+ }
151
171
  interface DeleteSessionPayload {
152
172
  sessionId: string;
153
173
  /** Stop a live runtime before deleting the persisted record. */
@@ -304,6 +324,9 @@ type SessionHostRequest = {
304
324
  } | {
305
325
  type: 'stop_session';
306
326
  payload: StopSessionPayload;
327
+ } | {
328
+ type: 'stop_mesh_writer';
329
+ payload: StopMeshWriterPayload;
307
330
  } | {
308
331
  type: 'delete_session';
309
332
  payload: DeleteSessionPayload;
@@ -887,4 +910,4 @@ interface SessionHostControlTransport {
887
910
  */
888
911
  declare function createSessionHostControlPlane(transport: SessionHostControlTransport): SessionHostControlPlane;
889
912
 
890
- export { type AcquireWritePayload, type AttachSessionPayload, CLI_CHILD_NICE_ENV, CLI_CHILD_NICE_INCREMENT, CLI_CHILD_SCHEDULING_ENV, type ClearSessionBufferPayload, type CreateSessionPayload, DEFAULT_CONFIG_DIR_NAME, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type GetTerminalSnapshotPayload, type HostUpgradeLeasePayload, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, SESSION_HOST_SUPPORTED_REQUEST_TYPES, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionClientType, type SessionHostCategory, SessionHostClient, type SessionHostClientOptions, type SessionHostControlPlane, type SessionHostControlTransport, type SessionHostDiagnostics, type SessionHostDisconnectInfo, type SessionHostDisconnectReason, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEndpointOptions, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostRequestType, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostSnapshot, type SessionHostSurfaceKind, type SessionHostSurfaceRecordLike, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTerminalSnapshot, type SessionTerminalState, type SessionTermination, type SessionTransport, type SessionWriteOwner, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, buildRuntimeDisplayName, buildRuntimeKey, canonicalizeInstancePath, classifyTermination, createCliChildPriorityPolicy, createLineParser, createResponseEnvelope, createSessionHostControlPlane, disconnectSessionHostClients, ensureNodePtySpawnHelperPermissions, findConnectedSessionHostClient, formatRuntimeOwner, getDefaultSessionHostEndpoint, getSessionHostRecoveryLabel, getSessionHostSurfaceKind, getWorkspaceLabel, hiddenSpawn as hiddenSpawnProcess, isDefaultInstanceConfigDir, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, isTerminalRecord, partitionSessionHostDiagnosticsSessions, partitionSessionHostRecords, replayLaunchEnv, resolveAttachableRuntimeRecord, resolveInstanceConfigDir, resolveRuntimeRecord, resolveSessionHostIpcKey, sanitizeSpawnEnv, spawnCliChild, writeEnvelope };
913
+ export { type AcquireWritePayload, type AttachSessionPayload, CLI_CHILD_NICE_ENV, CLI_CHILD_NICE_INCREMENT, CLI_CHILD_SCHEDULING_ENV, type ClearSessionBufferPayload, type CreateSessionPayload, DEFAULT_CONFIG_DIR_NAME, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type GetTerminalSnapshotPayload, type HostUpgradeLeasePayload, type MeshWriterAssignment, type MeshWriterStopTarget, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, SESSION_HOST_SUPPORTED_REQUEST_TYPES, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionClientType, type SessionHostCategory, SessionHostClient, type SessionHostClientOptions, type SessionHostControlPlane, type SessionHostControlTransport, type SessionHostDiagnostics, type SessionHostDisconnectInfo, type SessionHostDisconnectReason, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEndpointOptions, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostRequestType, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostSnapshot, type SessionHostSurfaceKind, type SessionHostSurfaceRecordLike, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTerminalSnapshot, type SessionTerminalState, type SessionTermination, type SessionTransport, type SessionWriteOwner, type StopMeshWriterPayload, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, buildRuntimeDisplayName, buildRuntimeKey, canonicalizeInstancePath, classifyTermination, createCliChildPriorityPolicy, createLineParser, createResponseEnvelope, createSessionHostControlPlane, disconnectSessionHostClients, ensureNodePtySpawnHelperPermissions, findConnectedSessionHostClient, formatRuntimeOwner, getDefaultSessionHostEndpoint, getSessionHostRecoveryLabel, getSessionHostSurfaceKind, getWorkspaceLabel, hiddenSpawn as hiddenSpawnProcess, isDefaultInstanceConfigDir, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, isTerminalRecord, partitionSessionHostDiagnosticsSessions, partitionSessionHostRecords, replayLaunchEnv, resolveAttachableRuntimeRecord, resolveInstanceConfigDir, resolveRuntimeRecord, resolveSessionHostIpcKey, sanitizeSpawnEnv, spawnCliChild, writeEnvelope };
package/dist/index.d.ts CHANGED
@@ -148,6 +148,26 @@ interface ResizeSessionPayload {
148
148
  interface StopSessionPayload {
149
149
  sessionId: string;
150
150
  }
151
+ interface MeshWriterAssignment {
152
+ meshId: string;
153
+ nodeId: string;
154
+ taskId: string;
155
+ attemptId: string;
156
+ generation: number;
157
+ dispatchNonce: number;
158
+ ownerDaemonId: string;
159
+ }
160
+ interface MeshWriterStopTarget {
161
+ runtimeKey: string;
162
+ startedAt: number;
163
+ osPid: number;
164
+ providerType: string;
165
+ assignment: MeshWriterAssignment;
166
+ }
167
+ interface StopMeshWriterPayload extends MeshWriterStopTarget {
168
+ sessionId: string;
169
+ clientId: string;
170
+ }
151
171
  interface DeleteSessionPayload {
152
172
  sessionId: string;
153
173
  /** Stop a live runtime before deleting the persisted record. */
@@ -304,6 +324,9 @@ type SessionHostRequest = {
304
324
  } | {
305
325
  type: 'stop_session';
306
326
  payload: StopSessionPayload;
327
+ } | {
328
+ type: 'stop_mesh_writer';
329
+ payload: StopMeshWriterPayload;
307
330
  } | {
308
331
  type: 'delete_session';
309
332
  payload: DeleteSessionPayload;
@@ -887,4 +910,4 @@ interface SessionHostControlTransport {
887
910
  */
888
911
  declare function createSessionHostControlPlane(transport: SessionHostControlTransport): SessionHostControlPlane;
889
912
 
890
- export { type AcquireWritePayload, type AttachSessionPayload, CLI_CHILD_NICE_ENV, CLI_CHILD_NICE_INCREMENT, CLI_CHILD_SCHEDULING_ENV, type ClearSessionBufferPayload, type CreateSessionPayload, DEFAULT_CONFIG_DIR_NAME, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type GetTerminalSnapshotPayload, type HostUpgradeLeasePayload, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, SESSION_HOST_SUPPORTED_REQUEST_TYPES, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionClientType, type SessionHostCategory, SessionHostClient, type SessionHostClientOptions, type SessionHostControlPlane, type SessionHostControlTransport, type SessionHostDiagnostics, type SessionHostDisconnectInfo, type SessionHostDisconnectReason, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEndpointOptions, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostRequestType, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostSnapshot, type SessionHostSurfaceKind, type SessionHostSurfaceRecordLike, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTerminalSnapshot, type SessionTerminalState, type SessionTermination, type SessionTransport, type SessionWriteOwner, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, buildRuntimeDisplayName, buildRuntimeKey, canonicalizeInstancePath, classifyTermination, createCliChildPriorityPolicy, createLineParser, createResponseEnvelope, createSessionHostControlPlane, disconnectSessionHostClients, ensureNodePtySpawnHelperPermissions, findConnectedSessionHostClient, formatRuntimeOwner, getDefaultSessionHostEndpoint, getSessionHostRecoveryLabel, getSessionHostSurfaceKind, getWorkspaceLabel, hiddenSpawn as hiddenSpawnProcess, isDefaultInstanceConfigDir, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, isTerminalRecord, partitionSessionHostDiagnosticsSessions, partitionSessionHostRecords, replayLaunchEnv, resolveAttachableRuntimeRecord, resolveInstanceConfigDir, resolveRuntimeRecord, resolveSessionHostIpcKey, sanitizeSpawnEnv, spawnCliChild, writeEnvelope };
913
+ export { type AcquireWritePayload, type AttachSessionPayload, CLI_CHILD_NICE_ENV, CLI_CHILD_NICE_INCREMENT, CLI_CHILD_SCHEDULING_ENV, type ClearSessionBufferPayload, type CreateSessionPayload, DEFAULT_CONFIG_DIR_NAME, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, type DetachSessionPayload, type ForceDetachClientPayload, type GetHostDiagnosticsPayload, type GetSnapshotPayload, type GetTerminalSnapshotPayload, type HostUpgradeLeasePayload, type MeshWriterAssignment, type MeshWriterStopTarget, type PruneDuplicateSessionsPayload, type ReleaseWritePayload, type ResizeSessionPayload, type RestartSessionPayload, type ResumeSessionPayload, SESSION_HOST_SUPPORTED_REQUEST_TYPES, type SendInputPayload, type SendSignalPayload, type SessionAttachedClient, type SessionBufferSnapshot, type SessionClientType, type SessionHostCategory, SessionHostClient, type SessionHostClientOptions, type SessionHostControlPlane, type SessionHostControlTransport, type SessionHostDiagnostics, type SessionHostDisconnectInfo, type SessionHostDisconnectReason, type SessionHostDuplicateSessionGroup, type SessionHostEndpoint, type SessionHostEndpointOptions, type SessionHostEvent, type SessionHostEventEnvelope, type SessionHostLogEntry, type SessionHostPruneDuplicatesResult, type SessionHostRecord, SessionHostRegistry, type SessionHostRequest, type SessionHostRequestEnvelope, type SessionHostRequestTrace, type SessionHostRequestType, type SessionHostResponse, type SessionHostResponseEnvelope, type SessionHostRuntimeTransition, type SessionHostSnapshot, type SessionHostSurfaceKind, type SessionHostSurfaceRecordLike, type SessionHostWireEnvelope, type SessionLaunchCommand, type SessionLifecycle, type SessionOwnerType, SessionRingBuffer, type SessionRingBufferOptions, type SessionTerminalSnapshot, type SessionTerminalState, type SessionTermination, type SessionTransport, type SessionWriteOwner, type StopMeshWriterPayload, type StopSessionPayload, type UpdateSessionMetaPayload, applyTerminalColorEnv, buildRuntimeDisplayName, buildRuntimeKey, canonicalizeInstancePath, classifyTermination, createCliChildPriorityPolicy, createLineParser, createResponseEnvelope, createSessionHostControlPlane, disconnectSessionHostClients, ensureNodePtySpawnHelperPermissions, findConnectedSessionHostClient, formatRuntimeOwner, getDefaultSessionHostEndpoint, getSessionHostRecoveryLabel, getSessionHostSurfaceKind, getWorkspaceLabel, hiddenSpawn as hiddenSpawnProcess, isDefaultInstanceConfigDir, isSessionHostLiveRuntime, isSessionHostRecoverySnapshot, isTerminalRecord, partitionSessionHostDiagnosticsSessions, partitionSessionHostRecords, replayLaunchEnv, resolveAttachableRuntimeRecord, resolveInstanceConfigDir, resolveRuntimeRecord, resolveSessionHostIpcKey, sanitizeSpawnEnv, spawnCliChild, writeEnvelope };
package/dist/index.js CHANGED
@@ -89,6 +89,7 @@ var SESSION_HOST_SUPPORTED_REQUEST_TYPES = [
89
89
  "send_input",
90
90
  "resize_session",
91
91
  "stop_session",
92
+ "stop_mesh_writer",
92
93
  "delete_session",
93
94
  "resume_session",
94
95
  "acquire_write",
@@ -929,9 +930,24 @@ var SessionHostClient = class {
929
930
  request
930
931
  };
931
932
  const timeoutLabel = timeoutMs % 1e3 === 0 ? `${timeoutMs / 1e3}s` : `${timeoutMs}ms`;
933
+ const startedAt = Date.now();
934
+ const startedMonotonicAt = performance.now();
932
935
  return new Promise((resolve3, reject) => {
933
936
  const timeout = setTimeout(() => {
934
- const timeoutError = Object.assign(new Error(`Session host request timed out after ${timeoutLabel} (${request.type})`), { code: "SESSION_HOST_REQUEST_TIMEOUT", requestType: request.type });
937
+ const actualElapsedMs = Math.max(0, Math.round(performance.now() - startedMonotonicAt));
938
+ const wallElapsedMs = Math.max(0, Date.now() - startedAt);
939
+ const observerLagMs = Math.max(0, actualElapsedMs - timeoutMs);
940
+ const timeoutError = Object.assign(
941
+ new Error(`Session host request timed out after ${timeoutLabel} (${request.type})`),
942
+ {
943
+ code: "SESSION_HOST_REQUEST_TIMEOUT",
944
+ requestType: request.type,
945
+ scheduledTimeoutMs: timeoutMs,
946
+ actualElapsedMs,
947
+ wallElapsedMs,
948
+ observerLagMs
949
+ }
950
+ );
935
951
  if (this.socket === socket) {
936
952
  this.disconnect(timeoutError);
937
953
  } else {
@@ -1021,8 +1037,22 @@ var SessionHostClient = class {
1021
1037
  reject(error);
1022
1038
  };
1023
1039
  const closed = () => failed(new Error("Session host connection closed before connect"));
1040
+ const connectStartedAt = Date.now();
1041
+ const connectStartedMonotonicAt = performance.now();
1024
1042
  const timer = setTimeout(() => {
1025
- const error = Object.assign(new Error(`Session host connect timed out after ${timeoutMs}ms`), { code: "SESSION_HOST_CONNECT_TIMEOUT" });
1043
+ const actualElapsedMs = Math.max(0, Math.round(performance.now() - connectStartedMonotonicAt));
1044
+ const wallElapsedMs = Math.max(0, Date.now() - connectStartedAt);
1045
+ const observerLagMs = Math.max(0, actualElapsedMs - timeoutMs);
1046
+ const error = Object.assign(
1047
+ new Error(`Session host connect timed out after ${timeoutMs}ms`),
1048
+ {
1049
+ code: "SESSION_HOST_CONNECT_TIMEOUT",
1050
+ scheduledTimeoutMs: timeoutMs,
1051
+ actualElapsedMs,
1052
+ wallElapsedMs,
1053
+ observerLagMs
1054
+ }
1055
+ );
1026
1056
  failed(error);
1027
1057
  if (this.socket === socket) this.disconnect(error);
1028
1058
  }, timeoutMs);
@@ -1064,12 +1094,26 @@ var SessionHostClient = class {
1064
1094
  const alreadyConnected = this.isConnected() && !this.connectPromise;
1065
1095
  if (options.timeoutMs !== void 0) {
1066
1096
  let timer;
1097
+ const raceStartedAt = Date.now();
1098
+ const raceStartedMonotonicAt = performance.now();
1067
1099
  try {
1068
1100
  await Promise.race([
1069
1101
  this.connect(timeoutMs),
1070
1102
  new Promise((_resolve, reject) => {
1071
1103
  timer = setTimeout(() => {
1072
- const error = Object.assign(new Error(`Session host connect timed out after ${timeoutMs}ms`), { code: "SESSION_HOST_CONNECT_TIMEOUT" });
1104
+ const actualElapsedMs = Math.max(0, Math.round(performance.now() - raceStartedMonotonicAt));
1105
+ const wallElapsedMs = Math.max(0, Date.now() - raceStartedAt);
1106
+ const observerLagMs = Math.max(0, actualElapsedMs - timeoutMs);
1107
+ const error = Object.assign(
1108
+ new Error(`Session host connect timed out after ${timeoutMs}ms`),
1109
+ {
1110
+ code: "SESSION_HOST_CONNECT_TIMEOUT",
1111
+ scheduledTimeoutMs: timeoutMs,
1112
+ actualElapsedMs,
1113
+ wallElapsedMs,
1114
+ observerLagMs
1115
+ }
1116
+ );
1073
1117
  reject(error);
1074
1118
  this.disconnect(error);
1075
1119
  }, timeoutMs);