ax 0.2.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +32 -0
- package/LICENSE +21 -0
- package/README.md +403 -0
- package/dist/api/audit.d.ts +47 -0
- package/dist/api/deep-journey.d.ts +90 -0
- package/dist/api/platform.d.ts +139 -0
- package/dist/api/shared.d.ts +14 -0
- package/dist/api/skills.d.ts +25 -0
- package/dist/contract/index.d.ts +22 -0
- package/dist/contract/types.gen.d.ts +3270 -0
- package/dist/contract/version.d.ts +2 -0
- package/dist/index.cjs +600 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +563 -0
- package/dist/main.cjs +597 -0
- package/package.json +70 -23
- package/ReadMe.md +0 -15
- package/ax.coffee +0 -38
- package/ax.js +0 -65
package/dist/main.cjs
ADDED
|
@@ -0,0 +1,597 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";var Mn=Object.create;var tt=Object.defineProperty;var Nn=Object.getOwnPropertyDescriptor;var Ln=Object.getOwnPropertyNames;var jn=Object.getPrototypeOf,Wn=Object.prototype.hasOwnProperty;var Dn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Bn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ln(t))!Wn.call(e,o)&&o!==n&&tt(e,o,{get:()=>t[o],enumerable:!(r=Nn(t,o))||r.enumerable});return e};var B=(e,t,n)=>(n=e!=null?Mn(jn(e)):{},Bn(t||!e||!e.__esModule?tt(n,"default",{value:e,enumerable:!0}):n,e));var W=Dn((Zi,$e)=>{"use strict";var le=process||{},ut=le.argv||[],ce=le.env||{},nr=!(ce.NO_COLOR||ut.includes("--no-color"))&&(!!ce.FORCE_COLOR||ut.includes("--color")||le.platform==="win32"||(le.stdout||{}).isTTY&&ce.TERM!=="dumb"||!!ce.CI),rr=(e,t,n=e)=>r=>{let o=""+r,i=o.indexOf(t,e.length);return~i?e+or(o,t,n,i)+t:e+o+t},or=(e,t,n,r)=>{let o="",i=0;do o+=e.substring(i,r)+n,i=r+t.length,r=e.indexOf(t,i);while(~r);return o+e.substring(i)},dt=(e=nr)=>{let t=e?rr:()=>String;return{isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};$e.exports=dt();$e.exports.createColors=dt});var Un=/\d/,Jn=["-","_","/","."];function Fn(e=""){if(!Un.test(e))return e!==e.toLowerCase()}function nt(e,t){let n=t??Jn,r=[];if(!e||typeof e!="string")return r;let o="",i,a;for(let s of e){let c=n.includes(s);if(c===!0){r.push(o),o="",i=void 0;continue}let l=Fn(s);if(a===!1){if(i===!1&&l===!0){r.push(o),o=s,i=l;continue}if(i===!0&&l===!1&&o.length>1){let u=o.at(-1);r.push(o.slice(0,Math.max(0,o.length-1))),o=u+s,i=l;continue}}o+=s,i=l,a=c}return r.push(o),r}function Hn(e){return e?e[0].toUpperCase()+e.slice(1):""}function Gn(e){return e?e[0].toLowerCase()+e.slice(1):""}function qn(e,t){return e?(Array.isArray(e)?e:nt(e)).map(n=>Hn(t?.normalize?n.toLowerCase():n)).join(""):""}function Z(e,t){return Gn(qn(e||"",t))}function re(e,t){return e?(Array.isArray(e)?e:nt(e)).map(n=>n.toLowerCase()).join(t??"-"):""}function rt(e){return re(e||"","_")}var st=require("util");function ee(e){return Array.isArray(e)?e:e===void 0?[]:[e]}function ve(e,t=""){let n=[];for(let r of e)for(let[o,i]of r.entries())n[o]=Math.max(n[o]||0,i.length);return e.map(r=>r.map((o,i)=>t+o[i===0?"padStart":"padEnd"](n[i])).join(" ")).join(`
|
|
3
|
+
`)}function R(e){return typeof e=="function"?e():e}var U=class extends Error{code;constructor(e,t){super(e),this.name="CLIError",this.code=t}};function Kn(e=[],t={}){let n=new Set(t.boolean||[]),r=new Set(t.string||[]),o=t.alias||{},i=t.default||{},a=new Map,s=new Map;for(let[g,f]of Object.entries(o)){let A=f;for(let P of A)a.set(g,P),s.has(P)||s.set(P,[]),s.get(P).push(g),a.set(P,g),s.has(g)||s.set(g,[]),s.get(g).push(P)}let c={};function l(g){if(n.has(g))return"boolean";let f=s.get(g)||[];for(let A of f)if(n.has(A))return"boolean";return"string"}function u(g){if(r.has(g))return!0;let f=s.get(g)||[];for(let A of f)if(r.has(A))return!0;return!1}let p=new Set([...n,...r,...Object.keys(o),...Object.values(o).flat(),...Object.keys(i)]);for(let g of p)c[g]||(c[g]={type:l(g),default:i[g]});for(let[g,f]of a.entries())g.length===1&&c[f]&&!c[f].short&&(c[f].short=g);let m=[],d={};for(let g=0;g<e.length;g++){let f=e[g];if(f==="--"){m.push(...e.slice(g));break}if(f.startsWith("--no-")){let A=f.slice(5);d[A]=!0;continue}m.push(f)}let y;try{y=(0,st.parseArgs)({args:m,options:Object.keys(c).length>0?c:void 0,allowPositionals:!0,strict:!1})}catch{y={values:{},positionals:m}}let h={_:[]};h._=y.positionals;for(let[g,f]of Object.entries(y.values)){let A=f;l(g)==="boolean"&&typeof f=="string"?A=f!=="false":u(g)&&typeof f=="boolean"&&(A=""),h[g]=A}for(let[g]of Object.entries(d)){h[g]=!1;let f=a.get(g);f&&(h[f]=!1);let A=s.get(g);if(A)for(let P of A)h[P]=!1}for(let[g,f]of a.entries())h[g]!==void 0&&h[f]===void 0&&(h[f]=h[g]),h[f]!==void 0&&h[g]===void 0&&(h[g]=h[f]),h[g]!==h[f]&&i[f]===h[f]&&(h[f]=h[g]);return h}var Vn=(()=>{let e=globalThis.process?.env??{};return e.NO_COLOR==="1"||e.TERM==="dumb"||e.TEST||e.CI})(),ae=(e,t=39)=>n=>Vn?n:`\x1B[${e}m${n}\x1B[${t}m`,oe=ae(1,22),N=ae(36),se=ae(90),ie=ae(4,24);function Yn(e,t){let n={boolean:[],string:[],alias:{},default:{}},r=at(t);for(let s of r){if(s.type==="positional")continue;s.type==="string"||s.type==="enum"?n.string.push(s.name):s.type==="boolean"&&n.boolean.push(s.name),s.default!==void 0&&(n.default[s.name]=s.default),s.alias&&(n.alias[s.name]=s.alias);let c=Z(s.name),l=re(s.name);if(c!==s.name||l!==s.name){let u=ee(n.alias[s.name]||[]);c!==s.name&&!u.includes(c)&&u.push(c),l!==s.name&&!u.includes(l)&&u.push(l),u.length>0&&(n.alias[s.name]=u)}}let o=Kn(e,n),[...i]=o._,a=new Proxy(o,{get(s,c){return s[c]??s[Z(c)]??s[re(c)]}});for(let[,s]of r.entries())if(s.type==="positional"){let c=i.shift();if(c!==void 0)a[s.name]=c;else{if(s.default===void 0&&s.required!==!1)throw new U(`Missing required positional argument: ${s.name.toUpperCase()}`,"EARG");a[s.name]=s.default}}else if(s.type==="enum"){let c=a[s.name],l=s.options||[];if(c!==void 0&&l.length>0&&!l.includes(c))throw new U(`Invalid value for argument: ${N(`--${s.name}`)} (${N(c)}). Expected one of: ${l.map(u=>N(u)).join(", ")}.`,"EARG")}else if(s.required&&a[s.name]===void 0)throw new U(`Missing required argument: --${s.name}`,"EARG");return a}function at(e){let t=[];for(let[n,r]of Object.entries(e||{}))t.push({...r,name:n,alias:ee(r.alias)});return t}async function Xn(e){return Promise.all(e.map(t=>R(t)))}async function xe(e,t){let n=await R(e.args||{}),r=Yn(t.rawArgs,n),o={rawArgs:t.rawArgs,args:r,data:t.data,cmd:e},i=await Xn(e.plugins??[]),a,s;try{for(let u of i)await u.setup?.(o);typeof e.setup=="function"&&await e.setup(o);let l=await R(e.subCommands);if(l&&Object.keys(l).length>0){let u=ct(t.rawArgs,n),p=t.rawArgs[u];if(p){let m=await ke(l,p);if(!m)throw new U(`Unknown command ${N(p)}`,"E_UNKNOWN_COMMAND");await xe(m,{rawArgs:t.rawArgs.slice(u+1)})}else{let m=await R(e.default);if(m){if(e.run)throw new U("Cannot specify both 'run' and 'default' on the same command.","E_DEFAULT_CONFLICT");let d=await ke(l,m);if(!d)throw new U(`Default sub command ${N(m)} not found in subCommands.`,"E_UNKNOWN_COMMAND");await xe(d,{rawArgs:t.rawArgs})}else if(!e.run)throw new U("No command specified.","E_NO_COMMAND")}}typeof e.run=="function"&&(a=await e.run(o))}catch(l){s=l}let c=[];if(typeof e.cleanup=="function")try{await e.cleanup(o)}catch(l){c.push(l)}for(let l of[...i].reverse())try{await l.cleanup?.(o)}catch(u){c.push(u)}if(s)throw s;if(c.length===1)throw c[0];if(c.length>1)throw new Error("Multiple cleanup errors",{cause:c});return{result:a}}async function Ae(e,t,n){let r=await R(e.subCommands);if(r&&Object.keys(r).length>0){let o=ct(t,await R(e.args||{})),i=t[o],a=await ke(r,i);if(a)return Ae(a,t.slice(o+1),e)}return[e,n]}async function ke(e,t){if(t in e)return R(e[t]);for(let n of Object.values(e)){let r=await R(n),o=await R(r?.meta);if(o?.alias&&ee(o.alias).includes(t))return r}}function ct(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r==="--")return-1;if(r.startsWith("-")){!r.includes("=")&&zn(r,t)&&n++;continue}return n}return-1}function zn(e,t){let n=e.replace(/^-{1,2}/,""),r=Z(n);for(let[o,i]of Object.entries(t))if(!(i.type!=="string"&&i.type!=="enum")&&(r===Z(o)||(Array.isArray(i.alias)?i.alias:i.alias?[i.alias]:[]).includes(n)))return!0;return!1}async function Qn(e,t){try{console.log(await er(e,t)+`
|
|
4
|
+
`)}catch(n){console.error(n)}}var Zn=/^no[-A-Z]/;async function er(e,t){let n=await R(e.meta||{}),r=at(await R(e.args||{})),o=await R(t?.meta||{}),i=`${o.name?`${o.name} `:""}`+(n.name||process.argv[1]),a=[],s=[],c=[],l=[];for(let d of r)if(d.type==="positional"){let y=d.name.toUpperCase(),h=d.required!==!1&&d.default===void 0;s.push([N(y+Se(d)),ot(d,h)]),l.push(h?`<${y}>`:`[${y}]`)}else{let y=d.required===!0&&d.default===void 0,h=[...(d.alias||[]).map(g=>`-${g}`),`--${d.name}`].join(", ")+Se(d);if(a.push([N(h),ot(d,y)]),d.type==="boolean"&&(d.default===!0||d.negativeDescription)&&!Zn.test(d.name)){let g=[...(d.alias||[]).map(f=>`--no-${f}`),`--no-${d.name}`].join(", ");a.push([N(g),[d.negativeDescription,y?se("(Required)"):""].filter(Boolean).join(" ")])}y&&l.push(`--${d.name}`+Se(d))}if(e.subCommands){let d=[],y=await R(e.subCommands);for(let[h,g]of Object.entries(y)){let f=await R((await R(g))?.meta);if(f?.hidden)continue;let A=ee(f?.alias),P=[h,...A].join(", ");c.push([N(P),f?.description||""]),d.push(h,...A)}l.push(d.join("|"))}let u=[],p=n.version||o.version;u.push(se(`${n.description} (${i+(p?` v${p}`:"")})`),"");let m=a.length>0||s.length>0;return u.push(`${ie(oe("USAGE"))} ${N(`${i}${m?" [OPTIONS]":""} ${l.join(" ")}`)}`,""),s.length>0&&(u.push(ie(oe("ARGUMENTS")),""),u.push(ve(s," ")),u.push("")),a.length>0&&(u.push(ie(oe("OPTIONS")),""),u.push(ve(a," ")),u.push("")),c.length>0&&(u.push(ie(oe("COMMANDS")),""),u.push(ve(c," ")),u.push("",`Use ${N(`${i} <command> --help`)} for more information about a command.`)),u.filter(d=>typeof d=="string").join(`
|
|
5
|
+
`)}function Se(e){let t=e.valueHint?`=<${e.valueHint}>`:"",n=t||`=<${rt(e.name)}>`;return!e.type||e.type==="positional"||e.type==="boolean"?t:e.type==="enum"&&e.options?.length?`=<${e.options.join("|")}>`:n}function ot(e,t){let n=t?se("(Required)"):"",r=e.default===void 0?"":se(`(Default: ${e.default})`);return[e.description,n,r].filter(Boolean).join(" ")}async function lt(e,t={}){let n=t.rawArgs||process.argv.slice(2),r=t.showUsage||Qn;try{let o=await tr(e);if(o.help.length>0&&n.some(i=>o.help.includes(i)))await r(...await Ae(e,n)),process.exit(0);else if(n.length===1&&o.version.includes(n[0])){let i=typeof e.meta=="function"?await e.meta():await e.meta;if(!i?.version)throw new U("No version specified","E_NO_VERSION");console.log(i.version)}else await xe(e,{rawArgs:n})}catch(o){o instanceof U?(await r(...await Ae(e,n)),console.error(o.message)):console.error(o,`
|
|
6
|
+
`),process.exit(1)}}async function tr(e){let t=await R(e.args||{}),n=new Set,r=new Set;for(let[o,i]of Object.entries(t)){n.add(o);for(let a of ee(i.alias))r.add(a)}return{help:it("help","h",n,r),version:it("version","v",n,r)}}function it(e,t,n,r){return n.has(e)||r.has(e)?[]:n.has(t)||r.has(t)?[`--${e}`]:[`--${e}`,`-${t}`]}var we=B(W(),1);var Re={name:"ax",version:"0.7.0",description:"Score any site's agent readiness and watch real AI agents navigate it \u2014 powered by ora",type:"module",packageManager:"pnpm@10.34.5",bin:{ax:"./dist/main.cjs"},exports:{".":{types:"./dist/index.d.ts",import:"./dist/index.js",require:"./dist/index.cjs"}},main:"./dist/index.cjs",types:"./dist/index.d.ts",files:["dist",".env.example"],engines:{node:">=22.4.0"},scripts:{build:"rm -rf dist && tsup && tsc -p tsconfig.lib.json","contract:gen":"node scripts/contract-gen.mjs",smoke:"node scripts/smoke.mjs","smoke:webmcp":"node scripts/smoke-webmcp.mjs","verify:pack":"node scripts/verify-pack.mjs",test:"vitest","test:ci":"vitest run --coverage","test:capture":"vitest run src/webmcp/capture.live.test.ts",lint:"biome check .","lint:fix":"biome check --write .",typecheck:"tsc --noEmit",prepublishOnly:"npm run build"},devDependencies:{"@biomejs/biome":"^2.5.7","@commitlint/cli":"^21.2.2","@commitlint/config-conventional":"^21.2.2","@types/node":"^26.2.0","@vitest/coverage-v8":"^3",citty:"^0.2.2","openapi-typescript":"^6.7.6",picocolors:"^1",tsup:"^8",typescript:"^7.0.2",vitest:"^3"},publishConfig:{access:"public"},pnpm:{onlyBuiltDependencies:["@biomejs/biome","esbuild"]},license:"MIT",homepage:"https://ora.ai",repository:{type:"git",url:"git+https://github.com/eralabs-ai/ora-cli.git"},keywords:["ai","agents","agent-readiness","agent-experience","llms.txt","ora","cli","scan"]};var Ce="1.23.0";function pt(e){let[t=0,n=0]=e.split(".").map(r=>Number.parseInt(r,10));return[t,n]}function sr(e){if(!e||!/^\d+\.\d+\.\d+$/.test(e))return!1;let[t,n]=pt(e),[r,o]=pt(Ce);return t>r||t===r&&n>o}var mt=!1;function te(e){mt||!sr(e)||(mt=!0,process.stderr.write(`ora reports contract ${e}; this CLI was built against ${Ce}. Newer fields may be missing from the output - upgrade with: npm i -g ax@latest
|
|
7
|
+
`))}function J(e){let t=new AbortController,n=!1,r,o=()=>{clearTimeout(r),r=setTimeout(()=>{n=!0,t.abort()},e)};return o(),{signal:t.signal,poke:o,disarm:()=>clearTimeout(r),tripped:()=>n}}async function F(e){try{let t=await e.json();return t.message||t.error||`HTTP ${e.status}`}catch{return`HTTP ${e.status}`}}var G=e=>new Promise(t=>setTimeout(t,e));var ar="https://ora.ai",cr=6e4,lr=2e3,ur=45,Ee=14,I=class extends Error{};function gt(e){return e?{authorization:`Bearer ${e}`}:{}}async function ht(e,t={}){let n=(t.baseUrl??process.env.ORA_API_URL??ar).replace(/\/+$/,"");t={...t,apiKey:t.apiKey||process.env.ORA_SCAN_API_KEY||void 0},t.progress?.(`Auditing ${e} with ora`);let r=await pr(n,e,t);te(r.result.contractVersion);let o=r.result;return ft(o)&&(o=await hr(n,o,t)),{result:o,verdict:r.verdict}}function dr(e,t,n){let r=new URLSearchParams({domain:t,format:"audit"});return n.force&&r.set("force","1"),n.ephemeral&&r.set("ephemeral","1"),n.maxAgeSeconds!==void 0&&r.set("maxAgeSeconds",String(n.maxAgeSeconds)),`${e}/api/scan/stream?${r}`}async function pr(e,t,n){let r=n.idleMs??cr,o=J(r),i=()=>new I(`ora audit timed out \u2014 no progress for ${Math.round(r/1e3)}s`),a;try{a=await fetch(dr(e,t,n),{headers:{accept:"text/event-stream",...gt(n.apiKey)},signal:o.signal})}catch(m){if(o.disarm(),o.tripped())throw i();let d=m instanceof Error?m.message:String(m);throw new I(`ora audit request failed: ${d}`)}if(a.status===429){o.disarm();let m=a.headers.get("retry-after");throw new I(`ora rate limit exceeded${m?` \u2014 retry after ${m}s`:""} (burst: 10 scans/min/IP; daily: 30 scans + 6 force per 24h). An ora-issued scan API key lifts these limits: set ORA_SCAN_API_KEY or pass --api-key.`)}if(!a.ok||!a.body)throw o.disarm(),new I(`ora audit failed: ${await F(a)}`);let s=gr(),c=new TextDecoder,l="",u,p;try{e:for await(let m of a.body){o.poke(),l=`${l}${c.decode(m,{stream:!0})}`.replace(/\r\n?/g,`
|
|
8
|
+
`);let d=l.indexOf(`
|
|
9
|
+
|
|
10
|
+
`);for(;d!==-1;){let y=mr(l.slice(0,d));if(l=l.slice(d+2),d=l.indexOf(`
|
|
11
|
+
|
|
12
|
+
`),!y)continue;let h;try{h=JSON.parse(y)}catch{continue}let g=s(h);if(g&&n.progress?.(g),h.type==="error")throw new I(`ora audit failed: ${typeof h.message=="string"?h.message:"scan error"}`);if(h.type==="scan_complete"&&h.result?u=h.result:h.type==="summary_ready"&&typeof h.agenticSummary=="string"&&(p=h.agenticSummary),u&&p)break e}}}catch(m){if(o.tripped())throw i();if(m instanceof I)throw m;let d=m instanceof Error?m.message:String(m);throw new I(`ora audit stream error: ${d}`)}finally{o.disarm(),a.body.cancel().catch(()=>{})}if(!u)throw new I("ora audit stream ended before completing");return{result:u,verdict:p}}function mr(e){let t=[];for(let n of e.split(`
|
|
13
|
+
`))n.startsWith("data:")&&t.push(n.slice(5).replace(/^ /,""));return t.join(`
|
|
14
|
+
`)}function gr(){let e=0,t=0,n="";return r=>{switch(r.type){case"kind_detecting":return"Detecting URL kind\u2026";case"kind_detected":return typeof r.kind=="string"?`Detected ${r.kind}, scanning\u2026`:void 0;case"scan_init":Array.isArray(r.checkRoster)&&(e=r.checkRoster.length);return;case"discovery_phase":return typeof r.label=="string"?r.label:void 0;case"check_complete":{if(t+=1,typeof r.checkName=="string"&&(n=r.checkName),e<=0)return`Running checks\u2026 (${t})`;let o=Math.min(t,e),i=Math.min(Ee,Math.max(0,Math.round(o/e*Ee)));return`${`${"\u2588".repeat(i)}${"\u2591".repeat(Ee-i)}`} ${o}/${e}${n?` \xB7 ${n}`:""}`}case"scan_complete":return"Finishing up\u2026";default:return}}}function ft(e){return e.analysisStatus==="complete"||e.analysisStatus==="stuck"?!1:e.analysisStatus==="partial"?!0:(e.pendingChecks?.length??0)>0}async function hr(e,t,n){let r=`${e}/api/score/${encodeURIComponent(t.domain)}?format=audit`,o=n.pollEveryMs??lr,i=n.pollLimit??ur,a=t;for(let s=0;s<i&&ft(a);s++){let c=a.pendingChecks?.length??0;n.progress?.(c?`Analyzing\u2026 ${c} check${c===1?"":"s"} pending`:"Analyzing\u2026"),await G(o);try{let l=await fetch(r,{headers:{accept:"application/json",...gt(n.apiKey)},signal:AbortSignal.timeout(15e3)});l.ok&&(a=await l.json())}catch{}}return a}function fr(e,t){let n=t.filter(r=>!r.skipped);return{name:e,checks:t,passed:n.filter(r=>r.passed).length,total:n.length,skipped:t.length-n.length}}function yr(e){let t=e.status==="pass",n=e.status==="na"||e.status==="pending",r={id:e.id,name:e.name,passed:t,status:e.status};return n&&(r.skipped=!0),n&&e.naReason?r.detail=e.naReason:e.details&&(r.detail=e.details),typeof e.estScoreGain=="number"&&(r.estScoreGain=e.estScoreGain),e.specUrl&&(r.specUrl=e.specUrl),!t&&!n&&e.recommendation&&(r.hint=e.recommendation),r}function yt(e,t){let{result:n}=e,r=(n.layers??[]).map(a=>fr(a.name,(a.checks??[]).map(yr))),o={target:n.domain||t,score:n.score,grade:n.grade,summary:e.verdict,sections:r,topFixes:n.topFixes??[],reportUrl:n.url,analysisStatus:n.analysisStatus},i=n;return i.servedFromCache&&typeof i.resultAgeSeconds=="number"&&(o.cacheAgeSeconds=i.resultAgeSeconds),n.mcpAuthRequired&&(o.mcpAuthRequired=!0),o}var w=B(W(),1),br=80,wr=120,ue=10;function vr(){return Math.min(wr,Math.max(br,process.stdout.columns??100))}function Te(e,t){return e.length<t?e+" ".repeat(t-e.length):e}function wt(e,t){if(t<=0||e.length<=t)return[e];let n=[],r="";for(let o of e.split(/\s+/))for(r=r?`${r} ${o}`:o;r.length>t;){let i=r.lastIndexOf(" ");i>0&&r.length-i-1<=t?(n.push(r.slice(0,i)),r=r.slice(i+1)):(n.push(r.slice(0,t)),r=r.slice(t))}return r&&n.push(r),n.length?n:[""]}function _e(e,t){let n=(a,s,c)=>w.default.dim(a+e.map(l=>"\u2500".repeat(l.width+2)).join(s)+c),r=w.default.dim("\u2502"),o=(a,s)=>{let c=a.map((p,m)=>wt(typeof p=="string"?p:p[0],e[m].width)),l=Math.max(1,...c.map(p=>p.length)),u=[];for(let p=0;p<l;p++){let m=c.map((d,y)=>{let h=Te(d[p]??"",e[y].width),g=s??(typeof a[y]=="string"?e[y].paint:a[y][1]);return` ${g?g(h):h} `});u.push(r+m.join(r)+r)}return u},i=[n("\u250C","\u252C","\u2510")];return i.push(...o(e.map(a=>a.title),w.default.bold)),i.push(n("\u251C","\u253C","\u2524")),t.forEach((a,s)=>{i.push(...o(a)),s<t.length-1&&i.push(n("\u251C","\u253C","\u2524"))}),i.push(n("\u2514","\u2534","\u2518")),i}function Sr(e,t){let r=Math.max(46,e-4-13),o=14,i=Math.min(26,Math.max(5,...t.map(l=>l.length))),a=r-1-i;a<o*2&&(i=Math.max(12,i-(o*2-a)),a=r-1-i);let s=Math.max(o,Math.ceil(a/2)),c=Math.max(o,a-s);return[{title:"",width:1},{title:"Check",width:i,paint:w.default.bold},{title:"What's wrong",width:s},{title:"How to fix",width:c,paint:w.default.cyan}]}function bt(e,t,n,r){let i=Math.max(40,e-4-7),a=Math.min(30,Math.max(n[0].length,...t.map(s=>s.length)));return[{title:n[0],width:a,paint:r},{title:n[1],width:Math.max(20,i-a),paint:r}]}function xr(e,t){if(t<=0)return w.default.dim("\u2500".repeat(ue));let n=Math.min(ue,Math.max(0,Math.round(e/t*ue)));return w.default.green("\u2588".repeat(n))+w.default.dim("\u2591".repeat(ue-n))}function Ar(e,t,n,r){let o=[""],i=e.total>0?`${e.passed}/${e.total} passed`:"no applicable checks",a=e.skipped>0?` \xB7 ${e.skipped} skipped`:"";o.push(` ${w.default.bold(Te(e.name,n))} ${xr(e.passed,e.total)} ${w.default.dim(i+a)}`);let s=e.checks.filter(c=>!c.passed&&!c.skipped);if(s.length){o.push(` ${w.default.red("\u2717")} ${w.default.bold(`Issues (${s.length})`)}`);let c=_e(Sr(t,s.map(u=>u.name)),s.map(u=>[u.status==="warning"?["\u26A0",w.default.yellow]:["\u2717",w.default.red],u.name,[u.detail??"",p=>p],u.hint??""]));o.push(...c.map(u=>` ${u}`));let l=s.filter(u=>u.specUrl);for(let u of l)o.push(w.default.dim(` \u21B3 ${u.id} spec: ${u.specUrl}`))}if(r.showPassing){let c=e.checks.filter(l=>l.passed&&!l.skipped);if(c.length){o.push(` ${w.default.green("\u2713")} ${w.default.bold(`Passed (${c.length})`)}`);let l=_e(bt(t,c.map(u=>u.name),["Check","Details"]),c.map(u=>[u.name,u.detail??""]));o.push(...l.map(u=>` ${u}`))}}if(r.showSkipped){let c=e.checks.filter(l=>l.skipped);if(c.length){o.push(` ${w.default.dim(`\u25CB Skipped (${c.length})`)}`);let l=_e(bt(t,c.map(u=>u.name),["Check","Reason"],w.default.dim),c.map(u=>[u.name,u.detail??""]));o.push(...l.map(u=>` ${u}`))}}return o}function kr(e){if(!e.topFixes.length)return[];let t=["",` ${w.default.bold("Top fixes")} ${w.default.dim("(ranked by ora)")}`],n=e.topFixes.reduce((r,o)=>Math.max(r,o.id.length),0);return e.topFixes.forEach((r,o)=>{let i=typeof r.estScoreGain=="number"?w.default.green(`\u2248 +${r.estScoreGain} pts`):w.default.dim("\u2014"),a=r.bonus?w.default.dim(" (bonus)"):"";t.push(` ${o+1}. ${w.default.bold(Te(r.id,n))} ${i}${a}`)}),t}function $r(e){return e<90?`${e}s`:e<5400?`${Math.round(e/60)} min`:`${Math.round(e/3600)}h`}function vt(e,t={}){let n=vr(),r=e.sections.reduce((l,u)=>Math.max(l,u.name.length),0),o=[""],i=e.score>=70?w.default.green:e.score>=50?w.default.yellow:w.default.red;if(o.push(` ${w.default.bold(e.target)} ${i(w.default.bold(`${e.score}/100 ${e.grade}`))}`),t.tunnel&&o.push(w.default.dim(" tunnel audit \u2014 disposable result, excluded from rankings; off-site checks (registry listings, brand search) usually fail for a throwaway hostname")),e.mcpAuthRequired&&o.push(w.default.yellow(" \u26A0 MCP handshake requires credentials \u2014 target is unscored (0/F means could not evaluate, not failed everything)")),e.summary)for(let l of wt(e.summary,n-4))o.push(` ${w.default.dim(l)}`);for(let l of e.sections)o.push(...Ar(l,n,r,t));o.push(...kr(e));let a=e.sections.reduce((l,u)=>l+u.passed,0),s=e.sections.reduce((l,u)=>l+u.skipped,0),c=[];if(!t.showPassing&&a>0&&c.push(` Run with --show-passing to list all ${a} passing checks`),!t.showSkipped&&s>0&&c.push(` ${s} check${s===1?"":"s"} skipped \u2014 run with --show-skipped to see them`),e.analysisStatus==="partial"?c.push(" Analysis still finishing \u2014 re-run shortly for the final score"):e.analysisStatus==="stuck"&&c.push(" Scan did not fully resolve \u2014 re-run with --force to complete it"),typeof e.cacheAgeSeconds=="number"&&c.push(` cached result (${$r(e.cacheAgeSeconds)} old) \xB7 pass --force for a fresh scan`),e.reportUrl&&c.push(` Full report: ${e.reportUrl}`),c.length){o.push("");for(let l of c)o.push(w.default.dim(l))}return o.push(""),o}var St=require("child_process"),Y=class extends Error{},Rr=3e4,Cr=9e4,Er=1e4;function Pe(e){try{let n=new URL(e.includes("://")?e:`http://${e}`).hostname;return n==="localhost"||n==="127.0.0.1"||n==="::1"||n==="[::1]"||n.endsWith(".local")||n.endsWith(".localhost")}catch{return!1}}function _r(e){for(let t of e.matchAll(/https:\/\/[^\s"'|]+/g))try{let n=new URL(t[0]);if(n.pathname==="/"&&!n.search&&!Pe(n.hostname))return n.origin}catch{}}async function xt(e,t=Rr){let n=await Pr(e,t);try{await Tr(n.url,Cr)}catch(r){throw n.close(),r}return n}async function Tr(e,t){let n=Date.now()+t;for(;Date.now()<n;){try{if((await fetch(e,{redirect:"manual",signal:AbortSignal.timeout(Er)})).status<500)return}catch{}await new Promise(r=>setTimeout(r,5e3))}throw new Y([`tunnel opened but never became routable within ${Math.round(t/1e3)}s.`,"Some networks and DNS filters block tunnel vendors' domains entirely -","if this repeats, try another network, DNS resolver, or tunnel tool."].join(`
|
|
15
|
+
`))}function Pr(e,t){return new Promise((n,r)=>{let o=process.platform!=="win32",i=(0,St.spawn)(e,{shell:!0,detached:o,stdio:["ignore","pipe","pipe"]}),a=!1,s="",c=()=>{try{o&&i.pid?process.kill(-i.pid,"SIGTERM"):i.kill("SIGTERM")}catch{}},l=p=>{a||(a=!0,clearTimeout(u),c(),r(p))},u=setTimeout(()=>l(new Y(`tunnel command did not print a public https URL within ${Math.round(t/1e3)}s: ${e}`)),t);i.on("error",p=>l(new Y(p.message))),i.on("exit",p=>{let m=s.trim()?`
|
|
16
|
+
output: ${s.trim().slice(-300)}`:"";l(new Y(`tunnel command exited before printing a public https URL (code ${p??"unknown"}): ${e}${m}`))});for(let p of[i.stdout,i.stderr])p?.setEncoding("utf8"),p?.on("data",m=>{s=(s+m).slice(-2e3);let d=_r(s);d&&!a&&(a=!0,clearTimeout(u),i.removeAllListeners("exit"),n({url:d,close:c}))})})}var Ie=B(W(),1);function X(e,t){let n=process.stdout.columns??100;return Math.min(t,Math.max(e,n))}function q(e,t){let n=e.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-1)}\u2026`:n}function O(e,t){let n=[],r="";for(let o of e.replace(/\s+/g," ").trim().split(" "))r&&r.length+1+o.length>t?(n.push(r),r=o):r=r?`${r} ${o}`:o;return r&&n.push(r),n}var z=["\u25C7","\u25C7","\u25C8","\u25C8","\u25C6","\u25C6","\u25C8","\u25C8"];function E(e){return e.replace(/[\u0000-\u001f\u007f-\u009f]/g," ")}var Ir=80,de,Oe=0,ne="";function Or(){let e=Ie.default.cyan(z[Oe%z.length]),t=Math.max(10,(process.stderr.columns??80)-2),n=ne.length>t?`${ne.slice(0,t-1)}\u2026`:ne;process.stderr.write(`\r\x1B[K${e} ${Ie.default.dim(n)}`),Oe++}var S={start(e){S.stop(),Oe=0,ne=e,process.stderr.isTTY&&(de=setInterval(Or,Ir))},update(e){ne=e},stop(){de&&(clearInterval(de),de=void 0,process.stderr.write("\r\x1B[K"))}};var C={OK:0,BELOW_MIN_SCORE:1,USAGE:2,API:3};function At(e,t,n,r){if(e===void 0)return{};let o=Number(e);return e.trim()===""||!Number.isInteger(o)||o<n||o>r?{error:`${t} must be an integer between ${n} and ${r}, got ${JSON.stringify(e)}`}:{value:o}}function Mr(e){let t=e.trim().replace(/\/+$/,"");if(!(!t||/\s/.test(t)))try{let n=new URL(t.includes("://")?t:`https://${t}`);return!n.hostname.includes(".")&&n.hostname!=="localhost"?void 0:t}catch{return}}async function kt(e){let t=Mr(e.url);if(!t)return console.error(`Not a scannable URL or domain: ${JSON.stringify(e.url)}`),C.USAGE;let n=At(e.minScore,"--min-score",0,100),r=At(e.maxAge,"--max-age",0,86400);for(let d of[n,r])if(d.error)return console.error(d.error),C.USAGE;let o=e.tunnelCmd?.trim()||process.env.ORA_TUNNEL_CMD?.trim(),i=!!o;if(!i&&Pe(t))return console.error([`${t} only exists on this machine, and ora audits public URLs.`,"Either audit a publicly reachable deployment of this site (e.g. a preview URL),","or run it through a tunnel you provide:"," ax audit localhost:3000 --tunnel-cmd 'ngrok http 3000 --log stdout'","Any command that prints a public https URL works; the result is stored as","ephemeral (excluded from rankings, deleted after a few days)."].join(`
|
|
17
|
+
`)),C.USAGE;let a=!e.json;a&&S.start(`Auditing ${t} with ora`);let s,c=()=>s?.close(),l=d=>{c(),process.exit(d==="SIGINT"?130:143)},u=t;if(i&&o){a&&S.update(`Opening a tunnel to ${t}`);try{s=await xt(o)}catch(d){return S.stop(),console.error(d instanceof Error?d.message:String(d)),C.USAGE}process.on("SIGINT",l),process.on("SIGTERM",l),u=s.url}let p;try{p=await ht(u,{progress:a?d=>S.update(d):void 0,maxAgeSeconds:r.value,force:e.force,ephemeral:i||void 0,apiKey:e.apiKey?.trim()||void 0})}catch(d){return S.stop(),console.error(`Audit failed: ${d instanceof Error?d.message:String(d)}`),d instanceof I?C.API:C.USAGE}finally{c(),process.removeListener("SIGINT",l),process.removeListener("SIGTERM",l)}S.stop();let{result:m}=p;if(e.json)process.stdout.write(`${JSON.stringify(m,null,2)}
|
|
18
|
+
`);else for(let d of vt(yt(p,t),{showSkipped:e.showSkipped,showPassing:e.showPassing,tunnel:i}))console.log(d);if(n.value!==void 0){if(m.mcpAuthRequired)return process.stderr.write(`--min-score skipped: the MCP handshake requires credentials, so the target is unscored
|
|
19
|
+
`),C.OK;if(m.score<n.value)return e.json||console.log(` Score ${m.score} is below the required minimum ${n.value}
|
|
20
|
+
`),C.BELOW_MIN_SCORE}return C.OK}var _=B(W(),1);var Nr="https://api.agentfront.sh",Lr=12e4;async function jr(e,t){let n=await fetch(`${e}/auth/token`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:"{}"});if(n.status===401)throw new Error("ora rejected the API key (401). Check ORA_API_KEY.");let r=await n.json().catch(()=>({}));if(!n.ok||!r.token)throw new Error(`ora auth failed (${n.status})${r.error?`: ${r.error}`:""}`);return r.token}async function Wr(e,t,n){let r={intent:n.intent};n.domain&&(r.domain=n.domain),n.harness&&(r.harness=n.harness),n.model&&(r.model=n.model),n.executionKind&&(r.execution_kind=n.executionKind);let o=await fetch(`${e}/experiment/v1/runs`,{method:"POST",headers:{authorization:`Bearer ${t}`,"content-type":"application/json"},body:JSON.stringify(r)});if(o.status===429)throw new Error("ora rate limit hit (429). Wait a moment and retry.");let i=await o.text(),a;try{a=JSON.parse(i)}catch{throw new Error(`ora returned a non-JSON response (${o.status})`)}if(!o.ok||!a.runId)throw new Error(`ora run failed (${o.status}): ${a.message??a.error??i}`);return a}function Me(e){let t="message",n=[];for(let r of e.split(`
|
|
21
|
+
`))r.startsWith(":")||(r.startsWith("event:")?t=r.slice(6).trim():r.startsWith("data:")&&n.push(r.slice(5).replace(/^ /,"")));return n.length?{event:t,data:n.join(`
|
|
22
|
+
`)}:null}async function Dr(e,t,n,r,o){let i=n.startsWith("http")?n:`${e}${n}`,a=J(o),s=await fetch(i,{headers:{authorization:`Bearer ${t}`,accept:"text/event-stream"},signal:a.signal});if(!s.ok||!s.body)throw a.disarm(),new Error(`ora run stream failed (${s.status})`);let c=new TextDecoder,l={steps:[],trajectory:[]},u="";try{e:for await(let p of s.body){a.poke(),u=`${u}${c.decode(p,{stream:!0})}`.replace(/\r\n?/g,`
|
|
23
|
+
`);let m=u.indexOf(`
|
|
24
|
+
|
|
25
|
+
`);for(;m!==-1;){let d=Me(u.slice(0,m));if(u=u.slice(m+2),m=u.indexOf(`
|
|
26
|
+
|
|
27
|
+
`),!d)continue;let y;try{y=JSON.parse(d.data)}catch{continue}if(Br(l,d.event,y,r),l.summary&&l.insight)break e}}}catch(p){throw a.tripped()?new Error(`ora run stream timed out after ${o}ms of silence`):p}finally{a.disarm(),s.body.cancel().catch(()=>{})}return l}function Br(e,t,n,r){switch(t){case"trajectory":{let o=n.steps;Array.isArray(o)&&(e.trajectory=o,r.snapshot?.(e.trajectory));return}case"step":{let o=n.step;o&&(e.steps.push(o),r.step?.(o,Number(n.seq??e.steps.length)));return}case"result":{let o=n.result;o&&(e.summary=o,r.finished?.(o));return}case"insight":{let o=n.insight;o&&(e.insight=o,r.scored?.(o));return}default:return}}async function Ur(e,t,n){for(let r=0;;r++){let o;try{let i=await fetch(`${e}/experiment/v1/runs?pageSize=50`,{headers:{authorization:`Bearer ${t}`}});if(!i.ok)return;o=(await i.json()).results?.find(s=>s.id===n)}catch{return}if(!o)return;if(o.total_tokens!=null||o.cost_usd!=null)return{totalTokens:o.total_tokens??void 0,inputTokens:o.input_tokens??void 0,outputTokens:o.output_tokens??void 0,cacheReadTokens:o.cache_read_tokens??void 0,cacheCreationTokens:o.cache_creation_tokens??void 0,costUsd:o.cost_usd??void 0};if(r>0)return;await G(1200)}}async function Ne(e,t={}){let n=(e.baseUrl??process.env.ORA_PLATFORM_URL??Nr).replace(/\/+$/,""),r=e.apiKey??process.env.ORA_API_KEY;if(!r)throw new Error("Missing ORA_API_KEY. Set it in your environment or a local .env file (see .env.example).");let o=await jr(n,r),i=await Wr(n,o,e),a={runId:i.runId,intent:e.intent,domain:e.domain,harness:e.harness};if(i.status==="succeeded"&&!i.streamUrl)return{...a,steps:[],trajectory:[]};t.opened?.(i.runId);let s=await Dr(n,o,i.streamUrl??`/experiment/v1/runs/${i.runId}/stream`,t,e.idleMs??Lr),c=s.summary?await Ur(n,o,i.runId):void 0;return{...a,result:s.summary,insight:s.insight,usage:c,steps:s.steps,trajectory:s.trajectory}}var Jr="https://ora.ai",Fr=12e4,Hr=5e3,Gr=180,$=class extends Error{};function Le(e){return(e??process.env.ORA_API_URL??Jr).replace(/\/+$/,"")}async function je(e){let t;try{t=await fetch(e,{headers:{accept:"application/json"},signal:AbortSignal.timeout(15e3)})}catch(n){let r=n instanceof Error?n.message:String(n);throw new $(`ora request failed: ${r}`)}if(!t.ok)throw new $(`ora request failed: ${await F(t)}`);return await t.json()}function Ct(e){return je(`${Le(e)}/api/journey/intents`)}function Et(e){return je(`${Le(e)}/api/journey/agents`)}function qr(e){let t=r=>{let o=e.headers.get(r);if(o===null)return;let i=Number.parseInt(o,10);return Number.isFinite(i)?i:void 0},n=t("x-ratelimit-reset");return{limit:t("x-ratelimit-limit"),remaining:t("x-ratelimit-remaining"),resetAtMs:n!==void 0?n*1e3:void 0}}async function Kr(e,t,n){let r={intent:n.task?{custom:n.task,domain:t}:{...n.intentId?{intent_id:n.intentId}:{},domain:t},harness:n.harness,model:n.model},o;try{o=await fetch(`${e}/api/journey/runs`,{method:"POST",headers:{"content-type":"application/json",accept:"application/json",...n.apiKey?{authorization:`Bearer ${n.apiKey}`}:{}},body:JSON.stringify(r),signal:AbortSignal.timeout(3e4)})}catch(a){let s=a instanceof Error?a.message:String(a);throw new $(`ora journey request failed: ${s}`)}if(o.status===401)throw new $("free-text tasks need an ora partner API key \u2014 set ORA_PARTNER_API_KEY or pass --api-key (keys are issued by ora on request)");if(o.status===429){let a=o.headers.get("retry-after"),s=n.apiKey?"keyed allowance: 1000 runs per 24h per key":"burst: 20/min/IP; daily: 200 runs per 24h per IP \u2014 an ora partner API key raises this to 1000/24h per key: set ORA_PARTNER_API_KEY or pass --api-key";throw new $(`ora journey caller limit exceeded${a?` \u2014 retry after ${We(Number(a)*1e3)}`:""} (${s})`)}if(o.status===503)throw new $("ora's run engine is unavailable right now \u2014 try again shortly");if(!o.ok)throw new $(`ora journey request failed: ${await F(o)}`);let i=await o.json();return te(i.contractVersion),{record:i,cached:i.rate_limited===!0,allowance:qr(o)}}function We(e){if(!Number.isFinite(e)||e<=0)return"soon";let t=e/36e5;if(t>=1)return`${Math.ceil(t)}h`;let n=e/6e4;return n>=1?`${Math.ceil(n)}m`:`${Math.ceil(e/1e3)}s`}function Vr(e){if(!e)return"starting\u2026";if(e.type==="text")return"thinking\u2026";if(e.action==="search")return e.search_query?`searching \u201C${$t(e.search_query,40)}\u201D`:"searching\u2026";let t=e.label??`${e.url_host??""}${e.url_path??""}`,n=e.completed===!1?"fetching":"fetched";return t?`${n} ${$t(t,48)}`:`${n}\u2026`}function $t(e,t){return e.length>t?`${e.slice(0,t-1)}\u2026`:e}async function Yr(e,t,n){let r=t.startsWith("http")?t:`${e}${t}`,o=n.idleMs??Fr,i=J(o),a=()=>new $(`ora journey stream timed out \u2014 no frames for ${Math.round(o/1e3)}s`),s;try{s=await fetch(r,{headers:{accept:"text/event-stream"},signal:i.signal})}catch(p){if(i.disarm(),i.tripped())throw a();let m=p instanceof Error?p.message:String(p);throw new $(`ora journey stream failed: ${m}`)}if(!s.ok||!s.body)throw i.disarm(),new $(`ora journey stream failed: ${await F(s)}`);let c=new TextDecoder,l={},u="";try{e:for await(let p of s.body){i.poke(),u=`${u}${c.decode(p,{stream:!0})}`.replace(/\r\n?/g,`
|
|
28
|
+
`);let m=u.indexOf(`
|
|
29
|
+
|
|
30
|
+
`);for(;m!==-1;){let d=Me(u.slice(0,m));if(u=u.slice(m+2),m=u.indexOf(`
|
|
31
|
+
|
|
32
|
+
`),!d)continue;let y;try{y=JSON.parse(d.data)}catch{continue}if(d.event==="trajectory"){let h=y.steps??[],g=h.filter(f=>f.type==="tool_call").at(-1);n.progress?.(`step ${h.length} \xB7 ${Vr(g??h.at(-1))}`)}else if(d.event==="processing")n.progress?.(typeof y.message=="string"?y.message:"generating insights\u2026");else if(d.event==="result"){l.result=y;break e}else if(d.event==="error"){l.errorMessage=typeof y.message=="string"?y.message:"unknown engine error";break e}}}}catch(p){if(i.tripped())throw a();if(p instanceof $)throw p;let m=p instanceof Error?p.message:String(p);throw new $(`ora journey stream error: ${m}`)}finally{i.disarm(),s.body.cancel().catch(()=>{})}return l}function pe(e,t){return je(`${e}/api/journey/runs/${encodeURIComponent(t)}`)}async function Rt(e,t,n){let r=n.pollEveryMs??Hr,o=n.pollLimit??Gr,i=await pe(e,t);for(let a=0;a<o&&i.status==="running";a++){n.progress?.("agent working\u2026 (polling)"),await G(r);try{i=await pe(e,t)}catch{}}return i}async function _t(e,t){let n=Le(t.baseUrl);t={...t,apiKey:t.apiKey||process.env.ORA_PARTNER_API_KEY||process.env.ORA_SCAN_API_KEY||void 0};let r=await Kr(n,e,t),{record:o}=r;r.cached&&t.progress?.("target at its 24h cap \u2014 fetching the most recent stored run");let i;if(!t.noStream&&o.status==="running")try{i=(await Yr(n,o.stream_url,t)).errorMessage}catch{t.progress?.("stream went quiet \u2014 switching to polling"),await Rt(n,o.id,t)}else t.noStream&&o.status==="running"&&await Rt(n,o.id,t);let a=await Xr(n,o.id,t);if(a.status==="running")throw i?new $(`ora journey run failed: ${i}`):new $(`run ${o.id} is still executing \u2014 the ${t.noStream?"poll budget ran out":"stream ended"} before a terminal result. Check ${n}/api/journey/runs/${o.id} shortly`);return te(a.contractVersion),{record:o,cached:r.cached,retryAfterMs:r.record.retry_after_ms,allowance:r.allowance,detail:a,engineError:i}}async function Xr(e,t,n){let r=await pe(e,t);for(let o=0;o<3&&r.status==="running";o++)n.progress?.("finalizing\u2026"),await G(1500),r=await pe(e,t);return r}var D={OK:0,RUN_FAILED:1,USAGE:2,API:3},zr="public caps: 100 runs/24h per target \xB7 200 runs/24h per IP",Qr="keyed caps: 1000 runs/24h per key \xB7 no per-target cap";function De(e){return console.error(_.default.red(`ax deep-journey: ${e}`)),D.API}function Zr(e,t){if(t==="failed")return _.default.red("\u2717 run failed");switch(e){case"satisfied":return _.default.green("\u2713 task satisfied");case"partial":return _.default.yellow("\u25D0 partially satisfied");case"unsatisfied":return _.default.red("\u2717 task not satisfied");default:return _.default.dim("\xB7 not gradable")}}function Tt(e){return`${e.label} \xB7 ${e.variant}`}function eo(e,t){let{detail:n}=e,r=[""];r.push(`${Zr(n.verdict,n.status)} ${_.default.dim(n.domain??t)}`);let o=[];n.step_count!=null&&o.push(`${n.step_count} steps`);let i=n.result;i?.num_turns!=null&&o.push(`${i.num_turns} turns`),i?.duration_ms!=null&&o.push(`${(i.duration_ms/1e3).toFixed(1)}s`),o.length&&r.push(_.default.dim(o.join(" \xB7 "))),i?.insight?.summary&&r.push("",i.insight.summary);for(let a of i?.insight?.key_observations??[])r.push(_.default.dim(` - ${a}`));return n.status==="failed"&&r.push("",_.default.dim(e.engineError?`Engine error: ${e.engineError} \u2014 re-running is free to try.`:"The run ended in an engine error; re-running is free to try.")),r.push("",_.default.dim(`For the 4-layer readiness audit, run: ax audit ${t}`)),r}async function Pt(e){let t=e.url.trim();if(!t)return console.error("ax deep-journey: a target URL or domain is required"),D.USAGE;let n=!e.json&&process.stderr.isTTY,r=e.task?.trim()||void 0,o=e.apiKey||process.env.ORA_PARTNER_API_KEY||process.env.ORA_SCAN_API_KEY||void 0;if(r&&e.intent!==void 0)return console.error("ax deep-journey: --task and --intent are mutually exclusive \u2014 a free-text task replaces the curated intent"),D.USAGE;if(r&&!o)return console.error("ax deep-journey: --task needs an ora partner API key \u2014 set ORA_PARTNER_API_KEY or pass --api-key (keys are issued by ora on request)"),D.USAGE;let i=e.intent,a;try{let[c,l]=await Promise.all([r?void 0:Ct(),Et()]);if(c){if(i===void 0)i=c.defaultId;else if(!c.intents.some(m=>m.id===i))return console.error(`ax deep-journey: unknown intent "${i}". Available intents:
|
|
33
|
+
${c.intents.map(m=>` ${m.id.padEnd(12)} ${m.hint}`).join(`
|
|
34
|
+
`)}`),D.USAGE}let u=e.agent??l.defaultId,p=l.agents.find(m=>m.id===u);if(!p)return console.error(`ax deep-journey: unknown agent "${u}". Available agents:
|
|
35
|
+
${l.agents.map(m=>` ${m.id.padEnd(12)} ${Tt(m)}`).join(`
|
|
36
|
+
`)}`),D.USAGE;a=p}catch(c){return De(c instanceof Error?c.message:String(c))}e.json||console.error(_.default.dim(o?Qr:zr)),n&&S.start(`Sending ${Tt(a)} to ${t} (${r?`"${r}"`:i})`);let s;try{s=await _t(t,{intentId:r?void 0:i,task:r,apiKey:o,harness:a.harness,model:a.model,noStream:e.noStream,progress:n?c=>S.update(c):void 0})}catch(c){return n&&S.stop(),c instanceof $?De(c.message):De(c instanceof Error?c.message:String(c))}if(n&&S.stop(),e.json)return console.log(JSON.stringify(s.detail,null,2)),s.detail.status==="failed"?D.RUN_FAILED:D.OK;s.cached?console.error(_.default.yellow(`This target hit its 24h cap \u2014 showing the most recent stored run${s.retryAfterMs?` (fresh run in ${We(s.retryAfterMs)})`:""}.`)):s.allowance.remaining!==void 0&&s.allowance.limit!==void 0&&console.error(_.default.dim(`allowance: ${s.allowance.remaining} of ${s.allowance.limit} target runs left in the 24h window`));for(let c of eo(s,t))console.log(c);return s.detail.status==="failed"?D.RUN_FAILED:D.OK}var v=B(W(),1);var k=B(W(),1);function Be(e){if(!e)return{};let t=e.match(/https?:\/\/([^/\s]+)(\/\S*)?/i);return t?{host:t[1],path:t[2]??"/"}:{}}function K(e){return/search/i.test(`${e.tool??""} ${e.action??""}`)}function to(e){if(K(e))return"\u{1F50D}";let t=`${e.tool??""} ${e.action??""}`.toLowerCase();return/fetch|http|get/.test(t)?"\u{1F310}":/read|open|view/.test(t)?"\u{1F4C4}":"\u{1F310}"}function no(e,t){if(K(e)){let c=e.input_display??String(e.input?.query??"search"),l=e.output_structured?.links?.length;return{id:e.id,kind:"search",icon:"\u{1F50D}",label:q(`"${c}"`,t),meta:l?`${l} results`:void 0,tone:"ok",notes:[],children:[]}}let{host:n,path:r}=Be(e.input_display??String(e.input?.url??"")),o=e.status,i=o!=null&&o>=300&&o<400,a=!!e.is_error||o!=null&&o>=400,s;if(i)s=`\u21B3 ${o}`;else if(a)s=`\u2717 ${o??"error"}`;else{let c=["\u2713"];o&&c.push(String(o)),e.duration_ms&&c.push(`${(e.duration_ms/1e3).toFixed(1)}s`),s=c.join(" ")}return{id:e.id,kind:"fetch",icon:to(e),label:q(`${n??"?"}${r??""}`,t),meta:s,tone:i?"redirect":a?"error":"ok",notes:[],children:[]}}function It(e,t,n){let r=X(60,120),o=Math.min(52,Math.max(24,r-40)),i=Math.max(30,r-24),a={id:-1,kind:"intent",icon:"\u25C6",label:q(t,i),tone:"root",notes:[],children:[]},s=new Map,c=[],l,u,p;for(let m of e){if(m.type==="text"&&m.kind==="reasoning"){let h=(m.thinking??m.text??"").trim();h&&c.push(q(h,i));continue}if(m.type!=="tool_call")continue;let d=no(m,o);d.notes=c,c=[],s.set(m.id,d);let y=a;if(!K(m)){let h=m.attribution?.referrer?.step_id,g=m.attribution?.kind,f=h!=null?s.get(h):void 0;f&&f!==d?y=f:g==="web_search"&&l?y=l:g==="previous_artifact"&&u&&(y=u)}y.children.push(d),K(m)?l=d:u=d,p=d}return p&&!n&&(p.tone="active",p.meta="\u2026"),{root:a,looseNotes:c}}function Ot(e){let t=e.filter(o=>o.kind==="reasoning").length,n=e.filter(o=>o.type==="tool_call"&&K(o)).length,r=[`${k.default.bold(String(e.length))} steps`];return t&&r.push(`${k.default.bold(String(t))} reasoning`),n&&r.push(`${k.default.bold(String(n))} search${n===1?"":"es"}`),r.join(k.default.dim(" \xB7 "))}function ro(e){switch(e){case"root":return{frame:k.default.dim,ink:t=>k.default.bold(t)};case"active":return{frame:k.default.cyan,ink:t=>k.default.cyan(k.default.bold(t))};case"redirect":return{frame:k.default.yellow,ink:k.default.yellow};case"error":return{frame:k.default.red,ink:k.default.red};default:return{frame:k.default.green,ink:k.default.green}}}var Mt=e=>k.default.dim(`(\u2026) ${e}`);function Nt(e,t){let{frame:n,ink:r}=ro(e.tone),i=`${e.icon} ${e.label}${e.meta?` ${e.meta}`:""}`.length+2,a=`${e.icon} ${r(e.label)}${e.meta?` ${k.default.dim(e.meta)}`:""}`,s=e.children.length>0,c=e.notes.map(Mt);return c.push(n(`\u256D${"\u2500".repeat(i)}\u256E`)),c.push(`${n(t?"\u2524":"\u2502")} ${a} ${n("\u2502")}`),c.push(n(s?`\u2570\u2500\u252C${"\u2500".repeat(i-2)}\u256F`:`\u2570${"\u2500".repeat(i)}\u256F`)),e.children.forEach((l,u)=>{let p=u===e.children.length-1,m=Nt(l,!0),d=l.notes.length+1;m.forEach((y,h)=>{let g;h===d?g=p?" \u2570\u2500\u2500":" \u251C\u2500\u2500":h<d?g=" \u2502 ":g=p?" ":" \u2502 ",c.push(k.default.dim(g)+y)})}),c}function Lt(e){let t=Nt(e.root,!1);return e.looseNotes.length&&(t.push(""),t.push(...e.looseNotes.map(Mt))),t}var Ue=B(W(),1);var me=class{rows=0;beat=0;bornAt=Date.now();ticker;live=!!process.stdout.isTTY;content=[];headline="";open(){this.live&&!this.ticker&&(this.ticker=setInterval(()=>this.pulse(),100))}draw(t,n){this.content=t,this.headline=n,this.repaint()}close(){this.ticker&&(clearInterval(this.ticker),this.ticker=void 0),this.live&&this.rows>0&&(process.stdout.write(`\x1B[${this.rows}A\r\x1B[0J`),this.rows=0)}banner(){let t=Ue.default.cyan(z[this.beat%z.length]),n=Math.floor((Date.now()-this.bornAt)/1e3),r=`${this.headline} ${n}s`,o=Math.max(10,(process.stdout.columns??80)-6),i=r.length>o?`${r.slice(0,o-1)}\u2026`:r;return` ${t} ${Ue.default.bold(i)}`}repaint(){if(!this.live)return;let t=[this.banner(),"",...this.content],n=this.rows>0?`\x1B[${this.rows}A`:"";for(let r of t)n+=`\x1B[2K${r}
|
|
37
|
+
`;t.length<this.rows&&(n+="\x1B[0J"),this.rows=t.length,process.stdout.write(n)}pulse(){!this.live||this.rows===0||(this.beat++,process.stdout.write(`\x1B[${this.rows}A\r\x1B[2K${this.banner()}\x1B[${this.rows}B\r`))}};var ge=()=>X(60,120);function oo(e){if(e.type==="tool_call"){let t=e.input_display??e.summary??"";if(K(e))return t?`searching ${q(t,40)}`:"searching\u2026";let{host:n}=Be(t);return n?`fetching ${n}`:"fetching\u2026"}return e.type==="text"&&e.kind==="reasoning"?"deciding next step\u2026":e.type==="text"?"writing the answer\u2026":"working\u2026"}var io=e=>e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e);function so(e){return e<.01?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function ao(e,t){let n=e.outcome==="success",r=[];return e.num_turns!=null&&r.push(`${e.num_turns} turns`),e.duration_ms!=null&&r.push(`${(e.duration_ms/1e3).toFixed(1)}s`),t?.totalTokens!=null&&r.push(`${io(t.totalTokens)} tokens`),t?.costUsd!=null&&r.push(so(t.costUsd)),["",` ${v.default.dim("\u2500".repeat(Math.min(ge()-4,52)))}`,` ${n?v.default.green("\u2713"):v.default.red("\u2717")} ${v.default.bold(n?"completed":e.outcome)}${r.length?` ${v.default.dim(r.join(" \xB7 "))}`:""}`]}function co(e,t=22){let n=Math.min(100,Math.max(0,e)),r=Math.round(n/100*t);return(n>=70?v.default.green:n>=50?v.default.yellow:v.default.red)("\u2588".repeat(r))+v.default.dim("\u2591".repeat(t-r))}function lo(e){return e==="high"?v.default.red("\u25CF high "):e==="medium"?v.default.yellow("\u25CF medium"):e==="low"?v.default.dim("\u25CF low "):v.default.dim("\u25CF ")}function uo(e){let t=[""];if(e.visibility_score!=null){let n=e.visibility_score,r=n>=70?v.default.green:n>=50?v.default.yellow:v.default.red,o=e.intent_satisfied?v.default.green("\u2713 intent satisfied"):v.default.yellow("\u2717 intent not satisfied");t.push(` ${v.default.bold("Visibility")} ${co(n)} ${r(v.default.bold(`${n}/100`))} ${o}`)}if(e.summary){t.push("");for(let n of O(e.summary,ge()-4))t.push(` ${v.default.dim(n)}`)}if(e.friction_points?.length){t.push("",` ${v.default.bold("Friction")}`);for(let n of e.friction_points){let[r,...o]=O(n,ge()-6);t.push(` ${v.default.yellow("\xB7")} ${r}`);for(let i of o)t.push(` ${i}`)}}if(e.recommendations?.length){t.push("",` ${v.default.bold("Recommendations")}`);for(let n of e.recommendations){t.push(` ${lo(n.priority)} ${v.default.bold(n.title)}`);for(let r of O(n.detail,ge()-8))t.push(` ${v.default.dim(r)}`)}}return t.push(""),t}function po(e){let t=e.insight??{};return JSON.stringify({runId:e.runId,intent:e.intent,domain:e.domain,harness:e.harness,model:e.result?.effective_model??e.result?.model,outcome:e.result?.outcome,durationMs:e.result?.duration_ms,numTurns:e.result?.num_turns,totalTokens:e.usage?.totalTokens,inputTokens:e.usage?.inputTokens,outputTokens:e.usage?.outputTokens,costUsd:e.usage?.costUsd,visibilityScore:t.visibility_score,intentSatisfied:t.intent_satisfied,taskSatisfied:t.task_satisfied,summary:t.summary,keyObservations:t.key_observations,frictionPoints:t.friction_points,recommendations:t.recommendations,journeyLayers:t.journey_layers,intentCategory:t.intent_category,steps:e.trajectory},null,2)}async function jt(e){let t={intent:e.intent,domain:e.domain,harness:e.harness,model:e.model};if(e.json)try{let a=await Ne(t);return process.stdout.write(`${po(a)}
|
|
38
|
+
`),a.result?.outcome==="success"?0:1}catch(a){return console.error(`Journey failed: ${a instanceof Error?a.message:String(a)}`),2}let n=new me,r=[],o=!1,i=()=>[` ${Ot(r)}`,"",...Lt(It(r,e.intent,o)).map(a=>` ${a}`)];console.log(),console.log(` ${v.default.cyan("\u25B6")} ${e.domain?v.default.bold(e.domain):v.default.dim("(no domain)")} ${v.default.dim("\xB7")} ${v.default.dim(e.harness)}`),console.log(),n.open(),n.draw(i(),"waking the agent");try{let a=await Ne(t,{snapshot:s=>{r=s;let c=s[s.length-1];n.draw(i(),c?oo(c):"working")},finished:()=>{o=!0,n.draw(i(),"scoring the journey")}});n.close(),o=!0,a.trajectory.length&&(r=a.trajectory);for(let s of i())console.log(s);if(a.result)for(let s of ao(a.result,a.usage))console.log(s);if(a.insight)for(let s of uo(a.insight))console.log(s);else a.result&&(console.log(v.default.dim(" (insight not available for this run)")),console.log());return a.result?.outcome==="success"?0:1}catch(a){return n.close(),console.error(`Journey failed: ${a instanceof Error?a.message:String(a)}`),2}}var he=require("fs"),Fe=require("path"),Q=B(W(),1);var Dt=require("crypto"),mo="https://ora.ai",L=class extends Error{};function Bt(e){return(e??process.env.ORA_API_URL??mo).replace(/\/+$/,"")}async function Je(e){let t=Bt(e),n;try{n=await fetch(`${t}/.well-known/agent-skills/index.json`,{headers:{accept:"application/json"},signal:AbortSignal.timeout(15e3)})}catch(o){throw new L(`could not reach the skill registry at ${t}: ${o instanceof Error?o.message:String(o)}`)}if(!n.ok)throw new L(`skill registry answered HTTP ${n.status}`);let r=await n.json();if(!Array.isArray(r.skills))throw new L("skill registry index has no skills[]");return r.skills}function Wt(e){return`sha256:${(0,Dt.createHash)("sha256").update(e).digest("hex")}`}async function Ut(e,t){let n=Bt(t),r=await Je(n),o=r.find(c=>c.name===e);if(!o){let c=r.map(l=>l.name).join(", ");throw new L(`unknown skill ${JSON.stringify(e)} - the registry has: ${c}`)}let i=o.url.startsWith("http")?o.url:`${n}${o.url}`,a;try{a=await fetch(i,{signal:AbortSignal.timeout(15e3)})}catch(c){throw new L(`could not fetch ${i}: ${c instanceof Error?c.message:String(c)}`)}if(!a.ok)throw new L(`skill fetch answered HTTP ${a.status} for ${i}`);let s=new Uint8Array(await a.arrayBuffer());if(o.digest&&Wt(s)!==o.digest)throw new L(`digest mismatch for ${e}: index says ${o.digest}, served bytes hash to ${Wt(s)} - refusing to use them`);return{entry:o,bytes:s}}var go=".claude/skills";function ho(e,t,n){let r=[],o="";for(let i of e.split(/\s+/))o&&`${o} ${i}`.length>t?(r.push(n+o),o=i):o=o?`${o} ${i}`:i;return o&&r.push(n+o),r}async function Jt(e){try{if(!e.name){let r=await Je();if(e.json)return process.stdout.write(`${JSON.stringify(r,null,2)}
|
|
39
|
+
`),C.OK;console.log("");for(let o of r){let i=o.digest?Q.default.dim(` ${o.digest.slice(0,19)}\u2026`):"";if(console.log(` ${Q.default.bold(o.name)}${i}`),o.description)for(let a of ho(o.description,76," "))console.log(Q.default.dim(a));console.log("")}return console.log(Q.default.dim(" Install one with: ax skill <name> --install")),console.log(""),C.OK}let{entry:t,bytes:n}=await Ut(e.name);if(e.install){let r=(0,Fe.join)(e.dir??go,t.name);(0,he.mkdirSync)(r,{recursive:!0});let o=(0,Fe.join)(r,"SKILL.md");return(0,he.writeFileSync)(o,n),console.log(`Installed ${t.name} to ${o}`),t.digest&&console.log(Q.default.dim(`verified ${t.digest}`)),C.OK}return process.stdout.write(n),C.OK}catch(t){let n=t instanceof Error?t.message:String(t);return console.error(`Skill command failed: ${n}`),t instanceof L&&n.includes("unknown skill")?C.USAGE:C.API}}var x=class extends Error{constructor(t,n){super(t,n),this.name="CdpError"}},Ft=1e4,Ht=5e3,Ge=class e{socket;nextId=1;pending=new Map;handlers=new Map;closed=!1;closeReason=null;constructor(t){this.socket=t,t.addEventListener("message",n=>{this.dispatch(String(n.data))}),t.addEventListener("close",()=>{this.fail("the browser closed the DevTools connection")}),t.addEventListener("error",()=>{this.fail("the DevTools connection errored")})}static async open(t){let n=new WebSocket(t);return await new Promise((r,o)=>{let i=setTimeout(()=>{o(new x(`timed out connecting to ${t}`))},Ht);n.addEventListener("open",()=>{clearTimeout(i),r()},{once:!0}),n.addEventListener("error",()=>{clearTimeout(i),o(new x(`could not connect to ${t}`))},{once:!0})}),new e(n)}dispatch(t){let n;try{n=JSON.parse(t)}catch{return}let r=n.id;if(typeof r=="number"){let s=this.pending.get(r);if(!s)return;this.pending.delete(r),clearTimeout(s.timer);let c=n.error;c?s.reject(new x(c.message??"CDP call failed")):s.resolve(n.result??{});return}let o=n.method;if(typeof o!="string")return;let i=typeof n.sessionId=="string"?n.sessionId:"",a=n.params??{};for(let s of this.handlers.get(`${i}\0${o}`)??[])try{s(a)}catch{}}fail(t){if(!this.closed){this.closed=!0,this.closeReason=t;for(let[,n]of this.pending)clearTimeout(n.timer),n.reject(new x(t));this.pending.clear()}}send(t,n={},r={}){if(this.closed)return Promise.reject(new x(this.closeReason??"the connection is closed"));let o=this.nextId++,i=r.timeoutMs??Ft;return new Promise((a,s)=>{let c=setTimeout(()=>{this.pending.delete(o),s(new x(`${t} timed out after ${i}ms`))},i);this.pending.set(o,{resolve:a,reject:s,timer:c});let l={id:o,method:t,params:n};r.sessionId&&(l.sessionId=r.sessionId);try{this.socket.send(JSON.stringify(l))}catch(u){this.pending.delete(o),clearTimeout(c),s(new x(`could not send ${t}`,{cause:u}))}})}on(t,n,r){let o=`${t}\0${n}`,i=this.handlers.get(o)??new Set;return i.add(r),this.handlers.set(o,i),()=>{i.delete(r)}}close(){this.closed=!0;try{this.socket.close()}catch{}}};async function Ke(e,t=Ht){if(e.startsWith("ws://")||e.startsWith("wss://"))return{webSocketDebuggerUrl:e,product:""};let n=e.startsWith("http://")||e.startsWith("https://")?e.replace(/\/+$/,""):`http://${e.replace(/\/+$/,"")}`,r;try{r=await fetch(`${n}/json/version`,{signal:AbortSignal.timeout(t)})}catch(i){throw new x(`no debuggable Chrome answered at ${n}`,{cause:i})}if(!r.ok)throw new x(`${n}/json/version returned HTTP ${r.status}`);let o=await r.json().catch(()=>null);if(!o?.webSocketDebuggerUrl)throw new x(`${n}/json/version carried no webSocketDebuggerUrl`);return{webSocketDebuggerUrl:o.webSocketDebuggerUrl,product:o.Browser??""}}var fe=class e{connection;product;constructor(t,n){this.connection=t,this.product=n}static async connect(t){let n=await Ge.open(t.webSocketDebuggerUrl),r=t.product;if(!r){let o=await n.send("Browser.getVersion").catch(()=>({}));r=typeof o.product=="string"?o.product:""}return new e(n,r.replace(/^(?:Headless)?Chrome\//i,""))}async newContext(t){let{browserContextId:n}=await this.connection.send("Target.createBrowserContext",{disposeOnDetach:!0}),{targetId:r}=await this.connection.send("Target.createTarget",{url:"about:blank",browserContextId:n}),{sessionId:o}=await this.connection.send("Target.attachToTarget",{targetId:r,flatten:!0}),i=new qe(this.connection,o,n,t.entryUrl);return await i.prepare(t.initScripts??[],t.viewport),i}close(){this.connection.close()}},fo=8,yo=1024*1024,bo=new Set(["Image","Media","Font"]),qe=class{connection;sessionId;browserContextId;entryHost;currentUrl="about:blank";viewport=null;domContentFired=!1;loadFired=!1;documentResponses=new Map;scripts=[];scriptsStarted=0;pendingScriptRequests=new Map;constructor(t,n,r,o){this.connection=t,this.sessionId=n,this.browserContextId=r,this.entryHost=He(o)}async prepare(t,n){await this.send("Page.enable"),await this.send("Runtime.enable"),await this.send("Network.enable"),await this.send("Fetch.enable",{patterns:[{urlPattern:"*"}]}),this.connection.on(this.sessionId,"Fetch.requestPaused",r=>{this.onRequestPaused(r)}),n&&(this.viewport=n,await this.send("Emulation.setDeviceMetricsOverride",{width:n.width,height:n.height,deviceScaleFactor:1,mobile:!1})),this.connection.on(this.sessionId,"Page.domContentEventFired",()=>{this.domContentFired=!0}),this.connection.on(this.sessionId,"Page.loadEventFired",()=>{this.loadFired=!0}),this.connection.on(this.sessionId,"Page.frameNavigated",r=>{let o=r.frame;!o||o.parentId||typeof o.url=="string"&&(this.currentUrl=o.url)}),this.connection.on(this.sessionId,"Network.responseReceived",r=>{this.onResponse(r)}),this.connection.on(this.sessionId,"Network.loadingFinished",r=>{this.onLoadingFinished(r)});for(let r of t)await this.send("Page.addScriptToEvaluateOnNewDocument",{source:r})}send(t,n={},r){return this.connection.send(t,n,{sessionId:this.sessionId,timeoutMs:r})}onRequestPaused(t){let n=t.requestId;if(typeof n!="string")return;(bo.has(String(t.resourceType))?this.send("Fetch.failRequest",{requestId:n,errorReason:"BlockedByClient"}):this.send("Fetch.continueRequest",{requestId:n})).catch(()=>{})}onResponse(t){let n=t.type,r=t.requestId,o=t.response;if(typeof r!="string"||!o)return;if(n==="Document"){let s=typeof t.frameId=="string"?t.frameId:"";this.documentResponses.set(s,{status:typeof o.status=="number"?o.status:0,headers:wo(o.headers??{})});return}if(n!=="Script"||this.scriptsStarted>=fo)return;let i=typeof o.url=="string"?o.url:"",a=He(i);a&&(a!==this.entryHost&&a!==He(this.currentUrl)||(this.scriptsStarted++,this.pendingScriptRequests.set(r,i)))}onLoadingFinished(t){let n=t.requestId;if(typeof n!="string")return;let r=this.pendingScriptRequests.get(n);r!==void 0&&(this.pendingScriptRequests.delete(n),this.send("Network.getResponseBody",{requestId:n}).then(o=>{let i=typeof o.body=="string"?o.body:"",a=o.base64Encoded===!0?Buffer.from(i,"base64").toString("utf8"):i;this.scripts.push({url:r,body:a.slice(0,yo)})}).catch(()=>{}))}async goto(t,n){this.domContentFired=!1,this.loadFired=!1;let r=await this.send("Page.navigate",{url:t},n),o=r.errorText;if(typeof o=="string"&&o.length>0)throw new x(`navigating to ${t} failed: ${o}`);let i=typeof r.frameId=="string"?r.frameId:"";return await this.waitFor(()=>this.domContentFired,n,`${t} never reached DOMContentLoaded`),this.currentUrl=await this.readLocation(t),this.documentResponses.get(i)??this.documentResponses.get("")??null}async waitForLoad(t){await this.waitFor(()=>this.loadFired,t,"load").catch(()=>{})}async waitFor(t,n,r){let o=Date.now()+n;for(;!t();){if(Date.now()>=o)throw new x(`timed out waiting for ${r}`);await new Promise(i=>setTimeout(i,25))}}async readLocation(t){let n=await this.evaluate("location.href",2e3).catch(()=>null);return typeof n=="string"&&n.length>0?n:t}async evaluate(t,n=Ft){let r=await this.send("Runtime.evaluate",{expression:t,awaitPromise:!0,returnByValue:!0},n),o=r.exceptionDetails;if(o)throw new x(o.exception?.description??o.text??"evaluation threw");return r.result?.value}async content(){return await this.evaluate("document.documentElement ? document.documentElement.outerHTML : ''").catch(()=>"")??""}async inlineScripts(){return await this.evaluate('Array.from(document.querySelectorAll("script:not([src])")).map(function (s) { return s.textContent || ""; }).join("\\n")').catch(()=>"")??""}url(){return this.currentUrl}collectedScripts(){return this.scripts.slice()}viewportSize(){return this.viewport}async screenshot(t,n){try{let o=(await this.send("Page.captureScreenshot",{format:"jpeg",quality:t,captureBeyondViewport:!1},n)).data;return typeof o!="string"||o.length===0?null:Buffer.from(o,"base64")}catch{return null}}async close(){await this.connection.send("Target.disposeBrowserContext",{browserContextId:this.browserContextId}).catch(()=>{})}};function wo(e){let t={};for(let[n,r]of Object.entries(e)){let o=n.toLowerCase(),i=r.split(`
|
|
40
|
+
`).map(a=>a.trim()).filter(a=>a.length>0).join(", ");t[o]=t[o]===void 0?i:`${t[o]}, ${i}`}return t}function He(e){try{return new URL(e).host}catch{return""}}var vo=new Set([2,3]),So=8192,xo=864e10;function Ao(e){if(typeof e!="string")return null;let t=e.trim();if(t.length===0||t.length>So)return null;let n;try{n=Buffer.from(t,"base64")}catch{return null}if(n.length<=69||!vo.has(n[0])||n.readUInt32BE(65)!==n.length-69)return null;let o;try{o=JSON.parse(n.subarray(69).toString("utf8"))}catch{return null}if(!o||typeof o!="object")return null;let i=o,a=i.origin,s=i.feature,c=i.expiry;return typeof a!="string"||typeof s!="string"||typeof c!="number"||!Number.isFinite(c)||c<0||c>xo?null:{origin:a,feature:s,expiry:c,isSubdomain:i.isSubdomain===!0,isThirdParty:i.isThirdParty===!0}}function ko(e){return e.toLowerCase().replace(/[^a-z]/g,"").includes("modelcontext")}function $o(e,t,n){let r,o;try{r=new URL(e),o=new URL(t)}catch{return!1}if(r.protocol!==o.protocol)return!1;let i=r.hostname.toLowerCase(),a=o.hostname.toLowerCase();return i===a?!0:n&&a.endsWith(`.${i}`)}function Gt(e,t,n){let r=e.map(i=>i.trim()).filter(i=>i.length>0);if(r.length===0)return null;let o=null;for(let i of r){let a=Ao(i);if(!a)continue;let s=ko(a.feature),c=a.expiry*1e3>n.getTime(),l=$o(a.origin,t,a.isSubdomain),u=s&&c&&l,p=u?3:s?2:1;(!o||p>o.rank)&&(o={parsed:a,valid:u,rank:p})}return o?{present:!0,valid:o.valid,origin:o.parsed.origin,feature:o.parsed.feature,expiresAt:new Date(o.parsed.expiry*1e3).toISOString()}:{present:!0,valid:!1}}function qt(e){return e?e.split(",").map(t=>t.trim()).filter(t=>t.length>0):[]}var Ve="capture-incomplete:";function Ro(e){return e.imperative!==null||e.polyfillPackages.length>0}function Kt(e){return e.blocked?"blocked":e.loadError?"load-error":e.toolCount>0?e.nativeApi||e.originTrialValid||e.declarativeToolCount>0?"active":"testing-only":e.nativeApi?"api-empty":e.shimTakenOver||Ro(e.staticSignals)?"declared-inactive":"absent"}function Vt(e,t){switch(e){case"blocked":return"waf-blocked";case"load-error":return"unreachable";case"active":case"testing-only":{let n=t.filter(r=>r.via==="imperative");return n.length>0&&n.every(r=>!r.hasExecute)?"stub-only":"ok"}case"api-empty":case"declared-inactive":case"absent":return"no-tools";default:return e}}var Yt={"shared-experience":30,"task-completion":25,"tool-quality":25,trust:20},Ye={"page-experience":{title:"Page experience",category:"shared-experience",weight:20,docSlug:"page-experience"},"human-parity":{title:"Human parity",category:"shared-experience",weight:10,docSlug:"human-parity"},"tool-selection":{title:"Tool selection",category:"task-completion",weight:15,docSlug:"tool-selection"},"coverage-vs-site-type":{title:"Coverage vs. site type",category:"task-completion",weight:10,docSlug:"coverage-vs-site-type"},"schema-validity":{title:"Schema validity",category:"tool-quality",weight:4,docSlug:"schema-validity"},"schema-quality":{title:"Schema quality",category:"tool-quality",weight:4,docSlug:"schema-quality"},"description-quality":{title:"Description quality",category:"tool-quality",weight:5,docSlug:"description-quality"},"stub-detection":{title:"Stub detection",category:"tool-quality",weight:4,docSlug:"stub-detection"},"canonical-entry-point":{title:"Canonical entry point",category:"tool-quality",weight:3,docSlug:"canonical-entry-point"},"naming-quality":{title:"Naming quality",category:"tool-quality",weight:2,docSlug:"naming-quality"},"registration-errors":{title:"Registration errors",category:"tool-quality",weight:2,docSlug:"registration-errors"},"registration-timing":{title:"Registration timing",category:"tool-quality",weight:1,docSlug:"registration-timing"},"annotations-present":{title:"Annotations present",category:"trust",weight:6,docSlug:"annotations-present"},"annotation-mismatch":{title:"Annotation mismatch",category:"trust",weight:6,docSlug:"annotation-mismatch"},"injection-surface":{title:"Injection surface",category:"trust",weight:4,docSlug:"injection-surface"},"untrusted-content-hint":{title:"Untrusted content hint",category:"trust",weight:4,docSlug:"untrusted-content-hint"}},V="1";function Co(e,t,n){return!!(t["cf-mitigated"]==="challenge"||e===403&&n.includes("cf-browser-verification")||e===503&&n.includes("challenge-platform"))}function Xt(e,t,n){return!!(Co(e,t,n)||t["x-vercel-mitigated"]==="challenge"||"x-vercel-challenge-token"in t||n.includes("Vercel Security Checkpoint")||n.includes("vercel-challenge")||e===429&&n.length<2e3||e===403&&(n.includes("Access Denied")||n.includes("Bot Protection")))}var Eo=100,Qt=4096,_o=32768,To=50,Po=200,zt="__oraWebmcpCapture",Zt=`(function () {
|
|
41
|
+
"use strict";
|
|
42
|
+
try {
|
|
43
|
+
var W = typeof globalThis !== "undefined" ? globalThis : window;
|
|
44
|
+
if (W.${zt}) return;
|
|
45
|
+
|
|
46
|
+
var SHIM_VERSION = ${JSON.stringify(V)};
|
|
47
|
+
var MAX_TOOLS = ${Eo};
|
|
48
|
+
var MAX_DESCRIPTION_CHARS = ${Qt};
|
|
49
|
+
var MAX_SCHEMA_CHARS = ${_o};
|
|
50
|
+
var MAX_ERRORS = ${To};
|
|
51
|
+
// Internal bound only: a page looping on addEventListener must not grow
|
|
52
|
+
// the shim's retained set without limit.
|
|
53
|
+
var MAX_LISTENERS = 50;
|
|
54
|
+
|
|
55
|
+
// Natives are pinned at install time, while they are still pristine: this
|
|
56
|
+
// script runs before any page script, so everything captured here is the
|
|
57
|
+
// real implementation. Resolving them at call time instead would let a page
|
|
58
|
+
// swap performance.now (forging registrationMs, which feeds the
|
|
59
|
+
// registration-timing check), JSON (forging schemas), Array.isArray
|
|
60
|
+
// (steering provideContext), or Object.getOwnPropertyDescriptor (hiding a
|
|
61
|
+
// takeover) after the fact.
|
|
62
|
+
var nativeDefineProperty = Object.defineProperty;
|
|
63
|
+
var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
|
64
|
+
var nativeObjectCreate = Object.create;
|
|
65
|
+
var nativeIsArray = Array.isArray;
|
|
66
|
+
var nativeStringify = JSON.stringify;
|
|
67
|
+
var nativeParse = JSON.parse;
|
|
68
|
+
var nativeString = String;
|
|
69
|
+
var nativeTypeError = TypeError;
|
|
70
|
+
var nativeDateNow = Date.now;
|
|
71
|
+
var nativePromise = typeof Promise === "function" ? Promise : null;
|
|
72
|
+
var nativePerformanceNow = null;
|
|
73
|
+
try {
|
|
74
|
+
if (W.performance && typeof W.performance.now === "function") {
|
|
75
|
+
nativePerformanceNow = W.performance.now.bind(W.performance);
|
|
76
|
+
}
|
|
77
|
+
} catch (e) {
|
|
78
|
+
// A hostile performance getter cannot be pinned; the Date fallback holds.
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var entries = [];
|
|
82
|
+
var byKey = nativeObjectCreate(null);
|
|
83
|
+
var listenersByType = nativeObjectCreate(null);
|
|
84
|
+
var errors = [];
|
|
85
|
+
var provideContextCalls = 0;
|
|
86
|
+
var toolchangeEvents = 0;
|
|
87
|
+
var extraToolCount = 0;
|
|
88
|
+
var nextRegId = 1;
|
|
89
|
+
|
|
90
|
+
function now() {
|
|
91
|
+
if (nativePerformanceNow) return nativePerformanceNow();
|
|
92
|
+
return nativeDateNow();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Never throws, whatever the page put in the value: a description, an
|
|
96
|
+
// error message, or an event type can all carry a throwing toString.
|
|
97
|
+
function safeText(value, fallback) {
|
|
98
|
+
try {
|
|
99
|
+
return nativeString(value);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
return fallback;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function describeError(value) {
|
|
106
|
+
var message;
|
|
107
|
+
try {
|
|
108
|
+
message = value ? value.message : undefined;
|
|
109
|
+
} catch (e) {
|
|
110
|
+
// A thrown object with a throwing message getter.
|
|
111
|
+
message = undefined;
|
|
112
|
+
}
|
|
113
|
+
if (message !== undefined && message !== null) {
|
|
114
|
+
return safeText(message, "unreadable error message");
|
|
115
|
+
}
|
|
116
|
+
return safeText(value, "unreadable error");
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function recordError(message) {
|
|
120
|
+
if (errors.length >= MAX_ERRORS) return;
|
|
121
|
+
errors.push(
|
|
122
|
+
safeText(message, "unstringifiable registration error").slice(0, 500)
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Cycle-safe: tracks the ANCESTOR chain (via the replacer's holder), not
|
|
127
|
+
// every object seen, so a schema that reuses one sub-schema in two places
|
|
128
|
+
// still serializes both copies instead of reporting a false cycle.
|
|
129
|
+
function cycleSafeStringify(value) {
|
|
130
|
+
var stack = [];
|
|
131
|
+
return nativeStringify(value, function (key, val) {
|
|
132
|
+
if (typeof val === "function") return undefined;
|
|
133
|
+
if (val && typeof val === "object") {
|
|
134
|
+
while (stack.length > 0 && stack[stack.length - 1] !== this) stack.pop();
|
|
135
|
+
if (stack.indexOf(val) !== -1) return "[Circular]";
|
|
136
|
+
stack.push(val);
|
|
137
|
+
}
|
|
138
|
+
return val;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function safeCopy(value, maxChars) {
|
|
143
|
+
if (value === undefined || value === null) return null;
|
|
144
|
+
var json;
|
|
145
|
+
try {
|
|
146
|
+
json = cycleSafeStringify(value);
|
|
147
|
+
} catch (e) {
|
|
148
|
+
// Throwing getters, BigInt, or a structure too deep for JSON.stringify.
|
|
149
|
+
return { __unserializable: true };
|
|
150
|
+
}
|
|
151
|
+
if (typeof json !== "string") return null;
|
|
152
|
+
if (json.length > maxChars) return { __truncated: true };
|
|
153
|
+
try {
|
|
154
|
+
return nativeParse(json);
|
|
155
|
+
} catch (e) {
|
|
156
|
+
// Should not happen: nativeParse is the pinned native, and its input is
|
|
157
|
+
// this shim's own output. Kept so a copy failure never breaks a page.
|
|
158
|
+
return { __unserializable: true };
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function readProp(source, key) {
|
|
163
|
+
try {
|
|
164
|
+
return source[key];
|
|
165
|
+
} catch (e) {
|
|
166
|
+
// Property access on a page object can throw from a getter.
|
|
167
|
+
return undefined;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function hasExecute(tool) {
|
|
172
|
+
return (
|
|
173
|
+
typeof readProp(tool, "execute") === "function" ||
|
|
174
|
+
typeof readProp(tool, "callback") === "function"
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function markUnregistered(record, regId) {
|
|
179
|
+
if (!record || record.regId !== regId || record.unregistered) return;
|
|
180
|
+
record.unregistered = true;
|
|
181
|
+
record.unregisteredMs = now();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Registers or refreshes ONE tool. Entries are keyed by source + name, so
|
|
185
|
+
// a re-registration updates in place and keeps its first registrationMs -
|
|
186
|
+
// the timing checks want when the tool first appeared, and a page that
|
|
187
|
+
// re-provides its set on every state change must not exhaust MAX_TOOLS.
|
|
188
|
+
function upsert(tool, source, entryPoint) {
|
|
189
|
+
var name = readProp(tool, "name");
|
|
190
|
+
if (typeof name !== "string" || name.trim() === "") {
|
|
191
|
+
var error = new nativeTypeError(
|
|
192
|
+
"WebMCP registration rejected: tool name must be a non-empty string"
|
|
193
|
+
);
|
|
194
|
+
recordError(error.message);
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// A name collision is a name collision whatever registered it: two live
|
|
199
|
+
// tools called "search" are ambiguous to an agent even when one came
|
|
200
|
+
// from registerTool and the other from provideContext. Both entries are
|
|
201
|
+
// kept; the warning is the evidence.
|
|
202
|
+
for (var d = 0; d < entries.length; d++) {
|
|
203
|
+
if (entries[d].name === name && !entries[d].unregistered) {
|
|
204
|
+
recordError("duplicate tool name registered: " + name);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// A throwing toString must not drop the tool: record the defect and keep
|
|
210
|
+
// the registration, since an unreadable description is exactly what the
|
|
211
|
+
// description-quality check exists to see.
|
|
212
|
+
var description = "";
|
|
213
|
+
var rawDescription = readProp(tool, "description");
|
|
214
|
+
if (rawDescription !== undefined && rawDescription !== null) {
|
|
215
|
+
if (typeof rawDescription === "string") {
|
|
216
|
+
description = rawDescription;
|
|
217
|
+
} else {
|
|
218
|
+
try {
|
|
219
|
+
description = nativeString(rawDescription);
|
|
220
|
+
} catch (e) {
|
|
221
|
+
recordError(
|
|
222
|
+
"tool " + name + " has a description that could not be read as text"
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
var descriptionTruncated = description.length > MAX_DESCRIPTION_CHARS;
|
|
228
|
+
if (descriptionTruncated) description = description.slice(0, MAX_DESCRIPTION_CHARS);
|
|
229
|
+
|
|
230
|
+
var record = byKey[source + ":" + name];
|
|
231
|
+
if (!record) {
|
|
232
|
+
if (entries.length >= MAX_TOOLS) {
|
|
233
|
+
extraToolCount++;
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
record = { name: name, registrationMs: now() };
|
|
237
|
+
entries.push(record);
|
|
238
|
+
byKey[source + ":" + name] = record;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
record.description = description;
|
|
242
|
+
record.descriptionTruncated = descriptionTruncated;
|
|
243
|
+
record.inputSchema = safeCopy(readProp(tool, "inputSchema"), MAX_SCHEMA_CHARS);
|
|
244
|
+
record.annotations = safeCopy(readProp(tool, "annotations"), MAX_SCHEMA_CHARS);
|
|
245
|
+
record.hasExecute = hasExecute(tool);
|
|
246
|
+
record.entryPoint = entryPoint;
|
|
247
|
+
record.source = source;
|
|
248
|
+
record.unregistered = false;
|
|
249
|
+
record.unregisteredMs = null;
|
|
250
|
+
record.regId = nextRegId++;
|
|
251
|
+
return record;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// The spec's unregistration path is the AbortSignal in options; the
|
|
255
|
+
// tool-carried fallback observes pages that put the signal on the tool
|
|
256
|
+
// object instead.
|
|
257
|
+
function resolveSignal(tool, options) {
|
|
258
|
+
var signal = readProp(options, "signal");
|
|
259
|
+
if (!signal) signal = readProp(tool, "signal");
|
|
260
|
+
return signal || null;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// Callers with an already-aborted signal never reach here: registerTool
|
|
264
|
+
// rejects those before any record exists.
|
|
265
|
+
function wireAbort(signal, record, regId) {
|
|
266
|
+
if (!signal || typeof readProp(signal, "addEventListener") !== "function") return;
|
|
267
|
+
try {
|
|
268
|
+
signal.addEventListener("abort", function () {
|
|
269
|
+
markUnregistered(record, regId);
|
|
270
|
+
});
|
|
271
|
+
} catch (e) {
|
|
272
|
+
// A signal-like object that is not a real AbortSignal: capture is
|
|
273
|
+
// best-effort here and must never break the page's registration.
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// The draft's registerTool returns a Promise, and legacy pages hold the
|
|
278
|
+
// return value for its unregister method - so the shim returns a settled
|
|
279
|
+
// promise CARRYING unregister, serving both shapes at once (the agent
|
|
280
|
+
// invoke shim does the same). The internal catch marks the rejected path
|
|
281
|
+
// handled, so a page that ignores the return value produces no unhandled
|
|
282
|
+
// rejection from our shim.
|
|
283
|
+
function registration(settledPromise, unregister) {
|
|
284
|
+
settledPromise.catch(function () {});
|
|
285
|
+
settledPromise.unregister = unregister;
|
|
286
|
+
return settledPromise;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function noop() {}
|
|
290
|
+
|
|
291
|
+
function registerTool(tool, options, entryPoint) {
|
|
292
|
+
var signal = resolveSignal(tool, options);
|
|
293
|
+
if (signal && readProp(signal, "aborted") === true) {
|
|
294
|
+
// Already aborted at register time: the registration never lands, and
|
|
295
|
+
// per the draft the promise rejects with the abort reason.
|
|
296
|
+
var reason = readProp(signal, "reason");
|
|
297
|
+
if (!nativePromise) return { unregister: noop };
|
|
298
|
+
return registration(
|
|
299
|
+
nativePromise.reject(
|
|
300
|
+
reason === undefined
|
|
301
|
+
? new nativeTypeError("registration signal already aborted")
|
|
302
|
+
: reason
|
|
303
|
+
),
|
|
304
|
+
noop
|
|
305
|
+
);
|
|
306
|
+
}
|
|
307
|
+
var record = upsert(tool, "registerTool", entryPoint);
|
|
308
|
+
var regId = record ? record.regId : -1;
|
|
309
|
+
wireAbort(signal, record, regId);
|
|
310
|
+
// A capped registration (record null) still resolves: the page did
|
|
311
|
+
// nothing wrong, the shim just stopped recording past MAX_TOOLS.
|
|
312
|
+
var unregister = record
|
|
313
|
+
? function () { markUnregistered(record, regId); }
|
|
314
|
+
: noop;
|
|
315
|
+
if (!nativePromise) return { unregister: unregister };
|
|
316
|
+
return registration(nativePromise.resolve(undefined), unregister);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function provideContext(context, entryPoint) {
|
|
320
|
+
provideContextCalls++;
|
|
321
|
+
var tools = readProp(context, "tools");
|
|
322
|
+
if (tools === undefined || tools === null) tools = [];
|
|
323
|
+
if (!nativeIsArray(tools)) {
|
|
324
|
+
recordError("provideContext called with a non-array tools value");
|
|
325
|
+
tools = [];
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// Replacement semantics apply to the provideContext-sourced set only:
|
|
329
|
+
// mark it superseded BEFORE the new set lands, so re-providing a tool
|
|
330
|
+
// reactivates its entry instead of reading as a duplicate registration,
|
|
331
|
+
// and registerTool-sourced tools are left alone.
|
|
332
|
+
for (var i = 0; i < entries.length; i++) {
|
|
333
|
+
if (entries[i].source === "provideContext") {
|
|
334
|
+
markUnregistered(entries[i], entries[i].regId);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
for (var j = 0; j < tools.length; j++) {
|
|
339
|
+
var errorsBefore = errors.length;
|
|
340
|
+
try {
|
|
341
|
+
upsert(tools[j], "provideContext", entryPoint);
|
|
342
|
+
} catch (e) {
|
|
343
|
+
// One invalid tool must not drop the rest of the provided set, but
|
|
344
|
+
// it must never vanish silently either: upsert records the reason
|
|
345
|
+
// for the failures it raises itself, and anything else that escaped
|
|
346
|
+
// (a throwing getter on the tool object) is recorded here.
|
|
347
|
+
if (errors.length === errorsBefore) {
|
|
348
|
+
recordError(
|
|
349
|
+
"provideContext tool at index " + j + " failed to register: " +
|
|
350
|
+
describeError(e)
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return nativePromise ? nativePromise.resolve() : undefined;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function addEventListener(type, listener) {
|
|
359
|
+
if (typeof listener !== "function") return;
|
|
360
|
+
var key = safeText(type, "");
|
|
361
|
+
var list = listenersByType[key];
|
|
362
|
+
if (!list) {
|
|
363
|
+
list = [];
|
|
364
|
+
listenersByType[key] = list;
|
|
365
|
+
}
|
|
366
|
+
if (list.length < MAX_LISTENERS) list.push(listener);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function removeEventListener(type, listener) {
|
|
370
|
+
var list = listenersByType[safeText(type, "")];
|
|
371
|
+
if (!list) return;
|
|
372
|
+
var index = list.indexOf(listener);
|
|
373
|
+
if (index !== -1) list.splice(index, 1);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function dispatchEvent(event) {
|
|
377
|
+
var rawType = readProp(event, "type");
|
|
378
|
+
var type = safeText(
|
|
379
|
+
rawType === undefined || rawType === null ? event : rawType,
|
|
380
|
+
""
|
|
381
|
+
);
|
|
382
|
+
if (type === "toolchange") toolchangeEvents++;
|
|
383
|
+
|
|
384
|
+
var list = listenersByType[type];
|
|
385
|
+
if (list) {
|
|
386
|
+
for (var i = 0; i < list.length; i++) {
|
|
387
|
+
try {
|
|
388
|
+
list[i](event);
|
|
389
|
+
} catch (e) {
|
|
390
|
+
recordError("listener for " + type + " threw: " + describeError(e));
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
return true;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Two distinct delegate objects over one registry, so we can tell which
|
|
398
|
+
// global the page reached for.
|
|
399
|
+
function createDelegate(entryPoint) {
|
|
400
|
+
return {
|
|
401
|
+
registerTool: function (tool, options) {
|
|
402
|
+
return registerTool(tool, options, entryPoint);
|
|
403
|
+
},
|
|
404
|
+
provideContext: function (context) {
|
|
405
|
+
return provideContext(context, entryPoint);
|
|
406
|
+
},
|
|
407
|
+
addEventListener: addEventListener,
|
|
408
|
+
removeEventListener: removeEventListener,
|
|
409
|
+
dispatchEvent: dispatchEvent
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// Every entry point we installed on, so snapshot() can prove the shim is
|
|
414
|
+
// still the one answering. The getter is null when the install itself failed.
|
|
415
|
+
var installs = [];
|
|
416
|
+
|
|
417
|
+
function install(target, delegate, label) {
|
|
418
|
+
if (!target) return;
|
|
419
|
+
var getter = function () {
|
|
420
|
+
return delegate;
|
|
421
|
+
};
|
|
422
|
+
try {
|
|
423
|
+
nativeDefineProperty(target, "modelContext", {
|
|
424
|
+
// Deliberately configurable: making it non-configurable would give a
|
|
425
|
+
// legitimate polyfill a page-visible TypeError. A page CAN therefore
|
|
426
|
+
// redefine the property and take the entry point away from us, which
|
|
427
|
+
// is what detectTakeovers reports.
|
|
428
|
+
configurable: true,
|
|
429
|
+
enumerable: true,
|
|
430
|
+
get: getter,
|
|
431
|
+
set: function () {
|
|
432
|
+
// A page polyfill assigning its own implementation over the shim
|
|
433
|
+
// would blind the capture and produce a false "absent" verdict.
|
|
434
|
+
// The assignment is accepted silently and ignored: feature
|
|
435
|
+
// detection still passes and registrations through the global
|
|
436
|
+
// still land here.
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
installs.push({ target: target, getter: getter, label: label });
|
|
440
|
+
} catch (e) {
|
|
441
|
+
recordError("could not install shim on " + label + ": " + describeError(e));
|
|
442
|
+
installs.push({ target: target, getter: null, label: label });
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// Rechecked at snapshot time, not at install time: a page script can
|
|
447
|
+
// redefine the property at any point after we run, and an empty tools list
|
|
448
|
+
// must not be reported as absence when that happened.
|
|
449
|
+
function detectTakeovers() {
|
|
450
|
+
var taken = [];
|
|
451
|
+
for (var i = 0; i < installs.length; i++) {
|
|
452
|
+
var descriptor;
|
|
453
|
+
try {
|
|
454
|
+
descriptor = nativeGetOwnPropertyDescriptor(
|
|
455
|
+
installs[i].target,
|
|
456
|
+
"modelContext"
|
|
457
|
+
);
|
|
458
|
+
} catch (e) {
|
|
459
|
+
// An exotic target that refuses introspection counts as taken over.
|
|
460
|
+
descriptor = undefined;
|
|
461
|
+
}
|
|
462
|
+
if (!descriptor || descriptor.get !== installs[i].getter) {
|
|
463
|
+
taken.push(installs[i].label);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return taken;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
install(W.navigator, createDelegate("navigator"), "navigator");
|
|
470
|
+
install(W.document, createDelegate("document"), "document");
|
|
471
|
+
|
|
472
|
+
function snapshot() {
|
|
473
|
+
var tools = [];
|
|
474
|
+
for (var i = 0; i < entries.length; i++) {
|
|
475
|
+
var e = entries[i];
|
|
476
|
+
tools.push({
|
|
477
|
+
name: e.name,
|
|
478
|
+
description: e.description,
|
|
479
|
+
descriptionTruncated: e.descriptionTruncated,
|
|
480
|
+
inputSchema: e.inputSchema,
|
|
481
|
+
annotations: e.annotations,
|
|
482
|
+
hasExecute: e.hasExecute,
|
|
483
|
+
entryPoint: e.entryPoint,
|
|
484
|
+
source: e.source,
|
|
485
|
+
registrationMs: e.registrationMs,
|
|
486
|
+
unregistered: e.unregistered,
|
|
487
|
+
unregisteredMs: e.unregisteredMs
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
return {
|
|
491
|
+
shimVersion: SHIM_VERSION,
|
|
492
|
+
tools: tools,
|
|
493
|
+
provideContextCalls: provideContextCalls,
|
|
494
|
+
toolchangeEvents: toolchangeEvents,
|
|
495
|
+
registrationErrors: errors.slice(),
|
|
496
|
+
extraToolCount: extraToolCount,
|
|
497
|
+
takenOver: detectTakeovers()
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
// Non-writable and non-configurable: the capture payload is the audit's
|
|
502
|
+
// evidence, so a page must not be able to replace snapshot() and report
|
|
503
|
+
// whatever tools it wishes it had.
|
|
504
|
+
nativeDefineProperty(W, ${JSON.stringify(zt)}, {
|
|
505
|
+
value: {
|
|
506
|
+
shimVersion: SHIM_VERSION,
|
|
507
|
+
installedAt: now(),
|
|
508
|
+
snapshot: snapshot
|
|
509
|
+
},
|
|
510
|
+
writable: false,
|
|
511
|
+
configurable: false,
|
|
512
|
+
enumerable: false
|
|
513
|
+
});
|
|
514
|
+
} catch (installError) {
|
|
515
|
+
try {
|
|
516
|
+
console.warn("[ora-webmcp-shim] install failed", installError);
|
|
517
|
+
} catch (loggingError) {
|
|
518
|
+
// Nothing left to report to; never let the shim break the page.
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
})();`,en=`(function () {
|
|
522
|
+
var MAX_FORMS = ${Po};
|
|
523
|
+
var MAX_DESCRIPTION_CHARS = ${Qt};
|
|
524
|
+
var forms = [];
|
|
525
|
+
var nodes = document.querySelectorAll("form[toolname], [toolname]");
|
|
526
|
+
for (var i = 0; i < nodes.length && forms.length < MAX_FORMS; i++) {
|
|
527
|
+
var node = nodes[i];
|
|
528
|
+
var isForm = node.tagName === "FORM";
|
|
529
|
+
var description = node.getAttribute("tooldescription") || "";
|
|
530
|
+
forms.push({
|
|
531
|
+
toolName: node.getAttribute("toolname") || "",
|
|
532
|
+
toolDescription: description.slice(0, MAX_DESCRIPTION_CHARS),
|
|
533
|
+
action: isForm ? node.getAttribute("action") || "" : "",
|
|
534
|
+
method: isForm ? (node.getAttribute("method") || "get").toLowerCase() : "",
|
|
535
|
+
fieldCount: node.querySelectorAll("input, select, textarea").length
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
return { forms: forms };
|
|
539
|
+
})()`;var nn=["@mcp-b/global","@mcp-b/react-webmcp","usewebmcp"];function Io(e){let t=e.toLowerCase(),n=/document\.modelcontext/.test(t),r=/navigator\.modelcontext/.test(t),o=/modelcontext\??\.(registertool|providecontext)/.test(t),i=nn.find(s=>t.includes(s));return!n&&!r&&!o&&!i?null:{marker:n?"document.modelContext":r?"navigator.modelContext":o?"modelContext.registerTool/provideContext":`${i} package`,deprecatedAliasOnly:r&&!n}}var Oo=["webmcp","web model context protocol"];function tn(e){let t=e.toLowerCase();return Oo.some(n=>t.includes(n))}function rn(e,t,n){let r=[t,...n.map(s=>s.body)],o=Io(r.join(`
|
|
540
|
+
`)),i=new Set;for(let s of r){let c=s.toLowerCase();for(let l of nn)c.includes(l)&&i.add(l)}let a=tn(e)||r.some(tn);return{imperative:o,polyfillPackages:[...i],keywordMention:a}}var an=15e3,Mo=3e4,No=2e3,Lo=250,jo={fast:12e3,deep:2e4},Wo=2*1024*1024,cn=512,Do=512,Bo=60,Uo=15e5,ln={width:1280,height:720},on={imperative:null,polyfillPackages:[],keywordMention:!1},Jo=`(function () {
|
|
541
|
+
var tokens = [];
|
|
542
|
+
try {
|
|
543
|
+
var metas = document.querySelectorAll('meta[http-equiv="origin-trial" i]');
|
|
544
|
+
for (var i = 0; i < metas.length && tokens.length < 20; i++) {
|
|
545
|
+
var content = metas[i].getAttribute("content");
|
|
546
|
+
if (content) tokens.push(content);
|
|
547
|
+
}
|
|
548
|
+
} catch (e) {
|
|
549
|
+
// A document without a queryable DOM still answers the native probe.
|
|
550
|
+
}
|
|
551
|
+
var nativeApi = false;
|
|
552
|
+
try {
|
|
553
|
+
nativeApi = ("modelContext" in navigator) || ("modelContext" in document);
|
|
554
|
+
} catch (e) {
|
|
555
|
+
// A hostile getter on either global; absence is the honest answer.
|
|
556
|
+
}
|
|
557
|
+
return { nativeApi: nativeApi, metaTokens: tokens };
|
|
558
|
+
})()`,un=`(function () {
|
|
559
|
+
try {
|
|
560
|
+
var g = window.__oraWebmcpCapture;
|
|
561
|
+
return g ? g.snapshot() : null;
|
|
562
|
+
} catch (e) {
|
|
563
|
+
return null;
|
|
564
|
+
}
|
|
565
|
+
})()`,Fo=`(function () {
|
|
566
|
+
try {
|
|
567
|
+
var g = window.__oraWebmcpCapture;
|
|
568
|
+
if (!g) return "none";
|
|
569
|
+
var s = g.snapshot();
|
|
570
|
+
return s.tools.length + ":" + s.provideContextCalls + ":" + s.toolchangeEvents + ":" +
|
|
571
|
+
s.registrationErrors.length + ":" + s.extraToolCount + ":" + s.takenOver.length;
|
|
572
|
+
} catch (e) {
|
|
573
|
+
return "error";
|
|
574
|
+
}
|
|
575
|
+
})()`;function dn(e,t){return e.filter(n=>!n.unregistered).map(n=>({name:n.name.slice(0,cn),description:n.description,via:"imperative",entryPoint:n.source==="provideContext"?"provideContext":n.entryPoint,pageUrl:t,inputSchema:n.inputSchema,annotations:Go(n.annotations),hasExecute:n.hasExecute,registrationMs:n.registrationMs}))}function Ho(e,t){return e.map(n=>({name:n.toolName.slice(0,cn),description:n.toolDescription,via:"declarative",entryPoint:"form",pageUrl:t,inputSchema:null,annotations:{},hasExecute:!0,registrationMs:null}))}function Go(e){if(!e||typeof e!="object"||Array.isArray(e))return{};let t=e,n={};for(let r of["readOnlyHint","destructiveHint","idempotentHint","openWorldHint","untrustedContentHint"])typeof t[r]=="boolean"&&(n[r]=t[r]);return typeof t.title=="string"&&(n.title=t.title.slice(0,Do)),n}function qo(e){if(!e)return[];let t=[...e.registrationErrors];return e.takenOver.length>0&&t.push(`${Ve} the page replaced modelContext on ${e.takenOver.join(", ")}, so imperative tools may be under-reported`),e.extraToolCount>0&&t.push(`${Ve} the capture's tool cap was reached and ${e.extraToolCount} further registration attempts were not stored`),t}function Ko(e){if(!e)return null;for(let t of e.split(",")){let n=/^\s*([a-z0-9-]+)\s*=\s*(.*)$/i.exec(t);if(!n||!n[1].toLowerCase().replace(/-/g,"").includes("modelcontext"))continue;let r=n[2].trim().replace(/^\(|\)$/g,"").trim();return r==="*"?!0:r===""||r.toLowerCase()==="self"?!1:r.split(/\s+/).some(o=>o.toLowerCase()!=="self"&&o.length>0)}return null}async function Vo(e,t,n,r){let o=Date.now(),i={finalUrl:t,navMs:0,blocked:!1,nativeApi:!1,originTrialTokens:[],permissionsPolicy:null,html:"",inlineJs:"",scripts:[],screenshot:null,loadError:null},a=null;try{a=await e.newContext({entryUrl:t,viewport:ln});let s;try{s=await a.goto(t,be(n,an))}catch(h){return{...i,navMs:Date.now()-o,loadError:ye(h)}}let c=Date.now()-o;await a.waitForLoad(be(n,5e3));let l=s?.headers??{},u=s?.status??0,p=(await a.content()).slice(0,Wo),m=await a.inlineScripts(),d=await a.evaluate(Jo).catch(()=>null)??{},y=r?await Zo(a,n):null;return{finalUrl:a.url(),navMs:c,blocked:Xt(u,l,p),nativeApi:d.nativeApi===!0,originTrialTokens:[...qt(l["origin-trial"]),...Array.isArray(d.metaTokens)?d.metaTokens:[]],permissionsPolicy:l["permissions-policy"]??null,html:p,inlineJs:m,scripts:a.collectedScripts(),screenshot:y,loadError:null}}catch(s){return{...i,navMs:Date.now()-o,loadError:ye(s)}}finally{await a?.close()}}async function Yo(e,t,n,r,o){let i=null;try{i=await e.newContext({initScripts:[Zt],entryUrl:t,viewport:ln});try{await i.goto(t,be(r,an))}catch(l){return{snapshot:null,declarative:null,quietMs:0,loadError:ye(l)}}let a=await Xo(i,n,r,o),s=await i.evaluate(un).catch(()=>null),c=await i.evaluate(en).catch(()=>null);return{snapshot:s,declarative:c,quietMs:a,loadError:null}}catch(a){return{snapshot:null,declarative:null,quietMs:0,loadError:ye(a)}}finally{await i?.close()}}async function Xo(e,t,n,r){let o=Date.now(),i=Math.min(jo[t],Math.max(0,n-o)),a=null,s=o;for(;Date.now()-o<i;){let c=await e.evaluate(Fo).catch(()=>null);if(c!==a)a=typeof c=="string"?c:null,s=Date.now(),r&&await zo(e,r);else if(Date.now()-s>=No)break;if(await ti(Math.min(Lo,Math.max(0,n-Date.now()))),Date.now()>=n)break}return Date.now()-o}async function zo(e,t){let n=await e.evaluate(un).catch(()=>null);n&&t(dn(n.tools,e.url()))}async function Qo(e,t,n,r,o){let i=Date.now(),a=i+Mo,s=await Vo(e,t,a,r),l=s.loadError!==null||s.blocked?{snapshot:null,declarative:null,quietMs:0,loadError:null}:await Yo(e,t,n,a,o),u=s.loadError??l.loadError,p=l.snapshot,m=(l.declarative?.forms??[]).filter(On=>On.toolName.trim()!==""),d=s.finalUrl||t,y=p?dn(p.tools,d):[],h=Ho(m,d),g=[...y,...h],f=ei(s.html,s.inlineJs,s.scripts),A=Gt(s.originTrialTokens,sn(d)??sn(t)??"",new Date),P={loadError:u,blocked:s.blocked,nativeApi:s.nativeApi,originTrialValid:A?.valid===!0,declarativeToolCount:h.length,toolCount:g.length,shimTakenOver:(p?.takenOver.length??0)>0,staticSignals:f},et=Kt(P);return{page:{url:t,finalUrl:d,verdict:et,status:Vt(et,g),tools:g,declarativeFormCount:h.length,consumer:{nativeApi:s.nativeApi,originTrial:A,permissionsPolicy:s.permissionsPolicy,iframeAllow:Ko(s.permissionsPolicy)},staticSignals:f,apiSurface:{toolchangeEvents:p?.toolchangeEvents??0,provideContextCalls:p?.provideContextCalls??0,registrationErrors:qo(p)},timing:{navMs:s.navMs,quietMs:l.quietMs,totalMs:Date.now()-i},error:u},screenshot:s.blocked?null:s.screenshot}}async function pn(e){let{url:t,endpoint:n,mode:r="fast",screenshot:o=!0,onTools:i}=e,a=Date.now(),s=new Date().toISOString(),c=await fe.connect(n);try{let l=await Qo(c,t,r,o,i);return{url:t,pages:[l.page],chromeVersion:c.product,shimVersion:V,capturedAt:s,durationMs:Date.now()-a,screenshot:l.screenshot}}finally{c.close()}}async function Zo(e,t){let n=await e.screenshot(Bo,be(t,5e3));if(!n||n.byteLength===0||n.byteLength>Uo)return null;let r=e.viewportSize();return{data:n.toString("base64"),mimeType:"image/jpeg",width:r?.width??0,height:r?.height??0}}function ei(e,t,n){if(!e)return on;try{return rn(e,t,n)}catch{return on}}function sn(e){try{return new URL(e).origin}catch{return null}}function ye(e){return(e instanceof Error?e.message:String(e)).split(`
|
|
576
|
+
`)[0].slice(0,300)}function be(e,t){return Math.max(250,Math.min(t,e-Date.now()))}function ti(e){return new Promise(t=>setTimeout(t,e))}var gn=require("child_process"),j=require("fs"),hn=require("os"),ze=require("path");var fn=9222;async function yn(e){if(e)try{return{ok:!0,endpoint:await Ke(e),close:async()=>{},launched:!1}}catch(t){let n=Xe(t);return{ok:!1,message:[`No debuggable Chrome answered at ${e}.`,...n.startsWith("no debuggable Chrome answered")?[]:[n],"",...ni(fn)].join(`
|
|
577
|
+
`)}}try{let t=await di();return{ok:!0,endpoint:t.endpoint,close:t.close,launched:!0}}catch(t){return{ok:!1,message:Xe(t)}}}function bn(e){return e.pages.some(t=>t.consumer.nativeApi)?["This Chrome provides WebMCP itself. ora captures with a browser that does not,","so anything that depended on the browser rather than on your page can read","differently there.","","Where that actually changed a result, ora says so in the availability reason","above - read that rather than this. This notice only reports what the browser","did, because deciding whether it changed the outcome is ora's job, not the","CLI's.","","If you started Chrome with --enable-features=WebMCPTesting, drop the flag (or","omit --chrome-endpoint and let this command start its own).","","Keep a flag-enabled Chrome for `npx @ora-ai/webmcp-verify`, which needs the API","present in order to call your tools."].join(`
|
|
578
|
+
`):null}function ni(e){return["The audit drives a Chrome you already have; it never downloads one.","Start one with a debugging port and a scratch profile:","",` ${wn(e)}`,"","Then re-run this command. Point at a different one with --chrome-endpoint.","","Do not add --enable-features=WebMCPTesting: the audit measures whether a","real browser gives an agent WebMCP on your page, and a browser that","provides it itself answers yes for every site."]}function wn(e){let t=process.platform==="darwin"?'"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"':process.platform==="win32"?'"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"':"google-chrome",n=process.platform==="win32"?"%TEMP%\\ax-webmcp":"/tmp/ax-webmcp";return`${t} --remote-debugging-port=${e} --user-data-dir=${n}`}function Xe(e){return e instanceof x||e instanceof Error?e.message:String(e)}function ri(){let e=process.env.CHROME_PATH;return e?[e]:process.platform==="darwin"?["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Chromium.app/Contents/MacOS/Chromium","/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"]:process.platform==="win32"?[process.env.PROGRAMFILES,process.env["PROGRAMFILES(X86)"],process.env.LOCALAPPDATA].filter(n=>!!n).map(n=>`${n}\\Google\\Chrome\\Application\\chrome.exe`):["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/chromium","/usr/bin/chromium-browser","/opt/google/chrome/chrome","/snap/bin/chromium"]}function oi(){for(let e of ri())try{if((0,j.statSync)(e).isFile())return e}catch{}return null}var ii=["--headless=new","--disable-gpu","--mute-audio","--no-first-run","--no-default-browser-check","--disable-background-networking","--disable-sync","--disable-extensions","--force-webrtc-ip-handling-policy=disable_non_proxied_udp"];function si(){return process.env.AX_WEBMCP_NO_SANDBOX==="1"}var mn=2e4,ai=3e3,ci=4,li=150;function ui(e,t){return e.exitCode!==null||e.signalCode!==null?Promise.resolve():new Promise(n=>{let r=()=>{clearTimeout(o),e.off("exit",r),n()},o=setTimeout(r,t);e.once("exit",r)})}async function di(){let e=oi();if(!e)throw new x(gi());let t=(0,j.mkdtempSync)((0,ze.join)((0,hn.tmpdir)(),"ax-webmcp-")),n=(0,gn.spawn)(e,[...ii,...si()?["--no-sandbox"]:[],"--remote-debugging-port=0",`--user-data-dir=${t}`,"about:blank"],{stdio:"ignore",detached:!0}),r=i=>{o().finally(()=>{process.removeListener("SIGINT",r),process.removeListener("SIGTERM",r),process.kill(process.pid,i)})},o=async()=>{process.removeListener("SIGINT",r),process.removeListener("SIGTERM",r);let i=n.pid;try{i!==void 0?process.kill(-i,"SIGTERM"):n.kill("SIGTERM")}catch{try{n.kill("SIGTERM")}catch{}}await ui(n,ai),await mi(t)};process.once("SIGINT",r),process.once("SIGTERM",r);try{let i=await pi(t,n);return{endpoint:await Ke(`127.0.0.1:${i}`),close:o}}catch(i){throw await o(),i instanceof x?i:new x(Xe(i))}}async function pi(e,t){let n=(0,ze.join)(e,"DevToolsActivePort"),r=Date.now()+mn;for(;Date.now()<r;){if(t.exitCode!==null)throw new x(`Chrome exited with code ${t.exitCode} before it was ready.`);try{let o=(0,j.readFileSync)(n,"utf8").split(`
|
|
579
|
+
`)[0]?.trim(),i=Number(o);if(Number.isInteger(i)&&i>0)return i}catch{}await new Promise(o=>setTimeout(o,100))}throw new x(`Chrome did not publish a debugging port within ${mn/1e3}s.`)}async function mi(e){for(let t=0;t<ci;t++){try{if((0,j.rmSync)(e,{recursive:!0,force:!0}),!(0,j.existsSync)(e))return}catch{}await new Promise(n=>setTimeout(n,li))}try{(0,j.rmSync)(e,{recursive:!0,force:!0})}catch{}}function gi(){return["No Chrome found on this machine.","","The audit opens your page in a real browser, because WebMCP tools only","exist inside a live page. This package never downloads one.","","Install Chrome (https://google.com/chrome), or point at one you already","have with CHROME_PATH=/path/to/chrome, or start one yourself and pass","--chrome-endpoint:","",` ${wn(fn)}`].join(`
|
|
580
|
+
`)}var hi="https://ora.ai",fi=12e4,T=class extends Error{code;retryAfterMs;constructor(t,n={}){super(t),this.name="WebmcpIngestError",this.code=n.code??null,this.retryAfterMs=n.retryAfterMs??null}},vn=4*1024*1024,Sn=10,xn=100,An=32768,kn=4096,$n=512;function Rn(e){if(e.shimVersion!==V)return`this build captures with shim version ${e.shimVersion}, which is not the version it was built against (${V})`;if(e.pages.length>Sn)return`capture covers ${e.pages.length} pages; the limit is ${Sn}`;for(let t of e.pages){if(t.tools.length>xn)return`${t.url} registered ${t.tools.length} tools; the limit is ${xn} per page`;for(let n of t.tools){if(n.name.length>$n)return`tool name on ${t.url} is ${n.name.length} characters; the limit is ${$n}`;if(n.description.length>kn)return`description for "${n.name}" is ${n.description.length} characters; the limit is ${kn}`;for(let[r,o]of[["inputSchema",n.inputSchema],["annotations",n.annotations]]){let i=yi(o);if(i===null)return`${r} for "${n.name}" could not be serialized (a cycle, or a value JSON cannot carry)`;if(i.length>An)return`${r} for "${n.name}" serializes to ${i.length} characters; the limit is ${An}`}}}return null}function Cn(e){let t=e.screenshot;if(!t)return{capture:e,droppedScreenshot:!1};let n=t.data.length>2*1024*1024,r=t.mimeType!=="image/jpeg";return!n&&!r?{capture:e,droppedScreenshot:!1}:{capture:{...e,screenshot:null},droppedScreenshot:!0}}function yi(e){try{return JSON.stringify(e)??"null"}catch{return null}}async function En(e,t,n={}){let r=(n.baseUrl??process.env.ORA_API_URL??hi).replace(/\/+$/,""),o=n.idleMs??fi,i=J(o),a=()=>new T(`ora scoring timed out \u2014 no progress for ${Math.round(o/1e3)}s`),s=JSON.stringify({url:e,capture:t});if(Buffer.byteLength(s,"utf8")>vn)throw i.disarm(),new T(`this capture serializes to ${Math.round(Buffer.byteLength(s,"utf8")/1024)} KB; the ingest limit is ${vn/1024/1024} MB`,{code:"BODY_TOO_LARGE"});let c;try{c=await fetch(`${r}/api/webmcp/audit/ingest`,{method:"POST",headers:{accept:"text/event-stream","content-type":"application/json",...n.apiKey?{authorization:`Bearer ${n.apiKey}`}:{}},body:s,signal:i.signal})}catch(l){throw i.disarm(),i.tripped()?a():new T(`ora ingest request failed: ${l instanceof Error?l.message:String(l)}`)}if(!c.ok||!c.body)throw i.disarm(),await bi(c);return wi(c,i,n,a)}async function bi(e){let t=await e.clone().json().catch(()=>null),n=t?.code??null;if(e.status===429){let r=Number(e.headers.get("retry-after")),o=t?.retry_after_ms??(Number.isFinite(r)&&r>0?r*1e3:null),i=o?` \u2014 retry in ${Math.ceil(o/1e3)}s`:"";return new T(`ora rate limit exceeded${i} (10/min and 20 per 24h per IP). An ora API key lifts these limits: set ORA_API_KEY or pass --api-key.`,{code:n??"RATE_LIMITED",retryAfterMs:o})}return n==="SHIM_VERSION_MISMATCH"?new T(`This ax build captures with a shim ora no longer scores, so the audit was refused.
|
|
581
|
+
Upgrade with \`npm i -g ax@latest\` (or \`npx ax@latest webmcp-audit \u2026\`) and run it again.
|
|
582
|
+
|
|
583
|
+
ora said: ${t?.error??"shim version mismatch"}`,{code:n}):e.status===503?new T(`ora cannot score right now: ${vi(t?.error??"scoring is unavailable")} Nothing was spent against your rate limit; try again shortly.`,{code:n??"SCORING_UNAVAILABLE"}):new T(`ora ingest failed: ${t?.error??await F(e)}`,{code:n})}async function wi(e,t,n,r){let o=new TextDecoder,i="",a;try{e:for await(let s of e.body){t.poke(),i=`${i}${o.decode(s,{stream:!0})}`.replace(/\r\n?/g,`
|
|
584
|
+
`);let c=i.indexOf(`
|
|
585
|
+
|
|
586
|
+
`);for(;c!==-1;){let l=Si(i.slice(0,c));if(i=i.slice(c+2),c=i.indexOf(`
|
|
587
|
+
|
|
588
|
+
`),!l)continue;let u;try{u=JSON.parse(l)}catch{continue}if(n.onEvent?.(u),u.type==="error")throw new T(`ora audit failed: ${u.message}`,{code:u.status});if(u.type==="done"){a=u.audit;break e}}}}catch(s){throw t.tripped()?r():s instanceof T?s:new T(`ora ingest stream failed: ${s instanceof Error?s.message:String(s)}`)}finally{t.disarm()}if(!a)throw new T("ora ingest stream ended before the audit completed");return a}function vi(e){let t=e.trim();return/[.!?]$/.test(t)?t:`${t}.`}function Si(e){let t=[];for(let n of e.split(`
|
|
589
|
+
`))n.startsWith("data:")&&t.push(n.slice(5).replace(/^ /,""));return t.join(`
|
|
590
|
+
`)}var b=B(W(),1);var Qe=12,xi=["fail","warning","unmeasured","na","pass"],Ze={fail:["\u2716",b.default.red],warning:["\u25B2",b.default.yellow],unmeasured:["?",b.default.magenta],na:["\u2013",b.default.dim],pass:["\u2714",b.default.green]},Ai={fail:"Failing",warning:"Warnings",unmeasured:"Not measured",na:"Not applicable",pass:"Passing"},ki=["shared-experience","task-completion","tool-quality","trust"],$i={"shared-experience":"Shared experience","task-completion":"Task completion","tool-quality":"Tool quality",trust:"Trust"};function _n(e,t={}){let n=X(80,120),r=e.availability.status==="ready";return["",...Ri(e,n),"",...Ei(e.availability,n),...r?["",..._i(e,n),"",...Pi(e)]:[],"",...Oi(e.findings,n,t.showPassing===!0),...Li(e.simulation,n),"",...ji(e,n)]}function Ri(e,t){let n=[` ${b.default.bold(E(e.url))}`],r=`${e.toolCount} tool${e.toolCount===1?"":"s"}`,o=[Ci(e.verdict),r,`Chrome ${E(e.chromeVersion)}`];return e.error&&o.push(b.default.red(E(e.error))),n.push(` ${b.default.dim(o.join(" \xB7 "))}`),n.map(i=>Tn(i,t))}function Ci(e){switch(e){case"active":return b.default.green("active");case"testing-only":case"declared-inactive":case"api-empty":return b.default.yellow(e);case"blocked":case"load-error":return b.default.red(e);default:return b.default.dim(e)}}function Ei(e,t){let[n,r]=e.status==="ready"?["agent-ready",b.default.green]:e.status==="not-ready"?["not agent-ready",b.default.red]:["availability unknown",b.default.yellow],o=[` ${r(b.default.bold(n))}`];for(let i of e.reasons)o.push(...O(E(i.detail),t-4).map(a=>` ${b.default.dim(a)}`));return e.status==="not-ready"&&o.push(...O("No score is reported for a page an agent cannot use yet: the reasons above are what to fix first.",t-4).map(i=>` ${b.default.dim(i)}`)),o}function _i(e,t){let n=e.score===null?"\u2014":String(e.score),r=[` ${b.default.bold(`${n}/100`)} ${Ti(e)}`];return e.grade===null&&e.score!==null&&r.push(...O(`The grade is withheld because only ${e.evidenceCoverage}% of the applicable check weight was actually measured. The score above still stands; the "Not measured" checks below are what is missing.`,t-4).map(o=>` ${b.default.dim(o)}`)),r}function Ti(e){return e.grade!==null?b.default.bold(b.default.green(`grade ${e.grade}`)):b.default.dim("grade withheld")}function Pi(e){let t=[` ${b.default.bold("Pillars")}`];for(let n of ki){let r=e.categoryScores[n]??0,o=Yt[n],i=e.findings.some(c=>Ye[c.checkId]?.category===n&&c.status!=="na"&&c.status!=="unmeasured"),a=i?Ii(r):b.default.dim("\u2591".repeat(Qe)),s=i?`weight ${o}`:`weight ${o} \xB7 nothing measured`;t.push(` ${$i[n].padEnd(18)} ${a} ${String(r).padStart(3)}% ${b.default.dim(s)}`)}return t}function Ii(e){let t=Math.round(Math.min(100,Math.max(0,e))/100*Qe);return`${(e>=75?b.default.green:e>=40?b.default.yellow:b.default.red)("\u2588".repeat(t))}${b.default.dim("\u2591".repeat(Qe-t))}`}function Oi(e,t,n){let r=[` ${b.default.bold("Checks")}`];for(let o of xi){let i=e.filter(a=>a.status===o);if(i.length!==0){if(o==="pass"&&!n){r.push(` ${b.default.dim(`${i.length} passing (--show-passing to list)`)}`);continue}r.push("",` ${b.default.bold(Ai[o])} (${i.length})`);for(let a of i)r.push(...Mi(a,t))}}return e.length===0&&r.push(` ${b.default.dim("no checks reported")}`),r}function Mi(e,t){let[n,r]=Ze[e.status],o=Ni(e.checkId),a=[` ${r(n)} ${o}${e.toolName?b.default.dim(` ${E(e.toolName)}`):""}`];return e.details&&a.push(...O(E(e.details),t-10).map(s=>` ${b.default.dim(s)}`)),e.evidence&&a.push(...O(E(e.evidence),t-10).map(s=>` ${b.default.dim(s)}`)),a}function Ni(e){return Ye[e]?.title??e}function Li(e,t){if(!e)return[];let n=["",` ${b.default.bold("Tool selection")}`];if(e.skipped)return n.push(...O(E(e.skipReason??"The selection simulation did not run."),t-4).map(o=>` ${b.default.dim(o)}`)),n;let r=Math.round(e.accuracy*100);n.push(` ${r}% of ${e.steps.length} intent${e.steps.length===1?"":"s"} picked the right tool ${b.default.dim(E(e.model))}`);for(let o of e.steps){let[i,a]=o.ok?Ze.pass:Ze.fail,s=o.chosenTool?E(o.chosenTool):b.default.dim("nothing");n.push(` ${a(i)} ${Tn(E(o.intent),t-30)} ${b.default.dim("\u2192")} ${s}`)}return n}function ji(e,t){let n=e.source==="local"?"Captured by your own browser and scored without being stored \u2014 this result is not published or ranked anywhere. Run the audit at webmcp.ora.ai for a public one.":"";return n?O(n,t-4).map(r=>` ${b.default.dim(r)}`):[]}function Tn(e,t){return e.length>t?`${e.slice(0,t-1)}\u2026`:e}var M={OK:0,BELOW_MIN_SCORE:1,USAGE:2,API:3};function Wi(e){let t=e.trim();if(!(!t||/\s/.test(t)))try{let n=new URL(t.includes("://")?t:`http://${t}`);return n.protocol!=="http:"&&n.protocol!=="https:"?void 0:n.toString()}catch{return}}function Di(e){if(e===void 0)return{};let t=Number(e);return e.trim()===""||!Number.isInteger(t)||t<0||t>100?{error:`--min-score must be an integer between 0 and 100, got ${JSON.stringify(e)}`}:{value:t}}async function Pn(e){let t=Wi(e.url);if(!t)return console.error(`Not an auditable URL: ${JSON.stringify(e.url)}`),console.error("Pass the page you want audited, e.g. http://localhost:3000"),M.USAGE;let n=Di(e.minScore);if(n.error)return console.error(n.error),M.USAGE;let r=await yn(e.chromeEndpoint);if(!r.ok)return console.error(r.message),M.USAGE;e.json||S.start(r.launched?`Starting Chrome and capturing ${t}`:`Capturing ${t}`);let o;try{o=await pn({url:t,endpoint:r.endpoint,onTools:p=>{e.json||S.update(`Capturing ${t} \u2014 ${p.length} tools`)}})}catch(p){return S.stop(),console.error(`Capture failed: ${p instanceof Error?p.message:String(p)}`),M.API}finally{await r.close()}let i=o.pages[0];if(i?.error)return S.stop(),console.error(`Could not capture ${t}: ${i.error}`),console.error("Is the dev server running?"),M.USAGE;let a=Rn(o);if(a)return S.stop(),console.error(`ora would refuse this capture: ${a}`),M.USAGE;let{capture:s,droppedScreenshot:c}=Cn(o);e.json||S.update("Scoring with ora");let l;try{l=await En(t,s,{apiKey:e.apiKey??process.env.ORA_API_KEY,onEvent:p=>{e.json||S.update(Bi(p))}})}catch(p){return S.stop(),p instanceof T?(console.error(p.message),M.API):(console.error(`Scoring failed: ${p instanceof Error?p.message:String(p)}`),M.API)}if(S.stop(),e.json)console.log(JSON.stringify(l,null,2));else for(let p of _n(l,{showPassing:e.showPassing}))console.log(p);c&&console.error("Note: the screenshot exceeded ora's 2 MB limit and was not sent, so page-experience could not be graded.");let u=bn(o);if(u&&console.error(`
|
|
591
|
+
${u}`),n.value!==void 0){if(l.availability.status!=="ready")return e.json||console.log(`
|
|
592
|
+
Not agent-ready, so there is no score to compare against --min-score ${n.value}
|
|
593
|
+
`),M.BELOW_MIN_SCORE;if(l.score===null)return e.json||console.error(`
|
|
594
|
+
ora returned no score, so --min-score cannot be evaluated.`),M.API;if(l.score<n.value)return e.json||console.log(`
|
|
595
|
+
Score ${l.score} is below the required minimum ${n.value}
|
|
596
|
+
`),M.BELOW_MIN_SCORE}return M.OK}function Bi(e){switch(e.type){case"phase":return`Scoring with ora \u2014 ${e.phase}`;case"tool-discovered":return`Scoring with ora \u2014 found ${E(e.tool.name)}`;case"finding":return`Scoring with ora \u2014 ${e.finding.checkId}`;case"simulation-step":return`Scoring with ora \u2014 simulating "${E(e.step.intent)}"`;default:return"Scoring with ora"}}function In(){if(typeof process.loadEnvFile!="function")return!1;try{return process.loadEnvFile(),!0}catch{return!1}}var H="ax",Ui={meta:{name:"audit",description:"Score a site's agent readiness (exit codes: 0 ok, 1 below --min-score, 2 usage, 3 API error)"},args:{url:{type:"positional",description:"URL or domain to audit (e.g. https://docs.example.com)",required:!0},json:{type:"boolean",description:"Print the raw ora audit payload as JSON",default:!1},"min-score":{type:"string",description:"Exit 1 when the score is below this threshold (0-100); the CI gate"},"max-age":{type:"string",description:"Accept a cached result up to this many seconds old (server default 6h)"},force:{type:"boolean",description:"Bypass the cache and rescan (spends the stricter 6/day force budget)",default:!1},"tunnel-cmd":{type:"string",description:"Command that exposes a local target and prints its public https URL (e.g. 'ngrok http 3000 --log stdout'); also read from ORA_TUNNEL_CMD. The result is stored as ephemeral"},"api-key":{type:"string",description:"ora-issued scan API key that lifts the scan rate limits; also read from ORA_SCAN_API_KEY"},"show-passing":{type:"boolean",description:"List each passing check individually",default:!1},"show-skipped":{type:"boolean",description:"List not-applicable / pending checks too",default:!1}},async run({args:e}){process.exitCode=await kt({url:e.url,json:!!e.json,showSkipped:!!e["show-skipped"],showPassing:!!e["show-passing"],minScore:e["min-score"],maxAge:e["max-age"],force:!!e.force,tunnelCmd:e["tunnel-cmd"],apiKey:e["api-key"]})}},Ji={meta:{name:"journey",description:"Send a real AI agent at a site and watch it navigate live"},args:{intent:{type:"positional",description:'Goal for the agent (e.g. "Find the API docs and how to auth")',required:!0},domain:{type:"string",description:"Site the agent targets (e.g. stripe.com)"},harness:{type:"string",description:"Agent harness: claude-code, codex, openclaw, hermess, claude-agent, eve, \u2026",default:"claude-code"},model:{type:"string",description:"Model override (harness default when omitted)"},json:{type:"boolean",description:"Output as JSON",default:!1}},async run({args:e}){process.exitCode=await jt({intent:e.intent,domain:e.domain,harness:e.harness,model:e.model,json:!!e.json})}},Fi={meta:{name:"deep-journey",description:"Run a real AI agent at a site on a curated task \u2014 or, with a partner API key, a free-text one \u2014 via ora's public API (exit codes: 0 ok, 1 run failed, 2 usage, 3 API error)"},args:{url:{type:"positional",description:"URL or domain the agent targets (e.g. stripe.com)",required:!0},intent:{type:"string",description:"Curated intent id (see GET /api/journey/intents; server default when omitted)"},agent:{type:"string",description:"Agent id from the public roster (see GET /api/journey/agents)"},json:{type:"boolean",description:"Print the terminal run detail as JSON",default:!1},task:{type:"string",description:"Free-text task for the agent (needs a partner API key; mutually exclusive with --intent)"},"api-key":{type:"string",description:"ora-issued partner API key: unlocks --task and the 1000/24h keyed allowance; also read from ORA_PARTNER_API_KEY"},"no-stream":{type:"boolean",description:"Skip the live trajectory stream and poll for the result instead",default:!1}},async run({args:e}){process.exitCode=await Pt({url:e.url,intent:e.intent,task:e.task,apiKey:e["api-key"],agent:e.agent,json:!!e.json,noStream:!!e["no-stream"]})}},Hi={meta:{name:"skill",description:"List, print, or install ora's agent skills (digest-verified from the registry, never bundled)"},args:{name:{type:"positional",description:"Skill name (omit to list the registry)",required:!1},install:{type:"boolean",description:"Write <dir>/<name>/SKILL.md instead of printing",default:!1},dir:{type:"string",description:"Install directory (default .claude/skills)"},json:{type:"boolean",description:"Print the raw registry index as JSON",default:!1}},async run({args:e}){process.exitCode=await Jt({name:e.name,install:!!e.install,dir:e.dir,json:!!e.json})}},Gi={meta:{name:"webmcp-audit",description:"Audit a page's WebMCP tools in a real browser - localhost included, so you can check before you publish (exit codes: 0 ok, 1 below --min-score, 2 usage, 3 API error)"},args:{url:{type:"positional",description:"Page to audit, scheme included (e.g. http://localhost:3000)",required:!0},"chrome-endpoint":{type:"string",description:"Drive a Chrome you started instead of launching one: ws:// URL, http origin, or host:port"},"min-score":{type:"string",description:"Exit 1 when the score is below this threshold (0-100); the CI gate"},"api-key":{type:"string",description:"ora API key that lifts the ingest rate limits; also read from ORA_API_KEY"},json:{type:"boolean",description:"Print the raw ora audit payload as JSON",default:!1},"show-passing":{type:"boolean",description:"List each passing check individually",default:!1}},async run({args:e}){process.exitCode=await Pn({url:e.url,json:!!e.json,showPassing:!!e["show-passing"],minScore:e["min-score"],chromeEndpoint:e["chrome-endpoint"],apiKey:e["api-key"]})}};function qi(){let e=we.default.green("$"),t=we.default.dim;return["",` ${we.default.bold(H)} ${t(`v${Re.version}`)}`,` ${t("Score any site's agent readiness \u2014 and watch real AI agents navigate it")}`,"",` ${t("Commands:")}`,` audit ${t("<url>")} ${t("Score a site's agent readiness")}`,` webmcp-audit ${t("<url>")} ${t("Audit a WebMCP surface in a real browser, localhost included")}`,` deep-journey ${t("<url>")} ${t("Run a real agent at a site on a curated or free-text task")}`,` journey ${t("<intent>")} ${t("Send a real agent at a site and watch it live (workspace)")}`,` skill ${t("[name]")} ${t("List, print, or install ora's agent skills")}`,"",` ${t("Examples:")}`,` ${e} ${H} audit https://docs.example.com`,` ${e} ${H} audit https://docs.example.com --min-score 70 ${t("# CI gate")}`,` ${e} ${H} audit https://docs.example.com --json`,` ${e} ${H} webmcp-audit http://localhost:3000`,` ${e} ${H} deep-journey stripe.com --intent pricing`,` ${e} ${H} journey "Find the API docs and how to authenticate" --domain stripe.com`,"",` ${t("audit options:")}`,` --min-score <n> ${t("Exit 1 when the score is below n (0-100); the CI gate")}`,` --max-age <s> ${t("Accept a cached result up to s seconds old (default 6h)")}`,` --force ${t("Bypass the cache and rescan (6/day budget)")}`,` --tunnel-cmd <c> ${t("Expose a local target via your own tunnel command (e.g. 'ngrok http 3000 --log stdout')")}`,` --api-key <k> ${t("ora-issued scan API key that lifts the rate limits; also read from ORA_SCAN_API_KEY")}`,` --json ${t("Print the raw ora audit payload as JSON")}`,` --show-passing ${t("List each passing check (hidden by default)")}`,` --show-skipped ${t("List skipped checks (hidden by default)")}`,"",` ${t("audit exit codes:")}`,` ${t("0 success \xB7 1 below --min-score \xB7 2 usage error \xB7 3 API unreachable/rate-limited")}`,"",` ${t("webmcp-audit options:")}`,` --chrome-endpoint ${t("<e> Drive a Chrome you started: ws:// URL, http origin, or host:port")}`,` --min-score <n> ${t("Exit 1 when the score is below n (0-100); the CI gate")}`,` --api-key <k> ${t("ora API key that lifts the ingest rate limits; also read from ORA_API_KEY")}`,` --json ${t("Print the raw ora audit payload as JSON")}`,` --show-passing ${t("List each passing check (hidden by default)")}`,` ${t("starts a headless Chrome you already have installed; never downloads one")}`,` ${t("scored by ora, stored nowhere: the result is never published or ranked")}`,"",` ${t("deep-journey options:")}`,` --intent <id> ${t("Curated task id, e.g. pricing, signup, api-docs (server default when omitted)")}`,` --task <text> ${t("Free-text task (needs a partner API key; replaces --intent)")}`,` --api-key <k> ${t("ora partner API key: unlocks --task + 1000 runs/24h; also read from ORA_PARTNER_API_KEY")}`,` --agent <id> ${t("Agent from the public roster (default: ora's pick)")}`,` --no-stream ${t("Poll for the result instead of streaming the trajectory")}`,` --json ${t("Print the terminal run detail as JSON")}`,` ${t("no key needed \xB7 public caps: 100 runs/24h per target, 200 runs/24h per IP")}`,"",` ${t("journey options:")}`,` --domain <d> ${t("Site the agent targets (e.g. stripe.com)")}`,` --harness <h> ${t("Agent harness: claude-code (default), codex, openclaw, hermess, claude-agent, eve, \u2026")}`,` --model <m> ${t("Model override (harness default when omitted)")}`,` --json ${t("Output as JSON")}`,` ${t("requires ORA_API_KEY (see .env.example)")}`,""].join(`
|
|
597
|
+
`)}var Ki={meta:{name:H,version:Re.version,description:"Score any site's agent readiness \u2014 and watch real AI agents navigate it"},subCommands:{audit:Ui,"webmcp-audit":Gi,"deep-journey":Fi,journey:Ji,skill:Hi},setup(){let e=process.argv[2];(!e||e==="--help"||e==="-h")&&(console.log(qi()),process.exit(0))}};In();lt(Ki);
|