@sourcegraph/amp 0.0.1773173082-gfe7cc2 → 0.0.1773203397-g13b2f7

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 (2) hide show
  1. package/dist/main.js +11 -11
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -830,7 +830,7 @@ Image files are handled as attachments and displayed in the UI.`);let D=X.split(
830
830
  `;Q.push(Y)}return Q.join("")}function Mc6(J){if(J.startsWith("/"))return!0;if(J.match(/^[A-Za-z]:[\\]/)||J.match(/^[A-Za-z]:[/]/))return!0;return!1}function Ic6(J){return Ac6.includes(V1.basename(J))}var Ac6;var uU=Z0(()=>{Q4();h0();xm1();vX();Ro();kX();ko();SJ();Ac6=["yarn.lock","package-lock.json","pnpm-lock.yaml","go.sum","go.mod","Cargo.lock","poetry.lock","Pipfile.lock","composer.lock","Gemfile.lock"]});function xU(J,Z="result"){if(J===null)return`<${Z}>null</${Z}>`;if(J===void 0)return`<${Z}>undefined</${Z}>`;if(typeof J==="string")return`<${Z}>${J}</${Z}>`;if(typeof J==="number"||typeof J==="boolean")return`<${Z}>${J}</${Z}>`;if(Array.isArray(J))return`<${Z}>${JSON.stringify(J)}</${Z}>`;if(typeof J==="object")return Object.entries(J).map(([Q,Y])=>{if(typeof Y==="object"&&Y!==null&&!Array.isArray(Y)){let X=xU(Y,Q);return`<${Q}>
831
831
  ${X}
832
832
  </${Q}>`}return xU(Y,Q)}).join(`
833
- `);return`<${Z}>${String(J)}</${Z}>`}function fm1(J){return J+ ++jc6}var jc6=0;function bm1(J){if(!J._regex)try{J._regex=new RegExp(J.pattern,J.caseInsensitive?"gi":"g")}catch(Z){j.warn("Error compiling regex",{pattern:J.id,error:Z}),J._regex=/$^/}return J._regex}var hm1;var mm1=Z0(()=>{h0();hm1=[{id:"sourcegraph-access-token-v3",category:"sourcegraph",title:"Sourcegraph Access Token (v3)",pattern:String.raw`(sgp_(?:[a-fA-F0-9]{16}|local)_[a-fA-F0-9]{40})`,keywords:["sgp_"]},{id:"sourcegraph-access-token-v2",category:"sourcegraph",title:"Sourcegraph Access Token (v2, deprecated)",pattern:String.raw`(sgp_[a-fA-F0-9]{40})`,keywords:["sgp_"]},{id:"sourcegraph-dotcom-user-gateway",category:"sourcegraph",title:"Sourcegraph Dotcom User Gateway Access Token",pattern:String.raw`(sgd_[a-fA-F0-9]{64})`,keywords:["sgd_"]},{id:"sourcegraph-license-key",category:"sourcegraph",title:"Sourcegraph License Key Token",pattern:String.raw`(slk_[a-fA-F0-9]{64})`,keywords:["slk_"]},{id:"sourcegraph-enterprise-subscription",category:"sourcegraph",title:"Sourcegraph Enterprise subscription Token",pattern:String.raw`(sgs_[a-fA-F0-9]{64})`,keywords:["sgs_"]},{id:"sourcegraph-amp",category:"sourcegraph",title:"Sourcegraph Amp Access Token",pattern:String.raw`(sgamp_user_[A-Z0-9]{26}_[a-f0-9]{64})`,keywords:["sgamp_user_"]},{id:"sourcegraph-amp-auth-bypass",category:"sourcegraph",title:"Sourcegraph Amp Auth Bypass Token",pattern:String.raw`(sgamp_user_auth-bypass_[a-zA-Z0-9_-]+)`,keywords:["sgamp_user_auth-bypass_"]},{id:"sourcegraph-workspace-token",category:"sourcegraph",title:"Sourcegraph Workspace Access Token",pattern:String.raw`(sgp_ws[a-fA-F0-9]{32}_[a-fA-F0-9]{40})`,keywords:["sgp_ws"]},{id:"github-pat",category:"github",title:"GitHub Personal Access Token",pattern:String.raw`(ghp_[0-9a-zA-Z]{36})`,keywords:["ghp_"]},{id:"github-oauth",category:"github",title:"GitHub OAuth Access Token",pattern:String.raw`(gho_[0-9a-zA-Z]{36})`,keywords:["gho_"]},{id:"github-app-token",category:"github",title:"GitHub App Token",pattern:String.raw`((ghu|ghs)_[0-9a-zA-Z]{36})`,keywords:["ghu_","ghs_"]},{id:"github-refresh-token",category:"github",title:"GitHub Refresh Token",pattern:String.raw`(ghr_[0-9a-zA-Z]{76})`,keywords:["ghr_"]},{id:"github-fine-grained-pat",category:"github",title:"GitHub Fine-grained personal access tokens",pattern:String.raw`(github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59})`,keywords:["github_pat_"]},{id:"gitlab-pat",category:"gitlab",title:"GitLab Personal Access Token",pattern:String.raw`(glpat-[0-9a-zA-Z_-]{20})`,keywords:["glpat-"]},{id:"bitbucket-pat",category:"bitbucket",title:"Bitbucket Personal Access Token",pattern:String.raw`(bbpat-[A-Za-z0-9]{20,200})`,keywords:["bbpat-"]},{id:"bitbucket-repo-access-token",category:"bitbucket",title:"Bitbucket Repository Access Token",pattern:String.raw`(bbrat-[A-Za-z0-9]{20,200})`,keywords:["bbrat-"]},{id:"bitbucket-dc-http-token",category:"bitbucket",title:"Bitbucket DC/Server HTTP Access Token",pattern:String.raw`(?:[a-z0-9_ .,-]{0,25}bitbucket[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([A-Za-z0-9+/]{40,80}={0,2})['"]`,keywords:["bitbucket"]},{id:"aws-access-key-id",category:"aws",title:"AWS Access Key ID",pattern:String.raw`((A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16})`,keywords:["AKIA","AGPA","AIDA","AROA","AIPA","ANPA","ANVA","ASIA"]},{id:"hugging-face-access-token",category:"huggingface",title:"Hugging Face Access Token",pattern:String.raw`(hf_[A-Za-z0-9]{34,40})`,keywords:["hf_"]},{id:"private-key",category:"asymmetric-private-key",title:"Asymmetric Private Key",pattern:String.raw`-----\s*?BEGIN[ A-Z0-9_-]*?PRIVATE KEY(?: BLOCK)?\s*?-----\s*([A-Za-z0-9=+/\s]+)\s*-----\s*?END[ A-Z0-9_-]*? PRIVATE KEY(?: BLOCK)?\s*?-----`,keywords:["-----"],caseInsensitive:!0},{id:"shopify-token",category:"shopify",title:"Shopify token",pattern:String.raw`(shp(ss|at|ca|pa)_[a-fA-F0-9]{32})`,keywords:["shpss_","shpat_","shpca_","shppa_"]},{id:"slack-access-token",category:"slack",title:"Slack token",pattern:String.raw`((xox[baoprs]-|xapp-|xwfp-)([0-9a-zA-Z-]{10,100}))`,keywords:["xoxb-","xoxa-","xoxp-","xoxr-","xoxs-","xoxo-","xapp-","xwfp-"]},{id:"slack-config-refresh-token",category:"slack",title:"Slack config refresh token",pattern:String.raw`(xoxe-\d-[a-zA-Z0-9]{146})`,caseInsensitive:!0,keywords:["xoxe-"]},{id:"slack-config-access-token",category:"slack",title:"Slack config access token",pattern:String.raw`(xoxe.xox[bp]-\d-[A-Z0-9]{163,166})`,caseInsensitive:!0,keywords:["xoxe.xoxb-","xoxe.xoxp-"]},{id:"slack-web-hook",category:"slack",title:"Slack Webhook",pattern:String.raw`(https:\/\/hooks\.slack\.com\/(services|triggers|workflows)\/[A-Za-z0-9+\/]{43,56})`,caseInsensitive:!0,keywords:["hooks.slack.com"]},{id:"stripe-secret-token",category:"stripe",title:"Stripe Secret Key",pattern:String.raw`(sk_(test|live)_[0-9a-z]{10,99})`,keywords:["sk_test_","sk_live_"],caseInsensitive:!0},{id:"supabase-service-key",category:"supabase",title:"Supabase Service Key",pattern:String.raw`(sbp_[a-fA-F0-9]{40})`,keywords:["sbp_"]},{id:"pypi-upload-token",category:"pypi",title:"PyPI upload token",pattern:String.raw`(pypi-AgEIcHlwaS5vcmc[A-Za-z0-9_-]{50,1000})`,keywords:["pypi-AgEIcHlwaS5vcmc"]},{id:"gcp-service-account",category:"google",title:"Google (GCP) Service-account",pattern:String.raw`("type": "service_account")`,keywords:['"type": "service_account"']},{id:"heroku-api-key",category:"heroku",title:"Heroku API Key",pattern:String.raw`(?:heroku[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"](\d[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})['"]`,keywords:["heroku"],caseInsensitive:!0},{id:"twilio-api-key",category:"twilio",title:"Twilio API Key",pattern:String.raw`(SK[0-9a-fA-F]{32})`,keywords:["SK"]},{id:"age-secret-key",category:"age",title:"Age secret key",pattern:String.raw`(AGE-SECRET-KEY-1[QPZRY9X8GF2TVDW0S3JN54KHCE6MUA7L]{58})`,keywords:["AGE-SECRET-KEY-1"]},{id:"jwt-token",category:"jwt",title:"JWT token",pattern:String.raw`(ey[a-zA-Z0-9]{17,}\.ey[a-zA-Z0-9/\\_-]{17,}\.(?:[a-zA-Z0-9/\\_-]{10,}={0,2})?)`,keywords:[".eyJ"]},{id:"npm-access-token",category:"npm",title:"npm access token",pattern:String.raw`(npm_[a-z0-9]{36})`,keywords:["npm_"],caseInsensitive:!0},{id:"sendgrid-api-token",category:"sendgrid",title:"SendGrid API token",pattern:String.raw`(SG\.[a-z0-9_.-]{66})`,keywords:["SG."],caseInsensitive:!0},{id:"aws-secret-access-key",category:"aws",title:"AWS Secret Access Key",pattern:String.raw`(aws[_-]secret[_-]access[_-]key[_-][A-Za-z0-9/+=]{40})`,keywords:["key"],caseInsensitive:!0},{id:"dockerconfig-secret",category:"docker",title:"Dockerconfig secret exposed",pattern:String.raw`((\.dockerconfigjson|dockercfg):\s*\|*\s*((ey|ew)+[A-Za-z0-9/+=]+))`,keywords:["dockerc"],caseInsensitive:!0},{id:"linear-api-token",category:"linear",title:"Linear API token",pattern:String.raw`(lin_api_[a-z0-9]{40})`,keywords:["lin_api_"],caseInsensitive:!0},{id:"sendinblue-api-token",category:"sendinblue",title:"Sendinblue API token",pattern:String.raw`(xkeysib-[a-f0-9]{64}-[a-z0-9]{16})`,keywords:["xkeysib-"],caseInsensitive:!0},{id:"planetscale-api-token",category:"planetscale",title:"PlanetScale API token",pattern:String.raw`(pscale_tkn_[a-z0-9_.-]{43})`,keywords:["pscale_tkn_"],caseInsensitive:!0},{id:"doppler-api-token",category:"doppler",title:"Doppler API token",pattern:String.raw`(dp\.pt\.[a-z0-9]{43})`,keywords:["dp.pt."],caseInsensitive:!0},{id:"discord-api-token",category:"discord",title:"Discord API key",pattern:String.raw`(?:discord[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-h0-9]{64})['"]`,keywords:["discord"],caseInsensitive:!0},{id:"pulumi-api-token",category:"pulumi",title:"Pulumi API token",pattern:String.raw`(pul-[a-f0-9]{40})`,keywords:["pul-"]},{id:"postman-api-token",category:"postman",title:"Postman API token",pattern:String.raw`(PMAK-[a-f0-9]{24}-[a-f0-9]{34})`,keywords:["PMAK-"],caseInsensitive:!0},{id:"facebook-token",category:"facebook",title:"Facebook token",pattern:String.raw`(?:facebook[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-f0-9]{32})['"]`,keywords:["facebook"],caseInsensitive:!0},{id:"twitter-token",category:"twitter",title:"Twitter token",pattern:String.raw`(?:twitter[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-f0-9]{35,44})['"]`,keywords:["twitter"],caseInsensitive:!0},{id:"adobe-client-id",category:"adobe",title:"Adobe Client ID (Oauth Web)",pattern:String.raw`(?:adobe[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-f0-9]{32})['"]`,keywords:["adobe"],caseInsensitive:!0},{id:"adobe-client-secret",category:"adobe",title:"Adobe Client Secret",pattern:String.raw`(p8e-[a-z0-9]{32})`,keywords:["p8e-"],caseInsensitive:!0},{id:"alibaba-access-key-id",category:"alibaba",title:"Alibaba AccessKey ID",pattern:String.raw`((LTAI)[a-z0-9]{20})`,keywords:["LTAI"],caseInsensitive:!0},{id:"alibaba-secret-key",category:"alibaba",title:"Alibaba Secret Key",pattern:String.raw`(?:alibaba[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{30})['"]`,keywords:["alibaba"],caseInsensitive:!0},{id:"asana-client-id",category:"asana",title:"Asana Client ID",pattern:String.raw`(?:asana[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([0-9]{16})['"]`,keywords:["asana"],caseInsensitive:!0},{id:"asana-client-secret",category:"asana",title:"Asana Client Secret",pattern:String.raw`(?:asana[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{32})['"]`,keywords:["asana"],caseInsensitive:!0},{id:"atlassian-api-token",category:"atlassian",title:"Atlassian API token",pattern:String.raw`(?:atlassian[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{24})['"]`,keywords:["atlassian"],caseInsensitive:!0},{id:"beamer-api-token",category:"beamer",title:"Beamer API token",pattern:String.raw`(?:beamer[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"](b_[a-z0-9=_-]{44})['"]`,keywords:["beamer"],caseInsensitive:!0},{id:"buildkite-agent-token",category:"buildkite",title:"Buildkite API Token V2",pattern:String.raw`(bkua_[a-fA-F0-9]{40})`,keywords:["bkua_"]},{id:"clojars-api-token",category:"clojars",title:"Clojars API token",pattern:String.raw`(CLOJARS_[a-z0-9]{60})`,keywords:["CLOJARS_"],caseInsensitive:!0},{id:"contentful-delivery-api-token",category:"contentful-delivery",title:"Contentful delivery API token",pattern:String.raw`(?:contentful[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9=_-]{43})['"]`,keywords:["contentful"],caseInsensitive:!0},{id:"databricks-api-token",category:"databricks",title:"Databricks API token",pattern:String.raw`(dapi[a-h0-9]{32})`,keywords:["dapi"]},{id:"discord-client-id",category:"discord",title:"Discord client ID",pattern:String.raw`(?:discord[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([0-9]{18})['"]`,keywords:["discord"],caseInsensitive:!0},{id:"discord-client-secret",category:"discord",title:"Discord client secret",pattern:String.raw`(?:discord[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9=_-]{32})['"]`,keywords:["discord"],caseInsensitive:!0},{id:"dropbox-api-secret",category:"dropbox",title:"Dropbox API secret/key",pattern:String.raw`(?:dropbox[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{15})['"]`,keywords:["dropbox"],caseInsensitive:!0},{id:"dropbox-short-lived-api-token",category:"dropbox",title:"Dropbox short lived API token",pattern:String.raw`(?:dropbox[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"](sl\.[a-z0-9=_-]{135})['"]`,keywords:["dropbox"],caseInsensitive:!0},{id:"dropbox-long-lived-api-token",category:"dropbox",title:"Dropbox long lived API token",pattern:String.raw`(?:dropbox[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{11}(AAAAAAAAAA)[a-z0-9_=-]{43})['"]`,keywords:["dropbox"],caseInsensitive:!0},{id:"duffel-api-token",category:"duffel",title:"Duffel API token",pattern:String.raw`(duffel_(test|live)_[a-z0-9_-]{43})`,keywords:["duffel_test_","duffel_live_"],caseInsensitive:!0},{id:"dynatrace-api-token",category:"dynatrace",title:"Dynatrace API token",pattern:String.raw`(dt0c01\.[a-z0-9]{24}\.[a-z0-9]{64})`,keywords:["dt0c01."],caseInsensitive:!0},{id:"easypost-api-token",category:"easypost",title:"EasyPost API token",pattern:String.raw`(EZ[AT]K[a-z0-9]{54})`,keywords:["EZAK","EZAT"],caseInsensitive:!0},{id:"fastly-api-token",category:"fastly",title:"Fastly API token",pattern:String.raw`(?:fastly[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9=_-]{32})['"]`,keywords:["fastly"],caseInsensitive:!0},{id:"finicity-client-secret",category:"finicity",title:"Finicity client secret",pattern:String.raw`(?:finicity[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{20})['"]`,keywords:["finicity"],caseInsensitive:!0},{id:"finicity-api-token",category:"finicity",title:"Finicity API token",pattern:String.raw`(?:finicity[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-f0-9]{32})['"]`,keywords:["finicity"],caseInsensitive:!0},{id:"flutterwave-public-key",category:"flutterwave",title:"Flutterwave public/secret key",pattern:String.raw`(FLW(PUB|SEC)K_TEST-[a-h0-9]{32}-X)`,keywords:["FLWSECK_TEST-","FLWPUBK_TEST-"],caseInsensitive:!0},{id:"flutterwave-enc-key",category:"flutterwave",title:"Flutterwave encrypted key",pattern:String.raw`(FLWSECK_TEST[a-h0-9]{12})`,keywords:["FLWSECK_TEST"]},{id:"frameio-api-token",category:"frameio",title:"Frame.io API token",pattern:String.raw`(fio-u-[a-z0-9_=-]{64})`,keywords:["fio-u-"],caseInsensitive:!0},{id:"gocardless-api-token",category:"gocardless",title:"GoCardless API token",pattern:String.raw`(live_[a-z0-9_=-]{40})`,keywords:["live_"],caseInsensitive:!0},{id:"grafana-api-token",category:"grafana",title:"Grafana API token",pattern:String.raw`(eyJrIjoi[a-z0-9_=-]{72,92})`,keywords:["eyJrIjoi"],caseInsensitive:!0},{id:"hashicorp-tf-api-token",category:"hashicorp",title:"HashiCorp Terraform user/org API token",pattern:String.raw`([a-z0-9]{14}\.atlasv1\.[a-z0-9_=-]{60,70})`,keywords:["atlasv1."],caseInsensitive:!0},{id:"hubspot-api-token",category:"hubspot",title:"HubSpot API token",pattern:String.raw`(?:hubspot[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-h0-9]{8}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{12})['"]`,keywords:["hubspot"],caseInsensitive:!0},{id:"intercom-api-token",category:"intercom",title:"Intercom API token",pattern:String.raw`(?:intercom[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9=_]{60})['"]`,keywords:["intercom"],caseInsensitive:!0},{id:"intercom-client-secret",category:"intercom",title:"Intercom client secret/ID",pattern:String.raw`(?:intercom[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-h0-9]{8}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{12})['"]`,keywords:["intercom"],caseInsensitive:!0},{id:"ionic-api-token",category:"ionic",title:"Ionic API token",pattern:String.raw`(?:ionic[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"](ion_[a-z0-9]{42})['"]`,keywords:["ionic"],caseInsensitive:!0},{id:"linear-client-secret",category:"linear",title:"Linear client secret/ID",pattern:String.raw`(?:linear[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-f0-9]{32})['"]`,keywords:["linear"],caseInsensitive:!0},{id:"lob-api-key",category:"lob",title:"Lob API Key",pattern:String.raw`(?:lob[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]((live|test)_[a-f0-9]{35})['"]`,keywords:["lob"],caseInsensitive:!0},{id:"mailchimp-api-key",category:"mailchimp",title:"Mailchimp API key",pattern:String.raw`(?:mailchimp[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-f0-9]{32}-us20)['"]`,keywords:["mailchimp"],caseInsensitive:!0},{id:"mailgun-token",category:"mailgun",title:"Mailgun private API token",pattern:String.raw`(?:mailgun[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]((pub)?key-[a-f0-9]{32})['"]`,keywords:["mailgun"],caseInsensitive:!0},{id:"mailgun-signing-key",category:"mailgun",title:"Mailgun webhook signing key",pattern:String.raw`(?:mailgun[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-h0-9]{32}-[a-h0-9]{8}-[a-h0-9]{8})['"]`,keywords:["mailgun"],caseInsensitive:!0},{id:"mapbox-api-token",category:"mapbox",title:"Mapbox API token",pattern:String.raw`(pk\.[a-z0-9]{60}\.[a-z0-9]{22})`,keywords:["pk."],caseInsensitive:!0},{id:"messagebird-api-token",category:"messagebird",title:"MessageBird API token",pattern:String.raw`(?:messagebird[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{25})['"]`,keywords:["messagebird"],caseInsensitive:!0},{id:"messagebird-client-id",category:"messagebird",title:"MessageBird API client ID",pattern:String.raw`(?:messagebird[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-h0-9]{8}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{12})['"]`,keywords:["messagebird"],caseInsensitive:!0},{id:"new-relic-user-api-key",category:"newrelic",title:"New Relic user API Key",pattern:String.raw`(NRAK-[A-Z0-9]{27})`,keywords:["NRAK-"]},{id:"new-relic-user-api-id",category:"newrelic",title:"New Relic user API ID",pattern:String.raw`(?:newrelic[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([A-Z0-9]{64})['"]`,keywords:["newrelic"],caseInsensitive:!0},{id:"new-relic-browser-api-token",category:"newrelic",title:"New Relic ingest browser API token",pattern:String.raw`(NRJS-[a-f0-9]{19})`,keywords:["NRJS-"]},{id:"planetscale-password",category:"planetscale",title:"PlanetScale password",pattern:String.raw`(pscale_pw_[a-z0-9_.-]{43})`,keywords:["pscale_pw_"],caseInsensitive:!0},{id:"private-packagist-token",category:"private-packagist",title:"Private Packagist token",pattern:String.raw`(packagist_[ou][ru]t_[a-f0-9]{68})`,keywords:["packagist_uut_","packagist_ort_","packagist_out_"],caseInsensitive:!0},{id:"rubygems-api-token",category:"rubygems",title:"Rubygem API token",pattern:String.raw`(rubygems_[a-f0-9]{48})`,keywords:["rubygems_"]},{id:"shippo-api-token",category:"shippo",title:"Shippo API token",pattern:String.raw`(shippo_(live|test)_[a-f0-9]{40})`,keywords:["shippo_live_","shippo_test_"]},{id:"linkedin-client-secret",category:"linkedin",title:"LinkedIn Client secret",pattern:String.raw`(?:linkedin[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z]{16})['"]`,keywords:["linkedin"],caseInsensitive:!0},{id:"linkedin-client-id",category:"linkedin",title:"LinkedIn Client ID",pattern:String.raw`(?:linkedin[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{14})['"]`,keywords:["linkedin"],caseInsensitive:!0},{id:"twitch-api-token",category:"twitch",title:"Twitch API token",pattern:String.raw`(?:twitch[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{30})['"]`,keywords:["twitch"],caseInsensitive:!0},{id:"typeform-api-token",category:"typeform",title:"Typeform API token",pattern:String.raw`(?:typeform[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}(tfp_[a-z0-9_.=-]{59})`,keywords:["typeform"],caseInsensitive:!0},{id:"todoist-api-token",category:"todoist",title:"Todoist API token",pattern:String.raw`(?:todoist[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:)[\s'"]{0,3}([0-9a-f]{40})`,keywords:["todoist"],caseInsensitive:!0},{id:"openai-api-key",category:"openai",title:"OpenAI API Key",pattern:String.raw`(sk-[a-zA-Z0-9]{50})`,caseInsensitive:!1,keywords:["sk-"]},{id:"openai-api-key-project",category:"openai",title:"OpenAI Project-scoped API Key",pattern:String.raw`(sk-proj-[A-Za-z0-9]{24}-[A-Za-z0-9]{40,128})`,caseInsensitive:!0,keywords:["sk-proj-"]},{id:"openai-api-key-env",category:"openai",title:"OpenAI Environment-scoped API Key",pattern:String.raw`(sk-(?:live|test)-[A-Za-z0-9]{24}-[A-Za-z0-9]{40,128})`,caseInsensitive:!0,keywords:["sk-live-","sk-test-"]},{id:"anthropic-api-key",category:"anthropic",title:"Anthropic API Key",pattern:String.raw`(sk-ant-([a-zA-Z0-9]{1,10}-)?[a-zA-Z0-9_-]{32,128})`,caseInsensitive:!1,keywords:["sk-ant-"]},{id:"canva-token",category:"canva",title:"Canva Token",pattern:String.raw`\b(cnv[a-z0-9]{2}[A-Za-z0-9_=-]+[a-f0-9]{8})\b`,caseInsensitive:!1,keywords:["cnv"]},{id:"api-key",category:"unknown",title:"Unknown API Key",pattern:String.raw`(?:[a-z0-9_ .,-]{0,25}api[-_](?:key|token)(?!length|count|max|min|maxlength|_length|_count|_min|_maxlength)[a-z0-9_ .,-]{0,25})\s*(?:=|>|:=|\|\|:|<=|=>|:)\s*['"]?((?!.*(?:api|key|secret|foo|example|dummy|password|12345|abcde|placeholder|fake|token))[a-z0-9+/_-]{6,128})['"]?(?=\s|$|[;,\]})'"])`,keywords:["api-key","api_key","api-token","api_token"],caseInsensitive:!0},{id:"webhook-secret",category:"unknown",title:"Unknown Webhook Secret",pattern:String.raw`(?:[a-z0-9_ .,-]{0,25}webhook[-_]secret(?!length|count|max|min|maxlength|_length|_count|_min|_maxlength)[a-z0-9_ .,-]{0,25})\s*(?:=|>|:=|\|\|:|<=|=>|:)\s*['"]?((?!.*(?:api|key|secret|foo|example|dummy|password|12345|abcde|placeholder|fake|token|webhook))[a-z0-9+/=_-]{6,128})['"]?(?=\s|$|[;,\]})'"])`,keywords:["webhook-secret","webhook_secret"],caseInsensitive:!0},{id:"secret-value",category:"unknown",title:"Unknown API Key",pattern:String.raw`(?:[a-z0-9_ .,-]{0,25}[-_](?:secret)(?!length|count|max|min|maxlength|_length|_count|_min|_maxlength)[a-z0-9_ .,-]{0,25})\s*(?:=|>|:=|\|\|:|<=|=>|:)\s*['"]?((?!.*(?:api|key|secret|foo|example|dummy|password|12345|abcde|placeholder|fake|token))[a-z0-9+/_-]{6,128})['"]?(?=\s|$|[;,\]})'"])`,keywords:["secret"],caseInsensitive:!0},{id:"password",category:"unknown",title:"Unknown Password",pattern:String.raw`(?:[a-z0-9_ .,-]{0,25}password(?!length|count|max|min|maxlength|_length|_count|_min|_maxlength)[a-z0-9_ .,-]{0,25})\s*(?:=|>|:=|\|\|:|<=|=>|:)\s*['"]?((?!.*(?:api|key|secret|foo|example|dummy|password|12345|abcde|placeholder|fake|token|password|pass|pwd))[a-z0-9+/=_-]{6,128})['"]?(?=\s|$|[;,\]})'"])`,keywords:["password"],caseInsensitive:!0},{id:"sk-secret",category:"unknown",title:"Unknown SK Secret",pattern:String.raw`(?:^|['"\s])(sk(?:[-_][a-z0-9]{1,10})?[-_][a-z0-9]{10,99})(?:$|['"\s])`,caseInsensitive:!0,keywords:["sk-","sk_"]}]});function Pc6(J){if(!J||typeof J!=="string")return J;let Z=J.replace(Rc6,"");if(Z.length!==J.length){let Q=J.length-Z.length;j.info("Invisible Unicode tag characters removed during sanitization",{removedCount:Q})}return Z}function _c6(J){if(!J||typeof J!=="string")return J;let Z=T00.get(J);if(Z!==void 0)return Z;let Q=Pc6(J);for(let Y of hm1){if(!Y.keywords.some((V)=>Y.caseInsensitive?Q.toLowerCase().includes(V.toLowerCase()):Q.includes(V)))continue;let X=bm1(Y);Q=Q.replace(X,(V,K)=>{return V.replace(K,`[REDACTED:${Y.id}]`)})}if(J.length<=Tc6){if(T00.size>=Cc6)T00.clear();T00.set(J,Q)}return Q}function _00(J,Z){if(!J||typeof J==="number"||typeof J==="boolean")return J;if(typeof J==="string")return Z(J);if(Array.isArray(J))return J.map((Q)=>{if(typeof Q==="string")return Z(Q);else if(Q&&typeof Q==="object")return _00(Q,Z);return Q});if(J&&typeof J==="object"){if("type"in J&&(J.type==="base64"||J.type==="image")&&"data"in J)return{...J};if("isImage"in J&&J.isImage===!0&&"content"in J&&typeof J.content==="string"){let Q={};for(let[Y,X]of Object.entries(J))if(Y==="content")Q[Y]=X;else Q[Y]=_00(X,Z);return Q}}return Object.fromEntries(Object.entries(J).map(([Q,Y])=>[Q,_00(Y,Z)]))}function S00(J){return _00(J,_c6)}var Rc6,Cc6=2000,Tc6=512000,T00;var gm1=Z0(()=>{h0();mm1();Rc6=/[\uDB40][\uDC00-\uDC7F]/g;T00=new Map});function Sc6(J){return J?J.length>=k00:!1}function YR(J){if(J.nextMessageId===void 0)J.nextMessageId=0;return J.nextMessageId++}function vc6(J,Z){let Q=SI0(J["~debug"]?.lastInferenceUsage,Z);if(!Q)return;J["~debug"]={...J["~debug"]??{},lastInferenceUsage:Q}}function SI0(J,Z){if(!J)return Z;if(!Z)return J;let Q=(X,V)=>Math.max(X,V),Y=(X,V)=>{if(V===null)return X;if(X===null)return V;return Math.max(X,V)};return{model:Z.model??J.model,maxInputTokens:Q(J.maxInputTokens,Z.maxInputTokens),inputTokens:Q(J.inputTokens,Z.inputTokens),outputTokens:Q(J.outputTokens,Z.outputTokens),cacheCreationInputTokens:Y(J.cacheCreationInputTokens,Z.cacheCreationInputTokens),cacheReadInputTokens:Y(J.cacheReadInputTokens,Z.cacheReadInputTokens),totalInputTokens:Q(J.totalInputTokens,Z.totalInputTokens),thinkingBudget:Z.thinkingBudget??J.thinkingBudget,timestamp:Z.timestamp??J.timestamp}}function pm1(J,Z=new Date){return(Q)=>{switch(Q.v++,J.type){case"cancelled":{v00(Q);let Y=Q.messages.at(-1);if(Y?.role==="user"){let X=Y.content.findLast((V)=>V.type==="tool_result");if(X)X.run.status="cancelled"}break}case"user:message:interrupt":{let Y=Q.messages[J.messageIndex];if(Y?.role==="user")Y.interrupted=!0;break}case"user:message:append-content":{let Y=Q.messages.find((X)=>X.messageId===J.messageId);if(Y?.role==="user")Y.content.push(...R6(J.content));break}case"fork:created":{if(!Q.relationships)Q.relationships=[];if(!Q.relationships.some((X)=>X.threadID===J.forkThreadID&&X.type==="fork"&&X.role==="parent"&&X.messageIndex===J.fromMessageIndex))Q.relationships.push({threadID:J.forkThreadID,type:"fork",role:"parent",messageIndex:J.fromMessageIndex,createdAt:Date.now()});Q.v++;break}case"thread:truncate":{if(Q.messages.splice(J.fromIndex),Q.relationships){if(Q.relationships=Q.relationships.filter((Y)=>Y.messageIndex===void 0||Y.messageIndex<J.fromIndex),Q.relationships.length===0)Q.relationships=void 0}break}case"user:message":{if(v00(Q),Q.archived)Q.archived=!1;let Y={role:"user",...J.message,messageId:YR(Q),content:J.message.content??[]},X=S00(Y);if(J.index!==void 0){if(!Q.messages[J.index])throw Error(`user message at index ${J.index} not found`);let V=Q.messages[J.index];if(Q.messages.filter((D)=>D.role==="user")[0]===V&&Y.agentMode&&!Q.mainThreadID)Q.agentMode=Y.agentMode;Q.messages.splice(J.index,Q.messages.length-J.index,X)}else{let V=e3(Q)===0;if((!Q.agentMode||V)&&Y.agentMode&&!Q.mainThreadID)Q.agentMode=Y.agentMode;if(Q.messages.push(X),Q.draft)Q.draft=void 0}break}case"user:message-queue:dequeue":{if(v00(Q),!Q.queuedMessages)return;let[Y,...X]=Q.queuedMessages;if(!Y)return;Q.messages.push(Y.queuedMessage),Q.queuedMessages=X;break}case"user:tool-input":{if(!R$(Q,J.toolUse)){j.debug(`Ignoring user:tool-input delta for missing tool use ${J.toolUse} (likely deleted due to thread edit/truncation)`);break}let X=R6(HI(Q,J.toolUse));if(!X){j.debug(`Ignoring user:tool-input delta for missing tool result block ${J.toolUse} (likely deleted due to thread edit/truncation)`);break}X.userInput=J.value;break}case"tool:data":{if(!WI(Q,J.toolUse)){j.debug(`Ignoring tool:data delta for missing tool use ${J.toolUse} (likely deleted due to thread edit/truncation)`);break}let X=R6(S00(J.data));dm1(Q,J.toolUse,X);break}case"tool:processed":{let Y=WI(Q,J.toolUse);if(!Y){j.debug(`Ignoring tool:processed delta for missing tool use ${J.toolUse} (likely deleted due to thread edit/truncation)`);break}let X=Y.block.input;Y.block.input=J.newArgs,Y.message.originalToolUseInput={...Y.message.originalToolUseInput,[J.toolUse]:X};break}case"assistant:message":{let Y=u8(Q,"assistant"),X=Y?.content.filter((K)=>K.type==="tool_use").map((K)=>K.id)||[];if(v00(Q),Y?.state.type==="cancelled"){for(let K of Q.messages)if(K.role==="user")K.content=K.content.filter((z)=>{if(z.type==="tool_result"&&X.includes(z.toolUseID))return!1;return!0})}let V={...J.message,messageId:YR(Q)};Q.messages.push(R6(V));break}case"assistant:message-update":{let Y=R6(J.message),X=Q.messages.at(-1);if(X?.role==="assistant"){let V=SI0(X.usage,Y.usage);Q.messages[Q.messages.length-1]={...Y,messageId:X.messageId,usage:V}}else Q.messages.push({...Y,messageId:YR(Q)});break}case"inference:completed":{if(vc6(Q,J.usage),!Q.env)Q.env={initial:{}};if(!Q.env.initial.tags)Q.env.initial.tags=[];if(Q.env.initial.tags=Q.env.initial.tags.filter((Y)=>Y!=="model:undefined"),J.model){let Y=`model:${J.model}`;if(!Q.env.initial.tags.includes(Y))Q.env.initial.tags=[...Q.env.initial.tags,Y]}if(J.usage){let Y=R6(u8(Q,"assistant"));if(Y){let X=SI0(Y.usage,J.usage);if(X)Y.usage=X}}break}case"title":{Q.title=J.value||void 0;break}case"max-tokens":{Q.maxTokens=J.value||void 0;break}case"main-thread":{Q.mainThreadID=J.value||void 0;break}case"agent-mode":{if(e3(Q)>0)throw Error("(bug) cannot change agentMode after first message");Q.agentMode=J.mode;break}case"environment":{Q.env=R6(J.env);break}case"user:message-queue:enqueue":{if(!Q.queuedMessages)Q.queuedMessages=[];if(Sc6(Q.queuedMessages))break;let Y={role:"user",...J.message,messageId:YR(Q),content:J.message.content??[]},X=S00(Y);Q.queuedMessages.push({id:fm1("queued-"),queuedMessage:R6(X)});break}case"user:message-queue:discard":{if(J.id===void 0){Q.queuedMessages=[];break}let Y=Q.queuedMessages?.findIndex((X)=>X.id===J.id);if(Y===void 0)throw Error(`queued message with id ${J.id} not found`);Q?.queuedMessages?.splice(Y,1);break}case"info:manual-bash-invocation":{Q.messages.push({role:"info",messageId:YR(Q),content:[{type:"manual_bash_invocation",args:R6(J.args),toolRun:R6(J.toolRun),hidden:J.hidden}]});break}case"clearPendingNavigation":{Q.pendingNavigation=void 0;break}case"setPendingNavigation":{Q.pendingNavigation=J.threadID;break}case"relationship":{if(!Q.relationships)Q.relationships=[];if(!Q.relationships.some((X)=>X.threadID===J.relationship.threadID&&X.type===J.relationship.type&&X.role===J.relationship.role))Q.relationships.push(R6(J.relationship));break}case"draft":{if(Q.draft=R6(J.content),J.autoSubmit)Q.autoSubmitDraft=!0;break}case"trace:start":{kc6(Q,J.span);break}case"trace:end":{yc6(Q,J.span,Z);break}case"trace:event":{uc6(Q,J.span,J.event);break}case"trace:attributes":{xc6(Q,J.span,J.attributes);break}}}}function v00(J){let Z=R6(u8(J,"assistant"));if(!Z)return;let Q=!1;if(Z.state.type==="streaming")Z.state={type:"cancelled"},Q=!0;else if(Z.state.type==="complete"){if(Z.content.some((K)=>K.type==="tool_use"&&!t3(K)))Z.state={type:"cancelled"},Q=!0}if(!Q)return;let Y=CZ(J),X=[];for(let V=0;V<Z.content.length;V++){let K=Z.content[V];if(K?.type!=="tool_use")continue;if(!t3(K)){j.debug(`Cleaning up incomplete tool_use ${K.id}`,{name:"markPriorStreamingAssistantMessageAsCancelled",threadID:J.id,blockID:K.id});let z={type:"tool_use",id:K.id,name:K.name,complete:!0,input:K.inputIncomplete??K.input??{}};Z.content[V]=z}if(!Y.has(K.id))X.push(K.id)}for(let V of X)dm1(J,V,{status:"cancelled"})}function dm1(J,Z,Q){let Y,X=WI(J,Z);if(X){let K=X.messageIndex;for(let z=K+1;z<J.messages.length;z++){let D=J.messages[z];if(D?.role==="user"){Y=D;break}}}if(!Y)Y={role:"user",messageId:YR(J),content:[]},J.messages.push(Y);let V=HI(J,Z);if(V)V.run=R6(Q);else V={type:"tool_result",toolUseID:Z,run:R6(Q)},Y.content.push(V)}function kc6(J,Z){if(!J.meta)J.meta={};if(!J.meta.traces)J.meta.traces=[];let Q=J.meta.traces.find((Y)=>Y.id===Z.id);if(Q){if(Q.startTime===void 0)Q.startTime=Z.startTime;return}J.meta.traces.push(R6({...Z}))}function yc6(J,Z,Q){if(!J.meta)J.meta={};if(!J.meta.traces)J.meta.traces=[];let Y=J.meta.traces.find((V)=>V.id===Z.id),X=Z.endTime??Q.toISOString();if(Y){if(Y.endTime===void 0)Y.endTime=X}}function uc6(J,Z,Q){if(!J.meta?.traces)return;let Y=J.meta.traces.find((X)=>X.id===Z);if(!Y)return;if(!Y.events)Y.events=[];Y.events.push(Q)}function xc6(J,Z,Q){if(!J.meta?.traces)return;let Y=J.meta.traces.find((X)=>X.id===Z);if(!Y)return;Y.attributes={...Y.attributes,...Q}}function XR(J){try{return ia(J.replace(/\\+$/,"")+'"')}catch{return ia(J)}}var k00=5;var VR=Z0(()=>{f2();h0();gm1();b4()});function wY(J){let Z=[];if(J.currentlyVisibleFiles){if(J.currentlyVisibleFiles.length>0)Z.push(`Currently visible files user has open: ${J.currentlyVisibleFiles.map(f9).join(", ")}`)}if(J.runningTerminalCommands&&J.runningTerminalCommands.length>0)Z.push(`Currently running terminal commands:
833
+ `);return`<${Z}>${String(J)}</${Z}>`}function fm1(J){return J+ ++jc6}var jc6=0;function bm1(J){if(!J._regex)try{J._regex=new RegExp(J.pattern,J.caseInsensitive?"gi":"g")}catch(Z){j.warn("Error compiling regex",{pattern:J.id,error:Z}),J._regex=/$^/}return J._regex}var hm1;var mm1=Z0(()=>{h0();hm1=[{id:"sourcegraph-access-token-v3",category:"sourcegraph",title:"Sourcegraph Access Token (v3)",pattern:String.raw`(sgp_(?:[a-fA-F0-9]{16}|local)_[a-fA-F0-9]{40})`,keywords:["sgp_"]},{id:"sourcegraph-access-token-v2",category:"sourcegraph",title:"Sourcegraph Access Token (v2, deprecated)",pattern:String.raw`(sgp_[a-fA-F0-9]{40})`,keywords:["sgp_"]},{id:"sourcegraph-dotcom-user-gateway",category:"sourcegraph",title:"Sourcegraph Dotcom User Gateway Access Token",pattern:String.raw`(sgd_[a-fA-F0-9]{64})`,keywords:["sgd_"]},{id:"sourcegraph-license-key",category:"sourcegraph",title:"Sourcegraph License Key Token",pattern:String.raw`(slk_[a-fA-F0-9]{64})`,keywords:["slk_"]},{id:"sourcegraph-enterprise-subscription",category:"sourcegraph",title:"Sourcegraph Enterprise subscription Token",pattern:String.raw`(sgs_[a-fA-F0-9]{64})`,keywords:["sgs_"]},{id:"sourcegraph-amp",category:"sourcegraph",title:"Sourcegraph Amp Access Token",pattern:String.raw`(sgamp_user_[A-Z0-9]{26}_[a-f0-9]{64})`,keywords:["sgamp_user_"]},{id:"sourcegraph-amp-auth-bypass",category:"sourcegraph",title:"Sourcegraph Amp Auth Bypass Token",pattern:String.raw`(sgamp_user_auth-bypass_[a-zA-Z0-9_-]+)`,keywords:["sgamp_user_auth-bypass_"]},{id:"sourcegraph-workspace-token",category:"sourcegraph",title:"Sourcegraph Workspace Access Token",pattern:String.raw`(sgp_ws[a-fA-F0-9]{32}_[a-fA-F0-9]{40})`,keywords:["sgp_ws"]},{id:"github-pat",category:"github",title:"GitHub Personal Access Token",pattern:String.raw`(ghp_[0-9a-zA-Z]{36})`,keywords:["ghp_"]},{id:"github-oauth",category:"github",title:"GitHub OAuth Access Token",pattern:String.raw`(gho_[0-9a-zA-Z]{36})`,keywords:["gho_"]},{id:"github-app-token",category:"github",title:"GitHub App Token",pattern:String.raw`((ghu|ghs)_[0-9a-zA-Z]{36})`,keywords:["ghu_","ghs_"]},{id:"github-refresh-token",category:"github",title:"GitHub Refresh Token",pattern:String.raw`(ghr_[0-9a-zA-Z]{76})`,keywords:["ghr_"]},{id:"github-fine-grained-pat",category:"github",title:"GitHub Fine-grained personal access tokens",pattern:String.raw`(github_pat_[a-zA-Z0-9]{22}_[a-zA-Z0-9]{59})`,keywords:["github_pat_"]},{id:"gitlab-pat",category:"gitlab",title:"GitLab Personal Access Token",pattern:String.raw`(glpat-[0-9a-zA-Z_-]{20})`,keywords:["glpat-"]},{id:"bitbucket-pat",category:"bitbucket",title:"Bitbucket Personal Access Token",pattern:String.raw`(bbpat-[A-Za-z0-9]{20,200})`,keywords:["bbpat-"]},{id:"bitbucket-repo-access-token",category:"bitbucket",title:"Bitbucket Repository Access Token",pattern:String.raw`(bbrat-[A-Za-z0-9]{20,200})`,keywords:["bbrat-"]},{id:"bitbucket-dc-http-token",category:"bitbucket",title:"Bitbucket DC/Server HTTP Access Token",pattern:String.raw`(?:[a-z0-9_ .,-]{0,25}bitbucket[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([A-Za-z0-9+/]{40,80}={0,2})['"]`,keywords:["bitbucket"]},{id:"aws-access-key-id",category:"aws",title:"AWS Access Key ID",pattern:String.raw`((A3T[A-Z0-9]|AKIA|ASIA)[A-Z0-9]{16})`,keywords:["A3T","AKIA","ASIA"]},{id:"hugging-face-access-token",category:"huggingface",title:"Hugging Face Access Token",pattern:String.raw`(hf_[A-Za-z0-9]{34,40})`,keywords:["hf_"]},{id:"private-key",category:"asymmetric-private-key",title:"Asymmetric Private Key",pattern:String.raw`-----\s*?BEGIN[ A-Z0-9_-]*?PRIVATE KEY(?: BLOCK)?\s*?-----\s*([A-Za-z0-9=+/\s]+)\s*-----\s*?END[ A-Z0-9_-]*? PRIVATE KEY(?: BLOCK)?\s*?-----`,keywords:["-----"],caseInsensitive:!0},{id:"shopify-token",category:"shopify",title:"Shopify token",pattern:String.raw`(shp(ss|at|ca|pa)_[a-fA-F0-9]{32})`,keywords:["shpss_","shpat_","shpca_","shppa_"]},{id:"slack-access-token",category:"slack",title:"Slack token",pattern:String.raw`((xox[baoprs]-|xapp-|xwfp-)([0-9a-zA-Z-]{10,100}))`,keywords:["xoxb-","xoxa-","xoxp-","xoxr-","xoxs-","xoxo-","xapp-","xwfp-"]},{id:"slack-config-refresh-token",category:"slack",title:"Slack config refresh token",pattern:String.raw`(xoxe-\d-[a-zA-Z0-9]{146})`,caseInsensitive:!0,keywords:["xoxe-"]},{id:"slack-config-access-token",category:"slack",title:"Slack config access token",pattern:String.raw`(xoxe.xox[bp]-\d-[A-Z0-9]{163,166})`,caseInsensitive:!0,keywords:["xoxe.xoxb-","xoxe.xoxp-"]},{id:"slack-web-hook",category:"slack",title:"Slack Webhook",pattern:String.raw`(https:\/\/hooks\.slack\.com\/(services|triggers|workflows)\/[A-Za-z0-9+\/]{43,56})`,caseInsensitive:!0,keywords:["hooks.slack.com"]},{id:"stripe-secret-token",category:"stripe",title:"Stripe Secret Key",pattern:String.raw`(sk_(test|live)_[0-9a-z]{10,99})`,keywords:["sk_test_","sk_live_"],caseInsensitive:!0},{id:"supabase-service-key",category:"supabase",title:"Supabase Service Key",pattern:String.raw`(sbp_[a-fA-F0-9]{40})`,keywords:["sbp_"]},{id:"pypi-upload-token",category:"pypi",title:"PyPI upload token",pattern:String.raw`(pypi-AgEIcHlwaS5vcmc[A-Za-z0-9_-]{50,1000})`,keywords:["pypi-AgEIcHlwaS5vcmc"]},{id:"gcp-service-account",category:"google",title:"Google (GCP) Service-account",pattern:String.raw`("type": "service_account")`,keywords:['"type": "service_account"']},{id:"heroku-api-key",category:"heroku",title:"Heroku API Key",pattern:String.raw`(?:heroku[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"](\d[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12})['"]`,keywords:["heroku"],caseInsensitive:!0},{id:"twilio-api-key",category:"twilio",title:"Twilio API Key",pattern:String.raw`(SK[0-9a-fA-F]{32})`,keywords:["SK"]},{id:"age-secret-key",category:"age",title:"Age secret key",pattern:String.raw`(AGE-SECRET-KEY-1[QPZRY9X8GF2TVDW0S3JN54KHCE6MUA7L]{58})`,keywords:["AGE-SECRET-KEY-1"]},{id:"jwt-token",category:"jwt",title:"JWT token",pattern:String.raw`(ey[a-zA-Z0-9]{17,}\.ey[a-zA-Z0-9/\\_-]{17,}\.(?:[a-zA-Z0-9/\\_-]{10,}={0,2})?)`,keywords:[".eyJ"]},{id:"npm-access-token",category:"npm",title:"npm access token",pattern:String.raw`(npm_[a-z0-9]{36})`,keywords:["npm_"],caseInsensitive:!0},{id:"sendgrid-api-token",category:"sendgrid",title:"SendGrid API token",pattern:String.raw`(SG\.[a-z0-9_.-]{66})`,keywords:["SG."],caseInsensitive:!0},{id:"aws-secret-access-key",category:"aws",title:"AWS Secret Access Key",pattern:String.raw`(aws[_-]secret[_-]access[_-]key[_-][A-Za-z0-9/+=]{40})`,keywords:["key"],caseInsensitive:!0},{id:"dockerconfig-secret",category:"docker",title:"Dockerconfig secret exposed",pattern:String.raw`((\.dockerconfigjson|dockercfg):\s*\|*\s*((ey|ew)+[A-Za-z0-9/+=]+))`,keywords:["dockerc"],caseInsensitive:!0},{id:"linear-api-token",category:"linear",title:"Linear API token",pattern:String.raw`(lin_api_[a-z0-9]{40})`,keywords:["lin_api_"],caseInsensitive:!0},{id:"sendinblue-api-token",category:"sendinblue",title:"Sendinblue API token",pattern:String.raw`(xkeysib-[a-f0-9]{64}-[a-z0-9]{16})`,keywords:["xkeysib-"],caseInsensitive:!0},{id:"planetscale-api-token",category:"planetscale",title:"PlanetScale API token",pattern:String.raw`(pscale_tkn_[a-z0-9_.-]{43})`,keywords:["pscale_tkn_"],caseInsensitive:!0},{id:"doppler-api-token",category:"doppler",title:"Doppler API token",pattern:String.raw`(dp\.pt\.[a-z0-9]{43})`,keywords:["dp.pt."],caseInsensitive:!0},{id:"discord-api-token",category:"discord",title:"Discord API key",pattern:String.raw`(?:discord[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-h0-9]{64})['"]`,keywords:["discord"],caseInsensitive:!0},{id:"pulumi-api-token",category:"pulumi",title:"Pulumi API token",pattern:String.raw`(pul-[a-f0-9]{40})`,keywords:["pul-"]},{id:"postman-api-token",category:"postman",title:"Postman API token",pattern:String.raw`(PMAK-[a-f0-9]{24}-[a-f0-9]{34})`,keywords:["PMAK-"],caseInsensitive:!0},{id:"facebook-token",category:"facebook",title:"Facebook token",pattern:String.raw`(?:facebook[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-f0-9]{32})['"]`,keywords:["facebook"],caseInsensitive:!0},{id:"twitter-token",category:"twitter",title:"Twitter token",pattern:String.raw`(?:twitter[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-f0-9]{35,44})['"]`,keywords:["twitter"],caseInsensitive:!0},{id:"adobe-client-id",category:"adobe",title:"Adobe Client ID (Oauth Web)",pattern:String.raw`(?:adobe[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-f0-9]{32})['"]`,keywords:["adobe"],caseInsensitive:!0},{id:"adobe-client-secret",category:"adobe",title:"Adobe Client Secret",pattern:String.raw`(p8e-[a-z0-9]{32})`,keywords:["p8e-"],caseInsensitive:!0},{id:"alibaba-access-key-id",category:"alibaba",title:"Alibaba AccessKey ID",pattern:String.raw`((LTAI)[a-z0-9]{20})`,keywords:["LTAI"],caseInsensitive:!0},{id:"alibaba-secret-key",category:"alibaba",title:"Alibaba Secret Key",pattern:String.raw`(?:alibaba[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{30})['"]`,keywords:["alibaba"],caseInsensitive:!0},{id:"asana-client-id",category:"asana",title:"Asana Client ID",pattern:String.raw`(?:asana[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([0-9]{16})['"]`,keywords:["asana"],caseInsensitive:!0},{id:"asana-client-secret",category:"asana",title:"Asana Client Secret",pattern:String.raw`(?:asana[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{32})['"]`,keywords:["asana"],caseInsensitive:!0},{id:"atlassian-api-token",category:"atlassian",title:"Atlassian API token",pattern:String.raw`(?:atlassian[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{24})['"]`,keywords:["atlassian"],caseInsensitive:!0},{id:"beamer-api-token",category:"beamer",title:"Beamer API token",pattern:String.raw`(?:beamer[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"](b_[a-z0-9=_-]{44})['"]`,keywords:["beamer"],caseInsensitive:!0},{id:"buildkite-agent-token",category:"buildkite",title:"Buildkite API Token V2",pattern:String.raw`(bkua_[a-fA-F0-9]{40})`,keywords:["bkua_"]},{id:"clojars-api-token",category:"clojars",title:"Clojars API token",pattern:String.raw`(CLOJARS_[a-z0-9]{60})`,keywords:["CLOJARS_"],caseInsensitive:!0},{id:"contentful-delivery-api-token",category:"contentful-delivery",title:"Contentful delivery API token",pattern:String.raw`(?:contentful[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9=_-]{43})['"]`,keywords:["contentful"],caseInsensitive:!0},{id:"databricks-api-token",category:"databricks",title:"Databricks API token",pattern:String.raw`(dapi[a-h0-9]{32})`,keywords:["dapi"]},{id:"discord-client-id",category:"discord",title:"Discord client ID",pattern:String.raw`(?:discord[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([0-9]{18})['"]`,keywords:["discord"],caseInsensitive:!0},{id:"discord-client-secret",category:"discord",title:"Discord client secret",pattern:String.raw`(?:discord[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9=_-]{32})['"]`,keywords:["discord"],caseInsensitive:!0},{id:"dropbox-api-secret",category:"dropbox",title:"Dropbox API secret/key",pattern:String.raw`(?:dropbox[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{15})['"]`,keywords:["dropbox"],caseInsensitive:!0},{id:"dropbox-short-lived-api-token",category:"dropbox",title:"Dropbox short lived API token",pattern:String.raw`(?:dropbox[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"](sl\.[a-z0-9=_-]{135})['"]`,keywords:["dropbox"],caseInsensitive:!0},{id:"dropbox-long-lived-api-token",category:"dropbox",title:"Dropbox long lived API token",pattern:String.raw`(?:dropbox[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{11}(AAAAAAAAAA)[a-z0-9_=-]{43})['"]`,keywords:["dropbox"],caseInsensitive:!0},{id:"duffel-api-token",category:"duffel",title:"Duffel API token",pattern:String.raw`(duffel_(test|live)_[a-z0-9_-]{43})`,keywords:["duffel_test_","duffel_live_"],caseInsensitive:!0},{id:"dynatrace-api-token",category:"dynatrace",title:"Dynatrace API token",pattern:String.raw`(dt0c01\.[a-z0-9]{24}\.[a-z0-9]{64})`,keywords:["dt0c01."],caseInsensitive:!0},{id:"easypost-api-token",category:"easypost",title:"EasyPost API token",pattern:String.raw`(EZ[AT]K[a-z0-9]{54})`,keywords:["EZAK","EZAT"],caseInsensitive:!0},{id:"fastly-api-token",category:"fastly",title:"Fastly API token",pattern:String.raw`(?:fastly[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9=_-]{32})['"]`,keywords:["fastly"],caseInsensitive:!0},{id:"finicity-client-secret",category:"finicity",title:"Finicity client secret",pattern:String.raw`(?:finicity[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{20})['"]`,keywords:["finicity"],caseInsensitive:!0},{id:"finicity-api-token",category:"finicity",title:"Finicity API token",pattern:String.raw`(?:finicity[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-f0-9]{32})['"]`,keywords:["finicity"],caseInsensitive:!0},{id:"flutterwave-public-key",category:"flutterwave",title:"Flutterwave public/secret key",pattern:String.raw`(FLW(PUB|SEC)K_TEST-[a-h0-9]{32}-X)`,keywords:["FLWSECK_TEST-","FLWPUBK_TEST-"],caseInsensitive:!0},{id:"flutterwave-enc-key",category:"flutterwave",title:"Flutterwave encrypted key",pattern:String.raw`(FLWSECK_TEST[a-h0-9]{12})`,keywords:["FLWSECK_TEST"]},{id:"frameio-api-token",category:"frameio",title:"Frame.io API token",pattern:String.raw`(fio-u-[a-z0-9_=-]{64})`,keywords:["fio-u-"],caseInsensitive:!0},{id:"gocardless-api-token",category:"gocardless",title:"GoCardless API token",pattern:String.raw`(live_[a-z0-9_=-]{40})`,keywords:["live_"],caseInsensitive:!0},{id:"grafana-api-token",category:"grafana",title:"Grafana API token",pattern:String.raw`(eyJrIjoi[a-z0-9_=-]{72,92})`,keywords:["eyJrIjoi"],caseInsensitive:!0},{id:"hashicorp-tf-api-token",category:"hashicorp",title:"HashiCorp Terraform user/org API token",pattern:String.raw`([a-z0-9]{14}\.atlasv1\.[a-z0-9_=-]{60,70})`,keywords:["atlasv1."],caseInsensitive:!0},{id:"hubspot-api-token",category:"hubspot",title:"HubSpot API token",pattern:String.raw`(?:hubspot[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-h0-9]{8}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{12})['"]`,keywords:["hubspot"],caseInsensitive:!0},{id:"intercom-api-token",category:"intercom",title:"Intercom API token",pattern:String.raw`(?:intercom[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9=_]{60})['"]`,keywords:["intercom"],caseInsensitive:!0},{id:"intercom-client-secret",category:"intercom",title:"Intercom client secret/ID",pattern:String.raw`(?:intercom[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-h0-9]{8}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{12})['"]`,keywords:["intercom"],caseInsensitive:!0},{id:"ionic-api-token",category:"ionic",title:"Ionic API token",pattern:String.raw`(?:ionic[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"](ion_[a-z0-9]{42})['"]`,keywords:["ionic"],caseInsensitive:!0},{id:"linear-client-secret",category:"linear",title:"Linear client secret/ID",pattern:String.raw`(?:linear[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-f0-9]{32})['"]`,keywords:["linear"],caseInsensitive:!0},{id:"lob-api-key",category:"lob",title:"Lob API Key",pattern:String.raw`(?:lob[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]((live|test)_[a-f0-9]{35})['"]`,keywords:["lob"],caseInsensitive:!0},{id:"mailchimp-api-key",category:"mailchimp",title:"Mailchimp API key",pattern:String.raw`(?:mailchimp[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-f0-9]{32}-us20)['"]`,keywords:["mailchimp"],caseInsensitive:!0},{id:"mailgun-token",category:"mailgun",title:"Mailgun private API token",pattern:String.raw`(?:mailgun[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]((pub)?key-[a-f0-9]{32})['"]`,keywords:["mailgun"],caseInsensitive:!0},{id:"mailgun-signing-key",category:"mailgun",title:"Mailgun webhook signing key",pattern:String.raw`(?:mailgun[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-h0-9]{32}-[a-h0-9]{8}-[a-h0-9]{8})['"]`,keywords:["mailgun"],caseInsensitive:!0},{id:"mapbox-api-token",category:"mapbox",title:"Mapbox API token",pattern:String.raw`(pk\.[a-z0-9]{60}\.[a-z0-9]{22})`,keywords:["pk."],caseInsensitive:!0},{id:"messagebird-api-token",category:"messagebird",title:"MessageBird API token",pattern:String.raw`(?:messagebird[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{25})['"]`,keywords:["messagebird"],caseInsensitive:!0},{id:"messagebird-client-id",category:"messagebird",title:"MessageBird API client ID",pattern:String.raw`(?:messagebird[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-h0-9]{8}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{4}-[a-h0-9]{12})['"]`,keywords:["messagebird"],caseInsensitive:!0},{id:"new-relic-user-api-key",category:"newrelic",title:"New Relic user API Key",pattern:String.raw`(NRAK-[A-Z0-9]{27})`,keywords:["NRAK-"]},{id:"new-relic-user-api-id",category:"newrelic",title:"New Relic user API ID",pattern:String.raw`(?:newrelic[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([A-Z0-9]{64})['"]`,keywords:["newrelic"],caseInsensitive:!0},{id:"new-relic-browser-api-token",category:"newrelic",title:"New Relic ingest browser API token",pattern:String.raw`(NRJS-[a-f0-9]{19})`,keywords:["NRJS-"]},{id:"planetscale-password",category:"planetscale",title:"PlanetScale password",pattern:String.raw`(pscale_pw_[a-z0-9_.-]{43})`,keywords:["pscale_pw_"],caseInsensitive:!0},{id:"private-packagist-token",category:"private-packagist",title:"Private Packagist token",pattern:String.raw`(packagist_[ou][ru]t_[a-f0-9]{68})`,keywords:["packagist_uut_","packagist_ort_","packagist_out_"],caseInsensitive:!0},{id:"rubygems-api-token",category:"rubygems",title:"Rubygem API token",pattern:String.raw`(rubygems_[a-f0-9]{48})`,keywords:["rubygems_"]},{id:"shippo-api-token",category:"shippo",title:"Shippo API token",pattern:String.raw`(shippo_(live|test)_[a-f0-9]{40})`,keywords:["shippo_live_","shippo_test_"]},{id:"linkedin-client-secret",category:"linkedin",title:"LinkedIn Client secret",pattern:String.raw`(?:linkedin[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z]{16})['"]`,keywords:["linkedin"],caseInsensitive:!0},{id:"linkedin-client-id",category:"linkedin",title:"LinkedIn Client ID",pattern:String.raw`(?:linkedin[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{14})['"]`,keywords:["linkedin"],caseInsensitive:!0},{id:"twitch-api-token",category:"twitch",title:"Twitch API token",pattern:String.raw`(?:twitch[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}['"]([a-z0-9]{30})['"]`,keywords:["twitch"],caseInsensitive:!0},{id:"typeform-api-token",category:"typeform",title:"Typeform API token",pattern:String.raw`(?:typeform[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:).{0,5}(tfp_[a-z0-9_.=-]{59})`,keywords:["typeform"],caseInsensitive:!0},{id:"todoist-api-token",category:"todoist",title:"Todoist API token",pattern:String.raw`(?:todoist[a-z0-9_ .,-]{0,25})(?:=|>|:=|\|\|:|<=|=>|:)[\s'"]{0,3}([0-9a-f]{40})`,keywords:["todoist"],caseInsensitive:!0},{id:"openai-api-key",category:"openai",title:"OpenAI API Key",pattern:String.raw`(sk-[a-zA-Z0-9]{50})`,caseInsensitive:!1,keywords:["sk-"]},{id:"openai-api-key-project",category:"openai",title:"OpenAI Project-scoped API Key",pattern:String.raw`(sk-proj-[A-Za-z0-9]{24}-[A-Za-z0-9]{40,128})`,caseInsensitive:!0,keywords:["sk-proj-"]},{id:"openai-api-key-env",category:"openai",title:"OpenAI Environment-scoped API Key",pattern:String.raw`(sk-(?:live|test)-[A-Za-z0-9]{24}-[A-Za-z0-9]{40,128})`,caseInsensitive:!0,keywords:["sk-live-","sk-test-"]},{id:"anthropic-api-key",category:"anthropic",title:"Anthropic API Key",pattern:String.raw`(sk-ant-([a-zA-Z0-9]{1,10}-)?[a-zA-Z0-9_-]{32,128})`,caseInsensitive:!1,keywords:["sk-ant-"]},{id:"canva-token",category:"canva",title:"Canva Token",pattern:String.raw`\b(cnv[a-z0-9]{2}[A-Za-z0-9_=-]+[a-f0-9]{8})\b`,caseInsensitive:!1,keywords:["cnv"]},{id:"api-key",category:"unknown",title:"Unknown API Key",pattern:String.raw`(?:[a-z0-9_ .,-]{0,25}api[-_](?:key|token)(?!length|count|max|min|maxlength|_length|_count|_min|_maxlength)[a-z0-9_ .,-]{0,25})\s*(?:=|>|:=|\|\|:|<=|=>|:)\s*['"]?((?!.*(?:api|key|secret|foo|example|dummy|password|12345|abcde|placeholder|fake|token))[a-z0-9+/_-]{6,128})['"]?(?=\s|$|[;,\]})'"])`,keywords:["api-key","api_key","api-token","api_token"],caseInsensitive:!0},{id:"webhook-secret",category:"unknown",title:"Unknown Webhook Secret",pattern:String.raw`(?:[a-z0-9_ .,-]{0,25}webhook[-_]secret(?!length|count|max|min|maxlength|_length|_count|_min|_maxlength)[a-z0-9_ .,-]{0,25})\s*(?:=|>|:=|\|\|:|<=|=>|:)\s*['"]?((?!.*(?:api|key|secret|foo|example|dummy|password|12345|abcde|placeholder|fake|token|webhook))[a-z0-9+/=_-]{6,128})['"]?(?=\s|$|[;,\]})'"])`,keywords:["webhook-secret","webhook_secret"],caseInsensitive:!0},{id:"secret-value",category:"unknown",title:"Unknown API Key",pattern:String.raw`(?:[a-z0-9_ .,-]{0,25}[-_](?:secret)(?!length|count|max|min|maxlength|_length|_count|_min|_maxlength)[a-z0-9_ .,-]{0,25})\s*(?:=|>|:=|\|\|:|<=|=>|:)\s*['"]?((?!.*(?:api|key|secret|foo|example|dummy|password|12345|abcde|placeholder|fake|token))[a-z0-9+/_-]{6,128})['"]?(?=\s|$|[;,\]})'"])`,keywords:["secret"],caseInsensitive:!0},{id:"password",category:"unknown",title:"Unknown Password",pattern:String.raw`(?:[a-z0-9_ .,-]{0,25}password(?!length|count|max|min|maxlength|_length|_count|_min|_maxlength)[a-z0-9_ .,-]{0,25})\s*(?:=|>|:=|\|\|:|<=|=>|:)\s*['"]?((?!.*(?:api|key|secret|foo|example|dummy|password|12345|abcde|placeholder|fake|token|password|pass|pwd))[a-z0-9+/=_-]{6,128})['"]?(?=\s|$|[;,\]})'"])`,keywords:["password"],caseInsensitive:!0},{id:"sk-secret",category:"unknown",title:"Unknown SK Secret",pattern:String.raw`(?:^|['"\s])(sk(?:[-_][a-z0-9]{1,10})?[-_][a-z0-9]{10,99})(?:$|['"\s])`,caseInsensitive:!0,keywords:["sk-","sk_"]}]});function Pc6(J){if(!J||typeof J!=="string")return J;let Z=J.replace(Rc6,"");if(Z.length!==J.length){let Q=J.length-Z.length;j.info("Invisible Unicode tag characters removed during sanitization",{removedCount:Q})}return Z}function _c6(J){if(!J||typeof J!=="string")return J;let Z=T00.get(J);if(Z!==void 0)return Z;let Q=Pc6(J);for(let Y of hm1){if(!Y.keywords.some((V)=>Y.caseInsensitive?Q.toLowerCase().includes(V.toLowerCase()):Q.includes(V)))continue;let X=bm1(Y);Q=Q.replace(X,(V,K)=>{return V.replace(K,`[REDACTED:${Y.id}]`)})}if(J.length<=Tc6){if(T00.size>=Cc6)T00.clear();T00.set(J,Q)}return Q}function _00(J,Z){if(!J||typeof J==="number"||typeof J==="boolean")return J;if(typeof J==="string")return Z(J);if(Array.isArray(J))return J.map((Q)=>{if(typeof Q==="string")return Z(Q);else if(Q&&typeof Q==="object")return _00(Q,Z);return Q});if(J&&typeof J==="object"){if("type"in J&&(J.type==="base64"||J.type==="image")&&"data"in J)return{...J};if("isImage"in J&&J.isImage===!0&&"content"in J&&typeof J.content==="string"){let Q={};for(let[Y,X]of Object.entries(J))if(Y==="content")Q[Y]=X;else Q[Y]=_00(X,Z);return Q}}return Object.fromEntries(Object.entries(J).map(([Q,Y])=>[Q,_00(Y,Z)]))}function S00(J){return _00(J,_c6)}var Rc6,Cc6=2000,Tc6=512000,T00;var gm1=Z0(()=>{h0();mm1();Rc6=/[\uDB40][\uDC00-\uDC7F]/g;T00=new Map});function Sc6(J){return J?J.length>=k00:!1}function YR(J){if(J.nextMessageId===void 0)J.nextMessageId=0;return J.nextMessageId++}function vc6(J,Z){let Q=SI0(J["~debug"]?.lastInferenceUsage,Z);if(!Q)return;J["~debug"]={...J["~debug"]??{},lastInferenceUsage:Q}}function SI0(J,Z){if(!J)return Z;if(!Z)return J;let Q=(X,V)=>Math.max(X,V),Y=(X,V)=>{if(V===null)return X;if(X===null)return V;return Math.max(X,V)};return{model:Z.model??J.model,maxInputTokens:Q(J.maxInputTokens,Z.maxInputTokens),inputTokens:Q(J.inputTokens,Z.inputTokens),outputTokens:Q(J.outputTokens,Z.outputTokens),cacheCreationInputTokens:Y(J.cacheCreationInputTokens,Z.cacheCreationInputTokens),cacheReadInputTokens:Y(J.cacheReadInputTokens,Z.cacheReadInputTokens),totalInputTokens:Q(J.totalInputTokens,Z.totalInputTokens),thinkingBudget:Z.thinkingBudget??J.thinkingBudget,timestamp:Z.timestamp??J.timestamp}}function pm1(J,Z=new Date){return(Q)=>{switch(Q.v++,J.type){case"cancelled":{v00(Q);let Y=Q.messages.at(-1);if(Y?.role==="user"){let X=Y.content.findLast((V)=>V.type==="tool_result");if(X)X.run.status="cancelled"}break}case"user:message:interrupt":{let Y=Q.messages[J.messageIndex];if(Y?.role==="user")Y.interrupted=!0;break}case"user:message:append-content":{let Y=Q.messages.find((X)=>X.messageId===J.messageId);if(Y?.role==="user")Y.content.push(...R6(J.content));break}case"fork:created":{if(!Q.relationships)Q.relationships=[];if(!Q.relationships.some((X)=>X.threadID===J.forkThreadID&&X.type==="fork"&&X.role==="parent"&&X.messageIndex===J.fromMessageIndex))Q.relationships.push({threadID:J.forkThreadID,type:"fork",role:"parent",messageIndex:J.fromMessageIndex,createdAt:Date.now()});Q.v++;break}case"thread:truncate":{if(Q.messages.splice(J.fromIndex),Q.relationships){if(Q.relationships=Q.relationships.filter((Y)=>Y.messageIndex===void 0||Y.messageIndex<J.fromIndex),Q.relationships.length===0)Q.relationships=void 0}break}case"user:message":{if(v00(Q),Q.archived)Q.archived=!1;let Y={role:"user",...J.message,messageId:YR(Q),content:J.message.content??[]},X=S00(Y);if(J.index!==void 0){if(!Q.messages[J.index])throw Error(`user message at index ${J.index} not found`);let V=Q.messages[J.index];if(Q.messages.filter((D)=>D.role==="user")[0]===V&&Y.agentMode&&!Q.mainThreadID)Q.agentMode=Y.agentMode;Q.messages.splice(J.index,Q.messages.length-J.index,X)}else{let V=e3(Q)===0;if((!Q.agentMode||V)&&Y.agentMode&&!Q.mainThreadID)Q.agentMode=Y.agentMode;if(Q.messages.push(X),Q.draft)Q.draft=void 0}break}case"user:message-queue:dequeue":{if(v00(Q),!Q.queuedMessages)return;let[Y,...X]=Q.queuedMessages;if(!Y)return;Q.messages.push(Y.queuedMessage),Q.queuedMessages=X;break}case"user:tool-input":{if(!R$(Q,J.toolUse)){j.debug(`Ignoring user:tool-input delta for missing tool use ${J.toolUse} (likely deleted due to thread edit/truncation)`);break}let X=R6(HI(Q,J.toolUse));if(!X){j.debug(`Ignoring user:tool-input delta for missing tool result block ${J.toolUse} (likely deleted due to thread edit/truncation)`);break}X.userInput=J.value;break}case"tool:data":{if(!WI(Q,J.toolUse)){j.debug(`Ignoring tool:data delta for missing tool use ${J.toolUse} (likely deleted due to thread edit/truncation)`);break}let X=R6(S00(J.data));dm1(Q,J.toolUse,X);break}case"tool:processed":{let Y=WI(Q,J.toolUse);if(!Y){j.debug(`Ignoring tool:processed delta for missing tool use ${J.toolUse} (likely deleted due to thread edit/truncation)`);break}let X=Y.block.input;Y.block.input=J.newArgs,Y.message.originalToolUseInput={...Y.message.originalToolUseInput,[J.toolUse]:X};break}case"assistant:message":{let Y=u8(Q,"assistant"),X=Y?.content.filter((K)=>K.type==="tool_use").map((K)=>K.id)||[];if(v00(Q),Y?.state.type==="cancelled"){for(let K of Q.messages)if(K.role==="user")K.content=K.content.filter((z)=>{if(z.type==="tool_result"&&X.includes(z.toolUseID))return!1;return!0})}let V={...J.message,messageId:YR(Q)};Q.messages.push(R6(V));break}case"assistant:message-update":{let Y=R6(J.message),X=Q.messages.at(-1);if(X?.role==="assistant"){let V=SI0(X.usage,Y.usage);Q.messages[Q.messages.length-1]={...Y,messageId:X.messageId,usage:V}}else Q.messages.push({...Y,messageId:YR(Q)});break}case"inference:completed":{if(vc6(Q,J.usage),!Q.env)Q.env={initial:{}};if(!Q.env.initial.tags)Q.env.initial.tags=[];if(Q.env.initial.tags=Q.env.initial.tags.filter((Y)=>Y!=="model:undefined"),J.model){let Y=`model:${J.model}`;if(!Q.env.initial.tags.includes(Y))Q.env.initial.tags=[...Q.env.initial.tags,Y]}if(J.usage){let Y=R6(u8(Q,"assistant"));if(Y){let X=SI0(Y.usage,J.usage);if(X)Y.usage=X}}break}case"title":{Q.title=J.value||void 0;break}case"max-tokens":{Q.maxTokens=J.value||void 0;break}case"main-thread":{Q.mainThreadID=J.value||void 0;break}case"agent-mode":{if(e3(Q)>0)throw Error("(bug) cannot change agentMode after first message");Q.agentMode=J.mode;break}case"environment":{Q.env=R6(J.env);break}case"user:message-queue:enqueue":{if(!Q.queuedMessages)Q.queuedMessages=[];if(Sc6(Q.queuedMessages))break;let Y={role:"user",...J.message,messageId:YR(Q),content:J.message.content??[]},X=S00(Y);Q.queuedMessages.push({id:fm1("queued-"),queuedMessage:R6(X)});break}case"user:message-queue:discard":{if(J.id===void 0){Q.queuedMessages=[];break}let Y=Q.queuedMessages?.findIndex((X)=>X.id===J.id);if(Y===void 0)throw Error(`queued message with id ${J.id} not found`);Q?.queuedMessages?.splice(Y,1);break}case"info:manual-bash-invocation":{Q.messages.push({role:"info",messageId:YR(Q),content:[{type:"manual_bash_invocation",args:R6(J.args),toolRun:R6(J.toolRun),hidden:J.hidden}]});break}case"clearPendingNavigation":{Q.pendingNavigation=void 0;break}case"setPendingNavigation":{Q.pendingNavigation=J.threadID;break}case"relationship":{if(!Q.relationships)Q.relationships=[];if(!Q.relationships.some((X)=>X.threadID===J.relationship.threadID&&X.type===J.relationship.type&&X.role===J.relationship.role))Q.relationships.push(R6(J.relationship));break}case"draft":{if(Q.draft=R6(J.content),J.autoSubmit)Q.autoSubmitDraft=!0;break}case"trace:start":{kc6(Q,J.span);break}case"trace:end":{yc6(Q,J.span,Z);break}case"trace:event":{uc6(Q,J.span,J.event);break}case"trace:attributes":{xc6(Q,J.span,J.attributes);break}}}}function v00(J){let Z=R6(u8(J,"assistant"));if(!Z)return;let Q=!1;if(Z.state.type==="streaming")Z.state={type:"cancelled"},Q=!0;else if(Z.state.type==="complete"){if(Z.content.some((K)=>K.type==="tool_use"&&!t3(K)))Z.state={type:"cancelled"},Q=!0}if(!Q)return;let Y=CZ(J),X=[];for(let V=0;V<Z.content.length;V++){let K=Z.content[V];if(K?.type!=="tool_use")continue;if(!t3(K)){j.debug(`Cleaning up incomplete tool_use ${K.id}`,{name:"markPriorStreamingAssistantMessageAsCancelled",threadID:J.id,blockID:K.id});let z={type:"tool_use",id:K.id,name:K.name,complete:!0,input:K.inputIncomplete??K.input??{}};Z.content[V]=z}if(!Y.has(K.id))X.push(K.id)}for(let V of X)dm1(J,V,{status:"cancelled"})}function dm1(J,Z,Q){let Y,X=WI(J,Z);if(X){let K=X.messageIndex;for(let z=K+1;z<J.messages.length;z++){let D=J.messages[z];if(D?.role==="user"){Y=D;break}}}if(!Y)Y={role:"user",messageId:YR(J),content:[]},J.messages.push(Y);let V=HI(J,Z);if(V)V.run=R6(Q);else V={type:"tool_result",toolUseID:Z,run:R6(Q)},Y.content.push(V)}function kc6(J,Z){if(!J.meta)J.meta={};if(!J.meta.traces)J.meta.traces=[];let Q=J.meta.traces.find((Y)=>Y.id===Z.id);if(Q){if(Q.startTime===void 0)Q.startTime=Z.startTime;return}J.meta.traces.push(R6({...Z}))}function yc6(J,Z,Q){if(!J.meta)J.meta={};if(!J.meta.traces)J.meta.traces=[];let Y=J.meta.traces.find((V)=>V.id===Z.id),X=Z.endTime??Q.toISOString();if(Y){if(Y.endTime===void 0)Y.endTime=X}}function uc6(J,Z,Q){if(!J.meta?.traces)return;let Y=J.meta.traces.find((X)=>X.id===Z);if(!Y)return;if(!Y.events)Y.events=[];Y.events.push(Q)}function xc6(J,Z,Q){if(!J.meta?.traces)return;let Y=J.meta.traces.find((X)=>X.id===Z);if(!Y)return;Y.attributes={...Y.attributes,...Q}}function XR(J){try{return ia(J.replace(/\\+$/,"")+'"')}catch{return ia(J)}}var k00=5;var VR=Z0(()=>{f2();h0();gm1();b4()});function wY(J){let Z=[];if(J.currentlyVisibleFiles){if(J.currentlyVisibleFiles.length>0)Z.push(`Currently visible files user has open: ${J.currentlyVisibleFiles.map(f9).join(", ")}`)}if(J.runningTerminalCommands&&J.runningTerminalCommands.length>0)Z.push(`Currently running terminal commands:
834
834
  ${J.runningTerminalCommands.join(`
835
835
  `)}`);if(J.activeEditor)Z.push(`Currently active editor: ${f9(J.activeEditor)}`);if(J.activeEditor&&!vk(J.activeEditor)){if(J.selectionRange)Z.push(`Selection range: ${J.selectionRange.start.line}:${J.selectionRange.start.column}-${J.selectionRange.end.line}:${J.selectionRange.end.column}`);else if(J.cursorLocation){if(Z.push(`Current cursor location: ${J.cursorLocation.line}:${J.cursorLocation.column}`),J.cursorLocationLine)Z.push(`Contents of line on which cursor is: \`${J.cursorLocationLine}\``)}}if(J.snapshotOIDs&&J.snapshotOIDs.length>0)for(let Q of J.snapshotOIDs)Z.push(`Git tree snapshot: ${Q.treeOID} (repo: ${Q.repoRoot})`);if(J.aggmanContext){let Q=J.aggmanContext;Z.push(`Current URL the user is on: ${Q.currentURL}`)}return`# User State
836
836
  ${Z.join(`
@@ -3077,7 +3077,7 @@ Guidelines:
3077
3077
  Keep diff hunks focused on the specific change being discussed, not the entire file diff.
3078
3078
  - If your understanding changes, add a later post_explanation call that corrects earlier claims.
3079
3079
 
3080
- Keep each explanation concise, concrete, and grounded in the actual diff.`;function b84(J){if(typeof J!=="number")return;if(!Number.isInteger(J)||J<1)return;return J}function sV5(J){let Z=J.text.trim();if(!Z)return;let Q=typeof J.file==="string"?J.file.trim():void 0,Y=b84(J.startLine),X=b84(J.endLine),V=typeof J.diff==="string"?J.diff.trim():void 0;return{text:Z,file:Q&&Q.length>0?Q:void 0,startLine:Y,endLine:X,diff:V&&V.length>0?V:void 0}}function tV5(J,Z){return{spec:{name:WM1,description:"Post one markdown explanation paragraph for the code tour. Use markdown links for locations, like [src/file.ts#L12-L20](src/file.ts#L12-L20).",inputSchema:{type:"object",properties:{text:{type:"string",description:"Markdown paragraph for this explanation section. When mentioning a file location, use a markdown link like [src/file.ts#L12-L20](src/file.ts#L12-L20)."},file:{type:"string",description:"Optional file path that this explanation paragraph refers to."},startLine:{type:"number",description:"Optional starting line for the referenced file range."},endLine:{type:"number",description:"Optional ending line for the referenced file range."},diff:{type:"string",description:"Optional unified diff hunk for this explanation. Should be a valid unified diff snippet (with --- and +++ headers and @@ hunk headers)."}},required:["text"]},source:"builtin",executionProfile:{resourceKeys:()=>[]}},fn:({args:Q})=>E4(async()=>{let Y=sV5(Q);if(!Y)return{status:"error",error:{message:"post_explanation requires a non-empty text value"}};J.push(Y);try{await u84(Z,Y)}catch(X){j.warn("Failed to append code tour explanation artifact",{path:Z,error:X instanceof Error?X.message:String(X)})}return{status:"done",result:"Explanation posted"}})}}function eV5(J,Z,Q,Y){return new v0((X)=>{let V=y84(Q),K=tV5(Y,V),z=Z.registerTool(K),D=new s8,U=r3["code-tour"].model?o3(r3["code-tour"].model):void 0;if(!U){z.dispose(),X.error(Error("Code tour subagent has no model defined"));return}let G=[{role:"user",content:J}],F=D.run(uY,{systemPrompt:f84,model:U,spec:r3["code-tour"]},{conversation:G,toolService:Z,env:Q}).subscribe({next:(q)=>X.next(q),error:(q)=>X.error(q),complete:()=>X.complete()});return()=>{F.unsubscribe(),z.dispose()}})}function $K5(J,Z){switch(J.status){case"in-progress":return{status:"in-progress",result:[...Z],progress:J.turns.map((Q)=>({message:Q.message,tool_uses:[...Q.activeTools.values()],explanations:[...Z]}))};case"done":return{status:"done",result:[...Z],progress:J.turns.map((Q)=>({message:Q.message,tool_uses:[...Q.activeTools.values()],explanations:[...Z]})),"~debug":J["~debug"]};case"error":return{status:"error",error:{message:J.message}};case"cancelled":return{status:"cancelled",reason:"Code tour was cancelled"}}}var JK5=({args:J},Z)=>{let Q=[];return E4(async()=>{let Y=typeof J.diff_description==="string"?J.diff_description:void 0,X=typeof J.focus==="string"?J.focus:void 0;return x84({diffDescription:Y,focus:X})}).pipe(e1((Y)=>{return j.debug("Code tour subagent starting",{hasDiffDescription:typeof J.diff_description==="string",hasFocus:typeof J.focus==="string"}),eV5(Y,Z.toolService,Z,Q)}),W1((Y)=>$K5(Y,Q)))},h84={spec:{name:qM1,description:`Generate a guided code tour for a diff. Use this when you need an explanation of what changed and why.
3080
+ Keep each explanation concise, concrete, and grounded in the actual diff.`;function b84(J){if(typeof J!=="number")return;if(!Number.isInteger(J)||J<1)return;return J}function sV5(J){let Z=J.text.trim();if(!Z)return;let Q=typeof J.file==="string"?J.file.trim():void 0,Y=b84(J.startLine),X=b84(J.endLine),V=typeof J.diff==="string"?J.diff.trim():void 0;return{text:Z,file:Q&&Q.length>0?Q:void 0,startLine:Y,endLine:X,diff:V&&V.length>0?V:void 0}}function tV5(J){return{spec:{name:WM1,description:"Post one markdown explanation paragraph for the code tour. Use markdown links for locations, like [src/file.ts#L12-L20](src/file.ts#L12-L20).",inputSchema:{type:"object",properties:{text:{type:"string",description:"Markdown paragraph for this explanation section. When mentioning a file location, use a markdown link like [src/file.ts#L12-L20](src/file.ts#L12-L20)."},file:{type:"string",description:"Optional file path that this explanation paragraph refers to."},startLine:{type:"number",description:"Optional starting line for the referenced file range."},endLine:{type:"number",description:"Optional ending line for the referenced file range."},diff:{type:"string",description:"Optional unified diff hunk for this explanation. Should be a valid unified diff snippet (with --- and +++ headers and @@ hunk headers)."}},required:["text"]},source:"builtin",executionProfile:{resourceKeys:()=>[]}},fn:({args:Z})=>E4(async()=>{let Q=sV5(Z);if(!Q)return{status:"error",error:{message:"post_explanation requires a non-empty text value"}};try{await u84(J,Q)}catch(Y){j.warn("Failed to append code tour explanation artifact",{path:J,error:Y instanceof Error?Y.message:String(Y)})}return{status:"done",result:"Explanation posted"}})}}function eV5(J,Z,Q,Y){return new v0((X)=>{let V=tV5(Y),K=Z.registerTool(V),z=new s8,D=r3["code-tour"].model?o3(r3["code-tour"].model):void 0;if(!D){K.dispose(),X.error(Error("Code tour subagent has no model defined"));return}let U=[{role:"user",content:J}],G=z.run(uY,{systemPrompt:f84,model:D,spec:r3["code-tour"]},{conversation:U,toolService:Z,env:Q}).subscribe({next:(F)=>X.next(F),error:(F)=>X.error(F),complete:()=>X.complete()});return()=>{G.unsubscribe(),K.dispose()}})}function $K5(J,Z){switch(J.status){case"in-progress":return{status:"in-progress",result:Z,progress:J.turns.map((Q)=>({message:Q.message,tool_uses:[...Q.activeTools.values()]}))};case"done":return{status:"done",result:Z,progress:J.turns.map((Q)=>({message:Q.message,tool_uses:[...Q.activeTools.values()]})),"~debug":J["~debug"]};case"error":return{status:"error",error:{message:J.message}};case"cancelled":return{status:"cancelled",reason:"Code tour was cancelled"}}}var JK5=({args:J},Z)=>{let Q=y84(Z);return E4(async()=>{let Y=typeof J.diff_description==="string"?J.diff_description:void 0,X=typeof J.focus==="string"?J.focus:void 0;return x84({diffDescription:Y,focus:X})}).pipe(e1((Y)=>{return j.debug("Code tour subagent starting",{hasDiffDescription:typeof J.diff_description==="string",hasFocus:typeof J.focus==="string"}),eV5(Y,Z.toolService,Z,Q)}),W1((Y)=>$K5(Y,Q)))},h84={spec:{name:qM1,description:`Generate a guided code tour for a diff. Use this when you need an explanation of what changed and why.
3081
3081
 
3082
3082
  If diff_description is omitted, this tool defaults to the repository's outstanding changes (staged + unstaged).
3083
3083
 
@@ -3085,7 +3085,7 @@ Use this tool for:
3085
3085
  - Walking through uncommitted changes before review
3086
3086
  - Explaining a complex patch in plain language
3087
3087
  - Understanding change intent and cross-file impact
3088
- `,inputSchema:{type:"object",properties:{diff_description:{type:"string",description:"Description of the diff to explain. Can be a git command, revision range, PR branch comparison, or natural-language diff target."},focus:{type:"string",description:"Optional focus area for the tour, such as architecture impact, risky changes, API behavior, or specific subsystems."}}},meta:{disableTimeout:!0},source:"builtin",executionProfile:{resourceKeys:()=>[]}},fn:JK5};B1();p9();F3();oQ();Kv0();F3();function m84(J){return{runInference:async(Z,Q,Y,X,V,K,z)=>{let D=await _50(Y,X,Q,V,o3(Z),J,K,z,void 0),U=D.message,G=C50(U),F;if("usage"in U&&U.usage){let q=U.usage;F={model:o3(Z),maxInputTokens:0,inputTokens:q.prompt_tokens??0,outputTokens:q.completion_tokens??0,cacheCreationInputTokens:null,cacheReadInputTokens:null,totalInputTokens:q.prompt_tokens??0,timestamp:new Date().toISOString()}}return{result:D,toolUses:G,debugUsage:F}},extractMessage:(Z)=>{let Q=Z.message;if("error"in Q)throw Error(`Cerebras error: ${Q.error}`);if("object"in Q&&Q.object==="chat.completion")return Q.choices[0]?.message?.content||void 0;if("object"in Q&&Q.object==="chat.completion.chunk")return Q.choices?.[0]?.delta?.content||void 0;return},updateConversation:(Z,Q,Y)=>{let X=Q.message,V=T50(X);if(V)Z.push(V);for(let{id:K,result:z}of Y){let D={role:"tool",content:ZK5(z),tool_call_id:K};Z.push(D)}}}}function ZK5(J){if(J.status==="error"){let Z=J.error;return JSON.stringify(Z)}if(J.status==="done"){if(typeof J.result==="string")return J.result;let Z=JSON.stringify(J.result);return Z===void 0?"":Z}return`Tool execution status: ${J.status}`}B1();p9();F3();oQ();L4();L4();var QK5=[{description:"Find all typescript files in the codebase",args:{filePattern:"**/*.ts"}},{description:"Find all test files under a specific directory",args:{filePattern:"src/**/*test*.ts"}},{description:"Search for svelte component files in the web/src directory",args:{filePattern:"web/src/**/*.svelte"}},{description:"Find up to 10 JSON files",args:{filePattern:"**/*.json",limit:10}}],t50={spec:{name:cF,description:`Fast file pattern matching tool that works with any codebase size
3088
+ `,inputSchema:{type:"object",properties:{diff_description:{type:"string",description:"Description of the diff to explain. Can be a git command, revision range, PR branch comparison, or natural-language diff target."},focus:{type:"string",description:"Optional focus area for the tour, such as architecture impact, risky changes, API behavior, or specific subsystems."}},additionalProperties:!1},meta:{disableTimeout:!0},source:"builtin",executionProfile:{resourceKeys:()=>[]}},fn:JK5};B1();p9();F3();oQ();Kv0();F3();function m84(J){return{runInference:async(Z,Q,Y,X,V,K,z)=>{let D=await _50(Y,X,Q,V,o3(Z),J,K,z,void 0),U=D.message,G=C50(U),F;if("usage"in U&&U.usage){let q=U.usage;F={model:o3(Z),maxInputTokens:0,inputTokens:q.prompt_tokens??0,outputTokens:q.completion_tokens??0,cacheCreationInputTokens:null,cacheReadInputTokens:null,totalInputTokens:q.prompt_tokens??0,timestamp:new Date().toISOString()}}return{result:D,toolUses:G,debugUsage:F}},extractMessage:(Z)=>{let Q=Z.message;if("error"in Q)throw Error(`Cerebras error: ${Q.error}`);if("object"in Q&&Q.object==="chat.completion")return Q.choices[0]?.message?.content||void 0;if("object"in Q&&Q.object==="chat.completion.chunk")return Q.choices?.[0]?.delta?.content||void 0;return},updateConversation:(Z,Q,Y)=>{let X=Q.message,V=T50(X);if(V)Z.push(V);for(let{id:K,result:z}of Y){let D={role:"tool",content:ZK5(z),tool_call_id:K};Z.push(D)}}}}function ZK5(J){if(J.status==="error"){let Z=J.error;return JSON.stringify(Z)}if(J.status==="done"){if(typeof J.result==="string")return J.result;let Z=JSON.stringify(J.result);return Z===void 0?"":Z}return`Tool execution status: ${J.status}`}B1();p9();F3();oQ();L4();L4();var QK5=[{description:"Find all typescript files in the codebase",args:{filePattern:"**/*.ts"}},{description:"Find all test files under a specific directory",args:{filePattern:"src/**/*test*.ts"}},{description:"Search for svelte component files in the web/src directory",args:{filePattern:"web/src/**/*.svelte"}},{description:"Find up to 10 JSON files",args:{filePattern:"**/*.json",limit:10}}],t50={spec:{name:cF,description:`Fast file pattern matching tool that works with any codebase size
3089
3089
 
3090
3090
  Use this tool to find files by name patterns across your codebase. Results are returned in ripgrep's traversal order, not by modification time.
3091
3091
 
@@ -5997,11 +5997,11 @@ ${W}`))}},error:(q)=>{if(!F)F=!0,z(Error(`Failed to spawn brew: ${q.message}`))}
5997
5997
  ${W}`;if(X==="pnpm"&&W.includes("Unable to find the global bin directory"))H+=`
5998
5998
 
5999
5999
  Hint: Try running "pnpm setup" to configure pnpm global directory, or use npm instead:
6000
- npm install -g @sourcegraph/amp`;z(Error(H))}},error:(q)=>{if(!G)G=!0,z(Error(`Failed to spawn ${X}: ${q.message}`))},complete:()=>{if(!G)G=!0,K()}})})}h0();h0();Mj();async function g80(J,Z){let X=`${Z||"https://registry.npmjs.org"}/@sourcegraph/amp/latest`,V=new AbortController,K=setTimeout(()=>V.abort(),5000);try{let z=await fetch(X,{signal:V.signal});if(!z.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let D=await z.json(),U=D.version??D["dist-tags"]?.latest;if(!U)return{hasUpdate:!1,currentVersion:J,source:"npm"};let G=PV4(J,U),F=G<0,q,W;if(D.time){let H=D.time[J],B=D.time[U],w=Date.now();if(H)q=Math.floor((w-new Date(H).getTime())/3600000);if(B)W=Math.floor((w-new Date(B).getTime())/3600000)}return j.info("NPM version comparison",{currentVersion:J,latestVersion:U,compareResult:G,hasUpdate:F,currentVersionAge:q,latestVersionAge:W}),{hasUpdate:F,latestVersion:U,currentVersion:J,currentVersionAge:q,latestVersionAge:W,source:"npm"}}catch(z){return j.debug("Error checking npm version",{error:z}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(K)}}var oA5="https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt";async function p80(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let Y=await fetch(`${oA5}?t=${Date.now()}`,{signal:Z.signal,cache:"no-store"});if(!Y.ok)return{hasUpdate:!1,currentVersion:J,source:"bin"};let X=(await Y.text()).trim();if(!X||!/^\d+\.\d+\.\d+/.test(X))return{hasUpdate:!1,currentVersion:J,source:"bin"};let V=PV4(J,X),K=V<0;return j.info("Bin version comparison",{currentVersion:J,latestVersion:X,compareResult:V,hasUpdate:K}),{hasUpdate:K,latestVersion:X,currentVersion:J,source:"bin"}}catch(Y){return j.debug("Error checking bin version",{error:Y}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Q)}}var rA5=604800000;function RV4(J){if(!J)return null;let Z=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Z))return null;let Q=Date.now()-Z;if(Q>rA5)return{ageMs:Q};return null}function PV4(J,Z){let Q=(K)=>{let[z,D]=K.split("-");return{parts:z?.split(".").map(Number)||[],label:D}},Y=Q(J),X=Q(Z),V=Math.max(Y.parts.length,X.parts.length);for(let K=0;K<V;K++){let z=Y.parts[K]||0,D=X.parts[K]||0;if(z<D)return-1;if(z>D)return 1}if(Y.label===X.label)return 0;if(!Y.label&&X.label)return 1;if(Y.label&&!X.label)return-1;if(Y.label&&X.label)return Y.label<X.label?-1:1;return 0}function Nx0(J){try{let Z=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Z)return null;let Q=parseInt(Z[1],10)*1000,Y=Z[2],X=Q!==0?Rq(Q):void 0;return{sha:Y,age:X}}catch{return null}}B1();function Ox0(J,Z,Q={}){let Y=new Z4,X=Y.pipe(j6({shouldCountRefs:!1}));return setImmediate(async()=>{let V=new PK().scoped("update"),K=Q.startDelayMs??0;if(K>0)await Zz(K);let z=X.subscribe({next:(D)=>{V.debug("emit new state",D)}});try{let D=process.env.AMP_TEST_UPDATE_STATUS;if(D){V.debug("using fake update status for testing",{status:D}),await Zz(500),Y.next(D);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){V.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let U=await Z.get("updates.mode");if(U==="disabled"){V.debug("checking disabled");return}let G=await m80(),F=G==="binary"||G==="brew";V.debug("checking",{currentVersion:J,mode:U,packageManager:G,isBinaryDistribution:F});let q=F?await p80(J):await g80(J,cE());if(!(q.latestVersion&&q.hasUpdate)){V.debug("no update available");return}let W=()=>{if(q.currentVersionAge!==void 0&&q.latestVersionAge!==void 0){let H=q.currentVersionAge-q.latestVersionAge,B=0.5;if(Math.abs(H)<0.5)return V.debug("versions too close together, suppressing update warning",{currentVersionAge:q.currentVersionAge,latestVersionAge:q.latestVersionAge,ageDifferenceHours:H}),!0}return!1};if(!U)U=G==="pnpm"?"warn":"auto",V.debug("no configured update mode; selected default based on package manager",{packageManager:G,mode:U});if(G==="brew"){if(!W())Y.next("update-available-brew");return}if(G==="binary"&&process.execPath!==Fx0()){if(V.debug("non-standard binary path, showing warning"),!W())Y.next("update-available-unrecognized-path");return}if(U==="warn"){if(!W())Y.next("update-available");return}if(!G){if(V.debug("auto-update not supported, falling back to warn mode"),!W())Y.next("update-available");return}if(G==="binary"&&process.platform==="win32"){if(V.debug("binary auto-update not supported on Windows, falling back to warn mode"),!W())Y.next("update-available");return}try{await lm(q.latestVersion,G);let H=await zH(q.latestVersion),B={from:q.currentVersion,to:q.latestVersion,...H};if(H.status==="same")V.info("success",B),Y.next("updated");else V.warn("success with warning",B),Y.next("updated-with-warning")}catch(H){Y.next("update-error")}}catch(D){V.debug("check failed",{error:D})}finally{await Zz(5000),Y.next("hidden"),z.unsubscribe(),Y.complete()}}),{state:X}}Mj();import{stderr as iz}from"node:process";function CV4(J){let Z=new rW().name("install").description("Install required tools like ripgrep to $AMP_HOME/bin").option("--force","Force reinstallation even if already installed").option("--verbose","Show installation progress and results").action(async(Y)=>{await zx0(Y.force||!1,Y.verbose||!1,"0.0.1773173082-gfe7cc2"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new rW("update").summary("Update Amp CLI").description("Update Amp CLI to the latest version. You can specify a particular version to install, or leave blank to get the latest stable release.").option("--target-version <version>","Update to a specific version").allowUnknownOption(!1).action(async(Y)=>{await sA5(Y.targetVersion)});J.addCommand(Q)}async function sA5(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")iz.write(Q1.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
6000
+ npm install -g @sourcegraph/amp`;z(Error(H))}},error:(q)=>{if(!G)G=!0,z(Error(`Failed to spawn ${X}: ${q.message}`))},complete:()=>{if(!G)G=!0,K()}})})}h0();h0();Mj();async function g80(J,Z){let X=`${Z||"https://registry.npmjs.org"}/@sourcegraph/amp/latest`,V=new AbortController,K=setTimeout(()=>V.abort(),5000);try{let z=await fetch(X,{signal:V.signal});if(!z.ok)return{hasUpdate:!1,currentVersion:J,source:"npm"};let D=await z.json(),U=D.version??D["dist-tags"]?.latest;if(!U)return{hasUpdate:!1,currentVersion:J,source:"npm"};let G=PV4(J,U),F=G<0,q,W;if(D.time){let H=D.time[J],B=D.time[U],w=Date.now();if(H)q=Math.floor((w-new Date(H).getTime())/3600000);if(B)W=Math.floor((w-new Date(B).getTime())/3600000)}return j.info("NPM version comparison",{currentVersion:J,latestVersion:U,compareResult:G,hasUpdate:F,currentVersionAge:q,latestVersionAge:W}),{hasUpdate:F,latestVersion:U,currentVersion:J,currentVersionAge:q,latestVersionAge:W,source:"npm"}}catch(z){return j.debug("Error checking npm version",{error:z}),{hasUpdate:!1,currentVersion:J,source:"npm"}}finally{clearTimeout(K)}}var oA5="https://storage.googleapis.com/amp-public-assets-prod-0/cli/cli-version.txt";async function p80(J){let Z=new AbortController,Q=setTimeout(()=>Z.abort(),5000);try{let Y=await fetch(`${oA5}?t=${Date.now()}`,{signal:Z.signal,cache:"no-store"});if(!Y.ok)return{hasUpdate:!1,currentVersion:J,source:"bin"};let X=(await Y.text()).trim();if(!X||!/^\d+\.\d+\.\d+/.test(X))return{hasUpdate:!1,currentVersion:J,source:"bin"};let V=PV4(J,X),K=V<0;return j.info("Bin version comparison",{currentVersion:J,latestVersion:X,compareResult:V,hasUpdate:K}),{hasUpdate:K,latestVersion:X,currentVersion:J,source:"bin"}}catch(Y){return j.debug("Error checking bin version",{error:Y}),{hasUpdate:!1,currentVersion:J,source:"bin"}}finally{clearTimeout(Q)}}var rA5=604800000;function RV4(J){if(!J)return null;let Z=typeof J==="number"?J:new Date(J).getTime();if(isNaN(Z))return null;let Q=Date.now()-Z;if(Q>rA5)return{ageMs:Q};return null}function PV4(J,Z){let Q=(K)=>{let[z,D]=K.split("-");return{parts:z?.split(".").map(Number)||[],label:D}},Y=Q(J),X=Q(Z),V=Math.max(Y.parts.length,X.parts.length);for(let K=0;K<V;K++){let z=Y.parts[K]||0,D=X.parts[K]||0;if(z<D)return-1;if(z>D)return 1}if(Y.label===X.label)return 0;if(!Y.label&&X.label)return 1;if(Y.label&&!X.label)return-1;if(Y.label&&X.label)return Y.label<X.label?-1:1;return 0}function Nx0(J){try{let Z=J.match(/^0\.0\.(\d+)(?:-g?([a-f0-9]+))?/);if(!Z)return null;let Q=parseInt(Z[1],10)*1000,Y=Z[2],X=Q!==0?Rq(Q):void 0;return{sha:Y,age:X}}catch{return null}}B1();function Ox0(J,Z,Q={}){let Y=new Z4,X=Y.pipe(j6({shouldCountRefs:!1}));return setImmediate(async()=>{let V=new PK().scoped("update"),K=Q.startDelayMs??0;if(K>0)await Zz(K);let z=X.subscribe({next:(D)=>{V.debug("emit new state",D)}});try{let D=process.env.AMP_TEST_UPDATE_STATUS;if(D){V.debug("using fake update status for testing",{status:D}),await Zz(500),Y.next(D);return}if(process.env.AMP_SKIP_UPDATE_CHECK==="1"){V.debug("checking disabled via AMP_SKIP_UPDATE_CHECK environment variable");return}let U=await Z.get("updates.mode");if(U==="disabled"){V.debug("checking disabled");return}let G=await m80(),F=G==="binary"||G==="brew";V.debug("checking",{currentVersion:J,mode:U,packageManager:G,isBinaryDistribution:F});let q=F?await p80(J):await g80(J,cE());if(!(q.latestVersion&&q.hasUpdate)){V.debug("no update available");return}let W=()=>{if(q.currentVersionAge!==void 0&&q.latestVersionAge!==void 0){let H=q.currentVersionAge-q.latestVersionAge,B=0.5;if(Math.abs(H)<0.5)return V.debug("versions too close together, suppressing update warning",{currentVersionAge:q.currentVersionAge,latestVersionAge:q.latestVersionAge,ageDifferenceHours:H}),!0}return!1};if(!U)U=G==="pnpm"?"warn":"auto",V.debug("no configured update mode; selected default based on package manager",{packageManager:G,mode:U});if(G==="brew"){if(!W())Y.next("update-available-brew");return}if(G==="binary"&&process.execPath!==Fx0()){if(V.debug("non-standard binary path, showing warning"),!W())Y.next("update-available-unrecognized-path");return}if(U==="warn"){if(!W())Y.next("update-available");return}if(!G){if(V.debug("auto-update not supported, falling back to warn mode"),!W())Y.next("update-available");return}if(G==="binary"&&process.platform==="win32"){if(V.debug("binary auto-update not supported on Windows, falling back to warn mode"),!W())Y.next("update-available");return}try{await lm(q.latestVersion,G);let H=await zH(q.latestVersion),B={from:q.currentVersion,to:q.latestVersion,...H};if(H.status==="same")V.info("success",B),Y.next("updated");else V.warn("success with warning",B),Y.next("updated-with-warning")}catch(H){Y.next("update-error")}}catch(D){V.debug("check failed",{error:D})}finally{await Zz(5000),Y.next("hidden"),z.unsubscribe(),Y.complete()}}),{state:X}}Mj();import{stderr as iz}from"node:process";function CV4(J){let Z=new rW().name("install").description("Install required tools like ripgrep to $AMP_HOME/bin").option("--force","Force reinstallation even if already installed").option("--verbose","Show installation progress and results").action(async(Y)=>{await zx0(Y.force||!1,Y.verbose||!1,"0.0.1773203397-g13b2f7"),process.exit()});J.addCommand(Z,{hidden:!0});let Q=new rW("update").summary("Update Amp CLI").description("Update Amp CLI to the latest version. You can specify a particular version to install, or leave blank to get the latest stable release.").option("--target-version <version>","Update to a specific version").allowUnknownOption(!1).action(async(Y)=>{await sA5(Y.targetVersion)});J.addCommand(Q)}async function sA5(J){if(process.env.AMP_SKIP_UPDATE_CHECK==="1")iz.write(Q1.yellow(`Note: AMP_SKIP_UPDATE_CHECK=1 is set, which disables automatic update checking. Manual updates will still work.
6001
6001
 
6002
6002
  `));try{if(!J){iz.write(Q1.blue(`Checking for updates...
6003
- `));let{hasUpdate:Y,latestVersion:X}=Dx0()?await p80("0.0.1773173082-gfe7cc2"):await g80("0.0.1773173082-gfe7cc2",cE());if(!Y){let V=Nx0("0.0.1773173082-gfe7cc2"),K=V?.age?`released ${V.age} ago`:`built ${Rq(new Date("2026-03-10T20:10:20.465Z"))} ago`;iz.write(Q1.green(`✓ Amp is already up to date on version ${"0.0.1773173082-gfe7cc2"} (${K})
6004
- `));let z=await zH("0.0.1773173082-gfe7cc2");if(z.warning)iz.write(`
6003
+ `));let{hasUpdate:Y,latestVersion:X}=Dx0()?await p80("0.0.1773203397-g13b2f7"):await g80("0.0.1773203397-g13b2f7",cE());if(!Y){let V=Nx0("0.0.1773203397-g13b2f7"),K=V?.age?`released ${V.age} ago`:`built ${Rq(new Date("2026-03-11T04:35:24.440Z"))} ago`;iz.write(Q1.green(`✓ Amp is already up to date on version ${"0.0.1773203397-g13b2f7"} (${K})
6004
+ `));let z=await zH("0.0.1773203397-g13b2f7");if(z.warning)iz.write(`
6005
6005
  `+Q1.yellow(z.warning)+`
6006
6006
  `);process.exit(0)}if(!X)iz.write(Q1.yellow("[WARN] could not find latest version")),process.exit(0);J=X}iz.write(Q1.blue(`Updating to version ${J}...
6007
6007
  `)),await lm(J,void 0,(Y)=>{iz.write(Q1.dim(`Running: ${Y}
@@ -7162,7 +7162,7 @@ Ctrl-X, Y, Z to unlock`;if(q){let f=U.text.replace(/`([^`]+)`/g,"$1")+`
7162
7162
  `),V=[];for(let K=0;K<X.length;K++){let U=X[K].replace(/\b(SELECT|FROM|WHERE|GROUP BY|ORDER BY|HAVING|LIMIT|JOIN|LEFT JOIN|RIGHT JOIN|INNER JOIN|ON|AND|OR|AS|IN|NOT|NULL|IS|BETWEEN|LIKE|EXISTS|UNION|DISTINCT|COUNT|SUM|AVG|MIN|MAX|DATE|TIMESTAMP_TRUNC|TIMESTAMP_SUB|CURRENT_TIMESTAMP|INTERVAL|CASE|WHEN|THEN|ELSE|END|WITH|INSERT|UPDATE|DELETE|SET|VALUES|INTO|CREATE|ALTER|DROP|TRUE|FALSE|ASC|DESC)\b/gi,"\x00$1\x01").split(/(\x00[^\x01]+\x01)/);for(let G of U)if(G.startsWith("\x00")&&G.endsWith("\x01"))V.push(new C(G.slice(1,-1),new b({color:Y.app.keybind,bold:!0})));else V.push(new C(G,new b({color:Q.colorScheme.foreground})));if(K<X.length-1)V.push(new C(`
7163
7163
  `))}return new c0({decoration:{color:Q.colorScheme.background,border:u1.all(new v1(Y.app.keybind,1,"rounded"))},child:new i0({padding:C0.symmetric(0,1),child:new $0({text:new C(void 0,void 0,V)})})})}}class jg0 extends O2{chartData;highlightIndex;showAxes;colors;constructor({key:J,chartData:Z,highlightIndex:Q=null,showAxes:Y=!0,colors:X=H$0}){super(J?{key:J}:{});this.chartData=Z,this.highlightIndex=Q,this.showAxes=Y,this.colors=X}createRenderObject(){return new Ag0({chartData:this.chartData,highlightIndex:this.highlightIndex,showAxes:this.showAxes,colors:this.colors})}updateRenderObject(J){let Z=J;Z.chartData=this.chartData,Z.highlightIndex=this.highlightIndex,Z.showAxes=this.showAxes,Z.colors=this.colors,Z.markNeedsLayout()}}function vw4(J,Z,Q,Y,X,V,K){if(V<=0)return null;switch(J){case"horizontal-bar":{let z=Q;return z>=0&&z<V?z:null}case"bar":case"stacked-bar":{let z=K?p8:0,D=Y-z;if(D<=0)return null;let U=Z-z;if(U<0||U>=D)return null;let G=Math.max(1,Math.floor(D/V)),F=Math.floor(U/G);return F>=0&&F<V?F:null}case"line":case"sparkline":case"stacked-area":{let z=K?p8:0,D=Y-z;if(D<=0)return null;let U=Math.max(0,Math.min(D-1,Z-z));if(V===1)return 0;let G=D/(V-1),F=Math.round(U/G);return Math.max(0,Math.min(V-1,F))}default:return null}}function Dc5(J,Z,Q,Y,X,V,K,z){if(X<=0||Z<0||Z>=X)return null;let D=2;switch(J){case"horizontal-bar":return{x:Math.floor(Q/2),y:Z};case"bar":case"stacked-bar":{let U=V?p8:0,G=Q-U,F=Y-(V?D:0);if(G<=0||F<=0)return null;let q=Math.max(1,Math.floor(G/X)),W=U+Z*q+Math.floor(q/2),H=z>0?K/z:0,B=Math.round((1-H)*(F-1));return{x:W,y:B}}case"line":case"sparkline":case"stacked-area":{let U=V?p8:0,G=Q-U,F=Y-(V?D:0);if(G<=0||F<=0)return null;let q=X>1?U+Math.round(Z/(X-1)*(G-1)):U+Math.floor(G/2),W=z>0?K/z:0,H=Math.round((1-W)*(F-1));return{x:q,y:H}}default:return null}}function Uc5(J){let Z=0;for(let Q of J)for(let Y of Q.points)if(Y.value>Z)Z=Y.value;return Z||1}function Gc5(J,Z,Q,Y,X){if(Q.length<=1){let z=Y(J.value),D=J.meta?` (${J.meta})`:"";return J.label.length+2+z.length+D.length}let V=J.label.length,K=0;for(let z of Q){let D=z.points[Z];if(!D)continue;K+=D.value;let U=2+z.name.length+2+Y(D.value).length;V=Math.max(V,U)}if(X){let z=9+Y(K).length;V=Math.max(V,z)}return V}function Fc5(J,Z,Q,Y,X,V,K){let z;try{let H=I1.of(J),B=f0.of(J);z={foreground:H.colorScheme.foreground,background:H.colorScheme.background,border:B.app.keybind}}catch{z={foreground:{type:"index",value:15},background:{type:"index",value:0},border:{type:"index",value:7}}}let D=new b({color:z.foreground,bold:!0}),U=new b({color:z.foreground}),G=new b({color:z.foreground,dim:!0}),F=[],q=new b({color:z.foreground,underline:!0}),W=(H,B)=>new C(B,q,void 0,J90(H),()=>{G8(J,H)});if(Y.length<=1){if(F.push(new C(`${Z.label}: `,D)),Z.link)F.push(W(Z.link,V(Z.value)));else F.push(new C(V(Z.value),U));if(Z.meta)F.push(new C(` (${Z.meta})`,G))}else{let H=K==="stacked-bar"||K==="stacked-area";F.push(new C(`${Z.label}
7164
7164
  `,D));let B=0;for(let w=0;w<Y.length;w++){let N=Y[w],O=N.points[Q];if(!O)continue;B+=O.value;let E=N.color??X[w%X.length]??z.foreground;if(F.push(new C("● ",new b({color:E}))),F.push(new C(`${N.name}: `,G)),O.link)F.push(W(O.link,V(O.value)));else F.push(new C(V(O.value),U));if(w<Y.length-1||H)F.push(new C(`
7165
- `))}if(H)F.push(new C(" ",G)),F.push(new C("Total: ",G)),F.push(new C(V(B),U))}return new c0({decoration:{color:z.background,border:u1.all(new v1(z.border,1,"rounded"))},child:new $0({text:new C(void 0,void 0,F)})})}aw();h0();t9();import{execSync as mc5}from"node:child_process";MI();jJ();F3();I7();ow();xX();S$();v$();kX();BE();b4();Jx();Yk();B1();var PN4=H4(PU(),1);import{writeFile as MN4}from"fs/promises";import AN4 from"path";h0();S$();class Rg0{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Z){this.enabled=J;this.configService=Z;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Z,Q])=>({feature:"cli.command",action:Z,source:{client:"cli",clientVersion:"0.0.1773173082-gfe7cc2"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await Bt(Z,this.configService)}catch(Z){j.error("Failed to export command telemetry events",Z)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Z=this.commandCounts.get(J)||0;this.commandCounts.set(J,Z+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class oH extends d0{props;constructor(J){super();this.props=J}createState(){return new kw4}}class kw4 extends g0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Z=(Q)=>{this.setState(()=>{this._state=Q(this._state)})};return this.widget.props.builder(J,Z,this._state)}}class yw4 extends g0{controller=new p7;focusNode=new s4({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});_textListener=()=>{this.setState(()=>{})};initState(){this.focusNode.requestFocus(),this.controller.addListener(this._textListener)}dispose(){this.controller.removeListener(this._textListener),this.focusNode.dispose()}build(J){let Z=f0.of(J),{colors:Q,app:Y}=Z,X=this.widget.props.isRequiredArg??!0,V=this.controller.text.trim().length>0,K=!X||V,z=u1.all(new v1(Q.foreground,1,"solid")),D=new QJ({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(W)=>{let H=W.trim();if(X&&H.length===0)return;this.widget.props.onSubmit(H)},autofocus:!0,style:{textColor:Q.foreground,border:null},maxLines:1}),U=new G1({children:[new c0({decoration:{color:Q.background},child:new $0({text:new C(">",new b({color:Q.foreground}))})}),new T1({child:D})]}),G=new c0({padding:C0.symmetric(1,0),child:new $0({text:new C("",void 0,[new C("Command: ",new b({color:Q.foreground})),new C(this.widget.props.commandName,new b({color:Y.command,bold:!0}))])})}),F=[];if(K)F.push(new C("Enter",new b({color:Y.keybind}))),F.push(new C(" to submit, ",new b({color:Q.foreground,dim:!0})));F.push(new C("Esc",new b({color:Y.keybind}))),F.push(new C(" to cancel",new b({color:Q.foreground,dim:!0})));let q=new c0({padding:C0.symmetric(1,0),child:new $0({text:new C("",void 0,F)})});return new c0({decoration:{border:z,color:Q.background},padding:C0.all(1),child:new u0({children:[G,new R0({height:1}),U,new X3,q]})})}}class vp extends d0{props;constructor(J){super();this.props=J}createState(){return new yw4}}import{isDeepStrictEqual as Pg0}from"node:util";var qc5=/[\\/_ +.#"@[({&]/,Wc5=/[\\/_ +.#"@[({&]/g,Hc5=/[\s-]/,uw4=/[\s-]/g;function N$0(J,Z,Q,Y,X,V,K){if(V===Z.length){if(X===J.length)return 1;return 0.99}let z=`${X},${V}`;if(K[z]!==void 0)return K[z];let D=Y.charAt(V),U=Q.indexOf(D,X),G=0,F,q,W,H;while(U>=0){if(F=N$0(J,Z,Q,Y,U+1,V+1,K),F>G){if(U===X)F*=1;else if(Hc5.test(J.charAt(U-1))){if(F*=0.9,H=J.slice(X,U-1).match(uw4),H&&X>0)F*=0.999**H.length}else if(qc5.test(J.charAt(U-1))){if(F*=0.8,W=J.slice(X,U-1).match(Wc5),W&&X>0)F*=0.999**W.length}else if(F*=0.3,X>0)F*=0.999**(U-X);if(J.charAt(U)!==Z.charAt(V))F*=0.9999}if(F<0.1&&(Q.charAt(U-1)===Y.charAt(V+1)||Y.charAt(V+1)===Y.charAt(V)&&Q.charAt(U-1)!==Y.charAt(V))){if(q=N$0(J,Z,Q,Y,U+1,V+2,K),q*0.1>F)F=q*0.1}if(F>G)G=F;U=Q.indexOf(D,U+1)}return K[z]=G,G}function w$0(J){return J.toLowerCase().replace(uw4," ")}function xw4(J,Z){let Q=N$0(J,Z,w$0(J),w$0(Z),0,0,{}),Y=Z.trim().split(/\s+/);if(Y.length>1){let X=0,V=0;for(let z of Y){let D=N$0(J,z,w$0(J),w$0(z),0,0,{});if(D===0)return Q;X+=D,V+=z.length}let K=X/Y.length*0.95;return Math.max(Q,K)}return Q}class vT{}class kT{}class O$0{}class E$0{}class fw4 extends d0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new bw4}}class bw4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}function Bc5(J,Z){if(J==="")return{matches:!0,score:1};let Q=xw4(Z,J);return{matches:Q>0.15,score:Q}}class a9 extends d0{props;debugLabel="FuzzyPicker";constructor(J){super();this.props=J}createState(){return new hw4}}class hw4 extends g0{textController;focusNode;scrollController=new Q5;selectedIndex=0;itemContexts=[];hasUserInteracted=!1;cachedQuery="";cachedItemsRef=null;cachedFiltered=[];initState(){if(this.scrollController.disableFollowMode(),this.textController=new p7(this.widget.props.controller?.query??""),this.focusNode=new s4({debugLabel:this.widget.debugLabel}),this.textController.addListener(()=>{this.hasUserInteracted=!0,this.selectedIndex=0,this.recomputeFilteredItems(),this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});let J=this.widget.props.controller;if(J)J.query=this.textController.text;this.syncSelection()}),this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let J=this.cachedFiltered.findIndex((Z)=>Pg0(Z,this.widget.props.controller?.selectedItem));if(J>=0)this.selectedIndex=J}this.clampSelectedIndex(),this.syncSelection(),this.ensureSelectedItemVisible()}didUpdateWidget(J){if(!Pg0(J.props.items,this.widget.props.items)){if(this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let Z=this.cachedFiltered.findIndex((Q)=>Pg0(Q,this.widget.props.controller?.selectedItem));if(Z>=0)this.selectedIndex=Z}this.clampSelectedIndex(),this.ensureSelectedItemVisible(),this.syncSelection()}}dispose(){this.widget.props.onSelectionChange?.(null),this.textController.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}invoke=(J)=>{if(J instanceof vT){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length-1)this.hasUserInteracted=!0,this.selectedIndex++,this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof kT){if(this.getFilteredItems().length>0&&this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--,this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof O$0){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length){let Q=Z[this.selectedIndex];if(Q){if(!(this.widget.props.isItemDisabled?.(Q)??!1))this.widget.props.onAccept(Q,{hasUserInteracted:this.hasUserInteracted})}}return"handled"}if(J instanceof E$0)return this.widget.props.onDismiss?.(),"handled";return"ignored"};syncSelection(){let Z=this.cachedFiltered[this.selectedIndex]??null;if(this.widget.props.controller)this.widget.props.controller.selectedItem=Z;this.widget.props.onSelectionChange?.(Z)}clampSelectedIndex(){let J=this.cachedFiltered.length-1;if(J<0){this.selectedIndex=0;return}this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,J))}recomputeFilteredItems(){let J=this.textController.text,Z=this.widget.props.items,Q=this.widget.props.normalizeQuery?.(J)??J,Y=Z.filter((X)=>!this.widget.props.filterItem||this.widget.props.filterItem(X,J)).map((X)=>({item:X,...Bc5(Q,this.widget.props.getLabel(X))})).filter((X)=>X.matches).sort(this.widget.props.sortItems?(X,V)=>this.widget.props.sortItems(X,V,J):(X,V)=>V.score-X.score).map((X)=>X.item);this.cachedQuery=J,this.cachedItemsRef=Z,this.cachedFiltered=this.widget.props.maxRenderItems?Y.slice(0,this.widget.props.maxRenderItems):Y}getFilteredItems(){let J=this.textController.text,Z=this.widget.props.items;if(this.cachedQuery===J&&this.cachedItemsRef===Z)return this.cachedFiltered;return this.recomputeFilteredItems(),this.cachedFiltered}ensureSelectedItemVisible(){let J=this.itemContexts[this.selectedIndex];if(!J)return;let Z=J.findRenderObject();if(!Z)return;let Q=0,Y=Z.size.height;RT(J,{top:Q,bottom:Y},{padding:1})}handleScroll=(J)=>{let Z=this.getFilteredItems();if(Z.length===0)return!1;let Q=this.selectedIndex;if(J.direction==="down")if(this.selectedIndex<Z.length-1)this.hasUserInteracted=!0,this.selectedIndex++;else return!1;else if(this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--;else return!1;return this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection(),this.selectedIndex!==Q};handleItemClick=(J,Z)=>{let Q=this.getFilteredItems();if(J>=0&&J<Q.length){let Y=Q[J],X=Y?this.widget.props.isItemDisabled?.(Y)??!1:!1;if(Z===1)this.hasUserInteracted=!0,this.selectedIndex=J,this.setState(),this.syncSelection();else if(Z===2&&!X){if(Y)this.hasUserInteracted=!0,this.widget.props.onAccept(Y,{hasUserInteracted:this.hasUserInteracted})}}};build(J){let Z=f0.of(J),{colors:Q}=Z,Y=this.getFilteredItems(),X=u1.all(new v1(Q.foreground,1,"solid")),V=this.widget.props.hidePromptWhenLoading&&this.widget.props.isLoading,K=this.widget.props.enabled??!0,z=new QJ({controller:this.textController,focusNode:this.focusNode,autofocus:!0,enabled:K,style:{backgroundColor:Q.background,textColor:Q.foreground,cursorColor:Q.cursor,placeholderColor:Q.mutedForeground,border:null},maxLines:1}),D=new I2({shortcuts:new Map([[new $4("ArrowDown"),new vT],[new $4("ArrowUp"),new kT],[new $4("Tab"),new vT],[new $4("Tab",{shift:!0}),new kT],[new $4("n",{ctrl:!0}),new vT],[new $4("p",{ctrl:!0}),new kT],[new $4("Enter"),new O$0],[new $4("Escape"),new E$0]]),focusNode:this.focusNode,child:z}),U=new T9({actions:new Map([[vT,new t4(this.invoke)],[kT,new t4(this.invoke)],[O$0,new t4(this.invoke)],[E$0,new t4(this.invoke)]]),child:D}),G=new G1({children:[new c0({decoration:{color:Q.background},child:new $0({text:new C(">",new b({color:Q.foreground}))})}),new T1({child:U})]});this.itemContexts=[];let F;if(this.widget.props.isLoading){let w=this.widget.props.loadingText??"Loading...";F=new R0({height:10,child:new c1({child:new $0({text:new C(w,new b({color:Q.foreground}))})})})}else if(Y.length===0&&this.widget.props.emptyStateText)F=new T1({child:new c1({child:new $0({text:new C(this.widget.props.emptyStateText,new b({color:Q.foreground,dim:!0}))})})});else{let w=Y.map((N,O)=>{let E=O===this.selectedIndex,L=this.widget.props.isItemDisabled?.(N)??!1,M;if(this.widget.props.renderItem)M=this.widget.props.renderItem(N,E,L,J);else{let A=E?Z.app.selectionBackground:void 0,I=E?Z.app.selectionForeground:Q.foreground;M=new c0({decoration:A?{color:A}:void 0,padding:C0.symmetric(2,0),child:new $0({text:new C(this.widget.props.getLabel(N),new b({color:I,dim:L}))})})}return new fw4(new i1({onClick:(A)=>this.handleItemClick(O,A.clickCount),child:M}),(A)=>{this.itemContexts[O]=A})});F=new u0({children:w,crossAxisAlignment:"start"})}let q=new i1({onScroll:this.handleScroll,opaque:!1,child:new I6({controller:this.scrollController,autofocus:!1,child:F})}),W=[];if(this.widget.props.title){let w=new c0({padding:C0.symmetric(1,0),child:new $0({text:new C(this.widget.props.title,new b({color:Z.app.command,bold:!0}))})});W.push(w)}if(!V)W.push(G,new R0({height:1}));if(this.textController.text!==""){let w=Y.length>0?Y[this.selectedIndex]:void 0,N=w&&this.widget.props.buildDisabledReasonWidget?.(w,J);W.push(new T1({child:new u0({mainAxisAlignment:"spaceBetween",children:[new T1({child:q}),new c0({padding:C0.only({top:1}),child:new c1({child:N??new R0({height:1})})})]})}))}else W.push(new T1({child:q}));if(this.widget.props.footer)W.push(this.widget.props.footer);return new c0({decoration:{border:X,color:Q.background},padding:C0.symmetric(1,0),child:new u0({children:W})})}}function mw4(J){let Q=new Date().getTime()-J.getTime(),Y=Math.floor(Q/60000),X=Math.floor(Q/3600000),V=Math.floor(Q/86400000);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;if(X<24)return`${X}h ago`;if(V<7)return`${V}d ago`;return J.toLocaleDateString()}class Cg0 extends d1{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Z=[...this.props.entries].sort((X,V)=>V.pubDate.getTime()-X.pubDate.getTime()),Q=Math.max(0,...Z.map((X)=>mw4(X.pubDate).length));return new a9({items:Z,getLabel:(X)=>X.title,onAccept:(X)=>this.props.onSelect?.(X),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(X,V,K,z)=>{let D=f0.of(z),{colors:U}=D,G=D.app,F=V?G.selectionBackground:void 0,q=V?G.selectionForeground:U.foreground,W=U.mutedForeground,H=(B,w)=>new R0({width:w,child:G1.end([new $0({text:new C(B,new b({color:W}))})])});return new c0({decoration:F?{color:F}:void 0,padding:C0.symmetric(2,0),child:new G1({children:[new T1({child:new $0({text:new C(X.title,new b({color:q})),overflow:"ellipsis",maxLines:1})}),new R0({width:2}),H(mw4(X.pubDate),Q)]})})}})}}b4();class Tg0 extends d0{createState(){return new gw4}}class gw4 extends g0{isGreen=!0;timer;initState(){this.timer=setInterval(()=>{this.isGreen=!this.isGreen,this.setState()},700)}dispose(){if(this.timer)clearInterval(this.timer);super.dispose()}build(J){let Q=f0.of(J).colors;return new $0({text:new C("●",new b({color:this.isGreen?Q.success:Q.mutedForeground,bold:!0})),maxLines:1})}}var wc5=/\/threads\/(T-[^/?#\s<>]+)/i;function Nc5(J){let Z=J.trim(),Y=Z.match(wc5)?.[1];if(Y&&B8(Y))return Y;let X=Z.replace(/^[<("'`]+|[>")'`,.]+$/g,"");if(B8(X))return X;return null}function Oc5(J){let Z=new Map,Q=new Map,Y=new Map,X=[];for(let K of J)Z.set(K.id,K);for(let K of J){let z=K.relationships.find((D)=>D.role==="child"&&Z.has(D.threadID)&&(D.type==="fork"||D.type==="handoff"));if(z){Y.set(K.id,z.type);let D=z.threadID,U=Q.get(D)||[];U.push(K),Q.set(D,U)}else X.push(K)}return l70.flatten(X,(K)=>Q.get(K.id)).map((K)=>({...K.item,depth:K.depth,isLast:K.isLast,ancestorsAreLast:K.ancestorsAreLast,relationshipType:Y.get(K.item.id)}))}function _g0(J,Z,Q){return new $0({text:new C(`${J}${Z}`,new b({color:Q})),maxLines:1})}function Ec5(J,Z,Q,Y){return[_g0("+",J,Y.success),X3.horizontal(1),_g0("~",Z,Y.warning),X3.horizontal(1),_g0("-",Q,Y.destructive)]}function Lc5(J){return typeof J==="object"&&J!==null&&"then"in J&&typeof J.then==="function"}class L$0 extends d0{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}createState(){return new pw4}}class pw4 extends g0{spinner=new R3;spinnerInterval=null;isSwitchingThread=!1;get isBusy(){return this.isSwitchingThread||this.widget.props.isLoading===!0}updateSpinnerAnimation(){if(this.isBusy){if(!this.spinnerInterval)this.spinnerInterval=setInterval(()=>{this.spinner.step(),this.setState(()=>{})},100);return}if(this.spinnerInterval)clearInterval(this.spinnerInterval),this.spinnerInterval=null}setSwitchingThread(J){if(this.isSwitchingThread===J)return;this.setState(()=>{this.isSwitchingThread=J}),this.updateSpinnerAnimation()}initState(){super.initState(),this.updateSpinnerAnimation()}didUpdateWidget(J){this.updateSpinnerAnimation()}dispose(){if(this.spinnerInterval)clearInterval(this.spinnerInterval),this.spinnerInterval=null;super.dispose()}build(J){let{props:Z}=this.widget,Q=this.isBusy,Y=this.isSwitchingThread?"Switching thread...":"Loading threads...",X=`${this.spinner.toBraille()} ${Y}`,V=Z.filterByWorkspace&&Z.currentWorkspaceURI?Z.threads.filter((O)=>O.workspaceURI===Z.currentWorkspaceURI):Z.threads;if(Z.excludeCurrentThread&&Z.currentThreadID)V=V.filter((O)=>O.id!==Z.currentThreadID);let K=Z.recentThreadIDs||[],z=new Set(K),D=Z.currentThreadID,U=[...V].sort((O,E)=>{if(D){if(O.id===D)return-1;if(E.id===D)return 1}let L=K.indexOf(O.id),M=K.indexOf(E.id);if(L!==-1&&M!==-1)return L-M;if(L!==-1)return-1;if(M!==-1)return 1;return 0}),G=Oc5(U),F=Math.max(0,...G.map((O)=>O.description.timeAgo.length)),q=f0.of(J),W=new i0({padding:C0.symmetric(0,1),child:new c1({child:new $0({text:new C("",new b({color:q.colors.foreground,dim:!0}),[new C("Ctrl+T",new b({color:q.colors.primary,dim:!0})),new C(Z.filterByWorkspace?" for all workspaces":" to filter by workspace",new b({color:q.colors.foreground,dim:!0}))])})})}),H="",B=null,w=(O)=>{if(O!==H)H=O,B=Nc5(O);return B};return new a9({items:G,getLabel:(O)=>`${O.title} ${O.id}`,filterItem:(O,E)=>{let L=w(E);if(L)return O.id.toLowerCase()===L.toLowerCase();return!0},normalizeQuery:(O)=>w(O)?"":O,onAccept:async(O,E)=>{if(!Z.onSelect||this.isSwitchingThread)return;let L=Z.onSelect(O.id,E);if(!Lc5(L))return;this.setSwitchingThread(!0);try{await L}finally{if(this.mounted)this.setSwitchingThread(!1)}},onDismiss:Z.onDismiss,onSelectionChange:(O)=>{if(Z.previewController){if(O)Z.previewController.select(O.id)}},title:Z.title,enabled:!Q,isLoading:Q,hidePromptWhenLoading:!0,loadingText:X,emptyStateText:"No threads match your filter",maxRenderItems:200,footer:Q?void 0:W,renderItem:(O,E,L,M)=>{let A=f0.of(M),{app:I,colors:R}=A,_=E?I.selectionBackground:void 0,S=E?I.selectionForeground:R.foreground,y=R.mutedForeground,m=(s,B0)=>new R0({width:B0,child:G1.end([new $0({text:new C(s,new b({color:y}))})])}),f=Z.threadViewStates[O.id],v=[],x=O.relationshipType==="handoff",c=new Jp({connectorColor:R.mutedForeground});if(O.depth>0){let s=[],B0=O.ancestorsAreLast.slice(1);for(let D0 of B0)s.push(new C(c.getAncestorPrefix(D0),new b({color:c.connectorColor,dim:c.connectorDim})));let l=O.isLast?c.elbow:c.tee,K0=c.getConnectorText(l);s.push(new C(K0,new b({color:c.connectorColor,dim:c.connectorDim}))),v.push(new $0({text:new C("",void 0,s)}))}let i=[],h=D===O.id?new C("(current) ",new b({color:R.success})):z.has(O.id)?new C("(visited) ",new b({color:R.foreground,dim:!0})):null;if(h)i.push(new $0({text:h}));if(hO(f))i.push(new Tg0),i.push(new R0({width:1}));let a=O.title;if(O.relationshipType==="fork"){let s=a.match(/^Forked\((\d+)\): /);if(s)a=a.slice(s[0].length);else while(a.startsWith("Forked: "))a=a.slice(8);i.push(new $0({text:new C("[fork] ",new b({color:R.primary}))}))}else if(x)i.push(new $0({text:new C("[handoff] ",new b({color:R.accent}))}));if(i.push(new T1({child:new $0({text:new C(a,new b({color:S})),overflow:"ellipsis",maxLines:1})})),i.push(new R0({width:2})),O.diffStats&&(O.diffStats.added>0||O.diffStats.changed>0||O.diffStats.deleted>0)){let s=E?{success:y,warning:y,destructive:y}:R;i.push(...Ec5(O.diffStats.added,O.diffStats.changed,O.diffStats.deleted,s)),i.push(new R0({width:2}))}return i.push(m(O.description.timeAgo,F)),new c0({decoration:_?{color:_}:void 0,padding:C0.symmetric(2,0),child:new G1({children:[...v,...i]})})}})}}function dw4(J){return 1-(1-J)**3}function cw4(J,Z,Q){return J+(Z-J)*Q}function kp(J,Z){if(!J)return{x:0,y:0};let Q=Z-J.startTime,Y=Math.min(Q/J.durationX,1),X=Math.min(Q/J.durationY,1),V=dw4(Y),K=dw4(X);return{x:cw4(J.startOffset.x,J.targetOffset.x,V),y:cw4(J.startOffset.y,J.targetOffset.y,K)}}var Mc5={nodeWidth:3,horizontalSpacing:3};class yT{options;constructor(J={}){this.options={...Mc5,...J}}layout(J){let{childrenMap:Z,resolvedParent:Q}=this.buildTree(J),Y=[],X=Z.get(void 0)??[];if(this.options.comparator)X.sort(this.options.comparator);let V=0,K=(z,D)=>{let U=Z.get(z.id)??[];if(this.options.comparator)U.sort(this.options.comparator);let G={...z,parentID:Q.get(z.id)};if(U.length===0){Y.push({node:G,position:{x:V,y:D}});let B=V;return V+=this.options.nodeWidth+this.options.horizontalSpacing,B}let F=[];for(let B of U)F.push(K(B,D+1));let q=Math.min(...F),W=Math.max(...F),H=Math.floor((q+W)/2);return Y.push({node:G,position:{x:H,y:D}}),H};for(let z of X)K(z,0);return Y}buildTree(J){let Z=new Set(J.map((V)=>V.id)),Q=[...J].sort((V,K)=>V.id.localeCompare(K.id)),Y=new Map;for(let V of Q){if(!V.parentID||!Z.has(V.parentID)){Y.set(V.id,void 0);continue}let K=!1,z=V.parentID;while(z){if(z===V.id){K=!0;break}z=Y.get(z)}Y.set(V.id,K?void 0:V.parentID)}let X=new Map;for(let V of J){let K=Y.get(V.id);if(!X.has(K))X.set(K,[]);X.get(K).push(V)}return{childrenMap:X,resolvedParent:Y}}}var Ac5={nodeWidth:3,nodeHeight:2};class uT{options;constructor(J={}){this.options={...Ac5,...J}}calculate(J){let Z=[],Q=new Map;for(let Y of J)Q.set(Y.node.id,Y);for(let Y of J){if(!Y.node.parentID)continue;let X=Q.get(Y.node.parentID);if(!X)continue;let V=this.calculateConnectorLine(X.position,Y.position);Z.push({points:V,fromNodeID:X.node.id,toNodeID:Y.node.id})}return Z}calculateConnectorLine(J,Z){let Q=Math.floor(this.options.nodeWidth/2),Y=[],X=J.x+Q,V=Z.x+Q,K=J.y*(this.options.nodeHeight+3)+this.options.nodeHeight;Y.push({x:X,y:K});let z=K+1;if(Y.push({x:X,y:z}),X!==V)Y.push({x:V,y:z});let D=Z.y*(this.options.nodeHeight+3)-1;return Y.push({x:V,y:D}),Y}}var Ic5={nodeWidth:3,nodeHeight:2},jc5={x:0,y:0};class A$0{options;constructor(J={}){this.options={...Ic5,...J}}getNodeWidth(){return this.options.nodeWidth}render(J,Z,Q,Y=jc5,X,V,K,z){let D=z?f0.of(z):null,U=D?.colors,G=D?.app,F=U?.mutedForeground??U?.foreground;if(J.length===0)return new $0({text:new C("No nodes",new b({color:F}))});let q=Math.max(...J.map((I)=>I.position.y)),H=Math.max(...J.map((I)=>I.position.x))+this.options.nodeWidth+3,B=this.options.nodeHeight+3,w=[];for(let I=q;I>=0;I--){let R=J.filter((y)=>y.position.y===I);R.sort((y,m)=>y.position.x-m.position.x);let _=[],S=0;for(let y of R){if(y.position.x>S)_.push(new R0({width:y.position.x-S}));let m=y.node.id===Q,f=K?.(y.node.data)??!1,v=V?.activeFlashOn??!1,x=y.node.id===V?.copyFlashNodeId;_.push(this.renderNode(m,f,v,x,G,U)),S=y.position.x+this.options.nodeWidth}if(w.push(new G1({crossAxisAlignment:"start",children:_})),I>0){let y=J.filter((v)=>v.position.y===I-1),m=R,f=this.renderConnectors(y,m,Z,H,U,G);w.push(...f)}}let N=new u0({crossAxisAlignment:"start",children:w}),O=Math.round(Y.x),E=Math.round(Y.y*B),L=(q+1)*B,M=[new R0({width:H,height:L}),new k6({left:O,top:E,child:N})],A=Q?J.find((I)=>I.node.id===Q):void 0;if(A&&X){let I=X(A.node.data),R=q-A.position.y,_=O+A.position.x+this.options.nodeWidth+1,S=E+R*B+1,y=30;if(V?.maxTitleWidthPercent&&V.viewportWidth)y=Math.floor(V.viewportWidth*V.maxTitleWidthPercent/100);M.push(new k6({left:_,top:S,child:this.renderInfoBox(I,y,U,G)}))}return new c0({padding:C0.horizontal(2),child:new OH(new d6({fit:"expand",children:M}))})}renderNode(J,Z,Q,Y,X,V){let K="┌─┐",z="└─┘",D=J?X?.threadGraphNodeSelected??V?.primary??V?.foreground:X?.threadGraphNode??V?.primary??V?.foreground,U=!1;if(Y)D=X?.threadGraphNodeSelected??V?.primary??D,K="┏━┓",z="┗━┛",U=!0;else if(Z&&Q)D=X?.toolSuccess??V?.primary??D,K="┏━┓",z="┗━┛";return new u0({crossAxisAlignment:"start",children:[new $0({text:new C(K,new b({color:D,bold:U}))}),new $0({text:new C(z,new b({color:D,bold:U}))})]})}wrapText(J,Z){let Q=J.split(" "),Y=[],X="";for(let V of Q){if(V.length>Z)V=V.slice(0,Z-1)+"…";if(X.length===0)X=V;else if(X.length+1+V.length<=Z)X+=" "+V;else Y.push(X),X=V}if(X.length>0)Y.push(X);return Y}renderInfoBox(J,Z=30,Q,Y){let X=this.wrapText(J,Z),V=Math.min(Z,Math.max(1,...X.map((q)=>q.length))),K=V+2,z="┌"+"─".repeat(K)+"┐",D="└"+"─".repeat(K)+"┘",U=Q?.border??Y?.threadGraphConnector??Q?.foreground,G=Q?.foreground,F=[new $0({text:new C(z,new b({color:U}))})];for(let q of X){let W=" ".repeat(V-q.length);F.push(new $0({text:new C("│ ",new b({color:U}),[new C(q+W,new b({color:G??U})),new C(" │",new b({color:U}))])}))}return F.push(new $0({text:new C(D,new b({color:U}))})),new u0({crossAxisAlignment:"start",children:F})}renderConnectors(J,Z,Q,Y,X,V){let K=[],z=Math.floor(this.options.nodeWidth/2),D=V?.threadGraphConnector??X?.primary??X?.foreground,U=Array(Y).fill(" ");for(let q of Z){let W=q.position.x+z;if(W>=0&&W<Y)U[W]="▲"}K.push(new $0({text:new C(U.join(""),new b({color:D}))}));let G=Array(Y).fill(" ");for(let q of J){let W=Z.filter((O)=>O.node.parentID===q.node.id);if(W.length===0)continue;let H=q.position.x+z,B=W.map((O)=>O.position.x+z),w=Math.min(...B),N=Math.max(...B);for(let O=w;O<=N;O++)if(O>=0&&O<Y){if(O===H)if(W.length===1&&B[0]===H)G[O]="│";else if(O===w)G[O]="└";else if(O===N)G[O]="┘";else G[O]="┬";else if(B.includes(O))if(O===w)G[O]="└";else if(O===N)G[O]="┘";else G[O]="┴";else if(G[O]===" ")G[O]="─"}}K.push(new $0({text:new C(G.join(""),new b({color:D}))}));let F=Array(Y).fill(" ");for(let q of J){if(Z.filter((B)=>B.node.parentID===q.node.id).length===0)continue;let H=q.position.x+z;if(H>=0&&H<Y)F[H]="│"}return K.push(new $0({text:new C(F.join(""),new b({color:D}))})),K}}var Rc5={nodeWidth:1,nodeHeight:1,nodeIcon:"□",selectedIcon:"□"},Pc5={x:0,y:0};class Sg0{options;constructor(J={}){this.options={...Rc5,...J}}getNodeWidth(){return this.options.nodeWidth}render(J,Z,Q,Y=Pc5,X,V,K,z){let D=z?f0.of(z):null,U=D?.colors,G=D?.app,F=U?.mutedForeground??U?.foreground;if(J.length===0)return new $0({text:new C("No nodes",new b({color:F}))});let q=Math.max(...J.map((I)=>I.position.y)),H=Math.max(...J.map((I)=>I.position.x))+this.options.nodeWidth+3,B=this.options.nodeHeight+1,w=[];for(let I=q;I>=0;I--){let R=J.filter((y)=>y.position.y===I);R.sort((y,m)=>y.position.x-m.position.x);let _=[],S=0;for(let y of R){if(y.position.x>S)_.push(new R0({width:y.position.x-S}));let m=y.node.id===Q,f=K?.(y.node.data)??!1,v=V?.activeFlashOn??!1;_.push(this.renderNode(m,f,v,G,U)),S=y.position.x+this.options.nodeWidth}if(w.push(new G1({crossAxisAlignment:"start",children:_})),I>0){let y=J.filter((v)=>v.position.y===I-1),m=R,f=this.renderConnectors(y,m,Z,H,U,G);w.push(...f)}}let N=new u0({crossAxisAlignment:"start",children:w}),O=Math.round(Y.x),E=Math.round(Y.y*B),L=(q+1)*B,M=[new R0({width:H,height:L}),new k6({left:O,top:E,child:N})],A=Q?J.find((I)=>I.node.id===Q):void 0;if(A&&X){let I=X(A.node.data),R=q-A.position.y,_=O+A.position.x+this.options.nodeWidth+1,S=E+R*B,y=30;if(V?.maxTitleWidthPercent&&V.viewportWidth)y=Math.floor(V.viewportWidth*V.maxTitleWidthPercent/100);M.push(new k6({left:_,top:S,child:this.renderInfoBox(I,y,U)}))}return new c0({padding:C0.horizontal(2),child:new OH(new d6({fit:"expand",children:M}))})}renderNode(J,Z,Q,Y,X){let V=J?this.options.selectedIcon:this.options.nodeIcon,K=J?Y?.threadGraphNodeSelected??X?.primary??X?.foreground:Y?.threadGraphNode??X?.primary??X?.foreground;if(Z&&Q)K=Y?.toolSuccess??X?.primary??K,V="■";return new $0({text:new C(V,new b({color:K}))})}wrapText(J,Z){let Q=J.split(" "),Y=[],X="";for(let V of Q){if(V.length>Z)V=V.slice(0,Z-1)+"…";if(X.length===0)X=V;else if(X.length+1+V.length<=Z)X+=" "+V;else Y.push(X),X=V}if(X.length>0)Y.push(X);return Y}renderInfoBox(J,Z=30,Q){let Y=this.wrapText(J,Z),X=Q?.foreground,V=[];for(let K of Y)V.push(new $0({text:new C(K,new b({color:X??Q?.primary??Q?.foreground}))}));return new u0({crossAxisAlignment:"start",children:V})}renderConnectors(J,Z,Q,Y,X,V){let K=[],z=Math.floor(this.options.nodeWidth/2),D=V?.threadGraphConnector??X?.primary??X?.foreground,U=Array(Y).fill(" ");for(let G of J){let F=Z.filter((w)=>w.node.parentID===G.node.id);if(F.length===0)continue;let q=G.position.x+z,W=F.map((w)=>w.position.x+z),H=Math.min(...W),B=Math.max(...W);for(let w=H;w<=B;w++)if(w>=0&&w<Y){let N=w===q,O=W.includes(w);if(N&&O)if(F.length===1)U[w]="│";else if(w===H)U[w]="└";else if(w===B)U[w]="┘";else U[w]="┼";else if(N)if(w===H)U[w]="└";else if(w===B)U[w]="┘";else U[w]="┬";else if(O)if(w===H)U[w]="└";else if(w===B)U[w]="┘";else U[w]="┴";else if(U[w]===" ")U[w]="─"}}return K.push(new $0({text:new C(U.join(""),new b({color:D}))})),K}}class yp extends H3{onWidth;onHeight;constructor(J){super(J.child);this.onWidth=J.onWidth,this.onHeight=J.onHeight}createRenderObject(){return new lw4(this.onWidth,this.onHeight)}updateRenderObject(J){J.onWidth=this.onWidth,J.onHeight=this.onHeight}}class lw4 extends M4{onWidth;onHeight;constructor(J,Z){super();this.onWidth=J,this.onHeight=Z}performLayout(){let J=this._lastConstraints,Z=Number.isFinite(J.maxWidth)?J.maxWidth:80,Q=Number.isFinite(J.maxHeight)?J.maxHeight:24;this.onWidth(Z),this.onHeight?.(Q);let Y=this.children[0];if(Y)Y.layout(J),this.setSize(Y.size.width,Y.size.height);else this.setSize(J.minWidth,J.minHeight)}paint(J,Z,Q){for(let Y of this.children)Y.paint(J,Z,Q)}}class yL extends d0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new aw4}}var iw4=400,nw4=300,Cc5=16;class aw4 extends g0{selectedNodeId=null;positionedNodes=[];dateComparator=(J,Z)=>{let Q=J.data.updatedAt??"",Y=Z.data.updatedAt??"";return Q.localeCompare(Y)};layoutEngine=new yT({nodeWidth:1,horizontalSpacing:1,comparator:this.dateComparator});lineCalculator=new uT;renderer=new Sg0;animation=null;currentOffset={x:0,y:0};animationTimer=null;viewportWidth=80;viewportHeight=24;activeFlashOn=!0;activeFlashTimer=null;initState(){let{initialSelectedThreadID:J}=this.widget.props;if(J){let Q=this.widget.props.threads.find((Y)=>Y.id===J);if(Q)this.selectedNodeId=Q.id}this.startActiveFlashTimer()}startActiveFlashTimer(){if(!this.widget.props.threads.some((Z)=>Z.isActive))return;this.activeFlashTimer=setInterval(()=>{this.activeFlashOn=!this.activeFlashOn,this.setState()},700)}stopActiveFlashTimer(){if(this.activeFlashTimer)clearInterval(this.activeFlashTimer),this.activeFlashTimer=null}didUpdateWidget(J){let Z=new Set(J.props.threads.map((D)=>D.id)),Q=new Set(this.widget.props.threads.map((D)=>D.id));if(Z.size!==Q.size||[...Z].some((D)=>!Q.has(D)))this.stopAnimation(),this.currentOffset={x:0,y:0};let X=J.props.initialSelectedThreadID,V=this.widget.props.initialSelectedThreadID;if(X!==V&&V){let U=this.widget.props.threads.find((G)=>G.id===V);if(U)this.selectedNodeId=U.id,this.stopAnimation(),this.currentOffset={x:0,y:0}}let K=J.props.threads.some((D)=>D.isActive),z=this.widget.props.threads.some((D)=>D.isActive);if(K!==z){if(this.stopActiveFlashTimer(),z)this.startActiveFlashTimer()}}dispose(){this.stopAnimation(),this.stopActiveFlashTimer()}startAnimation(J){this.stopAnimation(),this.animation={startOffset:{...this.currentOffset},targetOffset:J,startTime:Date.now(),durationX:iw4,durationY:nw4};let Z=Math.max(iw4,nw4);this.animationTimer=setInterval(()=>{let Q=Date.now();if(this.currentOffset=kp(this.animation,Q),this.animation&&Q-this.animation.startTime>=Z)this.currentOffset={...this.animation.targetOffset},this.stopAnimation();this.setState()},Cc5)}stopAnimation(){if(this.animationTimer)clearInterval(this.animationTimer),this.animationTimer=null;this.animation=null}calculateCenterOffset(J,Z,Q){let Y=Math.floor(this.renderer.getNodeWidth()/2),V=Math.floor(this.viewportWidth/2)-J-Y,K=Q-Z,z=2,D=Math.floor(this.viewportHeight/2),G=Math.floor(D/2)-K;return{x:V,y:G}}animateToNode(J){let Z=this.positionedNodes.find((Q)=>Q.node.id===J);if(Z){let Q=Math.max(...this.positionedNodes.map((X)=>X.position.y)),Y=this.calculateCenterOffset(Z.position.x,Z.position.y,Q);this.startAnimation(Y)}}toGraphNodes(){return this.widget.props.threads.map((J)=>({id:J.id,parentID:J.parentID,data:{title:J.title,updatedAt:J.updatedAt,isActive:J.isActive}}))}toThreadNode(J){return{id:J.node.id,parentID:J.node.parentID,title:J.node.data.title,updatedAt:J.node.data.updatedAt}}handleKeyEvent=(J)=>{if(!this.selectedNodeId)return"ignored";let Z=this.positionedNodes,Q=Z.find((X)=>X.node.id===this.selectedNodeId);if(!Q)return"ignored";let Y;switch(J.key){case"ArrowUp":{let X=Z.filter((V)=>V.node.parentID===Q.node.id);if(X.length>0){X.sort((K,z)=>K.position.x-z.position.x);let V=Math.floor(X.length/2);Y=X[V]}break}case"ArrowDown":{Y=Z.find((X)=>X.node.id===Q.node.parentID);break}case"ArrowLeft":{let X=Z.filter((V)=>V.position.y===Q.position.y&&V.position.x<Q.position.x);if(X.length>0)X.sort((V,K)=>K.position.x-V.position.x),Y=X[0];break}case"ArrowRight":{let X=Z.filter((V)=>V.position.y===Q.position.y&&V.position.x>Q.position.x);if(X.length>0)X.sort((V,K)=>V.position.x-K.position.x),Y=X[0];break}case"Enter":{if(this.widget.props.onSelect)this.widget.props.onSelect(this.toThreadNode(Q));return"handled"}default:{if(this.widget.props.onKey)return this.widget.props.onKey(J);return"ignored"}}if(Y)return this.selectedNodeId=Y.node.id,this.widget.props.onSelectionChange?.(this.toThreadNode(Y)),this.animateToNode(Y.node.id),"handled";if(this.widget.props.onKey)return this.widget.props.onKey(J);return"ignored"};build(J){let Z=this.toGraphNodes();this.positionedNodes=this.layoutEngine.layout(Z);let Q=this.lineCalculator.calculate(this.positionedNodes);if(!this.animation&&this.currentOffset.x===0&&this.currentOffset.y===0){let G=(this.selectedNodeId?this.positionedNodes.find((F)=>F.node.id===this.selectedNodeId):null)??this.positionedNodes.find((F)=>!F.node.parentID);if(G){let F=Math.max(...this.positionedNodes.map((q)=>q.position.y));this.currentOffset=this.calculateCenterOffset(G.position.x,G.position.y,F)}}let X=this.widget.props.showTitle??!0,V=this.widget.props.offsetY??0,K={x:this.currentOffset.x,y:this.currentOffset.y+V},z=this.renderer.render(this.positionedNodes,Q,this.selectedNodeId??void 0,K,X?(U)=>U.title:void 0,{maxTitleWidthPercent:this.widget.props.maxTitleWidthPercent,viewportWidth:this.viewportWidth,activeFlashOn:this.activeFlashOn},(U)=>U.isActive??!1,J),D=new yp({onWidth:(U)=>{if(this.viewportWidth!==U)this.viewportWidth=U,this.stopAnimation(),this.currentOffset={x:0,y:0},this.setState()},onHeight:(U)=>{if(this.viewportHeight!==U)this.viewportHeight=U,this.stopAnimation(),this.currentOffset={x:0,y:0},this.setState()},child:z});return new y4({autofocus:this.widget.props.autofocus??!0,onKey:this.handleKeyEvent,debugLabel:"MiniThreadGraph",child:D})}getSelectedNode(){let J=this.positionedNodes.find((Z)=>Z.node.id===this.selectedNodeId);return J?this.toThreadNode(J):null}}class rw4 extends d0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new sw4}}class sw4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}var ow4=30,Tc5=30;class xT{}class fT{}class I$0{}class j$0{}class vg0 extends d0{props;constructor(J){super();this.props=J}createState(){return new tw4}}class tw4 extends g0{highlightedIndex=0;controller=new p7;focusNode;scrollController=new Q5;filteredClusters=[];itemContexts=[];initState(){this.focusNode=new s4({debugLabel:"ClusterPicker"}),this.scrollController.disableFollowMode(),this.recomputeFiltered(),this.controller.addListener(()=>{this.highlightedIndex=0,this.recomputeFiltered(),this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()})})}didUpdateWidget(J){if(J.props.clusters!==this.widget.props.clusters){if(this.recomputeFiltered(),this.highlightedIndex>=this.filteredClusters.length)this.highlightedIndex=Math.max(0,this.filteredClusters.length-1)}}ensureSelectedItemVisible(){let J=this.itemContexts[this.highlightedIndex];if(!J)return;let Z=J.findRenderObject();if(!Z)return;let Q=0,Y=Z.size.height;RT(J,{top:Q,bottom:Y},{padding:1})}dispose(){this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}recomputeFiltered(){let J=this.controller.text.toLowerCase(),{clusters:Z}=this.widget.props;if(!J)this.filteredClusters=[...Z];else this.filteredClusters=Z.filter((Q)=>Q.label.toLowerCase().includes(J))}invoke=(J)=>{if(J instanceof xT){if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++,this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof fT){if(this.highlightedIndex>0)this.highlightedIndex--,this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof I$0){let Z=this.filteredClusters[this.highlightedIndex];if(Z)this.widget.props.onAccept(Z);return"handled"}if(J instanceof j$0)return this.widget.props.onDismiss(),"handled";return"ignored"};handleItemClick=(J,Z)=>{if(J>=0&&J<this.filteredClusters.length){if(Z===1)this.highlightedIndex=J,this.setState();else if(Z===2){let Q=this.filteredClusters[J];if(Q)this.widget.props.onAccept(Q)}}};handleScroll=(J)=>{if(this.filteredClusters.length===0)return!1;let Z=this.highlightedIndex;if(J.direction==="down")if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++;else return!1;else if(this.highlightedIndex>0)this.highlightedIndex--;else return!1;return this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.highlightedIndex!==Z};build(J){let{currentThreadID:Z}=this.widget.props,Q=f0.of(J),{colors:Y,app:X}=Q,z=a1.of(J).size.width>=Tc5+ow4,D=u1.all(new v1(Y.foreground,1,"solid")),U=this.filteredClusters[this.highlightedIndex]??null,G=new c0({padding:C0.symmetric(1,0),child:new $0({text:new C("Select a cluster",new b({color:X.command,bold:!0}))})}),F=new QJ({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:!0,style:{textColor:Y.foreground,border:null},maxLines:1}),q=new I2({shortcuts:new Map([[new $4("ArrowDown"),new xT],[new $4("ArrowUp"),new fT],[new $4("Tab"),new xT],[new $4("Tab",{shift:!0}),new fT],[new $4("n",{ctrl:!0}),new xT],[new $4("p",{ctrl:!0}),new fT],[new $4("Enter"),new I$0],[new $4("Escape"),new j$0]]),focusNode:this.focusNode,child:F}),W=new T9({actions:new Map([[xT,new t4(this.invoke)],[fT,new t4(this.invoke)],[I$0,new t4(this.invoke)],[j$0,new t4(this.invoke)]]),child:q}),H=new G1({children:[new c0({decoration:{color:Y.background},child:new $0({text:new C(">",new b({color:Y.foreground}))})}),new T1({child:W})]});this.itemContexts=[];let B=this.filteredClusters.map((M,A)=>{let I=A===this.highlightedIndex,R=Z?M.threads.some((m)=>m.id===Z):!1,_=I?X.selectionBackground:void 0,S=I?X.selectionForeground:Y.foreground,y=[new C(M.label,new b({color:S})),new C(` (${M.threads.length})`,new b({color:S,dim:!0}))];if(R)y.push(new C(" (current)",new b({color:I?X.selectionForeground:Y.success})));return new rw4(new i1({onClick:(m)=>this.handleItemClick(A,m.clickCount),child:new c0({decoration:_?{color:_}:void 0,padding:C0.symmetric(2,0),child:new $0({text:new C("",void 0,y)})})}),(m)=>{this.itemContexts[A]=m})}),w=new u0({children:B,crossAxisAlignment:"start"}),N=new T1({child:new i1({onScroll:this.handleScroll,child:new I6({controller:this.scrollController,autofocus:!1,child:w})})}),O=U?U.threads.map((M)=>({id:M.id,title:M.title,parentID:M.parentID,updatedAt:M.updatedAt})):[],E=U?new c0({padding:C0.all(1),child:new yL({threads:O,autofocus:!1,offsetY:2})}):null,L;if(z){let M=E?new T1({child:E}):new R0({width:ow4});L=new G1({crossAxisAlignment:"stretch",mainAxisAlignment:"start",children:[N,M]})}else{let M=[new T1({child:new i1({onScroll:this.handleScroll,child:new I6({controller:this.scrollController,autofocus:!1,child:w})})})];if(E)M.push(new T1({child:E}));L=new u0({crossAxisAlignment:"stretch",children:M})}return new c0({decoration:{border:D,color:Y.background},padding:C0.symmetric(1,0),child:new u0({children:[G,H,new R0({height:1}),new T1({child:L})]})})}}class YJ{static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!YJ._instance)YJ._instance=new YJ;return YJ._instance}get allExpanded(){return this._allExpanded}setAllExpanded(J){if(this._allExpanded===J)return;this._allExpanded=J,this._notifyListeners()}toggleAll(){this.setAllExpanded(!this._allExpanded)}addListener(J){return this._listeners.add(J),()=>this.removeListener(J)}removeListener(J){this._listeners.delete(J)}_notifyListeners(){for(let J of this._listeners)J()}}h0();class ew4 extends g0{labels=[];isLoading=!0;currentQuery="";initState(){this.loadLabels()}async loadLabels(){try{let J=await this.widget.props.internalAPIClient.getUserLabels({query:""},{config:this.widget.props.configService});if(!J.ok){j.error("Failed to load labels",J.error),this.isLoading=!1,this.labels=[],this.setState();return}this.labels=J.result,this.isLoading=!1,this.setState()}catch(J){j.error("Failed to load labels",J),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(J){let Z=J.trim().toLowerCase();if(Z.length===0)return null;if(Z.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Z))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(J){return this.getValidationError(J)===null&&J.length>0}getAvailableLabels(){let J=this.widget.props.currentLabels||[];return this.labels.filter((Z)=>!J.includes(Z.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Z=J.trim().toLowerCase();if(!this.isValidLabelName(Z))return!1;let Q=this.widget.props.currentLabels||[],Y=this.labels.some((V)=>V.name===Z),X=Q.includes(Z);return!Y&&!X}build(J){let Z=f0.of(J),{app:Q,colors:Y}=Z,X=this.currentQuery.trim().toLowerCase(),V=X.length>0?this.getValidationError(X):null,K=this.getAvailableLabels(),D=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...K];return new a9({title:"Add Label",items:D,getLabel:(U)=>{if("__isCreateMarker"in U)return this.currentQuery.trim().toLowerCase();return U.name},onAccept:(U)=>{if("__isCreateMarker"in U)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(U.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:V||"Type to create a new label",renderItem:(U,G,F,q)=>{let W=G?Q.selectionBackground:void 0,H=G?Q.selectionForeground:Y.foreground;if("__isCreateMarker"in U&&U.__isCreateMarker){let w=this.currentQuery.trim().toLowerCase();return new c0({decoration:W?{color:W}:void 0,padding:C0.symmetric(2,0),child:new $0({text:new C("",void 0,[new C("Create new label: ",new b({color:H})),new C(w,new b({color:H,bold:!0}))])})})}return new c0({decoration:W?{color:W}:void 0,padding:C0.symmetric(2,0),child:new $0({text:new C(U.name,new b({color:H}))})})},filterItem:(U,G)=>{if(this.currentQuery!==G)this.currentQuery=G,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in U&&U.__isCreateMarker)return this.shouldShowCreateMarker(G);let q=G.trim().toLowerCase();return q.length===0||U.name.includes(q)},sortItems:(U,G,F)=>{let q="__isCreateMarker"in U.item&&U.item.__isCreateMarker,W="__isCreateMarker"in G.item&&G.item.__isCreateMarker;if(q&&!W)return-1;if(!q&&W)return 1;return G.score-U.score}})}}class kg0 extends d0{props;constructor(J){super();this.props=J}createState(){return new ew4}}class FD extends d0{props;constructor(J){super();this.props=J}createState(){return new $N4}}class $N4 extends g0{_spinner=new R3;animationInterval=null;initState(){super.initState(),this.animationInterval=setInterval(()=>{this._spinner.step(),this.setState(()=>{})},100)}dispose(){if(this.animationInterval)clearInterval(this.animationInterval),this.animationInterval=null;super.dispose()}build(J){let Z=f0.of(J),{colors:Q,app:Y}=Z,X=u1.all(new v1(Q.foreground,1,"solid")),V=this._spinner.toBraille(),K=new $0({textAlign:"center",text:new C("",void 0,[new C(V,new b({color:Y.processing})),new C(" ",void 0),new C(this.widget.props.message,new b({color:Q.foreground}))])}),D=[new T1({child:new u0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[K]})})];if(this.widget.props.onAbort)D.push(new R0({height:2,child:new c0({padding:C0.symmetric(2,0),child:new $0({text:new C("",new b({dim:!0}),[new C("Press ",new b({color:Q.foreground})),new C("Esc",new b({color:Q.info})),new C(" to cancel",new b({color:Q.foreground}))])})})}));let U=new c0({decoration:new k4(Q.background,X),child:new R0({width:60,height:7,child:new u0({mainAxisAlignment:"start",children:D})})});if(this.widget.props.onAbort)return new y4({debugLabel:"LoadingDialog",autofocus:!0,onKey:(G)=>{if(G.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:U});return U}}class _8 extends d0{controller;getScrollInfo;thickness;trackChar;thumbChar;showTrack;thumbColor;trackColor;constructor({key:J,controller:Z,getScrollInfo:Q,thickness:Y=1,trackChar:X="█",thumbChar:V="█",showTrack:K=!0,thumbColor:z,trackColor:D}){super(J?{key:J}:{});this.controller=Z,this.getScrollInfo=Q,this.thickness=Y,this.trackChar=X,this.thumbChar=V,this.showTrack=K,this.thumbColor=z,this.trackColor=D}createState(){return new JN4}}class JN4 extends g0{_dragStartY=null;_dragStartOffset=null;_isOverThumb=!1;_isPositionOverThumb(J){let{totalContentHeight:Z,viewportHeight:Q}=this.widget.getScrollInfo(),X=this.context.findRenderObject()?.size.height??0;if(X===0||Z<=Q)return!1;let V=this.widget.getScrollInfo(),K=Math.min(1,Q/Z),z=Math.max(1,X*K),D=Math.max(0,Math.min(1,V.scrollOffset/(Z-Q))),U=X-z,G=Math.max(0,U*D),F=G+z;return J>=G&&J<=F}_handleHover=(J)=>{let Z=this._isOverThumb;if(this._isOverThumb=this._isPositionOverThumb(J.localPosition.y),Z!==this._isOverThumb)this.setState()};_handleDrag=(J)=>{let{totalContentHeight:Z,viewportHeight:Q,scrollOffset:Y}=this.widget.getScrollInfo(),V=this.context.findRenderObject()?.size.height??0;if(V===0||Z<=Q)return;if(this._dragStartY===null)this._dragStartY=J.localPosition.y,this._dragStartOffset=Y;let K=J.localPosition.y-this._dragStartY,z=Math.min(1,Q/Z),D=Math.max(1,V*z),U=V-D;if(U<=0)return;let G=Z-Q,F=U/G,q=K/F,W=Math.max(0,Math.min(G,this._dragStartOffset+q));this.widget.controller.jumpTo(W)};_handleRelease=()=>{this._dragStartY=null,this._dragStartOffset=null};_handleClick=(J)=>{if(J.button!=="left")return;let Z=J.localPosition.y,{totalContentHeight:Q,viewportHeight:Y,scrollOffset:X}=this.widget.getScrollInfo(),K=this.context.findRenderObject()?.size.height??0;if(K===0||Q<=Y)return;let z=Math.min(1,Y/Q),D=Math.max(1,K*z),U=Q-Y,G=K-D,F=Math.max(0,Math.min(1,X/(Q-Y))),q=Math.max(0,G*F),W=q+D;if(Z>=q&&Z<=W)return;if(Z<q)this.widget.controller.animateTo(Math.max(0,X-Y));else this.widget.controller.animateTo(Math.min(U,X+Y))};build(J){return new i1({onClick:this._handleClick,onHover:this._handleHover,onDrag:this._handleDrag,onRelease:this._handleRelease,cursor:this._isOverThumb?N5.POINTER:N5.DEFAULT,child:new ZN4({controller:this.widget.controller,getScrollInfo:this.widget.getScrollInfo,thickness:this.widget.thickness,trackChar:this.widget.trackChar,thumbChar:this.widget.thumbChar,showTrack:this.widget.showTrack,thumbColor:this.widget.thumbColor,trackColor:this.widget.trackColor})})}}class ZN4 extends uC{controller;getScrollInfo;thickness;trackChar;thumbChar;showTrack;thumbColor;trackColor;constructor({key:J,controller:Z,getScrollInfo:Q,thickness:Y=1,trackChar:X="█",thumbChar:V="█",showTrack:K=!0,thumbColor:z,trackColor:D}){super(J?{key:J}:{});this.controller=Z,this.getScrollInfo=Q,this.thickness=Y,this.trackChar=X,this.thumbChar=V,this.showTrack=K,this.thumbColor=z,this.trackColor=D}createRenderObject(){return new QN4(this)}updateRenderObject(J){J.updateWidget(this)}}class QN4 extends M4{_widget;constructor(J){super();this._widget=J}updateWidget(J){this._widget=J,this.markNeedsLayout()}performLayout(){let J=this._lastConstraints;f4(!!J,"performLayout called without constraints");let Z=Math.min(J.maxWidth,this._widget.thickness),Q=J.maxHeight;this.setSize(Z,Q),super.performLayout()}getMinIntrinsicWidth(J){return this._widget.thickness}getMaxIntrinsicWidth(J){return this._widget.thickness}getMinIntrinsicHeight(J){return 0}getMaxIntrinsicHeight(J){return 0}paint(J,Z,Q){let{thumbStartFloat:Y,thumbSizeFloat:X,showScrollbar:V}=this._calculateScrollbarMetrics();if(!V)return;let K=this._widget.trackColor,z=this._widget.thumbColor,D=["▁","▂","▃","▄","▅","▆","▇","█"],U=Y,G=Y+X;for(let F=0;F<this.size.height;F++){let q="█",W=!0;if(F===Math.floor(U)){let H=1-(U-F),B=Math.floor(H*8);q=D[B]||"█",W=!1}else if(F===Math.floor(G)){let H=1-(G-F),B=Math.floor(H*8);q=D[B]||"█"}else if(F>U&&F<G)W=!1;J.setChar(Z,Q+F,q,{fg:z,bg:K,reverse:W},1)}}_calculateScrollbarMetrics(){let{totalContentHeight:J,viewportHeight:Z,scrollOffset:Q}=this._widget.getScrollInfo(),Y=this.size.height;if(J<=Z||Y<=0)return{thumbStartFloat:0,thumbSizeFloat:0,showScrollbar:!1};let X=Math.max(0,Math.min(1,Q/(J-Z))),V=Math.min(1,Z/J),K=Math.max(1,Y*V),z=Y-K;return{thumbStartFloat:Math.max(0,z*X),thumbSizeFloat:K,showScrollbar:!0}}}class uL extends d0{props;constructor(J){super();this.props=J}createState(){return new YN4}}class YN4 extends g0{scrollController=new Q5;scrollAreaKey=new f7("message-dialog-scroll-area");viewportHeight=20;initState(){super.initState(),this.scrollController.followMode=!1,this.scrollController.addListener(()=>{this.setState()})}dispose(){this.scrollController.dispose(),super.dispose()}isWidgetMessage(J){return J instanceof P2}resolveFooterStyle(J){if(this.isWidgetMessage(J))return J.footerStyle;return"default"}getViewportHeight(){let Z=this.scrollAreaKey.currentElement?.renderObject;if(Z&&"size"in Z){let Q=Z.size;if(typeof Q.height==="number"&&Q.height>0)return this.viewportHeight=Q.height,Q.height}return this.viewportHeight}build(J){let Z=f0.of(J),Q=this.widget.props.message,Y=(()=>{if(this.isWidgetMessage(Q))return{title:Q.title,type:Q.type};if(Q instanceof Error&&Q.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Q.message};if(Q instanceof Error&&Q.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Q.message};let G=J$0(Q);return{title:G.title,type:G.type,description:G.description}})(),X=Y.type==="error"?Z.app.toolError:Z.app.command,V=u1.all(new v1(Z.colors.border,1,"solid")),K=new c0({padding:C0.symmetric(1,0),child:new $0({text:new C(Y.title,new b({color:X,bold:!0}))})}),z=this.isWidgetMessage(Q)?Q.widget:new $0({text:new C(Y.description,new b({color:Z.colors.foreground})),selectable:!0}),D=new T1({child:new j2({child:new c0({padding:C0.symmetric(1,0),child:new G1({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new T1({child:new I6({controller:this.scrollController,autofocus:!0,child:z})}),new _8({controller:this.scrollController,thumbColor:Z.app.scrollbarThumb,trackColor:Z.app.scrollbarTrack,getScrollInfo:()=>{let G=this.scrollController.maxScrollExtent,F=this.scrollController.offset,q=this.getViewportHeight(),W=G+q;return{totalContentHeight:Math.max(W,0),viewportHeight:Math.max(q,1),scrollOffset:Math.max(F,0)}}})]})})})}),U=new c0({padding:C0.symmetric(1,0),child:new $0({text:(()=>{if(this.widget.props.onRetry)return new C("",void 0,[new C("Press ",new b({color:Z.colors.foreground,dim:!0})),new C("R",new b({color:Z.app.keybind})),new C(" to retry, ",new b({color:Z.colors.foreground,dim:!0})),new C("Esc",new b({color:Z.app.keybind})),new C(" to cancel",new b({color:Z.colors.foreground,dim:!0}))]);let G=this.resolveFooterStyle(this.widget.props.message);if(G==="none")return new C("",new b({color:Z.colors.foreground,dim:!0}));if(G==="help"){let F=new b({color:Z.app.keybind}),q=new b({color:Z.colors.foreground,dim:!0});return new C("",q,[new C("Press ",q),new C("Escape",F),new C(" to close • Use ",q),new C("↑↓",F),new C(" or ",q),new C("j/k",F),new C(" to scroll",q)])}return new C("Press any key to close",new b({color:Z.colors.foreground,dim:!0,italic:!0}))})()})});return new y4({onKey:(G)=>{if(this.widget.props.onRetry&&G.key==="r")return this.widget.props.onRetry(),"handled";if(G.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!1,child:new c0({decoration:{border:V,color:Z.colors.background},padding:C0.all(1),child:new u0({mainAxisAlignment:"center",children:[K,new R0({height:1}),D,U]})})})}}t9();class XN4 extends d0{props;constructor(J){super();this.props=J}createState(){return new VN4}}class VN4 extends g0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((J)=>{this.plugins=J,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(J){let Z=J.startsWith("file://")?J.slice(7):J,Q=this.widget.props.cwd;if(Z.startsWith(Q))return Z.slice(Q.length+1);return Z}statusIcon(J){let Z=m8.default(),{colors:Q,app:Y}=Z;switch(J){case"loading":return{icon:"◌",color:Q.warning};case"active":return{icon:"✓",color:Y.toolSuccess};case"error":return{icon:"✗",color:Y.toolError}}}build(J){let Z=f0.of(J),{app:Q}=Z;if(this.plugins.length===0)return new $0({text:new C("No plugins found.",new b({dim:!0}))});let Y=[],X=this.plugins.length,V=this.plugins.filter((D)=>D.status==="active").length,K=this.plugins.reduce((D,U)=>D+U.registeredCommands.length,0),z=this.plugins.reduce((D,U)=>D+U.registeredTools.length,0);if(Y.push(new C(`${V}/${X} ${p4(X,"plugin")} active`,new b({bold:!0}))),K>0||z>0)Y.push(new C(` (${K} ${p4(K,"command")}, ${z} ${p4(z,"tool")})`,new b({dim:!0})));Y.push(new C(`
7165
+ `))}if(H)F.push(new C(" ",G)),F.push(new C("Total: ",G)),F.push(new C(V(B),U))}return new c0({decoration:{color:z.background,border:u1.all(new v1(z.border,1,"rounded"))},child:new $0({text:new C(void 0,void 0,F)})})}aw();h0();t9();import{execSync as mc5}from"node:child_process";MI();jJ();F3();I7();ow();xX();S$();v$();kX();BE();b4();Jx();Yk();B1();var PN4=H4(PU(),1);import{writeFile as MN4}from"fs/promises";import AN4 from"path";h0();S$();class Rg0{enabled;configService;commandCounts=new Map;timer=null;bufferTimeMs=1e4;constructor(J,Z){this.enabled=J;this.configService=Z;this.startTimer()}startTimer(){this.timer=setInterval(()=>{this.flushEvents()},this.bufferTimeMs)}async flushEvents(){if(this.commandCounts.size===0||!await this.enabled())return;let J=Array.from(this.commandCounts.entries()).map(([Z,Q])=>({feature:"cli.command",action:Z,source:{client:"cli",clientVersion:"0.0.1773203397-g13b2f7"},parameters:{metadata:{count:Q}},timestamp:Date.now()*1000}));this.commandCounts.clear();try{let Z=JSON.stringify(J);await Bt(Z,this.configService)}catch(Z){j.error("Failed to export command telemetry events",Z)}}async submit(J){if(!await this.enabled()||this.timer===null)return;let Z=this.commandCounts.get(J)||0;this.commandCounts.set(J,Z+1)}async dispose(){if(await this.flushEvents(),this.timer!==null)clearInterval(this.timer),this.timer=null}}class oH extends d0{props;constructor(J){super();this.props=J}createState(){return new kw4}}class kw4 extends g0{_state;initState(){super.initState(),this._state=this.widget.props.initialState}build(J){let Z=(Q)=>{this.setState(()=>{this._state=Q(this._state)})};return this.widget.props.builder(J,Z,this._state)}}class yw4 extends g0{controller=new p7;focusNode=new s4({debugLabel:"CommandArgumentPrompt",onKey:(J)=>{if(J.key==="Escape")return this.widget.props.onDismiss(),"handled";return"ignored"}});_textListener=()=>{this.setState(()=>{})};initState(){this.focusNode.requestFocus(),this.controller.addListener(this._textListener)}dispose(){this.controller.removeListener(this._textListener),this.focusNode.dispose()}build(J){let Z=f0.of(J),{colors:Q,app:Y}=Z,X=this.widget.props.isRequiredArg??!0,V=this.controller.text.trim().length>0,K=!X||V,z=u1.all(new v1(Q.foreground,1,"solid")),D=new QJ({controller:this.controller,focusNode:this.focusNode,placeholder:this.widget.props.placeholder??"Enter command argument...",onSubmitted:(W)=>{let H=W.trim();if(X&&H.length===0)return;this.widget.props.onSubmit(H)},autofocus:!0,style:{textColor:Q.foreground,border:null},maxLines:1}),U=new G1({children:[new c0({decoration:{color:Q.background},child:new $0({text:new C(">",new b({color:Q.foreground}))})}),new T1({child:D})]}),G=new c0({padding:C0.symmetric(1,0),child:new $0({text:new C("",void 0,[new C("Command: ",new b({color:Q.foreground})),new C(this.widget.props.commandName,new b({color:Y.command,bold:!0}))])})}),F=[];if(K)F.push(new C("Enter",new b({color:Y.keybind}))),F.push(new C(" to submit, ",new b({color:Q.foreground,dim:!0})));F.push(new C("Esc",new b({color:Y.keybind}))),F.push(new C(" to cancel",new b({color:Q.foreground,dim:!0})));let q=new c0({padding:C0.symmetric(1,0),child:new $0({text:new C("",void 0,F)})});return new c0({decoration:{border:z,color:Q.background},padding:C0.all(1),child:new u0({children:[G,new R0({height:1}),U,new X3,q]})})}}class vp extends d0{props;constructor(J){super();this.props=J}createState(){return new yw4}}import{isDeepStrictEqual as Pg0}from"node:util";var qc5=/[\\/_ +.#"@[({&]/,Wc5=/[\\/_ +.#"@[({&]/g,Hc5=/[\s-]/,uw4=/[\s-]/g;function N$0(J,Z,Q,Y,X,V,K){if(V===Z.length){if(X===J.length)return 1;return 0.99}let z=`${X},${V}`;if(K[z]!==void 0)return K[z];let D=Y.charAt(V),U=Q.indexOf(D,X),G=0,F,q,W,H;while(U>=0){if(F=N$0(J,Z,Q,Y,U+1,V+1,K),F>G){if(U===X)F*=1;else if(Hc5.test(J.charAt(U-1))){if(F*=0.9,H=J.slice(X,U-1).match(uw4),H&&X>0)F*=0.999**H.length}else if(qc5.test(J.charAt(U-1))){if(F*=0.8,W=J.slice(X,U-1).match(Wc5),W&&X>0)F*=0.999**W.length}else if(F*=0.3,X>0)F*=0.999**(U-X);if(J.charAt(U)!==Z.charAt(V))F*=0.9999}if(F<0.1&&(Q.charAt(U-1)===Y.charAt(V+1)||Y.charAt(V+1)===Y.charAt(V)&&Q.charAt(U-1)!==Y.charAt(V))){if(q=N$0(J,Z,Q,Y,U+1,V+2,K),q*0.1>F)F=q*0.1}if(F>G)G=F;U=Q.indexOf(D,U+1)}return K[z]=G,G}function w$0(J){return J.toLowerCase().replace(uw4," ")}function xw4(J,Z){let Q=N$0(J,Z,w$0(J),w$0(Z),0,0,{}),Y=Z.trim().split(/\s+/);if(Y.length>1){let X=0,V=0;for(let z of Y){let D=N$0(J,z,w$0(J),w$0(z),0,0,{});if(D===0)return Q;X+=D,V+=z.length}let K=X/Y.length*0.95;return Math.max(Q,K)}return Q}class vT{}class kT{}class O$0{}class E$0{}class fw4 extends d0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new bw4}}class bw4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}function Bc5(J,Z){if(J==="")return{matches:!0,score:1};let Q=xw4(Z,J);return{matches:Q>0.15,score:Q}}class a9 extends d0{props;debugLabel="FuzzyPicker";constructor(J){super();this.props=J}createState(){return new hw4}}class hw4 extends g0{textController;focusNode;scrollController=new Q5;selectedIndex=0;itemContexts=[];hasUserInteracted=!1;cachedQuery="";cachedItemsRef=null;cachedFiltered=[];initState(){if(this.scrollController.disableFollowMode(),this.textController=new p7(this.widget.props.controller?.query??""),this.focusNode=new s4({debugLabel:this.widget.debugLabel}),this.textController.addListener(()=>{this.hasUserInteracted=!0,this.selectedIndex=0,this.recomputeFilteredItems(),this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});let J=this.widget.props.controller;if(J)J.query=this.textController.text;this.syncSelection()}),this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let J=this.cachedFiltered.findIndex((Z)=>Pg0(Z,this.widget.props.controller?.selectedItem));if(J>=0)this.selectedIndex=J}this.clampSelectedIndex(),this.syncSelection(),this.ensureSelectedItemVisible()}didUpdateWidget(J){if(!Pg0(J.props.items,this.widget.props.items)){if(this.recomputeFilteredItems(),this.widget.props.controller?.selectedItem){let Z=this.cachedFiltered.findIndex((Q)=>Pg0(Q,this.widget.props.controller?.selectedItem));if(Z>=0)this.selectedIndex=Z}this.clampSelectedIndex(),this.ensureSelectedItemVisible(),this.syncSelection()}}dispose(){this.widget.props.onSelectionChange?.(null),this.textController.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}invoke=(J)=>{if(J instanceof vT){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length-1)this.hasUserInteracted=!0,this.selectedIndex++,this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof kT){if(this.getFilteredItems().length>0&&this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--,this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection();return"handled"}if(J instanceof O$0){let Z=this.getFilteredItems();if(Z.length>0&&this.selectedIndex<Z.length){let Q=Z[this.selectedIndex];if(Q){if(!(this.widget.props.isItemDisabled?.(Q)??!1))this.widget.props.onAccept(Q,{hasUserInteracted:this.hasUserInteracted})}}return"handled"}if(J instanceof E$0)return this.widget.props.onDismiss?.(),"handled";return"ignored"};syncSelection(){let Z=this.cachedFiltered[this.selectedIndex]??null;if(this.widget.props.controller)this.widget.props.controller.selectedItem=Z;this.widget.props.onSelectionChange?.(Z)}clampSelectedIndex(){let J=this.cachedFiltered.length-1;if(J<0){this.selectedIndex=0;return}this.selectedIndex=Math.max(0,Math.min(this.selectedIndex,J))}recomputeFilteredItems(){let J=this.textController.text,Z=this.widget.props.items,Q=this.widget.props.normalizeQuery?.(J)??J,Y=Z.filter((X)=>!this.widget.props.filterItem||this.widget.props.filterItem(X,J)).map((X)=>({item:X,...Bc5(Q,this.widget.props.getLabel(X))})).filter((X)=>X.matches).sort(this.widget.props.sortItems?(X,V)=>this.widget.props.sortItems(X,V,J):(X,V)=>V.score-X.score).map((X)=>X.item);this.cachedQuery=J,this.cachedItemsRef=Z,this.cachedFiltered=this.widget.props.maxRenderItems?Y.slice(0,this.widget.props.maxRenderItems):Y}getFilteredItems(){let J=this.textController.text,Z=this.widget.props.items;if(this.cachedQuery===J&&this.cachedItemsRef===Z)return this.cachedFiltered;return this.recomputeFilteredItems(),this.cachedFiltered}ensureSelectedItemVisible(){let J=this.itemContexts[this.selectedIndex];if(!J)return;let Z=J.findRenderObject();if(!Z)return;let Q=0,Y=Z.size.height;RT(J,{top:Q,bottom:Y},{padding:1})}handleScroll=(J)=>{let Z=this.getFilteredItems();if(Z.length===0)return!1;let Q=this.selectedIndex;if(J.direction==="down")if(this.selectedIndex<Z.length-1)this.hasUserInteracted=!0,this.selectedIndex++;else return!1;else if(this.selectedIndex>0)this.hasUserInteracted=!0,this.selectedIndex--;else return!1;return this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.syncSelection(),this.selectedIndex!==Q};handleItemClick=(J,Z)=>{let Q=this.getFilteredItems();if(J>=0&&J<Q.length){let Y=Q[J],X=Y?this.widget.props.isItemDisabled?.(Y)??!1:!1;if(Z===1)this.hasUserInteracted=!0,this.selectedIndex=J,this.setState(),this.syncSelection();else if(Z===2&&!X){if(Y)this.hasUserInteracted=!0,this.widget.props.onAccept(Y,{hasUserInteracted:this.hasUserInteracted})}}};build(J){let Z=f0.of(J),{colors:Q}=Z,Y=this.getFilteredItems(),X=u1.all(new v1(Q.foreground,1,"solid")),V=this.widget.props.hidePromptWhenLoading&&this.widget.props.isLoading,K=this.widget.props.enabled??!0,z=new QJ({controller:this.textController,focusNode:this.focusNode,autofocus:!0,enabled:K,style:{backgroundColor:Q.background,textColor:Q.foreground,cursorColor:Q.cursor,placeholderColor:Q.mutedForeground,border:null},maxLines:1}),D=new I2({shortcuts:new Map([[new $4("ArrowDown"),new vT],[new $4("ArrowUp"),new kT],[new $4("Tab"),new vT],[new $4("Tab",{shift:!0}),new kT],[new $4("n",{ctrl:!0}),new vT],[new $4("p",{ctrl:!0}),new kT],[new $4("Enter"),new O$0],[new $4("Escape"),new E$0]]),focusNode:this.focusNode,child:z}),U=new T9({actions:new Map([[vT,new t4(this.invoke)],[kT,new t4(this.invoke)],[O$0,new t4(this.invoke)],[E$0,new t4(this.invoke)]]),child:D}),G=new G1({children:[new c0({decoration:{color:Q.background},child:new $0({text:new C(">",new b({color:Q.foreground}))})}),new T1({child:U})]});this.itemContexts=[];let F;if(this.widget.props.isLoading){let w=this.widget.props.loadingText??"Loading...";F=new R0({height:10,child:new c1({child:new $0({text:new C(w,new b({color:Q.foreground}))})})})}else if(Y.length===0&&this.widget.props.emptyStateText)F=new T1({child:new c1({child:new $0({text:new C(this.widget.props.emptyStateText,new b({color:Q.foreground,dim:!0}))})})});else{let w=Y.map((N,O)=>{let E=O===this.selectedIndex,L=this.widget.props.isItemDisabled?.(N)??!1,M;if(this.widget.props.renderItem)M=this.widget.props.renderItem(N,E,L,J);else{let A=E?Z.app.selectionBackground:void 0,I=E?Z.app.selectionForeground:Q.foreground;M=new c0({decoration:A?{color:A}:void 0,padding:C0.symmetric(2,0),child:new $0({text:new C(this.widget.props.getLabel(N),new b({color:I,dim:L}))})})}return new fw4(new i1({onClick:(A)=>this.handleItemClick(O,A.clickCount),child:M}),(A)=>{this.itemContexts[O]=A})});F=new u0({children:w,crossAxisAlignment:"start"})}let q=new i1({onScroll:this.handleScroll,opaque:!1,child:new I6({controller:this.scrollController,autofocus:!1,child:F})}),W=[];if(this.widget.props.title){let w=new c0({padding:C0.symmetric(1,0),child:new $0({text:new C(this.widget.props.title,new b({color:Z.app.command,bold:!0}))})});W.push(w)}if(!V)W.push(G,new R0({height:1}));if(this.textController.text!==""){let w=Y.length>0?Y[this.selectedIndex]:void 0,N=w&&this.widget.props.buildDisabledReasonWidget?.(w,J);W.push(new T1({child:new u0({mainAxisAlignment:"spaceBetween",children:[new T1({child:q}),new c0({padding:C0.only({top:1}),child:new c1({child:N??new R0({height:1})})})]})}))}else W.push(new T1({child:q}));if(this.widget.props.footer)W.push(this.widget.props.footer);return new c0({decoration:{border:X,color:Q.background},padding:C0.symmetric(1,0),child:new u0({children:W})})}}function mw4(J){let Q=new Date().getTime()-J.getTime(),Y=Math.floor(Q/60000),X=Math.floor(Q/3600000),V=Math.floor(Q/86400000);if(Y<1)return"just now";if(Y<60)return`${Y}m ago`;if(X<24)return`${X}h ago`;if(V<7)return`${V}d ago`;return J.toLocaleDateString()}class Cg0 extends d1{props;debugLabel="NewsFeedPicker";constructor(J){super();this.props=J}build(J){let Z=[...this.props.entries].sort((X,V)=>V.pubDate.getTime()-X.pubDate.getTime()),Q=Math.max(0,...Z.map((X)=>mw4(X.pubDate).length));return new a9({items:Z,getLabel:(X)=>X.title,onAccept:(X)=>this.props.onSelect?.(X),onDismiss:this.props.onDismiss,title:this.props.title,emptyStateText:"No news entries available",maxRenderItems:100,renderItem:(X,V,K,z)=>{let D=f0.of(z),{colors:U}=D,G=D.app,F=V?G.selectionBackground:void 0,q=V?G.selectionForeground:U.foreground,W=U.mutedForeground,H=(B,w)=>new R0({width:w,child:G1.end([new $0({text:new C(B,new b({color:W}))})])});return new c0({decoration:F?{color:F}:void 0,padding:C0.symmetric(2,0),child:new G1({children:[new T1({child:new $0({text:new C(X.title,new b({color:q})),overflow:"ellipsis",maxLines:1})}),new R0({width:2}),H(mw4(X.pubDate),Q)]})})}})}}b4();class Tg0 extends d0{createState(){return new gw4}}class gw4 extends g0{isGreen=!0;timer;initState(){this.timer=setInterval(()=>{this.isGreen=!this.isGreen,this.setState()},700)}dispose(){if(this.timer)clearInterval(this.timer);super.dispose()}build(J){let Q=f0.of(J).colors;return new $0({text:new C("●",new b({color:this.isGreen?Q.success:Q.mutedForeground,bold:!0})),maxLines:1})}}var wc5=/\/threads\/(T-[^/?#\s<>]+)/i;function Nc5(J){let Z=J.trim(),Y=Z.match(wc5)?.[1];if(Y&&B8(Y))return Y;let X=Z.replace(/^[<("'`]+|[>")'`,.]+$/g,"");if(B8(X))return X;return null}function Oc5(J){let Z=new Map,Q=new Map,Y=new Map,X=[];for(let K of J)Z.set(K.id,K);for(let K of J){let z=K.relationships.find((D)=>D.role==="child"&&Z.has(D.threadID)&&(D.type==="fork"||D.type==="handoff"));if(z){Y.set(K.id,z.type);let D=z.threadID,U=Q.get(D)||[];U.push(K),Q.set(D,U)}else X.push(K)}return l70.flatten(X,(K)=>Q.get(K.id)).map((K)=>({...K.item,depth:K.depth,isLast:K.isLast,ancestorsAreLast:K.ancestorsAreLast,relationshipType:Y.get(K.item.id)}))}function _g0(J,Z,Q){return new $0({text:new C(`${J}${Z}`,new b({color:Q})),maxLines:1})}function Ec5(J,Z,Q,Y){return[_g0("+",J,Y.success),X3.horizontal(1),_g0("~",Z,Y.warning),X3.horizontal(1),_g0("-",Q,Y.destructive)]}function Lc5(J){return typeof J==="object"&&J!==null&&"then"in J&&typeof J.then==="function"}class L$0 extends d0{props;debugLabel="ThreadContinuationPicker";constructor(J){super();this.props=J}createState(){return new pw4}}class pw4 extends g0{spinner=new R3;spinnerInterval=null;isSwitchingThread=!1;get isBusy(){return this.isSwitchingThread||this.widget.props.isLoading===!0}updateSpinnerAnimation(){if(this.isBusy){if(!this.spinnerInterval)this.spinnerInterval=setInterval(()=>{this.spinner.step(),this.setState(()=>{})},100);return}if(this.spinnerInterval)clearInterval(this.spinnerInterval),this.spinnerInterval=null}setSwitchingThread(J){if(this.isSwitchingThread===J)return;this.setState(()=>{this.isSwitchingThread=J}),this.updateSpinnerAnimation()}initState(){super.initState(),this.updateSpinnerAnimation()}didUpdateWidget(J){this.updateSpinnerAnimation()}dispose(){if(this.spinnerInterval)clearInterval(this.spinnerInterval),this.spinnerInterval=null;super.dispose()}build(J){let{props:Z}=this.widget,Q=this.isBusy,Y=this.isSwitchingThread?"Switching thread...":"Loading threads...",X=`${this.spinner.toBraille()} ${Y}`,V=Z.filterByWorkspace&&Z.currentWorkspaceURI?Z.threads.filter((O)=>O.workspaceURI===Z.currentWorkspaceURI):Z.threads;if(Z.excludeCurrentThread&&Z.currentThreadID)V=V.filter((O)=>O.id!==Z.currentThreadID);let K=Z.recentThreadIDs||[],z=new Set(K),D=Z.currentThreadID,U=[...V].sort((O,E)=>{if(D){if(O.id===D)return-1;if(E.id===D)return 1}let L=K.indexOf(O.id),M=K.indexOf(E.id);if(L!==-1&&M!==-1)return L-M;if(L!==-1)return-1;if(M!==-1)return 1;return 0}),G=Oc5(U),F=Math.max(0,...G.map((O)=>O.description.timeAgo.length)),q=f0.of(J),W=new i0({padding:C0.symmetric(0,1),child:new c1({child:new $0({text:new C("",new b({color:q.colors.foreground,dim:!0}),[new C("Ctrl+T",new b({color:q.colors.primary,dim:!0})),new C(Z.filterByWorkspace?" for all workspaces":" to filter by workspace",new b({color:q.colors.foreground,dim:!0}))])})})}),H="",B=null,w=(O)=>{if(O!==H)H=O,B=Nc5(O);return B};return new a9({items:G,getLabel:(O)=>`${O.title} ${O.id}`,filterItem:(O,E)=>{let L=w(E);if(L)return O.id.toLowerCase()===L.toLowerCase();return!0},normalizeQuery:(O)=>w(O)?"":O,onAccept:async(O,E)=>{if(!Z.onSelect||this.isSwitchingThread)return;let L=Z.onSelect(O.id,E);if(!Lc5(L))return;this.setSwitchingThread(!0);try{await L}finally{if(this.mounted)this.setSwitchingThread(!1)}},onDismiss:Z.onDismiss,onSelectionChange:(O)=>{if(Z.previewController){if(O)Z.previewController.select(O.id)}},title:Z.title,enabled:!Q,isLoading:Q,hidePromptWhenLoading:!0,loadingText:X,emptyStateText:"No threads match your filter",maxRenderItems:200,footer:Q?void 0:W,renderItem:(O,E,L,M)=>{let A=f0.of(M),{app:I,colors:R}=A,_=E?I.selectionBackground:void 0,S=E?I.selectionForeground:R.foreground,y=R.mutedForeground,m=(s,B0)=>new R0({width:B0,child:G1.end([new $0({text:new C(s,new b({color:y}))})])}),f=Z.threadViewStates[O.id],v=[],x=O.relationshipType==="handoff",c=new Jp({connectorColor:R.mutedForeground});if(O.depth>0){let s=[],B0=O.ancestorsAreLast.slice(1);for(let D0 of B0)s.push(new C(c.getAncestorPrefix(D0),new b({color:c.connectorColor,dim:c.connectorDim})));let l=O.isLast?c.elbow:c.tee,K0=c.getConnectorText(l);s.push(new C(K0,new b({color:c.connectorColor,dim:c.connectorDim}))),v.push(new $0({text:new C("",void 0,s)}))}let i=[],h=D===O.id?new C("(current) ",new b({color:R.success})):z.has(O.id)?new C("(visited) ",new b({color:R.foreground,dim:!0})):null;if(h)i.push(new $0({text:h}));if(hO(f))i.push(new Tg0),i.push(new R0({width:1}));let a=O.title;if(O.relationshipType==="fork"){let s=a.match(/^Forked\((\d+)\): /);if(s)a=a.slice(s[0].length);else while(a.startsWith("Forked: "))a=a.slice(8);i.push(new $0({text:new C("[fork] ",new b({color:R.primary}))}))}else if(x)i.push(new $0({text:new C("[handoff] ",new b({color:R.accent}))}));if(i.push(new T1({child:new $0({text:new C(a,new b({color:S})),overflow:"ellipsis",maxLines:1})})),i.push(new R0({width:2})),O.diffStats&&(O.diffStats.added>0||O.diffStats.changed>0||O.diffStats.deleted>0)){let s=E?{success:y,warning:y,destructive:y}:R;i.push(...Ec5(O.diffStats.added,O.diffStats.changed,O.diffStats.deleted,s)),i.push(new R0({width:2}))}return i.push(m(O.description.timeAgo,F)),new c0({decoration:_?{color:_}:void 0,padding:C0.symmetric(2,0),child:new G1({children:[...v,...i]})})}})}}function dw4(J){return 1-(1-J)**3}function cw4(J,Z,Q){return J+(Z-J)*Q}function kp(J,Z){if(!J)return{x:0,y:0};let Q=Z-J.startTime,Y=Math.min(Q/J.durationX,1),X=Math.min(Q/J.durationY,1),V=dw4(Y),K=dw4(X);return{x:cw4(J.startOffset.x,J.targetOffset.x,V),y:cw4(J.startOffset.y,J.targetOffset.y,K)}}var Mc5={nodeWidth:3,horizontalSpacing:3};class yT{options;constructor(J={}){this.options={...Mc5,...J}}layout(J){let{childrenMap:Z,resolvedParent:Q}=this.buildTree(J),Y=[],X=Z.get(void 0)??[];if(this.options.comparator)X.sort(this.options.comparator);let V=0,K=(z,D)=>{let U=Z.get(z.id)??[];if(this.options.comparator)U.sort(this.options.comparator);let G={...z,parentID:Q.get(z.id)};if(U.length===0){Y.push({node:G,position:{x:V,y:D}});let B=V;return V+=this.options.nodeWidth+this.options.horizontalSpacing,B}let F=[];for(let B of U)F.push(K(B,D+1));let q=Math.min(...F),W=Math.max(...F),H=Math.floor((q+W)/2);return Y.push({node:G,position:{x:H,y:D}}),H};for(let z of X)K(z,0);return Y}buildTree(J){let Z=new Set(J.map((V)=>V.id)),Q=[...J].sort((V,K)=>V.id.localeCompare(K.id)),Y=new Map;for(let V of Q){if(!V.parentID||!Z.has(V.parentID)){Y.set(V.id,void 0);continue}let K=!1,z=V.parentID;while(z){if(z===V.id){K=!0;break}z=Y.get(z)}Y.set(V.id,K?void 0:V.parentID)}let X=new Map;for(let V of J){let K=Y.get(V.id);if(!X.has(K))X.set(K,[]);X.get(K).push(V)}return{childrenMap:X,resolvedParent:Y}}}var Ac5={nodeWidth:3,nodeHeight:2};class uT{options;constructor(J={}){this.options={...Ac5,...J}}calculate(J){let Z=[],Q=new Map;for(let Y of J)Q.set(Y.node.id,Y);for(let Y of J){if(!Y.node.parentID)continue;let X=Q.get(Y.node.parentID);if(!X)continue;let V=this.calculateConnectorLine(X.position,Y.position);Z.push({points:V,fromNodeID:X.node.id,toNodeID:Y.node.id})}return Z}calculateConnectorLine(J,Z){let Q=Math.floor(this.options.nodeWidth/2),Y=[],X=J.x+Q,V=Z.x+Q,K=J.y*(this.options.nodeHeight+3)+this.options.nodeHeight;Y.push({x:X,y:K});let z=K+1;if(Y.push({x:X,y:z}),X!==V)Y.push({x:V,y:z});let D=Z.y*(this.options.nodeHeight+3)-1;return Y.push({x:V,y:D}),Y}}var Ic5={nodeWidth:3,nodeHeight:2},jc5={x:0,y:0};class A$0{options;constructor(J={}){this.options={...Ic5,...J}}getNodeWidth(){return this.options.nodeWidth}render(J,Z,Q,Y=jc5,X,V,K,z){let D=z?f0.of(z):null,U=D?.colors,G=D?.app,F=U?.mutedForeground??U?.foreground;if(J.length===0)return new $0({text:new C("No nodes",new b({color:F}))});let q=Math.max(...J.map((I)=>I.position.y)),H=Math.max(...J.map((I)=>I.position.x))+this.options.nodeWidth+3,B=this.options.nodeHeight+3,w=[];for(let I=q;I>=0;I--){let R=J.filter((y)=>y.position.y===I);R.sort((y,m)=>y.position.x-m.position.x);let _=[],S=0;for(let y of R){if(y.position.x>S)_.push(new R0({width:y.position.x-S}));let m=y.node.id===Q,f=K?.(y.node.data)??!1,v=V?.activeFlashOn??!1,x=y.node.id===V?.copyFlashNodeId;_.push(this.renderNode(m,f,v,x,G,U)),S=y.position.x+this.options.nodeWidth}if(w.push(new G1({crossAxisAlignment:"start",children:_})),I>0){let y=J.filter((v)=>v.position.y===I-1),m=R,f=this.renderConnectors(y,m,Z,H,U,G);w.push(...f)}}let N=new u0({crossAxisAlignment:"start",children:w}),O=Math.round(Y.x),E=Math.round(Y.y*B),L=(q+1)*B,M=[new R0({width:H,height:L}),new k6({left:O,top:E,child:N})],A=Q?J.find((I)=>I.node.id===Q):void 0;if(A&&X){let I=X(A.node.data),R=q-A.position.y,_=O+A.position.x+this.options.nodeWidth+1,S=E+R*B+1,y=30;if(V?.maxTitleWidthPercent&&V.viewportWidth)y=Math.floor(V.viewportWidth*V.maxTitleWidthPercent/100);M.push(new k6({left:_,top:S,child:this.renderInfoBox(I,y,U,G)}))}return new c0({padding:C0.horizontal(2),child:new OH(new d6({fit:"expand",children:M}))})}renderNode(J,Z,Q,Y,X,V){let K="┌─┐",z="└─┘",D=J?X?.threadGraphNodeSelected??V?.primary??V?.foreground:X?.threadGraphNode??V?.primary??V?.foreground,U=!1;if(Y)D=X?.threadGraphNodeSelected??V?.primary??D,K="┏━┓",z="┗━┛",U=!0;else if(Z&&Q)D=X?.toolSuccess??V?.primary??D,K="┏━┓",z="┗━┛";return new u0({crossAxisAlignment:"start",children:[new $0({text:new C(K,new b({color:D,bold:U}))}),new $0({text:new C(z,new b({color:D,bold:U}))})]})}wrapText(J,Z){let Q=J.split(" "),Y=[],X="";for(let V of Q){if(V.length>Z)V=V.slice(0,Z-1)+"…";if(X.length===0)X=V;else if(X.length+1+V.length<=Z)X+=" "+V;else Y.push(X),X=V}if(X.length>0)Y.push(X);return Y}renderInfoBox(J,Z=30,Q,Y){let X=this.wrapText(J,Z),V=Math.min(Z,Math.max(1,...X.map((q)=>q.length))),K=V+2,z="┌"+"─".repeat(K)+"┐",D="└"+"─".repeat(K)+"┘",U=Q?.border??Y?.threadGraphConnector??Q?.foreground,G=Q?.foreground,F=[new $0({text:new C(z,new b({color:U}))})];for(let q of X){let W=" ".repeat(V-q.length);F.push(new $0({text:new C("│ ",new b({color:U}),[new C(q+W,new b({color:G??U})),new C(" │",new b({color:U}))])}))}return F.push(new $0({text:new C(D,new b({color:U}))})),new u0({crossAxisAlignment:"start",children:F})}renderConnectors(J,Z,Q,Y,X,V){let K=[],z=Math.floor(this.options.nodeWidth/2),D=V?.threadGraphConnector??X?.primary??X?.foreground,U=Array(Y).fill(" ");for(let q of Z){let W=q.position.x+z;if(W>=0&&W<Y)U[W]="▲"}K.push(new $0({text:new C(U.join(""),new b({color:D}))}));let G=Array(Y).fill(" ");for(let q of J){let W=Z.filter((O)=>O.node.parentID===q.node.id);if(W.length===0)continue;let H=q.position.x+z,B=W.map((O)=>O.position.x+z),w=Math.min(...B),N=Math.max(...B);for(let O=w;O<=N;O++)if(O>=0&&O<Y){if(O===H)if(W.length===1&&B[0]===H)G[O]="│";else if(O===w)G[O]="└";else if(O===N)G[O]="┘";else G[O]="┬";else if(B.includes(O))if(O===w)G[O]="└";else if(O===N)G[O]="┘";else G[O]="┴";else if(G[O]===" ")G[O]="─"}}K.push(new $0({text:new C(G.join(""),new b({color:D}))}));let F=Array(Y).fill(" ");for(let q of J){if(Z.filter((B)=>B.node.parentID===q.node.id).length===0)continue;let H=q.position.x+z;if(H>=0&&H<Y)F[H]="│"}return K.push(new $0({text:new C(F.join(""),new b({color:D}))})),K}}var Rc5={nodeWidth:1,nodeHeight:1,nodeIcon:"□",selectedIcon:"□"},Pc5={x:0,y:0};class Sg0{options;constructor(J={}){this.options={...Rc5,...J}}getNodeWidth(){return this.options.nodeWidth}render(J,Z,Q,Y=Pc5,X,V,K,z){let D=z?f0.of(z):null,U=D?.colors,G=D?.app,F=U?.mutedForeground??U?.foreground;if(J.length===0)return new $0({text:new C("No nodes",new b({color:F}))});let q=Math.max(...J.map((I)=>I.position.y)),H=Math.max(...J.map((I)=>I.position.x))+this.options.nodeWidth+3,B=this.options.nodeHeight+1,w=[];for(let I=q;I>=0;I--){let R=J.filter((y)=>y.position.y===I);R.sort((y,m)=>y.position.x-m.position.x);let _=[],S=0;for(let y of R){if(y.position.x>S)_.push(new R0({width:y.position.x-S}));let m=y.node.id===Q,f=K?.(y.node.data)??!1,v=V?.activeFlashOn??!1;_.push(this.renderNode(m,f,v,G,U)),S=y.position.x+this.options.nodeWidth}if(w.push(new G1({crossAxisAlignment:"start",children:_})),I>0){let y=J.filter((v)=>v.position.y===I-1),m=R,f=this.renderConnectors(y,m,Z,H,U,G);w.push(...f)}}let N=new u0({crossAxisAlignment:"start",children:w}),O=Math.round(Y.x),E=Math.round(Y.y*B),L=(q+1)*B,M=[new R0({width:H,height:L}),new k6({left:O,top:E,child:N})],A=Q?J.find((I)=>I.node.id===Q):void 0;if(A&&X){let I=X(A.node.data),R=q-A.position.y,_=O+A.position.x+this.options.nodeWidth+1,S=E+R*B,y=30;if(V?.maxTitleWidthPercent&&V.viewportWidth)y=Math.floor(V.viewportWidth*V.maxTitleWidthPercent/100);M.push(new k6({left:_,top:S,child:this.renderInfoBox(I,y,U)}))}return new c0({padding:C0.horizontal(2),child:new OH(new d6({fit:"expand",children:M}))})}renderNode(J,Z,Q,Y,X){let V=J?this.options.selectedIcon:this.options.nodeIcon,K=J?Y?.threadGraphNodeSelected??X?.primary??X?.foreground:Y?.threadGraphNode??X?.primary??X?.foreground;if(Z&&Q)K=Y?.toolSuccess??X?.primary??K,V="■";return new $0({text:new C(V,new b({color:K}))})}wrapText(J,Z){let Q=J.split(" "),Y=[],X="";for(let V of Q){if(V.length>Z)V=V.slice(0,Z-1)+"…";if(X.length===0)X=V;else if(X.length+1+V.length<=Z)X+=" "+V;else Y.push(X),X=V}if(X.length>0)Y.push(X);return Y}renderInfoBox(J,Z=30,Q){let Y=this.wrapText(J,Z),X=Q?.foreground,V=[];for(let K of Y)V.push(new $0({text:new C(K,new b({color:X??Q?.primary??Q?.foreground}))}));return new u0({crossAxisAlignment:"start",children:V})}renderConnectors(J,Z,Q,Y,X,V){let K=[],z=Math.floor(this.options.nodeWidth/2),D=V?.threadGraphConnector??X?.primary??X?.foreground,U=Array(Y).fill(" ");for(let G of J){let F=Z.filter((w)=>w.node.parentID===G.node.id);if(F.length===0)continue;let q=G.position.x+z,W=F.map((w)=>w.position.x+z),H=Math.min(...W),B=Math.max(...W);for(let w=H;w<=B;w++)if(w>=0&&w<Y){let N=w===q,O=W.includes(w);if(N&&O)if(F.length===1)U[w]="│";else if(w===H)U[w]="└";else if(w===B)U[w]="┘";else U[w]="┼";else if(N)if(w===H)U[w]="└";else if(w===B)U[w]="┘";else U[w]="┬";else if(O)if(w===H)U[w]="└";else if(w===B)U[w]="┘";else U[w]="┴";else if(U[w]===" ")U[w]="─"}}return K.push(new $0({text:new C(U.join(""),new b({color:D}))})),K}}class yp extends H3{onWidth;onHeight;constructor(J){super(J.child);this.onWidth=J.onWidth,this.onHeight=J.onHeight}createRenderObject(){return new lw4(this.onWidth,this.onHeight)}updateRenderObject(J){J.onWidth=this.onWidth,J.onHeight=this.onHeight}}class lw4 extends M4{onWidth;onHeight;constructor(J,Z){super();this.onWidth=J,this.onHeight=Z}performLayout(){let J=this._lastConstraints,Z=Number.isFinite(J.maxWidth)?J.maxWidth:80,Q=Number.isFinite(J.maxHeight)?J.maxHeight:24;this.onWidth(Z),this.onHeight?.(Q);let Y=this.children[0];if(Y)Y.layout(J),this.setSize(Y.size.width,Y.size.height);else this.setSize(J.minWidth,J.minHeight)}paint(J,Z,Q){for(let Y of this.children)Y.paint(J,Z,Q)}}class yL extends d0{props;constructor(J){super({key:J.key});this.props=J}createState(){return new aw4}}var iw4=400,nw4=300,Cc5=16;class aw4 extends g0{selectedNodeId=null;positionedNodes=[];dateComparator=(J,Z)=>{let Q=J.data.updatedAt??"",Y=Z.data.updatedAt??"";return Q.localeCompare(Y)};layoutEngine=new yT({nodeWidth:1,horizontalSpacing:1,comparator:this.dateComparator});lineCalculator=new uT;renderer=new Sg0;animation=null;currentOffset={x:0,y:0};animationTimer=null;viewportWidth=80;viewportHeight=24;activeFlashOn=!0;activeFlashTimer=null;initState(){let{initialSelectedThreadID:J}=this.widget.props;if(J){let Q=this.widget.props.threads.find((Y)=>Y.id===J);if(Q)this.selectedNodeId=Q.id}this.startActiveFlashTimer()}startActiveFlashTimer(){if(!this.widget.props.threads.some((Z)=>Z.isActive))return;this.activeFlashTimer=setInterval(()=>{this.activeFlashOn=!this.activeFlashOn,this.setState()},700)}stopActiveFlashTimer(){if(this.activeFlashTimer)clearInterval(this.activeFlashTimer),this.activeFlashTimer=null}didUpdateWidget(J){let Z=new Set(J.props.threads.map((D)=>D.id)),Q=new Set(this.widget.props.threads.map((D)=>D.id));if(Z.size!==Q.size||[...Z].some((D)=>!Q.has(D)))this.stopAnimation(),this.currentOffset={x:0,y:0};let X=J.props.initialSelectedThreadID,V=this.widget.props.initialSelectedThreadID;if(X!==V&&V){let U=this.widget.props.threads.find((G)=>G.id===V);if(U)this.selectedNodeId=U.id,this.stopAnimation(),this.currentOffset={x:0,y:0}}let K=J.props.threads.some((D)=>D.isActive),z=this.widget.props.threads.some((D)=>D.isActive);if(K!==z){if(this.stopActiveFlashTimer(),z)this.startActiveFlashTimer()}}dispose(){this.stopAnimation(),this.stopActiveFlashTimer()}startAnimation(J){this.stopAnimation(),this.animation={startOffset:{...this.currentOffset},targetOffset:J,startTime:Date.now(),durationX:iw4,durationY:nw4};let Z=Math.max(iw4,nw4);this.animationTimer=setInterval(()=>{let Q=Date.now();if(this.currentOffset=kp(this.animation,Q),this.animation&&Q-this.animation.startTime>=Z)this.currentOffset={...this.animation.targetOffset},this.stopAnimation();this.setState()},Cc5)}stopAnimation(){if(this.animationTimer)clearInterval(this.animationTimer),this.animationTimer=null;this.animation=null}calculateCenterOffset(J,Z,Q){let Y=Math.floor(this.renderer.getNodeWidth()/2),V=Math.floor(this.viewportWidth/2)-J-Y,K=Q-Z,z=2,D=Math.floor(this.viewportHeight/2),G=Math.floor(D/2)-K;return{x:V,y:G}}animateToNode(J){let Z=this.positionedNodes.find((Q)=>Q.node.id===J);if(Z){let Q=Math.max(...this.positionedNodes.map((X)=>X.position.y)),Y=this.calculateCenterOffset(Z.position.x,Z.position.y,Q);this.startAnimation(Y)}}toGraphNodes(){return this.widget.props.threads.map((J)=>({id:J.id,parentID:J.parentID,data:{title:J.title,updatedAt:J.updatedAt,isActive:J.isActive}}))}toThreadNode(J){return{id:J.node.id,parentID:J.node.parentID,title:J.node.data.title,updatedAt:J.node.data.updatedAt}}handleKeyEvent=(J)=>{if(!this.selectedNodeId)return"ignored";let Z=this.positionedNodes,Q=Z.find((X)=>X.node.id===this.selectedNodeId);if(!Q)return"ignored";let Y;switch(J.key){case"ArrowUp":{let X=Z.filter((V)=>V.node.parentID===Q.node.id);if(X.length>0){X.sort((K,z)=>K.position.x-z.position.x);let V=Math.floor(X.length/2);Y=X[V]}break}case"ArrowDown":{Y=Z.find((X)=>X.node.id===Q.node.parentID);break}case"ArrowLeft":{let X=Z.filter((V)=>V.position.y===Q.position.y&&V.position.x<Q.position.x);if(X.length>0)X.sort((V,K)=>K.position.x-V.position.x),Y=X[0];break}case"ArrowRight":{let X=Z.filter((V)=>V.position.y===Q.position.y&&V.position.x>Q.position.x);if(X.length>0)X.sort((V,K)=>V.position.x-K.position.x),Y=X[0];break}case"Enter":{if(this.widget.props.onSelect)this.widget.props.onSelect(this.toThreadNode(Q));return"handled"}default:{if(this.widget.props.onKey)return this.widget.props.onKey(J);return"ignored"}}if(Y)return this.selectedNodeId=Y.node.id,this.widget.props.onSelectionChange?.(this.toThreadNode(Y)),this.animateToNode(Y.node.id),"handled";if(this.widget.props.onKey)return this.widget.props.onKey(J);return"ignored"};build(J){let Z=this.toGraphNodes();this.positionedNodes=this.layoutEngine.layout(Z);let Q=this.lineCalculator.calculate(this.positionedNodes);if(!this.animation&&this.currentOffset.x===0&&this.currentOffset.y===0){let G=(this.selectedNodeId?this.positionedNodes.find((F)=>F.node.id===this.selectedNodeId):null)??this.positionedNodes.find((F)=>!F.node.parentID);if(G){let F=Math.max(...this.positionedNodes.map((q)=>q.position.y));this.currentOffset=this.calculateCenterOffset(G.position.x,G.position.y,F)}}let X=this.widget.props.showTitle??!0,V=this.widget.props.offsetY??0,K={x:this.currentOffset.x,y:this.currentOffset.y+V},z=this.renderer.render(this.positionedNodes,Q,this.selectedNodeId??void 0,K,X?(U)=>U.title:void 0,{maxTitleWidthPercent:this.widget.props.maxTitleWidthPercent,viewportWidth:this.viewportWidth,activeFlashOn:this.activeFlashOn},(U)=>U.isActive??!1,J),D=new yp({onWidth:(U)=>{if(this.viewportWidth!==U)this.viewportWidth=U,this.stopAnimation(),this.currentOffset={x:0,y:0},this.setState()},onHeight:(U)=>{if(this.viewportHeight!==U)this.viewportHeight=U,this.stopAnimation(),this.currentOffset={x:0,y:0},this.setState()},child:z});return new y4({autofocus:this.widget.props.autofocus??!0,onKey:this.handleKeyEvent,debugLabel:"MiniThreadGraph",child:D})}getSelectedNode(){let J=this.positionedNodes.find((Z)=>Z.node.id===this.selectedNodeId);return J?this.toThreadNode(J):null}}class rw4 extends d0{child;onContext;constructor(J,Z){super();this.child=J;this.onContext=Z}createState(){return new sw4}}class sw4 extends g0{build(J){return this.widget.onContext(J),this.widget.child}}var ow4=30,Tc5=30;class xT{}class fT{}class I$0{}class j$0{}class vg0 extends d0{props;constructor(J){super();this.props=J}createState(){return new tw4}}class tw4 extends g0{highlightedIndex=0;controller=new p7;focusNode;scrollController=new Q5;filteredClusters=[];itemContexts=[];initState(){this.focusNode=new s4({debugLabel:"ClusterPicker"}),this.scrollController.disableFollowMode(),this.recomputeFiltered(),this.controller.addListener(()=>{this.highlightedIndex=0,this.recomputeFiltered(),this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()})})}didUpdateWidget(J){if(J.props.clusters!==this.widget.props.clusters){if(this.recomputeFiltered(),this.highlightedIndex>=this.filteredClusters.length)this.highlightedIndex=Math.max(0,this.filteredClusters.length-1)}}ensureSelectedItemVisible(){let J=this.itemContexts[this.highlightedIndex];if(!J)return;let Z=J.findRenderObject();if(!Z)return;let Q=0,Y=Z.size.height;RT(J,{top:Q,bottom:Y},{padding:1})}dispose(){this.controller.dispose(),this.focusNode.dispose(),this.scrollController.dispose()}recomputeFiltered(){let J=this.controller.text.toLowerCase(),{clusters:Z}=this.widget.props;if(!J)this.filteredClusters=[...Z];else this.filteredClusters=Z.filter((Q)=>Q.label.toLowerCase().includes(J))}invoke=(J)=>{if(J instanceof xT){if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++,this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof fT){if(this.highlightedIndex>0)this.highlightedIndex--,this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()});return"handled"}if(J instanceof I$0){let Z=this.filteredClusters[this.highlightedIndex];if(Z)this.widget.props.onAccept(Z);return"handled"}if(J instanceof j$0)return this.widget.props.onDismiss(),"handled";return"ignored"};handleItemClick=(J,Z)=>{if(J>=0&&J<this.filteredClusters.length){if(Z===1)this.highlightedIndex=J,this.setState();else if(Z===2){let Q=this.filteredClusters[J];if(Q)this.widget.props.onAccept(Q)}}};handleScroll=(J)=>{if(this.filteredClusters.length===0)return!1;let Z=this.highlightedIndex;if(J.direction==="down")if(this.highlightedIndex<this.filteredClusters.length-1)this.highlightedIndex++;else return!1;else if(this.highlightedIndex>0)this.highlightedIndex--;else return!1;return this.setState(),W6.instance.addPostFrameCallback(()=>{this.ensureSelectedItemVisible()}),this.highlightedIndex!==Z};build(J){let{currentThreadID:Z}=this.widget.props,Q=f0.of(J),{colors:Y,app:X}=Q,z=a1.of(J).size.width>=Tc5+ow4,D=u1.all(new v1(Y.foreground,1,"solid")),U=this.filteredClusters[this.highlightedIndex]??null,G=new c0({padding:C0.symmetric(1,0),child:new $0({text:new C("Select a cluster",new b({color:X.command,bold:!0}))})}),F=new QJ({controller:this.controller,focusNode:this.focusNode,autofocus:!0,enabled:!0,style:{textColor:Y.foreground,border:null},maxLines:1}),q=new I2({shortcuts:new Map([[new $4("ArrowDown"),new xT],[new $4("ArrowUp"),new fT],[new $4("Tab"),new xT],[new $4("Tab",{shift:!0}),new fT],[new $4("n",{ctrl:!0}),new xT],[new $4("p",{ctrl:!0}),new fT],[new $4("Enter"),new I$0],[new $4("Escape"),new j$0]]),focusNode:this.focusNode,child:F}),W=new T9({actions:new Map([[xT,new t4(this.invoke)],[fT,new t4(this.invoke)],[I$0,new t4(this.invoke)],[j$0,new t4(this.invoke)]]),child:q}),H=new G1({children:[new c0({decoration:{color:Y.background},child:new $0({text:new C(">",new b({color:Y.foreground}))})}),new T1({child:W})]});this.itemContexts=[];let B=this.filteredClusters.map((M,A)=>{let I=A===this.highlightedIndex,R=Z?M.threads.some((m)=>m.id===Z):!1,_=I?X.selectionBackground:void 0,S=I?X.selectionForeground:Y.foreground,y=[new C(M.label,new b({color:S})),new C(` (${M.threads.length})`,new b({color:S,dim:!0}))];if(R)y.push(new C(" (current)",new b({color:I?X.selectionForeground:Y.success})));return new rw4(new i1({onClick:(m)=>this.handleItemClick(A,m.clickCount),child:new c0({decoration:_?{color:_}:void 0,padding:C0.symmetric(2,0),child:new $0({text:new C("",void 0,y)})})}),(m)=>{this.itemContexts[A]=m})}),w=new u0({children:B,crossAxisAlignment:"start"}),N=new T1({child:new i1({onScroll:this.handleScroll,child:new I6({controller:this.scrollController,autofocus:!1,child:w})})}),O=U?U.threads.map((M)=>({id:M.id,title:M.title,parentID:M.parentID,updatedAt:M.updatedAt})):[],E=U?new c0({padding:C0.all(1),child:new yL({threads:O,autofocus:!1,offsetY:2})}):null,L;if(z){let M=E?new T1({child:E}):new R0({width:ow4});L=new G1({crossAxisAlignment:"stretch",mainAxisAlignment:"start",children:[N,M]})}else{let M=[new T1({child:new i1({onScroll:this.handleScroll,child:new I6({controller:this.scrollController,autofocus:!1,child:w})})})];if(E)M.push(new T1({child:E}));L=new u0({crossAxisAlignment:"stretch",children:M})}return new c0({decoration:{border:D,color:Y.background},padding:C0.symmetric(1,0),child:new u0({children:[G,H,new R0({height:1}),new T1({child:L})]})})}}class YJ{static _instance=null;_allExpanded=!1;_listeners=new Set;static get instance(){if(!YJ._instance)YJ._instance=new YJ;return YJ._instance}get allExpanded(){return this._allExpanded}setAllExpanded(J){if(this._allExpanded===J)return;this._allExpanded=J,this._notifyListeners()}toggleAll(){this.setAllExpanded(!this._allExpanded)}addListener(J){return this._listeners.add(J),()=>this.removeListener(J)}removeListener(J){this._listeners.delete(J)}_notifyListeners(){for(let J of this._listeners)J()}}h0();class ew4 extends g0{labels=[];isLoading=!0;currentQuery="";initState(){this.loadLabels()}async loadLabels(){try{let J=await this.widget.props.internalAPIClient.getUserLabels({query:""},{config:this.widget.props.configService});if(!J.ok){j.error("Failed to load labels",J.error),this.isLoading=!1,this.labels=[],this.setState();return}this.labels=J.result,this.isLoading=!1,this.setState()}catch(J){j.error("Failed to load labels",J),this.isLoading=!1,this.labels=[],this.setState()}}getValidationError(J){let Z=J.trim().toLowerCase();if(Z.length===0)return null;if(Z.length>32)return"Label name cannot exceed 32 characters";if(!/^[a-z0-9][a-z0-9-]*$/.test(Z))return"Label must be alphanumeric with hyphens, starting with a letter or number";return null}isValidLabelName(J){return this.getValidationError(J)===null&&J.length>0}getAvailableLabels(){let J=this.widget.props.currentLabels||[];return this.labels.filter((Z)=>!J.includes(Z.name))}shouldShowCreateMarker(J){if(J.length===0||this.isLoading)return!1;let Z=J.trim().toLowerCase();if(!this.isValidLabelName(Z))return!1;let Q=this.widget.props.currentLabels||[],Y=this.labels.some((V)=>V.name===Z),X=Q.includes(Z);return!Y&&!X}build(J){let Z=f0.of(J),{app:Q,colors:Y}=Z,X=this.currentQuery.trim().toLowerCase(),V=X.length>0?this.getValidationError(X):null,K=this.getAvailableLabels(),D=[{id:"__create__",name:"__create_placeholder__",createdAt:"",__isCreateMarker:!0},...K];return new a9({title:"Add Label",items:D,getLabel:(U)=>{if("__isCreateMarker"in U)return this.currentQuery.trim().toLowerCase();return U.name},onAccept:(U)=>{if("__isCreateMarker"in U)this.widget.props.onSelect(this.currentQuery.trim().toLowerCase());else this.widget.props.onSelect(U.name)},onDismiss:this.widget.props.onDismiss,isLoading:this.isLoading,loadingText:"Loading labels...",emptyStateText:V||"Type to create a new label",renderItem:(U,G,F,q)=>{let W=G?Q.selectionBackground:void 0,H=G?Q.selectionForeground:Y.foreground;if("__isCreateMarker"in U&&U.__isCreateMarker){let w=this.currentQuery.trim().toLowerCase();return new c0({decoration:W?{color:W}:void 0,padding:C0.symmetric(2,0),child:new $0({text:new C("",void 0,[new C("Create new label: ",new b({color:H})),new C(w,new b({color:H,bold:!0}))])})})}return new c0({decoration:W?{color:W}:void 0,padding:C0.symmetric(2,0),child:new $0({text:new C(U.name,new b({color:H}))})})},filterItem:(U,G)=>{if(this.currentQuery!==G)this.currentQuery=G,setTimeout(()=>this.setState(),0);if("__isCreateMarker"in U&&U.__isCreateMarker)return this.shouldShowCreateMarker(G);let q=G.trim().toLowerCase();return q.length===0||U.name.includes(q)},sortItems:(U,G,F)=>{let q="__isCreateMarker"in U.item&&U.item.__isCreateMarker,W="__isCreateMarker"in G.item&&G.item.__isCreateMarker;if(q&&!W)return-1;if(!q&&W)return 1;return G.score-U.score}})}}class kg0 extends d0{props;constructor(J){super();this.props=J}createState(){return new ew4}}class FD extends d0{props;constructor(J){super();this.props=J}createState(){return new $N4}}class $N4 extends g0{_spinner=new R3;animationInterval=null;initState(){super.initState(),this.animationInterval=setInterval(()=>{this._spinner.step(),this.setState(()=>{})},100)}dispose(){if(this.animationInterval)clearInterval(this.animationInterval),this.animationInterval=null;super.dispose()}build(J){let Z=f0.of(J),{colors:Q,app:Y}=Z,X=u1.all(new v1(Q.foreground,1,"solid")),V=this._spinner.toBraille(),K=new $0({textAlign:"center",text:new C("",void 0,[new C(V,new b({color:Y.processing})),new C(" ",void 0),new C(this.widget.props.message,new b({color:Q.foreground}))])}),D=[new T1({child:new u0({mainAxisAlignment:"center",crossAxisAlignment:"center",children:[K]})})];if(this.widget.props.onAbort)D.push(new R0({height:2,child:new c0({padding:C0.symmetric(2,0),child:new $0({text:new C("",new b({dim:!0}),[new C("Press ",new b({color:Q.foreground})),new C("Esc",new b({color:Q.info})),new C(" to cancel",new b({color:Q.foreground}))])})})}));let U=new c0({decoration:new k4(Q.background,X),child:new R0({width:60,height:7,child:new u0({mainAxisAlignment:"start",children:D})})});if(this.widget.props.onAbort)return new y4({debugLabel:"LoadingDialog",autofocus:!0,onKey:(G)=>{if(G.key==="Escape")return this.widget.props.onAbort?.(),"handled";return"ignored"},child:U});return U}}class _8 extends d0{controller;getScrollInfo;thickness;trackChar;thumbChar;showTrack;thumbColor;trackColor;constructor({key:J,controller:Z,getScrollInfo:Q,thickness:Y=1,trackChar:X="█",thumbChar:V="█",showTrack:K=!0,thumbColor:z,trackColor:D}){super(J?{key:J}:{});this.controller=Z,this.getScrollInfo=Q,this.thickness=Y,this.trackChar=X,this.thumbChar=V,this.showTrack=K,this.thumbColor=z,this.trackColor=D}createState(){return new JN4}}class JN4 extends g0{_dragStartY=null;_dragStartOffset=null;_isOverThumb=!1;_isPositionOverThumb(J){let{totalContentHeight:Z,viewportHeight:Q}=this.widget.getScrollInfo(),X=this.context.findRenderObject()?.size.height??0;if(X===0||Z<=Q)return!1;let V=this.widget.getScrollInfo(),K=Math.min(1,Q/Z),z=Math.max(1,X*K),D=Math.max(0,Math.min(1,V.scrollOffset/(Z-Q))),U=X-z,G=Math.max(0,U*D),F=G+z;return J>=G&&J<=F}_handleHover=(J)=>{let Z=this._isOverThumb;if(this._isOverThumb=this._isPositionOverThumb(J.localPosition.y),Z!==this._isOverThumb)this.setState()};_handleDrag=(J)=>{let{totalContentHeight:Z,viewportHeight:Q,scrollOffset:Y}=this.widget.getScrollInfo(),V=this.context.findRenderObject()?.size.height??0;if(V===0||Z<=Q)return;if(this._dragStartY===null)this._dragStartY=J.localPosition.y,this._dragStartOffset=Y;let K=J.localPosition.y-this._dragStartY,z=Math.min(1,Q/Z),D=Math.max(1,V*z),U=V-D;if(U<=0)return;let G=Z-Q,F=U/G,q=K/F,W=Math.max(0,Math.min(G,this._dragStartOffset+q));this.widget.controller.jumpTo(W)};_handleRelease=()=>{this._dragStartY=null,this._dragStartOffset=null};_handleClick=(J)=>{if(J.button!=="left")return;let Z=J.localPosition.y,{totalContentHeight:Q,viewportHeight:Y,scrollOffset:X}=this.widget.getScrollInfo(),K=this.context.findRenderObject()?.size.height??0;if(K===0||Q<=Y)return;let z=Math.min(1,Y/Q),D=Math.max(1,K*z),U=Q-Y,G=K-D,F=Math.max(0,Math.min(1,X/(Q-Y))),q=Math.max(0,G*F),W=q+D;if(Z>=q&&Z<=W)return;if(Z<q)this.widget.controller.animateTo(Math.max(0,X-Y));else this.widget.controller.animateTo(Math.min(U,X+Y))};build(J){return new i1({onClick:this._handleClick,onHover:this._handleHover,onDrag:this._handleDrag,onRelease:this._handleRelease,cursor:this._isOverThumb?N5.POINTER:N5.DEFAULT,child:new ZN4({controller:this.widget.controller,getScrollInfo:this.widget.getScrollInfo,thickness:this.widget.thickness,trackChar:this.widget.trackChar,thumbChar:this.widget.thumbChar,showTrack:this.widget.showTrack,thumbColor:this.widget.thumbColor,trackColor:this.widget.trackColor})})}}class ZN4 extends uC{controller;getScrollInfo;thickness;trackChar;thumbChar;showTrack;thumbColor;trackColor;constructor({key:J,controller:Z,getScrollInfo:Q,thickness:Y=1,trackChar:X="█",thumbChar:V="█",showTrack:K=!0,thumbColor:z,trackColor:D}){super(J?{key:J}:{});this.controller=Z,this.getScrollInfo=Q,this.thickness=Y,this.trackChar=X,this.thumbChar=V,this.showTrack=K,this.thumbColor=z,this.trackColor=D}createRenderObject(){return new QN4(this)}updateRenderObject(J){J.updateWidget(this)}}class QN4 extends M4{_widget;constructor(J){super();this._widget=J}updateWidget(J){this._widget=J,this.markNeedsLayout()}performLayout(){let J=this._lastConstraints;f4(!!J,"performLayout called without constraints");let Z=Math.min(J.maxWidth,this._widget.thickness),Q=J.maxHeight;this.setSize(Z,Q),super.performLayout()}getMinIntrinsicWidth(J){return this._widget.thickness}getMaxIntrinsicWidth(J){return this._widget.thickness}getMinIntrinsicHeight(J){return 0}getMaxIntrinsicHeight(J){return 0}paint(J,Z,Q){let{thumbStartFloat:Y,thumbSizeFloat:X,showScrollbar:V}=this._calculateScrollbarMetrics();if(!V)return;let K=this._widget.trackColor,z=this._widget.thumbColor,D=["▁","▂","▃","▄","▅","▆","▇","█"],U=Y,G=Y+X;for(let F=0;F<this.size.height;F++){let q="█",W=!0;if(F===Math.floor(U)){let H=1-(U-F),B=Math.floor(H*8);q=D[B]||"█",W=!1}else if(F===Math.floor(G)){let H=1-(G-F),B=Math.floor(H*8);q=D[B]||"█"}else if(F>U&&F<G)W=!1;J.setChar(Z,Q+F,q,{fg:z,bg:K,reverse:W},1)}}_calculateScrollbarMetrics(){let{totalContentHeight:J,viewportHeight:Z,scrollOffset:Q}=this._widget.getScrollInfo(),Y=this.size.height;if(J<=Z||Y<=0)return{thumbStartFloat:0,thumbSizeFloat:0,showScrollbar:!1};let X=Math.max(0,Math.min(1,Q/(J-Z))),V=Math.min(1,Z/J),K=Math.max(1,Y*V),z=Y-K;return{thumbStartFloat:Math.max(0,z*X),thumbSizeFloat:K,showScrollbar:!0}}}class uL extends d0{props;constructor(J){super();this.props=J}createState(){return new YN4}}class YN4 extends g0{scrollController=new Q5;scrollAreaKey=new f7("message-dialog-scroll-area");viewportHeight=20;initState(){super.initState(),this.scrollController.followMode=!1,this.scrollController.addListener(()=>{this.setState()})}dispose(){this.scrollController.dispose(),super.dispose()}isWidgetMessage(J){return J instanceof P2}resolveFooterStyle(J){if(this.isWidgetMessage(J))return J.footerStyle;return"default"}getViewportHeight(){let Z=this.scrollAreaKey.currentElement?.renderObject;if(Z&&"size"in Z){let Q=Z.size;if(typeof Q.height==="number"&&Q.height>0)return this.viewportHeight=Q.height,Q.height}return this.viewportHeight}build(J){let Z=f0.of(J),Q=this.widget.props.message,Y=(()=>{if(this.isWidgetMessage(Q))return{title:Q.title,type:Q.type};if(Q instanceof Error&&Q.name==="CommandCancelledError")return{title:"Cancelled",type:"info",description:Q.message};if(Q instanceof Error&&Q.name==="CommandTimeoutError")return{title:"Timeout",type:"error",description:Q.message};let G=J$0(Q);return{title:G.title,type:G.type,description:G.description}})(),X=Y.type==="error"?Z.app.toolError:Z.app.command,V=u1.all(new v1(Z.colors.border,1,"solid")),K=new c0({padding:C0.symmetric(1,0),child:new $0({text:new C(Y.title,new b({color:X,bold:!0}))})}),z=this.isWidgetMessage(Q)?Q.widget:new $0({text:new C(Y.description,new b({color:Z.colors.foreground})),selectable:!0}),D=new T1({child:new j2({child:new c0({padding:C0.symmetric(1,0),child:new G1({key:this.scrollAreaKey,crossAxisAlignment:"stretch",children:[new T1({child:new I6({controller:this.scrollController,autofocus:!0,child:z})}),new _8({controller:this.scrollController,thumbColor:Z.app.scrollbarThumb,trackColor:Z.app.scrollbarTrack,getScrollInfo:()=>{let G=this.scrollController.maxScrollExtent,F=this.scrollController.offset,q=this.getViewportHeight(),W=G+q;return{totalContentHeight:Math.max(W,0),viewportHeight:Math.max(q,1),scrollOffset:Math.max(F,0)}}})]})})})}),U=new c0({padding:C0.symmetric(1,0),child:new $0({text:(()=>{if(this.widget.props.onRetry)return new C("",void 0,[new C("Press ",new b({color:Z.colors.foreground,dim:!0})),new C("R",new b({color:Z.app.keybind})),new C(" to retry, ",new b({color:Z.colors.foreground,dim:!0})),new C("Esc",new b({color:Z.app.keybind})),new C(" to cancel",new b({color:Z.colors.foreground,dim:!0}))]);let G=this.resolveFooterStyle(this.widget.props.message);if(G==="none")return new C("",new b({color:Z.colors.foreground,dim:!0}));if(G==="help"){let F=new b({color:Z.app.keybind}),q=new b({color:Z.colors.foreground,dim:!0});return new C("",q,[new C("Press ",q),new C("Escape",F),new C(" to close • Use ",q),new C("↑↓",F),new C(" or ",q),new C("j/k",F),new C(" to scroll",q)])}return new C("Press any key to close",new b({color:Z.colors.foreground,dim:!0,italic:!0}))})()})});return new y4({onKey:(G)=>{if(this.widget.props.onRetry&&G.key==="r")return this.widget.props.onRetry(),"handled";if(G.key==="Escape")return this.widget.props.onDismiss(),"handled";if(!this.widget.props.onRetry)return this.widget.props.onDismiss(),"handled";return"ignored"},autofocus:!1,child:new c0({decoration:{border:V,color:Z.colors.background},padding:C0.all(1),child:new u0({mainAxisAlignment:"center",children:[K,new R0({height:1}),D,U]})})})}}t9();class XN4 extends d0{props;constructor(J){super();this.props=J}createState(){return new VN4}}class VN4 extends g0{plugins=[];subscription=null;initState(){this.subscription=this.widget.props.pluginService.plugins.subscribe((J)=>{this.plugins=J,this.setState(()=>{})})}dispose(){this.subscription?.unsubscribe(),super.dispose()}getRelativePath(J){let Z=J.startsWith("file://")?J.slice(7):J,Q=this.widget.props.cwd;if(Z.startsWith(Q))return Z.slice(Q.length+1);return Z}statusIcon(J){let Z=m8.default(),{colors:Q,app:Y}=Z;switch(J){case"loading":return{icon:"◌",color:Q.warning};case"active":return{icon:"✓",color:Y.toolSuccess};case"error":return{icon:"✗",color:Y.toolError}}}build(J){let Z=f0.of(J),{app:Q}=Z;if(this.plugins.length===0)return new $0({text:new C("No plugins found.",new b({dim:!0}))});let Y=[],X=this.plugins.length,V=this.plugins.filter((D)=>D.status==="active").length,K=this.plugins.reduce((D,U)=>D+U.registeredCommands.length,0),z=this.plugins.reduce((D,U)=>D+U.registeredTools.length,0);if(Y.push(new C(`${V}/${X} ${p4(X,"plugin")} active`,new b({bold:!0}))),K>0||z>0)Y.push(new C(` (${K} ${p4(K,"command")}, ${z} ${p4(z,"tool")})`,new b({dim:!0})));Y.push(new C(`
7166
7166
 
7167
7167
  `));for(let D of this.plugins){let{icon:U,color:G}=this.statusIcon(D.status),F=this.getRelativePath(D.uri.toString());if(Y.push(new C(`${U} `,new b({color:G}))),Y.push(new C(F,new b({bold:!0}))),Y.push(new C(` ${D.status}`,new b({dim:!0}))),Y.push(new C(`
7168
7168
  `)),D.status==="active"&&D.registeredEvents.length>0)Y.push(new C(" Events: ",new b({dim:!0}))),Y.push(new C(D.registeredEvents.join(", "),new b({color:Q.link}))),Y.push(new C(`
@@ -7379,7 +7379,7 @@ ${X0.content||""}`:X0.content||"",a0=[],U1=X0.baseDir.startsWith("file://")?zJ0(
7379
7379
  `)}function mL4(J,Z){J.command("usage").description("Show your current Amp usage and credit balance").action(async(Q,Y)=>{let X=Y.optsWithGlobals(),V=await Z(X),K=await V.settings.get("proxy"),z=pI1({settings:{url:V.ampURL,proxy:K},secrets:{getToken:(U,G)=>V.secrets.get(U,G)}}),D=await M6.userDisplayBalanceInfo({},{config:z});if(!D.ok){if(D.error.code==="auth-required")process.stderr.write(Q1.red("Error: ")+"You must be logged in to view usage. Run `amp login` first.\n"),process.exit(1);process.stderr.write(Q1.red("Error: ")+D.error.message+`
7380
7380
  `),process.exit(1)}process.stdout.write(await Xo5(D.result.displayText)+`
7381
7381
  `),process.exit(0)})}var je5=HB.join(m2,"logs","headless.log"),Zl0=HB.join(IC,"device-id.json");async function Re5(){for(let J of KN)try{if((await J.listConfigs()).length>0)return J}catch(Z){j.debug("Failed to detect query-based IDE integration",{ideName:J.ideName,error:Z})}return}try{if(process.platform==="win32")await Promise.resolve().then(() => H4(U_(),1))}catch{}if(process.env.AMP_PWD)try{process.chdir(process.env.AMP_PWD),delete process.env.AMP_PWD}catch(J){N7.write(`Failed to change directory to ${process.env.AMP_PWD}: ${J}
7382
- `)}function Pe5(J){process.emitWarning=(Z,Q,Y,X)=>{let V=typeof Z==="string"?Z:Z.message||String(Z),K=Q||"Warning",z=!1;J.warn(V,{name:K,code:Y})}}function w7(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")P$("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")P$("experimental.agentMode",Z.mode)}function Bj4(J,Z){if(J.getOptionValueSourceWithGlobals("sp")==="cli"&&Z.sp)return Z.sp;if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Z.systemPrompt)return Z.systemPrompt;return}async function Ce5(J){try{return await Wj4(J,"utf-8")}catch{return J}}async function Ql0(J,Z,Q){let Y=Bj4(J,Z);if(!Y)return;let X=J5(Q)?Q.features:[],V=J5(Q)?Q.user.email:void 0;if(!X.some((z)=>z.name===$Y.HARNESS_SYSTEM_PROMPT&&z.enabled)&&!wj4(V))throw new z4("You are not allowed to do this.",1);P$("systemPrompt",await Ce5(Y))}function wj4(J){return!!(J&&Go(J))}function Yl0(J,Z){if(typeof J==="boolean")return J;if(!J5(Z))return!1;return IJ(Z.user.email)}function Xl0(J){if(!J5(J))return null;return{...J.user,features:J.features??[],team:J.workspace??void 0}}function Te5(J){try{let Z=new URL(J);return Z.hostname==="localhost"||Z.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function Vl0(J){let Y=Te5(J)?"Run `pnpm dev` to start the local server, then try again.":"Check your network connection or the server URL and try again.";return new z4(`Couldn't connect to the Amp server at ${J}.`,1,Y)}var zj4=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??pY,description:`Custom settings file path (overrides the default location ${pY})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(j).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${uE})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:n9(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration"},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection"},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"mode",long:"mode",short:"m",type:"option",default:uK.SMART.key,description:`Set the agent mode (${TX().map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:TX().map((J)=>J.mode).concat("large","deep","internal")},{name:"dtw",long:"dtw",type:"flag",description:"Use the DTW-backed thread provider in the TUI (experimental)",hidden:!0,aliases:["deliver-me-to-agg"]},{name:"headless",long:"headless",type:"optional-option",description:"Run headless DTW harness (no TUI). Optionally provide a thread ID to connect as executor.",hidden:!0},{name:"apiKey",long:"api-key",type:"option",description:"API key for internal DTW commands (overrides AMP_API_KEY)",hidden:!0},{name:"sp",long:"sp",type:"option",description:"Custom system prompt text or file path",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text",hidden:!0}],Dj4=(J)=>("deprecated"in J)&&J.deprecated===!0,_e5=(J)=>("hidden"in J)&&J.hidden===!0,Se5=(J)=>("default"in J),ve5=(J)=>("default"in J)?J.default:void 0,Nj4=[{name:"toggle-skills-count",entryPoint:Ax0}];function ke5(J,Z){let Q=Z.args[0],Y=Z.commands.map((V)=>V.name());if(Q&&!Q.includes(" ")&&Q.length<30&&!/[./\\]/.test(Q)){let V=Y.filter((z)=>Q.includes(z)||z.includes(Q)),K="Run amp --help for a list of available commands.";if(V.length>0)K=`Did you mean: ${V.join(", ")}? Or run amp --help for all commands.`;throw new z4(U8.unknownCommand(Q),1,K)}}async function zl0(J){return{...J,getThreadEnvironment:n$,threadSyncService:J.threadSyncService,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new $V(J.fileSystem),generateThreadTitle:h00,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>pJ(J.configService),pluginService:J.pluginService}}function Oj4(J){return{toolService:J.toolService,configService:J.configService,skillService:J.skillService,getThreadEnvironment:n$,filesystem:J.fileSystem,threadService:J.threadService}}var tJ0=z1.file(Hj4.homedir()),Kl0=process.env.XDG_CONFIG_HOME?z1.file(process.env.XDG_CONFIG_HOME):V1.joinPath(tJ0,".config");function ye5(J){return g74({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){m74(Z);let Q=D90(),Y=lx0();if((!Q||Y||BK4())&&J.config.settings["notifications.system.enabled"]!==!1){if(Z==="idle")process.stdout.write(IG("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Z==="requires-user-input")process.stdout.write(IG("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(D90()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}function ue5(){return{sync:async()=>{},uploadThread:async()=>{},discoverThreads:async()=>[],initialSyncComplete:Promise.resolve(),updateThreadMeta:async()=>{},threadSyncInfo:()=>v0.of({}),flushPendingSyncs:async()=>{},dispose:()=>{}}}async function S9(J,Z,Q){let Y=Q?.deferAuth??!1;uI1("0.0.1773173082-gfe7cc2");let X=Jr({storage:J.settings,secretStorage:J.secrets,workspaceRoots:v0.of([z1.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:tJ0,userConfigDir:Kl0});GK4(X);let V=await X.getLatest();j.debug("Global configuration initialized",{settingsKeys:Object.keys(V.settings)});let{toolService:K,dispose:z}=u74({configService:X}),D=new Map,U=()=>D.clear(),G=new xL0(X,J.settings.getWorkspaceRootPath()),F=Lh1({configService:X,filesystem:n6}),q=Eu1({configService:X,trustStore:G,skillMCPServers:F.skillMCPServers,createOAuthProvider:async(s,B0,l)=>{let K0=`${s}:${B0}`,D0=D.get(K0);if(D0)return j.debug("Reusing existing OAuth provider for server",{serverName:s,serverUrl:B0}),D0;j.debug("Creating OAuth provider for server",{serverName:s,serverUrl:B0});let E0=(async()=>{let z0=new CN(J.secrets),w0=await z0.getClientInfo(s,B0),n=l?.scopes??w0?.scopes,o=qX4();j.info("OAuth headless mode check",{useHeadless:o,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:e6.isTTY});let e;if(o)e=J.executeMode?FX4():GX4(s);let J0=new JL0({storage:z0,serverName:s,serverUrl:B0,clientId:l?.clientId??w0?.clientId,clientSecret:l?.clientSecret??w0?.clientSecret,authUrl:l?.authUrl??w0?.authUrl,tokenUrl:l?.tokenUrl??w0?.tokenUrl,scopes:n,headlessAuthHandler:e});return j.debug("OAuth provider created",{serverName:s,serverUrl:B0,hasManualClientId:!!(l?.clientId??w0?.clientId),willUseDCR:!(l?.clientId??w0?.clientId),scopes:n,headlessMode:o,executeMode:J.executeMode}),J0})();return D.set(K0,E0),E0}}),W=fv0({configService:X,filesystem:n6,spawn:p50}),H;if(J.executeMode){let s=await s34({toolService:K,providers:[q,W],initialTimeout:15000});H=s.registrations;for(let[B0,l]of s.initErrors)j.warn(`${B0} provider initialization slow or failed:`,l)}else H=bv0({toolService:K,providers:[q,W]});if(Z.jetbrains)QN("JetBrains");else if(Z.ide&&oX4())QN("VS Code");else if(Z.ide&&rX4())QN("Neovim");else if(Z.ide){let s=await Re5();if(s){let B0=Ur(s.ideName);if(B0)QN(B0)}}if(J.executeMode)xI1(!0);let B,w=x8.status.pipe(W1((s)=>Boolean(s.connected&&s.authenticated&&s.ideName&&Wj1(s.ideName))),I4()).subscribe((s)=>{if(s){if(!B)B=K.registerTool(r34)}else B?.dispose(),B=void 0}),N;if(!J.executeMode){let s=await J.settings.get("fuzzy.alwaysIncludePaths")??[];N=new E80(process.cwd(),{alwaysIncludePaths:s},!0)}else N=new class extends E80{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};let O=!1;{let s=await J.secrets.get("apiKey",J.ampURL);if(O=Boolean(s),j.info("API key lookup before login",{found:Boolean(s),ampURL:J.ampURL,deferAuth:Y}),!s)if(Y)j.info("No API key found, continuing startup with deferred auth");else{e6.write(`No API key found. Starting login flow...
7382
+ `)}function Pe5(J){process.emitWarning=(Z,Q,Y,X)=>{let V=typeof Z==="string"?Z:Z.message||String(Z),K=Q||"Warning",z=!1;J.warn(V,{name:K,code:Y})}}function w7(J,Z){if(J.getOptionValueSourceWithGlobals("dangerouslyAllowAll")==="cli")P$("dangerouslyAllowAll",Z.dangerouslyAllowAll);if(J.getOptionValueSourceWithGlobals("mode")==="cli")P$("experimental.agentMode",Z.mode)}function Bj4(J,Z){if(J.getOptionValueSourceWithGlobals("sp")==="cli"&&Z.sp)return Z.sp;if(J.getOptionValueSourceWithGlobals("systemPrompt")==="cli"&&Z.systemPrompt)return Z.systemPrompt;return}async function Ce5(J){try{return await Wj4(J,"utf-8")}catch{return J}}async function Ql0(J,Z,Q){let Y=Bj4(J,Z);if(!Y)return;let X=J5(Q)?Q.features:[],V=J5(Q)?Q.user.email:void 0;if(!X.some((z)=>z.name===$Y.HARNESS_SYSTEM_PROMPT&&z.enabled)&&!wj4(V))throw new z4("You are not allowed to do this.",1);P$("systemPrompt",await Ce5(Y))}function wj4(J){return!!(J&&Go(J))}function Yl0(J,Z){if(typeof J==="boolean")return J;if(!J5(Z))return!1;return IJ(Z.user.email)}function Xl0(J){if(!J5(J))return null;return{...J.user,features:J.features??[],team:J.workspace??void 0}}function Te5(J){try{let Z=new URL(J);return Z.hostname==="localhost"||Z.hostname==="127.0.0.1"}catch{return J.includes("localhost")||J.includes("127.0.0.1")}}function Vl0(J){let Y=Te5(J)?"Run `pnpm dev` to start the local server, then try again.":"Check your network connection or the server URL and try again.";return new z4(`Couldn't connect to the Amp server at ${J}.`,1,Y)}var zj4=[{name:"notifications",long:"notifications",type:"flag",description:(J)=>`${J?"Enable":"Disable"} sound notifications (enabled by default when not in execute mode)`},{name:"color",long:"color",type:"flag",description:(J)=>`${J?"Enable":"Disable"} color output (enabled by default if stdout and stderr are sent to a TTY)`},{name:"settingsFile",long:"settings-file",type:"option",default:process.env.AMP_SETTINGS_FILE??pY,description:`Custom settings file path (overrides the default location ${pY})`},{name:"logLevel",long:"log-level",type:"option",description:`Set log level (${Object.keys(j).join(", ")})`},{name:"logFile",long:"log-file",type:"option",description:`Set log file location (overrides the default location ${uE})`},{name:"format",long:"format",type:"option",description:"output using the standard or new-ui. Options: `ui`, `new-ui`",choices:["ui","jsonl","new-ui"],hidden:!0,deprecated:!0},{name:"dangerouslyAllowAll",long:"dangerously-allow-all",type:"switch",default:!1,description:"Disable all command confirmation prompts (agent will execute all commands without asking)"},{name:"jetbrains",long:"jetbrains",type:"flag",default:n9(),description:(J)=>J?"Enable JetBrains integration. When enabled, Amp automatically includes your open JetBrains file and text selection with every message.":"Disable JetBrains integration"},{name:"ide",long:"ide",type:"flag",default:!0,description:(J)=>J?"Enable IDE connection (default). When enabled, Amp automatically includes your open IDE's file and text selection with every message.":"Disable IDE connection"},{name:"interactive",long:"interactive",type:"flag",description:(J)=>J?"Enable interactive mode. This will enable the interactive UI.":"Disable interactive mode. This will disable the interactive UI.",hidden:!0,deprecated:!0},{name:"mcpConfig",long:"mcp-config",type:"option",description:"JSON configuration or file path for MCP servers to merge with existing settings"},{name:"mode",long:"mode",short:"m",type:"option",default:uK.SMART.key,description:`Set the agent mode (${TX().map((J)=>J.mode).join(", ")}) — controls the model, system prompt, and tool selection`,choices:TX().map((J)=>J.mode).concat("large","deep","internal")},{name:"dtw",long:"dtw",type:"flag",description:"Use the DTW-backed thread provider in the TUI (experimental)",hidden:!0,aliases:["deliver-me-to-agg"]},{name:"headless",long:"headless",type:"optional-option",description:"Run headless DTW harness (no TUI). Optionally provide a thread ID to connect as executor.",hidden:!0},{name:"apiKey",long:"api-key",type:"option",description:"API key for internal DTW commands (overrides AMP_API_KEY)",hidden:!0},{name:"sp",long:"sp",type:"option",description:"Custom system prompt text or file path",hidden:!0},{name:"systemPrompt",long:"system-prompt",type:"option",description:"Custom system prompt text",hidden:!0}],Dj4=(J)=>("deprecated"in J)&&J.deprecated===!0,_e5=(J)=>("hidden"in J)&&J.hidden===!0,Se5=(J)=>("default"in J),ve5=(J)=>("default"in J)?J.default:void 0,Nj4=[{name:"toggle-skills-count",entryPoint:Ax0}];function ke5(J,Z){let Q=Z.args[0],Y=Z.commands.map((V)=>V.name());if(Q&&!Q.includes(" ")&&Q.length<30&&!/[./\\]/.test(Q)){let V=Y.filter((z)=>Q.includes(z)||z.includes(Q)),K="Run amp --help for a list of available commands.";if(V.length>0)K=`Did you mean: ${V.join(", ")}? Or run amp --help for all commands.`;throw new z4(U8.unknownCommand(Q),1,K)}}async function zl0(J){return{...J,getThreadEnvironment:n$,threadSyncService:J.threadSyncService,osFileSystem:J.fileSystem,skillService:J.skillService,fileChangeTrackerStorage:new $V(J.fileSystem),generateThreadTitle:h00,deleteThread:(Z)=>J.threadService.delete(Z),getServerStatus:()=>pJ(J.configService),pluginService:J.pluginService}}function Oj4(J){return{toolService:J.toolService,configService:J.configService,skillService:J.skillService,getThreadEnvironment:n$,filesystem:J.fileSystem,threadService:J.threadService}}var tJ0=z1.file(Hj4.homedir()),Kl0=process.env.XDG_CONFIG_HOME?z1.file(process.env.XDG_CONFIG_HOME):V1.joinPath(tJ0,".config");function ye5(J){return g74({playNotificationSound:async(Z)=>{if(J.useNotificationsForService){m74(Z);let Q=D90(),Y=lx0();if((!Q||Y||BK4())&&J.config.settings["notifications.system.enabled"]!==!1){if(Z==="idle")process.stdout.write(IG("\x1B]777;notify;Amp;Agent is ready\x1B\\"));else if(Z==="requires-user-input")process.stdout.write(IG("\x1B]777;notify;Amp;Waiting for approval\x1B\\"))}}},windowFocused:()=>Promise.resolve(D90()),threadService:J.threadService,configService:J.configService,threadViewStates$:J.threadViewStates$})}function ue5(){return{sync:async()=>{},uploadThread:async()=>{},discoverThreads:async()=>[],initialSyncComplete:Promise.resolve(),updateThreadMeta:async()=>{},threadSyncInfo:()=>v0.of({}),flushPendingSyncs:async()=>{},dispose:()=>{}}}async function S9(J,Z,Q){let Y=Q?.deferAuth??!1;uI1("0.0.1773203397-g13b2f7");let X=Jr({storage:J.settings,secretStorage:J.secrets,workspaceRoots:v0.of([z1.file(process.cwd())]),defaultAmpURL:J.ampURL,homeDir:tJ0,userConfigDir:Kl0});GK4(X);let V=await X.getLatest();j.debug("Global configuration initialized",{settingsKeys:Object.keys(V.settings)});let{toolService:K,dispose:z}=u74({configService:X}),D=new Map,U=()=>D.clear(),G=new xL0(X,J.settings.getWorkspaceRootPath()),F=Lh1({configService:X,filesystem:n6}),q=Eu1({configService:X,trustStore:G,skillMCPServers:F.skillMCPServers,createOAuthProvider:async(s,B0,l)=>{let K0=`${s}:${B0}`,D0=D.get(K0);if(D0)return j.debug("Reusing existing OAuth provider for server",{serverName:s,serverUrl:B0}),D0;j.debug("Creating OAuth provider for server",{serverName:s,serverUrl:B0});let E0=(async()=>{let z0=new CN(J.secrets),w0=await z0.getClientInfo(s,B0),n=l?.scopes??w0?.scopes,o=qX4();j.info("OAuth headless mode check",{useHeadless:o,executeMode:J.executeMode,envVar:process.env.AMP_HEADLESS_OAUTH,isTTY:e6.isTTY});let e;if(o)e=J.executeMode?FX4():GX4(s);let J0=new JL0({storage:z0,serverName:s,serverUrl:B0,clientId:l?.clientId??w0?.clientId,clientSecret:l?.clientSecret??w0?.clientSecret,authUrl:l?.authUrl??w0?.authUrl,tokenUrl:l?.tokenUrl??w0?.tokenUrl,scopes:n,headlessAuthHandler:e});return j.debug("OAuth provider created",{serverName:s,serverUrl:B0,hasManualClientId:!!(l?.clientId??w0?.clientId),willUseDCR:!(l?.clientId??w0?.clientId),scopes:n,headlessMode:o,executeMode:J.executeMode}),J0})();return D.set(K0,E0),E0}}),W=fv0({configService:X,filesystem:n6,spawn:p50}),H;if(J.executeMode){let s=await s34({toolService:K,providers:[q,W],initialTimeout:15000});H=s.registrations;for(let[B0,l]of s.initErrors)j.warn(`${B0} provider initialization slow or failed:`,l)}else H=bv0({toolService:K,providers:[q,W]});if(Z.jetbrains)QN("JetBrains");else if(Z.ide&&oX4())QN("VS Code");else if(Z.ide&&rX4())QN("Neovim");else if(Z.ide){let s=await Re5();if(s){let B0=Ur(s.ideName);if(B0)QN(B0)}}if(J.executeMode)xI1(!0);let B,w=x8.status.pipe(W1((s)=>Boolean(s.connected&&s.authenticated&&s.ideName&&Wj1(s.ideName))),I4()).subscribe((s)=>{if(s){if(!B)B=K.registerTool(r34)}else B?.dispose(),B=void 0}),N;if(!J.executeMode){let s=await J.settings.get("fuzzy.alwaysIncludePaths")??[];N=new E80(process.cwd(),{alwaysIncludePaths:s},!0)}else N=new class extends E80{async start(){}async query(){return[]}getStats(){return{state:"unstarted",stats:[]}}dispose(){}};let O=!1;{let s=await J.secrets.get("apiKey",J.ampURL);if(O=Boolean(s),j.info("API key lookup before login",{found:Boolean(s),ampURL:J.ampURL,deferAuth:Y}),!s)if(Y)j.info("No API key found, continuing startup with deferred auth");else{e6.write(`No API key found. Starting login flow...
7383
7383
  `);let B0=await xe5(J),l=await J.secrets.get("apiKey",J.ampURL);if(j.info("Login flow completed",{success:B0,storedKeyPresent:Boolean(l),ampURL:J.ampURL}),!B0)await OG(),process.exit(1);O=!0}}{let s=await X.getLatest(),B0=s.settings.url,l=s.secrets.isSet?.[B0];j.info("Config secrets state after login",{configURL:B0,apiKeySet:l?.apiKey??!1})}let E=E1(pJ(X).pipe(x5((s)=>s!=="pending"))),L=await Ph1({isDevelopment:!1}),M=Y?"pending":await E;if(!Y)j.info("Server status resolved",{status:"ready",isAuthenticated:J5(M),isError:jq(M),errorMessage:jq(M)?M.error.message:void 0});let A=new xI0(L,X),I=new TA0(L,{lazy:!0,maxThreads:200});j.info("Starting Amp background services");let R=Yl0(Z.dtw,M),_=Boolean(R||Z.headless);if(_)j.info("DTW mode enabled: thread sync service disabled");let S=_?ue5():sm1({threadService:A,threadHistoryService:I,configService:X,isExtensionDevelopment:!1}),y;x8.status.subscribe((s)=>{y=s});let m=new tB0({workspaceRoots:[z1.file(process.cwd())],fileSystem:Z.jetbrains||Z.ide?It:n6,getCurrentFile:()=>{if(!y?.openFile)return;try{return z1.parse(y.openFile)}catch(s){j.warn("Failed to parse current file URI",{uri:y.openFile,error:s});return}},getOpenFiles:()=>{if(!y?.visibleFiles?.length)return[];let s=y.openFile;return y.visibleFiles.filter((B0)=>B0!==s).map((B0)=>{try{return z1.parse(B0)}catch(l){return j.warn("Failed to parse visible file URI",{uri:B0,error:l}),null}}).filter((B0)=>B0!==null)}}),f=new ax0,v=process.env.PLUGINS??"off",x=Z.headless?sV4():void 0,c=x??new l80({configService:X}),i=c instanceof l80?c:void 0;if(i)i.pluginExecutorKind=R?"local":"unknown";let h=JM0({configService:X,fileSystem:Z.jetbrains||Z.ide?It:n6,platform:c,internalPlugins:Nj4,pluginFilter:v}),a=Mx1({pluginService:h,toolService:K}),p={codebaseContextService:m,configService:X,toolService:K,mcpService:q,skillService:F,toolboxService:W,trustStore:G,threadService:A,threadHistoryService:I,threadSyncService:S,threadStorage:L,secretStorage:J.secrets,settingsStorage:J.settings,fuzzyServer:N,fileSystem:Z.jetbrains||Z.ide?It:n6,terminal:f,pluginService:h,pluginPlatform:i,headlessPluginPlatform:x,serverStatus:M,serverStatusPromise:E,hasAPIKeyAtStartup:O};return{...p,async asyncDispose(){if(p.mcpService.hasAuthenticatingClients())j.info("Waiting for OAuth authentication to complete before exit..."),await p.mcpService.waitForAuthentication();for(let s of H.values())s.dispose();await p.mcpService.dispose(),U(),await p.threadService.asyncDispose(),p.configService.unsubscribe(),z(),p.fuzzyServer.dispose(),p.threadSyncService.dispose(),p.settingsStorage[Symbol.dispose](),w.unsubscribe(),B?.dispose(),a.dispose(),await p.pluginService.dispose()}}}async function xe5(J){if(!J.executeMode){if(!await Lx0("Would you like to log in to Amp? [(y)es, (n)o]: "))return e6.write(`Login cancelled. Run the command again to retry.
7384
7384
  `),!1}return await Ej4(J)}async function Ej4(J){let Z=Le5(32).toString("hex"),Q=await PC(J.ampURL,Z),Y=new AbortController;try{await uX(Q,Y.signal)}catch(V){j.error("Error opening browser",{error:V})}let X=await PC(J.ampURL,Z,!1);e6.write(`If your browser does not open automatically, visit:
7385
7385
 
@@ -7387,7 +7387,7 @@ ${Q1.blue.bold(X)}
7387
7387
 
7388
7388
  `);try{return await _V4(J.ampURL,Z,J.secrets,Y),e6.write("\nLogin successful! Run `amp` to get started.\n"),!0}catch(V){return j.error("Login failed",{error:V}),N7.write(`
7389
7389
  Login failed: ${V instanceof Error?V.message:String(V)}
7390
- `),!1}}function fe5(){let J=new rW().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((H)=>{if(H.code==="commander.help"||H.code==="commander.version"||H.exitCode===0)fE(),process.exit(0);let B=H.originalError??H;jY4(B)}),J.option("-V, --version","Print the version number and exit",()=>{let B;try{B=`, ${Rq(new Date("2026-03-10T20:10:20.465Z"))} ago`}catch{}e6.write(`0.0.1773173082-gfe7cc2 (released 2026-03-10T20:10:20.465Z${B??""})
7390
+ `),!1}}function fe5(){let J=new rW().name("amp").description("AI-powered coding assistant").option("--visibility <visibility>","Set thread visibility (private, public, workspace, group)").configureOutput({writeErr:()=>{}});J.exitOverride((H)=>{if(H.code==="commander.help"||H.code==="commander.version"||H.exitCode===0)fE(),process.exit(0);let B=H.originalError??H;jY4(B)}),J.option("-V, --version","Print the version number and exit",()=>{let B;try{B=`, ${Rq(new Date("2026-03-11T04:35:24.440Z"))} ago`}catch{}e6.write(`0.0.1773203397-g13b2f7 (released 2026-03-11T04:35:24.440Z${B??""})
7391
7391
  `),process.exit(0)}),J.addHelpText("after",iX4()),J.configureHelp({formatHelp:nX4}),J.command("logout").description("Log out by removing stored API key").action(async(H,B)=>{let w=B.optsWithGlobals(),N=await w3(w);await ce5(N)}),J.command("login").description("Log in to Amp").addHelpText("after","If AMP_URL is set during login, it will be persisted to global settings for future CLI invocations, though AMP_URL will continue to take precedence.").action(async(H,B)=>{let w=B.optsWithGlobals(),N=await w3(w);await de5(N,await $x0(w,N.settings))}),J.command("git-credential-helper [action]",{hidden:!0}).summary("Git credential helper for GitHub").description("Internal: implements the git credential helper protocol. Used inside sandboxes to authenticate git operations with GitHub.").action(async(H,B,w)=>{let N=w.optsWithGlobals(),O=await w3(N);await oY4(H??"get",O.ampURL,O.secrets),process.exit(process.exitCode??0)}),J.command("sign-commit",{hidden:!0}).summary("Git commit signing helper").description("Internal: implements the gpg signing interface for git commit signing. Used inside sandboxes as gpg.program.").allowUnknownOption().action(async(H,B)=>{let w=B.optsWithGlobals(),N=await w3(w);await rY4(N.ampURL,N.secrets),process.exit(process.exitCode??0)}),J.command("dtw-curl [threadId] [action] [message...]",{hidden:!0}).summary("DTW helper").description("Internal: helper for DTW one-shot commands.").addHelpText("after",`
7392
7392
  Actions:
7393
7393
  add-message <message> Send a user message and wait for message_added
@@ -7443,8 +7443,8 @@ ${L}
7443
7443
 
7444
7444
  This thread belongs to a different user and cannot be continued for security reasons. Set AMP_RESUME_OTHER_USER_THREADS_INSECURE=1 to bypass this check.`)}}async function be5(J){if(!J.userEmail||!IJ(J.userEmail))throw new z4("DTW TUI mode is only available for Amp employees",1);j.info("[createDTWThreadPool] Creating DTW thread pool",{threadId:J.threadId,ampURL:J.ampURL,workerUrl:process.env.AMP_WORKER_URL});try{let Z=new Ug({threadService:J.threadService,configService:J.configService,mcpService:J.mcpService,toolService:J.toolService,skillService:J.skillService,getThreadEnvironment:n$,osFileSystem:J.fileSystem,fileChangeTrackerStorage:new $V(J.fileSystem),ampURL:J.ampURL});if(J.threadId)await Z.switchThread(J.threadId);else await Z.createThread();return Z}catch(Z){throw j.error("[createDTWThreadPool] Failed to create DTW thread pool",{threadId:J.threadId,error:Z}),Z}}async function he5(J){if(J.streamJsonInput)return{userInput:"",stdinInput:null};if(typeof J.execute==="string"){let Z=(await am()).trimEnd();return{userInput:J.execute,stdinInput:Z||null}}return{userInput:(await am()).trimEnd(),stdinInput:null}}function me5(J,Z,Q){if(J.remote&&!Z)throw new z4("The -r/--remote flag requires --execute mode",1,'Use: amp --remote --execute "your message"');if(J.streamJson&&!Z)throw new z4("The --stream-json flag requires --execute mode",1,'Use: amp --execute "your message" --stream-json');if(J.streamJsonInput&&!Z)throw new z4("The --stream-json-input flag requires --execute mode",1,"Use: amp --execute --stream-json --stream-json-input");if(J.streamJsonInput&&!J.streamJson)throw new z4("The --stream-json-input flag requires --stream-json",1,"Use: amp --execute --stream-json --stream-json-input");if(J.stats&&!Z)throw new z4("The --stats flag requires --execute mode",1,'Use: amp --execute "your message" --stats');if(J.archive&&!Z)throw new z4("The --archive flag requires --execute mode",1,'Use: amp --execute "your message" --archive');if(J.streamJsonInput&&typeof J.execute==="string"&&J.execute.trim()!=="")throw new z4("Do not provide a message argument when using --stream-json-input",1,`Supply messages via stdin JSONL instead: echo '{"type":"user","message":{"role":"user","content":[{"type":"text","text":"your message"}]}}' | amp --execute --stream-json --stream-json-input`);if(Z&&Q===""&&!J.streamJsonInput&&!J.headless)throw new z4("User message must be provided through stdin or as argument when using execute mode",1,`Either pass a message as an argument: amp --execute "your message"
7445
7445
  Or pipe via stdin: echo "your message" | amp --execute`)}async function eJ0(J,Z,Q){let Y=process.hrtime.bigint(),X=(l,K0)=>{let D0=Number(process.hrtime.bigint()-K0)/1e6,E0=_24();j.info("Startup phase",{phase:l,phaseMs:Math.round(D0),sinceMainMs:E0===null?void 0:Math.round(E0)})},{userInput:V,stdinInput:K}=await he5(Z),z=!!Z.streamJson||!!Z.streamJsonThinking;me5({...Z,streamJson:z},J.executeMode,V),w7(Q,Z);let D=process.hrtime.bigint(),U=Boolean(await J.secrets.get("apiKey",J.ampURL)),G=!J.executeMode&&!Z.headless&&U;j.info("Interactive auth startup mode",{deferInteractiveAuth:G,hasAPIKeyAtStartup:U,executeMode:J.executeMode,headless:Boolean(Z.headless)});let F=await S9(J,Z,{deferAuth:G});X("runMainThread:createThreadDependencies",D),D=process.hrtime.bigint();let q=await zl0(F);X("runMainThread:createWorkerDeps",D);let{serverStatus:W}=F;if(!G&&jq(W)){let l=Im(Error(W.error.message));if(l.message===U8.networkOffline||l.message===U8.networkTimeout)throw Vl0(J.ampURL);throw new z4(U8.invalidAPIKey,1)}let H=J5(W)?W:null,B=H?.user.email,w=wj4(B),N=!J.executeMode&&H!==null&&Yl0(Z.dtw,H);if(!G)await Ql0(Q,Z,W);let O=Xl0(W),E=O?.features??[],L=O?.team??null,M=d80(Z,O);if(M instanceof Error)z3(M.message);if((J.executeMode||z)&&k8(Z.mode)&&!w)throw new z4(`Execute mode is not permitted with --mode '${Z.mode}'`,1);if(H&&!lF(Z.mode,B))throw new z4(`Agent mode '${Z.mode}' is only available for Amp employees`,1);if(J.executeMode&&Z.remote)await $K4(V,K,F.configService),await F.asyncDispose(),process.exit(0);if(Z.headless){if(!B||!IJ(B))throw new z4("Headless DTW mode is only available for Amp employees",1);let l=await F.secretStorage.get("apiKey",J.ampURL);if(!l)throw new z4("API key required for headless mode. Please run `amp login` first.",1);let K0=typeof Z.headless==="string"&&Z.headless!=="true"?Z.headless:void 0;if(K0&&!B8(K0))throw new z4(`Invalid thread ID: ${K0}`,1);let D0=K0??await te5({dependencies:F,visibility:M??void 0}),E0=await wX4(D0);if(E0.status==="already-running")await F.asyncDispose(),await OG(),process.exit(0);try{await UX4({ampURL:J.ampURL,apiKey:l,workerUrl:process.env.AMP_WORKER_URL,workspaceRoot:process.cwd(),threadId:D0,configService:F.configService,mcpService:F.mcpService,toolService:F.toolService,skillService:F.skillService,fileSystem:F.fileSystem,pluginService:F.pluginService,pluginPlatform:F.headlessPluginPlatform})}finally{await E0.release(),await F.asyncDispose()}await OG(),process.exit(0)}let A={threadService:F.threadService,workerDeps:q,createThread:async()=>{let l=G?await F.serverStatusPromise:W,K0=await X80(J.settings,process.cwd(),Xl0(l),M);if(K0 instanceof Error)z3(K0.message);return Km0(q,{threadMeta:K0?kV(K0):void 0,agentMode:Z.mode,onFirstAssistantMessage:Uj4})},validateThreadOwnership:async(l,K0)=>{if(K0?.nonBlockingOwnershipCheck){Gj4(l,F.configService).catch((D0)=>{if(D0 instanceof z4){if(K0.onOwnershipError){K0.onOwnershipError(D0,l);return}LC(D0,l);return}j.warn("Failed to validate thread ownership in CLI, allowing to open",{error:D0})});return}try{await Gj4(l,F.configService)}catch(D0){if(D0 instanceof z4)throw D0;j.warn("Failed to validate thread ownership in CLI, allowing to open",{error:D0})}},switchThreadVisibility:M,switchThreadAgentMode:Z.mode,onFirstAssistantMessage:Uj4},I=async(l,K0)=>{try{if(l==="dtw")return be5({userEmail:K0?.dtwUserEmail??B,ampURL:J.ampURL,configService:F.configService,threadService:F.threadService,mcpService:F.mcpService,toolService:F.toolService,skillService:F.skillService,fileSystem:F.fileSystem,threadId:Z.threadId});return NW4(A,Z.threadId,{nonBlockingOwnershipCheck:Z.nonBlockingThreadOwnershipCheck})}catch(D0){if(D0 instanceof z4)throw D0;throw await LC(D0,Z.threadId),Error("handleError should have called process.exit()")}};if(Z.format==="jsonl")N7.write(`jsonl format is deprecated. Version "0.0.1752148945-gd8844f" or earlier is required to use jsonl format.
7446
- `),await OG(),process.exit(1);let R=(async()=>{if(G){j.info("Skipping initial free tier status fetch until auth is complete");return}try{let l=await F.configService.getLatest(),K0=Mk(l),D0=await M6.getUserFreeTierStatus({},{config:F.configService,signal:AbortSignal.timeout(K0)});if(D0.ok)return j.info("User free tier status:",D0),D0.result;return}catch(l){j.error("Failed to fetch free tier status:",l);return}})(),S=!J.executeMode?new Yf0:null,y,m=null;if(S)y=S,m=(async()=>{let l=G?await F.serverStatusPromise:F.serverStatus;await Ql0(Q,Z,l);let K0=process.hrtime.bigint(),D0=Yl0(Z.dtw,l),E0=J5(l)?l.user.email:void 0,z0=await I(D0?"dtw":"worker",{dtwUserEmail:E0});if(X("runMainThread:createThreadPool",K0),S.attach(z0),V){let w0=await E1(z0.threadHandles$);if(!w0)throw new z4("No active thread is available yet.",1);await w0.sendMessage({content:[{type:"text",text:V}]})}})(),m.catch(async(l)=>{let K0=l instanceof Error?l:Error(String(l));S.setInitError(K0),await LC(l,Z.threadId)});else D=process.hrtime.bigint(),y=await I(N?"dtw":"worker"),X("runMainThread:createThreadPool",D);let f=Z.notifications!==void 0?Z.notifications:!J.executeMode;D=process.hrtime.bigint();let v=await F.configService.getLatest();if(X("runMainThread:configService.getLatest",D),D=process.hrtime.bigint(),ye5({configService:F.configService,threadService:F.threadService,config:v,useNotificationsForService:f,threadViewStates$:()=>y.threadHandles$.pipe(e1((l)=>{if(!l)return v0.of({});return Y5(l.thread$,l.threadViewState$).pipe(W1(([K0,D0])=>({[K0.id]:D0})))}))}),X("runMainThread:createCliNotificationService",D),J.executeMode){if(pV4(F.mcpService,J.settings),!(y instanceof KT))throw new z4("Execute mode is not supported with the DTW thread pool",1);let l=y.getWorkerForExecuteMode();if(await yY4({worker:l,threadID:l.threadID,userInput:V,stdinInput:K,dependencies:F,streamJson:z,streamJsonInput:!!Z.streamJsonInput,streamJsonThinking:!!Z.streamJsonThinking,stats:!!Z.stats,ampURL:J.ampURL,isDogfooding:w,agentMode:Z.mode,labels:Z.label}),Z.archive)await M6.archiveThread({thread:l.threadID,archived:!0},{config:F.configService});await F.asyncDispose(),process.exit(0)}let x=!1,c=!1;if(Z.jetbrains||Z.ide){await Ej1();let l=await DN({jetbrainsOnly:Z.jetbrains});if(l.length===0){if(Z.jetbrains)x=!await F.configService.get("jetbrains.skipInstall")}else if(l.length===1){let K0=l[0];if(K0)x8.selectConfig(K0)}else c=!0}D=process.hrtime.bigint();let i=Ox0("0.0.1773173082-gfe7cc2",F.settingsStorage,{startDelayMs:3000});X("runMainThread:createUpdateService",D),D=process.hrtime.bigint();let h=new CA0(F.threadStorage);X("runMainThread:createThreadFuzzyIndexer",D),D=process.hrtime.bigint();let a=new Mx0(F.mcpService,J.settings.getWorkspaceRootPath());if(X("runMainThread:createMcpTrustHandler",D),V&&J.executeMode){let l=await E1(y.threadHandles$);if(!l)throw new z4("No active thread is available yet.",1);await l.sendMessage({content:[{type:"text",text:V}]})}D=process.hrtime.bigint();let p=await nz();X("runMainThread:loadSessionState",D),j.info("Loaded session state:",p);let s={...p,launchCount:p.launchCount+1};az(s);let B0=Z.threadId&&B8(Z.threadId)?Z.threadId:void 0;try{if(D=process.hrtime.bigint(),await RH4({codebaseContextService:F.codebaseContextService,history:new bu0,fuzzyServer:F.fuzzyServer,settingsStorage:F.settingsStorage,threadService:F.threadService,threadHistoryService:F.threadHistoryService,threadFuzzyIndexer:h,skillService:F.skillService,configService:F.configService,secretStorage:F.secretStorage,internalAPIClient:M6,threadPool:y,createSystemPromptDeps:async()=>Oj4(F),ideClient:x8,mcpService:F.mcpService,toolboxService:F.toolboxService,mcpTrustHandler:a,updateService:i,pluginPlatform:F.pluginPlatform,pluginService:F.pluginService},{initialServerStatus:F.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:F.hasAPIKeyAtStartup,ampURL:J.ampURL,startupThreadID:B0,showJetBrainsInstaller:x,showIdePickerHint:c,openThreadSwitcher:Z.openThreadSwitcher,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:Z.clientId,sessionState:s,freeTierStatusPromise:R,workspace:L??null,features:E,isDogfooding:w,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-03-10T20:10:20.465Z"},(l)=>new km0({...l,threadPool:l.threadPool},(K0)=>new Cd0({...K0,threadState:K0.threadState}))),X("runMainThread:mountApp-returned",D),m)await m}finally{}await F.asyncDispose(),X("runMainThread:dependencies.asyncDispose",Y),process.exit(0)}async function w3(J){if(j.info("Initializing CLI context",{argv:process.argv,nodeEnv:"production",hasAmpURL:Boolean(process.env.AMP_URL),hasAmpAPIKey:Boolean(process.env.AMP_API_KEY),hasSettingsFile:Boolean(process.env.AMP_SETTINGS_FILE)}),J.interactive)N7.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
7447
- `);let Z=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Q=process.stdout.isTTY&&process.stderr.isTTY;j.info("Execution mode resolved",{executeMode:Z,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let Y=await Ru1({get:async(z)=>{if(z!==Hu)return;try{let D=await Wj4(Zl0,"utf-8");return JSON.parse(D).installationID}catch{return}},set:async(z,D)=>{if(z!==Hu)return;await qj4(HB.dirname(Zl0),{recursive:!0}),await Me5(Zl0,JSON.stringify({installationID:D},null,2),{mode:384})}},{clientType:"cli",platform:eQ()});fI1(Y);let X=await _X4({...J,workspaceTrust:{current:!0,changes:Vk},getHook:process.env.AMP_URL?(z,D)=>{if(z==="url")return Promise.resolve(process.env.AMP_URL);return D()}:void 0});if(J.mcpConfig){let z=await mV4(J.mcpConfig);X=gV4(X,z)}let V=HB.dirname(X.getSettingsFilePath());h74(IC,V);let K=await X.get("url","global");if(!K)K=$7;if(j.info("Resolved Amp URL",{ampURL:K,settingsFile:X.getSettingsFilePath(),workspaceRoot:X.getWorkspaceRootPath()}),!Zq(K))j.info("Targeting custom Amp server",{ampURL:K});return X=PI1(X),{executeMode:Z,isTTY:Q,ampURL:K,settings:X,secrets:XK4(await $x0(J,X))}}function ge5(J){let Z={};for(let Q=0;Q<J.length;Q++){let Y=J[Q];if(Y?.startsWith("--")){let V=Y.slice(2).replace(/-([a-z])/g,(z,D)=>D.toUpperCase()),K=J[Q+1];if(K&&!K.startsWith("--"))Z[V]=K,Q++}}return Z}async function pe5(){T24();let J=ge5(process.argv),Z=process.argv.includes("--headless")||process.argv.some((V)=>V.startsWith("--headless="));pQ4({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE||(Z?je5:void 0)});let Q=process.argv.includes("--no-color"),Y=process.argv.includes("--color"),X=process.stdout.isTTY&&process.stderr.isTTY;if(Q||!Y&&!X)Q1.level=0;if(Pe5(j),j.info("Starting Amp CLI.",{version:"0.0.1773173082-gfe7cc2",buildTimestamp:"2026-03-10T20:10:20.465Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new z4(U8.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await fe5().parseAsync(process.argv)}f74().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await pe5().catch(LC)});async function de5(J,Z){let Q=J.ampURL.includes("localhost")||J.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!Q)await J.settings.set("url",process.env.AMP_URL,"global"),e6.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
7446
+ `),await OG(),process.exit(1);let R=(async()=>{if(G){j.info("Skipping initial free tier status fetch until auth is complete");return}try{let l=await F.configService.getLatest(),K0=Mk(l),D0=await M6.getUserFreeTierStatus({},{config:F.configService,signal:AbortSignal.timeout(K0)});if(D0.ok)return j.info("User free tier status:",D0),D0.result;return}catch(l){j.error("Failed to fetch free tier status:",l);return}})(),S=!J.executeMode?new Yf0:null,y,m=null;if(S)y=S,m=(async()=>{let l=G?await F.serverStatusPromise:F.serverStatus;await Ql0(Q,Z,l);let K0=process.hrtime.bigint(),D0=Yl0(Z.dtw,l),E0=J5(l)?l.user.email:void 0,z0=await I(D0?"dtw":"worker",{dtwUserEmail:E0});if(X("runMainThread:createThreadPool",K0),S.attach(z0),V){let w0=await E1(z0.threadHandles$);if(!w0)throw new z4("No active thread is available yet.",1);await w0.sendMessage({content:[{type:"text",text:V}]})}})(),m.catch(async(l)=>{let K0=l instanceof Error?l:Error(String(l));S.setInitError(K0),await LC(l,Z.threadId)});else D=process.hrtime.bigint(),y=await I(N?"dtw":"worker"),X("runMainThread:createThreadPool",D);let f=Z.notifications!==void 0?Z.notifications:!J.executeMode;D=process.hrtime.bigint();let v=await F.configService.getLatest();if(X("runMainThread:configService.getLatest",D),D=process.hrtime.bigint(),ye5({configService:F.configService,threadService:F.threadService,config:v,useNotificationsForService:f,threadViewStates$:()=>y.threadHandles$.pipe(e1((l)=>{if(!l)return v0.of({});return Y5(l.thread$,l.threadViewState$).pipe(W1(([K0,D0])=>({[K0.id]:D0})))}))}),X("runMainThread:createCliNotificationService",D),J.executeMode){if(pV4(F.mcpService,J.settings),!(y instanceof KT))throw new z4("Execute mode is not supported with the DTW thread pool",1);let l=y.getWorkerForExecuteMode();if(await yY4({worker:l,threadID:l.threadID,userInput:V,stdinInput:K,dependencies:F,streamJson:z,streamJsonInput:!!Z.streamJsonInput,streamJsonThinking:!!Z.streamJsonThinking,stats:!!Z.stats,ampURL:J.ampURL,isDogfooding:w,agentMode:Z.mode,labels:Z.label}),Z.archive)await M6.archiveThread({thread:l.threadID,archived:!0},{config:F.configService});await F.asyncDispose(),process.exit(0)}let x=!1,c=!1;if(Z.jetbrains||Z.ide){await Ej1();let l=await DN({jetbrainsOnly:Z.jetbrains});if(l.length===0){if(Z.jetbrains)x=!await F.configService.get("jetbrains.skipInstall")}else if(l.length===1){let K0=l[0];if(K0)x8.selectConfig(K0)}else c=!0}D=process.hrtime.bigint();let i=Ox0("0.0.1773203397-g13b2f7",F.settingsStorage,{startDelayMs:3000});X("runMainThread:createUpdateService",D),D=process.hrtime.bigint();let h=new CA0(F.threadStorage);X("runMainThread:createThreadFuzzyIndexer",D),D=process.hrtime.bigint();let a=new Mx0(F.mcpService,J.settings.getWorkspaceRootPath());if(X("runMainThread:createMcpTrustHandler",D),V&&J.executeMode){let l=await E1(y.threadHandles$);if(!l)throw new z4("No active thread is available yet.",1);await l.sendMessage({content:[{type:"text",text:V}]})}D=process.hrtime.bigint();let p=await nz();X("runMainThread:loadSessionState",D),j.info("Loaded session state:",p);let s={...p,launchCount:p.launchCount+1};az(s);let B0=Z.threadId&&B8(Z.threadId)?Z.threadId:void 0;try{if(D=process.hrtime.bigint(),await RH4({codebaseContextService:F.codebaseContextService,history:new bu0,fuzzyServer:F.fuzzyServer,settingsStorage:F.settingsStorage,threadService:F.threadService,threadHistoryService:F.threadHistoryService,threadFuzzyIndexer:h,skillService:F.skillService,configService:F.configService,secretStorage:F.secretStorage,internalAPIClient:M6,threadPool:y,createSystemPromptDeps:async()=>Oj4(F),ideClient:x8,mcpService:F.mcpService,toolboxService:F.toolboxService,mcpTrustHandler:a,updateService:i,pluginPlatform:F.pluginPlatform,pluginService:F.pluginService},{initialServerStatus:F.serverStatus,stdout:process.stdout,hasAPIKeyAtStartup:F.hasAPIKeyAtStartup,ampURL:J.ampURL,startupThreadID:B0,showJetBrainsInstaller:x,showIdePickerHint:c,openThreadSwitcher:Z.openThreadSwitcher,inspector:Z.inspector,inspectorPort:Z.inspectorPort,jetbrainsMode:Z.jetbrains,clientId:Z.clientId,sessionState:s,freeTierStatusPromise:R,workspace:L??null,features:E,isDogfooding:w,initialAgentMode:Q.getOptionValueSourceWithGlobals("mode")==="cli"?Z.mode:void 0,buildTimestamp:"2026-03-11T04:35:24.440Z"},(l)=>new km0({...l,threadPool:l.threadPool},(K0)=>new Cd0({...K0,threadState:K0.threadState}))),X("runMainThread:mountApp-returned",D),m)await m}finally{}await F.asyncDispose(),X("runMainThread:dependencies.asyncDispose",Y),process.exit(0)}async function w3(J){if(j.info("Initializing CLI context",{argv:process.argv,nodeEnv:"production",hasAmpURL:Boolean(process.env.AMP_URL),hasAmpAPIKey:Boolean(process.env.AMP_API_KEY),hasSettingsFile:Boolean(process.env.AMP_SETTINGS_FILE)}),J.interactive)N7.write(`Warning: --interactive flag is deprecated. Interactive mode is now the default unless --execute is used or output is redirected.
7447
+ `);let Z=!!J.execute||!process.stdout.isTTY&&!J.streamJson,Q=process.stdout.isTTY&&process.stderr.isTTY;j.info("Execution mode resolved",{executeMode:Z,stdoutTTY:process.stdout.isTTY,stderrTTY:process.stderr.isTTY,streamJson:J.streamJson,executeFlag:J.execute});let Y=await Ru1({get:async(z)=>{if(z!==Hu)return;try{let D=await Wj4(Zl0,"utf-8");return JSON.parse(D).installationID}catch{return}},set:async(z,D)=>{if(z!==Hu)return;await qj4(HB.dirname(Zl0),{recursive:!0}),await Me5(Zl0,JSON.stringify({installationID:D},null,2),{mode:384})}},{clientType:"cli",platform:eQ()});fI1(Y);let X=await _X4({...J,workspaceTrust:{current:!0,changes:Vk},getHook:process.env.AMP_URL?(z,D)=>{if(z==="url")return Promise.resolve(process.env.AMP_URL);return D()}:void 0});if(J.mcpConfig){let z=await mV4(J.mcpConfig);X=gV4(X,z)}let V=HB.dirname(X.getSettingsFilePath());h74(IC,V);let K=await X.get("url","global");if(!K)K=$7;if(j.info("Resolved Amp URL",{ampURL:K,settingsFile:X.getSettingsFilePath(),workspaceRoot:X.getWorkspaceRootPath()}),!Zq(K))j.info("Targeting custom Amp server",{ampURL:K});return X=PI1(X),{executeMode:Z,isTTY:Q,ampURL:K,settings:X,secrets:XK4(await $x0(J,X))}}function ge5(J){let Z={};for(let Q=0;Q<J.length;Q++){let Y=J[Q];if(Y?.startsWith("--")){let V=Y.slice(2).replace(/-([a-z])/g,(z,D)=>D.toUpperCase()),K=J[Q+1];if(K&&!K.startsWith("--"))Z[V]=K,Q++}}return Z}async function pe5(){T24();let J=ge5(process.argv),Z=process.argv.includes("--headless")||process.argv.some((V)=>V.startsWith("--headless="));pQ4({logLevel:J.logLevel||process.env.AMP_LOG_LEVEL,logFile:J.logFile||process.env.AMP_LOG_FILE||(Z?je5:void 0)});let Q=process.argv.includes("--no-color"),Y=process.argv.includes("--color"),X=process.stdout.isTTY&&process.stderr.isTTY;if(Q||!Y&&!X)Q1.level=0;if(Pe5(j),j.info("Starting Amp CLI.",{version:"0.0.1773203397-g13b2f7",buildTimestamp:"2026-03-11T04:35:24.440Z"}),parseInt(process.version.slice(1).split(".")[0]??"")<20)throw new z4(U8.nodeVersion(process.version),1,"Please upgrade your Node.js installation from https://nodejs.org");await fe5().parseAsync(process.argv)}f74().startActiveSpan("main",async(J)=>{process.on("exit",()=>J.end()),await pe5().catch(LC)});async function de5(J,Z){let Q=J.ampURL.includes("localhost")||J.ampURL.includes("127.0.0.1");if(process.env.AMP_URL&&!Q)await J.settings.set("url",process.env.AMP_URL,"global"),e6.write(`Saving custom server URL to settings: ${process.env.AMP_URL}
7448
7448
  `);else if(!Zq(J.ampURL))e6.write(`Logging in to ${new URL(J.ampURL).hostname}
7449
7449
  `);let Y=process.env.AMP_API_KEY;if(Y)e6.write(`API key found in environment variable, storing...
7450
7450
  `),await Z.set("apiKey",Y,J.ampURL),e6.write(`API key successfully stored.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcegraph/amp",
3
- "version": "0.0.1773173082-gfe7cc2",
3
+ "version": "0.0.1773203397-g13b2f7",
4
4
  "description": "CLI for Amp, the frontier coding agent.",
5
5
  "homepage": "https://ampcode.com/",
6
6
  "author": {