@opencode/console 0.1.0 → 0.1.2

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.
Files changed (65) hide show
  1. package/README.md +23 -1
  2. package/THIRD_PARTY_LICENSES.md +43 -0
  3. package/chunk-0067hzw7.js +11 -0
  4. package/chunk-0trayd9n.js +2 -0
  5. package/chunk-37whdg3n.js +1 -0
  6. package/chunk-6bc9ezw6.js +1 -0
  7. package/chunk-71rwyxw2.js +2 -0
  8. package/chunk-78cwb109.js +162 -0
  9. package/chunk-7k3ymrp6.js +254 -0
  10. package/chunk-83pr45e8.js +1 -0
  11. package/{chunk-z2kmm4pm.js → chunk-96f5c0tj.js} +2 -2
  12. package/chunk-ak1n0cs7.js +2 -0
  13. package/chunk-b02r286p.js +2 -0
  14. package/chunk-cdc5arvh.js +1 -0
  15. package/chunk-dnepb5ke.js +2 -0
  16. package/chunk-et9y1sb5.js +2 -0
  17. package/chunk-g9bke322.js +1 -0
  18. package/chunk-gvywgb0d.js +1 -0
  19. package/chunk-gxedprvk.js +32 -0
  20. package/chunk-jem7z938.js +3 -0
  21. package/chunk-kpp48ne0.js +1 -0
  22. package/chunk-ktx666b5.js +2 -0
  23. package/chunk-m3n97pxp.js +1 -0
  24. package/chunk-n5bt7jzp.js +3 -0
  25. package/chunk-px1nqkzb.js +2 -0
  26. package/chunk-rx6cjbq2.js +63 -0
  27. package/chunk-sbkpkav3.js +1 -0
  28. package/chunk-t8p1svd4.js +1 -0
  29. package/chunk-tx5wws16.js +2 -0
  30. package/chunk-vy3ahcaj.js +2 -0
  31. package/chunk-w6kmmxmz.js +1 -0
  32. package/chunk-wd4mfvqy.js +2 -0
  33. package/chunk-wkrya350.js +1 -0
  34. package/chunk-ysgtje2z.js +1 -0
  35. package/chunk-zgcspk2g.js +1 -0
  36. package/dsh-plugin.js +1 -0
  37. package/index.js +74 -47
  38. package/package.json +4 -2
  39. package/pi-extension.js +2 -2
  40. package/chunk-0krh2hdf.js +0 -1
  41. package/chunk-1c689590.js +0 -1
  42. package/chunk-1mfjsp5r.js +0 -2
  43. package/chunk-41p6m0xy.js +0 -6
  44. package/chunk-4v6awhyw.js +0 -1
  45. package/chunk-52p33kcn.js +0 -1
  46. package/chunk-5x5fc0mq.js +0 -2
  47. package/chunk-6tene1pb.js +0 -2
  48. package/chunk-9pcmbxq5.js +0 -1
  49. package/chunk-a85j5cz4.js +0 -1
  50. package/chunk-bgqw45qt.js +0 -2
  51. package/chunk-dsk7ztf6.js +0 -2
  52. package/chunk-g6d8xejf.js +0 -63
  53. package/chunk-gtf5exm1.js +0 -8
  54. package/chunk-hf4hqs7y.js +0 -3
  55. package/chunk-jqhy4pzf.js +0 -2
  56. package/chunk-ke4nwx54.js +0 -2
  57. package/chunk-nva98fq1.js +0 -32
  58. package/chunk-p909n1zf.js +0 -1
  59. package/chunk-q3519h2y.js +0 -1
  60. package/chunk-r2y8x1nz.js +0 -12
  61. package/chunk-rea503jg.js +0 -1
  62. package/chunk-sbec97g3.js +0 -2
  63. package/chunk-vx37gkw9.js +0 -1
  64. package/chunk-wb6qf86j.js +0 -1
  65. package/chunk-yjw665b0.js +0 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @opencode/console
2
2
 
3
- Connects Claude Code and Pi to an OpenCode Console workspace. They then use the workspace's models, MCP servers,
3
+ Connects Claude Code, Pi, Codex and DeepSeek Harness to an OpenCode Console workspace. They then use the workspace's models, MCP servers,
4
4
  skills and instructions, and their tool calls follow the workspace's policies. OpenCode connects to Console on its own,
5
5
  so OpenCode users don't need this package.
6
6
 
@@ -22,12 +22,34 @@ npx @opencode/console setup pi
22
22
  The package is also a Pi package, so `pi install npm:@opencode/console` works too; run `npx @opencode/console login`
23
23
  once after it.
24
24
 
25
+ ## Set up Codex
26
+
27
+ ```sh
28
+ npx @opencode/console setup codex
29
+ ```
30
+
31
+ Setup writes Codex's `~/.codex/config.toml` and `hooks.json` (or those in `CODEX_HOME`) and approves its policy hooks,
32
+ so Codex runs them without asking in `/hooks`.
33
+
34
+ ## Set up DeepSeek Harness
35
+
36
+ ```sh
37
+ npx @opencode/console setup deepseek-harness
38
+ ```
39
+
40
+ Setup adds a plugin to DeepSeek Harness's `~/.dsh/cordis.patch.yml` (or the one in `DSH_HOME`), so `dsh web`,
41
+ `dsh headless` and every other profile use the workspace. While it's set up, the workspace's models replace the model
42
+ providers you added to DeepSeek Harness, and new sessions start on the workspace's default model. Restart a running
43
+ `dsh` after setup.
44
+
25
45
  ## Other commands
26
46
 
27
47
  ```sh
28
48
  npx @opencode/console status # Show the sign-in, workspace and config
29
49
  npx @opencode/console setup claude-code --remove # Undo the Claude Code setup and keep the sign-in
30
50
  npx @opencode/console setup pi --remove # Undo the Pi setup and keep the sign-in
51
+ npx @opencode/console setup codex --remove # Undo the Codex setup and keep the sign-in
52
+ npx @opencode/console setup deepseek-harness --remove # Undo the DeepSeek Harness setup and keep the sign-in
31
53
  npx @opencode/console logout # Sign out
32
54
  ```
33
55
 
@@ -516,6 +516,33 @@ The above copyright notice and this permission notice shall be included in all c
516
516
 
517
517
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
518
518
 
519
+ ## smol-toml@1.9.1
520
+
521
+ Copyright (c) Squirrel Chat et al., All rights reserved.
522
+
523
+ Redistribution and use in source and binary forms, with or without
524
+ modification, are permitted provided that the following conditions are met:
525
+
526
+ 1. Redistributions of source code must retain the above copyright notice, this
527
+ list of conditions and the following disclaimer.
528
+ 2. Redistributions in binary form must reproduce the above copyright notice,
529
+ this list of conditions and the following disclaimer in the
530
+ documentation and/or other materials provided with the distribution.
531
+ 3. Neither the name of the copyright holder nor the names of its contributors
532
+ may be used to endorse or promote products derived from this software without
533
+ specific prior written permission.
534
+
535
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
536
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
537
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
538
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
539
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
540
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
541
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
542
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
543
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
544
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
545
+
519
546
  ## which@6.0.1
520
547
 
521
548
  The ISC License
@@ -545,3 +572,19 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
545
572
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
546
573
 
547
574
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
575
+
576
+ ## yaml@2.9.0
577
+
578
+ Copyright Eemeli Aro <eemeli@gmail.com>
579
+
580
+ Permission to use, copy, modify, and/or distribute this software for any purpose
581
+ with or without fee is hereby granted, provided that the above copyright notice
582
+ and this permission notice appear in all copies.
583
+
584
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
585
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
586
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
587
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
588
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
589
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
590
+ THIS SOFTWARE.
@@ -0,0 +1,11 @@
1
+ import{ds,ro,Qe,fn,At,_,at,je,Xe,It,Tt}from"./chunk-78cwb109.js";import{Ot}from"./chunk-0trayd9n.js";import{ke,J,be,W}from"./chunk-wd4mfvqy.js";import{ye,Be}from"./chunk-tx5wws16.js";import{$e}from"./chunk-71rwyxw2.js";import{Ct,cr,lr}from"./chunk-96f5c0tj.js";import{le}from"./chunk-ak1n0cs7.js";import{k,F,I,L,Ge,Ie,D,z,S,e,V,v,n,x,u,B,Ze,Z}from"./chunk-gxedprvk.js";var ss={};k(ss,{DeepSeekHarness:()=>ss,MCP_SERVICE:()=>Un,REALM:()=>Xo,Route:()=>ui,SERVICE:()=>eo,TOKEN:()=>Xr,Unreadable:()=>Ln,checks:()=>ns,defaultModel:()=>pi,invokedSkills:()=>rs,manifest:()=>pn,manifestFile:()=>to,mcpConfig:()=>ts,paths:()=>ya,refresh:()=>os,remove:()=>ba,routes:()=>es});import{createHash as H}from"node:crypto";import{existsSync as K,readdirSync as U,rmSync as Y}from"node:fs";import G from"node:os";import y from"node:path";function ya(s=process.env,t=G.homedir(),o=process.platform){let r=s.DSH_HOME?.trim(),i=r!==void 0&&(r.startsWith("~/")||o==="win32"&&r.startsWith("~\\")),a=y.resolve(r?r==="~"?t:i?y.join(t,r.slice(2)):r:t,r?"":".dsh");return{home:a,patch:y.join(a,"cordis.patch.yml"),skills:y.join(a,"skills")}}var Xr="OPENCODE_CONSOLE_TOKEN",Xo="opencode-console",eo="opencodeConsole",Un="opencodeConsoleMcp",ui=n({displayName:e,api:B(["anthropic-messages","openai-responses","openai-completions"]),baseURL:e,apiKeyEnv:e,headers:x(e,e),compat:S(n({supportsDeveloperRole:v,maxTokensField:e})),models:u(n({id:e,name:e,contextWindow:S(V),maxTokens:S(V),input:u(B(["text","image"]))}))}),j={messages:"anthropic-messages",responses:"openai-responses","chat-completions":"openai-completions"};function es(s){let t=Ct(s),o=lr(t),r=Map.groupBy(t,(i)=>i.provider);return Object.fromEntries([...r].flatMap(([i,a])=>{let l=a.map(Q),p=l[0],g=p!==void 0&&l.every((m)=>m?.api===p.api&&m.url===p.url);if(!g&&o===void 0)return[];let w=g?p.api:"anthropic-messages",f={displayName:s[i]?.name??i,api:w,baseURL:g?w==="anthropic-messages"?p.url.replace(/\/v1\/?$/,""):p.url:`${o}/anthropic`,apiKeyEnv:Xr,headers:{"x-opencode-plugin":`opencode-console/${le}`},...w==="openai-completions"?{compat:{supportsDeveloperRole:!1,maxTokensField:"max_tokens"}}:{},models:a.map((m)=>X(m,g||i==="opencode"?m.id:`${i}/${m.id}`))};return[[i,f]]}))}function pi(s){let t=Ct(s),o=cr(t,"sonnet","opus","haiku");if(!o)return;let i=es(s)[o.provider]?.models.find((a)=>a.id===o.id||a.id===`${o.provider}/${o.id}`)?.id;return i===void 0?void 0:{provider:o.provider,model:i}}function Q(s){let t=_(s.entry.api),o=Object.keys(j).find((i)=>(i in t)),r=o&&at(_(t[o]).base_url);return o&&r?{api:j[o],url:r}:void 0}function X(s,t){let o=_(s.entry.limit),r=_(s.entry.modalities).input;return{id:t,name:at(s.entry.name)??s.id,...E(o.context)===void 0?{}:{contextWindow:E(o.context)},...E(o.output)===void 0?{}:{maxTokens:E(o.output)},input:Array.isArray(r)&&r.some((i)=>typeof i==="string"&&i.startsWith("image"))?["text","image"]:["text"]}}function E(s){return typeof s==="number"&&Number.isFinite(s)&&s>0?s:void 0}function ts(s,t){if(!t)throw Error(`The workspace doesn't offer the MCP server ${s} anymore`);return{serverName:s,transport:"streamable-http",url:t.url,...t.headers?{headers:{...t.headers}}:{}}}class Ln extends Error{}async function ns(s,t){let o=_(s.input),r=s.name,i=(c,d,b={})=>({action:c,resources:d,directory:t.directory,...b}),a=(c)=>{let d=o[c];return typeof d==="string"&&d!==""?d:void 0},l=(c)=>{let d=a(c);if(d===void 0)throw new Ln(`${r}'s input has no ${c}`);return d},p=(c)=>t.resolve(l(c)),g=(c)=>{let d=t.skills&&ee(t.skills,c);return d?i("skill",[d]):i("read",[c])},w=async(c)=>{let d=a(c);return d===void 0?{}:{directories:[await t.resolve(d)]}},f=(c,d={})=>i("shell",[c??""],{opaque:!0,...d}),m=async()=>i("subagent",[(a("agent_preset")??a("name")??a("runtime")??"general").toLowerCase()],await w("cwd"));if(r.startsWith("mcp__"))return ne(r,t.servers??[]).map((c)=>i(c.action,c.resources,c));switch(r){case"bash":case"pwsh":{let c=a("workdir");return[i("shell",[l("command")],{shell:r==="pwsh"?"pwsh":"bash",path:c===void 0?t.cwd:await t.resolve(c)})]}case"read":case"read_image":case"lsp":return[g(await p("file_path"))];case"write":case"edit":return[i("edit",[await p("file_path")])];case"apply_patch":{let c=te(l("input"));if(c.length===0)throw new Ln("apply_patch's input names no file");return[i("edit",await Promise.all(c.map(t.resolve)))]}case"str_replace_editor":return l("command")==="view"?[g(await p("path"))]:[i("edit",[await p("path")])];case"glob":case"grep":{let c=a("path");return[i(r,[l("pattern")],{path:c===void 0?t.cwd:await t.resolve(c)})]}case"web_fetch":return[i("webfetch",[l("url")])];case"web_search":{let c=Array.isArray(o.queries)?o.queries.filter((b)=>typeof b==="string"&&b!==""):[],d=c.length>0?c:[a("query")].flatMap((b)=>b??[]);if(d.length===0)throw new Ln("web_search's input has no queries");return[i("websearch",d)]}case"subagent":case"subagent_fork":case"spawn_teammate":case"ralph":return[await m()];case"subagent_oar":return[await m(),f(a("prompt"))];case"workflow":return[f(a("script")),i("subagent:",["*"],{truncated:!0})];case"run_code":return[f(a("code"))];case"terminal_send":return[f(a("text"))];case"terminal_open":{let c=a("cwd");return[f(a("type"),c===void 0?{}:{path:await t.resolve(c)})]}case"ask_user_question":return[i("question",["*"])];case"working_directory":return a("cd")===void 0?[]:[i("working_directory",["*"],await w("cd"))];case"skill":return[i("skill",[l("name")])];case"read_mcp_resource":case"list_mcp_resources":case"list_mcp_resource_templates":return[i("mcp.use",[l("server")])];default:return[i(r.toLowerCase(),["*"])]}}function ee(s,t){let o=y.relative(s,t);if(o===""||o.startsWith("..")||y.isAbsolute(o))return;return o.split(y.sep)[0]}function ne(s,t){let r=t.filter((a)=>s.startsWith(`mcp__${a}__`)).toSorted((a,l)=>l.length-a.length)[0]??s.match(/^mcp__(.+?)__./)?.[1];if(!r)throw new Ln(`Can't tell which MCP server ${s} belongs to`);let i=s.slice(`mcp__${r}__`.length);return[{action:"mcp.use",resources:[r]},/_[0-9a-f]{12}$/.test(s)?{action:`${r}_`,resources:["*"],truncated:!0}:{action:`${r}_${i}`,resources:["*"]}]}function te(s){return s.split(/\r?\n/).flatMap((t)=>{let o=t.trim().match(/^\*\*\* (?:Add File|Update File|Delete File|Move to): (.+)$/)?.[1]?.trim();return o?[o]:[]})}function rs(s){let t=s.flatMap((o)=>_(o.source).kind!=="user"||!Array.isArray(o.content)?[]:o.content.flatMap((r)=>{let i=_(r);return i.type==="text"&&typeof i.text==="string"?Array.from(i.text.matchAll(/(^|\s)\/([a-z0-9]+(?:-[a-z0-9]+)*)(?=\s|$)/g),(a)=>a[2]):[]}));return[...new Set(t)]}var O="# opencode-console:start",P="# opencode-console:end",re=n({provider:e,model:e}),N=n({paths:n({home:e,patch:e,skills:e}),plugin:e,harness:S(e),created:v,skills:x(e,e),providers:S(e),routes:S(x(e,ui)),model:S(Ze(re))}),to=(s)=>y.join(s.data,"deepseek-harness.json");function pn(s){let t=to(s),o=J(t);if(o===void 0)return;let r=F(z(Z(N))(o));if(!r)throw Error(`${t} can't be read, so DeepSeek Harness was left as it is. Delete it and run setup again.`);return r}var os=D("DeepSeekHarness.refresh")(function*(s,t){let o=pn(s),r=t??o;if(!r)return;let i=yield*Be(s),a=i&&$e(s,ye(i));if(!i||!a?.config)return;let l=a.config,p=je(l),g=H("sha256").update(JSON.stringify(l.providers??null)).digest("hex"),f=!t&&o?.providers===g&&o.routes!==void 0?void 0:yield*Ot(i),m=yield*It(i,r.paths.skills,p.skills,o?.skills??{});return yield*ke(s,I(()=>oe(s,{paths:r.paths,plugin:r.plugin,harness:t?t.harness:o?.harness,routes:f?es(f):o?.routes??{},model:f?pi(f):o?.model??void 0,servers:Xe(l),instructions:p.instructions.length,skills:p.skills,bundles:m,providers:g})))});function ba(s){let t=pn(s);if(!t)return!1;let o=J(t.paths.patch);if(o!==void 0){let r=q(o),i=r.after===""?r.before.replace(/\n+$/,`
2
+ `):`${r.before}${r.after}`,a=i.split(`
3
+ `).every((l)=>l.trim()===""||l.trimStart().startsWith("#"));if(a&&t.created)W(t.paths.patch);else if(r.marked)At(t.paths.patch,a?`${i.trimEnd()}${i.trim()===""?"":`
4
+ `}[]
5
+ `:i)}return Object.keys(t.skills).forEach((r)=>Y(y.join(t.paths.skills,r),{recursive:!0,force:!0})),W(Qe(t.paths.patch)),W(to(s)),!0}function oe(s,t){let o=pn(s),r=J(t.paths.patch),i=q(r??""),a=se(t.paths.patch,i),l=o?.created??r===void 0,p=[],g=(h)=>{let M=a.rows.some((R)=>R.id===h&&R.insert===void 0&&R.config!==void 0);if(M)p.push(`the ${h} row in ${t.paths.patch}`);return!M},w=Object.entries(t.servers).filter(([h])=>/^[A-Za-z0-9_-]{1,32}$/.test(h)),f=Object.keys(t.routes).length>0&&g("llm-pi-ai"),m=f&&t.model&&g("agent-default-model")?t.model:void 0,c=[{insert:[{id:"opencode-console",name:t.plugin,isolate:{credentials:Xo}},...w.map(([h])=>({id:`opencode-console-mcp-${h}`,name:"@deepseek-ai/dsh-mcp-client",inject:[Un],config:`__opencode_console_mcp__:${h}`}))]},{id:"agent-loop",inject:ie(a.rows)},...f?[{id:"llm-pi-ai",isolate:{credentials:Xo},config:{providers:t.routes}}]:[],...m?[{id:"agent-default-model",config:m}]:[]],d=[`${O} (written by \`npx @opencode/console setup deepseek-harness\`, which replaces this block on every sync; --remove takes it out)`,...c.map((h)=>`- ${JSON.stringify(h).replace(/"config":"__opencode_console_mcp__:([A-Za-z0-9_-]+)"/g,(M,R)=>`"config": !!js "ctx.${Un}.server('${R}')"`)}`),P].join(`
6
+ `),b=i.marked?`${a.before}${d}
7
+ ${i.after}`:`${[a.before.trimEnd(),d].filter((h)=>h!=="").join(`
8
+
9
+ `)}
10
+ `;if(A(t.paths.patch,b).length!==a.rows.length+c.length)throw Error(`${t.paths.patch} couldn't take setup's rows, so it was left alone. Fix it and run setup again.`);if(!o)fn(t.paths.patch);if(b!==r)At(t.paths.patch,b,384);let C=Tt(t.paths.skills,t.skills,t.bundles,o?.skills??{},{named:!0});return p.push(...C.skipped),be(to(s),JSON.stringify(N.make({paths:t.paths,plugin:t.plugin,...t.harness===void 0?{}:{harness:t.harness},created:l,skills:C.skills,providers:t.providers,routes:{...t.routes},model:t.model??null}))),{routes:f?t.routes:{},model:m,servers:w.map(([h])=>h),skills:Object.keys(C.skills),instructions:t.instructions,skipped:p,shadowed:f?ae(t.paths.home):[]}}var T={tag:"tag:yaml.org,2002:js",resolve:(s)=>s};function q(s){let t=s.match(new RegExp(`^${O}[^\\n]*\\n[\\s\\S]*?^${P}[^\\n]*(?:\\n|$)`,"m"));if(!t||t.index===void 0)return{before:s,after:"",marked:!1};return{before:s.slice(0,t.index),after:s.slice(t.index+t[0].length),marked:!0}}function A(s,t){let o=ro(t,{customTags:[T]});if(o.errors.length>0||o.warnings.length>0)throw Error(`${s} isn't YAML DeepSeek Harness reads, so it was left alone. Fix it and run setup again.`);let r=o.toJS();if(r===null||r===void 0)return[];if(!Array.isArray(r))throw Error(`${s} isn't a YAML list of patch rows, so it was left alone. Fix it and run setup again.`);return r.map((i)=>_(i))}function se(s,t){let o=`${t.before}${t.after}`,r=A(s,o),i=ro(o,{customTags:[T]}).contents;if(!ds(i)||!i.flow)return{rows:r,before:t.before};if(r.length>0)throw Error(`${s} lists its rows in flow style ([...]), so it was left alone. Write them as a block list.`);return{rows:r,before:t.before.replace(/^\s*\[\s*\][ \t]*\n?/m,"")}}function ie(s){let o=s.filter((r)=>r.id==="agent-loop"&&r.insert===void 0).map((r)=>r.inject).flatMap((r)=>Array.isArray(r)?r.filter((i)=>typeof i==="string"):Object.keys(_(r)));return[...new Set([...o,eo])]}function ae(s){let t=y.join(s,"profiles");if(!K(t))return[];return U(t,{withFileTypes:!0}).filter((o)=>o.isDirectory()&&!o.name.startsWith(".")&&o.name!=="node_modules").map((o)=>o.name).filter((o)=>{let r=y.join(t,o,"cordis.patch.yml");return Ie(L(()=>A(r,J(r)??"").some((i)=>i.id==="llm-pi-ai"&&i.insert===void 0&&i.config!==void 0)).pipe(Ge(()=>!1)))})}
11
+ export{ya,Xr,Xo,eo,Un,ui,es,pi,ts,Ln,ns,rs,to,pn,os,ba,ss};
@@ -0,0 +1,2 @@
1
+ import{Ps,Ei,mn,ki,Sr,Ci,et,hn,_e,Ai,Ti,uo}from"./chunk-gvywgb0d.js";import{k,U,ve,xo,N,vt,Dt,G,l,wo,g,Pr,Lt,Ae,Vs,fe,D,S,d,j,e,V,n,x,u,w,Ze}from"./chunk-gxedprvk.js";var _s={};k(_s,{ConsoleClient:()=>_s,DeviceSignInFailed:()=>br,OAuth:()=>xr,SignedOut:()=>qn,SsoRequired:()=>yr,authorize:()=>Es,clientID:()=>gr,codexModelsPath:()=>ao,defaultServer:()=>ws,fetchCodexModels:()=>As,fetchConfig:()=>Cs,fetchModels:()=>Ot,fetchSkill:()=>Is,fetchSkillBlob:()=>Ts,headers:()=>wi,normalizeServer:()=>Os,refresh:()=>ks,revoke:()=>io,signedOutMessage:()=>Si,ssoMessage:()=>vi});var ws="https://opencode.ai/console",gr="opencode-console-cli",xr=n({type:d("oauth"),server:e,access:e,refresh:e,expires:V,accountID:e,email:S(e),orgID:S(e),orgName:S(e)}),Si="Signed out of OpenCode Console. Run `npx @opencode/console login` to sign in again",vi=(t)=>`Sign in with SSO again to use ${t??"your OpenCode Console workspace"}`;class yr extends N("ConsoleClient.SsoRequired"){get message(){return vi(this.organization)}}class qn extends N("ConsoleClient.SignedOut"){get message(){return Si}}class br extends N("ConsoleClient.DeviceSignInFailed"){}function wi(t){return{authorization:`Bearer ${t.type==="oauth"?t.access:t.key}`,...t.type==="oauth"&&t.orgID?{"x-org-id":t.orgID}:{}}}var v=n({device_code:e,user_code:e,verification_uri:e,verification_uri_complete:e,expires_in:V,interval:V}),h=n({access_token:e,refresh_token:e,expires_in:V,org_id:S(Ze(e))}),m=n({error:e}),R=n({id:e,email:e}),M=n({id:e,name:e}),T=n({_tag:d("SsoRequired"),connectionId:S(e)}),b=n({_tag:d("Unauthorized")}),O=x(e,j),B={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=D("ConsoleClient.authorize")(function*(t){let o=yield*_e,r=yield*p(`${t}/auth/device/code`,{client_id:gr,supports_org_scope:!0}).pipe(l(hn),l(et(v))),s=new URL(t).origin,i=URL.parse(r.verification_uri_complete,`${t}/`);if(!i||i.origin!==s||URL.parse(r.verification_uri,`${t}/`)?.origin!==s)return yield*new br({message:`${t} 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:f(t,r.device_code,ve(r.interval)).pipe(Ae(_e,o))}}),ks=D("ConsoleClient.refresh")(function*(t){let o=yield*p(`${t.server}/auth/device/token`,{grant_type:"refresh_token",refresh_token:t.refresh,client_id:gr});if(o.status===400){let c=yield*et(m)(o).pipe(wo);if(U(c)&&c.value.error==="invalid_grant")return yield*new qn}let r=yield*hn(o).pipe(l(et(h))),s=yield*vt,i=r.org_id??t.orgID;return xr.make({...t,access:r.access_token,refresh:r.refresh_token,expires:s+r.expires_in*1000,...i===void 0?{}:{orgID:i}})}),io=D("ConsoleClient.revoke")(function*(t){let o=yield*p(`${t.server}/auth/oauth/revoke`,{token:t.refresh,token_type_hint:"refresh_token",client_id:gr}).pipe(Pr(ve(5)));yield*hn(o)}),Cs=D("ConsoleClient.fetchConfig")(function*(t){return yield*a(t,"/api/v2/config",O)}),Ot=D("ConsoleClient.fetchModels")(function*(t){return yield*a(t,"/api/v1/models",H)}),ao="/api/v2/codex/models",As=D("ConsoleClient.fetchCodexModels")(function*(t){return yield*a(t,ao,I)}),Is=D("ConsoleClient.fetchSkill")(function*(t,o){return yield*a(t,`/api/v2/library/skills/${encodeURIComponent(o)}?format=v2`,E)}),Ts=D("ConsoleClient.fetchSkillBlob")(function*(t,o,r){return yield*C(t,`/api/v2/library/skills/${encodeURIComponent(o)}/blobs/${encodeURIComponent(r)}`,(s)=>s.arrayBuffer.pipe(g((i)=>new Uint8Array(i))))}),H=x(e,n({name:S(e),models:x(e,x(e,j))})),I=n({models:u(n({slug:e,display_name:S(e)}))}),E=n({slug:e,version:e,files:u(w([n({kind:d("text"),path:e,content:e}),n({kind:d("blob"),path:e,sha256:e})]))});function a(t,o,r){return C(t,o,et(r))}function C(t,o,r){return l(_e,(s)=>Ti(s).execute(Ps(`${t.server}${o}`).pipe(Sr,mn(wi(t)))).pipe(l((i)=>G(function*(){if(i.status===401){let c=yield*et(b)(i).pipe(wo);if(U(c))return yield*new qn}if(i.status===403){let c=yield*et(T)(i).pipe(wo);if(U(c))return yield*new yr({organization:t.type==="oauth"?t.orgName:void 0,url:A(t.server,c.value.connectionId)})}return yield*r(yield*hn(i))})),Vs,Pr(ve(10))))}function Os(t){let o=URL.parse(t);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 A(t,o){let r=encodeURIComponent(`${new URL(t).pathname.replace(/\/+$/,"")}/`);if(!o)return`${t}/login?next=${r}`;return`${t}/auth/sso/${encodeURIComponent(o)}/start?redirectTo=${r}`}function f(t,o,r){return G(function*(){yield*Lt(r);let s=yield*p(`${t}/auth/device/token`,{grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:o,client_id:gr}),i=yield*et(w([h,m]))(s);if("access_token"in i)return yield*J(t,i);if(i.error==="authorization_pending")return yield*f(t,o,r);if(i.error==="slow_down")return yield*f(t,o,xo(r,ve(5)));return yield*new br({message:B[i.error]??`The Console refused the sign-in (${i.error})`})})}var J=fe(function*(t,o){let[r,s]=yield*Dt([y(`${t}/api/user`,o.access_token,R),y(`${t}/api/orgs`,o.access_token,u(M))],{concurrency:2}),i=o.org_id==null?void 0:s.find((_)=>_.id===o.org_id);if(o.org_id!=null&&!i)return yield*new br({message:`The workspace ${o.org_id} wasn't found after signing in`});let c=yield*vt;return xr.make({type:"oauth",server:t,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 y(t,o,r){return l(_e,(s)=>Ai(s).execute(Ps(t).pipe(Sr,ki(o)))).pipe(l(et(r)))}function p(t,o){return l(_e,(r)=>r.execute(Ei(t).pipe(Sr,Ci(o)))).pipe(Ae(uo,{redirect:"manual"}))}
2
+ export{ws,gr,xr,Si,vi,yr,qn,br,wi,Es,ks,io,Cs,Ot,ao,As,Is,Ts,Os,_s};
@@ -0,0 +1 @@
1
+ import{co,lo,Rs,Oi}from"./chunk-gvywgb0d.js";export{Oi as FetchHttpClient,Rs as HttpClient,co as HttpClientRequest,lo as HttpClientResponse};
@@ -0,0 +1 @@
1
+ import{ar,cs,no,ls}from"./chunk-rx6cjbq2.js";import"./chunk-px1nqkzb.js";import"./chunk-gvywgb0d.js";import"./chunk-wd4mfvqy.js";import"./chunk-dnepb5ke.js";export{ls as PolicyEvaluator,ar as check,no as couldMatch,cs as statements};
@@ -0,0 +1,2 @@
1
+ import{mn,_e,Ii}from"./chunk-gvywgb0d.js";import{yr,qn,Cs}from"./chunk-0trayd9n.js";import{ke}from"./chunk-wd4mfvqy.js";import{Ee,ye,jn,Be}from"./chunk-tx5wws16.js";import{gs,xs,ys,mr}from"./chunk-ktx666b5.js";import{k,P,se,vt,r,I,l,vo,g,D}from"./chunk-gxedprvk.js";var fs={};k(fs,{WorkspaceSync:()=>fs,current:()=>$e,identify:()=>us,sync:()=>ps,userAgent:()=>di});function us(e){return se(_e,g(_e,(o)=>Ii(o,mn({"user-agent":di(e),"x-opencode-plugin":`opencode-console/${e.version}`}))))}function di(e){return[e.harness?.replace(/[\r\n]/g,"").trim(),`opencode-console/${e.version}`].filter(Boolean).join(" ")}var ps=D("WorkspaceSync.sync")(function*(e,o={}){let n=Ee(e);if(!n)return yield*ke(e,I(()=>ys(e))),{snapshot:void 0};let s=yield*vt,i=ye(n),c=$e(e,i);if(c&&!o.force&&!mr(c,s))return{snapshot:c};let t=yield*Be(e).pipe(l((a)=>a?Cs(a).pipe(g((p)=>({credential:a,config:p}))):r(void 0)),vo);if(P(t)){if(!t.success)return{snapshot:void 0};return{snapshot:yield*u(e,i,{owner:i,organization:jn(t.success.credential),fetched:s,config:t.success.config})}}let f=m(t.failure);if(!f)return{snapshot:c,error:t.failure};let d=c??{owner:i,organization:jn(n)};return{snapshot:yield*u(e,i,{...d,fetched:s,status:f}),error:t.failure}});function $e(e,o){let n=gs(e);return n?.owner===o?n:void 0}function u(e,o,n){return ke(e,I(()=>{let s=Ee(e);if(!s||ye(s)!==o)return;return xs(e,n),n}))}function m(e){if(e instanceof yr)return{message:e.message,url:e.url};if(e instanceof qn)return{message:e.message};return}
2
+ export{us,di,ps,$e,fs};