@thinkrun/cli 0.1.37 → 0.1.38

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/README.md CHANGED
@@ -131,6 +131,17 @@ thinkrun cloud stop
131
131
  | `doctor` | Diagnose endpoint/auth/session setup |
132
132
  | `audit on|off|status` | Enable, disable, or inspect local audit mode for the attached tab |
133
133
 
134
+ ### Recording upload
135
+
136
+ Upload an explicit local video for ThinkRun analysis without using the extension bridge:
137
+
138
+ ```bash
139
+ thinkrun recording upload ./walkthrough.webm --intent feedback --title "Checkout issue" --url https://example.com
140
+ thinkrun recording upload ./walkthrough.webm --dry-run
141
+ ```
142
+
143
+ Only regular readable `.webm`, `.mp4`, and `.mov` files up to 5 GiB are accepted. The command creates a recording, uploads directly with the service-provided presign when available, then finalizes analysis; it falls back to the authenticated recording stream only when direct upload is unavailable. `--dry-run` validates locally and makes no API request.
144
+
134
145
  #### Cloud Start Options
135
146
 
136
147
  ```bash
@@ -20,6 +20,7 @@ import { createSetupCommand } from '../src/commands/setup.js';
20
20
  import { createAnalyzeCommand } from '../src/commands/analyze.js';
21
21
  import { createSessionsCommand } from '../src/commands/sessions.js';
22
22
  import { createReleaseCommand } from '../src/commands/release.js';
23
+ import { createRecordingCommand } from '../src/commands/recording.js';
23
24
  import { createAgentInitCommand } from '../src/commands/agent-init.js';
24
25
  import { createNavigateCommand, createClickCommand, createClickAtCommand, createTypeCommand, createFillCommand, createScrollCommand, createWaitCommand, createWaitForTextCommand, createHoverCommand, createSelectCommand, createPressCommand, createBackCommand, createForwardCommand, createResumeCommand, createSnapshotCommand, createScreenshotCommand, createExtractCommand, createEvaluateCommand, createDialogCommand, createConsoleCommand, createNetworkCommand, createTabsCommand, createNewTabCommand, createCloseTabCommand, createAttachCommand, createUrlCommand, createTitleCommand, createHtmlCommand, createClearLogsCommand, createSwitchTabCommand, createFocusCommand, createNewWindowCommand, createTaskCommand, createTaskStatusCommand, createTaskCancelCommand, } from '../src/commands/actions.js';
25
26
  const __filename = fileURLToPath(import.meta.url);
@@ -100,6 +101,7 @@ program.addCommand(createSwitchTabCommand());
100
101
  program.addCommand(createFocusCommand());
101
102
  program.addCommand(createNewWindowCommand());
102
103
  program.addCommand(createReleaseCommand());
104
+ program.addCommand(createRecordingCommand());
103
105
  // Page info
104
106
  program.addCommand(createUrlCommand());
105
107
  program.addCommand(createTitleCommand());
@@ -1 +1 @@
1
- {"version":3,"file":"thinkrun.js","sourceRoot":"","sources":["../../bin/thinkrun.ts"],"names":[],"mappings":";AAEA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,qB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E,CAAC,CAAC;AAE9C,qBAAqB;AACrB,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAC;AAE3C,8BAA8B;AAC9B,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE,CAAC,CAAC;AAE5C,0EAA0E;AAC1E,0EAA0E;AAC1E,4EAA4E;AAC5E,yEAAyE;AACzE,wEAAwE;AACxE,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAG,gBAAgB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAI,+BAA+B;AAC1F,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,gBAAgB,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,wCAAwC;AAEnG,kBAAkB;AAClB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,mCAAmC;AACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC"}
@@ -0,0 +1,5 @@
1
+ export const MAX_RECORDING_UPLOAD_BYTES: number;
2
+ export class RecordingUploadError extends Error { code: string; }
3
+ export interface RecordingUploadFile { path: string; filename: string; sizeBytes: number; device: number; inode: number; contentType: 'video/webm' | 'video/mp4' | 'video/quicktime'; }
4
+ export function inspectRecordingUploadFile(path: string): Promise<RecordingUploadFile>;
5
+ export function uploadRecordingFile(options: { path: string; apiBase: string; apiKey?: string; intent?: string; title?: string; url?: string; dryRun?: boolean; fetchImpl?: typeof fetch }): Promise<Record<string, unknown>>;
@@ -0,0 +1,177 @@
1
+ /**
2
+ * Agent-facing local recording upload. This module deliberately accepts a path,
3
+ * never media bytes supplied by an API caller, and talks to the recording API
4
+ * directly (not through the browser extension/native bridge).
5
+ */
6
+ import { createReadStream } from 'node:fs';
7
+ import { access, lstat, open } from 'node:fs/promises';
8
+ import { constants } from 'node:fs';
9
+ import { basename, extname, resolve } from 'node:path';
10
+ import axios from 'axios';
11
+
12
+ export const MAX_RECORDING_UPLOAD_BYTES = 5 * 1024 * 1024 * 1024;
13
+ const MIME_BY_EXTENSION = Object.freeze({ '.webm': 'video/webm', '.mp4': 'video/mp4', '.mov': 'video/quicktime' });
14
+ const REQUEST_TIMEOUT_MS = 30_000;
15
+ const UPLOAD_TIMEOUT_MS = 30 * 60_000;
16
+ const CLEANUP_TIMEOUT_MS = 5_000;
17
+
18
+ export class RecordingUploadError extends Error {
19
+ constructor(code, message) { super(message); this.name = 'RecordingUploadError'; this.code = code; }
20
+ }
21
+
22
+ function safeMessage(value, fallback) {
23
+ const text = String(value || fallback)
24
+ .replace(/https?:\/\/[^\s"']+/gi, '[redacted-url]')
25
+ .replace(/\bauthorization\s*[:=]\s*(?:bearer\s+)?[^\s,;]+/gi, 'Authorization: [redacted]')
26
+ .replace(/\b(?:uploadToken|api[_-]?key|authorization)\s*[:=]\s*[^\s,;]+/gi, '[redacted-credential]')
27
+ .replace(/"(?:uploadToken|api[_-]?key|authorization)"\s*:\s*"[^"]*"/gi, '"[redacted-credential]"')
28
+ .replace(/\bBearer\s+[^\s,;]+/gi, 'Bearer [redacted]');
29
+ return text.slice(0, 500);
30
+ }
31
+
32
+ export async function inspectRecordingUploadFile(path) {
33
+ if (typeof path !== 'string' || !path.trim()) throw new RecordingUploadError('INVALID_PATH', 'A non-empty local file path is required');
34
+ const resolvedPath = resolve(path);
35
+ let info;
36
+ try { info = await lstat(resolvedPath); await access(resolvedPath, constants.R_OK); }
37
+ catch { throw new RecordingUploadError('FILE_NOT_READABLE', 'Recording file is not readable'); }
38
+ if (info.isSymbolicLink()) throw new RecordingUploadError('SYMLINK_NOT_ALLOWED', 'Recording path must not be a symbolic link');
39
+ if (!info.isFile()) throw new RecordingUploadError('NOT_A_REGULAR_FILE', 'Recording path must be a regular readable file');
40
+ const contentType = MIME_BY_EXTENSION[extname(resolvedPath).toLowerCase()];
41
+ if (!contentType) throw new RecordingUploadError('UNSUPPORTED_MEDIA_TYPE', 'Recording must be a .webm, .mp4, or .mov file');
42
+ if (info.size > MAX_RECORDING_UPLOAD_BYTES) throw new RecordingUploadError('FILE_TOO_LARGE', 'Recording exceeds the 5 GiB upload limit');
43
+ return { path: resolvedPath, filename: basename(resolvedPath), sizeBytes: info.size, device: info.dev, inode: info.ino, contentType };
44
+ }
45
+
46
+ function headers(apiKey, contentType = 'application/json') {
47
+ const result = { 'Content-Type': contentType };
48
+ const key = apiKey?.trim();
49
+ if (key) { result['X-API-Key'] = key; result.Authorization = `Bearer ${key}`; }
50
+ return result;
51
+ }
52
+
53
+ async function request(fetchImpl, url, options) {
54
+ const response = await fetchImpl(url, { ...options, signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS) });
55
+ if (!response.ok) throw new RecordingUploadError('API_ERROR', `Recording upload request failed (HTTP ${response.status})`);
56
+ return response.json();
57
+ }
58
+
59
+ function requireSuccess(payload, code, message) {
60
+ if (!payload?.success) throw new RecordingUploadError(code, message);
61
+ return payload;
62
+ }
63
+
64
+ // These failures occur before a socket can deliver upload bytes. Other thrown
65
+ // transport errors are deliberately treated as ambiguous and retained for the
66
+ // server-side recovery path; a response may have been lost after storage wrote.
67
+ function isDefinitivePreTransferError(error) {
68
+ return ['ENOTFOUND', 'ECONNREFUSED', 'ERR_INVALID_URL'].includes(error?.code);
69
+ }
70
+
71
+ async function cleanup(fetchImpl, baseUrl, apiKey, recordingId) {
72
+ if (!recordingId) return;
73
+ try {
74
+ await Promise.race([
75
+ fetchImpl(`${baseUrl}/api/feedback/recordings/${encodeURIComponent(recordingId)}`, { method: 'DELETE', headers: headers(apiKey), signal: AbortSignal.timeout(CLEANUP_TIMEOUT_MS) }),
76
+ new Promise((resolve) => setTimeout(resolve, CLEANUP_TIMEOUT_MS)),
77
+ ]);
78
+ }
79
+ catch { /* owned-stub cleanup is intentionally best effort */ }
80
+ }
81
+
82
+ /** @param {{ path:string, apiBase:string, apiKey?:string, intent?:string, title?:string, url?:string, dryRun?:boolean, fetchImpl?:typeof fetch }} options */
83
+ export async function uploadRecordingFile(options) {
84
+ const file = await inspectRecordingUploadFile(options.path);
85
+ const { device: _device, inode: _inode, ...publicFile } = file;
86
+ const intent = String(options.intent || 'feedback');
87
+ const title = String(options.title || file.filename);
88
+ if (intent.length > 200) throw new RecordingUploadError('INVALID_INTENT', 'Analysis intent must be 200 characters or fewer');
89
+ if (title.length > 500) throw new RecordingUploadError('INVALID_TITLE', 'Recording title must be 500 characters or fewer');
90
+ const url = options.url ? String(options.url) : '';
91
+ if (url) {
92
+ try { const parsed = new URL(url); if (!['http:', 'https:'].includes(parsed.protocol)) throw new Error('protocol'); }
93
+ catch { throw new RecordingUploadError('INVALID_URL', 'Associated URL must be an absolute http(s) URL'); }
94
+ }
95
+ if (options.dryRun) return { success: true, dryRun: true, source: 'cli', intent, title, url, ...publicFile };
96
+ const baseUrl = String(options.apiBase || '').replace(/\/$/, '');
97
+ if (!/^https?:\/\//.test(baseUrl)) throw new RecordingUploadError('INVALID_API_BASE', 'A valid API base URL is required');
98
+ const fetchImpl = options.fetchImpl || fetch;
99
+ let recordingId;
100
+ let uploadStarted = false;
101
+ let handle;
102
+ try {
103
+ // Open once after validation and stream that descriptor, preventing a path swap
104
+ // between inspection and upload. O_NOFOLLOW is an additional OS-level guard.
105
+ handle = await open(file.path, constants.O_RDONLY | (constants.O_NOFOLLOW || 0));
106
+ const opened = await handle.stat();
107
+ if (!opened.isFile() || opened.size !== file.sizeBytes || opened.dev !== file.device || opened.ino !== file.inode) throw new RecordingUploadError('FILE_CHANGED', 'Recording file changed during validation');
108
+ const stream = () => createReadStream(file.path, { fd: handle.fd, autoClose: false });
109
+ const created = requireSuccess(await request(fetchImpl, `${baseUrl}/api/feedback/recordings`, {
110
+ method: 'POST', headers: headers(options.apiKey), body: JSON.stringify({
111
+ source: 'cli', videoContentType: file.contentType,
112
+ metadata: { version: '1.0', duration: 0, url, title, profile: 'simple', intent, features: { audio: false, console: false, network: false, dom: false } },
113
+ actions: [], browserState: { consoleLogs: [], networkRequests: [] }, elements: [],
114
+ }),
115
+ }), 'CREATE_FAILED', 'Recording creation failed');
116
+ recordingId = created?.recordingId;
117
+ if (!created?.success || typeof recordingId !== 'string') throw new RecordingUploadError('CREATE_FAILED', 'Recording creation returned an invalid response');
118
+ let strategy = 'stream';
119
+ const directKeys = ['uploadUrl', 'uploadToken', 'presignedVideoObjectId'];
120
+ const directFields = directKeys.map((key) => created[key]);
121
+ if (directKeys.some((key) => Object.hasOwn(created, key)) && !directFields.every((value) => typeof value === 'string' && value.length > 0)) throw new RecordingUploadError('INVALID_DIRECT_UPLOAD_RESPONSE', 'Recording creation returned incomplete direct upload details');
122
+ if (directFields.every(Boolean)) {
123
+ strategy = 'direct';
124
+ // A dropped storage/finalize response can follow a successful write. Once
125
+ // upload begins, preserve the recording for recovery rather than deleting
126
+ // a valid upload and its queued analysis on an ambiguous outcome.
127
+ uploadStarted = true;
128
+ // Axios preserves Content-Length for Node file streams; fetch sends these
129
+ // as chunked bodies and R2's presigned endpoint rejects them with HTTP 411.
130
+ let direct;
131
+ try {
132
+ direct = options.fetchImpl
133
+ ? await fetchImpl(created.uploadUrl, { method: 'PUT', headers: { 'Content-Type': created.presignedVideoContentType || file.contentType, 'Content-Length': String(file.sizeBytes) }, body: stream(), duplex: 'half', signal: AbortSignal.timeout(UPLOAD_TIMEOUT_MS) })
134
+ : await axios.put(created.uploadUrl, stream(), { headers: { 'Content-Type': created.presignedVideoContentType || file.contentType, 'Content-Length': String(file.sizeBytes) }, maxBodyLength: MAX_RECORDING_UPLOAD_BYTES, timeout: UPLOAD_TIMEOUT_MS, validateStatus: () => true });
135
+ } catch (error) {
136
+ if (isDefinitivePreTransferError(error)) uploadStarted = false;
137
+ throw error;
138
+ }
139
+ const directSucceeded = typeof direct.ok === 'boolean'
140
+ ? direct.ok
141
+ : typeof direct.status === 'number' && direct.status >= 200 && direct.status < 300;
142
+ if (!directSucceeded) {
143
+ // Only a client-side rejection is definitive. A 5xx can be emitted
144
+ // after storage accepted bytes, so preserve recovery state for it.
145
+ if (direct.status >= 400 && direct.status < 500 && direct.status !== 408) uploadStarted = false;
146
+ throw new RecordingUploadError('DIRECT_UPLOAD_FAILED', `Direct recording upload failed (HTTP ${direct.status})`);
147
+ }
148
+ const finalized = requireSuccess(await request(fetchImpl, `${baseUrl}/api/feedback/recordings/${encodeURIComponent(recordingId)}/video/complete`, { method: 'POST', headers: headers(options.apiKey), body: JSON.stringify({ objectId: created.presignedVideoObjectId, uploadToken: created.uploadToken, sizeBytes: file.sizeBytes }) }), 'FINALIZE_FAILED', 'Recording upload finalize failed');
149
+ return { success: Boolean(finalized?.success), recordingId, source: 'cli', uploadStrategy: strategy, analysisEnqueued: Boolean(finalized?.analysisEnqueued), analysisJobId: finalized?.analysisJobId || null, analysisStatus: finalized?.analysisStatus || null, warning: finalized?.analysisEnqueueError ? safeMessage(finalized.analysisEnqueueError, 'Analysis enqueue failed') : undefined };
150
+ }
151
+ uploadStarted = true;
152
+ let streamedResponse;
153
+ try {
154
+ streamedResponse = options.fetchImpl
155
+ ? await fetchImpl(`${baseUrl}/api/feedback/recordings/${encodeURIComponent(recordingId)}/video`, { method: 'PUT', headers: { ...headers(options.apiKey, file.contentType), 'Content-Length': String(file.sizeBytes) }, body: stream(), duplex: 'half', signal: AbortSignal.timeout(UPLOAD_TIMEOUT_MS) })
156
+ : await axios.put(`${baseUrl}/api/feedback/recordings/${encodeURIComponent(recordingId)}/video`, stream(), { headers: { ...headers(options.apiKey, file.contentType), 'Content-Length': String(file.sizeBytes) }, maxBodyLength: MAX_RECORDING_UPLOAD_BYTES, timeout: UPLOAD_TIMEOUT_MS, validateStatus: () => true });
157
+ } catch (error) {
158
+ if (isDefinitivePreTransferError(error)) uploadStarted = false;
159
+ throw error;
160
+ }
161
+ const streamSucceeded = typeof streamedResponse.ok === 'boolean'
162
+ ? streamedResponse.ok
163
+ : typeof streamedResponse.status === 'number' && streamedResponse.status >= 200 && streamedResponse.status < 300;
164
+ if (!streamSucceeded) {
165
+ if (streamedResponse.status >= 400 && streamedResponse.status < 500 && streamedResponse.status !== 408) uploadStarted = false;
166
+ throw new RecordingUploadError('STREAM_UPLOAD_FAILED', `Streaming recording upload failed (HTTP ${streamedResponse.status})`);
167
+ }
168
+ const streamed = requireSuccess(typeof streamedResponse.json === 'function' ? await streamedResponse.json() : streamedResponse.data, 'STREAM_UPLOAD_FAILED', 'Streaming recording upload failed');
169
+ return { success: Boolean(streamed?.success), recordingId, source: 'cli', uploadStrategy: strategy, analysisEnqueued: Boolean(streamed?.analysisEnqueued), analysisJobId: streamed?.analysisJobId || null, analysisStatus: streamed?.analysisStatus || null, warning: streamed?.analysisEnqueueError ? safeMessage(streamed.analysisEnqueueError, 'Analysis enqueue failed') : undefined };
170
+ } catch (error) {
171
+ if (!uploadStarted) await cleanup(fetchImpl, baseUrl, options.apiKey, recordingId);
172
+ if (error instanceof RecordingUploadError) throw error;
173
+ throw new RecordingUploadError('UPLOAD_FAILED', safeMessage(error?.message, 'Recording upload failed'));
174
+ } finally {
175
+ await handle?.close().catch(() => {});
176
+ }
177
+ }
@@ -0,0 +1,141 @@
1
+ import { afterEach, describe, expect, test } from 'bun:test';
2
+ import { mkdtemp, writeFile, rm, symlink } from 'node:fs/promises';
3
+ import { tmpdir } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import { inspectRecordingUploadFile, uploadRecordingFile } from './recording-upload.js';
6
+
7
+ const dirs = [];
8
+ async function fixture(name = 'capture.webm') {
9
+ const dir = await mkdtemp(join(tmpdir(), 'thinkrun-upload-')); dirs.push(dir);
10
+ const path = join(dir, name); await writeFile(path, 'video'); return path;
11
+ }
12
+ afterEach(async () => { await Promise.all(dirs.splice(0).map((dir) => rm(dir, { recursive: true, force: true }))); });
13
+
14
+ describe('agent recording upload', () => {
15
+ test('validates explicit file locally and dry run makes no request', async () => {
16
+ const path = await fixture();
17
+ expect(await inspectRecordingUploadFile(path)).toMatchObject({ contentType: 'video/webm', sizeBytes: 5 });
18
+ const result = await uploadRecordingFile({ path, dryRun: true, apiBase: 'https://api.example.test', fetchImpl: () => { throw new Error('network'); } });
19
+ expect(result).toMatchObject({ success: true, dryRun: true, source: 'cli', intent: 'feedback', contentType: 'video/webm' });
20
+ });
21
+
22
+ test('uses direct upload then finalizes without returning credentials', async () => {
23
+ const path = await fixture(); const calls = [];
24
+ const fetchImpl = async (url, init = {}) => {
25
+ calls.push({ url, init });
26
+ if (String(url).endsWith('/recordings')) return new Response(JSON.stringify({ success: true, recordingId: 'rec-12345678', uploadUrl: 'https://signed.example.test/token', uploadToken: 'token-secret', presignedVideoObjectId: 'object-1', presignedVideoContentType: 'video/webm' }), { status: 200 });
27
+ if (String(url).startsWith('https://signed.')) return new Response('', { status: 200 });
28
+ return new Response(JSON.stringify({ success: true, analysisEnqueued: false, analysisStatus: 'enqueue_failed', analysisEnqueueError: 'queue unavailable https://secret.example.test' }), { status: 200 });
29
+ };
30
+ const result = await uploadRecordingFile({ path, apiBase: 'https://api.example.test', apiKey: 'do-not-leak', fetchImpl });
31
+ expect(result).toMatchObject({ success: true, recordingId: 'rec-12345678', uploadStrategy: 'direct', analysisEnqueued: false });
32
+ expect(JSON.stringify(result)).not.toContain('secret.example');
33
+ expect(JSON.stringify(result)).not.toContain('token-secret');
34
+ expect(calls).toHaveLength(3);
35
+ });
36
+
37
+ test('falls back to the authenticated streaming endpoint when no presign is offered', async () => {
38
+ const path = await fixture('capture.mov'); const calls = [];
39
+ const fetchImpl = async (url, init = {}) => {
40
+ calls.push({ url, init });
41
+ if (String(url).endsWith('/recordings')) return new Response(JSON.stringify({ success: true, recordingId: 'rec-12345678' }));
42
+ return new Response(JSON.stringify({ success: true, analysisEnqueued: true, analysisJobId: 'job-1', analysisStatus: 'queued' }));
43
+ };
44
+ const result = await uploadRecordingFile({ path, apiBase: 'https://api.example.test', fetchImpl });
45
+ expect(result).toMatchObject({ success: true, uploadStrategy: 'stream', analysisEnqueued: true, analysisJobId: 'job-1' });
46
+ expect(calls[1].init.headers).toMatchObject({ 'Content-Type': 'video/quicktime', 'Content-Length': '5' });
47
+ });
48
+
49
+ test('uses the default Axios transport for streaming fallback responses', async () => {
50
+ const path = await fixture(); const requests = [];
51
+ const server = Bun.serve({ port: 0, async fetch(request) {
52
+ const url = new URL(request.url); requests.push({ path: url.pathname, method: request.method, contentLength: request.headers.get('content-length') });
53
+ if (request.method === 'POST' && url.pathname.endsWith('/recordings')) return Response.json({ success: true, recordingId: 'rec-12345678' });
54
+ if (request.method === 'PUT') { await request.arrayBuffer(); return Response.json({ success: true, analysisEnqueued: true, analysisJobId: 'job-1', analysisStatus: 'queued' }); }
55
+ return Response.json({ success: true });
56
+ } });
57
+ try {
58
+ const result = await uploadRecordingFile({ path, apiBase: `http://127.0.0.1:${server.port}` });
59
+ expect(result).toMatchObject({ success: true, uploadStrategy: 'stream', analysisEnqueued: true, analysisJobId: 'job-1' });
60
+ expect(requests[1]).toMatchObject({ method: 'PUT', contentLength: '5' });
61
+ } finally { server.stop(true); }
62
+ });
63
+
64
+ test('preserves an uploaded recording when direct finalization is ambiguous', async () => {
65
+ const path = await fixture(); const methods = [];
66
+ const fetchImpl = async (url, init = {}) => {
67
+ methods.push(init.method);
68
+ if (String(url).endsWith('/recordings')) return new Response(JSON.stringify({ success: true, recordingId: 'rec-12345678', uploadUrl: 'https://signed.example.test/token', uploadToken: 'token', presignedVideoObjectId: 'object-1' }));
69
+ if (String(url).startsWith('https://signed.')) return new Response('', { status: 200 });
70
+ if (init.method === 'POST') return new Response(JSON.stringify({ success: false }), { status: 200 });
71
+ return new Response(JSON.stringify({ success: true }));
72
+ };
73
+ await expect(uploadRecordingFile({ path, apiBase: 'https://api.example.test', fetchImpl })).rejects.toMatchObject({ code: 'FINALIZE_FAILED' });
74
+ expect(methods).toEqual(['POST', 'PUT', 'POST']);
75
+ });
76
+
77
+ test('cleans up an owned stub after a definitive direct-upload rejection', async () => {
78
+ const path = await fixture(); const methods = [];
79
+ const fetchImpl = async (url, init = {}) => {
80
+ methods.push(init.method);
81
+ if (String(url).endsWith('/recordings')) return new Response(JSON.stringify({ success: true, recordingId: 'rec-12345678', uploadUrl: 'https://signed.example.test/token', uploadToken: 'token', presignedVideoObjectId: 'object-1' }));
82
+ if (String(url).startsWith('https://signed.')) return new Response('', { status: 403 });
83
+ return new Response(JSON.stringify({ success: true }));
84
+ };
85
+ await expect(uploadRecordingFile({ path, apiBase: 'https://api.example.test', fetchImpl })).rejects.toMatchObject({ code: 'DIRECT_UPLOAD_FAILED' });
86
+ expect(methods).toEqual(['POST', 'PUT', 'DELETE']);
87
+ });
88
+
89
+ test('preserves an owned recording after an ambiguous direct-upload server failure', async () => {
90
+ const path = await fixture(); const methods = [];
91
+ const fetchImpl = async (url, init = {}) => {
92
+ methods.push(init.method);
93
+ if (String(url).endsWith('/recordings')) return new Response(JSON.stringify({ success: true, recordingId: 'rec-12345678', uploadUrl: 'https://signed.example.test/token', uploadToken: 'token', presignedVideoObjectId: 'object-1' }));
94
+ if (String(url).startsWith('https://signed.')) return new Response('', { status: 500 });
95
+ return new Response(JSON.stringify({ success: true }));
96
+ };
97
+ await expect(uploadRecordingFile({ path, apiBase: 'https://api.example.test', fetchImpl })).rejects.toMatchObject({ code: 'DIRECT_UPLOAD_FAILED' });
98
+ expect(methods).toEqual(['POST', 'PUT']);
99
+ });
100
+
101
+ test('cleans up after a definitive pre-transfer failure', async () => {
102
+ const path = await fixture(); const methods = [];
103
+ const fetchImpl = async (url, init = {}) => {
104
+ methods.push(init.method);
105
+ if (String(url).endsWith('/recordings')) return new Response(JSON.stringify({ success: true, recordingId: 'rec-12345678', uploadUrl: 'https://signed.example.test/token', uploadToken: 'token', presignedVideoObjectId: 'object-1' }));
106
+ if (String(url).startsWith('https://signed.')) { const error = new Error('DNS failed'); error.code = 'ENOTFOUND'; throw error; }
107
+ return new Response(JSON.stringify({ success: true }));
108
+ };
109
+ await expect(uploadRecordingFile({ path, apiBase: 'https://api.example.test', fetchImpl })).rejects.toMatchObject({ code: 'UPLOAD_FAILED' });
110
+ expect(methods).toEqual(['POST', 'PUT', 'DELETE']);
111
+ });
112
+
113
+ test('redacts credentials from generic upstream errors', async () => {
114
+ const path = await fixture();
115
+ const fetchImpl = async () => { throw new Error('Authorization: Bearer secret-value https://signed.example.test/upload?uploadToken=token-secret'); };
116
+ const error = await uploadRecordingFile({ path, apiBase: 'https://api.example.test', fetchImpl }).catch((caught) => caught);
117
+ expect(error).toMatchObject({ code: 'UPLOAD_FAILED' });
118
+ expect(error.message).not.toContain('secret-value');
119
+ expect(error.message).not.toContain('signed.example');
120
+ });
121
+
122
+ test('rejects unsafe paths and overlong metadata before creating a recording', async () => {
123
+ const path = await fixture();
124
+ const link = `${path}.webm`;
125
+ await symlink(path, link);
126
+ await expect(inspectRecordingUploadFile(link)).rejects.toMatchObject({ code: 'SYMLINK_NOT_ALLOWED' });
127
+ await expect(uploadRecordingFile({ path, dryRun: true, apiBase: 'https://api.example.test', intent: 'x'.repeat(201) })).rejects.toMatchObject({ code: 'INVALID_INTENT' });
128
+ await expect(uploadRecordingFile({ path, dryRun: true, apiBase: 'https://api.example.test', title: 'x'.repeat(501) })).rejects.toMatchObject({ code: 'INVALID_TITLE' });
129
+ });
130
+
131
+ test('cleans up and rejects a partial direct-upload response', async () => {
132
+ const path = await fixture(); const methods = [];
133
+ const fetchImpl = async (_url, init = {}) => {
134
+ methods.push(init.method);
135
+ if (init.method === 'POST') return new Response(JSON.stringify({ success: true, recordingId: 'rec-12345678', uploadUrl: 'https://signed.example.test/secret' }));
136
+ return new Response(JSON.stringify({ success: true }));
137
+ };
138
+ await expect(uploadRecordingFile({ path, apiBase: 'https://api.example.test', fetchImpl })).rejects.toMatchObject({ code: 'INVALID_DIRECT_UPLOAD_RESPONSE' });
139
+ expect(methods).toEqual(['POST', 'DELETE']);
140
+ });
141
+ });
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function createRecordingCommand(): Command;
3
+ //# sourceMappingURL=recording.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recording.d.ts","sourceRoot":"","sources":["../../../src/commands/recording.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,wBAAgB,sBAAsB,IAAI,OAAO,CAuBhD"}
@@ -0,0 +1,38 @@
1
+ import { Command } from 'commander';
2
+ import { uploadRecordingFile, RecordingUploadError } from '../../shared/recording-upload.js';
3
+ import { config } from '../config/store.js';
4
+ import { isJsonMode } from '../output/mode.js';
5
+ import { emitJson } from '../output/formatter.js';
6
+ function apiBase() { return config.get('apiUrl') || process.env.THINKRUN_BASE_URL || 'https://api.thinkrun.ai'; }
7
+ function apiKey() { return config.get('apiKey') || process.env.THINKRUN_API_KEY || process.env.THINKBROWSE_API_KEY; }
8
+ export function createRecordingCommand() {
9
+ const recording = new Command('recording').description('Manage feedback recordings');
10
+ recording.addCommand(new Command('upload')
11
+ .description('Upload an explicit local .webm, .mp4, or .mov recording (direct API; never uses the browser bridge)')
12
+ .argument('<path>', 'Explicit local recording path')
13
+ .option('--intent <intent>', 'Analysis intent', 'feedback')
14
+ .option('--title <title>', 'Recording title')
15
+ .option('--url <url>', 'Associated absolute http(s) URL')
16
+ .option('--dry-run', 'Validate locally without network activity')
17
+ .action(async (path, options) => {
18
+ try {
19
+ const result = await uploadRecordingFile({ path, intent: options.intent, title: options.title, url: options.url, dryRun: options.dryRun, apiBase: apiBase(), apiKey: apiKey() });
20
+ if (isJsonMode()) {
21
+ emitJson({ success: true, command: 'recording upload', ...result });
22
+ return;
23
+ }
24
+ console.log(JSON.stringify(result, null, 2));
25
+ }
26
+ catch (error) {
27
+ const message = error instanceof Error ? error.message : 'Recording upload failed';
28
+ const code = error instanceof RecordingUploadError ? error.code : 'UPLOAD_FAILED';
29
+ if (isJsonMode())
30
+ emitJson({ success: false, command: 'recording upload', error: message, code });
31
+ else
32
+ console.error(`Error (${code}): ${message}`);
33
+ process.exitCode = 1;
34
+ }
35
+ }));
36
+ return recording;
37
+ }
38
+ //# sourceMappingURL=recording.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recording.js","sourceRoot":"","sources":["../../../src/commands/recording.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAC9F,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,SAAS,OAAO,KAAa,OAAQ,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAwB,IAAI,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,yBAAyB,CAAC,CAAC,CAAC;AACjJ,SAAS,MAAM,KAAyB,OAAQ,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAwB,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC;AAEjK,MAAM,UAAU,sBAAsB;IACpC,MAAM,SAAS,GAAG,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC;IACrF,SAAS,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC;SACvC,WAAW,CAAC,qGAAqG,CAAC;SAClH,QAAQ,CAAC,QAAQ,EAAE,+BAA+B,CAAC;SACnD,MAAM,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,UAAU,CAAC;SAC1D,MAAM,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;SAC5C,MAAM,CAAC,aAAa,EAAE,iCAAiC,CAAC;SACxD,MAAM,CAAC,WAAW,EAAE,2CAA2C,CAAC;SAChE,MAAM,CAAC,KAAK,EAAE,I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1,6 @@
1
1
  {
2
2
  "name": "@thinkrun/cli",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "CLI for controlling browsers via ThinkRun cloud and local infrastructure",
5
5
  "type": "module",
6
6
  "bin": {
@@ -50,9 +50,10 @@
50
50
  "url": "https://github.com/dundas/thinkrun/issues"
51
51
  },
52
52
  "dependencies": {
53
+ "axios": "^1.13.2",
54
+ "chalk": "^5.3.0",
53
55
  "commander": "^12.1.0",
54
56
  "conf": "^13.0.1",
55
- "chalk": "^5.3.0",
56
57
  "fast-uri": "^3.1.3",
57
58
  "ora": "^8.1.0"
58
59
  },