faf 8.2.0 → 8.2.2

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.
@@ -91,7 +91,7 @@ export declare function upsertCatalog(existing: AiCatalog | undefined, incoming:
91
91
  * the catalog cannot be edited that way (not a JSON object, `entries` not an
92
92
  * array, faf's row there twice, …).
93
93
  */
94
- export declare function upsertCatalogText(text: string | null, incoming: CatalogEntry[], host?: CatalogHost): {
94
+ export declare function upsertCatalogText(text: string | null, incoming: CatalogEntry[], host?: CatalogHost, changedAt?: string): {
95
95
  text: string;
96
96
  changed: boolean;
97
97
  };
@@ -2,8 +2,8 @@ import type { FafData } from '../core/types.js';
2
2
  /** Read CLAUDE.md from a directory. A CLAUDE.md link that leaves the
3
3
  * directory, or leads to a file that is not an AI context file, is refused
4
4
  * (SafePathError) and nothing is read; CLAUDE.md → AGENTS.md is read
5
- * through. A CLAUDE.md that is not UTF-8 is refused too (`faf sync --direction
6
- * pull` writes what it reads into project.faf). */
5
+ * through. A CLAUDE.md that is not UTF-8 is refused too. Library export;
6
+ * `faf sync` never reads CLAUDE.md back into project.faf. */
7
7
  export declare function readClaudeMd(dir: string): string | null;
8
8
  /** Write CLAUDE.md — non-destructive: injects/updates the faf block, preserves the rest. */
9
9
  export declare function writeClaudeMd(dir: string, content: string): void;
@@ -11,7 +11,7 @@ import { type KeptAlias } from '../core/yaml-edit.js';
11
11
  * through as it is. Every command that hands project.faf (or a .fafb) to
12
12
  * the kernel calls it through here, after it has read the file as a .faf
13
13
  * ({@link readFaf}, or {@link readFafFromString} with the path); one that
14
- * edits project.faf (`faf auto`, `faf go`, `faf sync --direction pull`)
14
+ * edits project.faf (`faf auto`, `faf go`)
15
15
  * asks the kernel before it writes, so the line is true. `faf diff` and
16
16
  * `faf log` score a version the kernel cannot read as 0 instead. */
17
17
  export declare function withKernel<T>(path: string, call: () => T): T;
package/dist/pack.js CHANGED
@@ -54,8 +54,8 @@ ${U.key.commentBefore}`:H.commentBefore;if(H.comment){let G=U.value??U.key;G.com
54
54
  ${G.comment}`:H.comment}H=U}$.items[Z]=_(H)?H:new j(H)}else X("Expected a sequence for this tag");return $}function D$($,X,Z){let{replacer:H}=Z,U=new h($);U.tag="tag:yaml.org,2002:pairs";let G=0;if(X&&Symbol.iterator in Object(X))for(let z of X){if(typeof H==="function")z=H.call(X,String(G++),z);let Q,J;if(Array.isArray(z))if(z.length===2)Q=z[0],J=z[1];else throw TypeError(`Expected [key, value] tuple: ${z}`);else if(z&&z instanceof Object){let B=Object.keys(z);if(B.length===1)Q=B[0],J=z[Q];else throw TypeError(`Expected tuple with one key, not ${B.length} keys`)}else Q=z;U.items.push(Y0(Q,J,Z))}return U}var b0={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:_$,createNode:D$};class I0 extends h{constructor(){super();this.add=C.prototype.add.bind(this),this.delete=C.prototype.delete.bind(this),this.get=C.prototype.get.bind(this),this.has=C.prototype.has.bind(this),this.set=C.prototype.set.bind(this),this.tag=I0.tag}toJSON($,X){if(!X)return super.toJSON($);let Z=new Map;if(X?.onCreate)X.onCreate(Z);for(let H of this.items){let U,G;if(_(H))U=N(H.key,"",X),G=N(H.value,U,X);else U=N(H,"",X);if(Z.has(U))throw Error("Ordered maps must not include duplicate keys");Z.set(U,G)}return Z}static from($,X,Z){let H=D$($,X,Z),U=new this;return U.items=H.items,U}}I0.tag="tag:yaml.org,2002:omap";var A0={collection:"seq",identify:($)=>$ instanceof Map,nodeClass:I0,default:!1,tag:"tag:yaml.org,2002:omap",resolve($,X){let Z=_$($,X),H=[];for(let{key:U}of Z.items)if(O(U))if(H.includes(U.value))X(`Ordered maps must not include duplicate keys: ${U.value}`);else H.push(U.value);return Object.assign(new I0,Z)},createNode:($,X,Z)=>I0.from($,X,Z)};function e$({value:$,source:X},Z){if(X&&($?K$:w$).test.test(X))return X;return $?Z.options.trueStr:Z.options.falseStr}var K$={identify:($)=>$===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new F(!0),stringify:e$},w$={identify:($)=>$===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new F(!1),stringify:e$};var $2={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:($)=>$.slice(-3).toLowerCase()==="nan"?NaN:$[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:E},X2={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:($)=>parseFloat($.replace(/_/g,"")),stringify($){let X=Number($.value);return isFinite(X)?X.toExponential():E($)}},Z2={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve($){let X=new F(parseFloat($.replace(/_/g,""))),Z=$.indexOf(".");if(Z!==-1){let H=$.substring(Z+1).replace(/_/g,"");if(H[H.length-1]==="0")X.minFractionDigits=H.length}return X},stringify:E};var N0=($)=>typeof $==="bigint"||Number.isInteger($);function Z$($,X,Z,{intAsBigInt:H}){let U=$[0];if(U==="-"||U==="+")X+=1;if($=$.substring(X).replace(/_/g,""),H){switch(Z){case 2:$=`0b${$}`;break;case 8:$=`0o${$}`;break;case 16:$=`0x${$}`;break}let z=BigInt($);return U==="-"?BigInt(-1)*z:z}let G=parseInt($,Z);return U==="-"?-1*G:G}function P$($,X,Z){let{value:H}=$;if(N0(H)){let U=H.toString(X);return H<0?"-"+Z+U.substr(1):Z+U}return E($)}var H2={identify:N0,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:($,X,Z)=>Z$($,2,2,Z),stringify:($)=>P$($,2,"0b")},U2={identify:N0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:($,X,Z)=>Z$($,1,8,Z),stringify:($)=>P$($,8,"0")},G2={identify:N0,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:($,X,Z)=>Z$($,0,10,Z),stringify:E},z2={identify:N0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:($,X,Z)=>Z$($,2,16,Z),stringify:($)=>P$($,16,"0x")};class F0 extends C{constructor($){super($);this.tag=F0.tag}add($){let X;if(_($))X=$;else if($&&typeof $==="object"&&"key"in $&&"value"in $&&$.value===null)X=new j($.key,null);else X=new j($,null);if(!$0(this.items,X.key))this.items.push(X)}get($,X){let Z=$0(this.items,$);return!X&&_(Z)?O(Z.key)?Z.key.value:Z.key:Z}set($,X){if(typeof X!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof X}`);let Z=$0(this.items,$);if(Z&&!X)this.items.splice(this.items.indexOf(Z),1);else if(!Z&&X)this.items.push(new j($))}toJSON($,X){return super.toJSON($,X,Set)}toString($,X,Z){if(!$)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},$,{allNullValues:!0}),X,Z);else throw Error("Set items must all have null values")}static from($,X,Z){let{replacer:H}=Z,U=new this($);if(X&&Symbol.iterator in Object(X))for(let G of X){if(typeof H==="function")G=H.call(X,G,G);U.items.push(Y0(G,null,Z))}return U}}F0.tag="tag:yaml.org,2002:set";var j0={collection:"map",identify:($)=>$ instanceof Set,nodeClass:F0,default:!1,tag:"tag:yaml.org,2002:set",createNode:($,X,Z)=>F0.from($,X,Z),resolve($,X){if(v($))if($.hasAllNullValues(!0))return Object.assign(new F0,$);else X("Set items must all have null values");else X("Expected a mapping for this tag");return $}};function M$($,X){let Z=$[0],H=Z==="-"||Z==="+"?$.substring(1):$,U=(z)=>X?BigInt(z):Number(z),G=H.replace(/_/g,"").split(":").reduce((z,Q)=>z*U(60)+U(Q),U(0));return Z==="-"?U(-1)*G:G}function J2($){let{value:X}=$,Z=(z)=>z;if(typeof X==="bigint")Z=(z)=>BigInt(z);else if(isNaN(X)||!isFinite(X))return E($);let H="";if(X<0)H="-",X*=Z(-1);let U=Z(60),G=[X%U];if(X<60)G.unshift(0);else if(X=(X-G[0])/U,G.unshift(X%U),X>=60)X=(X-G[0])/U,G.unshift(X);return H+G.map((z)=>String(z).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var H$={identify:($)=>typeof $==="bigint"||Number.isInteger($),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:($,X,{intAsBigInt:Z})=>M$($,Z),stringify:J2},U$={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:($)=>M$($,!1),stringify:J2},R0={identify:($)=>$ instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve($){let X=$.match(R0.test);if(!X)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,Z,H,U,G,z,Q]=X.map(Number),J=X[7]?Number((X[7]+"00").substr(1,3)):0,B=Date.UTC(Z,H-1,U,G||0,z||0,Q||0,J),R=X[8];if(R&&R!=="Z"){let W=M$(R,!1);if(Math.abs(W)<30)W*=60;B-=60000*W}return new Date(B)},stringify:({value:$})=>$?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};var b$=[l,c,X0,J0,K$,w$,H2,U2,G2,z2,$2,X2,Z2,M0,p,A0,b0,j0,H$,U$,R0];var Q2=new Map([["core",r$],["failsafe",[l,c,X0]],["json",t$],["yaml11",b$],["yaml-1.1",b$]]),B2={binary:M0,bool:P0,float:r0,floatExp:a0,floatNaN:n0,floatTime:U$,int:e0,intHex:$$,intOct:t0,intTime:H$,map:l,merge:p,null:J0,omap:A0,pairs:b0,seq:c,set:j0,timestamp:R0},W2={"tag:yaml.org,2002:binary":M0,"tag:yaml.org,2002:merge":p,"tag:yaml.org,2002:omap":A0,"tag:yaml.org,2002:pairs":b0,"tag:yaml.org,2002:set":j0,"tag:yaml.org,2002:timestamp":R0};function G$($,X,Z){let H=Q2.get(X);if(H&&!$)return Z&&!H.includes(p)?H.concat(p):H.slice();let U=H;if(!U)if(Array.isArray($))U=[];else{let G=Array.from(Q2.keys()).filter((z)=>z!=="yaml11").map((z)=>JSON.stringify(z)).join(", ");throw Error(`Unknown schema "${X}"; use one of ${G} or define customTags array`)}if(Array.isArray($))for(let G of $)U=U.concat(G);else if(typeof $==="function")U=$(U.slice());if(Z)U=U.concat(p);return U.reduce((G,z)=>{let Q=typeof z==="string"?B2[z]:z;if(!Q){let J=JSON.stringify(z),B=Object.keys(B2).map((R)=>JSON.stringify(R)).join(", ");throw Error(`Unknown custom tag ${J}; use one of ${B}`)}if(!G.includes(Q))G.push(Q);return G},[])}var m2=($,X)=>$.key<X.key?-1:$.key>X.key?1:0;class S0{constructor({compat:$,customTags:X,merge:Z,resolveKnownTags:H,schema:U,sortMapEntries:G,toStringDefaults:z}){this.compat=Array.isArray($)?G$($,"compat"):$?G$(null,$):null,this.name=typeof U==="string"&&U||"core",this.knownTags=H?W2:{},this.tags=G$(X,this.name,Z),this.toStringOptions=z??null,Object.defineProperty(this,x,{value:l}),Object.defineProperty(this,H0,{value:X0}),Object.defineProperty(this,r,{value:c}),this.sortMapEntries=typeof G==="function"?G:G===!0?m2:null}clone(){let $=Object.create(S0.prototype,Object.getOwnPropertyDescriptors(this));return $.tags=this.tags.slice(),$}}function V2($,X){let Z=[],H=X.directives===!0;if(X.directives!==!1&&$.directives){let J=$.directives.toString($);if(J)Z.push(J),H=!0;else if($.directives.docStart)H=!0}if(H)Z.push("---");let U=d0($,X),{commentString:G}=U.options;if($.commentBefore){if(Z.length!==1)Z.unshift("");let J=G($.commentBefore);Z.unshift(f(J,""))}let z=!1,Q=null;if($.contents){if(D($.contents)){if($.contents.spaceBefore&&H)Z.push("");if($.contents.commentBefore){let R=G($.contents.commentBefore);Z.push(f(R,""))}U.forceBlockIndent=!!$.comment,Q=$.contents.comment}let J=Q?void 0:()=>z=!0,B=t($.contents,U,()=>Q=null,J);if(Q)B+=n(B,"",G(Q));if((B[0]==="|"||B[0]===">")&&Z[Z.length-1]==="---")Z[Z.length-1]=`--- ${B}`;else Z.push(B)}else Z.push(t($.contents,U));if($.directives?.docEnd)if($.comment){let J=G($.comment);if(J.includes(`
55
55
  `))Z.push("..."),Z.push(f(J,""));else Z.push(`... ${J}`)}else Z.push("...");else{let J=$.comment;if(J&&z)J=J.replace(/^\n+/,"");if(J){if((!z||Q)&&Z[Z.length-1]!=="")Z.push("");Z.push(f(G(J),""))}}return Z.join(`
56
56
  `)+`
57
- `}class Q0{constructor($,X,Z){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,g,{value:g0});let H=null;if(typeof X==="function"||Array.isArray(X))H=X;else if(Z===void 0&&X)Z=X,X=void 0;let U=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},Z);this.options=U;let{version:G}=U;if(Z?._directives){if(this.directives=Z._directives.atDocument(),this.directives.yaml.explicit)G=this.directives.yaml.version}else this.directives=new S({version:G});this.setSchema(G,Z),this.contents=$===void 0?null:this.createNode($,H,Z)}clone(){let $=Object.create(Q0.prototype,{[g]:{value:g0}});if($.commentBefore=this.commentBefore,$.comment=this.comment,$.errors=this.errors.slice(),$.warnings=this.warnings.slice(),$.options=Object.assign({},this.options),this.directives)$.directives=this.directives.clone();if($.schema=this.schema.clone(),$.contents=D(this.contents)?this.contents.clone($.schema):this.contents,this.range)$.range=this.range.slice();return $}add($){if(L0(this.contents))this.contents.add($)}addIn($,X){if(L0(this.contents))this.contents.addIn($,X)}createAlias($,X){if(!$.anchor){let Z=V$(this);$.anchor=!X||Z.has(X)?q$(X||"a",Z):X}return new G0($.anchor)}createNode($,X,Z){let H=void 0;if(typeof X==="function")$=X.call({"":$},"",$),H=X;else if(Array.isArray(X)){let V=(P)=>typeof P==="number"||P instanceof String||P instanceof Number,I=X.filter(V).map(String);if(I.length>0)X=X.concat(I);H=X}else if(Z===void 0&&X)Z=X,X=void 0;let{aliasDuplicateObjects:U,anchorPrefix:G,flow:z,keepUndefined:Q,onTagObj:J,tag:B}=Z??{},{onAnchor:R,setAnchors:W,sourceObjects:T}=v$(this,G||"a"),Y={aliasDuplicateObjects:U??!0,keepUndefined:Q??!1,onAnchor:R,onTagObj:J,replacer:H,schema:this.schema,sourceObjects:T},L=o($,B,Y);if(z&&w(L))L.flow=!0;return W(),L}createPair($,X,Z={}){let H=this.createNode($,null,Z),U=this.createNode(X,null,Z);return new j(H,U)}delete($){return L0(this.contents)?this.contents.delete($):!1}deleteIn($){if(q0($)){if(this.contents==null)return!1;return this.contents=null,!0}return L0(this.contents)?this.contents.deleteIn($):!1}get($,X){return w(this.contents)?this.contents.get($,X):void 0}getIn($,X){if(q0($))return!X&&O(this.contents)?this.contents.value:this.contents;return w(this.contents)?this.contents.getIn($,X):void 0}has($){return w(this.contents)?this.contents.has($):!1}hasIn($){if(q0($))return this.contents!==void 0;return w(this.contents)?this.contents.hasIn($):!1}set($,X){if(this.contents==null)this.contents=_0(this.schema,[$],X);else if(L0(this.contents))this.contents.set($,X)}setIn($,X){if(q0($))this.contents=X;else if(this.contents==null)this.contents=_0(this.schema,Array.from($),X);else if(L0(this.contents))this.contents.setIn($,X)}setSchema($,X={}){if(typeof $==="number")$=String($);let Z;switch($){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new S({version:"1.1"});Z={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=$;else this.directives=new S({version:$});Z={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;Z=null;break;default:{let H=JSON.stringify($);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${H}`)}}if(X.schema instanceof Object)this.schema=X.schema;else if(Z)this.schema=new S0(Object.assign(Z,X));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:$,jsonArg:X,mapAsMap:Z,maxAliasCount:H,onAnchor:U,reviver:G}={}){let z={anchors:new Map,doc:this,keep:!$,mapAsMap:Z===!0,mapKeyWarned:!1,maxAliasCount:typeof H==="number"?H:100},Q=N(this.contents,X??"",z);if(typeof U==="function")for(let{count:J,res:B}of z.anchors.values())U(B,J);return typeof G==="function"?e(G,{"":Q},"",Q):Q}toJSON($,X){return this.toJS({json:!0,jsonArg:$,mapAsMap:!1,onAnchor:X})}toString($={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in $&&(!Number.isInteger($.indent)||Number($.indent)<=0)){let X=JSON.stringify($.indent);throw Error(`"indent" option must be a positive integer, not ${X}`)}return V2(this,$)}}function L0($){if(w($))return!0;throw Error("Expected a YAML collection as document contents")}var j$=Symbol("break visit"),i2=Symbol("skip children"),T2=Symbol("remove item");function B0($,X){if("type"in $&&$.type==="document")$={start:$.start,value:$.value};Y2(Object.freeze([]),$,X)}B0.BREAK=j$;B0.SKIP=i2;B0.REMOVE=T2;B0.itemAtPath=($,X)=>{let Z=$;for(let[H,U]of X){let G=Z?.[H];if(G&&"items"in G)Z=G.items[U];else return}return Z};B0.parentCollection=($,X)=>{let Z=B0.itemAtPath($,X.slice(0,-1)),H=X[X.length-1][0],U=Z?.[H];if(U&&"items"in U)return U;throw Error("Parent collection not found")};function Y2($,X,Z){let H=Z(X,$);if(typeof H==="symbol")return H;for(let U of["key","value"]){let G=X[U];if(G&&"items"in G){for(let z=0;z<G.items.length;++z){let Q=Y2(Object.freeze($.concat([[U,z]])),G.items[z],Z);if(typeof Q==="number")z=Q-1;else if(Q===j$)return j$;else if(Q===T2)G.items.splice(z,1),z-=1}if(typeof H==="function"&&U==="key")H=H(X,$)}}return typeof H==="function"?H(X,$):H}var i5=new Set("0123456789ABCDEFabcdef"),s5=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),n5=new Set(",[]{}"),a5=new Set(` ,[]{}
58
- \r `);function S$($,X,Z){let H=null;if(typeof X==="function"||Array.isArray(X))H=X;else if(Z===void 0&&X)Z=X;if(typeof Z==="string")Z=Z.length;if(typeof Z==="number"){let U=Math.round(Z);Z=U<1?void 0:U>8?{indent:8}:{indent:U}}if($===void 0){let{keepUndefined:U}=Z??X??{};if(!U)return}if(m($)&&!H)return $.toString(Z);return new Q0($,H,Z).toString(Z)}var I2="https://faf.one/ext/context/v1";function J$($,X={}){return{faf:X.fafPointer??"./project.faf",mediaType:"application/vnd.faf+yaml",iana:"https://www.iana.org/assignments/media-types/application/vnd.faf+yaml",deterministic:!0,...X.scoreEndpoint?{scoreEndpoint:X.scoreEndpoint}:{},generated:$.generated??X.now??new Date().toISOString()}}function F2($,X={}){let Z={"one.faf/context":J$($,X)},H=new TextEncoder().encode(JSON.stringify(Z)).length;if(H>4096)throw Error(`publisher-provided _meta is ${H}B — exceeds the registry ${"4096"}B cap`);return{["io.modelcontextprotocol.registry/publisher-provided"]:Z}}var e2="JSONRPC",R2="1.0",g$=["application/vnd.faf+yaml","application/vnd.fafm+yaml","application/vnd.fafa+yaml"],$9="https://static.modelcontextprotocol.io/schemas/v1/server-card.schema.json",X9="https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",L2="1.0",O2="1.0",C$={a2a:"application/a2a-agent-card+json",server_card:"application/mcp-server-card+json",fafa:"application/vnd.fafa+yaml"};function Z9($){return($.endpoints??[]).filter((X)=>String(X.protocol??"").toLowerCase()==="a2a"&&X.location)}function _2($,X={}){let Z=Z9($);if(Z.length>0)return Z;let H=X.doorUrl?.trim();if(H)return[{protocol:"a2a",location:H,version:R2}];return[]}function H9($){try{return`https://${C0($)}/.well-known/fafa`}catch{return}}function U9($,X,Z={}){let H=J$(X,Z),U=$.agent??{},G={fafaSpecVersion:String($.version??O2),mediaTypes:[...g$],provenance:{faf:H.faf,mediaType:H.mediaType},generated:H.generated};if(U.id)G.agentId=U.id;let z=H9($);if(z)G.passport=z;return{uri:I2,description:"FAF passport and project DNA as typed parts",required:!1,params:G}}function G9($){let X=new Set;for(let Z of $.capabilities??[])if(Z.cites_spec&&g$.includes(Z.cites_spec))X.add(Z.cites_spec);return["text/plain",...X]}function z9($,X={}){let Z=$.agent??{},H=_2($,X);if(H.length===0)throw Error("No A2A endpoint in .fafa (need endpoints[].protocol: a2a + location). Will not invent a door.");let U=String(Z.displayName??$.metadata?.persona??Z.name??"").trim(),G=String(Z.description??"").trim(),z=String(Z.version??"").trim();if(!U||!G||!z)throw Error("A2A card needs agent.displayName|name, description, version in .fafa");let Q=String(Z.vendor??"").trim(),J=String(Z.homepage??"").trim(),B=Q&&J?{organization:Q,url:J}:void 0,R=($.capabilities??[]).map((W)=>{let T=String(W.name??"").trim();if(!T)throw Error("A2A skill missing capabilities[].name");let Y=Array.isArray(W.tags)?W.tags.map(String):[],L=W.cites_spec&&g$.includes(W.cites_spec)?[W.cites_spec,"text/plain"]:void 0;return{id:T,name:T,description:String(W.description??"").trim()||T,tags:Y,...L?{inputModes:L}:{}}});return{name:U,description:G,supportedInterfaces:H.map((W)=>({url:String(W.location),protocolBinding:e2,protocolVersion:String(W.version??R2)})),...B?{provider:B}:{},version:z,capabilities:{streaming:!1,pushNotifications:!1,extendedAgentCard:!1,extensions:[...X.extensions??[]]},defaultInputModes:G9($),defaultOutputModes:["text/plain","application/json"],skills:R}}var J9=/^[a-z0-9][a-z0-9._-]*$/,Q9=/^(@[a-z0-9~][a-z0-9-._~]*\/)?[a-z0-9~][a-z0-9-._~]*$/,B9=/^[A-Za-z0-9]([A-Za-z0-9._-]*[A-Za-z0-9])?$/,W9=/^[A-Za-z0-9][^\s]*$/,V9=["a2a","mcp"],q9=/^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}$/;function q($){return String($??"").trim()}function Q$($){return Array.isArray($)?$.map(q).filter(Boolean):[]}function T9($){return q($).toLowerCase().replace(/^https?:\/\//,"").replace(/\/.*$/,"").replace(/^www\./,"")}function Y9($,X,Z){let H=["display_name","description","version"].filter((U)=>!q($[U]));if(H.length)throw Error(`Missing answer: ${H.join(", ")}`);if(!J9.test(X))throw Error("Short name: lowercase letters, digits, dots, hyphens or underscores.");if(!q9.test(Z))throw Error(`Domain "${$.domain}" is not a domain name (e.g. example.com).`)}function I9($,X){return($.skills??[]).filter((Z)=>q(Z.name)).map((Z)=>({name:q(Z.name),type:q(Z.type)||"tool",description:q(Z.description)||q(Z.name),tags:X.length?X:[q(Z.name).toLowerCase()]}))}function F9($){let X=($.packages??[]).filter((Z)=>q(Z.registryType)&&q(Z.identifier));for(let Z of X){let H=q(Z.registryType),U=q(Z.identifier);if(H==="npm"&&!Q9.test(U))throw Error(`Package "${U}" is not an npm package name (e.g. weather-mcp or @acme/weather).`);if(H==="pypi"&&!B9.test(U))throw Error(`Package "${U}" is not a PyPI package name (e.g. weather-mcp or weather_mcp).`);if(H!=="npm"&&H!=="pypi"&&!W9.test(U))throw Error(`Package "${U}" is not a ${H} package identifier: it must start with a letter or digit and have no spaces.`)}return X.map((Z)=>({registryType:q(Z.registryType),identifier:q(Z.identifier),...q(Z.version)?{version:q(Z.version)}:{}}))}function R9($){if(!/^https?:\/\/[^\s/]+/i.test(q($.url)))throw Error(`Where it runs: "${q($.url)}" is not an http(s) URL (or give an npm package).`);if(!V9.includes(q($.protocol).toLowerCase()))throw Error(`Protocol "${q($.protocol)}": a2a or mcp.`)}function L9($,X){let Z=($.endpoints??[]).filter((U)=>q(U.url));Z.forEach(R9);let H=[...Z.map((U)=>({protocol:q(U.protocol).toLowerCase(),transport:"http",location:q(U.url)})),...X.map((U)=>({protocol:"mcp",transport:"stdio",location:U.identifier}))];if(H.length===0)throw Error("Missing answer: endpoints (a URL, or a package people install)");return H}function O9($,X,Z,H){let U={domain:X},G=[["repository",q($.repository)],["icon",q($.icon)],["organizationUrl",q($.organization_url)]];for(let[Q,J]of G)if(J)U[Q]=J;if(Z.length)U.keywords=Z;let z=Q$($.example_requests);if(z.length)U.examples=z;if(H.length)U.packages=H;return U}function _9($){let X=q($.handle).toLowerCase(),Z=T9($.domain);Y9($,X,Z);let H=Q$($.tags),U=F9($),G={name:X,displayName:q($.display_name),id:`urn:air:${Z}:agent:${X}`,...q($.organization)?{vendor:q($.organization)}:{},version:q($.version),description:q($.description),homepage:q($.homepage)||`https://${Z}`,...q($.license)?{license:q($.license)}:{}};return{version:O2,agent:G,capabilities:I9($,H),endpoints:L9($,U),metadata:{cards:O9($,Z,H,U)}}}function D9($){return S$($,{lineWidth:0})}function C0($){let X=q($.agent?.id),Z=/^urn:air:([^:]+):/.exec(X);if(Z)return Z[1];let H=q($.metadata?.cards?.domain);if(H)return H;try{return new URL(q($.agent?.homepage)).hostname.replace(/^www\./,"")}catch{throw Error("The .fafa names no domain (agent.id urn:air, metadata.cards.domain or agent.homepage).")}}function f6($){return y$($)}function y$($){let X=q($.agent?.name).toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/^-+|-+$/g,"");if(!X)throw Error("The .fafa needs agent.name (the short name).");return X}function D2($){return`${C0($).split(".").reverse().join(".")}/${y$($)}`}function E$($){let X=$.replace(/\s+/g," ").trim();return X.length<=100?X:`${X.slice(0,97).trimEnd()}...`}function B$($){return($.endpoints??[]).filter((X)=>q(X.protocol).toLowerCase()==="mcp"&&/^https?:\/\//.test(q(X.location))).map((X)=>({type:"streamable-http",url:q(X.location)}))}function K9($){if(!$)return;try{let X=new URL($).hostname.replace(/^www\./,"");return{url:$,source:X.split(".")[0]}}catch{return}}function K2($){let X=$.agent??{},Z=$.metadata?.cards??{},H=q(X.description),U=q(X.version);if(!H||!U)throw Error("An MCP card needs agent.description and agent.version in .fafa");let G={name:D2($),version:U,description:E$(H)},z=q(X.displayName);if(z)G.title=E$(z);let Q=q(X.homepage);if(Q)G.websiteUrl=Q;let J=K9(q(Z.repository));if(J)G.repository=J;if(q(Z.icon))G.icons=[{src:q(Z.icon)}];return G}function w2($){return($.metadata?.cards?.packages??[]).map((X)=>({registryType:q(X.registryType),identifier:q(X.identifier),...q(X.version)?{version:q(X.version)}:{},transport:{type:"stdio"}}))}function h6($){return B$($).length>0||w2($).length>0}function k6($){let X=q($.agent?.displayName);return{name:D2($),...X?{title:E$(X)}:{}}}function w9($,X,Z={}){let H=B$($);if(H.length===0)throw Error("A Server Card describes a remote MCP server: the .fafa has no mcp endpoint at an http(s) URL.");return{$schema:$9,...K2($),remotes:H,...X?{_meta:{"one.faf/context":J$(X,Z)}}:{}}}function P9($,X,Z={}){let H=B$($),U=w2($);if(H.length===0&&U.length===0)throw Error("A registry entry needs a package people install or a remote MCP URL.");return{$schema:X9,...K2($),...U.length?{packages:U}:{},...H.length?{remotes:H}:{},...X?{_meta:F2(X,Z)}:{}}}function M9($,X,Z){if(!X.includes("a2a")||_2($,Z).length===0)return;return Z.a2aCardUrl??`https://${C0($)}/.well-known/agent-card.json`}function P2($,X,Z={}){let H=C0($),U=y$($),G=$.agent??{},z=q(G.displayName)||q(G.name),Q=q(G.description),J=q(G.version),B=Z.now??new Date().toISOString(),R=(Y,L,V)=>({identifier:`urn:air:${H}:${Y}:${U}`,displayName:z,type:L,description:Q,url:V,...J?{version:J}:{},updatedAt:B}),W=[],T=M9($,X,Z);if(T)W.push(R("a2a",C$.a2a,T));if(X.includes("server_card")){let Y=B$($)[0];if(Y)W.push(R("mcp",C$.server_card,`${Y.url.replace(/\/+$/,"")}/server-card`))}if(Z.listFafa!==!1)W.push(R("agent",C$.fafa,`https://${H}/.well-known/fafa`));return W}function M2($){let X=$.agent??{},Z=q(X.vendor)||q(X.displayName)||q(X.name);if(!Z)return;let H;try{H=C0($)}catch{H=void 0}return{displayName:Z,...H?{identifier:H}:{}}}function b9($,X,Z={}){let H=M2($);return{specVersion:L2,...H?{host:H}:{},entries:P2($,X,Z)}}function A9($){let X=$.metadata?.cards??{},Z=Q$(X.keywords),H=Q$(X.examples);return{...Z.length?{tags:Z}:{},...H.length?{representativeQueries:H}:{}}}function N9($,X,Z={}){let H=M2($),U=A9($);return{specVersion:L2,...H?{host:H}:{},entries:P2($,X,Z).map((G)=>({...G,...U}))}}function j9($,X){let Z=new Set(X.cards),H={fafa:$,fafaText:D9($)},{faf:U}=X;if(Z.has("a2a")){let z=[...X.a2aExtensions??[],...U?[U9($,U,X)]:[]];H.a2a=z9($,{extensions:z})}if(Z.has("server_card"))H.server_card=w9($,U,X);if(Z.has("server_json"))H.server_json=P9($,U,X);let G={now:X.now,listFafa:X.listFafa};if(Z.has("ai_catalog"))H.ai_catalog=b9($,X.cards,G);if(Z.has("ard"))H.ard=N9($,X.cards,G);return H}function x6($,X){return j9(_9($),X)}export{k6 as registryIdentity,P9 as projectServerJson,w9 as projectServerCard,j9 as projectPack,N9 as projectArd,b9 as projectAiCatalog,z9 as projectA2ACard,B$ as mcpRemotes,D2 as mcpName,h6 as hasRegistryEntry,D9 as fafaYaml,f6 as fafaHandle,C0 as fafaDomain,U9 as fafaContextExtension,P2 as catalogRows,M2 as catalogHost,x6 as buildPack,A9 as ardHints,_9 as answersToFafa,Z9 as a2aEndpoints,_2 as a2aDoors,X9 as SERVER_JSON_SCHEMA,$9 as SERVER_CARD_SCHEMA,g$ as FAF_MEDIA_TYPES,O2 as FAFA_SPEC_VERSION,C$ as CARD_MEDIA_TYPES,L2 as AI_CATALOG_SPEC_VERSION,R2 as A2A_PROTOCOL_VERSION,e2 as A2A_PROTOCOL_BINDING};
57
+ `}class Q0{constructor($,X,Z){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,g,{value:g0});let H=null;if(typeof X==="function"||Array.isArray(X))H=X;else if(Z===void 0&&X)Z=X,X=void 0;let U=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},Z);this.options=U;let{version:G}=U;if(Z?._directives){if(this.directives=Z._directives.atDocument(),this.directives.yaml.explicit)G=this.directives.yaml.version}else this.directives=new S({version:G});this.setSchema(G,Z),this.contents=$===void 0?null:this.createNode($,H,Z)}clone(){let $=Object.create(Q0.prototype,{[g]:{value:g0}});if($.commentBefore=this.commentBefore,$.comment=this.comment,$.errors=this.errors.slice(),$.warnings=this.warnings.slice(),$.options=Object.assign({},this.options),this.directives)$.directives=this.directives.clone();if($.schema=this.schema.clone(),$.contents=D(this.contents)?this.contents.clone($.schema):this.contents,this.range)$.range=this.range.slice();return $}add($){if(L0(this.contents))this.contents.add($)}addIn($,X){if(L0(this.contents))this.contents.addIn($,X)}createAlias($,X){if(!$.anchor){let Z=V$(this);$.anchor=!X||Z.has(X)?q$(X||"a",Z):X}return new G0($.anchor)}createNode($,X,Z){let H=void 0;if(typeof X==="function")$=X.call({"":$},"",$),H=X;else if(Array.isArray(X)){let V=(P)=>typeof P==="number"||P instanceof String||P instanceof Number,I=X.filter(V).map(String);if(I.length>0)X=X.concat(I);H=X}else if(Z===void 0&&X)Z=X,X=void 0;let{aliasDuplicateObjects:U,anchorPrefix:G,flow:z,keepUndefined:Q,onTagObj:J,tag:B}=Z??{},{onAnchor:R,setAnchors:W,sourceObjects:T}=v$(this,G||"a"),Y={aliasDuplicateObjects:U??!0,keepUndefined:Q??!1,onAnchor:R,onTagObj:J,replacer:H,schema:this.schema,sourceObjects:T},L=o($,B,Y);if(z&&w(L))L.flow=!0;return W(),L}createPair($,X,Z={}){let H=this.createNode($,null,Z),U=this.createNode(X,null,Z);return new j(H,U)}delete($){return L0(this.contents)?this.contents.delete($):!1}deleteIn($){if(q0($)){if(this.contents==null)return!1;return this.contents=null,!0}return L0(this.contents)?this.contents.deleteIn($):!1}get($,X){return w(this.contents)?this.contents.get($,X):void 0}getIn($,X){if(q0($))return!X&&O(this.contents)?this.contents.value:this.contents;return w(this.contents)?this.contents.getIn($,X):void 0}has($){return w(this.contents)?this.contents.has($):!1}hasIn($){if(q0($))return this.contents!==void 0;return w(this.contents)?this.contents.hasIn($):!1}set($,X){if(this.contents==null)this.contents=_0(this.schema,[$],X);else if(L0(this.contents))this.contents.set($,X)}setIn($,X){if(q0($))this.contents=X;else if(this.contents==null)this.contents=_0(this.schema,Array.from($),X);else if(L0(this.contents))this.contents.setIn($,X)}setSchema($,X={}){if(typeof $==="number")$=String($);let Z;switch($){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new S({version:"1.1"});Z={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=$;else this.directives=new S({version:$});Z={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;Z=null;break;default:{let H=JSON.stringify($);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${H}`)}}if(X.schema instanceof Object)this.schema=X.schema;else if(Z)this.schema=new S0(Object.assign(Z,X));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:$,jsonArg:X,mapAsMap:Z,maxAliasCount:H,onAnchor:U,reviver:G}={}){let z={anchors:new Map,doc:this,keep:!$,mapAsMap:Z===!0,mapKeyWarned:!1,maxAliasCount:typeof H==="number"?H:100},Q=N(this.contents,X??"",z);if(typeof U==="function")for(let{count:J,res:B}of z.anchors.values())U(B,J);return typeof G==="function"?e(G,{"":Q},"",Q):Q}toJSON($,X){return this.toJS({json:!0,jsonArg:$,mapAsMap:!1,onAnchor:X})}toString($={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in $&&(!Number.isInteger($.indent)||Number($.indent)<=0)){let X=JSON.stringify($.indent);throw Error(`"indent" option must be a positive integer, not ${X}`)}return V2(this,$)}}function L0($){if(w($))return!0;throw Error("Expected a YAML collection as document contents")}var j$=Symbol("break visit"),i2=Symbol("skip children"),T2=Symbol("remove item");function B0($,X){if("type"in $&&$.type==="document")$={start:$.start,value:$.value};Y2(Object.freeze([]),$,X)}B0.BREAK=j$;B0.SKIP=i2;B0.REMOVE=T2;B0.itemAtPath=($,X)=>{let Z=$;for(let[H,U]of X){let G=Z?.[H];if(G&&"items"in G)Z=G.items[U];else return}return Z};B0.parentCollection=($,X)=>{let Z=B0.itemAtPath($,X.slice(0,-1)),H=X[X.length-1][0],U=Z?.[H];if(U&&"items"in U)return U;throw Error("Parent collection not found")};function Y2($,X,Z){let H=Z(X,$);if(typeof H==="symbol")return H;for(let U of["key","value"]){let G=X[U];if(G&&"items"in G){for(let z=0;z<G.items.length;++z){let Q=Y2(Object.freeze($.concat([[U,z]])),G.items[z],Z);if(typeof Q==="number")z=Q-1;else if(Q===j$)return j$;else if(Q===T2)G.items.splice(z,1),z-=1}if(typeof H==="function"&&U==="key")H=H(X,$)}}return typeof H==="function"?H(X,$):H}var s5=new Set("0123456789ABCDEFabcdef"),n5=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),a5=new Set(",[]{}"),r5=new Set(` ,[]{}
58
+ \r `);function S$($,X,Z){let H=null;if(typeof X==="function"||Array.isArray(X))H=X;else if(Z===void 0&&X)Z=X;if(typeof Z==="string")Z=Z.length;if(typeof Z==="number"){let U=Math.round(Z);Z=U<1?void 0:U>8?{indent:8}:{indent:U}}if($===void 0){let{keepUndefined:U}=Z??X??{};if(!U)return}if(m($)&&!H)return $.toString(Z);return new Q0($,H,Z).toString(Z)}var I2="https://faf.one/ext/context/v1";function J$($,X={}){return{faf:X.fafPointer??"./project.faf",mediaType:"application/vnd.faf+yaml",iana:"https://www.iana.org/assignments/media-types/application/vnd.faf+yaml",deterministic:!0,...X.scoreEndpoint?{scoreEndpoint:X.scoreEndpoint}:{},generated:$.generated??X.now??new Date().toISOString()}}function F2($,X={}){let Z={"one.faf/context":J$($,X)},H=new TextEncoder().encode(JSON.stringify(Z)).length;if(H>4096)throw Error(`publisher-provided _meta is ${H}B — exceeds the registry ${"4096"}B cap`);return{["io.modelcontextprotocol.registry/publisher-provided"]:Z}}var e2="JSONRPC",R2="1.0",g$=["application/vnd.faf+yaml","application/vnd.fafm+yaml","application/vnd.fafa+yaml"],$9="https://static.modelcontextprotocol.io/schemas/v1/server-card.schema.json",X9="https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",L2="1.0",O2="1.0",C$={a2a:"application/a2a-agent-card+json",server_card:"application/mcp-server-card+json",fafa:"application/vnd.fafa+yaml"};function Z9($){return($.endpoints??[]).filter((X)=>String(X.protocol??"").toLowerCase()==="a2a"&&X.location)}function _2($,X={}){let Z=Z9($);if(Z.length>0)return Z;let H=X.doorUrl?.trim();if(H)return[{protocol:"a2a",location:H,version:R2}];return[]}function H9($){try{return`https://${C0($)}/.well-known/fafa`}catch{return}}function U9($,X,Z={}){let H=J$(X,Z),U=$.agent??{},G={fafaSpecVersion:String($.version??O2),mediaTypes:[...g$],provenance:{faf:H.faf,mediaType:H.mediaType},generated:H.generated};if(U.id)G.agentId=U.id;let z=H9($);if(z)G.passport=z;return{uri:I2,description:"FAF passport and project DNA as typed parts",required:!1,params:G}}function G9($){let X=new Set;for(let Z of $.capabilities??[])if(Z.cites_spec&&g$.includes(Z.cites_spec))X.add(Z.cites_spec);return["text/plain",...X]}function z9($,X={}){let Z=$.agent??{},H=_2($,X);if(H.length===0)throw Error("No A2A endpoint in .fafa (need endpoints[].protocol: a2a + location). Will not invent a door.");let U=String(Z.displayName??$.metadata?.persona??Z.name??"").trim(),G=String(Z.description??"").trim(),z=String(Z.version??"").trim();if(!U||!G||!z)throw Error("A2A card needs agent.displayName|name, description, version in .fafa");let Q=String(Z.vendor??"").trim(),J=String(Z.homepage??"").trim(),B=Q&&J?{organization:Q,url:J}:void 0,R=($.capabilities??[]).map((W)=>{let T=String(W.name??"").trim();if(!T)throw Error("A2A skill missing capabilities[].name");let Y=Array.isArray(W.tags)?W.tags.map(String):[],L=W.cites_spec&&g$.includes(W.cites_spec)?[W.cites_spec,"text/plain"]:void 0;return{id:T,name:T,description:String(W.description??"").trim()||T,tags:Y,...L?{inputModes:L}:{}}});return{name:U,description:G,supportedInterfaces:H.map((W)=>({url:String(W.location),protocolBinding:e2,protocolVersion:String(W.version??R2)})),...B?{provider:B}:{},version:z,capabilities:{streaming:!1,pushNotifications:!1,extendedAgentCard:!1,extensions:[...X.extensions??[]]},defaultInputModes:G9($),defaultOutputModes:["text/plain","application/json"],skills:R}}var J9=/^[a-z0-9][a-z0-9._-]*$/,Q9=/^(@[a-z0-9~][a-z0-9-._~]*\/)?[a-z0-9~][a-z0-9-._~]*$/,B9=/^[A-Za-z0-9]([A-Za-z0-9._-]*[A-Za-z0-9])?$/,W9=/^[A-Za-z0-9][^\s]*$/,V9=["a2a","mcp"],q9=/^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}$/;function q($){return String($??"").trim()}function Q$($){return Array.isArray($)?$.map(q).filter(Boolean):[]}function T9($){return q($).toLowerCase().replace(/^https?:\/\//,"").replace(/\/.*$/,"").replace(/^www\./,"")}function Y9($,X,Z){let H=["display_name","description","version"].filter((U)=>!q($[U]));if(H.length)throw Error(`Missing answer: ${H.join(", ")}`);if(!J9.test(X))throw Error("Short name: lowercase letters, digits, dots, hyphens or underscores.");if(!q9.test(Z))throw Error(`Domain "${$.domain}" is not a domain name (e.g. example.com).`)}function I9($,X){return($.skills??[]).filter((Z)=>q(Z.name)).map((Z)=>({name:q(Z.name),type:q(Z.type)||"tool",description:q(Z.description)||q(Z.name),tags:X.length?X:[q(Z.name).toLowerCase()]}))}function F9($){let X=($.packages??[]).filter((Z)=>q(Z.registryType)&&q(Z.identifier));for(let Z of X){let H=q(Z.registryType),U=q(Z.identifier);if(H==="npm"&&!Q9.test(U))throw Error(`Package "${U}" is not an npm package name (e.g. weather-mcp or @acme/weather).`);if(H==="pypi"&&!B9.test(U))throw Error(`Package "${U}" is not a PyPI package name (e.g. weather-mcp or weather_mcp).`);if(H!=="npm"&&H!=="pypi"&&!W9.test(U))throw Error(`Package "${U}" is not a ${H} package identifier: it must start with a letter or digit and have no spaces.`)}return X.map((Z)=>({registryType:q(Z.registryType),identifier:q(Z.identifier),...q(Z.version)?{version:q(Z.version)}:{}}))}function R9($){if(/\s/.test($))return!1;try{let X=new URL($);return(X.protocol==="http:"||X.protocol==="https:")&&X.hostname!==""}catch{return!1}}function L9($){if(!R9(q($.url)))throw Error(`Where it runs: "${q($.url)}" is not an http(s) URL (or give an npm package).`);if(!V9.includes(q($.protocol).toLowerCase()))throw Error(`Protocol "${q($.protocol)}": a2a or mcp.`)}function O9($,X){let Z=($.endpoints??[]).filter((U)=>q(U.url));Z.forEach(L9);let H=[...Z.map((U)=>({protocol:q(U.protocol).toLowerCase(),transport:"http",location:q(U.url)})),...X.map((U)=>({protocol:"mcp",transport:"stdio",location:U.identifier}))];if(H.length===0)throw Error("Missing answer: endpoints (a URL, or a package people install)");return H}function _9($,X,Z,H){let U={domain:X},G=[["repository",q($.repository)],["icon",q($.icon)],["organizationUrl",q($.organization_url)]];for(let[Q,J]of G)if(J)U[Q]=J;if(Z.length)U.keywords=Z;let z=Q$($.example_requests);if(z.length)U.examples=z;if(H.length)U.packages=H;return U}function D9($){let X=q($.handle).toLowerCase(),Z=T9($.domain);Y9($,X,Z);let H=Q$($.tags),U=F9($),G={name:X,displayName:q($.display_name),id:`urn:air:${Z}:agent:${X}`,...q($.organization)?{vendor:q($.organization)}:{},version:q($.version),description:q($.description),homepage:q($.homepage)||`https://${Z}`,...q($.license)?{license:q($.license)}:{}};return{version:O2,agent:G,capabilities:I9($,H),endpoints:O9($,U),metadata:{cards:_9($,Z,H,U)}}}function K9($){return S$($,{lineWidth:0})}function C0($){let X=q($.agent?.id),Z=/^urn:air:([^:]+):/.exec(X);if(Z)return Z[1];let H=q($.metadata?.cards?.domain);if(H)return H;try{return new URL(q($.agent?.homepage)).hostname.replace(/^www\./,"")}catch{throw Error("The .fafa names no domain (agent.id urn:air, metadata.cards.domain or agent.homepage).")}}function h6($){return y$($)}function y$($){let X=q($.agent?.name).toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/^-+|-+$/g,"");if(!X)throw Error("The .fafa needs agent.name (the short name).");return X}function D2($){return`${C0($).split(".").reverse().join(".")}/${y$($)}`}function E$($){let X=$.replace(/\s+/g," ").trim();return X.length<=100?X:`${X.slice(0,97).trimEnd()}...`}function B$($){return($.endpoints??[]).filter((X)=>q(X.protocol).toLowerCase()==="mcp"&&/^https?:\/\//.test(q(X.location))).map((X)=>({type:"streamable-http",url:q(X.location)}))}function w9($){if(!$)return;try{let X=new URL($).hostname.replace(/^www\./,"");return{url:$,source:X.split(".")[0]}}catch{return}}function K2($){let X=$.agent??{},Z=$.metadata?.cards??{},H=q(X.description),U=q(X.version);if(!H||!U)throw Error("An MCP card needs agent.description and agent.version in .fafa");let G={name:D2($),version:U,description:E$(H)},z=q(X.displayName);if(z)G.title=E$(z);let Q=q(X.homepage);if(Q)G.websiteUrl=Q;let J=w9(q(Z.repository));if(J)G.repository=J;if(q(Z.icon))G.icons=[{src:q(Z.icon)}];return G}function w2($){return($.metadata?.cards?.packages??[]).map((X)=>({registryType:q(X.registryType),identifier:q(X.identifier),...q(X.version)?{version:q(X.version)}:{},transport:{type:"stdio"}}))}function k6($){return B$($).length>0||w2($).length>0}function x6($){let X=q($.agent?.displayName);return{name:D2($),...X?{title:E$(X)}:{}}}function P9($,X,Z={}){let H=B$($);if(H.length===0)throw Error("A Server Card describes a remote MCP server: the .fafa has no mcp endpoint at an http(s) URL.");return{$schema:$9,...K2($),remotes:H,...X?{_meta:{"one.faf/context":J$(X,Z)}}:{}}}function M9($,X,Z={}){let H=B$($),U=w2($);if(H.length===0&&U.length===0)throw Error("A registry entry needs a package people install or a remote MCP URL.");return{$schema:X9,...K2($),...U.length?{packages:U}:{},...H.length?{remotes:H}:{},...X?{_meta:F2(X,Z)}:{}}}function b9($,X,Z){if(!X.includes("a2a")||_2($,Z).length===0)return;return Z.a2aCardUrl??`https://${C0($)}/.well-known/agent-card.json`}function P2($,X,Z={}){let H=C0($),U=y$($),G=$.agent??{},z=q(G.displayName)||q(G.name),Q=q(G.description),J=q(G.version),B=Z.now??new Date().toISOString(),R=(Y,L,V)=>({identifier:`urn:air:${H}:${Y}:${U}`,displayName:z,type:L,description:Q,url:V,...J?{version:J}:{},updatedAt:B}),W=[],T=b9($,X,Z);if(T)W.push(R("a2a",C$.a2a,T));if(X.includes("server_card")){let Y=B$($)[0];if(Y)W.push(R("mcp",C$.server_card,`${Y.url.replace(/\/+$/,"")}/server-card`))}if(Z.listFafa!==!1)W.push(R("agent",C$.fafa,`https://${H}/.well-known/fafa`));return W}function M2($){let X=$.agent??{},Z=q(X.vendor)||q(X.displayName)||q(X.name);if(!Z)return;let H;try{H=C0($)}catch{H=void 0}return{displayName:Z,...H?{identifier:H}:{}}}function A9($,X,Z={}){let H=M2($);return{specVersion:L2,...H?{host:H}:{},entries:P2($,X,Z)}}function N9($){let X=$.metadata?.cards??{},Z=Q$(X.keywords),H=Q$(X.examples);return{...Z.length?{tags:Z}:{},...H.length?{representativeQueries:H}:{}}}function j9($,X,Z={}){let H=M2($),U=N9($);return{specVersion:L2,...H?{host:H}:{},entries:P2($,X,Z).map((G)=>({...G,...U}))}}function S9($,X){let Z=new Set(X.cards),H={fafa:$,fafaText:K9($)},{faf:U}=X;if(Z.has("a2a")){let z=[...X.a2aExtensions??[],...U?[U9($,U,X)]:[]];H.a2a=z9($,{extensions:z})}if(Z.has("server_card"))H.server_card=P9($,U,X);if(Z.has("server_json"))H.server_json=M9($,U,X);let G={now:X.now,listFafa:X.listFafa};if(Z.has("ai_catalog"))H.ai_catalog=A9($,X.cards,G);if(Z.has("ard"))H.ard=j9($,X.cards,G);return H}function u6($,X){return S9(D9($),X)}export{x6 as registryIdentity,M9 as projectServerJson,P9 as projectServerCard,S9 as projectPack,j9 as projectArd,A9 as projectAiCatalog,z9 as projectA2ACard,B$ as mcpRemotes,D2 as mcpName,k6 as hasRegistryEntry,K9 as fafaYaml,h6 as fafaHandle,C0 as fafaDomain,U9 as fafaContextExtension,P2 as catalogRows,M2 as catalogHost,u6 as buildPack,N9 as ardHints,D9 as answersToFafa,Z9 as a2aEndpoints,_2 as a2aDoors,X9 as SERVER_JSON_SCHEMA,$9 as SERVER_CARD_SCHEMA,g$ as FAF_MEDIA_TYPES,O2 as FAFA_SPEC_VERSION,C$ as CARD_MEDIA_TYPES,L2 as AI_CATALOG_SPEC_VERSION,R2 as A2A_PROTOCOL_VERSION,e2 as A2A_PROTOCOL_BINDING};
59
59
 
60
- //# debugId=F4C90C93DD71C80C64756E2164756E21
60
+ //# debugId=D9F574F973CADBA964756E2164756E21
61
61
  //# sourceMappingURL=pack.js.map