@browserless.io/cli 0.2.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.0](https://github.com/browserless/browserless-cli/compare/v0.3.0...v0.4.0) (2026-09-22)
4
+
5
+
6
+ ### Features
7
+
8
+ * AUTO-419 track CLI profile setup attempts ([#100](https://github.com/browserless/browserless-cli/issues/100)) ([93f5f5f](https://github.com/browserless/browserless-cli/commit/93f5f5fc033dbe98788f614082e997bd31a7129c))
9
+
10
+ ## [0.3.0](https://github.com/browserless/browserless-cli/compare/v0.2.0...v0.3.0) (2026-08-04)
11
+
12
+
13
+ ### Features
14
+
15
+ * Profile refresh replays the capture settings a profile was created with — no flags needed ([#58](https://github.com/browserless/browserless-cli/issues/58)) ([94fe959](https://github.com/browserless/browserless-cli/commit/94fe959620909e9f7e9bfe533dd0c94c1560c712))
16
+
3
17
  ## [0.2.0](https://github.com/browserless/browserless-cli/compare/v0.1.0...v0.2.0) (2026-06-18)
4
18
 
5
19
 
@@ -12,8 +26,7 @@
12
26
 
13
27
  ### Features
14
28
 
15
- * agent functionality ([c453dba](https://github.com/browserless/browserless-cli/commit/c453dbad50aa3283f9f8340bf32ed51d185ff132))
16
- * agent functionality AI-107 ([c453dba](https://github.com/browserless/browserless-cli/commit/c453dbad50aa3283f9f8340bf32ed51d185ff132))
29
+ * Interactive agent chat via `browserless agent` ([c453dba](https://github.com/browserless/browserless-cli/commit/c453dbad50aa3283f9f8340bf32ed51d185ff132))
17
30
 
18
31
  ## [0.0.3](https://github.com/browserless/browserless-cli/compare/v0.0.2...v0.0.3) (2026-06-05)
19
32
 
@@ -29,14 +42,10 @@
29
42
  ## [0.0.2](https://github.com/browserless/browserless-cli/compare/v0.0.1...v0.0.2) (2026-05-27)
30
43
 
31
44
 
32
- * set next release to 0.0.2 ([e755492](https://github.com/browserless/browserless-cli/commit/e7554922a8576286c5ffe37edc1bfd55f532f2bd))
33
-
34
-
35
45
  ### Features
36
46
 
37
47
  * --region sfo|lon|ams shortcut + region config key ([c921251](https://github.com/browserless/browserless-cli/commit/c921251664c89bb0e66c2549767d37ae2f011734))
38
- * add browserless CLI for authenticated profile management ([d2ccbbe](https://github.com/browserless/browserless-cli/commit/d2ccbbe33204f74e188a1a4bb7a999e40a7034d7))
39
- * add browserless CLI for authenticated profile management [do not merge] ([4194243](https://github.com/browserless/browserless-cli/commit/41942439b3ee3166fe15c90648bfe7de8da4a6fe))
48
+ * Add the Browserless CLI for authenticated profile management ([d2ccbbe](https://github.com/browserless/browserless-cli/commit/d2ccbbe33204f74e188a1a4bb7a999e40a7034d7))
40
49
  * **capture:** live progress events, skip vendor NTP origins, cap loop on attempts, + --auto-fit/--keep-domain/--only-domain for artifact size mgmt ([f83c2a9](https://github.com/browserless/browserless-cli/commit/f83c2a99d086f9ab4c267f254a42c1154de7b9d4))
41
50
  * **capture:** skip sensitive profile files from temp copy + CI smoke that catches future Chrome additions ([0ad3a97](https://github.com/browserless/browserless-cli/commit/0ad3a9731c6133dcd68356c33b4ce40b0d01c4d0))
42
51
  * **ci:** cli-smoke integration test invokes every command on every OS via stub server ([c5fb558](https://github.com/browserless/browserless-cli/commit/c5fb5581bc4255b5b118e13cc543d4a115e5ebd5))
@@ -1 +1 @@
1
- var u=Object.defineProperty;var f=(r,e)=>u(r,"name",{value:e,configurable:!0});import{ApiError as d}from"../errors.js";const $=3e4,l=f((r,e,n,t)=>{const a=r.endsWith("/")?r:`${r}/`,m=e.replace(/^\/+/,""),c=new URL(m,a);if(c.searchParams.set("token",n),t)for(const[h,s]of Object.entries(t))s!==void 0&&c.searchParams.set(h,String(s));return c},"buildUrl"),w=f((r,e,n)=>{if(!n)return`HTTP ${r} ${e}`;try{const a=JSON.parse(n);if(a?.message&&typeof a.message=="string")return a.message}catch{}const t=n.trim();return t.length>200?`HTTP ${r} ${e}: ${t.slice(0,200)}\u2026`:`HTTP ${r} ${e}: ${t}`},"messageFromBody"),T=f(async(r,e)=>{const n=l(r.server,e.path,r.token,e.query),t={method:e.method};let a;e.rawBody!==void 0?a=e.rawBody:e.body!==void 0&&(a=JSON.stringify(e.body)),a!==void 0&&(t.body=a,t.headers={"Content-Type":"application/json"});const m=e.timeoutMs??$,c=new AbortController,h=setTimeout(()=>c.abort(),m);t.signal=c.signal;let s;try{s=await fetch(n,t)}catch(i){throw i?.name==="AbortError"?new d(`Request to ${r.server}${e.path} timed out after ${m}ms`,0):new d(`Failed to reach ${r.server}: ${i?.message??i}`,0)}finally{clearTimeout(h)}let o;try{o=await s.text()}catch(i){throw i?.name==="AbortError"?new d(`Request to ${r.server}${e.path} timed out after ${m}ms`,0):new d(`Failed to read response from ${r.server}${e.path}: ${i?.message??i}`,0)}if(!s.ok)throw new d(w(s.status,s.statusText,o),s.status,o);if(!(s.status===204||!o))try{return JSON.parse(o)}catch{throw new d(`Server returned non-JSON response: ${o}`,s.status,o)}},"apiFetch");export{T as apiFetch};
1
+ var $=Object.defineProperty;var c=(e,t)=>$(e,"name",{value:t,configurable:!0});import{ApiError as f}from"../errors.js";const w=3e4,l=c(e=>typeof e=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)?e.toLowerCase():void 0,"profileAttemptId"),y=c((e,t,n,r)=>{const s=e.endsWith("/")?e:`${e}/`,m=t.replace(/^\/+/,""),o=new URL(m,s);if(o.searchParams.set("token",n),r)for(const[h,u]of Object.entries(r))u!==void 0&&o.searchParams.set(h,String(u));return o},"buildUrl"),p=c((e,t,n)=>{if(!n)return`HTTP ${e} ${t}`;try{const s=JSON.parse(n);if(s?.message&&typeof s.message=="string")return s.message}catch{}const r=n.trim();return r.length>200?`HTTP ${e} ${t}: ${r.slice(0,200)}\u2026`:`HTTP ${e} ${t}: ${r}`},"messageFromBody"),T=c(async(e,t)=>{const n=y(e.server,t.path,e.token,t.query),r={method:t.method};let s;t.rawBody!==void 0?s=t.rawBody:t.body!==void 0&&(s=JSON.stringify(t.body)),s!==void 0&&(r.body=s,r.headers={"Content-Type":"application/json"});const m=l(t.attemptId);m&&(r.headers={...r.headers,"x-browserless-attempt-id":m});const o=t.timeoutMs??w,h=new AbortController,u=setTimeout(()=>h.abort(),o);r.signal=h.signal;let a;try{a=await fetch(n,r)}catch(d){throw d?.name==="AbortError"?new f(`Request to ${e.server}${t.path} timed out after ${o}ms`,0):new f(`Failed to reach ${e.server}: ${d?.message??d}`,0)}finally{clearTimeout(u)}let i;try{i=await a.text()}catch(d){throw d?.name==="AbortError"?new f(`Request to ${e.server}${t.path} timed out after ${o}ms`,0):new f(`Failed to read response from ${e.server}${t.path}: ${d?.message??d}`,0)}if(!a.ok)throw new f(p(a.status,a.statusText,i),a.status,i);if(!(a.status===204||!i))try{return JSON.parse(i)}catch{throw new f(`Server returned non-JSON response: ${i}`,a.status,i)}},"apiFetch");export{T as apiFetch,l as profileAttemptId};
@@ -1 +1 @@
1
- var f=Object.defineProperty;var e=(r,o)=>f(r,"name",{value:o,configurable:!0});import{apiFetch as i}from"./client.js";import{buildProfileBody as t}from"./upload.js";const a=e(async(r,o)=>i(r,{method:"POST",path:"/profile/refresh",rawBody:t(o)}),"refreshProfile");export{a as refreshProfile};
1
+ var a=Object.defineProperty;var e=(r,t)=>a(r,"name",{value:t,configurable:!0});import{apiFetch as i}from"./client.js";import{buildProfileBody as p,rethrowCaptureSettingsSkew as f}from"./upload.js";const s=e(async(r,t)=>{try{return await i(r,{method:"POST",path:"/profile/refresh",rawBody:p(t),attemptId:t.attemptId})}catch(o){return f(o,r.server)}},"refreshProfile");export{s as refreshProfile};
@@ -1 +1 @@
1
- var o=Object.defineProperty;var i=(e,t)=>o(e,"name",{value:t,configurable:!0});import{apiFetch as n}from"./client.js";const d=i(e=>e.serialized!==void 0?`{"name":${JSON.stringify(e.name)},"state":${e.serialized}}`:JSON.stringify({name:e.name,state:e.state}),"buildProfileBody"),a=i(async(e,t)=>n(e,{method:"POST",path:"/profile/upload",rawBody:d(t)}),"uploadProfile");export{d as buildProfileBody,a as uploadProfile};
1
+ var s=Object.defineProperty;var i=(t,e)=>s(t,"name",{value:e,configurable:!0});import{apiFetch as n}from"./client.js";import{ApiError as o}from"../errors.js";import{version as a}from"../version.js";const d=i(t=>{const e=t.serialized??JSON.stringify(t.state),r=t.captureSettings===void 0?"":`,"captureSettings":${JSON.stringify(t.captureSettings)}`;return`{"name":${JSON.stringify(t.name)},"state":${e}${r}}`},"buildProfileBody"),p=i((t,e)=>{throw!(t instanceof o)||t.status!==400||!/additional propert/i.test(`${t.body??""} ${t.message}`)?t:new o(`The server at ${e} rejected the profile capture settings this CLI (v${a}) sends \u2014 it predates either the field itself or one of its members. Deploy the server to every region before using this CLI against it. Server said: ${t.message}`,400,t.body)},"rethrowCaptureSettingsSkew"),u=i(async(t,e)=>{try{return await n(t,{method:"POST",path:"/profile/upload",rawBody:d(e),attemptId:e.attemptId})}catch(r){return p(r,t.server)}},"uploadProfile");export{d as buildProfileBody,p as rethrowCaptureSettingsSkew,u as uploadProfile};
@@ -1,21 +1,26 @@
1
- var O=Object.defineProperty;var p=(s,t)=>O(s,"name",{value:t,configurable:!0});import{resolveProfile as S}from"../browsers/discover.js";import{captureFromProfile as E}from"../capture/index.js";import{applyOnlyFilter as T,mergeExclusionPatterns as B,normalizeExclusion as C}from"../capture/exclusion.js";import{readConfig as F}from"../config/store.js";import{ensureTermsAccepted as P}from"../auth/disclaimer.js";import{UsageError as R}from"../errors.js";import{collectRepeated as h,parseNonNegativeInt as v}from"./client.js";import{formatBytes as a,measureOriginSizes as z,SERVER_ARTIFACT_CAP_BYTES as l,trimStateToFit as L}from"./trim-state.js";const U=p(s=>s.requiredOption("--browser <key>","Source browser key (chrome / brave / edge / ...) or display name").requiredOption("--profile <name>",'Source profile display name or directory (e.g. "Personal", "Default")').option("--exclude-domain <domain>","Append a domain to the exclusion list for this run (repeatable)",h).option("--no-default-excludes","Skip the persistent exclusion list for this run").option("--accept-terms","Pre-accept the liability disclaimer").option("--terms-ttl-days <n>","Override the disclaimer re-prompt TTL for this run").option("--password-store <store>","Linux only: --password-store value to pass through to the headless launch (basic / gnome-libsecret / kwallet5 / ...)").option("--auto-fit","If the captured artifact exceeds the 2 MB server cap, drop the heaviest origins (largest serialized contribution first) until it fits").option("--keep-domain <domain>","Domain that --auto-fit must never drop (suffix-match, same syntax as --exclude-domain; repeatable)",h).option("--only-domain <domain>","Capture only cookies / origins matching this domain \u2014 discard everything else (suffix-match; repeatable; applies after --exclude-domain)",h),"addCaptureFlags"),N=p(s=>{if(s.length>0&&!s.some(t=>C(t)!==null))throw new R(`--only-domain: no valid domain pattern in ${JSON.stringify(s)}. Use a hostname like "example.com" or "*.example.com".`)},"validateOnlyDomain"),V=p(async s=>{const{flags:t,requiresDisclaimer:w}=s,f=await S(t.browser,t.profile);w&&await P({acceptViaFlag:!!t.acceptTerms,ttlDaysOverride:t.termsTtlDays!==void 0?v("--terms-ttl-days",t.termsTtlDays):void 0});const x=await F(),$=B(x.excluded_domains,t.excludeDomain,t.defaultExcludes===!1);N(t.onlyDomain??[]),process.stderr.write(`> Capturing ${f.browserDisplayName} / ${f.profileDisplayName}
2
- `);const k=5,u=p(e=>{process.stderr.write(` ${e}
3
- `)},"writeLine"),b={copying:"copying profile data\u2026",launching:"launching headless browser\u2026","waiting-for-debugger":"waiting for browser to be ready\u2026"};let m="",y=0;const D={profile:f,excludedDomains:$,onlyDomains:t.onlyDomain??[],passwordStoreOverride:t.passwordStore,onProgress:p(e=>{if(e.phase!=="done"){if(e.phase==="capturing-origins"){if(e.attempted===0){m!=="capturing-origins"&&(m="capturing-origins",u("capturing per-origin storage\u2026"));return}if(!(e.attempted===e.total)&&e.attempted-y<k)return;y=e.attempted;const n=e.origin.length>50?e.origin.slice(0,47)+"\u2026":e.origin;u(` ${e.attempted}/${e.total} ${n}`);return}e.phase!==m&&(m=e.phase,u(b[e.phase]??e.phase))}},"onProgress")},r=await E(D);if(t.onlyDomain&&t.onlyDomain.length>0){const e=T(r.state,t.onlyDomain),n=r.state.cookies.length-e.state.cookies.length,o=r.diagnostics.originCountSkippedByOnlyDomain+e.originsDropped;(n>0||o>0)&&(r.state=e.state,r.serialized=JSON.stringify(e.state),process.stderr.write(` \u2192 --only-domain kept ${r.state.cookies.length} cookies / ${r.state.origins.length} origins; dropped ${n} cookies / ${o} origins not matching: ${t.onlyDomain.join(", ")}
4
- `))}const i=r.diagnostics,g=Buffer.byteLength(r.serialized,"utf-8");if(process.stderr.write(`> Captured ${i.cookieCountBeforeExclusion} cookies, ${i.originCountBeforeExclusion} origins in ${i.durationMs}ms (artifact: ${a(g)})
5
- `),i.cookieCountExcluded>0||i.originCountExcluded>0){const e=i.excludedDomains.length?i.excludedDomains.join(", "):"(none)";process.stderr.write(` \u2192 Excluded ${i.cookieCountExcluded} cookies / ${i.originCountExcluded} origins matching: ${e}
6
- `)}if(r.capHit&&process.stderr.write(` ! Hit the per-capture origin cap \u2014 some origins may be missing
7
- `),i.failedOrigins.length>0){process.stderr.write(` ! ${i.failedOrigins.length} origin(s) failed to capture \u2014 their localStorage / IndexedDB is missing from the upload:
8
- `);for(const e of i.failedOrigins)process.stderr.write(` - ${e.origin}: ${e.error}
9
- `)}if(r.passwordStoreDefaulted&&process.stderr.write(` ! Linux password-store could not be detected \u2014 defaulted to "basic". If decryption failed, re-run with --password-store=<your store>
10
- `),g>l){const e=z(r.state),d=10;process.stderr.write(` ! artifact size ${a(g)} exceeds the ${a(l)} server cap \u2014 heaviest origins:
11
- `);for(const{origin:n,bytes:o}of e.slice(0,d))process.stderr.write(` ${a(o).padStart(10)} ${n}
12
- `);if(e.length>d&&process.stderr.write(` \u2026 and ${e.length-d} more origins below ${a(e[d].bytes)}
13
- `),t.autoFit){const n=t.keepDomain??[],o=L(r.state,l,n);if(o.dropped.length===0&&o.finalBytes<=l)process.stderr.write(` ! --auto-fit had nothing to drop \u2014 artifact unchanged
14
- `);else{if(r.state=o.state,r.serialized=o.serialized,i.failedOrigins=[...i.failedOrigins,...o.dropped.map(c=>({origin:c,error:"dropped by --auto-fit to fit under the server cap",kind:"unknown"}))],o.dropped.length>0){process.stderr.write(` --auto-fit: dropped ${o.dropped.length} origin(s), now ${a(o.finalBytes)}:
15
- `);for(const c of o.dropped)process.stderr.write(` - ${c}
16
- `)}if(o.protectedFromDrop.length>0){process.stderr.write(` --auto-fit: ${o.protectedFromDrop.length} heavy origin(s) protected by --keep-domain:
17
- `);for(const c of o.protectedFromDrop)process.stderr.write(` - ${c}
18
- `)}o.finalBytes>l&&(o.protectedFromDrop.length>0?process.stderr.write(` ! Still ${a(o.finalBytes)} after the trim \u2014 the --keep-domain origins alone exceed the cap. Remove one or more --keep-domain entries, or accept the upload will be rejected.
1
+ var B=Object.defineProperty;var l=(e,t)=>B(e,"name",{value:t,configurable:!0});import{resolveProfile as A}from"../browsers/discover.js";import{captureFromProfile as I}from"../capture/index.js";import{applyOnlyFilter as L,mergeExclusionPatterns as R,normalizeExclusion as y}from"../capture/exclusion.js";import{readConfig as P}from"../config/store.js";import{ensureTermsAccepted as z}from"../auth/disclaimer.js";import{UsageError as _}from"../errors.js";import{version as G}from"../version.js";import{collectRepeated as k,parseNonNegativeInt as M}from"./client.js";import{formatBytes as u,measureOriginSizes as j,SERVER_ARTIFACT_CAP_BYTES as x,trimStateToFit as U}from"./trim-state.js";const ne=l((e,t={})=>{const s=t.sourceOptional?e.option.bind(e):e.requiredOption.bind(e),o=t.sourceOptional?". Optional here \u2014 read from the profile's stored settings when omitted":"";return s("--browser <key>",`Source browser key (chrome / brave / edge / ...) or display name${o}`),s("--profile <name>",`Source profile display name or directory (e.g. "Personal", "Default")${o}`),e.option("--exclude-domain <domain>","Append a domain to the exclusion list for this run (repeatable)",k).option("--no-default-excludes","Skip the persistent exclusion list for this run").option("--accept-terms","Pre-accept the liability disclaimer").option("--terms-ttl-days <n>","Override the disclaimer re-prompt TTL for this run").option("--password-store <store>","Linux only: --password-store value to pass through to the headless launch (basic / gnome-libsecret / kwallet5 / ...)").option("--auto-fit","If the captured artifact exceeds the 2 MB server cap, drop the heaviest origins (largest serialized contribution first) until it fits").option("--keep-domain <domain>","Domain that --auto-fit must never drop (suffix-match, same syntax as --exclude-domain; repeatable)",k).option("--only-domain <domain>","Capture only cookies / origins matching this domain \u2014 discard everything else (suffix-match; repeatable; applies after --exclude-domain)",k)},"addCaptureFlags"),H=l(e=>{if(e.length>0&&!e.some(t=>y(t)!==null))throw new _(`--only-domain: no valid domain pattern in ${JSON.stringify(e)}. Use a hostname like "example.com" or "*.example.com".`)},"validateOnlyDomain"),b=100,J=253,v=255,C=8*1024,K=/[$`\\!\u0000-\u001f\u007f]/,X=/^[A-Za-z0-9*._-]+$/,S=l((e,t)=>{process.stderr.write(` \u2192 Not storing ${e} for refresh (${t}); a later flagless \`profile refresh\` of this profile will not replay it
2
+ `)},"warnDropped"),Y=l(e=>{const t=`they serialize past the server's ${C}-byte limit`;process.stderr.write(e==="upload"?` \u2192 Not storing any capture settings (${t}); a later flagless \`profile refresh\` of this profile will have nothing to replay
3
+ `:` \u2192 Not updating the stored capture settings (${t}); whatever this profile already had is left as it was, so it no longer matches this run and a later flagless \`profile refresh\` will not reflect these filters. Shorten the domain lists to update them
4
+ `)},"warnOverCap"),O=l((e,t)=>{const s=t?.trim();if(s){if(K.test(s)){S(`--${e}`,"it contains characters a shell would interpret");return}if(s.length>v){S(`--${e}`,`it exceeds ${v} characters`);return}return s}},"safeScalar"),T=l((e,t,s=!1)=>{const o=[...new Set((t??[]).map(d=>y(d)).filter(d=>d!==null))],n=o.filter(d=>d.length<=J&&X.test(d));return n.length<o.length&&S(`${o.length-n.length} of ${o.length} --${e} patterns`,"the server only stores plain hostname patterns"),n.length?(n.length>b&&S(`${n.length-b} of ${n.length} --${e} patterns`,`the server stores at most ${b}`),n.slice(0,b)):s&&!(t??[]).length?[]:void 0},"safeDomains"),m=l((e,t)=>t===void 0?{}:{[e]:t},"withKey"),ae={browser:"browser",profile:"profile",excludeDomains:"excludeDomain",onlyDomains:"onlyDomain",keepDomains:"keepDomain",autoFit:"autoFit",passwordStore:"passwordStore"},le=l((e,t,s)=>{const o={...m("browser",O("browser",e.browser)),...m("profile",O("profile",e.profile)),...m("excludeDomains",T("exclude-domain",t.excludedDomains,e.defaultExcludes===!1)),...m("onlyDomains",T("only-domain",e.onlyDomain)),...m("keepDomains",T("keep-domain",e.keepDomain)),...e.autoFit?{autoFit:!0}:{},...m("passwordStore",O("password-store",e.passwordStore)),cliVersion:G};if(Buffer.byteLength(JSON.stringify(o),"utf8")>C){Y(s);return}return o},"buildCaptureSettings"),q=l(e=>{(e??[]).filter(t=>y(t)===null).forEach(t=>{process.stderr.write(` ! --exclude-domain ${JSON.stringify(t)} is not a usable domain pattern \u2014 nothing was excluded for it
5
+ `)})},"warnUnusableExcludes"),de=l((e,t)=>{if(!t)return e;const s=e.defaultExcludes===!1,o=(e.excludeDomain??[]).some(d=>y(d)!==null),n=!o&&t.excludeDomains!==void 0;return{...e,browser:e.browser??t.browser,profile:e.profile??t.profile,passwordStore:e.passwordStore??t.passwordStore,excludeDomain:o?e.excludeDomain:s?[]:t.excludeDomains,onlyDomain:e.onlyDomain??t.onlyDomains,keepDomain:e.keepDomain??t.keepDomains,autoFit:e.autoFit??t.autoFit,defaultExcludes:n?!1:e.defaultExcludes}},"mergeStoredSettings"),pe=l((e,t,s={})=>{if(!t)return;const o=l(g=>process.stderr.write(`${g}
6
+ `),"w"),n=s.userOptedOut===!0;o("> Refreshing with these effective settings:"),e.browser&&o(` --browser ${e.browser}`),e.profile&&o(` --profile ${e.profile}`);const d=(e.excludeDomain??[]).filter(g=>y(g)!==null);d.length&&o(` --exclude-domain ${d.join(", ")}`),e.onlyDomain?.length&&(o(` --only-domain ${e.onlyDomain.join(", ")}`),o(" ! only these domains are captured \u2014 everything else in the saved"),o(" profile is replaced, not kept")),e.keepDomain?.length&&o(` --keep-domain ${e.keepDomain.join(", ")}`),e.autoFit&&o(" --auto-fit (only acts if the capture exceeds the 2 MB cap)"),e.passwordStore&&o(` --password-store ${e.passwordStore}`),n&&o(" --no-default-excludes");const D=n&&!d.length,c=t.excludeDomains?.length;D&&c&&(o(` ! --no-default-excludes drops the ${c} stored exclusion pattern(s) for this run,`),o(" and re-pass --exclude-domain if you want to keep them.")),D?(o(" ! Unless the settings exceed the 8 KB cap (reported after the capture), the"),o(" refreshed profile is stored with NO exclusion list, so later flagless refreshes"),o(" replay 'exclude nothing' and stop applying this machine's config.")):n?(o(" ! --no-default-excludes is in force: ONLY the --exclude-domain patterns above"),o(" are excluded, and this machine's own config is not applied.")):c===void 0&&(o(" (no stored exclusion list \u2014 this machine's own config applies)"),o(" This run stores the effective list on the profile, so later flagless refreshes"),o(" replay that snapshot instead of re-reading this config.")),o(" Pass --browser, --profile, --password-store or a domain flag to override."),n||(o(c===void 0?" --exclude-domain adds to this machine's config for this run; there is no stored list to replace.":" --exclude-domain replaces the stored list and re-applies this machine's config."),c&&o(" --no-default-excludes drops the stored list for good."))},"printEffectiveSettings"),ce=l(async e=>{const{flags:t,requiresDisclaimer:s}=e;if(!t.browser||!t.profile){const r=[t.browser?null:"--browser",t.profile?null:"--profile"].filter(Boolean);throw new _(`${r.join(" and ")} ${r.length>1?"are":"is"} required: this profile has no stored capture settings to read them from (it was not created by the CLI, or this server does not return them yet)`)}const o=await A(t.browser,t.profile);s&&await z({acceptViaFlag:!!t.acceptTerms,ttlDaysOverride:t.termsTtlDays!==void 0?M("--terms-ttl-days",t.termsTtlDays):void 0});const n=await P(),d=R(n.excluded_domains,t.excludeDomain,t.defaultExcludes===!1);H(t.onlyDomain??[]),q(t.excludeDomain),process.stderr.write(`> Capturing ${o.browserDisplayName} / ${o.profileDisplayName}
7
+ `);const D=5,c=l(r=>{process.stderr.write(` ${r}
8
+ `)},"writeLine"),g={copying:"copying profile data\u2026",launching:"launching headless browser\u2026","waiting-for-debugger":"waiting for browser to be ready\u2026"};let $="",N=0;const F={profile:o,excludedDomains:d,onlyDomains:t.onlyDomain??[],passwordStoreOverride:t.passwordStore,onProgress:l(r=>{if(r.phase!=="done"){if(r.phase==="capturing-origins"){if(r.attempted===0){$!=="capturing-origins"&&($="capturing-origins",c("capturing per-origin storage\u2026"));return}if(!(r.attempted===r.total)&&r.attempted-N<D)return;N=r.attempted;const f=r.origin.length>50?r.origin.slice(0,47)+"\u2026":r.origin;c(` ${r.attempted}/${r.total} ${f}`);return}r.phase!==$&&($=r.phase,c(g[r.phase]??r.phase))}},"onProgress")},a=await I(F);if(t.onlyDomain&&t.onlyDomain.length>0){const r=L(a.state,t.onlyDomain),f=a.state.cookies.length-r.state.cookies.length,i=a.diagnostics.originCountSkippedByOnlyDomain+r.originsDropped;(f>0||i>0)&&(a.state=r.state,a.serialized=JSON.stringify(r.state),process.stderr.write(` \u2192 --only-domain kept ${a.state.cookies.length} cookies / ${a.state.origins.length} origins; dropped ${f} cookies / ${i} origins not matching: ${t.onlyDomain.join(", ")}
9
+ `))}const p=a.diagnostics,E=Buffer.byteLength(a.serialized,"utf-8");if(process.stderr.write(`> Captured ${p.cookieCountBeforeExclusion} cookies, ${p.originCountBeforeExclusion} origins in ${p.durationMs}ms (artifact: ${u(E)})
10
+ `),p.cookieCountExcluded>0||p.originCountExcluded>0){const r=p.excludedDomains.length?p.excludedDomains.join(", "):"(none)";process.stderr.write(` \u2192 Excluded ${p.cookieCountExcluded} cookies / ${p.originCountExcluded} origins matching: ${r}
11
+ `)}if(a.capHit&&process.stderr.write(` ! Hit the per-capture origin cap \u2014 some origins may be missing
12
+ `),p.failedOrigins.length>0){process.stderr.write(` ! ${p.failedOrigins.length} origin(s) failed to capture \u2014 their localStorage / IndexedDB is missing from the upload:
13
+ `);for(const r of p.failedOrigins)process.stderr.write(` - ${r.origin}: ${r.error}
14
+ `)}if(a.passwordStoreDefaulted&&process.stderr.write(` ! Linux password-store could not be detected \u2014 defaulted to "basic". If decryption failed, re-run with --password-store=<your store>
15
+ `),E>x){const r=j(a.state),h=10;process.stderr.write(` ! artifact size ${u(E)} exceeds the ${u(x)} server cap \u2014 heaviest origins:
16
+ `);for(const{origin:f,bytes:i}of r.slice(0,h))process.stderr.write(` ${u(i).padStart(10)} ${f}
17
+ `);if(r.length>h&&process.stderr.write(` \u2026 and ${r.length-h} more origins below ${u(r[h].bytes)}
18
+ `),t.autoFit){const f=t.keepDomain??[],i=U(a.state,x,f);if(i.dropped.length===0&&i.finalBytes<=x)process.stderr.write(` ! --auto-fit had nothing to drop \u2014 artifact unchanged
19
+ `);else{if(a.state=i.state,a.serialized=i.serialized,p.failedOrigins=[...p.failedOrigins,...i.dropped.map(w=>({origin:w,error:"dropped by --auto-fit to fit under the server cap",kind:"unknown"}))],i.dropped.length>0){process.stderr.write(` --auto-fit: dropped ${i.dropped.length} origin(s), now ${u(i.finalBytes)}:
20
+ `);for(const w of i.dropped)process.stderr.write(` - ${w}
21
+ `)}if(i.protectedFromDrop.length>0){process.stderr.write(` --auto-fit: ${i.protectedFromDrop.length} heavy origin(s) protected by --keep-domain:
22
+ `);for(const w of i.protectedFromDrop)process.stderr.write(` - ${w}
23
+ `)}i.finalBytes>x&&(i.protectedFromDrop.length>0?process.stderr.write(` ! Still ${u(i.finalBytes)} after the trim \u2014 the --keep-domain origins alone exceed the cap. Remove one or more --keep-domain entries, or accept the upload will be rejected.
19
24
  `):process.stderr.write(` ! Even after dropping every droppable origin the artifact is still over cap. The cookies alone may be too heavy.
20
25
  `))}}else process.stderr.write(` Re-run with --auto-fit to drop the heaviest origins automatically (combine with --keep-domain <domain> to protect specific sites; or --only-domain <domain> to capture just those), or pass --exclude-domain <host> for each you want removed.
21
- `)}return r},"runCapture");export{U as addCaptureFlags,V as runCapture,N as validateOnlyDomain};
26
+ `)}return a},"runCapture");export{ae as SETTINGS_REPLAY_SOURCE,ne as addCaptureFlags,le as buildCaptureSettings,de as mergeStoredSettings,pe as printEffectiveSettings,ce as runCapture,H as validateOnlyDomain,q as warnUnusableExcludes};
@@ -1,2 +1,2 @@
1
- var s=Object.defineProperty;var i=(e,o)=>s(e,"name",{value:o,configurable:!0});import{addClientFlags as t,buildClient as a,printJson as l}from"../../cli-utils/client.js";import{addCaptureFlags as c,runCapture as d}from"../../cli-utils/capture-runner.js";import{refreshProfile as f}from"../../api/refresh.js";const m=i(async e=>{const o=await d({flags:e,requiresDisclaimer:!0}),n=await a(e);process.stderr.write(`> Refreshing profile "${e.name}" on ${n.server}
2
- `);const r=await f(n,{name:e.name,state:o.state,serialized:o.serialized});if(e.json){l(r);return}console.log(`\u2713 Profile "${r.name}" refreshed`),console.log(` id: ${r.id}`),console.log(` cookies: ${r.cookieCount}`),console.log(` origins: ${r.originCount}`),console.log(` updated: ${r.updatedAt}`)},"action"),C=i(e=>{const o=e.command("refresh").description("Capture a local browser profile and replace an existing cloud profile in place").requiredOption("--name <name>","Name of the existing cloud profile to refresh");c(t(o)).action(m)},"registerRefresh");export{C as registerRefresh};
1
+ var c=Object.defineProperty;var a=(e,t)=>c(e,"name",{value:t,configurable:!0});import{addClientFlags as d,buildClient as f,printJson as m}from"../../cli-utils/client.js";import{addCaptureFlags as p,buildCaptureSettings as u,mergeStoredSettings as g,printEffectiveSettings as h,runCapture as C}from"../../cli-utils/capture-runner.js";import{getProfile as S}from"../../api/profiles.js";import{refreshProfile as w}from"../../api/refresh.js";import{withProfileSetup as $}from"../../telemetry/profile-setup.js";const x=a(e=>$(e.attemptId,"refresh",async t=>{const i=await f(e),s=await S(i,e.name),l=e.defaultExcludes===!1,o=g(e,s.captureSettings);h(o,s.captureSettings,{userOptedOut:l});const n=await C({flags:o,requiresDisclaimer:!0});t.ready(),process.stderr.write(`> Refreshing profile "${e.name}" on ${i.server}
2
+ `),t.submit();const r=await w(i,{attemptId:t.attemptId,name:e.name,state:n.state,serialized:n.serialized,captureSettings:u(o,n.diagnostics,"refresh")});if(e.json){m(r);return}console.log(`\u2713 Profile "${r.name}" refreshed`),console.log(` id: ${r.id}`),console.log(` cookies: ${r.cookieCount}`),console.log(` origins: ${r.originCount}`),console.log(` updated: ${r.updatedAt}`)}),"action"),q=a(e=>{const t=e.command("refresh").description("Capture a local browser profile and replace an existing cloud profile in place").requiredOption("--name <name>","Name of the existing cloud profile to refresh").option("--attempt-id <UUID>","Optional setup correlation ID");p(d(t),{sourceOptional:!0}).action(x)},"registerRefresh");export{q as registerRefresh};
@@ -1,2 +1,2 @@
1
- var n=Object.defineProperty;var a=(o,e)=>n(o,"name",{value:e,configurable:!0});import{addClientFlags as t,buildClient as l,printJson as s}from"../../cli-utils/client.js";import{addCaptureFlags as c,runCapture as d}from"../../cli-utils/capture-runner.js";import{uploadProfile as p}from"../../api/upload.js";const u=a(async o=>{const e=await d({flags:o,requiresDisclaimer:!0}),i=await l(o);process.stderr.write(`> Uploading to ${i.server}
2
- `);const r=await p(i,{name:o.name,state:e.state,serialized:e.serialized});if(o.json){s(r);return}console.log(`\u2713 Profile "${r.name}" uploaded`),console.log(` id: ${r.id}`),console.log(` cookies: ${r.cookieCount}`),console.log(` origins: ${r.originCount}`),console.log(` created: ${r.createdAt}`)},"action"),C=a(o=>{const e=o.command("upload").description("Capture a local browser profile and upload it as a new cloud profile").requiredOption("--name <name>","Name for the new cloud profile");c(t(e)).action(u)},"registerUpload");export{C as registerUpload};
1
+ var l=Object.defineProperty;var n=(e,t)=>l(e,"name",{value:t,configurable:!0});import{addClientFlags as s,buildClient as d,printJson as c}from"../../cli-utils/client.js";import{addCaptureFlags as p,buildCaptureSettings as u,runCapture as m}from"../../cli-utils/capture-runner.js";import{uploadProfile as g}from"../../api/upload.js";import{withProfileSetup as f}from"../../telemetry/profile-setup.js";const C={runCapture:m},w=n((e,t)=>f(e.attemptId,"create",async a=>{const r=await d(e),i=await t.runCapture({flags:e,requiresDisclaimer:!0});a.ready(),process.stderr.write(`> Uploading to ${r.server}
2
+ `),a.submit();const o=await g(r,{attemptId:a.attemptId,name:e.name,state:i.state,serialized:i.serialized,captureSettings:u(e,i.diagnostics,"upload")});if(e.json){c(o);return}console.log(`\u2713 Profile "${o.name}" uploaded`),console.log(` id: ${o.id}`),console.log(` cookies: ${o.cookieCount}`),console.log(` origins: ${o.originCount}`),console.log(` created: ${o.createdAt}`)}),"action"),P=n((e,t=C)=>{const a=e.command("upload").description("Capture a local browser profile and upload it as a new cloud profile").requiredOption("--name <name>","Name for the new cloud profile").option("--attempt-id <UUID>","Optional setup correlation ID");p(s(a)).action(r=>w(r,t))},"registerUpload");export{P as registerUpload};
@@ -1,2 +1,2 @@
1
- var f=Object.defineProperty;var t=(e,r)=>f(e,"name",{value:r,configurable:!0});import{performance as a}from"node:perf_hooks";import{readConfig as u}from"../config/store.js";import{REGION_URLS as E,KNOWN_REGIONS as _,isKnownRegion as l}from"../regions.js";import{version as v}from"../version.js";import{commandPath as g,usedFlagNames as R}from"./command-meta.js";import{getRecordedToken as h}from"./token-cache.js";import{getOrCreateDeviceId as T}from"./device-id.js";import{postCliEvents as S}from"./api.js";const w="CLI Command Run",i=t(e=>e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false","isTruthyEnv"),y=t(()=>{const e=Number(process.env.BROWSERLESS_TELEMETRY_TIMEOUT_MS);return e>0?e:2e3},"flushTimeoutMs"),s=t(e=>{i(process.env.BROWSERLESS_TELEMETRY_DEBUG)&&process.stderr.write(`[telemetry] ${e}
2
- `)},"debug");let c;const L=t(async()=>{if(i(process.env.BROWSERLESS_TELEMETRY_DISABLED)||i(process.env.DO_NOT_TRACK))return!1;try{const e=await u();return e.telemetry===void 0||e.telemetry===!0}catch{return!1}},"isEnabled"),W=t(e=>{c={command:g(e),flags:R(e),startedAt:a.now()}},"begin"),N=t(e=>{let r;try{r=new URL(e).origin}catch{return"custom"}return _.find(o=>{try{return new URL(E[o]).origin===r}catch{return!1}})??"custom"},"bucketServerUrl"),k=t(()=>Number(process.versions.node.split(".")[0])||0,"nodeMajor"),C=t((e,r,n,o)=>{const d={command:e.command,flags:e.flags,status:r.status,exit_code:r.exitCode,error_name:r.status==="error"?r.errorName:void 0,error_code:r.status==="error"?r.errorCode:void 0,duration_ms:Math.round(a.now()-e.startedAt),cli_version:v,os:process.platform,arch:process.arch,node_major:k(),is_ci:i(process.env.CI),server_region:n,cli_device_id:o};return{event_type:w,time:Date.now(),event_properties:d}},"buildEvent"),G=t(async e=>{const r=c;if(c=void 0,!!r)try{if(!await L()){s("skipped: telemetry disabled");return}const n=h();if(!n){s("skipped: no token resolved this run");return}const o=N(n.server);if(!l(o)){s("skipped: non-cloud server");return}const d=await T(),m=C(r,e,o,d),p=await S([m],{token:n.token,timeoutMs:y()});s(p?`sent (${o})`:`send failed (${o})`)}catch{s("skipped: error while flushing")}},"complete"),K=t(()=>{c=void 0},"_resetForTests");export{K as _resetForTests,W as begin,N as bucketServerUrl,G as complete,y as flushTimeoutMs,L as isEnabled};
1
+ var E=Object.defineProperty;var t=(e,r)=>E(e,"name",{value:r,configurable:!0});import{performance as p}from"node:perf_hooks";import{readConfig as l}from"../config/store.js";import{REGION_URLS as _,KNOWN_REGIONS as v,isKnownRegion as g}from"../regions.js";import{version as R}from"../version.js";import{commandPath as h,usedFlagNames as S}from"./command-meta.js";import{getRecordedToken as T}from"./token-cache.js";import{getOrCreateDeviceId as w}from"./device-id.js";import{postCliEvents as y}from"./api.js";const L="CLI Command Run",a=t(e=>e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false","isTruthyEnv"),N=t(()=>{const e=Number(process.env.BROWSERLESS_TELEMETRY_TIMEOUT_MS);return e>0?e:2e3},"flushTimeoutMs"),i=t(e=>{a(process.env.BROWSERLESS_TELEMETRY_DEBUG)&&process.stderr.write(`[telemetry] ${e}
2
+ `)},"debug");let c,s=[];const K=t(e=>{c&&s.length<6&&s.push(e)},"recordProfileSetupEvent"),k=t(async()=>{if(a(process.env.BROWSERLESS_TELEMETRY_DISABLED)||a(process.env.DO_NOT_TRACK))return!1;try{const e=await l();return e.telemetry===void 0||e.telemetry===!0}catch{return!1}},"isEnabled"),Y=t(e=>{s=[],c={command:h(e),flags:S(e),startedAt:p.now()}},"begin"),C=t(e=>{let r;try{r=new URL(e).origin}catch{return"custom"}return v.find(o=>{try{return new URL(_[o]).origin===r}catch{return!1}})??"custom"},"bucketServerUrl"),M=t(()=>Number(process.versions.node.split(".")[0])||0,"nodeMajor"),O=t((e,r,d,o)=>{const n={command:e.command,flags:e.flags,status:r.status,exit_code:r.exitCode,error_name:r.status==="error"?r.errorName:void 0,error_code:r.status==="error"?r.errorCode:void 0,duration_ms:Math.round(p.now()-e.startedAt),cli_version:R,os:process.platform,arch:process.arch,node_major:M(),is_ci:a(process.env.CI),server_region:d,cli_device_id:o};return{event_type:L,time:Date.now(),event_properties:n}},"buildEvent"),$=t(async e=>{const r=c;c=void 0;const d=s;if(s=[],!!r)try{if(!await k()){i("skipped: telemetry disabled");return}const o=T();if(!o){i("skipped: no token resolved this run");return}const n=C(o.server);if(!g(n)){i("skipped: non-cloud server");return}const m=await w(),f=O(r,e,n,m),u=await y([f,...d],{token:o.token,timeoutMs:N()});i(u?`sent (${n})`:`send failed (${n})`)}catch{i("skipped: error while flushing")}},"complete"),j=t(()=>{c=void 0,s=[]},"_resetForTests");export{j as _resetForTests,Y as begin,C as bucketServerUrl,$ as complete,N as flushTimeoutMs,k as isEnabled,K as recordProfileSetupEvent};
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var r=(o,i)=>p(o,"name",{value:i,configurable:!0});import{randomUUID as f}from"node:crypto";import{profileAttemptId as l}from"../api/client.js";import{ApiError as u,CaptureError as m,PreconditionError as _,UsageError as S}from"../errors.js";import{recordProfileSetupEvent as v}from"./index.js";const I=r(async(o,i,s)=>{const n=l(o)??f(),c=new Set;let d="capture";const t=r((e,a={})=>{c.has(e)||(c.add(e),v({event_type:e,time:Date.now(),event_properties:{attempt_id:n,setup_method:"cli",source:"cli",operation:i,...a}}))},"emit");t("Profile Setup Method Selected"),t("Profile Setup Started");try{return await s({attemptId:n,ready:r(()=>{t("Profile Setup Ready")},"ready"),submit:r(()=>{d="save",t("Profile Save Submitted")},"submit")})}catch(e){const a=e instanceof u?e.status===0?"connection_failed":e.status<500?"validation_rejected":"server_failed":e instanceof S?"validation_rejected":e instanceof _?"precondition_failed":e instanceof m?"capture_failed":"internal_error";throw t("Profile Setup Failed",{step:d,reason_code:a}),e}},"withProfileSetup");export{I as withProfileSetup};
package/build/version.js CHANGED
@@ -1 +1 @@
1
- const o="0.2.0";export{o as version};
1
+ const o="0.4.0";export{o as version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browserless.io/cli",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Browserless CLI — manage authentication profiles, sessions, and other Browserless features from your terminal.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -32,10 +32,12 @@
32
32
  "fixture:build": "npm run build && node scripts/build-fixture-profile.js",
33
33
  "verify:platform": "bash scripts/verify-cross-platform.sh",
34
34
  "clean": "node scripts/clean.mjs",
35
- "prepack": "npm run build:publish && node scripts/minify-build.mjs && node scripts/strip-test-artifacts.mjs"
35
+ "prepack": "npm run build:publish && node scripts/minify-build.mjs && node scripts/strip-test-artifacts.mjs",
36
+ "prepare": "husky"
36
37
  },
37
38
  "engines": {
38
- "node": ">=24"
39
+ "node": ">=24",
40
+ "npm": ">=11.10.0"
39
41
  },
40
42
  "mocha": {
41
43
  "spec": "build/**/*.spec.js",
@@ -45,28 +47,30 @@
45
47
  "dependencies": {
46
48
  "chrome-remote-interface": "^0.34.0",
47
49
  "commander": "^15.0.0",
48
- "ws": "^8.21.0"
50
+ "ws": "^8.21.3"
49
51
  },
50
52
  "optionalDependencies": {
51
- "@napi-rs/keyring": "^1.3.0"
53
+ "@napi-rs/keyring": "^2.1.0"
52
54
  },
53
55
  "devDependencies": {
54
56
  "@eslint/js": "^10.0.1",
55
57
  "@types/chai": "^5.2.3",
56
58
  "@types/chrome-remote-interface": "^0.34.0",
57
59
  "@types/mocha": "^10.0.10",
58
- "@types/node": "^25.9.3",
59
- "@types/sinon": "^21.0.1",
60
+ "@types/node": "^26.6.1",
61
+ "@types/sinon": "^22.0.0",
60
62
  "@types/ws": "^8.18.1",
61
63
  "chai": "^6.2.2",
62
- "esbuild": "^0.28.1",
63
- "eslint": "^10.5.0",
64
- "globals": "^17.6.0",
65
- "mocha": "^11.7.6",
66
- "prettier": "^3.8.4",
67
- "sinon": "^22.0.0",
64
+ "esbuild": "^0.28.2",
65
+ "eslint": "^10.10.0",
66
+ "globals": "^17.12.0",
67
+ "husky": "^9.1.7",
68
+ "lint-staged": "^17.5.1",
69
+ "mocha": "^12.0.2",
70
+ "prettier": "3.9.8",
71
+ "sinon": "^22.1.0",
68
72
  "typescript": "^6.0.3",
69
- "typescript-eslint": "^8.61.1"
73
+ "typescript-eslint": "^8.70.0"
70
74
  },
71
75
  "overrides": {
72
76
  "mocha": {
@@ -74,5 +78,14 @@
74
78
  "serialize-javascript": "^7.0.5",
75
79
  "glob": "^13.0.0"
76
80
  }
81
+ },
82
+ "lint-staged": {
83
+ "**/*": "prettier --write --ignore-unknown"
84
+ },
85
+ "prettier": {
86
+ "semi": true,
87
+ "trailingComma": "all",
88
+ "singleQuote": true,
89
+ "printWidth": 80
77
90
  }
78
91
  }