@opencode/console 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/THIRD_PARTY_LICENSES.md +27 -0
- package/chunk-03p95nje.js +6 -0
- package/chunk-2ktsq2gj.js +3 -0
- package/chunk-2y9vn023.js +1 -0
- package/chunk-5q7mrvv1.js +2 -0
- package/chunk-5w6hy202.js +1 -0
- package/chunk-6mydq7cv.js +2 -0
- package/chunk-6rpbc10h.js +2 -0
- package/chunk-81fv1abj.js +2 -0
- package/chunk-aym5xapq.js +1 -0
- package/chunk-bkr0zk6g.js +32 -0
- package/chunk-c16zjbe1.js +2 -0
- package/chunk-c9kvdzct.js +1 -0
- package/chunk-eyf3z07t.js +1 -0
- package/chunk-frqdgjbd.js +17 -0
- package/{chunk-z2kmm4pm.js → chunk-fzckrdm3.js} +2 -2
- package/chunk-hpy9mszv.js +1 -0
- package/chunk-jh21wbwd.js +2 -0
- package/chunk-kdkxhbxc.js +3 -0
- package/chunk-kvqewrn5.js +1 -0
- package/chunk-mpmqsnkz.js +1 -0
- package/chunk-mzpdnb17.js +1 -0
- package/chunk-nvh2a5rc.js +254 -0
- package/chunk-p59r4b0j.js +2 -0
- package/chunk-p7wsm5k0.js +1 -0
- package/chunk-sn451nak.js +2 -0
- package/chunk-vqmbpbbm.js +1 -0
- package/{chunk-g6d8xejf.js → chunk-wjghq897.js} +54 -54
- package/chunk-xeq3evq0.js +1 -0
- package/chunk-zdf3mvav.js +2 -0
- package/index.js +59 -44
- package/package.json +3 -2
- package/pi-extension.js +2 -2
- package/chunk-0krh2hdf.js +0 -1
- package/chunk-1c689590.js +0 -1
- package/chunk-1mfjsp5r.js +0 -2
- package/chunk-41p6m0xy.js +0 -6
- package/chunk-4v6awhyw.js +0 -1
- package/chunk-52p33kcn.js +0 -1
- package/chunk-5x5fc0mq.js +0 -2
- package/chunk-6tene1pb.js +0 -2
- package/chunk-9pcmbxq5.js +0 -1
- package/chunk-a85j5cz4.js +0 -1
- package/chunk-bgqw45qt.js +0 -2
- package/chunk-dsk7ztf6.js +0 -2
- package/chunk-gtf5exm1.js +0 -8
- package/chunk-hf4hqs7y.js +0 -3
- package/chunk-jqhy4pzf.js +0 -2
- package/chunk-ke4nwx54.js +0 -2
- package/chunk-nva98fq1.js +0 -32
- package/chunk-p909n1zf.js +0 -1
- package/chunk-q3519h2y.js +0 -1
- package/chunk-r2y8x1nz.js +0 -12
- package/chunk-rea503jg.js +0 -1
- package/chunk-sbec97g3.js +0 -2
- package/chunk-vx37gkw9.js +0 -1
- package/chunk-wb6qf86j.js +0 -1
- package/chunk-yjw665b0.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./chunk-zdf3mvav.js";import{k,H,w,F,t,n,Z}from"./chunk-bkr0zk6g.js";var g={};k(g,{CodexHook:()=>g,Unreadable:()=>d,checks:()=>P,decode:()=>E,mentions:()=>y,patchFiles:()=>m});import f from"node:path";var S=n({hook_event_name:t,cwd:w(t),tool_name:w(t),tool_input:w(F),prompt:w(t)}),E=H(Z(S));class d extends Error{}function P(s,l){let o=(e,u,v={})=>({action:e,resources:u,directory:l.directory,...v});if(s.hook_event_name==="UserPromptSubmit"){let e=y(s.prompt??"");return[...e.skills.length===0?[]:[o("skill",e.skills)],...e.servers.length===0?[]:[o("mcp.use",e.servers)],...e.plugins.length===0?[]:[o("plugin.use",e.plugins)]]}if(s.hook_event_name!=="PreToolUse")return[];let i=s.tool_name;if(!i)throw new d("The hook input names no tool");let r=s.cwd?f.resolve(l.directory,s.cwd):l.directory;if(i.startsWith("mcp__"))return M(i,l.servers).map((e)=>o(e.action,e.resources,e));let c=s.tool_input,p=(e)=>{let u=typeof c==="object"&&c!==null&&e in c?Reflect.get(c,e):void 0;return typeof u==="string"&&u!==""?u:void 0},a=(e)=>{let u=p(e);if(u===void 0)throw new d(`${i}'s input has no ${e}`);return u},_=l.platform==="win32"?{shell:"pwsh"}:{};switch(i){case"Bash":{let e=a("command"),u=e.includes("*** Begin Patch")?m(e,r):[];return[o("shell",[e],{..._,...r===l.directory?{}:{path:r}}),...u.length===0?[]:[o("edit",u)]]}case"apply_patch":{let e=m(a("command"),r);if(e.length===0)throw new d("The patch names no file");return[o("edit",e)]}case"view_image":return[o("read",[f.resolve(r,a("path"))])];case"request_user_input":case"request_user_input_async":return[o("question",["*"])];case"read_mcp_resource":return[o("mcp.use",[a("server")])];case"list_mcp_resources":case"list_mcp_resource_templates":{let e=p("server");return[o("mcp.use",e?[e]:[...l.servers,"*"])]}case"request_plugin_install":{let e=a(p("tool_id")===void 0?"plugin_id":"tool_id");return[o(p("tool_type")==="connector"?"mcp.use":"plugin.use",[e])]}default:if(i==="spawn_agent"||i.endsWith(".spawn_agent")){let e=p("agent_type")?.trim().toLowerCase()||void 0;return[o("subagent",[e===void 0||e==="default"?"general":e])]}return[o(i.toLowerCase(),["*"])]}}function m(s,l){let o=["*** Add File: ","*** Update File: ","*** Delete File: ","*** Move to: "];return[...new Set(s.split(`
|
|
2
|
+
`).flatMap((i)=>{let r=i.trim(),c=o.find((a)=>r.startsWith(a)),p=c&&r.slice(c.length).trim();return p?[f.resolve(l,p)]:[]}))]}function M(s,l){let o=l.filter((a)=>s.startsWith(`mcp__${h(a)}__`)).toSorted((a,_)=>_.length-a.length)[0],i=s.match(/^mcp__(.+?)__(.+)$/),r=o??i?.[1]?.replace(/_[0-9a-f]{12}$/,"");if(!r)throw new d(`Can't tell which MCP server ${s} belongs to`);let c=o?s.slice(`mcp__${h(o)}__`.length):i?.[2],p=c===void 0||/_[0-9a-f]{12}$/.test(s);return[{action:"mcp.use",resources:[r],...o?{}:{folded:!0}},p?{action:`${r}_`,resources:["*"],truncated:!0,folded:!0}:{action:`${r}_${c}`,resources:["*"],folded:!0}]}function h(s){return s.replace(/[^A-Za-z0-9_]/g,"_")}var T=new Set(["PATH","HOME","USER","SHELL","PWD","TMPDIR","TEMP","TMP","LANG","TERM","XDG_CONFIG_HOME"]);function y(s){let l=Array.from(s.matchAll(/(?:\[\$([A-Za-z0-9_:-]+)\]\(([^)]*)\))|\$([A-Za-z0-9_:-]+)/g),(r)=>({name:r[1]??r[3],link:r[1]===void 0?void 0:r[2].trim()})).filter((r)=>!T.has(r.name.toUpperCase())),o=(r)=>l.flatMap((c)=>c.link?.startsWith(r)?[c.link.slice(r.length).split(/[/?]/)[0]].filter(Boolean):[]),i=l.flatMap((r)=>r.link===void 0?/^[A-Z0-9_]+$/.test(r.name)?[]:[r.name]:/(?:^skill:\/\/|SKILL\.md$)/i.test(r.link)?[r.name]:[]);return{skills:[...new Set(i)],servers:[...new Set(o("mcp://"))],plugins:[...new Set(o("plugin://"))]}}export{g as CodexHook,d as Unreadable,P as checks,E as decode,y as mentions,m as patchFiles};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Qs,Xs,Xo,es,ts,sr,ei,ir,Xi,ns}from"./chunk-6mydq7cv.js";import"./chunk-5q7mrvv1.js";import"./chunk-81fv1abj.js";import"./chunk-p59r4b0j.js";import"./chunk-2y9vn023.js";import"./chunk-6rpbc10h.js";import"./chunk-zdf3mvav.js";export{Xs as Info,Qs as MAX_AGE_MS,ns as WorkspaceSnapshot,ts as clear,Xi as models,ei as policies,Xo as read,sr as stale,ir as workspace,es as write};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Zi,Ro,Mo,Br,Fo,No,Do,Uo,zr,Tn,Hr,$o,Yi,Qi,Lo,jo,On,Xn,it,Js,Bo,zo,Ho}from"./chunk-03p95nje.js";import"./chunk-wjghq897.js";import"./chunk-fzckrdm3.js";import"./chunk-sn451nak.js";import"./chunk-frqdgjbd.js";import"./chunk-6mydq7cv.js";import"./chunk-5q7mrvv1.js";import"./chunk-81fv1abj.js";import"./chunk-p59r4b0j.js";import"./chunk-2y9vn023.js";import"./chunk-6rpbc10h.js";import"./chunk-zdf3mvav.js";export{Ho as Pi,Br as Unreadable,Fo as checks,it as config,On as decide,Xn as decisions,Mo as defaultModel,Tn as directory,Uo as instructions,$o as manifest,zr as manifestFile,Bo as models,Hr as modelsFile,Zi as paths,Ro as providers,jo as refresh,Js as refreshStale,Qi as remove,Lo as session,Yi as setup,Do as skillCommand,zo as skills,No as userBash};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{us,ps}from"./chunk-p59r4b0j.js";import{ne,J}from"./chunk-6rpbc10h.js";import{k,De,N,be,r,W,h,D,H,w,F,t,n,x,p,Z}from"./chunk-bkr0zk6g.js";var Qo={};k(Qo,{Library:()=>Qo,fetchChanged:()=>tn,library:()=>gt,servers:()=>en,skillMarkdown:()=>Ys,write:()=>nn,writeInstructions:()=>rn});import{randomUUID as v}from"node:crypto";import{existsSync as b,mkdirSync as Q,renameSync as j,rmSync as O}from"node:fs";import g from"node:path";import{randomUUID as I}from"node:crypto";import{chmodSync as M,copyFileSync as B,existsSync as y,mkdirSync as K,renameSync as _,rmSync as z,statSync as T,writeFileSync as q}from"node:fs";import G from"node:path";var tr={originals:x(t,n({value:w(F)})),written:x(t,F)};function at(e){let o=ne(e);if(o===void 0||o.trim()==="")return;let i=N(H(Z(F))(o));if(typeof i!=="object"||i===null||Array.isArray(i))throw Error(`${e} isn't valid JSON, so it was left alone. Fix it and run setup again.`);return{...i}}function ct(e,o,i){let s=`${JSON.stringify(o,null,2)}
|
|
2
|
+
`;if(ne(e)===s)return;Rn(e,s,i)}function nr(e,o,i,s){let c={...i?.originals},d={...i?.written};return Object.keys(c).filter((a)=>!(a in o)).forEach((a)=>{Pn(e,a,{originals:c,written:d}),delete c[a],delete d[a]}),Object.entries(o).forEach(([a,u])=>{if(a in d&&JSON.stringify(Wr(e,a))!==JSON.stringify(d[a])&&!s)return;if(!(a in c))c[a]=P(e,a);Yo(e,a,u),d[a]=u}),{originals:c,written:d}}function Pn(e,o,i){if(JSON.stringify(Wr(e,o))!==JSON.stringify(i.written[o]))return;let s=i.originals[o];if(s&&"value"in s&&s.value!==void 0)Yo(e,o,s.value);else Zs(e,o)}function Wr(e,o){let[i,s]=S(o);return s===void 0?e[i]:U(e[i])[s]}function Yo(e,o,i){let[s,c]=S(o);if(c===void 0)e[s]=i;else e[s]={...U(e[s]),[c]:i}}function Zs(e,o){let[i,s]=S(o);if(s===void 0){delete e[i];return}let c=U(e[i]);if(delete c[s],Object.keys(c).length===0)delete e[i];else e[i]=c}var lt=(e)=>`${e}.opencode-console.bak`;function rr(e){if(!y(e)||y(lt(e)))return;B(e,lt(e)),M(lt(e),384)}function Rn(e,o,i=420){K(G.dirname(e),{recursive:!0});let s=`${e}.${I()}.tmp`;q(s,o,{mode:y(e)?T(e).mode&511:i,flag:"wx"});try{_(s,e)}catch(c){throw z(s,{force:!0}),c}}function U(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)?{...e}:{}}function Xt(e){return typeof e==="string"&&e!==""?e:void 0}function P(e,o){let i=Wr(e,o);return i===void 0?{}:{value:i}}function S(e){let o=e.indexOf(".");return o===-1?[e,void 0]:[e.slice(0,o),e.slice(o+1)]}function or(e){return e.map((o)=>process.platform==="win32"?`"${o.replaceAll('"','""')}"`:/^[\w@%+=:,./-]+$/.test(o)?o:`'${o.replaceAll("'",`'"'"'`)}'`).join(" ")}var V=n({instructions:w(p(n({name:t,content:t}))),skills:w(p(n({slug:t,version:t})))}),X=n({servers:x(t,n({type:t,url:w(t),headers:w(x(t,t))}))});function gt(e){let o=N(H(V)(e.library));return{instructions:o?.instructions??[],skills:(o?.skills??[]).filter((i)=>on(i.slug))}}function en(e){let o=De(H(X)(e.mcp),()=>({servers:{}})).servers;return Object.fromEntries(Object.entries(o).flatMap(([i,s])=>s.type==="remote"&&s.url!==void 0?[[i,{url:s.url,headers:s.headers}]]:[]))}var tn=D("Library.fetchChanged")(function*(e,o,i,s){return yield*be(i.filter((c)=>{let d=b(g.join(o,c.slug));if(d&&!(c.slug in s))return!1;return s[c.slug]!==c.version||!d}),(c)=>W(function*(){let d=yield*us(e,c.slug),a=yield*be(d.files,(u)=>u.kind==="text"?r({path:u.path,content:u.content}):ps(e,c.slug,u.sha256).pipe(h((l)=>({path:u.path,content:l}))),{concurrency:4});return{slug:c.slug,version:c.version,files:a}}),{concurrency:2})});function nn(e,o,i,s){let c={},d=[];return Object.keys(s).filter((a)=>!o.some((u)=>u.slug===a)).forEach((a)=>O(g.join(e,a),{recursive:!0,force:!0})),o.forEach((a)=>{let u=g.join(e,a.slug);if(b(u)&&!(a.slug in s)){d.push(`/${a.slug}`);return}let l=i.find((f)=>f.slug===a.slug);if(l)Y(u,l.files);c[a.slug]=l?.version??s[a.slug]??a.version}),{skills:c,skipped:d}}function Y(e,o){let i=`${e}.${v()}.tmp`,s=`${e}.${v()}.old`;Q(i,{recursive:!0});try{if(o.forEach((c)=>{let d=c.path.split(/[\\/]/);if(c.path===""||g.isAbsolute(c.path)||d.some((u)=>u===".."||u===""))return;let a=c.path==="SKILL.md"&&typeof c.content==="string"?Ys(c.content):c.content;Rn(g.join(i,c.path),a)}),b(e))j(e,s);j(i,e)}finally{O(i,{recursive:!0,force:!0}),O(s,{recursive:!0,force:!0})}}var m="<!-- opencode-console:start -->",R="<!-- opencode-console:end -->";function rn(e,o,i,s){if(i.length===0&&!o?.includes(m))return s;let c=(o??"").replace(new RegExp(`\\n*${m}[\\s\\S]*?${R}\\n?`),`
|
|
3
|
+
`).trim(),d=(f)=>f.replaceAll(m,"<!-- opencode-console start -->").replaceAll(R,"<!-- opencode-console end -->"),a=i.length===0?"":[m,"# Workspace instructions from OpenCode Console",...i.map((f)=>`## ${d(f.name)}
|
|
4
|
+
|
|
5
|
+
${d(f.content.trim())}`),R].join(`
|
|
6
|
+
|
|
7
|
+
`),u=[c,a].filter((f)=>f!=="").join(`
|
|
8
|
+
|
|
9
|
+
`),l=s||o===void 0&&a!=="";if(u===""&&l)return J(e),!1;if(`${u}
|
|
10
|
+
`!==o)Rn(e,`${u}
|
|
11
|
+
`);return l}function Ys(e){let o=e.match(/^---\n([\s\S]*?)\n---\n/);if(!o)return e;let i=o[1].split(`
|
|
12
|
+
`),s=i.some((u)=>/^\s*"?opencode\/autoinvoke"?:\s*false\s*$/.test(u)),d=[...i.filter((u,l)=>{if(u.startsWith("name:"))return!1;if(/^metadata:\s*$/.test(u))return i[l+1]?.trim().startsWith('"opencode/autoinvoke"')!==!0;return!/^\s+"opencode\/autoinvoke":/.test(u)}),...s?["disable-model-invocation: true"]:[]],a=e.slice(o[0].length);return d.length===0?a.replace(/^\n/,""):`---
|
|
13
|
+
${d.join(`
|
|
14
|
+
`)}
|
|
15
|
+
---
|
|
16
|
+
${a}`}function on(e){return/^[a-z0-9][a-z0-9._-]*$/i.test(e)&&e.toLowerCase()!=="synced"}
|
|
17
|
+
export{tr,at,ct,nr,Pn,Wr,Yo,Zs,lt,rr,Rn,U,Xt,or,gt,en,tn,nn,rn,Ys,Qo};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
export{
|
|
1
|
+
import{U,Xt}from"./chunk-frqdgjbd.js";function _n(t){return Object.entries(t).toSorted(([e],[o])=>i(e)-i(o)).flatMap(([e,o])=>Object.entries(o.models).flatMap(([n,r])=>s(r)?[{provider:e,providerName:o.name,id:n,entry:r}]:[]))}function Ko(t,...e){let o=(n)=>t.filter((r)=>r.id.toLowerCase().includes("claude")&&r.id.toLowerCase().includes(n)).toSorted((r,a)=>i(r.provider)-i(a.provider)||d(a).localeCompare(d(r)))[0];return e.map(o).find((n)=>n!==void 0)??t[0]}function Go(t){return t.flatMap((e)=>Object.values(U(e.entry.api))).flatMap((e)=>Xt(U(e).base_url)??[]).map((e)=>e.match(/^(https?:\/\/.+?)\/(?:go\/)?(?:anthropic\/v1|openai\/v1|google\/v1beta|v1)\/?$/)?.[1]??e.match(/^(https?:\/\/.+?)\/custom\/[^/]+(?:\/.*)?$/)?.[1]).find((e)=>e!==void 0)}function s(t){let e=U(U(t.capabilities).tools).supported,o=U(t.modalities).output;return(t.type??"chat")==="chat"&&e!==!1&&(!Array.isArray(o)||o.includes("text")&&!o.includes("audio"))}function d(t){return Xt(t.entry.release_date)??""}function i(t){return t==="opencode"?0:t==="opencode-go"?1:2}
|
|
2
|
+
export{_n,Ko,Go};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Jo,Vs,Vo,ht,Zo}from"./chunk-sn451nak.js";import"./chunk-6mydq7cv.js";import"./chunk-5q7mrvv1.js";import"./chunk-81fv1abj.js";import"./chunk-p59r4b0j.js";import"./chunk-2y9vn023.js";import"./chunk-6rpbc10h.js";import"./chunk-zdf3mvav.js";export{Zo as WorkspaceSync,ht as current,Jo as identify,Vo as sync,Vs as userAgent};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import"./chunk-zdf3mvav.js";import{k,N,H,w,F,t,n,x,Z}from"./chunk-bkr0zk6g.js";var h={};k(h,{ClaudeCodeHook:()=>h,Unreadable:()=>d,checks:()=>P,decode:()=>v,denial:()=>T,eventName:()=>C});var y=n({hook_event_name:t,cwd:w(t),tool_name:w(t),tool_input:w(x(t,F)),mcp_server:w(n({name:w(t)})),prompt:w(t),expansion_type:w(t),command_name:w(t)}),v=H(Z(y));class d extends Error{}var E={platform:process.platform,env:process.env};function P(e,a=E){let c=e.cwd,r=(s,i,f={})=>({action:s,resources:i,...c===void 0?{}:{directory:c},...f});if(e.hook_event_name==="UserPromptSubmit")return L(e.prompt??"").map((s)=>r(...s));if(e.hook_event_name==="UserPromptExpansion"){let s=e.command_name?.replace(/^\//,"");if(!s)throw new d("The expanded command has no name");if(e.expansion_type==="mcp_prompt"){let i=s.match(/^mcp__(.+?)__/)?.[1]??s.match(/^([^:]+):/)?.[1];if(!i)throw new d(`Can't tell which MCP server the prompt ${s} comes from`);return[r("mcp.use",[i])]}return[r("skill",[s])]}if(e.hook_event_name!=="PreToolUse")return[];let p=e.tool_name;if(!p)throw new d("The hook input names no tool");let o=e.tool_input??{},l=(...s)=>s.map((i)=>o[i]).find((i)=>typeof i==="string"&&i!==""),u=(...s)=>{let i=l(...s);if(i===void 0)throw new d(`${p}'s input has no ${s[0]}`);return i},g=a.env.CLAUDE_CODE_SHELL||(a.platform==="win32"?"bash":void 0),_=g===void 0?{}:{shell:g},m=M(p,e.mcp_server?.name);if(m)return[r("mcp.use",[m.server]),r(A(m.server,m.tool),["*"])];switch(p){case"Bash":return[r("shell",[u("command")],_)];case"PowerShell":return[r("shell",[u("command")],{shell:"pwsh"})];case"Monitor":{let s=l("command"),i=typeof o.ws==="object"&&o.ws!==null&&"url"in o.ws?o.ws.url:void 0,f=typeof i==="string"&&i!==""?i:void 0;if(s===void 0&&f===void 0)throw new d("Monitor's input has no command or ws.url");return[...s===void 0?[]:[r("shell",[s],_)],...f===void 0?[]:[r("webfetch",[f])]]}case"Edit":case"Write":case"MultiEdit":return[r("edit",[u("file_path")])];case"NotebookEdit":return[r("edit",[u("notebook_path")])];case"Read":return[r("read",[u("file_path")])];case"LSP":{let s=l("filePath","file_path","path");return[s===void 0?r("lsp",["*"]):r("read",[s])]}case"Glob":case"Grep":{let s=l("path");return[r(p.toLowerCase(),[u("pattern")],s===void 0?{}:{path:s})]}case"WebFetch":return[r("webfetch",[u("url")])];case"WebSearch":return[r("websearch",[u("query")])];case"Agent":case"Task":return[r("subagent",[S(l("subagent_type")??"general-purpose")])];case"Skill":return[r("skill",[u("skill","command","name").replace(/^\//,"")])];case"AskUserQuestion":return[r("question",["*"])];case"ReadMcpResourceTool":return[r("mcp.use",[u("server")])];case"ListMcpResourcesTool":{let s=l("server");return[r("mcp.use",[s??"*"])]}default:return[r(p.toLowerCase(),["*"])]}}function T(e,a){return{stdout:`${JSON.stringify(e==="PreToolUse"?{hookSpecificOutput:{hookEventName:"PreToolUse",permissionDecision:"deny",permissionDecisionReason:a}}:{decision:"block",reason:a})}
|
|
2
|
+
`,stderr:`${a}
|
|
3
|
+
`,code:2}}function C(e){return N(H(Z(n({hook_event_name:t})))(e))?.hook_event_name}function M(e,a){if(a&&e.startsWith(`mcp__${a}__`))return{server:a,tool:e.slice(`mcp__${a}__`.length)};let c=e.match(/^mcp__(.+?)__(.+)$/);return c?{server:c[1],tool:c[2]}:void 0}function A(e,a){return`${e}_${a.replace(/[^a-zA-Z0-9_-]/g,"_")}`}function S(e){let a=e.toLowerCase();return a==="general-purpose"?"general":a}function L(e){let a=Array.from(e.matchAll(/(?:^|\s)@(?:"([^"]+)"|(\S+))/g),(o)=>o[1]!==void 0?{quoted:o[1]}:{bare:o[2].replace(/[),.;!?]+$/,"")}),c=a.flatMap((o)=>("quoted"in o)?[o.quoted]:b(o.bare)?[o.bare]:[]),r=a.flatMap((o)=>("bare"in o)&&o.bare.startsWith("agent-")&&o.bare.length>6?[S(o.bare.slice(6))]:[]),p=a.flatMap((o)=>("bare"in o)&&!b(o.bare)&&!o.bare.startsWith("agent-")&&o.bare.includes(":")?[o.bare.slice(0,o.bare.indexOf(":"))].filter((l)=>l!==""):[]);return[...c.length===0?[]:[["read",c]],...r.length===0?[]:[["subagent",r]],...p.length===0?[]:[["mcp.use",p]]]}function b(e){if(e===""||e.startsWith("agent-"))return!1;return/^[A-Za-z]:[\\/]/.test(e)||!e.includes(":")}export{h as ClaudeCodeHook,d as Unreadable,P as checks,v as decode,T as denial,C as eventName};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{He,Kr,Fe,Mn,ea,xt,ta,rs}from"./chunk-5q7mrvv1.js";import"./chunk-p59r4b0j.js";import"./chunk-2y9vn023.js";import"./chunk-6rpbc10h.js";import"./chunk-zdf3mvav.js";export{rs as ConsoleCredentials,xt as fresh,ea as login,ta as logout,Mn as organization,Fe as owner,He as read,Kr as stored};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{gs,cn,Mt,xs,_e,ne,ys,ke,J,eo,bt,bs}from"./chunk-6rpbc10h.js";import"./chunk-zdf3mvav.js";export{bs as ConsoleStore,cn as credentialFile,bt as ensureDir,_e as locked,gs as make,ys as modified,ne as read,J as remove,Mt as snapshotFile,xs as syncClaimFile,eo as unreachable,ke as write};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{er,qo,qr,Wo}from"./chunk-wjghq897.js";import"./chunk-81fv1abj.js";import"./chunk-2y9vn023.js";import"./chunk-6rpbc10h.js";import"./chunk-zdf3mvav.js";export{Wo as PolicyEvaluator,er as check,qr as couldMatch,qo as statements};
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import"./chunk-zdf3mvav.js";import"./chunk-2y9vn023.js";import{on,Jr,ls}from"./chunk-p59r4b0j.js";import{_e,ne,ke,J}from"./chunk-6rpbc10h.js";import{Fe,xt}from"./chunk-5q7mrvv1.js";import{tr,at,ct,nr,Pn,lt,rr,Rn,U,or,gt,en,tn,nn,rn}from"./chunk-frqdgjbd.js";import"./chunk-81fv1abj.js";import{er,qo,qr}from"./chunk-wjghq897.js";import{ir}from"./chunk-6mydq7cv.js";import{ht}from"./chunk-sn451nak.js";import{_n,Go}from"./chunk-fzckrdm3.js";import{Me}from"./chunk-jh21wbwd.js";import{k,N,kt,be,I,h,D,H,w,t,ee,v,n,x,p,nt,Z}from"./chunk-bkr0zk6g.js";var ce={};k(ce,{Codex:()=>ce,PROVIDER:()=>Y,hookArgs:()=>pe,manifest:()=>Q,manifestFile:()=>X,models:()=>xe,paths:()=>gn,refresh:()=>bn,remove:()=>kn,rules:()=>Re,trustHash:()=>Pe});import{createHash as Ne}from"node:crypto";import{existsSync as de,realpathSync as cn,rmSync as hn}from"node:fs";import mn 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 Be(e,r){let i=e.slice(0,r).split(/\r?\n/);return[i.length,i.pop().length+1]}function Ve(e,r,i){let s=e.split(/\r?\n/),l="",a=(Math.log10(r+1)|0)+1;for(let o=r-1;o<=r+1;o++){let f=s[o-1];if(!f)continue;if(l+=o.toString().padEnd(a," "),l+=": ",l+=f,l+=`
|
|
28
|
+
`,o===r)l+=" ".repeat(a+i+2),l+=`^
|
|
29
|
+
`}return l}class m extends Error{line;column;codeblock;constructor(e,r){let[i,s]=Be(r.toml,r.ptr),l=Ve(r.toml,i,s);super(`Invalid TOML document: ${e}
|
|
30
|
+
|
|
31
|
+
${l}`,r);this.line=i,this.column=s,this.codeblock=l}static x(e,r,i){throw new m(e,{toml:r.s,ptr:i??r.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 F(e){let r=e.p,i=e.s.charCodeAt(e.p++),s=i,l=i===39,a=i===e.s.charCodeAt(e.p)&&i===e.s.charCodeAt(e.p+1);if(a){if((i=e.s.charCodeAt(e.p+=2))===10)e.p++;else if(i===13&&e.s.charCodeAt(e.p+1)===10)e.p+=2}let o="",f=e.p,c=0;for(;e.p<e.s.length;e.p++)if(i=e.s.charCodeAt(e.p),a&&(i===10||i===13&&e.s.charCodeAt(e.p+1)===10))c=c&&3;else if(i<32&&i!==9||i===127)m.x("control characters are not allowed in strings",e);else if((!c||c===3)&&i===s&&(!a||e.s.charCodeAt(e.p+1)===s&&e.s.charCodeAt(e.p+2)===s)){if(a){if(e.s.charCodeAt(e.p+3)===s)e.p++;if(e.s.charCodeAt(e.p+3)===s)e.p++}if(!c){let d=e.s.slice(f,e.p);o=o?o+d:d}return e.p+=a?3:1,o}else if(!c){if(!l&&i===92)o+=e.s.slice(f,f=e.p),c=1}else if(c===1)if(i===120||i===117||i===85){let d=e.p++-1,g=0,y=i===120?2:i===117?4:8;for(let O=0;O<y;O++,e.p++){let b=e.s.charCodeAt(e.p),A=b>=48&&b<=57?b-48:b>=65&&b<=70?b-65+10:b>=97&&b<=102?b-97+10:-1;if(A<0)m.x("invalid non-hex character in unicode escape",e);g=g<<4|A}if(g<0||g>1114111||g>=55296&&g<=57343)m.x("invalid unicode escape",e,d);o+=String.fromCodePoint(g),f=e.p--,c=0}else if(a&&(i===32||i===9))c=2;else{if(i===98)o+="\b";else if(i===116)o+="\t";else if(i===110)o+=`
|
|
58
|
+
`;else if(i===102)o+="\f";else if(i===114)o+="\r";else if(i===101)o+="\x1B";else if(i===34)o+='"';else if(i===92)o+="\\";else m.x("unrecognised escape sequence",e);f=e.p+1,c=0}else if(i!==32&&i!==9){if(c===2)m.x("invalid escape: only line-ending whitespace may be escaped",e,f);c=!l&&i===92?1:0,f=e.p}m.x("unfinished string",e,r)}/*!
|
|
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 Ke=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;class j extends Date{#n=!1;#r=!1;#e=null;constructor(e,r,i){let s=!0,l=!0,a="Z",o;if(typeof e==="string")if(r)e:{if(r<3){if(+e.slice(11,13)>23){e="";break e}if(r===2)a=null,e+="Z";else if((o=e.charCodeAt(e.length-1))!==90&&o!==122)a=e.slice(e.length-6);if(i)e=e.slice(0,10)+"T"+e.slice(11)}else if(r===4)e=+e.slice(0,2)>23?"":`0000-01-01T${e}Z`;s=r!==4,l=r!==3}else{let f=e.match(Ke);if(f){if(!f[1])s=!1,e=`0000-01-01T${e}`;if(l=!!f[2],l&&e[10]===" "&&(e=e.replace(" ","T")),f[2]&&+f[2]>23)e="";else if(a=f[3]||null,!a&&l)e+="Z"}else e=""}super(e);if(!isNaN(this.getTime()))this.#n=s,this.#r=l,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 e=super.toISOString();if(this.isDate())return e.slice(0,10);if(this.isTime())return e.slice(11,23);if(this.#e===null)return e.slice(0,-1);if(this.#e==="Z"||this.#e==="z")return e;let r=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return r=this.#e[0]==="-"?r:-r,new Date(this.getTime()-r*60000).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(e,r="Z"){let i=new j(e);return i.#e=r,i}static wrapAsLocalDateTime(e){let r=new j(e);return r.#e=null,r}static wrapAsLocalDate(e){let r=new j(e);return r.#r=!1,r.#e=null,r}static wrapAsLocalTime(e){let r=new j(e);return r.#n=!1,r.#e=null,r}}/*!
|
|
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(e,r=10){return r===16?e>47&&e<58||e>64&&e<71||e>96&&e<103:e>47&&e<48+r}function le(e,r){return e===32||e===9||e===10||e===13||r&&(e===r||e===44)||e===35}function P(e,r){let i=e.p,s=e.s.charCodeAt(e.p);if(s===91||s===123){e.d--||m.x("document contains excessively nested structures. aborting.",e);let l=s===91?Se(e):Ce(e);return e.d++,l}if(s===34||s===39)return F(e);if(s===116){if(e.s.charCodeAt(++e.p)!==114||e.s.charCodeAt(++e.p)!==117||e.s.charCodeAt(++e.p)!==101)m.x("invalid value",e,i);return e.p++,!0}if(s===102){if(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==108||e.s.charCodeAt(++e.p)!==115||e.s.charCodeAt(++e.p)!==101)m.x("invalid value",e,i);return e.p++,!1}if(s===43||s===45)return B(e,e.p,e.s.charCodeAt(++e.p),44-s,r);if(e.s.charCodeAt(e.p+4)===45&&e.s.charCodeAt(e.p+7)===45)return Ge(e,s,r);if(e.s.charCodeAt(e.p+2)===58)return He(e,s,r);return B(e,e.p,s,0,r)}function B(e,r,i,s,l){let a=i,o=0,f=!1;if(a===105){if(e.s.charCodeAt(++e.p)!==110||e.s.charCodeAt(++e.p)!==102)m.x("invalid value",e,r);return e.p++,(s||1)/0}if(a===110){if(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==110)m.x("invalid value",e,r);return e.p++,NaN}if(a===48){if(++e.p>=e.s.length||le(a=e.s.charCodeAt(e.p),l))return e.bi===!0?0n:0;if(!s){if(a===120)return ae(e,r,16,l);else if(a===98)return ae(e,r,2,l);else if(a===111)return ae(e,r,8,l)}if(a===46)o=2;else if(a===101||a===69)o=4;else m.x("illegal leading zero",e,r)}else if(!C(a))m.x("invalid value",e,r);while(++e.p<e.s.length&&(a=e.s.charCodeAt(e.p),!le(a,l))){if(!o)o=1;if(a===95){if(!(o&1))m.x("illegal underscore",e);o+=11,f=!0}else if(o===1&&a===46)o=2;else if((o===1||o===3)&&(a===101||a===69))o=4;else if(o===4&&(a===43||a===45))o=6;else if(!C(a))m.x("illegal character in numeric literal",e);else if(o>9)o-=11;else if(!(o&1))o++}if(!o){let d=(i-48)*(s||1);return e.bi===!0?BigInt(d):d}if(!(o&1))m.x("unfinished numeric value",e,r);let c=e.s.slice(r,e.p);if(f)c=c.replaceAll("_","");return o>1?parseFloat(c):Ae(e,c,10,r)}function ae(e,r,i,s){let l,a=1;while(++e.p<e.s.length&&(l=e.s.charCodeAt(e.p),!le(l,s)))if(l===95){if(a&1)m.x("illegal underscore",e);a=3}else if(!C(l,i))m.x("illegal character in numeric literal",e);else if(a&1)a--;if(a&1)m.x("unfinished numeric value",e);let o=e.s.slice(r+2,e.p);if(a)o=o.replaceAll("_","");return Ae(e,o,i,r)}function Ae(e,r,i,s){if(e.bi!==!0)e:{let l=parseInt(r,i);if(!Number.isSafeInteger(l)){if(e.bi)break e;m.x("integer value cannot be represented losslessly",e,s)}return l}return i===10?BigInt(r):BigInt((i===2?"0b":i===8?"0o":"0x")+r)}function Ge(e,r,i){let s=e.p++,l;if(!C(r)||!C(e.s.charCodeAt(e.p++))||!C(e.s.charCodeAt(e.p++))||!C(e.s.charCodeAt(e.p++)))return B(e,e.p=s,r,0,i);if(e.p+=5,!C(e.s.charCodeAt(e.p++)))m.x("invalid date-time: date part is malformed",e,s);if(e.p>=e.s.length||((r=e.s.charCodeAt(e.p))!==32||(l=!0,!C(e.s.charCodeAt(e.p+1))))&&r!==84&&r!==116){let o=e.s.slice(s,e.p);return L(e,o,3,!1,s)}if(e.s.charCodeAt(e.p+=3)!==58)m.x("invalid date-time: time part is malformed",e,s);if(e.s.charCodeAt(e.p+=3)===58)e.p+=3;if(e.s.charCodeAt(e.p)===46)while(C(e.s.charCodeAt(++e.p)));if(r=e.s.charCodeAt(e.p)){if(r===90||r===122){let o=e.s.slice(s,++e.p);return L(e,o,1,l,s,"[+00:00]")}if(r===43||r===45){let o=e.s.slice(s,e.p+=6);return L(e,o,1,l,s,!e.ld&&"["+e.s.slice(e.p-6,e.p)+"]")}}let a=e.s.slice(s,e.p);return L(e,a,2,l,s)}function He(e,r,i){let s=e.p;if(!C(r)||!C(e.s.charCodeAt(++e.p)))return B(e,--e.p,r,0,i);if(e.s.charCodeAt(e.p+=4)===58)e.p+=3;if(e.s.charCodeAt(e.p)===46)while(C(e.s.charCodeAt(++e.p)));let l=e.s.slice(s,e.p);return L(e,l,4,!1,s)}function L(e,r,i,s,l,a){if(e.ld){let o=new j(r,i,s);if(!o.isValid())m.x("invalid date",e,l);return o}try{if(a)r+=a;switch(i){case 1:return Temporal.ZonedDateTime.from(r);case 2:return Temporal.PlainDateTime.from(r);case 3:return Temporal.PlainDate.from(r);case 4:return Temporal.PlainTime.from(r)}}catch(o){m.x(o instanceof Error?o.message:""+o,e,l)}}/*!
|
|
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 qe(e){for(;e.p<e.s.length;e.p++){let r=e.s.charCodeAt(e.p);if(r===10)break;if(r===13&&e.s.charCodeAt(e.p+1)===10){e.p++;break}if(r<32&&r!==9||r===127)m.x("control characters are not allowed in comments",e)}}function T(e,r,i){let s;while(e.p<e.s.length){while(e.p<e.s.length&&((s=e.s.charCodeAt(e.p))===32||s===9||!r&&(s===10||s===13&&e.s.charCodeAt(e.p+1)===10)))e.p++;if(i||s!==35)break;qe(e)}}/*!
|
|
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 V(e,r=61){let i,s=0,l=[],a,o=e.s.charCodeAt(i=e.p);do if(o===r){if(!s)m.x("unexpected end of key",e);if(s===1)l.push(e.s.slice(a,e.p));return e.p++,l}else if(o===46){if(!s)m.x("illegal empty bare key",e);if(s===1)l.push(e.s.slice(a,e.p));s=0}else if(!s&&(o===34||o===39)){if(o===e.s.charCodeAt(e.p+1)&&o===e.s.charCodeAt(e.p+2))m.x("illegal quoted key: multiline strings are not allowed",e);l.push(F(e)),s=2,e.p--}else if(o===32||o===9){if(s===1)l.push(e.s.slice(a,e.p)),s=2}else if(s===2||o<48&&o!==45||o>57&&o<65||o>90&&o<97&&o!==95||o>122)m.x("illegal character in key",e);else if(!s)s=1,a=e.p;while(o=e.s.charCodeAt(++e.p));m.x("incomplete key-value: cannot find end of key",e,i)}function Ce(e){let r=e.p++,i=Object.create(null),s=new Set,l;while(e.p<e.s.length){if(T(e),(l=e.s.charCodeAt(e.p))===125)return e.p++,i;let a,o=i,f=!1,c=e.p,d=V(e);for(let y=0;y<d.length;y++){if(y)o=f?o[a]:o[a]=Object.create(null);if(a=d[y],(f=Object.hasOwn(o,a))&&(typeof o[a]!=="object"||s.has(o[a])))m.x("trying to redefine an already defined value",e,c);let O=a==="__proto__";if(e.uk&&(O||a==="constructor")){o=e.uk!==1&&m.x("document contains an unsafe property",e,c);break}if(!f&&O)Object.defineProperty(o,a,{enumerable:!0,configurable:!0,writable:!0})}if(f)m.x("trying to redefine an already defined value",e,c);T(e,!0,!0);let g=P(e,125);if(o&&typeof(o[a]=g)==="object")s.add(g);if(T(e),(l=e.s.charCodeAt(e.p++))===125)return i;if(l!==44)m.x("expected comma or end of structure",e,e.p-1)}m.x("unfinished table",e,r)}function Se(e){let r=e.p++,i=[],s;while(e.p<e.s.length){if(T(e),(s=e.s.charCodeAt(e.p))===93)return e.p++,i;if(i.push(P(e,93)),T(e),(s=e.s.charCodeAt(e.p++))===93)return i;if(s!==44)m.x("expected comma or end of structure",e,e.p-1)}m.x("unfinished array",e,r)}/*!
|
|
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 Te(e,r,i,s,l){let a=i,o=s,f,c=!1,d;for(let g=0;g<r.length;g++){if(g){if(a=c?a[f]:a[f]=Object.create(null),o=(d=o[f]).c,l===0&&(d.t===1||d.t===2))return null;if(d.t===2){let y=a.length-1;a=a[y],o=o[y].c}}if(f=r[g],(c=Object.hasOwn(a,f))&&o[f]?.t===0&&o[f]?.d)return null;if(!c){let y=f==="__proto__";if(e.uk&&(y||f==="constructor"))return!1;if(y)Object.defineProperty(a,f,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(o,f,{enumerable:!0,configurable:!0,writable:!0});o[f]={t:g<r.length-1&&l===2?3:l,d:!1,i:0,c:Object.create(null)}}}if(d=o[f],d.t!==l&&!(l===1&&d.t===3))return null;if(l===2){if(!d.d)d.d=!0,a[f]=[];a[f].push(a=Object.create(null)),d.c[d.i++]=d={t:1,d:!1,i:0,c:Object.create(null)}}if(d.d)return null;if(d.d=!0,l===1)a=c?a[f]:a[f]=Object.create(null);else if(l===0&&c)return null;return[f,a,d.c]}function Oe(e,r,i){if(r===null||e.uk===2)m.x(r===null?"trying to redefine an already defined table or value":"document contains an unsafe property",e,i)}function fe(e,r={}){let i={s:e,p:0,d:r.maxDepth??1000,bi:r.integersAsBigInt??!1,ld:r.useLegacyDate??!0,uk:r.unsafeKeyBehaviour==="throw"?2:r.unsafeKeyBehaviour==="drop"?1:0},s=Object.create(null),l=Object.create(null),a,o=!1,f=s,c=l;if(e.charCodeAt(0)===65279)i.p++;T(i);while(i.p<e.length){if(e.charCodeAt(i.p)===91){let d=e.charCodeAt(++i.p)===91;a=i.p+=+d,o=!1;let g=V(i,93);if(d){if(e.charCodeAt(i.p)!==93)m.x("expected end of table array declaration",i);i.p++}let y=Te(i,g,s,l,d?2:1);if(!y)Oe(i,y,a),o=!0;else c=y[2],f=y[1]}else{a=i.p;let d=V(i),g=Te(i,d,f,c,0);if(!g&&!o)Oe(i,g,a);T(i,!0,!0);let y=P(i,void 0);if(g&&!o)g[1][g[0]]=y}if(T(i,!0),i.p<e.length&&(a=e.charCodeAt(i.p))!==10&&(a!==13||e.charCodeAt(i.p+1)!==10))m.x("each key-value declaration must be followed by an end-of-line",i);T(i)}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 ve(e){let r=ne(e);if(r===void 0||r.trim()==="")return;let i=R(r);if(!i)throw Error(`${e} isn't valid TOML, so it was left alone. Fix it and run setup again.`);return{text:r,value:i}}function $e(e,r,i){let s=R(r)??{},l=je(s),a=i.reduce((c,d)=>{if(d.type==="key"){if(d.value===void 0)delete l[d.key];else l[d.key]=d.value;return Xe(c,d.key,d.value)}if(d.type==="remove")return pn(l,d.path),sn(c,d.path);return dn(l,d.path,d.entries),an(c,d.path,d.entries)},r),o=/^\s*\n/.test(r)?a:a.replace(/^\s*\n/,""),f=R(o);if(!f||q(f)!==q(l))throw Error(`${e} couldn't be updated without changing settings setup doesn't own, so it was left alone.`);return o}function z(e,r){return r.reduce((i,s)=>E(i)?i[s]:void 0,e)}function K(e){if(typeof e==="string")return JSON.stringify(e);if(typeof e==="number"||typeof e==="boolean")return String(e);if(Array.isArray(e))return`[${e.map(K).join(", ")}]`;if(E(e))return`{ ${Object.entries(e).filter(([,r])=>r!==void 0).map(([r,i])=>`${G(r)} = ${K(i)}`).join(", ")} }`;throw Error(`Can't write ${String(e)} as TOML`)}function G(e){return/^[A-Za-z0-9_-]+$/.test(e)?e:JSON.stringify(e)}function E(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof Date)}function R(e){try{return fe(e)}catch{return}}function Xe(e,r,i){let s=e.split(`
|
|
241
|
+
`),l=s.findIndex(ue),a=l===-1?s.length:l,o=s.slice(0,a).findIndex((d)=>ln(d)===r),f=i===void 0?[]:[`${G(r)} = ${K(i)}`];if(o!==-1)return[...s.slice(0,o),...f.map((d)=>`${d}${Qe(s[o])}`),...s.slice(o+1)].join(`
|
|
242
|
+
`);if(i===void 0)return e;let c=s.slice(0,a).findLastIndex((d)=>d.trim()!==""&&!d.trim().startsWith("#"));return[...s.slice(0,c+1),...f,...s.slice(c+1)].join(`
|
|
243
|
+
`)}function Qe(e){let r=[...e.matchAll(/#/g)].map((i)=>i.index).find((i)=>R(e.slice(0,i))!==void 0);return r===void 0?"":e.slice(e.slice(0,r).trimEnd().length)}function sn(e,r){let i=e.split(`
|
|
244
|
+
`),s=i.findIndex((c)=>ue(c)&&!c.trim().startsWith("[[")&&un(fn(c),r));if(s===-1)return e;let l=i.slice(s+1).findIndex(ue),a=l===-1?i.length:s+1+l,o=i.slice(0,a).findLastIndex((c)=>c.trim()!=="")+1,f=i.slice(0,s).findLastIndex((c)=>c.trim()!=="")+1;return[...i.slice(0,f),...i.slice(o)].join(`
|
|
245
|
+
`)}function an(e,r,i){let s=Object.entries(i).filter(([,a])=>a!==void 0).map(([a,o])=>`${G(a)} = ${K(o)}`),l=e.replace(/\s*$/,"");return`${l===""?"":`${l}
|
|
246
|
+
|
|
247
|
+
`}[${r.map(G).join(".")}]
|
|
248
|
+
${s.join(`
|
|
249
|
+
`)}
|
|
250
|
+
`}function ue(e){return/^\s*\[/.test(e)}function ln(e){let r=e.match(/^\s*(?:([A-Za-z0-9_-]+)|"((?:[^"\\]|\\.)*)"|'([^']*)')\s*=/);if(!r)return;let i=r[2]===void 0?void 0:R(`k = "${r[2]}"`)?.k;return r[1]??r[3]??(typeof i==="string"?i:void 0)}function fn(e){let r=R(`${e}
|
|
251
|
+
`),i=[],s=r;while(E(s)&&Object.keys(s).length===1){let l=Object.keys(s)[0];i.push(l),s=s[l]}return i}function je(e){return Object.fromEntries(Object.entries(e).map(([r,i])=>[r,Ee(i)]))}function Ee(e){if(Array.isArray(e))return e.map(Ee);if(E(e))return je(e);return e}function un(e,r){return e.length===r.length&&e.every((i,s)=>i===r[s])}function dn(e,r,i){let s=r.slice(0,-1).reduce((l,a)=>{let o=l[a];if(E(o))return o;let f={};return l[a]=f,f},e);s[r.at(-1)]=Object.fromEntries(Object.entries(i).filter(([,l])=>l!==void 0))}function pn(e,r){let i=z(e,r.slice(0,-1));if(E(i))delete i[r.at(-1)]}function q(e){if(Array.isArray(e))return`[${e.map(q).join(",")}]`;if(e instanceof Date)return JSON.stringify(e.toISOString());if(E(e))return`{${Object.keys(e).toSorted().map((r)=>[r,q(e[r])]).filter(([,r])=>r!=="{}").map(([r,i])=>`${JSON.stringify(r)}:${i}`).join(",")}}`;return JSON.stringify(e)}function gn(e=process.env,r=mn.homedir()){let i=e.CODEX_HOME?.trim(),s=i?De(S.resolve(i)):S.join(r,".codex"),l=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:(ne(l)?.trim()??"")===""?S.join(s,"AGENTS.md"):l}}function De(e){if(de(e))return cn(e);let r=S.dirname(e);return r===e?e:S.join(De(r),S.basename(e))}function xe(e,r,i){let s=Go(_n(e)),l=r.models[0];if(s===void 0||l===void 0)return;return{baseURL:`${s}/openai/v1`,catalogURL:`${i}${Jr}`,model:l.slug,count:r.models.length}}function Re(e){return e.flatMap((r,i)=>{if(r.action!=="tool.use"||r.effect!=="deny"||!r.resource.startsWith("shell:"))return[];let s=r.resource.slice(6).match(/^([^*?]+)\*$/)?.[1]?.trim(),l=s?.split(/\s+/)??[];if(!s||l.some((o)=>!/^[\w@%+=:,./-]+$/.test(o)))return[];if(e.slice(i+1).some((o)=>o.action==="tool.use"&&o.effect==="allow"&&qr(o.resource,`shell:${s}`)))return[];let a=[...r.message].map((o)=>o<" "||o===""?" ":o).join("");return[`prefix_rule(pattern = ${JSON.stringify(l)}, decision = "forbidden", justification = ${JSON.stringify(a)})`]})}var yn=n({baseURL:t,catalogURL:t,model:t,count:ee}),Le=n({paths:n({home:t,config:t,hooks:t,rules:t,skills:t,memory:t}),command:p(t),harness:w(t),environment:x(t,t),...tr,tables:p(p(t)),servers:p(t),skills:x(t,t),memoryCreated:v,created:n({config:v,hooks:v}),providers:w(t),models:w(nt(yn))}),X=(e)=>S.join(e.data,"codex.json");function Q(e){let r=X(e),i=ne(r);if(i===void 0)return;let s=N(H(Z(Le))(i));if(!s)throw Error(`${r} can't be read, so Codex was left as it is. Delete it and run setup again.`);return s}var Y="opencode-console",pe=["hook","codex"],bn=D("Codex.refresh")(function*(e,r){let i=Q(e),s=r??i;if(!s)return;let l=yield*xt(e),a=l&&ht(e,Fe(l));if(!l||!a?.config)return;let o=a.config,f=gt(o),c=Ne("sha256").update(JSON.stringify(o.providers??null)).digest("hex"),g=!r&&i?.providers===c&&i.models!==void 0?i.models??void 0:yield*kt([on(l),ls(l)],{concurrency:2}).pipe(h(([A,_])=>xe(A,_,l.server))),y=yield*tn(l,s.paths.skills,f.skills,i?.skills??{}),O=ir(l,a),b=yield*be([{action:"websearch:",resources:["*"],truncated:!0},{action:"websearch.use",resources:["openai"]}],(A)=>er(O,A));return yield*_e(e,I(()=>wn(e,{paths:s.paths,command:s.command,harness:r?r.harness:i?.harness,environment:r?r.environment??{}:i?.environment??{},models:g,servers:Object.fromEntries(Object.entries(en(o)).map(([A,_])=>[A,{url:_.url,gateway:_.headers!==void 0}])),instructions:f.instructions,skills:f.skills,bundles:y,rules:Re(qo(O)??[]),searchOff:b.some((A)=>A.effect==="deny"),providers:c,explicit:r!==void 0})))});function kn(e){let r=Q(e);if(!r)return!1;let i=ve(r.paths.config),s=at(r.paths.hooks),l=ne(r.paths.memory),a=i&&$e(r.paths.config,i.text,[...Object.keys(r.originals).flatMap((o)=>{let f={...i.value};return Pn(f,o,r),JSON.stringify(f[o])===JSON.stringify(i.value[o])?[]:[{type:"key",key:o,value:f[o]}]}),...r.tables.filter((o)=>z(i.value,o)!==void 0).map((o)=>({type:"remove",path:o}))]);if(i&&a!==void 0){if(a.trim()===""&&r.created.config)J(r.paths.config);else if(a!==i.text)Rn(r.paths.config,a)}if(s)if(Ue(s),Object.keys(s).length===0&&r.created.hooks)J(r.paths.hooks);else ct(r.paths.hooks,s);return J(r.paths.rules),Object.keys(r.skills).forEach((o)=>hn(S.join(r.paths.skills,o),{recursive:!0,force:!0})),rn(r.paths.memory,l,[],r.memoryCreated),[r.paths.config,r.paths.hooks].forEach((o)=>J(lt(o))),J(X(e)),!0}function wn(e,r){let i=Q(e),s=de(r.paths.config),l=de(r.paths.hooks),a=ve(r.paths.config)??{text:"",value:{}},o=at(r.paths.hooks)??{},f=ne(r.paths.memory),c=i?.created??{config:!s,hooks:!l},d=[];Ue(o);let g=U(o.hooks),y=[...r.command,...r.harness===void 0?[]:["--harness",r.harness]],O=Sn(y).map(([u,M])=>{let we=[...Array.isArray(g[u])?g[u]:[],M];return g[u]=we,{event:u,group:M,index:we.length-1}});o.hooks=g;let b={...a.value},{originals:A,written:_}=nr(b,An(r),i,r.explicit),ze=[...new Set([...Object.keys(i?.originals??{}),...Object.keys(A)])].flatMap((u)=>JSON.stringify(b[u])===JSON.stringify(a.value[u])?[]:[{type:"key",key:u,value:b[u]}]),re=new Map((i?.tables??[]).map((u)=>[JSON.stringify(u),u])),te=(u)=>!re.has(JSON.stringify(u))&&z(a.value,u)!==void 0,he=["model_providers",Y];if(r.models&&te(he))throw Error(`${r.paths.config} already has a model provider named ${Y}, so Codex was left as it is. Rename it and run setup again.`);let ie=Object.entries(r.servers).flatMap(([u,M])=>{if(M.url===void 0||!/^[a-z0-9_-]+$/i.test(u))return[];if(te(["mcp_servers",u]))return d.push(u),[];return[{name:u,url:M.url,gateway:M.gateway}]}),me=O.map((u)=>({path:["hooks","state",`${r.paths.hooks}:${Je(u.event)}:${u.index}:0`],hash:Pe(u.event,u.group)})),oe=[...r.models?[{path:[...he],entries:Cn(r)}]:[],...ie.map((u)=>({path:["mcp_servers",u.name],entries:{url:u.url,...u.gateway?{http_headers_helper:or([...On(r.environment),...y,"mcp-headers",u.name])}:{}}})),...me.map((u)=>({path:u.path,entries:{trusted_hash:u.hash}}))],We=(u)=>re.has(JSON.stringify(u.path))&&W(z(a.value,u.path))===W(u.entries),ge=new Set(oe.filter(We).map((u)=>JSON.stringify(u.path))),ye=$e(r.paths.config,a.text,[...ze,...[...re].filter(([u])=>!ge.has(u)).map(([,u])=>u).filter((u)=>z(a.value,u)!==void 0).map((u)=>({type:"remove",path:u})),...me.filter((u)=>te(u.path)).map((u)=>({type:"remove",path:u.path})),...oe.filter((u)=>!ge.has(JSON.stringify(u.path))).map((u)=>({type:"table",path:u.path,entries:u.entries}))]);if(!i)[r.paths.config,r.paths.hooks].forEach(rr);if(ye!==a.text)Rn(r.paths.config,ye,384);if(ct(r.paths.hooks,o,384),r.rules.length>0)vn(r.paths.rules,`# Written by OpenCode Console from the workspace's policies; \`npx @opencode/console sync\` rewrites it.
|
|
252
|
+
${r.rules.join(`
|
|
253
|
+
`)}
|
|
254
|
+
`);else J(r.paths.rules);let se=nn(r.paths.skills,r.skills,r.bundles,i?.skills??{});d.push(...se.skipped);let Ze=rn(r.paths.memory,f,r.instructions,i?.memoryCreated??!1);return ke(X(e),JSON.stringify(Le.make({paths:r.paths,command:[...r.command],...r.harness===void 0?{}:{harness:r.harness},environment:{...r.environment},originals:A,written:_,tables:oe.map((u)=>u.path),servers:ie.map((u)=>u.name),skills:se.skills,memoryCreated:Ze,created:c,providers:r.providers,models:r.models??null}))),{models:r.models,servers:ie.map((u)=>u.name),skills:Object.keys(se.skills),instructions:r.instructions.length,rules:r.rules.length,searchOff:r.searchOff,skipped:d}}function An(e){return{...e.models?{model_provider:Y,model:e.models.model}:{},...e.searchOff?{web_search:"disabled"}:{}}}function Cn(e){let r=e.models;return{name:"OpenCode Console",base_url:r.baseURL,wire_api:"responses",model_catalog_url:r.catalogURL,http_headers:{"x-opencode-plugin":`opencode-console/${Me}`},auth:{command:e.command[0],args:[...e.command.slice(1),"token"],refresh_interval_ms:240000,timeout_ms:15000}}}function Sn(e){let r=or([...e,...pe]);return[["PreToolUse",{matcher:"*",hooks:[{type:"command",command:r,timeout:30}]}],["UserPromptSubmit",{hooks:[{type:"command",command:r,timeout:30}]}],["SessionStart",{hooks:[{type:"command",command:r,timeout:10}]}]]}function Pe(e,r){let i=r.hooks[0],s={event_name:Je(e),..."matcher"in r?{matcher:r.matcher}:{},hooks:[{type:i.type,command:i.command,timeout:i.timeout,async:!1}]};return`sha256:${Ne("sha256").update(W(s)).digest("hex")}`}function Je(e){return e.replace(/([a-z])([A-Z])/g,"$1_$2").toLowerCase()}function W(e){if(Array.isArray(e))return`[${e.map(W).join(",")}]`;if(E(e))return`{${Object.keys(e).toSorted().map((r)=>`${JSON.stringify(r)}:${W(e[r])}`).join(",")}}`;return JSON.stringify(e)}function Ue(e){let r=U(e.hooks);if(Object.entries(r).forEach(([i,s])=>{if(!Array.isArray(s))return;let l=s.flatMap((a)=>{let o=U(a).hooks;if(!Array.isArray(o))return[a];let f=o.filter((c)=>!Tn(c));if(f.length===o.length)return[a];return f.length===0?[]:[{...U(a),hooks:f}]});if(l.length===0)delete r[i];else r[i]=l}),Object.keys(r).length===0)delete e.hooks;else e.hooks=r}function Tn(e){let r=U(e).command;return typeof r==="string"&&r.endsWith(` ${pe.join(" ")}`)}function On(e){let r=Object.entries(e);if(r.length===0||process.platform==="win32")return[];return["env",...r.map(([i,s])=>`${i}=${s}`)]}function vn(e,r){if(ne(e)!==r)Rn(e,r)}export{ce as Codex,Y as PROVIDER,pe as hookArgs,Q as manifest,X as manifestFile,xe as models,gn as paths,bn as refresh,kn as remove,Re as rules,Pe as trustHash};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{ms,oi,sn,si,pr,ii,qe,an,we,ai,li,Yr}from"./chunk-2y9vn023.js";import{k,M,xe,oo,R,pt,kt,W,l,lo,h,Er,It,Se,Ms,ue,D,w,d,F,t,ee,n,x,p,b,nt}from"./chunk-bkr0zk6g.js";var ds={};k(ds,{ConsoleClient:()=>ds,DeviceSignInFailed:()=>ur,OAuth:()=>cr,SignedOut:()=>Nn,SsoRequired:()=>lr,authorize:()=>is,clientID:()=>ar,codexModelsPath:()=>Jr,defaultServer:()=>ss,fetchCodexModels:()=>ls,fetchConfig:()=>cs,fetchModels:()=>on,fetchSkill:()=>us,fetchSkillBlob:()=>ps,headers:()=>ri,normalizeServer:()=>fs,refresh:()=>as,revoke:()=>Gr,signedOutMessage:()=>ti,ssoMessage:()=>ni});var ss="https://opencode.ai/console",ar="opencode-console-cli",cr=n({type:d("oauth"),server:t,access:t,refresh:t,expires:ee,accountID:t,email:w(t),orgID:w(t),orgName:w(t)}),ti="Signed out of OpenCode Console. Run `npx @opencode/console login` to sign in again",ni=(e)=>`Sign in with SSO again to use ${e??"your OpenCode Console workspace"}`;class lr extends R("ConsoleClient.SsoRequired"){get message(){return ni(this.organization)}}class Nn extends R("ConsoleClient.SignedOut"){get message(){return ti}}class ur extends R("ConsoleClient.DeviceSignInFailed"){}function ri(e){return{authorization:`Bearer ${e.type==="oauth"?e.access:e.key}`,...e.type==="oauth"&&e.orgID?{"x-org-id":e.orgID}:{}}}var _=n({device_code:t,user_code:t,verification_uri:t,verification_uri_complete:t,expires_in:ee,interval:ee}),y=n({access_token:t,refresh_token:t,expires_in:ee,org_id:w(nt(t))}),S=n({error:t}),v=n({id:t,email:t}),T=n({id:t,name:t}),U=n({_tag:d("SsoRequired"),connectionId:w(t)}),O=n({_tag:d("Unauthorized")}),B=x(t,F),H={access_denied:"The sign-in was denied in the browser",expired_token:"The code expired before it was approved. Start the sign-in again"},is=D("ConsoleClient.authorize")(function*(e){let o=yield*we,r=yield*u(`${e}/auth/device/code`,{client_id:ar,supports_org_scope:!0}).pipe(l(an),l(qe(_))),s=new URL(e).origin,i=URL.parse(r.verification_uri_complete,`${e}/`);if(!i||i.origin!==s||URL.parse(r.verification_uri,`${e}/`)?.origin!==s)return yield*new ur({message:`${e} sent a sign-in link to another site (${r.verification_uri_complete}), so the sign-in stopped`});return{url:i.href,code:r.user_code,callback:g(e,r.device_code,xe(r.interval)).pipe(Se(we,o))}}),as=D("ConsoleClient.refresh")(function*(e){let o=yield*u(`${e.server}/auth/device/token`,{grant_type:"refresh_token",refresh_token:e.refresh,client_id:ar});if(o.status===400){let c=yield*qe(S)(o).pipe(lo);if(M(c)&&c.value.error==="invalid_grant")return yield*new Nn}let r=yield*an(o).pipe(l(qe(y))),s=yield*pt,i=r.org_id??e.orgID;return cr.make({...e,access:r.access_token,refresh:r.refresh_token,expires:s+r.expires_in*1000,...i===void 0?{}:{orgID:i}})}),Gr=D("ConsoleClient.revoke")(function*(e){let o=yield*u(`${e.server}/auth/oauth/revoke`,{token:e.refresh,token_type_hint:"refresh_token",client_id:ar}).pipe(Er(xe(5)));yield*an(o)}),cs=D("ConsoleClient.fetchConfig")(function*(e){return yield*a(e,"/api/v2/config",B)}),on=D("ConsoleClient.fetchModels")(function*(e){return yield*a(e,"/api/v1/models",I)}),Jr="/api/v2/codex/models",ls=D("ConsoleClient.fetchCodexModels")(function*(e){return yield*a(e,Jr,E)}),us=D("ConsoleClient.fetchSkill")(function*(e,o){return yield*a(e,`/api/v2/library/skills/${encodeURIComponent(o)}?format=v2`,A)}),ps=D("ConsoleClient.fetchSkillBlob")(function*(e,o,r){return yield*m(e,`/api/v2/library/skills/${encodeURIComponent(o)}/blobs/${encodeURIComponent(r)}`,(s)=>s.arrayBuffer.pipe(h((i)=>new Uint8Array(i))))}),I=x(t,n({name:w(t),models:x(t,x(t,F))})),E=n({models:p(n({slug:t,display_name:w(t)}))}),A=n({slug:t,version:t,files:p(b([n({kind:d("text"),path:t,content:t}),n({kind:d("blob"),path:t,sha256:t})]))});function a(e,o,r){return m(e,o,qe(r))}function m(e,o,r){return l(we,(s)=>li(s).execute(ms(`${e.server}${o}`).pipe(pr,sn(ri(e)))).pipe(l((i)=>W(function*(){if(i.status===401){let c=yield*qe(O)(i).pipe(lo);if(M(c))return yield*new Nn}if(i.status===403){let c=yield*qe(U)(i).pipe(lo);if(M(c))return yield*new lr({organization:e.type==="oauth"?e.orgName:void 0,url:J(e.server,c.value.connectionId)})}return yield*r(yield*an(i))})),Ms,Er(xe(10))))}function fs(e){let o=URL.parse(e);if(!o)return;let r=["localhost","127.0.0.1","[::1]"].includes(o.hostname);if(o.protocol!=="https:"&&!(o.protocol==="http:"&&r))return;return`${o.origin}${o.pathname.replace(/\/+$/,"")}`}function J(e,o){let r=encodeURIComponent(`${new URL(e).pathname.replace(/\/+$/,"")}/`);if(!o)return`${e}/login?next=${r}`;return`${e}/auth/sso/${encodeURIComponent(o)}/start?redirectTo=${r}`}function g(e,o,r){return W(function*(){yield*It(r);let s=yield*u(`${e}/auth/device/token`,{grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:o,client_id:ar}),i=yield*qe(b([y,S]))(s);if("access_token"in i)return yield*z(e,i);if(i.error==="authorization_pending")return yield*g(e,o,r);if(i.error==="slow_down")return yield*g(e,o,oo(r,xe(5)));return yield*new ur({message:H[i.error]??`The Console refused the sign-in (${i.error})`})})}var z=ue(function*(e,o){let[r,s]=yield*kt([f(`${e}/api/user`,o.access_token,v),f(`${e}/api/orgs`,o.access_token,p(T))],{concurrency:2}),i=o.org_id==null?void 0:s.find((C)=>C.id===o.org_id);if(o.org_id!=null&&!i)return yield*new ur({message:`The workspace ${o.org_id} wasn't found after signing in`});let c=yield*pt;return cr.make({type:"oauth",server:e,access:o.access_token,refresh:o.refresh_token,expires:c+o.expires_in*1000,accountID:r.id,email:r.email,...i?{orgID:i.id,orgName:i.name}:{}})});function f(e,o,r){return l(we,(s)=>ai(s).execute(ms(e).pipe(pr,si(o)))).pipe(l(qe(r)))}function u(e,o){return l(we,(r)=>r.execute(oi(e).pipe(pr,ii(o)))).pipe(Se(Yr,{redirect:"manual"}))}
|
|
2
|
+
export{ss,ar,cr,ti,ni,lr,Nn,ur,ri,is,as,Gr,cs,on,Jr,ls,us,ps,fs,ds};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{pi,fi}from"./chunk-zdf3mvav.js";import{K,ie,V,ro,Ze,Et,Le,jt,As,Bt,yi,ae,js,Rr,Fr,Io,Hs,ra,oa}from"./chunk-bkr0zk6g.js";export{pi as Brand,Le as Cause,yi as Clock,ie as Context,Et as Data,Rr as DateTime,Ze as Duration,ae as Effect,jt as Exit,js as Fiber,oa as FileSystem,Bt as Layer,K as Option,fi as Path,ro as Record,V as Result,ra as Schema,Fr as SchemaGetter,Io as SchemaTransformation,As as Scope,Hs as Struct};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{sn,we,ci}from"./chunk-2y9vn023.js";import{lr,Nn,cs}from"./chunk-p59r4b0j.js";import{_e}from"./chunk-6rpbc10h.js";import{He,Fe,Mn,xt}from"./chunk-5q7mrvv1.js";import{Xo,es,ts,sr}from"./chunk-6mydq7cv.js";import{k,O,oe,pt,r,I,l,co,h,D}from"./chunk-bkr0zk6g.js";var Zo={};k(Zo,{WorkspaceSync:()=>Zo,current:()=>ht,identify:()=>Jo,sync:()=>Vo,userAgent:()=>Vs});function Jo(e){return oe(we,h(we,(o)=>ci(o,sn({"user-agent":Vs(e),"x-opencode-plugin":`opencode-console/${e.version}`}))))}function Vs(e){return[e.harness?.replace(/[\r\n]/g,"").trim(),`opencode-console/${e.version}`].filter(Boolean).join(" ")}var Vo=D("WorkspaceSync.sync")(function*(e,o={}){let n=He(e);if(!n)return yield*_e(e,I(()=>ts(e))),{snapshot:void 0};let s=yield*pt,i=Fe(n),c=ht(e,i);if(c&&!o.force&&!sr(c,s))return{snapshot:c};let t=yield*xt(e).pipe(l((a)=>a?cs(a).pipe(h((p)=>({credential:a,config:p}))):r(void 0)),co);if(O(t)){if(!t.success)return{snapshot:void 0};return{snapshot:yield*u(e,i,{owner:i,organization:Mn(t.success.credential),fetched:s,config:t.success.config})}}let f=m(t.failure);if(!f)return{snapshot:c,error:t.failure};let d=c??{owner:i,organization:Mn(n)};return{snapshot:yield*u(e,i,{...d,fetched:s,status:f}),error:t.failure}});function ht(e,o){let n=Xo(e);return n?.owner===o?n:void 0}function u(e,o,n){return _e(e,I(()=>{let s=He(e);if(!s||Fe(s)!==o)return;return es(e,n),n}))}function m(e){if(e instanceof lr)return{message:e.message,url:e.url};if(e instanceof Nn)return{message:e.message};return}
|
|
2
|
+
export{Jo,Vs,Vo,ht,Zo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ss,ar,cr,ti,ni,lr,Nn,ur,ri,is,as,Gr,cs,on,Jr,ls,us,ps,fs,ds}from"./chunk-p59r4b0j.js";import"./chunk-2y9vn023.js";import"./chunk-zdf3mvav.js";export{ds as ConsoleClient,ur as DeviceSignInFailed,cr as OAuth,Nn as SignedOut,lr as SsoRequired,is as authorize,ar as clientID,Jr as codexModelsPath,ss as defaultServer,ls as fetchCodexModels,cs as fetchConfig,on as fetchModels,us as fetchSkill,ps as fetchSkillBlob,ri as headers,fs as normalizeServer,as as refresh,Gr as revoke,ti as signedOutMessage,ni as ssoMessage};
|