@crewx/sdk 0.9.0-rc.127 → 0.9.0-rc.129

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.
@@ -1 +1,2 @@
1
- import {existsSync,readFileSync,statSync,readdirSync}from'fs';import {join,resolve}from'path';import {load}from'js-yaml';var d="SKILL.md",v=/^---\s*\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;function m(t){if(t===null||typeof t!="object"||Array.isArray(t))return false;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}function D(t){return t.isDirectory()||t.isSymbolicLink()}function k(t){try{return existsSync(t)&&statSync(t).isDirectory()}catch{return false}}var F=["index.js","main.js"];function O(t,e){let i=join(t,"package.json");if(existsSync(i))try{let n=JSON.parse(readFileSync(i,"utf8"));if(n.bin){let o=typeof n.bin=="string"?n.bin:Object.values(n.bin).find(s=>typeof s=="string");if(o){let s=resolve(t,o);if(existsSync(s))return s}}if(typeof n.main=="string"){let o=resolve(t,n.main);if(existsSync(o))return o}}catch{}let r=resolve(t,`${e}.js`);if(existsSync(r))return r;for(let n of F){let o=resolve(t,n);if(existsSync(o))return o}}function R(t){let e;try{e=readFileSync(t,"utf8");}catch{return {frontmatter:{},readable:false,valid:false,hasFrontmatter:false}}let i=e.match(v);if(!i)return {frontmatter:{},readable:true,valid:true,hasFrontmatter:false};try{let r=load(i[1]??"");if(!m(r))return {frontmatter:{},readable:!0,valid:!1,hasFrontmatter:!0};let n=m(r.metadata)?r.metadata:void 0;return {frontmatter:{...typeof r.name=="string"?{name:r.name}:{},...typeof(n?.version??r.version)=="string"?{version:n?.version??r.version}:{},...typeof r.description=="string"?{description:r.description}:{}},readable:!0,valid:!0,hasFrontmatter:!0}}catch{return {frontmatter:{},readable:true,valid:false,hasFrontmatter:true}}}function j(t){return [join(t,d),join(t,"skill",d)]}function f(t,e){if(!k(t))return null;for(let i of j(t)){if(!existsSync(i))continue;let n=R(i).frontmatter;return {name:n.name??e,...n.version===void 0?{}:{version:n.version},...n.description===void 0?{}:{description:n.description},skillMdPath:i,dir:t}}return null}function u(t){try{return readdirSync(t,{withFileTypes:!0}).filter(D)}catch{return []}}function w(t){return t.length===0||/[\\\u0000]/.test(t)?false:t.split("/").every(e=>e.length>0&&e!=="."&&e!=="..")}function y(t,e,i){!t||e.has(t.name)||(e.add(t.name),i.push(t));}function g(t){let e=[],i=new Set;for(let r of t)if(k(r))for(let n of u(r)){if(n.name.startsWith("@")){let o=join(r,n.name);for(let s of u(o))y(f(join(o,s.name),s.name),i,e);continue}y(f(join(r,n.name),n.name),i,e);}return e.sort((r,n)=>r.name.localeCompare(n.name))}function x(t,e){if(!w(t))throw new Error(`Skill not found: ${t}`);for(let r of e){let n=f(join(r,t),t);if(n)return n;for(let o of u(r)){if(!o.name.startsWith("@"))continue;let s=f(join(r,o.name,t),t);if(s)return s}}let i=g(e).find(r=>r.name===t);if(i)return i;throw new Error(`Skill not found: ${t}`)}var P=g,$=x;export{g as discover,P as discoverSkills,O as findEntrypoint,R as readSkillFrontmatter,x as resolve,$ as resolveSkill};
1
+ import {join,resolve,dirname,relative,sep,isAbsolute}from'path';import'url';import {createHash}from'crypto';import {existsSync,readFileSync,statSync,readdirSync,constants}from'fs';import {realpath,stat,readdir,open,lstat}from'fs/promises';import {load}from'js-yaml';var yi=Object.defineProperty;var O=(e,n)=>()=>(e&&(n=e(e=0)),n);var Ai=(e,n)=>{for(var t in n)yi(e,t,{get:n[t],enumerable:true});};var I=O(()=>{});var _,dn=O(()=>{I();_=class extends Error{constructor(t,i=t,o){super(i);this.code=t;this.currentRevision=o;}code;currentRevision;name="UiRuntimeError"};});function z(){throw new _("INPUT_INVALID","JSON value is not projection-safe")}function _i(e){let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function pn(e,n,t,i,o,r){if(n>i&&z(),e===null||typeof e=="string"||typeof e=="boolean")return typeof e=="string"&&(mi.test(e)||Ti.test(e)&&!Ni(o,r)||hi.test(e))&&z(),e;if(typeof e=="number")return Number.isFinite(e)||z(),e;(typeof e!="object"||e===void 0||typeof e=="function"||typeof e=="bigint")&&z();let s=e;t.has(s)&&z(),t.add(s);try{if(Array.isArray(e))return e.map(p=>pn(p,n+1,t,i,o,r));_i(s)||z();let a={};for(let[p,d]of Object.entries(e))(Ii.test(p)||gi.test(p))&&z(),a[p]=pn(d,n+1,t,i,[...o,p],r);return a}finally{t.delete(s);}}function ne(e,n=0,t=[]){(!Number.isInteger(n)||n<0||n>Ei)&&z(),(!Array.isArray(t)||t.some(o=>typeof o!="string"))&&z();let i=pn(e,0,new Set,Di+n,[],t);return (i===null||Array.isArray(i)||typeof i!="object")&&z(),i}function ge(e,n){if(!e||!n)return false;let t=e.split("."),i=n.split(".");return t.length>=i.length&&i.every((o,r)=>t[r]===o)}function Ni(e,n){if(e.length===0)return false;let t=e.join(".");return n.some(i=>ge(t,i))}function me(e){try{let n=JSON.stringify(e);return n===void 0&&z(),n}catch{z();}}function ln(e){return Array.isArray(e)?e.map(ln):e!==null&&typeof e=="object"?Object.fromEntries(Object.keys(e).sort().map(n=>[n,ln(e[n])])):e}function J(e){return me(ln(e))}function un(e){return Buffer.byteLength(e,"utf8")}var Ii,gi,mi,hi,Ti,Di,Ei,de=O(()=>{I();dn();Ii=/(?:proof|token|secret|password|cookie|authorization|private[_-]?key|stack|exception|plugin[_-]?text)/i,gi=/(?:url|uri|endpoint|path|file(?:name|path)?|cwd|shell|directory|dir|folder)$/i,mi=/<\/?[A-Za-z][^>]*>/,hi=/^(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)/,Ti=/^(?:https?|file|ftp|ws|wss):\/\//i;Di=8,Ei=4;});function he(e){return bi.has(e)||Pi.test(e)||Mi.test(e)}var nt,bi,Pi,Mi,Be,Se,te,fn,yn,An,In,gn,Te=O(()=>{I();nt=["__proto__","prototype","constructor","proof","token","secret","password","cookie","authorization","private_key","private-key","stack","exception","plugin_text","url","uri","endpoint","path","filename","filepath","cwd","shell","directory","dir","folder"],bi=new Set(nt),Pi=/(?:proof|token|secret|password|cookie|authorization|private[_-]?key|stack|exception|plugin[_-]?text)/i,Mi=/(?:url|uri|endpoint|path|file(?:name|path)?|cwd|shell|directory|dir|folder)$/i;Be=/^[A-Za-z0-9_]+$/,Se=/^[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*$/,te=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,fn=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/,yn=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,An=/^[A-Za-z0-9][A-Za-z0-9._:-]{0,255}$/,In=["blue","violet","emerald","amber","rose","sky","slate","indigo"],gn=["inline","panel"];});function mn(e){return typeof e=="string"&&tt.includes(e)}var tt,it=O(()=>{I();Te();tt=["text/plain","application/json"];});function He(e){if(!hn(e))return false;let n=Object.keys(e);return !(n.some(t=>t!=="in"&&t!=="out")||n.length===0||Object.hasOwn(e,"in")&&!Li(e.in)||Object.hasOwn(e,"out")&&!Oi(e.out))}function Li(e){return hn(e)?Object.keys(e).every(t=>t==="mediaType"||t==="required")&&Object.hasOwn(e,"mediaType")&&mn(e.mediaType)&&(!Object.hasOwn(e,"required")||typeof e.required=="boolean"):false}function Oi(e){return hn(e)?Object.keys(e).every(t=>t==="mediaType"||t==="range")&&Object.hasOwn(e,"mediaType")&&mn(e.mediaType)&&(!Object.hasOwn(e,"range")||typeof e.range=="boolean"):false}function hn(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}var Tn=O(()=>{I();it();new TextDecoder("utf-8",{fatal:true,ignoreBOM:true});});function ie(e){let t=e.renderer!==void 0||e.surfaces!==void 0||e.stateProjection!==void 0||e.dataPaths!==void 0||e.usage!==void 0||e.detailPanel!==void 0||e.displayModes!==void 0||e.summaryProjection!==void 0||e.legacy!==void 0||Object.values(e.actions).some(o=>o.resultProjection!==void 0)?{id:e.id,version:e.version,...e.renderer===void 0?{}:{renderer:e.renderer},...e.surfaces===void 0?{}:{surfaces:e.surfaces},...e.stateProjection===void 0?{}:{stateProjection:e.stateProjection},...e.dataPaths===void 0?{}:{dataPaths:e.dataPaths},...e.summaryProjection===void 0?{}:{summaryProjection:e.summaryProjection},...e.legacy===void 0?{}:{legacy:e.legacy},...e.usage===void 0?{}:{usage:e.usage},...e.detailPanel===void 0?{}:{detailPanel:e.detailPanel},...e.displayModes===void 0?{}:{displayModes:e.displayModes},...e.sourceHash===void 0?{}:{sourceHash:e.sourceHash},actions:e.actions}:e.sourceHash===void 0?{id:e.id,version:e.version,actions:e.actions}:{id:e.id,version:e.version,sourceHash:e.sourceHash,actions:e.actions},i=ne(t);return createHash("sha256").update(J(i)).digest("hex")}function oe(e){if(!/^\d+$/.test(String(e.version))||e.version<1||e.id.length<1||e.id.length>128)throw new _("DEFINITION_UNSUPPORTED","UI definition is invalid");if(e.sourceHash!==void 0&&(typeof e.sourceHash!="string"||!Ui.test(e.sourceHash)))throw new _("DEFINITION_UNSUPPORTED","UI definition source hash is invalid");if(!/^[0-9a-f]{64}$/.test(e.hash)||ie(e)!==e.hash)throw new _("DEFINITION_UNSUPPORTED","UI definition hash is invalid");for(let[n,t]of Object.entries(e.actions)){if(!n||!Array.isArray(t.capabilities)||t.capabilities.some(i=>!ki(i)))throw new _("DEFINITION_UNSUPPORTED","UI action declaration is invalid");if(t.confirmation!==void 0&&t.confirmation!=="none"&&t.confirmation!=="native")throw new _("DEFINITION_UNSUPPORTED","UI action confirmation is invalid");if(t.inputKeys&&(!Array.isArray(t.inputKeys)||t.inputKeys.some(i=>typeof i!="string"||!i)))throw new _("DEFINITION_UNSUPPORTED","UI action input declaration is invalid");if(t.dataInputs!==void 0&&(!Array.isArray(t.dataInputs)||new Set(t.dataInputs).size!==t.dataInputs.length||t.dataInputs.some(i=>typeof i!="string"||!i||t.inputKeys!==void 0&&!t.inputKeys.includes(i))))throw new _("DEFINITION_UNSUPPORTED","UI action data input declaration is invalid");if(t.resultProjection&&_n(t.resultProjection),t.content!==void 0&&!He(t.content))throw new _("DEFINITION_UNSUPPORTED","UI action content declaration is invalid");if(t.env!==void 0&&(!Array.isArray(t.env)||t.env.length===0||new Set(t.env).size!==t.env.length||t.env.some(i=>i!=="CREWX_APP_INSTANCE_ID"&&i!=="CREWX_THREAD_ID")))throw new _("DEFINITION_UNSUPPORTED","UI action environment declaration is invalid")}if(e.renderer!==void 0&&(!e.renderer||e.renderer.length>128))throw new _("DEFINITION_UNSUPPORTED","UI definition renderer is invalid");if(e.surfaces&&(!Array.isArray(e.surfaces)||e.surfaces.some(n=>!n||n.length>64)))throw new _("DEFINITION_UNSUPPORTED","UI definition surfaces are invalid");if(e.usage!==void 0&&e.usage!=="card"&&e.usage!=="window")throw new _("DEFINITION_UNSUPPORTED","UI definition usage is invalid");if(e.detailPanel!==void 0&&typeof e.detailPanel!="boolean")throw new _("DEFINITION_UNSUPPORTED","UI definition detailPanel is invalid");if(e.displayModes&&(!Array.isArray(e.displayModes)||e.displayModes.length===0||new Set(e.displayModes).size!==e.displayModes.length||e.displayModes.some(n=>n!=="inline"&&n!=="floating"&&n!=="focused")))throw new _("DEFINITION_UNSUPPORTED","UI definition displayModes are invalid");if(e.usage==="card"&&e.displayModes!==void 0)throw new _("DEFINITION_UNSUPPORTED","Card definitions cannot declare displayModes");if(e.usage==="window"&&e.detailPanel!==void 0)throw new _("DEFINITION_UNSUPPORTED","Window definitions cannot declare detailPanel");if(e.stateProjection&&_n(e.stateProjection),e.summaryProjection){_n(e.summaryProjection);let n=new Set(e.stateProjection?.allow??[]);if(e.summaryProjection.allow.some(t=>!n.has(t)))throw new _("DEFINITION_UNSUPPORTED","UI summary projection exceeds state projection")}if(e.legacy!==void 0){if(!e.legacy||typeof e.legacy!="object"||Array.isArray(e.legacy)||Object.keys(e.legacy).some(o=>!["readTool","actionTool","hostTools","agentAccess"].includes(o)))throw new _("DEFINITION_UNSUPPORTED","UI legacy metadata is invalid");let n=new Set;for(let[o,r]of [["readTool",e.legacy.readTool],["actionTool",e.legacy.actionTool]])if(r!==void 0){if(Ri(r,o==="readTool"),n.has(r.name))throw new _("DEFINITION_UNSUPPORTED","UI legacy tool names collide");n.add(r.name);}let t=e.legacy.hostTools;if(t!==void 0){if(!t||typeof t!="object"||Array.isArray(t))throw new _("DEFINITION_UNSUPPORTED","UI legacy host tools are invalid");let o={"doc.open":"crewx_app_html_viewer_open","pty.connect":"crewx_app_terminal_connect"};for(let[r,s]of Object.entries(t)){if(!Object.hasOwn(o,r)||o[r]!==s||typeof s!="string"||!/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(s)||n.has(s))throw new _("DEFINITION_UNSUPPORTED","UI legacy host tools are invalid");n.add(s);}}let i=e.legacy.agentAccess;if(i!==void 0&&(!i||typeof i!="object"||Array.isArray(i)||Object.entries(i).some(([o,r])=>!o||!Object.hasOwn(e.actions,o)||r!=="allowed"&&r!=="denied")))throw new _("DEFINITION_UNSUPPORTED","UI legacy agent access is invalid");if(e.legacy.actionTool!==void 0&&(!i||Object.keys(i).length===0))throw new _("DEFINITION_UNSUPPORTED","UI legacy action tool requires its complete agent access map")}if(e.dataPaths!==void 0){let n=new Set(["__proto__","prototype","constructor"]);if(!Array.isArray(e.dataPaths)||e.dataPaths.length>16||new Set(e.dataPaths).size!==e.dataPaths.length||e.dataPaths.some(t=>typeof t!="string"||!/^[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*$/.test(t)||t.split(".").some(i=>n.has(i))||!(e.stateProjection?.allow??[]).some(i=>ge(t,i))))throw new _("DEFINITION_UNSUPPORTED","UI definition dataPaths are invalid")}}function Ri(e,n){if(!e||typeof e!="object"||Array.isArray(e))throw new _("DEFINITION_UNSUPPORTED","UI legacy tool metadata is invalid");let t=e,i=["name","description","inputSchema","textFallback","visibility"],o=Object.hasOwn(t,"fixedResult");if(Object.keys(t).some(r=>!i.includes(r)&&!(n&&r==="fixedResult"))||i.some(r=>!Object.hasOwn(t,r))||typeof t.name!="string"||!/^[A-Za-z][A-Za-z0-9._-]{0,127}$/.test(t.name)||typeof t.description!="string"||t.description.trim().length===0||t.description.length>8192||typeof t.textFallback!="string"||t.textFallback.trim().length===0||t.textFallback.length>16384||!t.inputSchema||typeof t.inputSchema!="object"||Array.isArray(t.inputSchema)||!Array.isArray(t.visibility)||t.visibility.length===0||t.visibility.some(r=>r!=="model"&&r!=="app")||new Set(t.visibility).size!==t.visibility.length)throw new _("DEFINITION_UNSUPPORTED","UI legacy tool metadata is invalid");try{let r=ne(t.inputSchema);if(r.type!==void 0&&r.type!=="object")throw new Error("schema type");if(o){if(!n)throw new Error("fixed result location");let s=t.fixedResult;if(!s||typeof s!="object"||Array.isArray(s))throw new Error("fixed result");let a=s;if(Object.keys(a).sort().join(",")!=="argsPolicy,structuredContent"||a.argsPolicy!=="empty-only"&&a.argsPolicy!=="ignore"||!a.structuredContent||typeof a.structuredContent!="object"||Array.isArray(a.structuredContent))throw new Error("fixed result");let p=ne(a.structuredContent);if(un(me(p))>4*1024)throw new Error("fixed result size")}}catch{throw new _("DEFINITION_UNSUPPORTED","UI legacy tool metadata is not projection-safe")}}function _n(e){if(!Array.isArray(e.allow)||e.allow.some(n=>!/^[A-Za-z0-9_]+(?:\.[A-Za-z0-9_]+)*$/.test(n)))throw new _("DEFINITION_UNSUPPORTED","UI projection policy is invalid")}function ki(e){return e.length>0&&e.length<=128&&e!=="*"&&e!=="all"&&!/[/*]/.test(e)}var Ui,_e=O(()=>{I();de();dn();Tn();Ui=/^[0-9a-f]{64}$/;});var ot=O(()=>{I();de();});var Ue,rt=O(()=>{I();Ue="window";});function c(e,n=e){throw new q(e,n)}function k(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;try{let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}catch{return false}}function D(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function w(e,n,t=[]){let i=new Set([...n,...t]);Object.keys(e).some(o=>!i.has(o))&&c("MANIFEST_INVALID"),n.some(o=>!D(e,o))&&c("MANIFEST_INVALID");}function $e(e,n=false,t=false,i=false){return vi.test(e)||!i&&Vi.test(e)||ji.test(e)||t&&st.test(e)||Fi.test(e)&&!(n&&/^\s*data:/i.test(e)&&!st.test(e))}function Je(e,n=new Set,t=0,i=false,o=false){if(typeof e=="string"){$e(e,i,o)&&c("UNSAFE_VALUE");return}if(!(e===null||typeof e!="object")){(t>8||n.has(e))&&c("MANIFEST_INVALID"),n.add(e);try{if(Array.isArray(e)){for(let r of e)Je(r,n,t+1);return}k(e)||c("MANIFEST_INVALID");for(let[r,s]of Object.entries(e))Je(s,n,t+1,i&&t===0&&(r==="name"||r==="description"),o);}finally{n.delete(e);}}}function K(e,n){let t=e[n];return typeof t!="string"&&c("MANIFEST_INVALID"),t}function W(e,n,t){let i=e[n];return (!Number.isSafeInteger(i)||i<t)&&c("MANIFEST_INVALID"),i}function Dn(e){return xi.test(e)||c("MANIFEST_INVALID"),e}function De(e){return wi.test(e)||c("TOKEN_INVALID"),e}function so(e){return At.test(e)||c("MANIFEST_INVALID"),e}function ao(e){k(e)||c("MANIFEST_INVALID");let n={};for(let[t,i]of Object.entries(e)){let o=so(t);k(i)||c("MANIFEST_INVALID");let r=i.type;if(r==="text"){w(i,["type","maxLength"]),n[o]={type:r,maxLength:W(i,"maxLength",1)};continue}if(r==="text-list"){w(i,["type","max","itemMaxLength"]),n[o]={type:r,max:W(i,"max",0),itemMaxLength:W(i,"itemMaxLength",1)};continue}if(r==="step-list"){w(i,["type","min","max","labelMaxLength","detailMaxLength"]);let s=W(i,"min",0),a=W(i,"max",1);s>a&&c("MANIFEST_INVALID"),n[o]={type:r,min:s,max:a,labelMaxLength:W(i,"labelMaxLength",1),detailMaxLength:W(i,"detailMaxLength",1)};continue}typeof r=="string"&&c("SCHEMA_TYPE_UNSUPPORTED"),c("MANIFEST_INVALID");}return n}function co(e,n,t){let i=e[n];(!i||i.type!==t)&&c("MANIFEST_INVALID");}function ze(e,n,t){let i=K(e,"field");return At.test(i)||c("MANIFEST_INVALID"),co(n,i,t),i}function po(e,n){k(e)||c("MANIFEST_INVALID");let t=e.primitive;switch(typeof t!="string"&&c("MANIFEST_INVALID"),ro.includes(t)||c("PRIMITIVE_UNKNOWN"),t){case "card-shell":return w(e,["primitive"]),{primitive:t};case "meta-banner":return w(e,["primitive","badgeToken","noticeToken"]),{primitive:t,badgeToken:De(K(e,"badgeToken")),noticeToken:De(K(e,"noticeToken"))};case "heading":return w(e,["primitive","field"]),{primitive:t,field:ze(e,n,"text")};case "labeled-text":return w(e,["primitive","titleToken","field","variant"]),e.variant!=="callout"&&c("MANIFEST_INVALID"),{primitive:t,titleToken:De(K(e,"titleToken")),field:ze(e,n,"text"),variant:"callout"};case "step-flow":return w(e,["primitive","titleToken","field"]),{primitive:t,titleToken:De(K(e,"titleToken")),field:ze(e,n,"step-list")};case "text-list":{w(e,["primitive","titleToken","field"],["emptyToken","hideWhenEmpty"]);let i={primitive:t,titleToken:De(K(e,"titleToken")),field:ze(e,n,"text-list")};return D(e,"emptyToken")&&(i.emptyToken=De(K(e,"emptyToken"))),D(e,"hideWhenEmpty")&&(typeof e.hideWhenEmpty!="boolean"&&c("MANIFEST_INVALID"),i.hideWhenEmpty=e.hideWhenEmpty),i}}return c("MANIFEST_INVALID")}function lo(e,n){return Array.isArray(e)||c("MANIFEST_INVALID"),e.map(t=>po(t,n))}function x(e="v2 manifest exceeds a contract limit"){return c("LIMIT_EXCEEDED",e)}function G(e="initial state is not projection-safe"){return c("INITIAL_STATE_INVALID",e)}function at(e,n){return (typeof e!="string"||e.length===0||e.length>4096||e.trim().length===0||to.test(e)||io.test(e))&&c("MANIFEST_INVALID",`${n} is invalid`),($e(e,true,true)||Bi.test(e)||Hi.test(e)||zi.test(e))&&c("UNSAFE_VALUE",`${n} contains an unsafe value`),e}function En(e,n){return (typeof e!="string"||!te.test(e))&&c("MANIFEST_INVALID",`${n} is invalid`),e}function uo(e){return (typeof e!="string"||!fn.test(e)||e==="*"||e==="all")&&c("MANIFEST_INVALID","action capability is invalid"),e}function It(e){return (typeof e!="string"||!no.test(e))&&c("MANIFEST_INVALID","resource hash is invalid"),e}function Nn(e,n=new Set,t=0){if(typeof e=="string"){e.length>4096&&x("v2 manifest string is too long");return}if(!(e===null||typeof e=="boolean")){if(typeof e=="number"){Number.isFinite(e)||c("MANIFEST_INVALID","v2 manifest contains a non-finite number");return}(e===void 0||typeof e=="function"||typeof e=="bigint")&&c("MANIFEST_INVALID","v2 manifest contains a non-JSON value"),typeof e!="object"&&c("MANIFEST_INVALID"),t>8&&x("v2 manifest nesting is too deep"),n.has(e)&&c("MANIFEST_INVALID","v2 manifest contains a cycle"),n.add(e);try{if(Array.isArray(e)){e.length>128&&x("v2 manifest array is too long");for(let i of e)Nn(i,n,t+1);return}k(e)||c("MANIFEST_INVALID","v2 manifest contains a non-plain object");for(let i of Object.values(e))Nn(i,n,t+1);}finally{n.delete(e);}}}function gt(e){return (typeof e!="string"||e.length>4096||!Se.test(e))&&(typeof e=="string"&&e.length>4096&&x("projection path is too long"),c("MANIFEST_INVALID","projection paths must be canonical exact paths")),e.split(".").some(t=>he(t))&&c("MANIFEST_INVALID","projection paths cannot address reserved state keys"),e}function bn(e){k(e)||c("MANIFEST_INVALID","projection policy must be an object"),w(e,["allow"]),Array.isArray(e.allow)||c("MANIFEST_INVALID","projection allow must be an array"),e.allow.length>128&&x("projection allowlist is too long");let n=[],t=new Set;for(let i of e.allow){let o=gt(i);t.has(o)&&c("MANIFEST_INVALID","projection allowlist contains a duplicate path"),t.add(o),n.push(o);}return {allow:n}}function fo(e,n){if(e===void 0)return;Array.isArray(e)||c("MANIFEST_INVALID","dataPaths must be an array"),e.length>oo&&x("dataPaths exceed the v2 limit");let t=[],i=new Set;for(let o of e){let r=gt(o);i.has(r)&&c("MANIFEST_INVALID","dataPaths contain a duplicate path"),n.some(s=>ge(r,s))||c("MANIFEST_INVALID","dataPaths must be projection-allowed"),i.add(r),t.push(r);}return t}function Ee(e,n,t=Number.MAX_SAFE_INTEGER){return (!Number.isSafeInteger(e)||e<0||e>t)&&c("MANIFEST_INVALID",`${n} is invalid`),e}function ct(e,n){return (typeof e!="number"||!Number.isFinite(e))&&c("MANIFEST_INVALID",`${n} is invalid`),e}function Pn(e,n=0,t=new Set){if(typeof e=="string")return (e.length>4096||$e(e))&&c("UNSAFE_VALUE","schema enum contains an unsafe string"),e;if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)||c("MANIFEST_INVALID","schema enum contains a non-finite number"),e;(n>8||typeof e!="object"||e===void 0)&&x("schema enum is too deep"),t.has(e)&&c("MANIFEST_INVALID","schema enum contains a cycle"),t.add(e);try{if(Array.isArray(e))return e.length>128&&x("schema enum array is too long"),e.map(o=>Pn(o,n+1,t));k(e)||c("MANIFEST_INVALID","schema enum contains a non-plain object");let i={};for(let[o,r]of Object.entries(e))he(o)&&c("MANIFEST_INVALID","schema enum contains a reserved key"),i[o]=Pn(r,n+1,t);return i}finally{t.delete(e);}}function yo(e,n){if(e===void 0)return;Array.isArray(e)||c("MANIFEST_INVALID","schema required must be an array"),e.length>64&&x("schema required list is too long");let t=[],i=new Set;for(let o of e)(typeof o!="string"||!Se.test(o))&&c("MANIFEST_INVALID","schema required contains an invalid key"),o.length>4096&&x("schema required key is too long"),i.has(o)&&c("MANIFEST_INVALID","schema required contains a duplicate key"),n&&!Object.prototype.hasOwnProperty.call(n,o)&&c("MANIFEST_INVALID","schema required references an undeclared property"),i.add(o),t.push(o);return t}function Ao(e,n){let t=n?Se:Be;return e.length>4096&&x("schema property name is too long"),(!t.test(e)||e.split(".").some(i=>he(i)))&&c("MANIFEST_INVALID","schema property name is invalid"),e}function Mn(e,n=0,t=false){k(e)||c("MANIFEST_INVALID","action inputSchema must be an object"),n>8&&x("action inputSchema is too deep");let i=e.type;i!=="object"&&i!=="string"&&i!=="number"&&i!=="integer"&&i!=="boolean"&&i!=="array"&&i!=="null"&&(typeof i=="string"&&c("SCHEMA_TYPE_UNSUPPORTED","action inputSchema type is unsupported"),c("MANIFEST_INVALID","action inputSchema type is required"));let o=["type","enum"];i==="string"&&o.push("minLength","maxLength"),i==="array"&&o.push("minItems","maxItems","items"),i==="object"&&o.push("minProperties","maxProperties","properties","required","additionalProperties"),(i==="number"||i==="integer")&&o.push("minimum","maximum"),w(e,["type"],o.filter(a=>a!=="type"));let r={type:i};if(D(e,"enum")&&(Array.isArray(e.enum)||c("MANIFEST_INVALID","schema enum must be an array"),e.enum.length>128&&x("schema enum is too long"),r.enum=e.enum.map(a=>Pn(a))),i==="string"&&(D(e,"minLength")&&(r.minLength=Ee(e.minLength,"schema minLength",4096)),D(e,"maxLength")&&(r.maxLength=Ee(e.maxLength,"schema maxLength",4096)),r.minLength!==void 0&&r.maxLength!==void 0&&r.minLength>r.maxLength&&c("MANIFEST_INVALID","schema string length bounds are inverted")),(i==="number"||i==="integer")&&(D(e,"minimum")&&(r.minimum=ct(e.minimum,"schema minimum")),D(e,"maximum")&&(r.maximum=ct(e.maximum,"schema maximum")),r.minimum!==void 0&&r.maximum!==void 0&&r.minimum>r.maximum&&c("MANIFEST_INVALID","schema numeric bounds are inverted")),i==="array"&&(D(e,"minItems")&&(r.minItems=Ee(e.minItems,"schema minItems",128)),D(e,"maxItems")&&(r.maxItems=Ee(e.maxItems,"schema maxItems",128)),r.minItems!==void 0&&r.maxItems!==void 0&&r.minItems>r.maxItems&&c("MANIFEST_INVALID","schema array length bounds are inverted"),D(e,"items")&&(r.items=Mn(e.items,n+1,false))),i==="object"){let a;if(D(e,"properties")){k(e.properties)||c("MANIFEST_INVALID","schema properties must be an object");let d=Object.entries(e.properties);d.length>64&&x("schema properties are too many"),a={};for(let[u,y]of d){let b=Ao(u,t);a[b]=Mn(y,n+1,false);}r.properties=a;}D(e,"minProperties")&&(r.minProperties=Ee(e.minProperties,"schema minProperties",64)),D(e,"maxProperties")&&(r.maxProperties=Ee(e.maxProperties,"schema maxProperties",64)),r.minProperties!==void 0&&r.maxProperties!==void 0&&r.minProperties>r.maxProperties&&c("MANIFEST_INVALID","schema object property bounds are inverted");let p=yo(e.required,a);p!==void 0&&(r.required=p),D(e,"additionalProperties")&&(e.additionalProperties!==false&&c("MANIFEST_INVALID","schema additionalProperties must be false"),r.additionalProperties=false);}let s=JSON.stringify(r);return (s===void 0||Buffer.byteLength(s,"utf8")>65536)&&x("action inputSchema subtree is too large"),r}function Io(e){let n=Mn(e,0,true);return (n.type!=="object"||!n.properties)&&c("MANIFEST_INVALID","action inputSchema must declare object properties"),n}function go(e){if(k(e)||c("MANIFEST_INVALID","action backend must be an object"),e.type==="core"){w(e,Ki);let n=e.handler;return (typeof n!="string"||!yn.test(n))&&c("MANIFEST_INVALID","core backend handler is invalid"),{type:"core",handler:n}}if(e.type==="skill"){w(e,qi,Zi),(!Array.isArray(e.command)||e.command.length===0||e.command.length>16)&&c("MANIFEST_INVALID","skill backend command is invalid");let n=[];for(let i of e.command)(typeof i!="string"||i.length===0||i.length>256||!An.test(i))&&c("MANIFEST_INVALID","skill backend command token is invalid"),n.push(i);let t=D(e,"env")?ho(e.env):void 0;return {type:"skill",command:n,...t===void 0?{}:{env:t}}}c("MANIFEST_INVALID","action backend type is unsupported");}function mo(e){k(e)||c("MANIFEST_INVALID","action must be an object"),w(e,$i,Xi),D(e,"_meta")&&mt(e._meta);let n=En(e.actionId,"actionId"),t=uo(e.capability),i=e.mutation;typeof i!="boolean"&&c("MANIFEST_INVALID","action mutation must be boolean");let o=Io(e.inputSchema),r;if(D(e,"dataInputs")){Array.isArray(e.dataInputs)||c("MANIFEST_INVALID","action dataInputs must be an array");let u=o.properties,y=new Set,b=[];for(let g of e.dataInputs)(typeof g!="string"||!D(u,g)||y.has(g))&&c("MANIFEST_INVALID","action dataInputs must be unique declared properties"),y.add(g),b.push(g);r=b;}let s=bn(e.resultProjection),a=go(e.backend),p;D(e,"content")&&((a.type!=="skill"||!He(e.content))&&c("MANIFEST_INVALID","action content declaration is invalid"),p=To(e.content));let d;if(D(e,"confirmation")){let u=e.confirmation;u!=="none"&&u!=="native"&&c("MANIFEST_INVALID","action confirmation is invalid"),d=u;}return {actionId:n,capability:t,mutation:i,inputSchema:o,resultProjection:s,backend:a,...p===void 0?{}:{content:p},...r===void 0?{}:{dataInputs:r},...d===void 0?{}:{confirmation:d}}}function ho(e){(!Array.isArray(e)||e.length===0)&&c("MANIFEST_INVALID","skill backend env is invalid");let n=new Set,t=[];for(let i of e)(i!=="CREWX_APP_INSTANCE_ID"&&i!=="CREWX_THREAD_ID"||n.has(i))&&c("MANIFEST_INVALID","skill backend env is invalid"),n.add(i),t.push(i);return Object.freeze(t)}function To(e){return Object.freeze({...e.in===void 0?{}:{in:Object.freeze({...e.in})},...e.out===void 0?{}:{out:Object.freeze({...e.out})}})}function _o(e){return k(e)||c("INITIAL_STATE_INVALID","initialState must be an object"),w(e,Qi,eo),e.path!=="ui/state.json"&&c("MANIFEST_INVALID","initialState path is not fixed"),D(e,"hash")?{path:"ui/state.json",hash:It(e.hash)}:{path:"ui/state.json"}}function Do(e){return (!k(e)||Object.keys(e).length!==1||!D(e,"wasm")||e.wasm!==true)&&c("MANIFEST_INVALID",'runtime must be exactly { "wasm": true }'),{wasm:true}}function Eo(e,n){Je(e,new Set,0,true,true),Nn(e),k(e)||c("MANIFEST_INVALID"),w(e,Ji,Wi),D(e,"_meta")&&mt(e._meta),e.manifestVersion!==2&&c("MANIFEST_INVALID");let t;D(e,"runtime")&&(t=Do(e.runtime));let i=En(e.pluginId,"pluginId"),o=En(e.definitionId,"definitionId"),r=W(e,"version",1),s=at(e.name,"name"),a=at(e.description,"description"),p;D(e,"icon")&&((typeof e.icon!="string"||!/^[a-z][a-z0-9-]{0,63}$/.test(e.icon))&&c("MANIFEST_INVALID","icon is invalid"),p=e.icon);let d;D(e,"tone")&&((typeof e.tone!="string"||!In.includes(e.tone))&&c("MANIFEST_INVALID","tone is invalid"),d=e.tone),e.entry!=="ui/index.html"&&c("MANIFEST_INVALID","entry path is not fixed");let u;D(e,"entryHash")&&(u=It(e.entryHash));let y;D(e,"initialState")&&(y=_o(e.initialState));let b;D(e,"usage")&&(e.usage!=="card"&&e.usage!=="window"&&c("MANIFEST_INVALID","usage is invalid"),b=e.usage);let g;D(e,"detailPanel")&&(typeof e.detailPanel!="boolean"&&c("MANIFEST_INVALID","detailPanel is invalid"),g=e.detailPanel);let f;if(D(e,"displayModes")){((b??Ue)!==Ue||!Array.isArray(e.displayModes)||e.displayModes.length===0)&&c("MANIFEST_INVALID","displayModes are only valid for window Apps");let M=new Set(["inline","floating","focused"]);(new Set(e.displayModes).size!==e.displayModes.length||e.displayModes.some(l=>typeof l!="string"||!M.has(l)))&&c("MANIFEST_INVALID","displayModes are invalid"),f=e.displayModes;}(b??Ue)===Ue&&g!==void 0&&c("MANIFEST_INVALID","detailPanel is card-only");let T=n.mode??"local";T!=="local"&&T!=="installed"&&T!=="published"&&c("MANIFEST_INVALID","manifest mode is invalid"),T!=="local"&&u===void 0&&c("MANIFEST_INVALID","installed manifests require entryHash"),T!=="local"&&y!==void 0&&y.hash===void 0&&c("MANIFEST_INVALID","installed manifests require initialState.hash"),(!Array.isArray(e.surfaces)||e.surfaces.length===0)&&c("MANIFEST_INVALID","surfaces are invalid"),e.surfaces.length>2&&x("surfaces exceed the v2 limit");let C=[],j=new Set;for(let M of e.surfaces)(typeof M!="string"||!gn.includes(M))&&c("MANIFEST_INVALID","surface is unsupported"),j.has(M)&&c("MANIFEST_INVALID","surfaces contain a duplicate"),j.add(M),C.push(M);k(e.size)||c("MANIFEST_INVALID","size must be an object"),w(e.size,["height"]);let m=W(e.size,"height",1);m>720&&x("size.height exceeds the v2 limit");let N=bn(e.stateProjection),S=e.summaryProjection===void 0?void 0:bn(e.summaryProjection);S!==void 0&&S.allow.some(M=>!N.allow.includes(M))&&c("MANIFEST_INVALID","summaryProjection must be a subset of stateProjection.allow");let H=fo(e.dataPaths,N.allow);Array.isArray(e.actions)||c("MANIFEST_INVALID","actions must be an array"),e.actions.length>32&&x("actions exceed the v2 limit");let v=[],X=new Set;for(let M of e.actions){let l=mo(M);if(X.has(l.actionId)&&c("MANIFEST_INVALID","actions contain a duplicate actionId"),l.backend.type==="core"&&l.backend.handler==="state.set"){l.mutation||c("MANIFEST_INVALID","state.set actions must be mutations");for(let P of Object.keys(l.inputSchema.properties))N.allow.includes(P)||c("MANIFEST_INVALID","state.set input paths must be projection-allowed");}X.add(l.actionId),v.push(l);}return {manifestVersion:2,pluginId:i,definitionId:o,version:r,name:s,description:a,...p===void 0?{}:{icon:p},...d===void 0?{}:{tone:d},entry:"ui/index.html",...u===void 0?{}:{entryHash:u},...t===void 0?{}:{runtime:t},...y===void 0?{}:{initialState:y},...b===void 0?{}:{usage:b},...g===void 0?{}:{detailPanel:g},...f===void 0?{}:{displayModes:f},surfaces:C,size:{height:m},stateProjection:N,...S===void 0?{}:{summaryProjection:S},...H===void 0?{}:{dataPaths:H},actions:v}}function mt(e){k(e)||c("MANIFEST_INVALID","_meta must be an object");let n=JSON.stringify(e);(n===void 0||Buffer.byteLength(n,"utf8")>Yi)&&x("_meta exceeds the 4 KiB limit");}function No(e){let n={},t={};for(let r of e.actions){n[r.actionId]={capabilities:[r.capability],inputKeys:Object.keys(r.inputSchema.properties??{}),...r.dataInputs===void 0?{}:{dataInputs:r.dataInputs},resultProjection:r.resultProjection,...r.confirmation===void 0?{}:{confirmation:r.confirmation},...r.content===void 0?{}:{content:r.content},...r.backend.type!=="skill"||r.backend.env===void 0?{}:{env:r.backend.env}};let s=r.backend.type==="skill"||r.backend.type==="core"&&r.backend.handler==="state.set";t[r.actionId]={actionId:r.actionId,mutation:r.mutation,backend:r.backend,launchPolicy:s?"allowed":"denied",...s?{}:{denialCode:"EXEC_DENIED"}};}let i={id:e.definitionId,version:e.version,renderer:"sandbox-html",...e.usage===void 0?{}:{usage:e.usage},...e.detailPanel===void 0?{}:{detailPanel:e.detailPanel},...e.displayModes===void 0?{}:{displayModes:e.displayModes},surfaces:e.surfaces,stateProjection:e.stateProjection,...e.summaryProjection===void 0?{}:{summaryProjection:e.summaryProjection},...e.dataPaths===void 0?{}:{dataPaths:e.dataPaths},actions:n},o={entry:{path:"ui/index.html",...e.entryHash===void 0?{}:{hash:e.entryHash}},...e.initialState===void 0?{}:{initialState:e.initialState}};return {manifest:e,definition:i,handlers:t,resources:o}}function Ln(e,n,t,i,o,r){if(typeof e=="string"){let s=o.length>0&&r.some(a=>ge(o.join("."),a));return (e.length>4096||$e(e,false,false,s))&&G("state contains an unsafe string"),e}if(e===null||typeof e=="boolean")return e;if(typeof e=="number")return Number.isFinite(e)||G("state contains a non-finite number"),e;(e===void 0||typeof e!="object"||typeof e=="function"||typeof e=="bigint")&&G("state contains a non-JSON value"),t>8&&G("state is too deep"),n.has(e)&&G("state contains a cycle"),n.add(e);try{let s;if(Array.isArray(e))e.length>128&&G("state array is too long"),s=e.map(p=>Ln(p,n,t+1,65536,o,r));else {k(e)||G("state contains a non-plain object");let p={};for(let[d,u]of Object.entries(e))(d.length>4096||!Be.test(d)||he(d))&&(d.length>4096&&G("state key is too long"),G("state contains a reserved or invalid key")),p[d]=Ln(u,n,t+1,65536,[...o,d],r);s=p;}let a=JSON.stringify(s);return (a===void 0||Buffer.byteLength(a,"utf8")>i)&&G("state subtree is too large"),s}finally{n.delete(e);}}function Sn(e,n=[]){k(e)||G("initial state must be a JSON object");let t=Ln(e,new Set,0,65536,[],n);return (t===null||Array.isArray(t)||typeof t!="object")&&G(),t}function bo(e,n={}){Je(e),k(e)||c("MANIFEST_INVALID"),w(e,Gi),e.manifestVersion!==1&&c("MANIFEST_INVALID");let t=Dn(K(e,"pluginId")),i=Dn(K(e,"definitionId")),o=W(e,"version",1),r=W(e,"primitiveSet",1),s=n.supportedPrimitiveSet??Ci;(!Number.isSafeInteger(s)||s<1)&&c("MANIFEST_INVALID"),r>s&&c("PRIMITIVE_SET_UNSUPPORTED"),k(e.activation)||c("MANIFEST_INVALID"),w(e.activation,["kind","language"]),e.activation.kind!=="fenced-code"&&c("MANIFEST_INVALID");let a=Dn(K(e.activation,"language")),p=ao(e.schema),d=lo(e.layout,p);return {manifestVersion:1,pluginId:t,definitionId:i,version:o,primitiveSet:r,activation:{kind:"fenced-code",language:a},schema:p,layout:d}}function Po(e,n={}){return k(e)||c("MANIFEST_INVALID"),Object.hasOwn(e,"lineage")&&c("MANIFEST_INVALID","lineage is only allowed in product bundle indexes"),e.manifestVersion===2?Eo(e,n):bo(e,n)}function Xe(e,n={}){try{return Po(e,n)}catch(t){if(t instanceof q)throw t;return c("MANIFEST_INVALID")}}function Un(e,n={}){let t=Xe(e,n);return t.manifestVersion===2?No(t):t}var Ci,wi,xi,At,vi,ji,Vi,Fi,st,Bi,Hi,zi,Gi,Ji,Wi,$i,Xi,Yi,Ki,qi,Zi,Qi,eo,no,to,io,oo,ro,q,ht=O(()=>{I();rt();de();Tn();Te();Ci=1,wi=/^[a-z][a-zA-Z0-9]*(\.[a-zA-Z0-9]+)+$/,xi=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/,At=/^[A-Za-z][A-Za-z0-9_-]{0,63}$/,vi=/<\/?[A-Za-z][^>]*>/,ji=/^(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)/,Vi=/^(?:https?|file|ftp|ws|wss):\/\//i,Fi=/^\s*(?:javascript|data):/i,st=/data:[^,\s]*,/i,Bi=/(?:https?|file|ftp|ws|wss):\/\//i,Hi=/javascript:/i,zi=/(?:^[\s]*|[\s"'(=])(?:[A-Za-z]:[\\/]|\\\\|~[\\/]|\/)(?=[^\s"'<>])[^\s"'<>]*/,Gi=["manifestVersion","pluginId","definitionId","version","primitiveSet","activation","schema","layout"],Ji=["manifestVersion","pluginId","definitionId","version","name","description","entry","surfaces","size","stateProjection","actions"],Wi=["_meta","icon","tone","entryHash","runtime","initialState","usage","detailPanel","displayModes","summaryProjection","dataPaths","focusedAiDataPaths"],$i=["actionId","capability","mutation","inputSchema","resultProjection","backend"],Xi=["confirmation","dataInputs","content","_meta"],Yi=4*1024,Ki=["type","handler"],qi=["type","command"],Zi=["env"],Qi=["path"],eo=["hash"],no=/^[0-9a-f]{64}$/,to=/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/,io=/[\r\n]/,oo=16,ro=["card-shell","meta-banner","heading","labeled-text","step-flow","text-list"],q=class extends Error{constructor(t,i=t){super(i);this.code=t;}code;name="UiPluginValidationError"};});var Tt=O(()=>{I();ot();ht();Te();});function qe(e,n=e){throw new re(e,n)}var re,Ze=O(()=>{I();re=class extends Error{constructor(t,i=t){super(i);this.code=t;}code;name="McpAppContractError"};});var _t=O(()=>{I();});var Dt=O(()=>{I();_e();de();Ze();_t();});function Et(e,n){return Mo.add(e),n!==void 0&&Lo.set(e,n),e}var Mo,Lo,Qe=O(()=>{I();Mo=new WeakSet,Lo=new WeakMap;});function ke(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Rn(e,n,t=[]){let i=new Set([...n,...t]),o=Object.keys(e);return n.every(r=>Object.hasOwn(e,r))&&o.every(r=>i.has(r))}function Pt(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;for(let n of Object.values(e))Pt(n);return Object.freeze(e)}function V(e){throw new Z("LINEAGE_INVALID",e)}function wo(e){throw new Z("LINEAGE_STALE",e)}function Mt(e){if(!ke(e)||!Rn(e,Uo,Ro)||!ke(e.actions))return V("Lineage definition shape is invalid");for(let n of Object.values(e.actions))if(!ke(n)||!Rn(n,ko,Co))return V("Lineage action definition shape is invalid");return e}function xo(e){if(!ke(e)||!Rn(e,Oo,So))return V("Lineage entry shape is invalid");if(!Number.isSafeInteger(e.version)||e.version<1||typeof e.hash!="string"||!Nt.test(e.hash))return V("Lineage entry identity is invalid");if(e.sourceHash!==void 0&&(typeof e.sourceHash!="string"||!Nt.test(e.sourceHash)))return V("Lineage source hash is invalid");if(e.compat!==void 0&&e.compat!=="break")return V("Lineage compatibility marker is invalid");let n=Mt(e.definition);if(n.version!==e.version)return V("Lineage version does not match its definition");if(e.sourceHash!==void 0&&n.sourceHash!==e.sourceHash)return V("Lineage source hash does not match its definition");let t;try{t=ie(n),oe({...n,hash:e.hash});}catch{return V("Lineage definition is invalid")}return t!==e.hash?V("Lineage definition hash does not match"):Pt({version:e.version,hash:e.hash,definition:n,...e.sourceHash===void 0?{}:{sourceHash:e.sourceHash},...e.compat===void 0?{}:{compat:e.compat}})}function bt(e){return e.stateProjection?.allow??[]}function vo(e,n){let t=[],i=new Set(bt(n));bt(e).some(a=>!i.has(a))&&t.push("S1_STATE_PROJECTION");let o=new Set(n.dataPaths??[]);(e.dataPaths??[]).some(a=>!o.has(a))&&t.push("S2_DATA_PATHS");for(let[a,p]of Object.entries(e.actions)){let d=n.actions[a];if(d&&(p.confirmation??"native")==="native"&&(d.confirmation??"native")!=="native"){t.push("S3_ACTION_CONFIRMATION");break}}Object.keys(e.legacy?.agentAccess??{}).some(a=>!Object.hasOwn(n.actions,a))&&t.push("S4_LEGACY_AGENT_ACTIONS");let s=e.summaryProjection?.allow;if(s!==void 0){let a=new Set(n.summaryProjection?.allow??[]);s.some(p=>!a.has(p))&&t.push("S5_SUMMARY_PROJECTION");}return t}function jo(e,n){return J(e)===J(n)}function kn(e,n){if(!Array.isArray(e)||e.length===0)return V("Definition lineage is missing");if(!ke(n)||typeof n.hash!="string")return V("Current definition is invalid");let t,i;try{let{hash:a,...p}=n;i=Mt(p),t={...i,hash:a},oe(t);}catch{return V("Current definition is invalid")}let o=e.map(xo),r=o[0].definition.id;if(o.some(a=>a.definition.id!==r))return V("Lineage definition ids do not match");if(o.some((a,p)=>p>0&&a.version<=o[p-1].version))return V("Lineage generations are not in increasing version order");if(o.some((a,p)=>o.findIndex(d=>d.hash===a.hash)!==p))return V("Lineage contains a duplicate hash");let s=o[o.length-1];if(s.version!==t.version||s.hash!==t.hash||s.definition.id!==t.id||!jo(s.definition,i))return wo("The last lineage generation does not match the current package");if(t.legacy!==void 0){let a=new Set(Object.keys(t.actions)),p=new Set;for(let u of o)if(u.sourceHash===void 0)for(let y of Object.keys(u.definition.actions))a.has(y)&&p.add(y);let d=Object.keys(t.legacy.agentAccess??{});if(d.length!==p.size||d.some(u=>!p.has(u))){let u="S4_LEGACY_AGENT_ACCESS_COMPLETE";throw new Z("LINEAGE_INVALID",`Lineage compatibility failed: ${u}`,[u])}}for(let a=0;a<o.length-1;a+=1){if(o.slice(a,-1).some(u=>u.compat==="break"))continue;let d=vo(o[a].definition,t);if(d.length>0)throw new Z("LINEAGE_INVALID",`Lineage compatibility failed: ${d.join(", ")}`,d)}return Object.freeze({entries:Object.freeze(o),current:t})}var Z,Nt,Oo,So,Uo,Ro,ko,Co,Cn=O(()=>{I();_e();de();Z=class extends Error{constructor(t,i=t,o=[]){super(i);this.code=t;this.violations=o;}code;violations;name="UiDefinitionLineageError"},Nt=/^[0-9a-f]{64}$/,Oo=["version","hash","definition"],So=["sourceHash","compat"],Uo=["id","version","actions"],Ro=["sourceHash","usage","detailPanel","displayModes","renderer","surfaces","stateProjection","dataPaths","summaryProjection","legacy"],ko=["capabilities"],Co=["inputKeys","dataInputs","confirmation","resultProjection","content","env"];});var Lt,Ot,St=O(()=>{I();Lt=["crewx_app_terminal_connect","crewx_app_html_viewer_open"],Ot=["crewx_listWorkspaces","crewx_queryAgent","crewx_executeAgent","crewx_getTaskResult","crewx_listTasks","crewx_listAgents","callBrowser","openTab","listTabs","closeTab"];});var Ut=O(()=>{I();_e();Qe();});function wn(e,n=0){try{let t=ne(e,n);return t.type!==void 0&&t.type!=="object"&&qe("TOOL_INVALID","MCP App inputSchema must describe an object"),t}catch(t){if(t instanceof re)throw t;qe("TOOL_INVALID","MCP App inputSchema must be projection-safe JSON");}}function Rt(e){if(e.length===0)return wn({type:"object",properties:{},additionalProperties:false});let n=e.map(i=>i.actionId),t=new Map;for(let i of e)t.set(i.actionId,wn(i.inputSchema));return wn(Bo(n,t),Fo)}function Bo(e,n){let t=e.map(i=>({type:"object",properties:{actionId:{type:"string",const:i},input:n.get(i)??{type:"object"}},required:["actionId","input"],additionalProperties:false}));return Object.freeze({type:"object",oneOf:Object.freeze(t),properties:Object.freeze({actionId:Object.freeze({type:"string",enum:Object.freeze([...e])}),input:Object.freeze({type:"object"})}),required:Object.freeze(["actionId","input"]),additionalProperties:false})}var Ce,Fo,xn=O(()=>{I();Dt();_e();de();Qe();Ze();Cn();St();Ut();Ce=8*1024*1024,new Set(Lt),new Set(Ot),Fo=4;});function se(e){let n=typeof e=="object"&&e!==null&&"code"in e?String(e.code):"";return n==="ENOENT"?new A("NOT_FOUND"):n==="ELOOP"?new A("PATH_ESCAPED"):n==="EFBIG"||n==="EOVERFLOW"?new A("LIMIT_EXCEEDED"):n==="EACCES"||n==="EPERM"||n==="ENOTDIR"?new A("READ_DENIED"):new A("READ_DENIED")}function $o(e){if(typeof e!="string"||e.length===0||!isAbsolute(e))throw new A("READ_DENIED")}function kt(e){if(typeof e!="string"||isAbsolute(e)||/[\\\u0000]/.test(e))throw new A("PATH_ESCAPED");if(e==="")return [];let n=e.split("/");if(n.some(t=>t.length===0||t==="."||t===".."))throw new A("PATH_ESCAPED");return n}function en(e,n){let t=relative(e,n);return t===""||t!==".."&&!t.startsWith(`..${sep}`)&&!isAbsolute(t)}function nn(e){return {dev:e.dev,ino:e.ino,size:e.size,mtimeNs:e.mtimeNs,ctimeNs:e.ctimeNs}}function Vn(e,n){return e.dev===n.dev&&e.ino===n.ino}function Vt(e,n){return Vn(e,n)&&e.size===n.size&&e.mtimeNs===n.mtimeNs&&e.ctimeNs===n.ctimeNs}async function Ct(e){$o(e);let n,t;try{n=await realpath(e),t=await stat(n,{bigint:!0});}catch(i){throw se(i)}if(!t.isDirectory())throw new A("READ_DENIED");return {realRoot:n,identity:nn(t)}}async function Xo(e,n,t){if(t.length<2||t[0]!=="apps"&&t[0]!=="skills")return;let i,o;try{if(i=resolve(e,t[0],t[1]),o=await realpath(i),!(await stat(o,{bigint:!0})).isDirectory())throw new A("READ_DENIED")}catch(r){throw r instanceof A?r:se(r)}if(!en(n,o))throw new A("PATH_ESCAPED");return o}async function wt(e,n,t,i){let o,r,s;try{o=await lstat(e,{bigint:!0}),r=await realpath(e),s=await stat(r,{bigint:!0});}catch(a){throw se(a)}if(!en(n,r)||t!==void 0&&!en(t,r))throw new A("PATH_ESCAPED");if(!o.isFile()||!s.isFile())throw new A("READ_DENIED");if(!Vn(i,o)||!Vn(i,s)||i.dev!==s.dev)throw new A("PATH_ESCAPED")}async function vn(e,n){let t,i;try{t=await realpath(e),i=await stat(t,{bigint:!0});}catch{throw new A("PATH_ESCAPED")}if(t!==n.realRoot||!Vt(n.identity,nn(i)))throw new A("PATH_ESCAPED")}function Yo(e){return e.isSymbolicLink()?{name:e.name,kind:"symlink"}:e.isDirectory()?{name:e.name,kind:"directory"}:e.isFile()?{name:e.name,kind:"file"}:{name:e.name,kind:"other"}}var A,jt,Jo,Wo,Pe,on,Ft,Bt,Bn=O(()=>{I();A=class extends Error{constructor(t){super(t);this.code=t;}code;name="AppDiscoveryFsError"},jt=constants.O_NOFOLLOW,Jo=constants.O_NONBLOCK,Wo=constants.O_RDONLY|(jt??0)|(Jo??0);Pe=class{async listDirectory(n,t){let i=kt(t),o=await Ct(n),r=resolve(n,...i),s,a;try{s=await realpath(r),a=await stat(s,{bigint:!0});}catch(p){let d=se(p);if(d.code==="NOT_FOUND")return [];throw d}if(!en(o.realRoot,s)||!a.isDirectory())throw new A("PATH_ESCAPED");try{let p=await readdir(s,{withFileTypes:!0,encoding:"utf8"});return await vn(n,o),p.map(Yo)}catch(p){let d=se(p);if(d.code==="NOT_FOUND")return [];throw d}}async readdir(n,t){return this.listDirectory(n,t)}async readDirectory(n,t){return this.listDirectory(n,t)}async readVerifiedFile(n,t,i){if(!Number.isSafeInteger(i)||i<0)throw new A("READ_DENIED");if(jt===void 0)throw new A("UNSUPPORTED");let o=kt(t),r=await Ct(n),s=resolve(n,...o),a=relative(n,s);if(a===".."||a.startsWith(`..${sep}`)||isAbsolute(a))throw new A("PATH_ESCAPED");let p;try{p=await open(s,Wo);}catch(d){throw se(d)}try{let d;try{let f=await p.stat({bigint:!0});d=nn(f);}catch(f){throw se(f)}if(d.size>BigInt(i))throw new A("LIMIT_EXCEEDED");if(d.size>BigInt(Number.MAX_SAFE_INTEGER))throw new A("LIMIT_EXCEEDED");await vn(n,r);let u=await Xo(n,r.realRoot,o);await wt(s,r.realRoot,u,d);let y=new Uint8Array(new ArrayBuffer(Number(d.size))),b=0;for(;b<y.byteLength;){let f;try{f=(await p.read(y,b,y.byteLength-b,b)).bytesRead;}catch(T){throw se(T)}if(f<=0)throw new A("IDENTITY_CHANGED");b+=f;}let g;try{let f=await p.stat({bigint:!0});g=nn(f);}catch(f){throw se(f)}if(!Vt(d,g))throw new A("IDENTITY_CHANGED");return await wt(s,r.realRoot,u,g),await vn(n,r),new Uint8Array(y)}finally{await p.close().catch(()=>{});}}async readFileVerified(n,t,i){return this.readVerifiedFile(n,t,i)}},on=new Pe,Ft=on,Bt=Pe;});function ve(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;try{let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}catch{return false}}function zt(e){return typeof e=="string"&&te.test(e)?e:void 0}function tr(e){return e.length>0&&e!=="."&&e!==".."&&!/[\\/\u0000]/.test(e)}function ye(e,n){let t=new TextEncoder().encode(e),i=new TextEncoder().encode(n),o=Math.min(t.byteLength,i.byteLength);for(let r=0;r<o;r+=1){let s=t[r]-i[r];if(s!==0)return s}return t.byteLength-i.byteLength}function ir(e){if(typeof e=="string")return {name:e,kind:"directory"};if(e===null||typeof e!="object")return null;let n=e;if(typeof n.name!="string")return null;if(n.kind==="file"||n.kind==="directory"||n.kind==="symlink"||n.kind==="other")return {name:n.name,kind:n.kind};if(n.type==="file"||n.type==="directory"||n.type==="symlink"||n.type==="other")return {name:n.name,kind:n.type};let t=n.isDirectory;if(typeof t=="function"&&t.call(e))return {name:n.name,kind:"directory"};let i=n.isSymbolicLink;if(typeof i=="function"&&i.call(e))return {name:n.name,kind:"symlink"};let o=n.isFile;return typeof o=="function"&&o.call(e)?{name:n.name,kind:"file"}:{name:n.name,kind:"other"}}function or(e){if(e instanceof Uint8Array)return new Uint8Array(e);if(e instanceof ArrayBuffer)return new Uint8Array(e.slice(0));if(Array.isArray(e)&&e.every(n=>Number.isInteger(n)&&n>=0&&n<=255))return Uint8Array.from(e);throw new TypeError("filesystem port returned an invalid byte array")}function rr(e){return er.decode(e)}function sr(e){return JSON.parse(rr(e))}function Gt(e){switch(e){case "ENOENT":return "NOT_FOUND";case "ELOOP":case "EXDEV":return "PATH_ESCAPED";case "EFBIG":case "EOVERFLOW":return "LIMIT_EXCEEDED";case "EACCES":case "EPERM":case "ENOTDIR":return "READ_DENIED";default:return e}}function ar(e){if(e instanceof A)return Gt(e.code);if(e!==null&&typeof e=="object"&&"code"in e){let n=e.code;if(typeof n=="string")return Gt(n)}}function ae(e,n){let t=n();return Number.isFinite(t)&&Number.isFinite(e)&&t-e<=5e3}function cr(e){if(typeof e.readVerifiedFile=="function")return e.readVerifiedFile;if(typeof e.readFileVerified=="function")return e.readFileVerified}function dr(e){if(typeof e.listDirectory=="function")return e.listDirectory;if(typeof e.readDirectory=="function")return e.readDirectory;if(typeof e.readdir=="function")return e.readdir}async function Jt(e,n,t,i){let o=cr(e);if(!o)throw new A("READ_DENIED");return or(await o.call(e,n,t,i))}async function Gn(e,n,t){let i=dr(e);if(!i)throw new A("READ_DENIED");let o=await i.call(e,n,t);if(!Array.isArray(o))throw new A("READ_DENIED");return o.map(ir).filter(r=>r!==null)}function pr(e,n,t,i){return Object.freeze({code:e,...{},source:n,relativePath:t})}function lr(e){if(!ve(e))throw new TypeError("productBundle.reservedIds must be an object with appIds and definitionIds arrays");try{let n=Reflect.ownKeys(e);if(n.length!==2||!n.includes("appIds")||!n.includes("definitionIds"))throw new TypeError("productBundle.reservedIds must contain exactly appIds and definitionIds");let t=(i,o)=>{if(!Array.isArray(i))throw new TypeError("productBundle.reservedIds."+o+" must be an array");let r=[];for(let s=0;s<i.length;s+=1){let a=i[s];if(typeof a!="string"||a.length===0)throw new TypeError("productBundle.reservedIds."+o+" must contain non-empty strings");r.push(a);}return Object.freeze([...new Set(r)].sort(ye))};return Object.freeze({appIds:t(e.appIds,"appIds"),definitionIds:t(e.definitionIds,"definitionIds")})}catch(n){throw n instanceof TypeError?n:new TypeError("productBundle.reservedIds must be a valid reservation object")}}function ur(e,n){return e.appIds.length===n.appIds.length&&e.appIds.every((t,i)=>t===n.appIds[i])&&e.definitionIds.length===n.definitionIds.length&&e.definitionIds.every((t,i)=>t===n.definitionIds[i])}function je(e){return Object.freeze({appIds:Object.freeze([...new Set(e.map(n=>n.appId))].sort(ye)),definitionIds:Object.freeze([...new Set(e.map(n=>n.definition.id))].sort(ye))})}function rn(e,n){let t=Object.keys(e).sort(ye),i=[...n].sort(ye);return t.length===i.length&&t.every((o,r)=>o===i[r])}function Wt(e){if(typeof e!="string"||e.length===0||e.startsWith("/")||/[\\\u0000]/.test(e))return;let n=e.split("/");if(!n.some(t=>t.length===0||t==="."||t===".."))return n}function fr(e){let n;try{n=sr(e);}catch{return}if(!ve(n)||!rn(n,["version","packages"])||n.version!==1||!Array.isArray(n.packages)||n.packages.length>Jn)return;let t=new Set,i=new Set,o=0,r=[];for(let s of n.packages){if(!ve(s))return;let a=["packageDir","appId","definition","files"],p=Object.hasOwn(s,"lineage"),d=Object.hasOwn(s,"launcher"),u=[...p?["lineage"]:[],...d?["launcher"]:[]];if(!rn(s,[...a,...u])||d&&s.launcher!==false)return;let y=Wt(s.packageDir),b=zt(s.appId);if(!y||y.length!==2||y[0]!=="apps"||!tr(y[1])||!b||t.has(s.packageDir)||!ve(s.definition)||!rn(s.definition,["id","version","hash"]))return;let g=zt(s.definition.id),f=s.definition.version,T=s.definition.hash;if(!g||!Number.isSafeInteger(f)||f<1||typeof T!="string"||!zn.test(T)||!Array.isArray(s.files)||s.files.length<2||s.files.length>Wn)return;let C=new Set,j=[];for(let m of s.files){if(!ve(m)||!rn(m,["path","sha256"]))return;let N=Wt(m.path);if(!N||typeof m.sha256!="string"||!zn.test(m.sha256))return;let S=N.join("/"),H=`${s.packageDir}/${S}`;if(C.has(S)||i.has(H))return;C.add(S),i.add(H),j.push(Object.freeze({path:S,sha256:m.sha256}));}if(!C.has("ui-plugin.json")||!C.has("ui/index.html")||(o+=j.length,o>qo))return;t.add(s.packageDir),r.push(Object.freeze({packageDir:s.packageDir,...d?{launcher:false}:{},appId:b,definition:Object.freeze({id:g,version:f,hash:T}),lineage:Array.isArray(s.lineage)?s.lineage:[],files:Object.freeze(j.sort((m,N)=>ye(m.path,N.path)))}));}return Object.freeze({version:1,packages:Object.freeze(r)})}function fe(e){let n=ar(e);return n==="PATH_ESCAPED"||n==="IDENTITY_CHANGED"||n==="TOCTOU"?"PATH_ESCAPED":n==="LIMIT_EXCEEDED"?"LIMIT_EXCEEDED":"BUNDLE_INTEGRITY"}async function yr(e,n,t,i,o){let r=[],s=async(a,p)=>{if(!ae(i,o))throw new A("LIMIT_EXCEEDED");if(p>2)throw new A("LIMIT_EXCEEDED");let d=await Gn(e,n,a);for(let u of d){if(typeof u.name!="string"||u.name.length===0||u.name==="."||u.name===".."||/[\\/\u0000]/.test(u.name))throw new A("PATH_ESCAPED");let y=`${a}/${u.name}`;if(u.kind==="file"){if(r.push(y.slice(t.length+1)),r.length>Wn)throw new A("LIMIT_EXCEEDED")}else if(u.kind==="directory")await s(y,p+1);else throw u.kind==="symlink"?new A("PATH_ESCAPED"):new A("READ_DENIED")}};return await s(t,0),r.sort(ye)}function Ar(e){return e==="ui-plugin.json"?262144:e==="ui/index.html"?Ce:e==="ui/state.json"?65536:e.startsWith("ui/assets/")?Qo:Zo}async function $t(e,n,t,i){if(e===void 0)return {packages:[],diagnostics:[],incomplete:false,reservedIds:nr};let o=lr(e.reservedIds),r=[],s=(l,P,F)=>pr(l,"bundled",P),a=(l=[],P=false,F)=>({...F===void 0?{}:{indexHash:F},packages:l,diagnostics:r,incomplete:P,reservedIds:o});if(typeof e.root!="string"||e.root.length===0||typeof e.expectedIndexHash!="string"||!zn.test(e.expectedIndexHash))return r.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a();let p;try{p=await Jt(n,e.root,"bundle-index.json",Ko);}catch(l){return r.push(s(fe(l),"bundle-index.json")),a()}let d=createHash("sha256").update(p).digest("hex");if(d!==e.expectedIndexHash)return r.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a();let u=fr(p);if(u===void 0)return r.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a();if(!ur(je(u.packages),o))return r.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a([],false,d);if(!ae(t,i))return r.push(s("LIMIT_EXCEEDED","bundle-index.json")),a(u.packages.map(l=>({indexEntry:l,failureCode:"LIMIT_EXCEEDED"})),true,d);let y;try{y=await Gn(n,e.root,"");}catch(l){return r.push(s(fe(l),"bundle-index.json")),a(u.packages.map(P=>({indexEntry:P,failureCode:fe(l)})),false,d)}if(!ae(t,i))return r.push(s("LIMIT_EXCEEDED","bundle-index.json")),a(u.packages.map(l=>({indexEntry:l,failureCode:"LIMIT_EXCEEDED"})),true,d);let b=y.find(l=>l.name==="bundle-index.json"&&l.kind==="file"),g=y.find(l=>l.name==="apps"&&l.kind==="directory"),f=l=>u.packages.map(P=>({indexEntry:P,failureCode:l}));if(!b)return r.push(s("BUNDLE_INTEGRITY","bundle-index.json")),a(f("BUNDLE_INTEGRITY"),false,d);let T=y.filter(l=>l.name!=="bundle-index.json"&&l.name!=="apps");if(T.length>0){let l=T.some(P=>P.kind==="symlink")?"PATH_ESCAPED":"BUNDLE_INTEGRITY";return r.push(s(l,"bundle-index.json")),a(f("BUNDLE_INTEGRITY"),false,d)}if(y.some(l=>l.name==="apps"&&l.kind!=="directory"))return r.push(s("PATH_ESCAPED","apps")),a(f("PATH_ESCAPED"),false,d);let C=[];if(g)try{C=await Gn(n,e.root,"apps");}catch(l){return r.push(s(fe(l),"apps")),a(f(fe(l)),false,d)}if(!ae(t,i)||C.length>Jn)return r.push(s("LIMIT_EXCEEDED","apps")),a(f("LIMIT_EXCEEDED"),true,d);let j=new Map(u.packages.map(l=>[l.packageDir.slice(5),l])),m=C.filter(l=>!j.has(l.name));for(let l of m)r.push(s(l.kind==="symlink"?"PATH_ESCAPED":"BUNDLE_INTEGRITY",`apps/${l.name}`));if(m.length>0){let l=m.some(P=>P.kind==="symlink")?"PATH_ESCAPED":"BUNDLE_INTEGRITY";return a(f(l),false,d)}let N=new Set,S=new Map,H=new Map;for(let l of u.packages){let P=S.get(l.appId)??[];P.push(l),S.set(l.appId,P);let F=`${l.definition.id}\0${String(l.definition.version)}`,h=H.get(F)??[];h.push(l),H.set(F,h);}for(let l of [...S.values(),...H.values()])if(l.length>1)for(let P of l)N.add(P);let v=[],X=p.byteLength,M=false;for(let l of u.packages){if(!ae(t,i)){M=true,v.push({indexEntry:l,failureCode:"LIMIT_EXCEEDED"});continue}let P;try{let L=l.lineage[l.lineage.length-1];if(!L)throw new Z("LINEAGE_INVALID","Definition lineage is missing");if(L.definition.id!==l.definition.id||L.version!==l.definition.version||L.hash!==l.definition.hash)throw new Z("LINEAGE_STALE","Last lineage generation does not match bundle identity");P=kn(l.lineage,{...L.definition,hash:L.hash}).entries;}catch(L){let Q=L instanceof Z?L.code:"LINEAGE_INVALID";r.push(s(Q,l.packageDir)),v.push({indexEntry:l,failureCode:Q});continue}let F=C.find(L=>L.name===l.packageDir.slice(5));if(!g||!F){v.push({indexEntry:l,failureCode:"BUNDLE_INTEGRITY"});continue}if(F.kind!=="directory"){v.push({indexEntry:l,failureCode:F.kind==="symlink"?"PATH_ESCAPED":"BUNDLE_INTEGRITY"});continue}let h;try{let L=await yr(n,e.root,l.packageDir,t,i);if(!ae(t,i)){M=!0,v.push({indexEntry:l,failureCode:"LIMIT_EXCEEDED"});continue}let Q=l.files.map(Y=>Y.path);if(L.length!==Q.length||L.some((Y,pe)=>Y!==Q[pe])){v.push({indexEntry:l,failureCode:"BUNDLE_INTEGRITY"});continue}h=new Map;let ee;for(let Y of l.files){if(!ae(t,i)){ee="LIMIT_EXCEEDED",M=!0;break}if(X>=Hn){ee="LIMIT_EXCEEDED";break}let pe;try{pe=await Jt(n,e.root,`${l.packageDir}/${Y.path}`,Ar(Y.path));}catch(fi){ee=fe(fi);break}if(!ae(t,i)){ee="LIMIT_EXCEEDED",M=!0;break}if(X+pe.byteLength>Hn){X=Hn,ee="LIMIT_EXCEEDED";break}if(X+=pe.byteLength,createHash("sha256").update(pe).digest("hex")!==Y.sha256){ee="BUNDLE_INTEGRITY";break}h.set(Y.path,pe);}if(ee!==void 0){v.push({indexEntry:l,failureCode:ee});continue}}catch(L){ae(t,i)||(M=true),v.push({indexEntry:l,failureCode:fe(L)});continue}v.push({indexEntry:l,lineage:P,files:h,...N.has(l)?{failureCode:"DUPLICATE_ID"}:{}});}return a(v,M,d)}var Ko,Jn,Wn,qo,Zo,Qo,Hn,zn,er,nr,$n=O(()=>{I();Cn();Te();xn();Bn();Ko=256*1024,Jn=64,Wn=128,qo=Jn*Wn,Zo=2*1024*1024,Qo=8*1024*1024,Hn=32*1024*1024,zn=/^[0-9a-f]{64}$/,er=new TextDecoder("utf-8",{fatal:true}),nr=Object.freeze({appIds:Object.freeze([]),definitionIds:Object.freeze([])});});var si={};Ai(si,{AppDiscoveryFsError:()=>A,LOCAL_APP_TOOL_PREFIX:()=>gr,MCP_APP_WORKSPACE_TOOL_PREFIX:()=>mr,NodeAppDiscoveryFs:()=>Pe,NodeAppDiscoveryFsAdapter:()=>Bt,WORKSPACE_APP_TOOL_PREFIX:()=>Le,defaultAppDiscoveryFs:()=>on,defaultNodeAppDiscoveryFs:()=>Ft,deriveWorkspaceAppToolName:()=>hr,deriveWorkspaceAppToolNames:()=>qn,discoverWorkspaceAppCandidates:()=>Jr,discoverWorkspaceApps:()=>Qn,productAppBundleReservations:()=>je,scanWorkspaceApps:()=>Wr});function qn(e){if(typeof e!="string"||!te.test(e))throw new TypeError("pluginId must be a safe UI plugin identifier");let n=`${Le}${e}`.length+7<=128?e:`hash_${createHash("sha256").update(e,"utf8").digest("hex")}`;return {read:`${Le}${n}_read`,action:`${Le}${n}_action`}}function hr(e,n="read"){let t=qn(e);return n==="read"?t.read:t.action}function Ve(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;try{let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}catch{return false}}function Yt(e){return typeof e=="string"&&te.test(e)?e:void 0}function _r(e,n){return n.length===0||n==="."||n===".."||/[\\/\u0000]/.test(n)?e==="skills"?"skills":"apps":`${e==="skills"?"skills":"apps"}/${n}`}function Dr(e){return e.length>0&&e!=="."&&e!==".."&&!/[\\/\u0000]/.test(e)}function ni(e,n){let t=new TextEncoder().encode(e),i=new TextEncoder().encode(n),o=Math.min(t.byteLength,i.byteLength);for(let r=0;r<o;r+=1){let s=t[r]-i[r];if(s!==0)return s}return t.byteLength-i.byteLength}function Er(e){if(typeof e=="string")return {name:e,kind:"directory"};if(e===null||typeof e!="object")return null;let n=e;if(typeof n.name!="string")return null;if(n.kind==="file"||n.kind==="directory"||n.kind==="symlink"||n.kind==="other")return {name:n.name,kind:n.kind};if(n.type==="file"||n.type==="directory"||n.type==="symlink"||n.type==="other")return {name:n.name,kind:n.type};let t=n.isDirectory;if(typeof t=="function"&&t.call(e))return {name:n.name,kind:"directory"};let i=n.isSymbolicLink;if(typeof i=="function"&&i.call(e))return {name:n.name,kind:"symlink"};let o=n.isFile;return typeof o=="function"&&o.call(e)?{name:n.name,kind:"file"}:{name:n.name,kind:"other"}}function Nr(e){if(e instanceof Uint8Array)return new Uint8Array(e);if(e instanceof ArrayBuffer)return new Uint8Array(e.slice(0));if(Array.isArray(e)&&e.every(n=>Number.isInteger(n)&&n>=0&&n<=255))return Uint8Array.from(e);throw new TypeError("filesystem port returned an invalid byte array")}function ti(e){return Tr.decode(e)}function ii(e){return JSON.parse(ti(e))}function br(e){if(!Ve(e))return;let n=Yt(e.pluginId);if(!n)return;let t=Yt(e.definitionId),i=e.version,o=t&&Number.isSafeInteger(i)&&i>=1?`${t}\0${String(i)}`:void 0;return {pluginId:n,...o===void 0?{}:{definitionKey:o}}}function Pr(e){let n=ii(e);return {value:n,identity:br(n)}}function Zn(e,n,t,i){let o={code:e,...i===void 0?{}:{pluginId:i},source:n,relativePath:t};return Object.freeze(o)}function Kt(e){switch(e){case "ENOENT":return "NOT_FOUND";case "ELOOP":case "EXDEV":return "PATH_ESCAPED";case "EFBIG":case "EOVERFLOW":return "LIMIT_EXCEEDED";case "EACCES":case "EPERM":case "ENOTDIR":return "READ_DENIED";default:return e}}function Ae(e){if(e instanceof A)return Kt(e.code);if(e!==null&&typeof e=="object"&&"code"in e){let n=e.code;if(typeof n=="string")return Kt(n)}}function Fe(e,n){return e==="PATH_ESCAPED"||e==="IDENTITY_CHANGED"||e==="TOCTOU"?"PATH_ESCAPED":e==="LIMIT_EXCEEDED"?"LIMIT_EXCEEDED":n==="manifest"&&e==="NOT_FOUND"?"MANIFEST_MISSING":n==="entry"?"ENTRY_INVALID":n==="initial"?"INITIAL_STATE_INVALID":"MANIFEST_INVALID"}function qt(e){switch(e.code){case "MANIFEST_INVALID":case "PRIMITIVE_UNKNOWN":case "PRIMITIVE_SET_UNSUPPORTED":case "SCHEMA_TYPE_UNSUPPORTED":case "TOKEN_INVALID":case "UNSAFE_VALUE":return "MANIFEST_INVALID";case "LIMIT_EXCEEDED":return "LIMIT_EXCEEDED";case "INITIAL_STATE_INVALID":return "INITIAL_STATE_INVALID";default:return oi("UiPluginValidationError",e.code)}}function oi(e,n){throw new Error(`Unmapped ${e} code: ${String(n)}`)}function Xn(e){switch(e){case "APP_ID_INVALID":case "TOOL_ID_INVALID":case "RESOURCE_URI_INVALID":case "TOOL_INVALID":case "SERIALIZATION_INVALID":return "MANIFEST_INVALID";case "APP_ID_CONFLICT":case "TOOL_ID_CONFLICT":return "DUPLICATE_ID";case "RESOURCE_NOT_FOUND":case "HTML_INVALID":return "ENTRY_INVALID";case "STATE_INVALID":case "STATE_PROJECTION_INVALID":case "BUTTON_INVALID":return "INITIAL_STATE_INVALID";default:return oi("McpAppContractError",e)}}function Yn(e,n){let t=n();return Number.isFinite(t)&&Number.isFinite(e)&&t-e<=5e3}function Mr(e){return {pluginId:e.appId,definitionKey:`${e.definition.id}\0${String(e.definition.version)}`}}function Lr(e,n){let t=n.get("package.json");if(t!==void 0)try{let o=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(t));if(Ve(o)){let r=o.bin,s=typeof r=="string"?r:Ve(r)?Object.values(r).find(a=>typeof a=="string"):void 0;for(let a of [s,o.main]){if(typeof a!="string")continue;let p=Or(a);if(p&&n.has(p))return p}}}catch{}return [`${e.slice(e.lastIndexOf("/")+1)}.js`,"index.js","main.js"].find(o=>n.has(o))}function Or(e){if(e.startsWith("/")||e.includes("\\")||e.includes("\0"))return;let n=e.split("/").filter(t=>t!==".");if(!(n.length===0||n.some(t=>t.length===0||t==="..")))return n.join("/")}function Sr(){return globalThis.performance?.now()??Date.now()}function Me(e){if(e===null||typeof e!="object"||Object.isFrozen(e))return e;for(let n of Object.values(e))Me(n);return Object.freeze(e)}function Zt(e){return Object.freeze(Array.from(e))}async function Kn(e,n,t,i){if(n.pinnedFiles!==void 0){let o=n.pinnedFiles.get(t);if(o===void 0)throw new A("NOT_FOUND");if(o.byteLength>i)throw new A("LIMIT_EXCEEDED");return new Uint8Array(o)}return ri(e,n.root,`${n.relativePath}/${t}`,i)}function Ur(e,n,t){let i=createHash("sha256"),o=new TextEncoder().encode(J(e)),r=s=>{let a=new Uint8Array(8);new DataView(a.buffer).setBigUint64(0,BigInt(s)),i.update(a);};return r(o.byteLength),i.update(o),r(n.byteLength),i.update(n),r(t.byteLength),i.update(t),i.digest("hex")}function Rr(e,n){let t={...e.definition,sourceHash:n},i={...t,hash:ie(t)};try{oe(i);}catch{throw new q("MANIFEST_INVALID","normalized definition is invalid")}return i}function kr(e){return e.actions.some(n=>n.backend.type==="core"&&n.backend.handler!=="state.set")}function Cr(e){if(typeof e.readVerifiedFile=="function")return e.readVerifiedFile;if(typeof e.readFileVerified=="function")return e.readFileVerified}function wr(e){if(typeof e.listDirectory=="function")return e.listDirectory;if(typeof e.readDirectory=="function")return e.readDirectory;if(typeof e.readdir=="function")return e.readdir}async function ri(e,n,t,i){let o=Cr(e);if(!o)throw new A("READ_DENIED");return Nr(await o.call(e,n,t,i))}async function xr(e,n,t){let i=wr(e);if(!i)throw new A("READ_DENIED");let o=await i.call(e,n,t);if(!Array.isArray(o))throw new A("READ_DENIED");return o.map(Er).filter(r=>r!==null)}function vr(e){let n=[];for(let t of [e.reserved,e.builtin])t&&n.push(t);return e.builtins&&"listMcpApps"in e.builtins?n.push(Qt(e.builtins)):e.builtins&&n.push(e.builtins),e.builtinCatalog&&n.push(Qt(e.builtinCatalog)),n.push({...e.reservedAppIds===void 0?{}:{appIds:e.reservedAppIds},...e.reservedDefinitionIds===void 0?{}:{definitionIds:e.reservedDefinitionIds},...e.reservedToolNames===void 0?{}:{toolNames:e.reservedToolNames}}),n}function Qt(e){let n=[],t=[],i=[];for(let o of e.listMcpApps())typeof o.appId=="string"&&n.push(o.appId),o.definition&&typeof o.definition.id=="string"&&t.push(o.definition.id);for(let o of e.listMcpAppTools())typeof o.name=="string"&&i.push(o.name);return {appIds:n,definitionIds:t,toolNames:i}}function ce(e,n){e.diagnostic||(e.diagnostic=Zn(n,e.source,e.relativePath,e.identity?.pluginId));}function jr(e){let n=new Map;for(let i of e){let o=i.identity?.pluginId;if(o===void 0)continue;let r=n.get(o)??[];r.push(i),n.set(o,r);}for(let i of n.values()){if(i.length<2)continue;let o=i.filter(s=>s.provenance!==void 0);if(o.length>0){for(let s of i)s.provenance===void 0&&ce(s,"RESERVED_ID");if(o.length>1)for(let s of o)ce(s,"DUPLICATE_ID");continue}let r=i.filter(s=>s.source==="apps");if(r.length>1){for(let s of r)ce(s,"DUPLICATE_ID");for(let s of i.filter(a=>a.source==="skills"))ce(s,"DUPLICATE_ID");}else for(let s of i.filter(a=>a.source==="skills"))ce(s,"DUPLICATE_ID");}let t=new Map;for(let i of e){if(i.diagnostic?.code==="RESERVED_ID")continue;let o=i.identity?.definitionKey;if(o===void 0)continue;let r=t.get(o)??[];r.push(i),t.set(o,r);}for(let i of t.values())if(i.length>1)for(let o of i)ce(o,"DUPLICATE_ID");}function Vr(e,n,t){let i=new Set,o=new Set,r=new Set,s=new Set(t.appIds),a=new Set(t.definitionIds);for(let p of vr(n)){for(let d of p.appIds??[])typeof d=="string"&&i.add(d);for(let d of p.definitionIds??[])typeof d=="string"&&o.add(d);for(let d of p.toolNames??[])typeof d=="string"&&r.add(d);}for(let p of e){let d=p.candidate;if(!d)continue;if(i.has(d.pluginId)||o.has(d.definitionId)){ce(p,"RESERVED_ID");continue}if(p.provenance===void 0&&(s.has(d.pluginId)||a.has(d.definitionId))){ce(p,"RESERVED_ID");continue}[d.toolNames.read,d.toolNames.action].filter(y=>y!==void 0).some(y=>r.has(y))&&ce(p,"DUPLICATE_ID");}}function Fr(e){return [...e].sort((n,t)=>{let i=Xt.indexOf(n.source)-Xt.indexOf(t.source);return i!==0?i:ni(n.relativePath,t.relativePath)})}function E(e,n){e.diagnostic=Zn(n,e.source,e.relativePath,e.identity?.pluginId);}async function ei(e,n,t){if(t.byteLength>262144){E(n,"LIMIT_EXCEEDED");return}let i;try{i=Pr(t);}catch{E(n,"MANIFEST_INVALID");return}if(n.bundleIdentity===void 0)n.identity=i.identity;else if(i.identity?.pluginId!==n.bundleIdentity.appId||i.identity.definitionKey!==`${n.bundleIdentity.definitionId}\0${String(n.bundleIdentity.version)}`){E(n,"BUNDLE_INTEGRITY");return}if(Ve(i.value)&&i.value.builtinOnly===true){E(n,"RESERVED_ID");return}let o;try{let h=Xe(i.value,{mode:"local"});if(h.manifestVersion!==2)throw new q("MANIFEST_INVALID","workspace App requires v2");o=h;}catch(h){if(h instanceof q){E(n,qt(h));return}if(h instanceof re){E(n,Xn(h.code));return}if(Ve(h)&&typeof h.code=="string"){E(n,Xn(h.code));return}throw h}let r={pluginId:o.pluginId,definitionKey:`${o.definitionId}\0${String(o.version)}`};if(n.bundleIdentity===void 0&&(n.identity=r),o.actions.length>0)try{Rt(o.actions.map(h=>({actionId:h.actionId,inputSchema:h.inputSchema})));}catch(h){if(h instanceof re){E(n,Xn(h.code));return}throw h}let s;try{s=await Kn(e,n,"ui/index.html",Ce);}catch(h){E(n,Fe(Ae(h),"entry"));return}if(s.byteLength>Ce){E(n,"LIMIT_EXCEEDED");return}let a;try{a=ti(s);}catch{E(n,"ENTRY_INVALID");return}if(s.byteLength===0||a.length===0){E(n,"ENTRY_INVALID");return}let p=createHash("sha256").update(s).digest("hex");if(o.entryHash!==void 0&&o.entryHash!==p){E(n,"ENTRY_INVALID");return}let d={},u,y;if(o.initialState!==void 0){try{u=await Kn(e,n,"ui/state.json",65536);}catch(h){E(n,Fe(Ae(h),"initial"));return}if(u.byteLength>65536){E(n,"LIMIT_EXCEEDED");return}try{let h=ii(u),L=o.dataPaths??[],Q=Sn(h,L);d=ne(Q,0,L),me(d);}catch{E(n,"INITIAL_STATE_INVALID");return}if(y=createHash("sha256").update(u).digest("hex"),o.initialState.hash!==void 0&&o.initialState.hash!==y){E(n,"INITIAL_STATE_INVALID");return}}let b={...o,entryHash:p,...o.initialState===void 0?{}:{initialState:{path:"ui/state.json",hash:y}}},g=Un(b),f=Ur(b,s,u??new Uint8Array),T;try{T=Rr(g,f);}catch(h){if(h instanceof q){E(n,qt(h));return}throw h}let C;if(n.bundleLineage!==void 0){let h=n.bundleLineage[n.bundleLineage.length-1];if(!h){E(n,"LINEAGE_INVALID");return}let{legacy:L,...Q}=h.definition,{hash:ee,...Y}=T;if(J(Q)!==J(Y)){E(n,"LINEAGE_STALE");return}if(L!==void 0&&(T={...T,legacy:L}),L!==void 0)try{T={...T,hash:ie(T)},oe(T);}catch{E(n,"LINEAGE_INVALID");return}C=n.bundleLineage;}if(n.bundleIdentity!==void 0&&n.bundleIdentity.appId!==o.pluginId){E(n,"BUNDLE_INTEGRITY");return}if(n.bundleIdentity!==void 0&&(n.bundleIdentity.definitionId!==T.id||n.bundleIdentity.version!==T.version||n.bundleIdentity.definitionHash!==T.hash)){E(n,"LINEAGE_STALE");return}let j=qn(o.pluginId),m=o.actions.length===0?{read:j.read}:j,N=Me(g),S=Me(b),H=Me(T),v=Me({...g.handlers}),X=Zt(s),M=u===void 0?void 0:Zt(u),l=Object.freeze({...n.provenance===void 0?{}:{provenance:n.provenance},entry:Object.freeze({path:"ui/index.html",hash:p,bytes:X}),...M===void 0?{}:{initialState:Object.freeze({path:"ui/state.json",hash:y,bytes:M})}}),P={appId:o.pluginId,pluginId:o.pluginId,definitionId:o.definitionId,version:o.version,relativePath:n.relativePath,manifest:S,normalized:N,name:o.name,description:o.description,...o.icon===void 0?{}:{icon:o.icon},...o.tone===void 0?{}:{tone:o.tone},definition:H,handlers:v,resources:l,html:a,entryBytes:X,entryHash:p,initialState:Me(d),...M===void 0?{}:{initialStateBytes:M},...y===void 0?{}:{initialStateHash:y},sourceHash:f,toolNames:Object.freeze(m)},F=n.provenance===void 0?{...P,source:n.source}:{...P,provenance:n.provenance,lineage:C??[]};n.candidate=Object.freeze(F),kr(o)&&E(n,"EXEC_DENIED");}async function Br(e,n){try{return await Kn(e,n,"ui-plugin.json",262144)}catch(t){if(Ae(t)==="NOT_FOUND")return;E(n,Fe(Ae(t),"manifest"));return}}function Hr(e,n,t,i=Ir,o=false){let r=Fr(e);jr(r);let s=Object.freeze(r.filter(u=>u.candidate!==void 0&&u.diagnostic===void 0).map(u=>u.candidate)),a=Object.freeze(r.filter(u=>u.diagnostic!==void 0).map(u=>u.diagnostic)),p=o?Object.freeze({...t===void 0?{}:{indexHash:t},diagnostics:Object.freeze(a.filter(u=>u.source==="bundled").map(u=>Object.freeze({...u}))),reservedAppIds:Object.freeze([...i.appIds]),reservedDefinitionIds:Object.freeze([...i.definitionIds])}):void 0,d={apps:s,diagnostics:a,complete:n===void 0,...n===void 0?{}:{incompleteReason:n},...t===void 0?{}:{productBundleIndexHash:t},...p===void 0?{}:{productBundleSnapshotMetadata:p}};return Object.defineProperty(d,"candidates",{configurable:false,enumerable:false,get:()=>s}),Object.freeze(d)}function zr(e){if(e===null||typeof e!="object"&&typeof e!="function")return false;let n=e;return typeof n.readVerifiedFile=="function"||typeof n.readFileVerified=="function"||typeof n.listDirectory=="function"||typeof n.readDirectory=="function"||typeof n.readdir=="function"}function Gr(e,n){if(zr(e))return {fs:e,options:n??{}};let t=e??n??{};return {fs:t.filesystem??t.fileSystem??t.fs??on,options:t}}async function Qn(e,n,t){if(typeof e!="string"||e.length===0)throw new TypeError("workspaceRoot must be explicit");let{fs:i,options:o}=Gr(n,t),r=o.clock??Sr,s=r(),a=[],p=0,d,u=await $t(o.productBundle,i,s,r);a.push(...u.diagnostics.map(g=>({source:g.source,root:o.productBundle?.root??e,name:"",relativePath:g.relativePath,diagnostic:g})));let y=u.reservedIds;u.incomplete&&(d="time_limit");for(let g of u.packages){let f=g.indexEntry,T=f.packageDir,C=g.files===void 0?void 0:Lr(T,g.files),j=u.indexHash===void 0?void 0:Et(Object.freeze({kind:"bundled",launcher:f.launcher!==false,indexHash:u.indexHash,packageDir:T,appId:f.appId,definitionId:f.definition.id,version:f.definition.version,definitionHash:f.definition.hash,files:f.files}),C),m={source:"bundled",root:o.productBundle?.root??e,name:T.slice(5),relativePath:T,...j===void 0?{}:{provenance:j},...g.files===void 0?{}:{pinnedFiles:g.files},...g.lineage===void 0?{}:{bundleLineage:g.lineage},bundleIdentity:{appId:f.appId,definitionId:f.definition.id,version:f.definition.version,definitionHash:f.definition.hash},identity:Mr(f)};if(a.push(m),p+=1,g.failureCode!==void 0){E(m,g.failureCode);continue}let N=g.files?.get("ui-plugin.json");if(N===void 0){E(m,"BUNDLE_INTEGRITY");continue}await ei(i,m,N),m.candidate!==void 0&&m.diagnostic===void 0&&p<64&&!Yn(s,r)&&(d="time_limit");}let b=[{source:"apps",directory:"apps"},{source:"skills",directory:"skills"}];for(let g of b){let{source:f,directory:T}=g,C;try{C=await xr(i,e,T);}catch(m){if(Ae(m)==="NOT_FOUND")continue;a.push({source:f,root:e,name:"",relativePath:f,diagnostic:Zn(Fe(Ae(m),"manifest"),f,f)});continue}let j=C.filter(m=>m.kind==="directory"||m.kind==="symlink").filter(m=>Dr(m.name)).map(m=>({source:f,root:e,name:m.name,relativePath:_r(f,m.name)})).sort((m,N)=>ni(m.relativePath,N.relativePath));for(let m of j){let N={...m};a.push(N);let S;if(f==="skills"&&(S=await Br(i,N),S===void 0))continue;if(p>=64){E(N,"LIMIT_EXCEEDED");continue}if(m.relativePath.split("/").length-1>2){E(N,"LIMIT_EXCEEDED");continue}if(d!==void 0||!Yn(s,r)){E(N,"LIMIT_EXCEEDED"),d="time_limit";continue}if(p+=1,S===void 0)try{S=await ri(i,N.root,`${N.relativePath}/ui-plugin.json`,262144);}catch(v){E(N,Fe(Ae(v),"manifest"));continue}await ei(i,N,S),N.diagnostic===void 0&&p<64&&!Yn(s,r)&&(d="time_limit");}}return Vr(a,o,y),Hr(a,d,u.indexHash,y,o.productBundle!==void 0)}var Ir,Le,gr,mr,Xt,Tr,Jr,Wr,ai=O(()=>{I();_e();de();Tt();Te();xn();Ze();Bn();Qe();$n();$n();Ir=je([]),Le="crewx_local_app_",gr=Le,mr=Le;Xt=["bundled","apps","skills"],Tr=new TextDecoder("utf-8",{fatal:true});Jr=Qn,Wr=Qn;});I();var ci="SKILL.md",qr=/^---\s*\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/;function di(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function Zr(e){return e.isDirectory()||e.isSymbolicLink()}function ui(e){try{return existsSync(e)&&statSync(e).isDirectory()}catch{return false}}var Qr=["index.js","main.js"];function Nc(e,n){let t=join(e,"package.json");if(existsSync(t))try{let o=JSON.parse(readFileSync(t,"utf8"));if(o.bin){let r=typeof o.bin=="string"?o.bin:Object.values(o.bin).find(s=>typeof s=="string");if(r){let s=resolve(e,r);if(existsSync(s))return s}}if(typeof o.main=="string"){let r=resolve(e,o.main);if(existsSync(r))return r}}catch{}let i=resolve(e,`${n}.js`);if(existsSync(i))return i;for(let o of Qr){let r=resolve(e,o);if(existsSync(r))return r}}function es(e){let n;try{n=readFileSync(e,"utf8");}catch{return {frontmatter:{},readable:false,valid:false,hasFrontmatter:false}}let t=n.match(qr);if(!t)return {frontmatter:{},readable:true,valid:true,hasFrontmatter:false};try{let i=load(t[1]??"");if(!di(i))return {frontmatter:{},readable:!0,valid:!1,hasFrontmatter:!0};let o=di(i.metadata)?i.metadata:void 0;return {frontmatter:{...typeof i.name=="string"?{name:i.name}:{},...typeof(o?.version??i.version)=="string"?{version:o?.version??i.version}:{},...typeof i.description=="string"?{description:i.description}:{}},readable:!0,valid:!0,hasFrontmatter:!0}}catch{return {frontmatter:{},readable:true,valid:false,hasFrontmatter:true}}}function ns(e){return [join(e,ci),join(e,"skill",ci)]}function an(e,n){if(!ui(e))return null;for(let t of ns(e)){if(!existsSync(t))continue;let o=es(t).frontmatter;return {name:o.name??n,...o.version===void 0?{}:{version:o.version},...o.description===void 0?{}:{description:o.description},skillMdPath:t,dir:e}}return null}function et(e){try{return readdirSync(e,{withFileTypes:!0}).filter(Zr)}catch{return []}}function ts(e){return e.length===0||/[\\\u0000]/.test(e)?false:e.split("/").every(n=>n.length>0&&n!=="."&&n!=="..")}function pi(e,n,t){!e||n.has(e.name)||(n.add(e.name),t.push(e));}function cn(e){let n=[],t=new Set;for(let i of e)if(ui(i))for(let o of et(i)){if(o.name.startsWith("@")){let r=join(i,o.name);for(let s of et(r))pi(an(join(r,s.name),s.name),t,n);continue}pi(an(join(i,o.name),o.name),t,n);}return n.sort((i,o)=>i.name.localeCompare(o.name))}function is(e,n){if(!ts(e))throw new Error(`Skill not found: ${e}`);for(let i of n){let o=an(join(i,e),e);if(o)return o;for(let r of et(i)){if(!r.name.startsWith("@"))continue;let s=an(join(i,r.name,e),e);if(s)return s}}let t=cn(n).find(i=>i.name===e);if(t)return t;throw new Error(`Skill not found: ${e}`)}async function bc(e){if(!e||e.root===null)return {skills:[],diagnostics:[]};let{discoverWorkspaceApps:n}=await Promise.resolve().then(()=>(ai(),si)),t=await n(e.root,{productBundle:e}),i=[],o=new Set;for(let r of t.apps){let s=r.provenance?.kind==="bundled"?r.provenance.packageDir:void 0;if(!s)continue;let a=join(e.root,...s.split("/"));for(let p of cn([dirname(a)]))resolve(p.dir)!==resolve(a)||o.has(p.name)||(o.add(p.name),i.push(p));for(let p of [join(a,"skill"),join(a,"skills")])for(let d of cn([p]))o.has(d.name)||(o.add(d.name),i.push(d));}return {skills:i.sort((r,s)=>r.name.localeCompare(s.name)),diagnostics:t.diagnostics.filter(r=>r.source==="bundled")}}var Pc=cn,Mc=is;
2
+ export{cn as discover,bc as discoverBundledProductSkills,Pc as discoverSkills,Nc as findEntrypoint,es as readSkillFrontmatter,is as resolve,Mc as resolveSkill};
@@ -21,3 +21,5 @@ export type { BuiltinThreadState, LegacyThreadState, StableThreadState, ThreadPr
21
21
  export type { AgentConfig, CrewxProjectConfig, CrewxOptions, QueryOptions, QueryResult, ExecuteOptions, ExecuteResult, ContextMode, } from './types/index.js';
22
22
  export { MCP_APP_HOST_TOOL_ALLOWLIST } from './mcp-app/types.js';
23
23
  export type { CrewxAppCapability, CrewxAppCatalogOptions, CrewxAppCatalogResult, CrewxAppDefinitionHashInput, CrewxAppDefinitionSummary, CrewxAppDiagnostic, CrewxAppDiagnosticCode, CrewxAppDiagnosticSource, CrewxAppInstalledProjection, CrewxAppLocalDefinitionRef, CrewxAppOrigin, CrewxAppOwnership, CrewxAppShareability, CrewxAppSharingAvailability, CrewxAppSummary, McpAppHostToolName, } from './mcp-app/types.js';
24
+ export { UI_CONTENT_MEDIA_TYPES, buildMcpAppContentActions, contentActionsMatch, isMcpAppContentActions, isUiContentMediaType, isValidUiAppInstanceId, } from './mcp-app/content-declarations.js';
25
+ export type { McpAppContentActionDeclaration, McpAppContentActions, UiContentMediaType, } from './mcp-app/content-declarations.js';
@@ -1,6 +1,6 @@
1
- import {load}from'js-yaml';import'js-tiktoken';import'js-tiktoken/lite';import Ve from'js-tiktoken/ranks/o200k_base';import {z as z$1}from'zod';var A=class extends Error{constructor(e,n){let r=n.length>0?` Available: ${n.join(", ")}`:"";super(`Agent not found: "${e}".${r}`),this.name="AgentNotFoundError";}},ye={claude:{id:"claude",provider:"cli/claude"},copilot:{id:"copilot",provider:"cli/copilot"},codex:{id:"codex",provider:"cli/codex"}};function w(t,e){let n=t.startsWith("@")?t.slice(1):t,r=e.find(i=>i.id===n);if(r)return r;let o=ye[n];if(o)return o;throw new A(t,e.map(i=>i.id))}var f=class extends Error{constructor(n,r,o){super(n);this.providerStr=r;this.name="ProviderError",this.code=o?.code??"UNKNOWN",this.kind=o?.kind??(this.code==="UNKNOWN"?"transient":void 0),this.retryAfterMs=o?.retryAfterMs;}providerStr;code;kind;retryAfterMs;stdout};var Z=new Map;function S(t,e){Z.set(t,e);}function _(t){let e=t.split("/");if(e.length!==2)throw new f(`Invalid provider format: "${t}". Expected namespace/id (e.g., api/webllm)`,t);let[n,r]=e,o=Z.get(n);if(o)return o(r,t);throw new f(`Unsupported provider namespace: "${n}". Register a factory with registerProviderFactory('${n}', factory).`,t)}var he=new Function("u","return import(u)"),D=class t{_agents;_config;_tools=new Map;_apiProviders=new Map;constructor(e,n){this._agents=new Map(e.map(r=>[r.id,r])),this._config=n;}static async fromConfig(e,n){let r=new t(e.agents??[],e),o=e.agents??[],i=p=>Array.isArray(p.provider)?p.provider[0]:p.provider,d=o.filter(p=>i(p)==="api/webllm"),s=o.filter(p=>i(p)==="api/openrouter");if(d.length>0&&await r._initWebLLM(d,n?.onProgress),s.length>0){if(!n?.openrouterApiKey)throw new Error("openrouterApiKey is required when using api/openrouter provider");r._initOpenRouter(s,n.openrouterApiKey);}return r._apiProviders.size>0&&S("api",(p,c)=>{let l=r._apiProviders.get(p);if(!l)throw new f(`Unknown api provider: ${p}`,c);return l}),r}async _initWebLLM(e,n){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not available. Chrome 113+ or Edge 113+ required.");let r=await he("https://esm.run/@mlc-ai/web-llm"),o=e[0]?.inline?.model??"gemma-2-2b-it-q4f16_1-MLC",i=await r.CreateMLCEngine(o,{initProgressCallback:n?s=>n(s):void 0}),d=[];this._apiProviders.set("webllm",{async query(s,p){let c=[];p?.systemPrompt&&c.push({role:"system",content:p.systemPrompt}),c.push(...d),c.push({role:"user",content:s});let l="",y=await i.chat.completions.create({messages:c,stream:true,temperature:.7,max_tokens:4096});for await(let h of y){let u=h.choices?.[0]?.delta?.content??"";l+=u,p?.onOutput&&p.onOutput(l,"stdout");}return d.push({role:"user",content:s}),d.push({role:"assistant",content:l}),l},async execute(s,p){return this.query(s,p)}});}_initOpenRouter(e,n){let r=e[0]?.inline?.model??"google/gemma-2-2b-it",o=[];this._apiProviders.set("openrouter",{async query(i,d){let s=[];d?.systemPrompt&&s.push({role:"system",content:d.systemPrompt}),s.push(...o),s.push({role:"user",content:i});let p=await fetch("https://openrouter.ai/api/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({model:d?.model||r,messages:s,stream:true})});if(!p.ok){let u=await p.text();throw new Error(`OpenRouter API error (${p.status}): ${u}`)}let c=p.body.getReader(),l=new TextDecoder,y="",h="";for(;;){let{done:u,value:b}=await c.read();if(u)break;h+=l.decode(b,{stream:true});let Y=h.split(`
2
- `);h=Y.pop();for(let me of Y){let O=me.trim();if(!O||!O.startsWith("data: "))continue;let Q=O.slice(6);if(Q!=="[DONE]")try{let X=JSON.parse(Q).choices?.[0]?.delta?.content??"";y+=X,X&&d?.onOutput&&d.onOutput(y,"stdout");}catch{}}}return o.push({role:"user",content:i}),o.push({role:"assistant",content:y}),y},async execute(i,d){return this.query(i,d)}});}get agents(){return this._agents}get config(){return this._config}get tools(){return this._tools}registerTool(e,n){this._tools.set(e,{name:e,...n});}async query(e,n,r){let o=Date.now(),i;try{i=w(e,Array.from(this._agents.values()));}catch(u){if(u instanceof A)return {ok:false,data:"",error:{code:"AGENT_NOT_FOUND",message:u.message},meta:{agentId:e.replace(/^@/,""),provider:"",durationMs:Date.now()-o}};throw u}let d=Array.isArray(i.provider)?i.provider[0]??"api/default":i.provider,s=r?.provider??d,p=r?.model??i.inline?.model,c=i.options,l=c&&typeof c=="object"&&!Array.isArray(c)?c.query:void 0,y=l&&typeof l=="object"&&!Array.isArray(l)&&typeof l.mode=="string"&&l.mode.trim()||void 0,h;try{h=_(s);}catch(u){return {ok:false,data:"",error:{code:"PROVIDER_ERROR",message:u.message,...u instanceof f?{providerCode:u.code}:{}},meta:{agentId:i.id,provider:s,model:p,durationMs:Date.now()-o}}}try{return {ok:!0,data:await h.query(n,{model:p,context:r?.context,systemPrompt:i.inline?.system_prompt??i.inline?.prompt,onOutput:r?.onOutput?b=>r.onOutput(b):void 0}),meta:{agentId:i.id,provider:s,model:p,durationMs:Date.now()-o}}}catch(u){return {ok:false,data:"",error:{code:"QUERY_FAILED",message:u.message,...u instanceof f?{providerCode:u.code}:{},...y?{mode:y}:{}},meta:{agentId:i.id,provider:s,model:p,durationMs:Date.now()-o}}}}async execute(e,n,r){let o=Date.now(),i;try{i=w(e,Array.from(this._agents.values()));}catch(l){if(l instanceof A)return {ok:false,data:"",error:{code:"AGENT_NOT_FOUND",message:l.message},meta:{agentId:e.replace(/^@/,""),provider:"",durationMs:Date.now()-o}};throw l}let d=Array.isArray(i.provider)?i.provider[0]??"api/default":i.provider,s=r?.provider??d,p=r?.model??i.inline?.model,c;try{c=_(s);}catch(l){return {ok:false,data:"",error:{code:"PROVIDER_ERROR",message:l.message,...l instanceof f?{providerCode:l.code}:{}},meta:{agentId:i.id,provider:s,model:p,durationMs:Date.now()-o}}}try{return {ok:!0,data:await c.execute(n,{model:p,context:r?.context,systemPrompt:i.inline?.system_prompt??i.inline?.prompt}),meta:{agentId:i.id,provider:s,model:p,durationMs:Date.now()-o}}}catch(l){return {ok:false,data:"",error:{code:"EXECUTE_FAILED",message:l.message,...l instanceof f?{providerCode:l.code}:{}},meta:{agentId:i.id,provider:s,model:p,durationMs:Date.now()-o}}}}};var g="[REDACTED]",J="[PATH]";function L(t){if(typeof t!="string")return;let e=t.trim();if(e)return e=e.replace(/^\s*at\s+[^\r\n]+(?:\r?\n|$)/gim,""),e=e.replace(/(^|[\r\n])\s*(?:authorization|proxy-authorization|x-api-key|x-goog-api-key|x-auth-token|cookie|set-cookie)\s*:\s*[^\r\n]*/gim,`$1[HTTP HEADER ${g}]`),e=Ae(e),e=e.replace(/\b(?:Bearer|Basic)\s+[A-Za-z0-9._~+\-/]+=*/gi,`${g}`),e=e.replace(/\bsk-[A-Za-z0-9][A-Za-z0-9_-]*/g,g),e=e.replace(/\bghp_[A-Za-z0-9][A-Za-z0-9_-]*/g,g),e=e.replace(/\bxoxb-[A-Za-z0-9-]+/g,g),e=e.replace(/\bxoxp-[A-Za-z0-9-]+/g,g),e=e.replace(/\bAKIA[0-9A-Z]{12,}\b/g,g),e=e.replace(/\bgithub_pat_[A-Za-z0-9_]+/g,g),e=e.replace(/\bgho_[A-Za-z0-9_]+/g,g),e=e.replace(/\bAIza[A-Za-z0-9_-]{20,}\b/g,g),e=e.replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,g),e=e.replace(/\b(?:authorization|api[_ -]?key|access[_ -]?token|auth[_ -]?token|refresh[_ -]?token|token|secret|password)\s*([:=])\s*["']?[^\s,;&"']+/gi,(n,r)=>`${g}${r}${g}`),e=e.replace(/([?&](?:api[_-]?key|access[_-]?token|token)=)[^&\s]+/gi,`$1${g}`),e=e.replace(/(?:\/(?:Users|home|private|var\/folders|tmp|workspace|workspaces|Volumes|opt|etc|srv|Applications)\/[^\s"'`),;]+)/g,J),e=e.replace(/\b[A-Z]:\\(?:Users|home|Windows|Program Files|workspace|workspaces)\\[^\s"'`),;]*/gi,J),e=e.replace(/[\r\n]{3,}/g,`
1
+ import {load}from'js-yaml';import'js-tiktoken';import'js-tiktoken/lite';import nt from'js-tiktoken/ranks/o200k_base';import {z as z$1}from'zod';var x=class extends Error{constructor(t,n){let r=n.length>0?` Available: ${n.join(", ")}`:"";super(`Agent not found: "${t}".${r}`),this.name="AgentNotFoundError";}},ve={claude:{id:"claude",provider:"cli/claude"},copilot:{id:"copilot",provider:"cli/copilot"},codex:{id:"codex",provider:"cli/codex"}};function N(e,t){let n=e.startsWith("@")?e.slice(1):e,r=t.find(i=>i.id===n);if(r)return r;let o=ve[n];if(o)return o;throw new x(e,t.map(i=>i.id))}var f=class extends Error{constructor(n,r,o){super(n);this.providerStr=r;this.name="ProviderError",this.code=o?.code??"UNKNOWN",this.kind=o?.kind??(this.code==="UNKNOWN"?"transient":void 0),this.retryAfterMs=o?.retryAfterMs;}providerStr;code;kind;retryAfterMs;stdout};var oe=new Map;function B(e,t){oe.set(e,t);}function O(e){let t=e.split("/");if(t.length!==2)throw new f(`Invalid provider format: "${e}". Expected namespace/id (e.g., api/webllm)`,e);let[n,r]=t,o=oe.get(n);if(o)return o(r,e);throw new f(`Unsupported provider namespace: "${n}". Register a factory with registerProviderFactory('${n}', factory).`,e)}var ke=new Function("u","return import(u)"),F=class e{_agents;_config;_tools=new Map;_apiProviders=new Map;constructor(t,n){this._agents=new Map(t.map(r=>[r.id,r])),this._config=n;}static async fromConfig(t,n){let r=new e(t.agents??[],t),o=t.agents??[],i=p=>Array.isArray(p.provider)?p.provider[0]:p.provider,a=o.filter(p=>i(p)==="api/webllm"),s=o.filter(p=>i(p)==="api/openrouter");if(a.length>0&&await r._initWebLLM(a,n?.onProgress),s.length>0){if(!n?.openrouterApiKey)throw new Error("openrouterApiKey is required when using api/openrouter provider");r._initOpenRouter(s,n.openrouterApiKey);}return r._apiProviders.size>0&&B("api",(p,l)=>{let c=r._apiProviders.get(p);if(!c)throw new f(`Unknown api provider: ${p}`,l);return c}),r}async _initWebLLM(t,n){if(typeof navigator>"u"||!navigator.gpu)throw new Error("WebGPU is not available. Chrome 113+ or Edge 113+ required.");let r=await ke("https://esm.run/@mlc-ai/web-llm"),o=t[0]?.inline?.model??"gemma-2-2b-it-q4f16_1-MLC",i=await r.CreateMLCEngine(o,{initProgressCallback:n?s=>n(s):void 0}),a=[];this._apiProviders.set("webllm",{async query(s,p){let l=[];p?.systemPrompt&&l.push({role:"system",content:p.systemPrompt}),l.push(...a),l.push({role:"user",content:s});let c="",y=await i.chat.completions.create({messages:l,stream:true,temperature:.7,max_tokens:4096});for await(let T of y){let u=T.choices?.[0]?.delta?.content??"";c+=u,p?.onOutput&&p.onOutput(c,"stdout");}return a.push({role:"user",content:s}),a.push({role:"assistant",content:c}),c},async execute(s,p){return this.query(s,p)}});}_initOpenRouter(t,n){let r=t[0]?.inline?.model??"google/gemma-2-2b-it",o=[];this._apiProviders.set("openrouter",{async query(i,a){let s=[];a?.systemPrompt&&s.push({role:"system",content:a.systemPrompt}),s.push(...o),s.push({role:"user",content:i});let p=await fetch("https://openrouter.ai/api/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({model:a?.model||r,messages:s,stream:true})});if(!p.ok){let u=await p.text();throw new Error(`OpenRouter API error (${p.status}): ${u}`)}let l=p.body.getReader(),c=new TextDecoder,y="",T="";for(;;){let{done:u,value:U}=await l.read();if(u)break;T+=c.decode(U,{stream:true});let te=T.split(`
2
+ `);T=te.pop();for(let Pe of te){let L=Pe.trim();if(!L||!L.startsWith("data: "))continue;let ne=L.slice(6);if(ne!=="[DONE]")try{let re=JSON.parse(ne).choices?.[0]?.delta?.content??"";y+=re,re&&a?.onOutput&&a.onOutput(y,"stdout");}catch{}}}return o.push({role:"user",content:i}),o.push({role:"assistant",content:y}),y},async execute(i,a){return this.query(i,a)}});}get agents(){return this._agents}get config(){return this._config}get tools(){return this._tools}registerTool(t,n){this._tools.set(t,{name:t,...n});}async query(t,n,r){let o=Date.now(),i;try{i=N(t,Array.from(this._agents.values()));}catch(u){if(u instanceof x)return {ok:false,data:"",error:{code:"AGENT_NOT_FOUND",message:u.message},meta:{agentId:t.replace(/^@/,""),provider:"",durationMs:Date.now()-o}};throw u}let a=Array.isArray(i.provider)?i.provider[0]??"api/default":i.provider,s=r?.provider??a,p=r?.model??i.inline?.model,l=i.options,c=l&&typeof l=="object"&&!Array.isArray(l)?l.query:void 0,y=c&&typeof c=="object"&&!Array.isArray(c)&&typeof c.mode=="string"&&c.mode.trim()||void 0,T;try{T=O(s);}catch(u){return {ok:false,data:"",error:{code:"PROVIDER_ERROR",message:u.message,...u instanceof f?{providerCode:u.code}:{}},meta:{agentId:i.id,provider:s,model:p,durationMs:Date.now()-o}}}try{return {ok:!0,data:await T.query(n,{model:p,context:r?.context,systemPrompt:i.inline?.system_prompt??i.inline?.prompt,onOutput:r?.onOutput?U=>r.onOutput(U):void 0}),meta:{agentId:i.id,provider:s,model:p,durationMs:Date.now()-o}}}catch(u){return {ok:false,data:"",error:{code:"QUERY_FAILED",message:u.message,...u instanceof f?{providerCode:u.code}:{},...y?{mode:y}:{}},meta:{agentId:i.id,provider:s,model:p,durationMs:Date.now()-o}}}}async execute(t,n,r){let o=Date.now(),i;try{i=N(t,Array.from(this._agents.values()));}catch(c){if(c instanceof x)return {ok:false,data:"",error:{code:"AGENT_NOT_FOUND",message:c.message},meta:{agentId:t.replace(/^@/,""),provider:"",durationMs:Date.now()-o}};throw c}let a=Array.isArray(i.provider)?i.provider[0]??"api/default":i.provider,s=r?.provider??a,p=r?.model??i.inline?.model,l;try{l=O(s);}catch(c){return {ok:false,data:"",error:{code:"PROVIDER_ERROR",message:c.message,...c instanceof f?{providerCode:c.code}:{}},meta:{agentId:i.id,provider:s,model:p,durationMs:Date.now()-o}}}try{return {ok:!0,data:await l.execute(n,{model:p,context:r?.context,systemPrompt:i.inline?.system_prompt??i.inline?.prompt}),meta:{agentId:i.id,provider:s,model:p,durationMs:Date.now()-o}}}catch(c){return {ok:false,data:"",error:{code:"EXECUTE_FAILED",message:c.message,...c instanceof f?{providerCode:c.code}:{}},meta:{agentId:i.id,provider:s,model:p,durationMs:Date.now()-o}}}}};var g="[REDACTED]",ie="[PATH]";function G(e){if(typeof e!="string")return;let t=e.trim();if(t)return t=t.replace(/^\s*at\s+[^\r\n]+(?:\r?\n|$)/gim,""),t=t.replace(/(^|[\r\n])\s*(?:authorization|proxy-authorization|x-api-key|x-goog-api-key|x-auth-token|cookie|set-cookie)\s*:\s*[^\r\n]*/gim,`$1[HTTP HEADER ${g}]`),t=Oe(t),t=t.replace(/\b(?:Bearer|Basic)\s+[A-Za-z0-9._~+\-/]+=*/gi,`${g}`),t=t.replace(/\bsk-[A-Za-z0-9][A-Za-z0-9_-]*/g,g),t=t.replace(/\bghp_[A-Za-z0-9][A-Za-z0-9_-]*/g,g),t=t.replace(/\bxoxb-[A-Za-z0-9-]+/g,g),t=t.replace(/\bxoxp-[A-Za-z0-9-]+/g,g),t=t.replace(/\bAKIA[0-9A-Z]{12,}\b/g,g),t=t.replace(/\bgithub_pat_[A-Za-z0-9_]+/g,g),t=t.replace(/\bgho_[A-Za-z0-9_]+/g,g),t=t.replace(/\bAIza[A-Za-z0-9_-]{20,}\b/g,g),t=t.replace(/\beyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\b/g,g),t=t.replace(/\b(?:authorization|api[_ -]?key|access[_ -]?token|auth[_ -]?token|refresh[_ -]?token|token|secret|password)\s*([:=])\s*["']?[^\s,;&"']+/gi,(n,r)=>`${g}${r}${g}`),t=t.replace(/([?&](?:api[_-]?key|access[_-]?token|token)=)[^&\s]+/gi,`$1${g}`),t=t.replace(/(?:\/(?:Users|home|private|var\/folders|tmp|workspace|workspaces|Volumes|opt|etc|srv|Applications)\/[^\s"'`),;]+)/g,ie),t=t.replace(/\b[A-Z]:\\(?:Users|home|Windows|Program Files|workspace|workspaces)\\[^\s"'`),;]*/gi,ie),t=t.replace(/[\r\n]{3,}/g,`
3
3
 
4
- `).trim(),Te(e,1024)||void 0}function Te(t,e){let n=new TextEncoder;if(n.encode(t).byteLength<=e)return t;let r="",o=0;for(let i of t){let d=n.encode(i).byteLength;if(o+d>e)break;r+=i,o+=d;}return r}function Ae(t){let e=/\b(?:request|response|http)?\s*body\s*[:=]\s*/gim,n="",r=0,o;for(;(o=e.exec(t))!==null;){if(o.index<r)continue;let i=o.index+o[0].length,d=xe(t,i),s=d>=0?d:t.indexOf(`
5
- `,i)>=0?t.indexOf(`
6
- `,i):t.length;n+=t.slice(r,o.index),n+=`[HTTP BODY ${g}]`,r=s;}return n+t.slice(r)}function xe(t,e){let n=t[e];if(n==='"'||n==="'")return Ee(t,e,n);if(n!=="{"&&n!=="[")return -1;let r=[],o,i=false;for(let d=e;d<t.length;d+=1){let s=t[d];if(o){i?i=false:s==="\\"?i=true:s===o&&(o=void 0);continue}if(s==='"'||s==="'"){o=s;continue}if(s==="{"||s==="["){r.push(s);continue}if(s!=="}"&&s!=="]")continue;let p=r.pop();if(s==="}"&&p!=="{"||s==="]"&&p!=="[")return -1;if(r.length===0)return d+1}return -1}function Ee(t,e,n){let r=false;for(let o=e+1;o<t.length;o+=1){let i=t[o];if(r)r=false;else if(i==="\\")r=true;else if(i===n)return o+1}return -1}var Ie=new Set(["USAGE_LIMITED","CONTEXT_WINDOW_EXCEEDED","INPUT_TOO_LARGE","MODEL_NOT_SUPPORTED","MODEL_AT_CAPACITY","AUTH_REQUIRED","CLI_NOT_AVAILABLE","CLI_UPDATE_REQUIRED","AGENT_NOT_FOUND","PERMISSION_OR_TRUST","TIMEOUT_OR_STUCK","NETWORK_OR_PROVIDER_TRANSIENT","PROVIDER_CONFIGURATION","AGENT_MODE_RESTRICTED","PROCESS_FAILED"]),ve=new Set(["plan","plan-auto","read-only"]),Ce={QUOTA_EXHAUSTED:"USAGE_LIMITED",RATE_LIMITED:"USAGE_LIMITED",AUTH_REQUIRED:"AUTH_REQUIRED",TIMEOUT_IDLE:"TIMEOUT_OR_STUCK",TIMEOUT_TOTAL:"TIMEOUT_OR_STUCK",TIMEOUT_RESUME:"NETWORK_OR_PROVIDER_TRANSIENT",PROVIDER_NOT_FOUND:"PROVIDER_CONFIGURATION",INVALID_PROVIDER_FORMAT:"PROVIDER_CONFIGURATION",PROVIDER_CRASHED:"PROCESS_FAILED",EMPTY_OUTPUT:"PROCESS_FAILED"},Me=[{code:"USAGE_LIMITED",pattern:/(?:rate[ _-]?limit|quota|usage[ /_-]?limit|usage exhausted|too many requests|429\b)/i},{code:"CONTEXT_WINDOW_EXCEEDED",pattern:/context (?:window|length)|maximum context|context[_ -]?window[_ -]?exceeded|too many tokens/i},{code:"INPUT_TOO_LARGE",pattern:/input[_ -]?(?:is[_ -]?)?too[_ -]?large|prompt (?:is )?too (?:large|long)|request[_ -]?(?:is[_ -]?)?too[_ -]?large|payload[_ -]?(?:is[_ -]?)?too[_ -]?large|maximum input/i},{code:"MODEL_AT_CAPACITY",pattern:/(?:model|service|provider).*(?:at capacity|overloaded|temporarily busy)|at capacity|overloaded/i},{code:"MODEL_NOT_SUPPORTED",pattern:/(?:model|invalid_request_error).*(?:not[ _-]?supported|unsupported|does[ _-]?not[ _-]?exist|not[ _-]?found|invalid)|model[_-]?not[_-]?(?:found|supported)/i},{code:"AUTH_REQUIRED",pattern:/(?:401\b|unauthori[sz]ed|not logged in|login required|sign[ -]?in required|api key (?:is )?(?:missing|invalid|required)|authentication required)/i},{code:"CLI_UPDATE_REQUIRED",pattern:/(?:requires? a newer version|update (?:your )?cli|cli version.*(?:old|outdated|unsupported)|version mismatch)/i},{code:"CLI_NOT_AVAILABLE",pattern:/(?:ENOENT|command not found|executable.*not found|cli.*(?:not installed|unavailable)|is .* installed\?)/i},{code:"AGENT_NOT_FOUND",pattern:/agent[_ -]?not[_ -]?found|unknown agent/i},{code:"PERMISSION_OR_TRUST",pattern:/(?:permission denied|operation not permitted|workspace trust|not trusted|access denied|EACCES|EPERM)/i},{code:"NETWORK_OR_PROVIDER_TRANSIENT",pattern:/(?:resume failed|failed .*resum(?:e|ing)|after resuming the session|재개 실패|세션 재개)/i},{code:"TIMEOUT_OR_STUCK",pattern:/(?:timeout|timed out|took too long|stuck|idle timeout|ETIMEDOUT)/i},{code:"NETWORK_OR_PROVIDER_TRANSIENT",pattern:/(?:network (?:unreachable|error)|connection (?:reset|refused|closed)|ECONN(?:RESET|REFUSED|ABORTED)|service unavailable|upstream.*(?:5\d\d|error)|provider.*(?:5\d\d|unavailable|down)|\b5\d\d\b)/i},{code:"PROVIDER_CONFIGURATION",pattern:/(?:invalid provider|unsupported provider|provider namespace|provider configuration|provider config|missing provider)/i}];function _e(t){try{if(!T(t)||t.status!=="failed")return U();let e=Pe(t.error);if(F(e.message))return U();let n=m(t.providerId)??e.provider??null,r=Re(t.logs),o=te(e.code);if(o)return v(o,n,e.message,e);let i=P(e.providerCode)??P(e.code),d=i?B(i,e.message,{exitCode:Le(t.exitCode),mode:e.mode,fromProviderCodeField:!!e.providerCode}):void 0;if(d)return v(d,n,e.message,e,i);let s=be(r);if(!ke(e)&&s&&(s.type==="user_stop"||F(s.message)))return U();if(s){let c=Oe(s.code,s.providerCode,s.message);if(c)return v(c,n,s.message??e.message,e,s.providerCode??s.code,s,s.structuredFailure?"terminal":"envelope")}let p=we(e.message,r);return p?v(p.code,n,p.message,e,p.terminal?.providerCode??p.terminal?.code,p.terminal,p.terminal?.structuredFailure?"terminal":"envelope"):v("PROCESS_FAILED",n,e.message,e)}catch{return {errorCode:"PROCESS_FAILED",errorProvider:null}}}function U(){return {errorCode:null,errorProvider:null}}function v(t,e,n,r,o,i,d="envelope"){let s={};if(i?.resetAt!==void 0&&(s.resetAt=i.resetAt),r?.model&&(s.model=r.model),r?.mode&&(s.mode=r.mode),i?.type&&(s.upstreamType=i.type),o&&(s.upstreamCode=o),t==="CLI_NOT_AVAILABLE"||t==="CLI_UPDATE_REQUIRED"){let y=e?.startsWith("cli/")?e.slice(4):void 0;y&&(s.cliName=y);}let p=d==="terminal"?n:r?.message,c=d==="terminal"?i?.structuredFailure?p:void 0:r?.isEnvelope?p:void 0,l=L(c);return l&&(s.technicalMessage=l),Object.keys(s).length>0?{errorCode:t,errorProvider:e,errorMeta:s}:{errorCode:t,errorProvider:e}}function Pe(t){let e=typeof t=="string"?E(t):t;return T(e)?{isEnvelope:true,code:m(e.code),providerCode:m(e.providerCode),message:m(e.message)??m(e.error),provider:m(e.provider)??m(e.errorProvider),model:m(e.model),mode:m(e.mode)}:{isEnvelope:false,...typeof t=="string"&&t.trim()?{message:t.trim()}:{}}}function E(t){try{return JSON.parse(t)}catch{return}}function ke(t){return !!(t.code||t.providerCode||t.message)}function Re(t){let e=[];if(typeof t=="string"){let n=E(t);if(Array.isArray(n))e.push(...n);else for(let r of t.split(/\r?\n/)){let o=E(r.trim());o!==void 0&&e.push(o);}}else Array.isArray(t)?e.push(...t):T(t)&&e.push(t);return e.flatMap(x)}function x(t){if(!T(t))return [];let e=m(t.type),n=m(t.message);if(n&&!e){let o=E(n);if(Array.isArray(o))return o.flatMap(x);if(T(o))return x(o);let i=n.split(/\r?\n/).map(d=>E(d.trim())).filter(d=>T(d));return i.length>0?i.flatMap(x):t.level==="stderr"?[{type:"stderr",message:n,rank:1,structuredFailure:false}]:x({type:"info",content:n})}if(e==="rate_limit_event"){let o=ee(t.rate_limit_info);return m(o?.status)!=="rejected"?[]:[{type:e,code:"RATE_LIMITED",message:C(o?.message,t.message),resetAt:De(o?.resetsAt),rank:4,structuredFailure:true}]}if(e==="turn.failed"||e==="error"){let o=ee(t.error),i=C(o?.message,o?.detail,t.message,t.errorMessage,t.content),d=C(o?.code,t.code,t.errorCode);return [{type:e,code:d,providerCode:C(o?.providerCode,t.providerCode),message:i,rank:e==="turn.failed"?3:2,structuredFailure:true}]}if(e==="text"&&typeof t.content=="string"){let o=E(t.content);if(T(o))return x(o)}let r=C(t.errorMessage,t.content);return r&&F(r)?[{type:"user_stop",message:r,rank:1,structuredFailure:false}]:r&&/(?:turn\.failed|type:error)/i.test(r)?[{type:r.match(/turn\.failed/i)?"turn.failed":"error",message:r,rank:3,structuredFailure:false}]:[]}function be(t){return [...t].sort((e,n)=>n.rank-e.rank)[0]}function Oe(t,e,n){let r=te(t);if(r)return r;if(t){let o=B(t,n);if(o)return o}if(e){let o=B(e,n);if(o)return o}return N(n)}function we(t,e){let n=N(t);if(n)return {code:n,message:t};for(let r of [...e].sort((o,i)=>i.rank-o.rank)){let o=N(r.message);if(o)return {code:o,message:r.message,terminal:r}}}function N(t){if(!(typeof t!="string"||!t.trim()))return Me.find(e=>e.pattern.test(t))?.code}function B(t,e,n){let r=P(t)??t;if(r==="MODEL_UNAVAILABLE")return /(?:capacity|overloaded|busy)/i.test(e??"")?"MODEL_AT_CAPACITY":"MODEL_NOT_SUPPORTED";if(r==="EMPTY_OUTPUT"&&n?.fromProviderCodeField===true&&n.exitCode===0&&Se(n.mode))return "AGENT_MODE_RESTRICTED";if(r!=="UNKNOWN")return Ce[r]}function te(t){let e=P(t);return e&&Ie.has(e)?e:void 0}function P(t){return typeof t=="string"&&t.trim()?t.trim().toUpperCase():void 0}function Se(t){return typeof t=="string"&&ve.has(t.trim().toLowerCase())}function F(t){return t?/\b(?:stopped|killed|aborted|cancelled|canceled)\s+by\s+user\b/i.test(t)||/사용자에 의해 중지됨/.test(t)||/\b(?:SIGTERM\s+143|143\s+SIGTERM)\b/i.test(t):false}function T(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ee(t){return T(t)?t:void 0}function m(t){return typeof t=="string"&&t.trim()?t.trim():void 0}function De(t){return typeof t=="string"||typeof t=="number"&&Number.isFinite(t)?t:void 0}function Le(t){return typeof t=="number"&&Number.isInteger(t)?t:void 0}function C(...t){return t.map(m).find(e=>!!e)}var Ue=["none","minimal","low","medium","high","xhigh","max","ultra"],Ne={claude:["low","medium","high","xhigh","max"],codex:["none","minimal","low","medium","high","xhigh","max","ultra"],opencode:[],copilot:["none","low","medium","high","xhigh","max"],antigravity:["low","medium","high"],grok:["low","medium","high","xhigh"]};var k={claude:{models:[{id:"claude-fable-5-1",name:"Claude Fable 5.1",contextWindowTokens:1e6,tier:"flagship",recommended:true},{id:"claude-fable-5",name:"Claude Fable 5",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-opus-5-5",name:"Claude Opus 5.5",contextWindowTokens:1e6,tier:"flagship",recommended:true},{id:"claude-opus-5",name:"Claude Opus 5",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-sonnet-5",name:"Claude Sonnet 5",contextWindowTokens:1e6,tier:"balanced",recommended:true},{id:"claude-opus-4-8[1m]",name:"Claude Opus 4.8",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-opus-4-7[1m]",name:"Claude Opus 4.7",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-opus-4-6[1m]",name:"Claude Opus 4.6",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-sonnet-4-6[1m]",name:"Claude Sonnet 4.6",contextWindowTokens:1e6,tier:"balanced"},{id:"claude-haiku-4-5",name:"Claude Haiku 4.5",contextWindowTokens:2e5,tier:"speed"}],modes:[{id:"default",name:"Default",description:"Uses Claude's default permission handling with normal approval prompts."},{id:"acceptEdits",name:"Accept Edits",description:"Allows file edits without approval; other permission checks remain in place."},{id:"plan",name:"Plan",description:"Keeps Claude in plan mode so it can inspect and propose changes without applying them."},{id:"dontAsk",name:"Don't Ask",description:"Does not ask for permissions; only pre-approved tool actions can proceed."},{id:"bypassPermissions",name:"Bypass Permissions",description:"Bypasses Claude permission checks so tools can run without approval prompts."}],effort:["low","medium","high"],modelOverrides:{"claude-fable-5-1":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-fable-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-opus-5-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"medium"},"claude-opus-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-sonnet-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-opus-4-8[1m]":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-opus-4-7[1m]":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-opus-4-6[1m]":{effort:["low","medium","high","max"],defaultEffort:"high"},"claude-sonnet-4-6[1m]":{effort:["low","medium","high","max"],defaultEffort:"high"},"claude-haiku-4-5":{effort:[]}},providerOptions:[]},codex:{models:[{id:"gpt-6-astra",name:"GPT-6 Astra",contextWindowTokens:105e4,tier:"flagship"},{id:"gpt-6-sol",name:"GPT-6 Sol",contextWindowTokens:105e4,tier:"balanced",recommended:true},{id:"gpt-6-luna",name:"GPT-6 Luna",contextWindowTokens:105e4,tier:"speed",recommended:true},{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",contextWindowTokens:105e4,tier:"flagship"},{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",contextWindowTokens:105e4,tier:"balanced"},{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",contextWindowTokens:105e4,tier:"speed"},{id:"gpt-5.5",name:"GPT-5.5",contextWindowTokens:105e4,tier:"flagship"},{id:"gpt-5.4",name:"GPT-5.4",contextWindowTokens:105e4,tier:"flagship"},{id:"gpt-5.4-mini",name:"GPT-5.4 Mini",contextWindowTokens:4e5,tier:"speed"},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",contextWindowTokens:4e5,tier:"flagship"},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",contextWindowTokens:128e3,tier:"speed"}],modes:[{id:"agent",name:"Agent",description:"Uses the workspace-write sandbox; can read and modify workspace files without full machine access."},{id:"read-only",name:"Read Only",description:"Uses the read-only sandbox; can inspect files but cannot write to the workspace."},{id:"plan",name:"Plan",description:"Uses the read-only sandbox for planning and inspection; cannot write to the workspace."},{id:"agent-full-access",name:"Agent Full Access",description:"Bypasses approvals and the sandbox; can access and modify files beyond the workspace."},{id:"yolo",name:"YOLO",description:"Bypasses approvals and the sandbox for unrestricted execution and full filesystem access."}],effort:["minimal","low","medium","high"],modelOverrides:{"gpt-6-astra":{effort:["low","medium","high","xhigh","max"],defaultEffort:"xhigh"},"gpt-6-sol":{effort:["none","low","medium","high","xhigh","max"],defaultEffort:"max"},"gpt-6-luna":{effort:["none","low","medium","high","xhigh","max"],defaultEffort:"medium"},"gpt-5.6-sol":{effort:["low","medium","high","xhigh","max","ultra"],defaultEffort:"xhigh"},"gpt-5.6-terra":{effort:["low","medium","high","xhigh","max","ultra"],defaultEffort:"high"},"gpt-5.6-luna":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"gpt-5.5":{effort:["low","medium","high","xhigh"],defaultEffort:"high"}},providerOptions:[]},opencode:{models:[],modes:[{id:"plan",name:"Plan",description:"Uses the plan agent without --auto; planning follows standard approval behavior."},{id:"plan-auto",name:"Plan \xB7 Auto",description:"Uses the plan agent with --auto; planning uses automatic approvals."},{id:"build",name:"Build",description:"Uses the build agent without --auto; work follows standard approval behavior."},{id:"build-auto",name:"Build \xB7 Auto",description:"Uses the build agent with --auto; work uses automatic approvals."}],effort:[],modelOverrides:{},providerOptions:[]},copilot:{models:[{id:"auto",name:"Auto"},{id:"claude-sonnet-5",name:"Claude Sonnet 5",contextWindowTokens:1e6,tier:"balanced"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",contextWindowTokens:1e6,tier:"balanced"},{id:"gpt-5.5",name:"GPT-5.5",contextWindowTokens:105e4,tier:"flagship"},{id:"gpt-5.4",name:"GPT-5.4",contextWindowTokens:105e4,tier:"flagship"},{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro",contextWindowTokens:1048576,tier:"flagship"}],modes:[{id:"interactive",name:"Interactive",description:"Passes --mode interactive; tool access follows Copilot's interactive mode behavior."},{id:"plan",name:"Plan",description:"Passes --mode plan; planning and permission behavior follow Copilot's plan mode."},{id:"autopilot",name:"Autopilot",description:"Passes --mode autopilot; execution behavior follows Copilot's autonomous mode."}],effort:["none","low","medium","high","xhigh","max"],modelOverrides:{},providerOptions:[]},antigravity:{models:[{id:"gemini-3.7-flash",name:"Gemini 3.7 Flash",contextWindowTokens:1048576,tier:"balanced"},{id:"gemini-3.6-flash",name:"Gemini 3.6 Flash",contextWindowTokens:1048576,tier:"balanced"},{id:"gemini-3.5-flash",name:"Gemini 3.5 Flash",contextWindowTokens:1048576,tier:"balanced"},{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro",contextWindowTokens:1048576,tier:"flagship"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",contextWindowTokens:1e6,tier:"balanced"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",contextWindowTokens:1e6,tier:"flagship"},{id:"gpt-oss-120b",name:"GPT-OSS 120B",contextWindowTokens:128e3,tier:"balanced"}],modes:[{id:"default",name:"Default",description:"Uses Antigravity's default permission handling. No extra permission flags are passed."},{id:"plan",name:"Plan",description:"Passes --mode plan. This turns on /plan; it is not a Claude-style permission mode."},{id:"acceptEdits",name:"Accept Edits",description:"Passes --mode accept-edits."},{id:"bypassPermissions",name:"Bypass Permissions",description:"Passes --dangerously-skip-permissions so tools can run without approval prompts."}],effort:["low","medium","high"],modelOverrides:{"gemini-3.7-flash":{effort:["low","medium","high"],defaultEffort:"medium"},"gemini-3.6-flash":{effort:["low","medium","high"],defaultEffort:"medium"},"gemini-3.5-flash":{effort:["low","medium","high"],defaultEffort:"medium"},"gemini-3.1-pro":{effort:["low","high"],defaultEffort:"high"},"claude-sonnet-4-6":{effort:[]},"claude-opus-4-6-thinking":{effort:[]},"gpt-oss-120b":{effort:["medium"],defaultEffort:"medium"}},providerOptions:[]},grok:{models:[{id:"grok-4.7",name:"Grok 4.7",contextWindowTokens:5e5,tier:"flagship",recommended:true},{id:"grok-4.6",name:"Grok 4.6",contextWindowTokens:5e5,tier:"flagship"},{id:"grok-4.5",name:"Grok 4.5",contextWindowTokens:5e5,tier:"flagship"}],modes:[{id:"default",name:"Default",description:"Uses Grok's default permission handling."},{id:"acceptEdits",name:"Accept Edits",description:"Allows file edits without changing the selected sandbox profile."},{id:"auto",name:"Auto",description:"Uses Grok automatic permission handling."},{id:"dontAsk",name:"Don't Ask",description:"Does not ask for permission before tool execution."},{id:"bypassPermissions",name:"Bypass Permissions",description:"Bypasses Grok permission checks for tool execution."},{id:"plan",name:"Plan",description:"Keeps Grok in planning mode without applying changes."}],effort:["low","medium","high"],modelOverrides:{"grok-4.7":{effort:["low","medium","high","xhigh"],defaultEffort:"high"},"grok-4.6":{effort:["low","medium","high","xhigh"],defaultEffort:"high"},"grok-4.5":{effort:["low","medium","high"],defaultEffort:"high"}},providerOptions:[{key:"alwaysApprove",type:"boolean"},{key:"sandbox",type:"enum",values:["workspace","read-only","off"]}]}},H={providers:{"cli/codex":{model:"gpt-6-sol",query:{mode:"agent",effort:"max"},execute:{mode:"agent-full-access",effort:"max"}},"cli/claude":{model:"claude-opus-5-5",query:{mode:"default",effort:"high"},execute:{mode:"bypassPermissions",effort:"xhigh"}},"cli/grok":{model:"grok-4.7",query:{mode:"default",effort:"high",providerOptions:{alwaysApprove:true,sandbox:"off"}},execute:{mode:"bypassPermissions",effort:"xhigh",providerOptions:{alwaysApprove:true,sandbox:"off"}}}}};Object.fromEntries(Object.entries(k).map(([t,e])=>[t,e.models]));var He="claude-opus-4-8",Ge="claude-opus-4-8[1m]",ne=[{baseModelId:"claude-opus-4-8",catalogModelId:"claude-opus-4-8[1m]"},{baseModelId:"claude-opus-4-7",catalogModelId:"claude-opus-4-7[1m]"},{baseModelId:"claude-opus-4-6",catalogModelId:"claude-opus-4-6[1m]"},{baseModelId:"claude-sonnet-4-6",catalogModelId:"claude-sonnet-4-6[1m]"}];var je=new Map(ne.map(({baseModelId:t,catalogModelId:e})=>[t,e]));function re(t){return je.get(t)??t}var oe=[{legacyId:"Gemini 3.7 Flash (High)",model:"gemini-3.7-flash",effort:"high"},{legacyId:"Gemini 3.7 Flash (Medium)",model:"gemini-3.7-flash",effort:"medium"},{legacyId:"Gemini 3.7 Flash (Low)",model:"gemini-3.7-flash",effort:"low"},{legacyId:"Gemini 3.6 Flash (High)",model:"gemini-3.6-flash",effort:"high"},{legacyId:"Gemini 3.6 Flash (Medium)",model:"gemini-3.6-flash",effort:"medium"},{legacyId:"Gemini 3.6 Flash (Low)",model:"gemini-3.6-flash",effort:"low"},{legacyId:"Gemini 3.5 Flash (Medium)",model:"gemini-3.5-flash",effort:"medium"},{legacyId:"Gemini 3.5 Flash (High)",model:"gemini-3.5-flash",effort:"high"},{legacyId:"Gemini 3.5 Flash (Low)",model:"gemini-3.5-flash",effort:"low"},{legacyId:"Gemini 3.1 Pro (Low)",model:"gemini-3.1-pro",effort:"low"},{legacyId:"Gemini 3.1 Pro (High)",model:"gemini-3.1-pro",effort:"high"},{legacyId:"Claude Sonnet 4.6 (Thinking)",model:"claude-sonnet-4-6"},{legacyId:"Claude Opus 4.6 (Thinking)",model:"claude-opus-4-6-thinking"},{legacyId:"GPT-OSS 120B (Medium)",model:"gpt-oss-120b",effort:"medium"},{legacyId:"gemini-3.7-flash-high",model:"gemini-3.7-flash",effort:"high"},{legacyId:"gemini-3.7-flash-medium",model:"gemini-3.7-flash",effort:"medium"},{legacyId:"gemini-3.7-flash-low",model:"gemini-3.7-flash",effort:"low"},{legacyId:"gemini-3.6-flash-high",model:"gemini-3.6-flash",effort:"high"},{legacyId:"gemini-3.6-flash-medium",model:"gemini-3.6-flash",effort:"medium"},{legacyId:"gemini-3.6-flash-low",model:"gemini-3.6-flash",effort:"low"},{legacyId:"gemini-3.5-flash-high",model:"gemini-3.5-flash",effort:"high"},{legacyId:"gemini-3.5-flash-medium",model:"gemini-3.5-flash",effort:"medium"},{legacyId:"gemini-3.5-flash-low",model:"gemini-3.5-flash",effort:"low"},{legacyId:"gemini-3.1-pro-high",model:"gemini-3.1-pro",effort:"high"},{legacyId:"gemini-3.1-pro-low",model:"gemini-3.1-pro",effort:"low"},{legacyId:"gpt-oss-120b-medium",model:"gpt-oss-120b",effort:"medium"}],ze=new Map(oe.map(({legacyId:t,model:e,effort:n})=>[t,n===void 0?{model:e}:{model:e,effort:n}]));function ie(t){if(!t)return {};let e=ze.get(t);return e?{...e}:{model:t}}function G(t,e){return t==="antigravity"||t==="cli/antigravity"?ie(e):e===void 0?{}:{model:re(e)}}var se=30,ae=80;Object.keys(Ve.special_tokens);var $e=z$1.object({model:z$1.string().optional(),system_prompt:z$1.string().optional(),prompt:z$1.string().optional(),layout:z$1.union([z$1.string(),z$1.object({id:z$1.string(),props:z$1.record(z$1.unknown()).optional()}),z$1.object({props:z$1.record(z$1.unknown())}),z$1.object({template:z$1.string(),capabilities:z$1.object({semanticContinuity:z$1.boolean().optional(),continuity:z$1.boolean().optional(),continuitySlot:z$1.string().optional(),slot:z$1.string().optional()}).optional()})]).optional()}).catchall(z$1.unknown()),qe=z$1.object({include:z$1.array(z$1.string()).optional()}).optional(),Ke=z$1.object({id:z$1.string(),name:z$1.string().optional(),role:z$1.string().optional(),team:z$1.string().optional(),provider:z$1.union([z$1.string(),z$1.array(z$1.string())]),working_directory:z$1.string().optional(),description:z$1.string().optional(),tags:z$1.array(z$1.string()).optional(),inline:$e.optional(),skills:qe}).catchall(z$1.unknown());z$1.object({id:z$1.string(),name:z$1.string(),workflow_id:z$1.string(),description:z$1.string().optional(),goal_id:z$1.string().optional()});var Ye=z$1.number().finite().int().min(se).max(ae),Qe=z$1.object({inputBudgetPercent:Ye.optional()}).catchall(z$1.unknown()),Xe=z$1.object({continuity:Qe.optional()}).catchall(z$1.unknown()),Ze=z$1.object({bin_resolution:z$1.enum(["global_first","local_first"]).optional(),dreaming:Xe.optional(),wi:z$1.object({boards:z$1.array(z$1.unknown()).optional().catch(()=>{})}).catchall(z$1.unknown()).optional().catch(()=>{})}).catchall(z$1.unknown()),de=z$1.object({agents:z$1.array(Ke).optional(),hooks:z$1.array(z$1.unknown()).optional(),settings:Ze.optional(),skills:z$1.unknown().optional(),layouts:z$1.record(z$1.unknown()).optional(),documents:z$1.record(z$1.unknown()).optional()}).catchall(z$1.unknown());var I=class extends Error{constructor(n,r){super(n);this.cause=r;this.name="ConfigLoadError";}cause};function et(t){if(!t||typeof t!="string"||!t.trim())throw new I("YAML content must be a non-empty string");let e;try{e=load(t);}catch(o){throw new I(`YAML parse error: ${o.message}`,o)}let n=tt(e),r=de.safeParse(n);if(!r.success)throw new I(`Config validation error: ${r.error.message}`);return r.data}function tt(t){if(!t||typeof t!="object")return {agents:[]};let e=t;if(e.agents&&typeof e.agents=="object"&&!Array.isArray(e.agents)){let n=e.agents,r=Object.entries(n).map(([o,i])=>({id:o,...i&&typeof i=="object"?i:{}}));return {...e,agents:r}}return e.agents?e:{...e,agents:[]}}var nt={auto:"default"};function rt(t){return nt[t]??t}var ot="crewx:fs:",j=class{prefix;store;constructor(e){this.prefix=e?.prefix??ot,this.store=e?.storage??new Map;}async readFile(e){let n=this.toKey(e),r=this.store.get(n);if(r===void 0)throw new Error(`BrowserFsAdapter: file not found: ${e}`);return r}async exists(e){return this.store.has(this.toKey(e))}resolvePath(...e){let n=e.map(d=>d.replace(/\\/g,"/")).join("/").replace(/\/+/g,"/"),r=n.split("/"),o=[];for(let d of r)d==="."||d===""||(d===".."?o.pop():o.push(d));let i=o.join("/");return n.startsWith("/")?`/${i}`:i}isAbsolute(e){return e.startsWith("/")}setItem(e,n){this.store.set(this.toKey(e),n);}removeItem(e){this.store.delete(this.toKey(e));}keys(){return Array.from(this.store.keys()).filter(e=>e.startsWith(this.prefix)).map(e=>e.slice(this.prefix.length))}async readdir(e){let n=e.replace(/\\/g,"/").replace(/\/$/,""),r=this.toKey(n+"/"),o=[];for(let i of this.store.keys())if(i.startsWith(r)){let s=i.slice(r.length).split("/")[0];s&&!o.includes(s)&&o.push(s);}return o}toKey(e){return `${this.prefix}${e.replace(/\\/g,"/")}`}};var z=["codex","claude","grok","opencode","antigravity","copilot"];function it(t){let e=t.indexOf("/");return e===-1?t:t.slice(e+1)}function W(t){let e=it(t),n=z.indexOf(e);return n===-1?z.length:n}function st(t,e){return W(t)-W(e)}var at=new Set(["claude","copilot","codex","grok","opencode"]);function dt(t){if(!t)return "";if(t.startsWith("acp/")){let e=t.slice(4);if(at.has(e))return `cli/${e}`}return t}function R(t){return {mode:t.mode,effort:t.effort}}function pt(t){let e=H.providers[t];if(!e)return;let n=t.startsWith("cli/")?t.slice(4):t,r=k[n]?.models.find(d=>d.recommended===true&&d.tier==="balanced")?.id??e.model,o={query:R(e.query),execute:R(e.execute)},i={query:R(e.query),execute:R(e.execute)};return {planner:{model:e.model,...o},worker:{model:r,...i}}}var le=["urgent","high","medium","low"],ce=["investigating","in-progress","in-review","on-hold","done"],M="custom:";var lt=new Set(le),ct=new Set(ce),ut={urgent:"U \uAE34\uAE09 Urgent",high:"P0 \uAE09\uD568 High",medium:"P1 \uC911\uC694 Medium",low:"P2 \uBCF4\uD1B5 Low"},V={investigating:"\uC870\uC0AC\uC911 Looking into","in-progress":"\uC9C4\uD589\uC911 In progress","in-review":"\uAC80\uD1A0\uC911 In review","on-hold":"\uBCF4\uB958 On hold",done:"\uC644\uB8CC Done"};function pe(t,e){return !e||e.includes(t)?e??t:`${t} ${e}`}function $(t){return typeof t=="string"&&lt.has(t)}function q(t){if(typeof t!="string")return false;if(ct.has(t))return true;if(t.startsWith("c_"))return t.length>2;if(!t.startsWith(M))return false;let e=t.slice(M.length);return e.length>=1&&e.length<=20}function ue(t){if(t.startsWith(M))return t.slice(M.length)}function K(t){if(!t)return null;try{let e=JSON.parse(t);return !e||typeof e!="object"||Array.isArray(e)?null:e}catch{return null}}function gt(t){let e=K(t);return !!e&&Object.prototype.hasOwnProperty.call(e,"threadTitle")}function ge(t){let e=K(t);if(!e)return {};let n=e.threadTitle;if(!n||typeof n!="object"||Array.isArray(n))return {};let r=n,o={};return $(r.priority)&&(o.priority=r.priority),q(r.state)&&(o.state=r.state),o}function ft(t,e){let n=K(t)??{},r={...ge(t)};return e.priority===null?delete r.priority:e.priority!==void 0&&(r.priority=e.priority),e.state===null?delete r.state:e.state!==void 0&&(r.state=e.state),r.priority===void 0&&r.state===void 0?delete n.threadTitle:n.threadTitle=r,Object.keys(n).length===0?null:JSON.stringify(n)}function mt(t,e=new Map){let n=[];return t.priority&&n.push(pe(ut[t.priority],e.get(t.priority))),t.state&&(t.state.startsWith(M)?n.push(ue(t.state)??""):V[t.state]?n.push(pe(V[t.state],e.get(t.state))):e.has(t.state)?n.push(t.state,e.get(t.state)??""):t.state.startsWith("c_")?n.push(t.state):n.push(V[t.state]??"")),n.filter(Boolean).join(" ")}function fe(t,e){if(!t||t.trim().length===0)return;let n=new Set,r=false,o=false;for(let i of t.split(",")){let d=i.trim();if(d){if(d==="none"){r=true,o=true;continue}e(d)&&(n.add(d),o=true);}}if(o)return {values:n,includeNone:r}}function yt(t){return fe(t,$)}function ht(t){return fe(t,q)}function Tt(t,e){return e?t?e.values.has(t):e.includeNone:true}var At=["crewx_app_terminal_connect","crewx_app_html_viewer_open"];export{oe as ANTIGRAVITY_MODEL_COMPATIBILITY,ce as BUILTIN_THREAD_STATES,j as BrowserFsAdapter,ne as CLAUDE_MODEL_COMPATIBILITY_PAIRS,He as CLAUDE_OPUS_4_8_BASE_MODEL_ID,Ge as CLAUDE_OPUS_4_8_LEGACY_MODEL_ID,I as ConfigLoadError,D as Crewx,Ue as EFFORT_LEVELS,At as MCP_APP_HOST_TOOL_ALLOWLIST,Ne as PROVIDER_ARGV_EFFORTS,z as PROVIDER_ORDER,f as ProviderError,le as THREAD_PRIORITIES,_e as classifyTaskError,st as compareProviders,_ as createProvider,ue as customStateLabel,pt as getDefaultAgentProfile,gt as hasThreadTitleKey,$ as isThreadPriority,q as isThreadState,Tt as matchesThreadTitleFilter,ft as mergeThreadTitleMeta,rt as normalizeClaudeMode,dt as normalizeProviderId,yt as parseThreadPriorityFilter,ht as parseThreadStateFilter,et as parseYamlContent,W as providerRank,ge as readThreadTitleMeta,L as redactTechnicalMessage,S as registerProviderFactory,ie as resolveAntigravityModel,re as resolveCatalogModelId,G as resolveProviderCatalogModel,mt as threadTitleSearchHaystack};
4
+ `).trim(),Re(t,1024)||void 0}function Re(e,t){let n=new TextEncoder;if(n.encode(e).byteLength<=t)return e;let r="",o=0;for(let i of e){let a=n.encode(i).byteLength;if(o+a>t)break;r+=i,o+=a;}return r}function Oe(e){let t=/\b(?:request|response|http)?\s*body\s*[:=]\s*/gim,n="",r=0,o;for(;(o=t.exec(e))!==null;){if(o.index<r)continue;let i=o.index+o[0].length,a=be(e,i),s=a>=0?a:e.indexOf(`
5
+ `,i)>=0?e.indexOf(`
6
+ `,i):e.length;n+=e.slice(r,o.index),n+=`[HTTP BODY ${g}]`,r=s;}return n+e.slice(r)}function be(e,t){let n=e[t];if(n==='"'||n==="'")return we(e,t,n);if(n!=="{"&&n!=="[")return -1;let r=[],o,i=false;for(let a=t;a<e.length;a+=1){let s=e[a];if(o){i?i=false:s==="\\"?i=true:s===o&&(o=void 0);continue}if(s==='"'||s==="'"){o=s;continue}if(s==="{"||s==="["){r.push(s);continue}if(s!=="}"&&s!=="]")continue;let p=r.pop();if(s==="}"&&p!=="{"||s==="]"&&p!=="[")return -1;if(r.length===0)return a+1}return -1}function we(e,t,n){let r=false;for(let o=t+1;o<e.length;o+=1){let i=e[o];if(r)r=false;else if(i==="\\")r=true;else if(i===n)return o+1}return -1}var Se=new Set(["USAGE_LIMITED","CONTEXT_WINDOW_EXCEEDED","INPUT_TOO_LARGE","MODEL_NOT_SUPPORTED","MODEL_AT_CAPACITY","AUTH_REQUIRED","CLI_NOT_AVAILABLE","CLI_UPDATE_REQUIRED","AGENT_NOT_FOUND","PERMISSION_OR_TRUST","TIMEOUT_OR_STUCK","NETWORK_OR_PROVIDER_TRANSIENT","PROVIDER_CONFIGURATION","AGENT_MODE_RESTRICTED","PROCESS_FAILED"]),De=new Set(["plan","plan-auto","read-only"]),Ue={QUOTA_EXHAUSTED:"USAGE_LIMITED",RATE_LIMITED:"USAGE_LIMITED",AUTH_REQUIRED:"AUTH_REQUIRED",TIMEOUT_IDLE:"TIMEOUT_OR_STUCK",TIMEOUT_TOTAL:"TIMEOUT_OR_STUCK",TIMEOUT_RESUME:"NETWORK_OR_PROVIDER_TRANSIENT",PROVIDER_NOT_FOUND:"PROVIDER_CONFIGURATION",INVALID_PROVIDER_FORMAT:"PROVIDER_CONFIGURATION",PROVIDER_CRASHED:"PROCESS_FAILED",EMPTY_OUTPUT:"PROCESS_FAILED"},Le=[{code:"USAGE_LIMITED",pattern:/(?:rate[ _-]?limit|quota|usage[ /_-]?limit|usage exhausted|too many requests|429\b)/i},{code:"CONTEXT_WINDOW_EXCEEDED",pattern:/context (?:window|length)|maximum context|context[_ -]?window[_ -]?exceeded|too many tokens/i},{code:"INPUT_TOO_LARGE",pattern:/input[_ -]?(?:is[_ -]?)?too[_ -]?large|prompt (?:is )?too (?:large|long)|request[_ -]?(?:is[_ -]?)?too[_ -]?large|payload[_ -]?(?:is[_ -]?)?too[_ -]?large|maximum input/i},{code:"MODEL_AT_CAPACITY",pattern:/(?:model|service|provider).*(?:at capacity|overloaded|temporarily busy)|at capacity|overloaded/i},{code:"MODEL_NOT_SUPPORTED",pattern:/(?:model|invalid_request_error).*(?:not[ _-]?supported|unsupported|does[ _-]?not[ _-]?exist|not[ _-]?found|invalid)|model[_-]?not[_-]?(?:found|supported)/i},{code:"AUTH_REQUIRED",pattern:/(?:401\b|unauthori[sz]ed|not logged in|login required|sign[ -]?in required|api key (?:is )?(?:missing|invalid|required)|authentication required)/i},{code:"CLI_UPDATE_REQUIRED",pattern:/(?:requires? a newer version|update (?:your )?cli|cli version.*(?:old|outdated|unsupported)|version mismatch)/i},{code:"CLI_NOT_AVAILABLE",pattern:/(?:ENOENT|command not found|executable.*not found|cli.*(?:not installed|unavailable)|is .* installed\?)/i},{code:"AGENT_NOT_FOUND",pattern:/agent[_ -]?not[_ -]?found|unknown agent/i},{code:"PERMISSION_OR_TRUST",pattern:/(?:permission denied|operation not permitted|workspace trust|not trusted|access denied|EACCES|EPERM)/i},{code:"NETWORK_OR_PROVIDER_TRANSIENT",pattern:/(?:resume failed|failed .*resum(?:e|ing)|after resuming the session|재개 실패|세션 재개)/i},{code:"TIMEOUT_OR_STUCK",pattern:/(?:timeout|timed out|took too long|stuck|idle timeout|ETIMEDOUT)/i},{code:"NETWORK_OR_PROVIDER_TRANSIENT",pattern:/(?:network (?:unreachable|error)|connection (?:reset|refused|closed)|ECONN(?:RESET|REFUSED|ABORTED)|service unavailable|upstream.*(?:5\d\d|error)|provider.*(?:5\d\d|unavailable|down)|\b5\d\d\b)/i},{code:"PROVIDER_CONFIGURATION",pattern:/(?:invalid provider|unsupported provider|provider namespace|provider configuration|provider config|missing provider)/i}];function Ne(e){try{if(!A(e)||e.status!=="failed")return j();let t=Be(e.error);if(W(t.message))return j();let n=m(e.providerId)??t.provider??null,r=Ge(e.logs),o=ae(t.code);if(o)return M(o,n,t.message,t);let i=b(t.providerCode)??b(t.code),a=i?z(i,t.message,{exitCode:$e(e.exitCode),mode:t.mode,fromProviderCodeField:!!t.providerCode}):void 0;if(a)return M(a,n,t.message,t,i);let s=je(r);if(!Fe(t)&&s&&(s.type==="user_stop"||W(s.message)))return j();if(s){let l=He(s.code,s.providerCode,s.message);if(l)return M(l,n,s.message??t.message,t,s.providerCode??s.code,s,s.structuredFailure?"terminal":"envelope")}let p=ze(t.message,r);return p?M(p.code,n,p.message,t,p.terminal?.providerCode??p.terminal?.code,p.terminal,p.terminal?.structuredFailure?"terminal":"envelope"):M("PROCESS_FAILED",n,t.message,t)}catch{return {errorCode:"PROCESS_FAILED",errorProvider:null}}}function j(){return {errorCode:null,errorProvider:null}}function M(e,t,n,r,o,i,a="envelope"){let s={};if(i?.resetAt!==void 0&&(s.resetAt=i.resetAt),r?.model&&(s.model=r.model),r?.mode&&(s.mode=r.mode),i?.type&&(s.upstreamType=i.type),o&&(s.upstreamCode=o),e==="CLI_NOT_AVAILABLE"||e==="CLI_UPDATE_REQUIRED"){let y=t?.startsWith("cli/")?t.slice(4):void 0;y&&(s.cliName=y);}let p=a==="terminal"?n:r?.message,l=a==="terminal"?i?.structuredFailure?p:void 0:r?.isEnvelope?p:void 0,c=G(l);return c&&(s.technicalMessage=c),Object.keys(s).length>0?{errorCode:e,errorProvider:t,errorMeta:s}:{errorCode:e,errorProvider:t}}function Be(e){let t=typeof e=="string"?_(e):e;return A(t)?{isEnvelope:true,code:m(t.code),providerCode:m(t.providerCode),message:m(t.message)??m(t.error),provider:m(t.provider)??m(t.errorProvider),model:m(t.model),mode:m(t.mode)}:{isEnvelope:false,...typeof e=="string"&&e.trim()?{message:e.trim()}:{}}}function _(e){try{return JSON.parse(e)}catch{return}}function Fe(e){return !!(e.code||e.providerCode||e.message)}function Ge(e){let t=[];if(typeof e=="string"){let n=_(e);if(Array.isArray(n))t.push(...n);else for(let r of e.split(/\r?\n/)){let o=_(r.trim());o!==void 0&&t.push(o);}}else Array.isArray(e)?t.push(...e):A(e)&&t.push(e);return t.flatMap(I)}function I(e){if(!A(e))return [];let t=m(e.type),n=m(e.message);if(n&&!t){let o=_(n);if(Array.isArray(o))return o.flatMap(I);if(A(o))return I(o);let i=n.split(/\r?\n/).map(a=>_(a.trim())).filter(a=>A(a));return i.length>0?i.flatMap(I):e.level==="stderr"?[{type:"stderr",message:n,rank:1,structuredFailure:false}]:I({type:"info",content:n})}if(t==="rate_limit_event"){let o=se(e.rate_limit_info);return m(o?.status)!=="rejected"?[]:[{type:t,code:"RATE_LIMITED",message:C(o?.message,e.message),resetAt:Ve(o?.resetsAt),rank:4,structuredFailure:true}]}if(t==="turn.failed"||t==="error"){let o=se(e.error),i=C(o?.message,o?.detail,e.message,e.errorMessage,e.content),a=C(o?.code,e.code,e.errorCode);return [{type:t,code:a,providerCode:C(o?.providerCode,e.providerCode),message:i,rank:t==="turn.failed"?3:2,structuredFailure:true}]}if(t==="text"&&typeof e.content=="string"){let o=_(e.content);if(A(o))return I(o)}let r=C(e.errorMessage,e.content);return r&&W(r)?[{type:"user_stop",message:r,rank:1,structuredFailure:false}]:r&&/(?:turn\.failed|type:error)/i.test(r)?[{type:r.match(/turn\.failed/i)?"turn.failed":"error",message:r,rank:3,structuredFailure:false}]:[]}function je(e){return [...e].sort((t,n)=>n.rank-t.rank)[0]}function He(e,t,n){let r=ae(e);if(r)return r;if(e){let o=z(e,n);if(o)return o}if(t){let o=z(t,n);if(o)return o}return H(n)}function ze(e,t){let n=H(e);if(n)return {code:n,message:e};for(let r of [...t].sort((o,i)=>i.rank-o.rank)){let o=H(r.message);if(o)return {code:o,message:r.message,terminal:r}}}function H(e){if(!(typeof e!="string"||!e.trim()))return Le.find(t=>t.pattern.test(e))?.code}function z(e,t,n){let r=b(e)??e;if(r==="MODEL_UNAVAILABLE")return /(?:capacity|overloaded|busy)/i.test(t??"")?"MODEL_AT_CAPACITY":"MODEL_NOT_SUPPORTED";if(r==="EMPTY_OUTPUT"&&n?.fromProviderCodeField===true&&n.exitCode===0&&We(n.mode))return "AGENT_MODE_RESTRICTED";if(r!=="UNKNOWN")return Ue[r]}function ae(e){let t=b(e);return t&&Se.has(t)?t:void 0}function b(e){return typeof e=="string"&&e.trim()?e.trim().toUpperCase():void 0}function We(e){return typeof e=="string"&&De.has(e.trim().toLowerCase())}function W(e){return e?/\b(?:stopped|killed|aborted|cancelled|canceled)\s+by\s+user\b/i.test(e)||/사용자에 의해 중지됨/.test(e)||/\b(?:SIGTERM\s+143|143\s+SIGTERM)\b/i.test(e):false}function A(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function se(e){return A(e)?e:void 0}function m(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function Ve(e){return typeof e=="string"||typeof e=="number"&&Number.isFinite(e)?e:void 0}function $e(e){return typeof e=="number"&&Number.isInteger(e)?e:void 0}function C(...e){return e.map(m).find(t=>!!t)}var qe=["none","minimal","low","medium","high","xhigh","max","ultra"],Ke={claude:["low","medium","high","xhigh","max"],codex:["none","minimal","low","medium","high","xhigh","max","ultra"],opencode:[],copilot:["none","low","medium","high","xhigh","max"],antigravity:["low","medium","high"],grok:["low","medium","high","xhigh"]};var w={claude:{models:[{id:"claude-fable-5-1",name:"Claude Fable 5.1",contextWindowTokens:1e6,tier:"flagship",recommended:true},{id:"claude-fable-5",name:"Claude Fable 5",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-opus-5-5",name:"Claude Opus 5.5",contextWindowTokens:1e6,tier:"flagship",recommended:true},{id:"claude-opus-5",name:"Claude Opus 5",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-sonnet-5",name:"Claude Sonnet 5",contextWindowTokens:1e6,tier:"balanced",recommended:true},{id:"claude-opus-4-8[1m]",name:"Claude Opus 4.8",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-opus-4-7[1m]",name:"Claude Opus 4.7",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-opus-4-6[1m]",name:"Claude Opus 4.6",contextWindowTokens:1e6,tier:"flagship"},{id:"claude-sonnet-4-6[1m]",name:"Claude Sonnet 4.6",contextWindowTokens:1e6,tier:"balanced"},{id:"claude-haiku-4-5",name:"Claude Haiku 4.5",contextWindowTokens:2e5,tier:"speed"}],modes:[{id:"default",name:"Default",description:"Uses Claude's default permission handling with normal approval prompts."},{id:"acceptEdits",name:"Accept Edits",description:"Allows file edits without approval; other permission checks remain in place."},{id:"plan",name:"Plan",description:"Keeps Claude in plan mode so it can inspect and propose changes without applying them."},{id:"dontAsk",name:"Don't Ask",description:"Does not ask for permissions; only pre-approved tool actions can proceed."},{id:"bypassPermissions",name:"Bypass Permissions",description:"Bypasses Claude permission checks so tools can run without approval prompts."}],effort:["low","medium","high"],modelOverrides:{"claude-fable-5-1":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-fable-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-opus-5-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"medium"},"claude-opus-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-sonnet-5":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-opus-4-8[1m]":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-opus-4-7[1m]":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"claude-opus-4-6[1m]":{effort:["low","medium","high","max"],defaultEffort:"high"},"claude-sonnet-4-6[1m]":{effort:["low","medium","high","max"],defaultEffort:"high"},"claude-haiku-4-5":{effort:[]}},providerOptions:[]},codex:{models:[{id:"gpt-6-astra",name:"GPT-6 Astra",contextWindowTokens:105e4,tier:"flagship"},{id:"gpt-6-sol",name:"GPT-6 Sol",contextWindowTokens:105e4,tier:"balanced",recommended:true},{id:"gpt-6-luna",name:"GPT-6 Luna",contextWindowTokens:105e4,tier:"speed",recommended:true},{id:"gpt-5.6-sol",name:"GPT-5.6 Sol",contextWindowTokens:105e4,tier:"flagship"},{id:"gpt-5.6-terra",name:"GPT-5.6 Terra",contextWindowTokens:105e4,tier:"balanced"},{id:"gpt-5.6-luna",name:"GPT-5.6 Luna",contextWindowTokens:105e4,tier:"speed"},{id:"gpt-5.5",name:"GPT-5.5",contextWindowTokens:105e4,tier:"flagship"},{id:"gpt-5.4",name:"GPT-5.4",contextWindowTokens:105e4,tier:"flagship"},{id:"gpt-5.4-mini",name:"GPT-5.4 Mini",contextWindowTokens:4e5,tier:"speed"},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",contextWindowTokens:4e5,tier:"flagship"},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",contextWindowTokens:128e3,tier:"speed"}],modes:[{id:"agent",name:"Agent",description:"Uses the workspace-write sandbox; can read and modify workspace files without full machine access."},{id:"read-only",name:"Read Only",description:"Uses the read-only sandbox; can inspect files but cannot write to the workspace."},{id:"plan",name:"Plan",description:"Uses the read-only sandbox for planning and inspection; cannot write to the workspace."},{id:"agent-full-access",name:"Agent Full Access",description:"Bypasses approvals and the sandbox; can access and modify files beyond the workspace."},{id:"yolo",name:"YOLO",description:"Bypasses approvals and the sandbox for unrestricted execution and full filesystem access."}],effort:["minimal","low","medium","high"],modelOverrides:{"gpt-6-astra":{effort:["low","medium","high","xhigh","max"],defaultEffort:"xhigh"},"gpt-6-sol":{effort:["none","low","medium","high","xhigh","max"],defaultEffort:"max"},"gpt-6-luna":{effort:["none","low","medium","high","xhigh","max"],defaultEffort:"medium"},"gpt-5.6-sol":{effort:["low","medium","high","xhigh","max","ultra"],defaultEffort:"xhigh"},"gpt-5.6-terra":{effort:["low","medium","high","xhigh","max","ultra"],defaultEffort:"high"},"gpt-5.6-luna":{effort:["low","medium","high","xhigh","max"],defaultEffort:"high"},"gpt-5.5":{effort:["low","medium","high","xhigh"],defaultEffort:"high"}},providerOptions:[]},opencode:{models:[],modes:[{id:"plan",name:"Plan",description:"Uses the plan agent without --auto; planning follows standard approval behavior."},{id:"plan-auto",name:"Plan \xB7 Auto",description:"Uses the plan agent with --auto; planning uses automatic approvals."},{id:"build",name:"Build",description:"Uses the build agent without --auto; work follows standard approval behavior."},{id:"build-auto",name:"Build \xB7 Auto",description:"Uses the build agent with --auto; work uses automatic approvals."}],effort:[],modelOverrides:{},providerOptions:[]},copilot:{models:[{id:"auto",name:"Auto"},{id:"claude-sonnet-5",name:"Claude Sonnet 5",contextWindowTokens:1e6,tier:"balanced"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",contextWindowTokens:1e6,tier:"balanced"},{id:"gpt-5.5",name:"GPT-5.5",contextWindowTokens:105e4,tier:"flagship"},{id:"gpt-5.4",name:"GPT-5.4",contextWindowTokens:105e4,tier:"flagship"},{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro",contextWindowTokens:1048576,tier:"flagship"}],modes:[{id:"interactive",name:"Interactive",description:"Passes --mode interactive; tool access follows Copilot's interactive mode behavior."},{id:"plan",name:"Plan",description:"Passes --mode plan; planning and permission behavior follow Copilot's plan mode."},{id:"autopilot",name:"Autopilot",description:"Passes --mode autopilot; execution behavior follows Copilot's autonomous mode."}],effort:["none","low","medium","high","xhigh","max"],modelOverrides:{},providerOptions:[]},antigravity:{models:[{id:"gemini-3.7-flash",name:"Gemini 3.7 Flash",contextWindowTokens:1048576,tier:"balanced"},{id:"gemini-3.6-flash",name:"Gemini 3.6 Flash",contextWindowTokens:1048576,tier:"balanced"},{id:"gemini-3.5-flash",name:"Gemini 3.5 Flash",contextWindowTokens:1048576,tier:"balanced"},{id:"gemini-3.1-pro",name:"Gemini 3.1 Pro",contextWindowTokens:1048576,tier:"flagship"},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",contextWindowTokens:1e6,tier:"balanced"},{id:"claude-opus-4-6-thinking",name:"Claude Opus 4.6 Thinking",contextWindowTokens:1e6,tier:"flagship"},{id:"gpt-oss-120b",name:"GPT-OSS 120B",contextWindowTokens:128e3,tier:"balanced"}],modes:[{id:"default",name:"Default",description:"Uses Antigravity's default permission handling. No extra permission flags are passed."},{id:"plan",name:"Plan",description:"Passes --mode plan. This turns on /plan; it is not a Claude-style permission mode."},{id:"acceptEdits",name:"Accept Edits",description:"Passes --mode accept-edits."},{id:"bypassPermissions",name:"Bypass Permissions",description:"Passes --dangerously-skip-permissions so tools can run without approval prompts."}],effort:["low","medium","high"],modelOverrides:{"gemini-3.7-flash":{effort:["low","medium","high"],defaultEffort:"medium"},"gemini-3.6-flash":{effort:["low","medium","high"],defaultEffort:"medium"},"gemini-3.5-flash":{effort:["low","medium","high"],defaultEffort:"medium"},"gemini-3.1-pro":{effort:["low","high"],defaultEffort:"high"},"claude-sonnet-4-6":{effort:[]},"claude-opus-4-6-thinking":{effort:[]},"gpt-oss-120b":{effort:["medium"],defaultEffort:"medium"}},providerOptions:[]},grok:{models:[{id:"grok-4.7",name:"Grok 4.7",contextWindowTokens:5e5,tier:"flagship",recommended:true},{id:"grok-4.6",name:"Grok 4.6",contextWindowTokens:5e5,tier:"flagship"},{id:"grok-4.5",name:"Grok 4.5",contextWindowTokens:5e5,tier:"flagship"}],modes:[{id:"default",name:"Default",description:"Uses Grok's default permission handling."},{id:"acceptEdits",name:"Accept Edits",description:"Allows file edits without changing the selected sandbox profile."},{id:"auto",name:"Auto",description:"Uses Grok automatic permission handling."},{id:"dontAsk",name:"Don't Ask",description:"Does not ask for permission before tool execution."},{id:"bypassPermissions",name:"Bypass Permissions",description:"Bypasses Grok permission checks for tool execution."},{id:"plan",name:"Plan",description:"Keeps Grok in planning mode without applying changes."}],effort:["low","medium","high"],modelOverrides:{"grok-4.7":{effort:["low","medium","high","xhigh"],defaultEffort:"high"},"grok-4.6":{effort:["low","medium","high","xhigh"],defaultEffort:"high"},"grok-4.5":{effort:["low","medium","high"],defaultEffort:"high"}},providerOptions:[{key:"alwaysApprove",type:"boolean"},{key:"sandbox",type:"enum",values:["workspace","read-only","off"]}]}},V={providers:{"cli/codex":{model:"gpt-6-sol",query:{mode:"agent",effort:"max"},execute:{mode:"agent-full-access",effort:"max"}},"cli/claude":{model:"claude-opus-5-5",query:{mode:"default",effort:"high"},execute:{mode:"bypassPermissions",effort:"xhigh"}},"cli/grok":{model:"grok-4.7",query:{mode:"default",effort:"high",providerOptions:{alwaysApprove:true,sandbox:"off"}},execute:{mode:"bypassPermissions",effort:"xhigh",providerOptions:{alwaysApprove:true,sandbox:"off"}}}}};Object.fromEntries(Object.entries(w).map(([e,t])=>[e,t.models]));var Qe="claude-opus-4-8",Ze="claude-opus-4-8[1m]",de=[{baseModelId:"claude-opus-4-8",catalogModelId:"claude-opus-4-8[1m]"},{baseModelId:"claude-opus-4-7",catalogModelId:"claude-opus-4-7[1m]"},{baseModelId:"claude-opus-4-6",catalogModelId:"claude-opus-4-6[1m]"},{baseModelId:"claude-sonnet-4-6",catalogModelId:"claude-sonnet-4-6[1m]"}];var Je=new Map(de.map(({baseModelId:e,catalogModelId:t})=>[e,t]));function pe(e){return Je.get(e)??e}var ce=[{legacyId:"Gemini 3.7 Flash (High)",model:"gemini-3.7-flash",effort:"high"},{legacyId:"Gemini 3.7 Flash (Medium)",model:"gemini-3.7-flash",effort:"medium"},{legacyId:"Gemini 3.7 Flash (Low)",model:"gemini-3.7-flash",effort:"low"},{legacyId:"Gemini 3.6 Flash (High)",model:"gemini-3.6-flash",effort:"high"},{legacyId:"Gemini 3.6 Flash (Medium)",model:"gemini-3.6-flash",effort:"medium"},{legacyId:"Gemini 3.6 Flash (Low)",model:"gemini-3.6-flash",effort:"low"},{legacyId:"Gemini 3.5 Flash (Medium)",model:"gemini-3.5-flash",effort:"medium"},{legacyId:"Gemini 3.5 Flash (High)",model:"gemini-3.5-flash",effort:"high"},{legacyId:"Gemini 3.5 Flash (Low)",model:"gemini-3.5-flash",effort:"low"},{legacyId:"Gemini 3.1 Pro (Low)",model:"gemini-3.1-pro",effort:"low"},{legacyId:"Gemini 3.1 Pro (High)",model:"gemini-3.1-pro",effort:"high"},{legacyId:"Claude Sonnet 4.6 (Thinking)",model:"claude-sonnet-4-6"},{legacyId:"Claude Opus 4.6 (Thinking)",model:"claude-opus-4-6-thinking"},{legacyId:"GPT-OSS 120B (Medium)",model:"gpt-oss-120b",effort:"medium"},{legacyId:"gemini-3.7-flash-high",model:"gemini-3.7-flash",effort:"high"},{legacyId:"gemini-3.7-flash-medium",model:"gemini-3.7-flash",effort:"medium"},{legacyId:"gemini-3.7-flash-low",model:"gemini-3.7-flash",effort:"low"},{legacyId:"gemini-3.6-flash-high",model:"gemini-3.6-flash",effort:"high"},{legacyId:"gemini-3.6-flash-medium",model:"gemini-3.6-flash",effort:"medium"},{legacyId:"gemini-3.6-flash-low",model:"gemini-3.6-flash",effort:"low"},{legacyId:"gemini-3.5-flash-high",model:"gemini-3.5-flash",effort:"high"},{legacyId:"gemini-3.5-flash-medium",model:"gemini-3.5-flash",effort:"medium"},{legacyId:"gemini-3.5-flash-low",model:"gemini-3.5-flash",effort:"low"},{legacyId:"gemini-3.1-pro-high",model:"gemini-3.1-pro",effort:"high"},{legacyId:"gemini-3.1-pro-low",model:"gemini-3.1-pro",effort:"low"},{legacyId:"gpt-oss-120b-medium",model:"gpt-oss-120b",effort:"medium"}],et=new Map(ce.map(({legacyId:e,model:t,effort:n})=>[e,n===void 0?{model:t}:{model:t,effort:n}]));function le(e){if(!e)return {};let t=et.get(e);return t?{...t}:{model:e}}function $(e,t){return e==="antigravity"||e==="cli/antigravity"?le(t):t===void 0?{}:{model:pe(t)}}var ue=30,ge=80;Object.keys(nt.special_tokens);var rt=z$1.object({model:z$1.string().optional(),system_prompt:z$1.string().optional(),prompt:z$1.string().optional(),layout:z$1.union([z$1.string(),z$1.object({id:z$1.string(),props:z$1.record(z$1.unknown()).optional()}),z$1.object({props:z$1.record(z$1.unknown())}),z$1.object({template:z$1.string(),capabilities:z$1.object({semanticContinuity:z$1.boolean().optional(),continuity:z$1.boolean().optional(),continuitySlot:z$1.string().optional(),slot:z$1.string().optional()}).optional()})]).optional()}).catchall(z$1.unknown()),ot=z$1.object({include:z$1.array(z$1.string()).optional()}).optional(),it=z$1.object({id:z$1.string(),name:z$1.string().optional(),role:z$1.string().optional(),team:z$1.string().optional(),provider:z$1.union([z$1.string(),z$1.array(z$1.string())]),working_directory:z$1.string().optional(),description:z$1.string().optional(),tags:z$1.array(z$1.string()).optional(),inline:rt.optional(),skills:ot}).catchall(z$1.unknown());z$1.object({id:z$1.string(),name:z$1.string(),workflow_id:z$1.string(),description:z$1.string().optional(),goal_id:z$1.string().optional()});var st=z$1.number().finite().int().min(ue).max(ge),at=z$1.object({inputBudgetPercent:st.optional()}).catchall(z$1.unknown()),dt=z$1.object({continuity:at.optional()}).catchall(z$1.unknown()),pt=z$1.object({bin_resolution:z$1.enum(["global_first","local_first"]).optional(),dreaming:dt.optional(),wi:z$1.object({boards:z$1.array(z$1.unknown()).optional().catch(()=>{})}).catchall(z$1.unknown()).optional().catch(()=>{})}).catchall(z$1.unknown()),fe=z$1.object({agents:z$1.array(it).optional(),hooks:z$1.array(z$1.unknown()).optional(),settings:pt.optional(),skills:z$1.unknown().optional(),layouts:z$1.record(z$1.unknown()).optional(),documents:z$1.record(z$1.unknown()).optional()}).catchall(z$1.unknown());var E=class extends Error{constructor(n,r){super(n);this.cause=r;this.name="ConfigLoadError";}cause};function lt(e){if(!e||typeof e!="string"||!e.trim())throw new E("YAML content must be a non-empty string");let t;try{t=load(e);}catch(o){throw new E(`YAML parse error: ${o.message}`,o)}let n=ut(t),r=fe.safeParse(n);if(!r.success)throw new E(`Config validation error: ${r.error.message}`);return r.data}function ut(e){if(!e||typeof e!="object")return {agents:[]};let t=e;if(t.agents&&typeof t.agents=="object"&&!Array.isArray(t.agents)){let n=t.agents,r=Object.entries(n).map(([o,i])=>({id:o,...i&&typeof i=="object"?i:{}}));return {...t,agents:r}}return t.agents?t:{...t,agents:[]}}var gt={auto:"default"};function ft(e){return gt[e]??e}var mt="crewx:fs:",q=class{prefix;store;constructor(t){this.prefix=t?.prefix??mt,this.store=t?.storage??new Map;}async readFile(t){let n=this.toKey(t),r=this.store.get(n);if(r===void 0)throw new Error(`BrowserFsAdapter: file not found: ${t}`);return r}async exists(t){return this.store.has(this.toKey(t))}resolvePath(...t){let n=t.map(a=>a.replace(/\\/g,"/")).join("/").replace(/\/+/g,"/"),r=n.split("/"),o=[];for(let a of r)a==="."||a===""||(a===".."?o.pop():o.push(a));let i=o.join("/");return n.startsWith("/")?`/${i}`:i}isAbsolute(t){return t.startsWith("/")}setItem(t,n){this.store.set(this.toKey(t),n);}removeItem(t){this.store.delete(this.toKey(t));}keys(){return Array.from(this.store.keys()).filter(t=>t.startsWith(this.prefix)).map(t=>t.slice(this.prefix.length))}async readdir(t){let n=t.replace(/\\/g,"/").replace(/\/$/,""),r=this.toKey(n+"/"),o=[];for(let i of this.store.keys())if(i.startsWith(r)){let s=i.slice(r.length).split("/")[0];s&&!o.includes(s)&&o.push(s);}return o}toKey(t){return `${this.prefix}${t.replace(/\\/g,"/")}`}};var K=["codex","claude","grok","opencode","antigravity","copilot"];function yt(e){let t=e.indexOf("/");return t===-1?e:e.slice(t+1)}function Y(e){let t=yt(e),n=K.indexOf(t);return n===-1?K.length:n}function ht(e,t){return Y(e)-Y(t)}var Tt=new Set(["claude","copilot","codex","grok","opencode"]);function At(e){if(!e)return "";if(e.startsWith("acp/")){let t=e.slice(4);if(Tt.has(t))return `cli/${t}`}return e}function S(e){return {mode:e.mode,effort:e.effort}}function xt(e){let t=V.providers[e];if(!t)return;let n=e.startsWith("cli/")?e.slice(4):e,r=w[n]?.models.find(a=>a.recommended===true&&a.tier==="balanced")?.id??t.model,o={query:S(t.query),execute:S(t.execute)},i={query:S(t.query),execute:S(t.execute)};return {planner:{model:t.model,...o},worker:{model:r,...i}}}var ye=["urgent","high","medium","low"],he=["investigating","in-progress","in-review","on-hold","done"],P="custom:";var It=new Set(ye),_t=new Set(he),Et={urgent:"U \uAE34\uAE09 Urgent",high:"P0 \uAE09\uD568 High",medium:"P1 \uC911\uC694 Medium",low:"P2 \uBCF4\uD1B5 Low"},X={investigating:"\uC870\uC0AC\uC911 Looking into","in-progress":"\uC9C4\uD589\uC911 In progress","in-review":"\uAC80\uD1A0\uC911 In review","on-hold":"\uBCF4\uB958 On hold",done:"\uC644\uB8CC Done"};function me(e,t){return !t||t.includes(e)?t??e:`${e} ${t}`}function Q(e){return typeof e=="string"&&It.has(e)}function Z(e){if(typeof e!="string")return false;if(_t.has(e))return true;if(e.startsWith("c_"))return e.length>2;if(!e.startsWith(P))return false;let t=e.slice(P.length);return t.length>=1&&t.length<=20}function Te(e){if(e.startsWith(P))return e.slice(P.length)}function J(e){if(!e)return null;try{let t=JSON.parse(e);return !t||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}}function Mt(e){let t=J(e);return !!t&&Object.prototype.hasOwnProperty.call(t,"threadTitle")}function Ae(e){let t=J(e);if(!t)return {};let n=t.threadTitle;if(!n||typeof n!="object"||Array.isArray(n))return {};let r=n,o={};return Q(r.priority)&&(o.priority=r.priority),Z(r.state)&&(o.state=r.state),o}function Ct(e,t){let n=J(e)??{},r={...Ae(e)};return t.priority===null?delete r.priority:t.priority!==void 0&&(r.priority=t.priority),t.state===null?delete r.state:t.state!==void 0&&(r.state=t.state),r.priority===void 0&&r.state===void 0?delete n.threadTitle:n.threadTitle=r,Object.keys(n).length===0?null:JSON.stringify(n)}function Pt(e,t=new Map){let n=[];return e.priority&&n.push(me(Et[e.priority],t.get(e.priority))),e.state&&(e.state.startsWith(P)?n.push(Te(e.state)??""):X[e.state]?n.push(me(X[e.state],t.get(e.state))):t.has(e.state)?n.push(e.state,t.get(e.state)??""):e.state.startsWith("c_")?n.push(e.state):n.push(X[e.state]??"")),n.filter(Boolean).join(" ")}function xe(e,t){if(!e||e.trim().length===0)return;let n=new Set,r=false,o=false;for(let i of e.split(",")){let a=i.trim();if(a){if(a==="none"){r=true,o=true;continue}t(a)&&(n.add(a),o=true);}}if(o)return {values:n,includeNone:r}}function vt(e){return xe(e,Q)}function kt(e){return xe(e,Z)}function Rt(e,t){return t?e?t.values.has(e):t.includeNone:true}var Ot=["crewx_app_terminal_connect","crewx_app_html_viewer_open"];var bt=["__proto__","prototype","constructor","proof","token","secret","password","cookie","authorization","private_key","private-key","stack","exception","plugin_text","url","uri","endpoint","path","filename","filepath","cwd","shell","directory","dir","folder"];new Set(bt);var Ie=/^[A-Za-z][A-Za-z0-9._-]{0,127}$/;var _e=["text/plain","application/json"],wt=/^uic_[A-Za-z0-9_-]+$/,St=/^[0-9a-f]{64}$/,h="MCP App content declarations are invalid";function k(e){return typeof e=="string"&&_e.includes(e)}function Ee(e){return typeof e=="string"&&e.length<=128&&wt.test(e)}function Dt(e,t){try{let n=t,r=v(n,"actions");if(!Ce(r))throw new Error(h);let o=[];for(let a of Object.keys(r)){let s=v(r,a);if(s===null||typeof s!="object"||Array.isArray(s))throw new Error(h);let p=Object.getOwnPropertyDescriptor(s,"content");if(p===void 0)continue;if(!Object.hasOwn(p,"value"))throw new Error(h);let l=Lt(p.value);o.push({actionId:a,...l});}if(o.length===0)return;o.sort((a,s)=>a.actionId<s.actionId?-1:a.actionId>s.actionId?1:0);let i={schemaVersion:1,instanceId:e,definition:{id:v(n,"id"),version:v(n,"version"),hash:v(n,"hash")},actions:o};if(!ee(i))throw new Error(h);for(let a of o)a.in!==void 0&&Object.freeze(a.in),a.out!==void 0&&Object.freeze(a.out),Object.freeze(a);return Object.freeze(o),Object.freeze(i.definition),Object.freeze(i)}catch{throw new Error(h)}}function ee(e){try{if(!D(e,["schemaVersion","instanceId","definition","actions"]))return !1;let t=e;if(t.schemaVersion!==1||!Ee(t.instanceId)||!Ft(t.definition))return !1;let n=t.actions;if(!Wt(n)||n.length===0)return !1;let r;for(let o=0;o<n.length;o+=1){let i=n[o];if(!Gt(i)||r!==void 0&&!(r<i.actionId))return !1;r=i.actionId;}return !0}catch{return false}}function Ut(e,t,n){return ee(e)?e.instanceId===t&&e.definition.id===n.id&&e.definition.version===n.version&&e.definition.hash===n.hash:false}function Lt(e){if(!R(e,["in","out"]))throw new Error(h);let t=e,n=Object.hasOwn(t,"in"),r=Object.hasOwn(t,"out");if(!n&&!r)throw new Error(h);return {...n?{in:Nt(t.in)}:{},...r?{out:Bt(t.out)}:{}}}function Nt(e){if(!R(e,["mediaType","required"],["mediaType"]))throw new Error(h);let t=e,n=t.mediaType,r=Object.hasOwn(t,"required")?t.required:false;if(!k(n)||typeof r!="boolean")throw new Error(h);return {mediaType:n,required:r}}function Bt(e){if(!R(e,["mediaType","range"],["mediaType"]))throw new Error(h);let t=e,n=t.mediaType,r=Object.hasOwn(t,"range")?t.range:false;if(!k(n)||typeof r!="boolean")throw new Error(h);return {mediaType:n,range:r}}function Ft(e){if(!D(e,["id","version","hash"]))return false;let t=e;return Me(t.id)&&zt(t.version)&&typeof t.hash=="string"&&St.test(t.hash)}function Gt(e){if(!R(e,["actionId","in","out"],["actionId"]))return false;let t=e,n=t.actionId,r=Object.hasOwn(t,"in"),o=Object.hasOwn(t,"out");return !(typeof n!="string"||!Me(n)||!r&&!o||r&&!jt(t.in)||o&&!Ht(t.out))}function jt(e){if(!D(e,["mediaType","required"]))return false;let t=e;return k(t.mediaType)&&typeof t.required=="boolean"}function Ht(e){if(!D(e,["mediaType","range"]))return false;let t=e;return k(t.mediaType)&&typeof t.range=="boolean"}function Me(e){return typeof e=="string"&&Ie.test(e)}function zt(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function Wt(e){if(!Array.isArray(e))return false;let t=Reflect.ownKeys(e);if(t.length!==e.length+1||t[e.length]!=="length")return false;for(let n=0;n<e.length;n+=1){if(t[n]!==String(n))return false;let r=Object.getOwnPropertyDescriptor(e,String(n));if(r===void 0||!Object.hasOwn(r,"value"))return false}return true}function D(e,t){return R(e,t,t)}function R(e,t,n=[]){if(!Ce(e))return false;let r=Reflect.ownKeys(e);if(r.length>t.length||r.length<n.length)return false;for(let o of r){if(typeof o!="string"||!t.includes(o))return false;let i=Object.getOwnPropertyDescriptor(e,o);if(i===void 0||!Object.hasOwn(i,"value"))return false}return n.every(o=>Object.hasOwn(e,o))}function Ce(e){if(e===null||typeof e!="object"||Array.isArray(e))return false;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function v(e,t){if(e===null||typeof e!="object")return;let n=Object.getOwnPropertyDescriptor(e,t);return n!==void 0&&Object.hasOwn(n,"value")?n.value:void 0}export{ce as ANTIGRAVITY_MODEL_COMPATIBILITY,he as BUILTIN_THREAD_STATES,q as BrowserFsAdapter,de as CLAUDE_MODEL_COMPATIBILITY_PAIRS,Qe as CLAUDE_OPUS_4_8_BASE_MODEL_ID,Ze as CLAUDE_OPUS_4_8_LEGACY_MODEL_ID,E as ConfigLoadError,F as Crewx,qe as EFFORT_LEVELS,Ot as MCP_APP_HOST_TOOL_ALLOWLIST,Ke as PROVIDER_ARGV_EFFORTS,K as PROVIDER_ORDER,f as ProviderError,ye as THREAD_PRIORITIES,_e as UI_CONTENT_MEDIA_TYPES,Dt as buildMcpAppContentActions,Ne as classifyTaskError,ht as compareProviders,Ut as contentActionsMatch,O as createProvider,Te as customStateLabel,xt as getDefaultAgentProfile,Mt as hasThreadTitleKey,ee as isMcpAppContentActions,Q as isThreadPriority,Z as isThreadState,k as isUiContentMediaType,Ee as isValidUiAppInstanceId,Rt as matchesThreadTitleFilter,Ct as mergeThreadTitleMeta,ft as normalizeClaudeMode,At as normalizeProviderId,vt as parseThreadPriorityFilter,kt as parseThreadStateFilter,lt as parseYamlContent,Y as providerRank,Ae as readThreadTitleMeta,G as redactTechnicalMessage,B as registerProviderFactory,le as resolveAntigravityModel,pe as resolveCatalogModelId,$ as resolveProviderCatalogModel,Pt as threadTitleSearchHaystack};
package/dist/index.d.ts CHANGED
@@ -2,9 +2,11 @@ export { Crewx, loadAgentSkills } from './facade/Crewx';
2
2
  export type { ToolDefinition } from './facade/Crewx';
3
3
  export { resolveTaskTicketEnv } from './facade/task-ticket.js';
4
4
  export type { TaskTicketGrant, TaskTicketIssuer, TaskTicketRequest } from './facade/task-ticket.js';
5
+ export { getVerifiedProductAppBundleExecutable } from './mcp-app/bundle-provenance.js';
6
+ export { isVerifiedProductAppBundleProvenance } from './mcp-app/bundle-provenance.js';
5
7
  export { discover as discoverSkills, findEntrypoint, resolve as resolveSkill, } from './skills/index.js';
6
8
  export type { SkillDefinition, SkillFrontmatter, SkillFrontmatterReadResult } from './skills/index.js';
7
- export type { ActionReceipt, ActionReceiptOutcome, CreateUiInstanceInput, JsonObject, JsonPrimitive, JsonValue, UiActionHandlerContext, UiActionHandlerRegistration, UiActionHandlerResult, UiActionEnvelope, UiActionConfirmation, UiActor, UiDefinition, UiDefinitionAction, UiDefinitionDisplayMode, UiDefinitionInput, UiDefinitionLegacyMetadata, UiDefinitionLegacyTool, UiDefinitionLegacyReadTool, UiDefinitionLegacyToolVisibility, UiDefinitionRef, UiDefinitionUsage, UiProjectionPolicy, UiExecutionContext, UiAuthenticatedActor, UiTaskActorSnapshot, UiAuthenticatedExecutionContext, UiApprovalRequestContext, UiApprovalDecisionProvenance, UiApprovalPendingReceipt, UiApprovalRequestReceiptResult, UiAuthenticatedGrantPolicy, UiServerRuntimeFacade, UiServerRuntimeOptions, UiAgentContextProjection, UiExternalActionHandlerRegistration, UiInstance, UiInstanceStatus, UiLocalGrantPolicy, UiRuntimeFacade, UiRuntimeOptions, UiStateActionHandlerRegistration, } from './ui-instance/types.js';
9
+ export type { ActionReceipt, ActionReceiptOutcome, CreateUiInstanceInput, JsonObject, JsonPrimitive, JsonValue, UiActionHandlerContext, UiActionHandlerRegistration, UiActionHandlerResult, UiActionEnvelope, UiActionConfirmation, UiActor, UiDefinition, UiDefinitionAction, UiDefinitionDisplayMode, UiDefinitionInput, UiDefinitionLegacyMetadata, UiDefinitionLegacyTool, UiDefinitionLegacyReadTool, UiDefinitionLegacyToolVisibility, UiDefinitionRef, UiDefinitionUsage, UiProjectionPolicy, UiExecutionContext, UiAuthenticatedActor, UiTaskActorSnapshot, UiAuthenticatedExecutionContext, UiApprovalRequestContext, UiApprovalDecisionProvenance, UiApprovalPendingReceipt, UiApprovalRequestReceiptResult, UiAuthenticatedGrantPolicy, UiServerRuntimeFacade, UiServerRuntimeOptions, UiAgentContextProjection, UiExternalActionHandlerRegistration, UiInstance, UiInstanceStatus, UiLocalGrantPolicy, UiRuntimeFacade, UiRuntimeOptions, UiStateActionHandlerRegistration, UiSkillBackendEnvironmentKey, } from './ui-instance/types.js';
8
10
  export { isUiAuthenticatedActor } from './ui-instance/types.js';
9
11
  export type { UiRuntimeStoreOptions } from './ui-instance/runtime.js';
10
12
  export { UiInstanceStore, openUiInstanceReadStore, UiRuntimeError, hashUiDefinition, hasUiDefinitionLineageBreak, projectSafeJsonObject, redactJsonPaths, selectUiDefinitionLineageEntry, UiDefinitionLineageError, validateUiDefinitionLineage, createUiServerRuntime, resolveUiEffectiveCapabilities, } from './ui-instance/index.js';
@@ -12,9 +14,11 @@ export type { UiAuditSnapshotInput, UiDefinitionLineageEntry, UiDefinitionLineag
12
14
  export type { UiRuntimeErrorCode } from './ui-instance/index.js';
13
15
  export { findProjectionViolations } from './ui-instance/json.js';
14
16
  export type { FindProjectionViolationsOptions, ProjectionRule, ProjectionViolation, } from './ui-instance/json.js';
15
- export { MAX_HTML_LENGTH, MCP_APP_HOST_TOOL_ALLOWLIST, MCP_CORE_TOOL_NAMES, MCP_APP_LOCAL_RESOURCE_MIME_TYPE, MCP_APP_RESOURCE_MIME_TYPE, MCP_APP_RESOURCE_URI_PREFIX, McpAppContractError, resolveAgentAccess, listMcpAppAgentActions, MCP_APP_PROJECTION_MAX_BYTES, MCP_APP_MODEL_CONTEXT_MAX_ARRAY_LENGTH, MCP_APP_MODEL_CONTEXT_MAX_BYTES, MCP_APP_MODEL_CONTEXT_MAX_DEPTH, MCP_APP_MODEL_CONTEXT_MAX_STRING_LENGTH, buildMcpAppStateDescriptor, buildMcpAppStateProjections, projectMcpAppSummaryState, buildMcpAppsContext, buildTerminalMcpAppStateDescriptor, buildTerminalMcpAppStateProjections, createBuiltinMcpAppRegistry, buildMcpAppLocalRegistration, buildMcpAppBundleRegistrationInput, buildMcpAppBundleAgentActionDescriptors, planProductBundleLegacyToolNames, createMcpAppLocalRegistration, registerLocalMcpApp, createMcpAppWorkspaceRegistry, createWorkspaceAppRegistry, createWorkspaceMcpAppRegistry, buildInstalledAppRef, createMcpAppRegistry, createMcpAppToolResult, makeUiUri, resolveMcpAppFixedResultCall, INSTALLED_APP_ENTRY, InstalledAppRefError, registerMcpApp, requireMcpAppResource, resolveLocalMcpAppResource, resolveMcpAppResource, serializeMcpAppStateJson, serializeMcpAppStateXml, sanitizeMcpAppModelContext, serializeMcpAppModelContextXml, toMcpAppToolRegistration, validateInstalledAppRef, AppDiscoveryFsError, NodeAppDiscoveryFs, NodeAppDiscoveryFsAdapter, defaultAppDiscoveryFs, defaultNodeAppDiscoveryFs, deriveWorkspaceAppToolName, deriveWorkspaceAppToolNames, discoverWorkspaceAppCandidates, discoverWorkspaceApps, createWorkspaceAppCatalog, discoverWorkspaceAppCatalog, hashAppDefinition, hashCrewxAppDefinition, listWorkspaceApps, buildWorkspaceAppSnapshot, discoverWorkspaceAppSnapshot, reconfirmWorkspaceAppSnapshot, LOCAL_APP_TOOL_PREFIX, MCP_APP_WORKSPACE_TOOL_PREFIX, scanWorkspaceApps, WORKSPACE_APP_TOOL_PREFIX, SKILL_BACKEND_DEFAULT_TIMEOUT_MS, SKILL_BACKEND_INHERITED_ENV_ALLOWLIST, SKILL_BACKEND_MAX_INPUT_BYTES, SKILL_BACKEND_MAX_OUTPUT_BYTES, SKILL_BACKEND_SCHEMA_VERSION, buildSkillBackendHandler, buildSkillBackendChildEnvironment, buildVerifiedBundleSkillBackendHandler, externalResourceCheckItems, inspectSkillBackendOutput, scanExternalResources, } from './mcp-app/index.js';
16
- export type { AppDevCheckItem, ExternalResourceFinding, ExternalResourceKind, InspectSkillBackendOutputOptions, ScanExternalResourcesOptions, AppDiscoveryBytes, AppDiscoveryDiagnostic, AppDiscoveryDirectoryEntry, AppDiscoveryDirectoryEntryKind, AppDiscoveryDirectoryListing, AppDiscoveryFileSystem, AppDiscoveryFsErrorCode, AppDiscoveryMaybePromise, AppDiscoveryOptions, McpAppDiscoveryDiagnostic, WorkspaceAppBuiltinCatalog, WorkspaceAppCandidate, WorkspaceAppDiscoveryIncompleteReason, WorkspaceAppDiscoveryOptions, WorkspaceAppDiscoveryResult, WorkspaceAppDiscoverySource, WorkspaceAppDiagnostic, WorkspaceAppDiagnosticCode, WorkspaceAppResourceSnapshot, WorkspaceAppReservedCatalog, WorkspaceAppSource, WorkspaceAppToolNames, ProductAppBundleDefinitionIdentity, ProductAppBundleFileHash, ProductAppBundleIndex, ProductAppBundleInput, ProductAppBundlePackageIndex, ProductAppBundleProvenance, CrewxAppBuiltinCatalog, CrewxAppCapability, CrewxAppCatalogOptions, CrewxAppCatalogResult, CrewxAppDefinitionHashInput, CrewxAppDefinitionSummary, CrewxAppDiagnostic, CrewxAppDiagnosticCode, CrewxAppDiagnosticSource, CrewxAppInstalledProjection, CrewxAppLocalDefinitionRef, CrewxAppOrigin, CrewxAppOwnership, CrewxAppShareability, CrewxAppSharingAvailability, CrewxAppSummary, McpAppActionDispatcherToolInput, McpAppActionToolDescriptor, McpAppActionToolInput, McpAppButtonDescriptor, McpAppButtonInput, McpAppContractErrorCode, McpAppDescriptor, McpAppDescriptorInput, McpAppInputSchema, McpAppTone, McpUiResourceCsp, McpAppRegistry, McpAppResource, McpAppServerStateInput, McpAppStateDescriptor, McpAppStateProjections, McpAppsContext, McpAppModelContext, McpAppModelContextInput, McpAppHostToolInput, McpAppHostToolName, McpCoreToolName, McpAppReadToolInput, McpAppSingleActionToolInput, McpAppToolCommonInput, McpAppToolDescriptor, McpAppFixedResult, McpAppFixedResultCall, McpAppFixedResultInvalidParams, McpAppFixedResultResolution, McpAppFixedResultUnavailable, McpAppToolInput, McpAppToolMetadata, McpAppToolRegistration, McpAppToolResult, McpAppToolVisibility, McpAppInstanceResourceBinding, McpAppMcpResourceBinding, McpAppResourceBinding, McpAppLocalResource, McpAppLocalRegistrationInput, McpAppLocalReadToolDescriptor, McpAppLocalActionToolDescriptor, McpAppLocalSingleActionToolDescriptor, McpAppLocalToolDiagnostic, McpAppAgentAccess, McpAppAgentAccessAction, McpAppVerifiedBundleAccessContext, McpAppLocalToolDescriptor, McpAppLocalRegistration, McpAppBuiltinRegistration, McpAppResolvedRegistration, McpAppLocalLauncher, McpAppBuiltinLauncher, McpAppLauncher, WorkspaceAppLauncher, WorkspaceAppResolvedRegistration, McpAppWorkspaceRegistry, WorkspaceAppRegistry, McpAppWorkspaceRegistryInput, WorkspaceAppSnapshot, WorkspaceAppSnapshotBuildOptions, WorkspaceAppSnapshotOptions, WorkspaceAppSnapshotReconfirmResult, WorkspaceAppSnapshotResource, WorkspaceAppSnapshotInitialState, WorkspaceAppInitialState, BuildInstalledAppRefInput, InstalledAppPackageFile, InstalledAppRef, InstalledAppRefErrorCode, SkillBackendExecutionPort, SkillBackendExecutionRequest, SkillBackendExecutionResponse, SkillBackendHandlerBuildInput, SkillBackendInfrastructureErrorCode, SkillBackendPayload, SkillBackendChildEnvironment, VerifiedBundleSkillBackendBuildInput, VerifiedBundleSkillRunnerPort, VerifiedBundleSkillSpawnRequest, McpAppRegistryOptions, McpAppBundleHostToolTemplate, McpAppBundleAgentActionDescriptor, } from './mcp-app/index.js';
17
+ export { MAX_HTML_LENGTH, MCP_APP_HOST_TOOL_ALLOWLIST, MCP_CORE_TOOL_NAMES, MCP_APP_LOCAL_RESOURCE_MIME_TYPE, MCP_APP_RESOURCE_MIME_TYPE, MCP_APP_RESOURCE_URI_PREFIX, McpAppContractError, resolveAgentAccess, listMcpAppAgentActions, MCP_APP_PROJECTION_MAX_BYTES, MCP_APP_MODEL_CONTEXT_MAX_ARRAY_LENGTH, MCP_APP_MODEL_CONTEXT_MAX_BYTES, MCP_APP_MODEL_CONTEXT_MAX_DEPTH, MCP_APP_MODEL_CONTEXT_MAX_STRING_LENGTH, buildMcpAppStateDescriptor, buildMcpAppStateProjections, projectMcpAppSummaryState, buildMcpAppsContext, buildTerminalMcpAppStateDescriptor, buildTerminalMcpAppStateProjections, createBuiltinMcpAppRegistry, buildMcpAppLocalRegistration, buildMcpAppBundleRegistrationInput, buildMcpAppBundleAgentActionDescriptors, planProductBundleLegacyToolNames, productAppBundleReservations, createMcpAppLocalRegistration, registerLocalMcpApp, createMcpAppWorkspaceRegistry, createWorkspaceAppRegistry, createWorkspaceMcpAppRegistry, buildInstalledAppRef, createMcpAppRegistry, createMcpAppToolResult, makeUiUri, resolveMcpAppFixedResultCall, INSTALLED_APP_ENTRY, InstalledAppRefError, registerMcpApp, requireMcpAppResource, resolveLocalMcpAppResource, resolveMcpAppResource, serializeMcpAppStateJson, serializeMcpAppStateXml, sanitizeMcpAppModelContext, serializeMcpAppModelContextXml, toMcpAppToolRegistration, validateInstalledAppRef, AppDiscoveryFsError, NodeAppDiscoveryFs, NodeAppDiscoveryFsAdapter, defaultAppDiscoveryFs, defaultNodeAppDiscoveryFs, deriveWorkspaceAppToolName, deriveWorkspaceAppToolNames, discoverWorkspaceAppCandidates, discoverWorkspaceApps, loadProductAppBundleAssets, createWorkspaceAppCatalog, discoverWorkspaceAppCatalog, hashAppDefinition, hashCrewxAppDefinition, listWorkspaceApps, buildWorkspaceAppSnapshot, discoverWorkspaceAppSnapshot, reconfirmWorkspaceAppSnapshot, LOCAL_APP_TOOL_PREFIX, MCP_APP_WORKSPACE_TOOL_PREFIX, scanWorkspaceApps, WORKSPACE_APP_TOOL_PREFIX, SKILL_BACKEND_DEFAULT_TIMEOUT_MS, SKILL_BACKEND_INHERITED_ENV_ALLOWLIST, SKILL_BACKEND_MAX_INPUT_BYTES, SKILL_BACKEND_MAX_OUTPUT_BYTES, SKILL_BACKEND_CONTENT_SCHEMA_VERSION, SKILL_BACKEND_SCHEMA_VERSION, buildSkillBackendHandler, buildSkillBackendChildEnvironment, buildVerifiedBundleSkillBackendHandler, buildMcpAppContentActions, contentActionsMatch, UI_CONTENT_ERROR_CODES, UI_CONTENT_MAX_BYTES, UI_CONTENT_MAX_LINES, UI_CONTENT_MAX_MEMORY_BYTES, UI_CONTENT_MEDIA_TYPES, UI_CONTENT_OUTPUT_TTL_MS, UI_CONTENT_TICKET_TTL_MS, UiContentChannelError, contentBindingMatches, countContentLines, decodeContentUtf8, isUiContentDeclaration, isUiContentMediaType, isMcpAppContentActions, isUiContentRangeRequest, isValidUiAppInstanceId, isValidUiThreadIdentity, sha256Content, validateContentBytes, validateContentFrame, externalResourceCheckItems, inspectSkillBackendOutput, scanExternalResources, } from './mcp-app/index.js';
18
+ export type { AppDevCheckItem, ExternalResourceFinding, ExternalResourceKind, InspectSkillBackendOutputOptions, ScanExternalResourcesOptions, AppDiscoveryBytes, AppDiscoveryDiagnostic, AppDiscoveryDirectoryEntry, AppDiscoveryDirectoryEntryKind, AppDiscoveryDirectoryListing, AppDiscoveryFileSystem, AppDiscoveryFsErrorCode, AppDiscoveryMaybePromise, AppDiscoveryOptions, McpAppDiscoveryDiagnostic, WorkspaceAppBuiltinCatalog, WorkspaceAppCandidate, WorkspaceAppDiscoveryIncompleteReason, WorkspaceAppDiscoveryOptions, WorkspaceAppDiscoveryResult, WorkspaceAppDiscoverySource, WorkspaceAppDiagnostic, WorkspaceAppDiagnosticCode, WorkspaceAppResourceSnapshot, WorkspaceAppReservedCatalog, WorkspaceAppSource, WorkspaceAppToolNames, ProductAppBundleDefinitionIdentity, ProductAppBundleFileHash, ProductAppBundleIndex, ProductAppBundleInput, ProductAppBundlePackageIndex, ProductAppBundleReservations, ProductAppBundleProvenance, ProductAppBundleSnapshotMetadata, ProductAppBundleAsset, ProductAppBundleAssetCatalog, ProductAppBundleAssetLoadOptions, CrewxAppBuiltinCatalog, CrewxAppCapability, CrewxAppCatalogOptions, CrewxAppCatalogResult, CrewxAppDefinitionHashInput, CrewxAppDefinitionSummary, CrewxAppDiagnostic, CrewxAppDiagnosticCode, CrewxAppDiagnosticSource, CrewxAppInstalledProjection, CrewxAppLocalDefinitionRef, CrewxAppOrigin, CrewxAppOwnership, CrewxAppShareability, CrewxAppSharingAvailability, CrewxAppSummary, McpAppActionDispatcherToolInput, McpAppActionToolDescriptor, McpAppActionToolInput, McpAppButtonDescriptor, McpAppButtonInput, McpAppContractErrorCode, McpAppDescriptor, McpAppDescriptorInput, McpAppInputSchema, McpAppTone, McpUiResourceCsp, McpAppRegistry, McpAppResource, McpAppServerStateInput, McpAppStateDescriptor, McpAppStateProjections, McpAppsContext, McpAppModelContext, McpAppModelContextInput, McpAppHostToolInput, McpAppHostToolName, McpCoreToolName, McpAppReadToolInput, McpAppSingleActionToolInput, McpAppToolCommonInput, McpAppToolDescriptor, McpAppFixedResult, McpAppFixedResultCall, McpAppFixedResultInvalidParams, McpAppFixedResultResolution, McpAppFixedResultUnavailable, McpAppToolInput, McpAppToolMetadata, McpAppToolRegistration, McpAppToolResult, McpAppToolVisibility, McpAppInstanceResourceBinding, McpAppMcpResourceBinding, McpAppResourceBinding, McpAppLocalResource, McpAppLocalRegistrationInput, McpAppLocalReadToolDescriptor, McpAppLocalActionToolDescriptor, McpAppLocalSingleActionToolDescriptor, McpAppLocalToolDiagnostic, McpAppAgentAccess, McpAppAgentAccessAction, McpAppVerifiedBundleAccessContext, McpAppLocalToolDescriptor, McpAppLocalRegistration, McpAppBuiltinRegistration, McpAppResolvedRegistration, McpAppLocalLauncher, McpAppBuiltinLauncher, McpAppLauncher, WorkspaceAppLauncher, WorkspaceAppResolvedRegistration, McpAppWorkspaceRegistry, WorkspaceAppRegistry, McpAppWorkspaceRegistryInput, WorkspaceAppSnapshot, WorkspaceAppSnapshotBuildOptions, WorkspaceAppSnapshotOptions, WorkspaceAppSnapshotReconfirmResult, WorkspaceAppSnapshotResource, WorkspaceAppSnapshotInitialState, WorkspaceAppInitialState, BuildInstalledAppRefInput, InstalledAppPackageFile, InstalledAppRef, InstalledAppRefErrorCode, SkillBackendExecutionPort, SkillBackendExecutionRequest, SkillBackendExecutionResponse, SkillBackendHandlerBuildInput, SkillBackendInfrastructureErrorCode, SkillBackendPayload, SkillBackendChildEnvironment, VerifiedBundleSkillBackendBuildInput, VerifiedBundleSkillRunnerPort, VerifiedBundleSkillSpawnRequest, McpAppRegistryOptions, McpAppBundleHostToolTemplate, McpAppBundleAgentActionDescriptor, SkillBackendPayloadV1, SkillBackendPayloadV2, SkillBackendContentInputHeader, SkillBackendContentOutputHeader, ContentFrame, McpAppContentActionDeclaration, McpAppContentActions, UiActionContentDeclaration, UiContentBinding, UiContentChannelPort, UiContentErrorCode, UiContentInputDeclaration, UiContentInputTicket, UiContentMediaType, UiContentOutputDeclaration, UiContentRange, UiContentRangeRequest, ValidateContentFrameOptions, } from './mcp-app/index.js';
17
19
  export { canonicalManifestJson, manifestHash, normalizeManifest, UiPluginValidationError, validateInitialState, validateManifest, validatePayload, } from './ui-plugin/index.js';
20
+ export { normalizeUiPluginCsp, policyHash } from './ui-plugin/csp.js';
21
+ export type { NormalizedUiPluginCsp, UiPluginCspInput, UiPluginCspNormalizationErrorCode, UiPluginPolicyHashInput, UiPluginPolicyRuntime, } from './ui-plugin/csp.js';
18
22
  export { UI_PLUGIN_CAPABILITY_PATTERN, UI_PLUGIN_HANDLER_PATTERN, UI_PLUGIN_IDENTIFIER_PATTERN, UI_PLUGIN_MAX_CANDIDATE_DEPTH, UI_PLUGIN_MAX_ACTIONS, UI_PLUGIN_MAX_ARRAY_LENGTH, UI_PLUGIN_MAX_COMMAND_LENGTH, UI_PLUGIN_MAX_COMMAND_PARTS, UI_PLUGIN_MAX_DISCOVERED_APPS, UI_PLUGIN_MAX_DISCOVERY_TIME_MS, UI_PLUGIN_MAX_HEIGHT, UI_PLUGIN_MAX_INITIAL_STATE_BYTES, UI_PLUGIN_MAX_JSON_DEPTH, UI_PLUGIN_MAX_MANIFEST_BYTES, UI_PLUGIN_MAX_PROJECTION_PATHS, UI_PLUGIN_MAX_SCHEMA_DEPTH, UI_PLUGIN_MAX_SCHEMA_PROPERTIES, UI_PLUGIN_MAX_STRING_LENGTH, UI_PLUGIN_MAX_SUBTREE_BYTES, UI_PLUGIN_MAX_SURFACES, UI_PLUGIN_RESERVED_STATE_KEYS, UI_PLUGIN_SAFE_PATH_PATTERN, UI_PLUGIN_SAFE_PATH_SEGMENT_PATTERN, UI_PLUGIN_SKILL_TOKEN_PATTERN, UI_PLUGIN_SURFACES, UI_PLUGIN_TONES, isUiPluginReservedStateKey, } from './ui-plugin/index.js';
19
23
  export type { UiPluginActivation, UiPluginCardShellNode, UiPluginFieldSchema, UiPluginHeadingNode, UiPluginLabeledTextNode, UiPluginLayoutNode, UiPluginLayout, UiPluginManifest, UiPluginAction, UiPluginBackend, UiPluginCoreBackend, UiPluginInputSchema, UiPluginJsonSchema, UiPluginJsonSchemaType, UiPluginManifestMode, UiPluginManifestV1, UiPluginManifestV2, UiPluginNormalizedManifestV2, UiPluginNormalizedV2, UiPluginMetaBannerNode, UiPluginPayload, UiPluginPayloadValue, UiPluginPrimitive, UiPluginSchemaType, UiPluginSchema, UiPluginStep, UiPluginStepFlowNode, UiPluginStepListSchema, UiPluginTextListNode, UiPluginTextListSchema, UiPluginTextSchema, UiPluginProjectionPolicy, UiPluginResourceMetadata, UiPluginResourceRef, UiPluginSize, UiPluginSkillBackend, UiPluginSurface, UiPluginTone, UiPluginHandlerMetadata, UiPluginValidationErrorCode, UiPluginValidationOptions, } from './ui-plugin/index.js';
20
24
  export { DEFAULT_PUBLISH_MAX_BYTES, DEFAULT_PUBLISH_MAX_FILES, packApp, packPublish, packTemplate, planPublish, PublishError, uploadToMarketplace, } from './publish/index.js';