@threadbase-sh/streamer 1.23.1 → 1.24.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
@@ -76,9 +76,16 @@ interface Logger {
76
76
  pino: Logger$1;
77
77
  }
78
78
 
79
+ declare const CLAUDE_CODE_PROVIDER: "claude-code";
80
+ declare const CODEX_CLI_PROVIDER: "codex-cli";
81
+ type ProviderName = typeof CLAUDE_CODE_PROVIDER | typeof CODEX_CLI_PROVIDER;
82
+ declare function isProviderName(value: unknown): value is ProviderName;
83
+ declare function isProviderResumable(_provider: string | null | undefined, availabilityResumable: boolean): boolean;
84
+
79
85
  type SessionStatus = "running" | "waiting_input" | "idle";
80
86
  interface ManagedSession {
81
87
  id: string;
88
+ provider?: ProviderName;
82
89
  projectId?: string;
83
90
  projectPath: string;
84
91
  projectName: string;
@@ -101,6 +108,15 @@ interface ManagedSession {
101
108
  lastActivityAt?: Date;
102
109
  filePath?: string;
103
110
  resumedFromConversationId?: string;
111
+ /**
112
+ * Set once a live session's underlying persisted conversation file is
113
+ * discovered after the fact (currently: fresh Codex sessions, whose
114
+ * rollout id isn't known until the CLI creates its own JSONL). Distinct
115
+ * from `resumedFromConversationId` (resume flow) and `conversationId` on
116
+ * `SessionResponse` (stable mobile deep-link alias, always === id for the
117
+ * lifetime of a live PTY) — must never be written into either of those.
118
+ */
119
+ boundConversationId?: string;
104
120
  /**
105
121
  * Multi-agent mode only. Per-session in-memory LRU of progress event ids
106
122
  * seen by the webhook receiver. Used to drop Temporal-replay duplicates
@@ -226,6 +242,7 @@ type WSMessage = {
226
242
  interface SessionResponse {
227
243
  id: string;
228
244
  conversationId: string;
245
+ provider?: ProviderName;
229
246
  projectId?: string;
230
247
  status: SessionStatus;
231
248
  projectPath: string;
@@ -251,6 +268,8 @@ interface SessionResponse {
251
268
  lastActivityAt?: string;
252
269
  filePath?: string;
253
270
  resumedFromConversationId?: string;
271
+ /** See `ManagedSession.boundConversationId` — never repurposes `conversationId`. */
272
+ boundConversationId?: string;
254
273
  }
255
274
  interface ConversationListResponse {
256
275
  conversations: unknown[];
@@ -324,6 +343,21 @@ interface StartFreshSessionOptions {
324
343
  projectName?: string;
325
344
  systemPrompt?: string;
326
345
  }
346
+ interface SessionRunner {
347
+ start(sessionId: string, options: StartSessionOptions): Promise<ManagedSession>;
348
+ startFresh(options: StartFreshSessionOptions): Promise<ManagedSession>;
349
+ sendInput(sessionId: string, input: string): number;
350
+ sendKeys(sessionId: string, keys: string): void;
351
+ cancel(sessionId: string): void;
352
+ killPid(pid: number): void;
353
+ putOnHold(sessionId: string): void;
354
+ getOutput(sessionId: string): string;
355
+ getOutputLines(sessionId: string, maxLines: number): Promise<string[]>;
356
+ getSession(sessionId: string): ManagedSession | null;
357
+ hasSession(sessionId: string): boolean;
358
+ listSessions(): ManagedSession[];
359
+ dispose(): void;
360
+ }
327
361
 
328
362
  interface ConversationCacheOptions {
329
363
  filterAgentConversations?: boolean;
@@ -596,30 +630,17 @@ declare class SessionsRepository {
596
630
  listManagedSessions(): ManagedSession[];
597
631
  }
598
632
 
599
- declare class PTYManager {
600
- private sessions;
601
- private onOutput;
602
- private onStatusChange;
603
- private onReady;
604
- private onPermissionChange;
605
- private onLiveQuestion;
606
- private onLiveQuestionGone;
607
- private permissionOpen;
608
- private lastScreenQuestionKey;
609
- private shellPromptOpen;
610
- private pendingReady;
611
- private queuedInputs;
612
- private log;
613
- private firstChunkAt;
614
- private chunkIndex;
615
- private lastChunkAt;
633
+ declare class LiveSessionManager {
634
+ private runners;
616
635
  constructor(options?: PTYManagerOptions);
617
- start(sessionId: string, options: StartSessionOptions): Promise<ManagedSession>;
618
- startFresh(options: StartFreshSessionOptions): Promise<ManagedSession>;
619
- sendKeys(sessionId: string, keys: string): void;
636
+ start(sessionId: string, options: StartSessionOptions & {
637
+ provider?: ProviderName;
638
+ }): Promise<ManagedSession>;
639
+ startFresh(options: StartFreshSessionOptions & {
640
+ provider?: ProviderName;
641
+ }): Promise<ManagedSession>;
620
642
  sendInput(sessionId: string, input: string): number;
621
- private writeSubmit;
622
- private flushQueuedInputs;
643
+ sendKeys(sessionId: string, keys: string): void;
623
644
  cancel(sessionId: string): void;
624
645
  killPid(pid: number): void;
625
646
  putOnHold(sessionId: string): void;
@@ -629,10 +650,8 @@ declare class PTYManager {
629
650
  hasSession(sessionId: string): boolean;
630
651
  listSessions(): ManagedSession[];
631
652
  dispose(): void;
632
- private handleOutput;
633
- private detectLivePrompts;
634
- private markReady;
635
- private handleExit;
653
+ private runnerFor;
654
+ private assertSupportedProvider;
636
655
  }
637
656
 
638
657
  declare class WSHub {
@@ -657,7 +676,7 @@ type ApiDeps = {
657
676
  };
658
677
  publicUrl: string | null;
659
678
  browseRoot: string | null;
660
- ptyManager: PTYManager;
679
+ ptyManager: LiveSessionManager;
661
680
  sessionStore: SessionStore;
662
681
  wsHub: WSHub;
663
682
  cache: () => ConversationCache | null;
@@ -761,6 +780,47 @@ declare function createPool(config: DbConfig): Promise<Pool>;
761
780
 
762
781
  declare function discoverClaudeProcesses(): Promise<DiscoveredProcess[]>;
763
782
 
783
+ declare class PTYManager implements SessionRunner {
784
+ private sessions;
785
+ private onOutput;
786
+ private onStatusChange;
787
+ private onReady;
788
+ private onPermissionChange;
789
+ private onLiveQuestion;
790
+ private onLiveQuestionGone;
791
+ private permissionOpen;
792
+ private lastScreenQuestionKey;
793
+ private shellPromptOpen;
794
+ private pendingReady;
795
+ private queuedInputs;
796
+ private log;
797
+ private firstChunkAt;
798
+ private chunkIndex;
799
+ private lastChunkAt;
800
+ private startPromises;
801
+ constructor(options?: PTYManagerOptions);
802
+ start(sessionId: string, options: StartSessionOptions): Promise<ManagedSession>;
803
+ private doStart;
804
+ startFresh(options: StartFreshSessionOptions): Promise<ManagedSession>;
805
+ sendKeys(sessionId: string, keys: string): void;
806
+ sendInput(sessionId: string, input: string): number;
807
+ private writeSubmit;
808
+ private flushQueuedInputs;
809
+ cancel(sessionId: string): void;
810
+ killPid(pid: number): void;
811
+ putOnHold(sessionId: string): void;
812
+ getOutput(sessionId: string): string;
813
+ getOutputLines(sessionId: string, maxLines: number): Promise<string[]>;
814
+ getSession(sessionId: string): ManagedSession | null;
815
+ hasSession(sessionId: string): boolean;
816
+ listSessions(): ManagedSession[];
817
+ dispose(): void;
818
+ private handleOutput;
819
+ private detectLivePrompts;
820
+ private markReady;
821
+ private handleExit;
822
+ }
823
+
764
824
  declare class StreamerServer {
765
825
  private httpServer;
766
826
  private ptyManager;
@@ -877,6 +937,7 @@ declare class StreamerServer {
877
937
  private linkSessionToProject;
878
938
  private watchConversationFile;
879
939
  private watchForJsonl;
940
+ private watchForCodexRollout;
880
941
  private handleBrowse;
881
942
  private handleMkdir;
882
943
  private handleSetSessionName;
@@ -933,4 +994,4 @@ declare class ConversationWatcher {
933
994
  private readNewLines;
934
995
  }
935
996
 
936
- export { type AgentClient, type AgentClientOpts, type AgentConfig, type AppendArgs, type AskOption, type AskQuestion, type ConversationListResponse, ConversationWatcher, type ConversationWriter, type DbConfig, type DiscoveredProcess, type ManagedSession, PTYManager, type PTYManagerOptions, type PermissionOption, type ProgressDedupeLRU, type ServerConfig, type SessionCursor, type SessionListPage, type SessionListQuery, type SessionResponse, type SessionSortKey, type SessionStatus, SessionStore, type SortOrder, type StartFreshSessionOptions, type StartSessionOptions, StreamerServer, WSHub, type WSMessage, createAgentClient, createConversationWriter, createPool, createProgressDedupeLRU, createProgressRoutes, discoverClaudeProcesses, generateApiKey, getDbConfig, isDbEnabled, loadOrCreateApiKey, maskConnectionString, readAgentConfig, validateApiKey };
997
+ export { type AgentClient, type AgentClientOpts, type AgentConfig, type AppendArgs, type AskOption, type AskQuestion, CLAUDE_CODE_PROVIDER, CODEX_CLI_PROVIDER, type ConversationListResponse, ConversationWatcher, type ConversationWriter, type DbConfig, type DiscoveredProcess, LiveSessionManager, type ManagedSession, PTYManager, type PTYManagerOptions, type PermissionOption, type ProgressDedupeLRU, type ProviderName, type ServerConfig, type SessionCursor, type SessionListPage, type SessionListQuery, type SessionResponse, type SessionRunner, type SessionSortKey, type SessionStatus, SessionStore, type SortOrder, type StartFreshSessionOptions, type StartSessionOptions, StreamerServer, WSHub, type WSMessage, createAgentClient, createConversationWriter, createPool, createProgressDedupeLRU, createProgressRoutes, discoverClaudeProcesses, generateApiKey, getDbConfig, isDbEnabled, isProviderName, isProviderResumable, loadOrCreateApiKey, maskConnectionString, readAgentConfig, validateApiKey };
package/dist/index.d.ts CHANGED
@@ -76,9 +76,16 @@ interface Logger {
76
76
  pino: Logger$1;
77
77
  }
78
78
 
79
+ declare const CLAUDE_CODE_PROVIDER: "claude-code";
80
+ declare const CODEX_CLI_PROVIDER: "codex-cli";
81
+ type ProviderName = typeof CLAUDE_CODE_PROVIDER | typeof CODEX_CLI_PROVIDER;
82
+ declare function isProviderName(value: unknown): value is ProviderName;
83
+ declare function isProviderResumable(_provider: string | null | undefined, availabilityResumable: boolean): boolean;
84
+
79
85
  type SessionStatus = "running" | "waiting_input" | "idle";
80
86
  interface ManagedSession {
81
87
  id: string;
88
+ provider?: ProviderName;
82
89
  projectId?: string;
83
90
  projectPath: string;
84
91
  projectName: string;
@@ -101,6 +108,15 @@ interface ManagedSession {
101
108
  lastActivityAt?: Date;
102
109
  filePath?: string;
103
110
  resumedFromConversationId?: string;
111
+ /**
112
+ * Set once a live session's underlying persisted conversation file is
113
+ * discovered after the fact (currently: fresh Codex sessions, whose
114
+ * rollout id isn't known until the CLI creates its own JSONL). Distinct
115
+ * from `resumedFromConversationId` (resume flow) and `conversationId` on
116
+ * `SessionResponse` (stable mobile deep-link alias, always === id for the
117
+ * lifetime of a live PTY) — must never be written into either of those.
118
+ */
119
+ boundConversationId?: string;
104
120
  /**
105
121
  * Multi-agent mode only. Per-session in-memory LRU of progress event ids
106
122
  * seen by the webhook receiver. Used to drop Temporal-replay duplicates
@@ -226,6 +242,7 @@ type WSMessage = {
226
242
  interface SessionResponse {
227
243
  id: string;
228
244
  conversationId: string;
245
+ provider?: ProviderName;
229
246
  projectId?: string;
230
247
  status: SessionStatus;
231
248
  projectPath: string;
@@ -251,6 +268,8 @@ interface SessionResponse {
251
268
  lastActivityAt?: string;
252
269
  filePath?: string;
253
270
  resumedFromConversationId?: string;
271
+ /** See `ManagedSession.boundConversationId` — never repurposes `conversationId`. */
272
+ boundConversationId?: string;
254
273
  }
255
274
  interface ConversationListResponse {
256
275
  conversations: unknown[];
@@ -324,6 +343,21 @@ interface StartFreshSessionOptions {
324
343
  projectName?: string;
325
344
  systemPrompt?: string;
326
345
  }
346
+ interface SessionRunner {
347
+ start(sessionId: string, options: StartSessionOptions): Promise<ManagedSession>;
348
+ startFresh(options: StartFreshSessionOptions): Promise<ManagedSession>;
349
+ sendInput(sessionId: string, input: string): number;
350
+ sendKeys(sessionId: string, keys: string): void;
351
+ cancel(sessionId: string): void;
352
+ killPid(pid: number): void;
353
+ putOnHold(sessionId: string): void;
354
+ getOutput(sessionId: string): string;
355
+ getOutputLines(sessionId: string, maxLines: number): Promise<string[]>;
356
+ getSession(sessionId: string): ManagedSession | null;
357
+ hasSession(sessionId: string): boolean;
358
+ listSessions(): ManagedSession[];
359
+ dispose(): void;
360
+ }
327
361
 
328
362
  interface ConversationCacheOptions {
329
363
  filterAgentConversations?: boolean;
@@ -596,30 +630,17 @@ declare class SessionsRepository {
596
630
  listManagedSessions(): ManagedSession[];
597
631
  }
598
632
 
599
- declare class PTYManager {
600
- private sessions;
601
- private onOutput;
602
- private onStatusChange;
603
- private onReady;
604
- private onPermissionChange;
605
- private onLiveQuestion;
606
- private onLiveQuestionGone;
607
- private permissionOpen;
608
- private lastScreenQuestionKey;
609
- private shellPromptOpen;
610
- private pendingReady;
611
- private queuedInputs;
612
- private log;
613
- private firstChunkAt;
614
- private chunkIndex;
615
- private lastChunkAt;
633
+ declare class LiveSessionManager {
634
+ private runners;
616
635
  constructor(options?: PTYManagerOptions);
617
- start(sessionId: string, options: StartSessionOptions): Promise<ManagedSession>;
618
- startFresh(options: StartFreshSessionOptions): Promise<ManagedSession>;
619
- sendKeys(sessionId: string, keys: string): void;
636
+ start(sessionId: string, options: StartSessionOptions & {
637
+ provider?: ProviderName;
638
+ }): Promise<ManagedSession>;
639
+ startFresh(options: StartFreshSessionOptions & {
640
+ provider?: ProviderName;
641
+ }): Promise<ManagedSession>;
620
642
  sendInput(sessionId: string, input: string): number;
621
- private writeSubmit;
622
- private flushQueuedInputs;
643
+ sendKeys(sessionId: string, keys: string): void;
623
644
  cancel(sessionId: string): void;
624
645
  killPid(pid: number): void;
625
646
  putOnHold(sessionId: string): void;
@@ -629,10 +650,8 @@ declare class PTYManager {
629
650
  hasSession(sessionId: string): boolean;
630
651
  listSessions(): ManagedSession[];
631
652
  dispose(): void;
632
- private handleOutput;
633
- private detectLivePrompts;
634
- private markReady;
635
- private handleExit;
653
+ private runnerFor;
654
+ private assertSupportedProvider;
636
655
  }
637
656
 
638
657
  declare class WSHub {
@@ -657,7 +676,7 @@ type ApiDeps = {
657
676
  };
658
677
  publicUrl: string | null;
659
678
  browseRoot: string | null;
660
- ptyManager: PTYManager;
679
+ ptyManager: LiveSessionManager;
661
680
  sessionStore: SessionStore;
662
681
  wsHub: WSHub;
663
682
  cache: () => ConversationCache | null;
@@ -761,6 +780,47 @@ declare function createPool(config: DbConfig): Promise<Pool>;
761
780
 
762
781
  declare function discoverClaudeProcesses(): Promise<DiscoveredProcess[]>;
763
782
 
783
+ declare class PTYManager implements SessionRunner {
784
+ private sessions;
785
+ private onOutput;
786
+ private onStatusChange;
787
+ private onReady;
788
+ private onPermissionChange;
789
+ private onLiveQuestion;
790
+ private onLiveQuestionGone;
791
+ private permissionOpen;
792
+ private lastScreenQuestionKey;
793
+ private shellPromptOpen;
794
+ private pendingReady;
795
+ private queuedInputs;
796
+ private log;
797
+ private firstChunkAt;
798
+ private chunkIndex;
799
+ private lastChunkAt;
800
+ private startPromises;
801
+ constructor(options?: PTYManagerOptions);
802
+ start(sessionId: string, options: StartSessionOptions): Promise<ManagedSession>;
803
+ private doStart;
804
+ startFresh(options: StartFreshSessionOptions): Promise<ManagedSession>;
805
+ sendKeys(sessionId: string, keys: string): void;
806
+ sendInput(sessionId: string, input: string): number;
807
+ private writeSubmit;
808
+ private flushQueuedInputs;
809
+ cancel(sessionId: string): void;
810
+ killPid(pid: number): void;
811
+ putOnHold(sessionId: string): void;
812
+ getOutput(sessionId: string): string;
813
+ getOutputLines(sessionId: string, maxLines: number): Promise<string[]>;
814
+ getSession(sessionId: string): ManagedSession | null;
815
+ hasSession(sessionId: string): boolean;
816
+ listSessions(): ManagedSession[];
817
+ dispose(): void;
818
+ private handleOutput;
819
+ private detectLivePrompts;
820
+ private markReady;
821
+ private handleExit;
822
+ }
823
+
764
824
  declare class StreamerServer {
765
825
  private httpServer;
766
826
  private ptyManager;
@@ -877,6 +937,7 @@ declare class StreamerServer {
877
937
  private linkSessionToProject;
878
938
  private watchConversationFile;
879
939
  private watchForJsonl;
940
+ private watchForCodexRollout;
880
941
  private handleBrowse;
881
942
  private handleMkdir;
882
943
  private handleSetSessionName;
@@ -933,4 +994,4 @@ declare class ConversationWatcher {
933
994
  private readNewLines;
934
995
  }
935
996
 
936
- export { type AgentClient, type AgentClientOpts, type AgentConfig, type AppendArgs, type AskOption, type AskQuestion, type ConversationListResponse, ConversationWatcher, type ConversationWriter, type DbConfig, type DiscoveredProcess, type ManagedSession, PTYManager, type PTYManagerOptions, type PermissionOption, type ProgressDedupeLRU, type ServerConfig, type SessionCursor, type SessionListPage, type SessionListQuery, type SessionResponse, type SessionSortKey, type SessionStatus, SessionStore, type SortOrder, type StartFreshSessionOptions, type StartSessionOptions, StreamerServer, WSHub, type WSMessage, createAgentClient, createConversationWriter, createPool, createProgressDedupeLRU, createProgressRoutes, discoverClaudeProcesses, generateApiKey, getDbConfig, isDbEnabled, loadOrCreateApiKey, maskConnectionString, readAgentConfig, validateApiKey };
997
+ export { type AgentClient, type AgentClientOpts, type AgentConfig, type AppendArgs, type AskOption, type AskQuestion, CLAUDE_CODE_PROVIDER, CODEX_CLI_PROVIDER, type ConversationListResponse, ConversationWatcher, type ConversationWriter, type DbConfig, type DiscoveredProcess, LiveSessionManager, type ManagedSession, PTYManager, type PTYManagerOptions, type PermissionOption, type ProgressDedupeLRU, type ProviderName, type ServerConfig, type SessionCursor, type SessionListPage, type SessionListQuery, type SessionResponse, type SessionRunner, type SessionSortKey, type SessionStatus, SessionStore, type SortOrder, type StartFreshSessionOptions, type StartSessionOptions, StreamerServer, WSHub, type WSMessage, createAgentClient, createConversationWriter, createPool, createProgressDedupeLRU, createProgressRoutes, discoverClaudeProcesses, generateApiKey, getDbConfig, isDbEnabled, isProviderName, isProviderResumable, loadOrCreateApiKey, maskConnectionString, readAgentConfig, validateApiKey };