limixbot 0.3.115 → 0.3.117

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/assets/{ActivityPanel-BKVVoPVs.js → ActivityPanel-BM1b9taQ.js} +1 -1
  2. package/dist/assets/{App-Bs3xsnrc.js → App-BxG-YzD6.js} +105 -105
  3. package/dist/assets/{AppEventEditor-OAf9a0tt.js → AppEventEditor-BoyGgX37.js} +1 -1
  4. package/dist/assets/{BotSettingsDialog-BjXot86a.js → BotSettingsDialog-CH-C6V27.js} +1 -1
  5. package/dist/assets/{BrowserPanel-hL-eDB2c.js → BrowserPanel-BP0rB8gc.js} +1 -1
  6. package/dist/assets/{BrowserProfilesManager-C6T0zWzY.js → BrowserProfilesManager-I_W5CeDw.js} +1 -1
  7. package/dist/assets/{CloudAddDialog-DRM9yXbC.js → CloudAddDialog-BLD7cXUQ.js} +1 -1
  8. package/dist/assets/{ComputerFilesPane-BNu7R0f8.js → ComputerFilesPane-CqvfE5KU.js} +1 -1
  9. package/dist/assets/ComputerPanel-B5iNNZpC.js +2 -0
  10. package/dist/assets/{DataPanel-DfN9iz0h.js → DataPanel-Cir4xsgw.js} +1 -1
  11. package/dist/assets/{GrokMoveDialog-BjiqGVnQ.js → GrokMoveDialog-iMcvTtfo.js} +1 -1
  12. package/dist/assets/{InspectorPanel-DwuollBI.js → InspectorPanel-DC0YSqwR.js} +1 -1
  13. package/dist/assets/{KeyboardShortcutsModal-Cqyls2vU.js → KeyboardShortcutsModal-DKYsQYco.js} +1 -1
  14. package/dist/assets/{LimixResizeHandles-Cdd3ZWsF.js → LimixResizeHandles-BFDsvKba.js} +1 -1
  15. package/dist/assets/{LiveDesktop-BqYFy0dM.js → LiveDesktop-DSEo6MLM.js} +1 -1
  16. package/dist/assets/{LocalVmWorkspace-fc7eYhrx.js → LocalVmWorkspace-DsRYr_Eb.js} +1 -1
  17. package/dist/assets/{MacLocalControl-DZ-mA_P5.js → MacLocalControl-ByD0i8RP.js} +1 -1
  18. package/dist/assets/{MarkdownFilePreview-Db67LyUo.js → MarkdownFilePreview-BH_a4s1t.js} +1 -1
  19. package/dist/assets/{NewBotDialog-1eCNcdXB.js → NewBotDialog-c7Nzc3-x.js} +1 -1
  20. package/dist/assets/{PhoneAppDialog-FAjmm1JH.js → PhoneAppDialog-B2IdWVnS.js} +1 -1
  21. package/dist/assets/{PluginsPanel-Ch6zuNsG.js → PluginsPanel-BZ-W8iYn.js} +1 -1
  22. package/dist/assets/{ProIntroduction-B2GdPHit.js → ProIntroduction-B5HKVQdt.js} +1 -1
  23. package/dist/assets/{RemoteAgentSettingsPanel-LNFAibT2.js → RemoteAgentSettingsPanel-dJ_7wMex.js} +1 -1
  24. package/dist/assets/{RoomPanel-Cx3DTlAR.js → RoomPanel-BBaokkyZ.js} +1 -1
  25. package/dist/assets/{RoutinesPage-Cxwi6eIR.js → RoutinesPage-w5uVzak5.js} +1 -1
  26. package/dist/assets/{SettingsModal-Dyw-u2wY.js → SettingsModal-Bcbqt5op.js} +1 -1
  27. package/dist/assets/{ShareTeamDialog-DCdKihAm.js → ShareTeamDialog-7g01kEx_.js} +1 -1
  28. package/dist/assets/{SignedInSites-DH7N9tUA.js → SignedInSites-CKtIA7Fz.js} +1 -1
  29. package/dist/assets/{TeamLibraryPanel-CbQaWAWx.js → TeamLibraryPanel-CBQF_CrL.js} +1 -1
  30. package/dist/assets/{TeamMapPage-DoYg4ueL.js → TeamMapPage-oifQ8xlb.js} +1 -1
  31. package/dist/assets/{TriggersPage-CtDhsC18.js → TriggersPage-CWbksDpA.js} +1 -1
  32. package/dist/assets/{VisibilitySection-DmAqf_a9.js → VisibilitySection-BrQ-tl1G.js} +1 -1
  33. package/dist/assets/{WebhookTrigger-DIkM9UMJ.js → WebhookTrigger-rDG0ZT50.js} +1 -1
  34. package/dist/assets/{WorksOnGrid-BXPjyVfb.js → WorksOnGrid-Dip4b6IG.js} +1 -1
  35. package/dist/assets/{core-CLmWJmRN.js → core-DUEVpZGk.js} +1 -1
  36. package/dist/assets/{import-name-CuQ-o1MN.js → import-name-D5PQDvuG.js} +1 -1
  37. package/dist/assets/{index-B4GUPRYB.js → index-CNH8nghe.js} +1 -1
  38. package/dist/assets/{index-CLQ_hYWY.js → index-DwVpO-c7.js} +2 -2
  39. package/dist/assets/{mcp-servers-CE2IPhL7.js → mcp-servers-lsLwqttP.js} +1 -1
  40. package/dist/assets/{new-bot-biSOJm6z.js → new-bot-D4mBnK0R.js} +1 -1
  41. package/dist/assets/{org-library-4LsB5uzZ.js → org-library-6Gajkwod.js} +1 -1
  42. package/dist/assets/{package-format-CBEJWXeV.js → package-format-EFYnU7b8.js} +1 -1
  43. package/dist/assets/{remote-desktop-panel-BUZzS8Qz.js → remote-desktop-panel-DtPdf9sc.js} +1 -1
  44. package/dist/index.html +1 -1
  45. package/dist-server/index.js +54 -50
  46. package/dist-server/limixbot.js +17 -16
  47. package/dist-server/package.json +1 -1
  48. package/dist-server/pair-cli.js +17 -16
  49. package/dist-server/server/browser/chrome/launcher.js +23 -6
  50. package/dist-server/server/chief-of-staff.js +1 -1
  51. package/dist-server/server/host/browser.js +8 -3
  52. package/dist-server/server/workspace-backup-policy.js +18 -1
  53. package/dist-server/server/workspace-backup.js +6 -4
  54. package/dist-server/workspace-backup.worker.js +29 -29
  55. package/package.json +1 -1
  56. package/dist/assets/ComputerPanel-DxKmRVYu.js +0 -2
@@ -24368,17 +24368,18 @@ late name it comes from (or that it is custom), why it fits, what it is responsi
24368
24368
  e fix, and use propose_team_setup for any bot change; never ask them to send you a token or password.",sectionKey3=section4=>section4?.trim()||"",EVERYONE_ON_THE_MAP="When the person writes to @everyone on the Team map, it comes to you alone, so you decide who it concerns: hand it with coordinate_bots to the teammates whose work it touches, never to all of them by default, and do the part that is yours. If it concerns nobody else, answer it yourself.";function chiefOfStaffSystemPrompt(chiefId,bots,canDelegate,also){
24369
24369
  let chief=bots.find(bot=>bot.id===chiefId),chiefSection=sectionKey3(chief?.section),sectionName=peerName(chiefSection)||"General",owner2=chief?botOwner(chief):null,person2=owner2?peerName(nameFromEmail(owner2))||"your person":null,reachable=reachablePeers(bots,chief??{id:chiefId,name:""},also),team=chief?reachable.filter(bot=>hasAuthority(chief,bot)):reachable,others=chief?reachable.filter(bot=>!hasAuthority(chief,bot)):[],roster=renderRoster(team,{max:ROSTER_MAX_BOTS,empty:"- No other visible b\
24370
24370
  ots are available yet.",about:!0,department:chiefSection}),othersRoster=others.length?renderRoster(others,{max:Math.max(ROSTER_MAX_BOTS-team.length,OTHERS_MIN_BOTS),empty:"",about:!1,department:chiefSection}):"",delegation=canDelegate?"Use list_bots or list_room_targets for the live reachable roster. Use coordinate_bots to assign actual teammates concrete work, or with consult: true to ask them for advice. It returns immediately and keeps you available to the user; give clear, self-contained bri\
24371
- efs, then end your turn \u2014 you resume automatically when their results return, success or failure. Say that work is assigned, not completed; only claim completion after the teammate's result has actually arrived, and if a teammate fails or stalls, tell the user plainly and decide the next step yourself. Leads can coordinate their own specialists. Do not poll or wait, send acknowledgements as new work, or substitute native helpers for named bots. On return, verify the requested outcome, resolve de\
24372
- cisions within the user's scope, request concrete corrections with rework=true when necessary, and return one consolidated answer. Consultations are advice, not proof that work or tests ran. A refusal from coordinate_bots means nothing was sent: fix what it names (usually the id \u2014 copy it from list_bots or your roster; a unique teammate name also works) and retry, and never describe a handoff the tool did not accept.":"Your current engine cannot contact teammates. Be honest about that limit\
24373
- ation and ask the user to choose a delegation-compatible engine before promising coordinated work.",isChief=!chief?.defaultBot||chief.chiefOfStaff===!0;return[isChief?person2?`You are ${person2}'s assistant and Chief of Staff: their one point of contact. The bots that report to ${person2}, in every department, are your team: you direct their work, and their incidents come to you.`:`You are the person's assistant and the Chief of Staff for the ${sectionName} department: their one point of contact\
24374
- .`:chief?.defaultBot?.person?`You hold a Chief of Staff's tools for the ${sectionName} department, but you are not the Chief: the daily brief and team incidents stay with the Chief.`:`You hold a Chief of Staff's tools for the ${sectionName} department, but you are not the Chief: team incidents stay with the Chief. Keeping an eye on the person's day and their daily brief are yours.`,chief?.managedSections?.length?`The owner also made you responsible for these departments: ${chief.managedSections.
24375
- map(s4=>peerName(s4)||"General").join(", ")}. You supervise their bots and may propose setup changes there. You remain the user's single point of contact. This does not grant other bots your access, change their tool permissions, or expose unrelated conversation history.`:"",canDelegate&&"Every other bot on this team, in any department, is reachable too: consult it or hand it work with coordinate_bots whenever a job needs it, without asking anyone to set anything up. Reaching a bot gives you no \
24376
- authority over it: its setup, its threads and its incidents stay with its own Chief, so ask rather than direct.","Do the work yourself, bring in a teammate when one fits the job, and return one concise consolidated answer. Never invent a teammate's progress or result. Normal permission and approval rules still apply.",canDelegate&&"A standing preference the person states for all their bots (where reminders go, how replies should sound) is one line you save yourself with memory_update action pref\
24377
- er: every bot reads it. Never send it to each bot with coordinate_bots.",canDelegate?SPECIALISTS:"",canDelegate&&isChief?EVERYONE_ON_THE_MAP:"",canDelegate&&isChief?`Incidents: when a teammate's run fails, stalls or cannot start, Limix Bot reports it to you in your "Problems to look at" thread with a link to the thread. Read the report, then either call retry_thread to resume that thread where it stopped, coordinate_bots with a corrected brief when the request itself must change, or \u2014 when only \
24378
- the person can fix the cause (a sign-in, a missing credential, an unanswered question, a setting) \u2014 say so plainly and stop. Never retry the same thread more than twice; report what failed and what you did in one or two sentences.`:"",delegation,canDelegate?'Housekeeping: list_threads also shows threads one teammate opened on another (marked "opened by"), and you may close_thread those once they are idle and their work is done. Threads the person started are theirs: never close them.':"",canDelegate?
24379
- "When the user asks you to assemble or configure a team, use list_team_setup for the exact authorized teams, bot IDs and model catalog, then propose_team_setup once with all named specialists and their profile/model changes. Include new teams explicitly; the plan covers their creation and your access. Existing thread models and other bots' execution permissions stay unchanged. Every plan waits for the person's decision on a card: end your turn after proposing; the decision automatically resumes \
24380
- you once with a structured result, including the group chat if they chose one. Report failed or cancelled results honestly. Do not ask for another yes, poll, or repeat the proposal. After successful setup, use the available coordination tools for already requested work. For explicitly requested bot deletion, use propose_bot_deletion separately and follow its applied or pending result too.":"",person2?`Bots that report to ${person2} (your team):`:chief?.managedSections?.length?"Your team, in the \
24381
- departments you are responsible for:":`Current ${sectionName} department (your team):`,roster,othersRoster&&(person2?"Other bots you can reach (they report to someone else):":"Other bots you can reach, in other departments:"),othersRoster].filter(Boolean).join(`
24371
+ efs, then end your turn \u2014 you resume automatically when their results return, success or failure. Say that work is assigned, not completed; only claim completion after the teammate's result has actually arrived, and if a teammate fails or stalls, tell the user plainly and decide the next step yourself. Leads can coordinate their own specialists. For a multi-part deliverable, give each work item one accountable owner. Send independent items in parallel with separate calls. Sequence dependent work\
24372
+ after its prerequisite result. In each brief include the relevant inputs, the output to return and a verifiable done_when. Assign overlapping edits sequentially. If independent review is needed, give a different teammate the actual artifact and acceptance criteria. Reconcile their findings and surface any unresolved blocker before handoff. Do not poll or wait, send acknowledgements as new work, or substitute native helpers for named bots. On return, verify the requested outcome, resolve decisio\
24373
+ ns within the user's scope, request concrete corrections with rework=true when necessary, and return one consolidated answer. Consultations are advice, not proof that work or tests ran. A refusal from coordinate_bots means nothing was sent: fix what it names (usually the id \u2014 copy it from list_bots or your roster; a unique teammate name also works) and retry, and never describe a handoff the tool did not accept.":"Your current engine cannot contact teammates. Be honest about that limitation\
24374
+ and ask the user to choose a delegation-compatible engine before promising coordinated work.",isChief=!chief?.defaultBot||chief.chiefOfStaff===!0;return[isChief?person2?`You are ${person2}'s assistant and Chief of Staff: their one point of contact. The bots that report to ${person2}, in every department, are your team: you direct their work, and their incidents come to you.`:`You are the person's assistant and the Chief of Staff for the ${sectionName} department: their one point of contact.`:chief?.
24375
+ defaultBot?.person?`You hold a Chief of Staff's tools for the ${sectionName} department, but you are not the Chief: the daily brief and team incidents stay with the Chief.`:`You hold a Chief of Staff's tools for the ${sectionName} department, but you are not the Chief: team incidents stay with the Chief. Keeping an eye on the person's day and their daily brief are yours.`,chief?.managedSections?.length?`The owner also made you responsible for these departments: ${chief.managedSections.map(s4=>peerName(
24376
+ s4)||"General").join(", ")}. You supervise their bots and may propose setup changes there. You remain the user's single point of contact. This does not grant other bots your access, change their tool permissions, or expose unrelated conversation history.`:"",canDelegate&&"Every other bot on this team, in any department, is reachable too: consult it or hand it work with coordinate_bots whenever a job needs it, without asking anyone to set anything up. Reaching a bot gives you no authority over it\
24377
+ : its setup, its threads and its incidents stay with its own Chief, so ask rather than direct.","Do the work yourself, bring in a teammate when one fits the job, and return one concise consolidated answer. Never invent a teammate's progress or result. Normal permission and approval rules still apply.",canDelegate&&"A standing preference the person states for all their bots (where reminders go, how replies should sound) is one line you save yourself with memory_update action prefer: every bot rea\
24378
+ ds it. Never send it to each bot with coordinate_bots.",canDelegate?SPECIALISTS:"",canDelegate&&isChief?EVERYONE_ON_THE_MAP:"",canDelegate&&isChief?`Incidents: when a teammate's run fails, stalls or cannot start, Limix Bot reports it to you in your "Problems to look at" thread with a link to the thread. Read the report, then either call retry_thread to resume that thread where it stopped, coordinate_bots with a corrected brief when the request itself must change, or \u2014 when only the person can fi\
24379
+ x the cause (a sign-in, a missing credential, an unanswered question, a setting) \u2014 say so plainly and stop. Never retry the same thread more than twice; report what failed and what you did in one or two sentences.`:"",delegation,canDelegate?'Housekeeping: list_threads also shows threads one teammate opened on another (marked "opened by"), and you may close_thread those once they are idle and their work is done. Threads the person started are theirs: never close them.':"",canDelegate?"When t\
24380
+ he user asks you to assemble or configure a team, use list_team_setup for the exact authorized teams, bot IDs and model catalog, then propose_team_setup once with all named specialists and their profile/model changes. Include new teams explicitly; the plan covers their creation and your access. Existing thread models and other bots' execution permissions stay unchanged. Every plan waits for the person's decision on a card: end your turn after proposing; the decision automatically resumes you onc\
24381
+ e with a structured result, including the group chat if they chose one. Report failed or cancelled results honestly. Do not ask for another yes, poll, or repeat the proposal. After successful setup, use the available coordination tools for already requested work. For explicitly requested bot deletion, use propose_bot_deletion separately and follow its applied or pending result too.":"",person2?`Bots that report to ${person2} (your team):`:chief?.managedSections?.length?"Your team, in the departm\
24382
+ ents you are responsible for:":`Current ${sectionName} department (your team):`,roster,othersRoster&&(person2?"Other bots you can reach (they report to someone else):":"Other bots you can reach, in other departments:"),othersRoster].filter(Boolean).join(`
24382
24383
  `)}var tooLongRefusal=(field5,max4,how)=>`${field5} is over its ${String(max4)}-character limit, so nothing was done. ${how}`,COORDINATE_FIELDS={message:"Send only what the teammate needs to start, and save the long detail to a file in this folder and name its path, then call coordinate_bots again.",done_when:"Say in a sentence or two what finished looks like, then call coordinate_bots again.",title:"Use a shorter title, then call coordinate_bots again.",reason:"Say why in one short line, then call\
24383
24384
  coordinate_bots again."};function coordinateTooLong(issues){let refusals=issues.map(issue3=>{let field5=String(issue3.path[0]),how=COORDINATE_FIELDS[field5];return issue3.code==="too_big"&&how&&issue3.maximum!==void 0?tooLongRefusal(field5,issue3.maximum,how):void 0});return refusals.length&&refusals.every(Boolean)?refusals.join(" "):void 0}init_bot_owner();var ledBy=(room,botId2)=>{let lead=room.defaultResponder;return lead.kind==="member"?lead.botId===botId2:lead.kind==="auto"&&lead.fallbackBotId===botId2};function chiefAbsentFrom(room,bots){if(room.dm)return;let scope=chiefScope({section:room.section}),chief=bots.find(bot=>bot.chiefOfStaff&&!bot.hidden&&chiefScope(bot)===scope);return chief&&!room.memberIds.includes(chief.id)?{botId:chief.id,name:chief.name}:void 0}function createChiefRooms(deps){let{store:store5}=deps;function retarget(room,from,to2){
24384
24385
  let lead=room.defaultResponder.kind==="auto"?{kind:"auto",fallbackBotId:to2.id}:{kind:"member",botId:to2.id};try{let updated=deps.updateRoom(room.id,{memberIds:[...new Set([...room.memberIds,to2.id])],defaultResponder:lead});return store5.appendMessage(room.threadId,{role:"bot",kind:"activity",tool:{name:`notice: ${serverLine(conversationLanguage(room.threadId),"server.rooms.chiefRetargeted",{chief:to2.name,former:from.name})}`,ok:!0}}),updated}catch(error66){return console.warn(`chief rooms: ${room.
@@ -28791,23 +28792,25 @@ match5[1]),height:Number(match5[2])}:null},named4=parse18(env.OMB_BROWSER_SCREEN
28791
28792
  `
28792
28793
  `).filter(line6=>/ connected /u.test(line6));return parse18(lines.find(line6=>/ primary /u.test(line6))??lines[0]??"")??SERVER_SCREEN2}}catch{}return SERVER_SCREEN2}function browserLanguage(env){let named4=env.OMB_BROWSER_LANG?.trim();if(named4)return/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u.test(named4)?named4:void 0;let locale4=env.LC_ALL?.trim()||env.LC_MESSAGES?.trim()||env.LANG?.trim()||"",match5=/^([a-z]{2,3})(?:_([A-Z]{2}))?(?:[.@]|$)/u.exec(locale4);return match5?match5[2]?`${match5[1]}-${match5[2]}`:
28793
28794
  match5[1]:void 0}function languageList(language){let first2=language??"en-US",base2=first2.split("-")[0];return[first2,...base2!==first2?[base2]:[],...base2==="en"?[]:["en-US","en"]].join(",")}function browserTimeZone(env,platform2){let zone=env.OMB_BROWSER_TIMEZONE?.trim()||(platform2==="win32"?"":env.TZ?.trim()||"");return/^:?[A-Za-z0-9_+\-./]{1,64}$/u.test(zone)?zone:void 0}var SOURCES={installed:"installed",downloaded:"downloaded",named:"named by OMB_CHROME_PATH or AGENT_BROWSER_EXECUTABLE_PATH","agent-browser":"installed by agent-browser"},megabytes2=bytes4=>Math.round(bytes4/1048576),message6=error66=>error66 instanceof Error?error66.message:String(error66);function runsLauncher(path8,env,timeoutMs2=1e4){return new Promise((resolve59,reject)=>{execFile21(path8,["--version"],{env,timeout:timeoutMs2,windowsHide:!0},error66=>{if(!error66||error66.killed)return resolve59();reject(new Error(`the browser launcher does not run here: ${error66.message}`))})})}var ChromeLauncher=class{path;state={kind:"idle"};preparing=null;screen=null;options;host;sidecars;box=null;constructor(options2){let env=options2.env??process.env,platform2=options2.platform??process.
28794
- platform;this.options={...options2,env,platform:platform2,readyWaitMs:options2.readyWaitMs??45e3},this.host=options2.host??chromeHost({dataDir:options2.dataDir,env,platform:platform2,arch:options2.arch}),this.sidecars=options2.sidecars??new IdentitySidecars,this.path=launcherPath(options2.dataDir,platform2)}boxWith(box2){if(this.box=box2,this.state.kind==="ready"&&this.state.launcher){let launcher={...this.state.launcher,...this.boxed()};writeLauncher(this.path,launcher,this.options.platform),this.
28795
- state={...this.state,launcher}}}boxed(){let box2=this.box?.()??null;return box2?{box:box2}:{}}plan(){let downloading=this.state.kind==="preparing"||this.state.kind==="downloading";return resolveChromePlan(this.host,this.options.engine?this.options.engine():this.managedEngine(),{downloading})}env(){return this.state.kind==="failed"||this.plan().kind==="legacy"?{}:(this.prepare(),this.followTimeZone(),{AGENT_BROWSER_EXECUTABLE_PATH:this.path,AGENT_BROWSER_HIDE_SCROLLBARS:"0"})}followTimeZone(){let state=this.
28796
- state;if(state.kind!=="ready"||!state.launcher)return;let timeZone=browserTimeZone(this.options.env,this.options.platform);if(timeZone===state.launcher.timeZone)return;let launcher={...state.launcher,timeZone};try{writeLauncher(this.path,launcher,this.options.platform),this.state={...state,launcher},this.log(`browser: the next browser started tells time in ${timeZone??"the system's zone"}`)}catch(error66){this.log(`browser: could not move the browser to ${timeZone??"the system's zone"} (${message6(
28797
- error66)})`)}}start(){this.plan().kind!=="legacy"&&this.prepare()}prepare(){if(this.preparing)return this.preparing;if(this.state.kind==="failed"||this.state.kind==="ready"&&this.fresh(this.state))return Promise.resolve();let plan=this.plan();if(plan.kind==="legacy")return Promise.resolve();let previous2=this.state.kind==="ready"?this.state:null;return previous2||(this.state={kind:"preparing"}),this.preparing=this.prepareFor(plan).then(ready=>{this.state=ready,this.log(`browser: ${this.describe()}`)},
28798
- error66=>{this.state=previous2?{...previous2,fingerprint:this.fingerprintOr(previous2)}:{kind:"failed",reason:message6(error66)},this.log(`browser: Chrome could not be prepared (${message6(error66)}); ${previous2?"keeping the browser already set up":"bots keep the engine's own browser"}`)}).finally(()=>{this.preparing=null}),this.preparing}async ready(spec){if(!this.uses(spec))return;let timer4,done=await Promise.race([this.prepare().then(()=>!0),new Promise(resolve59=>{timer4=setTimeout(()=>resolve59(
28799
- !1),this.options.readyWaitMs),timer4.unref?.()})]);if(clearTimeout(timer4),!done){let state=this.state;throw new Error(state.kind==="downloading"?`Getting the browser ready (${megabytes2(state.progress.received)} of ${megabytes2(state.progress.total)} MB). Try again in a minute.`:"Getting the browser ready. Try again in a moment.")}if(this.state.kind==="failed")throw new Error(`Chrome could not be started (${this.state.reason}). Try again: your next browser call uses the built-in browser.`)}async started(session,spec){
28800
- this.state.kind!=="ready"||!this.uses(spec)||!ownsBrowserViewport(spec.env??{})||await this.sidecars.ensure(session,spec,{...this.state.identity,acceptLanguage:languageList(browserLanguage(this.options.env))})}stopped(session){this.sidecars.forget(session)}describe(){let state=this.state;if(state.kind==="ready")return`${product(state.chrome,state.identity)} ${state.identity.userAgentMetadata.fullVersion.split(".")[0]} (${SOURCES[state.chrome.source]})`;let plan=this.plan();return plan.kind==="le\
28801
- gacy"?`${this.engineBrowser()} (${plan.reason})`:state.kind==="failed"?`${this.engineBrowser()} (Chrome could not be started: ${state.reason})`:state.kind==="downloading"?`Chrome for Testing ${state.pin.version} (downloading: ${megabytes2(state.progress.received)} of ${megabytes2(state.progress.total)} MB)`:plan.kind==="download"?`Chrome for Testing ${plan.pin.version} (not downloaded yet)`:`${product(plan.chrome)} (${SOURCES[plan.chrome.source]}; not started yet)`}chromeEnv(){return this.options.
28802
- platform==="darwin"?{...this.options.env,HOME:userInfo3().homedir}:this.options.env}uses(spec){return spec.env?.AGENT_BROWSER_EXECUTABLE_PATH===this.path&&!attachesToChrome(spec.env)}fresh(state){try{return chromeFingerprint(state.chrome.path)===state.fingerprint}catch{return!1}}fingerprintOr(state){try{return chromeFingerprint(state.chrome.path)}catch{return state.fingerprint}}async prepareFor(plan){let chrome=plan.kind==="download"?await this.download(plan.pin):plan.chrome,identity9;try{identity9=
28803
- await this.identityOf(chrome)}catch(error66){if(plan.kind!=="chrome"||plan.chrome.source!=="installed"||!plan.fallback)throw error66;this.log(`browser: Google Chrome at ${chrome.path} could not start headless (${message6(error66)}); using Chrome for Testing`),chrome=await this.download(plan.fallback),identity9=await this.identityOf(chrome)}let{env,platform:platform2}=this.options,launcher;return this.options.wrapper!==!1&&(this.screen??=this.options.screen?this.options.screen():primaryScreen(platform2,
28804
- env),launcher={chrome:chrome.path,userAgent:identity9.userAgent,screen:await this.screen,language:browserLanguage(env),timeZone:browserTimeZone(env,platform2),...platform2==="darwin"?{home:userInfo3().homedir}:{},...this.boxed()},writeLauncher(this.path,launcher,platform2),platform2!=="win32"&&await(this.options.checkLauncher??runsLauncher)(this.path,this.chromeEnv())),{kind:"ready",chrome,identity:{userAgent:identity9.userAgent,userAgentMetadata:identity9.userAgentMetadata},product:identity9.product,
28805
- fingerprint:chromeFingerprint(chrome.path),...launcher?{launcher}:{}}}async download(pin){return this.state={kind:"downloading",pin,progress:{received:0,total:pin.bytes}},{path:await(this.options.install??installChromeForTesting)({dataDir:this.options.dataDir,pin,onProgress:progress=>{this.state.kind==="downloading"&&(this.state={...this.state,progress})}}),source:"downloaded"}}async identityOf(chrome){let env=this.chromeEnv(),injected=this.options.calibrate,calibrate=injected?async options3=>{let read4=await injected(
28806
- options3.executablePath,env);return{...read4,product:`Chrome/${read4.userAgentMetadata.fullVersion}`,fingerprint:chromeFingerprint(options3.executablePath),calibratedAt:new Date().toISOString()}}:calibrateIdentity,host3=this.options.platform==="linux"&&existsSync87("/.dockerenv")?"container":"desktop",options2={executablePath:chrome.path,host:host3,env,sandbox:this.options.sandbox??!needsNoSandbox(env)};return(await loadOrCalibrateIdentity(this.options.dataDir,options2,calibrate)).identity}async binary(){
28807
- let plan=this.plan();if(plan.kind==="legacy")throw new Error(`no Chrome to run here (${plan.reason})`);let timer4,done=await Promise.race([this.prepare().then(()=>!0),new Promise(resolve59=>{timer4=setTimeout(()=>resolve59(!1),this.options.readyWaitMs),timer4.unref?.()})]);clearTimeout(timer4);let state=this.state;if(!done)throw new Error(state.kind==="downloading"?`Getting the browser ready (${megabytes2(state.progress.received)} of ${megabytes2(state.progress.total)} MB). Try again in a minute\
28808
- .`:"Getting the browser ready. Try again in a moment.");if(state.kind==="failed")throw new Error(`Chrome could not be started (${state.reason}).`);if(state.kind!=="ready")throw new Error("Chrome is not ready yet. Try again in a moment.");return{path:state.chrome.path,identity:state.identity,product:state.product,source:state.chrome.source}}managedEngine(){let status5=browserEngineStatus({dataDir:this.options.dataDir,env:this.options.env,platform:this.options.platform,arch:this.options.arch});return status5.
28809
- kind==="ready"?{managed:status5.managed}:null}engineBrowser(){let named4=this.options.env.AGENT_BROWSER_EXECUTABLE_PATH?.trim();return named4||(this.options.env.OMB_RESOURCES_PATH?"the bundled Chromium headless shell":"agent-browser's own browser")}log(line6){(this.options.log??console.log)(line6)}};function product(chrome,identity9){return identity9?.userAgentMetadata.brands.some(({brand})=>brand==="Google Chrome")||chrome.source==="installed"?"Google Chrome":chrome.source==="downloaded"||/for Testing|chrome-(?:linux|mac|win)/iu.
28810
- test(chrome.path)?"Chrome for Testing":"Chromium"}var chromeLauncher=new ChromeLauncher({dataDir:DATA_DIR,host:chromeHost({dataDir:DATA_DIR,enginePath:augmentedPath})});init_bot_thread_limits();var NETWORK_CODES=new Set(["ECONNREFUSED","ECONNRESET","ETIMEDOUT","ENOTFOUND","EAI_AGAIN","EPIPE","UND_ERR_SOCKET","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT"]);function transientClaimFailure(error66){for(let current3=error66,depth2=0;current3&&typeof current3=="object"&&depth2<4;current3=current3.cause,depth2++){let failure12=current3;if(failure12.transient===!0||failure12.name==="TimeoutError"||typeof failure12.code=="string"&&NETWORK_CODES.has(failure12.code))return!0}return!1}function keepTransient(original,shown3){
28795
+ platform;this.options={...options2,env,platform:platform2,readyWaitMs:options2.readyWaitMs??45e3},this.host=options2.host??chromeHost({dataDir:options2.dataDir,env,platform:platform2,arch:options2.arch}),this.sidecars=options2.sidecars??new IdentitySidecars,this.path=launcherPath(options2.dataDir,platform2)}boxWith(box2){if(this.box=box2,this.state.kind==="ready"&&this.state.launcher){let launcher={...this.state.launcher,...this.boxed()};this.options.platform!=="win32"&&writeLauncher(this.path,launcher,
28796
+ this.options.platform),this.state={...this.state,launcher}}}boxed(){let box2=this.box?.()??null;return box2?{box:box2}:{}}plan(){let downloading=this.state.kind==="preparing"||this.state.kind==="downloading";return resolveChromePlan(this.host,this.options.engine?this.options.engine():this.managedEngine(),{downloading})}env(){if(this.state.kind==="failed"||this.plan().kind==="legacy")return{};if(this.prepare(),this.options.platform==="win32"){let settings=this.state.kind==="ready"&&this.state.launcher;
28797
+ return settings?{AGENT_BROWSER_EXECUTABLE_PATH:settings.chrome,AGENT_BROWSER_USER_AGENT:settings.userAgent,AGENT_BROWSER_ARGS:launcherFlags(settings,"win32").filter(flag4=>!flag4.startsWith("--user-agent=")).join(`
28798
+ `),AGENT_BROWSER_HIDE_SCROLLBARS:"0"}:{}}return this.followTimeZone(),{AGENT_BROWSER_EXECUTABLE_PATH:this.path,AGENT_BROWSER_HIDE_SCROLLBARS:"0"}}followTimeZone(){let state=this.state;if(state.kind!=="ready"||!state.launcher)return;let timeZone=browserTimeZone(this.options.env,this.options.platform);if(timeZone===state.launcher.timeZone)return;let launcher={...state.launcher,timeZone};try{this.options.platform!=="win32"&&writeLauncher(this.path,launcher,this.options.platform),this.state={...state,
28799
+ launcher},this.log(`browser: the next browser started tells time in ${timeZone??"the system's zone"}`)}catch(error66){this.log(`browser: could not move the browser to ${timeZone??"the system's zone"} (${message6(error66)})`)}}start(){this.plan().kind!=="legacy"&&this.prepare()}prepare(){if(this.preparing)return this.preparing;if(this.state.kind==="failed"||this.state.kind==="ready"&&this.fresh(this.state))return Promise.resolve();let plan=this.plan();if(plan.kind==="legacy")return Promise.resolve();
28800
+ let previous2=this.state.kind==="ready"?this.state:null;return previous2||(this.state={kind:"preparing"}),this.preparing=this.prepareFor(plan).then(ready=>{this.state=ready,this.log(`browser: ${this.describe()}`)},error66=>{this.state=previous2?{...previous2,fingerprint:this.fingerprintOr(previous2)}:{kind:"failed",reason:message6(error66)},this.log(`browser: Chrome could not be prepared (${message6(error66)}); ${previous2?"keeping the browser already set up":"bots keep the engine's own browser"}`)}).
28801
+ finally(()=>{this.preparing=null}),this.preparing}async ready(spec){if(!this.uses(spec))return;let timer4,done=await Promise.race([this.prepare().then(()=>!0),new Promise(resolve59=>{timer4=setTimeout(()=>resolve59(!1),this.options.readyWaitMs),timer4.unref?.()})]);if(clearTimeout(timer4),!done){let state=this.state;throw new Error(state.kind==="downloading"?`Getting the browser ready (${megabytes2(state.progress.received)} of ${megabytes2(state.progress.total)} MB). Try again in a minute.`:"Get\
28802
+ ting the browser ready. Try again in a moment.")}if(this.state.kind==="failed")throw new Error(`Chrome could not be started (${this.state.reason}). Try again: your next browser call uses the built-in browser.`)}async started(session,spec){this.state.kind!=="ready"||!this.uses(spec)||!ownsBrowserViewport(spec.env??{})||await this.sidecars.ensure(session,spec,{...this.state.identity,acceptLanguage:languageList(browserLanguage(this.options.env))})}stopped(session){this.sidecars.forget(session)}describe(){
28803
+ let state=this.state;if(state.kind==="ready")return`${product(state.chrome,state.identity)} ${state.identity.userAgentMetadata.fullVersion.split(".")[0]} (${SOURCES[state.chrome.source]})`;let plan=this.plan();return plan.kind==="legacy"?`${this.engineBrowser()} (${plan.reason})`:state.kind==="failed"?`${this.engineBrowser()} (Chrome could not be started: ${state.reason})`:state.kind==="downloading"?`Chrome for Testing ${state.pin.version} (downloading: ${megabytes2(state.progress.received)} of ${megabytes2(
28804
+ state.progress.total)} MB)`:plan.kind==="download"?`Chrome for Testing ${plan.pin.version} (not downloaded yet)`:`${product(plan.chrome)} (${SOURCES[plan.chrome.source]}; not started yet)`}chromeEnv(){return this.options.platform==="darwin"?{...this.options.env,HOME:userInfo3().homedir}:this.options.env}uses(spec){if(!spec.env||attachesToChrome(spec.env))return!1;let executable=spec.env.AGENT_BROWSER_EXECUTABLE_PATH;return executable===this.path||this.options.platform==="win32"&&this.state.kind===
28805
+ "ready"&&executable===this.state.chrome.path}fresh(state){try{return chromeFingerprint(state.chrome.path)===state.fingerprint}catch{return!1}}fingerprintOr(state){try{return chromeFingerprint(state.chrome.path)}catch{return state.fingerprint}}async prepareFor(plan){let chrome=plan.kind==="download"?await this.download(plan.pin):plan.chrome,identity9;try{identity9=await this.identityOf(chrome)}catch(error66){if(plan.kind!=="chrome"||plan.chrome.source!=="installed"||!plan.fallback)throw error66;this.
28806
+ log(`browser: Google Chrome at ${chrome.path} could not start headless (${message6(error66)}); using Chrome for Testing`),chrome=await this.download(plan.fallback),identity9=await this.identityOf(chrome)}let{env,platform:platform2}=this.options,launcher;return this.options.wrapper!==!1&&(this.screen??=this.options.screen?this.options.screen():primaryScreen(platform2,env),launcher={chrome:chrome.path,userAgent:identity9.userAgent,screen:await this.screen,language:browserLanguage(env),timeZone:browserTimeZone(
28807
+ env,platform2),...platform2==="darwin"?{home:userInfo3().homedir}:{},...this.boxed()},platform2!=="win32"&&(writeLauncher(this.path,launcher,platform2),await(this.options.checkLauncher??runsLauncher)(this.path,this.chromeEnv()))),{kind:"ready",chrome,identity:{userAgent:identity9.userAgent,userAgentMetadata:identity9.userAgentMetadata},product:identity9.product,fingerprint:chromeFingerprint(chrome.path),...launcher?{launcher}:{}}}async download(pin){return this.state={kind:"downloading",pin,progress:{
28808
+ received:0,total:pin.bytes}},{path:await(this.options.install??installChromeForTesting)({dataDir:this.options.dataDir,pin,onProgress:progress=>{this.state.kind==="downloading"&&(this.state={...this.state,progress})}}),source:"downloaded"}}async identityOf(chrome){let env=this.chromeEnv(),injected=this.options.calibrate,calibrate=injected?async options3=>{let read4=await injected(options3.executablePath,env);return{...read4,product:`Chrome/${read4.userAgentMetadata.fullVersion}`,fingerprint:chromeFingerprint(
28809
+ options3.executablePath),calibratedAt:new Date().toISOString()}}:calibrateIdentity,host3=this.options.platform==="linux"&&existsSync87("/.dockerenv")?"container":"desktop",options2={executablePath:chrome.path,host:host3,env,sandbox:this.options.sandbox??!needsNoSandbox(env)};return(await loadOrCalibrateIdentity(this.options.dataDir,options2,calibrate)).identity}async binary(){let plan=this.plan();if(plan.kind==="legacy")throw new Error(`no Chrome to run here (${plan.reason})`);let timer4,done=await Promise.
28810
+ race([this.prepare().then(()=>!0),new Promise(resolve59=>{timer4=setTimeout(()=>resolve59(!1),this.options.readyWaitMs),timer4.unref?.()})]);clearTimeout(timer4);let state=this.state;if(!done)throw new Error(state.kind==="downloading"?`Getting the browser ready (${megabytes2(state.progress.received)} of ${megabytes2(state.progress.total)} MB). Try again in a minute.`:"Getting the browser ready. Try again in a moment.");if(state.kind==="failed")throw new Error(`Chrome could not be started (${state.
28811
+ reason}).`);if(state.kind!=="ready")throw new Error("Chrome is not ready yet. Try again in a moment.");return{path:state.chrome.path,identity:state.identity,product:state.product,source:state.chrome.source}}managedEngine(){let status5=browserEngineStatus({dataDir:this.options.dataDir,env:this.options.env,platform:this.options.platform,arch:this.options.arch});return status5.kind==="ready"?{managed:status5.managed}:null}engineBrowser(){let named4=this.options.env.AGENT_BROWSER_EXECUTABLE_PATH?.trim();
28812
+ return named4||(this.options.env.OMB_RESOURCES_PATH?"the bundled Chromium headless shell":"agent-browser's own browser")}log(line6){(this.options.log??console.log)(line6)}};function product(chrome,identity9){return identity9?.userAgentMetadata.brands.some(({brand})=>brand==="Google Chrome")||chrome.source==="installed"?"Google Chrome":chrome.source==="downloaded"||/for Testing|chrome-(?:linux|mac|win)/iu.test(chrome.path)?"Chrome for Testing":"Chromium"}var chromeLauncher=new ChromeLauncher({dataDir:DATA_DIR,
28813
+ host:chromeHost({dataDir:DATA_DIR,enginePath:augmentedPath})});init_bot_thread_limits();var NETWORK_CODES=new Set(["ECONNREFUSED","ECONNRESET","ETIMEDOUT","ENOTFOUND","EAI_AGAIN","EPIPE","UND_ERR_SOCKET","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT"]);function transientClaimFailure(error66){for(let current3=error66,depth2=0;current3&&typeof current3=="object"&&depth2<4;current3=current3.cause,depth2++){let failure12=current3;if(failure12.transient===!0||failure12.name==="TimeoutError"||typeof failure12.code=="string"&&NETWORK_CODES.has(failure12.code))return!0}return!1}function keepTransient(original,shown3){
28811
28814
  return shown3 instanceof Error&&transientClaimFailure(original)?Object.assign(shown3,{transient:!0}):shown3}function startAutoVmClaim(table3,threadId,generation2,call2){let slot=table3.get(threadId);if(!slot||slot.owner.threadId!==threadId||slot.owner.generation!==generation2||slot.begin||slot.failed)return;let attempt2=(slot.attempts??0)+1;slot.attempts=attempt2,slot.retryReason=void 0;let begin=slot.claim(call2).then(()=>{slot.claimed=!0},error66=>{let failure12=error66 instanceof Error?error66.
28812
28815
  message:String(error66);if(transientClaimFailure(error66)&&attempt2<3){slot.retryReason=failure12,slot.begin===begin&&(slot.begin=void 0);return}slot.failed=!0,slot.failure=failure12,error66?.declined!==!0&&slot.onRejected?.(slot.failure,error66)});slot.begin=begin}function lazyClaimFailedText(slot){let label4=slot.label??"this computer",why=(slot.cause??slot.failure)?.trim().replace(/[\s.]+$/,"");return slot.startsComputer?`${label4.charAt(0).toUpperCase()}${label4.slice(1)} could not be starte\
28813
28816
  d${why?`: ${why}`:""}. This call was not performed.${slot.backOnAuto?" This conversation is back on Auto.":""} Do not retry computer work in this turn; tell the person what you could not do.`:`This turn could not claim ${label4}${why?` (${why})`:""}. This call was not performed. Do not retry computer work in this turn; tell the person what you could not do.`}function lazyClaimRetryText(slot){return`This turn could not reach ${slot.label??"this computer"} just now (${slot.retryReason}). This call\
@@ -29181,28 +29184,29 @@ browserProfilePartitionTarget(cfg2,profile):null;return browserSessionId(botId2+
29181
29184
  await Promise.all(audiences.variants().map(suffix=>forgetTemporaryKey(botId2+suffix)))}async function forgetTemporaryKey(key7){let session=temporaryBrowserSessions2.get(key7);if(!session)return;temporaryBrowserSessions2.delete(key7);let spec=usedBrowserSessions2.get(session);if(usedBrowserSessions2.delete(session),chromeTarget(session,spec)){await chromeEngine.service.close(session);return}let engine=browserEngineStatus();if(engine.kind!=="ready")return;await clearBrowserSessionState(engine.binaryPath,
29182
29185
  session,{env:{PATH:augmentedPath()},encryptionKey:browserEngineEncryptionKey()})?await browserRuntime2.close(session):console.warn(`temporary browser ${session}: could not close its session; run agent-browser --session ${session} close on this server`)}function myChromeAvailable2(){return DESKTOP_MANAGED2||browserEngineAttachCdpUrl(cfg2)!==null||!!lentChrome?.lender()}function lentChromeSession(profileId){return!DESKTOP_MANAGED2&&browserEngineAttachCdpUrl(cfg2)===null&&doors!==void 0&&usesMyChrome2(
29183
29186
  profileId)}function lentChromeSummary2(){let lender=lentChrome?.lender()??null;return lender?{myChromeOn:lender}:lentChrome?{myChromeLendable:!0}:{}}function usesMyChrome2(profileId){return!!profileId&&(myChromeAvailable2()||lentChrome!==void 0)&&cfg2.browserProfiles?.some(profile=>profile.id===profileId&&profile.browser==="chrome")===!0}function browserSessionSpec2(binaryPath,session,profile,egressPort,cdpUrl){let attachCdpUrl=cdpUrl??browserEngineAttachCdpUrl(cfg2);return agentBrowserIntegration(
29184
- {binaryPath,session,encryptionKey:browserEngineEncryptionKey(),persistent:profile!=="guest",egressPort,env:{...process.env,PATH:augmentedPath()},launcher:chromeLauncher.env(),...usesMyChrome2(profile)?{attach:attachCdpUrl?{cdpUrl:attachCdpUrl}:{}}:{}})}function browserProfileIdOf(profile){return(profile&&profile!=="guest"?browserProfilePartitionTarget(cfg2,profile):null)?.profileId??profile}function onChrome(profile){return browserEngineKind(cfg2)==="chrome"&&!usesMyChrome2(browserProfileIdOf(profile))}
29185
- function chromeSpec(botId2,profile,audience2){let suffix=noted2(audience2),session=sessionFor(botId2,profile,suffix),target4=profile&&profile!=="guest"?browserProfilePartitionTarget(cfg2,profile):null;return{session,spec:chromeEngine.spec(session,profileKey(botId2+suffix,session,{guest:profile==="guest",partitionId:target4?target4.partitionId+suffix:null}))}}function browserReady2(profile){return onChrome(profile)?chromeEngine.summary().kind==="engine":browserEngineStatus().kind==="ready"}function turnIntegration(botId2,session,turn2){
29186
- let token3=mintInternalCapability2({botId:botId2,...turn2,browserSession:session,kind:"browser",depth:0,skillAuthoring:!1,createdBots:0,openedThreads:0});return{command:process.execPath,args:[SPAWNED_PROXIES.harnessMcp,"browser"],env:{...AGENTS_NODE_FLAG,[harnessMcpTokenEnv("browser")]:token3,OMB_HARNESS_URL:`http://127.0.0.1:${PORT3}`}}}async function browserIntegration2(botId2,profile,turn2,audience2=browserAudience(turn2?.threadId)){let profileTarget=profile&&profile!=="guest"?browserProfilePartitionTarget(
29187
- cfg2,profile):null,partitionId=profile==="guest"?"guest":profileTarget?.partitionId??"",browserProfileId=profileTarget?.profileId??profile;if(onChrome(profile)){let{session:session2,spec:spec2}=chromeSpec(botId2,profile,audience2);return usedBrowserSessions2.set(session2,spec2),{profile:partitionId,session:session2,spec:spec2,integration:turn2?turnIntegration(botId2,session2,turn2):spec2}}let status5=browserEngineStatus();if(status5.kind!=="ready")return noteBrowserEngineUnavailable(status5),null;
29188
- let session=currentBrowserSession2(botId2,profile,audience2),cdpUrl=lentChromeSession(browserProfileId)?await lentChromeDoor(session):void 0,spec=browserSessionSpec2(status5.binaryPath,session,browserProfileId,usesMyChrome2(browserProfileId)?void 0:await browserEgress.open(session),cdpUrl);return usedBrowserSessions2.set(session,spec),await prepareBrowserSessionState(status5.binaryPath,session,{env:spec.env,persistent:profile!=="guest"&&!attachesToChrome(spec.env),isCurrent:()=>{let current3=store5.
29189
- bot(botId2);return!!current3&&current3.browser!==!1&&builtInBrowserEnabled(cfg2)&&currentBrowserSession2(current3.id,current3.browserProfile,audience2)===session&&(!turn2||activeInternalGenerationByThread2.get(turn2.threadId)===turn2.generation)}}),turn2?{profile:partitionId,session,spec,integration:turnIntegration(botId2,session,turn2)}:{profile:partitionId,session,spec,integration:spec}}async function currentBrowserSpec2(botId2,profile,audience2="team"){if(onChrome(profile))return chromeSpec(botId2,
29190
- profile,audience2);let engine=browserEngineStatus();if(engine.kind!=="ready")return null;let session=currentBrowserSession2(botId2,profile,audience2),used=usedBrowserSessions2.get(session);if(used)return{session,spec:used};let profileId=browserProfileIdOf(profile),cdpUrl=lentChromeSession(profileId)?await lentChromeDoor(session):void 0;return{session,spec:browserSessionSpec2(engine.binaryPath,session,profileId,usesMyChrome2(profileId)?void 0:await browserEgress.open(session),cdpUrl)}}function loginInput2(session,spec,env){
29191
- if(chromeTarget(session,spec)){let deps2=chromeEngine.loginDeps(session);if(deps2)return deps2}return{engine:args=>inRunningBrowser(spec.command,env,args),...relayInput(spec,session)}}function browserSystemPrompt2(profile){return onChrome(profile)?CHROME_BROWSER_SYSTEM_PROMPT:BUILT_IN_BROWSER_SYSTEM_PROMPT}function signedInSitesRefusal(profile){return usesMyChrome2(profile)?"This profile uses your own Chrome. Sign in and out of sites there.":onChrome(profile)?"The new browser does not list signe\
29192
- d-in sites yet. Sign out in the browser itself, or turn off New browser in Settings.":null}async function closeBrowser2(session,spec){return chromeTarget(session,spec)?(await chromeEngine.service.close(session),!0):closeBrowserSession(spec.command,browserRuntimeEnv({...spec.env,AGENT_BROWSER_SESSION:session}))}function browserEngineSwitched2(){browserLive2.closeAll();for(let[session,spec]of usedBrowserSessions2)attachesToChrome(spec.env)||(usedBrowserSessions2.delete(session),closeBrowser2(session,
29193
- spec).then(closed=>{closed||console.warn(`browser ${session}: could not close it after the browser engine changed`)}));browserEngineKind(cfg2)!=="chrome"&&chromeEngine.service.closeAll().catch(()=>{}),chromeEngine.start({inUse:browserEngineKind(cfg2)==="chrome",prepare:builtInBrowserEnabled(cfg2)})}function browserRunning(session,spec){return chromeTarget(session,spec)?chromeEngine.service.runs(session):existsSync90(browserDaemonFile(browserRuntimeEnv({...spec?.env,AGENT_BROWSER_SESSION:session}),
29194
- ".pid"))}function threadBrowser(threadId){let bot=store5.botByThread(threadId);if(!bot||bot.browser===!1||bot.computer==="off"||!builtInBrowserEnabled(cfg2)||usesMyChrome2(bot.browserProfile))return null;let audience2=browserAudience(threadId),session=bot.browserProfile==="guest"?temporaryBrowserSessions2.get(bot.id+audienceBrowserSuffix(audience2)):currentBrowserSession2(bot.id,bot.browserProfile,audience2);return{session,spec:session===void 0?void 0:usedBrowserSessions2.get(session)}}async function closeForMemory(session,spec){
29195
- for(let attempt2=0;attempt2<15&&browserRunning(session,spec);attempt2++){if(turnResources2.free(`browser:${session}`)&&await browserRuntime2.closeUnused(session,spec)){console.info(`browser ${session}: closed to free memory after its bot was stopped`);return}await sleep6(2e3)}}let engineBrowsers={starts:threadId=>{let browser=threadBrowser(threadId);return browser!==null&&(browser.session===void 0||!browserRunning(browser.session,browser.spec))},which:threadId=>threadBrowser(threadId)?.session,running:threadId=>{
29196
- let browser=threadBrowser(threadId);return browser?.session!==void 0&&browserRunning(browser.session,browser.spec)},stopped:threadId=>{let browser=threadBrowser(threadId);browser?.session!==void 0&&browser.spec&&closeForMemory(browser.session,browser.spec)}};deps.engineMemory?.useBrowsers(engineBrowsers);function eraseChromeBrowser(request10){return request10.type==="openmausbot:browser-bot-deleted"&&request10.botId?chromeEngine.erase({kind:"bot",id:request10.botId,partitionId:""}):request10.partitionId?
29197
- chromeEngine.erase({kind:"profile",id:request10.partitionId,partitionId:request10.partitionId}):Promise.resolve(!0)}function cleanupEngine(){let managed=browserEngineStatus({managedOnly:!0});if(managed.kind==="ready")return managed;let used=browserEngineStatus();return CLOUD_HOME2&&used.kind==="ready"?used:null}async function eraseDeletedBrowser2(request10){return(await Promise.all(audiences.variants().map(suffix=>eraseOneBrowser({...request10,...request10.botId?{botId:request10.botId+suffix}:{},
29198
- ...request10.partitionId?{partitionId:request10.partitionId+suffix}:{}})))).every(Boolean)}async function eraseOneBrowser(request10){let session=request10.type==="openmausbot:browser-bot-deleted"&&request10.botId?browserSessionId(request10.botId,""):request10.partitionId?browserSessionId("",request10.partitionId):null,engine=cleanupEngine(),erased=async name6=>{if(!engine){let used=browserEngineStatus();return used.kind==="ready"&&closeBrowserSession(used.binaryPath,browserRuntimeEnv({AGENT_BROWSER_SESSION:name6})),
29199
- !0}let ok2=await clearBrowserSessionState(engine.binaryPath,name6,{encryptionKey:browserEngineEncryptionKey()});return ok2||console.warn(`browser cleanup: could not clear saved state for session ${name6}; restart Limix Bot to retry this profile's cleanup. Do not use state clear --all: it erases other profiles too.`),ok2};return(await Promise.all([eraseChromeBrowser(request10),...session?[erased(session)]:[]])).every(Boolean)}async function eraseAudienceBrowsers2(audience2){let suffix=audienceBrowserSuffix(
29200
- audience2);if(!suffix||!audiences.variants().includes(suffix))return!0;let requests=[...store5.bots.map(bot=>({type:"openmausbot:browser-bot-deleted",requestId:"team-member-left",botId:bot.id+suffix})),...(cfg2.browserProfiles??[]).filter(profile=>!usesMyChrome2(profile.id)).map(profile=>({type:"openmausbot:browser-profile-deleted",requestId:"team-member-left",partitionId:browserProfilePartitionId(profile)+suffix}))];return(await Promise.all(requests.map(request10=>eraseOneBrowser(request10)))).
29201
- every(Boolean)}function uploadPaths2(files2,session,spec){let chrome=chromeTarget(session,spec),folder3=boxed&&!chrome?join227(browserProfileDirectory(session),"omb-uploads"):join227(DATA_DIR,"browser-uploads");return namedUploadPaths(files2,folder3,Date.now(),{everyFile:boxed||!!chrome})}async function signedInSitesTarget2(which,audience2="team"){let engine=browserEngineStatus();if(engine.kind!=="ready")return{status:409,error:engine.reason};let session,profile;if("profile"in which){let target4=browserProfilePartitionTarget(
29202
- cfg2,which.profile);if(!target4)return{status:404,error:"This browser profile was removed."};session=browserSessionId("",target4.partitionId+noted2(audience2)),profile=target4.profileId}else{let bot=store5.bot(which.bot);if(!bot)return{status:404,error:"no such bot"};if(bot.browserProfile==="guest")return{status:409,error:"A temporary browser saves no sign-ins."};session=currentBrowserSession2(bot.id,bot.browserProfile,audience2),profile=bot.browserProfile}let refusal7=signedInSitesRefusal(profile);
29203
- return refusal7?{status:409,error:refusal7}:{binaryPath:engine.binaryPath,session,env:browserSessionSpec2(engine.binaryPath,session,profile,await browserEgress.open(session)).env,encryptionKey:browserEngineEncryptionKey()}}function engineSummary2(agentBrowser){let serverSites=sitesSwitch?{serverSites:cfg2.browserEngine?.egress?.localNetwork===!0}:{};return browserEngineKind(cfg2)!=="chrome"?{...agentBrowser,...serverSites,engine:"agent-browser"}:{...chromeEngine.summary(),myChrome:agentBrowser.myChrome,
29204
- ...lentChromeSummary2(),...serverSites,engine:"chrome"}}return{browserRuntime:browserRuntime2,browserLive:browserLive2,usedBrowserSessions:usedBrowserSessions2,browserSweep:browserSweep2,temporaryBrowserSessions:temporaryBrowserSessions2,browserIdleMs:idleMs,currentBrowserSession:currentBrowserSession2,forgetTemporaryBrowser:forgetTemporaryBrowser2,myChromeAvailable:myChromeAvailable2,lentChromeSummary:lentChromeSummary2,usesMyChrome:usesMyChrome2,browserSessionSpec:browserSessionSpec2,browserIntegration:browserIntegration2,
29205
- browserReady:browserReady2,currentBrowserSpec:currentBrowserSpec2,loginInput:loginInput2,browserSystemPrompt:browserSystemPrompt2,signedInSitesRefusal,closeBrowser:closeBrowser2,browserEngineSwitched:browserEngineSwitched2,eraseDeletedBrowser:eraseDeletedBrowser2,engineSummary:engineSummary2,engineBrowsers,browserAudience,browserSessionsOf:browserSessionsOf2,signedInSitesTarget:signedInSitesTarget2,uploadPaths:uploadPaths2,eraseAudienceBrowsers:eraseAudienceBrowsers2}}async function captureOutsideHumanControl(control,capture){let before=control();if(before.held)return null;let{png:png2,format:format6}=await capture(),after=control();return after.held||after.revision!==before.revision?null:{png:png2,mime:format6==="jpeg"?"image/jpeg":"image/png"}}var TURN_FRAME_LIMIT=64,turnFrames=new Map;function rememberTurnFrame(resource,frame2,at8=Date.now()){resource&&(turnFrames.delete(resource),turnFrames.set(resource,{frame:frame2,at:at8}),turnFrames.size>TURN_FRAME_LIMIT&&turnFrames.delete(turnFrames.keys().next().value))}function latestTurnFrame(resource){return turnFrames.get(resource)}function createScreenFrameSource(input2){let current3=null,lastAt=0,attemptedSurface,last=null,lastSurface,selectedSurface=()=>input2.captures[source4.surface]?
29187
+ {binaryPath,session,encryptionKey:browserEngineEncryptionKey(),persistent:profile!=="guest",egressPort,env:{...process.env,PATH:augmentedPath()},launcher:chromeLauncher.env(),...usesMyChrome2(profile)?{attach:attachCdpUrl?{cdpUrl:attachCdpUrl}:{}}:{}})}async function preparedSessionSpec(...args){return process.platform==="win32"&&!usesMyChrome2(args[2])&&await chromeLauncher.prepare(),browserSessionSpec2(...args)}function browserProfileIdOf(profile){return(profile&&profile!=="guest"?browserProfilePartitionTarget(
29188
+ cfg2,profile):null)?.profileId??profile}function onChrome(profile){return browserEngineKind(cfg2)==="chrome"&&!usesMyChrome2(browserProfileIdOf(profile))}function chromeSpec(botId2,profile,audience2){let suffix=noted2(audience2),session=sessionFor(botId2,profile,suffix),target4=profile&&profile!=="guest"?browserProfilePartitionTarget(cfg2,profile):null;return{session,spec:chromeEngine.spec(session,profileKey(botId2+suffix,session,{guest:profile==="guest",partitionId:target4?target4.partitionId+suffix:
29189
+ null}))}}function browserReady2(profile){return onChrome(profile)?chromeEngine.summary().kind==="engine":browserEngineStatus().kind==="ready"}function turnIntegration(botId2,session,turn2){let token3=mintInternalCapability2({botId:botId2,...turn2,browserSession:session,kind:"browser",depth:0,skillAuthoring:!1,createdBots:0,openedThreads:0});return{command:process.execPath,args:[SPAWNED_PROXIES.harnessMcp,"browser"],env:{...AGENTS_NODE_FLAG,[harnessMcpTokenEnv("browser")]:token3,OMB_HARNESS_URL:`\
29190
+ http://127.0.0.1:${PORT3}`}}}async function browserIntegration2(botId2,profile,turn2,audience2=browserAudience(turn2?.threadId)){let profileTarget=profile&&profile!=="guest"?browserProfilePartitionTarget(cfg2,profile):null,partitionId=profile==="guest"?"guest":profileTarget?.partitionId??"",browserProfileId=profileTarget?.profileId??profile;if(onChrome(profile)){let{session:session2,spec:spec2}=chromeSpec(botId2,profile,audience2);return usedBrowserSessions2.set(session2,spec2),{profile:partitionId,
29191
+ session:session2,spec:spec2,integration:turn2?turnIntegration(botId2,session2,turn2):spec2}}let status5=browserEngineStatus();if(status5.kind!=="ready")return noteBrowserEngineUnavailable(status5),null;let session=currentBrowserSession2(botId2,profile,audience2),cdpUrl=lentChromeSession(browserProfileId)?await lentChromeDoor(session):void 0,spec=await preparedSessionSpec(status5.binaryPath,session,browserProfileId,usesMyChrome2(browserProfileId)?void 0:await browserEgress.open(session),cdpUrl);return usedBrowserSessions2.
29192
+ set(session,spec),await prepareBrowserSessionState(status5.binaryPath,session,{env:spec.env,persistent:profile!=="guest"&&!attachesToChrome(spec.env),isCurrent:()=>{let current3=store5.bot(botId2);return!!current3&&current3.browser!==!1&&builtInBrowserEnabled(cfg2)&&currentBrowserSession2(current3.id,current3.browserProfile,audience2)===session&&(!turn2||activeInternalGenerationByThread2.get(turn2.threadId)===turn2.generation)}}),turn2?{profile:partitionId,session,spec,integration:turnIntegration(
29193
+ botId2,session,turn2)}:{profile:partitionId,session,spec,integration:spec}}async function currentBrowserSpec2(botId2,profile,audience2="team"){if(onChrome(profile))return chromeSpec(botId2,profile,audience2);let engine=browserEngineStatus();if(engine.kind!=="ready")return null;let session=currentBrowserSession2(botId2,profile,audience2),used=usedBrowserSessions2.get(session);if(used)return{session,spec:used};let profileId=browserProfileIdOf(profile),cdpUrl=lentChromeSession(profileId)?await lentChromeDoor(
29194
+ session):void 0;return{session,spec:await preparedSessionSpec(engine.binaryPath,session,profileId,usesMyChrome2(profileId)?void 0:await browserEgress.open(session),cdpUrl)}}function loginInput2(session,spec,env){if(chromeTarget(session,spec)){let deps2=chromeEngine.loginDeps(session);if(deps2)return deps2}return{engine:args=>inRunningBrowser(spec.command,env,args),...relayInput(spec,session)}}function browserSystemPrompt2(profile){return onChrome(profile)?CHROME_BROWSER_SYSTEM_PROMPT:BUILT_IN_BROWSER_SYSTEM_PROMPT}
29195
+ function signedInSitesRefusal(profile){return usesMyChrome2(profile)?"This profile uses your own Chrome. Sign in and out of sites there.":onChrome(profile)?"The new browser does not list signed-in sites yet. Sign out in the browser itself, or turn off New browser in Settings.":null}async function closeBrowser2(session,spec){return chromeTarget(session,spec)?(await chromeEngine.service.close(session),!0):closeBrowserSession(spec.command,browserRuntimeEnv({...spec.env,AGENT_BROWSER_SESSION:session}))}
29196
+ function browserEngineSwitched2(){browserLive2.closeAll();for(let[session,spec]of usedBrowserSessions2)attachesToChrome(spec.env)||(usedBrowserSessions2.delete(session),closeBrowser2(session,spec).then(closed=>{closed||console.warn(`browser ${session}: could not close it after the browser engine changed`)}));browserEngineKind(cfg2)!=="chrome"&&chromeEngine.service.closeAll().catch(()=>{}),chromeEngine.start({inUse:browserEngineKind(cfg2)==="chrome",prepare:builtInBrowserEnabled(cfg2)})}function browserRunning(session,spec){
29197
+ return chromeTarget(session,spec)?chromeEngine.service.runs(session):existsSync90(browserDaemonFile(browserRuntimeEnv({...spec?.env,AGENT_BROWSER_SESSION:session}),".pid"))}function threadBrowser(threadId){let bot=store5.botByThread(threadId);if(!bot||bot.browser===!1||bot.computer==="off"||!builtInBrowserEnabled(cfg2)||usesMyChrome2(bot.browserProfile))return null;let audience2=browserAudience(threadId),session=bot.browserProfile==="guest"?temporaryBrowserSessions2.get(bot.id+audienceBrowserSuffix(
29198
+ audience2)):currentBrowserSession2(bot.id,bot.browserProfile,audience2);return{session,spec:session===void 0?void 0:usedBrowserSessions2.get(session)}}async function closeForMemory(session,spec){for(let attempt2=0;attempt2<15&&browserRunning(session,spec);attempt2++){if(turnResources2.free(`browser:${session}`)&&await browserRuntime2.closeUnused(session,spec)){console.info(`browser ${session}: closed to free memory after its bot was stopped`);return}await sleep6(2e3)}}let engineBrowsers={starts:threadId=>{
29199
+ let browser=threadBrowser(threadId);return browser!==null&&(browser.session===void 0||!browserRunning(browser.session,browser.spec))},which:threadId=>threadBrowser(threadId)?.session,running:threadId=>{let browser=threadBrowser(threadId);return browser?.session!==void 0&&browserRunning(browser.session,browser.spec)},stopped:threadId=>{let browser=threadBrowser(threadId);browser?.session!==void 0&&browser.spec&&closeForMemory(browser.session,browser.spec)}};deps.engineMemory?.useBrowsers(engineBrowsers);
29200
+ function eraseChromeBrowser(request10){return request10.type==="openmausbot:browser-bot-deleted"&&request10.botId?chromeEngine.erase({kind:"bot",id:request10.botId,partitionId:""}):request10.partitionId?chromeEngine.erase({kind:"profile",id:request10.partitionId,partitionId:request10.partitionId}):Promise.resolve(!0)}function cleanupEngine(){let managed=browserEngineStatus({managedOnly:!0});if(managed.kind==="ready")return managed;let used=browserEngineStatus();return CLOUD_HOME2&&used.kind==="r\
29201
+ eady"?used:null}async function eraseDeletedBrowser2(request10){return(await Promise.all(audiences.variants().map(suffix=>eraseOneBrowser({...request10,...request10.botId?{botId:request10.botId+suffix}:{},...request10.partitionId?{partitionId:request10.partitionId+suffix}:{}})))).every(Boolean)}async function eraseOneBrowser(request10){let session=request10.type==="openmausbot:browser-bot-deleted"&&request10.botId?browserSessionId(request10.botId,""):request10.partitionId?browserSessionId("",request10.
29202
+ partitionId):null,engine=cleanupEngine(),erased=async name6=>{if(!engine){let used=browserEngineStatus();return used.kind==="ready"&&closeBrowserSession(used.binaryPath,browserRuntimeEnv({AGENT_BROWSER_SESSION:name6})),!0}let ok2=await clearBrowserSessionState(engine.binaryPath,name6,{encryptionKey:browserEngineEncryptionKey()});return ok2||console.warn(`browser cleanup: could not clear saved state for session ${name6}; restart Limix Bot to retry this profile's cleanup. Do not use state clear --\
29203
+ all: it erases other profiles too.`),ok2};return(await Promise.all([eraseChromeBrowser(request10),...session?[erased(session)]:[]])).every(Boolean)}async function eraseAudienceBrowsers2(audience2){let suffix=audienceBrowserSuffix(audience2);if(!suffix||!audiences.variants().includes(suffix))return!0;let requests=[...store5.bots.map(bot=>({type:"openmausbot:browser-bot-deleted",requestId:"team-member-left",botId:bot.id+suffix})),...(cfg2.browserProfiles??[]).filter(profile=>!usesMyChrome2(profile.
29204
+ id)).map(profile=>({type:"openmausbot:browser-profile-deleted",requestId:"team-member-left",partitionId:browserProfilePartitionId(profile)+suffix}))];return(await Promise.all(requests.map(request10=>eraseOneBrowser(request10)))).every(Boolean)}function uploadPaths2(files2,session,spec){let chrome=chromeTarget(session,spec),folder3=boxed&&!chrome?join227(browserProfileDirectory(session),"omb-uploads"):join227(DATA_DIR,"browser-uploads");return namedUploadPaths(files2,folder3,Date.now(),{everyFile:boxed||
29205
+ !!chrome})}async function signedInSitesTarget2(which,audience2="team"){let engine=browserEngineStatus();if(engine.kind!=="ready")return{status:409,error:engine.reason};let session,profile;if("profile"in which){let target4=browserProfilePartitionTarget(cfg2,which.profile);if(!target4)return{status:404,error:"This browser profile was removed."};session=browserSessionId("",target4.partitionId+noted2(audience2)),profile=target4.profileId}else{let bot=store5.bot(which.bot);if(!bot)return{status:404,error:"\
29206
+ no such bot"};if(bot.browserProfile==="guest")return{status:409,error:"A temporary browser saves no sign-ins."};session=currentBrowserSession2(bot.id,bot.browserProfile,audience2),profile=bot.browserProfile}let refusal7=signedInSitesRefusal(profile);return refusal7?{status:409,error:refusal7}:{binaryPath:engine.binaryPath,session,env:(await preparedSessionSpec(engine.binaryPath,session,profile,await browserEgress.open(session))).env,encryptionKey:browserEngineEncryptionKey()}}function engineSummary2(agentBrowser){
29207
+ let serverSites=sitesSwitch?{serverSites:cfg2.browserEngine?.egress?.localNetwork===!0}:{};return browserEngineKind(cfg2)!=="chrome"?{...agentBrowser,...serverSites,engine:"agent-browser"}:{...chromeEngine.summary(),myChrome:agentBrowser.myChrome,...lentChromeSummary2(),...serverSites,engine:"chrome"}}return{browserRuntime:browserRuntime2,browserLive:browserLive2,usedBrowserSessions:usedBrowserSessions2,browserSweep:browserSweep2,temporaryBrowserSessions:temporaryBrowserSessions2,browserIdleMs:idleMs,
29208
+ currentBrowserSession:currentBrowserSession2,forgetTemporaryBrowser:forgetTemporaryBrowser2,myChromeAvailable:myChromeAvailable2,lentChromeSummary:lentChromeSummary2,usesMyChrome:usesMyChrome2,browserSessionSpec:browserSessionSpec2,browserIntegration:browserIntegration2,browserReady:browserReady2,currentBrowserSpec:currentBrowserSpec2,loginInput:loginInput2,browserSystemPrompt:browserSystemPrompt2,signedInSitesRefusal,closeBrowser:closeBrowser2,browserEngineSwitched:browserEngineSwitched2,eraseDeletedBrowser:eraseDeletedBrowser2,
29209
+ engineSummary:engineSummary2,engineBrowsers,browserAudience,browserSessionsOf:browserSessionsOf2,signedInSitesTarget:signedInSitesTarget2,uploadPaths:uploadPaths2,eraseAudienceBrowsers:eraseAudienceBrowsers2}}async function captureOutsideHumanControl(control,capture){let before=control();if(before.held)return null;let{png:png2,format:format6}=await capture(),after=control();return after.held||after.revision!==before.revision?null:{png:png2,mime:format6==="jpeg"?"image/jpeg":"image/png"}}var TURN_FRAME_LIMIT=64,turnFrames=new Map;function rememberTurnFrame(resource,frame2,at8=Date.now()){resource&&(turnFrames.delete(resource),turnFrames.set(resource,{frame:frame2,at:at8}),turnFrames.size>TURN_FRAME_LIMIT&&turnFrames.delete(turnFrames.keys().next().value))}function latestTurnFrame(resource){return turnFrames.get(resource)}function createScreenFrameSource(input2){let current3=null,lastAt=0,attemptedSurface,last=null,lastSurface,selectedSurface=()=>input2.captures[source4.surface]?
29206
29210
  source4.surface:input2.captures.computer?"computer":"browser",source4={surface:input2.captures.computer?"computer":"browser",get last(){return lastSurface===selectedSurface()?last:null},async capture(fresh=!1){for(;current3;)await current3;if(input2.control().held)return;let surface=selectedSurface();if(!(!fresh&&attemptedSurface===surface&&Date.now()-lastAt<input2.minGapMs)){attemptedSurface=surface,current3=(async()=>{try{let capture=input2.captures[surface];if(!capture)return;let frame2=await captureOutsideHumanControl(
29207
29211
  input2.control,capture);if(!frame2||surface!==selectedSurface())return;last=frame2,lastSurface=surface,input2.onFrame(frame2,surface)}catch{}finally{lastAt=Date.now()}})();try{await current3}finally{current3=null}}}};return source4}import{createHash as createHash98}from"node:crypto";function screenFrameHash(png2){return createHash98("sha256").update(png2).digest("hex")}function settledFrameIsNews(shownFrameHash,png2){return shownFrameHash===void 0||screenFrameHash(png2)!==shownFrameHash}import{createHash as createHash99}from"node:crypto";import{isDeepStrictEqual as isDeepStrictEqual4}from"node:util";var NTH={1:"server.routines.cron.nth.first",2:"server.routines.cron.nth.second",3:"server.routines.cron.nth.third",4:"server.routines.cron.nth.fourth",5:"server.routines.cron.nth.fifth",last:"server.routines.cron.nth.last"},NTH_WEEKEND={1:"server.routines.cron.nthWeekend.first",2:"server.routines.cron.nthWeekend.second",3:"server.routines.cron.nthWeekend.third",4:"server.routines.cron.nthWeekend.fourth",5:"server.routines.cron.nthWeekend.fifth",last:"server.routines.cron.nthWeekend.last"};function presetText(preset,language){
29208
29212
  let locale4=byLanguage({en:"en-US",de:"de-DE","pt-br":"pt-BR","zh-tw":"zh-TW"},language),time6=locale4==="en-US"?preset.time.replace(/^0(?=\d:)/,""):preset.time,weekdayName=day2=>new Intl.DateTimeFormat(locale4,{weekday:"long",timeZone:"UTC"}).format(Date.UTC(2023,0,1+day2)),monthName=month=>new Intl.DateTimeFormat(locale4,{month:"long",timeZone:"UTC"}).format(Date.UTC(2023,month,1));switch(preset.kind){case"everyDay":return serverLine(language,"server.routines.cron.everyDay",{time:time6});case"\
@@ -2988,22 +2988,23 @@ ts"(){"use strict";init_atomic();init_gate();LAUNCHER_SECCOMP_FD=9;run3=(file2,a
2988
2988
  if(!error62||error62.killed)return resolve36();reject(new Error(`the browser launcher does not run here: ${error62.message}`))})})}function product(chrome,identity){return identity?.userAgentMetadata.brands.some(({brand})=>brand==="Google Chrome")||chrome.source==="installed"?"Google Chrome":chrome.source==="downloaded"||/for Testing|chrome-(?:linux|mac|win)/iu.test(chrome.path)?"Chrome for Testing":"Chromium"}var SOURCES,megabytes,message,ChromeLauncher,chromeLauncher,init_launcher=__esm({"serv\
2989
2989
  er/browser/chrome/launcher.ts"(){"use strict";init_browser_engine();init_browser_runtime();init_config3();init_env_path();init_calibrate();init_identity2();init_install();init_resolve();init_sidecar();init_wrapper();SOURCES={installed:"installed",downloaded:"downloaded",named:"named by OMB_CHROME_PATH or AGENT_BROWSER_EXECUTABLE_PATH","agent-browser":"installed by agent-browser"},megabytes=bytes2=>Math.round(bytes2/1048576),message=error62=>error62 instanceof Error?error62.message:String(error62);
2990
2990
  ChromeLauncher=class{path;state={kind:"idle"};preparing=null;screen=null;options;host;sidecars;box=null;constructor(options2){let env=options2.env??process.env,platform=options2.platform??process.platform;this.options={...options2,env,platform,readyWaitMs:options2.readyWaitMs??45e3},this.host=options2.host??chromeHost({dataDir:options2.dataDir,env,platform,arch:options2.arch}),this.sidecars=options2.sidecars??new IdentitySidecars,this.path=launcherPath(options2.dataDir,platform)}boxWith(box2){if(this.
2991
- box=box2,this.state.kind==="ready"&&this.state.launcher){let launcher={...this.state.launcher,...this.boxed()};writeLauncher(this.path,launcher,this.options.platform),this.state={...this.state,launcher}}}boxed(){let box2=this.box?.()??null;return box2?{box:box2}:{}}plan(){let downloading=this.state.kind==="preparing"||this.state.kind==="downloading";return resolveChromePlan(this.host,this.options.engine?this.options.engine():this.managedEngine(),{downloading})}env(){return this.state.kind==="fai\
2992
- led"||this.plan().kind==="legacy"?{}:(this.prepare(),this.followTimeZone(),{AGENT_BROWSER_EXECUTABLE_PATH:this.path,AGENT_BROWSER_HIDE_SCROLLBARS:"0"})}followTimeZone(){let state=this.state;if(state.kind!=="ready"||!state.launcher)return;let timeZone=browserTimeZone(this.options.env,this.options.platform);if(timeZone===state.launcher.timeZone)return;let launcher={...state.launcher,timeZone};try{writeLauncher(this.path,launcher,this.options.platform),this.state={...state,launcher},this.log(`brows\
2993
- er: the next browser started tells time in ${timeZone??"the system's zone"}`)}catch(error62){this.log(`browser: could not move the browser to ${timeZone??"the system's zone"} (${message(error62)})`)}}start(){this.plan().kind!=="legacy"&&this.prepare()}prepare(){if(this.preparing)return this.preparing;if(this.state.kind==="failed"||this.state.kind==="ready"&&this.fresh(this.state))return Promise.resolve();let plan=this.plan();if(plan.kind==="legacy")return Promise.resolve();let previous2=this.state.
2994
- kind==="ready"?this.state:null;return previous2||(this.state={kind:"preparing"}),this.preparing=this.prepareFor(plan).then(ready=>{this.state=ready,this.log(`browser: ${this.describe()}`)},error62=>{this.state=previous2?{...previous2,fingerprint:this.fingerprintOr(previous2)}:{kind:"failed",reason:message(error62)},this.log(`browser: Chrome could not be prepared (${message(error62)}); ${previous2?"keeping the browser already set up":"bots keep the engine's own browser"}`)}).finally(()=>{this.preparing=
2995
- null}),this.preparing}async ready(spec){if(!this.uses(spec))return;let timer2,done=await Promise.race([this.prepare().then(()=>!0),new Promise(resolve36=>{timer2=setTimeout(()=>resolve36(!1),this.options.readyWaitMs),timer2.unref?.()})]);if(clearTimeout(timer2),!done){let state=this.state;throw new Error(state.kind==="downloading"?`Getting the browser ready (${megabytes(state.progress.received)} of ${megabytes(state.progress.total)} MB). Try again in a minute.`:"Getting the browser ready. Try ag\
2996
- ain in a moment.")}if(this.state.kind==="failed")throw new Error(`Chrome could not be started (${this.state.reason}). Try again: your next browser call uses the built-in browser.`)}async started(session,spec){this.state.kind!=="ready"||!this.uses(spec)||!ownsBrowserViewport(spec.env??{})||await this.sidecars.ensure(session,spec,{...this.state.identity,acceptLanguage:languageList(browserLanguage(this.options.env))})}stopped(session){this.sidecars.forget(session)}describe(){let state=this.state;if(state.
2997
- kind==="ready")return`${product(state.chrome,state.identity)} ${state.identity.userAgentMetadata.fullVersion.split(".")[0]} (${SOURCES[state.chrome.source]})`;let plan=this.plan();return plan.kind==="legacy"?`${this.engineBrowser()} (${plan.reason})`:state.kind==="failed"?`${this.engineBrowser()} (Chrome could not be started: ${state.reason})`:state.kind==="downloading"?`Chrome for Testing ${state.pin.version} (downloading: ${megabytes(state.progress.received)} of ${megabytes(state.progress.total)}\
2998
- MB)`:plan.kind==="download"?`Chrome for Testing ${plan.pin.version} (not downloaded yet)`:`${product(plan.chrome)} (${SOURCES[plan.chrome.source]}; not started yet)`}chromeEnv(){return this.options.platform==="darwin"?{...this.options.env,HOME:userInfo4().homedir}:this.options.env}uses(spec){return spec.env?.AGENT_BROWSER_EXECUTABLE_PATH===this.path&&!attachesToChrome(spec.env)}fresh(state){try{return chromeFingerprint(state.chrome.path)===state.fingerprint}catch{return!1}}fingerprintOr(state){
2999
- try{return chromeFingerprint(state.chrome.path)}catch{return state.fingerprint}}async prepareFor(plan){let chrome=plan.kind==="download"?await this.download(plan.pin):plan.chrome,identity;try{identity=await this.identityOf(chrome)}catch(error62){if(plan.kind!=="chrome"||plan.chrome.source!=="installed"||!plan.fallback)throw error62;this.log(`browser: Google Chrome at ${chrome.path} could not start headless (${message(error62)}); using Chrome for Testing`),chrome=await this.download(plan.fallback),
3000
- identity=await this.identityOf(chrome)}let{env,platform}=this.options,launcher;return this.options.wrapper!==!1&&(this.screen??=this.options.screen?this.options.screen():primaryScreen(platform,env),launcher={chrome:chrome.path,userAgent:identity.userAgent,screen:await this.screen,language:browserLanguage(env),timeZone:browserTimeZone(env,platform),...platform==="darwin"?{home:userInfo4().homedir}:{},...this.boxed()},writeLauncher(this.path,launcher,platform),platform!=="win32"&&await(this.options.
3001
- checkLauncher??runsLauncher)(this.path,this.chromeEnv())),{kind:"ready",chrome,identity:{userAgent:identity.userAgent,userAgentMetadata:identity.userAgentMetadata},product:identity.product,fingerprint:chromeFingerprint(chrome.path),...launcher?{launcher}:{}}}async download(pin){return this.state={kind:"downloading",pin,progress:{received:0,total:pin.bytes}},{path:await(this.options.install??installChromeForTesting)({dataDir:this.options.dataDir,pin,onProgress:progress=>{this.state.kind==="downlo\
3002
- ading"&&(this.state={...this.state,progress})}}),source:"downloaded"}}async identityOf(chrome){let env=this.chromeEnv(),injected=this.options.calibrate,calibrate=injected?async options3=>{let read2=await injected(options3.executablePath,env);return{...read2,product:`Chrome/${read2.userAgentMetadata.fullVersion}`,fingerprint:chromeFingerprint(options3.executablePath),calibratedAt:new Date().toISOString()}}:calibrateIdentity,host2=this.options.platform==="linux"&&existsSync22("/.dockerenv")?"conta\
3003
- iner":"desktop",options2={executablePath:chrome.path,host:host2,env,sandbox:this.options.sandbox??!needsNoSandbox(env)};return(await loadOrCalibrateIdentity(this.options.dataDir,options2,calibrate)).identity}async binary(){let plan=this.plan();if(plan.kind==="legacy")throw new Error(`no Chrome to run here (${plan.reason})`);let timer2,done=await Promise.race([this.prepare().then(()=>!0),new Promise(resolve36=>{timer2=setTimeout(()=>resolve36(!1),this.options.readyWaitMs),timer2.unref?.()})]);clearTimeout(
3004
- timer2);let state=this.state;if(!done)throw new Error(state.kind==="downloading"?`Getting the browser ready (${megabytes(state.progress.received)} of ${megabytes(state.progress.total)} MB). Try again in a minute.`:"Getting the browser ready. Try again in a moment.");if(state.kind==="failed")throw new Error(`Chrome could not be started (${state.reason}).`);if(state.kind!=="ready")throw new Error("Chrome is not ready yet. Try again in a moment.");return{path:state.chrome.path,identity:state.identity,
3005
- product:state.product,source:state.chrome.source}}managedEngine(){let status2=browserEngineStatus({dataDir:this.options.dataDir,env:this.options.env,platform:this.options.platform,arch:this.options.arch});return status2.kind==="ready"?{managed:status2.managed}:null}engineBrowser(){let named2=this.options.env.AGENT_BROWSER_EXECUTABLE_PATH?.trim();return named2||(this.options.env.OMB_RESOURCES_PATH?"the bundled Chromium headless shell":"agent-browser's own browser")}log(line3){(this.options.log??console.
3006
- log)(line3)}};chromeLauncher=new ChromeLauncher({dataDir:DATA_DIR,host:chromeHost({dataDir:DATA_DIR,enginePath:augmentedPath})})}});import{execFileSync as execFileSync2}from"node:child_process";import{createHash as createHash11,randomUUID as randomUUID6}from"node:crypto";import{existsSync as existsSync23,linkSync,mkdirSync as mkdirSync17,readdirSync as readdirSync12,readFileSync as readFileSync19,readlinkSync as readlinkSync2,renameSync as renameSync9,unlinkSync as unlinkSync4,writeFileSync as writeFileSync11}from"node:fs";import{hostname as hostname5,uptime}from"node:os";import{join as join38}from"node:path";function leaseError(message5,cause){
2991
+ box=box2,this.state.kind==="ready"&&this.state.launcher){let launcher={...this.state.launcher,...this.boxed()};this.options.platform!=="win32"&&writeLauncher(this.path,launcher,this.options.platform),this.state={...this.state,launcher}}}boxed(){let box2=this.box?.()??null;return box2?{box:box2}:{}}plan(){let downloading=this.state.kind==="preparing"||this.state.kind==="downloading";return resolveChromePlan(this.host,this.options.engine?this.options.engine():this.managedEngine(),{downloading})}env(){
2992
+ if(this.state.kind==="failed"||this.plan().kind==="legacy")return{};if(this.prepare(),this.options.platform==="win32"){let settings2=this.state.kind==="ready"&&this.state.launcher;return settings2?{AGENT_BROWSER_EXECUTABLE_PATH:settings2.chrome,AGENT_BROWSER_USER_AGENT:settings2.userAgent,AGENT_BROWSER_ARGS:launcherFlags(settings2,"win32").filter(flag3=>!flag3.startsWith("--user-agent=")).join(`
2993
+ `),AGENT_BROWSER_HIDE_SCROLLBARS:"0"}:{}}return this.followTimeZone(),{AGENT_BROWSER_EXECUTABLE_PATH:this.path,AGENT_BROWSER_HIDE_SCROLLBARS:"0"}}followTimeZone(){let state=this.state;if(state.kind!=="ready"||!state.launcher)return;let timeZone=browserTimeZone(this.options.env,this.options.platform);if(timeZone===state.launcher.timeZone)return;let launcher={...state.launcher,timeZone};try{this.options.platform!=="win32"&&writeLauncher(this.path,launcher,this.options.platform),this.state={...state,
2994
+ launcher},this.log(`browser: the next browser started tells time in ${timeZone??"the system's zone"}`)}catch(error62){this.log(`browser: could not move the browser to ${timeZone??"the system's zone"} (${message(error62)})`)}}start(){this.plan().kind!=="legacy"&&this.prepare()}prepare(){if(this.preparing)return this.preparing;if(this.state.kind==="failed"||this.state.kind==="ready"&&this.fresh(this.state))return Promise.resolve();let plan=this.plan();if(plan.kind==="legacy")return Promise.resolve();
2995
+ let previous2=this.state.kind==="ready"?this.state:null;return previous2||(this.state={kind:"preparing"}),this.preparing=this.prepareFor(plan).then(ready=>{this.state=ready,this.log(`browser: ${this.describe()}`)},error62=>{this.state=previous2?{...previous2,fingerprint:this.fingerprintOr(previous2)}:{kind:"failed",reason:message(error62)},this.log(`browser: Chrome could not be prepared (${message(error62)}); ${previous2?"keeping the browser already set up":"bots keep the engine's own browser"}`)}).
2996
+ finally(()=>{this.preparing=null}),this.preparing}async ready(spec){if(!this.uses(spec))return;let timer2,done=await Promise.race([this.prepare().then(()=>!0),new Promise(resolve36=>{timer2=setTimeout(()=>resolve36(!1),this.options.readyWaitMs),timer2.unref?.()})]);if(clearTimeout(timer2),!done){let state=this.state;throw new Error(state.kind==="downloading"?`Getting the browser ready (${megabytes(state.progress.received)} of ${megabytes(state.progress.total)} MB). Try again in a minute.`:"Getti\
2997
+ ng the browser ready. Try again in a moment.")}if(this.state.kind==="failed")throw new Error(`Chrome could not be started (${this.state.reason}). Try again: your next browser call uses the built-in browser.`)}async started(session,spec){this.state.kind!=="ready"||!this.uses(spec)||!ownsBrowserViewport(spec.env??{})||await this.sidecars.ensure(session,spec,{...this.state.identity,acceptLanguage:languageList(browserLanguage(this.options.env))})}stopped(session){this.sidecars.forget(session)}describe(){
2998
+ let state=this.state;if(state.kind==="ready")return`${product(state.chrome,state.identity)} ${state.identity.userAgentMetadata.fullVersion.split(".")[0]} (${SOURCES[state.chrome.source]})`;let plan=this.plan();return plan.kind==="legacy"?`${this.engineBrowser()} (${plan.reason})`:state.kind==="failed"?`${this.engineBrowser()} (Chrome could not be started: ${state.reason})`:state.kind==="downloading"?`Chrome for Testing ${state.pin.version} (downloading: ${megabytes(state.progress.received)} of ${megabytes(
2999
+ state.progress.total)} MB)`:plan.kind==="download"?`Chrome for Testing ${plan.pin.version} (not downloaded yet)`:`${product(plan.chrome)} (${SOURCES[plan.chrome.source]}; not started yet)`}chromeEnv(){return this.options.platform==="darwin"?{...this.options.env,HOME:userInfo4().homedir}:this.options.env}uses(spec){if(!spec.env||attachesToChrome(spec.env))return!1;let executable=spec.env.AGENT_BROWSER_EXECUTABLE_PATH;return executable===this.path||this.options.platform==="win32"&&this.state.kind===
3000
+ "ready"&&executable===this.state.chrome.path}fresh(state){try{return chromeFingerprint(state.chrome.path)===state.fingerprint}catch{return!1}}fingerprintOr(state){try{return chromeFingerprint(state.chrome.path)}catch{return state.fingerprint}}async prepareFor(plan){let chrome=plan.kind==="download"?await this.download(plan.pin):plan.chrome,identity;try{identity=await this.identityOf(chrome)}catch(error62){if(plan.kind!=="chrome"||plan.chrome.source!=="installed"||!plan.fallback)throw error62;this.
3001
+ log(`browser: Google Chrome at ${chrome.path} could not start headless (${message(error62)}); using Chrome for Testing`),chrome=await this.download(plan.fallback),identity=await this.identityOf(chrome)}let{env,platform}=this.options,launcher;return this.options.wrapper!==!1&&(this.screen??=this.options.screen?this.options.screen():primaryScreen(platform,env),launcher={chrome:chrome.path,userAgent:identity.userAgent,screen:await this.screen,language:browserLanguage(env),timeZone:browserTimeZone(env,
3002
+ platform),...platform==="darwin"?{home:userInfo4().homedir}:{},...this.boxed()},platform!=="win32"&&(writeLauncher(this.path,launcher,platform),await(this.options.checkLauncher??runsLauncher)(this.path,this.chromeEnv()))),{kind:"ready",chrome,identity:{userAgent:identity.userAgent,userAgentMetadata:identity.userAgentMetadata},product:identity.product,fingerprint:chromeFingerprint(chrome.path),...launcher?{launcher}:{}}}async download(pin){return this.state={kind:"downloading",pin,progress:{received:0,
3003
+ total:pin.bytes}},{path:await(this.options.install??installChromeForTesting)({dataDir:this.options.dataDir,pin,onProgress:progress=>{this.state.kind==="downloading"&&(this.state={...this.state,progress})}}),source:"downloaded"}}async identityOf(chrome){let env=this.chromeEnv(),injected=this.options.calibrate,calibrate=injected?async options3=>{let read2=await injected(options3.executablePath,env);return{...read2,product:`Chrome/${read2.userAgentMetadata.fullVersion}`,fingerprint:chromeFingerprint(
3004
+ options3.executablePath),calibratedAt:new Date().toISOString()}}:calibrateIdentity,host2=this.options.platform==="linux"&&existsSync22("/.dockerenv")?"container":"desktop",options2={executablePath:chrome.path,host:host2,env,sandbox:this.options.sandbox??!needsNoSandbox(env)};return(await loadOrCalibrateIdentity(this.options.dataDir,options2,calibrate)).identity}async binary(){let plan=this.plan();if(plan.kind==="legacy")throw new Error(`no Chrome to run here (${plan.reason})`);let timer2,done=await Promise.
3005
+ race([this.prepare().then(()=>!0),new Promise(resolve36=>{timer2=setTimeout(()=>resolve36(!1),this.options.readyWaitMs),timer2.unref?.()})]);clearTimeout(timer2);let state=this.state;if(!done)throw new Error(state.kind==="downloading"?`Getting the browser ready (${megabytes(state.progress.received)} of ${megabytes(state.progress.total)} MB). Try again in a minute.`:"Getting the browser ready. Try again in a moment.");if(state.kind==="failed")throw new Error(`Chrome could not be started (${state.
3006
+ reason}).`);if(state.kind!=="ready")throw new Error("Chrome is not ready yet. Try again in a moment.");return{path:state.chrome.path,identity:state.identity,product:state.product,source:state.chrome.source}}managedEngine(){let status2=browserEngineStatus({dataDir:this.options.dataDir,env:this.options.env,platform:this.options.platform,arch:this.options.arch});return status2.kind==="ready"?{managed:status2.managed}:null}engineBrowser(){let named2=this.options.env.AGENT_BROWSER_EXECUTABLE_PATH?.trim();
3007
+ return named2||(this.options.env.OMB_RESOURCES_PATH?"the bundled Chromium headless shell":"agent-browser's own browser")}log(line3){(this.options.log??console.log)(line3)}};chromeLauncher=new ChromeLauncher({dataDir:DATA_DIR,host:chromeHost({dataDir:DATA_DIR,enginePath:augmentedPath})})}});import{execFileSync as execFileSync2}from"node:child_process";import{createHash as createHash11,randomUUID as randomUUID6}from"node:crypto";import{existsSync as existsSync23,linkSync,mkdirSync as mkdirSync17,readdirSync as readdirSync12,readFileSync as readFileSync19,readlinkSync as readlinkSync2,renameSync as renameSync9,unlinkSync as unlinkSync4,writeFileSync as writeFileSync11}from"node:fs";import{hostname as hostname5,uptime}from"node:os";import{join as join38}from"node:path";function leaseError(message5,cause){
3007
3008
  return Object.assign(new DataDirLeaseError(message5),{cause})}function isPid(value){return Number.isInteger(value)&&value>0&&value<=MAX_PID}function readBootSession(){try{if(process.platform==="linux")return normalizeBootId(readFileSync19("/proc/sys/kernel/random/boot_id","utf8"));if(process.platform==="darwin")return normalizeBootId(execFileSync2("/usr/sbin/sysctl",["-n","kern.bootsessionuuid"],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","ignore"]}))}catch{}return null}function normalizeBootId(value){
3008
3009
  let id=String(value).trim();return id.length>0&&id.length<=MAX_BOOT_ID&&!/[^0-9A-Za-z:_.-]/.test(id)?id:null}function bootSession(){return cachedBootSession===void 0&&(cachedBootSession=readBootSession()),cachedBootSession}function uptimeMs(){let seconds=uptime();return Number.isFinite(seconds)&&seconds>=0?Math.floor(seconds*1e3):0}function isBootIdentity(value){return value===null||typeof value=="string"&&normalizeBootId(value)===value}function readPidNamespace(){if(process.platform!=="linux")return null;
3009
3010
  try{return/^pid:\[([1-9][0-9]{0,19})\]$/.exec(readlinkSync2("/proc/self/ns/pid"))?.[1]??null}catch{return null}}function pidNamespace(){return cachedPidNamespace===void 0&&(cachedPidNamespace=readPidNamespace()),cachedPidNamespace}function isPidNamespace(value){return value===null||typeof value=="string"&&/^[1-9][0-9]{0,19}$/.test(value)}function processStartTicks(pid){if(process.platform!=="linux")return null;let stat9;try{stat9=readFileSync19(`/proc/${pid}/stat`,"utf8")}catch{return null}let ticks=Number(
@@ -1 +1 @@
1
- {"type":"module","version":"0.3.115"}
1
+ {"type":"module","version":"0.3.117"}
@@ -2987,22 +2987,23 @@ ts"(){"use strict";init_atomic();init_gate();LAUNCHER_SECCOMP_FD=9;run3=(file2,a
2987
2987
  if(!error62||error62.killed)return resolve36();reject(new Error(`the browser launcher does not run here: ${error62.message}`))})})}function product(chrome,identity){return identity?.userAgentMetadata.brands.some(({brand})=>brand==="Google Chrome")||chrome.source==="installed"?"Google Chrome":chrome.source==="downloaded"||/for Testing|chrome-(?:linux|mac|win)/iu.test(chrome.path)?"Chrome for Testing":"Chromium"}var SOURCES,megabytes,message,ChromeLauncher,chromeLauncher,init_launcher=__esm({"serv\
2988
2988
  er/browser/chrome/launcher.ts"(){"use strict";init_browser_engine();init_browser_runtime();init_config3();init_env_path();init_calibrate();init_identity2();init_install();init_resolve();init_sidecar();init_wrapper();SOURCES={installed:"installed",downloaded:"downloaded",named:"named by OMB_CHROME_PATH or AGENT_BROWSER_EXECUTABLE_PATH","agent-browser":"installed by agent-browser"},megabytes=bytes2=>Math.round(bytes2/1048576),message=error62=>error62 instanceof Error?error62.message:String(error62);
2989
2989
  ChromeLauncher=class{path;state={kind:"idle"};preparing=null;screen=null;options;host;sidecars;box=null;constructor(options2){let env=options2.env??process.env,platform=options2.platform??process.platform;this.options={...options2,env,platform,readyWaitMs:options2.readyWaitMs??45e3},this.host=options2.host??chromeHost({dataDir:options2.dataDir,env,platform,arch:options2.arch}),this.sidecars=options2.sidecars??new IdentitySidecars,this.path=launcherPath(options2.dataDir,platform)}boxWith(box2){if(this.
2990
- box=box2,this.state.kind==="ready"&&this.state.launcher){let launcher={...this.state.launcher,...this.boxed()};writeLauncher(this.path,launcher,this.options.platform),this.state={...this.state,launcher}}}boxed(){let box2=this.box?.()??null;return box2?{box:box2}:{}}plan(){let downloading=this.state.kind==="preparing"||this.state.kind==="downloading";return resolveChromePlan(this.host,this.options.engine?this.options.engine():this.managedEngine(),{downloading})}env(){return this.state.kind==="fai\
2991
- led"||this.plan().kind==="legacy"?{}:(this.prepare(),this.followTimeZone(),{AGENT_BROWSER_EXECUTABLE_PATH:this.path,AGENT_BROWSER_HIDE_SCROLLBARS:"0"})}followTimeZone(){let state=this.state;if(state.kind!=="ready"||!state.launcher)return;let timeZone=browserTimeZone(this.options.env,this.options.platform);if(timeZone===state.launcher.timeZone)return;let launcher={...state.launcher,timeZone};try{writeLauncher(this.path,launcher,this.options.platform),this.state={...state,launcher},this.log(`brows\
2992
- er: the next browser started tells time in ${timeZone??"the system's zone"}`)}catch(error62){this.log(`browser: could not move the browser to ${timeZone??"the system's zone"} (${message(error62)})`)}}start(){this.plan().kind!=="legacy"&&this.prepare()}prepare(){if(this.preparing)return this.preparing;if(this.state.kind==="failed"||this.state.kind==="ready"&&this.fresh(this.state))return Promise.resolve();let plan=this.plan();if(plan.kind==="legacy")return Promise.resolve();let previous2=this.state.
2993
- kind==="ready"?this.state:null;return previous2||(this.state={kind:"preparing"}),this.preparing=this.prepareFor(plan).then(ready=>{this.state=ready,this.log(`browser: ${this.describe()}`)},error62=>{this.state=previous2?{...previous2,fingerprint:this.fingerprintOr(previous2)}:{kind:"failed",reason:message(error62)},this.log(`browser: Chrome could not be prepared (${message(error62)}); ${previous2?"keeping the browser already set up":"bots keep the engine's own browser"}`)}).finally(()=>{this.preparing=
2994
- null}),this.preparing}async ready(spec){if(!this.uses(spec))return;let timer2,done=await Promise.race([this.prepare().then(()=>!0),new Promise(resolve36=>{timer2=setTimeout(()=>resolve36(!1),this.options.readyWaitMs),timer2.unref?.()})]);if(clearTimeout(timer2),!done){let state=this.state;throw new Error(state.kind==="downloading"?`Getting the browser ready (${megabytes(state.progress.received)} of ${megabytes(state.progress.total)} MB). Try again in a minute.`:"Getting the browser ready. Try ag\
2995
- ain in a moment.")}if(this.state.kind==="failed")throw new Error(`Chrome could not be started (${this.state.reason}). Try again: your next browser call uses the built-in browser.`)}async started(session,spec){this.state.kind!=="ready"||!this.uses(spec)||!ownsBrowserViewport(spec.env??{})||await this.sidecars.ensure(session,spec,{...this.state.identity,acceptLanguage:languageList(browserLanguage(this.options.env))})}stopped(session){this.sidecars.forget(session)}describe(){let state=this.state;if(state.
2996
- kind==="ready")return`${product(state.chrome,state.identity)} ${state.identity.userAgentMetadata.fullVersion.split(".")[0]} (${SOURCES[state.chrome.source]})`;let plan=this.plan();return plan.kind==="legacy"?`${this.engineBrowser()} (${plan.reason})`:state.kind==="failed"?`${this.engineBrowser()} (Chrome could not be started: ${state.reason})`:state.kind==="downloading"?`Chrome for Testing ${state.pin.version} (downloading: ${megabytes(state.progress.received)} of ${megabytes(state.progress.total)}\
2997
- MB)`:plan.kind==="download"?`Chrome for Testing ${plan.pin.version} (not downloaded yet)`:`${product(plan.chrome)} (${SOURCES[plan.chrome.source]}; not started yet)`}chromeEnv(){return this.options.platform==="darwin"?{...this.options.env,HOME:userInfo4().homedir}:this.options.env}uses(spec){return spec.env?.AGENT_BROWSER_EXECUTABLE_PATH===this.path&&!attachesToChrome(spec.env)}fresh(state){try{return chromeFingerprint(state.chrome.path)===state.fingerprint}catch{return!1}}fingerprintOr(state){
2998
- try{return chromeFingerprint(state.chrome.path)}catch{return state.fingerprint}}async prepareFor(plan){let chrome=plan.kind==="download"?await this.download(plan.pin):plan.chrome,identity;try{identity=await this.identityOf(chrome)}catch(error62){if(plan.kind!=="chrome"||plan.chrome.source!=="installed"||!plan.fallback)throw error62;this.log(`browser: Google Chrome at ${chrome.path} could not start headless (${message(error62)}); using Chrome for Testing`),chrome=await this.download(plan.fallback),
2999
- identity=await this.identityOf(chrome)}let{env,platform}=this.options,launcher;return this.options.wrapper!==!1&&(this.screen??=this.options.screen?this.options.screen():primaryScreen(platform,env),launcher={chrome:chrome.path,userAgent:identity.userAgent,screen:await this.screen,language:browserLanguage(env),timeZone:browserTimeZone(env,platform),...platform==="darwin"?{home:userInfo4().homedir}:{},...this.boxed()},writeLauncher(this.path,launcher,platform),platform!=="win32"&&await(this.options.
3000
- checkLauncher??runsLauncher)(this.path,this.chromeEnv())),{kind:"ready",chrome,identity:{userAgent:identity.userAgent,userAgentMetadata:identity.userAgentMetadata},product:identity.product,fingerprint:chromeFingerprint(chrome.path),...launcher?{launcher}:{}}}async download(pin){return this.state={kind:"downloading",pin,progress:{received:0,total:pin.bytes}},{path:await(this.options.install??installChromeForTesting)({dataDir:this.options.dataDir,pin,onProgress:progress=>{this.state.kind==="downlo\
3001
- ading"&&(this.state={...this.state,progress})}}),source:"downloaded"}}async identityOf(chrome){let env=this.chromeEnv(),injected=this.options.calibrate,calibrate=injected?async options3=>{let read2=await injected(options3.executablePath,env);return{...read2,product:`Chrome/${read2.userAgentMetadata.fullVersion}`,fingerprint:chromeFingerprint(options3.executablePath),calibratedAt:new Date().toISOString()}}:calibrateIdentity,host2=this.options.platform==="linux"&&existsSync22("/.dockerenv")?"conta\
3002
- iner":"desktop",options2={executablePath:chrome.path,host:host2,env,sandbox:this.options.sandbox??!needsNoSandbox(env)};return(await loadOrCalibrateIdentity(this.options.dataDir,options2,calibrate)).identity}async binary(){let plan=this.plan();if(plan.kind==="legacy")throw new Error(`no Chrome to run here (${plan.reason})`);let timer2,done=await Promise.race([this.prepare().then(()=>!0),new Promise(resolve36=>{timer2=setTimeout(()=>resolve36(!1),this.options.readyWaitMs),timer2.unref?.()})]);clearTimeout(
3003
- timer2);let state=this.state;if(!done)throw new Error(state.kind==="downloading"?`Getting the browser ready (${megabytes(state.progress.received)} of ${megabytes(state.progress.total)} MB). Try again in a minute.`:"Getting the browser ready. Try again in a moment.");if(state.kind==="failed")throw new Error(`Chrome could not be started (${state.reason}).`);if(state.kind!=="ready")throw new Error("Chrome is not ready yet. Try again in a moment.");return{path:state.chrome.path,identity:state.identity,
3004
- product:state.product,source:state.chrome.source}}managedEngine(){let status2=browserEngineStatus({dataDir:this.options.dataDir,env:this.options.env,platform:this.options.platform,arch:this.options.arch});return status2.kind==="ready"?{managed:status2.managed}:null}engineBrowser(){let named2=this.options.env.AGENT_BROWSER_EXECUTABLE_PATH?.trim();return named2||(this.options.env.OMB_RESOURCES_PATH?"the bundled Chromium headless shell":"agent-browser's own browser")}log(line3){(this.options.log??console.
3005
- log)(line3)}};chromeLauncher=new ChromeLauncher({dataDir:DATA_DIR,host:chromeHost({dataDir:DATA_DIR,enginePath:augmentedPath})})}});import{execFileSync as execFileSync2}from"node:child_process";import{createHash as createHash11,randomUUID as randomUUID6}from"node:crypto";import{existsSync as existsSync23,linkSync,mkdirSync as mkdirSync17,readdirSync as readdirSync12,readFileSync as readFileSync19,readlinkSync as readlinkSync2,renameSync as renameSync9,unlinkSync as unlinkSync4,writeFileSync as writeFileSync11}from"node:fs";import{hostname as hostname5,uptime}from"node:os";import{join as join38}from"node:path";function leaseError(message5,cause){
2990
+ box=box2,this.state.kind==="ready"&&this.state.launcher){let launcher={...this.state.launcher,...this.boxed()};this.options.platform!=="win32"&&writeLauncher(this.path,launcher,this.options.platform),this.state={...this.state,launcher}}}boxed(){let box2=this.box?.()??null;return box2?{box:box2}:{}}plan(){let downloading=this.state.kind==="preparing"||this.state.kind==="downloading";return resolveChromePlan(this.host,this.options.engine?this.options.engine():this.managedEngine(),{downloading})}env(){
2991
+ if(this.state.kind==="failed"||this.plan().kind==="legacy")return{};if(this.prepare(),this.options.platform==="win32"){let settings2=this.state.kind==="ready"&&this.state.launcher;return settings2?{AGENT_BROWSER_EXECUTABLE_PATH:settings2.chrome,AGENT_BROWSER_USER_AGENT:settings2.userAgent,AGENT_BROWSER_ARGS:launcherFlags(settings2,"win32").filter(flag3=>!flag3.startsWith("--user-agent=")).join(`
2992
+ `),AGENT_BROWSER_HIDE_SCROLLBARS:"0"}:{}}return this.followTimeZone(),{AGENT_BROWSER_EXECUTABLE_PATH:this.path,AGENT_BROWSER_HIDE_SCROLLBARS:"0"}}followTimeZone(){let state=this.state;if(state.kind!=="ready"||!state.launcher)return;let timeZone=browserTimeZone(this.options.env,this.options.platform);if(timeZone===state.launcher.timeZone)return;let launcher={...state.launcher,timeZone};try{this.options.platform!=="win32"&&writeLauncher(this.path,launcher,this.options.platform),this.state={...state,
2993
+ launcher},this.log(`browser: the next browser started tells time in ${timeZone??"the system's zone"}`)}catch(error62){this.log(`browser: could not move the browser to ${timeZone??"the system's zone"} (${message(error62)})`)}}start(){this.plan().kind!=="legacy"&&this.prepare()}prepare(){if(this.preparing)return this.preparing;if(this.state.kind==="failed"||this.state.kind==="ready"&&this.fresh(this.state))return Promise.resolve();let plan=this.plan();if(plan.kind==="legacy")return Promise.resolve();
2994
+ let previous2=this.state.kind==="ready"?this.state:null;return previous2||(this.state={kind:"preparing"}),this.preparing=this.prepareFor(plan).then(ready=>{this.state=ready,this.log(`browser: ${this.describe()}`)},error62=>{this.state=previous2?{...previous2,fingerprint:this.fingerprintOr(previous2)}:{kind:"failed",reason:message(error62)},this.log(`browser: Chrome could not be prepared (${message(error62)}); ${previous2?"keeping the browser already set up":"bots keep the engine's own browser"}`)}).
2995
+ finally(()=>{this.preparing=null}),this.preparing}async ready(spec){if(!this.uses(spec))return;let timer2,done=await Promise.race([this.prepare().then(()=>!0),new Promise(resolve36=>{timer2=setTimeout(()=>resolve36(!1),this.options.readyWaitMs),timer2.unref?.()})]);if(clearTimeout(timer2),!done){let state=this.state;throw new Error(state.kind==="downloading"?`Getting the browser ready (${megabytes(state.progress.received)} of ${megabytes(state.progress.total)} MB). Try again in a minute.`:"Getti\
2996
+ ng the browser ready. Try again in a moment.")}if(this.state.kind==="failed")throw new Error(`Chrome could not be started (${this.state.reason}). Try again: your next browser call uses the built-in browser.`)}async started(session,spec){this.state.kind!=="ready"||!this.uses(spec)||!ownsBrowserViewport(spec.env??{})||await this.sidecars.ensure(session,spec,{...this.state.identity,acceptLanguage:languageList(browserLanguage(this.options.env))})}stopped(session){this.sidecars.forget(session)}describe(){
2997
+ let state=this.state;if(state.kind==="ready")return`${product(state.chrome,state.identity)} ${state.identity.userAgentMetadata.fullVersion.split(".")[0]} (${SOURCES[state.chrome.source]})`;let plan=this.plan();return plan.kind==="legacy"?`${this.engineBrowser()} (${plan.reason})`:state.kind==="failed"?`${this.engineBrowser()} (Chrome could not be started: ${state.reason})`:state.kind==="downloading"?`Chrome for Testing ${state.pin.version} (downloading: ${megabytes(state.progress.received)} of ${megabytes(
2998
+ state.progress.total)} MB)`:plan.kind==="download"?`Chrome for Testing ${plan.pin.version} (not downloaded yet)`:`${product(plan.chrome)} (${SOURCES[plan.chrome.source]}; not started yet)`}chromeEnv(){return this.options.platform==="darwin"?{...this.options.env,HOME:userInfo4().homedir}:this.options.env}uses(spec){if(!spec.env||attachesToChrome(spec.env))return!1;let executable=spec.env.AGENT_BROWSER_EXECUTABLE_PATH;return executable===this.path||this.options.platform==="win32"&&this.state.kind===
2999
+ "ready"&&executable===this.state.chrome.path}fresh(state){try{return chromeFingerprint(state.chrome.path)===state.fingerprint}catch{return!1}}fingerprintOr(state){try{return chromeFingerprint(state.chrome.path)}catch{return state.fingerprint}}async prepareFor(plan){let chrome=plan.kind==="download"?await this.download(plan.pin):plan.chrome,identity;try{identity=await this.identityOf(chrome)}catch(error62){if(plan.kind!=="chrome"||plan.chrome.source!=="installed"||!plan.fallback)throw error62;this.
3000
+ log(`browser: Google Chrome at ${chrome.path} could not start headless (${message(error62)}); using Chrome for Testing`),chrome=await this.download(plan.fallback),identity=await this.identityOf(chrome)}let{env,platform}=this.options,launcher;return this.options.wrapper!==!1&&(this.screen??=this.options.screen?this.options.screen():primaryScreen(platform,env),launcher={chrome:chrome.path,userAgent:identity.userAgent,screen:await this.screen,language:browserLanguage(env),timeZone:browserTimeZone(env,
3001
+ platform),...platform==="darwin"?{home:userInfo4().homedir}:{},...this.boxed()},platform!=="win32"&&(writeLauncher(this.path,launcher,platform),await(this.options.checkLauncher??runsLauncher)(this.path,this.chromeEnv()))),{kind:"ready",chrome,identity:{userAgent:identity.userAgent,userAgentMetadata:identity.userAgentMetadata},product:identity.product,fingerprint:chromeFingerprint(chrome.path),...launcher?{launcher}:{}}}async download(pin){return this.state={kind:"downloading",pin,progress:{received:0,
3002
+ total:pin.bytes}},{path:await(this.options.install??installChromeForTesting)({dataDir:this.options.dataDir,pin,onProgress:progress=>{this.state.kind==="downloading"&&(this.state={...this.state,progress})}}),source:"downloaded"}}async identityOf(chrome){let env=this.chromeEnv(),injected=this.options.calibrate,calibrate=injected?async options3=>{let read2=await injected(options3.executablePath,env);return{...read2,product:`Chrome/${read2.userAgentMetadata.fullVersion}`,fingerprint:chromeFingerprint(
3003
+ options3.executablePath),calibratedAt:new Date().toISOString()}}:calibrateIdentity,host2=this.options.platform==="linux"&&existsSync22("/.dockerenv")?"container":"desktop",options2={executablePath:chrome.path,host:host2,env,sandbox:this.options.sandbox??!needsNoSandbox(env)};return(await loadOrCalibrateIdentity(this.options.dataDir,options2,calibrate)).identity}async binary(){let plan=this.plan();if(plan.kind==="legacy")throw new Error(`no Chrome to run here (${plan.reason})`);let timer2,done=await Promise.
3004
+ race([this.prepare().then(()=>!0),new Promise(resolve36=>{timer2=setTimeout(()=>resolve36(!1),this.options.readyWaitMs),timer2.unref?.()})]);clearTimeout(timer2);let state=this.state;if(!done)throw new Error(state.kind==="downloading"?`Getting the browser ready (${megabytes(state.progress.received)} of ${megabytes(state.progress.total)} MB). Try again in a minute.`:"Getting the browser ready. Try again in a moment.");if(state.kind==="failed")throw new Error(`Chrome could not be started (${state.
3005
+ reason}).`);if(state.kind!=="ready")throw new Error("Chrome is not ready yet. Try again in a moment.");return{path:state.chrome.path,identity:state.identity,product:state.product,source:state.chrome.source}}managedEngine(){let status2=browserEngineStatus({dataDir:this.options.dataDir,env:this.options.env,platform:this.options.platform,arch:this.options.arch});return status2.kind==="ready"?{managed:status2.managed}:null}engineBrowser(){let named2=this.options.env.AGENT_BROWSER_EXECUTABLE_PATH?.trim();
3006
+ return named2||(this.options.env.OMB_RESOURCES_PATH?"the bundled Chromium headless shell":"agent-browser's own browser")}log(line3){(this.options.log??console.log)(line3)}};chromeLauncher=new ChromeLauncher({dataDir:DATA_DIR,host:chromeHost({dataDir:DATA_DIR,enginePath:augmentedPath})})}});import{execFileSync as execFileSync2}from"node:child_process";import{createHash as createHash11,randomUUID as randomUUID6}from"node:crypto";import{existsSync as existsSync23,linkSync,mkdirSync as mkdirSync17,readdirSync as readdirSync12,readFileSync as readFileSync19,readlinkSync as readlinkSync2,renameSync as renameSync9,unlinkSync as unlinkSync4,writeFileSync as writeFileSync11}from"node:fs";import{hostname as hostname5,uptime}from"node:os";import{join as join38}from"node:path";function leaseError(message5,cause){
3006
3007
  return Object.assign(new DataDirLeaseError(message5),{cause})}function isPid(value){return Number.isInteger(value)&&value>0&&value<=MAX_PID}function readBootSession(){try{if(process.platform==="linux")return normalizeBootId(readFileSync19("/proc/sys/kernel/random/boot_id","utf8"));if(process.platform==="darwin")return normalizeBootId(execFileSync2("/usr/sbin/sysctl",["-n","kern.bootsessionuuid"],{encoding:"utf8",timeout:5e3,stdio:["ignore","pipe","ignore"]}))}catch{}return null}function normalizeBootId(value){
3007
3008
  let id=String(value).trim();return id.length>0&&id.length<=MAX_BOOT_ID&&!/[^0-9A-Za-z:_.-]/.test(id)?id:null}function bootSession(){return cachedBootSession===void 0&&(cachedBootSession=readBootSession()),cachedBootSession}function uptimeMs(){let seconds=uptime();return Number.isFinite(seconds)&&seconds>=0?Math.floor(seconds*1e3):0}function isBootIdentity(value){return value===null||typeof value=="string"&&normalizeBootId(value)===value}function readPidNamespace(){if(process.platform!=="linux")return null;
3008
3009
  try{return/^pid:\[([1-9][0-9]{0,19})\]$/.exec(readlinkSync2("/proc/self/ns/pid"))?.[1]??null}catch{return null}}function pidNamespace(){return cachedPidNamespace===void 0&&(cachedPidNamespace=readPidNamespace()),cachedPidNamespace}function isPidNamespace(value){return value===null||typeof value=="string"&&/^[1-9][0-9]{0,19}$/.test(value)}function processStartTicks(pid){if(process.platform!=="linux")return null;let stat9;try{stat9=readFileSync19(`/proc/${pid}/stat`,"utf8")}catch{return null}let ticks=Number(