@tbox.cn/tboxcode-dsh-llm 0.0.0-stage → 0.1.0-rc.1

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.
@@ -0,0 +1,3 @@
1
+ import{randomBytes as e}from"node:crypto";import{appendFile as t,mkdir as n,readFile as r,readdir as i,rm as a,stat as o,writeFile as s}from"node:fs/promises";import{dirname as c,join as l}from"node:path";import{zstdCompressSync as u,zstdDecompressSync as d}from"node:zlib";function f(e){if(e.length===0)throw Error(`cannot encode an empty path segment`);if(e===`.`)return`~002E`;if(e===`..`)return`~002E~002E`;let t=``;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n),i=String.fromCharCode(r);i!==`~`&&/^[A-Za-z0-9._-]$/.test(i)?t+=i:t+=`~`+r.toString(16).toUpperCase().padStart(4,`0`)}return t}function p(e){if(e.length===0)throw Error(`cannot encode an empty project path`);let t=``,n=!1;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r),a=String.fromCharCode(i);a===`/`||a===`\\`||a===`:`?(n||(t+=`-`),n=!0):a!==`~`&&/^[A-Za-z0-9._-]$/.test(a)?(t+=a,n=!1):(t+=`~`+i.toString(16).toUpperCase().padStart(4,`0`),n=!1)}return`--${(t.replace(/^-+/,``)||`root`).slice(0,251)}--`}function m(e,t){return t===void 0?l(e,`_no-cwd`):l(e,p(t))}function h(e,t,n){return l(m(e,t),f(n))}function g(e,t,n){return l(h(e,t,n),`tboxcode`,`llm-calls`)}function _(e){return l(e,`_tboxcode`,`orphan-llm-calls`)}const v=new Set([`authorization`,`x-api-key`,`api-key`,`cookie`,`proxy-authorization`,`x-goog-api-key`]);function y(e){return e.length<=8?e.slice(0,4):`${e.slice(0,4)}***${e.slice(-4)}`}function b(e){if(!e)return;let t=Object.fromEntries(Object.entries(e).filter(([e])=>!v.has(e.toLowerCase())));return Object.keys(t).length>0?t:void 0}function x(e){let t={};for(let[n,r]of Object.entries(e)){let e=n.toLowerCase(),i=Array.isArray(r)?r.join(`, `):String(r??``);t[n]=v.has(e)?y(i):i}return t}function S(e,t){if(t<=0||Buffer.byteLength(e,`utf-8`)<=t)return{text:e,truncated:!1};let n=``,r=0;for(let i of e){let e=Buffer.byteLength(i,`utf-8`);if(r+e>t)break;n+=i,r+=e}return{text:n,truncated:!0}}function C(){return e(4).toString(`hex`)}function w(e=new Date){let t=(e,t=2)=>String(e).padStart(t,`0`);return`${e.getFullYear()}${t(e.getMonth()+1)}${t(e.getDate())}-${t(e.getHours())}${t(e.getMinutes())}${t(e.getSeconds())}-${t(e.getMilliseconds(),3)}`}function T(e,t,n,r){let i;try{i=new URL(t)}catch{i={pathname:t,search:``}}let a=[`${e} ${i.pathname}${i.search??``} HTTP/1.1`];for(let[e,t]of Object.entries(n))a.push(`${e}: ${t}`);return a.push(``,r),a.join(`
2
+ `)}function E(e,t,n,r){let i=[`HTTP/1.1 ${e} ${t||``}`.trimEnd()];for(let[e,t]of Object.entries(n))i.push(`${e}: ${t}`);return i.push(``,r),i.join(`
3
+ `)}function D(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}var O=class{partPath;ts;callIdShort;slug;buf=``;byteCount=0;finalized=!1;disabled=!1;finalizedFile=null;partFilename;_ioChain=Promise.resolve();done;_doneResolve;constructor(e,t,n,r,i,a,o){this.logDir=e,this.max_file_bytes=i,this.onError=o,this.ts=a,this.callIdShort=n?n.replace(/^llmc_/,``).slice(0,8):C(),this.slug=`${t}_${this.callIdShort}_${r}`,this.partFilename=`${this.ts}_${this.slug}.http.part`,this.partPath=l(e,this.partFilename);let s;this.done=new Promise(e=>{s=e}),this._doneResolve=s}finalFilename(e){return`${this.ts}_${this.slug}_${e}.http.zst`}append(e){if(!(this.finalized||this.disabled)){if(this.max_file_bytes>0){let t=this.byteCount+Buffer.byteLength(e,`utf-8`);if(this.byteCount>=this.max_file_bytes)return;if(t>this.max_file_bytes){let{text:t}=S(e,this.max_file_bytes-this.byteCount);this.buf+=t,this.buf+=`\n[truncated at ${D(this.max_file_bytes)}]\n`,this.byteCount=this.max_file_bytes;return}}this.buf+=e,this.byteCount+=this.max_file_bytes>0?Buffer.byteLength(e,`utf-8`):0}}writeMeta(e){for(let[t,n]of Object.entries(e))this.append(`# ${t}: ${n}\n`)}writeRequest(e){this.append(e),this._flushToPartAsync()}writeResponse(e,t,n){this.append(`\n######## RESPONSE (header: ${e.toFixed(0)}ms, body: ${t.toFixed(0)}ms) ########\n\n`),this.append(n)}writeTrailer(e,t,n,r,i){this.append(`\n# duration: ${e.toFixed(0)}ms\n`),this.append(`# header-ttfb: ${t.toFixed(0)}ms\n`),this.append(`# ttfb: ${n.toFixed(0)}ms\n`),this.append(`# body-size: request=${D(r)}, response=${D(i)}\n`)}async finalize(e){if(this.finalized)return this.finalizedFile;if(this.finalized=!0,!this.disabled){this._flushToPartAsync();let t=l(this.logDir,this.finalFilename(e)),n=this.partPath;await new Promise(r=>{this._ioChain=this._ioChain.then(async()=>{try{await s(t,u(Buffer.from(this.buf,`utf-8`))),await a(n,{force:!0}),this.finalizedFile=this.finalFilename(e)}catch{this.finalizedFile=this.partFilename}r()})})}return this._ioChain=this._ioChain.then(()=>this._doneResolve()),this.finalizedFile??this.partFilename}async abort(){return this.finalized?this.finalizedFile:(this.finalized=!0,this.disabled||(this._flushToPartAsync(),this.finalizedFile=this.partFilename),this._ioChain=this._ioChain.then(()=>this._doneResolve()),this.finalizedFile)}_flushToPartAsync(){if(this.buf.length===0)return;let e=this.buf,t=this.partPath;this._ioChain=this._ioChain.then(async()=>{if(!this.disabled)try{await n(c(t),{recursive:!0}),await s(t,e,`utf-8`)}catch(e){this.disabled=!0,this.onError?.(`llm-call-log: write failed, disabling for this call`,e)}})}};function k(e,t){return{file:t.file??``,time:t.time,sessionId:e.sessionId,trigger:e.trigger,callId:t.callId,attempt:t.attempt,status:t.status,durationMs:Math.round(t.durationMs),headerTtfbMs:Math.round(t.headerTtfbMs),ttfbMs:Math.round(t.ttfbMs),reqBytes:t.reqBytes,resBytes:t.resBytes,provider:e.provider_name,model:e.modelId,upstreamModel:e.upstream_model}}function A(e,r=globalThis.fetch){if(!e.enabled)return{fetch:r,drain:()=>Promise.resolve()};n(e.logDir,{recursive:!0}).catch(()=>{});let i=new Set,a=new Map,o=Promise.resolve();function s(n){let r=`${JSON.stringify(n)}\n`;o=o.then(async()=>{try{await t(l(e.logDir,`index.jsonl`),r,`utf-8`)}catch(t){e.onError?.(`llm-call-log: index append failed`,t)}})}let c=!1;return{fetch:async function(t,n){let o=process.env.TBOXCODE_LLM_LOG===`0`||process.env.TBOXCODE_LLM_LOG===`false`;if(o||c){if(o){for(let e of i)e.abort();i.clear()}return r(t,n)}let l=w(),u=globalThis.performance?.now()??Date.now(),d=e.callId,f=d?(a.get(d)??0)+1:1;d&&a.set(d,f);let p=new O(e.logDir,e.trigger,d,f,e.max_file_bytes,l,e.onError);i.add(p),p.done.then(()=>i.delete(p),()=>i.delete(p));let m=n?.method??`POST`,h,g={};typeof t==`string`||t instanceof URL?h=t instanceof URL?t.toString():t:(h=t.url,m=n?.method??t.method,g=M(t.headers)),n?.headers&&(g={...g,...M(n.headers)});let{text:_,isReal:v}=N(n?.body),y=v?Buffer.byteLength(_,`utf-8`):0,b=e.sanitize_headers?x(g):Object.fromEntries(Object.entries(g).map(([e,t])=>[e,Array.isArray(t)?t.join(`, `):String(t??``)]));p.writeMeta({time:new Date().toISOString(),session:e.sessionId,trigger:e.trigger,...e.traitsVersion===void 0?{}:{_traitsV:e.traitsVersion},...d?{call:d,attempt:String(f)}:{},provider:`${e.protocol} (${e.provider_name})`,model:e.modelId,upstreamModel:e.upstream_model}),p.writeRequest(T(m,h,b,_));let C;try{C=await r(t,n)}catch(e){throw p.writeMeta({error:`fetch failed: ${String(e)}`}),p.abort(),e}let A=(globalThis.performance?.now()??Date.now())-u,j=M(C.headers),P=e.sanitize_headers?x(j):Object.fromEntries(Object.entries(j).map(([e,t])=>[e,Array.isArray(t)?t.join(`, `):String(t??``)])),F=C.status;if(!C.body){p.writeResponse(A,A,E(F,C.statusText,P,``));let t=(globalThis.performance?.now()??Date.now())-u;return p.writeTrailer(t,A,A,y,0),s(k(e,{file:await p.finalize(F),time:l,callId:d,attempt:f,status:F,durationMs:t,headerTtfbMs:A,ttfbMs:A,reqBytes:y,resBytes:0})),C}let[I,L]=C.body.tee(),R=new Response(I,{status:C.status,statusText:C.statusText,headers:C.headers});return(async()=>{let t=0,n=0,r=[],i=0,a=!1,o=!1,c=null;try{c=L.getReader();let o=new TextDecoder;for(;;){let{done:s,value:l}=await c.read();if(s)break;if(l&&(n===0&&(n=(globalThis.performance?.now()??Date.now())-u),t+=l.byteLength,!a)){let t=o.decode(l,{stream:!0}),n=Buffer.byteLength(t,`utf-8`);i+n<=e.max_file_bytes?(r.push(t),i+=n):a=!0}}a||r.push(o.decode())}catch(e){r.push(`\n[stream interrupted: ${String(e)}]\n`),o=!0}finally{c?.releaseLock()}let{text:m,truncated:h}=S(r.join(``),e.max_file_bytes);p.writeResponse(A,n,E(F,C.statusText,P,m)),(h||a)&&p.writeMeta({note:`response body truncated at ${D(e.max_file_bytes)}`}),o&&p.writeMeta({status:`stream-interrupted`});let g=(globalThis.performance?.now()??Date.now())-u;p.writeTrailer(g,A,n,y,t),s(k(e,{file:await p.finalize(F),time:l,callId:d,attempt:f,status:F,durationMs:g,headerTtfbMs:A,ttfbMs:n,reqBytes:y,resBytes:t}))})().catch(()=>{p.abort().catch(()=>{})}),R},drain:async()=>{for(c=!0;i.size>0;){let e=[...i];await Promise.allSettled(e.map(e=>e.done))}await o}}}async function j(e){let t=await r(e);return e.endsWith(`.http.zst`)?d(t).toString(`utf-8`):t.toString(`utf-8`)}function M(e){if(!e)return{};if(e instanceof Headers){let t={};return e.forEach((e,n)=>{t[n]=e}),t}if(Array.isArray(e)){let t={};for(let n of e){let e=n[0],r=n[1]??``;e!==void 0&&(t[e]=r)}return t}if(typeof e==`object`){let t={};for(let[n,r]of Object.entries(e))t[n]=Array.isArray(r)?r.join(`, `):String(r??``);return t}return{}}function N(e){if(e==null)return{text:``,isReal:!0};if(typeof e==`string`)return{text:e,isReal:!0};if(e instanceof Uint8Array)return{text:new TextDecoder().decode(e),isReal:!0};if(typeof Buffer<`u`&&Buffer.isBuffer(e))return{text:e.toString(`utf-8`),isReal:!0};try{return{text:`[unserializable body: ${typeof e}]`,isReal:!1}}catch{return{text:`[unserializable body: ${typeof e}]`,isReal:!1}}}async function P(e,t,n=1e3){if(t<=0)return 0;let r=Date.now()-t*864e5,s=0,c=0,u=async e=>{let t;try{t=await i(e,{withFileTypes:!0})}catch{return}for(let i of t){if(c>=n)return;let t=i.name;if(i.isDirectory()||!t.endsWith(`.http.zst`)&&!t.endsWith(`.http.part`)&&!t.endsWith(`.http`)&&t!==`index.jsonl`)continue;c++;let u=l(e,t);try{(await o(u)).mtimeMs<r&&(await a(u,{force:!0}),s++)}catch{}}};try{await u(_(e));let t;try{t=await i(e,{withFileTypes:!0})}catch{t=[]}for(let r of t){if(!r.isDirectory()||c>=n||r.name===`_tboxcode`)continue;let t;try{t=await i(l(e,r.name),{withFileTypes:!0})}catch{continue}for(let i of t)!i.isDirectory()||c>=n||await u(l(e,r.name,i.name,`tboxcode`,`llm-calls`));if(c>=n)break}return s}catch{return s}}export{j as a,b as c,C as i,g as l,A as n,x as o,w as r,S as s,P as t,_ as u};
@@ -0,0 +1,120 @@
1
+ //#region src/call-log.d.ts
2
+ /**
3
+ * call-log —— LLM 调用线级日志(异步 I/O)。
4
+ *
5
+ * 移植自 openacpagent v0.9.20 `agent/llm/call-log.ts`(784 行)。包装注入
6
+ * @ai-sdk provider 工厂的 fetch:每次 LLM HTTP 调用(含重试 attempt 与 HTTP
7
+ * 错误)落盘为人类可读文件,另追加一行 JSON 摘要至 index.jsonl。
8
+ *
9
+ * 本仓收敛改造(S1a 决断,deltas 对照源):
10
+ * 1. 文件名无 `-s{step}` 段——ai-sdk adapter 无 step 可达面(S1a seam 探针)
11
+ * 与 turnId 同为 IndexEntry 恒省略字段。
12
+ * 2. 落盘为 zstd 压缩帧(node:zlib zstdCompressSync,v22.15+):进行中
13
+ * `.http.part`(明文,崩溃可裸读)→ finalize 原子改写 `.http.zst`;
14
+ * abort 保持 `.part`。读取端 readCallLogFile 按后缀分流(含存量裸
15
+ * `.http`——openacpagent 遗留布局的兼容读)。
16
+ * 3. meta 头 `_traitsV`:traits 哈希(traitsHash sha256-16hex)随请求元数据
17
+ * 落盘——golden 字节比对与 traits 版本演进的对账锚。
18
+ * 4. 两态路由由调用方解析(adapter 接线):有会话 →
19
+ * `<sessionDir>/tboxcode/llm-calls`;无(agentless / 未持久化)→
20
+ * `<root>/_tboxcode/orphan-llm-calls`(该目录禁进 session 目录扫描)。
21
+ * 5. retention 扫描本仓布局 `<root>/<projectKey>/<encodedSessionId>/
22
+ * tboxcode/llm-calls` 与 orphan 目录(源为 workspaces/sessions 两层)。
23
+ * 6. 零 logger 依赖(C1 降级先例):warn 走可选 onError 回调。
24
+ *
25
+ * 设计保留(源语义):
26
+ * - 每调用一文件:{ts}_{trigger}_{callId8}_{attempt}_{status}.http.zst
27
+ * - .part → finalize 原子改写;abort/写失败保持 .part 且 index 记实况名
28
+ * - 请求快照入队异步 I/O 链,真 fetch 立即发出——零事件循环阻塞
29
+ * - SSE 响应体 tee:SDK 一支,后台任务一支(内存受 max_file_bytes 约束)
30
+ * - 敏感头脱敏(first4+last4,core/headers 单源)
31
+ * - 全部 fs 错误就地吸纳:写失败只停用该调用日志,永不影响 LLM 调用
32
+ * - drain() 循环至 pending 清空——修在途会话提前返回缺陷
33
+ * - TBOXCODE_LLM_LOG=0|false 运行时热杀(每 fetch 检查,紧急停用旁路)
34
+ */
35
+ interface LlmCallLogConfig {
36
+ enabled: boolean;
37
+ max_file_bytes: number;
38
+ sanitize_headers: boolean;
39
+ }
40
+ interface LlmCallLogContext extends LlmCallLogConfig {
41
+ /** call-log 目录(调用方两态路由解析:会话目录或 orphan 目录)。 */
42
+ logDir: string;
43
+ sessionId: string;
44
+ trigger: 'main' | 'compact' | 'title';
45
+ /** 当前 LLM 调用 id(per streamText 调用;SDK 内部重试共享)。attempt 计数键。 */
46
+ callId?: string;
47
+ /** traits 哈希(meta 头 `_traitsV`——golden 对账锚)。 */
48
+ traitsVersion?: string;
49
+ provider_name: string;
50
+ /** config 键 modelId(catalog / index 关联)。 */
51
+ modelId: string;
52
+ /** 实际发往上游 endpoint 的 API model id。 */
53
+ upstream_model: string;
54
+ protocol: string;
55
+ /** 写失败等诊断回调(缺省静默——fs 错误永不影响 LLM 调用)。 */
56
+ onError?: (message: string, error: unknown) => void;
57
+ }
58
+ type FetchInput = Parameters<typeof fetch>[0];
59
+ type FetchInit = Parameters<typeof fetch>[1];
60
+ type HttpHeaders = Record<string, string | string[] | undefined>;
61
+ declare function sanitize_headers(headers: HttpHeaders): Record<string, string>;
62
+ /** UTF-8 安全的字节预算截断。 */
63
+ declare function truncateBody(bodyText: string, maxBytes: number): {
64
+ text: string;
65
+ truncated: boolean;
66
+ };
67
+ declare function randomHex8(): string;
68
+ declare function fileTimestamp(date?: Date): string;
69
+ /** 15 字段(收敛形态):turnId/step/interrupted 恒省略(无 adapter 可达面;
70
+ * 中断信息落文件 meta 头 status: stream-interrupted)。 */
71
+ interface IndexEntry {
72
+ file: string;
73
+ time: string;
74
+ sessionId: string;
75
+ trigger: string;
76
+ callId?: string;
77
+ attempt: number;
78
+ status: number;
79
+ durationMs: number;
80
+ /** fetch 发起到响应头的耗时(ms)。 */
81
+ headerTtfbMs: number;
82
+ /** fetch 发起到首响应体字节的耗时(ms);无体响应等于 headerTtfbMs。 */
83
+ ttfbMs: number;
84
+ reqBytes: number;
85
+ resBytes: number;
86
+ provider: string;
87
+ model: string;
88
+ upstreamModel: string;
89
+ }
90
+ interface LoggingFetchHandle {
91
+ /** 包装后的 fetch——传给 @ai-sdk provider 工厂。 */
92
+ fetch: typeof fetch;
93
+ /** await 本句柄全部在途日志写。 */
94
+ drain: () => Promise<void>;
95
+ }
96
+ /**
97
+ * 以 LLM 调用日志包装 fetch 实现。
98
+ *
99
+ * @param ctx 日志上下文(目录、会话、trigger、上限等)
100
+ * @param baseFetch 真实 fetch 委托目标。缺省 globalThis.fetch;注入自定义
101
+ * fetch 用于测试或连接策略(本仓叠装
102
+ * createSseRateLimitFetch 在内层)。
103
+ */
104
+ declare function createLoggingFetch(ctx: LlmCallLogContext, baseFetch?: typeof fetch): LoggingFetchHandle;
105
+ /**
106
+ * 读取一个 call-log 文件为明文。按后缀分流:`.http.zst` → zstd 解压;
107
+ * `.http.part` / 裸 `.http`(openacpagent 遗留布局与 abort 半成品)→ 明文直读。
108
+ */
109
+ declare function readCallLogFile(path: string): Promise<string>;
110
+ /**
111
+ * 按保留天数清理过期 call-log(本仓布局):
112
+ * - 会话目录:`<root>/<projectKey>/<encodedSessionId>/tboxcode/llm-calls`
113
+ * - orphan 目录:`<root>/_tboxcode/orphan-llm-calls`
114
+ * 清理对象:`.http.zst` / `.http.part` / `.http` 与 index.jsonl。
115
+ * 返回删除文件数(测试与调度诊断面)。调度接线归 serve-gateway(本函数为
116
+ * 纯清扫原语)。
117
+ */
118
+ declare function cleanupOldLlmLogs(sessionRoot: string, retentionDays: number, maxFiles?: number): Promise<number>;
119
+ //#endregion
120
+ export { FetchInit, FetchInput, HttpHeaders, IndexEntry, LlmCallLogConfig, LlmCallLogContext, LoggingFetchHandle, cleanupOldLlmLogs, createLoggingFetch, fileTimestamp, randomHex8, readCallLogFile, sanitize_headers, truncateBody };
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./call-log-UkoWWuyZ.js";export{o as cleanupOldLlmLogs,n as createLoggingFetch,i as fileTimestamp,t as randomHex8,e as readCallLogFile,r as sanitize_headers,a as truncateBody};
package/lib/echo.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { GenerateOptions, LlmAdapter, LlmModelInfo, LlmResolvedModelInfo, StreamChunk } from "@deepseek-ai/dsh-llm";
2
+ import { Context } from "@deepseek-ai/cordis";
3
+
4
+ //#region src/echo.d.ts
5
+
6
+ declare const name = "tboxcode-llm-echo";
7
+ declare const inject: string[];
8
+ interface EchoConfig {
9
+ /** 每个 text-delta 之间的延迟(ms)——mid-stream 断线重连窗口靠它拉开。 */
10
+ delayMs?: number;
11
+ /** 每个 text-delta 携带的词数。 */
12
+ chunkWords?: number;
13
+ }
14
+ declare class EchoAdapter extends LlmAdapter {
15
+ #private;
16
+ constructor(config?: EchoConfig);
17
+ listModels(provider: string): Promise<readonly LlmModelInfo[]>;
18
+ resolveModel(provider: string, model: string): Promise<LlmResolvedModelInfo>;
19
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
20
+ }
21
+ /** cordis 插件入口:注册 echo provider 路由;apply 返回 disposer 释放注册。 */
22
+ declare function apply(ctx: Context, config?: EchoConfig): () => void;
23
+ //#endregion
24
+ export { EchoAdapter, EchoConfig, apply, inject, name };
package/lib/echo.js ADDED
@@ -0,0 +1,2 @@
1
+ import{LlmAdapter as e}from"@deepseek-ai/dsh-llm";const t=`tboxcode-llm-echo`,n=[`llm`];function r(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.role!==`user`||!Array.isArray(n.content))continue;let r=n.content.filter(e=>e?.type===`text`&&!e.text.includes(`<system-reminder>`)).map(e=>e.text).join(`
2
+ `).trim();if(r.length>0)return r}}function i(e,t){let n=e.split(/\s+/).filter(e=>e.length>0);if(n.length===0)return[e];let r=[];for(let e=0;e<n.length;e+=t)r.push(n.slice(e,e+t).join(` `));return r}async function a(e,t){e<=0||await new Promise((n,r)=>{let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(t.reason)},{once:!0})})}var o=class extends e{#e;#t;constructor(e={}){super(),this.#e=e.delayMs??30,this.#t=e.chunkWords??1}listModels(e){return Promise.resolve([{provider:e,id:`echo`,name:`Echo`,description:`echo driver——确定性回显(测试与流式收口)`,inputModalities:[`text`]}])}async resolveModel(e,t){return{provider:e,id:t,name:t,context:{contextWindow:128e3}}}async*stream(e){let t=r(e.messages)??`echo`,n=i(t,this.#t);yield{type:`block-start`,index:0,blockType:`text`};for(let t of n)await a(this.#e,e.signal),yield{type:`text-delta`,index:0,text:t};yield{type:`block-end`,index:0,block:{type:`text`,text:t}},yield{type:`usage`,usage:{inputTokens:1,outputTokens:n.length}},yield{type:`finish`,reason:{kind:`stop`}}}};function s(e,t={}){let n=new o(t),r=e.llm.registerAdapter([`echo`],n);return()=>{r()}}export{o as EchoAdapter,s as apply,n as inject,t as name};
package/lib/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { Context } from "@deepseek-ai/cordis";
2
+
3
+ //#region src/index.d.ts
4
+ declare const name = "tboxcode-llm";
5
+ declare const inject: string[];
6
+ /** cordis 插件入口:注册全部启用 provider 路由;watcher 热载经 replace 换装。 */
7
+ declare function apply(ctx: Context): () => void;
8
+ //#endregion
9
+ export { apply, inject, name };
package/lib/index.js ADDED
@@ -0,0 +1,119 @@
1
+ import{c as e,l as t,n,u as r}from"./call-log-UkoWWuyZ.js";import{createRequire as i}from"node:module";import{createHash as a,randomBytes as o}from"node:crypto";import{rm as s,writeFile as c}from"node:fs/promises";import{join as l}from"node:path";import{LlmAdapter as u,LlmError as d}from"@deepseek-ai/dsh-llm";import{existsSync as f,readFileSync as p,statSync as m,watch as h}from"node:fs";import{homedir as g}from"node:os";import{jsonSchema as _,streamText as v,tool as y}from"ai";import{createAnthropic as b}from"@ai-sdk/anthropic";import{createOpenAICompatible as x}from"@ai-sdk/openai-compatible";import{createOpenAI as S}from"@ai-sdk/openai";import{z as C}from"zod";Object.create,Object.defineProperty,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty;var w=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),T=i(import.meta.url),E=w((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),D=w((e=>{var t=E();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),ee=w((e=>{var t=E(),n=D();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||(!e||a.some(e=>e.startsWith(n)))&&r.push(`%TAG ${t} ${n}`);return r.join(`
2
+ `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),O=w((e=>{var t=E(),n=D();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),te=w((e=>{function t(e,n,r,i){if(i&&typeof i==`object`)if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}return e.call(n,r,i)}e.applyReviver=t})),k=w((e=>{var t=E();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),ne=w((e=>{var t=te(),n=E(),r=k();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),A=w((e=>{var t=O(),n=D(),r=E(),i=ne(),a=k(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,`tag`,{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let o;for(let e of i){if(e===this)break;e.anchor===this.source&&(o=e)}if(o&&t){let{anchors:e,doc:n,maxAliasCount:r}=t,i=e.get(o);if(i||=(a.toJS(o,null,t),e.get(o)),i?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(r>=0&&(i.count+=1,i.aliasCount===0&&(i.aliasCount=s(n,o,e)),i.count*i.aliasCount>r))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return o}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}else if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}else if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),j=w((e=>{var t=E(),n=ne(),r=k();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),M=w((e=>{var t=A(),n=E(),r=j();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??=c(e),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),re=w((e=>{var t=M(),n=E(),r=ne();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,`schema`,{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),N=w((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
3
+ `)?n(r,t):r.includes(`
4
+ `)?`
5
+ `+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),ie=w((e=>{let t=`block`,n=`quoted`;function r(e,r,a=`flow`,{indentAtStart:o,lineWidth:s=80,minContentWidth:c=20,onFold:l,onOverflow:u}={}){if(!s||s<0)return e;s<c&&(c=0);let d=Math.max(1+c,1+s-r.length);if(e.length<=d)return e;let f=[],p={},m=s-r.length;typeof o==`number`&&(o>s-Math.max(2,c)?f.push(0):m=s-o);let h,g,_=!1,v=-1,y=-1,b=-1;a===t&&(v=i(e,v,r.length),v!==-1&&(m=v+d));for(let o;o=e[v+=1];){if(a===n&&o===`\\`){switch(y=v,e[v+1]){case`x`:v+=3;break;case`u`:v+=5;break;case`U`:v+=9;break;default:v+=1}b=v}if(o===`
6
+ `)a===t&&(v=i(e,v,r.length)),m=v+r.length+d,h=void 0;else{if(o===` `&&g&&g!==` `&&g!==`
7
+ `&&g!==` `){let t=e[v+1];t&&t!==` `&&t!==`
8
+ `&&t!==` `&&(h=v)}if(v>=m)if(h)f.push(h),m=h+d,h=void 0;else if(a===n){for(;g===` `||g===` `;)g=o,o=e[v+=1],_=!0;let t=v>b+1?v-2:y-1;if(p[t])return e;f.push(t),p[t]=!0,m=t+d,h=void 0}else _=!0}g=o}if(_&&u&&u(),f.length===0)return e;l&&l();let x=e.slice(0,f[0]);for(let t=0;t<f.length;++t){let i=f[t],o=f[t+1]||e.length;i===0?x=`\n${r}${e.slice(0,o)}`:(a===n&&p[i]&&(x+=`${e[i]}\\`),x+=`\n${r}${e.slice(i+1,o)}`)}return x}function i(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
9
+ `);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=r})),P=w((e=>{var t=j(),n=ie();let r=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),i=e=>/^(%|---|\.\.\.)/m.test(e);function a(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
10
+ `){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function o(e,t){let a=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return a;let{implicitKey:o}=t,s=t.options.doubleQuotedMinMultiLineLength,c=t.indent||(i(e)?` `:``),l=``,u=0;for(let e=0,t=a[e];t;t=a[++e])if(t===` `&&a[e+1]===`\\`&&a[e+2]===`n`&&(l+=a.slice(u,e)+`\\ `,e+=1,u=e,t=`\\`),t===`\\`)switch(a[e+1]){case`u`:{l+=a.slice(u,e);let t=a.substr(e+2,4);switch(t){case`0000`:l+=`\\0`;break;case`0007`:l+=`\\a`;break;case`000b`:l+=`\\v`;break;case`001b`:l+=`\\e`;break;case`0085`:l+=`\\N`;break;case`00a0`:l+=`\\_`;break;case`2028`:l+=`\\L`;break;case`2029`:l+=`\\P`;break;default:t.substr(0,2)===`00`?l+=`\\x`+t.substr(2):l+=a.substr(e,6)}e+=5,u=e+1}break;case`n`:if(o||a[e+2]===`"`||a.length<s)e+=1;else{for(l+=a.slice(u,e)+`
11
+
12
+ `;a[e+2]===`\\`&&a[e+3]===`n`&&a[e+4]!==`"`;)l+=`
13
+ `,e+=2;l+=c,a[e+2]===` `&&(l+=`\\`),e+=1,u=e+1}break;default:e+=1}return l=u?l+a.slice(u):a,o?l:n.foldFlowLines(l,c,n.FOLD_QUOTED,r(t,!1))}function s(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
14
+ `)||/[ \t]\n|\n[ \t]/.test(e))return o(e,t);let a=t.indent||(i(e)?` `:``),s=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${a}`)+`'`;return t.implicitKey?s:n.foldFlowLines(s,a,n.FOLD_FLOW,r(t,!1))}function c(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=o;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?s:i&&!t?o:n?s:o}return r(e,t)}let l;try{l=RegExp(`(^|(?<!
15
+ ))
16
+ +(?!
17
+ |$)`,`g`)}catch{l=/\n+(?!\n|$)/g}function u({comment:e,type:o,value:s},u,d,f){let{blockQuote:p,commentString:m,lineWidth:h}=u.options;if(!p||/\n[\t ]+$/.test(s))return c(s,u);let g=u.indent||(u.forceBlockIndent||i(s)?` `:``),_=p===`literal`?!0:p===`folded`||o===t.Scalar.BLOCK_FOLDED?!1:o===t.Scalar.BLOCK_LITERAL?!0:!a(s,h,g.length);if(!s)return _?`|
18
+ `:`>
19
+ `;let v,y;for(y=s.length;y>0;--y){let e=s[y-1];if(e!==`
20
+ `&&e!==` `&&e!==` `)break}let b=s.substring(y),x=b.indexOf(`
21
+ `);x===-1?v=`-`:s===b||x!==b.length-1?(v=`+`,f&&f()):v=``,b&&=(s=s.slice(0,-b.length),b[b.length-1]===`
22
+ `&&(b=b.slice(0,-1)),b.replace(l,`$&${g}`));let S=!1,C,w=-1;for(C=0;C<s.length;++C){let e=s[C];if(e===` `)S=!0;else if(e===`
23
+ `)w=C;else break}let T=s.substring(0,w<C?w+1:C);T&&=(s=s.substring(T.length),T.replace(/\n+/g,`$&${g}`));let E=(S?g?`2`:`1`:``)+v;if(e&&(E+=` `+m(e.replace(/ ?[\r\n]+/g,` `)),d&&d()),!_){let e=s.replace(/\n+/g,`
24
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${g}`),i=!1,a=r(u,!0);p!==`folded`&&o!==t.Scalar.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let c=n.foldFlowLines(`${T}${e}${b}`,g,n.FOLD_BLOCK,a);if(!i)return`>${E}\n${g}${c}`}return s=s.replace(/\n+/g,`$&${g}`),`|${E}\n${g}${T}${s}${b}`}function d(e,a,o,s){let{type:l,value:d}=e,{actualString:f,implicitKey:p,indent:m,indentStep:h,inFlow:g}=a;if(p&&d.includes(`
25
+ `)||g&&/[[\]{},]/.test(d))return c(d,a);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(d))return p||g||!d.includes(`
26
+ `)?c(d,a):u(e,a,o,s);if(!p&&!g&&l!==t.Scalar.PLAIN&&d.includes(`
27
+ `))return u(e,a,o,s);if(i(d)){if(m===``)return a.forceBlockIndent=!0,u(e,a,o,s);if(p&&m===h)return c(d,a)}let _=d.replace(/\n+/g,`$&\n${m}`);if(f){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(_),{compat:t,tags:n}=a.doc.schema;if(n.some(e)||t?.some(e))return c(d,a)}return p?_:n.foldFlowLines(_,m,n.FOLD_FLOW,r(a,!1))}function f(e,n,r,i){let{implicitKey:a,inFlow:l}=n,f=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(f.value)&&(p=t.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||l?c(f.value,n):u(f,n,r,i);case t.Scalar.QUOTE_DOUBLE:return o(f.value,n);case t.Scalar.QUOTE_SINGLE:return s(f.value,n);case t.Scalar.PLAIN:return d(f,n,r,i);default:return null}},h=m(p);if(h===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(h=m(r),h===null)throw Error(`Unsupported default string type ${r}`)}return h}e.stringifyString=f})),F=w((e=>{var t=O(),n=E(),r=N(),i=P();function a(e,t){let n=Object.assign({blockQuote:!0,commentString:r.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,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function o(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function s(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function c(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let c,l=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>c=e});c??=o(t.doc.schema.tags,l);let u=s(l,c,t);u.length>0&&(t.indentAtStart=(t.indentAtStart??0)+u.length+1);let d=typeof c.stringify==`function`?c.stringify(l,t,r,a):n.isScalar(l)?i.stringifyString(l,t,r,a):l.toString(t,r,a);return u?n.isScalar(l)||d[0]===`{`||d[0]===`[`?`${u} ${d}`:`${u}\n${t.indent}${d}`:d}e.createStringifyContext=a,e.stringify=c})),ae=w((e=>{var t=E(),n=j(),r=F(),i=N();function a({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:f,options:{commentString:p,indentSeq:m,simpleKeys:h}}=o,g=t.isNode(e)&&e.comment||null;if(h){if(g)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let _=!h&&(!e||g&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!_&&(h||!l),indent:d+f});let v=!1,y=!1,b=r.stringify(e,o,()=>v=!0,()=>y=!0);if(!_&&!o.inFlow&&b.length>1024){if(h)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);_=!0}if(o.inFlow){if(l||a==null)return v&&s&&s(),b===``?`?`:_?`? ${b}`:b}else if(l&&!h||a==null&&_)return b=`? ${b}`,g&&!v?b+=i.lineComment(b,o.indent,p(g)):y&&c&&c(),b;v&&(g=null),_?(g&&(b+=i.lineComment(b,o.indent,p(g))),b=`? ${b}\n${d}:`):(b=`${b}:`,g&&(b+=i.lineComment(b,o.indent,p(g))));let x,S,C;t.isNode(a)?(x=!!a.spaceBefore,S=a.commentBefore,C=a.comment):(x=!1,S=null,C=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!_&&!g&&t.isScalar(a)&&(o.indentAtStart=b.length+1),y=!1,!m&&f.length>=2&&!o.inFlow&&!_&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let w=!1,T=r.stringify(a,o,()=>w=!0,()=>y=!0),E=` `;if(g||x||S){if(E=x?`
28
+ `:``,S){let e=p(S);E+=`\n${i.indentComment(e,o.indent)}`}T===``&&!o.inFlow?E===`
29
+ `&&C&&(E=`
30
+
31
+ `):E+=`\n${o.indent}`}else if(!_&&t.isCollection(a)){let e=T[0],t=T.indexOf(`
32
+ `),n=t!==-1,r=o.inFlow??a.flow??a.items.length===0;if(n||!r){let r=!1;if(n&&(e===`&`||e===`!`)){let n=T.indexOf(` `);e===`&`&&n!==-1&&n<t&&T[n+1]===`!`&&(n=T.indexOf(` `,n+1)),(n===-1||t<n)&&(r=!0)}r||(E=`\n${o.indent}`)}}else (T===``||T[0]===`
33
+ `)&&(E=``);return b+=E+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),oe=w((e=>{var t=T(`process`);function n(e,...t){e===`debug`&&console.log(...t)}function r(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=n,e.warn=r})),I=w((e=>{var t=E(),n=j();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:a}),stringify:()=>`<<`},i=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function a(e,n,r){let i=s(e,r);if(t.isSeq(i))for(let t of i.items)o(e,n,t);else if(Array.isArray(i))for(let t of i)o(e,n,t);else o(e,n,i)}function o(e,n,r){let i=s(e,r);if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}function s(e,n){return e&&t.isAlias(n)?n.resolve(e.doc,e):n}e.addMergeToJSMap=a,e.isMergeKey=i,e.merge=r})),se=w((e=>{var t=oe(),n=I(),r=F(),i=E(),a=k();function o(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=s(r,n,e),c=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:c,writable:!0,enumerable:!0,configurable:!0}):t[i]=c}}return t}function s(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=o})),L=w((e=>{var t=M(),n=ae(),r=se(),i=E();function a(e,n,r){return new o(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var o=class e{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return i.isNode(n)&&(n=n.clone(t)),i.isNode(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){let n=t?.mapAsMap?new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=o,e.createPair=a})),ce=w((e=>{var t=E(),n=F(),r=N();function i(e,t,n){return(t.inFlow??e.flow?o:a)(e,t,n)}function a({comment:e,items:i},a,{blockItemPrefix:o,flowChars:c,itemIndent:l,onChompKeep:u,onComment:d}){let{indent:f,options:{commentString:p}}=a,m=Object.assign({},a,{indent:l,type:null}),h=!1,g=[];for(let e=0;e<i.length;++e){let c=i[e],u=null;if(t.isNode(c))!h&&c.spaceBefore&&g.push(``),s(a,g,c.commentBefore,h),c.comment&&(u=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(!h&&e.spaceBefore&&g.push(``),s(a,g,e.commentBefore,h))}h=!1;let d=n.stringify(c,m,()=>u=null,()=>h=!0);u&&(d+=r.lineComment(d,l,p(u))),h&&u&&(h=!1),g.push(o+d)}let _;if(g.length===0)_=c.start+c.end;else{_=g[0];for(let e=1;e<g.length;++e){let t=g[e];_+=t?`\n${f}${t}`:`
34
+ `}}return e?(_+=`
35
+ `+r.indentComment(p(e),f),d&&d()):h&&u&&u(),_}function o({items:e},i,{flowChars:a,itemIndent:o}){let{indent:c,indentStep:l,flowCollectionPadding:u,options:{commentString:d}}=i;o+=l;let f=Object.assign({},i,{indent:o,inFlow:!0,type:null}),p=!1,m=0,h=[];for(let a=0;a<e.length;++a){let c=e[a],l=null;if(t.isNode(c))c.spaceBefore&&h.push(``),s(i,h,c.commentBefore,!1),c.comment&&(l=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(e.spaceBefore&&h.push(``),s(i,h,e.commentBefore,!1),e.comment&&(p=!0));let n=t.isNode(c.value)?c.value:null;n?(n.comment&&(l=n.comment),n.commentBefore&&(p=!0)):c.value==null&&e?.comment&&(l=e.comment)}l&&(p=!0);let u=n.stringify(c,f,()=>l=null);p||=h.length>m||u.includes(`
36
+ `),a<e.length-1?u+=`,`:i.options.trailingComma&&(i.options.lineWidth>0&&(p||=h.reduce((e,t)=>e+t.length+2,2)+(u.length+2)>i.options.lineWidth),p&&(u+=`,`)),l&&(u+=r.lineComment(u,o,d(l))),h.push(u),m=h.length}let{start:g,end:_}=a;if(h.length===0)return g+_;if(!p){let e=h.reduce((e,t)=>e+t.length+2,2);p=i.options.lineWidth>0&&e>i.options.lineWidth}if(p){let e=g;for(let t of h)e+=t?`\n${l}${c}${t}`:`
37
+ `;return`${e}\n${c}${_}`}else return`${g}${u}${h.join(` `)}${u}${_}`}function s({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=i})),R=w((e=>{var t=ce(),n=se(),r=re(),i=E(),a=L(),o=j();function s(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}e.YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),s=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)s(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))s(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=s(this.items,n.key),c=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(c){let e=this.items.findIndex(e=>c(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=s(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=s(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!s(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}},e.findPair=s})),z=w((e=>{var t=E(),n=R();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),B=w((e=>{var t=M(),n=ce(),r=re(),i=E(),a=j(),o=k(),s=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=c(e);return typeof t==`number`?this.items.splice(t,1).length>0:!1}get(e,t){let n=c(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=c(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=c(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function c(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=s})),V=w((e=>{var t=E(),n=B();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),H=w((e=>{var t=P();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),le=w((e=>{var t=j();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),ue=w((e=>{var t=j();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),U=w((e=>{function t({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-- >0;)a+=`0`}return a}e.stringifyNumber=t})),de=w((e=>{var t=j(),n=U();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),fe=w((e=>{var t=U();let n=e=>typeof e==`bigint`||Number.isInteger(e),r=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function i(e,r,i){let{value:a}=e;return n(a)&&a>=0?i+a.toString(r):t.stringifyNumber(e)}e.int={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)},e.intOct={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>r(e,2,8,n),stringify:e=>i(e,8,`0o`)}})),pe=w((e=>{var t=z(),n=le(),r=V(),i=H(),a=ue(),o=de(),s=fe();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),me=w((e=>{var t=j(),n=z(),r=V();function i(e){return typeof e==`bigint`||Number.isInteger(e)}let a=({value:e})=>JSON.stringify(e),o=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:a},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:a},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:a},{identify:i,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>i(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:a}];e.schema=[n.map,r.seq].concat(o,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),he=w((e=>{var t=T(`buffer`),n=j(),r=P();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}else return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
38
+ `:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),W=w((e=>{var t=E(),n=L(),r=j(),i=B();function a(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function o(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e))if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`);else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let s={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:a,createNode:o};e.createPairs=o,e.pairs=s,e.resolvePairs=a})),ge=w((e=>{var t=E(),n=k(),r=R(),i=B(),a=W(),o=class e extends i.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=e.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),_e=w((e=>{var t=j();function n({value:e,source:t},n){return t&&(e?r:i).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}let r={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:n},i={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:n};e.falseTag=i,e.trueTag=r})),ve=w((e=>{var t=j(),n=U();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),ye=w((e=>{var t=U();let n=e=>typeof e==`bigint`||Number.isInteger(e);function r(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function i(e,r,i){let{value:a}=e;if(n(a)){let e=a.toString(r);return a<0?`-`+i+e.substr(1):i+e}return t.stringifyNumber(e)}let a={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>r(e,2,2,n),stringify:e=>i(e,2,`0b`)},o={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>r(e,1,8,n),stringify:e=>i(e,8,`0`)},s={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},c={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)};e.int=s,e.intBin=a,e.intHex=c,e.intOct=o})),be=w((e=>{var t=E(),n=L(),r=R(),i=class e extends r.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),xe=w((e=>{var t=U();function n(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function r(e){let{value:n}=e,r=e=>e;if(typeof n==`bigint`)r=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let i=``;n<0&&(i=`-`,n*=r(-1));let a=r(60),o=[n%a];return n<60?o.unshift(0):(n=(n-o[0])/a,o.unshift(n%a),n>=60&&(n=(n-o[0])/a,o.unshift(n))),i+o.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let i={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>n(e,r),stringify:r},a={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>n(e,!1),stringify:r},o={identify:e=>e 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(e){let t=e.match(o.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,r,i,a,s,c,l]=t.map(Number),u=t[7]?Number((t[7]+`00`).substr(1,3)):0,d=Date.UTC(r,i-1,a,s||0,c||0,l||0,u),f=t[8];if(f&&f!==`Z`){let e=n(f,!1);Math.abs(e)<30&&(e*=60),d-=6e4*e}return new Date(d)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=a,e.intTime=i,e.timestamp=o})),Se=w((e=>{var t=z(),n=le(),r=V(),i=H(),a=he(),o=_e(),s=ve(),c=ye(),l=I(),u=ge(),d=W(),f=be(),p=xe();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),Ce=w((e=>{var t=z(),n=le(),r=V(),i=H(),a=ue(),o=de(),s=fe(),c=pe(),l=me(),u=he(),d=I(),f=ge(),p=W(),m=Se(),h=be(),g=xe();let _=new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function b(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i)if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=b})),we=w((e=>{var t=E(),n=z(),r=V(),i=H(),a=Ce();let o=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;e.Schema=class e{constructor({compat:e,customTags:s,merge:c,resolveKnownTags:l,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof u==`string`&&u||`core`,this.knownTags=l?a.coreKnownTags:{},this.tags=a.getTags(s,this.name,c),this.toStringOptions=f??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof d==`function`?d:d===!0?o:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}})),Te=w((e=>{var t=E(),n=F(),r=N();function i(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd)if(e.comment){let t=c(e.comment);t.includes(`
39
+ `)?(a.push(`...`),a.push(r.indentComment(t,``))):a.push(`... ${t}`)}else a.push(`...`);else{let t=e.comment;t&&l&&(t=t.replace(/^\n+/,``)),t&&((!l||u)&&a[a.length-1]!==``&&a.push(``),a.push(r.indentComment(c(t),``)))}return a.join(`
40
+ `)+`
41
+ `}e.stringifyDocument=i})),G=w((e=>{var t=A(),n=re(),r=E(),i=L(),a=k(),o=we(),s=Te(),c=O(),l=te(),u=M(),d=ee(),f=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let t=Object.create(e.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=r.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:f}=n??{},{onAnchor:p,setAnchors:m,sourceObjects:h}=c.createNodeAnchors(this,o||`a`),g={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:p,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:h},_=u.createNode(e,f,g);return s&&r.isCollection(_)&&(_.flow=!0),m(),_}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return p(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):p(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function p(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=f})),K=w((e=>{var t=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},n=class extends t{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},r=class extends t{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};e.YAMLError=t,e.YAMLParseError=n,e.YAMLWarning=r,e.prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
42
+ `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}}})),q=w((e=>{function t(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:(!b||n!==`seq-item-ind`)&&(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}e.resolveProps=t})),Ee=w((e=>{function t(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
43
+ `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let n of e.items){for(let e of n.start)if(e.type===`newline`)return!0;if(n.sep){for(let e of n.sep)if(e.type===`newline`)return!0}if(t(n.key)||t(n.value))return!0}return!1;default:return!0}}e.containsNewline=t})),De=w((e=>{var t=Ee();function n(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=n})),Oe=w((e=>{var t=E();function n(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=n})),ke=w((e=>{var t=L(),n=R(),r=q(),i=Ee(),a=De(),o=Oe();let s=`All mapping items must start at the same column`;function c({composeNode:e,composeEmptyNode:c},l,u,d,f){let p=new(f?.nodeClass??n.YAMLMap)(l.schema);l.atRoot&&=!1;let m=u.offset,h=null;for(let n of u.items){let{start:f,key:g,sep:_,value:v}=n,y=r.resolveProps(f,{indicator:`explicit-key-ind`,next:g??_?.[0],offset:m,onError:d,parentIndent:u.indent,startOnNewline:!0}),b=!y.found;if(b){if(g&&(g.type===`block-seq`?d(m,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in g&&g.indent!==u.indent&&d(m,`BAD_INDENT`,s)),!y.anchor&&!y.tag&&!_){h=y.end,y.comment&&(p.comment?p.comment+=`
44
+ `+y.comment:p.comment=y.comment);continue}(y.newlineAfterProp||i.containsNewline(g))&&d(g??f[f.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else y.found?.indent!==u.indent&&d(m,`BAD_INDENT`,s);l.atKey=!0;let x=y.end,S=g?e(l,g,y,d):c(l,x,f,null,y,d);l.schema.compat&&a.flowIndentCheck(u.indent,g,d),l.atKey=!1,o.mapIncludes(l,p.items,S)&&d(x,`DUPLICATE_KEY`,`Map keys must be unique`);let C=r.resolveProps(_??[],{indicator:`map-value-ind`,next:v,offset:S.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||g.type===`block-scalar`});if(m=C.end,C.found){b&&(v?.type===`block-map`&&!C.hasNewline&&d(m,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),l.options.strict&&y.start<C.found.offset-1024&&d(S.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let r=v?e(l,v,C,d):c(l,m,_,null,C,d);l.schema.compat&&a.flowIndentCheck(u.indent,v,d),m=r.range[2];let i=new t.Pair(S,r);l.options.keepSourceTokens&&(i.srcToken=n),p.items.push(i)}else{b&&d(S.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),C.comment&&(S.comment?S.comment+=`
45
+ `+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=c})),Ae=w((e=>{var t=B(),n=q(),r=De();function i({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new(c?.nodeClass??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let f=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||c)c?.type===`block-seq`?s(f.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=f.end,f.comment&&(l.comment=f.comment);continue}let p=c?e(a,c,f,s):i(a,f.end,t,null,f,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=p.range[2],l.items.push(p)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=i})),J=w((e=>{function t(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=t})),je=w((e=>{var t=E(),n=L(),r=R(),i=B(),a=J(),o=q(),s=Ee(),c=Oe();let l=`Block collections are not allowed within flow collections`,u=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function d({composeNode:e,composeEmptyNode:d},f,p,m,h){let g=p.start.source===`{`,_=g?`flow map`:`flow sequence`,v=new(h?.nodeClass??(g?r.YAMLMap:i.YAMLSeq))(f.schema);v.flow=!0;let y=f.atRoot;y&&(f.atRoot=!1),f.atKey&&=!1;let b=p.offset+p.start.source.length;for(let i=0;i<p.items.length;++i){let a=p.items[i],{start:h,key:y,sep:x,value:S}=a,C=o.resolveProps(h,{flow:_,indicator:`explicit-key-ind`,next:y??x?.[0],offset:b,onError:m,parentIndent:p.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!x&&!S){i===0&&C.comma?m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`):i<p.items.length-1&&m(C.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${_}`),C.comment&&(v.comment?v.comment+=`
46
+ `+C.comment:v.comment=C.comment),b=C.end;continue}!g&&f.options.strict&&s.containsNewline(y)&&m(y,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(i===0)C.comma&&m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`);else if(C.comma||m(C.start,`MISSING_CHAR`,`Missing , between ${_} items`),C.comment){let e=``;loop:for(let t of h)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let n=v.items[v.items.length-1];t.isPair(n)&&(n=n.value??n.key),n.comment?n.comment+=`
47
+ `+e:n.comment=e,C.comment=C.comment.substring(e.length+1)}}if(!g&&!x&&!C.found){let t=S?e(f,S,C,m):d(f,C.end,x,null,C,m);v.items.push(t),b=t.range[2],u(S)&&m(t.range,`BLOCK_IN_FLOW`,l)}else{f.atKey=!0;let t=C.end,i=y?e(f,y,C,m):d(f,t,h,null,C,m);u(y)&&m(i.range,`BLOCK_IN_FLOW`,l),f.atKey=!1;let s=o.resolveProps(x??[],{flow:_,indicator:`map-value-ind`,next:S,offset:i.range[2],onError:m,parentIndent:p.indent,startOnNewline:!1});if(s.found){if(!g&&!C.found&&f.options.strict){if(x)for(let e of x){if(e===s.found)break;if(e.type===`newline`){m(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}C.start<s.found.offset-1024&&m(s.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else S&&(`source`in S&&S.source?.[0]===`:`?m(S,`MISSING_CHAR`,`Missing space after : in ${_}`):m(s.start,`MISSING_CHAR`,`Missing , or : between ${_} items`));let w=S?e(f,S,s,m):s.found?d(f,s.end,x,null,s,m):null;w?u(S)&&m(w.range,`BLOCK_IN_FLOW`,l):s.comment&&(i.comment?i.comment+=`
48
+ `+s.comment:i.comment=s.comment);let T=new n.Pair(i,w);if(f.options.keepSourceTokens&&(T.srcToken=a),g){let e=v;c.mapIncludes(f,e.items,i)&&m(t,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(T)}else{let e=new r.YAMLMap(f.schema);e.flow=!0,e.items.push(T);let t=(w??i).range;e.range=[i.range[0],t[1],t[2]],v.items.push(e)}b=w?w.range[2]:s.end}}let x=g?`}`:`]`,[S,...C]=p.end,w=b;if(S?.source===x)w=S.offset+S.source.length;else{let e=_[0].toUpperCase()+_.substring(1),t=y?`${e} must end with a ${x}`:`${e} in block collection must be sufficiently indented and end with a ${x}`;m(b,y?`MISSING_CHAR`:`BAD_INDENT`,t),S&&S.source.length!==1&&C.unshift(S)}if(C.length>0){let e=a.resolveEnd(C,w,f.options.strict,m);e.comment&&(v.comment?v.comment+=`
49
+ `+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=d})),Me=w((e=>{var t=E(),n=j(),r=R(),i=B(),a=ke(),o=Ae(),s=je();function c(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function l(e,a,o,s,l){let u=s.tag,d=u?a.directives.tagName(u.source,e=>l(u,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&u?e.offset>u.offset?e:u:e??u;n&&(!t||t.offset<n.offset)&&l(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let f=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!u||!d||d===`!`||d===r.YAMLMap.tagName&&f===`map`||d===i.YAMLSeq.tagName&&f===`seq`)return c(e,a,o,l,d);let p=a.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!p){let t=a.schema.knownTags[d];if(t?.collection===f)a.schema.tags.push(Object.assign({},t,{default:!1})),p=t;else return t?l(u,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${f} collection, but expects ${t.collection??`scalar`}`,!0):l(u,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${d}`,!0),c(e,a,o,l,d)}let m=c(e,a,o,l,d,p),h=p.resolve?.(m,e=>l(u,`TAG_RESOLVE_FAILED`,e),a.options)??m,g=t.isNode(h)?h:new n.Scalar(h);return g.range=m.range,g.tag=d,p?.format&&(g.format=p.format),g}e.composeCollection=l})),Ne=w((e=>{var t=j();function n(e,n,a){let o=n.offset,s=r(n,e.options.strict,a);if(!s)return{value:``,type:null,comment:``,range:[o,o,o]};let c=s.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,l=n.source?i(n.source):[],u=l.length;for(let e=l.length-1;e>=0;--e){let t=l[e][1];if(t===``||t===`\r`)u=e;else break}if(u===0){let e=s.chomp===`+`&&l.length>0?`
50
+ `.repeat(Math.max(1,l.length-1)):``,t=o+s.length;return n.source&&(t+=n.source.length),{value:e,type:c,comment:s.comment,range:[o,t,t]}}let d=n.indent+s.indent,f=n.offset+s.length,p=0;for(let t=0;t<u;++t){let[n,r]=l[t];if(r===``||r===`\r`)s.indent===0&&n.length>d&&(d=n.length);else{n.length<d&&a(f+n.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),s.indent===0&&(d=n.length),p=t,d===0&&!e.atRoot&&a(f,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}f+=n.length+r.length+1}for(let e=l.length-1;e>=u;--e)l[e][0].length>d&&(u=e+1);let m=``,h=``,g=!1;for(let e=0;e<p;++e)m+=l[e][0].slice(d)+`
51
+ `;for(let e=p;e<u;++e){let[n,r]=l[e];f+=n.length+r.length+1;let i=r[r.length-1]===`\r`;if(i&&(r=r.slice(0,-1)),r&&n.length<d){let e=`Block scalar lines must not be less indented than their ${s.indent?`explicit indentation indicator`:`first line`}`;a(f-r.length-(i?2:1),`BAD_INDENT`,e),n=``}c===t.Scalar.BLOCK_LITERAL?(m+=h+n.slice(d)+r,h=`
52
+ `):n.length>d||r[0]===` `?(h===` `?h=`
53
+ `:!g&&h===`
54
+ `&&(h=`
55
+
56
+ `),m+=h+n.slice(d)+r,h=`
57
+ `,g=!0):r===``?h===`
58
+ `?m+=`
59
+ `:h=`
60
+ `:(m+=h+r,h=` `,g=!1)}switch(s.chomp){case`-`:break;case`+`:for(let e=u;e<l.length;++e)m+=`
61
+ `+l[e][0].slice(d);m[m.length-1]!==`
62
+ `&&(m+=`
63
+ `);break;default:m+=`
64
+ `}let _=o+s.length+n.source.length;return{value:m,type:c,comment:s.comment,range:[o,_,_]}}function r({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function i(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=n})),Pe=w((e=>{var t=j(),n=J();function r(e,r,o){let{offset:c,type:l,source:u,end:d}=e,f,p,m=(e,t,n)=>o(c+e,t,n);switch(l){case`scalar`:f=t.Scalar.PLAIN,p=i(u,m);break;case`single-quoted-scalar`:f=t.Scalar.QUOTE_SINGLE,p=a(u,m);break;case`double-quoted-scalar`:f=t.Scalar.QUOTE_DOUBLE,p=s(u,m);break;default:return o(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${l}`),{value:``,type:null,comment:``,range:[c,c+u.length,c+u.length]}}let h=c+u.length,g=n.resolveEnd(d,h,r,o);return{value:p,type:f,comment:g.comment,range:[c,h,g.offset]}}function i(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`;break}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),o(e)}function a(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),o(e.slice(1,-1)).replace(/''/g,`'`)}function o(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
65
+ `?a+=o:o=`
66
+ `:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function s(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(!(i===`\r`&&e[r+1]===`
67
+ `))if(i===`
68
+ `){let{fold:t,offset:i}=c(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=l[i];if(a)n+=a;else if(i===`
69
+ `)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
70
+ `)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=u(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
71
+ `&&!(a===`\r`&&e[r+2]===`
72
+ `)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function c(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
73
+ `||r===`\r`)&&!(r===`\r`&&e[t+2]!==`
74
+ `);)r===`
75
+ `&&(n+=`
76
+ `),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}let l={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
77
+ `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function u(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}e.resolveFlowScalar=r})),Fe=w((e=>{var t=E(),n=j(),r=Ne(),i=Pe();function a(e,a,c,l){let{value:u,type:d,comment:f,range:p}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,l):i.resolveFlowScalar(a,e.options.strict,l),m=c?e.directives.tagName(c.source,e=>l(c,`TAG_RESOLVE_FAILED`,e)):null,h;h=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:m?o(e.schema,u,m,c,l):a.type===`scalar`?s(e,u,a,l):e.schema[t.SCALAR];let g;try{let r=h.resolve(u,e=>l(c??a,`TAG_RESOLVE_FAILED`,e),e.options);g=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);l(c??a,`TAG_RESOLVE_FAILED`,t),g=new n.Scalar(u)}return g.range=p,g.source=u,d&&(g.type=d),m&&(g.tag=m),h.format&&(g.format=h.format),f&&(g.comment=f),g}function o(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r)if(t.default&&t.test)o.push(t);else return t;for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function s({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=a})),Ie=w((e=>{function t(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=t})),Le=w((e=>{var t=A(),n=E(),r=Me(),i=Fe(),a=J(),o=Ie();let s={composeNode:c,composeEmptyNode:l};function c(e,t,a,o){let c=e.atKey,{spaceBefore:d,comment:f,anchor:p,tag:m}=a,h,g=!0;switch(t.type){case`alias`:h=u(e,t,o),(p||m)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:h=i.composeScalar(e,t,m,o),p&&(h.anchor=p.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{h=r.composeCollection(s,e,t,a,o),p&&(h.anchor=p.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),g=!1}return h??=l(e,t.offset,void 0,null,a,o),p&&h.anchor===``&&o(p,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(h)||typeof h.value!=`string`||h.tag&&h.tag!==`tag:yaml.org,2002:str`)&&o(m??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),d&&(h.spaceBefore=!0),f&&(t.type===`scalar`&&t.source===``?h.comment=f:h.commentBefore=f),e.options.keepSourceTokens&&g&&(h.srcToken=t),h}function l(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let f={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},p=i.composeScalar(e,f,l,d);return c&&(p.anchor=c.source.substring(1),p.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}function u({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=l,e.composeNode=c})),Re=w((e=>{var t=G(),n=Le(),r=J(),i=q();function a(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),f=new t.Document(void 0,d),p={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},m=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});m.found&&(f.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!m.hasNewline&&u(m.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),f.contents=c?n.composeNode(p,c,m,u):n.composeEmptyNode(p,m.end,s,null,m,u);let h=f.contents.range[2],g=r.resolveEnd(l,h,!1,u);return g.comment&&(f.comment=g.comment),f.range=[o,h,g.offset],f}e.composeDoc=a})),ze=w((e=>{var t=T(`process`),n=ee(),r=G(),i=K(),a=E(),o=Re(),s=J();function c(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function l(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
78
+
79
+ `:`
80
+ `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}e.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=c(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=l(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=c(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}}})),Be=w((e=>{var t=Ne(),n=Pe(),r=K(),i=P();function a(e,i=!0,a){if(e){let o=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,o);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,o)}}return null}function o(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:`newline`,offset:-1,indent:r,source:`
81
+ `}];switch(c[0]){case`|`:case`>`:{let e=c.indexOf(`
82
+ `),t=c.substring(0,e),n=c.substring(e+1)+`
83
+ `,i=[{type:`block-scalar-header`,offset:o,indent:r,source:t}];return l(i,u)||i.push({type:`newline`,offset:-1,indent:r,source:`
84
+ `}),{type:`block-scalar`,offset:o,indent:r,props:i,source:n}}case`"`:return{type:`double-quoted-scalar`,offset:o,indent:r,source:c,end:u};case`'`:return{type:`single-quoted-scalar`,offset:o,indent:r,source:c,end:u};default:return{type:`scalar`,offset:o,indent:r,source:c,end:u}}}function s(e,t,n={}){let{afterKey:r=!1,implicitKey:a=!1,inFlow:o=!1,type:s}=n,l=`indent`in e?e.indent:null;if(r&&typeof l==`number`&&(l+=2),!s)switch(e.type){case`single-quoted-scalar`:s=`QUOTE_SINGLE`;break;case`double-quoted-scalar`:s=`QUOTE_DOUBLE`;break;case`block-scalar`:{let t=e.props[0];if(t.type!==`block-scalar-header`)throw Error(`Invalid block scalar header`);s=t.source[0]===`>`?`BLOCK_FOLDED`:`BLOCK_LITERAL`;break}default:s=`PLAIN`}let d=i.stringifyString({type:s,value:t},{implicitKey:a||l===null,indent:l!==null&&l>0?` `.repeat(l):``,inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(d[0]){case`|`:case`>`:c(e,d);break;case`"`:u(e,d,`double-quoted-scalar`);break;case`'`:u(e,d,`single-quoted-scalar`);break;default:u(e,d,`scalar`)}}function c(e,t){let n=t.indexOf(`
85
+ `),r=t.substring(0,n),i=t.substring(n+1)+`
86
+ `;if(e.type===`block-scalar`){let t=e.props[0];if(t.type!==`block-scalar-header`)throw Error(`Invalid block scalar header`);t.source=r,e.source=i}else{let{offset:t}=e,n=`indent`in e?e.indent:-1,a=[{type:`block-scalar-header`,offset:t,indent:n,source:r}];l(a,`end`in e?e.end:void 0)||a.push({type:`newline`,offset:-1,indent:n,source:`
87
+ `});for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:`block-scalar`,indent:n,props:a,source:i})}}function l(e,t){if(t)for(let n of t)switch(n.type){case`space`:case`comment`:e.push(n);break;case`newline`:return e.push(n),!0}return!1}function u(e,t,n){switch(e.type){case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:e.type=n,e.source=t;break;case`block-scalar`:{let r=e.props.slice(1),i=t.length;e.props[0].type===`block-scalar-header`&&(i-=e.props[0].source.length);for(let e of r)e.offset+=i;delete e.props,Object.assign(e,{type:n,source:t,end:r});break}case`block-map`:case`block-seq`:{let r={type:`newline`,offset:e.offset+t.length,indent:e.indent,source:`
88
+ `};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=o,e.resolveAsScalar=a,e.setScalarValue=s})),Ve=w((e=>{let t=e=>`type`in e?n(e):r(e);function n(e){switch(e.type){case`block-scalar`:{let t=``;for(let r of e.props)t+=n(r);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=r(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=r(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=r(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function r({start:e,key:t,sep:r,value:i}){let a=``;for(let t of e)a+=t.source;if(t&&(a+=n(t)),r)for(let e of r)a+=e.source;return i&&(a+=n(i)),a}e.stringify=t})),He=w((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),a(Object.freeze([]),e,t)}i.BREAK=t,i.SKIP=n,i.REMOVE=r,i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},i.parentCollection=(e,t)=>{let n=i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],a=n?.[r];if(a&&`items`in a)return a;throw Error(`Parent collection not found`)};function a(e,n,i){let o=i(n,e);if(typeof o==`symbol`)return o;for(let s of[`key`,`value`]){let c=n[s];if(c&&`items`in c){for(let n=0;n<c.items.length;++n){let o=a(Object.freeze(e.concat([[s,n]])),c.items[n],i);if(typeof o==`number`)n=o-1;else if(o===t)return t;else o===r&&(c.items.splice(n,1),--n)}typeof o==`function`&&s===`key`&&(o=o(n,e))}}return typeof o==`function`?o(n,e):o}e.visit=i})),Y=w((e=>{var t=Be(),n=Ve(),r=He();let i=e=>!!e&&`items`in e,a=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);function o(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:return`<FLOW_END>`;case``:return`<SCALAR>`;default:return JSON.stringify(e)}}function s(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
89
+ `:case`\r
90
+ `: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(e[0]){case` `:case` `: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}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=i,e.isScalar=a,e.prettyToken=o,e.tokenType=s})),Ue=w((e=>{var t=Y();function n(e){switch(e){case void 0:case` `:case`
91
+ `:case`\r`:case` `:return!0;default:return!1}}let r=new Set(`0123456789ABCDEFabcdef`),i=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),a=new Set(`,[]{}`),o=new Set(` ,[]{}
92
+ \r `),s=e=>!e||o.has(e);e.Lexer=class{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(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
93
+ `?!0:t===`\r`?this.buffer[e+1]===`
94
+ `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
95
+ `||!t&&!this.atEnd)return e+n+1}return t===`
96
+ `||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&n(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
97
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){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 e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===t.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}else n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield t.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&n(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!n(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&n(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);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(s),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,r,i=-1;do e=yield*this.pushNewline(),e>0?(r=yield*this.pushSpaces(!1),this.indentValue=i=r):r=0,r+=yield*this.pushSpaces(!0);while(e+r>0);let a=this.getLine();if(a===null)return this.setNext(`flow`);if((i!==-1&&i<this.indentNext&&a[0]!==`#`||i===0&&(a.startsWith(`---`)||a.startsWith(`...`))&&n(a[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(a[0]===`]`||a[0]===`}`)))return this.flowLevel=0,yield t.FLOW_END,yield*this.parseLineStart();let o=0;for(;a[o]===`,`;)o+=yield*this.pushCount(1),o+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(o+=yield*this.pushIndicators(),a[o]){case void 0:return`flow`;case`#`:return yield*this.pushCount(a.length-o),`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,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(s),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||n(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
98
+ `,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
99
+ `,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>n(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,n=0,r;loop:for(let t=this.pos;r=this.buffer[t];++t)switch(r){case` `:n+=1;break;case`
100
+ `:e=t,n=0;break;case`\r`:{let e=this.buffer[t+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
101
+ `)break}default:break loop}if(!r&&!this.atEnd)return this.setNext(`block-scalar`);if(n>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=n:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
102
+ `,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let i=e+1;for(r=this.buffer[i];r===` `;)r=this.buffer[++i];if(r===` `){for(;r===` `||r===` `||r===`\r`||r===`
103
+ `;)r=this.buffer[++i];e=i-1}else if(!this.blockScalarKeep)do{let t=e-1,r=this.buffer[t];r===`\r`&&(r=this.buffer[--t]);let i=t;for(;r===` `;)r=this.buffer[--t];if(r===`
104
+ `&&t>=this.pos&&t+1+n>i)e=t;else break}while(!0);return yield t.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,r=this.pos-1,i=this.pos-1,o;for(;o=this.buffer[++i];)if(o===`:`){let t=this.buffer[i+1];if(n(t)||e&&a.has(t))break;r=i}else if(n(o)){let t=this.buffer[i+1];if(o===`\r`&&(t===`
105
+ `?(i+=1,o=`
106
+ `,t=this.buffer[i+1]):r=i),t===`#`||e&&a.has(t))break;if(o===`
107
+ `){let e=this.continueScalar(i+1);if(e===-1)break;i=Math.max(i,e-2)}}else{if(e&&a.has(o))break;r=i}return!o&&!this.atEnd?this.setNext(`plain-scalar`):(yield t.SCALAR,yield*this.pushToIndex(r+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(s),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,r=this.charAt(1);if(n(r)||t&&a.has(r)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!n(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(i.has(t))t=this.buffer[++e];else if(t===`%`&&r.has(this.buffer[e+1])&&r.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
108
+ `?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
109
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}})),We=w((e=>{e.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}})),Ge=w((e=>{var t=T(`process`),n=Y(),r=Ue();function i(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function a(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function o(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function s(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function c(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function l(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function u(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!i(t.start,`explicit-key-ind`)&&!i(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,o(t.value)?t.value.end?l(t.value.end,t.sep):t.value.end=t.sep:l(t.start,t.sep),delete t.sep)}e.Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new r.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,t.env.LOG_TOKENS&&console.log(`|`,n.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=n.tokenType(e);if(r)if(r===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=r,yield*this.step(),r){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}else{let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&u(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&a(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.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 e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:a(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=c(s(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
110
+ `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
111
+ `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){l(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,a=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(a=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):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(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(i(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(o(t.key)&&!i(t.sep,`newline`)){let e=c(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else a.length>0?t.sep=t.sep.concat(a,this.sourceToken):t.sep.push(this.sourceToken);else if(i(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=c(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||r?e.items.push({start:a,key:null,sep:[this.sourceToken]}):i(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:a,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!i(t.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 n&&e.items.push({start:a});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){l(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||i(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=c(s(t));u(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
112
+ `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
113
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){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 t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){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:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),Ke=w((e=>{var t=ze(),n=G(),r=K(),i=oe(),a=E(),o=We(),s=Ge();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f}));w((e=>{var t=ze(),n=G(),r=we(),i=K(),a=A(),o=E(),s=L(),c=j(),l=R(),u=B();Y();var d=Ue(),f=We(),p=Ge(),m=Ke(),h=D();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync}))();function X(){return process.env.TBOXCODE_DSH_CONFIG_DIR??l(g(),`.config`,`tboxcode-dsh`)}function qe(e=X()){for(let t of[`config.jsonc`,`config.json`]){let n=l(e,t);if(f(n))return n}return null}function Je(e){let t=``,n=0,r=e.length,i=!1;for(;n<r;){let a=e[n];if(i){if(t+=a,a===`\\`){n+1<r&&(t+=e[n+1]),n+=2;continue}a===`"`&&(i=!1),n++;continue}if(a===`"`){i=!0,t+=a,n++;continue}if(a===`/`&&e[n+1]===`/`){for(;n<r&&e[n]!==`
114
+ `;)n++;continue}if(a===`/`&&e[n+1]===`*`){for(n+=2;n<r&&!(e[n]===`*`&&e[n+1]===`/`);)n++;n+=2;continue}t+=a,n++}return t.replace(/,(\s*[}\]])/g,`$1`)}function Z(e,t=new WeakSet){if(typeof e==`string`)return e.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,(e,t)=>{let n=process.env[t];return n===void 0?e:n});if(Array.isArray(e))return e.map(e=>Z(e,t));if(typeof e==`object`&&e){let n=e;if(t.has(n))return e;t.add(n);let r={};for(let[e,i]of Object.entries(n))r[e]=Z(i,t);return t.delete(n),r}return e}function Ye(e=X()){let t=qe(e);if(t===null)return{path:null,config:{}};let n=p(t,`utf-8`);try{let e=JSON.parse(Je(n));if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`config 顶层必须是对象`);return{path:t,config:Z(e)}}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`config 解析失败(${t}):${n}`)}}function Xe(e,t,n,r=500){let i=new Set(t),a,o=!1,s=()=>{a!==void 0&&clearTimeout(a),a=setTimeout(()=>{o||n()},r)},c;try{c=h(e,{persistent:!1},(e,t)=>{t!==null&&!i.has(t)||s()})}catch{return{dispose:()=>{o=!0}}}return c.on(`error`,()=>{}),{dispose:()=>{o=!0,a!==void 0&&clearTimeout(a),c.close()}}}function Ze(e,t){return t.image===void 0?e.map(e=>{if(!Array.isArray(e.content))return e;let t=[];for(let n of e.content){let e=n;if(e.type!==`image`){t.push(n);continue}let r=e.mimeType??(typeof e.image==`object`&&e.image?e.image.mediaType:void 0),i=r===void 0?`[image]`:`[image: ${r}]`,a=t.length-1,o=t[a];o?.type===`text`?t[a]={...o,text:o.text+i}:t.push({type:`text`,text:i})}return{...e,content:t}}):e}const Qe=e=>Array.isArray(e);function $e(e){return e.map(e=>{if(e.role!==`assistant`)return e;if(Qe(e.content))return e.content.some(e=>e.type===`reasoning`)?e:{...e,content:[...e.content,{type:`reasoning`,text:``}]};let t=typeof e.content==`string`?e.content:``;return{...e,content:[...t?[{type:`text`,text:t}]:[],{type:`reasoning`,text:``}]}})}function et(e){let t=e=>e.replace(/[^a-zA-Z0-9_-]/g,`_`);return e.map(e=>Qe(e.content)?{...e,content:e.content.map(e=>{let n=e;return(n.type===`tool-call`||n.type===`tool-result`)&&n.toolCallId!==void 0?{...n,toolCallId:t(n.toolCallId)}:n})}:e)}function tt(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&t.push(r);let i=e[n+1];r?.role===`tool`&&i?.role===`user`&&t.push({role:`assistant`,content:[{type:`text`,text:`Done.`}]})}return t}function nt(e){return e.filter(e=>!(Qe(e.content)&&e.content.length===0))}const rt={"ensure-assistant-reasoning":$e,"scrub-tool-call-id":et,"done-after-tool":tt,"drop-empty-content":nt};function it(e,t=[]){return t.reduce((e,t)=>rt[t](e),e)}function at(e){switch(e){case`openai`:return`openai`;case`anthropic`:return`anthropic`;case`openai-compatible`:return`openaiCompatible`}}function ot(e){return e===void 0||e===`none`?`none`:typeof e==`string`?{mode:`automatic`,ttl:`5m`}:{...e}}function st(e){let t=ct(e);return a(`sha256`).update(t).digest(`hex`).slice(0,16)}function ct(e){return JSON.stringify(lt(e))}function lt(e){if(Array.isArray(e))return e.map(lt);if(typeof e==`object`&&e){let t=e;return Object.fromEntries(Object.keys(t).sort().map(e=>[e,lt(t[e])]))}return e}function ut(e,t){return e===`openai-compatible`?t:at(e)}const dt=/\$\{(\w+(?:\.\w+)?)\}/g;function ft(e,t,n){let r=e.replace(dt,(e,r)=>{switch(r){case`sessionId`:return t.sessionId;case`effort`:return n??t.effort??``;case`model.output`:return String(t.model.output);case`model.context`:return String(t.model.context);default:return``}});return r=pt(r),r}function pt(e){let t=e;return t=t.replace(/min\(([^)]+)\)/g,(e,t)=>{let n=t.split(`,`).map(e=>Number.parseFloat(e.trim()));return String(Math.min(...n))}),t=t.replace(/max\(([^)]+)\)/g,(e,t)=>{let n=t.split(`,`).map(e=>Number.parseFloat(e.trim()));return String(Math.max(...n))}),t=t.replace(/floor\(([^)]+)\)/g,(e,t)=>String(Math.floor(Number.parseFloat(t.trim())))),t}function mt(e,t,n,r,i,a){let o=at(t.protocol),s=t.protocol===`anthropic`?`anthropic`:o,c=t.reasoning?.effort,l=c?.levels,u=n.effort!==void 0&&l?.some(e=>e.id===n.effort)===!0?n.effort:c?.default??l?.[0]?.id,d=it(e,t.quirks);d=Ze(d,t);let f=t.reasoning;if(f?.interleaved===!0&&f.field!==void 0){let e=f.field;d=d.map(t=>{if(t.role!==`assistant`||!Array.isArray(t.content))return t;let n=t.content.filter(e=>e.type===`reasoning`).map(e=>e.text??``).join(``),r=t.content.filter(e=>e.type!==`reasoning`),i=t.providerOptions,a=i?.[o]??{};return{...t,content:r,providerOptions:{...i,[o]:{...a,[e]:n}}}})}let p=ot(t.cache),m=r,h=null,g=null;if(p!==`none`){let e=p.ttl,n=p.mode===`explicit`?p.scope??[`system`,`tools`]:[`system`,`messages`],i={type:`ephemeral`,ttl:e},o=n.includes(`system`);if(o&&(m={role:`system`,content:r,providerOptions:{[s]:{cacheControl:i}}}),n.includes(`tools`)&&(h=i,g=s),n.includes(`messages`)&&(a?.messageBreakpoints??!0)){let e=t.protocol===`anthropic`?Math.max(0,4-(o?1:0)-(h===null?0:1)):1;if(e>0){let n=d.slice(-e);for(let e of n)ht(e,i,s,t.protocol)}}}let _={...t.body??{}};for(let[e,r]of Object.entries(t.body_templates??{}))_[e]=ft(r,n,u);let v=t.reasoning?.effort?.levels;if(u!==void 0&&v!==void 0){let e=v.find(e=>e.id===u);e?.body!==void 0&&Object.assign(_,e.body)}let y=_;if(t.when?.reasoning===!0&&!n.reasoningEnabled){let e=t.when?.reasoning_keys??[`enable_thinking`,`thinking`];y=Object.fromEntries(Object.entries(_).filter(([t])=>!e.includes(t)))}let b=ut(t.protocol,i),x={};if(Object.keys(y).length>0){let e={...y};t.protocol===`openai-compatible`&&typeof e.reasoning_effort==`string`&&e.reasoningEffort===void 0&&(e.reasoningEffort=e.reasoning_effort),x[b]=e}return{messages:d,system:m,providerOptions:x,extraBody:y,toolsCacheControl:h,toolsCacheControlKey:g}}function ht(e,t,n,r){if(r!==`anthropic`&&Array.isArray(e.content)&&e.content.length>0){let r=e.content[e.content.length-1],i=r.providerOptions?.[n]??{};r.providerOptions={...r.providerOptions,[n]:{...i,cacheControl:t}}}else{let r=e,i=r.providerOptions?.[n]??{};r.providerOptions={...r.providerOptions,[n]:{...i,cacheControl:t}}}}function gt(e){return b({apiKey:e.apiKey,baseURL:e.baseURL,headers:e.headers,fetch:e.fetch})(e.upstream_model)}function _t(){return{extractMetadata:async({parsedBody:e})=>{let t=e?.usage;return t===void 0?void 0:{usage:t}},createStreamExtractor:()=>{let e;return{processChunk(t){let n=t?.usage;n!==void 0&&(e=n)},buildMetadata(){return e===void 0?void 0:{usage:e}}}}}}function vt(e){return x({name:e.provider_name,apiKey:e.apiKey,baseURL:e.baseURL??`http://offline.invalid/v1`,headers:e.headers,fetch:e.fetch,includeUsage:!0,metadataExtractor:_t(),supportedUrls:()=>({"image/*":[/^https?:\/\//]})}).chatModel(e.upstream_model)}function yt(e){return S({apiKey:e.apiKey,baseURL:e.baseURL,headers:e.headers,fetch:e.fetch})(e.upstream_model)}function bt(e,t){let{provider_name:n,upstream_model:r,traits:i,credentials:a}=e,o=t?.drain,s;switch(i.protocol){case`openai`:s=yt({upstream_model:r,apiKey:a.apiKey,baseURL:a.baseURL,headers:a.headers,fetch:t?.fetch});break;case`openai-compatible`:s=vt({upstream_model:r,provider_name:n,apiKey:a.apiKey,baseURL:a.baseURL,headers:a.headers,fetch:t?.fetch});break;case`anthropic`:s=gt({upstream_model:r,apiKey:a.apiKey,baseURL:a.baseURL,headers:a.headers,fetch:t?.fetch});break}return{streamText(e){return v({model:s,system:e.system,messages:e.messages,providerOptions:e.providerOptions,tools:e.tools,toolChoice:e.toolChoice,abortSignal:e.signal,maxRetries:e.maxRetries??2,...e.params})},dispose(){return o?.()}}}var xt=class extends Error{constructor(e){super(`Model not configured: ${e}`),this.modelId=e,this.name=`ModelNotConfiguredError`}},Q=class extends Error{constructor(e,t){super(`Provider not configured: ${e}${t?` (${t})`:``}`),this.ref=e,this.detail=t,this.name=`ProviderNotConfiguredError`}},St=class extends Error{constructor(e){super(`Effort template not found: "${e}"`),this.templateName=e,this.name=`EffortTemplateNotFoundError`}},Ct=class extends Error{constructor(e,t){super(`Effort default "${t}" not in resolved levels (model ${e})`),this.ref=e,this.defaultId=t,this.name=`EffortDefaultNotInLevelsError`}};function wt(e,t){let n=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=n.get(e.id);n.set(e.id,t===void 0?e:{...t,...e})}return[...n.values()]}function Tt(e,t,n){if(!e)return;if(!e.effort)return e;let r=e.effort,i;if(r.template!==void 0){let n=t?.[r.template];if(n===void 0)throw new St(r.template);let a=wt(n.levels,r.levels??[]);if(a.length===0)return{...e,effort:void 0};i={...n,default:r.default??n.default??a[0].id,levels:a}}else if(r.levels!==void 0&&r.levels.length>0)i={...r,default:r.default??r.levels[0].id,levels:r.levels};else return{...e,effort:void 0};let a=i.default;if(!i.levels.some(e=>e.id===a))throw new Ct(n??`(unknown)`,a);return{...e,effort:i}}const Et=C.enum([`openai`,`openai-compatible`,`anthropic`]),Dt=C.enum([`5m`,`1h`]),Ot=C.object({mode:C.enum([`automatic`,`explicit`]),ttl:Dt,scope:C.array(C.enum([`system`,`tools`,`messages`])).optional()}),kt=C.enum([`ensure-assistant-reasoning`,`scrub-tool-call-id`,`done-after-tool`,`drop-empty-content`]),At=C.object({id:C.string().min(1).max(80),name:C.string().max(80).optional(),description:C.string().optional(),body:C.record(C.string(),C.unknown()).optional(),headers:C.record(C.string(),C.string()).optional()}),jt=C.object({default:C.string().min(1).max(80).optional(),levels:C.array(At).optional()}).passthrough().extend({template:C.string().min(1).max(120).optional()}).refine(e=>e.template||e.levels!==void 0&&e.levels.length>0,`effort requires either template or levels`),Mt=C.object({default:C.string().min(1).max(80).optional(),levels:C.array(At).min(1)}).passthrough(),Nt=C.object({field:C.enum([`reasoning`,`reasoning_content`,`reasoning_details`]).optional(),interleaved:C.boolean().optional(),summary:C.literal(`auto`).optional(),include:C.literal(`encrypted`).optional(),effort:jt.optional()}),Pt=C.object({protocol:Et,provider_name:C.string().optional(),upstream_model:C.string().min(1).optional(),reasoning:Nt.optional(),image:C.enum([`url`,`base64`]).optional(),cache:C.union([C.literal(`none`),C.literal(`anthropic`),C.literal(`openai-compatible`),C.literal(`bedrock`),Ot]).optional(),limit:C.object({context:C.number().positive(),output:C.number().positive(),idle_timeout_ms:C.number().int().positive().optional()}),body:C.record(C.string(),C.unknown()).optional(),body_templates:C.record(C.string(),C.string()).optional(),headers:C.record(C.string(),C.string()).optional(),when:C.object({reasoning:C.boolean().optional(),reasoning_keys:C.array(C.string()).optional()}).optional(),quirks:C.array(kt).optional()}).passthrough(),Ft=C.object({apiKey:C.string().optional(),baseURL:C.string().optional(),headers:C.record(C.string(),C.string()).optional()}).passthrough(),It=Pt.extend({protocol:Et.optional()}),Lt=C.object({protocol:Et.optional(),name:C.string().optional(),npm:C.string().optional(),api:C.string().optional(),options:Ft.optional(),models:C.record(C.string(),It)}).passthrough(),Rt=C.object({match:C.object({provider:C.string().optional(),protocol:C.enum([`openai`,`openai-compatible`,`anthropic`]).optional(),model:C.string().optional()}),traits:Pt.partial().omit({protocol:!0,upstream_model:!0}).refine(e=>!(`protocol`in e)&&!(`upstream_model`in e),{message:`trait presets must not set protocol or upstream_model (F6/F7)`})}),zt=C.object({enabled:C.boolean().default(!0),max_file_bytes:C.number().int().nonnegative().default(512*1024*1024),sanitize_headers:C.boolean().default(!0),retention_days:C.number().int().nonnegative().default(14)}).optional(),Bt=C.object({model:C.string().optional(),provider:C.record(C.string(),Lt).optional(),enabled_providers:C.array(C.string()).optional(),disabled_providers:C.array(C.string()).optional(),effort:C.string().optional(),effort_templates:C.record(C.string(),Mt).optional(),trait_presets:C.array(Rt).optional(),llm_log:zt}).passthrough(),Vt=C.object({type:C.literal(`api`).default(`api`),key:C.string().refine(e=>e.trim().length>0,{message:`auth entry key must not be empty`})}),Ht=C.record(C.string().min(1),Vt),Ut=Object.freeze({});function Wt(e){return{enabled:e?.enabled!==!1&&process.env.TBOXCODE_LLM_LOG!==`0`&&process.env.TBOXCODE_LLM_LOG!==`false`,max_file_bytes:e?.max_file_bytes??512*1024*1024,sanitize_headers:e?.sanitize_headers!==!1,retention_days:e?.retention_days??14}}function Gt(e){let t=e.indexOf(`/`);if(t===-1)throw new Q(e,`model reference must use provider/model format`);let n=e.slice(0,t),r=e.slice(t+1);if(n.length===0||r.length===0)throw new Q(e,`empty provider or model segment`);return{providerId:n,modelId:r}}function Kt(t,n,r=Ut){let{providerId:i,modelId:a}=Gt(t),o=n.provider?.[i];if(o===void 0)throw new Q(t,`provider not found`);if(n.disabled_providers?.includes(i)===!0)throw new Q(t,`provider disabled`);if(n.enabled_providers!==void 0&&n.enabled_providers.length>0&&!n.enabled_providers.includes(i))throw new Q(t,`provider not enabled`);let s=o.models[a];if(s===void 0)throw new xt(t);let c=s.protocol??o.protocol;if(c===void 0)throw new Q(t,`protocol unresolved`);let l={};for(let e of n.trait_presets??[]){let t=e.match.provider===void 0||new RegExp(e.match.provider).test(i),n=e.match.protocol===void 0||c===e.match.protocol,r=e.match.model===void 0||new RegExp(e.match.model).test(a);t&&n&&r&&(l={...l,...e.traits})}let u={...l,...s,protocol:c},d=Tt(u.reasoning,n.effort_templates,t);d!==void 0&&(u={...u,reasoning:d});let f=e(s.headers),p={...o.options?.headers,...f},m=u.reasoning?.effort;if(m?.levels!==void 0&&m.levels.length>0){let t=typeof n.effort==`string`&&m.levels.some(e=>e.id===n.effort)?n.effort:m.default,r=e(m.levels.find(e=>e.id===t)?.headers);r!==void 0&&(p={...p,...r})}let h={apiKey:r[i]?.key??o.options?.apiKey??``,baseURL:o.options?.baseURL??o.api,headers:p!==void 0&&Object.keys(p).length>0?p:void 0},g=s.provider_name??o.name??i;return{providerId:i,modelId:a,upstream_model:u.upstream_model??a,traits:u,credentials:h,provider_name:g}}function qt(e){let t=e.toLowerCase();return/rate[_ ]?limit/.test(t)||t.includes(`速率限制`)||/too[_ ]?many[_ ]?requests/.test(t)||/quota/.test(t)||/exceeded.*requests/.test(t)||/rate.*increased/.test(t)}function Jt(e){let t=String(e.code??``),n=String(e.type??``);return t===`1302`||t===`429`||t===`insufficient_quota`||n===`too_many_requests`||n===`insufficient_quota`||/rate[_-]?limit/i.test(t)||/exhausted/i.test(t)?!0:qt(String(e.message??``))}function Yt(e){if(typeof e!=`object`||!e)return;let t=e;if(typeof t.retry_after==`number`&&t.retry_after>0)return Math.ceil(t.retry_after);if(typeof t.retry_after_secs==`number`&&t.retry_after_secs>0)return Math.ceil(t.retry_after_secs)}function Xt(e){return async(t,n)=>{let r=await e(t,n);if(r.status!==200||r.body===null||!(r.headers.get(`content-type`)??``).includes(`text/event-stream`))return r;let i=r.body.getReader(),a=new TextDecoder,o=[],s=``;try{for(;;){let{done:e,value:t}=await i.read();if(e)break;o.push(t),s+=a.decode(t,{stream:!0});let n=s.indexOf(`
115
+
116
+ `);if(n===-1)continue;let c=Qt(s.slice(0,n));return c!==null&&Jt(c)?(i.cancel(),$t(c)):Zt(r,o,i)}}catch{return Zt(r,o,i)}return Zt(r,o,i)}}function Zt(e,t,n){let r=!1;return new Response(new ReadableStream({start(e){for(let n of t){if(r)return;try{e.enqueue(n)}catch{return}}(async()=>{try{for(;!r;){let{done:t,value:r}=await n.read();if(t)break;try{e.enqueue(r)}catch{break}}}catch{}try{e.close()}catch{}})()},cancel(){r=!0,n.cancel().catch(()=>{})}}),{status:e.status,statusText:e.statusText,headers:e.headers})}function Qt(e){for(let t of e.split(`
117
+ `)){let e=t.trim();if(e.startsWith(`data:`))try{let t=JSON.parse(e.slice(5).trim());return t.error!==void 0&&typeof t.error==`object`?t.error:t}catch{}}return null}function $t(e){let t=Yt(e)??5,n=typeof e?.message==`string`?e.message:`Rate limit exceeded`;return new Response(JSON.stringify({error:{message:n,type:`rate_limit_error`,code:`rate_limit_exceeded`}}),{status:429,headers:{"content-type":`application/json`,"retry-after":String(t)}})}function en(e){return e.map(e=>e.text??``).filter(e=>e.length>0).join(``)}function tn(e){let t=e.attachment,n=e.type===`image`?`image`:`file`,r=t?.mediaType??`unknown`;return`[${n}${t?.name===void 0?``:` ${t.name}`}: ${r}]`}function nn(e,t){let n=t!==void 0&&t.length>0?[t]:[],r=n.length>0,i=[];for(let t of e){let e=t.content,a=Array.isArray(e)?e:[];switch(t.role){case`system`:{if(r)continue;let e=en(a);e.length>0&&n.push(e);continue}case`developer`:continue;case`user`:{let e=[];for(let t of a){let n=t;if(n.type===`text`){e.push({type:`text`,text:n.text??``});continue}if(n.type!==`reasoning`&&(n.type===`image`||n.type===`file`)){e.push({type:`text`,text:tn(t)});continue}}i.push({role:`user`,content:e});continue}case`assistant`:{let e=[];for(let t of a){let n=t;if(n.type===`text`){(n.text??``).length>0&&e.push({type:`text`,text:n.text});continue}if(n.type===`reasoning`){(n.text??``).length>0&&e.push({type:`reasoning`,text:n.text});continue}if(n.type===`tool-call`){e.push({type:`tool-call`,toolCallId:n.id??``,toolName:n.name??``,input:rn(n.arguments??`{}`)});continue}(n.type===`image`||n.type===`file`)&&e.push({type:`text`,text:tn(t)})}i.push({role:`assistant`,content:e});continue}case`tool`:{let e=t,n=en(e.content);i.push({role:`tool`,content:[{type:`tool-result`,toolCallId:e.toolCallId,output:{type:`text`,value:n},...e.isError===!0?{isError:!0}:{}}]});continue}default:continue}}return{system:n.join(`
118
+
119
+ `),messages:i}}function rn(e){try{return JSON.parse(e)}catch{return{}}}function an(e){if(e===void 0||e.length===0)return;let t={};for(let n of e)t[n.name]=y({description:n.description,inputSchema:_(n.parameters)});return t}function on(e){if(e instanceof Error){let t=(e.lastError??e).statusCode;return{name:e.name,msg:e.message.toLowerCase(),statusCode:typeof t==`number`?t:void 0}}return{name:``,msg:String(e).toLowerCase(),statusCode:void 0}}function sn(e){return e.name===`TypeError`&&e.msg.includes(`terminated`)||e.msg.includes(`econnreset`)||e.msg.includes(`econnrefused`)||e.msg.includes(`socket hang up`)||e.msg.includes(`fetch failed`)||e.msg.includes(`network error`)||e.msg.includes(`other side closed`)||e.msg.includes(`cannot connect to api`)}function cn(e){return e.statusCode===401||e.msg.includes(`unauthorized`)||e.msg.includes(`invalid api key`)}function ln(e){return e.statusCode===429||e.msg.includes(`rate limit`)||e.msg.includes(`rate_limit`)||e.msg.includes(`too many requests`)||qt(e.msg)}function un(e){return e.statusCode!==void 0&&e.statusCode>=500||e.msg.includes(`server error`)||e.msg.includes(`internal server`)}function dn(e){return e.statusCode===400&&(e.msg.includes(`context length`)||e.msg.includes(`context_window`)||e.msg.includes(`maximum context`))}function fn(e){return e.name===`AI_NoOutputGeneratedError`||e.msg.includes(`no output generated`)}function pn(e){return e.msg.includes(`content_filter`)||e.msg.includes(`content policy`)||e.msg.includes(`content filter`)||e.msg.includes(`safety filter`)}const mn=[{match:sn,code:`TRANSPORT`,message:`与 LLM 服务的连接中断(网络异常)`},{match:cn,code:`AUTH`,message:`模型服务鉴权失败,请检查 API Key 配置`},{match:ln,code:`RATE_LIMIT`,message:`触发限流,请稍后重试`},{match:dn,code:`CONTEXT_WINDOW_EXCEEDED`,message:`上下文长度超限`},{match:un,code:`SERVER`,message:`模型服务异常`},{match:fn,code:`EMPTY_RESPONSE`,message:`模型未产生输出`},{match:pn,code:`INVALID_REQUEST`,message:`内容被安全策略拦截`}];function hn(e){return e instanceof DOMException&&e.name===`AbortError`}function gn(e){if(e instanceof d)return e;if(hn(e))return new d(`请求已取消`,`ABORTED`,{cause:e});let t=on(e);for(let n of mn)if(n.match(t))return new d(n.message,n.code,{cause:e instanceof Error?e:void 0});return new d(`LLM 调用失败`,`TRANSPORT`,{cause:e instanceof Error?e:void 0})}const $=e=>e;var _n=class extends u{#e;#t;#n;#r;constructor(e){super(),this.#e=e.config,this.#t=e.auth,this.#n=e.llmLog,this.#r=e.callLogPaths}refresh(e,t,n){this.#e=e,this.#t=t,this.#n=n}get llmLog(){return this.#n}providerInfo(e){return{id:e,name:this.#e.provider?.[e]?.name??e}}listModels(e){let t=this.#e.provider?.[e];if(t===void 0)return Promise.resolve([]);let n=Object.entries(t.models).map(([n,r])=>({provider:e,id:n,name:r.provider_name??t.name??n,inputModalities:[`text`]}));return Promise.resolve(n)}async resolveModel(e,t){let n=this.#i(`${e}/${t}`),r=n.traits.reasoning?.effort;return{provider:e,id:t,name:n.traits.provider_name??t,context:{contextWindow:n.traits.limit.context},defaultMaxTokens:n.traits.limit.output,...r?.levels!==void 0&&r.levels.length>0?{reasoning:{efforts:r.levels.map(e=>({id:$(e.id),name:e.name??e.id})),...r.default===void 0?{}:{defaultEffort:$(r.default)}}}:{}}}async*stream(e){yield*(await this.prepareCall(e.provider,e.model,e.signal)).stream(e)}async prepareCall(e,t,n){let r=this.#i(`${e}/${t}`);return{model:await this.resolveModel(e,t),stream:e=>this.#o(r,e)}}#i(e){return Kt(e,this.#e,this.#t)}async#a(e,i){if(!this.#n.enabled||this.#r===void 0)return;let{root:a,cwdOf:s}=this.#r,c=i.sessionId===void 0?void 0:String(i.sessionId),l=`llmc_${o(8).toString(`hex`)}`,u;if(c!==void 0)try{let e=await s(c);u=e===void 0?r(a):t(a,e,c)}catch{u=r(a)}else u=r(a);let d=i.purpose,f=d===`compaction`?`compact`:d===`session-title`?`title`:`main`,p=n({enabled:!0,max_file_bytes:this.#n.max_file_bytes,sanitize_headers:this.#n.sanitize_headers,logDir:u,sessionId:c??`agentless`,trigger:f,callId:l,traitsVersion:yn(e.traits),provider_name:e.provider_name,modelId:i.model,upstream_model:e.upstream_model,protocol:e.traits.protocol,onError:(e,t)=>console.warn(`[tboxcode-llm] ${e}: ${String(t)}`)},Xt(globalThis.fetch));return{fetch:p.fetch,drain:p.drain,callId:l}}async*#o(e,t){let n=e.traits,r=await this.#a(e,t),i=bt(e,r===void 0?void 0:{fetch:r.fetch,drain:r.drain}),{system:a,messages:o}=t,s=nn(o,a),c=an(t.tools),l={sessionId:t.sessionId??`agentless`,effort:t.reasoningEffort,model:{id:t.model,context:n.limit.context,output:n.limit.output},reasoningEnabled:n.reasoning!==void 0},u=t.purpose!==`compaction`,d=mt(s.messages,n,l,s.system,e.provider_name,{messageBreakpoints:u}),f=d.toolsCacheControl!==null&&d.toolsCacheControlKey!==null&&c!==void 0?Object.fromEntries(Object.entries(c).map(([e,t])=>[e,{...t,providerOptions:{...t.providerOptions,[d.toolsCacheControlKey]:{...t.providerOptions?.[d.toolsCacheControlKey]??{},cacheControl:d.toolsCacheControl}}}])):c,p=i.streamText({model:{id:e.upstream_model,traits:n},system:d.system,messages:d.messages,providerOptions:d.providerOptions,tools:f,signal:t.signal??new AbortController().signal,credentials:e.credentials,maxRetries:2}),m={text:0,reasoning:0,"tool-call":0},h=new Map,g=new Map,_=new Map,v=!1;try{for await(let e of p.fullStream)switch(e.type){case`text-start`:{let t=String(e.id??``);h.set(t,{index:m.text++,buffer:``}),yield{type:`block-start`,index:h.get(t).index,blockType:`text`};break}case`text-delta`:{let t=String(e.id??``),n=h.get(t),r=String(e.text??``);if(n===void 0)break;n.buffer+=r,yield{type:`text-delta`,index:n.index,text:r};break}case`text-end`:{let t=String(e.id??``),n=h.get(t);if(n===void 0)break;h.delete(t),yield{type:`block-end`,index:n.index,block:{type:`text`,text:n.buffer}};break}case`reasoning-start`:{let t=String(e.id??``);g.set(t,{index:m.reasoning++,buffer:``}),yield{type:`block-start`,index:g.get(t).index,blockType:`reasoning`};break}case`reasoning-delta`:{let t=String(e.id??``),n=g.get(t),r=String(e.text??``);if(n===void 0)break;n.buffer+=r,yield{type:`reasoning-delta`,index:n.index,text:r};break}case`reasoning-end`:{let t=String(e.id??``),n=g.get(t);if(n===void 0)break;g.delete(t),yield{type:`block-end`,index:n.index,block:{type:`reasoning`,text:n.buffer}};break}case`tool-input-start`:{let t=String(e.id??``),n=m[`tool-call`]++;_.set(t,{index:n,name:String(e.toolName??``),buffer:``}),yield{type:`block-start`,index:n,blockType:`tool-call`};break}case`tool-input-delta`:{let t=String(e.id??``),n=_.get(t);if(n===void 0)break;let r=String(e.delta??``);n.buffer+=r,yield{type:`tool-call-delta`,index:n.index,id:$(t),name:n.name,argumentsDelta:r};break}case`tool-call`:{let t=String(e.toolCallId??e.id??``),n=_.get(t);if(n===void 0)break;_.delete(t);let r=e.invalid===!0?n.buffer:JSON.stringify(e.input??{});yield{type:`block-end`,index:n.index,block:{type:`tool-call`,id:$(t),name:n.name,arguments:r}};break}case`error`:throw gn(e.error);case`finish`:{let t=e.totalUsage??{},n=t.inputTokenDetails??{};yield{type:`usage`,usage:{inputTokens:Number(t.inputTokens??0),outputTokens:Number(t.outputTokens??0),...Number(n.cacheReadTokens??0)>0?{cacheReadTokens:Number(n.cacheReadTokens)}:{}}},v=!0,yield{type:`finish`,reason:vn(e.finishReason)};break}default:break}v||(yield{type:`usage`,usage:{inputTokens:0,outputTokens:0}},yield{type:`finish`,reason:{kind:`stop`}})}catch(e){throw gn(e)}finally{await i.dispose()}}};function vn(e){switch(e){case`tool-calls`:return{kind:`tool-calls`};case`length`:return{kind:`max-tokens`};case`error`:return{kind:`error`,failure:{message:`stream error`,code:`SERVER`}};case`stop`:case`unknown`:case`other`:case`content-filter`:default:return{kind:`stop`}}}function yn(e){return st(e)}const bn=`tboxcode-llm`,xn=[`llm`];function Sn(e){let t=e.get(`sessionPersistence`),n=t?.config?.root,r=t?.stat;if(!(n===void 0||r===void 0))return{root:n,cwdOf:async e=>(await r.call(t,e))?.header.cwd}}function Cn(e){for(let t of[`auth.jsonc`,`auth.json`]){let n=l(e,t);if(f(n))try{m(n).mode&63&&console.warn(`[tboxcode-llm] auth 文件权限过宽(建议 0600): ${n}`);let e=Z(JSON.parse(Je(p(n,`utf-8`))));return Ht.parse(e)}catch(e){throw new d(`auth 文件解析失败(${n}):${e instanceof Error?e.message:String(e)}`,`INVALID_CREDENTIAL`)}}return{}}function wn(){let e=X(),t=Ye(e).config;return{config:Bt.parse(t),auth:Cn(e)}}function Tn(e){let t=wn(),n=Wt(t.config.llm_log),r=()=>Object.keys(t.config.provider??{}),i,a;i=new _n({config:t.config,auth:t.auth,llmLog:n,callLogPaths:Sn(e)}),a=e.llm.registerAdapter(r(),i);let o=X(),s;try{s=Xe(o,[`config.jsonc`,`config.json`,`auth.jsonc`,`auth.json`],()=>{try{let e=wn();t.config=e.config,t.auth=e.auth;let n=Wt(e.config.llm_log);i?.refresh?.(e.config,e.auth,n),a?.replace(r())}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[tboxcode-llm] 配置热载失败(保留上一代):${t}`)}})}catch{}return()=>{s?.dispose(),a?.()}}export{Tn as apply,xn as inject,bn as name};
@@ -0,0 +1,210 @@
1
+ import { GenerateOptions, LlmAdapter, LlmModelInfo, LlmResolvedModelInfo, StreamChunk } from "@deepseek-ai/dsh-llm";
2
+ import { Context } from "@deepseek-ai/cordis";
3
+
4
+ //#region src/scenario/scripted-adapter.d.ts
5
+ declare const name = "tboxcode-llm-scenario";
6
+ declare const inject: string[];
7
+ /** 行为词表(MOCK_LLM_BEHAVIORS 子集的 adapter 侧语义;字符串形态为速记)。 */
8
+ type BehaviorSpec = 'echo' | 'success' | 'empty' | {
9
+ kind: 'echo';
10
+ } | {
11
+ kind: 'success';
12
+ text?: string;
13
+ } | {
14
+ kind: 'empty';
15
+ }
16
+ /** 长活跃 turn 唯一正解(stall 会被 llm-retry 超时重试消费——spike-hmr 实证)。 */ | {
17
+ kind: 'slow_success';
18
+ chunkDelayMs: number;
19
+ chunks: number;
20
+ text?: string;
21
+ }
22
+ /** 声明式工具调用:发出 tool_call 块后以 tool-calls 收尾(驱动 client 工具循环)。 */ | {
23
+ kind: 'tool_call_success';
24
+ tool: string;
25
+ arguments?: string;
26
+ }
27
+ /** finish error 形态的限流(LlmFailure.rate_limit——经 llm-retry 消费)。 */ | {
28
+ kind: 'rate_limit';
29
+ retryAfterMs?: number;
30
+ }
31
+ /** 流中抛 TRANSPORT 码(经 llm-retry 消费)。 */ | {
32
+ kind: 'connection_reset';
33
+ }
34
+ /** finish max-tokens(截断语义)。 */ | {
35
+ kind: 'max_tokens';
36
+ text?: string;
37
+ };
38
+ type NormalizedBehavior = {
39
+ kind: 'echo';
40
+ } | {
41
+ kind: 'success';
42
+ text?: string;
43
+ } | {
44
+ kind: 'empty';
45
+ } | {
46
+ kind: 'slow_success';
47
+ chunkDelayMs: number;
48
+ chunks: number;
49
+ text?: string;
50
+ } | {
51
+ kind: 'tool_call_success';
52
+ tool: string;
53
+ arguments?: string;
54
+ } | {
55
+ kind: 'rate_limit';
56
+ retryAfterMs?: number;
57
+ } | {
58
+ kind: 'connection_reset';
59
+ } | {
60
+ kind: 'max_tokens';
61
+ text?: string;
62
+ };
63
+ /** 单请求捕获记录(JSONL 一行;messages 原样序列化——branded 字段 JSON 安全)。 */
64
+ interface ScenarioCapture {
65
+ /** 请求序号(适配器级单调递增,跨 session 连续;含辅助调用)。 */
66
+ index: number;
67
+ /** 主对话请求(purpose 空)= true;辅助调用(session-title / compaction)= false。 */
68
+ main: boolean;
69
+ messages: unknown;
70
+ system?: string;
71
+ tools?: unknown;
72
+ model?: string;
73
+ reasoningEffort?: string;
74
+ sessionId?: string;
75
+ purpose?: string;
76
+ /** 行为消耗(对照脚本序号——重试消耗语义的对账锚;辅助调用 = aux:<purpose>)。 */
77
+ behavior: string;
78
+ }
79
+ interface ScenarioDriverConfig {
80
+ /** FIFO 行为脚本(每 stream 消费一条)。 */
81
+ script: BehaviorSpec[];
82
+ /** 捕获 JSONL 落盘路径(缺省不落盘——纯进程内消费场景)。 */
83
+ captureFile?: string;
84
+ /** barrier 目录(缺省不启用 barrier 门)。 */
85
+ barrierDir?: string;
86
+ /** barrier 等待超时 ms(缺省 10s)。 */
87
+ barrierTimeoutMs?: number;
88
+ }
89
+ declare function normalizeBehavior(spec: BehaviorSpec): NormalizedBehavior;
90
+ declare function behaviorLabel(spec: BehaviorSpec): string;
91
+ /** 提取最后一条用户消息的可见文本(跳过 reminder 注入块——回显目标是人类输入)。 */
92
+ declare function lastUserText(messages: GenerateOptions['messages']): string | undefined;
93
+ declare class ScenarioAdapter extends LlmAdapter {
94
+ #private;
95
+ constructor(config: ScenarioDriverConfig);
96
+ /** 已消费行为数(进程内对账面;跨进程断言走 captureFile 的 index/behavior 字段)。 */
97
+ get consumed(): number;
98
+ listModels(provider: string): Promise<readonly LlmModelInfo[]>;
99
+ resolveModel(provider: string, model: string): Promise<LlmResolvedModelInfo>;
100
+ stream(options: GenerateOptions): AsyncIterable<StreamChunk>;
101
+ }
102
+ /** cordis 插件入口:注册 scenario provider 路由;apply 返回 disposer 释放注册。 */
103
+ declare function apply(ctx: Context, config: ScenarioDriverConfig): () => void;
104
+ //#endregion
105
+ //#region src/scenario/interpreter.d.ts
106
+ interface CaptureRecord {
107
+ index: number;
108
+ /** 主对话请求(purpose 空)= true;辅助调用(session-title / compaction)= false。 */
109
+ main?: boolean;
110
+ messages: unknown;
111
+ system?: string;
112
+ tools?: unknown;
113
+ model?: string;
114
+ reasoningEffort?: string;
115
+ sessionId?: string;
116
+ purpose?: string;
117
+ behavior: string;
118
+ }
119
+ /** 解释器 IO 面(L3 harness 实装;单测 stub)。 */
120
+ interface ScenarioIO {
121
+ /** 全量捕获记录(capture JSONL 解析,按 index 序)。 */
122
+ captured(): readonly CaptureRecord[];
123
+ /** wire 事件 type 序列(wireCollector 顺序记录)。 */
124
+ events(): readonly string[];
125
+ /** ACP 侧回显聚合文本(agent_message_chunk text 拼接)。 */
126
+ echoed(): string;
127
+ prompt(text: string): Promise<void>;
128
+ waitTurnEnd(timeoutMs: number): Promise<void>;
129
+ /** configOptions mode 通道(harness 实装 = set_config_option configId='mode')。 */
130
+ setMode(value: string): Promise<void>;
131
+ /** ACP session/cancel 通知(中止在飞 turn)。 */
132
+ cancel(): Promise<void>;
133
+ }
134
+ type AssertionSpec = {
135
+ updateSequence: readonly (string | '*')[];
136
+ } | {
137
+ captureLens: {
138
+ request: number;
139
+ path: string;
140
+ equals?: unknown;
141
+ contains?: string;
142
+ notContains?: string;
143
+ };
144
+ } | {
145
+ snapshotPath: {
146
+ file: string;
147
+ pointer: string;
148
+ equals: unknown;
149
+ };
150
+ } | {
151
+ crossCapture: {
152
+ a: {
153
+ request: number;
154
+ path: string;
155
+ };
156
+ b: {
157
+ request: number;
158
+ path: string;
159
+ };
160
+ op: 'equals' | 'prefix';
161
+ };
162
+ } | {
163
+ echoEquals: string;
164
+ } | {
165
+ negate: AssertionSpec;
166
+ };
167
+ interface AssertionResult {
168
+ pass: boolean;
169
+ detail: string;
170
+ }
171
+ /** 点路径取值:数字段 = 数组索引(负值 = 从末尾反数,-1 = 末元素);对象段 = 键。缺位返回 undefined。 */
172
+ declare function getByPath(root: unknown, path: string): unknown;
173
+ /** 连续子序列匹配:expected 按序且连续出现于 actual;`*` 通配单元素。 */
174
+ declare function matchesSubsequence(actual: readonly string[], expected: readonly (string | '*')[]): boolean;
175
+ declare function evaluateAssertion(spec: AssertionSpec, io: ScenarioIO, snapshotReader?: (file: string, pointer: string) => unknown): AssertionResult;
176
+ type ActionSpec = {
177
+ prompt: string;
178
+ } | {
179
+ waitTurnEnd: number;
180
+ } | {
181
+ pause: number;
182
+ }
183
+ /** configOptions mode 通道(C4 交付:set_config_option configId='mode')。 */ | {
184
+ setMode: string;
185
+ }
186
+ /** ACP session/cancel 通知(中止在飞 turn——llm-retry 的 abort 消费面)。 */ | {
187
+ cancel: true;
188
+ }
189
+ /** 发起 prompt 但不等待完成(cancel 场景的编排原语——流中取消)。 */ | {
190
+ promptNoWait: string;
191
+ };
192
+ interface ScenarioFixture {
193
+ name: string;
194
+ /** 驱动脚本(写入 scenario 行 config——harness 消费)。 */
195
+ script: BehaviorSpec[];
196
+ /** 场景自有 overlay 行(harness 追加 --patch;翻译覆盖 / 行禁用等)。 */
197
+ overlays?: unknown[][];
198
+ /** 场景差异 config 节(harness 拼进场景 config.jsonc——launch 全量翻译消费)。 */
199
+ configExtra?: Record<string, unknown>;
200
+ /** 开启 TBOXCODE_LLM_LOG=1(llm-calls 落盘容忍场景)。 */
201
+ llmLog?: boolean;
202
+ actions: readonly ActionSpec[];
203
+ assertions: readonly AssertionSpec[];
204
+ }
205
+ /** 动作编排执行;返回全部断言求值结果(调用方判定全绿 / 打印失败明细)。 */
206
+ declare function runScenario(fixture: ScenarioFixture, io: ScenarioIO, snapshotReader?: (file: string, pointer: string) => unknown): Promise<AssertionResult[]>;
207
+ /** capture JSONL 读取(harness 的 captured() 实装基元;文件缺位 = 空捕获)。 */
208
+ declare function readCaptureFile(file: string): Promise<CaptureRecord[]>;
209
+ //#endregion
210
+ export { type ActionSpec, type AssertionResult, type AssertionSpec, type BehaviorSpec, type CaptureRecord, type NormalizedBehavior, ScenarioAdapter, type ScenarioCapture, type ScenarioDriverConfig, type ScenarioFixture, type ScenarioIO, apply, behaviorLabel, evaluateAssertion, getByPath, inject, lastUserText, matchesSubsequence, name, normalizeBehavior, readCaptureFile, runScenario };
@@ -0,0 +1,3 @@
1
+ import{appendFile as e,mkdir as t,readFile as n,writeFile as r}from"node:fs/promises";import{join as i}from"node:path";import{LlmAdapter as a,LlmError as o}from"@deepseek-ai/dsh-llm";import{existsSync as s}from"node:fs";const c=`tboxcode-llm-scenario`,l=[`llm`];function u(e){return typeof e==`string`?{kind:e}:e}function d(e){return typeof e==`string`?e:e.kind}function f(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.role!==`user`||!Array.isArray(n.content))continue;let r=n.content.filter(e=>e?.type===`text`&&!e.text.includes(`<system-reminder>`)).map(e=>e.text).join(`
2
+ `).trim();if(r.length>0)return r}}function p(e,t){return e<=0?Promise.resolve():new Promise((n,r)=>{let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(t.reason)},{once:!0})})}async function m(e,n,a){await t(e,{recursive:!0}),await r(i(e,`${n}.wait`),String(Date.now()),`utf-8`);let c=i(e,`${n}.release`),l=Date.now()+a;for(;!s(c);){if(Date.now()>l)throw new o(`scenario barrier ${n} 超时(${a}ms)——release 文件未出现`,`TRANSPORT`);await p(25,void 0)}}var h=class extends a{#e;#t=0;#n=0;constructor(e){super(),this.#e=e}get consumed(){return this.#t}listModels(e){return Promise.resolve([{provider:e,id:`scenario`,name:`Scenario`,description:`scenario driver——声明式行为脚本(场景套件)`,inputModalities:[`text`]}])}async resolveModel(e,t){return{provider:e,id:t,name:t,context:{contextWindow:128e3}}}#r(){if(this.#t>=this.#e.script.length)throw new o(`scenario script 耗尽(已消费 ${this.#t}/${this.#e.script.length})——场景编排不足`,`INVALID_REQUEST`);return u(this.#e.script[this.#t++])}async#i(t,n,r,i=!0){let a={index:this.#n++,main:i,messages:t.messages,system:t.system,tools:t.tools,model:t.model,reasoningEffort:t.reasoningEffort,sessionId:t.sessionId,purpose:t.purpose,behavior:r??n.kind};this.#e.captureFile!==void 0&&await e(this.#e.captureFile,`${JSON.stringify(a)}\n`,`utf-8`)}async#a(e){this.#e.barrierDir!==void 0&&await m(this.#e.barrierDir,e,this.#e.barrierTimeoutMs??1e4)}async*stream(e){if(e.purpose!==void 0){await this.#i(e,{kind:`empty`},`aux:${e.purpose}`,!1),yield*this.#o({kind:`empty`},e);return}let t=this.#r();await this.#i(e,t,void 0,!0),await this.#a(`req-${this.#n-1}`),yield*this.#o(t,e)}async*#o(e,t){switch(e.kind){case`connection_reset`:throw new o(`scenario connection_reset——模拟传输中断`,`TRANSPORT`);case`rate_limit`:yield{type:`finish`,reason:{kind:`error`,failure:{message:`scenario rate_limit——模拟 429`,code:`RATE_LIMIT`,status:429,providerRetryAfterMs:e.retryAfterMs}}};return;case`tool_call_success`:{let t=e.arguments??`{}`;yield{type:`block-start`,index:0,blockType:`tool-call`},yield{type:`tool-call-delta`,index:0,id:`scenario-tool-${e.tool}`,name:e.tool,argumentsDelta:t},yield{type:`block-end`,index:0,block:{type:`tool-call`,id:`scenario-tool-${e.tool}`,name:e.tool,arguments:t}},yield{type:`usage`,usage:{inputTokens:1,outputTokens:1}},yield{type:`finish`,reason:{kind:`tool-calls`}};return}case`empty`:yield{type:`block-start`,index:0,blockType:`text`},yield{type:`block-end`,index:0,block:{type:`text`,text:``}},yield{type:`usage`,usage:{inputTokens:1,outputTokens:0}},yield{type:`finish`,reason:{kind:`stop`}};return;case`slow_success`:case`success`:case`max_tokens`:case`echo`:{let n=e.kind===`echo`?f(t.messages)??`echo`:e.text??f(t.messages)??`scenario`,r=e.kind===`slow_success`?Array.from({length:e.chunks},(e,t)=>n.slice(t,t+1)||`·`):[n];yield{type:`block-start`,index:0,blockType:`text`};for(let n of r)e.kind===`slow_success`&&await p(e.chunkDelayMs,t.signal),yield{type:`text-delta`,index:0,text:n};yield{type:`block-end`,index:0,block:{type:`text`,text:n}},yield{type:`usage`,usage:{inputTokens:1,outputTokens:r.length}},yield{type:`finish`,reason:e.kind===`max_tokens`?{kind:`max-tokens`}:{kind:`stop`}};return}}}};function g(e,t){let n=new h(t),r=e.llm.registerAdapter([`scenario`],n);return()=>{r()}}function _(e,t){let n=e;for(let e of t.split(`.`)){if(n==null)return;let t=Number(e);if(Array.isArray(n)){if(Number.isInteger(t)){let e=t<0?n.length+t:t;if(e<0||e>=n.length)return;n=n[e];continue}return}if(typeof n==`object`)n=n[e];else return}return n}function v(e,t){if(t.length===0)return!0;if(t.length>e.length)return!1;outer:for(let n=0;n<=e.length-t.length;n++){for(let r=0;r<t.length;r++){let i=t[r];if(i!==`*`&&i!==e[n+r])continue outer}return!0}return!1}function y(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length>t.length?!1:e.every((e,n)=>JSON.stringify(e)===JSON.stringify(t[n])):JSON.stringify(e)===JSON.stringify(t)}function b(e,t,n=()=>void 0){if(`negate`in e){let r=b(e.negate,t,n);return{pass:!r.pass,detail:`negate(${r.pass?`通过→取反失败`:`失败→取反通过`}) ${r.detail}`}}if(`updateSequence`in e){let n=t.events();return{pass:v(n,e.updateSequence),detail:`updateSequence ${JSON.stringify(e.updateSequence)} vs [${n.join(`,`)}]`}}if(`captureLens`in e){let n=e.captureLens,r=t.captured(),i=r[n.request<0?r.length+n.request:n.request];if(i===void 0)return{pass:!1,detail:`captureLens 捕获 #${n.request} 不存在(共 ${r.length})`};let a=_(i,n.path);return`equals`in n&&n.equals!==void 0?{pass:JSON.stringify(a)===JSON.stringify(n.equals),detail:`captureLens ${n.path} = ${JSON.stringify(a)}(期望 ${JSON.stringify(n.equals)})`}:`contains`in n&&n.contains!==void 0?{pass:(typeof a==`string`?a:a===void 0?``:JSON.stringify(a)).includes(n.contains),detail:`captureLens ${n.path} contains("${n.contains}")`}:`notContains`in n&&n.notContains!==void 0?{pass:!(typeof a==`string`?a:a===void 0?``:JSON.stringify(a)).includes(n.notContains),detail:`captureLens ${n.path} notContains("${n.notContains}")`}:{pass:!1,detail:`captureLens 缺断言词(equals/contains/notContains 之一)`}}if(`snapshotPath`in e){let t=n(e.snapshotPath.file,e.snapshotPath.pointer);return{pass:JSON.stringify(t)===JSON.stringify(e.snapshotPath.equals),detail:`snapshotPath ${e.snapshotPath.file}#${e.snapshotPath.pointer} = ${JSON.stringify(t)}`}}if(`crossCapture`in e){let n=e.crossCapture,r=_(t.captured()[n.a.request],n.a.path),i=_(t.captured()[n.b.request],n.b.path);return{pass:n.op===`prefix`?y(r,i):JSON.stringify(r)===JSON.stringify(i),detail:`crossCapture ${n.a.request}:${n.a.path} ${n.op} ${n.b.request}:${n.b.path}`}}if(`echoEquals`in e){let n=t.echoed();return{pass:n===e.echoEquals,detail:`echoEquals "${n.slice(0,80)}"(期望 "${e.echoEquals.slice(0,80)}")`}}return{pass:!1,detail:`未知断言组合子`}}async function x(e,t,n=()=>void 0){for(let n of e.actions)`prompt`in n?await t.prompt(n.prompt):`waitTurnEnd`in n?await t.waitTurnEnd(n.waitTurnEnd):`pause`in n?await new Promise(e=>setTimeout(e,n.pause)):`setMode`in n?await t.setMode(n.setMode):`cancel`in n?await t.cancel():`promptNoWait`in n&&t.prompt(n.promptNoWait).catch(()=>{});return e.assertions.map(e=>b(e,t,n))}async function S(e){let t;try{t=await n(e,`utf-8`)}catch{return[]}return t.split(`
3
+ `).filter(e=>e.trim().length>0).map(e=>JSON.parse(e))}export{h as ScenarioAdapter,g as apply,d as behaviorLabel,b as evaluateAssertion,_ as getByPath,l as inject,f as lastUserText,v as matchesSubsequence,c as name,u as normalizeBehavior,S as readCaptureFile,x as runScenario};
package/package.json CHANGED
@@ -1,6 +1,58 @@
1
1
  {
2
2
  "name": "@tbox.cn/tboxcode-dsh-llm",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-rc.1",
4
+ "type": "module",
5
+ "description": "LlmAdapter:三协议 + traits + 限流 + call-log(zstd)+ echo / scenario driver + listModels GUI 硬规格 + adapters-updated 刷新",
6
+ "main": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/index.d.ts",
11
+ "default": "./lib/index.js"
12
+ },
13
+ "./echo": {
14
+ "types": "./lib/echo.d.ts",
15
+ "default": "./lib/echo.js"
16
+ },
17
+ "./call-log": {
18
+ "types": "./lib/call-log.d.ts",
19
+ "default": "./lib/call-log.js"
20
+ },
21
+ "./scenario": {
22
+ "types": "./lib/scenario/index.d.ts",
23
+ "default": "./lib/scenario/index.js"
24
+ }
25
+ },
26
+ "files": [
27
+ "lib"
28
+ ],
29
+ "peerDependencies": {
30
+ "@deepseek-ai/dsh-llm": "0.2.1-rc.2"
31
+ },
32
+ "dependencies": {
33
+ "@ai-sdk/anthropic": "3.0.85",
34
+ "@ai-sdk/openai": "3.0.74",
35
+ "@ai-sdk/openai-compatible": "2.0.51",
36
+ "ai": "6.0.208",
37
+ "zod": "4.6.7"
38
+ },
39
+ "devDependencies": {
40
+ "@deepseek-ai/cordis": "4.0.5",
41
+ "@deepseek-ai/dsh": "0.2.1-rc.2",
42
+ "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
43
+ "@types/ws": "^8.18.0",
44
+ "ws": "^8.19.0",
45
+ "yaml": "^2.8.0",
46
+ "@tbox.cn/tboxcode-dsh-cli": "0.1.0-rc.1",
47
+ "@tbox.cn/tboxcode-dsh-runtime": "0.1.0-rc.1"
48
+ },
49
+ "dsh": {
50
+ "bundle": {
51
+ "patch": []
52
+ }
53
+ },
54
+ "scripts": {
55
+ "build": "tsdown",
56
+ "typecheck": "tsc --noEmit -p tsconfig.json"
57
+ }
6
58
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.