faf-cli 6.11.0 → 6.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -162,15 +162,15 @@ ${Z.comment}`:Z.comment}this.doc.range[2]=Z.offset;break}default:this.errors.pus
162
162
  `)+1;while(Z!==0)this.onNewLine(this.offset+Z),Z=this.source.indexOf(`
163
163
  `,Z)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap($){let Z=$.items[$.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,Z.value){let z="end"in Z.value?Z.value.end:void 0;if((Array.isArray(z)?z[z.length-1]:void 0)?.type==="comment")z?.push(this.sourceToken);else $.items.push({start:[this.sourceToken]})}else if(Z.sep)Z.sep.push(this.sourceToken);else Z.start.push(this.sourceToken);return;case"space":case"comment":if(Z.value)$.items.push({start:[this.sourceToken]});else if(Z.sep)Z.sep.push(this.sourceToken);else{if(this.atIndentedComment(Z.start,$.indent)){let X=$.items[$.items.length-2]?.value?.end;if(Array.isArray(X)){Array.prototype.push.apply(X,Z.start),X.push(this.sourceToken),$.items.pop();return}}Z.start.push(this.sourceToken)}return}if(this.indent>=$.indent){let z=!this.onKeyLine&&this.indent===$.indent,X=z&&(Z.sep||Z.explicitKey)&&this.type!=="seq-item-ind",J=[];if(X&&Z.sep&&!Z.value){let Q=[];for(let Y=0;Y<Z.sep.length;++Y){let U=Z.sep[Y];switch(U.type){case"newline":Q.push(Y);break;case"space":break;case"comment":if(U.indent>$.indent)Q.length=0;break;default:Q.length=0}}if(Q.length>=2)J=Z.sep.splice(Q[1])}switch(this.type){case"anchor":case"tag":if(X||Z.value)J.push(this.sourceToken),$.items.push({start:J}),this.onKeyLine=!0;else if(Z.sep)Z.sep.push(this.sourceToken);else Z.start.push(this.sourceToken);return;case"explicit-key-ind":if(!Z.sep&&!Z.explicitKey)Z.start.push(this.sourceToken),Z.explicitKey=!0;else if(X||Z.value)J.push(this.sourceToken),$.items.push({start:J,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(Z.explicitKey)if(!Z.sep)if(z$(Z.start,"newline"))Object.assign(Z,{key:null,sep:[this.sourceToken]});else{let Q=p$(Z.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:Q,key:null,sep:[this.sourceToken]}]})}else if(Z.value)$.items.push({start:[],key:null,sep:[this.sourceToken]});else if(z$(Z.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:J,key:null,sep:[this.sourceToken]}]});else if(p9(Z.key)&&!z$(Z.sep,"newline")){let Q=p$(Z.start),Y=Z.key,U=Z.sep;U.push(this.sourceToken),delete Z.key,delete Z.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:Q,key:Y,sep:U}]})}else if(J.length>0)Z.sep=Z.sep.concat(J,this.sourceToken);else Z.sep.push(this.sourceToken);else if(!Z.sep)Object.assign(Z,{key:null,sep:[this.sourceToken]});else if(Z.value||X)$.items.push({start:J,key:null,sep:[this.sourceToken]});else if(z$(Z.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else Z.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let Q=this.flowScalar(this.type);if(X||Z.value)$.items.push({start:J,key:Q,sep:[]}),this.onKeyLine=!0;else if(Z.sep)this.stack.push(Q);else Object.assign(Z,{key:Q,sep:[]}),this.onKeyLine=!0;return}default:{let Q=this.startBlockValue($);if(Q){if(Q.type==="block-seq"){if(!Z.explicitKey&&Z.sep&&!z$(Z.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(z)$.items.push({start:J});this.stack.push(Q);return}}}}yield*this.pop(),yield*this.step()}*blockSequence($){let Z=$.items[$.items.length-1];switch(this.type){case"newline":if(Z.value){let z="end"in Z.value?Z.value.end:void 0;if((Array.isArray(z)?z[z.length-1]:void 0)?.type==="comment")z?.push(this.sourceToken);else $.items.push({start:[this.sourceToken]})}else Z.start.push(this.sourceToken);return;case"space":case"comment":if(Z.value)$.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(Z.start,$.indent)){let X=$.items[$.items.length-2]?.value?.end;if(Array.isArray(X)){Array.prototype.push.apply(X,Z.start),X.push(this.sourceToken),$.items.pop();return}}Z.start.push(this.sourceToken)}return;case"anchor":case"tag":if(Z.value||this.indent<=$.indent)break;Z.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==$.indent)break;if(Z.value||z$(Z.start,"seq-item-ind"))$.items.push({start:[this.sourceToken]});else Z.start.push(this.sourceToken);return}if(this.indent>$.indent){let z=this.startBlockValue($);if(z){this.stack.push(z);return}}yield*this.pop(),yield*this.step()}*flowCollection($){let Z=$.items[$.items.length-1];if(this.type==="flow-error-end"){let z;do yield*this.pop(),z=this.peek(1);while(z?.type==="flow-collection")}else if($.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!Z||Z.sep)$.items.push({start:[this.sourceToken]});else Z.start.push(this.sourceToken);return;case"map-value-ind":if(!Z||Z.value)$.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Z.sep)Z.sep.push(this.sourceToken);else Object.assign(Z,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!Z||Z.value)$.items.push({start:[this.sourceToken]});else if(Z.sep)Z.sep.push(this.sourceToken);else Z.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let X=this.flowScalar(this.type);if(!Z||Z.value)$.items.push({start:[],key:X,sep:[]});else if(Z.sep)this.stack.push(X);else Object.assign(Z,{key:X,sep:[]});return}case"flow-map-end":case"flow-seq-end":$.end.push(this.sourceToken);return}let z=this.startBlockValue($);if(z)this.stack.push(z);else yield*this.pop(),yield*this.step()}else{let z=this.peek(2);if(z.type==="block-map"&&(this.type==="map-value-ind"&&z.indent===$.indent||this.type==="newline"&&!z.items[z.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&z.type!=="flow-collection"){let X=b2(z),J=p$(X);d9($);let Q=$.end.splice(1,$.end.length);Q.push(this.sourceToken);let Y={type:"block-map",offset:$.offset,indent:$.indent,items:[{start:J,key:$,sep:Q}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=Y}else yield*this.lineEnd($)}}flowScalar($){if(this.onNewLine){let Z=this.source.indexOf(`
164
164
  `)+1;while(Z!==0)this.onNewLine(this.offset+Z),Z=this.source.indexOf(`
165
- `,Z)+1}return{type:$,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue($){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let Z=b2($),z=p$(Z);return z.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:z,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let Z=b2($),z=p$(Z);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:z,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment($,Z){if(this.type!=="comment")return!1;if(this.indent<=Z)return!1;return $.every((z)=>z.type==="newline"||z.type==="space")}*documentEnd($){if(this.type!=="doc-mode"){if($.end)$.end.push(this.sourceToken);else $.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd($){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if($.end)$.end.push(this.sourceToken);else $.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}vK.Parser=l9});var a9=A((sK)=>{var i9=E8(),mK=c1(),s1=d1(),cK=v6(),dK=c(),pK=v8(),n9=u8();function s9($){let Z=$.prettyErrors!==!1;return{lineCounter:$.lineCounter||Z&&new pK.LineCounter||null,prettyErrors:Z}}function lK($,Z={}){let{lineCounter:z,prettyErrors:X}=s9(Z),J=new n9.Parser(z?.addNewLine),Q=new i9.Composer(Z),Y=Array.from(Q.compose(J.parse($)));if(X&&z)for(let U of Y)U.errors.forEach(s1.prettifyError($,z)),U.warnings.forEach(s1.prettifyError($,z));if(Y.length>0)return Y;return Object.assign([],{empty:!0},Q.streamInfo())}function r9($,Z={}){let{lineCounter:z,prettyErrors:X}=s9(Z),J=new n9.Parser(z?.addNewLine),Q=new i9.Composer(Z),Y=null;for(let U of Q.compose(J.parse($),!0,$.length))if(!Y)Y=U;else if(Y.options.logLevel!=="silent"){Y.errors.push(new s1.YAMLParseError(U.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(X&&z)Y.errors.forEach(s1.prettifyError($,z)),Y.warnings.forEach(s1.prettifyError($,z));return Y}function iK($,Z,z){let X=void 0;if(typeof Z==="function")X=Z;else if(z===void 0&&Z&&typeof Z==="object")z=Z;let J=r9($,z);if(!J)return null;if(J.warnings.forEach((Q)=>cK.warn(J.options.logLevel,Q)),J.errors.length>0)if(J.options.logLevel!=="silent")throw J.errors[0];else J.errors=[];return J.toJS(Object.assign({reviver:X},z))}function nK($,Z,z){let X=null;if(typeof Z==="function"||Array.isArray(Z))X=Z;else if(z===void 0&&Z)z=Z;if(typeof z==="string")z=z.length;if(typeof z==="number"){let J=Math.round(z);z=J<1?void 0:J>8?{indent:8}:{indent:J}}if($===void 0){let{keepUndefined:J}=z??Z??{};if(!J)return}if(dK.isDocument($)&&!X)return $.toString(z);return new mK.Document($,X,z).toString(z)}sK.parse=iK;sK.parseAllDocuments=lK;sK.parseDocument=r9;sK.stringify=nK});var Z7={};wZ(Z7,{orange:()=>V0,italic:()=>hH,fafCyanDeep:()=>k2,fafCyan:()=>D,dim:()=>N,bold:()=>w,FAF_HEX:()=>r1});var d8=($)=>(Z)=>`\x1B[${$}m${Z}\x1B[0m`,w,N,hH,r1,D=($)=>`\x1B[38;2;0;212;212m${$}\x1B[0m`,k2=($)=>`\x1B[38;2;14;140;140m${$}\x1B[0m`,V0=($)=>`\x1B[38;5;208m${$}\x1B[0m`;var d=S(()=>{w=d8("1"),N=d8("2"),hH=d8("3"),r1={cyan:"#00D4D4",cyanDeep:"#0E8C8C",orange:"#FF6B35"}});var Z3=A((eA,iL)=>{iL.exports={name:"faf-cli",version:"6.11.0",description:"Persistent AI Context Standard — project DNA for AI. IANA-registered. Anthropic-approved.",type:"module",icon:"https://faf.one/orange-smiley.svg",logo:"https://faf.one/orange-smiley.svg",main:"dist/index.js",types:"./dist/index.d.ts",bin:{faf:"dist/cli.js","faf-cli":"dist/cli.js"},exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"}},files:["dist/**/*","README.md","LICENSE","project.faf"],scripts:{dev:"bun src/cli.ts",build:"bun build src/cli.ts --outdir dist --target=node --minify --sourcemap=linked --external faf-scoring-kernel --external open && bun build src/index.ts --outdir dist --target=node --minify --sourcemap=linked --external faf-scoring-kernel --external open && tsc -p tsconfig.build.json",compile:"bun build src/cli.ts --compile --bytecode --minify --outfile faf","compile:all":"bun build src/cli.ts --compile --bytecode --minify --target=bun-darwin-arm64 --outfile faf-darwin-arm64 && bun build src/cli.ts --compile --bytecode --minify --target=bun-darwin-x64 --outfile faf-darwin-x64 && bun build src/cli.ts --compile --bytecode --minify --target=bun-linux-x64 --outfile faf-linux-x64 && bun build src/cli.ts --compile --bytecode --minify --target=bun-windows-x64 --outfile faf-windows-x64.exe",test:"bun test --timeout=120000","test:watch":"bun test --watch --timeout=120000",lint:"eslint src/**/*.ts",format:"prettier --write 'src/**/*.ts'","check:no-hardcode":"! grep -rEln '/(Users|home/runner|private/var)/' dist/ || (echo '❌ Hardcoded build-machine path leaked into dist — see grep output above. Externalize the offending dep in the build script.'; exit 1)",prepublishOnly:"bun run build && bun run check:no-hardcode"},keywords:["faf","ai-context","project-dna","bi-sync","cli","claude","gemini","cursor","mcp","model-context-protocol","persistent-context","ai-readiness","foundational"],author:"wolfejam <wolfejam@faf.one>",license:"MIT",repository:{type:"git",url:"https://github.com/Wolfe-Jam/faf-cli.git"},homepage:"https://faf.one",bugs:{url:"https://github.com/Wolfe-Jam/faf-cli/issues"},dependencies:{commander:"^14.0.1","faf-scoring-kernel":"^2.0.3",open:"^11.0.0",yaml:"^2.4.1"},optionalDependencies:{"@anthropic-ai/sdk":"^0.91.1"},devDependencies:{"@faf/specification":"github:Wolfe-Jam/faf",ajv:"^8.17.1","@types/node":"^22.15.0","@typescript-eslint/eslint-plugin":"^8.41.0","@typescript-eslint/parser":"^8.41.0",eslint:"^9.39.2",prettier:"^3.2.5",typescript:"^5.3.3","typescript-eslint":"^8.59.1"},engines:{node:">=18.0.0"},publishConfig:{access:"public"}}});function R($,Z,z,X,J){if(X==="m")throw TypeError("Private method is not writable");if(X==="a"&&!J)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!J:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?J.call($,z):J?J.value=z:Z.set($,z),z}function H($,Z,z,X){if(z==="a"&&!X)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!X:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return z==="m"?X:z==="a"?X.call($):X?X.value:Z.get($)}var d0=()=>{};var J3=function(){let{crypto:$}=globalThis;if($?.randomUUID)return J3=$.randomUUID.bind($),$.randomUUID();let Z=new Uint8Array(1),z=$?()=>$.getRandomValues(Z)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(X)=>(+X^z()&15>>+X/4).toString(16))};function p0($){return typeof $==="object"&&$!==null&&(("name"in $)&&$.name==="AbortError"||("message"in $)&&String($.message).includes("FetchRequestCanceledException"))}var Z4=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null){try{if(Object.prototype.toString.call($)==="[object Error]"){let Z=Error($.message,$.cause?{cause:$.cause}:{});if($.stack)Z.stack=$.stack;if($.cause&&!Z.cause)Z.cause=$.cause;if($.name)Z.name=$.name;return Z}}catch{}try{return Error(JSON.stringify($))}catch{}}return Error($)};var _,X0,q0,Y$,$1,Z1,z1,X1,J1,Q1,Y1,U1,G1;var N0=S(()=>{_=class _ extends Error{};X0=class X0 extends _{constructor($,Z,z,X,J){super(`${X0.makeMessage($,Z,z)}`);this.status=$,this.headers=X,this.requestID=X?.get("request-id"),this.error=Z,this.type=J??null}static makeMessage($,Z,z){let X=Z?.message?typeof Z.message==="string"?Z.message:JSON.stringify(Z.message):Z?JSON.stringify(Z):z;if($&&X)return`${$} ${X}`;if($)return`${$} status code (no body)`;if(X)return X;return"(no status code or body)"}static generate($,Z,z,X){if(!$||!X)return new Y$({message:z,cause:Z4(Z)});let J=Z,Q=J?.error?.type;if($===400)return new Z1($,J,z,X,Q);if($===401)return new z1($,J,z,X,Q);if($===403)return new X1($,J,z,X,Q);if($===404)return new J1($,J,z,X,Q);if($===409)return new Q1($,J,z,X,Q);if($===422)return new Y1($,J,z,X,Q);if($===429)return new U1($,J,z,X,Q);if($>=500)return new G1($,J,z,X,Q);return new X0($,J,z,X,Q)}};q0=class q0 extends X0{constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}};Y$=class Y$ extends X0{constructor({message:$,cause:Z}){super(void 0,void 0,$||"Connection error.",void 0);if(Z)this.cause=Z}};$1=class $1 extends Y${constructor({message:$}={}){super({message:$??"Request timed out."})}};Z1=class Z1 extends X0{};z1=class z1 extends X0{};X1=class X1 extends X0{};J1=class J1 extends X0{};Q1=class Q1 extends X0{};Y1=class Y1 extends X0{};U1=class U1 extends X0{};G1=class G1 extends X0{}});function n2($){if(typeof $!=="object")return{};return $??{}}function U3($){if(!$)return!0;for(let Z in $)return!1;return!0}function _z($,Z){return Object.prototype.hasOwnProperty.call($,Z)}var AN,Pz=($)=>{return AN.test($)},Q3=($)=>(Q3=Array.isArray,Q3($)),Y3,Cz=($,Z)=>{if(typeof Z!=="number"||!Number.isInteger(Z))throw new _(`${$} must be an integer`);if(Z<0)throw new _(`${$} must be a positive integer`);return Z},s2=($)=>{try{return JSON.parse($)}catch(Z){return}};var P$=S(()=>{N0();AN=/^[a-z][a-z0-9+.-]*:/i,Y3=Q3});var Ez=($)=>new Promise((Z)=>setTimeout(Z,$));var U$="0.91.1";function RN(){if(typeof Deno<"u"&&Deno.build!=null)return"deno";if(typeof EdgeRuntime<"u")return"edge";if(Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]")return"node";return"unknown"}function wN(){if(typeof navigator>"u"||!navigator)return null;let $=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:Z,pattern:z}of $){let X=z.exec(navigator.userAgent);if(X){let J=X[1]||0,Q=X[2]||0,Y=X[3]||0;return{browser:Z,version:`${J}.${Q}.${Y}`}}}return null}var xz=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},FN=()=>{let $=RN();if($==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U$,"X-Stainless-OS":Sz(Deno.build.os),"X-Stainless-Arch":jz(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if($==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U$,"X-Stainless-OS":Sz(globalThis.process.platform??"unknown"),"X-Stainless-Arch":jz(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let Z=wN();if(Z)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${Z.browser}`,"X-Stainless-Runtime-Version":Z.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},jz=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},Sz=($)=>{if($=$.toLowerCase(),$.includes("ios"))return"iOS";if($==="android")return"Android";if($==="darwin")return"MacOS";if($==="win32")return"Windows";if($==="freebsd")return"FreeBSD";if($==="openbsd")return"OpenBSD";if($==="linux")return"Linux";if($)return`Other:${$}`;return"Unknown"},bz,kz=()=>{return bz??(bz=FN())};var G3=()=>{};function yz(){if(typeof fetch<"u")return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function W3(...$){let Z=globalThis.ReadableStream;if(typeof Z>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new Z(...$)}function r2($){let Z=Symbol.asyncIterator in $?$[Symbol.asyncIterator]():$[Symbol.iterator]();return W3({start(){},async pull(z){let{done:X,value:J}=await Z.next();if(X)z.close();else z.enqueue(J)},async cancel(){await Z.return?.()}})}function z4($){if($[Symbol.asyncIterator])return $;let Z=$.getReader();return{async next(){try{let z=await Z.read();if(z?.done)Z.releaseLock();return z}catch(z){throw Z.releaseLock(),z}},async return(){let z=Z.cancel();return Z.releaseLock(),await z,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function fz($){if($===null||typeof $!=="object")return;if($[Symbol.asyncIterator]){await $[Symbol.asyncIterator]().return?.();return}let Z=$.getReader(),z=Z.cancel();Z.releaseLock(),await z}var gz=({headers:$,body:Z})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(Z)}};function hz($){return Object.entries($).filter(([Z,z])=>typeof z<"u").map(([Z,z])=>{if(typeof z==="string"||typeof z==="number"||typeof z==="boolean")return`${encodeURIComponent(Z)}=${encodeURIComponent(z)}`;if(z===null)return`${encodeURIComponent(Z)}=`;throw new _(`Cannot stringify type ${typeof z}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}var vz=S(()=>{N0()});function cz($){let Z=0;for(let J of $)Z+=J.length;let z=new Uint8Array(Z),X=0;for(let J of $)z.set(J,X),X+=J.length;return z}function X4($){let Z;return(uz??(Z=new globalThis.TextEncoder,uz=Z.encode.bind(Z)))($)}function q3($){let Z;return(mz??(Z=new globalThis.TextDecoder,mz=Z.decode.bind(Z)))($)}var uz,mz;class G${constructor(){O0.set(this,void 0),D0.set(this,void 0),R(this,O0,new Uint8Array,"f"),R(this,D0,null,"f")}decode($){if($==null)return[];let Z=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?X4($):$;R(this,O0,cz([H(this,O0,"f"),Z]),"f");let z=[],X;while((X=CN(H(this,O0,"f"),H(this,D0,"f")))!=null){if(X.carriage&&H(this,D0,"f")==null){R(this,D0,X.index,"f");continue}if(H(this,D0,"f")!=null&&(X.index!==H(this,D0,"f")+1||X.carriage)){z.push(q3(H(this,O0,"f").subarray(0,H(this,D0,"f")-1))),R(this,O0,H(this,O0,"f").subarray(H(this,D0,"f")),"f"),R(this,D0,null,"f");continue}let J=H(this,D0,"f")!==null?X.preceding-1:X.preceding,Q=q3(H(this,O0,"f").subarray(0,J));z.push(Q),R(this,O0,H(this,O0,"f").subarray(X.index),"f"),R(this,D0,null,"f")}return z}flush(){if(!H(this,O0,"f").length)return[];return this.decode(`
166
- `)}}function CN($,Z){for(let J=Z??0;J<$.length;J++){if($[J]===10)return{preceding:J,index:J+1,carriage:!1};if($[J]===13)return{preceding:J,index:J+1,carriage:!0}}return null}function dz($){for(let X=0;X<$.length-1;X++){if($[X]===10&&$[X+1]===10)return X+2;if($[X]===13&&$[X+1]===13)return X+2;if($[X]===13&&$[X+1]===10&&X+3<$.length&&$[X+2]===13&&$[X+3]===10)return X+4}return-1}var O0,D0;var V3=S(()=>{d0();O0=new WeakMap,D0=new WeakMap;G$.NEWLINE_CHARS=new Set([`
167
- `,"\r"]);G$.NEWLINE_REGEXP=/\r\n|[\n\r]/g});function J4(){}function a2($,Z,z){if(!Z||o2[$]>o2[z])return J4;else return Z[$].bind(Z)}function G0($){let Z=$.logger,z=$.logLevel??"off";if(!Z)return EN;let X=pz.get(Z);if(X&&X[0]===z)return X[1];let J={error:a2("error",Z,z),warn:a2("warn",Z,z),info:a2("info",Z,z),debug:a2("debug",Z,z)};return pz.set(Z,[z,J]),J}var o2,K3=($,Z,z)=>{if(!$)return;if(_z(o2,$))return $;G0(z).warn(`${Z} was set to ${JSON.stringify($)}, expected one of ${JSON.stringify(Object.keys(o2))}`);return},EN,pz,l0=($)=>{if($.options)$.options={...$.options},delete $.options.headers;if($.headers)$.headers=Object.fromEntries(($.headers instanceof Headers?[...$.headers]:Object.entries($.headers)).map(([Z,z])=>[Z,Z.toLowerCase()==="x-api-key"||Z.toLowerCase()==="authorization"||Z.toLowerCase()==="cookie"||Z.toLowerCase()==="set-cookie"?"***":z]));if("retryOfRequestLogID"in $){if($.retryOfRequestLogID)$.retryOf=$.retryOfRequestLogID;delete $.retryOfRequestLogID}return $};var t2=S(()=>{P$();o2={off:0,error:200,warn:300,info:400,debug:500};EN={error:J4,warn:J4,info:J4,debug:J4},pz=new WeakMap});async function*jN($,Z){if(!$.body){if(Z.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative")throw new _("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new _("Attempted to iterate over a response with no body")}let z=new lz,X=new G$,J=z4($.body);for await(let Q of SN(J))for(let Y of X.decode(Q)){let U=z.decode(Y);if(U)yield U}for(let Q of X.flush()){let Y=z.decode(Q);if(Y)yield Y}}async function*SN($){let Z=new Uint8Array;for await(let z of $){if(z==null)continue;let X=z instanceof ArrayBuffer?new Uint8Array(z):typeof z==="string"?X4(z):z,J=new Uint8Array(Z.length+X.length);J.set(Z),J.set(X,Z.length),Z=J;let Q;while((Q=dz(Z))!==-1)yield Z.slice(0,Q),Z=Z.slice(Q)}if(Z.length>0)yield Z}class lz{constructor(){this.event=null,this.data=[],this.chunks=[]}decode($){if($.endsWith("\r"))$=$.substring(0,$.length-1);if(!$){if(!this.event&&!this.data.length)return null;let J={event:this.event,data:this.data.join(`
168
- `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],J}if(this.chunks.push($),$.startsWith(":"))return null;let[Z,z,X]=bN($,":");if(X.startsWith(" "))X=X.substring(1);if(Z==="event")this.event=X;else if(Z==="data")this.data.push(X);return null}}function bN($,Z){let z=$.indexOf(Z);if(z!==-1)return[$.substring(0,z),Z,$.substring(z+Z.length)];return[$,"",""]}var Q4,I0;var H3=S(()=>{d0();N0();V3();P$();t2();N0();I0=class I0{constructor($,Z,z){this.iterator=$,Q4.set(this,void 0),this.controller=Z,R(this,Q4,z,"f")}static fromSSEResponse($,Z,z){let X=!1,J=z?G0(z):console;async function*Q(){if(X)throw new _("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let Y=!1;try{for await(let U of jN($,Z)){if(U.event==="completion")try{yield JSON.parse(U.data)}catch(G){throw J.error("Could not parse message into JSON:",U.data),J.error("From chunk:",U.raw),G}if(U.event==="message_start"||U.event==="message_delta"||U.event==="message_stop"||U.event==="content_block_start"||U.event==="content_block_delta"||U.event==="content_block_stop"||U.event==="message"||U.event==="user.message"||U.event==="user.interrupt"||U.event==="user.tool_confirmation"||U.event==="user.custom_tool_result"||U.event==="agent.message"||U.event==="agent.thinking"||U.event==="agent.tool_use"||U.event==="agent.tool_result"||U.event==="agent.mcp_tool_use"||U.event==="agent.mcp_tool_result"||U.event==="agent.custom_tool_use"||U.event==="agent.thread_context_compacted"||U.event==="session.status_running"||U.event==="session.status_idle"||U.event==="session.status_rescheduled"||U.event==="session.status_terminated"||U.event==="session.error"||U.event==="session.deleted"||U.event==="span.model_request_start"||U.event==="span.model_request_end")try{yield JSON.parse(U.data)}catch(G){throw J.error("Could not parse message into JSON:",U.data),J.error("From chunk:",U.raw),G}if(U.event==="ping")continue;if(U.event==="error"){let G=s2(U.data)??U.data,W=G?.error?.type;throw new X0(void 0,G,void 0,$.headers,W)}}Y=!0}catch(U){if(p0(U))return;throw U}finally{if(!Y)Z.abort()}}return new I0(Q,Z,z)}static fromReadableStream($,Z,z){let X=!1;async function*J(){let Y=new G$,U=z4($);for await(let G of U)for(let W of Y.decode(G))yield W;for(let G of Y.flush())yield G}async function*Q(){if(X)throw new _("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let Y=!1;try{for await(let U of J()){if(Y)continue;if(U)yield JSON.parse(U)}Y=!0}catch(U){if(p0(U))return;throw U}finally{if(!Y)Z.abort()}}return new I0(Q,Z,z)}[(Q4=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let $=[],Z=[],z=this.iterator(),X=(J)=>{return{next:()=>{if(J.length===0){let Q=z.next();$.push(Q),Z.push(Q)}return J.shift()}}};return[new I0(()=>X($),this.controller,H(this,Q4,"f")),new I0(()=>X(Z),this.controller,H(this,Q4,"f"))]}toReadableStream(){let $=this,Z;return W3({async start(){Z=$[Symbol.asyncIterator]()},async pull(z){try{let{value:X,done:J}=await Z.next();if(J)return z.close();let Q=X4(JSON.stringify(X)+`
169
- `);z.enqueue(Q)}catch(X){z.error(X)}},async cancel(){await Z.return?.()}})}}});async function e2($,Z){let{response:z,requestLogID:X,retryOfRequestLogID:J,startTime:Q}=Z,Y=await(async()=>{if(Z.options.stream){if(G0($).debug("response",z.status,z.url,z.headers,z.body),Z.options.__streamClass)return Z.options.__streamClass.fromSSEResponse(z,Z.controller);return I0.fromSSEResponse(z,Z.controller)}if(z.status===204)return null;if(Z.options.__binaryResponse)return z;let G=z.headers.get("content-type")?.split(";")[0]?.trim();if(G?.includes("application/json")||G?.endsWith("+json")){if(z.headers.get("content-length")==="0")return;let K=await z.json();return B3(K,z)}return await z.text()})();return G0($).debug(`[${X}] response parsed`,l0({retryOfRequestLogID:J,url:z.url,status:z.status,body:Y,durationMs:Date.now()-Q})),Y}function B3($,Z){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:Z.headers.get("request-id"),enumerable:!1})}var L3=S(()=>{H3();t2()});var Y4,W$;var $6=S(()=>{d0();L3();W$=class W$ extends Promise{constructor($,Z,z=e2){super((X)=>{X(null)});this.responsePromise=Z,this.parseResponse=z,Y4.set(this,void 0),R(this,Y4,$,"f")}_thenUnwrap($){return new W$(H(this,Y4,"f"),this.responsePromise,async(Z,z)=>B3($(await this.parseResponse(Z,z),z),z.response))}asResponse(){return this.responsePromise.then(($)=>$.response)}async withResponse(){let[$,Z]=await Promise.all([this.parse(),this.asResponse()]);return{data:$,response:Z,request_id:Z.headers.get("request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then(($)=>this.parseResponse(H(this,Y4,"f"),$));return this.parsedPromise}then($,Z){return this.parse().then($,Z)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}};Y4=new WeakMap});var Z6,N3,U4,S0,i;var t=S(()=>{d0();N0();L3();$6();P$();N3=class N3{constructor($,Z,z,X){Z6.set(this,void 0),R(this,Z6,$,"f"),this.options=X,this.response=Z,this.body=z}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageRequestOptions()!=null}async getNextPage(){let $=this.nextPageRequestOptions();if(!$)throw new _("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await H(this,Z6,"f").requestAPIList(this.constructor,$)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(Z6=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let Z of $.getPaginatedItems())yield Z}};U4=class U4 extends W${constructor($,Z,z){super($,Z,async(X,J)=>new z(X,J.response,await e2(X,J),J.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let Z of $)yield Z}};S0=class S0 extends N3{constructor($,Z,z,X){super($,Z,z,X);this.data=z.data||[],this.has_more=z.has_more||!1,this.first_id=z.first_id||null,this.last_id=z.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let Z=this.first_id;if(!Z)return null;return{...this.options,query:{...n2(this.options.query),before_id:Z}}}let $=this.last_id;if(!$)return null;return{...this.options,query:{...n2(this.options.query),after_id:$}}}};i=class i extends N3{constructor($,Z,z,X){super($,Z,z,X);this.data=z.data||[],this.next_page=z.next_page||null}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){let $=this.next_page;if(!$)return null;return{...this.options,query:{...n2(this.options.query),page:$}}}}});function _$($,Z,z){return T3(),new File($,Z??"unknown_file",z)}function G4($,Z){let z=typeof $==="object"&&$!==null&&(("name"in $)&&$.name&&String($.name)||("url"in $)&&$.url&&String($.url)||("filename"in $)&&$.filename&&String($.filename)||("path"in $)&&$.path&&String($.path))||"";return Z?z.split(/[\\/]/).pop()||void 0:z}function kN($){let Z=typeof $==="function"?$:$.fetch,z=iz.get(Z);if(z)return z;let X=(async()=>{try{let J="Response"in Z?Z.Response:(await Z("data:,")).constructor,Q=new FormData;if(Q.toString()===await new J(Q).text())return!1;return!0}catch{return!0}})();return iz.set(Z,X),X}var T3=()=>{if(typeof File>"u"){let{process:$}=globalThis,Z=typeof $?.versions?.node==="string"&&parseInt($.versions.node.split("."))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(Z?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}},O3=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",W1=async($,Z,z=!0)=>{return{...$,body:await yN($.body,Z,z)}},iz,yN=async($,Z,z=!0)=>{if(!await kN(Z))throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let X=new FormData;return await Promise.all(Object.entries($||{}).map(([J,Q])=>M3(X,J,Q,z))),X},fN=($)=>$ instanceof Blob&&("name"in $),M3=async($,Z,z,X)=>{if(z===void 0)return;if(z==null)throw TypeError(`Received null for "${Z}"; to pass null in FormData, you must use the string 'null'`);if(typeof z==="string"||typeof z==="number"||typeof z==="boolean")$.append(Z,String(z));else if(z instanceof Response){let J={},Q=z.headers.get("Content-Type");if(Q)J={type:Q};$.append(Z,_$([await z.blob()],G4(z,X),J))}else if(O3(z))$.append(Z,_$([await new Response(r2(z)).blob()],G4(z,X)));else if(fN(z))$.append(Z,_$([z],G4(z,X),{type:z.type}));else if(Array.isArray(z))await Promise.all(z.map((J)=>M3($,Z+"[]",J,X)));else if(typeof z==="object")await Promise.all(Object.entries(z).map(([J,Q])=>M3($,`${Z}[${J}]`,Q,X)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${z} instead`)};var q1=S(()=>{iz=new WeakMap});async function W4($,Z,z){if(T3(),$=await $,Z||(Z=G4($,!0)),gN($)){if($ instanceof File&&Z==null&&z==null)return $;return _$([await $.arrayBuffer()],Z??$.name,{type:$.type,lastModified:$.lastModified,...z})}if(hN($)){let J=await $.blob();return Z||(Z=new URL($.url).pathname.split(/[\\/]/).pop()),_$(await D3(J),Z,z)}let X=await D3($);if(!z?.type){let J=X.find((Q)=>typeof Q==="object"&&("type"in Q)&&Q.type);if(typeof J==="string")z={...z,type:J}}return _$(X,Z,z)}async function D3($){let Z=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)Z.push($);else if(nz($))Z.push($ instanceof Blob?$:await $.arrayBuffer());else if(O3($))for await(let z of $)Z.push(...await D3(z));else{let z=$?.constructor?.name;throw Error(`Unexpected data type: ${typeof $}${z?`; constructor: ${z}`:""}${vN($)}`)}return Z}function vN($){if(typeof $!=="object"||$===null)return"";return`; props: [${Object.getOwnPropertyNames($).map((z)=>`"${z}"`).join(", ")}]`}var nz=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function",gN=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&nz($),hN=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function";var sz=S(()=>{q1();q1()});var I3=S(()=>{sz()});var rz=()=>{};class f{constructor($){this._client=$}}function*mN($){if(!$)return;if(az in $){let{values:X,nulls:J}=$;yield*X.entries();for(let Q of J)yield[Q,null];return}let Z=!1,z;if($ instanceof Headers)z=$.entries();else if(Y3($))z=$;else Z=!0,z=Object.entries($??{});for(let X of z){let J=X[0];if(typeof J!=="string")throw TypeError("expected header name to be a string");let Q=Y3(X[1])?X[1]:[X[1]],Y=!1;for(let U of Q){if(U===void 0)continue;if(Z&&!Y)Y=!0,yield[J,null];yield[J,U]}}}var az,T=($)=>{let Z=new Headers,z=new Set;for(let X of $){let J=new Set;for(let[Q,Y]of mN(X)){let U=Q.toLowerCase();if(!J.has(U))Z.delete(Q),J.add(U);if(Y===null)Z.delete(Q),z.add(U);else Z.append(Q,Y),z.delete(U)}}return{[az]:!0,values:Z,nulls:z}};var s=S(()=>{P$();az=Symbol.for("brand.privateNullableHeaders")});function tz($){return $.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var oz,cN=($=tz)=>function(z,...X){if(z.length===1)return z[0];let J=!1,Q=[],Y=z.reduce((q,V,K)=>{if(/[?#]/.test(V))J=!0;let B=X[K],O=(J?encodeURIComponent:$)(""+B);if(K!==X.length&&(B==null||typeof B==="object"&&B.toString===Object.getPrototypeOf(Object.getPrototypeOf(B.hasOwnProperty??oz)??oz)?.toString))O=B+"",Q.push({start:q.length+V.length,length:O.length,error:`Value of type ${Object.prototype.toString.call(B).slice(8,-1)} is not a valid path parameter`});return q+V+(K===X.length?"":O)},""),U=Y.split(/[?#]/,1)[0],G=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,W;while((W=G.exec(U))!==null)Q.push({start:W.index,length:W[0].length,error:`Value "${W[0]}" can't be safely passed as a path parameter`});if(Q.sort((q,V)=>q.start-V.start),Q.length>0){let q=0,V=Q.reduce((K,B)=>{let O=" ".repeat(B.start-q),L="^".repeat(B.length);return q=B.start+B.length,K+O+L},"");throw new _(`Path parameters result in path with invalid segments:
165
+ `,Z)+1}return{type:$,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue($){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let Z=b2($),z=p$(Z);return z.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:z,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let Z=b2($),z=p$(Z);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:z,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment($,Z){if(this.type!=="comment")return!1;if(this.indent<=Z)return!1;return $.every((z)=>z.type==="newline"||z.type==="space")}*documentEnd($){if(this.type!=="doc-mode"){if($.end)$.end.push(this.sourceToken);else $.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}*lineEnd($){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:if($.end)$.end.push(this.sourceToken);else $.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}vK.Parser=l9});var a9=A((sK)=>{var i9=E8(),mK=c1(),s1=d1(),cK=v6(),dK=c(),pK=v8(),n9=u8();function s9($){let Z=$.prettyErrors!==!1;return{lineCounter:$.lineCounter||Z&&new pK.LineCounter||null,prettyErrors:Z}}function lK($,Z={}){let{lineCounter:z,prettyErrors:X}=s9(Z),J=new n9.Parser(z?.addNewLine),Q=new i9.Composer(Z),Y=Array.from(Q.compose(J.parse($)));if(X&&z)for(let U of Y)U.errors.forEach(s1.prettifyError($,z)),U.warnings.forEach(s1.prettifyError($,z));if(Y.length>0)return Y;return Object.assign([],{empty:!0},Q.streamInfo())}function r9($,Z={}){let{lineCounter:z,prettyErrors:X}=s9(Z),J=new n9.Parser(z?.addNewLine),Q=new i9.Composer(Z),Y=null;for(let U of Q.compose(J.parse($),!0,$.length))if(!Y)Y=U;else if(Y.options.logLevel!=="silent"){Y.errors.push(new s1.YAMLParseError(U.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(X&&z)Y.errors.forEach(s1.prettifyError($,z)),Y.warnings.forEach(s1.prettifyError($,z));return Y}function iK($,Z,z){let X=void 0;if(typeof Z==="function")X=Z;else if(z===void 0&&Z&&typeof Z==="object")z=Z;let J=r9($,z);if(!J)return null;if(J.warnings.forEach((Q)=>cK.warn(J.options.logLevel,Q)),J.errors.length>0)if(J.options.logLevel!=="silent")throw J.errors[0];else J.errors=[];return J.toJS(Object.assign({reviver:X},z))}function nK($,Z,z){let X=null;if(typeof Z==="function"||Array.isArray(Z))X=Z;else if(z===void 0&&Z)z=Z;if(typeof z==="string")z=z.length;if(typeof z==="number"){let J=Math.round(z);z=J<1?void 0:J>8?{indent:8}:{indent:J}}if($===void 0){let{keepUndefined:J}=z??Z??{};if(!J)return}if(dK.isDocument($)&&!X)return $.toString(z);return new mK.Document($,X,z).toString(z)}sK.parse=iK;sK.parseAllDocuments=lK;sK.parseDocument=r9;sK.stringify=nK});var Z7={};wZ(Z7,{orange:()=>V0,italic:()=>hH,fafCyanDeep:()=>k2,fafCyan:()=>D,dim:()=>N,bold:()=>w,FAF_HEX:()=>r1});var d8=($)=>(Z)=>`\x1B[${$}m${Z}\x1B[0m`,w,N,hH,r1,D=($)=>`\x1B[38;2;0;212;212m${$}\x1B[0m`,k2=($)=>`\x1B[38;2;14;140;140m${$}\x1B[0m`,V0=($)=>`\x1B[38;5;208m${$}\x1B[0m`;var d=S(()=>{w=d8("1"),N=d8("2"),hH=d8("3"),r1={cyan:"#00D4D4",cyanDeep:"#0E8C8C",orange:"#FF6B35"}});var Z3=A(($R,nL)=>{nL.exports={name:"faf-cli",version:"6.12.0",description:"Persistent AI Context Standard — project DNA for AI. IANA-registered. Anthropic-merged.",type:"module",icon:"https://faf.one/orange-smiley.svg",logo:"https://faf.one/orange-smiley.svg",main:"dist/index.js",types:"./dist/index.d.ts",bin:{faf:"dist/cli.js","faf-cli":"dist/cli.js"},exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"}},files:["dist/**/*","README.md","LICENSE","project.faf"],scripts:{dev:"bun src/cli.ts",clean:"rm -rf dist",build:"bun run clean && bun build src/cli.ts --outdir dist --target=node --minify --sourcemap=linked --external faf-scoring-kernel --external open && bun build src/index.ts --outdir dist --target=node --minify --sourcemap=linked --external faf-scoring-kernel --external open && tsc -p tsconfig.build.json",compile:"bun build src/cli.ts --compile --bytecode --minify --outfile faf","compile:all":"bun build src/cli.ts --compile --bytecode --minify --target=bun-darwin-arm64 --outfile faf-darwin-arm64 && bun build src/cli.ts --compile --bytecode --minify --target=bun-darwin-x64 --outfile faf-darwin-x64 && bun build src/cli.ts --compile --bytecode --minify --target=bun-linux-x64 --outfile faf-linux-x64 && bun build src/cli.ts --compile --bytecode --minify --target=bun-windows-x64 --outfile faf-windows-x64.exe",test:"bun test --timeout=120000","test:watch":"bun test --watch --timeout=120000",lint:"eslint src/**/*.ts",format:"prettier --write 'src/**/*.ts'","check:no-hardcode":"! grep -rEln '/(Users|home/runner|private/var)/' dist/ || (echo '❌ Hardcoded build-machine path leaked into dist — see grep output above. Externalize the offending dep in the build script.'; exit 1)",prepublishOnly:"bun run build && bun run check:no-hardcode"},keywords:["faf","ai-context","project-dna","bi-sync","cli","claude","gemini","cursor","mcp","model-context-protocol","persistent-context","ai-readiness","foundational"],author:"wolfejam <wolfejam@faf.one>",license:"MIT",repository:{type:"git",url:"https://github.com/Wolfe-Jam/faf-cli.git"},homepage:"https://faf.one",bugs:{url:"https://github.com/Wolfe-Jam/faf-cli/issues"},dependencies:{commander:"^14.0.1","faf-scoring-kernel":"^2.0.3",open:"^11.0.0",yaml:"^2.4.1"},optionalDependencies:{"@anthropic-ai/sdk":"^0.91.1"},devDependencies:{"@faf/specification":"github:Wolfe-Jam/faf",ajv:"^8.17.1","@types/node":"^22.15.0","@typescript-eslint/eslint-plugin":"^8.41.0","@typescript-eslint/parser":"^8.41.0",eslint:"^9.39.2",prettier:"^3.2.5",typescript:"^5.3.3","typescript-eslint":"^8.59.1"},engines:{node:">=18.0.0"},publishConfig:{access:"public"}}});function R($,Z,z,X,J){if(X==="m")throw TypeError("Private method is not writable");if(X==="a"&&!J)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!J:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return X==="a"?J.call($,z):J?J.value=z:Z.set($,z),z}function H($,Z,z,X){if(z==="a"&&!X)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!X:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return z==="m"?X:z==="a"?X.call($):X?X.value:Z.get($)}var d0=()=>{};var J3=function(){let{crypto:$}=globalThis;if($?.randomUUID)return J3=$.randomUUID.bind($),$.randomUUID();let Z=new Uint8Array(1),z=$?()=>$.getRandomValues(Z)[0]:()=>Math.random()*255&255;return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(X)=>(+X^z()&15>>+X/4).toString(16))};function p0($){return typeof $==="object"&&$!==null&&(("name"in $)&&$.name==="AbortError"||("message"in $)&&String($.message).includes("FetchRequestCanceledException"))}var Z4=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null){try{if(Object.prototype.toString.call($)==="[object Error]"){let Z=Error($.message,$.cause?{cause:$.cause}:{});if($.stack)Z.stack=$.stack;if($.cause&&!Z.cause)Z.cause=$.cause;if($.name)Z.name=$.name;return Z}}catch{}try{return Error(JSON.stringify($))}catch{}}return Error($)};var _,X0,q0,Y$,$1,Z1,z1,X1,J1,Q1,Y1,U1,G1;var N0=S(()=>{_=class _ extends Error{};X0=class X0 extends _{constructor($,Z,z,X,J){super(`${X0.makeMessage($,Z,z)}`);this.status=$,this.headers=X,this.requestID=X?.get("request-id"),this.error=Z,this.type=J??null}static makeMessage($,Z,z){let X=Z?.message?typeof Z.message==="string"?Z.message:JSON.stringify(Z.message):Z?JSON.stringify(Z):z;if($&&X)return`${$} ${X}`;if($)return`${$} status code (no body)`;if(X)return X;return"(no status code or body)"}static generate($,Z,z,X){if(!$||!X)return new Y$({message:z,cause:Z4(Z)});let J=Z,Q=J?.error?.type;if($===400)return new Z1($,J,z,X,Q);if($===401)return new z1($,J,z,X,Q);if($===403)return new X1($,J,z,X,Q);if($===404)return new J1($,J,z,X,Q);if($===409)return new Q1($,J,z,X,Q);if($===422)return new Y1($,J,z,X,Q);if($===429)return new U1($,J,z,X,Q);if($>=500)return new G1($,J,z,X,Q);return new X0($,J,z,X,Q)}};q0=class q0 extends X0{constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}};Y$=class Y$ extends X0{constructor({message:$,cause:Z}){super(void 0,void 0,$||"Connection error.",void 0);if(Z)this.cause=Z}};$1=class $1 extends Y${constructor({message:$}={}){super({message:$??"Request timed out."})}};Z1=class Z1 extends X0{};z1=class z1 extends X0{};X1=class X1 extends X0{};J1=class J1 extends X0{};Q1=class Q1 extends X0{};Y1=class Y1 extends X0{};U1=class U1 extends X0{};G1=class G1 extends X0{}});function n2($){if(typeof $!=="object")return{};return $??{}}function U3($){if(!$)return!0;for(let Z in $)return!1;return!0}function _z($,Z){return Object.prototype.hasOwnProperty.call($,Z)}var RN,Pz=($)=>{return RN.test($)},Q3=($)=>(Q3=Array.isArray,Q3($)),Y3,Cz=($,Z)=>{if(typeof Z!=="number"||!Number.isInteger(Z))throw new _(`${$} must be an integer`);if(Z<0)throw new _(`${$} must be a positive integer`);return Z},s2=($)=>{try{return JSON.parse($)}catch(Z){return}};var P$=S(()=>{N0();RN=/^[a-z][a-z0-9+.-]*:/i,Y3=Q3});var Ez=($)=>new Promise((Z)=>setTimeout(Z,$));var U$="0.91.1";function FN(){if(typeof Deno<"u"&&Deno.build!=null)return"deno";if(typeof EdgeRuntime<"u")return"edge";if(Object.prototype.toString.call(typeof globalThis.process<"u"?globalThis.process:0)==="[object process]")return"node";return"unknown"}function PN(){if(typeof navigator>"u"||!navigator)return null;let $=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(let{key:Z,pattern:z}of $){let X=z.exec(navigator.userAgent);if(X){let J=X[1]||0,Q=X[2]||0,Y=X[3]||0;return{browser:Z,version:`${J}.${Q}.${Y}`}}}return null}var xz=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},wN=()=>{let $=FN();if($==="deno")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U$,"X-Stainless-OS":Sz(Deno.build.os),"X-Stainless-Arch":jz(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":typeof Deno.version==="string"?Deno.version:Deno.version?.deno??"unknown"};if(typeof EdgeRuntime<"u")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":globalThis.process.version};if($==="node")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U$,"X-Stainless-OS":Sz(globalThis.process.platform??"unknown"),"X-Stainless-Arch":jz(globalThis.process.arch??"unknown"),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":globalThis.process.version??"unknown"};let Z=PN();if(Z)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${Z.browser}`,"X-Stainless-Runtime-Version":Z.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":U$,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}},jz=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},Sz=($)=>{if($=$.toLowerCase(),$.includes("ios"))return"iOS";if($==="android")return"Android";if($==="darwin")return"MacOS";if($==="win32")return"Windows";if($==="freebsd")return"FreeBSD";if($==="openbsd")return"OpenBSD";if($==="linux")return"Linux";if($)return`Other:${$}`;return"Unknown"},bz,kz=()=>{return bz??(bz=wN())};var G3=()=>{};function yz(){if(typeof fetch<"u")return fetch;throw Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new Anthropic({ fetch })` or polyfill the global, `globalThis.fetch = fetch`")}function W3(...$){let Z=globalThis.ReadableStream;if(typeof Z>"u")throw Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");return new Z(...$)}function r2($){let Z=Symbol.asyncIterator in $?$[Symbol.asyncIterator]():$[Symbol.iterator]();return W3({start(){},async pull(z){let{done:X,value:J}=await Z.next();if(X)z.close();else z.enqueue(J)},async cancel(){await Z.return?.()}})}function z4($){if($[Symbol.asyncIterator])return $;let Z=$.getReader();return{async next(){try{let z=await Z.read();if(z?.done)Z.releaseLock();return z}catch(z){throw Z.releaseLock(),z}},async return(){let z=Z.cancel();return Z.releaseLock(),await z,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}async function fz($){if($===null||typeof $!=="object")return;if($[Symbol.asyncIterator]){await $[Symbol.asyncIterator]().return?.();return}let Z=$.getReader(),z=Z.cancel();Z.releaseLock(),await z}var gz=({headers:$,body:Z})=>{return{bodyHeaders:{"content-type":"application/json"},body:JSON.stringify(Z)}};function hz($){return Object.entries($).filter(([Z,z])=>typeof z<"u").map(([Z,z])=>{if(typeof z==="string"||typeof z==="number"||typeof z==="boolean")return`${encodeURIComponent(Z)}=${encodeURIComponent(z)}`;if(z===null)return`${encodeURIComponent(Z)}=`;throw new _(`Cannot stringify type ${typeof z}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)}).join("&")}var vz=S(()=>{N0()});function cz($){let Z=0;for(let J of $)Z+=J.length;let z=new Uint8Array(Z),X=0;for(let J of $)z.set(J,X),X+=J.length;return z}function X4($){let Z;return(uz??(Z=new globalThis.TextEncoder,uz=Z.encode.bind(Z)))($)}function q3($){let Z;return(mz??(Z=new globalThis.TextDecoder,mz=Z.decode.bind(Z)))($)}var uz,mz;class G${constructor(){O0.set(this,void 0),D0.set(this,void 0),R(this,O0,new Uint8Array,"f"),R(this,D0,null,"f")}decode($){if($==null)return[];let Z=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?X4($):$;R(this,O0,cz([H(this,O0,"f"),Z]),"f");let z=[],X;while((X=EN(H(this,O0,"f"),H(this,D0,"f")))!=null){if(X.carriage&&H(this,D0,"f")==null){R(this,D0,X.index,"f");continue}if(H(this,D0,"f")!=null&&(X.index!==H(this,D0,"f")+1||X.carriage)){z.push(q3(H(this,O0,"f").subarray(0,H(this,D0,"f")-1))),R(this,O0,H(this,O0,"f").subarray(H(this,D0,"f")),"f"),R(this,D0,null,"f");continue}let J=H(this,D0,"f")!==null?X.preceding-1:X.preceding,Q=q3(H(this,O0,"f").subarray(0,J));z.push(Q),R(this,O0,H(this,O0,"f").subarray(X.index),"f"),R(this,D0,null,"f")}return z}flush(){if(!H(this,O0,"f").length)return[];return this.decode(`
166
+ `)}}function EN($,Z){for(let J=Z??0;J<$.length;J++){if($[J]===10)return{preceding:J,index:J+1,carriage:!1};if($[J]===13)return{preceding:J,index:J+1,carriage:!0}}return null}function dz($){for(let X=0;X<$.length-1;X++){if($[X]===10&&$[X+1]===10)return X+2;if($[X]===13&&$[X+1]===13)return X+2;if($[X]===13&&$[X+1]===10&&X+3<$.length&&$[X+2]===13&&$[X+3]===10)return X+4}return-1}var O0,D0;var V3=S(()=>{d0();O0=new WeakMap,D0=new WeakMap;G$.NEWLINE_CHARS=new Set([`
167
+ `,"\r"]);G$.NEWLINE_REGEXP=/\r\n|[\n\r]/g});function J4(){}function a2($,Z,z){if(!Z||o2[$]>o2[z])return J4;else return Z[$].bind(Z)}function G0($){let Z=$.logger,z=$.logLevel??"off";if(!Z)return jN;let X=pz.get(Z);if(X&&X[0]===z)return X[1];let J={error:a2("error",Z,z),warn:a2("warn",Z,z),info:a2("info",Z,z),debug:a2("debug",Z,z)};return pz.set(Z,[z,J]),J}var o2,K3=($,Z,z)=>{if(!$)return;if(_z(o2,$))return $;G0(z).warn(`${Z} was set to ${JSON.stringify($)}, expected one of ${JSON.stringify(Object.keys(o2))}`);return},jN,pz,l0=($)=>{if($.options)$.options={...$.options},delete $.options.headers;if($.headers)$.headers=Object.fromEntries(($.headers instanceof Headers?[...$.headers]:Object.entries($.headers)).map(([Z,z])=>[Z,Z.toLowerCase()==="x-api-key"||Z.toLowerCase()==="authorization"||Z.toLowerCase()==="cookie"||Z.toLowerCase()==="set-cookie"?"***":z]));if("retryOfRequestLogID"in $){if($.retryOfRequestLogID)$.retryOf=$.retryOfRequestLogID;delete $.retryOfRequestLogID}return $};var t2=S(()=>{P$();o2={off:0,error:200,warn:300,info:400,debug:500};jN={error:J4,warn:J4,info:J4,debug:J4},pz=new WeakMap});async function*SN($,Z){if(!$.body){if(Z.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative")throw new _("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new _("Attempted to iterate over a response with no body")}let z=new lz,X=new G$,J=z4($.body);for await(let Q of bN(J))for(let Y of X.decode(Q)){let U=z.decode(Y);if(U)yield U}for(let Q of X.flush()){let Y=z.decode(Q);if(Y)yield Y}}async function*bN($){let Z=new Uint8Array;for await(let z of $){if(z==null)continue;let X=z instanceof ArrayBuffer?new Uint8Array(z):typeof z==="string"?X4(z):z,J=new Uint8Array(Z.length+X.length);J.set(Z),J.set(X,Z.length),Z=J;let Q;while((Q=dz(Z))!==-1)yield Z.slice(0,Q),Z=Z.slice(Q)}if(Z.length>0)yield Z}class lz{constructor(){this.event=null,this.data=[],this.chunks=[]}decode($){if($.endsWith("\r"))$=$.substring(0,$.length-1);if(!$){if(!this.event&&!this.data.length)return null;let J={event:this.event,data:this.data.join(`
168
+ `),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],J}if(this.chunks.push($),$.startsWith(":"))return null;let[Z,z,X]=xN($,":");if(X.startsWith(" "))X=X.substring(1);if(Z==="event")this.event=X;else if(Z==="data")this.data.push(X);return null}}function xN($,Z){let z=$.indexOf(Z);if(z!==-1)return[$.substring(0,z),Z,$.substring(z+Z.length)];return[$,"",""]}var Q4,I0;var H3=S(()=>{d0();N0();V3();P$();t2();N0();I0=class I0{constructor($,Z,z){this.iterator=$,Q4.set(this,void 0),this.controller=Z,R(this,Q4,z,"f")}static fromSSEResponse($,Z,z){let X=!1,J=z?G0(z):console;async function*Q(){if(X)throw new _("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let Y=!1;try{for await(let U of SN($,Z)){if(U.event==="completion")try{yield JSON.parse(U.data)}catch(G){throw J.error("Could not parse message into JSON:",U.data),J.error("From chunk:",U.raw),G}if(U.event==="message_start"||U.event==="message_delta"||U.event==="message_stop"||U.event==="content_block_start"||U.event==="content_block_delta"||U.event==="content_block_stop"||U.event==="message"||U.event==="user.message"||U.event==="user.interrupt"||U.event==="user.tool_confirmation"||U.event==="user.custom_tool_result"||U.event==="agent.message"||U.event==="agent.thinking"||U.event==="agent.tool_use"||U.event==="agent.tool_result"||U.event==="agent.mcp_tool_use"||U.event==="agent.mcp_tool_result"||U.event==="agent.custom_tool_use"||U.event==="agent.thread_context_compacted"||U.event==="session.status_running"||U.event==="session.status_idle"||U.event==="session.status_rescheduled"||U.event==="session.status_terminated"||U.event==="session.error"||U.event==="session.deleted"||U.event==="span.model_request_start"||U.event==="span.model_request_end")try{yield JSON.parse(U.data)}catch(G){throw J.error("Could not parse message into JSON:",U.data),J.error("From chunk:",U.raw),G}if(U.event==="ping")continue;if(U.event==="error"){let G=s2(U.data)??U.data,W=G?.error?.type;throw new X0(void 0,G,void 0,$.headers,W)}}Y=!0}catch(U){if(p0(U))return;throw U}finally{if(!Y)Z.abort()}}return new I0(Q,Z,z)}static fromReadableStream($,Z,z){let X=!1;async function*J(){let Y=new G$,U=z4($);for await(let G of U)for(let W of Y.decode(G))yield W;for(let G of Y.flush())yield G}async function*Q(){if(X)throw new _("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let Y=!1;try{for await(let U of J()){if(Y)continue;if(U)yield JSON.parse(U)}Y=!0}catch(U){if(p0(U))return;throw U}finally{if(!Y)Z.abort()}}return new I0(Q,Z,z)}[(Q4=new WeakMap,Symbol.asyncIterator)](){return this.iterator()}tee(){let $=[],Z=[],z=this.iterator(),X=(J)=>{return{next:()=>{if(J.length===0){let Q=z.next();$.push(Q),Z.push(Q)}return J.shift()}}};return[new I0(()=>X($),this.controller,H(this,Q4,"f")),new I0(()=>X(Z),this.controller,H(this,Q4,"f"))]}toReadableStream(){let $=this,Z;return W3({async start(){Z=$[Symbol.asyncIterator]()},async pull(z){try{let{value:X,done:J}=await Z.next();if(J)return z.close();let Q=X4(JSON.stringify(X)+`
169
+ `);z.enqueue(Q)}catch(X){z.error(X)}},async cancel(){await Z.return?.()}})}}});async function e2($,Z){let{response:z,requestLogID:X,retryOfRequestLogID:J,startTime:Q}=Z,Y=await(async()=>{if(Z.options.stream){if(G0($).debug("response",z.status,z.url,z.headers,z.body),Z.options.__streamClass)return Z.options.__streamClass.fromSSEResponse(z,Z.controller);return I0.fromSSEResponse(z,Z.controller)}if(z.status===204)return null;if(Z.options.__binaryResponse)return z;let G=z.headers.get("content-type")?.split(";")[0]?.trim();if(G?.includes("application/json")||G?.endsWith("+json")){if(z.headers.get("content-length")==="0")return;let K=await z.json();return B3(K,z)}return await z.text()})();return G0($).debug(`[${X}] response parsed`,l0({retryOfRequestLogID:J,url:z.url,status:z.status,body:Y,durationMs:Date.now()-Q})),Y}function B3($,Z){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:Z.headers.get("request-id"),enumerable:!1})}var L3=S(()=>{H3();t2()});var Y4,W$;var $6=S(()=>{d0();L3();W$=class W$ extends Promise{constructor($,Z,z=e2){super((X)=>{X(null)});this.responsePromise=Z,this.parseResponse=z,Y4.set(this,void 0),R(this,Y4,$,"f")}_thenUnwrap($){return new W$(H(this,Y4,"f"),this.responsePromise,async(Z,z)=>B3($(await this.parseResponse(Z,z),z),z.response))}asResponse(){return this.responsePromise.then(($)=>$.response)}async withResponse(){let[$,Z]=await Promise.all([this.parse(),this.asResponse()]);return{data:$,response:Z,request_id:Z.headers.get("request-id")}}parse(){if(!this.parsedPromise)this.parsedPromise=this.responsePromise.then(($)=>this.parseResponse(H(this,Y4,"f"),$));return this.parsedPromise}then($,Z){return this.parse().then($,Z)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}};Y4=new WeakMap});var Z6,N3,U4,S0,i;var t=S(()=>{d0();N0();L3();$6();P$();N3=class N3{constructor($,Z,z,X){Z6.set(this,void 0),R(this,Z6,$,"f"),this.options=X,this.response=Z,this.body=z}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageRequestOptions()!=null}async getNextPage(){let $=this.nextPageRequestOptions();if(!$)throw new _("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");return await H(this,Z6,"f").requestAPIList(this.constructor,$)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(Z6=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let Z of $.getPaginatedItems())yield Z}};U4=class U4 extends W${constructor($,Z,z){super($,Z,async(X,J)=>new z(X,J.response,await e2(X,J),J.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let Z of $)yield Z}};S0=class S0 extends N3{constructor($,Z,z,X){super($,Z,z,X);this.data=z.data||[],this.has_more=z.has_more||!1,this.first_id=z.first_id||null,this.last_id=z.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageRequestOptions(){if(this.options.query?.before_id){let Z=this.first_id;if(!Z)return null;return{...this.options,query:{...n2(this.options.query),before_id:Z}}}let $=this.last_id;if(!$)return null;return{...this.options,query:{...n2(this.options.query),after_id:$}}}};i=class i extends N3{constructor($,Z,z,X){super($,Z,z,X);this.data=z.data||[],this.next_page=z.next_page||null}getPaginatedItems(){return this.data??[]}nextPageRequestOptions(){let $=this.next_page;if(!$)return null;return{...this.options,query:{...n2(this.options.query),page:$}}}}});function _$($,Z,z){return T3(),new File($,Z??"unknown_file",z)}function G4($,Z){let z=typeof $==="object"&&$!==null&&(("name"in $)&&$.name&&String($.name)||("url"in $)&&$.url&&String($.url)||("filename"in $)&&$.filename&&String($.filename)||("path"in $)&&$.path&&String($.path))||"";return Z?z.split(/[\\/]/).pop()||void 0:z}function yN($){let Z=typeof $==="function"?$:$.fetch,z=iz.get(Z);if(z)return z;let X=(async()=>{try{let J="Response"in Z?Z.Response:(await Z("data:,")).constructor,Q=new FormData;if(Q.toString()===await new J(Q).text())return!1;return!0}catch{return!0}})();return iz.set(Z,X),X}var T3=()=>{if(typeof File>"u"){let{process:$}=globalThis,Z=typeof $?.versions?.node==="string"&&parseInt($.versions.node.split("."))<20;throw Error("`File` is not defined as a global, which is required for file uploads."+(Z?" Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`.":""))}},O3=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",W1=async($,Z,z=!0)=>{return{...$,body:await fN($.body,Z,z)}},iz,fN=async($,Z,z=!0)=>{if(!await yN(Z))throw TypeError("The provided fetch function does not support file uploads with the current global FormData class.");let X=new FormData;return await Promise.all(Object.entries($||{}).map(([J,Q])=>M3(X,J,Q,z))),X},gN=($)=>$ instanceof Blob&&("name"in $),M3=async($,Z,z,X)=>{if(z===void 0)return;if(z==null)throw TypeError(`Received null for "${Z}"; to pass null in FormData, you must use the string 'null'`);if(typeof z==="string"||typeof z==="number"||typeof z==="boolean")$.append(Z,String(z));else if(z instanceof Response){let J={},Q=z.headers.get("Content-Type");if(Q)J={type:Q};$.append(Z,_$([await z.blob()],G4(z,X),J))}else if(O3(z))$.append(Z,_$([await new Response(r2(z)).blob()],G4(z,X)));else if(gN(z))$.append(Z,_$([z],G4(z,X),{type:z.type}));else if(Array.isArray(z))await Promise.all(z.map((J)=>M3($,Z+"[]",J,X)));else if(typeof z==="object")await Promise.all(Object.entries(z).map(([J,Q])=>M3($,`${Z}[${J}]`,Q,X)));else throw TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${z} instead`)};var q1=S(()=>{iz=new WeakMap});async function W4($,Z,z){if(T3(),$=await $,Z||(Z=G4($,!0)),hN($)){if($ instanceof File&&Z==null&&z==null)return $;return _$([await $.arrayBuffer()],Z??$.name,{type:$.type,lastModified:$.lastModified,...z})}if(vN($)){let J=await $.blob();return Z||(Z=new URL($.url).pathname.split(/[\\/]/).pop()),_$(await D3(J),Z,z)}let X=await D3($);if(!z?.type){let J=X.find((Q)=>typeof Q==="object"&&("type"in Q)&&Q.type);if(typeof J==="string")z={...z,type:J}}return _$(X,Z,z)}async function D3($){let Z=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)Z.push($);else if(nz($))Z.push($ instanceof Blob?$:await $.arrayBuffer());else if(O3($))for await(let z of $)Z.push(...await D3(z));else{let z=$?.constructor?.name;throw Error(`Unexpected data type: ${typeof $}${z?`; constructor: ${z}`:""}${uN($)}`)}return Z}function uN($){if(typeof $!=="object"||$===null)return"";return`; props: [${Object.getOwnPropertyNames($).map((z)=>`"${z}"`).join(", ")}]`}var nz=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function",hN=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&nz($),vN=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function";var sz=S(()=>{q1();q1()});var I3=S(()=>{sz()});var rz=()=>{};class f{constructor($){this._client=$}}function*cN($){if(!$)return;if(az in $){let{values:X,nulls:J}=$;yield*X.entries();for(let Q of J)yield[Q,null];return}let Z=!1,z;if($ instanceof Headers)z=$.entries();else if(Y3($))z=$;else Z=!0,z=Object.entries($??{});for(let X of z){let J=X[0];if(typeof J!=="string")throw TypeError("expected header name to be a string");let Q=Y3(X[1])?X[1]:[X[1]],Y=!1;for(let U of Q){if(U===void 0)continue;if(Z&&!Y)Y=!0,yield[J,null];yield[J,U]}}}var az,T=($)=>{let Z=new Headers,z=new Set;for(let X of $){let J=new Set;for(let[Q,Y]of cN(X)){let U=Q.toLowerCase();if(!J.has(U))Z.delete(Q),J.add(U);if(Y===null)Z.delete(Q),z.add(U);else Z.append(Q,Y),z.delete(U)}}return{[az]:!0,values:Z,nulls:z}};var s=S(()=>{P$();az=Symbol.for("brand.privateNullableHeaders")});function tz($){return $.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g,encodeURIComponent)}var oz,dN=($=tz)=>function(z,...X){if(z.length===1)return z[0];let J=!1,Q=[],Y=z.reduce((q,V,K)=>{if(/[?#]/.test(V))J=!0;let B=X[K],O=(J?encodeURIComponent:$)(""+B);if(K!==X.length&&(B==null||typeof B==="object"&&B.toString===Object.getPrototypeOf(Object.getPrototypeOf(B.hasOwnProperty??oz)??oz)?.toString))O=B+"",Q.push({start:q.length+V.length,length:O.length,error:`Value of type ${Object.prototype.toString.call(B).slice(8,-1)} is not a valid path parameter`});return q+V+(K===X.length?"":O)},""),U=Y.split(/[?#]/,1)[0],G=/(?<=^|\/)(?:\.|%2e){1,2}(?=\/|$)/gi,W;while((W=G.exec(U))!==null)Q.push({start:W.index,length:W[0].length,error:`Value "${W[0]}" can't be safely passed as a path parameter`});if(Q.sort((q,V)=>q.start-V.start),Q.length>0){let q=0,V=Q.reduce((K,B)=>{let O=" ".repeat(B.start-q),L="^".repeat(B.length);return q=B.start+B.length,K+O+L},"");throw new _(`Path parameters result in path with invalid segments:
170
170
  ${Q.map((K)=>K.error).join(`
171
171
  `)}
172
172
  ${Y}
173
- ${V}`)}return Y},I;var J0=S(()=>{N0();oz=Object.freeze(Object.create(null)),I=cN(tz)});var q4;var A3=S(()=>{t();s();J0();q4=class q4 extends f{create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/environments?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/environments/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/environments/${$}?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/environments?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/environments/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}archive($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/environments/${$}/archive?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}}});function z6($){return typeof $==="object"&&$!==null&&V4 in $}function R3($,Z){let z=new Set;if($){for(let X of $)if(z6(X))z.add(X[V4])}if(Z)for(let X of Z){if(z6(X))z.add(X[V4]);if(Array.isArray(X.content)){for(let J of X.content)if(z6(J))z.add(J[V4])}}return Array.from(z)}function X6($,Z){let z=R3($,Z);if(z.length===0)return{};return{"x-stainless-helper":z.join(", ")}}function ez($){if(z6($))return{"x-stainless-helper":$[V4]};return{}}var V4;var K4=S(()=>{V4=Symbol("anthropic.sdk.stainlessHelper")});var H4;var F3=S(()=>{t();s();K4();q1();J0();H4=class H4 extends f{list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/files?beta=true",S0,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"files-api-2025-04-14"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/files/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"files-api-2025-04-14"].toString()},z?.headers])})}download($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/files/${$}/content?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},z?.headers]),__binaryResponse:!0})}retrieveMetadata($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/files/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"files-api-2025-04-14"].toString()},z?.headers])})}upload($,Z){let{betas:z,...X}=$;return this._client.post("/v1/files?beta=true",W1({body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"files-api-2025-04-14"].toString()},ez(X.file),Z?.headers])},this._client))}}});var B4;var w3=S(()=>{t();s();J0();B4=class B4 extends f{retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/models/${$}?beta=true`,{...z,headers:T([{...X?.toString()!=null?{"anthropic-beta":X?.toString()}:void 0},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/models?beta=true",S0,{query:X,...Z,headers:T([{...z?.toString()!=null?{"anthropic-beta":z?.toString()}:void 0},Z?.headers])})}}});var L4;var P3=S(()=>{t();s();J0();L4=class L4 extends f{create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/user_profiles?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"user-profiles-2026-03-24"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/user_profiles/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"user-profiles-2026-03-24"].toString()},z?.headers])})}update($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/user_profiles/${$}?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"user-profiles-2026-03-24"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/user_profiles?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"user-profiles-2026-03-24"].toString()},Z?.headers])})}createEnrollmentURL($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/user_profiles/${$}/enrollment_url?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"user-profiles-2026-03-24"].toString()},z?.headers])})}}});var N4;var _3=S(()=>{t();s();J0();N4=class N4 extends f{list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/agents/${$}/versions?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}}});var V1;var C3=S(()=>{_3();_3();t();s();J0();V1=class V1 extends f{constructor(){super(...arguments);this.versions=new N4(this._client)}create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/agents?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X,...J}=Z??{};return this._client.get(I`/v1/agents/${$}?beta=true`,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/agents/${$}?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/agents?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}archive($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/agents/${$}/archive?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}};V1.Versions=N4});var M4;var E3=S(()=>{t();s();J0();M4=class M4 extends f{create($,Z,z){let{view:X,betas:J,...Q}=Z;return this._client.post(I`/v1/memory_stores/${$}/memories?beta=true`,{query:{view:X},body:Q,...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}retrieve($,Z,z){let{memory_store_id:X,betas:J,...Q}=Z;return this._client.get(I`/v1/memory_stores/${X}/memories/${$}?beta=true`,{query:Q,...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{memory_store_id:X,view:J,betas:Q,...Y}=Z;return this._client.post(I`/v1/memory_stores/${X}/memories/${$}?beta=true`,{query:{view:J},body:Y,...z,headers:T([{"anthropic-beta":[...Q??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/memory_stores/${$}/memories?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}delete($,Z,z){let{memory_store_id:X,expected_content_sha256:J,betas:Q}=Z;return this._client.delete(I`/v1/memory_stores/${X}/memories/${$}?beta=true`,{query:{expected_content_sha256:J},...z,headers:T([{"anthropic-beta":[...Q??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}}});var T4;var j3=S(()=>{t();s();J0();T4=class T4 extends f{retrieve($,Z,z){let{memory_store_id:X,betas:J,...Q}=Z;return this._client.get(I`/v1/memory_stores/${X}/memory_versions/${$}?beta=true`,{query:Q,...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/memory_stores/${$}/memory_versions?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}redact($,Z,z){let{memory_store_id:X,betas:J}=Z;return this._client.post(I`/v1/memory_stores/${X}/memory_versions/${$}/redact?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}}});var C$;var S3=S(()=>{E3();E3();j3();j3();t();s();J0();C$=class C$ extends f{constructor(){super(...arguments);this.memories=new M4(this._client),this.memoryVersions=new T4(this._client)}create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/memory_stores?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/memory_stores/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/memory_stores/${$}?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/memory_stores?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/memory_stores/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}archive($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/memory_stores/${$}/archive?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}};C$.Memories=M4;C$.MemoryVersions=T4});var K1=S(()=>{N0()});var J6;var b3=S(()=>{J6={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192}});function $X($){return $?.output_format??$?.output_config?.format}function x3($,Z,z){let X=$X(Z);if(!Z||!("parse"in(X??{})))return{...$,content:$.content.map((J)=>{if(J.type==="text"){let Q=Object.defineProperty({...J},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(Q,"parsed",{get(){return z.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return J}),parsed_output:null};return k3($,Z,z)}function k3($,Z,z){let X=null,J=$.content.map((Q)=>{if(Q.type==="text"){let Y=tN(Z,Q.text);if(X===null)X=Y;let U=Object.defineProperty({...Q},"parsed_output",{value:Y,enumerable:!1});return Object.defineProperty(U,"parsed",{get(){return z.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),Y},enumerable:!1})}return Q});return{...$,content:J,parsed_output:X}}function tN($,Z){let z=$X($);if(z?.type!=="json_schema")return null;try{if("parse"in z)return z.parse(Z);return JSON.parse(Z)}catch(X){throw new _(`Failed to parse structured output: ${X}`)}}var y3=S(()=>{N0()});var eN=($)=>{let Z=0,z=[];while(Z<$.length){let X=$[Z];if(X==="\\"){Z++;continue}if(X==="{"){z.push({type:"brace",value:"{"}),Z++;continue}if(X==="}"){z.push({type:"brace",value:"}"}),Z++;continue}if(X==="["){z.push({type:"paren",value:"["}),Z++;continue}if(X==="]"){z.push({type:"paren",value:"]"}),Z++;continue}if(X===":"){z.push({type:"separator",value:":"}),Z++;continue}if(X===","){z.push({type:"delimiter",value:","}),Z++;continue}if(X==='"'){let U="",G=!1;X=$[++Z];while(X!=='"'){if(Z===$.length){G=!0;break}if(X==="\\"){if(Z++,Z===$.length){G=!0;break}U+=X+$[Z],X=$[++Z]}else U+=X,X=$[++Z]}if(X=$[++Z],!G)z.push({type:"string",value:U});continue}if(X&&/\s/.test(X)){Z++;continue}let Q=/[0-9]/;if(X&&Q.test(X)||X==="-"||X==="."){let U="";if(X==="-")U+=X,X=$[++Z];while(X&&Q.test(X)||X===".")U+=X,X=$[++Z];z.push({type:"number",value:U});continue}let Y=/[a-z]/i;if(X&&Y.test(X)){let U="";while(X&&Y.test(X)){if(Z===$.length)break;U+=X,X=$[++Z]}if(U=="true"||U=="false"||U==="null")z.push({type:"name",value:U});else{Z++;continue}continue}Z++}return z},H1=($)=>{if($.length===0)return $;let Z=$[$.length-1];switch(Z.type){case"separator":return $=$.slice(0,$.length-1),H1($);break;case"number":let z=Z.value[Z.value.length-1];if(z==="."||z==="-")return $=$.slice(0,$.length-1),H1($);case"string":let X=$[$.length-2];if(X?.type==="delimiter")return $=$.slice(0,$.length-1),H1($);else if(X?.type==="brace"&&X.value==="{")return $=$.slice(0,$.length-1),H1($);break;case"delimiter":return $=$.slice(0,$.length-1),H1($);break}return $},$M=($)=>{let Z=[];if($.map((z)=>{if(z.type==="brace")if(z.value==="{")Z.push("}");else Z.splice(Z.lastIndexOf("}"),1);if(z.type==="paren")if(z.value==="[")Z.push("]");else Z.splice(Z.lastIndexOf("]"),1)}),Z.length>0)Z.reverse().map((z)=>{if(z==="}")$.push({type:"brace",value:"}"});else if(z==="]")$.push({type:"paren",value:"]"})});return $},ZM=($)=>{let Z="";return $.map((z)=>{switch(z.type){case"string":Z+='"'+z.value+'"';break;default:Z+=z.value;break}}),Z},Q6=($)=>JSON.parse(ZM($M(H1(eN($)))));var f3=()=>{};var g3=S(()=>{H3()});function JX($){return $.type==="tool_use"||$.type==="server_tool_use"||$.type==="mcp_tool_use"}function QX($){}var P0,q$,B1,O4,Y6,D4,I4,U6,A4,i0,R4,G6,W6,E$,q6,V6,F4,h3,ZX,K6,v3,u3,m3,zX,XX="__json_buf",w4;var YX=S(()=>{d0();f3();K1();g3();y3();w4=class w4{constructor($,Z){P0.add(this),this.messages=[],this.receivedMessages=[],q$.set(this,void 0),B1.set(this,null),this.controller=new AbortController,O4.set(this,void 0),Y6.set(this,()=>{}),D4.set(this,()=>{}),I4.set(this,void 0),U6.set(this,()=>{}),A4.set(this,()=>{}),i0.set(this,{}),R4.set(this,!1),G6.set(this,!1),W6.set(this,!1),E$.set(this,!1),q6.set(this,void 0),V6.set(this,void 0),F4.set(this,void 0),K6.set(this,(z)=>{if(R(this,G6,!0,"f"),p0(z))z=new q0;if(z instanceof q0)return R(this,W6,!0,"f"),this._emit("abort",z);if(z instanceof _)return this._emit("error",z);if(z instanceof Error){let X=new _(z.message);return X.cause=z,this._emit("error",X)}return this._emit("error",new _(String(z)))}),R(this,O4,new Promise((z,X)=>{R(this,Y6,z,"f"),R(this,D4,X,"f")}),"f"),R(this,I4,new Promise((z,X)=>{R(this,U6,z,"f"),R(this,A4,X,"f")}),"f"),H(this,O4,"f").catch(()=>{}),H(this,I4,"f").catch(()=>{}),R(this,B1,$,"f"),R(this,F4,Z?.logger??console,"f")}get response(){return H(this,q6,"f")}get request_id(){return H(this,V6,"f")}async withResponse(){R(this,E$,!0,"f");let $=await H(this,O4,"f");if(!$)throw Error("Could not resolve a `Response` object");return{data:this,response:$,request_id:$.headers.get("request-id")}}static fromReadableStream($){let Z=new w4(null);return Z._run(()=>Z._fromReadableStream($)),Z}static createMessage($,Z,z,{logger:X}={}){let J=new w4(Z,{logger:X});for(let Q of Z.messages)J._addMessageParam(Q);return R(J,B1,{...Z,stream:!0},"f"),J._run(()=>J._createMessage($,{...Z,stream:!0},{...z,headers:{...z?.headers,"X-Stainless-Helper-Method":"stream"}})),J}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},H(this,K6,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,Z=!0){if(this.receivedMessages.push($),Z)this._emit("message",$)}async _createMessage($,Z,z){let X=z?.signal,J;if(X){if(X.aborted)this.controller.abort();J=this.controller.abort.bind(this.controller),X.addEventListener("abort",J)}try{H(this,P0,"m",v3).call(this);let{response:Q,data:Y}=await $.create({...Z,stream:!0},{...z,signal:this.controller.signal}).withResponse();this._connected(Q);for await(let U of Y)H(this,P0,"m",u3).call(this,U);if(Y.controller.signal?.aborted)throw new q0;H(this,P0,"m",m3).call(this)}finally{if(X&&J)X.removeEventListener("abort",J)}}_connected($){if(this.ended)return;R(this,q6,$,"f"),R(this,V6,$?.headers.get("request-id"),"f"),H(this,Y6,"f").call(this,$),this._emit("connect")}get ended(){return H(this,R4,"f")}get errored(){return H(this,G6,"f")}get aborted(){return H(this,W6,"f")}abort(){this.controller.abort()}on($,Z){return(H(this,i0,"f")[$]||(H(this,i0,"f")[$]=[])).push({listener:Z}),this}off($,Z){let z=H(this,i0,"f")[$];if(!z)return this;let X=z.findIndex((J)=>J.listener===Z);if(X>=0)z.splice(X,1);return this}once($,Z){return(H(this,i0,"f")[$]||(H(this,i0,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,z)=>{if(R(this,E$,!0,"f"),$!=="error")this.once("error",z);this.once($,Z)})}async done(){R(this,E$,!0,"f"),await H(this,I4,"f")}get currentMessage(){return H(this,q$,"f")}async finalMessage(){return await this.done(),H(this,P0,"m",h3).call(this)}async finalText(){return await this.done(),H(this,P0,"m",ZX).call(this)}_emit($,...Z){if(H(this,R4,"f"))return;if($==="end")R(this,R4,!0,"f"),H(this,U6,"f").call(this);let z=H(this,i0,"f")[$];if(z)H(this,i0,"f")[$]=z.filter((X)=>!X.once),z.forEach(({listener:X})=>X(...Z));if($==="abort"){let X=Z[0];if(!H(this,E$,"f")&&!z?.length)Promise.reject(X);H(this,D4,"f").call(this,X),H(this,A4,"f").call(this,X),this._emit("end");return}if($==="error"){let X=Z[0];if(!H(this,E$,"f")&&!z?.length)Promise.reject(X);H(this,D4,"f").call(this,X),H(this,A4,"f").call(this,X),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",H(this,P0,"m",h3).call(this))}async _fromReadableStream($,Z){let z=Z?.signal,X;if(z){if(z.aborted)this.controller.abort();X=this.controller.abort.bind(this.controller),z.addEventListener("abort",X)}try{H(this,P0,"m",v3).call(this),this._connected(null);let J=I0.fromReadableStream($,this.controller);for await(let Q of J)H(this,P0,"m",u3).call(this,Q);if(J.controller.signal?.aborted)throw new q0;H(this,P0,"m",m3).call(this)}finally{if(z&&X)z.removeEventListener("abort",X)}}[(q$=new WeakMap,B1=new WeakMap,O4=new WeakMap,Y6=new WeakMap,D4=new WeakMap,I4=new WeakMap,U6=new WeakMap,A4=new WeakMap,i0=new WeakMap,R4=new WeakMap,G6=new WeakMap,W6=new WeakMap,E$=new WeakMap,q6=new WeakMap,V6=new WeakMap,F4=new WeakMap,K6=new WeakMap,P0=new WeakSet,h3=function(){if(this.receivedMessages.length===0)throw new _("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},ZX=function(){if(this.receivedMessages.length===0)throw new _("stream ended without producing a Message with role=assistant");let Z=this.receivedMessages.at(-1).content.filter((z)=>z.type==="text").map((z)=>z.text);if(Z.length===0)throw new _("stream ended without producing a content block with type=text");return Z.join(" ")},v3=function(){if(this.ended)return;R(this,q$,void 0,"f")},u3=function(Z){if(this.ended)return;let z=H(this,P0,"m",zX).call(this,Z);switch(this._emit("streamEvent",Z,z),Z.type){case"content_block_delta":{let X=z.content.at(-1);switch(Z.delta.type){case"text_delta":{if(X.type==="text")this._emit("text",Z.delta.text,X.text||"");break}case"citations_delta":{if(X.type==="text")this._emit("citation",Z.delta.citation,X.citations??[]);break}case"input_json_delta":{if(JX(X)&&X.input)this._emit("inputJson",Z.delta.partial_json,X.input);break}case"thinking_delta":{if(X.type==="thinking")this._emit("thinking",Z.delta.thinking,X.thinking);break}case"signature_delta":{if(X.type==="thinking")this._emit("signature",X.signature);break}case"compaction_delta":{if(X.type==="compaction"&&X.content)this._emit("compaction",X.content);break}default:QX(Z.delta)}break}case"message_stop":{this._addMessageParam(z),this._addMessage(x3(z,H(this,B1,"f"),{logger:H(this,F4,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",z.content.at(-1));break}case"message_start":{R(this,q$,z,"f");break}case"content_block_start":case"message_delta":break}},m3=function(){if(this.ended)throw new _("stream has ended, this shouldn't happen");let Z=H(this,q$,"f");if(!Z)throw new _("request ended without sending any chunks");return R(this,q$,void 0,"f"),x3(Z,H(this,B1,"f"),{logger:H(this,F4,"f")})},zX=function(Z){let z=H(this,q$,"f");if(Z.type==="message_start"){if(z)throw new _(`Unexpected event order, got ${Z.type} before receiving "message_stop"`);return Z.message}if(!z)throw new _(`Unexpected event order, got ${Z.type} before "message_start"`);switch(Z.type){case"message_stop":return z;case"message_delta":if(z.container=Z.delta.container,z.stop_reason=Z.delta.stop_reason,z.stop_sequence=Z.delta.stop_sequence,z.usage.output_tokens=Z.usage.output_tokens,z.context_management=Z.context_management,Z.usage.input_tokens!=null)z.usage.input_tokens=Z.usage.input_tokens;if(Z.usage.cache_creation_input_tokens!=null)z.usage.cache_creation_input_tokens=Z.usage.cache_creation_input_tokens;if(Z.usage.cache_read_input_tokens!=null)z.usage.cache_read_input_tokens=Z.usage.cache_read_input_tokens;if(Z.usage.server_tool_use!=null)z.usage.server_tool_use=Z.usage.server_tool_use;if(Z.usage.iterations!=null)z.usage.iterations=Z.usage.iterations;return z;case"content_block_start":return z.content.push(Z.content_block),z;case"content_block_delta":{let X=z.content.at(Z.index);switch(Z.delta.type){case"text_delta":{if(X?.type==="text")z.content[Z.index]={...X,text:(X.text||"")+Z.delta.text};break}case"citations_delta":{if(X?.type==="text")z.content[Z.index]={...X,citations:[...X.citations??[],Z.delta.citation]};break}case"input_json_delta":{if(X&&JX(X)){let J=X[XX]||"";J+=Z.delta.partial_json;let Q={...X};if(Object.defineProperty(Q,XX,{value:J,enumerable:!1,writable:!0}),J)try{Q.input=Q6(J)}catch(Y){let U=new _(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${Y}. JSON: ${J}`);H(this,K6,"f").call(this,U)}z.content[Z.index]=Q}break}case"thinking_delta":{if(X?.type==="thinking")z.content[Z.index]={...X,thinking:X.thinking+Z.delta.thinking};break}case"signature_delta":{if(X?.type==="thinking")z.content[Z.index]={...X,signature:Z.delta.signature};break}case"compaction_delta":{if(X?.type==="compaction")z.content[Z.index]={...X,content:(X.content||"")+Z.delta.content};break}default:QX(Z.delta)}return z}case"content_block_stop":return z}},Symbol.asyncIterator)](){let $=[],Z=[],z=!1;return this.on("streamEvent",(X)=>{let J=Z.shift();if(J)J.resolve(X);else $.push(X)}),this.on("end",()=>{z=!0;for(let X of Z)X.resolve(void 0);Z.length=0}),this.on("abort",(X)=>{z=!0;for(let J of Z)J.reject(X);Z.length=0}),this.on("error",(X)=>{z=!0;for(let J of Z)J.reject(X);Z.length=0}),{next:async()=>{if(!$.length){if(z)return{value:void 0,done:!0};return new Promise((J,Q)=>Z.push({resolve:J,reject:Q})).then((J)=>J?{value:J,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new I0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}});var L1;var H6=S(()=>{L1=class L1 extends Error{constructor($){let Z=typeof $==="string"?$:$.map((z)=>{if(z.type==="text")return z.text;return`[${z.type}]`}).join(" ");super(Z);this.name="ToolError",this.content=$}}});var UX=1e5,GX=`You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
173
+ ${V}`)}return Y},I;var J0=S(()=>{N0();oz=Object.freeze(Object.create(null)),I=dN(tz)});var q4;var A3=S(()=>{t();s();J0();q4=class q4 extends f{create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/environments?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/environments/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/environments/${$}?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/environments?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/environments/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}archive($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/environments/${$}/archive?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}}});function z6($){return typeof $==="object"&&$!==null&&V4 in $}function R3($,Z){let z=new Set;if($){for(let X of $)if(z6(X))z.add(X[V4])}if(Z)for(let X of Z){if(z6(X))z.add(X[V4]);if(Array.isArray(X.content)){for(let J of X.content)if(z6(J))z.add(J[V4])}}return Array.from(z)}function X6($,Z){let z=R3($,Z);if(z.length===0)return{};return{"x-stainless-helper":z.join(", ")}}function ez($){if(z6($))return{"x-stainless-helper":$[V4]};return{}}var V4;var K4=S(()=>{V4=Symbol("anthropic.sdk.stainlessHelper")});var H4;var F3=S(()=>{t();s();K4();q1();J0();H4=class H4 extends f{list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/files?beta=true",S0,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"files-api-2025-04-14"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/files/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"files-api-2025-04-14"].toString()},z?.headers])})}download($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/files/${$}/content?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"files-api-2025-04-14"].toString(),Accept:"application/binary"},z?.headers]),__binaryResponse:!0})}retrieveMetadata($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/files/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"files-api-2025-04-14"].toString()},z?.headers])})}upload($,Z){let{betas:z,...X}=$;return this._client.post("/v1/files?beta=true",W1({body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"files-api-2025-04-14"].toString()},ez(X.file),Z?.headers])},this._client))}}});var B4;var w3=S(()=>{t();s();J0();B4=class B4 extends f{retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/models/${$}?beta=true`,{...z,headers:T([{...X?.toString()!=null?{"anthropic-beta":X?.toString()}:void 0},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/models?beta=true",S0,{query:X,...Z,headers:T([{...z?.toString()!=null?{"anthropic-beta":z?.toString()}:void 0},Z?.headers])})}}});var L4;var P3=S(()=>{t();s();J0();L4=class L4 extends f{create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/user_profiles?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"user-profiles-2026-03-24"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/user_profiles/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"user-profiles-2026-03-24"].toString()},z?.headers])})}update($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/user_profiles/${$}?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"user-profiles-2026-03-24"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/user_profiles?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"user-profiles-2026-03-24"].toString()},Z?.headers])})}createEnrollmentURL($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/user_profiles/${$}/enrollment_url?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"user-profiles-2026-03-24"].toString()},z?.headers])})}}});var N4;var _3=S(()=>{t();s();J0();N4=class N4 extends f{list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/agents/${$}/versions?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}}});var V1;var C3=S(()=>{_3();_3();t();s();J0();V1=class V1 extends f{constructor(){super(...arguments);this.versions=new N4(this._client)}create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/agents?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X,...J}=Z??{};return this._client.get(I`/v1/agents/${$}?beta=true`,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/agents/${$}?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/agents?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}archive($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/agents/${$}/archive?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}};V1.Versions=N4});var M4;var E3=S(()=>{t();s();J0();M4=class M4 extends f{create($,Z,z){let{view:X,betas:J,...Q}=Z;return this._client.post(I`/v1/memory_stores/${$}/memories?beta=true`,{query:{view:X},body:Q,...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}retrieve($,Z,z){let{memory_store_id:X,betas:J,...Q}=Z;return this._client.get(I`/v1/memory_stores/${X}/memories/${$}?beta=true`,{query:Q,...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{memory_store_id:X,view:J,betas:Q,...Y}=Z;return this._client.post(I`/v1/memory_stores/${X}/memories/${$}?beta=true`,{query:{view:J},body:Y,...z,headers:T([{"anthropic-beta":[...Q??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/memory_stores/${$}/memories?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}delete($,Z,z){let{memory_store_id:X,expected_content_sha256:J,betas:Q}=Z;return this._client.delete(I`/v1/memory_stores/${X}/memories/${$}?beta=true`,{query:{expected_content_sha256:J},...z,headers:T([{"anthropic-beta":[...Q??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}}});var T4;var j3=S(()=>{t();s();J0();T4=class T4 extends f{retrieve($,Z,z){let{memory_store_id:X,betas:J,...Q}=Z;return this._client.get(I`/v1/memory_stores/${X}/memory_versions/${$}?beta=true`,{query:Q,...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/memory_stores/${$}/memory_versions?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}redact($,Z,z){let{memory_store_id:X,betas:J}=Z;return this._client.post(I`/v1/memory_stores/${X}/memory_versions/${$}/redact?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}}});var C$;var S3=S(()=>{E3();E3();j3();j3();t();s();J0();C$=class C$ extends f{constructor(){super(...arguments);this.memories=new M4(this._client),this.memoryVersions=new T4(this._client)}create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/memory_stores?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/memory_stores/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/memory_stores/${$}?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/memory_stores?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/memory_stores/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}archive($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/memory_stores/${$}/archive?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}};C$.Memories=M4;C$.MemoryVersions=T4});var K1=S(()=>{N0()});var J6;var b3=S(()=>{J6={"claude-opus-4-20250514":8192,"claude-opus-4-0":8192,"claude-4-opus-20250514":8192,"anthropic.claude-opus-4-20250514-v1:0":8192,"claude-opus-4@20250514":8192,"claude-opus-4-1-20250805":8192,"anthropic.claude-opus-4-1-20250805-v1:0":8192,"claude-opus-4-1@20250805":8192}});function $X($){return $?.output_format??$?.output_config?.format}function x3($,Z,z){let X=$X(Z);if(!Z||!("parse"in(X??{})))return{...$,content:$.content.map((J)=>{if(J.type==="text"){let Q=Object.defineProperty({...J},"parsed_output",{value:null,enumerable:!1});return Object.defineProperty(Q,"parsed",{get(){return z.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),null},enumerable:!1})}return J}),parsed_output:null};return k3($,Z,z)}function k3($,Z,z){let X=null,J=$.content.map((Q)=>{if(Q.type==="text"){let Y=eN(Z,Q.text);if(X===null)X=Y;let U=Object.defineProperty({...Q},"parsed_output",{value:Y,enumerable:!1});return Object.defineProperty(U,"parsed",{get(){return z.logger.warn("The `parsed` property on `text` blocks is deprecated, please use `parsed_output` instead."),Y},enumerable:!1})}return Q});return{...$,content:J,parsed_output:X}}function eN($,Z){let z=$X($);if(z?.type!=="json_schema")return null;try{if("parse"in z)return z.parse(Z);return JSON.parse(Z)}catch(X){throw new _(`Failed to parse structured output: ${X}`)}}var y3=S(()=>{N0()});var $M=($)=>{let Z=0,z=[];while(Z<$.length){let X=$[Z];if(X==="\\"){Z++;continue}if(X==="{"){z.push({type:"brace",value:"{"}),Z++;continue}if(X==="}"){z.push({type:"brace",value:"}"}),Z++;continue}if(X==="["){z.push({type:"paren",value:"["}),Z++;continue}if(X==="]"){z.push({type:"paren",value:"]"}),Z++;continue}if(X===":"){z.push({type:"separator",value:":"}),Z++;continue}if(X===","){z.push({type:"delimiter",value:","}),Z++;continue}if(X==='"'){let U="",G=!1;X=$[++Z];while(X!=='"'){if(Z===$.length){G=!0;break}if(X==="\\"){if(Z++,Z===$.length){G=!0;break}U+=X+$[Z],X=$[++Z]}else U+=X,X=$[++Z]}if(X=$[++Z],!G)z.push({type:"string",value:U});continue}if(X&&/\s/.test(X)){Z++;continue}let Q=/[0-9]/;if(X&&Q.test(X)||X==="-"||X==="."){let U="";if(X==="-")U+=X,X=$[++Z];while(X&&Q.test(X)||X===".")U+=X,X=$[++Z];z.push({type:"number",value:U});continue}let Y=/[a-z]/i;if(X&&Y.test(X)){let U="";while(X&&Y.test(X)){if(Z===$.length)break;U+=X,X=$[++Z]}if(U=="true"||U=="false"||U==="null")z.push({type:"name",value:U});else{Z++;continue}continue}Z++}return z},H1=($)=>{if($.length===0)return $;let Z=$[$.length-1];switch(Z.type){case"separator":return $=$.slice(0,$.length-1),H1($);break;case"number":let z=Z.value[Z.value.length-1];if(z==="."||z==="-")return $=$.slice(0,$.length-1),H1($);case"string":let X=$[$.length-2];if(X?.type==="delimiter")return $=$.slice(0,$.length-1),H1($);else if(X?.type==="brace"&&X.value==="{")return $=$.slice(0,$.length-1),H1($);break;case"delimiter":return $=$.slice(0,$.length-1),H1($);break}return $},ZM=($)=>{let Z=[];if($.map((z)=>{if(z.type==="brace")if(z.value==="{")Z.push("}");else Z.splice(Z.lastIndexOf("}"),1);if(z.type==="paren")if(z.value==="[")Z.push("]");else Z.splice(Z.lastIndexOf("]"),1)}),Z.length>0)Z.reverse().map((z)=>{if(z==="}")$.push({type:"brace",value:"}"});else if(z==="]")$.push({type:"paren",value:"]"})});return $},zM=($)=>{let Z="";return $.map((z)=>{switch(z.type){case"string":Z+='"'+z.value+'"';break;default:Z+=z.value;break}}),Z},Q6=($)=>JSON.parse(zM(ZM(H1($M($)))));var f3=()=>{};var g3=S(()=>{H3()});function JX($){return $.type==="tool_use"||$.type==="server_tool_use"||$.type==="mcp_tool_use"}function QX($){}var P0,q$,B1,O4,Y6,D4,I4,U6,A4,i0,R4,G6,W6,E$,q6,V6,F4,h3,ZX,K6,v3,u3,m3,zX,XX="__json_buf",w4;var YX=S(()=>{d0();f3();K1();g3();y3();w4=class w4{constructor($,Z){P0.add(this),this.messages=[],this.receivedMessages=[],q$.set(this,void 0),B1.set(this,null),this.controller=new AbortController,O4.set(this,void 0),Y6.set(this,()=>{}),D4.set(this,()=>{}),I4.set(this,void 0),U6.set(this,()=>{}),A4.set(this,()=>{}),i0.set(this,{}),R4.set(this,!1),G6.set(this,!1),W6.set(this,!1),E$.set(this,!1),q6.set(this,void 0),V6.set(this,void 0),F4.set(this,void 0),K6.set(this,(z)=>{if(R(this,G6,!0,"f"),p0(z))z=new q0;if(z instanceof q0)return R(this,W6,!0,"f"),this._emit("abort",z);if(z instanceof _)return this._emit("error",z);if(z instanceof Error){let X=new _(z.message);return X.cause=z,this._emit("error",X)}return this._emit("error",new _(String(z)))}),R(this,O4,new Promise((z,X)=>{R(this,Y6,z,"f"),R(this,D4,X,"f")}),"f"),R(this,I4,new Promise((z,X)=>{R(this,U6,z,"f"),R(this,A4,X,"f")}),"f"),H(this,O4,"f").catch(()=>{}),H(this,I4,"f").catch(()=>{}),R(this,B1,$,"f"),R(this,F4,Z?.logger??console,"f")}get response(){return H(this,q6,"f")}get request_id(){return H(this,V6,"f")}async withResponse(){R(this,E$,!0,"f");let $=await H(this,O4,"f");if(!$)throw Error("Could not resolve a `Response` object");return{data:this,response:$,request_id:$.headers.get("request-id")}}static fromReadableStream($){let Z=new w4(null);return Z._run(()=>Z._fromReadableStream($)),Z}static createMessage($,Z,z,{logger:X}={}){let J=new w4(Z,{logger:X});for(let Q of Z.messages)J._addMessageParam(Q);return R(J,B1,{...Z,stream:!0},"f"),J._run(()=>J._createMessage($,{...Z,stream:!0},{...z,headers:{...z?.headers,"X-Stainless-Helper-Method":"stream"}})),J}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},H(this,K6,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,Z=!0){if(this.receivedMessages.push($),Z)this._emit("message",$)}async _createMessage($,Z,z){let X=z?.signal,J;if(X){if(X.aborted)this.controller.abort();J=this.controller.abort.bind(this.controller),X.addEventListener("abort",J)}try{H(this,P0,"m",v3).call(this);let{response:Q,data:Y}=await $.create({...Z,stream:!0},{...z,signal:this.controller.signal}).withResponse();this._connected(Q);for await(let U of Y)H(this,P0,"m",u3).call(this,U);if(Y.controller.signal?.aborted)throw new q0;H(this,P0,"m",m3).call(this)}finally{if(X&&J)X.removeEventListener("abort",J)}}_connected($){if(this.ended)return;R(this,q6,$,"f"),R(this,V6,$?.headers.get("request-id"),"f"),H(this,Y6,"f").call(this,$),this._emit("connect")}get ended(){return H(this,R4,"f")}get errored(){return H(this,G6,"f")}get aborted(){return H(this,W6,"f")}abort(){this.controller.abort()}on($,Z){return(H(this,i0,"f")[$]||(H(this,i0,"f")[$]=[])).push({listener:Z}),this}off($,Z){let z=H(this,i0,"f")[$];if(!z)return this;let X=z.findIndex((J)=>J.listener===Z);if(X>=0)z.splice(X,1);return this}once($,Z){return(H(this,i0,"f")[$]||(H(this,i0,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,z)=>{if(R(this,E$,!0,"f"),$!=="error")this.once("error",z);this.once($,Z)})}async done(){R(this,E$,!0,"f"),await H(this,I4,"f")}get currentMessage(){return H(this,q$,"f")}async finalMessage(){return await this.done(),H(this,P0,"m",h3).call(this)}async finalText(){return await this.done(),H(this,P0,"m",ZX).call(this)}_emit($,...Z){if(H(this,R4,"f"))return;if($==="end")R(this,R4,!0,"f"),H(this,U6,"f").call(this);let z=H(this,i0,"f")[$];if(z)H(this,i0,"f")[$]=z.filter((X)=>!X.once),z.forEach(({listener:X})=>X(...Z));if($==="abort"){let X=Z[0];if(!H(this,E$,"f")&&!z?.length)Promise.reject(X);H(this,D4,"f").call(this,X),H(this,A4,"f").call(this,X),this._emit("end");return}if($==="error"){let X=Z[0];if(!H(this,E$,"f")&&!z?.length)Promise.reject(X);H(this,D4,"f").call(this,X),H(this,A4,"f").call(this,X),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",H(this,P0,"m",h3).call(this))}async _fromReadableStream($,Z){let z=Z?.signal,X;if(z){if(z.aborted)this.controller.abort();X=this.controller.abort.bind(this.controller),z.addEventListener("abort",X)}try{H(this,P0,"m",v3).call(this),this._connected(null);let J=I0.fromReadableStream($,this.controller);for await(let Q of J)H(this,P0,"m",u3).call(this,Q);if(J.controller.signal?.aborted)throw new q0;H(this,P0,"m",m3).call(this)}finally{if(z&&X)z.removeEventListener("abort",X)}}[(q$=new WeakMap,B1=new WeakMap,O4=new WeakMap,Y6=new WeakMap,D4=new WeakMap,I4=new WeakMap,U6=new WeakMap,A4=new WeakMap,i0=new WeakMap,R4=new WeakMap,G6=new WeakMap,W6=new WeakMap,E$=new WeakMap,q6=new WeakMap,V6=new WeakMap,F4=new WeakMap,K6=new WeakMap,P0=new WeakSet,h3=function(){if(this.receivedMessages.length===0)throw new _("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},ZX=function(){if(this.receivedMessages.length===0)throw new _("stream ended without producing a Message with role=assistant");let Z=this.receivedMessages.at(-1).content.filter((z)=>z.type==="text").map((z)=>z.text);if(Z.length===0)throw new _("stream ended without producing a content block with type=text");return Z.join(" ")},v3=function(){if(this.ended)return;R(this,q$,void 0,"f")},u3=function(Z){if(this.ended)return;let z=H(this,P0,"m",zX).call(this,Z);switch(this._emit("streamEvent",Z,z),Z.type){case"content_block_delta":{let X=z.content.at(-1);switch(Z.delta.type){case"text_delta":{if(X.type==="text")this._emit("text",Z.delta.text,X.text||"");break}case"citations_delta":{if(X.type==="text")this._emit("citation",Z.delta.citation,X.citations??[]);break}case"input_json_delta":{if(JX(X)&&X.input)this._emit("inputJson",Z.delta.partial_json,X.input);break}case"thinking_delta":{if(X.type==="thinking")this._emit("thinking",Z.delta.thinking,X.thinking);break}case"signature_delta":{if(X.type==="thinking")this._emit("signature",X.signature);break}case"compaction_delta":{if(X.type==="compaction"&&X.content)this._emit("compaction",X.content);break}default:QX(Z.delta)}break}case"message_stop":{this._addMessageParam(z),this._addMessage(x3(z,H(this,B1,"f"),{logger:H(this,F4,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",z.content.at(-1));break}case"message_start":{R(this,q$,z,"f");break}case"content_block_start":case"message_delta":break}},m3=function(){if(this.ended)throw new _("stream has ended, this shouldn't happen");let Z=H(this,q$,"f");if(!Z)throw new _("request ended without sending any chunks");return R(this,q$,void 0,"f"),x3(Z,H(this,B1,"f"),{logger:H(this,F4,"f")})},zX=function(Z){let z=H(this,q$,"f");if(Z.type==="message_start"){if(z)throw new _(`Unexpected event order, got ${Z.type} before receiving "message_stop"`);return Z.message}if(!z)throw new _(`Unexpected event order, got ${Z.type} before "message_start"`);switch(Z.type){case"message_stop":return z;case"message_delta":if(z.container=Z.delta.container,z.stop_reason=Z.delta.stop_reason,z.stop_sequence=Z.delta.stop_sequence,z.usage.output_tokens=Z.usage.output_tokens,z.context_management=Z.context_management,Z.usage.input_tokens!=null)z.usage.input_tokens=Z.usage.input_tokens;if(Z.usage.cache_creation_input_tokens!=null)z.usage.cache_creation_input_tokens=Z.usage.cache_creation_input_tokens;if(Z.usage.cache_read_input_tokens!=null)z.usage.cache_read_input_tokens=Z.usage.cache_read_input_tokens;if(Z.usage.server_tool_use!=null)z.usage.server_tool_use=Z.usage.server_tool_use;if(Z.usage.iterations!=null)z.usage.iterations=Z.usage.iterations;return z;case"content_block_start":return z.content.push(Z.content_block),z;case"content_block_delta":{let X=z.content.at(Z.index);switch(Z.delta.type){case"text_delta":{if(X?.type==="text")z.content[Z.index]={...X,text:(X.text||"")+Z.delta.text};break}case"citations_delta":{if(X?.type==="text")z.content[Z.index]={...X,citations:[...X.citations??[],Z.delta.citation]};break}case"input_json_delta":{if(X&&JX(X)){let J=X[XX]||"";J+=Z.delta.partial_json;let Q={...X};if(Object.defineProperty(Q,XX,{value:J,enumerable:!1,writable:!0}),J)try{Q.input=Q6(J)}catch(Y){let U=new _(`Unable to parse tool parameter JSON from model. Please retry your request or adjust your prompt. Error: ${Y}. JSON: ${J}`);H(this,K6,"f").call(this,U)}z.content[Z.index]=Q}break}case"thinking_delta":{if(X?.type==="thinking")z.content[Z.index]={...X,thinking:X.thinking+Z.delta.thinking};break}case"signature_delta":{if(X?.type==="thinking")z.content[Z.index]={...X,signature:Z.delta.signature};break}case"compaction_delta":{if(X?.type==="compaction")z.content[Z.index]={...X,content:(X.content||"")+Z.delta.content};break}default:QX(Z.delta)}return z}case"content_block_stop":return z}},Symbol.asyncIterator)](){let $=[],Z=[],z=!1;return this.on("streamEvent",(X)=>{let J=Z.shift();if(J)J.resolve(X);else $.push(X)}),this.on("end",()=>{z=!0;for(let X of Z)X.resolve(void 0);Z.length=0}),this.on("abort",(X)=>{z=!0;for(let J of Z)J.reject(X);Z.length=0}),this.on("error",(X)=>{z=!0;for(let J of Z)J.reject(X);Z.length=0}),{next:async()=>{if(!$.length){if(z)return{value:void 0,done:!0};return new Promise((J,Q)=>Z.push({resolve:J,reject:Q})).then((J)=>J?{value:J,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new I0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}});var L1;var H6=S(()=>{L1=class L1 extends Error{constructor($){let Z=typeof $==="string"?$:$.map((z)=>{if(z.type==="text")return z.text;return`[${z.type}]`}).join(" ");super(Z);this.name="ToolError",this.content=$}}});var UX=1e5,GX=`You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
174
174
  1. Task Overview
175
175
  The user's core request and success criteria
176
176
  Any clarifications or constraints they specified
@@ -192,21 +192,21 @@ User preferences or style requirements
192
192
  Domain-specific details that aren't obvious
193
193
  Any promises made to the user
194
194
  Be concise but complete—err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
195
- Wrap your summary in <summary></summary> tags.`;function qX(){let $,Z;return{promise:new Promise((X,J)=>{$=X,Z=J}),resolve:$,reject:Z}}async function zM($,Z=$.messages.at(-1),z){if(!Z||Z.role!=="assistant"||!Z.content||typeof Z.content==="string")return null;let X=Z.content.filter((Q)=>Q.type==="tool_use");if(X.length===0)return null;return{role:"user",content:await Promise.all(X.map(async(Q)=>{let Y=$.tools.find((U)=>("name"in U?U.name:U.mcp_server_name)===Q.name);if(!Y||!("run"in Y))return{type:"tool_result",tool_use_id:Q.id,content:`Error: Tool '${Q.name}' not found`,is_error:!0};try{let U=Q.input;if("parse"in Y&&Y.parse)U=Y.parse(U);let G=await Y.run(U,{toolUseBlock:Q,signal:z?.signal});return{type:"tool_result",tool_use_id:Q.id,content:G}}catch(U){return{type:"tool_result",tool_use_id:Q.id,content:U instanceof L1?U.content:`Error: ${U instanceof Error?U.message:String(U)}`,is_error:!0}}}))}}var P4,N1,j$,U0,M0,A0,n0,V$,_4,WX,c3,C4;var d3=S(()=>{d0();H6();N0();s();K4();C4=class C4{constructor($,Z,z){P4.add(this),this.client=$,N1.set(this,!1),j$.set(this,!1),U0.set(this,void 0),M0.set(this,void 0),A0.set(this,void 0),n0.set(this,void 0),V$.set(this,void 0),_4.set(this,0),R(this,U0,{params:{...Z,messages:structuredClone(Z.messages)}},"f");let J=["BetaToolRunner",...R3(Z.tools,Z.messages)].join(", ");if(R(this,M0,{...z,headers:T([{"x-stainless-helper":J},z?.headers])},"f"),R(this,V$,qX(),"f"),Z.compactionControl?.enabled)console.warn('Anthropic: The `compactionControl` parameter is deprecated and will be removed in a future version. Use server-side compaction instead by passing `edits: [{ type: "compact_20260112" }]` in the params passed to `toolRunner()`. See https://platform.claude.com/docs/en/build-with-claude/compaction')}async*[(N1=new WeakMap,j$=new WeakMap,U0=new WeakMap,M0=new WeakMap,A0=new WeakMap,n0=new WeakMap,V$=new WeakMap,_4=new WeakMap,P4=new WeakSet,WX=async function(){let Z=H(this,U0,"f").params.compactionControl;if(!Z||!Z.enabled)return!1;let z=0;if(H(this,A0,"f")!==void 0)try{let G=await H(this,A0,"f");z=G.usage.input_tokens+(G.usage.cache_creation_input_tokens??0)+(G.usage.cache_read_input_tokens??0)+G.usage.output_tokens}catch{return!1}let X=Z.contextTokenThreshold??UX;if(z<X)return!1;let J=Z.model??H(this,U0,"f").params.model,Q=Z.summaryPrompt??GX,Y=H(this,U0,"f").params.messages;if(Y[Y.length-1].role==="assistant"){let G=Y[Y.length-1];if(Array.isArray(G.content)){let W=G.content.filter((q)=>q.type!=="tool_use");if(W.length===0)Y.pop();else G.content=W}}let U=await this.client.beta.messages.create({model:J,messages:[...Y,{role:"user",content:[{type:"text",text:Q}]}],max_tokens:H(this,U0,"f").params.max_tokens},{signal:H(this,M0,"f").signal,headers:T([H(this,M0,"f").headers,{"x-stainless-helper":"compaction"}])});if(U.content[0]?.type!=="text")throw new _("Expected text response for compaction");return H(this,U0,"f").params.messages=[{role:"user",content:U.content}],!0},Symbol.asyncIterator)](){var $;if(H(this,N1,"f"))throw new _("Cannot iterate over a consumed stream");R(this,N1,!0,"f"),R(this,j$,!0,"f"),R(this,n0,void 0,"f");try{while(!0){let Z;try{if(H(this,U0,"f").params.max_iterations&&H(this,_4,"f")>=H(this,U0,"f").params.max_iterations)break;R(this,j$,!1,"f"),R(this,n0,void 0,"f"),R(this,_4,($=H(this,_4,"f"),$++,$),"f"),R(this,A0,void 0,"f");let{max_iterations:z,compactionControl:X,...J}=H(this,U0,"f").params;if(J.stream)Z=this.client.beta.messages.stream({...J},H(this,M0,"f")),R(this,A0,Z.finalMessage(),"f"),H(this,A0,"f").catch(()=>{}),yield Z;else R(this,A0,this.client.beta.messages.create({...J,stream:!1},H(this,M0,"f")),"f"),yield H(this,A0,"f");if(!await H(this,P4,"m",WX).call(this)){if(!H(this,j$,"f")){let{role:U,content:G}=await H(this,A0,"f");H(this,U0,"f").params.messages.push({role:U,content:G})}let Y=await H(this,P4,"m",c3).call(this,H(this,U0,"f").params.messages.at(-1));if(Y)H(this,U0,"f").params.messages.push(Y);else if(!H(this,j$,"f"))break}}finally{if(Z)Z.abort()}}if(!H(this,A0,"f"))throw new _("ToolRunner concluded without a message from the server");H(this,V$,"f").resolve(await H(this,A0,"f"))}catch(Z){throw R(this,N1,!1,"f"),H(this,V$,"f").promise.catch(()=>{}),H(this,V$,"f").reject(Z),R(this,V$,qX(),"f"),Z}}setMessagesParams($){if(typeof $==="function")H(this,U0,"f").params=$(H(this,U0,"f").params);else H(this,U0,"f").params=$;R(this,j$,!0,"f"),R(this,n0,void 0,"f")}setRequestOptions($){if(typeof $==="function")R(this,M0,$(H(this,M0,"f")),"f");else R(this,M0,{...H(this,M0,"f"),...$},"f")}async generateToolResponse($=H(this,M0,"f").signal){let Z=await H(this,A0,"f")??this.params.messages.at(-1);if(!Z)return null;return H(this,P4,"m",c3).call(this,Z,$)}done(){return H(this,V$,"f").promise}async runUntilDone(){if(!H(this,N1,"f"))for await(let $ of this);return this.done()}get params(){return H(this,U0,"f").params}pushMessages(...$){this.setMessagesParams((Z)=>({...Z,messages:[...Z.messages,...$]}))}then($,Z){return this.runUntilDone().then($,Z)}};c3=async function(Z,z=H(this,M0,"f").signal){if(H(this,n0,"f")!==void 0)return H(this,n0,"f");return R(this,n0,zM(H(this,U0,"f").params,Z,{...H(this,M0,"f"),signal:z}),"f"),H(this,n0,"f")}});var M1;var p3=S(()=>{N0();V3();M1=class M1{constructor($,Z){this.iterator=$,this.controller=Z}async*decoder(){let $=new G$;for await(let Z of this.iterator)for(let z of $.decode(Z))yield JSON.parse(z);for(let Z of $.flush())yield JSON.parse(Z)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse($,Z){if(!$.body){if(Z.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative")throw new _("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new _("Attempted to iterate over a response with no body")}return new M1(z4($.body),Z)}}});var E4;var l3=S(()=>{t();s();p3();K1();J0();E4=class E4 extends f{create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/messages/batches?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/messages/batches/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/messages/batches?beta=true",S0,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/messages/batches/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString()},z?.headers])})}cancel($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/messages/batches/${$}/cancel?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString()},z?.headers])})}async results($,Z={},z){let X=await this.retrieve($);if(!X.results_url)throw new _(`No batch \`results_url\`; Has it finished processing? ${X.processing_status} - ${X.id}`);let{betas:J}=Z??{};return this._client.get(X.results_url,{...z,headers:T([{"anthropic-beta":[...J??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary"},z?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((Q,Y)=>M1.fromResponse(Y.response,Y.controller))}}});function KX($){if(!$.output_format)return $;if($.output_config?.format)throw new _("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");let{output_format:Z,...z}=$;return{...z,output_config:{...$.output_config,format:Z}}}var VX,JM,K$;var i3=S(()=>{K1();b3();s();K4();y3();YX();d3();H6();l3();l3();d3();H6();VX={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026"},JM=["claude-mythos-preview","claude-opus-4-6"];K$=class K$ extends f{constructor(){super(...arguments);this.batches=new E4(this._client)}create($,Z){let z=KX($),{betas:X,...J}=z;if(J.model in VX)console.warn(`The model '${J.model}' is deprecated and will reach end-of-life on ${VX[J.model]}
196
- Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);if(JM.includes(J.model)&&J.thinking&&J.thinking.type==="enabled")console.warn(`Using Claude with ${J.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let Q=this._client._options.timeout;if(!J.stream&&Q==null){let U=J6[J.model]??void 0;Q=this._client.calculateNonstreamingTimeout(J.max_tokens,U)}let Y=X6(J.tools,J.messages);return this._client.post("/v1/messages?beta=true",{body:J,timeout:Q??600000,...Z,headers:T([{...X?.toString()!=null?{"anthropic-beta":X?.toString()}:void 0},Y,Z?.headers]),stream:z.stream??!1})}parse($,Z){return Z={...Z,headers:T([{"anthropic-beta":[...$.betas??[],"structured-outputs-2025-12-15"].toString()},Z?.headers])},this.create($,Z).then((z)=>k3(z,$,{logger:this._client.logger??console}))}stream($,Z){return w4.createMessage(this,$,Z)}countTokens($,Z){let z=KX($),{betas:X,...J}=z;return this._client.post("/v1/messages/count_tokens?beta=true",{body:J,...Z,headers:T([{"anthropic-beta":[...X??[],"token-counting-2024-11-01"].toString()},Z?.headers])})}toolRunner($,Z){return new C4(this._client,$,Z)}};K$.Batches=E4;K$.BetaToolRunner=C4;K$.ToolError=L1});var j4;var n3=S(()=>{t();s();J0();j4=class j4 extends f{list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/sessions/${$}/events?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}send($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/sessions/${$}/events?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}stream($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/sessions/${$}/events/stream?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers]),stream:!0})}}});var S4;var s3=S(()=>{t();s();J0();S4=class S4 extends f{retrieve($,Z,z){let{session_id:X,betas:J}=Z;return this._client.get(I`/v1/sessions/${X}/resources/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{session_id:X,betas:J,...Q}=Z;return this._client.post(I`/v1/sessions/${X}/resources/${$}?beta=true`,{body:Q,...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/sessions/${$}/resources?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}delete($,Z,z){let{session_id:X,betas:J}=Z;return this._client.delete(I`/v1/sessions/${X}/resources/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}add($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/sessions/${$}/resources?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}}});var S$;var r3=S(()=>{n3();n3();s3();s3();t();s();J0();S$=class S$ extends f{constructor(){super(...arguments);this.events=new j4(this._client),this.resources=new S4(this._client)}create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/sessions?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/sessions/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/sessions/${$}?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/sessions?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/sessions/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}archive($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/sessions/${$}/archive?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}};S$.Events=j4;S$.Resources=S4});var b4;var a3=S(()=>{t();s();q1();J0();b4=class b4 extends f{create($,Z={},z){let{betas:X,...J}=Z??{};return this._client.post(I`/v1/skills/${$}/versions?beta=true`,W1({body:J,...z,headers:T([{"anthropic-beta":[...X??[],"skills-2025-10-02"].toString()},z?.headers])},this._client))}retrieve($,Z,z){let{skill_id:X,betas:J}=Z;return this._client.get(I`/v1/skills/${X}/versions/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"skills-2025-10-02"].toString()},z?.headers])})}list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/skills/${$}/versions?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"skills-2025-10-02"].toString()},z?.headers])})}delete($,Z,z){let{skill_id:X,betas:J}=Z;return this._client.delete(I`/v1/skills/${X}/versions/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"skills-2025-10-02"].toString()},z?.headers])})}}});var T1;var o3=S(()=>{a3();a3();t();s();q1();J0();T1=class T1 extends f{constructor(){super(...arguments);this.versions=new b4(this._client)}create($={},Z){let{betas:z,...X}=$??{};return this._client.post("/v1/skills?beta=true",W1({body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"skills-2025-10-02"].toString()},Z?.headers])},this._client,!1))}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/skills/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"skills-2025-10-02"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/skills?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"skills-2025-10-02"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/skills/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"skills-2025-10-02"].toString()},z?.headers])})}};T1.Versions=b4});var x4;var t3=S(()=>{t();s();J0();x4=class x4 extends f{create($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/vaults/${$}/credentials?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}retrieve($,Z,z){let{vault_id:X,betas:J}=Z;return this._client.get(I`/v1/vaults/${X}/credentials/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{vault_id:X,betas:J,...Q}=Z;return this._client.post(I`/v1/vaults/${X}/credentials/${$}?beta=true`,{body:Q,...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/vaults/${$}/credentials?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}delete($,Z,z){let{vault_id:X,betas:J}=Z;return this._client.delete(I`/v1/vaults/${X}/credentials/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}archive($,Z,z){let{vault_id:X,betas:J}=Z;return this._client.post(I`/v1/vaults/${X}/credentials/${$}/archive?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}}});var O1;var e3=S(()=>{t3();t3();t();s();J0();O1=class O1 extends f{constructor(){super(...arguments);this.credentials=new x4(this._client)}create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/vaults?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/vaults/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/vaults/${$}?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/vaults?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/vaults/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}archive($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/vaults/${$}/archive?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}};O1.Credentials=x4});var B0;var $Z=S(()=>{A3();A3();F3();F3();w3();w3();P3();P3();C3();C3();S3();S3();i3();i3();r3();r3();o3();o3();e3();e3();B0=class B0 extends f{constructor(){super(...arguments);this.models=new B4(this._client),this.messages=new K$(this._client),this.agents=new V1(this._client),this.environments=new q4(this._client),this.sessions=new S$(this._client),this.vaults=new O1(this._client),this.memoryStores=new C$(this._client),this.files=new H4(this._client),this.skills=new T1(this._client),this.userProfiles=new L4(this._client)}};B0.Models=B4;B0.Messages=K$;B0.Agents=V1;B0.Environments=q4;B0.Sessions=S$;B0.Vaults=O1;B0.MemoryStores=C$;B0.Files=H4;B0.Skills=T1;B0.UserProfiles=L4});var D1;var ZZ=S(()=>{s();D1=class D1 extends f{create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/complete",{body:X,timeout:this._client._options.timeout??600000,...Z,headers:T([{...z?.toString()!=null?{"anthropic-beta":z?.toString()}:void 0},Z?.headers]),stream:$.stream??!1})}}});function HX($){return $?.output_config?.format}function zZ($,Z,z){let X=HX(Z);if(!Z||!("parse"in(X??{})))return{...$,content:$.content.map((J)=>{if(J.type==="text")return Object.defineProperty({...J},"parsed_output",{value:null,enumerable:!1});return J}),parsed_output:null};return XZ($,Z,z)}function XZ($,Z,z){let X=null,J=$.content.map((Q)=>{if(Q.type==="text"){let Y=HM(Z,Q.text);if(X===null)X=Y;return Object.defineProperty({...Q},"parsed_output",{value:Y,enumerable:!1})}return Q});return{...$,content:J,parsed_output:X}}function HM($,Z){let z=HX($);if(z?.type!=="json_schema")return null;try{if("parse"in z)return z.parse(Z);return JSON.parse(Z)}catch(X){throw new _(`Failed to parse structured output: ${X}`)}}var JZ=S(()=>{N0()});function MX($){return $.type==="tool_use"||$.type==="server_tool_use"}function TX($){}var _0,H$,I1,k4,B6,y4,f4,L6,g4,s0,h4,N6,M6,b$,T6,O6,v4,QZ,BX,YZ,UZ,GZ,WZ,LX,NX="__json_buf",u4;var OX=S(()=>{d0();K1();g3();f3();JZ();u4=class u4{constructor($,Z){_0.add(this),this.messages=[],this.receivedMessages=[],H$.set(this,void 0),I1.set(this,null),this.controller=new AbortController,k4.set(this,void 0),B6.set(this,()=>{}),y4.set(this,()=>{}),f4.set(this,void 0),L6.set(this,()=>{}),g4.set(this,()=>{}),s0.set(this,{}),h4.set(this,!1),N6.set(this,!1),M6.set(this,!1),b$.set(this,!1),T6.set(this,void 0),O6.set(this,void 0),v4.set(this,void 0),YZ.set(this,(z)=>{if(R(this,N6,!0,"f"),p0(z))z=new q0;if(z instanceof q0)return R(this,M6,!0,"f"),this._emit("abort",z);if(z instanceof _)return this._emit("error",z);if(z instanceof Error){let X=new _(z.message);return X.cause=z,this._emit("error",X)}return this._emit("error",new _(String(z)))}),R(this,k4,new Promise((z,X)=>{R(this,B6,z,"f"),R(this,y4,X,"f")}),"f"),R(this,f4,new Promise((z,X)=>{R(this,L6,z,"f"),R(this,g4,X,"f")}),"f"),H(this,k4,"f").catch(()=>{}),H(this,f4,"f").catch(()=>{}),R(this,I1,$,"f"),R(this,v4,Z?.logger??console,"f")}get response(){return H(this,T6,"f")}get request_id(){return H(this,O6,"f")}async withResponse(){R(this,b$,!0,"f");let $=await H(this,k4,"f");if(!$)throw Error("Could not resolve a `Response` object");return{data:this,response:$,request_id:$.headers.get("request-id")}}static fromReadableStream($){let Z=new u4(null);return Z._run(()=>Z._fromReadableStream($)),Z}static createMessage($,Z,z,{logger:X}={}){let J=new u4(Z,{logger:X});for(let Q of Z.messages)J._addMessageParam(Q);return R(J,I1,{...Z,stream:!0},"f"),J._run(()=>J._createMessage($,{...Z,stream:!0},{...z,headers:{...z?.headers,"X-Stainless-Helper-Method":"stream"}})),J}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},H(this,YZ,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,Z=!0){if(this.receivedMessages.push($),Z)this._emit("message",$)}async _createMessage($,Z,z){let X=z?.signal,J;if(X){if(X.aborted)this.controller.abort();J=this.controller.abort.bind(this.controller),X.addEventListener("abort",J)}try{H(this,_0,"m",UZ).call(this);let{response:Q,data:Y}=await $.create({...Z,stream:!0},{...z,signal:this.controller.signal}).withResponse();this._connected(Q);for await(let U of Y)H(this,_0,"m",GZ).call(this,U);if(Y.controller.signal?.aborted)throw new q0;H(this,_0,"m",WZ).call(this)}finally{if(X&&J)X.removeEventListener("abort",J)}}_connected($){if(this.ended)return;R(this,T6,$,"f"),R(this,O6,$?.headers.get("request-id"),"f"),H(this,B6,"f").call(this,$),this._emit("connect")}get ended(){return H(this,h4,"f")}get errored(){return H(this,N6,"f")}get aborted(){return H(this,M6,"f")}abort(){this.controller.abort()}on($,Z){return(H(this,s0,"f")[$]||(H(this,s0,"f")[$]=[])).push({listener:Z}),this}off($,Z){let z=H(this,s0,"f")[$];if(!z)return this;let X=z.findIndex((J)=>J.listener===Z);if(X>=0)z.splice(X,1);return this}once($,Z){return(H(this,s0,"f")[$]||(H(this,s0,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,z)=>{if(R(this,b$,!0,"f"),$!=="error")this.once("error",z);this.once($,Z)})}async done(){R(this,b$,!0,"f"),await H(this,f4,"f")}get currentMessage(){return H(this,H$,"f")}async finalMessage(){return await this.done(),H(this,_0,"m",QZ).call(this)}async finalText(){return await this.done(),H(this,_0,"m",BX).call(this)}_emit($,...Z){if(H(this,h4,"f"))return;if($==="end")R(this,h4,!0,"f"),H(this,L6,"f").call(this);let z=H(this,s0,"f")[$];if(z)H(this,s0,"f")[$]=z.filter((X)=>!X.once),z.forEach(({listener:X})=>X(...Z));if($==="abort"){let X=Z[0];if(!H(this,b$,"f")&&!z?.length)Promise.reject(X);H(this,y4,"f").call(this,X),H(this,g4,"f").call(this,X),this._emit("end");return}if($==="error"){let X=Z[0];if(!H(this,b$,"f")&&!z?.length)Promise.reject(X);H(this,y4,"f").call(this,X),H(this,g4,"f").call(this,X),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",H(this,_0,"m",QZ).call(this))}async _fromReadableStream($,Z){let z=Z?.signal,X;if(z){if(z.aborted)this.controller.abort();X=this.controller.abort.bind(this.controller),z.addEventListener("abort",X)}try{H(this,_0,"m",UZ).call(this),this._connected(null);let J=I0.fromReadableStream($,this.controller);for await(let Q of J)H(this,_0,"m",GZ).call(this,Q);if(J.controller.signal?.aborted)throw new q0;H(this,_0,"m",WZ).call(this)}finally{if(z&&X)z.removeEventListener("abort",X)}}[(H$=new WeakMap,I1=new WeakMap,k4=new WeakMap,B6=new WeakMap,y4=new WeakMap,f4=new WeakMap,L6=new WeakMap,g4=new WeakMap,s0=new WeakMap,h4=new WeakMap,N6=new WeakMap,M6=new WeakMap,b$=new WeakMap,T6=new WeakMap,O6=new WeakMap,v4=new WeakMap,YZ=new WeakMap,_0=new WeakSet,QZ=function(){if(this.receivedMessages.length===0)throw new _("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},BX=function(){if(this.receivedMessages.length===0)throw new _("stream ended without producing a Message with role=assistant");let Z=this.receivedMessages.at(-1).content.filter((z)=>z.type==="text").map((z)=>z.text);if(Z.length===0)throw new _("stream ended without producing a content block with type=text");return Z.join(" ")},UZ=function(){if(this.ended)return;R(this,H$,void 0,"f")},GZ=function(Z){if(this.ended)return;let z=H(this,_0,"m",LX).call(this,Z);switch(this._emit("streamEvent",Z,z),Z.type){case"content_block_delta":{let X=z.content.at(-1);switch(Z.delta.type){case"text_delta":{if(X.type==="text")this._emit("text",Z.delta.text,X.text||"");break}case"citations_delta":{if(X.type==="text")this._emit("citation",Z.delta.citation,X.citations??[]);break}case"input_json_delta":{if(MX(X)&&X.input)this._emit("inputJson",Z.delta.partial_json,X.input);break}case"thinking_delta":{if(X.type==="thinking")this._emit("thinking",Z.delta.thinking,X.thinking);break}case"signature_delta":{if(X.type==="thinking")this._emit("signature",X.signature);break}default:TX(Z.delta)}break}case"message_stop":{this._addMessageParam(z),this._addMessage(zZ(z,H(this,I1,"f"),{logger:H(this,v4,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",z.content.at(-1));break}case"message_start":{R(this,H$,z,"f");break}case"content_block_start":case"message_delta":break}},WZ=function(){if(this.ended)throw new _("stream has ended, this shouldn't happen");let Z=H(this,H$,"f");if(!Z)throw new _("request ended without sending any chunks");return R(this,H$,void 0,"f"),zZ(Z,H(this,I1,"f"),{logger:H(this,v4,"f")})},LX=function(Z){let z=H(this,H$,"f");if(Z.type==="message_start"){if(z)throw new _(`Unexpected event order, got ${Z.type} before receiving "message_stop"`);return Z.message}if(!z)throw new _(`Unexpected event order, got ${Z.type} before "message_start"`);switch(Z.type){case"message_stop":return z;case"message_delta":if(z.stop_reason=Z.delta.stop_reason,z.stop_sequence=Z.delta.stop_sequence,z.usage.output_tokens=Z.usage.output_tokens,Z.usage.input_tokens!=null)z.usage.input_tokens=Z.usage.input_tokens;if(Z.usage.cache_creation_input_tokens!=null)z.usage.cache_creation_input_tokens=Z.usage.cache_creation_input_tokens;if(Z.usage.cache_read_input_tokens!=null)z.usage.cache_read_input_tokens=Z.usage.cache_read_input_tokens;if(Z.usage.server_tool_use!=null)z.usage.server_tool_use=Z.usage.server_tool_use;return z;case"content_block_start":return z.content.push({...Z.content_block}),z;case"content_block_delta":{let X=z.content.at(Z.index);switch(Z.delta.type){case"text_delta":{if(X?.type==="text")z.content[Z.index]={...X,text:(X.text||"")+Z.delta.text};break}case"citations_delta":{if(X?.type==="text")z.content[Z.index]={...X,citations:[...X.citations??[],Z.delta.citation]};break}case"input_json_delta":{if(X&&MX(X)){let J=X[NX]||"";J+=Z.delta.partial_json;let Q={...X};if(Object.defineProperty(Q,NX,{value:J,enumerable:!1,writable:!0}),J)Q.input=Q6(J);z.content[Z.index]=Q}break}case"thinking_delta":{if(X?.type==="thinking")z.content[Z.index]={...X,thinking:X.thinking+Z.delta.thinking};break}case"signature_delta":{if(X?.type==="thinking")z.content[Z.index]={...X,signature:Z.delta.signature};break}default:TX(Z.delta)}return z}case"content_block_stop":return z}},Symbol.asyncIterator)](){let $=[],Z=[],z=!1;return this.on("streamEvent",(X)=>{let J=Z.shift();if(J)J.resolve(X);else $.push(X)}),this.on("end",()=>{z=!0;for(let X of Z)X.resolve(void 0);Z.length=0}),this.on("abort",(X)=>{z=!0;for(let J of Z)J.reject(X);Z.length=0}),this.on("error",(X)=>{z=!0;for(let J of Z)J.reject(X);Z.length=0}),{next:async()=>{if(!$.length){if(z)return{value:void 0,done:!0};return new Promise((J,Q)=>Z.push({resolve:J,reject:Q})).then((J)=>J?{value:J,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new I0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}});var m4;var qZ=S(()=>{t();s();p3();K1();J0();m4=class m4 extends f{create($,Z){return this._client.post("/v1/messages/batches",{body:$,...Z})}retrieve($,Z){return this._client.get(I`/v1/messages/batches/${$}`,Z)}list($={},Z){return this._client.getAPIList("/v1/messages/batches",S0,{query:$,...Z})}delete($,Z){return this._client.delete(I`/v1/messages/batches/${$}`,Z)}cancel($,Z){return this._client.post(I`/v1/messages/batches/${$}/cancel`,Z)}async results($,Z){let z=await this.retrieve($);if(!z.results_url)throw new _(`No batch \`results_url\`; Has it finished processing? ${z.processing_status} - ${z.id}`);return this._client.get(z.results_url,{...Z,headers:T([{Accept:"application/binary"},Z?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((X,J)=>M1.fromResponse(J.response,J.controller))}}});var x$,DX,LM;var VZ=S(()=>{s();K4();OX();JZ();qZ();qZ();b3();x$=class x$ extends f{constructor(){super(...arguments);this.batches=new m4(this._client)}create($,Z){if($.model in DX)console.warn(`The model '${$.model}' is deprecated and will reach end-of-life on ${DX[$.model]}
197
- Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);if(LM.includes($.model)&&$.thinking&&$.thinking.type==="enabled")console.warn(`Using Claude with ${$.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let z=this._client._options.timeout;if(!$.stream&&z==null){let J=J6[$.model]??void 0;z=this._client.calculateNonstreamingTimeout($.max_tokens,J)}let X=X6($.tools,$.messages);return this._client.post("/v1/messages",{body:$,timeout:z??600000,...Z,headers:T([X,Z?.headers]),stream:$.stream??!1})}parse($,Z){return this.create($,Z).then((z)=>XZ(z,$,{logger:this._client.logger??console}))}stream($,Z){return u4.createMessage(this,$,Z,{logger:this._client.logger??console})}countTokens($,Z){return this._client.post("/v1/messages/count_tokens",{body:$,...Z})}};DX={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026","claude-3-5-haiku-latest":"February 19th, 2026","claude-3-5-haiku-20241022":"February 19th, 2026","claude-opus-4-0":"June 15th, 2026","claude-opus-4-20250514":"June 15th, 2026","claude-sonnet-4-0":"June 15th, 2026","claude-sonnet-4-20250514":"June 15th, 2026"},LM=["claude-mythos-preview","claude-opus-4-6"];x$.Batches=m4});var A1;var KZ=S(()=>{t();s();J0();A1=class A1 extends f{retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/models/${$}`,{...z,headers:T([{...X?.toString()!=null?{"anthropic-beta":X?.toString()}:void 0},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/models",S0,{query:X,...Z,headers:T([{...z?.toString()!=null?{"anthropic-beta":z?.toString()}:void 0},Z?.headers])})}}});var IX=S(()=>{$Z();ZZ();VZ();KZ();rz()});var c4=($)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[$]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.($)?.trim()||void 0;return};class a{constructor({baseURL:$=c4("ANTHROPIC_BASE_URL"),apiKey:Z=c4("ANTHROPIC_API_KEY")??null,authToken:z=c4("ANTHROPIC_AUTH_TOKEN")??null,...X}={}){HZ.add(this),D6.set(this,void 0);let J={apiKey:Z,authToken:z,...X,baseURL:$||"https://api.anthropic.com"};if(!J.dangerouslyAllowBrowser&&xz())throw new _(`It looks like you're running in a browser-like environment.
195
+ Wrap your summary in <summary></summary> tags.`;function qX(){let $,Z;return{promise:new Promise((X,J)=>{$=X,Z=J}),resolve:$,reject:Z}}async function XM($,Z=$.messages.at(-1),z){if(!Z||Z.role!=="assistant"||!Z.content||typeof Z.content==="string")return null;let X=Z.content.filter((Q)=>Q.type==="tool_use");if(X.length===0)return null;return{role:"user",content:await Promise.all(X.map(async(Q)=>{let Y=$.tools.find((U)=>("name"in U?U.name:U.mcp_server_name)===Q.name);if(!Y||!("run"in Y))return{type:"tool_result",tool_use_id:Q.id,content:`Error: Tool '${Q.name}' not found`,is_error:!0};try{let U=Q.input;if("parse"in Y&&Y.parse)U=Y.parse(U);let G=await Y.run(U,{toolUseBlock:Q,signal:z?.signal});return{type:"tool_result",tool_use_id:Q.id,content:G}}catch(U){return{type:"tool_result",tool_use_id:Q.id,content:U instanceof L1?U.content:`Error: ${U instanceof Error?U.message:String(U)}`,is_error:!0}}}))}}var P4,N1,j$,U0,M0,A0,n0,V$,_4,WX,c3,C4;var d3=S(()=>{d0();H6();N0();s();K4();C4=class C4{constructor($,Z,z){P4.add(this),this.client=$,N1.set(this,!1),j$.set(this,!1),U0.set(this,void 0),M0.set(this,void 0),A0.set(this,void 0),n0.set(this,void 0),V$.set(this,void 0),_4.set(this,0),R(this,U0,{params:{...Z,messages:structuredClone(Z.messages)}},"f");let J=["BetaToolRunner",...R3(Z.tools,Z.messages)].join(", ");if(R(this,M0,{...z,headers:T([{"x-stainless-helper":J},z?.headers])},"f"),R(this,V$,qX(),"f"),Z.compactionControl?.enabled)console.warn('Anthropic: The `compactionControl` parameter is deprecated and will be removed in a future version. Use server-side compaction instead by passing `edits: [{ type: "compact_20260112" }]` in the params passed to `toolRunner()`. See https://platform.claude.com/docs/en/build-with-claude/compaction')}async*[(N1=new WeakMap,j$=new WeakMap,U0=new WeakMap,M0=new WeakMap,A0=new WeakMap,n0=new WeakMap,V$=new WeakMap,_4=new WeakMap,P4=new WeakSet,WX=async function(){let Z=H(this,U0,"f").params.compactionControl;if(!Z||!Z.enabled)return!1;let z=0;if(H(this,A0,"f")!==void 0)try{let G=await H(this,A0,"f");z=G.usage.input_tokens+(G.usage.cache_creation_input_tokens??0)+(G.usage.cache_read_input_tokens??0)+G.usage.output_tokens}catch{return!1}let X=Z.contextTokenThreshold??UX;if(z<X)return!1;let J=Z.model??H(this,U0,"f").params.model,Q=Z.summaryPrompt??GX,Y=H(this,U0,"f").params.messages;if(Y[Y.length-1].role==="assistant"){let G=Y[Y.length-1];if(Array.isArray(G.content)){let W=G.content.filter((q)=>q.type!=="tool_use");if(W.length===0)Y.pop();else G.content=W}}let U=await this.client.beta.messages.create({model:J,messages:[...Y,{role:"user",content:[{type:"text",text:Q}]}],max_tokens:H(this,U0,"f").params.max_tokens},{signal:H(this,M0,"f").signal,headers:T([H(this,M0,"f").headers,{"x-stainless-helper":"compaction"}])});if(U.content[0]?.type!=="text")throw new _("Expected text response for compaction");return H(this,U0,"f").params.messages=[{role:"user",content:U.content}],!0},Symbol.asyncIterator)](){var $;if(H(this,N1,"f"))throw new _("Cannot iterate over a consumed stream");R(this,N1,!0,"f"),R(this,j$,!0,"f"),R(this,n0,void 0,"f");try{while(!0){let Z;try{if(H(this,U0,"f").params.max_iterations&&H(this,_4,"f")>=H(this,U0,"f").params.max_iterations)break;R(this,j$,!1,"f"),R(this,n0,void 0,"f"),R(this,_4,($=H(this,_4,"f"),$++,$),"f"),R(this,A0,void 0,"f");let{max_iterations:z,compactionControl:X,...J}=H(this,U0,"f").params;if(J.stream)Z=this.client.beta.messages.stream({...J},H(this,M0,"f")),R(this,A0,Z.finalMessage(),"f"),H(this,A0,"f").catch(()=>{}),yield Z;else R(this,A0,this.client.beta.messages.create({...J,stream:!1},H(this,M0,"f")),"f"),yield H(this,A0,"f");if(!await H(this,P4,"m",WX).call(this)){if(!H(this,j$,"f")){let{role:U,content:G}=await H(this,A0,"f");H(this,U0,"f").params.messages.push({role:U,content:G})}let Y=await H(this,P4,"m",c3).call(this,H(this,U0,"f").params.messages.at(-1));if(Y)H(this,U0,"f").params.messages.push(Y);else if(!H(this,j$,"f"))break}}finally{if(Z)Z.abort()}}if(!H(this,A0,"f"))throw new _("ToolRunner concluded without a message from the server");H(this,V$,"f").resolve(await H(this,A0,"f"))}catch(Z){throw R(this,N1,!1,"f"),H(this,V$,"f").promise.catch(()=>{}),H(this,V$,"f").reject(Z),R(this,V$,qX(),"f"),Z}}setMessagesParams($){if(typeof $==="function")H(this,U0,"f").params=$(H(this,U0,"f").params);else H(this,U0,"f").params=$;R(this,j$,!0,"f"),R(this,n0,void 0,"f")}setRequestOptions($){if(typeof $==="function")R(this,M0,$(H(this,M0,"f")),"f");else R(this,M0,{...H(this,M0,"f"),...$},"f")}async generateToolResponse($=H(this,M0,"f").signal){let Z=await H(this,A0,"f")??this.params.messages.at(-1);if(!Z)return null;return H(this,P4,"m",c3).call(this,Z,$)}done(){return H(this,V$,"f").promise}async runUntilDone(){if(!H(this,N1,"f"))for await(let $ of this);return this.done()}get params(){return H(this,U0,"f").params}pushMessages(...$){this.setMessagesParams((Z)=>({...Z,messages:[...Z.messages,...$]}))}then($,Z){return this.runUntilDone().then($,Z)}};c3=async function(Z,z=H(this,M0,"f").signal){if(H(this,n0,"f")!==void 0)return H(this,n0,"f");return R(this,n0,XM(H(this,U0,"f").params,Z,{...H(this,M0,"f"),signal:z}),"f"),H(this,n0,"f")}});var M1;var p3=S(()=>{N0();V3();M1=class M1{constructor($,Z){this.iterator=$,this.controller=Z}async*decoder(){let $=new G$;for await(let Z of this.iterator)for(let z of $.decode(Z))yield JSON.parse(z);for(let Z of $.flush())yield JSON.parse(Z)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse($,Z){if(!$.body){if(Z.abort(),typeof globalThis.navigator<"u"&&globalThis.navigator.product==="ReactNative")throw new _("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api");throw new _("Attempted to iterate over a response with no body")}return new M1(z4($.body),Z)}}});var E4;var l3=S(()=>{t();s();p3();K1();J0();E4=class E4 extends f{create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/messages/batches?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/messages/batches/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/messages/batches?beta=true",S0,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/messages/batches/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString()},z?.headers])})}cancel($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/messages/batches/${$}/cancel?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString()},z?.headers])})}async results($,Z={},z){let X=await this.retrieve($);if(!X.results_url)throw new _(`No batch \`results_url\`; Has it finished processing? ${X.processing_status} - ${X.id}`);let{betas:J}=Z??{};return this._client.get(X.results_url,{...z,headers:T([{"anthropic-beta":[...J??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary"},z?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((Q,Y)=>M1.fromResponse(Y.response,Y.controller))}}});function KX($){if(!$.output_format)return $;if($.output_config?.format)throw new _("Both output_format and output_config.format were provided. Please use only output_config.format (output_format is deprecated).");let{output_format:Z,...z}=$;return{...z,output_config:{...$.output_config,format:Z}}}var VX,QM,K$;var i3=S(()=>{K1();b3();s();K4();y3();YX();d3();H6();l3();l3();d3();H6();VX={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026"},QM=["claude-mythos-preview","claude-opus-4-6"];K$=class K$ extends f{constructor(){super(...arguments);this.batches=new E4(this._client)}create($,Z){let z=KX($),{betas:X,...J}=z;if(J.model in VX)console.warn(`The model '${J.model}' is deprecated and will reach end-of-life on ${VX[J.model]}
196
+ Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);if(QM.includes(J.model)&&J.thinking&&J.thinking.type==="enabled")console.warn(`Using Claude with ${J.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let Q=this._client._options.timeout;if(!J.stream&&Q==null){let U=J6[J.model]??void 0;Q=this._client.calculateNonstreamingTimeout(J.max_tokens,U)}let Y=X6(J.tools,J.messages);return this._client.post("/v1/messages?beta=true",{body:J,timeout:Q??600000,...Z,headers:T([{...X?.toString()!=null?{"anthropic-beta":X?.toString()}:void 0},Y,Z?.headers]),stream:z.stream??!1})}parse($,Z){return Z={...Z,headers:T([{"anthropic-beta":[...$.betas??[],"structured-outputs-2025-12-15"].toString()},Z?.headers])},this.create($,Z).then((z)=>k3(z,$,{logger:this._client.logger??console}))}stream($,Z){return w4.createMessage(this,$,Z)}countTokens($,Z){let z=KX($),{betas:X,...J}=z;return this._client.post("/v1/messages/count_tokens?beta=true",{body:J,...Z,headers:T([{"anthropic-beta":[...X??[],"token-counting-2024-11-01"].toString()},Z?.headers])})}toolRunner($,Z){return new C4(this._client,$,Z)}};K$.Batches=E4;K$.BetaToolRunner=C4;K$.ToolError=L1});var j4;var n3=S(()=>{t();s();J0();j4=class j4 extends f{list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/sessions/${$}/events?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}send($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/sessions/${$}/events?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}stream($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/sessions/${$}/events/stream?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers]),stream:!0})}}});var S4;var s3=S(()=>{t();s();J0();S4=class S4 extends f{retrieve($,Z,z){let{session_id:X,betas:J}=Z;return this._client.get(I`/v1/sessions/${X}/resources/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{session_id:X,betas:J,...Q}=Z;return this._client.post(I`/v1/sessions/${X}/resources/${$}?beta=true`,{body:Q,...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/sessions/${$}/resources?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}delete($,Z,z){let{session_id:X,betas:J}=Z;return this._client.delete(I`/v1/sessions/${X}/resources/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}add($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/sessions/${$}/resources?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}}});var S$;var r3=S(()=>{n3();n3();s3();s3();t();s();J0();S$=class S$ extends f{constructor(){super(...arguments);this.events=new j4(this._client),this.resources=new S4(this._client)}create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/sessions?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/sessions/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/sessions/${$}?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/sessions?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/sessions/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}archive($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/sessions/${$}/archive?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}};S$.Events=j4;S$.Resources=S4});var b4;var a3=S(()=>{t();s();q1();J0();b4=class b4 extends f{create($,Z={},z){let{betas:X,...J}=Z??{};return this._client.post(I`/v1/skills/${$}/versions?beta=true`,W1({body:J,...z,headers:T([{"anthropic-beta":[...X??[],"skills-2025-10-02"].toString()},z?.headers])},this._client))}retrieve($,Z,z){let{skill_id:X,betas:J}=Z;return this._client.get(I`/v1/skills/${X}/versions/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"skills-2025-10-02"].toString()},z?.headers])})}list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/skills/${$}/versions?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"skills-2025-10-02"].toString()},z?.headers])})}delete($,Z,z){let{skill_id:X,betas:J}=Z;return this._client.delete(I`/v1/skills/${X}/versions/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"skills-2025-10-02"].toString()},z?.headers])})}}});var T1;var o3=S(()=>{a3();a3();t();s();q1();J0();T1=class T1 extends f{constructor(){super(...arguments);this.versions=new b4(this._client)}create($={},Z){let{betas:z,...X}=$??{};return this._client.post("/v1/skills?beta=true",W1({body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"skills-2025-10-02"].toString()},Z?.headers])},this._client,!1))}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/skills/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"skills-2025-10-02"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/skills?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"skills-2025-10-02"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/skills/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"skills-2025-10-02"].toString()},z?.headers])})}};T1.Versions=b4});var x4;var t3=S(()=>{t();s();J0();x4=class x4 extends f{create($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/vaults/${$}/credentials?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}retrieve($,Z,z){let{vault_id:X,betas:J}=Z;return this._client.get(I`/v1/vaults/${X}/credentials/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{vault_id:X,betas:J,...Q}=Z;return this._client.post(I`/v1/vaults/${X}/credentials/${$}?beta=true`,{body:Q,...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($,Z={},z){let{betas:X,...J}=Z??{};return this._client.getAPIList(I`/v1/vaults/${$}/credentials?beta=true`,i,{query:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}delete($,Z,z){let{vault_id:X,betas:J}=Z;return this._client.delete(I`/v1/vaults/${X}/credentials/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}archive($,Z,z){let{vault_id:X,betas:J}=Z;return this._client.post(I`/v1/vaults/${X}/credentials/${$}/archive?beta=true`,{...z,headers:T([{"anthropic-beta":[...J??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}}});var O1;var e3=S(()=>{t3();t3();t();s();J0();O1=class O1 extends f{constructor(){super(...arguments);this.credentials=new x4(this._client)}create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/vaults?beta=true",{body:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/vaults/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}update($,Z,z){let{betas:X,...J}=Z;return this._client.post(I`/v1/vaults/${$}?beta=true`,{body:J,...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/vaults?beta=true",i,{query:X,...Z,headers:T([{"anthropic-beta":[...z??[],"managed-agents-2026-04-01"].toString()},Z?.headers])})}delete($,Z={},z){let{betas:X}=Z??{};return this._client.delete(I`/v1/vaults/${$}?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}archive($,Z={},z){let{betas:X}=Z??{};return this._client.post(I`/v1/vaults/${$}/archive?beta=true`,{...z,headers:T([{"anthropic-beta":[...X??[],"managed-agents-2026-04-01"].toString()},z?.headers])})}};O1.Credentials=x4});var B0;var $Z=S(()=>{A3();A3();F3();F3();w3();w3();P3();P3();C3();C3();S3();S3();i3();i3();r3();r3();o3();o3();e3();e3();B0=class B0 extends f{constructor(){super(...arguments);this.models=new B4(this._client),this.messages=new K$(this._client),this.agents=new V1(this._client),this.environments=new q4(this._client),this.sessions=new S$(this._client),this.vaults=new O1(this._client),this.memoryStores=new C$(this._client),this.files=new H4(this._client),this.skills=new T1(this._client),this.userProfiles=new L4(this._client)}};B0.Models=B4;B0.Messages=K$;B0.Agents=V1;B0.Environments=q4;B0.Sessions=S$;B0.Vaults=O1;B0.MemoryStores=C$;B0.Files=H4;B0.Skills=T1;B0.UserProfiles=L4});var D1;var ZZ=S(()=>{s();D1=class D1 extends f{create($,Z){let{betas:z,...X}=$;return this._client.post("/v1/complete",{body:X,timeout:this._client._options.timeout??600000,...Z,headers:T([{...z?.toString()!=null?{"anthropic-beta":z?.toString()}:void 0},Z?.headers]),stream:$.stream??!1})}}});function HX($){return $?.output_config?.format}function zZ($,Z,z){let X=HX(Z);if(!Z||!("parse"in(X??{})))return{...$,content:$.content.map((J)=>{if(J.type==="text")return Object.defineProperty({...J},"parsed_output",{value:null,enumerable:!1});return J}),parsed_output:null};return XZ($,Z,z)}function XZ($,Z,z){let X=null,J=$.content.map((Q)=>{if(Q.type==="text"){let Y=BM(Z,Q.text);if(X===null)X=Y;return Object.defineProperty({...Q},"parsed_output",{value:Y,enumerable:!1})}return Q});return{...$,content:J,parsed_output:X}}function BM($,Z){let z=HX($);if(z?.type!=="json_schema")return null;try{if("parse"in z)return z.parse(Z);return JSON.parse(Z)}catch(X){throw new _(`Failed to parse structured output: ${X}`)}}var JZ=S(()=>{N0()});function MX($){return $.type==="tool_use"||$.type==="server_tool_use"}function TX($){}var _0,H$,I1,k4,B6,y4,f4,L6,g4,s0,h4,N6,M6,b$,T6,O6,v4,QZ,BX,YZ,UZ,GZ,WZ,LX,NX="__json_buf",u4;var OX=S(()=>{d0();K1();g3();f3();JZ();u4=class u4{constructor($,Z){_0.add(this),this.messages=[],this.receivedMessages=[],H$.set(this,void 0),I1.set(this,null),this.controller=new AbortController,k4.set(this,void 0),B6.set(this,()=>{}),y4.set(this,()=>{}),f4.set(this,void 0),L6.set(this,()=>{}),g4.set(this,()=>{}),s0.set(this,{}),h4.set(this,!1),N6.set(this,!1),M6.set(this,!1),b$.set(this,!1),T6.set(this,void 0),O6.set(this,void 0),v4.set(this,void 0),YZ.set(this,(z)=>{if(R(this,N6,!0,"f"),p0(z))z=new q0;if(z instanceof q0)return R(this,M6,!0,"f"),this._emit("abort",z);if(z instanceof _)return this._emit("error",z);if(z instanceof Error){let X=new _(z.message);return X.cause=z,this._emit("error",X)}return this._emit("error",new _(String(z)))}),R(this,k4,new Promise((z,X)=>{R(this,B6,z,"f"),R(this,y4,X,"f")}),"f"),R(this,f4,new Promise((z,X)=>{R(this,L6,z,"f"),R(this,g4,X,"f")}),"f"),H(this,k4,"f").catch(()=>{}),H(this,f4,"f").catch(()=>{}),R(this,I1,$,"f"),R(this,v4,Z?.logger??console,"f")}get response(){return H(this,T6,"f")}get request_id(){return H(this,O6,"f")}async withResponse(){R(this,b$,!0,"f");let $=await H(this,k4,"f");if(!$)throw Error("Could not resolve a `Response` object");return{data:this,response:$,request_id:$.headers.get("request-id")}}static fromReadableStream($){let Z=new u4(null);return Z._run(()=>Z._fromReadableStream($)),Z}static createMessage($,Z,z,{logger:X}={}){let J=new u4(Z,{logger:X});for(let Q of Z.messages)J._addMessageParam(Q);return R(J,I1,{...Z,stream:!0},"f"),J._run(()=>J._createMessage($,{...Z,stream:!0},{...z,headers:{...z?.headers,"X-Stainless-Helper-Method":"stream"}})),J}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},H(this,YZ,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,Z=!0){if(this.receivedMessages.push($),Z)this._emit("message",$)}async _createMessage($,Z,z){let X=z?.signal,J;if(X){if(X.aborted)this.controller.abort();J=this.controller.abort.bind(this.controller),X.addEventListener("abort",J)}try{H(this,_0,"m",UZ).call(this);let{response:Q,data:Y}=await $.create({...Z,stream:!0},{...z,signal:this.controller.signal}).withResponse();this._connected(Q);for await(let U of Y)H(this,_0,"m",GZ).call(this,U);if(Y.controller.signal?.aborted)throw new q0;H(this,_0,"m",WZ).call(this)}finally{if(X&&J)X.removeEventListener("abort",J)}}_connected($){if(this.ended)return;R(this,T6,$,"f"),R(this,O6,$?.headers.get("request-id"),"f"),H(this,B6,"f").call(this,$),this._emit("connect")}get ended(){return H(this,h4,"f")}get errored(){return H(this,N6,"f")}get aborted(){return H(this,M6,"f")}abort(){this.controller.abort()}on($,Z){return(H(this,s0,"f")[$]||(H(this,s0,"f")[$]=[])).push({listener:Z}),this}off($,Z){let z=H(this,s0,"f")[$];if(!z)return this;let X=z.findIndex((J)=>J.listener===Z);if(X>=0)z.splice(X,1);return this}once($,Z){return(H(this,s0,"f")[$]||(H(this,s0,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,z)=>{if(R(this,b$,!0,"f"),$!=="error")this.once("error",z);this.once($,Z)})}async done(){R(this,b$,!0,"f"),await H(this,f4,"f")}get currentMessage(){return H(this,H$,"f")}async finalMessage(){return await this.done(),H(this,_0,"m",QZ).call(this)}async finalText(){return await this.done(),H(this,_0,"m",BX).call(this)}_emit($,...Z){if(H(this,h4,"f"))return;if($==="end")R(this,h4,!0,"f"),H(this,L6,"f").call(this);let z=H(this,s0,"f")[$];if(z)H(this,s0,"f")[$]=z.filter((X)=>!X.once),z.forEach(({listener:X})=>X(...Z));if($==="abort"){let X=Z[0];if(!H(this,b$,"f")&&!z?.length)Promise.reject(X);H(this,y4,"f").call(this,X),H(this,g4,"f").call(this,X),this._emit("end");return}if($==="error"){let X=Z[0];if(!H(this,b$,"f")&&!z?.length)Promise.reject(X);H(this,y4,"f").call(this,X),H(this,g4,"f").call(this,X),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",H(this,_0,"m",QZ).call(this))}async _fromReadableStream($,Z){let z=Z?.signal,X;if(z){if(z.aborted)this.controller.abort();X=this.controller.abort.bind(this.controller),z.addEventListener("abort",X)}try{H(this,_0,"m",UZ).call(this),this._connected(null);let J=I0.fromReadableStream($,this.controller);for await(let Q of J)H(this,_0,"m",GZ).call(this,Q);if(J.controller.signal?.aborted)throw new q0;H(this,_0,"m",WZ).call(this)}finally{if(z&&X)z.removeEventListener("abort",X)}}[(H$=new WeakMap,I1=new WeakMap,k4=new WeakMap,B6=new WeakMap,y4=new WeakMap,f4=new WeakMap,L6=new WeakMap,g4=new WeakMap,s0=new WeakMap,h4=new WeakMap,N6=new WeakMap,M6=new WeakMap,b$=new WeakMap,T6=new WeakMap,O6=new WeakMap,v4=new WeakMap,YZ=new WeakMap,_0=new WeakSet,QZ=function(){if(this.receivedMessages.length===0)throw new _("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},BX=function(){if(this.receivedMessages.length===0)throw new _("stream ended without producing a Message with role=assistant");let Z=this.receivedMessages.at(-1).content.filter((z)=>z.type==="text").map((z)=>z.text);if(Z.length===0)throw new _("stream ended without producing a content block with type=text");return Z.join(" ")},UZ=function(){if(this.ended)return;R(this,H$,void 0,"f")},GZ=function(Z){if(this.ended)return;let z=H(this,_0,"m",LX).call(this,Z);switch(this._emit("streamEvent",Z,z),Z.type){case"content_block_delta":{let X=z.content.at(-1);switch(Z.delta.type){case"text_delta":{if(X.type==="text")this._emit("text",Z.delta.text,X.text||"");break}case"citations_delta":{if(X.type==="text")this._emit("citation",Z.delta.citation,X.citations??[]);break}case"input_json_delta":{if(MX(X)&&X.input)this._emit("inputJson",Z.delta.partial_json,X.input);break}case"thinking_delta":{if(X.type==="thinking")this._emit("thinking",Z.delta.thinking,X.thinking);break}case"signature_delta":{if(X.type==="thinking")this._emit("signature",X.signature);break}default:TX(Z.delta)}break}case"message_stop":{this._addMessageParam(z),this._addMessage(zZ(z,H(this,I1,"f"),{logger:H(this,v4,"f")}),!0);break}case"content_block_stop":{this._emit("contentBlock",z.content.at(-1));break}case"message_start":{R(this,H$,z,"f");break}case"content_block_start":case"message_delta":break}},WZ=function(){if(this.ended)throw new _("stream has ended, this shouldn't happen");let Z=H(this,H$,"f");if(!Z)throw new _("request ended without sending any chunks");return R(this,H$,void 0,"f"),zZ(Z,H(this,I1,"f"),{logger:H(this,v4,"f")})},LX=function(Z){let z=H(this,H$,"f");if(Z.type==="message_start"){if(z)throw new _(`Unexpected event order, got ${Z.type} before receiving "message_stop"`);return Z.message}if(!z)throw new _(`Unexpected event order, got ${Z.type} before "message_start"`);switch(Z.type){case"message_stop":return z;case"message_delta":if(z.stop_reason=Z.delta.stop_reason,z.stop_sequence=Z.delta.stop_sequence,z.usage.output_tokens=Z.usage.output_tokens,Z.usage.input_tokens!=null)z.usage.input_tokens=Z.usage.input_tokens;if(Z.usage.cache_creation_input_tokens!=null)z.usage.cache_creation_input_tokens=Z.usage.cache_creation_input_tokens;if(Z.usage.cache_read_input_tokens!=null)z.usage.cache_read_input_tokens=Z.usage.cache_read_input_tokens;if(Z.usage.server_tool_use!=null)z.usage.server_tool_use=Z.usage.server_tool_use;return z;case"content_block_start":return z.content.push({...Z.content_block}),z;case"content_block_delta":{let X=z.content.at(Z.index);switch(Z.delta.type){case"text_delta":{if(X?.type==="text")z.content[Z.index]={...X,text:(X.text||"")+Z.delta.text};break}case"citations_delta":{if(X?.type==="text")z.content[Z.index]={...X,citations:[...X.citations??[],Z.delta.citation]};break}case"input_json_delta":{if(X&&MX(X)){let J=X[NX]||"";J+=Z.delta.partial_json;let Q={...X};if(Object.defineProperty(Q,NX,{value:J,enumerable:!1,writable:!0}),J)Q.input=Q6(J);z.content[Z.index]=Q}break}case"thinking_delta":{if(X?.type==="thinking")z.content[Z.index]={...X,thinking:X.thinking+Z.delta.thinking};break}case"signature_delta":{if(X?.type==="thinking")z.content[Z.index]={...X,signature:Z.delta.signature};break}default:TX(Z.delta)}return z}case"content_block_stop":return z}},Symbol.asyncIterator)](){let $=[],Z=[],z=!1;return this.on("streamEvent",(X)=>{let J=Z.shift();if(J)J.resolve(X);else $.push(X)}),this.on("end",()=>{z=!0;for(let X of Z)X.resolve(void 0);Z.length=0}),this.on("abort",(X)=>{z=!0;for(let J of Z)J.reject(X);Z.length=0}),this.on("error",(X)=>{z=!0;for(let J of Z)J.reject(X);Z.length=0}),{next:async()=>{if(!$.length){if(z)return{value:void 0,done:!0};return new Promise((J,Q)=>Z.push({resolve:J,reject:Q})).then((J)=>J?{value:J,done:!1}:{value:void 0,done:!0})}return{value:$.shift(),done:!1}},return:async()=>{return this.abort(),{value:void 0,done:!0}}}}toReadableStream(){return new I0(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}});var m4;var qZ=S(()=>{t();s();p3();K1();J0();m4=class m4 extends f{create($,Z){return this._client.post("/v1/messages/batches",{body:$,...Z})}retrieve($,Z){return this._client.get(I`/v1/messages/batches/${$}`,Z)}list($={},Z){return this._client.getAPIList("/v1/messages/batches",S0,{query:$,...Z})}delete($,Z){return this._client.delete(I`/v1/messages/batches/${$}`,Z)}cancel($,Z){return this._client.post(I`/v1/messages/batches/${$}/cancel`,Z)}async results($,Z){let z=await this.retrieve($);if(!z.results_url)throw new _(`No batch \`results_url\`; Has it finished processing? ${z.processing_status} - ${z.id}`);return this._client.get(z.results_url,{...Z,headers:T([{Accept:"application/binary"},Z?.headers]),stream:!0,__binaryResponse:!0})._thenUnwrap((X,J)=>M1.fromResponse(J.response,J.controller))}}});var x$,DX,NM;var VZ=S(()=>{s();K4();OX();JZ();qZ();qZ();b3();x$=class x$ extends f{constructor(){super(...arguments);this.batches=new m4(this._client)}create($,Z){if($.model in DX)console.warn(`The model '${$.model}' is deprecated and will reach end-of-life on ${DX[$.model]}
197
+ Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);if(NM.includes($.model)&&$.thinking&&$.thinking.type==="enabled")console.warn(`Using Claude with ${$.model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking`);let z=this._client._options.timeout;if(!$.stream&&z==null){let J=J6[$.model]??void 0;z=this._client.calculateNonstreamingTimeout($.max_tokens,J)}let X=X6($.tools,$.messages);return this._client.post("/v1/messages",{body:$,timeout:z??600000,...Z,headers:T([X,Z?.headers]),stream:$.stream??!1})}parse($,Z){return this.create($,Z).then((z)=>XZ(z,$,{logger:this._client.logger??console}))}stream($,Z){return u4.createMessage(this,$,Z,{logger:this._client.logger??console})}countTokens($,Z){return this._client.post("/v1/messages/count_tokens",{body:$,...Z})}};DX={"claude-1.3":"November 6th, 2024","claude-1.3-100k":"November 6th, 2024","claude-instant-1.1":"November 6th, 2024","claude-instant-1.1-100k":"November 6th, 2024","claude-instant-1.2":"November 6th, 2024","claude-3-sonnet-20240229":"July 21st, 2025","claude-3-opus-20240229":"January 5th, 2026","claude-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025","claude-3-7-sonnet-latest":"February 19th, 2026","claude-3-7-sonnet-20250219":"February 19th, 2026","claude-3-5-haiku-latest":"February 19th, 2026","claude-3-5-haiku-20241022":"February 19th, 2026","claude-opus-4-0":"June 15th, 2026","claude-opus-4-20250514":"June 15th, 2026","claude-sonnet-4-0":"June 15th, 2026","claude-sonnet-4-20250514":"June 15th, 2026"},NM=["claude-mythos-preview","claude-opus-4-6"];x$.Batches=m4});var A1;var KZ=S(()=>{t();s();J0();A1=class A1 extends f{retrieve($,Z={},z){let{betas:X}=Z??{};return this._client.get(I`/v1/models/${$}`,{...z,headers:T([{...X?.toString()!=null?{"anthropic-beta":X?.toString()}:void 0},z?.headers])})}list($={},Z){let{betas:z,...X}=$??{};return this._client.getAPIList("/v1/models",S0,{query:X,...Z,headers:T([{...z?.toString()!=null?{"anthropic-beta":z?.toString()}:void 0},Z?.headers])})}}});var IX=S(()=>{$Z();ZZ();VZ();KZ();rz()});var c4=($)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[$]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.($)?.trim()||void 0;return};class a{constructor({baseURL:$=c4("ANTHROPIC_BASE_URL"),apiKey:Z=c4("ANTHROPIC_API_KEY")??null,authToken:z=c4("ANTHROPIC_AUTH_TOKEN")??null,...X}={}){HZ.add(this),D6.set(this,void 0);let J={apiKey:Z,authToken:z,...X,baseURL:$||"https://api.anthropic.com"};if(!J.dangerouslyAllowBrowser&&xz())throw new _(`It looks like you're running in a browser-like environment.
198
198
 
199
199
  This is disabled by default, as it risks exposing your secret API credentials to attackers.
200
200
  If you understand the risks and have appropriate mitigations in place,
201
201
  you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
202
202
 
203
203
  new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
204
- `);this.baseURL=J.baseURL,this.timeout=J.timeout??BZ.DEFAULT_TIMEOUT,this.logger=J.logger??console;let Q="warn";this.logLevel=Q,this.logLevel=K3(J.logLevel,"ClientOptions.logLevel",this)??K3(c4("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??Q,this.fetchOptions=J.fetchOptions,this.maxRetries=J.maxRetries??2,this.fetch=J.fetch??yz(),R(this,D6,gz,"f"),this._options=J,this.apiKey=typeof Z==="string"?Z:null,this.authToken=z}withOptions($){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...$})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:$,nulls:Z}){if($.get("x-api-key")||$.get("authorization"))return;if(this.apiKey&&$.get("x-api-key"))return;if(Z.has("x-api-key"))return;if(this.authToken&&$.get("authorization"))return;if(Z.has("authorization"))return;throw Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders($){return T([await this.apiKeyAuth($),await this.bearerAuth($)])}async apiKeyAuth($){if(this.apiKey==null)return;return T([{"X-Api-Key":this.apiKey}])}async bearerAuth($){if(this.authToken==null)return;return T([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery($){return hz($)}getUserAgent(){return`${this.constructor.name}/JS ${U$}`}defaultIdempotencyKey(){return`stainless-node-retry-${J3()}`}makeStatusError($,Z,z,X){return X0.generate($,Z,z,X)}buildURL($,Z,z){let X=!H(this,HZ,"m",AX).call(this)&&z||this.baseURL,J=Pz($)?new URL($):new URL(X+(X.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),Q=this.defaultQuery(),Y=Object.fromEntries(J.searchParams);if(!U3(Q)||!U3(Y))Z={...Y,...Q,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))J.search=this.stringifyQuery(Z);return J.toString()}_calculateNonstreamingTimeout($){if(3600*$/128000>600)throw new _("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 600000}async prepareOptions($){}async prepareRequest($,{url:Z,options:z}){}get($,Z){return this.methodRequest("get",$,Z)}post($,Z){return this.methodRequest("post",$,Z)}patch($,Z){return this.methodRequest("patch",$,Z)}put($,Z){return this.methodRequest("put",$,Z)}delete($,Z){return this.methodRequest("delete",$,Z)}methodRequest($,Z,z){return this.request(Promise.resolve(z).then((X)=>{return{method:$,path:Z,...X}}))}request($,Z=null){return new W$(this,this.makeRequest($,Z,void 0))}async makeRequest($,Z,z){let X=await $,J=X.maxRetries??this.maxRetries;if(Z==null)Z=J;await this.prepareOptions(X);let{req:Q,url:Y,timeout:U}=await this.buildRequest(X,{retryCount:J-Z});await this.prepareRequest(Q,{url:Y,options:X});let G="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),W=z===void 0?"":`, retryOf: ${z}`,q=Date.now();if(G0(this).debug(`[${G}] sending request`,l0({retryOfRequestLogID:z,method:X.method,url:Y,options:X,headers:Q.headers})),X.signal?.aborted)throw new q0;let V=new AbortController,K=await this.fetchWithTimeout(Y,Q,U,V).catch(Z4),B=Date.now();if(K instanceof globalThis.Error){let M=`retrying, ${Z} attempts remaining`;if(X.signal?.aborted)throw new q0;let F=p0(K)||/timed? ?out/i.test(String(K)+("cause"in K?String(K.cause):""));if(Z)return G0(this).info(`[${G}] connection ${F?"timed out":"failed"} - ${M}`),G0(this).debug(`[${G}] connection ${F?"timed out":"failed"} (${M})`,l0({retryOfRequestLogID:z,url:Y,durationMs:B-q,message:K.message})),this.retryRequest(X,Z,z??G);if(G0(this).info(`[${G}] connection ${F?"timed out":"failed"} - error; no more retries left`),G0(this).debug(`[${G}] connection ${F?"timed out":"failed"} (error; no more retries left)`,l0({retryOfRequestLogID:z,url:Y,durationMs:B-q,message:K.message})),F)throw new $1;throw new Y$({cause:K})}let O=[...K.headers.entries()].filter(([M])=>M==="request-id").map(([M,F])=>", "+M+": "+JSON.stringify(F)).join(""),L=`[${G}${W}${O}] ${Q.method} ${Y} ${K.ok?"succeeded":"failed"} with status ${K.status} in ${B-q}ms`;if(!K.ok){let M=await this.shouldRetry(K);if(Z&&M){let y=`retrying, ${Z} attempts remaining`;return await fz(K.body),G0(this).info(`${L} - ${y}`),G0(this).debug(`[${G}] response error (${y})`,l0({retryOfRequestLogID:z,url:K.url,status:K.status,headers:K.headers,durationMs:B-q})),this.retryRequest(X,Z,z??G,K.headers)}let F=M?"error; no more retries left":"error; not retryable";G0(this).info(`${L} - ${F}`);let j=await K.text().catch((y)=>Z4(y).message),b=s2(j),x=b?void 0:j;throw G0(this).debug(`[${G}] response error (${F})`,l0({retryOfRequestLogID:z,url:K.url,status:K.status,headers:K.headers,message:x,durationMs:Date.now()-q})),this.makeStatusError(K.status,b,x,K.headers)}return G0(this).info(L),G0(this).debug(`[${G}] response start`,l0({retryOfRequestLogID:z,url:K.url,status:K.status,headers:K.headers,durationMs:B-q})),{response:K,options:X,controller:V,requestLogID:G,retryOfRequestLogID:z,startTime:q}}getAPIList($,Z,z){return this.requestAPIList(Z,z&&"then"in z?z.then((X)=>({method:"get",path:$,...X})):{method:"get",path:$,...z})}requestAPIList($,Z){let z=this.makeRequest(Z,null,void 0);return new U4(this,z,$)}async fetchWithTimeout($,Z,z,X){let{signal:J,method:Q,...Y}=Z||{},U=this._makeAbort(X);if(J)J.addEventListener("abort",U,{once:!0});let G=setTimeout(U,z),W=globalThis.ReadableStream&&Y.body instanceof globalThis.ReadableStream||typeof Y.body==="object"&&Y.body!==null&&Symbol.asyncIterator in Y.body,q={signal:X.signal,...W?{duplex:"half"}:{},method:"GET",...Y};if(Q)q.method=Q.toUpperCase();try{return await this.fetch.call(void 0,$,q)}finally{clearTimeout(G)}}async shouldRetry($){let Z=$.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if($.status===408)return!0;if($.status===409)return!0;if($.status===429)return!0;if($.status>=500)return!0;return!1}async retryRequest($,Z,z,X){let J,Q=X?.get("retry-after-ms");if(Q){let U=parseFloat(Q);if(!Number.isNaN(U))J=U}let Y=X?.get("retry-after");if(Y&&!J){let U=parseFloat(Y);if(!Number.isNaN(U))J=U*1000;else J=Date.parse(Y)-Date.now()}if(J===void 0){let U=$.maxRetries??this.maxRetries;J=this.calculateDefaultRetryTimeoutMillis(Z,U)}return await Ez(J),this.makeRequest($,Z-1,z)}calculateDefaultRetryTimeoutMillis($,Z){let J=Z-$,Q=Math.min(0.5*Math.pow(2,J),8),Y=1-Math.random()*0.25;return Q*Y*1000}calculateNonstreamingTimeout($,Z){if(3600000*$/128000>600000||Z!=null&&$>Z)throw new _("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return 600000}async buildRequest($,{retryCount:Z=0}={}){let z={...$},{method:X,path:J,query:Q,defaultBaseURL:Y}=z,U=this.buildURL(J,Q,Y);if("timeout"in z)Cz("timeout",z.timeout);z.timeout=z.timeout??this.timeout;let{bodyHeaders:G,body:W}=this.buildBody({options:z}),q=await this.buildHeaders({options:$,method:X,bodyHeaders:G,retryCount:Z});return{req:{method:X,headers:q,...z.signal&&{signal:z.signal},...globalThis.ReadableStream&&W instanceof globalThis.ReadableStream&&{duplex:"half"},...W&&{body:W},...this.fetchOptions??{},...z.fetchOptions??{}},url:U,timeout:z.timeout}}async buildHeaders({options:$,method:Z,bodyHeaders:z,retryCount:X}){let J={};if(this.idempotencyHeader&&Z!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();J[this.idempotencyHeader]=$.idempotencyKey}let Q=T([J,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(X),...$.timeout?{"X-Stainless-Timeout":String(Math.trunc($.timeout/1000))}:{},...kz(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders($),this._options.defaultHeaders,z,$.headers]);return this.validateHeaders(Q),Q.values}_makeAbort($){return()=>$.abort()}buildBody({options:{body:$,headers:Z}}){if(!$)return{bodyHeaders:void 0,body:void 0};let z=T([Z]);if(ArrayBuffer.isView($)||$ instanceof ArrayBuffer||$ instanceof DataView||typeof $==="string"&&z.values.has("content-type")||globalThis.Blob&&$ instanceof globalThis.Blob||$ instanceof FormData||$ instanceof URLSearchParams||globalThis.ReadableStream&&$ instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:$};else if(typeof $==="object"&&((Symbol.asyncIterator in $)||(Symbol.iterator in $)&&("next"in $)&&typeof $.next==="function"))return{bodyHeaders:void 0,body:r2($)};else if(typeof $==="object"&&z.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery($)};else return H(this,D6,"f").call(this,{body:$,headers:z})}}var HZ,BZ,D6,AX,LZ="\\n\\nHuman:",NZ="\\n\\nAssistant:",B$;var MZ=S(()=>{d0();P$();G3();vz();N0();t();I3();IX();$6();ZZ();KZ();$Z();VZ();G3();s();t2();P$();BZ=a,D6=new WeakMap,HZ=new WeakSet,AX=function(){return this.baseURL!=="https://api.anthropic.com"};a.Anthropic=BZ;a.HUMAN_PROMPT=LZ;a.AI_PROMPT=NZ;a.DEFAULT_TIMEOUT=600000;a.AnthropicError=_;a.APIError=X0;a.APIConnectionError=Y$;a.APIConnectionTimeoutError=$1;a.APIUserAbortError=q0;a.NotFoundError=J1;a.ConflictError=Q1;a.RateLimitError=U1;a.BadRequestError=Z1;a.AuthenticationError=z1;a.InternalServerError=G1;a.PermissionDeniedError=X1;a.UnprocessableEntityError=Y1;a.toFile=W4;B$=class B$ extends a{constructor(){super(...arguments);this.completions=new D1(this),this.messages=new x$(this),this.models=new A1(this),this.beta=new B0(this)}};B$.Completions=D1;B$.Messages=x$;B$.Models=A1;B$.Beta=B0});var RX={};wZ(RX,{toFile:()=>W4,default:()=>B$,UnprocessableEntityError:()=>Y1,RateLimitError:()=>U1,PermissionDeniedError:()=>X1,PagePromise:()=>U4,NotFoundError:()=>J1,InternalServerError:()=>G1,HUMAN_PROMPT:()=>LZ,ConflictError:()=>Q1,BaseAnthropic:()=>a,BadRequestError:()=>Z1,AuthenticationError:()=>z1,AnthropicError:()=>_,Anthropic:()=>B$,APIUserAbortError:()=>q0,APIPromise:()=>W$,APIError:()=>X0,APIConnectionTimeoutError:()=>$1,APIConnectionError:()=>Y$,AI_PROMPT:()=>NZ});var FX=S(()=>{MZ();I3();$6();MZ();t();N0()});var cZ=sX(mZ(),1),{program:VT,createCommand:KT,createArgument:HT,createOption:BT,CommanderError:LT,InvalidArgumentError:NT,InvalidOptionArgumentError:MT,Command:dZ,Argument:TT,Option:OT,Help:DT}=cZ.default;import{readFileSync as $7,writeFileSync as fH,existsSync as t9}from"fs";import{join as e9,dirname as gH}from"path";var eK=E8(),$H=c1(),ZH=H8(),m8=d1(),zH=_1(),X$=c(),XH=t0(),JH=Z0(),QH=$$(),YH=Z$(),vO=j2(),UH=h8(),GH=v8(),WH=u8(),x2=a9(),o9=w1();var qH=eK.Composer,VH=$H.Document,KH=ZH.Schema,HH=m8.YAMLError,BH=m8.YAMLParseError,LH=m8.YAMLWarning,NH=zH.Alias,MH=X$.isAlias,TH=X$.isCollection,OH=X$.isDocument,DH=X$.isMap,IH=X$.isNode,AH=X$.isPair,RH=X$.isScalar,FH=X$.isSeq,wH=XH.Pair,PH=JH.Scalar,_H=QH.YAMLMap,CH=YH.YAMLSeq;var EH=UH.Lexer,jH=GH.LineCounter,SH=WH.Parser,J$=x2.parse,bH=x2.parseAllDocuments,xH=x2.parseDocument,c8=x2.stringify,kH=o9.visit,yH=o9.visitAsync;function l($){let Z=$7($,"utf-8");return J$(Z)}function r($,Z){let z=Z._meta,X={...Z};delete X._meta;let J=c8(X,{lineWidth:0});if(z?.found&&z.found.length>0){let Q=z.found.join(" + ");J=J.replace(/^(\s+type:\s+\S+)(\s*)$/m,(Y,U,G)=>{if(G.includes("#"))return Y;return`${U} # found: ${Q}`})}fH($,J,"utf-8")}function u($){return $7($,"utf-8")}function v($=process.cwd()){let Z=["project.faf",".faf"];for(let X of Z){let J=e9($,X);if(t9(J))return J}let z=gH($);if(z!==$)for(let X of Z){let J=e9(z,X);if(t9(J))return J}return null}d();var l$=[{name:"TROPHY",indicator:`${V0("\uD83C\uDFC6")} ${V0("TROPHY")}`,threshold:100},{name:"GOLD",indicator:`${V0(w("★"))} ${V0("GOLD")}`,threshold:99},{name:"SILVER",indicator:`${D("◆")} ${D("SILVER")}`,threshold:95},{name:"BRONZE",indicator:`${k2("◇")} ${k2("BRONZE")}`,threshold:85},{name:"GREEN",indicator:`${w("●")} GREEN`,threshold:70},{name:"YELLOW",indicator:`${N("●")} YELLOW`,threshold:55},{name:"RED",indicator:`${N("○")} RED`,threshold:1},{name:"WHITE",indicator:`${N("♡")}`,threshold:0}];function i$($){return $.indicator}function p8($){for(let Z of l$)if($>=Z.threshold)return Z;return l$[l$.length-1]}var l8=null;function a1(){if(l8)return l8;try{let $=T0("faf-scoring-kernel");return l8=$,$}catch{throw Error(`faf-scoring-kernel not installed.
204
+ `);this.baseURL=J.baseURL,this.timeout=J.timeout??BZ.DEFAULT_TIMEOUT,this.logger=J.logger??console;let Q="warn";this.logLevel=Q,this.logLevel=K3(J.logLevel,"ClientOptions.logLevel",this)??K3(c4("ANTHROPIC_LOG"),"process.env['ANTHROPIC_LOG']",this)??Q,this.fetchOptions=J.fetchOptions,this.maxRetries=J.maxRetries??2,this.fetch=J.fetch??yz(),R(this,D6,gz,"f"),this._options=J,this.apiKey=typeof Z==="string"?Z:null,this.authToken=z}withOptions($){return new this.constructor({...this._options,baseURL:this.baseURL,maxRetries:this.maxRetries,timeout:this.timeout,logger:this.logger,logLevel:this.logLevel,fetch:this.fetch,fetchOptions:this.fetchOptions,apiKey:this.apiKey,authToken:this.authToken,...$})}defaultQuery(){return this._options.defaultQuery}validateHeaders({values:$,nulls:Z}){if($.get("x-api-key")||$.get("authorization"))return;if(this.apiKey&&$.get("x-api-key"))return;if(Z.has("x-api-key"))return;if(this.authToken&&$.get("authorization"))return;if(Z.has("authorization"))return;throw Error('Could not resolve authentication method. Expected either apiKey or authToken to be set. Or for one of the "X-Api-Key" or "Authorization" headers to be explicitly omitted')}async authHeaders($){return T([await this.apiKeyAuth($),await this.bearerAuth($)])}async apiKeyAuth($){if(this.apiKey==null)return;return T([{"X-Api-Key":this.apiKey}])}async bearerAuth($){if(this.authToken==null)return;return T([{Authorization:`Bearer ${this.authToken}`}])}stringifyQuery($){return hz($)}getUserAgent(){return`${this.constructor.name}/JS ${U$}`}defaultIdempotencyKey(){return`stainless-node-retry-${J3()}`}makeStatusError($,Z,z,X){return X0.generate($,Z,z,X)}buildURL($,Z,z){let X=!H(this,HZ,"m",AX).call(this)&&z||this.baseURL,J=Pz($)?new URL($):new URL(X+(X.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),Q=this.defaultQuery(),Y=Object.fromEntries(J.searchParams);if(!U3(Q)||!U3(Y))Z={...Y,...Q,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))J.search=this.stringifyQuery(Z);return J.toString()}_calculateNonstreamingTimeout($){if(3600*$/128000>600)throw new _("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#streaming-responses for more details");return 600000}async prepareOptions($){}async prepareRequest($,{url:Z,options:z}){}get($,Z){return this.methodRequest("get",$,Z)}post($,Z){return this.methodRequest("post",$,Z)}patch($,Z){return this.methodRequest("patch",$,Z)}put($,Z){return this.methodRequest("put",$,Z)}delete($,Z){return this.methodRequest("delete",$,Z)}methodRequest($,Z,z){return this.request(Promise.resolve(z).then((X)=>{return{method:$,path:Z,...X}}))}request($,Z=null){return new W$(this,this.makeRequest($,Z,void 0))}async makeRequest($,Z,z){let X=await $,J=X.maxRetries??this.maxRetries;if(Z==null)Z=J;await this.prepareOptions(X);let{req:Q,url:Y,timeout:U}=await this.buildRequest(X,{retryCount:J-Z});await this.prepareRequest(Q,{url:Y,options:X});let G="log_"+(Math.random()*16777216|0).toString(16).padStart(6,"0"),W=z===void 0?"":`, retryOf: ${z}`,q=Date.now();if(G0(this).debug(`[${G}] sending request`,l0({retryOfRequestLogID:z,method:X.method,url:Y,options:X,headers:Q.headers})),X.signal?.aborted)throw new q0;let V=new AbortController,K=await this.fetchWithTimeout(Y,Q,U,V).catch(Z4),B=Date.now();if(K instanceof globalThis.Error){let M=`retrying, ${Z} attempts remaining`;if(X.signal?.aborted)throw new q0;let F=p0(K)||/timed? ?out/i.test(String(K)+("cause"in K?String(K.cause):""));if(Z)return G0(this).info(`[${G}] connection ${F?"timed out":"failed"} - ${M}`),G0(this).debug(`[${G}] connection ${F?"timed out":"failed"} (${M})`,l0({retryOfRequestLogID:z,url:Y,durationMs:B-q,message:K.message})),this.retryRequest(X,Z,z??G);if(G0(this).info(`[${G}] connection ${F?"timed out":"failed"} - error; no more retries left`),G0(this).debug(`[${G}] connection ${F?"timed out":"failed"} (error; no more retries left)`,l0({retryOfRequestLogID:z,url:Y,durationMs:B-q,message:K.message})),F)throw new $1;throw new Y$({cause:K})}let O=[...K.headers.entries()].filter(([M])=>M==="request-id").map(([M,F])=>", "+M+": "+JSON.stringify(F)).join(""),L=`[${G}${W}${O}] ${Q.method} ${Y} ${K.ok?"succeeded":"failed"} with status ${K.status} in ${B-q}ms`;if(!K.ok){let M=await this.shouldRetry(K);if(Z&&M){let y=`retrying, ${Z} attempts remaining`;return await fz(K.body),G0(this).info(`${L} - ${y}`),G0(this).debug(`[${G}] response error (${y})`,l0({retryOfRequestLogID:z,url:K.url,status:K.status,headers:K.headers,durationMs:B-q})),this.retryRequest(X,Z,z??G,K.headers)}let F=M?"error; no more retries left":"error; not retryable";G0(this).info(`${L} - ${F}`);let j=await K.text().catch((y)=>Z4(y).message),b=s2(j),x=b?void 0:j;throw G0(this).debug(`[${G}] response error (${F})`,l0({retryOfRequestLogID:z,url:K.url,status:K.status,headers:K.headers,message:x,durationMs:Date.now()-q})),this.makeStatusError(K.status,b,x,K.headers)}return G0(this).info(L),G0(this).debug(`[${G}] response start`,l0({retryOfRequestLogID:z,url:K.url,status:K.status,headers:K.headers,durationMs:B-q})),{response:K,options:X,controller:V,requestLogID:G,retryOfRequestLogID:z,startTime:q}}getAPIList($,Z,z){return this.requestAPIList(Z,z&&"then"in z?z.then((X)=>({method:"get",path:$,...X})):{method:"get",path:$,...z})}requestAPIList($,Z){let z=this.makeRequest(Z,null,void 0);return new U4(this,z,$)}async fetchWithTimeout($,Z,z,X){let{signal:J,method:Q,...Y}=Z||{},U=this._makeAbort(X);if(J)J.addEventListener("abort",U,{once:!0});let G=setTimeout(U,z),W=globalThis.ReadableStream&&Y.body instanceof globalThis.ReadableStream||typeof Y.body==="object"&&Y.body!==null&&Symbol.asyncIterator in Y.body,q={signal:X.signal,...W?{duplex:"half"}:{},method:"GET",...Y};if(Q)q.method=Q.toUpperCase();try{return await this.fetch.call(void 0,$,q)}finally{clearTimeout(G)}}async shouldRetry($){let Z=$.headers.get("x-should-retry");if(Z==="true")return!0;if(Z==="false")return!1;if($.status===408)return!0;if($.status===409)return!0;if($.status===429)return!0;if($.status>=500)return!0;return!1}async retryRequest($,Z,z,X){let J,Q=X?.get("retry-after-ms");if(Q){let U=parseFloat(Q);if(!Number.isNaN(U))J=U}let Y=X?.get("retry-after");if(Y&&!J){let U=parseFloat(Y);if(!Number.isNaN(U))J=U*1000;else J=Date.parse(Y)-Date.now()}if(J===void 0){let U=$.maxRetries??this.maxRetries;J=this.calculateDefaultRetryTimeoutMillis(Z,U)}return await Ez(J),this.makeRequest($,Z-1,z)}calculateDefaultRetryTimeoutMillis($,Z){let J=Z-$,Q=Math.min(0.5*Math.pow(2,J),8),Y=1-Math.random()*0.25;return Q*Y*1000}calculateNonstreamingTimeout($,Z){if(3600000*$/128000>600000||Z!=null&&$>Z)throw new _("Streaming is required for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-typescript#long-requests for more details");return 600000}async buildRequest($,{retryCount:Z=0}={}){let z={...$},{method:X,path:J,query:Q,defaultBaseURL:Y}=z,U=this.buildURL(J,Q,Y);if("timeout"in z)Cz("timeout",z.timeout);z.timeout=z.timeout??this.timeout;let{bodyHeaders:G,body:W}=this.buildBody({options:z}),q=await this.buildHeaders({options:$,method:X,bodyHeaders:G,retryCount:Z});return{req:{method:X,headers:q,...z.signal&&{signal:z.signal},...globalThis.ReadableStream&&W instanceof globalThis.ReadableStream&&{duplex:"half"},...W&&{body:W},...this.fetchOptions??{},...z.fetchOptions??{}},url:U,timeout:z.timeout}}async buildHeaders({options:$,method:Z,bodyHeaders:z,retryCount:X}){let J={};if(this.idempotencyHeader&&Z!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();J[this.idempotencyHeader]=$.idempotencyKey}let Q=T([J,{Accept:"application/json","User-Agent":this.getUserAgent(),"X-Stainless-Retry-Count":String(X),...$.timeout?{"X-Stainless-Timeout":String(Math.trunc($.timeout/1000))}:{},...kz(),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01"},await this.authHeaders($),this._options.defaultHeaders,z,$.headers]);return this.validateHeaders(Q),Q.values}_makeAbort($){return()=>$.abort()}buildBody({options:{body:$,headers:Z}}){if(!$)return{bodyHeaders:void 0,body:void 0};let z=T([Z]);if(ArrayBuffer.isView($)||$ instanceof ArrayBuffer||$ instanceof DataView||typeof $==="string"&&z.values.has("content-type")||globalThis.Blob&&$ instanceof globalThis.Blob||$ instanceof FormData||$ instanceof URLSearchParams||globalThis.ReadableStream&&$ instanceof globalThis.ReadableStream)return{bodyHeaders:void 0,body:$};else if(typeof $==="object"&&((Symbol.asyncIterator in $)||(Symbol.iterator in $)&&("next"in $)&&typeof $.next==="function"))return{bodyHeaders:void 0,body:r2($)};else if(typeof $==="object"&&z.values.get("content-type")==="application/x-www-form-urlencoded")return{bodyHeaders:{"content-type":"application/x-www-form-urlencoded"},body:this.stringifyQuery($)};else return H(this,D6,"f").call(this,{body:$,headers:z})}}var HZ,BZ,D6,AX,LZ="\\n\\nHuman:",NZ="\\n\\nAssistant:",B$;var MZ=S(()=>{d0();P$();G3();vz();N0();t();I3();IX();$6();ZZ();KZ();$Z();VZ();G3();s();t2();P$();BZ=a,D6=new WeakMap,HZ=new WeakSet,AX=function(){return this.baseURL!=="https://api.anthropic.com"};a.Anthropic=BZ;a.HUMAN_PROMPT=LZ;a.AI_PROMPT=NZ;a.DEFAULT_TIMEOUT=600000;a.AnthropicError=_;a.APIError=X0;a.APIConnectionError=Y$;a.APIConnectionTimeoutError=$1;a.APIUserAbortError=q0;a.NotFoundError=J1;a.ConflictError=Q1;a.RateLimitError=U1;a.BadRequestError=Z1;a.AuthenticationError=z1;a.InternalServerError=G1;a.PermissionDeniedError=X1;a.UnprocessableEntityError=Y1;a.toFile=W4;B$=class B$ extends a{constructor(){super(...arguments);this.completions=new D1(this),this.messages=new x$(this),this.models=new A1(this),this.beta=new B0(this)}};B$.Completions=D1;B$.Messages=x$;B$.Models=A1;B$.Beta=B0});var RX={};wZ(RX,{toFile:()=>W4,default:()=>B$,UnprocessableEntityError:()=>Y1,RateLimitError:()=>U1,PermissionDeniedError:()=>X1,PagePromise:()=>U4,NotFoundError:()=>J1,InternalServerError:()=>G1,HUMAN_PROMPT:()=>LZ,ConflictError:()=>Q1,BaseAnthropic:()=>a,BadRequestError:()=>Z1,AuthenticationError:()=>z1,AnthropicError:()=>_,Anthropic:()=>B$,APIUserAbortError:()=>q0,APIPromise:()=>W$,APIError:()=>X0,APIConnectionTimeoutError:()=>$1,APIConnectionError:()=>Y$,AI_PROMPT:()=>NZ});var FX=S(()=>{MZ();I3();$6();MZ();t();N0()});var cZ=sX(mZ(),1),{program:KT,createCommand:HT,createArgument:BT,createOption:LT,CommanderError:NT,InvalidArgumentError:MT,InvalidOptionArgumentError:TT,Command:dZ,Argument:OT,Option:DT,Help:IT}=cZ.default;import{readFileSync as $7,writeFileSync as fH,existsSync as t9}from"fs";import{join as e9,dirname as gH}from"path";var eK=E8(),$H=c1(),ZH=H8(),m8=d1(),zH=_1(),X$=c(),XH=t0(),JH=Z0(),QH=$$(),YH=Z$(),uO=j2(),UH=h8(),GH=v8(),WH=u8(),x2=a9(),o9=w1();var qH=eK.Composer,VH=$H.Document,KH=ZH.Schema,HH=m8.YAMLError,BH=m8.YAMLParseError,LH=m8.YAMLWarning,NH=zH.Alias,MH=X$.isAlias,TH=X$.isCollection,OH=X$.isDocument,DH=X$.isMap,IH=X$.isNode,AH=X$.isPair,RH=X$.isScalar,FH=X$.isSeq,wH=XH.Pair,PH=JH.Scalar,_H=QH.YAMLMap,CH=YH.YAMLSeq;var EH=UH.Lexer,jH=GH.LineCounter,SH=WH.Parser,J$=x2.parse,bH=x2.parseAllDocuments,xH=x2.parseDocument,c8=x2.stringify,kH=o9.visit,yH=o9.visitAsync;function l($){let Z=$7($,"utf-8");return J$(Z)}function r($,Z){let z=Z._meta,X={...Z};delete X._meta;let J=c8(X,{lineWidth:0});if(z?.found&&z.found.length>0){let Q=z.found.join(" + ");J=J.replace(/^(\s+type:\s+\S+)(\s*)$/m,(Y,U,G)=>{if(G.includes("#"))return Y;return`${U} # found: ${Q}`})}fH($,J,"utf-8")}function u($){return $7($,"utf-8")}function v($=process.cwd()){let Z=["project.faf",".faf"];for(let X of Z){let J=e9($,X);if(t9(J))return J}let z=gH($);if(z!==$)for(let X of Z){let J=e9(z,X);if(t9(J))return J}return null}d();var l$=[{name:"TROPHY",indicator:`${V0("\uD83C\uDFC6")} ${V0("TROPHY")}`,threshold:100},{name:"GOLD",indicator:`${V0(w("★"))} ${V0("GOLD")}`,threshold:99},{name:"SILVER",indicator:`${D("◆")} ${D("SILVER")}`,threshold:95},{name:"BRONZE",indicator:`${k2("◇")} ${k2("BRONZE")}`,threshold:85},{name:"GREEN",indicator:`${w("●")} GREEN`,threshold:70},{name:"YELLOW",indicator:`${N("●")} YELLOW`,threshold:55},{name:"RED",indicator:`${N("○")} RED`,threshold:1},{name:"WHITE",indicator:`${N("♡")}`,threshold:0}];function i$($){return $.indicator}function p8($){for(let Z of l$)if($>=Z.threshold)return Z;return l$[l$.length-1]}var l8=null;function a1(){if(l8)return l8;try{let $=T0("faf-scoring-kernel");return l8=$,$}catch{throw Error(`faf-scoring-kernel not installed.
205
205
 
206
206
  Run: npm install faf-scoring-kernel
207
207
  `)}}function W0($){return JSON.parse(a1().score_faf($))}function z7($){return a1().validate_faf($)}function y2($){return a1().compile_fafb($)}function X7($){return JSON.parse(a1().decompile_fafb($))}function J7(){return a1().sdk_version()}function K0($){return{score:$.score,tier:p8($.score),populated:$.populated,empty:$.empty,ignored:$.ignored,active:$.active,total:$.total,slots:$.slots}}function H0($){if(/^\s*app_type:\s*about\s*$/m.test($)){let z=$.match(/^\s+source_score:\s*(\d+)\s*$/m),X=z?parseInt(z[1],10):-1,J=X>=0&&X<=100?X:-1,Q=$.match(/^\s+represents:\s*(\S+)\s*$/m),Y=Q?Q[1]:void 0;return{score:J,tier:J>=0?p8(J):l$[l$.length-1],populated:0,empty:0,ignored:0,active:0,total:0,slots:{},inherited:!0,represents:Y}}return K0(W0($))}d();function z0($,Z,z=!1){let X=i$($.tier),J=w(`${$.score}%`);if(console.log(`${X} ${J} ${N(`${$.populated}/${$.active} slots`)} ${N("—")} ${Z}`),$.tier.name==="TROPHY")console.log(N(" Trophy. AI never has to guess."));else if($.empty>0){let Q=Object.entries($.slots).filter(([,W])=>W==="empty").map(([W])=>W),Y=Q.slice(0,3).join(", "),U=Q.length>3?`, +${Q.length-3} more`:"",G=$.empty===1?"slot":"slots";console.log(N(` ${$.empty} ${G} from Trophy: ${Y}${U}`))}if(z)console.log(""),vH($)}function vH($){for(let[Z,z]of Object.entries($.slots)){let X=z==="populated"?D("●"):z==="slotignored"?N("—"):N("○");console.log(` ${X} ${z==="slotignored"?N(Z):Z}`)}}d();function f2($,Z={}){let z=$??v();if(!z)console.error(`Error: project.faf not found
208
208
 
209
- Run 'faf init' to create one.`),process.exit(2);let X=u(z),J=H0(X);if(Z.json){console.log(JSON.stringify(J,null,2));return}if(Z.status){console.log(`${i$(J.tier)} ${w(`${J.score}%`)}`);return}z0(J,z,Z.verbose)}import{existsSync as nB}from"fs";import{join as _7}from"path";var $0=[{index:1,path:"project.name",description:"Project name",category:"project"},{index:2,path:"project.goal",description:"Goal (use case)",category:"project"},{index:3,path:"project.main_language",description:"Primary language",category:"project"},{index:4,path:"human_context.who",description:"Who is this for?",category:"human"},{index:5,path:"human_context.what",description:"What are they building",category:"human"},{index:6,path:"human_context.why",description:"Why does it exist",category:"human"},{index:7,path:"human_context.where",description:"Where does it run",category:"human"},{index:8,path:"human_context.when",description:"When was it started / timeline",category:"human"},{index:9,path:"human_context.how",description:"How is it built",category:"human"},{index:10,path:"stack.frontend",canonical:"stack.framework",description:"Framework (React, Svelte, etc.)",category:"frontend"},{index:11,path:"stack.css_framework",canonical:"stack.css",description:"CSS framework",category:"frontend"},{index:12,path:"stack.ui_library",description:"UI component library",category:"frontend"},{index:13,path:"stack.state_management",canonical:"stack.state",description:"State management",category:"frontend"},{index:14,path:"stack.backend",description:"Backend framework",category:"backend"},{index:15,path:"stack.api_type",canonical:"stack.api",description:"API style (REST, GraphQL, etc.)",category:"backend"},{index:16,path:"stack.runtime",description:"Runtime (Node, Bun, Python, etc.)",category:"backend"},{index:17,path:"stack.database",canonical:"stack.db",description:"Database",category:"backend"},{index:18,path:"stack.connection",description:"Connection method (Prisma, etc.)",category:"backend"},{index:19,path:"stack.hosting",description:"Hosting platform",category:"universal"},{index:20,path:"stack.build",description:"Build tool",category:"universal"},{index:21,path:"stack.cicd",description:"CI/CD",category:"universal"},{index:22,path:"stack.monorepo_tool",description:"Monorepo tool",category:"enterprise_infra"},{index:23,path:"stack.package_manager",canonical:"stack.pkg_manager",description:"Package manager",category:"enterprise_infra"},{index:24,path:"stack.workspaces",description:"Workspace configuration",category:"enterprise_infra"},{index:25,path:"monorepo.packages_count",description:"Number of packages",category:"enterprise_infra"},{index:26,path:"monorepo.build_orchestrator",description:"Build orchestration tool",category:"enterprise_infra"},{index:27,path:"stack.admin",description:"Admin panel",category:"enterprise_app"},{index:28,path:"stack.cache",description:"Caching layer",category:"enterprise_app"},{index:29,path:"stack.search",description:"Search engine",category:"enterprise_app"},{index:30,path:"stack.storage",description:"Object storage",category:"enterprise_app"},{index:31,path:"monorepo.versioning_strategy",description:"Version strategy",category:"enterprise_ops"},{index:32,path:"monorepo.shared_configs",description:"Shared configs",category:"enterprise_ops"},{index:33,path:"monorepo.remote_cache",description:"Remote build cache",category:"enterprise_ops"}],Q7=new Map($0.flatMap(($)=>$.canonical?[[$.path,$],[$.canonical,$]]:[[$.path,$]])),QD=new Map($0.filter(($)=>$.canonical).map(($)=>[$.canonical,$.path])),YD=new Map($0.filter(($)=>$.canonical).map(($)=>[$.path,$.canonical]));function Y7($,Z){let z=(J)=>{let Q=J.split("."),Y=$;for(let U of Q)if(Y&&typeof Y==="object"&&U in Y)Y=Y[U];else return;return Y},X=z(Z.path);if(X!==void 0)return X;if(Z.canonical)return z(Z.canonical);return}var UD=$0.filter(($)=>$.index<=21);var i8=new Set(["describe your project goal","development teams","cloud platform","null","none","unknown","n/a","not applicable"]);function v0($){if($===null||$===void 0||$==="")return!0;if(typeof $==="string")return i8.has($.toLowerCase().trim());if(Array.isArray($)&&$.length===0)return!0;if(typeof $==="object"&&Object.keys($).length===0)return!0;return!1}var n$={about:[],documentation:["project","human"],intent:["project","human"],encyclopedia:["project","human"],cli:["project","human","universal"],library:["project","human","universal"],sdk:["project","human","universal"],wasm:["project","human","universal"],html:["project","human","universal"],"server-card":["project","human","universal"],frontend:["project","frontend","human","universal"],website:["project","frontend","human","universal"],mobile:["project","frontend","human","universal"],extension:["project","frontend","human","universal"],mcp:["project","backend","human","universal"],backend:["project","backend","universal","human"],"data-science":["project","backend","human","universal"],fullstack:["project","frontend","backend","universal","human"],svelte:["project","frontend","backend","universal","human"],framework:["project","frontend","backend","universal","human"],"monorepo-root":["project","human","enterprise_infra","enterprise_app","enterprise_ops"],mcpaas:["project","backend","universal","human","enterprise_app","enterprise_ops"],saas:["project","frontend","backend","universal","human","enterprise_app"],enterprise:["project","frontend","backend","universal","human","enterprise_infra","enterprise_app","enterprise_ops"]};import{existsSync as C,readFileSync as u0,readdirSync as G7}from"fs";import{join as P}from"path";var U7=[{name:"Next.js",slug:"nextjs",category:"frontend",signals:[{type:"dependency",key:"next"},{type:"file",pattern:"next.config.*"}]},{name:"React",slug:"react",category:"frontend",signals:[{type:"dependency",key:"react"}]},{name:"SvelteKit",slug:"sveltekit",category:"frontend",signals:[{type:"dependency",key:"@sveltejs/kit"},{type:"file",pattern:"svelte.config.*"}]},{name:"Svelte",slug:"svelte",category:"frontend",signals:[{type:"dependency",key:"svelte"},{type:"devDependency",key:"svelte"}]},{name:"Vue.js",slug:"vue",category:"frontend",signals:[{type:"dependency",key:"vue"}]},{name:"Nuxt",slug:"nuxt",category:"frontend",signals:[{type:"dependency",key:"nuxt"},{type:"file",pattern:"nuxt.config.*"}]},{name:"Angular",slug:"angular",category:"frontend",signals:[{type:"dependency",key:"@angular/core"},{type:"file",pattern:"angular.json"}]},{name:"Astro",slug:"astro",category:"frontend",signals:[{type:"dependency",key:"astro"},{type:"file",pattern:"astro.config.*"}]},{name:"Solid",slug:"solid",category:"frontend",signals:[{type:"dependency",key:"solid-js"}]},{name:"Remix",slug:"remix",category:"frontend",signals:[{type:"dependency",key:"@remix-run/react"}]},{name:"Gatsby",slug:"gatsby",category:"frontend",signals:[{type:"dependency",key:"gatsby"},{type:"file",pattern:"gatsby-config.*"}]},{name:"Qwik",slug:"qwik",category:"frontend",signals:[{type:"dependency",key:"@builder.io/qwik"}]},{name:"Vercel (SvelteKit)",slug:"adapter-vercel",category:"hosting",signals:[{type:"dependency",key:"@sveltejs/adapter-vercel"},{type:"devDependency",key:"@sveltejs/adapter-vercel"}]},{name:"Node (SvelteKit)",slug:"adapter-node",category:"hosting",signals:[{type:"dependency",key:"@sveltejs/adapter-node"},{type:"devDependency",key:"@sveltejs/adapter-node"}]},{name:"Static (SvelteKit)",slug:"adapter-static",category:"hosting",signals:[{type:"dependency",key:"@sveltejs/adapter-static"},{type:"devDependency",key:"@sveltejs/adapter-static"}]},{name:"Cloudflare (SvelteKit)",slug:"adapter-cloudflare",category:"hosting",signals:[{type:"dependency",key:"@sveltejs/adapter-cloudflare"},{type:"devDependency",key:"@sveltejs/adapter-cloudflare"}]},{name:"Netlify (SvelteKit)",slug:"adapter-netlify",category:"hosting",signals:[{type:"dependency",key:"@sveltejs/adapter-netlify"},{type:"devDependency",key:"@sveltejs/adapter-netlify"}]},{name:"Tailwind CSS",slug:"tailwind",category:"css",signals:[{type:"dependency",key:"tailwindcss"},{type:"devDependency",key:"tailwindcss"},{type:"file",pattern:"tailwind.config.*"}]},{name:"Bootstrap",slug:"bootstrap",category:"css",signals:[{type:"dependency",key:"bootstrap"}]},{name:"Styled Components",slug:"styled-components",category:"css",signals:[{type:"dependency",key:"styled-components"}]},{name:"shadcn/ui",slug:"shadcn",category:"ui",signals:[{type:"file",pattern:"components.json"},{type:"dependency",key:"@radix-ui/react-dialog"}]},{name:"Material UI",slug:"mui",category:"ui",signals:[{type:"dependency",key:"@mui/material"}]},{name:"Chakra UI",slug:"chakra",category:"ui",signals:[{type:"dependency",key:"@chakra-ui/react"}]},{name:"Ant Design",slug:"antd",category:"ui",signals:[{type:"dependency",key:"antd"}]},{name:"Redux",slug:"redux",category:"state",signals:[{type:"dependency",key:"@reduxjs/toolkit"}]},{name:"Zustand",slug:"zustand",category:"state",signals:[{type:"dependency",key:"zustand"}]},{name:"Jotai",slug:"jotai",category:"state",signals:[{type:"dependency",key:"jotai"}]},{name:"Pinia",slug:"pinia",category:"state",signals:[{type:"dependency",key:"pinia"}]},{name:"Express",slug:"express",category:"backend",signals:[{type:"dependency",key:"express"}]},{name:"Fastify",slug:"fastify",category:"backend",signals:[{type:"dependency",key:"fastify"}]},{name:"Hono",slug:"hono",category:"backend",signals:[{type:"dependency",key:"hono"}]},{name:"Elysia",slug:"elysia",category:"backend",signals:[{type:"dependency",key:"elysia"}]},{name:"NestJS",slug:"nestjs",category:"backend",signals:[{type:"dependency",key:"@nestjs/core"}]},{name:"Koa",slug:"koa",category:"backend",signals:[{type:"dependency",key:"koa"}]},{name:"Django",slug:"django",category:"backend",signals:[{type:"file",pattern:"manage.py"},{type:"file",pattern:"settings.py"}]},{name:"Flask",slug:"flask",category:"backend",signals:[{type:"file",pattern:"app.py"}]},{name:"FastAPI",slug:"fastapi",category:"backend",signals:[{type:"file",pattern:"main.py"}]},{name:"Rails",slug:"rails",category:"backend",signals:[{type:"file",pattern:"Gemfile"},{type:"file",pattern:"config/routes.rb"}]},{name:"Spring Boot",slug:"spring",category:"backend",signals:[{type:"file",pattern:"pom.xml"},{type:"file",pattern:"build.gradle"}]},{name:"Prisma",slug:"prisma",category:"database",signals:[{type:"dependency",key:"prisma"},{type:"devDependency",key:"prisma"},{type:"file",pattern:"prisma/schema.prisma"}]},{name:"Drizzle",slug:"drizzle",category:"database",signals:[{type:"dependency",key:"drizzle-orm"},{type:"file",pattern:"drizzle.config.*"}]},{name:"TypeORM",slug:"typeorm",category:"database",signals:[{type:"dependency",key:"typeorm"}]},{name:"Mongoose",slug:"mongoose",category:"database",signals:[{type:"dependency",key:"mongoose"}]},{name:"Vite",slug:"vite",category:"build",signals:[{type:"dependency",key:"vite"},{type:"devDependency",key:"vite"},{type:"file",pattern:"vite.config.*"}]},{name:"webpack",slug:"webpack",category:"build",signals:[{type:"dependency",key:"webpack"},{type:"devDependency",key:"webpack"},{type:"file",pattern:"webpack.config.*"}]},{name:"esbuild",slug:"esbuild",category:"build",signals:[{type:"dependency",key:"esbuild"},{type:"devDependency",key:"esbuild"}]},{name:"Turbopack",slug:"turbopack",category:"build",signals:[{type:"file",pattern:"turbo.json"}]},{name:"Jest",slug:"jest",category:"testing",signals:[{type:"devDependency",key:"jest"},{type:"file",pattern:"jest.config.*"}]},{name:"Vitest",slug:"vitest",category:"testing",signals:[{type:"devDependency",key:"vitest"}]},{name:"Playwright",slug:"playwright",category:"testing",signals:[{type:"devDependency",key:"@playwright/test"},{type:"file",pattern:"playwright.config.*"}]},{name:"Cypress",slug:"cypress",category:"testing",signals:[{type:"devDependency",key:"cypress"},{type:"file",pattern:"cypress.config.*"}]},{name:"Turborepo",slug:"turborepo",category:"monorepo",signals:[{type:"devDependency",key:"turbo"},{type:"file",pattern:"turbo.json"}]},{name:"Nx",slug:"nx",category:"monorepo",signals:[{type:"devDependency",key:"nx"},{type:"file",pattern:"nx.json"}]},{name:"Lerna",slug:"lerna",category:"monorepo",signals:[{type:"devDependency",key:"lerna"},{type:"file",pattern:"lerna.json"}]},{name:"MCP SDK",slug:"mcp",category:"ai",signals:[{type:"dependency",key:"@modelcontextprotocol/sdk"}]},{name:"Anthropic SDK",slug:"anthropic",category:"ai",signals:[{type:"dependency",key:"@anthropic-ai/sdk"}]},{name:"OpenAI SDK",slug:"openai",category:"ai",signals:[{type:"dependency",key:"openai"}]},{name:"LangChain",slug:"langchain",category:"ai",signals:[{type:"dependency",key:"langchain"}]},{name:"Vercel",slug:"vercel",category:"hosting",signals:[{type:"file",pattern:"vercel.json"}]},{name:"Netlify",slug:"netlify",category:"hosting",signals:[{type:"file",pattern:"netlify.toml"}]},{name:"Docker",slug:"docker",category:"hosting",signals:[{type:"file",pattern:"Dockerfile"},{type:"file",pattern:"docker-compose.yml"}]},{name:"Cloudflare Workers",slug:"cloudflare",category:"hosting",signals:[{type:"file",pattern:"wrangler.toml"},{type:"dependency",key:"wrangler"}]},{name:"GitHub Actions",slug:"github-actions",category:"cicd",signals:[{type:"file",pattern:".github/workflows/*.yml"}]},{name:"Commander.js",slug:"commander",category:"cli",signals:[{type:"dependency",key:"commander"}]}];function uH($){let Z=P($,"Cargo.toml");if(!C(Z))return null;try{let X=u0(Z,"utf-8").match(/^\s*\[package\][\s\S]*?^\s*name\s*=\s*"([^"]+)"/m);return X?X[1]:null}catch{return null}}function mH($){let Z=P($,"Cargo.toml");if(!C(Z))return!1;try{let z=u0(Z,"utf-8");return/^\s*\[\[bin\]\]/m.test(z)}catch{return!1}}function cH($,Z){if(Z?.keywords?.some((X)=>/^sdk(?:\s|-|$)|\-sdk$/i.test(X)))return'package.json keywords contains "sdk"';if(Z?.name&&/(?:^|[-_/])sdk(?:[-_/]|$)/i.test(Z.name))return`package.json name "${Z.name}" → sdk`;let z=uH($);if(z&&/(?:^|[-_])sdk(?:[-_]|$)/i.test(z))return`Cargo.toml name "${z}" → sdk`;return null}function dH($){let Z=["manifest.json","public/manifest.json","src/manifest.json","app/manifest.json","extension/manifest.json","dist/manifest.json"];for(let z of Z){let X=P($,z);if(!C(X))continue;try{let J=JSON.parse(u0(X,"utf-8"));if(typeof J.manifest_version==="number")return`${z} manifest_version ${J.manifest_version} (browser extension)`}catch{}}return null}function pH($){let Z=/(numpy|pandas|jupyter|scikit-learn|sklearn|pytorch|tensorflow|matplotlib|scipy)/i,z=P($,"pyproject.toml");if(C(z))try{let Q=u0(z,"utf-8").match(Z);if(Q)return`pyproject.toml depends on ${Q[1]}`}catch{}let X=P($,"requirements.txt");if(C(X))try{let Q=u0(X,"utf-8").match(Z);if(Q)return`requirements.txt contains ${Q[1]}`}catch{}return null}function lH($,Z){let z=["react-native","expo","@capacitor/core","@ionic/core"];if(Z){for(let X of z)if(Z.dependencies?.[X]||Z.devDependencies?.[X])return`${X} dependency`}if(C(P($,"pubspec.yaml")))return"pubspec.yaml (Flutter)";if(C(P($,"ios"))&&C(P($,"android")))return"ios/ + android/ dirs";return null}function iH($,Z){let z=P($,"Cargo.toml");if(C(z))try{let J=u0(z,"utf-8");if(/crate-type\s*=\s*\[[^\]]*"cdylib"/.test(J))return'Cargo.toml crate-type = ["cdylib"]';if(/wasm-bindgen|wasm-pack/i.test(J))return"Cargo.toml wasm-bindgen/wasm-pack"}catch{}let X=P($,"build.zig");if(C(X))try{let J=u0(X,"utf-8");if(/\.wasm\b|wasm32|setOutputFormat\(\.wasm/i.test(J))return"build.zig wasm target"}catch{}if(Z?.keywords?.some((J)=>/^wasm(?:-|$)|webassembly/i.test(J)))return'package.json keywords contains "wasm"';return null}function nH($,Z){if(!C(P($,"index.html")))return null;if(Z?.dependencies||Z?.devDependencies){let z={...Z.dependencies??{},...Z.devDependencies??{}};if(["react","vue","svelte","@sveltejs/kit","next","nuxt","astro","gatsby","solid-js","qwik"].some((J)=>z[J]))return null}return"index.html (vanilla, no frontend framework)"}function sH($,Z){if(Z?.name&&/specification|^@.*\/spec/i.test(Z.name))return`package name "${Z.name}" → documentation`;if(Z?.keywords?.some((z)=>/^(specification|format-spec|standard)$/i.test(z)))return'package keywords contains "specification"';if(Z?.files&&Z.files.length>0){let z=/^(dist|src|lib|build|bin)\/|\.(js|ts|tsx|jsx|mjs|cjs|py|rs|go)$/,X=Z.files.some((Q)=>z.test(Q)),J=Z.files.some((Q)=>/\.(md|MD)|examples?\//.test(Q));if(!X&&J)return"package.json files = docs/examples only (no source)"}return null}function rH($,Z,z){let X=z.find((J)=>J.slug==="astro"||J.slug==="gatsby");if(X)return`${X.name} (static-site framework)`;if(Z?.keywords?.some((J)=>/^(website|marketing|landing|brochure|portfolio)$/i.test(J)))return'package keywords contains "website"/"marketing"/"landing"';return null}function aH($,Z){if(!Z)return null;let z={...Z.dependencies??{},...Z.devDependencies??{}},X=["@clerk/nextjs","@clerk/clerk-react","next-auth","@auth/core","auth0","@auth0/nextjs-auth0"],J=["stripe","@stripe/stripe-js","lemonsqueezy"],Q=X.some((U)=>z[U]),Y=J.some((U)=>z[U]);if(Q&&Y)return"auth + payment dependencies";return null}function oH($,Z,z){if(Z?.keywords?.some((Q)=>/mcpaas/i.test(Q)))return'package keywords contains "mcpaas"';if(Z?.name&&/mcpaas/i.test(Z.name))return`package name "${Z.name}" → mcpaas`;let X=z.some((Q)=>Q.slug==="mcp"),J=z.some((Q)=>Q.category==="database");if(X&&J&&Z?.dependencies&&Object.keys(Z.dependencies).length>10)return"MCP + database + complex deps (platform shape)";return null}function tH($,Z){if(!Z?.private)return null;if(!(!!Z.workspaces||C(P($,"pnpm-workspace.yaml"))))return null;return"private workspace + multi-package"}function A$($){let Z=P($,"package.json");if(!C(Z))return null;try{return JSON.parse(u0(Z,"utf-8"))}catch{return null}}function eH($,Z){if(!Z.includes("*"))return C(P($,Z));let z=Z.split("/");if(z.length===1){let U=Z.split("*")[0];try{return G7($).some((G)=>G.startsWith(U))}catch{return!1}}let X=P($,...z.slice(0,-1)),J=z[z.length-1],Q=J.split("*")[0],Y=J.split("*")[1]||"";try{return G7(X).some((U)=>U.startsWith(Q)&&U.endsWith(Y))}catch{return!1}}function $B($,Z,z){switch($.type){case"dependency":return!!Z?.dependencies?.[$.key];case"devDependency":return!!Z?.devDependencies?.[$.key];case"file":return eH(z,$.pattern);default:return!1}}function n8($){let Z=A$($);return U7.map((z)=>{let J=z.signals.filter((Q)=>$B(Q,Z,$)).length/z.signals.length;return{name:z.name,slug:z.slug,category:z.category,confidence:J}}).filter((z)=>z.confidence>0).sort((z,X)=>X.confidence-z.confidence)}function W7($){let Z=A$($);if(Z?.devDependencies?.typescript||Z?.dependencies?.typescript)return"TypeScript";if(C(P($,"tsconfig.json")))return"TypeScript";if(C(P($,"Cargo.toml")))return"Rust";if(C(P($,"go.mod")))return"Go";if(C(P($,"pyproject.toml"))||C(P($,"setup.py")))return"Python";if(C(P($,"Gemfile")))return"Ruby";if(C(P($,"pom.xml"))||C(P($,"build.gradle")))return"Java";if(C(P($,"Package.swift")))return"Swift";if(C(P($,"build.zig")))return"Zig";if(Z)return"JavaScript";return"Unknown"}function q7($){let Z=A$($),z=n8($),X=[],J=sH($,Z);if(J)return X.push(J),{type:"documentation",found:X};let Q=cH($,Z);if(Q)return X.push(Q),{type:"sdk",found:X};let Y=dH($);if(Y)return X.push(Y),{type:"extension",found:X};let U=oH($,Z,z);if(U)return X.push(U),{type:"mcpaas",found:X};let G=aH($,Z);if(G)return X.push(G),{type:"saas",found:X};let W=iH($,Z);if(W)return X.push(W),{type:"wasm",found:X};let q=lH($,Z);if(q)return X.push(q),{type:"mobile",found:X};if(z.some((g)=>g.slug==="mcp"))return X.push("MCP SDK signal"),{type:"mcp",found:X};if(Z?.bin)return X.push("package.json bin"),{type:"cli",found:X};if(mH($))return X.push("Cargo.toml [[bin]]"),{type:"cli",found:X};if(C(P($,"build.zig"))){if(X.push("build.zig"),C(P($,"src/main.zig")))return X.push("src/main.zig"),{type:"cli",found:X};if(C(P($,"src/root.zig")))return X.push("src/root.zig"),{type:"library",found:X}}let K=z.some((g)=>g.slug==="svelte"||g.slug==="sveltekit");if(Z?.private===!0&&(C(P($,"pnpm-workspace.yaml"))||Z?.workspaces!==void 0)&&K)return X.push("private workspace","Svelte"),{type:"framework",found:X};if(K)return X.push("Svelte/SvelteKit"),{type:"svelte",found:X};let O=z.some((g)=>g.category==="frontend"),L=z.some((g)=>g.category==="backend");if(Z?.private&&(Z.workspaces||C(P($,"pnpm-workspace.yaml")))&&O&&L)return X.push("private workspace + frontend + backend frameworks"),{type:"enterprise",found:X};let M=tH($,Z);if(M)return X.push(M),{type:"monorepo-root",found:X};let F=rH($,Z,z);if(F)return X.push(F),{type:"website",found:X};if(z.some((g)=>g.slug==="nextjs"||g.slug==="nuxt"))return X.push(z.find((g)=>g.slug==="nextjs")?"Next.js":"Nuxt"),{type:"fullstack",found:X};let b=z.some((g)=>g.category==="frontend"),x=z.some((g)=>g.category==="backend");if(b&&x)return X.push("frontend framework","backend framework"),{type:"fullstack",found:X};if(b)return X.push("frontend framework"),{type:"frontend",found:X};if(x)return X.push("backend framework"),{type:"backend",found:X};let k=pH($);if(k)return X.push(k),{type:"data-science",found:X};let y=nH($,Z);if(y)return X.push(y),{type:"html",found:X};if(Z?.main&&!Z?.bin)return X.push("package.json main (no bin)"),{type:"library",found:X};return X.push("no classifying signals — fallback"),{type:"library",found:X}}function V7($){if(C(P($,"bunfig.toml")))return"Bun";if(C(P($,"deno.json"))||C(P($,"deno.jsonc")))return"Deno";if(A$($))return"Node.js";if(C(P($,"Cargo.toml")))return"Rust";if(C(P($,"go.mod")))return"Go";return"Unknown"}function K7($){if(C(P($,"bun.lockb"))||C(P($,"bun.lock")))return"bun";if(C(P($,"pnpm-lock.yaml")))return"pnpm";if(C(P($,"yarn.lock")))return"yarn";if(C(P($,"package-lock.json")))return"npm";return"npm"}function H7($){if(C(P($,".github/workflows")))return"GitHub Actions";if(C(P($,".gitlab-ci.yml")))return"GitLab CI";if(C(P($,".circleci")))return"CircleCI";if(C(P($,"Jenkinsfile")))return"Jenkins";return null}function B7($){if(C(P($,"vercel.json")))return"Vercel";if(C(P($,"netlify.toml")))return"Netlify";if(C(P($,"wrangler.toml")))return"Cloudflare";if(C(P($,"Dockerfile")))return"Docker";if(C(P($,"fly.toml")))return"Fly.io";if(C(P($,"render.yaml")))return"Render";return null}function L7($){let Z=P($,"svelte.config.js");if(!C(Z))return null;try{let X=u0(Z,"utf-8").match(/@sveltejs\/adapter-(\w+)/);if(X){let J=X[1];switch(J){case"vercel":return"Vercel";case"node":return"Node";case"static":return"Static";case"cloudflare":return"Cloudflare";case"netlify":return"Netlify";case"auto":return"Auto";default:return J}}return null}catch{return null}}function N7($){let Z=A$($);if(Z?.devDependencies?.vite||Z?.dependencies?.vite)return"Vite";if(Z?.devDependencies?.webpack||Z?.dependencies?.webpack)return"webpack";if(Z?.devDependencies?.esbuild||Z?.dependencies?.esbuild)return"esbuild";if(C(P($,"tsconfig.json"))&&Z?.devDependencies?.typescript)return"TypeScript (tsc)";return null}function M7($){return["package.json","Cargo.toml","pyproject.toml","go.mod","build.zig","build.zig.zon","src/index.ts","src/index.js","src/main.ts","src/cli.ts","src/main.rs","src/lib.rs","src/main.zig","src/root.zig","src/__init__.py","main.py","__main__.py","main.go","cmd/main.go","README.md","SPECIFICATION.md","BINARY-FORMAT.md","tsconfig.json","wrangler.toml","vercel.json"].filter((z)=>C(P($,z)))}function T7($,Z){let z={};if(Z?.scripts){for(let X of["build","test","lint","dev","start"])if(Z.scripts[X]){let J=C(P($,"bun.lock"))||C(P($,"bun.lockb"))?"bun run":"npm run";z[X]=`${J} ${X}`}}if(C(P($,"Cargo.toml"))){if(!z.build)z.build="cargo build --release";if(!z.test)z.test="cargo test";if(!z.lint)z.lint="cargo clippy"}if(C(P($,"build.zig"))){if(!z.build)z.build="zig build";if(!z.test)z.test="zig build test"}if(C(P($,"go.mod"))){if(!z.build)z.build="go build ./...";if(!z.test)z.test="go test ./..."}if(C(P($,"pyproject.toml"))||C(P($,"pytest.ini"))){if(!z.test)z.test="pytest"}return z}function O7($,Z,z,X){let J=[];if(X&&X!=="Unknown")J.push(X);let Q=new Set(["frontend","backend","database","build","css","state","monorepo"]);for(let Y of z)if(Q.has(Y.category))J.push(Y.name);if(C(P($,"bunfig.toml")))J.push("Bun");else if(C(P($,"deno.json"))||C(P($,"deno.jsonc")))J.push("Deno");if(J.length<3&&Z?.dependencies){let Y=Object.keys(Z.dependencies).slice(0,5);for(let U of Y)if(!J.some((G)=>G.toLowerCase().includes(U.toLowerCase())))J.push(U)}return J}function g2($){let Z=A$($),z=n8($),X=W7($),J=q7($),Q=J.type,Y=V7($),U=K7($),G=H7($),W=B7($),q=N7($),V=z.find((n)=>n.category==="frontend"),K=z.find((n)=>n.category==="css"),B=z.find((n)=>n.category==="ui"),O=z.find((n)=>n.category==="state"),L=z.find((n)=>n.category==="backend"),M=z.find((n)=>n.category==="database"),F=n$[Q]||n$.library,j=Q==="framework",b=z.some((n)=>n.slug==="svelte"||n.slug==="sveltekit"),x=j&&b?"svelte":j?null:null,k=Q==="svelte"||x==="svelte",y=k?L7($):null,g=k&&z.some((n)=>n.slug==="sveltekit"),E=new Set(["css_framework","ui_library","database","connection","hosting"]),m={},b0=$0.filter((n)=>n.path.startsWith("stack."));for(let n of b0){let o=n.path.replace("stack.","");if(!F.includes(n.category)){m[o]="slotignored";continue}if(j&&E.has(o)){m[o]="slotignored";continue}switch(o){case"frontend":m[o]=V?.name??(Q==="cli"?"CLI":"");break;case"css_framework":m[o]=K?.name??"";break;case"ui_library":m[o]=B?.name??"";break;case"state_management":m[o]=k?O?.name??"Runes":O?.name??"";break;case"backend":m[o]=k?g?"SvelteKit":L?.name??"":L?.name??"";break;case"api_type":m[o]=g?"Server Routes":"";break;case"runtime":m[o]=Y!=="Unknown"?Y:"";break;case"database":m[o]=M?.name??"";break;case"connection":m[o]=M?.name??"";break;case"hosting":if(k&&y)m[o]=y;else m[o]=W??"";break;case"build":m[o]=k?"Vite":q??"";break;case"cicd":m[o]=G??"";break;case"package_manager":m[o]=U;break;default:m[o]="";break}}let x0={},e=$0.filter((n)=>n.path.startsWith("monorepo."));for(let n of e){let o=n.path.replace("monorepo.","");if(!F.includes(n.category))x0[o]="slotignored";else x0[o]=""}let R1={name:Z?.name??$.split("/").pop()??"project",goal:Z?.description??"",main_language:X,type:Q};if(j&&x)R1.framework=x;let AZ=O7($,Z,z,X),RZ=M7($),FZ=T7($,Z),p4={faf_version:"2.5.0",project:R1,stack:m,human_context:{who:"",what:Z?.description??"",why:"",where:"",when:"",how:""},monorepo:x0,_meta:{found:J.found}};if(AZ.length>0)p4.tech_stack=AZ;if(RZ.length>0)p4.key_files=RZ;if(Object.keys(FZ).length>0)p4.commands=FZ;return p4}import{existsSync as zB,readFileSync as XB}from"fs";import{join as JB}from"path";var D7={MIN_LENGTH:8,MAX_LENGTH:280},ZB=[/^(see|see\s+the?)\s+readme/i,/^(tbd|todo|fixme|coming\s+soon)\b/i,/^(software|application|app|project|tool|library|framework)\.?$/i,/^(for\s+users|for\s+developers)\.?$/i,/^(description|goal|name|title)\.?$/i,/^lorem\s+ipsum/i,/^example(\s+\w+)?\.?$/i];function j0($){let Z=$.trim();if(Z.length<D7.MIN_LENGTH)return!1;if(Z.length>D7.MAX_LENGTH)return!1;if(ZB.some((z)=>z.test(Z)))return!1;if(/^[\s|\-*+]/.test(Z))return!1;if(Z.split(`
209
+ Run 'faf init' to create one.`),process.exit(2);let X=u(z),J=H0(X);if(Z.json){console.log(JSON.stringify(J,null,2));return}if(Z.status){console.log(`${i$(J.tier)} ${w(`${J.score}%`)}`);return}z0(J,z,Z.verbose)}import{existsSync as nB}from"fs";import{join as _7}from"path";var $0=[{index:1,path:"project.name",description:"Project name",category:"project"},{index:2,path:"project.goal",description:"Goal (use case)",category:"project"},{index:3,path:"project.main_language",description:"Primary language",category:"project"},{index:4,path:"human_context.who",description:"Who is this for?",category:"human"},{index:5,path:"human_context.what",description:"What are they building",category:"human"},{index:6,path:"human_context.why",description:"Why does it exist",category:"human"},{index:7,path:"human_context.where",description:"Where does it run",category:"human"},{index:8,path:"human_context.when",description:"When was it started / timeline",category:"human"},{index:9,path:"human_context.how",description:"How is it built",category:"human"},{index:10,path:"stack.frontend",canonical:"stack.framework",description:"Framework (React, Svelte, etc.)",category:"frontend"},{index:11,path:"stack.css_framework",canonical:"stack.css",description:"CSS framework",category:"frontend"},{index:12,path:"stack.ui_library",description:"UI component library",category:"frontend"},{index:13,path:"stack.state_management",canonical:"stack.state",description:"State management",category:"frontend"},{index:14,path:"stack.backend",description:"Backend framework",category:"backend"},{index:15,path:"stack.api_type",canonical:"stack.api",description:"API style (REST, GraphQL, etc.)",category:"backend"},{index:16,path:"stack.runtime",description:"Runtime (Node, Bun, Python, etc.)",category:"backend"},{index:17,path:"stack.database",canonical:"stack.db",description:"Database",category:"backend"},{index:18,path:"stack.connection",description:"Connection method (Prisma, etc.)",category:"backend"},{index:19,path:"stack.hosting",description:"Hosting platform",category:"universal"},{index:20,path:"stack.build",description:"Build tool",category:"universal"},{index:21,path:"stack.cicd",description:"CI/CD",category:"universal"},{index:22,path:"stack.monorepo_tool",description:"Monorepo tool",category:"enterprise_infra"},{index:23,path:"stack.package_manager",canonical:"stack.pkg_manager",description:"Package manager",category:"enterprise_infra"},{index:24,path:"stack.workspaces",description:"Workspace configuration",category:"enterprise_infra"},{index:25,path:"monorepo.packages_count",description:"Number of packages",category:"enterprise_infra"},{index:26,path:"monorepo.build_orchestrator",description:"Build orchestration tool",category:"enterprise_infra"},{index:27,path:"stack.admin",description:"Admin panel",category:"enterprise_app"},{index:28,path:"stack.cache",description:"Caching layer",category:"enterprise_app"},{index:29,path:"stack.search",description:"Search engine",category:"enterprise_app"},{index:30,path:"stack.storage",description:"Object storage",category:"enterprise_app"},{index:31,path:"monorepo.versioning_strategy",description:"Version strategy",category:"enterprise_ops"},{index:32,path:"monorepo.shared_configs",description:"Shared configs",category:"enterprise_ops"},{index:33,path:"monorepo.remote_cache",description:"Remote build cache",category:"enterprise_ops"}],Q7=new Map($0.flatMap(($)=>$.canonical?[[$.path,$],[$.canonical,$]]:[[$.path,$]])),YD=new Map($0.filter(($)=>$.canonical).map(($)=>[$.canonical,$.path])),UD=new Map($0.filter(($)=>$.canonical).map(($)=>[$.path,$.canonical]));function Y7($,Z){let z=(J)=>{let Q=J.split("."),Y=$;for(let U of Q)if(Y&&typeof Y==="object"&&U in Y)Y=Y[U];else return;return Y},X=z(Z.path);if(X!==void 0)return X;if(Z.canonical)return z(Z.canonical);return}var GD=$0.filter(($)=>$.index<=21);var i8=new Set(["describe your project goal","development teams","cloud platform","null","none","unknown","n/a","not applicable"]);function v0($){if($===null||$===void 0||$==="")return!0;if(typeof $==="string")return i8.has($.toLowerCase().trim());if(Array.isArray($)&&$.length===0)return!0;if(typeof $==="object"&&Object.keys($).length===0)return!0;return!1}var n$={about:[],documentation:["project","human"],intent:["project","human"],encyclopedia:["project","human"],cli:["project","human","universal"],library:["project","human","universal"],sdk:["project","human","universal"],wasm:["project","human","universal"],html:["project","human","universal"],"server-card":["project","human","universal"],frontend:["project","frontend","human","universal"],website:["project","frontend","human","universal"],mobile:["project","frontend","human","universal"],extension:["project","frontend","human","universal"],mcp:["project","backend","human","universal"],backend:["project","backend","universal","human"],"data-science":["project","backend","human","universal"],fullstack:["project","frontend","backend","universal","human"],svelte:["project","frontend","backend","universal","human"],framework:["project","frontend","backend","universal","human"],"monorepo-root":["project","human","enterprise_infra","enterprise_app","enterprise_ops"],mcpaas:["project","backend","universal","human","enterprise_app","enterprise_ops"],saas:["project","frontend","backend","universal","human","enterprise_app"],enterprise:["project","frontend","backend","universal","human","enterprise_infra","enterprise_app","enterprise_ops"]};import{existsSync as C,readFileSync as u0,readdirSync as G7}from"fs";import{join as P}from"path";var U7=[{name:"Next.js",slug:"nextjs",category:"frontend",signals:[{type:"dependency",key:"next"},{type:"file",pattern:"next.config.*"}]},{name:"React",slug:"react",category:"frontend",signals:[{type:"dependency",key:"react"}]},{name:"SvelteKit",slug:"sveltekit",category:"frontend",signals:[{type:"dependency",key:"@sveltejs/kit"},{type:"file",pattern:"svelte.config.*"}]},{name:"Svelte",slug:"svelte",category:"frontend",signals:[{type:"dependency",key:"svelte"},{type:"devDependency",key:"svelte"}]},{name:"Vue.js",slug:"vue",category:"frontend",signals:[{type:"dependency",key:"vue"}]},{name:"Nuxt",slug:"nuxt",category:"frontend",signals:[{type:"dependency",key:"nuxt"},{type:"file",pattern:"nuxt.config.*"}]},{name:"Angular",slug:"angular",category:"frontend",signals:[{type:"dependency",key:"@angular/core"},{type:"file",pattern:"angular.json"}]},{name:"Astro",slug:"astro",category:"frontend",signals:[{type:"dependency",key:"astro"},{type:"file",pattern:"astro.config.*"}]},{name:"Solid",slug:"solid",category:"frontend",signals:[{type:"dependency",key:"solid-js"}]},{name:"Remix",slug:"remix",category:"frontend",signals:[{type:"dependency",key:"@remix-run/react"}]},{name:"Gatsby",slug:"gatsby",category:"frontend",signals:[{type:"dependency",key:"gatsby"},{type:"file",pattern:"gatsby-config.*"}]},{name:"Qwik",slug:"qwik",category:"frontend",signals:[{type:"dependency",key:"@builder.io/qwik"}]},{name:"Vercel (SvelteKit)",slug:"adapter-vercel",category:"hosting",signals:[{type:"dependency",key:"@sveltejs/adapter-vercel"},{type:"devDependency",key:"@sveltejs/adapter-vercel"}]},{name:"Node (SvelteKit)",slug:"adapter-node",category:"hosting",signals:[{type:"dependency",key:"@sveltejs/adapter-node"},{type:"devDependency",key:"@sveltejs/adapter-node"}]},{name:"Static (SvelteKit)",slug:"adapter-static",category:"hosting",signals:[{type:"dependency",key:"@sveltejs/adapter-static"},{type:"devDependency",key:"@sveltejs/adapter-static"}]},{name:"Cloudflare (SvelteKit)",slug:"adapter-cloudflare",category:"hosting",signals:[{type:"dependency",key:"@sveltejs/adapter-cloudflare"},{type:"devDependency",key:"@sveltejs/adapter-cloudflare"}]},{name:"Netlify (SvelteKit)",slug:"adapter-netlify",category:"hosting",signals:[{type:"dependency",key:"@sveltejs/adapter-netlify"},{type:"devDependency",key:"@sveltejs/adapter-netlify"}]},{name:"Tailwind CSS",slug:"tailwind",category:"css",signals:[{type:"dependency",key:"tailwindcss"},{type:"devDependency",key:"tailwindcss"},{type:"file",pattern:"tailwind.config.*"}]},{name:"Bootstrap",slug:"bootstrap",category:"css",signals:[{type:"dependency",key:"bootstrap"}]},{name:"Styled Components",slug:"styled-components",category:"css",signals:[{type:"dependency",key:"styled-components"}]},{name:"shadcn/ui",slug:"shadcn",category:"ui",signals:[{type:"file",pattern:"components.json"},{type:"dependency",key:"@radix-ui/react-dialog"}]},{name:"Material UI",slug:"mui",category:"ui",signals:[{type:"dependency",key:"@mui/material"}]},{name:"Chakra UI",slug:"chakra",category:"ui",signals:[{type:"dependency",key:"@chakra-ui/react"}]},{name:"Ant Design",slug:"antd",category:"ui",signals:[{type:"dependency",key:"antd"}]},{name:"Redux",slug:"redux",category:"state",signals:[{type:"dependency",key:"@reduxjs/toolkit"}]},{name:"Zustand",slug:"zustand",category:"state",signals:[{type:"dependency",key:"zustand"}]},{name:"Jotai",slug:"jotai",category:"state",signals:[{type:"dependency",key:"jotai"}]},{name:"Pinia",slug:"pinia",category:"state",signals:[{type:"dependency",key:"pinia"}]},{name:"Express",slug:"express",category:"backend",signals:[{type:"dependency",key:"express"}]},{name:"Fastify",slug:"fastify",category:"backend",signals:[{type:"dependency",key:"fastify"}]},{name:"Hono",slug:"hono",category:"backend",signals:[{type:"dependency",key:"hono"}]},{name:"Elysia",slug:"elysia",category:"backend",signals:[{type:"dependency",key:"elysia"}]},{name:"NestJS",slug:"nestjs",category:"backend",signals:[{type:"dependency",key:"@nestjs/core"}]},{name:"Koa",slug:"koa",category:"backend",signals:[{type:"dependency",key:"koa"}]},{name:"Django",slug:"django",category:"backend",signals:[{type:"file",pattern:"manage.py"},{type:"file",pattern:"settings.py"}]},{name:"Flask",slug:"flask",category:"backend",signals:[{type:"file",pattern:"app.py"}]},{name:"FastAPI",slug:"fastapi",category:"backend",signals:[{type:"file",pattern:"main.py"}]},{name:"Rails",slug:"rails",category:"backend",signals:[{type:"file",pattern:"Gemfile"},{type:"file",pattern:"config/routes.rb"}]},{name:"Spring Boot",slug:"spring",category:"backend",signals:[{type:"file",pattern:"pom.xml"},{type:"file",pattern:"build.gradle"}]},{name:"Prisma",slug:"prisma",category:"database",signals:[{type:"dependency",key:"prisma"},{type:"devDependency",key:"prisma"},{type:"file",pattern:"prisma/schema.prisma"}]},{name:"Drizzle",slug:"drizzle",category:"database",signals:[{type:"dependency",key:"drizzle-orm"},{type:"file",pattern:"drizzle.config.*"}]},{name:"TypeORM",slug:"typeorm",category:"database",signals:[{type:"dependency",key:"typeorm"}]},{name:"Mongoose",slug:"mongoose",category:"database",signals:[{type:"dependency",key:"mongoose"}]},{name:"Vite",slug:"vite",category:"build",signals:[{type:"dependency",key:"vite"},{type:"devDependency",key:"vite"},{type:"file",pattern:"vite.config.*"}]},{name:"webpack",slug:"webpack",category:"build",signals:[{type:"dependency",key:"webpack"},{type:"devDependency",key:"webpack"},{type:"file",pattern:"webpack.config.*"}]},{name:"esbuild",slug:"esbuild",category:"build",signals:[{type:"dependency",key:"esbuild"},{type:"devDependency",key:"esbuild"}]},{name:"Turbopack",slug:"turbopack",category:"build",signals:[{type:"file",pattern:"turbo.json"}]},{name:"Jest",slug:"jest",category:"testing",signals:[{type:"devDependency",key:"jest"},{type:"file",pattern:"jest.config.*"}]},{name:"Vitest",slug:"vitest",category:"testing",signals:[{type:"devDependency",key:"vitest"}]},{name:"Playwright",slug:"playwright",category:"testing",signals:[{type:"devDependency",key:"@playwright/test"},{type:"file",pattern:"playwright.config.*"}]},{name:"Cypress",slug:"cypress",category:"testing",signals:[{type:"devDependency",key:"cypress"},{type:"file",pattern:"cypress.config.*"}]},{name:"Turborepo",slug:"turborepo",category:"monorepo",signals:[{type:"devDependency",key:"turbo"},{type:"file",pattern:"turbo.json"}]},{name:"Nx",slug:"nx",category:"monorepo",signals:[{type:"devDependency",key:"nx"},{type:"file",pattern:"nx.json"}]},{name:"Lerna",slug:"lerna",category:"monorepo",signals:[{type:"devDependency",key:"lerna"},{type:"file",pattern:"lerna.json"}]},{name:"MCP SDK",slug:"mcp",category:"ai",signals:[{type:"dependency",key:"@modelcontextprotocol/sdk"}]},{name:"Anthropic SDK",slug:"anthropic",category:"ai",signals:[{type:"dependency",key:"@anthropic-ai/sdk"}]},{name:"OpenAI SDK",slug:"openai",category:"ai",signals:[{type:"dependency",key:"openai"}]},{name:"LangChain",slug:"langchain",category:"ai",signals:[{type:"dependency",key:"langchain"}]},{name:"Vercel",slug:"vercel",category:"hosting",signals:[{type:"file",pattern:"vercel.json"}]},{name:"Netlify",slug:"netlify",category:"hosting",signals:[{type:"file",pattern:"netlify.toml"}]},{name:"Docker",slug:"docker",category:"hosting",signals:[{type:"file",pattern:"Dockerfile"},{type:"file",pattern:"docker-compose.yml"}]},{name:"Cloudflare Workers",slug:"cloudflare",category:"hosting",signals:[{type:"file",pattern:"wrangler.toml"},{type:"dependency",key:"wrangler"}]},{name:"GitHub Actions",slug:"github-actions",category:"cicd",signals:[{type:"file",pattern:".github/workflows/*.yml"}]},{name:"Commander.js",slug:"commander",category:"cli",signals:[{type:"dependency",key:"commander"}]}];function uH($){let Z=P($,"Cargo.toml");if(!C(Z))return null;try{let X=u0(Z,"utf-8").match(/^\s*\[package\][\s\S]*?^\s*name\s*=\s*"([^"]+)"/m);return X?X[1]:null}catch{return null}}function mH($){let Z=P($,"Cargo.toml");if(!C(Z))return!1;try{let z=u0(Z,"utf-8");return/^\s*\[\[bin\]\]/m.test(z)}catch{return!1}}function cH($,Z){if(Z?.keywords?.some((X)=>/^sdk(?:\s|-|$)|\-sdk$/i.test(X)))return'package.json keywords contains "sdk"';if(Z?.name&&/(?:^|[-_/])sdk(?:[-_/]|$)/i.test(Z.name))return`package.json name "${Z.name}" → sdk`;let z=uH($);if(z&&/(?:^|[-_])sdk(?:[-_]|$)/i.test(z))return`Cargo.toml name "${z}" → sdk`;return null}function dH($){let Z=["manifest.json","public/manifest.json","src/manifest.json","app/manifest.json","extension/manifest.json","dist/manifest.json"];for(let z of Z){let X=P($,z);if(!C(X))continue;try{let J=JSON.parse(u0(X,"utf-8"));if(typeof J.manifest_version==="number")return`${z} manifest_version ${J.manifest_version} (browser extension)`}catch{}}return null}function pH($){let Z=/(numpy|pandas|jupyter|scikit-learn|sklearn|pytorch|tensorflow|matplotlib|scipy)/i,z=P($,"pyproject.toml");if(C(z))try{let Q=u0(z,"utf-8").match(Z);if(Q)return`pyproject.toml depends on ${Q[1]}`}catch{}let X=P($,"requirements.txt");if(C(X))try{let Q=u0(X,"utf-8").match(Z);if(Q)return`requirements.txt contains ${Q[1]}`}catch{}return null}function lH($,Z){let z=["react-native","expo","@capacitor/core","@ionic/core"];if(Z){for(let X of z)if(Z.dependencies?.[X]||Z.devDependencies?.[X])return`${X} dependency`}if(C(P($,"pubspec.yaml")))return"pubspec.yaml (Flutter)";if(C(P($,"ios"))&&C(P($,"android")))return"ios/ + android/ dirs";return null}function iH($,Z){let z=P($,"Cargo.toml");if(C(z))try{let J=u0(z,"utf-8");if(/crate-type\s*=\s*\[[^\]]*"cdylib"/.test(J))return'Cargo.toml crate-type = ["cdylib"]';if(/wasm-bindgen|wasm-pack/i.test(J))return"Cargo.toml wasm-bindgen/wasm-pack"}catch{}let X=P($,"build.zig");if(C(X))try{let J=u0(X,"utf-8");if(/\.wasm\b|wasm32|setOutputFormat\(\.wasm/i.test(J))return"build.zig wasm target"}catch{}if(Z?.keywords?.some((J)=>/^wasm(?:-|$)|webassembly/i.test(J)))return'package.json keywords contains "wasm"';return null}function nH($,Z){if(!C(P($,"index.html")))return null;if(Z?.dependencies||Z?.devDependencies){let z={...Z.dependencies??{},...Z.devDependencies??{}};if(["react","vue","svelte","@sveltejs/kit","next","nuxt","astro","gatsby","solid-js","qwik"].some((J)=>z[J]))return null}return"index.html (vanilla, no frontend framework)"}function sH($,Z){if(Z?.name&&/specification|^@.*\/spec/i.test(Z.name))return`package name "${Z.name}" → documentation`;if(Z?.keywords?.some((z)=>/^(specification|format-spec|standard)$/i.test(z)))return'package keywords contains "specification"';if(Z?.files&&Z.files.length>0){let z=/^(dist|src|lib|build|bin)\/|\.(js|ts|tsx|jsx|mjs|cjs|py|rs|go)$/,X=Z.files.some((Q)=>z.test(Q)),J=Z.files.some((Q)=>/\.(md|MD)|examples?\//.test(Q));if(!X&&J)return"package.json files = docs/examples only (no source)"}return null}function rH($,Z,z){let X=z.find((J)=>J.slug==="astro"||J.slug==="gatsby");if(X)return`${X.name} (static-site framework)`;if(Z?.keywords?.some((J)=>/^(website|marketing|landing|brochure|portfolio)$/i.test(J)))return'package keywords contains "website"/"marketing"/"landing"';return null}function aH($,Z){if(!Z)return null;let z={...Z.dependencies??{},...Z.devDependencies??{}},X=["@clerk/nextjs","@clerk/clerk-react","next-auth","@auth/core","auth0","@auth0/nextjs-auth0"],J=["stripe","@stripe/stripe-js","lemonsqueezy"],Q=X.some((U)=>z[U]),Y=J.some((U)=>z[U]);if(Q&&Y)return"auth + payment dependencies";return null}function oH($,Z,z){if(Z?.keywords?.some((Q)=>/mcpaas/i.test(Q)))return'package keywords contains "mcpaas"';if(Z?.name&&/mcpaas/i.test(Z.name))return`package name "${Z.name}" → mcpaas`;let X=z.some((Q)=>Q.slug==="mcp"),J=z.some((Q)=>Q.category==="database");if(X&&J&&Z?.dependencies&&Object.keys(Z.dependencies).length>10)return"MCP + database + complex deps (platform shape)";return null}function tH($,Z){if(!Z?.private)return null;if(!(!!Z.workspaces||C(P($,"pnpm-workspace.yaml"))))return null;return"private workspace + multi-package"}function A$($){let Z=P($,"package.json");if(!C(Z))return null;try{return JSON.parse(u0(Z,"utf-8"))}catch{return null}}function eH($,Z){if(!Z.includes("*"))return C(P($,Z));let z=Z.split("/");if(z.length===1){let U=Z.split("*")[0];try{return G7($).some((G)=>G.startsWith(U))}catch{return!1}}let X=P($,...z.slice(0,-1)),J=z[z.length-1],Q=J.split("*")[0],Y=J.split("*")[1]||"";try{return G7(X).some((U)=>U.startsWith(Q)&&U.endsWith(Y))}catch{return!1}}function $B($,Z,z){switch($.type){case"dependency":return!!Z?.dependencies?.[$.key];case"devDependency":return!!Z?.devDependencies?.[$.key];case"file":return eH(z,$.pattern);default:return!1}}function n8($){let Z=A$($);return U7.map((z)=>{let J=z.signals.filter((Q)=>$B(Q,Z,$)).length/z.signals.length;return{name:z.name,slug:z.slug,category:z.category,confidence:J}}).filter((z)=>z.confidence>0).sort((z,X)=>X.confidence-z.confidence)}function W7($){let Z=A$($);if(Z?.devDependencies?.typescript||Z?.dependencies?.typescript)return"TypeScript";if(C(P($,"tsconfig.json")))return"TypeScript";if(C(P($,"Cargo.toml")))return"Rust";if(C(P($,"go.mod")))return"Go";if(C(P($,"pyproject.toml"))||C(P($,"setup.py")))return"Python";if(C(P($,"Gemfile")))return"Ruby";if(C(P($,"pom.xml"))||C(P($,"build.gradle")))return"Java";if(C(P($,"Package.swift")))return"Swift";if(C(P($,"build.zig")))return"Zig";if(Z)return"JavaScript";return"Unknown"}function q7($){let Z=A$($),z=n8($),X=[],J=sH($,Z);if(J)return X.push(J),{type:"documentation",found:X};let Q=cH($,Z);if(Q)return X.push(Q),{type:"sdk",found:X};let Y=dH($);if(Y)return X.push(Y),{type:"extension",found:X};let U=oH($,Z,z);if(U)return X.push(U),{type:"mcpaas",found:X};let G=aH($,Z);if(G)return X.push(G),{type:"saas",found:X};let W=iH($,Z);if(W)return X.push(W),{type:"wasm",found:X};let q=lH($,Z);if(q)return X.push(q),{type:"mobile",found:X};if(z.some((g)=>g.slug==="mcp"))return X.push("MCP SDK signal"),{type:"mcp",found:X};if(Z?.bin)return X.push("package.json bin"),{type:"cli",found:X};if(mH($))return X.push("Cargo.toml [[bin]]"),{type:"cli",found:X};if(C(P($,"build.zig"))){if(X.push("build.zig"),C(P($,"src/main.zig")))return X.push("src/main.zig"),{type:"cli",found:X};if(C(P($,"src/root.zig")))return X.push("src/root.zig"),{type:"library",found:X}}let K=z.some((g)=>g.slug==="svelte"||g.slug==="sveltekit");if(Z?.private===!0&&(C(P($,"pnpm-workspace.yaml"))||Z?.workspaces!==void 0)&&K)return X.push("private workspace","Svelte"),{type:"framework",found:X};if(K)return X.push("Svelte/SvelteKit"),{type:"svelte",found:X};let O=z.some((g)=>g.category==="frontend"),L=z.some((g)=>g.category==="backend");if(Z?.private&&(Z.workspaces||C(P($,"pnpm-workspace.yaml")))&&O&&L)return X.push("private workspace + frontend + backend frameworks"),{type:"enterprise",found:X};let M=tH($,Z);if(M)return X.push(M),{type:"monorepo-root",found:X};let F=rH($,Z,z);if(F)return X.push(F),{type:"website",found:X};if(z.some((g)=>g.slug==="nextjs"||g.slug==="nuxt"))return X.push(z.find((g)=>g.slug==="nextjs")?"Next.js":"Nuxt"),{type:"fullstack",found:X};let b=z.some((g)=>g.category==="frontend"),x=z.some((g)=>g.category==="backend");if(b&&x)return X.push("frontend framework","backend framework"),{type:"fullstack",found:X};if(b)return X.push("frontend framework"),{type:"frontend",found:X};if(x)return X.push("backend framework"),{type:"backend",found:X};let k=pH($);if(k)return X.push(k),{type:"data-science",found:X};let y=nH($,Z);if(y)return X.push(y),{type:"html",found:X};if(Z?.main&&!Z?.bin)return X.push("package.json main (no bin)"),{type:"library",found:X};return X.push("no classifying signals — fallback"),{type:"library",found:X}}function V7($){if(C(P($,"bunfig.toml")))return"Bun";if(C(P($,"deno.json"))||C(P($,"deno.jsonc")))return"Deno";if(A$($))return"Node.js";if(C(P($,"Cargo.toml")))return"Rust";if(C(P($,"go.mod")))return"Go";return"Unknown"}function K7($){if(C(P($,"bun.lockb"))||C(P($,"bun.lock")))return"bun";if(C(P($,"pnpm-lock.yaml")))return"pnpm";if(C(P($,"yarn.lock")))return"yarn";if(C(P($,"package-lock.json")))return"npm";return"npm"}function H7($){if(C(P($,".github/workflows")))return"GitHub Actions";if(C(P($,".gitlab-ci.yml")))return"GitLab CI";if(C(P($,".circleci")))return"CircleCI";if(C(P($,"Jenkinsfile")))return"Jenkins";return null}function B7($){if(C(P($,"vercel.json")))return"Vercel";if(C(P($,"netlify.toml")))return"Netlify";if(C(P($,"wrangler.toml")))return"Cloudflare";if(C(P($,"Dockerfile")))return"Docker";if(C(P($,"fly.toml")))return"Fly.io";if(C(P($,"render.yaml")))return"Render";return null}function L7($){let Z=P($,"svelte.config.js");if(!C(Z))return null;try{let X=u0(Z,"utf-8").match(/@sveltejs\/adapter-(\w+)/);if(X){let J=X[1];switch(J){case"vercel":return"Vercel";case"node":return"Node";case"static":return"Static";case"cloudflare":return"Cloudflare";case"netlify":return"Netlify";case"auto":return"Auto";default:return J}}return null}catch{return null}}function N7($){let Z=A$($);if(Z?.devDependencies?.vite||Z?.dependencies?.vite)return"Vite";if(Z?.devDependencies?.webpack||Z?.dependencies?.webpack)return"webpack";if(Z?.devDependencies?.esbuild||Z?.dependencies?.esbuild)return"esbuild";if(C(P($,"tsconfig.json"))&&Z?.devDependencies?.typescript)return"TypeScript (tsc)";return null}function M7($){return["package.json","Cargo.toml","pyproject.toml","go.mod","build.zig","build.zig.zon","src/index.ts","src/index.js","src/main.ts","src/cli.ts","src/main.rs","src/lib.rs","src/main.zig","src/root.zig","src/__init__.py","main.py","__main__.py","main.go","cmd/main.go","README.md","SPECIFICATION.md","BINARY-FORMAT.md","tsconfig.json","wrangler.toml","vercel.json"].filter((z)=>C(P($,z)))}function T7($,Z){let z={};if(Z?.scripts){for(let X of["build","test","lint","dev","start"])if(Z.scripts[X]){let J=C(P($,"bun.lock"))||C(P($,"bun.lockb"))?"bun run":"npm run";z[X]=`${J} ${X}`}}if(C(P($,"Cargo.toml"))){if(!z.build)z.build="cargo build --release";if(!z.test)z.test="cargo test";if(!z.lint)z.lint="cargo clippy"}if(C(P($,"build.zig"))){if(!z.build)z.build="zig build";if(!z.test)z.test="zig build test"}if(C(P($,"go.mod"))){if(!z.build)z.build="go build ./...";if(!z.test)z.test="go test ./..."}if(C(P($,"pyproject.toml"))||C(P($,"pytest.ini"))){if(!z.test)z.test="pytest"}return z}function O7($,Z,z,X){let J=[];if(X&&X!=="Unknown")J.push(X);let Q=new Set(["frontend","backend","database","build","css","state","monorepo"]);for(let Y of z)if(Q.has(Y.category))J.push(Y.name);if(C(P($,"bunfig.toml")))J.push("Bun");else if(C(P($,"deno.json"))||C(P($,"deno.jsonc")))J.push("Deno");if(J.length<3&&Z?.dependencies){let Y=Object.keys(Z.dependencies).slice(0,5);for(let U of Y)if(!J.some((G)=>G.toLowerCase().includes(U.toLowerCase())))J.push(U)}return J}function g2($){let Z=A$($),z=n8($),X=W7($),J=q7($),Q=J.type,Y=V7($),U=K7($),G=H7($),W=B7($),q=N7($),V=z.find((n)=>n.category==="frontend"),K=z.find((n)=>n.category==="css"),B=z.find((n)=>n.category==="ui"),O=z.find((n)=>n.category==="state"),L=z.find((n)=>n.category==="backend"),M=z.find((n)=>n.category==="database"),F=n$[Q]||n$.library,j=Q==="framework",b=z.some((n)=>n.slug==="svelte"||n.slug==="sveltekit"),x=j&&b?"svelte":j?null:null,k=Q==="svelte"||x==="svelte",y=k?L7($):null,g=k&&z.some((n)=>n.slug==="sveltekit"),E=new Set(["css_framework","ui_library","database","connection","hosting"]),m={},b0=$0.filter((n)=>n.path.startsWith("stack."));for(let n of b0){let o=n.path.replace("stack.","");if(!F.includes(n.category)){m[o]="slotignored";continue}if(j&&E.has(o)){m[o]="slotignored";continue}switch(o){case"frontend":m[o]=V?.name??(Q==="cli"?"CLI":"");break;case"css_framework":m[o]=K?.name??"";break;case"ui_library":m[o]=B?.name??"";break;case"state_management":m[o]=k?O?.name??"Runes":O?.name??"";break;case"backend":m[o]=k?g?"SvelteKit":L?.name??"":L?.name??"";break;case"api_type":m[o]=g?"Server Routes":"";break;case"runtime":m[o]=Y!=="Unknown"?Y:"";break;case"database":m[o]=M?.name??"";break;case"connection":m[o]=M?.name??"";break;case"hosting":if(k&&y)m[o]=y;else m[o]=W??"";break;case"build":m[o]=k?"Vite":q??"";break;case"cicd":m[o]=G??"";break;case"package_manager":m[o]=U;break;default:m[o]="";break}}let x0={},e=$0.filter((n)=>n.path.startsWith("monorepo."));for(let n of e){let o=n.path.replace("monorepo.","");if(!F.includes(n.category))x0[o]="slotignored";else x0[o]=""}let R1={name:Z?.name??$.split("/").pop()??"project",goal:Z?.description??"",main_language:X,type:Q};if(j&&x)R1.framework=x;let AZ=O7($,Z,z,X),RZ=M7($),FZ=T7($,Z),p4={faf_version:"2.5.0",project:R1,stack:m,human_context:{who:"",what:Z?.description??"",why:"",where:"",when:"",how:""},monorepo:x0,_meta:{found:J.found}};if(AZ.length>0)p4.tech_stack=AZ;if(RZ.length>0)p4.key_files=RZ;if(Object.keys(FZ).length>0)p4.commands=FZ;return p4}import{existsSync as zB,readFileSync as XB}from"fs";import{join as JB}from"path";var D7={MIN_LENGTH:8,MAX_LENGTH:280},ZB=[/^(see|see\s+the?)\s+readme/i,/^(tbd|todo|fixme|coming\s+soon)\b/i,/^(software|application|app|project|tool|library|framework)\.?$/i,/^(for\s+users|for\s+developers)\.?$/i,/^(description|goal|name|title)\.?$/i,/^lorem\s+ipsum/i,/^example(\s+\w+)?\.?$/i];function j0($){let Z=$.trim();if(Z.length<D7.MIN_LENGTH)return!1;if(Z.length>D7.MAX_LENGTH)return!1;if(ZB.some((z)=>z.test(Z)))return!1;if(/^[\s|\-*+]/.test(Z))return!1;if(Z.split(`
210
210
  `).length>4)return!1;return!0}function QB($){let Z=$.split(`
211
211
  `),z=0;while(z<Z.length&&/^(#\s|$)/.test(Z[z].trim()))z++;while(z<Z.length){let X=Z[z].trim();if(/^\[!\[/.test(X)){z++;continue}if(/^!\[/.test(X)){z++;continue}if(/^<img\s/i.test(X)){z++;continue}if(X===""){z++;continue}break}return Z.slice(z).join(`
212
212
  `)}function YB($){let z=QB($).split(`
@@ -217,7 +217,7 @@ new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
217
217
  `).replace(/<[^>]+>/g,"").replace(/!\[[^\]]*\]\([^)]*\)/g,"").trim()}function F$($){return $.replace(/\s+/g," ").replace(/[#*`>]/g,"").trim().slice(0,280)}function s$($,Z){let z=new RegExp(`##?\\s+(?:${Z})\\s*\\n+([\\s\\S]+?)(?:\\n\\n|\\n##?|$)`,"i"),X=$.match(z);return X&&X[1]&&X[1].trim().length>20?F$(X[1]):null}function o1($,Z,z=30){for(let X of Z){let J=$.match(X);if(J&&J[1]&&J[1].trim().length>=z)return F$(J[1])}return null}function yB($,Z){if($?.description&&$.description.length>20)return F$($.description);let z=s$(Z,"Purpose|What|About|Overview|Description");if(z)return z;let X=Z.split(/\n\s*\n/).map((J)=>J.trim()).find((J)=>J.length>30&&!J.startsWith("#"));if(X)return F$(X);return o1(Z,[/(?:core|main|primary)\s+(?:problem|challenge)(?:\s+is)?\s*:?\s*([^.\n]{30,})/i,/solves?\s+(?:the\s+)?(?:problem\s+of\s+)?([^.\n]{30,})/i])}function fB($){let Z=s$($,"Audience|Who|Who is this for|Who it.s for");if(Z)return Z;return o1($,[/\b(?:designed|built|made)\s+for\s+((?:developers?|teams?|engineers?|builders?|founders?)[^.\n]{0,80})/i,/\bfor\s+((?:developers?|teams?|engineers?|builders?|founders?)[^.\n]{0,80})/i],8)}function gB($){let Z=s$($,"Why|Mission|Motivation|Rationale|Vision");if(Z)return Z;return o1($,[/(?:our\s+)?(?:mission|purpose|goal)(?:\s+is)?\s*:?\s*([^.\n]{30,})/i,/(?:built|created|designed)\s+(?:because|to)\s+([^.\n]{30,})/i])}function hB($,Z){let z=typeof $?.repository==="string"?$.repository:$?.repository?.url;if(z)return F$(z.replace(/^git\+/,"").replace(/\.git$/,""));if($?.homepage)return F$($.homepage);return o1(Z,[/\b(?:deployed|hosted|available|published)\s+(?:on|at|via)\s+([^.\n]{4,80})/i],4)}function vB($){let Z=s$($,"Timeline|Status|Release|Roadmap");if(Z)return Z;return o1($,[/\b(production\s+since\s+[^.\n]{4,60})/i,/\b((?:in\s+)?(?:production|beta|alpha|development)\s+since\s+[^.\n]{4,60})/i,/\bsince\s+((?:[A-Z][a-z]+\s+)?\d{4}[^.\n]{0,40})/],4)}function uB($,Z){let z=$?.scripts?Object.keys($.scripts):[],X=["start","dev","build"].filter((Q)=>z.includes(Q));if(X.length)return F$(X.map((Q)=>`npm run ${Q}`).join(", "));let J=s$(Z,"Usage|Getting Started|Install|Installation|Quick Start");if(J)return J;return s$(Z,"Architecture|Approach|How it works|Methodology|How")}function r$($){let Z=g2($),z=h2($),X=m0(Z,z);mB(X);let J=m0(X,v2($));return m0(J,{human_context:u2($)})}function mB($){let Z=$.project?.type??"library",z=n$[Z]||n$.library;for(let X of $0){if(z.includes(X.category))continue;let[J,Q]=X.path.split(".");if(J==="stack"&&$.stack)$.stack[Q]="slotignored";if(J==="monorepo"&&$.monorepo)$.monorepo[Q]="slotignored"}}function m0($,Z){let z={...$};for(let[X,J]of Object.entries(Z)){let Q=z[X];if(v0(Q))z[X]=J;else if(typeof J==="object"&&J!==null&&!Array.isArray(J)&&typeof Q==="object"&&Q!==null&&!Array.isArray(Q))z[X]=m0(Q,J)}return z}import{existsSync as P7,readFileSync as cB,writeFileSync as dB}from"fs";import{join as pB,basename as lB}from"path";import{createHash as iB}from"crypto";class c0{projectPath;dnaPath;dna=null;constructor($){this.projectPath=$,this.dnaPath=pB($,".faf-dna")}exists(){return P7(this.dnaPath)}birth($){let Z=new Date().toISOString();return this.dna={birthCertificate:{born:Z,birthDNA:$,birthDNASource:"init",projectDNA:this.generateProjectDNA(),certificate:this.generateCertificate()},versions:[{version:"v1.0.0",timestamp:Z,score:$,changes:["Birth — initial context"],growth:0}],current:{version:"v1.0.0",score:$,lastSync:Z},growth:{totalGrowth:0,daysActive:0,milestones:[{type:"birth",score:$,date:Z,version:"v1.0.0",label:"Birth",emoji:"\uD83D\uDC23"}]},lastModified:Z,format:"faf-dna-v1"},this.save(),this.dna}recordGrowth($,Z){if(!this.dna&&!this.load())return null;let z=this.dna;if($===z.current.score)return z;let X=new Date().toISOString(),J=z.birthCertificate.birthDNA,Q=$-J,Y=this.incrementVersion(z.versions[z.versions.length-1].version);return z.versions.push({version:Y,timestamp:X,score:$,changes:Z,growth:Q}),z.current={version:Y,score:$,lastSync:X},z.growth.totalGrowth=Q,z.growth.daysActive=this.daysSince(z.birthCertificate.born),this.updateMilestones($,Y,X),this.save(),z}getJourney(){if(!this.dna&&!this.load())return"";let $=this.dna,Z=$.birthCertificate.birthDNA,z=$.growth.milestones.find((Q)=>Q.type==="peak"),X=$.current.score,J=`${Z}%`;if(z&&z.score!==Z){if(J+=` → ${z.score}%`,X<z.score)J+=` ← ${X}%`}else if(X!==Z)J+=` → ${X}%`;return J}getBirthDNADisplay(){if(!this.dna&&!this.load())return null;let $=this.dna;return{current:$.current.score,birthDNA:$.birthCertificate.birthDNA,growth:$.current.score-$.birthCertificate.birthDNA,born:$.birthCertificate.born}}getLog(){if(!this.dna&&!this.load())return[];return this.dna.versions.map(($)=>{let Z=$.growth>50?"\uD83D\uDE80":$.growth>20?"\uD83D\uDCC8":"\uD83D\uDCCA";return`${$.version} — ${$.score}% ${Z} (${$.timestamp.split("T")[0]}) ${$.changes.join(", ")}`})}load(){if(this.dna)return this.dna;if(!P7(this.dnaPath))return null;try{return this.dna=JSON.parse(cB(this.dnaPath,"utf-8")),this.dna}catch{return null}}save(){if(!this.dna)return;this.dna.lastModified=new Date().toISOString(),dB(this.dnaPath,JSON.stringify(this.dna,null,2)+`
218
218
  `,"utf-8")}generateProjectDNA(){return iB("sha256").update([this.projectPath,Date.now().toString(),Math.random().toString(36)].join(":")).digest("hex").substring(0,16)}generateCertificate(){let $=new Date().getFullYear(),Z=Math.random().toString(36).substring(2,6).toUpperCase(),z=lB(this.projectPath).replace(/[^A-Z0-9]/gi,"").toUpperCase().substring(0,8).padEnd(4,"X");return`FAF-${$}-${z}-${Z}`}incrementVersion($){let[Z,z,X]=$.replace("v","").split(".").map(Number);return`v${Z}.${z}.${X+1}`}daysSince($){return Math.floor((Date.now()-new Date($).getTime())/86400000)}updateMilestones($,Z,z){if(!this.dna)return;let X=this.dna.growth.milestones,J=(G)=>X.some((W)=>W.type===G),Q=(G,W,q)=>X.push({type:G,score:$,date:z,version:Z,label:W,emoji:q});if($>=this.dna.birthCertificate.birthDNA*2&&$>0&&!J("doubled"))Q("doubled","Doubled","2️⃣");if($>=70&&!J("championship"))Q("championship","Championship","\uD83C\uDFC6");if($>=85&&!J("elite"))Q("elite","Elite","◆");if($>=100&&!J("perfect"))Q("perfect","Perfect","\uD83C\uDFC6");let Y=X.find((G)=>G.type==="peak");if(!Y||$>Y.score){if(Y)X.splice(X.indexOf(Y),1);Q("peak","Peak","\uD83C\uDFD4️")}let U=X.findIndex((G)=>G.type==="current");if(U>=0)X.splice(U,1);Q("current","Current","\uD83D\uDCCD")}}d();function t8($={}){let Z=process.cwd(),z=$.output?$.output.endsWith(".faf")?$.output:_7(Z,$.output):_7(Z,"project.faf");if(nB(z)&&!$.force)console.error(`project.faf already exists. Use ${w("--force")} to overwrite.`),process.exit(1);let X=r$(Z);r(z,X);let J=u(z),Q=H0(J),Y=new c0(Z);if(!Y.exists()||$.force)Y.birth(Q.score);if(console.log(`${D("created")} ${z}`),z0(Q,z),console.log(N(` \uD83E\uDDEC Birth DNA ${Q.score}% — your journey starts here (faf dna)`)),Q.score<100)console.log(N(`
219
219
  run ${w("'faf go'")} to fill empty slots`))}d();function C7(){let $=new c0(process.cwd());if(!$.load())console.error(`${w("×")} No FAF DNA found. Run ${w("'faf init'")} to start your journey.`),process.exit(1);let Z=$.getJourney(),z=$.getBirthDNADisplay(),X=z.born.split("T")[0];console.log(),console.log(V0(w("\uD83E\uDDEC YOUR FAF DNA"))),console.log(),console.log(` ${D(w(Z))}`),console.log(),console.log(N(` Birth DNA ${z.birthDNA}% (born ${X}) · current ${z.current}% · growth ${z.growth>=0?"+":""}${z.growth}%`));let J=$.getLog();if(J.length>1){console.log(),console.log(N(" history:"));for(let Q of J)console.log(N(` ${Q}`))}console.log()}import{existsSync as sB}from"fs";import{join as rB}from"path";d();function E7(){let $=process.cwd(),Z=rB($,"project.faf");if(sB(Z)){let Q=l(Z),Y=m0(Q,h2($)),U=m0(Y,g2($)),G=m0(U,v2($)),W=m0(G,{human_context:u2($)});r(Z,W),console.log(`${D("updated")} ${Z}`)}else r(Z,r$($)),console.log(`${D("created")} ${Z}`);let z=u(Z),X=K0(W0(z)),J=new c0($);if(J.exists())J.recordGrowth(X.score,["faf auto"]);if(z0(X,Z),X.score<100)console.log(N(`
220
- run ${w("'faf go'")} to reach \uD83C\uDFC6 Trophy`))}import{existsSync as d2,statSync as g7}from"fs";import{join as h7,dirname as YL}from"path";import{readFileSync as ZL,existsSync as zL,statSync as RI}from"fs";import{join as S7}from"path";import{readFileSync as aB,writeFileSync as m2,existsSync as oB}from"fs";var tB="<!-- faf:start -->",eB="<!-- faf:end -->",$L="<!-- faf:";function Q$($,Z,z=tB,X=eB){let J=`${z}
220
+ run ${w("'faf go'")} to reach \uD83C\uDFC6 Trophy`))}import{existsSync as d2,statSync as g7}from"fs";import{join as h7,dirname as YL}from"path";import{readFileSync as ZL,existsSync as zL,statSync as FI}from"fs";import{join as S7}from"path";import{readFileSync as aB,writeFileSync as m2,existsSync as oB}from"fs";var tB="<!-- faf:start -->",eB="<!-- faf:end -->",$L="<!-- faf:";function Q$($,Z,z=tB,X=eB){let J=`${z}
221
221
  ${Z.trim()}
222
222
  ${X}`;if(!oB($)){m2($,`${J}
223
223
  `,"utf-8");return}let Q=aB($,"utf-8"),Y=Q.indexOf(z),U=Q.indexOf(X);if(Y!==-1&&U!==-1&&U>Y){let G=Q.slice(0,Y),W=Q.slice(U+X.length);m2($,`${G}${J}${W}`,"utf-8");return}if(Q.trimStart().startsWith($L)){m2($,`${J}
@@ -225,7 +225,7 @@ ${X}`;if(!oB($)){m2($,`${J}
225
225
 
226
226
  ${Q}`,"utf-8")}var b7="CLAUDE.md",XL="STATUS: BI-SYNC ACTIVE";function x7($){let Z=S7($,b7);if(!zL(Z))return null;return ZL(Z,"utf-8")}function k7($,Z){Q$(S7($,b7),Z)}function w$($,Z={}){let z=String($.project?.name??"").trim(),X=String($.project?.main_language??"").trim(),J=String($.project?.type??"").trim(),Q=String($.project?.goal??"").trim(),Y=`<!-- faf: ${[z,X,J,Q].join(" | ")} -->`,U=[];if(Z.doc)U.push(`doc=${Z.doc}`);else U.push(`claim=${Z.claim??"project.faf"}`);if(typeof Z.score==="number")U.push(`score=${Z.score}`);if(U.push(`family=${Z.family??"FAF"}`),Z.siblings&&Z.siblings.length>0)U.push(`siblings=${Z.siblings.join(",")}`);let G=`<!-- faf: ${U.join(" | ")} -->`;return`${Y}
227
227
  ${G}`}function y7($){let Z=[],z=$.project?.name??"Project",X=$.project?.main_language??"",J=$.project?.goal??"";if(Z.push(w$($)),Z.push(""),Z.push(`# CLAUDE.md — ${z}`),Z.push(""),J)Z.push("## What This Is"),Z.push(""),Z.push(J),Z.push("");let Q=$.stack??{},Y=[];if(X)Y.push(`**Language:** ${X}`);for(let[W,q]of Object.entries(Q))if(q&&q!=="slotignored"&&String(q).trim()){let V=W.replace(/_/g," ").replace(/\b\w/g,(K)=>K.toUpperCase());Y.push(`**${V}:** ${q}`)}if(Y.length>0){Z.push("## Stack"),Z.push("");for(let W of Y)Z.push(`- ${W}`);Z.push("")}let U=$.human_context??{},G=[["Who",U.who],["What",U.what],["Why",U.why],["Where",U.where],["When",U.when],["How",U.how]].filter(([W,q])=>q&&String(q).trim());if(G.length>0){Z.push("## Context"),Z.push("");for(let[W,q]of G)Z.push(`- **${W}:** ${q}`);Z.push("")}return Z.push("---"),Z.push(""),Z.push(`*${XL} — ${new Date().toISOString()}*`),Z.push(""),Z.join(`
228
- `)}function j7($){return $.replace(/\s+v\d+(?:\.\d+)*\s*$/i,"").trim()}function c2($){let Z={project:{}},z=$.match(/^# CLAUDE\.md\s*[—–-]\s*(.+)$/m);if(z)Z.project.name=j7(z[1].trim());if(!Z.project.name){let Q=$.match(/\*\*Name:\*\*\s*(.+)/);if(Q)Z.project.name=j7(Q[1].trim())}let X=$.match(/## What This Is\s*\n\s*\n(.+)/);if(X)Z.project.goal=X[1].trim();if(!Z.project.goal){let Q=$.match(/\*\*What Building:\*\*\s*(.+)/);if(Q)Z.project.goal=Q[1].trim()}let J=$.match(/\*\*Language:\*\*\s*(.+)/);if(J)Z.project.main_language=J[1].trim();if(!Z.project.main_language){let Q=$.match(/\*\*Main Language:\*\*\s*(.+)/);if(Q)Z.project.main_language=Q[1].trim()}return Z}import{readFileSync as CI,writeFileSync as JL,existsSync as EI}from"fs";import{join as QL}from"path";function f7($,Z){JL(QL($,"MEMORY.md"),Z,"utf-8")}d();function a$(){return process.env.FAF_PRO==="1"||process.env.FAF_PRO==="true"}function e8($={}){let Z=process.cwd(),z=v(Z);if(!z)console.error(`Error: project.faf not found
228
+ `)}function j7($){return $.replace(/\s+v\d+(?:\.\d+)*\s*$/i,"").trim()}function c2($){let Z={project:{}},z=$.match(/^# CLAUDE\.md\s*[—–-]\s*(.+)$/m);if(z)Z.project.name=j7(z[1].trim());if(!Z.project.name){let Q=$.match(/\*\*Name:\*\*\s*(.+)/);if(Q)Z.project.name=j7(Q[1].trim())}let X=$.match(/## What This Is\s*\n\s*\n(.+)/);if(X)Z.project.goal=X[1].trim();if(!Z.project.goal){let Q=$.match(/\*\*What Building:\*\*\s*(.+)/);if(Q)Z.project.goal=Q[1].trim()}let J=$.match(/\*\*Language:\*\*\s*(.+)/);if(J)Z.project.main_language=J[1].trim();if(!Z.project.main_language){let Q=$.match(/\*\*Main Language:\*\*\s*(.+)/);if(Q)Z.project.main_language=Q[1].trim()}return Z}import{readFileSync as EI,writeFileSync as JL,existsSync as jI}from"fs";import{join as QL}from"path";function f7($,Z){JL(QL($,"MEMORY.md"),Z,"utf-8")}d();function a$(){return process.env.FAF_PRO==="1"||process.env.FAF_PRO==="true"}function e8($={}){let Z=process.cwd(),z=v(Z);if(!z)console.error(`Error: project.faf not found
229
229
 
230
230
  Run 'faf init' to create one.`),process.exit(2);let X=h7(Z,"CLAUDE.md"),J=h7(Z,"MEMORY.md"),Q=$.direction??"auto";if(Q==="auto")v7(z,X,Z);else if(Q==="push")u7(z,Z);else if(Q==="pull")UL(z,X);if(a$())m7(z,J,Z);if($.watch)console.log(N("watching for changes... (Ctrl+C to stop)")),WL(z,X,J,Z)}function v7($,Z,z){u7($,z)}function u7($,Z){let z=l($),X=y7(z);k7(Z,X),console.log(`${D("◆")} sync .faf → CLAUDE.md ${N("← bi-sync")}`);let J=K0(W0(u($)));z0(J,$)}function UL($,Z){let z=K0(W0(u($)));if(z.tier.name!=="TROPHY")console.error(`${w("×")} sync --pull blocked: requires \uD83C\uDFC6 Trophy (currently ${z.score}%)`),console.error(N(" MD → .faf backfill only runs at 100%. Reach Trophy with 'faf go', then retry.")),process.exit(1);let X=x7(YL(Z));if(!X){console.error("CLAUDE.md not found.");return}let J=c2(X),Q=l($);if(J.project?.name)Q.project={...Q.project,name:J.project.name};if(J.project?.goal)Q.project={...Q.project,goal:J.project.goal};if(J.project?.main_language)Q.project={...Q.project,main_language:J.project.main_language};r($,Q),console.log(`${D("◆")} sync CLAUDE.md → .faf ${N("← bi-sync (Trophy-gated)")}`);let Y=K0(W0(u($)));z0(Y,$)}function m7($,Z,z){let X=l($),J=g7($).mtimeMs,Q=d2(Z)?g7(Z).mtimeMs:0;if(!d2(Z)||J>Q){let Y=GL(X);f7(z,Y),console.log(`${D("◆")} sync .faf → MEMORY.md ${N("← tri-sync")}`)}else console.log(`${D("◆")} sync MEMORY.md → .faf ${N("← tri-sync")}`)}function GL($){let Z=$.project??{},z=[`# ${Z.name??"Project"} — Memory Topics`,"","> Generated by faf sync (tri-sync)",""];if(Z.name)z.push(`- **Project:** ${Z.name}`);if(Z.goal)z.push(`- **Goal:** ${Z.goal}`);if(Z.main_language)z.push(`- **Language:** ${Z.main_language}`);if(Z.type)z.push(`- **Type:** ${Z.type}`);return z.join(`
231
231
  `)+`
@@ -317,41 +317,41 @@ Rendered on-demand from your current <strong>${o$(z)}</strong><br>
317
317
  </div>
318
318
  </body>
319
319
  </html>
320
- `}function l2($,Z,z,X="project.faf"){RL(FL($,"project.html"),SL(Z,z,X),"utf-8")}import{writeFileSync as bL}from"fs";import{join as xL}from"path";var Zz="application/vnd.faf+yaml",kL="https://static.modelcontextprotocol.io/schemas/v1/server-card.schema.json",yL=/^[a-zA-Z0-9.-]+\/[a-zA-Z0-9._-]+$/;function fL($){let Z=String($.project?.name??"project").trim();if(Z.includes("/")&&yL.test(Z))return Z;let z=$.project?.homepage??$.project?.website??$.project?.url,X="local";if(z)try{X=new URL(z).hostname.replace(/^www\./,"").split(".").reverse().join(".")}catch{}let J=Z.replace(/[^a-zA-Z0-9._-]/g,"-").replace(/^-+|-+$/g,"")||"project";return`${X}/${J}`}function gL($){let Z=String($.project?.goal??$.context??$.project?.name??"MCP server").replace(/\s+/g," ").trim();if(!Z)return"MCP server";return Z.length<=100?Z:Z.slice(0,97).trimEnd()+"..."}function hL($,Z={}){let z={$schema:kL,name:fL($),version:String($.project?.version??"0.1.0"),description:gL($)},X=$.project?.name;if(X&&X.length<=100)z.title=X;let J=$.project?.homepage??$.project?.website??$.project?.url;if(J)z.websiteUrl=J;if(Z.remoteUrl)z.remotes=[{type:"streamable-http",url:Z.remoteUrl}];return z._meta={"one.faf/context":{faf:Z.fafPointer??"./project.faf",mediaType:Zz,iana:`https://www.iana.org/assignments/media-types/${Zz}`,deterministic:!0,generated:$.generated??Z.now??new Date().toISOString()}},z}function zz($,Z,z={}){let X=hL(Z,z),J=xL($,"server-card");return bL(J,JSON.stringify(X,null,2)+`
320
+ `}function l2($,Z,z,X="project.faf"){RL(FL($,"project.html"),SL(Z,z,X),"utf-8")}import{writeFileSync as bL}from"fs";import{join as xL}from"path";var Zz="application/vnd.faf+yaml",kL="https://static.modelcontextprotocol.io/schemas/v1/server-card.schema.json",yL=/^[a-zA-Z0-9.-]+\/[a-zA-Z0-9._-]+$/;function fL($){let Z=String($.project?.name??"project").trim();if(Z.includes("/")&&yL.test(Z))return Z;let z=$.project?.homepage??$.project?.website??$.project?.url,X="local";if(z)try{X=new URL(z).hostname.replace(/^www\./,"").split(".").reverse().join(".")}catch{}let J=Z.replace(/[^a-zA-Z0-9._-]/g,"-").replace(/^-+|-+$/g,"")||"project";return`${X}/${J}`}function gL($){let Z=String($.project?.goal??$.context??$.project?.name??"MCP server").replace(/\s+/g," ").trim();if(!Z)return"MCP server";return Z.length<=100?Z:Z.slice(0,97).trimEnd()+"..."}function hL($,Z={}){return{faf:Z.fafPointer??"./project.faf",mediaType:Zz,iana:`https://www.iana.org/assignments/media-types/${Zz}`,deterministic:!0,...Z.scoreEndpoint?{scoreEndpoint:Z.scoreEndpoint}:{},generated:$.generated??Z.now??new Date().toISOString()}}function vL($,Z={}){let z={$schema:kL,name:fL($),version:String($.project?.version??"0.1.0"),description:gL($)},X=$.project?.name;if(X&&X.length<=100)z.title=X;let J=$.project?.homepage??$.project?.website??$.project?.url;if(J)z.websiteUrl=J;if(Z.remoteUrl)z.remotes=[{type:"streamable-http",url:Z.remoteUrl}];return z._meta={"one.faf/context":hL($,Z)},z}function zz($,Z,z={}){let X=vL(Z,z),J=xL($,"server-card");return bL(J,JSON.stringify(X,null,2)+`
321
321
  `,"utf-8"),J}d();function t$($={}){let Z=v();if(!Z)console.error(`Error: project.faf not found
322
322
 
323
- Run 'faf init' to create one.`),process.exit(2);let z=process.cwd(),X=l(Z),J=$.all||!$.agents&&!$.cursor&&!$.gemini&&!$.grok&&!$.conductor&&!$.html&&!$.card;if(J||$.agents)l7(z,X),console.log(" AGENTS.md");if(J||$.cursor)i7(z,X),console.log(" .cursorrules");if(J||$.gemini)n7(z,X),console.log(" GEMINI.md");if($.grok){let Y=o7(z,X);console.log(` .grok/config.toml (${Y})`)}if(J||$.html){let Y=H0(u(Z));l2(z,X,Y,Z),console.log(" project.html")}let Q=X.app_type==="server-card"||X.project?.type==="server-card";if($.card||J&&Q){let Y=zz(z,X);console.log(` ${Y.replace(`${z}/`,"")}`)}console.log(`${D("exported")} ${N(`from ${Z}`)}`)}import{join as vL}from"path";import uL from"open";d();function mL($){if(process.env.CI)return!1;try{return uL($).catch(()=>{return}),!0}catch{return!1}}function Xz(){let $=v();if(!$)console.error(`Error: project.faf not found
323
+ Run 'faf init' to create one.`),process.exit(2);let z=process.cwd(),X=l(Z),J=$.all||!$.agents&&!$.cursor&&!$.gemini&&!$.grok&&!$.conductor&&!$.html&&!$.card;if(J||$.agents)l7(z,X),console.log(" AGENTS.md");if(J||$.cursor)i7(z,X),console.log(" .cursorrules");if(J||$.gemini)n7(z,X),console.log(" GEMINI.md");if($.grok){let Y=o7(z,X);console.log(` .grok/config.toml (${Y})`)}if(J||$.html){let Y=H0(u(Z));l2(z,X,Y,Z),console.log(" project.html")}let Q=X.app_type==="server-card"||X.project?.type==="server-card";if($.card||J&&Q){let Y=zz(z,X);console.log(` ${Y.replace(`${z}/`,"")}`)}console.log(`${D("exported")} ${N(`from ${Z}`)}`)}import{join as uL}from"path";import mL from"open";d();function cL($){if(process.env.CI)return!1;try{return mL($).catch(()=>{return}),!0}catch{return!1}}function Xz(){let $=v();if(!$)console.error(`Error: project.faf not found
324
324
 
325
- Run 'faf init' to create one.`),process.exit(2);let Z=process.cwd(),z=l($),X=H0(u($));l2(Z,z,X,$);let J=vL(Z,"project.html"),Q=mL(J);console.log(" project.html"),console.log(Q?`${D("opened")} ${N("in your browser")}`:`${D("rendered")} ${N(`file://${J}`)}`)}import{mkdirSync as cL,rmSync as dL}from"fs";import{join as Jz}from"path";import{execSync as pL}from"child_process";import{tmpdir as lL}from"os";d();function Qz($){if(!$)console.error(`Error: Please provide a GitHub URL.
325
+ Run 'faf init' to create one.`),process.exit(2);let Z=process.cwd(),z=l($),X=H0(u($));l2(Z,z,X,$);let J=uL(Z,"project.html"),Q=cL(J);console.log(" project.html"),console.log(Q?`${D("opened")} ${N("in your browser")}`:`${D("rendered")} ${N(`file://${J}`)}`)}import{mkdirSync as dL,rmSync as pL}from"fs";import{join as Jz}from"path";import{execSync as lL}from"child_process";import{tmpdir as iL}from"os";d();function Qz($){if(!$)console.error(`Error: Please provide a GitHub URL.
326
326
 
327
- Usage: faf git <url>`),process.exit(1);let Z=$.endsWith(".git")?$:`${$}.git`,z=Jz(lL(),`faf-git-${Date.now()}`);cL(z,{recursive:!0});try{console.log(N(`cloning ${$}...`));try{pL(`git clone --depth 1 ${Z} ${z}`,{stdio:"pipe"})}catch(U){let W=(U?.stderr?.toString()??"").trim().split(`
327
+ Usage: faf git <url>`),process.exit(1);let Z=$.endsWith(".git")?$:`${$}.git`,z=Jz(iL(),`faf-git-${Date.now()}`);dL(z,{recursive:!0});try{console.log(N(`cloning ${$}...`));try{lL(`git clone --depth 1 ${Z} ${z}`,{stdio:"pipe"})}catch(U){let W=(U?.stderr?.toString()??"").trim().split(`
328
328
  `).slice(-2).join(" ").trim()||"git clone failed";console.error(`Error: could not clone ${$}
329
329
 
330
- ${W}`),process.exit(1)}let X=r$(z),J=Jz(process.cwd(),"project.faf");r(J,X),console.log(`${D("created")} ${J}`);let Q=u(J),Y=K0(W0(Q));z0(Y,J)}finally{dL(z,{recursive:!0,force:!0})}}d();function Yz($={}){if($.version||Object.keys($).length===0)nL()}function nL(){let $=Z3();console.log(`${D(w("faf"))} v${$.version}`),console.log(N(`kernel ${J7()} IANA application/vnd.faf+yaml`))}var t1=[{name:"HTML",extensions:[".html",".htm"],category:"web"},{name:"CSS",extensions:[".css"],category:"web"},{name:"JavaScript",extensions:[".js",".mjs",".cjs"],category:"web"},{name:"TypeScript",extensions:[".ts",".tsx",".mts",".cts"],category:"web"},{name:"JSX",extensions:[".jsx"],category:"web"},{name:"Vue",extensions:[".vue"],category:"web"},{name:"Svelte",extensions:[".svelte"],category:"web"},{name:"Astro",extensions:[".astro"],category:"web"},{name:"JSON",extensions:[".json"],category:"data"},{name:"YAML",extensions:[".yml",".yaml"],category:"data"},{name:"TOML",extensions:[".toml"],category:"data"},{name:"XML",extensions:[".xml"],category:"data"},{name:"CSV",extensions:[".csv"],category:"data"},{name:"INI",extensions:[".ini",".cfg"],category:"config"},{name:"Env",extensions:[".env"],category:"config"},{name:"Dockerfile",extensions:["Dockerfile"],category:"config"},{name:"Rust",extensions:[".rs"],category:"systems"},{name:"Go",extensions:[".go"],category:"systems"},{name:"C",extensions:[".c",".h"],category:"systems"},{name:"C++",extensions:[".cpp",".cc",".hpp"],category:"systems"},{name:"Zig",extensions:[".zig"],category:"systems"},{name:"Python",extensions:[".py"],category:"scripting"},{name:"Ruby",extensions:[".rb"],category:"scripting"},{name:"Shell",extensions:[".sh",".bash",".zsh"],category:"scripting"},{name:"Lua",extensions:[".lua"],category:"scripting"},{name:"Java",extensions:[".java"],category:"jvm"},{name:"Kotlin",extensions:[".kt",".kts"],category:"jvm"},{name:"Scala",extensions:[".scala"],category:"jvm"},{name:"C#",extensions:[".cs"],category:"dotnet"},{name:"F#",extensions:[".fs"],category:"dotnet"},{name:"Swift",extensions:[".swift"],category:"mobile"},{name:"Dart",extensions:[".dart"],category:"mobile"},{name:"Markdown",extensions:[".md",".mdx"],category:"docs"},{name:"LaTeX",extensions:[".tex"],category:"docs"},{name:"reStructuredText",extensions:[".rst"],category:"docs"},{name:"FAF",extensions:[".faf"],category:"faf"},{name:"FAFb",extensions:[".fafb"],category:"faf"}];d();function Uz(){console.log(`${D("formats")} ${N("— supported file types")}
331
- `);let $=new Map;for(let Z of t1){let z=$.get(Z.category)??[];z.push(Z),$.set(Z.category,z)}for(let[Z,z]of $){console.log(` ${w(Z)}`);for(let X of z)console.log(` ${X.name} ${N(X.extensions.join(", "))}`);console.log()}console.log(N(` ${t1.length} formats across ${$.size} categories`))}d();import{readdirSync as sL,rmSync as rL}from"fs";import{tmpdir as aL}from"os";import{join as oL}from"path";function Gz(){let $=aL(),Z=0;try{let z=sL($);for(let X of z)if(X.startsWith("faf-git-"))rL(oL($,X),{recursive:!0,force:!0}),Z++}catch{}if(Z>0)console.log(`${D("cleared")} ${Z} cached director${Z===1?"y":"ies"}`);else console.log(N("nothing to clear"))}function Wz($={}){let Z=v();if(!Z)console.error(`Error: project.faf not found
330
+ ${W}`),process.exit(1)}let X=r$(z),J=Jz(process.cwd(),"project.faf");r(J,X),console.log(`${D("created")} ${J}`);let Q=u(J),Y=K0(W0(Q));z0(Y,J)}finally{pL(z,{recursive:!0,force:!0})}}d();function Yz($={}){if($.version||Object.keys($).length===0)sL()}function sL(){let $=Z3();console.log(`${D(w("faf"))} v${$.version}`),console.log(N(`kernel ${J7()} IANA application/vnd.faf+yaml`))}var t1=[{name:"HTML",extensions:[".html",".htm"],category:"web"},{name:"CSS",extensions:[".css"],category:"web"},{name:"JavaScript",extensions:[".js",".mjs",".cjs"],category:"web"},{name:"TypeScript",extensions:[".ts",".tsx",".mts",".cts"],category:"web"},{name:"JSX",extensions:[".jsx"],category:"web"},{name:"Vue",extensions:[".vue"],category:"web"},{name:"Svelte",extensions:[".svelte"],category:"web"},{name:"Astro",extensions:[".astro"],category:"web"},{name:"JSON",extensions:[".json"],category:"data"},{name:"YAML",extensions:[".yml",".yaml"],category:"data"},{name:"TOML",extensions:[".toml"],category:"data"},{name:"XML",extensions:[".xml"],category:"data"},{name:"CSV",extensions:[".csv"],category:"data"},{name:"INI",extensions:[".ini",".cfg"],category:"config"},{name:"Env",extensions:[".env"],category:"config"},{name:"Dockerfile",extensions:["Dockerfile"],category:"config"},{name:"Rust",extensions:[".rs"],category:"systems"},{name:"Go",extensions:[".go"],category:"systems"},{name:"C",extensions:[".c",".h"],category:"systems"},{name:"C++",extensions:[".cpp",".cc",".hpp"],category:"systems"},{name:"Zig",extensions:[".zig"],category:"systems"},{name:"Python",extensions:[".py"],category:"scripting"},{name:"Ruby",extensions:[".rb"],category:"scripting"},{name:"Shell",extensions:[".sh",".bash",".zsh"],category:"scripting"},{name:"Lua",extensions:[".lua"],category:"scripting"},{name:"Java",extensions:[".java"],category:"jvm"},{name:"Kotlin",extensions:[".kt",".kts"],category:"jvm"},{name:"Scala",extensions:[".scala"],category:"jvm"},{name:"C#",extensions:[".cs"],category:"dotnet"},{name:"F#",extensions:[".fs"],category:"dotnet"},{name:"Swift",extensions:[".swift"],category:"mobile"},{name:"Dart",extensions:[".dart"],category:"mobile"},{name:"Markdown",extensions:[".md",".mdx"],category:"docs"},{name:"LaTeX",extensions:[".tex"],category:"docs"},{name:"reStructuredText",extensions:[".rst"],category:"docs"},{name:"FAF",extensions:[".faf"],category:"faf"},{name:"FAFb",extensions:[".fafb"],category:"faf"}];d();function Uz(){console.log(`${D("formats")} ${N("— supported file types")}
331
+ `);let $=new Map;for(let Z of t1){let z=$.get(Z.category)??[];z.push(Z),$.set(Z.category,z)}for(let[Z,z]of $){console.log(` ${w(Z)}`);for(let X of z)console.log(` ${X.name} ${N(X.extensions.join(", "))}`);console.log()}console.log(N(` ${t1.length} formats across ${$.size} categories`))}d();import{readdirSync as rL,rmSync as aL}from"fs";import{tmpdir as oL}from"os";import{join as tL}from"path";function Gz(){let $=oL(),Z=0;try{let z=rL($);for(let X of z)if(X.startsWith("faf-git-"))aL(tL($,X),{recursive:!0,force:!0}),Z++}catch{}if(Z>0)console.log(`${D("cleared")} ${Z} cached director${Z===1?"y":"ies"}`);else console.log(N("nothing to clear"))}function Wz($={}){let Z=v();if(!Z)console.error(`Error: project.faf not found
332
332
 
333
333
  Run 'faf init' to create one.`),process.exit(2);if($.json){let z=l(Z);console.log(JSON.stringify(z,null,2))}else{let z=u(Z);console.log(z)}}d();function qz(){let $=v();if(!$)console.error(`Error: project.faf not found
334
334
 
335
335
  Run 'faf init' to create one.`),process.exit(2);let Z=l($),z=[];for(let X of $0){let[J,Q]=X.path.split("."),U=Z[J]?.[Q];if(v0(U)||U==="slotignored")continue;z.push(`${X.path}: ${U}`)}if(z.length===0){console.log(N("no populated slots"));return}console.log(z.join(`
336
- `))}import{existsSync as tL,statSync as Vz}from"fs";import{join as eL}from"path";d();var $N=["CLAUDE.md","AGENTS.md",".cursorrules","GEMINI.md"];function Kz(){let $=v();if(!$)console.error(`Error: project.faf not found
336
+ `))}import{existsSync as eL,statSync as Vz}from"fs";import{join as $N}from"path";d();var ZN=["CLAUDE.md","AGENTS.md",".cursorrules","GEMINI.md"];function Kz(){let $=v();if(!$)console.error(`Error: project.faf not found
337
337
 
338
338
  Run 'faf init' to create one.`),process.exit(2);let Z=process.cwd(),z=Vz($).mtimeMs;console.log(`${D("drift")} ${N("— context file sync status")}
339
- `),console.log(` ${w(".faf")} ${N(z3(z))}`);let X=0;for(let J of $N){let Q=eL(Z,J);if(!tL(Q)){console.log(` ${N("○")} ${J} ${N("missing")}`);continue}let Y=Vz(Q).mtimeMs,U=Y-z;if(Math.abs(U)<1000)console.log(` ${D("●")} ${J} ${N("in sync")}`);else if(U>0)console.log(` ${w("!")} ${J} ${w("newer")} ${N(z3(Y))}`),X++;else console.log(` ${N("○")} ${J} ${N("older")} ${N(z3(Y))}`),X++}if(X>0)console.log(N(`
339
+ `),console.log(` ${w(".faf")} ${N(z3(z))}`);let X=0;for(let J of ZN){let Q=$N(Z,J);if(!eL(Q)){console.log(` ${N("○")} ${J} ${N("missing")}`);continue}let Y=Vz(Q).mtimeMs,U=Y-z;if(Math.abs(U)<1000)console.log(` ${D("●")} ${J} ${N("in sync")}`);else if(U>0)console.log(` ${w("!")} ${J} ${w("newer")} ${N(z3(Y))}`),X++;else console.log(` ${N("○")} ${J} ${N("older")} ${N(z3(Y))}`),X++}if(X>0)console.log(N(`
340
340
  run ${w("'faf sync'")} to resolve drift`))}function z3($){let Z=Date.now()-$,z=Math.floor(Z/1000);if(z<60)return`${z}s ago`;let X=Math.floor(z/60);if(X<60)return`${X}m ago`;let J=Math.floor(X/60);if(J<24)return`${J}h ago`;return`${Math.floor(J/24)}d ago`}d();function Hz($,Z){if(!$||Z===void 0)console.error(`Usage: faf edit <path> <value>
341
341
 
342
342
  Example: faf edit project.name "My Project"`),process.exit(1);let z=v();if(!z)console.error(`Error: project.faf not found
343
343
 
344
344
  Run 'faf init' to create one.`),process.exit(2);let X=l(z),J=$.split(".");if(J.length!==2)console.error("Error: path must be section.field (e.g. project.name)"),process.exit(1);let[Q,Y]=J;if(!X[Q]||typeof X[Q]!=="object")X[Q]={};X[Q][Y]=Z,r(z,X),console.log(`${D("updated")} ${$} ${N("→")} ${Z}`)}import{existsSync as i2,readFileSync as X3}from"fs";import{join as e1}from"path";d();function Bz(){let $=process.cwd(),Z=[],z={faf_version:"2.5.0",project:{}},X=e1($,"CLAUDE.md");if(i2(X)){let G=X3(X,"utf-8"),W=c2(G);if(W.project?.name)z.project.name=W.project.name;if(W.project?.goal)z.project.goal=W.project.goal;if(W.project?.main_language)z.project.main_language=W.project.main_language;Z.push("CLAUDE.md")}let J=e1($,"AGENTS.md");if(i2(J)){let G=X3(J,"utf-8");if(!z.project.name){let W=G.match(/^#\s+(.+)/m);if(W)z.project.name=W[1].trim()}Z.push("AGENTS.md")}let Q=e1($,"GEMINI.md");if(i2(Q)){let G=X3(Q,"utf-8");if(!z.project.name){let W=G.match(/^#\s+(.+)/m);if(W)z.project.name=W[1].trim()}Z.push("GEMINI.md")}let Y=e1($,".cursorrules");if(i2(Y))Z.push(".cursorrules");if(Z.length===0)console.error("No context files found (CLAUDE.md, AGENTS.md, GEMINI.md, .cursorrules)."),process.exit(2);let U=v($);if(U){let G=l(U);if(!G.project)G.project={};if(z.project.name&&!G.project.name)G.project.name=z.project.name;if(z.project.goal&&!G.project.goal)G.project.goal=z.project.goal;if(z.project.main_language&&!G.project.main_language)G.project.main_language=z.project.main_language;r(U,G),console.log(`${D("◆")} recover merged into ${U}`)}else{let G=e1($,"project.faf");r(G,z),console.log(`${D("◆")} recover created ${G}`)}console.log(N(` sources: ${Z.join(", ")}`))}d();var $4="2.5.0";function Lz($={}){let Z=v();if(!Z)console.error(`Error: project.faf not found
345
345
 
346
- Run 'faf init' to create one.`),process.exit(2);let z=l(Z),X=z.faf_version??"unknown";if(X===$4){console.log(`${D("◆")} migrate already at v${$4}`);return}if(z.faf_version=$4,!z.project)z.project={};if(!z.stack)z.stack={};if(!z.human_context)z.human_context={};if(!z.monorepo)z.monorepo={};if($.dryRun){console.log(`${D("◆")} migrate ${N("(dry run)")} v${X} → v${$4}`),console.log(N(` would update ${Z}`));return}r(Z,z),console.log(`${D("◆")} migrate v${X} → v${$4}`),console.log(N(` updated ${Z}`))}d();function Nz($){if($==="features")zN();else if($==="activate")XN();else ZN()}function ZN(){let $=a$();if(console.log(`${D("pro")} ${N("— FAF Pro status")}
347
- `),console.log(` Status: ${$?V0(w("PRO")):w("Free")}`),console.log(""),!$)console.log(N(" Upgrade: faf pro activate"))}function zN(){console.log(`${D("pro")} ${N("— Pro features")}
348
- `);let $=[["tri-sync",".faf ↔ CLAUDE.md ↔ MEMORY.md"],["enterprise slots","33-slot scoring (slots 22-33)"],["advanced analytics","Drift tracking & team metrics"]];for(let[Z,z]of $)console.log(` ${D("◆")} ${w(Z)} ${N("—")} ${z}`);console.log("")}function XN(){console.log(`${D("pro")} ${N("— activate")}
349
- `),console.log(" Set FAF_PRO=1 in your environment to enable Pro features."),console.log(""),console.log(N(" export FAF_PRO=1")),console.log(""),console.log(N(" Visit: https://faf.one/pro")),import("open").then(({default:$})=>$("https://faf.one/pro")).catch(()=>{})}import{gzipSync as JN}from"zlib";d();function Mz($={}){let Z=v();if(!Z)console.error(`Error: project.faf not found
346
+ Run 'faf init' to create one.`),process.exit(2);let z=l(Z),X=z.faf_version??"unknown";if(X===$4){console.log(`${D("◆")} migrate already at v${$4}`);return}if(z.faf_version=$4,!z.project)z.project={};if(!z.stack)z.stack={};if(!z.human_context)z.human_context={};if(!z.monorepo)z.monorepo={};if($.dryRun){console.log(`${D("◆")} migrate ${N("(dry run)")} v${X} → v${$4}`),console.log(N(` would update ${Z}`));return}r(Z,z),console.log(`${D("◆")} migrate v${X} → v${$4}`),console.log(N(` updated ${Z}`))}d();function Nz($){if($==="features")XN();else if($==="activate")JN();else zN()}function zN(){let $=a$();if(console.log(`${D("pro")} ${N("— FAF Pro status")}
347
+ `),console.log(` Status: ${$?V0(w("PRO")):w("Free")}`),console.log(""),!$)console.log(N(" Upgrade: faf pro activate"))}function XN(){console.log(`${D("pro")} ${N("— Pro features")}
348
+ `);let $=[["tri-sync",".faf ↔ CLAUDE.md ↔ MEMORY.md"],["enterprise slots","33-slot scoring (slots 22-33)"],["advanced analytics","Drift tracking & team metrics"]];for(let[Z,z]of $)console.log(` ${D("◆")} ${w(Z)} ${N("—")} ${z}`);console.log("")}function JN(){console.log(`${D("pro")} ${N("— activate")}
349
+ `),console.log(" Set FAF_PRO=1 in your environment to enable Pro features."),console.log(""),console.log(N(" export FAF_PRO=1")),console.log(""),console.log(N(" Visit: https://faf.one/pro")),import("open").then(({default:$})=>$("https://faf.one/pro")).catch(()=>{})}import{gzipSync as QN}from"zlib";d();function Mz($={}){let Z=v();if(!Z)console.error(`Error: project.faf not found
350
350
 
351
- Run 'faf init' to create one.`),process.exit(2);let z=u(Z),J=JN(Buffer.from(z)).toString("base64url");if($.raw){console.log(J);return}let Q=`https://faf.one/share?d=${J}`;if(console.log(`${D("◆")} share ${N(Z)}
351
+ Run 'faf init' to create one.`),process.exit(2);let z=u(Z),J=QN(Buffer.from(z)).toString("base64url");if($.raw){console.log(J);return}let Q=`https://faf.one/share?d=${J}`;if(console.log(`${D("◆")} share ${N(Z)}
352
352
  `),console.log(` ${Q}`),$.copy)try{let{execSync:Y}=T0("child_process"),U=process.platform;if(U==="darwin")Y("pbcopy",{input:Q});else if(U==="linux")Y("xclip -selection clipboard",{input:Q});console.log(N(`
353
353
  copied to clipboard`))}catch{console.log(N(`
354
- copy failed — install xclip or pbcopy`))}}import{mkdirSync as QN,writeFileSync as YN,rmSync as UN}from"fs";import{tmpdir as GN}from"os";import{join as Tz}from"path";d();function Oz(){let $=Tz(GN(),`faf-demo-${Date.now()}`);QN($,{recursive:!0}),console.log(`${D("demo")} ${N("— FAF in action")}
354
+ copy failed — install xclip or pbcopy`))}}import{mkdirSync as YN,writeFileSync as UN,rmSync as GN}from"fs";import{tmpdir as WN}from"os";import{join as Tz}from"path";d();function Oz(){let $=Tz(WN(),`faf-demo-${Date.now()}`);YN($,{recursive:!0}),console.log(`${D("demo")} ${N("— FAF in action")}
355
355
  `);let Z=`faf_version: 2.5.0
356
356
  project:
357
357
  name: acme-app
@@ -377,25 +377,25 @@ human_context:
377
377
  where: Cloud (Vercel + AWS)
378
378
  when: "2026"
379
379
  how: Agile sprints with CI/CD
380
- `,z=Tz($,"project.faf");YN(z,Z),console.log(` ${w("1.")} Created sample project.faf`),console.log(N(` ${z}
381
- `)),console.log(` ${w("2.")} Scoring...`);let X=K0(W0(u(z)));console.log(""),z0(X,"project.faf",!0),UN($,{recursive:!0,force:!0}),console.log(`
380
+ `,z=Tz($,"project.faf");UN(z,Z),console.log(` ${w("1.")} Created sample project.faf`),console.log(N(` ${z}
381
+ `)),console.log(` ${w("2.")} Scoring...`);let X=K0(W0(u(z)));console.log(""),z0(X,"project.faf",!0),GN($,{recursive:!0,force:!0}),console.log(`
382
382
  ${N(' Demo complete. Run "faf init" in your project to get started.')}`)}d();function Dz($,Z={}){if(!$)console.error("Usage: faf search <keyword>"),process.exit(2);let z=$.toLowerCase(),X=!Z.slots&&!Z.formats,J=0;if(X||Z.slots){let Q=$0.filter((Y)=>Y.path.toLowerCase().includes(z)||Y.description.toLowerCase().includes(z)||Y.category.toLowerCase().includes(z));if(Q.length>0){console.log(`${D("slots")} ${N(`— ${Q.length} match${Q.length===1?"":"es"}`)}
383
383
  `);for(let Y of Q)console.log(` ${w(`#${Y.index}`)} ${Y.path} ${N("—")} ${Y.description} ${N(`[${Y.category}]`)}`);console.log(""),J+=Q.length}}if(X||Z.formats){let Q=t1.filter((Y)=>Y.name.toLowerCase().includes(z)||Y.extensions.some((U)=>U.toLowerCase().includes(z))||Y.category.toLowerCase().includes(z));if(Q.length>0){console.log(`${D("formats")} ${N(`— ${Q.length} match${Q.length===1?"":"es"}`)}
384
- `);for(let Y of Q)console.log(` ${w(Y.name)} ${N(Y.extensions.join(", "))} ${N(`[${Y.category}]`)}`);console.log(""),J+=Q.length}}if(J===0)console.log(N(` No results for "${$}"`))}import{writeFileSync as WN}from"fs";d();function Iz($={}){let Z=v();if(!Z)console.error(`Error: project.faf not found
384
+ `);for(let Y of Q)console.log(` ${w(Y.name)} ${N(Y.extensions.join(", "))} ${N(`[${Y.category}]`)}`);console.log(""),J+=Q.length}}if(J===0)console.log(N(` No results for "${$}"`))}import{writeFileSync as qN}from"fs";d();function Iz($={}){let Z=v();if(!Z)console.error(`Error: project.faf not found
385
385
 
386
- Run 'faf init' to create one.`),process.exit(2);let z=l(Z),X=u(Z),J=H0(X),Q={taf_version:"1.0.0",generated:new Date().toISOString(),source:Z,project:z.project?.name??"unknown",faf_version:z.faf_version??"unknown",score:J.score,tier:J.tier.name,populated:J.populated,active:J.active,total:J.total,slots:J.slots},Y=JSON.stringify(Q,null,2);if($.output)WN($.output,Y,"utf-8"),console.log(`${D("◆")} taf receipt written to ${$.output}`);else console.log(Y)}import{createInterface as HN}from"readline";import{existsSync as Fz,readFileSync as BN,writeFileSync as LN,unlinkSync as NN}from"fs";import{join as MN}from"path";var e$="(terse — 3-4 words)",qN=[{path:"project.name",question:"What is the name of this project?",header:"Name",type:"text",required:!0},{path:"project.goal",question:"What does this project do? (one sentence)",header:"Goal",type:"text",required:!0},{path:"human_context.who",question:`Who is this for? ${e$}`,header:"Who",type:"text",required:!0},{path:"human_context.what",question:`What are they building? ${e$}`,header:"What",type:"text",required:!0},{path:"human_context.why",question:`Why does it exist? ${e$}`,header:"Why",type:"text",required:!0},{path:"human_context.where",question:`Where does it run or ship? ${e$}`,header:"Where",type:"text",required:!0},{path:"human_context.when",question:`When — timeline or stage? ${e$}`,header:"When",type:"text",required:!0},{path:"human_context.how",question:`How is it built or used? ${e$}`,header:"How",type:"text",required:!0}],VN=[{path:"project.main_language",question:"What is the primary programming language?",header:"Language",type:"select",required:!0,options:[{label:"TypeScript",value:"TypeScript",description:"JavaScript with types"},{label:"JavaScript",value:"JavaScript",description:"Vanilla JS or Node.js"},{label:"Python",value:"Python",description:"Python 3.x"},{label:"Rust",value:"Rust",description:"Systems programming"},{label:"Go",value:"Go",description:"Golang"},{label:"Other",value:"Other",description:"Specify manually"}]},{path:"stack.frontend",question:"What frontend framework does it use?",header:"Frontend",type:"select",required:!1,options:[{label:"React",value:"React",description:"React.js"},{label:"Vue",value:"Vue",description:"Vue.js"},{label:"Svelte",value:"Svelte",description:"Svelte/SvelteKit"},{label:"Next.js",value:"Next.js",description:"React framework"},{label:"None",value:"None",description:"No frontend"},{label:"Other",value:"Other",description:"Specify manually"}]},{path:"stack.backend",question:"What backend framework does it use?",header:"Backend",type:"select",required:!1,options:[{label:"Express",value:"Express",description:"Node.js Express"},{label:"Fastify",value:"Fastify",description:"Node.js Fastify"},{label:"Django",value:"Django",description:"Python Django"},{label:"FastAPI",value:"FastAPI",description:"Python FastAPI"},{label:"None",value:"None",description:"No backend"},{label:"Other",value:"Other",description:"Specify manually"}]},{path:"stack.database",question:"What database does it use?",header:"Database",type:"select",required:!1,options:[{label:"PostgreSQL",value:"PostgreSQL",description:"Postgres"},{label:"MySQL",value:"MySQL",description:"MySQL/MariaDB"},{label:"SQLite",value:"SQLite",description:"Embedded SQL"},{label:"MongoDB",value:"MongoDB",description:"Document store"},{label:"None",value:"None",description:"No database"},{label:"Other",value:"Other",description:"Specify manually"}]},{path:"stack.runtime",question:"What runtime does it run on?",header:"Runtime",type:"text",required:!1},{path:"stack.hosting",question:"Where is it hosted or distributed?",header:"Hosting",type:"text",required:!1},{path:"stack.build",question:"What is the build tool?",header:"Build",type:"text",required:!1},{path:"stack.cicd",question:"What CI/CD does it use?",header:"CI/CD",type:"text",required:!1}],Az=[...qN,...VN],KN=new Map(Az.map(($)=>[$.path,$])),WF=Object.fromEntries(Az.map(($)=>[$.path,$]));function Rz($){let Z=KN.get($);if(Z)return Z.question;let z=Q7.get($)??$0.find((X)=>X.canonical===$);return z?`${z.description}?`.replace(/\?\?$/,"?"):`${$}?`}d();var TN=".faf-session.json";function ON($,Z){let z=Z.split("."),X=$;for(let J of z){if(X===null||X===void 0||typeof X!=="object")return;X=X[J]}return X}function DN($,Z,z){let X=Z.split("."),J=$;for(let Q=0;Q<X.length-1;Q++){if(!J[X[Q]]||typeof J[X[Q]]!=="object")J[X[Q]]={};J=J[X[Q]]}J[X[X.length-1]]=z}async function wz($={}){let Z=v();if(!Z)console.error(`Error: project.faf not found
386
+ Run 'faf init' to create one.`),process.exit(2);let z=l(Z),X=u(Z),J=H0(X),Q={taf_version:"1.0.0",generated:new Date().toISOString(),source:Z,project:z.project?.name??"unknown",faf_version:z.faf_version??"unknown",score:J.score,tier:J.tier.name,populated:J.populated,active:J.active,total:J.total,slots:J.slots},Y=JSON.stringify(Q,null,2);if($.output)qN($.output,Y,"utf-8"),console.log(`${D("◆")} taf receipt written to ${$.output}`);else console.log(Y)}import{createInterface as BN}from"readline";import{existsSync as Fz,readFileSync as LN,writeFileSync as NN,unlinkSync as MN}from"fs";import{join as TN}from"path";var e$="(terse — 3-4 words)",VN=[{path:"project.name",question:"What is the name of this project?",header:"Name",type:"text",required:!0},{path:"project.goal",question:"What does this project do? (one sentence)",header:"Goal",type:"text",required:!0},{path:"human_context.who",question:`Who is this for? ${e$}`,header:"Who",type:"text",required:!0},{path:"human_context.what",question:`What are they building? ${e$}`,header:"What",type:"text",required:!0},{path:"human_context.why",question:`Why does it exist? ${e$}`,header:"Why",type:"text",required:!0},{path:"human_context.where",question:`Where does it run or ship? ${e$}`,header:"Where",type:"text",required:!0},{path:"human_context.when",question:`When — timeline or stage? ${e$}`,header:"When",type:"text",required:!0},{path:"human_context.how",question:`How is it built or used? ${e$}`,header:"How",type:"text",required:!0}],KN=[{path:"project.main_language",question:"What is the primary programming language?",header:"Language",type:"select",required:!0,options:[{label:"TypeScript",value:"TypeScript",description:"JavaScript with types"},{label:"JavaScript",value:"JavaScript",description:"Vanilla JS or Node.js"},{label:"Python",value:"Python",description:"Python 3.x"},{label:"Rust",value:"Rust",description:"Systems programming"},{label:"Go",value:"Go",description:"Golang"},{label:"Other",value:"Other",description:"Specify manually"}]},{path:"stack.frontend",question:"What frontend framework does it use?",header:"Frontend",type:"select",required:!1,options:[{label:"React",value:"React",description:"React.js"},{label:"Vue",value:"Vue",description:"Vue.js"},{label:"Svelte",value:"Svelte",description:"Svelte/SvelteKit"},{label:"Next.js",value:"Next.js",description:"React framework"},{label:"None",value:"None",description:"No frontend"},{label:"Other",value:"Other",description:"Specify manually"}]},{path:"stack.backend",question:"What backend framework does it use?",header:"Backend",type:"select",required:!1,options:[{label:"Express",value:"Express",description:"Node.js Express"},{label:"Fastify",value:"Fastify",description:"Node.js Fastify"},{label:"Django",value:"Django",description:"Python Django"},{label:"FastAPI",value:"FastAPI",description:"Python FastAPI"},{label:"None",value:"None",description:"No backend"},{label:"Other",value:"Other",description:"Specify manually"}]},{path:"stack.database",question:"What database does it use?",header:"Database",type:"select",required:!1,options:[{label:"PostgreSQL",value:"PostgreSQL",description:"Postgres"},{label:"MySQL",value:"MySQL",description:"MySQL/MariaDB"},{label:"SQLite",value:"SQLite",description:"Embedded SQL"},{label:"MongoDB",value:"MongoDB",description:"Document store"},{label:"None",value:"None",description:"No database"},{label:"Other",value:"Other",description:"Specify manually"}]},{path:"stack.runtime",question:"What runtime does it run on?",header:"Runtime",type:"text",required:!1},{path:"stack.hosting",question:"Where is it hosted or distributed?",header:"Hosting",type:"text",required:!1},{path:"stack.build",question:"What is the build tool?",header:"Build",type:"text",required:!1},{path:"stack.cicd",question:"What CI/CD does it use?",header:"CI/CD",type:"text",required:!1}],Az=[...VN,...KN],HN=new Map(Az.map(($)=>[$.path,$])),qF=Object.fromEntries(Az.map(($)=>[$.path,$]));function Rz($){let Z=HN.get($);if(Z)return Z.question;let z=Q7.get($)??$0.find((X)=>X.canonical===$);return z?`${z.description}?`.replace(/\?\?$/,"?"):`${$}?`}d();var ON=".faf-session.json";function DN($,Z){let z=Z.split("."),X=$;for(let J of z){if(X===null||X===void 0||typeof X!=="object")return;X=X[J]}return X}function IN($,Z,z){let X=Z.split("."),J=$;for(let Q=0;Q<X.length-1;Q++){if(!J[X[Q]]||typeof J[X[Q]]!=="object")J[X[Q]]={};J=J[X[Q]]}J[X[X.length-1]]=z}async function wz($={}){let Z=v();if(!Z)console.error(`Error: project.faf not found
387
387
 
388
- Run 'faf init' to create one.`),process.exit(2);let z=process.cwd(),X=MN(z,TN),J=0;if($.resume&&Fz(X))try{J=JSON.parse(BN(X,"utf-8")).slotIndex,console.log(N(` resuming from slot #${J+1}`))}catch{}let Q=l(Z),Y=$0.filter((B)=>{let O=ON(Q,B.path);return v0(O)&&O!=="slotignored"});if(Y.length===0){console.log(`${D("◆")} go all slots populated — \uD83C\uDFC6 Trophy`);let B=K0(W0(u(Z)));z0(B,Z);return}console.log(`${D("go")} ${N("— guided interview to \uD83C\uDFC6 Trophy")}`);let U=Y.length===1?"slot":"slots";console.log(N(` ${Y.length} ${U} from Trophy. Enter a value, "skip" to skip, or "quit" to stop.
389
- `));let G=HN({input:process.stdin,output:process.stdout}),W=(B)=>new Promise((O)=>G.question(B,O)),q=0,V=Y.slice(J);for(let B=0;B<V.length;B++){let O=V[B],L=await W(` ${w(`#${O.index}`)} ${Rz(O.path)} ${N(`(${O.path})`)}: `);if(L.toLowerCase()==="quit"){let M={slotIndex:J+B,fafPath:Z};LN(X,JSON.stringify(M),"utf-8"),console.log(N(`
390
- session saved. Resume with: faf go --resume`));break}if(L.toLowerCase()==="skip"||L.trim()==="")continue;DN(Q,O.path,L.trim()),q++}if(G.close(),q>0)r(Z,Q),console.log(`
391
- ${D("◆")} go filled ${q} slot${q===1?"":"s"}`);let K=K0(W0(u(Z)));if(z0(K,Z),Fz(X))try{NN(X)}catch{}}d();var MM=[/^(tbd|see\s+readme|todo|fixme|coming\s+soon|n\/a|unknown|none|null|not\s+specified)\b/i,/^(software|application|app|project|tool|library|framework)\.?$/i,/^(for\s+(users|developers|teams|engineers))\.?$/i,/^(general\s+purpose|various|multiple|description|goal|name|title)\.?$/i];function TM($){if(typeof $!=="string")return!1;let Z=$.trim();if(Z.length<4||Z.length>280)return!1;return!MM.some((z)=>z.test(Z))}function OM($,Z){let z=Z.split("."),X=$;for(let J of z){if(X===null||X===void 0||typeof X!=="object")return;X=X[J]}return X}function DM($,Z,z){let X=Z.split("."),J=$;for(let Q=0;Q<X.length-1;Q++){if(!J[X[Q]]||typeof J[X[Q]]!=="object")J[X[Q]]={};J=J[X[Q]]}J[X[X.length-1]]=z}async function wX($){if($==="analyze")await AM();else if($==="enhance")await IM();else console.log(`${D("ai")} ${N("— AI-powered features")}
388
+ Run 'faf init' to create one.`),process.exit(2);let z=process.cwd(),X=TN(z,ON),J=0;if($.resume&&Fz(X))try{J=JSON.parse(LN(X,"utf-8")).slotIndex,console.log(N(` resuming from slot #${J+1}`))}catch{}let Q=l(Z),Y=$0.filter((B)=>{let O=DN(Q,B.path);return v0(O)&&O!=="slotignored"});if(Y.length===0){console.log(`${D("◆")} go all slots populated — \uD83C\uDFC6 Trophy`);let B=K0(W0(u(Z)));z0(B,Z);return}console.log(`${D("go")} ${N("— guided interview to \uD83C\uDFC6 Trophy")}`);let U=Y.length===1?"slot":"slots";console.log(N(` ${Y.length} ${U} from Trophy. Enter a value, "skip" to skip, or "quit" to stop.
389
+ `));let G=BN({input:process.stdin,output:process.stdout}),W=(B)=>new Promise((O)=>G.question(B,O)),q=0,V=Y.slice(J);for(let B=0;B<V.length;B++){let O=V[B],L=await W(` ${w(`#${O.index}`)} ${Rz(O.path)} ${N(`(${O.path})`)}: `);if(L.toLowerCase()==="quit"){let M={slotIndex:J+B,fafPath:Z};NN(X,JSON.stringify(M),"utf-8"),console.log(N(`
390
+ session saved. Resume with: faf go --resume`));break}if(L.toLowerCase()==="skip"||L.trim()==="")continue;IN(Q,O.path,L.trim()),q++}if(G.close(),q>0)r(Z,Q),console.log(`
391
+ ${D("◆")} go filled ${q} slot${q===1?"":"s"}`);let K=K0(W0(u(Z)));if(z0(K,Z),Fz(X))try{MN(X)}catch{}}d();var TM=[/^(tbd|see\s+readme|todo|fixme|coming\s+soon|n\/a|unknown|none|null|not\s+specified)\b/i,/^(software|application|app|project|tool|library|framework)\.?$/i,/^(for\s+(users|developers|teams|engineers))\.?$/i,/^(general\s+purpose|various|multiple|description|goal|name|title)\.?$/i];function OM($){if(typeof $!=="string")return!1;let Z=$.trim();if(Z.length<4||Z.length>280)return!1;return!TM.some((z)=>z.test(Z))}function DM($,Z){let z=Z.split("."),X=$;for(let J of z){if(X===null||X===void 0||typeof X!=="object")return;X=X[J]}return X}function IM($,Z,z){let X=Z.split("."),J=$;for(let Q=0;Q<X.length-1;Q++){if(!J[X[Q]]||typeof J[X[Q]]!=="object")J[X[Q]]={};J=J[X[Q]]}J[X[X.length-1]]=z}async function wX($){if($==="analyze")await RM();else if($==="enhance")await AM();else console.log(`${D("ai")} ${N("— AI-powered features")}
392
392
  `),console.log(` ${w("faf ai enhance")} ${N("— fill empty slots via Claude")}`),console.log(` ${w("faf ai analyze")} ${N("— get improvement suggestions")}`),console.log(""),console.log(N(" Requires ANTHROPIC_API_KEY environment variable."))}async function PX(){let $=process.env.ANTHROPIC_API_KEY;if(!$)console.error(`Error: ANTHROPIC_API_KEY not set.
393
393
 
394
394
  export ANTHROPIC_API_KEY=sk-...`),process.exit(2);try{let{default:Z}=await Promise.resolve().then(() => (FX(),RX));return new Z({apiKey:$})}catch{console.error(`Error: @anthropic-ai/sdk not installed.
395
395
 
396
- npm install @anthropic-ai/sdk`),process.exit(2)}}async function IM(){let $=v();if(!$)console.error(`Error: project.faf not found
396
+ npm install @anthropic-ai/sdk`),process.exit(2)}}async function AM(){let $=v();if(!$)console.error(`Error: project.faf not found
397
397
 
398
- Run 'faf init' to create one.`),process.exit(2);let Z=l($),z=u($),X=$0.filter((G)=>{let W=OM(Z,G.path);return v0(W)&&W!=="slotignored"});if(X.length===0){console.log(`${D("◆")} ai enhance all slots populated`);return}console.log(`${D("ai")} enhance ${N(`extracting from ${X.length} empty slots...`)}`);let J=await PX(),Q=X.map((G)=>`- ${G.path}: ${G.description}`).join(`
398
+ Run 'faf init' to create one.`),process.exit(2);let Z=l($),z=u($),X=$0.filter((G)=>{let W=DM(Z,G.path);return v0(W)&&W!=="slotignored"});if(X.length===0){console.log(`${D("◆")} ai enhance all slots populated`);return}console.log(`${D("ai")} enhance ${N(`extracting from ${X.length} empty slots...`)}`);let J=await PX(),Q=X.map((G)=>`- ${G.path}: ${G.description}`).join(`
399
399
  `),Y=`You are extracting concrete content from a project's .faf file to fill empty slots. STRICT RULES:
400
400
 
401
401
  1. Return JSON mapping dot-paths to values OR null.
@@ -411,41 +411,41 @@ ${z}
411
411
  Empty slots to fill (return null if no concrete evidence):
412
412
  ${Q}
413
413
 
414
- Respond with ONLY valid JSON, no markdown fences. Each value is either a short string (with concrete evidence) or null (leave empty).`,U=await J.messages.create({model:"claude-haiku-4-5-20251001",max_tokens:1024,messages:[{role:"user",content:Y}]});try{let G=U.content[0].text,W=JSON.parse(G),q=0,V=0;for(let K of X){let B=W[K.path];if(B===null||B===void 0)continue;if(TM(B))DM(Z,K.path,B),console.log(` ${D("●")} ${K.path} ${N("←")} ${B}`),q++;else console.log(` ${N("○")} ${K.path} ${N("— rejected as slop, left empty")}`),V++}if(q>0){r($,Z),console.log(`
414
+ Respond with ONLY valid JSON, no markdown fences. Each value is either a short string (with concrete evidence) or null (leave empty).`,U=await J.messages.create({model:"claude-haiku-4-5-20251001",max_tokens:1024,messages:[{role:"user",content:Y}]});try{let G=U.content[0].text,W=JSON.parse(G),q=0,V=0;for(let K of X){let B=W[K.path];if(B===null||B===void 0)continue;if(OM(B))IM(Z,K.path,B),console.log(` ${D("●")} ${K.path} ${N("←")} ${B}`),q++;else console.log(` ${N("○")} ${K.path} ${N("— rejected as slop, left empty")}`),V++}if(q>0){r($,Z),console.log(`
415
415
  ${D("◆")} ai enhance filled ${q} slot${q===1?"":"s"}${V>0?` (${V} rejected)`:""}`);let K=K0(W0(u($)));z0(K,$)}else if(V>0)console.log(`
416
416
  ${N("all extractions rejected as slop. Run")} ${w("'faf go'")} ${N("for interview-fill.")}`);else console.log(`
417
- ${N("no concrete evidence for empty slots. Run")} ${w("'faf go'")} ${N("for interview-fill.")}`)}catch{console.error("Error: Could not parse AI response.")}}async function AM(){let $=v();if(!$)console.error(`Error: project.faf not found
417
+ ${N("no concrete evidence for empty slots. Run")} ${w("'faf go'")} ${N("for interview-fill.")}`)}catch{console.error("Error: Could not parse AI response.")}}async function RM(){let $=v();if(!$)console.error(`Error: project.faf not found
418
418
 
419
419
  Run 'faf init' to create one.`),process.exit(2);let Z=u($);console.log(`${D("ai")} analyze ${N("getting suggestions...")}`);let X=await(await PX()).messages.create({model:"claude-haiku-4-5-20251001",max_tokens:1024,messages:[{role:"user",content:`Analyze this .faf project context file and provide 3-5 specific suggestions for improvement. Focus on completeness, accuracy, and best practices.
420
420
 
421
421
  ${Z}
422
422
 
423
- Be concise. One line per suggestion.`}]});console.log(""),console.log(X.content[0].text)}import{existsSync as TZ,readFileSync as OZ,readdirSync as RM}from"fs";import{join as _X}from"path";d();function CX($,Z){if($==="import")FM(Z);else if($==="export")wM();else console.log(`${D("conductor")} ${N("— conductor integration")}
424
- `),console.log(` ${w("faf conductor import <path>")} ${N("— import conductor config into .faf")}`),console.log(` ${w("faf conductor export")} ${N("— generate conductor config from .faf")}`)}function FM($){if(!$)console.error("Usage: faf conductor import <path>"),process.exit(2);if(!TZ($))console.error(`Error: path not found: ${$}`),process.exit(2);let Z={faf_version:"2.5.0",project:{}};if(TZ($)&&$.endsWith(".json")){let J=JSON.parse(OZ($,"utf-8"));if(J.name)Z.project.name=J.name;if(J.description)Z.project.goal=J.description;if(J.language)Z.project.main_language=J.language}else if(TZ($)&&($.endsWith(".yml")||$.endsWith(".yaml"))){let J=J$(OZ($,"utf-8"));if(J.name)Z.project.name=J.name;if(J.description)Z.project.goal=J.description;if(J.language)Z.project.main_language=J.language}else try{let J=RM($);for(let Q of J){let Y=_X($,Q);if(Q.endsWith(".json"))try{let U=JSON.parse(OZ(Y,"utf-8"));if(U.name&&!Z.project.name)Z.project.name=U.name;if(U.description&&!Z.project.goal)Z.project.goal=U.description}catch{}}}catch{console.error(`Error: could not read directory: ${$}`),process.exit(2)}let z=process.cwd(),X=v(z);if(X){let J=l(X);if(!J.project)J.project={};if(Z.project.name&&!J.project.name)J.project.name=Z.project.name;if(Z.project.goal&&!J.project.goal)J.project.goal=Z.project.goal;if(Z.project.main_language&&!J.project.main_language)J.project.main_language=Z.project.main_language;r(X,J),console.log(`${D("◆")} conductor import merged into ${X}`)}else{let J=_X(z,"project.faf");r(J,Z),console.log(`${D("◆")} conductor import created ${J}`)}}function wM(){let $=v();if(!$)console.error(`Error: project.faf not found
423
+ Be concise. One line per suggestion.`}]});console.log(""),console.log(X.content[0].text)}import{existsSync as TZ,readFileSync as OZ,readdirSync as FM}from"fs";import{join as _X}from"path";d();function CX($,Z){if($==="import")wM(Z);else if($==="export")PM();else console.log(`${D("conductor")} ${N("— conductor integration")}
424
+ `),console.log(` ${w("faf conductor import <path>")} ${N("— import conductor config into .faf")}`),console.log(` ${w("faf conductor export")} ${N("— generate conductor config from .faf")}`)}function wM($){if(!$)console.error("Usage: faf conductor import <path>"),process.exit(2);if(!TZ($))console.error(`Error: path not found: ${$}`),process.exit(2);let Z={faf_version:"2.5.0",project:{}};if(TZ($)&&$.endsWith(".json")){let J=JSON.parse(OZ($,"utf-8"));if(J.name)Z.project.name=J.name;if(J.description)Z.project.goal=J.description;if(J.language)Z.project.main_language=J.language}else if(TZ($)&&($.endsWith(".yml")||$.endsWith(".yaml"))){let J=J$(OZ($,"utf-8"));if(J.name)Z.project.name=J.name;if(J.description)Z.project.goal=J.description;if(J.language)Z.project.main_language=J.language}else try{let J=FM($);for(let Q of J){let Y=_X($,Q);if(Q.endsWith(".json"))try{let U=JSON.parse(OZ(Y,"utf-8"));if(U.name&&!Z.project.name)Z.project.name=U.name;if(U.description&&!Z.project.goal)Z.project.goal=U.description}catch{}}}catch{console.error(`Error: could not read directory: ${$}`),process.exit(2)}let z=process.cwd(),X=v(z);if(X){let J=l(X);if(!J.project)J.project={};if(Z.project.name&&!J.project.name)J.project.name=Z.project.name;if(Z.project.goal&&!J.project.goal)J.project.goal=Z.project.goal;if(Z.project.main_language&&!J.project.main_language)J.project.main_language=Z.project.main_language;r(X,J),console.log(`${D("◆")} conductor import merged into ${X}`)}else{let J=_X(z,"project.faf");r(J,Z),console.log(`${D("◆")} conductor import created ${J}`)}}function PM(){let $=v();if(!$)console.error(`Error: project.faf not found
425
425
 
426
- Run 'faf init' to create one.`),process.exit(2);let Z=l($),z={name:Z.project?.name??"",description:Z.project?.goal??"",language:Z.project?.main_language??"",stack:Z.stack??{}};console.log(JSON.stringify(z,null,2))}d();import{readdirSync as PM,readFileSync as _M,existsSync as CM}from"fs";import{join as EM}from"path";var jM=["BRAKE","ENGINE","AERO","PIT"],SM=/(?:^|[^A-Za-z])(BRAKE|ENGINE|AERO|PIT)(?:[^A-Za-z]|$)/i;function bM($){let Z=$.match(SM);if(!Z)return null;return Z[1].toUpperCase()}function xM($){let Z=$.toLowerCase();if(Z.endsWith(".test.ts")||Z.endsWith(".test.js")||Z.endsWith(".test.tsx")||Z.endsWith(".test.jsx")||Z.endsWith(".spec.ts")||Z.endsWith(".spec.js"))return{ok:!0,lang:"typescript"};if(Z.endsWith(".rs"))return{ok:!0,lang:"rust"};if(Z.endsWith("_test.go"))return{ok:!0,lang:"go"};if((Z.startsWith("test_")||Z.endsWith("_test.py"))&&Z.endsWith(".py"))return{ok:!0,lang:"python"};if(Z.endsWith(".zig"))return{ok:!0,lang:"zig"};return{ok:!1}}function kM($,Z){let z=[];switch(Z){case"typescript":{let X=/\b(describe|test|it)\s*\(\s*(['"`])((?:\\.|(?!\2).)*)\2/g,J=[],Q;while((Q=X.exec($))!==null)J.push({idx:Q.index,type:Q[1]==="describe"?"describe":"test",name:Q[3]});let Y=[],U=0,G=null,W=0;for(let q=0;q<$.length;q++){while(W<J.length&&J[W].idx===q){let K=J[W];if(K.type==="describe")G=K.name;else{let B=Y.map((L)=>L.name),O=B.length>0?`${B.join(" > ")} > ${K.name}`:K.name;z.push(O)}W++}let V=$[q];if(V==="{"){if(U++,G!==null)Y.push({name:G,openDepth:U}),G=null}else if(V==="}"){U--;while(Y.length>0&&U<Y[Y.length-1].openDepth)Y.pop()}}break}case"rust":{let X=/#\[test\]\s*(?:\r?\n)\s*(?:pub\s+)?fn\s+([a-zA-Z_][a-zA-Z_0-9]*)/g,J;while((J=X.exec($))!==null)z.push(J[1]);break}case"python":{let X=/^\s*def\s+(test_[a-zA-Z_0-9]+)\s*\(/gm,J;while((J=X.exec($))!==null)z.push(J[1]);break}case"zig":{let X=/\btest\s+"((?:\\.|[^"\\])+)"/g,J;while((J=X.exec($))!==null)z.push(J[1]);break}case"go":{let X=/\bfunc\s+(Test[A-Z][a-zA-Z_0-9]*)\s*\(/g,J;while((J=X.exec($))!==null)z.push(J[1]);break}}return z}var yM=new Set(["node_modules",".git","target","dist","build",".next",".nuxt","coverage"]);function EX($,Z=[]){let z;try{z=PM($,{withFileTypes:!0})}catch{return Z}for(let X of z){if(yM.has(X.name))continue;if(X.name.startsWith(".")&&X.name!==".")continue;let J=EM($,X.name);if(X.isDirectory())EX(J,Z);else if(X.isFile())Z.push(J)}return Z}function fM($){let Z=[];if(!CM($))return Z;let z=EX($);for(let X of z){let J=X.split("/").pop()??"",Q=xM(J);if(!Q.ok||!Q.lang)continue;let Y;try{Y=_M(X,"utf-8")}catch{continue}if(Q.lang==="rust"&&!/#\[test\]/.test(Y))continue;if(Q.lang==="zig"&&!/\btest\s+"/.test(Y))continue;let U=kM(Y,Q.lang),G=X.replace(`${$}/`,"");for(let W of U)Z.push({file:G,language:Q.lang,testName:W,tier:bM(W)})}return Z}function gM($){let Z={BRAKE:0,ENGINE:0,AERO:0,PIT:0},z={},X=0,J=[],Q=new Set;for(let Y of $)if(Q.add(Y.file),z[Y.language]=(z[Y.language]??0)+1,Y.tier)Z[Y.tier]++;else if(X++,J.length<5)J.push(`${Y.file}: ${Y.testName}`);return{totalTests:$.length,byTier:Z,untiered:X,untieredExamples:J,filesScanned:Q.size,byLanguage:z}}function hM($){if(console.log(`${D(w("faf wjttc"))} ${N("— vendor-neutral test audit")}`),console.log(""),console.log(` Files scanned: ${w(String($.filesScanned))}`),console.log(` Tests found: ${w(String($.totalTests))}`),console.log(""),$.totalTests===0){console.log(N(" no tests found"));return}console.log(N(" Tiers:"));for(let Z of jM){let z=$.byTier[Z],X=(z/$.totalTests*100).toFixed(0),J=Z==="BRAKE"?V0("●"):Z==="ENGINE"?D("●"):Z==="AERO"?N("●"):N("○");console.log(` ${J} ${Z.padEnd(7)} ${w(String(z).padStart(4))} ${N(`(${X}%)`)}`)}if($.untiered>0){let Z=($.untiered/$.totalTests*100).toFixed(0);console.log(` ${N("○")} ${"untiered".padEnd(7)} ${w(String($.untiered).padStart(4))} ${N(`(${Z}%)`)}`)}if($.untiered>0&&$.untieredExamples.length>0){console.log(""),console.log(N(` Untiered examples (first ${$.untieredExamples.length}):`));for(let Z of $.untieredExamples)console.log(` ${N("·")} ${Z}`)}if(Object.keys($.byLanguage).length>1){console.log(""),console.log(N(" Languages:"));for(let[Z,z]of Object.entries($.byLanguage))console.log(` ${N("·")} ${Z.padEnd(12)} ${w(String(z))}`)}if($.byTier.BRAKE===0&&$.totalTests>0)console.log(""),console.log(V0(" ⚠ no BRAKE-tier tests — no safety canaries"))}function jX($={}){let Z=$.path??"tests",z=fM(Z),X=gM(z);if($.json)console.log(JSON.stringify(X,null,2));else hM(X);if($.strict&&X.untiered>0)process.exit(1)}import{createHash as xX}from"crypto";import{readFileSync as kX,writeFileSync as vM,existsSync as yX}from"fs";import{join as fX,dirname as uM}from"path";d();var SX="faf-bench/1",mM={"project.name":"What is the project's name?","project.goal":"What is the project's goal — what is it for?","project.main_language":"What is the primary programming language?","human_context.who":"Who is this project for?","human_context.what":"What are they building?","human_context.why":"Why does this project exist?","human_context.where":"Where does it run or get distributed?","human_context.when":"When — what is the project's timeline or stage?","human_context.how":"How is it built or used?"};function cM($,Z){return mM[$]??`What is the project's ${Z.replace(/\s*\(.*\)$/,"").toLowerCase()}?`}var dM=[["typescript","ts"],["javascript","js"],["python","py","python3"],["node","nodejs","node js","node.js"],["github actions","gh actions","actions"],["postgresql","postgres","pg"],["kubernetes","k8s"],["npm","npm registry"],["cloudflare workers","cf workers","workers"],["google cloud run","cloud run","gcp cloud run"]],d4=new Map;dM.forEach(($,Z)=>$.forEach((z)=>d4.set(z,Z)));var pM=new Set(["a","an","the","and","or","of","for","to","in","on","with","is","it","its","their","your","via","by","using","use","used"]);function DZ($){return $.toLowerCase().replace(/[^a-z0-9\s.+#-]/g," ").replace(/\.(?=\s|$)/g," ").replace(/\s+/g," ").trim()}function bX($){return DZ($).split(" ").filter((Z)=>Z&&!pM.has(Z))}function lM($,Z){let z=DZ($),X=DZ(Z);if(!z||!X)return!1;if(z===X)return!0;let J=d4.get(z);if(J!==void 0&&d4.get(X)===J)return!0;let Q=bX($);if(Q.length===0)return!1;let Y=new Set(bX(Z));return Q.every((U)=>{if(Y.has(U))return!0;let G=d4.get(U);return G!==void 0&&[...Y].some((W)=>d4.get(W)===G)})}function iM($){let Z=H0($),z=J$($),X=[],J={},Q=0;for(let G of $0){if(Z.slots[G.path]!=="populated")continue;let W=Y7(z,G);if(typeof W!=="string")continue;let q=W.trim();if(!q||i8.has(q.toLowerCase()))continue;Q+=1,X.push({n:Q,path:G.path,question:cM(G.path,G.description)}),J[Q]=q}let Y=JSON.stringify({v:SX,q:X.map((G)=>[G.path,G.question])}),U=xX("sha256").update(Y).digest("hex").slice(0,12);return{version:SX,qsetHash:U,questions:X,answers:J}}function nM($,Z){let z=$.questions.map((J)=>{let Q=Z[String(J.n)]??Z[J.path]??"";return{n:J.n,path:J.path,ok:typeof Q==="string"&&Q.trim()!==""&&lM($.answers[J.n],Q)}}),X=$.questions.filter((J)=>!z[J.n-1].ok);return{correct:z.filter((J)=>J.ok).length,total:$.questions.length,misses:X,perQuestion:z}}var gX=".faf-bench.json";function sM($){let Z=fX($,gX);if(!yX(Z))return null;try{return JSON.parse(kX(Z,"utf-8"))}catch{return null}}function rM($,Z){vM(fX($,gX),JSON.stringify(Z,null,2)+`
427
- `,"utf-8")}function IZ($,Z){let z=JSON.stringify({v:$.version,repo:Z??null,qset:$.qsetHash,protocol:$.protocol,cold:$.cold??null,faf:$.faf??null});return{projection:z,hash:xX("sha256").update(z).digest("hex")}}var I6=($)=>$===void 0?"—":`~${$.toLocaleString()}`;function aM($,Z){let{cold:z,faf:X}=$;console.log(`
426
+ Run 'faf init' to create one.`),process.exit(2);let Z=l($),z={name:Z.project?.name??"",description:Z.project?.goal??"",language:Z.project?.main_language??"",stack:Z.stack??{}};console.log(JSON.stringify(z,null,2))}d();import{readdirSync as _M,readFileSync as CM,existsSync as EM}from"fs";import{join as jM}from"path";var SM=["BRAKE","ENGINE","AERO","PIT"],bM=/(?:^|[^A-Za-z])(BRAKE|ENGINE|AERO|PIT)(?:[^A-Za-z]|$)/i;function xM($){let Z=$.match(bM);if(!Z)return null;return Z[1].toUpperCase()}function kM($){let Z=$.toLowerCase();if(Z.endsWith(".test.ts")||Z.endsWith(".test.js")||Z.endsWith(".test.tsx")||Z.endsWith(".test.jsx")||Z.endsWith(".spec.ts")||Z.endsWith(".spec.js"))return{ok:!0,lang:"typescript"};if(Z.endsWith(".rs"))return{ok:!0,lang:"rust"};if(Z.endsWith("_test.go"))return{ok:!0,lang:"go"};if((Z.startsWith("test_")||Z.endsWith("_test.py"))&&Z.endsWith(".py"))return{ok:!0,lang:"python"};if(Z.endsWith(".zig"))return{ok:!0,lang:"zig"};return{ok:!1}}function yM($,Z){let z=[];switch(Z){case"typescript":{let X=/\b(describe|test|it)\s*\(\s*(['"`])((?:\\.|(?!\2).)*)\2/g,J=[],Q;while((Q=X.exec($))!==null)J.push({idx:Q.index,type:Q[1]==="describe"?"describe":"test",name:Q[3]});let Y=[],U=0,G=null,W=0;for(let q=0;q<$.length;q++){while(W<J.length&&J[W].idx===q){let K=J[W];if(K.type==="describe")G=K.name;else{let B=Y.map((L)=>L.name),O=B.length>0?`${B.join(" > ")} > ${K.name}`:K.name;z.push(O)}W++}let V=$[q];if(V==="{"){if(U++,G!==null)Y.push({name:G,openDepth:U}),G=null}else if(V==="}"){U--;while(Y.length>0&&U<Y[Y.length-1].openDepth)Y.pop()}}break}case"rust":{let X=/#\[test\]\s*(?:\r?\n)\s*(?:pub\s+)?fn\s+([a-zA-Z_][a-zA-Z_0-9]*)/g,J;while((J=X.exec($))!==null)z.push(J[1]);break}case"python":{let X=/^\s*def\s+(test_[a-zA-Z_0-9]+)\s*\(/gm,J;while((J=X.exec($))!==null)z.push(J[1]);break}case"zig":{let X=/\btest\s+"((?:\\.|[^"\\])+)"/g,J;while((J=X.exec($))!==null)z.push(J[1]);break}case"go":{let X=/\bfunc\s+(Test[A-Z][a-zA-Z_0-9]*)\s*\(/g,J;while((J=X.exec($))!==null)z.push(J[1]);break}}return z}var fM=new Set(["node_modules",".git","target","dist","build",".next",".nuxt","coverage"]);function EX($,Z=[]){let z;try{z=_M($,{withFileTypes:!0})}catch{return Z}for(let X of z){if(fM.has(X.name))continue;if(X.name.startsWith(".")&&X.name!==".")continue;let J=jM($,X.name);if(X.isDirectory())EX(J,Z);else if(X.isFile())Z.push(J)}return Z}function gM($){let Z=[];if(!EM($))return Z;let z=EX($);for(let X of z){let J=X.split("/").pop()??"",Q=kM(J);if(!Q.ok||!Q.lang)continue;let Y;try{Y=CM(X,"utf-8")}catch{continue}if(Q.lang==="rust"&&!/#\[test\]/.test(Y))continue;if(Q.lang==="zig"&&!/\btest\s+"/.test(Y))continue;let U=yM(Y,Q.lang),G=X.replace(`${$}/`,"");for(let W of U)Z.push({file:G,language:Q.lang,testName:W,tier:xM(W)})}return Z}function hM($){let Z={BRAKE:0,ENGINE:0,AERO:0,PIT:0},z={},X=0,J=[],Q=new Set;for(let Y of $)if(Q.add(Y.file),z[Y.language]=(z[Y.language]??0)+1,Y.tier)Z[Y.tier]++;else if(X++,J.length<5)J.push(`${Y.file}: ${Y.testName}`);return{totalTests:$.length,byTier:Z,untiered:X,untieredExamples:J,filesScanned:Q.size,byLanguage:z}}function vM($){if(console.log(`${D(w("faf wjttc"))} ${N("— vendor-neutral test audit")}`),console.log(""),console.log(` Files scanned: ${w(String($.filesScanned))}`),console.log(` Tests found: ${w(String($.totalTests))}`),console.log(""),$.totalTests===0){console.log(N(" no tests found"));return}console.log(N(" Tiers:"));for(let Z of SM){let z=$.byTier[Z],X=(z/$.totalTests*100).toFixed(0),J=Z==="BRAKE"?V0("●"):Z==="ENGINE"?D("●"):Z==="AERO"?N("●"):N("○");console.log(` ${J} ${Z.padEnd(7)} ${w(String(z).padStart(4))} ${N(`(${X}%)`)}`)}if($.untiered>0){let Z=($.untiered/$.totalTests*100).toFixed(0);console.log(` ${N("○")} ${"untiered".padEnd(7)} ${w(String($.untiered).padStart(4))} ${N(`(${Z}%)`)}`)}if($.untiered>0&&$.untieredExamples.length>0){console.log(""),console.log(N(` Untiered examples (first ${$.untieredExamples.length}):`));for(let Z of $.untieredExamples)console.log(` ${N("·")} ${Z}`)}if(Object.keys($.byLanguage).length>1){console.log(""),console.log(N(" Languages:"));for(let[Z,z]of Object.entries($.byLanguage))console.log(` ${N("·")} ${Z.padEnd(12)} ${w(String(z))}`)}if($.byTier.BRAKE===0&&$.totalTests>0)console.log(""),console.log(V0(" ⚠ no BRAKE-tier tests — no safety canaries"))}function jX($={}){let Z=$.path??"tests",z=gM(Z),X=hM(z);if($.json)console.log(JSON.stringify(X,null,2));else vM(X);if($.strict&&X.untiered>0)process.exit(1)}import{createHash as xX}from"crypto";import{readFileSync as kX,writeFileSync as uM,existsSync as yX}from"fs";import{join as fX,dirname as mM}from"path";d();var SX="faf-bench/1",cM={"project.name":"What is the project's name?","project.goal":"What is the project's goal — what is it for?","project.main_language":"What is the primary programming language?","human_context.who":"Who is this project for?","human_context.what":"What are they building?","human_context.why":"Why does this project exist?","human_context.where":"Where does it run or get distributed?","human_context.when":"When — what is the project's timeline or stage?","human_context.how":"How is it built or used?"};function dM($,Z){return cM[$]??`What is the project's ${Z.replace(/\s*\(.*\)$/,"").toLowerCase()}?`}var pM=[["typescript","ts"],["javascript","js"],["python","py","python3"],["node","nodejs","node js","node.js"],["github actions","gh actions","actions"],["postgresql","postgres","pg"],["kubernetes","k8s"],["npm","npm registry"],["cloudflare workers","cf workers","workers"],["google cloud run","cloud run","gcp cloud run"]],d4=new Map;pM.forEach(($,Z)=>$.forEach((z)=>d4.set(z,Z)));var lM=new Set(["a","an","the","and","or","of","for","to","in","on","with","is","it","its","their","your","via","by","using","use","used"]);function DZ($){return $.toLowerCase().replace(/[^a-z0-9\s.+#-]/g," ").replace(/\.(?=\s|$)/g," ").replace(/\s+/g," ").trim()}function bX($){return DZ($).split(" ").filter((Z)=>Z&&!lM.has(Z))}function iM($,Z){let z=DZ($),X=DZ(Z);if(!z||!X)return!1;if(z===X)return!0;let J=d4.get(z);if(J!==void 0&&d4.get(X)===J)return!0;let Q=bX($);if(Q.length===0)return!1;let Y=new Set(bX(Z));return Q.every((U)=>{if(Y.has(U))return!0;let G=d4.get(U);return G!==void 0&&[...Y].some((W)=>d4.get(W)===G)})}function nM($){let Z=H0($),z=J$($),X=[],J={},Q=0;for(let G of $0){if(Z.slots[G.path]!=="populated")continue;let W=Y7(z,G);if(typeof W!=="string")continue;let q=W.trim();if(!q||i8.has(q.toLowerCase()))continue;Q+=1,X.push({n:Q,path:G.path,question:dM(G.path,G.description)}),J[Q]=q}let Y=JSON.stringify({v:SX,q:X.map((G)=>[G.path,G.question])}),U=xX("sha256").update(Y).digest("hex").slice(0,12);return{version:SX,qsetHash:U,questions:X,answers:J}}function sM($,Z){let z=$.questions.map((J)=>{let Q=Z[String(J.n)]??Z[J.path]??"";return{n:J.n,path:J.path,ok:typeof Q==="string"&&Q.trim()!==""&&iM($.answers[J.n],Q)}}),X=$.questions.filter((J)=>!z[J.n-1].ok);return{correct:z.filter((J)=>J.ok).length,total:$.questions.length,misses:X,perQuestion:z}}var gX=".faf-bench.json";function rM($){let Z=fX($,gX);if(!yX(Z))return null;try{return JSON.parse(kX(Z,"utf-8"))}catch{return null}}function aM($,Z){uM(fX($,gX),JSON.stringify(Z,null,2)+`
427
+ `,"utf-8")}function IZ($,Z){let z=JSON.stringify({v:$.version,repo:Z??null,qset:$.qsetHash,protocol:$.protocol,cold:$.cold??null,faf:$.faf??null});return{projection:z,hash:xX("sha256").update(z).digest("hex")}}var I6=($)=>$===void 0?"—":`~${$.toLocaleString()}`;function oM($,Z){let{cold:z,faf:X}=$;console.log(`
428
428
  ${w(`faf bench — ${Z}`)}
429
429
  `),console.log(` ${N("without context")} ${D("with .faf")}`),console.log(`answers ${z.score}/${z.total} ${w(`${X.score}/${X.total}`)}`),console.log(`tokens ${I6(z.tokens)} ${I6(X.tokens)}`);let J=z.total-z.score;if(J>0)console.log(`
430
430
  ${N(`The ${J} missing answer${J===1?"":"s"} were already in your repo — unstructured.`)}`),console.log(N("Structured context closes the gap."));let Q=IZ($,Z);console.log(`
431
- ${V0("✪ BENCH RECEIPT")}`),console.log(N(` qset: ${$.qsetHash} protocol: ${$.protocol} model: ${X.model??z.model??"unreported"}`)),console.log(N(` cold ${z.score}/${z.total} · faf ${X.score}/${X.total} · sha256: ${Q.hash.slice(0,16)}…`))}function oM($,Z){let z=$.cold,X=z.total-z.score;if(console.log(`
431
+ ${V0("✪ BENCH RECEIPT")}`),console.log(N(` qset: ${$.qsetHash} protocol: ${$.protocol} model: ${X.model??z.model??"unreported"}`)),console.log(N(` cold ${z.score}/${z.total} · faf ${X.score}/${X.total} · sha256: ${Q.hash.slice(0,16)}…`))}function tM($,Z){let z=$.cold,X=z.total-z.score;if(console.log(`
432
432
  ${w(`faf bench — ${Z}`)} ${V0("Trouble ahead, expensive trouble.")}
433
433
  `),console.log(` ${N("without context")}`),console.log(`answers ${z.score}/${z.total} ${N("— the AI is guessing at what you are building")}`),z.tokens!==void 0)console.log(`tokens ${I6(z.tokens)} ${N("— re-derivation burn, paid again EVERY session")}`);if(X>0)console.log(`
434
434
  ${X} answer${X===1?"":"s"} missing: the stack it can dig out (you pay for the dig);`),console.log("what you are trying to DO, it cannot derive at any price."),console.log("Both are already in your repo — unstructured.");console.log(`
435
- ${D("→ faf init && faf bench")} ${N("(close the gap, get the receipt)")}`)}var tM="https://mcpaas.live/bench/submit";async function eM($,Z){try{let z=await fetch(Z,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)});console.log(N(z.ok?` ✪ submitted to ${Z}`:` submit failed (${z.status})`))}catch{console.log(N(" submit skipped (endpoint unreachable)"))}}function hX($,Z,z={}){let X=z.file??v();if(!X)console.error(`Error: project.faf not found
435
+ ${D("→ faf init && faf bench")} ${N("(close the gap, get the receipt)")}`)}var eM="https://mcpaas.live/bench/submit";async function $T($,Z){try{let z=await fetch(Z,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($)});console.log(N(z.ok?` ✪ submitted to ${Z}`:` submit failed (${z.status})`))}catch{console.log(N(" submit skipped (endpoint unreachable)"))}}function hX($,Z,z={}){let X=z.file??v();if(!X)console.error(`Error: project.faf not found
436
436
 
437
- Run 'faf init' to create one — bench needs the answer key.`),process.exit(2);let J=u(X),Q=iM(J),Y=uM(X),U=J$(J)?.project?.name??Y.split("/").pop();if(Q.questions.length===0)console.error("Error: no populated slots to derive questions from.\n\n Run `faf go` to fill the .faf first."),process.exit(2);if($==="questions"){if(z.json){console.log(JSON.stringify({version:Q.version,qsetHash:Q.qsetHash,questions:Q.questions.map(({n:G,question:W})=>({n:G,question:W}))},null,2));return}console.log(`
437
+ Run 'faf init' to create one — bench needs the answer key.`),process.exit(2);let J=u(X),Q=nM(J),Y=mM(X),U=J$(J)?.project?.name??Y.split("/").pop();if(Q.questions.length===0)console.error("Error: no populated slots to derive questions from.\n\n Run `faf go` to fill the .faf first."),process.exit(2);if($==="questions"){if(z.json){console.log(JSON.stringify({version:Q.version,qsetHash:Q.qsetHash,questions:Q.questions.map(({n:G,question:W})=>({n:G,question:W}))},null,2));return}console.log(`
438
438
  ${w(`faf bench — ${Q.questions.length} questions`)} ${N(`qset ${Q.qsetHash}`)}
439
439
  `);for(let G of Q.questions)console.log(` ${String(G.n).padStart(2)}. ${G.question}`);console.log(`
440
- ${N('Answer terse — the value, not a sentence. Save as JSON: {"1": "...", "2": "..."}')}`);return}if($==="grade"){if(!Z||!yX(Z))console.error("Error: faf bench grade <answers.json> — file not found."),process.exit(2);let G=JSON.parse(kX(Z,"utf-8")),W=G.answers??G,q=nM(Q,W),V={score:q.correct,total:q.total,...z.tokens?{tokens:parseInt(z.tokens,10)}:{},...z.model?{model:z.model}:{}},K=sM(Y),B=K&&K.qsetHash===Q.qsetHash?K:{version:Q.version,qsetHash:Q.qsetHash,protocol:"in-session"};if(z.cold)B.cold=V;else if(z.faf)B.faf=V;else console.error("Error: specify the run mode — --cold (no context) or --faf (after reading project.faf)."),process.exit(2);if(rM(Y,B),z.json){let O=IZ(B,U);console.log(JSON.stringify({...B,receipt:O.hash,perQuestion:q.perQuestion},null,2));return}if(B.cold&&B.faf)aM(B,U);if(z.submit&&B.cold&&B.faf){let{cold:O,faf:L}=B,M=IZ(B,U);eM({date:new Date().toISOString().slice(0,10),model:L.model??O.model??z.model??"unreported",repo:U,qset:B.qsetHash,cold:`${O.score}/${O.total}`,faf:`${L.score}/${L.total}`,sha256:M.hash.slice(0,16)},z.endpoint??tM)}else if(B.cold)oM(B,U);else console.log(`
440
+ ${N('Answer terse — the value, not a sentence. Save as JSON: {"1": "...", "2": "..."}')}`);return}if($==="grade"){if(!Z||!yX(Z))console.error("Error: faf bench grade <answers.json> — file not found."),process.exit(2);let G=JSON.parse(kX(Z,"utf-8")),W=G.answers??G,q=sM(Q,W),V={score:q.correct,total:q.total,...z.tokens?{tokens:parseInt(z.tokens,10)}:{},...z.model?{model:z.model}:{}},K=rM(Y),B=K&&K.qsetHash===Q.qsetHash?K:{version:Q.version,qsetHash:Q.qsetHash,protocol:"in-session"};if(z.cold)B.cold=V;else if(z.faf)B.faf=V;else console.error("Error: specify the run mode — --cold (no context) or --faf (after reading project.faf)."),process.exit(2);if(aM(Y,B),z.json){let O=IZ(B,U);console.log(JSON.stringify({...B,receipt:O.hash,perQuestion:q.perQuestion},null,2));return}if(B.cold&&B.faf)oM(B,U);if(z.submit&&B.cold&&B.faf){let{cold:O,faf:L}=B,M=IZ(B,U);$T({date:new Date().toISOString().slice(0,10),model:L.model??O.model??z.model??"unreported",repo:U,qset:B.qsetHash,cold:`${O.score}/${O.total}`,faf:`${L.score}/${L.total}`,sha256:M.hash.slice(0,16)},z.endpoint??eM)}else if(B.cold)tM(B,U);else console.log(`
441
441
  ${w(`faf bench — ${U}`)} ${D("with .faf")}: ${w(`${V.score}/${V.total}`)} ${N(`tokens ${I6(V.tokens)}`)}`),console.log(N("Run the cold phase too for the full pair: faf bench (protocol)."));return}console.log(`
442
442
  ${w("faf bench — agent-native protocol")} ${N(`qset ${Q.qsetHash} · ${Q.questions.length} questions`)}
443
443
  `),console.log(`${w("COLD phase")} ${N("(fresh AI session, repo access)")}`),console.log(' 1. Instruct: "Answer these questions from the repository.'),console.log(' Do NOT read project.faf, CLAUDE.md, AGENTS.md, or any *.faf file."'),console.log(` 2. ${D("faf bench questions")} — hand them over; answers terse, saved as cold.json`),console.log(` 3. ${D("faf bench grade cold.json --cold --tokens <used> --model <name>")}
444
444
  `),console.log(`${w("FAF phase")} ${N("(same questions, context first)")}`),console.log(' 4. Instruct: "Read project.faf, then answer the same questions." → faf.json'),console.log(` 5. ${D("faf bench grade faf.json --faf --tokens <used> --model <name>")}
445
- `),console.log(N("Grading is mechanical against your own project.faf — the .faf IS the answer key.")),console.log(N(`Receipts carry protocol: in-session (honor-system cold). qset ${Q.qsetHash}.`))}import{existsSync as $T,writeFileSync as ZT}from"fs";d();function vX($={}){let Z=v();if(!Z)console.error(`Error: project.faf not found
445
+ `),console.log(N("Grading is mechanical against your own project.faf — the .faf IS the answer key.")),console.log(N(`Receipts carry protocol: in-session (honor-system cold). qset ${Q.qsetHash}.`))}import{existsSync as ZT,writeFileSync as zT}from"fs";d();function vX($={}){let Z=v();if(!Z)console.error(`Error: project.faf not found
446
446
 
447
- Run 'faf init' to create one.`),process.exit(2);let z=u(Z),X=H0(z),J=new c0(process.cwd()),Q=J.load()?J.getBirthDNADisplay():null,Y=Q?Q.current:null,U=Y!=null?X.score-Y:0,G=Y!=null&&U!==0,W=Z.replace(/\.faf$/,".fafb"),q=null;if($T(W)){let V=y2(z);ZT(W,V),q=V.length}if($.json)console.log(JSON.stringify({reGrounded:!0,score:X.score,tier:X.tier,baseline:Y,delta:U,drifted:G,fafb:q!=null?{reCompiled:!0,bytes:q}:{reCompiled:!1},journey:J.getJourney()||null},null,2));else{if(console.log(`${D("refresh")} ${N("— re-grounding on the live .faf")}
447
+ Run 'faf init' to create one.`),process.exit(2);let z=u(Z),X=H0(z),J=new c0(process.cwd()),Q=J.load()?J.getBirthDNADisplay():null,Y=Q?Q.current:null,U=Y!=null?X.score-Y:0,G=Y!=null&&U!==0,W=Z.replace(/\.faf$/,".fafb"),q=null;if(ZT(W)){let V=y2(z);zT(W,V),q=V.length}if($.json)console.log(JSON.stringify({reGrounded:!0,score:X.score,tier:X.tier,baseline:Y,delta:U,drifted:G,fafb:q!=null?{reCompiled:!0,bytes:q}:{reCompiled:!1},journey:J.getJourney()||null},null,2));else{if(console.log(`${D("refresh")} ${N("— re-grounding on the live .faf")}
448
448
  `),G){let V=U>0?"↑":"↓";console.log(` drift: ${N(`${Y}%`)} ${V} ${w(`${X.score}%`)} ${N(`(${U>0?"+":""}${U})`)}`)}else if(Y!=null)console.log(` no drift ${N(`— steady at ${X.score}%`)}`);else console.log(` baseline set ${N(`— ${X.score}%`)}`);if(q!=null)console.log(` .fafb re-compiled ${N(`(${q} bytes — fast tier current)`)}`);console.log(` re-grounded: ${i$(X.tier)} ${w(`${X.score}%`)}`)}if(J.exists())J.recordGrowth(X.score,["refresh — re-grounded"]);else J.birth(X.score)}var{version:uX}=Z3(),h=new dZ;h.name("faf").description("Foundational AI-Context Format — project DNA for any AI").version(uX,"-v, --version");h.command("init").description("Create .faf from your project").option("--yolo","Quick init with sensible defaults").option("--quick","Alias for --yolo").option("--force","Overwrite existing project.faf").option("--output <path>","Output path").action(($)=>t8($));h.command("dna").description("\uD83E\uDDEC Show your FAF DNA journey (birth → growth)").action(()=>C7());h.command("auto").description("Zero to 100% in one command").action(()=>E7());h.command("go").description("Guided interview to gold code").option("--resume","Resume previous session").action(($)=>wz($));h.command("score [file]").description("Score a .faf file").option("--verbose","Show slot breakdown").option("--status","Compact one-liner output").option("--json","Output as JSON").action(($,Z)=>f2($,Z));h.command("bench [action] [answersFile]").description("AI-grounding benchmark — cold vs with-faf (the .faf is the answer key)").option("--json","Output as JSON").option("--cold","Grade as the without-context run").option("--faf","Grade as the with-context run").option("--tokens <n>","Tokens used in the run (reported by the agent)").option("--model <name>","Model that answered (reported)").option("--file <path>","Path to project.faf (default: discovered)").option("--submit","Submit the full-pair receipt to the public bench ledger").option("--endpoint <url>","Override the submit endpoint").action(($,Z,z)=>hX($,Z,z));h.command("show").description("Render project.faf → project.html and open it").action(()=>Xz());h.command("sync").description(".faf ↔ CLAUDE.md (bi-sync, mtime auto-direction)").option("--watch","Watch for changes").option("--direction <dir>","Force direction: auto|push|pull","auto").action(($)=>e8($));h.command("compile [file]").description("Compile .faf to .fafb binary").option("--output <path>","Output path").action(($,Z)=>c7($,Z));h.command("decompile <file>").description("Decompile .fafb to JSON").option("--output <path>","Output path").action(($,Z)=>d7($,Z));h.command("git <url>").description("Instant .faf from any GitHub repo").action(($)=>Qz($));h.command("export").description("Export context files from .faf").option("--agents","Generate AGENTS.md").option("--cursor","Generate .cursorrules").option("--gemini","Generate GEMINI.md").option("--grok","Wire grok-faf-mcp into .grok/config.toml").option("--conductor","Generate conductor config").option("--html","Generate project.html (visual render of project.faf)").option("--card","Generate MCP Server Card (.well-known/mcp/server-card) with the FAF context-block").option("--all","Generate all formats").action(($)=>t$($));h.command("check [file]").description("Validate .faf file").option("--strict","Require 100% score").option("--fix","Auto-fix issues").option("--doctor","Full diagnostic").option("--trust","Verify trust chain").action(($,Z)=>$3($,Z));h.command("info").description("Show version and system info").option("--version","Show version").option("--faq","Show FAQ").option("--index","Show command index").option("--stacks","Show supported stacks").action(($)=>Yz($));h.command("formats").description("Show supported formats").action(()=>Uz());h.command("clear").description("Clear cached data").action(()=>Gz());h.command("convert").description("Convert .faf to other formats").option("--json","Output as JSON").action(($)=>Wz($));h.command("context").description("Generate context output").action(()=>qz());h.command("refresh").description("Re-ground on the live .faf — re-score, measure drift vs the DNA baseline, keep .fafb current").option("--json","Output as JSON").action(($)=>vX($));h.command("drift").description("Check context drift").action(()=>Kz());h.command("edit <path> <value>").description("Edit .faf fields").action(($,Z)=>Hz($,Z));h.command("recover").description("Recover .faf from context files").action(()=>Bz());h.command("migrate").description("Migrate .faf to latest version").option("--dry-run","Preview changes without writing").action(($)=>Lz($));h.command("pro [subcommand]").description("Pro features & licensing").action(($)=>Nz($));h.command("share").description("Share .faf via URL").option("--copy","Copy to clipboard").option("--raw","Output encoded string only").action(($)=>Mz($));h.command("demo").description("Demo walkthrough").action(()=>Oz());h.command("search <query>").description("Search slots and formats").option("--slots","Search slots only").option("--formats","Search formats only").action(($,Z)=>Dz($,Z));h.command("taf").description("Test Archive Format receipt").option("--output <path>","Write receipt to file").action(($)=>Iz($));h.command("ai [subcommand]").description("AI-powered features (enhance|analyze)").action(($)=>wX($));h.command("conductor [subcommand] [path]").description("Conductor integration").action(($,Z)=>CX($,Z));h.command("wjttc").description("Audit test suite for WJTTC tier coverage (vendor-neutral)").option("--path <path>","Test directory (default: tests)").option("--strict","Exit non-zero if any tests are untiered").option("--json","Output as JSON for CI consumption").action(($)=>jX($));h.command("bi-sync",{hidden:!0}).action(()=>e8());h.command("status",{hidden:!0}).action(()=>f2(void 0,{status:!0}));h.command("agents",{hidden:!0}).action(()=>t$({agents:!0}));h.command("cursor",{hidden:!0}).action(()=>t$({cursor:!0}));h.command("gemini",{hidden:!0}).action(()=>t$({gemini:!0}));h.command("grok",{hidden:!0}).action(()=>t$({grok:!0}));h.command("validate",{hidden:!0}).action(($)=>$3($));h.command("yolo",{hidden:!0}).action(()=>t8({yolo:!0}));if(process.argv.length<=2)(async()=>{let{bold:$,dim:Z,fafCyan:z}=await Promise.resolve().then(() => (d(),Z7)),X=process.cwd().replace(process.env.HOME??"","~"),J="\x1B[38;2;150;150;150m",Q="\x1B[48;2;150;150;150m",Y="\x1B[38;2;29;29;29m",U="\x1B[48;2;29;29;29m",G="\x1B[0m";console.log(""),console.log(`\x1B[48;2;29;29;29m ${"\x1B[38;2;150;150;150m"}▄${"\x1B[48;2;150;150;150m"}███████${"\x1B[48;2;29;29;29m"}${"\x1B[38;2;150;150;150m"}▄${"\x1B[0m"}`),console.log(`\x1B[48;2;29;29;29m \x1B[48;2;150;150;150m${"\x1B[38;2;150;150;150m"}█${"\x1B[38;2;29;29;29m"}█${"\x1B[38;2;150;150;150m"}███████${"\x1B[0m"} ${z($("faf"))} ${Z(`v${uX}`)}`);let W="\x1B[38;2;39;174;96m";console.log(`\x1B[48;2;29;29;29m${"\x1B[38;2;150;150;150m"}▀${"\x1B[48;2;150;150;150m"}${"\x1B[38;2;29;29;29m"}▀${"\x1B[48;2;29;29;29m"} \x1B[48;2;150;150;150m${"\x1B[38;2;150;150;150m"}██${"\x1B[48;2;29;29;29m"} \x1B[48;2;150;150;150m${"\x1B[38;2;150;150;150m"}██${"\x1B[48;2;29;29;29m"} \x1B[0m ${Z("Nelly Never Forgets")}`),console.log(`${W}▔▔▔▔▔▔▔▔▔▔▔▔${"\x1B[0m"}`),console.log(`${Z(" "+X)}`),console.log("");try{await f2(void 0,{status:!0})}catch{}console.log(""),console.log(` ${Z("Run")} ${z("faf --help")} ${Z("for commands")}`)})();else h.parse(process.argv);
449
449
 
450
- //# debugId=D0EBCF9D679D47CD64756E2164756E21
450
+ //# debugId=FE24805BE0D29F4464756E2164756E21
451
451
  //# sourceMappingURL=cli.js.map