@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 @@
|
|
|
1
|
+
import{gt,en,tn,nn,rn,Ys,Qo}from"./chunk-frqdgjbd.js";import"./chunk-p59r4b0j.js";import"./chunk-2y9vn023.js";import"./chunk-6rpbc10h.js";import"./chunk-zdf3mvav.js";export{Qo as Library,tn as fetchChanged,gt as library,en as servers,Ys as skillMarkdown,nn as write,rn as writeInstructions};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{k,c,i,a,Es,P,u,O,St,$e,Lt,Re,r,o,q,Co,Jn,Ao,ot}from"./chunk-bkr0zk6g.js";var pi={};k(pi,{BrandError:()=>b,all:()=>M,check:()=>R,make:()=>D,nominal:()=>Ss});var fi={};k(fi,{Path:()=>Ft,TypeId:()=>C,layer:()=>Y,make:()=>Un});class b{constructor(e){this.issue=e}_tag="BrandError";name="BrandError";issue;get message(){return Co(this.issue)}toString(){return`BrandError(${this.message})`}}function Ss(){return Object.assign((e)=>e,{option:(e)=>a(e),result:(e)=>u(e),is:(e)=>!0})}function D(e){return R(Jn(e))}function R(...e){let t=(s)=>St(Ao(e,s),(f)=>new b(f));return Object.assign((s)=>$e(t(s)),{option:(s)=>Es(t(s)),result:t,is:(s)=>O(t(s)),checks:e})}function M(...e){let t=e.flatMap((s)=>s.checks??[]);return Lt(t)?R(...t):Ss()}var C="~effect/Path",Ft=P("effect/Path"),Un=(e)=>Ft.of({...e,[C]:C,resolveWithin(t,s){if(e.parse(s).root!=="")return i();let f=e.resolve(t),l=e.resolve(f,s),n=e.relative(f,l);return n===".."||n.startsWith(`..${e.sep}`)||e.isAbsolute(n)?i():a(l)}});function E(e,t){let s="",f=0,l=-1,n=0,x;for(let m=0;m<=e.length;++m){if(m<e.length)x=e.charCodeAt(m);else if(x===47)break;else x=47;if(x===47){if(l===m-1||n===1);else if(l!==m-1&&n===2){if(s.length<2||f!==2||s.charCodeAt(s.length-1)!==46||s.charCodeAt(s.length-2)!==46){if(s.length>2){let d=s.lastIndexOf("/");if(d!==s.length-1){if(d===-1)s="",f=0;else s=s.slice(0,d),f=s.length-1-s.lastIndexOf("/");l=m,n=0;continue}}else if(s.length===2||s.length===1){s="",f=0,l=m,n=0;continue}}if(t){if(s.length>0)s+="/..";else s="..";f=2}}else{if(s.length>0)s+="/"+e.slice(l+1,m);else s=e.slice(l+1,m);f=m-l-1}l=m,n=0}else if(x===46&&n!==-1)++n;else n=-1}return s}function N(e){if(!e)return"";return e.startsWith(".")?e:`.${e}`}function z(e,t){let s=t.dir||t.root,f=t.base||(t.name||"")+N(t.ext);if(!s)return f;if(s===t.root)return s+f;return s+e+f}function _(e){if(e.protocol!=="file:")return o(new ot({module:"Path",method:"fromFileUrl",description:"URL must be of scheme file"}));else if(e.hostname!=="")return o(new ot({module:"Path",method:"fromFileUrl",description:"Invalid file URL host"}));let t=e.pathname;for(let s=0;s<t.length;s++)if(t[s]==="%"){let f=t.codePointAt(s+2)|32;if(t[s+1]==="2"&&f===102)return o(new ot({module:"Path",method:"fromFileUrl",description:"must not include encoded / characters"}))}return q({try:()=>decodeURIComponent(t),catch:(s)=>new ot({module:"Path",method:"fromFileUrl",cause:s})})}var T=function(){let t="",s=!1,f=void 0;for(let l=arguments.length-1;l>=-1&&!s;l--){let n;if(l>=0)n=arguments[l];else{let x=globalThis.process;if(f===void 0&&"process"in globalThis&&typeof x==="object"&&x!==null&&typeof x.cwd==="function")f=x.cwd();n=f}if(n.length===0)continue;t=n+"/"+t,s=n.charCodeAt(0)===47}if(t=E(t,!s),s)if(t.length>0)return"/"+t;else return"/";else if(t.length>0)return t;else return"."},W=47;function G(e){let t=new URL("file://"),s=T(e);if(e.charCodeAt(e.length-1)===W&&s[s.length-1]!=="/")s+="/";return t.pathname=X(s),r(t)}var J=/%/g,Q=/\\/g,V=/\n/g,K=/\r/g,j=/\t/g;function X(e){if(e.includes("%"))e=e.replace(J,"%25");if(e.includes("\\"))e=e.replace(Q,"%5C");if(e.includes(`
|
|
2
|
+
`))e=e.replace(V,"%0A");if(e.includes("\r"))e=e.replace(K,"%0D");if(e.includes("\t"))e=e.replace(j,"%09");return e}var S=Un({resolve:T,normalize(e){if(e.length===0)return".";let t=e.charCodeAt(0)===47,s=e.charCodeAt(e.length-1)===47;if(e=E(e,!t),e.length===0&&!t)e=".";if(e.length>0&&s)e+="/";if(t)return"/"+e;return e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return".";let e;for(let t=0;t<arguments.length;++t){let s=arguments[t];if(s.length>0)if(e===void 0)e=s;else e+="/"+s}if(e===void 0)return".";return S.normalize(e)},relative(e,t){if(e===t)return"";if(e=S.resolve(e),t=S.resolve(t),e===t)return"";let s=1;for(;s<e.length;++s)if(e.charCodeAt(s)!==47)break;let f=e.length,l=f-s,n=1;for(;n<t.length;++n)if(t.charCodeAt(n)!==47)break;let m=t.length-n,d=l<m?l:m,h=-1,p=0;for(;p<=d;++p){if(p===d){if(m>d){if(t.charCodeAt(n+p)===47)return t.slice(n+p+1);else if(p===0)return t.slice(n+p)}else if(l>d){if(e.charCodeAt(s+p)===47)h=p;else if(p===0)h=0}break}let A=e.charCodeAt(s+p),L=t.charCodeAt(n+p);if(A!==L)break;else if(A===47)h=p}let g="";for(p=s+h+1;p<=f;++p)if(p===f||e.charCodeAt(p)===47)if(g.length===0)g+="..";else g+="/..";if(g.length>0)return g+t.slice(n+h);else{if(n+=h,t.charCodeAt(n)===47)++n;return t.slice(n)}},dirname(e){if(e.length===0)return".";let t=e.charCodeAt(0),s=t===47,f=-1,l=!0;for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!l){f=n;break}}else l=!1;if(f===-1)return s?"/":".";if(s&&f===1)return"//";return e.slice(0,f)},basename(e,t){let s=0,f=-1,l=!0,n;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";let x=t.length-1,m=-1;for(n=e.length-1;n>=0;--n){let d=e.charCodeAt(n);if(d===47){if(!l){s=n+1;break}}else{if(m===-1)l=!1,m=n+1;if(x>=0)if(d===t.charCodeAt(x)){if(--x===-1)f=n}else x=-1,f=m}}if(s===f)f=m;else if(f===-1)f=e.length;return e.slice(s,f)}else{for(n=e.length-1;n>=0;--n)if(e.charCodeAt(n)===47){if(!l){s=n+1;break}}else if(f===-1)l=!1,f=n+1;if(f===-1)return"";return e.slice(s,f)}},extname(e){let t=-1,s=0,f=-1,l=!0,n=0;for(let x=e.length-1;x>=0;--x){let m=e.charCodeAt(x);if(m===47){if(!l){s=x+1;break}continue}if(f===-1)l=!1,f=x+1;if(m===46){if(t===-1)t=x;else if(n!==1)n=1}else if(t!==-1)n=-1}if(t===-1||f===-1||n===0||n===1&&t===f-1&&t===s+1)return"";return e.slice(t,f)},format:function(t){if(t===null||typeof t!=="object")throw TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return z("/",t)},parse(e){let t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;let s=e.charCodeAt(0),f=s===47,l;if(f)t.root="/",l=1;else l=0;let n=-1,x=0,m=-1,d=!0,h=e.length-1,p=0;for(;h>=l;--h){if(s=e.charCodeAt(h),s===47){if(!d){x=h+1;break}continue}if(m===-1)d=!1,m=h+1;if(s===46){if(n===-1)n=h;else if(p!==1)p=1}else if(n!==-1)p=-1}if(n===-1||m===-1||p===0||p===1&&n===m-1&&n===x+1){if(m!==-1)if(x===0&&f)t.base=t.name=e.slice(1,m);else t.base=t.name=e.slice(x,m)}else{if(x===0&&f)t.name=e.slice(1,n),t.base=e.slice(1,m);else t.name=e.slice(x,n),t.base=e.slice(x,m);t.ext=e.slice(n,m)}if(x>0)t.dir=e.slice(0,x-1);else if(f)t.dir="/";return t},sep:"/",fromFileUrl:_,toFileUrl:G,toNamespacedPath:c}),Y=Re(Ft)(S);export{Ss,pi,Ft,Un,fi};
|
package/index.js
CHANGED
|
@@ -1,74 +1,89 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
3
|
-
`),y!=="check")return 1;return
|
|
4
|
-
`),
|
|
5
|
-
`),
|
|
6
|
-
`),2;let{Option:e}=await import("./chunk-
|
|
7
|
-
`);return 0}async function
|
|
8
|
-
`);return 0}async function W(){let{Effect:
|
|
9
|
-
`);return}let
|
|
10
|
-
`),process.stdout.isTTY)await e(
|
|
11
|
-
`),
|
|
12
|
-
`);return
|
|
13
|
-
`),1;let e=
|
|
14
|
-
`:`${
|
|
15
|
-
`),0}let{ConsoleClient:
|
|
16
|
-
`);let
|
|
17
|
-
`),1;if(e&&
|
|
18
|
-
`),1;let
|
|
2
|
+
import{Me}from"./chunk-jh21wbwd.js";import{spawn as F}from"node:child_process";import N from"node:path";import{parseArgs as q}from"node:util";var S=q({allowPositionals:!0,strict:!1,options:{harness:{type:"string"},server:{type:"string"},json:{type:"boolean"},quiet:{type:"boolean"},remove:{type:"boolean"}}}),y=S.positionals[0],g=S.values,k=R("harness")??process.env.OPENCODE_CONSOLE_HARNESS,_="Not signed in. Run `npx @opencode/console login` or set OPENCODE_API_KEY.",j=["claude-code","pi","codex"],H=["claude-code","codex"],J={check:B,hook:V,login:Z,logout:se,"mcp-headers":ne,setup:Q,status:re,sync:ie,token:ae},x,K=y?J[y]:void 0;if(!K)process.stdout.write(pe()),process.exit(y&&!["help","--help","-h"].includes(y)?1:0);process.exitCode=await K().catch(async(o)=>{if(y==="hook")return b(`opencode-console couldn't check this: ${h(o)}`);if(process.stderr.write(`${h(o)}
|
|
3
|
+
`),y!=="check")return 1;return T(`opencode-console couldn't check this call: ${h(o)}`)});async function B(){let{Option:o,Schema:e}=await import("./chunk-p7wsm5k0.js"),t=e.decodeUnknownOption(e.fromJsonString(e.Struct({action:e.NonEmptyString,resources:e.NonEmptyArray(e.String),directory:e.optional(e.String),path:e.optional(e.String),shell:e.optional(e.String)})))(await L());if(o.isNone(t))return process.stderr.write(`Expected JSON on stdin: {"action": "...", "resources": ["...", ...]}
|
|
4
|
+
`),T("opencode-console couldn't read this tool call, so it was blocked");let[s]=await M([t.value]);return process.stdout.write(`${JSON.stringify(s)}
|
|
5
|
+
`),s?.effect==="deny"?2:0}async function V(){let o=S.positionals[1];if(!o||!H.includes(o))return process.stderr.write(`Usage: opencode-console hook <${H.join("|")}>
|
|
6
|
+
`),2;let{Option:e}=await import("./chunk-p7wsm5k0.js"),{ClaudeCodeHook:t}=await import("./chunk-kdkxhbxc.js"),s=await L();x=t.eventName(s);let r=o==="codex"?await G(s):c(t.decode(s));if(r===void 0)return b("opencode-console couldn't read this hook's input, so it was blocked");if(x==="SessionStart")return X();if(r.length===0)return 0;let a=(await M(r)).find((n)=>n.effect==="deny");return a?.effect==="deny"?b(a.message):0;function c(n){return e.isNone(n)?void 0:t.checks(n.value)}}async function G(o){let{Option:e}=await import("./chunk-p7wsm5k0.js"),{CodexHook:t}=await import("./chunk-c16zjbe1.js"),{Library:s}=await import("./chunk-xeq3evq0.js"),{WorkspaceSnapshot:r}=await import("./chunk-c9kvdzct.js"),{ConsoleStore:a}=await import("./chunk-mpmqsnkz.js"),c=t.decode(o);if(e.isNone(c))return;let n=r.read(a.make())?.config??{};return t.checks(c.value,{directory:process.cwd(),platform:process.platform,servers:Object.keys(s.servers(n))})}async function X(){let{ConsoleStore:o}=await import("./chunk-mpmqsnkz.js"),{ConsoleCredentials:e}=await import("./chunk-kvqewrn5.js"),{WorkspaceSync:t}=await import("./chunk-hpy9mszv.js"),s=o.make(),r=e.read(s);if(!r)return 0;await A({always:!0,force:!0});let a=t.current(s,e.owner(r))?.status;if(a)process.stdout.write(`${JSON.stringify({systemMessage:`${a.message}${a.url?`: ${a.url}`:""}`})}
|
|
7
|
+
`);return 0}async function M(o){let{Effect:e}=await import("./chunk-p7wsm5k0.js"),{ConsoleStore:t}=await import("./chunk-mpmqsnkz.js"),{ConsoleCredentials:s}=await import("./chunk-kvqewrn5.js"),{WorkspaceSnapshot:r}=await import("./chunk-c9kvdzct.js"),{PolicyEvaluator:a}=await import("./chunk-mzpdnb17.js"),c=t.make(),n=s.read(c),i=n&&s.owner(n),l=n?r.read(c):void 0,d=i&&l?.owner!==i?await(async()=>(await A({always:!0}),ce(()=>{let u=r.read(c);return u?.owner===i?u:void 0},3000)))():l&&r.stale(l,Date.now())?(await A(),l):l,p=r.workspace(n,d);return e.runPromise(e.forEach(o,(u)=>a.check(p,u)))}async function Z(){if(!await W())return 1;if(process.env.OPENCODE_API_KEY)process.stderr.write(`OPENCODE_API_KEY is set, so opencode-console keeps using that key until it's unset
|
|
8
|
+
`);return 0}async function W(){let{Effect:o}=await import("./chunk-p7wsm5k0.js"),{openUrl:e}=await import("./chunk-aesb1szb.js"),{ConsoleClient:t}=await import("./chunk-vqmbpbbm.js"),{ConsoleStore:s}=await import("./chunk-mpmqsnkz.js"),{ConsoleCredentials:r}=await import("./chunk-kvqewrn5.js"),{WorkspaceSync:a}=await import("./chunk-hpy9mszv.js"),c=R("server")??process.env.OPENCODE_CONSOLE_SERVER??t.defaultServer,n=t.normalizeServer(c);if(!n){process.stderr.write(`Not a Console URL: ${c}
|
|
9
|
+
`);return}let i=s.make(),l=await f(r.login(i,{server:n,prompt:(p)=>o.promise(async()=>{if(process.stderr.write(`Open ${p.url} and confirm the code ${p.code}
|
|
10
|
+
`),process.stdout.isTTY)await e(p.url).catch(()=>{return})})})),d=await f(a.sync(i,{force:!0}));if(process.stdout.write(`Signed in to ${l.orgName??"OpenCode Console"}${l.email?` as ${l.email}`:""}
|
|
11
|
+
`),d.error)process.stderr.write(`Couldn't fetch the workspace config: ${h(d.error)}. Run the command again to retry.
|
|
12
|
+
`);return l}async function Q(){let o=S.positionals[1];if(!o||!j.includes(o))return process.stderr.write(`Usage: opencode-console setup <${j.join("|")}> [--remove]
|
|
13
|
+
`),1;let e=o==="pi",t=o==="codex",s=e?"Pi":t?"Codex":"Claude Code",{ConsoleStore:r}=await import("./chunk-mpmqsnkz.js"),{ConsoleCredentials:a}=await import("./chunk-kvqewrn5.js"),{CliInstall:c}=await import("./chunk-5w6hy202.js"),{WorkspaceSync:n}=await import("./chunk-hpy9mszv.js"),i=r.make();if(g.remove===!0){let{Effect:v}=await import("./chunk-p7wsm5k0.js"),{ClaudeCode:O}=await import("./chunk-2ktsq2gj.js"),{Codex:P}=await import("./chunk-nvh2a5rc.js"),{Pi:C}=await import("./chunk-eyf3z07t.js"),Y=await v.runPromise(r.locked(i,v.sync(()=>{let U=e?C.remove(i):t?P.remove(i):O.remove(i);if(![O.manifestFile(i),C.manifestFile(i),P.manifestFile(i)].some((z)=>r.read(z)!==void 0))c.uninstall(i);return U})));return process.stdout.write(Y?`Removed OpenCode Console from ${s} and restored its settings. You're still signed in; \`npx @opencode/console logout\` signs out.
|
|
14
|
+
`:`${s} wasn't set up with OpenCode Console
|
|
15
|
+
`),0}let{ConsoleClient:l}=await import("./chunk-vqmbpbbm.js"),d=await de(e?"pi":t?"codex":"claude");if(d)k=e?`pi/${d}`:t?`codex_cli_rs/${d}`:`claude-cli/${d}`;let p=a.read(i),u=R("server");if(!p||u!==void 0&&p.server!==l.normalizeServer(u)){if(!await W())return 1}if(process.env.OPENCODE_API_KEY)process.stderr.write(`OPENCODE_API_KEY is set, so setup used that key, and ${s} will use it instead of your sign-in wherever it's set.
|
|
16
|
+
`);let w=await f(n.sync(i,{force:!0}));if(!w.snapshot?.config)return process.stderr.write(`Couldn't fetch the workspace config${w.error?`: ${h(w.error)}`:""}. Run setup again.
|
|
17
|
+
`),1;if(e&&D())return process.stderr.write("Set up Pi with the npm package: `npx @opencode/console setup pi`\n"),1;let E=c.install(i,{execPath:process.execPath,entry:D()?void 0:process.argv[1],path:process.env.PATH});if(t)return te(i,E,w.snapshot,d);return e?oe(i,E,w.snapshot,d):ee(i,E,w.snapshot,d)}async function ee(o,e,t,s){let{ClaudeCode:r}=await import("./chunk-2ktsq2gj.js"),{WorkspaceSnapshot:a}=await import("./chunk-c9kvdzct.js"),c=a.policies(t),n=await f(r.refresh(o,{paths:r.paths(),command:e,harness:s?`claude-cli/${s}`:void 0}));if(!n)return process.stderr.write(`Couldn't read the workspace config. Run setup again.
|
|
18
|
+
`),1;let l=[`Claude Code now uses ${t.organization??"your workspace"} through OpenCode Console.`,"",...n.models?[` Models ${m(n.models.options.length,"model","models")} in /model; opus is ${n.models.tiers.opus}, sonnet ${n.models.tiers.sonnet}, haiku ${n.models.tiers.haiku}`]:[" Models none from the workspace, so Claude Code keeps its own sign-in"],` Policies ${m(c?.length??0,"rule","rules")}, checked before every tool call`,...n.servers.length>0?[` MCP ${n.servers.join(", ")}`]:[],...I(n.instructions,n.skills.map((p)=>`/${p}`))];if(process.stdout.write(`${l.join(`
|
|
19
19
|
`)}
|
|
20
20
|
`),n.skipped.length>0)process.stderr.write(`
|
|
21
21
|
Kept your own ${n.skipped.join(", ")}, so the workspace's of the same name weren't added.
|
|
22
|
-
`);if(!
|
|
22
|
+
`);if(!s)process.stderr.write(`
|
|
23
23
|
Claude Code isn't on your PATH yet; these settings apply once it's installed.
|
|
24
|
-
`);let
|
|
25
|
-
${
|
|
24
|
+
`);let d=["ANTHROPIC_AUTH_TOKEN","ANTHROPIC_API_KEY"].filter((p)=>process.env[p]);if(n.models&&d.length>0)process.stderr.write(`
|
|
25
|
+
${d.join(" and ")} ${d.length===1?"is":"are"} set in your shell and Claude Code would use ${d.length===1?"it":"them"} instead of the workspace. Unset ${d.length===1?"it":"them"} before running claude.
|
|
26
26
|
`);return process.stdout.write(`
|
|
27
27
|
Run claude to start.
|
|
28
|
-
`),0}async function
|
|
29
|
-
`);return});let u=
|
|
28
|
+
`),0}async function oe(o,e,t,s){let{Pi:r}=await import("./chunk-eyf3z07t.js"),{Library:a}=await import("./chunk-xeq3evq0.js"),{WorkspaceSnapshot:c}=await import("./chunk-c9kvdzct.js"),n=e.at(-1),i=N.join(N.dirname(n),`pi-extension${N.extname(n)}`),l=r.session({store:o,...k?{harness:k}:{}}),d=await r.models(l),p=d&&r.defaultModel(d);await r.skills(l).catch((C)=>{process.stderr.write(`Couldn't download the Library's skills yet (${h(C)}); Pi tries again when it starts.
|
|
29
|
+
`);return});let u=t.config??{},{Effect:w}=await import("./chunk-p7wsm5k0.js"),{ConsoleStore:E}=await import("./chunk-mpmqsnkz.js");await w.runPromise(E.locked(o,w.sync(()=>r.setup(o,{paths:r.paths(),extension:i,...p?{model:p}:{}}))));let v=d?r.providers(d,()=>{return}).flatMap((C)=>C.models):[],O=Object.keys(a.servers(u)),P=[`Pi now uses ${t.organization??"your workspace"} through OpenCode Console.`,"",p?` Models ${m(v.length,"model","models")} in /model; new sessions start on ${p.provider}/${p.id}`:" Models none from the workspace, so Pi keeps its own providers",` Policies ${m(c.policies(t)?.length??0,"rule","rules")}, checked before every tool call and !command`,...O.length>0?[` MCP ${O.join(", ")}`]:[],...I(a.library(u).instructions.length,a.library(u).skills.map((C)=>`/skill:${C.slug}`))];if(process.stdout.write(`${P.join(`
|
|
30
30
|
`)}
|
|
31
|
-
`),!
|
|
31
|
+
`),!s)process.stderr.write(`
|
|
32
32
|
Pi isn't on your PATH yet; this applies once it's installed.
|
|
33
33
|
`);return process.stdout.write(`
|
|
34
34
|
Run pi to start.
|
|
35
|
-
`),0}function
|
|
36
|
-
`),1;let
|
|
37
|
-
`)
|
|
35
|
+
`),0}async function te(o,e,t,s){let{Codex:r}=await import("./chunk-nvh2a5rc.js"),{WorkspaceSnapshot:a}=await import("./chunk-c9kvdzct.js"),c=Object.fromEntries(["XDG_DATA_HOME","XDG_CACHE_HOME","OPENCODE_CONSOLE_SERVER"].flatMap((u)=>process.env[u]?[[u,process.env[u]]]:[])),n=await f(r.refresh(o,{paths:r.paths(),command:e,harness:s?`codex_cli_rs/${s}`:void 0,environment:c}));if(!n)return process.stderr.write(`Couldn't read the workspace config. Run setup again.
|
|
36
|
+
`),1;let i=a.policies(t)?.length??0,l=[`Codex now uses ${t.organization??"your workspace"} through OpenCode Console.`,"",n.models?` Models ${m(n.models.count,"model","models")} in /model; new sessions start on ${n.models.model}`:" Models none from the workspace, so Codex keeps its own sign-in",` Policies ${m(i,"rule","rules")}, checked before every tool call${n.rules>0?`; Codex also enforces ${m(n.rules,"shell rule","shell rules")} itself`:""}`,...n.searchOff?[" Search Codex's web search is off, since the workspace's policy limits it"]:[],...n.servers.length>0?[` MCP ${n.servers.join(", ")}`]:[],...I(n.instructions,n.skills.map((u)=>`$${u}`))];if(process.stdout.write(`${l.join(`
|
|
37
|
+
`)}
|
|
38
|
+
`),n.skipped.length>0)process.stderr.write(`
|
|
39
|
+
Kept your own ${n.skipped.join(", ")}, so the workspace's of the same name weren't added.
|
|
40
|
+
`);let{Library:d}=await import("./chunk-xeq3evq0.js"),p=Object.entries(d.servers(t.config??{})).filter(([u,w])=>w.headers!==void 0&&n.servers.includes(u)).map(([u])=>u);if(process.env.OPENCODE_API_KEY&&p.length>0)process.stderr.write(`
|
|
41
|
+
Codex connects to ${p.join(", ")} without your shell's environment, so ${p.length===1?"it":"they"} can't use OPENCODE_API_KEY. Run \`npx @opencode/console login\` to connect ${p.length===1?"it":"them"}.
|
|
42
|
+
`);if(!s)process.stderr.write(`
|
|
43
|
+
Codex isn't on your PATH yet; these settings apply once it's installed.
|
|
44
|
+
`);return process.stdout.write(`
|
|
45
|
+
Run codex to start.
|
|
46
|
+
`),0}function I(o,e){if(o+e.length===0)return[];return[` Library ${[...o>0?[m(o,"instruction","instructions")]:[],...e.length>0?[e.join(", ")]:[]].join(", ")}`]}async function ne(){let o=S.positionals[1];if(!o)return process.stderr.write(`Usage: opencode-console mcp-headers <server>
|
|
47
|
+
`),1;let{Option:e,Schema:t}=await import("./chunk-p7wsm5k0.js"),{ConsoleStore:s}=await import("./chunk-mpmqsnkz.js"),{WorkspaceSync:r}=await import("./chunk-hpy9mszv.js"),{snapshot:a}=await f(r.sync(s.make()));if(!a)return process.stderr.write(`${_}
|
|
48
|
+
`),1;let c=t.decodeUnknownOption(t.Struct({servers:t.Record(t.String,t.Struct({headers:t.optional(t.Record(t.String,t.String))}))}))(a.config?.mcp),n=e.getOrUndefined(c)?.servers[o];if(!n)return process.stderr.write(`The workspace doesn't offer the MCP server ${o} anymore
|
|
38
49
|
`),1;return process.stdout.write(`${JSON.stringify(n.headers??{})}
|
|
39
|
-
`),0}async function
|
|
50
|
+
`),0}async function se(){let{ConsoleStore:o}=await import("./chunk-mpmqsnkz.js"),{ConsoleCredentials:e}=await import("./chunk-kvqewrn5.js"),t=await f(e.logout(o.make()));if(process.stdout.write(t?`Signed out of OpenCode Console
|
|
40
51
|
`:`Not signed in
|
|
41
52
|
`),process.env.OPENCODE_API_KEY)process.stdout.write(`OPENCODE_API_KEY is still set, so opencode-console keeps using that key
|
|
42
|
-
`);return 0}async function
|
|
43
|
-
`),0;if(!
|
|
44
|
-
`),0;let
|
|
45
|
-
`).join("")),
|
|
46
|
-
${
|
|
47
|
-
`);return 0}async function
|
|
48
|
-
`)})
|
|
49
|
-
`)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
`),
|
|
53
|
-
`),
|
|
54
|
-
`),
|
|
55
|
-
`),
|
|
53
|
+
`);return 0}async function re(){let{ConsoleStore:o}=await import("./chunk-mpmqsnkz.js"),{ConsoleCredentials:e}=await import("./chunk-kvqewrn5.js"),{WorkspaceSnapshot:t}=await import("./chunk-c9kvdzct.js"),{WorkspaceSync:s}=await import("./chunk-hpy9mszv.js"),r=o.make(),a=e.read(r),c=a?(await f(s.sync(r))).snapshot:void 0,n=t.policies(c),i=a&&{server:a.server,credential:a.type==="key"?"OPENCODE_API_KEY":"device",email:a.type==="oauth"?a.email:void 0,workspace:c?.organization??e.organization(a),synced:n&&c?new Date(c.fetched).toISOString():void 0,policies:n?.length,models:t.models(c),needs:c?.status};if(g.json===!0)return process.stdout.write(`${JSON.stringify({signedIn:Boolean(i),...i})}
|
|
54
|
+
`),0;if(!i)return process.stdout.write(`${_}
|
|
55
|
+
`),0;let l=[["Signed in",i.credential==="OPENCODE_API_KEY"?"with OPENCODE_API_KEY":i.email??"yes"],...i.workspace?[["Workspace",i.workspace]]:[],["Console",i.server],["Policies",i.synced?`${m(i.policies??0,"policy","policies")}, synced at ${new Date(i.synced).toLocaleTimeString()}`:"not loaded yet, so tool calls are blocked"],["Models",i.models?`${i.models} from the workspace`:"none from the workspace"]];if(process.stdout.write(l.map(([d,p])=>`${d?.padEnd(10)} ${p}
|
|
56
|
+
`).join("")),i.needs)process.stdout.write(`
|
|
57
|
+
${i.needs.message}${i.needs.url?`: ${i.needs.url}`:""}
|
|
58
|
+
`);return 0}async function ie(){let{ConsoleStore:o}=await import("./chunk-mpmqsnkz.js"),{WorkspaceSnapshot:e}=await import("./chunk-c9kvdzct.js"),{WorkspaceSync:t}=await import("./chunk-hpy9mszv.js"),s=o.make(),r=e.read(s)?.fetched,a=await f(t.sync(s,{force:g.quiet!==!0||process.env.OPENCODE_CONSOLE_FORCE==="1"}));if(a.snapshot?.config&&!a.error&&a.snapshot.fetched!==r){let{ClaudeCode:i}=await import("./chunk-2ktsq2gj.js"),{Codex:l}=await import("./chunk-nvh2a5rc.js");await f(i.refresh(s)).catch((d)=>{if(g.quiet!==!0)process.stderr.write(`Couldn't update Claude Code: ${h(d)}
|
|
59
|
+
`)}),await f(l.refresh(s)).catch((d)=>{if(g.quiet!==!0)process.stderr.write(`Couldn't update Codex: ${h(d)}
|
|
60
|
+
`)})}if(g.quiet===!0)return a.error?1:0;if(!a.snapshot&&!a.error)return process.stderr.write(`${_}
|
|
61
|
+
`),1;if(a.error){let i=e.policies(a.snapshot)?`
|
|
62
|
+
Policies from the last sync still apply.`:"";return process.stderr.write(`Couldn't sync: ${h(a.error)}${i}
|
|
63
|
+
`),1}let c=a.snapshot?.organization,n=e.policies(a.snapshot)?.length??0;return process.stdout.write(`Synced ${c?`${c}'s`:"the workspace"} config (${m(n,"policy","policies")})
|
|
64
|
+
`),0}async function ae(){let{ConsoleStore:o}=await import("./chunk-mpmqsnkz.js"),{ConsoleCredentials:e}=await import("./chunk-kvqewrn5.js"),t=await f(e.fresh(o.make()));if(!t)return process.stderr.write(`${_}
|
|
65
|
+
`),1;return process.stdout.write(`${t.type==="key"?t.key:t.access}
|
|
66
|
+
`),0}async function f(o){let{Effect:e,Layer:t}=await import("./chunk-p7wsm5k0.js"),{FetchHttpClient:s}=await import("./chunk-aym5xapq.js"),{WorkspaceSync:r}=await import("./chunk-hpy9mszv.js");return e.runPromise(o.pipe(e.provide(r.identify({version:Me,harness:k}).pipe(t.provide(s.layer)))))}async function A(o={}){let{ConsoleStore:e}=await import("./chunk-mpmqsnkz.js"),t=e.syncClaimFile(e.make());try{let s=e.modified(t);if(!o.always&&s!==void 0&&Date.now()-s<30000)return;e.write(t,"");let r=D()?[process.execPath]:[process.execPath,process.argv[1]];F(r[0],[...r.slice(1),"sync","--quiet",...k?["--harness",k]:[]],{detached:!0,stdio:"ignore",env:{...process.env,...o.force?{OPENCODE_CONSOLE_FORCE:"1"}:{}}}).on("error",()=>{return}).unref()}catch{return}}async function ce(o,e){let t=Date.now()+e;for(;;){let s=o();if(s!==void 0||Date.now()>=t)return s;await new Promise((r)=>setTimeout(r,25))}}async function b(o){let{ClaudeCodeHook:e}=await import("./chunk-kdkxhbxc.js"),t=e.denial(x,o);return process.stdout.write(t.stdout),process.stderr.write(t.stderr),t.code}async function de(o){let{execFile:e}=await import("node:child_process");return new Promise((t)=>e(o,["--version"],{timeout:1e4},(s,r)=>t(s?void 0:r.match(/\d+\.\d+\.\d+\S*/)?.[0])))}function T(o){return process.stdout.write(`${JSON.stringify({effect:"deny",message:o})}
|
|
67
|
+
`),2}function m(o,e,t){return`${o} ${o===1?e:t}`}function D(){return/^(\/\$bunfs\/|[A-Za-z]:[\\/]~BUN[\\/])/.test(process.argv[1]??"")}async function L(){let o=[];for await(let e of process.stdin)o.push(Buffer.from(e));return Buffer.concat(o).toString("utf8")}function h(o){return o instanceof Error?o.message:String(o)}function R(o){let e=g[o];return typeof e==="string"?e:void 0}function pe(){return`opencode-console ${Me}
|
|
56
68
|
Connect coding agents to an OpenCode Console workspace: its models, MCP servers, Library and policies.
|
|
57
69
|
|
|
58
70
|
Usage: opencode-console <command> [options]
|
|
59
71
|
|
|
60
72
|
Commands:
|
|
61
|
-
setup <claude-code|pi>
|
|
62
|
-
|
|
73
|
+
setup <claude-code|pi|codex>
|
|
74
|
+
Sign in if needed and set up Claude Code, Pi or Codex to use the
|
|
75
|
+
workspace (--remove undoes it)
|
|
63
76
|
login [--server <url>] Sign in to OpenCode Console and pick a workspace
|
|
64
77
|
logout Sign out and remove the stored workspace config
|
|
65
78
|
status [--json] Show the sign-in, workspace and config
|
|
66
79
|
sync Fetch the workspace config now
|
|
67
80
|
token Print an access token for auth helpers such as Claude Code's apiKeyHelper
|
|
81
|
+
and Codex's model provider auth
|
|
68
82
|
check Check a tool call against the workspace's policies. Reads
|
|
69
83
|
{"action": "...", "resources": [...]} on stdin, with optional
|
|
70
84
|
"directory", "path" and "shell"; exits 0 to allow, 2 to deny
|
|
71
|
-
hook claude-code
|
|
85
|
+
hook <claude-code|codex>
|
|
86
|
+
Answer a Claude Code or Codex hook (setup registers it)
|
|
72
87
|
mcp-headers <server> Print a workspace MCP server's headers (setup registers it)
|
|
73
88
|
|
|
74
89
|
Options:
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opencode/console",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Connect Claude Code and
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Connect Claude Code, Pi and Codex to an OpenCode Console workspace and enforce its policies",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"opencode",
|
|
7
7
|
"claude-code",
|
|
8
|
+
"codex",
|
|
8
9
|
"pi-package",
|
|
9
10
|
"coding-agent",
|
|
10
11
|
"policy"
|
package/pi-extension.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-
|
|
2
|
-
`,exitCode:1,cancelled:!1,truncated:!1}}}),e.on("input",async(s,r)=>{if(p(n))await x(r).catch(()=>{return});let i=
|
|
1
|
+
import"./chunk-zdf3mvav.js";import"./chunk-2y9vn023.js";import"./chunk-p59r4b0j.js";import"./chunk-6rpbc10h.js";import{He,xt}from"./chunk-5q7mrvv1.js";import{gt,en}from"./chunk-frqdgjbd.js";import"./chunk-81fv1abj.js";import"./chunk-wjghq897.js";import"./chunk-6mydq7cv.js";import"./chunk-sn451nak.js";import{Ro,Mo,Fo,No,Do,Uo,Tn,Lo,On,Xn,it,Bo,zo}from"./chunk-03p95nje.js";import"./chunk-fzckrdm3.js";import{k,q,zt,vr,Kt}from"./chunk-bkr0zk6g.js";var S={};k(S,{PiExtension:()=>S,default:()=>O,install:()=>R});import{existsSync as B}from"node:fs";import T from"node:path";import{anthropicMessagesApi as j,createProvider as H,googleGenerativeAIApi as K,openAICompletionsApi as D,openAIResponsesApi as F}from"@earendil-works/pi-ai/compat";import{getBuiltinModels as G,getBuiltinProviders as b}from"@earendil-works/pi-ai/providers/all";import{VERSION as J}from"@earendil-works/pi-coding-agent";async function O(e){await R(e,Lo({harness:`pi/${J}`}))}var L=(e,n,o)=>{let a=b();return[...a.filter((t)=>t===e),...a.filter((t)=>t==="opencode"&&t!==e),...a.filter((t)=>t!==e&&t!=="opencode")].flatMap((t)=>G(t).filter((f)=>f.id===n&&f.api===o)).at(0)},U="opencode_workspace_instructions";async function R(e,n){let o=new Set,a=new Map,d=new Map,t=p(n),f=t?await Bo(n).catch(()=>{return}):void 0;if(Ro(f??{},L).forEach((s)=>{o.add(s.id),e.registerProvider(H({id:s.id,name:s.name,auth:{apiKey:{name:"OpenCode Console",resolve:()=>V(n)}},models:s.models,api:{"anthropic-messages":P(j()),"openai-responses":P(F()),"openai-completions":P(D()),"google-generative-ai":P(K())}}))}),t&&(await it(n).catch(()=>{return}))?.config)["opencode","opencode-go"].filter((s)=>!o.has(s)).forEach((s)=>{o.add(s),e.registerProvider(s,{models:[]})});if(t)await M(e,n,d).catch(()=>{return});let m=f&&Mo(f),h={},E=async(s)=>{let r=[...s.modelRegistry.getAll().map((c)=>c.provider),...b(),...s.modelRegistry.getRegisteredProviderIds(),...a.keys()],i=[...new Set(r)].filter((c)=>!o.has(c)),u=await Xn(n,i.map((c)=>({action:"provider.use",resources:[c]}))).catch(()=>{return});i.forEach((c,w)=>{let v=u?.[w]?.effect!=="allow";if(v&&!a.has(c)){let _=s.modelRegistry.getRegisteredNativeProvider(c);a.set(c,()=>{if(e.unregisterProvider(c),_)e.registerProvider(_)}),e.registerProvider(c,{models:[]})}let C=v?void 0:a.get(c);if(C)a.delete(c),C()}),h.fetched=(await it(n).catch(()=>{return}))?.fetched;let l=s.model,g=m&&s.modelRegistry.find(m.provider,m.id);if(g&&(!l||a.has(l.provider)))await e.setModel(g)},x=async(s)=>{let r=await it(n);if(r?.fetched!==h.fetched)await E(s);return r};e.on("session_start",async(s,r)=>{if(!p(n)){y(r,"OpenCode Console isn't signed in. Run `npx @opencode/console login`.","warning");return}let i=await it(n).catch(()=>{return});if(i?.status)y(r,`${i.status.message}${i.status.url?`: ${i.status.url}`:""}`,"warning");await E(r)}),e.on("resources_discover",async()=>{if(!p(n))return;let s=await zo(n).catch(()=>A(n));return B(s)?{skillPaths:[s]}:void 0}),e.on("before_agent_start",async(s,r)=>{if(!p(n))return;let i=s.systemPromptOptions,u=i.skills??[],l=await(async()=>{let g=await x(r),c=await Xn(n,u.map((w)=>({action:"skill",resources:[w.name]})));return{text:Uo(g?.config?gt(g.config).instructions:[]),skills:u.filter((w,v)=>c[v]?.effect==="allow")}})().catch(()=>({text:void 0,skills:[]}));if(l.text)i.sections={...i.sections,[U]:l.text};i.skills=l.skills}),e.on("tool_call",async(s,r)=>{let i=e.getAllTools(),u=i.find((c)=>c.name===s.toolName)?.namespace?.aliases?.[0],l=[...new Set([...i.flatMap((c)=>c.namespace?.aliases?.slice(0,1)??[]),...e.getMcpServers().map((c)=>c.name)])],g=await On(n,Fo(s,{cwd:r.cwd,server:u,servers:l,skills:A(n)}));return g?.effect==="deny"?{block:!0,reason:g.message}:void 0}),e.on("user_bash",async(s,r)=>{let i=await On(n,[No(s)]);if(i?.effect!=="deny")return;return y(r,i.message,"error"),{result:{output:`${i.message}
|
|
2
|
+
`,exitCode:1,cancelled:!1,truncated:!1}}}),e.on("input",async(s,r)=>{if(p(n))await x(r).catch(()=>{return});let i=Do(s.text);if(!i)return{action:"continue"};let u=await On(n,[{action:"skill",resources:[i]}]).catch((l)=>N(`/skill:${i}`,l));if(u?.effect!=="deny")return{action:"continue"};return y(r,u.message,"error"),{action:"handled"}}),e.on("before_provider_request",async(s,r)=>{let i=await I(n,r);if(i?.effect!=="deny")return;y(r,i.message,"error"),r.abort();return}),e.on("cache_warming_decision",async(s,r)=>(await I(n,r))?.effect==="deny"?{action:"stop"}:void 0),e.on("turn_start",()=>{if(p(n))M(e,n,d).catch(()=>{return})})}function p(e){return Kt(q(()=>He(e.store)!==void 0).pipe(vr(()=>!0)))}async function I(e,n){let o=n.model?.provider;if(!o||!p(e))return;return On(e,[{action:"provider.use",resources:[o]}]).catch((a)=>N(o,a))}function N(e,n){return{effect:"deny",message:`opencode-console couldn't check ${e}: ${n instanceof Error?n.message:String(n)}`}}var A=(e)=>T.join(Tn(e.store),"skills");async function M(e,n,o){let a=await it(n),d=a?.config?en(a.config):{};[...o.keys()].filter((t)=>!(t in d)).forEach((t)=>{o.delete(t),Kt(q(()=>e.unregisterMcpServer(t)).pipe(zt))}),Object.entries(d).forEach(([t,f])=>{let m={url:f.url,...f.headers?{headers:f.headers}:{}},h=JSON.stringify(m);if(o.get(t)===h)return;Kt(q(()=>{e.registerMcpServer(t,m),o.set(t,h)}).pipe(zt))})}async function V(e){let n=await e.run(xt(e.store));if(!n)return;return{auth:{apiKey:n.type==="key"?n.key:n.access},source:"OpenCode Console"}}function P(e){let n=(o)=>o?.sessionId?{...o,headers:{...o.headers,"x-opencode-session":o.sessionId}}:o;return{...e,stream:(o,a,d)=>e.stream(o,a,n(d)),streamSimple:(o,a,d)=>e.streamSimple(o,a,n(d))}}function y(e,n,o){if(e.hasUI)e.ui.notify(n,o)}export{S as PiExtension,O as default,R as install};
|
package/chunk-0krh2hdf.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Hi,Eo,wo,Pr,ko,Co,Io,Ao,Rr,wn,Mr,To,qi,Wi,Oo,_o,kn,Wn,ot,Bs,Po,Ro,Mo}from"./chunk-41p6m0xy.js";import"./chunk-g6d8xejf.js";import"./chunk-z2kmm4pm.js";import"./chunk-gtf5exm1.js";import"./chunk-sbec97g3.js";import"./chunk-dsk7ztf6.js";import"./chunk-6tene1pb.js";import"./chunk-1mfjsp5r.js";import"./chunk-ke4nwx54.js";import"./chunk-yjw665b0.js";import"./chunk-5x5fc0mq.js";import"./chunk-jqhy4pzf.js";export{Mo as Pi,Pr as Unreadable,ko as checks,ot as config,kn as decide,Wn as decisions,wo as defaultModel,wn as directory,Ao as instructions,To as manifest,Rr as manifestFile,Po as models,Mr as modelsFile,Hi as paths,Eo as providers,_o as refresh,Bs as refreshStale,Wi as remove,Oo as session,qi as setup,Io as skillCommand,Ro as skills,Co as userBash};
|
package/chunk-1c689590.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{oi,si}from"./chunk-jqhy4pzf.js";import{W,re,G,Gr,Ve,ht,De,Ft,Ss,Nt,pi,oe,Ms,Er,kr,go,Ds,Yi,Qi}from"./chunk-nva98fq1.js";export{oi as Brand,De as Cause,pi as Clock,re as Context,ht as Data,Er as DateTime,Ve as Duration,oe as Effect,Ft as Exit,Ms as Fiber,Qi as FileSystem,Nt as Layer,W as Option,si as Path,Gr as Record,G as Result,Yi as Schema,kr as SchemaGetter,go as SchemaTransformation,Ss as Scope,Ds as Struct};
|
package/chunk-1mfjsp5r.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Xo,Yn,es,ts,Lr,ss}from"./chunk-ke4nwx54.js";import{tn,At,ze,he,Re,me}from"./chunk-5x5fc0mq.js";import{w,D,xe,at,T,q,g,Dt,fr,hi,L,gr,J,se}from"./chunk-nva98fq1.js";var Qo={};w(Qo,{ConsoleCredentials:()=>Qo,fresh:()=>Qt,login:()=>Ji,logout:()=>Vi,organization:()=>In,owner:()=>Je,read:()=>je,stored:()=>Ur});import{createHash as c}from"node:crypto";var d=J(se(Yn)),f=300000;function je(e){let n=e.env.OPENCODE_API_KEY;if(!n)return Ur(e);let o=e.env.OPENCODE_CONSOLE_SERVER?.trim();if(!o)return{type:"key",server:Xo,key:n};let r=ss(o);if(!r)throw Error(`OPENCODE_CONSOLE_SERVER isn't a Console URL: ${o}. Use an https:// URL, or http:// only for localhost.`);return{type:"key",server:r,key:n}}function Ur(e){let n=i(e);if(n.corrupt)throw Error(`The sign-in in ${tn(e)} can't be read. Run \`npx @opencode/console login\` to replace it or \`npx @opencode/console logout\` to remove it.`);return n.credential}function Je(e){return JSON.stringify([e.server,e.type==="key"?c("sha256").update(e.key).digest("hex").slice(0,16):e.accountID,e.type==="oauth"?e.orgID:void 0])}function In(e){return e.type==="oauth"?e.orgName:void 0}var Ji=L("ConsoleCredentials.login")(function*(e,n){let o=yield*es(n.server);yield*n.prompt(o);let r=yield*o.callback,t=yield*ze(e,T(()=>{let l=i(e).credential;if(Re(tn(e),JSON.stringify(r)),!l||Je(l)!==Je(r))me(At(e));return l}));if(t)yield*Lr(t).pipe(Dt);return r}),Qt=L("ConsoleCredentials.fresh")(function*(e){let n=je(e);if(!n||n.type==="key"||!(yield*s(n)))return n;let o=yield*ze(e,q(function*(){let r=Ur(e);if(!r||!(yield*s(r)))return r;let t=yield*ts(r).pipe(fr(xe(30)));if(i(e).credential?.refresh!==r.refresh)return Ur(e);return Re(tn(e),JSON.stringify(t)),t})).pipe(hi);return yield*gr(o)}),Vi=L("ConsoleCredentials.logout")(function*(e){let n=yield*ze(e,T(()=>{let o=i(e).credential;return me(tn(e)),me(At(e)),o}));if(!n)return!1;return yield*Lr(n).pipe(Dt),!0});function s(e){return at.pipe(g((n)=>e.expires-f<=n))}function i(e){let n=he(tn(e));if(n===void 0)return{};let o=D(d(n));return o?{credential:o}:{corrupt:!0}}
|
|
2
|
-
export{je,Ur,Je,In,Ji,Qt,Vi,Qo};
|
package/chunk-41p6m0xy.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{pt,zr}from"./chunk-yjw665b0.js";import{er}from"./chunk-ke4nwx54.js";import{us,ls,ze,he,ps,Re,me,ft}from"./chunk-5x5fc0mq.js";import{je,Je}from"./chunk-1mfjsp5r.js";import{Uo,Gt,Jt,Lo,Nr,Ct,jo,z,Vt,Zt,Gn,Jn}from"./chunk-gtf5exm1.js";import{Fo}from"./chunk-g6d8xejf.js";import{Vn,Vo}from"./chunk-dsk7ztf6.js";import{Ho,qo,Yt}from"./chunk-sbec97g3.js";import{Fr,Do}from"./chunk-z2kmm4pm.js";import{st}from"./chunk-bgqw45qt.js";import{w,Me,D,cn,_e,T,dr,be,Ln,J,C,F,t,E,n,y,se}from"./chunk-nva98fq1.js";var Mo={};w(Mo,{Pi:()=>Mo,Unreadable:()=>Pr,checks:()=>ko,config:()=>ot,decide:()=>kn,decisions:()=>Wn,defaultModel:()=>wo,directory:()=>wn,instructions:()=>Ao,manifest:()=>To,manifestFile:()=>Rr,models:()=>Po,modelsFile:()=>Mr,paths:()=>Hi,providers:()=>Eo,refresh:()=>_o,refreshStale:()=>Bs,remove:()=>Wi,session:()=>Oo,setup:()=>qi,skillCommand:()=>Io,skills:()=>Ro,userBash:()=>Co});import{createHash as j}from"node:crypto";import{rmSync as O}from"node:fs";import b from"node:os";import u from"node:path";import{fileURLToPath as W}from"node:url";function Hi(e=process.env,o=b.homedir()){let r=e.PI_CODING_AGENT_DIR?.trim(),s=r?u.resolve(r==="~"?o:r.startsWith("~/")?u.join(o,r.slice(2)):r):u.join(o,".pi","agent");return{agent:s,settings:u.join(s,"settings.json")}}function Eo(e,o){return[...Map.groupBy(Fr(e).flatMap((s)=>A(s,o)??[]),(s)=>s.provider)].map(([s,i])=>({id:s,name:e[s]?.name??s,models:i}))}function wo(e){let o=Fr(e).filter((s)=>P(s)!==void 0),r=Do(o,"sonnet","opus","haiku");return r&&{provider:r.provider,id:r.id}}var S={messages:"anthropic-messages",responses:"openai-responses","chat-completions":"openai-completions","generate-content":"google-generative-ai"};function P(e){let o=z(e.entry.api),r=Object.keys(S).find((i)=>(i in o)),s=r&&Vt(z(o[r]).base_url);return r&&s?{api:S[r],baseURL:s}:void 0}function A(e,o){let r=P(e);if(!r)return;let s=r.api,i=o(e.provider,e.id,s),c=i?.api===s?i:void 0,d=e.entry,p=z(d.limit),a=z(z(d.cost).text),l=z(a.input),m=z(l.cache),x=z(d.modalities).input,k=z(z(d.capabilities).reasoning).supported;return{...s==="openai-completions"?{compat:I}:{},...c,id:e.id,name:Vt(d.name)??c?.name??e.id,api:s,provider:e.provider,baseUrl:s==="anthropic-messages"?r.baseURL.replace(/\/v1\/?$/,""):r.baseURL,reasoning:typeof k==="boolean"?k:c?.reasoning??!1,input:Array.isArray(x)?x.some((v)=>typeof v==="string"&&v.startsWith("image"))?["text","image"]:["text"]:c?.input??["text"],cost:{input:f(l.price)??c?.cost.input??0,output:f(z(a.output).price)??c?.cost.output??0,cacheRead:f(m.read)??c?.cost.cacheRead??0,cacheWrite:f(_(m.write))??f(_(z(m.explicit).write))??c?.cost.cacheWrite??0},contextWindow:f(p.context)??c?.contextWindow??128000,maxTokens:f(p.output)??c?.maxTokens??16384,headers:{...c?.headers,"x-opencode-plugin":`opencode-console/${st}`}}}var I={supportsStore:!1,supportsDeveloperRole:!1,supportsStrictMode:!0,maxTokensField:"max_tokens"};function _(e){return typeof e==="object"&&e!==null?Object.values(e)[0]:e}function f(e){return typeof e==="number"&&Number.isFinite(e)?e:void 0}class Pr extends Error{}function ko(e,o){let r=(a,l,m={})=>({action:a,resources:l,directory:o.cwd,...m}),s=e.toolName,i=(a)=>{let l=e.input[a];return typeof l==="string"&&l!==""?l:void 0},c=(a)=>{let l=i(a);if(l===void 0)throw new Pr(`${s}'s input has no ${a}`);return l},d=o.home??b.homedir(),p=(a)=>g(c(a),d);if(s.startsWith("mcp__"))return U(s,o.server).map((a)=>r(a.action,a.resources,a));switch(s){case"bash":return[r("shell",[c("command")],{shell:"bash"})];case"powershell":return[r("shell",[c("command")],{shell:"pwsh"})];case"read":{let a=p("path"),l=o.skills&&R(o.skills,u.resolve(o.cwd,a));return[l?r("skill",[l]):r("read",[a])]}case"write":case"edit":return[r("edit",[p("path")])];case"ls":return[r("read",[g(i("path")??".",d)])];case"grep":case"find":{let a=i("path");return[r(s==="find"?"glob":"grep",[c("pattern")],a===void 0?{}:{path:g(a,d)})]}case"read_mcp_resource":return[r("mcp.use",[c("server")])];case"list_mcp_resources":case"list_mcp_resource_templates":{let a=i("server"),l=o.servers??[];return[r("mcp.use",a?[a]:l.length>0?l:["*"])]}default:return[r(s.toLowerCase(),["*"])]}}function g(e,o){let r=e.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g," "),s=r.startsWith("@")?r.slice(1):r,i=s==="~"?o:s.startsWith("~/")?u.join(o,s.slice(2)):s;return i.startsWith("file://")?W(i):i}function R(e,o){let r=u.relative(u.resolve(e),o);if(r===""||r.startsWith("..")||u.isAbsolute(r))return;return r.split(u.sep)[0]}function U(e,o){let r=o&&`mcp__${o.replace(/[^A-Za-z0-9_]/g,"_")}__`,s=e.match(/^mcp__(.+?)__(.+)$/),i=o??s?.[1];if(!i)throw new Pr(`Can't tell which MCP server ${e} belongs to`);let c=r&&e.startsWith(r)?e.slice(r.length):o?void 0:s?.[2],d=o!==void 0,p=c===void 0||/_[0-9a-f]{8}$/.test(e);return[{action:"mcp.use",resources:[i],...d?{}:{folded:!0}},p?{action:`${i}_`,resources:["*"],truncated:!0}:{action:`${i}_${c}`,resources:["*"],folded:!0}]}function Co(e){return{action:"shell",resources:[e.command],directory:e.cwd,shell:"bash"}}function Io(e){return e.match(/^\/skill:([^\s]+)/)?.[1]}function Ao(e){if(e.length===0)return;return e.map((o)=>`## ${o.name}
|
|
2
|
-
|
|
3
|
-
${o.content.trim()}`).join(`
|
|
4
|
-
|
|
5
|
-
`)}var M=n({paths:n({agent:t,settings:t}),extension:t,created:E,...Uo}),Rr=(e)=>u.join(e.data,"pi.json"),wn=(e)=>u.join(e.data,"pi"),Mr=(e)=>u.join(e.cache,"pi-models.json");function To(e){let o=Rr(e),r=he(o);if(r===void 0)return;let s=D(J(se(M))(r));if(!s)throw Error(`${o} can't be read, so Pi was left as it is. Delete it and run setup again.`);return s}function qi(e,o){let r=To(e),s=r?.created??he(o.paths.settings)===void 0,i=Gt(o.paths.settings)??{};if(!r)jo(o.paths.settings);let c=Array.isArray(i.extensions)?i.extensions:[];i.extensions=[...c.filter((p)=>p!==r?.extension&&p!==o.extension),o.extension];let d=Lo(i,o.model?{defaultProvider:o.model.provider,defaultModel:o.model.id}:{},r,!0);Jt(o.paths.settings,i,384),Re(Rr(e),JSON.stringify(M.make({paths:o.paths,extension:o.extension,created:s,...d})))}function Wi(e){let o=To(e);if(!o)return!1;let r=Gt(o.paths.settings);if(r){let i=(Array.isArray(r.extensions)?r.extensions:[]).filter((c)=>c!==o.extension);if(i.length>0)r.extensions=i;else delete r.extensions;if(Object.keys(o.originals).forEach((c)=>Nr(r,c,o)),Object.keys(r).length===0&&o.created)me(o.paths.settings);else Jt(o.paths.settings,r)}return me(Ct(o.paths.settings)),O(wn(e),{recursive:!0,force:!0}),me(Mr(e)),me(Rr(e)),!0}function Oo(e={}){let o=Ho({version:st,harness:e.harness}).pipe(cn(zr)),r=e.fetch;return{store:e.store??us(),run:(s)=>Ln(r?s.pipe(dr(o),be(pt,r)):s.pipe(dr(o)))}}var h=new WeakMap;function _o(e){let o=h.get(e);if(o)return o;let r=e.run(qo(e.store)).finally(()=>h.delete(e));return h.set(e,r),r}async function kn(e,o){return(await Wn(e,o)).find((r)=>r.effect==="deny")}async function Wn(e,o){let r=je(e.store),s=Vo(r,r&&await ot(e));return Ln(_e(o,(i)=>Fo(s,i)))}async function ot(e){let o=je(e.store);if(!o)return;let r=Je(o),s=Yt(e.store,r);if(!s)await new Promise((i)=>{let c=setTimeout(i,3000);c.unref?.(),_o(e).catch(()=>{return}).finally(()=>{clearTimeout(c),i()})});else if(Vn(s,Date.now()))Bs(e);return Yt(e.store,r)}function Bs(e){let o=ls(e.store),r=ps(o);if(r!==void 0&&Date.now()-r<30000)return!1;return Re(o,""),_o(e).catch(()=>{return}),!0}var L=n({owner:t,providers:t,document:y(t,F)}),N=y(t,n({name:C(t),models:y(t,y(t,F))}));async function Po(e){let o=je(e.store),r=await ot(e);if(!o||!r?.config)return;let s=Je(o),i=j("sha256").update(JSON.stringify(r.config.providers??null)).digest("hex"),c=D(J(se(L))(he(Mr(e.store))??"")),d=c?.owner===s&&c.providers===i?c.document:void 0,p=d&&D(J(N)(d));if(p)return p;let a=await e.run(er(o));return Re(Mr(e.store),JSON.stringify({owner:s,providers:i,document:a})),a}var B=y(t,t);async function Ro(e){let o=je(e.store),r=await ot(e),s=u.join(wn(e.store),"skills"),i=u.join(wn(e.store),"skills.json");if(!o||!r?.config)return s;let c=Zt(r.config).skills,d=Me(J(se(B))(he(i)??""),()=>({})),p=await e.run(Gn(o,s,c,d));return await Ln(ze(e.store,T(()=>{ft(s),Re(i,JSON.stringify(Jn(s,c,p,d).skills))}))),s}
|
|
6
|
-
export{Hi,Eo,wo,Pr,ko,Co,Io,Ao,Rr,wn,Mr,To,qi,Wi,Oo,_o,kn,Wn,ot,Bs,Po,Ro,Mo};
|
package/chunk-4v6awhyw.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Xo,Zn,Yn,Js,Vs,Qn,An,Xn,Zs,es,ts,Lr,ns,er,rs,os,ss,is}from"./chunk-ke4nwx54.js";import"./chunk-yjw665b0.js";import"./chunk-jqhy4pzf.js";export{is as ConsoleClient,Xn as DeviceSignInFailed,Yn as OAuth,An as SignedOut,Qn as SsoRequired,es as authorize,Zn as clientID,Xo as defaultServer,ns as fetchConfig,er as fetchModels,rs as fetchSkill,os as fetchSkillBlob,Zs as headers,ss as normalizeServer,ts as refresh,Lr as revoke,Js as signedOutMessage,Vs as ssoMessage};
|
package/chunk-52p33kcn.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Zt,Kn,Gn,Jn,Hs,zo}from"./chunk-gtf5exm1.js";import"./chunk-ke4nwx54.js";import"./chunk-yjw665b0.js";import"./chunk-5x5fc0mq.js";import"./chunk-jqhy4pzf.js";export{zo as Library,Gn as fetchChanged,Zt as library,Kn as servers,Hs as skillMarkdown,Jn as write};
|
package/chunk-5x5fc0mq.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{w,ii,ai,fe,Dt,As}from"./chunk-nva98fq1.js";var fs={};w(fs,{ConsoleStore:()=>fs,credentialFile:()=>tn,ensureDir:()=>ft,locked:()=>ze,make:()=>us,modified:()=>ps,read:()=>he,remove:()=>me,snapshotFile:()=>At,syncClaimFile:()=>ls,unreachable:()=>qr,write:()=>Re});import{randomUUID as te}from"node:crypto";import{chmodSync as re,mkdirSync as oe,readFileSync as ne,renameSync as ae,rmSync as q,statSync as ie,writeFileSync as se}from"node:fs";import E from"node:path";import S from"path";import K from"os";import{randomBytes as W,randomUUID as Y}from"crypto";import{mkdir as N,readFile as V,rm as g,stat as J,utimes as B,writeFile as A}from"fs/promises";import{createHash as C}from"crypto";var _;(function(e){function i(y){return C("sha1").update(y).digest("hex")}e.fast=i;function s(y){return C("sha256").update(y).digest("hex")}e.sha256=s})(_||(_={}));var Tn;(function(e){let i;function s(r){i=r}e.setGlobal=s;let y=()=>{if(!i)throw Error("Flock global not set");return S.join(i.state,"locks")},v={staleMs:60000,timeoutMs:300000,baseDelayMs:100,maxDelayMs:2000};function O(r){if(typeof r!=="object"||r===null||!("code"in r))return;let t=r.code;if(typeof t!=="string")return;return t}function H(r,t){return new Promise((n,c)=>{if(t?.aborted){c(t.reason??Error("Aborted"));return}let a,f=()=>{t?.removeEventListener("abort",o),n()},o=()=>{if(a)clearTimeout(a);t?.removeEventListener("abort",o),c(t?.reason??Error("Aborted"))};t?.addEventListener("abort",o,{once:!0}),a=setTimeout(f,r)})}function F(r){let t=Math.floor(r*0.3),n=Math.floor(Math.random()*(2*t+1))-t;return Math.max(0,r+n)}function j(){return performance.now()}function I(){return performance.timeOrigin+j()}async function x(r){try{return await J(r)}catch(t){let n=O(t);if(n==="ENOENT"||n==="ENOTDIR")return;throw t}}async function k(r,t,n,c){let a=I(),f=await x(t);if(f)return a-f.mtimeMs>c;let o=await x(n);if(o)return a-o.mtimeMs>c;let l=await x(r);if(!l)return!1;return a-l.mtimeMs>c}async function G(r,t){let n=Y?.()??W(16).toString("hex"),c=S.join(r,"meta.json"),a=S.join(r,"heartbeat");try{await N(r,{mode:448})}catch(b){if(O(b)!=="EEXIST")throw b;if(!await k(r,a,c,t.staleMs))return{acquired:!1};let d=r+".breaker";try{await N(d,{mode:448})}catch(u){let M=O(u);if(M==="EEXIST"){let D=await x(d);if(D&&I()-D.mtimeMs>t.staleMs)await g(d,{recursive:!0,force:!0}).catch(()=>{return});return{acquired:!1}}if(M==="ENOENT"||M==="ENOTDIR")return{acquired:!1};throw u}try{if(!await k(r,a,c,t.staleMs))return{acquired:!1};await g(r,{recursive:!0,force:!0});try{await N(r,{mode:448})}catch(u){let M=O(u);if(M==="EEXIST"||M==="ENOTEMPTY")return{acquired:!1};throw u}}finally{await g(d,{recursive:!0,force:!0}).catch(()=>{return})}}let f={token:n,pid:process.pid,hostname:K.hostname(),createdAt:new Date().toISOString()};await A(a,"",{flag:"wx"}).catch(async()=>{throw await g(r,{recursive:!0,force:!0}),Error("Lock acquired but heartbeat already existed (possible compromise).")}),await A(c,JSON.stringify(f,null,2),{flag:"wx"}).catch(async()=>{throw await g(r,{recursive:!0,force:!0}),Error("Lock acquired but meta.json already existed (possible compromise).")});let o;return{acquired:!0,startHeartbeat:(b=Math.max(100,Math.floor(t.staleMs/3)))=>{if(o)return;o=setInterval(()=>{let d=new Date;B(a,d,d).catch(()=>{return})},b),o.unref?.()},release:async()=>{if(o)clearInterval(o),o=void 0;if((await V(c,"utf8").then((d)=>{let u=JSON.parse(d);if(!u||typeof u!=="object")return{};return{token:"token"in u&&typeof u.token==="string"?u.token:void 0}}).catch((d)=>{let u=O(d);if(u==="ENOENT"||u==="ENOTDIR")throw Error("Refusing to release: lock is compromised (metadata missing).");if(d instanceof SyntaxError)throw Error("Refusing to release: lock is compromised (metadata invalid).");throw d})).token!==n)throw Error("Refusing to release: lock token mismatch (not the owner).");await g(r,{recursive:!0,force:!0})}}}async function X(r,t,n){let c=j()+n.timeoutMs,a=0,f=0,o=n.baseDelayMs;while(!0){t.signal?.throwIfAborted();let l=await G(r,n);if(l.acquired)return l;if(j()>c)throw Error(`Timed out waiting for lock: ${t.key}`);a+=1;let p=F(o);await t.onWait?.({key:t.key,attempt:a,delay:p,waited:f}),await H(p,t.signal),f+=p,o=Math.min(n.maxDelayMs,Math.floor(o*1.7))}}async function T(r,t={}){t.signal?.throwIfAborted();let n={staleMs:t.staleMs??v.staleMs,timeoutMs:t.timeoutMs??v.timeoutMs,baseDelayMs:t.baseDelayMs??v.baseDelayMs,maxDelayMs:t.maxDelayMs??v.maxDelayMs},c=t.dir??y();await N(c,{recursive:!0});let a=S.join(c,_.fast(r)+".lock"),f=await X(a,{key:r,onWait:t.onWait,signal:t.signal},n);f.startHeartbeat();let o=()=>f.release();return{release:o,[Symbol.asyncDispose](){return o()}}}e.acquire=T;async function U(r,t,n={}){let a=[];try{const c=ii(a,await T(r,n),1);n.signal?.throwIfAborted();return await t()}catch(f){var o=f,l=1}finally{var p=ai(a,o,l);p&&await p}}e.withLock=U})(Tn||(Tn={}));import P from"os";import m from"path";var h=P.homedir(),z=process.env.XDG_DATA_HOME||(h?m.join(h,".local","share"):void 0),Q=process.env.XDG_CACHE_HOME||(h?m.join(h,".cache"):void 0),Z=process.env.XDG_CONFIG_HOME||(h?m.join(h,".config"):void 0),ee=process.env.XDG_STATE_HOME||(h?m.join(h,".local","state"):void 0);function Hr(e){return{data:m.join(z,e),cache:m.join(Q,e),config:m.join(Z,e),state:m.join(ee,e),tmp:m.join(P.tmpdir(),e)}}function us(e={}){let i=e.env??{OPENCODE_API_KEY:process.env.OPENCODE_API_KEY,OPENCODE_CONSOLE_SERVER:process.env.OPENCODE_CONSOLE_SERVER};if(e.root)return{data:E.join(e.root,"data"),cache:E.join(e.root,"cache"),env:i};let s=Hr("opencode-console");return{data:s.data,cache:s.cache,env:i}}var tn=(e)=>E.join(e.data,"credential.json"),At=(e)=>E.join(e.cache,"config.json"),ls=(e)=>E.join(e.cache,"sync.claim"),ce=30000,R=35000;function ze(e,i){return As(fe({try:()=>(ft(e.data),ft(E.join(e.data,"locks")),Tn.acquire("credential",{dir:E.join(e.data,"locks"),staleMs:ce,timeoutMs:R})),catch:(s)=>s instanceof Error&&s.message.startsWith("Timed out waiting for lock")?Error(`Timed out after ${R/1000}s waiting for another opencode-console process to update the sign-in`,{cause:s}):s}),()=>i,(s)=>fe(()=>s.release()).pipe(Dt))}function he(e){try{return ne(e,"utf8")}catch(i){if(L(i)==="ENOENT")return;throw i}}function ps(e){try{return ie(e,{throwIfNoEntry:!1})?.mtimeMs}catch(i){if(qr(i))return;throw i}}function Re(e,i){ft(E.dirname(e));let s=`${e}.${te()}.tmp`;se(s,i,{mode:384,flag:"wx"});try{ae(s,e)}catch(y){throw q(s,{force:!0}),y}}function me(e){q(e,{force:!0})}function qr(e){return["ENOENT","ENOTDIR","EACCES","EPERM"].includes(L(e)??"")}function ft(e){if(oe(e,{recursive:!0,mode:448}),process.platform!=="win32")re(e,448)}function L(e){return e instanceof Error&&"code"in e&&typeof e.code==="string"?e.code:void 0}
|
|
2
|
-
export{Tn,Hr,us,tn,At,ls,ze,he,ps,Re,me,qr,ft,fs};
|
package/chunk-6tene1pb.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{k,M,Pt,_n,r,fn,gn,$n,de,x,Ke,Cr,Et,ue,Ir,J,Le,C,Se,d,Oi,Wt,F,t,ne,E,n,y,yn,f,Ar,b,j,wt,zn,_i,Q,Ri,m,Us,lt,$e,ve,Hn,tt,Mi,Tr,kt,K,Ls,Ni,bn,yo,N,Sn}from"./chunk-nva98fq1.js";var Lo=Object.defineProperty,Ao=(o)=>o;function Uo(o,i){this[o]=Ao.bind(null,i)}var Ie=(o,i)=>{for(var p in i)Lo(o,p,{get:i[p],enumerable:!0,configurable:!0,set:Uo.bind(i,p)})};var u=K.check(Mi(0)),S=K.check(Tr(0)),An=t.pipe(Q("RelativePath"),ue({identifier:"RelativePath"})),w=t.pipe(Q("AbsolutePath"),ue({identifier:"AbsolutePath"})),e=(o)=>Le(o).pipe(m(C(Se(o)),{decode:de({strict:!1}),encode:Ke(Pt((i)=>i!==void 0))})),Fo=(o,i)=>Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)),s=(o)=>(i)=>Fo(i,o(i)),Un=tt.pipe(m(bn,{decode:x((o)=>gn(o)),encode:x((o)=>$n(o))}));var Eo=26,_o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",je=0,pe=0;function h(){return Ge(!1)}function Ve(){return Ge(!0)}function Ge(o,i=Date.now()){if(i!==je)je=i,pe=0;pe++;let p=BigInt(i)*0x1000n+BigInt(pe),g=o?~p:p,D=Array.from({length:6},(I,Ro)=>Number(g>>BigInt(40-8*Ro)&0xffn).toString(16).padStart(2,"0")).join(""),P=crypto.getRandomValues(new Uint8Array(Eo-12));return D+Array.from(P,(I)=>_o[I%62]).join("")}var Ye=t.pipe(Q("Project.ID"),ue({identifier:"Project.ID"}),s((o)=>({global:o.make("global")})));var ce=t.check(Hn("wrk")).pipe(Q("Workspace.ID"),ue({identifier:"Workspace.ID"}),s((o)=>{let i=()=>o.make("wrk_"+h());return{ascending:(p)=>{if(!p)return i();return o.make(p)},create:i}}));var Je=n({directory:w,workspaceID:e(ce)}).annotate({identifier:"Location.Ref"}),Yn=n(Et(Je.fields,["workspaceID"])).annotate({identifier:"Location.PublicRef"});class He extends N("Location.Info")({directory:w,workspaceID:e(ce),project:n({id:Ye,directory:w,canonical:w})}){}var Jn=n(Et(He.fields,["workspaceID"])).annotate({identifier:"Location.PublicInfo"});var Oo=t.check(Hn("evt_")).pipe(Q("Event.ID"),ue({identifier:"Event.ID"}),s((o)=>({create:()=>o.make("evt_"+h())}))),Wo=K.check(Tr(0)).pipe(Q("Event.Seq"),ue({identifier:"Event.Seq"})),No=K.check(Tr(1)).pipe(Q("Event.Version"),ue({identifier:"Event.Version"})),ir=n({aggregateID:t,seq:Wo,version:No});function c(o){let i=n(o.schema);return n({id:Oo,created:tt,metadata:e(y(t,F)),type:d(o.type),location:e(Je),data:i}).annotate({identifier:o.identifier??o.type}).pipe(s(()=>({type:o.type,durability:"ephemeral",durable:void 0,data:i})))}function l(...o){return Object.freeze(o)}var me=t.check(Hn("ses")).pipe(Q("SessionID"),ue({identifier:"Session.ID"}),s((o)=>({create:()=>o.make("ses_"+Ve())})));var et=t.check(Hn("per")).pipe(Q("Permission.ID"),ue({identifier:"Permission.ID"}),s((o)=>({create:(i)=>o.make(i??"per_"+h())}))),zo=b([n({type:d("tool"),messageID:t,id:t})]).annotate({identifier:"Permission.Source"}),jo={sessionID:me,action:t,resources:f(t),save:f(t).pipe(e),metadata:y(t,F).pipe(e),source:zo.pipe(e),message:t.pipe(e)},Vo=n({id:et,...jo}).annotate({identifier:"Permission.Request"}),$o=j(["once","always","reject"]).annotate({identifier:"Permission.Reply"}),Xe=c({type:"permission.asked",schema:Vo.fields}),Ze=c({type:"permission.replied",schema:{sessionID:me,requestID:et,reply:$o}}),ur={Asked:Xe,Replied:Ze,Definitions:l(Xe,Ze)},Ko=j(["allow","deny","ask"]).annotate({identifier:"Permission.Effect"}),Go=n({action:t,resource:t,effect:Ko}).annotate({identifier:"Permission.Rule"}),ot=f(Go).annotate({identifier:"Permission.Ruleset"});var Pe=t.pipe(Q("Integration.ID"),ue({identifier:"Integration.ID"})),_=t.pipe(Q("Integration.MethodID"),ue({identifier:"Integration.MethodID"}));var q=t.pipe(Q("Credential.ID"),ue({identifier:"Credential.ID"}),s((o)=>({create:()=>o.make("cred_"+h())}))),it=c({type:"credential.updated",schema:{}}),nt=c({type:"credential.switched",schema:{integrationID:Pe,credentialID:wt(q)}}),kr={Updated:it,Switched:nt,Definitions:l(it,nt)},Jo=n({type:d("oauth"),methodID:_,refresh:t,access:t,expires:S,metadata:e(y(t,F))}).annotate({identifier:"Credential.OAuth"}),Ho=n({type:d("key"),key:t,metadata:e(y(t,F))}).annotate({identifier:"Credential.Key"}),Qo=n({type:d("external"),methodID:_,metadata:e(y(t,F))}).annotate({identifier:"Credential.External"}),rt=b([Jo,Ho,Qo]).pipe($e("type")).annotate({identifier:"Credential.Value"}),Mr=n({id:q,integrationID:Pe,label:t,active:E,value:rt}).annotate({identifier:"Credential.Entry"}),Pr=n({id:e(q),integrationID:Pe,label:e(t),value:rt,activate:e(E)}).annotate({identifier:"Credential.CreateInput"});var st=n({status:j(["needs_auth"]),message:t,url:e(t)}).annotate({identifier:"Connection.Status"}),Xo=n({type:d("credential"),id:q,label:t,method:j(["key","oauth","external"]),status:e(st)}).annotate({identifier:"Connection.CredentialInfo"}),Zo=n({type:d("env"),name:t,status:e(st)}).annotate({identifier:"Connection.EnvInfo"}),pt=b([Xo,Zo]).pipe($e("type")).annotate({identifier:"Connection.Info"});var ei=t.check(Hn("frm_")).pipe(Q("Form.ID"),ue({identifier:"Form.ID"})),he=ei.pipe(s((o)=>({create:(i)=>o.make(i??"frm_"+h())}))),ti=y(t,F).annotate({identifier:"Form.Metadata"}),ft=n({value:t,label:t,description:t.pipe(e)}).annotate({identifier:"Form.Option"}),oi=n({key:t,op:j(["eq","neq"]),value:b([t,ne,E])}).annotate({identifier:"Form.When"}),B={key:t,title:t.pipe(e),description:t.pipe(e),required:E.pipe(e),hidden:E.pipe(e).annotate({description:"Skip the interactive authentication prompt and use the default unless an answer is supplied"}),when:f(oi).pipe(e)},ii=n({...B,type:d("string"),format:j(["email","uri","date","date-time"]).pipe(e),minLength:S.pipe(e),maxLength:S.pipe(e),pattern:t.pipe(e),placeholder:t.pipe(e),default:t.pipe(e),options:f(ft).pipe(e),custom:E.pipe(e)}).annotate({identifier:"Form.StringField"}),ni=n({...B,type:d("number"),minimum:ne.pipe(e),maximum:ne.pipe(e),default:ne.pipe(e)}).annotate({identifier:"Form.NumberField"}),ri=n({...B,type:d("integer"),minimum:ne.pipe(e),maximum:ne.pipe(e),default:ne.pipe(e)}).annotate({identifier:"Form.IntegerField"}),ai=n({...B,type:d("boolean"),default:E.pipe(e)}).annotate({identifier:"Form.BooleanField"}),si=n({...B,type:d("multiselect"),options:f(ft),minItems:S.pipe(e),maxItems:S.pipe(e),custom:E.pipe(e),default:f(t).pipe(e)}).annotate({identifier:"Form.MultiselectField"}),pi=n({key:t,type:d("external"),url:t,title:t.pipe(e),description:t.pipe(e)}).annotate({identifier:"Form.ExternalField"}),ci=b([ii,ni,ri,ai,si,pi]).pipe($e("type"),ue({identifier:"Form.Field"})),z=Ar(ci).annotate({identifier:"Form.Fields"}),li={id:he,sessionID:t,title:t,metadata:ti.pipe(e)},ut=n({...li,fields:z}).annotate({identifier:"Form.Info"}),di=b([t,ne,E,f(t)]).annotate({identifier:"Form.Value"}),xe=y(t,di).annotate({identifier:"Form.Answer"}),mi=b([n({status:d("pending")}),n({status:d("answered"),answer:xe}),n({status:d("cancelled"),message:t.pipe(e)})]).pipe($e("status")).annotate({identifier:"Form.State"}),Br=n({...ut.fields,state:mi}).annotate({identifier:"Form.Detail"}),Or=n({answer:xe}).annotate({identifier:"Form.Reply"}),ct=c({type:"form.created",schema:{form:ut}}),dt=c({type:"form.replied",schema:{id:he,sessionID:t,answer:xe}}),mt=c({type:"form.cancelled",schema:{id:he,sessionID:t}}),Wr={Created:ct,Replied:dt,Cancelled:mt,Definitions:l(ct,dt,mt)};var ye=Pe,be=_,fi=n({id:be,type:d("oauth"),label:t,form:e(z)}).annotate({identifier:"Integration.OAuthMethod"}),ui=n({id:be,type:d("command"),label:t,command:f(t)}).annotate({identifier:"Integration.CommandMethod"}),gi=n({type:d("key"),label:e(t),form:e(z)}).annotate({identifier:"Integration.KeyMethod"}),Si=n({id:be,type:d("external"),label:t,form:e(z)}).annotate({identifier:"Integration.ExternalMethod"}),hi=n({type:d("env"),names:f(t)}).annotate({identifier:"Integration.EnvMethod"}),xi=b([fi,ui,gi,Si,hi]).pipe($e("type")).annotate({identifier:"Integration.Method"}),St=c({type:"integration.updated",schema:{}}),Yr={Updated:St,Definitions:l(St)},Jr=n({id:ye,name:t,metadata:e(y(t,Wt))}).annotate({identifier:"Integration.Ref"}),Hr=n({id:ye,name:t,metadata:e(y(t,Wt)),methods:f(xi),connections:f(pt)}).annotate({identifier:"Integration.Info"}),ht=t.pipe(Q("Integration.AttemptID"),ue({identifier:"Integration.AttemptID"}),s((o)=>({create:()=>o.make("con_"+h())}))),v=n({created:ne,expires:ne});class yi extends N("Integration.Attempt")({attemptID:ht,url:t,instructions:t,mode:j(["auto","code"]),paste:Le(d(!0)),time:v}){}var Qr=b([n({status:d("pending"),time:v}),n({status:d("complete"),time:v}),n({status:d("failed"),message:t,time:v}),n({status:d("expired"),time:v})]).pipe($e("status")).annotate({identifier:"Integration.AttemptStatus"}),Xr=n({attemptID:ht,time:v}).annotate({identifier:"Integration.CommandAttempt"}),Zr=b([n({status:d("pending"),message:e(t),time:v}),n({status:d("complete"),time:v}),n({status:d("failed"),message:t,time:v}),n({status:d("expired"),time:v})]).pipe($e("status")).annotate({identifier:"Integration.CommandAttemptStatus"});var yt=b([j(["reasoning","reasoning_content","reasoning_text"]),t]).annotate({identifier:"Model.ReasoningField"}),bt=j(["max_completion_tokens","max_tokens"]).annotate({identifier:"Model.MaxTokensField"}),vt=j(["assets","state","root"]).annotate({identifier:"Model.MediaInput"}),Ii=j(["anthropic","alibaba"]).annotate({identifier:"Model.CacheFormat"}),O=n({reasoningField:yt.pipe(e),requireReasoning:E.pipe(e),maxTokensField:bt.pipe(e),requireFinishReason:E.pipe(e),requireAssistantAfterTool:E.pipe(e),supportsPromptCacheKey:E.pipe(e),streamUsage:E.pipe(e),cacheFormat:Ii.pipe(e),supportsThinkingBlockBinding:E.pipe(e),supportsEffortUpdates:E.pipe(e),mediaInput:vt.pipe(e)}).annotate({identifier:"Model.Compatibility"}),V=n(Et(O.fields,["supportsThinkingBlockBinding","supportsEffortUpdates"])).annotate({identifier:"Provider.Compatibility"});var R=t.pipe(Q("Provider.ID"),ue({identifier:"Provider.ID"}),s((o)=>({opencode:o.make("opencode"),anthropic:o.make("anthropic"),openai:o.make("openai"),google:o.make("google"),googleVertex:o.make("google-vertex"),githubCopilot:o.make("github-copilot"),claudeAgent:o.make("claude-agent"),amazonBedrock:o.make("amazon-bedrock"),azure:o.make("azure"),openrouter:o.make("openrouter"),mistral:o.make("mistral"),gitlab:o.make("gitlab")}))),Ct=c({type:"provider.updated",schema:{}}),pa={Updated:Ct,Definitions:l(Ct)},Dt=t,vi=j(["auto","enabled","disabled"]),Ci=b([n({type:d("summary")}),n({type:d("native")})]).pipe($e("type")).annotate({identifier:"Provider.Compaction"}),Di=j(["http","websocket"]).annotate({identifier:"Provider.Transport"}),ki=Oi([ne,j(["ms","s","m","h","d"])]).check(ve(/^\d+(ms|s|m|h|d)$/)).annotate({identifier:"Provider.CacheTTL"}),Pi=b([E,n({interval:b([d("auto"),t]).pipe(e).annotate({description:`Duration such as "4 minutes", or "auto" for 90% of the model's cache.ttl`}),duration:t.pipe(e).annotate({description:'Duration such as "30 minutes"'})})]).annotate({identifier:"Provider.CacheWarming"}),wi=n({ttl:ki.pipe(e),warming:Pi.pipe(e)}).annotate({identifier:"Provider.Cache"}),Li=j(["zstd","gzip","none"]).annotate({identifier:"Provider.Encoding"}),Ce=b([tt,d(!1)]).pipe(e),G=yn(n({timeout:Ce,headerTimeout:Ce,chunkTimeout:Ce,compaction:Ci.pipe(e),cache:wi.pipe(e),transport:Di.pipe(e),encoding:Li.pipe(e)}),[y(t,Wt)]).annotate({identifier:"Provider.Settings"}),Ai={settings:G.pipe(e),headers:y(t,t).pipe(e),body:y(t,Wt).pipe(e)},ca=n({settings:G.pipe(Us(r({}))),headers:y(t,t),body:y(t,Wt)}).annotate({identifier:"Provider.Request"}),la=n({id:R,canonical:R.pipe(e),integrationID:ye.pipe(e),name:t,activation:vi,package:Dt,compatibility:V.pipe(e),...Ai}).annotate({identifier:"Provider.Info"}).pipe(s(()=>({empty:(o)=>({id:o,name:o,activation:"auto",package:""})})));var fa=tt.pipe(Q("Money.USD"),ue({identifier:"Money.USD"}),s((o)=>({zero:o.make(0)}))),L=tt.pipe(Q("Money.USDPerMillionTokens"),ue({identifier:"Money.USDPerMillionTokens"}),s((o)=>({zero:o.make(0)})));var A=t.pipe(Q("Model.ID")),Mt=c({type:"model.updated",schema:{}}),Ia={Updated:Mt,Definitions:l(Mt)},U=t.pipe(Q("Model.VariantID")),Ui=n({id:A,providerID:R,variant:U.pipe(e)}).annotate({identifier:"Model.Ref"}).pipe(s((o)=>({parse:(i)=>{let p=i.indexOf("/");if(p<=0)throw Error(`Invalid model reference: ${i}`);let g=i.slice(0,p),D=i.indexOf("#",p+1),P=i.slice(p+1,D===-1?void 0:D),I=D===-1?void 0:i.slice(D+1);if(!P||g.includes("#")||I!==void 0&&(!I||I.includes("#")))throw Error(`Invalid model reference: ${i}`);return o.make({providerID:R.make(g),id:A.make(P),...I?{variant:U.make(I)}:{}})}})));var ke=t.pipe(Q("Model.Family")),Me=b([j(["chat","decision","image"]),t]).annotate({identifier:"Model.Type"}),H=yn(n(Cr(G.schema.fields,["compaction","cache","encoding"])),[y(t,Wt)]).annotate({identifier:"Model.Settings"}),Ti=yn(n(Et(H.schema.fields,["cache"])),H.records).annotate({identifier:"Model.VariantSettings"}),Rt={settings:H.pipe(e),headers:y(t,t).pipe(e),body:y(t,Wt).pipe(e)},X=n({tools:E,input:f(t),output:f(t),temperature:E.pipe(e)}).annotate({identifier:"Model.Capabilities"}).pipe(s(()=>({default:()=>({tools:!0,input:["text","image"],output:["text"]})}))),Fi=n({tier:n({type:lt("context"),size:K}).pipe(e),input:L,output:L,cache:n({read:L,write:L})}).annotate({identifier:"Model.Cost"}),Ei=n({id:U,...Rt,settings:Ti.pipe(e)}).annotate({identifier:"Model.Variant"}),ba=n({id:A,modelID:A,providerID:R,canonical:R.pipe(e),type:Me.pipe(e),family:ke.pipe(e),name:t,compatibility:O.pipe(e),package:Dt.pipe(e),...Rt,capabilities:X,variants:f(Ei),time:n({released:tt}),cost:f(Fi),status:j(["alpha","beta","deprecated","active"]),enabled:E,limit:n({context:K,input:K.pipe(e),output:K})}).annotate({identifier:"Model.Info"}).pipe(s(()=>({default:(o,i)=>({id:i,modelID:i,providerID:o,name:i,capabilities:X.default(),variants:[],time:{released:0},cost:[],status:"active",enabled:!0,limit:{context:200000,output:32000}})})));var Bi=R.check(ve(/^[^/#]+$/u)),Wi=A.check(ve(/^[^#]+$/u)),qi=U.check(ve(/^[^#]+$/u)),Lt=n({providerID:Bi,model:Wi,variant:qi.pipe(e)}),zi=t.check(ve(/^[^/#]+\/[^#]+(?:#[^#]+)?$/u)),Z=b([zi,Lt]).pipe(m(Lt,{decode:x((o)=>typeof o==="string"?ji(o):o),encode:de({strict:!1})})).annotate({identifier:"Config.ModelSelection"});function ji(o){let i=Ui.parse(o);return{providerID:i.providerID,model:i.id,...i.variant?{variant:i.variant}:{}}}var Vi=yn(n(G.schema.fields),[y(t,zn(Sn))]).annotate({identifier:"Config.Provider.Settings"}),Re=yn(n(H.schema.fields),[y(t,zn(Sn))]).annotate({identifier:"Config.Model.Settings"}),Ut=y(t,Sn),Ae={settings:Vi.pipe(e),headers:y(t,t).pipe(e),body:Ut.pipe(e)},At={settings:Re.pipe(e),headers:y(t,t).pipe(e),body:Ut.pipe(e)};class Tt extends N("Config.Provider.Request")({headers:Ae.headers,body:Ae.body}){}class Ft extends N("Config.Model.Cost.Cache")({read:L.pipe(e),write:L.pipe(e)}){}class Ue extends N("Config.Model.Cost")({tier:n({type:d("context"),size:K}).pipe(e),input:L,output:L,cache:Ft.pipe(e)}){}class _t extends N("Config.Model.Limit")({context:K.pipe(e),input:K.pipe(e),output:K.pipe(e)}){}var $i=b([n({supported:d(!1)}),n({supported:d(!0),toggle:E.pipe(e),effort:t.pipe(f,e),budget:n({min:K.pipe(e),max:K.pipe(e)}).pipe(e)})]).annotate({identifier:"Config.Model.Reasoning"});class Bt extends N("Config.Model")({modelID:A.pipe(e),type:Me.pipe(e),family:ke.pipe(e),name:t.pipe(e),releaseDate:t.check(ve(/^\d{4}-\d{2}(-\d{2})?$/u)).annotate({description:"Release date as YYYY-MM-DD or YYYY-MM"}).pipe(e),compatibility:O.pipe(e),package:t.pipe(e),...At,capabilities:X.mapFields((o)=>({tools:e(o.tools),input:e(o.input),output:e(o.output),temperature:o.temperature,reasoning:$i.pipe(e)})).annotate({identifier:"Config.Model.Capabilities"}).pipe(e),variants:n({id:U,...At,settings:yn(n(Et(Re.schema.fields,["cache"])),Re.records).annotate({identifier:"Config.Model.VariantSettings"}).pipe(e)}).pipe(f,e),cost:b([Ue,Ue.pipe(f)]).pipe(e),disabled:E.pipe(e),limit:_t.pipe(e)}){}class Te extends N("Config.Provider")({canonical:R.pipe(e),name:t.pipe(e),env:t.pipe(f,e),package:t.pipe(e),compatibility:V.pipe(e),...Ae,models:y(t,Bt).pipe(e)}){}var Ki=t.check(ve(/^#[0-9a-fA-F]{6}$/u));class Ot extends N("Config.Agent")({model:Z.pipe(e),request:Tt.pipe(e),system:t.pipe(e),description:t.pipe(e),mode:j(["subagent","primary","all"]).pipe(e),hidden:E.pipe(e),color:Ki.pipe(Ri(()=>fn),e),steps:u.pipe(e),disabled:E.pipe(e),permissions:ot.pipe(e)}){}class qt extends N("Config.Media.Image")({auto_resize:E.pipe(e),max_width:u.pipe(e),max_height:u.pipe(e),max_base64_bytes:u.pipe(e)}){}class zt extends N("Config.Media")({image:qt.pipe(e)}){}class Vt extends N("Config.Compaction.Keep")({tokens:S.pipe(e)}){}var Gi=t.check(ve(/^([1-9]\d?(\.\d+)?)%$/u)).annotate({identifier:"Config.Compaction.Percent"});class $t extends N("Config.Compaction")({auto:E.pipe(e),keep:Vt.pipe(e),buffer:b([Gi,S]).pipe(e).annotate({description:`Room kept free below the model's context window before automatic compaction, as a share of the window from "1%" to "99%", such as "20%" to compact at 80% full. A token count is also accepted.`})}){}class Gt extends N("Config.Command")({template:t,description:t.pipe(e),agent:t.pipe(e),model:Z.pipe(e),subagent:E.pipe(e),subtask:E.annotate({description:"Deprecated alias for subagent."}).pipe(e)}){}var Yi={todo:"Enable the experimental todowrite tool.",background_compaction:"Enable experimental background compaction: summarize the conversation in the background as it nears the compaction threshold, so automatic compaction does not wait for the summary. Background summaries that are never used still cost tokens.",media_blob:"Store new session media once in a deduplicated blob table instead of inline in every message row.",schedules:"Enable experimental scheduled tasks that wake a session with a prompt.",artifacts:"Enable experimental artifacts backed by pluggable providers."};var Qt=j(["allow","deny"]),Yo=j(["provider.use","tool.use","integration.connect","integration.use","mcp.use","skill.use","plugin.use","websearch.use"]),Ht=n({action:Yo,resource:t,effect:Qt}),Ji=new Map([["mcp","mcp.use"],["skill","skill.use"],["plugin","plugin.use"]]),Fe=Ht.pipe(m(Se(Ht),{decode:x((o)=>{if(o.action!=="integration.use")return o;let i=o.resource.indexOf(":"),p=i===-1?void 0:Ji.get(o.resource.slice(0,i));if(!p)return o;return{...o,action:p,resource:o.resource.slice(i+1)}}),encode:de()}));class Xt extends N("ConfigExperimental.Info")({portable_shell_scanner:E.pipe(e).annotate({description:"Deprecated: the built-in shell permission scanner is now always enabled."}),all_flags:E.pipe(e).annotate({description:"Turn every feature flag on regardless of the build channel, like OPENCODE_FLAGS=all; explicit per-flag settings still win, and false is not a kill switch."}),..._n(Yi,(o)=>E.pipe(e).annotate({description:`${o} Defaults to on in local and dev builds and off in releases.`})),part_rows:E.pipe(e).annotate({description:"Write each assistant part as its own session_part row instead of rewriting the whole message on every event. Defaults to false."}),image_generate:b([E,n({model:Z.pipe(e).annotate({description:"Default model for the experimental_image_generate tool when the agent doesn't choose one, as providerID/modelID. Falls back to automatic selection when it isn't available."})})]).pipe(e).annotate({description:"Settings for the experimental_image_generate tool, which is offered while a connected provider has an image model."}),subagent_depth:S.pipe(e).annotate({description:"Maximum subagent nesting depth. Defaults to 1."}),location_idle_timeout:b([yo,d(!1)]).pipe(e).annotate({description:'How long a location can go without session activity before its services are unloaded. Running sessions and background jobs keep a location loaded. Set to false to never unload (default: "60 minutes")'}),policies:Fe.pipe(f,e).annotate({description:"Deprecated: use top-level policies. Ordered policies controlling access to configured resources"})}){}class eo extends N("Config.Formatter.Entry")({disabled:E.pipe(e),command:t.pipe(f,e),environment:y(t,t).pipe(e),extensions:t.pipe(f,e)}){}var Hi=b([E,y(t,eo)]);var Qi=n({disabled:d(!0)});class oo extends N("Config.LSP.Server")({command:t.pipe(f),extensions:t.pipe(f,e),disabled:E.pipe(e),env:y(t,t).pipe(e),initialization:y(t,F).pipe(e)}){}var Xi=b([Qi,oo]),Zi=b([E,y(t,Xi)]);class oe extends N("Mcp.TimeoutConfig")({startup:u.pipe(e).annotate({description:"Maximum time in milliseconds to establish and initialize the MCP server."}),catalog:u.pipe(e).annotate({description:"Maximum time in milliseconds to wait for MCP discovery requests such as tools/list and prompts/list."}),execution:u.pipe(e).annotate({description:"Maximum time in milliseconds to wait for MCP tool and prompt execution."})}){}var Ee=j(["legacy","auto","2026-07-28"]).annotate({identifier:"Mcp.Protocol",description:'MCP protocol negotiation. "legacy" (default) opens with the initialize handshake and speaks protocol revisions up to 2025-11-25. "auto" probes for the 2026-07-28 revision and falls back to legacy when the server does not support it. "2026-07-28" requires that revision and fails otherwise.'});class _e extends N("Mcp.LocalConfig")({type:d("local"),command:t.pipe(f),cwd:t.pipe(e).annotate({description:"Working directory for the MCP server process. Relative paths resolve from the workspace directory."}),environment:y(t,t).pipe(e),disabled:E.pipe(e),codemode:E.pipe(e).annotate({description:"Expose this server's tools through Code Mode. Defaults to true."}),timeout:oe.pipe(e),protocol:Ee.pipe(e),pool:E.pipe(e).annotate({description:'Share one connection to this server across every directory that configures it identically, instead of one per directory. Only connections that negotiate the 2026-07-28 revision are shared; an unset "protocol" becomes "auto", and "legacy" never shares. Defaults to false.'})}){}class Be extends N("Mcp.OAuthConfig")({client_id:t.pipe(e),client_secret:t.pipe(e),scope:t.pipe(e),callback_port:K.check(kt({minimum:1,maximum:65535})).pipe(e),redirect_uri:t.pipe(e),auth_server_metadata_url:t.pipe(e).annotate({description:"URL of the OAuth or OpenID Connect authorization server metadata document. Set when the MCP server does not publish protected resource metadata that names its authorization server."})}){}class Oe extends N("Mcp.RemoteConfig")({type:d("remote"),url:t,headers:y(t,t).pipe(e),oauth:b([Be,d(!1)]).pipe(e),disabled:E.pipe(e),codemode:E.pipe(e).annotate({description:"Expose this server's tools through Code Mode. Defaults to true."}),timeout:oe.pipe(e),protocol:Ee.pipe(e),pool:E.pipe(e).annotate({description:'Share one connection to this server across every directory that configures it identically, instead of one per directory. Only connections that negotiate the 2026-07-28 revision are shared; an unset "protocol" becomes "auto", and "legacy" never shares. Defaults to false.'})}){}var en=b([_e,Oe]).pipe($e("type")),tn=n({status:d("connected")}).annotate({identifier:"Mcp.Status.Connected"}),on=n({status:d("pending")}).annotate({identifier:"Mcp.Status.Pending"}),nn=n({status:d("disabled")}).annotate({identifier:"Mcp.Status.Disabled"}),rn=n({status:d("failed"),error:t}).annotate({identifier:"Mcp.Status.Failed"}),an=n({status:d("needs_auth"),error:t}).annotate({identifier:"Mcp.Status.NeedsAuth"}),sn=b([tn,on,nn,rn,an]).pipe($e("status")),ns=n({name:t,status:sn,title:e(t),integrationID:e(Pe)}).annotate({identifier:"Mcp.Server"}),pn=n({server:t,name:t,uri:t,description:e(t),mimeType:e(t)}).annotate({identifier:"Mcp.Resource"}),cn=n({server:t,name:t,uriTemplate:t,description:e(t),mimeType:e(t)}).annotate({identifier:"Mcp.ResourceTemplate"}),rs=n({resources:f(pn),templates:f(cn)}).annotate({identifier:"Mcp.ResourceCatalog"}),ln=b([n({type:d("text"),uri:t,text:t,mimeType:e(t)}),n({type:d("blob"),uri:t,blob:t,mimeType:e(t)})]).pipe($e("type"),ue({identifier:"Mcp.ResourceContentPart"})),as=n({server:t,uri:t,contents:f(ln)}).annotate({identifier:"Mcp.ResourceContent"});var dn=oe,ls=_e,ds=Be,ms=Oe,mn=en,fs=Ee;class We extends N("Config.MCP")({timeout:dn.pipe(e),servers:y(t,mn).pipe(e)}){}class ro extends N("Config.Plugin.Entry")({package:t,options:y(t,F).pipe(e)}){}var un=b([t,ro]),hn=un.pipe(f);class so extends N("Config.Reference.Git")({repository:t,branch:t.pipe(e),description:t.pipe(e),hidden:E.pipe(e)}){}class po extends N("Config.Reference.Local")({path:t,description:t.pipe(e),hidden:E.pipe(e)}){}var xn=b([t,so,po]),In=y(t,xn);var ie=t.pipe(Q("WebSearch.ID"),ue({identifier:"WebSearch.ID"})),bs=n({id:ie,name:t}).annotate({identifier:"WebSearch.Provider"}),vs=n({query:t,providerID:ie.pipe(e)}).annotate({identifier:"WebSearch.Input"}),vn=n({url:t,title:t.pipe(e),content:t.pipe(e),time:n({published:tt.pipe(e).annotate({description:"Publication time in milliseconds since the Unix epoch"})})}).annotate({identifier:"WebSearch.Result"});class Dn extends N("WebSearch.Response")({providerID:ie,results:f(vn)}){}var lo=c({type:"websearch.updated",schema:{}}),Cs={Updated:lo,Definitions:l(lo)};class fo extends N("ConfigWebSearch.Info")({provider:b([d("random").annotate({description:"Reuse a randomly selected provider until it is rate limited, then switch to another available provider."}),ie])}){}var kn=b([d(!1),fo]);class go extends N("Config.ToolOutput")({max_lines:u.pipe(e),max_bytes:u.pipe(e)}){}class ho extends N("Config.Watcher")({ignore:t.pipe(f,e)}){}class Io extends N("Config.Warming")({prompt:t.pipe(e).annotate({description:"Prompt sent for keep-alive requests"}),interval:b([d("auto"),yo]).pipe(e).annotate({description:`Idle time between keep-alive requests (default: "4 minutes"). "auto" uses 90% of the model's cache.ttl and skips models without one.`}),duration:yo.pipe(e).annotate({description:'Time after the last active request to keep a session warm (default: "30 minutes")'})}){}var Mn=b([E,Io]);var Pn=n({directory:Ni.pipe(_i(Ls())).annotate({description:"Parent directory for new worktrees, relative to the project's primary checkout when not absolute"})}).annotate({identifier:"Config.Worktree"});class T extends N("Config.Info")({$schema:e(t).annotate({description:"JSON schema reference for configuration validation"}),shell:t.pipe(e).annotate({description:"Default shell to use for terminal and shell tool execution"}),model:Z.pipe(e).annotate({description:"Default model to use when no session or agent model is selected"}),default_agent:t.pipe(e).annotate({description:"Default primary agent to use when no session agent is selected"}),update:j(["disable","notify","auto"]).pipe(e).annotate({description:"Disable updates, notify when one is available, or install updates automatically"}),share:j(["manual","auto","disabled"]).pipe(e).annotate({description:"Control whether sessions may be shared manually, automatically, or not at all"}),enterprise:n({url:t.pipe(e)}).pipe(e).annotate({description:"Enterprise sharing service configuration"}),username:t.pipe(e).annotate({description:"Username displayed in conversations and used for telemetry identity"}),timezone:t.pipe(e).annotate({description:"IANA time zone for schedules, e.g. America/Los_Angeles. Defaults to the server's local zone"}),permissions:ot.pipe(e).annotate({description:"Ordered tool permission rules applied to agent tool use"}),policies:Fe.pipe(f,e).annotate({description:"Ordered policies controlling access to providers, tools, and integrations"}),agents:y(t,Ot).pipe(e).annotate({description:"Named built-in agent overrides and custom agent definitions"}),snapshots:E.pipe(e).annotate({description:"Enable snapshots used for undo and revert behavior"}),watcher:ho.pipe(e).annotate({description:"Filesystem watcher configuration"}),formatter:Hi.pipe(e).annotate({description:"Enable built-in formatters or configure formatter overrides"}),lsp:Zi.pipe(e).annotate({description:"Enable built-in language servers or configure server overrides"}),media:zt.pipe(e).annotate({description:"Media processing configuration"}),tool_output:go.pipe(e).annotate({description:"Tool output truncation thresholds"}),mcp:We.pipe(e).annotate({description:"MCP server configuration"}),compaction:$t.pipe(e).annotate({description:"Conversation compaction behavior"}),skills:t.pipe(f,e).annotate({description:"Additional paths or URLs to discover skills from"}),commands:y(t,Gt).pipe(e).annotate({description:"Named slash command definitions"}),instructions:t.pipe(f,e).annotate({description:"Additional paths or URLs supplying ambient instructions"}),references:In.pipe(e).annotate({description:"Named local directories or Git repositories available as external context"}),websearch:kn.pipe(e).annotate({description:"Web search provider selection"}),plugins:hn.pipe(e).annotate({description:"Ordered plugin enablement directives and external package declarations"}),worktree:Pn.pipe(e).annotate({description:"Directory defaults for local worktree creation"}),warming:Mn.pipe(e).annotate({description:"Keep recently active sessions warm with transient model requests (default: false)"}),providers:y(t,Te).pipe(e),experimental:Xt.pipe(e)}){}var ip=n({shell:wt(t)}).annotate({identifier:"Config.Patch"});class re extends N("Config.Document")({type:d("document"),path:w.pipe(e),info:T}){}class Do extends N("Config.Directory")({type:d("directory"),path:w}){}var np=b([re,Do]).annotate({identifier:"Config.Entry"}),Co=c({type:"config.updated",schema:{}}),rp={Updated:Co,Definitions:l(Co)};var It={};Ie(It,{ConfigIntegration:()=>It,Document:()=>Cn,Policies:()=>ze,Remote:()=>Mo,WellKnownDocument:()=>ae,make:()=>wo,suppliers:()=>Po});var ze=f(F).pipe(m(F,{decode:x((o)=>o.filter((i)=>{let p=J(n({action:t}))(i);if(M(p)&&!Ir(Yo)(p.value.action))return!1;let g=J(n({effect:t}))(i);return k(g)||Ir(Qt)(g.value.effect)})),encode:de({strict:!1})}),m(f(Fe))),Mo=n({providers:T.fields.providers,mcp:T.fields.mcp,policies:ze.pipe(C),websearch:T.fields.websearch});class Cn extends re.extend("Config.IntegrationDocument")({integrationID:Pe,connection:pt,organization:C(t)}){}class ae extends re.extend("Config.WellKnownDocument")({integrationID:Pe}){}function Po(o){return new Map(o.filter((i)=>i instanceof ae).flatMap((i)=>Object.keys(i.info.providers??{}).map((p)=>[p,i.integrationID])))}function wo(o){let i=o.info.mcp?.servers;return new Cn({type:"document",integrationID:o.integrationID,connection:o.connection,organization:o.organization,info:new T({providers:o.info.providers&&Object.fromEntries(Object.entries(o.info.providers).map(([p,g])=>[p,new Te({...g,env:void 0,settings:qe(g.settings),models:g.models&&Object.fromEntries(Object.entries(g.models).map(([D,P])=>[D,{...P,settings:qe(P.settings),variants:P.variants?.map((I)=>({...I,settings:qe(I.settings)}))}]))})])),mcp:i&&new We({servers:Object.fromEntries(Object.entries(i).filter(([,p])=>p.type==="remote"))}),policies:o.info.policies,websearch:o.info.websearch})})}function qe(o){return o&&Object.fromEntries(Object.entries(o).filter(([i])=>!["apiKey","authToken","accessToken"].includes(i)))}
|
|
2
|
-
export{Ie,Pe,Yo,It,Cn};
|
package/chunk-9pcmbxq5.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-jqhy4pzf.js";import{ft}from"./chunk-5x5fc0mq.js";import{w,D,J,t,n,se}from"./chunk-nva98fq1.js";var u={};w(u,{CliInstall:()=>u,directory:()=>m,install:()=>I,packageName:()=>b,uninstall:()=>k});import{randomUUID as S}from"node:crypto";import{chmodSync as g,copyFileSync as j,cpSync as v,existsSync as c,readFileSync as C,realpathSync as f,renameSync as h,rmSync as l}from"node:fs";import o from"node:path";var b="@opencode/console",m=(e)=>o.join(e.data,"cli");function I(e,r){let s=m(e);if(r.entry===void 0){let a=o.join(s,o.basename(r.execPath));return x(s,(p)=>{ft(p);let y=o.join(p,o.basename(r.execPath));j(r.execPath,y),g(y,493)}),[a]}let i=f(r.entry),d=o.dirname(i);if(!O(d))return[r.execPath,i];return x(s,(a)=>v(d,a,{recursive:!0})),[U(r.execPath,r.path),o.join(s,o.basename(i))]}function U(e,r){if(!c(e))return e;let s=f(e);return(r??"").split(o.delimiter).filter((i)=>o.isAbsolute(i)).map((i)=>o.join(i,o.basename(e))).find((i)=>c(i)&&f(i)===s)??e}function k(e){l(m(e),{recursive:!0,force:!0})}function O(e){let r=o.join(e,"package.json");if(!c(r))return!1;let s=J(se(n({name:t})))(C(r,"utf8"));return D(s)?.name===b}function x(e,r){ft(o.dirname(e));let s=`${e}.${S()}.tmp`,i=`${e}.${S()}.old`;try{if(r(s),c(e))h(e,i);h(s,e)}finally{l(s,{recursive:!0,force:!0}),l(i,{recursive:!0,force:!0})}}export{u as CliInstall,m as directory,I as install,b as packageName,k as uninstall};
|
package/chunk-a85j5cz4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{us,tn,At,ls,ze,he,ps,Re,me,qr,ft,fs}from"./chunk-5x5fc0mq.js";import"./chunk-jqhy4pzf.js";export{fs as ConsoleStore,tn as credentialFile,ft as ensureDir,ze as locked,us as make,ps as modified,he as read,me as remove,At as snapshotFile,ls as syncClaimFile,qr as unreachable,Re as write};
|
package/chunk-bgqw45qt.js
DELETED
package/chunk-dsk7ztf6.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{It}from"./chunk-6tene1pb.js";import{At,he,Re,me}from"./chunk-5x5fc0mq.js";import{In}from"./chunk-1mfjsp5r.js";import{w,Me,D,J,C,F,t,ne,n,y,se}from"./chunk-nva98fq1.js";var Zo={};w(Zo,{Info:()=>Ks,MAX_AGE_MS:()=>Ws,WorkspaceSnapshot:()=>Zo,clear:()=>Jo,models:()=>Gi,policies:()=>Gs,read:()=>Ko,stale:()=>Vn,workspace:()=>Vo,write:()=>Go});var Ws=60000,Ks=n({owner:t,organization:C(t),fetched:ne,config:C(y(t,F)),status:C(n({message:t,url:C(t)}))}),c=J(se(Ks)),f=n({policies:C(F)}),s=y(t,n({models:C(y(t,F))}));function Ko(o){return D(c(he(At(o))??""))}function Go(o,e){Re(At(o),JSON.stringify(e))}function Jo(o){me(At(o))}function Vn(o,e){return e-o.fetched>=Ws}function Gs(o){if(!o)return;let e=o.config;if(!e)return o.status?void 0:[];let r=e.policies??D(J(f)(e.experimental))?.policies;if(r===void 0)return[];return D(J(It.Policies)(r))}function Vo(o,e){if(!o)return{policies:[]};return{organization:e?.organization??In(o),policies:Gs(e),status:e?.status}}function Gi(o){let e=o?.config?.providers;if(e===void 0)return 0;return Object.values(Me(J(s)(e),()=>({}))).reduce((r,i)=>r+Object.keys(i.models??{}).length,0)}
|
|
2
|
-
export{Ws,Ks,Ko,Go,Jo,Vn,Gs,Vo,Gi,Zo};
|
package/chunk-gtf5exm1.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{rs,os}from"./chunk-ke4nwx54.js";import{he}from"./chunk-5x5fc0mq.js";import{w,Me,D,_e,r,q,g,L,J,C,F,t,n,y,f,se}from"./chunk-nva98fq1.js";var zo={};w(zo,{Library:()=>zo,fetchChanged:()=>Gn,library:()=>Zt,servers:()=>Kn,skillMarkdown:()=>Hs,write:()=>Jn});import{randomUUID as b}from"node:crypto";import{existsSync as x,mkdirSync as G,renameSync as R,rmSync as h}from"node:fs";import p from"node:path";import{randomUUID as A}from"node:crypto";import{chmodSync as j,copyFileSync as E,existsSync as m,mkdirSync as N,renameSync as B,rmSync as I,statSync as M,writeFileSync as W}from"node:fs";import K from"node:path";var Uo={originals:y(t,n({value:C(F)})),written:y(t,F)};function Gt(e){let i=he(e);if(i===void 0||i.trim()==="")return;let o=D(J(se(F))(i));if(typeof o!=="object"||o===null||Array.isArray(o))throw Error(`${e} isn't valid JSON, so it was left alone. Fix it and run setup again.`);return{...o}}function Jt(e,i,o){let s=`${JSON.stringify(i,null,2)}
|
|
2
|
-
`;if(he(e)===s)return;Bo(e,s,o)}function Lo(e,i,o,s){let c={...o?.originals},d={...o?.written};return Object.keys(c).filter((a)=>!(a in i)).forEach((a)=>{Nr(e,a,{originals:c,written:d}),delete c[a],delete d[a]}),Object.entries(i).forEach(([a,u])=>{if(a in d&&JSON.stringify(Dr(e,a))!==JSON.stringify(d[a])&&!s)return;if(!(a in c))c[a]=_(e,a);$o(e,a,u),d[a]=u}),{originals:c,written:d}}function Nr(e,i,o){if(JSON.stringify(Dr(e,i))!==JSON.stringify(o.written[i]))return;let s=o.originals[i];if(s&&"value"in s&&s.value!==void 0)$o(e,i,s.value);else zs(e,i)}function Dr(e,i){let[o,s]=S(i);return s===void 0?e[o]:z(e[o])[s]}function $o(e,i,o){let[s,c]=S(i);if(c===void 0)e[s]=o;else e[s]={...z(e[s]),[c]:o}}function zs(e,i){let[o,s]=S(i);if(s===void 0){delete e[o];return}let c=z(e[o]);if(delete c[s],Object.keys(c).length===0)delete e[o];else e[o]=c}var Ct=(e)=>`${e}.opencode-console.bak`;function jo(e){if(!m(e)||m(Ct(e)))return;E(e,Ct(e)),j(Ct(e),384)}function Bo(e,i,o=420){N(K.dirname(e),{recursive:!0});let s=`${e}.${A()}.tmp`;W(s,i,{mode:m(e)?M(e).mode&511:o,flag:"wx"});try{B(s,e)}catch(c){throw I(s,{force:!0}),c}}function z(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)?{...e}:{}}function Vt(e){return typeof e==="string"&&e!==""?e:void 0}function _(e,i){let o=Dr(e,i);return o===void 0?{}:{value:o}}function S(e){let i=e.indexOf(".");return i===-1?[e,void 0]:[e.slice(0,i),e.slice(i+1)]}var H=n({instructions:C(f(n({name:t,content:t}))),skills:C(f(n({slug:t,version:t})))}),P=n({servers:y(t,n({type:t,url:C(t),headers:C(y(t,t))}))});function Zt(e){let i=D(J(H)(e.library));return{instructions:i?.instructions??[],skills:(i?.skills??[]).filter((o)=>T(o.slug))}}function Kn(e){let i=Me(J(P)(e.mcp),()=>({servers:{}})).servers;return Object.fromEntries(Object.entries(i).flatMap(([o,s])=>s.type==="remote"&&s.url!==void 0?[[o,{url:s.url,headers:s.headers}]]:[]))}var Gn=L("Library.fetchChanged")(function*(e,i,o,s){return yield*_e(o.filter((c)=>{let d=x(p.join(i,c.slug));if(d&&!(c.slug in s))return!1;return s[c.slug]!==c.version||!d}),(c)=>q(function*(){let d=yield*rs(e,c.slug),a=yield*_e(d.files,(u)=>u.kind==="text"?r({path:u.path,content:u.content}):os(e,c.slug,u.sha256).pipe(g((l)=>({path:u.path,content:l}))),{concurrency:4});return{slug:c.slug,version:c.version,files:a}}),{concurrency:2})});function Jn(e,i,o,s){let c={},d=[];return Object.keys(s).filter((a)=>!i.some((u)=>u.slug===a)).forEach((a)=>h(p.join(e,a),{recursive:!0,force:!0})),i.forEach((a)=>{let u=p.join(e,a.slug);if(x(u)&&!(a.slug in s)){d.push(`/${a.slug}`);return}let l=o.find((v)=>v.slug===a.slug);if(l)Q(u,l.files);c[a.slug]=l?.version??s[a.slug]??a.version}),{skills:c,skipped:d}}function Q(e,i){let o=`${e}.${b()}.tmp`,s=`${e}.${b()}.old`;G(o,{recursive:!0});try{if(i.forEach((c)=>{let d=c.path.split(/[\\/]/);if(c.path===""||p.isAbsolute(c.path)||d.some((u)=>u===".."||u===""))return;let a=c.path==="SKILL.md"&&typeof c.content==="string"?Hs(c.content):c.content;Bo(p.join(o,c.path),a)}),x(e))R(e,s);R(o,e)}finally{h(o,{recursive:!0,force:!0}),h(s,{recursive:!0,force:!0})}}function Hs(e){let i=e.match(/^---\n([\s\S]*?)\n---\n/);if(!i)return e;let o=i[1].split(`
|
|
3
|
-
`),s=o.some((u)=>/^\s*"?opencode\/autoinvoke"?:\s*false\s*$/.test(u)),d=[...o.filter((u,l)=>{if(u.startsWith("name:"))return!1;if(/^metadata:\s*$/.test(u))return o[l+1]?.trim().startsWith('"opencode/autoinvoke"')!==!0;return!/^\s+"opencode\/autoinvoke":/.test(u)}),...s?["disable-model-invocation: true"]:[]],a=e.slice(i[0].length);return d.length===0?a.replace(/^\n/,""):`---
|
|
4
|
-
${d.join(`
|
|
5
|
-
`)}
|
|
6
|
-
---
|
|
7
|
-
${a}`}function T(e){return/^[a-z0-9][a-z0-9._-]*$/i.test(e)&&e.toLowerCase()!=="synced"}
|
|
8
|
-
export{Uo,Gt,Jt,Lo,Nr,Dr,$o,zs,Ct,jo,Bo,z,Vt,Zt,Kn,Gn,Jn,Hs,zo};
|
package/chunk-hf4hqs7y.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import"./chunk-jqhy4pzf.js";import{w,D,J,C,F,t,n,y,se}from"./chunk-nva98fq1.js";var h={};w(h,{ClaudeCodeHook:()=>h,Unreadable:()=>d,checks:()=>x,decode:()=>v,denial:()=>P,eventName:()=>T});var S=n({hook_event_name:t,cwd:C(t),tool_name:C(t),tool_input:C(y(t,F)),mcp_server:C(n({name:C(t)})),prompt:C(t),expansion_type:C(t),command_name:C(t)}),v=J(se(S));class d extends Error{}var E={platform:process.platform,env:process.env};function x(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",[k(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 P(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 T(e){return D(J(se(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 k(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?[k(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,x as checks,v as decode,P as denial,T as eventName};
|
package/chunk-jqhy4pzf.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{w,c,i,a,hs,P,l,O,dt,Ne,Mt,Oe,r,o,H,ho,jn,xo,nt}from"./chunk-nva98fq1.js";var oi={};w(oi,{BrandError:()=>b,all:()=>M,check:()=>R,make:()=>D,nominal:()=>ds});var si={};w(si,{Path:()=>Tt,TypeId:()=>C,layer:()=>Y,make:()=>On});class b{constructor(e){this.issue=e}_tag="BrandError";name="BrandError";issue;get message(){return ho(this.issue)}toString(){return`BrandError(${this.message})`}}function ds(){return Object.assign((e)=>e,{option:(e)=>a(e),result:(e)=>l(e),is:(e)=>!0})}function D(e){return R(jn(e))}function R(...e){let t=(s)=>dt(xo(e,s),(f)=>new b(f));return Object.assign((s)=>Ne(t(s)),{option:(s)=>hs(t(s)),result:t,is:(s)=>O(t(s)),checks:e})}function M(...e){let t=e.flatMap((s)=>s.checks??[]);return Mt(t)?R(...t):ds()}var C="~effect/Path",Tt=P("effect/Path"),On=(e)=>Tt.of({...e,[C]:C,resolveWithin(t,s){if(e.parse(s).root!=="")return i();let f=e.resolve(t),m=e.resolve(f,s),n=e.relative(f,m);return n===".."||n.startsWith(`..${e.sep}`)||e.isAbsolute(n)?i():a(m)}});function E(e,t){let s="",f=0,m=-1,n=0,p;for(let x=0;x<=e.length;++x){if(x<e.length)p=e.charCodeAt(x);else if(p===47)break;else p=47;if(p===47){if(m===x-1||n===1);else if(m!==x-1&&n===2){if(s.length<2||f!==2||s.charCodeAt(s.length-1)!==46||s.charCodeAt(s.length-2)!==46){if(s.length>2){let d=s.lastIndexOf("/");if(d!==s.length-1){if(d===-1)s="",f=0;else s=s.slice(0,d),f=s.length-1-s.lastIndexOf("/");m=x,n=0;continue}}else if(s.length===2||s.length===1){s="",f=0,m=x,n=0;continue}}if(t){if(s.length>0)s+="/..";else s="..";f=2}}else{if(s.length>0)s+="/"+e.slice(m+1,x);else s=e.slice(m+1,x);f=x-m-1}m=x,n=0}else if(p===46&&n!==-1)++n;else n=-1}return s}function z(e){if(!e)return"";return e.startsWith(".")?e:`.${e}`}function _(e,t){let s=t.dir||t.root,f=t.base||(t.name||"")+z(t.ext);if(!s)return f;if(s===t.root)return s+f;return s+e+f}function q(e){if(e.protocol!=="file:")return o(new nt({module:"Path",method:"fromFileUrl",description:"URL must be of scheme file"}));else if(e.hostname!=="")return o(new nt({module:"Path",method:"fromFileUrl",description:"Invalid file URL host"}));let t=e.pathname;for(let s=0;s<t.length;s++)if(t[s]==="%"){let f=t.codePointAt(s+2)|32;if(t[s+1]==="2"&&f===102)return o(new nt({module:"Path",method:"fromFileUrl",description:"must not include encoded / characters"}))}return H({try:()=>decodeURIComponent(t),catch:(s)=>new nt({module:"Path",method:"fromFileUrl",cause:s})})}var T=function(){let t="",s=!1,f=void 0;for(let m=arguments.length-1;m>=-1&&!s;m--){let n;if(m>=0)n=arguments[m];else{let p=globalThis.process;if(f===void 0&&"process"in globalThis&&typeof p==="object"&&p!==null&&typeof p.cwd==="function")f=p.cwd();n=f}if(n.length===0)continue;t=n+"/"+t,s=n.charCodeAt(0)===47}if(t=E(t,!s),s)if(t.length>0)return"/"+t;else return"/";else if(t.length>0)return t;else return"."},W=47;function G(e){let t=new URL("file://"),s=T(e);if(e.charCodeAt(e.length-1)===W&&s[s.length-1]!=="/")s+="/";return t.pathname=X(s),r(t)}var J=/%/g,Q=/\\/g,V=/\n/g,K=/\r/g,j=/\t/g;function X(e){if(e.includes("%"))e=e.replace(J,"%25");if(e.includes("\\"))e=e.replace(Q,"%5C");if(e.includes(`
|
|
2
|
-
`))e=e.replace(V,"%0A");if(e.includes("\r"))e=e.replace(K,"%0D");if(e.includes("\t"))e=e.replace(j,"%09");return e}var S=On({resolve:T,normalize(e){if(e.length===0)return".";let t=e.charCodeAt(0)===47,s=e.charCodeAt(e.length-1)===47;if(e=E(e,!t),e.length===0&&!t)e=".";if(e.length>0&&s)e+="/";if(t)return"/"+e;return e},isAbsolute(e){return e.length>0&&e.charCodeAt(0)===47},join(){if(arguments.length===0)return".";let e;for(let t=0;t<arguments.length;++t){let s=arguments[t];if(s.length>0)if(e===void 0)e=s;else e+="/"+s}if(e===void 0)return".";return S.normalize(e)},relative(e,t){if(e===t)return"";if(e=S.resolve(e),t=S.resolve(t),e===t)return"";let s=1;for(;s<e.length;++s)if(e.charCodeAt(s)!==47)break;let f=e.length,m=f-s,n=1;for(;n<t.length;++n)if(t.charCodeAt(n)!==47)break;let x=t.length-n,d=m<x?m:x,h=-1,u=0;for(;u<=d;++u){if(u===d){if(x>d){if(t.charCodeAt(n+u)===47)return t.slice(n+u+1);else if(u===0)return t.slice(n+u)}else if(m>d){if(e.charCodeAt(s+u)===47)h=u;else if(u===0)h=0}break}let A=e.charCodeAt(s+u),k=t.charCodeAt(n+u);if(A!==k)break;else if(A===47)h=u}let g="";for(u=s+h+1;u<=f;++u)if(u===f||e.charCodeAt(u)===47)if(g.length===0)g+="..";else g+="/..";if(g.length>0)return g+t.slice(n+h);else{if(n+=h,t.charCodeAt(n)===47)++n;return t.slice(n)}},dirname(e){if(e.length===0)return".";let t=e.charCodeAt(0),s=t===47,f=-1,m=!0;for(let n=e.length-1;n>=1;--n)if(t=e.charCodeAt(n),t===47){if(!m){f=n;break}}else m=!1;if(f===-1)return s?"/":".";if(s&&f===1)return"//";return e.slice(0,f)},basename(e,t){let s=0,f=-1,m=!0,n;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";let p=t.length-1,x=-1;for(n=e.length-1;n>=0;--n){let d=e.charCodeAt(n);if(d===47){if(!m){s=n+1;break}}else{if(x===-1)m=!1,x=n+1;if(p>=0)if(d===t.charCodeAt(p)){if(--p===-1)f=n}else p=-1,f=x}}if(s===f)f=x;else if(f===-1)f=e.length;return e.slice(s,f)}else{for(n=e.length-1;n>=0;--n)if(e.charCodeAt(n)===47){if(!m){s=n+1;break}}else if(f===-1)m=!1,f=n+1;if(f===-1)return"";return e.slice(s,f)}},extname(e){let t=-1,s=0,f=-1,m=!0,n=0;for(let p=e.length-1;p>=0;--p){let x=e.charCodeAt(p);if(x===47){if(!m){s=p+1;break}continue}if(f===-1)m=!1,f=p+1;if(x===46){if(t===-1)t=p;else if(n!==1)n=1}else if(t!==-1)n=-1}if(t===-1||f===-1||n===0||n===1&&t===f-1&&t===s+1)return"";return e.slice(t,f)},format:function(t){if(t===null||typeof t!=="object")throw TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return _("/",t)},parse(e){let t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;let s=e.charCodeAt(0),f=s===47,m;if(f)t.root="/",m=1;else m=0;let n=-1,p=0,x=-1,d=!0,h=e.length-1,u=0;for(;h>=m;--h){if(s=e.charCodeAt(h),s===47){if(!d){p=h+1;break}continue}if(x===-1)d=!1,x=h+1;if(s===46){if(n===-1)n=h;else if(u!==1)u=1}else if(n!==-1)u=-1}if(n===-1||x===-1||u===0||u===1&&n===x-1&&n===p+1){if(x!==-1)if(p===0&&f)t.base=t.name=e.slice(1,x);else t.base=t.name=e.slice(p,x)}else{if(p===0&&f)t.name=e.slice(1,n),t.base=e.slice(1,x);else t.name=e.slice(p,n),t.base=e.slice(p,x);t.ext=e.slice(n,x)}if(p>0)t.dir=e.slice(0,p-1);else if(f)t.dir="/";return t},sep:"/",fromFileUrl:q,toFileUrl:G,toNamespacedPath:c}),Y=Oe(Tt)(S);export{ds,oi,Tt,On,si};
|
package/chunk-ke4nwx54.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{as,Ys,Xt,Qs,tr,Xs,Be,en,Ee,ei,ni,Br}from"./chunk-yjw665b0.js";import{w,M,xe,Jr,R,at,pn,q,u,Xr,g,fr,yt,be,Is,ce,L,C,d,F,t,ne,n,y,f,b,wt}from"./chunk-nva98fq1.js";var is={};w(is,{ConsoleClient:()=>is,DeviceSignInFailed:()=>Xn,OAuth:()=>Yn,SignedOut:()=>An,SsoRequired:()=>Qn,authorize:()=>es,clientID:()=>Zn,defaultServer:()=>Xo,fetchConfig:()=>ns,fetchModels:()=>er,fetchSkill:()=>rs,fetchSkillBlob:()=>os,headers:()=>Zs,normalizeServer:()=>ss,refresh:()=>ts,revoke:()=>Lr,signedOutMessage:()=>Js,ssoMessage:()=>Vs});var Xo="https://opencode.ai/console",Zn="opencode-console-cli",Yn=n({type:d("oauth"),server:t,access:t,refresh:t,expires:ne,accountID:t,email:C(t),orgID:C(t),orgName:C(t)}),Js="Signed out of OpenCode Console. Run `npx @opencode/console login` to sign in again",Vs=(e)=>`Sign in with SSO again to use ${e??"your OpenCode Console workspace"}`;class Qn extends R("ConsoleClient.SsoRequired"){get message(){return Vs(this.organization)}}class An extends R("ConsoleClient.SignedOut"){get message(){return Js}}class Xn extends R("ConsoleClient.DeviceSignInFailed"){}function Zs(e){return{authorization:`Bearer ${e.type==="oauth"?e.access:e.key}`,...e.type==="oauth"&&e.orgID?{"x-org-id":e.orgID}:{}}}var x=n({device_code:t,user_code:t,verification_uri:t,verification_uri_complete:t,expires_in:ne,interval:ne}),S=n({access_token:t,refresh_token:t,expires_in:ne,org_id:C(wt(t))}),m=n({error:t}),v=n({id:t,email:t}),T=n({id:t,name:t}),U=n({_tag:d("SsoRequired"),connectionId:C(t)}),O=n({_tag:d("Unauthorized")}),B=y(t,F),D={access_denied:"The sign-in was denied in the browser",expired_token:"The code expired before it was approved. Start the sign-in again"},es=L("ConsoleClient.authorize")(function*(e){let o=yield*Ee,r=yield*a(`${e}/auth/device/code`,{client_id:Zn,supports_org_scope:!0}).pipe(u(en),u(Be(x))),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 Xn({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:l(e,r.device_code,xe(r.interval)).pipe(be(Ee,o))}}),ts=L("ConsoleClient.refresh")(function*(e){let o=yield*a(`${e.server}/auth/device/token`,{grant_type:"refresh_token",refresh_token:e.refresh,client_id:Zn});if(o.status===400){let c=yield*Be(m)(o).pipe(Xr);if(M(c)&&c.value.error==="invalid_grant")return yield*new An}let r=yield*en(o).pipe(u(Be(S))),s=yield*at,i=r.org_id??e.orgID;return Yn.make({...e,access:r.access_token,refresh:r.refresh_token,expires:s+r.expires_in*1000,...i===void 0?{}:{orgID:i}})}),Lr=L("ConsoleClient.revoke")(function*(e){let o=yield*a(`${e.server}/auth/oauth/revoke`,{token:e.refresh,token_type_hint:"refresh_token",client_id:Zn}).pipe(fr(xe(5)));yield*en(o)}),ns=L("ConsoleClient.fetchConfig")(function*(e){return yield*p(e,"/api/v2/config",B)}),er=L("ConsoleClient.fetchModels")(function*(e){return yield*p(e,"/api/v1/models",H)}),rs=L("ConsoleClient.fetchSkill")(function*(e,o){return yield*p(e,`/api/v2/library/skills/${encodeURIComponent(o)}?format=v2`,I)}),os=L("ConsoleClient.fetchSkillBlob")(function*(e,o,r){return yield*_(e,`/api/v2/library/skills/${encodeURIComponent(o)}/blobs/${encodeURIComponent(r)}`,(s)=>s.arrayBuffer.pipe(g((i)=>new Uint8Array(i))))}),H=y(t,n({name:C(t),models:y(t,y(t,F))})),I=n({slug:t,version:t,files:f(b([n({kind:d("text"),path:t,content:t}),n({kind:d("blob"),path:t,sha256:t})]))});function p(e,o,r){return _(e,o,Be(r))}function _(e,o,r){return u(Ee,(s)=>ni(s).execute(as(`${e.server}${o}`).pipe(tr,Xt(Zs(e)))).pipe(u((i)=>q(function*(){if(i.status===401){let c=yield*Be(O)(i).pipe(Xr);if(M(c))return yield*new An}if(i.status===403){let c=yield*Be(U)(i).pipe(Xr);if(M(c))return yield*new Qn({organization:e.type==="oauth"?e.orgName:void 0,url:E(e.server,c.value.connectionId)})}return yield*r(yield*en(i))})),Is,fr(xe(10))))}function ss(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 E(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 l(e,o,r){return q(function*(){yield*yt(r);let s=yield*a(`${e}/auth/device/token`,{grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:o,client_id:Zn}),i=yield*Be(b([S,m]))(s);if("access_token"in i)return yield*J(e,i);if(i.error==="authorization_pending")return yield*l(e,o,r);if(i.error==="slow_down")return yield*l(e,o,Jr(r,xe(5)));return yield*new Xn({message:D[i.error]??`The Console refused the sign-in (${i.error})`})})}var J=ce(function*(e,o){let[r,s]=yield*pn([h(`${e}/api/user`,o.access_token,v),h(`${e}/api/orgs`,o.access_token,f(T))],{concurrency:2}),i=o.org_id==null?void 0:s.find((k)=>k.id===o.org_id);if(o.org_id!=null&&!i)return yield*new Xn({message:`The workspace ${o.org_id} wasn't found after signing in`});let c=yield*at;return Yn.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 h(e,o,r){return u(Ee,(s)=>ei(s).execute(as(e).pipe(tr,Qs(o)))).pipe(u(Be(r)))}function a(e,o){return u(Ee,(r)=>r.execute(Ys(e).pipe(tr,Xs(o)))).pipe(be(Br,{redirect:"manual"}))}
|
|
2
|
-
export{Xo,Zn,Yn,Js,Vs,Qn,An,Xn,Zs,es,ts,Lr,ns,er,rs,os,ss,is};
|