@threadbase-sh/streamer 1.43.0 → 1.44.0

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.cts CHANGED
@@ -192,6 +192,11 @@ interface ManagedSession {
192
192
  * Cleared implicitly when a resume overwrites the stub with a real session.
193
193
  */
194
194
  rehydrated?: boolean;
195
+ /**
196
+ * This live session was re-adopted from the pty-host during boot rather than
197
+ * spawned by this streamer process. Internal lifecycle provenance only.
198
+ */
199
+ reconciled?: boolean;
195
200
  /**
196
201
  * What this session was doing when the streamer stopped it, for a stub whose
197
202
  * `status` had to flatten to `idle`. Only ever set from a registry row whose
@@ -276,7 +281,7 @@ type WSMessage = {
276
281
  reworkAttempt?: number;
277
282
  } | {
278
283
  type: "session_list";
279
- sessions: SessionResponse[];
284
+ sessions: readonly SessionResponse[];
280
285
  } | {
281
286
  type: "conversation_event";
282
287
  sessionId: string;
@@ -488,7 +493,8 @@ interface ConversationListResponse {
488
493
  type SessionSortKey = "startedAt" | "lastActivityAt" | "projectName" | "status";
489
494
  type SortOrder = "asc" | "desc";
490
495
  interface SessionListPage {
491
- sessions: SessionResponse[];
496
+ /** Response copies, like `SessionStore.list()` — see the note there. */
497
+ sessions: readonly Readonly<SessionResponse>[];
492
498
  nextCursor: string | null;
493
499
  total: number;
494
500
  }
@@ -1392,11 +1398,21 @@ declare class SessionStore {
1392
1398
  initAgentSession(sessionId: string, dedupeCapacity: number): void;
1393
1399
  updateManaged(sessionId: string, updates: Partial<ManagedSession>): ManagedSession | null;
1394
1400
  removeManaged(sessionId: string): boolean;
1401
+ /**
1402
+ * The **live** stored record — mutating it mutates the store. Paired with
1403
+ * `get()`, which hands back a throwaway response copy. Prefer
1404
+ * `updateManaged()` for writes; this is for readers that need the internal
1405
+ * shape (Date fields, `rehydrated`, …) rather than the wire shape.
1406
+ */
1395
1407
  getManaged(sessionId: string): ManagedSession | null;
1396
1408
  setDiscovered(processes: DiscoveredProcess[]): void;
1409
+ /**
1410
+ * The **live** stored records — mutating an element mutates the store. Paired
1411
+ * with `list()`, which hands back throwaway response copies.
1412
+ */
1397
1413
  listManaged(): ManagedSession[];
1398
- list(ptyAttachedIds: Set<string>): SessionResponse[];
1399
- get(sessionId: string, ptyAttachedIds: Set<string>): SessionResponse | null;
1414
+ list(ptyAttachedIds: Set<string>): readonly Readonly<SessionResponse>[];
1415
+ get(sessionId: string, ptyAttachedIds: Set<string>): Readonly<SessionResponse> | null;
1400
1416
  paginate(ptyAttachedIds: Set<string>, query: SessionListQuery): SessionListPage;
1401
1417
  }
1402
1418
 
@@ -1450,9 +1466,30 @@ declare class RuntimeStore {
1450
1466
  close(): void;
1451
1467
  }
1452
1468
 
1469
+ interface HostHeartbeatState {
1470
+ registryState: "known" | "unknown";
1471
+ referencedSessionIds: string[];
1472
+ }
1473
+ /**
1474
+ * A duplex line channel. Deliberately not a socket: the runner is tested
1475
+ * against an in-memory pair, and PR 7 supplies the real one over a unix socket
1476
+ * (POSIX) or named pipe (Windows).
1477
+ */
1478
+ interface HostTransport {
1479
+ send(line: string): void;
1480
+ onLine(handler: (line: string) => void): void;
1481
+ onClose(handler: () => void): void;
1482
+ close(): void;
1483
+ }
1484
+
1453
1485
  declare class LiveSessionManager {
1454
1486
  private runners;
1487
+ private remoteRunner;
1488
+ private options;
1455
1489
  constructor(options?: PTYManagerOptions);
1490
+ useRemoteRunner(transport: HostTransport): Promise<ManagedSession[]>;
1491
+ isRemote(): boolean;
1492
+ startRemoteHeartbeat(getState: () => HostHeartbeatState): void;
1456
1493
  start(sessionId: string, options: StartSessionOptions & {
1457
1494
  provider?: ProviderName;
1458
1495
  }): Promise<ManagedSession>;
@@ -1474,6 +1511,7 @@ declare class LiveSessionManager {
1474
1511
  dispose(): void;
1475
1512
  private runnerFor;
1476
1513
  private assertSupportedProvider;
1514
+ private activeRunners;
1477
1515
  }
1478
1516
 
1479
1517
  declare class WSHub {
@@ -1960,6 +1998,8 @@ declare class StreamerServer {
1960
1998
  * it is set once that rollout has been discovered.
1961
1999
  */
1962
2000
  private spawnArgvToken;
2001
+ /** Restore registry-only metadata after the host mirror has been adopted. */
2002
+ private refreshHostedSessionsFromRegistry;
1963
2003
  /**
1964
2004
  * Mirror a freshly-spawned session into the durable registry (C1 Phase 2).
1965
2005
  *
package/dist/index.d.ts CHANGED
@@ -192,6 +192,11 @@ interface ManagedSession {
192
192
  * Cleared implicitly when a resume overwrites the stub with a real session.
193
193
  */
194
194
  rehydrated?: boolean;
195
+ /**
196
+ * This live session was re-adopted from the pty-host during boot rather than
197
+ * spawned by this streamer process. Internal lifecycle provenance only.
198
+ */
199
+ reconciled?: boolean;
195
200
  /**
196
201
  * What this session was doing when the streamer stopped it, for a stub whose
197
202
  * `status` had to flatten to `idle`. Only ever set from a registry row whose
@@ -276,7 +281,7 @@ type WSMessage = {
276
281
  reworkAttempt?: number;
277
282
  } | {
278
283
  type: "session_list";
279
- sessions: SessionResponse[];
284
+ sessions: readonly SessionResponse[];
280
285
  } | {
281
286
  type: "conversation_event";
282
287
  sessionId: string;
@@ -488,7 +493,8 @@ interface ConversationListResponse {
488
493
  type SessionSortKey = "startedAt" | "lastActivityAt" | "projectName" | "status";
489
494
  type SortOrder = "asc" | "desc";
490
495
  interface SessionListPage {
491
- sessions: SessionResponse[];
496
+ /** Response copies, like `SessionStore.list()` — see the note there. */
497
+ sessions: readonly Readonly<SessionResponse>[];
492
498
  nextCursor: string | null;
493
499
  total: number;
494
500
  }
@@ -1392,11 +1398,21 @@ declare class SessionStore {
1392
1398
  initAgentSession(sessionId: string, dedupeCapacity: number): void;
1393
1399
  updateManaged(sessionId: string, updates: Partial<ManagedSession>): ManagedSession | null;
1394
1400
  removeManaged(sessionId: string): boolean;
1401
+ /**
1402
+ * The **live** stored record — mutating it mutates the store. Paired with
1403
+ * `get()`, which hands back a throwaway response copy. Prefer
1404
+ * `updateManaged()` for writes; this is for readers that need the internal
1405
+ * shape (Date fields, `rehydrated`, …) rather than the wire shape.
1406
+ */
1395
1407
  getManaged(sessionId: string): ManagedSession | null;
1396
1408
  setDiscovered(processes: DiscoveredProcess[]): void;
1409
+ /**
1410
+ * The **live** stored records — mutating an element mutates the store. Paired
1411
+ * with `list()`, which hands back throwaway response copies.
1412
+ */
1397
1413
  listManaged(): ManagedSession[];
1398
- list(ptyAttachedIds: Set<string>): SessionResponse[];
1399
- get(sessionId: string, ptyAttachedIds: Set<string>): SessionResponse | null;
1414
+ list(ptyAttachedIds: Set<string>): readonly Readonly<SessionResponse>[];
1415
+ get(sessionId: string, ptyAttachedIds: Set<string>): Readonly<SessionResponse> | null;
1400
1416
  paginate(ptyAttachedIds: Set<string>, query: SessionListQuery): SessionListPage;
1401
1417
  }
1402
1418
 
@@ -1450,9 +1466,30 @@ declare class RuntimeStore {
1450
1466
  close(): void;
1451
1467
  }
1452
1468
 
1469
+ interface HostHeartbeatState {
1470
+ registryState: "known" | "unknown";
1471
+ referencedSessionIds: string[];
1472
+ }
1473
+ /**
1474
+ * A duplex line channel. Deliberately not a socket: the runner is tested
1475
+ * against an in-memory pair, and PR 7 supplies the real one over a unix socket
1476
+ * (POSIX) or named pipe (Windows).
1477
+ */
1478
+ interface HostTransport {
1479
+ send(line: string): void;
1480
+ onLine(handler: (line: string) => void): void;
1481
+ onClose(handler: () => void): void;
1482
+ close(): void;
1483
+ }
1484
+
1453
1485
  declare class LiveSessionManager {
1454
1486
  private runners;
1487
+ private remoteRunner;
1488
+ private options;
1455
1489
  constructor(options?: PTYManagerOptions);
1490
+ useRemoteRunner(transport: HostTransport): Promise<ManagedSession[]>;
1491
+ isRemote(): boolean;
1492
+ startRemoteHeartbeat(getState: () => HostHeartbeatState): void;
1456
1493
  start(sessionId: string, options: StartSessionOptions & {
1457
1494
  provider?: ProviderName;
1458
1495
  }): Promise<ManagedSession>;
@@ -1474,6 +1511,7 @@ declare class LiveSessionManager {
1474
1511
  dispose(): void;
1475
1512
  private runnerFor;
1476
1513
  private assertSupportedProvider;
1514
+ private activeRunners;
1477
1515
  }
1478
1516
 
1479
1517
  declare class WSHub {
@@ -1960,6 +1998,8 @@ declare class StreamerServer {
1960
1998
  * it is set once that rollout has been discovered.
1961
1999
  */
1962
2000
  private spawnArgvToken;
2001
+ /** Restore registry-only metadata after the host mirror has been adopted. */
2002
+ private refreshHostedSessionsFromRegistry;
1963
2003
  /**
1964
2004
  * Mirror a freshly-spawned session into the durable registry (C1 Phase 2).
1965
2005
  *