jazz-ai 0.13.8 → 0.13.9

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.
Files changed (2) hide show
  1. package/dist/main.js +2 -2
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -64,7 +64,7 @@ Expecting one of '${Z.join("', '")}'`);if(this._lifeCycleHooks[I])this._lifeCycl
64
64
  `),this.outputHelp({error:!0});let Z=G||{},b=Z.exitCode||1,W=Z.code||"commander.error";this._exit(b,W,I)}_parseOptionsEnv(){this.options.forEach((I)=>{if(I.envVar&&I.envVar in Tl.env){let G=I.attributeName();if(this.getOptionValue(G)===void 0||["default","config","env"].includes(this.getOptionValueSource(G)))if(I.required||I.optional)this.emit(`optionEnv:${I.name()}`,Tl.env[I.envVar]);else this.emit(`optionEnv:${I.name()}`)}})}_parseOptionsImplied(){let I=new zwI(this.options),G=(Z)=>{return this.getOptionValue(Z)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(Z))};this.options.filter((Z)=>Z.implied!==void 0&&G(Z.attributeName())&&I.valueFromOption(this.getOptionValue(Z.attributeName()),Z)).forEach((Z)=>{Object.keys(Z.implied).filter((b)=>!G(b)).forEach((b)=>{this.setOptionValueWithSource(b,Z.implied[b],"implied")})})}missingArgument(I){let G=`error: missing required argument '${I}'`;this.error(G,{code:"commander.missingArgument"})}optionMissingArgument(I){let G=`error: option '${I.flags}' argument missing`;this.error(G,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(I){let G=`error: required option '${I.flags}' not specified`;this.error(G,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(I,G){let Z=(l)=>{let Y=l.attributeName(),N=this.getOptionValue(Y),c=this.options.find((F)=>F.negate&&Y===F.attributeName()),X=this.options.find((F)=>!F.negate&&Y===F.attributeName());if(c&&(c.presetArg===void 0&&N===!1||c.presetArg!==void 0&&N===c.presetArg))return c;return X||l},b=(l)=>{let Y=Z(l),N=Y.attributeName();if(this.getOptionValueSource(N)==="env")return`environment variable '${Y.envVar}'`;return`option '${Y.flags}'`},W=`error: ${b(I)} cannot be used with ${b(G)}`;this.error(W,{code:"commander.conflictingOption"})}unknownOption(I){if(this._allowUnknownOption)return;let G="";if(I.startsWith("--")&&this._showSuggestionAfterError){let b=[],W=this;do{let l=W.createHelp().visibleOptions(W).filter((Y)=>Y.long).map((Y)=>Y.long);b=b.concat(l),W=W.parent}while(W&&!W._enablePositionalOptions);G=gwI(I,b)}let Z=`error: unknown option '${I}'${G}`;this.error(Z,{code:"commander.unknownOption"})}_excessArguments(I){if(this._allowExcessArguments)return;let G=this.registeredArguments.length,Z=G===1?"":"s",b=I.length,W=this.parent?` for '${this.name()}'`:"",l=I.join(", "),Y=`error: too many arguments${W}. Expected ${G} argument${Z} but got ${b}: ${l}.`;this.error(Y,{code:"commander.excessArguments"})}unknownCommand(){let I=this.args[0],G="";if(this._showSuggestionAfterError){let b=[];this.createHelp().visibleCommands(this).forEach((W)=>{if(b.push(W.name()),W.alias())b.push(W.alias())}),G=gwI(I,b)}let Z=`error: unknown command '${I}'${G}`;this.error(Z,{code:"commander.unknownCommand"})}version(I,G,Z){if(I===void 0)return this._version;this._version=I,G=G||"-V, --version",Z=Z||"output the version number";let b=this.createOption(G,Z);return this._versionOptionName=b.attributeName(),this._registerOption(b),this.on("option:"+b.name(),()=>{this._outputConfiguration.writeOut(`${I}
65
65
  `),this._exit(0,"commander.version",I)}),this}description(I,G){if(I===void 0&&G===void 0)return this._description;if(this._description=I,G)this._argsDescription=G;return this}summary(I){if(I===void 0)return this._summary;return this._summary=I,this}alias(I){if(I===void 0)return this._aliases[0];let G=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)G=this.commands[this.commands.length-1];if(I===G._name)throw Error("Command alias can't be the same as its name");let Z=this.parent?._findCommand(I);if(Z){let b=[Z.name()].concat(Z.aliases()).join("|");throw Error(`cannot add alias '${I}' to command '${this.name()}' as already have command '${b}'`)}return G._aliases.push(I),this}aliases(I){if(I===void 0)return this._aliases;return I.forEach((G)=>this.alias(G)),this}usage(I){if(I===void 0){if(this._usage)return this._usage;let G=this.registeredArguments.map((Z)=>{return tr(Z)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?G:[]).join(" ")}return this._usage=I,this}name(I){if(I===void 0)return this._name;return this._name=I,this}helpGroup(I){if(I===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=I,this}commandsGroup(I){if(I===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=I,this}optionsGroup(I){if(I===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=I,this}_initOptionGroup(I){if(this._defaultOptionGroup&&!I.helpGroupHeading)I.helpGroup(this._defaultOptionGroup)}_initCommandGroup(I){if(this._defaultCommandGroup&&!I.helpGroup())I.helpGroup(this._defaultCommandGroup)}nameFromFilename(I){return this._name=CJ.basename(I,CJ.extname(I)),this}executableDir(I){if(I===void 0)return this._executableDir;return this._executableDir=I,this}helpInformation(I){let G=this.createHelp(),Z=this._getOutputContext(I);G.prepareContext({error:Z.error,helpWidth:Z.helpWidth,outputHasColors:Z.hasColors});let b=G.formatHelp(this,G);if(Z.hasColors)return b;return this._outputConfiguration.stripColor(b)}_getOutputContext(I){I=I||{};let G=!!I.error,Z,b,W;if(G)Z=(Y)=>this._outputConfiguration.writeErr(Y),b=this._outputConfiguration.getErrHasColors(),W=this._outputConfiguration.getErrHelpWidth();else Z=(Y)=>this._outputConfiguration.writeOut(Y),b=this._outputConfiguration.getOutHasColors(),W=this._outputConfiguration.getOutHelpWidth();return{error:G,write:(Y)=>{if(!b)Y=this._outputConfiguration.stripColor(Y);return Z(Y)},hasColors:b,helpWidth:W}}outputHelp(I){let G;if(typeof I==="function")G=I,I=void 0;let Z=this._getOutputContext(I),b={error:Z.error,write:Z.write,command:this};this._getCommandAndAncestors().reverse().forEach((l)=>l.emit("beforeAllHelp",b)),this.emit("beforeHelp",b);let W=this.helpInformation({error:Z.error});if(G){if(W=G(W),typeof W!=="string"&&!Buffer.isBuffer(W))throw Error("outputHelp callback must return a string or a Buffer")}if(Z.write(W),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",b),this._getCommandAndAncestors().forEach((l)=>l.emit("afterAllHelp",b))}helpOption(I,G){if(typeof I==="boolean"){if(I){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(I??"-h, --help",G??"display help for command"),I||G)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(I){return this._helpOption=I,this._initOptionGroup(I),this}help(I){this.outputHelp(I);let G=Number(Tl.exitCode??0);if(G===0&&I&&typeof I!=="function"&&I.error)G=1;this._exit(G,"commander.help","(outputHelp)")}addHelpText(I,G){let Z=["beforeAll","before","after","afterAll"];if(!Z.includes(I))throw Error(`Unexpected value for position to addHelpText.
66
66
  Expecting one of '${Z.join("', '")}'`);let b=`${I}Help`;return this.on(b,(W)=>{let l;if(typeof G==="function")l=G({error:W.error,command:W.command});else l=G;if(l)W.write(`${l}
67
- `)}),this}_outputHelpIfRequested(I){let G=this._getHelpOption();if(G&&I.find((b)=>G.is(b)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}});var I8W;var mVG=u(()=>{er();HVG();N8();pwI();kwI();I8W=new tg});var s0;var c8=u(()=>{s0={name:"jazz-ai",version:"0.13.8",description:"Your terminal. Your agent. Your rules.",license:"MIT",main:"dist/main.js",types:"dist/main.d.ts",type:"module",bin:{jazz:"./dist/main.js"},author:{name:"lvndry",email:"lvndry@proton.me",url:"https://github.com/lvndry"},homepage:"https://github.com/lvndry/jazz",repository:{type:"git",url:"https://github.com/lvndry/jazz.git"},bugs:{url:"https://github.com/lvndry/jazz/issues"},keywords:["cli","agents","automation","agentic","typescript","effect-ts","ai","llm","workflow","email","git","productivity","assistant","task-automation","developer-tools","ai-assistant","ai-agent","mcp","mcp-server","agent-skills"],scripts:{build:"bun run scripts/build.ts",typecheck:"bun run tsc --noEmit && bun run tsc -p tsconfig.build.json","typecheck:evals":"tsc -p evals/tsconfig.json",evals:"bun run evals/cli.ts",dev:"bun --watch src/main.ts",start:"bun dist/main.js",cli:"bun src/main.ts",prepare:"git config core.hooksPath .githooks || true",lint:"bun eslint src scripts --cache","lint:fix":"bun eslint src scripts --fix --cache",format:"bun prettier --write src",test:"bun test","test:watch":"bun test --watch","docs:check-links":"bun run scripts/check-docs-links.ts","docs:lint":"bunx markdownlint-cli2","docs:lint:fix":"bunx markdownlint-cli2 --fix","test:typecheck":"bunx tsc --project tsconfig.test.json",clean:"rm -rf dist",prebuild:"bun run clean",prepublishOnly:"bun run build"},dependencies:{"@ai-sdk/alibaba":"^2.0.16","@ai-sdk/anthropic":"^4.0.18","@ai-sdk/cerebras":"^3.0.14","@ai-sdk/deepseek":"^3.0.13","@ai-sdk/fireworks":"^3.0.15","@ai-sdk/google":"^4.0.21","@ai-sdk/groq":"^4.0.13","@ai-sdk/mcp":"^2.0.16","@ai-sdk/mistral":"^4.0.14","@ai-sdk/moonshotai":"^3.0.17","@ai-sdk/openai":"^4.0.17","@ai-sdk/openai-compatible":"^3.0.14","@ai-sdk/togetherai":"^3.0.15","@ai-sdk/xai":"^4.0.18","@effect/cluster":"^0.59.0","@effect/platform":"^0.96.2","@effect/platform-node":"^0.107.0","@effect/rpc":"^0.75.1","@effect/sql":"^0.51.1","@modelcontextprotocol/sdk":"^1.29.0","@openrouter/ai-sdk-provider":"^3.0.0","@perplexity-ai/perplexity_ai":"^0.33.0","@tavily/core":"^0.7.6","@toon-format/toon":"^2.3.0",ai:"^7.0.34",chalk:"^5.6.2","cli-highlight":"^2.1.11",commander:"^15.0.0","cron-parser":"^5.5.0",cronstrue:"^3.20.0",diff:"^9.0.0",effect:"^3.21.4","exa-js":"^2.14.0","fast-glob":"^3.3.3","gpt-tokenizer":"^3.4.0","gray-matter":"^4.0.3",ink:"^7.1.0","ink-select-input":"^6.2.0","ink-spinner":"^5.0.0","linkup-sdk":"^3.2.5",marked:"^18.0.5","marked-terminal":"^7.3.0","node-emoji":"^2.2.0","ollama-ai-provider-v2":"^4.0.1","parallel-web":"^1.1.0","pdf-parse":"^2.4.5",plist:"^5.0.0",react:"^19.2.7",semver:"^7.8.4","short-uuid":"^6.0.3","tz-lookup":"^6.1.25","vercel-minimax-ai-provider":"^0.0.2","wrap-ansi":"^10.0.0","zhipu-ai-provider":"^0.3.1",zod:"^4.4.3"},devDependencies:{"@eslint/js":"^10.0.1","@types/bun":"^1.3.14","@types/marked":"^6.0.0","@types/marked-terminal":"^6.1.1","@types/node":"^26.0.0","@types/react":"^19.2.17",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-import-x":"^4.16.2","eslint-plugin-n":"^18.1.0","eslint-plugin-prettier":"^5.5.6",prettier:"^3.8.4",typescript:"^6.0.3","typescript-eslint":"^8.61.1"},engines:{node:">=22.16.0",npm:">=10.0.0"},files:["dist/","vendor/terminal-notifier/","personas/","skills/","workflows/","README.md","LICENSE"]}});var dVG,wVG=()=>{return Object.assign((I)=>I,{[dVG]:dVG,option:(I)=>XI(I),either:(I)=>wG(I),is:(I)=>!0})};var hVG=u(()=>{aV();Vb();dVG=Symbol.for("effect/Brand/Refined")});var uwI,BwI,JVG;var vVG=u(()=>{OE();uwI=jI,BwI=sG,JVG=qI});var EVG,CVG,yVG;var AVG=u(()=>{Zr();EVG=RD,CVG=dD,yVG=kWG});var OwI=(I,G)=>{switch(G._tag){case"StringKeyword":case"TemplateLiteral":return Object.keys(I);case"SymbolKeyword":return Object.getOwnPropertySymbols(I);case"Refinement":return OwI(I,G.from)}},X8=(I)=>{let G=!1,Z;return()=>{if(G)return Z;return Z=I(),G=!0,Z}},MwI=(I)=>Array.isArray(I),pVG=(I)=>!Array.isArray(I),LVG=(I)=>`[${wv(I)}]`,Zt=(I)=>MwI(I)?I.map(LVG).join(""):LVG(I);var F8=u(()=>{uY()});var sE=(I,G,Z,b)=>{let W=I;if(Z&&fl(Z))W+=`
67
+ `)}),this}_outputHelpIfRequested(I){let G=this._getHelpOption();if(G&&I.find((b)=>G.is(b)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}});var I8W;var mVG=u(()=>{er();HVG();N8();pwI();kwI();I8W=new tg});var s0;var c8=u(()=>{s0={name:"jazz-ai",version:"0.13.9",description:"Your terminal. Your agent. Your rules.",license:"MIT",main:"dist/main.js",types:"dist/main.d.ts",type:"module",bin:{jazz:"./dist/main.js"},author:{name:"lvndry",email:"lvndry@proton.me",url:"https://github.com/lvndry"},homepage:"https://github.com/lvndry/jazz",repository:{type:"git",url:"https://github.com/lvndry/jazz.git"},bugs:{url:"https://github.com/lvndry/jazz/issues"},keywords:["cli","agents","automation","agentic","typescript","effect-ts","ai","llm","workflow","email","git","productivity","assistant","task-automation","developer-tools","ai-assistant","ai-agent","mcp","mcp-server","agent-skills"],scripts:{build:"bun run scripts/build.ts",typecheck:"bun run tsc --noEmit && bun run tsc -p tsconfig.build.json","typecheck:evals":"tsc -p evals/tsconfig.json",evals:"bun run evals/cli.ts",dev:"bun --watch src/main.ts",start:"bun dist/main.js",cli:"bun src/main.ts",prepare:"git config core.hooksPath .githooks || true",lint:"bun eslint src scripts --cache","lint:fix":"bun eslint src scripts --fix --cache",format:"bun prettier --write src",test:"bun test","test:watch":"bun test --watch","docs:check-links":"bun run scripts/check-docs-links.ts","docs:lint":"bunx markdownlint-cli2","docs:lint:fix":"bunx markdownlint-cli2 --fix","test:typecheck":"bunx tsc --project tsconfig.test.json",clean:"rm -rf dist",prebuild:"bun run clean",prepublishOnly:"bun run build"},dependencies:{"@ai-sdk/alibaba":"^2.0.16","@ai-sdk/anthropic":"^4.0.18","@ai-sdk/cerebras":"^3.0.14","@ai-sdk/deepseek":"^3.0.13","@ai-sdk/fireworks":"^3.0.15","@ai-sdk/google":"^4.0.21","@ai-sdk/groq":"^4.0.13","@ai-sdk/mcp":"^2.0.16","@ai-sdk/mistral":"^4.0.14","@ai-sdk/moonshotai":"^3.0.17","@ai-sdk/openai":"^4.0.17","@ai-sdk/openai-compatible":"^3.0.14","@ai-sdk/togetherai":"^3.0.15","@ai-sdk/xai":"^4.0.18","@effect/cluster":"^0.59.0","@effect/platform":"^0.96.2","@effect/platform-node":"^0.107.0","@effect/rpc":"^0.75.1","@effect/sql":"^0.51.1","@modelcontextprotocol/sdk":"^1.29.0","@openrouter/ai-sdk-provider":"^3.0.0","@perplexity-ai/perplexity_ai":"^0.33.0","@tavily/core":"^0.7.6","@toon-format/toon":"^2.3.0",ai:"^7.0.34",chalk:"^5.6.2","cli-highlight":"^2.1.11",commander:"^15.0.0","cron-parser":"^5.5.0",cronstrue:"^3.20.0",diff:"^9.0.0",effect:"^3.21.4","exa-js":"^2.14.0","fast-glob":"^3.3.3","gpt-tokenizer":"^3.4.0","gray-matter":"^4.0.3",ink:"^7.1.0","ink-select-input":"^6.2.0","ink-spinner":"^5.0.0","linkup-sdk":"^3.2.5",marked:"^18.0.5","marked-terminal":"^7.3.0","node-emoji":"^2.2.0","ollama-ai-provider-v2":"^4.0.1","parallel-web":"^1.1.0","pdf-parse":"^2.4.5",plist:"^5.0.0",react:"^19.2.7",semver:"^7.8.4","short-uuid":"^6.0.3","tz-lookup":"^6.1.25","vercel-minimax-ai-provider":"^0.0.2","wrap-ansi":"^10.0.0","zhipu-ai-provider":"^0.3.1",zod:"^4.4.3"},devDependencies:{"@eslint/js":"^10.0.1","@types/bun":"^1.3.14","@types/marked":"^6.0.0","@types/marked-terminal":"^6.1.1","@types/node":"^26.0.0","@types/react":"^19.2.17",eslint:"^10.5.0","eslint-config-prettier":"^10.1.8","eslint-plugin-import-x":"^4.16.2","eslint-plugin-n":"^18.1.0","eslint-plugin-prettier":"^5.5.6",prettier:"^3.8.4",typescript:"^6.0.3","typescript-eslint":"^8.61.1"},engines:{node:">=22.16.0",npm:">=10.0.0"},files:["dist/","vendor/terminal-notifier/","personas/","skills/","workflows/","README.md","LICENSE"]}});var dVG,wVG=()=>{return Object.assign((I)=>I,{[dVG]:dVG,option:(I)=>XI(I),either:(I)=>wG(I),is:(I)=>!0})};var hVG=u(()=>{aV();Vb();dVG=Symbol.for("effect/Brand/Refined")});var uwI,BwI,JVG;var vVG=u(()=>{OE();uwI=jI,BwI=sG,JVG=qI});var EVG,CVG,yVG;var AVG=u(()=>{Zr();EVG=RD,CVG=dD,yVG=kWG});var OwI=(I,G)=>{switch(G._tag){case"StringKeyword":case"TemplateLiteral":return Object.keys(I);case"SymbolKeyword":return Object.getOwnPropertySymbols(I);case"Refinement":return OwI(I,G.from)}},X8=(I)=>{let G=!1,Z;return()=>{if(G)return Z;return Z=I(),G=!0,Z}},MwI=(I)=>Array.isArray(I),pVG=(I)=>!Array.isArray(I),LVG=(I)=>`[${wv(I)}]`,Zt=(I)=>MwI(I)?I.map(LVG).join(""):LVG(I);var F8=u(()=>{uY()});var sE=(I,G,Z,b)=>{let W=I;if(Z&&fl(Z))W+=`
68
68
  at path: ${Zt(Z)}`;if(G!==void 0)W+=`
69
69
  details: ${G}`;if(b)W+=`
70
70
  schema (${b._tag}): ${b}`;return W},xwI=(I,G,Z)=>sE("Unsupported schema or overlapping types",`cannot extend ${I} with ${G}`,Z),zVG=(I)=>sE("Unsupported key schema",void 0,void 0,I),kVG=(I)=>sE("Unsupported literal",`literal value: ${aQ(I)}`),KwI=(I)=>sE("Duplicate index signature",`${I} index signature`),gVG,UVG,jwI=(I)=>sE("Duplicate property signature transformation",`Duplicate key ${aQ(I)}`),Wt=(I)=>sE("Duplicate property signature",`Duplicate key ${aQ(I)}`);var DwI=u(()=>{BY();uY();F8();gVG=sE("Unsupported index signature parameter","An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"),UVG=sE("Invalid element","A required element cannot follow an optional element. ts(1257)")});var BVG;var OVG=u(()=>{BVG=Symbol.for("effect/SchemaId/DateFromSelf")});class eg{typeParameters;decodeUnknown;encodeUnknown;annotations;_tag="Declaration";constructor(I,G,Z,b={}){this.typeParameters=I,this.decodeUnknown=G,this.encodeUnknown=Z,this.annotations=b}toString(){return kb(B5(this),()=>"<declaration schema>")}toJSON(){return{_tag:this._tag,typeParameters:this.typeParameters.map((I)=>I.toJSON()),annotations:Y2(this.annotations)}}}class IU{literal;annotations;_tag="Literal";constructor(I,G={}){this.literal=I,this.annotations=G}toString(){return kb(B5(this),()=>aQ(this.literal))}toJSON(){return{_tag:this._tag,literal:dv(this.literal)?String(this.literal):this.literal,annotations:Y2(this.annotations)}}}class Yt{symbol;annotations;_tag="UniqueSymbol";constructor(I,G={}){this.symbol=I,this.annotations=G}toString(){return kb(B5(this),()=>aQ(this.symbol))}toJSON(){return{_tag:this._tag,symbol:String(this.symbol),annotations:Y2(this.annotations)}}}class iVG{annotations;_tag="UndefinedKeyword";constructor(I={}){this.annotations=I}toString(){return km(this)}toJSON(){return{_tag:this._tag,annotations:Y2(this.annotations)}}}class oVG{annotations;_tag="VoidKeyword";constructor(I={}){this.annotations=I}toString(){return km(this)}toJSON(){return{_tag:this._tag,annotations:Y2(this.annotations)}}}class sVG{annotations;_tag="NeverKeyword";constructor(I={}){this.annotations=I}toString(){return km(this)}toJSON(){return{_tag:this._tag,annotations:Y2(this.annotations)}}}class rVG{annotations;_tag="UnknownKeyword";constructor(I={}){this.annotations=I}toString(){return km(this)}toJSON(){return{_tag:this._tag,annotations:Y2(this.annotations)}}}class tVG{annotations;_tag="AnyKeyword";constructor(I={}){this.annotations=I}toString(){return km(this)}toJSON(){return{_tag:this._tag,annotations:Y2(this.annotations)}}}class IcG{annotations;_tag="StringKeyword";constructor(I={}){this.annotations=I}toString(){return km(this)}toJSON(){return{_tag:this._tag,annotations:Y2(this.annotations)}}}class GcG{annotations;_tag="NumberKeyword";constructor(I={}){this.annotations=I}toString(){return km(this)}toJSON(){return{_tag:this._tag,annotations:Y2(this.annotations)}}}class ZcG{annotations;_tag="BooleanKeyword";constructor(I={}){this.annotations=I}toString(){return km(this)}toJSON(){return{_tag:this._tag,annotations:Y2(this.annotations)}}}class bcG{annotations;_tag="BigIntKeyword";constructor(I={}){this.annotations=I}toString(){return km(this)}toJSON(){return{_tag:this._tag,annotations:Y2(this.annotations)}}}class WcG{annotations;_tag="SymbolKeyword";constructor(I={}){this.annotations=I}toString(){return km(this)}toJSON(){return{_tag:this._tag,annotations:Y2(this.annotations)}}}class YcG{annotations;_tag="ObjectKeyword";constructor(I={}){this.annotations=I}toString(){return km(this)}toJSON(){return{_tag:this._tag,annotations:Y2(this.annotations)}}}class m8{type;annotations;constructor(I,G={}){this.type=I,this.annotations=G}toJSON(){return{type:this.type.toJSON(),annotations:Y2(this.annotations)}}toString(){return String(this.type)}}class Qt{elements;rest;isReadonly;annotations;_tag="TupleType";constructor(I,G,Z,b={}){this.elements=I,this.rest=G,this.isReadonly=Z,this.annotations=b;let W=!1,l=!1;for(let Y of I)if(Y.isOptional)W=!0;else if(W){l=!0;break}if(l||W&&G.length>1)throw Error(UVG)}toString(){return kb(B5(this),()=>SfZ(this))}toJSON(){return{_tag:this._tag,elements:this.elements.map((I)=>I.toJSON()),rest:this.rest.map((I)=>I.toJSON()),isReadonly:this.isReadonly,annotations:Y2(this.annotations)}}}class GU{type;isReadonly;parameter;constructor(I,G,Z){if(this.type=G,this.isReadonly=Z,VcG(I))this.parameter=I;else throw Error(gVG)}toString(){return(this.isReadonly?"readonly ":"")+`[x: ${this.parameter}]: ${this.type}`}toJSON(){return{parameter:this.parameter.toJSON(),type:this.type.toJSON(),isReadonly:this.isReadonly}}}class zm{annotations;_tag="TypeLiteral";propertySignatures;indexSignatures;constructor(I,G,Z={}){this.annotations=Z;let b={};for(let l=0;l<I.length;l++){let Y=I[l].name;if(Object.prototype.hasOwnProperty.call(b,Y))throw Error(Wt(Y));b[Y]=null}let W={string:!1,symbol:!1};for(let l=0;l<G.length;l++){let Y=HhI(G[l].parameter);if(Xt(Y)){if(W.string)throw Error(KwI("string"));W.string=!0}else if(lcG(Y)){if(W.symbol)throw Error(KwI("symbol"));W.symbol=!0}}this.propertySignatures=I,this.indexSignatures=G}toString(){return kb(B5(this),()=>PfZ(this))}toJSON(){return{_tag:this._tag,propertySignatures:this.propertySignatures.map((I)=>I.toJSON()),indexSignatures:this.indexSignatures.map((I)=>I.toJSON()),annotations:Y2(this.annotations)}}}class r0{types;annotations;static make=(I,G)=>{return Rt(I)?new r0(I,G):I.length===1?I[0]:Vt};static unify=(I,G)=>{return r0.make(nfZ(ccG(I)),G)};_tag="Union";constructor(I,G={}){this.types=I,this.annotations=G}toString(){return kb(B5(this),()=>this.types.map(String).join(" | "))}toJSON(){return{_tag:this._tag,types:this.types.map((I)=>I.toJSON()),annotations:Y2(this.annotations)}}}class ZU{f;annotations;_tag="Suspend";constructor(I,G={}){this.f=I,this.annotations=G,this.f=X8(I)}toString(){return B5(this).pipe(vF(()=>Z2(BC(this.f)(),(I)=>B5(I))),kb(()=>"<suspended schema>"))}toJSON(){let I=this.f(),G=qwI.get(I);if(G)return G;return qwI.set(I,{_tag:this._tag}),G={_tag:this._tag,ast:I.toJSON(),annotations:Y2(this.annotations)},qwI.set(I,G),G}}class bU{from;filter;annotations;_tag="Refinement";constructor(I,G,Z={}){this.from=I,this.filter=G,this.annotations=Z}toString(){return H8(this).pipe(kb(()=>fG(hcG(this),{onNone:()=>`{ ${this.from} | filter }`,onSome:(I)=>rE(this.from)?String(this.from)+" & "+I:I})))}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),annotations:Y2(this.annotations)}}}class tE{from;to;transformation;annotations;_tag="Transformation";constructor(I,G,Z,b={}){this.from=I,this.to=G,this.transformation=Z,this.annotations=b}toString(){return kb(B5(this),()=>`(${String(this.from)} <-> ${String(this.to)})`)}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),to:this.to.toJSON(),annotations:Y2(this.annotations)}}}class dt{decode;encode;_tag="FinalTransformation";constructor(I,G){this.decode=I,this.encode=G}}class QcG{_tag="ComposeTransformation"}class XhI{from;to;decode;encode;constructor(I,G,Z,b){this.from=I,this.to=G,this.decode=Z,this.encode=b}}class d8{propertySignatureTransformations;_tag="TypeLiteralTransformation";constructor(I){this.propertySignatureTransformations=I;let G={},Z={};for(let b of I){let W=b.from;if(G[W])throw Error(jwI(W));G[W]=!0;let l=b.to;if(Z[l])throw Error(jwI(l));Z[l]=!0}}}function z1(I,G){let Z=!1,b=OC(I.length);for(let W=0;W<I.length;W++){let l=I[W],Y=G(l);if(Y!==l)Z=!0;b[W]=Y}return Z?b:I}function tfZ(I){return fG(aVG(I),{onNone:()=>"",onSome:(G)=>G.map((Z)=>` & Brand<${aQ(Z)}>`).join("")})}var xVG,KVG,jVG,TwI,lt,Q8,SF,IA,yJ,SwI,PwI,_wI,$wI,nwI,fwI,DVG,iwI,owI,swI,rwI,twI,R8,qVG,t0,aVG,TVG,SVG,ewI,IhI,H8,GhI,PVG,_VG,$VG,nVG,fVG,ZhI,xfZ,bhI=(I)=>L0I(xfZ(I),(G)=>G===!0),WhI,KfZ,jfZ=(I)=>vF(KfZ(I),()=>H8(I)),AJ=(I)=>(G)=>G._tag===I,GA,Nt,DfZ,Vt,lhI,eVG,ct,Xt,Ft,YhI,NhI,VhI,qfZ,afZ,lcG,TfZ,ZA,NcG=(I)=>I.map((G)=>G.type),SfZ=(I)=>{let G=I.elements.map(String).join(", ");return ZaI(I.rest,{onEmpty:()=>`readonly [${G}]`,onNonEmpty:(Z,b)=>{let W=String(Z),l=W.includes(" | ")?`(${W})`:W;if(b.length>0){let Y=b.map(String).join(", ");if(I.elements.length>0)return`readonly [${G}, ...${l}[], ${Y}]`;else return`readonly [...${l}[], ${Y}]`}else if(I.elements.length>0)return`readonly [${G}, ...${l}[]]`;else return`ReadonlyArray<${W}>`}})},yV,VcG=(I)=>{switch(I._tag){case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":return!0;case"Refinement":return VcG(I.from)}return!1},MVG=(I)=>I.map(String).join("; "),PfZ=(I)=>{if(I.propertySignatures.length>0){let G=I.propertySignatures.map(String).join("; ");if(I.indexSignatures.length>0)return`{ ${G}; ${MVG(I.indexSignatures)} }`;else return`{ ${G} }`}else if(I.indexSignatures.length>0)return`{ ${MVG(I.indexSignatures)} }`;else return"{}"},chI,_fZ,$fZ,ccG=(I)=>MC(I,(G)=>Ht(G)?ccG(G.types):[G]),nfZ=(I)=>{let G=_fZ(I),Z=[],b={},W=[];for(let l of G)switch(l._tag){case"NeverKeyword":break;case"AnyKeyword":return[eVG];case"UnknownKeyword":return[lhI];case"ObjectKeyword":case"UndefinedKeyword":case"VoidKeyword":case"StringKeyword":case"NumberKeyword":case"BooleanKeyword":case"BigIntKeyword":case"SymbolKeyword":{if(!b[l._tag])b[l._tag]=l,Z.push(l);break}case"Literal":{let Y=typeof l.literal;switch(Y){case"string":case"number":case"bigint":case"boolean":{let N=$fZ[Y];if(!b[N]&&!W.includes(l.literal))W.push(l.literal),Z.push(l);break}case"object":{if(!W.includes(l.literal))W.push(l.literal),Z.push(l);break}}break}case"UniqueSymbol":{if(!b.SymbolKeyword&&!W.includes(l.symbol))W.push(l.symbol),Z.push(l);break}case"TupleType":{if(!b.ObjectKeyword)Z.push(l);break}case"TypeLiteral":{if(l.propertySignatures.length===0&&l.indexSignatures.length===0){if(!b["{}"])b["{}"]=l,Z.push(l)}else if(!b.ObjectKeyword)Z.push(l);break}default:Z.push(l)}return Z},XcG=(I,G)=>I.map(G),Rt=(I)=>I.length>1,Ht,qwI,rE,mt,FcG,ffZ=(I)=>(G)=>G._tag===I,RcG,FhI,wt=(I,G)=>{let Z=Object.getOwnPropertyDescriptors(I),b={...I.annotations};delete b[Q8];let W={...b,...G},l=ZhI(I);if(cZ(l))W[R8]=wt(l.value,G);return Z.annotations.value=W,Object.create(Object.getPrototypeOf(I),Z)},ifZ="[\\s\\S]*?",ofZ="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?",HcG=(I,G)=>{switch(I._tag){case"Literal":return kk(String(I.literal));case"StringKeyword":return ifZ;case"NumberKeyword":return ofZ;case"TemplateLiteral":return mcG(I,G,!1);case"Union":return I.types.map((Z)=>HcG(Z,G)).join("|")}},sfZ=(I,G,Z,b)=>{if(Ht(I)){if(Z&&!b)return`(?:${G})`}else if(!Z||!b)return G;return`(${G})`},mcG=(I,G,Z)=>{let b="";if(I.head!==""){let W=kk(I.head);b+=G&&Z?`(${W})`:W}for(let W of I.spans){let l=HcG(W.type,G);if(b+=sfZ(W.type,l,G,Z),W.literal!==""){let Y=kk(W.literal);b+=G&&Z?`(${Y})`:Y}}return b},dcG=(I)=>new RegExp(`^${mcG(I,!1,!0)}$`),QhI=(I,G)=>{let Z=[],b=[],W=(l)=>{switch(l._tag){case"NeverKeyword":break;case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":case"Refinement":b.push(new GU(l,G,!0));break;case"Literal":if(FV(l.literal)||yX(l.literal))Z.push(new yV(l.literal,G,!1,!0));else throw Error(kVG(l.literal));break;case"Enums":{for(let[Y,N]of l.enums)Z.push(new yV(N,G,!1,!0));break}case"UniqueSymbol":Z.push(new yV(l.symbol,G,!1,!0));break;case"Union":l.types.forEach(W);break;default:throw Error(zVG(l))}};return W(I),{propertySignatures:Z,indexSignatures:b}},RhI=(I)=>(G)=>{let Z=void 0;for(let b of I)if(Object.prototype.hasOwnProperty.call(G.annotations,b)){if(Z===void 0)Z={};Z[b]=G.annotations[b]}return Z},wcG=(I)=>(G)=>{let Z={...G.annotations};for(let b of I)delete Z[b];return Z},rfZ,A2=(I)=>{switch(I._tag){case"Declaration":{let G=z1(I.typeParameters,A2);return G===I.typeParameters?I:new eg(G,I.decodeUnknown,I.encodeUnknown,I.annotations)}case"TupleType":{let G=z1(I.elements,(W)=>{let l=A2(W.type);return l===W.type?W:new ZA(l,W.isOptional)}),Z=NcG(I.rest),b=z1(Z,A2);return G===I.elements&&b===Z?I:new Qt(G,b.map((W)=>new m8(W)),I.isReadonly,I.annotations)}case"TypeLiteral":{let G=z1(I.propertySignatures,(b)=>{let W=A2(b.type);return W===b.type?b:new yV(b.name,W,b.isOptional,b.isReadonly)}),Z=z1(I.indexSignatures,(b)=>{let W=A2(b.type);return W===b.type?b:new GU(b.parameter,W,b.isReadonly)});return G===I.propertySignatures&&Z===I.indexSignatures?I:new zm(G,Z,I.annotations)}case"Union":{let G=z1(I.types,A2);return G===I.types?I:r0.make(G,I.annotations)}case"Suspend":return new ZU(()=>A2(I.f()),I.annotations);case"Refinement":{let G=A2(I.from);return G===I.from?I:new bU(G,I.filter,I.annotations)}case"Transformation":{let G=rfZ(I);return A2(G!==void 0?wt(I.to,G):I.to)}}return I},awI=(I)=>{switch(I._tag){case"Transformation":return I.from;case"Refinement":return awI(I.from);case"Suspend":return awI(I.f())}},u5=(I,G)=>{switch(I._tag){case"Declaration":{let Z=z1(I.typeParameters,(b)=>u5(b,G));return Z===I.typeParameters?I:new eg(Z,I.decodeUnknown,I.encodeUnknown)}case"TupleType":{let Z=z1(I.elements,(l)=>{let Y=u5(l.type,G);return Y===l.type?l:new ZA(Y,l.isOptional)}),b=NcG(I.rest),W=z1(b,(l)=>u5(l,G));return Z===I.elements&&W===b?I:new Qt(Z,W.map((l)=>new m8(l)),I.isReadonly)}case"TypeLiteral":{let Z=z1(I.propertySignatures,(W)=>{let l=u5(W.type,G);return l===W.type?W:new yV(W.name,l,W.isOptional,W.isReadonly)}),b=z1(I.indexSignatures,(W)=>{let l=u5(W.type,G);return l===W.type?W:new GU(W.parameter,l,W.isReadonly)});return Z===I.propertySignatures&&b===I.indexSignatures?I:new zm(Z,b)}case"Union":{let Z=z1(I.types,(b)=>u5(b,G));return Z===I.types?I:r0.make(Z)}case"Suspend":{let Z=void 0,b=jfZ(I);if(cZ(b)){let W=G?"Bound":"";Z={[WhI]:`${b.value}Encoded${W}`}}return new ZU(()=>u5(I.f(),G),Z)}case"Refinement":{let Z=u5(I.from,G);if(G){if(Z===I.from)return I;if(awI(I.from)===void 0&&bhI(I))return new bU(Z,I.filter,I.annotations);return Z}else return Z}case"Transformation":return u5(I.from,G)}return I},w8=(I)=>u5(I,!1),Y2=(I)=>{let G={};for(let Z of Object.getOwnPropertySymbols(I))G[String(Z)]=I[Z];return G},HhI=(I)=>{switch(I._tag){case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":return I;case"Refinement":return HhI(I.from)}},km=(I)=>kb(B5(I),()=>I._tag),hcG=(I)=>ewI(I).pipe(vF(()=>GhI(I)),vF(()=>IhI(I)),Zl((G)=>G+tfZ(I))),B5=(I)=>vF(H8(I),()=>hcG(I));var mhI=u(()=>{BY();ZG();uY();DwI();F8();WE();Vb();hv();eZ();$FI();xVG=Symbol.for("effect/annotation/TypeConstructor"),KVG=Symbol.for("effect/annotation/Brand"),jVG=Symbol.for("effect/annotation/SchemaId"),TwI=Symbol.for("effect/annotation/Message"),lt=Symbol.for("effect/annotation/MissingMessage"),Q8=Symbol.for("effect/annotation/Identifier"),SF=Symbol.for("effect/annotation/Title"),IA=Symbol.for("effect/annotation/AutoTitle"),yJ=Symbol.for("effect/annotation/Description"),SwI=Symbol.for("effect/annotation/Examples"),PwI=Symbol.for("effect/annotation/Default"),_wI=Symbol.for("effect/annotation/JSONSchema"),$wI=Symbol.for("effect/annotation/Arbitrary"),nwI=Symbol.for("effect/annotation/Pretty"),fwI=Symbol.for("effect/annotation/Equivalence"),DVG=Symbol.for("effect/annotation/Documentation"),iwI=Symbol.for("effect/annotation/Concurrency"),owI=Symbol.for("effect/annotation/Batching"),swI=Symbol.for("effect/annotation/ParseIssueTitle"),rwI=Symbol.for("effect/annotation/ParseOptions"),twI=Symbol.for("effect/annotation/DecodingFallback"),R8=Symbol.for("effect/annotation/Surrogate"),qVG=Symbol.for("effect/annotation/StableFilter"),t0=k(2,(I,G)=>Object.prototype.hasOwnProperty.call(I.annotations,G)?XI(I.annotations[G]):mI()),aVG=t0(KVG),TVG=t0(TwI),SVG=t0(lt),ewI=t0(SF),IhI=t0(IA),H8=t0(Q8),GhI=t0(yJ),PVG=t0(iwI),_VG=t0(owI),$VG=t0(swI),nVG=t0(rwI),fVG=t0(twI),ZhI=t0(R8),xfZ=t0(qVG),WhI=Symbol.for("effect/annotation/JSONIdentifier"),KfZ=t0(WhI);GA=AJ("Literal");Nt=new iVG({[SF]:"undefined"});DfZ=new oVG({[SF]:"void"});Vt=new sVG({[SF]:"never"});lhI=new rVG({[SF]:"unknown"});eVG=new tVG({[SF]:"any"});ct=new IcG({[SF]:"string",[yJ]:"a string"}),Xt=AJ("StringKeyword");Ft=new GcG({[SF]:"number",[yJ]:"a number"}),YhI=AJ("NumberKeyword");NhI=new ZcG({[SF]:"boolean",[yJ]:"a boolean"}),VhI=AJ("BooleanKeyword");qfZ=new bcG({[SF]:"bigint",[yJ]:"a bigint"});afZ=new WcG({[SF]:"symbol",[yJ]:"a symbol"}),lcG=AJ("SymbolKeyword");TfZ=new YcG({[SF]:"object",[yJ]:"an object in the TypeScript meaning, i.e. the `object` type"});ZA=class ZA extends m8{isOptional;constructor(I,G,Z={}){super(I,Z);this.isOptional=G}toJSON(){return{type:this.type.toJSON(),isOptional:this.isOptional,annotations:Y2(this.annotations)}}toString(){return String(this.type)+(this.isOptional?"?":"")}};yV=class yV extends ZA{name;isReadonly;constructor(I,G,Z,b,W){super(G,Z,W);this.name=I,this.isReadonly=b}toString(){return(this.isReadonly?"readonly ":"")+String(this.name)+(this.isOptional?"?":"")+": "+this.type}toJSON(){return{name:String(this.name),type:this.type.toJSON(),isOptional:this.isOptional,isReadonly:this.isReadonly,annotations:Y2(this.annotations)}}};chI=AJ("TypeLiteral"),_fZ=nc(rd(JV,(I)=>{switch(I._tag){case"AnyKeyword":return 0;case"UnknownKeyword":return 1;case"ObjectKeyword":return 2;case"StringKeyword":case"NumberKeyword":case"BooleanKeyword":case"BigIntKeyword":case"SymbolKeyword":return 3}return 4})),$fZ={string:"StringKeyword",number:"NumberKeyword",boolean:"BooleanKeyword",bigint:"BigIntKeyword"};Ht=AJ("Union"),qwI=yZ(Symbol.for("effect/Schema/AST/toJSONMemoMap"),()=>new WeakMap);rE=AJ("Refinement"),mt={};FcG=AJ("Transformation");RcG=new QcG;FhI=ffZ("TypeLiteralTransformation"),rfZ=RhI([SwI,PwI,_wI,$wI,nwI,fwI])});class Ic{path;actual;issue;_tag="Pointer";constructor(I,G,Z){this.path=I,this.actual=G,this.issue=Z}}class hhI{actual;message;_tag="Unexpected";constructor(I,G){this.actual=I,this.message=G}}class WU{ast;message;_tag="Missing";actual=void 0;constructor(I,G){this.ast=I,this.message=G}}class N2{ast;actual;issues;output;_tag="Composite";constructor(I,G,Z,b){this.ast=I,this.actual=G,this.issues=Z,this.output=b}}class Jt{ast;actual;kind;issue;_tag="Refinement";constructor(I,G,Z,b){this.ast=I,this.actual=G,this.kind=Z,this.issue=b}}class vt{ast;actual;kind;issue;_tag="Transformation";constructor(I,G,Z,b){this.ast=I,this.actual=G,this.kind=Z,this.issue=b}}class ZR{ast;actual;message;_tag="Type";constructor(I,G,Z){this.ast=I,this.actual=G,this.message=Z}}class JhI{ast;actual;message;_tag="Forbidden";constructor(I,G,Z){this.ast=I,this.actual=G,this.message=Z}}function gm(I){return I.sort(liZ).map((G)=>G[1])}function FiZ(I){return GhI(I).pipe(vF(()=>ewI(I)),vF(()=>IhI(I)),vF(()=>H8(I)),kb(()=>`{ ${I.from} | filter }`))}function QiZ(I){if(I.message!==void 0)return I.message;return`Expected ${rE(I.ast)?FiZ(I.ast):String(I.ast)}, actual ${aQ(I.actual)}`}var vcG,ycG,AcG=(I)=>new ycG({issue:I}),YU,EhI,PF,LJ,_F,Et,LcG,Ct=(I,G)=>{if(G===void 0||yX(G))return I;if(I===void 0)return G;return{...I,...G}},efZ=(I,G,Z)=>{let b=Lc(I,G);return(W,l)=>b(W,Ct(Z,l))},IiZ=(I,G,Z)=>{let b=efZ(I,G,Z);return(W,l)=>_z(b(W,l),AcG)},GiZ=(I,G,Z)=>{let b=Lc(I,G);return(W,l)=>b(W,{...Ct(Z,l),isEffectAllowed:!0})},pcG=(I,G)=>GiZ(I.ast,!1,G),yt=(I,G)=>IiZ(A2(I.ast),!0,G),zcG=(I,G)=>{let Z=Lc(A2(I.ast),!0);return(b,W)=>u0(Z(b,{exact:!0,...Ct(G,W)}))},ZiZ,biZ,Lc=(I,G)=>{let Z=G?ZiZ:biZ,b=Z.get(I);if(b)return b;let W=WiZ(I,G),l=nVG(I),Y=cZ(l)?(X,F)=>W(X,Ct(F,l.value)):W,N=fVG(I),c=G&&cZ(N)?(X,F)=>J8(LcG(Y(X,F),N.value),I,X,F):Y;return Z.set(I,c),c},dhI=(I)=>FN(PVG(I)),whI=(I)=>FN(_VG(I)),WiZ=(I,G)=>{switch(I._tag){case"Refinement":if(G){let Z=Lc(I.from,!0);return(b,W)=>{W=W??mt;let l=W?.errors==="all",Y=LJ(LcG(Z(b,W),(N)=>{let c=new Jt(I,b,"From",N);if(l&&bhI(I)&&BcG(N))return fG(I.filter(b,W,I),{onNone:()=>hG(c),onSome:(X)=>hG(new N2(I,b,[c,new Jt(I,b,"Predicate",X)]))});return hG(c)}),(N)=>fG(I.filter(N,W,I),{onNone:()=>wG(N),onSome:(c)=>hG(new Jt(I,b,"Predicate",c))}));return J8(Y,I,b,W)}}else{let Z=Lc(A2(I),!0),b=Lc(gcG(I.from),!1);return(W,l)=>J8(LJ(Z(W,l),(Y)=>b(Y,l)),I,W,l)}case"Transformation":{let Z=YiZ(I.transformation,G),b=G?Lc(I.from,!0):Lc(I.to,!1),W=G?Lc(I.to,!0):Lc(I.from,!1);return(l,Y)=>J8(LJ(Et(b(l,Y),(N)=>new vt(I,l,G?"Encoded":"Type",N)),(N)=>LJ(Et(Z(N,Y??mt,I,l),(c)=>new vt(I,l,"Transformation",c)),(c)=>Et(W(c,Y),(X)=>new vt(I,l,G?"Type":"Encoded",X)))),I,l,Y)}case"Declaration":{let Z=G?I.decodeUnknown(...I.typeParameters):I.encodeUnknown(...I.typeParameters);return(b,W)=>J8(Z(b,W??mt,I),I,b,W)}case"Literal":return GR(I,(Z)=>Z===I.literal);case"UniqueSymbol":return GR(I,(Z)=>Z===I.symbol);case"UndefinedKeyword":return GR(I,HqI);case"NeverKeyword":return GR(I,mqI);case"UnknownKeyword":case"AnyKeyword":case"VoidKeyword":return wG;case"StringKeyword":return GR(I,FV);case"NumberKeyword":return GR(I,yX);case"BooleanKeyword":return GR(I,jQ);case"BigIntKeyword":return GR(I,dv);case"SymbolKeyword":return GR(I,vC);case"ObjectKeyword":return GR(I,mc);case"Enums":return GR(I,(Z)=>I.enums.some(([b,W])=>W===Z));case"TemplateLiteral":{let Z=dcG(I);return GR(I,(b)=>FV(b)&&Z.test(b))}case"TupleType":{let Z=I.elements.map((X)=>Lc(X.type,G)),b=I.rest.map((X)=>Lc(X.type,G)),W=I.elements.filter((X)=>!X.isOptional);if(I.rest.length>0)W=W.concat(I.rest.slice(1));let l=W.length,Y=I.elements.length>0?I.elements.map((X,F)=>F).join(" | "):"never",N=dhI(I),c=whI(I);return(X,F)=>{if(!g0I(X))return hG(new ZR(I,X));let Q=F?.errors==="all",R=[],H=0,m=[],d=X.length;for(let E=d;E<=l-1;E++){let v=new Ic(E,X,new WU(W[E-d]));if(Q){R.push([H++,v]);continue}else return hG(new N2(I,X,v,m))}if(I.rest.length===0)for(let E=I.elements.length;E<=d-1;E++){let v=new Ic(E,X,new hhI(X[E],`is unexpected, expected: ${Y}`));if(Q){R.push([H++,v]);continue}else return hG(new N2(I,X,v,m))}let w=0,y=void 0;for(;w<Z.length;w++)if(d<w+1){if(I.elements[w].isOptional)continue}else{let E=Z[w],v=E(X[w],F);if(PF(v)){if(UW(v)){let J=new Ic(w,X,v.left);if(Q){R.push([H++,J]);continue}else return hG(new N2(I,X,J,gm(m)))}m.push([H++,v.right])}else{let J=H++,C=w;if(!y)y=[];y.push(({es:L,output:z})=>SI(zE(v),(p)=>{if(UW(p)){let U=new Ic(C,X,p.left);if(Q)return L.push([J,U]),qZ;else return hG(new N2(I,X,U,gm(z)))}return z.push([J,p.right]),qZ}))}}if(fl(b)){let[E,...v]=b;for(;w<d-v.length;w++){let J=E(X[w],F);if(PF(J))if(UW(J)){let C=new Ic(w,X,J.left);if(Q){R.push([H++,C]);continue}else return hG(new N2(I,X,C,gm(m)))}else m.push([H++,J.right]);else{let C=H++,L=w;if(!y)y=[];y.push(({es:z,output:p})=>SI(zE(J),(U)=>{if(UW(U)){let B=new Ic(L,X,U.left);if(Q)return z.push([C,B]),qZ;else return hG(new N2(I,X,B,gm(p)))}else return p.push([C,U.right]),qZ}))}}for(let J=0;J<v.length;J++){let C=w+J;if(d<C+1)continue;else{let L=v[J](X[C],F);if(PF(L)){if(UW(L)){let z=new Ic(C,X,L.left);if(Q){R.push([H++,z]);continue}else return hG(new N2(I,X,z,gm(m)))}m.push([H++,L.right])}else{let z=H++;if(!y)y=[];y.push(({es:p,output:U})=>SI(zE(L),(B)=>{if(UW(B)){let M=new Ic(C,X,B.left);if(Q)return p.push([z,M]),qZ;else return hG(new N2(I,X,M,gm(U)))}return U.push([z,B.right]),qZ}))}}}}let A=({es:E,output:v})=>ed(E)?hG(new N2(I,X,gm(E),gm(v))):wG(gm(v));if(y&&y.length>0){let E=y;return fb(()=>{let v={es:nz(R),output:nz(m)};return SI(CV(E,(J)=>J(v),{concurrency:N,batching:c,discard:!0}),()=>A(v))})}return A({output:m,es:R})}}case"TypeLiteral":{if(I.propertySignatures.length===0&&I.indexSignatures.length===0)return GR(I,dqI);let Z=[],b={},W=[];for(let F of I.propertySignatures)Z.push([Lc(F.type,G),F]),b[F.name]=null,W.push(F.name);let l=I.indexSignatures.map((F)=>[Lc(F.parameter,G),Lc(F.type,G),F.parameter]),Y=r0.make(I.indexSignatures.map((F)=>F.parameter).concat(W.map((F)=>vC(F)?new Yt(F):new IU(F)))),N=Lc(Y,G),c=dhI(I),X=whI(I);return(F,Q)=>{if(!ecI(F))return hG(new ZR(I,F));let R=Q?.errors==="all",H=[],m=0,d=Q?.onExcessProperty==="error",w=Q?.onExcessProperty==="preserve",y={},A;if(d||w){A=Reflect.ownKeys(F);for(let C of A){let L=N(C,Q);if(PF(L)&&UW(L))if(d){let z=new Ic(C,F,new hhI(F[C],`is unexpected, expected: ${String(Y)}`));if(R){H.push([m++,z]);continue}else return hG(new N2(I,F,z,y))}else y[C]=F[C]}}let E=void 0,v=Q?.exact===!0;for(let C=0;C<Z.length;C++){let L=Z[C][1],z=L.name,p=Object.prototype.hasOwnProperty.call(F,z);if(!p){if(L.isOptional)continue;else if(v){let M=new Ic(z,F,new WU(L));if(R){H.push([m++,M]);continue}else return hG(new N2(I,F,M,y))}}let U=Z[C][0],B=U(F[z],Q);if(PF(B)){if(UW(B)){let M=new Ic(z,F,p?B.left:new WU(L));if(R){H.push([m++,M]);continue}else return hG(new N2(I,F,M,y))}y[z]=B.right}else{let M=m++,x=z;if(!E)E=[];E.push(({es:j,output:a})=>SI(zE(B),(q)=>{if(UW(q)){let D=new Ic(x,F,p?q.left:new WU(L));if(R)return j.push([M,D]),qZ;else return hG(new N2(I,F,D,a))}return a[x]=q.right,qZ}))}}for(let C=0;C<l.length;C++){let L=l[C],z=L[0],p=L[1],U=OwI(F,L[2]);for(let B of U){let M=z(B,Q);if(PF(M)&&u0(M)){let x=p(F[B],Q);if(PF(x)){if(UW(x)){let j=new Ic(B,F,x.left);if(R){H.push([m++,j]);continue}else return hG(new N2(I,F,j,y))}else if(!Object.prototype.hasOwnProperty.call(b,B))y[B]=x.right}else{let j=m++,a=B;if(!E)E=[];E.push(({es:q,output:D})=>SI(zE(x),(_)=>{if(UW(_)){let NI=new Ic(a,F,_.left);if(R)return q.push([j,NI]),qZ;else return hG(new N2(I,F,NI,D))}else{if(!Object.prototype.hasOwnProperty.call(b,B))D[B]=_.right;return qZ}}))}}}}let J=({es:C,output:L})=>{if(ed(C))return hG(new N2(I,F,gm(C),L));if(Q?.propertyOrder==="original"){let z=A||Reflect.ownKeys(F);for(let U of W)if(z.indexOf(U)===-1)z.push(U);let p={};for(let U of z)if(Object.prototype.hasOwnProperty.call(L,U))p[U]=L[U];return wG(p)}return wG(L)};if(E&&E.length>0){let C=E;return fb(()=>{let L={es:nz(H),output:Object.assign({},y)};return SI(CV(C,(z)=>z(L),{concurrency:c,batching:X,discard:!0}),()=>J(L))})}return J({es:H,output:y})}}case"Union":{let Z=kcG(I.types,G),b=Reflect.ownKeys(Z.keys),W=b.length,l=I.types.length,Y=new Map;for(let X=0;X<l;X++)Y.set(I.types[X],Lc(I.types[X],G));let N=dhI(I)??1,c=whI(I);return(X,F)=>{let Q=[],R=0,H=[];if(W>0)if(IK(X))for(let w=0;w<W;w++){let y=b[w],A=Z.keys[y].buckets;if(Object.prototype.hasOwnProperty.call(X,y)){let E=String(X[y]);if(Object.prototype.hasOwnProperty.call(A,E))H=H.concat(A[E]);else{let{candidates:v,literals:J}=Z.keys[y],C=r0.make(J),L=v.length===l?new zm([new yV(y,C,!1,!0)],[]):r0.make(v);Q.push([R++,new N2(L,X,new Ic(y,X,new ZR(C,X[y])))])}}else{let{candidates:E,literals:v}=Z.keys[y],J=new yV(y,r0.make(v),!1,!0),C=E.length===l?new zm([J],[]):r0.make(E);Q.push([R++,new N2(C,X,new Ic(y,X,new WU(J)))])}}else{let w=Z.candidates.length===l?I:r0.make(Z.candidates);Q.push([R++,new ZR(w,X)])}if(Z.otherwise.length>0)H=H.concat(Z.otherwise);let m=void 0;for(let w=0;w<H.length;w++){let y=H[w],A=Y.get(y)(X,F);if(PF(A)&&(!m||m.length===0))if(u0(A))return A;else Q.push([R++,A.left]);else{let E=R++;if(!m)m=[];m.push((v)=>fb(()=>{if("finalResult"in v)return qZ;else return SI(zE(A),(J)=>{if(u0(J))v.finalResult=J;else v.es.push([E,J.left]);return qZ})}))}}let d=(w)=>ed(w)?w.length===1&&w[0][1]._tag==="Type"?hG(w[0][1]):hG(new N2(I,X,gm(w))):hG(new ZR(I,X));if(m&&m.length>0){let w=m;return fb(()=>{let y={es:nz(Q)};return SI(CV(w,(A)=>A(y),{concurrency:N,batching:c,discard:!0}),()=>{if("finalResult"in y)return y.finalResult;return d(y.es)})})}return d(Q)}}case"Suspend":{let Z=X8(()=>Lc(I.f(),G));return(b,W)=>Z()(b,W)}}},GR=(I,G)=>(Z)=>G(Z)?wG(Z):hG(new ZR(I,Z)),h8=(I,G)=>{switch(I._tag){case"Declaration":{let Z=ZhI(I);if(cZ(Z))return h8(Z.value,G);break}case"TypeLiteral":{let Z=[];for(let b=0;b<I.propertySignatures.length;b++){let W=I.propertySignatures[b],l=G?w8(W.type):A2(W.type);if(GA(l)&&!W.isOptional)Z.push([W.name,l])}return Z}case"TupleType":{let Z=[];for(let b=0;b<I.elements.length;b++){let W=I.elements[b],l=G?w8(W.type):A2(W.type);if(GA(l)&&!W.isOptional)Z.push([b,l])}return Z}case"Refinement":return h8(I.from,G);case"Suspend":return h8(I.f(),G);case"Transformation":return h8(G?I.from:I.to,G)}return[]},kcG=(I,G)=>{let Z={},b=[],W=[];for(let l=0;l<I.length;l++){let Y=I[l],N=h8(Y,G);if(N.length>0){W.push(Y);for(let c=0;c<N.length;c++){let[X,F]=N[c],Q=String(F.literal);Z[X]=Z[X]||{buckets:{},literals:[],candidates:[]};let R=Z[X].buckets;if(Object.prototype.hasOwnProperty.call(R,Q)){if(c<N.length-1)continue;R[Q].push(Y),Z[X].literals.push(F),Z[X].candidates.push(Y)}else{R[Q]=[Y],Z[X].literals.push(F),Z[X].candidates.push(Y);break}}}else b.push(Y)}return{keys:Z,otherwise:b,candidates:W}},gcG=(I)=>rE(I)?gcG(I.from):I,J8=(I,G,Z,b)=>{if(b?.isEffectAllowed===!0)return I;if(PF(I))return I;let W=new g6,l=Pj(I,{scheduler:W});W.flush();let Y=l.unsafePoll();if(Y){if(R1(Y))return wG(Y.value);let N=Y.cause;if(UFI(N))return hG(N.error);return hG(new JhI(G,Z,MFI(N)))}return hG(new JhI(G,Z,"cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work"))},liZ=([I],[G])=>I>G?1:I<G?-1:0,YiZ=(I,G)=>{switch(I._tag){case"FinalTransformation":return G?I.decode:I.encode;case"ComposeTransformation":return wG;case"TypeLiteralTransformation":return(Z)=>{let b=wG(Z);for(let W of I.propertySignatureTransformations){let[l,Y]=G?[W.from,W.to]:[W.to,W.from],N=G?W.decode:W.encode;b=_F(b,(X)=>{let F=N(Object.prototype.hasOwnProperty.call(X,l)?XI(X[l]):mI());if(delete X[l],cZ(F))X[Y]=F.value;return X})}return b}}},TX=(I,G=[])=>({value:I,forest:G}),v8,NiZ=(I)=>I.value+UcG(`
@@ -7565,7 +7565,7 @@ updatedAt: "${W.updatedAt.toISOString()}"
7565
7565
  ---
7566
7566
 
7567
7567
  `+W.systemPrompt;return yield*h.tryPromise({try:async()=>{if(l!==b)await RF.mkdir(l,{recursive:!0}),await RF.writeFile(Dd.join(l,ux),N,"utf-8"),await RF.rm(b,{recursive:!0});else await RF.writeFile(Dd.join(l,ux),N,"utf-8")},catch:(c)=>new zc({operation:"write",path:l,reason:`Failed to update persona: ${c instanceof Error?c.message:String(c)}`})}),W}.bind(this))}deletePersona(I){return h.gen(function*(){if(Yz(I))return yield*h.fail(new zc({operation:"delete",path:I,reason:"Built-in personas cannot be deleted."}));let G=yield*this.getPersona(I),Z=this.getPersonaDir(G.name);yield*h.tryPromise({try:()=>RF.rm(Z,{recursive:!0}),catch:(b)=>new zc({operation:"delete",path:Z,reason:`Failed to delete persona: ${b instanceof Error?b.message:String(b)}`})})}.bind(this))}getPersonaByIdentifier(I){return h.gen(function*(){let G=yield*this.getPersona(I).pipe(h.catchTag("StorageNotFoundError",()=>h.succeed(null)));if(G)return G;return yield*this.getPersonaByName(I)}.bind(this))}}function CEZ(I){if(!I||I.trim().length===0)return h.fail(new Gc({field:"name",message:"Persona name cannot be empty",value:I,suggestion:"Provide a descriptive name for your persona, e.g., 'hacker', 'therapist', 'pirate'"}));if(I.length>100)return h.fail(new Gc({field:"name",message:"Persona name cannot exceed 100 characters",value:I,suggestion:`Use a shorter name (${I.length}/100 characters)`}));if(!/^[a-zA-Z0-9_-]+$/.test(I))return h.fail(new Gc({field:"name",message:"Persona name can only contain letters, numbers, underscores, and hyphens",value:I,suggestion:"Use only letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens (-). Example: 'cyber-punk'"}));return h.void}function yEZ(I){if(!I||I.trim().length===0)return h.fail(new Gc({field:"description",message:"Persona description cannot be empty",value:I,suggestion:"Describe the persona's character, e.g., 'A sarcastic hacker who explains everything in l33t speak'"}));if(I.length>500)return h.fail(new Gc({field:"description",message:"Persona description cannot exceed 500 characters",value:I,suggestion:`Use a shorter description (${I.length}/500 characters)`}));return h.void}function AEZ(I){if(!I||I.trim().length===0)return h.fail(new Gc({field:"systemPrompt",message:"System prompt cannot be empty",value:I,suggestion:"Provide instructions that define how the persona should behave, e.g., 'You are a cyberpunk hacker. Always use technical jargon and l33t speak...'"}));if(I.length>1e4)return h.fail(new Gc({field:"systemPrompt",message:"System prompt cannot exceed 10,000 characters",value:`(${I.length} chars)`,suggestion:`Use a shorter system prompt (${I.length}/10000 characters). Focus on the essential behavioral rules.`}));return h.void}function kEZ(){return dG.succeed(iF,new zEZ)}var pEZ,ux="persona.md",SyW,PyW;var f8I=u(()=>{OI();ml();MU();lN();Se();AV();pEZ=gW(t8(),1);SyW=["default","coder","researcher"],PyW=["summarizer"]});var i8I=200,o8I=500;function gEZ(I,G){let Z=new Intl.DateTimeFormat("en-US",{timeZone:G,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).formatToParts(new Date(I)),b={};for(let l of Z)if(l.type!=="literal")b[l.type]=Number(l.value);return Date.UTC(b.year??1970,(b.month??1)-1,b.day??1,b.hour??0,b.minute??0,b.second??0)-I}function $yW(I,G){let Z=new Intl.DateTimeFormat("en-CA",{timeZone:G,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(I)),b={};for(let W of Z)if(W.type!=="literal")b[W.type]=Number(W.value);return{year:b.year??1970,month:b.month??1,day:b.day??1}}function UEZ(I,G,Z,b,W,l){let Y=Date.UTC(I,G-1,Z,b,W,0),N=Y-gEZ(Y,l);return Y-gEZ(N,l)}function uEZ(I,G,Z){let b=I.trim().toLowerCase(),W=/^tomorrow\s+(\d{1,2}):(\d{2})$/.exec(b),l=W??/^(\d{1,2}):(\d{2})$/.exec(b);if(l){let c=Number(l[1]),X=Number(l[2]);if(c>23||X>59)return null;let F=$yW(G,Z),Q=W?1:0,R=UEZ(F.year,F.month,F.day+Q,c,X,Z);if(!W&&R<=G)R=UEZ(F.year,F.month,F.day+1,c,X,Z);return R}let Y=0;for(let c of b.matchAll(/(\d+)\s*([smhd])/g))Y+=Number(c[1])*(nyW[c[2]??""]??0);let N=b.replace(/(\d+)\s*([smhd])/g,"").trim();if(Y>0&&N==="")return G+Y;return null}var nyW;var BEZ=u(()=>{nyW={s:1000,m:60000,h:3600000,d:86400000}});import*as Nz from"node:path";function OEZ(I){return fyW.test(I)?h.void:h.fail(new wcI(`Invalid agent id: "${I}".`))}function iyW(){return Math.random().toString(36).slice(2,10)}function s8I(I,G){return Nz.join(I,`${G}.json`)}function oyW(I,G){return Nz.join(I,`${G}.lock`)}function r8I(I,G){return h.gen(function*(){if(!(yield*I.exists(G).pipe(h.catchAll(()=>h.succeed(!1)))))return[];let b=yield*I.readFileString(G).pipe(h.catchAll((W)=>h.fail(W instanceof Error?W:Error(String(W)))));try{let W=JSON.parse(b);return Array.isArray(W)?W:[]}catch{return[]}})}function MEZ(I,G,Z){return h.gen(function*(){let b=Nz.dirname(G),W=Nz.join(b,`.reminders-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`);yield*I.makeDirectory(b,{recursive:!0}).pipe(h.catchAll((l)=>h.fail(l instanceof Error?l:Error(String(l))))),yield*I.writeFileString(W,`${JSON.stringify(Z,null,2)}
7568
- `).pipe(h.catchAll((l)=>h.fail(l instanceof Error?l:Error(String(l))))),yield*I.rename(W,G).pipe(h.tapError(()=>I.remove(W).pipe(h.catchAll(()=>h.void))),h.catchAll((l)=>h.fail(l instanceof Error?l:Error(String(l)))))})}class xEZ{baseReminderDirectory;constructor(I){this.baseReminderDirectory=I?.baseReminderDirectory??Nz.join(bR(),"reminders")}withValidatedAgentLock(I,G){let Z=oyW(this.baseReminderDirectory,I);return h.gen(function*(){return yield*OEZ(I),yield*qM(Z,G)})}add=(I,G,Z,b)=>this.withValidatedAgentLock(I,h.gen(function*(){let W=yield*_I.FileSystem,l=s8I(this.baseReminderDirectory,I),Y=yield*r8I(W,l);if(Z.length>o8I)return yield*h.fail(new wcI(`Reminder text is ${Z.length} characters, exceeding the maximum of ${o8I}.`));if(Y.length>=i8I)return yield*h.fail(new wcI(`You already have ${Y.length} pending reminders, the maximum of ${i8I}.`));let N=uEZ(G,Date.now(),b);if(N===null)return{success:!1,message:`Could not understand the time '${G}' — try things like '30m', '2h', '18:00', or 'tomorrow 09:00'.`};let c={id:iyW(),fireAt:N,text:Z,createdAt:Date.now()};return yield*MEZ(W,l,[...Y,c]),{success:!0,reminder:c}}.bind(this)));list=(I)=>h.gen(function*(){yield*OEZ(I);let G=yield*_I.FileSystem,Z=s8I(this.baseReminderDirectory,I);return yield*r8I(G,Z)}.bind(this));cancel=(I,G)=>this.withValidatedAgentLock(I,h.gen(function*(){let Z=yield*_I.FileSystem,b=s8I(this.baseReminderDirectory,I),W=yield*r8I(Z,b),l=W.filter((Y)=>Y.id!==G);if(l.length===W.length)return{success:!1,message:`No reminder found with id "${G}".`};return yield*MEZ(Z,b,l),{success:!0,message:"Reminder cancelled."}}.bind(this)))}function KEZ(I){return dG.succeed(NB,new xEZ(I))}var wcI,fyW;var jEZ=u(()=>{xb();OI();ypI();vNI();AV();BEZ();wcI=class wcI extends Error{};fyW=/^[A-Za-z0-9_-]{1,64}$/});function syW(I){let G=new Date,Z=typeof I.createdAt==="string"?new Date(I.createdAt):G,b=Number.isNaN(Z.getTime())?G:Z;if(typeof I.updatedAt==="string"){let W=new Date(I.updatedAt),l=Number.isNaN(W.getTime())?b:W;return{createdAt:b,updatedAt:l}}return{createdAt:b,updatedAt:b}}class t8I{basePath;fs;constructor(I,G){this.basePath=I;this.fs=G}isNotFoundError(I){if(I&&typeof I==="object"){if(I._tag==="NotFound")return!0;if(I.code==="ENOENT")return!0;if(I.cause?.code==="ENOENT")return!0;let W=I.message;if(typeof W==="string"&&W.includes("ENOENT"))return!0}return!1}mapReadError(I,G){if(this.isNotFoundError(G))return new kJ({path:I,suggestion:"Verify the requested resource exists or create it first."});let Z=G instanceof Error?G.message:typeof G==="string"?G:String(G);return new zc({operation:"read",path:I,reason:`Failed to read file: ${Z}`})}getAgentsDir(){return`${this.basePath}/agents`}getAgentPath(I){return`${this.getAgentsDir()}/${I}.json`}ensureDirectoryExists(I){return h.gen(function*(){yield*this.fs.makeDirectory(I,{recursive:!0}).pipe(h.mapError((G)=>new zc({operation:"mkdir",path:I,reason:`Failed to create directory: ${String(G)}`})),h.catchAll(()=>h.void))}.bind(this))}readAgentFile(I){return h.gen(function*(){let G=yield*this.fs.readFileString(I).pipe(h.mapError((R)=>this.mapReadError(I,R))),Z=yield*CZZ(G).pipe(h.mapError((R)=>new zc({operation:"read",path:I,reason:`Invalid JSON format: ${R.message}`}))),b;try{b=bF(Z.config?.tools,{agentId:Z.id})}catch(R){if(R instanceof V2)return yield*h.fail(new zc({operation:"read",path:I,reason:`Invalid tool configuration: ${R.message}`}));throw R}let{tools:W,...l}=Z.config,Y=l;if(!Y.persona)Y.persona=Y.agentType||"default";let N=Y,c=b.length>0?{...N,tools:b}:N,{createdAt:X,updatedAt:F}=syW(Z);return{...Z,model:`${c.llmProvider}/${c.llmModel}`,config:c,createdAt:X,updatedAt:F}}.bind(this))}writeJsonFile(I,G){return h.gen(function*(){let Z=JSON.stringify(G,null,2);yield*this.fs.writeFileString(I,Z).pipe(h.mapError((b)=>new zc({operation:"write",path:I,reason:`Failed to write file: ${String(b)}`})))}.bind(this))}listJsonFiles(I){return h.gen(function*(){return yield*this.ensureDirectoryExists(I),(yield*this.fs.readDirectory(I).pipe(h.mapError((Z)=>new zc({operation:"list",path:I,reason:`Failed to list directory: ${String(Z)}`})))).filter((Z)=>Z.endsWith(".json"))}.bind(this))}saveAgent(I){return h.gen(function*(){let G=this.getAgentsDir();yield*this.ensureDirectoryExists(G);let Z=this.getAgentPath(I.id);yield*this.writeJsonFile(Z,I)}.bind(this))}getAgent(I){let G=this.getAgentPath(I);return this.readAgentFile(G)}listAgents(){return h.gen(function*(){let I=this.getAgentsDir(),G=yield*this.listJsonFiles(I),Z=[];for(let b of G){let W=`${I}/${b}`,l=yield*this.readAgentFile(W).pipe(h.catchAll(()=>h.void));if(l)Z.push(l)}return Z}.bind(this))}deleteAgent(I){return h.gen(function*(){let G=this.getAgentPath(I);yield*this.fs.remove(G).pipe(h.mapError((Z)=>{if(Z instanceof Error&&Z.cause.code.includes("ENOENT"))return new kJ({path:G});return new zc({operation:"delete",path:G,reason:`Failed to delete file: ${String(Z)}`})}))}.bind(this))}}var DEZ=u(()=>{OI();Gp();QNI();lN();uP()});import{randomUUID as ryW}from"node:crypto";import{appendFile as qEZ,mkdir as aEZ,readFile as tyW,readdir as TEZ,unlink as eyW}from"node:fs/promises";import f4 from"node:path";function bAW(){return f4.join(I9(),"telemetry")}function e8I(I){return I.toISOString().slice(0,10)}function WAW(){return{totalRequests:0,totalTokens:0,promptTokens:0,completionTokens:0,reasoningTokens:0,cacheReadTokens:0,cacheWriteTokens:0,toolDefinitionTokens:0,toolResultTokens:0,toolDefinitionsOffered:0,totalToolCalls:0,totalToolErrors:0,totalAgentRuns:0,totalDurationMs:0,byModel:{},byAgent:{}}}class SEZ{storagePath;enabled;bufferSize;flushIntervalMs;retentionDays;buffer=[];flushTimer=null;dirCreated=!1;constructor(I,G,Z,b,W){this.storagePath=I;this.enabled=G;this.bufferSize=Z;this.flushIntervalMs=b;this.retentionDays=W;if(this.enabled&&this.flushIntervalMs>0){if(this.flushTimer=setInterval(()=>{this.flushSync()},this.flushIntervalMs),this.flushTimer&&typeof this.flushTimer==="object"&&"unref"in this.flushTimer)this.flushTimer.unref()}}recordAgentRunStarted(I){return this.appendEvent("agent_run_started",I,{agentId:I.agentId,sessionId:I.conversationId})}recordAgentRunCompleted(I){return this.appendEvent("agent_run_completed",I,{agentId:I.agentId,sessionId:I.conversationId})}recordAgentRunFailed(I){return this.appendEvent("agent_run_failed",I,{agentId:I.agentId,sessionId:I.conversationId})}recordLLMUsage(I){let G={};if(I.agentId!==void 0)G.agentId=I.agentId;if(I.sessionId!==void 0)G.sessionId=I.sessionId;return this.appendEvent("llm_usage",I,G)}recordLLMRetry(I){let G={};if(I.agentId!==void 0)G.agentId=I.agentId;return this.appendEvent("llm_retry",I,G)}recordToolInvocation(I){let G=I.success?"tool_invocation":"tool_error",Z={};if(I.agentId!==void 0)Z.agentId=I.agentId;if(I.sessionId!==void 0)Z.sessionId=I.sessionId;return this.appendEvent(G,I,Z)}recordCommandExecuted(I){return this.appendEvent("command_executed",I)}recordEvent(I,G,Z){return this.appendEvent(I,G,Z)}getEvents(I){return h.gen(function*(){if(!this.enabled)return[];let Z=yield*this.loadAllEvents();if(I?.types&&I.types.length>0){let l=new Set(I.types);Z=Z.filter((Y)=>l.has(Y.type))}if(I?.agentId){let l=I.agentId;Z=Z.filter((Y)=>Y.agentId===l)}if(I?.sessionId){let l=I.sessionId;Z=Z.filter((Y)=>Y.sessionId===l)}if(I?.from){let l=I.from;Z=Z.filter((Y)=>Y.timestamp>=l)}if(I?.to){let l=I.to;Z=Z.filter((Y)=>Y.timestamp<=l)}Z.sort((l,Y)=>Y.timestamp.localeCompare(l.timestamp));let b=I?.offset??0,W=I?.limit??Z.length;return Z.slice(b,b+W)}.bind(this))}getUsageSummary(I){return h.gen(function*(){if(!this.enabled)return WAW();let G={};if(I?.from!==void 0)G.from=I.from;if(I?.to!==void 0)G.to=I.to;if(I?.agentId!==void 0)G.agentId=I.agentId;let Z=yield*this.getEvents(G);return this.aggregateUsage(Z)}.bind(this))}flush(){return h.gen(function*(){yield*this.flushBuffer()}.bind(this))}shutdown(){return h.gen(function*(){if(this.flushTimer)clearInterval(this.flushTimer),this.flushTimer=null;yield*this.flushBuffer()}.bind(this))}appendEvent(I,G,Z){return h.gen(function*(){if(!this.enabled)return;let b={id:ryW(),type:I,timestamp:new Date().toISOString(),data:G,...Z?.agentId?{agentId:Z.agentId}:{},...Z?.sessionId?{sessionId:Z.sessionId}:{}};if(this.buffer.push(b),this.buffer.length>=this.bufferSize)yield*this.flushBuffer()}.bind(this))}flushBuffer(){return h.gen(function*(){if(this.buffer.length===0)return;let I=[...this.buffer];this.buffer=[],yield*this.writeEvents(I)}.bind(this))}async flushSync(){if(this.buffer.length===0)return;let I=[...this.buffer];this.buffer=[];let G=f4.join(this.storagePath,hcI);try{if(!this.dirCreated)await aEZ(G,{recursive:!0}),this.dirCreated=!0;let Z=new Map;for(let b of I){let W=e8I(new Date(b.timestamp)),l=Z.get(W);if(l)l.push(b);else Z.set(W,[b])}for(let[b,W]of Z){let l=f4.join(G,`${b}.ndjson`),Y=W.map((N)=>JSON.stringify(N)).join(`
7568
+ `).pipe(h.catchAll((l)=>h.fail(l instanceof Error?l:Error(String(l))))),yield*I.rename(W,G).pipe(h.tapError(()=>I.remove(W).pipe(h.catchAll(()=>h.void))),h.catchAll((l)=>h.fail(l instanceof Error?l:Error(String(l)))))})}class xEZ{baseReminderDirectory;constructor(I){this.baseReminderDirectory=I?.baseReminderDirectory??Nz.join(bR(),"reminders")}withValidatedAgentLock(I,G){let Z=oyW(this.baseReminderDirectory,I),b=this.baseReminderDirectory;return h.gen(function*(){return yield*OEZ(I),yield*(yield*_I.FileSystem).makeDirectory(b,{recursive:!0}).pipe(h.catchAll((l)=>h.fail(l instanceof Error?l:Error(String(l))))),yield*qM(Z,G)})}add=(I,G,Z,b)=>this.withValidatedAgentLock(I,h.gen(function*(){let W=yield*_I.FileSystem,l=s8I(this.baseReminderDirectory,I),Y=yield*r8I(W,l);if(Z.length>o8I)return yield*h.fail(new wcI(`Reminder text is ${Z.length} characters, exceeding the maximum of ${o8I}.`));if(Y.length>=i8I)return yield*h.fail(new wcI(`You already have ${Y.length} pending reminders, the maximum of ${i8I}.`));let N=uEZ(G,Date.now(),b);if(N===null)return{success:!1,message:`Could not understand the time '${G}' — try things like '30m', '2h', '18:00', or 'tomorrow 09:00'.`};let c={id:iyW(),fireAt:N,text:Z,createdAt:Date.now()};return yield*MEZ(W,l,[...Y,c]),{success:!0,reminder:c}}.bind(this)));list=(I)=>h.gen(function*(){yield*OEZ(I);let G=yield*_I.FileSystem,Z=s8I(this.baseReminderDirectory,I);return yield*r8I(G,Z)}.bind(this));cancel=(I,G)=>this.withValidatedAgentLock(I,h.gen(function*(){let Z=yield*_I.FileSystem,b=s8I(this.baseReminderDirectory,I),W=yield*r8I(Z,b),l=W.filter((Y)=>Y.id!==G);if(l.length===W.length)return{success:!1,message:`No reminder found with id "${G}".`};return yield*MEZ(Z,b,l),{success:!0,message:"Reminder cancelled."}}.bind(this)))}function KEZ(I){return dG.succeed(NB,new xEZ(I))}var wcI,fyW;var jEZ=u(()=>{xb();OI();ypI();vNI();AV();BEZ();wcI=class wcI extends Error{};fyW=/^[A-Za-z0-9_-]{1,64}$/});function syW(I){let G=new Date,Z=typeof I.createdAt==="string"?new Date(I.createdAt):G,b=Number.isNaN(Z.getTime())?G:Z;if(typeof I.updatedAt==="string"){let W=new Date(I.updatedAt),l=Number.isNaN(W.getTime())?b:W;return{createdAt:b,updatedAt:l}}return{createdAt:b,updatedAt:b}}class t8I{basePath;fs;constructor(I,G){this.basePath=I;this.fs=G}isNotFoundError(I){if(I&&typeof I==="object"){if(I._tag==="NotFound")return!0;if(I.code==="ENOENT")return!0;if(I.cause?.code==="ENOENT")return!0;let W=I.message;if(typeof W==="string"&&W.includes("ENOENT"))return!0}return!1}mapReadError(I,G){if(this.isNotFoundError(G))return new kJ({path:I,suggestion:"Verify the requested resource exists or create it first."});let Z=G instanceof Error?G.message:typeof G==="string"?G:String(G);return new zc({operation:"read",path:I,reason:`Failed to read file: ${Z}`})}getAgentsDir(){return`${this.basePath}/agents`}getAgentPath(I){return`${this.getAgentsDir()}/${I}.json`}ensureDirectoryExists(I){return h.gen(function*(){yield*this.fs.makeDirectory(I,{recursive:!0}).pipe(h.mapError((G)=>new zc({operation:"mkdir",path:I,reason:`Failed to create directory: ${String(G)}`})),h.catchAll(()=>h.void))}.bind(this))}readAgentFile(I){return h.gen(function*(){let G=yield*this.fs.readFileString(I).pipe(h.mapError((R)=>this.mapReadError(I,R))),Z=yield*CZZ(G).pipe(h.mapError((R)=>new zc({operation:"read",path:I,reason:`Invalid JSON format: ${R.message}`}))),b;try{b=bF(Z.config?.tools,{agentId:Z.id})}catch(R){if(R instanceof V2)return yield*h.fail(new zc({operation:"read",path:I,reason:`Invalid tool configuration: ${R.message}`}));throw R}let{tools:W,...l}=Z.config,Y=l;if(!Y.persona)Y.persona=Y.agentType||"default";let N=Y,c=b.length>0?{...N,tools:b}:N,{createdAt:X,updatedAt:F}=syW(Z);return{...Z,model:`${c.llmProvider}/${c.llmModel}`,config:c,createdAt:X,updatedAt:F}}.bind(this))}writeJsonFile(I,G){return h.gen(function*(){let Z=JSON.stringify(G,null,2);yield*this.fs.writeFileString(I,Z).pipe(h.mapError((b)=>new zc({operation:"write",path:I,reason:`Failed to write file: ${String(b)}`})))}.bind(this))}listJsonFiles(I){return h.gen(function*(){return yield*this.ensureDirectoryExists(I),(yield*this.fs.readDirectory(I).pipe(h.mapError((Z)=>new zc({operation:"list",path:I,reason:`Failed to list directory: ${String(Z)}`})))).filter((Z)=>Z.endsWith(".json"))}.bind(this))}saveAgent(I){return h.gen(function*(){let G=this.getAgentsDir();yield*this.ensureDirectoryExists(G);let Z=this.getAgentPath(I.id);yield*this.writeJsonFile(Z,I)}.bind(this))}getAgent(I){let G=this.getAgentPath(I);return this.readAgentFile(G)}listAgents(){return h.gen(function*(){let I=this.getAgentsDir(),G=yield*this.listJsonFiles(I),Z=[];for(let b of G){let W=`${I}/${b}`,l=yield*this.readAgentFile(W).pipe(h.catchAll(()=>h.void));if(l)Z.push(l)}return Z}.bind(this))}deleteAgent(I){return h.gen(function*(){let G=this.getAgentPath(I);yield*this.fs.remove(G).pipe(h.mapError((Z)=>{if(Z instanceof Error&&Z.cause.code.includes("ENOENT"))return new kJ({path:G});return new zc({operation:"delete",path:G,reason:`Failed to delete file: ${String(Z)}`})}))}.bind(this))}}var DEZ=u(()=>{OI();Gp();QNI();lN();uP()});import{randomUUID as ryW}from"node:crypto";import{appendFile as qEZ,mkdir as aEZ,readFile as tyW,readdir as TEZ,unlink as eyW}from"node:fs/promises";import f4 from"node:path";function bAW(){return f4.join(I9(),"telemetry")}function e8I(I){return I.toISOString().slice(0,10)}function WAW(){return{totalRequests:0,totalTokens:0,promptTokens:0,completionTokens:0,reasoningTokens:0,cacheReadTokens:0,cacheWriteTokens:0,toolDefinitionTokens:0,toolResultTokens:0,toolDefinitionsOffered:0,totalToolCalls:0,totalToolErrors:0,totalAgentRuns:0,totalDurationMs:0,byModel:{},byAgent:{}}}class SEZ{storagePath;enabled;bufferSize;flushIntervalMs;retentionDays;buffer=[];flushTimer=null;dirCreated=!1;constructor(I,G,Z,b,W){this.storagePath=I;this.enabled=G;this.bufferSize=Z;this.flushIntervalMs=b;this.retentionDays=W;if(this.enabled&&this.flushIntervalMs>0){if(this.flushTimer=setInterval(()=>{this.flushSync()},this.flushIntervalMs),this.flushTimer&&typeof this.flushTimer==="object"&&"unref"in this.flushTimer)this.flushTimer.unref()}}recordAgentRunStarted(I){return this.appendEvent("agent_run_started",I,{agentId:I.agentId,sessionId:I.conversationId})}recordAgentRunCompleted(I){return this.appendEvent("agent_run_completed",I,{agentId:I.agentId,sessionId:I.conversationId})}recordAgentRunFailed(I){return this.appendEvent("agent_run_failed",I,{agentId:I.agentId,sessionId:I.conversationId})}recordLLMUsage(I){let G={};if(I.agentId!==void 0)G.agentId=I.agentId;if(I.sessionId!==void 0)G.sessionId=I.sessionId;return this.appendEvent("llm_usage",I,G)}recordLLMRetry(I){let G={};if(I.agentId!==void 0)G.agentId=I.agentId;return this.appendEvent("llm_retry",I,G)}recordToolInvocation(I){let G=I.success?"tool_invocation":"tool_error",Z={};if(I.agentId!==void 0)Z.agentId=I.agentId;if(I.sessionId!==void 0)Z.sessionId=I.sessionId;return this.appendEvent(G,I,Z)}recordCommandExecuted(I){return this.appendEvent("command_executed",I)}recordEvent(I,G,Z){return this.appendEvent(I,G,Z)}getEvents(I){return h.gen(function*(){if(!this.enabled)return[];let Z=yield*this.loadAllEvents();if(I?.types&&I.types.length>0){let l=new Set(I.types);Z=Z.filter((Y)=>l.has(Y.type))}if(I?.agentId){let l=I.agentId;Z=Z.filter((Y)=>Y.agentId===l)}if(I?.sessionId){let l=I.sessionId;Z=Z.filter((Y)=>Y.sessionId===l)}if(I?.from){let l=I.from;Z=Z.filter((Y)=>Y.timestamp>=l)}if(I?.to){let l=I.to;Z=Z.filter((Y)=>Y.timestamp<=l)}Z.sort((l,Y)=>Y.timestamp.localeCompare(l.timestamp));let b=I?.offset??0,W=I?.limit??Z.length;return Z.slice(b,b+W)}.bind(this))}getUsageSummary(I){return h.gen(function*(){if(!this.enabled)return WAW();let G={};if(I?.from!==void 0)G.from=I.from;if(I?.to!==void 0)G.to=I.to;if(I?.agentId!==void 0)G.agentId=I.agentId;let Z=yield*this.getEvents(G);return this.aggregateUsage(Z)}.bind(this))}flush(){return h.gen(function*(){yield*this.flushBuffer()}.bind(this))}shutdown(){return h.gen(function*(){if(this.flushTimer)clearInterval(this.flushTimer),this.flushTimer=null;yield*this.flushBuffer()}.bind(this))}appendEvent(I,G,Z){return h.gen(function*(){if(!this.enabled)return;let b={id:ryW(),type:I,timestamp:new Date().toISOString(),data:G,...Z?.agentId?{agentId:Z.agentId}:{},...Z?.sessionId?{sessionId:Z.sessionId}:{}};if(this.buffer.push(b),this.buffer.length>=this.bufferSize)yield*this.flushBuffer()}.bind(this))}flushBuffer(){return h.gen(function*(){if(this.buffer.length===0)return;let I=[...this.buffer];this.buffer=[],yield*this.writeEvents(I)}.bind(this))}async flushSync(){if(this.buffer.length===0)return;let I=[...this.buffer];this.buffer=[];let G=f4.join(this.storagePath,hcI);try{if(!this.dirCreated)await aEZ(G,{recursive:!0}),this.dirCreated=!0;let Z=new Map;for(let b of I){let W=e8I(new Date(b.timestamp)),l=Z.get(W);if(l)l.push(b);else Z.set(W,[b])}for(let[b,W]of Z){let l=f4.join(G,`${b}.ndjson`),Y=W.map((N)=>JSON.stringify(N)).join(`
7569
7569
  `)+`
7570
7570
  `;await qEZ(l,Y,{encoding:"utf8"})}}catch{this.buffer.unshift(...I)}}writeEvents(I){return h.gen(function*(){let G=f4.join(this.storagePath,hcI);yield*h.tryPromise({try:async()=>{if(!this.dirCreated)await aEZ(G,{recursive:!0}),this.dirCreated=!0},catch:(b)=>new YJI({path:G,message:`Failed to create telemetry directory: ${String(b)}`,cause:b,suggestion:"Check file system permissions for the telemetry storage path."})}).pipe(h.mapError((b)=>new G9({operation:"flush",message:b.message,cause:b})));let Z=new Map;for(let b of I){let W=e8I(new Date(b.timestamp)),l=Z.get(W);if(l)l.push(b);else Z.set(W,[b])}for(let[b,W]of Z){let l=f4.join(G,`${b}.ndjson`),Y=W.map((N)=>JSON.stringify(N)).join(`
7571
7571
  `)+`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jazz-ai",
3
- "version": "0.13.8",
3
+ "version": "0.13.9",
4
4
  "description": "Your terminal. Your agent. Your rules.",
5
5
  "license": "MIT",
6
6
  "main": "dist/main.js",