@browserless.io/cli 0.0.2 → 0.1.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 +19 -0
- package/build/agent/history.js +4 -0
- package/build/agent/types.js +1 -0
- package/build/agent/ws-client.js +1 -0
- package/build/capture/launch.js +7 -6
- package/build/cli-utils/agent-format.js +6 -0
- package/build/cli-utils/prompts.js +4 -0
- package/build/cli.js +2 -2
- package/build/commands/agent/chat.js +11 -0
- package/build/commands/agent/index.js +1 -0
- package/build/utils/ansi.js +1 -0
- package/build/utils/json-file.js +1 -1
- package/build/utils/spinner.js +3 -0
- package/build/version.js +1 -1
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.0](https://github.com/browserless/browserless-cli/compare/v0.0.3...v0.1.0) (2026-06-05)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* agent functionality ([c453dba](https://github.com/browserless/browserless-cli/commit/c453dbad50aa3283f9f8340bf32ed51d185ff132))
|
|
9
|
+
* agent functionality AI-107 ([c453dba](https://github.com/browserless/browserless-cli/commit/c453dbad50aa3283f9f8340bf32ed51d185ff132))
|
|
10
|
+
|
|
11
|
+
## [0.0.3](https://github.com/browserless/browserless-cli/compare/v0.0.2...v0.0.3) (2026-06-05)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* **capture:** connect to the browser CDP endpoint, not a default page target ([417cb12](https://github.com/browserless/browserless-cli/commit/417cb122743bfcfdd91ebbd4d010c7558f02138c))
|
|
17
|
+
* **capture:** retry the default-target CDP connect on "No inspectable targets" ([b834311](https://github.com/browserless/browserless-cli/commit/b8343118a801938e09ff4a5e67957762317a08b1))
|
|
18
|
+
* **capture:** wait for an inspectable target before connecting (fixes "No inspectable targets") ([69c2e96](https://github.com/browserless/browserless-cli/commit/69c2e961e6f70fba5fd40a6ea64e3aba9f323047))
|
|
19
|
+
* **cli:** set process.exitCode instead of process.exit() on error path ([2a6042a](https://github.com/browserless/browserless-cli/commit/2a6042a52fbdbedfcb56086566a6f0a4bdb09ea0))
|
|
20
|
+
* **cli:** windows/macos flaky tests ([559a10d](https://github.com/browserless/browserless-cli/commit/559a10d729251cca0ba1e891bffe13b8caf7b186))
|
|
21
|
+
|
|
3
22
|
## [0.0.2](https://github.com/browserless/browserless-cli/compare/v0.0.1...v0.0.2) (2026-05-27)
|
|
4
23
|
|
|
5
24
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var f=Object.defineProperty;var o=(r,e)=>f(r,"name",{value:e,configurable:!0});import l from"node:fs/promises";import m from"node:path";import{configDir as p}from"../config/paths.js";import{writeSecureFile as u}from"../utils/json-file.js";const n=200,a=o(()=>m.join(p(),"agent_history"),"defaultHistoryFile"),x=o(async(r=a())=>{try{return(await l.readFile(r,"utf-8")).split(`
|
|
2
|
+
`).map(t=>t.trim()).filter(t=>t.length>0).reverse().slice(0,n)}catch{return[]}},"loadHistory"),H=o(async(r,e=a())=>{const t=[];for(const c of r){const i=c.trim();if(i&&t[t.length-1]!==i&&(t.push(i),t.length>=n))break}const s=`${t.slice().reverse().join(`
|
|
3
|
+
`)}
|
|
4
|
+
`;await u(e,s,{atomic:!0})},"saveHistory");export{n as MAX_HISTORY_ENTRIES,a as defaultHistoryFile,x as loadHistory,H as saveHistory};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var s=Object.defineProperty;var t=(o,e)=>s(o,"name",{value:e,configurable:!0});const n=t(o=>!!o&&typeof o=="object"&&typeof o.success=="boolean","isAgentEndResult");export{n as isAgentEndResult};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var c=(i,e)=>d(i,"name",{value:e,configurable:!0});import{EventEmitter as f}from"node:events";import m from"ws";import{ApiError as p,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 p(`WebSocket connection failed: ${t.message}`,0));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 p("Cannot send a frame: WebSocket is not open.",0);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 p(`Server rejected the agent connection (HTTP ${e}${s}).`,e)}}export{$ as AgentClient,g as buildCliWsUrl};
|
package/build/capture/launch.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
var w=Object.defineProperty;var
|
|
2
|
-
Browser process: pid=${
|
|
3
|
-
Launch command: ${
|
|
4
|
-
|
|
5
|
-
${
|
|
6
|
-
|
|
1
|
+
var w=Object.defineProperty;var a=(e,r)=>w(e,"name",{value:r,configurable:!0});import g from"node:net";import{spawn as b,spawnSync as m}from"node:child_process";import{resolveLinuxPasswordStore as C}from"../browsers/password-store.js";import{CaptureError as c}from"../errors.js";const y=a(e=>new Promise(r=>setTimeout(r,e)),"sleep"),D=a(()=>new Promise((e,r)=>{const t=g.createServer();t.unref(),t.on("error",r),t.listen(0,"127.0.0.1",()=>{const n=t.address();t.close(()=>{typeof n=="object"&&n?e(n.port):r(new Error("Could not pick a free port"))})})}),"pickFreePort"),B=a(async(e,r=Number(process.env.BROWSERLESS_CDP_WAIT_MS)||15e3,t)=>{const n=Date.now()+r;let s,d="<not fetched>";for(;Date.now()<n;){try{if((await fetch(`http://127.0.0.1:${e}/json/version`)).ok){const o=await fetch(`http://127.0.0.1:${e}/json/list`);if(o.ok){const p=await o.json();if(Array.isArray(p)&&p.some(f=>typeof f?.webSocketDebuggerUrl=="string"))return;d=JSON.stringify(p)}}}catch(i){s=i}await y(150)}let l="";if(t){const i=t.getProcessState(),o=t.getStderr().trim();l=`
|
|
2
|
+
Browser process: pid=${i.pid??"unspawned"} exitCode=${i.exitCode} signal=${i.signalCode}
|
|
3
|
+
Launch command: ${i.spawnfile} ${i.spawnargs.slice(1).join(" ")}
|
|
4
|
+
Last /json/list: ${d}`+(o?`
|
|
5
|
+
Browser stderr (last ${Math.min(o.length,2e3)} chars):
|
|
6
|
+
${o.slice(-2e3)}`:`
|
|
7
|
+
Browser stderr: <empty>`)}throw new c(`Browser CDP endpoint did not expose an inspectable target within ${r}ms (last error: ${String(s)})${l}`,"cdp-timeout")},"waitForDebuggerEndpoint"),k=["--disable-background-networking","--disable-component-update","--disable-sync","--disable-domain-reliability","--disable-datasaver-prompt","--no-pings","--no-service-autorun","--safebrowsing-disable-auto-update","--disable-external-intent-requests","--metrics-recording-only","--disable-background-timer-throttling","--disable-backgrounding-occluded-windows","--disable-renderer-backgrounding","--disable-back-forward-cache","--disable-ipc-flooding-protection","--disable-hang-monitor","--disable-popup-blocking","--disable-prompt-on-repost","--disable-search-engine-choice-screen","--disable-breakpad","--disable-client-side-phishing-detection","--disable-infobars","--disable-print-preview","--disable-desktop-notifications","--disable-speech-api","--disable-speech-synthesis-api","--suppress-message-center-popups","--noerrdialogs","--disable-blink-features=AutomationControlled","--disable-features="+["AcceptCHFrame","AutoExpandDetailsElement","AvoidUnnecessaryBeforeUnloadCheckSync","CertificateTransparencyComponentUpdater","DialMediaRouteProvider","GlobalMediaControls","HttpsUpgrades","ImprovedCookieControls","LazyFrameLoading","MediaRouter","PaintHolding","Translate","AutomationControlled","BackForwardCache","OptimizationHints","CalculateNativeWinOcclusion","AutofillServerCommunication","CrashReporting","OverscrollHistoryNavigation","InfiniteSessionRestore"].join(",")],P=a(async e=>{const r=e.headless??!0,t=[`--remote-debugging-port=${e.port}`,`--user-data-dir=${e.userDataDir}`,`--profile-directory=${e.profile.profileDirName}`,"--no-first-run","--no-default-browser-check"];r&&t.push("--headless=new","--disable-gpu",...k);let n=!1;if(process.platform==="linux"){const{store:o,defaulted:p}=await C(e.profile.userDataDir,e.passwordStoreOverride);t.push(`--password-store=${o}`),n=p}t.push("about:blank");const s=b(e.profile.binaryPath,t,{detached:!1,stdio:["ignore","pipe","pipe"]}),d=[];let l=0;const i=64*1024;return s.stdout?.on("data",()=>{}),s.stderr?.on("data",o=>{l>=i||(d.push(o),l+=o.length)}),{child:s,passwordStoreDefaulted:n,diagnostics:{getStderr:a(()=>Buffer.concat(d).toString("utf-8"),"getStderr"),getProcessState:a(()=>({pid:s.pid,exitCode:s.exitCode,signalCode:s.signalCode,spawnfile:s.spawnfile,spawnargs:s.spawnargs}),"getProcessState")}}},"launchBrowser"),A=a(async e=>{const r=await fetch(`http://127.0.0.1:${e}/json/version`);if(!r.ok)throw new c(`CDP /json/version returned ${r.status} ${r.statusText}`,"cdp-metadata-invalid");const t=await r.json();if(typeof t.webSocketDebuggerUrl!="string"||typeof t.Browser!="string")throw new c(`CDP /json/version returned an unexpected payload: ${JSON.stringify(t)}`,"cdp-metadata-invalid");return{Browser:t.Browser,webSocketDebuggerUrl:t.webSocketDebuggerUrl}},"fetchCdpMetadata"),u=a((e,r)=>new Promise(t=>{if(e.exitCode!==null||e.signalCode!==null){t();return}const n=setTimeout(t,r);e.once("exit",()=>{clearTimeout(n),t()})}),"waitExitOrTimeout"),T=a(async(e,r=2e3)=>{if(!(!e||e.killed)){if(process.platform==="win32"&&typeof e.pid=="number"){m("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore",windowsHide:!0}),await u(e,r);return}e.kill("SIGTERM"),await u(e,r),!e.killed&&e.exitCode===null&&(e.kill("SIGKILL"),await u(e,5e3)),e.stdin?.destroy(),e.stdout?.destroy(),e.stderr?.destroy(),e.unref()}},"killBrowser");export{A as fetchCdpMetadata,T as killBrowser,P as launchBrowser,D as pickFreePort,B as waitForDebuggerEndpoint};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var d=Object.defineProperty;var s=(t,e)=>d(t,"name",{value:e,configurable:!0});import{green as f,red as m}from"../utils/ansi.js";import{isAgentEndResult as p}from"../agent/types.js";const h=/\b(log[- _]?in|sign[- _]?in|sign[- _]?up|authenticate|log on)/i,b=s(t=>h.test(t),"hasLoginIntent"),k=s(t=>{if(!t)return;const e=t.trim();return e||void 0},"normalizeRationale"),A=s((t,e)=>{const n=[];return e.username&&n.push(`USERNAME=${e.username}`),e.password&&n.push(`PASSWORD=${e.password}`),n.length===0?t:`Credentials available for this task (do not echo back):
|
|
2
|
+
${n.join(`
|
|
3
|
+
`)}
|
|
4
|
+
|
|
5
|
+
`+t},"withCredentials"),g=s((t,e)=>{const n=typeof t=="string"?t:t===null||typeof t!="object"?String(t):JSON.stringify(t);return n.length>e?`${n.slice(0,e-1)}\u2026`:n},"previewValue"),_=/^(pass(word|code)?|secret|token|auth(orization)?|cookie|credentials?|api[-_]?key|otp|mfa|text|value)$/i,R=s((t,e=60)=>{if(!t||typeof t!="object")return"";const n=t;if(Array.isArray(n.commands)){const o=n.commands;return`${o.length} cmds: ${o.map(i=>i.method??"?").join(" \u2192 ")}`.slice(0,e)}const r=Object.entries(n).filter(([,o])=>o!==void 0);if(r.length===0)return"";const l=[];let a=0;for(const[o,i]of r){const u=_.test(o)?"[REDACTED]":g(i,30),c=`${o}=${u}`;if(a+c.length+2>e)break;l.push(c),a+=c.length+2}return l.join(" ")},"summarizeParams"),j=s((t,e)=>{const n=e&&typeof e=="object"?e:{};if(t==="browserless_skill")return{method:"skill",params:{id:n.id}};if(t==="browserless_agent"){const r=n.commands;return Array.isArray(r)&&r.length>0?{method:"commands",params:{commands:r}}:{method:String(n.method??"agent"),params:n.params}}return{method:t??"?",params:e}},"unwrapToolCall"),S=s(t=>{if(!p(t.result))return"";const e=t.result,n=[`Result: ${e.success?f("success"):m("failed")}`];return typeof e.reason_code=="string"&&n.push(` reason_code: ${e.reason_code}`),typeof e.final_url=="string"&&n.push(` final_url: ${e.final_url}`),typeof e.evidence=="string"&&n.push(` evidence: ${e.evidence}`),n.join(`
|
|
6
|
+
`)},"formatEndResult");export{S as formatEndResult,b as hasLoginIntent,k as normalizeRationale,R as summarizeParams,j as unwrapToolCall,A as withCredentials};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var m=Object.defineProperty;var c=(s,u)=>m(s,"name",{value:u,configurable:!0});import d from"node:readline/promises";import{stdin as E,stdout as y}from"node:process";const b=200,p="",T="\x7F",g=c((s,u,e=y,t=E)=>({async line(o){const r=d.createInterface({input:t,output:e,history:s,historySize:b,removeHistoryDuplicates:!0});try{const i=(await r.question(o)).trim();return u(s).catch(()=>{}),i}finally{r.close()}},async linePrivate(o){const r=d.createInterface({input:t,output:e});try{return(await r.question(o)).trim()}finally{r.close()}},password(o){return new Promise((r,i)=>{if(!t.isTTY){i(new Error("Password input requires an interactive terminal (TTY)."));return}e.write(o),t.setRawMode?.(!0),t.resume(),t.setEncoding("utf8");let a="";const f=c(()=>{t.off("data",l),t.setRawMode?.(!1),t.pause()},"cleanup"),l=c(w=>{for(const n of w){if(n==="\r"||n===`
|
|
2
|
+
`){f(),e.write(`
|
|
3
|
+
`),r(a);return}if(n===p){f(),e.write(`
|
|
4
|
+
`),i(new Error("aborted"));return}if(n===T||n==="\b"){a.length>0&&(a=a.slice(0,-1),e.write("\b \b"));continue}a+=n,e.write("*")}},"onData");t.on("data",l)})}}),"buildPrompts");export{g as buildPrompts};
|
package/build/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Command as
|
|
2
|
+
import{Command as s}from"commander";import{version as o}from"./version.js";import{registerProfile as i}from"./commands/profile/index.js";import{registerAuth as t}from"./commands/auth/index.js";import{registerConfig as n}from"./commands/config/index.js";import{registerAgent as m}from"./commands/agent/index.js";import{exitCodeFor as p,UserFacingError as a}from"./errors.js";const e=new s;e.name("browserless").description("Browserless CLI \u2014 manage profiles, sessions, and more.").version(o),i(e),t(e),n(e),m(e),e.parseAsync(process.argv).catch(r=>{r instanceof a?process.stderr.write(`${r.message}
|
|
3
3
|
`):r instanceof Error?process.stderr.write(`${r.stack??r.message}
|
|
4
4
|
`):process.stderr.write(`${String(r)}
|
|
5
|
-
`),process.
|
|
5
|
+
`),process.exitCode=p(r)});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var C=Object.defineProperty;var n=(e,l)=>C(e,"name",{value:l,configurable:!0});import{stdout as g,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 y}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(f=>{o(),l({kind:"end",payload:f})},"onEnd"),s=n(f=>{o(),l({kind:"awaiting_input",payload:f})},"onAwait"),d=n(f=>{o(),l({kind:"error",payload:f})},"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:g,p=y(o),s=new z({out:o}),d=new Map;let a="idle";const f=n(()=>{a==="status"&&(s.clear(),o.write(`
|
|
2
|
+
`))},"ensureTextStart"),h=n(()=>{a==="text"&&o.write(`
|
|
3
|
+
`),a==="status"&&s.clear()},"ensureLineEndedBeforeBlock");e.on("data",t=>{typeof t.text!="string"||t.text.length===0||(f(),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"),m=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(m("",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(m(`${u} `,r.rationale,r.method,r.summary)),a="idle"}),e.on("usage",()=>{}),{printEnd:n(t=>{if(h(),a="idle",l){$({type:"end",result:t.result??null});return}const r=M(t);o.write(r?`
|
|
5
|
+
${r}
|
|
6
|
+
`:`
|
|
7
|
+
`)},"printEnd"),clearStatus:n(()=>{h(),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(y(process.stderr).gray(`
|
|
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:g;d.write(y(d).dim(`agent \u2192 ${s.server} (token from ${s.source})
|
|
10
|
+
`));const a=e.history!==!1&&!l,f=a?await P().catch(()=>[]):[],k=l??_(f,a?u=>B(u):async()=>{},d),m=o.makeClient({server:s.server,token:s.token});await m.connect();const t=G(m,p),r=H(m,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?m.start(c):m.send(c),u=!1;let i=await b(m);for(;i.kind==="awaiting_input";){const w=await k.linePrivate("Enter code: ");if(!w){i={kind:"closed"};break}m.send(w),i=await b(m)}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);continue}t.printEnd(i.payload)}}finally{r(),t.dispose(),m.close()}},"runAgentChat");export{Y as runAgentChat};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=Object.defineProperty;var r=(e,t)=>i(e,"name",{value:t,configurable:!0});import{addClientFlags as n}from"../../cli-utils/client.js";import{runAgentChat as a}from"./chat.js";const c=r(e=>{const t=e.command("agent [prompt]").description("Interactive chat with the Browserless hosted agent. The LLM runs server-side; the browser is driven for you.").option("--no-history","Disable reading + writing ~/.browserless/agent_history").action((o,s)=>a({...s,prompt:o}));n(t)},"registerAgent");export{c as registerAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=Object.defineProperty;var r=(e,o)=>c(e,"name",{value:o,configurable:!0});const s=r(e=>!process.env.NO_COLOR&&!!e.isTTY,"enabled"),n=r(e=>(o,t=process.stdout)=>s(t)?`\x1B[${e}m${o}\x1B[0m`:o,"wrap"),p=n("2"),x=n("31"),d=n("32"),g=n("90"),i=r(e=>({dim:r(o=>p(o,e),"dim"),red:r(o=>x(o,e),"red"),green:r(o=>d(o,e),"green"),gray:r(o=>g(o,e),"gray")}),"colorsFor");export{i as colorsFor,p as dim,g as gray,d as green,x as red};
|
package/build/utils/json-file.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var h=Object.defineProperty;var i=(e,r)=>h(e,"name",{value:r,configurable:!0});import a from"node:fs/promises";import d from"node:path";import{PreconditionError as s}from"../errors.js";const w=448,c=384,$=i(async(e,r)=>{let o;try{o=await a.readFile(e,"utf-8")}catch(t){const m=t?.code;if(m==="ENOENT")return r.defaults;throw new s(`Failed to read ${e} (${m??"unknown error"}): ${t.message}`,r.errorCode)}if(o.trim()==="")return r.defaults;let n;try{n=JSON.parse(o)}catch(t){throw new s(`Failed to parse ${e} \u2014 the file is not valid JSON. Inspect or remove it and retry. (${t.message})`,r.errorCode)}if(!r.validate(n)){const t=r.shapeHint??"the expected JSON shape";throw new s(`${e} does not match ${t}. Inspect and fix the file.`,r.errorCode)}return n},"readJsonFile"),u=i(async(e,r,o={})=>{const n=d.dirname(e);if(await a.mkdir(n,{recursive:!0,mode:w}),await a.chmod(n,w).catch(()=>{}),o.atomic){const t=d.join(n,`.${d.basename(e)}.${process.pid}.tmp`);await a.writeFile(t,r,{mode:c}),await a.rename(t,e),await a.chmod(e,c).catch(()=>{});return}await a.writeFile(e,r,{mode:c}),await a.chmod(e,c).catch(()=>{})},"writeSecureFile"),O=i((e,r,o={})=>u(e,JSON.stringify(r,null,2),o),"writeSecureJsonFile");export{$ as readJsonFile,u as writeSecureFile,O as writeSecureJsonFile};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var h=Object.defineProperty;var s=(i,t)=>h(i,"name",{value:t,configurable:!0});const e=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],o=80,c=100,n=s((i,t)=>i.length<=t?i:`${i.slice(0,Math.max(0,t-1))}\u2026`,"clipToWidth");class l{static{s(this,"Spinner")}out;isTTY;intervalMs;timer=null;idx=0;text="";active=!1;constructor(t={}){this.out=t.out??process.stdout,this.isTTY=t.isTTY??!!this.out.isTTY,this.intervalMs=t.intervalMs??80}isActive(){return this.active}set(t){this.text=t,this.isTTY&&(this.active=!0,this.render(),this.intervalMs>0&&!this.timer&&(this.timer=setInterval(()=>this.render(),this.intervalMs),this.timer.unref?.()))}done(t){if(this.stopTimer(),!this.isTTY){this.out.write(`${t}
|
|
2
|
+
`),this.active=!1;return}this.text=t,this.writeLine(t),this.out.write(`
|
|
3
|
+
`),this.active=!1}clear(){if(this.stopTimer(),!this.isTTY){this.active=!1;return}this.active&&this.out.write("\r\x1B[K"),this.active=!1}render(){const t=e[this.idx%e.length];this.idx+=1,this.writeLine(`${t} ${this.text}`)}writeLine(t){const r=this.maxWidth();this.out.write(`\r\x1B[K${n(t,r)}`)}maxWidth(){const t=this.out.columns;return typeof t=="number"&&t>10?t-1:100}stopTimer(){this.timer&&(clearInterval(this.timer),this.timer=null)}}export{l as Spinner};
|
package/build/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="0.0
|
|
1
|
+
const o="0.1.0";export{o as version};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browserless.io/cli",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.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",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"chrome-remote-interface": "^0.34.0",
|
|
47
|
-
"commander": "^
|
|
47
|
+
"commander": "^15.0.0",
|
|
48
|
+
"ws": "^8.21.0"
|
|
48
49
|
},
|
|
49
50
|
"optionalDependencies": {
|
|
50
51
|
"@napi-rs/keyring": "^1.3.0"
|
|
@@ -56,15 +57,16 @@
|
|
|
56
57
|
"@types/mocha": "^10.0.10",
|
|
57
58
|
"@types/node": "^25.9.1",
|
|
58
59
|
"@types/sinon": "^21.0.1",
|
|
60
|
+
"@types/ws": "^8.18.1",
|
|
59
61
|
"chai": "^6.2.2",
|
|
60
62
|
"esbuild": "^0.28.0",
|
|
61
|
-
"eslint": "^10.4.
|
|
63
|
+
"eslint": "^10.4.1",
|
|
62
64
|
"globals": "^17.6.0",
|
|
63
65
|
"mocha": "^11.7.6",
|
|
64
66
|
"prettier": "^3.8.3",
|
|
65
67
|
"sinon": "^22.0.0",
|
|
66
68
|
"typescript": "^6.0.3",
|
|
67
|
-
"typescript-eslint": "^8.60.
|
|
69
|
+
"typescript-eslint": "^8.60.1"
|
|
68
70
|
},
|
|
69
71
|
"overrides": {
|
|
70
72
|
"mocha": {
|