@opencode/console 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/THIRD_PARTY_LICENSES.md +16 -0
- package/chunk-0752rr1w.js +1 -0
- package/chunk-11wqcgnn.js +2 -0
- package/{chunk-c16zjbe1.js → chunk-1z17cm3w.js} +2 -2
- package/chunk-38zs2jre.js +1 -0
- package/chunk-3p7x3f0s.js +1 -0
- package/chunk-5a8bvcgq.js +15 -0
- package/chunk-6fqhbptf.js +1 -0
- package/chunk-6hmr86q5.js +3 -0
- package/chunk-6xs4y82y.js +2 -0
- package/chunk-7qa618ad.js +63 -0
- package/chunk-82p6vmpy.js +1 -0
- package/chunk-9dgq3xc0.js +32 -0
- package/chunk-9zpe1ry1.js +2 -0
- package/chunk-b4fde357.js +2 -0
- package/chunk-b6azftzw.js +254 -0
- package/chunk-bcmj4f7y.js +2 -0
- package/chunk-cd4h496v.js +2 -0
- package/chunk-g9f1r3v3.js +1 -0
- package/chunk-gcqbk8bn.js +149 -0
- package/chunk-ghvsrvdw.js +1 -0
- package/chunk-jpqmm6pm.js +2 -0
- package/chunk-jxh84gfh.js +1 -0
- package/chunk-kd1hjfpe.js +1 -0
- package/{chunk-zdf3mvav.js → chunk-m3m5harb.js} +2 -2
- package/chunk-mnjk01tj.js +1 -0
- package/chunk-nqk8n93s.js +1 -0
- package/chunk-qp7a49b3.js +1 -0
- package/chunk-r1adn0ka.js +11 -0
- package/chunk-tamzaefd.js +1 -0
- package/chunk-x65p26st.js +2 -0
- package/chunk-yb3fn5r1.js +2 -0
- package/{chunk-kdkxhbxc.js → chunk-z5mqjw9r.js} +2 -2
- package/dsh-plugin.js +1 -0
- package/index.js +59 -47
- package/package.json +3 -2
- package/pi-extension.js +2 -2
- package/chunk-03p95nje.js +0 -6
- package/chunk-2ktsq2gj.js +0 -3
- package/chunk-2y9vn023.js +0 -1
- package/chunk-5q7mrvv1.js +0 -2
- package/chunk-5w6hy202.js +0 -1
- package/chunk-6mydq7cv.js +0 -2
- package/chunk-6rpbc10h.js +0 -2
- package/chunk-81fv1abj.js +0 -2
- package/chunk-aym5xapq.js +0 -1
- package/chunk-bkr0zk6g.js +0 -32
- package/chunk-c9kvdzct.js +0 -1
- package/chunk-eyf3z07t.js +0 -1
- package/chunk-frqdgjbd.js +0 -17
- package/chunk-fzckrdm3.js +0 -2
- package/chunk-hpy9mszv.js +0 -1
- package/chunk-jh21wbwd.js +0 -2
- package/chunk-kvqewrn5.js +0 -1
- package/chunk-mpmqsnkz.js +0 -1
- package/chunk-mzpdnb17.js +0 -1
- package/chunk-nvh2a5rc.js +0 -254
- package/chunk-p59r4b0j.js +0 -2
- package/chunk-p7wsm5k0.js +0 -1
- package/chunk-sn451nak.js +0 -2
- package/chunk-vqmbpbbm.js +0 -1
- package/chunk-wjghq897.js +0 -63
- package/chunk-xeq3evq0.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_t}from"./chunk-jpqmm6pm.js";import{Ce,J,Se,K,Rt}from"./chunk-6xs4y82y.js";import{ke,be}from"./chunk-x65p26st.js";import{Ot}from"./chunk-yb3fn5r1.js";import{Be}from"./chunk-cd4h496v.js";import{ur,St,vt,pr,jn,Xe,fn,_,Et,dn,mn,Tt,dr}from"./chunk-gcqbk8bn.js";import{ue}from"./chunk-9zpe1ry1.js";import{k,rt,j,I,On,W,b,B,e,v,n,x,Z}from"./chunk-9dgq3xc0.js";var ns={};k(ns,{Pi:()=>ns,Unreadable:()=>Xr,checks:()=>Zo,defaultModel:()=>Vo,directory:()=>Un,manifest:()=>Xo,manifestFile:()=>eo,models:()=>es,modelsFile:()=>to,paths:()=>ya,providers:()=>Go,remove:()=>Sa,setup:()=>ba,skillCommand:()=>Qo,skills:()=>ts,userBash:()=>Yo});import{createHash as A}from"node:crypto";import{rmSync as R}from"node:fs";import P from"node:os";import u from"node:path";import{fileURLToPath as U}from"node:url";function ya(t=process.env,r=P.homedir()){let o=t.PI_CODING_AGENT_DIR?.trim(),s=o?u.resolve(o==="~"?r:o.startsWith("~/")?u.join(r,o.slice(2)):o):u.join(r,".pi","agent");return{agent:s,settings:u.join(s,"settings.json")}}function Go(t,r){return[...Map.groupBy(Tt(t).flatMap((s)=>E(s,r)??[]),(s)=>s.provider)].map(([s,i])=>({id:s,name:t[s]?.name??s,models:i}))}function Vo(t){let r=Tt(t).filter((s)=>M(s)!==void 0),o=dr(r,"sonnet","opus","haiku");return o&&{provider:o.provider,id:o.id}}var S={messages:"anthropic-messages",responses:"openai-responses","chat-completions":"openai-completions","generate-content":"google-generative-ai"};function M(t){let r=_(t.entry.api),o=Object.keys(S).find((i)=>(i in r)),s=o&&Et(_(r[o]).base_url);return o&&s?{api:S[o],baseURL:s}:void 0}function E(t,r){let o=M(t);if(!o)return;let s=o.api,i=r(t.provider,t.id,s),c=i?.api===s?i:void 0,d=t.entry,p=_(d.limit),a=_(_(d.cost).text),l=_(a.input),m=_(l.cache),h=_(d.modalities).input,y=_(_(d.capabilities).reasoning).supported;return{...s==="openai-completions"?{compat:D}:{},...c,id:t.id,name:Et(d.name)??c?.name??t.id,api:s,provider:t.provider,baseUrl:s==="anthropic-messages"?o.baseURL.replace(/\/v1\/?$/,""):o.baseURL,reasoning:typeof y==="boolean"?y:c?.reasoning??!1,input:Array.isArray(h)?h.some((w)=>typeof w==="string"&&w.startsWith("image"))?["text","image"]:["text"]:c?.input??["text"],cost:{input:f(l.price)??c?.cost.input??0,output:f(_(a.output).price)??c?.cost.output??0,cacheRead:f(m.read)??c?.cost.cacheRead??0,cacheWrite:f(C(m.write))??f(C(_(m.explicit).write))??c?.cost.cacheWrite??0},contextWindow:f(p.context)??c?.contextWindow??128000,maxTokens:f(p.output)??c?.maxTokens??16384,headers:{...c?.headers,"x-opencode-plugin":`opencode-console/${ue}`}}}var D={supportsStore:!1,supportsDeveloperRole:!1,supportsStrictMode:!0,maxTokensField:"max_tokens"};function C(t){return typeof t==="object"&&t!==null?Object.values(t)[0]:t}function f(t){return typeof t==="number"&&Number.isFinite(t)?t:void 0}class Xr extends Error{}function Zo(t,r){let o=(a,l,m={})=>({action:a,resources:l,directory:r.cwd,...m}),s=t.toolName,i=(a)=>{let l=t.input[a];return typeof l==="string"&&l!==""?l:void 0},c=(a)=>{let l=i(a);if(l===void 0)throw new Xr(`${s}'s input has no ${a}`);return l},d=r.home??P.homedir(),p=(a)=>g(c(a),d);if(s.startsWith("mcp__"))return F(s,r.server).map((a)=>o(a.action,a.resources,a));switch(s){case"bash":return[o("shell",[c("command")],{shell:"bash"})];case"powershell":return[o("shell",[c("command")],{shell:"pwsh"})];case"read":{let a=p("path"),l=r.skills&&N(r.skills,u.resolve(r.cwd,a));return[l?o("skill",[l]):o("read",[a])]}case"write":case"edit":return[o("edit",[p("path")])];case"ls":return[o("read",[g(i("path")??".",d)])];case"grep":case"find":{let a=i("path");return[o(s==="find"?"glob":"grep",[c("pattern")],a===void 0?{}:{path:g(a,d)})]}case"read_mcp_resource":return[o("mcp.use",[c("server")])];case"list_mcp_resources":case"list_mcp_resource_templates":{let a=i("server"),l=r.servers??[];return[o("mcp.use",a?[a]:l.length>0?l:["*"])]}default:return[o(s.toLowerCase(),["*"])]}}function g(t,r){let o=t.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g," "),s=o.startsWith("@")?o.slice(1):o,i=s==="~"?r:s.startsWith("~/")?u.join(r,s.slice(2)):s;return i.startsWith("file://")?U(i):i}function N(t,r){let o=u.relative(u.resolve(t),r);if(o===""||o.startsWith("..")||u.isAbsolute(o))return;return o.split(u.sep)[0]}function F(t,r){let o=r&&`mcp__${r.replace(/[^A-Za-z0-9_]/g,"_")}__`,s=t.match(/^mcp__(.+?)__(.+)$/),i=r??s?.[1];if(!i)throw new Xr(`Can't tell which MCP server ${t} belongs to`);let c=o&&t.startsWith(o)?t.slice(o.length):r?void 0:s?.[2],d=r!==void 0,p=c===void 0||/_[0-9a-f]{8}$/.test(t);return[{action:"mcp.use",resources:[i],...d?{}:{folded:!0}},p?{action:`${i}_`,resources:["*"],truncated:!0,folded:!0}:{action:`${i}_${c}`,resources:["*"],folded:!0}]}function Yo(t){return{action:"shell",resources:[t.command],directory:t.cwd,shell:"bash"}}function Qo(t){return t.match(/^\/skill:([^\s]+)/)?.[1]}var O=n({paths:n({agent:e,settings:e}),extension:e,created:v,...ur}),eo=(t)=>u.join(t.data,"pi.json"),Un=(t)=>u.join(t.data,"pi"),to=(t)=>u.join(t.cache,"pi-models.json");function Xo(t){let r=eo(t),o=J(r);if(o===void 0)return;let s=j(W(Z(O))(o));if(!s)throw Error(`${r} can't be read, so Pi was left as it is. Delete it and run setup again.`);return s}function ba(t,r){let o=Xo(t),s=o?.created??J(r.paths.settings)===void 0,i=St(r.paths.settings)??{};if(!o)fn(r.paths.settings);let c=Array.isArray(i.extensions)?i.extensions:[];i.extensions=[...c.filter((p)=>p!==o?.extension&&p!==r.extension),r.extension];let d=pr(i,r.model?{defaultProvider:r.model.provider,defaultModel:r.model.id}:{},o,!0);vt(r.paths.settings,i,384),Se(eo(t),JSON.stringify(O.make({paths:r.paths,extension:r.extension,created:s,...d})))}function Sa(t){let r=Xo(t);if(!r)return!1;let o=St(r.paths.settings);if(o){let i=(Array.isArray(o.extensions)?o.extensions:[]).filter((c)=>c!==r.extension);if(i.length>0)o.extensions=i;else delete o.extensions;if(Object.keys(r.originals).forEach((c)=>jn(o,c,r)),Object.keys(o).length===0&&r.created)K(r.paths.settings);else vt(r.paths.settings,o)}return K(Xe(r.paths.settings)),R(Un(t),{recursive:!0,force:!0}),K(to(t)),K(eo(t)),!0}var L=n({owner:e,providers:e,document:x(e,B)}),T=x(e,n({name:b(e),models:x(e,x(e,B))}));async function es(t){let r=ke(t.store),o=await Be(t);if(!r||!o?.config)return;let s=be(r),i=A("sha256").update(JSON.stringify(o.config.providers??null)).digest("hex"),c=j(W(Z(L))(J(to(t.store))??"")),d=c?.owner===s&&c.providers===i?c.document:void 0,p=d&&j(W(T)(d));if(p)return p;let a=await t.run(_t(r));return Se(to(t.store),JSON.stringify({owner:s,providers:i,document:a})),a}var G=x(e,e);async function ts(t){let r=ke(t.store),o=await Be(t),s=u.join(Un(t.store),"skills"),i=u.join(Un(t.store),"skills.json");if(!r||!o?.config)return s;let c=Ot(o),d=rt(W(Z(G))(J(i)??""),()=>({})),p=await t.run(dn(r,s,c,d));return await On(Ce(t.store,I(()=>{Rt(s),Se(i,JSON.stringify(mn(s,c,p,d).skills))}))),s}
|
|
2
|
+
export{ya,Go,Vo,Xr,Zo,Yo,Qo,eo,Un,to,Xo,ba,Sa,es,ts,ns};
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import"./chunk-m3m5harb.js";import"./chunk-qp7a49b3.js";import{_t,uo,_s}from"./chunk-jpqmm6pm.js";import{Ce,J,Se,K}from"./chunk-6xs4y82y.js";import{be,He}from"./chunk-x65p26st.js";import{ur,St,vt,pr,jn,Xe,fn,wt,_,fr,dn,mn,Tt,mr}from"./chunk-gcqbk8bn.js";import"./chunk-11wqcgnn.js";import{cr,fs,so}from"./chunk-7qa618ad.js";import{gr,lt,Ot,et}from"./chunk-yb3fn5r1.js";import{qe}from"./chunk-bcmj4f7y.js";import{lr}from"./chunk-5a8bvcgq.js";import{ue}from"./chunk-9zpe1ry1.js";import{k,j,pt,Ae,I,h,R,W,b,e,V,v,n,x,l,Ze,Z}from"./chunk-9dgq3xc0.js";var me={};k(me,{Codex:()=>me,PROVIDER:()=>Q,hookArgs:()=>ce,manifest:()=>ne,manifestFile:()=>ee,models:()=>Re,paths:()=>kn,refresh:()=>wn,remove:()=>An,rules:()=>Le,trustHash:()=>Je});import{createHash as xe}from"node:crypto";import{existsSync as pe,realpathSync as hn,rmSync as gn}from"node:fs";import yn from"node:os";import S from"node:path";/*!
|
|
2
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
3
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4
|
+
*
|
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
|
6
|
+
* modification, are permitted provided that the following conditions are met:
|
|
7
|
+
*
|
|
8
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
* list of conditions and the following disclaimer.
|
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
* this list of conditions and the following disclaimer in the
|
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
|
13
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
14
|
+
* may be used to endorse or promote products derived from this software without
|
|
15
|
+
* specific prior written permission.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
18
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
21
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
22
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
24
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
25
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
26
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
*/function Ve(r,t){let o=r.slice(0,t).split(/\r?\n/);return[o.length,o.pop().length+1]}function Ke(r,t,o){let s=r.split(/\r?\n/),f="",a=(Math.log10(t+1)|0)+1;for(let i=t-1;i<=t+1;i++){let u=s[i-1];if(!u)continue;if(f+=i.toString().padEnd(a," "),f+=": ",f+=u,f+=`
|
|
28
|
+
`,i===t)f+=" ".repeat(a+o+2),f+=`^
|
|
29
|
+
`}return f}class m extends Error{line;column;codeblock;constructor(r,t){let[o,s]=Ve(t.toml,t.ptr),f=Ke(t.toml,o,s);super(`Invalid TOML document: ${r}
|
|
30
|
+
|
|
31
|
+
${f}`,t);this.line=o,this.column=s,this.codeblock=f}static x(r,t,o){throw new m(r,{toml:t.s,ptr:o??t.p})}}/*!
|
|
32
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
33
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
34
|
+
*
|
|
35
|
+
* Redistribution and use in source and binary forms, with or without
|
|
36
|
+
* modification, are permitted provided that the following conditions are met:
|
|
37
|
+
*
|
|
38
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
39
|
+
* list of conditions and the following disclaimer.
|
|
40
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
41
|
+
* this list of conditions and the following disclaimer in the
|
|
42
|
+
* documentation and/or other materials provided with the distribution.
|
|
43
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
44
|
+
* may be used to endorse or promote products derived from this software without
|
|
45
|
+
* specific prior written permission.
|
|
46
|
+
*
|
|
47
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
48
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
49
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
50
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
51
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
52
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
53
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
54
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
55
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
56
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
57
|
+
*/function B(r){let t=r.p,o=r.s.charCodeAt(r.p++),s=o,f=o===39,a=o===r.s.charCodeAt(r.p)&&o===r.s.charCodeAt(r.p+1);if(a){if((o=r.s.charCodeAt(r.p+=2))===10)r.p++;else if(o===13&&r.s.charCodeAt(r.p+1)===10)r.p+=2}let i="",u=r.p,c=0;for(;r.p<r.s.length;r.p++)if(o=r.s.charCodeAt(r.p),a&&(o===10||o===13&&r.s.charCodeAt(r.p+1)===10))c=c&&3;else if(o<32&&o!==9||o===127)m.x("control characters are not allowed in strings",r);else if((!c||c===3)&&o===s&&(!a||r.s.charCodeAt(r.p+1)===s&&r.s.charCodeAt(r.p+2)===s)){if(a){if(r.s.charCodeAt(r.p+3)===s)r.p++;if(r.s.charCodeAt(r.p+3)===s)r.p++}if(!c){let p=r.s.slice(u,r.p);i=i?i+p:p}return r.p+=a?3:1,i}else if(!c){if(!f&&o===92)i+=r.s.slice(u,u=r.p),c=1}else if(c===1)if(o===120||o===117||o===85){let p=r.p++-1,g=0,y=o===120?2:o===117?4:8;for(let O=0;O<y;O++,r.p++){let w=r.s.charCodeAt(r.p),A=w>=48&&w<=57?w-48:w>=65&&w<=70?w-65+10:w>=97&&w<=102?w-97+10:-1;if(A<0)m.x("invalid non-hex character in unicode escape",r);g=g<<4|A}if(g<0||g>1114111||g>=55296&&g<=57343)m.x("invalid unicode escape",r,p);i+=String.fromCodePoint(g),u=r.p--,c=0}else if(a&&(o===32||o===9))c=2;else{if(o===98)i+="\b";else if(o===116)i+="\t";else if(o===110)i+=`
|
|
58
|
+
`;else if(o===102)i+="\f";else if(o===114)i+="\r";else if(o===101)i+="\x1B";else if(o===34)i+='"';else if(o===92)i+="\\";else m.x("unrecognised escape sequence",r);u=r.p+1,c=0}else if(o!==32&&o!==9){if(c===2)m.x("invalid escape: only line-ending whitespace may be escaped",r,u);c=!f&&o===92?1:0,u=r.p}m.x("unfinished string",r,t)}/*!
|
|
59
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
60
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
61
|
+
*
|
|
62
|
+
* Redistribution and use in source and binary forms, with or without
|
|
63
|
+
* modification, are permitted provided that the following conditions are met:
|
|
64
|
+
*
|
|
65
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
66
|
+
* list of conditions and the following disclaimer.
|
|
67
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
68
|
+
* this list of conditions and the following disclaimer in the
|
|
69
|
+
* documentation and/or other materials provided with the distribution.
|
|
70
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
71
|
+
* may be used to endorse or promote products derived from this software without
|
|
72
|
+
* specific prior written permission.
|
|
73
|
+
*
|
|
74
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
75
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
76
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
77
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
78
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
79
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
80
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
81
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
82
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
83
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
84
|
+
*/var Ge=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;class E extends Date{#n=!1;#r=!1;#e=null;constructor(r,t,o){let s=!0,f=!0,a="Z",i;if(typeof r==="string")if(t)e:{if(t<3){if(+r.slice(11,13)>23){r="";break e}if(t===2)a=null,r+="Z";else if((i=r.charCodeAt(r.length-1))!==90&&i!==122)a=r.slice(r.length-6);if(o)r=r.slice(0,10)+"T"+r.slice(11)}else if(t===4)r=+r.slice(0,2)>23?"":`0000-01-01T${r}Z`;s=t!==4,f=t!==3}else{let u=r.match(Ge);if(u){if(!u[1])s=!1,r=`0000-01-01T${r}`;if(f=!!u[2],f&&r[10]===" "&&(r=r.replace(" ","T")),u[2]&&+u[2]>23)r="";else if(a=u[3]||null,!a&&f)r+="Z"}else r=""}super(r);if(!isNaN(this.getTime()))this.#n=s,this.#r=f,this.#e=a}isDateTime(){return this.#n&&this.#r}isLocal(){return!this.#n||!this.#r||!this.#e}isDate(){return this.#n&&!this.#r}isTime(){return this.#r&&!this.#n}isValid(){return this.#n||this.#r}toISOString(){let r=super.toISOString();if(this.isDate())return r.slice(0,10);if(this.isTime())return r.slice(11,23);if(this.#e===null)return r.slice(0,-1);if(this.#e==="Z"||this.#e==="z")return r;let t=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return t=this.#e[0]==="-"?t:-t,new Date(this.getTime()-t*60000).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(r,t="Z"){let o=new E(r);return o.#e=t,o}static wrapAsLocalDateTime(r){let t=new E(r);return t.#e=null,t}static wrapAsLocalDate(r){let t=new E(r);return t.#r=!1,t.#e=null,t}static wrapAsLocalTime(r){let t=new E(r);return t.#n=!1,t.#e=null,t}}/*!
|
|
85
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
86
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
87
|
+
*
|
|
88
|
+
* Redistribution and use in source and binary forms, with or without
|
|
89
|
+
* modification, are permitted provided that the following conditions are met:
|
|
90
|
+
*
|
|
91
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
92
|
+
* list of conditions and the following disclaimer.
|
|
93
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
94
|
+
* this list of conditions and the following disclaimer in the
|
|
95
|
+
* documentation and/or other materials provided with the distribution.
|
|
96
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
97
|
+
* may be used to endorse or promote products derived from this software without
|
|
98
|
+
* specific prior written permission.
|
|
99
|
+
*
|
|
100
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
101
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
102
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
103
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
104
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
105
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
106
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
107
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
108
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
109
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
110
|
+
*/function C(r,t=10){return t===16?r>47&&r<58||r>64&&r<71||r>96&&r<103:r>47&&r<48+t}function le(r,t){return r===32||r===9||r===10||r===13||t&&(r===t||r===44)||r===35}function U(r,t){let o=r.p,s=r.s.charCodeAt(r.p);if(s===91||s===123){r.d--||m.x("document contains excessively nested structures. aborting.",r);let f=s===91?ve(r):Oe(r);return r.d++,f}if(s===34||s===39)return B(r);if(s===116){if(r.s.charCodeAt(++r.p)!==114||r.s.charCodeAt(++r.p)!==117||r.s.charCodeAt(++r.p)!==101)m.x("invalid value",r,o);return r.p++,!0}if(s===102){if(r.s.charCodeAt(++r.p)!==97||r.s.charCodeAt(++r.p)!==108||r.s.charCodeAt(++r.p)!==115||r.s.charCodeAt(++r.p)!==101)m.x("invalid value",r,o);return r.p++,!1}if(s===43||s===45)return G(r,r.p,r.s.charCodeAt(++r.p),44-s,t);if(r.s.charCodeAt(r.p+4)===45&&r.s.charCodeAt(r.p+7)===45)return Ye(r,s,t);if(r.s.charCodeAt(r.p+2)===58)return Qe(r,s,t);return G(r,r.p,s,0,t)}function G(r,t,o,s,f){let a=o,i=0,u=!1;if(a===105){if(r.s.charCodeAt(++r.p)!==110||r.s.charCodeAt(++r.p)!==102)m.x("invalid value",r,t);return r.p++,(s||1)/0}if(a===110){if(r.s.charCodeAt(++r.p)!==97||r.s.charCodeAt(++r.p)!==110)m.x("invalid value",r,t);return r.p++,NaN}if(a===48){if(++r.p>=r.s.length||le(a=r.s.charCodeAt(r.p),f))return r.bi===!0?0n:0;if(!s){if(a===120)return ae(r,t,16,f);else if(a===98)return ae(r,t,2,f);else if(a===111)return ae(r,t,8,f)}if(a===46)i=2;else if(a===101||a===69)i=4;else m.x("illegal leading zero",r,t)}else if(!C(a))m.x("invalid value",r,t);while(++r.p<r.s.length&&(a=r.s.charCodeAt(r.p),!le(a,f))){if(!i)i=1;if(a===95){if(!(i&1))m.x("illegal underscore",r);i+=11,u=!0}else if(i===1&&a===46)i=2;else if((i===1||i===3)&&(a===101||a===69))i=4;else if(i===4&&(a===43||a===45))i=6;else if(!C(a))m.x("illegal character in numeric literal",r);else if(i>9)i-=11;else if(!(i&1))i++}if(!i){let p=(o-48)*(s||1);return r.bi===!0?BigInt(p):p}if(!(i&1))m.x("unfinished numeric value",r,t);let c=r.s.slice(t,r.p);if(u)c=c.replaceAll("_","");return i>1?parseFloat(c):Te(r,c,10,t)}function ae(r,t,o,s){let f,a=1;while(++r.p<r.s.length&&(f=r.s.charCodeAt(r.p),!le(f,s)))if(f===95){if(a&1)m.x("illegal underscore",r);a=3}else if(!C(f,o))m.x("illegal character in numeric literal",r);else if(a&1)a--;if(a&1)m.x("unfinished numeric value",r);let i=r.s.slice(t+2,r.p);if(a)i=i.replaceAll("_","");return Te(r,i,o,t)}function Te(r,t,o,s){if(r.bi!==!0)e:{let f=parseInt(t,o);if(!Number.isSafeInteger(f)){if(r.bi)break e;m.x("integer value cannot be represented losslessly",r,s)}return f}return o===10?BigInt(t):BigInt((o===2?"0b":o===8?"0o":"0x")+t)}function Ye(r,t,o){let s=r.p++,f;if(!C(t)||!C(r.s.charCodeAt(r.p++))||!C(r.s.charCodeAt(r.p++))||!C(r.s.charCodeAt(r.p++)))return G(r,r.p=s,t,0,o);if(r.p+=5,!C(r.s.charCodeAt(r.p++)))m.x("invalid date-time: date part is malformed",r,s);if(r.p>=r.s.length||((t=r.s.charCodeAt(r.p))!==32||(f=!0,!C(r.s.charCodeAt(r.p+1))))&&t!==84&&t!==116){let i=r.s.slice(s,r.p);return P(r,i,3,!1,s)}if(r.s.charCodeAt(r.p+=3)!==58)m.x("invalid date-time: time part is malformed",r,s);if(r.s.charCodeAt(r.p+=3)===58)r.p+=3;if(r.s.charCodeAt(r.p)===46)while(C(r.s.charCodeAt(++r.p)));if(t=r.s.charCodeAt(r.p)){if(t===90||t===122){let i=r.s.slice(s,++r.p);return P(r,i,1,f,s,"[+00:00]")}if(t===43||t===45){let i=r.s.slice(s,r.p+=6);return P(r,i,1,f,s,!r.ld&&"["+r.s.slice(r.p-6,r.p)+"]")}}let a=r.s.slice(s,r.p);return P(r,a,2,f,s)}function Qe(r,t,o){let s=r.p;if(!C(t)||!C(r.s.charCodeAt(++r.p)))return G(r,--r.p,t,0,o);if(r.s.charCodeAt(r.p+=4)===58)r.p+=3;if(r.s.charCodeAt(r.p)===46)while(C(r.s.charCodeAt(++r.p)));let f=r.s.slice(s,r.p);return P(r,f,4,!1,s)}function P(r,t,o,s,f,a){if(r.ld){let i=new E(t,o,s);if(!i.isValid())m.x("invalid date",r,f);return i}try{if(a)t+=a;switch(o){case 1:return Temporal.ZonedDateTime.from(t);case 2:return Temporal.PlainDateTime.from(t);case 3:return Temporal.PlainDate.from(t);case 4:return Temporal.PlainTime.from(t)}}catch(i){m.x(i instanceof Error?i.message:""+i,r,f)}}/*!
|
|
111
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
112
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
113
|
+
*
|
|
114
|
+
* Redistribution and use in source and binary forms, with or without
|
|
115
|
+
* modification, are permitted provided that the following conditions are met:
|
|
116
|
+
*
|
|
117
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
118
|
+
* list of conditions and the following disclaimer.
|
|
119
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
120
|
+
* this list of conditions and the following disclaimer in the
|
|
121
|
+
* documentation and/or other materials provided with the distribution.
|
|
122
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
123
|
+
* may be used to endorse or promote products derived from this software without
|
|
124
|
+
* specific prior written permission.
|
|
125
|
+
*
|
|
126
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
127
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
128
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
129
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
130
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
131
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
132
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
133
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
134
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
135
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
136
|
+
*/function en(r){for(;r.p<r.s.length;r.p++){let t=r.s.charCodeAt(r.p);if(t===10)break;if(t===13&&r.s.charCodeAt(r.p+1)===10){r.p++;break}if(t<32&&t!==9||t===127)m.x("control characters are not allowed in comments",r)}}function T(r,t,o){let s;while(r.p<r.s.length){while(r.p<r.s.length&&((s=r.s.charCodeAt(r.p))===32||s===9||!t&&(s===10||s===13&&r.s.charCodeAt(r.p+1)===10)))r.p++;if(o||s!==35)break;en(r)}}/*!
|
|
137
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
138
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
139
|
+
*
|
|
140
|
+
* Redistribution and use in source and binary forms, with or without
|
|
141
|
+
* modification, are permitted provided that the following conditions are met:
|
|
142
|
+
*
|
|
143
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
144
|
+
* list of conditions and the following disclaimer.
|
|
145
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
146
|
+
* this list of conditions and the following disclaimer in the
|
|
147
|
+
* documentation and/or other materials provided with the distribution.
|
|
148
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
149
|
+
* may be used to endorse or promote products derived from this software without
|
|
150
|
+
* specific prior written permission.
|
|
151
|
+
*
|
|
152
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
153
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
154
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
155
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
156
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
157
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
158
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
159
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
160
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
161
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
162
|
+
*/function H(r,t=61){let o,s=0,f=[],a,i=r.s.charCodeAt(o=r.p);do if(i===t){if(!s)m.x("unexpected end of key",r);if(s===1)f.push(r.s.slice(a,r.p));return r.p++,f}else if(i===46){if(!s)m.x("illegal empty bare key",r);if(s===1)f.push(r.s.slice(a,r.p));s=0}else if(!s&&(i===34||i===39)){if(i===r.s.charCodeAt(r.p+1)&&i===r.s.charCodeAt(r.p+2))m.x("illegal quoted key: multiline strings are not allowed",r);f.push(B(r)),s=2,r.p--}else if(i===32||i===9){if(s===1)f.push(r.s.slice(a,r.p)),s=2}else if(s===2||i<48&&i!==45||i>57&&i<65||i>90&&i<97&&i!==95||i>122)m.x("illegal character in key",r);else if(!s)s=1,a=r.p;while(i=r.s.charCodeAt(++r.p));m.x("incomplete key-value: cannot find end of key",r,o)}function Oe(r){let t=r.p++,o=Object.create(null),s=new Set,f;while(r.p<r.s.length){if(T(r),(f=r.s.charCodeAt(r.p))===125)return r.p++,o;let a,i=o,u=!1,c=r.p,p=H(r);for(let y=0;y<p.length;y++){if(y)i=u?i[a]:i[a]=Object.create(null);if(a=p[y],(u=Object.hasOwn(i,a))&&(typeof i[a]!=="object"||s.has(i[a])))m.x("trying to redefine an already defined value",r,c);let O=a==="__proto__";if(r.uk&&(O||a==="constructor")){i=r.uk!==1&&m.x("document contains an unsafe property",r,c);break}if(!u&&O)Object.defineProperty(i,a,{enumerable:!0,configurable:!0,writable:!0})}if(u)m.x("trying to redefine an already defined value",r,c);T(r,!0,!0);let g=U(r,125);if(i&&typeof(i[a]=g)==="object")s.add(g);if(T(r),(f=r.s.charCodeAt(r.p++))===125)return o;if(f!==44)m.x("expected comma or end of structure",r,r.p-1)}m.x("unfinished table",r,t)}function ve(r){let t=r.p++,o=[],s;while(r.p<r.s.length){if(T(r),(s=r.s.charCodeAt(r.p))===93)return r.p++,o;if(o.push(U(r,93)),T(r),(s=r.s.charCodeAt(r.p++))===93)return o;if(s!==44)m.x("expected comma or end of structure",r,r.p-1)}m.x("unfinished array",r,t)}/*!
|
|
163
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
164
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
165
|
+
*
|
|
166
|
+
* Redistribution and use in source and binary forms, with or without
|
|
167
|
+
* modification, are permitted provided that the following conditions are met:
|
|
168
|
+
*
|
|
169
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
170
|
+
* list of conditions and the following disclaimer.
|
|
171
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
172
|
+
* this list of conditions and the following disclaimer in the
|
|
173
|
+
* documentation and/or other materials provided with the distribution.
|
|
174
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
175
|
+
* may be used to endorse or promote products derived from this software without
|
|
176
|
+
* specific prior written permission.
|
|
177
|
+
*
|
|
178
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
179
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
180
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
181
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
182
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
183
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
184
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
185
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
186
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
187
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
188
|
+
*/function $e(r,t,o,s,f){let a=o,i=s,u,c=!1,p;for(let g=0;g<t.length;g++){if(g){if(a=c?a[u]:a[u]=Object.create(null),i=(p=i[u]).c,f===0&&(p.t===1||p.t===2))return null;if(p.t===2){let y=a.length-1;a=a[y],i=i[y].c}}if(u=t[g],(c=Object.hasOwn(a,u))&&i[u]?.t===0&&i[u]?.d)return null;if(!c){let y=u==="__proto__";if(r.uk&&(y||u==="constructor"))return!1;if(y)Object.defineProperty(a,u,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(i,u,{enumerable:!0,configurable:!0,writable:!0});i[u]={t:g<t.length-1&&f===2?3:f,d:!1,i:0,c:Object.create(null)}}}if(p=i[u],p.t!==f&&!(f===1&&p.t===3))return null;if(f===2){if(!p.d)p.d=!0,a[u]=[];a[u].push(a=Object.create(null)),p.c[p.i++]=p={t:1,d:!1,i:0,c:Object.create(null)}}if(p.d)return null;if(p.d=!0,f===1)a=c?a[u]:a[u]=Object.create(null);else if(f===0&&c)return null;return[u,a,p.c]}function je(r,t,o){if(t===null||r.uk===2)m.x(t===null?"trying to redefine an already defined table or value":"document contains an unsafe property",r,o)}function fe(r,t={}){let o={s:r,p:0,d:t.maxDepth??1000,bi:t.integersAsBigInt??!1,ld:t.useLegacyDate??!0,uk:t.unsafeKeyBehaviour==="throw"?2:t.unsafeKeyBehaviour==="drop"?1:0},s=Object.create(null),f=Object.create(null),a,i=!1,u=s,c=f;if(r.charCodeAt(0)===65279)o.p++;T(o);while(o.p<r.length){if(r.charCodeAt(o.p)===91){let p=r.charCodeAt(++o.p)===91;a=o.p+=+p,i=!1;let g=H(o,93);if(p){if(r.charCodeAt(o.p)!==93)m.x("expected end of table array declaration",o);o.p++}let y=$e(o,g,s,f,p?2:1);if(!y)je(o,y,a),i=!0;else c=y[2],u=y[1]}else{a=o.p;let p=H(o),g=$e(o,p,u,c,0);if(!g&&!i)je(o,g,a);T(o,!0,!0);let y=U(o,void 0);if(g&&!i)g[1][g[0]]=y}if(T(o,!0),o.p<r.length&&(a=r.charCodeAt(o.p))!==10&&(a!==13||r.charCodeAt(o.p+1)!==10))m.x("each key-value declaration must be followed by an end-of-line",o);T(o)}return s}/*!
|
|
189
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
190
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
191
|
+
*
|
|
192
|
+
* Redistribution and use in source and binary forms, with or without
|
|
193
|
+
* modification, are permitted provided that the following conditions are met:
|
|
194
|
+
*
|
|
195
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
196
|
+
* list of conditions and the following disclaimer.
|
|
197
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
198
|
+
* this list of conditions and the following disclaimer in the
|
|
199
|
+
* documentation and/or other materials provided with the distribution.
|
|
200
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
201
|
+
* may be used to endorse or promote products derived from this software without
|
|
202
|
+
* specific prior written permission.
|
|
203
|
+
*
|
|
204
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
205
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
206
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
207
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
208
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
209
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
210
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
211
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
212
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
213
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
214
|
+
*/var Yn=!!"".isWellFormed;/*!
|
|
215
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
216
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
217
|
+
*
|
|
218
|
+
* Redistribution and use in source and binary forms, with or without
|
|
219
|
+
* modification, are permitted provided that the following conditions are met:
|
|
220
|
+
*
|
|
221
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
222
|
+
* list of conditions and the following disclaimer.
|
|
223
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
224
|
+
* this list of conditions and the following disclaimer in the
|
|
225
|
+
* documentation and/or other materials provided with the distribution.
|
|
226
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
227
|
+
* may be used to endorse or promote products derived from this software without
|
|
228
|
+
* specific prior written permission.
|
|
229
|
+
*
|
|
230
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
231
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
232
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
233
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
234
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
235
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
236
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
237
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
238
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
239
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
240
|
+
*/function Ee(r){let t=J(r);if(t===void 0||t.trim()==="")return;let o=L(t);if(!o)throw Error(`${r} isn't valid TOML, so it was left alone. Fix it and run setup again.`);return{text:t,value:o}}function Ie(r,t,o){let s=L(t)??{},f=Ne(s),a=o.reduce((c,p)=>{if(p.type==="key"){if(p.value===void 0)delete f[p.key];else f[p.key]=p.value;return rn(c,p.key,p.value)}if(p.type==="remove")return cn(f,p.path),on(c,p.path);return pn(f,p.path,p.entries),sn(c,p.path,p.entries)},t),i=/^\s*\n/.test(t)?a:a.replace(/^\s*\n/,""),u=L(i);if(!u||X(u)!==X(f))throw Error(`${r} couldn't be updated without changing settings setup doesn't own, so it was left alone.`);return i}function z(r,t){return t.reduce((o,s)=>N(o)?o[s]:void 0,r)}function q(r){if(typeof r==="string")return JSON.stringify(r);if(typeof r==="number"||typeof r==="boolean")return String(r);if(Array.isArray(r))return`[${r.map(q).join(", ")}]`;if(N(r))return`{ ${Object.entries(r).filter(([,t])=>t!==void 0).map(([t,o])=>`${Y(t)} = ${q(o)}`).join(", ")} }`;throw Error(`Can't write ${String(r)} as TOML`)}function Y(r){return/^[A-Za-z0-9_-]+$/.test(r)?r:JSON.stringify(r)}function N(r){return typeof r==="object"&&r!==null&&!Array.isArray(r)&&!(r instanceof Date)}function L(r){try{return fe(r)}catch{return}}function rn(r,t,o){let s=r.split(`
|
|
241
|
+
`),f=s.findIndex(de),a=f===-1?s.length:f,i=s.slice(0,a).findIndex((p)=>an(p)===t),u=o===void 0?[]:[`${Y(t)} = ${q(o)}`];if(i!==-1)return[...s.slice(0,i),...u.map((p)=>`${p}${tn(s[i])}`),...s.slice(i+1)].join(`
|
|
242
|
+
`);if(o===void 0)return r;let c=s.slice(0,a).findLastIndex((p)=>p.trim()!==""&&!p.trim().startsWith("#"));return[...s.slice(0,c+1),...u,...s.slice(c+1)].join(`
|
|
243
|
+
`)}function tn(r){let t=[...r.matchAll(/#/g)].map((o)=>o.index).find((o)=>L(r.slice(0,o))!==void 0);return t===void 0?"":r.slice(r.slice(0,t).trimEnd().length)}function on(r,t){let o=r.split(`
|
|
244
|
+
`),s=o.findIndex((c)=>de(c)&&!c.trim().startsWith("[[")&&un(ln(c),t));if(s===-1)return r;let f=o.slice(s+1).findIndex(de),a=f===-1?o.length:s+1+f,i=o.slice(0,a).findLastIndex((c)=>c.trim()!=="")+1,u=o.slice(0,s).findLastIndex((c)=>c.trim()!=="")+1;return[...o.slice(0,u),...o.slice(i)].join(`
|
|
245
|
+
`)}function sn(r,t,o){let s=Object.entries(o).filter(([,a])=>a!==void 0).map(([a,i])=>`${Y(a)} = ${q(i)}`),f=r.replace(/\s*$/,"");return`${f===""?"":`${f}
|
|
246
|
+
|
|
247
|
+
`}[${t.map(Y).join(".")}]
|
|
248
|
+
${s.join(`
|
|
249
|
+
`)}
|
|
250
|
+
`}function de(r){return/^\s*\[/.test(r)}function an(r){let t=r.match(/^\s*(?:([A-Za-z0-9_-]+)|"((?:[^"\\]|\\.)*)"|'([^']*)')\s*=/);if(!t)return;let o=t[2]===void 0?void 0:L(`k = "${t[2]}"`)?.k;return t[1]??t[3]??(typeof o==="string"?o:void 0)}function ln(r){let t=L(`${r}
|
|
251
|
+
`),o=[],s=t;while(N(s)&&Object.keys(s).length===1){let f=Object.keys(s)[0];o.push(f),s=s[f]}return o}function Ne(r){return Object.fromEntries(Object.entries(r).map(([t,o])=>[t,_e(o)]))}function _e(r){if(Array.isArray(r))return r.map(_e);if(N(r))return Ne(r);return r}function un(r,t){return r.length===t.length&&r.every((o,s)=>o===t[s])}function pn(r,t,o){let s=t.slice(0,-1).reduce((f,a)=>{let i=f[a];if(N(i))return i;let u={};return f[a]=u,u},r);s[t.at(-1)]=Object.fromEntries(Object.entries(o).filter(([,f])=>f!==void 0))}function cn(r,t){let o=z(r,t.slice(0,-1));if(N(o))delete o[t.at(-1)]}function X(r){if(Array.isArray(r))return`[${r.map(X).join(",")}]`;if(r instanceof Date)return JSON.stringify(r.toISOString());if(N(r))return`{${Object.keys(r).toSorted().map((t)=>[t,X(r[t])]).filter(([,t])=>t!=="{}").map(([t,o])=>`${JSON.stringify(t)}:${o}`).join(",")}}`;return JSON.stringify(r)}function kn(r=process.env,t=yn.homedir()){let o=r.CODEX_HOME?.trim(),s=o?Me(S.resolve(o)):S.join(t,".codex"),f=S.join(s,"AGENTS.override.md");return{home:s,config:S.join(s,"config.toml"),hooks:S.join(s,"hooks.json"),rules:S.join(s,"rules","opencode-console.rules"),skills:S.join(s,"skills"),memory:(J(f)?.trim()??"")===""?S.join(s,"AGENTS.md"):f}}function Me(r){if(pe(r))return hn(r);let t=S.dirname(r);return t===r?r:S.join(Me(t),S.basename(r))}function Re(r,t,o){let s=mr(Tt(r)),f=t.models[0];if(s===void 0||f===void 0)return;return{baseURL:`${s}/openai/v1`,catalogURL:`${o}${uo}`,model:f.slug,count:t.models.length}}function Le(r){return r.flatMap((t,o)=>{if(t.action!=="tool.use"||t.effect!=="deny"||!t.resource.startsWith("shell:"))return[];let s=t.resource.slice(6).match(/^([^*?]+)\*$/)?.[1]?.trim(),f=s?.split(/\s+/)??[];if(!s||f.some((i)=>!/^[\w@%+=:,./-]+$/.test(i)))return[];if(r.slice(o+1).some((i)=>i.action==="tool.use"&&i.effect==="allow"&&so(i.resource,`shell:${s}`)))return[];let a=[...t.message].map((i)=>i<" "||i===""?" ":i).join("");return[`prefix_rule(pattern = ${JSON.stringify(f)}, decision = "forbidden", justification = ${JSON.stringify(a)})`]})}var bn=n({baseURL:e,catalogURL:e,model:e,count:V}),Pe=n({paths:n({home:e,config:e,hooks:e,rules:e,skills:e,memory:e}),command:l(e),harness:b(e),environment:x(e,e),...ur,tables:l(l(e)),servers:l(e),skills:x(e,e),memoryCreated:v,created:n({config:v,hooks:v}),providers:b(e),models:b(Ze(bn))}),ee=(r)=>S.join(r.data,"codex.json");function ne(r){let t=ee(r),o=J(t);if(o===void 0)return;let s=j(W(Z(Pe))(o));if(!s)throw Error(`${t} can't be read, so Codex was left as it is. Delete it and run setup again.`);return s}var Q="opencode-console",ce=["hook","codex"],wn=R("Codex.refresh")(function*(r,t){let o=ne(r),s=t??o;if(!s)return;let f=yield*He(r),a=f&&qe(r,be(f));if(!f||!a?.config)return;let i=a.config,u=Ot(a),c=xe("sha256").update(JSON.stringify(i.providers??null)).digest("hex"),g=!t&&o?.providers===c&&o.models!==void 0?o.models??void 0:yield*pt([_t(f),_s(f)],{concurrency:2}).pipe(h(([A,D])=>Re(A,D,f.server))),y=yield*dn(f,s.paths.skills,u,o?.skills??{}),O=gr(f,a),w=yield*Ae([{action:"websearch:",resources:["*"],truncated:!0},{action:"websearch.use",resources:["openai"]}],(A)=>cr(O,A));return yield*Ce(r,I(()=>Cn(r,{paths:s.paths,command:s.command,harness:t?t.harness:o?.harness,environment:t?t.environment??{}:o?.environment??{},models:g,servers:Object.fromEntries(Object.entries(et(a)).map(([A,D])=>[A,{url:D.url,gateway:D.headers!==void 0}])),instructions:lt(a),skills:u,bundles:y,rules:Le(fs(O)??[]),searchOff:w.some((A)=>A.effect==="deny"),providers:c,explicit:t!==void 0})))});function An(r){let t=ne(r);if(!t)return!1;let o=Ee(t.paths.config),s=St(t.paths.hooks),f=J(t.paths.memory),a=o&&Ie(t.paths.config,o.text,[...Object.keys(t.originals).flatMap((i)=>{let u={...o.value};return jn(u,i,t),JSON.stringify(u[i])===JSON.stringify(o.value[i])?[]:[{type:"key",key:i,value:u[i]}]}),...t.tables.filter((i)=>z(o.value,i)!==void 0).map((i)=>({type:"remove",path:i}))]);if(o&&a!==void 0){if(a.trim()===""&&t.created.config)K(t.paths.config);else if(a!==o.text)wt(t.paths.config,a)}if(s)if(ze(s),Object.keys(s).length===0&&t.created.hooks)K(t.paths.hooks);else vt(t.paths.hooks,s);return K(t.paths.rules),Object.keys(t.skills).forEach((i)=>gn(S.join(t.paths.skills,i),{recursive:!0,force:!0})),lr(t.paths.memory,f,[],t.memoryCreated),[t.paths.config,t.paths.hooks].forEach((i)=>K(Xe(i))),K(ee(r)),!0}function Cn(r,t){let o=ne(r),s=pe(t.paths.config),f=pe(t.paths.hooks),a=Ee(t.paths.config)??{text:"",value:{}},i=St(t.paths.hooks)??{},u=J(t.paths.memory),c=o?.created??{config:!s,hooks:!f},p=[];ze(i);let g=_(i.hooks),y=[...t.command,...t.harness===void 0?[]:["--harness",t.harness]],O=On(y).map(([d,M])=>{let we=[...Array.isArray(g[d])?g[d]:[],M];return g[d]=we,{event:d,group:M,index:we.length-1}});i.hooks=g;let w={...a.value},{originals:A,written:D}=pr(w,Sn(t),o,t.explicit),We=[...new Set([...Object.keys(o?.originals??{}),...Object.keys(A)])].flatMap((d)=>JSON.stringify(w[d])===JSON.stringify(a.value[d])?[]:[{type:"key",key:d,value:w[d]}]),re=new Map((o?.tables??[]).map((d)=>[JSON.stringify(d),d])),te=(d)=>!re.has(JSON.stringify(d))&&z(a.value,d)!==void 0,he=["model_providers",Q];if(t.models&&te(he))throw Error(`${t.paths.config} already has a model provider named ${Q}, so Codex was left as it is. Rename it and run setup again.`);let oe=Object.entries(t.servers).flatMap(([d,M])=>{if(M.url===void 0||!/^[a-z0-9_-]+$/i.test(d))return[];if(te(["mcp_servers",d]))return p.push(d),[];return[{name:d,url:M.url,gateway:M.gateway}]}),ge=O.map((d)=>({path:["hooks","state",`${t.paths.hooks}:${Ue(d.event)}:${d.index}:0`],hash:Je(d.event,d.group)})),ie=[...t.models?[{path:[...he],entries:Tn(t)}]:[],...oe.map((d)=>({path:["mcp_servers",d.name],entries:{url:d.url,...d.gateway?{http_headers_helper:fr([...$n(t.environment),...y,"mcp-headers",d.name])}:{}}})),...ge.map((d)=>({path:d.path,entries:{trusted_hash:d.hash}}))],Fe=(d)=>re.has(JSON.stringify(d.path))&&F(z(a.value,d.path))===F(d.entries),ye=new Set(ie.filter(Fe).map((d)=>JSON.stringify(d.path))),ke=Ie(t.paths.config,a.text,[...We,...[...re].filter(([d])=>!ye.has(d)).map(([,d])=>d).filter((d)=>z(a.value,d)!==void 0).map((d)=>({type:"remove",path:d})),...ge.filter((d)=>te(d.path)).map((d)=>({type:"remove",path:d.path})),...ie.filter((d)=>!ye.has(JSON.stringify(d.path))).map((d)=>({type:"table",path:d.path,entries:d.entries}))]);if(!o)[t.paths.config,t.paths.hooks].forEach(fn);if(ke!==a.text)wt(t.paths.config,ke,384);if(vt(t.paths.hooks,i,384),t.rules.length>0)En(t.paths.rules,`# Written by OpenCode Console from the workspace's policies; \`npx @opencode/console sync\` rewrites it.
|
|
252
|
+
${t.rules.join(`
|
|
253
|
+
`)}
|
|
254
|
+
`);else K(t.paths.rules);let se=mn(t.paths.skills,t.skills,t.bundles,o?.skills??{});p.push(...se.skipped);let Be=lr(t.paths.memory,u,t.instructions,o?.memoryCreated??!1);return Se(ee(r),JSON.stringify(Pe.make({paths:t.paths,command:[...t.command],...t.harness===void 0?{}:{harness:t.harness},environment:{...t.environment},originals:A,written:D,tables:ie.map((d)=>d.path),servers:oe.map((d)=>d.name),skills:se.skills,memoryCreated:Be,created:c,providers:t.providers,models:t.models??null}))),{models:t.models,servers:oe.map((d)=>d.name),skills:Object.keys(se.skills),instructions:t.instructions.length,rules:t.rules.length,searchOff:t.searchOff,skipped:p}}function Sn(r){return{...r.models?{model_provider:Q,model:r.models.model}:{},...r.searchOff?{web_search:"disabled"}:{}}}function Tn(r){let t=r.models;return{name:"OpenCode Console",base_url:t.baseURL,wire_api:"responses",model_catalog_url:t.catalogURL,http_headers:{"x-opencode-plugin":`opencode-console/${ue}`},auth:{command:r.command[0],args:[...r.command.slice(1),"token"],refresh_interval_ms:240000,timeout_ms:15000}}}function On(r){let t=fr([...r,...ce]);return[["PreToolUse",{matcher:"*",hooks:[{type:"command",command:t,timeout:30}]}],["UserPromptSubmit",{hooks:[{type:"command",command:t,timeout:30}]}],["SessionStart",{hooks:[{type:"command",command:t,timeout:10}]}]]}function Je(r,t){let o=t.hooks[0],s={event_name:Ue(r),..."matcher"in t?{matcher:t.matcher}:{},hooks:[{type:o.type,command:o.command,timeout:o.timeout,async:!1}]};return`sha256:${xe("sha256").update(F(s)).digest("hex")}`}function Ue(r){return r.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase()}function F(r){if(Array.isArray(r))return`[${r.map(F).join(",")}]`;if(N(r))return`{${Object.keys(r).toSorted().map((t)=>`${JSON.stringify(t)}:${F(r[t])}`).join(",")}}`;return JSON.stringify(r)}function ze(r){let t=_(r.hooks);if(Object.entries(t).forEach(([o,s])=>{if(!Array.isArray(s))return;let f=s.flatMap((a)=>{let i=_(a).hooks;if(!Array.isArray(i))return[a];let u=i.filter((c)=>!vn(c));if(u.length===i.length)return[a];return u.length===0?[]:[{..._(a),hooks:u}]});if(f.length===0)delete t[o];else t[o]=f}),Object.keys(t).length===0)delete r.hooks;else r.hooks=t}function vn(r){let t=_(r).command;return typeof t==="string"&&t.endsWith(` ${ce.join(" ")}`)}function $n(r){let t=Object.entries(r);if(t.length===0||process.platform==="win32")return[];return["env",...t.map(([o,s])=>`${o}=${s}`)]}function En(r,t){if(J(r)!==t)wt(r,t)}export{me as Codex,Q as PROVIDER,ce as hookArgs,ne as manifest,ee as manifestFile,Re as models,kn as paths,wn as refresh,An as remove,Le as rules,Je as trustHash};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{hn,Re,Ri}from"./chunk-qp7a49b3.js";import{br,Hn,Os,Ps,Rs}from"./chunk-jpqmm6pm.js";import{Ce}from"./chunk-6xs4y82y.js";import{ke,be,Bn,He}from"./chunk-x65p26st.js";import{Ss,vs,ws,hr}from"./chunk-yb3fn5r1.js";import{k,P,se,Ct,pt,r,I,u,ko,h,Ie,R}from"./chunk-9dgq3xc0.js";var bs={};k(bs,{WorkspaceSync:()=>bs,current:()=>qe,identify:()=>xs,sync:()=>ys,userAgent:()=>Si});function xs(n){return se(Re,h(Re,(s)=>Ri(s,hn({"user-agent":Si(n),"x-opencode-plugin":`opencode-console/${n.version}`}))))}function Si(n){return[n.harness?.replace(/[\r\n]/g,"").trim(),`opencode-console/${n.version}`].filter(Boolean).join(" ")}var ys=R("WorkspaceSync.sync")(function*(n,s={}){let o=ke(n);if(!o)return yield*Ce(n,I(()=>ws(n))),{snapshot:void 0};let i=yield*Ct,l=be(o),t=qe(n,l);if(t&&!s.force&&!hr(t,i))return{snapshot:t};let c=yield*He(n).pipe(u((e)=>e?pt({config:Os(e),instructions:Ps(e).pipe(h((f)=>f.instructions),Ie(()=>t?.instructions)),skills:Rs(e).pipe(h((f)=>f.skills),Ie(()=>t?.skills))},{concurrency:"unbounded"}).pipe(h((f)=>({credential:e,...f}))):r(void 0)),ko);if(P(c)){if(!c.success)return{snapshot:void 0};let e=c.success;return{snapshot:yield*d(n,l,{owner:l,organization:Bn(e.credential),fetched:i,config:e.config,...e.instructions===void 0?{}:{instructions:e.instructions},...e.skills===void 0?{}:{skills:e.skills}})}}let a=m(c.failure);if(!a)return{snapshot:t,error:c.failure};let p=t??{owner:l,organization:Bn(o)};return{snapshot:yield*d(n,l,{...p,fetched:i,status:a}),error:c.failure}});function qe(n,s){let o=Ss(n);return o?.owner===s?o:void 0}function d(n,s,o){return Ce(n,I(()=>{let i=ke(n);if(!i||be(i)!==s)return;return vs(n,o),o}))}function m(n){if(n instanceof br)return{message:n.message,url:n.url};if(n instanceof Hn)return{message:n.message};return}
|
|
2
|
+
export{xs,Si,ys,qe,bs};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Pt,ho}from"./chunk-qp7a49b3.js";import{Er,Ls,js,Se}from"./chunk-6xs4y82y.js";import{ke,be}from"./chunk-x65p26st.js";import{cr}from"./chunk-7qa618ad.js";import{hr,gr}from"./chunk-yb3fn5r1.js";import{xs,ys,qe}from"./chunk-bcmj4f7y.js";import{ue}from"./chunk-9zpe1ry1.js";import{k,wn,Ae,Nr,Te,On}from"./chunk-9dgq3xc0.js";var ps={};k(ps,{InProcess:()=>ps,config:()=>Be,decide:()=>bt,decisions:()=>ar,refresh:()=>us,refreshStale:()=>yi,session:()=>ir});function ir(e={}){let r=xs({version:ue,harness:e.harness}).pipe(wn(ho)),o=e.fetch;return{store:e.store??Er(),run:(n)=>On(o?n.pipe(Nr(r),Te(Pt,o)):n.pipe(Nr(r)))}}var i=new WeakMap;function us(e){let r=i.get(e);if(r)return r;let o=e.run(ys(e.store)).finally(()=>i.delete(e));return i.set(e,o),o}async function bt(e,r){return(await ar(e,r)).find((o)=>o.effect==="deny")}async function ar(e,r){let o=ke(e.store),n=gr(o,o&&await Be(e));return On(Ae(r,(t)=>cr(n,t)))}async function Be(e){let r=ke(e.store);if(!r)return;let o=be(r),n=qe(e.store,o);if(!n)await new Promise((t)=>{let s=setTimeout(t,3000);s.unref?.(),us(e).catch(()=>{return}).finally(()=>{clearTimeout(s),t()})});else if(hr(n,Date.now()))yi(e);return qe(e.store,o)}function yi(e){let r=Ls(e.store),o=js(r);if(o!==void 0&&Date.now()-o<30000)return!1;return Se(r,""),us(e).catch(()=>{return}),!0}
|
|
2
|
+
export{ir,us,bt,ar,Be,yi,ps};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cr,fs,so,ds}from"./chunk-7qa618ad.js";import"./chunk-11wqcgnn.js";import"./chunk-qp7a49b3.js";import"./chunk-6xs4y82y.js";import"./chunk-m3m5harb.js";export{ds as PolicyEvaluator,cr as check,so as couldMatch,fs as statements};
|