@ccpocket-base-auth/bridge 1.26.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.
Files changed (89) hide show
  1. package/README.md +67 -0
  2. package/dist/archive-store.d.ts +28 -0
  3. package/dist/archive-store.js +68 -0
  4. package/dist/archive-store.js.map +1 -0
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +82 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/codex-process.d.ts +171 -0
  9. package/dist/codex-process.js +1928 -0
  10. package/dist/codex-process.js.map +1 -0
  11. package/dist/debug-trace-store.d.ts +15 -0
  12. package/dist/debug-trace-store.js +78 -0
  13. package/dist/debug-trace-store.js.map +1 -0
  14. package/dist/doctor.d.ts +58 -0
  15. package/dist/doctor.js +663 -0
  16. package/dist/doctor.js.map +1 -0
  17. package/dist/firebase-auth.d.ts +35 -0
  18. package/dist/firebase-auth.js +132 -0
  19. package/dist/firebase-auth.js.map +1 -0
  20. package/dist/gallery-store.d.ts +67 -0
  21. package/dist/gallery-store.js +333 -0
  22. package/dist/gallery-store.js.map +1 -0
  23. package/dist/image-store.d.ts +23 -0
  24. package/dist/image-store.js +142 -0
  25. package/dist/image-store.js.map +1 -0
  26. package/dist/index.d.ts +1 -0
  27. package/dist/index.js +191 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/mdns.d.ts +7 -0
  30. package/dist/mdns.js +49 -0
  31. package/dist/mdns.js.map +1 -0
  32. package/dist/parser.d.ts +465 -0
  33. package/dist/parser.js +251 -0
  34. package/dist/parser.js.map +1 -0
  35. package/dist/project-history.d.ts +10 -0
  36. package/dist/project-history.js +73 -0
  37. package/dist/project-history.js.map +1 -0
  38. package/dist/prompt-history-backup.d.ts +15 -0
  39. package/dist/prompt-history-backup.js +46 -0
  40. package/dist/prompt-history-backup.js.map +1 -0
  41. package/dist/proxy.d.ts +15 -0
  42. package/dist/proxy.js +95 -0
  43. package/dist/proxy.js.map +1 -0
  44. package/dist/push-i18n.d.ts +7 -0
  45. package/dist/push-i18n.js +75 -0
  46. package/dist/push-i18n.js.map +1 -0
  47. package/dist/push-relay.d.ts +29 -0
  48. package/dist/push-relay.js +70 -0
  49. package/dist/push-relay.js.map +1 -0
  50. package/dist/recording-store.d.ts +51 -0
  51. package/dist/recording-store.js +158 -0
  52. package/dist/recording-store.js.map +1 -0
  53. package/dist/screenshot.d.ts +28 -0
  54. package/dist/screenshot.js +98 -0
  55. package/dist/screenshot.js.map +1 -0
  56. package/dist/sdk-process.d.ts +180 -0
  57. package/dist/sdk-process.js +937 -0
  58. package/dist/sdk-process.js.map +1 -0
  59. package/dist/session.d.ts +142 -0
  60. package/dist/session.js +615 -0
  61. package/dist/session.js.map +1 -0
  62. package/dist/sessions-index.d.ts +128 -0
  63. package/dist/sessions-index.js +1767 -0
  64. package/dist/sessions-index.js.map +1 -0
  65. package/dist/setup-launchd.d.ts +8 -0
  66. package/dist/setup-launchd.js +109 -0
  67. package/dist/setup-launchd.js.map +1 -0
  68. package/dist/setup-systemd.d.ts +8 -0
  69. package/dist/setup-systemd.js +118 -0
  70. package/dist/setup-systemd.js.map +1 -0
  71. package/dist/startup-info.d.ts +8 -0
  72. package/dist/startup-info.js +92 -0
  73. package/dist/startup-info.js.map +1 -0
  74. package/dist/usage.d.ts +69 -0
  75. package/dist/usage.js +545 -0
  76. package/dist/usage.js.map +1 -0
  77. package/dist/version.d.ts +13 -0
  78. package/dist/version.js +43 -0
  79. package/dist/version.js.map +1 -0
  80. package/dist/websocket.d.ts +127 -0
  81. package/dist/websocket.js +2482 -0
  82. package/dist/websocket.js.map +1 -0
  83. package/dist/worktree-store.d.ts +25 -0
  84. package/dist/worktree-store.js +59 -0
  85. package/dist/worktree-store.js.map +1 -0
  86. package/dist/worktree.d.ts +47 -0
  87. package/dist/worktree.js +313 -0
  88. package/dist/worktree.js.map +1 -0
  89. package/package.json +68 -0
@@ -0,0 +1,127 @@
1
+ import type { Server as HttpServer } from "node:http";
2
+ import type { ImageStore } from "./image-store.js";
3
+ import type { GalleryStore } from "./gallery-store.js";
4
+ import type { ProjectHistory } from "./project-history.js";
5
+ import { DebugTraceStore } from "./debug-trace-store.js";
6
+ import { RecordingStore } from "./recording-store.js";
7
+ import type { FirebaseAuthClient } from "./firebase-auth.js";
8
+ import type { PromptHistoryBackupStore } from "./prompt-history-backup.js";
9
+ export interface BridgeServerOptions {
10
+ server: HttpServer;
11
+ apiKey?: string;
12
+ allowedDirs?: string[];
13
+ imageStore?: ImageStore;
14
+ galleryStore?: GalleryStore;
15
+ projectHistory?: ProjectHistory;
16
+ debugTraceStore?: DebugTraceStore;
17
+ recordingStore?: RecordingStore;
18
+ firebaseAuth?: FirebaseAuthClient;
19
+ promptHistoryBackup?: PromptHistoryBackupStore;
20
+ }
21
+ export declare class BridgeWebSocketServer {
22
+ private static readonly MAX_DEBUG_EVENTS;
23
+ private static readonly MAX_HISTORY_SUMMARY_ITEMS;
24
+ private wss;
25
+ private sessionManager;
26
+ private apiKey;
27
+ private allowedDirs;
28
+ private imageStore;
29
+ private galleryStore;
30
+ private projectHistory;
31
+ private debugTraceStore;
32
+ private recordingStore;
33
+ private worktreeStore;
34
+ private pushRelay;
35
+ private promptHistoryBackup;
36
+ private recentSessionsRequestId;
37
+ private debugEvents;
38
+ private notifiedPermissionToolUses;
39
+ private archiveStore;
40
+ /** FCM token → push notification locale */
41
+ private tokenLocales;
42
+ private tokenPrivacyMode;
43
+ constructor(options: BridgeServerOptions);
44
+ /**
45
+ * Validate that a project path is within the allowed directories.
46
+ * Returns true if the path is allowed, false otherwise.
47
+ */
48
+ private isPathAllowed;
49
+ /** Build a user-friendly error for disallowed project paths. */
50
+ private buildPathNotAllowedError;
51
+ close(): void;
52
+ /** Return session count for /health endpoint. */
53
+ get sessionCount(): number;
54
+ /** Return connected WebSocket client count. */
55
+ get clientCount(): number;
56
+ private handleConnection;
57
+ private handleClientMessage;
58
+ /**
59
+ * Load the saved session name from CLI storage and set it on the SessionInfo.
60
+ * Called after SessionManager.create() so that session_created carries the name.
61
+ */
62
+ private loadAndSetSessionName;
63
+ /**
64
+ * Handle rename_session: update in-memory name and persist to CLI storage.
65
+ *
66
+ * Supports both running sessions (by bridge session id) and recent sessions
67
+ * (by provider session id, i.e. claudeSessionId or codex threadId).
68
+ */
69
+ private handleRenameSession;
70
+ private resolveSession;
71
+ private getFirstSession;
72
+ private sendSessionList;
73
+ /** Broadcast session list to all connected clients. */
74
+ private broadcastSessionList;
75
+ private broadcastSessionMessage;
76
+ private listRecentSessions;
77
+ private getActiveCodexProcess;
78
+ private listRecentCodexThreads;
79
+ private createStandaloneCodexProcess;
80
+ /** Extract a short project label from the full projectPath (last directory name). */
81
+ private projectLabel;
82
+ /** Get unique locales from registered tokens. Falls back to ["en"] if none registered. */
83
+ private getRegisteredLocales;
84
+ /** Whether any registered token has privacy mode enabled (conservative: privacy wins). */
85
+ private isPrivacyMode;
86
+ /** Get a display label for push notification title: "name (project)" or just project. */
87
+ private sessionLabel;
88
+ private maybeSendPushNotification;
89
+ private broadcast;
90
+ private send;
91
+ /** Broadcast a gallery_new_image message to all connected clients. */
92
+ broadcastGalleryNewImage(image: import("./gallery-store.js").GalleryImageInfo): void;
93
+ private collectGitDiff;
94
+ private static readonly IMAGE_EXTENSIONS;
95
+ private static readonly AUTO_DISPLAY_THRESHOLD;
96
+ private static readonly MAX_IMAGE_SIZE;
97
+ private static mimeTypeForExt;
98
+ /**
99
+ * Scan diff text for image file changes and extract base64 data where appropriate.
100
+ *
101
+ * Detection strategy:
102
+ * 1. Binary markers: "Binary files a/<path> and b/<path> differ"
103
+ * 2. diff --git headers where the file extension is an image type
104
+ *
105
+ * For each detected image file:
106
+ * - Old version: `git show HEAD:<path>` (committed version)
107
+ * - New version: read from working tree
108
+ * - Apply size thresholds for auto-display / on-demand / text-only
109
+ */
110
+ private collectImageChanges;
111
+ /**
112
+ * Load a single diff image on demand (async I/O for better throughput).
113
+ */
114
+ private loadDiffImageAsync;
115
+ private extractSessionIdFromClientMessage;
116
+ private extractSessionIdFromServerMessage;
117
+ private recordDebugEvent;
118
+ private getDebugEvents;
119
+ private buildHistorySummary;
120
+ private summarizeClientMessage;
121
+ private summarizeServerMessage;
122
+ private summarizeOutboundMessage;
123
+ private pruneDebugEvents;
124
+ private buildReproRecipe;
125
+ private buildResumeSessionMessage;
126
+ private buildAgentPrompt;
127
+ }