@browserless.io/cli 0.5.2 → 0.6.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 +7 -0
- package/README.md +3 -2
- package/build/agent/ws-client.js +1 -1
- package/build/api/client.js +1 -1
- package/build/api/upload.js +1 -1
- package/build/auth/server-url.js +2 -2
- package/build/browsers/discover.js +5 -5
- package/build/cli-utils/capture-runner.js +6 -6
- package/build/cli-utils/client.js +2 -2
- package/build/cli.js +2 -2
- package/build/commands/agent/chat.js +8 -8
- package/build/commands/profile/launch.js +3 -3
- package/build/errors.js +1 -1
- package/build/regions.js +1 -1
- package/build/telemetry/index.js +2 -2
- package/build/version.js +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.0](https://github.com/browserless/browserless-cli/compare/v0.5.2...v0.6.0) (2026-11-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* AUTO-691 record failure category, code and HTTP status in CLI telemetry ([#145](https://github.com/browserless/browserless-cli/issues/145)) ([90e8459](https://github.com/browserless/browserless-cli/commit/90e8459415783cd1bb927e92b251f8a41e5b35d9))
|
|
9
|
+
|
|
3
10
|
## [0.5.2](https://github.com/browserless/browserless-cli/compare/v0.5.1...v0.5.2) (2026-10-30)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -364,8 +364,9 @@ authenticated with your token and targeted a Browserless cloud region:
|
|
|
364
364
|
|
|
365
365
|
- the command that ran (e.g. `profile upload`) and the **names** of the flags
|
|
366
366
|
you passed — never their values
|
|
367
|
-
- the outcome: `ok` / `error`, the exit code, and the error class
|
|
368
|
-
|
|
367
|
+
- the outcome: `ok` / `error`, the exit code, and on failure the error class,
|
|
368
|
+
a short error code (e.g. `cdp-timeout`, `not-found`), a category (e.g.
|
|
369
|
+
`network`) and the server's HTTP status when there is one — never the error message
|
|
369
370
|
- duration, CLI version, OS / architecture / Node major, whether it's running
|
|
370
371
|
under CI
|
|
371
372
|
- the production region (`sfo` / `lon` / `ams`) — never a raw server URL
|
package/build/agent/ws-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var p=Object.defineProperty;var c=(i,e)=>p(i,"name",{value:e,configurable:!0});import{EventEmitter as f}from"node:events";import m from"ws";import{ApiError as d,PreconditionError as w}from"../errors.js";const u=new Set([1e3,1001,1005]),g=c((i,e)=>{const r=i.replace(/^http/i,"ws").replace(/\/+$/,""),s=new URL(`${r}/chromium/cli`);return s.searchParams.set("token",e),s.toString()},"buildCliWsUrl");class $ extends f{static{c(this,"AgentClient")}ws=null;server;token;WebSocketImpl;constructor(e){super(),this.server=e.server,this.token=e.token,this.WebSocketImpl=e.WebSocketImpl??m}connect(){const e=g(this.server,this.token);return new Promise((r,s)=>{const n=new this.WebSocketImpl(e);let l=!1;const h=c(t=>{if(!l)if(l=!0,t){try{n.terminate()}catch{}s(t)}else this.ws=n,r()},"settle");n.once("open",()=>h()),n.once("unexpected-response",(t,a)=>{const o=a.statusCode??0;h(this.mapUpgradeError(o,a.statusMessage??""))}),n.on("error",t=>{if(!l){h(new d(`WebSocket connection failed: ${t.message}`,0,void 0,"websocket-failed"));return}this.emit("agent_error",{code:"ws-error",message:t.message,retryable:!1})}),n.on("message",t=>this.handleMessage(t)),n.on("close",(t,a)=>{const o=a?.toString("utf8")??"";if(!u.has(t)){this.emit("agent_error",{code:`ws-closed-${t}`,message:`WebSocket closed abnormally (code ${t}${o?`: ${o}`:""})`,retryable:!1});return}this.emit("close",{code:t,reason:o})})})}start(e){this.sendFrame({type:"start",prompt:e})}send(e){this.sendFrame({type:"send",prompt:e})}stop(){this.sendFrame({type:"stop"})}close(){this.ws&&this.ws.readyState===m.OPEN&&this.ws.close()}sendFrame(e){if(!this.ws||this.ws.readyState!==m.OPEN)throw new d("Cannot send a frame: WebSocket is not open.",0,void 0,"websocket-not-open");this.ws.send(JSON.stringify(e))}handleMessage(e){let r;try{r=JSON.parse(e.toString("utf8"))}catch{return}typeof r.type=="string"&&this.emit(r.type==="error"?"agent_error":r.type,r)}mapUpgradeError(e,r){const s=r?` \u2014 ${r}`:"";return e===401||e===403?new w(`Authentication failed (HTTP ${e}${s}). Check your token and server.`,"invalid-token"):new d(`Server rejected the agent connection (HTTP ${e}${s}).`,e)}}export{$ as AgentClient,g as buildCliWsUrl};
|
package/build/api/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var l=Object.defineProperty;var c=(e,t)=>l(e,"name",{value:t,configurable:!0});import{ApiError as f}from"../errors.js";const $=3e4,w=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"),p=c((e,t,a,r)=>{const s=e.endsWith("/")?e:`${e}/`,m=t.replace(/^\/+/,""),o=new URL(m,s);if(o.searchParams.set("token",a),r)for(const[u,h]of Object.entries(r))h!==void 0&&o.searchParams.set(u,String(h));return o},"buildUrl"),y=c((e,t,a)=>{if(!a)return`HTTP ${e} ${t}`;try{const s=JSON.parse(a);if(s?.message&&typeof s.message=="string")return s.message}catch{}const r=a.trim();return r.length>200?`HTTP ${e} ${t}: ${r.slice(0,200)}\u2026`:`HTTP ${e} ${t}: ${r}`},"messageFromBody"),T=c(async(e,t)=>{const a=p(e.server,t.path,e.token,t.query),r={method:t.method,redirect:"error"};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=w(t.attemptId);m&&(r.headers={...r.headers,"x-browserless-attempt-id":m});const o=t.timeoutMs??$,u=new AbortController,h=setTimeout(()=>u.abort(),o);r.signal=u.signal;let n;try{n=await fetch(a,r)}catch(i){throw i?.name==="AbortError"?new f(`Request to ${e.server}${t.path} timed out after ${o}ms`,0,void 0,"request-timeout"):new f(`Failed to reach ${e.server}: ${i?.message??i}`,0,void 0,"network-unreachable")}finally{clearTimeout(h)}let d;try{d=await n.text()}catch(i){throw i?.name==="AbortError"?new f(`Request to ${e.server}${t.path} timed out after ${o}ms`,0,void 0,"request-timeout"):new f(`Failed to read response from ${e.server}${t.path}: ${i?.message??i}`,0,void 0,"response-read-failed")}if(!n.ok)throw new f(y(n.status,n.statusText,d),n.status,d);if(!(n.status===204||!d))try{return JSON.parse(d)}catch{throw new f(`Server returned non-JSON response: ${d}`,n.status,d,"invalid-response")}},"apiFetch");export{T as apiFetch,w as profileAttemptId};
|
package/build/api/upload.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var o=Object.defineProperty;var i=(t,e)=>o(t,"name",{value:e,configurable:!0});import{apiFetch as n}from"./client.js";import{ApiError as s}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 s)||t.status!==400||!/additional propert/i.test(`${t.body??""} ${t.message}`)?t:new s(`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,"capture-settings-rejected")},"rethrowCaptureSettingsSkew"),h=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,h as uploadProfile};
|
package/build/auth/server-url.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var s=Object.defineProperty;var
|
|
2
|
-
`),
|
|
1
|
+
var s=Object.defineProperty;var t=(e,r)=>s(e,"name",{value:r,configurable:!0});import{PreconditionError as n,UsageError as o}from"../errors.js";import{isLoopbackHostname as p}from"../utils/loopback.js";const i="BROWSERLESS_ALLOW_INSECURE_HTTP",S=t(e=>{let r;try{r=new URL(e)}catch{throw new o(`server must be a valid URL (got "${e}")`,"invalid-server-url")}if(r.protocol==="https:")return e;if(r.protocol==="http:"){if(p(r.hostname))return e;if(process.env[i]==="1")return process.stderr.write(`warning: sending your Browserless token over unencrypted http:// to ${r.host} (BROWSERLESS_ALLOW_INSECURE_HTTP is set)
|
|
2
|
+
`),e;throw new n(`Refusing to send your Browserless token over unencrypted http:// to ${r.host}. Use https://, or set BROWSERLESS_ALLOW_INSECURE_HTTP=1 to override.`,"insecure-server-url")}throw new o(`server must use https:// (got "${r.protocol}")`,"unsupported-server-scheme")},"assertSecureServerUrl");export{i as ALLOW_INSECURE_ENV,S as assertSecureServerUrl};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var N=Object.defineProperty;var n=(e,
|
|
2
|
-
`);throw new w(`No profile named "${
|
|
3
|
-
${f}
|
|
4
|
-
`);throw new w(`Profile "${
|
|
5
|
-
${d}
|
|
1
|
+
var N=Object.defineProperty;var n=(e,r)=>N(e,"name",{value:r,configurable:!0});import h from"node:fs/promises";import m from"node:path";import{spawn as g}from"node:child_process";import{BUILT_IN_BROWSERS as y}from"./registry.js";import{readCustomBrowsers as p}from"./custom.js";import{UsageError as w}from"../errors.js";import{pathExists as c}from"../utils/fs.js";const b=n(e=>new Promise(r=>{const t=g("which",[e],{stdio:["ignore","pipe","ignore"]});let s="";t.stdout?.on("data",o=>{s+=o.toString()}),t.on("error",()=>r(null)),t.on("exit",o=>r(o===0&&s.trim()?s.trim():null))}),"whichOnPath"),k=n(async e=>{for(const r of e)if(await c(r))return r;return null},"firstExistingPath"),C=n(async e=>{const r=await k(e);if(r)return r;if(process.platform==="linux")for(const t of e){const s=m.basename(t);if(!s)continue;const o=await b(s);if(o)return o}return null},"firstExistingBinary"),B=n(async e=>{const r=m.join(e,"Local State");try{const t=await h.readFile(r,"utf-8"),o=JSON.parse(t)?.profile?.info_cache??{};return Object.fromEntries(Object.entries(o).map(([i,l])=>[i,l?.name??i]))}catch{return{}}},"readProfileDisplayNames"),$=n(async e=>await c(m.join(e,"Preferences"))||await c(m.join(e,"Cookies"))||await c(m.join(e,"Network","Cookies")),"looksLikeProfile"),P=n(async(e,r,t,s)=>{const o=await B(e);let i;try{i=await h.readdir(e,{withFileTypes:!0})}catch{return[]}const l=i.filter(a=>a.isDirectory()).filter(a=>a.name==="Default"||/^Profile \d+$/.test(a.name));return(await Promise.all(l.map(async a=>{const f=m.join(e,a.name);return await $(f)?{browserKey:t,browserDisplayName:s,profileDirName:a.name,profileDisplayName:o[a.name]??a.name,userDataDir:e,profilePath:f,binaryPath:r}:null}))).filter(a=>a!==null)},"profilesUnder"),L=n(async e=>{const r=e.userDataDirByPlatform[process.platform],t=e.binaryPathByPlatform[process.platform]??[];if(!r||t.length===0)return[];const s=Array.isArray(r)?r:[r],o=await C(t);if(!o)return[];for(const i of s){if(!await c(i))continue;const l=await P(i,o,e.key,e.displayName);if(l.length>0)return l}return[]},"discoverBuiltIn"),x=n(async e=>await c(e.userDataDir)?await c(e.binaryPath)?P(e.userDataDir,e.binaryPath,e.name,e.name):[]:[],"discoverCustom"),j=n(async()=>{const[e,r]=await Promise.all([Promise.all(y.map(L)),p().then(t=>Promise.all(t.map(x)))]);return[...e.flat(),...r.flat()]},"discoverProfiles"),T=n(async()=>{const e=await p();return(await Promise.all(e.map(async t=>{const[s,o]=await Promise.all([c(t.binaryPath),c(t.userDataDir)]);return s&&o?null:{name:t.name,binaryPath:t.binaryPath,userDataDir:t.userDataDir,missingBinary:!s,missingUserDataDir:!o}}))).filter(t=>t!==null)},"findBrokenCustomSources"),D=n((e,r)=>{const t=e.trim().toLowerCase();return r.browserKey.toLowerCase()===t||r.browserDisplayName.toLowerCase()===t},"matchesBrowser"),E=n((e,r)=>{const t=e.trim().toLowerCase();return r.profileDirName.toLowerCase()===t||r.profileDisplayName.toLowerCase()===t},"matchesProfile"),O=n((e,r,t,s)=>{const o=e.trim().toLowerCase();if(!t.some(a=>a.key.toLowerCase()===o||a.displayName.toLowerCase()===o))throw new w(`Unknown browser "${e}". Run \`browserless profile sources list\` to see detected browsers, or register a custom one with \`profile sources add\`.`,"unknown-browser");const l=s.filter(a=>D(e,a)&&E(r,a));if(l.length===1)return l[0];if(l.length===0){const a=s.filter(u=>D(e,u));if(a.length===0)throw new w(`Browser "${e}" is registered but has no detected profiles on this machine.`,"browser-has-no-profiles");const f=a.map(u=>` - ${u.profileDisplayName} (${u.profileDirName})`).join(`
|
|
2
|
+
`);throw new w(`No profile named "${r}" under ${e}. Available profiles:
|
|
3
|
+
${f}`,"local-profile-not-found")}const d=l.map(a=>` - ${a.profileDisplayName} (dir: ${a.profileDirName}) under ${a.browserDisplayName}`).join(`
|
|
4
|
+
`);throw new w(`Profile "${r}" matches multiple entries \u2014 disambiguate by passing the directory name to --profile:
|
|
5
|
+
${d}`,"local-profile-ambiguous")},"resolveProfileFromCandidates"),J=n(async(e,r)=>{const t=await p(),s=[...y.map(i=>({key:i.key,displayName:i.displayName})),...t.map(i=>({key:i.name,displayName:i.name}))],o=await j();return O(e,r,s,o)},"resolveProfile");export{j as discoverProfiles,T as findBrokenCustomSources,J as resolveProfile,O as resolveProfileFromCandidates,b as whichOnPath};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var _=Object.defineProperty;var p=(t,e)=>_(t,"name",{value:e,configurable:!0});import{resolveProfile as v}from"../browsers/discover.js";import{captureFromProfile as C}from"../capture/index.js";import{applyOnlyFilter as F,mergeExclusionPatterns as B,normalizeExclusion as y}from"../capture/exclusion.js";import{readConfig as A}from"../config/store.js";import{ensureTermsAccepted as I,isCi as R}from"../auth/disclaimer.js";import{formatProfileLockedMessage as P}from"../capture/profile-lock.js";import{UsageError as T}from"../errors.js";import{version as L}from"../version.js";import{collectRepeated as b,parseNonNegativeInt as z}from"./client.js";import{formatBytes as u,measureOriginSizes as G,SERVER_ARTIFACT_CAP_BYTES as x,trimStateToFit as M}from"./trim-state.js";const j=p((t,e)=>t===!0&&!e,"captureIsInteractive"),H=p((t,e)=>{const o={copying:"copying profile data\u2026",launching:"launching headless browser\u2026","waiting-for-debugger":"waiting for browser to be ready\u2026"};let s="",d=0;return r=>{if(r.phase!=="done"){if(r.phase==="waiting-for-unlock"){P(t,r,"wait").split(`
|
|
2
|
-
`).forEach(e);return}if(r.phase==="capturing-origins"){if(r.attempted===0){s!=="capturing-origins"&&(s="capturing-origins",e("capturing per-origin storage\u2026"));return}if(!(r.attempted===r.total)&&r.attempted-d<5)return;d=r.attempted;const i=r.origin.length>50?r.origin.slice(0,47)+"\u2026":r.origin;e(` ${r.attempted}/${r.total} ${i}`);return}r.phase!==s&&(s=r.phase,e(o[r.phase]??r.phase))}}},"createProgressRenderer"),ae=p((t,e={})=>{const l=e.sourceOptional?t.option.bind(t):t.requiredOption.bind(t),o=e.sourceOptional?". Optional here \u2014 read from the profile's stored settings when omitted":"";return l("--browser <key>",`Source browser key (chrome / brave / edge / ...) or display name${o}`),l("--profile <name>",`Source profile display name or directory (e.g. "Personal", "Default")${o}`),t.option("--exclude-domain <domain>","Append a domain to the exclusion list for this run (repeatable)",b).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)",b).option("--only-domain <domain>","Capture only cookies / origins matching this domain \u2014 discard everything else (suffix-match; repeatable; applies after --exclude-domain)",b)},"addCaptureFlags"),U=p(t=>{if(t.length>0&&!t.some(e=>y(e)!==null))throw new T(`--only-domain: no valid domain pattern in ${JSON.stringify(t)}. Use a hostname like "example.com" or "*.example.com"
|
|
2
|
+
`).forEach(e);return}if(r.phase==="capturing-origins"){if(r.attempted===0){s!=="capturing-origins"&&(s="capturing-origins",e("capturing per-origin storage\u2026"));return}if(!(r.attempted===r.total)&&r.attempted-d<5)return;d=r.attempted;const i=r.origin.length>50?r.origin.slice(0,47)+"\u2026":r.origin;e(` ${r.attempted}/${r.total} ${i}`);return}r.phase!==s&&(s=r.phase,e(o[r.phase]??r.phase))}}},"createProgressRenderer"),ae=p((t,e={})=>{const l=e.sourceOptional?t.option.bind(t):t.requiredOption.bind(t),o=e.sourceOptional?". Optional here \u2014 read from the profile's stored settings when omitted":"";return l("--browser <key>",`Source browser key (chrome / brave / edge / ...) or display name${o}`),l("--profile <name>",`Source profile display name or directory (e.g. "Personal", "Default")${o}`),t.option("--exclude-domain <domain>","Append a domain to the exclusion list for this run (repeatable)",b).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)",b).option("--only-domain <domain>","Capture only cookies / origins matching this domain \u2014 discard everything else (suffix-match; repeatable; applies after --exclude-domain)",b)},"addCaptureFlags"),U=p(t=>{if(t.length>0&&!t.some(e=>y(e)!==null))throw new T(`--only-domain: no valid domain pattern in ${JSON.stringify(t)}. Use a hostname like "example.com" or "*.example.com".`,"invalid-only-domain")},"validateOnlyDomain"),D=100,Y=253,O=255,N=8*1024,J=/[$`\\!\u0000-\u001f\u007f]/,K=/^[A-Za-z0-9*._-]+$/,$=p((t,e)=>{process.stderr.write(` \u2192 Not storing ${t} for refresh (${e}); a later flagless \`profile refresh\` of this profile will not replay it
|
|
3
3
|
`)},"warnDropped"),X=p(t=>{const e=`they serialize past the server's ${N}-byte limit`;process.stderr.write(t==="upload"?` \u2192 Not storing any capture settings (${e}); a later flagless \`profile refresh\` of this profile will have nothing to replay
|
|
4
4
|
`:` \u2192 Not updating the stored capture settings (${e}); 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
|
|
5
|
-
`)},"warnOverCap"),E=p((t,e)=>{const l=e?.trim();if(l){if(J.test(l)){$(`--${t}`,"it contains characters a shell would interpret");return}if(l.length>O){$(`--${t}`,`it exceeds ${O} characters`);return}return l}},"safeScalar"),k=p((t,e,l=!1)=>{const o=[...new Set((e??[]).map(d=>y(d)).filter(d=>d!==null))],s=o.filter(d=>d.length<=Y&&K.test(d));return s.length<o.length&&$(`${o.length-s.length} of ${o.length} --${t} patterns`,"the server only stores plain hostname patterns"),s.length?(s.length>D&&$(`${s.length-D} of ${s.length} --${t} patterns`,`the server stores at most ${D}`),s.slice(0,D)):l&&!(e??[]).length?[]:void 0},"safeDomains"),
|
|
5
|
+
`)},"warnOverCap"),E=p((t,e)=>{const l=e?.trim();if(l){if(J.test(l)){$(`--${t}`,"it contains characters a shell would interpret");return}if(l.length>O){$(`--${t}`,`it exceeds ${O} characters`);return}return l}},"safeScalar"),k=p((t,e,l=!1)=>{const o=[...new Set((e??[]).map(d=>y(d)).filter(d=>d!==null))],s=o.filter(d=>d.length<=Y&&K.test(d));return s.length<o.length&&$(`${o.length-s.length} of ${o.length} --${t} patterns`,"the server only stores plain hostname patterns"),s.length?(s.length>D&&$(`${s.length-D} of ${s.length} --${t} patterns`,`the server stores at most ${D}`),s.slice(0,D)):l&&!(e??[]).length?[]:void 0},"safeDomains"),h=p((t,e)=>e===void 0?{}:{[t]:e},"withKey"),le={browser:"browser",profile:"profile",excludeDomains:"excludeDomain",onlyDomains:"onlyDomain",keepDomains:"keepDomain",autoFit:"autoFit",passwordStore:"passwordStore"},de=p((t,e,l)=>{const o={...h("browser",E("browser",t.browser)),...h("profile",E("profile",t.profile)),...h("excludeDomains",k("exclude-domain",e.excludedDomains,t.defaultExcludes===!1)),...h("onlyDomains",k("only-domain",t.onlyDomain)),...h("keepDomains",k("keep-domain",t.keepDomain)),...t.autoFit?{autoFit:!0}:{},...h("passwordStore",E("password-store",t.passwordStore)),cliVersion:L};if(Buffer.byteLength(JSON.stringify(o),"utf8")>N){X(l);return}return o},"buildCaptureSettings"),q=p(t=>{(t??[]).filter(e=>y(e)===null).forEach(e=>{process.stderr.write(` ! --exclude-domain ${JSON.stringify(e)} is not a usable domain pattern \u2014 nothing was excluded for it
|
|
6
6
|
`)})},"warnUnusableExcludes"),pe=p((t,e)=>{if(!e)return t;const l=t.defaultExcludes===!1,o=(t.excludeDomain??[]).some(d=>y(d)!==null),s=!o&&e.excludeDomains!==void 0;return{...t,browser:t.browser??e.browser,profile:t.profile??e.profile,passwordStore:t.passwordStore??e.passwordStore,excludeDomain:o?t.excludeDomain:l?[]:e.excludeDomains,onlyDomain:t.onlyDomain??e.onlyDomains,keepDomain:t.keepDomain??e.keepDomains,autoFit:t.autoFit??e.autoFit,defaultExcludes:s?!1:t.defaultExcludes}},"mergeStoredSettings"),ce=p((t,e,l={})=>{if(!e)return;const o=p(i=>process.stderr.write(`${i}
|
|
7
|
-
`),"w"),s=l.userOptedOut===!0;o("> Refreshing with these effective settings:"),t.browser&&o(` --browser ${t.browser}`),t.profile&&o(` --profile ${t.profile}`);const d=(t.excludeDomain??[]).filter(i=>y(i)!==null);d.length&&o(` --exclude-domain ${d.join(", ")}`),t.onlyDomain?.length&&(o(` --only-domain ${t.onlyDomain.join(", ")}`),o(" ! only these domains are captured \u2014 everything else in the saved"),o(" profile is replaced, not kept")),t.keepDomain?.length&&o(` --keep-domain ${t.keepDomain.join(", ")}`),t.autoFit&&o(" --auto-fit (only acts if the capture exceeds the 2 MB cap)"),t.passwordStore&&o(` --password-store ${t.passwordStore}`),s&&o(" --no-default-excludes");const r=s&&!d.length,f=e.excludeDomains?.length;r&&f&&(o(` ! --no-default-excludes drops the ${f} stored exclusion pattern(s) for this run,`),o(" and re-pass --exclude-domain if you want to keep them.")),r?(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.")):s?(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.")):f===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."),s||(o(f===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."),f&&o(" --no-default-excludes drops the stored list for good."))},"printEffectiveSettings"),fe=p(async t=>{const{flags:e,requiresDisclaimer:l}=t;if(!e.browser||!e.profile){const a=[e.browser?null:"--browser",e.profile?null:"--profile"].filter(Boolean);throw new T(`${a.join(" and ")} ${a.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)
|
|
7
|
+
`),"w"),s=l.userOptedOut===!0;o("> Refreshing with these effective settings:"),t.browser&&o(` --browser ${t.browser}`),t.profile&&o(` --profile ${t.profile}`);const d=(t.excludeDomain??[]).filter(i=>y(i)!==null);d.length&&o(` --exclude-domain ${d.join(", ")}`),t.onlyDomain?.length&&(o(` --only-domain ${t.onlyDomain.join(", ")}`),o(" ! only these domains are captured \u2014 everything else in the saved"),o(" profile is replaced, not kept")),t.keepDomain?.length&&o(` --keep-domain ${t.keepDomain.join(", ")}`),t.autoFit&&o(" --auto-fit (only acts if the capture exceeds the 2 MB cap)"),t.passwordStore&&o(` --password-store ${t.passwordStore}`),s&&o(" --no-default-excludes");const r=s&&!d.length,f=e.excludeDomains?.length;r&&f&&(o(` ! --no-default-excludes drops the ${f} stored exclusion pattern(s) for this run,`),o(" and re-pass --exclude-domain if you want to keep them.")),r?(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.")):s?(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.")):f===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."),s||(o(f===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."),f&&o(" --no-default-excludes drops the stored list for good."))},"printEffectiveSettings"),fe=p(async t=>{const{flags:e,requiresDisclaimer:l}=t;if(!e.browser||!e.profile){const a=[e.browser?null:"--browser",e.profile?null:"--profile"].filter(Boolean);throw new T(`${a.join(" and ")} ${a.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)`,"missing-capture-settings")}const o=await v(e.browser,e.profile);l&&await I({acceptViaFlag:!!e.acceptTerms,ttlDaysOverride:e.termsTtlDays!==void 0?z("--terms-ttl-days",e.termsTtlDays):void 0});const s=await A(),d=B(s.excluded_domains,e.excludeDomain,e.defaultExcludes===!1);U(e.onlyDomain??[]),q(e.excludeDomain),process.stderr.write(`> Capturing ${o.browserDisplayName} / ${o.profileDisplayName}
|
|
8
8
|
`);const r=p(a=>{process.stderr.write(` ${a}
|
|
9
|
-
`)},"writeLine"),f={profile:o,excludedDomains:d,onlyDomains:e.onlyDomain??[],passwordStoreOverride:e.passwordStore,interactive:j(process.stdin.isTTY,R()),onProgress:H(o,r)},i=await C(f);if(e.onlyDomain&&e.onlyDomain.length>0){const a=F(i.state,e.onlyDomain),
|
|
9
|
+
`)},"writeLine"),f={profile:o,excludedDomains:d,onlyDomains:e.onlyDomain??[],passwordStoreOverride:e.passwordStore,interactive:j(process.stdin.isTTY,R()),onProgress:H(o,r)},i=await C(f);if(e.onlyDomain&&e.onlyDomain.length>0){const a=F(i.state,e.onlyDomain),m=i.state.cookies.length-a.state.cookies.length,n=i.diagnostics.originCountSkippedByOnlyDomain+a.originsDropped;(m>0||n>0)&&(i.state=a.state,i.serialized=JSON.stringify(a.state),process.stderr.write(` \u2192 --only-domain kept ${i.state.cookies.length} cookies / ${i.state.origins.length} origins; dropped ${m} cookies / ${n} origins not matching: ${e.onlyDomain.join(", ")}
|
|
10
10
|
`))}const c=i.diagnostics,S=Buffer.byteLength(i.serialized,"utf-8");if(process.stderr.write(`> Captured ${c.cookieCountBeforeExclusion} cookies, ${c.originCountBeforeExclusion} origins in ${c.durationMs}ms (artifact: ${u(S)})
|
|
11
11
|
`),c.cookieCountExcluded>0||c.originCountExcluded>0){const a=c.excludedDomains.length?c.excludedDomains.join(", "):"(none)";process.stderr.write(` \u2192 Excluded ${c.cookieCountExcluded} cookies / ${c.originCountExcluded} origins matching: ${a}
|
|
12
12
|
`)}if(i.capHit&&process.stderr.write(` ! Hit the per-capture origin cap \u2014 some origins may be missing
|
|
@@ -14,9 +14,9 @@ var _=Object.defineProperty;var p=(t,e)=>_(t,"name",{value:e,configurable:!0});i
|
|
|
14
14
|
`);for(const a of c.failedOrigins)process.stderr.write(` - ${a.origin}: ${a.error}
|
|
15
15
|
`)}if(i.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>
|
|
16
16
|
`),S>x){const a=G(i.state),g=10;process.stderr.write(` ! artifact size ${u(S)} exceeds the ${u(x)} server cap \u2014 heaviest origins:
|
|
17
|
-
`);for(const{origin:
|
|
17
|
+
`);for(const{origin:m,bytes:n}of a.slice(0,g))process.stderr.write(` ${u(n).padStart(10)} ${m}
|
|
18
18
|
`);if(a.length>g&&process.stderr.write(` \u2026 and ${a.length-g} more origins below ${u(a[g].bytes)}
|
|
19
|
-
`),e.autoFit){const
|
|
19
|
+
`),e.autoFit){const m=e.keepDomain??[],n=M(i.state,x,m);if(n.dropped.length===0&&n.finalBytes<=x)process.stderr.write(` ! --auto-fit had nothing to drop \u2014 artifact unchanged
|
|
20
20
|
`);else{if(i.state=n.state,i.serialized=n.serialized,c.failedOrigins=[...c.failedOrigins,...n.dropped.map(w=>({origin:w,error:"dropped by --auto-fit to fit under the server cap",kind:"unknown"}))],n.dropped.length>0){process.stderr.write(` --auto-fit: dropped ${n.dropped.length} origin(s), now ${u(n.finalBytes)}:
|
|
21
21
|
`);for(const w of n.dropped)process.stderr.write(` - ${w}
|
|
22
22
|
`)}if(n.protectedFromDrop.length>0){process.stderr.write(` --auto-fit: ${n.protectedFromDrop.length} heavy origin(s) protected by --keep-domain:
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var i=Object.defineProperty;var o=(e,r)=>i(e,"name",{value:r,configurable:!0});import{resolveServer as
|
|
2
|
-
`)},"printJson"),g=/^\d+$/,b=o((e,r,t=0)=>{const n=o(()=>{throw new
|
|
1
|
+
var i=Object.defineProperty;var o=(e,r)=>i(e,"name",{value:r,configurable:!0});import{resolveServer as l,resolveToken as a}from"../auth/store.js";import{UsageError as c}from"../errors.js";import{KNOWN_REGIONS as v}from"../regions.js";const m=o(async e=>{const r=await l({server:e.server,region:e.region}),{token:t,source:n}=await a({flag:e.token,server:r});return{server:r,token:t,source:n}},"buildClient"),k=o((e,r)=>[...r??[],e],"collectRepeated"),p=o(e=>e.option("--server <url>","Browserless server URL").option("--region <code>",`Browserless region (${v.join(" | ")}) \u2014 shorthand for --server`),"addServerOverrideFlags"),x=o(e=>p(e.option("--token <token>","API token (overrides env / keychain / file)")).option("--json","Emit the server response as JSON"),"addClientFlags"),I=o(e=>{process.stdout.write(JSON.stringify(e,null,2)+`
|
|
2
|
+
`)},"printJson"),g=/^\d+$/,b=o((e,r,t=0)=>{const n=o(()=>{throw new c(`${e} must be a${t>0?" positive":" non-negative"} integer (got "${r}")`,"invalid-integer-flag")},"fail");g.test(r)||n();const s=Number(r);return(!Number.isFinite(s)||!Number.isInteger(s)||s<t)&&n(),s},"parseNonNegativeInt");export{x as addClientFlags,p as addServerOverrideFlags,m as buildClient,k as collectRepeated,b as parseNonNegativeInt,I as printJson};
|
package/build/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var n=Object.defineProperty;var t=(e,
|
|
2
|
+
var n=Object.defineProperty;var t=(e,s)=>n(e,"name",{value:s,configurable:!0});import{Command as m}from"commander";import{version as a}from"./version.js";import{registerProfile as c}from"./commands/profile/index.js";import{registerAuth as p}from"./commands/auth/index.js";import{registerConfig as f}from"./commands/config/index.js";import{registerAgent as g}from"./commands/agent/index.js";import{exitCodeFor as l,UserFacingError as d}from"./errors.js";import*as o from"./telemetry/index.js";const r=new m;r.name("browserless").description("Browserless CLI \u2014 manage profiles, sessions, and more.").version(a),c(r),p(r),f(r),g(r);const i=t(e=>e.name()==="terms"&&e.parent?.name()==="profile","isProfileTerms");r.hook("preAction",(e,s)=>{if(!i(s))try{o.begin(s)}catch{}}),r.hook("postAction",async(e,s)=>{if(!i(s))try{await o.complete({status:"ok",exitCode:0})}catch{}}),r.parseAsync(process.argv).catch(async e=>{e instanceof d?process.stderr.write(`${e.message}
|
|
3
3
|
`):e instanceof Error?process.stderr.write(`${e.stack??e.message}
|
|
4
4
|
`):process.stderr.write(`${String(e)}
|
|
5
|
-
`),process.exitCode=l(e);try{await
|
|
5
|
+
`),process.exitCode=l(e);try{await o.complete(o.errorResult(e,process.exitCode))}catch{}});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var C=Object.defineProperty;var n=(e,l)=>C(e,"name",{value:l,configurable:!0});import{stdout as
|
|
2
|
-
`))},"ensureTextStart"),
|
|
3
|
-
`),a==="status"&&s.clear()},"ensureLineEndedBeforeBlock");e.on("data",t=>{typeof t.text!="string"||t.text.length===0||(
|
|
4
|
-
`);const{method:r,params:u}=j(t.method,t.params),c=L(u),i=I(t.rationale);d.set(t.id??"",{rationale:i,summary:c,method:r}),a="status",s.set(
|
|
1
|
+
var C=Object.defineProperty;var n=(e,l)=>C(e,"name",{value:l,configurable:!0});import{stdout as y,stderr as E}from"node:process";import{buildClient as S,printJson as $}from"../../cli-utils/client.js";import{buildPrompts as _}from"../../cli-utils/prompts.js";import{ApiError as T}from"../../errors.js";import{AgentClient as A}from"../../agent/ws-client.js";import{loadHistory as P,saveHistory as B}from"../../agent/history.js";import{normalizeRationale as I,formatEndResult as M,hasLoginIntent as R,summarizeParams as L,unwrapToolCall as j,withCredentials as v}from"../../cli-utils/agent-format.js";import{colorsFor as h}from"../../utils/ansi.js";import{Spinner as z}from"../../utils/spinner.js";const F={buildClient:S,makeClient:n(e=>new A(e),"makeClient")},b=n(e=>new Promise(l=>{const o=n(()=>{e.off("end",p),e.off("awaiting_input",s),e.off("agent_error",d),e.off("close",a)},"cleanup"),p=n(m=>{o(),l({kind:"end",payload:m})},"onEnd"),s=n(m=>{o(),l({kind:"awaiting_input",payload:m})},"onAwait"),d=n(m=>{o(),l({kind:"error",payload:m})},"onErr"),a=n(()=>{o(),l({kind:"closed"})},"onClose");e.once("end",p),e.once("awaiting_input",s),e.once("agent_error",d),e.once("close",a)}),"waitForTurnEnd"),G=n((e,l)=>{const o=l?E:y,p=h(o),s=new z({out:o}),d=new Map;let a="idle";const m=n(()=>{a==="status"&&(s.clear(),o.write(`
|
|
2
|
+
`))},"ensureTextStart"),g=n(()=>{a==="text"&&o.write(`
|
|
3
|
+
`),a==="status"&&s.clear()},"ensureLineEndedBeforeBlock");e.on("data",t=>{typeof t.text!="string"||t.text.length===0||(m(),a="text",o.write(t.text))});const k=n((t,r)=>{const c=t&&t!=="commands"?p.gray(t):"",i=r?p.dim(r):"";return[c,i].filter(Boolean).join(" ")},"formatTail"),f=n((t,r,u,c)=>{const i=k(u,c),w=r?`${r}: `:"";return`${t}${w}${i}`},"formatLine");return e.on("tool_call",t=>{a==="text"&&o.write(`
|
|
4
|
+
`);const{method:r,params:u}=j(t.method,t.params),c=L(u),i=I(t.rationale);d.set(t.id??"",{rationale:i,summary:c,method:r}),a="status",s.set(f("",i,r,c))}),e.on("tool_result",t=>{const r=d.get(t.id??"")??{summary:"",method:"?"};d.delete(t.id??"");const u=t.ok?p.green("\u2713"):p.red("\u2717");s.done(f(`${u} `,r.rationale,r.method,r.summary)),a="idle"}),e.on("usage",()=>{}),{printEnd:n(t=>{if(g(),a="idle",l){$({type:"end",result:t.result??null});return}const r=M(t);o.write(r?`
|
|
5
5
|
${r}
|
|
6
6
|
`:`
|
|
7
|
-
`)},"printEnd"),clearStatus:n(()=>{
|
|
7
|
+
`)},"printEnd"),clearStatus:n(()=>{g(),a="idle"},"clearStatus"),dispose:n(()=>s.clear(),"dispose")}},"createRenderer"),H=n((e,l)=>{let o=0;const p=n(()=>{if(o+=1,o===1){l(),process.stderr.write(h(process.stderr).gray(`
|
|
8
8
|
(stop sent \u2014 press Ctrl-C again to exit)
|
|
9
|
-
`));try{e.stop()}catch{}}else process.exit(130)},"handler"),s=["SIGINT","SIGBREAK"];return s.forEach(d=>process.on(d,p)),()=>s.forEach(d=>process.off(d,p))},"installSigint"),Y=n(async(e,l,o=F)=>{const p=!!e.json,s=await o.buildClient(e),d=p?E:
|
|
10
|
-
`));const a=e.history!==!1&&!l,
|
|
11
|
-
`),i.payload.retryable!==!0)throw new T("Agent session ended with an error.",0);continue}t.printEnd(i.payload)}}finally{r(),t.dispose(),
|
|
9
|
+
`));try{e.stop()}catch{}}else process.exit(130)},"handler"),s=["SIGINT","SIGBREAK"];return s.forEach(d=>process.on(d,p)),()=>s.forEach(d=>process.off(d,p))},"installSigint"),Y=n(async(e,l,o=F)=>{const p=!!e.json,s=await o.buildClient(e),d=p?E:y;d.write(h(d).dim(`agent \u2192 ${s.server} (token from ${s.source})
|
|
10
|
+
`));const a=e.history!==!1&&!l,m=a?await P().catch(()=>[]):[],k=l??_(m,a?u=>B(u):async()=>{},d),f=o.makeClient({server:s.server,token:s.token});await f.connect();const t=G(f,p),r=H(f,t.clearStatus);try{let u=!0;for(;;){let c;if(u&&e.prompt)c=e.prompt;else{try{c=await k.line("> ")}catch{break}if(c===""){if(u)continue;break}}if(u&&R(c))try{const w=await k.linePrivate("Username (blank to skip): "),x=w?await k.password("Password (blank to skip): "):"";c=v(c,{username:w,password:x})}catch{break}u?f.start(c):f.send(c),u=!1;let i=await b(f);for(;i.kind==="awaiting_input";){const w=await k.linePrivate("Enter code: ");if(!w){i={kind:"closed"};break}f.send(w),i=await b(f)}if(i.kind==="closed")break;if(i.kind==="error"){if(t.clearStatus(),process.stderr.write(`error: ${i.payload.message??i.payload.code??"unknown"}
|
|
11
|
+
`),i.payload.retryable!==!0)throw new T("Agent session ended with an error.",0,void 0,"agent-session-error");continue}t.printEnd(i.payload)}}finally{r(),t.dispose(),f.close()}},"runAgentChat");export{Y as runAgentChat};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var u=Object.defineProperty;var s=(e,r)=>u(e,"name",{value:r,configurable:!0});import{printJson as
|
|
1
|
+
var u=Object.defineProperty;var s=(e,r)=>u(e,"name",{value:r,configurable:!0});import{printJson as f}from"../../cli-utils/client.js";import{resolveProfile as h}from"../../browsers/discover.js";import{checkProfileLock as b}from"../../browsers/lock.js";import{fetchCdpMetadata as m,killBrowser as g,launchBrowser as y,pickFreePort as D,waitForDebuggerEndpoint as S}from"../../capture/launch.js";import{PreconditionError as k,UsageError as P}from"../../errors.js";const $=s((e,r)=>{const i=r?` (PID ${r})`:"";return`${e} is already running${i}. Quit it first (\u2318Q on macOS) and re-run \`browserless profile launch\`. \`profile launch\` boots a fresh process against your real profile dir, so the source browser must be closed.`},"formatProfileBusyMessage"),x=s(async e=>{if(!e.browser||!e.profile)throw new P("--browser and --profile are required","missing-required-flag");const r=await h(e.browser,e.profile),i=await b(r.userDataDir);if(i.locked)throw new k($(r.browserDisplayName,i.pid),"profile-busy");const t=await D(),{child:a,passwordStoreDefaulted:l,diagnostics:w}=await y({profile:r,userDataDir:r.userDataDir,port:t,headless:!!e.headless,passwordStoreOverride:e.passwordStore});let c=!1;const d=s(async()=>{c||(c=!0,process.stderr.write(`
|
|
2
2
|
> Shutting down browser
|
|
3
|
-
`),await
|
|
3
|
+
`),await g(a))},"cleanup"),n=s(o=>()=>{d().finally(()=>process.exit(o))},"signalHandler");process.once("SIGINT",n(130)),process.once("SIGTERM",n(143)),process.once("SIGBREAK",n(130));try{await S(t,void 0,w);const o=await m(t);e.json?f({pid:a.pid,httpEndpoint:`http://127.0.0.1:${t}`,webSocketDebuggerUrl:o.webSocketDebuggerUrl,browser:o.Browser,userDataDir:r.userDataDir,profileDirectory:r.profileDirName,headless:!!e.headless}):(process.stderr.write(`> Browser running (PID ${a.pid})
|
|
4
4
|
`),process.stderr.write(` ${o.Browser}
|
|
5
5
|
`),process.stderr.write(` HTTP endpoint: http://127.0.0.1:${t}
|
|
6
6
|
`),process.stderr.write(` WebSocket: ${o.webSocketDebuggerUrl}
|
|
@@ -9,4 +9,4 @@ var u=Object.defineProperty;var s=(e,r)=>u(e,"name",{value:r,configurable:!0});i
|
|
|
9
9
|
Note: this is your real ${r.browserDisplayName} profile \u2014 anything you do here persists.
|
|
10
10
|
`),process.stderr.write(`Press Ctrl-C to stop, or fully quit the browser (cmd-Q on macOS).
|
|
11
11
|
`)),await new Promise(p=>{a.once("exit",()=>p())}),process.stderr.write(`> Browser exited
|
|
12
|
-
`)}finally{await d()}},"action"),
|
|
12
|
+
`)}finally{await d()}},"action"),q=s(e=>{e.command("launch").description("Launch a local browser using your existing profile. Source browser must be closed; changes made in the launched window persist back to your real profile.").requiredOption("--browser <key>","Source browser key (chrome / brave / edge / ...) or display name").requiredOption("--profile <name>","Source profile display name or directory").option("--headless","Run the browser with no visible window").option("--password-store <store>","Linux only: --password-store value to pass through to the launched browser").option("--json","Print the launched browser metadata (PID, CDP URLs) as JSON").action(x)},"registerLaunch");export{$ as formatProfileBusyMessage,q as registerLaunch};
|
package/build/errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var c=Object.defineProperty;var s=(t,e)=>c(t,"name",{value:e,configurable:!0});class n extends Error{static{s(this,"UserFacingError")}exitCode=1;constructor(e){super(e),this.name="UserFacingError"}}class a extends n{static{s(this,"UsageError")}code;constructor(e,o){super(e),this.code=o,this.name="UsageError",this.exitCode=2}}class d extends n{static{s(this,"PreconditionError")}code;constructor(e,o){super(e),this.code=o,this.name="PreconditionError",this.exitCode=3}}class u extends n{static{s(this,"CaptureError")}code;constructor(e,o){super(e),this.code=o,this.name="CaptureError",this.exitCode=4}}class p extends n{static{s(this,"ApiError")}status;body;code;constructor(e,o,r,i){super(e),this.status=o,this.body=r,this.code=i,this.name="ApiError",this.exitCode=5}}const E=s(t=>t instanceof n?t.exitCode:1,"exitCodeFor"),f=s(t=>{if(t&&typeof t=="object"){const e=t.code;if(typeof e=="string"&&e.length>0)return e}},"errorCodeOf"),l={400:"bad-request",401:"unauthorized",403:"forbidden",404:"not-found",409:"conflict",413:"payload-too-large",429:"rate-limited"},h=new Set(["request-timeout","network-unreachable","response-read-failed","websocket-failed","websocket-not-open"]),C=s(t=>{let e="internal",o="unknown",r;return t instanceof a?(e="usage",o=t.code??"unknown"):t instanceof d?(e="precondition",o=t.code??"unknown"):t instanceof u?(e="capture",o=t.code??"unknown"):t instanceof p?(r=t.status>0?t.status:void 0,e=(t.code?h.has(t.code):t.status===0)?"network":"api",o=t.code??l[t.status]??(t.status>=400&&t.status<=499?"client-error":t.status>=500&&t.status<=599?"server-error":t.status===0?"unknown":"http-error")):t instanceof n||(o=f(t)??"unknown"),{errorName:t instanceof Error?t.name:void 0,errorCode:/^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$/.test(o)?o:"unknown",errorCategory:e,httpStatus:r}},"errorTelemetryOf");export{p as ApiError,u as CaptureError,d as PreconditionError,a as UsageError,n as UserFacingError,f as errorCodeOf,C as errorTelemetryOf,E as exitCodeFor};
|
package/build/regions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=Object.defineProperty;var r=(o,e)=>n(o,"name",{value:e,configurable:!0});import{UsageError as t}from"./errors.js";const s={sfo:"https://production-sfo.browserless.io",lon:"https://production-lon.browserless.io",ams:"https://production-ams.browserless.io"},i=Object.keys(s),p=r(o=>Object.prototype.hasOwnProperty.call(s,o),"isKnownRegion"),w=r(o=>{if(!p(o))throw new t(`Unknown region "${o}". Known regions: ${i.join(", ")}. For self-hosted or staging, pass --server <url> instead.`,"unknown-region");return s[o]},"regionToServerUrl");export{i as KNOWN_REGIONS,s as REGION_URLS,p as isKnownRegion,w as regionToServerUrl};
|
package/build/telemetry/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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
|
|
2
|
-
`)},"debug");let c,i=[];const
|
|
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 _}from"../config/store.js";import{errorTelemetryOf as l}from"../errors.js";import{REGION_URLS as R,KNOWN_REGIONS as g,isKnownRegion as v}from"../regions.js";import{version as h}from"../version.js";import{commandPath as S,usedFlagNames as T}from"./command-meta.js";import{getRecordedToken as y}from"./token-cache.js";import{getOrCreateDeviceId as w}from"./device-id.js";import{apiBaseUrl as L,isTrustedApiBase as O,postCliEvents as k}from"./api.js";const C="CLI Command Run",d=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"),s=t(e=>{d(process.env.BROWSERLESS_TELEMETRY_DEBUG)&&process.stderr.write(`[telemetry] ${e}
|
|
2
|
+
`)},"debug");let c,i=[];const j=t(e=>{c&&i.length<6&&i.push(e)},"recordProfileSetupEvent"),F=t((e,r)=>({status:"error",exitCode:r,...l(e)}),"errorResult"),x=t(async()=>{if(d(process.env.BROWSERLESS_TELEMETRY_DISABLED)||d(process.env.DO_NOT_TRACK))return!1;try{const e=await _();return e.telemetry===void 0||e.telemetry===!0}catch{return!1}},"isEnabled"),V=t(e=>{i=[],c={command:S(e),flags:T(e),startedAt:p.now()}},"begin"),M=t(e=>{let r;try{r=new URL(e).origin}catch{return"custom"}return g.find(o=>{try{return new URL(R[o]).origin===r}catch{return!1}})??"custom"},"bucketServerUrl"),B=t(()=>Number(process.versions.node.split(".")[0])||0,"nodeMajor"),I=t((e,r,a,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,error_category:r.status==="error"?r.errorCategory:void 0,http_status:r.status==="error"?r.httpStatus:void 0,duration_ms:Math.round(p.now()-e.startedAt),cli_version:h,os:process.platform,arch:process.arch,node_major:B(),is_ci:d(process.env.CI),server_region:a,cli_device_id:o};return{event_type:C,time:Date.now(),event_properties:n}},"buildEvent"),q=t(async e=>{const r=c;c=void 0;const a=i;if(i=[],!!r)try{if(!await x()){s("skipped: telemetry disabled");return}const o=y();if(!o){s("skipped: no token resolved this run");return}const n=M(o.server);if(!v(n)){s("skipped: non-cloud server");return}if(!O(L())){s("skipped: BROWSERLESS_API_URL is not a Browserless host");return}const m=await w(),f=I(r,e,n,m),u=await k([f,...a],{token:o.token,timeoutMs:N()});s(u?`sent (${n})`:`send failed (${n})`)}catch{s("skipped: error while flushing")}},"complete"),z=t(()=>{c=void 0,i=[]},"_resetForTests");export{z as _resetForTests,V as begin,M as bucketServerUrl,q as complete,F as errorResult,N as flushTimeoutMs,x as isEnabled,j as recordProfileSetupEvent};
|
package/build/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="0.
|
|
1
|
+
const o="0.6.0";export{o as version};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browserless.io/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"chrome-remote-interface": "^0.34.0",
|
|
49
49
|
"commander": "^15.0.0",
|
|
50
|
-
"ws": "^8.22.
|
|
50
|
+
"ws": "^8.22.1"
|
|
51
51
|
},
|
|
52
52
|
"optionalDependencies": {
|
|
53
53
|
"@napi-rs/keyring": "^2.1.2"
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@eslint/js": "^10.0.1",
|
|
57
57
|
"@types/chai": "^5.2.3",
|
|
58
|
-
"@types/chrome-remote-interface": "^0.34.
|
|
58
|
+
"@types/chrome-remote-interface": "^0.34.1",
|
|
59
59
|
"@types/mocha": "^10.0.10",
|
|
60
|
-
"@types/node": "^26.6.
|
|
60
|
+
"@types/node": "^26.6.6",
|
|
61
61
|
"@types/sinon": "^22.0.2",
|
|
62
62
|
"@types/ws": "^8.18.2",
|
|
63
63
|
"chai": "^6.3.0",
|
|
64
64
|
"esbuild": "^0.28.2",
|
|
65
|
-
"eslint": "^10.
|
|
66
|
-
"globals": "^17.
|
|
65
|
+
"eslint": "^10.14.0",
|
|
66
|
+
"globals": "^17.14.0",
|
|
67
67
|
"husky": "^9.1.7",
|
|
68
68
|
"lint-staged": "^17.6.0",
|
|
69
69
|
"mocha": "^12.0.3",
|