btcp-browser-agent 0.1.0 → 0.1.1

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 (136) hide show
  1. package/package.json +8 -9
  2. package/packages/core/dist/actions.d.ts +97 -0
  3. package/packages/core/dist/actions.js +940 -0
  4. package/packages/core/dist/errors.d.ts +138 -0
  5. package/packages/core/dist/errors.js +157 -0
  6. package/packages/core/dist/index.d.ts +120 -0
  7. package/packages/core/dist/index.js +134 -0
  8. package/packages/core/dist/ref-map.d.ts +16 -0
  9. package/packages/core/dist/ref-map.js +91 -0
  10. package/packages/core/dist/snapshot.d.ts +37 -0
  11. package/packages/core/dist/snapshot.js +751 -0
  12. package/packages/core/dist/types.d.ts +396 -0
  13. package/packages/core/dist/types.js +7 -0
  14. package/packages/extension/dist/background.d.ts +227 -0
  15. package/packages/extension/dist/background.js +737 -0
  16. package/packages/extension/dist/content.d.ts +18 -0
  17. package/packages/extension/dist/content.js +149 -0
  18. package/packages/extension/dist/index.d.ts +228 -0
  19. package/packages/extension/dist/index.js +350 -0
  20. package/packages/extension/dist/session-manager.d.ts +87 -0
  21. package/packages/extension/dist/session-manager.js +322 -0
  22. package/packages/extension/{src/session-types.ts → dist/session-types.d.ts} +113 -144
  23. package/packages/extension/dist/session-types.js +5 -0
  24. package/packages/extension/dist/types.d.ts +88 -0
  25. package/packages/extension/dist/types.js +7 -0
  26. package/CLAUDE.md +0 -230
  27. package/SKILL.md +0 -143
  28. package/SNAPSHOT_IMPROVEMENTS.md +0 -302
  29. package/USAGE.md +0 -146
  30. package/dist/index.d.ts.map +0 -1
  31. package/dist/index.js.map +0 -1
  32. package/docs/browser-cli-design.md +0 -500
  33. package/examples/chrome-extension/CHANGELOG.md +0 -210
  34. package/examples/chrome-extension/DEBUG.md +0 -231
  35. package/examples/chrome-extension/ERROR_FIXED.md +0 -147
  36. package/examples/chrome-extension/QUICK_TEST.md +0 -189
  37. package/examples/chrome-extension/README.md +0 -149
  38. package/examples/chrome-extension/SESSION_ONLY_MODE.md +0 -305
  39. package/examples/chrome-extension/TEST_WITH_YOUR_TABS.md +0 -97
  40. package/examples/chrome-extension/build.js +0 -43
  41. package/examples/chrome-extension/manifest.json +0 -37
  42. package/examples/chrome-extension/package-lock.json +0 -1063
  43. package/examples/chrome-extension/package.json +0 -21
  44. package/examples/chrome-extension/popup.html +0 -195
  45. package/examples/chrome-extension/src/background.ts +0 -12
  46. package/examples/chrome-extension/src/content.ts +0 -7
  47. package/examples/chrome-extension/src/popup.ts +0 -303
  48. package/examples/chrome-extension/src/scenario-google-github.ts +0 -389
  49. package/examples/chrome-extension/test-page.html +0 -127
  50. package/examples/chrome-extension/tests/README.md +0 -206
  51. package/examples/chrome-extension/tests/scenario-google-to-github-star.ts +0 -380
  52. package/examples/chrome-extension/tsconfig.json +0 -14
  53. package/examples/snapshots/README.md +0 -207
  54. package/examples/snapshots/amazon-com-detail.html +0 -9528
  55. package/examples/snapshots/amazon-com-detail.snapshot.txt +0 -997
  56. package/examples/snapshots/convert-snapshots.ts +0 -97
  57. package/examples/snapshots/edition-cnn-com.html +0 -13292
  58. package/examples/snapshots/edition-cnn-com.snapshot.txt +0 -562
  59. package/examples/snapshots/github-com-microsoft-vscode.html +0 -2916
  60. package/examples/snapshots/github-com-microsoft-vscode.snapshot.txt +0 -455
  61. package/examples/snapshots/google-search.html +0 -20012
  62. package/examples/snapshots/google-search.snapshot.txt +0 -195
  63. package/examples/snapshots/metadata.json +0 -86
  64. package/examples/snapshots/npr-org-templates.html +0 -2031
  65. package/examples/snapshots/npr-org-templates.snapshot.txt +0 -224
  66. package/examples/snapshots/stackoverflow-com.html +0 -5216
  67. package/examples/snapshots/stackoverflow-com.snapshot.txt +0 -2404
  68. package/examples/snapshots/test-all-mode.html +0 -46
  69. package/examples/snapshots/test-all-mode.snapshot.txt +0 -5
  70. package/examples/snapshots/validate.test.ts +0 -296
  71. package/packages/cli/package.json +0 -42
  72. package/packages/cli/src/__tests__/cli.test.ts +0 -434
  73. package/packages/cli/src/__tests__/errors.test.ts +0 -226
  74. package/packages/cli/src/__tests__/executor.test.ts +0 -275
  75. package/packages/cli/src/__tests__/formatter.test.ts +0 -260
  76. package/packages/cli/src/__tests__/parser.test.ts +0 -288
  77. package/packages/cli/src/__tests__/suggestions.test.ts +0 -255
  78. package/packages/cli/src/commands/back.ts +0 -22
  79. package/packages/cli/src/commands/check.ts +0 -33
  80. package/packages/cli/src/commands/clear.ts +0 -33
  81. package/packages/cli/src/commands/click.ts +0 -32
  82. package/packages/cli/src/commands/closetab.ts +0 -31
  83. package/packages/cli/src/commands/eval.ts +0 -41
  84. package/packages/cli/src/commands/fill.ts +0 -30
  85. package/packages/cli/src/commands/focus.ts +0 -33
  86. package/packages/cli/src/commands/forward.ts +0 -22
  87. package/packages/cli/src/commands/goto.ts +0 -34
  88. package/packages/cli/src/commands/help.ts +0 -162
  89. package/packages/cli/src/commands/hover.ts +0 -34
  90. package/packages/cli/src/commands/index.ts +0 -129
  91. package/packages/cli/src/commands/newtab.ts +0 -35
  92. package/packages/cli/src/commands/press.ts +0 -40
  93. package/packages/cli/src/commands/reload.ts +0 -25
  94. package/packages/cli/src/commands/screenshot.ts +0 -27
  95. package/packages/cli/src/commands/scroll.ts +0 -64
  96. package/packages/cli/src/commands/select.ts +0 -35
  97. package/packages/cli/src/commands/snapshot.ts +0 -21
  98. package/packages/cli/src/commands/tab.ts +0 -32
  99. package/packages/cli/src/commands/tabs.ts +0 -26
  100. package/packages/cli/src/commands/text.ts +0 -27
  101. package/packages/cli/src/commands/title.ts +0 -17
  102. package/packages/cli/src/commands/type.ts +0 -38
  103. package/packages/cli/src/commands/uncheck.ts +0 -33
  104. package/packages/cli/src/commands/url.ts +0 -17
  105. package/packages/cli/src/commands/wait.ts +0 -54
  106. package/packages/cli/src/errors.ts +0 -164
  107. package/packages/cli/src/executor.ts +0 -68
  108. package/packages/cli/src/formatter.ts +0 -215
  109. package/packages/cli/src/index.ts +0 -257
  110. package/packages/cli/src/parser.ts +0 -195
  111. package/packages/cli/src/suggestions.ts +0 -207
  112. package/packages/cli/src/terminal/Terminal.ts +0 -365
  113. package/packages/cli/src/terminal/index.ts +0 -5
  114. package/packages/cli/src/types.ts +0 -155
  115. package/packages/cli/tsconfig.json +0 -20
  116. package/packages/core/package.json +0 -35
  117. package/packages/core/src/actions.ts +0 -1210
  118. package/packages/core/src/errors.ts +0 -296
  119. package/packages/core/src/index.test.ts +0 -638
  120. package/packages/core/src/index.ts +0 -220
  121. package/packages/core/src/ref-map.ts +0 -107
  122. package/packages/core/src/snapshot.ts +0 -873
  123. package/packages/core/src/types.ts +0 -536
  124. package/packages/core/tsconfig.json +0 -23
  125. package/packages/extension/README.md +0 -129
  126. package/packages/extension/package.json +0 -43
  127. package/packages/extension/src/background.ts +0 -888
  128. package/packages/extension/src/content.ts +0 -172
  129. package/packages/extension/src/index.ts +0 -579
  130. package/packages/extension/src/session-manager.ts +0 -385
  131. package/packages/extension/src/types.ts +0 -162
  132. package/packages/extension/tsconfig.json +0 -28
  133. package/src/index.ts +0 -64
  134. package/tsconfig.build.json +0 -12
  135. package/tsconfig.json +0 -26
  136. package/vitest.config.ts +0 -13
@@ -0,0 +1,322 @@
1
+ /**
2
+ * SessionManager - Manages tab groups and sessions for BTCP Browser Agent
3
+ */
4
+ /**
5
+ * Storage key for session persistence
6
+ */
7
+ const SESSION_STORAGE_KEY = 'btcp_active_session';
8
+ /**
9
+ * SessionManager handles Chrome tab group operations and session state
10
+ */
11
+ export class SessionManager {
12
+ activeSessionGroupId = null;
13
+ sessionCounter = 0;
14
+ initialized = false;
15
+ constructor() {
16
+ // Restore session on creation
17
+ this.restoreSession();
18
+ }
19
+ /**
20
+ * Restore session from storage
21
+ */
22
+ async restoreSession() {
23
+ if (this.initialized)
24
+ return;
25
+ try {
26
+ console.log('[SessionManager] Restoring session from storage...');
27
+ const result = await chrome.storage.session.get(SESSION_STORAGE_KEY);
28
+ const data = result[SESSION_STORAGE_KEY];
29
+ if (data?.groupId) {
30
+ console.log('[SessionManager] Found stored session:', data);
31
+ // Verify the group still exists
32
+ try {
33
+ const group = await chrome.tabGroups.get(data.groupId);
34
+ console.log('[SessionManager] Group still exists:', group);
35
+ // Restore session state
36
+ this.activeSessionGroupId = data.groupId;
37
+ this.sessionCounter = data.sessionCounter;
38
+ console.log('[SessionManager] Session restored successfully');
39
+ }
40
+ catch (err) {
41
+ console.log('[SessionManager] Stored group no longer exists, clearing...');
42
+ await this.clearStoredSession();
43
+ }
44
+ }
45
+ else {
46
+ console.log('[SessionManager] No stored session found');
47
+ }
48
+ }
49
+ catch (err) {
50
+ console.error('[SessionManager] Failed to restore session:', err);
51
+ }
52
+ finally {
53
+ this.initialized = true;
54
+ }
55
+ }
56
+ /**
57
+ * Persist session to storage
58
+ */
59
+ async persistSession() {
60
+ if (this.activeSessionGroupId === null) {
61
+ await this.clearStoredSession();
62
+ return;
63
+ }
64
+ const data = {
65
+ groupId: this.activeSessionGroupId,
66
+ sessionCounter: this.sessionCounter,
67
+ timestamp: Date.now(),
68
+ };
69
+ try {
70
+ await chrome.storage.session.set({ [SESSION_STORAGE_KEY]: data });
71
+ console.log('[SessionManager] Session persisted:', data);
72
+ }
73
+ catch (err) {
74
+ console.error('[SessionManager] Failed to persist session:', err);
75
+ }
76
+ }
77
+ /**
78
+ * Clear stored session
79
+ */
80
+ async clearStoredSession() {
81
+ try {
82
+ await chrome.storage.session.remove(SESSION_STORAGE_KEY);
83
+ console.log('[SessionManager] Cleared stored session');
84
+ }
85
+ catch (err) {
86
+ console.error('[SessionManager] Failed to clear stored session:', err);
87
+ }
88
+ }
89
+ /**
90
+ * Reconnect to a specific session group
91
+ * Used when popup detects a stored session that isn't currently active
92
+ */
93
+ async reconnectSession(groupId) {
94
+ try {
95
+ console.log('[SessionManager] Attempting to reconnect to session group:', groupId);
96
+ // Verify the group still exists
97
+ const group = await chrome.tabGroups.get(groupId);
98
+ console.log('[SessionManager] Group found:', group);
99
+ // Get stored session data for counter
100
+ const result = await chrome.storage.session.get(SESSION_STORAGE_KEY);
101
+ const data = result[SESSION_STORAGE_KEY];
102
+ // Restore session state
103
+ this.activeSessionGroupId = groupId;
104
+ this.sessionCounter = data?.sessionCounter ?? this.sessionCounter;
105
+ console.log('[SessionManager] Session reconnected successfully');
106
+ return true;
107
+ }
108
+ catch (err) {
109
+ console.error('[SessionManager] Failed to reconnect session:', err);
110
+ // Clear invalid stored session
111
+ await this.clearStoredSession();
112
+ return false;
113
+ }
114
+ }
115
+ /**
116
+ * Create a new tab group
117
+ */
118
+ async createGroup(options = {}) {
119
+ console.log('[SessionManager] createGroup called with options:', options);
120
+ const { tabIds = [], title = this.generateSessionName(), color = 'blue', collapsed = false, } = options;
121
+ // If no tabIds provided, create a new blank tab for the session
122
+ let targetTabIds = tabIds;
123
+ if (targetTabIds.length === 0) {
124
+ console.log('[SessionManager] No tabIds provided, creating new blank tab...');
125
+ const newTab = await chrome.tabs.create({
126
+ url: 'about:blank',
127
+ active: true
128
+ });
129
+ console.log('[SessionManager] Created new tab:', newTab.id);
130
+ if (newTab?.id) {
131
+ targetTabIds = [newTab.id];
132
+ }
133
+ else {
134
+ console.error('[SessionManager] Failed to create new tab');
135
+ throw new Error('Failed to create new tab for session');
136
+ }
137
+ }
138
+ console.log('[SessionManager] Creating group with tabs:', targetTabIds);
139
+ // Get the window for the tab (must be a normal window)
140
+ const tabs = await chrome.tabs.query({ windowId: chrome.windows.WINDOW_ID_CURRENT });
141
+ const targetTab = tabs.find(t => targetTabIds.includes(t.id));
142
+ if (!targetTab || !targetTab.windowId) {
143
+ console.error('[SessionManager] Could not find valid window for tab');
144
+ throw new Error('Could not find a normal window for the tab');
145
+ }
146
+ // Verify it's a normal window, not popup/devtools/etc
147
+ const window = await chrome.windows.get(targetTab.windowId);
148
+ if (window.type !== 'normal') {
149
+ console.error('[SessionManager] Window is not normal type:', window.type);
150
+ throw new Error(`Tabs can only be grouped in normal windows, not ${window.type} windows`);
151
+ }
152
+ // Create the group
153
+ const groupId = await chrome.tabs.group({
154
+ tabIds: targetTabIds,
155
+ createProperties: {
156
+ windowId: targetTab.windowId,
157
+ },
158
+ });
159
+ console.log('[SessionManager] Group created with ID:', groupId);
160
+ // Update group properties
161
+ await chrome.tabGroups.update(groupId, {
162
+ title,
163
+ color,
164
+ collapsed,
165
+ });
166
+ console.log('[SessionManager] Group updated with title:', title);
167
+ // Set as active session
168
+ this.activeSessionGroupId = groupId;
169
+ // Persist to storage
170
+ await this.persistSession();
171
+ // Get group info
172
+ const group = await chrome.tabGroups.get(groupId);
173
+ console.log('[SessionManager] Group info:', group);
174
+ return this.mapChromeGroupToGroupInfo(group);
175
+ }
176
+ /**
177
+ * Update an existing tab group
178
+ */
179
+ async updateGroup(groupId, options) {
180
+ await chrome.tabGroups.update(groupId, {
181
+ ...(options.title !== undefined && { title: options.title }),
182
+ ...(options.color !== undefined && { color: options.color }),
183
+ ...(options.collapsed !== undefined && { collapsed: options.collapsed }),
184
+ });
185
+ const group = await chrome.tabGroups.get(groupId);
186
+ return this.mapChromeGroupToGroupInfo(group);
187
+ }
188
+ /**
189
+ * Delete a tab group (closes all tabs in the group)
190
+ */
191
+ async deleteGroup(groupId) {
192
+ // Get all tabs in the group
193
+ const tabs = await chrome.tabs.query({ groupId });
194
+ const tabIds = tabs.map((tab) => tab.id).filter((id) => id !== undefined);
195
+ // Close all tabs (this automatically removes the group)
196
+ if (tabIds.length > 0) {
197
+ await chrome.tabs.remove(tabIds);
198
+ }
199
+ // Clear active session if this was the active group
200
+ if (this.activeSessionGroupId === groupId) {
201
+ this.activeSessionGroupId = null;
202
+ // Clear from storage
203
+ await this.clearStoredSession();
204
+ }
205
+ }
206
+ /**
207
+ * List all tab groups
208
+ */
209
+ async listGroups() {
210
+ const groups = await chrome.tabGroups.query({});
211
+ return groups.map((group) => this.mapChromeGroupToGroupInfo(group));
212
+ }
213
+ /**
214
+ * Get a specific tab group
215
+ */
216
+ async getGroup(groupId) {
217
+ const group = await chrome.tabGroups.get(groupId);
218
+ return this.mapChromeGroupToGroupInfo(group);
219
+ }
220
+ /**
221
+ * Add tabs to a group
222
+ */
223
+ async addTabsToGroup(groupId, tabIds) {
224
+ await chrome.tabs.group({
225
+ groupId,
226
+ tabIds,
227
+ });
228
+ }
229
+ /**
230
+ * Remove tabs from their group (ungroup them)
231
+ */
232
+ async removeTabsFromGroup(tabIds) {
233
+ await chrome.tabs.ungroup(tabIds);
234
+ }
235
+ /**
236
+ * Get current active session info
237
+ */
238
+ async getCurrentSession() {
239
+ if (this.activeSessionGroupId === null) {
240
+ return null;
241
+ }
242
+ try {
243
+ const group = await chrome.tabGroups.get(this.activeSessionGroupId);
244
+ const tabs = await chrome.tabs.query({ groupId: this.activeSessionGroupId });
245
+ const tabIds = tabs.map((tab) => tab.id).filter((id) => id !== undefined);
246
+ return {
247
+ groupId: this.activeSessionGroupId,
248
+ title: group.title || 'Untitled Session',
249
+ color: group.color,
250
+ tabCount: tabs.length,
251
+ tabIds,
252
+ windowId: group.windowId,
253
+ createdAt: Date.now(),
254
+ };
255
+ }
256
+ catch (error) {
257
+ // Group no longer exists
258
+ this.activeSessionGroupId = null;
259
+ return null;
260
+ }
261
+ }
262
+ /**
263
+ * Get the active session group ID
264
+ */
265
+ getActiveSessionGroupId() {
266
+ return this.activeSessionGroupId;
267
+ }
268
+ /**
269
+ * Set the active session group ID
270
+ */
271
+ setActiveSessionGroupId(groupId) {
272
+ this.activeSessionGroupId = groupId;
273
+ }
274
+ /**
275
+ * Add a tab to the active session (if one exists)
276
+ */
277
+ async addTabToActiveSession(tabId) {
278
+ if (this.activeSessionGroupId === null) {
279
+ return false;
280
+ }
281
+ try {
282
+ await this.addTabsToGroup(this.activeSessionGroupId, [tabId]);
283
+ return true;
284
+ }
285
+ catch (error) {
286
+ // Group may no longer exist
287
+ this.activeSessionGroupId = null;
288
+ return false;
289
+ }
290
+ }
291
+ /**
292
+ * Generate a session name
293
+ */
294
+ generateSessionName() {
295
+ this.sessionCounter++;
296
+ return `BTCP Session ${this.sessionCounter}`;
297
+ }
298
+ /**
299
+ * Map Chrome tab group to GroupInfo
300
+ */
301
+ mapChromeGroupToGroupInfo(group) {
302
+ return {
303
+ id: group.id,
304
+ title: group.title,
305
+ color: group.color,
306
+ collapsed: group.collapsed,
307
+ windowId: group.windowId,
308
+ };
309
+ }
310
+ }
311
+ // Singleton instance
312
+ let sessionManagerInstance = null;
313
+ /**
314
+ * Get the singleton SessionManager instance
315
+ */
316
+ export function getSessionManager() {
317
+ if (!sessionManagerInstance) {
318
+ sessionManagerInstance = new SessionManager();
319
+ }
320
+ return sessionManagerInstance;
321
+ }
322
+ //# sourceMappingURL=session-manager.js.map
@@ -1,144 +1,113 @@
1
- /**
2
- * Session and Tab Group types for BTCP Browser Agent
3
- */
4
-
5
- import type { ExtensionBaseCommand } from './types.js';
6
-
7
- /**
8
- * Chrome tab group color options
9
- */
10
- export type GroupColor =
11
- | 'grey'
12
- | 'blue'
13
- | 'red'
14
- | 'yellow'
15
- | 'green'
16
- | 'pink'
17
- | 'purple'
18
- | 'cyan'
19
- | 'orange';
20
-
21
- /**
22
- * Tab group information
23
- */
24
- export interface GroupInfo {
25
- id: number;
26
- title?: string;
27
- color: GroupColor;
28
- collapsed: boolean;
29
- windowId: number;
30
- }
31
-
32
- /**
33
- * Session information
34
- */
35
- export interface SessionInfo {
36
- groupId: number;
37
- title: string;
38
- color: GroupColor;
39
- tabCount: number;
40
- tabIds: number[];
41
- windowId: number;
42
- createdAt: number;
43
- }
44
-
45
- /**
46
- * Options for creating a new tab group
47
- */
48
- export interface GroupCreateOptions {
49
- tabIds?: number[];
50
- title?: string;
51
- color?: GroupColor;
52
- collapsed?: boolean;
53
- }
54
-
55
- /**
56
- * Options for updating a tab group
57
- */
58
- export interface GroupUpdateOptions {
59
- title?: string;
60
- color?: GroupColor;
61
- collapsed?: boolean;
62
- }
63
-
64
- /**
65
- * Command to create a new tab group
66
- */
67
- export interface GroupCreateCommand extends ExtensionBaseCommand {
68
- action: 'groupCreate';
69
- tabIds?: number[];
70
- title?: string;
71
- color?: GroupColor;
72
- collapsed?: boolean;
73
- }
74
-
75
- /**
76
- * Command to update a tab group
77
- */
78
- export interface GroupUpdateCommand extends ExtensionBaseCommand {
79
- action: 'groupUpdate';
80
- groupId: number;
81
- title?: string;
82
- color?: GroupColor;
83
- collapsed?: boolean;
84
- }
85
-
86
- /**
87
- * Command to delete a tab group (closes all tabs)
88
- */
89
- export interface GroupDeleteCommand extends ExtensionBaseCommand {
90
- action: 'groupDelete';
91
- groupId: number;
92
- }
93
-
94
- /**
95
- * Command to list all tab groups
96
- */
97
- export interface GroupListCommand extends ExtensionBaseCommand {
98
- action: 'groupList';
99
- }
100
-
101
- /**
102
- * Command to add tabs to a group
103
- */
104
- export interface GroupAddTabsCommand extends ExtensionBaseCommand {
105
- action: 'groupAddTabs';
106
- groupId: number;
107
- tabIds: number[];
108
- }
109
-
110
- /**
111
- * Command to remove tabs from a group
112
- */
113
- export interface GroupRemoveTabsCommand extends ExtensionBaseCommand {
114
- action: 'groupRemoveTabs';
115
- tabIds: number[];
116
- }
117
-
118
- /**
119
- * Command to get a specific tab group
120
- */
121
- export interface GroupGetCommand extends ExtensionBaseCommand {
122
- action: 'groupGet';
123
- groupId: number;
124
- }
125
-
126
- /**
127
- * Command to get current active session
128
- */
129
- export interface SessionGetCurrentCommand extends ExtensionBaseCommand {
130
- action: 'sessionGetCurrent';
131
- }
132
-
133
- /**
134
- * Union type of all session-related commands
135
- */
136
- export type SessionCommand =
137
- | GroupCreateCommand
138
- | GroupUpdateCommand
139
- | GroupDeleteCommand
140
- | GroupListCommand
141
- | GroupAddTabsCommand
142
- | GroupRemoveTabsCommand
143
- | GroupGetCommand
144
- | SessionGetCurrentCommand;
1
+ /**
2
+ * Session and Tab Group types for BTCP Browser Agent
3
+ */
4
+ import type { ExtensionBaseCommand } from './types.js';
5
+ /**
6
+ * Chrome tab group color options
7
+ */
8
+ export type GroupColor = 'grey' | 'blue' | 'red' | 'yellow' | 'green' | 'pink' | 'purple' | 'cyan' | 'orange';
9
+ /**
10
+ * Tab group information
11
+ */
12
+ export interface GroupInfo {
13
+ id: number;
14
+ title?: string;
15
+ color: GroupColor;
16
+ collapsed: boolean;
17
+ windowId: number;
18
+ }
19
+ /**
20
+ * Session information
21
+ */
22
+ export interface SessionInfo {
23
+ groupId: number;
24
+ title: string;
25
+ color: GroupColor;
26
+ tabCount: number;
27
+ tabIds: number[];
28
+ windowId: number;
29
+ createdAt: number;
30
+ }
31
+ /**
32
+ * Options for creating a new tab group
33
+ */
34
+ export interface GroupCreateOptions {
35
+ tabIds?: number[];
36
+ title?: string;
37
+ color?: GroupColor;
38
+ collapsed?: boolean;
39
+ }
40
+ /**
41
+ * Options for updating a tab group
42
+ */
43
+ export interface GroupUpdateOptions {
44
+ title?: string;
45
+ color?: GroupColor;
46
+ collapsed?: boolean;
47
+ }
48
+ /**
49
+ * Command to create a new tab group
50
+ */
51
+ export interface GroupCreateCommand extends ExtensionBaseCommand {
52
+ action: 'groupCreate';
53
+ tabIds?: number[];
54
+ title?: string;
55
+ color?: GroupColor;
56
+ collapsed?: boolean;
57
+ }
58
+ /**
59
+ * Command to update a tab group
60
+ */
61
+ export interface GroupUpdateCommand extends ExtensionBaseCommand {
62
+ action: 'groupUpdate';
63
+ groupId: number;
64
+ title?: string;
65
+ color?: GroupColor;
66
+ collapsed?: boolean;
67
+ }
68
+ /**
69
+ * Command to delete a tab group (closes all tabs)
70
+ */
71
+ export interface GroupDeleteCommand extends ExtensionBaseCommand {
72
+ action: 'groupDelete';
73
+ groupId: number;
74
+ }
75
+ /**
76
+ * Command to list all tab groups
77
+ */
78
+ export interface GroupListCommand extends ExtensionBaseCommand {
79
+ action: 'groupList';
80
+ }
81
+ /**
82
+ * Command to add tabs to a group
83
+ */
84
+ export interface GroupAddTabsCommand extends ExtensionBaseCommand {
85
+ action: 'groupAddTabs';
86
+ groupId: number;
87
+ tabIds: number[];
88
+ }
89
+ /**
90
+ * Command to remove tabs from a group
91
+ */
92
+ export interface GroupRemoveTabsCommand extends ExtensionBaseCommand {
93
+ action: 'groupRemoveTabs';
94
+ tabIds: number[];
95
+ }
96
+ /**
97
+ * Command to get a specific tab group
98
+ */
99
+ export interface GroupGetCommand extends ExtensionBaseCommand {
100
+ action: 'groupGet';
101
+ groupId: number;
102
+ }
103
+ /**
104
+ * Command to get current active session
105
+ */
106
+ export interface SessionGetCurrentCommand extends ExtensionBaseCommand {
107
+ action: 'sessionGetCurrent';
108
+ }
109
+ /**
110
+ * Union type of all session-related commands
111
+ */
112
+ export type SessionCommand = GroupCreateCommand | GroupUpdateCommand | GroupDeleteCommand | GroupListCommand | GroupAddTabsCommand | GroupRemoveTabsCommand | GroupGetCommand | SessionGetCurrentCommand;
113
+ //# sourceMappingURL=session-types.d.ts.map
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Session and Tab Group types for BTCP Browser Agent
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=session-types.js.map
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @btcp/extension - Type definitions
3
+ *
4
+ * Types for extension commands and Chrome API wrappers.
5
+ */
6
+ import type { Command as CoreCommand, Response } from '@btcp/core';
7
+ import type { SessionCommand } from './session-types.js';
8
+ export type ExtensionAction = 'navigate' | 'back' | 'forward' | 'reload' | 'getUrl' | 'getTitle' | 'screenshot' | 'tabNew' | 'tabClose' | 'tabSwitch' | 'tabList' | 'groupCreate' | 'groupUpdate' | 'groupDelete' | 'groupList' | 'groupAddTabs' | 'groupRemoveTabs' | 'groupGet' | 'sessionGetCurrent' | 'popupInitialize';
9
+ export interface ExtensionBaseCommand {
10
+ id: string;
11
+ action: ExtensionAction;
12
+ }
13
+ export interface NavigateCommand extends ExtensionBaseCommand {
14
+ action: 'navigate';
15
+ url: string;
16
+ waitUntil?: 'load' | 'domcontentloaded';
17
+ }
18
+ export interface BackCommand extends ExtensionBaseCommand {
19
+ action: 'back';
20
+ }
21
+ export interface ForwardCommand extends ExtensionBaseCommand {
22
+ action: 'forward';
23
+ }
24
+ export interface ReloadCommand extends ExtensionBaseCommand {
25
+ action: 'reload';
26
+ bypassCache?: boolean;
27
+ }
28
+ export interface GetUrlCommand extends ExtensionBaseCommand {
29
+ action: 'getUrl';
30
+ }
31
+ export interface GetTitleCommand extends ExtensionBaseCommand {
32
+ action: 'getTitle';
33
+ }
34
+ export interface ScreenshotCommand extends ExtensionBaseCommand {
35
+ action: 'screenshot';
36
+ format?: 'png' | 'jpeg';
37
+ quality?: number;
38
+ }
39
+ export interface TabNewCommand extends ExtensionBaseCommand {
40
+ action: 'tabNew';
41
+ url?: string;
42
+ active?: boolean;
43
+ }
44
+ export interface TabCloseCommand extends ExtensionBaseCommand {
45
+ action: 'tabClose';
46
+ tabId?: number;
47
+ }
48
+ export interface TabSwitchCommand extends ExtensionBaseCommand {
49
+ action: 'tabSwitch';
50
+ tabId: number;
51
+ }
52
+ export interface TabListCommand extends ExtensionBaseCommand {
53
+ action: 'tabList';
54
+ }
55
+ export interface PopupInitializeCommand extends ExtensionBaseCommand {
56
+ action: 'popupInitialize';
57
+ }
58
+ export type ExtensionCommand = NavigateCommand | BackCommand | ForwardCommand | ReloadCommand | GetUrlCommand | GetTitleCommand | ScreenshotCommand | TabNewCommand | TabCloseCommand | TabSwitchCommand | TabListCommand | PopupInitializeCommand | SessionCommand;
59
+ export type Command = CoreCommand | ExtensionCommand;
60
+ export type { Response };
61
+ export type { SessionCommand, GroupInfo, SessionInfo, GroupCreateOptions, GroupUpdateOptions, } from './session-types.js';
62
+ export interface ExtensionCommandMessage {
63
+ type: 'btcp:command';
64
+ command: Command;
65
+ tabId?: number;
66
+ }
67
+ export interface ExtensionPingMessage {
68
+ type: 'btcp:ping';
69
+ }
70
+ export type ExtensionMessage = ExtensionCommandMessage | ExtensionPingMessage;
71
+ export interface ExtensionResponseMessage {
72
+ type: 'btcp:response';
73
+ response: Response;
74
+ }
75
+ export interface ExtensionPongResponse {
76
+ type: 'btcp:pong';
77
+ ready: boolean;
78
+ }
79
+ export type ExtensionResponse = ExtensionResponseMessage | ExtensionPongResponse;
80
+ export interface TabInfo {
81
+ id: number;
82
+ url?: string;
83
+ title?: string;
84
+ active: boolean;
85
+ index: number;
86
+ }
87
+ export type ChromeTab = chrome.tabs.Tab;
88
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @btcp/extension - Type definitions
3
+ *
4
+ * Types for extension commands and Chrome API wrappers.
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map