@opencode/console 0.1.3 → 0.1.4
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 +14 -0
- package/{chunk-11wqcgnn.js → chunk-172desm7.js} +2 -2
- package/{chunk-5a8bvcgq.js → chunk-17ek638g.js} +4 -4
- package/{chunk-1z17cm3w.js → chunk-1900gmc1.js} +2 -2
- package/chunk-1ekysq54.js +1 -0
- package/chunk-38wxxryg.js +1 -0
- package/chunk-4hra11sy.js +2 -0
- package/{chunk-z5mqjw9r.js → chunk-6dmhresx.js} +2 -2
- package/{chunk-m3m5harb.js → chunk-81pw2xsw.js} +2 -2
- package/chunk-87hkw75t.js +11 -0
- package/chunk-8stwzw95.js +2 -0
- package/{chunk-b4fde357.js → chunk-93je9v9b.js} +2 -2
- package/chunk-bfd21777.js +2 -0
- package/chunk-c8zgzn9g.js +2 -0
- package/chunk-c94982xf.js +1 -0
- package/{chunk-gcqbk8bn.js → chunk-e219b1sg.js} +67 -67
- package/chunk-eja0bnj7.js +1 -0
- package/chunk-fsg05nff.js +2 -0
- package/chunk-gj3j0mk6.js +1 -0
- package/chunk-hkjjea67.js +3 -0
- package/chunk-httrtddj.js +1 -0
- package/chunk-j6qa0p88.js +1 -0
- package/chunk-ka5nrr3r.js +1 -0
- package/chunk-m711drrn.js +1 -0
- package/chunk-n6fr9p3j.js +254 -0
- package/chunk-qsqer89q.js +1 -0
- package/{chunk-7qa618ad.js → chunk-tzhpc3tb.js} +49 -49
- package/chunk-v67dra35.js +1 -0
- package/chunk-vf7nj8yg.js +32 -0
- package/chunk-vrvsj5aj.js +1 -0
- package/chunk-w7jwta9c.js +1 -0
- package/chunk-wvtbwbxs.js +2 -0
- package/{chunk-6xs4y82y.js → chunk-xsr5jd61.js} +2 -2
- package/chunk-yqbzfq0h.js +1 -0
- package/dsh-plugin.js +1 -1
- package/index.js +60 -51
- package/package.json +1 -1
- package/pi-extension.js +2 -2
- package/chunk-0752rr1w.js +0 -1
- package/chunk-38zs2jre.js +0 -1
- package/chunk-3p7x3f0s.js +0 -1
- package/chunk-6fqhbptf.js +0 -1
- package/chunk-6hmr86q5.js +0 -3
- package/chunk-82p6vmpy.js +0 -1
- package/chunk-9dgq3xc0.js +0 -32
- package/chunk-9zpe1ry1.js +0 -2
- package/chunk-b6azftzw.js +0 -254
- package/chunk-bcmj4f7y.js +0 -2
- package/chunk-cd4h496v.js +0 -2
- package/chunk-g9f1r3v3.js +0 -1
- package/chunk-ghvsrvdw.js +0 -1
- package/chunk-jpqmm6pm.js +0 -2
- package/chunk-jxh84gfh.js +0 -1
- package/chunk-kd1hjfpe.js +0 -1
- package/chunk-mnjk01tj.js +0 -1
- package/chunk-nqk8n93s.js +0 -1
- package/chunk-qp7a49b3.js +0 -1
- package/chunk-r1adn0ka.js +0 -11
- package/chunk-tamzaefd.js +0 -1
- package/chunk-x65p26st.js +0 -2
- package/chunk-yb3fn5r1.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{wa,ro,rs,oo,Un,xi,os,yi,ss,$n,is,as,so,pn,cs,Ea,ls}from"./chunk-87hkw75t.js";import"./chunk-e219b1sg.js";import"./chunk-fsg05nff.js";import"./chunk-wvtbwbxs.js";import"./chunk-bfd21777.js";import"./chunk-172desm7.js";import"./chunk-4hra11sy.js";import"./chunk-w7jwta9c.js";import"./chunk-xsr5jd61.js";import"./chunk-81pw2xsw.js";export{ls as DeepSeekHarness,Un as MCP_SERVICE,rs as REALM,xi as Route,oo as SERVICE,ro as TOKEN,$n as Unreadable,is as checks,yi as defaultModel,as as invokedSkills,pn as manifest,so as manifestFile,ss as mcpConfig,wa as paths,cs as refresh,Ea as remove,os as routes};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{hn,Re,Mi}from"./chunk-w7jwta9c.js";import{Sr,zn,Os,Ps,Rs,Ms}from"./chunk-4hra11sy.js";import{Ae}from"./chunk-xsr5jd61.js";import{Ce,be,qn,ze}from"./chunk-bfd21777.js";import{Ss,vs,ws,gr}from"./chunk-wvtbwbxs.js";import{k,P,se,Ct,pt,r,I,u,ko,h,ke,R}from"./chunk-vf7nj8yg.js";var bs={};k(bs,{WorkspaceSync:()=>bs,current:()=>He,identify:()=>xs,sync:()=>ys,userAgent:()=>vi});function xs(e){return se(Re,h(Re,(t)=>Mi(t,hn({"user-agent":vi(e),"x-opencode-plugin":`opencode-console/${e.version}`}))))}function vi(e){return[e.harness?.replace(/[\r\n]/g,"").trim(),`opencode-console/${e.version}`].filter(Boolean).join(" ")}var ys=R("WorkspaceSync.sync")(function*(e,t={}){let o=Ce(e);if(!o)return yield*Ae(e,I(()=>ws(e))),{snapshot:void 0};let i=yield*Ct,l=be(o),s=He(e,l);if(s&&!t.force&&!gr(s,i))return{snapshot:s};let c=yield*ze(e).pipe(u((n)=>n?pt({config:Os(n),instructions:Ps(n).pipe(h((f)=>f.instructions),ke(()=>s?.instructions)),skills:Rs(n).pipe(h((f)=>f.skills),ke(()=>s?.skills)),telemetry:Ms(n).pipe(ke(()=>s?.telemetry))},{concurrency:"unbounded"}).pipe(h((f)=>({credential:n,...f}))):r(void 0)),ko);if(P(c)){if(!c.success)return{snapshot:void 0};let n=c.success;return{snapshot:yield*d(e,l,{owner:l,organization:qn(n.credential),fetched:i,config:n.config,...n.instructions===void 0?{}:{instructions:n.instructions},...n.skills===void 0?{}:{skills:n.skills},...n.telemetry===void 0?{}:{telemetry:n.telemetry}})}}let a=m(c.failure);if(!a)return{snapshot:s,error:c.failure};let p=s??{owner:l,organization:qn(o)};return{snapshot:yield*d(e,l,{...p,fetched:i,status:a}),error:c.failure}});function He(e,t){let o=Ss(e);return o?.owner===t?o:void 0}function d(e,t,o){return Ae(e,I(()=>{let i=Ce(e);if(!i||be(i)!==t)return;return vs(e,o),o}))}function m(e){if(e instanceof Sr)return{message:e.message,url:e.url};if(e instanceof zn)return{message:e.message};return}
|
|
2
|
+
export{xs,vi,ys,He,bs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ar,us,bt,cr,qe,bi,ps}from"./chunk-c8zgzn9g.js";import"./chunk-tzhpc3tb.js";import"./chunk-fsg05nff.js";import"./chunk-wvtbwbxs.js";import"./chunk-bfd21777.js";import"./chunk-172desm7.js";import"./chunk-4hra11sy.js";import"./chunk-w7jwta9c.js";import"./chunk-xsr5jd61.js";import"./chunk-81pw2xsw.js";export{ps as InProcess,qe as config,bt as decide,cr as decisions,us as refresh,bi as refreshStale,ar as session};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import"./chunk-81pw2xsw.js";import"./chunk-w7jwta9c.js";import{_t}from"./chunk-4hra11sy.js";import{Ae,V,Se,J}from"./chunk-xsr5jd61.js";import{be,ze}from"./chunk-bfd21777.js";import{pr,St,vt,fr,jn,dr,hs,Si,Xe,fn,_,Et,Bn,dn,mn,Tt,mr,hr}from"./chunk-e219b1sg.js";import"./chunk-172desm7.js";import{lt,Ot,et}from"./chunk-wvtbwbxs.js";import{He}from"./chunk-fsg05nff.js";import{ur}from"./chunk-17ek638g.js";import{ue}from"./chunk-8stwzw95.js";import{k,L,I,R,W,g,e,v,n,x,l,M,Le,G}from"./chunk-vf7nj8yg.js";var D={};k(D,{ClaudeCode:()=>D,hookArgs:()=>P,manifest:()=>A,manifestFile:()=>C,models:()=>X,paths:()=>oe,refresh:()=>re,remove:()=>se});import{createHash as Z}from"node:crypto";import{existsSync as T,rmSync as ee}from"node:fs";import ne from"node:os";import u from"node:path";function oe(t=process.env,o=ne.homedir()){let s=t.CLAUDE_CONFIG_DIR?.trim(),a=s?u.resolve(s):u.join(o,".claude");return{config:a,settings:u.join(a,"settings.json"),global:s?u.join(a,".claude.json"):u.join(o,".claude.json"),skills:u.join(a,"skills"),memory:u.join(a,"CLAUDE.md")}}function X(t){let o=Tt(t),s=hr(o);if(o.length===0||s===void 0)return;let a=(r)=>r.provider==="opencode"?r.id:`${r.provider}/${r.id}`,c=(...r)=>a(mr(o,...r));return{baseURL:`${s}/anthropic`,options:o.map((r)=>({model:a(r),label:Et(r.entry.name)??r.id,...r.provider==="opencode"||r.providerName===void 0?{}:{description:r.providerName}})),tiers:{opus:c("opus","sonnet","haiku"),sonnet:c("sonnet","opus","haiku"),haiku:c("haiku","sonnet","opus")}}}var te=n({baseURL:e,options:l(n({model:e,label:e,description:g(e)})),tiers:n({opus:e,sonnet:e,haiku:e})}),K=n({paths:n({config:e,settings:e,global:e,skills:e,memory:e}),command:l(e),harness:g(e),...pr,servers:l(e),skills:x(e,e),memoryCreated:v,created:g(n({settings:v,global:v})),providers:g(e),models:g(Le(te)),keepProvider:g(v),usage:g(M(["shared","kept"]))}),C=(t)=>u.join(t.data,"claude-code.json");function A(t){let o=C(t),s=V(o);if(s===void 0)return;let a=L(W(G(K))(s));if(!a)throw Error(`${o} can't be read, so Claude Code was left as it is. Delete it and run setup again.`);return a}var re=R("ClaudeCode.refresh")(function*(t,o,s=process.env){let a=A(t),c=o??a;if(!c)return;let r=yield*ze(t),i=r&&He(t,be(r));if(!r||!i?.config)return;let p=i.config,m=Ot(i),b=o?o.keepProvider===!0:a?.keepProvider===!0,h=Z("sha256").update(JSON.stringify(p.providers??null)).digest("hex"),O=!o&&a?.providers===h&&a.models!==void 0,y=b?void 0:O?a.models??void 0:X(yield*_t(r)),w=yield*dn(r,c.paths.skills,m,a?.skills??{});return yield*Ae(t,I(()=>ie(t,{paths:c.paths,command:c.command,harness:o?o.harness:a?.harness,models:y,servers:Object.fromEntries(Object.entries(et(i)).map(([N,f])=>[N,{url:f.url,gateway:f.headers!==void 0}])),instructions:lt(i),skills:m,bundles:w,providers:h,keepProvider:b,telemetry:i.telemetry,shell:s,explicit:o!==void 0})))});function se(t){let o=A(t);if(!o)return!1;let s=St(o.paths.settings),a=St(o.paths.global),c=V(o.paths.memory),r=o.created??{settings:!T(Xe(o.paths.settings)),global:!T(Xe(o.paths.global))};if(s)if(Object.keys(o.originals).forEach((i)=>jn(s,i,o)),Y(s,void 0),q(s),Object.keys(s).length===0&&r.settings)J(o.paths.settings);else vt(o.paths.settings,s);if(a){let i=_(a.mcpServers);if(o.servers.forEach((p)=>delete i[p]),Object.keys(i).length===0)delete a.mcpServers;else a.mcpServers=i;if(Object.keys(a).length===0&&r.global)J(o.paths.global);else vt(o.paths.global,a,384)}return Object.keys(o.skills).forEach((i)=>ee(u.join(o.paths.skills,i),{recursive:!0,force:!0})),ur(o.paths.memory,c,[],o.memoryCreated),[o.paths.settings,o.paths.global].forEach((i)=>J(Xe(i))),J(C(t)),!0}var P=["hook","claude-code"],z="x-opencode-plugin",F=["OTEL_EXPORTER_OTLP_ENDPOINT","OTEL_EXPORTER_OTLP_LOGS_ENDPOINT","OTEL_LOGS_EXPORTER"];function ie(t,o){let s=A(t),a=s===void 0,c=T(o.paths.settings),r=T(o.paths.global),i=St(o.paths.settings)??{},p=St(o.paths.global)??{},m=V(o.paths.memory),b=s?.created??{settings:!c,global:!r},h=[];if(a)[o.paths.settings,o.paths.global].forEach(fn);let O=!o.models&&o.telemetry?le(o,o.telemetry):void 0,y=O&&(ae(o,i,s,O)?"kept":"shared"),{originals:w,written:N}=fr(i,{...ce(o),...y==="shared"?O:{}},s,o.explicit);Y(i,o.models?`${z}: opencode-console/${ue}`:void 0),q(i);let f=_(i.hooks);de(o.command).forEach(([d,E])=>{f[d]=[...Array.isArray(f[d])?f[d]:[],E]}),i.hooks=f;let U=new Set(s?.servers??[]),S=_(p.mcpServers);U.forEach((d)=>{if(!(d in o.servers))delete S[d]});let j=Object.entries(o.servers).flatMap(([d,E])=>{if(E.url===void 0||!/^[a-z0-9_-]+$/i.test(d))return[];if(d in S&&!U.has(d))return h.push(d),[];return S[d]={type:"http",url:E.url,...E.gateway?{headersHelper:Bn([...o.command,"mcp-headers",d])}:{}},[d]});if(Object.keys(S).length>0)p.mcpServers=S;else delete p.mcpServers;if(vt(o.paths.settings,i,384),r||j.length>0)vt(o.paths.global,p,384);let H=mn(o.paths.skills,o.skills,o.bundles,s?.skills??{});h.push(...H.skipped);let B=H.skills,Q=ur(o.paths.memory,m,o.instructions,s?.memoryCreated??!1);return Se(C(t),JSON.stringify(K.make({paths:o.paths,command:[...o.command],...o.harness===void 0?{}:{harness:o.harness},originals:w,written:N,servers:j,skills:B,memoryCreated:Q,created:b,providers:o.providers,models:o.models??null,...o.keepProvider?{keepProvider:!0}:{},...y===void 0?{}:{usage:y}}))),{models:o.models,servers:j,skills:Object.keys(B),instructions:o.instructions.length,skipped:h,keepProvider:o.keepProvider,usage:y}}function le(t,o){return{"env.CLAUDE_CODE_ENABLE_TELEMETRY":"1","env.OTEL_LOGS_EXPORTER":"otlp","env.OTEL_EXPORTER_OTLP_LOGS_PROTOCOL":"http/json","env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT":o.otlpLogsUrl,"env.OTEL_LOGS_EXPORT_INTERVAL":"30000","env.OTEL_LOG_USER_PROMPTS":"0","env.OTEL_LOG_ASSISTANT_RESPONSES":"0","env.OTEL_LOG_TOOL_DETAILS":"0","env.OTEL_LOG_RAW_API_BODIES":"0",otelHeadersHelper:Bn([...t.command,"otel-headers"])}}function ae(t,o,s,a){return[...F.map((r)=>`env.${r}`),"otelHeadersHelper"].some((r)=>{let i=dr(o,r);if(i===void 0)return!1;return!(s&&(r in s.written)&&JSON.stringify(i)===JSON.stringify(s.written[r]))})||F.some((r)=>{let i=t.shell[r];return i!==void 0&&i!==""&&i!==a[`env.${r}`]})}function ce(t){let o=t.harness===void 0?{}:{"env.OPENCODE_CONSOLE_HARNESS":t.harness};if(!t.models)return o;return{...o,apiKeyHelper:Bn([...t.command,"token"]),"env.ANTHROPIC_BASE_URL":t.models.baseURL,"env.ANTHROPIC_DEFAULT_OPUS_MODEL":t.models.tiers.opus,"env.ANTHROPIC_DEFAULT_SONNET_MODEL":t.models.tiers.sonnet,"env.ANTHROPIC_DEFAULT_HAIKU_MODEL":t.models.tiers.haiku,modelPicker:{options:t.models.options,replaceBuiltInOptions:!0}}}function Y(t,o){let s=dr(t,"env.ANTHROPIC_CUSTOM_HEADERS"),c=[...(typeof s==="string"?s:"").split(`
|
|
2
|
+
`).filter((r)=>r.trim()!==""&&!r.toLowerCase().startsWith(`${z}:`)),...o===void 0?[]:[o]];if(c.length>0)hs(t,"env.ANTHROPIC_CUSTOM_HEADERS",c.join(`
|
|
3
|
+
`));else if(s!==void 0)Si(t,"env.ANTHROPIC_CUSTOM_HEADERS")}function de(t){let o={type:"command",command:t[0],args:[...t.slice(1),...P]},s={...o,timeout:30,onFailure:"block"};return[["PreToolUse",{matcher:"*",hooks:[s]}],["UserPromptSubmit",{hooks:[s]}],["UserPromptExpansion",{hooks:[s]}],["SessionStart",{hooks:[{...o,timeout:10}]}]]}function q(t){let o=_(t.hooks);if(Object.entries(o).forEach(([s,a])=>{if(!Array.isArray(a))return;let c=a.flatMap((r)=>{let i=_(r).hooks;if(!Array.isArray(i))return[r];let p=i.filter((m)=>!pe(m));if(p.length===i.length)return[r];return p.length===0?[]:[{..._(r),hooks:p}]});if(c.length===0)delete o[s];else o[s]=c}),Object.keys(o).length===0)delete t.hooks;else t.hooks=o}function pe(t){let o=_(t).args;return Array.isArray(o)&&o.slice(-P.length).join(" ")===P.join(" ")}export{D as ClaudeCode,P as hookArgs,A as manifest,C as manifestFile,X as models,oe as paths,re as refresh,se as remove};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{xs,vi,ys,He,bs}from"./chunk-fsg05nff.js";import"./chunk-wvtbwbxs.js";import"./chunk-bfd21777.js";import"./chunk-172desm7.js";import"./chunk-4hra11sy.js";import"./chunk-w7jwta9c.js";import"./chunk-xsr5jd61.js";import"./chunk-81pw2xsw.js";export{bs as WorkspaceSync,He as current,xs as identify,ys as sync,vi as userAgent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{wi,Ei,Ss,vs,ws,gr,ki,xr,lt,Ot,et,ka,Es}from"./chunk-wvtbwbxs.js";import"./chunk-bfd21777.js";import"./chunk-172desm7.js";import"./chunk-4hra11sy.js";import"./chunk-w7jwta9c.js";import"./chunk-xsr5jd61.js";import"./chunk-81pw2xsw.js";export{Ei as Info,wi as MAX_AGE_MS,Es as WorkspaceSnapshot,ws as clear,lt as instructions,ka as models,ki as policies,Ss as read,et as servers,Ot as skills,gr as stale,xr as workspace,vs as write};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ce,co,be,qn,Ca,ze,Aa,ks}from"./chunk-bfd21777.js";import"./chunk-4hra11sy.js";import"./chunk-w7jwta9c.js";import"./chunk-xsr5jd61.js";import"./chunk-81pw2xsw.js";export{ks as ConsoleCredentials,ze as fresh,Ca as login,Aa as logout,qn as organization,be as owner,Ce as read,co as stored};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{As,yr,br,Ci,Ai,Sr,zn,vr,Ii,Is,Ts,lo,Os,_t,uo,_s,Ps,Rs,Ms,Ns,Fs,Ds,Ls}from"./chunk-4hra11sy.js";import"./chunk-w7jwta9c.js";import"./chunk-81pw2xsw.js";export{Ls as ConsoleClient,vr as DeviceSignInFailed,br as OAuth,zn as SignedOut,Sr as SsoRequired,Is as authorize,yr as clientID,uo as codexModelsPath,As as defaultServer,_s as fetchCodexModels,Os as fetchConfig,Ps as fetchInstructions,_t as fetchModels,Ns as fetchSkill,Fs as fetchSkillBlob,Rs as fetchSkills,Ms as fetchTelemetry,Ii as headers,Ds as normalizeServer,Ts as refresh,lo as revoke,Ci as signedOutMessage,Ai as ssoMessage};
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import"./chunk-81pw2xsw.js";import"./chunk-w7jwta9c.js";import{_t,uo,_s}from"./chunk-4hra11sy.js";import{Ae,V,Se,J}from"./chunk-xsr5jd61.js";import{be,ze}from"./chunk-bfd21777.js";import{pr,St,vt,fr,jn,Xe,fn,wt,_,Bn,dn,mn,Tt,hr}from"./chunk-e219b1sg.js";import"./chunk-172desm7.js";import{lr,fs,io}from"./chunk-tzhpc3tb.js";import{xr,lt,Ot,et}from"./chunk-wvtbwbxs.js";import{He}from"./chunk-fsg05nff.js";import{ur}from"./chunk-17ek638g.js";import{ue}from"./chunk-8stwzw95.js";import{k,L,pt,Ie,I,h,R,W,g,d,e,H,v,n,x,l,Le,G}from"./chunk-vf7nj8yg.js";var ge={};k(ge,{Codex:()=>ge,PROVIDER:()=>ne,hookArgs:()=>he,manifest:()=>te,manifestFile:()=>re,models:()=>Je,paths:()=>wn,refresh:()=>Cn,remove:()=>Sn,rules:()=>Ue,trustHash:()=>Ze});import{createHash as xe}from"node:crypto";import{existsSync as me,realpathSync as yn,rmSync as kn}from"node:fs";import bn 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 qe(r,t){let o=r.slice(0,t).split(/\r?\n/);return[o.length,o.pop().length+1]}function Ye(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 y extends Error{line;column;codeblock;constructor(r,t){let[o,s]=qe(t.toml,t.ptr),f=Ye(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 y(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 K(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,m=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))m=m&&3;else if(o<32&&o!==9||o===127)y.x("control characters are not allowed in strings",r);else if((!m||m===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(!m){let c=r.s.slice(u,r.p);i=i?i+c:c}return r.p+=a?3:1,i}else if(!m){if(!f&&o===92)i+=r.s.slice(u,u=r.p),m=1}else if(m===1)if(o===120||o===117||o===85){let c=r.p++-1,b=0,w=o===120?2:o===117?4:8;for(let O=0;O<w;O++,r.p++){let A=r.s.charCodeAt(r.p),E=A>=48&&A<=57?A-48:A>=65&&A<=70?A-65+10:A>=97&&A<=102?A-97+10:-1;if(E<0)y.x("invalid non-hex character in unicode escape",r);b=b<<4|E}if(b<0||b>1114111||b>=55296&&b<=57343)y.x("invalid unicode escape",r,c);i+=String.fromCodePoint(b),u=r.p--,m=0}else if(a&&(o===32||o===9))m=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 y.x("unrecognised escape sequence",r);u=r.p+1,m=0}else if(o!==32&&o!==9){if(m===2)y.x("invalid escape: only line-ending whitespace may be escaped",r,u);m=!f&&o===92?1:0,u=r.p}y.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 Qe=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;class N 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(Qe);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 N(r);return o.#e=t,o}static wrapAsLocalDateTime(r){let t=new N(r);return t.#e=null,t}static wrapAsLocalDate(r){let t=new N(r);return t.#r=!1,t.#e=null,t}static wrapAsLocalTime(r){let t=new N(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 de(r,t){return r===32||r===9||r===10||r===13||t&&(r===t||r===44)||r===35}function Z(r,t){let o=r.p,s=r.s.charCodeAt(r.p);if(s===91||s===123){r.d--||y.x("document contains excessively nested structures. aborting.",r);let f=s===91?$e(r):ve(r);return r.d++,f}if(s===34||s===39)return K(r);if(s===116){if(r.s.charCodeAt(++r.p)!==114||r.s.charCodeAt(++r.p)!==117||r.s.charCodeAt(++r.p)!==101)y.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)y.x("invalid value",r,o);return r.p++,!1}if(s===43||s===45)return q(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 en(r,s,t);if(r.s.charCodeAt(r.p+2)===58)return nn(r,s,t);return q(r,r.p,s,0,t)}function q(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)y.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)y.x("invalid value",r,t);return r.p++,NaN}if(a===48){if(++r.p>=r.s.length||de(a=r.s.charCodeAt(r.p),f))return r.bi===!0?0n:0;if(!s){if(a===120)return fe(r,t,16,f);else if(a===98)return fe(r,t,2,f);else if(a===111)return fe(r,t,8,f)}if(a===46)i=2;else if(a===101||a===69)i=4;else y.x("illegal leading zero",r,t)}else if(!C(a))y.x("invalid value",r,t);while(++r.p<r.s.length&&(a=r.s.charCodeAt(r.p),!de(a,f))){if(!i)i=1;if(a===95){if(!(i&1))y.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))y.x("illegal character in numeric literal",r);else if(i>9)i-=11;else if(!(i&1))i++}if(!i){let c=(o-48)*(s||1);return r.bi===!0?BigInt(c):c}if(!(i&1))y.x("unfinished numeric value",r,t);let m=r.s.slice(t,r.p);if(u)m=m.replaceAll("_","");return i>1?parseFloat(m):Oe(r,m,10,t)}function fe(r,t,o,s){let f,a=1;while(++r.p<r.s.length&&(f=r.s.charCodeAt(r.p),!de(f,s)))if(f===95){if(a&1)y.x("illegal underscore",r);a=3}else if(!C(f,o))y.x("illegal character in numeric literal",r);else if(a&1)a--;if(a&1)y.x("unfinished numeric value",r);let i=r.s.slice(t+2,r.p);if(a)i=i.replaceAll("_","");return Oe(r,i,o,t)}function Oe(r,t,o,s){if(r.bi!==!0)e:{let f=parseInt(t,o);if(!Number.isSafeInteger(f)){if(r.bi)break e;y.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 en(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 q(r,r.p=s,t,0,o);if(r.p+=5,!C(r.s.charCodeAt(r.p++)))y.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 z(r,i,3,!1,s)}if(r.s.charCodeAt(r.p+=3)!==58)y.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 z(r,i,1,f,s,"[+00:00]")}if(t===43||t===45){let i=r.s.slice(s,r.p+=6);return z(r,i,1,f,s,!r.ld&&"["+r.s.slice(r.p-6,r.p)+"]")}}let a=r.s.slice(s,r.p);return z(r,a,2,f,s)}function nn(r,t,o){let s=r.p;if(!C(t)||!C(r.s.charCodeAt(++r.p)))return q(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 z(r,f,4,!1,s)}function z(r,t,o,s,f,a){if(r.ld){let i=new N(t,o,s);if(!i.isValid())y.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){y.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 rn(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)y.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;rn(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 Y(r,t=61){let o,s=0,f=[],a,i=r.s.charCodeAt(o=r.p);do if(i===t){if(!s)y.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)y.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))y.x("illegal quoted key: multiline strings are not allowed",r);f.push(K(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)y.x("illegal character in key",r);else if(!s)s=1,a=r.p;while(i=r.s.charCodeAt(++r.p));y.x("incomplete key-value: cannot find end of key",r,o)}function ve(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,m=r.p,c=Y(r);for(let w=0;w<c.length;w++){if(w)i=u?i[a]:i[a]=Object.create(null);if(a=c[w],(u=Object.hasOwn(i,a))&&(typeof i[a]!=="object"||s.has(i[a])))y.x("trying to redefine an already defined value",r,m);let O=a==="__proto__";if(r.uk&&(O||a==="constructor")){i=r.uk!==1&&y.x("document contains an unsafe property",r,m);break}if(!u&&O)Object.defineProperty(i,a,{enumerable:!0,configurable:!0,writable:!0})}if(u)y.x("trying to redefine an already defined value",r,m);T(r,!0,!0);let b=Z(r,125);if(i&&typeof(i[a]=b)==="object")s.add(b);if(T(r),(f=r.s.charCodeAt(r.p++))===125)return o;if(f!==44)y.x("expected comma or end of structure",r,r.p-1)}y.x("unfinished table",r,t)}function $e(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(Z(r,93)),T(r),(s=r.s.charCodeAt(r.p++))===93)return o;if(s!==44)y.x("expected comma or end of structure",r,r.p-1)}y.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 je(r,t,o,s,f){let a=o,i=s,u,m=!1,c;for(let b=0;b<t.length;b++){if(b){if(a=m?a[u]:a[u]=Object.create(null),i=(c=i[u]).c,f===0&&(c.t===1||c.t===2))return null;if(c.t===2){let w=a.length-1;a=a[w],i=i[w].c}}if(u=t[b],(m=Object.hasOwn(a,u))&&i[u]?.t===0&&i[u]?.d)return null;if(!m){let w=u==="__proto__";if(r.uk&&(w||u==="constructor"))return!1;if(w)Object.defineProperty(a,u,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(i,u,{enumerable:!0,configurable:!0,writable:!0});i[u]={t:b<t.length-1&&f===2?3:f,d:!1,i:0,c:Object.create(null)}}}if(c=i[u],c.t!==f&&!(f===1&&c.t===3))return null;if(f===2){if(!c.d)c.d=!0,a[u]=[];a[u].push(a=Object.create(null)),c.c[c.i++]=c={t:1,d:!1,i:0,c:Object.create(null)}}if(c.d)return null;if(c.d=!0,f===1)a=m?a[u]:a[u]=Object.create(null);else if(f===0&&m)return null;return[u,a,c.c]}function Ee(r,t,o){if(t===null||r.uk===2)y.x(t===null?"trying to redefine an already defined table or value":"document contains an unsafe property",r,o)}function pe(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,m=f;if(r.charCodeAt(0)===65279)o.p++;T(o);while(o.p<r.length){if(r.charCodeAt(o.p)===91){let c=r.charCodeAt(++o.p)===91;a=o.p+=+c,i=!1;let b=Y(o,93);if(c){if(r.charCodeAt(o.p)!==93)y.x("expected end of table array declaration",o);o.p++}let w=je(o,b,s,f,c?2:1);if(!w)Ee(o,w,a),i=!0;else m=w[2],u=w[1]}else{a=o.p;let c=Y(o),b=je(o,c,u,m,0);if(!b&&!i)Ee(o,b,a);T(o,!0,!0);let w=Z(o,void 0);if(b&&!i)b[1][b[0]]=w}if(T(o,!0),o.p<r.length&&(a=r.charCodeAt(o.p))!==10&&(a!==13||r.charCodeAt(o.p+1)!==10))y.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 er=!!"".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 Ne(r){let t=V(r);if(t===void 0||t.trim()==="")return;let o=U(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 _e(r,t,o){let s=U(t)??{},f=De(s),a=o.reduce((m,c)=>{if(c.type==="key"){if(c.value===void 0)delete f[c.key];else f[c.key]=c.value;return on(m,c.key,c.value)}if(c.type==="remove")return gn(f,c.path),an(m,c.path);return hn(f,c.path,c.entries),ln(m,c.path,c.entries)},t),i=/^\s*\n/.test(t)?a:a.replace(/^\s*\n/,""),u=U(i);if(!u||ee(u)!==ee(f))throw Error(`${r} couldn't be updated without changing settings setup doesn't own, so it was left alone.`);return i}function B(r,t){return t.reduce((o,s)=>D(o)?o[s]:void 0,r)}function X(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(X).join(", ")}]`;if(D(r))return`{ ${Object.entries(r).filter(([,t])=>t!==void 0).map(([t,o])=>`${Q(t)} = ${X(o)}`).join(", ")} }`;throw Error(`Can't write ${String(r)} as TOML`)}function Q(r){return/^[A-Za-z0-9_-]+$/.test(r)?r:JSON.stringify(r)}function D(r){return typeof r==="object"&&r!==null&&!Array.isArray(r)&&!(r instanceof Date)}function U(r){try{return pe(r)}catch{return}}function on(r,t,o){let s=r.split(`
|
|
241
|
+
`),f=s.findIndex(ce),a=f===-1?s.length:f,i=s.slice(0,a).findIndex((c)=>un(c)===t),u=o===void 0?[]:[`${Q(t)} = ${X(o)}`];if(i!==-1)return[...s.slice(0,i),...u.map((c)=>`${c}${sn(s[i])}`),...s.slice(i+1)].join(`
|
|
242
|
+
`);if(o===void 0)return r;let m=s.slice(0,a).findLastIndex((c)=>c.trim()!==""&&!c.trim().startsWith("#"));return[...s.slice(0,m+1),...u,...s.slice(m+1)].join(`
|
|
243
|
+
`)}function sn(r){let t=[...r.matchAll(/#/g)].map((o)=>o.index).find((o)=>U(r.slice(0,o))!==void 0);return t===void 0?"":r.slice(r.slice(0,t).trimEnd().length)}function an(r,t){let o=r.split(`
|
|
244
|
+
`),s=o.findIndex((m)=>ce(m)&&!m.trim().startsWith("[[")&&cn(pn(m),t));if(s===-1)return r;let f=o.slice(s+1).findIndex(ce),a=f===-1?o.length:s+1+f,i=o.slice(0,a).findLastIndex((m)=>m.trim()!=="")+1,u=o.slice(0,s).findLastIndex((m)=>m.trim()!=="")+1;return[...o.slice(0,u),...o.slice(i)].join(`
|
|
245
|
+
`)}function ln(r,t,o){let s=Object.entries(o).filter(([,a])=>a!==void 0).map(([a,i])=>`${Q(a)} = ${X(i)}`),f=r.replace(/\s*$/,"");return`${f===""?"":`${f}
|
|
246
|
+
|
|
247
|
+
`}[${t.map(Q).join(".")}]
|
|
248
|
+
${s.join(`
|
|
249
|
+
`)}
|
|
250
|
+
`}function ce(r){return/^\s*\[/.test(r)}function un(r){let t=r.match(/^\s*(?:([A-Za-z0-9_-]+)|"((?:[^"\\]|\\.)*)"|'([^']*)')\s*=/);if(!t)return;let o=t[2]===void 0?void 0:U(`k = "${t[2]}"`)?.k;return t[1]??t[3]??(typeof o==="string"?o:void 0)}function pn(r){let t=U(`${r}
|
|
251
|
+
`),o=[],s=t;while(D(s)&&Object.keys(s).length===1){let f=Object.keys(s)[0];o.push(f),s=s[f]}return o}function De(r){return Object.fromEntries(Object.entries(r).map(([t,o])=>[t,Pe(o)]))}function Pe(r){if(Array.isArray(r))return r.map(Pe);if(D(r))return De(r);return r}function cn(r,t){return r.length===t.length&&r.every((o,s)=>o===t[s])}function hn(r,t,o){let s=t.slice(0,-1).reduce((f,a)=>{let i=f[a];if(D(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 gn(r,t){let o=B(r,t.slice(0,-1));if(D(o))delete o[t.at(-1)]}function ee(r){if(Array.isArray(r))return`[${r.map(ee).join(",")}]`;if(r instanceof Date)return JSON.stringify(r.toISOString());if(D(r))return`{${Object.keys(r).toSorted().map((t)=>[t,ee(r[t])]).filter(([,t])=>t!=="{}").map(([t,o])=>`${JSON.stringify(t)}:${o}`).join(",")}}`;return JSON.stringify(r)}function wn(r=process.env,t=bn.homedir()){let o=r.CODEX_HOME?.trim(),s=o?Re(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:(V(f)?.trim()??"")===""?S.join(s,"AGENTS.md"):f}}function Re(r){if(me(r))return yn(r);let t=S.dirname(r);return t===r?r:S.join(Re(t),S.basename(r))}function Je(r,t,o){let s=hr(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 Ue(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"&&io(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 An=n({baseURL:e,catalogURL:e,model:e,count:H}),We=n({paths:n({home:e,config:e,hooks:e,rules:e,skills:e,memory:e}),command:l(e),harness:g(e),environment:x(e,e),...pr,tables:l(l(e)),servers:l(e),skills:x(e,e),memoryCreated:v,created:n({config:v,hooks:v}),providers:g(e),models:g(Le(An)),keepProvider:g(v),usage:g(d("shared"))}),re=(r)=>S.join(r.data,"codex.json");function te(r){let t=re(r),o=V(t);if(o===void 0)return;let s=L(W(G(We))(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 ne="opencode-console",he=["hook","codex"],Cn=R("Codex.refresh")(function*(r,t){let o=te(r),s=t??o;if(!s)return;let f=yield*ze(r),a=f&&He(r,be(f));if(!f||!a?.config)return;let i=a.config,u=Ot(a),m=xe("sha256").update(JSON.stringify(i.providers??null)).digest("hex"),c=!t&&o?.providers===m&&o.models!==void 0,b=t?t.keepProvider===!0:o?.keepProvider===!0,w=b?void 0:c?o.models??void 0:yield*pt([_t(f),_s(f)],{concurrency:2}).pipe(h(([j,P])=>Je(j,P,f.server))),O=yield*dn(f,s.paths.skills,u,o?.skills??{}),A=xr(f,a),E=yield*Ie([{action:"websearch:",resources:["*"],truncated:!0},{action:"websearch.use",resources:["openai"]}],(j)=>lr(A,j));return yield*Ae(r,I(()=>Tn(r,{paths:s.paths,command:s.command,harness:t?t.harness:o?.harness,environment:t?t.environment??{}:o?.environment??{},models:w,servers:Object.fromEntries(Object.entries(et(a)).map(([j,P])=>[j,{url:P.url,gateway:P.headers!==void 0}])),instructions:lt(a),skills:u,bundles:O,rules:Ue(fs(A)??[]),searchOff:E.some((j)=>j.effect==="deny"),providers:m,keepProvider:b,telemetry:a.telemetry,explicit:t!==void 0})))});function Sn(r){let t=te(r);if(!t)return!1;let o=Ne(t.paths.config),s=St(t.paths.hooks),f=V(t.paths.memory),a=o&&_e(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)=>B(o.value,i)!==void 0).map((i)=>({type:"remove",path:i}))]);if(o&&a!==void 0){if(a.trim()===""&&t.created.config)J(t.paths.config);else if(a!==o.text)wt(t.paths.config,a)}if(s)if(Fe(s),Object.keys(s).length===0&&t.created.hooks)J(t.paths.hooks);else vt(t.paths.hooks,s);return J(t.paths.rules),Object.keys(t.skills).forEach((i)=>kn(S.join(t.paths.skills,i),{recursive:!0,force:!0})),ur(t.paths.memory,f,[],t.memoryCreated),[t.paths.config,t.paths.hooks].forEach((i)=>J(Xe(i))),J(re(r)),!0}function Tn(r,t){let o=te(r),s=me(t.paths.config),f=me(t.paths.hooks),a=Ne(t.paths.config)??{text:"",value:{}},i=St(t.paths.hooks)??{},u=V(t.paths.memory),m=o?.created??{config:!s,hooks:!f},c=[],b=t.models||!t.telemetry?void 0:"shared";Fe(i);let w=_(i.hooks),O=[...t.command,...t.harness===void 0?[]:["--harness",t.harness]],A=$n(O,b==="shared").map(([p,M])=>{let Te=[...Array.isArray(w[p])?w[p]:[],M];return w[p]=Te,{event:p,group:M,index:Te.length-1}});i.hooks=w;let E={...a.value},{originals:j,written:P}=fr(E,On(t),o,t.explicit),Ve=[...new Set([...Object.keys(o?.originals??{}),...Object.keys(j)])].flatMap((p)=>JSON.stringify(E[p])===JSON.stringify(a.value[p])?[]:[{type:"key",key:p,value:E[p]}]),oe=new Map((o?.tables??[]).map((p)=>[JSON.stringify(p),p])),ie=(p)=>!oe.has(JSON.stringify(p))&&B(a.value,p)!==void 0,ye=["model_providers",ne];if(t.models&&ie(ye))throw Error(`${t.paths.config} already has a model provider named ${ne}, so Codex was left as it is. Rename it and run setup again.`);let se=Object.entries(t.servers).flatMap(([p,M])=>{if(M.url===void 0||!/^[a-z0-9_-]+$/i.test(p))return[];if(ie(["mcp_servers",p]))return c.push(p),[];return[{name:p,url:M.url,gateway:M.gateway}]}),ke=A.map((p)=>({path:["hooks","state",`${t.paths.hooks}:${Be(p.event)}:${p.index}:0`],hash:Ze(p.event,p.group)})),ae=[...t.models?[{path:[...ye],entries:vn(t)}]:[],...se.map((p)=>({path:["mcp_servers",p.name],entries:{url:p.url,...p.gateway?{http_headers_helper:Bn([...In(t.environment),...O,"mcp-headers",p.name])}:{}}})),...ke.map((p)=>({path:p.path,entries:{trusted_hash:p.hash}}))],Ge=(p)=>oe.has(JSON.stringify(p.path))&&F(B(a.value,p.path))===F(p.entries),we=new Set(ae.filter(Ge).map((p)=>JSON.stringify(p.path))),Ce=_e(t.paths.config,a.text,[...Ve,...[...oe].filter(([p])=>!we.has(p)).map(([,p])=>p).filter((p)=>B(a.value,p)!==void 0).map((p)=>({type:"remove",path:p})),...ke.filter((p)=>ie(p.path)).map((p)=>({type:"remove",path:p.path})),...ae.filter((p)=>!we.has(JSON.stringify(p.path))).map((p)=>({type:"table",path:p.path,entries:p.entries}))]);if(!o)[t.paths.config,t.paths.hooks].forEach(fn);if(Ce!==a.text)wt(t.paths.config,Ce,384);if(vt(t.paths.hooks,i,384),t.rules.length>0)Nn(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 J(t.paths.rules);let le=mn(t.paths.skills,t.skills,t.bundles,o?.skills??{});c.push(...le.skipped);let Ke=ur(t.paths.memory,u,t.instructions,o?.memoryCreated??!1);return Se(re(r),JSON.stringify(We.make({paths:t.paths,command:[...t.command],...t.harness===void 0?{}:{harness:t.harness},environment:{...t.environment},originals:j,written:P,tables:ae.map((p)=>p.path),servers:se.map((p)=>p.name),skills:le.skills,memoryCreated:Ke,created:m,providers:t.providers,models:t.models??null,...t.keepProvider?{keepProvider:!0}:{},...b===void 0?{}:{usage:b}}))),{models:t.models,servers:se.map((p)=>p.name),skills:Object.keys(le.skills),instructions:t.instructions.length,rules:t.rules.length,searchOff:t.searchOff,skipped:c,keepProvider:t.keepProvider,usage:b}}function On(r){return{...r.models?{model_provider:ne,model:r.models.model}:{},...r.searchOff?{web_search:"disabled"}:{}}}function vn(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 $n(r,t){let o=Bn([...r,...he]);return[["PreToolUse",{matcher:"*",hooks:[{type:"command",command:o,timeout:30}]}],["UserPromptSubmit",{hooks:[{type:"command",command:o,timeout:30}]}],["SessionStart",{hooks:[{type:"command",command:o,timeout:10}]}],...t?[["PostModelRequest",{hooks:[{type:"command",command:o,timeout:10}]}]]:[]]}function Ze(r,t){let o=t.hooks[0],s={event_name:Be(r),...t.matcher===void 0?{}:{matcher:t.matcher},hooks:[{type:o.type,command:o.command,timeout:o.timeout,async:o.async===!0}]};return`sha256:${xe("sha256").update(F(s)).digest("hex")}`}function Be(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(D(r))return`{${Object.keys(r).toSorted().map((t)=>`${JSON.stringify(t)}:${F(r[t])}`).join(",")}}`;return JSON.stringify(r)}function Fe(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((m)=>!En(m));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 En(r){let t=_(r).command;return typeof t==="string"&&t.endsWith(` ${he.join(" ")}`)}function In(r){let t=Object.entries(r);if(t.length===0||process.platform==="win32")return[];return["env",...t.map(([o,s])=>`${o}=${s}`)]}function Nn(r,t){if(V(r)!==t)wt(r,t)}export{ge as Codex,ne as PROVIDER,he as hookArgs,te as manifest,re as manifestFile,Je as models,wn as paths,Cn as refresh,Sn as remove,Ue as rules,Ze as trustHash};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{wr,po,fo,$s,Fi}from"./chunk-w7jwta9c.js";export{Fi as FetchHttpClient,$s as HttpClient,wr as HttpClientError,po as HttpClientRequest,fo as HttpClientResponse};
|