@oracle-agent/oracle 0.21.0 → 0.22.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.
@@ -1,4 +1,4 @@
1
- import y from"node:fs";import Y from"node:path";var b="signing: not installed (optional) \u2014 npm i -g @oracle-agent/operator";import L from"node:fs";import h from"node:path";import x from"node:fs";import P from"node:os";import d from"node:path";import{fileURLToPath as w}from"node:url";var I=d.dirname(w(import.meta.url)),q=d.resolve(I,"../..");function S(){return process.env.ORACLE_FAKE_HOME||P.homedir()}function $(){return process.env.ORACLE_PUBLIC_DESKTOP==="1"}function R(){return $()?process.env.ORACLE_CONFIG_DIR||d.join(S(),".config","oracle"):d.join(S(),".config","oracle")}function D(){return d.join(R(),"desk.json")}function N(){return d.join(R(),"env")}function f({force:e=!1}={}){if(f._done&&!e)return f._result||null;f._done=!0;let r={},t=(o,n)=>{if(n==null)return;let c=String(n).trim();c&&(process.env[o]!=null&&String(process.env[o]).trim()!==""||(process.env[o]=c,r[o]=c))};try{let o=N();if(x.existsSync(o))for(let n of x.readFileSync(o,"utf8").split(/\r?\n/)){let c=n.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/);if(!c||c[2].startsWith("#"))continue;let a=c[2];(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'"))&&(a=a.slice(1,-1)),t(c[1],a)}}catch{}try{let o=D();if(x.existsSync(o)){let n=JSON.parse(x.readFileSync(o,"utf8"));n&&typeof n=="object"&&(t("ORACLE_DESK_URL",n.deskUrl||n.dataUrl||n.url),t("ORACLE_DATA_URL",n.dataUrl||n.deskUrl||n.url),t("ORACLE_API_URL",n.apiUrl||n.dataUrl||n.deskUrl),t("ORACLE_PUBLIC_URL",n.publicUrl||n.deskUrl||n.dataUrl),t("ORACLE_EXEC_URL",n.execUrl),t("MAD_DESK_URL",n.deskUrl||n.dataUrl))}}catch{}let s=process.env.ORACLE_DESK_URL||process.env.ORACLE_DATA_URL||"";return s&&(t("ORACLE_DESK_URL",s),t("ORACLE_DATA_URL",s),t("ORACLE_API_URL",s),t("ORACLE_PUBLIC_URL",s),t("MAD_DESK_URL",s)),f._result=Object.keys(r).length?r:null,f._result}try{f()}catch{}var H="0.19.0",se=`hermes-agent==${H}`;var C="0.12.1",ie=Object.freeze({posix:Object.freeze({url:`https://github.com/astral-sh/uv/releases/download/${C}/uv-installer.sh`,sha256:"d3f5412d38c99f9d024901843bf98206f0d2c6dbe64df40d0b740e2751ca62c1"}),windows:Object.freeze({url:`https://github.com/astral-sh/uv/releases/download/${C}/uv-installer.ps1`,sha256:"b9ec035151bfbb11d616dbd69886498d885551489eddf095ea3c0ad59f640eb0"})});function M(){return h.join(R(),"runtime")}function B(){return h.join(M(),"venv")}function V(e){let r=process.platform==="win32"?"Scripts":"bin",t=process.platform==="win32"?`${e}.exe`:e;return h.join(B(),r,t)}function F(){return V("hermes")}function K(e){let r=process.platform==="win32"&&!h.extname(e)?["",".exe",".cmd",".bat"]:[""];for(let t of(process.env.PATH||"").split(h.delimiter))if(t)for(let s of r){let o=h.join(t,`${e}${s}`);try{if(L.existsSync(o))return o}catch{}}return null}function T(){if(process.env.ORACLE_HERMES_BIN)return{ok:!0,bin:process.env.ORACLE_HERMES_BIN,source:"env"};let e=K("hermes");if(e)return{ok:!0,bin:e,source:"path"};let r=F();return L.existsSync(r)?{ok:!0,bin:r,source:"managed"}:{ok:!1,bin:null,source:null}}function U(){let[e,r]=process.versions.node.split(".").map(Number);return e>20||e===20&&r>=19}function G(e){if(!y.existsSync(e))return{};let r={};for(let t of y.readFileSync(e,"utf8").split(/\r?\n/)){let s=t.match(/^([A-Z0-9_]+)=(.*)$/);s&&(r[s[1]]=s[2])}return r}async function W(e){let r=e.replace(/\/$/,"");for(let t of["/health","/public/health"])try{if((await fetch(r+t)).ok)return!0}catch{}return!1}var fe={name:"doctor",summary:"check read plane; checks signer too when installed",group:"read",usage:"oracle doctor [--json]",async run(e){let r=e.argv.includes("--json"),t=[],s=!1,o=(i,u,E,p=null)=>{t.push({id:i,status:u,detail:E,fix:p}),u==="fail"&&(s=!0)};o("node",U()?"ok":"fail",`node ${process.versions.node}`,U()?null:"install node >= 20.19");let n=e.paths.oracleExecEnvPath(),c=G(n),a=process.env.ORACLE_ROUTE_ATTESTATION_SECRET||process.env.MAD_ROUTE_ATTESTATION_SECRET||process.env.ORACLE_ATTESTATION_SECRET||process.env.ORACLE_STAMP_HMAC_SECRET||c.ORACLE_ROUTE_ATTESTATION_SECRET||c.MAD_ROUTE_ATTESTATION_SECRET||c.ORACLE_ATTESTATION_SECRET||c.ORACLE_STAMP_HMAC_SECRET;o("attestation_secret",a?"ok":"warn",a?"present":"missing",a?null:"run oracle init --apply (writes ~/.config/oracle/exec.env)");let v=process.env.ORACLE_DATA_URL||"http://127.0.0.1:8787",g=await W(v),A=e.paths.loadDeskRouting&&(process.env.ORACLE_DESK_URL||process.env.ORACLE_PUBLIC_URL)?`desk ${process.env.ORACLE_DESK_URL||process.env.ORACLE_PUBLIC_URL}`:null;o("data_server",g?"ok":"warn",g?`reachable ${v}${A?` (${A})`:""}`:`down ${v}`,g?null:v.includes("127.0.0.1")||v.includes("localhost")?"oracle data serve OR set ~/.config/oracle/desk.json \u2192 Arch :8799":"check Arch desk is up (curl $ORACLE_DESK_URL/public/health)");let m=T();o("agent_runtime",m.ok?"ok":"warn",m.ok?`present ${m.bin} (${m.source})`:"not installed",m.ok?null:"oracle bootstrap");let O=Y.join(e.paths.hermesRoot(),"profiles"),_=0;y.existsSync(O)&&(_=y.readdirSync(O,{withFileTypes:!0}).filter(i=>i.isDirectory()).length),o("hermes_lanes",_>0?"ok":"warn",_>0?`${_} profile dir(s)`:"no lane profiles found",_>0?null:"oracle init --apply");let l=e.resolveOperator(),k={installed:!1};if(l.ok){let i=e.dispatchOperator("oracle-agentic-doctor",["--json"],{stdio:"pipe"}),u={installed:!0,version:l.version,source:l.source};if(i&&typeof i=="object"&&i.stdout)try{let p=JSON.parse(i.stdout);u={installed:!0,version:l.version,source:l.source,signingReady:p.signingReady,broadcastReady:p.broadcastReady,executionReady:p.executionReady,masterKillSwitch:p.masterKillSwitch,raw:p}}catch{u.doctorParseError=!0,u.doctorExit=i.code}else typeof i=="number"&&(u.doctorExit=i);k=u;let E=u.signingReady===!0;o("signing",E?"ok":"warn",E?`operator ${l.version} ready via ${l.source}`:`operator ${l.version} installed but signing is not ready`,E?null:"oracle sign doctor --json")}let j={ok:!s,checks:t,operator:k};if(r)process.stdout.write(JSON.stringify(j,null,2)+`
1
+ import y from"node:fs";import G from"node:path";var b="signing: not installed (optional) \u2014 npm i -g @oracle-agent/operator";import L from"node:fs";import h from"node:path";import x from"node:fs";import P from"node:os";import d from"node:path";import{fileURLToPath as w}from"node:url";var I=d.dirname(w(import.meta.url)),q=d.resolve(I,"../..");function S(){return process.env.ORACLE_FAKE_HOME||P.homedir()}function $(){return process.env.ORACLE_PUBLIC_DESKTOP==="1"}function R(){return $()?process.env.ORACLE_CONFIG_DIR||d.join(S(),".config","oracle"):d.join(S(),".config","oracle")}function D(){return d.join(R(),"desk.json")}function N(){return d.join(R(),"env")}function f({force:e=!1}={}){if(f._done&&!e)return f._result||null;f._done=!0;let r={},t=(o,n)=>{if(n==null)return;let c=String(n).trim();c&&(process.env[o]!=null&&String(process.env[o]).trim()!==""||(process.env[o]=c,r[o]=c))};try{let o=N();if(x.existsSync(o))for(let n of x.readFileSync(o,"utf8").split(/\r?\n/)){let c=n.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/);if(!c||c[2].startsWith("#"))continue;let a=c[2];(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'"))&&(a=a.slice(1,-1)),t(c[1],a)}}catch{}try{let o=D();if(x.existsSync(o)){let n=JSON.parse(x.readFileSync(o,"utf8"));n&&typeof n=="object"&&(t("ORACLE_DESK_URL",n.deskUrl||n.dataUrl||n.url),t("ORACLE_DATA_URL",n.dataUrl||n.deskUrl||n.url),t("ORACLE_API_URL",n.apiUrl||n.dataUrl||n.deskUrl),t("ORACLE_PUBLIC_URL",n.publicUrl||n.deskUrl||n.dataUrl),t("ORACLE_EXEC_URL",n.execUrl),t("MAD_DESK_URL",n.deskUrl||n.dataUrl))}}catch{}let s=process.env.ORACLE_DESK_URL||process.env.ORACLE_DATA_URL||"";return s&&(t("ORACLE_DESK_URL",s),t("ORACLE_DATA_URL",s),t("ORACLE_API_URL",s),t("ORACLE_PUBLIC_URL",s),t("MAD_DESK_URL",s)),f._result=Object.keys(r).length?r:null,f._result}try{f()}catch{}var H="0.19.0",se=`hermes-agent==${H}`;var C="0.12.1",ie=Object.freeze({posix:Object.freeze({url:`https://github.com/astral-sh/uv/releases/download/${C}/uv-installer.sh`,sha256:"d3f5412d38c99f9d024901843bf98206f0d2c6dbe64df40d0b740e2751ca62c1"}),windows:Object.freeze({url:`https://github.com/astral-sh/uv/releases/download/${C}/uv-installer.ps1`,sha256:"b9ec035151bfbb11d616dbd69886498d885551489eddf095ea3c0ad59f640eb0"})});function M(){return h.join(R(),"runtime")}function B(){return h.join(M(),"venv")}function V(e){let r=process.platform==="win32"?"Scripts":"bin",t=process.platform==="win32"?`${e}.exe`:e;return h.join(B(),r,t)}function F(){return V("hermes")}function K(e){let r=process.platform==="win32"&&!h.extname(e)?["",".exe",".cmd",".bat"]:[""];for(let t of(process.env.PATH||"").split(h.delimiter))if(t)for(let s of r){let o=h.join(t,`${e}${s}`);try{if(L.existsSync(o))return o}catch{}}return null}function T(){if(process.env.ORACLE_HERMES_BIN)return{ok:!0,bin:process.env.ORACLE_HERMES_BIN,source:"env"};let e=K("hermes");if(e)return{ok:!0,bin:e,source:"path"};let r=F();return L.existsSync(r)?{ok:!0,bin:r,source:"managed"}:{ok:!1,bin:null,source:null}}function U(){let[e,r]=process.versions.node.split(".").map(Number);return e>20||e===20&&r>=19}function Y(e){if(!y.existsSync(e))return{};let r={};for(let t of y.readFileSync(e,"utf8").split(/\r?\n/)){let s=t.match(/^([A-Z0-9_]+)=(.*)$/);s&&(r[s[1]]=s[2])}return r}async function W(e){let r=e.replace(/\/$/,"");for(let t of["/health","/public/health"])try{if((await fetch(r+t)).ok)return!0}catch{}return!1}var fe={name:"doctor",summary:"check read plane; checks signer too when installed",group:"read",usage:"oracle doctor [--json]",async run(e){let r=e.argv.includes("--json"),t=[],s=!1,o=(i,u,E,p=null)=>{t.push({id:i,status:u,detail:E,fix:p}),u==="fail"&&(s=!0)};o("node",U()?"ok":"fail",`node ${process.versions.node}`,U()?null:"install node >= 20.19");let n=e.paths.oracleExecEnvPath(),c=Y(n),a=process.env.ORACLE_ROUTE_ATTESTATION_SECRET||process.env.MAD_ROUTE_ATTESTATION_SECRET||process.env.ORACLE_ATTESTATION_SECRET||process.env.ORACLE_STAMP_HMAC_SECRET||c.ORACLE_ROUTE_ATTESTATION_SECRET||c.MAD_ROUTE_ATTESTATION_SECRET||c.ORACLE_ATTESTATION_SECRET||c.ORACLE_STAMP_HMAC_SECRET;o("attestation_secret",a?"ok":"warn",a?"present":"missing",a?null:"run oracle init --apply (writes ~/.config/oracle/exec.env)");let v=process.env.ORACLE_DATA_URL||"http://127.0.0.1:8787",g=await W(v),A=e.paths.loadDeskRouting&&(process.env.ORACLE_DESK_URL||process.env.ORACLE_PUBLIC_URL)?`desk ${process.env.ORACLE_DESK_URL||process.env.ORACLE_PUBLIC_URL}`:null;o("data_server",g?"ok":"warn",g?`reachable ${v}${A?` (${A})`:""}`:`down ${v}`,g?null:v.includes("127.0.0.1")||v.includes("localhost")?"oracle data serve OR set ~/.config/oracle/desk.json \u2192 Arch :8799":"check Arch desk is up (curl $ORACLE_DESK_URL/public/health)");let m=T();o("agent_runtime",m.ok?"ok":"warn",m.ok?`present ${m.bin} (${m.source})`:"not installed",m.ok?null:"oracle bootstrap");let O=G.join(e.paths.hermesRoot(),"profiles"),_=0;y.existsSync(O)&&(_=y.readdirSync(O,{withFileTypes:!0}).filter(i=>i.isDirectory()).length),o("hermes_lanes",_>0?"ok":"warn",_>0?`${_} profile dir(s)`:"no lane profiles found",_>0?null:"oracle init --apply");let l=e.resolveOperator(),k={installed:!1};if(l.ok){let i=e.dispatchOperator("oracle-agentic-doctor",["--json"],{stdio:"pipe"}),u={installed:!0,version:l.version,source:l.source};if(i&&typeof i=="object"&&i.stdout)try{let p=JSON.parse(i.stdout);u={installed:!0,version:l.version,source:l.source,signingReady:p.signingReady,broadcastReady:p.broadcastReady,executionReady:p.executionReady,masterKillSwitch:p.masterKillSwitch,raw:p}}catch{u.doctorParseError=!0,u.doctorExit=i.code}else typeof i=="number"&&(u.doctorExit=i);k=u;let E=u.signingReady===!0;o("signing",E?"ok":"warn",E?`operator ${l.version} ready via ${l.source}`:`operator ${l.version} installed but signing is not ready`,E?null:"oracle sign doctor --json")}let j={ok:!s,checks:t,operator:k};if(r)process.stdout.write(JSON.stringify(j,null,2)+`
2
2
  `);else{for(let i of t)process.stdout.write(`${i.status.toUpperCase().padEnd(4)} ${i.id}: ${i.detail}
3
3
  `),i.fix&&process.stdout.write(` fix: ${i.fix}
4
4
  `);l.ok||process.stdout.write(`INFO ${b}
@@ -1,9 +1,9 @@
1
- import u from"node:fs";import c from"node:path";var g=Object.freeze({openrouter:{key:"OPENROUTER_API_KEY",baseUrl:"https://openrouter.ai/api/v1",model:"openrouter/auto"},openai:{key:"OPENAI_API_KEY",baseUrl:"https://api.openai.com/v1",model:"gpt-4.1-mini"},xai:{key:"XAI_API_KEY",baseUrl:"https://api.x.ai/v1",model:"grok-4-latest"},deepseek:{key:"DEEPSEEK_API_KEY",baseUrl:"https://api.deepseek.com/v1",model:"deepseek-chat"},gemini:{key:"GEMINI_API_KEY",alternateKey:"GOOGLE_API_KEY",baseUrl:"https://generativelanguage.googleapis.com/v1beta/openai",model:"gemini-2.5-flash"}}),O=Object.freeze({"anthropic-oauth":{key:"ANTHROPIC_API_KEY",baseUrl:"https://api.anthropic.com/v1",model:"claude-sonnet-4-20250514",protocol:"anthropic-messages"},"openai-codex":{key:"OPENAI_API_KEY",baseUrl:"https://chatgpt.com/backend-api/codex",model:"gpt-5.4",protocol:"responses"},"xai-oauth":{key:"XAI_API_KEY",baseUrl:"https://api.x.ai/v1",model:"grok-4-latest",protocol:"responses"}});var d=Object.freeze([{name:"oracle",bin:"oracle",label:"Oracle Native (default)",kind:"oracle"},{name:"hermes",bin:"hermes",label:"Hermes Agent",kind:"hermes"},{name:"opencode",bin:"opencode",label:"OpenCode",kind:"mcp"},{name:"claude",bin:"claude",label:"Claude Code",kind:"mcp"},{name:"codex",bin:"codex",label:"OpenAI Codex CLI",kind:"mcp"},{name:"cursor",bin:"cursor",label:"Cursor IDE",kind:"mcp"},{name:"windsurf",bin:"windsurf",label:"Windsurf",kind:"mcp"},{name:"aider",bin:"aider",label:"Aider",kind:"mcp"},{name:"continue",bin:"continue",label:"Continue",kind:"mcp"}]);function p(n){for(let o of(process.env.PATH||"").split(c.delimiter)){let e=c.join(o,n);try{if(u.existsSync(e))return e}catch{}}return null}function l(){let n=[];for(let o of d){if(o.name==="oracle"){n.push({...o,path:process.argv[1]||"oracle"});continue}let e=p(o.bin);e&&n.push({...o,path:e})}return n}var m=Object.freeze({claude:"claude-code",codex:"codex",cursor:"cursor",windsurf:"vscode",continue:"vscode",opencode:"generic",aider:"generic"});function h(n){if(n.kind==="oracle")return{...n,direction:"native",integrate:null,backendEnv:null,note:"Oracle's own agent loop. This is the default and needs no wiring."};let e=`oracle mcp install ${m[n.name]||"generic"}`;return n.kind==="hermes"?{...n,direction:"both",integrate:e,backendEnv:`ORACLE_CHAT_BACKEND=${n.name}`,note:"Legacy: this hands Oracle's native model loop to Hermes. Prefer the inbound MCP wiring above."}:{...n,direction:"inbound",integrate:e,backendEnv:null,note:"Calls Oracle as an MCP server. Oracle's native model loop stays in charge."}}function f(n){let o=n.map(h),e=o.find(r=>r.direction==="native"),a=o.filter(r=>r.direction==="inbound"||r.direction==="both"),i=o.filter(r=>r.backendEnv),t=[];if(t.push(""),t.push(`Oracle native chat: default${e?` (${e.path})`:""}`),t.push("Oracle runs its own agent loop, memory, skills, and scheduler."),t.push(""),t.push("Integrate Oracle INTO these clients (recommended \u2014 native loop stays):"),a.length===0)t.push(" (none detected \u2014 Oracle runs standalone, nothing else required)");else for(let r of a)t.push(` ${r.label.padEnd(22)} ${r.path}`),t.push(` ${" ".repeat(22)} ${r.integrate}`);if(t.push(""),i.length>0){t.push("Delegate Oracle's model loop to another harness (legacy, not recommended):");for(let r of i)t.push(` ${r.label.padEnd(22)} ${r.backendEnv}`),t.push(` ${" ".repeat(22)} ${r.note}`);t.push("")}return t.push("Detection is capability discovery only. It never changes the backend."),t.join(`
2
- `)}function s(){return["oracle harness \u2014 detect installed agent harnesses",""," oracle harness detect scan PATH for Agent Plugins-compatible clients","","Two directions, do not confuse them:"," inbound \u2014 the client calls Oracle as an MCP server (oracle mcp install <target>)."," Oracle's native model loop stays in charge. This is integration."," outbound \u2014 Oracle hands its model loop to that harness (ORACLE_CHAT_BACKEND=<name>)."," This surrenders the native harness and is legacy only.","","Detected: opencode, claude, codex, cursor, windsurf, aider, continue, hermes"].join(`
3
- `)}var C={name:"harness",summary:"detect installed agent harnesses",usage:s,async run(n,o){let e=n[0];if(e==="help"||e==="--help"||e==="-h")return process.stdout.write(s()+`
1
+ import u from"node:fs";import c from"node:path";var C=Object.freeze({openrouter:{key:"OPENROUTER_API_KEY",baseUrl:"https://openrouter.ai/api/v1",model:"openrouter/auto"},openai:{key:"OPENAI_API_KEY",baseUrl:"https://api.openai.com/v1",model:"gpt-4.1-mini"},anthropic:{key:"ANTHROPIC_API_KEY",baseUrl:"https://api.anthropic.com/v1",model:"claude-sonnet-4-6",protocol:"anthropic-messages"},xai:{key:"XAI_API_KEY",baseUrl:"https://api.x.ai/v1",model:"grok-4.5"},deepseek:{key:"DEEPSEEK_API_KEY",baseUrl:"https://api.deepseek.com/v1",model:"deepseek-chat"},gemini:{key:"GEMINI_API_KEY",alternateKey:"GOOGLE_API_KEY",baseUrl:"https://generativelanguage.googleapis.com/v1beta/openai",model:"gemini-2.5-flash"},kimi:{key:"MOONSHOT_API_KEY",alternateKey:"KIMI_API_KEY",baseUrl:"https://api.moonshot.ai/v1",model:"kimi-k3",protocol:"openai-chat"},mistral:{key:"MISTRAL_API_KEY",baseUrl:"https://api.mistral.ai/v1",model:"mistral-large-latest",protocol:"openai-chat"}}),P=Object.freeze({"anthropic-oauth":{key:"ANTHROPIC_API_KEY",baseUrl:"https://api.anthropic.com/v1",model:"claude-sonnet-4-20250514",protocol:"anthropic-messages"},"openai-codex":{key:"OPENAI_API_KEY",baseUrl:"https://chatgpt.com/backend-api/codex",model:"gpt-5.4",protocol:"responses"},"xai-oauth":{key:"XAI_API_KEY",baseUrl:"https://api.x.ai/v1",model:"grok-4-latest",protocol:"responses"}});var d=Object.freeze([{name:"oracle",bin:"oracle",label:"Oracle Native (default)",kind:"oracle"},{name:"hermes",bin:"hermes",label:"Hermes Agent",kind:"hermes"},{name:"opencode",bin:"opencode",label:"OpenCode",kind:"mcp"},{name:"claude",bin:"claude",label:"Claude Code",kind:"mcp"},{name:"codex",bin:"codex",label:"OpenAI Codex CLI",kind:"mcp"},{name:"cursor",bin:"cursor",label:"Cursor IDE",kind:"mcp"},{name:"windsurf",bin:"windsurf",label:"Windsurf",kind:"mcp"},{name:"aider",bin:"aider",label:"Aider",kind:"mcp"},{name:"continue",bin:"continue",label:"Continue",kind:"mcp"}]);function p(n){for(let o of(process.env.PATH||"").split(c.delimiter)){let e=c.join(o,n);try{if(u.existsSync(e))return e}catch{}}return null}function l(){let n=[];for(let o of d){if(o.name==="oracle"){n.push({...o,path:process.argv[1]||"oracle"});continue}let e=p(o.bin);e&&n.push({...o,path:e})}return n}var m=Object.freeze({claude:"claude-code",codex:"codex",cursor:"cursor",windsurf:"vscode",continue:"vscode",opencode:"generic",aider:"generic"});function h(n){if(n.kind==="oracle")return{...n,direction:"native",integrate:null,backendEnv:null,note:"Oracle's own agent loop. This is the default and needs no wiring."};let e=`oracle mcp install ${m[n.name]||"generic"}`;return n.kind==="hermes"?{...n,direction:"both",integrate:e,backendEnv:`ORACLE_CHAT_BACKEND=${n.name}`,note:"Legacy: this hands Oracle's native model loop to Hermes. Prefer the inbound MCP wiring above."}:{...n,direction:"inbound",integrate:e,backendEnv:null,note:"Calls Oracle as an MCP server. Oracle's native model loop stays in charge."}}function f(n){let o=n.map(h),e=o.find(r=>r.direction==="native"),i=o.filter(r=>r.direction==="inbound"||r.direction==="both"),s=o.filter(r=>r.backendEnv),t=[];if(t.push(""),t.push(`Oracle native chat: default${e?` (${e.path})`:""}`),t.push("Oracle runs its own agent loop, memory, skills, and scheduler."),t.push(""),t.push("Integrate Oracle INTO these clients (recommended \u2014 native loop stays):"),i.length===0)t.push(" (none detected \u2014 Oracle runs standalone, nothing else required)");else for(let r of i)t.push(` ${r.label.padEnd(22)} ${r.path}`),t.push(` ${" ".repeat(22)} ${r.integrate}`);if(t.push(""),s.length>0){t.push("Delegate Oracle's model loop to another harness (legacy, not recommended):");for(let r of s)t.push(` ${r.label.padEnd(22)} ${r.backendEnv}`),t.push(` ${" ".repeat(22)} ${r.note}`);t.push("")}return t.push("Detection is capability discovery only. It never changes the backend."),t.join(`
2
+ `)}function a(){return["oracle harness \u2014 detect installed agent harnesses",""," oracle harness detect scan PATH for Agent Plugins-compatible clients","","Two directions, do not confuse them:"," inbound \u2014 the client calls Oracle as an MCP server (oracle mcp install <target>)."," Oracle's native model loop stays in charge. This is integration."," outbound \u2014 Oracle hands its model loop to that harness (ORACLE_CHAT_BACKEND=<name>)."," This surrenders the native harness and is legacy only.","","Detected: opencode, claude, codex, cursor, windsurf, aider, continue, hermes"].join(`
3
+ `)}var y={name:"harness",summary:"detect installed agent harnesses",usage:a,async run(n,o){let e=n[0];if(e==="help"||e==="--help"||e==="-h")return process.stdout.write(a()+`
4
4
  `),0;if(e&&e!=="detect"&&e!=="list")return process.stderr.write(`oracle harness: unknown subcommand '${e}'
5
- `),process.stderr.write(s()+`
6
- `),1;let a=l();return a.length===0?(process.stderr.write(`No agent harnesses detected on PATH.
5
+ `),process.stderr.write(a()+`
6
+ `),1;let i=l();return i.length===0?(process.stderr.write(`No agent harnesses detected on PATH.
7
7
  `),process.stderr.write(`Oracle runs natively \u2014 no external agent required.
8
- `),0):(process.stdout.write(f(a)+`
9
- `),0)}};export{h as classifyHarness,C as default,f as renderHarnessReport};
8
+ `),0):(process.stdout.write(f(i)+`
9
+ `),0)}};export{h as classifyHarness,y as default,f as renderHarnessReport};
@@ -1,3 +1,3 @@
1
- import{spawnSync as i}from"node:child_process";var n=["oracle data serve # loopback read/prepare plane on 127.0.0.1:8787","oracle doctor # verify","oracle chat # premium oracle chat surface","oracle chain list # pick hyperliquid/base/solana/...","oracle setup # telegram/discord/slack messaging","oracle mcp install claude-code","# optional, explicit second step \u2014 signing stays a separate local package:","npm i -g @oracle-agent/operator","oracle sign init"];function o(){return["","Next:",...n.map(t=>" "+t),""].join(`
2
- `)}var d={name:"init",summary:"install agent lanes + read plane (dry-run by default)",group:"read",usage:"oracle init [--apply --force --only <lane> --json --yes]",async run(t){let r=[...t.argv];r.includes("--yes")&&!r.includes("--apply")&&r.push("--apply");let s=t.bin("oracle-init.mjs"),e=i(process.execPath,[s,...r],{encoding:"utf8",env:process.env});if(e.error)return process.stderr.write(`oracle: failed to spawn oracle-init: ${e.error.message}
3
- `),1;e.stdout&&process.stdout.write(e.stdout),e.stderr&&process.stderr.write(e.stderr);let a=typeof e.status=="number"?e.status:1;return a===0&&r.includes("--apply")&&!r.includes("--json")&&process.stdout.write(o()),a}};export{d as default};
1
+ import{spawnSync as i}from"node:child_process";var n=["oracle data serve # loopback read/prepare plane on 127.0.0.1:8787","oracle doctor # verify","oracle setup model # choose Claude, Codex, or Grok subscription OAuth","oracle chat # premium oracle chat surface","oracle chain list # pick hyperliquid/base/solana/...","oracle setup # telegram/discord/slack messaging","oracle mcp install claude-code","# optional, explicit second step \u2014 signing stays a separate local package:","npm i -g @oracle-agent/operator","oracle sign init"];function a(){return["","Next:",...n.map(o=>" "+o),""].join(`
2
+ `)}var d={name:"init",summary:"install agent lanes + read plane (dry-run by default)",group:"read",usage:"oracle init [--apply --force --only <lane> --json --yes]",async run(o){let r=[...o.argv];r.includes("--yes")&&!r.includes("--apply")&&r.push("--apply");let s=o.bin("oracle-init.mjs"),e=i(process.execPath,[s,...r],{encoding:"utf8",env:process.env});if(e.error)return process.stderr.write(`oracle: failed to spawn oracle-init: ${e.error.message}
3
+ `),1;e.stdout&&process.stdout.write(e.stdout),e.stderr&&process.stderr.write(e.stderr);let t=typeof e.status=="number"?e.status:1;return t===0&&r.includes("--apply")&&!r.includes("--json")&&process.stdout.write(a()),t}};export{d as default};
@@ -1,60 +1,60 @@
1
- import{parseArgs as Fe}from"node:util";import Y from"node:path";import{fileURLToPath as fe}from"node:url";var de=Y.dirname(fe(import.meta.url)),We=Y.resolve(de,"../.."),Be=Object.freeze(["oracle-vault","oracle-credential","oracle-signer","oracle-runner","oracle-agentic-init","oracle-agentic-doctor","oracle-control-mcp","oracle-operator-caps"]),Ge=Object.freeze(["vault","credential","signer","runner","sign"]),q=`oracle: signing is unavailable in the public package.
1
+ import{parseArgs as Ft}from"node:util";import q from"node:path";import{fileURLToPath as ft}from"node:url";var dt=q.dirname(ft(import.meta.url)),Wt=q.resolve(dt,"../.."),Gt=Object.freeze(["oracle-vault","oracle-credential","oracle-signer","oracle-runner","oracle-agentic-init","oracle-agentic-doctor","oracle-control-mcp","oracle-operator-caps"]),Bt=Object.freeze(["vault","credential","signer","runner","sign"]),K=`oracle: signing is unavailable in the public package.
2
2
 
3
3
  The public 'oracle' package is prepare-only and never handles keys.
4
4
  Owner-operated signing is private infrastructure and has no public npm install.
5
5
  Review and sign prepared artifacts in your own wallet instead.
6
6
 
7
7
  Nothing about your read/research/prepare setup is affected.
8
- `;function _(e=process.stderr){e.write(q),q.endsWith(`
9
- `)||e.write(`
10
- `)}import{spawnSync as Q}from"node:child_process";import ee from"node:path";import u from"node:fs";import j from"node:path";import ye from"node:os";import E from"node:fs";import me from"node:os";import h from"node:path";import{fileURLToPath as ge}from"node:url";var ke=h.dirname(ge(import.meta.url)),O=h.resolve(ke,"../..");function V(){return process.env.ORACLE_FAKE_HOME||me.homedir()}function he(){return process.env.ORACLE_PUBLIC_DESKTOP==="1"}function z(){return he()?process.env.ORACLE_CONFIG_DIR||h.join(V(),".config","oracle"):h.join(V(),".config","oracle")}function Se(){return h.join(z(),"desk.json")}function be(){return h.join(z(),"env")}function x({force:e=!1}={}){if(x._done&&!e)return x._result||null;x._done=!0;let r={},t=(n,o)=>{if(o==null)return;let s=String(o).trim();s&&(process.env[n]!=null&&String(process.env[n]).trim()!==""||(process.env[n]=s,r[n]=s))};try{let n=be();if(E.existsSync(n))for(let o of E.readFileSync(n,"utf8").split(/\r?\n/)){let s=o.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/);if(!s||s[2].startsWith("#"))continue;let c=s[2];(c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),t(s[1],c)}}catch{}try{let n=Se();if(E.existsSync(n)){let o=JSON.parse(E.readFileSync(n,"utf8"));o&&typeof o=="object"&&(t("ORACLE_DESK_URL",o.deskUrl||o.dataUrl||o.url),t("ORACLE_DATA_URL",o.dataUrl||o.deskUrl||o.url),t("ORACLE_API_URL",o.apiUrl||o.dataUrl||o.deskUrl),t("ORACLE_PUBLIC_URL",o.publicUrl||o.deskUrl||o.dataUrl),t("ORACLE_EXEC_URL",o.execUrl),t("MAD_DESK_URL",o.deskUrl||o.dataUrl))}}catch{}let i=process.env.ORACLE_DESK_URL||process.env.ORACLE_DATA_URL||"";return i&&(t("ORACLE_DESK_URL",i),t("ORACLE_DATA_URL",i),t("ORACLE_API_URL",i),t("ORACLE_PUBLIC_URL",i),t("MAD_DESK_URL",i)),x._result=Object.keys(r).length?r:null,x._result}try{x()}catch{}function P(e){let r=[h.join(O,"bin",e),h.join(O,"dist","bin",e),h.join(O,"..","bin",e)];return r.find(t=>E.existsSync(t))||r[0]}function g(){return process.env.ORACLE_FAKE_HOME||ye.homedir()}function k({oracleRoot:e=O,operator:r=null,withControl:t=!1}={}){let n={"oracle-data":{command:"node",args:[e===O?P("oracle-data-mcp.mjs"):[j.join(e,"bin","oracle-data-mcp.mjs"),j.join(e,"dist","bin","oracle-data-mcp.mjs")].find(o=>u.existsSync(o))||j.join(e,"bin","oracle-data-mcp.mjs")]}};if(t){if(!r||!r.ok)return{ok:!1,reason:"operator-missing"};let o=r.bins?.["oracle-control-mcp"]||r.controlMcp||null;if(!o)return{ok:!1,reason:"control-bin-missing"};n["oracle-control"]={command:"node",args:[o]};let s=e===O?P("oracle-exec-mcp.mjs"):[j.join(e,"bin","oracle-exec-mcp.mjs"),j.join(e,"dist","bin","oracle-exec-mcp.mjs")].find(c=>u.existsSync(c))||j.join(e,"bin","oracle-exec-mcp.mjs");u.existsSync(s)&&(n["oracle-exec"]={command:"node",args:[s]})}return{ok:!0,specs:n}}function S(e){if(!u.existsSync(e))return null;let r=`${e}.bak-oracle-${Math.floor(Date.now()/1e3)}`,t=r;for(let n=1;u.existsSync(t);n+=1)t=`${r}-${n}`;let i=Z(e,"read");try{let n=we(t);try{u.writeFileSync(n,u.readFileSync(i))}finally{u.closeSync(n)}}finally{u.closeSync(i)}return t}function $(){return u.constants.O_NOFOLLOW||0}function X(e){let r=u.lstatSync(e);if(r.isSymbolicLink()||!r.isFile())throw new Error(`refusing to use non-regular config path: ${e}`)}function Z(e,r){X(e);let t=(r==="read"?u.constants.O_RDONLY:u.constants.O_WRONLY)|$();return u.openSync(e,t)}function we(e){return u.openSync(e,u.constants.O_WRONLY|u.constants.O_CREAT|u.constants.O_EXCL|$(),384)}function Oe(e,r){u.existsSync(e)&&X(e);let t=u.openSync(e,u.constants.O_WRONLY|u.constants.O_CREAT|u.constants.O_TRUNC|$(),384);try{u.writeFileSync(t,r)}finally{u.closeSync(t)}try{u.chmodSync(e,384)}catch{}}function T(e,r=""){if(!u.existsSync(e))return r;let t=Z(e,"read");try{return u.readFileSync(t,"utf8")}finally{u.closeSync(t)}}function R(e,r){u.mkdirSync(j.dirname(e),{recursive:!0}),Oe(e,r)}function D(e,r={}){return u.existsSync(e)?JSON.parse(T(e,"{}")):structuredClone(r)}function I(e,r){R(e,JSON.stringify(r,null,2)+`
11
- `)}function b(e,r){let t=D(e,{});(!t.mcpServers||typeof t.mcpServers!="object")&&(t.mcpServers={});let i=!1;for(let[o,s]of Object.entries(r)){let c=t.mcpServers[o];c&&JSON.stringify(c)===JSON.stringify(s)||(t.mcpServers[o]=s,i=!0)}if(!i)return{status:"present",backup:null};let n=S(e);return I(e,t),{status:"written",backup:n}}function m(e,r={}){return{status:e,...r}}function je(){return ee.join(g(),".claude.json")}function ve(e){return ee.join(e||process.cwd(),".mcp.json")}function xe(e,r){let t=Q("claude",["--version"],{encoding:"utf8",timeout:1e4});if(t.error||t.status!==0)return null;let i=Q("claude",["mcp","add-json",e,JSON.stringify(r),"--scope","user"],{encoding:"utf8",timeout:3e4});return i.status!==0?{ok:!1,stderr:i.stderr||i.stdout||"failed"}:{ok:!0}}async function te({oracleRoot:e,operator:r,withControl:t=!1,project:i=!1,printOnly:n=!1,cwd:o=process.cwd()}){let s=k({oracleRoot:e,operator:r,withControl:t});if(!s.ok)return{ok:!1,code:3,reason:s.reason};if(n)return{ok:!0,print:{mcpServers:s.specs}};if(i){let a=ve(o),f=b(a,s.specs);return{ok:!0,...m(f.status,{path:a,backup:f.backup})}}let c=!1;for(let[a,f]of Object.entries(s.specs)){let p=xe(a,f);if(p&&p.ok){c=!0;continue}break}if(c)return{ok:!0,...m("written",{method:"claude-cli"})};let d=je(),l=b(d,s.specs);return{ok:!0,...m(l.status,{path:d,backup:l.backup})}}import Ce from"node:fs";import F from"node:path";function _e(){return process.platform==="darwin"?F.join(g(),"Library","Application Support","Claude","claude_desktop_config.json"):F.join(g(),".config","Claude","claude_desktop_config.json")}async function J({oracleRoot:e,operator:r,withControl:t=!1,printOnly:i=!1}){let n=k({oracleRoot:e,operator:r,withControl:t});if(!n.ok)return{ok:!1,code:3,reason:n.reason};let o=_e(),s={mcpServers:n.specs};if(i)return{ok:!0,print:s};let c=F.dirname(o);if(!Ce.existsSync(c))return{ok:!0,status:"printed (Claude Desktop not detected)",path:o,print:s};let d=b(o,n.specs);return{ok:!0,...m(d.status,{path:o,backup:d.backup})}}import re from"node:fs";import ne from"node:path";var oe="# oracle-mcp-install begin",se="# oracle-mcp-install end";function Ee(){return ne.join(g(),".codex","config.toml")}function Re(e){let r=[oe];for(let[t,i]of Object.entries(e))r.push(`[mcp_servers.${t}]`),r.push(`command = ${JSON.stringify(i.command)}`),r.push(`args = [${i.args.map(n=>JSON.stringify(n)).join(", ")}]`),r.push("");return r.push(se),r.join(`
8
+ `;function C(t=process.stderr){t.write(K),K.endsWith(`
9
+ `)||t.write(`
10
+ `)}import{spawnSync as Q}from"node:child_process";import tt from"node:path";import u from"node:fs";import R from"node:path";import yt from"node:os";import _ from"node:fs";import mt from"node:os";import h from"node:path";import{fileURLToPath as gt}from"node:url";var kt=h.dirname(gt(import.meta.url)),j=h.resolve(kt,"../..");function Y(){return process.env.ORACLE_FAKE_HOME||mt.homedir()}function ht(){return process.env.ORACLE_PUBLIC_DESKTOP==="1"}function V(){return ht()?process.env.ORACLE_CONFIG_DIR||h.join(Y(),".config","oracle"):h.join(Y(),".config","oracle")}function St(){return h.join(V(),"desk.json")}function bt(){return h.join(V(),"env")}function v({force:t=!1}={}){if(v._done&&!t)return v._result||null;v._done=!0;let r={},e=(n,o)=>{if(o==null)return;let s=String(o).trim();s&&(process.env[n]!=null&&String(process.env[n]).trim()!==""||(process.env[n]=s,r[n]=s))};try{let n=bt();if(_.existsSync(n))for(let o of _.readFileSync(n,"utf8").split(/\r?\n/)){let s=o.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/);if(!s||s[2].startsWith("#"))continue;let c=s[2];(c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),e(s[1],c)}}catch{}try{let n=St();if(_.existsSync(n)){let o=JSON.parse(_.readFileSync(n,"utf8"));o&&typeof o=="object"&&(e("ORACLE_DESK_URL",o.deskUrl||o.dataUrl||o.url),e("ORACLE_DATA_URL",o.dataUrl||o.deskUrl||o.url),e("ORACLE_API_URL",o.apiUrl||o.dataUrl||o.deskUrl),e("ORACLE_PUBLIC_URL",o.publicUrl||o.deskUrl||o.dataUrl),e("ORACLE_EXEC_URL",o.execUrl),e("MAD_DESK_URL",o.deskUrl||o.dataUrl))}}catch{}let i=process.env.ORACLE_DESK_URL||process.env.ORACLE_DATA_URL||"";return i&&(e("ORACLE_DESK_URL",i),e("ORACLE_DATA_URL",i),e("ORACLE_API_URL",i),e("ORACLE_PUBLIC_URL",i),e("MAD_DESK_URL",i)),v._result=Object.keys(r).length?r:null,v._result}try{v()}catch{}function z(t){let r=[h.join(j,"bin",t),h.join(j,"dist","bin",t),h.join(j,"..","bin",t)];return r.find(e=>_.existsSync(e))||r[0]}function g(){return process.env.ORACLE_FAKE_HOME||yt.homedir()}function k({oracleRoot:t=j,operator:r=null,withControl:e=!1}={}){let n={"oracle-data":{command:"node",args:[t===j?z("oracle-data-mcp.mjs"):[R.join(t,"bin","oracle-data-mcp.mjs"),R.join(t,"dist","bin","oracle-data-mcp.mjs")].find(o=>u.existsSync(o))||R.join(t,"bin","oracle-data-mcp.mjs")]}};if(e){if(!r||!r.ok)return{ok:!1,reason:"operator-missing"};let o=r.bins?.["oracle-control-mcp"]||r.controlMcp||null;if(!o)return{ok:!1,reason:"control-bin-missing"};n["oracle-control"]={command:"node",args:[o]}}return{ok:!0,specs:n}}function S(t){if(!u.existsSync(t))return null;let r=`${t}.bak-oracle-${Math.floor(Date.now()/1e3)}`,e=r;for(let n=1;u.existsSync(e);n+=1)e=`${r}-${n}`;let i=Z(t,"read");try{let n=wt(e);try{u.writeFileSync(n,u.readFileSync(i))}finally{u.closeSync(n)}}finally{u.closeSync(i)}return e}function P(){return u.constants.O_NOFOLLOW||0}function X(t){let r=u.lstatSync(t);if(r.isSymbolicLink()||!r.isFile())throw new Error(`refusing to use non-regular config path: ${t}`)}function Z(t,r){X(t);let e=(r==="read"?u.constants.O_RDONLY:u.constants.O_WRONLY)|P();return u.openSync(t,e)}function wt(t){return u.openSync(t,u.constants.O_WRONLY|u.constants.O_CREAT|u.constants.O_EXCL|P(),384)}function Ot(t,r){u.existsSync(t)&&X(t);let e=u.openSync(t,u.constants.O_WRONLY|u.constants.O_CREAT|u.constants.O_TRUNC|P(),384);try{u.writeFileSync(e,r)}finally{u.closeSync(e)}try{u.chmodSync(t,384)}catch{}}function $(t,r=""){if(!u.existsSync(t))return r;let e=Z(t,"read");try{return u.readFileSync(e,"utf8")}finally{u.closeSync(e)}}function E(t,r){u.mkdirSync(R.dirname(t),{recursive:!0}),Ot(t,r)}function T(t,r={}){return u.existsSync(t)?JSON.parse($(t,"{}")):structuredClone(r)}function D(t,r){E(t,JSON.stringify(r,null,2)+`
11
+ `)}function b(t,r){let e=T(t,{});(!e.mcpServers||typeof e.mcpServers!="object")&&(e.mcpServers={});let i=!1;for(let[o,s]of Object.entries(r)){let c=e.mcpServers[o];c&&JSON.stringify(c)===JSON.stringify(s)||(e.mcpServers[o]=s,i=!0)}if(!i)return{status:"present",backup:null};let n=S(t);return D(t,e),{status:"written",backup:n}}function m(t,r={}){return{status:t,...r}}function vt(){return tt.join(g(),".claude.json")}function jt(t){return tt.join(t||process.cwd(),".mcp.json")}function xt(t,r){let e=Q("claude",["--version"],{encoding:"utf8",timeout:1e4});if(e.error||e.status!==0)return null;let i=Q("claude",["mcp","add-json",t,JSON.stringify(r),"--scope","user"],{encoding:"utf8",timeout:3e4});return i.status!==0?{ok:!1,stderr:i.stderr||i.stdout||"failed"}:{ok:!0}}async function et({oracleRoot:t,operator:r,withControl:e=!1,project:i=!1,printOnly:n=!1,cwd:o=process.cwd()}){let s=k({oracleRoot:t,operator:r,withControl:e});if(!s.ok)return{ok:!1,code:3,reason:s.reason};if(n)return{ok:!0,print:{mcpServers:s.specs}};if(i){let a=jt(o),f=b(a,s.specs);return{ok:!0,...m(f.status,{path:a,backup:f.backup})}}let c=!1;for(let[a,f]of Object.entries(s.specs)){let p=xt(a,f);if(p&&p.ok){c=!0;continue}break}if(c)return{ok:!0,...m("written",{method:"claude-cli"})};let d=vt(),l=b(d,s.specs);return{ok:!0,...m(l.status,{path:d,backup:l.backup})}}import Ct from"node:fs";import I from"node:path";function _t(){return process.platform==="darwin"?I.join(g(),"Library","Application Support","Claude","claude_desktop_config.json"):I.join(g(),".config","Claude","claude_desktop_config.json")}async function F({oracleRoot:t,operator:r,withControl:e=!1,printOnly:i=!1}){let n=k({oracleRoot:t,operator:r,withControl:e});if(!n.ok)return{ok:!1,code:3,reason:n.reason};let o=_t(),s={mcpServers:n.specs};if(i)return{ok:!0,print:s};let c=I.dirname(o);if(!Ct.existsSync(c))return{ok:!0,status:"printed (Claude Desktop not detected)",path:o,print:s};let d=b(o,n.specs);return{ok:!0,...m(d.status,{path:o,backup:d.backup})}}import rt from"node:fs";import nt from"node:path";var ot="# oracle-mcp-install begin",st="# oracle-mcp-install end";function Et(){return nt.join(g(),".codex","config.toml")}function Rt(t){let r=[ot];for(let[e,i]of Object.entries(t))r.push(`[mcp_servers.${e}]`),r.push(`command = ${JSON.stringify(i.command)}`),r.push(`args = [${i.args.map(n=>JSON.stringify(n)).join(", ")}]`),r.push("");return r.push(st),r.join(`
12
12
  `)+`
13
- `}function Ae(e){return e.replace(new RegExp(`${oe}[\\s\\S]*?${se}\\n?`,"g"),"")}async function M({oracleRoot:e,operator:r,withControl:t=!1,printOnly:i=!1}){let n=k({oracleRoot:e,operator:r,withControl:t});if(!n.ok)return{ok:!1,code:3,reason:n.reason};let o=Re(n.specs),s=Ee();if(i)return{ok:!0,printText:o,path:s};re.mkdirSync(ne.dirname(s),{recursive:!0});let c=re.existsSync(s)?T(s,""):"";if(c.includes(o.trim()))return{ok:!0,...m("present",{path:s,backup:null})};let l=(Ae(c).trimEnd()+`
13
+ `}function At(t){return t.replace(new RegExp(`${ot}[\\s\\S]*?${st}\\n?`,"g"),"")}async function J({oracleRoot:t,operator:r,withControl:e=!1,printOnly:i=!1}){let n=k({oracleRoot:t,operator:r,withControl:e});if(!n.ok)return{ok:!1,code:3,reason:n.reason};let o=Rt(n.specs),s=Et();if(i)return{ok:!0,printText:o,path:s};rt.mkdirSync(nt.dirname(s),{recursive:!0});let c=rt.existsSync(s)?$(s,""):"";if(c.includes(o.trim()))return{ok:!0,...m("present",{path:s,backup:null})};let l=(At(c).trimEnd()+`
14
14
 
15
- `+o).replace(/^\n+/,"");if(c.trim()===l.trim())return{ok:!0,...m("present",{path:s,backup:null})};let a=c?S(s):null;return R(s,l.endsWith(`
15
+ `+o).replace(/^\n+/,"");if(c.trim()===l.trim())return{ok:!0,...m("present",{path:s,backup:null})};let a=c?S(s):null;return E(s,l.endsWith(`
16
16
  `)?l:l+`
17
- `),{ok:!0,...m("written",{path:s,backup:a})}}import Le from"node:fs";import ie from"node:path";var H="ChatGPT is hosted and can NEVER sign or reach your keys. This connector is read/prepare only; anything it prepares is unsigned until you sign it locally.";function Ne(){return{openapi:"3.1.0",info:{title:"Oracle Public (read/prepare)",version:"1.0.0",description:"Secret-free public surface for hosted clients. "+H},servers:[{url:"https://REPLACE-WITH-YOUR-TUNNEL"}],paths:{"/public/health":{get:{operationId:"publicHealth",summary:"Health check",responses:{200:{description:"ok"}}}},"/public/config":{get:{operationId:"publicConfig",summary:"Public config",responses:{200:{description:"ok"}}}},"/public/connect/request":{post:{operationId:"connectRequest",summary:"Build a connect request (unsigned)",responses:{200:{description:"unsigned request artifact"}}}},"/public/connect/assemble":{post:{operationId:"connectAssemble",summary:"Assemble an unsigned grant artifact",responses:{200:{description:"unsigned grant artifact"}}}},"/public/grants/active":{post:{operationId:"grantsActive",summary:"List active grants (read)",responses:{200:{description:"ok"}}}},"/public/grants/get":{post:{operationId:"grantsGet",summary:"Get a grant by id (read)",responses:{200:{description:"ok"}}}}}}}async function W({printOnly:e=!1}={}){let r=Ne(),t=ie.join(g(),".config","oracle","connectors","chatgpt-openapi.json"),i=JSON.stringify(r,null,2)+`
18
- `;e||(Le.mkdirSync(ie.dirname(t),{recursive:!0}),R(t,i));let n=[H,"","Next steps:"," 1. oracle public serve"," 2. Expose 127.0.0.1:8799 through YOUR HTTPS tunnel (cloudflared, tailscale funnel, etc.)."," Oracle will not create tunnels for you."," 3. Paste the OpenAPI spec into a GPT Action, or add the tunnel URL as a developer-mode MCP connector.",e?"":` Spec written to: ${t}`].filter(Boolean).join(`
19
- `);return{ok:!0,...m(e?"printed":"written",{path:t,print:r,instructions:n,cannotSign:H})}}import B from"node:path";import ce from"node:os";function Ue(){return process.platform==="darwin"?B.join(ce.homedir(),"Library","Application Support","Cursor","User","globalStorage","mcp.json"):process.platform==="win32"?B.join(ce.homedir(),"AppData","Roaming","Cursor","User","globalStorage","mcp.json"):B.join(g(),".config","cursor","mcp.json")}async function G({oracleRoot:e,operator:r,withControl:t=!1,project:i=!1,printOnly:n=!1,cwd:o=process.cwd()}){let s=k({oracleRoot:e,operator:r,withControl:t});if(!s.ok)return{ok:!1,code:3,reason:s.reason};if(n)return{ok:!0,printText:['Add this to your Cursor MCP config (Cmd+Shift+P \u2192 "MCP: Open Configuration"):',JSON.stringify({mcpServers:s.specs},null,2)].join(`
17
+ `),{ok:!0,...m("written",{path:s,backup:a})}}import Lt from"node:fs";import it from"node:path";var M="ChatGPT is hosted and can NEVER sign or reach your keys. This connector is read/prepare only; anything it prepares is unsigned until you sign it locally.";function Nt(){return{openapi:"3.1.0",info:{title:"Oracle Public (read/prepare)",version:"1.0.0",description:"Secret-free public surface for hosted clients. "+M},servers:[{url:"https://REPLACE-WITH-YOUR-TUNNEL"}],paths:{"/public/health":{get:{operationId:"publicHealth",summary:"Health check",responses:{200:{description:"ok"}}}},"/public/config":{get:{operationId:"publicConfig",summary:"Public config",responses:{200:{description:"ok"}}}},"/public/connect/request":{post:{operationId:"connectRequest",summary:"Build a connect request (unsigned)",responses:{200:{description:"unsigned request artifact"}}}},"/public/connect/assemble":{post:{operationId:"connectAssemble",summary:"Assemble an unsigned grant artifact",responses:{200:{description:"unsigned grant artifact"}}}},"/public/grants/active":{post:{operationId:"grantsActive",summary:"List active grants (read)",responses:{200:{description:"ok"}}}},"/public/grants/get":{post:{operationId:"grantsGet",summary:"Get a grant by id (read)",responses:{200:{description:"ok"}}}}}}}async function H({printOnly:t=!1}={}){let r=Nt(),e=it.join(g(),".config","oracle","connectors","chatgpt-openapi.json"),i=JSON.stringify(r,null,2)+`
18
+ `;t||(Lt.mkdirSync(it.dirname(e),{recursive:!0}),E(e,i));let n=[M,"","Next steps:"," 1. oracle public serve"," 2. Expose 127.0.0.1:8799 through YOUR HTTPS tunnel (cloudflared, tailscale funnel, etc.)."," Oracle will not create tunnels for you."," 3. Paste the OpenAPI spec into a GPT Action, or add the tunnel URL as a developer-mode MCP connector.",t?"":` Spec written to: ${e}`].filter(Boolean).join(`
19
+ `);return{ok:!0,...m(t?"printed":"written",{path:e,print:r,instructions:n,cannotSign:M})}}import W from"node:path";import ct from"node:os";function Ut(){return process.platform==="darwin"?W.join(ct.homedir(),"Library","Application Support","Cursor","User","globalStorage","mcp.json"):process.platform==="win32"?W.join(ct.homedir(),"AppData","Roaming","Cursor","User","globalStorage","mcp.json"):W.join(g(),".config","cursor","mcp.json")}async function G({oracleRoot:t,operator:r,withControl:e=!1,project:i=!1,printOnly:n=!1,cwd:o=process.cwd()}){let s=k({oracleRoot:t,operator:r,withControl:e});if(!s.ok)return{ok:!1,code:3,reason:s.reason};if(n)return{ok:!0,printText:['Add this to your Cursor MCP config (Cmd+Shift+P \u2192 "MCP: Open Configuration"):',JSON.stringify({mcpServers:s.specs},null,2)].join(`
20
20
 
21
- `)};let c=Ue(),d=b(c,s.specs);return{ok:!0,...m(d.status,{path:c,backup:d.backup})}}import A from"node:path";import ae from"node:os";function Pe(){return process.platform==="darwin"?A.join(ae.homedir(),"Library","Application Support","Code","User","globalStorage","mcp.json"):process.platform==="win32"?A.join(ae.homedir(),"AppData","Roaming","Code","User","globalStorage","mcp.json"):A.join(g(),".config","Code","User","globalStorage","mcp.json")}function $e(e){return A.join(e||process.cwd(),".vscode","mcp.json")}async function K({oracleRoot:e,operator:r,withControl:t=!1,project:i=!1,printOnly:n=!1,cwd:o=process.cwd()}){let s=k({oracleRoot:e,operator:r,withControl:t});if(!s.ok)return{ok:!1,code:3,reason:s.reason};if(n)return{ok:!0,printText:["Add this to your VS Code MCP config (.vscode/mcp.json):",JSON.stringify({mcpServers:s.specs},null,2),"","Alternatively, add to VS Code settings.json:",`"mcp.servers": ${JSON.stringify(s.specs,null,2)}`].join(`
22
- `)};let c=i?$e(o):Pe(),d=b(c,s.specs);return{ok:!0,...m(d.status,{path:c,backup:d.backup})}}import{readFileSync as N,existsSync as v,writeFileSync as L,mkdirSync as ue}from"node:fs";import{join as y,dirname as Te}from"node:path";import{homedir as pe}from"node:os";var De=y(Te(new URL(import.meta.url).pathname),"..","..","..","profiles","oracle","SOUL.md");function Ie(){let e=[De,y(pe(),".config","oracle","SOUL.md")];for(let r of e)if(v(r))return N(r,"utf8");throw new Error("SOUL.md not found \u2014 run 'oracle bootstrap' first")}async function le(e,{cwd:r=process.cwd(),printOnly:t=!1}={}){let i=Ie();if(e==="claude-code"||e==="claude"){let n=y(r,"CLAUDE.md"),o=v(n)?N(n,"utf8"):"",s=`# Oracle Agent Instructions
21
+ `)};let c=Ut(),d=b(c,s.specs);return{ok:!0,...m(d.status,{path:c,backup:d.backup})}}import A from"node:path";import at from"node:os";function Pt(){return process.platform==="darwin"?A.join(at.homedir(),"Library","Application Support","Code","User","globalStorage","mcp.json"):process.platform==="win32"?A.join(at.homedir(),"AppData","Roaming","Code","User","globalStorage","mcp.json"):A.join(g(),".config","Code","User","globalStorage","mcp.json")}function $t(t){return A.join(t||process.cwd(),".vscode","mcp.json")}async function B({oracleRoot:t,operator:r,withControl:e=!1,project:i=!1,printOnly:n=!1,cwd:o=process.cwd()}){let s=k({oracleRoot:t,operator:r,withControl:e});if(!s.ok)return{ok:!1,code:3,reason:s.reason};if(n)return{ok:!0,printText:["Add this to your VS Code MCP config (.vscode/mcp.json):",JSON.stringify({mcpServers:s.specs},null,2),"","Alternatively, add to VS Code settings.json:",`"mcp.servers": ${JSON.stringify(s.specs,null,2)}`].join(`
22
+ `)};let c=i?$t(o):Pt(),d=b(c,s.specs);return{ok:!0,...m(d.status,{path:c,backup:d.backup})}}import{readFileSync as N,existsSync as O,writeFileSync as L,mkdirSync as ut}from"node:fs";import{join as y,dirname as Tt}from"node:path";import{homedir as pt}from"node:os";var Dt=y(Tt(new URL(import.meta.url).pathname),"..","..","..","profiles","oracle","SOUL.md");function It(){let t=[Dt,y(pt(),".config","oracle","SOUL.md")];for(let r of t)if(O(r))return N(r,"utf8");throw new Error("SOUL.md not found \u2014 run 'oracle bootstrap' first")}async function lt(t,{cwd:r=process.cwd(),printOnly:e=!1}={}){let i=It();if(t==="claude-code"||t==="claude"){let n=y(r,"CLAUDE.md"),o=O(n)?N(n,"utf8"):"",s=`# Oracle Agent Instructions
23
23
  ${i}
24
24
  ---
25
- ${o}`;if(t)return{ok:!0,printText:`# Would write to ${n}:
25
+ ${o}`;if(e)return{ok:!0,printText:`# Would write to ${n}:
26
26
 
27
- ${s.slice(0,500)}...`,status:"printed"};let c=S(n);return L(n,s,"utf8"),{ok:!0,path:n,backup:c,status:"installed"}}if(e==="cursor"){let n=y(r,".cursorrules"),o=v(n)?N(n,"utf8"):"",s=`# Oracle Agent Instructions
27
+ ${s.slice(0,500)}...`,status:"printed"};let c=S(n);return L(n,s,"utf8"),{ok:!0,path:n,backup:c,status:"installed"}}if(t==="cursor"){let n=y(r,".cursorrules"),o=O(n)?N(n,"utf8"):"",s=`# Oracle Agent Instructions
28
28
  ${i}
29
29
  ---
30
- ${o}`;if(t)return{ok:!0,printText:`# Would write to ${n}:
30
+ ${o}`;if(e)return{ok:!0,printText:`# Would write to ${n}:
31
31
 
32
- ${s.slice(0,500)}...`,status:"printed"};let c=S(n);return L(n,s,"utf8"),{ok:!0,path:n,backup:c,status:"installed"}}if(e==="claude-desktop"){let n=y(pe(),"Library","Application Support","Claude","claude_desktop_config.json");if(!v(n))return{ok:!1,reason:"Claude Desktop config not found. Open Claude Desktop once first, then retry."};let o=D(n);if(t)return{ok:!0,printText:`# Would add Oracle SOUL to Claude Desktop custom instructions
32
+ ${s.slice(0,500)}...`,status:"printed"};let c=S(n);return L(n,s,"utf8"),{ok:!0,path:n,backup:c,status:"installed"}}if(t==="claude-desktop"){let n=y(pt(),"Library","Application Support","Claude","claude_desktop_config.json");if(!O(n))return{ok:!1,reason:"Claude Desktop config not found. Open Claude Desktop once first, then retry."};let o=T(n);if(e)return{ok:!0,printText:`# Would add Oracle SOUL to Claude Desktop custom instructions
33
33
 
34
34
  ${i.slice(0,500)}...`,status:"printed"};let s=S(n);return o.customInstructions=o.customInstructions||"",o.customInstructions=`# Oracle Agent Instructions
35
35
  ${i}
36
36
  ---
37
- ${o.customInstructions}`,I(n,o),{ok:!0,path:n,backup:s,status:"installed"}}if(e==="codex"||e==="copilot"){let n=y(r,".github"),o=y(n,"copilot-instructions.md"),s=v(o)?N(o,"utf8"):"";if(t)return{ok:!0,printText:`# Would write to ${o}:
37
+ ${o.customInstructions}`,D(n,o),{ok:!0,path:n,backup:s,status:"installed"}}if(t==="codex"||t==="copilot"){let n=y(r,".github"),o=y(n,"copilot-instructions.md"),s=O(o)?N(o,"utf8"):"";if(e)return{ok:!0,printText:`# Would write to ${o}:
38
38
 
39
- ${i.slice(0,500)}...`,status:"printed"};v(n)||ue(n,{recursive:!0});let c=S(o);return L(o,`${i}
39
+ ${i.slice(0,500)}...`,status:"printed"};O(n)||ut(n,{recursive:!0});let c=S(o);return L(o,`${i}
40
40
  ---
41
- ${s}`,"utf8"),{ok:!0,path:o,backup:c,status:"installed"}}if(e==="vscode"||e==="vs-code"){let n=y(r,".vscode"),o=y(n,"instructions.md");if(t)return{ok:!0,printText:`# Would write to ${o}:
41
+ ${s}`,"utf8"),{ok:!0,path:o,backup:c,status:"installed"}}if(t==="vscode"||t==="vs-code"){let n=y(r,".vscode"),o=y(n,"instructions.md");if(e)return{ok:!0,printText:`# Would write to ${o}:
42
42
 
43
- ${i.slice(0,500)}...`,status:"printed"};v(n)||ue(n,{recursive:!0});let s=S(o);return L(o,`${i}
44
- `,"utf8"),{ok:!0,path:o,backup:s,status:"installed"}}return{ok:!1,reason:`--with-soul not supported for target '${e}'`}}function U(){process.stderr.write(`usage: oracle mcp <install|print> [target] [flags]
43
+ ${i.slice(0,500)}...`,status:"printed"};O(n)||ut(n,{recursive:!0});let s=S(o);return L(o,`${i}
44
+ `,"utf8"),{ok:!0,path:o,backup:s,status:"installed"}}return{ok:!1,reason:`--with-soul not supported for target '${t}'`}}function U(){process.stderr.write(`usage: oracle mcp <install|print> [target] [flags]
45
45
  targets: claude-code | claude-desktop | codex | copilot | chatgpt | cursor | vscode | generic
46
46
  flags: --with-control --with-soul --project --print --json
47
- `)}function C(e,{json:r=!1}={}){if(e.print&&!e.instructions?process.stdout.write(JSON.stringify(e.print,null,2)+`
48
- `):e.printText&&process.stdout.write(e.printText),e.instructions&&(process.stdout.write(e.instructions+`
49
- `),e.print&&r&&process.stdout.write(JSON.stringify(e.print,null,2)+`
50
- `)),!e.print&&!e.printText&&!e.instructions){let t={status:e.status,path:e.path||null,backup:e.backup||null,method:e.method||null};process.stdout.write((r?JSON.stringify(t,null,2):`${t.status}${t.path?" "+t.path:""}`)+`
51
- `)}}var Gt={name:"mcp",summary:"wire Oracle into AI clients",group:"read",usage:"oracle mcp install <target> [--with-control] [--with-soul] | oracle mcp print [--target <t>] | oracle mcp watchdog [--once]",async run(e){let r=e.argv[0];if(!r||r==="--help"||r==="-h")return U(),r?0:1;if(r==="watchdog"){let{spawn:a}=await import("node:child_process"),f=await import("node:path"),p=e.argv.includes("--once"),w=f.join(e.root,"bin","oracle-mcp-watchdog.mjs");return a(process.execPath,[w,...p?["--once"]:[]],{stdio:"inherit",detached:!0}).unref(),0}let t,i;try{({values:t,positionals:i}=Fe({args:e.argv.slice(1),options:{"with-control":{type:"boolean",default:!1},"with-soul":{type:"boolean",default:!1},project:{type:"boolean",default:!1},print:{type:"boolean",default:!1},json:{type:"boolean",default:!1},target:{type:"string"}},allowPositionals:!0,strict:!1}))}catch(a){return process.stderr.write(`oracle mcp: ${a.message}
52
- `),U(),1}let n=!!t["with-control"],o=!!t["with-soul"],s=!!t.project,c=!!t.json,d=e.resolveOperator?e.resolveOperator():{ok:!1};if(n&&(!d||!d.ok))return _(process.stderr),3;let l={oracleRoot:e.root,operator:d,withControl:n,project:s,cwd:process.cwd()};if(r==="print"){let a=t.target||i[0]||"claude-code";if(a==="generic"||a==="claude-code"){let f=k(l);return f.ok?(process.stdout.write(JSON.stringify({mcpServers:f.specs},null,2)+`
53
- `),0):(_(process.stderr),3)}if(a==="chatgpt"){let f=await W({printOnly:!0});return C(f,{json:c}),0}return a==="codex"||a==="copilot"?(C(await M({...l,printOnly:!0}),{json:c}),0):a==="claude-desktop"?(C(await J({...l,printOnly:!0}),{json:c}),0):a==="cursor"?(C(await G({...l,printOnly:!0}),{json:c}),0):a==="vscode"||a==="vs-code"?(C(await K({...l,printOnly:!0}),{json:c}),0):(process.stderr.write(`oracle mcp: unknown target '${a}'
54
- `),1)}if(r==="install"){let a=i[0]||t.target;if(!a)return U(),1;let f=!!t.print,p;if(a==="claude-code")p=await te({...l,printOnly:f});else if(a==="claude-desktop")p=await J({...l,printOnly:f});else if(a==="codex"||a==="copilot")p=await M({...l,printOnly:f});else if(a==="chatgpt")p=await W({printOnly:f});else if(a==="cursor")p=await G({...l,printOnly:f});else if(a==="vscode"||a==="vs-code")p=await K({...l,printOnly:f});else if(a==="generic"){let w=k(l);return w.ok?(process.stdout.write(JSON.stringify({mcpServers:w.specs},null,2)+`
55
- `),0):(_(process.stderr),3)}else return process.stderr.write(`oracle mcp: unknown target '${a}'
56
- `),1;if(!p.ok)return p.code===3?_(process.stderr):process.stderr.write(`oracle mcp: ${p.reason||"failed"}
57
- `),p.code||1;if(C(p,{json:c}),o){let w=await le(a,{cwd:process.cwd(),printOnly:f});w.ok?process.stderr.write(` soul \u2192 ${w.path||"injected"}
47
+ `)}function x(t,{json:r=!1}={}){if(t.print&&!t.instructions?process.stdout.write(JSON.stringify(t.print,null,2)+`
48
+ `):t.printText&&process.stdout.write(t.printText),t.instructions&&(process.stdout.write(t.instructions+`
49
+ `),t.print&&r&&process.stdout.write(JSON.stringify(t.print,null,2)+`
50
+ `)),!t.print&&!t.printText&&!t.instructions){let e={status:t.status,path:t.path||null,backup:t.backup||null,method:t.method||null};process.stdout.write((r?JSON.stringify(e,null,2):`${e.status}${e.path?" "+e.path:""}`)+`
51
+ `)}}var Be={name:"mcp",summary:"wire Oracle into AI clients",group:"read",usage:"oracle mcp install <target> [--with-control] [--with-soul] | oracle mcp print [--target <t>] | oracle mcp watchdog [--once]",async run(t){let r=t.argv[0];if(!r||r==="--help"||r==="-h")return U(),r?0:1;if(r==="watchdog"){let{spawn:a}=await import("node:child_process"),f=await import("node:path"),p=t.argv.includes("--once"),w=f.join(t.root,"bin","oracle-mcp-watchdog.mjs");return a(process.execPath,[w,...p?["--once"]:[]],{stdio:"inherit",detached:!0}).unref(),0}let e,i;try{({values:e,positionals:i}=Ft({args:t.argv.slice(1),options:{"with-control":{type:"boolean",default:!1},"with-soul":{type:"boolean",default:!1},project:{type:"boolean",default:!1},print:{type:"boolean",default:!1},json:{type:"boolean",default:!1},target:{type:"string"}},allowPositionals:!0,strict:!1}))}catch(a){return process.stderr.write(`oracle mcp: ${a.message}
52
+ `),U(),1}let n=!!e["with-control"],o=!!e["with-soul"],s=!!e.project,c=!!e.json,d=t.resolveOperator?t.resolveOperator():{ok:!1};if(n&&(!d||!d.ok))return C(process.stderr),3;let l={oracleRoot:t.root,operator:d,withControl:n,project:s,cwd:process.cwd()};if(r==="print"){let a=e.target||i[0]||"claude-code";if(a==="generic"||a==="claude-code"){let f=k(l);return f.ok?(process.stdout.write(JSON.stringify({mcpServers:f.specs},null,2)+`
53
+ `),0):(C(process.stderr),3)}if(a==="chatgpt"){let f=await H({printOnly:!0});return x(f,{json:c}),0}return a==="codex"||a==="copilot"?(x(await J({...l,printOnly:!0}),{json:c}),0):a==="claude-desktop"?(x(await F({...l,printOnly:!0}),{json:c}),0):a==="cursor"?(x(await G({...l,printOnly:!0}),{json:c}),0):a==="vscode"||a==="vs-code"?(x(await B({...l,printOnly:!0}),{json:c}),0):(process.stderr.write(`oracle mcp: unknown target '${a}'
54
+ `),1)}if(r==="install"){let a=i[0]||e.target;if(!a)return U(),1;let f=!!e.print,p;if(a==="claude-code")p=await et({...l,printOnly:f});else if(a==="claude-desktop")p=await F({...l,printOnly:f});else if(a==="codex"||a==="copilot")p=await J({...l,printOnly:f});else if(a==="chatgpt")p=await H({printOnly:f});else if(a==="cursor")p=await G({...l,printOnly:f});else if(a==="vscode"||a==="vs-code")p=await B({...l,printOnly:f});else if(a==="generic"){let w=k(l);return w.ok?(process.stdout.write(JSON.stringify({mcpServers:w.specs},null,2)+`
55
+ `),0):(C(process.stderr),3)}else return process.stderr.write(`oracle mcp: unknown target '${a}'
56
+ `),1;if(!p.ok)return p.code===3?C(process.stderr):process.stderr.write(`oracle mcp: ${p.reason||"failed"}
57
+ `),p.code||1;if(x(p,{json:c}),o){let w=await lt(a,{cwd:process.cwd(),printOnly:f});w.ok?process.stderr.write(` soul \u2192 ${w.path||"injected"}
58
58
  `):process.stderr.write(` soul: ${w.reason||"failed"}
59
59
  `)}return p.status&&String(p.status).startsWith("printed")&&p.print&&process.stdout.write(JSON.stringify(p.print,null,2)+`
60
- `),0}return U(),1}};export{Gt as default};
60
+ `),0}return U(),1}};export{Be as default};