@pickled-dev/cli 0.19.1 → 0.21.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/README.md +8 -8
- package/dist/index.js +128 -128
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,180 +1,180 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`)}displayWidth($){return
|
|
3
|
+
var WX=Object.create;var{getPrototypeOf:VX,defineProperty:P5,getOwnPropertyNames:KX}=Object;var BX=Object.prototype.hasOwnProperty;function LX($){return this[$]}var TX,DX,R5=($,Z,X)=>{var z=$!=null&&typeof $==="object";if(z){var q=Z?TX??=new WeakMap:DX??=new WeakMap,G=q.get($);if(G)return G}X=$!=null?WX(VX($)):{};let J=Z||!$||!$.__esModule?P5(X,"default",{value:$,enumerable:!0}):X;for(let Q of KX($))if(!BX.call(J,Q))P5(J,Q,{get:LX.bind($,Q),enumerable:!0});if(z)q.set($,J);return J};var F=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var B0=import.meta.require;var f$=F((_X)=>{class B4 extends Error{constructor($,Z,X){super(X);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=Z,this.exitCode=$,this.nestedError=void 0}}class j5 extends B4{constructor($){super(1,"commander.invalidArgument",$);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}_X.CommanderError=B4;_X.InvalidArgumentError=j5});var E1=F((IX)=>{var{InvalidArgumentError:OX}=f$();class A5{constructor($,Z){switch(this.description=Z||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,$[0]){case"<":this.required=!0,this._name=$.slice(1,-1);break;case"[":this.required=!1,this._name=$.slice(1,-1);break;default:this.required=!0,this._name=$;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue($,Z){if(Z===this.defaultValue||!Array.isArray(Z))return[$];return Z.push($),Z}default($,Z){return this.defaultValue=$,this.defaultValueDescription=Z,this}argParser($){return this.parseArg=$,this}choices($){return this.argChoices=$.slice(),this.parseArg=(Z,X)=>{if(!this.argChoices.includes(Z))throw new OX(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(Z,X);return Z},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function wX($){let Z=$.name()+($.variadic===!0?"...":"");return $.required?"<"+Z+">":"["+Z+"]"}IX.Argument=A5;IX.humanReadableArgName=wX});var L4=F((AX)=>{var{humanReadableArgName:jX}=E1();class N5{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext($){this.helpWidth=this.helpWidth??$.helpWidth??80}visibleCommands($){let Z=$.commands.filter((z)=>!z._hidden),X=$._getHelpCommand();if(X&&!X._hidden)Z.push(X);if(this.sortSubcommands)Z.sort((z,q)=>{return z.name().localeCompare(q.name())});return Z}compareOptions($,Z){let X=(z)=>{return z.short?z.short.replace(/^-/,""):z.long.replace(/^--/,"")};return X($).localeCompare(X(Z))}visibleOptions($){let Z=$.options.filter((z)=>!z.hidden),X=$._getHelpOption();if(X&&!X.hidden){let z=X.short&&$._findOption(X.short),q=X.long&&$._findOption(X.long);if(!z&&!q)Z.push(X);else if(X.long&&!q)Z.push($.createOption(X.long,X.description));else if(X.short&&!z)Z.push($.createOption(X.short,X.description))}if(this.sortOptions)Z.sort(this.compareOptions);return Z}visibleGlobalOptions($){if(!this.showGlobalOptions)return[];let Z=[];for(let X=$.parent;X;X=X.parent){let z=X.options.filter((q)=>!q.hidden);Z.push(...z)}if(this.sortOptions)Z.sort(this.compareOptions);return Z}visibleArguments($){if($._argsDescription)$.registeredArguments.forEach((Z)=>{Z.description=Z.description||$._argsDescription[Z.name()]||""});if($.registeredArguments.find((Z)=>Z.description))return $.registeredArguments;return[]}subcommandTerm($){let Z=$.registeredArguments.map((X)=>jX(X)).join(" ");return $._name+($._aliases[0]?"|"+$._aliases[0]:"")+($.options.length?" [options]":"")+(Z?" "+Z:"")}optionTerm($){return $.flags}argumentTerm($){return $.name()}longestSubcommandTermLength($,Z){return Z.visibleCommands($).reduce((X,z)=>{return Math.max(X,this.displayWidth(Z.styleSubcommandTerm(Z.subcommandTerm(z))))},0)}longestOptionTermLength($,Z){return Z.visibleOptions($).reduce((X,z)=>{return Math.max(X,this.displayWidth(Z.styleOptionTerm(Z.optionTerm(z))))},0)}longestGlobalOptionTermLength($,Z){return Z.visibleGlobalOptions($).reduce((X,z)=>{return Math.max(X,this.displayWidth(Z.styleOptionTerm(Z.optionTerm(z))))},0)}longestArgumentTermLength($,Z){return Z.visibleArguments($).reduce((X,z)=>{return Math.max(X,this.displayWidth(Z.styleArgumentTerm(Z.argumentTerm(z))))},0)}commandUsage($){let Z=$._name;if($._aliases[0])Z=Z+"|"+$._aliases[0];let X="";for(let z=$.parent;z;z=z.parent)X=z.name()+" "+X;return X+Z+" "+$.usage()}commandDescription($){return $.description()}subcommandDescription($){return $.summary()||$.description()}optionDescription($){let Z=[];if($.argChoices)Z.push(`choices: ${$.argChoices.map((X)=>JSON.stringify(X)).join(", ")}`);if($.defaultValue!==void 0){if($.required||$.optional||$.isBoolean()&&typeof $.defaultValue==="boolean")Z.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`)}if($.presetArg!==void 0&&$.optional)Z.push(`preset: ${JSON.stringify($.presetArg)}`);if($.envVar!==void 0)Z.push(`env: ${$.envVar}`);if(Z.length>0){let X=`(${Z.join(", ")})`;if($.description)return`${$.description} ${X}`;return X}return $.description}argumentDescription($){let Z=[];if($.argChoices)Z.push(`choices: ${$.argChoices.map((X)=>JSON.stringify(X)).join(", ")}`);if($.defaultValue!==void 0)Z.push(`default: ${$.defaultValueDescription||JSON.stringify($.defaultValue)}`);if(Z.length>0){let X=`(${Z.join(", ")})`;if($.description)return`${$.description} ${X}`;return X}return $.description}formatItemList($,Z,X){if(Z.length===0)return[];return[X.styleTitle($),...Z,""]}groupItems($,Z,X){let z=new Map;return $.forEach((q)=>{let G=X(q);if(!z.has(G))z.set(G,[])}),Z.forEach((q)=>{let G=X(q);if(!z.has(G))z.set(G,[]);z.get(G).push(q)}),z}formatHelp($,Z){let X=Z.padWidth($,Z),z=Z.helpWidth??80;function q(W,U){return Z.formatItem(W,X,U,Z)}let G=[`${Z.styleTitle("Usage:")} ${Z.styleUsage(Z.commandUsage($))}`,""],J=Z.commandDescription($);if(J.length>0)G=G.concat([Z.boxWrap(Z.styleCommandDescription(J),z),""]);let Q=Z.visibleArguments($).map((W)=>{return q(Z.styleArgumentTerm(Z.argumentTerm(W)),Z.styleArgumentDescription(Z.argumentDescription(W)))});if(G=G.concat(this.formatItemList("Arguments:",Q,Z)),this.groupItems($.options,Z.visibleOptions($),(W)=>W.helpGroupHeading??"Options:").forEach((W,U)=>{let V=W.map((B)=>{return q(Z.styleOptionTerm(Z.optionTerm(B)),Z.styleOptionDescription(Z.optionDescription(B)))});G=G.concat(this.formatItemList(U,V,Z))}),Z.showGlobalOptions){let W=Z.visibleGlobalOptions($).map((U)=>{return q(Z.styleOptionTerm(Z.optionTerm(U)),Z.styleOptionDescription(Z.optionDescription(U)))});G=G.concat(this.formatItemList("Global Options:",W,Z))}return this.groupItems($.commands,Z.visibleCommands($),(W)=>W.helpGroup()||"Commands:").forEach((W,U)=>{let V=W.map((B)=>{return q(Z.styleSubcommandTerm(Z.subcommandTerm(B)),Z.styleSubcommandDescription(Z.subcommandDescription(B)))});G=G.concat(this.formatItemList(U,V,Z))}),G.join(`
|
|
4
|
+
`)}displayWidth($){return S5($).length}styleTitle($){return $}styleUsage($){return $.split(" ").map((Z)=>{if(Z==="[options]")return this.styleOptionText(Z);if(Z==="[command]")return this.styleSubcommandText(Z);if(Z[0]==="["||Z[0]==="<")return this.styleArgumentText(Z);return this.styleCommandText(Z)}).join(" ")}styleCommandDescription($){return this.styleDescriptionText($)}styleOptionDescription($){return this.styleDescriptionText($)}styleSubcommandDescription($){return this.styleDescriptionText($)}styleArgumentDescription($){return this.styleDescriptionText($)}styleDescriptionText($){return $}styleOptionTerm($){return this.styleOptionText($)}styleSubcommandTerm($){return $.split(" ").map((Z)=>{if(Z==="[options]")return this.styleOptionText(Z);if(Z[0]==="["||Z[0]==="<")return this.styleArgumentText(Z);return this.styleSubcommandText(Z)}).join(" ")}styleArgumentTerm($){return this.styleArgumentText($)}styleOptionText($){return $}styleArgumentText($){return $}styleSubcommandText($){return $}styleCommandText($){return $}padWidth($,Z){return Math.max(Z.longestOptionTermLength($,Z),Z.longestGlobalOptionTermLength($,Z),Z.longestSubcommandTermLength($,Z),Z.longestArgumentTermLength($,Z))}preformatted($){return/\n[^\S\r\n]/.test($)}formatItem($,Z,X,z){let G=" ".repeat(2);if(!X)return G+$;let J=$.padEnd(Z+$.length-z.displayWidth($)),Q=2,Y=(this.helpWidth??80)-Z-Q-2,W;if(Y<this.minWidthToWrap||z.preformatted(X))W=X;else W=z.boxWrap(X,Y).replace(/\n/g,`
|
|
5
5
|
`+" ".repeat(Z+Q));return G+J+" ".repeat(Q)+W.replace(/\n/g,`
|
|
6
|
-
${G}`)}boxWrap($,Z){if(Z<this.minWidthToWrap)return $;let X=$.split(/\r\n|\n/),z=/[\s]*[^\s]+/g,q=[];return X.forEach((G)=>{let J=G.match(z);if(J===null){q.push("");return}let Q=[J.shift()],
|
|
7
|
-
`)}}function
|
|
6
|
+
${G}`)}boxWrap($,Z){if(Z<this.minWidthToWrap)return $;let X=$.split(/\r\n|\n/),z=/[\s]*[^\s]+/g,q=[];return X.forEach((G)=>{let J=G.match(z);if(J===null){q.push("");return}let Q=[J.shift()],H=this.displayWidth(Q[0]);J.forEach((Y)=>{let W=this.displayWidth(Y);if(H+W<=Z){Q.push(Y),H+=W;return}q.push(Q.join(""));let U=Y.trimStart();Q=[U],H=this.displayWidth(U)}),q.push(Q.join(""))}),q.join(`
|
|
7
|
+
`)}}function S5($){let Z=/\x1b\[\d*(;\d*)*m/g;return $.replace(Z,"")}AX.Help=N5;AX.stripColor=S5});var T4=F((bX)=>{var{InvalidArgumentError:CX}=f$();class E5{constructor($,Z){this.flags=$,this.description=Z||"",this.required=$.includes("<"),this.optional=$.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test($),this.mandatory=!1;let X=EX($);if(this.short=X.shortFlag,this.long=X.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default($,Z){return this.defaultValue=$,this.defaultValueDescription=Z,this}preset($){return this.presetArg=$,this}conflicts($){return this.conflictsWith=this.conflictsWith.concat($),this}implies($){let Z=$;if(typeof $==="string")Z={[$]:!0};return this.implied=Object.assign(this.implied||{},Z),this}env($){return this.envVar=$,this}argParser($){return this.parseArg=$,this}makeOptionMandatory($=!0){return this.mandatory=!!$,this}hideHelp($=!0){return this.hidden=!!$,this}_collectValue($,Z){if(Z===this.defaultValue||!Array.isArray(Z))return[$];return Z.push($),Z}choices($){return this.argChoices=$.slice(),this.parseArg=(Z,X)=>{if(!this.argChoices.includes(Z))throw new CX(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(Z,X);return Z},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return C5(this.name().replace(/^no-/,""));return C5(this.name())}helpGroup($){return this.helpGroupHeading=$,this}is($){return this.short===$||this.long===$}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class b5{constructor($){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,$.forEach((Z)=>{if(Z.negate)this.negativeOptions.set(Z.attributeName(),Z);else this.positiveOptions.set(Z.attributeName(),Z)}),this.negativeOptions.forEach((Z,X)=>{if(this.positiveOptions.has(X))this.dualOptions.add(X)})}valueFromOption($,Z){let X=Z.attributeName();if(!this.dualOptions.has(X))return!0;let z=this.negativeOptions.get(X).presetArg,q=z!==void 0?z:!1;return Z.negate===(q===$)}}function C5($){return $.split("-").reduce((Z,X)=>{return Z+X[0].toUpperCase()+X.slice(1)})}function EX($){let Z,X,z=/^-[^-]$/,q=/^--[^-]/,G=$.split(/[ |,]+/).concat("guard");if(z.test(G[0]))Z=G.shift();if(q.test(G[0]))X=G.shift();if(!Z&&z.test(G[0]))Z=G.shift();if(!Z&&q.test(G[0]))Z=X,X=G.shift();if(G[0].startsWith("-")){let J=G[0],Q=`option creation failed due to '${J}' in option flags '${$}'`;if(/^-[^-][^-]/.test(J))throw Error(`${Q}
|
|
8
8
|
- a short flag is a single dash and a single character
|
|
9
9
|
- either use a single dash and a single character (for a short flag)
|
|
10
10
|
- or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(z.test(J))throw Error(`${Q}
|
|
11
11
|
- too many short flags`);if(q.test(J))throw Error(`${Q}
|
|
12
12
|
- too many long flags`);throw Error(`${Q}
|
|
13
|
-
- unrecognised flag format`)}if(Z===void 0&&X===void 0)throw Error(`option creation failed due to no flags found in '${$}'.`);return{shortFlag:Z,longFlag:X}}
|
|
13
|
+
- unrecognised flag format`)}if(Z===void 0&&X===void 0)throw Error(`option creation failed due to no flags found in '${$}'.`);return{shortFlag:Z,longFlag:X}}bX.Option=E5;bX.DualOptions=b5});var y5=F((hX)=>{function kX($,Z){if(Math.abs($.length-Z.length)>3)return Math.max($.length,Z.length);let X=[];for(let z=0;z<=$.length;z++)X[z]=[z];for(let z=0;z<=Z.length;z++)X[0][z]=z;for(let z=1;z<=Z.length;z++)for(let q=1;q<=$.length;q++){let G=1;if($[q-1]===Z[z-1])G=0;else G=1;if(X[q][z]=Math.min(X[q-1][z]+1,X[q][z-1]+1,X[q-1][z-1]+G),q>1&&z>1&&$[q-1]===Z[z-2]&&$[q-2]===Z[z-1])X[q][z]=Math.min(X[q][z],X[q-2][z-2]+1)}return X[$.length][Z.length]}function fX($,Z){if(!Z||Z.length===0)return"";Z=Array.from(new Set(Z));let X=$.startsWith("--");if(X)$=$.slice(2),Z=Z.map((J)=>J.slice(2));let z=[],q=3,G=0.4;if(Z.forEach((J)=>{if(J.length<=1)return;let Q=kX($,J),H=Math.max($.length,J.length);if((H-Q)/H>G){if(Q<q)q=Q,z=[J];else if(Q===q)z.push(J)}}),z.sort((J,Q)=>J.localeCompare(Q)),X)z=z.map((J)=>`--${J}`);if(z.length>1)return`
|
|
14
14
|
(Did you mean one of ${z.join(", ")}?)`;if(z.length===1)return`
|
|
15
|
-
(Did you mean ${z[0]}?)`;return""}
|
|
16
|
-
- specify the name in Command constructor or using .name()`);if(Z=Z||{},Z.isDefault)this._defaultCommandName=$._name;if(Z.noHelp||Z.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,Z){return new
|
|
17
|
-
Expecting one of '${X.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(Z);else this._lifeCycleHooks[$]=[Z];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(Z)=>{if(Z.code!=="commander.executeSubCommandAsync")throw Z};return this}_exit($,Z,X){if(this._exitCallback)this._exitCallback(new
|
|
18
|
-
- already used by option '${Z.flags}'`)}this._initOptionGroup($),this.options.push($)}_registerCommand($){let Z=(z)=>{return[z.name()].concat(z.aliases())},X=Z($).find((z)=>this._findCommand(z));if(X){let z=Z(this._findCommand(X)).join("|"),q=Z($).join("|");throw Error(`cannot add command '${q}' as already have command '${z}'`)}this._initCommandGroup($),this.commands.push($)}addOption($){this._registerOption($);let Z=$.name(),X=$.attributeName();if($.negate){let q=$.long.replace(/^--no-/,"--");if(!this._findOption(q))this.setOptionValueWithSource(X,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(X,$.defaultValue,"default");let z=(q,G,J)=>{if(q==null&&$.presetArg!==void 0)q=$.presetArg;let Q=this.getOptionValue(X);if(q!==null&&$.parseArg)q=this._callParseArg($,q,Q,G);else if(q!==null&&$.variadic)q=$._collectValue(q,Q);if(q==null)if($.negate)q=!1;else if($.isBoolean()||$.optional)q=!0;else q="";this.setOptionValueWithSource(X,q,J)};if(this.on("option:"+Z,(q)=>{let G=`error: option '${$.flags}' argument '${q}' is invalid.`;z(q,G,"cli")}),$.envVar)this.on("optionEnv:"+Z,(q)=>{let G=`error: option '${$.flags}' value '${q}' from env '${$.envVar}' is invalid.`;z(q,G,"env")});return this}_optionEx($,Z,X,z,q){if(typeof Z==="object"&&Z instanceof
|
|
15
|
+
(Did you mean ${z[0]}?)`;return""}hX.suggestSimilar=fX});var h5=F((cX)=>{var vX=B0("events").EventEmitter,D4=B0("child_process"),L0=B0("path"),b1=B0("fs"),b=B0("process"),{Argument:uX,humanReadableArgName:mX}=E1(),{CommanderError:_4}=f$(),{Help:dX,stripColor:pX}=L4(),{Option:x5,DualOptions:lX}=T4(),{suggestSimilar:k5}=y5();class M4 extends vX{constructor($){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=$||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(Z)=>b.stdout.write(Z),writeErr:(Z)=>b.stderr.write(Z),outputError:(Z,X)=>X(Z),getOutHelpWidth:()=>b.stdout.isTTY?b.stdout.columns:void 0,getErrHelpWidth:()=>b.stderr.isTTY?b.stderr.columns:void 0,getOutHasColors:()=>F4()??(b.stdout.isTTY&&b.stdout.hasColors?.()),getErrHasColors:()=>F4()??(b.stderr.isTTY&&b.stderr.hasColors?.()),stripColor:(Z)=>pX(Z)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings($){return this._outputConfiguration=$._outputConfiguration,this._helpOption=$._helpOption,this._helpCommand=$._helpCommand,this._helpConfiguration=$._helpConfiguration,this._exitCallback=$._exitCallback,this._storeOptionsAsProperties=$._storeOptionsAsProperties,this._combineFlagAndOptionalValue=$._combineFlagAndOptionalValue,this._allowExcessArguments=$._allowExcessArguments,this._enablePositionalOptions=$._enablePositionalOptions,this._showHelpAfterError=$._showHelpAfterError,this._showSuggestionAfterError=$._showSuggestionAfterError,this}_getCommandAndAncestors(){let $=[];for(let Z=this;Z;Z=Z.parent)$.push(Z);return $}command($,Z,X){let z=Z,q=X;if(typeof z==="object"&&z!==null)q=z,z=null;q=q||{};let[,G,J]=$.match(/([^ ]+) *(.*)/),Q=this.createCommand(G);if(z)Q.description(z),Q._executableHandler=!0;if(q.isDefault)this._defaultCommandName=Q._name;if(Q._hidden=!!(q.noHelp||q.hidden),Q._executableFile=q.executableFile||null,J)Q.arguments(J);if(this._registerCommand(Q),Q.parent=this,Q.copyInheritedSettings(this),z)return this;return Q}createCommand($){return new M4($)}createHelp(){return Object.assign(new dX,this.configureHelp())}configureHelp($){if($===void 0)return this._helpConfiguration;return this._helpConfiguration=$,this}configureOutput($){if($===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...$},this}showHelpAfterError($=!0){if(typeof $!=="string")$=!!$;return this._showHelpAfterError=$,this}showSuggestionAfterError($=!0){return this._showSuggestionAfterError=!!$,this}addCommand($,Z){if(!$._name)throw Error(`Command passed to .addCommand() must have a name
|
|
16
|
+
- specify the name in Command constructor or using .name()`);if(Z=Z||{},Z.isDefault)this._defaultCommandName=$._name;if(Z.noHelp||Z.hidden)$._hidden=!0;return this._registerCommand($),$.parent=this,$._checkForBrokenPassThrough(),this}createArgument($,Z){return new uX($,Z)}argument($,Z,X,z){let q=this.createArgument($,Z);if(typeof X==="function")q.default(z).argParser(X);else q.default(X);return this.addArgument(q),this}arguments($){return $.trim().split(/ +/).forEach((Z)=>{this.argument(Z)}),this}addArgument($){let Z=this.registeredArguments.slice(-1)[0];if(Z?.variadic)throw Error(`only the last argument can be variadic '${Z.name()}'`);if($.required&&$.defaultValue!==void 0&&$.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${$.name()}'`);return this.registeredArguments.push($),this}helpCommand($,Z){if(typeof $==="boolean"){if(this._addImplicitHelpCommand=$,$&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let X=$??"help [command]",[,z,q]=X.match(/([^ ]+) *(.*)/),G=Z??"display help for command",J=this.createCommand(z);if(J.helpOption(!1),q)J.arguments(q);if(G)J.description(G);if(this._addImplicitHelpCommand=!0,this._helpCommand=J,$||Z)this._initCommandGroup(J);return this}addHelpCommand($,Z){if(typeof $!=="object")return this.helpCommand($,Z),this;return this._addImplicitHelpCommand=!0,this._helpCommand=$,this._initCommandGroup($),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook($,Z){let X=["preSubcommand","preAction","postAction"];if(!X.includes($))throw Error(`Unexpected value for event passed to hook : '${$}'.
|
|
17
|
+
Expecting one of '${X.join("', '")}'`);if(this._lifeCycleHooks[$])this._lifeCycleHooks[$].push(Z);else this._lifeCycleHooks[$]=[Z];return this}exitOverride($){if($)this._exitCallback=$;else this._exitCallback=(Z)=>{if(Z.code!=="commander.executeSubCommandAsync")throw Z};return this}_exit($,Z,X){if(this._exitCallback)this._exitCallback(new _4($,Z,X));b.exit($)}action($){let Z=(X)=>{let z=this.registeredArguments.length,q=X.slice(0,z);if(this._storeOptionsAsProperties)q[z]=this;else q[z]=this.opts();return q.push(this),$.apply(this,q)};return this._actionHandler=Z,this}createOption($,Z){return new x5($,Z)}_callParseArg($,Z,X,z){try{return $.parseArg(Z,X)}catch(q){if(q.code==="commander.invalidArgument"){let G=`${z} ${q.message}`;this.error(G,{exitCode:q.exitCode,code:q.code})}throw q}}_registerOption($){let Z=$.short&&this._findOption($.short)||$.long&&this._findOption($.long);if(Z){let X=$.long&&this._findOption($.long)?$.long:$.short;throw Error(`Cannot add option '${$.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${X}'
|
|
18
|
+
- already used by option '${Z.flags}'`)}this._initOptionGroup($),this.options.push($)}_registerCommand($){let Z=(z)=>{return[z.name()].concat(z.aliases())},X=Z($).find((z)=>this._findCommand(z));if(X){let z=Z(this._findCommand(X)).join("|"),q=Z($).join("|");throw Error(`cannot add command '${q}' as already have command '${z}'`)}this._initCommandGroup($),this.commands.push($)}addOption($){this._registerOption($);let Z=$.name(),X=$.attributeName();if($.negate){let q=$.long.replace(/^--no-/,"--");if(!this._findOption(q))this.setOptionValueWithSource(X,$.defaultValue===void 0?!0:$.defaultValue,"default")}else if($.defaultValue!==void 0)this.setOptionValueWithSource(X,$.defaultValue,"default");let z=(q,G,J)=>{if(q==null&&$.presetArg!==void 0)q=$.presetArg;let Q=this.getOptionValue(X);if(q!==null&&$.parseArg)q=this._callParseArg($,q,Q,G);else if(q!==null&&$.variadic)q=$._collectValue(q,Q);if(q==null)if($.negate)q=!1;else if($.isBoolean()||$.optional)q=!0;else q="";this.setOptionValueWithSource(X,q,J)};if(this.on("option:"+Z,(q)=>{let G=`error: option '${$.flags}' argument '${q}' is invalid.`;z(q,G,"cli")}),$.envVar)this.on("optionEnv:"+Z,(q)=>{let G=`error: option '${$.flags}' value '${q}' from env '${$.envVar}' is invalid.`;z(q,G,"env")});return this}_optionEx($,Z,X,z,q){if(typeof Z==="object"&&Z instanceof x5)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let G=this.createOption(Z,X);if(G.makeOptionMandatory(!!$.mandatory),typeof z==="function")G.default(q).argParser(z);else if(z instanceof RegExp){let J=z;z=(Q,H)=>{let Y=J.exec(Q);return Y?Y[0]:H},G.default(q).argParser(z)}else G.default(z);return this.addOption(G)}option($,Z,X,z){return this._optionEx({},$,Z,X,z)}requiredOption($,Z,X,z){return this._optionEx({mandatory:!0},$,Z,X,z)}combineFlagAndOptionalValue($=!0){return this._combineFlagAndOptionalValue=!!$,this}allowUnknownOption($=!0){return this._allowUnknownOption=!!$,this}allowExcessArguments($=!0){return this._allowExcessArguments=!!$,this}enablePositionalOptions($=!0){return this._enablePositionalOptions=!!$,this}passThroughOptions($=!0){return this._passThroughOptions=!!$,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties($=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!$,this}getOptionValue($){if(this._storeOptionsAsProperties)return this[$];return this._optionValues[$]}setOptionValue($,Z){return this.setOptionValueWithSource($,Z,void 0)}setOptionValueWithSource($,Z,X){if(this._storeOptionsAsProperties)this[$]=Z;else this._optionValues[$]=Z;return this._optionValueSources[$]=X,this}getOptionValueSource($){return this._optionValueSources[$]}getOptionValueSourceWithGlobals($){let Z;return this._getCommandAndAncestors().forEach((X)=>{if(X.getOptionValueSource($)!==void 0)Z=X.getOptionValueSource($)}),Z}_prepareUserArgs($,Z){if($!==void 0&&!Array.isArray($))throw Error("first parameter to parse must be array or undefined");if(Z=Z||{},$===void 0&&Z.from===void 0){if(b.versions?.electron)Z.from="electron";let z=b.execArgv??[];if(z.includes("-e")||z.includes("--eval")||z.includes("-p")||z.includes("--print"))Z.from="eval"}if($===void 0)$=b.argv;this.rawArgs=$.slice();let X;switch(Z.from){case void 0:case"node":this._scriptPath=$[1],X=$.slice(2);break;case"electron":if(b.defaultApp)this._scriptPath=$[1],X=$.slice(2);else X=$.slice(1);break;case"user":X=$.slice(0);break;case"eval":X=$.slice(1);break;default:throw Error(`unexpected parse option { from: '${Z.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",X}parse($,Z){this._prepareForParse();let X=this._prepareUserArgs($,Z);return this._parseCommand([],X),this}async parseAsync($,Z){this._prepareForParse();let X=this._prepareUserArgs($,Z);return await this._parseCommand([],X),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw Error(`Can not call parse again when storeOptionsAsProperties is true.
|
|
19
19
|
- either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable($,Z,X){if(b1.existsSync($))return;let z=Z?`searched for local subcommand relative to directory '${Z}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",q=`'${$}' does not exist
|
|
20
20
|
- if '${X}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead
|
|
21
21
|
- if the default executable name is not suitable, use the executableFile option to supply a custom name or path
|
|
22
|
-
- ${z}`;throw Error(q)}_executeSubCommand($,Z){Z=Z.slice();let X=!1,z=[".js",".ts",".tsx",".mjs",".cjs"];function q(
|
|
22
|
+
- ${z}`;throw Error(q)}_executeSubCommand($,Z){Z=Z.slice();let X=!1,z=[".js",".ts",".tsx",".mjs",".cjs"];function q(Y,W){let U=L0.resolve(Y,W);if(b1.existsSync(U))return U;if(z.includes(L0.extname(W)))return;let V=z.find((B)=>b1.existsSync(`${U}${B}`));if(V)return`${U}${V}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let G=$._executableFile||`${this._name}-${$._name}`,J=this._executableDir||"";if(this._scriptPath){let Y;try{Y=b1.realpathSync(this._scriptPath)}catch{Y=this._scriptPath}J=L0.resolve(L0.dirname(Y),J)}if(J){let Y=q(J,G);if(!Y&&!$._executableFile&&this._scriptPath){let W=L0.basename(this._scriptPath,L0.extname(this._scriptPath));if(W!==this._name)Y=q(J,`${W}-${$._name}`)}G=Y||G}X=z.includes(L0.extname(G));let Q;if(b.platform!=="win32")if(X)Z.unshift(G),Z=f5(b.execArgv).concat(Z),Q=D4.spawn(b.argv[0],Z,{stdio:"inherit"});else Q=D4.spawn(G,Z,{stdio:"inherit"});else this._checkForMissingExecutable(G,J,$._name),Z.unshift(G),Z=f5(b.execArgv).concat(Z),Q=D4.spawn(b.execPath,Z,{stdio:"inherit"});if(!Q.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((W)=>{b.on(W,()=>{if(Q.killed===!1&&Q.exitCode===null)Q.kill(W)})});let H=this._exitCallback;Q.on("close",(Y)=>{if(Y=Y??1,!H)b.exit(Y);else H(new _4(Y,"commander.executeSubCommandAsync","(close)"))}),Q.on("error",(Y)=>{if(Y.code==="ENOENT")this._checkForMissingExecutable(G,J,$._name);else if(Y.code==="EACCES")throw Error(`'${G}' not executable`);if(!H)b.exit(1);else{let W=new _4(1,"commander.executeSubCommandAsync","(error)");W.nestedError=Y,H(W)}}),this.runningCommand=Q}_dispatchSubcommand($,Z,X){let z=this._findCommand($);if(!z)this.help({error:!0});z._prepareForParse();let q;return q=this._chainOrCallSubCommandHook(q,z,"preSubcommand"),q=this._chainOrCall(q,()=>{if(z._executableHandler)this._executeSubCommand(z,Z.concat(X));else return z._parseCommand(Z,X)}),q}_dispatchHelpCommand($){if(!$)this.help();let Z=this._findCommand($);if(Z&&!Z._executableHandler)Z.help();return this._dispatchSubcommand($,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach(($,Z)=>{if($.required&&this.args[Z]==null)this.missingArgument($.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let $=(X,z,q)=>{let G=z;if(z!==null&&X.parseArg){let J=`error: command-argument value '${z}' is invalid for argument '${X.name()}'.`;G=this._callParseArg(X,z,q,J)}return G};this._checkNumberOfArguments();let Z=[];this.registeredArguments.forEach((X,z)=>{let q=X.defaultValue;if(X.variadic){if(z<this.args.length){if(q=this.args.slice(z),X.parseArg)q=q.reduce((G,J)=>{return $(X,J,G)},X.defaultValue)}else if(q===void 0)q=[]}else if(z<this.args.length){if(q=this.args[z],X.parseArg)q=$(X,q,X.defaultValue)}Z[z]=q}),this.processedArgs=Z}_chainOrCall($,Z){if($?.then&&typeof $.then==="function")return $.then(()=>Z());return Z()}_chainOrCallHooks($,Z){let X=$,z=[];if(this._getCommandAndAncestors().reverse().filter((q)=>q._lifeCycleHooks[Z]!==void 0).forEach((q)=>{q._lifeCycleHooks[Z].forEach((G)=>{z.push({hookedCommand:q,callback:G})})}),Z==="postAction")z.reverse();return z.forEach((q)=>{X=this._chainOrCall(X,()=>{return q.callback(q.hookedCommand,this)})}),X}_chainOrCallSubCommandHook($,Z,X){let z=$;if(this._lifeCycleHooks[X]!==void 0)this._lifeCycleHooks[X].forEach((q)=>{z=this._chainOrCall(z,()=>{return q(this,Z)})});return z}_parseCommand($,Z){let X=this.parseOptions(Z);if(this._parseOptionsEnv(),this._parseOptionsImplied(),$=$.concat(X.operands),Z=X.unknown,this.args=$.concat(Z),$&&this._findCommand($[0]))return this._dispatchSubcommand($[0],$.slice(1),Z);if(this._getHelpCommand()&&$[0]===this._getHelpCommand().name())return this._dispatchHelpCommand($[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(Z),this._dispatchSubcommand(this._defaultCommandName,$,Z);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(X.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let z=()=>{if(X.unknown.length>0)this.unknownOption(X.unknown[0])},q=`command:${this.name()}`;if(this._actionHandler){z(),this._processArguments();let G;if(G=this._chainOrCallHooks(G,"preAction"),G=this._chainOrCall(G,()=>this._actionHandler(this.processedArgs)),this.parent)G=this._chainOrCall(G,()=>{this.parent.emit(q,$,Z)});return G=this._chainOrCallHooks(G,"postAction"),G}if(this.parent?.listenerCount(q))z(),this._processArguments(),this.parent.emit(q,$,Z);else if($.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",$,Z);if(this.listenerCount("command:*"))this.emit("command:*",$,Z);else if(this.commands.length)this.unknownCommand();else z(),this._processArguments()}else if(this.commands.length)z(),this.help({error:!0});else z(),this._processArguments()}_findCommand($){if(!$)return;return this.commands.find((Z)=>Z._name===$||Z._aliases.includes($))}_findOption($){return this.options.find((Z)=>Z.is($))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach(($)=>{$.options.forEach((Z)=>{if(Z.mandatory&&$.getOptionValue(Z.attributeName())===void 0)$.missingMandatoryOptionValue(Z)})})}_checkForConflictingLocalOptions(){let $=this.options.filter((X)=>{let z=X.attributeName();if(this.getOptionValue(z)===void 0)return!1;return this.getOptionValueSource(z)!=="default"});$.filter((X)=>X.conflictsWith.length>0).forEach((X)=>{let z=$.find((q)=>X.conflictsWith.includes(q.attributeName()));if(z)this._conflictingOption(X,z)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach(($)=>{$._checkForConflictingLocalOptions()})}parseOptions($){let Z=[],X=[],z=Z;function q(Y){return Y.length>1&&Y[0]==="-"}let G=(Y)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(Y))return!1;return!this._getCommandAndAncestors().some((W)=>W.options.map((U)=>U.short).some((U)=>/^-\d$/.test(U)))},J=null,Q=null,H=0;while(H<$.length||Q){let Y=Q??$[H++];if(Q=null,Y==="--"){if(z===X)z.push(Y);z.push(...$.slice(H));break}if(J&&(!q(Y)||G(Y))){this.emit(`option:${J.name()}`,Y);continue}if(J=null,q(Y)){let W=this._findOption(Y);if(W){if(W.required){let U=$[H++];if(U===void 0)this.optionMissingArgument(W);this.emit(`option:${W.name()}`,U)}else if(W.optional){let U=null;if(H<$.length&&(!q($[H])||G($[H])))U=$[H++];this.emit(`option:${W.name()}`,U)}else this.emit(`option:${W.name()}`);J=W.variadic?W:null;continue}}if(Y.length>2&&Y[0]==="-"&&Y[1]!=="-"){let W=this._findOption(`-${Y[1]}`);if(W){if(W.required||W.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${W.name()}`,Y.slice(2));else this.emit(`option:${W.name()}`),Q=`-${Y.slice(2)}`;continue}}if(/^--[^=]+=/.test(Y)){let W=Y.indexOf("="),U=this._findOption(Y.slice(0,W));if(U&&(U.required||U.optional)){this.emit(`option:${U.name()}`,Y.slice(W+1));continue}}if(z===Z&&q(Y)&&!(this.commands.length===0&&G(Y)))z=X;if((this._enablePositionalOptions||this._passThroughOptions)&&Z.length===0&&X.length===0){if(this._findCommand(Y)){Z.push(Y),X.push(...$.slice(H));break}else if(this._getHelpCommand()&&Y===this._getHelpCommand().name()){Z.push(Y,...$.slice(H));break}else if(this._defaultCommandName){X.push(Y,...$.slice(H));break}}if(this._passThroughOptions){z.push(Y,...$.slice(H));break}z.push(Y)}return{operands:Z,unknown:X}}opts(){if(this._storeOptionsAsProperties){let $={},Z=this.options.length;for(let X=0;X<Z;X++){let z=this.options[X].attributeName();$[z]=z===this._versionOptionName?this._version:this[z]}return $}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(($,Z)=>Object.assign($,Z.opts()),{})}error($,Z){if(this._outputConfiguration.outputError(`${$}
|
|
23
23
|
`,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError}
|
|
24
24
|
`);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(`
|
|
25
|
-
`),this.outputHelp({error:!0});let X=Z||{},z=X.exitCode||1,q=X.code||"commander.error";this._exit(z,q,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in b.env){let Z=$.attributeName();if(this.getOptionValue(Z)===void 0||["default","config","env"].includes(this.getOptionValueSource(Z)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,b.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new
|
|
26
|
-
`),this._exit(0,"commander.version",$)}),this}description($,Z){if($===void 0&&Z===void 0)return this._description;if(this._description=$,Z)this._argsDescription=Z;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let Z=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)Z=this.commands[this.commands.length-1];if($===Z._name)throw Error("Command alias can't be the same as its name");let X=this.parent?._findCommand($);if(X){let z=[X.name()].concat(X.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${z}'`)}return Z._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((Z)=>this.alias(Z)),this}usage($){if($===void 0){if(this._usage)return this._usage;let Z=this.registeredArguments.map((X)=>{return
|
|
25
|
+
`),this.outputHelp({error:!0});let X=Z||{},z=X.exitCode||1,q=X.code||"commander.error";this._exit(z,q,$)}_parseOptionsEnv(){this.options.forEach(($)=>{if($.envVar&&$.envVar in b.env){let Z=$.attributeName();if(this.getOptionValue(Z)===void 0||["default","config","env"].includes(this.getOptionValueSource(Z)))if($.required||$.optional)this.emit(`optionEnv:${$.name()}`,b.env[$.envVar]);else this.emit(`optionEnv:${$.name()}`)}})}_parseOptionsImplied(){let $=new lX(this.options),Z=(X)=>{return this.getOptionValue(X)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(X))};this.options.filter((X)=>X.implied!==void 0&&Z(X.attributeName())&&$.valueFromOption(this.getOptionValue(X.attributeName()),X)).forEach((X)=>{Object.keys(X.implied).filter((z)=>!Z(z)).forEach((z)=>{this.setOptionValueWithSource(z,X.implied[z],"implied")})})}missingArgument($){let Z=`error: missing required argument '${$}'`;this.error(Z,{code:"commander.missingArgument"})}optionMissingArgument($){let Z=`error: option '${$.flags}' argument missing`;this.error(Z,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue($){let Z=`error: required option '${$.flags}' not specified`;this.error(Z,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption($,Z){let X=(G)=>{let J=G.attributeName(),Q=this.getOptionValue(J),H=this.options.find((W)=>W.negate&&J===W.attributeName()),Y=this.options.find((W)=>!W.negate&&J===W.attributeName());if(H&&(H.presetArg===void 0&&Q===!1||H.presetArg!==void 0&&Q===H.presetArg))return H;return Y||G},z=(G)=>{let J=X(G),Q=J.attributeName();if(this.getOptionValueSource(Q)==="env")return`environment variable '${J.envVar}'`;return`option '${J.flags}'`},q=`error: ${z($)} cannot be used with ${z(Z)}`;this.error(q,{code:"commander.conflictingOption"})}unknownOption($){if(this._allowUnknownOption)return;let Z="";if($.startsWith("--")&&this._showSuggestionAfterError){let z=[],q=this;do{let G=q.createHelp().visibleOptions(q).filter((J)=>J.long).map((J)=>J.long);z=z.concat(G),q=q.parent}while(q&&!q._enablePositionalOptions);Z=k5($,z)}let X=`error: unknown option '${$}'${Z}`;this.error(X,{code:"commander.unknownOption"})}_excessArguments($){if(this._allowExcessArguments)return;let Z=this.registeredArguments.length,X=Z===1?"":"s",q=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${Z} argument${X} but got ${$.length}.`;this.error(q,{code:"commander.excessArguments"})}unknownCommand(){let $=this.args[0],Z="";if(this._showSuggestionAfterError){let z=[];this.createHelp().visibleCommands(this).forEach((q)=>{if(z.push(q.name()),q.alias())z.push(q.alias())}),Z=k5($,z)}let X=`error: unknown command '${$}'${Z}`;this.error(X,{code:"commander.unknownCommand"})}version($,Z,X){if($===void 0)return this._version;this._version=$,Z=Z||"-V, --version",X=X||"output the version number";let z=this.createOption(Z,X);return this._versionOptionName=z.attributeName(),this._registerOption(z),this.on("option:"+z.name(),()=>{this._outputConfiguration.writeOut(`${$}
|
|
26
|
+
`),this._exit(0,"commander.version",$)}),this}description($,Z){if($===void 0&&Z===void 0)return this._description;if(this._description=$,Z)this._argsDescription=Z;return this}summary($){if($===void 0)return this._summary;return this._summary=$,this}alias($){if($===void 0)return this._aliases[0];let Z=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)Z=this.commands[this.commands.length-1];if($===Z._name)throw Error("Command alias can't be the same as its name");let X=this.parent?._findCommand($);if(X){let z=[X.name()].concat(X.aliases()).join("|");throw Error(`cannot add alias '${$}' to command '${this.name()}' as already have command '${z}'`)}return Z._aliases.push($),this}aliases($){if($===void 0)return this._aliases;return $.forEach((Z)=>this.alias(Z)),this}usage($){if($===void 0){if(this._usage)return this._usage;let Z=this.registeredArguments.map((X)=>{return mX(X)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?Z:[]).join(" ")}return this._usage=$,this}name($){if($===void 0)return this._name;return this._name=$,this}helpGroup($){if($===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=$,this}commandsGroup($){if($===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=$,this}optionsGroup($){if($===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=$,this}_initOptionGroup($){if(this._defaultOptionGroup&&!$.helpGroupHeading)$.helpGroup(this._defaultOptionGroup)}_initCommandGroup($){if(this._defaultCommandGroup&&!$.helpGroup())$.helpGroup(this._defaultCommandGroup)}nameFromFilename($){return this._name=L0.basename($,L0.extname($)),this}executableDir($){if($===void 0)return this._executableDir;return this._executableDir=$,this}helpInformation($){let Z=this.createHelp(),X=this._getOutputContext($);Z.prepareContext({error:X.error,helpWidth:X.helpWidth,outputHasColors:X.hasColors});let z=Z.formatHelp(this,Z);if(X.hasColors)return z;return this._outputConfiguration.stripColor(z)}_getOutputContext($){$=$||{};let Z=!!$.error,X,z,q;if(Z)X=(J)=>this._outputConfiguration.writeErr(J),z=this._outputConfiguration.getErrHasColors(),q=this._outputConfiguration.getErrHelpWidth();else X=(J)=>this._outputConfiguration.writeOut(J),z=this._outputConfiguration.getOutHasColors(),q=this._outputConfiguration.getOutHelpWidth();return{error:Z,write:(J)=>{if(!z)J=this._outputConfiguration.stripColor(J);return X(J)},hasColors:z,helpWidth:q}}outputHelp($){let Z;if(typeof $==="function")Z=$,$=void 0;let X=this._getOutputContext($),z={error:X.error,write:X.write,command:this};this._getCommandAndAncestors().reverse().forEach((G)=>G.emit("beforeAllHelp",z)),this.emit("beforeHelp",z);let q=this.helpInformation({error:X.error});if(Z){if(q=Z(q),typeof q!=="string"&&!Buffer.isBuffer(q))throw Error("outputHelp callback must return a string or a Buffer")}if(X.write(q),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",z),this._getCommandAndAncestors().forEach((G)=>G.emit("afterAllHelp",z))}helpOption($,Z){if(typeof $==="boolean"){if($){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption($??"-h, --help",Z??"display help for command"),$||Z)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption($){return this._helpOption=$,this._initOptionGroup($),this}help($){this.outputHelp($);let Z=Number(b.exitCode??0);if(Z===0&&$&&typeof $!=="function"&&$.error)Z=1;this._exit(Z,"commander.help","(outputHelp)")}addHelpText($,Z){let X=["beforeAll","before","after","afterAll"];if(!X.includes($))throw Error(`Unexpected value for position to addHelpText.
|
|
27
27
|
Expecting one of '${X.join("', '")}'`);let z=`${$}Help`;return this.on(z,(q)=>{let G;if(typeof Z==="function")G=Z({error:q.error,command:q.command});else G=Z;if(G)q.write(`${G}
|
|
28
|
-
`)}),this}_outputHelpIfRequested($){let Z=this._getHelpOption();if(Z&&$.find((z)=>Z.is(z)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function
|
|
29
|
-
`)}}
|
|
30
|
-
`)?
|
|
28
|
+
`)}),this}_outputHelpIfRequested($){let Z=this._getHelpOption();if(Z&&$.find((z)=>Z.is(z)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function f5($){return $.map((Z)=>{if(!Z.startsWith("--inspect"))return Z;let X,z="127.0.0.1",q="9229",G;if((G=Z.match(/^(--inspect(-brk)?)$/))!==null)X=G[1];else if((G=Z.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(X=G[1],/^\d+$/.test(G[3]))q=G[3];else z=G[3];else if((G=Z.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)X=G[1],z=G[3],q=G[4];if(X&&q!=="0")return`${X}=${z}:${parseInt(q)+1}`;return Z})}function F4(){if(b.env.NO_COLOR||b.env.FORCE_COLOR==="0"||b.env.FORCE_COLOR==="false")return!1;if(b.env.FORCE_COLOR||b.env.CLICOLOR_FORCE!==void 0)return!0;return}cX.Command=M4;cX.useColor=F4});var m5=F((rX)=>{var{Argument:g5}=E1(),{Command:O4}=h5(),{CommanderError:nX,InvalidArgumentError:v5}=f$(),{Help:sX}=L4(),{Option:u5}=T4();rX.program=new O4;rX.createCommand=($)=>new O4($);rX.createOption=($,Z)=>new u5($,Z);rX.createArgument=($,Z)=>new g5($,Z);rX.Command=O4;rX.Option=u5;rX.Argument=g5;rX.Help=sX;rX.CommanderError=nX;rX.InvalidArgumentError=v5;rX.InvalidOptionArgumentError=v5});var E=F((Tz)=>{var R4=Symbol.for("yaml.alias"),l5=Symbol.for("yaml.document"),y1=Symbol.for("yaml.map"),c5=Symbol.for("yaml.pair"),j4=Symbol.for("yaml.scalar"),x1=Symbol.for("yaml.seq"),T0=Symbol.for("yaml.node.type"),Hz=($)=>!!$&&typeof $==="object"&&$[T0]===R4,Uz=($)=>!!$&&typeof $==="object"&&$[T0]===l5,Wz=($)=>!!$&&typeof $==="object"&&$[T0]===y1,Vz=($)=>!!$&&typeof $==="object"&&$[T0]===c5,i5=($)=>!!$&&typeof $==="object"&&$[T0]===j4,Kz=($)=>!!$&&typeof $==="object"&&$[T0]===x1;function a5($){if($&&typeof $==="object")switch($[T0]){case y1:case x1:return!0}return!1}function Bz($){if($&&typeof $==="object")switch($[T0]){case R4:case y1:case j4:case x1:return!0}return!1}var Lz=($)=>(i5($)||a5($))&&!!$.anchor;Tz.ALIAS=R4;Tz.DOC=l5;Tz.MAP=y1;Tz.NODE_TYPE=T0;Tz.PAIR=c5;Tz.SCALAR=j4;Tz.SEQ=x1;Tz.hasAnchor=Lz;Tz.isAlias=Hz;Tz.isCollection=a5;Tz.isDocument=Uz;Tz.isMap=Wz;Tz.isNode=Bz;Tz.isPair=Vz;Tz.isScalar=i5;Tz.isSeq=Kz});var h$=F((yz)=>{var v=E(),r=Symbol("break visit"),n5=Symbol("skip children"),W0=Symbol("remove node");function k1($,Z){let X=s5(Z);if(v.isDocument($)){if(z$(null,$.contents,X,Object.freeze([$]))===W0)$.contents=null}else z$(null,$,X,Object.freeze([]))}k1.BREAK=r;k1.SKIP=n5;k1.REMOVE=W0;function z$($,Z,X,z){let q=r5($,Z,X,z);if(v.isNode(q)||v.isPair(q))return o5($,z,q),z$($,q,X,z);if(typeof q!=="symbol"){if(v.isCollection(Z)){z=Object.freeze(z.concat(Z));for(let G=0;G<Z.items.length;++G){let J=z$(G,Z.items[G],X,z);if(typeof J==="number")G=J-1;else if(J===r)return r;else if(J===W0)Z.items.splice(G,1),G-=1}}else if(v.isPair(Z)){z=Object.freeze(z.concat(Z));let G=z$("key",Z.key,X,z);if(G===r)return r;else if(G===W0)Z.key=null;let J=z$("value",Z.value,X,z);if(J===r)return r;else if(J===W0)Z.value=null}}return q}async function f1($,Z){let X=s5(Z);if(v.isDocument($)){if(await q$(null,$.contents,X,Object.freeze([$]))===W0)$.contents=null}else await q$(null,$,X,Object.freeze([]))}f1.BREAK=r;f1.SKIP=n5;f1.REMOVE=W0;async function q$($,Z,X,z){let q=await r5($,Z,X,z);if(v.isNode(q)||v.isPair(q))return o5($,z,q),q$($,q,X,z);if(typeof q!=="symbol"){if(v.isCollection(Z)){z=Object.freeze(z.concat(Z));for(let G=0;G<Z.items.length;++G){let J=await q$(G,Z.items[G],X,z);if(typeof J==="number")G=J-1;else if(J===r)return r;else if(J===W0)Z.items.splice(G,1),G-=1}}else if(v.isPair(Z)){z=Object.freeze(z.concat(Z));let G=await q$("key",Z.key,X,z);if(G===r)return r;else if(G===W0)Z.key=null;let J=await q$("value",Z.value,X,z);if(J===r)return r;else if(J===W0)Z.value=null}}return q}function s5($){if(typeof $==="object"&&($.Collection||$.Node||$.Value))return Object.assign({Alias:$.Node,Map:$.Node,Scalar:$.Node,Seq:$.Node},$.Value&&{Map:$.Value,Scalar:$.Value,Seq:$.Value},$.Collection&&{Map:$.Collection,Seq:$.Collection},$);return $}function r5($,Z,X,z){if(typeof X==="function")return X($,Z,z);if(v.isMap(Z))return X.Map?.($,Z,z);if(v.isSeq(Z))return X.Seq?.($,Z,z);if(v.isPair(Z))return X.Pair?.($,Z,z);if(v.isScalar(Z))return X.Scalar?.($,Z,z);if(v.isAlias(Z))return X.Alias?.($,Z,z);return}function o5($,Z,X){let z=Z[Z.length-1];if(v.isCollection(z))z.items[$]=X;else if(v.isPair(z))if($==="key")z.key=X;else z.value=X;else if(v.isDocument(z))z.contents=X;else{let q=v.isAlias(z)?"alias":"scalar";throw Error(`Cannot replace node with ${q} parent`)}}yz.visit=k1;yz.visitAsync=f1});var A4=F((vz)=>{var t5=E(),fz=h$(),hz={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},gz=($)=>$.replace(/[!,[\]{}]/g,(Z)=>hz[Z]);class $0{constructor($,Z){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},$0.defaultYaml,$),this.tags=Object.assign({},$0.defaultTags,Z)}clone(){let $=new $0(this.yaml,this.tags);return $.docStart=this.docStart,$}atDocument(){let $=new $0(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:$0.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},$0.defaultTags);break}return $}add($,Z){if(this.atNextDocument)this.yaml={explicit:$0.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},$0.defaultTags),this.atNextDocument=!1;let X=$.trim().split(/[ \t]+/),z=X.shift();switch(z){case"%TAG":{if(X.length!==2){if(Z(0,"%TAG directive should contain exactly two parts"),X.length<2)return!1}let[q,G]=X;return this.tags[q]=G,!0}case"%YAML":{if(this.yaml.explicit=!0,X.length!==1)return Z(0,"%YAML directive should contain exactly one part"),!1;let[q]=X;if(q==="1.1"||q==="1.2")return this.yaml.version=q,!0;else{let G=/^\d+\.\d+$/.test(q);return Z(6,`Unsupported YAML version ${q}`,G),!1}}default:return Z(0,`Unknown directive ${z}`,!0),!1}}tagName($,Z){if($==="!")return"!";if($[0]!=="!")return Z(`Not a valid tag: ${$}`),null;if($[1]==="<"){let G=$.slice(2,-1);if(G==="!"||G==="!!")return Z(`Verbatim tags aren't resolved, so ${$} is invalid.`),null;if($[$.length-1]!==">")Z("Verbatim tags must end with a >");return G}let[,X,z]=$.match(/^(.*!)([^!]*)$/s);if(!z)Z(`The ${$} tag has no suffix`);let q=this.tags[X];if(q)try{return q+decodeURIComponent(z)}catch(G){return Z(String(G)),null}if(X==="!")return $;return Z(`Could not resolve tag: ${$}`),null}tagString($){for(let[Z,X]of Object.entries(this.tags))if($.startsWith(X))return Z+gz($.substring(X.length));return $[0]==="!"?$:`!<${$}>`}toString($){let Z=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],X=Object.entries(this.tags),z;if($&&X.length>0&&t5.isNode($.contents)){let q={};fz.visit($.contents,(G,J)=>{if(t5.isNode(J)&&J.tag)q[J.tag]=!0}),z=Object.keys(q)}else z=[];for(let[q,G]of X){if(q==="!!"&&G==="tag:yaml.org,2002:")continue;if(!$||z.some((J)=>J.startsWith(G)))Z.push(`%TAG ${q} ${G}`)}return Z.join(`
|
|
29
|
+
`)}}$0.defaultYaml={explicit:!1,version:"1.2"};$0.defaultTags={"!!":"tag:yaml.org,2002:"};vz.Directives=$0});var h1=F((lz)=>{var e5=E(),mz=h$();function dz($){if(/[\x00-\x19\s,[\]{}]/.test($)){let X=`Anchor must not contain whitespace or control characters: ${JSON.stringify($)}`;throw Error(X)}return!0}function $6($){let Z=new Set;return mz.visit($,{Value(X,z){if(z.anchor)Z.add(z.anchor)}}),Z}function Z6($,Z){for(let X=1;;++X){let z=`${$}${X}`;if(!Z.has(z))return z}}function pz($,Z){let X=[],z=new Map,q=null;return{onAnchor:(G)=>{X.push(G),q??(q=$6($));let J=Z6(Z,q);return q.add(J),J},setAnchors:()=>{for(let G of X){let J=z.get(G);if(typeof J==="object"&&J.anchor&&(e5.isScalar(J.node)||e5.isCollection(J.node)))J.node.anchor=J.anchor;else{let Q=Error("Failed to resolve repeated object (this should not happen)");throw Q.source=G,Q}}},sourceObjects:z}}lz.anchorIsValid=dz;lz.anchorNames=$6;lz.createNodeAnchors=pz;lz.findNewAnchor=Z6});var N4=F((sz)=>{function g$($,Z,X,z){if(z&&typeof z==="object")if(Array.isArray(z))for(let q=0,G=z.length;q<G;++q){let J=z[q],Q=g$($,z,String(q),J);if(Q===void 0)delete z[q];else if(Q!==J)z[q]=Q}else if(z instanceof Map)for(let q of Array.from(z.keys())){let G=z.get(q),J=g$($,z,q,G);if(J===void 0)z.delete(q);else if(J!==G)z.set(q,J)}else if(z instanceof Set)for(let q of Array.from(z)){let G=g$($,z,q,q);if(G===void 0)z.delete(q);else if(G!==q)z.delete(q),z.add(G)}else for(let[q,G]of Object.entries(z)){let J=g$($,z,q,G);if(J===void 0)delete z[q];else if(J!==G)z[q]=J}return $.call(Z,X,z)}sz.applyReviver=g$});var j0=F((tz)=>{var oz=E();function X6($,Z,X){if(Array.isArray($))return $.map((z,q)=>X6(z,String(q),X));if($&&typeof $.toJSON==="function"){if(!X||!oz.hasAnchor($))return $.toJSON(Z,X);let z={aliasCount:0,count:1,res:void 0};X.anchors.set($,z),X.onCreate=(G)=>{z.res=G,delete X.onCreate};let q=$.toJSON(Z,X);if(X.onCreate)X.onCreate(q);return q}if(typeof $==="bigint"&&!X?.keep)return Number($);return $}tz.toJS=X6});var g1=F((X3)=>{var $3=N4(),z6=E(),Z3=j0();class q6{constructor($){Object.defineProperty(this,z6.NODE_TYPE,{value:$})}clone(){let $=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)$.range=this.range.slice();return $}toJS($,{mapAsMap:Z,maxAliasCount:X,onAnchor:z,reviver:q}={}){if(!z6.isDocument($))throw TypeError("A document argument is required");let G={anchors:new Map,doc:$,keep:!0,mapAsMap:Z===!0,mapKeyWarned:!1,maxAliasCount:typeof X==="number"?X:100},J=Z3.toJS(this,"",G);if(typeof z==="function")for(let{count:Q,res:H}of G.anchors.values())z(H,Q);return typeof q==="function"?$3.applyReviver(q,{"":J},"",J):J}}X3.NodeBase=q6});var v$=F((Y3)=>{var q3=h1(),G3=h$(),G$=E(),J3=g1(),Q3=j0();class G6 extends J3.NodeBase{constructor($){super(G$.ALIAS);this.source=$,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve($,Z){let X;if(Z?.aliasResolveCache)X=Z.aliasResolveCache;else if(X=[],G3.visit($,{Node:(q,G)=>{if(G$.isAlias(G)||G$.hasAnchor(G))X.push(G)}}),Z)Z.aliasResolveCache=X;let z=void 0;for(let q of X){if(q===this)break;if(q.anchor===this.source)z=q}return z}toJSON($,Z){if(!Z)return{source:this.source};let{anchors:X,doc:z,maxAliasCount:q}=Z,G=this.resolve(z,Z);if(!G){let Q=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(Q)}let J=X.get(G);if(!J)Q3.toJS(G,null,Z),J=X.get(G);if(J?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(q>=0){if(J.count+=1,J.aliasCount===0)J.aliasCount=v1(z,G,X);if(J.count*J.aliasCount>q)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return J.res}toString($,Z,X){let z=`*${this.source}`;if($){if(q3.anchorIsValid(this.source),$.options.verifyAliasOrder&&!$.anchors.has(this.source)){let q=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(q)}if($.implicitKey)return`${z} `}return z}}function v1($,Z,X){if(G$.isAlias(Z)){let z=Z.resolve($),q=X&&z&&X.get(z);return q?q.count*q.aliasCount:0}else if(G$.isCollection(Z)){let z=0;for(let q of Z.items){let G=v1($,q,X);if(G>z)z=G}return z}else if(G$.isPair(Z)){let z=v1($,Z.key,X),q=v1($,Z.value,X);return Math.max(z,q)}return 1}Y3.Alias=G6});var g=F((B3)=>{var U3=E(),W3=g1(),V3=j0(),K3=($)=>!$||typeof $!=="function"&&typeof $!=="object";class p0 extends W3.NodeBase{constructor($){super(U3.SCALAR);this.value=$}toJSON($,Z){return Z?.keep?this.value:V3.toJS(this.value,$,Z)}toString(){return String(this.value)}}p0.BLOCK_FOLDED="BLOCK_FOLDED";p0.BLOCK_LITERAL="BLOCK_LITERAL";p0.PLAIN="PLAIN";p0.QUOTE_DOUBLE="QUOTE_DOUBLE";p0.QUOTE_SINGLE="QUOTE_SINGLE";B3.Scalar=p0;B3.isScalarValue=K3});var u$=F((O3)=>{var D3=v$(),l0=E(),J6=g(),_3="tag:yaml.org,2002:";function F3($,Z,X){if(Z){let z=X.filter((G)=>G.tag===Z),q=z.find((G)=>!G.format)??z[0];if(!q)throw Error(`Tag ${Z} not found`);return q}return X.find((z)=>z.identify?.($)&&!z.format)}function M3($,Z,X){if(l0.isDocument($))$=$.contents;if(l0.isNode($))return $;if(l0.isPair($)){let U=X.schema[l0.MAP].createNode?.(X.schema,null,X);return U.items.push($),U}if($ instanceof String||$ instanceof Number||$ instanceof Boolean||typeof BigInt<"u"&&$ instanceof BigInt)$=$.valueOf();let{aliasDuplicateObjects:z,onAnchor:q,onTagObj:G,schema:J,sourceObjects:Q}=X,H=void 0;if(z&&$&&typeof $==="object")if(H=Q.get($),H)return H.anchor??(H.anchor=q($)),new D3.Alias(H.anchor);else H={anchor:null,node:null},Q.set($,H);if(Z?.startsWith("!!"))Z=_3+Z.slice(2);let Y=F3($,Z,J.tags);if(!Y){if($&&typeof $.toJSON==="function")$=$.toJSON();if(!$||typeof $!=="object"){let U=new J6.Scalar($);if(H)H.node=U;return U}Y=$ instanceof Map?J[l0.MAP]:(Symbol.iterator in Object($))?J[l0.SEQ]:J[l0.MAP]}if(G)G(Y),delete X.onTagObj;let W=Y?.createNode?Y.createNode(X.schema,$,X):typeof Y?.nodeClass?.from==="function"?Y.nodeClass.from(X.schema,$,X):new J6.Scalar($);if(Z)W.tag=Z;else if(!Y.default)W.tag=Y.tag;if(H)H.node=W;return W}O3.createNode=M3});var u1=F((R3)=>{var I3=u$(),V0=E(),P3=g1();function S4($,Z,X){let z=X;for(let q=Z.length-1;q>=0;--q){let G=Z[q];if(typeof G==="number"&&Number.isInteger(G)&&G>=0){let J=[];J[G]=z,z=J}else z=new Map([[G,z]])}return I3.createNode(z,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:$,sourceObjects:new Map})}var Q6=($)=>$==null||typeof $==="object"&&!!$[Symbol.iterator]().next().done;class Y6 extends P3.NodeBase{constructor($,Z){super($);Object.defineProperty(this,"schema",{value:Z,configurable:!0,enumerable:!1,writable:!0})}clone($){let Z=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if($)Z.schema=$;if(Z.items=Z.items.map((X)=>V0.isNode(X)||V0.isPair(X)?X.clone($):X),this.range)Z.range=this.range.slice();return Z}addIn($,Z){if(Q6($))this.add(Z);else{let[X,...z]=$,q=this.get(X,!0);if(V0.isCollection(q))q.addIn(z,Z);else if(q===void 0&&this.schema)this.set(X,S4(this.schema,z,Z));else throw Error(`Expected YAML collection at ${X}. Remaining path: ${z}`)}}deleteIn($){let[Z,...X]=$;if(X.length===0)return this.delete(Z);let z=this.get(Z,!0);if(V0.isCollection(z))return z.deleteIn(X);else throw Error(`Expected YAML collection at ${Z}. Remaining path: ${X}`)}getIn($,Z){let[X,...z]=$,q=this.get(X,!0);if(z.length===0)return!Z&&V0.isScalar(q)?q.value:q;else return V0.isCollection(q)?q.getIn(z,Z):void 0}hasAllNullValues($){return this.items.every((Z)=>{if(!V0.isPair(Z))return!1;let X=Z.value;return X==null||$&&V0.isScalar(X)&&X.value==null&&!X.commentBefore&&!X.comment&&!X.tag})}hasIn($){let[Z,...X]=$;if(X.length===0)return this.has(Z);let z=this.get(Z,!0);return V0.isCollection(z)?z.hasIn(X):!1}setIn($,Z){let[X,...z]=$;if(z.length===0)this.set(X,Z);else{let q=this.get(X,!0);if(V0.isCollection(q))q.setIn(z,Z);else if(q===void 0&&this.schema)this.set(X,S4(this.schema,z,Z));else throw Error(`Expected YAML collection at ${X}. Remaining path: ${z}`)}}}R3.Collection=Y6;R3.collectionFromPath=S4;R3.isEmptyPath=Q6});var m$=F((E3)=>{var S3=($)=>$.replace(/^(?!$)(?: $)?/gm,"#");function C4($,Z){if(/^\n+$/.test($))return $.substring(1);return Z?$.replace(/^(?! *$)/gm,Z):$}var C3=($,Z,X)=>$.endsWith(`
|
|
30
|
+
`)?C4(X,Z):X.includes(`
|
|
31
31
|
`)?`
|
|
32
|
-
`+
|
|
33
|
-
`){if(X==="block")K=
|
|
32
|
+
`+C4(X,Z):($.endsWith(" ")?"":" ")+X;E3.indentComment=C4;E3.lineComment=C3;E3.stringifyComment=S3});var U6=F((f3)=>{function k3($,Z,X="flow",{indentAtStart:z,lineWidth:q=80,minContentWidth:G=20,onFold:J,onOverflow:Q}={}){if(!q||q<0)return $;if(q<G)G=0;let H=Math.max(1+G,1+q-Z.length);if($.length<=H)return $;let Y=[],W={},U=q-Z.length;if(typeof z==="number")if(z>q-Math.max(2,G))Y.push(0);else U=q-z;let V=void 0,B=void 0,T=!1,K=-1,L=-1,D=-1;if(X==="block"){if(K=H6($,K,Z.length),K!==-1)U=K+H}for(let M;M=$[K+=1];){if(X==="quoted"&&M==="\\"){switch(L=K,$[K+1]){case"x":K+=3;break;case"u":K+=5;break;case"U":K+=9;break;default:K+=1}D=K}if(M===`
|
|
33
|
+
`){if(X==="block")K=H6($,K,Z.length);U=K+Z.length+H,V=void 0}else{if(M===" "&&B&&B!==" "&&B!==`
|
|
34
34
|
`&&B!=="\t"){let w=$[K+1];if(w&&w!==" "&&w!==`
|
|
35
|
-
`&&w!=="\t")V=K}if(K>=U)if(V)
|
|
35
|
+
`&&w!=="\t")V=K}if(K>=U)if(V)Y.push(V),U=V+H,V=void 0;else if(X==="quoted"){while(B===" "||B==="\t")B=M,M=$[K+=1],T=!0;let w=K>D+1?K-2:L-1;if(W[w])return $;Y.push(w),W[w]=!0,U=w+H,V=void 0}else T=!0}B=M}if(T&&Q)Q();if(Y.length===0)return $;if(J)J();let _=$.slice(0,Y[0]);for(let M=0;M<Y.length;++M){let w=Y[M],R=Y[M+1]||$.length;if(w===0)_=`
|
|
36
36
|
${Z}${$.slice(0,R)}`;else{if(X==="quoted"&&W[w])_+=`${$[w]}\\`;_+=`
|
|
37
|
-
${Z}${$.slice(w+1,R)}`}}return _}function
|
|
38
|
-
`);z=Z,q=Z+1,G=$[q]}return z}
|
|
39
|
-
`){if(G-J>z)return!0;if(J=G+1,q-J<=z)return!1}return!0}function d$($,Z){let X=JSON.stringify($);if(Z.options.doubleQuotedAsJSON)return X;let{implicitKey:z}=Z,q=Z.options.doubleQuotedMinMultiLineLength,G=Z.indent||(p1($)?" ":""),J="",Q=0;for(let
|
|
37
|
+
${Z}${$.slice(w+1,R)}`}}return _}function H6($,Z,X){let z=Z,q=Z+1,G=$[q];while(G===" "||G==="\t")if(Z<q+X)G=$[++Z];else{do G=$[++Z];while(G&&G!==`
|
|
38
|
+
`);z=Z,q=Z+1,G=$[q]}return z}f3.FOLD_BLOCK="block";f3.FOLD_FLOW="flow";f3.FOLD_QUOTED="quoted";f3.foldFlowLines=k3});var p$=F((l3)=>{var J0=g(),A0=U6(),d1=($,Z)=>({indentAtStart:Z?$.indent.length:$.indentAtStart,lineWidth:$.options.lineWidth,minContentWidth:$.options.minContentWidth}),p1=($)=>/^(%|---|\.\.\.)/m.test($);function m3($,Z,X){if(!Z||Z<0)return!1;let z=Z-X,q=$.length;if(q<=z)return!1;for(let G=0,J=0;G<q;++G)if($[G]===`
|
|
39
|
+
`){if(G-J>z)return!0;if(J=G+1,q-J<=z)return!1}return!0}function d$($,Z){let X=JSON.stringify($);if(Z.options.doubleQuotedAsJSON)return X;let{implicitKey:z}=Z,q=Z.options.doubleQuotedMinMultiLineLength,G=Z.indent||(p1($)?" ":""),J="",Q=0;for(let H=0,Y=X[H];Y;Y=X[++H]){if(Y===" "&&X[H+1]==="\\"&&X[H+2]==="n")J+=X.slice(Q,H)+"\\ ",H+=1,Q=H,Y="\\";if(Y==="\\")switch(X[H+1]){case"u":{J+=X.slice(Q,H);let W=X.substr(H+2,4);switch(W){case"0000":J+="\\0";break;case"0007":J+="\\a";break;case"000b":J+="\\v";break;case"001b":J+="\\e";break;case"0085":J+="\\N";break;case"00a0":J+="\\_";break;case"2028":J+="\\L";break;case"2029":J+="\\P";break;default:if(W.substr(0,2)==="00")J+="\\x"+W.substr(2);else J+=X.substr(H,6)}H+=5,Q=H+1}break;case"n":if(z||X[H+2]==='"'||X.length<q)H+=1;else{J+=X.slice(Q,H)+`
|
|
40
40
|
|
|
41
|
-
`;while(X[
|
|
42
|
-
`,
|
|
41
|
+
`;while(X[H+2]==="\\"&&X[H+3]==="n"&&X[H+4]!=='"')J+=`
|
|
42
|
+
`,H+=2;if(J+=G,X[H+2]===" ")J+="\\";H+=1,Q=H+1}break;default:H+=1}}return J=Q?J+X.slice(Q):X,z?J:A0.foldFlowLines(J,G,A0.FOLD_QUOTED,d1(Z,!1))}function E4($,Z){if(Z.options.singleQuote===!1||Z.implicitKey&&$.includes(`
|
|
43
43
|
`)||/[ \t]\n|\n[ \t]/.test($))return d$($,Z);let X=Z.indent||(p1($)?" ":""),z="'"+$.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
44
|
-
${X}`)+"'";return Z.implicitKey?z:A0.foldFlowLines(z,X,A0.FOLD_FLOW,d1(Z,!1))}function
|
|
44
|
+
${X}`)+"'";return Z.implicitKey?z:A0.foldFlowLines(z,X,A0.FOLD_FLOW,d1(Z,!1))}function J$($,Z){let{singleQuote:X}=Z.options,z;if(X===!1)z=d$;else{let q=$.includes('"'),G=$.includes("'");if(q&&!G)z=E4;else if(G&&!q)z=d$;else z=X?E4:d$}return z($,Z)}var b4;try{b4=new RegExp(`(^|(?<!
|
|
45
45
|
))
|
|
46
46
|
+(?!
|
|
47
|
-
|$)`,"g")}catch{
|
|
47
|
+
|$)`,"g")}catch{b4=/\n+(?!\n|$)/g}function m1({comment:$,type:Z,value:X},z,q,G){let{blockQuote:J,commentString:Q,lineWidth:H}=z.options;if(!J||/\n[\t ]+$/.test(X))return J$(X,z);let Y=z.indent||(z.forceBlockIndent||p1(X)?" ":""),W=J==="literal"?!0:J==="folded"||Z===J0.Scalar.BLOCK_FOLDED?!1:Z===J0.Scalar.BLOCK_LITERAL?!0:!m3(X,H,Y.length);if(!X)return W?`|
|
|
48
48
|
`:`>
|
|
49
49
|
`;let U,V;for(V=X.length;V>0;--V){let R=X[V-1];if(R!==`
|
|
50
50
|
`&&R!=="\t"&&R!==" ")break}let B=X.substring(V),T=B.indexOf(`
|
|
51
51
|
`);if(T===-1)U="-";else if(X===B||T!==B.length-1){if(U="+",G)G()}else U="";if(B){if(X=X.slice(0,-B.length),B[B.length-1]===`
|
|
52
|
-
`)B=B.slice(0,-1);B=B.replace(
|
|
53
|
-
`)D=L;else break}let _=X.substring(0,D<L?D+1:L);if(_)X=X.substring(_.length),_=_.replace(/\n+/g,`$&${
|
|
54
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${
|
|
55
|
-
${
|
|
56
|
-
${
|
|
57
|
-
`)||W&&/[[\]{},]/.test(G))return
|
|
58
|
-
`)?
|
|
59
|
-
`))return m1($,Z,X,z);if(p1(G)){if(
|
|
60
|
-
${
|
|
61
|
-
${Z.indent}${Q}`}
|
|
62
|
-
${Q}:`}else if(L=`${L}:`,V)L+=c$.lineComment(L,X.indent,
|
|
63
|
-
`:"",_){let
|
|
64
|
-
${c$.indentComment(
|
|
65
|
-
`&&
|
|
52
|
+
`)B=B.slice(0,-1);B=B.replace(b4,`$&${Y}`)}let K=!1,L,D=-1;for(L=0;L<X.length;++L){let R=X[L];if(R===" ")K=!0;else if(R===`
|
|
53
|
+
`)D=L;else break}let _=X.substring(0,D<L?D+1:L);if(_)X=X.substring(_.length),_=_.replace(/\n+/g,`$&${Y}`);let w=(K?Y?"2":"1":"")+U;if($){if(w+=" "+Q($.replace(/ ?[\r\n]+/g," ")),q)q()}if(!W){let R=X.replace(/\n+/g,`
|
|
54
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${Y}`),P=!1,A=d1(z,!0);if(J!=="folded"&&Z!==J0.Scalar.BLOCK_FOLDED)A.onOverflow=()=>{P=!0};let O=A0.foldFlowLines(`${_}${R}${B}`,Y,A0.FOLD_BLOCK,A);if(!P)return`>${w}
|
|
55
|
+
${Y}${O}`}return X=X.replace(/\n+/g,`$&${Y}`),`|${w}
|
|
56
|
+
${Y}${_}${X}${B}`}function d3($,Z,X,z){let{type:q,value:G}=$,{actualString:J,implicitKey:Q,indent:H,indentStep:Y,inFlow:W}=Z;if(Q&&G.includes(`
|
|
57
|
+
`)||W&&/[[\]{},]/.test(G))return J$(G,Z);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(G))return Q||W||!G.includes(`
|
|
58
|
+
`)?J$(G,Z):m1($,Z,X,z);if(!Q&&!W&&q!==J0.Scalar.PLAIN&&G.includes(`
|
|
59
|
+
`))return m1($,Z,X,z);if(p1(G)){if(H==="")return Z.forceBlockIndent=!0,m1($,Z,X,z);else if(Q&&H===Y)return J$(G,Z)}let U=G.replace(/\n+/g,`$&
|
|
60
|
+
${H}`);if(J){let V=(K)=>K.default&&K.tag!=="tag:yaml.org,2002:str"&&K.test?.test(U),{compat:B,tags:T}=Z.doc.schema;if(T.some(V)||B?.some(V))return J$(G,Z)}return Q?U:A0.foldFlowLines(U,H,A0.FOLD_FLOW,d1(Z,!1))}function p3($,Z,X,z){let{implicitKey:q,inFlow:G}=Z,J=typeof $.value==="string"?$:Object.assign({},$,{value:String($.value)}),{type:Q}=$;if(Q!==J0.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(J.value))Q=J0.Scalar.QUOTE_DOUBLE}let H=(W)=>{switch(W){case J0.Scalar.BLOCK_FOLDED:case J0.Scalar.BLOCK_LITERAL:return q||G?J$(J.value,Z):m1(J,Z,X,z);case J0.Scalar.QUOTE_DOUBLE:return d$(J.value,Z);case J0.Scalar.QUOTE_SINGLE:return E4(J.value,Z);case J0.Scalar.PLAIN:return d3(J,Z,X,z);default:return null}},Y=H(Q);if(Y===null){let{defaultKeyType:W,defaultStringType:U}=Z.options,V=q&&W||U;if(Y=H(V),Y===null)throw Error(`Unsupported default string type ${V}`)}return Y}l3.stringifyString=p3});var l$=F((e3)=>{var i3=h1(),N0=E(),a3=m$(),n3=p$();function s3($,Z){let X=Object.assign({blockQuote:!0,commentString:a3.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},$.schema.toStringOptions,Z),z;switch(X.collectionStyle){case"block":z=!1;break;case"flow":z=!0;break;default:z=null}return{anchors:new Set,doc:$,flowCollectionPadding:X.flowCollectionPadding?" ":"",indent:"",indentStep:typeof X.indent==="number"?" ".repeat(X.indent):" ",inFlow:z,options:X}}function r3($,Z){if(Z.tag){let q=$.filter((G)=>G.tag===Z.tag);if(q.length>0)return q.find((G)=>G.format===Z.format)??q[0]}let X=void 0,z;if(N0.isScalar(Z)){z=Z.value;let q=$.filter((G)=>G.identify?.(z));if(q.length>1){let G=q.filter((J)=>J.test);if(G.length>0)q=G}X=q.find((G)=>G.format===Z.format)??q.find((G)=>!G.format)}else z=Z,X=$.find((q)=>q.nodeClass&&z instanceof q.nodeClass);if(!X){let q=z?.constructor?.name??(z===null?"null":typeof z);throw Error(`Tag not resolved for ${q} value`)}return X}function o3($,Z,{anchors:X,doc:z}){if(!z.directives)return"";let q=[],G=(N0.isScalar($)||N0.isCollection($))&&$.anchor;if(G&&i3.anchorIsValid(G))X.add(G),q.push(`&${G}`);let J=$.tag??(Z.default?null:Z.tag);if(J)q.push(z.directives.tagString(J));return q.join(" ")}function t3($,Z,X,z){if(N0.isPair($))return $.toString(Z,X,z);if(N0.isAlias($)){if(Z.doc.directives)return $.toString(Z);if(Z.resolvedAliases?.has($))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(Z.resolvedAliases)Z.resolvedAliases.add($);else Z.resolvedAliases=new Set([$]);$=$.resolve(Z.doc)}}let q=void 0,G=N0.isNode($)?$:Z.doc.createNode($,{onTagObj:(H)=>q=H});q??(q=r3(Z.doc.schema.tags,G));let J=o3(G,q,Z);if(J.length>0)Z.indentAtStart=(Z.indentAtStart??0)+J.length+1;let Q=typeof q.stringify==="function"?q.stringify(G,Z,X,z):N0.isScalar(G)?n3.stringifyString(G,Z,X,z):G.toString(Z,X,z);if(!J)return Q;return N0.isScalar(G)||Q[0]==="{"||Q[0]==="["?`${J} ${Q}`:`${J}
|
|
61
|
+
${Z.indent}${Q}`}e3.createStringifyContext=s3;e3.stringify=t3});var K6=F((z7)=>{var D0=E(),W6=g(),V6=l$(),c$=m$();function X7({key:$,value:Z},X,z,q){let{allNullValues:G,doc:J,indent:Q,indentStep:H,options:{commentString:Y,indentSeq:W,simpleKeys:U}}=X,V=D0.isNode($)&&$.comment||null;if(U){if(V)throw Error("With simple keys, key nodes cannot have comments");if(D0.isCollection($)||!D0.isNode($)&&typeof $==="object")throw Error("With simple keys, collection cannot be used as a key value")}let B=!U&&(!$||V&&Z==null&&!X.inFlow||D0.isCollection($)||(D0.isScalar($)?$.type===W6.Scalar.BLOCK_FOLDED||$.type===W6.Scalar.BLOCK_LITERAL:typeof $==="object"));X=Object.assign({},X,{allNullValues:!1,implicitKey:!B&&(U||!G),indent:Q+H});let T=!1,K=!1,L=V6.stringify($,X,()=>T=!0,()=>K=!0);if(!B&&!X.inFlow&&L.length>1024){if(U)throw Error("With simple keys, single line scalar must not span more than 1024 characters");B=!0}if(X.inFlow){if(G||Z==null){if(T&&z)z();return L===""?"?":B?`? ${L}`:L}}else if(G&&!U||Z==null&&B){if(L=`? ${L}`,V&&!T)L+=c$.lineComment(L,X.indent,Y(V));else if(K&&q)q();return L}if(T)V=null;if(B){if(V)L+=c$.lineComment(L,X.indent,Y(V));L=`? ${L}
|
|
62
|
+
${Q}:`}else if(L=`${L}:`,V)L+=c$.lineComment(L,X.indent,Y(V));let D,_,M;if(D0.isNode(Z))D=!!Z.spaceBefore,_=Z.commentBefore,M=Z.comment;else if(D=!1,_=null,M=null,Z&&typeof Z==="object")Z=J.createNode(Z);if(X.implicitKey=!1,!B&&!V&&D0.isScalar(Z))X.indentAtStart=L.length+1;if(K=!1,!W&&H.length>=2&&!X.inFlow&&!B&&D0.isSeq(Z)&&!Z.flow&&!Z.tag&&!Z.anchor)X.indent=X.indent.substring(2);let w=!1,R=V6.stringify(Z,X,()=>w=!0,()=>K=!0),P=" ";if(V||D||_){if(P=D?`
|
|
63
|
+
`:"",_){let A=Y(_);P+=`
|
|
64
|
+
${c$.indentComment(A,X.indent)}`}if(R===""&&!X.inFlow){if(P===`
|
|
65
|
+
`&&M)P=`
|
|
66
66
|
|
|
67
|
-
`}else
|
|
68
|
-
${X.indent}`}else if(!B&&D0.isCollection(Z)){let
|
|
69
|
-
`),y=
|
|
67
|
+
`}else P+=`
|
|
68
|
+
${X.indent}`}else if(!B&&D0.isCollection(Z)){let A=R[0],O=R.indexOf(`
|
|
69
|
+
`),y=O!==-1,m=X.inFlow??Z.flow??Z.items.length===0;if(y||!m){let i=!1;if(y&&(A==="&"||A==="!")){let x=R.indexOf(" ");if(A==="&"&&x!==-1&&x<O&&R[x+1]==="!")x=R.indexOf(" ",x+1);if(x===-1||O<x)i=!0}if(!i)P=`
|
|
70
70
|
${X.indent}`}}else if(R===""||R[0]===`
|
|
71
|
-
`)
|
|
72
|
-
${
|
|
71
|
+
`)P="";if(L+=P+R,X.inFlow){if(w&&z)z()}else if(M&&!w)L+=c$.lineComment(L,X.indent,Y(M));else if(K&&q)q();return L}z7.stringifyPair=X7});var y4=F((Q7)=>{var B6=B0("process");function G7($,...Z){if($==="debug")console.log(...Z)}function J7($,Z){if($==="debug"||$==="warn")if(typeof B6.emitWarning==="function")B6.emitWarning(Z);else console.warn(Z)}Q7.debug=G7;Q7.warn=J7});var i1=F((W7)=>{var i$=E(),L6=g(),l1="<<",c1={identify:($)=>$===l1||typeof $==="symbol"&&$.description===l1,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new L6.Scalar(Symbol(l1)),{addToJSMap:T6}),stringify:()=>l1},U7=($,Z)=>(c1.identify(Z)||i$.isScalar(Z)&&(!Z.type||Z.type===L6.Scalar.PLAIN)&&c1.identify(Z.value))&&$?.doc.schema.tags.some((X)=>X.tag===c1.tag&&X.default);function T6($,Z,X){if(X=$&&i$.isAlias(X)?X.resolve($.doc):X,i$.isSeq(X))for(let z of X.items)x4($,Z,z);else if(Array.isArray(X))for(let z of X)x4($,Z,z);else x4($,Z,X)}function x4($,Z,X){let z=$&&i$.isAlias(X)?X.resolve($.doc):X;if(!i$.isMap(z))throw Error("Merge sources must be maps or map aliases");let q=z.toJSON(null,$,Map);for(let[G,J]of q)if(Z instanceof Map){if(!Z.has(G))Z.set(G,J)}else if(Z instanceof Set)Z.add(G);else if(!Object.prototype.hasOwnProperty.call(Z,G))Object.defineProperty(Z,G,{value:J,writable:!0,enumerable:!0,configurable:!0});return Z}W7.addMergeToJSMap=T6;W7.isMergeKey=U7;W7.merge=c1});var f4=F((F7)=>{var L7=y4(),D6=i1(),T7=l$(),_6=E(),k4=j0();function D7($,Z,{key:X,value:z}){if(_6.isNode(X)&&X.addToJSMap)X.addToJSMap($,Z,z);else if(D6.isMergeKey($,X))D6.addMergeToJSMap($,Z,z);else{let q=k4.toJS(X,"",$);if(Z instanceof Map)Z.set(q,k4.toJS(z,q,$));else if(Z instanceof Set)Z.add(q);else{let G=_7(X,q,$),J=k4.toJS(z,G,$);if(G in Z)Object.defineProperty(Z,G,{value:J,writable:!0,enumerable:!0,configurable:!0});else Z[G]=J}}return Z}function _7($,Z,X){if(Z===null)return"";if(typeof Z!=="object")return String(Z);if(_6.isNode($)&&X?.doc){let z=T7.createStringifyContext(X.doc,{});z.anchors=new Set;for(let G of X.anchors.keys())z.anchors.add(G.anchor);z.inFlow=!0,z.inStringifyKey=!0;let q=$.toString(z);if(!X.mapKeyWarned){let G=JSON.stringify(q);if(G.length>40)G=G.substring(0,36)+'..."';L7.warn(X.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${G}. Set mapAsMap: true to use object keys.`),X.mapKeyWarned=!0}return q}return JSON.stringify(Z)}F7.addPairToJSMap=D7});var S0=F((P7)=>{var F6=u$(),O7=K6(),w7=f4(),a1=E();function I7($,Z,X){let z=F6.createNode($,void 0,X),q=F6.createNode(Z,void 0,X);return new n1(z,q)}class n1{constructor($,Z=null){Object.defineProperty(this,a1.NODE_TYPE,{value:a1.PAIR}),this.key=$,this.value=Z}clone($){let{key:Z,value:X}=this;if(a1.isNode(Z))Z=Z.clone($);if(a1.isNode(X))X=X.clone($);return new n1(Z,X)}toJSON($,Z){let X=Z?.mapAsMap?new Map:{};return w7.addPairToJSMap(Z,X,this)}toString($,Z,X){return $?.doc?O7.stringifyPair(this,$,Z,X):JSON.stringify(this)}}P7.Pair=n1;P7.createPair=I7});var h4=F((C7)=>{var c0=E(),M6=l$(),s1=m$();function A7($,Z,X){return(Z.inFlow??$.flow?S7:N7)($,Z,X)}function N7({comment:$,items:Z},X,{blockItemPrefix:z,flowChars:q,itemIndent:G,onChompKeep:J,onComment:Q}){let{indent:H,options:{commentString:Y}}=X,W=Object.assign({},X,{indent:G,type:null}),U=!1,V=[];for(let T=0;T<Z.length;++T){let K=Z[T],L=null;if(c0.isNode(K)){if(!U&&K.spaceBefore)V.push("");if(r1(X,V,K.commentBefore,U),K.comment)L=K.comment}else if(c0.isPair(K)){let _=c0.isNode(K.key)?K.key:null;if(_){if(!U&&_.spaceBefore)V.push("");r1(X,V,_.commentBefore,U)}}U=!1;let D=M6.stringify(K,W,()=>L=null,()=>U=!0);if(L)D+=s1.lineComment(D,G,Y(L));if(U&&L)U=!1;V.push(z+D)}let B;if(V.length===0)B=q.start+q.end;else{B=V[0];for(let T=1;T<V.length;++T){let K=V[T];B+=K?`
|
|
72
|
+
${H}${K}`:`
|
|
73
73
|
`}}if($){if(B+=`
|
|
74
|
-
`+s1.indentComment(
|
|
75
|
-
`)))
|
|
74
|
+
`+s1.indentComment(Y($),H),Q)Q()}else if(U&&J)J();return B}function S7({items:$},Z,{flowChars:X,itemIndent:z}){let{indent:q,indentStep:G,flowCollectionPadding:J,options:{commentString:Q}}=Z;z+=G;let H=Object.assign({},Z,{indent:z,inFlow:!0,type:null}),Y=!1,W=0,U=[];for(let T=0;T<$.length;++T){let K=$[T],L=null;if(c0.isNode(K)){if(K.spaceBefore)U.push("");if(r1(Z,U,K.commentBefore,!1),K.comment)L=K.comment}else if(c0.isPair(K)){let _=c0.isNode(K.key)?K.key:null;if(_){if(_.spaceBefore)U.push("");if(r1(Z,U,_.commentBefore,!1),_.comment)Y=!0}let M=c0.isNode(K.value)?K.value:null;if(M){if(M.comment)L=M.comment;if(M.commentBefore)Y=!0}else if(K.value==null&&_?.comment)L=_.comment}if(L)Y=!0;let D=M6.stringify(K,H,()=>L=null);if(T<$.length-1)D+=",";if(L)D+=s1.lineComment(D,z,Q(L));if(!Y&&(U.length>W||D.includes(`
|
|
75
|
+
`)))Y=!0;U.push(D),W=U.length}let{start:V,end:B}=X;if(U.length===0)return V+B;else{if(!Y){let T=U.reduce((K,L)=>K+L.length+2,2);Y=Z.options.lineWidth>0&&T>Z.options.lineWidth}if(Y){let T=V;for(let K of U)T+=K?`
|
|
76
76
|
${G}${q}${K}`:`
|
|
77
77
|
`;return`${T}
|
|
78
|
-
${q}${B}`}else return`${V}${J}${U.join(" ")}${J}${B}`}}function r1({indent:$,options:{commentString:Z}},X,z,q){if(z&&q)z=z.replace(/^\n+/,"");if(z){let G=s1.indentComment(Z(z),$);X.push(G.trimStart())}}
|
|
79
|
-
`:" ")}return
|
|
78
|
+
${q}${B}`}else return`${V}${J}${U.join(" ")}${J}${B}`}}function r1({indent:$,options:{commentString:Z}},X,z,q){if(z&&q)z=z.replace(/^\n+/,"");if(z){let G=s1.indentComment(Z(z),$);X.push(G.trimStart())}}C7.stringifyCollection=A7});var E0=F((f7)=>{var b7=h4(),y7=f4(),x7=u1(),C0=E(),o1=S0(),k7=g();function a$($,Z){let X=C0.isScalar(Z)?Z.value:Z;for(let z of $)if(C0.isPair(z)){if(z.key===Z||z.key===X)return z;if(C0.isScalar(z.key)&&z.key.value===X)return z}return}class O6 extends x7.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor($){super(C0.MAP,$);this.items=[]}static from($,Z,X){let{keepUndefined:z,replacer:q}=X,G=new this($),J=(Q,H)=>{if(typeof q==="function")H=q.call(Z,Q,H);else if(Array.isArray(q)&&!q.includes(Q))return;if(H!==void 0||z)G.items.push(o1.createPair(Q,H,X))};if(Z instanceof Map)for(let[Q,H]of Z)J(Q,H);else if(Z&&typeof Z==="object")for(let Q of Object.keys(Z))J(Q,Z[Q]);if(typeof $.sortMapEntries==="function")G.items.sort($.sortMapEntries);return G}add($,Z){let X;if(C0.isPair($))X=$;else if(!$||typeof $!=="object"||!("key"in $))X=new o1.Pair($,$?.value);else X=new o1.Pair($.key,$.value);let z=a$(this.items,X.key),q=this.schema?.sortMapEntries;if(z){if(!Z)throw Error(`Key ${X.key} already set`);if(C0.isScalar(z.value)&&k7.isScalarValue(X.value))z.value.value=X.value;else z.value=X.value}else if(q){let G=this.items.findIndex((J)=>q(X,J)<0);if(G===-1)this.items.push(X);else this.items.splice(G,0,X)}else this.items.push(X)}delete($){let Z=a$(this.items,$);if(!Z)return!1;return this.items.splice(this.items.indexOf(Z),1).length>0}get($,Z){let z=a$(this.items,$)?.value;return(!Z&&C0.isScalar(z)?z.value:z)??void 0}has($){return!!a$(this.items,$)}set($,Z){this.add(new o1.Pair($,Z),!0)}toJSON($,Z,X){let z=X?new X:Z?.mapAsMap?new Map:{};if(Z?.onCreate)Z.onCreate(z);for(let q of this.items)y7.addPairToJSMap(Z,z,q);return z}toString($,Z,X){if(!$)return JSON.stringify(this);for(let z of this.items)if(!C0.isPair(z))throw Error(`Map items must all be pairs; found ${JSON.stringify(z)} instead`);if(!$.allNullValues&&this.hasAllNullValues(!1))$=Object.assign({},$,{allNullValues:!0});return b7.stringifyCollection(this,$,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:$.indent||"",onChompKeep:X,onComment:Z})}}f7.YAMLMap=O6;f7.findPair=a$});var Q$=F((m7)=>{var v7=E(),w6=E0(),u7={collection:"map",default:!0,nodeClass:w6.YAMLMap,tag:"tag:yaml.org,2002:map",resolve($,Z){if(!v7.isMap($))Z("Expected a mapping for this tag");return $},createNode:($,Z,X)=>w6.YAMLMap.from($,Z,X)};m7.map=u7});var b0=F((n7)=>{var p7=u$(),l7=h4(),c7=u1(),e1=E(),i7=g(),a7=j0();class I6 extends c7.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor($){super(e1.SEQ,$);this.items=[]}add($){this.items.push($)}delete($){let Z=t1($);if(typeof Z!=="number")return!1;return this.items.splice(Z,1).length>0}get($,Z){let X=t1($);if(typeof X!=="number")return;let z=this.items[X];return!Z&&e1.isScalar(z)?z.value:z}has($){let Z=t1($);return typeof Z==="number"&&Z<this.items.length}set($,Z){let X=t1($);if(typeof X!=="number")throw Error(`Expected a valid index, not ${$}.`);let z=this.items[X];if(e1.isScalar(z)&&i7.isScalarValue(Z))z.value=Z;else this.items[X]=Z}toJSON($,Z){let X=[];if(Z?.onCreate)Z.onCreate(X);let z=0;for(let q of this.items)X.push(a7.toJS(q,String(z++),Z));return X}toString($,Z,X){if(!$)return JSON.stringify(this);return l7.stringifyCollection(this,$,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:($.indent||"")+" ",onChompKeep:X,onComment:Z})}static from($,Z,X){let{replacer:z}=X,q=new this($);if(Z&&Symbol.iterator in Object(Z)){let G=0;for(let J of Z){if(typeof z==="function"){let Q=Z instanceof Set?J:String(G++);J=z.call(Z,Q,J)}q.items.push(p7.createNode(J,void 0,X))}}return q}}function t1($){let Z=e1.isScalar($)?$.value:$;if(Z&&typeof Z==="string")Z=Number(Z);return typeof Z==="number"&&Number.isInteger(Z)&&Z>=0?Z:null}n7.YAMLSeq=I6});var Y$=F((t7)=>{var r7=E(),P6=b0(),o7={collection:"seq",default:!0,nodeClass:P6.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve($,Z){if(!r7.isSeq($))Z("Expected a sequence for this tag");return $},createNode:($,Z,X)=>P6.YAMLSeq.from($,Z,X)};t7.seq=o7});var n$=F((Xq)=>{var $q=p$(),Zq={identify:($)=>typeof $==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:($)=>$,stringify($,Z,X,z){return Z=Object.assign({actualString:!0},Z),$q.stringifyString($,Z,X,z)}};Xq.string=Zq});var $2=F((qq)=>{var R6=g(),j6={identify:($)=>$==null,createNode:()=>new R6.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new R6.Scalar(null),stringify:({source:$},Z)=>typeof $==="string"&&j6.test.test($)?$:Z.options.nullStr};qq.nullTag=j6});var g4=F((Qq)=>{var Jq=g(),A6={identify:($)=>typeof $==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:($)=>new Jq.Scalar($[0]==="t"||$[0]==="T"),stringify({source:$,value:Z},X){if($&&A6.test.test($)){let z=$[0]==="t"||$[0]==="T";if(Z===z)return $}return Z?X.options.trueStr:X.options.falseStr}};Qq.boolTag=A6});var H$=F((Uq)=>{function Hq({format:$,minFractionDigits:Z,tag:X,value:z}){if(typeof z==="bigint")return String(z);let q=typeof z==="number"?z:Number(z);if(!isFinite(q))return isNaN(q)?".nan":q<0?"-.inf":".inf";let G=Object.is(z,-0)?"-0":JSON.stringify(z);if(!$&&Z&&(!X||X==="tag:yaml.org,2002:float")&&/^\d/.test(G)){let J=G.indexOf(".");if(J<0)J=G.length,G+=".";let Q=Z-(G.length-J-1);while(Q-- >0)G+="0"}return G}Uq.stringifyNumber=Hq});var u4=F((Tq)=>{var Vq=g(),v4=H$(),Kq={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:v4.stringifyNumber},Bq={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($),stringify($){let Z=Number($.value);return isFinite(Z)?Z.toExponential():v4.stringifyNumber($)}},Lq={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve($){let Z=new Vq.Scalar(parseFloat($)),X=$.indexOf(".");if(X!==-1&&$[$.length-1]==="0")Z.minFractionDigits=$.length-X-1;return Z},stringify:v4.stringifyNumber};Tq.float=Lq;Tq.floatExp=Bq;Tq.floatNaN=Kq});var d4=F((Iq)=>{var N6=H$(),Z2=($)=>typeof $==="bigint"||Number.isInteger($),m4=($,Z,X,{intAsBigInt:z})=>z?BigInt($):parseInt($.substring(Z),X);function S6($,Z,X){let{value:z}=$;if(Z2(z)&&z>=0)return X+z.toString(Z);return N6.stringifyNumber($)}var Mq={identify:($)=>Z2($)&&$>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:($,Z,X)=>m4($,2,8,X),stringify:($)=>S6($,8,"0o")},Oq={identify:Z2,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:($,Z,X)=>m4($,0,10,X),stringify:N6.stringifyNumber},wq={identify:($)=>Z2($)&&$>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:($,Z,X)=>m4($,2,16,X),stringify:($)=>S6($,16,"0x")};Iq.int=Oq;Iq.intHex=wq;Iq.intOct=Mq});var C6=F((yq)=>{var Aq=Q$(),Nq=$2(),Sq=Y$(),Cq=n$(),Eq=g4(),p4=u4(),l4=d4(),bq=[Aq.map,Sq.seq,Cq.string,Nq.nullTag,Eq.boolTag,l4.intOct,l4.int,l4.intHex,p4.floatNaN,p4.floatExp,p4.float];yq.schema=bq});var b6=F((mq)=>{var kq=g(),fq=Q$(),hq=Y$();function E6($){return typeof $==="bigint"||Number.isInteger($)}var X2=({value:$})=>JSON.stringify($),gq=[{identify:($)=>typeof $==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:($)=>$,stringify:X2},{identify:($)=>$==null,createNode:()=>new kq.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:X2},{identify:($)=>typeof $==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:($)=>$==="true",stringify:X2},{identify:E6,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:($,Z,{intAsBigInt:X})=>X?BigInt($):parseInt($,10),stringify:({value:$})=>E6($)?$.toString():JSON.stringify($)},{identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:($)=>parseFloat($),stringify:X2}],vq={default:!0,tag:"",test:/^/,resolve($,Z){return Z(`Unresolved plain scalar ${JSON.stringify($)}`),$}},uq=[fq.map,hq.seq].concat(gq,vq);mq.schema=uq});var i4=F((cq)=>{var s$=B0("buffer"),c4=g(),pq=p$(),lq={identify:($)=>$ instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve($,Z){if(typeof s$.Buffer==="function")return s$.Buffer.from($,"base64");else if(typeof atob==="function"){let X=atob($.replace(/[\n\r]/g,"")),z=new Uint8Array(X.length);for(let q=0;q<X.length;++q)z[q]=X.charCodeAt(q);return z}else return Z("This environment does not support reading binary tags; either Buffer or atob is required"),$},stringify({comment:$,type:Z,value:X},z,q,G){if(!X)return"";let J=X,Q;if(typeof s$.Buffer==="function")Q=J instanceof s$.Buffer?J.toString("base64"):s$.Buffer.from(J.buffer).toString("base64");else if(typeof btoa==="function"){let H="";for(let Y=0;Y<J.length;++Y)H+=String.fromCharCode(J[Y]);Q=btoa(H)}else throw Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(Z??(Z=c4.Scalar.BLOCK_LITERAL),Z!==c4.Scalar.QUOTE_DOUBLE){let H=Math.max(z.options.lineWidth-z.indent.length,z.options.minContentWidth),Y=Math.ceil(Q.length/H),W=Array(Y);for(let U=0,V=0;U<Y;++U,V+=H)W[U]=Q.substr(V,H);Q=W.join(Z===c4.Scalar.BLOCK_LITERAL?`
|
|
79
|
+
`:" ")}return pq.stringifyString({comment:$,type:Z,value:Q},z,q,G)}};cq.binary=lq});var q2=F((rq)=>{var z2=E(),a4=S0(),aq=g(),nq=b0();function y6($,Z){if(z2.isSeq($))for(let X=0;X<$.items.length;++X){let z=$.items[X];if(z2.isPair(z))continue;else if(z2.isMap(z)){if(z.items.length>1)Z("Each pair must have its own sequence indicator");let q=z.items[0]||new a4.Pair(new aq.Scalar(null));if(z.commentBefore)q.key.commentBefore=q.key.commentBefore?`${z.commentBefore}
|
|
80
80
|
${q.key.commentBefore}`:z.commentBefore;if(z.comment){let G=q.value??q.key;G.comment=G.comment?`${z.comment}
|
|
81
|
-
${G.comment}`:z.comment}z=q}$.items[X]=z2.isPair(z)?z:new i4.Pair(z)}else Z("Expected a sequence for this tag");return $}function b6($,Z,X){let{replacer:z}=X,q=new iq.YAMLSeq($);q.tag="tag:yaml.org,2002:pairs";let G=0;if(Z&&Symbol.iterator in Object(Z))for(let J of Z){if(typeof z==="function")J=z.call(Z,String(G++),J);let Q,Y;if(Array.isArray(J))if(J.length===2)Q=J[0],Y=J[1];else throw TypeError(`Expected [key, value] tuple: ${J}`);else if(J&&J instanceof Object){let H=Object.keys(J);if(H.length===1)Q=H[0],Y=J[Q];else throw TypeError(`Expected tuple with one key, not ${H.length} keys`)}else Q=J;q.items.push(i4.createPair(Q,Y,X))}return q}var aq={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:E6,createNode:b6};nq.createPairs=b6;nq.pairs=aq;nq.resolvePairs=E6});var n4=F(($G)=>{var y6=E(),a4=R0(),r$=C0(),tq=E0(),x6=q2();class c0 extends tq.YAMLSeq{constructor(){super();this.add=r$.YAMLMap.prototype.add.bind(this),this.delete=r$.YAMLMap.prototype.delete.bind(this),this.get=r$.YAMLMap.prototype.get.bind(this),this.has=r$.YAMLMap.prototype.has.bind(this),this.set=r$.YAMLMap.prototype.set.bind(this),this.tag=c0.tag}toJSON($,Z){if(!Z)return super.toJSON($);let X=new Map;if(Z?.onCreate)Z.onCreate(X);for(let z of this.items){let q,G;if(y6.isPair(z))q=a4.toJS(z.key,"",Z),G=a4.toJS(z.value,q,Z);else q=a4.toJS(z,"",Z);if(X.has(q))throw Error("Ordered maps must not include duplicate keys");X.set(q,G)}return X}static from($,Z,X){let z=x6.createPairs($,Z,X),q=new this;return q.items=z.items,q}}c0.tag="tag:yaml.org,2002:omap";var eq={collection:"seq",identify:($)=>$ instanceof Map,nodeClass:c0,default:!1,tag:"tag:yaml.org,2002:omap",resolve($,Z){let X=x6.resolvePairs($,Z),z=[];for(let{key:q}of X.items)if(y6.isScalar(q))if(z.includes(q.value))Z(`Ordered maps must not include duplicate keys: ${q.value}`);else z.push(q.value);return Object.assign(new c0,X)},createNode:($,Z,X)=>c0.from($,Z,X)};$G.YAMLOMap=c0;$G.omap=eq});var v6=F((zG)=>{var k6=g();function f6({value:$,source:Z},X){if(Z&&($?h6:g6).test.test(Z))return Z;return $?X.options.trueStr:X.options.falseStr}var h6={identify:($)=>$===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new k6.Scalar(!0),stringify:f6},g6={identify:($)=>$===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new k6.Scalar(!1),stringify:f6};zG.falseTag=g6;zG.trueTag=h6});var u6=F((UG)=>{var JG=g(),s4=Y$(),QG={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:s4.stringifyNumber},YG={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 Z=Number($.value);return isFinite(Z)?Z.toExponential():s4.stringifyNumber($)}},HG={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve($){let Z=new JG.Scalar(parseFloat($.replace(/_/g,""))),X=$.indexOf(".");if(X!==-1){let z=$.substring(X+1).replace(/_/g,"");if(z[z.length-1]==="0")Z.minFractionDigits=z.length}return Z},stringify:s4.stringifyNumber};UG.float=HG;UG.floatExp=YG;UG.floatNaN=QG});var d6=F((_G)=>{var m6=Y$(),o$=($)=>typeof $==="bigint"||Number.isInteger($);function G2($,Z,X,{intAsBigInt:z}){let q=$[0];if(q==="-"||q==="+")Z+=1;if($=$.substring(Z).replace(/_/g,""),z){switch(X){case 2:$=`0b${$}`;break;case 8:$=`0o${$}`;break;case 16:$=`0x${$}`;break}let J=BigInt($);return q==="-"?BigInt(-1)*J:J}let G=parseInt($,X);return q==="-"?-1*G:G}function r4($,Z,X){let{value:z}=$;if(o$(z)){let q=z.toString(Z);return z<0?"-"+X+q.substr(1):X+q}return m6.stringifyNumber($)}var BG={identify:o$,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:($,Z,X)=>G2($,2,2,X),stringify:($)=>r4($,2,"0b")},LG={identify:o$,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:($,Z,X)=>G2($,1,8,X),stringify:($)=>r4($,8,"0")},TG={identify:o$,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:($,Z,X)=>G2($,0,10,X),stringify:m6.stringifyNumber},DG={identify:o$,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:($,Z,X)=>G2($,2,16,X),stringify:($)=>r4($,16,"0x")};_G.int=TG;_G.intBin=BG;_G.intHex=DG;_G.intOct=LG});var o4=F((IG)=>{var Y2=E(),J2=N0(),Q2=C0();class i0 extends Q2.YAMLMap{constructor($){super($);this.tag=i0.tag}add($){let Z;if(Y2.isPair($))Z=$;else if($&&typeof $==="object"&&"key"in $&&"value"in $&&$.value===null)Z=new J2.Pair($.key,null);else Z=new J2.Pair($,null);if(!Q2.findPair(this.items,Z.key))this.items.push(Z)}get($,Z){let X=Q2.findPair(this.items,$);return!Z&&Y2.isPair(X)?Y2.isScalar(X.key)?X.key.value:X.key:X}set($,Z){if(typeof Z!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof Z}`);let X=Q2.findPair(this.items,$);if(X&&!Z)this.items.splice(this.items.indexOf(X),1);else if(!X&&Z)this.items.push(new J2.Pair($))}toJSON($,Z){return super.toJSON($,Z,Set)}toString($,Z,X){if(!$)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},$,{allNullValues:!0}),Z,X);else throw Error("Set items must all have null values")}static from($,Z,X){let{replacer:z}=X,q=new this($);if(Z&&Symbol.iterator in Object(Z))for(let G of Z){if(typeof z==="function")G=z.call(Z,G,G);q.items.push(J2.createPair(G,null,X))}return q}}i0.tag="tag:yaml.org,2002:set";var PG={collection:"map",identify:($)=>$ instanceof Set,nodeClass:i0,default:!1,tag:"tag:yaml.org,2002:set",createNode:($,Z,X)=>i0.from($,Z,X),resolve($,Z){if(Y2.isMap($))if($.hasAllNullValues(!0))return Object.assign(new i0,$);else Z("Set items must all have null values");else Z("Expected a mapping for this tag");return $}};IG.YAMLSet=i0;IG.set=PG});var e4=F((CG)=>{var jG=Y$();function t4($,Z){let X=$[0],z=X==="-"||X==="+"?$.substring(1):$,q=(J)=>Z?BigInt(J):Number(J),G=z.replace(/_/g,"").split(":").reduce((J,Q)=>J*q(60)+q(Q),q(0));return X==="-"?q(-1)*G:G}function p6($){let{value:Z}=$,X=(J)=>J;if(typeof Z==="bigint")X=(J)=>BigInt(J);else if(isNaN(Z)||!isFinite(Z))return jG.stringifyNumber($);let z="";if(Z<0)z="-",Z*=X(-1);let q=X(60),G=[Z%q];if(Z<60)G.unshift(0);else if(Z=(Z-G[0])/q,G.unshift(Z%q),Z>=60)Z=(Z-G[0])/q,G.unshift(Z);return z+G.map((J)=>String(J).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var NG={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:($,Z,{intAsBigInt:X})=>t4($,X),stringify:p6},SG={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:($)=>t4($,!1),stringify:p6},l6={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 Z=$.match(l6.test);if(!Z)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,X,z,q,G,J,Q]=Z.map(Number),Y=Z[7]?Number((Z[7]+"00").substr(1,3)):0,H=Date.UTC(X,z-1,q,G||0,J||0,Q||0,Y),W=Z[8];if(W&&W!=="Z"){let U=t4(W,!1);if(Math.abs(U)<30)U*=60;H-=60000*U}return new Date(H)},stringify:({value:$})=>$?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};CG.floatTime=SG;CG.intTime=NG;CG.timestamp=l6});var i6=F((lG)=>{var xG=J$(),kG=$2(),fG=Q$(),hG=n$(),gG=c4(),c6=v6(),$9=u6(),H2=d6(),vG=i1(),uG=n4(),mG=q2(),dG=o4(),Z9=e4(),pG=[xG.map,fG.seq,hG.string,kG.nullTag,c6.trueTag,c6.falseTag,H2.intBin,H2.intOct,H2.int,H2.intHex,$9.floatNaN,$9.floatExp,$9.float,gG.binary,vG.merge,uG.omap,mG.pairs,dG.set,Z9.intTime,Z9.floatTime,Z9.timestamp];lG.schema=pG});var X8=F((eG)=>{var r6=J$(),iG=$2(),o6=Q$(),aG=n$(),nG=h4(),X9=v4(),z9=m4(),sG=N6(),rG=C6(),t6=c4(),t$=i1(),e6=n4(),$8=q2(),a6=i6(),Z8=o4(),U2=e4(),n6=new Map([["core",sG.schema],["failsafe",[r6.map,o6.seq,aG.string]],["json",rG.schema],["yaml11",a6.schema],["yaml-1.1",a6.schema]]),s6={binary:t6.binary,bool:nG.boolTag,float:X9.float,floatExp:X9.floatExp,floatNaN:X9.floatNaN,floatTime:U2.floatTime,int:z9.int,intHex:z9.intHex,intOct:z9.intOct,intTime:U2.intTime,map:r6.map,merge:t$.merge,null:iG.nullTag,omap:e6.omap,pairs:$8.pairs,seq:o6.seq,set:Z8.set,timestamp:U2.timestamp},oG={"tag:yaml.org,2002:binary":t6.binary,"tag:yaml.org,2002:merge":t$.merge,"tag:yaml.org,2002:omap":e6.omap,"tag:yaml.org,2002:pairs":$8.pairs,"tag:yaml.org,2002:set":Z8.set,"tag:yaml.org,2002:timestamp":U2.timestamp};function tG($,Z,X){let z=n6.get(Z);if(z&&!$)return X&&!z.includes(t$.merge)?z.concat(t$.merge):z.slice();let q=z;if(!q)if(Array.isArray($))q=[];else{let G=Array.from(n6.keys()).filter((J)=>J!=="yaml11").map((J)=>JSON.stringify(J)).join(", ");throw Error(`Unknown schema "${Z}"; use one of ${G} or define customTags array`)}if(Array.isArray($))for(let G of $)q=q.concat(G);else if(typeof $==="function")q=$(q.slice());if(X)q=q.concat(t$.merge);return q.reduce((G,J)=>{let Q=typeof J==="string"?s6[J]:J;if(!Q){let Y=JSON.stringify(J),H=Object.keys(s6).map((W)=>JSON.stringify(W)).join(", ");throw Error(`Unknown custom tag ${Y}; use one of ${H}`)}if(!G.includes(Q))G.push(Q);return G},[])}eG.coreKnownTags=oG;eG.getTags=tG});var J9=F((JJ)=>{var q9=E(),XJ=J$(),zJ=Q$(),qJ=n$(),W2=X8(),GJ=($,Z)=>$.key<Z.key?-1:$.key>Z.key?1:0;class G9{constructor({compat:$,customTags:Z,merge:X,resolveKnownTags:z,schema:q,sortMapEntries:G,toStringDefaults:J}){this.compat=Array.isArray($)?W2.getTags($,"compat"):$?W2.getTags(null,$):null,this.name=typeof q==="string"&&q||"core",this.knownTags=z?W2.coreKnownTags:{},this.tags=W2.getTags(Z,this.name,X),this.toStringOptions=J??null,Object.defineProperty(this,q9.MAP,{value:XJ.map}),Object.defineProperty(this,q9.SCALAR,{value:qJ.string}),Object.defineProperty(this,q9.SEQ,{value:zJ.seq}),this.sortMapEntries=typeof G==="function"?G:G===!0?GJ:null}clone(){let $=Object.create(G9.prototype,Object.getOwnPropertyDescriptors(this));return $.tags=this.tags.slice(),$}}JJ.Schema=G9});var z8=F((UJ)=>{var YJ=E(),Q9=l$(),e$=m$();function HJ($,Z){let X=[],z=Z.directives===!0;if(Z.directives!==!1&&$.directives){let Y=$.directives.toString($);if(Y)X.push(Y),z=!0;else if($.directives.docStart)z=!0}if(z)X.push("---");let q=Q9.createStringifyContext($,Z),{commentString:G}=q.options;if($.commentBefore){if(X.length!==1)X.unshift("");let Y=G($.commentBefore);X.unshift(e$.indentComment(Y,""))}let J=!1,Q=null;if($.contents){if(YJ.isNode($.contents)){if($.contents.spaceBefore&&z)X.push("");if($.contents.commentBefore){let W=G($.contents.commentBefore);X.push(e$.indentComment(W,""))}q.forceBlockIndent=!!$.comment,Q=$.contents.comment}let Y=Q?void 0:()=>J=!0,H=Q9.stringify($.contents,q,()=>Q=null,Y);if(Q)H+=e$.lineComment(H,"",G(Q));if((H[0]==="|"||H[0]===">")&&X[X.length-1]==="---")X[X.length-1]=`--- ${H}`;else X.push(H)}else X.push(Q9.stringify($.contents,q));if($.directives?.docEnd)if($.comment){let Y=G($.comment);if(Y.includes(`
|
|
82
|
-
`))X.push("..."),X.push(e$.indentComment(
|
|
81
|
+
${G.comment}`:z.comment}z=q}$.items[X]=z2.isPair(z)?z:new a4.Pair(z)}else Z("Expected a sequence for this tag");return $}function x6($,Z,X){let{replacer:z}=X,q=new nq.YAMLSeq($);q.tag="tag:yaml.org,2002:pairs";let G=0;if(Z&&Symbol.iterator in Object(Z))for(let J of Z){if(typeof z==="function")J=z.call(Z,String(G++),J);let Q,H;if(Array.isArray(J))if(J.length===2)Q=J[0],H=J[1];else throw TypeError(`Expected [key, value] tuple: ${J}`);else if(J&&J instanceof Object){let Y=Object.keys(J);if(Y.length===1)Q=Y[0],H=J[Q];else throw TypeError(`Expected tuple with one key, not ${Y.length} keys`)}else Q=J;q.items.push(a4.createPair(Q,H,X))}return q}var sq={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:y6,createNode:x6};rq.createPairs=x6;rq.pairs=sq;rq.resolvePairs=y6});var s4=F((XG)=>{var k6=E(),n4=j0(),r$=E0(),$G=b0(),f6=q2();class i0 extends $G.YAMLSeq{constructor(){super();this.add=r$.YAMLMap.prototype.add.bind(this),this.delete=r$.YAMLMap.prototype.delete.bind(this),this.get=r$.YAMLMap.prototype.get.bind(this),this.has=r$.YAMLMap.prototype.has.bind(this),this.set=r$.YAMLMap.prototype.set.bind(this),this.tag=i0.tag}toJSON($,Z){if(!Z)return super.toJSON($);let X=new Map;if(Z?.onCreate)Z.onCreate(X);for(let z of this.items){let q,G;if(k6.isPair(z))q=n4.toJS(z.key,"",Z),G=n4.toJS(z.value,q,Z);else q=n4.toJS(z,"",Z);if(X.has(q))throw Error("Ordered maps must not include duplicate keys");X.set(q,G)}return X}static from($,Z,X){let z=f6.createPairs($,Z,X),q=new this;return q.items=z.items,q}}i0.tag="tag:yaml.org,2002:omap";var ZG={collection:"seq",identify:($)=>$ instanceof Map,nodeClass:i0,default:!1,tag:"tag:yaml.org,2002:omap",resolve($,Z){let X=f6.resolvePairs($,Z),z=[];for(let{key:q}of X.items)if(k6.isScalar(q))if(z.includes(q.value))Z(`Ordered maps must not include duplicate keys: ${q.value}`);else z.push(q.value);return Object.assign(new i0,X)},createNode:($,Z,X)=>i0.from($,Z,X)};XG.YAMLOMap=i0;XG.omap=ZG});var m6=F((GG)=>{var h6=g();function g6({value:$,source:Z},X){if(Z&&($?v6:u6).test.test(Z))return Z;return $?X.options.trueStr:X.options.falseStr}var v6={identify:($)=>$===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new h6.Scalar(!0),stringify:g6},u6={identify:($)=>$===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new h6.Scalar(!1),stringify:g6};GG.falseTag=u6;GG.trueTag=v6});var d6=F((VG)=>{var YG=g(),r4=H$(),HG={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:r4.stringifyNumber},UG={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 Z=Number($.value);return isFinite(Z)?Z.toExponential():r4.stringifyNumber($)}},WG={identify:($)=>typeof $==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve($){let Z=new YG.Scalar(parseFloat($.replace(/_/g,""))),X=$.indexOf(".");if(X!==-1){let z=$.substring(X+1).replace(/_/g,"");if(z[z.length-1]==="0")Z.minFractionDigits=z.length}return Z},stringify:r4.stringifyNumber};VG.float=WG;VG.floatExp=UG;VG.floatNaN=HG});var l6=F((MG)=>{var p6=H$(),o$=($)=>typeof $==="bigint"||Number.isInteger($);function G2($,Z,X,{intAsBigInt:z}){let q=$[0];if(q==="-"||q==="+")Z+=1;if($=$.substring(Z).replace(/_/g,""),z){switch(X){case 2:$=`0b${$}`;break;case 8:$=`0o${$}`;break;case 16:$=`0x${$}`;break}let J=BigInt($);return q==="-"?BigInt(-1)*J:J}let G=parseInt($,X);return q==="-"?-1*G:G}function o4($,Z,X){let{value:z}=$;if(o$(z)){let q=z.toString(Z);return z<0?"-"+X+q.substr(1):X+q}return p6.stringifyNumber($)}var TG={identify:o$,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:($,Z,X)=>G2($,2,2,X),stringify:($)=>o4($,2,"0b")},DG={identify:o$,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:($,Z,X)=>G2($,1,8,X),stringify:($)=>o4($,8,"0")},_G={identify:o$,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:($,Z,X)=>G2($,0,10,X),stringify:p6.stringifyNumber},FG={identify:o$,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:($,Z,X)=>G2($,2,16,X),stringify:($)=>o4($,16,"0x")};MG.int=_G;MG.intBin=TG;MG.intHex=FG;MG.intOct=DG});var t4=F((jG)=>{var Y2=E(),J2=S0(),Q2=E0();class a0 extends Q2.YAMLMap{constructor($){super($);this.tag=a0.tag}add($){let Z;if(Y2.isPair($))Z=$;else if($&&typeof $==="object"&&"key"in $&&"value"in $&&$.value===null)Z=new J2.Pair($.key,null);else Z=new J2.Pair($,null);if(!Q2.findPair(this.items,Z.key))this.items.push(Z)}get($,Z){let X=Q2.findPair(this.items,$);return!Z&&Y2.isPair(X)?Y2.isScalar(X.key)?X.key.value:X.key:X}set($,Z){if(typeof Z!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof Z}`);let X=Q2.findPair(this.items,$);if(X&&!Z)this.items.splice(this.items.indexOf(X),1);else if(!X&&Z)this.items.push(new J2.Pair($))}toJSON($,Z){return super.toJSON($,Z,Set)}toString($,Z,X){if(!$)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},$,{allNullValues:!0}),Z,X);else throw Error("Set items must all have null values")}static from($,Z,X){let{replacer:z}=X,q=new this($);if(Z&&Symbol.iterator in Object(Z))for(let G of Z){if(typeof z==="function")G=z.call(Z,G,G);q.items.push(J2.createPair(G,null,X))}return q}}a0.tag="tag:yaml.org,2002:set";var RG={collection:"map",identify:($)=>$ instanceof Set,nodeClass:a0,default:!1,tag:"tag:yaml.org,2002:set",createNode:($,Z,X)=>a0.from($,Z,X),resolve($,Z){if(Y2.isMap($))if($.hasAllNullValues(!0))return Object.assign(new a0,$);else Z("Set items must all have null values");else Z("Expected a mapping for this tag");return $}};jG.YAMLSet=a0;jG.set=RG});var $9=F((bG)=>{var SG=H$();function e4($,Z){let X=$[0],z=X==="-"||X==="+"?$.substring(1):$,q=(J)=>Z?BigInt(J):Number(J),G=z.replace(/_/g,"").split(":").reduce((J,Q)=>J*q(60)+q(Q),q(0));return X==="-"?q(-1)*G:G}function c6($){let{value:Z}=$,X=(J)=>J;if(typeof Z==="bigint")X=(J)=>BigInt(J);else if(isNaN(Z)||!isFinite(Z))return SG.stringifyNumber($);let z="";if(Z<0)z="-",Z*=X(-1);let q=X(60),G=[Z%q];if(Z<60)G.unshift(0);else if(Z=(Z-G[0])/q,G.unshift(Z%q),Z>=60)Z=(Z-G[0])/q,G.unshift(Z);return z+G.map((J)=>String(J).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var CG={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:($,Z,{intAsBigInt:X})=>e4($,X),stringify:c6},EG={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:($)=>e4($,!1),stringify:c6},i6={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 Z=$.match(i6.test);if(!Z)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,X,z,q,G,J,Q]=Z.map(Number),H=Z[7]?Number((Z[7]+"00").substr(1,3)):0,Y=Date.UTC(X,z-1,q,G||0,J||0,Q||0,H),W=Z[8];if(W&&W!=="Z"){let U=e4(W,!1);if(Math.abs(U)<30)U*=60;Y-=60000*U}return new Date(Y)},stringify:({value:$})=>$?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};bG.floatTime=EG;bG.intTime=CG;bG.timestamp=i6});var n6=F((iG)=>{var fG=Q$(),hG=$2(),gG=Y$(),vG=n$(),uG=i4(),a6=m6(),Z9=d6(),H2=l6(),mG=i1(),dG=s4(),pG=q2(),lG=t4(),X9=$9(),cG=[fG.map,gG.seq,vG.string,hG.nullTag,a6.trueTag,a6.falseTag,H2.intBin,H2.intOct,H2.int,H2.intHex,Z9.floatNaN,Z9.floatExp,Z9.float,uG.binary,mG.merge,dG.omap,pG.pairs,lG.set,X9.intTime,X9.floatTime,X9.timestamp];iG.schema=cG});var q8=F((ZJ)=>{var t6=Q$(),nG=$2(),e6=Y$(),sG=n$(),rG=g4(),z9=u4(),q9=d4(),oG=C6(),tG=b6(),$8=i4(),t$=i1(),Z8=s4(),X8=q2(),s6=n6(),z8=t4(),U2=$9(),r6=new Map([["core",oG.schema],["failsafe",[t6.map,e6.seq,sG.string]],["json",tG.schema],["yaml11",s6.schema],["yaml-1.1",s6.schema]]),o6={binary:$8.binary,bool:rG.boolTag,float:z9.float,floatExp:z9.floatExp,floatNaN:z9.floatNaN,floatTime:U2.floatTime,int:q9.int,intHex:q9.intHex,intOct:q9.intOct,intTime:U2.intTime,map:t6.map,merge:t$.merge,null:nG.nullTag,omap:Z8.omap,pairs:X8.pairs,seq:e6.seq,set:z8.set,timestamp:U2.timestamp},eG={"tag:yaml.org,2002:binary":$8.binary,"tag:yaml.org,2002:merge":t$.merge,"tag:yaml.org,2002:omap":Z8.omap,"tag:yaml.org,2002:pairs":X8.pairs,"tag:yaml.org,2002:set":z8.set,"tag:yaml.org,2002:timestamp":U2.timestamp};function $J($,Z,X){let z=r6.get(Z);if(z&&!$)return X&&!z.includes(t$.merge)?z.concat(t$.merge):z.slice();let q=z;if(!q)if(Array.isArray($))q=[];else{let G=Array.from(r6.keys()).filter((J)=>J!=="yaml11").map((J)=>JSON.stringify(J)).join(", ");throw Error(`Unknown schema "${Z}"; use one of ${G} or define customTags array`)}if(Array.isArray($))for(let G of $)q=q.concat(G);else if(typeof $==="function")q=$(q.slice());if(X)q=q.concat(t$.merge);return q.reduce((G,J)=>{let Q=typeof J==="string"?o6[J]:J;if(!Q){let H=JSON.stringify(J),Y=Object.keys(o6).map((W)=>JSON.stringify(W)).join(", ");throw Error(`Unknown custom tag ${H}; use one of ${Y}`)}if(!G.includes(Q))G.push(Q);return G},[])}ZJ.coreKnownTags=eG;ZJ.getTags=$J});var Q9=F((YJ)=>{var G9=E(),qJ=Q$(),GJ=Y$(),JJ=n$(),W2=q8(),QJ=($,Z)=>$.key<Z.key?-1:$.key>Z.key?1:0;class J9{constructor({compat:$,customTags:Z,merge:X,resolveKnownTags:z,schema:q,sortMapEntries:G,toStringDefaults:J}){this.compat=Array.isArray($)?W2.getTags($,"compat"):$?W2.getTags(null,$):null,this.name=typeof q==="string"&&q||"core",this.knownTags=z?W2.coreKnownTags:{},this.tags=W2.getTags(Z,this.name,X),this.toStringOptions=J??null,Object.defineProperty(this,G9.MAP,{value:qJ.map}),Object.defineProperty(this,G9.SCALAR,{value:JJ.string}),Object.defineProperty(this,G9.SEQ,{value:GJ.seq}),this.sortMapEntries=typeof G==="function"?G:G===!0?QJ:null}clone(){let $=Object.create(J9.prototype,Object.getOwnPropertyDescriptors(this));return $.tags=this.tags.slice(),$}}YJ.Schema=J9});var G8=F((VJ)=>{var UJ=E(),Y9=l$(),e$=m$();function WJ($,Z){let X=[],z=Z.directives===!0;if(Z.directives!==!1&&$.directives){let H=$.directives.toString($);if(H)X.push(H),z=!0;else if($.directives.docStart)z=!0}if(z)X.push("---");let q=Y9.createStringifyContext($,Z),{commentString:G}=q.options;if($.commentBefore){if(X.length!==1)X.unshift("");let H=G($.commentBefore);X.unshift(e$.indentComment(H,""))}let J=!1,Q=null;if($.contents){if(UJ.isNode($.contents)){if($.contents.spaceBefore&&z)X.push("");if($.contents.commentBefore){let W=G($.contents.commentBefore);X.push(e$.indentComment(W,""))}q.forceBlockIndent=!!$.comment,Q=$.contents.comment}let H=Q?void 0:()=>J=!0,Y=Y9.stringify($.contents,q,()=>Q=null,H);if(Q)Y+=e$.lineComment(Y,"",G(Q));if((Y[0]==="|"||Y[0]===">")&&X[X.length-1]==="---")X[X.length-1]=`--- ${Y}`;else X.push(Y)}else X.push(Y9.stringify($.contents,q));if($.directives?.docEnd)if($.comment){let H=G($.comment);if(H.includes(`
|
|
82
|
+
`))X.push("..."),X.push(e$.indentComment(H,""));else X.push(`... ${H}`)}else X.push("...");else{let H=$.comment;if(H&&J)H=H.replace(/^\n+/,"");if(H){if((!J||Q)&&X[X.length-1]!=="")X.push("");X.push(e$.indentComment(G(H),""))}}return X.join(`
|
|
83
83
|
`)+`
|
|
84
|
-
`}
|
|
85
|
-
`;J=Q+J}if(/[^ ]/.test(J)){let Q=1,
|
|
84
|
+
`}VJ.stringifyDocument=WJ});var $1=F((OJ)=>{var BJ=v$(),U$=u1(),Z0=E(),LJ=S0(),TJ=j0(),DJ=Q9(),_J=G8(),H9=h1(),FJ=N4(),MJ=u$(),U9=A4();class W9{constructor($,Z,X){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Z0.NODE_TYPE,{value:Z0.DOC});let z=null;if(typeof Z==="function"||Array.isArray(Z))z=Z;else if(X===void 0&&Z)X=Z,Z=void 0;let q=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},X);this.options=q;let{version:G}=q;if(X?._directives){if(this.directives=X._directives.atDocument(),this.directives.yaml.explicit)G=this.directives.yaml.version}else this.directives=new U9.Directives({version:G});this.setSchema(G,X),this.contents=$===void 0?null:this.createNode($,z,X)}clone(){let $=Object.create(W9.prototype,{[Z0.NODE_TYPE]:{value:Z0.DOC}});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=Z0.isNode(this.contents)?this.contents.clone($.schema):this.contents,this.range)$.range=this.range.slice();return $}add($){if(W$(this.contents))this.contents.add($)}addIn($,Z){if(W$(this.contents))this.contents.addIn($,Z)}createAlias($,Z){if(!$.anchor){let X=H9.anchorNames(this);$.anchor=!Z||X.has(Z)?H9.findNewAnchor(Z||"a",X):Z}return new BJ.Alias($.anchor)}createNode($,Z,X){let z=void 0;if(typeof Z==="function")$=Z.call({"":$},"",$),z=Z;else if(Array.isArray(Z)){let K=(D)=>typeof D==="number"||D instanceof String||D instanceof Number,L=Z.filter(K).map(String);if(L.length>0)Z=Z.concat(L);z=Z}else if(X===void 0&&Z)X=Z,Z=void 0;let{aliasDuplicateObjects:q,anchorPrefix:G,flow:J,keepUndefined:Q,onTagObj:H,tag:Y}=X??{},{onAnchor:W,setAnchors:U,sourceObjects:V}=H9.createNodeAnchors(this,G||"a"),B={aliasDuplicateObjects:q??!0,keepUndefined:Q??!1,onAnchor:W,onTagObj:H,replacer:z,schema:this.schema,sourceObjects:V},T=MJ.createNode($,Y,B);if(J&&Z0.isCollection(T))T.flow=!0;return U(),T}createPair($,Z,X={}){let z=this.createNode($,null,X),q=this.createNode(Z,null,X);return new LJ.Pair(z,q)}delete($){return W$(this.contents)?this.contents.delete($):!1}deleteIn($){if(U$.isEmptyPath($)){if(this.contents==null)return!1;return this.contents=null,!0}return W$(this.contents)?this.contents.deleteIn($):!1}get($,Z){return Z0.isCollection(this.contents)?this.contents.get($,Z):void 0}getIn($,Z){if(U$.isEmptyPath($))return!Z&&Z0.isScalar(this.contents)?this.contents.value:this.contents;return Z0.isCollection(this.contents)?this.contents.getIn($,Z):void 0}has($){return Z0.isCollection(this.contents)?this.contents.has($):!1}hasIn($){if(U$.isEmptyPath($))return this.contents!==void 0;return Z0.isCollection(this.contents)?this.contents.hasIn($):!1}set($,Z){if(this.contents==null)this.contents=U$.collectionFromPath(this.schema,[$],Z);else if(W$(this.contents))this.contents.set($,Z)}setIn($,Z){if(U$.isEmptyPath($))this.contents=Z;else if(this.contents==null)this.contents=U$.collectionFromPath(this.schema,Array.from($),Z);else if(W$(this.contents))this.contents.setIn($,Z)}setSchema($,Z={}){if(typeof $==="number")$=String($);let X;switch($){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new U9.Directives({version:"1.1"});X={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=$;else this.directives=new U9.Directives({version:$});X={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;X=null;break;default:{let z=JSON.stringify($);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${z}`)}}if(Z.schema instanceof Object)this.schema=Z.schema;else if(X)this.schema=new DJ.Schema(Object.assign(X,Z));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:$,jsonArg:Z,mapAsMap:X,maxAliasCount:z,onAnchor:q,reviver:G}={}){let J={anchors:new Map,doc:this,keep:!$,mapAsMap:X===!0,mapKeyWarned:!1,maxAliasCount:typeof z==="number"?z:100},Q=TJ.toJS(this.contents,Z??"",J);if(typeof q==="function")for(let{count:H,res:Y}of J.anchors.values())q(Y,H);return typeof G==="function"?FJ.applyReviver(G,{"":Q},"",Q):Q}toJSON($,Z){return this.toJS({json:!0,jsonArg:$,mapAsMap:!1,onAnchor:Z})}toString($={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in $&&(!Number.isInteger($.indent)||Number($.indent)<=0)){let Z=JSON.stringify($.indent);throw Error(`"indent" option must be a positive integer, not ${Z}`)}return _J.stringifyDocument(this,$)}}function W$($){if(Z0.isCollection($))return!0;throw Error("Expected a YAML collection as document contents")}OJ.Document=W9});var Z1=F((PJ)=>{class V2 extends Error{constructor($,Z,X,z){super();this.name=$,this.code=X,this.message=z,this.pos=Z}}class J8 extends V2{constructor($,Z,X){super("YAMLParseError",$,Z,X)}}class Q8 extends V2{constructor($,Z,X){super("YAMLWarning",$,Z,X)}}var IJ=($,Z)=>(X)=>{if(X.pos[0]===-1)return;X.linePos=X.pos.map((Q)=>Z.linePos(Q));let{line:z,col:q}=X.linePos[0];X.message+=` at line ${z}, column ${q}`;let G=q-1,J=$.substring(Z.lineStarts[z-1],Z.lineStarts[z]).replace(/[\n\r]+$/,"");if(G>=60&&J.length>80){let Q=Math.min(G-39,J.length-79);J="\u2026"+J.substring(Q),G-=Q-1}if(J.length>80)J=J.substring(0,79)+"\u2026";if(z>1&&/^ *$/.test(J.substring(0,G))){let Q=$.substring(Z.lineStarts[z-2],Z.lineStarts[z-1]);if(Q.length>80)Q=Q.substring(0,79)+`\u2026
|
|
85
|
+
`;J=Q+J}if(/[^ ]/.test(J)){let Q=1,H=X.linePos[1];if(H?.line===z&&H.col>q)Q=Math.max(1,Math.min(H.col-q,80-G));let Y=" ".repeat(G)+"^".repeat(Q);X.message+=`:
|
|
86
86
|
|
|
87
87
|
${J}
|
|
88
|
-
${
|
|
89
|
-
`}};
|
|
90
|
-
`))return!0;if($.end){for(let Z of $.end)if(Z.type==="newline")return!0}return!1;case"flow-collection":for(let Z of $.items){for(let X of Z.start)if(X.type==="newline")return!0;if(Z.sep){for(let X of Z.sep)if(X.type==="newline")return!0}if(
|
|
91
|
-
`+K.comment;else Q.comment=K.comment;continue}if(K.newlineAfterProp||
|
|
92
|
-
`+
|
|
93
|
-
`+
|
|
94
|
-
`+
|
|
95
|
-
`+y.comment;else
|
|
96
|
-
`+L.comment;else
|
|
97
|
-
`.repeat(Math.max(1,J.length-1)):"",L=z+q.length;if(Z.source)L+=Z.source.length;return{value:K,type:G,comment:q.comment,range:[z,L,L]}}let
|
|
98
|
-
`;for(let K=W;K<Q;++K){let[L,D]=J[K];
|
|
99
|
-
`;else if(L.length>
|
|
88
|
+
${Y}
|
|
89
|
+
`}};PJ.YAMLError=V2;PJ.YAMLParseError=J8;PJ.YAMLWarning=Q8;PJ.prettifyError=IJ});var X1=F((CJ)=>{function SJ($,{flow:Z,indicator:X,next:z,offset:q,onError:G,parentIndent:J,startOnNewline:Q}){let H=!1,Y=Q,W=Q,U="",V="",B=!1,T=!1,K=null,L=null,D=null,_=null,M=null,w=null,R=null;for(let O of $){if(T){if(O.type!=="space"&&O.type!=="newline"&&O.type!=="comma")G(O.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");T=!1}if(K){if(Y&&O.type!=="comment"&&O.type!=="newline")G(K,"TAB_AS_INDENT","Tabs are not allowed as indentation");K=null}switch(O.type){case"space":if(!Z&&(X!=="doc-start"||z?.type!=="flow-collection")&&O.source.includes("\t"))K=O;W=!0;break;case"comment":{if(!W)G(O,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let y=O.source.substring(1)||" ";if(!U)U=y;else U+=V+y;V="",Y=!1;break}case"newline":if(Y){if(U)U+=O.source;else if(!w||X!=="seq-item-ind")H=!0}else V+=O.source;if(Y=!0,B=!0,L||D)_=O;W=!0;break;case"anchor":if(L)G(O,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(O.source.endsWith(":"))G(O.offset+O.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);L=O,R??(R=O.offset),Y=!1,W=!1,T=!0;break;case"tag":{if(D)G(O,"MULTIPLE_TAGS","A node can have at most one tag");D=O,R??(R=O.offset),Y=!1,W=!1,T=!0;break}case X:if(L||D)G(O,"BAD_PROP_ORDER",`Anchors and tags must be after the ${O.source} indicator`);if(w)G(O,"UNEXPECTED_TOKEN",`Unexpected ${O.source} in ${Z??"collection"}`);w=O,Y=X==="seq-item-ind"||X==="explicit-key-ind",W=!1;break;case"comma":if(Z){if(M)G(O,"UNEXPECTED_TOKEN",`Unexpected , in ${Z}`);M=O,Y=!1,W=!1;break}default:G(O,"UNEXPECTED_TOKEN",`Unexpected ${O.type} token`),Y=!1,W=!1}}let P=$[$.length-1],A=P?P.offset+P.source.length:q;if(T&&z&&z.type!=="space"&&z.type!=="newline"&&z.type!=="comma"&&(z.type!=="scalar"||z.source!==""))G(z.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(K&&(Y&&K.indent<=J||z?.type==="block-map"||z?.type==="block-seq"))G(K,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:M,found:w,spaceBefore:H,comment:U,hasNewline:B,anchor:L,tag:D,newlineAfterProp:_,end:A,start:R??A}}CJ.resolveProps=SJ});var K2=F((bJ)=>{function V9($){if(!$)return null;switch($.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if($.source.includes(`
|
|
90
|
+
`))return!0;if($.end){for(let Z of $.end)if(Z.type==="newline")return!0}return!1;case"flow-collection":for(let Z of $.items){for(let X of Z.start)if(X.type==="newline")return!0;if(Z.sep){for(let X of Z.sep)if(X.type==="newline")return!0}if(V9(Z.key)||V9(Z.value))return!0}return!1;default:return!0}}bJ.containsNewline=V9});var K9=F((fJ)=>{var xJ=K2();function kJ($,Z,X){if(Z?.type==="flow-collection"){let z=Z.end[0];if(z.indent===$&&(z.source==="]"||z.source==="}")&&xJ.containsNewline(Z))X(z,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}fJ.flowIndentCheck=kJ});var B9=F((vJ)=>{var Y8=E();function gJ($,Z,X){let{uniqueKeys:z}=$.options;if(z===!1)return!1;let q=typeof z==="function"?z:(G,J)=>G===J||Y8.isScalar(G)&&Y8.isScalar(J)&&G.value===J.value;return Z.some((G)=>q(G.key,X))}vJ.mapIncludes=gJ});var K8=F((cJ)=>{var H8=S0(),mJ=E0(),U8=X1(),dJ=K2(),W8=K9(),pJ=B9(),V8="All mapping items must start at the same column";function lJ({composeNode:$,composeEmptyNode:Z},X,z,q,G){let Q=new(G?.nodeClass??mJ.YAMLMap)(X.schema);if(X.atRoot)X.atRoot=!1;let H=z.offset,Y=null;for(let W of z.items){let{start:U,key:V,sep:B,value:T}=W,K=U8.resolveProps(U,{indicator:"explicit-key-ind",next:V??B?.[0],offset:H,onError:q,parentIndent:z.indent,startOnNewline:!0}),L=!K.found;if(L){if(V){if(V.type==="block-seq")q(H,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in V&&V.indent!==z.indent)q(H,"BAD_INDENT",V8)}if(!K.anchor&&!K.tag&&!B){if(Y=K.end,K.comment)if(Q.comment)Q.comment+=`
|
|
91
|
+
`+K.comment;else Q.comment=K.comment;continue}if(K.newlineAfterProp||dJ.containsNewline(V))q(V??U[U.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(K.found?.indent!==z.indent)q(H,"BAD_INDENT",V8);X.atKey=!0;let D=K.end,_=V?$(X,V,K,q):Z(X,D,U,null,K,q);if(X.schema.compat)W8.flowIndentCheck(z.indent,V,q);if(X.atKey=!1,pJ.mapIncludes(X,Q.items,_))q(D,"DUPLICATE_KEY","Map keys must be unique");let M=U8.resolveProps(B??[],{indicator:"map-value-ind",next:T,offset:_.range[2],onError:q,parentIndent:z.indent,startOnNewline:!V||V.type==="block-scalar"});if(H=M.end,M.found){if(L){if(T?.type==="block-map"&&!M.hasNewline)q(H,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(X.options.strict&&K.start<M.found.offset-1024)q(_.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let w=T?$(X,T,M,q):Z(X,H,B,null,M,q);if(X.schema.compat)W8.flowIndentCheck(z.indent,T,q);H=w.range[2];let R=new H8.Pair(_,w);if(X.options.keepSourceTokens)R.srcToken=W;Q.items.push(R)}else{if(L)q(_.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(M.comment)if(_.comment)_.comment+=`
|
|
92
|
+
`+M.comment;else _.comment=M.comment;let w=new H8.Pair(_);if(X.options.keepSourceTokens)w.srcToken=W;Q.items.push(w)}}if(Y&&Y<H)q(Y,"IMPOSSIBLE","Map comment with trailing content");return Q.range=[z.offset,H,Y??H],Q}cJ.resolveBlockMap=lJ});var B8=F((oJ)=>{var aJ=b0(),nJ=X1(),sJ=K9();function rJ({composeNode:$,composeEmptyNode:Z},X,z,q,G){let Q=new(G?.nodeClass??aJ.YAMLSeq)(X.schema);if(X.atRoot)X.atRoot=!1;if(X.atKey)X.atKey=!1;let H=z.offset,Y=null;for(let{start:W,value:U}of z.items){let V=nJ.resolveProps(W,{indicator:"seq-item-ind",next:U,offset:H,onError:q,parentIndent:z.indent,startOnNewline:!0});if(!V.found)if(V.anchor||V.tag||U)if(U?.type==="block-seq")q(V.end,"BAD_INDENT","All sequence items must start at the same column");else q(H,"MISSING_CHAR","Sequence item without - indicator");else{if(Y=V.end,V.comment)Q.comment=V.comment;continue}let B=U?$(X,U,V,q):Z(X,V.end,W,null,V,q);if(X.schema.compat)sJ.flowIndentCheck(z.indent,U,q);H=B.range[2],Q.items.push(B)}return Q.range=[z.offset,H,Y??H],Q}oJ.resolveBlockSeq=rJ});var V$=F(($Q)=>{function eJ($,Z,X,z){let q="";if($){let G=!1,J="";for(let Q of $){let{source:H,type:Y}=Q;switch(Y){case"space":G=!0;break;case"comment":{if(X&&!G)z(Q,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let W=H.substring(1)||" ";if(!q)q=W;else q+=J+W;J="";break}case"newline":if(q)J+=H;G=!0;break;default:z(Q,"UNEXPECTED_TOKEN",`Unexpected ${Y} at node end`)}Z+=H.length}}return{comment:q,offset:Z}}$Q.resolveEnd=eJ});var D8=F((HQ)=>{var XQ=E(),zQ=S0(),L8=E0(),qQ=b0(),GQ=V$(),T8=X1(),JQ=K2(),QQ=B9(),L9="Block collections are not allowed within flow collections",T9=($)=>$&&($.type==="block-map"||$.type==="block-seq");function YQ({composeNode:$,composeEmptyNode:Z},X,z,q,G){let J=z.start.source==="{",Q=J?"flow map":"flow sequence",Y=new(G?.nodeClass??(J?L8.YAMLMap:qQ.YAMLSeq))(X.schema);Y.flow=!0;let W=X.atRoot;if(W)X.atRoot=!1;if(X.atKey)X.atKey=!1;let U=z.offset+z.start.source.length;for(let L=0;L<z.items.length;++L){let D=z.items[L],{start:_,key:M,sep:w,value:R}=D,P=T8.resolveProps(_,{flow:Q,indicator:"explicit-key-ind",next:M??w?.[0],offset:U,onError:q,parentIndent:z.indent,startOnNewline:!1});if(!P.found){if(!P.anchor&&!P.tag&&!w&&!R){if(L===0&&P.comma)q(P.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${Q}`);else if(L<z.items.length-1)q(P.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${Q}`);if(P.comment)if(Y.comment)Y.comment+=`
|
|
93
|
+
`+P.comment;else Y.comment=P.comment;U=P.end;continue}if(!J&&X.options.strict&&JQ.containsNewline(M))q(M,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(L===0){if(P.comma)q(P.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${Q}`)}else{if(!P.comma)q(P.start,"MISSING_CHAR",`Missing , between ${Q} items`);if(P.comment){let A="";$:for(let O of _)switch(O.type){case"comma":case"space":break;case"comment":A=O.source.substring(1);break $;default:break $}if(A){let O=Y.items[Y.items.length-1];if(XQ.isPair(O))O=O.value??O.key;if(O.comment)O.comment+=`
|
|
94
|
+
`+A;else O.comment=A;P.comment=P.comment.substring(A.length+1)}}}if(!J&&!w&&!P.found){let A=R?$(X,R,P,q):Z(X,P.end,w,null,P,q);if(Y.items.push(A),U=A.range[2],T9(R))q(A.range,"BLOCK_IN_FLOW",L9)}else{X.atKey=!0;let A=P.end,O=M?$(X,M,P,q):Z(X,A,_,null,P,q);if(T9(M))q(O.range,"BLOCK_IN_FLOW",L9);X.atKey=!1;let y=T8.resolveProps(w??[],{flow:Q,indicator:"map-value-ind",next:R,offset:O.range[2],onError:q,parentIndent:z.indent,startOnNewline:!1});if(y.found){if(!J&&!P.found&&X.options.strict){if(w)for(let x of w){if(x===y.found)break;if(x.type==="newline"){q(x,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(P.start<y.found.offset-1024)q(y.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(R)if("source"in R&&R.source?.[0]===":")q(R,"MISSING_CHAR",`Missing space after : in ${Q}`);else q(y.start,"MISSING_CHAR",`Missing , or : between ${Q} items`);let m=R?$(X,R,y,q):y.found?Z(X,y.end,w,null,y,q):null;if(m){if(T9(R))q(m.range,"BLOCK_IN_FLOW",L9)}else if(y.comment)if(O.comment)O.comment+=`
|
|
95
|
+
`+y.comment;else O.comment=y.comment;let i=new zQ.Pair(O,m);if(X.options.keepSourceTokens)i.srcToken=D;if(J){let x=Y;if(QQ.mapIncludes(X,x.items,O))q(A,"DUPLICATE_KEY","Map keys must be unique");x.items.push(i)}else{let x=new L8.YAMLMap(X.schema);x.flow=!0,x.items.push(i);let I0=(m??O).range;x.range=[O.range[0],I0[1],I0[2]],Y.items.push(x)}U=m?m.range[2]:y.end}}let V=J?"}":"]",[B,...T]=z.end,K=U;if(B?.source===V)K=B.offset+B.source.length;else{let L=Q[0].toUpperCase()+Q.substring(1),D=W?`${L} must end with a ${V}`:`${L} in block collection must be sufficiently indented and end with a ${V}`;if(q(U,W?"MISSING_CHAR":"BAD_INDENT",D),B&&B.source.length!==1)T.unshift(B)}if(T.length>0){let L=GQ.resolveEnd(T,K,X.options.strict,q);if(L.comment)if(Y.comment)Y.comment+=`
|
|
96
|
+
`+L.comment;else Y.comment=L.comment;Y.range=[z.offset,K,L.offset]}else Y.range=[z.offset,K,K];return Y}HQ.resolveFlowCollection=YQ});var _8=F((FQ)=>{var WQ=E(),VQ=g(),KQ=E0(),BQ=b0(),LQ=K8(),TQ=B8(),DQ=D8();function D9($,Z,X,z,q,G){let J=X.type==="block-map"?LQ.resolveBlockMap($,Z,X,z,G):X.type==="block-seq"?TQ.resolveBlockSeq($,Z,X,z,G):DQ.resolveFlowCollection($,Z,X,z,G),Q=J.constructor;if(q==="!"||q===Q.tagName)return J.tag=Q.tagName,J;if(q)J.tag=q;return J}function _Q($,Z,X,z,q){let G=z.tag,J=!G?null:Z.directives.tagName(G.source,(V)=>q(G,"TAG_RESOLVE_FAILED",V));if(X.type==="block-seq"){let{anchor:V,newlineAfterProp:B}=z,T=V&&G?V.offset>G.offset?V:G:V??G;if(T&&(!B||B.offset<T.offset))q(T,"MISSING_CHAR","Missing newline after block sequence props")}let Q=X.type==="block-map"?"map":X.type==="block-seq"?"seq":X.start.source==="{"?"map":"seq";if(!G||!J||J==="!"||J===KQ.YAMLMap.tagName&&Q==="map"||J===BQ.YAMLSeq.tagName&&Q==="seq")return D9($,Z,X,q,J);let H=Z.schema.tags.find((V)=>V.tag===J&&V.collection===Q);if(!H){let V=Z.schema.knownTags[J];if(V?.collection===Q)Z.schema.tags.push(Object.assign({},V,{default:!1})),H=V;else{if(V)q(G,"BAD_COLLECTION_TYPE",`${V.tag} used for ${Q} collection, but expects ${V.collection??"scalar"}`,!0);else q(G,"TAG_RESOLVE_FAILED",`Unresolved tag: ${J}`,!0);return D9($,Z,X,q,J)}}let Y=D9($,Z,X,q,J,H),W=H.resolve?.(Y,(V)=>q(G,"TAG_RESOLVE_FAILED",V),Z.options)??Y,U=WQ.isNode(W)?W:new VQ.Scalar(W);if(U.range=Y.range,U.tag=J,H?.format)U.format=H.format;return U}FQ.composeCollection=_Q});var F9=F((PQ)=>{var _9=g();function OQ($,Z,X){let z=Z.offset,q=wQ(Z,$.options.strict,X);if(!q)return{value:"",type:null,comment:"",range:[z,z,z]};let G=q.mode===">"?_9.Scalar.BLOCK_FOLDED:_9.Scalar.BLOCK_LITERAL,J=Z.source?IQ(Z.source):[],Q=J.length;for(let K=J.length-1;K>=0;--K){let L=J[K][1];if(L===""||L==="\r")Q=K;else break}if(Q===0){let K=q.chomp==="+"&&J.length>0?`
|
|
97
|
+
`.repeat(Math.max(1,J.length-1)):"",L=z+q.length;if(Z.source)L+=Z.source.length;return{value:K,type:G,comment:q.comment,range:[z,L,L]}}let H=Z.indent+q.indent,Y=Z.offset+q.length,W=0;for(let K=0;K<Q;++K){let[L,D]=J[K];if(D===""||D==="\r"){if(q.indent===0&&L.length>H)H=L.length}else{if(L.length<H)X(Y+L.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(q.indent===0)H=L.length;if(W=K,H===0&&!$.atRoot)X(Y,"BAD_INDENT","Block scalar values in collections must be indented");break}Y+=L.length+D.length+1}for(let K=J.length-1;K>=Q;--K)if(J[K][0].length>H)Q=K+1;let U="",V="",B=!1;for(let K=0;K<W;++K)U+=J[K][0].slice(H)+`
|
|
98
|
+
`;for(let K=W;K<Q;++K){let[L,D]=J[K];Y+=L.length+D.length+1;let _=D[D.length-1]==="\r";if(_)D=D.slice(0,-1);if(D&&L.length<H){let w=`Block scalar lines must not be less indented than their ${q.indent?"explicit indentation indicator":"first line"}`;X(Y-D.length-(_?2:1),"BAD_INDENT",w),L=""}if(G===_9.Scalar.BLOCK_LITERAL)U+=V+L.slice(H)+D,V=`
|
|
99
|
+
`;else if(L.length>H||D[0]==="\t"){if(V===" ")V=`
|
|
100
100
|
`;else if(!B&&V===`
|
|
101
101
|
`)V=`
|
|
102
102
|
|
|
103
|
-
`;U+=V+L.slice(
|
|
103
|
+
`;U+=V+L.slice(H)+D,V=`
|
|
104
104
|
`,B=!0}else if(D==="")if(V===`
|
|
105
105
|
`)U+=`
|
|
106
106
|
`;else V=`
|
|
107
107
|
`;else U+=V+D,V=" ",B=!1}switch(q.chomp){case"-":break;case"+":for(let K=Q;K<J.length;++K)U+=`
|
|
108
|
-
`+J[K][0].slice(
|
|
108
|
+
`+J[K][0].slice(H);if(U[U.length-1]!==`
|
|
109
109
|
`)U+=`
|
|
110
110
|
`;break;default:U+=`
|
|
111
|
-
`}let T=z+q.length+Z.source.length;return{value:U,type:G,comment:q.comment,range:[z,T,T]}}function
|
|
111
|
+
`}let T=z+q.length+Z.source.length;return{value:U,type:G,comment:q.comment,range:[z,T,T]}}function wQ({offset:$,props:Z},X,z){if(Z[0].type!=="block-scalar-header")return z(Z[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:q}=Z[0],G=q[0],J=0,Q="",H=-1;for(let V=1;V<q.length;++V){let B=q[V];if(!Q&&(B==="-"||B==="+"))Q=B;else{let T=Number(B);if(!J&&T)J=T;else if(H===-1)H=$+V}}if(H!==-1)z(H,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${q}`);let Y=!1,W="",U=q.length;for(let V=1;V<Z.length;++V){let B=Z[V];switch(B.type){case"space":Y=!0;case"newline":U+=B.source.length;break;case"comment":if(X&&!Y)z(B,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");U+=B.source.length,W=B.source.substring(1);break;case"error":z(B,"UNEXPECTED_TOKEN",B.message),U+=B.source.length;break;default:{let T=`Unexpected token in block scalar header: ${B.type}`;z(B,"UNEXPECTED_TOKEN",T);let K=B.source;if(K&&typeof K==="string")U+=K.length}}}return{mode:G,indent:J,chomp:Q,comment:W,length:U}}function IQ($){let Z=$.split(/\n( *)/),X=Z[0],z=X.match(/^( *)/),G=[z?.[1]?[z[1],X.slice(z[1].length)]:["",X]];for(let J=1;J<Z.length;J+=2)G.push([Z[J],Z[J+1]]);return G}PQ.resolveBlockScalar=OQ});var O9=F((xQ)=>{var M9=g(),jQ=V$();function AQ($,Z,X){let{offset:z,type:q,source:G,end:J}=$,Q,H,Y=(V,B,T)=>X(z+V,B,T);switch(q){case"scalar":Q=M9.Scalar.PLAIN,H=NQ(G,Y);break;case"single-quoted-scalar":Q=M9.Scalar.QUOTE_SINGLE,H=SQ(G,Y);break;case"double-quoted-scalar":Q=M9.Scalar.QUOTE_DOUBLE,H=CQ(G,Y);break;default:return X($,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${q}`),{value:"",type:null,comment:"",range:[z,z+G.length,z+G.length]}}let W=z+G.length,U=jQ.resolveEnd(J,W,Z,X);return{value:H,type:Q,comment:U.comment,range:[z,W,U.offset]}}function NQ($,Z){let X="";switch($[0]){case"\t":X="a tab character";break;case",":X="flow indicator character ,";break;case"%":X="directive indicator character %";break;case"|":case">":{X=`block scalar indicator ${$[0]}`;break}case"@":case"`":{X=`reserved character ${$[0]}`;break}}if(X)Z(0,"BAD_SCALAR_START",`Plain value cannot start with ${X}`);return F8($)}function SQ($,Z){if($[$.length-1]!=="'"||$.length===1)Z($.length,"MISSING_CHAR","Missing closing 'quote");return F8($.slice(1,-1)).replace(/''/g,"'")}function F8($){let Z,X;try{Z=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
112
112
|
`,"sy"),X=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
113
113
|
`,"sy")}catch{Z=/(.*?)[ \t]*\r?\n/sy,X=/[ \t]*(.*?)[ \t]*\r?\n/sy}let z=Z.exec($);if(!z)return $;let q=z[1],G=" ",J=Z.lastIndex;X.lastIndex=J;while(z=X.exec($)){if(z[1]==="")if(G===`
|
|
114
114
|
`)q+=G;else G=`
|
|
115
|
-
`;else q+=G+z[1],G=" ";J=X.lastIndex}let Q=/[ \t]*(.*)/sy;return Q.lastIndex=J,z=Q.exec($),q+G+(z?.[1]??"")}function
|
|
115
|
+
`;else q+=G+z[1],G=" ";J=X.lastIndex}let Q=/[ \t]*(.*)/sy;return Q.lastIndex=J,z=Q.exec($),q+G+(z?.[1]??"")}function CQ($,Z){let X="";for(let z=1;z<$.length-1;++z){let q=$[z];if(q==="\r"&&$[z+1]===`
|
|
116
116
|
`)continue;if(q===`
|
|
117
|
-
`){let{fold:G,offset:J}=
|
|
117
|
+
`){let{fold:G,offset:J}=EQ($,z);X+=G,z=J}else if(q==="\\"){let G=$[++z],J=bQ[G];if(J)X+=J;else if(G===`
|
|
118
118
|
`){G=$[z+1];while(G===" "||G==="\t")G=$[++z+1]}else if(G==="\r"&&$[z+1]===`
|
|
119
|
-
`){G=$[++z+1];while(G===" "||G==="\t")G=$[++z+1]}else if(G==="x"||G==="u"||G==="U"){let Q={x:2,u:4,U:8}[G];X+=
|
|
119
|
+
`){G=$[++z+1];while(G===" "||G==="\t")G=$[++z+1]}else if(G==="x"||G==="u"||G==="U"){let Q={x:2,u:4,U:8}[G];X+=yQ($,z+1,Q,Z),z+=Q}else{let Q=$.substr(z-1,2);Z(z-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${Q}`),X+=Q}}else if(q===" "||q==="\t"){let G=z,J=$[z+1];while(J===" "||J==="\t")J=$[++z+1];if(J!==`
|
|
120
120
|
`&&!(J==="\r"&&$[z+2]===`
|
|
121
|
-
`))X+=z>G?$.slice(G,z+1):q}else X+=q}if($[$.length-1]!=='"'||$.length===1)Z($.length,"MISSING_CHAR",'Missing closing "quote');return X}function
|
|
121
|
+
`))X+=z>G?$.slice(G,z+1):q}else X+=q}if($[$.length-1]!=='"'||$.length===1)Z($.length,"MISSING_CHAR",'Missing closing "quote');return X}function EQ($,Z){let X="",z=$[Z+1];while(z===" "||z==="\t"||z===`
|
|
122
122
|
`||z==="\r"){if(z==="\r"&&$[Z+2]!==`
|
|
123
123
|
`)break;if(z===`
|
|
124
124
|
`)X+=`
|
|
125
|
-
`;Z+=1,z=$[Z+1]}if(!X)X=" ";return{fold:X,offset:Z}}var
|
|
126
|
-
`,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function
|
|
125
|
+
`;Z+=1,z=$[Z+1]}if(!X)X=" ";return{fold:X,offset:Z}}var bQ={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
126
|
+
`,r:"\r",t:"\t",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function yQ($,Z,X,z){let q=$.substr(Z,X),J=q.length===X&&/^[0-9a-fA-F]+$/.test(q)?parseInt(q,16):NaN;if(isNaN(J)){let Q=$.substr(Z-2,X+2);return z(Z-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${Q}`),Q}return String.fromCodePoint(J)}xQ.resolveFlowScalar=AQ});var O8=F((mQ)=>{var n0=E(),M8=g(),fQ=F9(),hQ=O9();function gQ($,Z,X,z){let{value:q,type:G,comment:J,range:Q}=Z.type==="block-scalar"?fQ.resolveBlockScalar($,Z,z):hQ.resolveFlowScalar(Z,$.options.strict,z),H=X?$.directives.tagName(X.source,(U)=>z(X,"TAG_RESOLVE_FAILED",U)):null,Y;if($.options.stringKeys&&$.atKey)Y=$.schema[n0.SCALAR];else if(H)Y=vQ($.schema,q,H,X,z);else if(Z.type==="scalar")Y=uQ($,q,Z,z);else Y=$.schema[n0.SCALAR];let W;try{let U=Y.resolve(q,(V)=>z(X??Z,"TAG_RESOLVE_FAILED",V),$.options);W=n0.isScalar(U)?U:new M8.Scalar(U)}catch(U){let V=U instanceof Error?U.message:String(U);z(X??Z,"TAG_RESOLVE_FAILED",V),W=new M8.Scalar(q)}if(W.range=Q,W.source=q,G)W.type=G;if(H)W.tag=H;if(Y.format)W.format=Y.format;if(J)W.comment=J;return W}function vQ($,Z,X,z,q){if(X==="!")return $[n0.SCALAR];let G=[];for(let Q of $.tags)if(!Q.collection&&Q.tag===X)if(Q.default&&Q.test)G.push(Q);else return Q;for(let Q of G)if(Q.test?.test(Z))return Q;let J=$.knownTags[X];if(J&&!J.collection)return $.tags.push(Object.assign({},J,{default:!1,test:void 0})),J;return q(z,"TAG_RESOLVE_FAILED",`Unresolved tag: ${X}`,X!=="tag:yaml.org,2002:str"),$[n0.SCALAR]}function uQ({atKey:$,directives:Z,schema:X},z,q,G){let J=X.tags.find((Q)=>(Q.default===!0||$&&Q.default==="key")&&Q.test?.test(z))||X[n0.SCALAR];if(X.compat){let Q=X.compat.find((H)=>H.default&&H.test?.test(z))??X[n0.SCALAR];if(J.tag!==Q.tag){let H=Z.tagString(J.tag),Y=Z.tagString(Q.tag),W=`Value may be parsed as either ${H} or ${Y}`;G(q,"TAG_RESOLVE_FAILED",W,!0)}}return J}mQ.composeScalar=gQ});var w8=F((lQ)=>{function pQ($,Z,X){if(Z){X??(X=Z.length);for(let z=X-1;z>=0;--z){let q=Z[z];switch(q.type){case"space":case"comment":case"newline":$-=q.source.length;continue}q=Z[++z];while(q?.type==="space")$+=q.source.length,q=Z[++z];break}}return $}lQ.emptyScalarPosition=pQ});var R8=F((eQ)=>{var iQ=v$(),aQ=E(),nQ=_8(),I8=O8(),sQ=V$(),rQ=w8(),oQ={composeNode:P8,composeEmptyNode:w9};function P8($,Z,X,z){let q=$.atKey,{spaceBefore:G,comment:J,anchor:Q,tag:H}=X,Y,W=!0;switch(Z.type){case"alias":if(Y=tQ($,Z,z),Q||H)z(Z,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(Y=I8.composeScalar($,Z,H,z),Q)Y.anchor=Q.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":if(Y=nQ.composeCollection(oQ,$,Z,X,z),Q)Y.anchor=Q.source.substring(1);break;default:{let U=Z.type==="error"?Z.message:`Unsupported token (type: ${Z.type})`;z(Z,"UNEXPECTED_TOKEN",U),Y=w9($,Z.offset,void 0,null,X,z),W=!1}}if(Q&&Y.anchor==="")z(Q,"BAD_ALIAS","Anchor cannot be an empty string");if(q&&$.options.stringKeys&&(!aQ.isScalar(Y)||typeof Y.value!=="string"||Y.tag&&Y.tag!=="tag:yaml.org,2002:str"))z(H??Z,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(G)Y.spaceBefore=!0;if(J)if(Z.type==="scalar"&&Z.source==="")Y.comment=J;else Y.commentBefore=J;if($.options.keepSourceTokens&&W)Y.srcToken=Z;return Y}function w9($,Z,X,z,{spaceBefore:q,comment:G,anchor:J,tag:Q,end:H},Y){let W={type:"scalar",offset:rQ.emptyScalarPosition(Z,X,z),indent:-1,source:""},U=I8.composeScalar($,W,Q,Y);if(J){if(U.anchor=J.source.substring(1),U.anchor==="")Y(J,"BAD_ALIAS","Anchor cannot be an empty string")}if(q)U.spaceBefore=!0;if(G)U.comment=G,U.range[2]=H;return U}function tQ({options:$},{offset:Z,source:X,end:z},q){let G=new iQ.Alias(X.substring(1));if(G.source==="")q(Z,"BAD_ALIAS","Alias cannot be an empty string");if(G.source.endsWith(":"))q(Z+X.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let J=Z+X.length,Q=sQ.resolveEnd(z,J,$.strict,q);if(G.range=[Z,J,Q.offset],Q.comment)G.comment=Q.comment;return G}eQ.composeEmptyNode=w9;eQ.composeNode=P8});var A8=F((JY)=>{var XY=$1(),j8=R8(),zY=V$(),qY=X1();function GY($,Z,{offset:X,start:z,value:q,end:G},J){let Q=Object.assign({_directives:Z},$),H=new XY.Document(void 0,Q),Y={atKey:!1,atRoot:!0,directives:H.directives,options:H.options,schema:H.schema},W=qY.resolveProps(z,{indicator:"doc-start",next:q??G?.[0],offset:X,onError:J,parentIndent:0,startOnNewline:!0});if(W.found){if(H.directives.docStart=!0,q&&(q.type==="block-map"||q.type==="block-seq")&&!W.hasNewline)J(W.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}H.contents=q?j8.composeNode(Y,q,W,J):j8.composeEmptyNode(Y,W.end,z,null,W,J);let U=H.contents.range[2],V=zY.resolveEnd(G,U,!1,J);if(V.comment)H.comment=V.comment;return H.range=[X,U,V.offset],H}JY.composeDoc=GY});var I9=F((KY)=>{var YY=B0("process"),HY=A4(),UY=$1(),z1=Z1(),N8=E(),WY=A8(),VY=V$();function q1($){if(typeof $==="number")return[$,$+1];if(Array.isArray($))return $.length===2?$:[$[0],$[1]];let{offset:Z,source:X}=$;return[Z,Z+(typeof X==="string"?X.length:1)]}function S8($){let Z="",X=!1,z=!1;for(let q=0;q<$.length;++q){let G=$[q];switch(G[0]){case"#":Z+=(Z===""?"":z?`
|
|
127
127
|
|
|
128
128
|
`:`
|
|
129
|
-
`)+(G.substring(1)||" "),X=!0,z=!1;break;case"%":if($[q+1]?.[0]!=="#")q+=1;X=!1;break;default:if(!X)z=!0;X=!1}}return{comment:Z,afterEmptyLine:z}}class
|
|
130
|
-
${X}`:X;else if(z||$.directives.docStart||!q)$.commentBefore=X;else if(
|
|
129
|
+
`)+(G.substring(1)||" "),X=!0,z=!1;break;case"%":if($[q+1]?.[0]!=="#")q+=1;X=!1;break;default:if(!X)z=!0;X=!1}}return{comment:Z,afterEmptyLine:z}}class C8{constructor($={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(Z,X,z,q)=>{let G=q1(Z);if(q)this.warnings.push(new z1.YAMLWarning(G,X,z));else this.errors.push(new z1.YAMLParseError(G,X,z))},this.directives=new HY.Directives({version:$.version||"1.2"}),this.options=$}decorate($,Z){let{comment:X,afterEmptyLine:z}=S8(this.prelude);if(X){let q=$.contents;if(Z)$.comment=$.comment?`${$.comment}
|
|
130
|
+
${X}`:X;else if(z||$.directives.docStart||!q)$.commentBefore=X;else if(N8.isCollection(q)&&!q.flow&&q.items.length>0){let G=q.items[0];if(N8.isPair(G))G=G.key;let J=G.commentBefore;G.commentBefore=J?`${X}
|
|
131
131
|
${J}`:X}else{let G=q.commentBefore;q.commentBefore=G?`${X}
|
|
132
|
-
${G}`:X}}if(Z)Array.prototype.push.apply($.errors,this.errors),Array.prototype.push.apply($.warnings,this.warnings);else $.errors=this.errors,$.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:
|
|
133
|
-
${Z.comment}`:Z.comment}this.doc.range[2]=Z.offset;break}default:this.errors.push(new z1.YAMLParseError(q1($),"UNEXPECTED_TOKEN",`Unsupported token ${$.type}`))}}*end($=!1,Z=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if($){let X=Object.assign({_directives:this.directives},this.options),z=new
|
|
134
|
-
`}];switch(Q[0]){case"|":case">":{let
|
|
135
|
-
`),W=Q.substring(0,
|
|
136
|
-
`,V=[{type:"block-scalar-header",offset:G,indent:z,source:W}];if(!
|
|
137
|
-
`});return{type:"block-scalar",offset:G,indent:z,props:V,source:U}}case'"':return{type:"double-quoted-scalar",offset:G,indent:z,source:Q,end:
|
|
132
|
+
${G}`:X}}if(Z)Array.prototype.push.apply($.errors,this.errors),Array.prototype.push.apply($.warnings,this.warnings);else $.errors=this.errors,$.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:S8(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose($,Z=!1,X=-1){for(let z of $)yield*this.next(z);yield*this.end(Z,X)}*next($){if(YY.env.LOG_STREAM)console.dir($,{depth:null});switch($.type){case"directive":this.directives.add($.source,(Z,X,z)=>{let q=q1($);q[0]+=Z,this.onError(q,"BAD_DIRECTIVE",X,z)}),this.prelude.push($.source),this.atDirectives=!0;break;case"document":{let Z=WY.composeDoc(this.options,this.directives,$,this.onError);if(this.atDirectives&&!Z.directives.docStart)this.onError($,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(this.decorate(Z,!1),this.doc)yield this.doc;this.doc=Z,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push($.source);break;case"error":{let Z=$.source?`${$.message}: ${JSON.stringify($.source)}`:$.message,X=new z1.YAMLParseError(q1($),"UNEXPECTED_TOKEN",Z);if(this.atDirectives||!this.doc)this.errors.push(X);else this.doc.errors.push(X);break}case"doc-end":{if(!this.doc){this.errors.push(new z1.YAMLParseError(q1($),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let Z=VY.resolveEnd($.end,$.offset+$.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),Z.comment){let X=this.doc.comment;this.doc.comment=X?`${X}
|
|
133
|
+
${Z.comment}`:Z.comment}this.doc.range[2]=Z.offset;break}default:this.errors.push(new z1.YAMLParseError(q1($),"UNEXPECTED_TOKEN",`Unsupported token ${$.type}`))}}*end($=!1,Z=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if($){let X=Object.assign({_directives:this.directives},this.options),z=new UY.Document(void 0,X);if(this.atDirectives)this.onError(Z,"MISSING_CHAR","Missing directives-end indicator line");z.range=[0,Z,Z],this.decorate(z,!1),yield z}}}KY.Composer=C8});var y8=F((wY)=>{var LY=F9(),TY=O9(),DY=Z1(),E8=p$();function _Y($,Z=!0,X){if($){let z=(q,G,J)=>{let Q=typeof q==="number"?q:Array.isArray(q)?q[0]:q.offset;if(X)X(Q,G,J);else throw new DY.YAMLParseError([Q,Q+1],G,J)};switch($.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return TY.resolveFlowScalar($,Z,z);case"block-scalar":return LY.resolveBlockScalar({options:{strict:Z}},$,z)}}return null}function FY($,Z){let{implicitKey:X=!1,indent:z,inFlow:q=!1,offset:G=-1,type:J="PLAIN"}=Z,Q=E8.stringifyString({type:J,value:$},{implicitKey:X,indent:z>0?" ".repeat(z):"",inFlow:q,options:{blockQuote:!0,lineWidth:-1}}),H=Z.end??[{type:"newline",offset:-1,indent:z,source:`
|
|
134
|
+
`}];switch(Q[0]){case"|":case">":{let Y=Q.indexOf(`
|
|
135
|
+
`),W=Q.substring(0,Y),U=Q.substring(Y+1)+`
|
|
136
|
+
`,V=[{type:"block-scalar-header",offset:G,indent:z,source:W}];if(!b8(V,H))V.push({type:"newline",offset:-1,indent:z,source:`
|
|
137
|
+
`});return{type:"block-scalar",offset:G,indent:z,props:V,source:U}}case'"':return{type:"double-quoted-scalar",offset:G,indent:z,source:Q,end:H};case"'":return{type:"single-quoted-scalar",offset:G,indent:z,source:Q,end:H};default:return{type:"scalar",offset:G,indent:z,source:Q,end:H}}}function MY($,Z,X={}){let{afterKey:z=!1,implicitKey:q=!1,inFlow:G=!1,type:J}=X,Q="indent"in $?$.indent:null;if(z&&typeof Q==="number")Q+=2;if(!J)switch($.type){case"single-quoted-scalar":J="QUOTE_SINGLE";break;case"double-quoted-scalar":J="QUOTE_DOUBLE";break;case"block-scalar":{let Y=$.props[0];if(Y.type!=="block-scalar-header")throw Error("Invalid block scalar header");J=Y.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:J="PLAIN"}let H=E8.stringifyString({type:J,value:Z},{implicitKey:q||Q===null,indent:Q!==null&&Q>0?" ".repeat(Q):"",inFlow:G,options:{blockQuote:!0,lineWidth:-1}});switch(H[0]){case"|":case">":OY($,H);break;case'"':P9($,H,"double-quoted-scalar");break;case"'":P9($,H,"single-quoted-scalar");break;default:P9($,H,"scalar")}}function OY($,Z){let X=Z.indexOf(`
|
|
138
138
|
`),z=Z.substring(0,X),q=Z.substring(X+1)+`
|
|
139
|
-
`;if($.type==="block-scalar"){let G=$.props[0];if(G.type!=="block-scalar-header")throw Error("Invalid block scalar header");G.source=z,$.source=q}else{let{offset:G}=$,J="indent"in $?$.indent:-1,Q=[{type:"block-scalar-header",offset:G,indent:J,source:z}];if(!
|
|
140
|
-
`});for(let
|
|
141
|
-
`};delete $.items,Object.assign($,{type:X,source:Z,end:[q]});break}default:{let z="indent"in $?$.indent:-1,q="end"in $&&Array.isArray($.end)?$.end.filter((G)=>G.type==="space"||G.type==="comment"||G.type==="newline"):[];for(let G of Object.keys($))if(G!=="type"&&G!=="offset")delete $[G];Object.assign($,{type:X,indent:z,source:Z,end:q})}}}
|
|
139
|
+
`;if($.type==="block-scalar"){let G=$.props[0];if(G.type!=="block-scalar-header")throw Error("Invalid block scalar header");G.source=z,$.source=q}else{let{offset:G}=$,J="indent"in $?$.indent:-1,Q=[{type:"block-scalar-header",offset:G,indent:J,source:z}];if(!b8(Q,"end"in $?$.end:void 0))Q.push({type:"newline",offset:-1,indent:J,source:`
|
|
140
|
+
`});for(let H of Object.keys($))if(H!=="type"&&H!=="offset")delete $[H];Object.assign($,{type:"block-scalar",indent:J,props:Q,source:q})}}function b8($,Z){if(Z)for(let X of Z)switch(X.type){case"space":case"comment":$.push(X);break;case"newline":return $.push(X),!0}return!1}function P9($,Z,X){switch($.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":$.type=X,$.source=Z;break;case"block-scalar":{let z=$.props.slice(1),q=Z.length;if($.props[0].type==="block-scalar-header")q-=$.props[0].source.length;for(let G of z)G.offset+=q;delete $.props,Object.assign($,{type:X,source:Z,end:z});break}case"block-map":case"block-seq":{let q={type:"newline",offset:$.offset+Z.length,indent:$.indent,source:`
|
|
141
|
+
`};delete $.items,Object.assign($,{type:X,source:Z,end:[q]});break}default:{let z="indent"in $?$.indent:-1,q="end"in $&&Array.isArray($.end)?$.end.filter((G)=>G.type==="space"||G.type==="comment"||G.type==="newline"):[];for(let G of Object.keys($))if(G!=="type"&&G!=="offset")delete $[G];Object.assign($,{type:X,indent:z,source:Z,end:q})}}}wY.createScalarToken=FY;wY.resolveAsScalar=_Y;wY.setScalarValue=MY});var x8=F((AY)=>{var jY=($)=>("type"in $)?L2($):B2($);function L2($){switch($.type){case"block-scalar":{let Z="";for(let X of $.props)Z+=L2(X);return Z+$.source}case"block-map":case"block-seq":{let Z="";for(let X of $.items)Z+=B2(X);return Z}case"flow-collection":{let Z=$.start.source;for(let X of $.items)Z+=B2(X);for(let X of $.end)Z+=X.source;return Z}case"document":{let Z=B2($);if($.end)for(let X of $.end)Z+=X.source;return Z}default:{let Z=$.source;if("end"in $&&$.end)for(let X of $.end)Z+=X.source;return Z}}}function B2({start:$,key:Z,sep:X,value:z}){let q="";for(let G of $)q+=G.source;if(Z)q+=L2(Z);if(X)for(let G of X)q+=G.source;if(z)q+=L2(z);return q}AY.stringify=jY});var h8=F((CY)=>{var R9=Symbol("break visit"),SY=Symbol("skip children"),k8=Symbol("remove item");function s0($,Z){if("type"in $&&$.type==="document")$={start:$.start,value:$.value};f8(Object.freeze([]),$,Z)}s0.BREAK=R9;s0.SKIP=SY;s0.REMOVE=k8;s0.itemAtPath=($,Z)=>{let X=$;for(let[z,q]of Z){let G=X?.[z];if(G&&"items"in G)X=G.items[q];else return}return X};s0.parentCollection=($,Z)=>{let X=s0.itemAtPath($,Z.slice(0,-1)),z=Z[Z.length-1][0],q=X?.[z];if(q&&"items"in q)return q;throw Error("Parent collection not found")};function f8($,Z,X){let z=X(Z,$);if(typeof z==="symbol")return z;for(let q of["key","value"]){let G=Z[q];if(G&&"items"in G){for(let J=0;J<G.items.length;++J){let Q=f8(Object.freeze($.concat([[q,J]])),G.items[J],X);if(typeof Q==="number")J=Q-1;else if(Q===R9)return R9;else if(Q===k8)G.items.splice(J,1),J-=1}if(typeof z==="function"&&q==="key")z=z(Z,$)}}return typeof z==="function"?z(Z,$):z}CY.visit=s0});var T2=F((gY)=>{var j9=y8(),bY=x8(),yY=h8(),A9="\uFEFF",N9="\x02",S9="\x18",C9="\x1F",xY=($)=>!!$&&("items"in $),kY=($)=>!!$&&($.type==="scalar"||$.type==="single-quoted-scalar"||$.type==="double-quoted-scalar"||$.type==="block-scalar");function fY($){switch($){case A9:return"<BOM>";case N9:return"<DOC>";case S9:return"<FLOW_END>";case C9:return"<SCALAR>";default:return JSON.stringify($)}}function hY($){switch($){case A9:return"byte-order-mark";case N9:return"doc-mode";case S9:return"flow-error-end";case C9:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
142
142
|
`:case`\r
|
|
143
|
-
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch($[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}
|
|
144
|
-
`:case"\r":case"\t":return!0;default:return!1}}var
|
|
145
|
-
\r `),
|
|
143
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch($[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}gY.createScalarToken=j9.createScalarToken;gY.resolveAsScalar=j9.resolveAsScalar;gY.setScalarValue=j9.setScalarValue;gY.stringify=bY.stringify;gY.visit=yY.visit;gY.BOM=A9;gY.DOCUMENT=N9;gY.FLOW_END=S9;gY.SCALAR=C9;gY.isCollection=xY;gY.isScalar=kY;gY.prettyToken=fY;gY.tokenType=hY});var b9=F(($H)=>{var G1=T2();function Q0($){switch($){case void 0:case" ":case`
|
|
144
|
+
`:case"\r":case"\t":return!0;default:return!1}}var g8=new Set("0123456789ABCDEFabcdef"),tY=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),D2=new Set(",[]{}"),eY=new Set(` ,[]{}
|
|
145
|
+
\r `),E9=($)=>!$||eY.has($);class v8{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex($,Z=!1){if($){if(typeof $!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+$:$,this.lineEndPos=null}this.atEnd=!Z;let X=this.next??"stream";while(X&&(Z||this.hasChars(1)))X=yield*this.parseNext(X)}atLineEnd(){let $=this.pos,Z=this.buffer[$];while(Z===" "||Z==="\t")Z=this.buffer[++$];if(!Z||Z==="#"||Z===`
|
|
146
146
|
`)return!0;if(Z==="\r")return this.buffer[$+1]===`
|
|
147
147
|
`;return!1}charAt($){return this.buffer[this.pos+$]}continueScalar($){let Z=this.buffer[$];if(this.indentNext>0){let X=0;while(Z===" ")Z=this.buffer[++X+$];if(Z==="\r"){let z=this.buffer[X+$+1];if(z===`
|
|
148
148
|
`||!z&&!this.atEnd)return $+X+1}return Z===`
|
|
149
|
-
`||X>=this.indentNext||!Z&&!this.atEnd?$+X:-1}if(Z==="-"||Z==="."){let X=this.buffer.substr($,3);if((X==="---"||X==="...")&&
|
|
150
|
-
`,this.pos),this.lineEndPos=$;if($===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[$-1]==="\r")$-=1;return this.buffer.substring(this.pos,$)}hasChars($){return this.pos+$<=this.buffer.length}setNext($){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=$,null}peek($){return this.buffer.substr(this.pos,$)}*parseNext($){switch($){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let $=this.getLine();if($===null)return this.setNext("stream");if($[0]===G1.BOM)yield*this.pushCount(1),$=$.substring(1);if($[0]==="%"){let Z=$.length,X=$.indexOf("#");while(X!==-1){let q=$[X-1];if(q===" "||q==="\t"){Z=X-1;break}else X=$.indexOf("#",X+1)}while(!0){let q=$[Z-1];if(q===" "||q==="\t")Z-=1;else break}let z=(yield*this.pushCount(Z))+(yield*this.pushSpaces(!0));return yield*this.pushCount($.length-z),this.pushNewline(),"stream"}if(this.atLineEnd()){let Z=yield*this.pushSpaces(!0);return yield*this.pushCount($.length-Z),yield*this.pushNewline(),"stream"}return yield G1.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let $=this.charAt(0);if(!$&&!this.atEnd)return this.setNext("line-start");if($==="-"||$==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let Z=this.peek(3);if((Z==="---"||Z==="...")&&
|
|
149
|
+
`||X>=this.indentNext||!Z&&!this.atEnd?$+X:-1}if(Z==="-"||Z==="."){let X=this.buffer.substr($,3);if((X==="---"||X==="...")&&Q0(this.buffer[$+3]))return-1}return $}getLine(){let $=this.lineEndPos;if(typeof $!=="number"||$!==-1&&$<this.pos)$=this.buffer.indexOf(`
|
|
150
|
+
`,this.pos),this.lineEndPos=$;if($===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[$-1]==="\r")$-=1;return this.buffer.substring(this.pos,$)}hasChars($){return this.pos+$<=this.buffer.length}setNext($){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=$,null}peek($){return this.buffer.substr(this.pos,$)}*parseNext($){switch($){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let $=this.getLine();if($===null)return this.setNext("stream");if($[0]===G1.BOM)yield*this.pushCount(1),$=$.substring(1);if($[0]==="%"){let Z=$.length,X=$.indexOf("#");while(X!==-1){let q=$[X-1];if(q===" "||q==="\t"){Z=X-1;break}else X=$.indexOf("#",X+1)}while(!0){let q=$[Z-1];if(q===" "||q==="\t")Z-=1;else break}let z=(yield*this.pushCount(Z))+(yield*this.pushSpaces(!0));return yield*this.pushCount($.length-z),this.pushNewline(),"stream"}if(this.atLineEnd()){let Z=yield*this.pushSpaces(!0);return yield*this.pushCount($.length-Z),yield*this.pushNewline(),"stream"}return yield G1.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let $=this.charAt(0);if(!$&&!this.atEnd)return this.setNext("line-start");if($==="-"||$==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let Z=this.peek(3);if((Z==="---"||Z==="...")&&Q0(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,Z==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Q0(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[$,Z]=this.peek(2);if(!Z&&!this.atEnd)return this.setNext("block-start");if(($==="-"||$==="?"||$===":")&&Q0(Z)){let X=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=X,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let $=this.getLine();if($===null)return this.setNext("doc");let Z=yield*this.pushIndicators();switch($[Z]){case"#":yield*this.pushCount($.length-Z);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(E9),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return Z+=yield*this.parseBlockScalarHeader(),Z+=yield*this.pushSpaces(!0),yield*this.pushCount($.length-Z),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let $,Z,X=-1;do{if($=yield*this.pushNewline(),$>0)Z=yield*this.pushSpaces(!1),this.indentValue=X=Z;else Z=0;Z+=yield*this.pushSpaces(!0)}while($+Z>0);let z=this.getLine();if(z===null)return this.setNext("flow");if(X!==-1&&X<this.indentNext&&z[0]!=="#"||X===0&&(z.startsWith("---")||z.startsWith("..."))&&Q0(z[3])){if(!(X===this.indentNext-1&&this.flowLevel===1&&(z[0]==="]"||z[0]==="}")))return this.flowLevel=0,yield G1.FLOW_END,yield*this.parseLineStart()}let q=0;while(z[q]===",")q+=yield*this.pushCount(1),q+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(q+=yield*this.pushIndicators(),z[q]){case void 0:return"flow";case"#":return yield*this.pushCount(z.length-q),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(E9),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let G=this.charAt(1);if(this.flowKey||Q0(G)||G===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let $=this.charAt(0),Z=this.buffer.indexOf($,this.pos+1);if($==="'")while(Z!==-1&&this.buffer[Z+1]==="'")Z=this.buffer.indexOf("'",Z+2);else while(Z!==-1){let q=0;while(this.buffer[Z-1-q]==="\\")q+=1;if(q%2===0)break;Z=this.buffer.indexOf('"',Z+1)}let X=this.buffer.substring(0,Z),z=X.indexOf(`
|
|
151
151
|
`,this.pos);if(z!==-1){while(z!==-1){let q=this.continueScalar(z+1);if(q===-1)break;z=X.indexOf(`
|
|
152
|
-
`,q)}if(z!==-1)Z=z-(X[z-1]==="\r"?2:1)}if(Z===-1){if(!this.atEnd)return this.setNext("quoted-scalar");Z=this.buffer.length}return yield*this.pushToIndex(Z+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let $=this.pos;while(!0){let Z=this.buffer[++$];if(Z==="+")this.blockScalarKeep=!0;else if(Z>"0"&&Z<="9")this.blockScalarIndent=Number(Z)-1;else if(Z!=="-")break}return yield*this.pushUntil((Z)=>
|
|
152
|
+
`,q)}if(z!==-1)Z=z-(X[z-1]==="\r"?2:1)}if(Z===-1){if(!this.atEnd)return this.setNext("quoted-scalar");Z=this.buffer.length}return yield*this.pushToIndex(Z+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let $=this.pos;while(!0){let Z=this.buffer[++$];if(Z==="+")this.blockScalarKeep=!0;else if(Z>"0"&&Z<="9")this.blockScalarIndent=Number(Z)-1;else if(Z!=="-")break}return yield*this.pushUntil((Z)=>Q0(Z)||Z==="#")}*parseBlockScalar(){let $=this.pos-1,Z=0,X;$:for(let q=this.pos;X=this.buffer[q];++q)switch(X){case" ":Z+=1;break;case`
|
|
153
153
|
`:$=q,Z=0;break;case"\r":{let G=this.buffer[q+1];if(!G&&!this.atEnd)return this.setNext("block-scalar");if(G===`
|
|
154
154
|
`)break}default:break $}if(!X&&!this.atEnd)return this.setNext("block-scalar");if(Z>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=Z;else this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let q=this.continueScalar($+1);if(q===-1)break;$=this.buffer.indexOf(`
|
|
155
155
|
`,q)}while($!==-1);if($===-1){if(!this.atEnd)return this.setNext("block-scalar");$=this.buffer.length}}let z=$+1;X=this.buffer[z];while(X===" ")X=this.buffer[++z];if(X==="\t"){while(X==="\t"||X===" "||X==="\r"||X===`
|
|
156
156
|
`)X=this.buffer[++z];$=z-1}else if(!this.blockScalarKeep)do{let q=$-1,G=this.buffer[q];if(G==="\r")G=this.buffer[--q];let J=q;while(G===" ")G=this.buffer[--q];if(G===`
|
|
157
|
-
`&&q>=this.pos&&q+1+Z>J)$=q;else break}while(!0);return yield G1.SCALAR,yield*this.pushToIndex($+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let $=this.flowLevel>0,Z=this.pos-1,X=this.pos-1,z;while(z=this.buffer[++X])if(z===":"){let q=this.buffer[X+1];if(
|
|
157
|
+
`&&q>=this.pos&&q+1+Z>J)$=q;else break}while(!0);return yield G1.SCALAR,yield*this.pushToIndex($+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let $=this.flowLevel>0,Z=this.pos-1,X=this.pos-1,z;while(z=this.buffer[++X])if(z===":"){let q=this.buffer[X+1];if(Q0(q)||$&&D2.has(q))break;Z=X}else if(Q0(z)){let q=this.buffer[X+1];if(z==="\r")if(q===`
|
|
158
158
|
`)X+=1,z=`
|
|
159
159
|
`,q=this.buffer[X+1];else Z=X;if(q==="#"||$&&D2.has(q))break;if(z===`
|
|
160
|
-
`){let G=this.continueScalar(X+1);if(G===-1)break;X=Math.max(X,G-2)}}else{if($&&D2.has(z))break;Z=X}if(!z&&!this.atEnd)return this.setNext("plain-scalar");return yield G1.SCALAR,yield*this.pushToIndex(Z+1,!0),$?"flow":"doc"}*pushCount($){if($>0)return yield this.buffer.substr(this.pos,$),this.pos+=$,$;return 0}*pushToIndex($,Z){let X=this.buffer.slice(this.pos,$);if(X)return yield X,this.pos+=X.length,X.length;else if(Z)yield"";return 0}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(
|
|
160
|
+
`){let G=this.continueScalar(X+1);if(G===-1)break;X=Math.max(X,G-2)}}else{if($&&D2.has(z))break;Z=X}if(!z&&!this.atEnd)return this.setNext("plain-scalar");return yield G1.SCALAR,yield*this.pushToIndex(Z+1,!0),$?"flow":"doc"}*pushCount($){if($>0)return yield this.buffer.substr(this.pos,$),this.pos+=$,$;return 0}*pushToIndex($,Z){let X=this.buffer.slice(this.pos,$);if(X)return yield X,this.pos+=X.length,X.length;else if(Z)yield"";return 0}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(E9))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let $=this.flowLevel>0,Z=this.charAt(1);if(Q0(Z)||$&&D2.has(Z)){if(!$)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;return(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}}return 0}*pushTag(){if(this.charAt(1)==="<"){let $=this.pos+2,Z=this.buffer[$];while(!Q0(Z)&&Z!==">")Z=this.buffer[++$];return yield*this.pushToIndex(Z===">"?$+1:$,!1)}else{let $=this.pos+1,Z=this.buffer[$];while(Z)if(tY.has(Z))Z=this.buffer[++$];else if(Z==="%"&&g8.has(this.buffer[$+1])&&g8.has(this.buffer[$+2]))Z=this.buffer[$+=3];else break;return yield*this.pushToIndex($,!1)}}*pushNewline(){let $=this.buffer[this.pos];if($===`
|
|
161
161
|
`)return yield*this.pushCount(1);else if($==="\r"&&this.charAt(1)===`
|
|
162
|
-
`)return yield*this.pushCount(2);else return 0}*pushSpaces($){let Z=this.pos-1,X;do X=this.buffer[++Z];while(X===" "||$&&X==="\t");let z=Z-this.pos;if(z>0)yield this.buffer.substr(this.pos,z),this.pos=Z;return z}*pushUntil($){let Z=this.pos,X=this.buffer[Z];while(!$(X))X=this.buffer[++Z];return yield*this.pushToIndex(Z,!1)}}
|
|
162
|
+
`)return yield*this.pushCount(2);else return 0}*pushSpaces($){let Z=this.pos-1,X;do X=this.buffer[++Z];while(X===" "||$&&X==="\t");let z=Z-this.pos;if(z>0)yield this.buffer.substr(this.pos,z),this.pos=Z;return z}*pushUntil($){let Z=this.pos,X=this.buffer[Z];while(!$(X))X=this.buffer[++Z];return yield*this.pushToIndex(Z,!1)}}$H.Lexer=v8});var y9=F((XH)=>{class u8{constructor(){this.lineStarts=[],this.addNewLine=($)=>this.lineStarts.push($),this.linePos=($)=>{let Z=0,X=this.lineStarts.length;while(Z<X){let q=Z+X>>1;if(this.lineStarts[q]<$)Z=q+1;else X=q}if(this.lineStarts[Z]===$)return{line:Z+1,col:1};if(Z===0)return{line:0,col:$};let z=this.lineStarts[Z-1];return{line:Z,col:$-z+1}}}}XH.LineCounter=u8});var x9=F((JH)=>{var qH=B0("process"),m8=T2(),GH=b9();function y0($,Z){for(let X=0;X<$.length;++X)if($[X].type===Z)return!0;return!1}function d8($){for(let Z=0;Z<$.length;++Z)switch($[Z].type){case"space":case"comment":case"newline":break;default:return Z}return-1}function l8($){switch($?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function _2($){switch($.type){case"document":return $.start;case"block-map":{let Z=$.items[$.items.length-1];return Z.sep??Z.start}case"block-seq":return $.items[$.items.length-1].start;default:return[]}}function K$($){if($.length===0)return[];let Z=$.length;$:while(--Z>=0)switch($[Z].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break $}while($[++Z]?.type==="space");return $.splice(Z,$.length)}function p8($){if($.start.type==="flow-seq-start"){for(let Z of $.items)if(Z.sep&&!Z.value&&!y0(Z.start,"explicit-key-ind")&&!y0(Z.sep,"map-value-ind")){if(Z.key)Z.value=Z.key;if(delete Z.key,l8(Z.value))if(Z.value.end)Array.prototype.push.apply(Z.value.end,Z.sep);else Z.value.end=Z.sep;else Array.prototype.push.apply(Z.start,Z.sep);delete Z.sep}}}class c8{constructor($){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new GH.Lexer,this.onNewLine=$}*parse($,Z=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let X of this.lexer.lex($,Z))yield*this.next(X);if(!Z)yield*this.end()}*next($){if(this.source=$,qH.env.LOG_TOKENS)console.log("|",m8.prettyToken($));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=$.length;return}let Z=m8.tokenType($);if(!Z){let X=`Not a YAML token: ${$}`;yield*this.pop({type:"error",offset:this.offset,message:X,source:$}),this.offset+=$.length}else if(Z==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=Z,yield*this.step(),Z){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+$.length);break;case"space":if(this.atNewLine&&$[0]===" ")this.indent+=$.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=$.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=$.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let $=this.peek(1);if(this.type==="doc-end"&&$?.type!=="doc-end"){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!$)return yield*this.stream();switch($.type){case"document":return yield*this.document($);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar($);case"block-scalar":return yield*this.blockScalar($);case"block-map":return yield*this.blockMap($);case"block-seq":return yield*this.blockSequence($);case"flow-collection":return yield*this.flowCollection($);case"doc-end":return yield*this.documentEnd($)}yield*this.pop()}peek($){return this.stack[this.stack.length-$]}*pop($){let Z=$??this.stack.pop();if(!Z)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield Z;else{let X=this.peek(1);if(Z.type==="block-scalar")Z.indent="indent"in X?X.indent:0;else if(Z.type==="flow-collection"&&X.type==="document")Z.indent=0;if(Z.type==="flow-collection")p8(Z);switch(X.type){case"document":X.value=Z;break;case"block-scalar":X.props.push(Z);break;case"block-map":{let z=X.items[X.items.length-1];if(z.value){X.items.push({start:[],key:Z,sep:[]}),this.onKeyLine=!0;return}else if(z.sep)z.value=Z;else{Object.assign(z,{key:Z,sep:[]}),this.onKeyLine=!z.explicitKey;return}break}case"block-seq":{let z=X.items[X.items.length-1];if(z.value)X.items.push({start:[],value:Z});else z.value=Z;break}case"flow-collection":{let z=X.items[X.items.length-1];if(!z||z.value)X.items.push({start:[],key:Z,sep:[]});else if(z.sep)z.value=Z;else Object.assign(z,{key:Z,sep:[]});return}default:yield*this.pop(),yield*this.pop(Z)}if((X.type==="document"||X.type==="block-map"||X.type==="block-seq")&&(Z.type==="block-map"||Z.type==="block-seq")){let z=Z.items[Z.items.length-1];if(z&&!z.sep&&!z.value&&z.start.length>0&&d8(z.start)===-1&&(Z.indent===0||z.start.every((q)=>q.type!=="comment"||q.indent<Z.indent))){if(X.type==="document")X.end=z.start;else X.items.push({start:z.start});Z.items.splice(-1,1)}}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let $={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")$.start.push(this.sourceToken);this.stack.push($);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document($){if($.value)return yield*this.lineEnd($);switch(this.type){case"doc-start":{if(d8($.start)!==-1)yield*this.pop(),yield*this.step();else $.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":$.start.push(this.sourceToken);return}let Z=this.startBlockValue($);if(Z)this.stack.push(Z);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar($){if(this.type==="map-value-ind"){let Z=_2(this.peek(2)),X=K$(Z),z;if($.end)z=$.end,z.push(this.sourceToken),delete $.end;else z=[this.sourceToken];let q={type:"block-map",offset:$.offset,indent:$.indent,items:[{start:X,key:$,sep:z}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=q}else yield*this.lineEnd($)}*blockScalar($){switch(this.type){case"space":case"comment":case"newline":$.props.push(this.sourceToken);return;case"scalar":if($.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let Z=this.source.indexOf(`
|
|
163
163
|
`)+1;while(Z!==0)this.onNewLine(this.offset+Z),Z=this.source.indexOf(`
|
|
164
|
-
`,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 X="end"in Z.value?Z.value.end:void 0;if((Array.isArray(X)?X[X.length-1]:void 0)?.type==="comment")X?.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 z=$.items[$.items.length-2]?.value?.end;if(Array.isArray(z)){Array.prototype.push.apply(z,Z.start),z.push(this.sourceToken),$.items.pop();return}}Z.start.push(this.sourceToken)}return}if(this.indent>=$.indent){let X=!this.onKeyLine&&this.indent===$.indent,z=X&&(Z.sep||Z.explicitKey)&&this.type!=="seq-item-ind",q=[];if(z&&Z.sep&&!Z.value){let G=[];for(let J=0;J<Z.sep.length;++J){let Q=Z.sep[J];switch(Q.type){case"newline":G.push(J);break;case"space":break;case"comment":if(Q.indent>$.indent)G.length=0;break;default:G.length=0}}if(G.length>=2)q=Z.sep.splice(G[1])}switch(this.type){case"anchor":case"tag":if(z||Z.value)q.push(this.sourceToken),$.items.push({start:q}),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(z||Z.value)q.push(this.sourceToken),$.items.push({start:q,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(
|
|
164
|
+
`,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 X="end"in Z.value?Z.value.end:void 0;if((Array.isArray(X)?X[X.length-1]:void 0)?.type==="comment")X?.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 z=$.items[$.items.length-2]?.value?.end;if(Array.isArray(z)){Array.prototype.push.apply(z,Z.start),z.push(this.sourceToken),$.items.pop();return}}Z.start.push(this.sourceToken)}return}if(this.indent>=$.indent){let X=!this.onKeyLine&&this.indent===$.indent,z=X&&(Z.sep||Z.explicitKey)&&this.type!=="seq-item-ind",q=[];if(z&&Z.sep&&!Z.value){let G=[];for(let J=0;J<Z.sep.length;++J){let Q=Z.sep[J];switch(Q.type){case"newline":G.push(J);break;case"space":break;case"comment":if(Q.indent>$.indent)G.length=0;break;default:G.length=0}}if(G.length>=2)q=Z.sep.splice(G[1])}switch(this.type){case"anchor":case"tag":if(z||Z.value)q.push(this.sourceToken),$.items.push({start:q}),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(z||Z.value)q.push(this.sourceToken),$.items.push({start:q,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(y0(Z.start,"newline"))Object.assign(Z,{key:null,sep:[this.sourceToken]});else{let G=K$(Z.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:G,key:null,sep:[this.sourceToken]}]})}else if(Z.value)$.items.push({start:[],key:null,sep:[this.sourceToken]});else if(y0(Z.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:q,key:null,sep:[this.sourceToken]}]});else if(l8(Z.key)&&!y0(Z.sep,"newline")){let G=K$(Z.start),J=Z.key,Q=Z.sep;Q.push(this.sourceToken),delete Z.key,delete Z.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:G,key:J,sep:Q}]})}else if(q.length>0)Z.sep=Z.sep.concat(q,this.sourceToken);else Z.sep.push(this.sourceToken);else if(!Z.sep)Object.assign(Z,{key:null,sep:[this.sourceToken]});else if(Z.value||z)$.items.push({start:q,key:null,sep:[this.sourceToken]});else if(y0(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 G=this.flowScalar(this.type);if(z||Z.value)$.items.push({start:q,key:G,sep:[]}),this.onKeyLine=!0;else if(Z.sep)this.stack.push(G);else Object.assign(Z,{key:G,sep:[]}),this.onKeyLine=!0;return}default:{let G=this.startBlockValue($);if(G){if(G.type==="block-seq"){if(!Z.explicitKey&&Z.sep&&!y0(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(X)$.items.push({start:q});this.stack.push(G);return}}}}yield*this.pop(),yield*this.step()}*blockSequence($){let Z=$.items[$.items.length-1];switch(this.type){case"newline":if(Z.value){let X="end"in Z.value?Z.value.end:void 0;if((Array.isArray(X)?X[X.length-1]:void 0)?.type==="comment")X?.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 z=$.items[$.items.length-2]?.value?.end;if(Array.isArray(z)){Array.prototype.push.apply(z,Z.start),z.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||y0(Z.start,"seq-item-ind"))$.items.push({start:[this.sourceToken]});else Z.start.push(this.sourceToken);return}if(this.indent>$.indent){let X=this.startBlockValue($);if(X){this.stack.push(X);return}}yield*this.pop(),yield*this.step()}*flowCollection($){let Z=$.items[$.items.length-1];if(this.type==="flow-error-end"){let X;do yield*this.pop(),X=this.peek(1);while(X?.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 z=this.flowScalar(this.type);if(!Z||Z.value)$.items.push({start:[],key:z,sep:[]});else if(Z.sep)this.stack.push(z);else Object.assign(Z,{key:z,sep:[]});return}case"flow-map-end":case"flow-seq-end":$.end.push(this.sourceToken);return}let X=this.startBlockValue($);if(X)this.stack.push(X);else yield*this.pop(),yield*this.step()}else{let X=this.peek(2);if(X.type==="block-map"&&(this.type==="map-value-ind"&&X.indent===$.indent||this.type==="newline"&&!X.items[X.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&X.type!=="flow-collection"){let z=_2(X),q=K$(z);p8($);let G=$.end.splice(1,$.end.length);G.push(this.sourceToken);let J={type:"block-map",offset:$.offset,indent:$.indent,items:[{start:q,key:$,sep:G}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=J}else yield*this.lineEnd($)}}flowScalar($){if(this.onNewLine){let Z=this.source.indexOf(`
|
|
165
165
|
`)+1;while(Z!==0)this.onNewLine(this.offset+Z),Z=this.source.indexOf(`
|
|
166
|
-
`,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=_2($),X=V$(Z);return X.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:X,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let Z=_2($),X=V$(Z);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:X,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment($,Z){if(this.type!=="comment")return!1;if(this.indent<=Z)return!1;return $.every((X)=>X.type==="newline"||X.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()}}}qH.Parser=p8});var n8=F((KH)=>{var l8=w9(),JH=$1(),J1=Z1(),QH=b4(),YH=E(),HH=b9(),c8=y9();function i8($){let Z=$.prettyErrors!==!1;return{lineCounter:$.lineCounter||Z&&new HH.LineCounter||null,prettyErrors:Z}}function UH($,Z={}){let{lineCounter:X,prettyErrors:z}=i8(Z),q=new c8.Parser(X?.addNewLine),G=new l8.Composer(Z),J=Array.from(G.compose(q.parse($)));if(z&&X)for(let Q of J)Q.errors.forEach(J1.prettifyError($,X)),Q.warnings.forEach(J1.prettifyError($,X));if(J.length>0)return J;return Object.assign([],{empty:!0},G.streamInfo())}function a8($,Z={}){let{lineCounter:X,prettyErrors:z}=i8(Z),q=new c8.Parser(X?.addNewLine),G=new l8.Composer(Z),J=null;for(let Q of G.compose(q.parse($),!0,$.length))if(!J)J=Q;else if(J.options.logLevel!=="silent"){J.errors.push(new J1.YAMLParseError(Q.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(z&&X)J.errors.forEach(J1.prettifyError($,X)),J.warnings.forEach(J1.prettifyError($,X));return J}function WH($,Z,X){let z=void 0;if(typeof Z==="function")z=Z;else if(X===void 0&&Z&&typeof Z==="object")X=Z;let q=a8($,X);if(!q)return null;if(q.warnings.forEach((G)=>QH.warn(q.options.logLevel,G)),q.errors.length>0)if(q.options.logLevel!=="silent")throw q.errors[0];else q.errors=[];return q.toJS(Object.assign({reviver:z},X))}function VH($,Z,X){let z=null;if(typeof Z==="function"||Array.isArray(Z))z=Z;else if(X===void 0&&Z)X=Z;if(typeof X==="string")X=X.length;if(typeof X==="number"){let q=Math.round(X);X=q<1?void 0:q>8?{indent:8}:{indent:q}}if($===void 0){let{keepUndefined:q}=X??Z??{};if(!q)return}if(YH.isDocument($)&&!z)return $.toString(X);return new JH.Document($,z,X).toString(X)}KH.parse=WH;KH.parseAllDocuments=UH;KH.parseDocument=a8;KH.stringify=VH});var r8=F((CH)=>{var _H=w9(),FH=$1(),MH=J9(),x9=Z1(),OH=v$(),y0=E(),wH=N0(),PH=g(),IH=C0(),RH=E0(),AH=T2(),jH=E9(),NH=b9(),SH=y9(),F2=n8(),s8=h$();CH.Composer=_H.Composer;CH.Document=FH.Document;CH.Schema=MH.Schema;CH.YAMLError=x9.YAMLError;CH.YAMLParseError=x9.YAMLParseError;CH.YAMLWarning=x9.YAMLWarning;CH.Alias=OH.Alias;CH.isAlias=y0.isAlias;CH.isCollection=y0.isCollection;CH.isDocument=y0.isDocument;CH.isMap=y0.isMap;CH.isNode=y0.isNode;CH.isPair=y0.isPair;CH.isScalar=y0.isScalar;CH.isSeq=y0.isSeq;CH.Pair=wH.Pair;CH.Scalar=PH.Scalar;CH.YAMLMap=IH.YAMLMap;CH.YAMLSeq=RH.YAMLSeq;CH.CST=AH;CH.Lexer=jH.Lexer;CH.LineCounter=NH.LineCounter;CH.Parser=SH.Parser;CH.parse=F2.parse;CH.parseAllDocuments=F2.parseAllDocuments;CH.parseDocument=F2.parseDocument;CH.stringify=F2.stringify;CH.visit=s8.visit;CH.visitAsync=s8.visitAsync});var u5=P5(v5(),1),{program:Z$,createCommand:uV,createArgument:mV,createOption:dV,CommanderError:pV,InvalidArgumentError:lV,InvalidOptionArgumentError:cV,Command:iV,Argument:aV,Option:O4,Help:nV}=u5.default;var m5={name:"@pickled-dev/cli",version:"0.19.0",description:"Test what agents actually understand about your product",module:"dist/index.js",type:"module",bin:{pickled:"./dist/index.js"},files:["dist"],scripts:{dev:"bun run ./src/index.ts",build:"bun build ./src/index.ts --outdir ./dist --target bun --minify --external @anthropic-ai/claude-agent-sdk",release:"semantic-release"},dependencies:{commander:"^14.0.2",chalk:"^5.6.2","@anthropic-ai/claude-agent-sdk":"^0.3.0"},devDependencies:{"@pickled-dev/config":"workspace:*","@pickled-dev/core":"workspace:*","semantic-release":"^25.0.2","@semantic-release/commit-analyzer":"^13.0.1","@semantic-release/exec":"^7.1.0","@semantic-release/git":"^10.0.1","@semantic-release/github":"^12.0.2","@semantic-release/release-notes-generator":"^14.0.3"}};import IV from"path";var U0={category:"cli",provider:"claude-code",model:"sonnet"},w4=["Read","Glob","Grep","Bash"],P4=["Edit","MultiEdit","Write","NotebookEdit"];var o8=P5(r8(),1);async function K$($){let Z=`${$}/pickled.yml`,X=Bun.file(Z);if(!await X.exists())throw Error(`pickled.yml not found in ${$}`);let z;try{let q=await X.text();z=o8.default.parse(q)}catch(q){throw Error(`Failed to parse pickled.yml: ${q}`)}return z=k9(z),QU(z),z}var JU=/\$\{([A-Z_][A-Z0-9_]*)\}/g;function k9($){if(typeof $==="string")return $.replace(JU,(Z,X)=>process.env[X]??"");if(Array.isArray($))return $.map(k9);if($!==null&&typeof $==="object"){let Z={};for(let[X,z]of Object.entries($))Z[X]=k9(z);return Z}return $}function QU($){if(!$.tool?.name)throw Error("pickled.yml: 'tool.name' is required");if(!Array.isArray($.scenarios)||$.scenarios.length===0)throw Error("pickled.yml: 'scenarios' must be a non-empty array");if($.docs?.sources)for(let[X,z]of Object.entries($.docs.sources))BU(X,z);if($.toolsets){if(typeof $.toolsets!=="object"||Array.isArray($.toolsets))throw Error("pickled.yml: 'toolsets' must be an object mapping name to configuration");for(let[X,z]of Object.entries($.toolsets))if(typeof z!=="object"||z===null||Array.isArray(z))throw Error(`pickled.yml: toolsets["${X}"] must be an object`)}if($.targets)for(let[X,z]of Object.entries($.targets)){if(z.systemPrompt!==void 0)throw Error(`pickled.yml: target "${X}" sets 'systemPrompt', which bypasses the citation contract. Remove it; custom prompts are not supported in citation mode.`);if(z.provider==="codex-cli"){if(!z.model)throw Error(`pickled.yml: target "${X}" (codex-cli) requires an explicit 'model' field. Codex's default model can change without notice; pin it for reproducible evals.`);if(z.maxTurns!==void 0)throw Error(`pickled.yml: target "${X}" (codex-cli) sets 'maxTurns', but the codex CLI does not support a turn cap. Remove the field.`)}if(z.category==="api"){if(!z.model)throw Error(`pickled.yml: target "${X}" (api/${z.provider}) requires an explicit 'model' field. Pickled does not substitute a default; reproducible evals depend on pinning the model.`);let q=["allowedTools","disallowedTools","mcpServers","permissionMode","maxTurns","maxThinkingTokens","maxBudgetUsd"];for(let G of q)if(z[G]!==void 0)throw Error(`pickled.yml: target "${X}" (api/${z.provider}) sets '${G}', which only applies to CLI/Agent SDK targets. Remove the field; API targets accept only model/temperature/maxTokens/threshold.`);if(z.workspaceContext!==void 0)throw Error(`pickled.yml: target "${X}" (api/${z.provider}) sets 'workspaceContext', which only applies to IDE targets. Remove the field.`)}}let Z=new Set(Object.keys($.docs?.sources??{}));for(let X of $.scenarios){if(!X.name||!X.prompt)throw Error("pickled.yml: every scenario needs 'name' and 'prompt'");if(X.requiredSources!==void 0){if(!Array.isArray(X.requiredSources))throw Error(`pickled.yml: scenario "${X.name}" has non-array 'requiredSources'. Omit the field to skip citation scoring, or set [] for "any cited source counts".`);for(let z of X.requiredSources)if(!Z.has(z))throw Error(`pickled.yml: scenario "${X.name}" references unknown source "${z}". Declared sources: ${[...Z].join(", ")||"(none)"}`)}DU(X.name,X.traps),KU(X.name,X.compareSurfaces,Z),HU(X.name,X.matrix,Z,new Set(Object.keys($.targets??{})),new Set(Object.keys($.toolsets??{none:{}}))),UU(X.name,X.expected),WU(X.name,X.verifiers,Z),VU(X)}YU($)}function YU($){if(!$.docs?.sources)return;let Z=[];for(let[z,q]of Object.entries($.docs.sources)){if(typeof q==="string")continue;let G=q.audit?.traps;if(Array.isArray(G))Z.push({id:z,list:G})}if(Z.length===0)return;let X=new Map;for(let z of $.scenarios)for(let q of z.traps??[]){let G=X.get(q.id);if(G!==void 0)throw Error(`pickled.yml: trap id "${q.id}" is declared in both scenario "${G}" and scenario "${z.name}". Globally unique trap ids are required when any source uses list-form audit.traps suppression. Rename one of the traps.`);X.set(q.id,z.name)}for(let{id:z,list:q}of Z)for(let G of q)if(!X.has(G)){let J=[...X.keys()].join(", ")||"(none)";throw Error(`pickled.yml: docs.sources["${z}"].audit.traps lists unknown trap id "${G}". Declared trap ids: ${J}`)}}function HU($,Z,X,z,q){if(Z===void 0)return;if(typeof Z!=="object"||Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" matrix must be an object with optional interfaces/sources/toolsets arrays`);let G=(J,Q,Y)=>{let H=Z[J];if(H===void 0)return;if(!Array.isArray(H))throw Error(`pickled.yml: scenario "${$}" matrix.${J} must be an array of ${Y} names`);if(H.length===0)throw Error(`pickled.yml: scenario "${$}" matrix.${J} cannot be empty (omit the field to use defaults)`);for(let W of H){if(typeof W!=="string")throw Error(`pickled.yml: scenario "${$}" matrix.${J} entries must be strings`);if(!Q.has(W))throw Error(`pickled.yml: scenario "${$}" matrix.${J} references unknown ${Y} "${W}". Declared: ${[...Q].join(", ")||"(none)"}`)}};G("interfaces",z,"target"),G("sources",X,"source"),G("toolsets",q,"toolset")}function UU($,Z){if(Z===void 0)return;if(typeof Z!=="object"||Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" expected must be an object with optional includes/excludes arrays`);let X=(z)=>{let q=Z[z];if(q===void 0)return;if(!Array.isArray(q))throw Error(`pickled.yml: scenario "${$}" expected.${z} must be an array of strings`);if(q.length===0)throw Error(`pickled.yml: scenario "${$}" expected.${z} cannot be empty (omit the field instead)`);for(let G=0;G<q.length;G++)if(typeof q[G]!=="string"||q[G].length===0)throw Error(`pickled.yml: scenario "${$}" expected.${z}[${G}] must be a non-empty string`)};X("includes"),X("excludes")}function WU($,Z,X){if(Z===void 0)return;if(typeof Z!=="object"||Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" verifiers must be an object`);let z=Z.sources;if(z===void 0)return;if(!Array.isArray(z))throw Error(`pickled.yml: scenario "${$}" verifiers.sources must be an array of source IDs`);for(let q of z){if(typeof q!=="string")throw Error(`pickled.yml: scenario "${$}" verifiers.sources entries must be strings`);if(!X.has(q))throw Error(`pickled.yml: scenario "${$}" verifiers.sources references unknown source "${q}"`)}}function VU($){let Z=$.requiredSources!==void 0,X=$.expected!==void 0&&($.expected.includes!==void 0&&$.expected.includes.length>0||$.expected.excludes!==void 0&&$.expected.excludes.length>0),z=$.traps!==void 0&&$.traps.length>0;if(!Z&&!X&&!z)throw Error(`pickled.yml: scenario "${$.name}" must declare at least one of requiredSources, expected.includes/excludes, or traps. A scenario with nothing to check has no verdict.`);let q=($.matrix?.toolsets??[]).filter((G)=>G!=="none");if(q.length>0&&!X&&!z)throw Error(`pickled.yml: scenario "${$.name}" declares non-none toolsets [${q.join(", ")}] but has neither expected.includes/excludes nor traps. Non-none cells skip the citation contract because the source is not injected, so requiredSources alone leaves them with no actionable answer contract. Add expected or traps, or restrict matrix.toolsets to ["none"].`)}function KU($,Z,X){if(Z===void 0)return;if(!Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" compareSurfaces must be an array of source-id lists`);if(Z.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces cannot be empty (use a non-empty list of surfaces, or remove the field)`);for(let z=0;z<Z.length;z++){let q=Z[z];if(!Array.isArray(q))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] must be an array of source ids`);if(q.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] must be a non-empty list of source ids`);for(let G of q){if(typeof G!=="string")throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] entries must be string source ids`);if(!X.has(G))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] references unknown source "${G}". Declared sources: ${[...X].join(", ")||"(none)"}`)}}}function BU($,Z){if(typeof Z==="string"){if(Z.length===0)throw Error(`pickled.yml: docs.sources["${$}"] string form must be a non-empty file path or URL`);return}if(!Z||typeof Z!=="object")throw Error(`pickled.yml: docs.sources["${$}"] must be a string (path/URL) or an object with a 'path' field`);let X=Z;if(typeof X.path!=="string"||X.path.length===0)throw Error(`pickled.yml: docs.sources["${$}"] object form requires a non-empty 'path' field`);if(X.audit!==void 0){if(typeof X.audit!=="object"||X.audit===null)throw Error(`pickled.yml: docs.sources["${$}"].audit must be an object`);let z=X.audit;if(z.traps!==void 0){let q=z.traps;if(typeof q==="boolean");else if(Array.isArray(q)){if(q.length===0)throw Error(`pickled.yml: docs.sources["${$}"].audit.traps cannot be an empty array; use true (scan all) or false (skip all) instead`);for(let G=0;G<q.length;G++)if(typeof q[G]!=="string")throw Error(`pickled.yml: docs.sources["${$}"].audit.traps[${G}] must be a string trap id`)}else throw Error(`pickled.yml: docs.sources["${$}"].audit.traps must be a boolean or an array of trap ids`)}for(let q of Object.keys(z))if(q!=="traps")throw Error(`pickled.yml: docs.sources["${$}"].audit has unknown field "${q}"`)}if(X.type!==void 0){if(X.type!=="file"&&X.type!=="url"&&X.type!=="codebase")throw Error(`pickled.yml: docs.sources["${$}"].type must be "file", "url", or "codebase"`)}if(X.type==="codebase"){if(typeof X.path==="string"&&X.path.split("/").includes(".."))throw Error(`pickled.yml: docs.sources["${$}"].path must not contain ".." segments. Codebase loader stays within the project root.`);if(X.exclude!==void 0){if(!Array.isArray(X.exclude))throw Error(`pickled.yml: docs.sources["${$}"].exclude must be an array of glob patterns`);for(let z=0;z<X.exclude.length;z++)if(typeof X.exclude[z]!=="string")throw Error(`pickled.yml: docs.sources["${$}"].exclude[${z}] must be a string glob pattern`)}if(X.maxBytes!==void 0){if(typeof X.maxBytes!=="number"||!Number.isFinite(X.maxBytes)||X.maxBytes<=0)throw Error(`pickled.yml: docs.sources["${$}"].maxBytes must be a positive number of bytes`)}}else{if(X.exclude!==void 0)throw Error(`pickled.yml: docs.sources["${$}"].exclude only applies to type: codebase sources`);if(X.maxBytes!==void 0)throw Error(`pickled.yml: docs.sources["${$}"].maxBytes only applies to type: codebase sources`)}for(let z of Object.keys(X))if(z!=="path"&&z!=="audit"&&z!=="type"&&z!=="exclude"&&z!=="maxBytes")throw Error(`pickled.yml: docs.sources["${$}"] has unknown field "${z}"`)}var LU=new Set(["g","y"]),TU=new Set(["i","m","s","u","v"]);function DU($,Z){if(Z===void 0)return;if(!Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" has non-array 'traps'`);let X=new Set;for(let z of Z){if(!z.id||typeof z.id!=="string")throw Error(`pickled.yml: scenario "${$}" has a trap missing 'id'`);if(X.has(z.id))throw Error(`pickled.yml: scenario "${$}" has duplicate trap id "${z.id}"`);if(X.add(z.id),!z.reason||typeof z.reason!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" requires non-empty 'reason'`);if(z.auditSeverity!==void 0&&z.auditSeverity!=="warning"&&z.auditSeverity!=="error")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" auditSeverity must be "warning" or "error"`);let q=typeof z.match==="string",G=typeof z.pattern==="string";if(q===G)throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" must set exactly one of 'match' or 'pattern'`);if(q){if(z.match==="")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has empty 'match'`);if(z.flags!==void 0)throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" sets 'flags' without 'pattern'`)}else{let J=z.pattern;if(typeof J!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" must set 'pattern'`);if(J==="")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has empty 'pattern'`);if(z.flags!==void 0){if(typeof z.flags!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has non-string 'flags'`);for(let Q of z.flags){if(LU.has(Q))throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" uses forbidden regex flag "${Q}" (g and y are not allowed)`);if(!TU.has(Q))throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" uses unsupported regex flag "${Q}"`)}}try{new RegExp(J,z.flags??"")}catch(Q){throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has invalid regex pattern: ${Q instanceof Error?Q.message:Q}`)}}}}function f9($,Z){let X=new Set([...Object.keys($.targets??{}),"default"]);if(!X.has(Z)){let z=[...X].sort().join(", ");throw Error(`Unknown target: "${Z}". Available targets: ${z}`)}return{...$,matrix:{...$.matrix,target:[Z]},scenarios:$.scenarios.filter((z)=>!z.target||z.target===Z)}}function h9($){if(typeof $==="string")return{path:$,auditTraps:!0};return{path:$.path,auditTraps:$.audit?.traps??!0}}function M2($){let{config:Z,files:X,pairs:z,findings:q}=$,G=[],J=q.filter((U)=>U.severity==="error").length,Q=q.filter((U)=>U.severity==="warning").length;if(G.push(`# Agent-context audit
|
|
166
|
+
`,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=_2($),X=K$(Z);return X.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:X,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let Z=_2($),X=K$(Z);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:X,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment($,Z){if(this.type!=="comment")return!1;if(this.indent<=Z)return!1;return $.every((X)=>X.type==="newline"||X.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()}}}JH.Parser=c8});var r8=F((LH)=>{var i8=I9(),YH=$1(),J1=Z1(),HH=y4(),UH=E(),WH=y9(),a8=x9();function n8($){let Z=$.prettyErrors!==!1;return{lineCounter:$.lineCounter||Z&&new WH.LineCounter||null,prettyErrors:Z}}function VH($,Z={}){let{lineCounter:X,prettyErrors:z}=n8(Z),q=new a8.Parser(X?.addNewLine),G=new i8.Composer(Z),J=Array.from(G.compose(q.parse($)));if(z&&X)for(let Q of J)Q.errors.forEach(J1.prettifyError($,X)),Q.warnings.forEach(J1.prettifyError($,X));if(J.length>0)return J;return Object.assign([],{empty:!0},G.streamInfo())}function s8($,Z={}){let{lineCounter:X,prettyErrors:z}=n8(Z),q=new a8.Parser(X?.addNewLine),G=new i8.Composer(Z),J=null;for(let Q of G.compose(q.parse($),!0,$.length))if(!J)J=Q;else if(J.options.logLevel!=="silent"){J.errors.push(new J1.YAMLParseError(Q.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(z&&X)J.errors.forEach(J1.prettifyError($,X)),J.warnings.forEach(J1.prettifyError($,X));return J}function KH($,Z,X){let z=void 0;if(typeof Z==="function")z=Z;else if(X===void 0&&Z&&typeof Z==="object")X=Z;let q=s8($,X);if(!q)return null;if(q.warnings.forEach((G)=>HH.warn(q.options.logLevel,G)),q.errors.length>0)if(q.options.logLevel!=="silent")throw q.errors[0];else q.errors=[];return q.toJS(Object.assign({reviver:z},X))}function BH($,Z,X){let z=null;if(typeof Z==="function"||Array.isArray(Z))z=Z;else if(X===void 0&&Z)X=Z;if(typeof X==="string")X=X.length;if(typeof X==="number"){let q=Math.round(X);X=q<1?void 0:q>8?{indent:8}:{indent:q}}if($===void 0){let{keepUndefined:q}=X??Z??{};if(!q)return}if(UH.isDocument($)&&!z)return $.toString(X);return new YH.Document($,z,X).toString(X)}LH.parse=KH;LH.parseAllDocuments=VH;LH.parseDocument=s8;LH.stringify=BH});var t8=F((bH)=>{var MH=I9(),OH=$1(),wH=Q9(),k9=Z1(),IH=v$(),x0=E(),PH=S0(),RH=g(),jH=E0(),AH=b0(),NH=T2(),SH=b9(),CH=y9(),EH=x9(),F2=r8(),o8=h$();bH.Composer=MH.Composer;bH.Document=OH.Document;bH.Schema=wH.Schema;bH.YAMLError=k9.YAMLError;bH.YAMLParseError=k9.YAMLParseError;bH.YAMLWarning=k9.YAMLWarning;bH.Alias=IH.Alias;bH.isAlias=x0.isAlias;bH.isCollection=x0.isCollection;bH.isDocument=x0.isDocument;bH.isMap=x0.isMap;bH.isNode=x0.isNode;bH.isPair=x0.isPair;bH.isScalar=x0.isScalar;bH.isSeq=x0.isSeq;bH.Pair=PH.Pair;bH.Scalar=RH.Scalar;bH.YAMLMap=jH.YAMLMap;bH.YAMLSeq=AH.YAMLSeq;bH.CST=NH;bH.Lexer=SH.Lexer;bH.LineCounter=CH.LineCounter;bH.Parser=EH.Parser;bH.parse=F2.parse;bH.parseAllDocuments=F2.parseAllDocuments;bH.parseDocument=F2.parseDocument;bH.stringify=F2.stringify;bH.visit=o8.visit;bH.visitAsync=o8.visitAsync});var d5=R5(m5(),1),{program:X$,createCommand:pV,createArgument:lV,createOption:cV,CommanderError:iV,InvalidArgumentError:aV,InvalidOptionArgumentError:nV,Command:sV,Argument:rV,Option:w4,Help:oV}=d5.default;var p5={name:"@pickled-dev/cli",version:"0.20.0",description:"Test what agents actually understand about your product",module:"dist/index.js",type:"module",bin:{pickled:"./dist/index.js"},files:["dist"],scripts:{dev:"bun run ./src/index.ts",build:"bun build ./src/index.ts --outdir ./dist --target bun --minify --external @anthropic-ai/claude-agent-sdk",release:"semantic-release"},dependencies:{commander:"^14.0.2",chalk:"^5.6.2","@anthropic-ai/claude-agent-sdk":"^0.3.0"},devDependencies:{"@pickled-dev/config":"workspace:*","@pickled-dev/core":"workspace:*","semantic-release":"^25.0.2","@semantic-release/commit-analyzer":"^13.0.1","@semantic-release/exec":"^7.1.0","@semantic-release/git":"^10.0.1","@semantic-release/github":"^12.0.2","@semantic-release/release-notes-generator":"^14.0.3"}};import AV from"path";var U0={category:"cli",provider:"claude-code",model:"sonnet"},I4=["Read","Glob","Grep","Bash"],P4=["Edit","MultiEdit","Write","NotebookEdit"];var e8=R5(t8(),1);async function B$($){let Z=`${$}/pickled.yml`,X=Bun.file(Z);if(!await X.exists())throw Error(`pickled.yml not found in ${$}`);let z;try{let q=await X.text();z=e8.default.parse(q)}catch(q){throw Error(`Failed to parse pickled.yml: ${q}`)}return z=f9(z),HU(z),z}var YU=/\$\{([A-Z_][A-Z0-9_]*)\}/g;function f9($){if(typeof $==="string")return $.replace(YU,(Z,X)=>process.env[X]??"");if(Array.isArray($))return $.map(f9);if($!==null&&typeof $==="object"){let Z={};for(let[X,z]of Object.entries($))Z[X]=f9(z);return Z}return $}function HU($){if(!$.tool?.name)throw Error("pickled.yml: 'tool.name' is required");if(!Array.isArray($.scenarios)||$.scenarios.length===0)throw Error("pickled.yml: 'scenarios' must be a non-empty array");if($.docs?.sources)for(let[X,z]of Object.entries($.docs.sources)){if(X==="none")throw Error('pickled.yml: docs.sources cannot use the reserved id "none". That name represents the no-context matrix cell (model prior with toolset:none, or open discovery with toolset:web). Rename this source.');TU(X,z)}if($.toolsets){if(typeof $.toolsets!=="object"||Array.isArray($.toolsets))throw Error("pickled.yml: 'toolsets' must be an object mapping name to configuration");for(let[X,z]of Object.entries($.toolsets))if(typeof z!=="object"||z===null||Array.isArray(z))throw Error(`pickled.yml: toolsets["${X}"] must be an object`)}if($.targets)for(let[X,z]of Object.entries($.targets)){if(z.systemPrompt!==void 0)throw Error(`pickled.yml: target "${X}" sets 'systemPrompt', which bypasses the citation contract. Remove it; custom prompts are not supported in citation mode.`);if(z.provider==="codex-cli"){if(!z.model)throw Error(`pickled.yml: target "${X}" (codex-cli) requires an explicit 'model' field. Codex's default model can change without notice; pin it for reproducible evals.`);if(z.maxTurns!==void 0)throw Error(`pickled.yml: target "${X}" (codex-cli) sets 'maxTurns', but the codex CLI does not support a turn cap. Remove the field.`)}if(z.category==="api"){if(!z.model)throw Error(`pickled.yml: target "${X}" (api/${z.provider}) requires an explicit 'model' field. Pickled does not substitute a default; reproducible evals depend on pinning the model.`);let q=["allowedTools","disallowedTools","mcpServers","permissionMode","maxTurns","maxThinkingTokens","maxBudgetUsd"];for(let G of q)if(z[G]!==void 0)throw Error(`pickled.yml: target "${X}" (api/${z.provider}) sets '${G}', which only applies to CLI/Agent SDK targets. Remove the field; API targets accept only model/temperature/maxTokens/threshold.`);if(z.workspaceContext!==void 0)throw Error(`pickled.yml: target "${X}" (api/${z.provider}) sets 'workspaceContext', which only applies to IDE targets. Remove the field.`)}}let Z=new Set(Object.keys($.docs?.sources??{}));for(let X of $.scenarios){if(!X.name||!X.prompt)throw Error("pickled.yml: every scenario needs 'name' and 'prompt'");if(X.requiredSources!==void 0){if(!Array.isArray(X.requiredSources))throw Error(`pickled.yml: scenario "${X.name}" has non-array 'requiredSources'. Omit the field to skip citation scoring, or set [] for "any cited source counts".`);for(let z of X.requiredSources)if(!Z.has(z))throw Error(`pickled.yml: scenario "${X.name}" references unknown source "${z}". Declared sources: ${[...Z].join(", ")||"(none)"}`)}FU(X.name,X.traps),LU(X.name,X.compareSurfaces,Z),WU(X.name,X.matrix,Z,new Set(Object.keys($.targets??{})),new Set(Object.keys($.toolsets??{none:{}}))),VU(X.name,X.expected),KU(X.name,X.verifiers,Z),BU(X)}UU($)}function UU($){if(!$.docs?.sources)return;let Z=[];for(let[z,q]of Object.entries($.docs.sources)){if(typeof q==="string")continue;let G=q.audit?.traps;if(Array.isArray(G))Z.push({id:z,list:G})}if(Z.length===0)return;let X=new Map;for(let z of $.scenarios)for(let q of z.traps??[]){let G=X.get(q.id);if(G!==void 0)throw Error(`pickled.yml: trap id "${q.id}" is declared in both scenario "${G}" and scenario "${z.name}". Globally unique trap ids are required when any source uses list-form audit.traps suppression. Rename one of the traps.`);X.set(q.id,z.name)}for(let{id:z,list:q}of Z)for(let G of q)if(!X.has(G)){let J=[...X.keys()].join(", ")||"(none)";throw Error(`pickled.yml: docs.sources["${z}"].audit.traps lists unknown trap id "${G}". Declared trap ids: ${J}`)}}function WU($,Z,X,z,q){if(Z===void 0)return;if(typeof Z!=="object"||Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" matrix must be an object with optional interfaces/sources/toolsets arrays`);let G=(J,Q,H)=>{let Y=Z[J];if(Y===void 0)return;if(!Array.isArray(Y))throw Error(`pickled.yml: scenario "${$}" matrix.${J} must be an array of ${H} names`);if(Y.length===0)throw Error(`pickled.yml: scenario "${$}" matrix.${J} cannot be empty (omit the field to use defaults)`);for(let W of Y){if(typeof W!=="string")throw Error(`pickled.yml: scenario "${$}" matrix.${J} entries must be strings`);if(!Q.has(W))throw Error(`pickled.yml: scenario "${$}" matrix.${J} references unknown ${H} "${W}". Declared: ${[...Q].join(", ")||"(none)"}`)}};G("interfaces",z,"target"),G("sources",new Set([...X,"none"]),"source"),G("toolsets",q,"toolset")}function VU($,Z){if(Z===void 0)return;if(typeof Z!=="object"||Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" expected must be an object with optional includes/excludes arrays`);let X=(z)=>{let q=Z[z];if(q===void 0)return;if(!Array.isArray(q))throw Error(`pickled.yml: scenario "${$}" expected.${z} must be an array of strings`);if(q.length===0)throw Error(`pickled.yml: scenario "${$}" expected.${z} cannot be empty (omit the field instead)`);for(let G=0;G<q.length;G++)if(typeof q[G]!=="string"||q[G].length===0)throw Error(`pickled.yml: scenario "${$}" expected.${z}[${G}] must be a non-empty string`)};X("includes"),X("excludes")}function KU($,Z,X){if(Z===void 0)return;if(typeof Z!=="object"||Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" verifiers must be an object`);let z=Z.sources;if(z===void 0)return;if(!Array.isArray(z))throw Error(`pickled.yml: scenario "${$}" verifiers.sources must be an array of source IDs`);for(let q of z){if(typeof q!=="string")throw Error(`pickled.yml: scenario "${$}" verifiers.sources entries must be strings`);if(!X.has(q))throw Error(`pickled.yml: scenario "${$}" verifiers.sources references unknown source "${q}"`)}}function BU($){let Z=$.requiredSources!==void 0,X=$.expected!==void 0&&($.expected.includes!==void 0&&$.expected.includes.length>0||$.expected.excludes!==void 0&&$.expected.excludes.length>0),z=$.traps!==void 0&&$.traps.length>0;if(!Z&&!X&&!z)throw Error(`pickled.yml: scenario "${$.name}" must declare at least one of requiredSources, expected.includes/excludes, or traps. A scenario with nothing to check has no verdict.`);let q=($.matrix?.toolsets??[]).filter((G)=>G!=="none");if(q.length>0&&!X&&!z)throw Error(`pickled.yml: scenario "${$.name}" declares non-none toolsets [${q.join(", ")}] but has neither expected.includes/excludes nor traps. Non-none cells skip the citation contract because the source is not injected, so requiredSources alone leaves them with no actionable answer contract. Add expected or traps, or restrict matrix.toolsets to ["none"].`)}function LU($,Z,X){if(Z===void 0)return;if(!Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" compareSurfaces must be an array of source-id lists`);if(Z.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces cannot be empty (use a non-empty list of surfaces, or remove the field)`);for(let z=0;z<Z.length;z++){let q=Z[z];if(!Array.isArray(q))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] must be an array of source ids`);if(q.length===0)throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] must be a non-empty list of source ids`);for(let G of q){if(typeof G!=="string")throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] entries must be string source ids`);if(!X.has(G))throw Error(`pickled.yml: scenario "${$}" compareSurfaces[${z}] references unknown source "${G}". Declared sources: ${[...X].join(", ")||"(none)"}`)}}}function TU($,Z){if(typeof Z==="string"){if(Z.length===0)throw Error(`pickled.yml: docs.sources["${$}"] string form must be a non-empty file path or URL`);return}if(!Z||typeof Z!=="object")throw Error(`pickled.yml: docs.sources["${$}"] must be a string (path/URL) or an object with a 'path' field`);let X=Z;if(typeof X.path!=="string"||X.path.length===0)throw Error(`pickled.yml: docs.sources["${$}"] object form requires a non-empty 'path' field`);if(X.audit!==void 0){if(typeof X.audit!=="object"||X.audit===null)throw Error(`pickled.yml: docs.sources["${$}"].audit must be an object`);let z=X.audit;if(z.traps!==void 0){let q=z.traps;if(typeof q==="boolean");else if(Array.isArray(q)){if(q.length===0)throw Error(`pickled.yml: docs.sources["${$}"].audit.traps cannot be an empty array; use true (scan all) or false (skip all) instead`);for(let G=0;G<q.length;G++)if(typeof q[G]!=="string")throw Error(`pickled.yml: docs.sources["${$}"].audit.traps[${G}] must be a string trap id`)}else throw Error(`pickled.yml: docs.sources["${$}"].audit.traps must be a boolean or an array of trap ids`)}for(let q of Object.keys(z))if(q!=="traps")throw Error(`pickled.yml: docs.sources["${$}"].audit has unknown field "${q}"`)}if(X.type!==void 0){if(X.type!=="file"&&X.type!=="url"&&X.type!=="codebase")throw Error(`pickled.yml: docs.sources["${$}"].type must be "file", "url", or "codebase"`)}if(X.type==="codebase"){if(typeof X.path==="string"&&X.path.split("/").includes(".."))throw Error(`pickled.yml: docs.sources["${$}"].path must not contain ".." segments. Codebase loader stays within the project root.`);if(X.exclude!==void 0){if(!Array.isArray(X.exclude))throw Error(`pickled.yml: docs.sources["${$}"].exclude must be an array of glob patterns`);for(let z=0;z<X.exclude.length;z++)if(typeof X.exclude[z]!=="string")throw Error(`pickled.yml: docs.sources["${$}"].exclude[${z}] must be a string glob pattern`)}if(X.maxBytes!==void 0){if(typeof X.maxBytes!=="number"||!Number.isFinite(X.maxBytes)||X.maxBytes<=0)throw Error(`pickled.yml: docs.sources["${$}"].maxBytes must be a positive number of bytes`)}}else{if(X.exclude!==void 0)throw Error(`pickled.yml: docs.sources["${$}"].exclude only applies to type: codebase sources`);if(X.maxBytes!==void 0)throw Error(`pickled.yml: docs.sources["${$}"].maxBytes only applies to type: codebase sources`)}for(let z of Object.keys(X))if(z!=="path"&&z!=="audit"&&z!=="type"&&z!=="exclude"&&z!=="maxBytes")throw Error(`pickled.yml: docs.sources["${$}"] has unknown field "${z}"`)}var DU=new Set(["g","y"]),_U=new Set(["i","m","s","u","v"]);function FU($,Z){if(Z===void 0)return;if(!Array.isArray(Z))throw Error(`pickled.yml: scenario "${$}" has non-array 'traps'`);let X=new Set;for(let z of Z){if(!z.id||typeof z.id!=="string")throw Error(`pickled.yml: scenario "${$}" has a trap missing 'id'`);if(X.has(z.id))throw Error(`pickled.yml: scenario "${$}" has duplicate trap id "${z.id}"`);if(X.add(z.id),!z.reason||typeof z.reason!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" requires non-empty 'reason'`);if(z.auditSeverity!==void 0&&z.auditSeverity!=="warning"&&z.auditSeverity!=="error")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" auditSeverity must be "warning" or "error"`);let q=typeof z.match==="string",G=typeof z.pattern==="string";if(q===G)throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" must set exactly one of 'match' or 'pattern'`);if(q){if(z.match==="")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has empty 'match'`);if(z.flags!==void 0)throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" sets 'flags' without 'pattern'`)}else{let J=z.pattern;if(typeof J!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" must set 'pattern'`);if(J==="")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has empty 'pattern'`);if(z.flags!==void 0){if(typeof z.flags!=="string")throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has non-string 'flags'`);for(let Q of z.flags){if(DU.has(Q))throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" uses forbidden regex flag "${Q}" (g and y are not allowed)`);if(!_U.has(Q))throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" uses unsupported regex flag "${Q}"`)}}try{new RegExp(J,z.flags??"")}catch(Q){throw Error(`pickled.yml: scenario "${$}" trap "${z.id}" has invalid regex pattern: ${Q instanceof Error?Q.message:Q}`)}}}}function h9($,Z){let X=new Set([...Object.keys($.targets??{}),"default"]);if(!X.has(Z)){let z=[...X].sort().join(", ");throw Error(`Unknown target: "${Z}". Available targets: ${z}`)}return{...$,matrix:{...$.matrix,target:[Z]},scenarios:$.scenarios.filter((z)=>!z.target||z.target===Z)}}function g9($){if(typeof $==="string")return{path:$,auditTraps:!0};return{path:$.path,auditTraps:$.audit?.traps??!0}}function M2($){let{config:Z,files:X,pairs:z,findings:q}=$,G=[],J=q.filter((U)=>U.severity==="error").length,Q=q.filter((U)=>U.severity==="warning").length;if(G.push(`# Agent-context audit
|
|
167
167
|
`),G.push(`Target: \`${Z.targetRepo}\``),G.push(`Budgets: root \u2264 ${Z.budgets.rootLines} lines, nested warn at ${Z.budgets.nestedWarnLines} lines.`),G.push(`Found ${X.length} agent-doc files. ${J} error(s), ${Q} warning(s).
|
|
168
168
|
`),G.push(`## Inventory
|
|
169
169
|
`),X.length===0)G.push(`No agent-doc files found.
|
|
170
|
-
`);else{G.push("| File | Lines | Kind | Notes |"),G.push("|---|---|---|---|");let U=[...X].sort((V,B)=>B.lineCount-V.lineCount);for(let V of U){let B=!V.relPath.includes("/"),T
|
|
170
|
+
`);else{G.push("| File | Lines | Kind | Notes |"),G.push("|---|---|---|---|");let U=[...X].sort((V,B)=>B.lineCount-V.lineCount);for(let V of U){let B=!V.relPath.includes("/"),T=$Z(V.lineCount,B,Z),K=V.isSymlink?`symlink \u2192 ${V.symlinkTarget?.replace(`${Z.targetRepo}/`,"")??"?"}`:"file";G.push(`| \`${V.relPath}\` | ${V.lineCount} | ${K} | ${T} |`)}G.push("")}if(G.push(`## AGENTS.md / CLAUDE.md pairs
|
|
171
171
|
`),z.length===0)G.push(`No pairs found.
|
|
172
|
-
`);else{G.push("| Directory | A | C | Class | Detail |"),G.push("|---|---|---|---|---|");for(let U of z)G.push(`| \`${U.dir||"(root)"}\` | ${U.agentsExists?"\u2713":"\xB7"} | ${U.claudeExists?"\u2713":"\xB7"} | ${U.classification} | ${U.detail} |`);G.push("")}let
|
|
173
|
-
`),
|
|
174
|
-
`);else for(let U of
|
|
175
|
-
`),U.brokenPathRefs.length>0){G.push("Broken path references:");for(let V of U.brokenPathRefs)G.push(` - \`${V}\``);G.push("")}if(U.brokenImports.length>0){G.push("Broken `@`-imports:");for(let V of U.brokenImports)G.push(` - \`${V}\``);G.push("")}}let
|
|
176
|
-
`),G.push("Looks like a script command in markdown that did not match anything in the target `package.json` `scripts` or the `knownCommands` allowlist. Workspace-filtered commands check against root scripts, so false positives are expected. Review, do not fail CI on this.\n"),
|
|
177
|
-
`);else for(let U of
|
|
172
|
+
`);else{G.push("| Directory | A | C | Class | Detail |"),G.push("|---|---|---|---|---|");for(let U of z)G.push(`| \`${U.dir||"(root)"}\` | ${U.agentsExists?"\u2713":"\xB7"} | ${U.claudeExists?"\u2713":"\xB7"} | ${U.classification} | ${U.detail} |`);G.push("")}let H=X.filter((U)=>!U.isSymlink&&U.brokenPathRefs.length+U.brokenImports.length>0);if(G.push(`## Broken references
|
|
173
|
+
`),H.length===0)G.push(`None detected.
|
|
174
|
+
`);else for(let U of H){if(G.push(`### \`${U.relPath}\`
|
|
175
|
+
`),U.brokenPathRefs.length>0){G.push("Broken path references:");for(let V of U.brokenPathRefs)G.push(` - \`${V}\``);G.push("")}if(U.brokenImports.length>0){G.push("Broken `@`-imports:");for(let V of U.brokenImports)G.push(` - \`${V}\``);G.push("")}}let Y=X.filter((U)=>!U.isSymlink&&U.unresolvedCommands.length>0);if(G.push(`## Unresolved package-manager commands (advisory)
|
|
176
|
+
`),G.push("Looks like a script command in markdown that did not match anything in the target `package.json` `scripts` or the `knownCommands` allowlist. Workspace-filtered commands check against root scripts, so false positives are expected. Review, do not fail CI on this.\n"),Y.length===0)G.push(`None flagged.
|
|
177
|
+
`);else for(let U of Y){G.push(`### \`${U.relPath}\`
|
|
178
178
|
`);for(let V of U.unresolvedCommands)G.push(` - \`${V}\``);G.push("")}let W=X.filter((U)=>{if(U.isSymlink)return!1;return!U.relPath.includes("/")?U.lineCount>Z.budgets.rootLines:U.lineCount>Z.budgets.nestedWarnLines});if(G.push(`## Section breakdown for files over budget
|
|
179
179
|
`),W.length===0)G.push(`All files within budget.
|
|
180
180
|
`);else for(let U of W){G.push(`### \`${U.relPath}\` (${U.lineCount} lines)
|
|
@@ -182,31 +182,31 @@ ${Z.comment}`:Z.comment}this.doc.range[2]=Z.offset;break}default:this.errors.pus
|
|
|
182
182
|
`),G.push("| Section | Lines |"),G.push("|---|---|");for(let V of U.sections.slice(0,10))G.push(`| ${V.header} | ${V.lines} |`);G.push("")}if(G.push(`## Registered-source trap matches
|
|
183
183
|
`),G.push("Catches stale claims in `docs.sources` against declared traps. Per-source suppression: `audit.traps: false` skips all traps; `audit.traps: [<trap_id>, ...]` skips only the listed traps and keeps scanning the rest.\n"),$.sourceTrapMatches.length===0)G.push(`None.
|
|
184
184
|
`);else{for(let U of $.sourceTrapMatches)G.push(`- **${U.sourceId}** (\`${U.sourcePath}:L${U.line}\`) \u2014 trap \`${U.trapId}\` matched \`${U.matched}\` (${U.severity})`),G.push(` - reason: ${U.trapReason}`),G.push(` - fix: remove the stale claim, retire the trap, set \`audit.traps: ['${U.trapId}']\` to suppress just this one (other traps still apply), or set \`audit.traps: false\` if the source is deliberately stale`);G.push("")}return G.join(`
|
|
185
|
-
`)}function O2($){return JSON.stringify($,null,2)}function w2($){let{config:Z,files:X,pairs:z,findings:q}=$,G=[],J=q.filter((U)=>U.severity==="error").length,Q=q.filter((U)=>U.severity==="warning").length;if(G.push("pickled audit"),G.push(`Target: ${Z.targetRepo}`),G.push(`Budgets: root \u2264 ${Z.budgets.rootLines} lines, nested warn at ${Z.budgets.nestedWarnLines} lines.`),G.push(`Found: ${X.length} agent-doc file(s) \xB7 ${J} error(s) \xB7 ${Q} warning(s)`),G.push(""),G.push("Inventory"),X.length===0)G.push(" none");else{let U=[...X].sort((B,T)=>T.lineCount-B.lineCount),V=Math.max(...U.map((B)=>B.relPath.length));for(let B of U){let T=!B.relPath.includes("/"),K
|
|
186
|
-
`)}function
|
|
185
|
+
`)}function O2($){return JSON.stringify($,null,2)}function w2($){let{config:Z,files:X,pairs:z,findings:q}=$,G=[],J=q.filter((U)=>U.severity==="error").length,Q=q.filter((U)=>U.severity==="warning").length;if(G.push("pickled audit"),G.push(`Target: ${Z.targetRepo}`),G.push(`Budgets: root \u2264 ${Z.budgets.rootLines} lines, nested warn at ${Z.budgets.nestedWarnLines} lines.`),G.push(`Found: ${X.length} agent-doc file(s) \xB7 ${J} error(s) \xB7 ${Q} warning(s)`),G.push(""),G.push("Inventory"),X.length===0)G.push(" none");else{let U=[...X].sort((B,T)=>T.lineCount-B.lineCount),V=Math.max(...U.map((B)=>B.relPath.length));for(let B of U){let T=!B.relPath.includes("/"),K=$Z(B.lineCount,T,Z),L=B.isSymlink?`symlink \u2192 ${B.symlinkTarget?.replace(`${Z.targetRepo}/`,"")??"?"}`:"file",D=`${B.lineCount}`.padStart(4),_=B.relPath.padEnd(V),M=K?` (${K})`:"";G.push(` ${_} ${D} lines ${L}${M}`)}}if(G.push(""),G.push("AGENTS.md / CLAUDE.md pairs"),z.length===0)G.push(" none");else for(let U of z){let V=U.dir||"(root)";G.push(` ${V}: ${U.classification} \xB7 ${U.detail}`)}G.push("");let H=X.filter((U)=>!U.isSymlink&&U.brokenPathRefs.length+U.brokenImports.length>0);if(G.push("Broken references"),H.length===0)G.push(" none");else for(let U of H){G.push(` ${U.relPath}:`);for(let V of U.brokenPathRefs)G.push(` path: ${V}`);for(let V of U.brokenImports)G.push(` @-import: ${V}`)}G.push("");let Y=X.filter((U)=>!U.isSymlink&&U.unresolvedCommands.length>0);if(G.push("Unresolved package-manager commands (advisory)"),Y.length===0)G.push(" none");else for(let U of Y){G.push(` ${U.relPath}:`);for(let V of U.unresolvedCommands)G.push(` ${V}`)}G.push("");let W=X.filter((U)=>{if(U.isSymlink)return!1;return!U.relPath.includes("/")?U.lineCount>Z.budgets.rootLines:U.lineCount>Z.budgets.nestedWarnLines});if(G.push("Section breakdown for files over budget"),W.length===0)G.push(" all files within budget");else for(let U of W){G.push(` ${U.relPath} (${U.lineCount} lines):`);for(let V of U.sections.slice(0,10))G.push(` ${V.header.padEnd(40)} ${V.lines} lines`)}if(G.push(""),G.push("Registered-source trap matches"),$.sourceTrapMatches.length===0)G.push(" none");else for(let U of $.sourceTrapMatches){let V=U.severity==="error"?"error":"warning";G.push(` [${V}] ${U.sourceId} (${U.sourcePath}:L${U.line}): trap ${U.trapId} matched "${U.matched}"`),G.push(` reason: ${U.trapReason}`),G.push(` fix: remove the stale claim, retire the trap, set audit.traps: ['${U.trapId}'] to suppress just this trap (others still apply), or set audit.traps: false if deliberately stale`)}return G.join(`
|
|
186
|
+
`)}function $Z($,Z,X){if(Z&&$>X.budgets.rootLines)return`over root budget (${$} > ${X.budgets.rootLines})`;if(!Z&&$>X.budgets.nestedWarnLines)return`over nested-warn (${$} > ${X.budgets.nestedWarnLines})`;return""}import{existsSync as T$,lstatSync as JZ,readFileSync as j2,readlinkSync as bU,statSync as yU}from"fs";import{dirname as A2,isAbsolute as xU,join as v9,relative as kU,resolve as u9}from"path";var{Glob:GZ}=globalThis.Bun;var I2=["node_modules/**","**/node_modules/**",".git/**","**/.git/**","dist/**","**/dist/**","build/**","**/build/**",".next/**","**/.next/**",".source/**","**/.source/**","out/**","**/out/**",".turbo/**","**/.turbo/**",".cache/**","**/.cache/**",".runs/**","**/.runs/**","coverage/**","**/coverage/**","**/__fixtures__/**","**/tests/**/fixture/**","**/tests/**/fixtures/**","**/test/**/fixture/**","**/test/**/fixtures/**"],L$={targetRepo:".",budgets:{rootLines:120,nestedWarnLines:200},ignore:I2,intentionalDifferentPairs:[],knownCommands:[]};function P2($){if(!$)return L$;return{targetRepo:$.targetRepo??L$.targetRepo,budgets:{rootLines:$.budgets?.rootLines??L$.budgets.rootLines,nestedWarnLines:$.budgets?.nestedWarnLines??L$.budgets.nestedWarnLines},ignore:$.ignore??I2,intentionalDifferentPairs:$.intentionalDifferentPairs??[],knownCommands:$.knownCommands??[]}}import{existsSync as AU}from"fs";import{join as NU,resolve as SU}from"path";function k0($){let Z=[],X=[];for(let z of $.traps){let q=MU($.response,z);if(q)Z.push(q);else X.push(z.id)}return{fired:Z,avoided:X}}function MU($,Z){if(Z.match!==void 0){let X=$.indexOf(Z.match);if(X===-1)return null;return{id:Z.id,reason:Z.reason,matched:Z.match,snippet:ZZ($,X,Z.match.length),index:X}}if(Z.pattern!==void 0){let z=new RegExp(Z.pattern,Z.flags??"").exec($);if(!z)return null;return{id:Z.id,reason:Z.reason,matched:z[0],snippet:ZZ($,z.index,z[0].length),index:z.index}}return null}function ZZ($,Z,X){let z=Math.max(0,Z-40),q=Math.min($.length,Z+X+40),G=$.slice(z,q).replace(/\s+/g," ").trim();if(z>0)G=`...${G}`;if(q<$.length)G=`${G}...`;return G}import R2 from"path";var{Glob:XZ}=globalThis.Bun;var OU=262144,wU=4194304;function IU($){return $.startsWith("http://")||$.startsWith("https://")}async function PU($,Z,X){let z=await fetch(Z);if(!z.ok)throw Error(`Failed to fetch source "${$}" from ${Z}: ${z.status} ${z.statusText}`);let q=await z.text();return{id:$,source:Z,content:q,name:new URL(Z).hostname+new URL(Z).pathname,type:"url",auditTraps:X}}async function RU($,Z,X,z){let q=R2.isAbsolute(Z)?Z:R2.resolve(X,Z),G=Bun.file(q);if(!await G.exists())throw Error(`Source "${$}" not found at ${q}`);let J=await G.text();return{id:$,source:Z,content:J,name:R2.basename(q),type:"file",auditTraps:z}}async function jU($,Z,X,z,q){let G=new XZ(Z.path),J=(Z.exclude??[]).map((B)=>new XZ(B)),Q=[];for await(let B of G.scan({cwd:X,onlyFiles:!0,followSymlinks:!1})){if(J.some((T)=>T.match(B)))continue;Q.push(B)}Q.sort();let H=Z.maxBytes??OU,Y=Math.max(H,wU),W=[],U=0;for(let B of Q){let T=R2.resolve(X,B),K=await Bun.file(T).text(),L=`// === ${B} ===
|
|
187
187
|
`;if(W.push(L,K),!K.endsWith(`
|
|
188
188
|
`))W.push(`
|
|
189
|
-
`);if(U+=L.length+K.length,U>
|
|
190
|
-
`)X++;return X}var
|
|
191
|
-
`)?W:W+1;return{relPath:Z,absPath:X,isSymlink:G,symlinkTarget:J,realRelPath:Q,lineCount:U,brokenPathRefs:
|
|
192
|
-
`),X=[],z=null;if(Z.forEach((q,G)=>{if(/^##\s+/.test(q)){if(z)X.push({header:z.header,lines:G-z.start});z={header:q.replace(/^##\s+/,"").trim(),start:G}}}),z){let q=z;X.push({header:q.header,lines:Z.length-q.start})}return X.sort((q,G)=>G.lines-q.lines)}function cU($){if($.length===0||$.length>160)return!1;if(!$.includes("/"))return!1;if(/\s/.test($))return!1;if(/^https?:\/\//.test($))return!1;if(/[*?{}[\]<>]/.test($))return!1;if($.startsWith("@"))return!1;if($.startsWith("~/"))return!1;if(/^[a-z]+:\/\//i.test($))return!1;if(/^cdn\./.test($)||/^unpkg\./.test($)||/^npm\./.test($))return!1;if(/^\/[a-z]/.test($)&&/(?:icon|image|img|asset|file|path)/i.test($))return!1;if(/^(cd|pnpm|npm|yarn|bun|node|git|ls|cat|grep|find|sed|awk|mkdir|rm|mv|cp|echo|export|source|sudo|brew|docker|curl|wget)\b/.test($))return!1;return/[a-zA-Z0-9_.-]\/[a-zA-Z0-9_.-]/.test($)}function iU($){return $.replace(/```[\s\S]*?```/g,"")}function aU($,Z){let X=new Map;for(let G of $){let J=G.relPath.split("/").pop()??"";if(J!=="AGENTS.md"&&J!=="CLAUDE.md")continue;let Q=j2(G.relPath),Y=X.get(Q)??{};if(J==="AGENTS.md")Y.agents=G;if(J==="CLAUDE.md")Y.claude=G;X.set(Q,Y)}let z=new Set(Z.intentionalDifferentPairs),q=[];for(let[G,J]of X){let Q=!!J.agents,Y=!!J.claude;if(!Q&&!Y)continue;if(!Q||!Y){q.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"single",detail:Q?"only AGENTS.md":"only CLAUDE.md"});continue}let{agents:H,claude:W}=J,U=`${H.relPath}:${W.relPath}`,V=`${W.relPath}:${H.relPath}`;if(z.has(U)||z.has(V)){q.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"intentional-different",detail:`allowlisted: ${H.lineCount}L vs ${W.lineCount}L`});continue}if(H.isSymlink&&H.symlinkTarget===W.absPath||W.isSymlink&&W.symlinkTarget===H.absPath){let L=H.isSymlink?"CLAUDE.md":"AGENTS.md";q.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"linked",detail:`canonical: ${L}`});continue}let T=A2(H.absPath,"utf8"),K=A2(W.absPath,"utf8");if(T===K)q.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"unexpected-duplicate",detail:`byte-for-byte duplicate (${H.lineCount}L), not symlinked`});else q.push({dir:G,agentsExists:Q,claudeExists:Y,classification:"unexpected-duplicate",detail:`divergent (${H.lineCount}L vs ${W.lineCount}L), not in intentional-different allowlist`})}return q.sort((G,J)=>G.dir.localeCompare(J.dir)),q}function nU($,Z,X){let z=[];for(let q of $){if(q.isSymlink)continue;for(let Q of q.brokenImports)z.push({severity:"error",category:"broken-import",file:q.relPath,message:`broken @-import: ${Q}`});for(let Q of q.brokenPathRefs)z.push({severity:"error",category:"broken-path-ref",file:q.relPath,message:`broken path reference: ${Q}`});for(let Q of q.unresolvedCommands)z.push({severity:"warning",category:"unresolved-command",file:q.relPath,message:`unresolved command: ${Q}`});let G=!q.relPath.includes("/"),J=G?X.budgets.rootLines:X.budgets.nestedWarnLines;if(q.lineCount>J)z.push({severity:"warning",category:"over-budget",file:q.relPath,message:`${q.lineCount} lines exceeds ${G?"root":"nested"} budget of ${J}`})}for(let q of Z)if(q.classification==="unexpected-duplicate"){let G=q.detail.startsWith("divergent")?"error":"warning";z.push({severity:G,category:G==="error"?"divergent-pair":"duplicate-pair",file:q.dir||"(root)",message:`AGENTS.md / CLAUDE.md ${q.detail}`})}return z}function _0($){let Z=$.confidence;if($.error)return{icon:"\u2717",label:"Error",confidence:Z,tone:"error"};if($.traps.fired.length>0)return{icon:"\u2717",label:"Trap fired",confidence:Z,tone:"error"};if($.answerable==="YES")return{icon:"\u2713",label:Z>=90?"Well grounded":"Grounded",confidence:Z,tone:"success"};if($.answerable==="PARTIAL")return{icon:"\u26A0",label:"Partially grounded",confidence:Z,tone:"warning"};return{icon:"\u2717",label:"Ungrounded",confidence:Z,tone:"error"}}function u9($){let Z=sU($);if(Z===null)return[];let X=[],z=/^\s*-\s+\[([^\]]+)\]\s*(.*)$/gm,q=z.exec(Z);while(q!==null)X.push({id:q[1].trim(),note:q[2].trim()||void 0}),q=z.exec(Z);return X}function sU($){let X=/^##\s+Sources\s*$/im.exec($);if(!X)return null;let z=X.index+X[0].length,q=$.slice(z),G=/^##\s+/m.exec(q);return G?q.slice(0,G.index):q}function T$($){let Z=u9($.response),X=new Set(Z.map((V)=>V.id)),z=new Set($.registeredIds),q=new Set($.requiredSources),G=[...X],J=[...q].filter((V)=>!X.has(V)),Q=[...X].filter((V)=>!z.has(V)),Y=[...q],H,W,U;if(G.length===0)H="NO",W=0,U="No citations in response";else if(Q.length===G.length)H="NO",W=0,U=`All cited sources are unknown: ${Q.join(", ")}`;else if(J.length===0&&Q.length===0)H="YES",W=100,U=Y.length>0?`All required sources cited: ${Y.join(", ")}`:`Cited registered sources: ${G.join(", ")}`;else{H="PARTIAL";let V=Y.length>0?Y.length:1,B=Y.length-J.length,T=Y.length>0?B/V*100:60,K=Q.length*15;W=Math.max(0,Math.min(100,Math.round(T-K)));let L=[];if(J.length>0)L.push(`missing: ${J.join(", ")}`);if(Q.length>0)L.push(`unknown: ${Q.join(", ")}`);U=L.join("; ")}return{answerable:H,confidence:W,reason:U,citations:{cited:G,required:Y,missing:J,unknown:Q}}}function S2($){let Z=$.expected,X=(Z?.includes??[]).map((J)=>({value:J,satisfied:$.response.includes(J)})),z=(Z?.excludes??[]).map((J)=>({value:J,satisfied:!$.response.includes(J)})),q=X.filter((J)=>J.satisfied).length+z.filter((J)=>J.satisfied).length,G=X.length+z.length;return{includes:X,excludes:z,satisfied:q,total:G}}var s0="0.40.1";var GZ=!1,r0=void 0,m9=void 0,rU=void 0,oU=void 0,tU=void 0,JZ=void 0,eU=void 0,C2=void 0,d9=void 0,QZ=void 0,p9=void 0,E2=void 0,YZ=void 0;function HZ($,Z={auto:!1}){if(GZ)throw Error(`you must \`import '@anthropic-ai/sdk/shims/${$.kind}'\` before importing anything else from @anthropic-ai/sdk`);if(r0)throw Error(`can't \`import '@anthropic-ai/sdk/shims/${$.kind}'\` after \`import '@anthropic-ai/sdk/shims/${r0}'\``);GZ=Z.auto,r0=$.kind,m9=$.fetch,rU=$.Request,oU=$.Response,tU=$.Headers,JZ=$.FormData,eU=$.Blob,C2=$.File,d9=$.ReadableStream,QZ=$.getMultipartRequestOptions,p9=$.getDefaultAgent,E2=$.fileFromPath,YZ=$.isFsReadStream}class l9{constructor($){this.body=$}get[Symbol.toStringTag](){return"MultipartBody"}}function UZ({manuallyImported:$}={}){let Z=$?"You may need to use polyfills":"Add one of these imports before your first `import \u2026 from '@anthropic-ai/sdk'`:\n- `import '@anthropic-ai/sdk/shims/node'` (if you're running on Node)\n- `import '@anthropic-ai/sdk/shims/web'` (otherwise)\n",X,z,q,G;try{X=fetch,z=Request,q=Response,G=Headers}catch(J){throw Error(`this environment is missing the following Web Fetch API type: ${J.message}. ${Z}`)}return{kind:"web",fetch:X,Request:z,Response:q,Headers:G,FormData:typeof FormData<"u"?FormData:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${Z}`)}},Blob:typeof Blob<"u"?Blob:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${Z}`)}},File:typeof File<"u"?File:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${Z}`)}},ReadableStream:typeof ReadableStream<"u"?ReadableStream:class{constructor(){throw Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${Z}`)}},getMultipartRequestOptions:async(J,Q)=>({...Q,body:new l9(J)}),getDefaultAgent:(J)=>{return},fileFromPath:()=>{throw Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/anthropics/anthropic-sdk-typescript#file-uploads")},isFsReadStream:(J)=>!1}}import{ReadStream as ZW}from"fs";function WZ(){let $=UZ();function Z(X){return X instanceof ZW}return{...$,isFsReadStream:Z}}var c9=()=>{if(!r0)HZ(WZ(),{auto:!0})};c9();class A extends Error{}class u extends A{constructor($,Z,X,z){super(`${u.makeMessage($,Z,X)}`);this.status=$,this.headers=z,this.request_id=z?.["request-id"],this.error=Z}static makeMessage($,Z,X){let z=Z?.message?typeof Z.message==="string"?Z.message:JSON.stringify(Z.message):Z?JSON.stringify(Z):X;if($&&z)return`${$} ${z}`;if($)return`${$} status code (no body)`;if(z)return z;return"(no status code or body)"}static generate($,Z,X,z){if(!$||!z)return new o0({message:X,cause:u2(Z)});let q=Z;if($===400)return new b2($,q,X,z);if($===401)return new y2($,q,X,z);if($===403)return new x2($,q,X,z);if($===404)return new k2($,q,X,z);if($===409)return new f2($,q,X,z);if($===422)return new h2($,q,X,z);if($===429)return new g2($,q,X,z);if($>=500)return new v2($,q,X,z);return new u($,q,X,z)}}class i extends u{constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}}class o0 extends u{constructor({message:$,cause:Z}){super(void 0,void 0,$||"Connection error.",void 0);if(Z)this.cause=Z}}class Y1 extends o0{constructor({message:$}={}){super({message:$??"Request timed out."})}}class b2 extends u{}class y2 extends u{}class x2 extends u{}class k2 extends u{}class f2 extends u{}class h2 extends u{}class g2 extends u{}class v2 extends u{}var m2=function($,Z,X,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!q:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,X):q?q.value=X:Z.set($,X),X},t0=function($,Z,X,z){if(X==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!z:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?z:X==="a"?z.call($):z?z.value:Z.get($)},t;class k0{constructor(){t.set(this,void 0),this.buffer=new Uint8Array,m2(this,t,null,"f")}decode($){if($==null)return[];let Z=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?new TextEncoder().encode($):$,X=new Uint8Array(this.buffer.length+Z.length);X.set(this.buffer),X.set(Z,this.buffer.length),this.buffer=X;let z=[],q;while((q=zW(this.buffer,t0(this,t,"f")))!=null){if(q.carriage&&t0(this,t,"f")==null){m2(this,t,q.index,"f");continue}if(t0(this,t,"f")!=null&&(q.index!==t0(this,t,"f")+1||q.carriage)){z.push(this.decodeText(this.buffer.slice(0,t0(this,t,"f")-1))),this.buffer=this.buffer.slice(t0(this,t,"f")),m2(this,t,null,"f");continue}let G=t0(this,t,"f")!==null?q.preceding-1:q.preceding,J=this.decodeText(this.buffer.slice(0,G));z.push(J),this.buffer=this.buffer.slice(q.index),m2(this,t,null,"f")}return z}decodeText($){if($==null)return"";if(typeof $==="string")return $;if(typeof Buffer<"u"){if($ instanceof Buffer)return $.toString();if($ instanceof Uint8Array)return Buffer.from($).toString();throw new A(`Unexpected: received non-Uint8Array (${$.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder<"u"){if($ instanceof Uint8Array||$ instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode($);throw new A(`Unexpected: received non-Uint8Array/ArrayBuffer (${$.constructor.name}) in a web platform. Please report this error.`)}throw new A("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length)return[];return this.decode(`
|
|
193
|
-
`)}}
|
|
194
|
-
`,"\r"]);
|
|
195
|
-
`);z.enqueue(J)}catch(q){z.error(q)}},async cancel(){await Z.return?.()}})}}async function*
|
|
196
|
-
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],q}if(this.chunks.push($),$.startsWith(":"))return null;let[Z,X,z]=JW($,":");if(z.startsWith(" "))z=z.substring(1);if(Z==="event")this.event=z;else if(Z==="data")this.data.push(z);return null}}function JW($,Z){let X=$.indexOf(Z);if(X!==-1)return[$.substring(0,X),Z,$.substring(X+Z.length)];return[$,"",""]}var QW=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function",YW=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&U1($),U1=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function";async function BZ($,Z,X){if($=await $,YW($))return $;if(QW($)){let q=await $.blob();Z||(Z=new URL($.url).pathname.split(/[\\/]/).pop()??"unknown_file");let G=U1(q)?[await q.arrayBuffer()]:[q];return new C2(G,Z,X)}let z=await HW($);if(Z||(Z=WW($)??"unknown_file"),!X?.type){let q=z[0]?.type;if(typeof q==="string")X={...X,type:q}}return new C2(z,Z,X)}async function HW($){let Z=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)Z.push($);else if(U1($))Z.push(await $.arrayBuffer());else if(VW($))for await(let X of $)Z.push(X);else throw Error(`Unexpected data type: ${typeof $}; constructor: ${$?.constructor?.name}; props: ${UW($)}`);return Z}function UW($){return`[${Object.getOwnPropertyNames($).map((X)=>`"${X}"`).join(", ")}]`}function WW($){return a9($.name)||a9($.filename)||a9($.path)?.split(/[\\/]/).pop()}var a9=($)=>{if(typeof $==="string")return $;if(typeof Buffer<"u"&&$ instanceof Buffer)return String($);return},VW=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",n9=($)=>$&&typeof $==="object"&&$.body&&$[Symbol.toStringTag]==="MultipartBody";var BW=function($,Z,X,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!q:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,X):q?q.value=X:Z.set($,X),X},LW=function($,Z,X,z){if(X==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!z:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?z:X==="a"?z.call($):z?z.value:Z.get($)},d2;c9();async function FZ($){let{response:Z}=$;if($.options.stream){if(D$("response",Z.status,Z.url,Z.headers,Z.body),$.options.__streamClass)return $.options.__streamClass.fromSSEResponse(Z,$.controller);return e.fromSSEResponse(Z,$.controller)}if(Z.status===204)return null;if($.options.__binaryResponse)return Z;let z=Z.headers.get("content-type")?.split(";")[0]?.trim();if(z?.includes("application/json")||z?.endsWith("+json")){let J=await Z.json();return D$("response",Z.status,Z.url,Z.headers,J),MZ(J,Z)}let G=await Z.text();return D$("response",Z.status,Z.url,Z.headers,G),G}function MZ($,Z){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:Z.headers.get("request-id"),enumerable:!1})}class l2 extends Promise{constructor($,Z=FZ){super((X)=>{X(null)});this.responsePromise=$,this.parseResponse=Z}_thenUnwrap($){return new l2(this.responsePromise,async(Z)=>MZ($(await this.parseResponse(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);return this.parsedPromise}then($,Z){return this.parse().then($,Z)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}}class r9{constructor({baseURL:$,maxRetries:Z=2,timeout:X=600000,httpAgent:z,fetch:q}){this.baseURL=$,this.maxRetries=s9("maxRetries",Z),this.timeout=s9("timeout",X),this.httpAgent=z,this.fetch=q??m9}authHeaders($){return{}}defaultHeaders($){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...FW(),...this.authHeaders($)}}validateHeaders($,Z){}defaultIdempotencyKey(){return`stainless-node-retry-${IW()}`}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,X){return this.request(Promise.resolve(X).then(async(z)=>{let q=z&&U1(z?.body)?new DataView(await z.body.arrayBuffer()):z?.body instanceof DataView?z.body:z?.body instanceof ArrayBuffer?new DataView(z.body):z&&ArrayBuffer.isView(z?.body)?new DataView(z.body.buffer):z?.body;return{method:$,path:Z,...z,body:q}}))}getAPIList($,Z,X){return this.requestAPIList(Z,{method:"get",path:$,...X})}calculateContentLength($){if(typeof $==="string"){if(typeof Buffer<"u")return Buffer.byteLength($,"utf8").toString();if(typeof TextEncoder<"u")return new TextEncoder().encode($).length.toString()}else if(ArrayBuffer.isView($))return $.byteLength.toString();return null}buildRequest($,{retryCount:Z=0}={}){let X={...$},{method:z,path:q,query:G,headers:J={}}=X,Q=ArrayBuffer.isView(X.body)||X.__binaryRequest&&typeof X.body==="string"?X.body:n9(X.body)?X.body.body:X.body?JSON.stringify(X.body,null,2):null,Y=this.calculateContentLength(Q),H=this.buildURL(q,G);if("timeout"in X)s9("timeout",X.timeout);X.timeout=X.timeout??this.timeout;let W=X.httpAgent??this.httpAgent??p9(H),U=X.timeout+1000;if(typeof W?.options?.timeout==="number"&&U>(W.options.timeout??0))W.options.timeout=U;if(this.idempotencyHeader&&z!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();J[this.idempotencyHeader]=$.idempotencyKey}let V=this.buildHeaders({options:X,headers:J,contentLength:Y,retryCount:Z});return{req:{method:z,...Q&&{body:Q},headers:V,...W&&{agent:W},signal:X.signal??null},url:H,timeout:X.timeout}}buildHeaders({options:$,headers:Z,contentLength:X,retryCount:z}){let q={};if(X)q["content-length"]=X;let G=this.defaultHeaders($);if(_Z(q,G),_Z(q,Z),n9($.body)&&r0!=="node")delete q["content-type"];if(p2(G,"x-stainless-retry-count")===void 0&&p2(Z,"x-stainless-retry-count")===void 0)q["x-stainless-retry-count"]=String(z);if(p2(G,"x-stainless-timeout")===void 0&&p2(Z,"x-stainless-timeout")===void 0&&$.timeout)q["x-stainless-timeout"]=String(Math.trunc($.timeout/1000));return this.validateHeaders(q,Z),q}_calculateNonstreamingTimeout($){if(3600*$/128000>600)throw new A("Streaming is strongly recommended for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-python#streaming-responses for more details");return 600000}async prepareOptions($){}async prepareRequest($,{url:Z,options:X}){}parseHeaders($){return!$?{}:(Symbol.iterator in $)?Object.fromEntries(Array.from($).map((Z)=>[...Z])):{...$}}makeStatusError($,Z,X,z){return u.generate($,Z,X,z)}request($,Z=null){return new l2(this.makeRequest($,Z))}async makeRequest($,Z){let X=await $,z=X.maxRetries??this.maxRetries;if(Z==null)Z=z;await this.prepareOptions(X);let{req:q,url:G,timeout:J}=this.buildRequest(X,{retryCount:z-Z});if(await this.prepareRequest(q,{url:G,options:X}),D$("request",G,X,q.headers),X.signal?.aborted)throw new i;let Q=new AbortController,Y=await this.fetchWithTimeout(G,q,J,Q).catch(u2);if(Y instanceof Error){if(X.signal?.aborted)throw new i;if(Z)return this.retryRequest(X,Z);if(Y.name==="AbortError")throw new Y1;throw new o0({cause:Y})}let H=i9(Y.headers);if(!Y.ok){if(Z&&this.shouldRetry(Y)){let K=`retrying, ${Z} attempts remaining`;return D$(`response (error; ${K})`,Y.status,G,H),this.retryRequest(X,Z,H)}let W=await Y.text().catch((K)=>u2(K).message),U=MW(W),V=U?void 0:W;throw D$(`response (error; ${Z?"(error; no more retries left)":"(error; not retryable)"})`,Y.status,G,H,V),this.makeStatusError(Y.status,U,V,H)}return{response:Y,options:X,controller:Q}}requestAPIList($,Z){let X=this.makeRequest(Z,null);return new OZ(this,X,$)}buildURL($,Z){let X=wW($)?new URL($):new URL(this.baseURL+(this.baseURL.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),z=this.defaultQuery();if(!wZ(z))Z={...z,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))X.search=this.stringifyQuery(Z);return X.toString()}stringifyQuery($){return Object.entries($).filter(([Z,X])=>typeof X<"u").map(([Z,X])=>{if(typeof X==="string"||typeof X==="number"||typeof X==="boolean")return`${encodeURIComponent(Z)}=${encodeURIComponent(X)}`;if(X===null)return`${encodeURIComponent(Z)}=`;throw new A(`Cannot stringify type ${typeof X}; 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("&")}async fetchWithTimeout($,Z,X,z){let{signal:q,...G}=Z||{};if(q)q.addEventListener("abort",()=>z.abort());let J=setTimeout(()=>z.abort(),X),Q={signal:z.signal,...G};if(Q.method)Q.method=Q.method.toUpperCase();let Y=60000,H=setTimeout(()=>{if(Q&&Q?.agent?.sockets){for(let W of Object.values(Q?.agent?.sockets).flat())if(W?.setKeepAlive)W.setKeepAlive(!0,Y)}},Y);return this.fetch.call(void 0,$,Q).finally(()=>{clearTimeout(J),clearTimeout(H)})}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,X){let z,q=X?.["retry-after-ms"];if(q){let J=parseFloat(q);if(!Number.isNaN(J))z=J}let G=X?.["retry-after"];if(G&&!z){let J=parseFloat(G);if(!Number.isNaN(J))z=J*1000;else z=Date.parse(G)-Date.now()}if(!(z&&0<=z&&z<60000)){let J=$.maxRetries??this.maxRetries;z=this.calculateDefaultRetryTimeoutMillis(Z,J)}return await PW(z),this.makeRequest($,Z-1)}calculateDefaultRetryTimeoutMillis($,Z){let q=Z-$,G=Math.min(0.5*Math.pow(2,q),8),J=1-Math.random()*0.25;return G*J*1000}getUserAgent(){return`${this.constructor.name}/JS ${s0}`}}class o9{constructor($,Z,X,z){d2.set(this,void 0),BW(this,d2,$,"f"),this.options=z,this.response=Z,this.body=X}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageInfo()!=null}async getNextPage(){let $=this.nextPageInfo();if(!$)throw new A("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let Z={...this.options};if("params"in $&&typeof Z.query==="object")Z.query={...Z.query,...$.params};else if("url"in $){let X=[...Object.entries(Z.query||{}),...$.url.searchParams.entries()];for(let[z,q]of X)$.url.searchParams.set(z,q);Z.query=void 0,Z.path=$.url.toString()}return await LW(this,d2,"f").requestAPIList(this.constructor,Z)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(d2=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let Z of $.getPaginatedItems())yield Z}}class OZ extends l2{constructor($,Z,X){super(Z,async(z)=>new X($,z.response,await FZ(z),z.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let Z of $)yield Z}}var i9=($)=>{return new Proxy(Object.fromEntries($.entries()),{get(Z,X){let z=X.toString();return Z[z.toLowerCase()]||Z[z]}})},TW={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},z0=($)=>{return typeof $==="object"&&$!==null&&!wZ($)&&Object.keys($).every((Z)=>PZ(TW,Z))},DW=()=>{if(typeof Deno<"u"&&Deno.build!=null)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":s0,"X-Stainless-OS":TZ(Deno.build.os),"X-Stainless-Arch":LZ(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":s0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if(Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":s0,"X-Stainless-OS":TZ(process.platform),"X-Stainless-Arch":LZ(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};let $=_W();if($)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":s0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${$.browser}`,"X-Stainless-Runtime-Version":$.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":s0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function _W(){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:X}of $){let z=X.exec(navigator.userAgent);if(z){let q=z[1]||0,G=z[2]||0,J=z[3]||0;return{browser:Z,version:`${q}.${G}.${J}`}}}return null}var LZ=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},TZ=($)=>{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"},DZ,FW=()=>{return DZ??(DZ=DW())},MW=($)=>{try{return JSON.parse($)}catch(Z){return}},OW=/^[a-z][a-z0-9+.-]*:/i,wW=($)=>{return OW.test($)},PW=($)=>new Promise((Z)=>setTimeout(Z,$)),s9=($,Z)=>{if(typeof Z!=="number"||!Number.isInteger(Z))throw new A(`${$} must be an integer`);if(Z<0)throw new A(`${$} must be a positive integer`);return Z},u2=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null)try{return Error(JSON.stringify($))}catch{}return Error(String($))};var c2=($)=>{if(typeof process<"u")return process.env?.[$]?.trim()??void 0;if(typeof Deno<"u")return Deno.env?.get?.($)?.trim();return};function wZ($){if(!$)return!0;for(let Z in $)return!1;return!0}function PZ($,Z){return Object.prototype.hasOwnProperty.call($,Z)}function _Z($,Z){for(let X in Z){if(!PZ(Z,X))continue;let z=X.toLowerCase();if(!z)continue;let q=Z[X];if(q===null)delete $[z];else if(q!==void 0)$[z]=q}}function D$($,...Z){if(typeof process<"u"&&process?.env?.DEBUG==="true")console.log(`Anthropic:DEBUG:${$}`,...Z)}var IW=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,($)=>{let Z=Math.random()*16|0;return($==="x"?Z:Z&3|8).toString(16)})},IZ=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},RW=($)=>{return typeof $?.get==="function"};var p2=($,Z)=>{let X=Z.toLowerCase();if(RW($)){let z=Z[0]?.toUpperCase()+Z.substring(1).replace(/([^\w])(\w)/g,(q,G,J)=>G+J.toUpperCase());for(let q of[Z,X,Z.toUpperCase(),z]){let G=$.get(q);if(G)return G}}for(let[z,q]of Object.entries($))if(z.toLowerCase()===X){if(Array.isArray(q)){if(q.length<=1)return q[0];return console.warn(`Received ${q.length} entries for the ${Z} header, using the first entry.`),q[0]}return q}return};class F0 extends o9{constructor($,Z,X,z){super($,Z,X,z);this.data=X.data||[],this.has_more=X.has_more||!1,this.first_id=X.first_id||null,this.last_id=X.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageParams(){let $=this.nextPageInfo();if(!$)return null;if("params"in $)return $.params;let Z=Object.fromEntries($.url.searchParams);if(!Object.keys(Z).length)return null;return Z}nextPageInfo(){if(this.options.query?.before_id){let Z=this.first_id;if(!Z)return null;return{params:{before_id:Z}}}let $=this.last_id;if(!$)return null;return{params:{after_id:$}}}}class c{constructor($){this._client=$}}class _$ extends c{retrieve($,Z){return this._client.get(`/v1/models/${$}?beta=true`,Z)}list($={},Z){if(z0($))return this.list({},$);return this._client.getAPIList("/v1/models?beta=true",W1,{query:$,...Z})}}class W1 extends F0{}_$.BetaModelInfosPage=W1;class F${constructor($,Z){this.iterator=$,this.controller=Z}async*decoder(){let $=new k0;for await(let Z of this.iterator)for(let X of $.decode(Z))yield JSON.parse(X);for(let Z of $.flush())yield JSON.parse(Z)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse($,Z){if(!$.body)throw Z.abort(),new A("Attempted to iterate over a response with no body");return new F$(H1($.body),Z)}}class M$ extends c{create($,Z){let{betas:X,...z}=$;return this._client.post("/v1/messages/batches?beta=true",{body:z,...Z,headers:{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}retrieve($,Z={},X){if(z0(Z))return this.retrieve($,{},Z);let{betas:z}=Z;return this._client.get(`/v1/messages/batches/${$}?beta=true`,{...X,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}list($={},Z){if(z0($))return this.list({},$);let{betas:X,...z}=$;return this._client.getAPIList("/v1/messages/batches?beta=true",V1,{query:z,...Z,headers:{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}delete($,Z={},X){if(z0(Z))return this.delete($,{},Z);let{betas:z}=Z;return this._client.delete(`/v1/messages/batches/${$}?beta=true`,{...X,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}cancel($,Z={},X){if(z0(Z))return this.cancel($,{},Z);let{betas:z}=Z;return this._client.post(`/v1/messages/batches/${$}/cancel?beta=true`,{...X,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}async results($,Z={},X){if(z0(Z))return this.results($,{},Z);let z=await this.retrieve($);if(!z.results_url)throw new A(`No batch \`results_url\`; Has it finished processing? ${z.processing_status} - ${z.id}`);let{betas:q}=Z;return this._client.get(z.results_url,{...X,headers:{"anthropic-beta":[...q??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary",...X?.headers},stream:!0,__binaryResponse:!0})._thenUnwrap((G,J)=>F$.fromResponse(J.response,J.controller))}}class V1 extends F0{}M$.BetaMessageBatchesPage=V1;var SW=($)=>{let Z=0,X=[];while(Z<$.length){let z=$[Z];if(z==="\\"){Z++;continue}if(z==="{"){X.push({type:"brace",value:"{"}),Z++;continue}if(z==="}"){X.push({type:"brace",value:"}"}),Z++;continue}if(z==="["){X.push({type:"paren",value:"["}),Z++;continue}if(z==="]"){X.push({type:"paren",value:"]"}),Z++;continue}if(z===":"){X.push({type:"separator",value:":"}),Z++;continue}if(z===","){X.push({type:"delimiter",value:","}),Z++;continue}if(z==='"'){let Q="",Y=!1;z=$[++Z];while(z!=='"'){if(Z===$.length){Y=!0;break}if(z==="\\"){if(Z++,Z===$.length){Y=!0;break}Q+=z+$[Z],z=$[++Z]}else Q+=z,z=$[++Z]}if(z=$[++Z],!Y)X.push({type:"string",value:Q});continue}if(z&&/\s/.test(z)){Z++;continue}let G=/[0-9]/;if(z&&G.test(z)||z==="-"||z==="."){let Q="";if(z==="-")Q+=z,z=$[++Z];while(z&&G.test(z)||z===".")Q+=z,z=$[++Z];X.push({type:"number",value:Q});continue}let J=/[a-z]/i;if(z&&J.test(z)){let Q="";while(z&&J.test(z)){if(Z===$.length)break;Q+=z,z=$[++Z]}if(Q=="true"||Q=="false"||Q==="null")X.push({type:"name",value:Q});else{Z++;continue}continue}Z++}return X},O$=($)=>{if($.length===0)return $;let Z=$[$.length-1];switch(Z.type){case"separator":return $=$.slice(0,$.length-1),O$($);break;case"number":let X=Z.value[Z.value.length-1];if(X==="."||X==="-")return $=$.slice(0,$.length-1),O$($);case"string":let z=$[$.length-2];if(z?.type==="delimiter")return $=$.slice(0,$.length-1),O$($);else if(z?.type==="brace"&&z.value==="{")return $=$.slice(0,$.length-1),O$($);break;case"delimiter":return $=$.slice(0,$.length-1),O$($);break}return $},CW=($)=>{let Z=[];if($.map((X)=>{if(X.type==="brace")if(X.value==="{")Z.push("}");else Z.splice(Z.lastIndexOf("}"),1);if(X.type==="paren")if(X.value==="[")Z.push("]");else Z.splice(Z.lastIndexOf("]"),1)}),Z.length>0)Z.reverse().map((X)=>{if(X==="}")$.push({type:"brace",value:"}"});else if(X==="]")$.push({type:"paren",value:"]"})});return $},EW=($)=>{let Z="";return $.map((X)=>{switch(X.type){case"string":Z+='"'+X.value+'"';break;default:Z+=X.value;break}}),Z},i2=($)=>JSON.parse(EW(CW(O$(SW($)))));var a=function($,Z,X,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!q:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,X):q?q.value=X:Z.set($,X),X},N=function($,Z,X,z){if(X==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!z:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?z:X==="a"?z.call($):z?z.value:Z.get($)},q0,f0,K1,a2,B1,L1,n2,T1,M0,D1,s2,r2,w$,o2,t2,t9,RZ,e9,$5,Z5,X5,AZ,jZ="__json_buf";class _1{constructor(){q0.add(this),this.messages=[],this.receivedMessages=[],f0.set(this,void 0),this.controller=new AbortController,K1.set(this,void 0),a2.set(this,()=>{}),B1.set(this,()=>{}),L1.set(this,void 0),n2.set(this,()=>{}),T1.set(this,()=>{}),M0.set(this,{}),D1.set(this,!1),s2.set(this,!1),r2.set(this,!1),w$.set(this,!1),o2.set(this,void 0),t2.set(this,void 0),e9.set(this,($)=>{if(a(this,s2,!0,"f"),$ instanceof Error&&$.name==="AbortError")$=new i;if($ instanceof i)return a(this,r2,!0,"f"),this._emit("abort",$);if($ instanceof A)return this._emit("error",$);if($ instanceof Error){let Z=new A($.message);return Z.cause=$,this._emit("error",Z)}return this._emit("error",new A(String($)))}),a(this,K1,new Promise(($,Z)=>{a(this,a2,$,"f"),a(this,B1,Z,"f")}),"f"),a(this,L1,new Promise(($,Z)=>{a(this,n2,$,"f"),a(this,T1,Z,"f")}),"f"),N(this,K1,"f").catch(()=>{}),N(this,L1,"f").catch(()=>{})}get response(){return N(this,o2,"f")}get request_id(){return N(this,t2,"f")}async withResponse(){let $=await N(this,K1,"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 _1;return Z._run(()=>Z._fromReadableStream($)),Z}static createMessage($,Z,X){let z=new _1;for(let q of Z.messages)z._addMessageParam(q);return z._run(()=>z._createMessage($,{...Z,stream:!0},{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),z}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},N(this,e9,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,Z=!0){if(this.receivedMessages.push($),Z)this._emit("message",$)}async _createMessage($,Z,X){let z=X?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}N(this,q0,"m",$5).call(this);let{response:q,data:G}=await $.create({...Z,stream:!0},{...X,signal:this.controller.signal}).withResponse();this._connected(q);for await(let J of G)N(this,q0,"m",Z5).call(this,J);if(G.controller.signal?.aborted)throw new i;N(this,q0,"m",X5).call(this)}_connected($){if(this.ended)return;a(this,o2,$,"f"),a(this,t2,$?.headers.get("request-id"),"f"),N(this,a2,"f").call(this,$),this._emit("connect")}get ended(){return N(this,D1,"f")}get errored(){return N(this,s2,"f")}get aborted(){return N(this,r2,"f")}abort(){this.controller.abort()}on($,Z){return(N(this,M0,"f")[$]||(N(this,M0,"f")[$]=[])).push({listener:Z}),this}off($,Z){let X=N(this,M0,"f")[$];if(!X)return this;let z=X.findIndex((q)=>q.listener===Z);if(z>=0)X.splice(z,1);return this}once($,Z){return(N(this,M0,"f")[$]||(N(this,M0,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,X)=>{if(a(this,w$,!0,"f"),$!=="error")this.once("error",X);this.once($,Z)})}async done(){a(this,w$,!0,"f"),await N(this,L1,"f")}get currentMessage(){return N(this,f0,"f")}async finalMessage(){return await this.done(),N(this,q0,"m",t9).call(this)}async finalText(){return await this.done(),N(this,q0,"m",RZ).call(this)}_emit($,...Z){if(N(this,D1,"f"))return;if($==="end")a(this,D1,!0,"f"),N(this,n2,"f").call(this);let X=N(this,M0,"f")[$];if(X)N(this,M0,"f")[$]=X.filter((z)=>!z.once),X.forEach(({listener:z})=>z(...Z));if($==="abort"){let z=Z[0];if(!N(this,w$,"f")&&!X?.length)Promise.reject(z);N(this,B1,"f").call(this,z),N(this,T1,"f").call(this,z),this._emit("end");return}if($==="error"){let z=Z[0];if(!N(this,w$,"f")&&!X?.length)Promise.reject(z);N(this,B1,"f").call(this,z),N(this,T1,"f").call(this,z),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",N(this,q0,"m",t9).call(this))}async _fromReadableStream($,Z){let X=Z?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}N(this,q0,"m",$5).call(this),this._connected(null);let z=e.fromReadableStream($,this.controller);for await(let q of z)N(this,q0,"m",Z5).call(this,q);if(z.controller.signal?.aborted)throw new i;N(this,q0,"m",X5).call(this)}[(f0=new WeakMap,K1=new WeakMap,a2=new WeakMap,B1=new WeakMap,L1=new WeakMap,n2=new WeakMap,T1=new WeakMap,M0=new WeakMap,D1=new WeakMap,s2=new WeakMap,r2=new WeakMap,w$=new WeakMap,o2=new WeakMap,t2=new WeakMap,e9=new WeakMap,q0=new WeakSet,t9=function(){if(this.receivedMessages.length===0)throw new A("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},RZ=function(){if(this.receivedMessages.length===0)throw new A("stream ended without producing a Message with role=assistant");let Z=this.receivedMessages.at(-1).content.filter((X)=>X.type==="text").map((X)=>X.text);if(Z.length===0)throw new A("stream ended without producing a content block with type=text");return Z.join(" ")},$5=function(){if(this.ended)return;a(this,f0,void 0,"f")},Z5=function(Z){if(this.ended)return;let X=N(this,q0,"m",AZ).call(this,Z);switch(this._emit("streamEvent",Z,X),Z.type){case"content_block_delta":{let z=X.content.at(-1);switch(Z.delta.type){case"text_delta":{if(z.type==="text")this._emit("text",Z.delta.text,z.text||"");break}case"citations_delta":{if(z.type==="text")this._emit("citation",Z.delta.citation,z.citations??[]);break}case"input_json_delta":{if(z.type==="tool_use"&&z.input)this._emit("inputJson",Z.delta.partial_json,z.input);break}case"thinking_delta":{if(z.type==="thinking")this._emit("thinking",Z.delta.thinking,z.thinking);break}case"signature_delta":{if(z.type==="thinking")this._emit("signature",z.signature);break}default:NZ(Z.delta)}break}case"message_stop":{this._addMessageParam(X),this._addMessage(X,!0);break}case"content_block_stop":{this._emit("contentBlock",X.content.at(-1));break}case"message_start":{a(this,f0,X,"f");break}case"content_block_start":case"message_delta":break}},X5=function(){if(this.ended)throw new A("stream has ended, this shouldn't happen");let Z=N(this,f0,"f");if(!Z)throw new A("request ended without sending any chunks");return a(this,f0,void 0,"f"),Z},AZ=function(Z){let X=N(this,f0,"f");if(Z.type==="message_start"){if(X)throw new A(`Unexpected event order, got ${Z.type} before receiving "message_stop"`);return Z.message}if(!X)throw new A(`Unexpected event order, got ${Z.type} before "message_start"`);switch(Z.type){case"message_stop":return X;case"message_delta":return X.stop_reason=Z.delta.stop_reason,X.stop_sequence=Z.delta.stop_sequence,X.usage.output_tokens=Z.usage.output_tokens,X;case"content_block_start":return X.content.push(Z.content_block),X;case"content_block_delta":{let z=X.content.at(Z.index);switch(Z.delta.type){case"text_delta":{if(z?.type==="text")z.text+=Z.delta.text;break}case"citations_delta":{if(z?.type==="text")z.citations??(z.citations=[]),z.citations.push(Z.delta.citation);break}case"input_json_delta":{if(z?.type==="tool_use"){let q=z[jZ]||"";if(q+=Z.delta.partial_json,Object.defineProperty(z,jZ,{value:q,enumerable:!1,writable:!0}),q)z.input=i2(q)}break}case"thinking_delta":{if(z?.type==="thinking")z.thinking+=Z.delta.thinking;break}case"signature_delta":{if(z?.type==="thinking")z.signature=Z.delta.signature;break}default:NZ(Z.delta)}return X}case"content_block_stop":return X}},Symbol.asyncIterator)](){let $=[],Z=[],X=!1;return this.on("streamEvent",(z)=>{let q=Z.shift();if(q)q.resolve(z);else $.push(z)}),this.on("end",()=>{X=!0;for(let z of Z)z.resolve(void 0);Z.length=0}),this.on("abort",(z)=>{X=!0;for(let q of Z)q.reject(z);Z.length=0}),this.on("error",(z)=>{X=!0;for(let q of Z)q.reject(z);Z.length=0}),{next:async()=>{if(!$.length){if(X)return{value:void 0,done:!0};return new Promise((q,G)=>Z.push({resolve:q,reject:G})).then((q)=>q?{value:q,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 e(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function NZ($){}var SZ={"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-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025"};class e0 extends c{constructor(){super(...arguments);this.batches=new M$(this._client)}create($,Z){let{betas:X,...z}=$;if(z.model in SZ)console.warn(`The model '${z.model}' is deprecated and will reach end-of-life on ${SZ[z.model]}
|
|
197
|
-
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);return this._client.post("/v1/messages?beta=true",{body:z,timeout:this._client._options.timeout??(z.stream?600000:this._client._calculateNonstreamingTimeout(z.max_tokens)),...Z,headers:{...X?.toString()!=null?{"anthropic-beta":X?.toString()}:void 0,...Z?.headers},stream:$.stream??!1})}stream($,Z){return _1.createMessage(this,$,Z)}countTokens($,Z){let{betas:X,...z}=$;return this._client.post("/v1/messages/count_tokens?beta=true",{body:z,...Z,headers:{"anthropic-beta":[...X??[],"token-counting-2024-11-01"].toString(),...Z?.headers}})}}e0.Batches=M$;e0.BetaMessageBatchesPage=V1;class O0 extends c{constructor(){super(...arguments);this.models=new _$(this._client),this.messages=new e0(this._client)}}O0.Models=_$;O0.BetaModelInfosPage=W1;O0.Messages=e0;class P$ extends c{create($,Z){return this._client.post("/v1/complete",{body:$,timeout:this._client._options.timeout??600000,...Z,stream:$.stream??!1})}}class I$ extends c{create($,Z){return this._client.post("/v1/messages/batches",{body:$,...Z})}retrieve($,Z){return this._client.get(`/v1/messages/batches/${$}`,Z)}list($={},Z){if(z0($))return this.list({},$);return this._client.getAPIList("/v1/messages/batches",F1,{query:$,...Z})}delete($,Z){return this._client.delete(`/v1/messages/batches/${$}`,Z)}cancel($,Z){return this._client.post(`/v1/messages/batches/${$}/cancel`,Z)}async results($,Z){let X=await this.retrieve($);if(!X.results_url)throw new A(`No batch \`results_url\`; Has it finished processing? ${X.processing_status} - ${X.id}`);return this._client.get(X.results_url,{...Z,headers:{Accept:"application/binary",...Z?.headers},__binaryResponse:!0})._thenUnwrap((z,q)=>F$.fromResponse(q.response,q.controller))}}class F1 extends F0{}I$.MessageBatchesPage=F1;var n=function($,Z,X,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!q:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,X):q?q.value=X:Z.set($,X),X},S=function($,Z,X,z){if(X==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!z:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?z:X==="a"?z.call($):z?z.value:Z.get($)},G0,h0,M1,e2,O1,w1,$4,P1,w0,I1,Z4,X4,R$,z4,q4,z5,CZ,q5,G5,J5,Q5,EZ,bZ="__json_buf";class R1{constructor(){G0.add(this),this.messages=[],this.receivedMessages=[],h0.set(this,void 0),this.controller=new AbortController,M1.set(this,void 0),e2.set(this,()=>{}),O1.set(this,()=>{}),w1.set(this,void 0),$4.set(this,()=>{}),P1.set(this,()=>{}),w0.set(this,{}),I1.set(this,!1),Z4.set(this,!1),X4.set(this,!1),R$.set(this,!1),z4.set(this,void 0),q4.set(this,void 0),q5.set(this,($)=>{if(n(this,Z4,!0,"f"),$ instanceof Error&&$.name==="AbortError")$=new i;if($ instanceof i)return n(this,X4,!0,"f"),this._emit("abort",$);if($ instanceof A)return this._emit("error",$);if($ instanceof Error){let Z=new A($.message);return Z.cause=$,this._emit("error",Z)}return this._emit("error",new A(String($)))}),n(this,M1,new Promise(($,Z)=>{n(this,e2,$,"f"),n(this,O1,Z,"f")}),"f"),n(this,w1,new Promise(($,Z)=>{n(this,$4,$,"f"),n(this,P1,Z,"f")}),"f"),S(this,M1,"f").catch(()=>{}),S(this,w1,"f").catch(()=>{})}get response(){return S(this,z4,"f")}get request_id(){return S(this,q4,"f")}async withResponse(){let $=await S(this,M1,"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 R1;return Z._run(()=>Z._fromReadableStream($)),Z}static createMessage($,Z,X){let z=new R1;for(let q of Z.messages)z._addMessageParam(q);return z._run(()=>z._createMessage($,{...Z,stream:!0},{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),z}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},S(this,q5,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,Z=!0){if(this.receivedMessages.push($),Z)this._emit("message",$)}async _createMessage($,Z,X){let z=X?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}S(this,G0,"m",G5).call(this);let{response:q,data:G}=await $.create({...Z,stream:!0},{...X,signal:this.controller.signal}).withResponse();this._connected(q);for await(let J of G)S(this,G0,"m",J5).call(this,J);if(G.controller.signal?.aborted)throw new i;S(this,G0,"m",Q5).call(this)}_connected($){if(this.ended)return;n(this,z4,$,"f"),n(this,q4,$?.headers.get("request-id"),"f"),S(this,e2,"f").call(this,$),this._emit("connect")}get ended(){return S(this,I1,"f")}get errored(){return S(this,Z4,"f")}get aborted(){return S(this,X4,"f")}abort(){this.controller.abort()}on($,Z){return(S(this,w0,"f")[$]||(S(this,w0,"f")[$]=[])).push({listener:Z}),this}off($,Z){let X=S(this,w0,"f")[$];if(!X)return this;let z=X.findIndex((q)=>q.listener===Z);if(z>=0)X.splice(z,1);return this}once($,Z){return(S(this,w0,"f")[$]||(S(this,w0,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,X)=>{if(n(this,R$,!0,"f"),$!=="error")this.once("error",X);this.once($,Z)})}async done(){n(this,R$,!0,"f"),await S(this,w1,"f")}get currentMessage(){return S(this,h0,"f")}async finalMessage(){return await this.done(),S(this,G0,"m",z5).call(this)}async finalText(){return await this.done(),S(this,G0,"m",CZ).call(this)}_emit($,...Z){if(S(this,I1,"f"))return;if($==="end")n(this,I1,!0,"f"),S(this,$4,"f").call(this);let X=S(this,w0,"f")[$];if(X)S(this,w0,"f")[$]=X.filter((z)=>!z.once),X.forEach(({listener:z})=>z(...Z));if($==="abort"){let z=Z[0];if(!S(this,R$,"f")&&!X?.length)Promise.reject(z);S(this,O1,"f").call(this,z),S(this,P1,"f").call(this,z),this._emit("end");return}if($==="error"){let z=Z[0];if(!S(this,R$,"f")&&!X?.length)Promise.reject(z);S(this,O1,"f").call(this,z),S(this,P1,"f").call(this,z),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",S(this,G0,"m",z5).call(this))}async _fromReadableStream($,Z){let X=Z?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}S(this,G0,"m",G5).call(this),this._connected(null);let z=e.fromReadableStream($,this.controller);for await(let q of z)S(this,G0,"m",J5).call(this,q);if(z.controller.signal?.aborted)throw new i;S(this,G0,"m",Q5).call(this)}[(h0=new WeakMap,M1=new WeakMap,e2=new WeakMap,O1=new WeakMap,w1=new WeakMap,$4=new WeakMap,P1=new WeakMap,w0=new WeakMap,I1=new WeakMap,Z4=new WeakMap,X4=new WeakMap,R$=new WeakMap,z4=new WeakMap,q4=new WeakMap,q5=new WeakMap,G0=new WeakSet,z5=function(){if(this.receivedMessages.length===0)throw new A("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},CZ=function(){if(this.receivedMessages.length===0)throw new A("stream ended without producing a Message with role=assistant");let Z=this.receivedMessages.at(-1).content.filter((X)=>X.type==="text").map((X)=>X.text);if(Z.length===0)throw new A("stream ended without producing a content block with type=text");return Z.join(" ")},G5=function(){if(this.ended)return;n(this,h0,void 0,"f")},J5=function(Z){if(this.ended)return;let X=S(this,G0,"m",EZ).call(this,Z);switch(this._emit("streamEvent",Z,X),Z.type){case"content_block_delta":{let z=X.content.at(-1);switch(Z.delta.type){case"text_delta":{if(z.type==="text")this._emit("text",Z.delta.text,z.text||"");break}case"citations_delta":{if(z.type==="text")this._emit("citation",Z.delta.citation,z.citations??[]);break}case"input_json_delta":{if(z.type==="tool_use"&&z.input)this._emit("inputJson",Z.delta.partial_json,z.input);break}case"thinking_delta":{if(z.type==="thinking")this._emit("thinking",Z.delta.thinking,z.thinking);break}case"signature_delta":{if(z.type==="thinking")this._emit("signature",z.signature);break}default:yZ(Z.delta)}break}case"message_stop":{this._addMessageParam(X),this._addMessage(X,!0);break}case"content_block_stop":{this._emit("contentBlock",X.content.at(-1));break}case"message_start":{n(this,h0,X,"f");break}case"content_block_start":case"message_delta":break}},Q5=function(){if(this.ended)throw new A("stream has ended, this shouldn't happen");let Z=S(this,h0,"f");if(!Z)throw new A("request ended without sending any chunks");return n(this,h0,void 0,"f"),Z},EZ=function(Z){let X=S(this,h0,"f");if(Z.type==="message_start"){if(X)throw new A(`Unexpected event order, got ${Z.type} before receiving "message_stop"`);return Z.message}if(!X)throw new A(`Unexpected event order, got ${Z.type} before "message_start"`);switch(Z.type){case"message_stop":return X;case"message_delta":return X.stop_reason=Z.delta.stop_reason,X.stop_sequence=Z.delta.stop_sequence,X.usage.output_tokens=Z.usage.output_tokens,X;case"content_block_start":return X.content.push(Z.content_block),X;case"content_block_delta":{let z=X.content.at(Z.index);switch(Z.delta.type){case"text_delta":{if(z?.type==="text")z.text+=Z.delta.text;break}case"citations_delta":{if(z?.type==="text")z.citations??(z.citations=[]),z.citations.push(Z.delta.citation);break}case"input_json_delta":{if(z?.type==="tool_use"){let q=z[bZ]||"";if(q+=Z.delta.partial_json,Object.defineProperty(z,bZ,{value:q,enumerable:!1,writable:!0}),q)z.input=i2(q)}break}case"thinking_delta":{if(z?.type==="thinking")z.thinking+=Z.delta.thinking;break}case"signature_delta":{if(z?.type==="thinking")z.signature=Z.delta.signature;break}default:yZ(Z.delta)}return X}case"content_block_stop":return X}},Symbol.asyncIterator)](){let $=[],Z=[],X=!1;return this.on("streamEvent",(z)=>{let q=Z.shift();if(q)q.resolve(z);else $.push(z)}),this.on("end",()=>{X=!0;for(let z of Z)z.resolve(void 0);Z.length=0}),this.on("abort",(z)=>{X=!0;for(let q of Z)q.reject(z);Z.length=0}),this.on("error",(z)=>{X=!0;for(let q of Z)q.reject(z);Z.length=0}),{next:async()=>{if(!$.length){if(X)return{value:void 0,done:!0};return new Promise((q,G)=>Z.push({resolve:q,reject:G})).then((q)=>q?{value:q,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 e(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function yZ($){}class g0 extends c{constructor(){super(...arguments);this.batches=new I$(this._client)}create($,Z){if($.model in xZ)console.warn(`The model '${$.model}' is deprecated and will reach end-of-life on ${xZ[$.model]}
|
|
198
|
-
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);return this._client.post("/v1/messages",{body:$,timeout:this._client._options.timeout??($.stream?600000:this._client._calculateNonstreamingTimeout($.max_tokens)),...Z,stream:$.stream??!1})}stream($,Z){return R1.createMessage(this,$,Z)}countTokens($,Z){return this._client.post("/v1/messages/count_tokens",{body:$,...Z})}}var
|
|
189
|
+
`);if(U+=L.length+K.length,U>Y)throw Error(`Codebase source "${$}" exceeded hard cap of ${Y} bytes (matched glob ${Z.path}). Tighten the glob or raise the limit via maxBytes (and accept the request-size risk).`)}if(U>H)q?.(` warn: codebase source [${$}] is ${U} bytes (soft cap ${H}); consider tightening the glob`);let V=W.join("");return{id:$,source:Z.path,content:V,name:`${Q.length} file${Q.length===1?"":"s"} in ${Z.path}`,type:"codebase",auditTraps:z,matchedFiles:Q}}async function zZ($,Z,X,z){let{path:q,auditTraps:G}=g9(Z);if(typeof Z!=="string"&&Z.type==="codebase")return jU($,Z,X,G,z);if(IU(q))return PU($,q,G);return RU($,q,X,G)}async function Q1($,Z,X){let z=Object.entries($);return await Promise.all(z.map(([G,J])=>zZ(G,J,Z,X)))}async function qZ($){if(!AU(NU($,"pickled.yml")))return{matches:[],findings:[]};let Z=await B$($),X=Z.docs?.sources;if(!X||Object.keys(X).length===0)return{matches:[],findings:[]};let z={};for(let[Y,W]of Object.entries(X)){let U=typeof W==="string"?W:W.path;if(U.startsWith("http://")||U.startsWith("https://"))continue;z[Y]=W}if(Object.keys(z).length===0)return{matches:[],findings:[]};let q=[],G=new Map;for(let Y of Z.scenarios)for(let W of Y.traps??[])q.push(W),G.set(W,W.auditSeverity??"warning");if(q.length===0)return{matches:[],findings:[]};let J=await Q1(z,$),Q=[],H=[];for(let Y of J){let W=Y.auditTraps;if(W===!1)continue;let U=Array.isArray(W)?new Set(W):null,V=Y.type==="codebase"&&Y.matchedFiles?await CU(Y.matchedFiles,$,Y.source):[{path:Y.source,content:Y.content}];for(let B of V)for(let T of q){if(U?.has(T.id))continue;let{fired:K}=k0({response:B.content,traps:[T]}),L=K[0];if(!L)continue;let D=EU(B.content,L.index),_=G.get(T)??"warning";Q.push({sourceId:Y.id,sourcePath:B.path,trapId:L.id,trapReason:L.reason,matched:L.matched,snippet:L.snippet,line:D,severity:_}),H.push({severity:_,category:"trap-source-match",file:B.path,message:`source [${Y.id}] matches trap '${L.id}' ("${L.matched}") in ${B.path}. ${L.reason} Fix: remove the stale claim from the source, retire the trap if no longer relevant, set audit.traps: ['${L.id}'] on the source to suppress just this trap (other traps still apply), or set audit.traps: false if the source is deliberately stale or test-only.`})}}return{matches:Q,findings:H}}async function CU($,Z,X){let z=[];for(let q of $)try{let G=await Bun.file(SU(Z,q)).text();z.push({path:q,content:G})}catch{}return z}function EU($,Z){let X=1,z=Math.min(Z,$.length);for(let q=0;q<z;q++)if($[q]===`
|
|
190
|
+
`)X++;return X}var fU=["AGENTS.md","CLAUDE.md","CLAUDE.local.md","llms.txt","llms-full.txt",".claude/CLAUDE.md",".claude/rules/*.md","**/AGENTS.md","**/CLAUDE.md","**/CLAUDE.local.md","**/llms.txt","**/llms-full.txt","**/.claude/CLAUDE.md","**/.claude/rules/*.md"];async function N2($){let Z=P2($),X=u9(Z.targetRepo);if(!T$(X))throw Error(`targetRepo does not exist: ${X}`);let z=new Set;for(let Y of fU){let W=new GZ(Y);for await(let U of W.scan({cwd:X,dot:!0,onlyFiles:!1,followSymlinks:!1})){if(Z.ignore.some((T)=>new GZ(T).match(U)))continue;let V=v9(X,U),B=JZ(V);if(B.isFile()){z.add(U);continue}if(B.isSymbolicLink())try{if(yU(V).isFile())z.add(U)}catch{}}}let q=[];for(let Y of[...z].sort())q.push(await hU(X,Y,v9(X,Y),Z));let G=sU(q,Z),J=rU(q,G,Z),{matches:Q,findings:H}=await qZ(X);return{config:Z,files:q,pairs:G,findings:[...J,...H],sourceTrapMatches:Q}}async function hU($,Z,X,z){let G=JZ(X).isSymbolicLink(),J=null,Q=Z;if(G){let V=bU(X),B=xU(V)?V:u9(A2(X),V);if(J=B,T$(B))Q=kU($,B)}let H=G&&J&&T$(J)?J:X,Y=j2(H,"utf8"),W=(Y.match(/\n/g)??[]).length,U=Y.endsWith(`
|
|
191
|
+
`)?W:W+1;return{relPath:Z,absPath:X,isSymlink:G,symlinkTarget:J,realRelPath:Q,lineCount:U,brokenPathRefs:vU(Y,$,Z),brokenImports:mU(Y,A2(X)),unresolvedCommands:cU(Y,$,z.knownCommands),sections:iU(Y)}}function gU($){let Z=$.split("/");if(Z.length<2)return null;if(Z[0]==="packages"||Z[0]==="apps"||Z[0]==="shared")return`${Z[0]}/${Z[1]}`;if(Z[0]==="tests")return Z.slice(0,2).join("/");return null}function vU($,Z,X){let z=nU($),q=A2(X),G=gU(X),J=new Set,Q=/`([^`\n]{2,200})`/g,H;H=Q.exec(z);while(H!==null){let Y=H[1].trim().replace(/[#?].*$/,"");if(aU(Y)&&!uU(Z,Y,q,G).found)J.add(Y);H=Q.exec(z)}return[...J].sort()}function uU($,Z,X,z){let q=[Z];if(X&&X!==".")q.push(`${X}/${Z}`);if(z)q.push(`${z}/${Z}`);q.push(`packages/${Z}`,`apps/${Z}`,`shared/${Z}`);for(let G of q){let J=G.replace(/\/+/g,"/");if(T$(`${$}/${J}`))return{found:!0,resolvedAs:J}}return{found:!1}}function mU($,Z){let X=new Set,z=/@([\w./@~-]+\.md)/g,q;q=z.exec($);while(q!==null){let G=q[1];if(G.startsWith("~/")){q=z.exec($);continue}let J=G.startsWith("/")?G:u9(Z,G);if(!T$(J))X.add(G);q=z.exec($)}return[...X].sort()}var dU=["bun","pnpm","npm","yarn"],pU=new Set(["install","add","remove","update","i","audit","list","ls","why","outdated","exec","run","create","init","x"]),lU={bun:new Set(["build","test","link","unlink","upgrade"])};function cU($,Z,X){let z=new Set,q=v9(Z,"package.json"),G=new Set;if(T$(q))try{let Q=JSON.parse(j2(q,"utf8"));G=new Set(Object.keys(Q.scripts??{}))}catch{}let J=new Set(X.map((Q)=>Q.trim()));for(let Q of dU){let H=new RegExp(`\\b${Q}\\s+(?:run\\s+|--filter\\s+\\S+\\s+(?:run\\s+)?)?([a-zA-Z][\\w:.\\-]*)`,"g"),Y;Y=H.exec($);while(Y!==null){let W=Y[1];if(!G.has(W)&&!J.has(`${Q} ${W}`)&&!J.has(`${Q} run ${W}`)&&!pU.has(W)&&!lU[Q]?.has(W))z.add(`${Q} ${W}`);Y=H.exec($)}}return[...z].sort()}function iU($){let Z=$.split(`
|
|
192
|
+
`),X=[],z=null;if(Z.forEach((q,G)=>{if(/^##\s+/.test(q)){if(z)X.push({header:z.header,lines:G-z.start});z={header:q.replace(/^##\s+/,"").trim(),start:G}}}),z){let q=z;X.push({header:q.header,lines:Z.length-q.start})}return X.sort((q,G)=>G.lines-q.lines)}function aU($){if($.length===0||$.length>160)return!1;if(!$.includes("/"))return!1;if(/\s/.test($))return!1;if(/^https?:\/\//.test($))return!1;if(/[*?{}[\]<>]/.test($))return!1;if($.startsWith("@"))return!1;if($.startsWith("~/"))return!1;if(/^[a-z]+:\/\//i.test($))return!1;if(/^cdn\./.test($)||/^unpkg\./.test($)||/^npm\./.test($))return!1;if(/^\/[a-z]/.test($)&&/(?:icon|image|img|asset|file|path)/i.test($))return!1;if(/^(cd|pnpm|npm|yarn|bun|node|git|ls|cat|grep|find|sed|awk|mkdir|rm|mv|cp|echo|export|source|sudo|brew|docker|curl|wget)\b/.test($))return!1;return/[a-zA-Z0-9_.-]\/[a-zA-Z0-9_.-]/.test($)}function nU($){return $.replace(/```[\s\S]*?```/g,"")}function sU($,Z){let X=new Map;for(let G of $){let J=G.relPath.split("/").pop()??"";if(J!=="AGENTS.md"&&J!=="CLAUDE.md")continue;let Q=A2(G.relPath),H=X.get(Q)??{};if(J==="AGENTS.md")H.agents=G;if(J==="CLAUDE.md")H.claude=G;X.set(Q,H)}let z=new Set(Z.intentionalDifferentPairs),q=[];for(let[G,J]of X){let Q=!!J.agents,H=!!J.claude;if(!Q&&!H)continue;if(!Q||!H){q.push({dir:G,agentsExists:Q,claudeExists:H,classification:"single",detail:Q?"only AGENTS.md":"only CLAUDE.md"});continue}let{agents:Y,claude:W}=J,U=`${Y.relPath}:${W.relPath}`,V=`${W.relPath}:${Y.relPath}`;if(z.has(U)||z.has(V)){q.push({dir:G,agentsExists:Q,claudeExists:H,classification:"intentional-different",detail:`allowlisted: ${Y.lineCount}L vs ${W.lineCount}L`});continue}if(Y.isSymlink&&Y.symlinkTarget===W.absPath||W.isSymlink&&W.symlinkTarget===Y.absPath){let L=Y.isSymlink?"CLAUDE.md":"AGENTS.md";q.push({dir:G,agentsExists:Q,claudeExists:H,classification:"linked",detail:`canonical: ${L}`});continue}let T=j2(Y.absPath,"utf8"),K=j2(W.absPath,"utf8");if(T===K)q.push({dir:G,agentsExists:Q,claudeExists:H,classification:"unexpected-duplicate",detail:`byte-for-byte duplicate (${Y.lineCount}L), not symlinked`});else q.push({dir:G,agentsExists:Q,claudeExists:H,classification:"unexpected-duplicate",detail:`divergent (${Y.lineCount}L vs ${W.lineCount}L), not in intentional-different allowlist`})}return q.sort((G,J)=>G.dir.localeCompare(J.dir)),q}function rU($,Z,X){let z=[];for(let q of $){if(q.isSymlink)continue;for(let Q of q.brokenImports)z.push({severity:"error",category:"broken-import",file:q.relPath,message:`broken @-import: ${Q}`});for(let Q of q.brokenPathRefs)z.push({severity:"error",category:"broken-path-ref",file:q.relPath,message:`broken path reference: ${Q}`});for(let Q of q.unresolvedCommands)z.push({severity:"warning",category:"unresolved-command",file:q.relPath,message:`unresolved command: ${Q}`});let G=!q.relPath.includes("/"),J=G?X.budgets.rootLines:X.budgets.nestedWarnLines;if(q.lineCount>J)z.push({severity:"warning",category:"over-budget",file:q.relPath,message:`${q.lineCount} lines exceeds ${G?"root":"nested"} budget of ${J}`})}for(let q of Z)if(q.classification==="unexpected-duplicate"){let G=q.detail.startsWith("divergent")?"error":"warning";z.push({severity:G,category:G==="error"?"divergent-pair":"duplicate-pair",file:q.dir||"(root)",message:`AGENTS.md / CLAUDE.md ${q.detail}`})}return z}function _0($){let Z=$.confidence;if($.error)return{icon:"\u2717",label:"Error",confidence:Z,tone:"error"};if($.traps.fired.length>0)return{icon:"\u2717",label:"Trap fired",confidence:Z,tone:"error"};if($.answerable==="YES")return{icon:"\u2713",label:Z>=90?"Well grounded":"Grounded",confidence:Z,tone:"success"};if($.answerable==="PARTIAL")return{icon:"\u26A0",label:"Partially grounded",confidence:Z,tone:"warning"};return{icon:"\u2717",label:"Ungrounded",confidence:Z,tone:"error"}}function m9($){let Z=oU($);if(Z===null)return[];let X=[],z=/^\s*-\s+\[([^\]]+)\]\s*(.*)$/gm,q=z.exec(Z);while(q!==null)X.push({id:q[1].trim(),note:q[2].trim()||void 0}),q=z.exec(Z);return X}function oU($){let X=/^##\s+Sources\s*$/im.exec($);if(!X)return null;let z=X.index+X[0].length,q=$.slice(z),G=/^##\s+/m.exec(q);return G?q.slice(0,G.index):q}function D$($){let Z=m9($.response),X=new Set(Z.map((V)=>V.id)),z=new Set($.registeredIds),q=new Set($.requiredSources),G=[...X],J=[...q].filter((V)=>!X.has(V)),Q=[...X].filter((V)=>!z.has(V)),H=[...q],Y,W,U;if(G.length===0)Y="NO",W=0,U="No citations in response";else if(Q.length===G.length)Y="NO",W=0,U=`All cited sources are unknown: ${Q.join(", ")}`;else if(J.length===0&&Q.length===0)Y="YES",W=100,U=H.length>0?`All required sources cited: ${H.join(", ")}`:`Cited registered sources: ${G.join(", ")}`;else{Y="PARTIAL";let V=H.length>0?H.length:1,B=H.length-J.length,T=H.length>0?B/V*100:60,K=Q.length*15;W=Math.max(0,Math.min(100,Math.round(T-K)));let L=[];if(J.length>0)L.push(`missing: ${J.join(", ")}`);if(Q.length>0)L.push(`unknown: ${Q.join(", ")}`);U=L.join("; ")}return{answerable:Y,confidence:W,reason:U,citations:{cited:G,required:H,missing:J,unknown:Q}}}function S2($){let Z=$.expected,X=(Z?.includes??[]).map((J)=>({value:J,satisfied:$.response.includes(J)})),z=(Z?.excludes??[]).map((J)=>({value:J,satisfied:!$.response.includes(J)})),q=X.filter((J)=>J.satisfied).length+z.filter((J)=>J.satisfied).length,G=X.length+z.length;return{includes:X,excludes:z,satisfied:q,total:G}}var r0="0.40.1";var QZ=!1,o0=void 0,d9=void 0,tU=void 0,eU=void 0,$W=void 0,YZ=void 0,ZW=void 0,C2=void 0,p9=void 0,HZ=void 0,l9=void 0,E2=void 0,UZ=void 0;function WZ($,Z={auto:!1}){if(QZ)throw Error(`you must \`import '@anthropic-ai/sdk/shims/${$.kind}'\` before importing anything else from @anthropic-ai/sdk`);if(o0)throw Error(`can't \`import '@anthropic-ai/sdk/shims/${$.kind}'\` after \`import '@anthropic-ai/sdk/shims/${o0}'\``);QZ=Z.auto,o0=$.kind,d9=$.fetch,tU=$.Request,eU=$.Response,$W=$.Headers,YZ=$.FormData,ZW=$.Blob,C2=$.File,p9=$.ReadableStream,HZ=$.getMultipartRequestOptions,l9=$.getDefaultAgent,E2=$.fileFromPath,UZ=$.isFsReadStream}class c9{constructor($){this.body=$}get[Symbol.toStringTag](){return"MultipartBody"}}function VZ({manuallyImported:$}={}){let Z=$?"You may need to use polyfills":"Add one of these imports before your first `import \u2026 from '@anthropic-ai/sdk'`:\n- `import '@anthropic-ai/sdk/shims/node'` (if you're running on Node)\n- `import '@anthropic-ai/sdk/shims/web'` (otherwise)\n",X,z,q,G;try{X=fetch,z=Request,q=Response,G=Headers}catch(J){throw Error(`this environment is missing the following Web Fetch API type: ${J.message}. ${Z}`)}return{kind:"web",fetch:X,Request:z,Response:q,Headers:G,FormData:typeof FormData<"u"?FormData:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${Z}`)}},Blob:typeof Blob<"u"?Blob:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${Z}`)}},File:typeof File<"u"?File:class{constructor(){throw Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${Z}`)}},ReadableStream:typeof ReadableStream<"u"?ReadableStream:class{constructor(){throw Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${Z}`)}},getMultipartRequestOptions:async(J,Q)=>({...Q,body:new c9(J)}),getDefaultAgent:(J)=>{return},fileFromPath:()=>{throw Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/anthropics/anthropic-sdk-typescript#file-uploads")},isFsReadStream:(J)=>!1}}import{ReadStream as zW}from"fs";function KZ(){let $=VZ();function Z(X){return X instanceof zW}return{...$,isFsReadStream:Z}}var i9=()=>{if(!o0)WZ(KZ(),{auto:!0})};i9();class j extends Error{}class u extends j{constructor($,Z,X,z){super(`${u.makeMessage($,Z,X)}`);this.status=$,this.headers=z,this.request_id=z?.["request-id"],this.error=Z}static makeMessage($,Z,X){let z=Z?.message?typeof Z.message==="string"?Z.message:JSON.stringify(Z.message):Z?JSON.stringify(Z):X;if($&&z)return`${$} ${z}`;if($)return`${$} status code (no body)`;if(z)return z;return"(no status code or body)"}static generate($,Z,X,z){if(!$||!z)return new t0({message:X,cause:u2(Z)});let q=Z;if($===400)return new b2($,q,X,z);if($===401)return new y2($,q,X,z);if($===403)return new x2($,q,X,z);if($===404)return new k2($,q,X,z);if($===409)return new f2($,q,X,z);if($===422)return new h2($,q,X,z);if($===429)return new g2($,q,X,z);if($>=500)return new v2($,q,X,z);return new u($,q,X,z)}}class a extends u{constructor({message:$}={}){super(void 0,void 0,$||"Request was aborted.",void 0)}}class t0 extends u{constructor({message:$,cause:Z}){super(void 0,void 0,$||"Connection error.",void 0);if(Z)this.cause=Z}}class Y1 extends t0{constructor({message:$}={}){super({message:$??"Request timed out."})}}class b2 extends u{}class y2 extends u{}class x2 extends u{}class k2 extends u{}class f2 extends u{}class h2 extends u{}class g2 extends u{}class v2 extends u{}var m2=function($,Z,X,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!q:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,X):q?q.value=X:Z.set($,X),X},e0=function($,Z,X,z){if(X==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!z:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?z:X==="a"?z.call($):z?z.value:Z.get($)},o;class f0{constructor(){o.set(this,void 0),this.buffer=new Uint8Array,m2(this,o,null,"f")}decode($){if($==null)return[];let Z=$ instanceof ArrayBuffer?new Uint8Array($):typeof $==="string"?new TextEncoder().encode($):$,X=new Uint8Array(this.buffer.length+Z.length);X.set(this.buffer),X.set(Z,this.buffer.length),this.buffer=X;let z=[],q;while((q=GW(this.buffer,e0(this,o,"f")))!=null){if(q.carriage&&e0(this,o,"f")==null){m2(this,o,q.index,"f");continue}if(e0(this,o,"f")!=null&&(q.index!==e0(this,o,"f")+1||q.carriage)){z.push(this.decodeText(this.buffer.slice(0,e0(this,o,"f")-1))),this.buffer=this.buffer.slice(e0(this,o,"f")),m2(this,o,null,"f");continue}let G=e0(this,o,"f")!==null?q.preceding-1:q.preceding,J=this.decodeText(this.buffer.slice(0,G));z.push(J),this.buffer=this.buffer.slice(q.index),m2(this,o,null,"f")}return z}decodeText($){if($==null)return"";if(typeof $==="string")return $;if(typeof Buffer<"u"){if($ instanceof Buffer)return $.toString();if($ instanceof Uint8Array)return Buffer.from($).toString();throw new j(`Unexpected: received non-Uint8Array (${$.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder<"u"){if($ instanceof Uint8Array||$ instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode($);throw new j(`Unexpected: received non-Uint8Array/ArrayBuffer (${$.constructor.name}) in a web platform. Please report this error.`)}throw new j("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length)return[];return this.decode(`
|
|
193
|
+
`)}}o=new WeakMap;f0.NEWLINE_CHARS=new Set([`
|
|
194
|
+
`,"\r"]);f0.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function GW($,Z){for(let q=Z??0;q<$.length;q++){if($[q]===10)return{preceding:q,index:q+1,carriage:!1};if($[q]===13)return{preceding:q,index:q+1,carriage:!0}}return null}function BZ($){for(let z=0;z<$.length-1;z++){if($[z]===10&&$[z+1]===10)return z+2;if($[z]===13&&$[z+1]===13)return z+2;if($[z]===13&&$[z+1]===10&&z+3<$.length&&$[z+2]===13&&$[z+3]===10)return z+4}return-1}function H1($){if($[Symbol.asyncIterator])return $;let Z=$.getReader();return{async next(){try{let X=await Z.read();if(X?.done)Z.releaseLock();return X}catch(X){throw Z.releaseLock(),X}},async return(){let X=Z.cancel();return Z.releaseLock(),await X,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}class t{constructor($,Z){this.iterator=$,this.controller=Z}static fromSSEResponse($,Z){let X=!1;async function*z(){if(X)throw Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let q=!1;try{for await(let G of JW($,Z)){if(G.event==="completion")try{yield JSON.parse(G.data)}catch(J){throw console.error("Could not parse message into JSON:",G.data),console.error("From chunk:",G.raw),J}if(G.event==="message_start"||G.event==="message_delta"||G.event==="message_stop"||G.event==="content_block_start"||G.event==="content_block_delta"||G.event==="content_block_stop")try{yield JSON.parse(G.data)}catch(J){throw console.error("Could not parse message into JSON:",G.data),console.error("From chunk:",G.raw),J}if(G.event==="ping")continue;if(G.event==="error")throw u.generate(void 0,`SSE Error: ${G.data}`,G.data,a9($.headers))}q=!0}catch(G){if(G instanceof Error&&G.name==="AbortError")return;throw G}finally{if(!q)Z.abort()}}return new t(z,Z)}static fromReadableStream($,Z){let X=!1;async function*z(){let G=new f0,J=H1($);for await(let Q of J)for(let H of G.decode(Q))yield H;for(let Q of G.flush())yield Q}async function*q(){if(X)throw Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");X=!0;let G=!1;try{for await(let J of z()){if(G)continue;if(J)yield JSON.parse(J)}G=!0}catch(J){if(J instanceof Error&&J.name==="AbortError")return;throw J}finally{if(!G)Z.abort()}}return new t(q,Z)}[Symbol.asyncIterator](){return this.iterator()}tee(){let $=[],Z=[],X=this.iterator(),z=(q)=>{return{next:()=>{if(q.length===0){let G=X.next();$.push(G),Z.push(G)}return q.shift()}}};return[new t(()=>z($),this.controller),new t(()=>z(Z),this.controller)]}toReadableStream(){let $=this,Z,X=new TextEncoder;return new p9({async start(){Z=$[Symbol.asyncIterator]()},async pull(z){try{let{value:q,done:G}=await Z.next();if(G)return z.close();let J=X.encode(JSON.stringify(q)+`
|
|
195
|
+
`);z.enqueue(J)}catch(q){z.error(q)}},async cancel(){await Z.return?.()}})}}async function*JW($,Z){if(!$.body)throw Z.abort(),new j("Attempted to iterate over a response with no body");let X=new LZ,z=new f0,q=H1($.body);for await(let G of QW(q))for(let J of z.decode(G)){let Q=X.decode(J);if(Q)yield Q}for(let G of z.flush()){let J=X.decode(G);if(J)yield J}}async function*QW($){let Z=new Uint8Array;for await(let X of $){if(X==null)continue;let z=X instanceof ArrayBuffer?new Uint8Array(X):typeof X==="string"?new TextEncoder().encode(X):X,q=new Uint8Array(Z.length+z.length);q.set(Z),q.set(z,Z.length),Z=q;let G;while((G=BZ(Z))!==-1)yield Z.slice(0,G),Z=Z.slice(G)}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 q={event:this.event,data:this.data.join(`
|
|
196
|
+
`),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],q}if(this.chunks.push($),$.startsWith(":"))return null;let[Z,X,z]=YW($,":");if(z.startsWith(" "))z=z.substring(1);if(Z==="event")this.event=z;else if(Z==="data")this.data.push(z);return null}}function YW($,Z){let X=$.indexOf(Z);if(X!==-1)return[$.substring(0,X),Z,$.substring(X+Z.length)];return[$,"",""]}var HW=($)=>$!=null&&typeof $==="object"&&typeof $.url==="string"&&typeof $.blob==="function",UW=($)=>$!=null&&typeof $==="object"&&typeof $.name==="string"&&typeof $.lastModified==="number"&&U1($),U1=($)=>$!=null&&typeof $==="object"&&typeof $.size==="number"&&typeof $.type==="string"&&typeof $.text==="function"&&typeof $.slice==="function"&&typeof $.arrayBuffer==="function";async function TZ($,Z,X){if($=await $,UW($))return $;if(HW($)){let q=await $.blob();Z||(Z=new URL($.url).pathname.split(/[\\/]/).pop()??"unknown_file");let G=U1(q)?[await q.arrayBuffer()]:[q];return new C2(G,Z,X)}let z=await WW($);if(Z||(Z=KW($)??"unknown_file"),!X?.type){let q=z[0]?.type;if(typeof q==="string")X={...X,type:q}}return new C2(z,Z,X)}async function WW($){let Z=[];if(typeof $==="string"||ArrayBuffer.isView($)||$ instanceof ArrayBuffer)Z.push($);else if(U1($))Z.push(await $.arrayBuffer());else if(BW($))for await(let X of $)Z.push(X);else throw Error(`Unexpected data type: ${typeof $}; constructor: ${$?.constructor?.name}; props: ${VW($)}`);return Z}function VW($){return`[${Object.getOwnPropertyNames($).map((X)=>`"${X}"`).join(", ")}]`}function KW($){return n9($.name)||n9($.filename)||n9($.path)?.split(/[\\/]/).pop()}var n9=($)=>{if(typeof $==="string")return $;if(typeof Buffer<"u"&&$ instanceof Buffer)return String($);return},BW=($)=>$!=null&&typeof $==="object"&&typeof $[Symbol.asyncIterator]==="function",s9=($)=>$&&typeof $==="object"&&$.body&&$[Symbol.toStringTag]==="MultipartBody";var TW=function($,Z,X,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!q:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,X):q?q.value=X:Z.set($,X),X},DW=function($,Z,X,z){if(X==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!z:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?z:X==="a"?z.call($):z?z.value:Z.get($)},d2;i9();async function OZ($){let{response:Z}=$;if($.options.stream){if(_$("response",Z.status,Z.url,Z.headers,Z.body),$.options.__streamClass)return $.options.__streamClass.fromSSEResponse(Z,$.controller);return t.fromSSEResponse(Z,$.controller)}if(Z.status===204)return null;if($.options.__binaryResponse)return Z;let z=Z.headers.get("content-type")?.split(";")[0]?.trim();if(z?.includes("application/json")||z?.endsWith("+json")){let J=await Z.json();return _$("response",Z.status,Z.url,Z.headers,J),wZ(J,Z)}let G=await Z.text();return _$("response",Z.status,Z.url,Z.headers,G),G}function wZ($,Z){if(!$||typeof $!=="object"||Array.isArray($))return $;return Object.defineProperty($,"_request_id",{value:Z.headers.get("request-id"),enumerable:!1})}class l2 extends Promise{constructor($,Z=OZ){super((X)=>{X(null)});this.responsePromise=$,this.parseResponse=Z}_thenUnwrap($){return new l2(this.responsePromise,async(Z)=>wZ($(await this.parseResponse(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);return this.parsedPromise}then($,Z){return this.parse().then($,Z)}catch($){return this.parse().catch($)}finally($){return this.parse().finally($)}}class o9{constructor({baseURL:$,maxRetries:Z=2,timeout:X=600000,httpAgent:z,fetch:q}){this.baseURL=$,this.maxRetries=r9("maxRetries",Z),this.timeout=r9("timeout",X),this.httpAgent=z,this.fetch=q??d9}authHeaders($){return{}}defaultHeaders($){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...OW(),...this.authHeaders($)}}validateHeaders($,Z){}defaultIdempotencyKey(){return`stainless-node-retry-${jW()}`}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,X){return this.request(Promise.resolve(X).then(async(z)=>{let q=z&&U1(z?.body)?new DataView(await z.body.arrayBuffer()):z?.body instanceof DataView?z.body:z?.body instanceof ArrayBuffer?new DataView(z.body):z&&ArrayBuffer.isView(z?.body)?new DataView(z.body.buffer):z?.body;return{method:$,path:Z,...z,body:q}}))}getAPIList($,Z,X){return this.requestAPIList(Z,{method:"get",path:$,...X})}calculateContentLength($){if(typeof $==="string"){if(typeof Buffer<"u")return Buffer.byteLength($,"utf8").toString();if(typeof TextEncoder<"u")return new TextEncoder().encode($).length.toString()}else if(ArrayBuffer.isView($))return $.byteLength.toString();return null}buildRequest($,{retryCount:Z=0}={}){let X={...$},{method:z,path:q,query:G,headers:J={}}=X,Q=ArrayBuffer.isView(X.body)||X.__binaryRequest&&typeof X.body==="string"?X.body:s9(X.body)?X.body.body:X.body?JSON.stringify(X.body,null,2):null,H=this.calculateContentLength(Q),Y=this.buildURL(q,G);if("timeout"in X)r9("timeout",X.timeout);X.timeout=X.timeout??this.timeout;let W=X.httpAgent??this.httpAgent??l9(Y),U=X.timeout+1000;if(typeof W?.options?.timeout==="number"&&U>(W.options.timeout??0))W.options.timeout=U;if(this.idempotencyHeader&&z!=="get"){if(!$.idempotencyKey)$.idempotencyKey=this.defaultIdempotencyKey();J[this.idempotencyHeader]=$.idempotencyKey}let V=this.buildHeaders({options:X,headers:J,contentLength:H,retryCount:Z});return{req:{method:z,...Q&&{body:Q},headers:V,...W&&{agent:W},signal:X.signal??null},url:Y,timeout:X.timeout}}buildHeaders({options:$,headers:Z,contentLength:X,retryCount:z}){let q={};if(X)q["content-length"]=X;let G=this.defaultHeaders($);if(MZ(q,G),MZ(q,Z),s9($.body)&&o0!=="node")delete q["content-type"];if(p2(G,"x-stainless-retry-count")===void 0&&p2(Z,"x-stainless-retry-count")===void 0)q["x-stainless-retry-count"]=String(z);if(p2(G,"x-stainless-timeout")===void 0&&p2(Z,"x-stainless-timeout")===void 0&&$.timeout)q["x-stainless-timeout"]=String(Math.trunc($.timeout/1000));return this.validateHeaders(q,Z),q}_calculateNonstreamingTimeout($){if(3600*$/128000>600)throw new j("Streaming is strongly recommended for operations that may take longer than 10 minutes. See https://github.com/anthropics/anthropic-sdk-python#streaming-responses for more details");return 600000}async prepareOptions($){}async prepareRequest($,{url:Z,options:X}){}parseHeaders($){return!$?{}:(Symbol.iterator in $)?Object.fromEntries(Array.from($).map((Z)=>[...Z])):{...$}}makeStatusError($,Z,X,z){return u.generate($,Z,X,z)}request($,Z=null){return new l2(this.makeRequest($,Z))}async makeRequest($,Z){let X=await $,z=X.maxRetries??this.maxRetries;if(Z==null)Z=z;await this.prepareOptions(X);let{req:q,url:G,timeout:J}=this.buildRequest(X,{retryCount:z-Z});if(await this.prepareRequest(q,{url:G,options:X}),_$("request",G,X,q.headers),X.signal?.aborted)throw new a;let Q=new AbortController,H=await this.fetchWithTimeout(G,q,J,Q).catch(u2);if(H instanceof Error){if(X.signal?.aborted)throw new a;if(Z)return this.retryRequest(X,Z);if(H.name==="AbortError")throw new Y1;throw new t0({cause:H})}let Y=a9(H.headers);if(!H.ok){if(Z&&this.shouldRetry(H)){let K=`retrying, ${Z} attempts remaining`;return _$(`response (error; ${K})`,H.status,G,Y),this.retryRequest(X,Z,Y)}let W=await H.text().catch((K)=>u2(K).message),U=wW(W),V=U?void 0:W;throw _$(`response (error; ${Z?"(error; no more retries left)":"(error; not retryable)"})`,H.status,G,Y,V),this.makeStatusError(H.status,U,V,Y)}return{response:H,options:X,controller:Q}}requestAPIList($,Z){let X=this.makeRequest(Z,null);return new IZ(this,X,$)}buildURL($,Z){let X=PW($)?new URL($):new URL(this.baseURL+(this.baseURL.endsWith("/")&&$.startsWith("/")?$.slice(1):$)),z=this.defaultQuery();if(!PZ(z))Z={...z,...Z};if(typeof Z==="object"&&Z&&!Array.isArray(Z))X.search=this.stringifyQuery(Z);return X.toString()}stringifyQuery($){return Object.entries($).filter(([Z,X])=>typeof X<"u").map(([Z,X])=>{if(typeof X==="string"||typeof X==="number"||typeof X==="boolean")return`${encodeURIComponent(Z)}=${encodeURIComponent(X)}`;if(X===null)return`${encodeURIComponent(Z)}=`;throw new j(`Cannot stringify type ${typeof X}; 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("&")}async fetchWithTimeout($,Z,X,z){let{signal:q,...G}=Z||{};if(q)q.addEventListener("abort",()=>z.abort());let J=setTimeout(()=>z.abort(),X),Q={signal:z.signal,...G};if(Q.method)Q.method=Q.method.toUpperCase();let H=60000,Y=setTimeout(()=>{if(Q&&Q?.agent?.sockets){for(let W of Object.values(Q?.agent?.sockets).flat())if(W?.setKeepAlive)W.setKeepAlive(!0,H)}},H);return this.fetch.call(void 0,$,Q).finally(()=>{clearTimeout(J),clearTimeout(Y)})}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,X){let z,q=X?.["retry-after-ms"];if(q){let J=parseFloat(q);if(!Number.isNaN(J))z=J}let G=X?.["retry-after"];if(G&&!z){let J=parseFloat(G);if(!Number.isNaN(J))z=J*1000;else z=Date.parse(G)-Date.now()}if(!(z&&0<=z&&z<60000)){let J=$.maxRetries??this.maxRetries;z=this.calculateDefaultRetryTimeoutMillis(Z,J)}return await RW(z),this.makeRequest($,Z-1)}calculateDefaultRetryTimeoutMillis($,Z){let q=Z-$,G=Math.min(0.5*Math.pow(2,q),8),J=1-Math.random()*0.25;return G*J*1000}getUserAgent(){return`${this.constructor.name}/JS ${r0}`}}class t9{constructor($,Z,X,z){d2.set(this,void 0),TW(this,d2,$,"f"),this.options=z,this.response=Z,this.body=X}hasNextPage(){if(!this.getPaginatedItems().length)return!1;return this.nextPageInfo()!=null}async getNextPage(){let $=this.nextPageInfo();if(!$)throw new j("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");let Z={...this.options};if("params"in $&&typeof Z.query==="object")Z.query={...Z.query,...$.params};else if("url"in $){let X=[...Object.entries(Z.query||{}),...$.url.searchParams.entries()];for(let[z,q]of X)$.url.searchParams.set(z,q);Z.query=void 0,Z.path=$.url.toString()}return await DW(this,d2,"f").requestAPIList(this.constructor,Z)}async*iterPages(){let $=this;yield $;while($.hasNextPage())$=await $.getNextPage(),yield $}async*[(d2=new WeakMap,Symbol.asyncIterator)](){for await(let $ of this.iterPages())for(let Z of $.getPaginatedItems())yield Z}}class IZ extends l2{constructor($,Z,X){super(Z,async(z)=>new X($,z.response,await OZ(z),z.options))}async*[Symbol.asyncIterator](){let $=await this;for await(let Z of $)yield Z}}var a9=($)=>{return new Proxy(Object.fromEntries($.entries()),{get(Z,X){let z=X.toString();return Z[z.toLowerCase()]||Z[z]}})},_W={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},X0=($)=>{return typeof $==="object"&&$!==null&&!PZ($)&&Object.keys($).every((Z)=>RZ(_W,Z))},FW=()=>{if(typeof Deno<"u"&&Deno.build!=null)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":r0,"X-Stainless-OS":_Z(Deno.build.os),"X-Stainless-Arch":DZ(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":r0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if(Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]")return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":r0,"X-Stainless-OS":_Z(process.platform),"X-Stainless-Arch":DZ(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};let $=MW();if($)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":r0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${$.browser}`,"X-Stainless-Runtime-Version":$.version};return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":r0,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};function MW(){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:X}of $){let z=X.exec(navigator.userAgent);if(z){let q=z[1]||0,G=z[2]||0,J=z[3]||0;return{browser:Z,version:`${q}.${G}.${J}`}}}return null}var DZ=($)=>{if($==="x32")return"x32";if($==="x86_64"||$==="x64")return"x64";if($==="arm")return"arm";if($==="aarch64"||$==="arm64")return"arm64";if($)return`other:${$}`;return"unknown"},_Z=($)=>{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"},FZ,OW=()=>{return FZ??(FZ=FW())},wW=($)=>{try{return JSON.parse($)}catch(Z){return}},IW=/^[a-z][a-z0-9+.-]*:/i,PW=($)=>{return IW.test($)},RW=($)=>new Promise((Z)=>setTimeout(Z,$)),r9=($,Z)=>{if(typeof Z!=="number"||!Number.isInteger(Z))throw new j(`${$} must be an integer`);if(Z<0)throw new j(`${$} must be a positive integer`);return Z},u2=($)=>{if($ instanceof Error)return $;if(typeof $==="object"&&$!==null)try{return Error(JSON.stringify($))}catch{}return Error(String($))};var c2=($)=>{if(typeof process<"u")return process.env?.[$]?.trim()??void 0;if(typeof Deno<"u")return Deno.env?.get?.($)?.trim();return};function PZ($){if(!$)return!0;for(let Z in $)return!1;return!0}function RZ($,Z){return Object.prototype.hasOwnProperty.call($,Z)}function MZ($,Z){for(let X in Z){if(!RZ(Z,X))continue;let z=X.toLowerCase();if(!z)continue;let q=Z[X];if(q===null)delete $[z];else if(q!==void 0)$[z]=q}}function _$($,...Z){if(typeof process<"u"&&process?.env?.DEBUG==="true")console.log(`Anthropic:DEBUG:${$}`,...Z)}var jW=()=>{return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,($)=>{let Z=Math.random()*16|0;return($==="x"?Z:Z&3|8).toString(16)})},jZ=()=>{return typeof window<"u"&&typeof window.document<"u"&&typeof navigator<"u"},AW=($)=>{return typeof $?.get==="function"};var p2=($,Z)=>{let X=Z.toLowerCase();if(AW($)){let z=Z[0]?.toUpperCase()+Z.substring(1).replace(/([^\w])(\w)/g,(q,G,J)=>G+J.toUpperCase());for(let q of[Z,X,Z.toUpperCase(),z]){let G=$.get(q);if(G)return G}}for(let[z,q]of Object.entries($))if(z.toLowerCase()===X){if(Array.isArray(q)){if(q.length<=1)return q[0];return console.warn(`Received ${q.length} entries for the ${Z} header, using the first entry.`),q[0]}return q}return};class F0 extends t9{constructor($,Z,X,z){super($,Z,X,z);this.data=X.data||[],this.has_more=X.has_more||!1,this.first_id=X.first_id||null,this.last_id=X.last_id||null}getPaginatedItems(){return this.data??[]}hasNextPage(){if(this.has_more===!1)return!1;return super.hasNextPage()}nextPageParams(){let $=this.nextPageInfo();if(!$)return null;if("params"in $)return $.params;let Z=Object.fromEntries($.url.searchParams);if(!Object.keys(Z).length)return null;return Z}nextPageInfo(){if(this.options.query?.before_id){let Z=this.first_id;if(!Z)return null;return{params:{before_id:Z}}}let $=this.last_id;if(!$)return null;return{params:{after_id:$}}}}class c{constructor($){this._client=$}}class F$ extends c{retrieve($,Z){return this._client.get(`/v1/models/${$}?beta=true`,Z)}list($={},Z){if(X0($))return this.list({},$);return this._client.getAPIList("/v1/models?beta=true",W1,{query:$,...Z})}}class W1 extends F0{}F$.BetaModelInfosPage=W1;class M${constructor($,Z){this.iterator=$,this.controller=Z}async*decoder(){let $=new f0;for await(let Z of this.iterator)for(let X of $.decode(Z))yield JSON.parse(X);for(let Z of $.flush())yield JSON.parse(Z)}[Symbol.asyncIterator](){return this.decoder()}static fromResponse($,Z){if(!$.body)throw Z.abort(),new j("Attempted to iterate over a response with no body");return new M$(H1($.body),Z)}}class O$ extends c{create($,Z){let{betas:X,...z}=$;return this._client.post("/v1/messages/batches?beta=true",{body:z,...Z,headers:{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}retrieve($,Z={},X){if(X0(Z))return this.retrieve($,{},Z);let{betas:z}=Z;return this._client.get(`/v1/messages/batches/${$}?beta=true`,{...X,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}list($={},Z){if(X0($))return this.list({},$);let{betas:X,...z}=$;return this._client.getAPIList("/v1/messages/batches?beta=true",V1,{query:z,...Z,headers:{"anthropic-beta":[...X??[],"message-batches-2024-09-24"].toString(),...Z?.headers}})}delete($,Z={},X){if(X0(Z))return this.delete($,{},Z);let{betas:z}=Z;return this._client.delete(`/v1/messages/batches/${$}?beta=true`,{...X,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}cancel($,Z={},X){if(X0(Z))return this.cancel($,{},Z);let{betas:z}=Z;return this._client.post(`/v1/messages/batches/${$}/cancel?beta=true`,{...X,headers:{"anthropic-beta":[...z??[],"message-batches-2024-09-24"].toString(),...X?.headers}})}async results($,Z={},X){if(X0(Z))return this.results($,{},Z);let z=await this.retrieve($);if(!z.results_url)throw new j(`No batch \`results_url\`; Has it finished processing? ${z.processing_status} - ${z.id}`);let{betas:q}=Z;return this._client.get(z.results_url,{...X,headers:{"anthropic-beta":[...q??[],"message-batches-2024-09-24"].toString(),Accept:"application/binary",...X?.headers},stream:!0,__binaryResponse:!0})._thenUnwrap((G,J)=>M$.fromResponse(J.response,J.controller))}}class V1 extends F0{}O$.BetaMessageBatchesPage=V1;var EW=($)=>{let Z=0,X=[];while(Z<$.length){let z=$[Z];if(z==="\\"){Z++;continue}if(z==="{"){X.push({type:"brace",value:"{"}),Z++;continue}if(z==="}"){X.push({type:"brace",value:"}"}),Z++;continue}if(z==="["){X.push({type:"paren",value:"["}),Z++;continue}if(z==="]"){X.push({type:"paren",value:"]"}),Z++;continue}if(z===":"){X.push({type:"separator",value:":"}),Z++;continue}if(z===","){X.push({type:"delimiter",value:","}),Z++;continue}if(z==='"'){let Q="",H=!1;z=$[++Z];while(z!=='"'){if(Z===$.length){H=!0;break}if(z==="\\"){if(Z++,Z===$.length){H=!0;break}Q+=z+$[Z],z=$[++Z]}else Q+=z,z=$[++Z]}if(z=$[++Z],!H)X.push({type:"string",value:Q});continue}if(z&&/\s/.test(z)){Z++;continue}let G=/[0-9]/;if(z&&G.test(z)||z==="-"||z==="."){let Q="";if(z==="-")Q+=z,z=$[++Z];while(z&&G.test(z)||z===".")Q+=z,z=$[++Z];X.push({type:"number",value:Q});continue}let J=/[a-z]/i;if(z&&J.test(z)){let Q="";while(z&&J.test(z)){if(Z===$.length)break;Q+=z,z=$[++Z]}if(Q=="true"||Q=="false"||Q==="null")X.push({type:"name",value:Q});else{Z++;continue}continue}Z++}return X},w$=($)=>{if($.length===0)return $;let Z=$[$.length-1];switch(Z.type){case"separator":return $=$.slice(0,$.length-1),w$($);break;case"number":let X=Z.value[Z.value.length-1];if(X==="."||X==="-")return $=$.slice(0,$.length-1),w$($);case"string":let z=$[$.length-2];if(z?.type==="delimiter")return $=$.slice(0,$.length-1),w$($);else if(z?.type==="brace"&&z.value==="{")return $=$.slice(0,$.length-1),w$($);break;case"delimiter":return $=$.slice(0,$.length-1),w$($);break}return $},bW=($)=>{let Z=[];if($.map((X)=>{if(X.type==="brace")if(X.value==="{")Z.push("}");else Z.splice(Z.lastIndexOf("}"),1);if(X.type==="paren")if(X.value==="[")Z.push("]");else Z.splice(Z.lastIndexOf("]"),1)}),Z.length>0)Z.reverse().map((X)=>{if(X==="}")$.push({type:"brace",value:"}"});else if(X==="]")$.push({type:"paren",value:"]"})});return $},yW=($)=>{let Z="";return $.map((X)=>{switch(X.type){case"string":Z+='"'+X.value+'"';break;default:Z+=X.value;break}}),Z},i2=($)=>JSON.parse(yW(bW(w$(EW($)))));var n=function($,Z,X,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!q:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,X):q?q.value=X:Z.set($,X),X},S=function($,Z,X,z){if(X==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!z:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?z:X==="a"?z.call($):z?z.value:Z.get($)},z0,h0,K1,a2,B1,L1,n2,T1,M0,D1,s2,r2,I$,o2,t2,e9,AZ,$5,Z5,X5,z5,NZ,SZ="__json_buf";class _1{constructor(){z0.add(this),this.messages=[],this.receivedMessages=[],h0.set(this,void 0),this.controller=new AbortController,K1.set(this,void 0),a2.set(this,()=>{}),B1.set(this,()=>{}),L1.set(this,void 0),n2.set(this,()=>{}),T1.set(this,()=>{}),M0.set(this,{}),D1.set(this,!1),s2.set(this,!1),r2.set(this,!1),I$.set(this,!1),o2.set(this,void 0),t2.set(this,void 0),$5.set(this,($)=>{if(n(this,s2,!0,"f"),$ instanceof Error&&$.name==="AbortError")$=new a;if($ instanceof a)return n(this,r2,!0,"f"),this._emit("abort",$);if($ instanceof j)return this._emit("error",$);if($ instanceof Error){let Z=new j($.message);return Z.cause=$,this._emit("error",Z)}return this._emit("error",new j(String($)))}),n(this,K1,new Promise(($,Z)=>{n(this,a2,$,"f"),n(this,B1,Z,"f")}),"f"),n(this,L1,new Promise(($,Z)=>{n(this,n2,$,"f"),n(this,T1,Z,"f")}),"f"),S(this,K1,"f").catch(()=>{}),S(this,L1,"f").catch(()=>{})}get response(){return S(this,o2,"f")}get request_id(){return S(this,t2,"f")}async withResponse(){let $=await S(this,K1,"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 _1;return Z._run(()=>Z._fromReadableStream($)),Z}static createMessage($,Z,X){let z=new _1;for(let q of Z.messages)z._addMessageParam(q);return z._run(()=>z._createMessage($,{...Z,stream:!0},{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),z}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},S(this,$5,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,Z=!0){if(this.receivedMessages.push($),Z)this._emit("message",$)}async _createMessage($,Z,X){let z=X?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}S(this,z0,"m",Z5).call(this);let{response:q,data:G}=await $.create({...Z,stream:!0},{...X,signal:this.controller.signal}).withResponse();this._connected(q);for await(let J of G)S(this,z0,"m",X5).call(this,J);if(G.controller.signal?.aborted)throw new a;S(this,z0,"m",z5).call(this)}_connected($){if(this.ended)return;n(this,o2,$,"f"),n(this,t2,$?.headers.get("request-id"),"f"),S(this,a2,"f").call(this,$),this._emit("connect")}get ended(){return S(this,D1,"f")}get errored(){return S(this,s2,"f")}get aborted(){return S(this,r2,"f")}abort(){this.controller.abort()}on($,Z){return(S(this,M0,"f")[$]||(S(this,M0,"f")[$]=[])).push({listener:Z}),this}off($,Z){let X=S(this,M0,"f")[$];if(!X)return this;let z=X.findIndex((q)=>q.listener===Z);if(z>=0)X.splice(z,1);return this}once($,Z){return(S(this,M0,"f")[$]||(S(this,M0,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,X)=>{if(n(this,I$,!0,"f"),$!=="error")this.once("error",X);this.once($,Z)})}async done(){n(this,I$,!0,"f"),await S(this,L1,"f")}get currentMessage(){return S(this,h0,"f")}async finalMessage(){return await this.done(),S(this,z0,"m",e9).call(this)}async finalText(){return await this.done(),S(this,z0,"m",AZ).call(this)}_emit($,...Z){if(S(this,D1,"f"))return;if($==="end")n(this,D1,!0,"f"),S(this,n2,"f").call(this);let X=S(this,M0,"f")[$];if(X)S(this,M0,"f")[$]=X.filter((z)=>!z.once),X.forEach(({listener:z})=>z(...Z));if($==="abort"){let z=Z[0];if(!S(this,I$,"f")&&!X?.length)Promise.reject(z);S(this,B1,"f").call(this,z),S(this,T1,"f").call(this,z),this._emit("end");return}if($==="error"){let z=Z[0];if(!S(this,I$,"f")&&!X?.length)Promise.reject(z);S(this,B1,"f").call(this,z),S(this,T1,"f").call(this,z),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",S(this,z0,"m",e9).call(this))}async _fromReadableStream($,Z){let X=Z?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}S(this,z0,"m",Z5).call(this),this._connected(null);let z=t.fromReadableStream($,this.controller);for await(let q of z)S(this,z0,"m",X5).call(this,q);if(z.controller.signal?.aborted)throw new a;S(this,z0,"m",z5).call(this)}[(h0=new WeakMap,K1=new WeakMap,a2=new WeakMap,B1=new WeakMap,L1=new WeakMap,n2=new WeakMap,T1=new WeakMap,M0=new WeakMap,D1=new WeakMap,s2=new WeakMap,r2=new WeakMap,I$=new WeakMap,o2=new WeakMap,t2=new WeakMap,$5=new WeakMap,z0=new WeakSet,e9=function(){if(this.receivedMessages.length===0)throw new j("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},AZ=function(){if(this.receivedMessages.length===0)throw new j("stream ended without producing a Message with role=assistant");let Z=this.receivedMessages.at(-1).content.filter((X)=>X.type==="text").map((X)=>X.text);if(Z.length===0)throw new j("stream ended without producing a content block with type=text");return Z.join(" ")},Z5=function(){if(this.ended)return;n(this,h0,void 0,"f")},X5=function(Z){if(this.ended)return;let X=S(this,z0,"m",NZ).call(this,Z);switch(this._emit("streamEvent",Z,X),Z.type){case"content_block_delta":{let z=X.content.at(-1);switch(Z.delta.type){case"text_delta":{if(z.type==="text")this._emit("text",Z.delta.text,z.text||"");break}case"citations_delta":{if(z.type==="text")this._emit("citation",Z.delta.citation,z.citations??[]);break}case"input_json_delta":{if(z.type==="tool_use"&&z.input)this._emit("inputJson",Z.delta.partial_json,z.input);break}case"thinking_delta":{if(z.type==="thinking")this._emit("thinking",Z.delta.thinking,z.thinking);break}case"signature_delta":{if(z.type==="thinking")this._emit("signature",z.signature);break}default:CZ(Z.delta)}break}case"message_stop":{this._addMessageParam(X),this._addMessage(X,!0);break}case"content_block_stop":{this._emit("contentBlock",X.content.at(-1));break}case"message_start":{n(this,h0,X,"f");break}case"content_block_start":case"message_delta":break}},z5=function(){if(this.ended)throw new j("stream has ended, this shouldn't happen");let Z=S(this,h0,"f");if(!Z)throw new j("request ended without sending any chunks");return n(this,h0,void 0,"f"),Z},NZ=function(Z){let X=S(this,h0,"f");if(Z.type==="message_start"){if(X)throw new j(`Unexpected event order, got ${Z.type} before receiving "message_stop"`);return Z.message}if(!X)throw new j(`Unexpected event order, got ${Z.type} before "message_start"`);switch(Z.type){case"message_stop":return X;case"message_delta":return X.stop_reason=Z.delta.stop_reason,X.stop_sequence=Z.delta.stop_sequence,X.usage.output_tokens=Z.usage.output_tokens,X;case"content_block_start":return X.content.push(Z.content_block),X;case"content_block_delta":{let z=X.content.at(Z.index);switch(Z.delta.type){case"text_delta":{if(z?.type==="text")z.text+=Z.delta.text;break}case"citations_delta":{if(z?.type==="text")z.citations??(z.citations=[]),z.citations.push(Z.delta.citation);break}case"input_json_delta":{if(z?.type==="tool_use"){let q=z[SZ]||"";if(q+=Z.delta.partial_json,Object.defineProperty(z,SZ,{value:q,enumerable:!1,writable:!0}),q)z.input=i2(q)}break}case"thinking_delta":{if(z?.type==="thinking")z.thinking+=Z.delta.thinking;break}case"signature_delta":{if(z?.type==="thinking")z.signature=Z.delta.signature;break}default:CZ(Z.delta)}return X}case"content_block_stop":return X}},Symbol.asyncIterator)](){let $=[],Z=[],X=!1;return this.on("streamEvent",(z)=>{let q=Z.shift();if(q)q.resolve(z);else $.push(z)}),this.on("end",()=>{X=!0;for(let z of Z)z.resolve(void 0);Z.length=0}),this.on("abort",(z)=>{X=!0;for(let q of Z)q.reject(z);Z.length=0}),this.on("error",(z)=>{X=!0;for(let q of Z)q.reject(z);Z.length=0}),{next:async()=>{if(!$.length){if(X)return{value:void 0,done:!0};return new Promise((q,G)=>Z.push({resolve:q,reject:G})).then((q)=>q?{value:q,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 t(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function CZ($){}var EZ={"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-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025"};class $$ extends c{constructor(){super(...arguments);this.batches=new O$(this._client)}create($,Z){let{betas:X,...z}=$;if(z.model in EZ)console.warn(`The model '${z.model}' is deprecated and will reach end-of-life on ${EZ[z.model]}
|
|
197
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);return this._client.post("/v1/messages?beta=true",{body:z,timeout:this._client._options.timeout??(z.stream?600000:this._client._calculateNonstreamingTimeout(z.max_tokens)),...Z,headers:{...X?.toString()!=null?{"anthropic-beta":X?.toString()}:void 0,...Z?.headers},stream:$.stream??!1})}stream($,Z){return _1.createMessage(this,$,Z)}countTokens($,Z){let{betas:X,...z}=$;return this._client.post("/v1/messages/count_tokens?beta=true",{body:z,...Z,headers:{"anthropic-beta":[...X??[],"token-counting-2024-11-01"].toString(),...Z?.headers}})}}$$.Batches=O$;$$.BetaMessageBatchesPage=V1;class O0 extends c{constructor(){super(...arguments);this.models=new F$(this._client),this.messages=new $$(this._client)}}O0.Models=F$;O0.BetaModelInfosPage=W1;O0.Messages=$$;class P$ extends c{create($,Z){return this._client.post("/v1/complete",{body:$,timeout:this._client._options.timeout??600000,...Z,stream:$.stream??!1})}}class R$ extends c{create($,Z){return this._client.post("/v1/messages/batches",{body:$,...Z})}retrieve($,Z){return this._client.get(`/v1/messages/batches/${$}`,Z)}list($={},Z){if(X0($))return this.list({},$);return this._client.getAPIList("/v1/messages/batches",F1,{query:$,...Z})}delete($,Z){return this._client.delete(`/v1/messages/batches/${$}`,Z)}cancel($,Z){return this._client.post(`/v1/messages/batches/${$}/cancel`,Z)}async results($,Z){let X=await this.retrieve($);if(!X.results_url)throw new j(`No batch \`results_url\`; Has it finished processing? ${X.processing_status} - ${X.id}`);return this._client.get(X.results_url,{...Z,headers:{Accept:"application/binary",...Z?.headers},__binaryResponse:!0})._thenUnwrap((z,q)=>M$.fromResponse(q.response,q.controller))}}class F1 extends F0{}R$.MessageBatchesPage=F1;var s=function($,Z,X,z,q){if(z==="m")throw TypeError("Private method is not writable");if(z==="a"&&!q)throw TypeError("Private accessor was defined without a setter");if(typeof Z==="function"?$!==Z||!q:!Z.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return z==="a"?q.call($,X):q?q.value=X:Z.set($,X),X},C=function($,Z,X,z){if(X==="a"&&!z)throw TypeError("Private accessor was defined without a getter");if(typeof Z==="function"?$!==Z||!z:!Z.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?z:X==="a"?z.call($):z?z.value:Z.get($)},q0,g0,M1,e2,O1,w1,$4,I1,w0,P1,Z4,X4,j$,z4,q4,q5,bZ,G5,J5,Q5,Y5,yZ,xZ="__json_buf";class R1{constructor(){q0.add(this),this.messages=[],this.receivedMessages=[],g0.set(this,void 0),this.controller=new AbortController,M1.set(this,void 0),e2.set(this,()=>{}),O1.set(this,()=>{}),w1.set(this,void 0),$4.set(this,()=>{}),I1.set(this,()=>{}),w0.set(this,{}),P1.set(this,!1),Z4.set(this,!1),X4.set(this,!1),j$.set(this,!1),z4.set(this,void 0),q4.set(this,void 0),G5.set(this,($)=>{if(s(this,Z4,!0,"f"),$ instanceof Error&&$.name==="AbortError")$=new a;if($ instanceof a)return s(this,X4,!0,"f"),this._emit("abort",$);if($ instanceof j)return this._emit("error",$);if($ instanceof Error){let Z=new j($.message);return Z.cause=$,this._emit("error",Z)}return this._emit("error",new j(String($)))}),s(this,M1,new Promise(($,Z)=>{s(this,e2,$,"f"),s(this,O1,Z,"f")}),"f"),s(this,w1,new Promise(($,Z)=>{s(this,$4,$,"f"),s(this,I1,Z,"f")}),"f"),C(this,M1,"f").catch(()=>{}),C(this,w1,"f").catch(()=>{})}get response(){return C(this,z4,"f")}get request_id(){return C(this,q4,"f")}async withResponse(){let $=await C(this,M1,"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 R1;return Z._run(()=>Z._fromReadableStream($)),Z}static createMessage($,Z,X){let z=new R1;for(let q of Z.messages)z._addMessageParam(q);return z._run(()=>z._createMessage($,{...Z,stream:!0},{...X,headers:{...X?.headers,"X-Stainless-Helper-Method":"stream"}})),z}_run($){$().then(()=>{this._emitFinal(),this._emit("end")},C(this,G5,"f"))}_addMessageParam($){this.messages.push($)}_addMessage($,Z=!0){if(this.receivedMessages.push($),Z)this._emit("message",$)}async _createMessage($,Z,X){let z=X?.signal;if(z){if(z.aborted)this.controller.abort();z.addEventListener("abort",()=>this.controller.abort())}C(this,q0,"m",J5).call(this);let{response:q,data:G}=await $.create({...Z,stream:!0},{...X,signal:this.controller.signal}).withResponse();this._connected(q);for await(let J of G)C(this,q0,"m",Q5).call(this,J);if(G.controller.signal?.aborted)throw new a;C(this,q0,"m",Y5).call(this)}_connected($){if(this.ended)return;s(this,z4,$,"f"),s(this,q4,$?.headers.get("request-id"),"f"),C(this,e2,"f").call(this,$),this._emit("connect")}get ended(){return C(this,P1,"f")}get errored(){return C(this,Z4,"f")}get aborted(){return C(this,X4,"f")}abort(){this.controller.abort()}on($,Z){return(C(this,w0,"f")[$]||(C(this,w0,"f")[$]=[])).push({listener:Z}),this}off($,Z){let X=C(this,w0,"f")[$];if(!X)return this;let z=X.findIndex((q)=>q.listener===Z);if(z>=0)X.splice(z,1);return this}once($,Z){return(C(this,w0,"f")[$]||(C(this,w0,"f")[$]=[])).push({listener:Z,once:!0}),this}emitted($){return new Promise((Z,X)=>{if(s(this,j$,!0,"f"),$!=="error")this.once("error",X);this.once($,Z)})}async done(){s(this,j$,!0,"f"),await C(this,w1,"f")}get currentMessage(){return C(this,g0,"f")}async finalMessage(){return await this.done(),C(this,q0,"m",q5).call(this)}async finalText(){return await this.done(),C(this,q0,"m",bZ).call(this)}_emit($,...Z){if(C(this,P1,"f"))return;if($==="end")s(this,P1,!0,"f"),C(this,$4,"f").call(this);let X=C(this,w0,"f")[$];if(X)C(this,w0,"f")[$]=X.filter((z)=>!z.once),X.forEach(({listener:z})=>z(...Z));if($==="abort"){let z=Z[0];if(!C(this,j$,"f")&&!X?.length)Promise.reject(z);C(this,O1,"f").call(this,z),C(this,I1,"f").call(this,z),this._emit("end");return}if($==="error"){let z=Z[0];if(!C(this,j$,"f")&&!X?.length)Promise.reject(z);C(this,O1,"f").call(this,z),C(this,I1,"f").call(this,z),this._emit("end")}}_emitFinal(){if(this.receivedMessages.at(-1))this._emit("finalMessage",C(this,q0,"m",q5).call(this))}async _fromReadableStream($,Z){let X=Z?.signal;if(X){if(X.aborted)this.controller.abort();X.addEventListener("abort",()=>this.controller.abort())}C(this,q0,"m",J5).call(this),this._connected(null);let z=t.fromReadableStream($,this.controller);for await(let q of z)C(this,q0,"m",Q5).call(this,q);if(z.controller.signal?.aborted)throw new a;C(this,q0,"m",Y5).call(this)}[(g0=new WeakMap,M1=new WeakMap,e2=new WeakMap,O1=new WeakMap,w1=new WeakMap,$4=new WeakMap,I1=new WeakMap,w0=new WeakMap,P1=new WeakMap,Z4=new WeakMap,X4=new WeakMap,j$=new WeakMap,z4=new WeakMap,q4=new WeakMap,G5=new WeakMap,q0=new WeakSet,q5=function(){if(this.receivedMessages.length===0)throw new j("stream ended without producing a Message with role=assistant");return this.receivedMessages.at(-1)},bZ=function(){if(this.receivedMessages.length===0)throw new j("stream ended without producing a Message with role=assistant");let Z=this.receivedMessages.at(-1).content.filter((X)=>X.type==="text").map((X)=>X.text);if(Z.length===0)throw new j("stream ended without producing a content block with type=text");return Z.join(" ")},J5=function(){if(this.ended)return;s(this,g0,void 0,"f")},Q5=function(Z){if(this.ended)return;let X=C(this,q0,"m",yZ).call(this,Z);switch(this._emit("streamEvent",Z,X),Z.type){case"content_block_delta":{let z=X.content.at(-1);switch(Z.delta.type){case"text_delta":{if(z.type==="text")this._emit("text",Z.delta.text,z.text||"");break}case"citations_delta":{if(z.type==="text")this._emit("citation",Z.delta.citation,z.citations??[]);break}case"input_json_delta":{if(z.type==="tool_use"&&z.input)this._emit("inputJson",Z.delta.partial_json,z.input);break}case"thinking_delta":{if(z.type==="thinking")this._emit("thinking",Z.delta.thinking,z.thinking);break}case"signature_delta":{if(z.type==="thinking")this._emit("signature",z.signature);break}default:kZ(Z.delta)}break}case"message_stop":{this._addMessageParam(X),this._addMessage(X,!0);break}case"content_block_stop":{this._emit("contentBlock",X.content.at(-1));break}case"message_start":{s(this,g0,X,"f");break}case"content_block_start":case"message_delta":break}},Y5=function(){if(this.ended)throw new j("stream has ended, this shouldn't happen");let Z=C(this,g0,"f");if(!Z)throw new j("request ended without sending any chunks");return s(this,g0,void 0,"f"),Z},yZ=function(Z){let X=C(this,g0,"f");if(Z.type==="message_start"){if(X)throw new j(`Unexpected event order, got ${Z.type} before receiving "message_stop"`);return Z.message}if(!X)throw new j(`Unexpected event order, got ${Z.type} before "message_start"`);switch(Z.type){case"message_stop":return X;case"message_delta":return X.stop_reason=Z.delta.stop_reason,X.stop_sequence=Z.delta.stop_sequence,X.usage.output_tokens=Z.usage.output_tokens,X;case"content_block_start":return X.content.push(Z.content_block),X;case"content_block_delta":{let z=X.content.at(Z.index);switch(Z.delta.type){case"text_delta":{if(z?.type==="text")z.text+=Z.delta.text;break}case"citations_delta":{if(z?.type==="text")z.citations??(z.citations=[]),z.citations.push(Z.delta.citation);break}case"input_json_delta":{if(z?.type==="tool_use"){let q=z[xZ]||"";if(q+=Z.delta.partial_json,Object.defineProperty(z,xZ,{value:q,enumerable:!1,writable:!0}),q)z.input=i2(q)}break}case"thinking_delta":{if(z?.type==="thinking")z.thinking+=Z.delta.thinking;break}case"signature_delta":{if(z?.type==="thinking")z.signature=Z.delta.signature;break}default:kZ(Z.delta)}return X}case"content_block_stop":return X}},Symbol.asyncIterator)](){let $=[],Z=[],X=!1;return this.on("streamEvent",(z)=>{let q=Z.shift();if(q)q.resolve(z);else $.push(z)}),this.on("end",()=>{X=!0;for(let z of Z)z.resolve(void 0);Z.length=0}),this.on("abort",(z)=>{X=!0;for(let q of Z)q.reject(z);Z.length=0}),this.on("error",(z)=>{X=!0;for(let q of Z)q.reject(z);Z.length=0}),{next:async()=>{if(!$.length){if(X)return{value:void 0,done:!0};return new Promise((q,G)=>Z.push({resolve:q,reject:G})).then((q)=>q?{value:q,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 t(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function kZ($){}class v0 extends c{constructor(){super(...arguments);this.batches=new R$(this._client)}create($,Z){if($.model in fZ)console.warn(`The model '${$.model}' is deprecated and will reach end-of-life on ${fZ[$.model]}
|
|
198
|
+
Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.`);return this._client.post("/v1/messages",{body:$,timeout:this._client._options.timeout??($.stream?600000:this._client._calculateNonstreamingTimeout($.max_tokens)),...Z,stream:$.stream??!1})}stream($,Z){return R1.createMessage(this,$,Z)}countTokens($,Z){return this._client.post("/v1/messages/count_tokens",{body:$,...Z})}}var fZ={"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-2.1":"July 21st, 2025","claude-2.0":"July 21st, 2025"};v0.Batches=R$;v0.MessageBatchesPage=F1;class Z$ extends c{retrieve($,Z){return this._client.get(`/v1/models/${$}`,Z)}list($={},Z){if(X0($))return this.list({},$);return this._client.getAPIList("/v1/models",A$,{query:$,...Z})}}class A$ extends F0{}Z$.ModelInfosPage=A$;var hZ;class k extends o9{constructor({baseURL:$=c2("ANTHROPIC_BASE_URL"),apiKey:Z=c2("ANTHROPIC_API_KEY")??null,authToken:X=c2("ANTHROPIC_AUTH_TOKEN")??null,...z}={}){let q={apiKey:Z,authToken:X,...z,baseURL:$||"https://api.anthropic.com"};if(!q.dangerouslyAllowBrowser&&jZ())throw new j(`It looks like you're running in a browser-like environment.
|
|
199
199
|
|
|
200
200
|
This is disabled by default, as it risks exposing your secret API credentials to attackers.
|
|
201
201
|
If you understand the risks and have appropriate mitigations in place,
|
|
202
202
|
you can set the \`dangerouslyAllowBrowser\` option to \`true\`, e.g.,
|
|
203
203
|
|
|
204
204
|
new Anthropic({ apiKey, dangerouslyAllowBrowser: true });
|
|
205
|
-
`);super({baseURL:q.baseURL,timeout:q.timeout??600000,httpAgent:q.httpAgent,maxRetries:q.maxRetries,fetch:q.fetch});this.completions=new P$(this),this.messages=new
|
|
205
|
+
`);super({baseURL:q.baseURL,timeout:q.timeout??600000,httpAgent:q.httpAgent,maxRetries:q.maxRetries,fetch:q.fetch});this.completions=new P$(this),this.messages=new v0(this),this.models=new Z$(this),this.beta=new O0(this),this._options=q,this.apiKey=Z,this.authToken=X}defaultQuery(){return this._options.defaultQuery}defaultHeaders($){return{...super.defaultHeaders($),...this._options.dangerouslyAllowBrowser?{"anthropic-dangerous-direct-browser-access":"true"}:void 0,"anthropic-version":"2023-06-01",...this._options.defaultHeaders}}validateHeaders($,Z){if(this.apiKey&&$["x-api-key"])return;if(Z["x-api-key"]===null)return;if(this.authToken&&$.authorization)return;if(Z.authorization===null)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')}authHeaders($){return{...this.apiKeyAuth($),...this.bearerAuth($)}}apiKeyAuth($){if(this.apiKey==null)return{};return{"X-Api-Key":this.apiKey}}bearerAuth($){if(this.authToken==null)return{};return{Authorization:`Bearer ${this.authToken}`}}}hZ=k;k.Anthropic=hZ;k.HUMAN_PROMPT=`
|
|
206
206
|
|
|
207
|
-
Human:`;
|
|
207
|
+
Human:`;k.AI_PROMPT=`
|
|
208
208
|
|
|
209
|
-
Assistant:`;
|
|
209
|
+
Assistant:`;k.DEFAULT_TIMEOUT=600000;k.AnthropicError=j;k.APIError=u;k.APIConnectionError=t0;k.APIConnectionTimeoutError=Y1;k.APIUserAbortError=a;k.NotFoundError=k2;k.ConflictError=f2;k.RateLimitError=g2;k.BadRequestError=b2;k.AuthenticationError=y2;k.InternalServerError=v2;k.PermissionDeniedError=x2;k.UnprocessableEntityError=h2;k.toFile=TZ;k.fileFromPath=E2;k.Completions=P$;k.Messages=v0;k.Models=Z$;k.ModelInfosPage=A$;k.Beta=O0;var gZ=k;function N$($,Z,X){let z=Z.length>0?Z.map((J)=>`- ${J.id}: ${J.name} (${J.source})`).join(`
|
|
210
210
|
`):"(no sources provided)",q=Z.map((J)=>`<source id="${J.id}">
|
|
211
211
|
${J.content.trimEnd()}
|
|
212
212
|
</source>`).join(`
|
|
@@ -231,28 +231,28 @@ End your response with a "## Sources" section that lists every source you actual
|
|
|
231
231
|
Rules:
|
|
232
232
|
- Only cite IDs that appear in the inventory above. Do not invent IDs.
|
|
233
233
|
- If you cannot answer from the provided sources, say so explicitly and write an empty "## Sources" section (just the heading, no bullets).
|
|
234
|
-
- The "## Sources" heading must be the last heading in your response.`}
|
|
234
|
+
- The "## Sources" heading must be the last heading in your response.`}function G4($,Z){let X=Z&&Z.length>0?`
|
|
235
235
|
The canonical source for this question is: ${Z}
|
|
236
236
|
Use it as the primary reference; consult related authoritative sources if needed.`:`
|
|
237
237
|
Research the answer using authoritative sources you can reach with your tools.`;return`You are answering a question about the tool "${$.name}": ${$.description}.
|
|
238
238
|
|
|
239
239
|
Use the tools available to you to research the answer. Be specific and accurate; do not invent facts.${X}
|
|
240
240
|
|
|
241
|
-
If you cannot find the answer with the available tools, say so explicitly rather than guessing.`}class H5{category="cli";provider="claude-code";name;config;constructor($,Z){this.name=$,this.config=Z}async run($,Z){let{tool:X,cwd:z,context:q,docs:G,requiredSources:J,discovery:Q,restrictBuiltinTools:
|
|
241
|
+
If you cannot find the answer with the available tools, say so explicitly rather than guessing.`}class H5{category="api";provider="anthropic";name;config;clientFactory;constructor($,Z,X){this.name=$,this.config=Z,this.clientFactory=X??(()=>new gZ)}async run($,Z){let{tool:X,docs:z,requiredSources:q,discovery:G,webTools:J}=Z;if(!this.config.model)throw Error(`API target "${this.name}" missing 'model'. API targets must declare an explicit model.`);let Q=G?G4(X,G.sourceHint):N$(X,z,q),H=this.clientFactory(),Y=J?.search?[{type:"web_search_20250305",name:"web_search"}]:void 0,W=await H.messages.create({model:this.config.model,max_tokens:this.config.maxTokens??4096,temperature:this.config.temperature??0,system:Q,messages:[{role:"user",content:$}],...Y?{tools:Y}:{}}),U=hW(W.content),V=gW(W.content);return{response:U,allResponses:U?[{type:"final",text:U}]:[],toolsUsed:V,sources:[],metadata:{model:this.config.model,category:this.category,provider:this.provider,target:this.name}}}}function hW($){if(!Array.isArray($))return"";let Z=[];for(let X of $)if(X.type==="text"&&typeof X.text==="string")Z.push(X.text);return Z.join("")}function gW($){if(!Array.isArray($))return[];let Z=new Set;for(let X of $)if(X.type==="server_tool_use"&&typeof X.name==="string")Z.add(X.name);return Array.from(Z)}import{query as vW}from"@anthropic-ai/claude-agent-sdk";class U5{category="cli";provider="claude-code";name;config;constructor($,Z){this.name=$,this.config=Z}async run($,Z){let{tool:X,cwd:z,context:q,docs:G,requiredSources:J,discovery:Q,restrictBuiltinTools:H}=Z,Y=[],W=[],U=Q?G4(X,Q.sourceHint):N$(X,G,J),V={cwd:z,model:this.config.model??"sonnet",systemPrompt:U,allowedTools:q?.allowedTools??this.config.allowedTools??I4,disallowedTools:q?.disallowedTools??this.config.disallowedTools??P4,permissionMode:this.config.permissionMode??"acceptEdits",maxTurns:this.config.maxTurns??10,maxThinkingTokens:this.config.maxThinkingTokens,maxBudgetUsd:this.config.maxBudgetUsd,mcpServers:q?.mcpServers??this.config.mcpServers,settingSources:[]};if(H!==void 0)V.tools=H;let B=[],T="",K="";for await(let L of vW({prompt:$,options:V})){if(L.type==="assistant"){let D=L.message?.content;if(Array.isArray(D)){let _="";for(let M of D){if(M.type==="text")_+=M.text;if(M.type==="tool_use"){let w=M;if(!Y.includes(w.name))Y.push(w.name)}}if(_){let M=B.length===0?"initial":"intermediate";B.push({type:M,text:_}),T=_}}}if(L.type==="result"){let D=L;if(D.result)K=D.result}}if(B.length>0)B[B.length-1].type="final";return{response:K||T,allResponses:B,toolsUsed:Y,sources:W,metadata:{model:this.config.model??"sonnet",category:this.category,provider:this.provider,target:this.name}}}}import{randomUUID as uW}from"crypto";import{rm as mW}from"fs/promises";import{tmpdir as dW}from"os";import{join as pW}from"path";var lW="codex";class W5{category="cli";provider="codex-cli";name;config;spawnFn;readFileFn;binary;constructor($,Z,X={}){this.name=$,this.config=Z,this.spawnFn=X.spawn??nW,this.readFileFn=X.readFile??sW,this.binary=X.binary??lW}async run($,Z){let{tool:X,cwd:z,docs:q,requiredSources:G}=Z,J=this.config.model;if(!J)throw Error(`CodexCliTarget "${this.name}" requires an explicit model. Validation should have caught this at config load.`);let H=`${N$(X,q,G)}
|
|
242
242
|
|
|
243
243
|
---
|
|
244
244
|
|
|
245
|
-
${$}`,
|
|
246
|
-
`)){let q=z.trim();if(!q)continue;let G;try{G=JSON.parse(q)}catch{continue}let J=pW(G);if(J){let Y=Z.length===0?"initial":"intermediate";Z.push({type:Y,text:J})}let Q=lW(G);if(Q&&!X.includes(Q))X.push(Q)}return{allResponses:Z,toolsUsed:X}}function pW($){if(!$||typeof $!=="object")return null;let Z=$;if(typeof Z.message==="string")return Z.message;if(typeof Z.content==="string")return Z.content;if(typeof Z.type==="string"&&(Z.type==="assistant_message"||Z.type==="agent_message")&&typeof Z.text==="string")return Z.text;if(Z.type==="message"&&typeof Z.text==="string")return Z.text;return null}function lW($){if(!$||typeof $!=="object")return null;let Z=$;if(typeof Z.tool==="string")return Z.tool;if(typeof Z.type==="string"&&(Z.type==="tool_call"||Z.type==="function_call")&&typeof Z.name==="string")return Z.name;return null}var cW=async($,Z,X)=>{let z=Bun.spawn([$,...Z],{cwd:X.cwd,stdin:"pipe",stdout:"pipe",stderr:"pipe"});z.stdin.write(X.stdin),await z.stdin.end();let[q,G,J]=await Promise.all([new Response(z.stdout).text(),new Response(z.stderr).text(),z.exited]);return{exitCode:J,stdout:q,stderr:G}},iW=async($)=>{let Z=Bun.file($);if(!await Z.exists())throw Error(`Last-message file not found: ${$}`);return Z.text()};function G4($,Z){let X=Z??U0;switch(X.category){case"cli":return aW($,X);case"api":return nW($,X);case"ide":throw Error("IDE targets not yet implemented. Coming soon!");default:throw Error(`Unknown target category: ${X.category}`)}}function aW($,Z){switch(Z.provider){case"claude-code":return new H5($,Z);case"codex-cli":return new U5($,Z);case"gemini-cli":throw Error("Gemini CLI target not yet implemented. Coming soon!");case"amazon-q":throw Error("Amazon Q target not yet implemented. Coming soon!");default:throw Error(`Unknown CLI provider: ${Z.provider}`)}}function nW($,Z){switch(Z.provider){case"anthropic":return new Y5($,Z);case"openai":throw Error("OpenAI API target not yet implemented. Coming soon!");case"google":throw Error("Google API target not yet implemented. Coming soon!");default:throw Error(`Unknown API provider: ${Z.provider}`)}}var N$="default";function J4($,Z){if(!$||$===N$)return{name:N$,config:U0};if(Z?.[$])return{name:$,config:Z[$]};return console.warn(`Target "${$}" not found, using default`),{name:N$,config:U0}}function W5($,Z){if(!$||$===N$)return{name:N$,config:{}};if(Z?.[$])return{name:$,config:Z[$]};return console.warn(`Context "${$}" not found, using default`),{name:N$,config:{}}}var V5="__matrix__";function sW($){let Z=[],X=$.matrix?.target??["default"],z=$.matrix?.context??["default"];for(let q of $.scenarios){let G=q.context?[q.context]:z;if(q.matrix){for(let Q of G)Z.push({scenario:q,targetName:V5,contextName:Q});continue}let J=q.target?[q.target]:X;for(let Q of J)for(let Y of G)Z.push({scenario:q,targetName:Q,contextName:Y})}return Z}async function K5($,Z,X={}){let{onProgress:z}=X,q=[];if(Z.scenarios.length===0)throw Error("No scenarios defined in config");let G=Z.docs?.sources??{},J=[];if(Object.keys(G).length>0){z?.("Loading sources..."),J=await Q1(G,$.path);for(let W of J)z?.(` [${W.id}] ${W.name}`);z?.("")}let Q=J.map((W)=>W.id),Y=sW(Z);if(X.scenarioFilter&&X.scenarioFilter.length>0){let W=new Set(X.scenarioFilter);if(Y=Y.filter((U)=>W.has(U.scenario.name)),Y.length===0)throw Error(`No scenarios matched filter: ${[...W].join(", ")}. Declared scenarios: ${Z.scenarios.map((U)=>U.name).join(", ")}`)}let H="";for(let{scenario:W,targetName:U,contextName:V}of Y){let B=rW(U,V);if(W.name!==H){if(H)z?.("");z?.(`"${W.name}"`),H=W.name}try{let T=await oW(W,U,V,$,Z,J,Q,X);q.push(T);let K=B?B.padEnd(18):"";if(T.cells){z?.(` ${K} (matrix mode)`);for(let L of T.cells){let D=_0(L),O=` [${[L.cell.interface,L.cell.source??"-",L.cell.toolset].join(" \xB7 ")}]`.padEnd(40);z?.(`${O} ${D.icon} ${D.label} (${D.confidence}%)`)}}else if(T.surfaces){z?.(` ${K} (compare-surfaces mode)`);for(let L of T.surfaces){let D=_0(L),_=` [${L.active.join(",")}]`.padEnd(22);z?.(`${_} ${D.icon} ${D.label} (${D.confidence}%)`)}}else{let L=_0({answerable:T.answerable??"NO",confidence:T.confidence??0,traps:T.traps??{fired:[],avoided:[]},error:T.error});z?.(` ${K} ${L.icon} ${L.label} (${L.confidence}%)`)}}catch(T){let K=U==="default"?U0:Z.targets?.[U]??U0,L=W.requiredSources??[],D={scenario:W,answerable:"NO",confidence:0,response:"",reason:"Error during run",citations:{cited:[],required:L,missing:L,unknown:[]},traps:{fired:[],avoided:(W.traps??[]).map((O)=>O.id)},error:T instanceof Error?T.message:String(T),target:{target:U===V5?"matrix":U,category:K.category,provider:K.provider,model:K.model??"unknown"},context:{name:V}};q.push(D);let _=B?B.padEnd(18):"";z?.(` ${_} \u2717 Error`)}}return z?.(""),tW($,J,q)}function rW($,Z){if($==="default"&&Z==="default")return"";if(Z==="default")return`[${$}]`;return`[${$}/${Z}]`}async function oW($,Z,X,z,q,G,J,Q){if($.matrix&&Z===V5)return eW($,X,z,q,G,Q);let{config:Y}=J4(Z,q.targets),{config:H}=W5(X,q.contexts),W=Q.targetFactory?Q.targetFactory(Z,Y):G4(Z,Y);if($.compareSurfaces&&$.compareSurfaces.length>0){let w=[],R;for(let I of $.compareSurfaces){let C=new Set(I),M=G.filter((P0)=>C.has(P0.id)),p=($.requiredSources??[]).filter((P0)=>C.has(P0)),s=await W.run($.prompt,{tool:z,cwd:z.path,context:H,docs:M,requiredSources:p,onProgress:Q.onProgress}),k=T$({response:s.response,requiredSources:p,registeredIds:I}),o=x0({response:s.response,traps:$.traps??[]}),E$=o.fired.length>0,N1=E$?"NO":k.answerable,W4=E$?0:k.confidence,S1=E$?`Trap fired: ${o.fired.map((P0)=>`"${P0.id}" (${P0.reason})`).join("; ")}`:k.reason;w.push({active:I,answerable:N1,confidence:W4,response:s.response,reason:S1,citations:k.citations,traps:o,allResponses:s.allResponses}),R=s.metadata??R}return{scenario:$,answerable:null,confidence:null,response:null,reason:null,citations:null,traps:null,surfaces:w,target:R,context:{name:X}}}let U=$.requiredSources??[],V=await W.run($.prompt,{tool:z,cwd:z.path,context:H,docs:G,requiredSources:U,onProgress:Q.onProgress}),B=x0({response:V.response,traps:$.traps??[]}),T=B.fired.length>0,K=$.requiredSources!==void 0?T$({response:V.response,requiredSources:U,registeredIds:J}):null,L=$.expected!==void 0?S2({response:V.response,expected:$.expected}):null,D,_,O;if(T)D="NO",_=0,O=`Trap fired: ${B.fired.map((w)=>`"${w.id}" (${w.reason})`).join("; ")}`;else{let w=[],R=[];if(K)w.push({answerable:K.answerable,confidence:K.confidence}),R.push(K.reason);if(L){let I=L.total===0?100:Math.round(L.satisfied/L.total*100),C=I===100?"YES":I===0?"NO":"PARTIAL";w.push({answerable:C,confidence:I})}if(w.length===0)D="YES",_=100,O="No traps fired; no other contract declared";else{let I={YES:0,PARTIAL:1,NO:2};D=w.reduce((M,y)=>I[y.answerable]>I[M.answerable]?y:M).answerable,_=Math.round(w.reduce((M,y)=>M+y.confidence,0)/w.length),O=R.filter((M)=>M.length>0).join(" | ")}}return{scenario:$,answerable:D,confidence:_,response:V.response,reason:O,citations:K?K.citations:{cited:[],required:U,missing:[],unknown:[]},traps:B,target:V.metadata,context:{name:X},toolsUsed:V.toolsUsed,sources:V.sources,allResponses:V.allResponses}}function tW($,Z,X){let z=[];for(let Q of X){if(Q.surfaces){for(let Y of Q.surfaces)z.push({answerable:Y.answerable,confidence:Y.confidence});continue}if(Q.cells){for(let Y of Q.cells)z.push({answerable:Y.answerable,confidence:Y.confidence});continue}if(Q.answerable!==null&&Q.confidence!==null)z.push({answerable:Q.answerable,confidence:Q.confidence})}let q=z.length,G=z.filter((Q)=>Q.answerable==="YES"||Q.answerable==="PARTIAL").length,J=q>0?Math.round(z.reduce((Q,Y)=>{if(Y.answerable==="YES")return Q+Y.confidence;if(Y.answerable==="PARTIAL")return Q+Y.confidence*0.5;return Q},0)/q):0;return{tool:{name:$.name,description:$.description,path:$.path},docs:Z,scenarios:X,summary:{total:q,answered:G,unanswered:q-G,score:J}}}async function eW($,Z,X,z,q,G){let{config:J}=W5(Z,z.contexts),Q=$.matrix??{},Y=$.target??"default",H=Q.interfaces??[Y],W=Q.sources??[null],U=Q.toolsets??["none"],V=G.cellFilter??{},B=[],T;for(let L of H){if(V.interface&&V.interface!==L)continue;for(let D of W){if(V.source!==void 0&&V.source!==(D??""))continue;for(let _ of U){if(V.toolset&&V.toolset!==_)continue;let O=_==="none"?null:z.toolsets?.[_]??null,w=_!=="none"&&(O?.webSearch===!0||O?.webFetch===!0),R=_!=="none"&&O?.mcpServers?Object.keys(O.mcpServers):[],I=R.length>0,{config:C}=J4(L,z.targets);if(_!=="none"){if(w&&I)throw Error(`Toolset "${_}" mixes webSearch/webFetch with mcpServers; declare separate toolsets per shape so provenance can be attributed to one tool path.`);if(!w&&!I)throw Error(`Toolset "${_}" is declared but defines no runtime shape. Supported today: "none", web (webSearch/webFetch flags), MCP (mcpServers map). Other adapters (Firecrawl, native API search) land per release.`);if(C.provider!=="claude-code")throw Error(`Toolset "${_}" is implemented only on the claude-code interface. Interface "${L}" uses provider "${C.provider}"; rerun with a Claude Code interface or use toolset "none".`)}let M=[],y=[],p=[];if(w){if(O?.webSearch)M.push("WebSearch"),y.push("WebSearch"),p.push((j)=>j==="WebSearch");if(O?.webFetch)M.push("WebFetch"),y.push("WebFetch"),p.push((j)=>j==="WebFetch")}if(I)for(let j of R)M.push(`mcp__${j}__*`),p.push((d)=>d.startsWith(`mcp__${j}__`));let s=_==="none"?C:{...C,allowedTools:M,disallowedTools:[],mcpServers:I?O?.mcpServers:void 0,maxTurns:Math.max(C.maxTurns??0,15)},k=G.targetFactory?G.targetFactory(L,s):G4(L,s),o=_==="none",E$=o?D===null?q:q.filter((j)=>j.id===D):[],N1=o?D===null?q.map((j)=>j.id):[D]:[],W4=$.requiredSources??[],S1=o?W4.filter((j)=>N1.includes(j)):[],P0=ZV($.prompt,D,q,o),GX=o?void 0:{sourceHint:XV(D,q)},K0;try{let j=_==="none"?J:void 0;K0=await k.run(P0,{tool:X,cwd:X.path,context:j,docs:E$,requiredSources:S1,discovery:GX,restrictBuiltinTools:_==="none"?void 0:y,onProgress:G.onProgress})}catch(j){B.push({cell:{interface:L,source:D,toolset:_},answerable:"NO",confidence:0,response:"",reason:`Error in cell: ${j instanceof Error?j.message:String(j)}`,citations:null,traps:{fired:[],avoided:($.traps??[]).map((d)=>d.id)},error:j instanceof Error?j.message:String(j)});continue}let V4=x0({response:K0.response,traps:$.traps??[]}),JX=V4.fired.length>0,I0=$.requiredSources!==void 0&&o?T$({response:K0.response,requiredSources:S1,registeredIds:N1}):null,m=$.expected!==void 0?S2({response:K0.response,expected:$.expected}):null,b$=_!=="none"&&p.length>0?{expected:M,used:(K0.toolsUsed??[]).filter((j)=>p.some((d)=>d(j)))}:null,QX=b$!==null&&b$.used.length===0,YX=()=>{let j=[];if(I0)j.push(I0.reason);if(m){let d=m.includes.filter((l)=>!l.satisfied).map((l)=>`"${l.value}"`),$0=m.excludes.filter((l)=>!l.satisfied).map((l)=>`"${l.value}"`),v0=[];if(d.length>0)v0.push(`missing includes: ${d.join(", ")}`);if($0.length>0)v0.push(`hit excludes: ${$0.join(", ")}`);j.push(v0.length>0?v0.join("; "):`expected checks satisfied (${m.satisfied}/${m.total})`)}return j.filter((d)=>d.length>0)},y$,x$,k$;if(JX)y$="NO",x$=0,k$=`Trap fired: ${V4.fired.map((j)=>`"${j.id}" (${j.reason})`).join("; ")}`;else if(QX){let j=b$;y$="NO",x$=0;let d=`Provenance failed: toolset "${_}" configured but none of [${j.expected.join(", ")}] were used (answer rests on model prior knowledge)`,$0=YX();k$=$0.length>0?`${d} | ${$0.join(" | ")}`:d}else{let j=[],d=[];if(I0)j.push({answerable:I0.answerable,confidence:I0.confidence}),d.push(I0.reason);if(m){let $0=m.total===0?100:Math.round(m.satisfied/m.total*100),v0=$0===100?"YES":$0===0?"NO":"PARTIAL";j.push({answerable:v0,confidence:$0});let l=m.includes.filter((m0)=>!m0.satisfied).map((m0)=>`"${m0.value}"`),u0=m.excludes.filter((m0)=>!m0.satisfied).map((m0)=>`"${m0.value}"`),C1=[];if(l.length>0)C1.push(`missing includes: ${l.join(", ")}`);if(u0.length>0)C1.push(`hit excludes: ${u0.join(", ")}`);d.push(C1.length>0?C1.join("; "):`expected checks satisfied (${m.satisfied}/${m.total})`)}if(b$)d.push(`tool use verified (${b$.used.join(", ")})`);if(j.length===0)y$="YES",x$=100,k$="No traps fired; no other contract declared";else{let $0={YES:0,PARTIAL:1,NO:2};y$=j.reduce((l,u0)=>$0[u0.answerable]>$0[l.answerable]?u0:l).answerable,x$=Math.round(j.reduce((l,u0)=>l+u0.confidence,0)/j.length),k$=d.filter((l)=>l.length>0).join(" | ")}}B.push({cell:{interface:L,source:D,toolset:_},answerable:y$,confidence:x$,response:K0.response,reason:k$,citations:I0?I0.citations:null,traps:V4,expected:m?{includes:m.includes,excludes:m.excludes,satisfied:m.satisfied,total:m.total}:void 0,toolsUsed:K0.toolsUsed,allResponses:K0.allResponses}),T=K0.metadata??T}}}let K=$V($,q);return{scenario:$,answerable:null,confidence:null,response:null,reason:null,citations:null,traps:null,cells:B,verifierSamples:K,target:T,context:{name:Z}}}function $V($,Z){let X=$.verifiers?.sources;if(!X||X.length===0)return;let z=new Map(Z.map((G)=>[G.id,G])),q=[];for(let G of X){let J=z.get(G);if(!J)continue;q.push({id:J.id,name:J.name,content:J.content})}return q.length>0?q:void 0}function ZV($,Z,X,z){if(z)return $;if(Z===null)return $;let q=X.find((J)=>J.id===Z);if(!q)return $;let G=q.type==="url"?`The canonical source for this question is the documentation at ${q.source}. Use your available tools to research it.`:`The canonical source for this question is "${q.name}" (registered locally as ${q.id}). Use your available tools to research from authoritative sources.`;return`${$}
|
|
245
|
+
${$}`,Y=pW(dW(),`pickled-codex-${uW()}.txt`),W=["--ask-for-approval","never","exec","--json","--sandbox","read-only","--ignore-user-config","--ignore-rules","--ephemeral","--skip-git-repo-check","--cd",z,"--model",J,"--output-last-message",Y,"-"];try{let U=await this.spawnFn(this.binary,W,{cwd:z,stdin:H}),{allResponses:V,toolsUsed:B}=cW(U.stdout);if(U.exitCode!==0)throw Error(`codex exec failed (exit ${U.exitCode}): ${U.stderr.trim()||"no stderr output"}`);let T="";try{T=(await this.readFileFn(Y)).trim()}catch{T=V.length>0?V[V.length-1].text:""}if(V.length>0)V[V.length-1].type="final";return{response:T,allResponses:V,toolsUsed:B,sources:[],metadata:{model:J,category:this.category,provider:this.provider,target:this.name}}}finally{await mW(Y,{force:!0})}}}function cW($){let Z=[],X=[];for(let z of $.split(`
|
|
246
|
+
`)){let q=z.trim();if(!q)continue;let G;try{G=JSON.parse(q)}catch{continue}let J=iW(G);if(J){let H=Z.length===0?"initial":"intermediate";Z.push({type:H,text:J})}let Q=aW(G);if(Q&&!X.includes(Q))X.push(Q)}return{allResponses:Z,toolsUsed:X}}function iW($){if(!$||typeof $!=="object")return null;let Z=$;if(typeof Z.message==="string")return Z.message;if(typeof Z.content==="string")return Z.content;if(typeof Z.type==="string"&&(Z.type==="assistant_message"||Z.type==="agent_message")&&typeof Z.text==="string")return Z.text;if(Z.type==="message"&&typeof Z.text==="string")return Z.text;return null}function aW($){if(!$||typeof $!=="object")return null;let Z=$;if(typeof Z.tool==="string")return Z.tool;if(typeof Z.type==="string"&&(Z.type==="tool_call"||Z.type==="function_call")&&typeof Z.name==="string")return Z.name;return null}var nW=async($,Z,X)=>{let z=Bun.spawn([$,...Z],{cwd:X.cwd,stdin:"pipe",stdout:"pipe",stderr:"pipe"});z.stdin.write(X.stdin),await z.stdin.end();let[q,G,J]=await Promise.all([new Response(z.stdout).text(),new Response(z.stderr).text(),z.exited]);return{exitCode:J,stdout:q,stderr:G}},sW=async($)=>{let Z=Bun.file($);if(!await Z.exists())throw Error(`Last-message file not found: ${$}`);return Z.text()};function J4($,Z){let X=Z??U0;switch(X.category){case"cli":return rW($,X);case"api":return oW($,X);case"ide":throw Error("IDE targets not yet implemented. Coming soon!");default:throw Error(`Unknown target category: ${X.category}`)}}function rW($,Z){switch(Z.provider){case"claude-code":return new U5($,Z);case"codex-cli":return new W5($,Z);case"gemini-cli":throw Error("Gemini CLI target not yet implemented. Coming soon!");case"amazon-q":throw Error("Amazon Q target not yet implemented. Coming soon!");default:throw Error(`Unknown CLI provider: ${Z.provider}`)}}function oW($,Z){switch(Z.provider){case"anthropic":return new H5($,Z);case"openai":throw Error("OpenAI API target not yet implemented. Coming soon!");case"google":throw Error("Google API target not yet implemented. Coming soon!");default:throw Error(`Unknown API provider: ${Z.provider}`)}}var S$="default";function Q4($,Z){if(!$||$===S$)return{name:S$,config:U0};if(Z?.[$])return{name:$,config:Z[$]};return console.warn(`Target "${$}" not found, using default`),{name:S$,config:U0}}function V5($,Z){if(!$||$===S$)return{name:S$,config:{}};if(Z?.[$])return{name:$,config:Z[$]};return console.warn(`Context "${$}" not found, using default`),{name:S$,config:{}}}var K5="__matrix__";function tW($){let Z=[],X=$.matrix?.target??["default"],z=$.matrix?.context??["default"];for(let q of $.scenarios){let G=q.context?[q.context]:z;if(q.matrix){for(let Q of G)Z.push({scenario:q,targetName:K5,contextName:Q});continue}let J=q.target?[q.target]:X;for(let Q of J)for(let H of G)Z.push({scenario:q,targetName:Q,contextName:H})}return Z}async function B5($,Z,X={}){let{onProgress:z}=X,q=[];if(Z.scenarios.length===0)throw Error("No scenarios defined in config");let G=Z.docs?.sources??{},J=[];if(Object.keys(G).length>0){z?.("Loading sources..."),J=await Q1(G,$.path);for(let W of J)z?.(` [${W.id}] ${W.name}`);z?.("")}let Q=J.map((W)=>W.id),H=tW(Z);if(X.scenarioFilter&&X.scenarioFilter.length>0){let W=new Set(X.scenarioFilter);if(H=H.filter((U)=>W.has(U.scenario.name)),H.length===0)throw Error(`No scenarios matched filter: ${[...W].join(", ")}. Declared scenarios: ${Z.scenarios.map((U)=>U.name).join(", ")}`)}let Y="";for(let{scenario:W,targetName:U,contextName:V}of H){let B=eW(U,V);if(W.name!==Y){if(Y)z?.("");z?.(`"${W.name}"`),Y=W.name}try{let T=await $V(W,U,V,$,Z,J,Q,X);q.push(T);let K=B?B.padEnd(18):"";if(T.cells){z?.(` ${K} (matrix mode)`);for(let L of T.cells){let D=_0(L),M=` [${[L.cell.interface,L.cell.source??"-",L.cell.toolset].join(" \xB7 ")}]`.padEnd(40);z?.(`${M} ${D.icon} ${D.label} (${D.confidence}%)`)}}else if(T.surfaces){z?.(` ${K} (compare-surfaces mode)`);for(let L of T.surfaces){let D=_0(L),_=` [${L.active.join(",")}]`.padEnd(22);z?.(`${_} ${D.icon} ${D.label} (${D.confidence}%)`)}}else{let L=_0({answerable:T.answerable??"NO",confidence:T.confidence??0,traps:T.traps??{fired:[],avoided:[]},error:T.error});z?.(` ${K} ${L.icon} ${L.label} (${L.confidence}%)`)}}catch(T){let K=U==="default"?U0:Z.targets?.[U]??U0,L=W.requiredSources??[],D={scenario:W,answerable:"NO",confidence:0,response:"",reason:"Error during run",citations:{cited:[],required:L,missing:L,unknown:[]},traps:{fired:[],avoided:(W.traps??[]).map((M)=>M.id)},error:T instanceof Error?T.message:String(T),target:{target:U===K5?"matrix":U,category:K.category,provider:K.provider,model:K.model??"unknown"},context:{name:V}};q.push(D);let _=B?B.padEnd(18):"";z?.(` ${_} \u2717 Error`)}}return z?.(""),ZV($,J,q)}function eW($,Z){if($==="default"&&Z==="default")return"";if(Z==="default")return`[${$}]`;return`[${$}/${Z}]`}async function $V($,Z,X,z,q,G,J,Q){if($.matrix&&Z===K5)return XV($,X,z,q,G,Q);let{config:H}=Q4(Z,q.targets),{config:Y}=V5(X,q.contexts),W=Q.targetFactory?Q.targetFactory(Z,H):J4(Z,H);if($.compareSurfaces&&$.compareSurfaces.length>0){let w=[],R;for(let P of $.compareSurfaces){let A=new Set(P),O=G.filter((P0)=>A.has(P0.id)),m=($.requiredSources??[]).filter((P0)=>A.has(P0)),i=await W.run($.prompt,{tool:z,cwd:z.path,context:Y,docs:O,requiredSources:m,onProgress:Q.onProgress}),x=D$({response:i.response,requiredSources:m,registeredIds:P}),I0=k0({response:i.response,traps:$.traps??[]}),H0=I0.fired.length>0,N1=H0?"NO":x.answerable,V4=H0?0:x.confidence,S1=H0?`Trap fired: ${I0.fired.map((P0)=>`"${P0.id}" (${P0.reason})`).join("; ")}`:x.reason;w.push({active:P,answerable:N1,confidence:V4,response:i.response,reason:S1,citations:x.citations,traps:I0,allResponses:i.allResponses}),R=i.metadata??R}return{scenario:$,answerable:null,confidence:null,response:null,reason:null,citations:null,traps:null,surfaces:w,target:R,context:{name:X}}}let U=$.requiredSources??[],V=await W.run($.prompt,{tool:z,cwd:z.path,context:Y,docs:G,requiredSources:U,onProgress:Q.onProgress}),B=k0({response:V.response,traps:$.traps??[]}),T=B.fired.length>0,K=$.requiredSources!==void 0?D$({response:V.response,requiredSources:U,registeredIds:J}):null,L=$.expected!==void 0?S2({response:V.response,expected:$.expected}):null,D,_,M;if(T)D="NO",_=0,M=`Trap fired: ${B.fired.map((w)=>`"${w.id}" (${w.reason})`).join("; ")}`;else{let w=[],R=[];if(K)w.push({answerable:K.answerable,confidence:K.confidence}),R.push(K.reason);if(L){let P=L.total===0?100:Math.round(L.satisfied/L.total*100),A=P===100?"YES":P===0?"NO":"PARTIAL";w.push({answerable:A,confidence:P})}if(w.length===0)D="YES",_=100,M="No traps fired; no other contract declared";else{let P={YES:0,PARTIAL:1,NO:2};D=w.reduce((O,y)=>P[y.answerable]>P[O.answerable]?y:O).answerable,_=Math.round(w.reduce((O,y)=>O+y.confidence,0)/w.length),M=R.filter((O)=>O.length>0).join(" | ")}}return{scenario:$,answerable:D,confidence:_,response:V.response,reason:M,citations:K?K.citations:{cited:[],required:U,missing:[],unknown:[]},traps:B,target:V.metadata,context:{name:X},toolsUsed:V.toolsUsed,sources:V.sources,allResponses:V.allResponses}}function ZV($,Z,X){let z=[];for(let Q of X){if(Q.surfaces){for(let H of Q.surfaces)z.push({answerable:H.answerable,confidence:H.confidence});continue}if(Q.cells){for(let H of Q.cells)z.push({answerable:H.answerable,confidence:H.confidence});continue}if(Q.answerable!==null&&Q.confidence!==null)z.push({answerable:Q.answerable,confidence:Q.confidence})}let q=z.length,G=z.filter((Q)=>Q.answerable==="YES"||Q.answerable==="PARTIAL").length,J=q>0?Math.round(z.reduce((Q,H)=>{if(H.answerable==="YES")return Q+H.confidence;if(H.answerable==="PARTIAL")return Q+H.confidence*0.5;return Q},0)/q):0;return{tool:{name:$.name,description:$.description,path:$.path},docs:Z,scenarios:X,summary:{total:q,answered:G,unanswered:q-G,score:J}}}async function XV($,Z,X,z,q,G){let{config:J}=V5(Z,z.contexts),Q=$.matrix??{},H=$.target??"default",Y=Q.interfaces??[H],W=Q.sources??[null],U=Q.toolsets??["none"],V=G.cellFilter??{},B=[],T;for(let L of Y){if(V.interface&&V.interface!==L)continue;for(let D of W){if(V.source!==void 0&&V.source!==(D??""))continue;for(let _ of U){if(V.toolset&&V.toolset!==_)continue;let M=_==="none"?null:z.toolsets?.[_]??null,w=_!=="none"&&(M?.webSearch===!0||M?.webFetch===!0),R=_!=="none"&&M?.mcpServers?Object.keys(M.mcpServers):[],P=R.length>0,{config:A}=Q4(L,z.targets);if(_!=="none"){if(w&&P)throw Error(`Toolset "${_}" mixes webSearch/webFetch with mcpServers; declare separate toolsets per shape so provenance can be attributed to one tool path.`);if(!w&&!P)throw Error(`Toolset "${_}" is declared but defines no runtime shape. Supported today: "none", web (webSearch/webFetch flags), MCP (mcpServers map). Other adapters (Firecrawl, native API search) land per release.`);if(P&&A.provider!=="claude-code")throw Error(`Toolset "${_}" (MCP) is implemented only on the claude-code interface today. Interface "${L}" uses provider "${A.provider}"; rerun with a Claude Code interface or use toolset "none".`);if(w&&A.provider!=="claude-code"&&A.provider!=="anthropic")throw Error(`Toolset "${_}" (web) is implemented on claude-code and anthropic interfaces today. Interface "${L}" uses provider "${A.provider}"; rerun with a supported interface or use toolset "none".`);if(w&&A.provider==="anthropic"&&!M?.webSearch)throw Error(`Toolset "${_}" on anthropic provider requires webSearch: true. The Anthropic API exposes a single server-side web tool; declare webSearch to enable it, or split web/fetch behaviour across separate toolsets.`)}let O=[],y=[],m=[],i=A.provider==="anthropic";if(w)if(i)m.push((N)=>N==="web_search");else{if(M?.webSearch)O.push("WebSearch"),y.push("WebSearch"),m.push((N)=>N==="WebSearch");if(M?.webFetch)O.push("WebFetch"),y.push("WebFetch"),m.push((N)=>N==="WebFetch")}if(P)for(let N of R)O.push(`mcp__${N}__*`),m.push((p)=>p.startsWith(`mcp__${N}__`));let x=_==="none"||i?A:{...A,allowedTools:O,disallowedTools:[],mcpServers:P?M?.mcpServers:void 0,maxTurns:Math.max(A.maxTurns??0,15)},I0=G.targetFactory?G.targetFactory(L,x):J4(L,x),H0=_==="none",N1=D==="none",V4=N1||!H0?[]:D===null?q:q.filter((N)=>N.id===D),S1=N1||!H0?[]:D===null?q.map((N)=>N.id):[D],P0=$.requiredSources??[],I5=H0?P0.filter((N)=>S1.includes(N)):[],JX=qV($.prompt,D,q,H0),QX=H0?void 0:{sourceHint:GV(D,q)},K0;try{let N=_==="none"?J:void 0;K0=await I0.run(JX,{tool:X,cwd:X.path,context:N,docs:V4,requiredSources:I5,discovery:QX,restrictBuiltinTools:_==="none"?void 0:y,webTools:w&&i?{search:M?.webSearch===!0}:void 0,onProgress:G.onProgress})}catch(N){B.push({cell:{interface:L,source:D,toolset:_},answerable:"NO",confidence:0,response:"",reason:`Error in cell: ${N instanceof Error?N.message:String(N)}`,citations:null,traps:{fired:[],avoided:($.traps??[]).map((p)=>p.id)},error:N instanceof Error?N.message:String(N)});continue}let K4=k0({response:K0.response,traps:$.traps??[]}),YX=K4.fired.length>0,R0=$.requiredSources!==void 0&&H0?D$({response:K0.response,requiredSources:I5,registeredIds:S1}):null,d=$.expected!==void 0?S2({response:K0.response,expected:$.expected}):null,b$=_!=="none"&&m.length>0?{expected:O,used:(K0.toolsUsed??[]).filter((N)=>m.some((p)=>p(N)))}:null,HX=b$!==null&&b$.used.length===0,UX=()=>{let N=[];if(R0)N.push(R0.reason);if(d){let p=d.includes.filter((l)=>!l.satisfied).map((l)=>`"${l.value}"`),e=d.excludes.filter((l)=>!l.satisfied).map((l)=>`"${l.value}"`),u0=[];if(p.length>0)u0.push(`missing includes: ${p.join(", ")}`);if(e.length>0)u0.push(`hit excludes: ${e.join(", ")}`);N.push(u0.length>0?u0.join("; "):`expected checks satisfied (${d.satisfied}/${d.total})`)}return N.filter((p)=>p.length>0)},y$,x$,k$;if(YX)y$="NO",x$=0,k$=`Trap fired: ${K4.fired.map((N)=>`"${N.id}" (${N.reason})`).join("; ")}`;else if(HX){let N=b$;y$="NO",x$=0;let p=`Provenance failed: toolset "${_}" configured but none of [${N.expected.join(", ")}] were used (answer rests on model prior knowledge)`,e=UX();k$=e.length>0?`${p} | ${e.join(" | ")}`:p}else{let N=[],p=[];if(R0)N.push({answerable:R0.answerable,confidence:R0.confidence}),p.push(R0.reason);if(d){let e=d.total===0?100:Math.round(d.satisfied/d.total*100),u0=e===100?"YES":e===0?"NO":"PARTIAL";N.push({answerable:u0,confidence:e});let l=d.includes.filter((d0)=>!d0.satisfied).map((d0)=>`"${d0.value}"`),m0=d.excludes.filter((d0)=>!d0.satisfied).map((d0)=>`"${d0.value}"`),C1=[];if(l.length>0)C1.push(`missing includes: ${l.join(", ")}`);if(m0.length>0)C1.push(`hit excludes: ${m0.join(", ")}`);p.push(C1.length>0?C1.join("; "):`expected checks satisfied (${d.satisfied}/${d.total})`)}if(b$)p.push(`tool use verified (${b$.used.join(", ")})`);if(N.length===0)y$="YES",x$=100,k$="No traps fired; no other contract declared";else{let e={YES:0,PARTIAL:1,NO:2};y$=N.reduce((l,m0)=>e[m0.answerable]>e[l.answerable]?m0:l).answerable,x$=Math.round(N.reduce((l,m0)=>l+m0.confidence,0)/N.length),k$=p.filter((l)=>l.length>0).join(" | ")}}B.push({cell:{interface:L,source:D,toolset:_},answerable:y$,confidence:x$,response:K0.response,reason:k$,citations:R0?R0.citations:null,traps:K4,expected:d?{includes:d.includes,excludes:d.excludes,satisfied:d.satisfied,total:d.total}:void 0,toolsUsed:K0.toolsUsed,allResponses:K0.allResponses}),T=K0.metadata??T}}}let K=zV($,q);return{scenario:$,answerable:null,confidence:null,response:null,reason:null,citations:null,traps:null,cells:B,verifierSamples:K,target:T,context:{name:Z}}}function zV($,Z){let X=$.verifiers?.sources;if(!X||X.length===0)return;let z=new Map(Z.map((G)=>[G.id,G])),q=[];for(let G of X){let J=z.get(G);if(!J)continue;q.push({id:J.id,name:J.name,content:J.content})}return q.length>0?q:void 0}function qV($,Z,X,z){if(z)return $;if(Z===null||Z==="none")return $;let q=X.find((J)=>J.id===Z);if(!q)return $;let G=q.type==="url"?`The canonical source for this question is the documentation at ${q.source}. Use your available tools to research it.`:`The canonical source for this question is "${q.name}" (registered locally as ${q.id}). Use your available tools to research from authoritative sources.`;return`${$}
|
|
247
247
|
|
|
248
|
-
${G}`}function
|
|
248
|
+
${G}`}function GV($,Z){if($===null||$==="none")return null;let X=Z.find((z)=>z.id===$);if(!X)return null;if(X.type==="url")return X.source;return X.name}var vZ=($=0)=>(Z)=>`\x1B[${Z+$}m`,uZ=($=0)=>(Z)=>`\x1B[${38+$};5;${Z}m`,mZ=($=0)=>(Z,X,z)=>`\x1B[${38+$};2;${Z};${X};${z}m`,f={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},QD=Object.keys(f.modifier),JV=Object.keys(f.color),QV=Object.keys(f.bgColor),YD=[...JV,...QV];function YV(){let $=new Map;for(let[Z,X]of Object.entries(f)){for(let[z,q]of Object.entries(X))f[z]={open:`\x1B[${q[0]}m`,close:`\x1B[${q[1]}m`},X[z]=f[z],$.set(q[0],q[1]);Object.defineProperty(f,Z,{value:X,enumerable:!1})}return Object.defineProperty(f,"codes",{value:$,enumerable:!1}),f.color.close="\x1B[39m",f.bgColor.close="\x1B[49m",f.color.ansi=vZ(),f.color.ansi256=uZ(),f.color.ansi16m=mZ(),f.bgColor.ansi=vZ(10),f.bgColor.ansi256=uZ(10),f.bgColor.ansi16m=mZ(10),Object.defineProperties(f,{rgbToAnsi256:{value(Z,X,z){if(Z===X&&X===z){if(Z<8)return 16;if(Z>248)return 231;return Math.round((Z-8)/247*24)+232}return 16+36*Math.round(Z/255*5)+6*Math.round(X/255*5)+Math.round(z/255*5)},enumerable:!1},hexToRgb:{value(Z){let X=/[a-f\d]{6}|[a-f\d]{3}/i.exec(Z.toString(16));if(!X)return[0,0,0];let[z]=X;if(z.length===3)z=[...z].map((G)=>G+G).join("");let q=Number.parseInt(z,16);return[q>>16&255,q>>8&255,q&255]},enumerable:!1},hexToAnsi256:{value:(Z)=>f.rgbToAnsi256(...f.hexToRgb(Z)),enumerable:!1},ansi256ToAnsi:{value(Z){if(Z<8)return 30+Z;if(Z<16)return 90+(Z-8);let X,z,q;if(Z>=232)X=((Z-232)*10+8)/255,z=X,q=X;else{Z-=16;let Q=Z%36;X=Math.floor(Z/36)/5,z=Math.floor(Q/6)/5,q=Q%6/5}let G=Math.max(X,z,q)*2;if(G===0)return 30;let J=30+(Math.round(q)<<2|Math.round(z)<<1|Math.round(X));if(G===2)J+=60;return J},enumerable:!1},rgbToAnsi:{value:(Z,X,z)=>f.ansi256ToAnsi(f.rgbToAnsi256(Z,X,z)),enumerable:!1},hexToAnsi:{value:(Z)=>f.ansi256ToAnsi(f.hexToAnsi256(Z)),enumerable:!1}}),f}var HV=YV(),Y0=HV;import L5 from"process";import UV from"os";import dZ from"tty";function G0($,Z=globalThis.Deno?globalThis.Deno.args:L5.argv){let X=$.startsWith("-")?"":$.length===1?"-":"--",z=Z.indexOf(X+$),q=Z.indexOf("--");return z!==-1&&(q===-1||z<q)}var{env:h}=L5,Y4;if(G0("no-color")||G0("no-colors")||G0("color=false")||G0("color=never"))Y4=0;else if(G0("color")||G0("colors")||G0("color=true")||G0("color=always"))Y4=1;function WV(){if("FORCE_COLOR"in h){if(h.FORCE_COLOR==="true")return 1;if(h.FORCE_COLOR==="false")return 0;return h.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(h.FORCE_COLOR,10),3)}}function VV($){if($===0)return!1;return{level:$,hasBasic:!0,has256:$>=2,has16m:$>=3}}function KV($,{streamIsTTY:Z,sniffFlags:X=!0}={}){let z=WV();if(z!==void 0)Y4=z;let q=X?Y4:z;if(q===0)return 0;if(X){if(G0("color=16m")||G0("color=full")||G0("color=truecolor"))return 3;if(G0("color=256"))return 2}if("TF_BUILD"in h&&"AGENT_NAME"in h)return 1;if($&&!Z&&q===void 0)return 0;let G=q||0;if(h.TERM==="dumb")return G;if(L5.platform==="win32"){let J=UV.release().split(".");if(Number(J[0])>=10&&Number(J[2])>=10586)return Number(J[2])>=14931?3:2;return 1}if("CI"in h){if(["GITHUB_ACTIONS","GITEA_ACTIONS","CIRCLECI"].some((J)=>(J in h)))return 3;if(["TRAVIS","APPVEYOR","GITLAB_CI","BUILDKITE","DRONE"].some((J)=>(J in h))||h.CI_NAME==="codeship")return 1;return G}if("TEAMCITY_VERSION"in h)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(h.TEAMCITY_VERSION)?1:0;if(h.COLORTERM==="truecolor")return 3;if(h.TERM==="xterm-kitty")return 3;if(h.TERM==="xterm-ghostty")return 3;if(h.TERM==="wezterm")return 3;if("TERM_PROGRAM"in h){let J=Number.parseInt((h.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(h.TERM_PROGRAM){case"iTerm.app":return J>=3?3:2;case"Apple_Terminal":return 2}}if(/-256(color)?$/i.test(h.TERM))return 2;if(/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(h.TERM))return 1;if("COLORTERM"in h)return 1;return G}function pZ($,Z={}){let X=KV($,{streamIsTTY:$&&$.isTTY,...Z});return VV(X)}var BV={stdout:pZ({isTTY:dZ.isatty(1)}),stderr:pZ({isTTY:dZ.isatty(2)})},lZ=BV;function cZ($,Z,X){let z=$.indexOf(Z);if(z===-1)return $;let q=Z.length,G=0,J="";do J+=$.slice(G,z)+Z+X,G=z+q,z=$.indexOf(Z,G);while(z!==-1);return J+=$.slice(G),J}function iZ($,Z,X,z){let q=0,G="";do{let J=$[z-1]==="\r";G+=$.slice(q,J?z-1:z)+Z+(J?`\r
|
|
249
249
|
`:`
|
|
250
250
|
`)+X,q=z+1,z=$.indexOf(`
|
|
251
|
-
`,q)}while(z!==-1);return G+=$.slice(q),G}var{stdout:
|
|
252
|
-
`);if(G!==-1)Z=
|
|
253
|
-
`)}function
|
|
254
|
-
`);let Q=G.findings.filter((U)=>U.severity==="error").length,
|
|
255
|
-
`);else
|
|
251
|
+
`,q)}while(z!==-1);return G+=$.slice(q),G}var{stdout:aZ,stderr:nZ}=lZ,T5=Symbol("GENERATOR"),C$=Symbol("STYLER"),j1=Symbol("IS_EMPTY"),sZ=["ansi","ansi","ansi256","ansi16m"],E$=Object.create(null),LV=($,Z={})=>{if(Z.level&&!(Number.isInteger(Z.level)&&Z.level>=0&&Z.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let X=aZ?aZ.level:0;$.level=Z.level===void 0?X:Z.level};var TV=($)=>{let Z=(...X)=>X.join(" ");return LV(Z,$),Object.setPrototypeOf(Z,A1.prototype),Z};function A1($){return TV($)}Object.setPrototypeOf(A1.prototype,Function.prototype);for(let[$,Z]of Object.entries(Y0))E$[$]={get(){let X=H4(this,_5(Z.open,Z.close,this[C$]),this[j1]);return Object.defineProperty(this,$,{value:X}),X}};E$.visible={get(){let $=H4(this,this[C$],!0);return Object.defineProperty(this,"visible",{value:$}),$}};var D5=($,Z,X,...z)=>{if($==="rgb"){if(Z==="ansi16m")return Y0[X].ansi16m(...z);if(Z==="ansi256")return Y0[X].ansi256(Y0.rgbToAnsi256(...z));return Y0[X].ansi(Y0.rgbToAnsi(...z))}if($==="hex")return D5("rgb",Z,X,...Y0.hexToRgb(...z));return Y0[X][$](...z)},DV=["rgb","hex","ansi256"];for(let $ of DV){E$[$]={get(){let{level:X}=this;return function(...z){let q=_5(D5($,sZ[X],"color",...z),Y0.color.close,this[C$]);return H4(this,q,this[j1])}}};let Z="bg"+$[0].toUpperCase()+$.slice(1);E$[Z]={get(){let{level:X}=this;return function(...z){let q=_5(D5($,sZ[X],"bgColor",...z),Y0.bgColor.close,this[C$]);return H4(this,q,this[j1])}}}}var _V=Object.defineProperties(()=>{},{...E$,level:{enumerable:!0,get(){return this[T5].level},set($){this[T5].level=$}}}),_5=($,Z,X)=>{let z,q;if(X===void 0)z=$,q=Z;else z=X.openAll+$,q=Z+X.closeAll;return{open:$,close:Z,openAll:z,closeAll:q,parent:X}},H4=($,Z,X)=>{let z=(...q)=>FV(z,q.length===1?""+q[0]:q.join(" "));return Object.setPrototypeOf(z,_V),z[T5]=$,z[C$]=Z,z[j1]=X,z},FV=($,Z)=>{if($.level<=0||!Z)return $[j1]?"":Z;let X=$[C$];if(X===void 0)return Z;let{openAll:z,closeAll:q}=X;if(Z.includes("\x1B"))while(X!==void 0)Z=cZ(Z,X.close,X.open),X=X.parent;let G=Z.indexOf(`
|
|
252
|
+
`);if(G!==-1)Z=iZ(Z,q,z,G);return z+Z+q};Object.defineProperties(A1.prototype,E$);var MV=A1(),_D=A1({level:nZ?nZ.level:0});var I=MV;var rZ="\u2500".repeat(55);function F5($){if($==="success")return I.green;if($==="warning")return I.yellow;return I.red}function OV($){if($>=70)return I.green;if($>=50)return I.yellow;return I.red}function M5($){if($.label==="Error")return $.label;return`${$.label} (${$.confidence}%)`}function wV($){let Z=_0({answerable:$.answerable??"NO",confidence:$.confidence??0,traps:$.traps??{fired:[],avoided:[]},error:$.error}),X=F5(Z.tone);return{icon:X(Z.icon),status:M5(Z),color:X}}function IV($){let Z=$.target?.target??"default",X=$.context?.name??"default";if(Z==="default"&&X==="default")return"";if(X==="default")return I.dim(`[${Z}]`);return I.dim(`[${Z}/${X}]`)}function PV($){let Z=$.map((X)=>X.scenario.name);return new Set(Z).size!==Z.length}function U4($){return $.map((Z)=>`[${Z}]`).join(", ")}function O5($,Z){let X=[];if($.error)return X.push(I.dim(`${Z}error: ${$.error}`)),X;if($.traps.fired.length>0)for(let z of $.traps.fired)X.push(I.red(`${Z}trap: ${z.id}`)),X.push(I.dim(`${Z}reason: ${z.reason}`)),X.push(I.dim(`${Z}match: "${z.matched}"`));else if($.reason&&$.answerable!=="YES")X.push(I.dim(`${Z}reason: ${$.reason}`));if($.citations.cited.length>0)X.push(I.dim(`${Z}cited: ${U4($.citations.cited)}`));if($.citations.missing.length>0)X.push(I.dim(`${Z}missing: ${U4($.citations.missing)}`));if($.citations.unknown.length>0)X.push(I.dim(`${Z}unknown: ${U4($.citations.unknown)}`));return X}function oZ($,Z){if(!$.traps||!$.citations)return[];return O5({error:$.error,traps:$.traps,reason:$.reason??"",answerable:$.answerable??"NO",citations:$.citations},Z)}function tZ($){let{icon:Z,status:X,color:z}=wV($),q=IV($),G=`${Z} ${X}`;return q?`${q} ${z(G)}`:z(G)}function eZ($,Z){if(!$.cells)return[];let X=[];X.push(`${Z}${I.dim("Matrix cells (interface \xB7 source \xB7 toolset)")}`);for(let z of $.cells){let q=_0(z),G=F5(q.tone),J=`[${z.cell.interface} \xB7 ${z.cell.source??"-"} \xB7 ${z.cell.toolset}]`,Q=I.dim(J),H=`${G(q.icon)} ${G(M5(q))}`;if(X.push(`${Z}${Q} ${H}`),X.push(...O5({traps:z.traps,reason:z.reason,answerable:z.answerable,citations:z.citations??{cited:[],required:[],missing:[],unknown:[]}},`${Z} `)),z.expected){let Y=z.expected.includes.filter((U)=>!U.satisfied).map((U)=>`"${U.value}"`),W=z.expected.excludes.filter((U)=>!U.satisfied).map((U)=>`"${U.value}"`);if(Y.length>0)X.push(I.dim(`${Z} expected.includes missing: ${Y.join(", ")}`));if(W.length>0)X.push(I.dim(`${Z} expected.excludes hit: ${W.join(", ")}`))}if(z.toolsUsed&&z.toolsUsed.length>0)X.push(I.dim(`${Z} tools: ${z.toolsUsed.join(", ")}`))}if($.verifierSamples&&$.verifierSamples.length>0){X.push(`${Z}${I.dim("Verifier samples (human review; never LLM-judged)")}`);for(let z of $.verifierSamples){let q=z.content.slice(0,200).replace(/\s+/g," ").trim(),G=z.content.length>200?"...":"";X.push(I.dim(`${Z} [${z.id}] ${z.name}`)),X.push(I.dim(`${Z} ${q}${G}`))}}return X}function $X($,Z){if(!$.surfaces)return[];let X=[];X.push(`${Z}${I.dim("Citations scoped to active surface (compare mode)")}`);for(let z of $.surfaces){let q=_0(z),G=F5(q.tone),J=I.dim(`[${z.active.join(",")}]`),Q=`${G(q.icon)} ${G(M5(q))}`;X.push(`${Z}${J} ${Q}`),X.push(...O5({traps:z.traps,reason:z.reason,answerable:z.answerable,citations:z.citations},`${Z} `))}return X}function RV($){let Z=0,X=0,z=0;for(let q of $){if(q.surfaces){for(let G of q.surfaces)Z+=G.traps.fired.length,X+=G.citations.missing.length,z+=G.citations.unknown.length;continue}if(q.traps)Z+=q.traps.fired.length;if(q.citations)X+=q.citations.missing.length,z+=q.citations.unknown.length}if(Z>0&&X+z>0)return"Review fired traps and citation gaps.";if(Z>0)return"Review fired traps before trusting this surface.";if(X+z>0)return"Review missing and unknown citations.";return"Citations hold. No declared traps fired."}function jV($,Z){let X=$.summary.score,q=`Overall: ${OV(X)(`${X}`)} / 100`;if(Z===void 0||Z<=0)return q;let J=X>=Z?I.green("run passes"):I.red("run fails");return`${q} \xB7 threshold ${Z} \xB7 ${J}`}function ZX($,Z={}){let{tool:X,scenarios:z,summary:q}=$,G=z,J=[];if(J.push(I.bold("pickled check")),J.push(rZ),J.push(`Tool: ${I.cyan(X.name)}`),$.docs.length>0)J.push(`Sources: ${I.dim(U4($.docs.map((Q)=>Q.id)))}`);else J.push(`Sources: ${I.dim("none registered")}`);if(J.push(`Scenarios: ${I.dim(String(q.total))}`),J.push(""),PV(G)){let Q=new Map;for(let H of G){let Y=H.scenario.name;if(!Q.has(Y))Q.set(Y,[]);Q.get(Y)?.push(H)}for(let[H,Y]of Q){J.push(`Scenario: ${H}`);for(let W of Y)if(W.cells)J.push(...eZ(W," "));else if(W.surfaces)J.push(...$X(W," "));else J.push(` ${tZ(W)}`),J.push(...oZ(W," "));J.push("")}}else for(let Q of G){if(J.push(`Scenario: ${Q.scenario.name}`),Q.cells)J.push(...eZ(Q," "));else if(Q.surfaces)J.push(...$X(Q," "));else J.push(` ${tZ(Q)}`),J.push(...oZ(Q," "));J.push("")}return J.push(rZ),J.push(jV($,Z.threshold)),J.push(I.dim(RV(z))),J.join(`
|
|
253
|
+
`)}function w5($,Z={}){console.log(ZX($,Z)),console.log()}function W4($,Z={}){if(Z.verbose)return JSON.stringify($,null,2);let X={...$,docs:$.docs.map((z)=>({...z,content:""})),scenarios:$.scenarios.map((z)=>{let{allResponses:q,verifierSamples:G,cells:J,surfaces:Q,...H}=z;return{...H,verifierSamples:G?.map((Y)=>({...Y,content:""})),cells:J?.map((Y)=>{let{allResponses:W,...U}=Y;return U}),surfaces:Q?.map((Y)=>{let{allResponses:W,...U}=Y;return U})}})};return JSON.stringify(X,null,2)}function NV($){if($.format&&$.format!=="terminal")return $.format;if($.json)return"json";return $.format??"terminal"}async function XX($,Z){let{output:X}=Z,z=NV(Z),q=AV.resolve($),G;try{G=await N2({targetRepo:q})}catch(U){console.error(I.red(U instanceof Error?U.message:U)),process.exit(1)}let J;if(z==="json")J=O2(G);else if(z==="markdown")J=M2(G);else J=w2(G);if(X)await Bun.write(X,J);else await SV(`${J}
|
|
254
|
+
`);let Q=G.findings.filter((U)=>U.severity==="error").length,H=G.findings.filter((U)=>U.severity==="warning").length;if(z!=="json"&&!X)if(console.log(),Q===0&&H===0)console.log(I.green("Audit clean. No issues found."));else{let U=Q>0?I.red:I.yellow;console.log(U(`Audit found ${Q} error(s), ${H} warning(s).`))}if((Z.failOn??"error")==="warning"?Q+H>0:Q>0)process.exit(1)}function SV($){return new Promise((Z,X)=>{process.stdout.write($,(z)=>{if(z)X(z);else Z()})})}import CV from"path";async function qX($,Z){let{json:X,output:z,verbose:q}=Z,G=(K)=>!X&&console.log(K),J=CV.resolve($),Q;try{Q=await B$(J)}catch(K){console.error(I.red(K instanceof Error?K.message:K)),console.error(),console.error(I.dim("Run `pickled init` to create a config file")),process.exit(1)}if(Z.target){let K=Q.scenarios.length;try{Q=h9(Q,Z.target)}catch(D){console.error(I.red(D instanceof Error?D.message:String(D))),process.exit(1)}let L=K-Q.scenarios.length;if(L>0&&!X)G(I.dim(`Skipping ${L} scenario(s) with explicit target != "${Z.target}"`))}let H={name:Q.tool.name,description:Q.tool.description,path:J};if(q){G(I.bold("pickled check")),G(""),G(I.dim(` Tool: ${H.name}`)),G(I.dim(` Scenarios: ${Q.scenarios.length}`));for(let K of Q.scenarios)G(I.dim(` - ${K.name}`))}let Y;try{Y=EV(Z.threshold,Q.threshold)}catch(K){console.error(I.red(K instanceof Error?K.message:K)),process.exit(1)}let W=Z.interface??Z.target,U=W||Z.source||Z.toolset?{interface:W,source:Z.source,toolset:Z.toolset}:void 0,V=Z.scenario?[Z.scenario]:void 0,B=await B5(H,Q,{onProgress:q?(K)=>{if(!X)G(I.dim(` ${K}`))}:void 0,cellFilter:U,scenarioFilter:V}),T=Y>0&&B.summary.score<Y;if(z)await Bun.write(z,W4(B,{verbose:q}));else if(X)await bV(`${W4(B,{verbose:q})}
|
|
255
|
+
`);else w5(B,{threshold:Y});if(T){if(X||z)console.error(I.red(`Overall: ${B.summary.score} / 100 \xB7 threshold ${Y} \xB7 run fails`)),console.error(I.dim("Review failed scenarios before trusting this surface."));process.exit(1)}}function EV($,Z){if($===void 0){if(Z===void 0)return 0;return zX(Z,"pickled.yml threshold")}return zX($,"--threshold")}function zX($,Z){if(typeof $==="number"){if(Number.isInteger($)&&$>=0&&$<=100)return $;throw Error(`Invalid ${Z} "${$}". Expected an integer from 0 to 100.`)}if(typeof $==="string"&&/^\d+$/.test($)){let X=Number($);if(X<=100)return X}if(typeof $==="string")throw Error(`Invalid ${Z} "${$}". Expected an integer from 0 to 100.`);throw Error(`Invalid ${Z}. Expected an integer from 0 to 100.`)}function bV($){return new Promise((Z,X)=>{process.stdout.write($,(z)=>{if(z)X(z);else Z()})})}import yV from"path";var xV=`# pickled.yml - Agent legibility check for your product
|
|
256
256
|
|
|
257
257
|
tool:
|
|
258
258
|
name: "your-product"
|
|
@@ -274,4 +274,4 @@ scenarios:
|
|
|
274
274
|
|
|
275
275
|
# Optional: fail CI if score falls below threshold
|
|
276
276
|
# threshold: 80
|
|
277
|
-
`;async function
|
|
277
|
+
`;async function GX($){let X=`${yV.resolve($)}/pickled.yml`;if(await Bun.file(X).exists())console.error(I.red("pickled.yml already exists")),process.exit(1);await Bun.write(X,xV),console.log(I.green("Created pickled.yml")),console.log(),console.log(I.dim("Next steps:")),console.log(I.dim(" 1. Edit pickled.yml: list your sources and scenarios")),console.log(I.dim(" 2. Run: pickled check")),console.log()}X$.name("pickled").description("Test what agents actually understand about your product").version(p5.version);X$.command("init").description("Create a pickled.yml config file").argument("[path]","Path to your project (default: current directory)",".").action(GX);X$.command("audit").description("Static scan of agent-context files (CLAUDE.md, AGENTS.md, llms.txt). No LLM calls.").argument("[path]","Path to your project (default: current directory)",".").addOption(new w4("--format <name>","Output format").choices(["terminal","markdown","json"]).default("terminal")).option("--json","Shorthand for --format json").option("-o, --output <file>","Save report to file").addOption(new w4("--fail-on <level>","Exit non-zero on this severity or higher").choices(["error","warning"]).default("error")).action(XX);X$.command("check").description("Run agent scenarios against registered sources").argument("[path]","Path to your project (default: current directory)",".").option("--json","Output as JSON").option("-o, --output <file>","Save report to file").option("-v, --verbose","Show detailed progress").option("-t, --threshold <percent>","Minimum score % to pass (overrides config)").option("--target <name>","Restrict to the named target. Overrides matrix.target for non-matrix scenarios; for matrix scenarios, also filters cells by interface unless --interface is explicitly set.").option("--scenario <name>","Run only the named scenario (for CI matrix one-job-per-cell usage)").option("--interface <name>","Matrix cell filter: run only cells with this interface. Takes precedence over --target for matrix cells.").option("--source <name>","Matrix cell filter: run only cells with this source id").option("--toolset <name>","Matrix cell filter: run only cells with this toolset name").action(qX);await X$.parseAsync();
|